From 08923297e9ff89a3235461d311beda97bbfbf22b Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 4 Feb 2025 12:21:06 +0100 Subject: [PATCH 001/512] Only register_interop_behavior() for datetime & time when they are imported * Otherwise just loading polyglot has the heavy cost of loading datetime too. * This way the interop behavior is defined regardless of whether `import polyglot` was done (without relying on polyglot to be loaded at startup). --- .../builtins/modules/TimeModuleBuiltins.java | 7 +- graalpython/lib-graalpython/_polyglot.py | 65 +------------- .../lib-graalpython/_polyglot_datetime.py | 60 +++++++++++++ graalpython/lib-graalpython/_polyglot_time.py | 84 +++++++++++++++++++ graalpython/lib-python/3/datetime.py | 2 + 5 files changed, 153 insertions(+), 65 deletions(-) create mode 100644 graalpython/lib-graalpython/_polyglot_datetime.py create mode 100644 graalpython/lib-graalpython/_polyglot_time.py diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java index 46bd74525e..6eec222635 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -49,6 +49,7 @@ import java.util.List; import java.util.TimeZone; +import com.oracle.graal.python.nodes.statement.AbstractImportNode; import org.graalvm.nativeimage.ImageInfo; import com.oracle.graal.python.annotations.ArgumentClinic; @@ -153,6 +154,7 @@ public final class TimeModuleBuiltins extends PythonBuiltins { public static final TruffleString T_DAYLIGHT = tsLiteral("daylight"); public static final TruffleString T_TIMEZONE = tsLiteral("timezone"); public static final TruffleString T_ALTZONE = tsLiteral("altzone"); + public static final TruffleString T_POLYGLOT_TIME = tsLiteral("_polyglot_time"); @Override protected List> getNodeFactories() { @@ -192,6 +194,9 @@ public void postInitialize(Python3Core core) { int rawOffsetSeconds = defaultTimeZone.getRawOffset() / -1000; timeModule.setAttribute(T_TIMEZONE, rawOffsetSeconds); timeModule.setAttribute(T_ALTZONE, rawOffsetSeconds - 3600); + + // register_interop_behavior() for time.struct_time + AbstractImportNode.importModule(T_POLYGLOT_TIME); } @TruffleBoundary diff --git a/graalpython/lib-graalpython/_polyglot.py b/graalpython/lib-graalpython/_polyglot.py index caf9cebdc0..770575c8a8 100644 --- a/graalpython/lib-graalpython/_polyglot.py +++ b/graalpython/lib-graalpython/_polyglot.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, 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 @@ -37,9 +37,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import datetime import polyglot -import time def interop_type(foreign_class, allow_method_overwrites=False): @@ -112,37 +110,6 @@ def wrapper(python_class): setattr(polyglot, "interop_behavior", interop_behavior) -def _date_time_tz(dt: datetime.datetime): - if dt.tzinfo is not None: - utcoffset = dt.tzinfo.utcoffset(dt) - return utcoffset.days * 3600 * 24 + utcoffset.seconds - raise polyglot.UnsupportedMessage - - -def _struct_time_tz(st: time.struct_time): - if st.tm_gmtoff is not None: - return st.tm_gmtoff - return st.tm_zone - - -polyglot.register_interop_behavior(datetime.time, - is_time=True, as_time=lambda d: (d.hour, d.minute, d.second, d.microsecond), - is_time_zone=lambda t: t.tzinfo is not None, as_time_zone=_date_time_tz) - -polyglot.register_interop_behavior(datetime.date, - is_date=True, as_date=lambda d: (d.year, d.month, d.day)) - -polyglot.register_interop_behavior(datetime.datetime, - is_date=True, as_date=lambda d: (d.year, d.month, d.day), - is_time=True, as_time=lambda d: (d.hour, d.minute, d.second, d.microsecond), - is_time_zone=lambda t: t.tzinfo is not None, as_time_zone=_date_time_tz) - -polyglot.register_interop_behavior(time.struct_time, - is_date=True, as_date=lambda t: (t.tm_year, t.tm_mon, t.tm_mday), - is_time=True, as_time=lambda t: (t.tm_hour, t.tm_min, t.tm_sec, 0), - is_time_zone=lambda t: t.tm_zone is not None or t.tm_gmtoff is not None, - as_time_zone=_struct_time_tz) - # loading arrow structures on demand def __getattr__(name): if name == "arrow": @@ -153,33 +120,3 @@ def __getattr__(name): setattr(polyglot, "__getattr__", __getattr__) setattr(polyglot, "__path__", ".") - -# example extending time.struct_time using the decorator wrapper -# -# @polyglot.interop_behavior(time.struct_time) -# class StructTimeInteropBehavior: -# @staticmethod -# def is_date(t): -# return True -# -# @staticmethod -# def as_date(t): -# return t.tm_year, t.tm_mon, t.tm_mday -# -# @staticmethod -# def is_time(t): -# return True -# -# @staticmethod -# def as_time(t): -# return t.tm_hour, t.tm_min, t.tm_sec, 0 -# -# @staticmethod -# def is_time_zone(t): -# return t.tm_zone is not None or t.tm_gmtoff is not None -# -# @staticmethod -# def as_time_zone(t): -# if t.tm_gmtoff is not None: -# return t.tm_gmtoff -# return t.tm_zone diff --git a/graalpython/lib-graalpython/_polyglot_datetime.py b/graalpython/lib-graalpython/_polyglot_datetime.py new file mode 100644 index 0000000000..80f73a74de --- /dev/null +++ b/graalpython/lib-graalpython/_polyglot_datetime.py @@ -0,0 +1,60 @@ +# Copyright (c) 2023, 2025, 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. + +import datetime +import polyglot + +def _date_time_tz(dt: datetime.datetime): + if dt.tzinfo is not None: + utcoffset = dt.tzinfo.utcoffset(dt) + return utcoffset.days * 3600 * 24 + utcoffset.seconds + raise polyglot.UnsupportedMessage + + +polyglot.register_interop_behavior(datetime.time, + is_time=True, as_time=lambda d: (d.hour, d.minute, d.second, d.microsecond), + is_time_zone=lambda t: t.tzinfo is not None, as_time_zone=_date_time_tz) + +polyglot.register_interop_behavior(datetime.date, + is_date=True, as_date=lambda d: (d.year, d.month, d.day)) + +polyglot.register_interop_behavior(datetime.datetime, + is_date=True, as_date=lambda d: (d.year, d.month, d.day), + is_time=True, as_time=lambda d: (d.hour, d.minute, d.second, d.microsecond), + is_time_zone=lambda t: t.tzinfo is not None, as_time_zone=_date_time_tz) diff --git a/graalpython/lib-graalpython/_polyglot_time.py b/graalpython/lib-graalpython/_polyglot_time.py new file mode 100644 index 0000000000..ed4dc0fc54 --- /dev/null +++ b/graalpython/lib-graalpython/_polyglot_time.py @@ -0,0 +1,84 @@ +# Copyright (c) 2023, 2025, 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. + +import time +import polyglot + + +def _struct_time_tz(st: time.struct_time): + if st.tm_gmtoff is not None: + return st.tm_gmtoff + return st.tm_zone + + +polyglot.register_interop_behavior(time.struct_time, + is_date=True, as_date=lambda t: (t.tm_year, t.tm_mon, t.tm_mday), + is_time=True, as_time=lambda t: (t.tm_hour, t.tm_min, t.tm_sec, 0), + is_time_zone=lambda t: t.tm_zone is not None or t.tm_gmtoff is not None, + as_time_zone=_struct_time_tz) + +# example extending time.struct_time using the decorator wrapper +# +# @polyglot.interop_behavior(time.struct_time) +# class StructTimeInteropBehavior: +# @staticmethod +# def is_date(t): +# return True +# +# @staticmethod +# def as_date(t): +# return t.tm_year, t.tm_mon, t.tm_mday +# +# @staticmethod +# def is_time(t): +# return True +# +# @staticmethod +# def as_time(t): +# return t.tm_hour, t.tm_min, t.tm_sec, 0 +# +# @staticmethod +# def is_time_zone(t): +# return t.tm_zone is not None or t.tm_gmtoff is not None +# +# @staticmethod +# def as_time_zone(t): +# if t.tm_gmtoff is not None: +# return t.tm_gmtoff +# return t.tm_zone diff --git a/graalpython/lib-python/3/datetime.py b/graalpython/lib-python/3/datetime.py index e284a733ef..c564969464 100644 --- a/graalpython/lib-python/3/datetime.py +++ b/graalpython/lib-python/3/datetime.py @@ -2642,3 +2642,5 @@ def _name_from_offset(delta): # appropriate to maintain a single module level docstring and # remove the following line. from _datetime import __doc__ + +import _polyglot_datetime # GraalPy change: register interop behavior on datetime as soon as datetime is defined From 8bfdf1009e64b046eca9051381bafbd7bc668d85 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 4 Feb 2025 12:27:08 +0100 Subject: [PATCH 002/512] Let PolyglotModuleBuiltins#postInitialize load _polyglot.py and don't force to load polyglot at startup --- .../src/com/oracle/graal/python/builtins/Python3Core.java | 3 --- .../python/builtins/modules/PolyglotModuleBuiltins.java | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index 97405a14f7..3146f1acf9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -1083,9 +1083,6 @@ public void run() { } } - // import polyglot decorators and special interop predefined behavior - loadFile(toTruffleStringUncached("_polyglot"), getContext().getCoreHomeOrFail()); - initialized = true; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java index a6656c2793..b414152f0d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java @@ -113,6 +113,7 @@ import com.oracle.graal.python.nodes.interop.InteropBehaviorMethod; import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.GetForeignObjectClassNode; +import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; @@ -161,6 +162,7 @@ public final class PolyglotModuleBuiltins extends PythonBuiltins { private static final TruffleString T_MODIFIABLE = tsLiteral("modifiable"); private static final TruffleString T_INVOKABLE = tsLiteral("invokable"); private static final TruffleString T_INTERNAL = tsLiteral("internal"); + private static final TruffleString T_INTERNAL_POLYGLOT_MODULE = tsLiteral("_polyglot"); @Override protected List> getNodeFactories() { @@ -189,6 +191,9 @@ public void postInitialize(Python3Core core) { super.postInitialize(core); GetForeignObjectClassNode.getUncached().defineSingleTraitClasses(core.getContext()); + + // import polyglot decorators which are defined in Python code + AbstractImportNode.importModule(T_INTERNAL_POLYGLOT_MODULE); } @Builtin(name = "import_value", minNumOfPositionalArgs = 1, parameterNames = {"name"}) From 54b306398f2846076247a5dd03b0f3fe4232a894 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 4 Feb 2025 13:34:39 +0100 Subject: [PATCH 003/512] Modules need to be under lib-graalpython/modules to be found by import --- .../freeze_modules.py | 8 +++++--- .../builtins/objects/module/FrozenModules.java | 14 ++++++++++---- .../lib-graalpython/{ => modules}/_polyglot.py | 0 .../{ => modules}/_polyglot_datetime.py | 0 .../{ => modules}/_polyglot_time.py | 0 5 files changed, 15 insertions(+), 7 deletions(-) rename graalpython/lib-graalpython/{ => modules}/_polyglot.py (100%) rename graalpython/lib-graalpython/{ => modules}/_polyglot_datetime.py (100%) rename graalpython/lib-graalpython/{ => modules}/_polyglot_time.py (100%) diff --git a/graalpython/com.oracle.graal.python.frozen/freeze_modules.py b/graalpython/com.oracle.graal.python.frozen/freeze_modules.py index c08d654cd6..3da7439318 100644 --- a/graalpython/com.oracle.graal.python.frozen/freeze_modules.py +++ b/graalpython/com.oracle.graal.python.frozen/freeze_modules.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, 2024, Oracle and/or its affiliates. +# Copyright (c) 2021, 2025, Oracle and/or its affiliates. # Copyright (C) 1996-2020 Python Software Foundation # # Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -105,13 +105,15 @@ def add_graalpython_core(): l.append("polyglot.arrow : polyglot.arrow = " + os.path.join(lib_graalpython, "modules/_polyglot_arrow.py")) for name in [ "modules/_sysconfigdata", + "modules/_polyglot", + "modules/_polyglot_datetime", + "modules/_polyglot_time", ]: modname = os.path.basename(name) modpath = os.path.join(lib_graalpython, f"{name}.py") l.append(f"{modname} : {modname} = {modpath}") for name in [ "__graalpython__", - "_polyglot", "_sre", "_sysconfig", "_weakref", @@ -495,7 +497,7 @@ def lower_camel_case(str): # write frozen files FROZEN_MODULES_HEADER = """/* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/FrozenModules.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/FrozenModules.java index ad7000fa5e..ba3867f90f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/FrozenModules.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/FrozenModules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -218,8 +218,10 @@ private static final class Map { private static final PythonFrozenModule FROZEN_ONLY = new PythonFrozenModule("FROZEN_ONLY", null, false); private static final PythonFrozenModule POLYGLOT_ARROW = new PythonFrozenModule("POLYGLOT_ARROW", null, false); private static final PythonFrozenModule _SYSCONFIGDATA = new PythonFrozenModule("_SYSCONFIGDATA", null, false); + private static final PythonFrozenModule _POLYGLOT = new PythonFrozenModule("_POLYGLOT", null, false); + private static final PythonFrozenModule _POLYGLOT_DATETIME = new PythonFrozenModule("_POLYGLOT_DATETIME", null, false); + private static final PythonFrozenModule _POLYGLOT_TIME = new PythonFrozenModule("_POLYGLOT_TIME", null, false); private static final PythonFrozenModule GRAALPY___GRAALPYTHON__ = new PythonFrozenModule("GRAALPY___GRAALPYTHON__", null, false); - private static final PythonFrozenModule GRAALPY__POLYGLOT = new PythonFrozenModule("GRAALPY__POLYGLOT", null, false); private static final PythonFrozenModule GRAALPY__SRE = new PythonFrozenModule("GRAALPY__SRE", null, false); private static final PythonFrozenModule GRAALPY__SYSCONFIG = new PythonFrozenModule("GRAALPY__SYSCONFIG", null, false); private static final PythonFrozenModule GRAALPY__WEAKREF = new PythonFrozenModule("GRAALPY__WEAKREF", null, false); @@ -595,10 +597,14 @@ public static final PythonFrozenModule lookup(String name) { return Map.POLYGLOT_ARROW; case "_sysconfigdata": return Map._SYSCONFIGDATA; + case "_polyglot": + return Map._POLYGLOT; + case "_polyglot_datetime": + return Map._POLYGLOT_DATETIME; + case "_polyglot_time": + return Map._POLYGLOT_TIME; case "graalpy.__graalpython__": return Map.GRAALPY___GRAALPYTHON__; - case "graalpy._polyglot": - return Map.GRAALPY__POLYGLOT; case "graalpy._sre": return Map.GRAALPY__SRE; case "graalpy._sysconfig": diff --git a/graalpython/lib-graalpython/_polyglot.py b/graalpython/lib-graalpython/modules/_polyglot.py similarity index 100% rename from graalpython/lib-graalpython/_polyglot.py rename to graalpython/lib-graalpython/modules/_polyglot.py diff --git a/graalpython/lib-graalpython/_polyglot_datetime.py b/graalpython/lib-graalpython/modules/_polyglot_datetime.py similarity index 100% rename from graalpython/lib-graalpython/_polyglot_datetime.py rename to graalpython/lib-graalpython/modules/_polyglot_datetime.py diff --git a/graalpython/lib-graalpython/_polyglot_time.py b/graalpython/lib-graalpython/modules/_polyglot_time.py similarity index 100% rename from graalpython/lib-graalpython/_polyglot_time.py rename to graalpython/lib-graalpython/modules/_polyglot_time.py From cea4899d01c51068978b53293150877009fdd19e Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 4 Feb 2025 14:35:03 +0100 Subject: [PATCH 004/512] graalpy -v should not override Truffle log level * It's a CPython-compatible flag and should only set the Python flag, not touch log levels. * Otherwise `graalpy --log.level=FINE -v ...` is actually at INFO and not FINE level which is very confusing. --- .../src/com/oracle/graal/python/shell/GraalPythonMain.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java index f0a6328d1f..68ba6b5ccc 100644 --- a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java +++ b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java @@ -778,9 +778,6 @@ protected void launch(Builder contextBuilder) { contextBuilder.option("python.IntMaxStrDigits", Integer.toString(intMaxStrDigits)); } contextBuilder.option("python.DontWriteBytecodeFlag", Boolean.toString(dontWriteBytecode)); - if (verboseFlag) { - contextBuilder.option("log.python.level", "INFO"); - } contextBuilder.option("python.QuietFlag", Boolean.toString(quietFlag)); contextBuilder.option("python.NoUserSiteFlag", Boolean.toString(noUserSite)); contextBuilder.option("python.NoSiteFlag", Boolean.toString(noSite)); From 4c2f7e77c865c48eece12c9980c25adb23c6b9db Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Mon, 10 Feb 2025 11:17:33 +0100 Subject: [PATCH 005/512] [GR-62055] Increase timeout for shared engine tests since they are slow under jacoco. --- .../engine/SharedEngineMultithreadingTestBase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java index 3972dac6d0..6230ef9a34 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java @@ -117,7 +117,9 @@ protected static void submitAndWaitAll(ExecutorService service, Task[] tasks) th boolean wasTimeout = false; for (Future future : futures) { try { - future.get(2, TimeUnit.MINUTES); + // Under coverage, some of these tests are almost 10x slower, + // so we go with a 15min timeout + future.get(15, TimeUnit.MINUTES); } catch (TimeoutException e) { wasTimeout = true; } From 32ca5355f5bdbd8781003cc8fd3eef1d20afb8b7 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Mon, 10 Feb 2025 11:32:36 +0100 Subject: [PATCH 006/512] [GR-62058] Try harder to get coverage on windows --- mx.graalpython/mx_graalpython.py | 53 ++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index 7f98cfa7e3..7f00af0ec6 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -1563,6 +1563,30 @@ def graalpython_gate_runner(args, tasks): "com.oracle.graal.python.test.advanced.ExclusionsTest" ]) + if WIN32 and is_collecting_coverage(): + mx.log("Ask for shutdown of any remaining graalpy.exe processes") + # On windows, the jacoco command can fail if the file is still locked + # by lingering test processes, so we try to give it a bit of a cleanup + mx.run([ + 'taskkill.exe', + '/T', # with children + '/IM', + 'graalpy.exe', + ], nonZeroIsFatal=False) + time.sleep(2) + mx.log("Forcefully terminate any remaining graalpy.exe processes") + mx.run([ + 'taskkill.exe', + '/F', # force + '/T', # with children + '/IM', + 'graalpy.exe', + ], nonZeroIsFatal=False) + # Forcefully killing processes on Windows does not release file + # locks immediately, so we still need to sleep for a bit in the + # hopes that the OS will release + time.sleep(8) + mx_gate.add_gate_runner(SUITE, graalpython_gate_runner) @@ -2398,25 +2422,16 @@ def python_coverage(args): '--strict-mode', '--tags', args.tags, ] + jacoco_args, env=env) - # On windows, the command can fail if the file is still locked by lingering test processes - retries = 3 if WIN32 else 1 - while True: - retval = mx.run_mx([ - '--strict-compliance', - '--kill-with-sigquit', - 'jacocoreport', - '--format', 'lcov', - '--omit-excluded', - 'coverage', - '--generic-paths', - '--exclude-src-gen', - ], env=env) - if retval == 0: - break - retries -= 1 - if not retries: - sys.exit("Failed to collect coverage report") - time.sleep(10) + mx.run_mx([ + '--strict-compliance', + '--kill-with-sigquit', + 'jacocoreport', + '--format', 'lcov', + '--omit-excluded', + 'coverage', + '--generic-paths', + '--exclude-src-gen', + ], env=env) if args.mode == 'truffle': executable = graalpy_standalone_jvm() From 437b0938483977c2ef8e1b77a0d174c1e77cab23 Mon Sep 17 00:00:00 2001 From: Fengyun Liu Date: Mon, 9 Dec 2024 16:39:48 +0100 Subject: [PATCH 007/512] Update overlay --- ci.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.jsonnet b/ci.jsonnet index 60791dfb90..0afcce4291 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "bfb3f7fd7d0d4df846dad9d87dfa10d7a79dfd8b" } +{ "overlay": "ac2b03008a765064fba41da97cbcd096f6d19809" } From 378e4360cdf77473a6a96a77698bb2c3e2e3d649 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 5 Feb 2025 13:22:01 +0100 Subject: [PATCH 008/512] Add test to track modules being imported during startup --- .../src/tests/test_startup.py | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/test_startup.py diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py b/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py new file mode 100644 index 0000000000..5e0fb21c8a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py @@ -0,0 +1,90 @@ +# Copyright (c) 2025, 2025, 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. + +import unittest +import sys +import re +import subprocess +import platform + +# Both lists should remain as small as possible to avoid adding overhead to startup +expected_nosite_startup_modules = [ + '_frozen_importlib', + '_frozen_importlib_external', + 'builtins', + '__graalpython__', + '_weakref', + 'unicodedata', + '_sre', + '_sysconfig', + 'java', + 'pip_hook', +] + +expected_full_startup_modules = expected_nosite_startup_modules + [ + '_abc', + 'types', + '_weakrefset', + '_py_abc', + 'abc', + 'stat', + '_collections_abc', + 'genericpath', + *(['_winapi', 'ntpath'] if platform.system() == 'Windows' else ['posixpath']), + 'os', + '_sitebuiltins', + '_io', + 'io', + 'site', +] + +class StartupTests(unittest.TestCase): + @unittest.skipUnless(sys.implementation.name == 'graalpy', "GraalPy-specific test") + def test_startup_nosite(self): + result = subprocess.check_output([sys.executable, '--log.level=FINE', '-S', '-v', '-c', 'print("Hello")'], stderr=subprocess.STDOUT, text=True) + assert 'Hello' in result + imports = re.findall("import '(\S+)'", result) + self.assertEqual(expected_nosite_startup_modules, imports) + + @unittest.skipUnless(sys.implementation.name == 'graalpy', "GraalPy-specific test") + def test_startup_full(self): + result = subprocess.check_output([sys.executable, '--log.level=FINE', '-v', '-c', 'print("Hello")'], stderr=subprocess.STDOUT, text=True) + assert 'Hello' in result + imports = re.findall("import '(\S+)'", result) + self.assertEqual(expected_full_startup_modules, imports) From eeea32fbe692bf47f66624c5abcb1ba212d0ef21 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 12 Feb 2025 16:08:54 +0100 Subject: [PATCH 009/512] Fix int-to-double conversion in int.__pow__ with negative exponent Fixes #473 --- .../src/tests/test_int.py | 26 ++++++++++++++++++- .../builtins/objects/ints/IntBuiltins.java | 16 ++++++------ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_int.py b/graalpython/com.oracle.graal.python.test/src/tests/test_int.py index e1b4104d77..897b2588b5 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_int.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_int.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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,6 +42,8 @@ import array +from tests.util import assert_raises + BIG_NUMBER = 99999937497465632974931 class _NamedIntConstant(int): @@ -118,6 +120,28 @@ def test_bigint_mul(): assert 99999937497465632974931 * (2**100) == 126764980791447734004805377032945185921379990352429056 +def test_pow(): + assert 2 ** 10 == 1024 + assert type(2 ** -1) is float + assert 2 ** -1 == 0.5 + assert_raises(ValueError, pow, 2, 2, 0) + + assert pow(2, 10, 1) == 0 + assert pow(2, 10, 3) == 1 + assert pow(2, 10, -3) == -2 + + assert 18446744073709551616 ** 2 == 340282366920938463463374607431768211456 + assert type(18446744073709551616 ** -1) is float + assert 18446744073709551616 ** -1 == 5.421010862427522e-20 + assert_raises(OverflowError, pow, 2**80000, -1) + assert_raises(OverflowError, pow, 2**80000, -(2**64)) + assert_raises(ZeroDivisionError, pow, 0, -18446744073709551616) + + assert_raises(ValueError, pow, 18446744073709551616, 2, 0) + assert pow(18446744073709551616, 2, 7) == 4 + assert pow(18446744073709551616, 2, -3) == -2 + + def test_int_from_custom(): class CustomInt4(): def __int__(self): diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index e2a653ee65..e902954f4c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -1202,10 +1202,11 @@ PInt doPLPos(PInt left, long right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Shared("leftIsZero") @Cached InlinedConditionProfile leftIsZero, @Shared @Cached PRaiseNode.Lazy raiseNode) { - if (leftIsZero.profile(inliningTarget, left.isZero())) { + double leftDouble = PInt.doubleValueWithOverflow(this, left.getValue()); + if (leftIsZero.profile(inliningTarget, leftDouble == 0.0)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } - return TrueDivNode.op(this, BigInteger.ONE, op(left.getValue(), -right)); + return Math.pow(leftDouble, right); } @Specialization @@ -1358,14 +1359,13 @@ private Object op(BigInteger left, BigInteger right) { // we'll raise unless left is one of the shortcut values return op(left, Long.MAX_VALUE); } - } else if (left.signum() == 0) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } else { - try { - return Math.pow(left.longValueExact(), right.longValueExact()); - } catch (ArithmeticException e) { - return Math.pow(left.doubleValue(), right.doubleValue()); + double leftDouble = PInt.doubleValueWithOverflow(this, left); + double rightDouble = PInt.doubleValueWithOverflow(this, right); + if (leftDouble == 0.0) { + throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } + return Math.pow(leftDouble, rightDouble); } } From 9513ba0e62f5e9aa80edf3cb9ceda3945ed75a0a Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 12 Feb 2025 17:14:52 +0100 Subject: [PATCH 010/512] Increase precision of integer truediv Fixes #474 --- .../oracle/graal/python/builtins/objects/ints/IntBuiltins.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index e902954f4c..576bf3526d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -601,7 +601,7 @@ static double doPP(PInt left, PInt right, */ @TruffleBoundary private static double op(Node raisingNode, BigInteger a, BigInteger b) { - final int precisionOfDouble = 17; + final int precisionOfDouble = 18; if (fitsIntoDouble(a) && fitsIntoDouble(b)) { return a.doubleValue() / b.doubleValue(); } From 0fd8c5232d2eef5b7cab6a3ed5e5d8b9757e1063 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 12 Feb 2025 17:38:33 +0100 Subject: [PATCH 011/512] Handle corner case in int.to_bytes Fixes #475 --- graalpython/com.oracle.graal.python.test/src/tests/test_int.py | 1 + .../oracle/graal/python/builtins/objects/ints/IntBuiltins.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_int.py b/graalpython/com.oracle.graal.python.test/src/tests/test_int.py index 897b2588b5..625a9a8be9 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_int.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_int.py @@ -800,6 +800,7 @@ def test_UnsignedLittleEndian(self): def test_SpecialCases(self): self.assertEqual((0).to_bytes(0, 'big'), b'') + self.assertEqual((-1).to_bytes(0, 'big', signed=True), b'') self.assertEqual((1).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x01') self.assertEqual((0).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x00') self.assertEqual((-1).to_bytes(5, 'big', signed=True), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index 576bf3526d..2e4ee5d9a8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -2651,7 +2651,7 @@ public static byte[] fromLong(long self, int byteCount, boolean isBigEndian, boo index += delta; } - if (overflowProfile.profile(inliningTarget, !signed && number != 0 || (signed && bytes.length == 1 && bytes[0] != self) || (byteCount == 0 && self != 0))) { + if (overflowProfile.profile(inliningTarget, !signed && number != 0 || (signed && bytes.length == 1 && bytes[0] != self) || (byteCount == 0 && self != 0 && self != -1))) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.MESSAGE_INT_TO_BIG); } From 32323b8241d0e1d8e2b6fec7e485c198c8c6ac97 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Mon, 10 Feb 2025 16:55:14 +0100 Subject: [PATCH 012/512] Add nb_power slot --- .../oracle/graal/python/annotations/Slot.java | 2 + .../graal/python/processor/SlotsMapping.java | 2 + .../src/tests/cpyext/test_tp_slots.py | 13 +- .../builtins/modules/BuiltinFunctions.java | 25 +- .../cext/PythonCextAbstractBuiltins.java | 16 +- .../objects/cext/capi/PyProcsWrapper.java | 100 ++++++-- .../objects/cext/capi/SlotMethodDef.java | 16 +- .../objects/cext/capi/ToNativeTypeNode.java | 1 - .../cext/hpy/GraalHPyArithmeticNode.java | 64 +---- .../cext/hpy/GraalHPyContextFunctions.java | 9 +- .../objects/complex/ComplexBuiltins.java | 7 +- .../objects/floats/FloatBuiltins.java | 19 +- .../foreign/ForeignNumberBuiltins.java | 34 ++- .../builtins/objects/ints/IntBuiltins.java | 5 +- .../objects/type/SpecialMethodSlot.java | 16 -- .../python/builtins/objects/type/TpSlots.java | 97 +++++--- .../slots/BuiltinSlotWrapperSignature.java | 2 +- .../objects/type/slots/TpSlotBinaryOp.java | 67 ++--- .../objects/type/slots/TpSlotNbPower.java | 230 ++++++++++++++++++ .../graal/python/lib/CallBinaryOp1Node.java | 8 +- .../graal/python/lib/CallTernaryOpNode.java | 132 ++++++++++ .../graal/python/lib/PyNumberAddNode.java | 6 +- .../graal/python/lib/PyNumberAndNode.java | 4 +- .../graal/python/lib/PyNumberDivmodNode.java | 4 +- .../python/lib/PyNumberFloorDivideNode.java | 4 +- .../graal/python/lib/PyNumberLshiftNode.java | 4 +- .../lib/PyNumberMatrixMultiplyNode.java | 4 +- .../python/lib/PyNumberMultiplyNode.java | 6 +- .../graal/python/lib/PyNumberOrNode.java | 4 +- .../graal/python/lib/PyNumberPowerNode.java | 109 +++++++++ .../python/lib/PyNumberRemainderNode.java | 4 +- .../graal/python/lib/PyNumberRshiftNode.java | 4 +- .../python/lib/PyNumberSubtractNode.java | 4 +- .../python/lib/PyNumberTrueDivideNode.java | 4 +- .../graal/python/lib/PyNumberXorNode.java | 4 +- .../graal/python/lib/PySequenceConcat.java | 6 +- .../graal/python/nodes/ErrorMessages.java | 2 +- .../nodes/expression/BinaryArithmetic.java | 15 +- 38 files changed, 743 insertions(+), 310 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryOpNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index bf54294c82..4d9f5c834d 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -135,6 +135,8 @@ enum SlotKind { nb_true_divide("__truediv__, __rtruediv__"), /** foo @ bar */ nb_matrix_multiply("__matmul__, __rmatmul__"), + /** foo ** bar */ + nb_power("__pow__, __rpow__"), /** sequence length/size */ sq_length("__len__"), /** sequence item: read element at index */ diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index 14ed5b28f2..a9281af8b7 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -56,6 +56,7 @@ static String getSlotBaseClass(Slot s) { case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> "TpSlotBinaryOp.TpSlotBinaryOpBuiltin"; + case nb_power -> "TpSlotNbPower.TpSlotNbPowerBuiltin"; case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat"; case sq_length, mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix(s.isComplex()); case sq_item, sq_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin"; @@ -77,6 +78,7 @@ static String getSlotNodeBaseClass(Slot s) { case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode"; + case nb_power -> "com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode"; case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode"; case sq_length, mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode"; case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode"; diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index 28af6b6bd9..0a7479f806 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -859,13 +859,12 @@ def __rmatmul__(self, other): assert 2 % obj == 2 assert divmod(obj, 2) == (1, 1) assert divmod(2, obj) == (0, 2) - # TODO fix on graalpy - # assert obj ** 2 == 9 - # assert 2 ** obj == 8 - # assert pow(obj, 2, 2) == 1 - # if isinstance(obj.delegate, int): # pow doesn't call __rpow__ - # assert pow(2, obj, 2) == 0 - # assert pow(2, 2, obj) == 1 + assert obj ** 2 == 9 + assert 2 ** obj == 8 + assert pow(obj, 2, 2) == 1 + if isinstance(obj.delegate, int): # pow doesn't call __rpow__ + assert pow(2, obj, 2) == 0 + assert pow(2, 2, obj) == 1 assert -obj == -3 assert +obj == 3 assert abs(obj) == 3 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 45dcd1c6a2..83bb3b2291 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -171,6 +171,7 @@ import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyNumberDivmodNode; import com.oracle.graal.python.lib.PyNumberIndexNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyObjectAsciiNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectDir; @@ -211,14 +212,10 @@ import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.expression.TernaryArithmetic; import com.oracle.graal.python.nodes.frame.GetFrameLocalsNode; import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -2119,26 +2116,12 @@ private int getDebuggerSessionCount() { @Builtin(name = J_POW, minNumOfPositionalArgs = 2, numOfPositionalOnlyArgs = 0, parameterNames = {"base", "exp", "mod"}) @GenerateNodeFactory public abstract static class PowNode extends PythonTernaryBuiltinNode { - @NeverDefault - static BinaryOpNode binaryPow() { - return BinaryArithmetic.Pow.create(); - } - - @NeverDefault - static LookupAndCallTernaryNode ternaryPow() { - return TernaryArithmetic.Pow.create(); - } @Specialization - Object binary(VirtualFrame frame, Object x, Object y, @SuppressWarnings("unused") PNone z, - @Cached("binaryPow()") BinaryOpNode powNode) { - return powNode.executeObject(frame, x, y); - } - - @Specialization(guards = "!isPNone(z)") Object ternary(VirtualFrame frame, Object x, Object y, Object z, - @Cached("ternaryPow()") LookupAndCallTernaryNode powNode) { - return powNode.execute(frame, x, y, z); + @Bind("this") Node inliningTarget, + @Cached PyNumberPowerNode power) { + return power.execute(frame, inliningTarget, x, y, z); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index d16ba20a8d..05d971d18c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -109,6 +109,7 @@ import com.oracle.graal.python.lib.PyNumberIndexNode; import com.oracle.graal.python.lib.PyNumberLongNode; import com.oracle.graal.python.lib.PyNumberMultiplyNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectGetItem; @@ -132,7 +133,6 @@ import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.expression.InplaceArithmetic; import com.oracle.graal.python.nodes.expression.LookupAndCallInplaceNode; -import com.oracle.graal.python.nodes.expression.TernaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; @@ -452,16 +452,10 @@ abstract static class PyNumber_Power extends CApiTernaryBuiltinNode { @Child private LookupAndCallTernaryNode callNode; @Specialization - Object doGeneric(Object o1, Object o2, Object o3) { - return ensureCallNode().execute(null, o1, o2, o3); - } - - private LookupAndCallTernaryNode ensureCallNode() { - if (callNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callNode = insert(TernaryArithmetic.Pow.create()); - } - return callNode; + Object doGeneric(Object o1, Object o2, Object o3, + @Bind("this") Node inliningTarget, + @Cached PyNumberPowerNode powerNode) { + return powerNode.execute(null, inliningTarget, o1, o2, o3); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java index 5686c9aebc..66a8204fd9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java @@ -51,19 +51,21 @@ import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.TransformExceptionToNativeNode; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.ints.PInt; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotManaged; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.CallSlotBinaryOpNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.CallSlotDescrGet; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet.CallSlotDescrSet; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.CallManagedSlotGetAttrNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.CallSlotNbBoolNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.CallSlotMpAssSubscriptNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.CallManagedSlotSetAttrNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.CallSlotSqAssItemNode; @@ -300,63 +302,63 @@ protected String getSignature() { @ExportLibrary(InteropLibrary.class) public static final class BinaryOpSlotFuncWrapper extends TpSlotWrapper { - private final BinaryOpSlot binaryOp; + private final ReversibleSlot binaryOp; - public BinaryOpSlotFuncWrapper(TpSlotManaged delegate, BinaryOpSlot binaryOp) { + public BinaryOpSlotFuncWrapper(TpSlotManaged delegate, ReversibleSlot binaryOp) { super(delegate); this.binaryOp = binaryOp; } public static BinaryOpSlotFuncWrapper createAdd(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_ADD); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_ADD); } public static BinaryOpSlotFuncWrapper createSubtract(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_SUBTRACT); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_SUBTRACT); } public static BinaryOpSlotFuncWrapper createMultiply(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_MULTIPLY); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_MULTIPLY); } public static BinaryOpSlotFuncWrapper createRemainder(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_REMAINDER); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_REMAINDER); } public static BinaryOpSlotFuncWrapper createLShift(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_LSHIFT); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_LSHIFT); } public static BinaryOpSlotFuncWrapper createRShift(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_RSHIFT); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_RSHIFT); } public static BinaryOpSlotFuncWrapper createAnd(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_AND); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_AND); } public static BinaryOpSlotFuncWrapper createXor(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_XOR); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_XOR); } public static BinaryOpSlotFuncWrapper createOr(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_OR); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_OR); } public static BinaryOpSlotFuncWrapper createFloorDivide(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_FLOOR_DIVIDE); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_FLOOR_DIVIDE); } public static BinaryOpSlotFuncWrapper createTrueDivide(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_TRUE_DIVIDE); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_TRUE_DIVIDE); } public static BinaryOpSlotFuncWrapper createDivMod(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_DIVMOD); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_DIVMOD); } public static BinaryOpSlotFuncWrapper createMatrixMultiply(TpSlotManaged delegate) { - return new BinaryOpSlotFuncWrapper(delegate, BinaryOpSlot.NB_MATRIX_MULTIPLY); + return new BinaryOpSlotFuncWrapper(delegate, ReversibleSlot.NB_MATRIX_MULTIPLY); } @ExportMessage @@ -745,9 +747,9 @@ protected String getSignature() { } @ExportLibrary(InteropLibrary.class) - public static final class TernaryFunctionWrapper extends PyProcsWrapper { + public static final class CallFunctionWrapper extends PyProcsWrapper { - public TernaryFunctionWrapper(Object delegate) { + public CallFunctionWrapper(Object delegate) { super(delegate); } @@ -755,7 +757,7 @@ public TernaryFunctionWrapper(Object delegate) { static class Execute { @Specialization(guards = "arguments.length == 3") - static Object call(TernaryFunctionWrapper self, Object[] arguments, + static Object call(CallFunctionWrapper self, Object[] arguments, @Bind("this") Node inliningTarget, @Cached ExecutePositionalStarargsNode posStarargsNode, @Cached ExpandKeywordStarargsNode expandKwargsNode, @@ -779,7 +781,7 @@ static Object call(TernaryFunctionWrapper self, Object[] arguments, Object result = callNode.execute(null, self.getDelegate(), pArgs, kwArgsArray); return toNativeNode.execute(result); } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "TernaryFunctionWrapper", self.getDelegate()); + throw checkThrowableBeforeNative(t, "CallFunctionWrapper", self.getDelegate()); } } catch (PException e) { transformExceptionToNativeNode.execute(inliningTarget, e); @@ -791,7 +793,7 @@ static Object call(TernaryFunctionWrapper self, Object[] arguments, } @Specialization(guards = "arguments.length != 3") - static Object error(@SuppressWarnings("unused") TernaryFunctionWrapper self, Object[] arguments) throws ArityException { + static Object error(@SuppressWarnings("unused") CallFunctionWrapper self, Object[] arguments) throws ArityException { CompilerDirectives.transferToInterpreterAndInvalidate(); throw ArityException.create(3, 3, arguments.length); } @@ -803,6 +805,62 @@ protected String getSignature() { } } + @ExportLibrary(InteropLibrary.class) + public static final class NbPowerWrapper extends TpSlotWrapper { + + public NbPowerWrapper(TpSlotManaged delegate) { + super(delegate); + } + + @Override + public TpSlotWrapper cloneWith(TpSlotManaged slot) { + return new NbPowerWrapper(slot); + } + + @ExportMessage + static Object execute(NbPowerWrapper self, Object[] arguments, + @Bind("$node") Node inliningTarget, + @Cached NativeToPythonNode toJavaNode, + @Cached PythonToNativeNewRefNode toNativeNode, + @Cached TransformExceptionToNativeNode transformExceptionToNativeNode, + @Cached GetClassNode vGetClassNode, + @Cached GetClassNode wGetClassNode, + @Cached IsSameTypeNode isSameTypeNode, + @Cached GetCachedTpSlotsNode wGetSlots, + @Cached TpSlotNbPower.CallSlotNbPowerNode callSlot, + @Cached GilNode gil) { + boolean mustRelease = gil.acquire(); + CApiTiming.enter(); + try { + try { + // convert args + Object v = toJavaNode.execute(arguments[0]); + Object w = toJavaNode.execute(arguments[1]); + Object z = toJavaNode.execute(arguments[2]); + Object vType = vGetClassNode.execute(inliningTarget, v); + Object wType = wGetClassNode.execute(inliningTarget, w); + TpSlots wSlots = wGetSlots.execute(inliningTarget, wType); + boolean sameTypes = isSameTypeNode.execute(inliningTarget, vType, wType); + Object result = callSlot.execute(null, inliningTarget, self.getSlot(), v, vType, w, wSlots.nb_power(), wType, z, sameTypes); + return toNativeNode.execute(result); + } catch (Throwable t) { + throw checkThrowableBeforeNative(t, "NbPowerWrapper", self.getDelegate()); + } + } catch (PException e) { + transformExceptionToNativeNode.execute(inliningTarget, e); + return PythonContext.get(gil).getNativeNull(); + } finally { + CApiTiming.exit(self.timing); + gil.release(mustRelease); + } + } + + @Override + protected String getSignature() { + return "(POINTER,POINTER,POINTER):POINTER"; + } + } + @ExportLibrary(InteropLibrary.class) public static final class RichcmpFunctionWrapper extends PyProcsWrapper { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java index 1ecf3c2994..1b0fb038d6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java @@ -55,7 +55,6 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_subtract; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_true_divide; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_xor; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_power; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_hash; @@ -85,7 +84,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUFFLE_RICHCOMPARE__; @@ -94,7 +92,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.HashfuncWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InitWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.RichcmpFunctionWrapper; -import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.TernaryFunctionWrapper; +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.CallFunctionWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.UnaryFuncLegacyWrapper; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.type.MethodsFlags; @@ -103,7 +101,7 @@ import com.oracle.truffle.api.strings.TruffleString; public enum SlotMethodDef { - TP_CALL(PyTypeObject__tp_call, T___CALL__, TernaryFunctionWrapper::new), + TP_CALL(PyTypeObject__tp_call, T___CALL__, CallFunctionWrapper::new), TP_HASH(PyTypeObject__tp_hash, T___HASH__, HashfuncWrapper::new), TP_INIT(PyTypeObject__tp_init, T___INIT__, InitWrapper::new), TP_ITER(PyTypeObject__tp_iter, T___ITER__, PyProcsWrapper.UnaryFuncLegacyWrapper::new), @@ -116,7 +114,7 @@ public enum SlotMethodDef { AM_AITER(PyAsyncMethods__am_aiter, T___AITER__, UnaryFuncLegacyWrapper::new, MethodsFlags.AM_AITER), AM_ANEXT(PyAsyncMethods__am_anext, T___ANEXT__, PyProcsWrapper.UnaryFuncLegacyWrapper::new, MethodsFlags.AM_ANEXT), // (mq) AM_SEND is an internal function and mostly called from within AWAIT, AITER, ANEXT. - /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, TernaryFunctionWrapper::new, MethodsFlags.AM_SEND), */ + /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, CallFunctionWrapper::new, MethodsFlags.AM_SEND), */ NB_INPLACE_ADD(PyNumberMethods__nb_inplace_add, T___IADD__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_ADD), NB_INPLACE_AND(PyNumberMethods__nb_inplace_and, T___IAND__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_AND), @@ -124,13 +122,12 @@ public enum SlotMethodDef { NB_INPLACE_LSHIFT(PyNumberMethods__nb_inplace_lshift, T___ILSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_LSHIFT), NB_INPLACE_MULTIPLY(PyNumberMethods__nb_inplace_multiply, T___IMUL__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_MULTIPLY), NB_INPLACE_OR(PyNumberMethods__nb_inplace_or, T___IOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_OR), - NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, TernaryFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER), + NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER), NB_INPLACE_REMAINDER(PyNumberMethods__nb_inplace_remainder, T___IMOD__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_REMAINDER), NB_INPLACE_RSHIFT(PyNumberMethods__nb_inplace_rshift, T___IRSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_RSHIFT), NB_INPLACE_SUBTRACT(PyNumberMethods__nb_inplace_subtract, T___ISUB__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_SUBTRACT), NB_INPLACE_TRUE_DIVIDE(PyNumberMethods__nb_inplace_true_divide, T___ITRUEDIV__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_TRUE_DIVIDE), - NB_INPLACE_XOR(PyNumberMethods__nb_inplace_xor, T___IXOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_XOR), - NB_POWER(PyNumberMethods__nb_power, T___POW__, TernaryFunctionWrapper::new, MethodsFlags.NB_POWER); + NB_INPLACE_XOR(PyNumberMethods__nb_inplace_xor, T___IXOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_XOR); public final TruffleString methodName; public final Function wrapperFactory; @@ -174,8 +171,7 @@ public enum SlotMethodDef { NB_INPLACE_RSHIFT, NB_INPLACE_SUBTRACT, NB_INPLACE_TRUE_DIVIDE, - NB_INPLACE_XOR, - NB_POWER); + NB_INPLACE_XOR); } private static void initGroup(CFields typeField, SlotMethodDef... slots) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index eeb0deee13..3d2ffcb5fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -163,7 +163,6 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_subtract, getSlot(obj, SlotMethodDef.NB_INPLACE_SUBTRACT)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_true_divide, getSlot(obj, SlotMethodDef.NB_INPLACE_TRUE_DIVIDE)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_xor, getSlot(obj, SlotMethodDef.NB_INPLACE_XOR)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_power, getSlot(obj, SlotMethodDef.NB_POWER)); return mem; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java index b8ee9ed5cf..1c01a5fdd6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,12 +44,10 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.nodes.call.GenericInvokeNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.expression.InplaceArithmetic; import com.oracle.graal.python.nodes.expression.LookupAndCallInplaceNode; -import com.oracle.graal.python.nodes.expression.TernaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -179,66 +177,6 @@ public boolean isAdoptable() { } } - public abstract static class HPyTernaryArithmeticNode extends Node { - - public abstract Object execute(Object arg0, Object arg1, Object arg2); - - @NeverDefault - public static HPyTernaryArithmeticNode create(TernaryArithmetic operator) { - return new HPyTernaryArithmeticCached(operator); - } - - public static HPyTernaryArithmeticNode getUncached(TernaryArithmetic operator) { - return HPyTernaryArithmeticUncached.UNCACHEDS[operator.ordinal()]; - } - } - - private static final class HPyTernaryArithmeticCached extends HPyTernaryArithmeticNode { - @Child private LookupAndCallTernaryNode opNode; - - private HPyTernaryArithmeticCached(TernaryArithmetic operator) { - opNode = operator.create(); - } - - @Override - public Object execute(Object arg0, Object arg1, Object arg2) { - return opNode.execute(null, arg0, arg1, arg2); - } - } - - private static final class HPyTernaryArithmeticUncached extends HPyTernaryArithmeticNode { - final TernaryArithmetic operator; - - public HPyTernaryArithmeticUncached(TernaryArithmetic operator) { - this.operator = operator; - } - - @TruffleBoundary - @Override - public Object execute(Object arg0, Object arg1, Object arg2) { - Object[] pythonArguments = PArguments.create(3); - PArguments.setArgument(pythonArguments, 0, arg0); - PArguments.setArgument(pythonArguments, 1, arg1); - PArguments.setArgument(pythonArguments, 2, arg2); - RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); - return GenericInvokeNode.invokeUncached(callTarget, pythonArguments); - } - - @Override - public boolean isAdoptable() { - return false; - } - - private static final HPyTernaryArithmeticUncached[] UNCACHEDS; - static { - TernaryArithmetic[] values = TernaryArithmetic.values(); - UNCACHEDS = new HPyTernaryArithmeticUncached[values.length]; - for (int i = 0; i < values.length; i++) { - UNCACHEDS[i] = new HPyTernaryArithmeticUncached(values[i]); - } - } - } - public abstract static class HPyInplaceArithmeticNode extends Node { public abstract Object execute(Object arg0, Object arg1, Object arg2); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java index dcbf20b84b..d988655d42 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java @@ -97,7 +97,6 @@ import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ReadUnicodeArrayNode; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyBinaryArithmeticNode; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyInplaceArithmeticNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyTernaryArithmeticNode; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyUnaryArithmeticNode; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyASCIINodeGen; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAbsoluteNodeGen; @@ -312,6 +311,7 @@ import com.oracle.graal.python.lib.PyLongAsDoubleNode; import com.oracle.graal.python.lib.PyNumberCheckNode; import com.oracle.graal.python.lib.PyNumberIndexNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyObjectDelItem; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectGetAttrO; @@ -345,7 +345,6 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.InplaceArithmetic; -import com.oracle.graal.python.nodes.expression.TernaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryArithmetic; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; @@ -1021,13 +1020,13 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ar @HPyContextFunction("ctx_Power") @GenerateUncached - @ImportStatic(TernaryArithmetic.class) public abstract static class GraalHPyPower extends HPyQuaternaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, Object arg2, - @Cached(parameters = "Pow") HPyTernaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1, arg2); + @Bind("this") Node inliningTarget, + @Cached PyNumberPowerNode powerNode) { + return powerNode.execute(null, inliningTarget, arg0, arg1, arg2); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java index 1a2d47ab09..ae48d00b1a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java @@ -52,9 +52,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___RPOW__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ZeroDivisionError; @@ -524,14 +522,11 @@ static Object doComplex(Object leftObj, Object rightObj, } } - @Builtin(name = J___RPOW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3, reverseOperation = true) - @Builtin(name = J___POW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3) - @TypeSystemReference(PythonArithmeticTypes.class) + @Slot(value = SlotKind.nb_power, isComplex = true) @GenerateNodeFactory abstract static class PowerNode extends PythonTernaryBuiltinNode { @Specialization - @InliningCutoff static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unused") PNone mod, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexLeft, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java index eadc01ee34..385c5254f5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java @@ -40,10 +40,8 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; import static com.oracle.graal.python.runtime.formatting.FormattingUtils.validateForFloat; @@ -77,10 +75,10 @@ import com.oracle.graal.python.lib.PyFloatCheckNode; import com.oracle.graal.python.lib.PyLongFromDoubleNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallVarargsNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; @@ -343,8 +341,7 @@ protected Object op(double a, double b) { } } - @Builtin(name = J___RPOW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3, reverseOperation = true) - @Builtin(name = J___POW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3) + @Slot(value = SlotKind.nb_power, isComplex = true) @GenerateNodeFactory public abstract static class PowNode extends PythonTernaryBuiltinNode { protected abstract double executeDouble(VirtualFrame frame, double left, double right, PNone none) throws UnexpectedResultException; @@ -398,7 +395,7 @@ private static double doOperation(Node inliningTarget, double left, double right @InliningCutoff static double doDD(VirtualFrame frame, double left, double right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, - @Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow, + @Shared @Cached PyNumberPowerNode powerNode, @Shared @Cached PRaiseNode.Lazy raiseNode) throws UnexpectedResultException { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { return 1.0; @@ -407,7 +404,7 @@ static double doDD(VirtualFrame frame, double left, double right, @SuppressWarni CompilerDirectives.transferToInterpreterAndInvalidate(); // Negative numbers raised to fractional powers become complex. PythonObjectFactory factory = PythonObjectFactory.getUncached(); - throw new UnexpectedResultException(callPow.execute(frame, factory.createComplex(left, 0), factory.createComplex(right, 0), none)); + throw new UnexpectedResultException(powerNode.execute(frame, inliningTarget, factory.createComplex(left, 0), factory.createComplex(right, 0), none)); } return Math.pow(left, right); } @@ -416,7 +413,7 @@ static double doDD(VirtualFrame frame, double left, double right, @SuppressWarni @InliningCutoff static Object doDDToComplex(VirtualFrame frame, double left, double right, PNone none, @Bind("this") Node inliningTarget, - @Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow, + @Shared @Cached PyNumberPowerNode powerNode, @Exclusive @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { @@ -425,7 +422,7 @@ static Object doDDToComplex(VirtualFrame frame, double left, double right, PNone if (left < 0 && Double.isFinite(left) && Double.isFinite(right) && (right % 1 != 0)) { // Negative numbers raised to fractional powers become complex. PythonObjectFactory pof = factory.get(inliningTarget); - return callPow.execute(frame, pof.createComplex(left, 0), pof.createComplex(right, 0), none); + return powerNode.execute(frame, inliningTarget, pof.createComplex(left, 0), pof.createComplex(right, 0), none); } return Math.pow(left, right); } @@ -435,7 +432,7 @@ static Object doDDToComplex(VirtualFrame frame, double left, double right, PNone static Object doGeneric(VirtualFrame frame, Object left, Object right, Object mod, @Bind("this") Node inliningTarget, @Cached CastToJavaDoubleNode castToJavaDoubleNode, - @Shared("powCall") @Cached("create(Pow)") LookupAndCallTernaryNode callPow, + @Shared @Cached PyNumberPowerNode powerNode, @Exclusive @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (!(mod instanceof PNone)) { @@ -449,7 +446,7 @@ static Object doGeneric(VirtualFrame frame, Object left, Object right, Object mo } catch (CannotCastException e) { return PNotImplemented.NOT_IMPLEMENTED; } - return doDDToComplex(frame, leftDouble, rightDouble, PNone.NONE, inliningTarget, callPow, factory, raiseNode); + return doDDToComplex(frame, leftDouble, rightDouble, PNone.NONE, inliningTarget, powerNode, factory, raiseNode); } public static PowNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index fdc2923be2..86ef886d58 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -34,10 +34,8 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -50,6 +48,7 @@ import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; +import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.builtins.objects.foreign.ForeignObjectBuiltins.ForeignGetattrNode; @@ -72,6 +71,7 @@ import com.oracle.graal.python.lib.PyNumberNegativeNode; import com.oracle.graal.python.lib.PyNumberOrNode; import com.oracle.graal.python.lib.PyNumberPositiveNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyNumberRemainderNode; import com.oracle.graal.python.lib.PyNumberRshiftNode; import com.oracle.graal.python.lib.PyNumberSubtractNode; @@ -87,6 +87,7 @@ import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; @@ -570,19 +571,26 @@ static Object doIt(VirtualFrame frame, Object left, Object right, } } - @Builtin(name = J___POW__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_power, isComplex = true) @GenerateNodeFactory - abstract static class PowNode extends ForeignBinaryNode { - PowNode() { - super(BinaryArithmetic.Pow.create(), false); - } - } + abstract static class PowNode extends PythonTernaryBuiltinNode { - @Builtin(name = J___RPOW__, minNumOfPositionalArgs = 2) - @GenerateNodeFactory - abstract static class RPowNode extends ForeignBinaryNode { - RPowNode() { - super(BinaryArithmetic.Pow.create(), true); + @Specialization + static Object doIt(VirtualFrame frame, Object v, Object w, Object z, + @Bind("this") Node inliningTarget, + @Cached UnboxNode unboxV, + @Cached UnboxNode unboxW, + @Cached UnboxNode unboxZ, + @Cached PyNumberPowerNode power) { + v = unboxV.execute(inliningTarget, v); + w = unboxW.execute(inliningTarget, w); + if (!(z instanceof PNone)) { + z = unboxZ.execute(inliningTarget, z); + } + if (v == null || w == null || z == null) { + return PNotImplemented.NOT_IMPLEMENTED; + } + return power.execute(frame, inliningTarget, v, w, z); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index e2a653ee65..aa0e2a7605 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -51,10 +51,8 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUFFLE_RICHCOMPARE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; @@ -1085,8 +1083,7 @@ public static MulNode create() { } } - @Builtin(name = J___RPOW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3, reverseOperation = true) - @Builtin(name = J___POW__, minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 3) + @Slot(value = SlotKind.nb_power, isComplex = true) @GenerateNodeFactory @TypeSystemReference(PythonArithmeticTypes.class) @ImportStatic(MathGuards.class) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java index 127007bb91..6e3969706a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java @@ -45,7 +45,6 @@ import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.AM_AWAIT; import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.NB_INPLACE_ADD; import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.NB_INPLACE_MULTIPLY; -import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.NB_POWER; import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.SQ_CONTAINS; import static com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot.Flags.NO_BUILTIN_DESCRIPTORS; import static com.oracle.graal.python.nodes.HiddenAttr.METHODS_FLAGS; @@ -78,11 +77,9 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SET_NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUBCLASSCHECK__; @@ -194,8 +191,6 @@ public enum SpecialMethodSlot { Gt(T___GT__), Ge(T___GE__), - Pow(T___POW__, NB_POWER), - RPow(T___RPOW__, NB_POWER), Round(T___ROUND__), IAdd(T___IADD__, NB_INPLACE_ADD), @@ -250,7 +245,6 @@ static class Flags { } static { - Pow.reverse = RPow; assert checkFind(); assert checkReverseSlots(); } @@ -876,16 +870,6 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin return Round; } break; - case 'p' * 26 + 'o': // po - if (eqNode.execute(name, T___POW__, TS_ENCODING)) { - return Pow; - } - break; - case 'r' * 26 + 'p': // rp - if (eqNode.execute(name, T___RPOW__, TS_ENCODING)) { - return RPow; - } - break; case 'i' * 26 + 'a': // ia if (eqNode.execute(name, T___IADD__, TS_ENCODING)) { return IAdd; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index 914fbec3ce..c984c2a92d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -65,6 +65,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEG__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POS__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RAND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RDIVMOD__; @@ -74,6 +75,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RRSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSUB__; @@ -113,6 +115,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.GetAttrWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InquiryWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.LenfuncWrapper; +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbPowerWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.ObjobjargWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SetattrWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SsizeargfuncSlotWrapper; @@ -141,7 +144,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotBinaryFuncBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotSqConcat; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotBinaryOpBuiltin; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotBinaryOpPython; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotReversiblePython; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.TpSlotDescrGetBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet.TpSlotDescrSetBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet.TpSlotDescrSetPython; @@ -151,6 +154,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.TpSlotLenBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.TpSlotMpAssSubscriptBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.TpSlotMpAssSubscriptPython; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.TpSlotNbPowerBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.TpSlotSetAttrBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.TpSlotSetAttrPython; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin; @@ -258,6 +262,7 @@ public record TpSlots(TpSlot nb_bool, // TpSlot nb_true_divide, // TpSlot nb_divmod, // TpSlot nb_matrix_multiply, // + TpSlot nb_power, // TpSlot sq_length, // TpSlot sq_item, // TpSlot sq_ass_item, // @@ -422,7 +427,7 @@ public enum TpSlotMeta { UnaryFuncWrapper::new), NB_ADD( TpSlots::nb_add, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_add, @@ -430,7 +435,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createAdd), NB_SUBTRACT( TpSlots::nb_subtract, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_subtract, @@ -438,7 +443,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createSubtract), NB_MULTIPLY( TpSlots::nb_multiply, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_multiply, @@ -446,7 +451,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createMultiply), NB_REMAINDER( TpSlots::nb_remainder, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_remainder, @@ -454,7 +459,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createRemainder), NB_LSHIFT( TpSlots::nb_lshift, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_lshift, @@ -462,7 +467,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createLShift), NB_RSHIFT( TpSlots::nb_rshift, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_rshift, @@ -470,7 +475,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createRShift), NB_AND( TpSlots::nb_and, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_and, @@ -478,7 +483,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createAnd), NB_XOR( TpSlots::nb_xor, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_xor, @@ -486,7 +491,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createXor), NB_OR( TpSlots::nb_or, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_or, @@ -494,7 +499,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createOr), NB_FLOOR_DIVIDE( TpSlots::nb_floor_divide, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_floor_divide, @@ -502,7 +507,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createFloorDivide), NB_TRUE_DIVIDE( TpSlots::nb_true_divide, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_true_divide, @@ -510,7 +515,7 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createTrueDivide), NB_DIVMOD( TpSlots::nb_divmod, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_divmod, @@ -518,12 +523,20 @@ public enum TpSlotMeta { BinaryOpSlotFuncWrapper::createDivMod), NB_MATRIX_MULTIPLY( TpSlots::nb_matrix_multiply, - TpSlotBinaryOpPython.class, + TpSlotReversiblePython.class, TpSlotBinaryOpBuiltin.class, TpSlotGroup.AS_NUMBER, CFields.PyNumberMethods__nb_matrix_multiply, PExternalFunctionWrapper.BINARYFUNC, BinaryOpSlotFuncWrapper::createMatrixMultiply), + NB_POWER( + TpSlots::nb_power, + TpSlotReversiblePython.class, + TpSlotNbPowerBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_power, + PExternalFunctionWrapper.TERNARYFUNC, + NbPowerWrapper::new), SQ_LENGTH( TpSlots::sq_length, TpSlotPythonSingle.class, @@ -816,44 +829,47 @@ private static void addSlotDef(LinkedHashMap defs, TpSl TpSlotDef.withoutHPy(T___SET__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_SET), // TpSlotDef.withoutHPy(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE)); addSlotDef(s, TpSlotMeta.NB_ADD, - TpSlotDef.withoutHPy(T___ADD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RADD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_SUBTRACT, - TpSlotDef.withoutHPy(T___SUB__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RSUB__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___SUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RSUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_MULTIPLY, - TpSlotDef.withoutHPy(T___MUL__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMUL__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___MUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_REMAINDER, - TpSlotDef.withoutHPy(T___MOD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMOD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___MOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_LSHIFT, - TpSlotDef.withoutHPy(T___LSHIFT__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RLSHIFT__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___LSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RLSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_RSHIFT, - TpSlotDef.withoutHPy(T___RSHIFT__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RRSHIFT__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___RSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RRSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_AND, - TpSlotDef.withoutHPy(T___AND__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RAND__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___AND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RAND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_XOR, - TpSlotDef.withoutHPy(T___XOR__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RXOR__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___XOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RXOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_OR, - TpSlotDef.withoutHPy(T___OR__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___ROR__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___OR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___ROR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_FLOOR_DIVIDE, - TpSlotDef.withoutHPy(T___FLOORDIV__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RFLOORDIV__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___FLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RFLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_TRUE_DIVIDE, - TpSlotDef.withoutHPy(T___TRUEDIV__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RTRUEDIV__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___TRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RTRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_DIVMOD, - TpSlotDef.withoutHPy(T___DIVMOD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RDIVMOD__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___DIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RDIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_MATRIX_MULTIPLY, - TpSlotDef.withoutHPy(T___MATMUL__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMATMUL__, TpSlotBinaryOpPython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.withoutHPy(T___MATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.withoutHPy(T___RMATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + addSlotDef(s, TpSlotMeta.NB_POWER, + TpSlotDef.withoutHPy(T___POW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC), + TpSlotDef.withoutHPy(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_BOOL, TpSlotDef.withSimpleFunction(T___BOOL__, PExternalFunctionWrapper.INQUIRY)); addSlotDef(s, TpSlotMeta.NB_INDEX, TpSlotDef.withSimpleFunction(T___INDEX__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INT, TpSlotDef.withSimpleFunction(T___INT__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1475,6 +1491,7 @@ public TpSlots build() { get(TpSlotMeta.NB_TRUE_DIVIDE), // get(TpSlotMeta.NB_DIVMOD), // get(TpSlotMeta.NB_MATRIX_MULTIPLY), // + get(TpSlotMeta.NB_POWER), // get(TpSlotMeta.SQ_LENGTH), // get(TpSlotMeta.SQ_ITEM), // get(TpSlotMeta.SQ_ASS_ITEM), // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/BuiltinSlotWrapperSignature.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/BuiltinSlotWrapperSignature.java index cafd60aae0..7821b0d686 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/BuiltinSlotWrapperSignature.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/BuiltinSlotWrapperSignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java index 3cc64a294f..462a7da957 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java @@ -49,6 +49,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RAND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RDIVMOD__; @@ -58,6 +59,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RRSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSUB__; @@ -125,7 +127,7 @@ public class TpSlotBinaryOp { private TpSlotBinaryOp() { } - public enum BinaryOpSlot { + public enum ReversibleSlot { NB_ADD(T___ADD__, T___RADD__), NB_SUBTRACT(T___SUB__, T___RSUB__), NB_MULTIPLY(T___MUL__, T___RMUL__), @@ -138,13 +140,14 @@ public enum BinaryOpSlot { NB_FLOOR_DIVIDE(T___FLOORDIV__, T___RFLOORDIV__), NB_TRUE_DIVIDE(T___TRUEDIV__, T___RTRUEDIV__), NB_DIVMOD(T___DIVMOD__, T___RDIVMOD__), - NB_MATRIX_MULTIPLY(T___MATMUL__, T___RMATMUL__); + NB_MATRIX_MULTIPLY(T___MATMUL__, T___RMATMUL__), + NB_POWER_BINARY(T___POW__, T___RPOW__); - private static final BinaryOpSlot[] VALUES = values(); + private static final ReversibleSlot[] VALUES = values(); private final TruffleString name; private final TruffleString rname; - BinaryOpSlot(TruffleString name, TruffleString rname) { + ReversibleSlot(TruffleString name, TruffleString rname) { this.name = name; this.rname = rname; } @@ -165,11 +168,12 @@ public TpSlot getSlotValue(TpSlots slots) { case NB_TRUE_DIVIDE -> slots.nb_true_divide(); case NB_DIVMOD -> slots.nb_divmod(); case NB_MATRIX_MULTIPLY -> slots.nb_matrix_multiply(); + case NB_POWER_BINARY -> slots.nb_power(); }; } - public static BinaryOpSlot fromCallableNames(TruffleString[] names) { - for (BinaryOpSlot op : VALUES) { + public static ReversibleSlot fromCallableNames(TruffleString[] names) { + for (ReversibleSlot op : VALUES) { if (names[0].equals(op.name) && names[1].equals(op.rname)) { return op; } @@ -234,24 +238,24 @@ public Object execute(VirtualFrame frame, Object self, Object other) { public abstract static class BinaryOpBuiltinNode extends PythonBinaryBuiltinNode { } - public static final class TpSlotBinaryOpPython extends TpSlotPython { - private final BinaryOpSlot op; + public static final class TpSlotReversiblePython extends TpSlotPython { + private final ReversibleSlot op; private final TruffleWeakReference left; private final TruffleWeakReference right; private final TruffleWeakReference type; - public TpSlotBinaryOpPython(BinaryOpSlot op, Object setattr, Object delattr, Object type) { + public TpSlotReversiblePython(ReversibleSlot op, Object left, Object right, Object type) { this.op = op; - this.left = asWeakRef(setattr); - this.right = asWeakRef(delattr); + this.left = asWeakRef(left); + this.right = asWeakRef(right); this.type = new TruffleWeakReference<>(type); } - public static TpSlotBinaryOpPython create(Object[] callables, TruffleString[] callableNames, Object type) { + public static TpSlotReversiblePython create(Object[] callables, TruffleString[] callableNames, Object type) { assert callables.length == 2; - BinaryOpSlot op = BinaryOpSlot.fromCallableNames(callableNames); + ReversibleSlot op = ReversibleSlot.fromCallableNames(callableNames); assert op != null : "Unexpected callable names: " + Arrays.toString(callableNames); - return new TpSlotBinaryOpPython(op, callables[0], callables[1], type); + return new TpSlotReversiblePython(op, callables[0], callables[1], type); } @Override @@ -259,7 +263,7 @@ public TpSlotPython forNewType(Object klass) { Object newLeft = LookupAttributeInMRONode.Dynamic.getUncached().execute(klass, op.name); Object newRight = LookupAttributeInMRONode.Dynamic.getUncached().execute(klass, op.rname); if (newLeft != getLeft() || newRight != getRight()) { - return new TpSlotBinaryOpPython(op, newLeft, newRight, getType()); + return new TpSlotReversiblePython(op, newLeft, newRight, getType()); } return this; } @@ -288,27 +292,27 @@ public abstract static class CallSlotBinaryOpNode extends Node { // This happens in CallBinaryOp1Node (cpython:binary_op1) public abstract Object execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, - BinaryOpSlot op); + ReversibleSlot op); @SuppressWarnings("unused") @Specialization(guards = "cachedSlot == slot", limit = "3") static Object callCachedBuiltin(VirtualFrame frame, TpSlotBinaryOpBuiltin slot, Object self, - Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op, + Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, ReversibleSlot op, @Cached("slot") TpSlotBinaryOpBuiltin cachedSlot, @Cached("cachedSlot.createOpSlotNode()") BinaryOpBuiltinNode slotNode) { return slotNode.execute(frame, self, other); } @Specialization - static Object callPython(VirtualFrame frame, TpSlotBinaryOpPython slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op, - @Cached(inline = false) CallBinaryOpPythonSlotNode callPython) { + static Object callPython(VirtualFrame frame, TpSlotReversiblePython slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, ReversibleSlot op, + @Cached(inline = false) CallReversiblePythonSlotNode callPython) { return callPython.execute(frame, slot, self, selfType, other, otherSlot, otherType, sameTypes, op); } @SuppressWarnings("unused") @Specialization static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, Object self, - Object selfType, Object arg, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op, + Object selfType, Object arg, TpSlot otherSlot, Object otherType, boolean sameTypes, ReversibleSlot op, @Exclusive @Cached GetThreadStateNode getThreadStateNode, @Cached(inline = false) PythonToNativeNode selfToNativeNode, @Cached(inline = false) PythonToNativeNode argToNativeNode, @@ -344,7 +348,7 @@ static Object callHPy(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative s @Specialization(replaces = "callCachedBuiltin") @InliningCutoff static Object callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotBinaryOpBuiltin slot, - Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op, + Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, ReversibleSlot op, @Cached(inline = false) CallContext callContext, @Cached InlinedConditionProfile isNullFrameProfile, @Cached(inline = false) IndirectCallNode indirectCallNode) { @@ -357,11 +361,12 @@ static Object callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, @GenerateUncached @GenerateInline(false) // intentional explicit "data-class" - abstract static class CallBinaryOpPythonSlotNode extends Node { - public abstract Object execute(VirtualFrame frame, TpSlot slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op); + abstract static class CallReversiblePythonSlotNode extends Node { + public abstract Object execute(VirtualFrame frame, TpSlotReversiblePython slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, + ReversibleSlot op); @Specialization - static Object callPython(VirtualFrame frame, TpSlotBinaryOpPython slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, BinaryOpSlot op, + static Object callPython(VirtualFrame frame, TpSlotReversiblePython slot, Object self, Object selfType, Object other, TpSlot otherSlot, Object otherType, boolean sameTypes, ReversibleSlot op, @Bind("this") Node inliningTarget, @Cached IsSubtypeNode isSubtypeNode, @Cached GetCachedTpSlotsNode getSelfSlotsNode, @@ -371,11 +376,11 @@ static Object callPython(VirtualFrame frame, TpSlotBinaryOpPython slot, Object s @Cached InlinedConditionProfile dispatchR2Profile, @Cached BinaryPythonSlotDispatcherNode dispatcherNode) { // Implements the logic of SLOT1BINFULL macro from CPython - TpSlotBinaryOpPython otherSlotValue = null; + TpSlotReversiblePython otherSlotValue = null; boolean doOther = false; if (!sameTypes) { - if (isBinOpWrapper(otherSlot, op)) { - otherSlotValue = (TpSlotBinaryOpPython) otherSlot; + if (isSameReversibleWrapper(otherSlot, op)) { + otherSlotValue = (TpSlotReversiblePython) otherSlot; doOther = true; } } @@ -383,7 +388,7 @@ static Object callPython(VirtualFrame frame, TpSlotBinaryOpPython slot, Object s TpSlots selfSlots = getSelfSlotsNode.execute(inliningTarget, selfType); TpSlot selfSlotValue = op.getSlotValue(selfSlots); // Note: the slot may be other's slot, not self's slot, so this test may not pass - if (isBinOpWrapper(selfSlotValue, op)) { + if (isSameReversibleWrapper(selfSlotValue, op)) { if (doOther && isSubtypeNode.execute(frame, otherType, selfType)) { if (methodIsOverloaded(frame, inliningTarget, slot, otherSlotValue, neNode)) { Object result = dispatchIfAvailable(frame, inliningTarget, dispatchR1Profile, dispatcherNode, other, self, otherSlotValue.getRight(), otherSlotValue.getType()); @@ -415,14 +420,14 @@ private static Object dispatchIfAvailable(VirtualFrame frame, Node inliningTarge } } - static boolean isBinOpWrapper(TpSlot s, BinaryOpSlot op) { + static boolean isSameReversibleWrapper(TpSlot s, ReversibleSlot op) { // Equivalent to CPython test: Py_TYPE(other)->tp_as_number->SLOTNAME == TESTFUNC // We have multiple wrappers, because we cache state (MRO lookups) in the wrapper too - return s instanceof TpSlotBinaryOpPython p && p.op == op; + return s instanceof TpSlotReversiblePython p && p.op == op; } static boolean methodIsOverloaded(VirtualFrame frame, Node inliningTarget, - TpSlotBinaryOpPython leftSlot, TpSlotBinaryOpPython rightSlot, RichCompareCallablesNotEqual neNode) { + TpSlotReversiblePython leftSlot, TpSlotReversiblePython rightSlot, RichCompareCallablesNotEqual neNode) { // CPython uses _PyObject_LookupAttr(Py_TYPE(x), name) as opposed to // _PyType_Lookup(Py_TYPE(x), name). Moreover, we cache the MRO lookup results in the // slot, CPython doesn't, presumably because the slot cannot (easily) hold the extra diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java new file mode 100644 index 0000000000..0272498c35 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2025, 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.builtins.objects.type.slots; + +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.Python3Core; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode; +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PyObjectCheckFunctionResultNode; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonTransferNode; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; +import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.NodeFactoryUtils.WrapperNodeFactory; +import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.TernaryPythonSlotDispatcherNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.CallReversiblePythonSlotNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotReversiblePython; +import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; +import com.oracle.graal.python.runtime.ExecutionContext.CallContext; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NodeFactory; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.strings.TruffleString; + +public final class TpSlotNbPower { + private TpSlotNbPower() { + } + + public abstract static class TpSlotNbPowerBuiltin extends TpSlotBuiltin { + private final int callTargetIndex = TpSlotBuiltinCallTargetRegistry.getNextCallTargetIndex(); + + private static final BuiltinSlotWrapperSignature SIGNATURE = BuiltinSlotWrapperSignature.of(2, "v", "w", "z"); + + protected TpSlotNbPowerBuiltin(NodeFactory nodeFactory) { + super(nodeFactory); + } + + final PythonTernaryBuiltinNode createOpSlotNode() { + return createNode(); + } + + @Override + public void initialize(PythonLanguage language) { + RootCallTarget callTarget = createBuiltinCallTarget(language, SIGNATURE, getNodeFactory(), J___POW__); + language.setBuiltinSlotCallTarget(callTargetIndex, callTarget); + } + + @Override + public PBuiltinFunction createBuiltin(Python3Core core, Object type, TruffleString tsName, PExternalFunctionWrapper wrapper) { + return switch (wrapper) { + case TERNARYFUNC -> createBuiltin(core, type, tsName, SIGNATURE, wrapper, getNodeFactory()); + case TERNARYFUNC_R -> createRBuiltin(core, type, tsName); + default -> null; + }; + } + + private PBuiltinFunction createRBuiltin(Python3Core core, Object type, TruffleString tsName) { + var factory = WrapperNodeFactory.wrap(getNodeFactory(), SwapArgumentsNode.class, SwapArgumentsNode::new); + return createBuiltin(core, type, tsName, SIGNATURE, PExternalFunctionWrapper.TERNARYFUNC_R, factory); + } + } + + static final class SwapArgumentsNode extends PythonTernaryBuiltinNode { + @Child private PythonTernaryBuiltinNode wrapped; + + SwapArgumentsNode(PythonTernaryBuiltinNode wrapped) { + this.wrapped = wrapped; + } + + @Override + public Object execute(VirtualFrame frame, Object self, Object w, Object z) { + return wrapped.execute(frame, w, self, z); + } + } + + @GenerateInline + @GenerateCached(false) + @GenerateUncached + public abstract static class CallSlotNbPowerNode extends Node { + private static final CApiTiming C_API_TIMING = CApiTiming.create(true, "ternaryfunc"); + + public abstract Object execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes); + + @SuppressWarnings("unused") + @Specialization(guards = "cachedSlot == slot", limit = "3") + static Object callCachedBuiltin(VirtualFrame frame, TpSlotNbPowerBuiltin slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes, + @Cached("slot") TpSlotNbPowerBuiltin cachedSlot, + @Cached("cachedSlot.createOpSlotNode()") PythonTernaryBuiltinNode slotNode) { + return slotNode.execute(frame, v, w, z); + } + + @Specialization + static Object callPython(VirtualFrame frame, TpSlotReversiblePython slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes, + @Cached(inline = false) CallNbPowerPythonNode callPython) { + return callPython.execute(frame, slot, v, vType, w, wSlot, wType, z, sameTypes); + } + + @SuppressWarnings("unused") + @Specialization + static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes, + @Cached GetThreadStateNode getThreadStateNode, + @Cached(inline = false) PythonToNativeNode vToNative, + @Cached(inline = false) PythonToNativeNode wToNative, + @Cached(inline = false) PythonToNativeNode zToNative, + @Cached ExternalFunctionInvokeNode externalInvokeNode, + @Cached(inline = false) NativeToPythonTransferNode toPythonNode, + @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { + PythonContext ctx = PythonContext.get(inliningTarget); + PythonContext.PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); + Object result = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___POW__, slot.callable, + vToNative.execute(v), wToNative.execute(w), zToNative.execute(z)); + return checkResultNode.execute(state, T___POW__, toPythonNode.execute(result)); + } + + @SuppressWarnings("unused") + @Specialization(replaces = "callCachedBuiltin") + @InliningCutoff + static Object callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotNbPowerBuiltin slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes, + @Cached(inline = false) CallContext callContext, + @Cached InlinedConditionProfile isNullFrameProfile, + @Cached(inline = false) IndirectCallNode indirectCallNode) { + Object[] arguments = PArguments.create(3); + PArguments.setArgument(arguments, 0, v); + PArguments.setArgument(arguments, 1, w); + PArguments.setArgument(arguments, 2, z); + return BuiltinDispatchers.callGenericBuiltin(frame, inliningTarget, slot.callTargetIndex, arguments, callContext, isNullFrameProfile, indirectCallNode); + } + } + + @GenerateUncached + @GenerateInline(false) // intentional explicit "data-class" + abstract static class CallNbPowerPythonNode extends Node { + public abstract Object execute(VirtualFrame frame, TpSlotReversiblePython slot, Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes); + + @Specialization + static Object callPythonAsBinary(VirtualFrame frame, TpSlotReversiblePython slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, @SuppressWarnings("unused") PNone z, boolean sameTypes, + @Cached CallReversiblePythonSlotNode callPython) { + return callPython.execute(frame, slot, v, vType, w, wSlot, wType, sameTypes, ReversibleSlot.NB_POWER_BINARY); + } + + @Fallback + @SuppressWarnings("unused") + static Object callPythonAsTernary(VirtualFrame frame, TpSlotReversiblePython slot, + Object v, Object vType, Object w, TpSlot wSlot, Object wType, Object z, boolean sameTypes, + @Bind("this") Node inliningTarget, + @Cached GetCachedTpSlotsNode getSelfSlotsNode, + @Cached TernaryPythonSlotDispatcherNode dispatcherNode, + @Cached InlinedBranchProfile notImplementedProfile) { + /* + * Three-arg power doesn't use __rpow__. But ternary_op can call this when the second + * argument's type uses slot_nb_power, so check before calling self.__pow__. + */ + TpSlots selfSlots = getSelfSlotsNode.execute(inliningTarget, vType); + if (CallReversiblePythonSlotNode.isSameReversibleWrapper(selfSlots.nb_power(), ReversibleSlot.NB_POWER_BINARY)) { + return dispatcherNode.execute(frame, inliningTarget, slot.getLeft(), slot.getType(), v, w, z); + } + notImplementedProfile.enter(inliningTarget); + return PNotImplemented.NOT_IMPLEMENTED; + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java index 5da1edf36f..3071008a18 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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.type.TypeNodes.IsSameTypeNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.IsSameSlotNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.CallSlotBinaryOpNode; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; @@ -64,7 +64,7 @@ @GenerateCached(false) public abstract class CallBinaryOp1Node extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, - Object w, Object classW, TpSlot slotW, BinaryOpSlot op); + Object w, Object classW, TpSlot slotW, ReversibleSlot op); // CPython binary_op1 may end up calling SLOT1BINFULL - wrapper around the dunder methods, which // duplicates some of the logic checking the right operand, its slot, and whether it is subtype. @@ -86,7 +86,7 @@ public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v // we just try __rxxx__, again, without any subclass check. @Specialization - static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, Object w, Object classW, TpSlot slotWIn, BinaryOpSlot op, + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, Object w, Object classW, TpSlot slotWIn, ReversibleSlot op, @Cached IsSameTypeNode isSameTypeNode, @Cached IsSameSlotNode isSameSlotNode, @Cached InlinedConditionProfile isSameTypeProfile, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryOpNode.java new file mode 100644 index 0000000000..706e0e5fd5 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryOpNode.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.IsSameSlotNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.CallSlotNbPowerNode; +import com.oracle.graal.python.nodes.classes.IsSubtypeNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; + +@GenerateInline +@GenerateCached(value = false) +@GenerateUncached +public abstract class CallTernaryOpNode extends Node { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, Object w, Object classW, TpSlot slotW, Object z); + + @Specialization + static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, Object w, Object classW, TpSlot slotWIn, Object z, + @Cached IsSameTypeNode isSameTypeNode, + @Cached IsSameSlotNode isSameSlotNode, + @Cached InlinedConditionProfile isSameTypeProfile, + @Cached InlinedConditionProfile isSameSlotProfile, + @Cached(inline = false) IsSubtypeNode isSubtypeNode, + @Cached InlinedBranchProfile wResultBranch, + @Cached InlinedBranchProfile vResultBranch, + @Cached InlinedBranchProfile wResult2Branch, + @Cached InlinedBranchProfile notImplementedBranch, + @Cached CallSlotNbPowerNode callSlotWNode, + @Cached CallSlotNbPowerNode callSlotVNode, + @Cached CallSlotNbPowerNode callSlotZNode, + @Cached GetClassNode getZClass, + @Cached GetCachedTpSlotsNode getZSlots) { + TpSlot slotW = null; + boolean sameTypes = isSameTypeProfile.profile(inliningTarget, isSameTypeNode.execute(inliningTarget, classW, classV)); + if (!sameTypes) { + slotW = slotWIn; + if (isSameSlotProfile.profile(inliningTarget, slotV != null && slotW != null && isSameSlotNode.execute(inliningTarget, slotW, slotV))) { + slotW = null; + } + } + + if (slotV != null) { + if (slotW != null && isSubtypeNode.execute(frame, classW, classV)) { + assert !sameTypes; + Object result = callSlotWNode.execute(frame, inliningTarget, slotW, v, classV, w, slotW, classW, z, false); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + wResultBranch.enter(inliningTarget); + return result; + } + slotW = null; + } + Object result = callSlotVNode.execute(frame, inliningTarget, slotV, v, classV, w, slotWIn, classW, z, sameTypes); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + vResultBranch.enter(inliningTarget); + return result; + } + } + + if (slotW != null) { + assert !sameTypes; + Object result = callSlotWNode.execute(frame, inliningTarget, slotW, v, classV, w, slotW, classW, z, false); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + wResult2Branch.enter(inliningTarget); + return result; + } + } + + if (z != PNone.NONE) { + Object classZ = getZClass.execute(inliningTarget, z); + TpSlot slotZ = getZSlots.execute(inliningTarget, classZ).nb_power(); + if (slotZ != null) { + if ((slotV == null || !isSameSlotNode.execute(inliningTarget, slotZ, slotV)) && (slotW == null || !isSameSlotNode.execute(inliningTarget, slotZ, slotW))) { + return callSlotZNode.execute(frame, inliningTarget, slotZ, v, classV, w, slotWIn, classW, z, false); + } + } + } + + notImplementedBranch.enter(inliningTarget); + return PNotImplemented.NOT_IMPLEMENTED; + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 483757851e..91ee5c1a5d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -52,7 +52,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; @@ -182,7 +182,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, TpSlot slotV = slotsV.nb_add(); TpSlot slotW = slotsW.nb_add(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_ADD); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_ADD); if (result != PNotImplemented.NOT_IMPLEMENTED) { hasNbAddResult.enter(inliningTarget); return result; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index dbaef51dc7..6f8083ce72 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -94,7 +94,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_and(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_and(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_AND); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_AND); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java index cbb830c858..fdf765a769 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -84,7 +84,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_divmod(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_divmod(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_DIVMOD); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_DIVMOD); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index 29e1cda87a..dbce52a051 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -122,7 +122,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_floor_divide(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_floor_divide(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_FLOOR_DIVIDE); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_FLOOR_DIVIDE); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index 82ce4248ae..9a7f29497d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -102,7 +102,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_lshift(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_lshift(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_LSHIFT); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_LSHIFT); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java index fe1bcffd5e..2076c14976 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -82,7 +82,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_matrix_multiply(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_matrix_multiply(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_MATRIX_MULTIPLY); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_MATRIX_MULTIPLY); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index 2f58fa3bce..78ad860388 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -138,7 +138,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, TpSlot slotV = slotsV.nb_multiply(); TpSlot slotW = slotsW.nb_multiply(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_MULTIPLY); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_MULTIPLY); if (result != PNotImplemented.NOT_IMPLEMENTED) { hasNbMulResult.enter(inliningTarget); return result; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index deba1bad16..29a24b4396 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -93,7 +93,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_or(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_or(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_OR); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_OR); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java new file mode 100644 index 0000000000..08567bf55d --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(inlineByDefault = true) +@GenerateUncached +public abstract class PyNumberPowerNode extends BinaryOpNode { + + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z); + + @Override + public final Object executeObject(VirtualFrame frame, Object left, Object right) { + return executeCached(frame, left, right, PNone.NONE); + } + + public final Object executeCached(VirtualFrame frame, Object v, Object w, Object z) { + return execute(frame, this, v, w, z); + } + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z, + @Cached GetClassNode getVClass, + @Cached GetClassNode getWClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Cached CallTernaryOpNode callTernaryOpNode, + @Cached PRaiseNode.Lazy raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + Object classW = getWClass.execute(inliningTarget, w); + TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_power(); + TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_power(); + Object result = callTernaryOpNode.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, z); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; + } + return raiseNotSupported(inliningTarget, v, w, z, raiseNode); + } + + @InliningCutoff + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Object z, PRaiseNode.Lazy raiseNode) { + if (z == PNone.NONE) { + return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "** or pow()", v, w); + } else { + return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, "** or pow()", v, w, z); + } + } + + @NeverDefault + public static PyNumberPowerNode create() { + return PyNumberPowerNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index fdfb76ca64..9d1f89d2ef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -45,7 +45,7 @@ import com.oracle.graal.python.builtins.objects.floats.FloatBuiltins; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -99,7 +99,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_remainder(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_remainder(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_REMAINDER); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_REMAINDER); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index 2bc00a6dff..cc39873f8d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -48,7 +48,7 @@ import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; @@ -99,7 +99,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_rshift(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_rshift(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_RSHIFT); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_RSHIFT); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index b9218bbf78..0711269403 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -128,7 +128,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_subtract(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_subtract(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_SUBTRACT); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_SUBTRACT); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index 731a66d293..f759484415 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -111,7 +111,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_true_divide(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_true_divide(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_TRUE_DIVIDE); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_TRUE_DIVIDE); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index 71a5de5032..06c67afdf1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; @@ -93,7 +93,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_xor(); TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_xor(); if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_XOR); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_XOR); if (result != PNotImplemented.NOT_IMPLEMENTED) { return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java index b428605f03..bcc4a7c448 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -52,7 +52,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; @@ -132,7 +132,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, TpSlot slotW = slotsW.nb_add(); if (slotV != null || slotW != null) { hasNbAddSlot.enter(inliningTarget); - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, BinaryOpSlot.NB_ADD); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_ADD); if (result != PNotImplemented.NOT_IMPLEMENTED) { hasNbAddResult.enter(inliningTarget); return result; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java index 3f8cfe2700..7804fc3b01 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java @@ -776,7 +776,7 @@ public abstract class ErrorMessages { public static final TruffleString UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P = tsLiteral("unsupported operand type(s) for %s: '%p' and '%p'"); public static final TruffleString UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P_PRINT = cat(UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, tsLiteral(". Did you mean \"print(, file=)\"?")); - public static final TruffleString UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P = tsLiteral("unsupported operand type(s) for %s(): '%p', '%p', '%p'"); + public static final TruffleString UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P = tsLiteral("unsupported operand type(s) for %s: '%p', '%p', '%p'"); public static final TruffleString UNSUPPORTED_OPERAND_TYPES_FOR_S_PR_S_P_AND_P = tsLiteral("unsupported operand type(s) for %s or %s(): '%p' and '%p'"); public static final TruffleString UNSUPPORTED_SIZE_WAS = tsLiteral("unsupported %s size; was: %d"); public static final TruffleString UNSUPPORTED_STR_TYPE = tsLiteral("unsupported string type: %s"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java index e907bda862..6f5d23cdbc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java @@ -58,6 +58,7 @@ import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyNumberOrNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyNumberRemainderNode; import com.oracle.graal.python.lib.PyNumberRshiftNode; import com.oracle.graal.python.lib.PyNumberSubtractNode; @@ -92,7 +93,7 @@ public enum BinaryArithmetic { Or(PyNumberOrNode::create), Xor(PyNumberXorNode::create), MatMul(PyNumberMatrixMultiplyNode::create), - Pow(BinaryArithmeticFactory.PowNodeGen::create), + Pow(PyNumberPowerNode::create), DivMod(PyNumberDivmodNode::create); interface CreateBinaryOp { @@ -179,18 +180,6 @@ public static LookupAndCallBinaryNode createCallNode(SpecialMethodSlot slot, Sup } - public abstract static class PowNode extends BinaryArithmeticNode { - - public static final Supplier NOT_IMPLEMENTED = createHandler("** or pow()"); - - @Specialization - public static Object doGeneric(VirtualFrame frame, Object left, Object right, - // TODO: ternary_op is not implemented (GR-<2????>) - @Cached("createCallNode(Pow, NOT_IMPLEMENTED)") LookupAndCallBinaryNode callNode) { - return callNode.executeObject(frame, left, right); - } - } - public abstract static class GenericBinaryArithmeticNode extends BinaryArithmeticNode { private final SpecialMethodSlot slot; From 9ae89627b6bd5246915047f1b566cd6e4597e264 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 24 Jan 2025 18:31:52 +0100 Subject: [PATCH 013/512] Replace PythonObjectFactory with node-less PFactory --- .../asdl/asdl_java.py | 4 +- .../asdl/java_file.py | 4 +- .../graal/python/pegparser/sst/AliasTy.java | 2 +- .../graal/python/pegparser/sst/ArgTy.java | 2 +- .../python/pegparser/sst/ArgumentsTy.java | 2 +- .../graal/python/pegparser/sst/BoolOpTy.java | 2 +- .../graal/python/pegparser/sst/CmpOpTy.java | 2 +- .../python/pegparser/sst/ComprehensionTy.java | 2 +- .../python/pegparser/sst/ExceptHandlerTy.java | 2 +- .../python/pegparser/sst/ExprContextTy.java | 2 +- .../graal/python/pegparser/sst/ExprTy.java | 2 +- .../graal/python/pegparser/sst/KeywordTy.java | 2 +- .../python/pegparser/sst/MatchCaseTy.java | 2 +- .../graal/python/pegparser/sst/ModTy.java | 2 +- .../python/pegparser/sst/OperatorTy.java | 2 +- .../graal/python/pegparser/sst/PatternTy.java | 2 +- .../python/pegparser/sst/SSTreeVisitor.java | 2 +- .../graal/python/pegparser/sst/StmtTy.java | 2 +- .../python/pegparser/sst/TypeIgnoreTy.java | 2 +- .../graal/python/pegparser/sst/UnaryOpTy.java | 2 +- .../python/pegparser/sst/WithItemTy.java | 2 +- .../builtin/modules/ConversionNodeTests.java | 3 +- .../modules/DirFdConversionNodeTests.java | 15 +- .../FileDescriptorConversionNodeTests.java | 15 +- .../modules/PathConversionNodeTests.java | 29 +- .../test/builtin/objects/dict/PDictTest.java | 11 +- .../python/test/datatype/PRangeTests.java | 18 +- .../util/CastToJavaUnsignedLongNodeTests.java | 11 +- .../test/runtime/PythonModuleTests.java | 5 +- .../oracle/graal/python/PythonLanguage.java | 47 +- .../python/builtins/BoundBuiltinCallable.java | 6 +- .../graal/python/builtins/Python3Core.java | 31 +- .../builtins/PythonBuiltinClassType.java | 4 - .../graal/python/builtins/PythonBuiltins.java | 32 +- .../builtins/modules/ArrayModuleBuiltins.java | 56 +- .../modules/AsyncioModuleBuiltins.java | 5 +- .../modules/BinasciiModuleBuiltins.java | 29 +- .../builtins/modules/BuiltinConstructors.java | 479 +++-- .../builtins/modules/BuiltinFunctions.java | 56 +- .../builtins/modules/CmathModuleBuiltins.java | 110 +- .../modules/CodecsModuleBuiltins.java | 56 +- .../modules/CodecsTruffleModuleBuiltins.java | 45 +- .../modules/CollectionsModuleBuiltins.java | 41 +- .../modules/ContextvarsModuleBuiltins.java | 13 +- .../builtins/modules/ErrnoModuleBuiltins.java | 5 +- .../builtins/modules/FcntlModuleBuiltins.java | 13 +- .../builtins/modules/GcModuleBuiltins.java | 17 +- .../modules/GraalHPyDebugModuleBuiltins.java | 11 +- .../GraalHPyUniversalModuleBuiltins.java | 3 +- .../modules/GraalPythonModuleBuiltins.java | 49 +- .../builtins/modules/ImpModuleBuiltins.java | 45 +- .../modules/ItertoolsModuleBuiltins.java | 252 +-- .../modules/LocaleModuleBuiltins.java | 19 +- .../modules/LsprofModuleBuiltins.java | 42 +- .../builtins/modules/MMapModuleBuiltins.java | 10 +- .../modules/MarshalModuleBuiltins.java | 89 +- .../builtins/modules/MathModuleBuiltins.java | 69 +- .../builtins/modules/NtModuleBuiltins.java | 11 +- .../modules/PolyglotModuleBuiltins.java | 8 +- .../builtins/modules/PosixModuleBuiltins.java | 824 ++++---- .../python/builtins/modules/Profiler.java | 62 + .../builtins/modules/PwdModuleBuiltins.java | 42 +- .../builtins/modules/QueueModuleBuiltins.java | 12 +- .../modules/RandomModuleBuiltins.java | 12 +- .../modules/ResourceModuleBuiltins.java | 15 +- .../builtins/modules/SREModuleBuiltins.java | 7 +- .../builtins/modules/SSLModuleBuiltins.java | 19 +- .../modules/SelectModuleBuiltins.java | 21 +- .../modules/SignalModuleBuiltins.java | 21 +- .../modules/SocketModuleBuiltins.java | 151 +- .../modules/StringModuleBuiltins.java | 18 +- .../modules/StructModuleBuiltins.java | 28 +- .../builtins/modules/SysModuleBuiltins.java | 107 +- .../modules/ThreadModuleBuiltins.java | 37 +- .../builtins/modules/TimeModuleBuiltins.java | 19 +- .../modules/TokenizeModuleBuiltins.java | 14 +- .../modules/WarningsModuleBuiltins.java | 51 +- .../modules/WeakRefModuleBuiltins.java | 20 +- .../modules/WinregModuleBuiltins.java | 9 +- .../builtins/modules/ast/AstBuiltins.java | 9 +- .../modules/ast/AstModuleBuiltins.java | 29 +- .../python/builtins/modules/ast/AstState.java | 2 +- .../builtins/modules/ast/AstTypeFactory.java | 19 +- .../python/builtins/modules/ast/Obj2Sst.java | 2 +- .../builtins/modules/ast/Sst2ObjVisitor.java | 152 +- .../modules/ast/Sst2ObjVisitorBase.java | 32 +- .../modules/bz2/BZ2CompressorBuiltins.java | 30 +- .../modules/bz2/BZ2DecompressorBuiltins.java | 22 +- .../modules/bz2/BZ2ModuleBuiltins.java | 19 +- .../modules/cext/PythonCextBuiltins.java | 33 +- .../modules/cext/PythonCextBytesBuiltins.java | 69 +- .../cext/PythonCextCapsuleBuiltins.java | 9 +- .../modules/cext/PythonCextClassBuiltins.java | 14 +- .../cext/PythonCextComplexBuiltins.java | 9 +- .../cext/PythonCextContextBuiltins.java | 17 +- .../modules/cext/PythonCextDescrBuiltins.java | 9 +- .../modules/cext/PythonCextDictBuiltins.java | 20 +- .../modules/cext/PythonCextErrBuiltins.java | 16 +- .../modules/cext/PythonCextFuncBuiltins.java | 16 +- .../cext/PythonCextGenericAliasBuiltins.java | 11 +- .../modules/cext/PythonCextIterBuiltins.java | 9 +- .../modules/cext/PythonCextListBuiltins.java | 13 +- .../modules/cext/PythonCextLongBuiltins.java | 19 +- .../cext/PythonCextMethodBuiltins.java | 11 +- .../cext/PythonCextNamespaceBuiltins.java | 19 +- .../cext/PythonCextObjectBuiltins.java | 7 +- .../cext/PythonCextPyStateBuiltins.java | 7 +- .../cext/PythonCextPyThreadBuiltins.java | 8 +- .../modules/cext/PythonCextSetBuiltins.java | 29 +- .../cext/PythonCextStructSeqBuiltins.java | 17 +- .../cext/PythonCextTracebackBuiltins.java | 12 +- .../modules/cext/PythonCextTupleBuiltins.java | 9 +- .../modules/cext/PythonCextTypeBuiltins.java | 21 +- .../cext/PythonCextUnicodeBuiltins.java | 77 +- .../cjkcodecs/CodecsCNModuleBuiltins.java | 27 +- .../cjkcodecs/CodecsHKModuleBuiltins.java | 19 +- .../CodecsISO2022ModuleBuiltins.java | 27 +- .../cjkcodecs/CodecsJPModuleBuiltins.java | 49 +- .../cjkcodecs/CodecsKRModuleBuiltins.java | 23 +- .../cjkcodecs/CodecsTWModuleBuiltins.java | 19 +- .../cjkcodecs/MultibyteCodecBuiltins.java | 23 +- .../modules/cjkcodecs/MultibyteCodecUtil.java | 37 +- .../cjkcodecs/MultibyteDecodeBuffer.java | 8 +- .../cjkcodecs/MultibyteEncodeBuffer.java | 9 +- .../MultibyteIncrementalDecoderBuiltins.java | 22 +- .../MultibyteIncrementalEncoderBuiltins.java | 28 +- .../MultibyteStreamReaderBuiltins.java | 10 +- .../MultibyteStreamWriterBuiltins.java | 29 +- .../MultibytecodecModuleBuiltins.java | 16 +- .../builtins/modules/codecs/CharmapNodes.java | 18 +- .../modules/codecs/ErrorHandlers.java | 77 +- .../modules/csv/CSVModuleBuiltins.java | 16 +- .../modules/csv/CSVReaderBuiltins.java | 7 +- .../modules/ctypes/CArgObjectBuiltins.java | 9 +- .../modules/ctypes/CDataBuiltins.java | 15 +- .../modules/ctypes/CDataTypeBuiltins.java | 31 +- .../ctypes/CDataTypeSequenceBuiltins.java | 11 +- .../modules/ctypes/CFieldBuiltins.java | 61 +- .../modules/ctypes/CtypesModuleBuiltins.java | 91 +- .../builtins/modules/ctypes/CtypesNodes.java | 14 +- .../ctypes/LazyPyCArrayTypeBuiltins.java | 23 +- .../ctypes/LazyPyCSimpleTypeBuiltins.java | 49 +- .../modules/ctypes/PyCArrayBuiltins.java | 21 +- .../modules/ctypes/PyCArrayTypeBuiltins.java | 10 +- .../modules/ctypes/PyCFuncPtrBuiltins.java | 15 +- .../ctypes/PyCFuncPtrTypeBuiltins.java | 11 +- .../modules/ctypes/PyCPointerBuiltins.java | 21 +- .../ctypes/PyCPointerTypeBuiltins.java | 17 +- .../modules/ctypes/PyCSimpleTypeBuiltins.java | 34 +- .../modules/ctypes/PyCStructTypeBuiltins.java | 13 +- .../modules/ctypes/StgDictBuiltins.java | 20 +- .../ctypes/StructUnionTypeBuiltins.java | 25 +- .../modules/ctypes/UnionTypeBuiltins.java | 17 +- .../functools/FunctoolsModuleBuiltins.java | 11 +- .../modules/functools/KeyWrapperBuiltins.java | 7 +- .../functools/LruCacheWrapperBuiltins.java | 30 +- .../builtins/modules/functools/PPartial.java | 17 +- .../modules/functools/PartialBuiltins.java | 61 +- .../modules/hashlib/DigestObject.java | 15 +- .../modules/hashlib/DigestObjectBuiltins.java | 12 +- .../hashlib/HashlibModuleBuiltins.java | 20 +- .../hashlib/ShakeDigestObjectBuiltins.java | 9 +- .../io/AbstractBufferedIOBuiltins.java | 29 +- .../modules/io/BufferedRWPairBuiltins.java | 17 +- .../modules/io/BufferedRandomBuiltins.java | 14 +- .../modules/io/BufferedReaderBuiltins.java | 19 +- .../io/BufferedReaderMixinBuiltins.java | 63 +- .../modules/io/BufferedWriterBuiltins.java | 19 +- .../modules/io/BufferedWriterNodes.java | 9 +- .../builtins/modules/io/BytesIOBuiltins.java | 74 +- .../builtins/modules/io/FileIOBuiltins.java | 57 +- .../builtins/modules/io/IOBaseBuiltins.java | 13 +- .../builtins/modules/io/IOModuleBuiltins.java | 87 +- .../python/builtins/modules/io/IONodes.java | 37 +- .../io/IncrementalNewlineDecoderBuiltins.java | 30 +- .../python/builtins/modules/io/PBytesIO.java | 15 +- .../modules/io/RawIOBaseBuiltins.java | 20 +- .../builtins/modules/io/StringIOBuiltins.java | 14 +- .../modules/io/TextIOWrapperBuiltins.java | 16 +- .../modules/io/TextIOWrapperNodes.java | 24 +- .../modules/json/JSONEncoderBuiltins.java | 11 +- .../modules/json/JSONModuleBuiltins.java | 16 +- .../modules/json/JSONScannerBuiltins.java | 34 +- .../modules/lzma/LZMACompressorBuiltins.java | 17 +- .../lzma/LZMADecompressorBuiltins.java | 21 +- .../modules/lzma/LZMAModuleBuiltins.java | 29 +- .../GraalPySemLockBuiltins.java | 9 +- .../MultiprocessingGraalPyModuleBuiltins.java | 42 +- .../MultiprocessingModuleBuiltins.java | 11 +- .../multiprocessing/SemLockBuiltins.java | 11 +- .../python/builtins/modules/pickle/PData.java | 13 +- .../builtins/modules/pickle/PPickler.java | 28 +- .../builtins/modules/pickle/PUnpickler.java | 26 +- .../modules/pickle/PickleBufferBuiltins.java | 9 +- .../modules/pickle/PickleModuleBuiltins.java | 52 +- .../builtins/modules/pickle/PickleUtils.java | 9 +- .../modules/pickle/PicklerBuiltins.java | 13 +- .../pickle/PicklerMemoProxyBuiltins.java | 28 +- .../builtins/modules/pickle/PicklerNodes.java | 31 +- .../modules/pickle/UnpicklerBuiltins.java | 13 +- .../pickle/UnpicklerMemoProxyBuiltins.java | 17 +- .../builtins/modules/zlib/ZLibCompObject.java | 17 +- .../modules/zlib/ZLibModuleBuiltins.java | 50 +- .../modules/zlib/ZlibCompressBuiltins.java | 60 +- .../modules/zlib/ZlibDecompressBuiltins.java | 83 +- .../builtins/modules/zlib/ZlibNodes.java | 33 +- .../objects/PythonAbstractObject.java | 5 +- .../builtins/objects/array/ArrayBuiltins.java | 45 +- .../python/builtins/objects/array/PArray.java | 6 +- .../asyncio/AsyncGeneratorBuiltins.java | 28 +- .../objects/bytes/ByteArrayBuiltins.java | 76 +- .../builtins/objects/bytes/BytesBuiltins.java | 44 +- .../objects/bytes/BytesCommonBuiltins.java | 180 +- .../builtins/objects/bytes/BytesNodes.java | 33 +- .../cext/capi/CApiMemberAccessNodes.java | 12 +- .../builtins/objects/cext/capi/CExtNodes.java | 58 +- .../cext/capi/ExternalFunctionNodes.java | 110 +- .../objects/cext/capi/PThreadState.java | 5 +- .../cext/capi/PyDateTimeCAPIWrapper.java | 5 +- .../objects/cext/capi/ToNativeTypeNode.java | 9 +- .../objects/cext/capi/UnicodeObjectNodes.java | 7 +- .../capi/transitions/CApiTransitions.java | 6 +- .../transitions/GetNativeWrapperNode.java | 7 +- .../objects/cext/common/CExtCommonNodes.java | 32 +- .../objects/cext/common/CExtContext.java | 7 +- .../objects/cext/hpy/GraalHPyContext.java | 3 +- .../cext/hpy/GraalHPyContextFunctions.java | 132 +- .../cext/hpy/GraalHPyMemberAccessNodes.java | 12 +- .../cext/hpy/GraalHPyNativeContext.java | 8 +- .../objects/cext/hpy/GraalHPyNodes.java | 67 +- .../cext/hpy/GraalHPyObjectBuiltins.java | 6 +- .../cext/hpy/HPyExternalFunctionNodes.java | 48 +- .../cext/hpy/jni/GraalHPyJNIContext.java | 23 +- .../builtins/objects/code/CodeBuiltins.java | 82 +- .../builtins/objects/code/CodeNodes.java | 20 +- .../python/builtins/objects/code/PCode.java | 71 +- .../objects/common/BufferStorageNodes.java | 16 +- .../objects/common/KeywordsStorage.java | 4 +- .../objects/common/SequenceStorageNodes.java | 26 +- .../objects/complex/ComplexBuiltins.java | 81 +- .../objects/contextvars/ContextBuiltins.java | 23 +- .../contextvars/ContextIteratorBuiltins.java | 8 +- .../contextvars/ContextVarBuiltins.java | 15 +- .../objects/contextvars/PContextIterator.java | 13 +- .../objects/contextvars/TokenBuiltins.java | 11 +- .../builtins/objects/deque/DequeBuiltins.java | 36 +- .../objects/deque/DequeIterBuiltins.java | 9 +- .../objects/dict/DefaultDictBuiltins.java | 15 +- .../builtins/objects/dict/DictBuiltins.java | 57 +- .../objects/dict/DictValuesBuiltins.java | 17 +- .../objects/dict/DictViewBuiltins.java | 67 +- .../objects/enumerate/EnumerateBuiltins.java | 25 +- .../objects/enumerate/PEnumerate.java | 9 +- .../exception/BaseExceptionAttrNode.java | 14 +- .../exception/BaseExceptionBuiltins.java | 34 +- .../exception/BaseExceptionGroupBuiltins.java | 27 +- .../objects/exception/ExceptionNodes.java | 19 +- .../exception/ImportErrorBuiltins.java | 21 +- .../objects/exception/OsErrorBuiltins.java | 23 +- .../exception/PrepareExceptionNode.java | 7 +- .../exception/StopIterationBuiltins.java | 6 +- .../exception/SyntaxErrorBuiltins.java | 4 +- .../objects/exception/SystemExitBuiltins.java | 14 +- .../exception/UnicodeErrorBuiltins.java | 15 +- .../objects/floats/FloatBuiltins.java | 37 +- .../foreign/ForeignAbstractClassBuiltins.java | 19 +- .../foreign/ForeignNumberBuiltins.java | 15 +- .../foreign/ForeignObjectBuiltins.java | 9 +- .../builtins/objects/frame/FrameBuiltins.java | 12 +- .../function/AbstractFunctionBuiltins.java | 15 +- .../function/BuiltinFunctionBuiltins.java | 13 +- .../objects/function/FunctionBuiltins.java | 17 +- .../function/MethodDescriptorBuiltins.java | 19 +- .../objects/function/PBuiltinFunction.java | 9 +- .../function/WrapperDescriptorBuiltins.java | 15 +- .../generator/CommonGeneratorBuiltins.java | 12 +- .../objects/generator/CoroutineBuiltins.java | 14 +- .../objects/generator/GeneratorBuiltins.java | 19 +- .../objects/generator/PGenerator.java | 8 +- .../getsetdescriptor/GetSetDescriptor.java | 8 +- .../MemberDescriptorBuiltins.java | 9 +- .../builtins/objects/ints/IntBuiltins.java | 303 ++- .../builtins/objects/ints/IntNodes.java | 8 +- .../python/builtins/objects/ints/PInt.java | 13 +- .../objects/iterator/IteratorBuiltins.java | 126 +- .../objects/iterator/PBigRangeIterator.java | 9 +- .../objects/iterator/PZipBuiltins.java | 17 +- .../iterator/SentinelIteratorBuiltins.java | 11 +- .../objects/itertools/AccumulateBuiltins.java | 37 +- .../objects/itertools/ChainBuiltins.java | 28 +- .../itertools/CombinationsBuiltins.java | 35 +- .../objects/itertools/CompressBuiltins.java | 9 +- .../objects/itertools/CountBuiltins.java | 13 +- .../objects/itertools/CycleBuiltins.java | 31 +- .../objects/itertools/DropwhileBuiltins.java | 9 +- .../itertools/FilterfalseBuiltins.java | 9 +- .../objects/itertools/GroupByBuiltins.java | 21 +- .../objects/itertools/GrouperBuiltins.java | 16 +- .../objects/itertools/IsliceBuiltins.java | 18 +- .../objects/itertools/PTeeDataObject.java | 9 +- .../objects/itertools/PairwiseBuiltins.java | 9 +- .../itertools/PermutationsBuiltins.java | 31 +- .../objects/itertools/ProductBuiltins.java | 34 +- .../objects/itertools/RepeatBuiltins.java | 11 +- .../objects/itertools/StarmapBuiltins.java | 11 +- .../objects/itertools/TakewhileBuiltins.java | 13 +- .../objects/itertools/TeeBuiltins.java | 30 +- .../itertools/TeeDataObjectBuiltins.java | 17 +- .../objects/itertools/ZipLongestBuiltins.java | 20 +- .../builtins/objects/list/ListBuiltins.java | 48 +- .../builtins/objects/map/MapBuiltins.java | 10 +- .../mappingproxy/MappingproxyBuiltins.java | 7 +- .../memoryview/MemoryViewBuiltins.java | 61 +- .../method/AbstractMethodBuiltins.java | 14 +- .../objects/method/ClassmethodBuiltins.java | 21 +- .../method/InstancemethodBuiltins.java | 10 +- .../objects/method/MethodBuiltins.java | 15 +- .../objects/method/PDecoratedMethod.java | 11 +- .../builtins/objects/mmap/MMapBuiltins.java | 102 +- .../objects/module/ModuleBuiltins.java | 18 +- .../builtins/objects/module/PythonModule.java | 10 +- .../namespace/SimpleNamespaceBuiltins.java | 13 +- .../objects/object/ObjectBuiltins.java | 7 +- .../builtins/objects/object/ObjectNodes.java | 26 +- .../ordereddict/OrderedDictBuiltins.java | 33 +- .../ordereddict/OrderedDictItemsBuiltins.java | 15 +- .../OrderedDictIteratorBuiltins.java | 18 +- .../ordereddict/OrderedDictKeysBuiltins.java | 15 +- .../OrderedDictValuesBuiltins.java | 15 +- .../objects/posix/DirEntryBuiltins.java | 50 +- .../posix/ScandirIteratorBuiltins.java | 8 +- .../objects/property/PropertyBuiltins.java | 5 +- .../objects/queue/SimpleQueueBuiltins.java | 9 +- .../objects/random/RandomBuiltins.java | 11 +- .../builtins/objects/range/RangeBuiltins.java | 72 +- .../builtins/objects/range/RangeNodes.java | 12 +- .../referencetype/ReferenceTypeBuiltins.java | 9 +- .../objects/reversed/ReversedBuiltins.java | 29 +- .../builtins/objects/set/BaseSetBuiltins.java | 32 +- .../objects/set/FrozenSetBuiltins.java | 68 +- .../builtins/objects/set/SetBuiltins.java | 61 +- .../python/builtins/objects/set/SetNodes.java | 49 +- .../builtins/objects/slice/PObjectSlice.java | 11 +- .../builtins/objects/slice/SliceBuiltins.java | 39 +- .../builtins/objects/slice/SliceNodes.java | 37 +- .../objects/socket/SocketBuiltins.java | 171 +- .../builtins/objects/socket/SocketNodes.java | 13 +- .../builtins/objects/ssl/CertUtils.java | 65 +- .../objects/ssl/MemoryBIOBuiltins.java | 15 +- .../objects/ssl/SSLContextBuiltins.java | 53 +- .../objects/ssl/SSLErrorBuiltins.java | 10 +- .../objects/ssl/SSLSocketBuiltins.java | 33 +- .../builtins/objects/str/StringBuiltins.java | 68 +- .../builtins/objects/str/StringNodes.java | 11 +- .../builtins/objects/str/StringUtils.java | 40 +- .../objects/struct/StructBuiltins.java | 25 +- .../builtins/objects/struct/StructNodes.java | 33 +- .../struct/StructUnpackIteratorBuiltins.java | 11 +- .../objects/superobject/SuperBuiltins.java | 11 +- .../objects/thread/RLockBuiltins.java | 9 +- .../objects/thread/ThreadLocalNodes.java | 11 +- .../tokenize/TokenizerIterBuiltins.java | 9 +- .../MaterializeLazyTracebackNode.java | 8 +- .../objects/traceback/TracebackBuiltins.java | 14 +- .../objects/tuple/StructSequence.java | 55 +- .../builtins/objects/tuple/TupleBuiltins.java | 48 +- .../objects/tuple/TupleGetterBuiltins.java | 11 +- .../objects/type/PythonManagedClass.java | 6 +- .../python/builtins/objects/type/TpSlots.java | 6 +- .../builtins/objects/type/TypeBuiltins.java | 65 +- .../builtins/objects/type/TypeNodes.java | 55 +- .../builtins/objects/type/slots/TpSlot.java | 5 +- .../objects/types/GenericAliasBuiltins.java | 37 +- .../types/GenericAliasIteratorBuiltins.java | 15 +- .../objects/types/GenericTypeNodes.java | 19 +- .../objects/types/UnionTypeBuiltins.java | 23 +- .../graal/python/compiler/Compiler.java | 5 +- .../RaisePythonExceptionErrorCallback.java | 7 +- .../python/lib/PyContextCopyCurrent.java | 8 +- .../oracle/graal/python/lib/PyDictKeys.java | 10 +- .../graal/python/lib/PyImportImport.java | 12 +- .../graal/python/lib/PyIterNextNode.java | 11 +- .../oracle/graal/python/lib/PyLongCopy.java | 9 +- .../python/lib/PyLongFromDoubleNode.java | 10 +- .../python/lib/PyLongFromUnicodeObject.java | 11 +- .../python/lib/PyMemoryViewFromObject.java | 18 +- .../graal/python/lib/PyNumberAddNode.java | 19 +- .../graal/python/lib/PyObjectGetItem.java | 6 +- .../graal/python/lib/PyObjectGetIter.java | 15 +- .../graal/python/lib/PySequenceConcat.java | 17 +- .../oracle/graal/python/lib/PySliceNew.java | 31 +- .../python/lib/PyTraceBackPrintNode.java | 17 +- .../python/lib/PyUnicodeAsEncodedString.java | 7 +- .../lib/PyUnicodeFromEncodedObject.java | 10 +- .../oracle/graal/python/nodes/PRaiseNode.java | 25 +- .../python/nodes/WriteUnraisableNode.java | 10 +- .../nodes/argument/ReadVarArgsNode.java | 13 +- .../nodes/argument/ReadVarKeywordsNode.java | 12 +- .../capsule/CreateArrowPyCapsuleNode.java | 9 +- .../python/nodes/builtins/ListNodes.java | 69 +- .../python/nodes/builtins/TupleNodes.java | 46 +- .../bytecode/CopyDictWithoutKeysNode.java | 11 +- .../nodes/bytecode/MakeFunctionNode.java | 14 +- .../python/nodes/bytecode/MatchClassNode.java | 11 +- .../python/nodes/bytecode/MatchKeysNode.java | 17 +- .../PBytecodeGeneratorFunctionRootNode.java | 14 +- .../nodes/bytecode/PBytecodeRootNode.java | 83 +- .../nodes/bytecode/SetupAnnotationsNode.java | 24 +- .../python/nodes/bytecode/UnpackExNode.java | 14 +- .../exception/TopLevelExceptionHandler.java | 11 +- .../expression/CastToListExpressionNode.java | 11 +- .../nodes/frame/GetFrameLocalsNode.java | 11 +- .../nodes/frame/MaterializeFrameNode.java | 26 +- .../builtins/PythonVarargsBuiltinNode.java | 16 +- .../python/nodes/object/DeleteDictNode.java | 10 +- .../nodes/object/GetDictIfExistsNode.java | 12 +- .../object/GetForeignObjectClassNode.java | 3 +- .../nodes/object/GetOrCreateDictNode.java | 10 +- .../nodes/object/GetRegisteredClassNode.java | 3 +- .../nodes/statement/AbstractImportNode.java | 10 +- .../nodes/util/CoerceToComplexNode.java | 19 +- .../nodes/util/NarrowBigIntegerNode.java | 10 +- .../graal/python/runtime/PythonContext.java | 33 +- .../runtime/exception/ExceptionUtils.java | 14 +- .../formatting/BytesFormatProcessor.java | 6 +- .../runtime/formatting/FormatProcessor.java | 4 +- .../graal/python/runtime/object/IDUtils.java | 15 +- .../graal/python/runtime/object/PFactory.java | 1695 ++++++++++++++++ .../runtime/object/PythonObjectFactory.java | 1739 ----------------- .../object/PythonObjectSlowPathFactory.java | 97 - .../oracle/graal/python/util/PythonUtils.java | 36 +- mx.graalpython/copyrights/overrides | 2 +- 432 files changed, 7806 insertions(+), 7905 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/Profiler.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectSlowPathFactory.java diff --git a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py index 77b684f9d4..465666c897 100755 --- a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py +++ b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, 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 @@ -285,7 +285,7 @@ def visit_abstract_class(self, c: model.AbstractClass, emitter: java_file.Emitte def visit_concrete_class(self, c: model.ConcreteClass, emitter: java_file.Emitter): with emitter.define(f'public Object visit({c.full_name} node)', '@Override'): - emitter.println(f'PythonObject o = factory.createPythonObject(state.{c.name.cls_field});') + emitter.println(f'PythonObject o = createPythonObject(state.{c.name.cls_field});') for f in c.fields: self.visit(f, emitter) if c.outer_has_attributes or c.attributes: diff --git a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/java_file.py b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/java_file.py index 8119ee2fa9..8c37571e8b 100644 --- a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/java_file.py +++ b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/java_file.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, 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 @@ from typing import Optional HEADER = """/* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/AliasTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/AliasTy.java index cfd2343286..a492e85003 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/AliasTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/AliasTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgTy.java index 0ace1cb17e..07c350cef1 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgumentsTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgumentsTy.java index 1d783c4a0f..f73083ec50 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgumentsTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ArgumentsTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/BoolOpTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/BoolOpTy.java index 0717d0a435..e62e44bcb0 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/BoolOpTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/BoolOpTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/CmpOpTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/CmpOpTy.java index 1b881e99a0..2f154eb844 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/CmpOpTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/CmpOpTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ComprehensionTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ComprehensionTy.java index 4beed845a8..f42a5e1427 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ComprehensionTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ComprehensionTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExceptHandlerTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExceptHandlerTy.java index 9efab27d5d..6c0aa13c2f 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExceptHandlerTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExceptHandlerTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprContextTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprContextTy.java index a4b09cfdfb..e6f4f850b1 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprContextTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprContextTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprTy.java index 4612ccb74c..1fb5d88c9d 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ExprTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/KeywordTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/KeywordTy.java index ef64367a15..32aeca4faf 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/KeywordTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/KeywordTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/MatchCaseTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/MatchCaseTy.java index 1a883ad89d..f7f80b4fd7 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/MatchCaseTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/MatchCaseTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ModTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ModTy.java index a0bd22ed37..6ea70dcabe 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ModTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/ModTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/OperatorTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/OperatorTy.java index 43d5c410fa..15222bba8b 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/OperatorTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/OperatorTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/PatternTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/PatternTy.java index 1dcbb13df8..4b6ff77335 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/PatternTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/PatternTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/SSTreeVisitor.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/SSTreeVisitor.java index 8b22fd364b..9a48161b32 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/SSTreeVisitor.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/SSTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/StmtTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/StmtTy.java index 02b3cdcf05..ac67e6076c 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/StmtTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/StmtTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/TypeIgnoreTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/TypeIgnoreTy.java index a66076b4ac..c5952df203 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/TypeIgnoreTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/TypeIgnoreTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/UnaryOpTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/UnaryOpTy.java index b3805a57b9..03b2e2d6a6 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/UnaryOpTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/UnaryOpTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/WithItemTy.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/WithItemTy.java index 69665b12cb..7a102ea40f 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/WithItemTy.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/sst/WithItemTy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/ConversionNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/ConversionNodeTests.java index a8efa356d8..f8f223d639 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/ConversionNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/ConversionNodeTests.java @@ -57,6 +57,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.frame.VirtualFrame; @@ -96,7 +97,7 @@ public boolean isPythonInternal() { }.getCallTarget(); try { Object[] arguments = PArguments.create(1); - PArguments.setGlobals(arguments, pythonContext.factory().createDict()); + PArguments.setGlobals(arguments, PFactory.createDict(language)); PArguments.setException(arguments, PException.NO_EXCEPTION); PArguments.setArgument(arguments, 0, arg); PythonThreadState threadState = pythonContext.getThreadState(language); diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/DirFdConversionNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/DirFdConversionNodeTests.java index c50c407a1d..df5386d0be 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/DirFdConversionNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/DirFdConversionNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -52,10 +52,11 @@ import org.junit.Before; import org.junit.Test; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.PosixModuleBuiltinsFactory; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; public class DirFdConversionNodeTests extends ConversionNodeTests { @@ -108,20 +109,20 @@ public void longTooSmall() { @Test public void pintFitsInt() { - Assert.assertEquals(42, call(factory().createInt(BigInteger.valueOf(42)))); + Assert.assertEquals(42, call(PFactory.createInt(PythonLanguage.get(null), BigInteger.valueOf(42)))); } @Test public void pintTooBig() { expectPythonMessage("OverflowError: fd is greater than maximum", () -> { - call(factory().createInt(BigInteger.ONE.shiftLeft(100))); + call(PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100))); }); } @Test public void pintTooSmall() { expectPythonMessage("OverflowError: fd is less than minimum", () -> { - call(factory().createInt(BigInteger.ONE.shiftLeft(100).negate())); + call(PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100).negate())); }); } @@ -162,10 +163,6 @@ protected static int call(Object arg) { return (int) result; } - private static PythonObjectFactory factory() { - return PythonObjectFactory.getUncached(); - } - private static Object evalValue(String source) { return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source)); } diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/FileDescriptorConversionNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/FileDescriptorConversionNodeTests.java index fcd75590d8..eeac46c197 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/FileDescriptorConversionNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/FileDescriptorConversionNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -52,10 +52,11 @@ import org.junit.Before; import org.junit.Test; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.PosixModuleBuiltinsFactory; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; public class FileDescriptorConversionNodeTests extends ConversionNodeTests { @@ -110,20 +111,20 @@ public void longTooSmall() { @Test public void pintFitsInt() { - Assert.assertEquals(42, call(factory().createInt(BigInteger.valueOf(42)))); + Assert.assertEquals(42, call(PFactory.createInt(PythonLanguage.get(null), BigInteger.valueOf(42)))); } @Test public void pintTooBig() { expectPythonMessage("OverflowError: Python int too large to convert to Java int", () -> { - call(factory().createInt(BigInteger.ONE.shiftLeft(100))); + call(PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100))); }); } @Test public void pintTooSmall() { expectPythonMessage("OverflowError: Python int too large to convert to Java int", () -> { - call(factory().createInt(BigInteger.ONE.shiftLeft(100).negate())); + call(PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100).negate())); }); } @@ -166,10 +167,6 @@ protected static int call(Object arg) { return (int) result; } - private static PythonObjectFactory factory() { - return PythonObjectFactory.getUncached(); - } - private static Object evalValue(String source) { return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source)); } diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/PathConversionNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/PathConversionNodeTests.java index 4e11a6859f..e42ef940fd 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/PathConversionNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/PathConversionNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -59,6 +59,7 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.PosixFd; import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.PosixPath; import com.oracle.graal.python.builtins.modules.PosixModuleBuiltinsFactory; @@ -67,7 +68,7 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.runtime.PosixSupportLibrary.Buffer; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; import com.oracle.graal.python.util.Function; import com.oracle.truffle.api.strings.TruffleString; @@ -123,7 +124,7 @@ public void noValueForbiddenWithoutFd() { @Test public void string() { Assert.assertEquals("abc", callAndExpectPath(false, false, T_ABC, false)); - Assert.assertEquals("abc", callAndExpectPath(false, false, factory().createString(T_ABC), false)); + Assert.assertEquals("abc", callAndExpectPath(false, false, PFactory.createString(PythonLanguage.get(null), T_ABC), false)); } @Test @@ -135,16 +136,16 @@ public void stringWithZero() { @Test public void bytes() { - Assert.assertEquals("abc", callAndExpectPath(false, false, factory().createBytes("abc".getBytes()), true)); - Assert.assertEquals("abc", callAndExpectPath(false, true, factory().createBytes("abc".getBytes()), true)); - Assert.assertEquals("abc", callAndExpectPath(true, false, factory().createBytes("abc".getBytes()), true)); - Assert.assertEquals("abc", callAndExpectPath(true, true, factory().createBytes("abc".getBytes()), true)); + Assert.assertEquals("abc", callAndExpectPath(false, false, PFactory.createBytes(PythonLanguage.get(null), "abc".getBytes()), true)); + Assert.assertEquals("abc", callAndExpectPath(false, true, PFactory.createBytes(PythonLanguage.get(null), "abc".getBytes()), true)); + Assert.assertEquals("abc", callAndExpectPath(true, false, PFactory.createBytes(PythonLanguage.get(null), "abc".getBytes()), true)); + Assert.assertEquals("abc", callAndExpectPath(true, true, PFactory.createBytes(PythonLanguage.get(null), "abc".getBytes()), true)); } @Test public void bytesWithZero() { expectPythonMessage("ValueError: fun: embedded null character in arg", () -> { - call(false, false, factory().createBytes("a\0c".getBytes())); + call(false, false, PFactory.createBytes(PythonLanguage.get(null), "a\0c".getBytes())); }); } @@ -221,27 +222,27 @@ public void longForbidden() { @Test public void pintFitsInt() { - Assert.assertEquals(42, callAndExpectFd(factory().createInt(BigInteger.valueOf(42)))); + Assert.assertEquals(42, callAndExpectFd(PFactory.createInt(PythonLanguage.get(null), BigInteger.valueOf(42)))); } @Test public void pintTooBig() { expectPythonMessage("OverflowError: fd is greater than maximum", () -> { - call(false, true, factory().createInt(BigInteger.ONE.shiftLeft(100))); + call(false, true, PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100))); }); } @Test public void pintTooSmall() { expectPythonMessage("OverflowError: fd is less than minimum", () -> { - call(false, true, factory().createInt(BigInteger.ONE.shiftLeft(100).negate())); + call(false, true, PFactory.createInt(PythonLanguage.get(null), BigInteger.ONE.shiftLeft(100).negate())); }); } @Test public void pintForbidden() { expectPythonMessage("TypeError: fun: arg should be string, bytes, os.PathLike or None, not int", () -> { - call(true, false, factory().createInt(BigInteger.valueOf(42))); + call(true, false, PFactory.createInt(PythonLanguage.get(null), BigInteger.valueOf(42))); }); } @@ -386,10 +387,6 @@ protected static Object call(boolean nullable, boolean allowFd, Object arg) { return call(arg, PosixModuleBuiltinsFactory.PathConversionNodeGen.create("fun", "arg", nullable, allowFd)); } - private static PythonObjectFactory factory() { - return PythonObjectFactory.getUncached(); - } - private static Object evalValue(String source) { return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source)); } diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/dict/PDictTest.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/dict/PDictTest.java index 7219973429..30450f9d61 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/dict/PDictTest.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/dict/PDictTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -48,11 +48,12 @@ import org.junit.Before; import org.junit.Test; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDelItem; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; import com.oracle.truffle.api.strings.TruffleString; @@ -82,7 +83,7 @@ static int length(PDict dict) { @Test public void economicMapStorageTransition() { - PDict dict = PythonObjectFactory.getUncached().createDict(); + PDict dict = PFactory.createDict(PythonLanguage.get(null)); dict.setItem(ts("key1"), 42); dict.setItem(11, ts("abc")); assertTrue(dict.getDictStorage() instanceof EconomicMapStorage); @@ -91,7 +92,7 @@ public void economicMapStorageTransition() { @Test public void economicMapStorageSet() { - PDict dict = PythonObjectFactory.getUncached().createDict(); + PDict dict = PFactory.createDict(PythonLanguage.get(null)); dict.setItem(11, ts("abc")); assertTrue(dict.getDictStorage() instanceof EconomicMapStorage); @@ -103,7 +104,7 @@ public void economicMapStorageSet() { @Test public void economicMapStorageDel() { - PDict dict = PythonObjectFactory.getUncached().createDict(); + PDict dict = PFactory.createDict(PythonLanguage.get(null)); dict.setItem(11, ts("abc")); dict.setItem(ts("key1"), 42); dict.setItem(ts("key2"), 24); diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java index 29ef1d1168..d8448fe7aa 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -37,7 +37,7 @@ import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -64,10 +64,10 @@ public void doInsert(Node child) { public void loopWithOnlyStop() throws UnexpectedResultException { PythonTests.enterContext(); try { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - PRange range = factory.createIntRange(10); + PythonLanguage language = PythonLanguage.get(null); + PRange range = PFactory.createIntRange(language, 10); int index = 0; - TestRoot testRoot = new TestRoot(PythonLanguage.get(factory)); + TestRoot testRoot = new TestRoot(language); Object iter = PyObjectGetIter.executeUncached(range); GetNextNode next = GetNextNode.create(); testRoot.doInsert(next); @@ -92,10 +92,10 @@ public void loopWithOnlyStop() throws UnexpectedResultException { public void loopWithStep() throws UnexpectedResultException { PythonTests.enterContext(); try { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - PRange range = PythonObjectFactory.getUncached().createIntRange(0, 10, 2, 5); + PythonLanguage language = PythonLanguage.get(null); + PRange range = PFactory.createIntRange(language, 0, 10, 2, 5); int index = 0; - TestRoot testRoot = new TestRoot(PythonLanguage.get(factory)); + TestRoot testRoot = new TestRoot(language); Object iter = PyObjectGetIter.executeUncached(range); GetNextNode next = GetNextNode.create(); testRoot.doInsert(next); @@ -120,7 +120,7 @@ public void loopWithStep() throws UnexpectedResultException { public void getItem() { PythonTests.enterContext(); try { - PIntRange range = PythonObjectFactory.getUncached().createIntRange(10); + PIntRange range = PFactory.createIntRange(PythonLanguage.get(null), 10); assertEquals(3, range.getIntItemNormalized(3)); } finally { PythonTests.closeContext(); diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/util/CastToJavaUnsignedLongNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/util/CastToJavaUnsignedLongNodeTests.java index 97524bb859..7be63c54d2 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/util/CastToJavaUnsignedLongNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/util/CastToJavaUnsignedLongNodeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -50,17 +50,16 @@ import org.junit.Before; import org.junit.Test; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.util.CastToJavaUnsignedLongNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; public class CastToJavaUnsignedLongNodeTests { - private static PythonObjectFactory factory = PythonObjectFactory.getUncached(); - @Before public void setUp() { PythonTests.enterContext(); @@ -127,11 +126,11 @@ public void nonInteger() { } private static PInt makePInt(long l) { - return factory.createInt(BigInteger.valueOf(l)); + return PFactory.createInt(PythonLanguage.get(null), BigInteger.valueOf(l)); } private static PInt makePInt(String hexString) { - return factory.createInt(new BigInteger(hexString, 16)); + return PFactory.createInt(PythonLanguage.get(null), new BigInteger(hexString, 16)); } private static void expect(PythonBuiltinClassType errorType, Runnable test) { diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java index d702d04fbf..ead733eca1 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -47,6 +47,7 @@ import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.test.PythonTests; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; @@ -91,7 +92,7 @@ public void tearDown() { @Test public void pythonModuleTest() { - PythonModule module = context.factory().createPythonModule(tsLiteral("testModule")); + PythonModule module = PFactory.createPythonModule(context.getLanguage(), tsLiteral("testModule")); assertEquals("testModule", module.getAttribute(T___NAME__).toString()); assertEquals("None", module.getAttribute(T___DOC__).toString()); assertEquals("None", module.getAttribute(T___PACKAGE__).toString()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index db34ae3f50..c48c51e79d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -107,7 +107,7 @@ import com.oracle.graal.python.runtime.PythonImageBuildOptions; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.Function; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.Supplier; @@ -127,6 +127,7 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Idempotent; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.AllocationReporter; import com.oracle.truffle.api.instrumentation.ProvidedTags; import com.oracle.truffle.api.instrumentation.StandardTags; import com.oracle.truffle.api.interop.InteropLibrary; @@ -440,6 +441,7 @@ private DescriptorCallTargets getOrCreateStructSeqNonBuiltinTargets(Descriptor d @CompilationFinal(dimensions = 1) private volatile Object[] engineOptionsStorage; @CompilationFinal private volatile OptionValues engineOptions; + @CompilationFinal private AllocationReporter allocationReporter; /** For fast access to the PythonThreadState object by the owning thread. */ private final ContextThreadLocal threadState = locals.createContextThreadLocal(PythonContext.PythonThreadState::new); @@ -521,6 +523,12 @@ protected PythonContext createContext(Env env) { assert areOptionsCompatible(options, PythonOptions.createEngineOptions(env)) : "invalid engine options"; } + if (allocationReporter == null) { + allocationReporter = env.lookup(AllocationReporter.class); + } else { + assert allocationReporter == env.lookup(AllocationReporter.class); + } + return context; } @@ -534,6 +542,11 @@ public T getEngineOption(OptionKey key) { } } + public AllocationReporter getAllocationReporter() { + assert allocationReporter != null; + return allocationReporter; + } + @Override protected OptionDescriptors getOptionDescriptors() { return PythonOptions.DESCRIPTORS; @@ -593,7 +606,7 @@ protected CallTarget parse(ParsingRequest request) { } if (MIME_TYPE_BYTECODE.equals(source.getMimeType())) { byte[] bytes = source.getBytes().toByteArray(); - CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(bytes); + CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(context, bytes); boolean internal = shouldMarkSourceInternal(context); // The original file path should be passed as the name String name = source.getName(); @@ -804,8 +817,8 @@ public Object execute(VirtualFrame frame) { @Override protected Object getLanguageView(PythonContext context, Object value) { assert !(value instanceof PythonAbstractObject); - PythonObjectFactory factory = PythonObjectFactory.getUncached(); InteropLibrary interopLib = InteropLibrary.getFactory().getUncached(value); + PythonLanguage language = context.getLanguage(); try { if (interopLib.isBoolean(value)) { if (interopLib.asBoolean(value)) { @@ -814,21 +827,21 @@ protected Object getLanguageView(PythonContext context, Object value) { return context.getFalse(); } } else if (interopLib.isString(value)) { - return factory.createString(interopLib.asTruffleString(value).switchEncodingUncached(TS_ENCODING)); + return PFactory.createString(language, interopLib.asTruffleString(value).switchEncodingUncached(TS_ENCODING)); } else if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) { // TODO: (tfel) once the interop protocol allows us to // distinguish fixed point from floating point reliably, we can // remove this branch - return factory.createInt(interopLib.asLong(value)); + return PFactory.createInt(language, interopLib.asLong(value)); } else if (value instanceof Float || value instanceof Double) { // TODO: (tfel) once the interop protocol allows us to // distinguish fixed point from floating point reliably, we can // remove this branch - return factory.createFloat(interopLib.asDouble(value)); + return PFactory.createFloat(language, interopLib.asDouble(value)); } else if (interopLib.fitsInLong(value)) { - return factory.createInt(interopLib.asLong(value)); + return PFactory.createInt(language, interopLib.asLong(value)); } else if (interopLib.fitsInDouble(value)) { - return factory.createFloat(interopLib.asDouble(value)); + return PFactory.createFloat(language, interopLib.asDouble(value)); } else { return new ForeignLanguageView(value); } @@ -1054,13 +1067,19 @@ public Shape getBuiltinTypeInstanceShape(PythonBuiltinClassType type) { Shape shape = builtinTypeInstanceShapes[ordinal]; if (shape == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - Shape.DerivedBuilder shapeBuilder = Shape.newBuilder(getEmptyShape()).addConstantProperty(HiddenAttr.getClassHiddenKey(), type, 0); - if (!type.isBuiltinWithDict()) { - shapeBuilder.shapeFlags(PythonObject.HAS_SLOTS_BUT_NO_DICT_FLAG); - } - shape = shapeBuilder.build(); - builtinTypeInstanceShapes[ordinal] = shape; + shape = createBuiltinShape(type, ordinal); + } + return shape; + } + + private Shape createBuiltinShape(PythonBuiltinClassType type, int ordinal) { + Shape shape; + Shape.DerivedBuilder shapeBuilder = Shape.newBuilder(getEmptyShape()).addConstantProperty(HiddenAttr.getClassHiddenKey(), type, 0); + if (!type.isBuiltinWithDict()) { + shapeBuilder.shapeFlags(PythonObject.HAS_SLOTS_BUT_NO_DICT_FLAG); } + shape = shapeBuilder.build(); + builtinTypeInstanceShapes[ordinal] = shape; return shape; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/BoundBuiltinCallable.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/BoundBuiltinCallable.java index 833560df82..07f3c49918 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/BoundBuiltinCallable.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/BoundBuiltinCallable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -40,8 +40,8 @@ */ package com.oracle.graal.python.builtins; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.PythonLanguage; public interface BoundBuiltinCallable { - T boundToObject(PythonBuiltinClassType binding, PythonObjectFactory factory); + T boundToObject(PythonBuiltinClassType binding, PythonLanguage language); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index 3146f1acf9..7d6dd23d65 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -59,9 +59,6 @@ import java.util.ServiceLoader; import java.util.logging.Level; -import com.oracle.graal.python.builtins.objects.foreign.ForeignExecutableBuiltins; -import com.oracle.graal.python.builtins.objects.foreign.ForeignInstantiableBuiltins; -import com.oracle.graal.python.builtins.objects.foreign.ForeignIterableBuiltins; import org.graalvm.nativeimage.ImageInfo; import com.oracle.graal.python.PythonLanguage; @@ -264,6 +261,9 @@ import com.oracle.graal.python.builtins.objects.floats.PFloat; import com.oracle.graal.python.builtins.objects.foreign.ForeignAbstractClassBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignBooleanBuiltins; +import com.oracle.graal.python.builtins.objects.foreign.ForeignExecutableBuiltins; +import com.oracle.graal.python.builtins.objects.foreign.ForeignInstantiableBuiltins; +import com.oracle.graal.python.builtins.objects.foreign.ForeignIterableBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignNumberBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignObjectBuiltins; import com.oracle.graal.python.builtins.objects.frame.FrameBuiltins; @@ -384,7 +384,7 @@ import com.oracle.graal.python.runtime.exception.ExceptionUtils; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.interop.PythonMapScope; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.Supplier; import com.oracle.truffle.api.CallTarget; @@ -396,6 +396,7 @@ import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLogger; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; @@ -842,7 +843,6 @@ private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed, private volatile boolean initialized; private final PythonLanguage language; - @CompilationFinal private PythonObjectSlowPathFactory objectFactory; public Python3Core(PythonLanguage language, boolean isNativeSupportAllowed, boolean socketIOAllowed) { this.language = language; @@ -924,7 +924,6 @@ public final boolean isCoreInitialized() { * Load the core library and prepare all builtin classes and modules. */ public final void initialize(PythonContext context) { - objectFactory = new PythonObjectSlowPathFactory(context.getAllocationReporter(), context.getLanguage()); initializeJavaCore(); initializeImportlib(); context.applyModuleOptions(); @@ -1216,9 +1215,11 @@ private void initializeTypes() { } } // now initialize well-known objects - pyTrue = factory().createInt(PythonBuiltinClassType.Boolean, BigInteger.ONE); - pyFalse = factory().createInt(PythonBuiltinClassType.Boolean, BigInteger.ZERO); - pyNaN = factory().createFloat(Double.NaN); + PythonBuiltinClassType booleanType = PythonBuiltinClassType.Boolean; + Shape booleanShape = booleanType.getInstanceShape(getLanguage()); + pyTrue = PFactory.createInt(getLanguage(), booleanType, booleanShape, BigInteger.ONE); + pyFalse = PFactory.createInt(getLanguage(), booleanType, booleanShape, BigInteger.ZERO); + pyNaN = PFactory.createFloat(getLanguage(), Double.NaN); } private void populateBuiltins() { @@ -1247,7 +1248,7 @@ private void populateBuiltins() { for (PythonBuiltinClassType klass : PythonBuiltinClassType.VALUES) { wrapped.clear(); TpSlots.addOperatorsToBuiltin(wrapped, this, klass); - PythonBuiltins.addFunctionsToModuleObject(wrapped, lookupType(klass), factory()); + PythonBuiltins.addFunctionsToModuleObject(wrapped, lookupType(klass), getLanguage()); } // core machinery @@ -1269,7 +1270,7 @@ private void addBuiltinModule(TruffleString name, PythonModule module) { private PythonModule createModule(TruffleString name, PythonBuiltins moduleBuiltins) { PythonModule mod = builtinModules.get(name); if (mod == null) { - mod = factory().createPythonModule(name); + mod = PFactory.createPythonModule(getLanguage(), name); if (moduleBuiltins != null) { mod.setBuiltins(moduleBuiltins); } @@ -1280,7 +1281,7 @@ private PythonModule createModule(TruffleString name, PythonBuiltins moduleBuilt private void addBuiltinsTo(PythonObject obj, PythonBuiltins builtinsForObj) { builtinsForObj.addConstantsToModuleObject(obj); - builtinsForObj.addFunctionsToModuleObject(obj, objectFactory); + builtinsForObj.addFunctionsToModuleObject(obj, getLanguage()); } @TruffleBoundary @@ -1306,7 +1307,7 @@ private void loadFile(TruffleString s, TruffleString prefix) { PythonModule mod = lookupBuiltinModule(s); if (mod == null) { // use an anonymous module for the side-effects - mod = factory().createPythonModule(T___ANONYMOUS__); + mod = PFactory.createPythonModule(getLanguage(), T___ANONYMOUS__); } loadFile(s, prefix, mod); } @@ -1324,10 +1325,6 @@ private void loadFile(TruffleString s, TruffleString prefix, PythonModule mod) { GenericInvokeNode.getUncached().execute(callTarget, PArguments.withGlobals(mod)); } - public final PythonObjectSlowPathFactory factory() { - return objectFactory; - } - public final PInt getTrue() { return pyTrue; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java index 8d586cc758..07881f7807 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java @@ -173,7 +173,6 @@ import com.oracle.graal.python.builtins.objects.types.UnionTypeBuiltins; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.interop.TruffleObject; @@ -799,9 +798,6 @@ public String toString() { } public final Shape getInstanceShape(PythonLanguage lang) { - if (name == null) { - throw CompilerDirectives.shouldNotReachHere("incorrect use of Python builtin type marker"); - } return lang.getBuiltinTypeInstanceShape(this); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltins.java index 89f6cc235b..4770b57d70 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -116,6 +116,7 @@ import java.util.Map.Entry; import java.util.Set; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; @@ -125,7 +126,7 @@ import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.BiConsumer; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.NodeFactory; @@ -173,7 +174,8 @@ public void initialize(Python3Core core) { declaresExplicitSelf = true; } TruffleString tsName = toTruffleStringUncached(builtin.name()); - RootCallTarget callTarget = core.getLanguage().initBuiltinCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, factory, declaresExplicitSelf), factory.getNodeClass(), + PythonLanguage language = core.getLanguage(); + RootCallTarget callTarget = language.initBuiltinCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, factory, declaresExplicitSelf), factory.getNodeClass(), builtin.name()); Object builtinDoc = builtin.doc().isEmpty() ? PNone.NONE : toTruffleStringUncached(builtin.doc()); int flags = PBuiltinFunction.getFlags(builtin, callTarget); @@ -181,8 +183,8 @@ public void initialize(Python3Core core) { assert !builtin.isGetter() && !builtin.isSetter() && !builtin.isClassmethod() && !builtin.isStaticmethod(); // we explicitly do not make these "staticmethods" here, since CPython also doesn't // for builtin types - PBuiltinFunction newFunc = core.factory().createBuiltinFunction(T___NEW__, constructsClass, numDefaults(builtin), flags, callTarget); - PBuiltinMethod newMethod = core.factory().createBuiltinMethod(constructsClass, newFunc); + PBuiltinFunction newFunc = PFactory.createBuiltinFunction(language, T___NEW__, constructsClass, numDefaults(builtin), flags, callTarget); + PBuiltinMethod newMethod = PFactory.createBuiltinMethod(language, constructsClass, newFunc); PythonBuiltinClass builtinClass = core.lookupType(constructsClass); builtinClass.setAttributeUnsafe(T___NEW__, newMethod); final Object currentBuiltinDoc = builtinClass.getAttribute(T___DOC__); @@ -195,9 +197,9 @@ public void initialize(Python3Core core) { // HACK: TODO: we should not see any slots here anymore once all are converted // to slots, then we can make the slot field in PBuiltinFunction final, for now, // we patch it in TpSlots#wrapBuiltinSlots - function = core.factory().createWrapperDescriptor(tsName, null, numDefaults(builtin), flags, callTarget, null, null); + function = PFactory.createWrapperDescriptor(language, tsName, null, numDefaults(builtin), flags, callTarget, null, null); } else { - function = core.factory().createBuiltinFunction(tsName, null, numDefaults(builtin), flags, callTarget); + function = PFactory.createBuiltinFunction(language, tsName, null, numDefaults(builtin), flags, callTarget); } function.setAttribute(T___DOC__, builtinDoc); BoundBuiltinCallable callable = function; @@ -205,12 +207,12 @@ public void initialize(Python3Core core) { assert !builtin.isClassmethod() && !builtin.isStaticmethod(); PBuiltinFunction get = builtin.isGetter() ? function : null; PBuiltinFunction set = builtin.isSetter() ? function : null; - callable = core.factory().createGetSetDescriptor(get, set, tsName, null, builtin.allowsDelete()); + callable = PFactory.createGetSetDescriptor(language, get, set, tsName, null, builtin.allowsDelete()); } else if (builtin.isClassmethod()) { assert !builtin.isStaticmethod(); - callable = core.factory().createBuiltinClassmethodFromCallableObj(function); + callable = PFactory.createBuiltinClassmethodFromCallableObj(language, function); } else if (builtin.isStaticmethod()) { - callable = core.factory().createStaticmethodFromCallableObj(function); + callable = PFactory.createStaticmethodFromCallableObj(language, function); } builtinFunctions.put(toTruffleStringUncached(builtin.name()), callable); } @@ -294,18 +296,18 @@ void addConstantsToModuleObject(PythonObject obj) { } } - void addFunctionsToModuleObject(PythonObject obj, PythonObjectSlowPathFactory factory) { - addFunctionsToModuleObject(builtinFunctions, obj, factory); + void addFunctionsToModuleObject(PythonObject obj, PythonLanguage language) { + addFunctionsToModuleObject(builtinFunctions, obj, language); } - static void addFunctionsToModuleObject(Map> builtinFunctions, PythonObject obj, PythonObjectSlowPathFactory factory) { + static void addFunctionsToModuleObject(Map> builtinFunctions, PythonObject obj, PythonLanguage language) { for (Entry> entry : builtinFunctions.entrySet()) { Object value; assert obj instanceof PythonModule || obj instanceof PythonBuiltinClass : "unexpected object while adding builtins"; if (obj instanceof PythonModule) { - value = factory.createBuiltinMethod(obj, (PBuiltinFunction) entry.getValue()); + value = PFactory.createBuiltinMethod(language, obj, (PBuiltinFunction) entry.getValue()); } else { - value = entry.getValue().boundToObject(((PythonBuiltinClass) obj).getType(), factory); + value = entry.getValue().boundToObject(((PythonBuiltinClass) obj).getType(), language); } obj.setAttribute(entry.getKey(), value); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java index ce713d1aa2..fcf8ecaef9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -40,6 +40,7 @@ import java.nio.ByteOrder; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -59,6 +60,7 @@ import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.range.PIntRange; import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToTruffleStringCheckedNode; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.GetNextNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetIter; @@ -74,7 +76,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.util.SplitArgsNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.BufferFormat; @@ -169,21 +171,23 @@ abstract static class ArrayNodeInternal extends Node { @Specialization(guards = "isNoValue(initializer)") static PArray array(Node inliningTarget, Object cls, TruffleString typeCode, @SuppressWarnings("unused") PNone initializer, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); - return factory.createArray(cls, typeCode, format); + return PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format); } @Specialization @InliningCutoff static PArray arrayWithRangeInitializer(Node inliningTarget, Object cls, TruffleString typeCode, PIntRange range, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached ArrayNodes.PutValueNode putValueNode) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); PArray array; try { - array = factory.createArray(cls, typeCode, format, range.getIntLength()); + array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format, range.getIntLength()); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); @@ -203,10 +207,11 @@ static PArray arrayWithRangeInitializer(Node inliningTarget, Object cls, Truffle @Specialization static PArray arrayWithBytesInitializer(VirtualFrame frame, Node inliningTarget, Object cls, TruffleString typeCode, PBytesLike bytes, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(inline = false) ArrayBuiltins.FromBytesNode fromBytesNode) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); - PArray array = factory.createArray(cls, typeCode, format); + PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format); fromBytesNode.executeWithoutClinic(frame, array, bytes); return array; } @@ -215,14 +220,15 @@ static PArray arrayWithBytesInitializer(VirtualFrame frame, Node inliningTarget, @InliningCutoff static PArray arrayWithStringInitializer(VirtualFrame frame, Node inliningTarget, Object cls, TruffleString typeCode, Object initializer, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(inline = false) ArrayBuiltins.FromUnicodeNode fromUnicodeNode, @Cached PRaiseNode.Lazy raise) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); if (format != BufferFormat.UNICODE) { throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_USE_STR_TO_INITIALIZE_ARRAY, typeCode); } - PArray array = factory.createArray(cls, typeCode, format); + PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format); fromUnicodeNode.execute(frame, array, initializer); return array; } @@ -231,13 +237,14 @@ static PArray arrayWithStringInitializer(VirtualFrame frame, Node inliningTarget @InliningCutoff static PArray arrayArrayInitializer(VirtualFrame frame, Node inliningTarget, Object cls, TruffleString typeCode, PArray initializer, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached ArrayNodes.PutValueNode putValueNode, @Cached ArrayNodes.GetValueNode getValueNode) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); try { int length = initializer.getLength(); - PArray array = factory.createArray(cls, typeCode, format, length); + PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format, length); for (int i = 0; i < length; i++) { putValueNode.execute(frame, inliningTarget, array, i, getValueNode.execute(inliningTarget, initializer, i)); } @@ -252,7 +259,8 @@ static PArray arrayArrayInitializer(VirtualFrame frame, Node inliningTarget, Obj @InliningCutoff static PArray arraySequenceInitializer(VirtualFrame frame, Node inliningTarget, Object cls, TruffleString typeCode, PSequence initializer, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached ArrayNodes.PutValueNode putValueNode, @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode) { @@ -260,7 +268,7 @@ static PArray arraySequenceInitializer(VirtualFrame frame, Node inliningTarget, SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, initializer); int length = storage.length(); try { - PArray array = factory.createArray(cls, typeCode, format, length); + PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format, length); for (int i = 0; i < length; i++) { putValueNode.execute(frame, inliningTarget, array, i, getItemNode.execute(inliningTarget, storage, i)); } @@ -276,7 +284,8 @@ static PArray arraySequenceInitializer(VirtualFrame frame, Node inliningTarget, static PArray arrayIteratorInitializer(VirtualFrame frame, Node inliningTarget, Object cls, TruffleString typeCode, Object initializer, @Cached PyObjectGetIter getIter, @Shared @Cached GetFormatCheckedNode getFormatCheckedNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached ArrayNodes.PutValueNode putValueNode, @Cached(inline = false) GetNextNode nextNode, @Cached IsBuiltinObjectProfile errorProfile, @@ -285,7 +294,7 @@ static PArray arrayIteratorInitializer(VirtualFrame frame, Node inliningTarget, Object iter = getIter.execute(frame, inliningTarget, initializer); BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); - PArray array = factory.createArray(cls, typeCode, format); + PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format); int length = 0; while (true) { @@ -353,14 +362,14 @@ static Object reconstructCached(VirtualFrame frame, Object arrayType, TruffleStr @Exclusive @Cached ArrayBuiltins.ByteSwapNode byteSwapNode, @Exclusive @Cached TruffleString.CodePointLengthNode lengthNode, @Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Exclusive @Cached PythonObjectFactory factory, + @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode); if (format == null) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_TYPECODE); } return doReconstruct(frame, inliningTarget, arrayType, typeCode, cachedCode, bytes, callDecode, fromBytesNode, fromUnicodeNode, isSubtypeNode, byteSwapNode, formatProfile.profile(format), - factory, raiseNode); + getInstanceShape, raiseNode); } @Specialization(replaces = "reconstructCached") @@ -373,19 +382,20 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty @Exclusive @Cached ArrayBuiltins.ByteSwapNode byteSwapNode, @Exclusive @Cached TruffleString.CodePointLengthNode lengthNode, @Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Exclusive @Cached PythonObjectFactory factory, + @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode); if (format == null) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_TYPECODE); } - return doReconstruct(frame, inliningTarget, arrayType, typeCode, mformatCode, bytes, callDecode, fromBytesNode, fromUnicodeNode, isSubtypeNode, byteSwapNode, format, factory, raiseNode); + return doReconstruct(frame, inliningTarget, arrayType, typeCode, mformatCode, bytes, callDecode, fromBytesNode, fromUnicodeNode, isSubtypeNode, byteSwapNode, format, getInstanceShape, + raiseNode); } private static Object doReconstruct(VirtualFrame frame, Node inliningTarget, Object arrayType, TruffleString typeCode, int mformatCode, PBytes bytes, PyObjectCallMethodObjArgs callDecode, ArrayBuiltins.FromBytesNode fromBytesNode, ArrayBuiltins.FromUnicodeNode fromUnicodeNode, IsSubtypeNode isSubtypeNode, ArrayBuiltins.ByteSwapNode byteSwapNode, BufferFormat format, - PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { + TypeNodes.GetInstanceShape getInstanceShape, PRaiseNode.Lazy raiseNode) { if (!isSubtypeNode.execute(frame, arrayType, PythonBuiltinClassType.PArray)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_NOT_SUBTYPE_OF_ARRAY, arrayType); } @@ -393,11 +403,11 @@ private static Object doReconstruct(VirtualFrame frame, Node inliningTarget, Obj if (machineFormat != null) { PArray array; if (machineFormat == MachineFormat.forFormat(format)) { - array = factory.createArray(arrayType, typeCode, machineFormat.format); + array = PFactory.createArray(PythonLanguage.get(inliningTarget), arrayType, getInstanceShape.execute(arrayType), typeCode, machineFormat.format); fromBytesNode.executeWithoutClinic(frame, array, bytes); } else { TruffleString newTypeCode = machineFormat.format == format ? typeCode : machineFormat.format.baseTypeCode; - array = factory.createArray(arrayType, newTypeCode, machineFormat.format); + array = PFactory.createArray(PythonLanguage.get(inliningTarget), arrayType, getInstanceShape.execute(arrayType), newTypeCode, machineFormat.format); if (machineFormat.unicodeEncoding != null) { Object decoded = callDecode.execute(frame, inliningTarget, bytes, T_DECODE, machineFormat.unicodeEncoding); fromUnicodeNode.execute(frame, array, decoded); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java index 86f6cdf903..b0b39be693 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java @@ -70,7 +70,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -253,9 +253,8 @@ public Object unregisterTask(VirtualFrame frame, PythonModule self, Object task, @Override public void postInitialize(Python3Core core) { - PythonObjectSlowPathFactory factory = core.factory(); PythonModule self = core.lookupBuiltinModule(T__ASYNCIO); - self.setAttribute(CURRENT_TASKS_ATTR, factory.createDict()); + self.setAttribute(CURRENT_TASKS_ATTR, PFactory.createDict(core.getLanguage())); Object weakref = AbstractImportNode.importModule(WEAKREF); Object weakSetCls = PyObjectGetAttr.executeUncached(weakref, WEAKSET); Object weakSet = CallNode.executeUncached(weakSetCls); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java index e4f0b202a0..0511a7b818 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java @@ -54,6 +54,7 @@ import java.util.Base64; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ClinicConverterFactory; import com.oracle.graal.python.builtins.Builtin; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -195,10 +196,10 @@ abstract static class A2bBase64Node extends PythonBinaryClinicBuiltinNode { PBytes doConvert(VirtualFrame frame, Object buffer, boolean strictMode, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { ByteSequenceStorage storage = b64decode(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), strictMode); - return factory.createBytes(storage); + return PFactory.createBytes(language, storage); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -280,10 +281,10 @@ abstract static class A2bHexNode extends PythonUnaryClinicBuiltinNode { PBytes a2b(VirtualFrame frame, Object buffer, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { byte[] bytes = a2b(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer)); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -325,7 +326,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class B2aBase64Node extends PythonClinicBuiltinNode { @TruffleBoundary - private PBytes b2a(byte[] data, int lenght, int newline, PythonObjectFactory factory) { + private PBytes b2a(byte[] data, int lenght, int newline, PythonLanguage language) { ByteBuffer encoded; try { encoded = Base64.getEncoder().encode(ByteBuffer.wrap(data, 0, lenght)); @@ -335,18 +336,18 @@ private PBytes b2a(byte[] data, int lenght, int newline, PythonObjectFactory fac if (newline != 0) { byte[] encodedWithNL = Arrays.copyOf(encoded.array(), encoded.limit() + 1); encodedWithNL[encodedWithNL.length - 1] = '\n'; - return factory.createBytes(encodedWithNL); + return PFactory.createBytes(language, encodedWithNL); } - return factory.createBytes(encoded.array(), encoded.limit()); + return PFactory.createBytes(language, encoded.array(), encoded.limit()); } @Specialization(limit = "3") PBytes b2aBuffer(VirtualFrame frame, Object buffer, int newline, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { - return b2a(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), newline, factory); + return b2a(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), newline, language); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -371,28 +372,28 @@ static PBytes b2a(VirtualFrame frame, Object buffer, Object sep, int bytesPerSep @Bind("this") Node inliningTarget, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (sep != PNone.NO_VALUE || bytesPerSep != 1) { // TODO implement sep and bytes_per_sep throw raiseNode.get(inliningTarget).raise(NotImplementedError); } try { - return b2a(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), factory); + return b2a(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), language); } finally { bufferLib.release(buffer, frame, indirectCallData); } } @TruffleBoundary - private static PBytes b2a(byte[] bytes, int length, PythonObjectFactory factory) { + private static PBytes b2a(byte[] bytes, int length, PythonLanguage language) { byte[] output = new byte[length * 2]; for (int i = 0; i < length; i++) { int v = bytes[i] & 0xff; output[i * 2] = HEX_DIGITS[v >> 4]; output[i * 2 + 1] = HEX_DIGITS[v & 0xf]; } - return factory.createBytes(output); + return PFactory.createBytes(language, output); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java index 90d03d8aae..985c7f9d0d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java @@ -98,6 +98,7 @@ import java.math.BigInteger; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -115,7 +116,6 @@ import com.oracle.graal.python.builtins.objects.bytes.PByteArray; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.cell.PCell; -import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction; import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes; @@ -125,6 +125,7 @@ import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper; import com.oracle.graal.python.builtins.objects.code.CodeNodes; import com.oracle.graal.python.builtins.objects.code.PCode; +import com.oracle.graal.python.builtins.objects.common.EmptyStorage; import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetObjectArrayNode; @@ -159,7 +160,6 @@ import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.traceback.PTraceback; import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; import com.oracle.graal.python.builtins.objects.type.TypeBuiltins; @@ -232,8 +232,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.Assumption; @@ -259,6 +258,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; @@ -351,11 +351,18 @@ static Object dontCallBytes(VirtualFrame frame, Object cls, Object source, Objec abstract static class CreateBytes extends PNodeWithContext { abstract Object execute(Node inliningTarget, Object cls, byte[] bytes); + @Specialization(guards = "isBuiltinBytes(cls)") + static PBytes doBuiltin(@SuppressWarnings("unused") Object cls, byte[] bytes, + @Bind PythonLanguage language) { + return PFactory.createBytes(language, bytes); + } + @Specialization(guards = "!needsNativeAllocationNode.execute(inliningTarget, cls)") static PBytes doManaged(@SuppressWarnings("unused") Node inliningTarget, Object cls, byte[] bytes, @SuppressWarnings("unused") @Shared @Cached TypeNodes.NeedsNativeAllocationNode needsNativeAllocationNode, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createBytes(cls, bytes); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createBytes(language, cls, getInstanceShape.execute(cls), bytes); } @Specialization(guards = "needsNativeAllocationNode.execute(inliningTarget, cls)") @@ -371,6 +378,10 @@ static Object doNative(@SuppressWarnings("unused") Node inliningTarget, Object c wrapper.free(); } } + + protected static boolean isBuiltinBytes(Object cls) { + return cls == PythonBuiltinClassType.PBytes; + } } } @@ -391,9 +402,10 @@ static Object doNative(@SuppressWarnings("unused") Node inliningTarget, Object c public abstract static class ByteArrayNode extends PythonBuiltinNode { @Specialization public PByteArray setEmpty(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BytesCommonBuiltins.InitNode - return factory.createByteArray(cls, PythonUtils.EMPTY_BYTE_ARRAY); + return PFactory.createByteArray(language, cls, getInstanceShape.execute(cls), PythonUtils.EMPTY_BYTE_ARRAY); } // TODO: native allocation? @@ -423,8 +435,9 @@ public static Object executeUncached(Object cls, double real, double imaginary) @Specialization(guards = "!needsNativeAllocationNode.execute(inliningTarget, cls)", limit = "1") static PComplex doManaged(@SuppressWarnings("unused") Node inliningTarget, Object cls, double real, double imaginary, @SuppressWarnings("unused") @Cached NeedsNativeAllocationNode needsNativeAllocationNode, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(cls, real, imaginary); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createComplex(language, cls, getInstanceShape.execute(cls), real, imaginary); } @Fallback @@ -493,10 +506,9 @@ Object complexFromDouble(VirtualFrame frame, Object cls, PFloat real, @SuppressW @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode isBuiltinObjectProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { return complexFromObject(frame, cls, real, imag, inliningTarget, createComplexNode, canBeDoubleNode, asDoubleNode, isComplexType, isResultComplexType, isPrimitiveProfile, - isBuiltinObjectProfile, factory, + isBuiltinObjectProfile, raiseNode); } @@ -524,10 +536,9 @@ Object complexFromLong(VirtualFrame frame, Object cls, PInt real, @SuppressWarni @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode complexCheck, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { return complexFromObject(frame, cls, real, imag, inliningTarget, createComplexNode, canBeDoubleNode, asDoubleNode, isComplexType, isResultComplexType, isPrimitiveProfile, complexCheck, - factory, raiseNode); + raiseNode); } @Specialization(guards = {"isNoValue(imag)", "!isNoValue(number)", "!isString(number)"}) @@ -540,7 +551,6 @@ Object complexFromObject(VirtualFrame frame, Object cls, Object number, @Suppres @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode complexCheck, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { PComplex value = getComplexNumberFromObject(frame, number, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { @@ -554,7 +564,7 @@ Object complexFromObject(VirtualFrame frame, Object cls, Object number, @Suppres if (complexCheck.execute(inliningTarget, value)) { return value; } - return factory.createComplex(value.getReal(), value.getImag()); + return PFactory.createComplex(PythonLanguage.get(inliningTarget), value.getReal(), value.getImag()); } return createComplexNode.execute(inliningTarget, cls, value.getReal(), value.getImag()); } @@ -901,21 +911,23 @@ public abstract static class DictionaryNode extends PythonBuiltinNode { @Specialization(guards = "isBuiltinDict(cls)") @SuppressWarnings("unused") static PDict builtinDict(Object cls, Object[] args, PKeyword[] keywordArgs, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDict(); + @Bind PythonLanguage language) { + return PFactory.createDict(language); } @Specialization(replaces = "builtinDict") @SuppressWarnings("unused") static PDict dict(Object cls, Object[] args, PKeyword[] keywordArgs, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile orderedProfile, @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + Shape shape = getInstanceShape.execute(cls); if (orderedProfile.profile(inliningTarget, isSubtypeNode.execute(cls, PythonBuiltinClassType.POrderedDict))) { - return factory.createOrderedDict(cls); + return PFactory.createOrderedDict(language, cls, shape); } - return factory.createDict(cls); + return PFactory.createDict(language, cls, shape, EmptyStorage.INSTANCE); } protected static boolean isBuiltinDict(Object cls) { @@ -942,32 +954,36 @@ public abstract static class EnumerateNode extends PythonBuiltinNode { static PEnumerate doNone(VirtualFrame frame, Object cls, Object iterable, @SuppressWarnings("unused") PNone keywordArg, @Bind("this") Node inliningTarget, @Shared("getIter") @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEnumerate(cls, getIter.execute(frame, inliningTarget, iterable), 0); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createEnumerate(language, cls, getInstanceShape.execute(cls), getIter.execute(frame, inliningTarget, iterable), 0); } @Specialization static PEnumerate doInt(VirtualFrame frame, Object cls, Object iterable, int start, @Bind("this") Node inliningTarget, @Shared("getIter") @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEnumerate(cls, getIter.execute(frame, inliningTarget, iterable), start); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createEnumerate(language, cls, getInstanceShape.execute(cls), getIter.execute(frame, inliningTarget, iterable), start); } @Specialization static PEnumerate doLong(VirtualFrame frame, Object cls, Object iterable, long start, @Bind("this") Node inliningTarget, @Shared("getIter") @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEnumerate(cls, getIter.execute(frame, inliningTarget, iterable), start); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createEnumerate(language, cls, getInstanceShape.execute(cls), getIter.execute(frame, inliningTarget, iterable), start); } @Specialization static PEnumerate doPInt(VirtualFrame frame, Object cls, Object iterable, PInt start, @Bind("this") Node inliningTarget, @Shared("getIter") @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEnumerate(cls, getIter.execute(frame, inliningTarget, iterable), start); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createEnumerate(language, cls, getInstanceShape.execute(cls), getIter.execute(frame, inliningTarget, iterable), start); } static boolean isIntegerIndex(Object idx) { @@ -990,35 +1006,35 @@ public abstract static class ReversedNode extends PythonBuiltinNode { @Specialization static PythonObject reversed(@SuppressWarnings("unused") Object cls, PIntRange range, @Bind("this") Node inliningTarget, - @Cached InlinedBranchProfile overflowProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached InlinedBranchProfile overflowProfile) { int lstart = range.getIntStart(); int lstep = range.getIntStep(); int ulen = range.getIntLength(); try { int new_stop = subtractExact(lstart, lstep); int new_start = addExact(new_stop, multiplyExact(ulen, lstep)); - return factory.createIntRangeIterator(new_start, new_stop, negateExact(lstep), ulen); + return PFactory.createIntRangeIterator(language, new_start, new_stop, negateExact(lstep), ulen); } catch (OverflowException e) { overflowProfile.enter(inliningTarget); - return handleOverflow(lstart, lstep, ulen, PythonContext.get(inliningTarget).factory()); + return handleOverflow(language, lstart, lstep, ulen); } } @TruffleBoundary - private static PBigRangeIterator handleOverflow(int lstart, int lstep, int ulen, PythonObjectSlowPathFactory factory) { + private static PBigRangeIterator handleOverflow(PythonLanguage language, int lstart, int lstep, int ulen) { BigInteger bstart = BigInteger.valueOf(lstart); BigInteger bstep = BigInteger.valueOf(lstep); BigInteger blen = BigInteger.valueOf(ulen); BigInteger new_stop = bstart.subtract(bstep); BigInteger new_start = new_stop.add(blen.multiply(bstep)); - return factory.createBigRangeIterator(new_start, new_stop, bstep.negate(), blen); + return PFactory.createBigRangeIterator(language, new_start, new_stop, bstep.negate(), blen); } @Specialization @TruffleBoundary - PythonObject reversed(@SuppressWarnings("unused") Object cls, PBigRange range) { + static PythonObject reversed(@SuppressWarnings("unused") Object cls, PBigRange range) { BigInteger lstart = range.getBigIntegerStart(); BigInteger lstep = range.getBigIntegerStep(); BigInteger ulen = range.getBigIntegerLength(); @@ -1026,21 +1042,23 @@ PythonObject reversed(@SuppressWarnings("unused") Object cls, PBigRange range) { BigInteger new_stop = lstart.subtract(lstep); BigInteger new_start = new_stop.add(ulen.multiply(lstep)); - return getContext().factory().createBigRangeIterator(new_start, new_stop, lstep.negate(), ulen); + return PFactory.createBigRangeIterator(PythonLanguage.get(null), new_start, new_stop, lstep.negate(), ulen); } @Specialization static PythonObject reversed(Object cls, PString value, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castToStringNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createStringReverseIterator(cls, castToStringNode.execute(inliningTarget, value)); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createStringReverseIterator(language, cls, getInstanceShape.execute(cls), castToStringNode.execute(inliningTarget, value)); } @Specialization static PythonObject reversed(Object cls, TruffleString value, - @Shared @Cached PythonObjectFactory factory) { - return factory.createStringReverseIterator(cls, value); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createStringReverseIterator(language, cls, getInstanceShape.execute(cls), value); } @Specialization(guards = {"!isString(sequence)", "!isPRange(sequence)"}) @@ -1052,7 +1070,8 @@ static Object reversed(VirtualFrame frame, Object cls, Object sequence, @Cached PySequenceSizeNode pySequenceSizeNode, @Cached InlinedConditionProfile noReversedProfile, @Cached PySequenceCheckNode pySequenceCheck, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { Object sequenceKlass = getClassNode.execute(inliningTarget, sequence); Object reversed = lookupReversed.execute(frame, sequenceKlass, sequence); @@ -1061,7 +1080,7 @@ static Object reversed(VirtualFrame frame, Object cls, Object sequence, throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_ISNT_REVERSIBLE, sequence); } else { int lengthHint = pySequenceSizeNode.execute(frame, inliningTarget, sequence); - return factory.createSequenceReverseIterator(cls, sequence, lengthHint); + return PFactory.createSequenceReverseIterator(language, cls, getInstanceShape.execute(cls), sequence, lengthHint); } } else { return callReversed.executeObject(frame, reversed, sequence); @@ -1145,19 +1164,22 @@ abstract static class NonPrimitiveFloatNode extends Node { @Specialization(guards = {"!needsNativeAllocation", "isNoValue(obj)"}) @InliningCutoff - Object floatFromNoneManagedSubclass(Object cls, PNone obj, - @SuppressWarnings("unused") boolean needsNativeAllocation, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFloat(cls, PrimitiveFloatNode.floatFromNoValue(obj)); + static Object floatFromNoneManagedSubclass(Object cls, PNone obj, @SuppressWarnings("unused") boolean needsNativeAllocation, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + Shape shape = getInstanceShape.execute(cls); + return PFactory.createFloat(language, cls, shape, PrimitiveFloatNode.floatFromNoValue(obj)); } @Specialization(guards = "!needsNativeAllocation") @InliningCutoff - Object floatFromObjectManagedSubclass(VirtualFrame frame, Object cls, Object obj, @SuppressWarnings("unused") boolean needsNativeAllocation, + static Object floatFromObjectManagedSubclass(VirtualFrame frame, Object cls, Object obj, @SuppressWarnings("unused") boolean needsNativeAllocation, @Bind("this") @SuppressWarnings("unused") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Shared @Cached PrimitiveFloatNode recursiveCallNode) { - return factory.createFloat(cls, recursiveCallNode.execute(frame, inliningTarget, obj)); + Shape shape = getInstanceShape.execute(cls); + return PFactory.createFloat(language, cls, shape, recursiveCallNode.execute(frame, inliningTarget, obj)); } // logic similar to float_subtype_new(PyTypeObject *type, PyObject *x) from CPython @@ -1195,8 +1217,9 @@ public abstract static class FrozenSetNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(arg)") static PFrozenSet frozensetEmpty(Object cls, @SuppressWarnings("unused") PNone arg, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFrozenSet(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createFrozenSet(language, cls, getInstanceShape.execute(cls), EmptyStorage.INSTANCE); } @Specialization(guards = "isBuiltinClass.profileIsAnyBuiltinClass(inliningTarget, cls)") @@ -1210,17 +1233,19 @@ static PFrozenSet frozensetIdentity(@SuppressWarnings("unused") Object cls, PFro static PFrozenSet subFrozensetIdentity(Object cls, PFrozenSet arg, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared("isBuiltinProfile") @SuppressWarnings("unused") @Cached IsAnyBuiltinClassProfile isBuiltinClass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFrozenSet(cls, arg.getDictStorage()); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createFrozenSet(language, cls, getInstanceShape.execute(cls), arg.getDictStorage()); } @Specialization(guards = {"!isNoValue(iterable)", "!isPFrozenSet(iterable)"}) static PFrozenSet frozensetIterable(VirtualFrame frame, Object cls, Object iterable, @Bind("this") Node inliningTarget, @Cached HashingCollectionNodes.GetClonedHashingStorageNode getHashingStorageNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { HashingStorage storage = getHashingStorageNode.doNoValue(frame, inliningTarget, iterable); - return factory.createFrozenSet(cls, storage); + return PFactory.createFrozenSet(language, cls, getInstanceShape.execute(cls), storage); } } @@ -1263,26 +1288,30 @@ abstract static class CreateIntSubclassNode extends Node { @Specialization static Object doSubclass(Object cls, int value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(cls, value); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createInt(language, cls, getInstanceShape.execute(cls), value); } @Specialization static Object doSubclass(Object cls, long value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(cls, value); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createInt(language, cls, getInstanceShape.execute(cls), value); } @Specialization static Object doSubclass(Object cls, boolean value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(cls, PInt.intValue(value)); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createInt(language, cls, getInstanceShape.execute(cls), PInt.intValue(value)); } @Specialization static Object doSubclass(Object cls, PInt value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(cls, value.getValue()); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createInt(language, cls, getInstanceShape.execute(cls), value.getValue()); } } @@ -1360,10 +1389,21 @@ public static boolean bool(VirtualFrame frame, @SuppressWarnings("unused") Objec The argument must be an iterable if specified.""") @GenerateNodeFactory public abstract static class ListNode extends PythonVarargsBuiltinNode { - @Specialization + @Specialization(guards = "isBuiltinList(cls)") + PList doBuiltin(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords, + @Bind PythonLanguage language) { + return PFactory.createList(language); + } + + @Fallback protected PList constructList(Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords, - @Cached PythonObjectFactory factory) { - return factory.createList(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createList(language, cls, getInstanceShape.execute(cls)); + } + + protected static boolean isBuiltinList(Object cls) { + return cls == PythonBuiltinClassType.PList; } } @@ -1441,22 +1481,24 @@ public final Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused" @Specialization(guards = {"!self.needsNativeAllocation()"}) Object doManagedObject(VirtualFrame frame, PythonManagedClass self, Object[] varargs, PKeyword[] kwargs, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached CheckExcessArgsNode checkExcessArgsNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { checkExcessArgsNode.execute(inliningTarget, self, varargs, kwargs); if (self.isAbstractClass()) { throw reportAbstractClass(frame, self); } - return factory.createPythonObject(self); + return PFactory.createPythonObject(language, self, getInstanceShape.execute(self)); } @Specialization static Object doBuiltinTypeType(PythonBuiltinClassType self, Object[] varargs, PKeyword[] kwargs, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached CheckExcessArgsNode checkExcessArgsNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { checkExcessArgsNode.execute(inliningTarget, self, varargs, kwargs); - return factory.createPythonObject(self); + return PFactory.createPythonObject(language, self, getInstanceShape.execute(self)); } @Specialization(guards = "self.needsNativeAllocation()") @@ -1536,87 +1578,87 @@ public abstract static class RangeNode extends PythonQuaternaryBuiltinNode { @Specialization(guards = "isStop(start, stop, step)") static Object doIntStop(Object cls, int stop, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doInt(cls, 0, stop, 1, inliningTarget, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, factory, raiseNode); + return doInt(cls, 0, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, raiseNode); } @Specialization(guards = "isStop(start, stop, step)") static Object doPintStop(Object cls, PInt stop, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doPint(cls, factory.createInt(0), stop, factory.createInt(1), inliningTarget, lenOfRangeNode, factory, raiseNode); + return doPint(cls, PFactory.createInt(language, BigInteger.ZERO), stop, PFactory.createInt(language, BigInteger.ONE), inliningTarget, language, lenOfRangeNode, raiseNode); } @Specialization(guards = "isStop(start, stop, step)") static Object doGenericStop(VirtualFrame frame, Object cls, Object stop, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doGeneric(frame, cls, 0, stop, 1, inliningTarget, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, factory, raiseNode); + return doGeneric(frame, cls, 0, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, raiseNode); } // start stop @Specialization(guards = "isStartStop(start, stop, step)") static Object doIntStartStop(Object cls, int start, int stop, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doInt(cls, start, stop, 1, inliningTarget, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, factory, raiseNode); + return doInt(cls, start, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, raiseNode); } @Specialization(guards = "isStartStop(start, stop, step)") static Object doPintStartStop(Object cls, PInt start, PInt stop, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doPint(cls, start, stop, factory.createInt(1), inliningTarget, lenOfRangeNode, factory, raiseNode); + return doPint(cls, start, stop, PFactory.createInt(language, BigInteger.ONE), inliningTarget, language, lenOfRangeNode, raiseNode); } @Specialization(guards = "isStartStop(start, stop, step)") static Object doGenericStartStop(VirtualFrame frame, Object cls, Object start, Object stop, @SuppressWarnings("unused") PNone step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doGeneric(frame, cls, start, stop, 1, inliningTarget, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, factory, raiseNode); + return doGeneric(frame, cls, start, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, raiseNode); } // start stop step @Specialization static Object doInt(@SuppressWarnings("unused") Object cls, int start, int stop, int step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNode, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (step == 0) { throw raiseNode.get(inliningTarget).raise(ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); } try { int len = lenOfRangeNode.executeInt(inliningTarget, start, stop, step); - return factory.createIntRange(start, stop, step, len); + return PFactory.createIntRange(language, start, stop, step, len); } catch (OverflowException e) { exceptionProfile.enter(inliningTarget); return createBigRangeNode.execute(inliningTarget, start, stop, step); @@ -1626,26 +1668,26 @@ static Object doInt(@SuppressWarnings("unused") Object cls, int start, int stop, @Specialization static Object doPint(@SuppressWarnings("unused") Object cls, PInt start, PInt stop, PInt step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (step.isZero()) { throw raiseNode.get(inliningTarget).raise(ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); } BigInteger len = lenOfRangeNode.execute(inliningTarget, start.getValue(), stop.getValue(), step.getValue()); - return factory.createBigRange(start, stop, step, factory.createInt(len)); + return PFactory.createBigRange(language, start, stop, step, PFactory.createInt(language, len)); } @Specialization(guards = "isStartStopStep(start, stop, step)") static Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object start, Object stop, Object step, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { Object lstart = indexNode.execute(frame, inliningTarget, start); Object lstop = indexNode.execute(frame, inliningTarget, stop); @@ -1655,7 +1697,7 @@ static Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object c int istart = cast.execute(inliningTarget, lstart); int istop = cast.execute(inliningTarget, lstop); int istep = cast.execute(inliningTarget, lstep); - return doInt(cls, istart, istop, istep, inliningTarget, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, factory, raiseNode); + return doInt(cls, istart, istop, istep, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, raiseNode); } catch (PException e) { e.expect(inliningTarget, OverflowError, overflowProfile); return createBigRangeNode.execute(inliningTarget, lstart, lstop, lstep); @@ -1683,11 +1725,21 @@ protected static boolean isStartStopStep(Object start, Object stop, Object step) Build an unordered collection of unique elements.""") @GenerateNodeFactory public abstract static class SetNode extends PythonBuiltinNode { + @Specialization(guards = "isBuiltinSet(cls)") + public PSet setEmpty(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object arg, + @Bind PythonLanguage language) { + return PFactory.createSet(language); + } - @Specialization + @Fallback public PSet setEmpty(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { - return factory.createSet(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createSet(language, cls, getInstanceShape.execute(cls)); + } + + protected static boolean isBuiltinSet(Object cls) { + return cls == PythonBuiltinClassType.PSet; } } @@ -1724,8 +1776,8 @@ static Object strNoArgs(Object cls, PNone arg, Object encoding, Object errors, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached TypeNodes.NeedsNativeAllocationNode needsNativeAllocationNode, @Exclusive @Cached IsBuiltinClassExactProfile isPrimitiveProfile, - @Shared @Cached PythonObjectFactory factory) { - return asPString(cls, T_EMPTY_STRING, inliningTarget, isPrimitiveProfile, factory); + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return asPString(cls, T_EMPTY_STRING, inliningTarget, isPrimitiveProfile, getInstanceShape); } @Specialization(guards = {"!needsNativeAllocationNode.execute(inliningTarget, cls)", "!isNoValue(obj)", "isNoValue(encoding)", "isNoValue(errors)"}, limit = "1") @@ -1736,13 +1788,13 @@ static Object strOneArg(VirtualFrame frame, Object cls, Object obj, @SuppressWar @Exclusive @Cached InlinedConditionProfile isStringProfile, @Cached CastToTruffleStringNode castToTruffleStringNode, @Exclusive @Cached PyObjectStrAsObjectNode strNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { Object result = strNode.execute(frame, inliningTarget, obj); // try to return a primitive if possible assertNoJavaString(result); if (isStringProfile.profile(inliningTarget, result instanceof TruffleString)) { - return asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, factory); + return asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, getInstanceShape); } if (isPrimitiveProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.PString)) { @@ -1751,7 +1803,7 @@ static Object strOneArg(VirtualFrame frame, Object cls, Object obj, @SuppressWar return result; } else { try { - return asPString(cls, castToTruffleStringNode.execute(inliningTarget, result), inliningTarget, isPrimitiveProfile, factory); + return asPString(cls, castToTruffleStringNode.execute(inliningTarget, result), inliningTarget, isPrimitiveProfile, getInstanceShape); } catch (CannotCastException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new IllegalStateException("asPstring result not castable to String"); @@ -1770,7 +1822,7 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi @Exclusive @CachedLibrary("obj") PythonBufferAcquireLibrary acquireLib, @Exclusive @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode, - @Shared @Cached PythonObjectFactory factory, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object buffer; try { @@ -1781,11 +1833,11 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi try { // TODO(fa): we should directly call '_codecs.decode' // TODO don't copy, CPython creates a memoryview - PBytes bytesObj = factory.createBytes(bufferLib.getCopiedByteArray(buffer)); + PBytes bytesObj = PFactory.createBytes(PythonLanguage.get(inliningTarget), bufferLib.getCopiedByteArray(buffer)); Object en = encoding == PNone.NO_VALUE ? T_UTF8 : encoding; Object result = assertNoJavaString(callDecodeNode.execute(frame, bytesObj, en, errors)); if (isStringProfile.profile(inliningTarget, result instanceof TruffleString)) { - return asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, factory); + return asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, getInstanceShape); } else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) { return result; } @@ -1830,7 +1882,7 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o @Exclusive @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode, @Shared @Cached(neverDefault = true) CExtNodes.StringSubtypeNew subtypeNew, - @Shared @Cached PythonObjectFactory factory, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object buffer; try { @@ -1839,11 +1891,11 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NEED_BYTELIKE_OBJ, obj); } try { - PBytes bytesObj = factory.createBytes(bufferLib.getCopiedByteArray(buffer)); + PBytes bytesObj = PFactory.createBytes(PythonLanguage.get(inliningTarget), bufferLib.getCopiedByteArray(buffer)); Object en = encoding == PNone.NO_VALUE ? T_UTF8 : encoding; Object result = assertNoJavaString(callDecodeNode.execute(frame, bytesObj, en, errors)); if (isStringProfile.profile(inliningTarget, result instanceof TruffleString)) { - return subtypeNew.call(cls, asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, factory)); + return subtypeNew.call(cls, asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, getInstanceShape)); } else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) { return subtypeNew.call(cls, result); } @@ -1858,11 +1910,11 @@ protected static boolean isSubtypeOfString(VirtualFrame frame, IsSubtypeNode isS } private static Object asPString(Object cls, TruffleString str, Node inliningTarget, IsBuiltinClassExactProfile isPrimitiveProfile, - PythonObjectFactory factory) { + TypeNodes.GetInstanceShape getInstanceShape) { if (isPrimitiveProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.PString)) { return str; } else { - return factory.createString(cls, str); + return PFactory.createString(PythonLanguage.get(inliningTarget), cls, getInstanceShape.execute(cls), str); } } @@ -1883,12 +1935,26 @@ public static StrNode create() { @GenerateNodeFactory public abstract static class TupleNode extends PythonBinaryBuiltinNode { - @Specialization(guards = "!needsNativeAllocationNode.execute(inliningTarget, cls)") + @Specialization(guards = "isBuiltinTupleType(cls)") + static Object doBuiltin(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object iterable, + @Shared @Cached TupleNodes.ConstructTupleNode constructTupleNode) { + return constructTupleNode.execute(frame, iterable); + } + + @Specialization(guards = "!needsNativeAllocationNode.execute(inliningTarget, cls)", replaces = "doBuiltin") static PTuple constructTuple(VirtualFrame frame, Object cls, Object iterable, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached TypeNodes.NeedsNativeAllocationNode needsNativeAllocationNode, - @Cached TupleNodes.ConstructTupleNode constructTupleNode) { - return constructTupleNode.execute(frame, cls, iterable); + @Shared @Cached TupleNodes.ConstructTupleNode constructTupleNode, + @Cached TypeNodes.IsSameTypeNode isSameTypeNode, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PTuple tuple = constructTupleNode.execute(frame, iterable); + if (isSameTypeNode.execute(inliningTarget, cls, PythonBuiltinClassType.PTuple)) { + return tuple; + } else { + return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), tuple.getSequenceStorage()); + } } // delegate to tuple_subtype_new(PyTypeObject *type, PyObject *x) @@ -1902,6 +1968,10 @@ static Object doNative(@SuppressWarnings("unused") VirtualFrame frame, Object cl return subtypeNew.call(cls, iterable); } + protected static boolean isBuiltinTupleType(Object cls) { + return cls == PythonBuiltinClassType.PTuple; + } + protected static boolean isSubtypeOfTuple(VirtualFrame frame, IsSubtypeNode isSubtypeNode, Object cls) { return isSubtypeNode.execute(frame, cls, PythonBuiltinClassType.PTuple); } @@ -1937,8 +2007,8 @@ static boolean isNoneOrEmptyPKeyword(Object value) { static PZip zip(VirtualFrame frame, Object cls, Object[] args, @SuppressWarnings("unused") Object kw, @Bind("this") Node inliningTarget, @Exclusive @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { - return zip(frame, inliningTarget, cls, args, false, getIter, factory); + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return zip(frame, inliningTarget, cls, args, false, getIter, getInstanceShape); } @Specialization(guards = "kw.length == 1") @@ -1948,10 +2018,10 @@ static PZip zip(VirtualFrame frame, Object cls, Object[] args, PKeyword[] kw, @Exclusive @Cached PyObjectGetIter getIter, @Cached PyObjectIsTrueNode isTrueNode, @Cached InlinedConditionProfile profile, - @Shared @Cached PythonObjectFactory factory, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (profile.profile(inliningTarget, eqNode.execute(kw[0].getName(), T_STRICT, TS_ENCODING))) { - return zip(frame, inliningTarget, cls, args, isTrueNode.execute(frame, kw[0].getValue()), getIter, factory); + return zip(frame, inliningTarget, cls, args, isTrueNode.execute(frame, kw[0].getValue()), getIter, getInstanceShape); } throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_IS_AN_INVALID_ARG_FOR_S, kw[0].getName(), T_ZIP); } @@ -1962,14 +2032,14 @@ static Object zip(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unu throw raiseNode.raise(TypeError, ErrorMessages.S_TAKES_AT_MOST_ONE_KEYWORD_ARGUMENT_D_GIVEN, T_ZIP, kw.length); } - private static PZip zip(VirtualFrame frame, Node inliningTarget, Object cls, Object[] args, boolean strict, PyObjectGetIter getIter, PythonObjectFactory factory) { + private static PZip zip(VirtualFrame frame, Node inliningTarget, Object cls, Object[] args, boolean strict, PyObjectGetIter getIter, TypeNodes.GetInstanceShape getInstanceShape) { Object[] iterables = new Object[args.length]; LoopNode.reportLoopCount(inliningTarget, args.length); for (int i = 0; i < args.length; i++) { Object item = args[i]; iterables[i] = getIter.execute(frame, inliningTarget, item); } - return factory.createZip(cls, iterables, strict); + return PFactory.createZip(PythonLanguage.get(inliningTarget), cls, getInstanceShape.execute(cls), iterables, strict); } } @@ -1982,8 +2052,8 @@ public abstract static class FunctionNode extends PythonBuiltinNode { @Specialization static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, @SuppressWarnings("unused") PNone defaultArgs, @SuppressWarnings("unused") PNone closure, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFunction(name, code, globals, null); + @Bind PythonLanguage language) { + return PFactory.createFunction(language, name, code, globals, null); } @Specialization @@ -1991,24 +2061,24 @@ static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD PTuple closure, @Bind("this") Node inliningTarget, @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFunction(T_LAMBDA_NAME, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); + @Bind PythonLanguage language) { + return PFactory.createFunction(language, T_LAMBDA_NAME, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); } @Specialization static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs, @SuppressWarnings("unused") PNone closure, @SuppressWarnings("unused") @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFunction(T_LAMBDA_NAME, code, globals, null); + @Bind PythonLanguage language) { + return PFactory.createFunction(language, T_LAMBDA_NAME, code, globals, null); } @Specialization static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, @SuppressWarnings("unused") PNone defaultArgs, PTuple closure, @Bind("this") Node inliningTarget, @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFunction(name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); + @Bind PythonLanguage language) { + return PFactory.createFunction(language, name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); } @Specialization @@ -2016,27 +2086,28 @@ static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD @SuppressWarnings("unused") PNone closure, @Bind("this") Node inliningTarget, @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // TODO split defaults of positional args from kwDefaults - return factory.createFunction(code.getName(), code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null); + return PFactory.createFunction(language, code.getName(), code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null); } @Specialization static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, PTuple defaultArgs, @SuppressWarnings("unused") PNone closure, @Bind("this") Node inliningTarget, @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // TODO split defaults of positional args from kwDefaults - return factory.createFunction(name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null); + return PFactory.createFunction(language, name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null); } @Specialization static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, PTuple defaultArgs, PTuple closure, @Bind("this") Node inliningTarget, @Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // TODO split defaults of positional args from kwDefaults - return factory.createFunction(name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); + return PFactory.createFunction(language, name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, + PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure))); } @Fallback @@ -2198,34 +2269,14 @@ private IsAcceptableBaseNode ensureIsAcceptableBaseNode() { The name must be a string; the optional doc argument can have any type.""") @GenerateNodeFactory public abstract static class ModuleNode extends PythonBuiltinNode { - @Specialization - @SuppressWarnings("unused") - static Object doType(PythonBuiltinClass self, Object[] varargs, PKeyword[] kwargs, - @Shared @Cached PythonObjectFactory factory) { - return factory.createPythonModule(self.getType()); - } - - @Specialization(guards = "!isPythonBuiltinClass(self)") - @SuppressWarnings("unused") - static Object doManaged(PythonManagedClass self, Object[] varargs, PKeyword[] kwargs, - @Shared @Cached PythonObjectFactory factory) { - return factory.createPythonModule(self); - } @Specialization @SuppressWarnings("unused") - static Object doType(PythonBuiltinClassType self, Object[] varargs, PKeyword[] kwargs, - @Shared @Cached PythonObjectFactory factory) { - return factory.createPythonModule(self); - } - - @Specialization(guards = "isTypeNode.execute(inliningTarget, self)", limit = "1") - @SuppressWarnings("unused") - static Object doNative(PythonAbstractNativeObject self, Object[] varargs, PKeyword[] kwargs, + static Object doGeneric(Object cls, Object[] varargs, PKeyword[] kwargs, @Bind("this") Node inliningTarget, - @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createPythonModule(self); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createPythonModule(language, cls, getInstanceShape.execute(cls)); } } @@ -2373,25 +2424,25 @@ static Object generator(Object args, Object kwargs, @GenerateNodeFactory public abstract static class MethodTypeNode extends PythonTernaryBuiltinNode { @Specialization - static Object method(Object cls, PFunction func, Object self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createMethod(cls, self, func); + static Object method(@SuppressWarnings("unused") Object cls, PFunction func, Object self, + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); } @Specialization static Object methodBuiltin(@SuppressWarnings("unused") Object cls, PBuiltinFunction func, Object self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createMethod(self, func); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); } @Specialization static Object methodGeneric(@SuppressWarnings("unused") Object cls, Object func, Object self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyCallableCheckNode callableCheck, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (callableCheck.execute(inliningTarget, func)) { - return factory.createMethod(self, func); + return PFactory.createMethod(language, self, func); } else { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.FIRST_ARG_MUST_BE_CALLABLE_S, ""); } @@ -2402,9 +2453,9 @@ static Object methodGeneric(@SuppressWarnings("unused") Object cls, Object func, @GenerateNodeFactory public abstract static class BuiltinMethodTypeNode extends PythonBuiltinNode { @Specialization - Object method(Object cls, Object self, PBuiltinFunction func, - @Cached PythonObjectFactory factory) { - return factory.createBuiltinMethod(cls, self, func); + Object method(@SuppressWarnings("unused") Object cls, Object self, PBuiltinFunction func, + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, self, func); } } @@ -2426,14 +2477,14 @@ static Object call( public abstract static class TracebackTypeNode extends PythonClinicBuiltinNode { @Specialization static Object createTraceback(@SuppressWarnings("unused") Object cls, PTraceback next, PFrame pframe, int lasti, int lineno, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTracebackWithLasti(pframe, lineno, lasti, next); + @Bind PythonLanguage language) { + return PFactory.createTracebackWithLasti(language, pframe, lineno, lasti, next); } @Specialization static Object createTraceback(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") PNone next, PFrame pframe, int lasti, int lineno, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTracebackWithLasti(pframe, lineno, lasti, null); + @Bind PythonLanguage language) { + return PFactory.createTracebackWithLasti(language, pframe, lineno, lasti, null); } @Specialization(guards = {"!isPTraceback(next)", "!isNone(next)"}) @@ -2544,10 +2595,10 @@ private Assumption getAssumption() { @Specialization Object newCell(@SuppressWarnings("unused") Object cls, Object contents, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached InlinedConditionProfile nonEmptyProfile) { Assumption assumption = getAssumption(); - PCell cell = factory.createCell(assumption); + PCell cell = PFactory.createCell(language, assumption); if (nonEmptyProfile.profile(inliningTarget, !isNoValue(contents))) { cell.setRef(contents, assumption); } @@ -2575,27 +2626,28 @@ public final Object varArgExecute(VirtualFrame frame, Object self, Object[] argu static Object doManaged(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached TypeNodes.NeedsNativeAllocationNode needsNativeAllocationNode, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached InlinedConditionProfile argsProfile) { PTuple argsTuple; if (argsProfile.profile(inliningTarget, args.length == 0)) { argsTuple = null; } else { - argsTuple = factory.createTuple(args); + argsTuple = PFactory.createTuple(language, args); } - return factory.createBaseException(cls, null, argsTuple); + return PFactory.createBaseException(language, cls, getInstanceShape.execute(cls), null, argsTuple); } @Specialization(guards = "needsNativeAllocationNode.execute(inliningTarget, cls)", limit = "1") static Object doNativeSubtype(Object cls, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached TypeNodes.NeedsNativeAllocationNode needsNativeAllocationNode, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PCallCapiFunction callCapiFunction, @Cached PythonToNativeNode toNativeNode, @Cached NativeToPythonTransferNode toPythonNode, @Cached ExternalFunctionNodes.DefaultCheckFunctionResultNode checkFunctionResultNode) { - Object argsTuple = args.length > 0 ? factory.createTuple(args) : factory.createEmptyTuple(); + Object argsTuple = args.length > 0 ? PFactory.createTuple(language, args) : PFactory.createEmptyTuple(language); Object nativeResult = callCapiFunction.call(NativeCAPISymbol.FUN_EXCEPTION_SUBTYPE_NEW, toNativeNode.execute(cls), toNativeNode.execute(argsTuple)); return toPythonNode.execute(checkFunctionResultNode.execute(PythonContext.get(inliningTarget), NativeCAPISymbol.FUN_EXCEPTION_SUBTYPE_NEW.getTsName(), nativeResult)); } @@ -2608,8 +2660,9 @@ public abstract static class BaseExceptionGroupNode extends PythonTernaryBuiltin @Specialization static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Object exceptionsObj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached CastToTruffleStringNode castToStringNode, - @Cached PythonObjectFactory factory, @Cached PySequenceCheckNode sequenceCheckNode, @Cached TupleNodes.ConstructTupleNode toTupleNode, @Cached SequenceStorageNodes.ToArrayNode toArrayNode, @@ -2667,7 +2720,7 @@ static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Objec throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_NEST_BASE_EXCEPTIONS_IN_N, cls); } } - return factory.createBaseExceptionGroup(cls, message, exceptions, new Object[]{messageObj, exceptionsObj}); + return PFactory.createBaseExceptionGroup(language, cls, getInstanceShape.execute(cls), message, exceptions, new Object[]{messageObj, exceptionsObj}); } } @@ -2675,14 +2728,14 @@ static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Objec @GenerateNodeFactory public abstract static class MappingproxyNode extends PythonBinaryBuiltinNode { @Specialization(guards = "!isNoValue(obj)") - static Object doMapping(Object klass, Object obj, + static Object doMapping(@SuppressWarnings("unused") Object cls, Object obj, @Bind("this") Node inliningTarget, @Cached PyMappingCheckNode mappingCheckNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { // descrobject.c mappingproxy_check_mapping() if (!(obj instanceof PList || obj instanceof PTuple) && mappingCheckNode.execute(inliningTarget, obj)) { - return factory.createMappingproxy(klass, obj); + return PFactory.createMappingproxy(language, obj); } throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ARG_MUST_BE_S_NOT_P, "mappingproxy()", "mapping", obj); } @@ -2716,7 +2769,7 @@ public abstract static class GetSetDescriptorNode extends DescriptorNode { @TruffleBoundary Object call(@SuppressWarnings("unused") Object clazz, Object get, Object set, TruffleString name, Object owner) { denyInstantiationAfterInitialization(T_GETSET_DESCRIPTOR); - return PythonObjectFactory.getUncached().createGetSetDescriptor(ensure(get), ensure(set), name, owner); + return PFactory.createGetSetDescriptor(PythonLanguage.get(null), ensure(get), ensure(set), name, owner); } } @@ -2728,7 +2781,7 @@ public abstract static class MemberDescriptorNode extends DescriptorNode { @TruffleBoundary Object doGeneric(@SuppressWarnings("unused") Object clazz, Object get, Object set, TruffleString name, Object owner) { denyInstantiationAfterInitialization(T_MEMBER_DESCRIPTOR); - return PythonObjectFactory.getUncached().createGetSetDescriptor(ensure(get), ensure(set), name, owner); + return PFactory.createGetSetDescriptor(PythonLanguage.get(null), ensure(get), ensure(set), name, owner); } } @@ -2740,7 +2793,7 @@ public abstract static class WrapperDescriptorNode extends DescriptorNode { @TruffleBoundary Object doGeneric(@SuppressWarnings("unused") Object clazz, Object get, Object set, TruffleString name, Object owner) { denyInstantiationAfterInitialization(T_WRAPPER_DESCRIPTOR); - return PythonObjectFactory.getUncached().createGetSetDescriptor(ensure(get), ensure(set), name, owner); + return PFactory.createGetSetDescriptor(PythonLanguage.get(null), ensure(get), ensure(set), name, owner); } } @@ -2818,10 +2871,21 @@ def cmeth(cls, arg): super().cmeth(arg)""") @GenerateNodeFactory public abstract static class SuperInitNode extends PythonTernaryBuiltinNode { - @Specialization - static Object doObjectIndirect(Object self, @SuppressWarnings("unused") Object type, @SuppressWarnings("unused") Object object, - @Cached PythonObjectFactory factory) { - return factory.createSuperObject(self); + @Specialization(guards = "isBuiltinSuper(cls)") + static Object doBuiltin(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object type, @SuppressWarnings("unused") Object object, + @Bind PythonLanguage language) { + return PFactory.createSuperObject(language); + } + + @Fallback + static Object doOther(Object cls, @SuppressWarnings("unused") Object type, @SuppressWarnings("unused") Object object, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createSuperObject(language, cls, getInstanceShape.execute(cls)); + } + + protected static boolean isBuiltinSuper(Object cls) { + return cls == PythonBuiltinClassType.Super; } } @@ -2849,9 +2913,10 @@ It can be called either on the class (e.g. C.f()) or on an instance @GenerateNodeFactory public abstract static class ClassmethodNode extends PythonBinaryBuiltinNode { @Specialization - static Object doObjectIndirect(Object self, @SuppressWarnings("unused") Object callable, - @Cached PythonObjectFactory factory) { - return factory.createClassmethod(self); + static Object doObjectIndirect(Object cls, @SuppressWarnings("unused") Object callable, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createClassmethod(language, cls, getInstanceShape.execute(cls)); } } @@ -2859,9 +2924,10 @@ static Object doObjectIndirect(Object self, @SuppressWarnings("unused") Object c @GenerateNodeFactory public abstract static class InstancemethodNode extends PythonBinaryBuiltinNode { @Specialization - static Object doObjectIndirect(Object self, @SuppressWarnings("unused") Object callable, - @Cached PythonObjectFactory factory) { - return factory.createInstancemethod(self); + static Object doObjectIndirect(Object cls, @SuppressWarnings("unused") Object callable, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createInstancemethod(language, cls, getInstanceShape.execute(cls)); } } @@ -2887,9 +2953,10 @@ It can be called either on the class (e.g. C.f()) or on an instance @GenerateNodeFactory public abstract static class StaticmethodNode extends PythonBinaryBuiltinNode { @Specialization - static Object doObjectIndirect(Object self, @SuppressWarnings("unused") Object callable, - @Cached PythonObjectFactory factory) { - return factory.createStaticmethod(self); + static Object doObjectIndirect(Object cls, @SuppressWarnings("unused") Object callable, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createStaticmethod(language, cls, getInstanceShape.execute(cls)); } } @@ -2906,7 +2973,8 @@ static PMap doit(VirtualFrame frame, Object cls, Object[] args, PKeyword[] keywo @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached InlinedLoopConditionProfile loopProfile, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "map()"); @@ -2914,7 +2982,7 @@ static PMap doit(VirtualFrame frame, Object cls, Object[] args, PKeyword[] keywo if (args.length < 2) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MAP_MUST_HAVE_AT_LEAST_TWO_ARGUMENTS); } - PMap map = factory.createMap(cls); + PMap map = PFactory.createMap(language, cls, getInstanceShape.execute(cls)); map.setFunction(args[0]); Object[] iterators = new Object[args.length - 1]; loopProfile.profileCounted(inliningTarget, iterators.length); @@ -2962,9 +3030,10 @@ def x(self): @GenerateNodeFactory public abstract static class PropertyNode extends PythonVarargsBuiltinNode { @Specialization - static PProperty doit(Object self, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] keywords, - @Cached PythonObjectFactory factory) { - return factory.createProperty(self); + static PProperty doit(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] keywords, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createProperty(language, cls, getInstanceShape.execute(cls)); } } @@ -2974,9 +3043,10 @@ static PProperty doit(Object self, @SuppressWarnings("unused") Object[] args, @S @GenerateNodeFactory public abstract static class SimpleNamespaceNode extends PythonVarargsBuiltinNode { @Specialization - static PSimpleNamespace doit(Object self, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] keywords, - @Cached PythonObjectFactory factory) { - return factory.createSimpleNamespace(self); + static PSimpleNamespace doit(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] keywords, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createSimpleNamespace(language, cls, getInstanceShape.execute(cls)); } } @@ -2985,8 +3055,9 @@ static PSimpleNamespace doit(Object self, @SuppressWarnings("unused") Object[] a abstract static class GenericAliasNode extends PythonTernaryBuiltinNode { @Specialization static PGenericAlias doit(Object cls, Object origin, Object arguments, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, origin, arguments, false); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createGenericAlias(language, cls, getInstanceShape.execute(cls), origin, arguments, false); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 83bb3b2291..35ea14c64c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -247,7 +247,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -1036,18 +1036,17 @@ protected abstract Object executeInternal(VirtualFrame frame, Object source, Tru Object doCompile(VirtualFrame frame, TruffleString expression, TruffleString filename, TruffleString mode, int flags, boolean dontInherit, int optimize, int featureVersion, @Shared @Cached ReadCallerFrameNode readCallerFrame, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (!dontInherit) { PFrame fr = readCallerFrame.executeWith(frame, 0); - PCode code = factory.createCode(fr.getTarget()); + PCode code = PFactory.createCode(language, fr.getTarget()); flags |= code.getFlags() & PyCF_MASK; } - return compile(expression, filename, mode, flags, dontInherit, optimize, featureVersion, factory); + return compile(expression, filename, mode, flags, dontInherit, optimize, featureVersion); } @TruffleBoundary - Object compile(TruffleString expression, TruffleString filename, TruffleString mode, int flags, @SuppressWarnings("unused") boolean dontInherit, int optimize, int featureVersion, - PythonObjectFactory factory) { + Object compile(TruffleString expression, TruffleString filename, TruffleString mode, int flags, @SuppressWarnings("unused") boolean dontInherit, int optimize, int featureVersion) { checkFlags(flags); checkOptimize(optimize, optimize); checkSource(expression); @@ -1104,7 +1103,7 @@ Object compile(TruffleString expression, TruffleString filename, TruffleString m } else { ct = getContext().getLanguage().cacheCode(filename, createCode); } - return wrapRootCallTarget((RootCallTarget) ct, factory); + return wrapRootCallTarget((RootCallTarget) ct); } @Specialization(limit = "3") @@ -1123,7 +1122,6 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri @Cached TruffleString.FromByteArrayNode fromByteArrayNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Shared @Cached ReadCallerFrameNode readCallerFrame, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (wSource instanceof PCode) { return wSource; @@ -1147,7 +1145,7 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri if (!dontInherit) { PFrame fr = readCallerFrame.executeWith(frame, 0); - PCode code = factory.createCode(fr.getTarget()); + PCode code = PFactory.createCode(PythonLanguage.get(inliningTarget), fr.getTarget()); flags |= code.getFlags() & PyCF_MASK; } @@ -1155,20 +1153,20 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri ModTy mod = AstModuleBuiltins.obj2sst(context, wSource, getParserInputType(mode, flags)); Source source = PythonUtils.createFakeSource(filename); RootCallTarget rootCallTarget = context.getLanguage(inliningTarget).compileForBytecodeInterpreter(context, mod, source, false, optimize, null, null, flags); - return wrapRootCallTarget(rootCallTarget, factory); + return wrapRootCallTarget(rootCallTarget); } - TruffleString source = sourceAsString(frame, inliningTarget, wSource, filename, interopLib, acquireLib, bufferLib, handleDecodingErrorNode, asStrNode, switchEncodingNode, factory, + TruffleString source = sourceAsString(frame, inliningTarget, wSource, filename, interopLib, acquireLib, bufferLib, handleDecodingErrorNode, asStrNode, switchEncodingNode, raiseNode, indirectCallData); checkSource(source); - return compile(source, filename, mode, flags, dontInherit, optimize, featureVersion, factory); + return compile(source, filename, mode, flags, dontInherit, optimize, featureVersion); } - private static PCode wrapRootCallTarget(RootCallTarget rootCallTarget, PythonObjectFactory factory) { + private static PCode wrapRootCallTarget(RootCallTarget rootCallTarget) { RootNode rootNode = rootCallTarget.getRootNode(); if (rootNode instanceof PBytecodeRootNode) { ((PBytecodeRootNode) rootNode).triggerDeferredDeprecationWarnings(); } - return factory.createCode(rootCallTarget); + return PFactory.createCode(PythonLanguage.get(null), rootCallTarget); } @TruffleBoundary @@ -1214,7 +1212,7 @@ private InputType getParserInputType(TruffleString mode, int flags) { // modeled after _Py_SourceAsString TruffleString sourceAsString(VirtualFrame frame, Node inliningTarget, Object source, TruffleString filename, InteropLibrary interopLib, PythonBufferAcquireLibrary acquireLib, PythonBufferAccessLibrary bufferLib, CodecsModuleBuiltins.HandleDecodingErrorNode handleDecodingErrorNode, PyObjectStrAsTruffleStringNode asStrNode, - TruffleString.SwitchEncodingNode switchEncodingNode, PythonObjectFactory factory, PRaiseNode.Lazy raiseNode, IndirectCallData indirectCallData) { + TruffleString.SwitchEncodingNode switchEncodingNode, PRaiseNode.Lazy raiseNode, IndirectCallData indirectCallData) { if (interopLib.isString(source)) { try { return switchEncodingNode.execute(interopLib.asTruffleString(source), TS_ENCODING); @@ -1238,7 +1236,7 @@ TruffleString sourceAsString(VirtualFrame frame, Node inliningTarget, Object sou CodecsModuleBuiltins.TruffleDecoder decoder = new CodecsModuleBuiltins.TruffleDecoder(pythonEncodingNameFromJavaName, charset, bytes, bytesLen, CodingErrorAction.REPORT); if (!decoder.decodingStep(true)) { try { - handleDecodingErrorNode.execute(frame, decoder, T_STRICT, factory.createBytes(bytes, bytesLen)); + handleDecodingErrorNode.execute(frame, decoder, T_STRICT, PFactory.createBytes(PythonLanguage.get(inliningTarget), bytes, bytesLen)); throw CompilerDirectives.shouldNotReachHere(); } catch (PException e) { throw raiseInvalidSyntax(filename, "(unicode error) %s", asStrNode.execute(frame, inliningTarget, e.getEscapedException())); @@ -1542,8 +1540,8 @@ static Object iter(VirtualFrame frame, Object object, @SuppressWarnings("unused" static Object iter(Object callable, Object sentinel, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Cached PyCallableCheckNode callableCheck, - @Cached PythonObjectFactory factory) { - return factory.createSentinelIterator(callable, sentinel); + @Bind PythonLanguage language) { + return PFactory.createSentinelIterator(language, callable, sentinel); } @Fallback @@ -2327,7 +2325,7 @@ abstract static class UpdateBasesNode extends Node { @Specialization static PTuple update(PTuple bases, Object[] arguments, int nargs, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PyObjectLookupAttr getMroEntries, @Cached CallUnaryMethodNode callMroEntries, @Cached PRaiseNode.Lazy raiseNode) { @@ -2372,7 +2370,7 @@ static PTuple update(PTuple bases, Object[] arguments, int nargs, if (newBases == null) { return bases; } - return factory.createTuple(newBases.toArray()); + return PFactory.createTuple(language, newBases.toArray()); } } @@ -2430,9 +2428,9 @@ private static Object buildJavaClass(Object namespace, TruffleString name, Objec } @InliningCutoff - private static Object buildJavaClass(VirtualFrame frame, PythonLanguage language, PFunction function, Object[] arguments, PythonObjectFactory factory, CallDispatchNode callBody, + private static Object buildJavaClass(VirtualFrame frame, PythonLanguage language, PFunction function, Object[] arguments, CallDispatchNode callBody, TruffleString name) { - PDict ns = factory.createDict(new DynamicObjectStorage(language)); + PDict ns = PFactory.createDict(language, new DynamicObjectStorage(language)); Object[] args = PArguments.create(0); PArguments.setSpecialArgument(args, ns); callBody.executeCall(frame, function, args); @@ -2444,7 +2442,6 @@ protected Object doItNonFunction(VirtualFrame frame, Object function, Object[] a @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castToTruffleStringNode, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PythonObjectFactory factory, @Cached CalculateMetaclassNode calculateMetaClass, @Cached("create(T___PREPARE__)") GetAttributeNode getPrepare, @Cached PyMappingCheckNode pyMappingCheckNode, @@ -2470,15 +2467,16 @@ protected Object doItNonFunction(VirtualFrame frame, Object function, Object[] a throw raise(PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_NAME_NOT_STRING); } - Object[] basesArray = Arrays.copyOfRange(arguments, 1, arguments.length); - PTuple origBases = factory.createTuple(basesArray); - - PythonContext ctx = PythonContext.get(calculateMetaClass); + PythonContext ctx = PythonContext.get(inliningTarget); Env env = ctx.getEnv(); PythonLanguage language = ctx.getLanguage(inliningTarget); + + Object[] basesArray = Arrays.copyOfRange(arguments, 1, arguments.length); + PTuple origBases = PFactory.createTuple(language, basesArray); + if (arguments.length == 2 && env.isHostObject(arguments[1]) && env.asHostObject(arguments[1]) instanceof Class) { // we want to subclass a Java class - return buildJavaClass(frame, language, (PFunction) function, arguments, factory, callBody, name); + return buildJavaClass(frame, language, (PFunction) function, arguments, callBody, name); } class InitializeBuildClass { @@ -2540,7 +2538,7 @@ class InitializeBuildClass { ns = callPrep.execute(frame, prep, new Object[]{name, init.bases}, init.mkw); } catch (PException p) { p.expectAttributeError(inliningTarget, noAttributeProfile); - ns = factory.createDict(new DynamicObjectStorage(language)); + ns = PFactory.createDict(language, new DynamicObjectStorage(language)); } if (!pyMappingCheckNode.execute(inliningTarget, ns)) { throw raiseNoMapping(init.isClass, init.meta, ns); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java index fe32d28808..1fe9d7865d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -10,6 +10,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -29,7 +30,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CoerceToComplexNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -78,14 +79,14 @@ public void initialize(Python3Core core) { addBuiltinConstant("tau", 2 * Math.PI); addBuiltinConstant("inf", Double.POSITIVE_INFINITY); addBuiltinConstant("nan", Double.NaN); - addBuiltinConstant("infj", core.factory().createComplex(0, Double.POSITIVE_INFINITY)); - addBuiltinConstant("nanj", core.factory().createComplex(0, Double.NaN)); + addBuiltinConstant("infj", PFactory.createComplex(core.getLanguage(), 0, Double.POSITIVE_INFINITY)); + addBuiltinConstant("nanj", PFactory.createComplex(core.getLanguage(), 0, Double.NaN)); super.initialize(core); } - static PComplex specialValue(PythonObjectFactory factory, ComplexValue[][] table, double real, double imag) { + static PComplex specialValue(PythonLanguage language, ComplexValue[][] table, double real, double imag) { ComplexValue v = specialValue(table, real, imag); - return v == null ? null : v.toPComplex(factory); + return v == null ? null : v.toPComplex(language); } static ComplexValue specialValue(ComplexValue[][] table, double real, double imag) { @@ -122,8 +123,8 @@ static class ComplexValue { this.imag = imag; } - PComplex toPComplex(PythonObjectFactory factory) { - return factory.createComplex(real, imag); + PComplex toPComplex(PythonLanguage language) { + return PFactory.createComplex(language, real, imag); } } @@ -179,31 +180,31 @@ interface Op { @Specialization static PComplex doL(Node inliningTarget, long value, Op op, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(factory); + return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(language); } @Specialization static PComplex doD(Node inliningTarget, double value, Op op, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(factory); + return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(language); } @Specialization static PComplex doC(Node inliningTarget, PComplex value, Op op, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return op.compute(inliningTarget, value.getReal(), value.getImag(), raiseNode).toPComplex(factory); + return op.compute(inliningTarget, value.getReal(), value.getImag(), raiseNode).toPComplex(language); } @Specialization static PComplex doGeneral(VirtualFrame frame, Node inliningTarget, Object value, Op op, @Cached CoerceToComplexNode coerceToComplex, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - return doC(inliningTarget, coerceToComplex.execute(frame, inliningTarget, value), op, factory, raiseNode); + return doC(inliningTarget, coerceToComplex.execute(frame, inliningTarget, value), op, language, raiseNode); } } @@ -312,21 +313,21 @@ abstract static class PolarNode extends PythonUnaryBuiltinNode { @Specialization static PTuple doL(long value, - @Shared @Cached PythonObjectFactory factory) { - return doD(value, factory); + @Bind PythonLanguage language) { + return doD(value, language); } @Specialization static PTuple doD(double value, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{Math.abs(value), value < 0 ? Math.PI : 0}); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, new Object[]{Math.abs(value), value < 0 ? Math.PI : 0}); } @Specialization static PTuple doC(PComplex value, @Shared @Cached ComplexBuiltins.AbsNode absNode, - @Shared @Cached PythonObjectFactory factory) { - return toPolar(value, absNode, factory); + @Bind PythonLanguage language) { + return toPolar(value, absNode, language); } @Specialization @@ -334,13 +335,13 @@ static PTuple doGeneral(VirtualFrame frame, Object value, @Bind("this") Node inliningTarget, @Cached CoerceToComplexNode coerceToComplex, @Shared @Cached ComplexBuiltins.AbsNode absNode, - @Shared @Cached PythonObjectFactory factory) { - return toPolar(coerceToComplex.execute(frame, inliningTarget, value), absNode, factory); + @Bind PythonLanguage language) { + return toPolar(coerceToComplex.execute(frame, inliningTarget, value), absNode, language); } - private static PTuple toPolar(PComplex value, ComplexBuiltins.AbsNode absNode, PythonObjectFactory factory) { + private static PTuple toPolar(PComplex value, ComplexBuiltins.AbsNode absNode, PythonLanguage language) { double r = absNode.executeDouble(value); - return factory.createTuple(new Object[]{r, Math.atan2(value.getImag(), value.getReal())}); + return PFactory.createTuple(language, new Object[]{r, Math.atan2(value.getImag(), value.getReal())}); } } @@ -393,7 +394,7 @@ static PComplex doGeneral(VirtualFrame frame, Object r, Object phi, @TruffleBoundary private static PComplex rect(Node raisingNode, double r, double phi) { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); + PythonLanguage language = PythonLanguage.get(null); // deal with special values if (!Double.isFinite(r) || !Double.isFinite(phi)) { // need to raise an exception if r is a nonzero number and phi is infinite @@ -408,14 +409,14 @@ private static PComplex rect(Node raisingNode, double r, double phi) { double real = Math.copySign(Double.POSITIVE_INFINITY, Math.cos(phi)); double imag = Math.copySign(Double.POSITIVE_INFINITY, Math.sin(phi)); if (r > 0) { - return factory.createComplex(real, imag); + return PFactory.createComplex(language, real, imag); } else { - return factory.createComplex(-real, -imag); + return PFactory.createComplex(language, -real, -imag); } } - return specialValue(factory, SPECIAL_VALUES, r, phi); + return specialValue(language, SPECIAL_VALUES, r, phi); } - return factory.createComplex(r * Math.cos(phi), r * Math.sin(phi)); + return PFactory.createComplex(language, r * Math.cos(phi), r * Math.sin(phi)); } } @@ -446,15 +447,15 @@ static LogNode create() { @Specialization(guards = "isNoValue(y)") PComplex doComplexNone(PComplex x, @SuppressWarnings("unused") PNone y, - @Shared @Cached PythonObjectFactory factory) { - return log(x, factory); + @Bind PythonLanguage language) { + return log(x, language); } @Specialization PComplex doComplexComplex(VirtualFrame frame, PComplex x, PComplex y, @Shared @Cached ComplexBuiltins.DivNode divNode, - @Shared @Cached PythonObjectFactory factory) { - return divNode.executeComplex(frame, log(x, factory), log(y, factory)); + @Bind PythonLanguage language) { + return divNode.executeComplex(frame, log(x, language), log(y, language)); } @Specialization(guards = "isNoValue(yObj)") @@ -462,9 +463,9 @@ PComplex doGeneral(VirtualFrame frame, Object xObj, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached CoerceToComplexNode coerceXToComplex, // unused node to avoid mixing shared and non-shared inlined nodes - @SuppressWarnings("unsued") @Shared @Cached CoerceToComplexNode coerceYToComplex, - @Shared @Cached PythonObjectFactory factory) { - return log(coerceXToComplex.execute(frame, inliningTarget, xObj), factory); + @SuppressWarnings("unused") @Shared @Cached CoerceToComplexNode coerceYToComplex, + @Bind PythonLanguage language) { + return log(coerceXToComplex.execute(frame, inliningTarget, xObj), language); } @Specialization(guards = "!isNoValue(yObj)") @@ -473,20 +474,20 @@ PComplex doGeneral(VirtualFrame frame, Object xObj, Object yObj, @Shared @Cached CoerceToComplexNode coerceXToComplex, @Shared @Cached CoerceToComplexNode coerceYToComplex, @Shared @Cached ComplexBuiltins.DivNode divNode, - @Shared @Cached PythonObjectFactory factory) { - PComplex x = log(coerceXToComplex.execute(frame, inliningTarget, xObj), factory); - PComplex y = log(coerceYToComplex.execute(frame, inliningTarget, yObj), factory); + @Bind PythonLanguage language) { + PComplex x = log(coerceXToComplex.execute(frame, inliningTarget, xObj), language); + PComplex y = log(coerceYToComplex.execute(frame, inliningTarget, yObj), language); return divNode.executeComplex(frame, x, y); } - private PComplex log(PComplex z, PythonObjectFactory factory) { - PComplex r = specialValue(factory, SPECIAL_VALUES, z.getReal(), z.getImag()); + private PComplex log(PComplex z, PythonLanguage language) { + PComplex r = specialValue(language, SPECIAL_VALUES, z.getReal(), z.getImag()); if (r != null) { return r; } double real = computeRealPart(z.getReal(), z.getImag()); double imag = Math.atan2(z.getImag(), z.getReal()); - return factory.createComplex(real, imag); + return PFactory.createComplex(language, real, imag); } @TruffleBoundary @@ -523,17 +524,17 @@ abstract static class Log10Node extends PythonUnaryBuiltinNode { @Specialization PComplex doComplex(VirtualFrame frame, PComplex z, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PComplex r = logNode.executeComplex(frame, z, PNone.NO_VALUE); - return factory.createComplex(r.getReal() / LN_10, r.getImag() / LN_10); + return PFactory.createComplex(language, r.getReal() / LN_10, r.getImag() / LN_10); } @Specialization PComplex doGeneral(VirtualFrame frame, Object zObj, @Bind("this") Node inliningTarget, @Cached CoerceToComplexNode coerceXToComplex, - @Shared @Cached PythonObjectFactory factory) { - return doComplex(frame, coerceXToComplex.execute(frame, inliningTarget, zObj), factory); + @Bind PythonLanguage language) { + return doComplex(frame, coerceXToComplex.execute(frame, inliningTarget, zObj), language); } } @@ -1103,20 +1104,18 @@ abstract static class IsCloseNode extends PythonBuiltinNode { @Specialization static boolean doCCDD(PComplex a, PComplex b, double relTolObj, double absTolObj, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached AbsNode absNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return isClose(inliningTarget, a, b, relTolObj, absTolObj, factory, absNode, raiseNode); + return isClose(inliningTarget, a, b, relTolObj, absTolObj, absNode, raiseNode); } @Specialization @SuppressWarnings("unused") static boolean doCCNN(PComplex a, PComplex b, PNone relTolObj, PNone absTolObj, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached AbsNode absNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return isClose(inliningTarget, a, b, DEFAULT_REL_TOL, DEFAULT_ABS_TOL, factory, absNode, raiseNode); + return isClose(inliningTarget, a, b, DEFAULT_REL_TOL, DEFAULT_ABS_TOL, absNode, raiseNode); } @Specialization @@ -1126,17 +1125,16 @@ static boolean doGeneral(VirtualFrame frame, Object aObj, Object bObj, Object re @Cached CoerceToComplexNode coerceBToComplex, @Cached PyFloatAsDoubleNode relAsDoubleNode, @Cached PyFloatAsDoubleNode absAsDoubleNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached AbsNode absNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { PComplex a = coerceAToComplex.execute(frame, inliningTarget, aObj); PComplex b = coerceBToComplex.execute(frame, inliningTarget, bObj); double relTol = PGuards.isNoValue(relTolObj) ? DEFAULT_REL_TOL : relAsDoubleNode.execute(frame, inliningTarget, relTolObj); double absTol = PGuards.isPNone(absTolObj) ? DEFAULT_ABS_TOL : absAsDoubleNode.execute(frame, inliningTarget, absTolObj); - return isClose(inliningTarget, a, b, relTol, absTol, factory, absNode, raiseNode); + return isClose(inliningTarget, a, b, relTol, absTol, absNode, raiseNode); } - private static boolean isClose(Node inliningTarget, PComplex a, PComplex b, double relTol, double absTol, PythonObjectFactory factory, AbsNode absNode, PRaiseNode.Lazy raiseNode) { + private static boolean isClose(Node inliningTarget, PComplex a, PComplex b, double relTol, double absTol, AbsNode absNode, PRaiseNode.Lazy raiseNode) { if (relTol < 0.0 || absTol < 0.0) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TOLERANCE_MUST_NON_NEGATIVE); } @@ -1147,7 +1145,7 @@ private static boolean isClose(Node inliningTarget, PComplex a, PComplex b, doub Double.isInfinite(b.getReal()) || Double.isInfinite(b.getImag())) { return false; } - PComplex diff = factory.createComplex(a.getReal() - b.getReal(), a.getImag() - b.getImag()); + PComplex diff = PFactory.createComplex(PythonLanguage.get(inliningTarget), a.getReal() - b.getReal(), a.getImag() - b.getImag()); double len = absNode.executeDouble(diff); return len <= absTol || len <= relTol * absNode.executeDouble(b) || len <= relTol * absNode.executeDouble(a); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java index a24567c5a2..21d8ae4162 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java @@ -96,6 +96,7 @@ import java.nio.charset.CodingErrorAction; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -151,7 +152,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.CharsetMapping; @@ -646,13 +647,13 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = {"isString(self)"}) static Object encode(Object self, TruffleString encoding, TruffleString errors, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached CastToTruffleStringNode castStr, @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Cached CodecsEncodeToJavaBytesNode encode, - @Cached PythonObjectFactory factory) { + @Cached CodecsEncodeToJavaBytesNode encode) { TruffleString input = castStr.execute(inliningTarget, self); - PBytes bytes = factory.createBytes(encode.execute(self, encoding, errors)); - return factory.createTuple(new Object[]{bytes, codePointLengthNode.execute(input, TS_ENCODING)}); + PBytes bytes = PFactory.createBytes(language, encode.execute(self, encoding, errors)); + return PFactory.createTuple(language, new Object[]{bytes, codePointLengthNode.execute(input, TS_ENCODING)}); } @Fallback @@ -683,6 +684,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static Object decode(VirtualFrame frame, Object input, TruffleString encoding, TruffleString errors, boolean finalData, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("input") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @@ -690,8 +692,7 @@ static Object decode(VirtualFrame frame, Object input, TruffleString encoding, T @Cached NormalizeEncodingNameNode normalizeEncodingNameNode, @Cached InternErrorAction internErrorAction, @Cached HandleDecodingErrorNode errorHandler, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { Object buffer = acquireLib.acquireReadonly(input, frame, indirectCallData); try { int len = bufferLib.getBufferLength(buffer); @@ -706,13 +707,13 @@ static Object decode(VirtualFrame frame, Object input, TruffleString encoding, T try { decoder = new TruffleDecoder(normalizedEncoding, charset, bytes, len, errorAction); while (!decoder.decodingStep(finalData)) { - errorHandler.execute(frame, decoder, internErrorAction.execute(inliningTarget, errors), factory.createBytes(bytes, len)); + errorHandler.execute(frame, decoder, internErrorAction.execute(inliningTarget, errors), PFactory.createBytes(language, bytes, len)); } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw raiseNode.raise(MemoryError); } - return factory.createTuple(new Object[]{decoder.getString(), decoder.getInputPosition()}); + return PFactory.createTuple(language, new Object[]{decoder.getString(), decoder.getInputPosition()}); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -733,26 +734,26 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization Object decodeByteArray(byte[] bytes, TruffleString errors, - @Shared @Cached PythonObjectFactory factory) { - return decodeBytes(bytes, bytes.length, errors, factory); + @Bind PythonLanguage language) { + return decodeBytes(bytes, bytes.length, errors, language); } @Specialization(limit = "3") Object decode(VirtualFrame frame, Object buffer, TruffleString errors, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, - @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory) { + @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib) { try { int len = bufferLib.getBufferLength(buffer); - return decodeBytes(bufferLib.getInternalOrCopiedByteArray(buffer), len, errors, factory); + return decodeBytes(bufferLib.getInternalOrCopiedByteArray(buffer), len, errors, language); } finally { bufferLib.release(buffer, frame, indirectCallData); } } - private Object decodeBytes(byte[] bytes, int len, TruffleString errors, PythonObjectFactory factory) { + private Object decodeBytes(byte[] bytes, int len, TruffleString errors, PythonLanguage language) { ByteArrayBuffer result = doDecode(bytes, len, errors); - return factory.createTuple(new Object[]{factory.createBytes(result.getInternalBytes(), result.getLength()), len}); + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, result.getInternalBytes(), result.getLength()), len}); } @TruffleBoundary @@ -885,8 +886,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization Object encode(PBytes data, @SuppressWarnings("unused") TruffleString errors, @Bind("this") Node inliningTarget, - @Cached GetInternalByteArrayNode getInternalByteArrayNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached GetInternalByteArrayNode getInternalByteArrayNode) { byte[] bytes = getInternalByteArrayNode.execute(inliningTarget, data.getSequenceStorage()); int size = data.getSequenceStorage().length(); ByteArrayBuffer buffer = new ByteArrayBuffer(); @@ -917,8 +918,8 @@ Object encode(PBytes data, @SuppressWarnings("unused") TruffleString errors, } } - return factory.createTuple(new Object[]{ - factory.createBytes(buffer.getByteArray()), + return PFactory.createTuple(language, new Object[]{ + PFactory.createBytes(language, buffer.getByteArray()), size }); } @@ -991,7 +992,7 @@ static PTuple lookup(VirtualFrame frame, Node inliningTarget, TruffleString enco } if (hasTruffleEncodingProfile.profile(inliningTarget, hasTruffleEncodingNormalized(normalizedEncoding))) { PythonModule codecs = context.lookupBuiltinModule(T__CODECS_TRUFFLE); - result = CodecsTruffleModuleBuiltins.codecsInfo(codecs, encoding, context, context.factory()); + result = CodecsTruffleModuleBuiltins.codecsInfo(codecs, encoding, context); } else { Object[] searchPaths = getSearchPaths(context); for (Object func : searchPaths) { @@ -1510,12 +1511,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization Object doIt(VirtualFrame frame, TruffleString str, TruffleString errors, Object mapping, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Cached PyUnicodeEncodeCharmapNode encodeCharmapNode, - @Cached PythonObjectFactory factory) { + @Cached PyUnicodeEncodeCharmapNode encodeCharmapNode) { int len = codePointLengthNode.execute(str, TS_ENCODING); - PBytes result = factory.createBytes(encodeCharmapNode.execute(frame, inliningTarget, str, errors, mapping)); - return factory.createTuple(new Object[]{result, len}); + PBytes result = PFactory.createBytes(language, encodeCharmapNode.execute(frame, inliningTarget, str, errors, mapping)); + return PFactory.createTuple(language, new Object[]{result, len}); } } @@ -1536,8 +1537,7 @@ Object doIt(VirtualFrame frame, Object data, TruffleString errors, Object mappin @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("data") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PyUnicodeDecodeCharmapNode pyUnicodeDecodeCharmapNode, - @Cached PythonObjectFactory factory) { + @Cached PyUnicodeDecodeCharmapNode pyUnicodeDecodeCharmapNode) { Object dataBuffer = bufferAcquireLib.acquireReadonly(data, frame, context, context.getLanguage(inliningTarget), indirectCallData); int len; try { @@ -1546,7 +1546,7 @@ Object doIt(VirtualFrame frame, Object data, TruffleString errors, Object mappin bufferLib.release(dataBuffer, frame, indirectCallData); } TruffleString result = len == 0 ? T_EMPTY_STRING : pyUnicodeDecodeCharmapNode.execute(frame, data, errors, mapping); - return factory.createTuple(new Object[]{result, len}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{result, len}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java index ef4afc8854..ffc8d512c0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java @@ -99,7 +99,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -158,15 +158,13 @@ protected List> getNodeFa } private static PythonClass initClass(TruffleString className, TruffleString superClassName, BuiltinDescr[] descrs, PythonModule codecsTruffleModule, PythonModule codecsModule, - PythonLanguage language, - PythonObjectFactory factory) { + PythonLanguage language) { PythonAbstractClass superClass = (PythonAbstractClass) codecsModule.getAttribute(superClassName); - return initClass(className, superClass, descrs, codecsTruffleModule, language, factory); + return initClass(className, superClass, descrs, codecsTruffleModule, language); } - private static PythonClass initClass(TruffleString className, PythonAbstractClass superClass, BuiltinDescr[] descrs, PythonModule codecsTruffleModule, PythonLanguage language, - PythonObjectFactory factory) { - PythonClass clazz = factory.createPythonClassAndFixupSlots(language, PythonBuiltinClassType.PythonClass, className, superClass, new PythonAbstractClass[]{superClass}); + private static PythonClass initClass(TruffleString className, PythonAbstractClass superClass, BuiltinDescr[] descrs, PythonModule codecsTruffleModule, PythonLanguage language) { + PythonClass clazz = PFactory.createPythonClassAndFixupSlots(language, className, superClass, new PythonAbstractClass[]{superClass}); for (BuiltinDescr d : descrs) { PythonUtils.createMethod(language, clazz, d.nodeFactory(), d.enclosingType ? clazz : null, 1); } @@ -180,36 +178,37 @@ private record BuiltinDescr(NodeFactory nodeFac } @TruffleBoundary - static PTuple codecsInfo(PythonModule self, TruffleString encoding, PythonContext context, PythonObjectFactory factory) { + static PTuple codecsInfo(PythonModule self, TruffleString encoding, PythonContext context) { PythonModule codecsModule = AbstractImportNode.importModule(T_CODECS); CodecsTruffleModuleBuiltins codecsTruffleBuiltins = (CodecsTruffleModuleBuiltins) self.getBuiltins(); if (self.getAttribute(T_TRUFFLE_CODEC) instanceof PNone) { - initCodecClasses(self, codecsModule, context, factory); + initCodecClasses(self, codecsModule, context); } + PythonLanguage language = context.getLanguage(); // encode/decode methods for codecs.CodecInfo - PythonObject truffleCodec = factory.createPythonObject(codecsTruffleBuiltins.truffleCodecClass); + PythonObject truffleCodec = createPythonObject(language, codecsTruffleBuiltins.truffleCodecClass); truffleCodec.setAttribute(T_ATTR_ENCODING, encoding); Object encodeMethod = PyObjectGetAttr.executeUncached(truffleCodec, T_ENCODE); Object decodeMethod = PyObjectGetAttr.executeUncached(truffleCodec, T_DECODE); // incrementalencoder factory function for codecs.CodecInfo - PythonObject tie = factory.createPythonObject(codecsTruffleBuiltins.applyEncodingClass); + PythonObject tie = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass); tie.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleIncrementalEncoderClass); tie.setAttribute(T_ATTR_ENCODING, encoding); // incrementaldecoder factory function for codecs.CodecInfo - PythonObject tid = factory.createPythonObject(codecsTruffleBuiltins.applyEncodingClass); + PythonObject tid = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass); tid.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleIncrementalDecoderClass); tid.setAttribute(T_ATTR_ENCODING, encoding); // streamwriter factory function for codecs.CodecInfo - PythonObject sr = factory.createPythonObject(codecsTruffleBuiltins.applyEncodingClass); + PythonObject sr = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass); sr.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleStreamReaderClass); sr.setAttribute(T_ATTR_ENCODING, encoding); // streamreader factory function for codecs.CodecInfo - PythonObject sw = factory.createPythonObject(codecsTruffleBuiltins.applyEncodingClass); + PythonObject sw = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass); sw.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleStreamWriterClass); sw.setAttribute(T_ATTR_ENCODING, encoding); @@ -218,6 +217,10 @@ static PTuple codecsInfo(PythonModule self, TruffleString encoding, PythonContex return (PTuple) CallVarargsMethodNode.getUncached().execute(null, codecInfoClass, new Object[]{}, createCodecInfoArgs(encoding, encodeMethod, decodeMethod, tie, tid, sr, sw)); } + private static PythonObject createPythonObject(PythonLanguage language, PythonClass cls) { + return PFactory.createPythonObject(language, cls, cls.getInstanceShape()); + } + private static PKeyword[] createCodecInfoArgs(TruffleString encoding, Object encodeMethod, Object decodeMethod, PythonObject tie, PythonObject tid, PythonObject sr, PythonObject sw) { return new PKeyword[]{ new PKeyword(T_NAME, encoding), @@ -234,7 +237,7 @@ private static PKeyword[] createCodecInfoArgs(TruffleString encoding, Object enc * create classes based on types declared in lib/3/codes.py */ // @formatter:off - private static void initCodecClasses(PythonModule codecsTruffleModule, PythonModule codecsModule, PythonContext context, PythonObjectFactory factory) { + private static void initCodecClasses(PythonModule codecsTruffleModule, PythonModule codecsModule, PythonContext context) { // TODO - the incremental codec and reader/writer won't work well with stateful // encodings, like some of the CJK encodings @@ -250,7 +253,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod new BuiltinDescr[]{ new BuiltinDescr(EncodeNodeFactory.getInstance(), false), new BuiltinDescr(CodecDecodeNodeFactory.getInstance(), true)}, - codecsTruffleModule, language, factory); + codecsTruffleModule, language); // class TruffleIncrementalEncoder(codecs.IncrementalEncoder): // def __init__(self, encoding, *args, **kwargs): @@ -262,7 +265,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod new BuiltinDescr[]{ new BuiltinDescr(CodecInitNodeFactory.getInstance(), false), new BuiltinDescr(IncrementalEncodeNodeFactory.getInstance(), true)}, - codecsTruffleModule, codecsModule, language, factory); + codecsTruffleModule, codecsModule, language); // class TruffleIncrementalDecoder(codecs.BufferedIncrementalDecoder): // def __init__(self, encoding, *args, **kwargs): @@ -274,7 +277,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod new BuiltinDescr[]{ new BuiltinDescr(CodecInitNodeFactory.getInstance(), false), new BuiltinDescr(IncrementalDecodeNodeFactory.getInstance(), true)}, - codecsTruffleModule, codecsModule, language, factory); + codecsTruffleModule, codecsModule, language); // class TruffleStreamWriter(codecs.StreamWriter): // def __init__(self, encoding, *args, **kwargs): @@ -286,7 +289,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod new BuiltinDescr[]{ new BuiltinDescr(CodecInitNodeFactory.getInstance(), false), new BuiltinDescr(EncodeNodeFactory.getInstance(), true)}, - codecsTruffleModule, codecsModule, language, factory); + codecsTruffleModule, codecsModule, language); // class TruffleStreamReader(codecs.StreamReader): // def __init__(self, encoding, *args, **kwargs): @@ -298,7 +301,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod new BuiltinDescr[]{ new BuiltinDescr(CodecInitNodeFactory.getInstance(), false), new BuiltinDescr(StreamDecodeNodeFactory.getInstance(), true)}, - codecsTruffleModule, codecsModule, language, factory); + codecsTruffleModule, codecsModule, language); // serves as factory function for CodecInfo-s incrementalencoder/decode and streamwriter/reader // class apply_encoding: @@ -306,7 +309,7 @@ private static void initCodecClasses(PythonModule codecsTruffleModule, PythonMod // return self.fn(self.encoding, *args, **kwargs) codecsTruffleBuiltins.applyEncodingClass = initClass(T_APPLY_ENCODING, context.lookupType(PythonBuiltinClassType.PythonObject), new BuiltinDescr[]{new BuiltinDescr(CallApplyNodeFactory.getInstance(), false)}, - codecsTruffleModule, language, factory); + codecsTruffleModule, language); } // @formatter:on diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java index 801772f68c..934e08654b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -59,6 +60,7 @@ import com.oracle.graal.python.builtins.objects.deque.PDequeIter; import com.oracle.graal.python.builtins.objects.dict.PDefaultDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyNumberIndexNode; import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.ErrorMessages; @@ -69,8 +71,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -92,19 +93,12 @@ protected List> getNodeFa @GenerateNodeFactory abstract static class DequeNode extends PythonVarargsBuiltinNode { - @Override - public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { - if (arguments.length >= 1) { - return doGeneric(arguments[0], null, null); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw VarargsBuiltinDirectInvocationNotSupported.INSTANCE; - } - @Specialization @SuppressWarnings("unused") - PDeque doGeneric(Object cls, Object[] args, PKeyword[] kwargs) { - return factory().createDeque(cls); + PDeque doGeneric(Object cls, Object[] args, PKeyword[] kwargs, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createDeque(language, cls, getInstanceShape.execute(cls)); } } @@ -122,12 +116,12 @@ static PDequeIter doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Obje @Cached PyNumberIndexNode toIndexNode, @Cached CastToJavaIntExactNode castToJavaIntExactNode, @Cached DequeIterNextNode getNextNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!dequeProfile.profile(inliningTarget, deque instanceof PDeque)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); } - PDequeIter dequeIter = factory.createDequeIter((PDeque) deque); + PDequeIter dequeIter = PFactory.createDequeIter(language, (PDeque) deque); if (indexNoneProfile.profile(inliningTarget, indexObj != PNone.NO_VALUE)) { int index = castToJavaIntExactNode.execute(inliningTarget, toIndexNode.execute(frame, inliningTarget, indexObj)); for (int i = 0; i < index; i++) { @@ -151,12 +145,12 @@ static PDequeIter doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Obje @Cached PyNumberIndexNode toIndexNode, @Cached CastToJavaIntExactNode castToJavaIntExactNode, @Cached DequeIterNextNode getNextNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!dequeProfile.profile(inliningTarget, deque instanceof PDeque)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); } - PDequeIter dequeIter = factory.createDequeRevIter((PDeque) deque); + PDequeIter dequeIter = PFactory.createDequeRevIter(language, (PDeque) deque); if (indexNoneProfile.profile(inliningTarget, indexObj != PNone.NO_VALUE)) { int index = castToJavaIntExactNode.execute(inliningTarget, toIndexNode.execute(frame, inliningTarget, indexObj)); for (int i = 0; i < index; i++) { @@ -174,8 +168,9 @@ abstract static class DefaultDictNode extends PythonVarargsBuiltinNode { @Specialization @SuppressWarnings("unused") PDefaultDict doGeneric(Object cls, Object[] args, PKeyword[] kwargs, - @Cached PythonObjectFactory factory) { - return factory.createDefaultDict(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createDefaultDict(language, cls, getInstanceShape.execute(cls)); } } @@ -190,9 +185,9 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - Object construct(Object cls, int index, Object doc, - @Cached PythonObjectFactory factory) { - return factory.createTupleGetter(cls, index, doc); + Object construct(@SuppressWarnings("unused") Object cls, int index, Object doc, + @Bind PythonLanguage language) { + return PFactory.createTupleGetter(language, index, doc); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java index 23dc550b09..33c5ff36ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -60,7 +61,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -103,11 +104,11 @@ protected ArgumentClinicProvider getArgumentClinic() { protected static Object constructDef(@SuppressWarnings("unused") Object cls, TruffleString name, Object def, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile noValueProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (noValueProfile.profile(inliningTarget, isNoValue(def))) { def = PContextVar.NO_DEFAULT; } - return factory.createContextVar(name, def); + return PFactory.createContextVar(language, name, def); } } @@ -116,8 +117,8 @@ protected static Object constructDef(@SuppressWarnings("unused") Object cls, Tru public abstract static class ContextNode extends PythonUnaryBuiltinNode { @Specialization static Object construct(@SuppressWarnings("unused") Object cls, - @Cached PythonObjectFactory factory) { - return factory.createContextVarsContext(); + @Bind PythonLanguage language) { + return PFactory.createContextVarsContext(language); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ErrnoModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ErrnoModuleBuiltins.java index 2972ac9617..1d9a8d7fdf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ErrnoModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ErrnoModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -53,6 +53,7 @@ import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.strings.TruffleString; @@ -75,7 +76,7 @@ public void initialize(Python3Core core) { } // publish the dictionary with mapping code -> string name - PDict errorCode = core.factory().createDict(storage); + PDict errorCode = PFactory.createDict(core.getLanguage(), storage); addBuiltinConstant("errorcode", errorCode); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java index 6e20c9bea8..c20cc0a987 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -79,8 +79,9 @@ import com.oracle.graal.python.runtime.PosixConstants.IntConstant; import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; +import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -198,7 +199,8 @@ abstract static class IoctlNode extends PythonClinicBuiltinNode { @Specialization Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutateArg, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @@ -209,7 +211,6 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat @Cached GilNode gilNode, @Cached PRaiseNode.Lazy raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached SysModuleBuiltins.AuditNode auditNode) { auditNode.audit(inliningTarget, "fcnt.ioctl", fd, request, arg); @@ -260,7 +261,7 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat if (writable && mutateArg) { return ret; } else { - return factory.createBytes(ioctlArg, len); + return PFactory.createBytes(context.getLanguage(inliningTarget), ioctlArg, len); } } finally { if (writeBack) { @@ -289,7 +290,7 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat byte[] ioctlArg = new byte[len + 1]; copyToByteArrayNode.execute(stringArg, 0, ioctlArg, 0, len, utf8); callIoctlBytes(frame, inliningTarget, fd, request, ioctlArg, true, posixLib, gilNode, constructAndRaiseNode); - return factory.createBytes(ioctlArg, len); + return PFactory.createBytes(context.getLanguage(inliningTarget), ioctlArg, len); } // int arg diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java index c0664e86e4..d4c4585762 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java @@ -29,6 +29,7 @@ import java.lang.management.ManagementFactory; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -65,7 +66,7 @@ import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -105,7 +106,7 @@ public void initialize(Python3Core core) { addBuiltinConstant("DEBUG_UNCOLLECTABLE", DEBUG_UNCOLLECTABLE); addBuiltinConstant("DEBUG_SAVEALL", DEBUG_SAVEALL); addBuiltinConstant("DEBUG_LEAK", DEBUG_LEAK); - addBuiltinConstant(CALLBACKS, core.factory().createList()); + addBuiltinConstant(CALLBACKS, PFactory.createList(core.getLanguage())); super.initialize(core); } @@ -127,7 +128,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un @Cached PyObjectGetAttr getAttr, @Cached PyObjectGetIter getIter, @Cached(neverDefault = true) PyIterNextNode next, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached CallBinaryMethodNode call, @Cached GilNode gil, @Cached GetThreadStateNode getThreadStateNode, @@ -141,7 +142,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un long res = 0; if (cb != null) { phase = START; - info = factory.createDict(new PKeyword[]{ + info = PFactory.createDict(language, new PKeyword[]{ new PKeyword(GENERATION, 2), new PKeyword(COLLECTED, 0), new PKeyword(UNCOLLECTABLE, 0), @@ -161,7 +162,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un } if (phase != null) { phase = STOP; - info = factory.createDict(new PKeyword[]{ + info = PFactory.createDict(language, new PKeyword[]{ new PKeyword(GENERATION, 2), new PKeyword(COLLECTED, freedMemory), new PKeyword(UNCOLLECTABLE, 0), @@ -287,7 +288,7 @@ static PTuple count() { count += cc; } } - return PythonContext.get(null).factory().createTuple(new Object[]{count, 0, 0}); + return PFactory.createTuple(PythonLanguage.get(null), new Object[]{count, 0, 0}); } } @@ -313,7 +314,7 @@ abstract static class GcGetReferentsNode extends PythonBuiltinNode { static PList getReferents(@SuppressWarnings("unused") Object objects) { // TODO: this is just a dummy implementation; for native objects, this should actually // use 'tp_traverse' - return PythonContext.get(null).factory().createList(); + return PFactory.createList(PythonLanguage.get(null)); } } @@ -324,7 +325,7 @@ abstract static class GcGetReferrersNode extends PythonBuiltinNode { @TruffleBoundary static PList doGeneric(@SuppressWarnings("unused") Object objects) { // dummy implementation - return PythonContext.get(null).factory().createList(); + return PFactory.createList(PythonLanguage.get(null)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java index 7fbf2ab87f..ed28573a80 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import java.util.Collections; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,6 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -135,11 +137,12 @@ public Object execute(VirtualFrame frame) { @TruffleBoundary static PBuiltinMethod createFunction(Python3Core core, PythonModule module) { Builtin builtin = NotAvailable.class.getAnnotation(Builtin.class); - RootCallTarget callTarget = core.getLanguage().createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, NotAvailable.NODE_FACTORY, false), NotAvailable.class, + PythonLanguage language = core.getLanguage(); + RootCallTarget callTarget = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, NotAvailable.NODE_FACTORY, false), NotAvailable.class, builtin.name()); int flags = PBuiltinFunction.getFlags(builtin, callTarget); TruffleString name = PythonUtils.toTruffleStringUncached(builtin.name()); - PBuiltinFunction fun = core.factory().createBuiltinFunction(name, null, 0, flags, callTarget); - return core.factory().createBuiltinMethod(module, fun); + PBuiltinFunction fun = PFactory.createBuiltinFunction(language, name, null, 0, flags, callTarget); + return PFactory.createBuiltinMethod(language, module, fun); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java index e6a9ceded9..339859f6a8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java @@ -78,6 +78,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -124,7 +125,7 @@ public void initialize(Python3Core core) { @Override public void postInitialize(Python3Core core) { PythonModule module = core.lookupBuiltinModule(T_HPY_UNIVERSAL); - module.setAttribute(T___ALL__, core.factory().createTuple(ALL_ARRAY)); + module.setAttribute(T___ALL__, PFactory.createTuple(core.getLanguage(), ALL_ARRAY)); } @Builtin(name = "load", parameterNames = {"name", "path", "spec", "debug", "mode"}, minNumOfPositionalArgs = 3) 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 1e20104ca1..5bc287952d 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -83,11 +83,6 @@ import java.util.List; import java.util.logging.Level; -import com.oracle.graal.python.nodes.arrow.ArrowArray; -import com.oracle.graal.python.nodes.arrow.ArrowSchema; -import com.oracle.graal.python.nodes.arrow.capsule.CreateArrowPyCapsuleNode; -import com.oracle.graal.python.nodes.arrow.vector.VectorToArrowArrayNode; -import com.oracle.graal.python.nodes.arrow.vector.VectorToArrowSchemaNode; import org.graalvm.nativeimage.ImageInfo; import com.oracle.graal.python.PythonLanguage; @@ -141,6 +136,11 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.arrow.ArrowArray; +import com.oracle.graal.python.nodes.arrow.ArrowSchema; +import com.oracle.graal.python.nodes.arrow.capsule.CreateArrowPyCapsuleNode; +import com.oracle.graal.python.nodes.arrow.vector.VectorToArrowArrayNode; +import com.oracle.graal.python.nodes.arrow.vector.VectorToArrowSchemaNode; import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; import com.oracle.graal.python.nodes.call.CallNode; @@ -166,7 +166,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonExitException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.NativePrimitiveSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; @@ -274,7 +274,7 @@ public void postInitialize(Python3Core core) { mod.setAttribute(tsLiteral("capi_home"), capiHome); mod.setAttribute(tsLiteral("jni_home"), context.getJNIHome()); Object[] arr = convertToObjectArray(PythonOptions.getExecutableList(context)); - PList executableList = PythonObjectFactory.getUncached().createList(arr); + PList executableList = PFactory.createList(language, arr); mod.setAttribute(tsLiteral("executable_list"), executableList); mod.setAttribute(tsLiteral("venvlauncher_command"), context.getOption(PythonOptions.VenvlauncherCommand)); mod.setAttribute(tsLiteral("ForeignType"), core.lookupType(PythonBuiltinClassType.ForeignObject)); @@ -441,15 +441,15 @@ public abstract static class ReadFileNode extends PythonUnaryBuiltinNode { @Specialization PBytes doString(VirtualFrame frame, Object filenameObj, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached CastToTruffleStringNode castToTruffleStringNode, @Cached TruffleString.EqualNode eqNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { TruffleString filename = castToTruffleStringNode.execute(inliningTarget, filenameObj); - TruffleFile file = getContext().getPublicTruffleFileRelaxed(filename, PythonLanguage.T_DEFAULT_PYTHON_EXTENSIONS); + TruffleFile file = context.getPublicTruffleFileRelaxed(filename, PythonLanguage.T_DEFAULT_PYTHON_EXTENSIONS); byte[] bytes = file.readAllBytes(); - return factory.createBytes(bytes); + return PFactory.createBytes(context.getLanguage(inliningTarget), bytes); } catch (Exception ex) { ErrorAndMessagePair errAndMsg = OSErrorEnum.fromException(ex, eqNode); throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, errAndMsg.oserror.getNumber(), errAndMsg.message); @@ -543,8 +543,8 @@ public abstract static class BuiltinNode extends PythonUnaryBuiltinNode { @Specialization public Object doIt(VirtualFrame frame, PFunction func, @Bind("this") Node inliningTarget, - @Cached PyObjectGetItem getItem, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @Cached PyObjectGetItem getItem) { PFunction builtinFunc = convertToBuiltin(func); PythonObject globals = func.getGlobals(); PythonModule builtinModule; @@ -552,10 +552,10 @@ public Object doIt(VirtualFrame frame, PFunction func, builtinModule = (PythonModule) globals; } else { TruffleString moduleName = (TruffleString) getItem.execute(frame, inliningTarget, globals, T___NAME__); - builtinModule = getContext().lookupBuiltinModule(moduleName); + builtinModule = context.lookupBuiltinModule(moduleName); assert builtinModule != null; } - return factory.createBuiltinMethod(builtinModule, builtinFunc); + return PFactory.createBuiltinMethod(context.getLanguage(inliningTarget), builtinModule, builtinFunc); } @TruffleBoundary @@ -634,8 +634,8 @@ static Tool forBinary(String name, Object... targets) { @Specialization @TruffleBoundary Object getToolPath() { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - Env env = getContext().getEnv(); + PythonContext context = getContext(); + Env env = context.getEnv(); LanguageInfo llvmInfo = env.getInternalLanguages().get(J_LLVM_LANGUAGE); Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); List toolchainPaths = toolchain.getPaths("PATH"); @@ -658,12 +658,12 @@ Object getToolPath() { } } if (path != null) { - storage.putUncached(toTruffleStringUncached(path), factory.createTuple(tool.targets)); + storage.putUncached(toTruffleStringUncached(path), PFactory.createTuple(context.getLanguage(), tool.targets)); } else { LOGGER.fine("Could not locate tool " + tool.name); } } - return factory.createDict(storage); + return PFactory.createDict(context.getLanguage(), storage); } } @@ -692,7 +692,8 @@ public abstract static class GetToolchainPathsNode extends PythonUnaryBuiltinNod @Specialization @TruffleBoundary protected Object getToolPath(TruffleString tool) { - Env env = getContext().getEnv(); + PythonContext context = getContext(); + Env env = context.getEnv(); LanguageInfo llvmInfo = env.getInternalLanguages().get(J_LLVM_LANGUAGE); Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); List toolPaths = toolchain.getPaths(tool.toJavaStringUncached()); @@ -703,7 +704,7 @@ protected Object getToolPath(TruffleString tool) { for (int i = 0; i < pathNames.length; i++) { pathNames[i] = toTruffleStringUncached(toolPaths.get(i).toString().replace("\\", "/")); } - return PythonObjectFactory.getUncached().createList(pathNames); + return PFactory.createList(context.getLanguage(), pathNames); } } @@ -727,8 +728,8 @@ public abstract static class DetermineSystemToolchain extends PythonUnaryBuiltin @Specialization static PDict doGeneric(@SuppressWarnings("unused") Object unused, - @Cached PythonObjectFactory factory) { - return factory.createDict(fromToolchain()); + @Bind PythonLanguage language) { + return PFactory.createDict(language, fromToolchain()); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java index a8de465698..ff40c6724b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java @@ -117,7 +117,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; @@ -260,8 +260,6 @@ public abstract static class GetMagic extends PythonBuiltinNode { MAGIC_NUMBER_BYTES[3] = '\n'; } - @Child PythonObjectFactory factory = PythonObjectFactory.create(); // GR-47032 - @Specialization(guards = "isSingleContext()") PBytes runCachedSingleContext( @Cached(value = "getMagicNumberPBytes()", weak = true) PBytes magicBytes) { @@ -269,12 +267,13 @@ PBytes runCachedSingleContext( } @Specialization(replaces = "runCachedSingleContext") - PBytes run() { - return factory.createBytes(MAGIC_NUMBER_BYTES); + PBytes run( + @Bind PythonLanguage language) { + return PFactory.createBytes(language, MAGIC_NUMBER_BYTES); } protected PBytes getMagicNumberPBytes() { - return factory.createBytes(MAGIC_NUMBER_BYTES); + return PFactory.createBytes(PythonLanguage.get(this), MAGIC_NUMBER_BYTES); } } @@ -540,6 +539,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object run(VirtualFrame frame, TruffleString name, Object dataObj, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached TruffleString.EqualNode equalNode, @@ -558,7 +558,7 @@ static Object run(VirtualFrame frame, TruffleString name, Object dataObj, raiseFrozenError(frame, FROZEN_INVALID, name, constructAndRaiseNode.get(inliningTarget)); } } else { - FrozenResult result = findFrozen(PythonContext.get(inliningTarget), name, equalNode); + FrozenResult result = findFrozen(context, name, equalNode); FrozenStatus status = result.status; info = result.info; raiseFrozenError(frame, status, name, constructAndRaiseNode.get(inliningTarget)); @@ -567,7 +567,7 @@ static Object run(VirtualFrame frame, TruffleString name, Object dataObj, Object code = null; try { - code = MarshalModuleBuiltins.Marshal.load(info.data, info.size); + code = MarshalModuleBuiltins.Marshal.load(context, info.data, info.size); } catch (MarshalError | NumberFormatException e) { raiseFrozenError(frame, FROZEN_INVALID, name, constructAndRaiseNode.get(inliningTarget)); } @@ -603,12 +603,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - Object run(VirtualFrame frame, TruffleString name, boolean withData, + static Object run(VirtualFrame frame, TruffleString name, boolean withData, + @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached MemoryViewNode memoryViewNode, @Cached TruffleString.EqualNode equalNode, - @Cached PConstructAndRaiseNode constructAndRaiseNode, - @Cached PythonObjectFactory factory) { - FrozenResult result = findFrozen(getContext(), name, equalNode); + @Cached PConstructAndRaiseNode constructAndRaiseNode) { + FrozenResult result = findFrozen(context, name, equalNode); FrozenStatus status = result.status; FrozenInfo info = result.info; @@ -624,7 +625,7 @@ Object run(VirtualFrame frame, TruffleString name, boolean withData, PMemoryView data = null; if (withData) { - data = memoryViewNode.execute(frame, factory.createBytes(info.data)); + data = memoryViewNode.execute(frame, PFactory.createBytes(context.getLanguage(inliningTarget), info.data)); } Object[] returnValues = new Object[]{ @@ -633,7 +634,7 @@ Object run(VirtualFrame frame, TruffleString name, boolean withData, info.origName == null ? PNone.NONE : info.origName }; - return factory.createTuple(returnValues); + return PFactory.createTuple(context.getLanguage(inliningTarget), returnValues); } } @@ -689,13 +690,13 @@ public static PythonModule importFrozenModuleObject(Python3Core core, TruffleStr } } - PCode code = (PCode) MarshalModuleBuiltins.Marshal.load(info.data, info.size); + PCode code = (PCode) MarshalModuleBuiltins.Marshal.load(core.getContext(), info.data, info.size); - PythonModule module = globals == null ? core.factory().createPythonModule(name) : globals; + PythonModule module = globals == null ? PFactory.createPythonModule(core.getLanguage(), name) : globals; if (info.isPackage) { /* Set __path__ to the empty list */ - WriteAttributeToPythonObjectNode.getUncached().execute(module, T___PATH__, core.factory().createList()); + WriteAttributeToPythonObjectNode.getUncached().execute(module, T___PATH__, PFactory.createList(core.getLanguage())); } RootCallTarget callTarget = CodeNodes.GetCodeCallTargetNode.executeUncached(code); @@ -767,10 +768,10 @@ public abstract static class SourceHashNode extends PythonBinaryClinicBuiltinNod @Specialization static PBytes run(long magicNumber, Object sourceBuffer, @Bind("this") Node inliningTarget, - @Cached BytesNodes.HashBufferNode hashBufferNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached BytesNodes.HashBufferNode hashBufferNode) { long sourceHash = hashBufferNode.execute(inliningTarget, sourceBuffer); - return factory.createBytes(computeHash(magicNumber, sourceHash)); + return PFactory.createBytes(language, computeHash(magicNumber, sourceHash)); } @TruffleBoundary @@ -814,8 +815,8 @@ public Object run(PCode code, TruffleString path) { public abstract static class ExtensionSuffixesNode extends PythonBuiltinNode { @Specialization Object run( - @Cached PythonObjectFactory factory) { - return factory.createList(new Object[]{PythonContext.get(this).getSoAbi(), T_EXT_SO, T_EXT_PYD}); + @Bind PythonLanguage language) { + return PFactory.createList(language, new Object[]{PythonContext.get(this).getSoAbi(), T_EXT_SO, T_EXT_PYD}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java index c2182724a6..c7b724608d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java @@ -34,7 +34,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.MUST_BE_NON_NEGATIVE; import static com.oracle.graal.python.nodes.ErrorMessages.NUMBER_IS_REQUIRED; import static com.oracle.graal.python.nodes.ErrorMessages.STEP_FOR_ISLICE_MUST_BE; -import static com.oracle.graal.python.nodes.ErrorMessages.S_EXPECTED_GOT_P; import static com.oracle.graal.python.nodes.ErrorMessages.S_FOR_ISLICE_MUST_BE; import static com.oracle.graal.python.nodes.ErrorMessages.S_MUST_BE_S; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___COPY__; @@ -42,6 +41,7 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -74,7 +74,6 @@ import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; import com.oracle.graal.python.lib.PyCallableCheckNode; -import com.oracle.graal.python.lib.PyLongAsIntNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyNumberCheckNode; import com.oracle.graal.python.lib.PyObjectGetIter; @@ -94,7 +93,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -124,59 +123,19 @@ protected List> getNodeFa @GenerateNodeFactory public abstract static class AccumulateNode extends PythonBuiltinNode { - @Specialization(guards = "isTypeNode.execute(inliningTarget, cls)") - protected static PAccumulate construct(VirtualFrame frame, Object cls, Object iterable, @SuppressWarnings("unused") PNone func, @SuppressWarnings("unused") PNone initial, - @Bind("this") Node inliningTarget, - @Shared("getIter") @Cached PyObjectGetIter getIter, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - return create(frame, inliningTarget, cls, iterable, null, null, getIter, factory); - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "!isNone(initial)"}) - protected static PAccumulate construct(VirtualFrame frame, Object cls, Object iterable, @SuppressWarnings("unused") PNone func, Object initial, - @Bind("this") Node inliningTarget, - @Shared("getIter") @Cached PyObjectGetIter getIter, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - return create(frame, inliningTarget, cls, iterable, null, initial, getIter, factory); - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "!isNone(func)"}) - protected static PAccumulate construct(VirtualFrame frame, Object cls, Object iterable, Object func, @SuppressWarnings("unused") PNone initial, - @Bind("this") Node inliningTarget, - @Shared("getIter") @Cached PyObjectGetIter getIter, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - return create(frame, inliningTarget, cls, iterable, func, null, getIter, factory); - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "!isNone(func)", "!isNone(initial)"}) + @Specialization protected static PAccumulate construct(VirtualFrame frame, Object cls, Object iterable, Object func, Object initial, @Bind("this") Node inliningTarget, - @Shared("getIter") @Cached PyObjectGetIter getIter, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - return create(frame, inliningTarget, cls, iterable, func, initial, getIter, factory); - } - - private static PAccumulate create(VirtualFrame frame, Node inliningTarget, Object cls, Object iterable, Object func, Object initial, PyObjectGetIter getIter, PythonObjectFactory factory) { - PAccumulate self = factory.createAccumulate(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, + @Cached PyObjectGetIter getIter) { + PAccumulate self = PFactory.createAccumulate(language, cls, getInstanceShape.execute(cls)); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); self.setFunc(func instanceof PNone ? null : func); self.setTotal(null); self.setInitial(initial instanceof PNone ? null : initial); return self; } - - @Specialization(guards = "!isTypeNode.execute(inliningTarget, cls)") - @SuppressWarnings("unused") - static Object notype(Object cls, Object iterable, Object func, Object initial, - @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); - } } @Builtin(name = "combinations", minNumOfPositionalArgs = 3, constructsClass = PythonBuiltinClassType.PCombinations, parameterNames = {"cls", "iterable", @@ -200,7 +159,8 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, @Cached LoopConditionProfile indicesLoopProfile, @Cached InlinedConditionProfile wrongTypeProfile, @Cached InlinedConditionProfile negativeProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -209,7 +169,7 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); } - PCombinations self = factory.createCombinations(cls); + PCombinations self = PFactory.createCombinations(language, cls, getInstanceShape.execute(cls)); self.setPool(toArrayNode.execute(frame, iterable)); int[] indices = new int[r]; @@ -247,7 +207,8 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, @Cached ToArrayNode toArrayNode, @Cached InlinedConditionProfile wrongTypeProfile, @Cached InlinedConditionProfile negativeProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -255,7 +216,7 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, if (negativeProfile.profile(inliningTarget, r < 0)) { throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); } - PCombinationsWithReplacement self = factory.createCombinationsWithReplacement(cls); + PCombinationsWithReplacement self = PFactory.createCombinationsWithReplacement(language, cls, getInstanceShape.execute(cls)); self.setPool(toArrayNode.execute(frame, iterable)); self.setR(r); @@ -283,12 +244,13 @@ static PCompress construct(VirtualFrame frame, Object cls, Object data, Object s @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } - PCompress self = factory.createCompress(cls); + PCompress self = PFactory.createCompress(language, cls, getInstanceShape.execute(cls)); self.setData(getIter.execute(frame, inliningTarget, data)); self.setSelectors(getIter.execute(frame, inliningTarget, selectors)); return self; @@ -316,7 +278,8 @@ static PCycle construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -328,7 +291,7 @@ static PCycle construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "cycle", 1); } Object iterable = args[0]; - PCycle self = factory.createCycle(cls); + PCycle self = PFactory.createCycle(language, cls, getInstanceShape.execute(cls)); self.setSaved(new ArrayList<>()); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); self.setIndex(0); @@ -348,7 +311,8 @@ static PDropwhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -361,7 +325,7 @@ static PDropwhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw } Object predicate = args[0]; Object iterable = args[1]; - PDropwhile self = factory.createDropwhile(cls); + PDropwhile self = PFactory.createDropwhile(language, cls, getInstanceShape.execute(cls)); self.setPredicate(predicate); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); self.setDoneDropping(false); @@ -381,7 +345,8 @@ static PFilterfalse construct(VirtualFrame frame, Object cls, Object[] args, PKe @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -394,7 +359,7 @@ static PFilterfalse construct(VirtualFrame frame, Object cls, Object[] args, PKe } Object func = args[0]; Object sequence = args[1]; - PFilterfalse self = factory.createFilterfalse(cls); + PFilterfalse self = PFactory.createFilterfalse(language, cls, getInstanceShape.execute(cls)); self.setFunc(PGuards.isPNone(func) ? null : func); self.setSequence(getIter.execute(frame, inliningTarget, sequence)); return self; @@ -431,12 +396,13 @@ static PGroupBy construct(VirtualFrame frame, Object cls, Object iterable, Objec @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } - PGroupBy self = factory.createGroupBy(cls); + PGroupBy self = PFactory.createGroupBy(language, cls, getInstanceShape.execute(cls)); self.setKeyFunc(PGuards.isNone(key) ? null : key); self.setIt(getIter.execute(frame, inliningTarget, iterable)); return self; @@ -452,7 +418,7 @@ static PGrouper construct(Object cls, Object parent, Object tgtKey, @Cached InlinedConditionProfile wrongTypeProfile, @Cached InlinedConditionProfile isPGroupByProfile, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -460,7 +426,7 @@ static PGrouper construct(Object cls, Object parent, Object tgtKey, if (!isPGroupByProfile.profile(inliningTarget, parent instanceof PGroupBy)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INCORRECT_USAGE_OF_INTERNAL_GROUPER); } - return factory.createGrouper((PGroupBy) parent, tgtKey); + return PFactory.createGrouper(language, (PGroupBy) parent, tgtKey); } } @@ -475,7 +441,8 @@ static PTakewhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -488,7 +455,7 @@ static PTakewhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw } Object predicate = args[0]; Object iterable = args[1]; - PTakewhile self = factory.createTakewhile(cls); + PTakewhile self = PFactory.createTakewhile(language, cls, getInstanceShape.execute(cls)); self.setPredicate(predicate); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); return self; @@ -514,8 +481,8 @@ static Object negativeN(Object iterable, int n, @SuppressWarnings("unused") @Specialization(guards = "n == 0") static Object zeroN(Object iterable, int n, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, PythonUtils.EMPTY_OBJECT_ARRAY); } @Specialization(guards = "n > 0") @@ -526,14 +493,14 @@ static Object tee(VirtualFrame frame, Object iterable, int n, @Cached PyCallableCheckNode callableCheckNode, @Cached CallVarargsMethodNode callNode, @Cached InlinedBranchProfile notCallableProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object it = iterNode.execute(frame, iterable, PNone.NO_VALUE); Object copyCallable = getAttrNode.execute(frame, inliningTarget, it, T___COPY__); if (!callableCheckNode.execute(inliningTarget, copyCallable)) { notCallableProfile.enter(inliningTarget); // as in Tee.__NEW__() - PTeeDataObject dataObj = factory.createTeeDataObject(it); - it = factory.createTee(dataObj, 0); + PTeeDataObject dataObj = PFactory.createTeeDataObject(language, it); + it = PFactory.createTee(language, dataObj, 0); } // return tuple([it] + [it.__copy__() for i in range(1, n)]) @@ -544,7 +511,7 @@ static Object tee(VirtualFrame frame, Object iterable, int n, for (int i = 1; i < n; i++) { tupleObjs[i] = callNode.execute(frame, copyCallable, PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS); } - return factory.createTuple(tupleObjs); + return PFactory.createTuple(language, tupleObjs); } } @@ -558,12 +525,12 @@ PTeeDataObject construct(Object cls, Object[] arguments, PKeyword[] keywords, @Bind("this") Node inliningTarget, @Cached IsTypeNode isTypeNode, @Cached InlinedBranchProfile errorProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (!isTypeNode.execute(inliningTarget, cls)) { errorProfile.enter(inliningTarget); throw raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } - return factory.createTeeDataObject(); + return PFactory.createTeeDataObject(language); } } @@ -591,7 +558,8 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, Object @Cached InlinedLoopConditionProfile indicesLoopProfile, @Cached InlinedLoopConditionProfile cyclesLoopProfile, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -612,7 +580,7 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, Object throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); } } - PPermutations self = factory.createPermutations(cls); + PPermutations self = PFactory.createPermutations(language, cls, getInstanceShape.execute(cls)); self.setPool(pool); self.setR(r); int n = pool.length; @@ -664,8 +632,9 @@ static Object constructNoneRepeat(VirtualFrame frame, Object cls, Object[] itera @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached ToArrayNode toArrayNode, @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PProduct self = factory.createProduct(cls); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PProduct self = PFactory.createProduct(language, cls, getInstanceShape.execute(cls)); constructOneRepeat(frame, self, iterables, toArrayNode); return self; } @@ -675,8 +644,9 @@ static Object constructOneRepeat(VirtualFrame frame, Object cls, Object[] iterab @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached ToArrayNode toArrayNode, @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PProduct self = factory.createProduct(cls); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PProduct self = PFactory.createProduct(language, cls, getInstanceShape.execute(cls)); constructOneRepeat(frame, self, iterables, toArrayNode); return self; } @@ -687,7 +657,8 @@ static Object construct(VirtualFrame frame, Object cls, Object[] iterables, int @Shared @Cached ToArrayNode toArrayNode, @Cached InlinedLoopConditionProfile loopProfile, @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { Object[][] lists = unpackIterables(frame, iterables, toArrayNode); Object[][] gears = new Object[lists.length * repeat][]; loopProfile.profileCounted(inliningTarget, repeat); @@ -695,7 +666,7 @@ static Object construct(VirtualFrame frame, Object cls, Object[] iterables, int for (int i = 0; loopProfile.inject(inliningTarget, i < repeat); i++) { PythonUtils.arraycopy(lists, 0, gears, i * lists.length, lists.length); } - PProduct self = factory.createProduct(cls); + PProduct self = PFactory.createProduct(language, cls, getInstanceShape.execute(cls)); construct(self, gears); return self; } @@ -704,8 +675,9 @@ static Object construct(VirtualFrame frame, Object cls, Object[] iterables, int static Object constructNoRepeat(Object cls, @SuppressWarnings("unused") Object[] iterables, @SuppressWarnings("unused") int repeat, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PProduct self = factory.createProduct(cls); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PProduct self = PFactory.createProduct(language, cls, getInstanceShape.execute(cls)); self.setGears(new Object[0][]); self.setIndices(new int[0]); self.setLst(null); @@ -763,78 +735,25 @@ static Object construct(Object cls, Object iterables, Object repeat, @Builtin(name = "repeat", minNumOfPositionalArgs = 2, parameterNames = {"$self", "object", "times"}, constructsClass = PythonBuiltinClassType.PRepeat, doc = "repeat(object [,times]) -> create an iterator which returns the object\n" + "for the specified number of times. If not specified, returns the object\nendlessly.") - @ArgumentClinic(name = "times", defaultValue = "PNone.NONE", useDefaultForNone = true) @GenerateNodeFactory - public abstract static class RepeatNode extends PythonTernaryClinicBuiltinNode { + public abstract static class RepeatNode extends PythonTernaryBuiltinNode { - @Override - protected ArgumentClinicProvider getArgumentClinic() { - return ItertoolsModuleBuiltinsClinicProviders.RepeatNodeClinicProviderGen.INSTANCE; - } - - @Specialization(guards = "isTypeNode.execute(inliningTarget, cls)") - static Object constructNone(Object cls, Object object, @SuppressWarnings("unused") PNone times, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PRepeat self = factory.createRepeat(cls); - self.setElement(object); - self.setCnt(-1); - return self; - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "times < 0"}) - static Object constructNeg(Object cls, Object object, @SuppressWarnings("unused") int times, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PRepeat self = factory.createRepeat(cls); - self.setElement(object); - self.setCnt(0); - return self; - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "times >= 0"}) - static Object construct(Object cls, Object object, int times, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PRepeat self = factory.createRepeat(cls); - self.setElement(object); - self.setCnt(times); - return self; - } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "times >= 0"}, limit = "1") - static Object construct(VirtualFrame frame, Object cls, Object object, long times, + @Specialization + static Object construct(VirtualFrame frame, Object cls, Object object, Object timesObj, @Bind("this") Node inliningTarget, - @Cached PyLongAsIntNode asIntNode, - @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PythonObjectFactory factory) { - PRepeat self = factory.createRepeat(cls); + @Bind PythonLanguage language, + @Cached PyNumberAsSizeNode asSizeNode, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PRepeat self = PFactory.createRepeat(language, cls, getInstanceShape.execute(cls)); self.setElement(object); - self.setCnt(asIntNode.execute(frame, inliningTarget, times)); + if (timesObj != PNone.NONE) { + int times = asSizeNode.executeExact(frame, inliningTarget, timesObj); + self.setCnt(times > 0 ? times : 0); + } else { + self.setCnt(-1); + } return self; } - - @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "!isNone(times)", "!isInt(times)", "!isLong(times)"}) - @SuppressWarnings("unused") - static Object construct(Object cls, Object object, Object times, - @Bind("this") Node inliningTarget, - @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, S_EXPECTED_GOT_P, "integer", times); - } - - @Specialization(guards = "!isTypeNode.execute(inliningTarget, cls)") - @SuppressWarnings("unused") - static Object notype(Object cls, Object object, Object times, - @Bind("this") Node inliningTarget, - @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); - } - } @Builtin(name = "chain", minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, constructsClass = PythonBuiltinClassType.PChain, doc = "Return a chain object whose .__next__() method returns elements from the\n" + @@ -848,7 +767,8 @@ static PChain construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -856,8 +776,8 @@ static PChain construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "chain()"); } - PChain self = factory.createChain(cls); - self.setSource(getIter.execute(frame, inliningTarget, factory.createList(args))); + PChain self = PFactory.createChain(language, cls, getInstanceShape.execute(cls)); + self.setSource(getIter.execute(frame, inliningTarget, PFactory.createList(language, args))); self.setActive(PNone.NONE); return self; } @@ -879,7 +799,8 @@ static Object construct(Object cls, Object start, Object step, @Bind("this") Node inliningTarget, @Cached PyNumberCheckNode checkNode, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -890,7 +811,7 @@ static Object construct(Object cls, Object start, Object step, if (!checkNode.execute(inliningTarget, step)) { throw raiseNode.get(inliningTarget).raise(TypeError, NUMBER_IS_REQUIRED); } - PCount self = factory.createCount(cls); + PCount self = PFactory.createCount(language, cls, getInstanceShape.execute(cls)); self.setCnt(start); self.setStep(step); return self; @@ -908,7 +829,8 @@ static PStarmap construct(VirtualFrame frame, Object cls, Object[] args, PKeywor @Cached(inline = false /* uncommon path */) TypeNodes.HasObjectInitNode hasObjectInitNode, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); @@ -921,7 +843,7 @@ static PStarmap construct(VirtualFrame frame, Object cls, Object[] args, PKeywor } Object fun = args[0]; Object iterable = args[1]; - PStarmap self = factory.createStarmap(cls); + PStarmap self = PFactory.createStarmap(language, cls, getInstanceShape.execute(cls)); self.setFun(fun); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); return self; @@ -952,7 +874,8 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo @Cached InlinedBranchProfile wrongTypeBranch, @Cached InlinedBranchProfile wrongArgsBranch, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { wrongTypeBranch.enter(inliningTarget); @@ -1022,7 +945,7 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo } } Object iterable = args[0]; - PIslice self = factory.createIslice(cls); + PIslice self = PFactory.createIslice(language, cls, getInstanceShape.execute(cls)); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); self.setNext(start); self.setStop(stop); @@ -1050,7 +973,8 @@ static Object construct(VirtualFrame frame, Object cls, Object[] args, Object fi @Cached InlinedLoopConditionProfile loopProfile, @Cached IsTypeNode isTypeNode, @Cached InlinedBranchProfile errorProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { // Note: @Fallback or other @Specialization generate data-class @@ -1063,7 +987,7 @@ static Object construct(VirtualFrame frame, Object cls, Object[] args, Object fi fillValue = null; } - PZipLongest self = factory.createZipLongest(cls); + PZipLongest self = PFactory.createZipLongest(language, cls, getInstanceShape.execute(cls)); self.setFillValue(fillValue); self.setNumActive(args.length); @@ -1087,17 +1011,17 @@ static PPairwise construct(VirtualFrame frame, Object cls, Object iterable, @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, @Cached IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { // Note: @Fallback or other @Specialization generate data-class throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } - PPairwise self = factory.createPairwise(cls); + PPairwise self = PFactory.createPairwise(language, cls, getInstanceShape.execute(cls)); self.setIterable(getIter.execute(frame, inliningTarget, iterable)); return self; } } - } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java index 4bef0e0f31..67fce07408 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; import java.util.Locale; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -72,7 +73,7 @@ import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.locale.LocaleUtils; import com.oracle.graal.python.runtime.locale.PythonLocale; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -117,7 +118,7 @@ public abstract static class LocaleConvNode extends PythonBuiltinNode { @TruffleBoundary static PDict localeconv() { PythonContext ctx = PythonContext.get(null); - PythonObjectFactory factory = ctx.factory(); + PythonLanguage language = ctx.getLanguage(); LinkedHashMap dict = new LinkedHashMap<>(20); final PythonLocale currentPythonLocale = ctx.getCurrentLocale(); @@ -128,7 +129,7 @@ static PDict localeconv() { dict.put("decimal_point", TruffleString.fromCodePointUncached(decimalFormatSymbols.getDecimalSeparator(), TS_ENCODING)); dict.put("thousands_sep", TruffleString.fromCodePointUncached(decimalFormatSymbols.getGroupingSeparator(), TS_ENCODING)); - dict.put("grouping", getDecimalFormatGrouping(factory, numericLocaleNumFormat)); + dict.put("grouping", getDecimalFormatGrouping(language, numericLocaleNumFormat)); // LC_MONETARY Locale monetaryLocale = currentPythonLocale.category(LC_MONETARY); @@ -140,7 +141,7 @@ static PDict localeconv() { dict.put("currency_symbol", toTruffleStringUncached(decimalFormatSymbols.getCurrencySymbol())); dict.put("mon_decimal_point", TruffleString.fromCodePointUncached(decimalFormatSymbols.getMonetaryDecimalSeparator(), TS_ENCODING)); dict.put("mon_thousands_sep", TruffleString.fromCodePointUncached(decimalFormatSymbols.getGroupingSeparator(), TS_ENCODING)); - dict.put("mon_grouping", getDecimalFormatGrouping(factory, monetaryNumFormat)); + dict.put("mon_grouping", getDecimalFormatGrouping(language, monetaryNumFormat)); // TODO: reasonable default, but not the current locale setting dict.put("positive_sign", ""); dict.put("negative_sign", TruffleString.fromCodePointUncached(decimalFormatSymbols.getMinusSign(), TS_ENCODING)); @@ -153,21 +154,21 @@ static PDict localeconv() { dict.put("p_sign_posn", PNone.NONE); dict.put("n_sign_posn", PNone.NONE); - return factory.createDictFromMap(dict); + return PFactory.createDictFromMap(language, dict); } private static DecimalFormatSymbols getDecimalFormatSymbols(Locale locale, NumberFormat numberFormat) { return numberFormat instanceof DecimalFormat decimalFormat ? decimalFormat.getDecimalFormatSymbols() : new DecimalFormatSymbols(locale); } - private static PList getDecimalFormatGrouping(PythonObjectFactory factory, NumberFormat numberFormat) { + private static PList getDecimalFormatGrouping(PythonLanguage language, NumberFormat numberFormat) { if (numberFormat instanceof DecimalFormat decimalFormat) { // TODO: this does not support groupings with variable size groups like in India // Possible approach: decimalFormat.toPattern() gives a generic pattern (e.g., // #,#00.0#) that would have to be parsed to extract the group sizes from it - return factory.createList(new Object[]{decimalFormat.getGroupingSize(), 0}); + return PFactory.createList(language, new Object[]{decimalFormat.getGroupingSize(), 0}); } else { - return factory.createList(); + return PFactory.createList(language); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java index 0c91bb9359..a8c503b1da 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; import java.util.Map; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -57,24 +58,21 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.StructSequence; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.InstrumentInfo; import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.instrumentation.SourceSectionFilter; -import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.tools.profiler.CPUSampler; import com.oracle.truffle.tools.profiler.CPUSampler.Payload; @@ -138,14 +136,14 @@ abstract static class LsprofNew extends PythonBuiltinNode { @Specialization @TruffleBoundary Profiler doit(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs) { - Env env = getContext().getEnv(); + PythonContext context = getContext(); + Env env = context.getEnv(); Map instruments = env.getInstruments(); InstrumentInfo instrumentInfo = instruments.get(CPUSamplerInstrument.ID); if (instrumentInfo != null) { CPUSampler sampler = env.lookup(instrumentInfo, CPUSampler.class); if (sampler != null) { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - return factory.trace(new Profiler(cls, factory.getShape(cls), sampler)); + return PFactory.createProfiler(context.getLanguage(), cls, TypeNodes.GetInstanceShape.executeUncached(cls), sampler); } } throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.NotImplementedError, ErrorMessages.COVERAGE_TRACKER_NOT_AVAILABLE); @@ -153,22 +151,6 @@ Profiler doit(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWa } } -class Profiler extends PythonBuiltinObject { - boolean subcalls; - boolean builtins; - double timeunit; - Object externalTimer; - double time; - final CPUSampler sampler; - - public Profiler(Object cls, Shape instanceShape, CPUSampler sampler) { - super(cls, instanceShape); - this.sampler = sampler; - this.sampler.setFilter(SourceSectionFilter.newBuilder().includeInternal(true).build()); - this.sampler.setPeriod(1); - } -} - @CoreFunctions(extendClasses = PythonBuiltinClassType.LsprofProfiler) class ProfilerBuiltins extends PythonBuiltins { @Override @@ -291,23 +273,23 @@ static PList doit(Profiler self) { } self.sampler.close(); - return PythonObjectFactory.getUncached().createList(entries.toArray()); + return PFactory.createList(PythonLanguage.get(null), entries.toArray()); } private static void countNode(List entries, ProfilerNode node, double avgSampleTime) { - PythonObjectSlowPathFactory factory = PythonContext.get(null).factory(); + PythonLanguage language = PythonLanguage.get(null); Collection> children = node.getChildren(); Object[] profilerEntry = getProfilerEntry(node, avgSampleTime); Object[] calls = new Object[children.size()]; int callIdx = 0; for (ProfilerNode childNode : children) { countNode(entries, childNode, avgSampleTime); - calls[callIdx++] = factory.createStructSeq(LsprofModuleBuiltins.PROFILER_SUBENTRY_DESC, getProfilerEntry(childNode, avgSampleTime)); + calls[callIdx++] = PFactory.createStructSeq(language, LsprofModuleBuiltins.PROFILER_SUBENTRY_DESC, getProfilerEntry(childNode, avgSampleTime)); } assert callIdx == calls.length; profilerEntry = Arrays.copyOf(profilerEntry, 6); - profilerEntry[profilerEntry.length - 1] = factory.createList(calls); - entries.add(factory.createStructSeq(LsprofModuleBuiltins.PROFILER_ENTRY_DESC, profilerEntry)); + profilerEntry[profilerEntry.length - 1] = PFactory.createList(language, calls); + entries.add(PFactory.createStructSeq(language, LsprofModuleBuiltins.PROFILER_ENTRY_DESC, profilerEntry)); } private static Object[] getProfilerEntry(ProfilerNode node, double avgSampleTime) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java index e576c697c7..962926ddc9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -64,6 +64,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; import com.oracle.graal.python.builtins.objects.mmap.PMMap; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode; @@ -75,7 +76,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -167,7 +168,7 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int @Cached SysModuleBuiltins.AuditNode auditNode, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupport, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (lengthIn < 0) { throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MEM_MAPPED_LENGTH_MUST_BE_POSITIVE); @@ -252,7 +253,8 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } - return factory.createMMap(PythonContext.get(inliningTarget), clazz, mmapHandle, dupFd, length, access); + PythonContext context = PythonContext.get(inliningTarget); + return PFactory.createMMap(context.getLanguage(inliningTarget), context, clazz, getInstanceShape.execute(clazz), mmapHandle, dupFd, length, access); } @Specialization(guards = "isIllegal(fd)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java index 32ddad0ee3..dbe0c43be8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -44,6 +44,7 @@ import java.util.HashMap; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -105,7 +106,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; @@ -158,19 +159,21 @@ protected static LookupAndCallBinaryNode createCallWriteNode() { @Specialization static Object doit(VirtualFrame frame, Object value, Object file, int version, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached("createCallWriteNode()") LookupAndCallBinaryNode callNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - Object savedState = IndirectCallContext.enter(frame, indirectCallData); + PythonLanguage language = context.getLanguage(inliningTarget); + PythonContext.PythonThreadState threadState = context.getThreadState(language); + Object savedState = IndirectCallContext.enter(frame, threadState, indirectCallData); try { - return callNode.executeObject(frame, file, factory.createBytes(Marshal.dump(value, version, PythonContext.get(inliningTarget)))); + return callNode.executeObject(frame, file, PFactory.createBytes(language, Marshal.dump(context, value, version))); } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); } finally { - IndirectCallContext.exit(frame, indirectCallData, savedState); + IndirectCallContext.exit(frame, threadState, savedState); } } } @@ -187,18 +190,20 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object doit(VirtualFrame frame, Object value, int version, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - Object savedState = IndirectCallContext.enter(frame, indirectCallData); + PythonLanguage language = context.getLanguage(inliningTarget); + PythonContext.PythonThreadState threadState = context.getThreadState(language); + Object savedState = IndirectCallContext.enter(frame, threadState, indirectCallData); try { - return factory.createBytes(Marshal.dump(value, version, PythonContext.get(inliningTarget))); + return PFactory.createBytes(language, Marshal.dump(context, value, version)); } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); } finally { - IndirectCallContext.exit(frame, indirectCallData, savedState); + IndirectCallContext.exit(frame, threadState, savedState); } } } @@ -214,6 +219,7 @@ protected static LookupAndCallBinaryNode createCallReadNode() { @Specialization static Object doit(VirtualFrame frame, Object file, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createCallReadNode()") LookupAndCallBinaryNode callNode, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferLib, @Cached PRaiseNode.Lazy raiseNode) { @@ -222,7 +228,7 @@ static Object doit(VirtualFrame frame, Object file, throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.READ_RETURNED_NOT_BYTES, buffer); } try { - return Marshal.loadFile(file); + return Marshal.loadFile(context, file); } catch (NumberFormatException e) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } catch (Marshal.MarshalError me) { @@ -239,11 +245,12 @@ abstract static class LoadsNode extends PythonUnaryClinicBuiltinNode { @Specialization static Object doit(VirtualFrame frame, Object buffer, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached PRaiseNode.Lazy raiseNode) { try { - return Marshal.load(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer)); + return Marshal.load(context, bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer)); } catch (NumberFormatException e) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } catch (Marshal.MarshalError me) { @@ -346,15 +353,15 @@ public final Throwable fillInStackTrace() { } @TruffleBoundary - static byte[] dump(Object value, int version, Python3Core core) throws IOException, MarshalError { - Marshal outMarshal = new Marshal(version, core.getTrue(), core.getFalse()); + static byte[] dump(PythonContext context, Object value, int version) throws IOException, MarshalError { + Marshal outMarshal = new Marshal(context, version, context.getTrue(), context.getFalse()); outMarshal.writeObject(value); return outMarshal.out.toByteArray(); } @TruffleBoundary - static Object load(byte[] ary, int length) throws NumberFormatException, MarshalError { - Marshal inMarshal = new Marshal(ary, length); + static Object load(PythonContext context, byte[] ary, int length) throws NumberFormatException, MarshalError { + Marshal inMarshal = new Marshal(context, ary, length); Object result = inMarshal.readObject(); if (result == null) { throw new MarshalError(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_MARSHAL_DATA_NULL); @@ -363,8 +370,8 @@ static Object load(byte[] ary, int length) throws NumberFormatException, Marshal } @TruffleBoundary - static Object loadFile(Object file) throws NumberFormatException, MarshalError { - Marshal inMarshal = new Marshal(file); + static Object loadFile(PythonContext context, Object file) throws NumberFormatException, MarshalError { + Marshal inMarshal = new Marshal(context, file); Object result = inMarshal.readObject(); if (result == null) { throw new MarshalError(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_MARSHAL_DATA_NULL); @@ -387,7 +394,7 @@ static final class FileLikeInputStream extends InputStream { this.fileLike = fileLike; this.asSize = PyNumberAsSizeNode.getUncached(); this.singleByteStore = new ByteSequenceStorage(new byte[1]); - this.buffer = PythonObjectFactory.getUncached().createByteArray(singleByteStore); + this.buffer = PFactory.createByteArray(PythonLanguage.get(null), singleByteStore); } @Override @@ -418,7 +425,7 @@ public int read(byte[] b, int off, int len) { } } - private static final PythonObjectFactory factory = PythonObjectFactory.getUncached(); + private final PythonContext context; final HashMap refMap; final ArrayList refList; final ByteArrayOutputStream out; @@ -431,7 +438,8 @@ public int read(byte[] b, int off, int len) { byte[] buffer = new byte[Long.BYTES]; int depth = 0; - Marshal(int version, PInt pyTrue, PInt pyFalse) { + Marshal(PythonContext context, int version, PInt pyTrue, PInt pyFalse) { + this.context = context; this.version = version; this.pyTrue = pyTrue; this.pyFalse = pyFalse; @@ -441,7 +449,8 @@ public int read(byte[] b, int off, int len) { this.refList = null; } - Marshal(byte[] in, int length) { + Marshal(PythonContext context, byte[] in, int length) { + this.context = context; this.in = new ByteArrayInputStream(in, 0, length); this.refList = new ArrayList<>(); this.version = -1; @@ -451,7 +460,8 @@ public int read(byte[] b, int off, int len) { this.refMap = null; } - Marshal(Object in) { + Marshal(PythonContext context, Object in) { + this.context = context; this.in = new FileLikeInputStream(in); this.refList = new ArrayList<>(); this.version = -1; @@ -461,6 +471,10 @@ public int read(byte[] b, int off, int len) { this.refMap = null; } + private PythonLanguage getLanguage() { + return context.getLanguage(); + } + private void writeByte(int v) { out.write(v); } @@ -979,17 +993,17 @@ private Object readObject(int type, AddRefAndReturn addRef) throws NumberFormatE case TYPE_BIG_INTEGER: return readBigInteger(); case TYPE_LONG: - return addRef.run(factory.createInt(readBigInteger())); + return addRef.run(PFactory.createInt(getLanguage(), readBigInteger())); case TYPE_FLOAT: return addRef.run(readDoubleString()); case TYPE_BINARY_FLOAT: return addRef.run(readDouble()); case TYPE_COMPLEX: - return addRef.run(factory.createComplex(readDoubleString(), readDoubleString())); + return addRef.run(PFactory.createComplex(getLanguage(), readDoubleString(), readDoubleString())); case TYPE_BINARY_COMPLEX: - return addRef.run(factory.createComplex(readDouble(), readDouble())); + return addRef.run(PFactory.createComplex(getLanguage(), readDouble(), readDouble())); case TYPE_STRING: - return addRef.run(factory.createBytes(readBytes())); + return addRef.run(PFactory.createBytes(getLanguage(), readBytes())); case TYPE_ASCII_INTERNED: return addRef.run(readAscii(readSize(), true)); case TYPE_ASCII: @@ -1005,24 +1019,24 @@ private Object readObject(int type, AddRefAndReturn addRef) throws NumberFormatE case TYPE_SMALL_TUPLE: int smallTupleSize = readByteSize(); Object[] smallTupleItems = new Object[smallTupleSize]; - Object smallTuple = addRef.run(factory.createTuple(smallTupleItems)); + Object smallTuple = addRef.run(PFactory.createTuple(getLanguage(), smallTupleItems)); readArray(smallTupleItems); return smallTuple; case TYPE_TUPLE: int tupleSize = readSize(); Object[] tupleItems = new Object[tupleSize]; - Object tuple = addRef.run(factory.createTuple(tupleItems)); + Object tuple = addRef.run(PFactory.createTuple(getLanguage(), tupleItems)); readArray(tupleItems); return tuple; case TYPE_LIST: int listSize = readSize(); Object[] listItems = new Object[listSize]; - Object list = addRef.run(factory.createList(listItems)); + Object list = addRef.run(PFactory.createList(getLanguage(), listItems)); readArray(listItems); return list; case TYPE_DICT: HashingStorage store = PDict.createNewStorage(0); - PDict dict = factory.createDict(store); + PDict dict = PFactory.createDict(getLanguage(), store); addRef.run(dict); while (true) { Object key = readObject(); @@ -1042,9 +1056,9 @@ private Object readObject(int type, AddRefAndReturn addRef) throws NumberFormatE HashingStorage setStore = EconomicMapStorage.create(setSz); PBaseSet set; if (type == TYPE_FROZENSET) { - set = factory.createFrozenSet(setStore); + set = PFactory.createFrozenSet(getLanguage(), setStore); } else { - set = factory.createSet(setStore); + set = PFactory.createSet(getLanguage(), setStore); } addRef.run(set); for (int i = 0; i < setSz; i++) { @@ -1326,7 +1340,6 @@ private PCode readCode() { // get a new ID every time we deserialize the same filename in the same context. We use // slow-path context lookup, since this code is likely dominated by the deserialization // time - PythonContext context = PythonContext.get(null); ByteBuffer.wrap(codeString).putLong(codeLen, context.getDeserializationId(fileName)); int firstLineNo = readInt(); byte[] lnoTab = readBytes(); @@ -1335,9 +1348,9 @@ private PCode readCode() { } @TruffleBoundary - public static byte[] serializeCodeUnit(CodeUnit code) { + public static byte[] serializeCodeUnit(PythonContext context, CodeUnit code) { try { - Marshal marshal = new Marshal(CURRENT_VERSION, null, null); + Marshal marshal = new Marshal(context, CURRENT_VERSION, null, null); marshal.writeCodeUnit(code); return marshal.out.toByteArray(); } catch (IOException e) { @@ -1348,9 +1361,9 @@ public static byte[] serializeCodeUnit(CodeUnit code) { } @TruffleBoundary - public static CodeUnit deserializeCodeUnit(byte[] bytes) { + public static CodeUnit deserializeCodeUnit(PythonContext context, byte[] bytes) { try { - Marshal marshal = new Marshal(bytes, bytes.length); + Marshal marshal = new Marshal(context, bytes, bytes.length); return marshal.readCodeUnit(); } catch (Marshal.MarshalError me) { throw PRaiseNode.getUncached().raise(me.type, me.message, me.arguments); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java index 9266b8f0cd..4e98b5bb38 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -82,7 +83,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.nodes.util.NarrowBigIntegerNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -362,8 +363,8 @@ static long factorialSmallInt(int value) { @Specialization(guards = {"value >= SMALL_FACTORIALS.length"}) static PInt factorialInt(int value, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(factorialPart(1, value)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, factorialPart(1, value)); } @Specialization(guards = {"value < 0"}) @@ -379,8 +380,8 @@ static long factorialSmallLong(long value) { @Specialization(guards = {"value >= SMALL_FACTORIALS.length"}) static PInt factorialLong(long value, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(factorialPart(1, value)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, factorialPart(1, value)); } @Fallback @@ -439,26 +440,26 @@ private BigInteger calculateComb(BigInteger n, BigInteger k) { @Specialization PInt comb(long n, long k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculateComb(PInt.longToBigInteger(n), PInt.longToBigInteger(k))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculateComb(PInt.longToBigInteger(n), PInt.longToBigInteger(k))); } @Specialization PInt comb(long n, PInt k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculateComb(PInt.longToBigInteger(n), k.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculateComb(PInt.longToBigInteger(n), k.getValue())); } @Specialization PInt comb(PInt n, long k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculateComb(n.getValue(), PInt.longToBigInteger(k))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculateComb(n.getValue(), PInt.longToBigInteger(k))); } @Specialization PInt comb(PInt n, PInt k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculateComb(n.getValue(), k.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculateComb(n.getValue(), k.getValue())); } @Specialization @@ -510,26 +511,26 @@ private BigInteger calculatePerm(BigInteger n, BigInteger k) { @Specialization PInt perm(long n, long k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculatePerm(PInt.longToBigInteger(n), PInt.longToBigInteger(k))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculatePerm(PInt.longToBigInteger(n), PInt.longToBigInteger(k))); } @Specialization PInt perm(long n, PInt k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculatePerm(PInt.longToBigInteger(n), k.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculatePerm(PInt.longToBigInteger(n), k.getValue())); } @Specialization PInt perm(PInt n, long k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculatePerm(n.getValue(), PInt.longToBigInteger(k))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculatePerm(n.getValue(), PInt.longToBigInteger(k))); } @Specialization PInt perm(PInt n, PInt k, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(calculatePerm(n.getValue(), k.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, calculatePerm(n.getValue(), k.getValue())); } @Specialization @@ -701,12 +702,12 @@ public static double[] frexp(double value) { @Specialization static PTuple frexpD(double value, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] content = new Object[2]; double[] primContent = frexp(value); content[0] = primContent[0]; content[1] = (int) primContent[1]; - return factory.createTuple(content); + return PFactory.createTuple(language, content); } @Override @@ -839,17 +840,17 @@ protected ArgumentClinicProvider getArgumentClinic() { public abstract static class ModfNode extends PythonUnaryClinicBuiltinNode { @Specialization static PTuple modfD(double value, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (!Double.isFinite(value)) { if (Double.isInfinite(value)) { - return factory.createTuple(new Object[]{Math.copySign(0., value), value}); + return PFactory.createTuple(language, new Object[]{Math.copySign(0., value), value}); } else if (Double.isNaN(value)) { - return factory.createTuple(new Object[]{value, value}); + return PFactory.createTuple(language, new Object[]{value, value}); } } double fraction = value % 1; double integral = value - fraction; - return factory.createTuple(new Object[]{fraction, integral}); + return PFactory.createTuple(language, new Object[]{fraction, integral}); } @Override @@ -1058,14 +1059,14 @@ static long gcd(long x, long y) { @Specialization static PInt gcd(long x, PInt y, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createInt(op(PInt.longToBigInteger(x), y.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(PInt.longToBigInteger(x), y.getValue())); } @Specialization static PInt gcd(PInt x, long y, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createInt(op(x.getValue(), PInt.longToBigInteger(y))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(x.getValue(), PInt.longToBigInteger(y))); } @TruffleBoundary @@ -1075,8 +1076,8 @@ private static BigInteger op(BigInteger x, BigInteger y) { @Specialization PInt gcd(PInt x, PInt y, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createInt(op(x.getValue(), y.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(x.getValue(), y.getValue())); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/NtModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/NtModuleBuiltins.java index 2f003dff72..738f1bb76d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/NtModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/NtModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -65,7 +66,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.runtime.PosixSupportLibrary; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -123,12 +124,12 @@ abstract static class PathSplitRootNode extends PythonUnaryClinicBuiltinNode { Object splitroot(PosixPath path) { // TODO should call WINAPI PathCchSkipRoot - PythonObjectFactory factory = PythonObjectFactory.getUncached(); + PythonLanguage language = PythonLanguage.get(null); TruffleString pathString = PosixSupportLibrary.getUncached().getPathAsString(getPosixSupport(), path.value); int len = pathString.codePointLengthUncached(TS_ENCODING); int index = pathString.indexOfCodePointUncached(':', 0, len, TS_ENCODING); if (index <= 0) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, pathString}); + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, pathString}); } else { index++; int first = pathString.codePointAtIndexUncached(index, TS_ENCODING); @@ -137,7 +138,7 @@ Object splitroot(PosixPath path) { } TruffleString root = pathString.substringUncached(0, index, TS_ENCODING, false); TruffleString rest = pathString.substringUncached(index, len - index, TS_ENCODING, false); - return factory.createTuple(new Object[]{root, rest}); + return PFactory.createTuple(language, new Object[]{root, rest}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java index b414152f0d..2310c287c7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java @@ -119,7 +119,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ArrayBasedSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; @@ -632,15 +632,15 @@ public abstract static class GetRegisteredInteropBehaviorNode extends PythonUnar PList get(PythonAbstractObject klass, @Bind("this") Node inliningTarget, @Cached TypeNodes.IsTypeNode isTypeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode raiseNode, @Cached HiddenAttr.ReadNode readHiddenAttrNode) { if (isTypeNode.execute(inliningTarget, klass)) { Object value = readHiddenAttrNode.execute(inliningTarget, klass, HiddenAttr.HOST_INTEROP_BEHAVIOR, null); if (value instanceof InteropBehavior behavior) { - return factory.createList(behavior.getDefinedMethods()); + return PFactory.createList(language, behavior.getDefinedMethods()); } - return factory.createList(); + return PFactory.createList(language); } throw raiseNode.raise(ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a type", klass); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index 3b62e8c849..1855f6b7cc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -128,7 +128,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonExitException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; @@ -282,9 +282,10 @@ public void initialize(Python3Core core) { haveFunctions.add(tsLiteral("HAVE_FTRUNCATE")); haveFunctions.add(tsLiteral("MS_WINDOWS")); } - addBuiltinConstant("_have_functions", core.factory().createList(haveFunctions.toArray())); - addBuiltinConstant("environ", core.factory().createDict()); - addBuiltinConstant("sysconf_names", core.factory().createDict()); + PythonLanguage language = core.getLanguage(); + addBuiltinConstant("_have_functions", PFactory.createList(language, haveFunctions.toArray())); + addBuiltinConstant("environ", PFactory.createDict(language)); + addBuiltinConstant("sysconf_names", PFactory.createDict(language)); StructSequence.initType(core, STAT_RESULT_DESC); StructSequence.initType(core, STATVFS_RESULT_DESC); @@ -317,11 +318,12 @@ public void postInitialize(Python3Core core) { PosixSupportLibrary posixLib = PosixSupportLibrary.getUncached(); Object posixSupport = core.getContext().getPosixSupport(); + PythonLanguage language = core.getLanguage(); // fill the environ dictionary with the current environment // TODO we should probably use PosixSupportLibrary to get environ Map getenv = core.getContext().getEnv().getEnvironment(); - PDict environ = core.factory().createDict(); + PDict environ = PFactory.createDict(language); String pyenvLauncherKey = "__PYVENV_LAUNCHER__"; for (Entry entry : getenv.entrySet()) { if (entry.getKey().equals("GRAAL_PYTHON_ARGS") && entry.getValue().endsWith("\013")) { @@ -337,7 +339,7 @@ public void postInitialize(Python3Core core) { } key = toTruffleStringUncached(entry.getKey()); } else { - key = core.factory().createBytes(entry.getKey().getBytes()); + key = PFactory.createBytes(language, entry.getKey().getBytes()); } if (pyenvLauncherKey.equals(entry.getKey())) { // On Mac, the CPython launcher uses this env variable to specify the real Python @@ -353,13 +355,13 @@ public void postInitialize(Python3Core core) { if (PythonOS.getPythonOS() == PythonOS.PLATFORM_WIN32) { val = value; } else { - val = core.factory().createBytes(value.toJavaStringUncached().getBytes()); + val = PFactory.createBytes(language, value.toJavaStringUncached().getBytes()); } } else { if (PythonOS.getPythonOS() == PythonOS.PLATFORM_WIN32) { val = toTruffleStringUncached(entry.getValue()); } else { - val = core.factory().createBytes((entry.getValue().getBytes())); + val = PFactory.createBytes(language, (entry.getValue().getBytes())); } } environ.setItem(key, val); @@ -445,7 +447,8 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, PBytes valueBytes, @Bind("this") Node inliningTarget, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { // Unlike in other posix builtins, we go through str -> bytes -> byte[] -> String @@ -453,7 +456,7 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, PBytes valueBytes, // is subject to sys.audit. byte[] name = toBytesNode.execute(nameBytes); byte[] value = toBytesNode.execute(valueBytes); - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); Object nameOpaque = checkNull(inliningTarget, posixLib.createPathFromBytes(posixSupport, name), raiseNode); Object valueOpaque = checkNull(inliningTarget, posixLib.createPathFromBytes(posixSupport, value), raiseNode); checkEqualSign(inliningTarget, name, raiseNode); @@ -493,18 +496,19 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone putenv(VirtualFrame frame, PBytes nameBytes, + static PNone putenv(VirtualFrame frame, PBytes nameBytes, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { byte[] name = toBytesNode.execute(nameBytes); - Object nameOpaque = checkNull(inliningTarget, posixLib.createPathFromBytes(getPosixSupport(), name), raiseNode); + Object nameOpaque = checkNull(inliningTarget, posixLib.createPathFromBytes(context.getPosixSupport(), name), raiseNode); auditNode.audit(inliningTarget, "os.unsetenv", nameBytes); try { - posixLib.unsetenv(getPosixSupport(), nameOpaque); + posixLib.unsetenv(context.getPosixSupport(), nameOpaque); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -532,28 +536,30 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object execvArgsList(VirtualFrame frame, PosixPath path, PList argv, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached ToArrayNode toArrayNode, @Shared @Cached ObjectToOpaquePathNode toOpaquePathNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { - execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); + execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, context.getPosixSupport(), toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); throw CompilerDirectives.shouldNotReachHere("execv should not return normally"); } @Specialization static Object execvArgsTuple(VirtualFrame frame, PosixPath path, PTuple argv, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached ToArrayNode toArrayNode, @Shared @Cached ObjectToOpaquePathNode toOpaquePathNode, @Shared @Cached AuditNode auditNode, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { - execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); + execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, context.getPosixSupport(), toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); throw CompilerDirectives.shouldNotReachHere("execv should not return normally"); } @@ -567,6 +573,7 @@ static Object execvInvalidArgs(VirtualFrame frame, PosixPath path, Object argv, private static void execv(VirtualFrame frame, PosixPath path, Object argv, SequenceStorage argvStorage, Node inliningTarget, PosixSupportLibrary posixLib, + PosixSupport posixSupport, SequenceStorageNodes.ToArrayNode toArrayNode, ObjectToOpaquePathNode toOpaquePathNode, SysModuleBuiltins.AuditNode auditNode, @@ -587,7 +594,7 @@ private static void execv(VirtualFrame frame, PosixPath path, Object argv, Seque gil.release(true); try { - posixLib.execv(PosixSupport.get(inliningTarget), path.value, opaqueArgs); + posixLib.execv(posixSupport, path.value, opaqueArgs); } catch (PosixException e) { gil.acquire(); throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -602,8 +609,9 @@ private static void execv(VirtualFrame frame, PosixPath path, Object argv, Seque @GenerateNodeFactory public abstract static class GetPidNode extends PythonBuiltinNode { @Specialization - long getPid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.getpid(getPosixSupport()); + static long getPid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getpid(context.getPosixSupport()); } } @@ -611,8 +619,9 @@ long getPid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { @GenerateNodeFactory public abstract static class GetUidNode extends PythonBuiltinNode { @Specialization - long getUid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.getuid(getPosixSupport()); + static long getUid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getuid(context.getPosixSupport()); } } @@ -620,8 +629,9 @@ long getUid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { @GenerateNodeFactory public abstract static class GetEUidNode extends PythonBuiltinNode { @Specialization - long getUid(@CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib) { - return posixLib.geteuid(getPosixSupport()); + static long getUid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.geteuid(context.getPosixSupport()); } } @@ -629,8 +639,9 @@ long getUid(@CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib) { @GenerateNodeFactory public abstract static class GetGidNode extends PythonBuiltinNode { @Specialization - long getGid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.getgid(getPosixSupport()); + static long getGid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getgid(context.getPosixSupport()); } } @@ -638,8 +649,9 @@ long getGid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { @GenerateNodeFactory public abstract static class GetEGidNode extends PythonBuiltinNode { @Specialization - long getGid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.getegid(getPosixSupport()); + static long getGid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getegid(context.getPosixSupport()); } } @@ -647,8 +659,9 @@ long getGid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { @GenerateNodeFactory public abstract static class GetPpidNode extends PythonBuiltinNode { @Specialization - long getPpid(@CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.getppid(getPosixSupport()); + static long getPpid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getppid(context.getPosixSupport()); } } @@ -665,8 +678,8 @@ public abstract static class GetLoadAvgNode extends PythonBuiltinNode { */ @TruffleBoundary @Specialization - PTuple getloadavg(@Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory) { + static PTuple getloadavg(@Bind("this") Node inliningTarget, + @Bind PythonLanguage language) { double load = -1.0; // (mq) without native call we can only obtain system load average for the last minute. if (ManagementFactory.getOperatingSystemMXBean() != null) { @@ -675,7 +688,7 @@ PTuple getloadavg(@Bind("this") Node inliningTarget, if (load < 0) { PRaiseNode.raiseUncached(inliningTarget, OSError); } - return factory.createTuple(new Object[]{load, load, load}); + return PFactory.createTuple(language, new Object[]{load, load, load}); } } @@ -689,12 +702,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - long getPgid(VirtualFrame frame, long pid, + static long getPgid(VirtualFrame frame, long pid, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.getpgid(getPosixSupport(), pid); + return posixLib.getpgid(context.getPosixSupport(), pid); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -712,12 +726,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - Object setPgid(VirtualFrame frame, long pid, long pgid, + static Object setPgid(VirtualFrame frame, long pid, long pgid, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.setpgid(getPosixSupport(), pid, pgid); + posixLib.setpgid(context.getPosixSupport(), pid, pgid); return PNone.NONE; } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -729,12 +744,13 @@ Object setPgid(VirtualFrame frame, long pid, long pgid, @GenerateNodeFactory public abstract static class SetPgrpdNode extends PythonBuiltinNode { @Specialization - Object getPpid(VirtualFrame frame, + static Object getPpid(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.setpgid(getPosixSupport(), 0, 0); + posixLib.setpgid(context.getPosixSupport(), 0, 0); return PNone.NONE; } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -746,8 +762,9 @@ Object getPpid(VirtualFrame frame, @GenerateNodeFactory public abstract static class GetPgrpNode extends PythonBuiltinNode { @Specialization - long getPpid(@CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib) { - return posixLib.getpgrp(getPosixSupport()); + static long getPpid(@Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.getpgrp(context.getPosixSupport()); } } @@ -761,12 +778,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - long getSid(VirtualFrame frame, long pid, + static long getSid(VirtualFrame frame, long pid, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.getsid(getPosixSupport(), pid); + return posixLib.getsid(context.getPosixSupport(), pid); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -778,12 +796,13 @@ long getSid(VirtualFrame frame, long pid, public abstract static class SetSidNode extends PythonBuiltinNode { @Specialization - Object setsid(VirtualFrame frame, + static Object setsid(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.setsid(getPosixSupport()); + posixLib.setsid(context.getPosixSupport()); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -795,14 +814,14 @@ Object setsid(VirtualFrame frame, @GenerateNodeFactory abstract static class GetGroupsNode extends PythonBuiltinNode { @Specialization - Object getgroups(VirtualFrame frame, + static Object getgroups(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - long[] groups = posixLib.getgroups(getPosixSupport()); - return factory.createList(new LongSequenceStorage(groups)); + long[] groups = posixLib.getgroups(context.getPosixSupport()); + return PFactory.createList(context.getLanguage(inliningTarget), new LongSequenceStorage(groups)); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -814,16 +833,16 @@ Object getgroups(VirtualFrame frame, public abstract static class OpenPtyNode extends PythonBuiltinNode { @Specialization - Object openpty(VirtualFrame frame, + static Object openpty(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - OpenPtyResult result = posixLib.openpty(getPosixSupport()); - posixLib.setInheritable(getPosixSupport(), result.masterFd(), false); - posixLib.setInheritable(getPosixSupport(), result.slaveFd(), false); - return factory.createTuple(new int[]{result.masterFd(), result.slaveFd()}); + OpenPtyResult result = posixLib.openpty(context.getPosixSupport()); + posixLib.setInheritable(context.getPosixSupport(), result.masterFd(), false); + posixLib.setInheritable(context.getPosixSupport(), result.slaveFd(), false); + return PFactory.createTuple(context.getLanguage(inliningTarget), new int[]{result.masterFd(), result.slaveFd()}); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -844,9 +863,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int open(VirtualFrame frame, PosixPath path, int flags, int mode, int dirFd, + static int open(VirtualFrame frame, PosixPath path, int flags, int mode, int dirFd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached InlinedBranchProfile errorProfile, @Cached GilNode gil, @@ -860,11 +880,11 @@ int open(VirtualFrame frame, PosixPath path, int flags, int mode, int dirFd, try { while (true) { try { - return posixLib.openat(getPosixSupport(), dirFd, path.value, fixedFlags, mode); + return posixLib.openat(context.getPosixSupport(), dirFd, path.value, fixedFlags, mode); } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { gil.acquire(); // need GIL to construct OSError throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); @@ -888,19 +908,19 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone close(VirtualFrame frame, int fd, + static PNone close(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - PythonContext ctx = getContext(); - if (ctx.getSharedMultiprocessingData().decrementFDRefCount(fd)) { + if (context.getSharedMultiprocessingData().decrementFDRefCount(fd)) { return PNone.NONE; } gil.release(true); try { - posixLib.close(getPosixSupport(), fd); + posixLib.close(context.getPosixSupport(), fd); } finally { gil.acquire(); } @@ -923,45 +943,46 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PBytes doRead(VirtualFrame frame, int fd, int length, + static PBytes doRead(VirtualFrame frame, int fd, int length, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile1, @Cached InlinedBranchProfile errorProfile2, @Cached GilNode gil, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { if (length < 0) { int error = OSErrorEnum.EINVAL.getNumber(); - throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, error, posixLib.strerror(getPosixSupport(), error)); + throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, error, posixLib.strerror(context.getPosixSupport(), error)); } try { - return read(fd, length, inliningTarget, posixLib, errorProfile1, gil, factory); + return read(fd, length, inliningTarget, posixLib, context.getPosixSupport(), errorProfile1, gil); } catch (PosixException e) { errorProfile2.enter(inliningTarget); throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } } - public PBytes read(int fd, int length, + public static PBytes read(int fd, int length, Node inliningTarget, PosixSupportLibrary posixLib, - InlinedBranchProfile errorProfile, GilNode gil, PythonObjectFactory factory) throws PosixException { + PosixSupport posixSupport, + InlinedBranchProfile errorProfile, GilNode gil) throws PosixException { gil.release(true); try { while (true) { try { - Buffer result = posixLib.read(getPosixSupport(), fd, length); + Buffer result = posixLib.read(posixSupport, fd, length); if (result.length > Integer.MAX_VALUE) { // sanity check that it is safe to cast result.length to int, to be // removed once we support large arrays throw CompilerDirectives.shouldNotReachHere("Posix read() returned more bytes than requested"); } - return factory.createBytes(result.data, 0, (int) result.length); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), result.data, (int) result.length); } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { throw e; } @@ -989,12 +1010,13 @@ static long doWrite(VirtualFrame frame, int fd, Object dataBuffer, @Bind("this") Node inliningTarget, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("dataBuffer") PythonBufferAccessLibrary bufferLib, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return write(fd, bufferLib.getInternalOrCopiedByteArray(dataBuffer), bufferLib.getBufferLength(dataBuffer), inliningTarget, posixLib, errorProfile, gil); + return write(fd, bufferLib.getInternalOrCopiedByteArray(dataBuffer), bufferLib.getBufferLength(dataBuffer), inliningTarget, posixLib, context.getPosixSupport(), errorProfile, gil); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } finally { @@ -1003,13 +1025,13 @@ static long doWrite(VirtualFrame frame, int fd, Object dataBuffer, } public static long write(int fd, byte[] dataBytes, - int dataLen, Node inliningTarget, PosixSupportLibrary posixLib, + int dataLen, Node inliningTarget, PosixSupportLibrary posixLib, PosixSupport posixSupport, InlinedBranchProfile errorProfile, GilNode gil) throws PosixException { gil.release(true); try { while (true) { try { - return posixLib.write(PosixSupport.get(inliningTarget), fd, new Buffer(dataBytes, dataLen)); + return posixLib.write(posixSupport, fd, new Buffer(dataBytes, dataLen)); } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { @@ -1036,12 +1058,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int dup(VirtualFrame frame, int fd, + static int dup(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.dup(getPosixSupport(), fd); + return posixLib.dup(context.getPosixSupport(), fd); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1061,19 +1084,20 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int dup2(VirtualFrame frame, int fd, int fd2, boolean inheritable, + static int dup2(VirtualFrame frame, int fd, int fd2, boolean inheritable, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { if (fd < 0 || fd2 < 0) { // CPython does not set errno here and raises a 'random' OSError // (possibly with errno=0 Success) int error = OSErrorEnum.EINVAL.getNumber(); - throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, error, posixLib.strerror(getPosixSupport(), error)); + throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, error, posixLib.strerror(context.getPosixSupport(), error)); } try { - return posixLib.dup2(getPosixSupport(), fd, fd2, inheritable); + return posixLib.dup2(context.getPosixSupport(), fd, fd2, inheritable); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1091,12 +1115,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean getInheritable(VirtualFrame frame, int fd, + static boolean getInheritable(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.getInheritable(getPosixSupport(), fd); + return posixLib.getInheritable(context.getPosixSupport(), fd); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1115,13 +1140,14 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone setInheritable(VirtualFrame frame, int fd, int inheritable, + static PNone setInheritable(VirtualFrame frame, int fd, int inheritable, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { // not sure why inheritable is not a boolean, but that is how they do it in CPython - posixLib.setInheritable(getPosixSupport(), fd, inheritable != 0); + posixLib.setInheritable(context.getPosixSupport(), fd, inheritable != 0); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1134,23 +1160,23 @@ PNone setInheritable(VirtualFrame frame, int fd, int inheritable, abstract static class PipeNode extends PythonBuiltinNode { @Specialization - PTuple pipe(VirtualFrame frame, + static PTuple pipe(VirtualFrame frame, @Bind("this") Node inliningTarget, @Cached GilNode gil, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { int[] pipe; gil.release(true); try { - pipe = posixLib.pipe(getPosixSupport()); + pipe = posixLib.pipe(context.getPosixSupport()); } catch (PosixException e) { gil.acquire(); // need to acquire the gil to construct the OSError object throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } finally { gil.acquire(); } - return factory.createTuple(new Object[]{pipe[0], pipe[1]}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{pipe[0], pipe[1]}); } } @@ -1181,12 +1207,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - long lseek(VirtualFrame frame, int fd, long pos, int how, + static long lseek(VirtualFrame frame, int fd, long pos, int how, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.lseek(getPosixSupport(), fd, pos, mapPythonSeekWhenceToPosix(how)); + return posixLib.lseek(context.getPosixSupport(), fd, pos, mapPythonSeekWhenceToPosix(how)); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1207,8 +1234,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PNone ftruncate(VirtualFrame frame, int fd, long length, @Bind("this") Node inliningTarget, - @Bind("getPosixSupport()") PosixSupport posixSupport, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, @Cached InlinedBranchProfile errorProfile, @@ -1218,7 +1245,7 @@ static PNone ftruncate(VirtualFrame frame, int fd, long length, try { gil.release(true); try { - posixLib.ftruncate(posixSupport, fd, length); + posixLib.ftruncate(context.getPosixSupport(), fd, length); } finally { gil.acquire(); } @@ -1249,8 +1276,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PNone truncate(VirtualFrame frame, PosixPath path, long length, @Bind("this") Node inliningTarget, - @Bind("getPosixSupport()") PosixSupport posixSupport, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { @@ -1258,7 +1285,7 @@ static PNone truncate(VirtualFrame frame, PosixPath path, long length, try { gil.release(true); try { - posixLib.truncate(posixSupport, path.value, length); + posixLib.truncate(context.getPosixSupport(), path.value, length); } finally { gil.acquire(); } @@ -1271,13 +1298,13 @@ static PNone truncate(VirtualFrame frame, PosixPath path, long length, @Specialization static PNone ftruncate(VirtualFrame frame, PosixFd fd, long length, @Bind("this") Node inliningTarget, - @Bind("getPosixSupport()") PosixSupport posixSupport, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, @Shared @Cached GilNode gil, @Cached InlinedBranchProfile errorProfile, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { - return FtruncateNode.ftruncate(frame, fd.fd, length, inliningTarget, posixSupport, posixLib, auditNode, gil, errorProfile, constructAndRaiseNode); + return FtruncateNode.ftruncate(frame, fd.fd, length, inliningTarget, context, posixLib, auditNode, gil, errorProfile, constructAndRaiseNode); } } @@ -1292,19 +1319,20 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone fsync(VirtualFrame frame, int fd, + static PNone fsync(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { while (true) { try { - posixLib.fsync(getPosixSupport(), fd); + posixLib.fsync(context.getPosixSupport(), fd); return PNone.NONE; } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1324,12 +1352,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean getBlocking(VirtualFrame frame, int fd, + static boolean getBlocking(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.getBlocking(getPosixSupport(), fd); + return posixLib.getBlocking(context.getPosixSupport(), fd); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1348,12 +1377,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone setBlocking(VirtualFrame frame, int fd, boolean blocking, + static PNone setBlocking(VirtualFrame frame, int fd, boolean blocking, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.setBlocking(getPosixSupport(), fd, blocking); + posixLib.setBlocking(context.getPosixSupport(), fd, blocking); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1372,15 +1402,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple getTerminalSize(VirtualFrame frame, int fd, + static PTuple getTerminalSize(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { // TODO default value should be fileno(stdout) try { - int[] result = posixLib.getTerminalSize(getPosixSupport(), fd); - return factory.createStructSeq(TERMINAL_SIZE_DESC, result[0], result[1]); + int[] result = posixLib.getTerminalSize(context.getPosixSupport(), fd); + return PFactory.createStructSeq(context.getLanguage(inliningTarget), TERMINAL_SIZE_DESC, result[0], result[1]); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1400,15 +1430,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple doStatPath(VirtualFrame frame, PosixPath path, int dirFd, boolean followSymlinks, + static PTuple doStatPath(VirtualFrame frame, PosixPath path, int dirFd, boolean followSymlinks, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared("positive") @Cached InlinedConditionProfile positiveLongProfile, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - long[] out = posixLib.fstatat(getPosixSupport(), dirFd, path.value, followSymlinks); - return createStatResult(inliningTarget, factory, positiveLongProfile, out); + long[] out = posixLib.fstatat(context.getPosixSupport(), dirFd, path.value, followSymlinks); + return createStatResult(inliningTarget, context.getLanguage(inliningTarget), positiveLongProfile, out); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1429,15 +1459,15 @@ static PTuple doStatFdWithFollowSymlinks(VirtualFrame frame, PosixFd fd, int dir } @Specialization(guards = {"isDefault(dirFd)", "followSymlinks"}) - PTuple doStatFd(VirtualFrame frame, PosixFd fd, @SuppressWarnings("unused") int dirFd, @SuppressWarnings("unused") boolean followSymlinks, + static PTuple doStatFd(VirtualFrame frame, PosixFd fd, @SuppressWarnings("unused") int dirFd, @SuppressWarnings("unused") boolean followSymlinks, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared("positive") @Cached InlinedConditionProfile positiveLongProfile, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - long[] out = posixLib.fstat(getPosixSupport(), fd.fd); - return createStatResult(inliningTarget, factory, positiveLongProfile, out); + long[] out = posixLib.fstat(context.getPosixSupport(), fd.fd); + return createStatResult(inliningTarget, context.getLanguage(inliningTarget), positiveLongProfile, out); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, fd.originalObject); } @@ -1460,16 +1490,16 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple doStatPath(VirtualFrame frame, PosixPath path, int dirFd, + static PTuple doStatPath(VirtualFrame frame, PosixPath path, int dirFd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile positiveLongProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { // TODO we used to return all zeros when the filename was equal to sys.executable - long[] out = posixLib.fstatat(getPosixSupport(), dirFd, path.value, false); - return createStatResult(inliningTarget, factory, positiveLongProfile, out); + long[] out = posixLib.fstatat(context.getPosixSupport(), dirFd, path.value, false); + return createStatResult(inliningTarget, context.getLanguage(inliningTarget), positiveLongProfile, out); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1487,21 +1517,21 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple doStatFd(VirtualFrame frame, int fd, + static PTuple doStatFd(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile positiveLongProfile, @Cached InlinedBranchProfile errorProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { while (true) { try { - long[] out = posixLib.fstat(getPosixSupport(), fd); - return createStatResult(inliningTarget, factory, positiveLongProfile, out); + long[] out = posixLib.fstat(context.getPosixSupport(), fd); + return createStatResult(inliningTarget, context.getLanguage(inliningTarget), positiveLongProfile, out); } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1510,12 +1540,12 @@ PTuple doStatFd(VirtualFrame frame, int fd, } } - private static PTuple createStatvfsResult(Node inliningTarget, long[] out, InlinedConditionProfile positiveLongProfile, PythonObjectFactory factory) { + private static PTuple createStatvfsResult(Node inliningTarget, long[] out, InlinedConditionProfile positiveLongProfile, PythonLanguage language) { Object[] res = new Object[out.length]; for (int i = 0; i < out.length; i++) { - res[i] = PInt.createPythonIntFromUnsignedLong(inliningTarget, factory, positiveLongProfile, out[i]); + res[i] = PInt.createPythonIntFromUnsignedLong(inliningTarget, language, positiveLongProfile, out[i]); } - return factory.createStructSeq(STATVFS_RESULT_DESC, res); + return PFactory.createStructSeq(language, STATVFS_RESULT_DESC, res); } @Builtin(name = "statvfs", minNumOfPositionalArgs = 1, parameterNames = {"path"}) @@ -1529,24 +1559,24 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple doStatvfs(VirtualFrame frame, PosixFileHandle posixFileHandle, + static PTuple doStatvfs(VirtualFrame frame, PosixFileHandle posixFileHandle, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile posixPathProfile, @Cached InlinedConditionProfile positiveLongProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { long[] out; try { if (posixPathProfile.profile(inliningTarget, posixFileHandle instanceof PosixPath)) { - out = posixLib.statvfs(getPosixSupport(), ((PosixPath) posixFileHandle).value); + out = posixLib.statvfs(context.getPosixSupport(), ((PosixPath) posixFileHandle).value); } else { - out = posixLib.fstatvfs(getPosixSupport(), ((PosixFd) posixFileHandle).fd); + out = posixLib.fstatvfs(context.getPosixSupport(), ((PosixFd) posixFileHandle).fd); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, posixFileHandle.originalObject); } - return createStatvfsResult(inliningTarget, out, positiveLongProfile, factory); + return createStatvfsResult(inliningTarget, out, positiveLongProfile, context.getLanguage(inliningTarget)); } } @@ -1556,19 +1586,19 @@ PTuple doStatvfs(VirtualFrame frame, PosixFileHandle posixFileHandle, abstract static class FStatvfsNode extends PythonUnaryClinicBuiltinNode { @Specialization - PTuple doStatvfs(VirtualFrame frame, int fd, + static PTuple doStatvfs(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile positiveLongProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { long[] out; try { - out = posixLib.fstatvfs(getPosixSupport(), fd); + out = posixLib.fstatvfs(context.getPosixSupport(), fd); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, fd); } - return createStatvfsResult(inliningTarget, out, positiveLongProfile, factory); + return createStatvfsResult(inliningTarget, out, positiveLongProfile, context.getLanguage(inliningTarget)); } @Override @@ -1583,13 +1613,13 @@ protected ArgumentClinicProvider getArgumentClinic() { abstract static class UnameNode extends PythonBuiltinNode { @Specialization - PTuple uname(VirtualFrame frame, + static PTuple uname(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return factory.createStructSeq(UNAME_RESULT_DESC, posixLib.uname(getPosixSupport())); + return PFactory.createStructSeq(context.getLanguage(inliningTarget), UNAME_RESULT_DESC, posixLib.uname(context.getPosixSupport())); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1608,14 +1638,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone unlink(VirtualFrame frame, PosixPath path, int dirFd, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PNone unlink(VirtualFrame frame, PosixPath path, int dirFd, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.remove", path.originalObject, dirFdForAudit(dirFd)); try { - posixLib.unlinkat(getPosixSupport(), dirFd, path.value, false); + posixLib.unlinkat(context.getPosixSupport(), dirFd, path.value, false); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1653,12 +1684,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone link(VirtualFrame frame, PosixPath src, PosixPath dst, int srcDirFd, int dstDirFd, boolean followSymlinks, + static PNone link(VirtualFrame frame, PosixPath src, PosixPath dst, int srcDirFd, int dstDirFd, boolean followSymlinks, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.linkat(getPosixSupport(), srcDirFd, src.value, dstDirFd, dst.value, followSymlinks ? AT_SYMLINK_FOLLOW.value : 0); + posixLib.linkat(context.getPosixSupport(), srcDirFd, src.value, dstDirFd, dst.value, followSymlinks ? AT_SYMLINK_FOLLOW.value : 0); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, src.originalObject, dst.originalObject); } @@ -1680,12 +1712,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone symlink(VirtualFrame frame, PosixPath src, PosixPath dst, @SuppressWarnings("unused") boolean targetIsDir, int dirFd, + static PNone symlink(VirtualFrame frame, PosixPath src, PosixPath dst, @SuppressWarnings("unused") boolean targetIsDir, int dirFd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.symlinkat(getPosixSupport(), src.value, dirFd, dst.value); + posixLib.symlinkat(context.getPosixSupport(), src.value, dirFd, dst.value); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, src.originalObject, dst.originalObject); } @@ -1706,14 +1739,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone mkdir(VirtualFrame frame, PosixPath path, int mode, int dirFd, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PNone mkdir(VirtualFrame frame, PosixPath path, int mode, int dirFd, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.mkdir", path.originalObject, mode, dirFdForAudit(dirFd)); try { - posixLib.mkdirat(getPosixSupport(), dirFd, path.value, mode); + posixLib.mkdirat(context.getPosixSupport(), dirFd, path.value, mode); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1733,14 +1767,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone rmdir(VirtualFrame frame, PosixPath path, int dirFd, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PNone rmdir(VirtualFrame frame, PosixPath path, int dirFd, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.rmdir", path.originalObject, dirFdForAudit(dirFd)); try { - posixLib.unlinkat(getPosixSupport(), dirFd, path.value, true); + posixLib.unlinkat(context.getPosixSupport(), dirFd, path.value, true); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1752,12 +1787,13 @@ PNone rmdir(VirtualFrame frame, PosixPath path, int dirFd, @GenerateNodeFactory abstract static class GetcwdNode extends PythonBuiltinNode { @Specialization - TruffleString getcwd(VirtualFrame frame, + static TruffleString getcwd(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.getPathAsString(getPosixSupport(), posixLib.getcwd(getPosixSupport())); + return posixLib.getPathAsString(context.getPosixSupport(), posixLib.getcwd(context.getPosixSupport())); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1768,13 +1804,14 @@ TruffleString getcwd(VirtualFrame frame, @GenerateNodeFactory abstract static class GetcwdbNode extends PythonBuiltinNode { @Specialization - PBytes getcwdb(VirtualFrame frame, + static PBytes getcwdb(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return opaquePathToBytes(posixLib.getcwd(getPosixSupport()), posixLib, getPosixSupport(), factory); + Object path = posixLib.getcwd(context.getPosixSupport()); + return opaquePathToBytes(path, posixLib, context.getPosixSupport(), context.getLanguage(inliningTarget)); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1792,12 +1829,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone chdirPath(VirtualFrame frame, PosixPath path, + static PNone chdirPath(VirtualFrame frame, PosixPath path, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.chdir(getPosixSupport(), path.value); + posixLib.chdir(context.getPosixSupport(), path.value); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } @@ -1805,12 +1843,13 @@ PNone chdirPath(VirtualFrame frame, PosixPath path, } @Specialization - PNone chdirFd(VirtualFrame frame, PosixFd fd, + static PNone chdirFd(VirtualFrame frame, PosixFd fd, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.fchdir(getPosixSupport(), fd.fd); + posixLib.fchdir(context.getPosixSupport(), fd.fd); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, fd.originalObject); } @@ -1829,19 +1868,20 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone fchdir(VirtualFrame frame, int fd, + static PNone fchdir(VirtualFrame frame, int fd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { while (true) { try { - posixLib.fchdir(getPosixSupport(), fd); + posixLib.fchdir(context.getPosixSupport(), fd); return PNone.NONE; } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1861,12 +1901,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean isatty(int fd, + static boolean isatty(int fd, @Cached GilNode gil, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { gil.release(true); try { - return posixLib.isatty(getPosixSupport(), fd); + return posixLib.isatty(context.getPosixSupport(), fd); } finally { gil.acquire(); } @@ -1906,30 +1947,30 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PScandirIterator scandirPath(VirtualFrame frame, PosixPath path, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PScandirIterator scandirPath(VirtualFrame frame, PosixPath path, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.scandir", path.originalObject == null ? PNone.NONE : path.originalObject); try { - return factory.createScandirIterator(getContext(), posixLib.opendir(getPosixSupport(), path.value), path, false); + return PFactory.createScandirIterator(context.getLanguage(inliningTarget), context, posixLib.opendir(context.getPosixSupport(), path.value), path, false); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } } @Specialization - PScandirIterator scandirFd(VirtualFrame frame, PosixFd fd, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PScandirIterator scandirFd(VirtualFrame frame, PosixFd fd, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.scandir", fd.originalObject); - Object dirStream = dupAndFdopendir(frame, inliningTarget, posixLib, getPosixSupport(), fd, constructAndRaiseNode); - return factory.createScandirIterator(getContext(), dirStream, fd, true); + Object dirStream = dupAndFdopendir(frame, inliningTarget, posixLib, context.getPosixSupport(), fd, constructAndRaiseNode); + return PFactory.createScandirIterator(context.getLanguage(inliningTarget), context, dirStream, fd, true); } } @@ -1944,56 +1985,57 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PList listdirPath(VirtualFrame frame, PosixPath path, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PList listdirPath(VirtualFrame frame, PosixPath path, @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.listdir", path.originalObject == null ? PNone.NONE : path.originalObject); try { - return listdir(frame, inliningTarget, posixLib.opendir(getPosixSupport(), path.value), path.wasBufferLike, false, posixLib, constructAndRaiseNode, factory); + return listdir(frame, inliningTarget, posixLib.opendir(context.getPosixSupport(), path.value), path.wasBufferLike, false, posixLib, constructAndRaiseNode, + context.getLanguage(inliningTarget), context.getPosixSupport()); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); } } @Specialization - PList listdirFd(VirtualFrame frame, PosixFd fd, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PList listdirFd(VirtualFrame frame, PosixFd fd, @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.listdir", fd.originalObject); - Object dirStream = dupAndFdopendir(frame, inliningTarget, posixLib, getPosixSupport(), fd, constructAndRaiseNode); - return listdir(frame, inliningTarget, dirStream, false, true, posixLib, constructAndRaiseNode, factory); + Object dirStream = dupAndFdopendir(frame, inliningTarget, posixLib, context.getPosixSupport(), fd, constructAndRaiseNode); + return listdir(frame, inliningTarget, dirStream, false, true, posixLib, constructAndRaiseNode, context.getLanguage(inliningTarget), context.getPosixSupport()); } - private PList listdir(VirtualFrame frame, Node inliningTarget, Object dirStream, boolean produceBytes, boolean needsRewind, PosixSupportLibrary posixLib, - PConstructAndRaiseNode.Lazy constructAndRaiseNode, PythonObjectFactory factory) { + private static PList listdir(VirtualFrame frame, Node inliningTarget, Object dirStream, boolean produceBytes, boolean needsRewind, PosixSupportLibrary posixLib, + PConstructAndRaiseNode.Lazy constructAndRaiseNode, PythonLanguage language, PosixSupport posixSupport) { List list = new ArrayList<>(); try { while (true) { - Object dirEntry = posixLib.readdir(getPosixSupport(), dirStream); + Object dirEntry = posixLib.readdir(posixSupport, dirStream); if (dirEntry == null) { - return factory.createList(listToArray(list)); + return PFactory.createList(language, listToArray(list)); } - Object name = posixLib.dirEntryGetName(getPosixSupport(), dirEntry); + Object name = posixLib.dirEntryGetName(posixSupport, dirEntry); if (produceBytes) { - addToList(list, opaquePathToBytes(name, posixLib, getPosixSupport(), factory)); + addToList(list, opaquePathToBytes(name, posixLib, posixSupport, language)); } else { - addToList(list, posixLib.getPathAsString(getPosixSupport(), name)); + addToList(list, posixLib.getPathAsString(posixSupport, name)); } } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } finally { if (needsRewind) { - posixLib.rewinddir(getPosixSupport(), dirStream); + posixLib.rewinddir(posixSupport, dirStream); } try { - posixLib.closedir(getPosixSupport(), dirStream); + posixLib.closedir(posixSupport, dirStream); } catch (PosixException e) { // ignored (CPython does not check the return value of closedir) } @@ -2127,12 +2169,13 @@ static PNone utimensat(VirtualFrame frame, PosixPath path, Object times, Object @Bind("this") Node inliningTarget, @Shared @Cached UtimeArgsToTimespecNode timespecNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { long[] timespec = timespecNode.execute(frame, times, ns); auditNode.audit(inliningTarget, "os.utime", path.originalObject, checkNone(times), checkNone(ns), dirFdForAudit(dirFd)); try { - posixLib.utimensat(PosixSupport.get(inliningTarget), dirFd, path.value, timespec, followSymlinks); + posixLib.utimensat(context.getPosixSupport(), dirFd, path.value, timespec, followSymlinks); } catch (PosixException e) { // filename is intentionally not included, see CPython's os_utime_impl throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2145,12 +2188,13 @@ static PNone utimes(VirtualFrame frame, PosixPath path, Object times, Object ns, @Bind("this") Node inliningTarget, @Shared @Cached UtimeArgsToTimespecNode timespecNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Timeval[] timeval = timespecNode.toTimeval(frame, times, ns); auditNode.audit(inliningTarget, "os.utime", path.originalObject, checkNone(times), checkNone(ns), dirFdForAudit(dirFd)); try { - posixLib.utimes(PosixSupport.get(inliningTarget), path.value, timeval); + posixLib.utimes(context.getPosixSupport(), path.value, timeval); } catch (PosixException e) { // filename is intentionally not included, see CPython's os_utime_impl throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2163,12 +2207,13 @@ static PNone lutimes(VirtualFrame frame, PosixPath path, Object times, Object ns @Bind("this") Node inliningTarget, @Shared @Cached UtimeArgsToTimespecNode timespecNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Timeval[] timeval = timespecNode.toTimeval(frame, times, ns); auditNode.audit(inliningTarget, "os.utime", path.originalObject, checkNone(times), checkNone(ns), dirFdForAudit(dirFd)); try { - posixLib.lutimes(PosixSupport.get(inliningTarget), path.value, timeval); + posixLib.lutimes(context.getPosixSupport(), path.value, timeval); } catch (PosixException e) { // filename is intentionally not included, see CPython's os_utime_impl throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2195,12 +2240,13 @@ static PNone futimens(VirtualFrame frame, PosixFd fd, Object times, Object ns, i @Bind("this") Node inliningTarget, @Shared @Cached UtimeArgsToTimespecNode timespecNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { long[] timespec = timespecNode.execute(frame, times, ns); auditNode.audit(inliningTarget, "os.utime", fd.originalObject, checkNone(times), checkNone(ns), dirFdForAudit(dirFd)); try { - posixLib.futimens(PosixSupport.get(inliningTarget), fd.fd, timespec); + posixLib.futimens(context.getPosixSupport(), fd.fd, timespec); } catch (PosixException e) { // filename is intentionally not included, see CPython's os_utime_impl throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2213,12 +2259,13 @@ static PNone futimes(VirtualFrame frame, PosixFd fd, Object times, Object ns, in @Bind("this") Node inliningTarget, @Shared @Cached UtimeArgsToTimespecNode timespecNode, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Timeval[] timeval = timespecNode.toTimeval(frame, times, ns); auditNode.audit(inliningTarget, "os.utime", fd.originalObject, checkNone(times), checkNone(ns), dirFdForAudit(dirFd)); try { - posixLib.futimes(PosixSupport.get(inliningTarget), fd.fd, timeval); + posixLib.futimes(context.getPosixSupport(), fd.fd, timeval); } catch (PosixException e) { // filename is intentionally not included, see CPython's os_utime_impl throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2259,14 +2306,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone rename(VirtualFrame frame, PosixPath src, PosixPath dst, int srcDirFd, int dstDirFd, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + static PNone rename(VirtualFrame frame, PosixPath src, PosixPath dst, int srcDirFd, int dstDirFd, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.rename", src.originalObject, dst.originalObject, dirFdForAudit(srcDirFd), dirFdForAudit(dstDirFd)); try { - posixLib.renameat(getPosixSupport(), srcDirFd, src.value, dstDirFd, dst.value); + posixLib.renameat(context.getPosixSupport(), srcDirFd, src.value, dstDirFd, dst.value); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, src.originalObject, dst.originalObject); } @@ -2306,9 +2354,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean access(PosixPath path, int mode, int dirFd, boolean effectiveIds, boolean followSymlinks, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.faccessat(getPosixSupport(), dirFd, path.value, mode, effectiveIds, followSymlinks); + static boolean access(PosixPath path, int mode, int dirFd, boolean effectiveIds, boolean followSymlinks, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.faccessat(context.getPosixSupport(), dirFd, path.value, mode, effectiveIds, followSymlinks); } } @@ -2323,14 +2372,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone fchmod(VirtualFrame frame, int fd, int mode, + static PNone fchmod(VirtualFrame frame, int fd, int mode, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.chmod", fd, mode, -1); try { - posixLib.fchmod(getPosixSupport(), fd, mode); + posixLib.fchmod(context.getPosixSupport(), fd, mode); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, fd); } @@ -2355,12 +2405,13 @@ protected ArgumentClinicProvider getArgumentClinic() { static PNone chmodFollow(VirtualFrame frame, PosixPath path, int mode, int dirFd, boolean followSymlinks, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { auditNode.audit(inliningTarget, "os.chmod", path.originalObject, mode, dirFdForAudit(dirFd)); try { - posixLib.fchmodat(PosixSupport.get(inliningTarget), dirFd, path.value, mode, followSymlinks); + posixLib.fchmodat(context.getPosixSupport(), dirFd, path.value, mode, followSymlinks); } catch (PosixException e) { // TODO CPython checks for ENOTSUP as well if (e.getErrorCode() == OSErrorEnum.EOPNOTSUPP.getNumber() && !followSymlinks) { @@ -2376,10 +2427,11 @@ static PNone chmodFollow(VirtualFrame frame, PosixPath path, int mode, int dirFd } @Specialization - PNone chmodFollow(VirtualFrame frame, PosixFd fd, int mode, int dirFd, @SuppressWarnings("unused") boolean followSymlinks, + static PNone chmodFollow(VirtualFrame frame, PosixFd fd, int mode, int dirFd, @SuppressWarnings("unused") boolean followSymlinks, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, // unused node to avoid mixing shared and non-shared inlined nodes @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) { @@ -2389,7 +2441,7 @@ PNone chmodFollow(VirtualFrame frame, PosixFd fd, int mode, int dirFd, @Suppress // arguments is used, CPython's implementation of chmod simply ignores dir_fd and // follow_symlinks if a fd is specified instead of a path. try { - posixLib.fchmod(getPosixSupport(), fd.fd, mode); + posixLib.fchmod(context.getPosixSupport(), fd.fd, mode); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, fd.originalObject); } @@ -2404,17 +2456,18 @@ PNone chmodFollow(VirtualFrame frame, PosixFd fd, int mode, int dirFd, @Suppress @GenerateNodeFactory abstract static class FChownNode extends PythonTernaryClinicBuiltinNode { @Specialization - Object chown(VirtualFrame frame, int fd, long uid, long gid, + static Object chown(VirtualFrame frame, int fd, long uid, long gid, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.chown", fd, uid, gid, -1); try { gil.release(true); try { - posixLib.fchown(getPosixSupport(), fd, uid, gid); + posixLib.fchown(context.getPosixSupport(), fd, uid, gid); } finally { gil.acquire(); } @@ -2437,17 +2490,18 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class LChownNode extends PythonTernaryClinicBuiltinNode { @Specialization - Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, + static Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "os.chown", path.originalObject, uid, gid, -1); try { gil.release(true); try { - posixLib.fchownat(getPosixSupport(), AT_FDCWD.value, path.value, uid, gid, false); + posixLib.fchownat(context.getPosixSupport(), AT_FDCWD.value, path.value, uid, gid, false); } finally { gil.acquire(); } @@ -2475,7 +2529,8 @@ abstract static class ChownNode extends PythonClinicBuiltinNode { static Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, int dirFd, boolean followSymlinks, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, // unused node to avoid mixing shared and non-shared inlined nodes @@ -2484,7 +2539,7 @@ static Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, int try { gil.release(true); try { - posixLib.fchownat(PosixSupport.get(inliningTarget), dirFd, path.value, uid, gid, followSymlinks); + posixLib.fchownat(context.getPosixSupport(), dirFd, path.value, uid, gid, followSymlinks); } finally { gil.acquire(); } @@ -2498,7 +2553,8 @@ static Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, int static Object chown(VirtualFrame frame, PosixFd fd, long uid, long gid, int dirFd, boolean followSymlinks, @Bind("this") Node inliningTarget, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Shared @Cached PRaiseNode.Lazy raiseNode) { @@ -2512,7 +2568,7 @@ static Object chown(VirtualFrame frame, PosixFd fd, long uid, long gid, int dirF try { gil.release(true); try { - posixLib.fchown(PosixSupport.get(inliningTarget), fd.fd, uid, gid); + posixLib.fchown(context.getPosixSupport(), fd.fd, uid, gid); } finally { gil.acquire(); } @@ -2541,18 +2597,18 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - Object readlinkAsBytes(VirtualFrame frame, PosixPath path, int dirFd, + static Object readlinkAsBytes(VirtualFrame frame, PosixPath path, int dirFd, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile wasBufferLikeProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - Object link = posixLib.readlinkat(getPosixSupport(), dirFd, path.value); + Object link = posixLib.readlinkat(context.getPosixSupport(), dirFd, path.value); if (wasBufferLikeProfile.profile(inliningTarget, path.wasBufferLike)) { - return opaquePathToBytes(link, posixLib, getPosixSupport(), factory); + return opaquePathToBytes(link, posixLib, context.getPosixSupport(), context.getLanguage(inliningTarget)); } else { - return posixLib.getPathAsString(getPosixSupport(), link); + return posixLib.getPathAsString(context.getPosixSupport(), link); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); @@ -2571,9 +2627,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - TruffleString getStrError(int code, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.strerror(getPosixSupport(), code); + static TruffleString getStrError(int code, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.strerror(context.getPosixSupport(), code); } } @@ -2622,23 +2679,23 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PTuple waitpid(VirtualFrame frame, long pid, int options, + static PTuple waitpid(VirtualFrame frame, long pid, int options, @Bind("this") Node inliningTarget, @Cached GilNode gil, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { gil.release(true); try { while (true) { try { - long[] result = posixLib.waitpid(getPosixSupport(), pid, options); - return factory.createTuple(new Object[]{result[0], result[1]}); + long[] result = posixLib.waitpid(context.getPosixSupport(), pid, options); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{result[0], result[1]}); } catch (PosixException e) { errorProfile.enter(inliningTarget); if (e.getErrorCode() == OSErrorEnum.EINTR.getNumber()) { - PythonContext.triggerAsyncActions(this); + PythonContext.triggerAsyncActions(inliningTarget); } else { gil.acquire(); throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -2658,12 +2715,13 @@ PTuple waitpid(VirtualFrame frame, long pid, int options, abstract static class WaitstatusToExitcodeNode extends PythonUnaryBuiltinNode { @Specialization static int waitstatusToExitcode(VirtualFrame frame, Object statusObj, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached PyLongAsIntNode longAsInt, @Cached PRaiseNode.Lazy raiseNode) { int status = longAsInt.execute(frame, inliningTarget, statusObj); - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); if (posixLib.wifexited(posixSupport, status)) { int exitcode = posixLib.wexitstatus(posixSupport, status); if (exitcode < 0) { @@ -2696,9 +2754,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean wcoredump(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wcoredump(getPosixSupport(), status); + static boolean wcoredump(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wcoredump(context.getPosixSupport(), status); } } @@ -2712,9 +2771,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean wifcontinued(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wifcontinued(getPosixSupport(), status); + static boolean wifcontinued(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wifcontinued(context.getPosixSupport(), status); } } @@ -2728,9 +2788,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean wifstopped(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wifstopped(getPosixSupport(), status); + static boolean wifstopped(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wifstopped(context.getPosixSupport(), status); } } @@ -2744,9 +2805,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean wifsignaled(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wifsignaled(getPosixSupport(), status); + static boolean wifsignaled(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wifsignaled(context.getPosixSupport(), status); } } @@ -2760,9 +2822,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - boolean wifexited(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wifexited(getPosixSupport(), status); + static boolean wifexited(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wifexited(context.getPosixSupport(), status); } } @@ -2776,9 +2839,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int wexitstatus(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wexitstatus(getPosixSupport(), status); + static int wexitstatus(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wexitstatus(context.getPosixSupport(), status); } } @@ -2793,8 +2857,9 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization int wtermsig(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wtermsig(getPosixSupport(), status); + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wtermsig(context.getPosixSupport(), status); } } @@ -2808,9 +2873,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int wstopsig(int status, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib) { - return posixLib.wstopsig(getPosixSupport(), status); + static int wstopsig(int status, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib) { + return posixLib.wstopsig(context.getPosixSupport(), status); } } @@ -2824,11 +2890,12 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int system(PBytes command, + static int system(PBytes command, @Bind("this") Node inliningTarget, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil) { // Unlike in other posix builtins, we go through str -> bytes -> byte[] -> String // conversions for emulated backend because the bytes version after fsencode conversion @@ -2837,8 +2904,8 @@ int system(PBytes command, byte[] bytes = toBytesNode.execute(command); gil.release(true); try { - Object cmdOpaque = posixLib.createPathFromBytes(getPosixSupport(), bytes); - return posixLib.system(getPosixSupport(), cmdOpaque); + Object cmdOpaque = posixLib.createPathFromBytes(context.getPosixSupport(), bytes); + return posixLib.system(context.getPosixSupport(), cmdOpaque); } finally { gil.acquire(); } @@ -2851,11 +2918,12 @@ int system(PBytes command, @TypeSystemReference(PythonArithmeticTypes.class) abstract static class URandomNode extends PythonUnaryClinicBuiltinNode { @Specialization(guards = "size >= 0") - PBytes urandom(int size, - @Cached PythonObjectFactory factory) { + static PBytes urandom(int size, + @Bind("this") Node inliningTarget, + @Bind PythonContext context) { byte[] bytes = new byte[size]; - nextBytes(getContext().getSecureRandom(), bytes); - return factory.createBytes(bytes); + nextBytes(context.getSecureRandom(), bytes); + return PFactory.createBytes(context.getLanguage(inliningTarget), bytes); } @Specialization(guards = "size < 0") @@ -2943,12 +3011,13 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - int umask(VirtualFrame frame, int mask, + static int umask(VirtualFrame frame, int mask, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.umask(getPosixSupport(), mask); + return posixLib.umask(context.getPosixSupport(), mask); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -2959,12 +3028,13 @@ int umask(VirtualFrame frame, int mask, @GenerateNodeFactory abstract static class CtermId extends PythonBuiltinNode { @Specialization - TruffleString ctermid(VirtualFrame frame, + static TruffleString ctermid(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixLib.ctermid(getPosixSupport()); + return posixLib.ctermid(context.getPosixSupport()); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -2982,14 +3052,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone kill(VirtualFrame frame, long pid, int signal, + static PNone kill(VirtualFrame frame, long pid, int signal, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "kill", pid, signal); try { - posixLib.kill(getPosixSupport(), pid, signal); + posixLib.kill(context.getPosixSupport(), pid, signal); return PNone.NONE; } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -3010,14 +3081,15 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - PNone kill(VirtualFrame frame, long pid, int signal, + static PNone kill(VirtualFrame frame, long pid, int signal, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "killpg", pid, signal); try { - posixLib.killpg(getPosixSupport(), pid, signal); + posixLib.killpg(context.getPosixSupport(), pid, signal); return PNone.NONE; } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -3044,7 +3116,7 @@ static Object doTrivial(VirtualFrame frame, Object value, abstract static class RegisterAtForkNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") - Object register(Object before, Object afterInChild, Object afterInParent) { + static Object register(Object before, Object afterInChild, Object afterInParent) { // TODO should we at least call multiprocessing.util.register_after_fork? return PNone.NONE; } @@ -3064,15 +3136,15 @@ public abstract static class StringOrBytesToBytesNode extends Node { @Specialization(guards = "isString(strObj)") static PBytes doString(Node inliningTarget, Object strObj, + @Bind PythonLanguage language, @Cached CastToTruffleStringNode castToStringNode, @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached(inline = false) TruffleString.CopyToByteArrayNode copyToByteArrayNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached(inline = false) TruffleString.CopyToByteArrayNode copyToByteArrayNode) { TruffleString str = castToStringNode.execute(inliningTarget, strObj); TruffleString utf8 = switchEncodingNode.execute(str, Encoding.UTF_8); byte[] bytes = new byte[utf8.byteLength(Encoding.UTF_8)]; copyToByteArrayNode.execute(utf8, 0, bytes, 0, bytes.length, Encoding.UTF_8); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } @Specialization @@ -3095,18 +3167,20 @@ abstract static class StringOrBytesToOpaquePathNode extends Node { @Specialization(guards = "isString(strObj)") static Object doString(Node inliningTarget, Object strObj, @Cached CastToTruffleStringNode castToStringNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { TruffleString str = castToStringNode.execute(inliningTarget, strObj); - return checkPath(inliningTarget, posixLib.createPathFromString(PosixSupport.get(inliningTarget), str), raiseNode); + return checkPath(inliningTarget, posixLib.createPathFromString(context.getPosixSupport(), str), raiseNode); } @Specialization static Object doBytes(Node inliningTarget, PBytes bytes, @Cached(inline = false) BytesNodes.ToBytesNode toBytesNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - return checkPath(inliningTarget, posixLib.createPathFromBytes(PosixSupport.get(inliningTarget), toBytesNode.execute(bytes)), raiseNode); + return checkPath(inliningTarget, posixLib.createPathFromBytes(context.getPosixSupport(), toBytesNode.execute(bytes)), raiseNode); } private static Object checkPath(Node inliningTarget, Object path, PRaiseNode.Lazy raiseNode) { @@ -3260,10 +3334,10 @@ static int dirFdForAudit(int dirFd) { return dirFd == AT_FDCWD.value ? -1 : dirFd; } - public static PTuple createStatResult(Node inliningTarget, PythonObjectFactory factory, InlinedConditionProfile positiveLongProfile, long[] out) { + public static PTuple createStatResult(Node inliningTarget, PythonLanguage language, InlinedConditionProfile positiveLongProfile, long[] out) { Object[] res = new Object[16]; for (int i = 0; i < 7; i++) { - res[i] = PInt.createPythonIntFromUnsignedLong(inliningTarget, factory, positiveLongProfile, out[i]); + res[i] = PInt.createPythonIntFromUnsignedLong(inliningTarget, language, positiveLongProfile, out[i]); } res[6] = out[6]; for (int i = 7; i < 10; i++) { @@ -3271,9 +3345,9 @@ public static PTuple createStatResult(Node inliningTarget, PythonObjectFactory f long nsFraction = out[i + 3]; res[i] = seconds; res[i + 3] = seconds + nsFraction * 1.0e-9; - res[i + 6] = factory.createInt(convertToNanoseconds(seconds, nsFraction)); + res[i + 6] = PFactory.createInt(language, convertToNanoseconds(seconds, nsFraction)); } - return factory.createStructSeq(STAT_RESULT_DESC, res); + return PFactory.createStructSeq(language, STAT_RESULT_DESC, res); } @TruffleBoundary @@ -3284,14 +3358,14 @@ private static BigInteger convertToNanoseconds(long sec, long ns) { return r.add(BigInteger.valueOf(ns)); } - public static PBytes opaquePathToBytes(Object opaquePath, PosixSupportLibrary posixLib, Object posixSupport, PythonObjectFactory factory) { + public static PBytes opaquePathToBytes(Object opaquePath, PosixSupportLibrary posixLib, Object posixSupport, PythonLanguage language) { Buffer buf = posixLib.getPathAsBytes(posixSupport, opaquePath); if (buf.length > Integer.MAX_VALUE) { // sanity check that it is safe to cast result.length to int, to be removed once // we support large arrays throw CompilerDirectives.shouldNotReachHere("Posix path cannot fit into a Java array"); } - return factory.createBytes(buf.data, 0, (int) buf.length); + return PFactory.createBytes(language, buf.data, (int) buf.length); } // ------------------ @@ -3335,7 +3409,7 @@ static int doFdInt(int value) { } @Specialization - int doFdLong(long value, + static int doFdLong(long value, @Bind("this") Node inliningTarget, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { return longToFd(inliningTarget, value, raiseNode); @@ -3343,7 +3417,7 @@ int doFdLong(long value, @Specialization @SuppressWarnings("truffle-static-method") - int doFdPInt(PInt value, + static int doFdPInt(PInt value, @Bind("this") Node inliningTarget, @Exclusive @Cached CastToJavaLongLossyNode castToLongNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { @@ -3352,7 +3426,7 @@ int doFdPInt(PInt value, @Specialization(guards = {"!isPNone(value)", "!canBeInteger(value)"}) @SuppressWarnings("truffle-static-method") - int doIndex(VirtualFrame frame, Object value, + static int doIndex(VirtualFrame frame, Object value, @Bind("this") Node inliningTarget, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberIndexNode indexNode, @@ -3404,9 +3478,10 @@ public PathConversionNode(String functionName, String argumentName, boolean null @Specialization(guards = "nullable") PosixFileHandle doNone(@SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - Object path = posixLib.createPathFromString(PosixSupport.get(inliningTarget), T_DOT); + Object path = posixLib.createPathFromString(context.getPosixSupport(), T_DOT); return new PosixPath(null, checkPath(inliningTarget, path, raiseNode), false); } @@ -3440,10 +3515,11 @@ static PosixFileHandle doFdPInt(PInt value, PosixFileHandle doUnicode(Object value, @Bind("this") Node inliningTarget, @Exclusive @Cached CastToTruffleStringNode castToStringNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { TruffleString str = castToStringNode.execute(inliningTarget, value); - Object path = posixLib.createPathFromString(PosixSupport.get(inliningTarget), str); + Object path = posixLib.createPathFromString(context.getPosixSupport(), str); return new PosixPath(value, checkPath(inliningTarget, path, raiseNode), false); } @@ -3452,9 +3528,10 @@ PosixFileHandle doUnicode(Object value, PosixFileHandle doBytes(PBytes value, @Bind("this") Node inliningTarget, @Exclusive @Cached BytesNodes.ToBytesNode toByteArrayNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - Object path = posixLib.createPathFromBytes(PosixSupport.get(inliningTarget), toByteArrayNode.execute(value)); + Object path = posixLib.createPathFromBytes(context.getPosixSupport(), toByteArrayNode.execute(value)); return new PosixPath(value, checkPath(inliningTarget, path, raiseNode), true); } @@ -3466,7 +3543,7 @@ PosixFileHandle doBuffer(VirtualFrame frame, Object value, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("value") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached WarningsModuleBuiltins.WarnNode warningNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { PythonLanguage language = context.getLanguage(inliningTarget); @@ -3474,7 +3551,7 @@ PosixFileHandle doBuffer(VirtualFrame frame, Object value, try { warningNode.warnFormat(frame, null, PythonBuiltinClassType.DeprecationWarning, 1, ErrorMessages.S_S_SHOULD_BE_S_NOT_P, functionNameWithColon, argumentName, getAllowedTypes(), value); - Object path = posixLib.createPathFromBytes(PosixSupport.get(inliningTarget), bufferLib.getCopiedByteArray(value)); + Object path = posixLib.createPathFromBytes(context.getPosixSupport(), bufferLib.getCopiedByteArray(value)); return new PosixPath(value, checkPath(inliningTarget, path, raiseNode), true); } finally { bufferLib.release(buffer, frame, context, language, indirectCallData); @@ -3503,7 +3580,8 @@ PosixFileHandle doGeneric(VirtualFrame frame, Object value, @Cached("create(T___FSPATH__)") LookupAndCallUnaryNode callFSPath, @Exclusive @Cached BytesNodes.ToBytesNode toByteArrayNode, @Exclusive @Cached CastToTruffleStringNode castToStringNode, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object pathObject = callFSPath.executeObject(frame, value); if (pathObject == PNone.NO_VALUE) { @@ -3513,10 +3591,10 @@ PosixFileHandle doGeneric(VirtualFrame frame, Object value, // 'pathObject' replaces 'value' as the PosixPath.originalObject for auditing purposes // by design if (pathObject instanceof PBytes) { - return doBytes((PBytes) pathObject, inliningTarget, toByteArrayNode, posixLib, raiseNode); + return doBytes((PBytes) pathObject, inliningTarget, toByteArrayNode, context, posixLib, raiseNode); } if (PGuards.isString(pathObject)) { - return doUnicode(pathObject, inliningTarget, castToStringNode, posixLib, raiseNode); + return doUnicode(pathObject, inliningTarget, castToStringNode, context, posixLib, raiseNode); } throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, value, pathObject); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/Profiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/Profiler.java new file mode 100644 index 0000000000..50c8feed4a --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/Profiler.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025, 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.builtins.modules; + +import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; +import com.oracle.truffle.api.instrumentation.SourceSectionFilter; +import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.tools.profiler.CPUSampler; + +public class Profiler extends PythonBuiltinObject { + boolean subcalls; + boolean builtins; + double timeunit; + Object externalTimer; + double time; + final CPUSampler sampler; + + public Profiler(Object cls, Shape instanceShape, CPUSampler sampler) { + super(cls, instanceShape); + this.sampler = sampler; + this.sampler.setFilter(SourceSectionFilter.newBuilder().includeInternal(true).build()); + this.sampler.setPeriod(1); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java index a79a3d1df3..30994df2cf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -46,6 +46,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -75,7 +76,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.PwdResult; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -126,12 +127,12 @@ public void initialize(Python3Core core) { StructSequence.initType(core, STRUCT_PASSWD_DESC); } - private static Object[] createPwuidObject(Node inliningTarget, PwdResult pwd, PythonObjectFactory factory, InlinedConditionProfile unsignedConversionProfile) { + private static Object[] createPwuidObject(Node inliningTarget, PwdResult pwd, PythonLanguage language, InlinedConditionProfile unsignedConversionProfile) { return new Object[]{ pwd.name, T_NOT_AVAILABLE, - PInt.createPythonIntFromUnsignedLong(inliningTarget, factory, unsignedConversionProfile, pwd.uid), - PInt.createPythonIntFromUnsignedLong(inliningTarget, factory, unsignedConversionProfile, pwd.gid), + PInt.createPythonIntFromUnsignedLong(inliningTarget, language, unsignedConversionProfile, pwd.uid), + PInt.createPythonIntFromUnsignedLong(inliningTarget, language, unsignedConversionProfile, pwd.gid), /* gecos: */ T_EMPTY_STRING, pwd.dir, pwd.shell @@ -144,13 +145,13 @@ public abstract static class GetpwuidNode extends PythonUnaryBuiltinNode { @Specialization static Object doGetpwuid(VirtualFrame frame, Object uidObj, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached UidConversionNode uidConversionNode, @Cached IsBuiltinObjectProfile classProfile, @Cached GilNode gil, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile unsignedConversionProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { long uid; try { @@ -163,7 +164,6 @@ static Object doGetpwuid(VirtualFrame frame, Object uidObj, } PwdResult pwd; try { - PythonContext context = PythonContext.get(inliningTarget); gil.release(true); try { pwd = posixLib.getpwuid(context.getPosixSupport(), uid); @@ -176,7 +176,8 @@ static Object doGetpwuid(VirtualFrame frame, Object uidObj, if (pwd == null) { throw raiseUidNotFound(raiseNode.get(inliningTarget)); } - return factory.createStructSeq(STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, factory, unsignedConversionProfile)); + PythonLanguage language = context.getLanguage(inliningTarget); + return PFactory.createStructSeq(language, STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, language, unsignedConversionProfile)); } private static PException raiseUidNotFound(PRaiseNode raiseNode) { @@ -197,12 +198,13 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object doGetpwname(VirtualFrame frame, TruffleString name, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached GilNode gil, @Cached StringOrBytesToOpaquePathNode encodeFSDefault, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile unsignedConversionProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { // Note: CPython also takes only Strings, not bytes, and then encodes the String // StringOrBytesToOpaquePathNode already checks for embedded '\0' @@ -210,7 +212,6 @@ static Object doGetpwname(VirtualFrame frame, TruffleString name, PwdResult pwd; try { gil.release(true); - PythonContext context = PythonContext.get(inliningTarget); try { pwd = posixLib.getpwnam(context.getPosixSupport(), nameEncoded); } finally { @@ -222,7 +223,7 @@ static Object doGetpwname(VirtualFrame frame, TruffleString name, if (pwd == null) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, ErrorMessages.GETPWNAM_NAME_NOT_FOUND, name); } - return factory.createStructSeq(STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, factory, unsignedConversionProfile)); + return PFactory.createStructSeq(language, STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, context.getLanguage(inliningTarget), unsignedConversionProfile)); } } @@ -230,24 +231,25 @@ static Object doGetpwname(VirtualFrame frame, TruffleString name, @GenerateNodeFactory public abstract static class GetpwallNode extends PythonBuiltinNode { @Specialization - Object doGetpall(VirtualFrame frame, + static Object doGetpall(VirtualFrame frame, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile unsignedConversionProfile, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { // We cannot release the GIL, because the underlying POSIX calls are not thread safe PwdResult[] entries; try { - entries = posixLib.getpwentries(getPosixSupport()); + entries = posixLib.getpwentries(context.getPosixSupport()); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } + PythonLanguage language = context.getLanguage(inliningTarget); Object[] result = new Object[entries.length]; for (int i = 0; i < result.length; i++) { - result[i] = factory.createStructSeq(STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, entries[i], factory, unsignedConversionProfile)); + result[i] = PFactory.createStructSeq(language, STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, entries[i], language, unsignedConversionProfile)); } - return factory.createList(result); + return PFactory.createList(language, result); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/QueueModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/QueueModuleBuiltins.java index 60ac362574..f083fdd6c3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/QueueModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/QueueModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,16 +44,19 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; 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.objects.queue.PSimpleQueue; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -81,8 +84,9 @@ abstract static class SimpleQueueNode extends PythonUnaryBuiltinNode { @Specialization static PSimpleQueue doGeneric(Object cls, - @Cached PythonObjectFactory factory) { - return factory.createSimpleQueue(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createSimpleQueue(language, cls, getInstanceShape.execute(cls)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/RandomModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/RandomModuleBuiltins.java index 810cc61d65..8c1acbb386 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/RandomModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/RandomModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -29,16 +29,19 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.random.PRandom; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -64,8 +67,9 @@ abstract static class PRandomNode extends PythonBuiltinNode { @Specialization PRandom random(VirtualFrame frame, Object cls, Object seed, - @Cached PythonObjectFactory factory) { - PRandom random = factory.createRandom(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + PRandom random = PFactory.createRandom(language, cls, getInstanceShape.execute(cls)); setSeed.executeObject(frame, random, seed != PNone.NO_VALUE ? seed : PNone.NONE); return random; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java index 1fd1a2df14..44d8d756aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -62,7 +63,8 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PosixSupportLibrary.RusageResult; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -159,10 +161,11 @@ abstract static class GetRuUsageNode extends PythonBuiltinNode { @Specialization static PTuple getruusage(VirtualFrame frame, int who, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); RusageResult rusage; try { rusage = posixLib.getrusage(posixSupport, who); @@ -174,7 +177,7 @@ static PTuple getruusage(VirtualFrame frame, int who, } } - return PythonObjectFactory.getUncached().createStructSeq(STRUCT_RUSAGE_DESC, + return PFactory.createStructSeq(context.getLanguage(inliningTarget), STRUCT_RUSAGE_DESC, rusage.ru_utime(), rusage.ru_stime(), rusage.ru_maxrss(), rusage.ru_ixrss(), rusage.ru_idrss(), rusage.ru_isrss(), rusage.ru_minflt(), rusage.ru_majflt(), rusage.ru_nswap(), rusage.ru_inblock(), rusage.ru_oublock(), @@ -196,9 +199,9 @@ static int getPageSize() { abstract static class GetRLimitNode extends PythonBuiltinNode { @Specialization static PTuple getPageSize(@SuppressWarnings("unused") int which, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // dummy implementation - report "unrestricted" for everything - return factory.createTuple(new Object[]{RLIM_INFINITY, RLIM_INFINITY}); + return PFactory.createTuple(language, new Object[]{RLIM_INFINITY, RLIM_INFINITY}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java index f861d643f0..3f82f666a6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -51,6 +51,7 @@ import org.graalvm.collections.EconomicMap; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -88,7 +89,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -582,7 +583,7 @@ static void check(VirtualFrame frame, Object input, boolean expectBytes, @NeverDefault protected PTuple getSupportedBinaryInputTypes() { - return PythonObjectFactory.getUncached().createTuple(new Object[]{PythonBuiltinClassType.PBytes, PythonBuiltinClassType.PByteArray, PythonBuiltinClassType.PMMap, + return PFactory.createTuple(PythonLanguage.get(null), new Object[]{PythonBuiltinClassType.PBytes, PythonBuiltinClassType.PByteArray, PythonBuiltinClassType.PMMap, PythonBuiltinClassType.PMemoryView, PythonBuiltinClassType.PArray}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java index e03d62c3fd..2260a423dd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -98,7 +98,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleLogger; @@ -220,9 +220,8 @@ public void postInitialize(Python3Core core) { super.postInitialize(core); loadDefaults(); PythonModule module = core.lookupBuiltinModule(T__SSL); - PythonObjectFactory factory = core.factory(); module.setAttribute(tsLiteral("OPENSSL_VERSION_NUMBER"), 0); - PTuple versionInfo = factory.createTuple(new int[]{0, 0, 0, 0, 0}); + PTuple versionInfo = PFactory.createTuple(core.getLanguage(), new int[]{0, 0, 0, 0, 0}); module.setAttribute(tsLiteral("OPENSSL_VERSION_INFO"), versionInfo); module.setAttribute(tsLiteral("OPENSSL_VERSION"), toTruffleStringUncached("GraalVM JSSE")); module.setAttribute(tsLiteral("_DEFAULT_CIPHERS"), T_DEFAULT_CIPHER_STRING); @@ -310,13 +309,13 @@ abstract static class Txt2ObjNode extends PythonBinaryClinicBuiltinNode { static Object txt2obj(TruffleString txt, boolean name, @Bind("this") Node inliningTarget, @Cached TruffleString.EqualNode equalNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { // TODO implement properly if (equalNode.execute(T_OID_TLS_SERVER, txt, TS_ENCODING)) { - return factory.createTuple(new Object[]{129, T_SERVER_AUTH, T_TLS_WEB_SERVER_AUTHENTICATION, txt}); + return PFactory.createTuple(language, new Object[]{129, T_SERVER_AUTH, T_TLS_WEB_SERVER_AUTHENTICATION, txt}); } else if (equalNode.execute(T_OID_TLS_CLIENT, txt, TS_ENCODING)) { - return factory.createTuple(new Object[]{130, T_CLIENT_AUTH, T_TLS_WEB_CLIENT_AUTHENTICATION, txt}); + return PFactory.createTuple(language, new Object[]{130, T_CLIENT_AUTH, T_TLS_WEB_CLIENT_AUTHENTICATION, txt}); } throw raiseNode.get(inliningTarget).raise(NotImplementedError); } @@ -389,11 +388,11 @@ abstract static class GetDefaultVerifyPathsNode extends PythonBuiltinNode { @Specialization Object getDefaultPaths( - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // there is no default location given by graalpython // in case the env variables SSL_CERT_FILE or SSL_CERT_DIR // are provided, ssl.py#get_default_verify_paths will take care of it - return factory.createTuple(new Object[]{T_SSL_CERT_FILE, T_EMPTY_STRING, T_SSL_CERT_DIR, T_EMPTY_STRING}); + return PFactory.createTuple(language, new Object[]{T_SSL_CERT_FILE, T_EMPTY_STRING, T_SSL_CERT_DIR, T_EMPTY_STRING}); } } @@ -438,7 +437,7 @@ private Object decode(TruffleFile file) throws PException { if (!(cert instanceof X509Certificate)) { throw PConstructAndRaiseNode.raiseUncachedSSLError(SSL_ERR_DECODING_PEM_FILE_UNEXPECTED_S, cert.getClass().getName()); } - return CertUtils.decodeCertificate(getContext().factory(), (X509Certificate) certs.get(0)); + return CertUtils.decodeCertificate((X509Certificate) certs.get(0), PythonLanguage.get(null)); } catch (IOException | DecoderException ex) { throw PConstructAndRaiseNode.raiseUncachedSSLError(SSL_CANT_OPEN_FILE_S, ex.toString()); } catch (CertificateException | CRLException ex) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java index 1214db605d..6f41808631 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -74,7 +75,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.SelectResult; import com.oracle.graal.python.runtime.PosixSupportLibrary.Timeval; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.util.ArrayBuilder; import com.oracle.graal.python.util.IntArrayBuilder; @@ -132,7 +133,7 @@ static PTuple doGeneric(VirtualFrame frame, Object rlist, Object wlist, Object x @Cached InlinedBranchProfile notSelectableBranch, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { ObjAndFDList readFDs = seq2set(frame, inliningTarget, rlist, sizeNode, asFileDescriptor, callGetItemNode, constructListNode, raiseNode); ObjAndFDList writeFDs = seq2set(frame, inliningTarget, wlist, sizeNode, asFileDescriptor, callGetItemNode, constructListNode, raiseNode); @@ -161,18 +162,18 @@ static PTuple doGeneric(VirtualFrame frame, Object rlist, Object wlist, Object x // GraalPython hack: if one of the channels is not selectable (can happen only in // the emulated mode), we just return everything. notSelectableBranch.enter(inliningTarget); - return factory.createTuple(new Object[]{rlist, wlist, xlist}); + return PFactory.createTuple(language, new Object[]{rlist, wlist, xlist}); } - return factory.createTuple(new PList[]{ - toList(result.getReadFds(), readFDs, factory), - toList(result.getWriteFds(), writeFDs, factory), - toList(result.getErrorFds(), xFDs, factory)}); + return PFactory.createTuple(language, new PList[]{ + toList(result.getReadFds(), readFDs, language), + toList(result.getWriteFds(), writeFDs, language), + toList(result.getErrorFds(), xFDs, language)}); } /** * Also maps the returned FDs back to their original Python level objects. */ - private static PList toList(boolean[] result, ObjAndFDList fds, PythonObjectFactory factory) { + private static PList toList(boolean[] result, ObjAndFDList fds, PythonLanguage language) { Object[] resultObjs = new Object[result.length]; int resultObjsIdx = 0; for (int i = 0; i < fds.fds.length; i++) { @@ -180,7 +181,7 @@ private static PList toList(boolean[] result, ObjAndFDList fds, PythonObjectFact resultObjs[resultObjsIdx++] = fds.objects[i]; } } - return factory.createList(PythonUtils.arrayCopyOf(resultObjs, resultObjsIdx)); + return PFactory.createList(language, PythonUtils.arrayCopyOf(resultObjs, resultObjsIdx)); } private static ObjAndFDList seq2set(VirtualFrame frame, Node inliningTarget, Object sequence, PyObjectSizeNode sizeNode, PyObjectAsFileDescriptor asFileDescriptor, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java index 43b55adaa2..654b436933 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -59,6 +59,7 @@ import org.graalvm.nativeimage.ImageInfo; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -90,7 +91,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -241,7 +242,7 @@ public int frameIndex() { abstract static class ValidSignalsNode extends PythonBuiltinNode { @Specialization static Object validSignals( - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int signalCount = 0; for (int i = 0; i < Signals.SIGNAL_NAMES.length; i++) { if (Signals.SIGNAL_NAMES[i] != null) { @@ -256,7 +257,7 @@ static Object validSignals( } } - return factory.createTuple(validSignals); + return PFactory.createTuple(language, validSignals); } } @@ -464,14 +465,14 @@ Object doIt(VirtualFrame frame, PythonModule self, int which, Object seconds, Ob @Bind("this") Node inliningTarget, @Cached PyTimeFromObjectNode timeFromObjectNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ModuleData moduleData = self.getModuleState(ModuleData.class); long usDelay = toMicroseconds(frame, inliningTarget, seconds, timeFromObjectNode); long usInterval = toMicroseconds(frame, inliningTarget, interval, timeFromObjectNode); if (which != ITIMER_REAL) { throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, OSErrorEnum.EINVAL); } - PTuple resultTuple = GetitimerNode.createResultTuple(factory, moduleData); + PTuple resultTuple = GetitimerNode.createResultTuple(language, moduleData); setitimer(moduleData, usDelay, usInterval); return resultTuple; } @@ -532,18 +533,18 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object doIt(VirtualFrame frame, PythonModule self, int which, @Bind("this") Node inliningTarget, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ModuleData moduleData = self.getModuleState(ModuleData.class); if (which != ITIMER_REAL) { throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, OSErrorEnum.EINVAL); } - return createResultTuple(factory, moduleData); + return createResultTuple(language, moduleData); } - static PTuple createResultTuple(PythonObjectFactory factory, ModuleData moduleData) { + static PTuple createResultTuple(PythonLanguage language, ModuleData moduleData) { long oldInterval = moduleData.itimerInterval; long oldDelay = getOldDelay(moduleData); - return factory.createTuple(new Object[]{oldDelay / (double) SEC_TO_US, oldInterval / (double) SEC_TO_US}); + return PFactory.createTuple(language, new Object[]{oldDelay / (double) SEC_TO_US, oldInterval / (double) SEC_TO_US}); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java index f9e39499f6..20a289e4ce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -67,6 +67,7 @@ import java.nio.ByteOrder; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -80,12 +81,12 @@ import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum; -import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.socket.SocketNodes; import com.oracle.graal.python.builtins.objects.socket.SocketNodes.IdnaFromStringOrBytesConverterNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyLongAsIntNode; import com.oracle.graal.python.lib.PyLongAsLongNode; import com.oracle.graal.python.nodes.ErrorMessages; @@ -116,11 +117,11 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PosixSupportLibrary.UniversalSockAddr; import com.oracle.graal.python.runtime.PosixSupportLibrary.UniversalSockAddrLibrary; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.TimeUtils; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -212,17 +213,10 @@ private void addConstant(PosixConstants.IntConstant constant) { public abstract static class SocketNode extends PythonVarargsBuiltinNode { // All the "real" work is done by __init__ @Specialization - Object socket(Object cls) { - return factory().createSocket(cls); - } - - @Override - public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { - if (self == PNone.NO_VALUE && arguments.length > 0) { - return socket(arguments[0]); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw VarargsBuiltinDirectInvocationNotSupported.INSTANCE; + Object socket(Object cls, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createSocket(language, cls, getInstanceShape.execute(cls)); } } @@ -253,8 +247,9 @@ static Object set(VirtualFrame frame, PythonModule module, Object value, @GenerateNodeFactory public abstract static class GetHostnameNode extends PythonBuiltinNode { @Specialization - TruffleString doGeneric(VirtualFrame frame, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static TruffleString doGeneric(VirtualFrame frame, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, @@ -263,7 +258,7 @@ TruffleString doGeneric(VirtualFrame frame, try { gil.release(true); try { - return posixLib.getPathAsString(getPosixSupport(), posixLib.gethostname(getPosixSupport())); + return posixLib.getPathAsString(context.getPosixSupport(), posixLib.gethostname(context.getPosixSupport())); } finally { gil.acquire(); } @@ -277,8 +272,9 @@ TruffleString doGeneric(VirtualFrame frame, @GenerateNodeFactory public abstract static class GetHostByAddrNode extends PythonUnaryBuiltinNode { @Specialization - Object doGeneric(VirtualFrame frame, Object ip, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object doGeneric(VirtualFrame frame, Object ip, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") AddrInfoCursorLibrary addrInfoCursorLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary sockAddrLibrary, @Bind("this") Node inliningTarget, @@ -288,8 +284,7 @@ Object doGeneric(VirtualFrame frame, Object ip, @Cached SocketNodes.MakeIpAddrNode makeIpAddrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached SysModuleBuiltins.AuditNode auditNode, - @Cached GilNode gil, - @Cached PythonObjectFactory factory) { + @Cached GilNode gil) { /* * TODO this uses getnameinfo and getaddrinfo to emulate the legacy gethostbyaddr. We * might want to use the legacy API in the future @@ -298,8 +293,8 @@ Object doGeneric(VirtualFrame frame, Object ip, UniversalSockAddr addr = setIpAddrNode.execute(frame, idnaConverter.execute(frame, ip), AF_UNSPEC.value); int family = sockAddrLibrary.getFamily(addr); try { - Object[] getnameinfoResult = posixLib.getnameinfo(getPosixSupport(), addr, NI_NAMEREQD.value); - TruffleString hostname = posixLib.getPathAsString(getPosixSupport(), getnameinfoResult[0]); + Object[] getnameinfoResult = posixLib.getnameinfo(context.getPosixSupport(), addr, NI_NAMEREQD.value); + TruffleString hostname = posixLib.getPathAsString(context.getPosixSupport(), getnameinfoResult[0]); SequenceStorage storage = new ObjectSequenceStorage(5); @@ -307,7 +302,7 @@ Object doGeneric(VirtualFrame frame, Object ip, AddrInfoCursor cursor; gil.release(true); try { - cursor = posixLib.getaddrinfo(getPosixSupport(), getnameinfoResult[0], posixLib.createPathFromString(getPosixSupport(), T_ZERO), + cursor = posixLib.getaddrinfo(context.getPosixSupport(), getnameinfoResult[0], posixLib.createPathFromString(context.getPosixSupport(), T_ZERO), family, 0, 0, 0); } finally { gil.acquire(); @@ -323,7 +318,8 @@ Object doGeneric(VirtualFrame frame, Object ip, } catch (GetAddrInfoException e1) { // Ignore failing forward lookup and return at least the hostname } - return factory.createTuple(new Object[]{hostname, factory.createList(), factory.createList(storage)}); + PythonLanguage language = context.getLanguage(inliningTarget); + return PFactory.createTuple(language, new Object[]{hostname, PFactory.createList(language), PFactory.createList(language, storage)}); } catch (GetAddrInfoException e) { // TODO convert error code from gaierror to herror throw constructAndRaiseNode.get(inliningTarget).executeWithArgsOnly(frame, SocketHError, new Object[]{1, e.getMessageAsTruffleString()}); @@ -340,21 +336,21 @@ protected static IdnaFromStringOrBytesConverterNode createIdnaConverter() { @GenerateNodeFactory public abstract static class GetHostByNameNode extends PythonUnaryBuiltinNode { @Specialization - TruffleString getHostByName(VirtualFrame frame, Object nameObj, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static TruffleString getHostByName(VirtualFrame frame, Object nameObj, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary addrLib, @Bind("this") Node inliningTarget, @Cached("createIdnaConverter()") IdnaFromStringOrBytesConverterNode idnaConverter, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached SocketNodes.SetIpAddrNode setIpAddrNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { byte[] name = idnaConverter.execute(frame, nameObj); - auditNode.audit(inliningTarget, "socket.gethostbyname", factory.createTuple(new Object[]{nameObj})); + auditNode.audit(inliningTarget, "socket.gethostbyname", PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{nameObj})); UniversalSockAddr addr = setIpAddrNode.execute(frame, name, AF_INET.value); Inet4SockAddr inet4SockAddr = addrLib.asInet4SockAddr(addr); try { - return posixLib.getPathAsString(getPosixSupport(), posixLib.inet_ntop(getPosixSupport(), AF_INET.value, inet4SockAddr.getAddressAsBytes())); + return posixLib.getPathAsString(context.getPosixSupport(), posixLib.inet_ntop(context.getPosixSupport(), AF_INET.value, inet4SockAddr.getAddressAsBytes())); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -370,35 +366,36 @@ protected static IdnaFromStringOrBytesConverterNode createIdnaConverter() { @GenerateNodeFactory public abstract static class GetHostByNameExNode extends PythonUnaryBuiltinNode { @Specialization - Object get(VirtualFrame frame, Object nameObj, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object get(VirtualFrame frame, Object nameObj, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary addrLib, @CachedLibrary(limit = "1") AddrInfoCursorLibrary addrInfoCursorLib, @Bind("this") Node inliningTarget, @Cached("createIdnaConverter()") IdnaFromStringOrBytesConverterNode idnaConverter, @Cached SysModuleBuiltins.AuditNode auditNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { byte[] name = idnaConverter.execute(frame, nameObj); // The event name is really without the _ex, it's not a copy-paste error - auditNode.audit(inliningTarget, "socket.gethostbyname", factory.createTuple(new Object[]{nameObj})); + auditNode.audit(inliningTarget, "socket.gethostbyname", PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{nameObj})); /* * TODO this uses getaddrinfo to emulate the legacy gethostbyname. It doesn't support * aliases and multiple addresses. We might want to use the legacy gethostbyname_r API * in the future */ try { - AddrInfoCursor cursor = posixLib.getaddrinfo(getPosixSupport(), posixLib.createPathFromBytes(getPosixSupport(), name), + PosixSupport posixSupport = context.getPosixSupport(); + AddrInfoCursor cursor = posixLib.getaddrinfo(posixSupport, posixLib.createPathFromBytes(posixSupport, name), null, AF_INET.value, 0, 0, AI_CANONNAME.value); try { - TruffleString canonName = posixLib.getPathAsString(getPosixSupport(), addrInfoCursorLib.getCanonName(cursor)); + TruffleString canonName = posixLib.getPathAsString(posixSupport, addrInfoCursorLib.getCanonName(cursor)); Inet4SockAddr inet4SockAddr = addrLib.asInet4SockAddr(addrInfoCursorLib.getSockAddr(cursor)); - TruffleString addr = posixLib.getPathAsString(getPosixSupport(), posixLib.inet_ntop(getPosixSupport(), AF_INET.value, inet4SockAddr.getAddressAsBytes())); + TruffleString addr = posixLib.getPathAsString(posixSupport, posixLib.inet_ntop(posixSupport, AF_INET.value, inet4SockAddr.getAddressAsBytes())); // getaddrinfo doesn't support aliases - PList aliases = factory.createList(); + PList aliases = PFactory.createList(context.getLanguage(inliningTarget)); // we support just one address for now - PList addrs = factory.createList(new Object[]{addr}); - return factory.createTuple(new Object[]{canonName, aliases, addrs}); + PList addrs = PFactory.createList(context.getLanguage(inliningTarget), new Object[]{addr}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{canonName, aliases, addrs}); } finally { addrInfoCursorLib.release(cursor); } @@ -424,7 +421,8 @@ public abstract static class GetServByNameNode extends PythonBinaryClinicBuiltin static Object getServByName(TruffleString serviceName, Object protocolNameObj, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile noneProtocol, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") AddrInfoCursorLibrary addrInfoCursorLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary sockAddrLibrary, @Cached TruffleString.ToJavaStringNode toJavaStringNode, @@ -454,7 +452,7 @@ static Object getServByName(TruffleString serviceName, Object protocolNameObj, gil.release(true); AddrInfoCursor cursor; try { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); cursor = posixLib.getaddrinfo(posixSupport, null, posixLib.createPathFromString(posixSupport, serviceName), AF_INET.value, 0, protocol, 0); } finally { gil.acquire(); @@ -550,7 +548,8 @@ public abstract static class GetNameInfoNode extends PythonBinaryClinicBuiltinNo @Specialization static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") AddrInfoCursorLibrary addrInfoCursorLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary sockAddrLibrary, @Cached GilNode gil, @@ -560,7 +559,6 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached TruffleString.FromLongNode fromLongNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { SequenceStorage addr = sockaddr.getSequenceStorage(); int addrLen = addr.length(); @@ -593,7 +591,7 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, int family; // TODO getaddrinfo lock? gil.release(true); - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); try { AddrInfoCursor cursor = posixLib.getaddrinfo(posixSupport, posixLib.createPathFromString(posixSupport, address), posixLib.createPathFromString(posixSupport, fromLongNode.execute(port, TS_ENCODING, false)), @@ -626,7 +624,7 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, Object[] getnameinfo = posixLib.getnameinfo(posixSupport, queryAddr, flags); TruffleString host = posixLib.getPathAsString(posixSupport, getnameinfo[0]); TruffleString service = posixLib.getPathAsString(posixSupport, getnameinfo[1]); - return factory.createTuple(new Object[]{host, service}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{host, service}); } catch (GetAddrInfoException e) { throw constructAndRaiseNode.get(inliningTarget).executeWithArgsOnly(frame, SocketGAIError, new Object[]{e.getErrorCode(), e.getMessageAsTruffleString()}); } @@ -655,7 +653,8 @@ public abstract static class GetAddrInfoNode extends PythonClinicBuiltinNode { @Specialization static Object getAddrInfo(VirtualFrame frame, Object hostObject, Object portObject, int family, int type, int proto, int flags, @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") AddrInfoCursorLibrary cursorLib, @Cached InlinedExactClassProfile profile, @Cached("createIdna()") IdnaFromStringOrBytesConverterNode idna, @@ -668,10 +667,9 @@ static Object getAddrInfo(VirtualFrame frame, Object hostObject, Object portObje @Cached SequenceStorageNodes.AppendNode appendNode, @Cached TruffleString.FromLongNode fromLongNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { Object host = null; - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); if (hostObject != PNone.NONE) { host = posixLib.createPathFromBytes(posixSupport, idna.execute(frame, hostObject)); } @@ -712,10 +710,11 @@ static Object getAddrInfo(VirtualFrame frame, Object hostObject, Object portObje if (cursorLib.getCanonName(cursor) != null) { canonName = posixLib.getPathAsString(posixSupport, cursorLib.getCanonName(cursor)); } - PTuple tuple = factory.createTuple(new Object[]{cursorLib.getFamily(cursor), cursorLib.getSockType(cursor), cursorLib.getProtocol(cursor), canonName, addr}); + PTuple tuple = PFactory.createTuple(context.getLanguage(inliningTarget), + new Object[]{cursorLib.getFamily(cursor), cursorLib.getSockType(cursor), cursorLib.getProtocol(cursor), canonName, addr}); storage = appendNode.execute(inliningTarget, storage, tuple, SequenceStorageNodes.ListGeneralizationNode.SUPPLIER); } while (cursorLib.next(cursor)); - return factory.createList(storage); + return PFactory.createList(context.getLanguage(inliningTarget), storage); } finally { cursorLib.release(cursor); } @@ -736,8 +735,9 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class CloseNode extends PythonUnaryBuiltinNode { @Specialization - Object close(VirtualFrame frame, Object fdObj, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object close(VirtualFrame frame, Object fdObj, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached GilNode gil, @Cached PyLongAsIntNode asIntNode, @@ -746,7 +746,7 @@ Object close(VirtualFrame frame, Object fdObj, try { gil.release(true); try { - posixLib.close(getPosixSupport(), fd); + posixLib.close(context.getPosixSupport(), fd); } finally { gil.acquire(); } @@ -764,8 +764,9 @@ Object close(VirtualFrame frame, Object fdObj, @GenerateNodeFactory abstract static class DupNode extends PythonUnaryBuiltinNode { @Specialization - Object close(VirtualFrame frame, Object fdObj, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object close(VirtualFrame frame, Object fdObj, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached GilNode gil, @Cached PyLongAsIntNode asIntNode, @@ -774,12 +775,12 @@ Object close(VirtualFrame frame, Object fdObj, try { gil.release(true); try { - int dup = posixLib.dup(getPosixSupport(), fd); + int dup = posixLib.dup(context.getPosixSupport(), fd); try { - posixLib.setInheritable(getPosixSupport(), dup, false); + posixLib.setInheritable(context.getPosixSupport(), dup, false); } catch (PosixException e1) { try { - posixLib.close(getPosixSupport(), dup); + posixLib.close(context.getPosixSupport(), dup); } catch (PosixException e2) { // ignore } @@ -801,15 +802,15 @@ abstract static class InetAtoNNode extends PythonUnaryClinicBuiltinNode { @Specialization static PBytes doConvert(TruffleString addr, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PythonObjectFactory factory, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PRaiseNode.Lazy raiseNode) { try { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); int converted = posixLib.inet_aton(posixSupport, posixLib.createPathFromString(posixSupport, addr)); byte[] bytes = new byte[4]; ByteArraySupport.bigEndian().putInt(bytes, 0, converted); - return factory.createBytes(bytes); + return PFactory.createBytes(context.getLanguage(inliningTarget), bytes); } catch (PosixSupportLibrary.InvalidAddressException e) { throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.ILLEGAL_IP_ADDR_STRING_TO_INET_ATON); } @@ -830,7 +831,8 @@ static TruffleString doGeneric(VirtualFrame frame, Object addr, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("addr") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PRaiseNode.Lazy raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(addr, frame, indirectCallData); try { @@ -839,7 +841,7 @@ static TruffleString doGeneric(VirtualFrame frame, Object addr, if (len != 4) { throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.PACKED_IP_WRONG_LENGTH, "inet_ntoa"); } - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); Object result = posixLib.inet_ntoa(posixSupport, ByteArraySupport.bigEndian().getInt(bytes, 0)); return posixLib.getPathAsString(posixSupport, result); } finally { @@ -856,14 +858,14 @@ abstract static class InetPtoNNode extends PythonBinaryClinicBuiltinNode { @Specialization static PBytes doConvert(VirtualFrame frame, int family, TruffleString addr, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); byte[] bytes = posixLib.inet_pton(posixSupport, family, posixLib.createPathFromString(posixSupport, addr)); - return factory.createBytes(bytes); + return PFactory.createBytes(context.getLanguage(inliningTarget), bytes); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } catch (PosixSupportLibrary.InvalidAddressException e) { @@ -887,7 +889,8 @@ static TruffleString doGeneric(VirtualFrame frame, int family, Object obj, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("obj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(obj, frame, indirectCallData); @@ -906,7 +909,7 @@ static TruffleString doGeneric(VirtualFrame frame, int family, Object obj, throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNKNOWN_ADDR_FAMILY, family); } try { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); Object result = posixLib.inet_ntop(posixSupport, family, bytes); return posixLib.getPathAsString(posixSupport, result); } catch (PosixException e) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StringModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StringModuleBuiltins.java index 14abb5dd33..92086f7152 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StringModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StringModuleBuiltins.java @@ -59,7 +59,7 @@ import com.oracle.graal.python.runtime.ExecutionContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -85,8 +85,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization PSequenceIterator formatterParser(VirtualFrame frame, TruffleString self, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PythonObjectFactory factory) { + @Cached("createFor(this)") IndirectCallData indirectCallData) { TemplateFormatter formatter = new TemplateFormatter(self); List parserList; PythonContext context = PythonContext.get(this); @@ -97,16 +96,16 @@ PSequenceIterator formatterParser(VirtualFrame frame, TruffleString self, } finally { ExecutionContext.IndirectCallContext.exit(frame, language, context, state); } - return parserListToIterator(parserList, factory); + return parserListToIterator(parserList, language); } } - private static PSequenceIterator parserListToIterator(List parserList, PythonObjectFactory factory) { + private static PSequenceIterator parserListToIterator(List parserList, PythonLanguage language) { Object[] tuples = new Object[parserList.size()]; for (int i = 0; i < tuples.length; i++) { - tuples[i] = factory.createTuple(parserList.get(i)); + tuples[i] = PFactory.createTuple(language, parserList.get(i)); } - return factory.createSequenceIterator(factory.createList(tuples)); + return PFactory.createSequenceIterator(language, PFactory.createList(language, tuples)); } @Builtin(name = J_FORMATTER_FIELD_NAME_SPLIT, minNumOfPositionalArgs = 1, parameterNames = {"self"}) @@ -120,8 +119,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization Object formatterParser(VirtualFrame frame, TruffleString self, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PythonObjectFactory factory) { + @Cached("createFor(this)") IndirectCallData indirectCallData) { TemplateFormatter formatter = new TemplateFormatter(self); TemplateFormatter.FieldNameSplitResult result; PythonContext context = PythonContext.get(this); @@ -132,7 +130,7 @@ Object formatterParser(VirtualFrame frame, TruffleString self, } finally { ExecutionContext.IndirectCallContext.exit(frame, language, context, state); } - return factory.createTuple(new Object[]{result.first, parserListToIterator(result.parserList, factory)}); + return PFactory.createTuple(language, new Object[]{result.first, parserListToIterator(result.parserList, language)}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java index 55787472b2..d70b4ad778 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java @@ -1,13 +1,10 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 */ package com.oracle.graal.python.builtins.modules; -import static com.oracle.graal.python.nodes.ErrorMessages.ARG_MUST_BE_STR_OR_BYTES; -import static com.oracle.graal.python.nodes.ErrorMessages.BAD_CHR_IN_STRUCT_FMT; -import static com.oracle.graal.python.nodes.ErrorMessages.REPEAT_COUNT_WITHOUT_FMT; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_BOOL; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_CHAR; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_DOUBLE; @@ -52,7 +49,10 @@ import static com.oracle.graal.python.builtins.objects.struct.FormatCode.T_LBL_VOID_PTR; import static com.oracle.graal.python.nodes.BuiltinNames.J__STRUCT; import static com.oracle.graal.python.nodes.BuiltinNames.T__STRUCT; +import static com.oracle.graal.python.nodes.ErrorMessages.ARG_MUST_BE_STR_OR_BYTES; +import static com.oracle.graal.python.nodes.ErrorMessages.BAD_CHR_IN_STRUCT_FMT; import static com.oracle.graal.python.nodes.ErrorMessages.EMBEDDED_NULL_CHARACTER; +import static com.oracle.graal.python.nodes.ErrorMessages.REPEAT_COUNT_WITHOUT_FMT; import static com.oracle.graal.python.runtime.exception.PythonErrorType.StructError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -63,6 +63,7 @@ import java.util.List; import java.util.Set; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -80,7 +81,6 @@ import com.oracle.graal.python.builtins.objects.struct.FormatDef; import com.oracle.graal.python.builtins.objects.struct.PStruct; import com.oracle.graal.python.builtins.objects.struct.StructBuiltins; -import com.oracle.graal.python.util.LRUCache; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; @@ -93,7 +93,8 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.graal.python.util.LRUCache; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -235,10 +236,9 @@ static PStruct struct(@SuppressWarnings("unused") Object cls, TruffleString form @Bind("this") Node inliningTarget, @Shared @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @SuppressWarnings("unused") @Shared @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, - @Shared @Cached PythonObjectFactory factory) { + @SuppressWarnings("unused") @Shared @Cached TruffleString.GetCodeRangeNode getCodeRangeNode) { byte[] fmt = PythonUtils.getAsciiBytes(format, copyToByteArrayNode, switchEncodingNode); - return factory.createStruct(createStructInternal(inliningTarget, fmt)); + return PFactory.createStruct(PythonLanguage.get(inliningTarget), createStructInternal(inliningTarget, fmt)); } @Specialization @@ -247,18 +247,16 @@ static PStruct struct(Object cls, PString format, @Cached CastToTruffleStringNode castToTruffleStringNode, @Shared @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @SuppressWarnings("unused") @Shared @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, - @Shared @Cached PythonObjectFactory factory) { - return struct(cls, castToTruffleStringNode.execute(inliningTarget, format), inliningTarget, copyToByteArrayNode, switchEncodingNode, getCodeRangeNode, factory); + @SuppressWarnings("unused") @Shared @Cached TruffleString.GetCodeRangeNode getCodeRangeNode) { + return struct(cls, castToTruffleStringNode.execute(inliningTarget, format), inliningTarget, copyToByteArrayNode, switchEncodingNode, getCodeRangeNode); } @Specialization(limit = "1") static PStruct struct(@SuppressWarnings("unused") Object cls, PBytes format, @Bind("this") Node inliningTarget, - @CachedLibrary("format") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory) { + @CachedLibrary("format") PythonBufferAccessLibrary bufferLib) { byte[] fmt = bufferLib.getCopiedByteArray(format); - return factory.createStruct(createStructInternal(inliningTarget, fmt)); + return PFactory.createStruct(PythonLanguage.get(inliningTarget), createStructInternal(inliningTarget, fmt)); } @Specialization(guards = {"!isPBytes(format)", "!isPString(format)", "!isAsciiTruffleString(format, getCodeRangeNode)"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java index d33bfc47fd..ef559ae7f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java @@ -230,7 +230,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.formatting.IntegerFormatter; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.CharsetMapping; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -507,8 +507,8 @@ protected List> getNodeFa return SysModuleBuiltinsFactory.getFactories(); } - protected static PSimpleNamespace makeImplementation(PythonObjectFactory factory, PTuple versionInfo, TruffleString gmultiarch) { - final PSimpleNamespace ns = factory.createSimpleNamespace(); + private static PSimpleNamespace makeImplementation(PythonLanguage language, PTuple versionInfo, TruffleString gmultiarch) { + final PSimpleNamespace ns = PFactory.createSimpleNamespace(language); ns.setAttribute(tsLiteral("name"), T_GRAALPYTHON_ID); /*- 'cache_tag' must match the format of mx.graalpython/mx_graalpython.py:graalpy_ext */ ns.setAttribute(T_CACHE_TAG, toTruffleStringUncached(J_GRAALPYTHON_ID + @@ -522,6 +522,7 @@ protected static PSimpleNamespace makeImplementation(PythonObjectFactory factory @Override public void initialize(Python3Core core) { + PythonLanguage language = core.getLanguage(); StructSequence.initType(core, VERSION_INFO_DESC); if (PythonOS.getPythonOS() == PLATFORM_WIN32) { StructSequence.initType(core, WINDOWS_VER_DESC); @@ -536,19 +537,18 @@ public void initialize(Python3Core core) { addBuiltinConstant("abiflags", T_EMPTY_STRING); addBuiltinConstant("byteorder", ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? T_LITTLE : T_BIG); addBuiltinConstant("copyright", T_LICENSE); - final PythonObjectFactory factory = PythonObjectFactory.getUncached(); - addBuiltinConstant(T_MODULES, factory.createDict()); - addBuiltinConstant("path", factory.createList()); - addBuiltinConstant("builtin_module_names", factory.createTuple(core.builtinModuleNames())); + addBuiltinConstant(T_MODULES, PFactory.createDict(language)); + addBuiltinConstant("path", PFactory.createList(language)); + addBuiltinConstant("builtin_module_names", PFactory.createTuple(language, core.builtinModuleNames())); addBuiltinConstant("maxsize", MAXSIZE); - final PTuple versionInfo = factory.createStructSeq(VERSION_INFO_DESC, PythonLanguage.MAJOR, PythonLanguage.MINOR, PythonLanguage.MICRO, PythonLanguage.RELEASE_LEVEL_STRING, + final PTuple versionInfo = PFactory.createStructSeq(language, VERSION_INFO_DESC, PythonLanguage.MAJOR, PythonLanguage.MINOR, PythonLanguage.MICRO, PythonLanguage.RELEASE_LEVEL_STRING, PythonLanguage.RELEASE_SERIAL); addBuiltinConstant("version_info", versionInfo); addBuiltinConstant("api_version", PythonLanguage.API_VERSION); addBuiltinConstant("version", toTruffleStringUncached(PythonLanguage.VERSION + " (" + COMPILE_TIME + ")" + "\n[Graal, " + Truffle.getRuntime().getName() + ", Java " + System.getProperty("java.version") + " (" + System.getProperty("os.arch") + ")]")); - addBuiltinConstant("float_info", factory.createStructSeq(FLOAT_INFO_DESC, + addBuiltinConstant("float_info", PFactory.createStructSeq(language, FLOAT_INFO_DESC, Double.MAX_VALUE, // DBL_MAX Double.MAX_EXPONENT + 1, // DBL_MAX_EXP 308, // DBL_MIN_10_EXP @@ -561,8 +561,8 @@ public void initialize(Python3Core core) { 2, // FLT_RADIX 1 // FLT_ROUNDS )); - addBuiltinConstant("int_info", factory.createStructSeq(INT_INFO_DESC, 32, 4, INT_DEFAULT_MAX_STR_DIGITS, INT_MAX_STR_DIGITS_THRESHOLD)); - addBuiltinConstant("hash_info", factory.createStructSeq(HASH_INFO_DESC, + addBuiltinConstant("int_info", PFactory.createStructSeq(language, INT_INFO_DESC, 32, 4, INT_DEFAULT_MAX_STR_DIGITS, INT_MAX_STR_DIGITS_THRESHOLD)); + addBuiltinConstant("hash_info", PFactory.createStructSeq(language, HASH_INFO_DESC, 64, // width HASH_MODULUS, // modulus HASH_INF, // inf @@ -573,7 +573,7 @@ public void initialize(Python3Core core) { 0, // seed_bits 0 // cutoff )); - addBuiltinConstant("thread_info", factory.createStructSeq(THREAD_INFO_DESC, PNone.NONE, PNone.NONE, PNone.NONE)); + addBuiltinConstant("thread_info", PFactory.createStructSeq(language, THREAD_INFO_DESC, PNone.NONE, PNone.NONE, PNone.NONE)); addBuiltinConstant("maxunicode", IntegerFormatter.LIMIT_UNICODE.intValue() - 1); PythonOS os = getPythonOS(); @@ -589,7 +589,7 @@ public void initialize(Python3Core core) { addBuiltinConstant(T_STDOUT, PNone.NONE); addBuiltinConstant(T_STDERR, PNone.NONE); - addBuiltinConstant("implementation", makeImplementation(factory, versionInfo, gmultiarch)); + addBuiltinConstant("implementation", makeImplementation(language, versionInfo, gmultiarch)); addBuiltinConstant("hexversion", PythonLanguage.VERSION_HEX); if (os == PLATFORM_WIN32) { @@ -597,9 +597,9 @@ public void initialize(Python3Core core) { } addBuiltinConstant("float_repr_style", "short"); - addBuiltinConstant("meta_path", factory.createList()); - addBuiltinConstant("path_hooks", factory.createList()); - addBuiltinConstant("path_importer_cache", factory.createDict()); + addBuiltinConstant("meta_path", PFactory.createList(language)); + addBuiltinConstant("path_hooks", PFactory.createList(language)); + addBuiltinConstant("path_importer_cache", PFactory.createDict(language)); // default prompt for interactive shell addBuiltinConstant("ps1", ">>> "); @@ -607,7 +607,7 @@ public void initialize(Python3Core core) { addBuiltinConstant("ps2", "... "); // CPython builds for distros report empty strings too, because they are built from // tarballs, not git - addBuiltinConstant("_git", factory.createTuple(new Object[]{T_GRAALPYTHON_ID, T_EMPTY_STRING, T_EMPTY_STRING})); + addBuiltinConstant("_git", PFactory.createTuple(language, new Object[]{T_GRAALPYTHON_ID, T_EMPTY_STRING, T_EMPTY_STRING})); if (PythonOS.getPythonOS() == PLATFORM_WIN32) { addBuiltinConstant("_vpath", ""); @@ -623,12 +623,12 @@ public void postInitialize0(Python3Core core) { super.postInitialize(core); PythonModule sys = core.lookupBuiltinModule(T_SYS); PythonContext context = core.getContext(); + PythonLanguage language = core.getLanguage(); String[] args = context.getEnv().getApplicationArguments(); - final PythonObjectFactory factory = PythonObjectFactory.getUncached(); - sys.setAttribute(tsLiteral("argv"), factory.createList(convertToObjectArray(args))); - sys.setAttribute(tsLiteral("orig_argv"), factory.createList(convertToObjectArray(PythonOptions.getOrigArgv(core.getContext())))); + sys.setAttribute(tsLiteral("argv"), PFactory.createList(language, convertToObjectArray(args))); + sys.setAttribute(tsLiteral("orig_argv"), PFactory.createList(language, convertToObjectArray(PythonOptions.getOrigArgv(core.getContext())))); - sys.setAttribute(tsLiteral("stdlib_module_names"), createStdLibModulesSet(factory)); + sys.setAttribute(tsLiteral("stdlib_module_names"), createStdLibModulesSet(language)); TruffleString prefix = context.getSysPrefix(); for (TruffleString name : SysModuleBuiltins.SYS_PREFIX_ATTRIBUTES) { @@ -666,7 +666,7 @@ public void postInitialize0(Python3Core core) { } else { warnoptions = PythonUtils.EMPTY_OBJECT_ARRAY; } - sys.setAttribute(tsLiteral("warnoptions"), factory.createList(warnoptions)); + sys.setAttribute(tsLiteral("warnoptions"), PFactory.createList(language, warnoptions)); Env env = context.getEnv(); TruffleString pythonPath = context.getOption(PythonOptions.PythonPath); @@ -695,9 +695,9 @@ public void postInitialize0(Python3Core core) { // include our native modules on the path path[pathIdx++] = toTruffleStringUncached(capiHome + env.getFileNameSeparator() + "modules"); } - PList sysPaths = factory.createList(path); + PList sysPaths = PFactory.createList(language, path); sys.setAttribute(tsLiteral("path"), sysPaths); - sys.setAttribute(tsLiteral("flags"), factory.createStructSeq(SysModuleBuiltins.FLAGS_DESC, + sys.setAttribute(tsLiteral("flags"), PFactory.createStructSeq(language, SysModuleBuiltins.FLAGS_DESC, PInt.intValue(!context.getOption(PythonOptions.PythonOptimizeFlag)), // debug PInt.intValue(context.getOption(PythonOptions.InspectFlag)), // inspect PInt.intValue(context.getOption(PythonOptions.TerminalIsInteractive)), // interactive @@ -723,18 +723,18 @@ public void postInitialize0(Python3Core core) { sys.setAttribute(T___BREAKPOINTHOOK__, sys.getAttribute(T_BREAKPOINTHOOK)); } - private static PFrozenSet createStdLibModulesSet(PythonObjectFactory factory) { + private static PFrozenSet createStdLibModulesSet(PythonLanguage language) { EconomicMapStorage storage = EconomicMapStorage.create(STDLIB_MODULE_NAMES.length); for (String s : STDLIB_MODULE_NAMES) { storage.putUncachedWithJavaEq(s, PNone.NONE); } - return factory.createFrozenSet(storage); + return PFactory.createFrozenSet(language, storage); } /** * Like {@link PythonUtils#toTruffleStringArrayUncached(String[])}, but creates an array of * {@link Object}'s. The intended use of this method is in slow-path in calls to methods like - * {@link PythonObjectFactory#createTuple(Object[])}. + * {@link PFactory#createTuple}. */ private static Object[] convertToObjectArray(String[] src) { if (src == null) { @@ -765,8 +765,8 @@ public void postInitialize(Python3Core core) { @TruffleBoundary static void initStd(Python3Core core) { - PythonObjectFactory factory = core.factory(); PythonContext context = core.getContext(); + PythonLanguage language = core.getLanguage(); // wrap std in/out/err GraalPythonModuleBuiltins gp = (GraalPythonModuleBuiltins) core.lookupBuiltinModule(T___GRAALPYTHON__).getBuiltins(); @@ -779,35 +779,35 @@ static void initStd(Python3Core core) { // Note that stdin is always buffered, this only applies to stdout and stderr boolean buffering = !context.getOption(PythonOptions.UnbufferedIO); - PFileIO stdinFileIO = factory.createFileIO(PythonBuiltinClassType.PFileIO); + PFileIO stdinFileIO = PFactory.createFileIO(language); FileIOBuiltins.FileIOInit.internalInit(stdinFileIO, toTruffleStringUncached(""), 0, IOMode.RB); - PBuffered stdinBuffer = factory.createBufferedReader(PythonBuiltinClassType.PBufferedReader); - BufferedReaderBuiltins.BufferedReaderInit.internalInit(stdinBuffer, stdinFileIO, BufferedReaderBuiltins.DEFAULT_BUFFER_SIZE, factory, posixSupport, posixLib); - setWrapper(T_STDIN, T___STDIN__, T_R, stdioEncoding, stdioError, stdinBuffer, sysModule, factory, true); + PBuffered stdinBuffer = PFactory.createBufferedReader(language); + BufferedReaderBuiltins.BufferedReaderInit.internalInit(stdinBuffer, stdinFileIO, BufferedReaderBuiltins.DEFAULT_BUFFER_SIZE, language, posixSupport, posixLib); + setWrapper(T_STDIN, T___STDIN__, T_R, stdioEncoding, stdioError, stdinBuffer, sysModule, language, true); - PFileIO stdoutFileIO = factory.createFileIO(PythonBuiltinClassType.PFileIO); + PFileIO stdoutFileIO = PFactory.createFileIO(language); FileIOBuiltins.FileIOInit.internalInit(stdoutFileIO, toTruffleStringUncached(""), 1, IOMode.WB); - Object stdoutBuffer = createBufferedIO(buffering, factory, stdoutFileIO, posixSupport, posixLib); - setWrapper(T_STDOUT, T___STDOUT__, T_W, stdioEncoding, stdioError, stdoutBuffer, sysModule, factory, buffering); + Object stdoutBuffer = createBufferedIO(buffering, language, stdoutFileIO, posixSupport, posixLib); + setWrapper(T_STDOUT, T___STDOUT__, T_W, stdioEncoding, stdioError, stdoutBuffer, sysModule, language, buffering); - PFileIO stderr = factory.createFileIO(PythonBuiltinClassType.PFileIO); + PFileIO stderr = PFactory.createFileIO(language); FileIOBuiltins.FileIOInit.internalInit(stderr, toTruffleStringUncached(""), 2, IOMode.WB); - Object stderrBuffer = createBufferedIO(buffering, factory, stderr, posixSupport, posixLib); - setWrapper(T_STDERR, T___STDERR__, T_W, stdioEncoding, T_BACKSLASHREPLACE, stderrBuffer, sysModule, factory, buffering); + Object stderrBuffer = createBufferedIO(buffering, language, stderr, posixSupport, posixLib); + setWrapper(T_STDERR, T___STDERR__, T_W, stdioEncoding, T_BACKSLASHREPLACE, stderrBuffer, sysModule, language, buffering); } - private static Object createBufferedIO(boolean buffering, PythonObjectFactory factory, PFileIO fileIo, Object posixSupport, PosixSupportLibrary posixLib) { + private static Object createBufferedIO(boolean buffering, PythonLanguage language, PFileIO fileIo, Object posixSupport, PosixSupportLibrary posixLib) { if (!buffering) { return fileIo; } - PBuffered writer = factory.createBufferedWriter(PythonBuiltinClassType.PBufferedWriter); - BufferedWriterBuiltins.BufferedWriterInit.internalInit(writer, fileIo, BufferedReaderBuiltins.DEFAULT_BUFFER_SIZE, factory, posixSupport, posixLib); + PBuffered writer = PFactory.createBufferedWriter(language); + BufferedWriterBuiltins.BufferedWriterInit.internalInit(writer, fileIo, BufferedReaderBuiltins.DEFAULT_BUFFER_SIZE, language, posixSupport, posixLib); return writer; } private static PTextIO setWrapper(TruffleString name, TruffleString specialName, TruffleString mode, TruffleString encoding, TruffleString error, Object buffer, PythonModule sysModule, - PythonObjectFactory factory, boolean buffering) { - PTextIO textIOWrapper = factory.createTextIO(PythonBuiltinClassType.PTextIOWrapper); + PythonLanguage language, boolean buffering) { + PTextIO textIOWrapper = PFactory.createTextIO(language); TextIOWrapperInitNodeGen.getUncached().execute(null, null, textIOWrapper, buffer, encoding, error, PNone.NONE, /* line_buffering */ buffering, /* write_through */ !buffering); @@ -850,15 +850,15 @@ static PTuple run(VirtualFrame frame, @Cached GetEscapedExceptionNode getEscapedExceptionNode, @Cached GetCaughtExceptionNode getCaughtExceptionNode, @Cached ExceptionNodes.GetTracebackNode getTracebackNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { AbstractTruffleException currentException = getCaughtExceptionNode.execute(frame); assert currentException != PException.NO_EXCEPTION; if (currentException == null) { - return factory.createTuple(new PNone[]{PNone.NONE, PNone.NONE, PNone.NONE}); + return PFactory.createTuple(language, new PNone[]{PNone.NONE, PNone.NONE, PNone.NONE}); } else { Object exceptionObject = getEscapedExceptionNode.execute(inliningTarget, currentException); Object traceback = getTracebackNode.execute(inliningTarget, exceptionObject); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, exceptionObject), exceptionObject, traceback}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, exceptionObject), exceptionObject, traceback}); } } } @@ -925,13 +925,13 @@ Object currentFrames(VirtualFrame frame, @Cached WarningsModuleBuiltins.WarnNode warnNode, @Cached ReadCallerFrameNode readCallerFrameNode, @Cached HashingStorageSetItem setHashingStorageItem, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { auditNode.audit(inliningTarget, "sys._current_frames"); if (!getLanguage().singleThreadedAssumption.isValid()) { warnNode.warn(frame, RuntimeWarning, ErrorMessages.WARN_CURRENT_FRAMES_MULTITHREADED); } PFrame currentFrame = readCallerFrameNode.executeWith(frame, 0); - PDict result = factory.createDict(); + PDict result = PFactory.createDict(language); result.setDictStorage(setHashingStorageItem.execute(frame, inliningTarget, result.getDictStorage(), PThread.getThreadId(Thread.currentThread()), currentFrame)); return result; } @@ -1222,11 +1222,11 @@ abstract static class GetAsyncgenHooks extends PythonBuiltinNode { static Object setAsyncgenHooks( @Bind("this") Node inliningTarget, @Bind PythonContext context, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // TODO: use asyncgen_hooks object PythonContext.PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); Object firstiter = threadState.getAsyncgenFirstIter(); - return factory.createTuple(new Object[]{firstiter == null ? PNone.NONE : firstiter, PNone.NONE}); + return PFactory.createTuple(language, new Object[]{firstiter == null ? PNone.NONE : firstiter, PNone.NONE}); } } @@ -2058,14 +2058,15 @@ abstract static class Getwindowsversion extends PythonBuiltinNode { static int PLATFORM = 2; @Specialization - PTuple getVersion(@Cached PythonObjectFactory factory) { + PTuple getVersion( + @Bind PythonLanguage language) { if (CACHED_VERSION_INFO == null) { cacheVersion(); } - return factory.createStructSeq(WINDOWS_VER_DESC, + return PFactory.createStructSeq(language, WINDOWS_VER_DESC, CACHED_VERSION_INFO[0], CACHED_VERSION_INFO[1], CACHED_VERSION_INFO[2], PLATFORM, T_EMPTY_STRING, 0, 0, 0, 1, - factory.createTuple(CACHED_VERSION_INFO)); + PFactory.createTuple(language, CACHED_VERSION_INFO)); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java index 8a50577f63..59a4cad38c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -49,6 +49,7 @@ import java.lang.ref.WeakReference; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -62,6 +63,7 @@ import com.oracle.graal.python.builtins.objects.thread.PRLock; import com.oracle.graal.python.builtins.objects.thread.PThread; import com.oracle.graal.python.builtins.objects.thread.PThreadLocal; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.WriteUnraisableNode; @@ -80,7 +82,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonThreadKillException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleThreadBuilder; @@ -115,8 +117,9 @@ public void initialize(Python3Core core) { abstract static class ThreadLocalNode extends PythonBuiltinNode { @Specialization PThreadLocal construct(Object cls, Object[] args, PKeyword[] keywordArgs, - @Cached PythonObjectFactory factory) { - return factory.createThreadLocal(cls, args, keywordArgs); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createThreadLocal(language, cls, getInstanceShape.execute(cls), args, keywordArgs); } } @@ -126,8 +129,8 @@ public abstract static class AllocateLockNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") PLock construct(Object self, Object unused, - @Cached PythonObjectFactory factory) { - return factory.createLock(PythonBuiltinClassType.PLock); + @Bind PythonLanguage language) { + return PFactory.createLock(language); } } @@ -136,8 +139,9 @@ PLock construct(Object self, Object unused, abstract static class ConstructLockNode extends PythonUnaryBuiltinNode { @Specialization PLock construct(Object cls, - @Cached PythonObjectFactory factory) { - return factory.createLock(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createLock(language, cls, getInstanceShape.execute(cls)); } } @@ -146,8 +150,9 @@ PLock construct(Object cls, abstract static class ConstructRLockNode extends PythonUnaryBuiltinNode { @Specialization PRLock construct(Object cls, - @Cached PythonObjectFactory factory) { - return factory.createRLock(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createRLock(language, cls, getInstanceShape.execute(cls)); } } @@ -211,12 +216,11 @@ abstract static class StartNewThreadNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("try") - long start(VirtualFrame frame, Object cls, Object callable, Object args, Object kwargs, + long start(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object callable, Object args, Object kwargs, @Bind("this") Node inliningTarget, @Cached CallNode callNode, @Cached ExecutePositionalStarargsNode getArgsNode, - @Cached ExpandKeywordStarargsNode getKwArgsNode, - @Cached PythonObjectFactory factory) { + @Cached ExpandKeywordStarargsNode getKwArgsNode) { PythonContext context = getContext(); TruffleLanguage.Env env = context.getEnv(); PythonModule threadModule = context.lookupBuiltinModule(T__THREAD); @@ -252,7 +256,7 @@ long start(VirtualFrame frame, Object cls, Object callable, Object args, Object } }).context(env.getContext()).threadGroup(context.getThreadGroup()); - PThread pThread = factory.createPythonThread(cls, threadBuilder.build()); + PThread pThread = PFactory.createPythonThread(PythonLanguage.get(inliningTarget), threadBuilder.build()); pThread.start(); return pThread.getId(); } @@ -264,8 +268,9 @@ abstract static class SetSentinelNode extends PythonBuiltinNode { @Specialization @TruffleBoundary Object setSentinel() { - PLock sentinelLock = PythonObjectFactory.getUncached().createLock(); - PythonContext.get(this).setSentinelLockWeakref(new WeakReference<>(sentinelLock)); + PythonContext context = PythonContext.get(null); + PLock sentinelLock = PFactory.createLock(context.getLanguage()); + context.setSentinelLockWeakref(new WeakReference<>(sentinelLock)); return sentinelLock; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java index 6eec222635..043be4b730 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java @@ -52,6 +52,7 @@ import com.oracle.graal.python.nodes.statement.AbstractImportNode; import org.graalvm.nativeimage.ImageInfo; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -92,7 +93,7 @@ import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleSafepoint; @@ -185,9 +186,9 @@ public void postInitialize(Python3Core core) { boolean hasDaylightSaving = !noDaylightSavingZone.equalsUncached(daylightSavingZone, TS_ENCODING); if (hasDaylightSaving) { - timeModule.setAttribute(T_TZNAME, core.factory().createTuple(new Object[]{noDaylightSavingZone, daylightSavingZone})); + timeModule.setAttribute(T_TZNAME, PFactory.createTuple(core.getLanguage(), new Object[]{noDaylightSavingZone, daylightSavingZone})); } else { - timeModule.setAttribute(T_TZNAME, core.factory().createTuple(new Object[]{noDaylightSavingZone})); + timeModule.setAttribute(T_TZNAME, PFactory.createTuple(core.getLanguage(), new Object[]{noDaylightSavingZone})); } timeModule.setAttribute(T_DAYLIGHT, PInt.intValue(hasDaylightSaving)); @@ -318,8 +319,8 @@ public abstract static class PythonGMTimeNode extends PythonBuiltinNode { static PTuple gmtime(VirtualFrame frame, Object seconds, @Bind("this") Node inliningTarget, @Cached ToLongTime toLongTime, - @Cached PythonObjectFactory factory) { - return factory.createStructSeq(STRUCT_TIME_DESC, getTimeStruct(GMT, toLongTime.execute(frame, inliningTarget, seconds))); + @Bind PythonLanguage language) { + return PFactory.createStructSeq(language, STRUCT_TIME_DESC, getTimeStruct(GMT, toLongTime.execute(frame, inliningTarget, seconds))); } } @@ -354,9 +355,9 @@ public abstract static class PythonLocalTimeNode extends PythonBinaryBuiltinNode static PTuple localtime(VirtualFrame frame, PythonModule module, Object seconds, @Bind("this") Node inliningTarget, @Cached ToLongTime toLongTime, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ModuleState moduleState = module.getModuleState(ModuleState.class); - return factory.createStructSeq(STRUCT_TIME_DESC, getTimeStruct(moduleState.currentZoneId, toLongTime.execute(frame, inliningTarget, seconds))); + return PFactory.createStructSeq(language, STRUCT_TIME_DESC, getTimeStruct(moduleState.currentZoneId, toLongTime.execute(frame, inliningTarget, seconds))); } } @@ -1113,7 +1114,7 @@ static Object getClockInfo(TruffleString name, @Bind("this") Node inliningTarget, @Cached WriteAttributeToPythonObjectNode writeAttrNode, @Cached TruffleString.EqualNode equalNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { final boolean adjustable; final boolean monotonic; @@ -1129,7 +1130,7 @@ static Object getClockInfo(TruffleString name, throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, UNKNOWN_CLOCK); } - final PSimpleNamespace ns = factory.createSimpleNamespace(); + final PSimpleNamespace ns = PFactory.createSimpleNamespace(language); writeAttrNode.execute(ns, T_ADJUSTABLE, adjustable); writeAttrNode.execute(ns, T_IMPLEMENTATION, name); writeAttrNode.execute(ns, T_MONOTONIC, monotonic); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TokenizeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TokenizeModuleBuiltins.java index 5edfab4e64..c7f3c99d29 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TokenizeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TokenizeModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -53,7 +54,8 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -79,10 +81,10 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - static PTokenizerIter tokenizerIter(Object cls, TruffleString source, - @Cached TruffleString.ToJavaStringNode toJavaStringNode, - @Cached PythonObjectFactory factory) { - return factory.createTokenizerIter(cls, toJavaStringNode.execute(source)); + static PTokenizerIter tokenizerIter(@SuppressWarnings("unused") Object cls, TruffleString source, + @Bind PythonLanguage language, + @Cached TruffleString.ToJavaStringNode toJavaStringNode) { + return PFactory.createTokenizerIter(language, toJavaStringNode.execute(source)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java index 21648c3b82..469e070bb9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java @@ -122,8 +122,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.formatting.ErrorMessageFormatter; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -176,9 +175,9 @@ public void initialize(Python3Core core) { // we need to copy the attrs, since they must still be available even if the user `del`s the // attrs addBuiltinConstant("_defaultaction", T_DEFAULT); - PDict onceregistry = core.factory().createDict(); + PDict onceregistry = PFactory.createDict(core.getLanguage()); addBuiltinConstant("_onceregistry", onceregistry); - PList filters = initFilters(core.factory()); + PList filters = initFilters(core.getLanguage()); addBuiltinConstant("filters", filters); ModuleState moduleState = new ModuleState(); moduleState.filtersVersion = 0L; @@ -189,18 +188,18 @@ public void initialize(Python3Core core) { super.initialize(core); } - private static PTuple createFilter(PythonObjectSlowPathFactory factory, PythonBuiltinClassType cat, TruffleString id, Object mod) { - return factory.createTuple(new Object[]{id, PNone.NONE, cat, mod, 0}); + private static PTuple createFilter(PythonLanguage language, PythonBuiltinClassType cat, TruffleString id, Object mod) { + return PFactory.createTuple(language, new Object[]{id, PNone.NONE, cat, mod, 0}); } // init_filters - private static PList initFilters(PythonObjectSlowPathFactory factory) { - return factory.createList(new Object[]{ - createFilter(factory, PythonBuiltinClassType.DeprecationWarning, T_DEFAULT, T___MAIN__), - createFilter(factory, PythonBuiltinClassType.DeprecationWarning, T_IGNORE, PNone.NONE), - createFilter(factory, PythonBuiltinClassType.PendingDeprecationWarning, T_IGNORE, PNone.NONE), - createFilter(factory, PythonBuiltinClassType.ImportWarning, T_IGNORE, PNone.NONE), - createFilter(factory, PythonBuiltinClassType.ResourceWarning, T_IGNORE, PNone.NONE)}); + private static PList initFilters(PythonLanguage language) { + return PFactory.createList(language, new Object[]{ + createFilter(language, PythonBuiltinClassType.DeprecationWarning, T_DEFAULT, T___MAIN__), + createFilter(language, PythonBuiltinClassType.DeprecationWarning, T_IGNORE, PNone.NONE), + createFilter(language, PythonBuiltinClassType.PendingDeprecationWarning, T_IGNORE, PNone.NONE), + createFilter(language, PythonBuiltinClassType.ImportWarning, T_IGNORE, PNone.NONE), + createFilter(language, PythonBuiltinClassType.ResourceWarning, T_IGNORE, PNone.NONE)}); } static final class WarningsModuleNode extends Node { @@ -210,7 +209,6 @@ static final class WarningsModuleNode extends Node { @Child GetClassNode getClassNode; @Child PyNumberAsSizeNode asSizeNode; @Child PyObjectIsTrueNode isTrueNode; - @Child PythonObjectFactory factory; @Child IsSubClassNode isSubClassNode; @Child GetOrCreateDictNode getDictNode; @Child GetDictFromGlobalsNode getDictFromGlobalsNode; @@ -387,15 +385,6 @@ private PRaiseNode getRaise() { return raiseNode; } - private PythonObjectFactory getFactory() { - if (factory == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - reportPolymorphicSpecialize(); - factory = insert(PythonObjectFactory.create()); - } - return factory; - } - private IsSubClassNode getIsSubClass() { if (isSubClassNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -675,12 +664,12 @@ private TruffleString normalizeModule(TruffleString filename) { } @TruffleBoundary - private static boolean updateRegistry(PythonObjectSlowPathFactory factory, PythonModule _warnings, PDict registry, Object text, Object category, boolean addZero) { + private static boolean updateRegistry(PythonLanguage language, PythonModule _warnings, PDict registry, Object text, Object category, boolean addZero) { PTuple altKey; if (addZero) { - altKey = factory.createTuple(new Object[]{text, category, 0}); + altKey = PFactory.createTuple(language, new Object[]{text, category, 0}); } else { - altKey = factory.createTuple(new Object[]{text, category}); + altKey = PFactory.createTuple(language, new Object[]{text, category}); } return alreadyWarnedShouldSet(_warnings, registry, altKey); } @@ -794,7 +783,7 @@ private void warnExplicit(VirtualFrame frame, PythonModule warnings, message = getCallNode().execute(frame, category, message); } - Object key = getFactory().createTuple(new Object[]{text, category, lineno}); + Object key = PFactory.createTuple(PythonLanguage.get(this), new Object[]{text, category, lineno}); if (registry != null) { if (alreadyWarnedShouldNotSet(frame, warnings, registry, key)) { return; @@ -845,13 +834,13 @@ private static void warnExplicitPart2(PythonContext context, Node node, PythonMo if (action.equalsUncached(T_ONCE, TS_ENCODING)) { if (registry == null) { PDict currentRegistry = getOnceRegistry(node, context, warnings); - alreadyWarned = updateRegistry(context.factory(), warnings, currentRegistry, text, category, false); + alreadyWarned = updateRegistry(context.getLanguage(), warnings, currentRegistry, text, category, false); } else { - alreadyWarned = updateRegistry(context.factory(), warnings, registry, text, category, false); + alreadyWarned = updateRegistry(context.getLanguage(), warnings, registry, text, category, false); } } else if (action.equalsUncached(T_MODULE, TS_ENCODING)) { if (registry != null) { - alreadyWarned = updateRegistry(context.factory(), warnings, registry, text, category, false); + alreadyWarned = updateRegistry(context.getLanguage(), warnings, registry, text, category, false); } } else if (!action.equalsUncached(T_DEFAULT, TS_ENCODING)) { throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNRECOGNIZED_ACTION_IN_WARNINGS, action, @@ -898,7 +887,7 @@ private void setupContext(VirtualFrame frame, int stackLevel, TruffleString[] fi registry[0] = getDictGetItemNode().executeCached(frame, globals, T___WARNINGREGISTRY__); if (registry[0] == null) { - registry[0] = getFactory().createDict(); + registry[0] = PFactory.createDict(PythonLanguage.get(this)); getSetItemNode().executeCached(frame, globals, T___WARNINGREGISTRY__, registry[0]); } Object moduleObj = getDictGetItemNode().executeCached(frame, globals, SpecialAttributeNames.T___NAME__); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java index 3c5412ca21..298854a1e0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -55,6 +55,7 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -88,7 +89,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -259,7 +260,8 @@ static PReferenceType refType(Object cls, Object object, @SuppressWarnings("unus @Exclusive @Cached GetClassNode getClassNode, @Cached HiddenAttr.ReadNode readWeaklistNode, @Cached HiddenAttr.WriteNode writeWeakListNode, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached HiddenAttr.ReadNode readQueueNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object obj = object; @@ -281,7 +283,7 @@ static PReferenceType refType(Object cls, Object object, @SuppressWarnings("unus return (PReferenceType) wr; // is must be a PReferenceType instance. } - PReferenceType ref = factory.createReferenceType(cls, obj, null, getWeakReferenceQueue(inliningTarget, readQueueNode)); + PReferenceType ref = PFactory.createReferenceType(language, cls, getInstanceShape.execute(cls), obj, null, getWeakReferenceQueue(inliningTarget, readQueueNode)); writeWeakListNode.execute(inliningTarget, (PythonAbstractObject) obj, WEAKLIST, ref); return ref; } @@ -290,8 +292,9 @@ static PReferenceType refType(Object cls, Object object, @SuppressWarnings("unus static PReferenceType refTypeWithCallback(Object cls, Object object, Object callback, @Bind("this") Node inliningTarget, @Exclusive @Cached HiddenAttr.ReadNode readQueueNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createReferenceType(cls, object, callback, getWeakReferenceQueue(inliningTarget, readQueueNode)); + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createReferenceType(language, cls, getInstanceShape.execute(cls), object, callback, getWeakReferenceQueue(inliningTarget, readQueueNode)); } @Specialization @@ -301,7 +304,8 @@ PReferenceType refType(Object cls, PythonAbstractNativeObject pythonObject, Obje @Exclusive @Cached GetClassNode getClassNode, @Cached IsBuiltinClassExactProfile profile, @Cached GetMroNode getMroNode, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached HiddenAttr.ReadNode readQueueNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object actualCallback = callback instanceof PNone ? null : callback; @@ -335,7 +339,7 @@ PReferenceType refType(Object cls, PythonAbstractNativeObject pythonObject, Obje } if (allowed) { CApiTransitions.addNativeWeakRef(getContext(), pythonObject); - return factory.createReferenceType(cls, pythonObject, actualCallback, getWeakReferenceQueue(inliningTarget, readQueueNode)); + return PFactory.createReferenceType(language, cls, getInstanceShape.execute(cls), pythonObject, actualCallback, getWeakReferenceQueue(inliningTarget, readQueueNode)); } else { return refType(cls, pythonObject, actualCallback, raiseNode.get(inliningTarget)); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WinregModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WinregModuleBuiltins.java index e72c7c79d2..49ab1f7d64 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WinregModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WinregModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -55,7 +56,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonQuaternaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -103,10 +104,10 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object openKey(VirtualFrame frame, Object key, Object subKey, Object reserved, Object access, @Bind("this") Node inliningTarget, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (key instanceof Integer intKey) { if (intKey == HKEY_CLASSES_ROOT) { - return factory.createLock(); + return PFactory.createLock(language); } } throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, OSErrorEnum.ENOENT); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java index 446ae216fa..b67a26f384 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -54,6 +54,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -74,7 +75,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.object.SetDictNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -180,10 +181,10 @@ static Object doit(VirtualFrame frame, PythonObject self, Object ignored, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached PyObjectLookupAttr lookupAttr, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object clazz = getClassNode.execute(inliningTarget, self); Object dict = lookupAttr.execute(frame, inliningTarget, self, T___DICT__); - return factory.createTuple(new Object[]{clazz, factory.createTuple(EMPTY_OBJECT_ARRAY), dict}); + return PFactory.createTuple(language, new Object[]{clazz, PFactory.createTuple(language, EMPTY_OBJECT_ARRAY), dict}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java index ac5040e41c..841d0e853d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,35 +45,36 @@ import static com.oracle.graal.python.builtins.modules.BuiltinFunctions.CompileNode.PyCF_TYPE_COMMENTS; import static com.oracle.graal.python.nodes.ErrorMessages.EXPECTED_S_NODE_GOT_P; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___MATCH_ARGS__; -import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; import static com.oracle.truffle.api.CompilerDirectives.shouldNotReachHere; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; 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.objects.PNone; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; import com.oracle.graal.python.builtins.objects.type.PythonClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.pegparser.InputType; import com.oracle.graal.python.pegparser.sst.ModTy; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(defineModule = AstModuleBuiltins.J__AST, isEager = true) @@ -98,7 +99,7 @@ public void initialize(Python3Core core) { addBuiltinConstant("PyCF_ALLOW_TOP_LEVEL_AWAIT", PyCF_ALLOW_TOP_LEVEL_AWAIT); PythonBuiltinClass clsAst = core.lookupType(PythonBuiltinClassType.AST); - PTuple emptyTuple = core.factory().createTuple(EMPTY_OBJECT_ARRAY); + PTuple emptyTuple = PFactory.createEmptyTuple(core.getLanguage()); clsAst.setAttribute(T__FIELDS, emptyTuple); clsAst.setAttribute(T__ATTRIBUTES, emptyTuple); clsAst.setAttribute(T___MATCH_ARGS__, emptyTuple); @@ -108,7 +109,7 @@ public void initialize(Python3Core core) { public void postInitialize(Python3Core core) { super.postInitialize(core); PythonModule astModule = core.lookupBuiltinModule(T__AST); - AstTypeFactory astTypeFactory = new AstTypeFactory(core.getLanguage(), core.factory(), astModule); + AstTypeFactory astTypeFactory = new AstTypeFactory(core.getLanguage(), astModule); AstState state = new AstState(astTypeFactory, core.lookupType(PythonBuiltinClassType.AST)); astModule.setModuleState(state); } @@ -116,18 +117,12 @@ public void postInitialize(Python3Core core) { @Builtin(name = "AST", minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, constructsClass = PythonBuiltinClassType.AST) @GenerateNodeFactory public abstract static class AstNode extends PythonVarargsBuiltinNode { - @Override - public final Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { - if (self == PNone.NO_VALUE && arguments.length > 0) { - return factory().createPythonObject(arguments[0]); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw VarargsBuiltinDirectInvocationNotSupported.INSTANCE; - } @Specialization - PythonObject generic(Object cls, @SuppressWarnings("unused") Object[] varargs, @SuppressWarnings("unused") PKeyword[] kwargs) { - return factory().createPythonObject(cls); + static PythonObject generic(Object cls, @SuppressWarnings("unused") Object[] varargs, @SuppressWarnings("unused") PKeyword[] kwargs, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createPythonObject(language, cls, getInstanceShape.execute(cls)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstState.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstState.java index b416484a6c..29ba5b10cb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstState.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstTypeFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstTypeFactory.java index 89ed1bee7d..00bbb68146 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstTypeFactory.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstTypeFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -49,13 +49,12 @@ import static com.oracle.graal.python.util.PythonUtils.convertToObjectArray; import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.strings.TruffleString; /** @@ -64,23 +63,21 @@ final class AstTypeFactory { private final PythonLanguage language; - private final PythonObjectFactory factory; private final PythonModule astModule; - AstTypeFactory(PythonLanguage language, PythonObjectFactory factory, PythonModule astModule) { + AstTypeFactory(PythonLanguage language, PythonModule astModule) { this.language = language; - this.factory = factory; this.astModule = astModule; } PythonClass makeType(TruffleString name, PythonAbstractClass base, TruffleString[] fields, TruffleString[] attributes, TruffleString[] optional, TruffleString docString) { - PythonClass newType = factory.createPythonClassAndFixupSlots(language, PythonBuiltinClassType.PythonClass, name, base, new PythonAbstractClass[]{base}); + PythonClass newType = PFactory.createPythonClassAndFixupSlots(language, name, base, new PythonAbstractClass[]{base}); newType.setAttribute(T___MODULE__, T_AST); newType.setAttribute(T___DOC__, docString); - newType.setAttribute(T__FIELDS, factory.createTuple(convertToObjectArray(fields))); - newType.setAttribute(T___MATCH_ARGS__, factory.createTuple(convertToObjectArray(fields))); + newType.setAttribute(T__FIELDS, PFactory.createTuple(language, convertToObjectArray(fields))); + newType.setAttribute(T___MATCH_ARGS__, PFactory.createTuple(language, convertToObjectArray(fields))); if (attributes != null) { - newType.setAttribute(T__ATTRIBUTES, factory.createTuple(convertToObjectArray(attributes))); + newType.setAttribute(T__ATTRIBUTES, PFactory.createTuple(language, convertToObjectArray(attributes))); } for (TruffleString n : optional) { newType.setAttribute(n, PNone.NONE); @@ -90,6 +87,6 @@ PythonClass makeType(TruffleString name, PythonAbstractClass base, TruffleString } PythonObject createSingleton(PythonClass cls) { - return factory.createPythonObject(cls); + return PFactory.createPythonObject(language, cls, cls.getInstanceShape()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java index 0592423a9d..243cd7c5e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitor.java index d21cebcb1c..e698ae2164 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -77,7 +77,7 @@ final class Sst2ObjVisitor extends Sst2ObjVisitorBase { @Override public Object visit(ModTy.Module node) { - PythonObject o = factory.createPythonObject(state.clsModule); + PythonObject o = createPythonObject(state.clsModule); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_TYPE_IGNORES, seq2List(node.typeIgnores)); return o; @@ -85,21 +85,21 @@ public Object visit(ModTy.Module node) { @Override public Object visit(ModTy.Interactive node) { - PythonObject o = factory.createPythonObject(state.clsInteractive); + PythonObject o = createPythonObject(state.clsInteractive); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); return o; } @Override public Object visit(ModTy.Expression node) { - PythonObject o = factory.createPythonObject(state.clsExpression); + PythonObject o = createPythonObject(state.clsExpression); o.setAttribute(AstState.T_F_BODY, visitNonNull(node.body)); return o; } @Override public Object visit(ModTy.FunctionType node) { - PythonObject o = factory.createPythonObject(state.clsFunctionType); + PythonObject o = createPythonObject(state.clsFunctionType); o.setAttribute(AstState.T_F_ARGTYPES, seq2List(node.argTypes)); o.setAttribute(AstState.T_F_RETURNS, visitNonNull(node.returns)); return o; @@ -107,7 +107,7 @@ public Object visit(ModTy.FunctionType node) { @Override public Object visit(StmtTy.FunctionDef node) { - PythonObject o = factory.createPythonObject(state.clsFunctionDef); + PythonObject o = createPythonObject(state.clsFunctionDef); o.setAttribute(AstState.T_F_NAME, visitNonNull(node.name)); o.setAttribute(AstState.T_F_ARGS, visitNonNull(node.args)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -120,7 +120,7 @@ public Object visit(StmtTy.FunctionDef node) { @Override public Object visit(StmtTy.AsyncFunctionDef node) { - PythonObject o = factory.createPythonObject(state.clsAsyncFunctionDef); + PythonObject o = createPythonObject(state.clsAsyncFunctionDef); o.setAttribute(AstState.T_F_NAME, visitNonNull(node.name)); o.setAttribute(AstState.T_F_ARGS, visitNonNull(node.args)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -133,7 +133,7 @@ public Object visit(StmtTy.AsyncFunctionDef node) { @Override public Object visit(StmtTy.ClassDef node) { - PythonObject o = factory.createPythonObject(state.clsClassDef); + PythonObject o = createPythonObject(state.clsClassDef); o.setAttribute(AstState.T_F_NAME, visitNonNull(node.name)); o.setAttribute(AstState.T_F_BASES, seq2List(node.bases)); o.setAttribute(AstState.T_F_KEYWORDS, seq2List(node.keywords)); @@ -145,7 +145,7 @@ public Object visit(StmtTy.ClassDef node) { @Override public Object visit(StmtTy.Return node) { - PythonObject o = factory.createPythonObject(state.clsReturn); + PythonObject o = createPythonObject(state.clsReturn); o.setAttribute(AstState.T_F_VALUE, visitNullable(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -153,7 +153,7 @@ public Object visit(StmtTy.Return node) { @Override public Object visit(StmtTy.Delete node) { - PythonObject o = factory.createPythonObject(state.clsDelete); + PythonObject o = createPythonObject(state.clsDelete); o.setAttribute(AstState.T_F_TARGETS, seq2List(node.targets)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -161,7 +161,7 @@ public Object visit(StmtTy.Delete node) { @Override public Object visit(StmtTy.Assign node) { - PythonObject o = factory.createPythonObject(state.clsAssign); + PythonObject o = createPythonObject(state.clsAssign); o.setAttribute(AstState.T_F_TARGETS, seq2List(node.targets)); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_TYPE_COMMENT, visitNullableStringOrByteArray(node.typeComment)); @@ -171,7 +171,7 @@ public Object visit(StmtTy.Assign node) { @Override public Object visit(StmtTy.AugAssign node) { - PythonObject o = factory.createPythonObject(state.clsAugAssign); + PythonObject o = createPythonObject(state.clsAugAssign); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_OP, visitNonNull(node.op)); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); @@ -181,7 +181,7 @@ public Object visit(StmtTy.AugAssign node) { @Override public Object visit(StmtTy.AnnAssign node) { - PythonObject o = factory.createPythonObject(state.clsAnnAssign); + PythonObject o = createPythonObject(state.clsAnnAssign); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_ANNOTATION, visitNonNull(node.annotation)); o.setAttribute(AstState.T_F_VALUE, visitNullable(node.value)); @@ -192,7 +192,7 @@ public Object visit(StmtTy.AnnAssign node) { @Override public Object visit(StmtTy.For node) { - PythonObject o = factory.createPythonObject(state.clsFor); + PythonObject o = createPythonObject(state.clsFor); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_ITER, visitNonNull(node.iter)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -204,7 +204,7 @@ public Object visit(StmtTy.For node) { @Override public Object visit(StmtTy.AsyncFor node) { - PythonObject o = factory.createPythonObject(state.clsAsyncFor); + PythonObject o = createPythonObject(state.clsAsyncFor); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_ITER, visitNonNull(node.iter)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -216,7 +216,7 @@ public Object visit(StmtTy.AsyncFor node) { @Override public Object visit(StmtTy.While node) { - PythonObject o = factory.createPythonObject(state.clsWhile); + PythonObject o = createPythonObject(state.clsWhile); o.setAttribute(AstState.T_F_TEST, visitNonNull(node.test)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_ORELSE, seq2List(node.orElse)); @@ -226,7 +226,7 @@ public Object visit(StmtTy.While node) { @Override public Object visit(StmtTy.If node) { - PythonObject o = factory.createPythonObject(state.clsIf); + PythonObject o = createPythonObject(state.clsIf); o.setAttribute(AstState.T_F_TEST, visitNonNull(node.test)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_ORELSE, seq2List(node.orElse)); @@ -236,7 +236,7 @@ public Object visit(StmtTy.If node) { @Override public Object visit(StmtTy.With node) { - PythonObject o = factory.createPythonObject(state.clsWith); + PythonObject o = createPythonObject(state.clsWith); o.setAttribute(AstState.T_F_ITEMS, seq2List(node.items)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_TYPE_COMMENT, visitNullableStringOrByteArray(node.typeComment)); @@ -246,7 +246,7 @@ public Object visit(StmtTy.With node) { @Override public Object visit(StmtTy.AsyncWith node) { - PythonObject o = factory.createPythonObject(state.clsAsyncWith); + PythonObject o = createPythonObject(state.clsAsyncWith); o.setAttribute(AstState.T_F_ITEMS, seq2List(node.items)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_TYPE_COMMENT, visitNullableStringOrByteArray(node.typeComment)); @@ -256,7 +256,7 @@ public Object visit(StmtTy.AsyncWith node) { @Override public Object visit(StmtTy.Match node) { - PythonObject o = factory.createPythonObject(state.clsMatch); + PythonObject o = createPythonObject(state.clsMatch); o.setAttribute(AstState.T_F_SUBJECT, visitNonNull(node.subject)); o.setAttribute(AstState.T_F_CASES, seq2List(node.cases)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -265,7 +265,7 @@ public Object visit(StmtTy.Match node) { @Override public Object visit(StmtTy.Raise node) { - PythonObject o = factory.createPythonObject(state.clsRaise); + PythonObject o = createPythonObject(state.clsRaise); o.setAttribute(AstState.T_F_EXC, visitNullable(node.exc)); o.setAttribute(AstState.T_F_CAUSE, visitNullable(node.cause)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -274,7 +274,7 @@ public Object visit(StmtTy.Raise node) { @Override public Object visit(StmtTy.Try node) { - PythonObject o = factory.createPythonObject(state.clsTry); + PythonObject o = createPythonObject(state.clsTry); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_HANDLERS, seq2List(node.handlers)); o.setAttribute(AstState.T_F_ORELSE, seq2List(node.orElse)); @@ -285,7 +285,7 @@ public Object visit(StmtTy.Try node) { @Override public Object visit(StmtTy.TryStar node) { - PythonObject o = factory.createPythonObject(state.clsTryStar); + PythonObject o = createPythonObject(state.clsTryStar); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); o.setAttribute(AstState.T_F_HANDLERS, seq2List(node.handlers)); o.setAttribute(AstState.T_F_ORELSE, seq2List(node.orElse)); @@ -296,7 +296,7 @@ public Object visit(StmtTy.TryStar node) { @Override public Object visit(StmtTy.Assert node) { - PythonObject o = factory.createPythonObject(state.clsAssert); + PythonObject o = createPythonObject(state.clsAssert); o.setAttribute(AstState.T_F_TEST, visitNonNull(node.test)); o.setAttribute(AstState.T_F_MSG, visitNullable(node.msg)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -305,7 +305,7 @@ public Object visit(StmtTy.Assert node) { @Override public Object visit(StmtTy.Import node) { - PythonObject o = factory.createPythonObject(state.clsImport); + PythonObject o = createPythonObject(state.clsImport); o.setAttribute(AstState.T_F_NAMES, seq2List(node.names)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -313,7 +313,7 @@ public Object visit(StmtTy.Import node) { @Override public Object visit(StmtTy.ImportFrom node) { - PythonObject o = factory.createPythonObject(state.clsImportFrom); + PythonObject o = createPythonObject(state.clsImportFrom); o.setAttribute(AstState.T_F_MODULE, visitNullable(node.module)); o.setAttribute(AstState.T_F_NAMES, seq2List(node.names)); o.setAttribute(AstState.T_F_LEVEL, visitNullable(node.level)); @@ -323,7 +323,7 @@ public Object visit(StmtTy.ImportFrom node) { @Override public Object visit(StmtTy.Global node) { - PythonObject o = factory.createPythonObject(state.clsGlobal); + PythonObject o = createPythonObject(state.clsGlobal); o.setAttribute(AstState.T_F_NAMES, seq2List(node.names)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -331,7 +331,7 @@ public Object visit(StmtTy.Global node) { @Override public Object visit(StmtTy.Nonlocal node) { - PythonObject o = factory.createPythonObject(state.clsNonlocal); + PythonObject o = createPythonObject(state.clsNonlocal); o.setAttribute(AstState.T_F_NAMES, seq2List(node.names)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -339,7 +339,7 @@ public Object visit(StmtTy.Nonlocal node) { @Override public Object visit(StmtTy.Expr node) { - PythonObject o = factory.createPythonObject(state.clsExpr); + PythonObject o = createPythonObject(state.clsExpr); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -347,28 +347,28 @@ public Object visit(StmtTy.Expr node) { @Override public Object visit(StmtTy.Pass node) { - PythonObject o = factory.createPythonObject(state.clsPass); + PythonObject o = createPythonObject(state.clsPass); fillSourceRangeAttributes(o, node.getSourceRange()); return o; } @Override public Object visit(StmtTy.Break node) { - PythonObject o = factory.createPythonObject(state.clsBreak); + PythonObject o = createPythonObject(state.clsBreak); fillSourceRangeAttributes(o, node.getSourceRange()); return o; } @Override public Object visit(StmtTy.Continue node) { - PythonObject o = factory.createPythonObject(state.clsContinue); + PythonObject o = createPythonObject(state.clsContinue); fillSourceRangeAttributes(o, node.getSourceRange()); return o; } @Override public Object visit(ExprTy.BoolOp node) { - PythonObject o = factory.createPythonObject(state.clsBoolOp); + PythonObject o = createPythonObject(state.clsBoolOp); o.setAttribute(AstState.T_F_OP, visitNonNull(node.op)); o.setAttribute(AstState.T_F_VALUES, seq2List(node.values)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -377,7 +377,7 @@ public Object visit(ExprTy.BoolOp node) { @Override public Object visit(ExprTy.NamedExpr node) { - PythonObject o = factory.createPythonObject(state.clsNamedExpr); + PythonObject o = createPythonObject(state.clsNamedExpr); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -386,7 +386,7 @@ public Object visit(ExprTy.NamedExpr node) { @Override public Object visit(ExprTy.BinOp node) { - PythonObject o = factory.createPythonObject(state.clsBinOp); + PythonObject o = createPythonObject(state.clsBinOp); o.setAttribute(AstState.T_F_LEFT, visitNonNull(node.left)); o.setAttribute(AstState.T_F_OP, visitNonNull(node.op)); o.setAttribute(AstState.T_F_RIGHT, visitNonNull(node.right)); @@ -396,7 +396,7 @@ public Object visit(ExprTy.BinOp node) { @Override public Object visit(ExprTy.UnaryOp node) { - PythonObject o = factory.createPythonObject(state.clsUnaryOp); + PythonObject o = createPythonObject(state.clsUnaryOp); o.setAttribute(AstState.T_F_OP, visitNonNull(node.op)); o.setAttribute(AstState.T_F_OPERAND, visitNonNull(node.operand)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -405,7 +405,7 @@ public Object visit(ExprTy.UnaryOp node) { @Override public Object visit(ExprTy.Lambda node) { - PythonObject o = factory.createPythonObject(state.clsLambda); + PythonObject o = createPythonObject(state.clsLambda); o.setAttribute(AstState.T_F_ARGS, visitNonNull(node.args)); o.setAttribute(AstState.T_F_BODY, visitNonNull(node.body)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -414,7 +414,7 @@ public Object visit(ExprTy.Lambda node) { @Override public Object visit(ExprTy.IfExp node) { - PythonObject o = factory.createPythonObject(state.clsIfExp); + PythonObject o = createPythonObject(state.clsIfExp); o.setAttribute(AstState.T_F_TEST, visitNonNull(node.test)); o.setAttribute(AstState.T_F_BODY, visitNonNull(node.body)); o.setAttribute(AstState.T_F_ORELSE, visitNonNull(node.orElse)); @@ -424,7 +424,7 @@ public Object visit(ExprTy.IfExp node) { @Override public Object visit(ExprTy.Dict node) { - PythonObject o = factory.createPythonObject(state.clsDict); + PythonObject o = createPythonObject(state.clsDict); o.setAttribute(AstState.T_F_KEYS, seq2List(node.keys)); o.setAttribute(AstState.T_F_VALUES, seq2List(node.values)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -433,7 +433,7 @@ public Object visit(ExprTy.Dict node) { @Override public Object visit(ExprTy.Set node) { - PythonObject o = factory.createPythonObject(state.clsSet); + PythonObject o = createPythonObject(state.clsSet); o.setAttribute(AstState.T_F_ELTS, seq2List(node.elements)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -441,7 +441,7 @@ public Object visit(ExprTy.Set node) { @Override public Object visit(ExprTy.ListComp node) { - PythonObject o = factory.createPythonObject(state.clsListComp); + PythonObject o = createPythonObject(state.clsListComp); o.setAttribute(AstState.T_F_ELT, visitNonNull(node.element)); o.setAttribute(AstState.T_F_GENERATORS, seq2List(node.generators)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -450,7 +450,7 @@ public Object visit(ExprTy.ListComp node) { @Override public Object visit(ExprTy.SetComp node) { - PythonObject o = factory.createPythonObject(state.clsSetComp); + PythonObject o = createPythonObject(state.clsSetComp); o.setAttribute(AstState.T_F_ELT, visitNonNull(node.element)); o.setAttribute(AstState.T_F_GENERATORS, seq2List(node.generators)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -459,7 +459,7 @@ public Object visit(ExprTy.SetComp node) { @Override public Object visit(ExprTy.DictComp node) { - PythonObject o = factory.createPythonObject(state.clsDictComp); + PythonObject o = createPythonObject(state.clsDictComp); o.setAttribute(AstState.T_F_KEY, visitNonNull(node.key)); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_GENERATORS, seq2List(node.generators)); @@ -469,7 +469,7 @@ public Object visit(ExprTy.DictComp node) { @Override public Object visit(ExprTy.GeneratorExp node) { - PythonObject o = factory.createPythonObject(state.clsGeneratorExp); + PythonObject o = createPythonObject(state.clsGeneratorExp); o.setAttribute(AstState.T_F_ELT, visitNonNull(node.element)); o.setAttribute(AstState.T_F_GENERATORS, seq2List(node.generators)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -478,7 +478,7 @@ public Object visit(ExprTy.GeneratorExp node) { @Override public Object visit(ExprTy.Await node) { - PythonObject o = factory.createPythonObject(state.clsAwait); + PythonObject o = createPythonObject(state.clsAwait); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -486,7 +486,7 @@ public Object visit(ExprTy.Await node) { @Override public Object visit(ExprTy.Yield node) { - PythonObject o = factory.createPythonObject(state.clsYield); + PythonObject o = createPythonObject(state.clsYield); o.setAttribute(AstState.T_F_VALUE, visitNullable(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -494,7 +494,7 @@ public Object visit(ExprTy.Yield node) { @Override public Object visit(ExprTy.YieldFrom node) { - PythonObject o = factory.createPythonObject(state.clsYieldFrom); + PythonObject o = createPythonObject(state.clsYieldFrom); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -502,7 +502,7 @@ public Object visit(ExprTy.YieldFrom node) { @Override public Object visit(ExprTy.Compare node) { - PythonObject o = factory.createPythonObject(state.clsCompare); + PythonObject o = createPythonObject(state.clsCompare); o.setAttribute(AstState.T_F_LEFT, visitNonNull(node.left)); o.setAttribute(AstState.T_F_OPS, seq2List(node.ops)); o.setAttribute(AstState.T_F_COMPARATORS, seq2List(node.comparators)); @@ -512,7 +512,7 @@ public Object visit(ExprTy.Compare node) { @Override public Object visit(ExprTy.Call node) { - PythonObject o = factory.createPythonObject(state.clsCall); + PythonObject o = createPythonObject(state.clsCall); o.setAttribute(AstState.T_F_FUNC, visitNonNull(node.func)); o.setAttribute(AstState.T_F_ARGS, seq2List(node.args)); o.setAttribute(AstState.T_F_KEYWORDS, seq2List(node.keywords)); @@ -522,7 +522,7 @@ public Object visit(ExprTy.Call node) { @Override public Object visit(ExprTy.FormattedValue node) { - PythonObject o = factory.createPythonObject(state.clsFormattedValue); + PythonObject o = createPythonObject(state.clsFormattedValue); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_CONVERSION, visitNonNull(node.conversion)); o.setAttribute(AstState.T_F_FORMAT_SPEC, visitNullable(node.formatSpec)); @@ -532,7 +532,7 @@ public Object visit(ExprTy.FormattedValue node) { @Override public Object visit(ExprTy.JoinedStr node) { - PythonObject o = factory.createPythonObject(state.clsJoinedStr); + PythonObject o = createPythonObject(state.clsJoinedStr); o.setAttribute(AstState.T_F_VALUES, seq2List(node.values)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -540,7 +540,7 @@ public Object visit(ExprTy.JoinedStr node) { @Override public Object visit(ExprTy.Constant node) { - PythonObject o = factory.createPythonObject(state.clsConstant); + PythonObject o = createPythonObject(state.clsConstant); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_KIND, visitNullableStringOrByteArray(node.kind)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -549,7 +549,7 @@ public Object visit(ExprTy.Constant node) { @Override public Object visit(ExprTy.Attribute node) { - PythonObject o = factory.createPythonObject(state.clsAttribute); + PythonObject o = createPythonObject(state.clsAttribute); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_ATTR, visitNonNull(node.attr)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); @@ -559,7 +559,7 @@ public Object visit(ExprTy.Attribute node) { @Override public Object visit(ExprTy.Subscript node) { - PythonObject o = factory.createPythonObject(state.clsSubscript); + PythonObject o = createPythonObject(state.clsSubscript); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_SLICE, visitNonNull(node.slice)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); @@ -569,7 +569,7 @@ public Object visit(ExprTy.Subscript node) { @Override public Object visit(ExprTy.Starred node) { - PythonObject o = factory.createPythonObject(state.clsStarred); + PythonObject o = createPythonObject(state.clsStarred); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -578,7 +578,7 @@ public Object visit(ExprTy.Starred node) { @Override public Object visit(ExprTy.Name node) { - PythonObject o = factory.createPythonObject(state.clsName); + PythonObject o = createPythonObject(state.clsName); o.setAttribute(AstState.T_F_ID, visitNonNull(node.id)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -587,7 +587,7 @@ public Object visit(ExprTy.Name node) { @Override public Object visit(ExprTy.List node) { - PythonObject o = factory.createPythonObject(state.clsList); + PythonObject o = createPythonObject(state.clsList); o.setAttribute(AstState.T_F_ELTS, seq2List(node.elements)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -596,7 +596,7 @@ public Object visit(ExprTy.List node) { @Override public Object visit(ExprTy.Tuple node) { - PythonObject o = factory.createPythonObject(state.clsTuple); + PythonObject o = createPythonObject(state.clsTuple); o.setAttribute(AstState.T_F_ELTS, seq2List(node.elements)); o.setAttribute(AstState.T_F_CTX, visitNonNull(node.context)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -605,7 +605,7 @@ public Object visit(ExprTy.Tuple node) { @Override public Object visit(ExprTy.Slice node) { - PythonObject o = factory.createPythonObject(state.clsSlice); + PythonObject o = createPythonObject(state.clsSlice); o.setAttribute(AstState.T_F_LOWER, visitNullable(node.lower)); o.setAttribute(AstState.T_F_UPPER, visitNullable(node.upper)); o.setAttribute(AstState.T_F_STEP, visitNullable(node.step)); @@ -715,7 +715,7 @@ public Object visitNonNull(CmpOpTy v) { @Override public Object visit(ComprehensionTy node) { - PythonObject o = factory.createPythonObject(state.clsComprehensionTy); + PythonObject o = createPythonObject(state.clsComprehensionTy); o.setAttribute(AstState.T_F_TARGET, visitNonNull(node.target)); o.setAttribute(AstState.T_F_ITER, visitNonNull(node.iter)); o.setAttribute(AstState.T_F_IFS, seq2List(node.ifs)); @@ -725,7 +725,7 @@ public Object visit(ComprehensionTy node) { @Override public Object visit(ExceptHandlerTy.ExceptHandler node) { - PythonObject o = factory.createPythonObject(state.clsExceptHandler); + PythonObject o = createPythonObject(state.clsExceptHandler); o.setAttribute(AstState.T_F_TYPE, visitNullable(node.type)); o.setAttribute(AstState.T_F_NAME, visitNullable(node.name)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -735,7 +735,7 @@ public Object visit(ExceptHandlerTy.ExceptHandler node) { @Override public Object visit(ArgumentsTy node) { - PythonObject o = factory.createPythonObject(state.clsArgumentsTy); + PythonObject o = createPythonObject(state.clsArgumentsTy); o.setAttribute(AstState.T_F_POSONLYARGS, seq2List(node.posOnlyArgs)); o.setAttribute(AstState.T_F_ARGS, seq2List(node.args)); o.setAttribute(AstState.T_F_VARARG, visitNullable(node.varArg)); @@ -748,7 +748,7 @@ public Object visit(ArgumentsTy node) { @Override public Object visit(ArgTy node) { - PythonObject o = factory.createPythonObject(state.clsArgTy); + PythonObject o = createPythonObject(state.clsArgTy); o.setAttribute(AstState.T_F_ARG, visitNonNull(node.arg)); o.setAttribute(AstState.T_F_ANNOTATION, visitNullable(node.annotation)); o.setAttribute(AstState.T_F_TYPE_COMMENT, visitNullableStringOrByteArray(node.typeComment)); @@ -758,7 +758,7 @@ public Object visit(ArgTy node) { @Override public Object visit(KeywordTy node) { - PythonObject o = factory.createPythonObject(state.clsKeywordTy); + PythonObject o = createPythonObject(state.clsKeywordTy); o.setAttribute(AstState.T_F_ARG, visitNullable(node.arg)); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -767,7 +767,7 @@ public Object visit(KeywordTy node) { @Override public Object visit(AliasTy node) { - PythonObject o = factory.createPythonObject(state.clsAliasTy); + PythonObject o = createPythonObject(state.clsAliasTy); o.setAttribute(AstState.T_F_NAME, visitNonNull(node.name)); o.setAttribute(AstState.T_F_ASNAME, visitNullable(node.asName)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -776,7 +776,7 @@ public Object visit(AliasTy node) { @Override public Object visit(WithItemTy node) { - PythonObject o = factory.createPythonObject(state.clsWithItemTy); + PythonObject o = createPythonObject(state.clsWithItemTy); o.setAttribute(AstState.T_F_CONTEXT_EXPR, visitNonNull(node.contextExpr)); o.setAttribute(AstState.T_F_OPTIONAL_VARS, visitNullable(node.optionalVars)); return o; @@ -784,7 +784,7 @@ public Object visit(WithItemTy node) { @Override public Object visit(MatchCaseTy node) { - PythonObject o = factory.createPythonObject(state.clsMatchCaseTy); + PythonObject o = createPythonObject(state.clsMatchCaseTy); o.setAttribute(AstState.T_F_PATTERN, visitNonNull(node.pattern)); o.setAttribute(AstState.T_F_GUARD, visitNullable(node.guard)); o.setAttribute(AstState.T_F_BODY, seq2List(node.body)); @@ -793,7 +793,7 @@ public Object visit(MatchCaseTy node) { @Override public Object visit(PatternTy.MatchValue node) { - PythonObject o = factory.createPythonObject(state.clsMatchValue); + PythonObject o = createPythonObject(state.clsMatchValue); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -801,7 +801,7 @@ public Object visit(PatternTy.MatchValue node) { @Override public Object visit(PatternTy.MatchSingleton node) { - PythonObject o = factory.createPythonObject(state.clsMatchSingleton); + PythonObject o = createPythonObject(state.clsMatchSingleton); o.setAttribute(AstState.T_F_VALUE, visitNonNull(node.value)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -809,7 +809,7 @@ public Object visit(PatternTy.MatchSingleton node) { @Override public Object visit(PatternTy.MatchSequence node) { - PythonObject o = factory.createPythonObject(state.clsMatchSequence); + PythonObject o = createPythonObject(state.clsMatchSequence); o.setAttribute(AstState.T_F_PATTERNS, seq2List(node.patterns)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -817,7 +817,7 @@ public Object visit(PatternTy.MatchSequence node) { @Override public Object visit(PatternTy.MatchMapping node) { - PythonObject o = factory.createPythonObject(state.clsMatchMapping); + PythonObject o = createPythonObject(state.clsMatchMapping); o.setAttribute(AstState.T_F_KEYS, seq2List(node.keys)); o.setAttribute(AstState.T_F_PATTERNS, seq2List(node.patterns)); o.setAttribute(AstState.T_F_REST, visitNullable(node.rest)); @@ -827,7 +827,7 @@ public Object visit(PatternTy.MatchMapping node) { @Override public Object visit(PatternTy.MatchClass node) { - PythonObject o = factory.createPythonObject(state.clsMatchClass); + PythonObject o = createPythonObject(state.clsMatchClass); o.setAttribute(AstState.T_F_CLS, visitNonNull(node.cls)); o.setAttribute(AstState.T_F_PATTERNS, seq2List(node.patterns)); o.setAttribute(AstState.T_F_KWD_ATTRS, seq2List(node.kwdAttrs)); @@ -838,7 +838,7 @@ public Object visit(PatternTy.MatchClass node) { @Override public Object visit(PatternTy.MatchStar node) { - PythonObject o = factory.createPythonObject(state.clsMatchStar); + PythonObject o = createPythonObject(state.clsMatchStar); o.setAttribute(AstState.T_F_NAME, visitNullable(node.name)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -846,7 +846,7 @@ public Object visit(PatternTy.MatchStar node) { @Override public Object visit(PatternTy.MatchAs node) { - PythonObject o = factory.createPythonObject(state.clsMatchAs); + PythonObject o = createPythonObject(state.clsMatchAs); o.setAttribute(AstState.T_F_PATTERN, visitNullable(node.pattern)); o.setAttribute(AstState.T_F_NAME, visitNullable(node.name)); fillSourceRangeAttributes(o, node.getSourceRange()); @@ -855,7 +855,7 @@ public Object visit(PatternTy.MatchAs node) { @Override public Object visit(PatternTy.MatchOr node) { - PythonObject o = factory.createPythonObject(state.clsMatchOr); + PythonObject o = createPythonObject(state.clsMatchOr); o.setAttribute(AstState.T_F_PATTERNS, seq2List(node.patterns)); fillSourceRangeAttributes(o, node.getSourceRange()); return o; @@ -863,7 +863,7 @@ public Object visit(PatternTy.MatchOr node) { @Override public Object visit(TypeIgnoreTy.TypeIgnore node) { - PythonObject o = factory.createPythonObject(state.clsTypeIgnore); + PythonObject o = createPythonObject(state.clsTypeIgnore); o.setAttribute(AstState.T_F_LINENO, visitNonNull(node.lineNo)); o.setAttribute(AstState.T_F_TAG, visitNonNullStringOrByteArray(node.tag)); return o; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitorBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitorBase.java index 9d106b646d..fe054561f2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitorBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Sst2ObjVisitorBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -46,15 +46,17 @@ import static com.oracle.graal.python.builtins.modules.ast.AstState.T_F_LINENO; import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.object.PythonObject; +import com.oracle.graal.python.builtins.objects.type.PythonClass; import com.oracle.graal.python.pegparser.sst.CmpOpTy; import com.oracle.graal.python.pegparser.sst.ConstantValue; import com.oracle.graal.python.pegparser.sst.SSTNode; import com.oracle.graal.python.pegparser.sst.SSTreeVisitor; import com.oracle.graal.python.pegparser.tokenizer.SourceRange; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.strings.TruffleString; @@ -63,10 +65,10 @@ */ abstract class Sst2ObjVisitorBase implements SSTreeVisitor { - final PythonObjectFactory factory; + final PythonLanguage language; Sst2ObjVisitorBase() { - factory = PythonObjectFactory.getUncached(); + language = PythonLanguage.get(null); } static int visitNullable(int i) { @@ -106,11 +108,11 @@ Object visitNonNullStringOrByteArray(Object o) { return toTruffleStringUncached((String) o); } assert o instanceof byte[]; - return factory.createBytes((byte[]) o); + return PFactory.createBytes(language, (byte[]) o); } final Object visitNonNull(ConstantValue v) { - return PythonUtils.pythonObjectFromConstantValue(v, factory); + return PythonUtils.pythonObjectFromConstantValue(v); } abstract Object visitNonNull(CmpOpTy op); @@ -121,41 +123,45 @@ final Object visitNonNull(SSTNode node) { final PList seq2List(String[] seq) { if (seq == null || seq.length == 0) { - return factory.createList(); + return PFactory.createList(language); } Object[] objs = new Object[seq.length]; for (int i = 0; i < objs.length; ++i) { objs[i] = visitNullable(seq[i]); } - return factory.createList(objs); + return PFactory.createList(language, objs); } final PList seq2List(CmpOpTy[] seq) { if (seq == null || seq.length == 0) { - return factory.createList(); + return PFactory.createList(language); } Object[] objs = new Object[seq.length]; for (int i = 0; i < objs.length; ++i) { objs[i] = visitNullable(seq[i]); } - return factory.createList(objs); + return PFactory.createList(language, objs); } final PList seq2List(SSTNode[] seq) { if (seq == null || seq.length == 0) { - return factory.createList(); + return PFactory.createList(language); } Object[] objs = new Object[seq.length]; for (int i = 0; i < objs.length; ++i) { objs[i] = visitNullable(seq[i]); } - return factory.createList(objs); + return PFactory.createList(language, objs); } - static final void fillSourceRangeAttributes(PythonObject o, SourceRange sourceRange) { + static void fillSourceRangeAttributes(PythonObject o, SourceRange sourceRange) { o.setAttribute(T_F_LINENO, sourceRange.startLine); o.setAttribute(T_F_COL_OFFSET, sourceRange.startColumn); o.setAttribute(T_F_END_LINENO, sourceRange.endLine); o.setAttribute(T_F_END_COL_OFFSET, sourceRange.endColumn); } + + protected PythonObject createPythonObject(PythonClass cls) { + return PFactory.createPythonObject(language, cls, cls.getInstanceShape()); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java index f63ae127f2..28865aeb0d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -71,7 +71,7 @@ import com.oracle.graal.python.runtime.NFIBz2Support; import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -134,24 +134,25 @@ static Object err(Object self, Object compresslevel, abstract static class CompressNode extends PythonBinaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) - PBytes doNativeBytes(BZ2Object.BZ2Compressor self, PBytesLike data, + static PBytes doNativeBytes(BZ2Object.BZ2Compressor self, PBytesLike data, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached SequenceStorageNodes.GetInternalByteArrayNode toBytes, - @Shared("c") @Cached Bz2Nodes.Bz2NativeCompress compress, - @Shared @Cached PythonObjectFactory factory) { + @Shared("c") @Cached Bz2Nodes.Bz2NativeCompress compress) { byte[] bytes = toBytes.execute(inliningTarget, data.getSequenceStorage()); int len = data.getSequenceStorage().length(); - return factory.createBytes(compress.compress(self, PythonContext.get(this), bytes, len)); + return PFactory.createBytes(context.getLanguage(inliningTarget), compress.compress(self, context, bytes, len)); } @Specialization(guards = {"!self.isFlushed()"}) - PBytes doNativeObject(VirtualFrame frame, BZ2Object.BZ2Compressor self, Object data, + static PBytes doNativeObject(VirtualFrame frame, BZ2Object.BZ2Compressor self, Object data, + @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached BytesNodes.ToBytesNode toBytes, - @Shared("c") @Cached Bz2Nodes.Bz2NativeCompress compress, - @Shared @Cached PythonObjectFactory factory) { + @Shared("c") @Cached Bz2Nodes.Bz2NativeCompress compress) { byte[] bytes = toBytes.execute(frame, data); int len = bytes.length; - return factory.createBytes(compress.compress(self, PythonContext.get(this), bytes, len)); + return PFactory.createBytes(context.getLanguage(inliningTarget), compress.compress(self, context, bytes, len)); } @SuppressWarnings("unused") @@ -167,11 +168,12 @@ static PNone error(BZ2Object.BZ2Compressor self, Object data, abstract static class FlushNode extends PythonUnaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) - PBytes doit(BZ2Object.BZ2Compressor self, - @Cached Bz2Nodes.Bz2NativeCompress compress, - @Cached PythonObjectFactory factory) { + static PBytes doit(BZ2Object.BZ2Compressor self, + @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @Cached Bz2Nodes.Bz2NativeCompress compress) { self.setFlushed(); - return factory.createBytes(compress.flush(self, PythonContext.get(this))); + return PFactory.createBytes(context.getLanguage(inliningTarget), compress.flush(self, context)); } @SuppressWarnings("unused") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java index 502e057287..e33951bfd7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -66,11 +67,10 @@ import com.oracle.graal.python.runtime.NFIBz2Support; import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -118,26 +118,26 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = {"!self.isEOF()"}) static PBytes doNativeBytes(BZ2Object.BZ2Decompressor self, PBytesLike data, int maxLength, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached SequenceStorageNodes.GetInternalByteArrayNode toBytes, - @Exclusive @Cached Bz2Nodes.Bz2NativeDecompress decompress, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached Bz2Nodes.Bz2NativeDecompress decompress) { synchronized (self) { byte[] bytes = toBytes.execute(inliningTarget, data.getSequenceStorage()); int len = data.getSequenceStorage().length(); - return factory.createBytes(decompress.execute(inliningTarget, self, bytes, len, maxLength)); + return PFactory.createBytes(language, decompress.execute(inliningTarget, self, bytes, len, maxLength)); } } @Specialization(guards = {"!self.isEOF()"}) static PBytes doNativeObject(VirtualFrame frame, BZ2Object.BZ2Decompressor self, Object data, int maxLength, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached BytesNodes.ToBytesNode toBytes, - @Exclusive @Cached Bz2Nodes.Bz2NativeDecompress decompress, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached Bz2Nodes.Bz2NativeDecompress decompress) { synchronized (self) { byte[] bytes = toBytes.execute(frame, data); int len = bytes.length; - return factory.createBytes(decompress.execute(inliningTarget, self, bytes, len, maxLength)); + return PFactory.createBytes(language, decompress.execute(inliningTarget, self, bytes, len, maxLength)); } } @@ -154,8 +154,8 @@ static Object err(BZ2Object.BZ2Decompressor self, PBytesLike data, int maxLength abstract static class UnusedDataNode extends PythonUnaryBuiltinNode { @Specialization static PBytes doit(BZ2Object.BZ2Decompressor self, - @Cached PythonObjectFactory factory) { - return factory.createBytes(self.getUnusedData()); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, self.getUnusedData()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2ModuleBuiltins.java index 4d72367d0d..37253013fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -52,8 +53,8 @@ import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -76,10 +77,10 @@ public void initialize(Python3Core core) { @GenerateNodeFactory public abstract static class BZ2CompressorNode extends PythonBuiltinNode { @Specialization - static BZ2Object.BZ2Compressor doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + static BZ2Object.BZ2Compressor doNew(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object arg, + @Bind PythonLanguage language) { // data filled in subsequent __init__ call - see BZ2CompressorBuiltins.InitNode - return factory.createBZ2Compressor(cls); + return PFactory.createBZ2Compressor(language); } } @@ -87,10 +88,10 @@ static BZ2Object.BZ2Compressor doNew(Object cls, @SuppressWarnings("unused") Obj @GenerateNodeFactory public abstract static class BZ2DecompressorNode extends PythonBuiltinNode { @Specialization - static BZ2Object.BZ2Decompressor doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + static BZ2Object.BZ2Decompressor doNew(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object arg, + @Bind PythonLanguage language) { // data filled in subsequent __init__ call - see BZ2DecompressorBuiltins.InitNode - return factory.createBZ2Decompressor(cls); + return PFactory.createBZ2Decompressor(language); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java index a1e959050a..b44f6287df 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java @@ -190,7 +190,7 @@ import com.oracle.graal.python.runtime.exception.ExceptionUtils; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.NativeByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; @@ -205,7 +205,6 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -253,26 +252,26 @@ public abstract static class PromoteBorrowedValue extends Node { @Specialization static PString doString(TruffleString str, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createString(str); + @Bind PythonLanguage language) { + return PFactory.createString(language, str); } @Specialization static PythonBuiltinObject doInteger(int i, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(i); + @Bind PythonLanguage language) { + return PFactory.createInt(language, i); } @Specialization static PythonBuiltinObject doLong(long i, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(i); + @Bind PythonLanguage language) { + return PFactory.createInt(language, i); } @Specialization(guards = "!isNaN(d)") static PythonBuiltinObject doDouble(double d, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createFloat(d); + @Bind PythonLanguage language) { + return PFactory.createFloat(language, d); } static boolean isNaN(double d) { @@ -298,12 +297,12 @@ public static PException checkThrowableBeforeNative(Throwable t, String where1, CompilerDirectives.transferToInterpreter(); PythonContext context = PythonContext.get(null); context.ensureGilAfterFailure(); - PBaseException newException = context.factory().createBaseException(RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, EMPTY_OBJECT_ARRAY); + PBaseException newException = PFactory.createBaseException(context.getLanguage(), RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, EMPTY_OBJECT_ARRAY); throw ExceptionUtils.wrapJavaException(soe, null, newException); } if (t instanceof OutOfMemoryError oome) { CompilerDirectives.transferToInterpreter(); - PBaseException newException = PythonContext.get(null).factory().createBaseException(MemoryError); + PBaseException newException = PFactory.createBaseException(PythonLanguage.get(null), MemoryError); throw ExceptionUtils.wrapJavaException(oome, null, newException); } // everything else: log and convert to PException (SystemError) @@ -1143,14 +1142,14 @@ private static Object[] collect(MroSequenceStorage mro, int idx) { abstract static class PyFrame_New extends CApiQuaternaryBuiltinNode { @Specialization static Object newFrame(Object threadState, PCode code, PythonObject globals, Object locals, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object frameLocals; if (locals == null || PGuards.isPNone(locals)) { - frameLocals = factory.createDict(); + frameLocals = PFactory.createDict(language); } else { frameLocals = locals; } - return factory.createPFrame(threadState, code, globals, frameLocals); + return PFactory.createPFrame(language, threadState, code, globals, frameLocals); } } @@ -1171,7 +1170,7 @@ static Object wrap(Object bufferStructPointer, Object ownerObj, long lenObj, @Cached CastToJavaIntExactNode castToIntNode, @Cached TruffleString.CodePointLengthNode lengthNode, @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int ndim = castToIntNode.execute(inliningTarget, ndimObj); int itemsize = castToIntNode.execute(inliningTarget, itemsizeObj); int len = castToIntNode.execute(inliningTarget, lenObj); @@ -1202,7 +1201,7 @@ static Object wrap(Object bufferStructPointer, Object ownerObj, long lenObj, if (!lib.isNull(bufferStructPointer)) { bufferLifecycleManager = new NativeBufferLifecycleManager.NativeBufferLifecycleManagerFromType(bufferStructPointer); } - return factory.createMemoryView(PythonContext.get(inliningTarget), bufferLifecycleManager, buffer, owner, len, readonly, itemsize, + return PFactory.createMemoryView(language, PythonContext.get(inliningTarget), bufferLifecycleManager, buffer, owner, len, readonly, itemsize, BufferFormat.forMemoryView(format, lengthNode, atIndexNode), format, ndim, bufPointer, 0, shape, strides, suboffsets, flags); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java index e146727e9e..f3d47b9596 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -58,6 +58,7 @@ import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.BytesNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; @@ -97,7 +98,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.nodes.util.CastToByteNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; @@ -217,26 +218,26 @@ abstract static class PyTruffleBytes_FromStringAndSize extends CApiBinaryBuiltin @Specialization static Object doGeneric(PythonNativeWrapper object, long size, + @Bind PythonLanguage language, @Cached NativeToPythonNode asPythonObjectNode, - @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode) { byte[] ary = getByteArrayNode.execute(null, asPythonObjectNode.execute(object)); if (size >= 0 && size < ary.length) { // cast to int is guaranteed because of 'size < ary.length' - return factory.createBytes(Arrays.copyOf(ary, (int) size)); + return PFactory.createBytes(language, Arrays.copyOf(ary, (int) size)); } else { - return factory.createBytes(ary); + return PFactory.createBytes(language, ary); } } @Specialization(guards = "!isNativeWrapper(nativePointer)") static Object doNativePointer(Object nativePointer, long size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached GetByteArrayNode getByteArrayNode, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - return factory.createBytes(getByteArrayNode.execute(inliningTarget, nativePointer, size)); + return PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, nativePointer, size)); } catch (InteropException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { @@ -250,26 +251,26 @@ static Object doNativePointer(Object nativePointer, long size, abstract static class PyTruffleByteArray_FromStringAndSize extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(PythonNativeWrapper object, long size, + @Bind PythonLanguage language, @Cached NativeToPythonNode asPythonObjectNode, - @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached BytesNodes.ToBytesNode getByteArrayNode) { byte[] ary = getByteArrayNode.execute(null, asPythonObjectNode.execute(object)); if (size >= 0 && size < ary.length) { // cast to int is guaranteed because of 'size < ary.length' - return factory.createByteArray(Arrays.copyOf(ary, (int) size)); + return PFactory.createByteArray(language, Arrays.copyOf(ary, (int) size)); } else { - return factory.createByteArray(ary); + return PFactory.createByteArray(language, ary); } } @Specialization(guards = "!isNativeWrapper(nativePointer)") static Object doNativePointer(Object nativePointer, long size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached GetByteArrayNode getByteArrayNode, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - return factory.createByteArray(getByteArrayNode.execute(inliningTarget, nativePointer, size)); + return PFactory.createByteArray(language, getByteArrayNode.execute(inliningTarget, nativePointer, size)); } catch (InteropException e) { return raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { @@ -312,23 +313,23 @@ abstract static class PyTruffle_Bytes_EmptyWithCapacity extends CApiUnaryBuiltin @Specialization static PBytes doInt(int size, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(new byte[size]); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, new byte[size]); } @Specialization(rewriteOn = OverflowException.class) static PBytes doLong(long size, - @Shared @Cached PythonObjectFactory factory) throws OverflowException { - return doInt(PInt.intValueExact(size), factory); + @Bind PythonLanguage language) throws OverflowException { + return doInt(PInt.intValueExact(size), language); } @Specialization(replaces = "doLong") static PBytes doLongOvf(long size, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { try { - return doInt(PInt.intValueExact(size), factory); + return doInt(PInt.intValueExact(size), language); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); } @@ -336,17 +337,17 @@ static PBytes doLongOvf(long size, @Specialization(rewriteOn = OverflowException.class) static PBytes doPInt(PInt size, - @Shared @Cached PythonObjectFactory factory) throws OverflowException { - return doInt(size.intValueExact(), factory); + @Bind PythonLanguage language) throws OverflowException { + return doInt(size.intValueExact(), language); } @Specialization(replaces = "doPInt") static PBytes doPIntOvf(PInt size, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { try { - return doInt(size.intValueExact(), factory); + return doInt(size.intValueExact(), language); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); } @@ -358,23 +359,23 @@ abstract static class PyTruffle_ByteArray_EmptyWithCapacity extends CApiUnaryBui @Specialization static PByteArray doInt(int size, - @Shared @Cached PythonObjectFactory factory) { - return factory.createByteArray(new byte[size]); + @Bind PythonLanguage language) { + return PFactory.createByteArray(language, new byte[size]); } @Specialization(rewriteOn = OverflowException.class) static PByteArray doLong(long size, - @Shared @Cached PythonObjectFactory factory) throws OverflowException { - return doInt(PInt.intValueExact(size), factory); + @Bind PythonLanguage language) throws OverflowException { + return doInt(PInt.intValueExact(size), language); } @Specialization(replaces = "doLong") static PByteArray doLongOvf(long size, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { try { - return doInt(PInt.intValueExact(size), factory); + return doInt(PInt.intValueExact(size), language); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); } @@ -382,17 +383,17 @@ static PByteArray doLongOvf(long size, @Specialization(rewriteOn = OverflowException.class) static PByteArray doPInt(PInt size, - @Shared @Cached PythonObjectFactory factory) throws OverflowException { - return doInt(size.intValueExact(), factory); + @Bind PythonLanguage language) throws OverflowException { + return doInt(size.intValueExact(), language); } @Specialization(replaces = "doPInt") static PByteArray doPIntOvf(PInt size, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { try { - return doInt(size.intValueExact(), factory); + return doInt(size.intValueExact(), language); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java index 456e9f832f..410ef50f24 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -55,6 +55,7 @@ import static com.oracle.graal.python.nodes.ErrorMessages.PY_CAPSULE_IMPORT_S_IS_NOT_VALID; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiTernaryBuiltinNode; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.StringLiterals; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -100,12 +101,12 @@ public abstract static class PyCapsuleNewNode extends Node { @Specialization static PyCapsule doGeneric(Node inliningTarget, Object pointer, Object namePtr, Object destructor, @CachedLibrary(limit = "1") InteropLibrary interopLibrary, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (interopLibrary.isNull(pointer)) { throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT); } - PyCapsule capsule = factory.createCapsuleNativeName(pointer, interopLibrary.isNull(namePtr) ? null : namePtr); + PyCapsule capsule = PFactory.createCapsuleNativeName(language, pointer, interopLibrary.isNull(namePtr) ? null : namePtr); if (!interopLibrary.isNull(destructor)) { capsule.registerDestructor(destructor); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java index 65c58365f9..a7a603d441 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,13 +44,13 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObject; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; import com.oracle.graal.python.builtins.objects.method.PDecoratedMethod; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; @@ -63,10 +63,10 @@ abstract static class PyInstanceMethod_New extends CApiUnaryBuiltinNode { @Specialization static Object staticmethod(Object func, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { checkNonNullArg(inliningTarget, func, raiseNode); - PDecoratedMethod res = factory.createInstancemethod(PythonBuiltinClassType.PInstancemethod); + PDecoratedMethod res = PFactory.createInstancemethod(language); res.setCallable(func); return res; } @@ -77,12 +77,12 @@ abstract static class PyMethod_New extends CApiBinaryBuiltinNode { @Specialization static Object methodNew(Object func, Object self, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { checkNonNullArg(inliningTarget, func, self, raiseNode); // Note: CPython also constructs the object directly, without running the constructor or // checking the inputs - return factory.createMethod(self, func); + return PFactory.createMethod(language, self, func); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java index 6797e32c2e..cf805f5aca 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -50,6 +50,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOAT__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.ComplexNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -173,8 +174,8 @@ abstract static class PyComplex_FromDoubles extends CApiBinaryBuiltinNode { @Specialization static PComplex asDouble(double r, double i, - @Cached PythonObjectFactory factory) { - return factory.createComplex(r, i); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, r, i); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java index f586ef8607..b131a49166 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java @@ -50,6 +50,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.VoidNoReturn; import static com.oracle.graal.python.runtime.exception.ExceptionUtils.printPythonLikeStackTrace; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; @@ -65,7 +66,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -134,15 +135,15 @@ abstract static class PyContextVar_Set extends CApiBinaryBuiltinNode { static Object doGeneric(Object var, Object val, @Bind("this") Node inliningTarget, @Bind PythonContext pythonContext, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (!(var instanceof PContextVar pvar)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } - PythonContext.PythonThreadState threadState = pythonContext.getThreadState(pythonContext.getLanguage(inliningTarget)); + PythonLanguage language = pythonContext.getLanguage(inliningTarget); + PythonContext.PythonThreadState threadState = pythonContext.getThreadState(language); Object oldValue = pvar.getValue(threadState); pvar.setValue(threadState, val); - return factory.createContextVarsToken(pvar, oldValue); + return PFactory.createContextVarsToken(language, pvar, oldValue); } } @@ -160,8 +161,8 @@ static Object doGeneric( abstract static class PyContext_Copy extends CApiUnaryBuiltinNode { @Specialization static Object doGeneric(PContextVarsContext context, - @Cached PythonObjectFactory factory) { - return factory.copyContextVarsContext(context); + @Bind PythonLanguage language) { + return PFactory.copyContextVarsContext(language, context); } } @@ -169,8 +170,8 @@ static Object doGeneric(PContextVarsContext context, abstract static class PyContext_New extends CApiNullaryBuiltinNode { @Specialization static Object doGeneric( - @Cached PythonObjectFactory factory) { - return factory.createContextVarsContext(); + @Bind PythonLanguage language) { + return PFactory.createContextVarsContext(language); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDescrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDescrBuiltins.java index ff8493c9e0..9d174eb562 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDescrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDescrBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -50,6 +50,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyTypeObject; import static com.oracle.graal.python.builtins.objects.cext.common.CExtContext.isClassOrStaticMethod; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi6BuiltinNode; @@ -58,7 +59,7 @@ import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextTypeBuiltins.CreateGetSetNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextTypeBuiltins.NewClassMethodNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; @@ -94,14 +95,14 @@ abstract static class PyTruffleDescr_NewClassMethod extends CApi7BuiltinNode { static Object doNativeCallable(Object methodDefPtr, TruffleString name, Object doc, int flags, Object wrapper, Object methObj, Object type, @Bind("this") Node inliningTarget, @Cached NewClassMethodNode newClassMethodNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object func = newClassMethodNode.execute(inliningTarget, methodDefPtr, name, methObj, flags, wrapper, type, doc); if (!isClassOrStaticMethod(flags)) { /* * NewClassMethodNode only wraps method with METH_CLASS and METH_STATIC set but we * need to do so here. */ - func = factory.createClassmethodFromCallableObj(func); + func = PFactory.createClassmethodFromCallableObj(language, func); } return func; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java index 8804ab75a9..9edf930793 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java @@ -62,6 +62,7 @@ import java.util.logging.Level; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.StrNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi5BuiltinNode; @@ -110,7 +111,7 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; @@ -135,8 +136,9 @@ public final class PythonCextDictBuiltins { abstract static class PyDict_New extends CApiNullaryBuiltinNode { @Specialization - static Object run(@Cached PythonObjectFactory factory) { - return factory.createDict(); + static Object run( + @Bind PythonLanguage language) { + return PFactory.createDict(language); } } @@ -288,8 +290,8 @@ abstract static class PyDict_Copy extends CApiUnaryBuiltinNode { static Object copy(PDict dict, @Bind("this") Node inliningTarget, @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory) { - return factory.createDict(copyNode.execute(inliningTarget, dict.getDictStorage())); + @Bind PythonLanguage language) { + return PFactory.createDict(language, copyNode.execute(inliningTarget, dict.getDictStorage())); } @Fallback @@ -488,8 +490,8 @@ abstract static class PyDict_Keys extends CApiUnaryBuiltinNode { @Specialization static Object keys(PDict dict, @Cached ConstructListNode listNode, - @Cached PythonObjectFactory factory) { - return listNode.execute(null, factory.createDictKeysView(dict)); + @Bind PythonLanguage language) { + return listNode.execute(null, PFactory.createDictKeysView(language, dict)); } @Fallback @@ -503,8 +505,8 @@ abstract static class PyDict_Values extends CApiUnaryBuiltinNode { @Specialization static Object values(PDict dict, @Cached ConstructListNode listNode, - @Cached PythonObjectFactory factory) { - return listNode.execute(null, factory.createDictValuesView(dict)); + @Bind PythonLanguage language) { + return listNode.execute(null, PFactory.createDictValuesView(language, dict)); } @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java index eebc9919a0..407591b9e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java @@ -124,7 +124,7 @@ import com.oracle.graal.python.runtime.exception.ExceptionUtils; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -336,6 +336,7 @@ abstract static class PyErr_NewException extends CApiTernaryBuiltinNode { @Specialization static Object newEx(TruffleString name, Object base, Object dict, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached HashingStorageGetItem getItem, @Cached TruffleString.IndexOfCodePointNode indexOfCodepointNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @@ -345,13 +346,12 @@ static Object newEx(TruffleString name, Object base, Object dict, @Cached InlinedBranchProfile notDotProfile, @Cached InlinedBranchProfile notModuleProfile, @Cached InlinedConditionProfile baseProfile, - @Cached PythonObjectFactory.Lazy factory, @Cached PRaiseNode.Lazy raiseNode) { if (base == PNone.NO_VALUE) { base = PythonErrorType.Exception; } if (dict == PNone.NO_VALUE) { - dict = factory.get(inliningTarget).createDict(); + dict = PFactory.createDict(language); } int length = codePointLengthNode.execute(name, TS_ENCODING); int dotIdx = indexOfCodepointNode.execute(name, '.', 0, length, TS_ENCODING); @@ -367,7 +367,7 @@ static Object newEx(TruffleString name, Object base, Object dict, if (baseProfile.profile(inliningTarget, base instanceof PTuple)) { bases = (PTuple) base; } else { - bases = factory.get(inliningTarget).createTuple(new Object[]{base}); + bases = PFactory.createTuple(language, new Object[]{base}); } return typeNode.execute(null, PythonBuiltinClassType.PythonClass, substringNode.execute(name, dotIdx + 1, length - dotIdx - 1, TS_ENCODING, false), bases, dict, PKeyword.EMPTY_KEYWORDS); @@ -381,12 +381,12 @@ abstract static class PyErr_NewExceptionWithDoc extends CApiQuaternaryBuiltinNod static Object raise(TruffleString name, Object doc, Object base, Object dict, @Cached PyErr_NewException newExNode, @Cached WriteAttributeToObjectNode writeAtrrNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (base == PNone.NO_VALUE) { base = PythonErrorType.Exception; } if (dict == PNone.NO_VALUE) { - dict = factory.createDict(); + dict = PFactory.createDict(language); } Object ex = newExNode.execute(name, base, dict); if (doc != PNone.NO_VALUE) { @@ -406,7 +406,7 @@ Object info( @Cached ExceptionNodes.GetTracebackNode getTracebackNode, @Cached InlinedBranchProfile noExceptionProfile, @Cached GetEscapedExceptionNode getEscapedExceptionNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { AbstractTruffleException currentException = getCaughtExceptionNode.executeFromNative(); if (currentException == null) { noExceptionProfile.enter(inliningTarget); @@ -415,7 +415,7 @@ Object info( assert currentException != PException.NO_EXCEPTION; Object exception = getEscapedExceptionNode.execute(inliningTarget, currentException); Object traceback = noneToNativeNull(inliningTarget, getTracebackNode.execute(inliningTarget, exception)); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, exception), exception, traceback}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, exception), exception, traceback}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFuncBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFuncBuiltins.java index 0aeeef07f6..9835b61b3a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFuncBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFuncBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -47,7 +47,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; @@ -56,10 +56,10 @@ import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.builtins.objects.method.PDecoratedMethod; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.strings.TruffleString; @@ -69,8 +69,8 @@ public final class PythonCextFuncBuiltins { abstract static class PyStaticMethod_New extends CApiUnaryBuiltinNode { @Specialization static Object staticmethod(Object func, - @Cached PythonObjectFactory factory) { - PDecoratedMethod res = factory.createStaticmethod(PythonBuiltinClassType.PStaticmethod); + @Bind PythonLanguage language) { + PDecoratedMethod res = PFactory.createStaticmethod(language); res.setCallable(func); return res; } @@ -80,8 +80,8 @@ static Object staticmethod(Object func, abstract static class PyClassMethod_New extends CApiUnaryBuiltinNode { @Specialization static Object staticmethod(Object callable, - @Cached PythonObjectFactory factory) { - return factory.createClassmethodFromCallableObj(callable); + @Bind PythonLanguage language) { + return PFactory.createClassmethodFromCallableObj(language, callable); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextGenericAliasBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextGenericAliasBuiltins.java index 0b54f33287..bb8895a010 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextGenericAliasBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextGenericAliasBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,10 +44,11 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObject; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Specialization; public final class PythonCextGenericAliasBuiltins { @@ -56,8 +57,8 @@ public final class PythonCextGenericAliasBuiltins { abstract static class Py_GenericAlias extends CApiBinaryBuiltinNode { @Specialization static Object genericAlias(Object origin, Object args, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(origin, args); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, origin, args); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextIterBuiltins.java index e9eeca74f2..b08b938c62 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextIterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextIterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,13 +45,14 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObject; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.IterNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; import com.oracle.graal.python.builtins.objects.iterator.PSequenceIterator; import com.oracle.graal.python.lib.PyIterCheckNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; @@ -73,8 +74,8 @@ static int check(Object obj, abstract static class PySeqIter_New extends CApiUnaryBuiltinNode { @Specialization static PSequenceIterator call(Object seq, - @Cached PythonObjectFactory factory) { - return factory.createSequenceIterator(seq); + @Bind PythonLanguage language) { + return PFactory.createSequenceIterator(language, seq); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java index 6fdcfc1802..4e3c3b4657 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java @@ -56,6 +56,7 @@ import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; @@ -81,14 +82,12 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.builtins.ListNodes.AppendNode; import com.oracle.graal.python.nodes.builtins.TupleNodes.ConstructTupleNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; @@ -106,14 +105,14 @@ static Object newListError(long size, @SuppressWarnings("unused") @Specialization(guards = "size == 0") static Object newEmptyList(long size, - @Shared @Cached PythonObjectFactory factory) { - return factory.createList(PythonUtils.EMPTY_OBJECT_ARRAY); + @Bind PythonLanguage language) { + return PFactory.createList(language); } @Specialization(guards = "size > 0") static Object newList(long size, - @Shared @Cached PythonObjectFactory factory) { - return factory.createList(array(size)); + @Bind PythonLanguage language) { + return PFactory.createList(language, array(size)); } private static Object[] array(long size) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java index 9b935668c4..168e515605 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java @@ -59,6 +59,7 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi5BuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; @@ -84,7 +85,7 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -275,16 +276,16 @@ static long doSignedLong(long n) { @Specialization(guards = "!isInteger(pointer)", limit = "2") static Object doPointer(Object pointer, @CachedLibrary("pointer") InteropLibrary lib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // We capture the native pointer at the time when we create the wrapper if it exists. if (lib.isPointer(pointer)) { try { - return factory.createNativeVoidPtr(pointer, lib.asPointer(pointer)); + return PFactory.createNativeVoidPtr(language, pointer, lib.asPointer(pointer)); } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); } } - return factory.createNativeVoidPtr(pointer); + return PFactory.createNativeVoidPtr(language, pointer); } } @@ -308,23 +309,23 @@ static Object doUnsignedLongPositive(long n) { @Specialization(guards = "n < 0") static Object doUnsignedLongNegative(long n, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(convertToBigInteger(n)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, convertToBigInteger(n)); } @Specialization(guards = "!isInteger(pointer)", limit = "2") static Object doPointer(Object pointer, @CachedLibrary("pointer") InteropLibrary lib, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // We capture the native pointer at the time when we create the wrapper if it exists. if (lib.isPointer(pointer)) { try { - return factory.createNativeVoidPtr(pointer, lib.asPointer(pointer)); + return PFactory.createNativeVoidPtr(language, pointer, lib.asPointer(pointer)); } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); } } - return factory.createNativeVoidPtr(pointer); + return PFactory.createNativeVoidPtr(language, pointer); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMethodBuiltins.java index 5529b70771..3860972a83 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -52,6 +52,7 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___MODULE__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApi9BuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.objects.PNone; @@ -60,7 +61,7 @@ import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -90,7 +91,7 @@ final Object execute(Node inliningTarget, Object methodDefPtr, TruffleString nam @Specialization static Object doNativeCallable(Node inliningTarget, Object methodDefPtr, TruffleString name, Object methObj, Object flags, int wrapper, Object self, Object module, Object cls, Object doc, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached CreateFunctionNode createFunctionNode, @Cached HiddenAttr.WriteNode writeHiddenAttrNode, @Cached(inline = false) WriteAttributeToPythonObjectNode writeAttrNode) { @@ -102,9 +103,9 @@ static Object doNativeCallable(Node inliningTarget, Object methodDefPtr, Truffle writeAttrNode.execute(func, T___DOC__, doc); PBuiltinMethod method; if (cls != PNone.NO_VALUE) { - method = factory.createBuiltinMethod(self, func, cls); + method = PFactory.createBuiltinMethod(language, self, func, cls); } else { - method = factory.createBuiltinMethod(self, func); + method = PFactory.createBuiltinMethod(language, self, func); } writeAttrNode.execute(method, T___MODULE__, module); return method; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextNamespaceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextNamespaceBuiltins.java index 85cb7bd4f3..3973656710 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextNamespaceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextNamespaceBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +45,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; import com.oracle.graal.python.builtins.objects.common.HashingStorage; @@ -57,7 +58,7 @@ import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.namespace.PSimpleNamespace; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -77,16 +78,15 @@ static Object impDict(PDict dict, @Shared("itNext") @Cached HashingStorageIteratorNext itNext, @Shared("itKey") @Cached HashingStorageIteratorKey itKey, @Shared("itVal") @Cached HashingStorageIteratorValue itValue, - @Shared("dylib") @CachedLibrary(limit = "1") DynamicObjectLibrary dyLib, - @Shared @Cached PythonObjectFactory factory) { + @Shared("dylib") @CachedLibrary(limit = "1") DynamicObjectLibrary dyLib) { HashingStorage storage = dict.getDictStorage(); - return impl(inliningTarget, storage, getIterator, itNext, itKey, itValue, dyLib, factory); + return impl(inliningTarget, storage, getIterator, itNext, itKey, itValue, dyLib); } private static Object impl(Node inliningTarget, HashingStorage storage, HashingStorageGetIterator getIterator, HashingStorageIteratorNext itNext, HashingStorageIteratorKey itKey, HashingStorageIteratorValue itValue, - DynamicObjectLibrary dyLib, PythonObjectFactory factory) { - PSimpleNamespace ns = factory.createSimpleNamespace(); + DynamicObjectLibrary dyLib) { + PSimpleNamespace ns = PFactory.createSimpleNamespace(PythonLanguage.get(inliningTarget)); HashingStorageNodes.HashingStorageIterator it = getIterator.execute(inliningTarget, storage); while (itNext.execute(inliningTarget, storage, it)) { Object key = itKey.execute(inliningTarget, storage, it); @@ -104,10 +104,9 @@ static Object impGeneric(Object dict, @Shared("itNext") @Cached HashingStorageIteratorNext itNext, @Shared("itKey") @Cached HashingStorageIteratorKey itKey, @Shared("itVal") @Cached HashingStorageIteratorValue itValue, - @Shared("dylib") @CachedLibrary(limit = "1") DynamicObjectLibrary dyLib, - @Shared @Cached PythonObjectFactory factory) { + @Shared("dylib") @CachedLibrary(limit = "1") DynamicObjectLibrary dyLib) { HashingStorage hs = initNode.execute(null, dict, PKeyword.EMPTY_KEYWORDS); - return impl(inliningTarget, hs, getIterator, itNext, itKey, itValue, dyLib, factory); + return impl(inliningTarget, hs, getIterator, itNext, itKey, itValue, dyLib); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java index c1e8add19d..bb596034d9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java @@ -64,6 +64,7 @@ import java.io.PrintWriter; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.BytesNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.FormatNode; @@ -135,7 +136,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ArrayBasedSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; @@ -538,12 +539,12 @@ static Object bytes(Object obj, @Specialization(guards = "isNoValue(obj)") static Object bytesNoValue(@SuppressWarnings("unused") Object obj, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { /* * Note: CPython calls PyBytes_FromString("") but we do not directly have it. * Therefore, we directly create the bytes object with string "" here. */ - return factory.createBytes(BytesUtils.NULL_STRING); + return PFactory.createBytes(language, BytesUtils.NULL_STRING); } protected static boolean hasBytes(Node inliningTarget, Object obj, PyObjectLookupAttr lookupAttrNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyStateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyStateBuiltins.java index 3993c3c00d..36a161c79b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyStateBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyStateBuiltins.java @@ -72,7 +72,7 @@ import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.ThreadLocalAction; @@ -150,12 +150,11 @@ abstract static class PyThreadState_GetDict extends CApiNullaryBuiltinNode { @TruffleBoundary static PDict get( @Bind("this") Node inliningTarget, - @Bind PythonContext context, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context) { PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); PDict threadStateDict = threadState.getDict(); if (threadStateDict == null) { - threadStateDict = factory.createDict(); + threadStateDict = PFactory.createDict(context.getLanguage()); threadState.setDict(threadStateDict); } return threadStateDict; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyThreadBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyThreadBuiltins.java index df9a34215a..1c813ea024 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyThreadBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPyThreadBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -49,7 +49,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Void; import static com.oracle.graal.python.builtins.objects.ints.PInt.intValue; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiNullaryBuiltinNode; @@ -58,7 +58,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor; import com.oracle.graal.python.builtins.objects.thread.PLock; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; @@ -77,7 +77,7 @@ abstract static class PyThread_allocate_lock extends CApiNullaryBuiltinNode { long allocate() { CApiContext context = getCApiContext(); long id = context.lockId.incrementAndGet() ^ LOCK_MASK; - PLock lock = PythonObjectFactory.getUncached().createLock(PythonBuiltinClassType.PLock); + PLock lock = PFactory.createLock(PythonLanguage.get(null)); context.locks.put(id, lock); return id; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java index 6b9cc18e71..c887fbe379 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -51,6 +51,7 @@ import static com.oracle.graal.python.nodes.ErrorMessages.EXPECTED_S_NOT_P; import static com.oracle.graal.python.nodes.ErrorMessages.NATIVE_S_SUBTYPES_NOT_IMPLEMENTED; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.FrozenSetNode; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.StrNode; @@ -79,7 +80,7 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.truffle.PythonTypes; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -96,13 +97,13 @@ abstract static class PySet_New extends CApiUnaryBuiltinNode { @Specialization(guards = {"!isNone(iterable)", "!isNoValue(iterable)"}) static Object newSet(Object iterable, @Cached ConstructSetNode constructSetNode) { - return constructSetNode.executeWith(null, iterable); + return constructSetNode.execute(null, iterable); } @Specialization static Object newSet(@SuppressWarnings("unused") PNone iterable, - @Cached PythonObjectFactory factory) { - return factory.createSet(); + @Bind PythonLanguage language) { + return PFactory.createSet(language); } } @@ -143,9 +144,8 @@ static Object nextEntry(PSet set, long pos, @Shared @Cached HashingStorageIteratorNext itNext, @Shared @Cached HashingStorageIteratorKey itKey, @Shared @Cached HashingStorageIteratorKeyHash itKeyHash, - @Shared @Cached InlinedLoopConditionProfile loopProfile, - @Shared @Cached PythonObjectFactory.Lazy factory) { - return next(inliningTarget, (int) pos, set.getDictStorage(), getIterator, itNext, itKey, itKeyHash, loopProfile, factory); + @Shared @Cached InlinedLoopConditionProfile loopProfile) { + return next(inliningTarget, (int) pos, set.getDictStorage(), getIterator, itNext, itKey, itKeyHash, loopProfile); } @Specialization(guards = "pos < size(inliningTarget, set, sizeNode)") @@ -156,9 +156,8 @@ static Object nextEntry(PFrozenSet set, long pos, @Shared @Cached HashingStorageIteratorNext itNext, @Shared @Cached HashingStorageIteratorKey itKey, @Shared @Cached HashingStorageIteratorKeyHash itKeyHash, - @Shared @Cached InlinedLoopConditionProfile loopProfile, - @Shared @Cached PythonObjectFactory.Lazy factory) { - return next(inliningTarget, (int) pos, set.getDictStorage(), getIterator, itNext, itKey, itKeyHash, loopProfile, factory); + @Shared @Cached InlinedLoopConditionProfile loopProfile) { + return next(inliningTarget, (int) pos, set.getDictStorage(), getIterator, itNext, itKey, itKeyHash, loopProfile); } @Specialization(guards = {"isPSet(set) || isPFrozenSet(set)", "pos >= size(inliningTarget, set, sizeNode)"}) @@ -198,7 +197,7 @@ protected int size(Node inliningTarget, Object set, PyObjectSizeNode sizeNode) { private static Object next(Node inliningTarget, int pos, HashingStorage storage, HashingStorageGetIterator getIterator, HashingStorageIteratorNext itNext, HashingStorageIteratorKey itKey, HashingStorageIteratorKeyHash itKeyHash, - InlinedLoopConditionProfile loopProfile, PythonObjectFactory.Lazy factory) { + InlinedLoopConditionProfile loopProfile) { HashingStorageIterator it = getIterator.execute(inliningTarget, storage); loopProfile.profileCounted(inliningTarget, pos); for (int i = 0; loopProfile.inject(inliningTarget, i <= pos); i++) { @@ -208,7 +207,7 @@ private static Object next(Node inliningTarget, int pos, HashingStorage storage, } Object key = itKey.execute(inliningTarget, storage, it); long hash = itKeyHash.execute(null, inliningTarget, storage, it); - return factory.get(inliningTarget).createTuple(new Object[]{key, hash}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{key, hash}); } } @@ -237,8 +236,8 @@ static Object newFrozenSet(Object iterable, @SuppressWarnings("unused") @Specialization static Object newFrozenSet(PNone iterable, - @Cached PythonObjectFactory factory) { - return factory.createFrozenSet(PythonBuiltinClassType.PFrozenSet); + @Bind PythonLanguage language) { + return PFactory.createFrozenSet(language); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java index 3e8a392940..19fd093562 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -68,6 +68,7 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.StructSequence; import com.oracle.graal.python.builtins.objects.type.PythonClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -76,7 +77,8 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -136,10 +138,10 @@ Object doGeneric(TruffleString typeName, TruffleString typeDoc, Object fields, i @Cached ReadAttributeFromObjectNode readTypeBuiltinNode, @CachedLibrary(limit = "1") DynamicObjectLibrary dylib, @Cached CallNode callTypeNewNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object typeBuiltin = readTypeBuiltinNode.execute(getCore().getBuiltins(), BuiltinNames.T_TYPE); - PTuple bases = factory.createTuple(new Object[]{PythonBuiltinClassType.PTuple}); - PDict namespace = factory.createDict(new PKeyword[]{new PKeyword(SpecialAttributeNames.T___DOC__, typeDoc)}); + PTuple bases = PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PTuple}); + PDict namespace = PFactory.createDict(language, new PKeyword[]{new PKeyword(SpecialAttributeNames.T___DOC__, typeDoc)}); Object cls = callTypeNewNode.executeWithoutFrame(typeBuiltin, typeName, bases, namespace); initNode.execute(cls, fields, nInSequence); if (cls instanceof PythonClass) { @@ -157,7 +159,8 @@ static Object doGeneric(Object cls, @Bind("this") Node inliningTarget, @Cached("createForceType()") ReadAttributeFromObjectNode readRealSizeNode, @Cached CastToJavaIntExactNode castToIntNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { try { Object realSizeObj = readRealSizeNode.execute(cls, StructSequence.T_N_FIELDS); @@ -167,7 +170,7 @@ static Object doGeneric(Object cls, int realSize = castToIntNode.execute(inliningTarget, realSizeObj); Object[] values = new Object[realSize]; Arrays.fill(values, PNone.NO_VALUE); // Initialize to C NULL - return factory.createTuple(cls, values); + return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(values)); } } catch (CannotCastException e) { throw CompilerDirectives.shouldNotReachHere("attribute 'n_fields' is expected to be a Java int"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTracebackBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTracebackBuiltins.java index ada7ed0b0c..556612a663 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTracebackBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTracebackBuiltins.java @@ -46,6 +46,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyFrameObject; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Void; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiTernaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; @@ -56,7 +57,7 @@ import com.oracle.graal.python.builtins.objects.traceback.MaterializeLazyTracebackNode; import com.oracle.graal.python.builtins.objects.traceback.PTraceback; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; @@ -72,8 +73,8 @@ abstract static class _PyTraceback_Add extends CApiTernaryBuiltinNode { static Object tbHere(TruffleString funcname, TruffleString filename, int lineno, @Cached PyCode_NewEmpty newCode, @Cached PyTraceBack_Here pyTraceBackHereNode, - @Cached PythonObjectFactory factory) { - PFrame frame = factory.createPFrame(null, newCode.execute(filename, funcname, lineno), factory.createDict(), factory.createDict()); + @Bind PythonLanguage language) { + PFrame frame = PFactory.createPFrame(language, null, newCode.execute(filename, funcname, lineno), PFactory.createDict(language), PFactory.createDict(language)); pyTraceBackHereNode.execute(frame); return PNone.NONE; } @@ -85,8 +86,7 @@ abstract static class PyTraceBack_Here extends CApiUnaryBuiltinNode { static int tbHere(PFrame frame, @Bind("this") Node inliningTarget, @Bind PythonContext context, - @Cached MaterializeLazyTracebackNode materializeLazyTracebackNode, - @Cached PythonObjectFactory factory) { + @Cached MaterializeLazyTracebackNode materializeLazyTracebackNode) { PythonContext.PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); AbstractTruffleException currentException = threadState.getCurrentException(); if (currentException != null) { @@ -94,7 +94,7 @@ static int tbHere(PFrame frame, if (threadState.getCurrentTraceback() != null) { currentTraceback = materializeLazyTracebackNode.execute(inliningTarget, threadState.getCurrentTraceback()); } - PTraceback newTraceback = factory.createTraceback(frame, frame.getLine(), currentTraceback); + PTraceback newTraceback = PFactory.createTraceback(PythonLanguage.get(inliningTarget), frame, frame.getLine(), currentTraceback); threadState.setCurrentTraceback(new LazyTraceback(newTraceback)); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java index b1ae9aa248..94356e0df5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -48,6 +48,7 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Py_ssize_t; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; @@ -68,7 +69,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.builtins.TupleNodes.GetNativeTupleStorage; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; @@ -86,7 +87,7 @@ abstract static class PyTuple_New extends CApiUnaryBuiltinNode { @Specialization static PTuple doGeneric(long longSize, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode, @Cached CStructAccess.AllocateNode alloc) { int size = (int) longSize; @@ -99,7 +100,7 @@ static PTuple doGeneric(long longSize, */ Object mem = alloc.alloc((longSize + 1) * CStructAccess.POINTER_SIZE); NativeObjectSequenceStorage storage = NativeObjectSequenceStorage.create(mem, size, size, true); - return factory.createTuple(storage); + return PFactory.createTuple(language, storage); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java index 2d0d418396..d7cc998246 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java @@ -103,7 +103,7 @@ import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; import com.oracle.graal.python.util.Function; import com.oracle.graal.python.util.PythonUtils; @@ -190,7 +190,7 @@ abstract static class PyTruffle_Compute_Mro extends CApiBinaryBuiltinNode { @TruffleBoundary static Object doIt(PythonNativeClass self, TruffleString className) { PythonAbstractClass[] doSlowPath = TypeNodes.ComputeMroNode.doSlowPath(self); - return PythonObjectFactory.getUncached().createTuple(new MroSequenceStorage(className, doSlowPath)); + return PFactory.createTuple(PythonLanguage.get(null), new MroSequenceStorage(className, doSlowPath)); } } @@ -208,7 +208,7 @@ abstract static class PyTruffle_NewTypeDict extends CApiUnaryBuiltinNode { static PDict doGeneric(PythonNativeClass nativeClass) { PythonLanguage language = PythonLanguage.get(null); NativeTypeDictStorage nativeTypeStore = new NativeTypeDictStorage(language.getEmptyShape()); - PDict dict = PythonObjectFactory.getUncached().createDict(new DynamicObjectStorage(nativeTypeStore)); + PDict dict = PFactory.createDict(language, new DynamicObjectStorage(nativeTypeStore)); HiddenAttr.WriteNode.executeUncached(dict, HiddenAttr.INSTANCESHAPE, language.getShapeForClass(nativeClass)); return dict; } @@ -269,7 +269,7 @@ abstract static class NewClassMethodNode extends Node { @Specialization(guards = "isClassOrStaticMethod(flags)") static Object classOrStatic(Node inliningTarget, Object methodDefPtr, TruffleString name, Object methObj, int flags, int wrapper, Object type, Object doc, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached HiddenAttr.WriteNode writeHiddenAttrNode, @Cached(inline = false) WriteAttributeToPythonObjectNode writeAttrNode, @Exclusive @Cached CreateFunctionNode createFunctionNode) { @@ -277,9 +277,9 @@ static Object classOrStatic(Node inliningTarget, Object methodDefPtr, TruffleStr writeHiddenAttrNode.execute(inliningTarget, func, METHOD_DEF_PTR, methodDefPtr); PythonObject function; if ((flags & METH_CLASS) != 0) { - function = factory.createClassmethodFromCallableObj(func); + function = PFactory.createClassmethodFromCallableObj(language, func); } else { - function = factory.createStaticmethodFromCallableObj(func); + function = PFactory.createStaticmethodFromCallableObj(language, func); } writeAttrNode.execute(function, T___NAME__, name); writeAttrNode.execute(function, T___DOC__, doc); @@ -358,7 +358,7 @@ public static int addMember(Object clazz, PDict tpDict, TruffleString memberName } // create member descriptor - GetSetDescriptor memberDescriptor = PythonObjectFactory.getUncached().createMemberDescriptor(getterObject, setterObject, memberName, clazz); + GetSetDescriptor memberDescriptor = PFactory.createMemberDescriptor(language, getterObject, setterObject, memberName, clazz); WriteAttributeToPythonObjectNode.getUncached().execute(memberDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); // add member descriptor to tp_dict @@ -376,7 +376,6 @@ abstract static class CreateGetSetNode extends Node { @Specialization @TruffleBoundary static GetSetDescriptor createGetSet(Node inliningTarget, TruffleString name, Object cls, Object getter, Object setter, Object doc, Object closure, - @Cached(inline = false) PythonObjectFactory factory, @CachedLibrary(limit = "2") InteropLibrary interopLibrary) { assert !(doc instanceof CArrayWrapper); // note: 'doc' may be NULL; in this case, we would store 'None' @@ -385,7 +384,7 @@ static GetSetDescriptor createGetSet(Node inliningTarget, TruffleString name, Ob if (!interopLibrary.isNull(getter)) { RootCallTarget getterCT = getterCallTarget(name, language); getter = EnsureExecutableNode.executeUncached(getter, PExternalFunctionWrapper.GETTER); - get = factory.createBuiltinFunction(name, cls, EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(getter, closure), 0, getterCT); + get = PFactory.createBuiltinFunction(language, name, cls, EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(getter, closure), 0, getterCT); } PBuiltinFunction set = null; @@ -393,11 +392,11 @@ static GetSetDescriptor createGetSet(Node inliningTarget, TruffleString name, Ob if (hasSetter) { RootCallTarget setterCT = setterCallTarget(name, language); setter = EnsureExecutableNode.executeUncached(setter, PExternalFunctionWrapper.SETTER); - set = factory.createBuiltinFunction(name, cls, EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(setter, closure), 0, setterCT); + set = PFactory.createBuiltinFunction(language, name, cls, EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(setter, closure), 0, setterCT); } // create get-set descriptor - GetSetDescriptor descriptor = factory.createGetSetDescriptor(get, set, name, cls, hasSetter); + GetSetDescriptor descriptor = PFactory.createGetSetDescriptor(language, get, set, name, cls, hasSetter); WriteAttributeToPythonObjectNode.executeUncached(descriptor, T___DOC__, doc); return descriptor; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java index a5b8e9a05d..4dbf93ba44 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java @@ -84,6 +84,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.StrNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.ChrNode; @@ -103,6 +104,7 @@ import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; +import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.UnicodeFromFormatNode; import com.oracle.graal.python.builtins.objects.cext.capi.PySequenceArrayWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.UnicodeObjectNodes.UnicodeAsWideCharNode; @@ -149,7 +151,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -316,8 +318,7 @@ static Object withPString(PString str, @Cached StringNodes.IsInternedStringNode isInternedStringNode, @Cached StringNodes.InternStringNode internNode, @Cached HashingStorageGetItem getItem, - @Cached HashingStorageSetItem setItem, - @Cached PythonObjectFactory.Lazy factory) { + @Cached HashingStorageSetItem setItem) { if (!unicodeCheckExactNode.execute(inliningTarget, str)) { return getNativeNull(inliningTarget); } @@ -330,10 +331,11 @@ static Object withPString(PString str, return str; } TruffleString ts = cast.execute(inliningTarget, str); - PDict dict = getCApiContext(inliningTarget).getInternedUnicode(); + CApiContext cApiContext = getCApiContext(inliningTarget); + PDict dict = cApiContext.getInternedUnicode(); if (dict == null) { - dict = factory.get(inliningTarget).createDict(); - getCApiContext(inliningTarget).setInternedUnicode(dict); + dict = PFactory.createDict(cApiContext.getContext().getLanguage(internNode)); + cApiContext.setInternedUnicode(dict); } Object interned = getItem.execute(inliningTarget, dict.getDictStorage(), ts); if (interned == null) { @@ -692,8 +694,8 @@ static int doGeneric(Object type, long lindex, abstract static class PyTruffleUnicode_New extends CApiQuaternaryBuiltinNode { @Specialization static Object doGeneric(Object ptr, long elements, long elementSize, int isAscii, - @Cached PythonObjectFactory factory) { - return factory.createString(new NativeCharSequence(ptr, (int) elements, (int) elementSize, isAscii != 0)); + @Bind PythonLanguage language) { + return PFactory.createString(language, new NativeCharSequence(ptr, (int) elements, (int) elementSize, isAscii != 0)); } } @@ -709,17 +711,12 @@ private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNo }; } - private static PString asPString(TruffleString ts, SwitchEncodingNode switchEncodingNode, PythonObjectFactory factory) { - return factory.createString(switchEncodingNode.execute(ts, TS_ENCODING)); - } - @Specialization(guards = "ptrLib.isPointer(ptr)") static Object doNative(Object ptr, long byteLength, int kind, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared("ptrLib") @CachedLibrary(limit = "1") InteropLibrary ptrLib, @Cached FromNativePointerNode fromNativePointerNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { try { int iByteLength = PInt.intValueExact(byteLength); @@ -730,7 +727,7 @@ static Object doNative(Object ptr, long byteLength, int kind, * For now, we use ISO-8859-1 and UTF-16 but that's not entirely correct. */ TruffleString ts = fromNativePointerNode.execute(ptr, 0, iByteLength, srcEncoding, true); - return asPString(ts, switchEncodingNode, factory); + return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(MemoryError); } @@ -743,13 +740,12 @@ static Object doManaged(Object ptr, long byteLength, int kind, @Cached GetByteArrayNode getByteArrayNode, @Cached FromByteArrayNode fromByteArrayNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { try { Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); byte[] ucsBytes = getByteArrayNode.execute(inliningTarget, ptr, byteLength); TruffleString ts = fromByteArrayNode.execute(ucsBytes, srcEncoding); - return asPString(ts, switchEncodingNode, factory); + return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (InteropException e) { /* * This means that we cannot read the array-like foreign object or the foreign @@ -774,23 +770,18 @@ private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNo }; } - private static PString asPString(TruffleString ts, SwitchEncodingNode switchEncodingNode, PythonObjectFactory factory) { - return factory.createString(switchEncodingNode.execute(ts, TS_ENCODING)); - } - @Specialization(guards = "ptrLib.isPointer(ptr)") static Object doNative(Object ptr, long byteLength, int kind, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared("ptrLib") @CachedLibrary(limit = "1") InteropLibrary ptrLib, @Cached FromNativePointerNode fromNativePointerNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { try { int iByteLength = PInt.intValueExact(byteLength); Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); TruffleString ts = fromNativePointerNode.execute(ptr, 0, iByteLength, srcEncoding, true); - return asPString(ts, switchEncodingNode, factory); + return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(MemoryError); } @@ -803,13 +794,12 @@ static Object doManaged(Object ptr, long byteLength, int kind, @Cached GetByteArrayNode getByteArrayNode, @Cached FromByteArrayNode fromByteArrayNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { try { Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); byte[] ucsBytes = getByteArrayNode.execute(inliningTarget, ptr, byteLength); TruffleString ts = fromByteArrayNode.execute(ucsBytes, srcEncoding); - return asPString(ts, switchEncodingNode, factory); + return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (InteropException e) { /* * This means that we cannot read the array-like foreign object or the foreign @@ -826,8 +816,8 @@ static Object doManaged(Object ptr, long byteLength, int kind, abstract static class PyUnicode_FromString extends CApiUnaryBuiltinNode { @Specialization static PString run(TruffleString str, - @Cached PythonObjectFactory factory) { - return factory.createString(str); + @Bind PythonLanguage language) { + return PFactory.createString(language, str); } @Specialization @@ -859,12 +849,12 @@ abstract static class PyTruffleUnicode_DecodeUTF8Stateful extends CApiQuaternary @Specialization static Object doUtf8Decode(Object cByteArray, long size, TruffleString errors, int reportConsumed, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - PBytes bytes = factory.createBytes(getByteArrayNode.execute(inliningTarget, cByteArray, size)); + PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); return decode.call(null, bytes, T_UTF8, errors, reportConsumed == 0); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); @@ -880,12 +870,12 @@ abstract static class PyTruffleUnicode_DecodeUTF16Stateful extends CApi5BuiltinN @Specialization static Object decode(Object cByteArray, long size, TruffleString errors, int byteorder, int reportConsumed, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - PBytes bytes = factory.createBytes(getByteArrayNode.execute(inliningTarget, cByteArray, size)); + PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); TruffleString encoding; if (byteorder == 0) { encoding = T_UTF_16; @@ -909,12 +899,12 @@ abstract static class PyTruffleUnicode_DecodeUTF32Stateful extends CApi5BuiltinN @Specialization static Object decode(Object cByteArray, long size, TruffleString errors, int byteorder, int reportConsumed, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - PBytes bytes = factory.createBytes(getByteArrayNode.execute(inliningTarget, cByteArray, size)); + PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); TruffleString encoding; if (byteorder == 0) { encoding = T_UTF_32; @@ -948,10 +938,9 @@ abstract static class PyUnicode_EncodeFSDefault extends CApiUnaryBuiltinNode { static PBytes fromObject(Object s, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castStr, - @Cached EncodeNativeStringNode encode, - @Cached PythonObjectFactory factory) { + @Cached EncodeNativeStringNode encode) { byte[] array = encode.execute(StandardCharsets.UTF_8, castStr.execute(inliningTarget, s), T_REPLACE); - return factory.createBytes(array); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), array); } } @@ -973,10 +962,9 @@ abstract static class PyUnicode_FromWideChar extends CApiBinaryBuiltinNode { Object doInt(Object arr, long size, @Bind("this") Node inliningTarget, @Cached ReadUnicodeArrayNode readArray, - @Cached TruffleString.FromIntArrayUTF32Node fromArray, - @Cached PythonObjectFactory factory) { + @Cached TruffleString.FromIntArrayUTF32Node fromArray) { assert TS_ENCODING == Encoding.UTF_32 : "needs switch_encoding otherwise"; - return factory.createString(fromArray.execute(readArray.execute(inliningTarget, arr, castToInt(size), CStructs.wchar_t.size()))); + return PFactory.createString(PythonLanguage.get(inliningTarget), fromArray.execute(readArray.execute(inliningTarget, arr, castToInt(size), CStructs.wchar_t.size()))); } } @@ -989,16 +977,14 @@ protected NativeEncoderNode(Charset charset) { @Specialization(guards = "isNoValue(errors)") Object doUnicode(Object s, @SuppressWarnings("unused") PNone errors, - @Shared("encodeNode") @Cached EncodeNativeStringNode encodeNativeStringNode, - @Shared @Cached PythonObjectFactory factory) { - return doUnicode(s, T_STRICT, encodeNativeStringNode, factory); + @Shared("encodeNode") @Cached EncodeNativeStringNode encodeNativeStringNode) { + return doUnicode(s, T_STRICT, encodeNativeStringNode); } @Specialization Object doUnicode(Object s, TruffleString errors, - @Shared("encodeNode") @Cached EncodeNativeStringNode encodeNativeStringNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeNativeStringNode.execute(charset, s, errors)); + @Shared("encodeNode") @Cached EncodeNativeStringNode encodeNativeStringNode) { + return PFactory.createBytes(PythonLanguage.get(this), encodeNativeStringNode.execute(charset, s, errors)); } @Fallback @@ -1194,11 +1180,10 @@ static Object doit(Object encoding, Object object, long length, long start, long @Bind("this") Node inliningTarget, @Cached GetByteArrayNode getByteArrayNode, @Cached CallNode callNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { PBytes bytes; try { - bytes = factory.createBytes(getByteArrayNode.execute(inliningTarget, object, length)); + bytes = PFactory.createBytes(PythonLanguage.get(inliningTarget), getByteArrayNode.execute(inliningTarget, object, length)); } catch (InteropException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java index 0b9fb8aaaf..2a7e28741d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -103,15 +104,15 @@ public void initialize(Python3Core core) { @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_CN); - registerCodec("gb2312", 0, CodecType.STATELESS, 0, MappingType.DECONLY, MAPPING_LIST, CODEC_LIST, codec, factory); - registerCodec("gbk", 1, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("gb18030", 2, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("hz", 3, CodecType.STATEFUL, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("gbkext", -1, null, 1, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("gbcommon", -1, null, 2, MappingType.ENCONLY, MAPPING_LIST, null, codec, factory); - registerCodec("gb18030ext", -1, null, 3, MappingType.ENCDEC, MAPPING_LIST, null, codec, factory); + registerCodec("gb2312", 0, CodecType.STATELESS, 0, MappingType.DECONLY, MAPPING_LIST, CODEC_LIST, codec, language); + registerCodec("gbk", 1, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("gb18030", 2, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("hz", 3, CodecType.STATEFUL, -1, null, null, CODEC_LIST, codec, language); + registerCodec("gbkext", -1, null, 1, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("gbcommon", -1, null, 2, MappingType.ENCONLY, MAPPING_LIST, null, codec, language); + registerCodec("gb18030ext", -1, null, 3, MappingType.ENCDEC, MAPPING_LIST, null, codec, language); } @Builtin(name = "getcodec", minNumOfPositionalArgs = 1) @@ -124,7 +125,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -136,8 +137,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java index 59f6e9f429..79329e4033 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -99,11 +100,11 @@ public void initialize(Python3Core core) { @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_HK); - registerCodec("big5hkscs", 0, CodecType.STATELESS_WINIT, 0, MappingType.DECONLY, MAPPING_LIST, CODEC_LIST, codec, factory); - registerCodec("big5hkscs_bmp", -1, null, 1, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, factory); - registerCodec("big5hkscs_nonbmp", -1, null, 2, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, factory); + registerCodec("big5hkscs", 0, CodecType.STATELESS_WINIT, 0, MappingType.DECONLY, MAPPING_LIST, CODEC_LIST, codec, language); + registerCodec("big5hkscs_bmp", -1, null, 1, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, language); + registerCodec("big5hkscs_nonbmp", -1, null, 2, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, language); } @Builtin(name = "getcodec", minNumOfPositionalArgs = 1) @@ -116,7 +117,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -128,8 +129,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java index 883ea00440..fdf58b9d1e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -65,7 +66,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -99,16 +100,16 @@ protected List> getNodeFa @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_ISO2022); int i = 0; - registerCodec("iso2022_kr", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp_1", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp_2", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp_2004", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp_3", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("iso2022_jp_ext", i, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, factory); + registerCodec("iso2022_kr", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp_1", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp_2", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp_2004", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp_3", i++, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); + registerCodec("iso2022_jp_ext", i, CodecType.ISO2022, -1, null, null, CODEC_LIST, codec, language); } @Override @@ -126,7 +127,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -138,8 +139,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java index 4d1e9d09a1..7555de5d80 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -108,29 +109,29 @@ protected List> getNodeFa @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_JP); int i = 0; - registerCodec("shift_jis", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("cp932", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("euc_jp", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("shift_jis_2004", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("euc_jis_2004", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("euc_jisx0213", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("shift_jisx0213", i, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); + registerCodec("shift_jis", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("cp932", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("euc_jp", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("shift_jis_2004", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("euc_jis_2004", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("euc_jisx0213", i++, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("shift_jisx0213", i, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); i = 0; - registerCodec("jisx0208", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0212", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisxcommon", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_1_bmp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_2_bmp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_bmp", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_1_emp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_2_emp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_emp", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, factory); - registerCodec("jisx0213_pair", -1, null, i++, MappingType.ENCDEC, MAPPING_LIST, null, codec, factory); - registerCodec("cp932ext", -1, null, i, MappingType.ENCDEC, MAPPING_LIST, null, codec, factory); + registerCodec("jisx0208", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0212", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisxcommon", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_1_bmp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_2_bmp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_bmp", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_1_emp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_2_emp", -1, null, i++, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_emp", -1, null, i++, MappingType.ENCONLY, MAPPING_LIST, null, codec, language); + registerCodec("jisx0213_pair", -1, null, i++, MappingType.ENCDEC, MAPPING_LIST, null, codec, language); + registerCodec("cp932ext", -1, null, i, MappingType.ENCDEC, MAPPING_LIST, null, codec, language); } @Override @@ -148,7 +149,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -160,8 +161,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java index 70d50acc4e..25f99a0321 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -96,14 +97,14 @@ protected List> getNodeFa @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_KR); - registerCodec("euc_kr", 0, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("cp949", 1, CodecType.STATELESS, 1, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, factory); - registerCodec("johab", 2, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); + registerCodec("euc_kr", 0, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("cp949", 1, CodecType.STATELESS, 1, MappingType.ENCONLY, MAPPING_LIST, CODEC_LIST, codec, language); + registerCodec("johab", 2, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); - registerCodec("ksx1001", -1, null, 0, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); - registerCodec("cp949ext", -1, null, 2, MappingType.DECONLY, MAPPING_LIST, null, codec, factory); + registerCodec("ksx1001", -1, null, 0, MappingType.DECONLY, MAPPING_LIST, null, codec, language); + registerCodec("cp949ext", -1, null, 2, MappingType.DECONLY, MAPPING_LIST, null, codec, language); } @Override @@ -121,7 +122,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -133,8 +134,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java index 0f82419396..8a71f69d73 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -94,11 +95,11 @@ protected List> getNodeFa @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule codec = core.lookupBuiltinModule(T__CODECS_TW); - registerCodec("big5", 0, CodecType.STATELESS, 0, MappingType.ENCDEC, MAPPING_LIST, CODEC_LIST, codec, factory); - registerCodec("cp950", 1, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, factory); - registerCodec("cp950ext", -1, null, 1, MappingType.ENCDEC, MAPPING_LIST, null, codec, factory); + registerCodec("big5", 0, CodecType.STATELESS, 0, MappingType.ENCDEC, MAPPING_LIST, CODEC_LIST, codec, language); + registerCodec("cp950", 1, CodecType.STATELESS, -1, null, null, CODEC_LIST, codec, language); + registerCodec("cp950ext", -1, null, 1, MappingType.ENCDEC, MAPPING_LIST, null, codec, language); } @Override @@ -116,7 +117,7 @@ static Object getcodec(Object encoding, @Cached TruffleString.EqualNode isEqual, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { @@ -128,8 +129,8 @@ static Object getcodec(Object encoding, throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } - PyCapsule codecobj = factory.createCapsuleJavaName(codec, PyMultibyteCodec_CAPSULE_NAME); - return createCodec(inliningTarget, codecobj, factory, raiseNode); + PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); + return createCodec(inliningTarget, codecobj, raiseNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java index 6995a40711..126804b23c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -52,6 +52,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -64,7 +65,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -119,16 +120,16 @@ static Object ts(VirtualFrame frame, MultibyteCodecObject self, TruffleString uc @Exclusive @Cached MultibyteCodecUtil.EncodeNode encodeNode, @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared @Cached TruffleString.EqualNode isEqual, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { TruffleString errorcb = internalErrorCallback(errors, isEqual); MultibyteCodecState state = self.codec.encinit(errorcb); int datalen = codePointLengthNode.execute(ucvt, TS_ENCODING); - PBytes r = encodeEmptyInput(datalen, MBENC_FLUSH | MBENC_RESET, factory); + PBytes r = encodeEmptyInput(inliningTarget, datalen, MBENC_FLUSH | MBENC_RESET); if (r == null) { MultibyteEncodeBuffer buf = new MultibyteEncodeBuffer(ucvt); - r = encodeNode.execute(frame, inliningTarget, self.codec, state, buf, errorcb, MBENC_FLUSH | MBENC_RESET, factory); + r = encodeNode.execute(frame, inliningTarget, self.codec, state, buf, errorcb, MBENC_FLUSH | MBENC_RESET); } - return factory.createTuple(new Object[]{r, datalen}); + return PFactory.createTuple(language, new Object[]{r, datalen}); } @Specialization(guards = "!isTruffleString(input)") @@ -140,7 +141,7 @@ static Object notTS(VirtualFrame frame, MultibyteCodecObject self, Object input, @Exclusive @Cached MultibyteCodecUtil.EncodeNode encodeNode, @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared @Cached TruffleString.EqualNode isEqual, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object ucvt = input; if (!unicodeCheck.execute(inliningTarget, input)) { @@ -151,7 +152,7 @@ static Object notTS(VirtualFrame frame, MultibyteCodecObject self, Object input, } TruffleString str = toTruffleStringNode.execute(inliningTarget, ucvt); - return ts(frame, self, str, errors, inliningTarget, encodeNode, codePointLengthNode, isEqual, factory); + return ts(frame, self, str, errors, inliningTarget, encodeNode, codePointLengthNode, isEqual, language); } } @@ -186,13 +187,13 @@ protected ArgumentClinicProvider getArgumentClinic() { Object decode(VirtualFrame frame, MultibyteCodecObject self, byte[] input, TruffleString errors, @Cached MultibyteCodecUtil.DecodeErrorNode decodeErrorNode, @Cached TruffleString.EqualNode isEqual, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int datalen = input.length; TruffleString errorcb = internalErrorCallback(errors, isEqual); if (datalen == 0) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, 0}); + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, 0}); } MultibyteDecodeBuffer buf = new MultibyteDecodeBuffer(input); MultibyteCodecState state = self.codec.decinit(errorcb); @@ -205,7 +206,7 @@ Object decode(VirtualFrame frame, MultibyteCodecObject self, byte[] input, Truff } } - return factory.createTuple(new Object[]{buf.toTString(), datalen}); + return PFactory.createTuple(language, new Object[]{buf.toTString(), datalen}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java index b48118e590..207f24926a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -71,6 +71,7 @@ import java.nio.CharBuffer; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.codecs.CodecsRegistry.PyCodecLookupErrorNode; import com.oracle.graal.python.builtins.objects.bytes.BytesNodes; import com.oracle.graal.python.builtins.objects.bytes.PBytes; @@ -86,7 +87,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -170,7 +171,7 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, MultibyteCodecState state, MultibyteEncodeBuffer buf, Object errors, int e, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached BaseExceptionAttrNode attrNode, @Cached SequenceStorageNodes.GetInternalObjectArrayNode getArray, @Cached PyUnicodeCheckNode unicodeCheckNode, @@ -233,10 +234,10 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, /* use cached exception object if available */ if (buf.excobj == null) { - buf.excobj = factory.createBaseException(UnicodeEncodeError); + buf.excobj = PFactory.createBaseException(language, UnicodeEncodeError); TruffleString encoding = codec.encoding; Object[] args = new Object[]{encoding, buf.toTString(), start, end, reason}; - buf.excobj.setArgs(factory.createTuple(args)); + buf.excobj.setArgs(PFactory.createTuple(language, args)); buf.excobj.setExceptionAttributes(args); } else { attrNode.execute(buf.excobj, start, IDX_START, UNICODE_ERROR_ATTR_FACTORY); @@ -277,11 +278,10 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, if (isUnicode) { TruffleString str = toTString.execute(inliningTarget, tobj); int datalen = codePointLengthNode.execute(str, TS_ENCODING); - retstr = encodeEmptyInput(datalen, MBENC_FLUSH, factory); + retstr = encodeEmptyInput(inliningTarget, datalen, MBENC_FLUSH); if (retstr == null) { MultibyteEncodeBuffer tmpbuf = new MultibyteEncodeBuffer(str); - retstr = encodeNode.execute(frame, inliningTarget, codec, state, tmpbuf, ERROR_STRICT, MBENC_FLUSH, - factory); + retstr = encodeNode.execute(frame, inliningTarget, codec, state, tmpbuf, ERROR_STRICT, MBENC_FLUSH); } } else { retstr = (PBytes) tobj; @@ -326,7 +326,7 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, // MultibyteCodecState state, MultibyteDecodeBuffer buf, TruffleString errors, int e, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached BaseExceptionAttrNode attrNode, @Cached SequenceStorageNodes.GetInternalObjectArrayNode getArray, @Cached PyUnicodeCheckNode unicodeCheckNode, @@ -368,11 +368,11 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, /* use cached exception object if available */ if (buf.excobj == null) { - buf.excobj = factory.createBaseException(UnicodeDecodeError); - PBytes inbuf = buf.createPBytes(factory); + buf.excobj = PFactory.createBaseException(language, UnicodeDecodeError); + PBytes inbuf = PFactory.createBytes(language, buf.inputBuffer.array(), buf.getInpos()); TruffleString encoding = codec.encoding; Object[] args = new Object[]{encoding, inbuf, buf.getInpos(), start, end, reason}; - buf.excobj.setArgs(factory.createTuple(args)); + buf.excobj.setArgs(PFactory.createTuple(language, args)); buf.excobj.setExceptionAttributes(args); } else { attrNode.execute(buf.excobj, start, IDX_START, UNICODE_ERROR_ATTR_FACTORY); @@ -426,10 +426,9 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, } } - protected static PBytes encodeEmptyInput(int len, int flags, - PythonObjectFactory factory) { + protected static PBytes encodeEmptyInput(Node inliningTarget, int len, int flags) { if (len == 0 && (flags & MBENC_RESET) == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(PythonLanguage.get(inliningTarget)); } return null; } @@ -438,18 +437,16 @@ protected static PBytes encodeEmptyInput(int len, int flags, @GenerateCached(false) abstract static class EncodeNode extends Node { - abstract PBytes execute(VirtualFrame frame, Node inliningTarget, MultibyteCodec codec, MultibyteCodecState state, MultibyteEncodeBuffer buf, Object errors, int flags, - PythonObjectFactory factory); + abstract PBytes execute(VirtualFrame frame, Node inliningTarget, MultibyteCodec codec, MultibyteCodecState state, MultibyteEncodeBuffer buf, Object errors, int flags); // multibytecodec_encode @Specialization static PBytes encode(VirtualFrame frame, Node inliningTarget, MultibyteCodec codec, MultibyteCodecState state, MultibyteEncodeBuffer buf, Object errors, int flags, - PythonObjectFactory factory, @Cached(inline = false) EncodeErrorNode encodeErrorNode, @Cached PRaiseNode.Lazy raiseNode) { // if (buf.inlen == 0 && (flags & MBENC_RESET) == 0) { - // return factory.createBytes(EMPTY_BYTE_ARRAY); + // return PFactory.createBytes(language, EMPTY_BYTE_ARRAY); // } if (buf.getInlen() > (MAXSIZE - 16) / 2) { @@ -486,7 +483,7 @@ static PBytes encode(VirtualFrame frame, Node inliningTarget, MultibyteCodec cod } } - return buf.createPBytes(factory); + return buf.createPBytes(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java index 20edfb8590..94672160ec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -48,10 +48,8 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; -import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.exception.PBaseException; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -102,10 +100,6 @@ protected boolean isFull() { return !inputBuffer.hasRemaining(); } - protected PBytes createPBytes(PythonObjectFactory factory) { - return factory.createBytes(inputBuffer.array(), getInpos()); - } - @TruffleBoundary protected void replaceInbuf(byte[] inbuf) { inputBuffer = ByteBuffer.wrap(inbuf); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java index 39e1b48d56..34f298cf23 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -46,10 +46,11 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.exception.PBaseException; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -138,8 +139,8 @@ protected void expandOutputBuffer(int esize, Node raisingNode) { } @TruffleBoundary - protected PBytes createPBytes(PythonObjectFactory factory) { - outobj = factory.createBytes(outputBuffer.array(), outputBuffer.position()); + protected PBytes createPBytes() { + outobj = PFactory.createBytes(PythonLanguage.get(null), outputBuffer.array(), outputBuffer.position()); return outobj; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java index 236c749107..8e471c805d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -54,9 +54,11 @@ import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.UnicodeError; +import java.math.BigInteger; import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -67,6 +69,7 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PRaiseNode; @@ -79,7 +82,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -108,14 +111,15 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, @Cached CastToTruffleStringNode castToStringNode, @Cached PyObjectGetAttr getAttr, @Cached TruffleString.EqualNode isEqual, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { // "|s:IncrementalDecoder" TruffleString errors = null; if (err != PNone.NO_VALUE) { errors = castToStringNode.execute(inliningTarget, err); } - MultibyteIncrementalDecoderObject self = factory.createMultibyteIncrementalDecoderObject(type); + MultibyteIncrementalDecoderObject self = PFactory.createMultibyteIncrementalDecoderObject(language, type, getInstanceShape.execute(type)); Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { @@ -240,12 +244,12 @@ abstract static class GetStateNode extends PythonUnaryBuiltinNode { @Specialization static Object getstate(MultibyteIncrementalDecoderObject self, @Bind("this") Node inliningTarget, - @Cached HiddenAttr.WriteNode writeHiddenAttrNode, - @Cached PythonObjectFactory factory) { - PBytes buffer = factory.createBytes(Arrays.copyOf(self.pending, self.pendingsize)); - PInt statelong = factory.createInt(0); + @Bind PythonLanguage language, + @Cached HiddenAttr.WriteNode writeHiddenAttrNode) { + PBytes buffer = PFactory.createBytes(language, Arrays.copyOf(self.pending, self.pendingsize)); + PInt statelong = PFactory.createInt(language, BigInteger.ZERO); writeHiddenAttrNode.execute(inliningTarget, statelong, HiddenAttr.DECODER_OBJECT, self.state); - return factory.createTuple(new Object[]{buffer, statelong}); + return PFactory.createTuple(language, new Object[]{buffer, statelong}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java index 8b13e3d60d..5302fc7ae5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -65,6 +65,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -74,6 +75,7 @@ import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.ints.IntNodes; import com.oracle.graal.python.builtins.objects.ints.PInt; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.lib.PyUnicodeCheckNode; @@ -87,7 +89,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -122,7 +124,8 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, @Cached CastToTruffleStringNode castToStringNode, @Cached PyObjectGetAttr getAttr, @Cached TruffleString.EqualNode isEqual, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { // "|s:IncrementalEncoder" TruffleString errors = null; @@ -130,7 +133,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, errors = castToStringNode.execute(inliningTarget, err); } - MultibyteIncrementalEncoderObject self = factory.createMultibyteIncrementalEncoderObject(type); + MultibyteIncrementalEncoderObject self = PFactory.createMultibyteIncrementalEncoderObject(language, type, getInstanceShape.execute(type)); Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { @@ -159,13 +162,11 @@ static PNone init(@SuppressWarnings("unused") MultibyteIncrementalEncoderObject @SuppressWarnings("truffle-inlining") // footprint reduction 44 -> 25 protected abstract static class EncodeStatefulNode extends Node { - abstract Object execute(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Object unistr, int end, - PythonObjectFactory factory); + abstract Object execute(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Object unistr, int end); // encoder_encode_stateful @Specialization static Object ts(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, TruffleString ucvt, int end, - PythonObjectFactory factory, @Bind("this") Node inliningTarget, @Exclusive @Cached MultibyteCodecUtil.EncodeNode encodeNode, @Shared @Cached TruffleString.ConcatNode concatNode, @@ -183,12 +184,11 @@ static Object ts(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Truffl int datalen = codePointLengthNode.execute(inbuf, TS_ENCODING); PBytes r; try { - r = encodeEmptyInput(datalen, MBENC_FLUSH | MBENC_RESET, factory); + r = encodeEmptyInput(inliningTarget, datalen, MBENC_FLUSH | MBENC_RESET); if (r == null) { MultibyteEncodeBuffer buf = new MultibyteEncodeBuffer(inbuf); r = encodeNode.execute(frame, inliningTarget, ctx.codec, ctx.state, buf, - ctx.errors, end != 0 ? MBENC_FLUSH | MBENC_RESET : 0, - factory); + ctx.errors, end != 0 ? MBENC_FLUSH | MBENC_RESET : 0); if (buf.getInpos() < datalen) { if (datalen - buf.getInpos() > MAXENCPENDING) { /* normal codecs can't reach here */ @@ -208,7 +208,6 @@ static Object ts(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Truffl @Specialization(guards = "!isTruffleString(unistr)") static Object notTS(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Object unistr, int end, - PythonObjectFactory factory, @Bind("this") Node inliningTarget, @Cached PyObjectStrAsObjectNode strNode, @Cached PyUnicodeCheckNode unicodeCheckNode, @@ -226,7 +225,7 @@ static Object notTS(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Obj } } TruffleString str = toTruffleStringNode.execute(inliningTarget, ucvt); - return ts(frame, ctx, str, end, factory, inliningTarget, encodeNode, concatNode, codePointLengthNode, substringNode, raiseNode); + return ts(frame, ctx, str, end, inliningTarget, encodeNode, concatNode, codePointLengthNode, substringNode, raiseNode); } } @@ -244,9 +243,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object encode(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Object unistr, int end, - @Cached EncodeStatefulNode encodeStatefulNode, - @Cached PythonObjectFactory factory) { - return encodeStatefulNode.execute(frame, ctx, unistr, end, factory); + @Cached EncodeStatefulNode encodeStatefulNode) { + return encodeStatefulNode.execute(frame, ctx, unistr, end); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java index 3603962382..02e9cf81ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -54,6 +54,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -106,7 +107,8 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object stream, @Cached CastToTruffleStringNode castToStringNode, @Cached PyObjectGetAttr getAttr, @Cached TruffleString.EqualNode isEqual, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { // "O|s:StreamReader" TruffleString errors = null; @@ -114,7 +116,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object stream, errors = castToStringNode.execute(inliningTarget, err); } - MultibyteStreamReaderObject self = factory.createMultibyteStreamReaderObject(type); + MultibyteStreamReaderObject self = PFactory.createMultibyteStreamReaderObject(language, type, getInstanceShape.execute(type)); Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_IS_UNEXPECTED_TYPE); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java index 22cabe1b6c..f00753fc89 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -62,6 +63,7 @@ import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.common.SequenceNodes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.nodes.PRaiseNode; @@ -71,7 +73,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; @@ -104,14 +106,15 @@ static Object mbstreamwriterNew(VirtualFrame frame, Object type, Object stream, @Cached CastToTruffleStringNode castToStringNode, @Cached PyObjectGetAttr getAttr, @Cached TruffleString.EqualNode isEqual, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { // "O|s:StreamWriter" TruffleString errors = null; if (err != PNone.NO_VALUE) { errors = castToStringNode.execute(inliningTarget, err); } - MultibyteStreamWriterObject self = factory.createMultibyteStreamWriterObject(type); + MultibyteStreamWriterObject self = PFactory.createMultibyteStreamWriterObject(language, type, getInstanceShape.execute(type)); Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { @@ -147,10 +150,9 @@ abstract static class WriteNode extends PythonBinaryBuiltinNode { static Object write(VirtualFrame frame, MultibyteStreamWriterObject self, Object strobj, @Bind("this") Node inliningTarget, @Cached MultibyteIncrementalEncoderBuiltins.EncodeStatefulNode encodeStatefulNode, - @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PythonObjectFactory factory) { + @Cached PyObjectCallMethodObjArgs callMethod) { // mbstreamwriter_iwrite - Object str = encodeStatefulNode.execute(frame, self, strobj, 0, factory); + Object str = encodeStatefulNode.execute(frame, self, strobj, 0); callMethod.execute(frame, inliningTarget, self.stream, WRITE, str); return PNone.NONE; } @@ -167,15 +169,14 @@ static Object writelines(VirtualFrame frame, MultibyteStreamWriterObject self, P @Cached MultibyteIncrementalEncoderBuiltins.EncodeStatefulNode encodeStatefulNode, @Cached SequenceNodes.GetSequenceStorageNode getStorage, @Cached SequenceStorageNodes.GetItemNode getItem, - @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PythonObjectFactory factory) { + @Cached PyObjectCallMethodObjArgs callMethod) { SequenceStorage sq = getStorage.execute(inliningTarget, lines); for (int i = 0; i < sq.length(); i++) { /* length can be changed even within this loop */ Object strobj = getItem.execute(sq, i); // mbstreamwriter_iwrite - Object str = encodeStatefulNode.execute(frame, self, strobj, 0, factory); + Object str = encodeStatefulNode.execute(frame, self, strobj, 0); callMethod.execute(frame, inliningTarget, self.stream, WRITE, str); } return PNone.NONE; @@ -199,18 +200,16 @@ static Object reset(VirtualFrame frame, MultibyteStreamWriterObject self, @Bind("this") Node inliningTarget, @Cached PyObjectCallMethodObjArgs callMethod, @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Cached MultibyteCodecUtil.EncodeNode encodeNode, - @Cached PythonObjectFactory factory) { + @Cached MultibyteCodecUtil.EncodeNode encodeNode) { if (self.pending == null) { return PNone.NONE; } int datalen = codePointLengthNode.execute(self.pending, TS_ENCODING); - PBytes pwrt = encodeEmptyInput(datalen, MBENC_FLUSH | MBENC_RESET, factory); + PBytes pwrt = encodeEmptyInput(inliningTarget, datalen, MBENC_FLUSH | MBENC_RESET); if (pwrt == null) { MultibyteEncodeBuffer buf = new MultibyteEncodeBuffer(self.pending); pwrt = encodeNode.execute(frame, inliningTarget, self.codec, self.state, buf, - self.errors, MBENC_FLUSH | MBENC_RESET, - factory); + self.errors, MBENC_FLUSH | MBENC_RESET); } /* * some pending buffer can be truncated when UnicodeEncodeError is raised on 'strict' diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java index e4dfad8bc4..2ad485b8a1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -50,10 +50,10 @@ import java.nio.charset.Charset; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; 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.cjkcodecs.DBCSMap.MappingType; import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteCodec.CodecType; @@ -62,7 +62,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.CharsetMapping; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -99,7 +99,7 @@ protected List> getNodeFa protected static void registerCodec(String name, int cidx, CodecType ct, int midx, MappingType mt, DBCSMap[] maps, MultibyteCodec[] codecs, - PythonModule codec, PythonObjectFactory factory) { + PythonModule codec, PythonLanguage language) { TruffleString tsName = toTruffleStringUncached(name); TruffleString normalizedEncoding = CharsetMapping.normalizeUncached(tsName); Charset charset = CharsetMapping.getCharsetNormalized(normalizedEncoding); @@ -110,7 +110,7 @@ protected static void registerCodec(String name, int cidx, CodecType ct, int mid if (midx != -1) { DBCSMap h = maps[midx] = new DBCSMap(name, tsName, charset, mt); codec.setAttribute(toTruffleStringUncached(h.charsetMapName), - factory.createCapsuleJavaName(h, PyMultibyteCodec_CAPSULE_NAME)); + PFactory.createCapsuleJavaName(language, h, PyMultibyteCodec_CAPSULE_NAME)); } } } @@ -127,13 +127,11 @@ abstract static class CreateCodecNode extends PythonUnaryBuiltinNode { @Specialization static Object createCodec(PyCapsule arg, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - return createCodec(inliningTarget, arg, factory, raiseNode); + return createCodec(inliningTarget, arg, raiseNode); } static Object createCodec(Node inliningTarget, PyCapsule arg, - PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { if (!PyCapsule.capsuleJavaNameIs(arg, PyMultibyteCodec_CAPSULE_NAME)) { throw raiseNode.get(inliningTarget).raise(ValueError, ARGUMENT_TYPE_INVALID); @@ -141,7 +139,7 @@ static Object createCodec(Node inliningTarget, PyCapsule arg, MultibyteCodec codec; codec = (MultibyteCodec) arg.getPointer(); codec.codecinit(); - return factory.createMultibyteCodecObject(PythonBuiltinClassType.MultibyteCodec, codec); + return PFactory.createMultibyteCodecObject(PythonLanguage.get(inliningTarget), codec); } @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java index 3d876912c4..548ef01be4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java @@ -83,7 +83,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ByteArrayBuilder; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -120,8 +120,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @Cached(inline = false) TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached(inline = false) HashingStorageSetItem setItemNode, - @Cached PRaiseNode.Lazy raiseNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached PRaiseNode.Lazy raiseNode) { int len = Math.min(codePointLengthNode.execute(map, TS_ENCODING), 256); if (len == 0) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); @@ -134,12 +133,12 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map, Arrays.fill(level1, (byte) 0xFF); Arrays.fill(level2, (byte) 0xFF); if (codePointAtIndexNode.execute(map, 0, TS_ENCODING, ErrorHandling.BEST_EFFORT) != 0) { - return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode, factory); + return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode); } for (int i = 1; i < len; ++i) { int cp = codePointAtIndexNode.execute(map, i, TS_ENCODING, ErrorHandling.BEST_EFFORT); if (cp == 0 || cp > 0xFFFF) { - return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode, factory); + return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode); } if (cp == 0xFFFE) { continue; @@ -154,7 +153,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map, } } if (count2 >= 0xFF || count3 >= 0xFF) { - return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode, factory); + return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode); } byte[] level23 = new byte[16 * count2 + 128 * count3]; @@ -176,17 +175,16 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map, int i3 = 128 * (level23[i2] & 0xFF) + o3; level23[l3Start + i3] = (byte) i; } - return factory.createEncodingMap(count2, count3, level1, level23); + return PFactory.createEncodingMap(PythonLanguage.get(inliningTarget), count2, count3, level1, level23); } - private static Object doDict(VirtualFrame frame, Node inliningTarget, TruffleString map, int len, TruffleString.CodePointAtIndexNode codePointAtIndexNode, HashingStorageSetItem setItemNode, - PythonObjectFactory factory) { + private static Object doDict(VirtualFrame frame, Node inliningTarget, TruffleString map, int len, TruffleString.CodePointAtIndexNode codePointAtIndexNode, HashingStorageSetItem setItemNode) { HashingStorage store = PDict.createNewStorage(len); for (int i = 0; i < len; ++i) { int cp = codePointAtIndexNode.execute(map, i, TS_ENCODING, ErrorHandling.BEST_EFFORT); store = setItemNode.execute(frame, inliningTarget, store, cp, i); } - return factory.createDict(store); + return PFactory.createDict(PythonLanguage.get(inliningTarget), store); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java index 4b7db4d338..3c893aaced 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java @@ -60,6 +60,7 @@ import java.nio.ByteOrder; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.codecs.CodecsRegistry.PyCodecLookupErrorNode; @@ -91,7 +92,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -284,19 +285,19 @@ abstract static class IgnoreErrorHandlerNode extends ErrorHandlerBaseNode { @Specialization(guards = "isDecode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doDecodeException(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PyUnicodeDecodeErrorGetEndNode getEndNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, getEndNode.execute(inliningTarget, exception)}); + @Cached PyUnicodeDecodeErrorGetEndNode getEndNode) { + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, getEndNode.execute(inliningTarget, exception)}); } @Specialization(guards = "isEncodeOrTranslate(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncodeOrTranslateException(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, getEndNode.execute(inliningTarget, exception)}); + @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode) { + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, getEndNode.execute(inliningTarget, exception)}); } @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") @@ -317,27 +318,27 @@ abstract static class ReplaceErrorHandlerNode extends ErrorHandlerBaseNode { @Specialization(guards = "isDecode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doDecodeException(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PyUnicodeDecodeErrorGetEndNode getEndNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{T_REPLACEMENT, getEndNode.execute(inliningTarget, exception)}); + @Cached PyUnicodeDecodeErrorGetEndNode getEndNode) { + return PFactory.createTuple(language, new Object[]{T_REPLACEMENT, getEndNode.execute(inliningTarget, exception)}); } @Specialization(guards = "isEncodeOrTranslate(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncodeOrTranslateException(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, - @Cached TruffleString.RepeatNode repeatNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached TruffleString.RepeatNode repeatNode) { TruffleString replacement = isEncode(inliningTarget, exception, pyObjectTypeCheck) ? T_QUESTIONMARK : T_REPLACEMENT; int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); int n = end - start; // CPython raises SystemError for negative values, we return an empty string TruffleString result = n < 1 ? T_EMPTY_STRING : repeatNode.execute(replacement, n, TS_ENCODING); - return factory.createTuple(new Object[]{result, end}); + return PFactory.createTuple(language, new Object[]{result, end}); } @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") @@ -356,14 +357,14 @@ abstract static class XmlCharRefReplaceErrorHandlerNode extends ErrorHandlerBase @Specialization(guards = "isEncode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncode(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetObjectNode getObjectNode, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached TruffleString.FromByteArrayNode fromByteArrayNode, - @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { TruffleString src = getObjectNode.execute(inliningTarget, exception); int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); @@ -377,7 +378,7 @@ static Object doEncode(PBaseException exception, pos = appendXmlCharRefReplacement(replacement, pos, codePointAtIndexNode.execute(src, i, TS_ENCODING, ErrorHandling.BEST_EFFORT)); } TruffleString resultAscii = fromByteArrayNode.execute(replacement, Encoding.US_ASCII, false); - return factory.createTuple(new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); + return PFactory.createTuple(language, new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); } @Specialization(guards = "!isEncode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") @@ -396,6 +397,7 @@ abstract static class BackslashReplaceErrorHandlerNode extends ErrorHandlerBaseN @Specialization(guards = "isDecode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doDecodeException(VirtualFrame frame, PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeDecodeErrorGetObjectNode getObjectNode, @@ -404,13 +406,12 @@ static Object doDecodeException(VirtualFrame frame, PBaseException exception, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached @Shared TruffleString.FromByteArrayNode fromByteArrayNode, - @Cached @Shared TruffleString.SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached @Shared TruffleString.SwitchEncodingNode switchEncodingNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); Object object = getObjectNode.execute(inliningTarget, exception); if (start >= end) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, end}); + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, end}); } byte[] replacement = new byte[4 * (end - start)]; int pos = 0; @@ -424,25 +425,25 @@ static Object doDecodeException(VirtualFrame frame, PBaseException exception, accessLib.release(srcBuf, frame, indirectCallData); } TruffleString resultAscii = fromByteArrayNode.execute(replacement, Encoding.US_ASCII, false); - return factory.createTuple(new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); + return PFactory.createTuple(language, new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); } @Specialization(guards = "isEncodeOrTranslate(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncodeOrTranslateException(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetObjectNode getObjectNode, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached @Shared TruffleString.FromByteArrayNode fromByteArrayNode, - @Cached @Shared TruffleString.SwitchEncodingNode switchEncodingNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached @Shared TruffleString.SwitchEncodingNode switchEncodingNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); TruffleString src = getObjectNode.execute(inliningTarget, exception); if (start >= end) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, end}); + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, end}); } int len = 0; for (int i = start; i < end; ++i) { @@ -462,7 +463,7 @@ static Object doEncodeOrTranslateException(PBaseException exception, pos = BytesUtils.unicodeNonAsciiEscape(cp, pos, replacement, true); } TruffleString resultAscii = fromByteArrayNode.execute(replacement, Encoding.US_ASCII, false); - return factory.createTuple(new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); + return PFactory.createTuple(language, new Object[]{switchEncodingNode.execute(resultAscii, TS_ENCODING), end}); } @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") @@ -481,6 +482,7 @@ abstract static class NameReplaceErrorHandlerNode extends ErrorHandlerBaseNode { @Specialization(guards = "isEncode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncode(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetObjectNode getObjectNode, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @@ -491,13 +493,12 @@ static Object doEncode(PBaseException exception, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, - @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleStringBuilder.ToStringNode toStringNode) { TruffleString src = getObjectNode.execute(inliningTarget, exception); int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); if (start >= end) { - return factory.createTuple(new Object[]{T_EMPTY_STRING, start}); + return PFactory.createTuple(language, new Object[]{T_EMPTY_STRING, start}); } TruffleStringBuilder tsb = TruffleStringBuilder.create(TS_ENCODING); byte[] buf = new byte[1 + 1 + 8]; // \UNNNNNNNN @@ -515,7 +516,7 @@ static Object doEncode(PBaseException exception, appendStringNode.execute(tsb, switchEncodingNode.execute(fromByteArrayNode.execute(buf, 0, len, Encoding.US_ASCII, true), TS_ENCODING)); } } - return factory.createTuple(new Object[]{toStringNode.execute(tsb), end}); + return PFactory.createTuple(language, new Object[]{toStringNode.execute(tsb), end}); } @Specialization(guards = "!isEncode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") @@ -534,6 +535,7 @@ abstract static class SurrogatePassErrorHandlerNode extends ErrorHandlerBaseNode @Specialization(guards = "isEncode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncode(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Exclusive @Cached PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetObjectNode getObjectNode, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @@ -541,7 +543,6 @@ static Object doEncode(PBaseException exception, @Cached PyUnicodeEncodeErrorGetEncodingNode getEncodingNode, @Exclusive @Cached GetStandardEncodingNode getStandardEncodingNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); @@ -552,7 +553,7 @@ static Object doEncode(PBaseException exception, throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); } if (start >= end) { - return factory.createTuple(new Object[]{factory.createBytes(new byte[0]), end}); + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, new byte[0]), end}); } byte[] result = new byte[encoding.byteLength * (end - start)]; int pos = 0; @@ -564,12 +565,13 @@ static Object doEncode(PBaseException exception, encodeCodepoint(encoding, result, pos, cp); pos += encoding.byteLength; } - return factory.createTuple(new Object[]{factory.createBytes(result), end}); + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, result), end}); } @Specialization(guards = "isDecode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doDecode(VirtualFrame frame, PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @SuppressWarnings("unused") @Exclusive @Cached PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeDecodeErrorGetObjectNode getObjectNode, @@ -580,7 +582,6 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached TruffleString.FromCodePointNode fromCodePointNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { int start = getStartNode.execute(inliningTarget, exception); getEndNode.execute(inliningTarget, exception); // called for side effects only @@ -600,7 +601,7 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, if (!isSurrogate(cp)) { throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); } - return factory.createTuple(new Object[]{fromCodePointNode.execute(cp, TS_ENCODING, true), start + encoding.byteLength}); + return PFactory.createTuple(language, new Object[]{fromCodePointNode.execute(cp, TS_ENCODING, true), start + encoding.byteLength}); } finally { accessLib.release(srcBuf, frame, indirectCallData); } @@ -671,18 +672,18 @@ abstract static class SurrogateEscapeErrorHandlerNode extends ErrorHandlerBaseNo @Specialization(guards = "isEncode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doEncode(PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @SuppressWarnings("unused") @Exclusive @Cached PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeEncodeOrTranslateErrorGetObjectNode getObjectNode, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); TruffleString src = getObjectNode.execute(inliningTarget, exception); if (start >= end) { - return factory.createTuple(new Object[]{factory.createBytes(new byte[0]), end}); + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, new byte[0]), end}); } byte[] result = new byte[end - start]; int pos = 0; @@ -693,12 +694,13 @@ static Object doEncode(PBaseException exception, } result[pos++] = (byte) (cp - 0xdc00); } - return factory.createTuple(new Object[]{factory.createBytes(result), end}); + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, result), end}); } @Specialization(guards = "isDecode(inliningTarget, exception, pyObjectTypeCheck)", limit = "1") static Object doDecode(VirtualFrame frame, PBaseException exception, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @SuppressWarnings("unused") @Exclusive @Cached PyObjectTypeCheck pyObjectTypeCheck, @Cached PyUnicodeDecodeErrorGetObjectNode getObjectNode, @@ -708,7 +710,6 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); @@ -729,7 +730,7 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, if (consumed == 0) { throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); } - return factory.createTuple(new Object[]{toStringNode.execute(tsb), start + consumed}); + return PFactory.createTuple(language, new Object[]{toStringNode.execute(tsb), start + consumed}); } finally { accessLib.release(srcBuf, frame, indirectCallData); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java index efd9e7d425..3361d93597 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java @@ -56,6 +56,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -69,6 +70,7 @@ import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.type.PythonClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyCallableCheckNode; import com.oracle.graal.python.lib.PyDictDelItem; import com.oracle.graal.python.lib.PyDictGetItem; @@ -91,7 +93,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -146,7 +148,7 @@ public void initialize(Python3Core core) { addBuiltinConstant("QUOTE_ALL", QUOTE_ALL.ordinal()); addBuiltinConstant("QUOTE_NONNUMERIC", QUOTE_NONNUMERIC.ordinal()); addBuiltinConstant("QUOTE_NONE", QUOTE_NONE.ordinal()); - addBuiltinConstant(T__DIALECTS, core.factory().createDict()); + addBuiltinConstant(T__DIALECTS, PFactory.createDict(core.getLanguage())); super.initialize(core); } @@ -262,10 +264,10 @@ static Object createReader(VirtualFrame frame, Object csvfile, Object dialectObj @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, @Cached CallNode callNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object inputIter = getIter.execute(frame, inliningTarget, csvfile); CSVDialect dialect = (CSVDialect) callNode.execute(frame, PythonBuiltinClassType.CSVDialect, new Object[]{dialectObj}, kwargs); - return factory.createCSVReader(PythonBuiltinClassType.CSVReader, inputIter, dialect); + return PFactory.createCSVReader(language, inputIter, dialect); } } @@ -278,14 +280,14 @@ static Object createReader(VirtualFrame frame, Object outputFile, Object dialect @Cached CallNode callNode, @Cached PyObjectLookupAttr lookupAttr, @Cached PyCallableCheckNode checkCallable, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object write = lookupAttr.execute(frame, inliningTarget, outputFile, T_WRITE); if (write == PNone.NO_VALUE || !checkCallable.execute(inliningTarget, write)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_MUST_HAVE_WRITE_METHOD, "argument 1"); } CSVDialect dialect = (CSVDialect) callNode.execute(frame, PythonBuiltinClassType.CSVDialect, new Object[]{dialectObj}, kwargs); - return factory.createCSVWriter(PythonBuiltinClassType.CSVWriter, write, dialect); + return PFactory.createCSVWriter(language, write, dialect); } } @@ -529,7 +531,7 @@ private static Object createCSVDialect(Node raisingNode, PythonBuiltinClassType int quoteCharCodePoint = TruffleString.EqualNode.getUncached().execute(quoteChar, T_NOT_SET, TS_ENCODING) ? NOT_SET_CODEPOINT : TruffleString.CodePointAtIndexNode.getUncached().execute(quoteChar, 0, TS_ENCODING); - return PythonObjectFactory.getUncached().createCSVDialect(cls, delimiter, delimiterCodePoint, doubleQuote, + return PFactory.createCSVDialect(PythonLanguage.get(null), cls, TypeNodes.GetInstanceShape.executeUncached(cls), delimiter, delimiterCodePoint, doubleQuote, escapeChar, escapeCharCodePoint, lineTerminator, quoteChar, quoteCharCodePoint, quoting, skipInitialSpace, strict); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java index 8a843a5c27..8ee12c5684 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java @@ -57,6 +57,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -130,9 +131,9 @@ static Object nextPos(VirtualFrame frame, CSVReader self, @Cached CastToTruffleStringNode castToStringNode, @Cached GetClassNode getClassNode, @Cached IsBuiltinObjectProfile isBuiltinClassProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { - PList fields = factory.createList(); + PList fields = PFactory.createList(language); CSVModuleBuiltins csvModuleBuiltins = (CSVModuleBuiltins) PythonContext.get(inliningTarget).lookupBuiltinModule(T__CSV).getBuiltins(); self.parseReset(); do { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java index 79144207e7..4207cd1891 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -55,7 +56,7 @@ import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; @@ -162,9 +163,9 @@ abstract static class ParamFuncNode extends Node { @Specialization static PyCArgObject paramFunc(CDataObject self, StgDictObject stgDict, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached(inline = false) TruffleString.CodePointAtIndexNode codePointAtIndexNode) { - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); switch (stgDict.paramfunc) { // Corresponds to PyCArrayType_paramfunc case PyCArrayTypeParamFunc -> { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java index a7deaae0c6..6381bad907 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -59,6 +59,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -86,7 +87,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; @@ -169,12 +170,12 @@ protected abstract static class BaseReduceNode extends PythonUnaryBuiltinNode { @Specialization static Object reduce(VirtualFrame frame, CDataObject self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached("create(T___DICT__)") GetAttributeNode getAttributeNode, @Cached ReadAttributeFromPythonObjectNode readAttrNode, @Cached PointerNodes.ReadBytesNode readBytesNode, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { StgDictObject stgDict = pyObjectStgDictNode.execute(inliningTarget, self); if ((stgDict.flags & (TYPEFLAG_ISPOINTER | TYPEFLAG_HASPOINTER)) != 0) { @@ -182,17 +183,17 @@ static Object reduce(VirtualFrame frame, CDataObject self, } Object dict = getAttributeNode.executeObject(frame, self); Object[] t1 = new Object[]{dict, null}; - t1[1] = factory.createBytes(readBytesNode.execute(inliningTarget, self.b_ptr, self.b_size)); + t1[1] = PFactory.createBytes(language, readBytesNode.execute(inliningTarget, self.b_ptr, self.b_size)); Object clazz = getClassNode.execute(inliningTarget, self); - Object[] t2 = new Object[]{clazz, factory.createTuple(t1)}; + Object[] t2 = new Object[]{clazz, PFactory.createTuple(language, t1)}; PythonModule ctypes = PythonContext.get(inliningTarget).lookupBuiltinModule(T__CTYPES); Object unpickle = readAttrNode.execute(ctypes, T_UNPICKLE, null); if (unpickle == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, toTruffleStringUncached("unpickle isn't supported yet.")); } - Object[] t3 = new Object[]{unpickle, factory.createTuple(t2)}; - return factory.createTuple(t3); // "O(O(NN))" + Object[] t3 = new Object[]{unpickle, PFactory.createTuple(language, t2)}; + return PFactory.createTuple(language, t3); // "O(O(NN))" } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java index 7e848296df..878c21408f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -60,6 +60,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -99,7 +100,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -420,6 +421,7 @@ protected abstract static class PyCDataSetNode extends Node { @Specialization static void PyCData_set(VirtualFrame frame, CDataObject dst, Object type, FieldSet setfunc, Object value, int index, int size, Pointer ptr, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached SetFuncNode setFuncNode, @Cached CallNode callNode, @Cached PyTypeCheck pyTypeCheck, @@ -429,14 +431,13 @@ static void PyCData_set(VirtualFrame frame, CDataObject dst, Object type, FieldS @Cached KeepRefNode keepRefNode, @Cached PointerNodes.MemcpyNode memcpyNode, @Cached PointerNodes.WritePointerNode writePointerNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, dst)) { throw raiseNode.get(inliningTarget).raise(TypeError, NOT_A_CTYPE_INSTANCE); } Object result = PyCDataSetInternal(frame, inliningTarget, type, setfunc, value, size, ptr, - factory, + language, pyTypeCheck, setFuncNode, callNode, @@ -455,7 +456,7 @@ static void PyCData_set(VirtualFrame frame, CDataObject dst, Object type, FieldS */ // corresponds to _PyCData_set static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object type, FieldSet setfunc, Object value, int size, Pointer ptr, - PythonObjectFactory factory, + PythonLanguage language, PyTypeCheck pyTypeCheck, SetFuncNode setFuncNode, CallNode callNode, @@ -480,7 +481,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object if (PGuards.isPTuple(value)) { Object ob = callNode.execute(frame, type, value); return PyCDataSetInternal(frame, inliningTarget, type, setfunc, ob, size, ptr, - factory, + language, pyTypeCheck, setFuncNode, callNode, @@ -501,7 +502,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object if (isInstanceNode.executeWith(frame, value, type)) { memcpyNode.execute(inliningTarget, ptr, src.b_ptr, size); - return GetKeepedObjects(src, factory); + return GetKeepedObjects(src, language); } if (pyTypeCheck.isPyCPointerTypeObject(inliningTarget, type) && pyTypeCheck.isArrayObject(inliningTarget, value)) { @@ -516,7 +517,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object writePointerNode.execute(inliningTarget, ptr, src.b_ptr); - Object keep = GetKeepedObjects(src, factory); + Object keep = GetKeepedObjects(src, language); /* * We are assigning an array object to a field which represents a pointer. This has @@ -525,7 +526,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object * it's object list. So we create a tuple, containing b_objects list PLUS the array * itself, and return that! */ - return factory.createTuple(new Object[]{keep, value}); + return PFactory.createTuple(language, new Object[]{keep, value}); } throw raiseNode.get(inliningTarget).raise(TypeError, INCOMPATIBLE_TYPES_P_INSTANCE_INSTEAD_OF_P_INSTANCE, value, type); } @@ -536,14 +537,14 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object * Code to keep needed objects alive */ - protected static CDataObject PyCData_GetContainer(CDataObject leaf, PythonObjectFactory factory) { + protected static CDataObject PyCData_GetContainer(CDataObject leaf, PythonLanguage language) { CDataObject self = leaf; while (self.b_base != null) { self = self.b_base; } if (self.b_objects == null) { if (self.b_length != 0) { - self.b_objects = factory.createDict(); + self.b_objects = PFactory.createDict(language); } else { self.b_objects = PNone.NONE; } @@ -551,8 +552,8 @@ protected static CDataObject PyCData_GetContainer(CDataObject leaf, PythonObject return self; } - static Object GetKeepedObjects(CDataObject target, PythonObjectFactory factory) { - return PyCData_GetContainer(target, factory).b_objects; + static Object GetKeepedObjects(CDataObject target, PythonLanguage language) { + return PyCData_GetContainer(target, language).b_objects; } /* @@ -585,13 +586,13 @@ static void none(CDataObject target, int index, PNone keep) { @Specialization(guards = "!isNone(keep)") static void KeepRef(VirtualFrame frame, Node inliningTarget, CDataObject target, int index, Object keep, + @Bind PythonLanguage language, @Cached(inline = false) TruffleStringBuilder.AppendStringNode appendStringNode, @Cached(inline = false) TruffleStringBuilder.ToStringNode toStringNode, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, @Cached HashingStorageSetItem setItem, - @Cached(inline = false) PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - CDataObject ob = PyCData_GetContainer(target, factory); + CDataObject ob = PyCData_GetContainer(target, language); if (!PGuards.isDict(ob.b_objects)) { ob.b_objects = keep; return; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java index b760db1fc6..1602d3d3ed 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java @@ -56,6 +56,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.CoreFunctions; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -116,9 +117,9 @@ static Object PyCArrayType_from_ctype(VirtualFrame frame, Object itemtype, int l @Cached IsTypeNode isTypeNode, @Cached GetNameNode getNameNode, @Cached SimpleTruffleStringFormatNode simpleFormatNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { - Object key = factory.createTuple(new Object[]{itemtype, length}); + Object key = PFactory.createTuple(language, new Object[]{itemtype, length}); CtypesThreadState ctypes = CtypesThreadState.get(context, context.getLanguage(inliningTarget)); Object result = getItem.execute(frame, inliningTarget, ctypes.cache, key); if (result != null) { @@ -129,8 +130,8 @@ static Object PyCArrayType_from_ctype(VirtualFrame frame, Object itemtype, int l throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_A_TYPE_OBJECT); } TruffleString name = simpleFormatNode.format("%s_Array_%d", getNameNode.execute(inliningTarget, itemtype), length); - PDict dict = factory.createDict(new PKeyword[]{new PKeyword(T__LENGTH_, length), new PKeyword(T__TYPE_, itemtype)}); - PTuple tuple = factory.createTuple(new Object[]{PyCArray}); + PDict dict = PFactory.createDict(language, new PKeyword[]{new PKeyword(T__LENGTH_, length), new PKeyword(T__TYPE_, itemtype)}); + PTuple tuple = PFactory.createTuple(language, new Object[]{PyCArray}); result = callNode.execute(frame, PyCArrayType, name, tuple, dict); HashingStorage newStorage = setItem.execute(frame, inliningTarget, ctypes.cache, key, result); assert newStorage == ctypes.cache; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java index c5d71e14c5..593e499b8d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -237,14 +238,15 @@ TruffleString PyCField_repr(CFieldObject self, @SuppressWarnings("fallthrough") abstract static class PyCFieldFromDesc extends Node { - abstract CFieldObject execute(Node inliningTarget, Object desc, int index, int bitsize, int pack, boolean big_endian, int[] props, PythonObjectFactory factory); + abstract CFieldObject execute(Node inliningTarget, Object desc, int index, int bitsize, int pack, boolean big_endian, int[] props); @Specialization - static CFieldObject PyCField_FromDesc(Node inliningTarget, Object desc, int index, int bitsize, int pack, boolean big_endian, int[] props, PythonObjectFactory factory, + static CFieldObject PyCField_FromDesc(Node inliningTarget, Object desc, int index, int bitsize, int pack, boolean big_endian, int[] props, + @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PRaiseNode.Lazy raiseNode) { - CFieldObject self = factory.createCFieldObject(PythonBuiltinClassType.CField); + CFieldObject self = PFactory.createCFieldObject(language); StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, desc); if (dict == null) { throw raiseNode.get(inliningTarget).raise(TypeError, HAS_NO_STGINFO); @@ -559,8 +561,7 @@ static Object f_set_sw(VirtualFrame frame, @SuppressWarnings("unused") FieldSet @SuppressWarnings("unused") static Object O_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, Object value, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, - @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode) { writePointerNode.execute(inliningTarget, ptr, Pointer.pythonObject(value)); return PNone.NONE; } @@ -692,14 +693,14 @@ static Object z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Specialization(guards = "setfunc == Z_set") static Object Z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, Object value, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Exclusive @Cached CastToTruffleStringNode toString, @Exclusive @Cached PyLongCheckNode longCheckNode, @Exclusive @Cached PointerNodes.PointerFromLongNode pointerFromLongNode, @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, - @Shared @Cached PythonObjectFactory factory) { // CTYPES_UNICODE + @Exclusive @Cached PRaiseNode.Lazy raiseNode) { // CTYPES_UNICODE if (value == PNone.NONE) { writePointerNode.execute(inliningTarget, ptr, Pointer.NULL); return PNone.NONE; @@ -719,7 +720,7 @@ static Object Z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O /* ptr is a char**, we need to add the indirection */ Pointer valuePtr = Pointer.bytes(bytes); writePointerNode.execute(inliningTarget, ptr, valuePtr); - return createPyMemCapsule(valuePtr, factory); + return createPyMemCapsule(valuePtr, context, inliningTarget); } @Specialization(guards = "setfunc == P_set") @@ -751,9 +752,9 @@ static Object error(VirtualFrame frame, FieldSet setfunc, Pointer ptr, Object va private static final byte[] CTYPES_CFIELD_CAPSULE_NAME_PYMEM = PyCapsule.capsuleName("_ctypes/cfield.c pymem"); - private static PyCapsule createPyMemCapsule(Pointer pointer, PythonObjectFactory factory) { - PyCapsule capsule = factory.createCapsuleJavaName(pointer, CTYPES_CFIELD_CAPSULE_NAME_PYMEM); - new PointerReference(capsule, pointer, PythonContext.get(factory).getSharedFinalizer()); + private static PyCapsule createPyMemCapsule(Pointer pointer, PythonContext context, Node inliningTarget) { + PyCapsule capsule = PFactory.createCapsuleJavaName(context.getLanguage(inliningTarget), pointer, CTYPES_CFIELD_CAPSULE_NAME_PYMEM); + new PointerReference(capsule, pointer, context.getSharedFinalizer()); return capsule; } } @@ -879,21 +880,21 @@ static Object l_get_sw(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr @Specialization(guards = "getfunc == L_get") static Object L_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, - @Shared @Cached PointerNodes.ReadLongNode readLongNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached PointerNodes.ReadLongNode readLongNode) { long val = readLongNode.execute(inliningTarget, ptr); // GET_BITFIELD(val, size); - return val < 0 ? factory.createInt(PInt.longToUnsignedBigInteger(val)) : val; + return val < 0 ? PFactory.createInt(language, PInt.longToUnsignedBigInteger(val)) : val; } @Specialization(guards = "getfunc == L_get_sw") static Object L_get_sw(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, - @Shared @Cached PointerNodes.ReadLongNode readLongNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached PointerNodes.ReadLongNode readLongNode) { long val = SWAP_8(readLongNode.execute(inliningTarget, ptr)); // GET_BITFIELD(val, size); - return val < 0 ? factory.createInt(PInt.longToUnsignedBigInteger(val)) : val; + return val < 0 ? PFactory.createInt(language, PInt.longToUnsignedBigInteger(val)) : val; } @Specialization(guards = "getfunc == d_get") @@ -942,9 +943,9 @@ static Object O_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @ @Specialization(guards = "getfunc == c_get") static Object c_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, - @Shared @Cached PointerNodes.ReadByteNode readByteNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(new byte[]{readByteNode.execute(inliningTarget, ptr)}); + @Bind PythonLanguage language, + @Shared @Cached PointerNodes.ReadByteNode readByteNode) { + return PFactory.createBytes(language, new byte[]{readByteNode.execute(inliningTarget, ptr)}); } @Specialization(guards = "getfunc == u_get") @@ -973,17 +974,17 @@ static Object U_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, i @Specialization(guards = "getfunc == s_get") static Object s_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached PointerNodes.StrLenNode strLenNode, - @Shared @Cached PointerNodes.ReadBytesNode readBytesNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(readBytesNode.execute(inliningTarget, ptr, strLenNode.execute(inliningTarget, ptr, size))); + @Shared @Cached PointerNodes.ReadBytesNode readBytesNode) { + return PFactory.createBytes(language, readBytesNode.execute(inliningTarget, ptr, strLenNode.execute(inliningTarget, ptr, size))); } @Specialization(guards = "getfunc == z_get") static Object z_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached PointerNodes.ReadPointerNode readPointerNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PointerNodes.StrLenNode strLenNode, @Shared @Cached PointerNodes.ReadBytesNode readBytesNode) { // ptr is a char**, we need to deref it to get char* @@ -992,7 +993,7 @@ static Object z_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @ return PNone.NONE; } byte[] bytes = readBytesNode.execute(inliningTarget, valuePtr, strLenNode.execute(inliningTarget, valuePtr)); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } @Specialization(guards = "getfunc == Z_get") @@ -1015,9 +1016,9 @@ static Object Z_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @ @Specialization(guards = "getfunc == P_get") static Object P_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached PointerNodes.ReadPointerNode readPointerNode, - @Cached PointerNodes.GetPointerValueAsObjectNode getPointerValueAsObjectNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached PointerNodes.GetPointerValueAsObjectNode getPointerValueAsObjectNode) { Pointer valuePtr = readPointerNode.execute(inliningTarget, ptr); if (valuePtr.isNull()) { return 0L; @@ -1025,9 +1026,9 @@ static Object P_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @ Object p = getPointerValueAsObjectNode.execute(inliningTarget, valuePtr); if (p instanceof Long) { long val = (long) p; - return val < 0 ? factory.createInt(PInt.longToUnsignedBigInteger(val)) : val; + return val < 0 ? PFactory.createInt(language, PInt.longToUnsignedBigInteger(val)) : val; } - return factory.createNativeVoidPtr(p); + return PFactory.createNativeVoidPtr(language, p); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java index fb56f967a4..5c3bd3442d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java @@ -169,8 +169,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -242,7 +241,7 @@ protected List> getNodeFa @Override public void initialize(Python3Core core) { super.initialize(core); - addBuiltinConstant("_pointer_type_cache", core.factory().createDict()); + addBuiltinConstant("_pointer_type_cache", PFactory.createDict(core.getLanguage())); if (PythonOS.getPythonOS() == PythonOS.PLATFORM_WIN32) { addBuiltinConstant("FUNCFLAG_STDCALL", FUNCFLAG_STDCALL); } @@ -259,11 +258,11 @@ public void initialize(Python3Core core) { @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - PythonObjectFactory factory = core.factory(); + PythonLanguage language = core.getLanguage(); PythonModule ctypesModule = core.lookupBuiltinModule(T__CTYPES); - ctypesModule.setAttribute(tsLiteral("_string_at_addr"), factory.createNativeVoidPtr(StringAtFunction.create())); - ctypesModule.setAttribute(tsLiteral("_cast_addr"), factory.createNativeVoidPtr(CastFunction.create())); - ctypesModule.setAttribute(tsLiteral("_wstring_at_addr"), factory.createNativeVoidPtr(WStringAtFunction.create())); + ctypesModule.setAttribute(tsLiteral("_string_at_addr"), PFactory.createNativeVoidPtr(language, StringAtFunction.create())); + ctypesModule.setAttribute(tsLiteral("_cast_addr"), PFactory.createNativeVoidPtr(language, CastFunction.create())); + ctypesModule.setAttribute(tsLiteral("_wstring_at_addr"), PFactory.createNativeVoidPtr(language, WStringAtFunction.create())); int rtldLocal = RTLD_LOCAL.getValueIfDefined(); ctypesModule.setAttribute(tsLiteral("RTLD_LOCAL"), rtldLocal); ctypesModule.setAttribute(tsLiteral("RTLD_GLOBAL"), RTLD_GLOBAL.getValueIfDefined()); @@ -297,9 +296,9 @@ public void postInitialize(Python3Core core) { } if (handle != null) { NativeFunction memmove = MemMoveFunction.create(handle, context); - ctypesModule.setAttribute(tsLiteral("_memmove_addr"), factory.createNativeVoidPtr(memmove, memmove.adr)); + ctypesModule.setAttribute(tsLiteral("_memmove_addr"), PFactory.createNativeVoidPtr(language, memmove, memmove.adr)); NativeFunction memset = MemSetFunction.create(handle, context); - ctypesModule.setAttribute(tsLiteral("_memset_addr"), factory.createNativeVoidPtr(memset, memset.adr)); + ctypesModule.setAttribute(tsLiteral("_memset_addr"), PFactory.createNativeVoidPtr(language, memset, memset.adr)); } // If handle == null, and we don't set the attributes, ctypes module is going to fail in // __init__.py on importing those attributes from _ctypes. This way the failure will happen @@ -510,9 +509,9 @@ static Object POINTER(VirtualFrame frame, Object cls, @Cached GetNameNode getNameNode, @Cached CastToTruffleStringNode toTruffleStringNode, @Cached SimpleTruffleStringFormatNode formatNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - CtypesThreadState ctypes = CtypesThreadState.get(context, context.getLanguage(inliningTarget)); + PythonLanguage language = context.getLanguage(inliningTarget); + CtypesThreadState ctypes = CtypesThreadState.get(context, language); Object result = getItem.execute(frame, inliningTarget, ctypes.ptrtype_cache, cls); if (result != null) { return result; @@ -521,13 +520,13 @@ static Object POINTER(VirtualFrame frame, Object cls, if (PGuards.isString(cls)) { TruffleString name = toTruffleStringNode.execute(inliningTarget, cls); TruffleString buf = formatNode.format("LP_%s", name); - Object[] args = new Object[]{buf, PyCPointer, factory.createDict()}; + Object[] args = new Object[]{buf, PyCPointer, PFactory.createDict(language)}; result = callNode.execute(frame, PyCPointerType, args, PKeyword.EMPTY_KEYWORDS); - key = factory.createNativeVoidPtr(result); + key = PFactory.createNativeVoidPtr(language, result); } else if (isTypeNode.execute(inliningTarget, cls)) { TruffleString buf = formatNode.format("LP_%s", getNameNode.execute(inliningTarget, cls)); - PTuple bases = factory.createTuple(new Object[]{PyCPointer}); - Object[] args = new Object[]{buf, bases, factory.createDict(new PKeyword[]{new PKeyword(T__TYPE_, cls)})}; + PTuple bases = PFactory.createTuple(language, new Object[]{PyCPointer}); + Object[] args = new Object[]{buf, bases, PFactory.createDict(language, new PKeyword[]{new PKeyword(T__TYPE_, cls)})}; result = callNode.execute(frame, PyCPointerType, args, PKeyword.EMPTY_KEYWORDS); key = cls; } else { @@ -588,7 +587,7 @@ static Object buffer_info(Object arg, @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, arg); if (dict == null) { @@ -602,7 +601,7 @@ static Object buffer_info(Object arg, shape[i] = dict.shape[i]; } - return factory.createTuple(new Object[]{dict.format, dict.ndim, factory.createTuple(shape)}); + return PFactory.createTuple(language, new Object[]{dict.format, dict.ndim, PFactory.createTuple(language, shape)}); } } @@ -712,10 +711,10 @@ static Object py_dl_open(PythonModule self, TruffleString name, int m, @Bind("this") Node inliningTarget, @Cached AuditNode auditNode) { PythonContext context = PythonContext.get(inliningTarget); - PythonObjectSlowPathFactory factory = context.factory(); + PythonLanguage language = context.getLanguage(inliningTarget); auditNode.audit(inliningTarget, "ctypes.dlopen", name); if (name.isEmpty()) { - return factory.createNativeVoidPtr(((CtypesModuleBuiltins) self.getBuiltins()).rtldDefault); + return PFactory.createNativeVoidPtr(language, ((CtypesModuleBuiltins) self.getBuiltins()).rtldDefault); } // The loaded library can link against libpython, so we have to make sure it is loaded @@ -731,7 +730,7 @@ static Object py_dl_open(PythonModule self, TruffleString name, int m, long adr = PyObjectHashNode.executeUncached(handler); handle = new DLHandler(handler, adr, name.toJavaStringUncached(), true); registerAddress(context, handle.adr, handle); - return factory.createNativeVoidPtr(handle); + return PFactory.createNativeVoidPtr(language, handle); } else if (context.getEnv().isNativeAccessAllowed()) { CtypesThreadState ctypes = CtypesThreadState.get(context, context.getLanguage()); /*- @@ -741,7 +740,7 @@ static Object py_dl_open(PythonModule self, TruffleString name, int m, if (!eqNode.execute(name, MACOS_Security_LIB, TS_ENCODING) && !eqNode.execute(name, MACOS_CoreFoundation_LIB, TS_ENCODING)) { handle = loadNFILibrary(context, ctypes.backendType, name.toJavaStringUncached(), mode); registerAddress(context, handle.adr, handle); - return factory.createNativeVoidPtr(handle, handle.adr); + return PFactory.createNativeVoidPtr(language, handle, handle.adr); } } } catch (Exception e) { @@ -777,11 +776,11 @@ protected abstract static class CtypesDlSymNode extends PNodeWithContext { @Specialization static Object ctypes_dlsym(VirtualFrame frame, Pointer handlePtr, Object n, PythonBuiltinClassType error, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached CtypesNodes.HandleFromPointerNode handleFromPointerNode, @Cached PyObjectHashNode hashNode, @Cached CastToJavaStringNode asString, @CachedLibrary(limit = "1") InteropLibrary ilib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { DLHandler handle = handleFromPointerNode.getDLHandler(inliningTarget, handlePtr); String name = asString.execute(n); @@ -794,12 +793,12 @@ static Object ctypes_dlsym(VirtualFrame frame, Pointer handlePtr, Object n, Pyth long adr = isManaged ? hashNode.execute(frame, inliningTarget, sym) : ilib.asPointer(sym); sym = isManaged ? CallLLVMFunction.create(sym, ilib) : sym; NativeFunction func = new NativeFunction(sym, adr, name, isManaged); - registerAddress(PythonContext.get(inliningTarget), adr, func); + registerAddress(context, adr, func); // PyLong_FromVoidPtr(ptr); if (!isManaged) { - return factory.createNativeVoidPtr(func, adr); + return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func, adr); } else { - return factory.createNativeVoidPtr(func); + return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func); } } catch (UnsupportedMessageException | UnknownIdentifierException e) { throw raiseNode.get(inliningTarget).raise(error, e); @@ -973,12 +972,12 @@ Object doit(CDataObject obj, int offset, @Bind("this") Node inliningTarget, @Exclusive @Cached GetClassNode getClassNode, @Cached PyTypeCheck pyTypeCheck, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { return error(null, obj, offset, inliningTarget, getClassNode, raiseNode); } - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.tag = 'P'; parg.pffi_type = FFIType.ffi_type_pointer; parg.obj = obj; @@ -1036,15 +1035,15 @@ protected abstract static class AddressOfNode extends PythonUnaryBuiltinNode { @Specialization static Object doit(CDataObject obj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, @Cached AuditNode auditNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { return error(obj, raiseNode.get(inliningTarget)); } auditNode.audit(inliningTarget, "ctypes.addressof", obj); - return factory.createNativeVoidPtr(obj.b_ptr); + return PFactory.createNativeVoidPtr(language, obj.b_ptr); } @Fallback @@ -1208,7 +1207,7 @@ Object _ctypes_callproc(VirtualFrame frame, NativeFunction pProc, Object[] argar if (mode == BackendMode.NFI) { result = callNativeFunction(inliningTarget, pProc, avalues, atypes, rtype, ilib, raiseNode); } else { - result = callManagedFunction(inliningTarget, pProc, avalues, ilib, raiseNode); + result = callManagedFunction(inliningTarget, pProc, avalues, ilib); if (mode == BackendMode.INTRINSIC) { /* * We don't want result conversion for functions implemented in Java, they @@ -1221,7 +1220,7 @@ Object _ctypes_callproc(VirtualFrame frame, NativeFunction pProc, Object[] argar return getResultNode.execute(frame, restype, rtype, result, checker); } - static Object callManagedFunction(Node inliningTarget, NativeFunction pProc, Object[] argarray, InteropLibrary ilib, PRaiseNode.Lazy raiseNode) { + static Object callManagedFunction(Node inliningTarget, NativeFunction pProc, Object[] argarray, InteropLibrary ilib) { try { return ilib.execute(pProc.sym, argarray); } catch (PException e) { @@ -1815,9 +1814,9 @@ protected abstract static class CastFunctionNode extends Node { @Specialization Object cast(Pointer ptr, Pointer srcObj, Pointer ctypeObj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached HashingStorageSetItem setItem, @Cached PyTypeCheck pyTypeCheck, - @Cached PythonObjectFactory factory, @Cached CallNode callNode, @Cached CastCheckPtrTypeNode castCheckPtrTypeNode, @Cached PointerNodes.ReadPythonObject readPythonObject, @@ -1838,16 +1837,16 @@ Object cast(Pointer ptr, Pointer srcObj, Pointer ctypeObj, * PyCData_GetContainer will initialize src.b_objects, we need this so it can be * shared */ - PyCData_GetContainer(cdata, factory); + PyCData_GetContainer(cdata, language); if (cdata.b_objects == null) { - cdata.b_objects = factory.createDict(); + cdata.b_objects = PFactory.createDict(language); } result.b_objects = cdata.b_objects; if (PGuards.isDict(result.b_objects)) { // PyLong_FromVoidPtr((void *)src); PDict dict = (PDict) result.b_objects; - Object index = factory.createNativeVoidPtr(cdata); + Object index = PFactory.createNativeVoidPtr(language, cdata); dict.setDictStorage(setItem.execute(null, inliningTarget, dict.getDictStorage(), index, cdata)); } } @@ -1887,10 +1886,10 @@ protected abstract static class MemmoveNode extends Node { @Specialization static Object memmove(Node inliningTarget, Pointer destPtr, Pointer srcPtr, long size, - @Cached PointerNodes.MemcpyNode memcpyNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached PointerNodes.MemcpyNode memcpyNode) { memcpyNode.execute(inliningTarget, destPtr, srcPtr, (int) size); - return factory.createNativeVoidPtr(destPtr); + return PFactory.createNativeVoidPtr(language, destPtr); } } @@ -1949,9 +1948,9 @@ protected abstract static class MemsetNode extends Node { @Specialization static Object memset(Node inliningTarget, Pointer ptr, int value, long size, + @Bind PythonLanguage language, @Cached PointerNodes.WriteLongNode writeLongNode, - @Cached PointerNodes.WriteByteNode writeByteNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached PointerNodes.WriteByteNode writeByteNode) { byte b = (byte) value; long fill = 0; for (int i = 0; i < Long.BYTES * 8; i += 8) { @@ -1969,7 +1968,7 @@ static Object memset(Node inliningTarget, Pointer ptr, int value, long size, for (; i < size; i++) { writeByteNode.execute(inliningTarget, ptr.withOffset(i), b); } - return factory.createNativeVoidPtr(ptr); + return PFactory.createNativeVoidPtr(language, ptr); } } @@ -2027,15 +2026,15 @@ protected abstract static class StringAtFunctionNode extends Node { @Specialization static Object string_at(Pointer ptr, int size, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PointerNodes.ReadBytesNode read, @Cached PointerNodes.StrLenNode strLenNode, @Cached AuditNode auditNode) { - auditNode.audit(inliningTarget, "ctypes.string_at", factory.createNativeVoidPtr(ptr), size); + auditNode.audit(inliningTarget, "ctypes.string_at", PFactory.createNativeVoidPtr(language, ptr), size); if (size == -1) { size = strLenNode.execute(inliningTarget, ptr); } - return factory.createBytes(read.execute(inliningTarget, ptr, size)); + return PFactory.createBytes(language, read.execute(inliningTarget, ptr, size)); } } @@ -2070,13 +2069,13 @@ protected abstract static class WStringAtFunctionNode extends Node { @Specialization static TruffleString wstring_at(Pointer ptr, int size, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached AuditNode auditNode, @Cached PointerNodes.ReadBytesNode read, @Cached PointerNodes.WCsLenNode wCsLenNode, @Cached TruffleString.FromByteArrayNode fromByteArrayNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - auditNode.audit(inliningTarget, "ctypes.wstring_at", factory.createNativeVoidPtr(ptr), size); + auditNode.audit(inliningTarget, "ctypes.wstring_at", PFactory.createNativeVoidPtr(language, ptr), size); if (size == -1) { size = wCsLenNode.execute(inliningTarget, ptr); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java index 6b706257f4..b01f95d28b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -57,6 +57,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.truffle.api.strings.TruffleString.Encoding.US_ASCII; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonOS; import com.oracle.graal.python.builtins.modules.ctypes.FFIType.FFI_TYPES; @@ -66,6 +67,7 @@ import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetBaseClassNode; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; import com.oracle.graal.python.lib.PyObjectTypeCheck; @@ -73,9 +75,10 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -344,12 +347,13 @@ public abstract static class CreateCDataObjectNode extends Node { @Specialization static CDataObject doCreate(Node inliningTarget, Object type, Pointer pointer, int size, boolean needsfree, @Cached(inline = false) IsSubtypeNode isSubtypeNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached TypeNodes.GetInstanceShape getInstanceShape, + @Bind PythonLanguage language) { CDataObject result; if (isSubtypeNode.execute(type, PyCFuncPtr)) { - result = factory.createPyCFuncPtrObject(type, pointer, size, needsfree); + result = PFactory.createPyCFuncPtrObject(language, type, getInstanceShape.execute(type), pointer, size, needsfree); } else { - result = factory.createCDataObject(type, pointer, size, needsfree); + result = PFactory.createCDataObject(language, type, getInstanceShape.execute(type), pointer, size, needsfree); } if (needsfree) { new PointerReference(result, pointer, PythonContext.get(inliningTarget).getSharedFinalizer()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java index d5ba1bf969..d9910ce92a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -76,9 +76,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -133,10 +131,9 @@ private static void createGetSet(PythonLanguage language, Object type, NodeFacto l -> new BuiltinFunctionRootNode(l, builtin, factory, true), factory.getNodeClass(), builtin.name()); - PythonObjectSlowPathFactory f = PythonContext.get(null).factory(); int flags = PBuiltinFunction.getFlags(builtin, rawCallTarget); - PBuiltinFunction getter = f.createBuiltinFunction(name, type, 1, flags, rawCallTarget); - GetSetDescriptor callable = f.createGetSetDescriptor(getter, getter, name, type, false); + PBuiltinFunction getter = PFactory.createBuiltinFunction(language, name, type, 1, flags, rawCallTarget); + GetSetDescriptor callable = PFactory.createGetSetDescriptor(language, getter, getter, name, type, false); callable.setAttribute(T___DOC__, toTruffleStringUncached(builtin.doc())); WriteAttributeToObjectNode.getUncached(true).execute(type, name, callable); } @@ -147,10 +144,10 @@ abstract static class CharArrayRawNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(value)") static PBytes doGet(CDataObject self, @SuppressWarnings("unused") PNone value, + @Bind PythonLanguage language, @Bind("this") Node inliningTarget, - @Cached PointerNodes.ReadBytesNode read, - @Cached PythonObjectFactory factory) { - return factory.createBytes(read.execute(inliningTarget, self.b_ptr, self.b_size)); + @Cached PointerNodes.ReadBytesNode read) { + return PFactory.createBytes(language, read.execute(inliningTarget, self.b_ptr, self.b_size)); } @Specialization(limit = "3") @@ -183,10 +180,10 @@ abstract static class CharArrayValueNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(value)") static PBytes doGet(CDataObject self, @SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PointerNodes.StrLenNode strLenNode, - @Cached PointerNodes.ReadBytesNode read, - @Cached PythonObjectFactory factory) { - return factory.createBytes(read.execute(inliningTarget, self.b_ptr, strLenNode.execute(inliningTarget, self.b_ptr))); + @Cached PointerNodes.ReadBytesNode read) { + return PFactory.createBytes(language, read.execute(inliningTarget, self.b_ptr, strLenNode.execute(inliningTarget, self.b_ptr))); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java index cf3d3e988d..6ad818bd6a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -77,15 +77,13 @@ import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeFactory; @@ -102,28 +100,28 @@ protected List> getNodeFa } @TruffleBoundary - protected static void addCVoidPFromParam(PythonObjectSlowPathFactory factory, PythonLanguage language, Object type) { + protected static void addCVoidPFromParam(PythonLanguage language, Object type) { NodeFactory rawFactory = CVoidPFromParamNodeFactory.getInstance(); Builtin rawNodeBuiltin = CVoidPFromParamNode.class.getAnnotation(Builtin.class); - addClassMethod(factory, language, type, rawFactory, rawNodeBuiltin); + addClassMethod(language, type, rawFactory, rawNodeBuiltin); } @TruffleBoundary - protected static void addCCharPFromParam(PythonObjectSlowPathFactory factory, PythonLanguage language, Object type) { + protected static void addCCharPFromParam(PythonLanguage language, Object type) { NodeFactory rawFactory = CCharPFromParamNodeFactory.getInstance(); Builtin rawNodeBuiltin = CCharPFromParamNode.class.getAnnotation(Builtin.class); - addClassMethod(factory, language, type, rawFactory, rawNodeBuiltin); + addClassMethod(language, type, rawFactory, rawNodeBuiltin); } @TruffleBoundary - protected static void addCWCharPFromParam(PythonObjectSlowPathFactory factory, PythonLanguage language, Object type) { + protected static void addCWCharPFromParam(PythonLanguage language, Object type) { NodeFactory rawFactory = CWCharPFromParamNodeFactory.getInstance(); Builtin rawNodeBuiltin = CWCharPFromParamNode.class.getAnnotation(Builtin.class); - addClassMethod(factory, language, type, rawFactory, rawNodeBuiltin); + addClassMethod(language, type, rawFactory, rawNodeBuiltin); } @TruffleBoundary - private static void addClassMethod(PythonObjectSlowPathFactory objectFactory, PythonLanguage language, Object type, NodeFactory nodeFactory, Builtin builtin) { + private static void addClassMethod(PythonLanguage language, Object type, NodeFactory nodeFactory, Builtin builtin) { TruffleString name = toTruffleStringUncached(builtin.name()); Object builtinDoc = PNone.NONE; RootCallTarget callTarget = language.createCachedCallTarget( @@ -131,8 +129,8 @@ private static void addClassMethod(PythonObjectSlowPathFactory objectFactory, Py nodeFactory.getNodeClass(), builtin.name()); int flags = PBuiltinFunction.getFlags(builtin, callTarget); - PBuiltinFunction function = objectFactory.createBuiltinFunction(name, type, 1, flags, callTarget); - PDecoratedMethod classMethod = objectFactory.createClassmethodFromCallableObj(function); + PBuiltinFunction function = PFactory.createBuiltinFunction(language, name, type, 1, flags, callTarget); + PDecoratedMethod classMethod = PFactory.createClassmethodFromCallableObj(language, function); function.setAttribute(T___DOC__, builtinDoc); WriteAttributeToObjectNode.getUncached(true).execute(type, name, classMethod); } @@ -159,10 +157,9 @@ static Object c_wchar_p_from_param(VirtualFrame frame, Object type, Object value @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached CWCharPFromParamNode cwCharPFromParamNode, @Cached PyObjectLookupAttr lookupAttr, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (PGuards.isString(value)) { - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(PythonLanguage.get(inliningTarget)); parg.pffi_type = ffi_type_pointer; parg.tag = 'Z'; parg.valuePointer = Pointer.allocate(parg.pffi_type, parg.pffi_type.size); @@ -220,9 +217,9 @@ static Object voidPtr(@SuppressWarnings("unused") Object type, Object value, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached PyLongCheckNode longCheckNode, @Exclusive @Cached SetFuncNode setFuncNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { /* int, long */ - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'P'; parg.valuePointer = Pointer.allocate(parg.pffi_type, parg.pffi_type.size); @@ -234,9 +231,9 @@ static Object voidPtr(@SuppressWarnings("unused") Object type, Object value, @Specialization static Object bytes(@SuppressWarnings("unused") Object type, PBytes value, @Exclusive @Cached SetFuncNode setFuncNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { /* bytes */ - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'z'; parg.valuePointer = Pointer.allocate(parg.pffi_type, parg.pffi_type.size); @@ -248,9 +245,9 @@ static Object bytes(@SuppressWarnings("unused") Object type, PBytes value, @Specialization static Object string(@SuppressWarnings("unused") Object type, TruffleString value, @Exclusive @Cached SetFuncNode setFuncNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { /* unicode */ - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'Z'; parg.valuePointer = Pointer.allocate(parg.pffi_type, parg.pffi_type.size); @@ -269,7 +266,7 @@ static Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, @Cached CVoidPFromParamNode cVoidPFromParamNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached PyObjectLookupAttr lookupAttr, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { /* c_void_p instance (or subclass) */ boolean res = isInstanceNode.executeWith(frame, value, type); @@ -292,7 +289,7 @@ static Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, } /* function pointer */ if (value instanceof PyCFuncPtrObject func && pyTypeCheck.isPyCFuncPtrObject(inliningTarget, value)) { - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'P'; parg.valuePointer = func.b_ptr; @@ -305,7 +302,7 @@ static Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, int code = codePointAtIndexNode.execute((TruffleString) stgd.proto, 0, TS_ENCODING); /* c_char_p, c_wchar_p */ if (code == 'z' || code == 'Z') { - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'Z'; parg.obj = value; @@ -338,8 +335,8 @@ static Object none(Object type, PNone value) { @Specialization static Object bytes(@SuppressWarnings("unused") Object type, PBytes value, @Cached SetFuncNode setFuncNode, - @Cached PythonObjectFactory factory) { - PyCArgObject parg = factory.createCArgObject(); + @Bind PythonLanguage language) { + PyCArgObject parg = PFactory.createCArgObject(language); parg.pffi_type = ffi_type_pointer; parg.tag = 'z'; parg.valuePointer = Pointer.allocate(parg.pffi_type, parg.pffi_type.size); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java index 1fba2fa8cd..43c604be2f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java @@ -58,6 +58,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -292,14 +293,14 @@ static Object doInt(CDataObject self, int index, static Object doSlice(CDataObject self, PSlice slice, @CachedLibrary("self") PythonBufferAccessLibrary bufferLib, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached PyCDataGetNode pyCDataGetNode, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached SliceUnpack sliceUnpack, @Cached AdjustIndices adjustIndices, @Cached TruffleString.FromByteArrayNode fromByteArrayNode, - @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { StgDictObject stgdict = pyObjectStgDictNode.execute(inliningTarget, self); assert stgdict != null : "Cannot be NULL for array object instances"; Object proto = stgdict.proto; @@ -313,17 +314,17 @@ static Object doSlice(CDataObject self, PSlice slice, byte[] ptr = bufferLib.getInternalOrCopiedByteArray(self); if (slicelen <= 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } - if (sliceInfo.step == 1) { - return factory.createBytes(ptr, sliceInfo.start, slicelen); + if (sliceInfo.start == 0 && sliceInfo.step == 1) { + return PFactory.createBytes(language, ptr, slicelen); } byte[] dest = new byte[slicelen]; for (int cur = sliceInfo.start, i = 0; i < slicelen; cur += sliceInfo.step, i++) { dest[i] = ptr[cur]; } - return factory.createBytes(dest); + return PFactory.createBytes(language, dest); } if (itemdict.getfunc == FieldDesc.u.getfunc) { // CTYPES_UNICODE byte[] ptr = bufferLib.getInternalOrCopiedByteArray(self); @@ -349,7 +350,7 @@ static Object doSlice(CDataObject self, PSlice slice, for (int cur = sliceInfo.start, i = 0; i < slicelen; cur += sliceInfo.step, i++) { np[i] = doInt(self, cur, inliningTarget, pyCDataGetNode, pyObjectStgDictNode); } - return factory.createList(np); + return PFactory.createList(language, np); } @Specialization(guards = "!isPSlice(item)", replaces = "doInt") @@ -392,8 +393,8 @@ static int Array_length(CDataObject self) { public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java index d86a887fd2..c50d24a0b9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -82,7 +82,7 @@ import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -120,7 +120,7 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P @Cached SetDictNode setDict, @Cached HashingStorageAddAllToOther addAllToOtherNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { /* * create the new instance (which is a class, since we are a metatype!) @@ -151,7 +151,7 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P throw raiseNode.get(inliningTarget).raise(AttributeError, CLASS_MUST_DEFINE_A_TYPE_ATTRIBUTE); } - StgDictObject stgdict = factory.createStgDictObject(PythonBuiltinClassType.StgDict); + StgDictObject stgdict = PFactory.createStgDictObject(language); StgDictObject itemdict = pyTypeStgDictNode.execute(inliningTarget, type_attr); if (itemdict == null) { @@ -193,7 +193,7 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P /* replace the class dict by our updated spam dict */ PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } addAllToOtherNode.execute(frame, inliningTarget, resDict.getDictStorage(), stgdict); setDict.execute(inliningTarget, (PythonObject) result, stgdict); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java index 710ced01fa..8ffc0a903e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -84,6 +84,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -134,7 +135,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -262,7 +263,7 @@ static Object error(@SuppressWarnings("unused") Object type, @SuppressWarnings(" } static CThunkObject CThunkObjectNew(int nArgs) { - CThunkObject p = PythonObjectFactory.getUncached().createCThunkObject(PythonBuiltinClassType.CThunkObject, nArgs); + CThunkObject p = PFactory.createCThunkObject(PythonLanguage.get(null), nArgs); p.pcl_write = null; p.pcl_exec = null; @@ -415,19 +416,19 @@ protected abstract static class PointerArgTypesNode extends PythonBinaryBuiltinN @Specialization(guards = {"isNoValue(value)", "self.argtypes != null"}) static Object PyCFuncPtr_get_argtypes(PyCFuncPtrObject self, @SuppressWarnings("unused") PNone value, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(self.argtypes); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, self.argtypes); } @Specialization(guards = {"isNoValue(value)", "self.argtypes == null"}) static Object PyCFuncPtr_get_argtypes(PyCFuncPtrObject self, @SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { StgDictObject dict = pyObjectStgDictNode.execute(inliningTarget, self); assert dict != null : "Cannot be NULL for PyCFuncPtrObject instances"; if (dict.argtypes != null) { - return factory.createTuple(dict.argtypes); + return PFactory.createTuple(language, dict.argtypes); } else { return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java index b0e2a51ef0..6a289c5bfc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -52,6 +52,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -77,7 +78,7 @@ import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -127,9 +128,9 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, @Cached PyCallableCheckNode callableCheck, @Cached HashingStorageGetItem getItem, @Cached HashingStorageAddAllToOther addAllToOtherNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { - StgDictObject stgdict = factory.createStgDictObject(PythonBuiltinClassType.StgDict); + StgDictObject stgdict = PFactory.createStgDictObject(language); stgdict.paramfunc = CArgObjectBuiltins.PyCFuncPtrTypeParamFunc; /* @@ -147,7 +148,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, /* replace the class dict by our updated storage dict */ PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } addAllToOtherNode.execute(frame, inliningTarget, resDict.getDictStorage(), stgdict); setDict.execute(inliningTarget, result, stgdict); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java index fe771d6fd5..d03ce6ebfd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java @@ -61,6 +61,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -132,13 +133,13 @@ abstract static class PointerSetContentsNode extends Node { @Specialization static void set(VirtualFrame frame, Node inliningTarget, CDataObject self, Object value, + @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, @Cached PRaiseNode.Lazy raiseNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached(inline = false) IsInstanceNode isInstanceNode, @Cached KeepRefNode keepRefNode, - @Cached PointerNodes.WritePointerNode writePointerNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached PointerNodes.WritePointerNode writePointerNode) { if (value == null) { throw raiseNode.get(inliningTarget).raise(TypeError, POINTER_DOES_NOT_SUPPORT_ITEM_DELETION); } @@ -162,7 +163,7 @@ static void set(VirtualFrame frame, Node inliningTarget, CDataObject self, Objec */ keepRefNode.execute(frame, inliningTarget, self, 1, value); - Object keep = GetKeepedObjects(dst, factory); + Object keep = GetKeepedObjects(dst, language); keepRefNode.execute(frame, inliningTarget, self, 0, keep); } } @@ -332,6 +333,7 @@ static Object doInt(CDataObject self, int index, @Specialization(limit = "1") static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary("self") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached PyCDataGetNode pyCDataGetNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, @@ -340,7 +342,6 @@ static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, @Cached TruffleString.FromByteArrayNode fromByteArrayNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { /* * Since pointers have no length, and we want to apply different semantics to negative @@ -387,16 +388,16 @@ static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, byte[] ptr = bufferLib.getInternalOrCopiedByteArray(self); if (len <= 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } - if (step == 1) { - return factory.createBytes(ptr, start, len); + if (start == 0 && step == 1) { + return PFactory.createBytes(language, ptr, len); } byte[] dest = new byte[len]; for (int cur = start, i = 0; i < len; cur += step, i++) { dest[i] = ptr[cur]; } - return factory.createBytes(dest); + return PFactory.createBytes(language, dest); } if (itemdict.getfunc == FieldDesc.u.getfunc) { // CTYPES_UNICODE byte[] ptr = bufferLib.getInternalOrCopiedByteArray(self); @@ -419,7 +420,7 @@ static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, for (int cur = start, i = 0; i < len; cur += step, i++) { np[i] = PointerGetItemNode.Pointer_item(self, cur, inliningTarget, pyCDataGetNode, pyTypeStgDictNode, pyObjectStgDictNode, readPointerNode, raiseNode); } - return factory.createList(np); + return PFactory.createList(language, np); } @Specialization(guards = "!isPSlice(item)", replaces = "doInt") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java index 7bfb019725..885b2586f8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -84,7 +85,7 @@ import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.util.CastToJavaBooleanNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -128,13 +129,13 @@ static Object PyCPointerType_new(VirtualFrame frame, Object type, Object[] args, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, @Cached StringUtils.SimpleTruffleStringFormatNode formatNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { /* * stgdict items size, align, length contain info about pointers itself, stgdict.proto * has info about the pointed to type! */ - StgDictObject stgdict = factory.createStgDictObject(PythonBuiltinClassType.StgDict); + StgDictObject stgdict = PFactory.createStgDictObject(language); stgdict.size = StgDictObject.VOID_PTR_SIZE; stgdict.align = FieldDesc.P.pffi_type.alignment; stgdict.length = 1; @@ -168,7 +169,7 @@ static Object PyCPointerType_new(VirtualFrame frame, Object type, Object[] args, /* replace the class dict by our updated spam dict */ PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } addAllToOtherNode.execute(frame, inliningTarget, resDict.getDictStorage(), stgdict); setDict.execute(inliningTarget, result, stgdict); @@ -185,7 +186,6 @@ protected abstract static class FromParamNode extends PythonBinaryBuiltinNode { /* _byref consumes a refcount to its argument */ static PyCArgObject byref(Node inliningTarget, Object obj, PyTypeCheck pyTypeCheck, - PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, EXPECTED_CDATA_INSTANCE); @@ -193,7 +193,7 @@ static PyCArgObject byref(Node inliningTarget, Object obj, CDataObject cdata = (CDataObject) obj; - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(PythonLanguage.get(inliningTarget)); parg.tag = 'P'; parg.pffi_type = ffi_type_pointer; parg.obj = cdata; @@ -217,7 +217,6 @@ static Object PyCPointerType_from_param(VirtualFrame frame, Object type, Object @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CDataTypeFromParamNode fromParamNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { StgDictObject typedict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); /* @@ -225,7 +224,7 @@ static Object PyCPointerType_from_param(VirtualFrame frame, Object type, Object * byref(). */ if (isInstanceNode.executeWith(frame, value, typedict.proto)) { - return byref(inliningTarget, value, pyTypeCheck, factory, raiseNode); + return byref(inliningTarget, value, pyTypeCheck, raiseNode); } if (pyTypeCheck.isPointerObject(inliningTarget, value) || pyTypeCheck.isArrayObject(inliningTarget, value)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java index 56265f5393..fefdf623ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java @@ -42,7 +42,6 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PyCSimpleType; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SimpleCData; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StgDict; import static com.oracle.graal.python.builtins.modules.ctypes.CDataTypeBuiltins.J_FROM_PARAM; import static com.oracle.graal.python.builtins.modules.ctypes.CDataTypeBuiltins.T__AS_PARAMETER_; import static com.oracle.graal.python.builtins.modules.ctypes.CtypesModuleBuiltins.TYPEFLAG_ISPOINTER; @@ -95,8 +94,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -153,7 +151,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.EqualNode eqNode, @Cached TruffleString.FromCharArrayUTF16Node fromCharArrayNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { /* @@ -186,7 +184,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, throw raiseNode.get(inliningTarget).raise(ValueError, TYPE_S_NOT_SUPPORTED, proto_str); } - StgDictObject stgdict = factory.createStgDictObject(StgDict); + StgDictObject stgdict = PFactory.createStgDictObject(language); stgdict.ffi_type_pointer = fmt.pffi_type; stgdict.align = fmt.pffi_type.alignment; @@ -204,7 +202,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, /* replace the class dict by our updated spam dict */ PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } addAllToOtherNode.execute(frame, inliningTarget, resDict.getDictStorage(), stgdict); setDict.execute(inliningTarget, (PythonObject) result, stgdict); @@ -214,18 +212,16 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, * PyCSimpleType_from_param generic method. */ PythonContext context = PythonContext.get(inliningTarget); - PythonObjectSlowPathFactory slowPathFactory = context.factory(); if (getBaseClassNode.execute(inliningTarget, result) == context.lookupType(SimpleCData)) { - PythonLanguage language = context.getLanguage(); if (eqNode.execute(T_LOWER_Z, proto_str, TS_ENCODING)) { /* c_char_p */ - LazyPyCSimpleTypeBuiltins.addCCharPFromParam(slowPathFactory, language, result); + LazyPyCSimpleTypeBuiltins.addCCharPFromParam(language, result); stgdict.flags |= TYPEFLAG_ISPOINTER; } else if (eqNode.execute(T_UPPER_Z, proto_str, TS_ENCODING)) { /* c_wchar_p */ - LazyPyCSimpleTypeBuiltins.addCWCharPFromParam(slowPathFactory, language, result); + LazyPyCSimpleTypeBuiltins.addCWCharPFromParam(language, result); stgdict.flags |= TYPEFLAG_ISPOINTER; } else if (eqNode.execute(T_UPPER_P, proto_str, TS_ENCODING)) { /* c_void_p */ - LazyPyCSimpleTypeBuiltins.addCVoidPFromParam(slowPathFactory, language, result); + LazyPyCSimpleTypeBuiltins.addCVoidPFromParam(language, result); stgdict.flags |= TYPEFLAG_ISPOINTER; } else if (eqNode.execute(T_LOWER_S, proto_str, TS_ENCODING) || eqNode.execute(T_UPPER_X, proto_str, TS_ENCODING) || @@ -241,8 +237,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, toTruffleStringNode, getDict, setDict, - addAllToOtherNode, - factory); + addAllToOtherNode); StgDictObject sw_dict = pyTypeStgDictNode.execute(inliningTarget, swapped); setAttrString.execute(frame, inliningTarget, result, T_CTYPE_BE, swapped); setAttrString.execute(frame, inliningTarget, result, T_CTYPE_LE, result); @@ -262,8 +257,7 @@ private static Object CreateSwappedType(VirtualFrame frame, Node inliningTarget, CastToTruffleStringNode toString, GetDictIfExistsNode getDict, SetDictNode setDict, - HashingStorageAddAllToOther addAllToOther, - PythonObjectFactory factory) { + HashingStorageAddAllToOther addAllToOther) { int argsLen = args.length; Object[] swapped_args = new Object[argsLen]; TruffleString suffix = toString.execute(inliningTarget, internStringNode.execute(inliningTarget, T__BE)); @@ -277,7 +271,8 @@ private static Object CreateSwappedType(VirtualFrame frame, Node inliningTarget, * create the new instance (which is a class, since we are a metatype!) */ Object result = typeNew.execute(frame, type, swapped_args[0], swapped_args[1], swapped_args[2], kwds); - StgDictObject stgdict = factory.createStgDictObject(StgDict); + PythonLanguage language = PythonLanguage.get(inliningTarget); + StgDictObject stgdict = PFactory.createStgDictObject(language); stgdict.ffi_type_pointer = fmt.pffi_type; stgdict.align = fmt.pffi_type.alignment; stgdict.length = 0; @@ -290,7 +285,7 @@ private static Object CreateSwappedType(VirtualFrame frame, Node inliningTarget, /* replace the class dict by our updated spam dict */ PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } addAllToOther.execute(frame, inliningTarget, resDict.getDictStorage(), stgdict); setDict.execute(inliningTarget, (PythonObject) result, stgdict); @@ -314,7 +309,6 @@ static Object PyCSimpleType_from_param(VirtualFrame frame, Object type, Object v @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectLookupAttr lookupAsParam, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { /* * If the value is already an instance of the requested type, we can use it as is @@ -333,7 +327,7 @@ static Object PyCSimpleType_from_param(VirtualFrame frame, Object type, Object v FieldDesc fd = FFIType._ctypes_get_fielddesc(code); assert fd != null; - PyCArgObject parg = factory.createCArgObject(); + PyCArgObject parg = PFactory.createCArgObject(PythonLanguage.get(inliningTarget)); parg.tag = code; parg.pffi_type = fd.pffi_type; parg.valuePointer = Pointer.allocate(parg.pffi_type, dict.size); @@ -347,7 +341,7 @@ static Object PyCSimpleType_from_param(VirtualFrame frame, Object type, Object v Object as_parameter = lookupAsParam.execute(frame, inliningTarget, value, T__AS_PARAMETER_); if (as_parameter != PNone.NO_VALUE) { // Py_EnterRecursiveCall("while processing _as_parameter_"); TODO - Object r = PyCSimpleType_from_param(frame, type, as_parameter, inliningTarget, setFuncNode, isInstanceNode, pyTypeStgDictNode, lookupAsParam, codePointAtIndexNode, factory, raiseNode); + Object r = PyCSimpleType_from_param(frame, type, as_parameter, inliningTarget, setFuncNode, isInstanceNode, pyTypeStgDictNode, lookupAsParam, codePointAtIndexNode, raiseNode); // Py_LeaveRecursiveCall(); return r; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCStructTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCStructTypeBuiltins.java index 04d9ba26cb..fcdcb1ddeb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCStructTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCStructTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -59,7 +59,6 @@ import com.oracle.graal.python.builtins.objects.type.TypeBuiltins; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -92,13 +91,12 @@ protected abstract static class SetattrNode extends SetAttrBuiltinNode { void doStringKey(VirtualFrame frame, Object object, TruffleString key, Object value, @Shared @Cached TypeBuiltins.SetattrNode typeSetAttr, @Shared @Cached TruffleString.EqualNode equalNode, - @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict) { // CPython just delegates to "PyType_Type.tp_setattro" with the comment: /* XXX Should we disallow deleting _fields_? */ typeSetAttr.executeSetAttr(frame, object, key, value); if (equalNode.execute(key, StructUnionTypeBuiltins.T__FIELDS_, TS_ENCODING)) { - updateStgDict.execute(frame, object, value, true, factory); + updateStgDict.execute(frame, object, value, true); } } @@ -109,10 +107,9 @@ void doGeneric(VirtualFrame frame, Object object, Object keyObject, Object value @Cached CastToTruffleStringCheckedNode castKeyToStringNode, @Shared @Cached TypeBuiltins.SetattrNode typeSetAttr, @Shared @Cached TruffleString.EqualNode equalNode, - @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict) { TruffleString key = castKeyToStringNode.cast(inliningTarget, keyObject, ATTR_NAME_MUST_BE_STRING, keyObject); - doStringKey(frame, object, key, value, typeSetAttr, equalNode, updateStgDict, factory); + doStringKey(frame, object, key, value, typeSetAttr, equalNode, updateStgDict); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java index 5d7f407ed3..5be831605e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java @@ -90,7 +90,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -171,12 +171,12 @@ Object doit(VirtualFrame frame, StgDictObject self, @SuppressWarnings("truffle-inlining") // footprint reduction 112 -> 94 protected abstract static class MakeFieldsNode extends PNodeWithContext { - abstract void execute(VirtualFrame frame, Object type, CFieldObject descr, int index, int offset, PythonObjectFactory factory); + abstract void execute(VirtualFrame frame, Object type, CFieldObject descr, int index, int offset); @TruffleBoundary - private void executeBoundary(Object type, CFieldObject descr, int index, int offset, PythonObjectFactory factory) { + private void executeBoundary(Object type, CFieldObject descr, int index, int offset) { // recursive calls are done as boundary calls to avoid too many deopts - execute(null, type, descr, index, offset, factory); + execute(null, type, descr, index, offset); } /* @@ -185,7 +185,7 @@ private void executeBoundary(Object type, CFieldObject descr, int index, int off * into type. */ @Specialization - static void MakeFields(VirtualFrame frame, Object type, CFieldObject descr, int index, int offset, PythonObjectFactory factory, + static void MakeFields(VirtualFrame frame, Object type, CFieldObject descr, int index, int offset, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached PyObjectGetAttrO getAttributeNode, @@ -220,13 +220,13 @@ static void MakeFields(VirtualFrame frame, Object type, CFieldObject descr, int if (fdescr.anonymous != 0) { Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); try { - recursiveNode.executeBoundary(type, fdescr, index + fdescr.index, offset + fdescr.offset, context.factory()); + recursiveNode.executeBoundary(type, fdescr, index + fdescr.index, offset + fdescr.offset); } finally { IndirectCallContext.exit(frame, language, context, state); } continue; } - CFieldObject new_descr = factory.createCFieldObject(CField); + CFieldObject new_descr = PFactory.createCFieldObject(language); // assert (Py_TYPE(new_descr) == PythonBuiltinClassType.CField); new_descr.size = fdescr.size; new_descr.offset = fdescr.offset + offset; @@ -305,13 +305,13 @@ static StgDictObject PyObject_stgdict(Node inliningTarget, Object self, @SuppressWarnings("truffle-inlining") // footprint reduction 132 -> 115 protected abstract static class MakeAnonFieldsNode extends Node { - abstract void execute(VirtualFrame frame, Object type, PythonObjectFactory factory); + abstract void execute(VirtualFrame frame, Object type); /* * Iterate over the names in the type's _anonymous_ attribute, if present, */ @Specialization - static void MakeAnonFields(VirtualFrame frame, Object type, PythonObjectFactory factory, + static void MakeAnonFields(VirtualFrame frame, Object type, @Bind("this") Node inliningTarget, @Cached PySequenceCheckNode sequenceCheckNode, @Cached PyObjectSizeNode sizeNode, @@ -338,7 +338,7 @@ static void MakeAnonFields(VirtualFrame frame, Object type, PythonObjectFactory descr.anonymous = 1; /* descr is in the field descriptor. */ - makeFieldsNode.execute(frame, type, descr, descr.index, descr.offset, factory); + makeFieldsNode.execute(frame, type, descr, descr.index, descr.offset); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java index ec38eb8b2a..76692aed21 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -66,6 +66,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -104,7 +105,7 @@ import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -148,6 +149,7 @@ protected boolean isStruct() { @Specialization protected Object StructUnionTypeNew(VirtualFrame frame, Object type, Object[] args, PKeyword[] kwds, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached HashingStorageAddAllToOther addAllToOtherNode, @Cached HashingStorageGetItem getItemResDict, @Cached HashingStorageGetItem getItemStgDict, @@ -156,8 +158,7 @@ protected Object StructUnionTypeNew(VirtualFrame frame, Object type, Object[] ar @Cached GetDictIfExistsNode getDict, @Cached SetDictNode setDict, @Cached GetBaseClassNode getBaseClassNode, - @Cached PyObjectSetAttr setFieldsAttributeNode, - @Cached PythonObjectFactory factory) { + @Cached PyObjectSetAttr setFieldsAttributeNode) { /* * create the new instance (which is a class, since we are a metatype!) */ @@ -165,13 +166,13 @@ protected Object StructUnionTypeNew(VirtualFrame frame, Object type, Object[] ar PDict resDict = getDict.execute(result); if (resDict == null) { - resDict = factory.createDictFixedStorage((PythonObject) result); + resDict = PFactory.createDictFixedStorage(language, (PythonObject) result); } if (getItemResDict.hasKey(inliningTarget, resDict.getDictStorage(), T__ABSTRACT_)) { return result; } - StgDictObject dict = factory.createStgDictObject(PythonBuiltinClassType.StgDict); + StgDictObject dict = PFactory.createStgDictObject(language); if (!isStruct()) { dict.flags |= TYPEFLAG_HASUNION; } @@ -205,7 +206,7 @@ protected Object StructUnionTypeNew(VirtualFrame frame, Object type, Object[] ar @ImportStatic(StructUnionTypeBuiltins.class) @SuppressWarnings("truffle-inlining") // footprint reduction 292 -> 275 protected abstract static class PyCStructUnionTypeUpdateStgDict extends Node { - abstract void execute(VirtualFrame frame, Object type, Object fields, boolean isStruct, PythonObjectFactory factory); + abstract void execute(VirtualFrame frame, Object type, Object fields, boolean isStruct); /* * Retrieve the (optional) _pack_ attribute from a type, the _fields_ attribute, and create @@ -213,7 +214,7 @@ protected abstract static class PyCStructUnionTypeUpdateStgDict extends Node { */ @SuppressWarnings("fallthrough") @Specialization - static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, Object fields, boolean isStruct, PythonObjectFactory factory, + static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, Object fields, boolean isStruct, @Bind("this") Node inliningTarget, @Cached PyTypeCheck pyTypeCheck, @Cached GetInternalObjectArrayNode getArray, @@ -321,7 +322,6 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O for (int idx = 0; idx < len + 1; idx++) { stgdict.ffi_type_pointer.elements[idx] = new FFIType(); } - */ ffi_ofs = 0; } @@ -412,7 +412,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O CFieldObject prop; if (isStruct) { int[] props = new int[]{field_size, bitofs, size, offset, align}; - prop = cFieldFromDesc.execute(inliningTarget, desc, i, bitsize, pack, big_endian, props, factory); + prop = cFieldFromDesc.execute(inliningTarget, desc, i, bitsize, pack, big_endian, props); field_size = props[0]; bitofs = props[1]; size = props[2]; @@ -426,7 +426,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O offset = 0; align = 0; int[] props = new int[]{field_size, bitofs, size, offset, align}; - prop = cFieldFromDesc.execute(inliningTarget, desc, i, bitsize, pack, big_endian, props, factory); + prop = cFieldFromDesc.execute(inliningTarget, desc, i, bitsize, pack, big_endian, props); field_size = props[0]; bitofs = props[1]; size = props[2]; @@ -516,7 +516,6 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O fieldsError(); } Object desc = tuple[1]; - StgDictObject dict = pyTypeStgDictNode.execute(desc); if (dict == null) { throw raise(TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); @@ -612,7 +611,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O } stgdict.flags |= DICTFLAG_FINAL; - makeAnonFieldsNode.execute(frame, type, factory); + makeAnonFieldsNode.execute(frame, type); } static void fieldsError(PRaiseNode raiseNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java index 4b494e6811..2f7f6f3093 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -61,7 +61,6 @@ import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -102,10 +101,9 @@ static void doStringKey(VirtualFrame frame, Object object, TruffleString key, Ob @Exclusive @Cached ObjectNodes.GenericSetAttrNode genericSetAttrNode, @Shared @Cached WriteAttributeToObjectNode write, @Shared @Cached TruffleString.EqualNode equalNode, - @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict) { genericSetAttrNode.execute(inliningTarget, frame, object, key, value, write); - updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict, factory); + updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict); } // @Exclusive to address warning @@ -118,17 +116,16 @@ static void doGenericKey(VirtualFrame frame, Object object, Object keyObject, Ob @Exclusive @Cached ObjectNodes.GenericSetAttrNode genericSetAttrNode, @Shared @Cached WriteAttributeToObjectNode write, @Shared @Cached TruffleString.EqualNode equalNode, - @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PyCStructUnionTypeUpdateStgDict updateStgDict) { TruffleString key = GenericSetAttrNode.castAttributeKey(inliningTarget, keyObject, castKeyNode, raiseNode); genericSetAttrNode.execute(inliningTarget, frame, object, key, value, write); - updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict, factory); + updateStgDictIfNecessary(frame, object, key, value, equalNode, updateStgDict); } private static void updateStgDictIfNecessary(VirtualFrame frame, Object object, TruffleString key, Object value, - EqualNode equalNode, PyCStructUnionTypeUpdateStgDict updateStgDict, PythonObjectFactory factory) { + EqualNode equalNode, PyCStructUnionTypeUpdateStgDict updateStgDict) { if (equalNode.execute(key, StructUnionTypeBuiltins.T__FIELDS_, TS_ENCODING)) { - updateStgDict.execute(frame, object, value, false, factory); + updateStgDict.execute(frame, object, value, false); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java index 80fa1baef0..3c0ca89832 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -65,7 +66,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -100,7 +101,7 @@ public void initialize(Python3Core core) { "\n" + // "cache_info_type: namedtuple class with the fields:\n" + // " hits misses currsize maxsize\n"); - core.lookupBuiltinModule(T_FUNCTOOLS).setModuleState(core.factory().createPythonObject(PythonObject)); + core.lookupBuiltinModule(T_FUNCTOOLS).setModuleState(PFactory.createPythonObject(core.getLanguage(), PythonObject, PythonObject.getInstanceShape(core.getLanguage()))); } // functools.reduce(function, iterable[, initializer]) @@ -172,8 +173,8 @@ Object doReduce(VirtualFrame frame, Object function, Object sequence, Object ini public abstract static class CmpToKeyNode extends PythonUnaryBuiltinNode { @Specialization static Object doConvert(Object myCmp, - @Cached PythonObjectFactory factory) { - return factory.createKeyWrapper(myCmp); + @Bind PythonLanguage language) { + return PFactory.createKeyWrapper(language, myCmp); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java index 7dc439de6a..22456534d6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -63,7 +64,7 @@ import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -174,8 +175,8 @@ BinaryComparisonNode createCmp() { public abstract static class KWCallNode extends PythonBinaryBuiltinNode { @Specialization static Object call(PKeyWrapper self, Object obj, - @Cached PythonObjectFactory factory) { - final PKeyWrapper keyWrapper = factory.createKeyWrapper(self.getCmp()); + @Bind PythonLanguage language) { + final PKeyWrapper keyWrapper = PFactory.createKeyWrapper(language, self.getCmp()); keyWrapper.setObject(obj); return keyWrapper; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java index 99a8b38fa2..9d540461cd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -56,6 +56,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -71,6 +72,7 @@ import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode; import com.oracle.graal.python.lib.PyCallableCheckNode; import com.oracle.graal.python.lib.PyIndexCheckNode; @@ -93,7 +95,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -147,7 +149,7 @@ static Object lruCacheNew(VirtualFrame frame, Object type, @Cached PyCallableCheckNode callableCheck, @Cached PyIndexCheckNode indexCheck, @Cached PyNumberAsSizeNode numberAsSize, - @Cached PythonObjectFactory factory, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!callableCheck.execute(inliningTarget, func)) { @@ -175,7 +177,8 @@ static Object lruCacheNew(VirtualFrame frame, Object type, throw raiseNode.get(inliningTarget).raise(TypeError, MAXSIZE_SHOULD_BE_INTEGER_OR_NONE); } - LruCacheObject obj = factory.createLruCacheObject(type); + PythonContext context = PythonContext.get(inliningTarget); + LruCacheObject obj = PFactory.createLruCacheObject(context.getLanguage(inliningTarget), type, getInstanceShape.execute(type)); obj.root.prev = obj.root; obj.root.next = obj.root; @@ -187,7 +190,7 @@ static Object lruCacheNew(VirtualFrame frame, Object type, obj.misses = obj.hits = 0; obj.maxsize = maxsize; - obj.kwdMark = PythonContext.get(inliningTarget).lookupBuiltinModule(T_FUNCTOOLS).getModuleState(Object.class); + obj.kwdMark = context.lookupBuiltinModule(T_FUNCTOOLS).getModuleState(Object.class); obj.cacheInfoType = cache_info_type; // obj.dict = null; @@ -288,8 +291,7 @@ static Object lruCacheMakeKey(Object kwdMark, Object[] args, PKeyword[] kwds, in Node inliningTarget, GetClassNode getClassNode, PyUnicodeCheckExactNode unicodeCheckExact, - PyLongCheckExactNode longCheckExact, - PythonObjectFactory factory) { + PyLongCheckExactNode longCheckExact) { int kwdsSize = kwds.length; /* short path, key will match args anyway, which is a tuple */ if (typed == 0 && kwdsSize == 0) { @@ -303,7 +305,7 @@ static Object lruCacheMakeKey(Object kwdMark, Object[] args, PKeyword[] kwds, in } } - return factory.createTuple(args); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), args); } int argsLen = args.length; int keySize = args.length; @@ -338,7 +340,7 @@ static Object lruCacheMakeKey(Object kwdMark, Object[] args, PKeyword[] kwds, in } } assert (keyPos == keySize); - return factory.createTuple(keyArray); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), keyArray); } // infinite_lru_cache_wrapper @@ -531,10 +533,9 @@ static Object cachedLruCacheWrapper(VirtualFrame frame, LruCacheObject self, Obj @Cached PyUnicodeCheckExactNode unicodeCheckExact, @Cached PyLongCheckExactNode longCheckExact, @Cached ObjectHashMap.RemoveNode popItem, - @Cached InlinedConditionProfile profile, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile profile) { Object key = lruCacheMakeKey(self.kwdMark, args, kwds, self.typed, - inliningTarget, getClassNode, unicodeCheckExact, longCheckExact, factory); + inliningTarget, getClassNode, unicodeCheckExact, longCheckExact); long hash = hashNode.execute(frame, inliningTarget, key); Object cached = getItem.execute(frame, inliningTarget, self.cache, key, hash); if (profile.profile(inliningTarget, self.isInfinite())) { @@ -582,12 +583,11 @@ abstract static class GetNode extends DescrGetBuiltinNode { @Specialization static Object getmethod(LruCacheObject self, Object obj, @SuppressWarnings("unused") Object type, @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile objIsNoneProfile, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile objIsNoneProfile) { if (objIsNoneProfile.profile(inliningTarget, obj instanceof PNone)) { return self; } - return factory.createMethod(obj, self); + return PFactory.createMethod(PythonLanguage.get(inliningTarget), obj, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PPartial.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PPartial.java index 9dfdb02743..7cc36b701b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PPartial.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PPartial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.modules.functools; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageCopy; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; import com.oracle.graal.python.builtins.objects.common.SequenceNodes; @@ -47,7 +48,7 @@ import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; @@ -76,9 +77,9 @@ public Object[] getArgs() { return args; } - public PTuple getArgsTuple(PythonObjectFactory factory) { + public PTuple getArgsTuple(PythonLanguage language) { if (argsTuple == null) { - this.argsTuple = factory.createTuple(args); + this.argsTuple = PFactory.createTuple(language, args); } return argsTuple; } @@ -92,16 +93,16 @@ public PDict getKw() { return kw; } - public PDict getOrCreateKw(PythonObjectFactory factory) { + public PDict getOrCreateKw(PythonLanguage language) { if (kw == null) { - kw = factory.createDict(); + kw = PFactory.createDict(language); } return kw; } - public PDict getKwCopy(Node inliningTarget, PythonObjectFactory factory, HashingStorageCopy copyNode) { + public PDict getKwCopy(Node inliningTarget, PythonLanguage language, HashingStorageCopy copyNode) { assert kw != null; - return factory.createDict(copyNode.execute(inliningTarget, kw.getDictStorage())); + return PFactory.createDict(language, copyNode.execute(inliningTarget, kw.getDictStorage())); } public boolean hasKw(Node inliningTarget, HashingStorageLen lenNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java index ec3601c9e1..b7bfb230c8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -60,6 +60,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -104,7 +105,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -176,19 +177,20 @@ static Object createFromPartialWoDictWoKw(Object cls, Object[] args, PKeyword[] @Exclusive @Cached InlinedConditionProfile hasArgsProfile, @Exclusive @Cached InlinedConditionProfile hasKeywordsProfile, @Exclusive @SuppressWarnings("unused") @Cached HashingStorageLen lenNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { assert args[0] instanceof PPartial; final PPartial function = (PPartial) args[0]; Object[] funcArgs = getNewPartialArgs(function, args, inliningTarget, hasArgsProfile, 1); PDict funcKwDict; if (hasKeywordsProfile.profile(inliningTarget, keywords.length > 0)) { - funcKwDict = factory.createDict(keywords); + funcKwDict = PFactory.createDict(language, keywords); } else { - funcKwDict = factory.createDict(); + funcKwDict = PFactory.createDict(language); } - return factory.createPartial(cls, function.getFn(), funcArgs, funcKwDict); + return PFactory.createPartial(language, cls, getInstanceShape.execute(cls), function.getFn(), funcArgs, funcKwDict); } @Specialization(guards = {"atLeastOneArg(args)", "isPartialWithoutDict(inliningTarget, getDict, args, lenNode, true)", "!withKeywords(keywords)"}, limit = "1") @@ -198,11 +200,12 @@ static Object createFromPartialWoDictWKw(Object cls, Object[] args, @SuppressWar @Exclusive @Cached InlinedConditionProfile hasArgsProfile, @Exclusive @SuppressWarnings("unused") @Cached HashingStorageLen lenNode, @Exclusive @Cached HashingStorageCopy copyNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { assert args[0] instanceof PPartial; final PPartial function = (PPartial) args[0]; Object[] funcArgs = getNewPartialArgs(function, args, inliningTarget, hasArgsProfile, 1); - return factory.createPartial(cls, function.getFn(), funcArgs, function.getKwCopy(inliningTarget, factory, copyNode)); + return PFactory.createPartial(language, cls, getInstanceShape.execute(cls), function.getFn(), funcArgs, function.getKwCopy(inliningTarget, language, copyNode)); } @Specialization(guards = {"atLeastOneArg(args)", "isPartialWithoutDict(inliningTarget, getDict, args, lenNode, true)", "withKeywords(keywords)"}, limit = "1") @@ -214,16 +217,17 @@ static Object createFromPartialWoDictWKwKw(VirtualFrame frame, Object cls, Objec @Exclusive @SuppressWarnings("unused") @Cached HashingStorageLen lenNode, @Exclusive @Cached HashingStorageCopy copyHashingStorageNode, @Cached HashingStorageAddAllToOther addAllToOtherNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape) { assert args[0] instanceof PPartial; final PPartial function = (PPartial) args[0]; Object[] funcArgs = getNewPartialArgs(function, args, inliningTarget, hasArgsProfile, 1); HashingStorage storage = copyHashingStorageNode.execute(inliningTarget, function.getKw().getDictStorage()); - PDict result = factory.createDict(storage); + PDict result = PFactory.createDict(language, storage); addAllToOtherNode.execute(frame, inliningTarget, initNode.execute(frame, PNone.NO_VALUE, keywords), result); - return factory.createPartial(cls, function.getFn(), funcArgs, result); + return PFactory.createPartial(language, cls, getInstanceShape.execute(cls), function.getFn(), funcArgs, result); } @Specialization(guards = {"atLeastOneArg(args)", "!isPartialWithoutDict(getDict, args)"}, limit = "1") @@ -232,7 +236,8 @@ static Object createGeneric(Object cls, Object[] args, PKeyword[] keywords, @SuppressWarnings("unused") @Exclusive @Cached GetDictIfExistsNode getDict, @Exclusive @Cached InlinedConditionProfile hasKeywordsProfile, @Cached PyCallableCheckNode callableCheckNode, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { Object function = args[0]; if (!callableCheckNode.execute(inliningTarget, function)) { @@ -242,11 +247,11 @@ static Object createGeneric(Object cls, Object[] args, PKeyword[] keywords, final Object[] funcArgs = PythonUtils.arrayCopyOfRange(args, 1, args.length); PDict funcKwDict; if (hasKeywordsProfile.profile(inliningTarget, keywords.length > 0)) { - funcKwDict = factory.createDict(keywords); + funcKwDict = PFactory.createDict(language, keywords); } else { - funcKwDict = factory.createDict(); + funcKwDict = PFactory.createDict(language); } - return factory.createPartial(cls, function, funcArgs, funcKwDict); + return PFactory.createPartial(language, cls, getInstanceShape.execute(cls), function, funcArgs, funcKwDict); } @Specialization(guards = "!atLeastOneArg(args)") @@ -271,8 +276,8 @@ static Object doGet(PPartial self) { public abstract static class PartialArgsNode extends PythonUnaryBuiltinNode { @Specialization static Object doGet(PPartial self, - @Cached PythonObjectFactory factory) { - return self.getArgsTuple(factory); + @Bind PythonLanguage language) { + return self.getArgsTuple(language); } } @@ -307,8 +312,8 @@ static Object setDict(@SuppressWarnings("unused") PPartial self, Object mapping, public abstract static class PartialKeywordsNode extends PythonUnaryBuiltinNode { @Specialization static Object doGet(PPartial self, - @Cached PythonObjectFactory factory) { - return self.getOrCreateKw(factory); + @Bind PythonLanguage language) { + return self.getOrCreateKw(language); } } @@ -321,7 +326,7 @@ static Object reduce(PPartial self, @Cached GetClassNode getClassNode, @Cached GetDictIfExistsNode getDictIfExistsNode, @Cached GetOrCreateDictNode getOrCreateDictNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { final PDict dict; if (self.getShape().getPropertyCount() > 0) { dict = getOrCreateDictNode.execute(inliningTarget, self); @@ -329,9 +334,9 @@ static Object reduce(PPartial self, dict = getDictIfExistsNode.execute(self); } final Object type = getClassNode.execute(inliningTarget, self); - final PTuple fnTuple = factory.createTuple(new Object[]{self.getFn()}); - final PTuple argsTuple = factory.createTuple(new Object[]{self.getFn(), self.getArgsTuple(factory), self.getKw(), (dict != null) ? dict : PNone.NONE}); - return factory.createTuple(new Object[]{type, fnTuple, argsTuple}); + final PTuple fnTuple = PFactory.createTuple(language, new Object[]{self.getFn()}); + final PTuple argsTuple = PFactory.createTuple(language, new Object[]{self.getFn(), self.getArgsTuple(language), self.getKw(), (dict != null) ? dict : PNone.NONE}); + return PFactory.createTuple(language, new Object[]{type, fnTuple, argsTuple}); } } @@ -352,7 +357,7 @@ static Object setState(VirtualFrame frame, PPartial self, PTuple state, @Cached PyTupleGetItem getItemNode, @Cached TupleNodes.ConstructTupleNode constructTupleNode, @Cached HashingStorageCopy copyStorageNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (state.getSequenceStorage().length() != 4) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); @@ -381,9 +386,9 @@ static Object setState(VirtualFrame frame, PPartial self, PTuple state, final PDict fnKwargsDict; if (fnKwargs == PNone.NONE) { - fnKwargsDict = factory.createDict(); + fnKwargsDict = PFactory.createDict(language); } else if (!dictCheckExactNode.execute(inliningTarget, fnKwargs)) { - fnKwargsDict = factory.createDict(copyStorageNode.execute(inliningTarget, ((PDict) fnKwargs).getDictStorage())); + fnKwargsDict = PFactory.createDict(language, copyStorageNode.execute(inliningTarget, ((PDict) fnKwargs).getDictStorage())); } else { fnKwargsDict = (PDict) fnKwargs; } @@ -544,8 +549,8 @@ public static TruffleString repr(VirtualFrame frame, PPartial partial, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObject.java index 38f3faef1e..180a253237 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,9 +44,10 @@ import javax.crypto.Mac; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.object.Shape; @@ -199,7 +200,7 @@ private PythonBuiltinClassType determineMainDigestType() { */ abstract void update(byte[] data, int length); - abstract DigestObject copy(PythonObjectFactory factory) throws CloneNotSupportedException; + abstract DigestObject copy() throws CloneNotSupportedException; abstract int getDigestLength(); @@ -263,8 +264,8 @@ private static final class MessageDigestObject extends DigestObjectBase { @Override @TruffleBoundary - DigestObject copy(PythonObjectFactory factory) throws CloneNotSupportedException { - return factory.createDigestObject(getType(), getAlgorithm(), digest.clone()); + DigestObject copy() throws CloneNotSupportedException { + return PFactory.createDigestObject(PythonLanguage.get(null), getType(), getAlgorithm(), digest.clone()); } @Override @@ -302,8 +303,8 @@ private static final class MacDigestObject extends DigestObjectBase { @Override @TruffleBoundary - DigestObject copy(PythonObjectFactory factory) throws CloneNotSupportedException { - return factory.createDigestObject(getType(), getAlgorithm(), mac.clone()); + DigestObject copy() throws CloneNotSupportedException { + return PFactory.createDigestObject(PythonLanguage.get(null), getType(), getAlgorithm(), mac.clone()); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java index 80ed174aa8..a8678ca506 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -59,7 +60,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -89,10 +90,9 @@ abstract static class CopyNode extends PythonUnaryBuiltinNode { @Specialization static DigestObject copy(DigestObject self, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { - return self.copy(factory); + return self.copy(); } catch (CloneNotSupportedException e) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError); } @@ -104,8 +104,8 @@ static DigestObject copy(DigestObject self, abstract static class DigestNode extends PythonUnaryBuiltinNode { @Specialization static PBytes digest(DigestObject self, - @Cached PythonObjectFactory factory) { - return factory.createBytes(self.digest()); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, self.digest()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java index 0ff93cf187..9dff6e5708 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -60,6 +60,7 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -87,7 +88,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -158,10 +159,11 @@ public void initialize(Python3Core core) { for (var digest : DIGEST_ALGORITHMS) { algos.putUncachedWithJavaEq(digest, PNone.NONE); } - addBuiltinConstant("openssl_md_meth_names", core.factory().createFrozenSet(algos)); + PythonLanguage language = core.getLanguage(); + addBuiltinConstant("openssl_md_meth_names", PFactory.createFrozenSet(language, algos)); EconomicMapStorage storage = EconomicMapStorage.create(); - addBuiltinConstant(J_CONSTRUCTORS, core.factory().createMappingproxy(core.factory().createDict(storage))); + addBuiltinConstant(J_CONSTRUCTORS, PFactory.createMappingproxy(language, PFactory.createDict(language, storage))); core.lookupBuiltinModule(T_HASHLIB).setModuleState(storage); super.initialize(core); } @@ -283,14 +285,13 @@ static Object hmacNewFromFunction(VirtualFrame frame, PythonModule self, Object @Shared("concatStr") @Cached TruffleString.ConcatNode concatStr, @Shared("acquireLib") @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @Shared("bufferLib") @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { // cast guaranteed in our initialize EconomicMapStorage constructors = self.getModuleState(EconomicMapStorage.class); Object name = getItemNode.execute(frame, inliningTarget, constructors, digestmod); if (name != null) { assert name instanceof TruffleString; // guaranteed in our initialize - return hmacNew(self, key, msg, name, inliningTarget, castStr, castJStr, concatStr, acquireLib, bufferLib, factory, raiseNode); + return hmacNew(self, key, msg, name, inliningTarget, castStr, castJStr, concatStr, acquireLib, bufferLib, raiseNode); } else { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError); } @@ -304,7 +305,6 @@ static Object hmacNew(@SuppressWarnings("unused") PythonModule self, Object keyO @Shared("concatStr") @Cached TruffleString.ConcatNode concatStr, @Shared("acquireLib") @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @Shared("bufferLib") @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { TruffleString digestmod = castStr.execute(inliningTarget, digestmodObj); Object key; @@ -326,7 +326,8 @@ static Object hmacNew(@SuppressWarnings("unused") PythonModule self, Object keyO byte[] msgBytes = msg == null ? null : bufferLib.getInternalOrCopiedByteArray(msg); int msgLen = msg == null ? 0 : bufferLib.getBufferLength(msg); Mac mac = createMac(digestmod, bufferLib.getInternalOrCopiedByteArray(key), bufferLib.getBufferLength(key), msgBytes, msgLen); - return factory.createDigestObject(PythonBuiltinClassType.HashlibHmac, castJStr.execute(concatStr.execute(HMAC_PREFIX, digestmod, TS_ENCODING, true)), mac); + return PFactory.createDigestObject(PythonLanguage.get(inliningTarget), PythonBuiltinClassType.HashlibHmac, + castJStr.execute(concatStr.execute(HMAC_PREFIX, digestmod, TS_ENCODING, true)), mac); } catch (InvalidKeyException | NoSuchAlgorithmException e) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError, e); } finally { @@ -362,7 +363,6 @@ abstract static class CreateDigestNode extends Node { @Specialization static Object doIt(VirtualFrame frame, Node inliningTarget, PythonBuiltinClassType type, String pythonName, String javaName, Object value, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached(inline = false) PythonObjectFactory factory, @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Cached PRaiseNode.Lazy raise) { @@ -383,7 +383,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, PythonBuiltinClassTy } catch (NoSuchAlgorithmException e) { throw raise.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError, e); } - return factory.createDigestObject(type, pythonName, digest); + return PFactory.createDigestObject(PythonLanguage.get(inliningTarget), type, pythonName, digest); } finally { if (buffer != null) { bufferLib.release(buffer, frame, indirectCallData); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java index 1d736b68e4..268a976356 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -94,12 +95,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PBytes digest(DigestObject self, int length, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (self.getDigestLength() != length) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFAULT_DIGEST_LENGTHS); } - return factory.createBytes(self.digest()); + return PFactory.createBytes(language, self.digest()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java index e1d5232967..10d38fa1fc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import static com.oracle.graal.python.nodes.ErrorMessages.IO_UNINIT; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.RawTellIgnoreErrorNode; @@ -66,8 +67,9 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; @@ -85,25 +87,26 @@ abstract class AbstractBufferedIOBuiltins extends PythonBuiltins { @GenerateCached(false) public abstract static class BufferedInitNode extends PNodeWithContext { - public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, int bufferSize, PythonObjectFactory factory); + public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, int bufferSize); @Specialization(guards = "bufferSize > 0") - static void bufferedInit(VirtualFrame frame, Node inliningTarget, PBuffered self, int bufferSize, PythonObjectFactory factory, - @Cached RawTellIgnoreErrorNode rawTellNode) { - init(self, bufferSize, factory); + static void bufferedInit(VirtualFrame frame, Node inliningTarget, PBuffered self, int bufferSize, + @Cached RawTellIgnoreErrorNode rawTellNode, + @Bind PythonLanguage language) { + init(self, bufferSize, language); rawTellNode.execute(frame, inliningTarget, self); } @SuppressWarnings("unused") @Specialization(guards = "bufferSize <= 0") - static void bufferSizeError(PBuffered self, int bufferSize, PythonObjectFactory factory, + static void bufferSizeError(PBuffered self, int bufferSize, @Cached(inline = false) PRaiseNode raiseNode) { throw raiseNode.raise(ValueError, BUF_SIZE_POS); } - private static void init(PBuffered self, int bufferSize, PythonObjectFactory factory) { + private static void init(PBuffered self, int bufferSize, PythonLanguage language) { self.initBuffer(bufferSize); - self.setLock(factory.createLock()); + self.setLock(PFactory.createLock(language)); self.setOwner(0); int n; for (n = bufferSize - 1; (n & 1) != 0; n >>= 1) { @@ -112,10 +115,10 @@ private static void init(PBuffered self, int bufferSize, PythonObjectFactory fac self.setBufferMask(mask); } - public static void internalInit(PBuffered self, int bufferSize, PythonObjectFactory factory, + public static void internalInit(PBuffered self, int bufferSize, PythonLanguage language, Object posixSupport, PosixSupportLibrary posixLib) { - init(self, bufferSize, factory); + init(self, bufferSize, language); try { FileIOBuiltins.TellNode.internalTell(self.getFileIORaw(), posixSupport, posixLib); } catch (PosixException e) { @@ -216,13 +219,13 @@ public final PException raiseEAGAIN(TruffleString message, int written) { @Specialization static PException raise(Node node, Object errno, TruffleString message, int written, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] args = new Object[]{ errno, message, written }; - PBaseException exception = factory.createBaseException(BlockingIOError, factory.createTuple(args)); + PBaseException exception = PFactory.createBaseException(language, BlockingIOError, PFactory.createTuple(language, args)); final Object[] attrs = OS_ERROR_ATTR_FACTORY.create(); attrs[OsErrorBuiltins.IDX_ERRNO] = errno; attrs[OsErrorBuiltins.IDX_STRERROR] = message; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java index 9cd72d1105..4a6189b539 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,8 +41,6 @@ package com.oracle.graal.python.builtins.modules.io; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedRWPair; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedReader; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedWriter; import static com.oracle.graal.python.builtins.modules.io.IONodes.J_CLOSE; import static com.oracle.graal.python.builtins.modules.io.IONodes.J_CLOSED; import static com.oracle.graal.python.builtins.modules.io.IONodes.J_FLUSH; @@ -75,6 +73,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -91,7 +90,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.IsNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -128,13 +127,13 @@ static PNone doInit(VirtualFrame frame, PRWPair self, Object reader, Object writ @Cached IOBaseBuiltins.CheckBoolMethodHelperNode checkWritableNode, @Cached BufferedReaderBuiltins.BufferedReaderInit initReaderNode, @Cached BufferedWriterBuiltins.BufferedWriterInit initWriterNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { checkReadableNode.checkReadable(frame, inliningTarget, reader); checkWritableNode.checkWriteable(frame, inliningTarget, writer); - self.setReader(factory.createBufferedReader(PBufferedReader)); - initReaderNode.execute(frame, inliningTarget, self.getReader(), reader, bufferSize, factory); - self.setWriter(factory.createBufferedWriter(PBufferedWriter)); - initWriterNode.execute(frame, inliningTarget, self.getWriter(), writer, bufferSize, factory); + self.setReader(PFactory.createBufferedReader(language)); + initReaderNode.execute(frame, inliningTarget, self.getReader(), reader, bufferSize); + self.setWriter(PFactory.createBufferedWriter(language)); + initWriterNode.execute(frame, inliningTarget, self.getWriter(), writer, bufferSize); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRandomBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRandomBuiltins.java index ac9a19e585..cdb5be4fa2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRandomBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRandomBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -52,7 +52,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -74,10 +73,10 @@ protected List> getNodeFa @GenerateInline public abstract static class BufferedRandomInit extends Node { - public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory); + public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize); @Specialization - static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory, + static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, @Cached IOBaseBuiltins.CheckBoolMethodHelperNode checkSeekableNode, @Cached IOBaseBuiltins.CheckBoolMethodHelperNode checkReadableNode, @Cached IOBaseBuiltins.CheckBoolMethodHelperNode checkWritableNode, @@ -90,7 +89,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Obje checkReadableNode.checkReadable(frame, inliningTarget, raw); checkWritableNode.checkWriteable(frame, inliningTarget, raw); self.setRaw(raw, isFileIO(self, raw, PBufferedRandom, inliningTarget, getSelfClass, getRawClass)); - bufferedInitNode.execute(frame, inliningTarget, self, bufferSize, factory); + bufferedInitNode.execute(frame, inliningTarget, self, bufferSize); self.resetRead(); self.resetWrite(); self.setPos(0); @@ -107,10 +106,9 @@ public abstract static class InitNode extends PythonBuiltinNode { static Object doIt(VirtualFrame frame, PBuffered self, Object raw, Object bufferSize, @Bind("this") Node inliningTarget, @Cached InitBufferSizeNode initBufferSizeNode, - @Cached BufferedRandomInit init, - @Cached PythonObjectFactory factory) { + @Cached BufferedRandomInit init) { int size = initBufferSizeNode.execute(frame, inliningTarget, bufferSize); - init.execute(frame, inliningTarget, self, raw, size, factory); + init.execute(frame, inliningTarget, self, raw, size); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderBuiltins.java index 38ae3204f9..959fc33fc2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.objects.PNone; @@ -56,7 +57,6 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.runtime.PosixSupportLibrary; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -78,10 +78,10 @@ protected List> getNodeFa @GenerateCached(false) public abstract static class BufferedReaderInit extends Node { - public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory); + public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize); @Specialization - static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory, + static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, @Cached IOBaseBuiltins.CheckBoolMethodHelperNode checkReadableNode, @Cached BufferedInitNode bufferedInitNode, @Cached GetPythonObjectClassNode getSelfClass, @@ -90,17 +90,17 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PBuffered self, Obje self.setDetached(false); checkReadableNode.checkReadable(frame, inliningTarget, raw); self.setRaw(raw, isFileIO(self, raw, PBufferedReader, inliningTarget, getSelfClass, getRawClass)); - bufferedInitNode.execute(frame, inliningTarget, self, bufferSize, factory); + bufferedInitNode.execute(frame, inliningTarget, self, bufferSize); self.resetRead(); self.setOK(true); } - public static void internalInit(PBuffered self, PFileIO raw, int bufferSize, PythonObjectFactory factory, + public static void internalInit(PBuffered self, PFileIO raw, int bufferSize, PythonLanguage language, Object posixSupport, PosixSupportLibrary posixLib) { self.setDetached(false); self.setRaw(raw, true); - BufferedInitNode.internalInit(self, bufferSize, factory, posixSupport, posixLib); + BufferedInitNode.internalInit(self, bufferSize, language, posixSupport, posixLib); self.resetRead(); self.setOK(true); } @@ -114,10 +114,9 @@ public abstract static class InitNode extends PythonBuiltinNode { static Object doIt(VirtualFrame frame, PBuffered self, Object raw, Object bufferSize, @Bind("this") Node inliningTarget, @Cached InitBufferSizeNode initBufferSizeNode, - @Cached BufferedReaderInit init, - @Cached PythonObjectFactory factory) { + @Cached BufferedReaderInit init) { int size = initBufferSizeNode.execute(frame, inliningTarget, bufferSize); - init.execute(frame, inliningTarget, self, raw, size, factory); + init.execute(frame, inliningTarget, self, raw, size); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java index e8f374a893..6e9a6459af 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -71,6 +71,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -96,12 +97,11 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -136,13 +136,13 @@ abstract static class RawReadNode extends PNodeWithContext { // This is the spec way @Specialization static byte[] bufferedreaderRawRead(VirtualFrame frame, Node inliningTarget, PBuffered self, int len, + @Bind PythonLanguage language, @Cached(inline = false) BytesNodes.ToBytesNode toBytes, - @Cached(inline = false) PythonObjectFactory factory, @Cached PyObjectCallMethodObjArgs callMethodReadInto, @Cached PyNumberAsSizeNode asSizeNode, @Cached InlinedConditionProfile osError, @Cached PRaiseNode.Lazy lazyRaiseNode) { - PByteArray memobj = factory.createByteArray(new byte[len]); + PByteArray memobj = PFactory.createByteArray(language, new byte[len]); // TODO _PyIO_trap_eintr [GR-23297] Object res = callMethodReadInto.execute(frame, inliningTarget, self.getRaw(), T_READINTO, memobj); if (res == PNone.NONE) { @@ -250,9 +250,9 @@ public static boolean isReadFast(PBuffered self, int size) { @Specialization(guards = {"self.isOK()", "size == 0"}) Object empty(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int size, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { checkIsClosedNode.execute(frame, self); - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } /* @@ -272,9 +272,9 @@ public static byte[] bufferedreaderReadFast(PBuffered self, int size) { @Specialization(guards = {"self.isOK()", "size > 0", "isReadFast(self, size)"}) Object readFast(VirtualFrame frame, PBuffered self, int size, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { checkIsClosedNode.execute(frame, self); - return factory.createBytes(bufferedreaderReadFast(self, size)); + return PFactory.createBytes(language, bufferedreaderReadFast(self, size)); } /** @@ -284,17 +284,17 @@ Object readFast(VirtualFrame frame, PBuffered self, int size, @SuppressWarnings("truffle-static-method") // checkIsClosedNode Object bufferedreaderReadGeneric(VirtualFrame frame, PBuffered self, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached EnterBufferedNode lock, @Cached RawReadNode rawReadNode, @Cached FillBufferNode fillBufferNode, - @Exclusive @Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) { checkIsClosedNode.execute(frame, self); try { lock.enter(inliningTarget, self); int currentSize = safeDowncast(self); if (size <= currentSize) { - return factory.createBytes(bufferedreaderReadFast(self, size)); + return PFactory.createBytes(language, bufferedreaderReadFast(self, size)); } byte[] res = new byte[size]; int remaining = size; @@ -328,7 +328,7 @@ If we had readv() we could do this in one pass. */ if (r == 0 || r == -2) { /* EOF occurred */ if (r == 0 || written > 0) { - return factory.createBytes(PythonUtils.arrayCopyOf(res, written)); + return PFactory.createBytes(language, PythonUtils.arrayCopyOf(res, written)); } return PNone.NONE; } @@ -347,7 +347,7 @@ reads, which could block indefinitely (e.g. on a socket). if (r == 0 || r == -2) { /* EOF occurred */ if (r == 0 || written > 0) { - return factory.createBytes(PythonUtils.arrayCopyOf(res, written)); + return PFactory.createBytes(language, PythonUtils.arrayCopyOf(res, written)); } return PNone.NONE; } @@ -369,7 +369,7 @@ reads, which could block indefinitely (e.g. on a socket). } } - return factory.createBytes(res); + return PFactory.createBytes(language, res); } finally { EnterBufferedNode.leave(self); } @@ -384,6 +384,7 @@ reads, which could block indefinitely (e.g. on a socket). @SuppressWarnings("truffle-static-method") // checkIsClosedNode Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached EnterBufferedNode lock, @Exclusive @Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode, @Cached("create(T_READALL)") LookupAttributeInMRONode readallAttr, @@ -393,7 +394,6 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin @Cached GetClassNode getClassNode, @Cached PyObjectCallMethodObjArgs callMethod, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { checkIsClosedNode.execute(frame, self); try { @@ -426,9 +426,9 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin byte[] res = new byte[data.length + bytesLen]; PythonUtils.arraycopy(data, 0, res, 0, data.length); bufferLib.readIntoByteArray(tmp, 0, res, data.length, bytesLen); - return factory.createBytes(res); + return PFactory.createBytes(language, res); } - return factory.createBytes(data); + return PFactory.createBytes(language, data); } else { return tmp; } @@ -456,7 +456,7 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin if (currentSize == 0) { return r; } else { - return factory.createBytes(toByteArray(chunks)); + return PFactory.createBytes(language, toByteArray(chunks)); } } currentSize += dataLen; @@ -490,10 +490,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "self.isOK()") static PBytes doit(VirtualFrame frame, PBuffered self, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached EnterBufferedNode lock, @Cached("create(T_READ)") CheckIsClosedNode checkIsClosedNode, - @Cached RawReadNode rawReadNode, - @Cached PythonObjectFactory factory) { + @Cached RawReadNode rawReadNode) { checkIsClosedNode.execute(frame, self); int n = size; if (n < 0) { @@ -501,7 +501,7 @@ static PBytes doit(VirtualFrame frame, PBuffered self, int size, } if (n == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } /*- Return up to n bytes. If at least one byte is buffered, we only return buffered bytes. Otherwise, we do one raw read. */ @@ -510,13 +510,13 @@ static PBytes doit(VirtualFrame frame, PBuffered self, int size, if (have > 0) { n = have < n ? have : n; byte[] b = ReadNode.bufferedreaderReadFast(self, n); - return factory.createBytes(b); + return PFactory.createBytes(language, b); } try { lock.enter(inliningTarget, self); self.resetRead(); // _bufferedreader_reset_buf byte[] fill = rawReadNode.execute(frame, inliningTarget, self, n); - return factory.createBytes(fill == BLOCKED ? PythonUtils.EMPTY_BYTE_ARRAY : fill); + return PFactory.createBytes(language, fill == BLOCKED ? PythonUtils.EMPTY_BYTE_ARRAY : fill); } finally { EnterBufferedNode.leave(self); } @@ -748,12 +748,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "self.isOK()") static PBytes doit(VirtualFrame frame, PBuffered self, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("create(T_READLINE)") CheckIsClosedNode checkIsClosedNode, - @Cached BufferedReadlineNode readlineNode, - @Cached PythonObjectFactory factory) { + @Cached BufferedReadlineNode readlineNode) { checkIsClosedNode.execute(frame, self); byte[] res = readlineNode.execute(frame, inliningTarget, self, size); - return factory.createBytes(res); + return PFactory.createBytes(language, res); } } @@ -796,18 +796,18 @@ static byte[] bufferedreaderPeekUnlocked(VirtualFrame frame, Node inliningTarget @Specialization(guards = "self.isOK()") static Object doit(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached EnterBufferedNode lock, @Cached("create(T_PEEK)") CheckIsClosedNode checkIsClosedNode, @Cached FillBufferNode fillBufferNode, - @Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode, - @Cached PythonObjectFactory factory) { + @Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) { checkIsClosedNode.execute(frame, self); try { lock.enter(inliningTarget, self); if (self.isWritable()) { flushAndRewindUnlockedNode.execute(frame, inliningTarget, self); } - return factory.createBytes(bufferedreaderPeekUnlocked(frame, inliningTarget, self, fillBufferNode)); + return PFactory.createBytes(language, bufferedreaderPeekUnlocked(frame, inliningTarget, self, fillBufferNode)); } finally { EnterBufferedNode.leave(self); } @@ -824,14 +824,13 @@ static PBytes doit(VirtualFrame frame, PBuffered self, @Bind("this") Node inliningTarget, @Cached("create(T_READLINE)") CheckIsClosedNode checkIsClosedNode, @Cached BufferedReadlineNode readlineNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { checkIsClosedNode.execute(frame, self); byte[] line = readlineNode.execute(frame, inliningTarget, self, -1); if (line.length == 0) { throw raiseNode.get(inliningTarget).raiseStopIteration(); } - return factory.createBytes(line); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), line); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterBuiltins.java index ac47b999fe..4e591c1e93 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.modules.io.IOBaseBuiltins.CheckBoolMethodHelperNode; @@ -54,7 +55,6 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.runtime.PosixSupportLibrary; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -76,10 +76,10 @@ protected List> getNodeFa @GenerateCached(false) public abstract static class BufferedWriterInit extends Node { - public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory); + public abstract void execute(VirtualFrame frame, Node inliningTarget, PBuffered self, Object raw, int bufferSize); @Specialization - static void doInit(VirtualFrame frame, @SuppressWarnings("unused") Node ignored, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory, + static void doInit(VirtualFrame frame, @SuppressWarnings("unused") Node ignored, PBuffered self, Object raw, int bufferSize, @Bind("this") Node inliningTarget, @Cached CheckBoolMethodHelperNode checkWritableNode, @Cached BufferedInitNode bufferedInitNode, @@ -89,18 +89,18 @@ static void doInit(VirtualFrame frame, @SuppressWarnings("unused") Node ignored, self.setDetached(false); checkWritableNode.checkWriteable(frame, inliningTarget, raw); self.setRaw(raw, isFileIO(self, raw, PBufferedWriter, inliningTarget, getSelfClass, getRawClass)); - bufferedInitNode.execute(frame, inliningTarget, self, bufferSize, factory); + bufferedInitNode.execute(frame, inliningTarget, self, bufferSize); self.resetWrite(); self.setPos(0); self.setOK(true); } - public static void internalInit(PBuffered self, PFileIO raw, int bufferSize, PythonObjectFactory factory, + public static void internalInit(PBuffered self, PFileIO raw, int bufferSize, PythonLanguage language, Object posixSupport, PosixSupportLibrary posixLib) { self.setDetached(false); self.setRaw(raw, true); - BufferedInitNode.internalInit(self, bufferSize, factory, posixSupport, posixLib); + BufferedInitNode.internalInit(self, bufferSize, language, posixSupport, posixLib); self.resetWrite(); self.setPos(0); self.setOK(true); @@ -116,10 +116,9 @@ public abstract static class InitNode extends PythonBuiltinNode { static Object doIt(VirtualFrame frame, PBuffered self, Object raw, Object bufferSize, @Bind("this") Node inliningTarget, @Cached InitBufferSizeNode initBufferSizeNode, - @Cached BufferedWriterInit init, - @Cached PythonObjectFactory factory) { + @Cached BufferedWriterInit init) { int size = initBufferSizeNode.execute(frame, inliningTarget, bufferSize); - init.execute(frame, inliningTarget, self, raw, size, factory); + init.execute(frame, inliningTarget, self, raw, size); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java index baebfde434..af283f1837 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -51,6 +51,7 @@ import static com.oracle.graal.python.runtime.exception.PythonErrorType.OSError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; import com.oracle.graal.python.builtins.objects.bytes.PBytes; @@ -63,7 +64,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -223,11 +224,11 @@ abstract static class RawWriteNode extends PNodeWithContext { */ @Specialization static int bufferedwriterRawWrite(VirtualFrame frame, Node inliningTarget, PBuffered self, byte[] buf, int len, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyNumberAsSizeNode asSizeNode, @Cached PRaiseNode.Lazy lazyRaiseNode) { - PBytes memobj = factory.createBytes(buf, len); + PBytes memobj = PFactory.createBytes(language, buf, len); Object res = callMethod.execute(frame, inliningTarget, self.getRaw(), T_WRITE, memobj); if (res == PNone.NONE) { /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java index a04992337d..f5d34eac5f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 @@ package com.oracle.graal.python.builtins.modules.io; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBytesIOBuf; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_CUR; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_END; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_SET; @@ -82,6 +81,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -114,7 +114,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.ArrayBuilder; import com.oracle.graal.python.util.PythonUtils; @@ -204,9 +204,9 @@ static PNone init(VirtualFrame frame, PBytesIO self, Object initvalue, static PBytes readBytes(PBytesIO self, int size, PythonBufferAccessLibrary bufferLib, - PythonObjectFactory factory) { + PythonLanguage language) { if (size == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } assert (size <= self.getStringSize()); @@ -214,10 +214,10 @@ static PBytes readBytes(PBytesIO self, int size, if (self.getPos() == 0 && bufferLib.hasInternalByteArray(buffer) && self.getExports() == 0 && size > bufferLib.getBufferLength(buffer) / 2) { self.incPos(size); self.markEscaped(); - return factory.createBytes(bufferLib.getInternalByteArray(buffer), size); + return PFactory.createBytes(language, bufferLib.getInternalByteArray(buffer), size); } - PBytes output = factory.createBytes(bufferLib.getCopyOfRange(buffer, self.getPos(), self.getPos() + size)); + PBytes output = PFactory.createBytes(language, bufferLib.getCopyOfRange(buffer, self.getPos(), self.getPos() + size)); self.incPos(size); return output; } @@ -234,8 +234,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "self.hasBuf()") static Object read(PBytesIO self, int len, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) { int size = len; /* adjust invalid sizes */ int n = self.getStringSize() - self.getPos(); @@ -245,7 +245,7 @@ static Object read(PBytesIO self, int len, size = 0; } } - return readBytes(self, size, bufferLib, factory); + return readBytes(self, size, bufferLib, language); } } @@ -311,10 +311,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "self.hasBuf()") Object readline(PBytesIO self, int size, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) { int n = scanEOL(self, size, bufferLib); - return readBytes(self, n, bufferLib, factory); + return readBytes(self, n, bufferLib, language); } } @@ -330,8 +330,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "self.hasBuf()") static Object readlines(PBytesIO self, int maxsize, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) { ArrayBuilder result = new ArrayBuilder<>(); int n; @@ -341,7 +341,7 @@ static Object readlines(PBytesIO self, int maxsize, int size = 0; while ((n = scanEOL(self, -1, buf)) != 0) { self.incPos(n); - PBytes line = factory.createBytes(PythonUtils.arrayCopyOfRange(buf, cur, cur + n)); + PBytes line = PFactory.createBytes(language, PythonUtils.arrayCopyOfRange(buf, cur, cur + n)); result.add(line); size += n; if (maxsize > 0 && size >= maxsize) { @@ -349,7 +349,7 @@ static Object readlines(PBytesIO self, int maxsize, } cur += n; } - return factory.createList(result.toArray(new Object[0])); + return PFactory.createList(language, result.toArray(new Object[0])); } } @@ -397,15 +397,15 @@ abstract static class TruncateNode extends ClosedCheckPythonBinaryBuiltinNode { @Specialization(guards = "self.hasBuf()") static Object truncate(PBytesIO self, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { self.checkExports(inliningTarget, raiseNode); if (size < 0) { throw raiseNode.get(inliningTarget).raise(ValueError, NEGATIVE_SIZE_VALUE_D, size); } if (size < self.getStringSize()) { - self.unshareAndResize(bufferLib, factory, size, true); + self.unshareAndResize(bufferLib, language, size, true); self.setStringSize(size); } return size; @@ -414,20 +414,20 @@ static Object truncate(PBytesIO self, int size, @Specialization(guards = "self.hasBuf()") static Object truncate(PBytesIO self, @SuppressWarnings("unused") PNone size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return truncate(self, self.getPos(), inliningTarget, bufferLib, factory, raiseNode); + return truncate(self, self.getPos(), inliningTarget, language, bufferLib, raiseNode); } @Specialization(guards = {"self.hasBuf()", "!isPNone(size)"}) static Object truncate(VirtualFrame frame, PBytesIO self, Object size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyNumberAsSizeNode asSizeNode, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - return truncate(self, asSizeNode.executeExact(frame, inliningTarget, size), inliningTarget, bufferLib, factory, raiseNode); + return truncate(self, asSizeNode.executeExact(frame, inliningTarget, size), inliningTarget, language, bufferLib, raiseNode); } } @@ -438,10 +438,10 @@ abstract static class WriteNode extends ClosedCheckPythonBinaryBuiltinNode { @Specialization(guards = "self.hasBuf()", limit = "3") static Object doWrite(VirtualFrame frame, PBytesIO self, Object b, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("b") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkExports(inliningTarget, raiseNode); Object buffer = acquireLib.acquireReadonly(b, frame, indirectCallData); @@ -452,7 +452,7 @@ static Object doWrite(VirtualFrame frame, PBytesIO self, Object b, } int pos = self.getPos(); int endpos = pos + len; - self.unshareAndResize(bufferLib, factory, endpos, false); + self.unshareAndResize(bufferLib, language, endpos, false); bufferLib.readIntoBuffer(buffer, 0, self.getBuf(), pos, len, bufferLib); self.setPos(endpos); if (endpos > self.getStringSize()) { @@ -599,12 +599,12 @@ abstract static class GetBufferNode extends ClosedCheckPythonUnaryBuiltinNode { static Object doit(VirtualFrame frame, PBytesIO self, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyMemoryViewFromObject memoryViewNode, - @Cached SequenceStorageNodes.SetLenNode setLenNode, - @Cached PythonObjectFactory factory) { - self.unshareIfNecessary(bufferLib, factory); + @Cached SequenceStorageNodes.SetLenNode setLenNode) { + self.unshareIfNecessary(bufferLib, language); setLenNode.execute(inliningTarget, self.getBuf().getSequenceStorage(), self.getStringSize()); - PBytesIOBuffer buf = factory.createBytesIOBuf(PBytesIOBuf, self); + PBytesIOBuffer buf = PFactory.createBytesIOBuf(language, self); return memoryViewNode.execute(frame, buf); } } @@ -614,12 +614,12 @@ static Object doit(VirtualFrame frame, PBytesIO self, abstract static class GetValueNode extends ClosedCheckPythonUnaryBuiltinNode { @Specialization(guards = "self.hasBuf()") static Object doCopy(PBytesIO self, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) { if (bufferLib.hasInternalByteArray(self.getBuf()) && self.getExports() == 0) { self.markEscaped(); } - return factory.createBytes(bufferLib.getInternalOrCopiedByteArray(self.getBuf()), self.getStringSize()); + return PFactory.createBytes(language, bufferLib.getInternalOrCopiedByteArray(self.getBuf()), self.getStringSize()); } } @@ -629,12 +629,12 @@ abstract static class GetStateNode extends ClosedCheckPythonUnaryBuiltinNode { @Specialization(guards = "self.hasBuf()") static Object doit(VirtualFrame frame, PBytesIO self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetValueNode getValueNode, - @Cached GetOrCreateDictNode getDict, - @Cached PythonObjectFactory factory) { + @Cached GetOrCreateDictNode getDict) { Object initValue = getValueNode.execute(frame, self); Object[] state = new Object[]{initValue, self.getPos(), getDict.execute(inliningTarget, self)}; - return factory.createTuple(state); + return PFactory.createTuple(language, state); } } @@ -775,14 +775,14 @@ abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode { @Specialization(guards = "self.hasBuf()") static Object doit(PBytesIO self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { int n = scanEOL(self, -1, bufferLib); if (n == 0) { throw raiseNode.get(inliningTarget).raiseStopIteration(); } - return readBytes(self, n, bufferLib, factory); + return readBytes(self, n, bufferLib, language); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java index 08cb8802bc..85aa552c4b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java @@ -106,6 +106,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -152,7 +153,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -311,7 +312,8 @@ public static void internalInit(PFileIO self, TruffleString name, int fd, IOMode @Specialization(guards = {"!isBadMode(mode)", "!isInvalidMode(mode)"}) static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object nameobj, IONodes.IOMode mode, boolean closefd, Object opener, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached(inline = false) CallNode callOpener, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, @@ -350,10 +352,9 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object try { boolean fdIsOwn = false; - PythonContext ctxt = PythonContext.get(inliningTarget); if (fd >= 0) { self.setCloseFD(closefd); - self.setFD(fd, ctxt); + self.setFD(fd, context); } else { self.setCloseFD(true); if (errorProfile.profile(inliningTarget, !closefd)) { @@ -361,14 +362,14 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object } if (opener instanceof PNone) { - self.setFD(open(frame, name, flags, 0666, ctxt, inliningTarget, posixLib, gil, exceptionProfile, raiseNode, constructAndRaiseNode), ctxt); + self.setFD(open(frame, name, flags, 0666, context, inliningTarget, posixLib, gil, exceptionProfile, raiseNode, constructAndRaiseNode), context); } else { Object fdobj = callOpener.execute(frame, opener, nameobj, flags); if (!indexCheckNode.execute(inliningTarget, fdobj)) { throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_INT_FROM_OPENER); } - self.setFD(asSizeNode.executeExact(frame, inliningTarget, fdobj), ctxt); + self.setFD(asSizeNode.executeExact(frame, inliningTarget, fdobj), context); if (self.getFD() < 0) { /* * The opener returned a negative but didn't set an exception. See issue @@ -378,7 +379,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object } } try { - posixLib.setInheritable(ctxt.getPosixSupport(), self.getFD(), false); + posixLib.setInheritable(context.getPosixSupport(), self.getFD(), false); } catch (PosixException e) { exceptionProfile1.enter(inliningTarget); throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -390,7 +391,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object long[] fstatResult; gil.release(true); try { - fstatResult = posixLib.fstat(ctxt.getPosixSupport(), self.getFD()); + fstatResult = posixLib.fstat(context.getPosixSupport(), self.getFD()); } finally { gil.acquire(); } @@ -428,7 +429,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object try { gil.release(true); try { - long res = posixLib.lseek(ctxt.getPosixSupport(), self.getFD(), 0, mapPythonSeekWhenceToPosix(SEEK_END)); + long res = posixLib.lseek(context.getPosixSupport(), self.getFD(), 0, mapPythonSeekWhenceToPosix(SEEK_END)); self.setSeekable(res >= 0 ? 1 : 0); } finally { gil.acquire(); @@ -513,22 +514,21 @@ static Object readall(VirtualFrame frame, PFileIO self, @SuppressWarnings("unuse @Specialization(guards = {"!self.isClosed()", "self.isReadable()", "size == 0"}) static Object none(@SuppressWarnings("unused") PFileIO self, @SuppressWarnings("unused") int size, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEmptyBytes(); + @Bind PythonLanguage language) { + return PFactory.createEmptyBytes(language); } @Specialization(guards = {"!self.isClosed()", "self.isReadable()", "size >= 0"}) static Object read(VirtualFrame frame, PFileIO self, int size, @Bind("this") Node inliningTarget, - @Cached PosixModuleBuiltins.ReadNode posixRead, @Cached InlinedBranchProfile readErrorProfile, @Cached InlinedBranchProfile readErrorProfile2, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - return posixRead.read(self.getFD(), size, inliningTarget, posixLib, readErrorProfile, gil, factory); + return PosixModuleBuiltins.ReadNode.read(self.getFD(), size, inliningTarget, posixLib, context.getPosixSupport(), readErrorProfile, gil); } catch (PosixException e) { if (e.getErrorCode() == EAGAIN.getNumber()) { readErrorProfile2.enter(inliningTarget); @@ -558,14 +558,13 @@ abstract static class ReadallNode extends PythonUnaryBuiltinNode { @Specialization(guards = "!self.isClosed()") static Object readall(VirtualFrame frame, PFileIO self, @Bind("this") Node inliningTarget, - @Cached PosixModuleBuiltins.ReadNode posixRead, @Cached InlinedBranchProfile readErrorProfile, @Cached SequenceStorageNodes.GetInternalByteArrayNode getBytes, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile multipleReadsProfile, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { int bufsize = SMALLCHUNK; boolean mayBeQuick = false; @@ -591,7 +590,7 @@ static Object readall(VirtualFrame frame, PFileIO self, int bytesRead = 0; PBytes b; try { - b = posixRead.read(self.getFD(), bufsize, inliningTarget, posixLib, readErrorProfile, gil, factory); + b = PosixModuleBuiltins.ReadNode.read(self.getFD(), bufsize, inliningTarget, posixLib, context.getPosixSupport(), readErrorProfile, gil); bytesRead = b.getSequenceStorage().length(); if (bytesRead == 0 || (mayBeQuick && bytesRead == bufsize - 1)) { return b; @@ -619,7 +618,7 @@ static Object readall(VirtualFrame frame, PFileIO self, int n; try { - b = posixRead.read(self.getFD(), bufsize - bytesRead, inliningTarget, posixLib, readErrorProfile, gil, factory); + b = PosixModuleBuiltins.ReadNode.read(self.getFD(), bufsize - bytesRead, inliningTarget, posixLib, context.getPosixSupport(), readErrorProfile, gil); /* * PosixModuleBuiltins#ReadNode creates PBytes with exact size; */ @@ -642,7 +641,7 @@ static Object readall(VirtualFrame frame, PFileIO self, bytesRead += n; } - return factory.createBytes(toByteArray(result)); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), toByteArray(result)); } @Specialization(guards = "self.isClosed()") @@ -662,19 +661,18 @@ static Object readinto(VirtualFrame frame, PFileIO self, Object buffer, @Bind("this") Node inliningTarget, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PosixModuleBuiltins.ReadNode posixRead, @Cached InlinedBranchProfile readErrorProfile, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { int size = bufferLib.getBufferLength(buffer); if (size == 0) { return 0; } try { - PBytes data = posixRead.read(self.getFD(), size, inliningTarget, posixLib, readErrorProfile, gil, factory); + PBytes data = PosixModuleBuiltins.ReadNode.read(self.getFD(), size, inliningTarget, posixLib, context.getPosixSupport(), readErrorProfile, gil); int n = bufferLib.getBufferLength(data); bufferLib.readIntoBuffer(data, 0, buffer, 0, n, bufferLib); return n; @@ -717,8 +715,9 @@ public abstract static class WriteNode extends PythonBinaryClinicBuiltinNode { @Specialization(limit = "3") static Object write(VirtualFrame frame, PFileIO self, Object buffer, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedBranchProfile errorProfile, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @@ -732,7 +731,7 @@ static Object write(VirtualFrame frame, PFileIO self, Object buffer, } try { return PosixModuleBuiltins.WriteNode.write(self.getFD(), bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), - inliningTarget, posixLib, errorProfile, gil); + inliningTarget, posixLib, context.getPosixSupport(), errorProfile, gil); } catch (PosixException e) { if (e.getErrorCode() == EAGAIN.getNumber()) { return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java index c6fe4327e0..6535c80d7d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java @@ -87,6 +87,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -118,7 +119,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.IsNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ArrayBuilder; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; @@ -480,13 +481,13 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PBytes readline(VirtualFrame frame, Object self, int limit, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyObjectLookupAttr lookupPeek, @Cached CallNode callPeek, @Cached PyObjectCallMethodObjArgs callRead, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached InlinedConditionProfile hasPeek, @Cached InlinedConditionProfile isBytes, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { /* For backwards compatibility, a (slowish) readline(). */ Object peek = lookupPeek.execute(frame, inliningTarget, self, T_PEEK); @@ -528,7 +529,7 @@ static PBytes readline(VirtualFrame frame, Object self, int limit, } } - return factory.createBytes(toByteArray(buffer)); + return PFactory.createBytes(language, toByteArray(buffer)); } } @@ -544,12 +545,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object withHint(VirtualFrame frame, Object self, int hintIn, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetNextNode next, @Cached InlinedConditionProfile isNegativeHintProfile, @Cached IsBuiltinObjectProfile errorProfile, @Cached PyObjectGetIter getIter, - @Cached PyObjectSizeNode sizeNode, - @Cached PythonObjectFactory factory) { + @Cached PyObjectSizeNode sizeNode) { int hint = isNegativeHintProfile.profile(inliningTarget, hintIn <= 0) ? Integer.MAX_VALUE : hintIn; int length = 0; Object iterator = getIter.execute(frame, inliningTarget, self); @@ -568,7 +569,7 @@ static Object withHint(VirtualFrame frame, Object self, int hintIn, break; } } - return factory.createList(list.toArray(new Object[0])); + return PFactory.createList(language, list.toArray(new Object[0])); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java index 6cc698da4d..9a7709f4fd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -75,6 +75,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -88,6 +89,7 @@ import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectSetAttr; import com.oracle.graal.python.nodes.ErrorMessages; @@ -103,7 +105,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -154,8 +156,9 @@ public void initialize(Python3Core core) { public abstract static class IOBaseNode extends PythonBuiltinNode { @Specialization static PythonObject doGeneric(Object cls, - @Cached PythonObjectFactory factory) { - return factory.createPythonObject(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createPythonObject(language, cls, getInstanceShape.execute(cls)); } } @@ -164,9 +167,10 @@ static PythonObject doGeneric(Object cls, public abstract static class FileIONode extends PythonBuiltinNode { @Specialization static PFileIO doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see FileIOBuiltins.InitNode - return factory.createFileIO(cls); + return PFactory.createFileIO(language, cls, getInstanceShape.execute(cls)); } } @@ -175,9 +179,10 @@ static PFileIO doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class BufferedReaderNode extends PythonBuiltinNode { @Specialization static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BufferedReaderBuiltins.InitNode - return factory.createBufferedReader(cls); + return PFactory.createBufferedReader(language, cls, getInstanceShape.execute(cls)); } } @@ -186,9 +191,10 @@ static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class BufferedWriterNode extends PythonBuiltinNode { @Specialization static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BufferedWriterBuiltins.InitNode - return factory.createBufferedWriter(cls); + return PFactory.createBufferedWriter(language, cls, getInstanceShape.execute(cls)); } } @@ -197,9 +203,10 @@ static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class BufferedRWPairNode extends PythonBuiltinNode { @Specialization static PRWPair doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BufferedRWPairBuiltins.InitNode - return factory.createRWPair(cls); + return PFactory.createRWPair(language, cls, getInstanceShape.execute(cls)); } } @@ -208,9 +215,10 @@ static PRWPair doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class BufferedRandomNode extends PythonBuiltinNode { @Specialization static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BufferedRandomBuiltins.InitNode - return factory.createBufferedRandom(cls); + return PFactory.createBufferedRandom(language, cls, getInstanceShape.execute(cls)); } } @@ -219,9 +227,10 @@ static PBuffered doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class TextIOWrapperNode extends PythonBuiltinNode { @Specialization static PTextIO doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see TextIOWrapperBuiltins.InitNode - return factory.createTextIO(cls); + return PFactory.createTextIO(language, cls, getInstanceShape.execute(cls)); } } @@ -230,10 +239,11 @@ static PTextIO doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class BytesIONode extends PythonBuiltinNode { @Specialization static PBytesIO doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see BytesIONodeBuiltins.InitNode - PBytesIO bytesIO = factory.createBytesIO(cls); - bytesIO.setBuf(factory.createByteArray(PythonUtils.EMPTY_BYTE_ARRAY)); + PBytesIO bytesIO = PFactory.createBytesIO(language, cls, getInstanceShape.execute(cls)); + bytesIO.setBuf(PFactory.createByteArray(language, PythonUtils.EMPTY_BYTE_ARRAY)); return bytesIO; } } @@ -243,9 +253,10 @@ static PBytesIO doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class StringIONode extends PythonBuiltinNode { @Specialization static PStringIO doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see StringIONodeBuiltins.InitNode - return factory.createStringIO(cls); + return PFactory.createStringIO(language, cls, getInstanceShape.execute(cls)); } } @@ -254,19 +265,19 @@ static PStringIO doNew(Object cls, @SuppressWarnings("unused") Object arg, public abstract static class IncrementalNewlineDecoderNode extends PythonBuiltinNode { @Specialization static PNLDecoder doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see // IncrementalNewlineDecoderBuiltins.InitNode - return factory.createNLDecoder(cls); + return PFactory.createNLDecoder(language, cls, getInstanceShape.execute(cls)); } } private static PFileIO createFileIO(VirtualFrame frame, Node inliningTarget, Object file, IONodes.IOMode mode, boolean closefd, Object opener, - PythonObjectFactory factory, FileIOBuiltins.FileIOInit initFileIO) { /* Create the Raw file stream */ mode.text = mode.universal = false; // FileIO doesn't recognize those. - PFileIO fileIO = factory.createFileIO(PythonBuiltinClassType.PFileIO); + PFileIO fileIO = PFactory.createFileIO(PythonLanguage.get(inliningTarget)); initFileIO.execute(frame, inliningTarget, fileIO, file, mode, closefd, opener); return fileIO; } @@ -285,9 +296,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PFileIO openCode(VirtualFrame frame, TruffleString path, @Bind("this") Node inliningTarget, - @Cached FileIOBuiltins.FileIOInit initFileIO, - @Cached PythonObjectFactory factory) { - return createFileIO(frame, inliningTarget, path, IOMode.RB, true, PNone.NONE, factory, initFileIO); + @Cached FileIOBuiltins.FileIOInit initFileIO) { + return createFileIO(frame, inliningTarget, path, IOMode.RB, true, PNone.NONE, initFileIO); } } @@ -319,9 +329,9 @@ protected static Object openText(VirtualFrame frame, Object file, IONodes.IOMode @Cached PyObjectSetAttr setAttrNode, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, factory, initFileIO); + PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, initFileIO); Object result = fileIO; try { /* buffering */ @@ -359,11 +369,11 @@ protected static Object openText(VirtualFrame frame, Object file, IONodes.IOMode /* wraps into a buffered file */ - PBuffered buffer = createBufferedIO.execute(frame, inliningTarget, fileIO, buffering, factory, mode); + PBuffered buffer = createBufferedIO.execute(frame, inliningTarget, fileIO, buffering, mode); result = buffer; /* wraps into a TextIOWrapper */ - PTextIO wrapper = factory.createTextIO(PTextIOWrapper); + PTextIO wrapper = PFactory.createTextIO(language); initTextIO.execute(frame, inliningTarget, wrapper, buffer, encoding, errors == PNone.NONE ? T_STRICT : (TruffleString) errors, newline, line_buffering, false); @@ -385,9 +395,8 @@ protected static PFileIO openBinaryNoBuf(VirtualFrame frame, Object file, IONode @SuppressWarnings("unused") PNone newline, boolean closefd, Object opener, @Bind("this") Node inliningTarget, - @Exclusive @Cached FileIOBuiltins.FileIOInit initFileIO, - @Shared @Cached PythonObjectFactory factory) { - return createFileIO(frame, inliningTarget, file, mode, closefd, opener, factory, initFileIO); + @Exclusive @Cached FileIOBuiltins.FileIOInit initFileIO) { + return createFileIO(frame, inliningTarget, file, mode, closefd, opener, initFileIO); } @Specialization(guards = {"!isXRWA(mode)", "!isUnknown(mode)", "!isTB(mode)", "isValidUniveral(mode)", "isBinary(mode)", "bufferingValue == 1"}) @@ -402,10 +411,9 @@ protected static Object openBinaryB1(VirtualFrame frame, Object file, IONodes.IO @Exclusive @Cached IONodes.CreateBufferedIONode createBufferedIO, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { warnNode.warnEx(frame, RuntimeWarning, LINE_BUFFERING_ISNT_SUPPORTED, 1); - return openBinary(frame, file, mode, bufferingValue, encoding, errors, newline, closefd, opener, inliningTarget, initFileIO, createBufferedIO, posixLib, callClose, factory, raiseNode); + return openBinary(frame, file, mode, bufferingValue, encoding, errors, newline, closefd, opener, inliningTarget, initFileIO, createBufferedIO, posixLib, callClose, raiseNode); } @Specialization(guards = {"!isXRWA(mode)", "!isUnknown(mode)", "!isTB(mode)", "isValidUniveral(mode)", "isBinary(mode)", "bufferingValue != 1", "bufferingValue != 0"}) @@ -419,9 +427,8 @@ protected static Object openBinary(VirtualFrame frame, Object file, IONodes.IOMo @Exclusive @Cached IONodes.CreateBufferedIONode createBufferedIO, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, factory, initFileIO); + PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, initFileIO); try { /* buffering */ boolean isatty = false; @@ -455,7 +462,7 @@ protected static Object openBinary(VirtualFrame frame, Object file, IONodes.IOMo /* wraps into a buffered file */ /* if binary, returns the buffered file */ - return createBufferedIO.execute(frame, inliningTarget, fileIO, buffering, factory, mode); + return createBufferedIO.execute(frame, inliningTarget, fileIO, buffering, mode); } catch (PException e) { callClose.execute(frame, inliningTarget, fileIO, T_CLOSE); throw e; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java index 717ce49df3..57b90112fd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,9 +41,6 @@ package com.oracle.graal.python.builtins.modules.io; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.DeprecationWarning; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedRandom; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedReader; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PBufferedWriter; import static com.oracle.graal.python.nodes.ErrorMessages.EMBEDDED_NULL_CHARACTER; import static com.oracle.graal.python.nodes.ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P; import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_MODE_S; @@ -53,6 +50,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ClinicConverterFactory; import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins; import com.oracle.graal.python.builtins.objects.PNone; @@ -67,7 +65,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -467,7 +465,7 @@ public static CastOpenNameNode create() { @GenerateCached(false) @GenerateInline public abstract static class CreateBufferedIONode extends Node { - public abstract PBuffered execute(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, PythonObjectFactory factory, IONodes.IOMode mode); + public abstract PBuffered execute(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, IONodes.IOMode mode); protected static boolean isRandom(IONodes.IOMode mode) { return mode.updating; @@ -482,26 +480,29 @@ protected static boolean isReading(IONodes.IOMode mode) { } @Specialization(guards = "isRandom(mode)") - static PBuffered createRandom(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, PythonObjectFactory factory, @SuppressWarnings("unused") IONodes.IOMode mode, - @Cached BufferedRandomBuiltins.BufferedRandomInit initBuffered) { - PBuffered buffer = factory.createBufferedRandom(PBufferedRandom); - initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering, factory); + static PBuffered createRandom(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, @SuppressWarnings("unused") IONodes.IOMode mode, + @Cached BufferedRandomBuiltins.BufferedRandomInit initBuffered, + @Bind PythonLanguage language) { + PBuffered buffer = PFactory.createBufferedRandom(language); + initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering); return buffer; } @Specialization(guards = {"!isRandom(mode)", "isWriting(mode)"}) - static PBuffered createWriter(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, PythonObjectFactory factory, @SuppressWarnings("unused") IONodes.IOMode mode, - @Cached BufferedWriterBuiltins.BufferedWriterInit initBuffered) { - PBuffered buffer = factory.createBufferedWriter(PBufferedWriter); - initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering, factory); + static PBuffered createWriter(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, @SuppressWarnings("unused") IONodes.IOMode mode, + @Cached BufferedWriterBuiltins.BufferedWriterInit initBuffered, + @Bind PythonLanguage language) { + PBuffered buffer = PFactory.createBufferedWriter(language); + initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering); return buffer; } @Specialization(guards = {"!isRandom(mode)", "!isWriting(mode)", "isReading(mode)"}) - static PBuffered createWriter(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, PythonObjectFactory factory, @SuppressWarnings("unused") IONodes.IOMode mode, - @Cached BufferedReaderBuiltins.BufferedReaderInit initBuffered) { - PBuffered buffer = factory.createBufferedReader(PBufferedReader); - initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering, factory); + static PBuffered createWriter(VirtualFrame frame, Node inliningTarget, PFileIO fileIO, int buffering, @SuppressWarnings("unused") IONodes.IOMode mode, + @Cached BufferedReaderBuiltins.BufferedReaderInit initBuffered, + @Bind PythonLanguage language) { + PBuffered buffer = PFactory.createBufferedReader(language); + initBuffered.execute(frame, inliningTarget, buffer, fileIO, buffering); return buffer; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java index 02f0006ced..0010e47da7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -62,6 +62,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -82,11 +83,10 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -284,20 +284,20 @@ abstract static class GetStateNode extends PythonUnaryBuiltinNode { @Specialization(guards = "!self.hasDecoder()") static Object noDecoder(PNLDecoder self, - @Shared @Cached PythonObjectFactory factory) { - PBytes buffer = factory.createEmptyBytes(); + @Bind PythonLanguage language) { + PBytes buffer = PFactory.createEmptyBytes(language); int flag = self.isPendingCR() ? 1 : 0; - return factory.createTuple(new Object[]{buffer, flag}); + return PFactory.createTuple(language, new Object[]{buffer, flag}); } @Specialization(guards = "self.hasDecoder()") static Object withDecoder(VirtualFrame frame, PNLDecoder self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, @Cached PyObjectCallMethodObjArgs callMethod, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { Object state = callMethod.execute(frame, inliningTarget, self.getDecoder(), T_GETSTATE); if (!(state instanceof PTuple)) { @@ -312,7 +312,7 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, if (self.isPendingCR()) { flag |= 1; } - return factory.createTuple(new Object[]{objects[0], flag}); + return PFactory.createTuple(language, new Object[]{objects[0], flag}); } } @@ -339,11 +339,11 @@ static Object noDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, @Specialization(guards = "self.hasDecoder()") static Object withDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @Exclusive @Cached PyIndexCheckNode indexCheckNode, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object[] objects = getObjectArrayNode.execute(inliningTarget, state); if (objects.length != 2 || !indexCheckNode.execute(inliningTarget, objects[1])) { @@ -352,7 +352,7 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, int flag = asSizeNode.executeExact(frame, inliningTarget, objects[1]); self.setPendingCR((flag & 1) != 0); flag >>= 1; - PTuple tuple = factory.createTuple(new Object[]{objects[0], flag}); + PTuple tuple = PFactory.createTuple(language, new Object[]{objects[0], flag}); return callMethod.execute(frame, inliningTarget, self.getDecoder(), T_SETSTATE, tuple); } @@ -388,7 +388,7 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, abstract static class NewlineNode extends PythonBuiltinNode { @Specialization static Object newline(PNLDecoder self, - @Cached PythonObjectFactory factory) { + @Bind("this") Node inliningTarget) { switch (self.getSeenNewline()) { case SEEN_CR: return T_CR; @@ -397,13 +397,13 @@ static Object newline(PNLDecoder self, case SEEN_CRLF: return T_CRLF; case SEEN_CR | SEEN_LF: - return factory.createTuple(new Object[]{T_CR, T_NEWLINE}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{T_CR, T_NEWLINE}); case SEEN_CR | SEEN_CRLF: - return factory.createTuple(new Object[]{T_CR, T_CRLF}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{T_CR, T_CRLF}); case SEEN_LF | SEEN_CRLF: - return factory.createTuple(new Object[]{T_NEWLINE, T_CRLF}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{T_NEWLINE, T_CRLF}); case SEEN_CR | SEEN_LF | SEEN_CRLF: - return factory.createTuple(new Object[]{T_CR, T_NEWLINE, T_CRLF}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{T_CR, T_NEWLINE, T_CRLF}); default: return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java index b0efce23a8..9b5a9a650f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,13 +42,14 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.BufferError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; import com.oracle.graal.python.builtins.objects.bytes.PByteArray; import com.oracle.graal.python.builtins.objects.memoryview.BufferLifecycleManager; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; @@ -120,14 +121,14 @@ public void markEscaped() { * it without copying the first time the program asks for the whole contents. So that a sequence * of writes followed by one getvalue call doesn't have to copy the whole buffer at the end. */ - public void unshareIfNecessary(PythonBufferAccessLibrary bufferLib, PythonObjectFactory factory) { + public void unshareIfNecessary(PythonBufferAccessLibrary bufferLib, PythonLanguage language) { if (escaped || getExports() != 0) { - buf = factory.createByteArray(bufferLib.getCopiedByteArray(buf)); + buf = PFactory.createByteArray(language, bufferLib.getCopiedByteArray(buf)); escaped = false; } } - public void unshareAndResize(PythonBufferAccessLibrary bufferLib, PythonObjectFactory factory, int size, boolean truncate) { + public void unshareAndResize(PythonBufferAccessLibrary bufferLib, PythonLanguage language, int size, boolean truncate) { int origLength = bufferLib.getBufferLength(getBuf()); int alloc; if (truncate && size < origLength / 2) { @@ -135,7 +136,7 @@ public void unshareAndResize(PythonBufferAccessLibrary bufferLib, PythonObjectFa alloc = size; } else if (size < origLength) { /* Within allocated size; quick exit */ - unshareIfNecessary(bufferLib, factory); + unshareIfNecessary(bufferLib, language); return; } else if (size <= origLength * 1.125) { /* Moderate upsize; overallocate similar to list_resize() */ @@ -150,7 +151,7 @@ public void unshareAndResize(PythonBufferAccessLibrary bufferLib, PythonObjectFa } byte[] newBuf = new byte[alloc]; bufferLib.readIntoByteArray(getBuf(), 0, newBuf, 0, Math.min(stringSize, size)); - setBuf(factory.createByteArray(newBuf)); + setBuf(PFactory.createByteArray(language, newBuf)); escaped = false; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java index 58547e96d5..ee5e07aa9f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -59,6 +59,7 @@ import java.io.ByteArrayOutputStream; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -121,24 +122,24 @@ static Object readall(VirtualFrame frame, Object self, @SuppressWarnings("unused @Specialization(guards = "size >= 0") static Object read(VirtualFrame frame, Object self, int size, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached BytesNodes.ToBytesNode toBytes, @Exclusive @Cached PyObjectCallMethodObjArgs callMethodReadInto, - @Cached PyNumberAsSizeNode asSizeNode, - @Cached PythonObjectFactory factory) { - PByteArray b = factory.createByteArray(new byte[size]); + @Cached PyNumberAsSizeNode asSizeNode) { + PByteArray b = PFactory.createByteArray(language, new byte[size]); Object res = callMethodReadInto.execute(frame, inliningTarget, self, T_READINTO, b); if (res == PNone.NONE) { return res; } int n = asSizeNode.executeExact(frame, inliningTarget, res, ValueError); if (n == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } byte[] bytes = toBytes.execute(b); if (n < size) { - return factory.createBytes(PythonUtils.arrayCopyOf(bytes, n)); + return PFactory.createBytes(language, PythonUtils.arrayCopyOf(bytes, n)); } - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } } @@ -157,7 +158,6 @@ static Object readall(VirtualFrame frame, Object self, @Cached InlinedConditionProfile chunksSize0Profile, @Cached InlinedCountingConditionProfile bytesLen0Profile, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { ByteArrayOutputStream chunks = createOutputStream(); while (true) { @@ -180,7 +180,7 @@ static Object readall(VirtualFrame frame, Object self, append(chunks, bytes, bytesLen); } - return factory.createBytes(toByteArray(chunks)); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), toByteArray(chunks)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java index b3be129689..1f0ef51ac2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -40,7 +40,6 @@ */ package com.oracle.graal.python.builtins.modules.io; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PIncrementalNewlineDecoder; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_CUR; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_END; import static com.oracle.graal.python.builtins.modules.io.BufferedIOUtil.SEEK_SET; @@ -87,6 +86,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -117,7 +117,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; @@ -283,7 +283,7 @@ static PNone init(VirtualFrame frame, PStringIO self, TruffleString initialValue @Cached TruffleStringBuilder.ToStringNode toStringNode, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached IONodes.ToTruffleStringNode toTruffleStringNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { TruffleString newline; @@ -317,7 +317,7 @@ static PNone init(VirtualFrame frame, PStringIO self, TruffleString initialValue } if (self.isReadUniversal()) { - Object incDecoder = factory.createNLDecoder(PIncrementalNewlineDecoder); + Object incDecoder = PFactory.createNLDecoder(language); initNode.execute(frame, incDecoder, self.getDecoder(), self.isReadTranslate(), PNone.NO_VALUE); self.setDecoder(incDecoder); } @@ -632,11 +632,11 @@ static Object doit(VirtualFrame frame, PStringIO self, @Bind("this") Node inliningTarget, @Cached GetValueNode getValueNode, @Cached GetOrCreateDictNode getDict, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object initValue = getValueNode.execute(frame, self); Object readnl = self.getReadNewline() == null ? PNone.NONE : self.getReadNewline(); Object[] state = new Object[]{initValue, readnl, self.getPos(), getDict.execute(inliningTarget, self)}; - return factory.createTuple(state); + return PFactory.createTuple(language, state); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java index 9961cdefa9..2374247068 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java @@ -129,6 +129,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -166,7 +167,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; @@ -678,7 +679,6 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { checkClosedNode.execute(frame, self); if (!self.isSeekable()) { @@ -758,7 +758,7 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, self.clearSnapshot(); /* Restore the decoder to its state from the safe start point. */ - decoderSetStateNode.execute(frame, inliningTarget, self, cookie, factory); + decoderSetStateNode.execute(frame, inliningTarget, self, cookie); if (cookie.charsToSkip != 0) { /* Just like _read_chunk, feed the decoder and save a snapshot. */ @@ -892,6 +892,7 @@ static Object didntMove(VirtualFrame frame, PTextIO self, }) static Object tell(VirtualFrame frame, PTextIO self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached TextIOWrapperNodes.WriteFlushNode writeFlushNode, @Cached TextIOWrapperNodes.DecoderSetStateNode decoderSetStateNode, @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @@ -906,7 +907,6 @@ static Object tell(VirtualFrame frame, PTextIO self, @Exclusive @Cached PyLongAsLongNode asLongNode, @Cached PyObjectSizeNode sizeNode, @CachedLibrary(limit = "2") InteropLibrary isString, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { PTextIO.CookieType cookie = getCookie(frame, inliningTarget, self, writeFlushNode, callMethodFlush, callMethodTell, asLongNode); byte[] snapshotNextInput = self.getSnapshotNextInput(); @@ -921,8 +921,8 @@ static Object tell(VirtualFrame frame, PTextIO self, assert (skipBack <= nextInputLength); while (skipBytes > 0) { /* Decode up to temptative start point */ - decoderSetStateNode.execute(frame, inliningTarget, self, cookie, factory); - PBytes in = factory.createBytes(snapshotNextInput, skipBytes); + decoderSetStateNode.execute(frame, inliningTarget, self, cookie); + PBytes in = PFactory.createBytes(language, snapshotNextInput, skipBytes); int charsDecoded = decoderDecode(frame, inliningTarget, self, in, callMethodDecode, toString, codePointLengthNode); if (charsDecoded <= decodedCharsUsed) { Object[] state = decoderGetstate(frame, inliningTarget, self, savedState, getObjectArrayNode, callMethodGetState, callMethodSetState, raiseNode); @@ -945,7 +945,7 @@ static Object tell(VirtualFrame frame, PTextIO self, } if (skipBytes <= 0) { skipBytes = 0; - decoderSetStateNode.execute(frame, inliningTarget, self, cookie, factory); + decoderSetStateNode.execute(frame, inliningTarget, self, cookie); } /* Note our initial start point. */ @@ -962,7 +962,7 @@ static Object tell(VirtualFrame frame, PTextIO self, int charsDecoded = 0; byte[] input = PythonUtils.arrayCopyOfRange(snapshotNextInput, skipBytes, nextInputLength); while (input.length > 0) { - PBytes start = factory.createBytes(input, 1); + PBytes start = PFactory.createBytes(language, input, 1); int n = decoderDecode(frame, inliningTarget, self, start, callMethodDecode, toString, codePointLengthNode); /* We got n chars for 1 byte */ charsDecoded += n; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java index 9d0e636a58..a614ee75ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java @@ -42,7 +42,6 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.EncodingWarning; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.IOUnsupportedOperation; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.PIncrementalNewlineDecoder; import static com.oracle.graal.python.builtins.modules.CodecsTruffleModuleBuiltins.T_INCREMENTALDECODER; import static com.oracle.graal.python.builtins.modules.CodecsTruffleModuleBuiltins.T_INCREMENTALENCODER; import static com.oracle.graal.python.builtins.modules.io.IONodes.T_CLOSED; @@ -77,6 +76,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.CodecsTruffleModuleBuiltins; import com.oracle.graal.python.builtins.modules.CodecsTruffleModuleBuiltins.MakeIncrementalcodecNode; import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins; @@ -100,7 +100,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -199,10 +199,10 @@ static void nothingTodo(@SuppressWarnings("unused") PTextIO self) { @Specialization(guards = "self.hasPendingBytes()") static void writeflush(VirtualFrame frame, Node inliningTarget, PTextIO self, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PyObjectCallMethodObjArgs callMethod) { byte[] pending = self.getAndClearPendingBytes(); - PBytes b = factory.createBytes(pending); + PBytes b = PFactory.createBytes(language, pending); callMethod.execute(frame, inliningTarget, self.getBuffer(), T_WRITE, b); // TODO: check _PyIO_trap_eintr } @@ -631,10 +631,10 @@ static TruffleString decodeGeneric(VirtualFrame frame, Object decoder, Object o, @GenerateCached(false) protected abstract static class DecoderSetStateNode extends Node { - public abstract void execute(VirtualFrame frame, Node inliningTarget, PTextIO self, PTextIO.CookieType cookie, PythonObjectFactory factory); + public abstract void execute(VirtualFrame frame, Node inliningTarget, PTextIO self, PTextIO.CookieType cookie); @Specialization(guards = "!self.hasDecoder()") - static void nothing(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") PTextIO.CookieType cookie, @SuppressWarnings("unused") PythonObjectFactory factory) { + static void nothing(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") PTextIO.CookieType cookie) { // nothing to do. } @@ -650,15 +650,16 @@ protected static boolean isAtInit(PTextIO.CookieType cookie) { } @Specialization(guards = {"self.hasDecoder()", "isAtInit(cookie)"}) - static void atInit(VirtualFrame frame, Node inliningTarget, PTextIO self, @SuppressWarnings("unused") PTextIO.CookieType cookie, @SuppressWarnings("unused") PythonObjectFactory factory, + static void atInit(VirtualFrame frame, Node inliningTarget, PTextIO self, @SuppressWarnings("unused") PTextIO.CookieType cookie, @Exclusive @Cached PyObjectCallMethodObjArgs callMethodReset) { callMethodReset.execute(frame, inliningTarget, self.getDecoder(), T_RESET); } @Specialization(guards = {"self.hasDecoder()", "!isAtInit(cookie)"}) - static void decoderSetstate(VirtualFrame frame, Node inliningTarget, PTextIO self, PTextIO.CookieType cookie, PythonObjectFactory factory, + static void decoderSetstate(VirtualFrame frame, Node inliningTarget, PTextIO self, PTextIO.CookieType cookie, + @Bind PythonLanguage language, @Exclusive @Cached PyObjectCallMethodObjArgs callMethodSetState) { - PTuple tuple = factory.createTuple(new Object[]{factory.createEmptyBytes(), cookie.decFlags}); + PTuple tuple = PFactory.createTuple(language, new Object[]{PFactory.createEmptyBytes(language), cookie.decFlags}); callMethodSetState.execute(frame, inliningTarget, self.getDecoder(), T_SETSTATE, tuple); } @@ -747,15 +748,14 @@ static void setDecoder(VirtualFrame frame, Node inliningTarget, PTextIO self, Ob @Cached(inline = false) MakeIncrementalcodecNode makeIncrementalcodecNode, @Cached InlinedConditionProfile isTrueProfile, @Cached PyObjectCallMethodObjArgs callMethodReadable, - @Cached PyObjectIsTrueNode isTrueNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached PyObjectIsTrueNode isTrueNode) { Object res = callMethodReadable.execute(frame, inliningTarget, self.getBuffer(), T_READABLE); if (isTrueProfile.profile(inliningTarget, !isTrueNode.execute(frame, res))) { return; } Object decoder = makeIncrementalcodecNode.execute(frame, codecInfo, errors, T_INCREMENTALDECODER); if (self.isReadUniversal()) { - PNLDecoder incDecoder = factory.createNLDecoder(PIncrementalNewlineDecoder); + PNLDecoder incDecoder = PFactory.createNLDecoder(PythonLanguage.get(inliningTarget)); IncrementalNewlineDecoderBuiltins.InitNode.internalInit(incDecoder, decoder, self.isReadTranslate()); self.setDecoder(incDecoder); } else { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java index 5aa6922398..59cc6e6a1d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -21,6 +21,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -62,12 +63,12 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.formatting.FloatFormatter; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -108,8 +109,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization protected PTuple call(PJSONEncoder self, Object obj, @SuppressWarnings("unused") int indent, - @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{jsonEncode(self, obj)}); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, new Object[]{jsonEncode(self, obj)}); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java index 7a24558a6f..2de099ac51 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java @@ -12,6 +12,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -25,6 +26,7 @@ import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToJavaStringCheckedNode; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -36,7 +38,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -94,11 +96,11 @@ protected ArgumentClinicProvider getArgumentClinic() { Object call(Object string, int end, boolean strict, @Bind("this") Node inliningTarget, @Cached CastToJavaStringCheckedNode castString, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { IntRef nextIdx = new IntRef(); TruffleString result = JSONScannerBuiltins.scanStringUnicode(castString.cast(inliningTarget, string, ErrorMessages.FIRST_ARG_MUST_BE_STRING_NOT_P, string), end, strict, nextIdx, this); - return factory.createTuple(new Object[]{result, nextIdx.value}); + return PFactory.createTuple(language, new Object[]{result, nextIdx.value}); } } @@ -189,7 +191,8 @@ public abstract static class MakeScanner extends PythonBinaryBuiltinNode { @Specialization public PJSONScanner doNew(VirtualFrame frame, Object cls, Object context, @Cached PyObjectIsTrueNode castStrict, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { boolean strict = castStrict.execute(frame, getStrict.execute(frame, context)); Object objectHook = getObjectHook.execute(frame, context); @@ -197,7 +200,7 @@ public PJSONScanner doNew(VirtualFrame frame, Object cls, Object context, Object parseFloat = getParseFloat.execute(frame, context); Object parseInt = getParseInt.execute(frame, context); Object parseConstant = getParseConstant.execute(frame, context); - return factory.createJSONScanner(cls, strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant); + return PFactory.createJSONScanner(language, cls, getInstanceShape.execute(cls), strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant); } } @@ -241,7 +244,8 @@ PJSONEncoder doNew(Object cls, Object markers, Object defaultFn, Object encoder, } } } - return getContext().factory().createJSONEncoder(cls, markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode); + return PFactory.createJSONEncoder(PythonLanguage.get(null), cls, TypeNodes.GetInstanceShape.executeUncached(cls), + markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java index 97146e249d..48838a024b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java @@ -38,18 +38,15 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(extendClasses = PythonBuiltinClassType.JSONScanner) @@ -78,11 +75,6 @@ public abstract static class CallScannerNode extends PythonTernaryClinicBuiltinN @Child private CallUnaryMethodNode callParseConstant = CallUnaryMethodNode.create(); @Child private CallUnaryMethodNode callObjectHook = CallUnaryMethodNode.create(); @Child private CallUnaryMethodNode callObjectPairsHook = CallUnaryMethodNode.create(); - @Child private PythonObjectFactory factory = PythonObjectFactory.create(); - - @CompilationFinal private Shape tupleInstanceShape; - @CompilationFinal private Shape listInstanceShape; - @CompilationFinal private Shape dictInstanceShape; @Override protected ArgumentClinicProvider getArgumentClinic() { @@ -92,21 +84,9 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization protected PTuple call(PJSONScanner self, TruffleString string, int idx, @Cached TruffleString.ToJavaStringNode toJavaStringNode) { - if (tupleInstanceShape == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - tupleInstanceShape = PythonLanguage.get(this).getBuiltinTypeInstanceShape(PythonBuiltinClassType.PTuple); - } - if (listInstanceShape == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - listInstanceShape = PythonLanguage.get(this).getBuiltinTypeInstanceShape(PythonBuiltinClassType.PList); - } - if (dictInstanceShape == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - dictInstanceShape = PythonLanguage.get(this).getBuiltinTypeInstanceShape(PythonBuiltinClassType.PDict); - } IntRef nextIdx = new IntRef(); Object result = scanOnceUnicode(self, toJavaStringNode.execute(string), idx, nextIdx); - return factory.createTuple(new Object[]{result, nextIdx.value}); + return PFactory.createTuple(PythonLanguage.get(this), new Object[]{result, nextIdx.value}); } @TruffleBoundary @@ -120,6 +100,8 @@ private Object parseObjectUnicode(PJSONScanner scanner, String string, int start */ boolean hasPairsHook = scanner.objectPairsHook != PNone.NONE; + PythonLanguage language = PythonLanguage.get(null); + int idx = start; int length = string.length(); @@ -161,7 +143,7 @@ private Object parseObjectUnicode(PJSONScanner scanner, String string, int start idx = nextIdx.value; if (hasPairsHook) { - listStorage.insertItem(listStorage.length(), factory.createTuple(PythonBuiltinClassType.PTuple, tupleInstanceShape, new Object[]{key, val})); + listStorage.insertItem(listStorage.length(), PFactory.createTuple(language, new Object[]{key, val})); } else { HashingStorage newStorage = HashingStorageSetItem.executeUncached(mapStorage, key, val); assert newStorage == mapStorage; @@ -186,11 +168,11 @@ private Object parseObjectUnicode(PJSONScanner scanner, String string, int start nextIdx.value = idx + 1; if (hasPairsHook) { - return callObjectPairsHook.executeObject(scanner.objectPairsHook, factory.createList(PythonBuiltinClassType.PList, listInstanceShape, listStorage)); + return callObjectPairsHook.executeObject(scanner.objectPairsHook, PFactory.createList(language, listStorage)); } /* if object_hook is not None: rval = object_hook(rval) */ - PDict rval = factory.createDict(PythonBuiltinClassType.PDict, dictInstanceShape, mapStorage); + PDict rval = PFactory.createDict(language, mapStorage); if (scanner.objectHook != PNone.NONE) { return callObjectHook.executeObject(scanner.objectHook, rval); } @@ -242,7 +224,7 @@ private Object parseArrayUnicode(PJSONScanner scanner, String string, int start, throw decodeError(this, string, length - 1, ErrorMessages.EXPECTING_VALUE); } nextIdx.value = idx + 1; - return factory.createList(PythonBuiltinClassType.PList, listInstanceShape, storage); + return PFactory.createList(PythonLanguage.get(null), storage); } private static int skipWhitespace(String string, int start, int length) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java index 295b43080d..d5644b074a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.ClinicConverterFactory; @@ -78,7 +79,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.api.dsl.Bind; @@ -178,11 +179,11 @@ abstract static class CompressNode extends PythonBinaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) static PBytes doBytes(VirtualFrame frame, LZMACompressor self, Object data, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetArrayAndLengthHelperNode getArrayAndLengthHelperNode, - @Cached LZMANodes.CompressNode compress, - @Cached PythonObjectFactory factory) { + @Cached LZMANodes.CompressNode compress) { ArrayAndLength aal = getArrayAndLengthHelperNode.execute(frame, inliningTarget, data); - return factory.createBytes(compress.compress(inliningTarget, self, PythonContext.get(inliningTarget), aal.array, aal.length)); + return PFactory.createBytes(language, compress.compress(inliningTarget, self, PythonContext.get(inliningTarget), aal.array, aal.length)); } @SuppressWarnings("unused") @@ -226,10 +227,10 @@ abstract static class FlushNode extends PythonUnaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) static PBytes doit(LZMACompressor self, @Bind("this") Node inliningTarget, - @Cached LZMANodes.CompressNode compress, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached LZMANodes.CompressNode compress) { self.setFlushed(); - return factory.createBytes(compress.flush(inliningTarget, self, PythonContext.get(inliningTarget))); + return PFactory.createBytes(language, compress.flush(inliningTarget, self, PythonContext.get(inliningTarget))); } @SuppressWarnings("unused") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java index c86554b75e..17983e6658 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -56,6 +56,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -78,7 +79,7 @@ import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -205,24 +206,24 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = {"!self.isEOF()"}) static PBytes doBytes(LZMADecompressor self, PBytesLike data, int maxLength, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached SequenceStorageNodes.GetInternalByteArrayNode toBytes, - @Exclusive @Cached LZMANodes.DecompressNode decompress, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached LZMANodes.DecompressNode decompress) { byte[] bytes = toBytes.execute(inliningTarget, data.getSequenceStorage()); int len = data.getSequenceStorage().length(); - return factory.createBytes(decompress.execute(inliningTarget, self, bytes, len, maxLength)); + return PFactory.createBytes(language, decompress.execute(inliningTarget, self, bytes, len, maxLength)); } @Specialization(guards = {"!self.isEOF()"}) static PBytes doObject(VirtualFrame frame, LZMADecompressor self, Object data, int maxLength, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached BytesNodes.ToBytesNode toBytes, - @Exclusive @Cached LZMANodes.DecompressNode decompress, - @Shared @Cached PythonObjectFactory factory) { + @Exclusive @Cached LZMANodes.DecompressNode decompress) { byte[] bytes = toBytes.execute(frame, data); int len = bytes.length; - return factory.createBytes(decompress.execute(inliningTarget, self, bytes, len, maxLength)); + return PFactory.createBytes(language, decompress.execute(inliningTarget, self, bytes, len, maxLength)); } @SuppressWarnings("unused") @@ -282,8 +283,8 @@ abstract static class UnusedDataNode extends PythonUnaryBuiltinNode { @Specialization static PBytes doUnusedData(LZMADecompressor self, - @Cached PythonObjectFactory factory) { - return factory.createBytes(self.getUnusedData()); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, self.getUnusedData()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java index 045ee97e5d..7574a24ee4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -80,6 +80,7 @@ import org.graalvm.shadowed.org.tukaani.xz.XZ; import org.graalvm.shadowed.org.tukaani.xz.XZOutputStream; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -88,6 +89,7 @@ import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.module.PythonModule; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; @@ -97,7 +99,8 @@ import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.runtime.NFILZMASupport; import com.oracle.graal.python.runtime.NativeLibrary; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -262,27 +265,27 @@ public void postInitialize(Python3Core c) { @Builtin(name = "LZMACompressor", minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, constructsClass = PLZMACompressor) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class LZMACompressorNode extends PythonBuiltinNode { @Specialization LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see LZMACompressorBuiltins.InitNode - return factory.createLZMACompressor(cls, getContext().getNFILZMASupport().isAvailable()); + PythonContext context = getContext(); + return PFactory.createLZMACompressor(context.getLanguage(this), cls, getInstanceShape.execute(cls), context.getNFILZMASupport().isAvailable()); } } @Builtin(name = "LZMADecompressor", minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, constructsClass = PLZMADecompressor) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class LZMADecompressorNode extends PythonBuiltinNode { @Specialization LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PythonObjectFactory factory) { + @Cached TypeNodes.GetInstanceShape getInstanceShape) { // data filled in subsequent __init__ call - see LZMADecompressorBuiltins.InitNode - return factory.createLZMADecompressor(cls, getContext().getNFILZMASupport().isAvailable()); + PythonContext context = getContext(); + return PFactory.createLZMADecompressor(context.getLanguage(this), cls, getInstanceShape.execute(cls), context.getNFILZMASupport().isAvailable()); } } @@ -308,8 +311,8 @@ abstract static class EncodeFilterPropertiesNode extends PythonUnaryBuiltinNode @Specialization static PBytes encode(VirtualFrame frame, Object filter, @Cached LZMANodes.EncodeFilterProperties encodeFilterProperties, - @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeFilterProperties.execute(frame, filter)); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, encodeFilterProperties.execute(frame, filter)); } } @@ -321,12 +324,12 @@ abstract static class DecodeFilterPropertiesNode extends PythonBinaryBuiltinNode @Specialization static PDict encode(VirtualFrame frame, Object id, Object encodedProps, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached CastToJavaLongLossyNode toLong, @Cached BytesNodes.ToBytesNode toBytes, - @Cached LZMANodes.DecodeFilterProperties decodeFilterProperties, - @Cached PythonObjectFactory factory) { + @Cached LZMANodes.DecodeFilterProperties decodeFilterProperties) { byte[] bytes = toBytes.execute(frame, encodedProps); - PDict dict = factory.createDict(); + PDict dict = PFactory.createDict(language); decodeFilterProperties.execute(frame, toLong.execute(inliningTarget, id), bytes, dict); return dict; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java index 45a533e723..41e7a60abf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -46,6 +46,7 @@ import java.util.List; import java.util.concurrent.Semaphore; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -66,7 +67,7 @@ import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.SharedMultiprocessingData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -240,7 +241,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object doEnter(@SuppressWarnings("unused") Object handle, int kind, @SuppressWarnings("unused") Object maxvalue, TruffleString name, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { SharedMultiprocessingData multiprocessing = PythonContext.get(inliningTarget).getSharedMultiprocessingData(); Semaphore semaphore = multiprocessing.getNamedSemaphore(name); if (semaphore == null) { @@ -248,7 +249,7 @@ static Object doEnter(@SuppressWarnings("unused") Object handle, int kind, @Supp // provided handle semaphore = newSemaphore(); } - return factory.createGraalPySemLock(PythonBuiltinClassType.PGraalPySemLock, name, kind, semaphore); + return PFactory.createGraalPySemLock(language, name, kind, semaphore); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java index 308f2b859b..86d2466c87 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -64,6 +64,7 @@ import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.thread.PThread; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.ErrorMessages; @@ -85,7 +86,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.Timeval; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.SharedMultiprocessingData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.ArrayBuilder; @@ -118,7 +119,7 @@ protected List> getNodeFa @Override public void initialize(Python3Core core) { // TODO: add necessary entries to the dict - addBuiltinConstant("flags", core.factory().createDict()); + addBuiltinConstant("flags", PFactory.createDict(core.getLanguage())); super.initialize(core); } @@ -133,7 +134,8 @@ abstract static class SemLockNode extends PythonClinicBuiltinNode { @Specialization static PGraalPySemLock construct(Object cls, int kind, int value, @SuppressWarnings("unused") int maxValue, TruffleString name, boolean unlink, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (kind != PGraalPySemLock.RECURSIVE_MUTEX && kind != PGraalPySemLock.SEMAPHORE) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.UNRECOGNIZED_KIND); @@ -152,7 +154,7 @@ static PGraalPySemLock construct(Object cls, int kind, int value, @SuppressWarni multiprocessing.putNamedSemaphore(name, semaphore); } } - return factory.createGraalPySemLock(cls, name, kind, semaphore); + return PFactory.createGraalPySemLock(language, cls, getInstanceShape.execute(cls), name, kind, semaphore); } @TruffleBoundary @@ -218,13 +220,13 @@ long getTid( abstract static class WaitTidNode extends PythonBinaryBuiltinNode { @Specialization PTuple waittid(long id, @SuppressWarnings("unused") int options, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { long tid = convertTid(id); // TODO implement for options - WNOHANG and 0 final SharedMultiprocessingData multiprocessing = getContext().getSharedMultiprocessingData(); Thread thread = multiprocessing.getChildContextThread(tid); if (thread != null && thread.isAlive()) { - return factory.createTuple(new Object[]{0, 0, 0}); + return PFactory.createTuple(language, new Object[]{0, 0, 0}); } PythonContext.ChildContextData data = multiprocessing.getChildContextData(tid); @@ -234,7 +236,7 @@ PTuple waittid(long id, @SuppressWarnings("unused") int options, * clean it. See popen_truffleprocess that calls the _waittid builtin. */ multiprocessing.removeChildContextData(tid); - return factory.createTuple(new Object[]{id, data.wasSignaled() ? data.getExitCode() : 0, data.getExitCode()}); + return PFactory.createTuple(language, new Object[]{id, data.wasSignaled() ? data.getExitCode() : 0, data.getExitCode()}); } } @@ -274,7 +276,7 @@ abstract static class PipeNode extends PythonBuiltinNode { @Specialization PTuple pipe(@Cached GilNode gil, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int[] pipe; PythonContext ctx = getContext(); SharedMultiprocessingData sharedData = ctx.getSharedMultiprocessingData(); @@ -286,7 +288,7 @@ PTuple pipe(@Cached GilNode gil, } finally { gil.acquire(); } - return factory.createTuple(new Object[]{pipe[0], pipe[1]}); + return PFactory.createTuple(language, new Object[]{pipe[0], pipe[1]}); } } @@ -327,8 +329,8 @@ Object doWrite(long fd, PBytes data, public abstract static class ReadNode extends PythonBinaryBuiltinNode { @Specialization Object doReadInt(int fd, @SuppressWarnings("unused") Object length, - @Shared @Cached GilNode gil, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached GilNode gil) { SharedMultiprocessingData sharedData = getContext().getSharedMultiprocessingData(); gil.release(true); try { @@ -336,9 +338,9 @@ Object doReadInt(int fd, @SuppressWarnings("unused") Object length, throw PRaiseNode.raiseUncached(this, OSError, ErrorMessages.BAD_FILE_DESCRIPTOR); }); if (data == PNone.NONE) { - return factory.createBytes(PythonUtils.EMPTY_BYTE_ARRAY, 0, 0); + return PFactory.createEmptyBytes(language); } - return factory.createBytes((byte[]) data); + return PFactory.createBytes(language, (byte[]) data); } finally { gil.acquire(); } @@ -346,9 +348,9 @@ Object doReadInt(int fd, @SuppressWarnings("unused") Object length, @Specialization Object doReadLong(long fd, Object length, - @Shared @Cached GilNode gil, - @Shared @Cached PythonObjectFactory factory) { - return doReadInt((int) fd, length, gil, factory); + @Bind PythonLanguage language, + @Shared @Cached GilNode gil) { + return doReadInt((int) fd, length, language, gil); } } @@ -394,6 +396,7 @@ abstract static class SelectNode extends PythonBuiltinNode { @Specialization Object doGeneric(VirtualFrame frame, Object multiprocessingFdsList, Object multiprocessingObjsList, Object posixFileObjsList, Object timeoutObj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PosixModuleBuiltins.FileDescriptorConversionNode fdConvertor, @Cached PyObjectSizeNode sizeNode, @Cached PyObjectGetItem getItem, @@ -402,8 +405,7 @@ Object doGeneric(VirtualFrame frame, Object multiprocessingFdsList, Object multi @Cached CastToJavaIntLossyNode castToJava, @Cached CastToJavaDoubleNode castToDouble, @Cached GilNode gil, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { PythonContext context = getContext(); SharedMultiprocessingData sharedData = context.getSharedMultiprocessingData(); @@ -443,7 +445,7 @@ Object doGeneric(VirtualFrame frame, Object multiprocessingFdsList, Object multi } } - return factory.createList(result.toArray(new Object[0])); + return PFactory.createList(language, result.toArray(new Object[0])); } catch (PosixSupportLibrary.PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } finally { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java index 3b290b2982..503ec392a6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,12 +45,14 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode; @@ -61,7 +63,7 @@ import com.oracle.graal.python.runtime.PosixSupport; import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -92,7 +94,8 @@ static PSemLock construct(VirtualFrame frame, Object cls, int kind, int value, i @Bind("this") Node inliningTarget, @Bind("getPosixSupport()") PosixSupport posixSupport, @CachedLibrary("posixSupport") PosixSupportLibrary posixLib, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { if (kind != PGraalPySemLock.RECURSIVE_MUTEX && kind != PGraalPySemLock.SEMAPHORE) { @@ -117,7 +120,7 @@ static PSemLock construct(VirtualFrame frame, Object cls, int kind, int value, i throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } } - return factory.createSemLock(cls, handle, kind, maxValue, name); + return PFactory.createSemLock(language, cls, getInstanceShape.execute(cls), handle, kind, maxValue, name); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java index 2834d0b355..6b25b671de 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -55,6 +56,7 @@ import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.thread.PThread; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyFloatAsDoubleNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; @@ -71,7 +73,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PosixSupportLibrary.UnsupportedPosixFeatureException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -362,7 +364,8 @@ static Object rebuild(VirtualFrame frame, Object cls, @SuppressWarnings("unused" @Bind("this") Node inliningTarget, @Bind("getPosixSupport()") PosixSupport posixSupport, @CachedLibrary("posixSupport") PosixSupportLibrary posixLib, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Object posixName = posixLib.createPathFromString(posixSupport, name); long handle; @@ -371,7 +374,7 @@ static Object rebuild(VirtualFrame frame, Object cls, @SuppressWarnings("unused" } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } - return factory.createSemLock(cls, handle, kind, maxValue, name); + return PFactory.createSemLock(language, cls, getInstanceShape.execute(cls), handle, kind, maxValue, name); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java index ec3f3c30a2..61a1f25b8f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.modules.pickle; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.tuple.PTuple; @@ -47,7 +48,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; @@ -155,7 +156,7 @@ public abstract static class PDataPopTupleNode extends PDataBaseNode { @Specialization static PTuple popTuple(PData self, int start, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { int len, i, j; @@ -168,7 +169,7 @@ static PTuple popTuple(PData self, int start, items[j] = self.data[i]; } self.size = start; - return factory.createTuple(items); + return PFactory.createTuple(language, items); } public static PDataPopTupleNode create() { @@ -183,7 +184,7 @@ public abstract static class PDataPopListNode extends PDataBaseNode { @Specialization public PList popList(PData self, int start, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int len, i, j; len = self.size - start; @@ -192,7 +193,7 @@ public PList popList(PData self, int start, items[j] = self.data[i]; } self.size = start; - return factory.createList(items); + return PFactory.createList(language, items); } public static PDataPopListNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java index 5331ccbf86..673b820c03 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java @@ -65,6 +65,7 @@ import org.graalvm.collections.Pair; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; @@ -107,7 +108,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.Consumer; import com.oracle.graal.python.util.NumericSupport; @@ -353,9 +354,9 @@ public void commitFrame() { frameStart = -1; } - public PBytes getString(PythonObjectFactory factory) { + public PBytes getString(PythonLanguage language) { commitFrame(); - return factory.createBytes(outputBuffer, outputLen); + return PFactory.createBytes(language, outputBuffer, outputLen); } // inner nodes @@ -528,7 +529,7 @@ protected void writeBytes(VirtualFrame frame, PPickler pickler, byte[] header, i if (pld == null) { // TODO: It would be better to use a memoryview with a linked original string if // this is possible. - pld = factory().createBytes(data, 0, dataSize); + pld = PFactory.createBytes(PythonLanguage.get(this), data, dataSize); } getCallNode().execute(frame, pickler.write, pld); // Reinitialize the buffer for subsequent calls to _Pickler_Write. @@ -543,9 +544,9 @@ protected void writeBytes(VirtualFrame frame, PPickler pickler, byte[] header, i protected PTuple createTuple(Object... items) { if (items.length == 0) { - return factory().createEmptyTuple(); + return PFactory.createEmptyTuple(PythonLanguage.get(this)); } - return factory().createTuple(items); + return PFactory.createTuple(PythonLanguage.get(this), items); } protected void fastSaveEnter(PPickler pickler, Object obj) { @@ -570,10 +571,11 @@ public abstract static class FlushToFileNode extends BasePickleWriteNode { public abstract void execute(VirtualFrame frame, PPickler pickler); @Specialization - public void flush(VirtualFrame frame, PPickler pickler) { + public void flush(VirtualFrame frame, PPickler pickler, + @Bind PythonLanguage language) { assert pickler.write != null; // This will commit the frame first - PBytes output = pickler.getString(factory()); + PBytes output = pickler.getString(language); call(frame, pickler.write, output); } } @@ -1054,7 +1056,7 @@ private void saveReduce(VirtualFrame frame, PythonContext ctx, PPickler pickler, callable = callStarArgsAndKwArgs(frame, st.partial, newargs, kwargs); save(frame, pickler, callable, 0); - save(frame, pickler, factory().createEmptyTuple(), 0); + save(frame, pickler, PFactory.createEmptyTuple(PythonLanguage.get(this)), 0); write(pickler, PickleUtils.OPCODE_REDUCE); } } else if (useNewobj) { @@ -1110,7 +1112,7 @@ private void saveReduce(VirtualFrame frame, PythonContext ctx, PPickler pickler, // Save the class and its __new__ arguments save(frame, pickler, cls, 0); - newargtup = getItem(frame, argtup, factory().createIntSlice(1, argtupSize, 1)); + newargtup = getItem(frame, argtup, PFactory.createIntSlice(PythonLanguage.get(this), 1, argtupSize, 1)); save(frame, pickler, newargtup, 0); write(pickler, PickleUtils.OPCODE_NEWOBJ); } else { @@ -1738,7 +1740,7 @@ private void saveBytearrayData(VirtualFrame frame, PPickler pickler, Object obj, memoPut(pickler, obj); } - private void saveBytearray(VirtualFrame frame, PythonContext ctx, PPickler pickler, Object obj, IndirectCallData indirectCallData) { + private void saveBytearray(VirtualFrame frame, Node inliningTarget, PythonContext ctx, PPickler pickler, Object obj, IndirectCallData indirectCallData) { Object buffer = getBufferAcquireLibrary().acquireReadonly(obj, frame, indirectCallData); try { if (pickler.proto < 5) { @@ -1750,7 +1752,7 @@ private void saveBytearray(VirtualFrame frame, PythonContext ctx, PPickler pickl reduceValue = createTuple(byteArrayClass, createTuple()); } else { byte[] bytes = getBufferLibrary().getCopiedByteArray(buffer); - reduceValue = createTuple(byteArrayClass, createTuple(factory().createBytes(bytes))); + reduceValue = createTuple(byteArrayClass, createTuple(PFactory.createBytes(ctx.getLanguage(inliningTarget), bytes))); } // save_reduce() will memoize the object automatically. @@ -2026,7 +2028,7 @@ void saveGeneric(VirtualFrame frame, PPickler pickler, Object objArg, int persSa saveTuple(frame, pickler, obj); return; } else if (isBuiltinClass(type, PythonBuiltinClassType.PByteArray)) { - saveBytearray(frame, ctx, pickler, obj, indirectCallData); + saveBytearray(frame, inliningTarget, ctx, pickler, obj, indirectCallData); return; } else if (obj instanceof PPickleBuffer buffer) { savePicklebuffer(frame, pickler, buffer); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java index f3e125de7b..f655fa1a01 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java @@ -130,6 +130,7 @@ import org.graalvm.collections.Pair; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.buffer.BufferFlags; @@ -168,6 +169,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.NumericSupport; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -442,7 +444,7 @@ protected PythonBufferAccessLibrary getBufferAccessLibrary() { } public Object createMemoryViewFromBytes(VirtualFrame frame, byte[] bytes, int n) { - return ensureMemoryViewNode().execute(frame, factory().createByteArray(bytes, n)); + return ensureMemoryViewNode().execute(frame, PFactory.createByteArray(PythonLanguage.get(this), bytes, n)); } public Object createMemoryView(VirtualFrame frame, Object obj) { @@ -946,7 +948,7 @@ private void loadCountedBinBytes(VirtualFrame frame, PUnpickler self, int nbytes byte[] buffer = new byte[size]; readInto(frame, self, buffer); - Object bytes = factory().createBytes(buffer); + Object bytes = PFactory.createBytes(PythonLanguage.get(this), buffer); pDataPush(self, bytes); } @@ -960,7 +962,7 @@ private void loadCountedByteArray(VirtualFrame frame, PUnpickler self) { byte[] buffer = new byte[size]; readInto(frame, self, buffer); - Object bytearray = factory().createByteArray(buffer); + Object bytearray = PFactory.createByteArray(PythonLanguage.get(this), buffer); pDataPush(self, bytearray); } @@ -1008,7 +1010,7 @@ private void loadCountedBinString(VirtualFrame frame, PUnpickler self, int nbyte // Convert Python 2.x strings to bytes if the *encoding* given to the Unpickler was // 'bytes'. Otherwise, convert them to unicode. - final PBytes bytes = factory().createBytes(s.getBytes(size), size); + final PBytes bytes = PFactory.createBytes(PythonLanguage.get(this), s.getBytes(size), size); if (ensureTsEqualNode().execute(self.encoding, T_CODEC_BYTES, TS_ENCODING)) { obj = bytes; } else { @@ -1037,7 +1039,11 @@ private void loadString(VirtualFrame frame, PUnpickler self) { // Use the PyBytes API to decode the string, since that is what is used to encode, and // then coerce the result to Unicode. - bytes = escapeDecode(frame, factory(), s, pStart, len); + if (len == 0) { + bytes = PFactory.createEmptyBytes(PythonLanguage.get(this)); + } else { + bytes = escapeDecode(frame, PythonUtils.arrayCopyOfRange(s, pStart, pStart + len)); + } // Leave the Python 2.x strings as bytes if the *encoding* given to the Unpickler was // 'bytes'. Otherwise, convert them to unicode. @@ -1093,7 +1099,7 @@ private void loadTuple(PUnpickler self) { } private void loadEmptyList(PUnpickler self) { - pDataPush(self, factory().createList()); + pDataPush(self, PFactory.createList(PythonLanguage.get(this))); } private void loadList(PUnpickler self) { @@ -1103,7 +1109,7 @@ private void loadList(PUnpickler self) { } private void loadEmptyDict(PUnpickler self) { - pDataPush(self, factory().createDict()); + pDataPush(self, PFactory.createDict(PythonLanguage.get(this))); } private void loadDict(VirtualFrame frame, PUnpickler self) { @@ -1125,11 +1131,11 @@ private void loadDict(VirtualFrame frame, PUnpickler self) { } self.stack.clear(i); - pDataPush(self, factory().createDict(storage)); + pDataPush(self, PFactory.createDict(PythonLanguage.get(this), storage)); } private void loadEmptySet(PUnpickler self) { - pDataPush(self, factory().createSet()); + pDataPush(self, PFactory.createSet(PythonLanguage.get(this))); } private void loadAddItems(VirtualFrame frame, PUnpickler self) { @@ -1168,7 +1174,7 @@ private void loadAddItems(VirtualFrame frame, PUnpickler self) { private void loadFrozenSet(VirtualFrame frame, PUnpickler self) { int i = marker(self); Object items = pDataPopTuple(self, i); - Object frozenset = factory().createFrozenSet(getClonedHashingStorage(frame, items)); + Object frozenset = PFactory.createFrozenSet(PythonLanguage.get(this), getClonedHashingStorage(frame, items)); pDataPush(self, frozenset); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java index 6f588766b2..6c64e33abb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.BufferFormat; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -84,7 +85,7 @@ Object raw(VirtualFrame frame, PPickleBuffer self, @Bind("this") Node inliningTarget, @Cached PyMemoryViewFromObject memoryViewFromObject, @Cached MemoryViewNodes.ReleaseNode releaseNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { final Object view = self.getView(); if (view == null) { @@ -98,7 +99,7 @@ Object raw(VirtualFrame frame, PPickleBuffer self, } int[] shape = new int[]{mv.getLength()}; int[] strides = new int[]{1}; - return factory.createMemoryView(getContext(), mv.getLifecycleManager(), mv.getBuffer(), mv.getOwner(), mv.getLength(), + return PFactory.createMemoryView(language, getContext(), mv.getLifecycleManager(), mv.getBuffer(), mv.getOwner(), mv.getLength(), mv.isReadOnly(), 1, BufferFormat.UINT_8, BufferFormat.T_UINT_8_TYPE_CODE, 1, mv.getBufferPointer(), mv.getOffset(), shape, strides, null, PMemoryView.FLAG_C | PMemoryView.FLAG_FORTRAN); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java index 891068b1dc..4f7a0a56c9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -56,6 +57,7 @@ import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAcquireLibrary; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.module.PythonModule; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.nodes.HiddenAttr; @@ -66,7 +68,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -99,11 +101,11 @@ public void postInitialize(Python3Core core) { abstract static class ConstructPickleBufferNode extends PythonBinaryBuiltinNode { @Specialization(limit = "3") static PPickleBuffer construct(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object object, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, - @CachedLibrary("object") PythonBufferAcquireLibrary acquireLib, - @Cached PythonObjectFactory factory) { + @CachedLibrary("object") PythonBufferAcquireLibrary acquireLib) { Object buffer = acquireLib.acquire(object, BufferFlags.PyBUF_FULL_RO, frame, indirectCallData); - return factory.createPickleBuffer(buffer); + return PFactory.createPickleBuffer(language, buffer); } } @@ -112,8 +114,9 @@ static PPickleBuffer construct(VirtualFrame frame, @SuppressWarnings("unused") O abstract static class ConstructPicklerNode extends PythonVarargsBuiltinNode { @Specialization PPickler construct(Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords, - @Cached PythonObjectFactory factory) { - return factory.createPickler(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createPickler(language, cls, getInstanceShape.execute(cls)); } } @@ -122,8 +125,9 @@ PPickler construct(Object cls, @SuppressWarnings("unused") Object[] arguments, @ abstract static class ConstructPicklerMemoProxyNode extends PythonBinaryBuiltinNode { @Specialization PPicklerMemoProxy construct(Object cls, PPickler pickler, - @Cached PythonObjectFactory factory) { - return factory.createPicklerMemoProxy(pickler, cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createPicklerMemoProxy(language, pickler, cls, getInstanceShape.execute(cls)); } } @@ -132,8 +136,9 @@ PPicklerMemoProxy construct(Object cls, PPickler pickler, abstract static class ConstructUnpicklerMemoProxyNode extends PythonBinaryBuiltinNode { @Specialization PUnpicklerMemoProxy construct(Object cls, PUnpickler unpickler, - @Cached PythonObjectFactory factory) { - return factory.createUnpicklerMemoProxy(unpickler, cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createUnpicklerMemoProxy(language, unpickler, cls, getInstanceShape.execute(cls)); } } @@ -142,8 +147,9 @@ PUnpicklerMemoProxy construct(Object cls, PUnpickler unpickler, abstract static class ConstructUnpicklerNode extends PythonVarargsBuiltinNode { @Specialization PUnpickler construct(Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords, - @Cached PythonObjectFactory factory) { - return factory.createUnpickler(cls); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createUnpickler(language, cls, getInstanceShape.execute(cls)); } } @@ -163,12 +169,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object dump(VirtualFrame frame, @SuppressWarnings("unused") PythonModule self, Object obj, Object file, int protocol, boolean fixImports, Object bufferCallback, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PPickler.DumpNode dumpNode, @Cached PPickler.FlushToFileNode flushToFileNode, @Cached PyObjectLookupAttr lookup, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - PPickler pickler = factory.createPickler(); + PPickler pickler = PFactory.createPickler(language); pickler.setProtocol(inliningTarget, raiseNode, protocol, fixImports); pickler.setOutputStream(frame, inliningTarget, raiseNode, lookup, file); pickler.setBufferCallback(inliningTarget, raiseNode, bufferCallback); @@ -193,14 +199,14 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object dump(VirtualFrame frame, @SuppressWarnings("unused") PythonModule self, Object obj, int protocol, boolean fixImports, Object bufferCallback, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PPickler.DumpNode dumpNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - PPickler pickler = factory.createPickler(); + PPickler pickler = PFactory.createPickler(language); pickler.setProtocol(inliningTarget, raiseNode, protocol, fixImports); pickler.setBufferCallback(inliningTarget, raiseNode, bufferCallback); dumpNode.execute(frame, pickler, obj); - return pickler.getString(factory); + return pickler.getString(language); } } @@ -220,12 +226,12 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object load(VirtualFrame frame, @SuppressWarnings("unused") PythonModule self, Object file, @SuppressWarnings("unused") boolean fixImports, TruffleString encoding, TruffleString errors, Object buffers, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PUnpickler.LoadNode loadNode, @Cached PyObjectLookupAttr lookup, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { - PUnpickler unpickler = factory.createUnpickler(); + PUnpickler unpickler = PFactory.createUnpickler(language); unpickler.setInputStream(frame, inliningTarget, raiseNode, lookup, file); unpickler.setInputEncoding(encoding, errors); unpickler.setBuffers(frame, inliningTarget, getIter, buffers); @@ -251,12 +257,12 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object loads(VirtualFrame frame, @SuppressWarnings("unused") PythonModule self, Object buffer, boolean fixImports, TruffleString encoding, TruffleString errors, Object buffers, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached PUnpickler.LoadNode loadNode, - @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory) { + @Cached PyObjectGetIter getIter) { try { - PUnpickler unpickler = factory.createUnpickler(); + PUnpickler unpickler = PFactory.createUnpickler(language); byte[] data = bufferLib.getCopiedByteArray(buffer); unpickler.setStringInput(data, data.length); unpickler.setInputEncoding(encoding, errors); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java index 6fcdb97251..3efa079792 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -50,6 +50,7 @@ import org.graalvm.collections.Pair; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.bytes.ByteArrayBuffer; @@ -60,7 +61,7 @@ import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.StringLiterals; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.frame.VirtualFrame; @@ -373,9 +374,9 @@ public static Pair initMethodRef(VirtualFrame frame, Node inlini } } - public static Object reconstructMethod(PythonObjectFactory factory, Object func, Object self) { + public static Object reconstructMethod(PythonLanguage language, Object func, Object self) { if (self != null) { - return factory.createMethod(self, func); + return PFactory.createMethod(language, self, func); } return func; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java index 5d1039854d..0fd7fffb30 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -84,7 +85,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -244,8 +245,8 @@ Object set(VirtualFrame frame, PPickler self, Object value, public abstract static class PicklerMemoNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(none)") static Object get(PPickler self, @SuppressWarnings("unused") PNone none, - @Cached PythonObjectFactory factory) { - return factory.createPicklerMemoProxy(self); + @Bind PythonLanguage language) { + return PFactory.createPicklerMemoProxy(language, self); } @Specialization(guards = {"!isNoValue(obj)", "!isDeleteMarker(obj)"}) @@ -291,13 +292,13 @@ public abstract static class PicklerPersistentIdNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(none)") static Object get(PPickler self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { final Object persFunc = self.getPersFunc(); if (persFunc == null) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_ID); } - return PickleUtils.reconstructMethod(factory, persFunc, self.getPersFuncSelf()); + return PickleUtils.reconstructMethod(language, persFunc, self.getPersFuncSelf()); } @Specialization(guards = {"!isNoValue(obj)", "!isDeleteMarker(obj)"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerMemoProxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerMemoProxyBuiltins.java index 98b6472d35..b8243bd187 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerMemoProxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerMemoProxyBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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,6 +45,7 @@ import java.util.LinkedHashMap; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -55,10 +56,9 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -82,16 +82,16 @@ Object clear(PPicklerMemoProxy self) { } @TruffleBoundary - public static PDict picklerMemoCopyImpl(PythonContext context, MemoTable memoTable) { - PythonObjectFactory factory = context.factory(); + public static PDict picklerMemoCopyImpl(MemoTable memoTable) { + PythonLanguage language = PythonLanguage.get(null); LinkedHashMap copy = new LinkedHashMap<>(); MemoIterator iterator = memoTable.iterator(); while (iterator.advance()) { copy.put(System.identityHashCode(iterator.key()), - factory.createTuple(new Object[]{iterator.value(), iterator.key()})); + PFactory.createTuple(language, new Object[]{iterator.value(), iterator.key()})); } - return factory.createDictFromMapGeneric(copy); + return PFactory.createDictFromMapGeneric(language, copy); } @Builtin(name = "copy", minNumOfPositionalArgs = 1, parameterNames = {"$self"}) @@ -100,7 +100,7 @@ public abstract static class PicklerMemoProxyCopyNode extends PythonUnaryBuiltin @Specialization Object copy(PPicklerMemoProxy self) { final MemoTable memoTable = self.getPickler().getMemo(); - return picklerMemoCopyImpl(getContext(), memoTable); + return picklerMemoCopyImpl(memoTable); } } @@ -108,12 +108,12 @@ Object copy(PPicklerMemoProxy self) { @GenerateNodeFactory public abstract static class PicklerMemoProxyReduceNode extends PythonUnaryBuiltinNode { @Specialization - Object reduce(PPicklerMemoProxy self, - @Cached PythonObjectFactory factory) { + static Object reduce(PPicklerMemoProxy self, + @Bind PythonLanguage language) { final MemoTable memoTable = self.getPickler().getMemo(); - final PDict dictMemoCopy = picklerMemoCopyImpl(getContext(), memoTable); - final PTuple dictArgs = factory.createTuple(new Object[]{dictMemoCopy}); - return factory.createTuple(new Object[]{PythonBuiltinClassType.PDict, dictArgs}); + final PDict dictMemoCopy = picklerMemoCopyImpl(memoTable); + final PTuple dictArgs = PFactory.createTuple(language, new Object[]{dictMemoCopy}); + return PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PDict, dictArgs}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java index 6d2c6b00a5..74c5c9e9ec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java @@ -57,10 +57,9 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; -import com.oracle.graal.python.lib.PyLongFromUnicodeObject; -import com.oracle.graal.python.lib.PyObjectSetItem; import org.graalvm.collections.Pair; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins; @@ -83,10 +82,12 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.lib.PyIterCheckNode; import com.oracle.graal.python.lib.PyIterNextNode; +import com.oracle.graal.python.lib.PyLongFromUnicodeObject; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; +import com.oracle.graal.python.lib.PyObjectSetItem; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.HiddenAttr; @@ -103,7 +104,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -126,7 +127,6 @@ abstract static class BasePickleNode extends Node { @SuppressWarnings("FieldMayBeFinal") @Child private PyIterNextNode getNextNode = PyIterNextNode.create(); @Child CastToTruffleStringNode toStringNode = CastToTruffleStringNode.create(); - @Child private PythonObjectFactory objectFactory; @Child private HiddenAttr.ReadNode readHiddenAttributeNode; @Child private IsBuiltinObjectProfile errProfile; @Child private InlineIsBuiltinClassProfile isBuiltinClassProfile; @@ -318,14 +318,6 @@ protected HashingStorageIteratorValue ensureHashingStorageIteratorValue() { return hashingStorageItValue; } - protected final PythonObjectFactory factory() { - if (objectFactory == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - objectFactory = insert(PythonObjectFactory.create()); - } - return objectFactory; - } - protected int length(VirtualFrame frame, Object object) { if (sizeNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -367,15 +359,15 @@ protected CodecsModuleBuiltins.CodecsEscapeDecodeNode ensureEscapeDecodeNode() { } protected Object unicodeRawDecodeEscape(VirtualFrame frame, byte[] bytes, int len) { - return decode(frame, factory().createBytes(bytes, 0, len), T_CODEC_RAW_UNICODE_ESCAPE); + return decode(frame, PFactory.createBytes(PythonLanguage.get(this), bytes, len), T_CODEC_RAW_UNICODE_ESCAPE); } protected Object decodeASCII(VirtualFrame frame, byte[] bytes, int len, TruffleString errors) { - return decode(frame, factory().createBytes(bytes, 0, len), T_CODEC_ASCII, errors); + return decode(frame, PFactory.createBytes(PythonLanguage.get(this), bytes, len), T_CODEC_ASCII, errors); } protected Object decodeUTF8(VirtualFrame frame, ByteArrayView bytes, int len, TruffleString errors) { - return decode(frame, factory().createBytes(bytes.getBytes(len), 0, len), T_UTF8, errors); + return decode(frame, PFactory.createBytes(PythonLanguage.get(this), bytes.getBytes(len), len), T_UTF8, errors); } protected Object decode(VirtualFrame frame, Object value, TruffleString encoding) { @@ -386,13 +378,6 @@ protected Object decode(VirtualFrame frame, Object value, TruffleString encoding return getItem(frame, ensureCodecsDecodeNode().call(frame, value, encoding, errors, false), 0); } - protected Object escapeDecode(VirtualFrame frame, PythonObjectFactory factory, byte[] data, int offset, int len) { - if (len == 0) { - return factory.createEmptyBytes(); - } - return escapeDecode(frame, PythonUtils.arrayCopyOfRange(data, offset, offset + len)); - } - protected Object escapeDecode(VirtualFrame frame, byte[] data) { return getItem(frame, ensureEscapeDecodeNode().execute(frame, data, T_ERRORS_STRICT), 0); } @@ -683,7 +668,7 @@ protected Pair get2To3Mapping(VirtualFrame frame, private Pair getMapping(VirtualFrame frame, PDict nameMapping, PDict importMapping, TruffleString nameMappingLabel, TruffleString importMappingLabel, TruffleString moduleName, TruffleString globalName) { - Object key = factory().createTuple(new Object[]{moduleName, globalName}); + Object key = PFactory.createTuple(PythonLanguage.get(this), new Object[]{moduleName, globalName}); Object item = getDictItem(frame, nameMapping, key); if (item != null) { if (!(item instanceof PTuple) || length(frame, item) != 2) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java index 76f15c478e..051c0a9d16 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -162,13 +163,13 @@ public abstract static class UnpicklerPersistentLoadNode extends PythonBuiltinNo @Specialization(guards = "isNoValue(none)") static Object get(PUnpickler self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { final Object persFunc = self.getPersFunc(); if (persFunc == null) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_LOAD); } - return PickleUtils.reconstructMethod(factory, persFunc, self.getPersFuncSelf()); + return PickleUtils.reconstructMethod(language, persFunc, self.getPersFuncSelf()); } @Specialization(guards = "!isNoValue(obj)") @@ -193,8 +194,8 @@ static Object set(PUnpickler self, Object obj, public abstract static class UnpicklerMemoNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(none)") static Object get(PUnpickler self, @SuppressWarnings("unused") PNone none, - @Cached PythonObjectFactory factory) { - return factory.createUnpicklerMemoProxy(self); + @Bind PythonLanguage language) { + return PFactory.createUnpicklerMemoProxy(language, self); } @Specialization(guards = {"!isNoValue(obj)", "!isDeleteMarker(obj)"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerMemoProxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerMemoProxyBuiltins.java index 9e01a285b2..3785edba87 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerMemoProxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerMemoProxyBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -54,7 +55,7 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -86,8 +87,8 @@ public abstract static class UnpicklerMemoProxyCopyNode extends PythonUnaryBuilt Object copy(PUnpicklerMemoProxy self, @Bind("this") Node inliningTarget, @Cached HashingStorageSetItem setItem, - @Cached PythonObjectFactory factory) { - return factory.createDict(self.getUnpickler().copyMemoToHashingStorage(inliningTarget, setItem)); + @Bind PythonLanguage language) { + return PFactory.createDict(language, self.getUnpickler().copyMemoToHashingStorage(inliningTarget, setItem)); } } @@ -98,10 +99,10 @@ public abstract static class UnpicklerMemoProxyReduceNode extends PythonUnaryBui Object reduce(PUnpicklerMemoProxy self, @Bind("this") Node inliningTarget, @Cached HashingStorageSetItem setItem, - @Cached PythonObjectFactory factory) { - final PDict dictMemoCopy = factory.createDict(self.getUnpickler().copyMemoToHashingStorage(inliningTarget, setItem)); - final PTuple constructorArgs = factory.createTuple(new Object[]{dictMemoCopy}); - return factory.createTuple(new Object[]{PythonBuiltinClassType.PDict, constructorArgs}); + @Bind PythonLanguage language) { + final PDict dictMemoCopy = PFactory.createDict(language, self.getUnpickler().copyMemoToHashingStorage(inliningTarget, setItem)); + final PTuple constructorArgs = PFactory.createTuple(language, new Object[]{dictMemoCopy}); + return PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PDict, constructorArgs}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java index 2254eba7f8..c68a766994 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -40,8 +40,6 @@ */ package com.oracle.graal.python.builtins.modules.zlib; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ZlibCompress; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ZlibDecompress; import static com.oracle.graal.python.builtins.modules.zlib.ZLibModuleBuiltins.MAX_WBITS; import static com.oracle.graal.python.builtins.objects.bytes.BytesUtils.mask; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ZLibError; @@ -51,12 +49,13 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.runtime.NFIZlibSupport; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; @@ -77,7 +76,7 @@ public ZLibCompObject(Object cls, Shape instanceShape) { this.unconsumedTail = null; } - // Note: some IDEs mark this class as inaccessible in PythonObjectFactory, but changing this to + // Note: some IDEs mark this class as inaccessible in PFactory, but changing this to // public will cause a warning: [this-escape] possible 'this' escape before subclass is fully // initialized protected static class NativeZlibCompObject extends ZLibCompObject { @@ -176,7 +175,7 @@ public void setInflaterInput(byte[] data, int length, Node node) { } @TruffleBoundary - public ZLibCompObject copyCompressObj(PythonObjectFactory factory) { + public ZLibCompObject copyCompressObj() { assert canCopy; Deflater deflater = new Deflater(level, wbits < 0 || wbits > (MAX_WBITS + 9)); @@ -184,7 +183,7 @@ public ZLibCompObject copyCompressObj(PythonObjectFactory factory) { if (zdict.length > 0) { deflater.setDictionary(zdict); } - ZLibCompObject obj = factory.createJavaZLibCompObject(ZlibCompress, deflater, level, wbits, strategy, zdict); + ZLibCompObject obj = PFactory.createJavaZLibCompObjectCompress(PythonLanguage.get(null), deflater, level, wbits, strategy, zdict); if (inputData != null) { // feed the new copy of deflater the same input data ((JavaZlibCompObject) obj).setDeflaterInput(inputData, inputLen); @@ -194,14 +193,14 @@ public ZLibCompObject copyCompressObj(PythonObjectFactory factory) { } @TruffleBoundary - public ZLibCompObject copyDecompressObj(PythonObjectFactory factory, Node node) { + public ZLibCompObject copyDecompressObj(Node node) { assert canCopy; boolean isRAW = wbits < 0; Inflater inflater = new Inflater(isRAW || wbits > (MAX_WBITS + 9)); if (isRAW && zdict.length > 0) { inflater.setDictionary(zdict); } - ZLibCompObject obj = factory.createJavaZLibCompObject(ZlibDecompress, inflater, wbits, zdict); + ZLibCompObject obj = PFactory.createJavaZLibCompObjectDecompress(PythonLanguage.get(null), inflater, wbits, zdict); if (inputData != null) { try { ((JavaZlibCompObject) obj).setInflaterInput(inputData, inputLen, node); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java index 8c7166019e..eaadef3527 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,8 +41,6 @@ package com.oracle.graal.python.builtins.modules.zlib; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ZlibCompress; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ZlibDecompress; import static com.oracle.graal.python.builtins.modules.zlib.ZlibNodes.Z_OK; import static com.oracle.graal.python.nodes.ErrorMessages.EXPECTED_BYTESLIKE_GOT_P; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; @@ -59,6 +57,7 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ClinicConverterFactory; import com.oracle.graal.python.annotations.ClinicConverterFactory.UseDefaultForNone; @@ -92,9 +91,8 @@ import com.oracle.graal.python.runtime.NFIZlibSupport; import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -510,15 +508,15 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PBytes compress(VirtualFrame frame, Object buffer, int level, int wbits, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached CompressInnerNode innerNode, - @Cached PythonObjectFactory factory) { + @Cached CompressInnerNode innerNode) { try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); byte[] resultArray = innerNode.execute(inliningTarget, bytes, len, level, wbits); - return factory.createBytes(resultArray); + return PFactory.createBytes(language, resultArray); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -574,10 +572,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PBytes decompress(VirtualFrame frame, Object buffer, int wbits, int bufsize, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached DecompressInnerNode innerNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { if (bufsize < 0) { @@ -586,7 +584,7 @@ static PBytes decompress(VirtualFrame frame, Object buffer, int wbits, int bufsi byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); byte[] resultArray = innerNode.execute(inliningTarget, bytes, len, wbits, bufsize); - return factory.createBytes(resultArray); + return PFactory.createBytes(language, resultArray); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -667,10 +665,10 @@ protected static boolean isValidWBitRange(int wbits) { @Specialization(guards = {"method == DEFLATED", "useNative()"}) static Object doNative(int level, int method, int wbits, int memLevel, int strategy, byte[] zdict, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached NativeLibrary.InvokeNativeFunction createCompObject, @Cached NativeLibrary.InvokeNativeFunction compressObjInit, - @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling, - @Cached PythonObjectFactory factory) { + @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { NFIZlibSupport zlibSupport = PythonContext.get(inliningTarget).getNFIZlibSupport(); Object zst = zlibSupport.createCompObject(createCompObject); @@ -684,7 +682,7 @@ static Object doNative(int level, int method, int wbits, int memLevel, int strat if (err != Z_OK) { errorHandling.execute(inliningTarget, zst, err, zlibSupport, true); } - return factory.createNativeZLibCompObject(ZlibCompress, zst, zlibSupport); + return PFactory.createNativeZLibCompObjectCompress(language, zst, zlibSupport); } /** @@ -703,7 +701,7 @@ static Object doJava(int level, @SuppressWarnings("unused") int method, int wbit if (zdict.length > 0) { deflater.setDictionary(zdict); } - return PythonObjectFactory.getUncached().createJavaZLibCompObject(ZlibCompress, deflater, level, wbits, strategy, zdict); + return PFactory.createJavaZLibCompObjectCompress(PythonLanguage.get(null), deflater, level, wbits, strategy, zdict); } @SuppressWarnings("unused") @@ -742,30 +740,30 @@ protected static boolean isValidWBitRange(int wbits) { } @Specialization(guards = {"useNative()"}) - Object doNative(int wbits, byte[] zdict, + static Object doNative(int wbits, byte[] zdict, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached NativeLibrary.InvokeNativeFunction createCompObject, @Cached NativeLibrary.InvokeNativeFunction decompressObjInit, - @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling, - @Cached PythonObjectFactory factory) { - NFIZlibSupport zlibSupport = PythonContext.get(this).getNFIZlibSupport(); + @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { + NFIZlibSupport zlibSupport = context.getNFIZlibSupport(); Object zst = zlibSupport.createCompObject(createCompObject); int err; if (zdict.length > 0) { - err = zlibSupport.decompressObjInitWithDict(zst, wbits, PythonContext.get(this).getEnv().asGuestValue(zdict), zdict.length, decompressObjInit); + err = zlibSupport.decompressObjInitWithDict(zst, wbits, context.getEnv().asGuestValue(zdict), zdict.length, decompressObjInit); } else { err = zlibSupport.decompressObjInit(zst, wbits, decompressObjInit); } if (err != Z_OK) { errorHandling.execute(inliningTarget, zst, err, zlibSupport, true); } - return factory.createNativeZLibCompObject(ZlibDecompress, zst, zlibSupport); + return PFactory.createNativeZLibCompObjectDecompress(context.getLanguage(inliningTarget), zst, zlibSupport); } - @CompilerDirectives.TruffleBoundary + @TruffleBoundary @Specialization(guards = {"!useNative()", "isValidWBitRange(wbits)"}) - Object doJava(int wbits, byte[] zdict) { + static Object doJava(int wbits, byte[] zdict) { // wbits < 0: generate a RAW stream, i.e., no wrapping // wbits 25..31: gzip container, i.e., no wrapping // Otherwise: wrap stream with zlib header and trailer @@ -774,10 +772,10 @@ Object doJava(int wbits, byte[] zdict) { if (isRAW && zdict.length > 0) { inflater.setDictionary(zdict); } - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - ZLibCompObject obj = factory.createJavaZLibCompObject(ZlibDecompress, inflater, wbits, zdict); - obj.setUnusedData(factory.createEmptyBytes()); - obj.setUnconsumedTail(factory.createEmptyBytes()); + PythonLanguage language = PythonLanguage.get(null); + ZLibCompObject obj = PFactory.createJavaZLibCompObjectDecompress(language, inflater, wbits, zdict); + obj.setUnusedData(PFactory.createEmptyBytes(language)); + obj.setUnconsumedTail(PFactory.createEmptyBytes(language)); return obj; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java index 689b562d9f..7c35370221 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -54,6 +54,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -74,12 +75,11 @@ import com.oracle.graal.python.runtime.NFIZlibSupport; import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -105,10 +105,10 @@ abstract static class CompressNode extends PythonBinaryClinicBuiltinNode { @Specialization static PBytes compress(VirtualFrame frame, ZLibCompObject self, Object buffer, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached CompressInnerNode innerNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { if (!self.isInitialized()) { @@ -116,7 +116,7 @@ static PBytes compress(VirtualFrame frame, ZLibCompObject self, Object buffer, } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); - return factory.createBytes(innerNode.execute(inliningTarget, self, bytes, len)); + return PFactory.createBytes(language, innerNode.execute(inliningTarget, self, bytes, len)); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -153,42 +153,43 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateCached(false) abstract static class BaseCopyNode extends PNodeWithContext { - public abstract Object execute(Node inliningTarget, ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory); + public abstract Object execute(Node inliningTarget, ZLibCompObject self); @Specialization(guards = "self.isInitialized()") - static Object doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static Object doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, + @Bind PythonContext context, @Cached(inline = false) NativeLibrary.InvokeNativeFunction createCompObject, @Cached(inline = false) NativeLibrary.InvokeNativeFunction compressObjCopy, @Cached(inline = false) NativeLibrary.InvokeNativeFunction deallocateStream, @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { synchronized (self) { assert self.isInitialized(); - NFIZlibSupport zlibSupport = ctxt.getNFIZlibSupport(); + NFIZlibSupport zlibSupport = context.getNFIZlibSupport(); Object zstNewCopy = zlibSupport.createCompObject(createCompObject); int err = zlibSupport.compressObjCopy(self.getZst(), zstNewCopy, compressObjCopy); if (err != Z_OK) { zlibSupport.deallocateStream(zstNewCopy, deallocateStream); errorHandling.execute(inliningTarget, self.getZst(), err, zlibSupport, false); } - return factory.createNativeZLibCompObject(ZlibCompress, zstNewCopy, zlibSupport); + return PFactory.createNativeZLibCompObjectCompress(context.getLanguage(inliningTarget), zstNewCopy, zlibSupport); } } @Specialization(guards = {"self.isInitialized()", "self.canCopy()"}) - static Object doJava(ZLibCompObject.JavaZlibCompObject self, @SuppressWarnings("unused") PythonContext ctxt, PythonObjectFactory factory) { - return self.copyCompressObj(factory); + static Object doJava(ZLibCompObject.JavaZlibCompObject self) { + return self.copyCompressObj(); } @SuppressWarnings("unused") @Specialization(guards = {"self.isInitialized()", "!self.canCopy()"}) - static PNone error(ZLibCompObject.JavaZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static PNone error(ZLibCompObject.JavaZlibCompObject self, @Cached.Shared @Cached(inline = false) PRaiseNode raise) { throw raise.raise(NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); } @SuppressWarnings("unused") @Specialization(guards = "!self.isInitialized()") - static PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static PNone error(ZLibCompObject self, @Cached.Shared @Cached(inline = false) PRaiseNode raise) { throw raise.raise(ValueError, ErrorMessages.INCONSISTENT_STREAM_STATE); } @@ -200,9 +201,8 @@ abstract static class CopyNode extends PythonUnaryBuiltinNode { @Specialization static Object doit(ZLibCompObject self, @Bind("this") Node inliningTarget, - @Cached BaseCopyNode copyNode, - @Cached PythonObjectFactory factory) { - return copyNode.execute(inliningTarget, self, PythonContext.get(inliningTarget), factory); + @Cached BaseCopyNode copyNode) { + return copyNode.execute(inliningTarget, self); } } @@ -217,9 +217,8 @@ abstract static class DeepCopyNode extends PythonBinaryBuiltinNode { @Specialization static Object doit(ZLibCompObject self, @SuppressWarnings("unused") Object memo, @Bind("this") Node inliningTarget, - @Cached BaseCopyNode copyNode, - @Cached PythonObjectFactory factory) { - return copyNode.execute(inliningTarget, self, PythonContext.get(inliningTarget), factory); + @Cached BaseCopyNode copyNode) { + return copyNode.execute(inliningTarget, self); } } @@ -237,8 +236,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @SuppressWarnings("unused") @Specialization(guards = "mode == Z_NO_FLUSH") static PBytes empty(ZLibCompObject self, int mode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEmptyBytes(); + @Bind PythonLanguage language) { + return PFactory.createEmptyBytes(language); } @Specialization(guards = {"mode != Z_NO_FLUSH", "self.isInitialized()"}) @@ -248,16 +247,15 @@ static PBytes doit(ZLibCompObject.NativeZlibCompObject self, int mode, @Cached ZlibNodes.GetNativeBufferNode getBuffer, @Cached NativeLibrary.InvokeNativeFunction getIsInitialised, @Cached ZlibNodes.NativeDeallocation processDeallocation, - @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling, - @Shared @Cached PythonObjectFactory factory) { + @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { synchronized (self) { assert self.isInitialized(); - PythonContext ctxt = PythonContext.get(inliningTarget); - NFIZlibSupport zlibSupport = ctxt.getNFIZlibSupport(); + PythonContext context = PythonContext.get(inliningTarget); + NFIZlibSupport zlibSupport = context.getNFIZlibSupport(); Object lastInput; if (self.lastInput == null) { // all previous input data has been processed or nothing has been compressed. - lastInput = ctxt.getEnv().asGuestValue(PythonUtils.EMPTY_BYTE_ARRAY); + lastInput = context.getEnv().asGuestValue(PythonUtils.EMPTY_BYTE_ARRAY); } else { // pass the last data input to continue processing. // all other needed info, e.g. size and offset, about the last data input is @@ -268,18 +266,18 @@ static PBytes doit(ZLibCompObject.NativeZlibCompObject self, int mode, if (err != Z_OK) { errorHandling.execute(inliningTarget, self.getZst(), err, zlibSupport, false); } - byte[] resultArray = getBuffer.getOutputBuffer(inliningTarget, self.getZst(), ctxt); + byte[] resultArray = getBuffer.getOutputBuffer(inliningTarget, self.getZst(), context); if (zlibSupport.getIsInitialised(self.getZst(), getIsInitialised) == 0) { - processDeallocation.execute(inliningTarget, self, ctxt, factory, true); + processDeallocation.execute(inliningTarget, self, context, true); } - return factory.createBytes(resultArray); + return PFactory.createBytes(context.getLanguage(inliningTarget), resultArray); } } @Specialization(guards = {"mode != Z_NO_FLUSH", "self.isInitialized()"}) static PBytes doit(ZLibCompObject.JavaZlibCompObject self, int mode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(ZlibNodes.JavaCompressNode.execute(self, mode)); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, ZlibNodes.JavaCompressNode.execute(self, mode)); } @SuppressWarnings("unused") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java index 52e0aa4467..eec33b9332 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -76,11 +77,10 @@ import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -111,10 +111,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PBytes decompress(VirtualFrame frame, ZLibCompObject self, Object buffer, int maxLength, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached DecompressInnerNode innerNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { if (!self.isInitialized()) { @@ -125,7 +125,7 @@ static PBytes decompress(VirtualFrame frame, ZLibCompObject self, Object buffer, } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); - return factory.createBytes(innerNode.execute(frame, inliningTarget, self, bytes, len, maxLength)); + return PFactory.createBytes(language, innerNode.execute(frame, inliningTarget, self, bytes, len, maxLength)); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -146,9 +146,8 @@ static byte[] doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject @Specialization static byte[] doJava(VirtualFrame frame, Node inliningTarget, ZLibCompObject.JavaZlibCompObject self, byte[] bytes, int length, int maxLength, - @Cached(inline = false) BytesNodes.ToBytesNode toBytes, - @Cached(inline = false) PythonObjectFactory factory) { - return ZlibNodes.JavaDecompressor.execute(frame, self, bytes, length, maxLength, DEF_BUF_SIZE, inliningTarget, factory, toBytes); + @Cached(inline = false) BytesNodes.ToBytesNode toBytes) { + return ZlibNodes.JavaDecompressor.execute(frame, self, bytes, length, maxLength, DEF_BUF_SIZE, inliningTarget, toBytes); } } } @@ -157,44 +156,45 @@ static byte[] doJava(VirtualFrame frame, Node inliningTarget, ZLibCompObject.Jav @GenerateCached(false) abstract static class BaseCopyNode extends PNodeWithContext { - public abstract Object execute(Node inliningTarget, ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory); + public abstract Object execute(Node inliningTarget, ZLibCompObject self); @Specialization(guards = "self.isInitialized()") - static Object doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static Object doNative(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, + @Bind PythonContext context, @Cached(inline = false) NativeLibrary.InvokeNativeFunction createCompObject, @Cached(inline = false) NativeLibrary.InvokeNativeFunction decompressObjCopy, @Cached(inline = false) NativeLibrary.InvokeNativeFunction deallocateStream, @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { synchronized (self) { assert self.isInitialized(); - NFIZlibSupport zlibSupport = ctxt.getNFIZlibSupport(); + NFIZlibSupport zlibSupport = context.getNFIZlibSupport(); Object zstNewCopy = zlibSupport.createCompObject(createCompObject); int err = zlibSupport.decompressObjCopy(self.getZst(), zstNewCopy, decompressObjCopy); if (err != Z_OK) { zlibSupport.deallocateStream(zstNewCopy, deallocateStream); errorHandling.execute(inliningTarget, self.getZst(), err, zlibSupport, false); } - ZLibCompObject copy = factory.createNativeZLibCompObject(ZlibDecompress, zstNewCopy, zlibSupport); + ZLibCompObject copy = PFactory.createNativeZLibCompObjectDecompress(context.getLanguage(inliningTarget), zstNewCopy, zlibSupport); copy.setEof(self.isEof()); return copy; } } @Specialization(guards = {"self.isInitialized()", "self.canCopy()"}) - static Object doJava(Node inliningTarget, ZLibCompObject.JavaZlibCompObject self, @SuppressWarnings("unused") PythonContext ctxt, PythonObjectFactory factory) { - return self.copyDecompressObj(factory, inliningTarget); + static Object doJava(Node inliningTarget, ZLibCompObject.JavaZlibCompObject self) { + return self.copyDecompressObj(inliningTarget); } @SuppressWarnings("unused") @Specialization(guards = {"self.isInitialized()", "!self.canCopy()"}) - static PNone error(ZLibCompObject.JavaZlibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static PNone error(ZLibCompObject.JavaZlibCompObject self, @Cached.Shared @Cached(inline = false) PRaiseNode raise) { throw raise.raise(NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); } @SuppressWarnings("unused") @Specialization(guards = "!self.isInitialized()") - static PNone error(ZLibCompObject self, PythonContext ctxt, PythonObjectFactory factory, + static PNone error(ZLibCompObject self, @Cached.Shared @Cached(inline = false) PRaiseNode raise) { throw raise.raise(ValueError, INCONSISTENT_STREAM_STATE); } @@ -206,9 +206,8 @@ abstract static class CopyNode extends PythonUnaryBuiltinNode { @Specialization static Object doit(ZLibCompObject self, @Bind("this") Node inliningTarget, - @Cached BaseCopyNode copyNode, - @Cached PythonObjectFactory factory) { - return copyNode.execute(inliningTarget, self, PythonContext.get(inliningTarget), factory); + @Cached BaseCopyNode copyNode) { + return copyNode.execute(inliningTarget, self); } } @@ -223,9 +222,8 @@ abstract static class DeepCopyNode extends PythonBinaryBuiltinNode { @Specialization static Object doit(ZLibCompObject self, @SuppressWarnings("unused") Object memo, @Bind("this") Node inliningTarget, - @Cached BaseCopyNode copyNode, - @Cached PythonObjectFactory factory) { - return copyNode.execute(inliningTarget, self, PythonContext.get(inliningTarget), factory); + @Cached BaseCopyNode copyNode) { + return copyNode.execute(inliningTarget, self); } } @@ -242,57 +240,56 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = {"length > 0", "!self.isEof()", "self.isInitialized()"}) static PBytes doit(ZLibCompObject.NativeZlibCompObject self, int length, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached NativeLibrary.InvokeNativeFunction decompressObjFlush, @Cached ZlibNodes.GetNativeBufferNode getBuffer, @Cached NativeLibrary.InvokeNativeFunction getIsInitialised, @Cached ZlibNodes.NativeDeallocation processDeallocation, - @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling, - @Shared @Cached PythonObjectFactory factory) { + @Cached ZlibNodes.ZlibNativeErrorHandling errorHandling) { synchronized (self) { - PythonContext ctxt = PythonContext.get(inliningTarget); assert self.isInitialized(); - NFIZlibSupport zlibSupport = ctxt.getNFIZlibSupport(); + NFIZlibSupport zlibSupport = context.getNFIZlibSupport(); int err = zlibSupport.decompressObjFlush(self.getZst(), length, decompressObjFlush); if (err != Z_OK) { errorHandling.execute(inliningTarget, self.getZst(), err, zlibSupport, false); } - byte[] resultArray = getBuffer.getOutputBuffer(inliningTarget, self.getZst(), ctxt); + byte[] resultArray = getBuffer.getOutputBuffer(inliningTarget, self.getZst(), context); if (zlibSupport.getIsInitialised(self.getZst(), getIsInitialised) == 0) { - processDeallocation.execute(inliningTarget, self, ctxt, factory, false); + processDeallocation.execute(inliningTarget, self, context, false); } - return factory.createBytes(resultArray); + return PFactory.createBytes(context.getLanguage(inliningTarget), resultArray); } } @Specialization(guards = {"length > 0", "!self.isEof()", "self.isInitialized()"}) PBytes doit(VirtualFrame frame, ZLibCompObject.JavaZlibCompObject self, int length, - @Cached BytesNodes.ToBytesNode toBytes, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached BytesNodes.ToBytesNode toBytes) { byte[] res; try { byte[] bytes = toBytes.execute(self.getUnconsumedTail()); - res = ZlibNodes.JavaDecompressor.execute(frame, self, bytes, bytes.length, 0, length, this, factory, toBytes); + res = ZlibNodes.JavaDecompressor.execute(frame, self, bytes, bytes.length, 0, length, this, toBytes); } catch (PException e) { // CPython ignores errors here res = PythonUtils.EMPTY_BYTE_ARRAY; } self.setUninitialized(); - return factory.createBytes(res); + return PFactory.createBytes(language, res); } @SuppressWarnings("unused") @Specialization(guards = {"length > 0", "self.isEof() || !self.isInitialized()"}) static PBytes empty(ZLibCompObject.JavaZlibCompObject self, int length, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { self.setUninitialized(); - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } @SuppressWarnings("unused") @Specialization(guards = {"length > 0", "self.isEof() || !self.isInitialized()"}) static PBytes empty(ZLibCompObject.NativeZlibCompObject self, int length, - @Shared @Cached PythonObjectFactory factory) { - return factory.createEmptyBytes(); + @Bind PythonLanguage language) { + return PFactory.createEmptyBytes(language); } @SuppressWarnings("unused") @@ -309,11 +306,11 @@ abstract static class UnusedDataNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.isInitialized()") static PBytes doit(ZLibCompObject.NativeZlibCompObject self, @Bind("this") Node inliningTarget, - @Cached ZlibNodes.GetNativeBufferNode getBuffer, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @Cached ZlibNodes.GetNativeBufferNode getBuffer) { synchronized (self) { assert self.isInitialized(); - return factory.createBytes(getBuffer.getUnusedDataBuffer(inliningTarget, self.getZst(), PythonContext.get(inliningTarget))); + return PFactory.createBytes(context.getLanguage(inliningTarget), getBuffer.getUnusedDataBuffer(inliningTarget, self.getZst(), context)); } } @@ -334,11 +331,11 @@ abstract static class UnconsumedTailNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.isInitialized()") static PBytes doit(ZLibCompObject.NativeZlibCompObject self, @Bind("this") Node inliningTarget, - @Cached ZlibNodes.GetNativeBufferNode getBuffer, - @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @Cached ZlibNodes.GetNativeBufferNode getBuffer) { synchronized (self) { assert self.isInitialized(); - return factory.createBytes(getBuffer.getUnconsumedTailBuffer(inliningTarget, self.getZst(), PythonContext.get(inliningTarget))); + return PFactory.createBytes(context.getLanguage(inliningTarget), getBuffer.getUnconsumedTailBuffer(inliningTarget, self.getZst(), context)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java index 77dd75769d..2b4a974768 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -73,6 +73,7 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.bytes.BytesNodes; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; @@ -82,7 +83,7 @@ import com.oracle.graal.python.runtime.NFIZlibSupport; import com.oracle.graal.python.runtime.NativeLibrary; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -469,10 +470,10 @@ void fallback(Object zst, int function, int err, NFIZlibSupport zlibSupport, boo @GenerateCached(false) public abstract static class NativeDeallocation extends PNodeWithContext { - public abstract void execute(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext context, PythonObjectFactory factory, boolean isCompressObj); + public abstract void execute(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext context, boolean isCompressObj); @Specialization(guards = "isCompressObj") - static void doCompressObj(ZLibCompObject.NativeZlibCompObject self, PythonContext context, @SuppressWarnings("unused") PythonObjectFactory factory, + static void doCompressObj(ZLibCompObject.NativeZlibCompObject self, PythonContext context, @SuppressWarnings("unused") boolean isCompressObj, @Shared @Cached(inline = false) NativeLibrary.InvokeNativeFunction deallocateStream) { context.getNFIZlibSupport().deallocateStream(self.getZst(), deallocateStream); @@ -481,15 +482,16 @@ static void doCompressObj(ZLibCompObject.NativeZlibCompObject self, PythonContex } @Specialization(guards = "!isCompressObj") - static void doDecompressObj(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext context, PythonObjectFactory factory, + static void doDecompressObj(Node inliningTarget, ZLibCompObject.NativeZlibCompObject self, PythonContext context, @SuppressWarnings("unused") boolean isCompressObj, @Cached GetNativeBufferNode getUnusedDataBuffer, @Cached GetNativeBufferNode getUnconsumedBuffer, @Shared @Cached(inline = false) NativeLibrary.InvokeNativeFunction deallocateStream) { byte[] unusedData = getUnusedDataBuffer.getUnusedDataBuffer(inliningTarget, self.getZst(), context); - self.setUnusedData(factory.createBytes(unusedData)); + PythonLanguage language = context.getLanguage(inliningTarget); + self.setUnusedData(PFactory.createBytes(language, unusedData)); byte[] unconsumed = getUnconsumedBuffer.getUnconsumedTailBuffer(inliningTarget, self.getZst(), context); - self.setUnconsumedTail(factory.createBytes(unconsumed)); + self.setUnconsumedTail(PFactory.createBytes(language, unconsumed)); context.getNFIZlibSupport().deallocateStream(self.getZst(), deallocateStream); self.setEof(true); self.markReleased(); @@ -594,35 +596,36 @@ private static byte[] createByteArray(ZLibCompObject.JavaZlibCompObject self, In } public static byte[] execute(VirtualFrame frame, ZLibCompObject.JavaZlibCompObject self, byte[] bytes, int length, int maxLength, int bufSize, - Node nodeForRaise, PythonObjectFactory factory, BytesNodes.ToBytesNode toBytesNode) { + Node inliningTarget, BytesNodes.ToBytesNode toBytesNode) { Inflater inflater = (Inflater) self.stream; - byte[] result = createByteArray(self, inflater, bytes, length, maxLength, bufSize, nodeForRaise); + byte[] result = createByteArray(self, inflater, bytes, length, maxLength, bufSize, inliningTarget); self.setEof(isFinished(inflater)); byte[] unusedDataBytes = toBytesNode.execute(frame, self.getUnusedData()); int unconsumedTailLen = self.getUnconsumedTail().getSequenceStorage().length(); - saveUnconsumedInput(self, bytes, length, unusedDataBytes, unconsumedTailLen, factory); + saveUnconsumedInput(self, bytes, length, unusedDataBytes, unconsumedTailLen, inliningTarget); return result; } private static void saveUnconsumedInput(ZLibCompObject.JavaZlibCompObject self, byte[] data, int length, - byte[] unusedDataBytes, int unconsumedTailLen, PythonObjectFactory factory) { + byte[] unusedDataBytes, int unconsumedTailLen, Node inliningTarget) { Inflater inflater = (Inflater) self.stream; int unusedLen = getRemaining(inflater); byte[] tail = PythonUtils.arrayCopyOfRange(data, length - unusedLen, length); + PythonLanguage language = PythonLanguage.get(inliningTarget); if (self.isEof()) { if (unconsumedTailLen > 0) { - self.setUnconsumedTail(factory.createEmptyBytes()); + self.setUnconsumedTail(PFactory.createEmptyBytes(language)); } if (unusedDataBytes.length > 0 && tail.length > 0) { byte[] newUnusedData = new byte[unusedDataBytes.length + tail.length]; PythonUtils.arraycopy(unusedDataBytes, 0, newUnusedData, 0, unusedDataBytes.length); PythonUtils.arraycopy(tail, 0, newUnusedData, unusedDataBytes.length, tail.length); - self.setUnusedData(factory.createBytes(newUnusedData)); + self.setUnusedData(PFactory.createBytes(language, newUnusedData)); } else if (tail.length > 0) { - self.setUnusedData(factory.createBytes(tail)); + self.setUnusedData(PFactory.createBytes(language, tail)); } } else { - self.setUnconsumedTail(factory.createBytes(tail)); + self.setUnconsumedTail(PFactory.createBytes(language, tail)); } } 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 bc9233c76e..6152dda06f 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 @@ -153,7 +153,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; @@ -1592,7 +1592,6 @@ public boolean hasMetaParents( @ExportMessage public Object getMetaParents( @Bind("$node") Node inliningTarget, - @Exclusive @Cached PythonObjectFactory factory, @Exclusive @Cached TypeNodes.IsTypeNode isTypeNode, @Exclusive @Cached TypeNodes.GetBaseClassesNode getBaseClassNode, @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { @@ -1601,7 +1600,7 @@ public Object getMetaParents( if (isTypeNode.execute(inliningTarget, this)) { var bases = getBaseClassNode.execute(inliningTarget, this); if (bases.length > 0) { - return factory.createTuple(bases); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), bases); } } throw UnsupportedMessageException.create(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index 329a6cbf18..0710f48b4d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -63,6 +63,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -125,7 +126,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -178,11 +179,11 @@ abstract static class ConcatNode extends SqConcatBuiltinNode { @Specialization(guards = "left.getFormat() == right.getFormat()") Object concat(PArray left, PArray right, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { int newLength = PythonUtils.addExact(left.getLength(), right.getLength()); int itemShift = left.getItemSizeShift(); - PArray newArray = factory.createArray(left.getFormatString(), left.getFormat(), newLength); + PArray newArray = PFactory.createArray(language, left.getFormatString(), left.getFormat(), newLength); bufferLib.readIntoBuffer(left.getBuffer(), 0, newArray.getBuffer(), 0, left.getLength() << itemShift, bufferLib); bufferLib.readIntoBuffer(right.getBuffer(), 0, newArray.getBuffer(), left.getLength() << itemShift, right.getLength() << itemShift, bufferLib); return newArray; @@ -232,7 +233,7 @@ static PArray concat(PArray self, int valueIn, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Cached InlinedBranchProfile negativeSize, @Cached InlinedLoopConditionProfile loopProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int value = valueIn; if (value < 0) { negativeSize.enter(inliningTarget); @@ -240,7 +241,7 @@ static PArray concat(PArray self, int valueIn, } try { int newLength = Math.max(PythonUtils.multiplyExact(self.getLength(), value), 0); - PArray newArray = factory.createArray(self.getFormatString(), self.getFormat(), newLength); + PArray newArray = PFactory.createArray(language, self.getFormatString(), self.getFormat(), newLength); int segmentLength = self.getBytesLength(); loopProfile.profileCounted(inliningTarget, value); for (int i = 0; loopProfile.inject(inliningTarget, i < value); i++) { @@ -601,13 +602,13 @@ static Object doSlice(PArray self, PSlice slice, @Exclusive @Cached InlinedConditionProfile simpleStepProfile, @Cached SliceNodes.SliceUnpack sliceUnpack, @Cached SliceNodes.AdjustIndices adjustIndices, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PSlice.SliceInfo sliceInfo = adjustIndices.execute(inliningTarget, self.getLength(), sliceUnpack.execute(inliningTarget, slice)); int itemShift = itemShiftProfile.profile(inliningTarget, (byte) self.getItemSizeShift()); int itemsize = self.getItemSize(); PArray newArray; try { - newArray = factory.createArray(self.getFormatString(), self.getFormat(), sliceInfo.sliceLength); + newArray = PFactory.createArray(language, self.getFormatString(), self.getFormat(), sliceInfo.sliceLength); } catch (OverflowException e) { // It's a slice of existing array, the length cannot overflow throw CompilerDirectives.shouldNotReachHere(); @@ -782,8 +783,8 @@ abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object getitem(PArray self, - @Cached PythonObjectFactory factory) { - return factory.createArrayIterator(self); + @Bind PythonLanguage language) { + return PFactory.createArrayIterator(language, self); } } @@ -814,14 +815,14 @@ static Object reduceLegacy(VirtualFrame frame, PArray self, @SuppressWarnings("u @Cached @Exclusive GetClassNode getClassNode, @Cached @Exclusive PyObjectLookupAttr lookupDict, @Cached ToListNode toListNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object cls = getClassNode.execute(inliningTarget, self); Object dict = lookupDict.execute(frame, inliningTarget, self, T___DICT__); if (dict == PNone.NO_VALUE) { dict = PNone.NONE; } - PTuple args = factory.createTuple(new Object[]{self.getFormatString(), toListNode.execute(frame, self)}); - return factory.createTuple(new Object[]{cls, args, dict}); + PTuple args = PFactory.createTuple(language, new Object[]{self.getFormatString(), toListNode.execute(frame, self)}); + return PFactory.createTuple(language, new Object[]{cls, args, dict}); } @Specialization(guards = "protocol >= 3") @@ -831,7 +832,7 @@ static Object reduce(VirtualFrame frame, PArray self, @SuppressWarnings("unused" @Cached @Exclusive PyObjectLookupAttr lookupDict, @Cached PyObjectGetAttr getReconstructor, @Cached ToBytesNode toBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule arrayModule = PythonContext.get(inliningTarget).lookupBuiltinModule(T_ARRAY); PArray.MachineFormat mformat = PArray.MachineFormat.forFormat(self.getFormat()); assert mformat != null; @@ -841,8 +842,8 @@ static Object reduce(VirtualFrame frame, PArray self, @SuppressWarnings("unused" dict = PNone.NONE; } Object reconstructor = getReconstructor.execute(frame, inliningTarget, arrayModule, T_ARRAY_RECONSTRUCTOR); - PTuple args = factory.createTuple(new Object[]{cls, self.getFormatString(), mformat.code, toBytesNode.execute(frame, self)}); - return factory.createTuple(new Object[]{reconstructor, args, dict}); + PTuple args = PFactory.createTuple(language, new Object[]{cls, self.getFormatString(), mformat.code, toBytesNode.execute(frame, self)}); + return PFactory.createTuple(language, new Object[]{reconstructor, args, dict}); } } @@ -873,8 +874,8 @@ abstract static class BufferInfoNode extends PythonUnaryBuiltinNode { @Specialization static Object bufferinfo(PArray self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached ArrayNodes.EnsureNativeStorageNode ensureNativeStorageNode, - @Cached PythonObjectFactory factory, @CachedLibrary(limit = "1") InteropLibrary lib) { Object nativePointer = ensureNativeStorageNode.execute(inliningTarget, self).getPtr(); if (!(nativePointer instanceof Long)) { @@ -885,7 +886,7 @@ static Object bufferinfo(PArray self, throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError); } } - return factory.createTuple(new Object[]{nativePointer, self.getLength()}); + return PFactory.createTuple(language, new Object[]{nativePointer, self.getLength()}); } } @@ -1274,10 +1275,10 @@ abstract static class ToBytesNode extends PythonUnaryBuiltinNode { @Specialization Object tobytes(PArray self, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { byte[] bytes = new byte[self.getBytesLength()]; bufferLib.readIntoByteArray(self.getBuffer(), 0, bytes, 0, bytes.length); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } } @@ -1320,9 +1321,9 @@ abstract static class ToFileNode extends PythonBinaryBuiltinNode { @Specialization static Object tofile(VirtualFrame frame, PArray self, Object file, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PythonObjectFactory factory) { + @Cached PyObjectCallMethodObjArgs callMethod) { if (self.getLength() > 0) { int remaining = self.getBytesLength(); int blocksize = 64 * 1024; @@ -1335,7 +1336,7 @@ static Object tofile(VirtualFrame frame, PArray self, Object file, buffer = new byte[blocksize]; } bufferLib.readIntoByteArray(self.getBuffer(), i * blocksize, buffer, 0, buffer.length); - callMethod.execute(frame, inliningTarget, file, T_WRITE, factory.createBytes(buffer)); + callMethod.execute(frame, inliningTarget, file, T_WRITE, PFactory.createBytes(language, buffer)); remaining -= blocksize; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java index 68462f32e7..87c31b135b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -86,11 +86,11 @@ public PArray(Object clazz, Shape instanceShape, TruffleString formatString, Buf this.storage = new ByteSequenceStorage(EMPTY_BYTE_ARRAY); } - public PArray(Object clazz, Shape instanceShape, TruffleString formatString, BufferFormat format, int length) throws OverflowException { + public PArray(Object clazz, Shape instanceShape, TruffleString formatString, BufferFormat format, int byteSize) { super(clazz, instanceShape); this.formatString = formatString; this.format = format; - this.storage = new ByteSequenceStorage(new byte[PythonUtils.multiplyExact(length, format.bytesize)]); + this.storage = new ByteSequenceStorage(new byte[byteSize]); } public BufferFormat getFormat() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGeneratorBuiltins.java index 021f85aff3..07e0fca228 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGeneratorBuiltins.java @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -58,7 +59,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -93,9 +94,8 @@ public abstract static class GetCode extends PythonUnaryBuiltinNode { @Specialization static Object getCode(PAsyncGen self, @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile hasCodeProfile, - @Cached PythonObjectFactory.Lazy factory) { - return self.getOrCreateCode(inliningTarget, hasCodeProfile, factory); + @Cached InlinedConditionProfile hasCodeProfile) { + return self.getOrCreateCode(inliningTarget, hasCodeProfile); } } @@ -136,9 +136,9 @@ static Object aSend(VirtualFrame frame, PAsyncGen self, Object sent, @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached CallUnaryMethodNode callFirstIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { callHooks(frame, self, context.getThreadState(context.getLanguage(inliningTarget)), callFirstIter); - return factory.createAsyncGeneratorASend(self, sent); + return PFactory.createAsyncGeneratorASend(language, self, sent); } } @@ -152,9 +152,9 @@ static Object athrow(VirtualFrame frame, PAsyncGen self, Object arg1, Object arg @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached CallUnaryMethodNode callFirstIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { callHooks(frame, self, context.getThreadState(context.getLanguage(inliningTarget)), callFirstIter); - return factory.createAsyncGeneratorAThrow(self, arg1, arg2, arg3); + return PFactory.createAsyncGeneratorAThrow(language, self, arg1, arg2, arg3); } } @@ -175,9 +175,9 @@ static Object aNext(VirtualFrame frame, PAsyncGen self, @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached CallUnaryMethodNode callFirstIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { callHooks(frame, self, context.getThreadState(context.getLanguage(inliningTarget)), callFirstIter); - return factory.createAsyncGeneratorASend(self, PNone.NONE); + return PFactory.createAsyncGeneratorASend(language, self, PNone.NONE); } } @@ -189,9 +189,9 @@ Object aClose(VirtualFrame frame, PAsyncGen self, @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached CallUnaryMethodNode callFirstIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { callHooks(frame, self, context.getThreadState(context.getLanguage(inliningTarget)), callFirstIter); - return factory.createAsyncGeneratorAThrow(self, null, PNone.NO_VALUE, PNone.NO_VALUE); + return PFactory.createAsyncGeneratorAThrow(language, self, null, PNone.NO_VALUE, PNone.NO_VALUE); } } @@ -200,8 +200,8 @@ Object aClose(VirtualFrame frame, PAsyncGen self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index 381fc26369..a50c5fc9f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -78,7 +79,6 @@ import com.oracle.graal.python.builtins.objects.slice.SliceNodes; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode; @@ -106,7 +106,7 @@ import com.oracle.graal.python.nodes.util.CastToByteNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -203,9 +203,7 @@ abstract static class GetitemNode extends SqItemBuiltinNode { static Object doInt(Object self, int key, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Cached BytesNodes.GetBytesStorage getBytesStorage, - @Cached PRaiseNode.Lazy raiseNode, - @Cached SequenceStorageSqItemNode sqItemNode, - @Cached SequenceStorageNodes.GetItemScalarNode getItemNode) { + @Cached SequenceStorageSqItemNode sqItemNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); return sqItemNode.execute(inliningTarget, storage, key, ErrorMessages.BYTEARRAY_OUT_OF_BOUNDS); } @@ -226,7 +224,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, throw raiseNonIntIndex(inliningTarget, raiseNode, idx); } return subscriptNode.execute(frame, inliningTarget, getBytesStorage.execute(inliningTarget, self), idx, - ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PythonObjectFactory::createByteArray); + ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PFactory::createByteArray); } @InliningCutoff @@ -302,6 +300,7 @@ static void doSliceSequence(VirtualFrame frame, PByteArray self, PSlice slice, P @Specialization(guards = {"!isNoValue(value)", "bufferAcquireLib.hasBuffer(value)"}, limit = "3") static void doSliceBuffer(VirtualFrame frame, PByteArray self, PSlice slice, Object value, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("value") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @@ -311,12 +310,11 @@ static void doSliceBuffer(VirtualFrame frame, PByteArray self, PSlice slice, Obj @Cached @Shared SliceNodes.CoerceToIntSlice sliceCast, @Cached @Shared SliceNodes.SliceUnpack unpack, @Cached @Shared SliceNodes.AdjustIndices adjustIndices, - @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(value, frame, indirectCallData); try { // TODO avoid copying if possible. Note that it is possible that value is self - PBytes bytes = factory.createBytes(bufferLib.getCopiedByteArray(value)); + PBytes bytes = PFactory.createBytes(language, bufferLib.getCopiedByteArray(value)); doSliceSequence(frame, self, slice, bytes, inliningTarget, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, unpack, adjustIndices, raiseNode); } finally { bufferLib.release(buffer, frame, indirectCallData); @@ -445,11 +443,11 @@ static PByteArray add(PByteArray self, PBytesLike other, @Specialization(guards = "!isBytes(other)", limit = "3") static PByteArray add(VirtualFrame frame, PByteArray self, Object other, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("other") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached @Shared SequenceStorageNodes.ConcatNode concatNode, - @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { Object buffer; try { @@ -460,7 +458,7 @@ static PByteArray add(VirtualFrame frame, PByteArray self, Object other, try { self.checkCanResize(inliningTarget, raiseNode); // TODO avoid copying - PBytes bytes = factory.createBytes(bufferLib.getCopiedByteArray(buffer)); + PBytes bytes = PFactory.createBytes(language, bufferLib.getCopiedByteArray(buffer)); SequenceStorage res = concatNode.execute(self.getSequenceStorage(), bytes.getSequenceStorage()); updateSequenceStorage(self, res); return self; @@ -640,6 +638,7 @@ static PNone doBytes(VirtualFrame frame, PByteArray self, PBytesLike source, @Specialization(guards = "!isBytes(source)", limit = "3") static PNone doGeneric(VirtualFrame frame, PByteArray self, Object source, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("source") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @@ -647,7 +646,6 @@ static PNone doGeneric(VirtualFrame frame, PByteArray self, Object source, @Cached BytesNodes.IterableToByteNode iterableToByteNode, @Cached IsBuiltinObjectProfile errorProfile, @Cached("createExtend()") @Shared SequenceStorageNodes.ExtendNode extendNode, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { self.checkCanResize(inliningTarget, raiseNode); byte[] b; @@ -667,7 +665,7 @@ static PNone doGeneric(VirtualFrame frame, PByteArray self, Object source, throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_EXTEND_BYTEARRAY_WITH_P, source); } } - PByteArray bytes = factory.createByteArray(b); + PByteArray bytes = PFactory.createByteArray(language, b); extend(frame, self, bytes, b.length, extendNode); return PNone.NONE; } @@ -691,10 +689,12 @@ public abstract static class CopyNode extends PythonBuiltinNode { @Specialization static PByteArray copy(PByteArray byteArray, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetClassNode getClassNode, - @Cached SequenceStorageNodes.ToByteArrayNode toByteArray, - @Cached PythonObjectFactory factory) { - return factory.createByteArray(getClassNode.execute(inliningTarget, byteArray), toByteArray.execute(inliningTarget, byteArray.getSequenceStorage())); + @Cached TypeNodes.GetInstanceShape getInstanceShape, + @Cached SequenceStorageNodes.ToByteArrayNode toByteArray) { + Object cls = getClassNode.execute(inliningTarget, byteArray); + return PFactory.createByteArray(language, cls, getInstanceShape.execute(cls), toByteArray.execute(inliningTarget, byteArray.getSequenceStorage())); } } @@ -735,28 +735,24 @@ static PNone clear(VirtualFrame frame, PByteArray byteArray, @GenerateNodeFactory public abstract static class FromHexNode extends PythonBinaryClinicBuiltinNode { - @Specialization(guards = "isBuiltinBytesType(inliningTarget, cls, isSameType)") - static PByteArray doBytes(Object cls, TruffleString str, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("isSameType") @Cached IsSameTypeNode isSameType, + @Specialization(guards = "isBuiltinByteArrayType(cls)") + static PByteArray doBytes(@SuppressWarnings("unused") Object cls, TruffleString str, @Shared("hexToBytes") @Cached HexStringToBytesNode hexStringToBytesNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createByteArray(cls, hexStringToBytesNode.execute(str)); + @Bind PythonLanguage language) { + return PFactory.createByteArray(language, hexStringToBytesNode.execute(str)); } - @Specialization(guards = "!isBuiltinBytesType(inliningTarget, cls, isSameType)") + @Specialization(guards = "!isBuiltinByteArrayType(cls)") static Object doGeneric(VirtualFrame frame, Object cls, TruffleString str, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("isSameType") @Cached IsSameTypeNode isSameType, @Cached CallNode callNode, @Shared("hexToBytes") @Cached HexStringToBytesNode hexStringToBytesNode, - @Shared @Cached PythonObjectFactory factory) { - PByteArray byteArray = factory.createByteArray(hexStringToBytesNode.execute(str)); + @Bind PythonLanguage language) { + PByteArray byteArray = PFactory.createByteArray(language, hexStringToBytesNode.execute(str)); return callNode.execute(frame, cls, byteArray); } - protected static boolean isBuiltinBytesType(Node inliningTarget, Object cls, IsSameTypeNode isSameTypeNode) { - return isSameTypeNode.execute(inliningTarget, PythonBuiltinClassType.PBytes, cls); + protected static boolean isBuiltinByteArrayType(Object cls) { + return cls == PythonBuiltinClassType.PByteArray; } @Override @@ -773,11 +769,11 @@ public abstract static class TranslateNode extends BytesNodes.BaseTranslateNode @Specialization static PByteArray translate(VirtualFrame frame, PByteArray self, Object table, Object delete, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile isLenTable256Profile, @Cached InlinedBranchProfile hasTable, @Cached InlinedBranchProfile hasDelete, @Cached BytesNodes.ToBytesNode toBytesNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { byte[] bTable = null; if (table != PNone.NONE) { @@ -800,9 +796,9 @@ static PByteArray translate(VirtualFrame frame, PByteArray self, Object table, O } else if (bDelete != null) { result = delete(bSelf, bDelete); } else { - return factory.createByteArray(bSelf); + return PFactory.createByteArray(language, bSelf); } - return factory.createByteArray(result.array); + return PFactory.createByteArray(language, result.array); } } @@ -819,22 +815,22 @@ public static int alloc(PByteArray byteArray) { } } - protected static Object commonReduce(int proto, byte[] bytes, int len, Object clazz, Object dict, - PythonObjectFactory factory, TruffleStringBuilder.AppendCodePointNode appendCodePointNode, TruffleStringBuilder.ToStringNode toStringNode) { + static Object commonReduce(int proto, byte[] bytes, int len, Object clazz, Object dict, + PythonLanguage language, TruffleStringBuilder.AppendCodePointNode appendCodePointNode, TruffleStringBuilder.ToStringNode toStringNode) { TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); BytesUtils.repr(sb, bytes, len, appendCodePointNode); TruffleString str = toStringNode.execute(sb); Object contents; if (proto < 3) { - contents = factory.createTuple(new Object[]{str, T_LATIN_1}); + contents = PFactory.createTuple(language, new Object[]{str, T_LATIN_1}); } else { if (len > 0) { - contents = factory.createTuple(new Object[]{str, len}); + contents = PFactory.createTuple(language, new Object[]{str, len}); } else { - contents = factory.createTuple(new Object[0]); + contents = PFactory.createTuple(language, new Object[0]); } } - return factory.createTuple(new Object[]{clazz, contents, dict}); + return PFactory.createTuple(language, new Object[]{clazz, contents, dict}); } @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1) @@ -844,17 +840,17 @@ protected abstract static class ReduceNode extends PythonUnaryBuiltinNode { @Specialization static Object reduce(VirtualFrame frame, PByteArray self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached SequenceStorageNodes.GetInternalByteArrayNode getBytes, @Cached GetClassNode getClassNode, @Cached PyObjectGetStateNode getStateNode, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, - @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleStringBuilder.ToStringNode toStringNode) { byte[] bytes = getBytes.execute(inliningTarget, self.getSequenceStorage()); int len = self.getSequenceStorage().length(); Object state = getStateNode.execute(frame, inliningTarget, self); Object clazz = getClassNode.execute(inliningTarget, self); - return commonReduce(2, bytes, len, clazz, state, factory, appendCodePointNode, toStringNode); + return commonReduce(2, bytes, len, clazz, state, language, appendCodePointNode, toStringNode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java index 0bea205499..f2f0b369ec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java @@ -40,6 +40,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -54,7 +55,6 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.SequenceStorageSqItemNode; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.type.TpSlots; -import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode; import com.oracle.graal.python.lib.PyBytesCheckExactNode; @@ -70,7 +70,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -123,9 +123,7 @@ abstract static class GetitemNode extends SqItemBuiltinNode { static Object doInt(Object self, int key, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Cached BytesNodes.GetBytesStorage getBytesStorage, - @Cached PRaiseNode.Lazy raiseNode, - @Cached SequenceStorageSqItemNode sqItemNode, - @Cached SequenceStorageNodes.GetItemScalarNode getItemNode) { + @Cached SequenceStorageSqItemNode sqItemNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); return sqItemNode.execute(inliningTarget, storage, key, ErrorMessages.BYTES_OUT_OF_BOUNDS); } @@ -146,7 +144,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, throw raiseNonIntIndex(inliningTarget, raiseNode, idx); } return subscriptNode.execute(frame, inliningTarget, getBytesStorage.execute(inliningTarget, self), idx, - ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PythonObjectFactory::createBytes); + ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PFactory::createBytes); } @InliningCutoff @@ -174,11 +172,11 @@ public abstract static class TranslateNode extends BytesNodes.BaseTranslateNode @Specialization static Object translate(VirtualFrame frame, Object self, Object table, Object delete, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile isLenTable256Profile, @Cached InlinedBranchProfile hasTable, @Cached InlinedBranchProfile hasDelete, @Cached BytesNodes.ToBytesNode toBytesNode, - @Cached PythonObjectFactory factory, @Cached PyBytesCheckExactNode checkExactNode, @Cached PRaiseNode.Lazy raiseNode) { byte[] bTable = null; @@ -202,12 +200,12 @@ static Object translate(VirtualFrame frame, Object self, Object table, Object de } else if (bDelete != null) { result = delete(bSelf, bDelete); } else if (!checkExactNode.execute(inliningTarget, self)) { - return factory.createBytes(bSelf); + return PFactory.createBytes(language, bSelf); } else { return self; } if (result.changed || !checkExactNode.execute(inliningTarget, self)) { - return factory.createBytes(result.array); + return PFactory.createBytes(language, result.array); } return self; } @@ -219,28 +217,24 @@ static Object translate(VirtualFrame frame, Object self, Object table, Object de @GenerateNodeFactory public abstract static class FromHexNode extends PythonBinaryClinicBuiltinNode { - @Specialization(guards = "isBuiltinBytesType(inliningTarget, cls, isSameType)") - static PBytes doBytes(Object cls, TruffleString str, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("isSameType") @Cached TypeNodes.IsSameTypeNode isSameType, + @Specialization(guards = "isBuiltinBytesType(cls)") + static PBytes doBytes(@SuppressWarnings("unused") Object cls, TruffleString str, @Shared("hexToBytes") @Cached BytesNodes.HexStringToBytesNode hexStringToBytesNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBytes(cls, hexStringToBytesNode.execute(str)); + @Bind PythonLanguage language) { + return PFactory.createBytes(language, hexStringToBytesNode.execute(str)); } - @Specialization(guards = "!isBuiltinBytesType(inliningTarget, cls, isSameType)") + @Specialization(guards = "!isBuiltinBytesType(cls)") static Object doGeneric(VirtualFrame frame, Object cls, TruffleString str, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Shared("isSameType") @Cached TypeNodes.IsSameTypeNode isSameType, @Cached CallNode callNode, @Shared("hexToBytes") @Cached BytesNodes.HexStringToBytesNode hexStringToBytesNode, - @Shared @Cached PythonObjectFactory factory) { - PBytes bytes = factory.createBytes(hexStringToBytesNode.execute(str)); + @Bind PythonLanguage language) { + PBytes bytes = PFactory.createBytes(language, hexStringToBytesNode.execute(str)); return callNode.execute(frame, cls, bytes); } - protected static boolean isBuiltinBytesType(Node inliningTarget, Object cls, TypeNodes.IsSameTypeNode isSameTypeNode) { - return isSameTypeNode.execute(inliningTarget, PythonBuiltinClassType.PBytes, cls); + protected static boolean isBuiltinBytesType(Object cls) { + return cls == PythonBuiltinClassType.PBytes; } @Override @@ -362,13 +356,13 @@ abstract static class BytesNode extends PythonUnaryBuiltinNode { @Specialization static Object bytes(Object self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached PyBytesCheckExactNode check, - @Cached BytesNodes.GetBytesStorage getBytesStorage, - @Cached PythonObjectFactory.Lazy factory) { + @Cached BytesNodes.GetBytesStorage getBytesStorage) { if (check.execute(inliningTarget, self)) { return self; } else { - return factory.get(inliningTarget).createBytes(getBytesStorage.execute(inliningTarget, self)); + return PFactory.createBytes(language, getBytesStorage.execute(inliningTarget, self)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java index 6b02e3723a..ddd6c980a9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java @@ -133,7 +133,7 @@ import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.formatting.BytesFormatProcessor; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; @@ -277,10 +277,9 @@ static PBytesLike join(VirtualFrame frame, Object self, Object iterable, @Cached GetBytesStorage getBytesStorage, @Cached SequenceStorageNodes.ToByteArrayNode toByteArrayNode, @Cached BytesNodes.BytesJoinNode bytesJoinNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] res = bytesJoinNode.execute(frame, inliningTarget, toByteArrayNode.execute(inliningTarget, getBytesStorage.execute(inliningTarget, self)), iterable); - return create.execute(inliningTarget, factory, self, res); + return create.execute(inliningTarget, self, res); } } @@ -292,10 +291,9 @@ public abstract static class ConcatNode extends SqConcatBuiltinNode { static PBytesLike add(PBytesLike self, PBytesLike other, @Bind("this") Node node, @Cached("createWithOverflowError()") @Shared SequenceStorageNodes.ConcatNode concatNode, - @Cached @Exclusive BytesNodes.CreateBytesNode create, - @Shared @Cached PythonObjectFactory factory) { + @Cached @Exclusive BytesNodes.CreateBytesNode create) { SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage()); - return create.execute(node, factory, self, res); + return create.execute(node, self, res); } @Specialization(limit = "3") @@ -307,7 +305,6 @@ static PBytesLike add(VirtualFrame frame, Object self, Object other, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached("createWithOverflowError()") @Shared SequenceStorageNodes.ConcatNode concatNode, @Cached @Exclusive BytesNodes.CreateBytesNode create, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { Object buffer; try { @@ -319,7 +316,7 @@ static PBytesLike add(VirtualFrame frame, Object self, Object other, // TODO avoid copying byte[] bytes = bufferLib.getCopiedByteArray(buffer); SequenceStorage res = concatNode.execute(getBytesStorage.execute(inliningTarget, self), new ByteSequenceStorage(bytes)); - return create.execute(inliningTarget, factory, self, res); + return create.execute(inliningTarget, self, res); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -334,10 +331,9 @@ static PBytesLike mul(VirtualFrame frame, Object self, int times, @Bind("this") Node inliningTarget, @Cached GetBytesStorage getBytesStorage, @Cached("createWithOverflowError()") SequenceStorageNodes.RepeatNode repeatNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { SequenceStorage res = repeatNode.execute(frame, getBytesStorage.execute(inliningTarget, self), times); - return create.execute(inliningTarget, factory, self, res); + return create.execute(inliningTarget, self, res); } } @@ -372,8 +368,7 @@ static Object mod(VirtualFrame frame, Object self, Object right, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached BytesNodes.CreateBytesNode create, - @Cached TupleBuiltins.GetItemNode getTupleItemNode, - @Cached PythonObjectFactory factory) { + @Cached TupleBuiltins.GetItemNode getTupleItemNode) { Object buffer = acquireLib.acquireReadonly(self, frame, indirectCallData); try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); @@ -382,7 +377,7 @@ static Object mod(VirtualFrame frame, Object self, Object right, Object savedState = IndirectCallContext.enter(frame, indirectCallData); try { byte[] data = formatter.format(right); - return create.execute(inliningTarget, factory, self, data); + return create.execute(inliningTarget, self, data); } finally { IndirectCallContext.exit(frame, indirectCallData, savedState); } @@ -427,8 +422,8 @@ boolean contains(VirtualFrame frame, Object self, Object other, abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static PSequenceIterator contains(Object self, - @Cached PythonObjectFactory factory) { - return factory.createSequenceIterator(self); + @Bind PythonLanguage language) { + return PFactory.createSequenceIterator(language, self); } } @@ -624,6 +619,7 @@ public abstract static class PartitionAbstractNode extends PythonBinaryBuiltinNo @SuppressWarnings("truffle-static-method") // TODO: inh PTuple partition(VirtualFrame frame, Object self, Object sep, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("sep") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @@ -631,7 +627,6 @@ PTuple partition(VirtualFrame frame, Object self, Object sep, @Cached InlinedConditionProfile notFound, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached BytesNodes.CreateBytesNode createBytesNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); @@ -646,28 +641,28 @@ PTuple partition(VirtualFrame frame, Object self, Object sep, int idx = BytesNodes.FindNode.find(bytes, len, sepBytes, 0, bytes.length, isRight()); PBytesLike first, second, third; if (notFound.profile(inliningTarget, idx == -1)) { - second = createBytesNode.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + second = createBytesNode.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); if (isRight()) { - third = createBytesNode.execute(inliningTarget, factory, self, bytes); - first = createBytesNode.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + third = createBytesNode.execute(inliningTarget, self, bytes); + first = createBytesNode.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } else { - first = createBytesNode.execute(inliningTarget, factory, self, bytes); - third = createBytesNode.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + first = createBytesNode.execute(inliningTarget, self, bytes); + third = createBytesNode.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } } else { - second = createBytesNode.execute(inliningTarget, factory, self, sepBytes); + second = createBytesNode.execute(inliningTarget, self, sepBytes); if (idx == 0) { - first = createBytesNode.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); - third = createBytesNode.execute(inliningTarget, factory, self, Arrays.copyOfRange(bytes, lenSep, len)); + first = createBytesNode.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); + third = createBytesNode.execute(inliningTarget, self, Arrays.copyOfRange(bytes, lenSep, len)); } else if (idx == len - 1) { - first = createBytesNode.execute(inliningTarget, factory, self, Arrays.copyOfRange(bytes, 0, len - lenSep)); - third = createBytesNode.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + first = createBytesNode.execute(inliningTarget, self, Arrays.copyOfRange(bytes, 0, len - lenSep)); + third = createBytesNode.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } else { - first = createBytesNode.execute(inliningTarget, factory, self, Arrays.copyOfRange(bytes, 0, idx)); - third = createBytesNode.execute(inliningTarget, factory, self, Arrays.copyOfRange(bytes, idx + lenSep, len)); + first = createBytesNode.execute(inliningTarget, self, Arrays.copyOfRange(bytes, 0, idx)); + third = createBytesNode.execute(inliningTarget, self, Arrays.copyOfRange(bytes, idx + lenSep, len)); } } - return factory.createTuple(new Object[]{first, second, third}); + return PFactory.createTuple(language, new Object[]{first, second, third}); } finally { bufferLib.release(sepBuffer, frame, indirectCallData); } @@ -1211,7 +1206,6 @@ PBytesLike bytes(VirtualFrame frame, Object self, Object widthObj, Object fillOb @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Cached InlinedBranchProfile hasFill, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { int width = asSizeNode.executeExact(frame, inliningTarget, widthObj); SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); @@ -1226,9 +1220,9 @@ PBytesLike bytes(VirtualFrame frame, Object self, Object widthObj, Object fillOb } } if (checkSkip(len, width)) { - return create.execute(inliningTarget, factory, self, copyNode.execute(inliningTarget, storage)); + return create.execute(inliningTarget, self, copyNode.execute(inliningTarget, storage)); } - return create.execute(inliningTarget, factory, self, make(bufferLib.getCopiedByteArray(self), len, width, fillByte)); + return create.execute(inliningTarget, self, make(bufferLib.getCopiedByteArray(self), len, width, fillByte)); } protected String methodName() { @@ -1339,8 +1333,7 @@ static PBytesLike replace(Object self, Object substrBuffer, Object replacementBu @Cached InlinedConditionProfile selfSubAreEmpty, @Cached InlinedConditionProfile selfIsEmpty, @Cached InlinedConditionProfile subIsEmpty, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { try { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); @@ -1349,16 +1342,16 @@ static PBytesLike replace(Object self, Object substrBuffer, Object replacementBu byte[] replacementBytes = bufferLib.getCopiedByteArray(replacementBuffer); int maxcount = count < 0 ? Integer.MAX_VALUE : count; if (selfSubAreEmpty.profile(inliningTarget, len == 0 && subBytes.length == 0)) { - return create.execute(inliningTarget, factory, self, replacementBytes); + return create.execute(inliningTarget, self, replacementBytes); } if (selfIsEmpty.profile(inliningTarget, len == 0)) { - return create.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + return create.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } if (subIsEmpty.profile(inliningTarget, subBytes.length == 0)) { - return create.execute(inliningTarget, factory, self, replaceWithEmptySub(bytes, len, replacementBytes, maxcount)); + return create.execute(inliningTarget, self, replaceWithEmptySub(bytes, len, replacementBytes, maxcount)); } byte[] newBytes = replace(bytes, len, subBytes, replacementBytes, maxcount); - return create.execute(inliningTarget, factory, self, newBytes); + return create.execute(inliningTarget, self, newBytes); } finally { bufferLib.release(substrBuffer); bufferLib.release(replacementBuffer); @@ -1437,13 +1430,12 @@ abstract static class LowerNode extends PythonUnaryBuiltinNode { static PBytesLike replace(Object self, @Bind("this") Node node, @Cached BytesNodes.ToBytesNode toBytes, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] bytes = toBytes.execute(null, self); for (int i = 0; i < bytes.length; ++i) { bytes[i] = toLower(bytes[i]); } - return create.execute(node, factory, self, bytes); + return create.execute(node, self, bytes); } } @@ -1455,13 +1447,12 @@ abstract static class UpperNode extends PythonUnaryBuiltinNode { static PBytesLike replace(Object self, @Bind("this") Node inliningTarget, @Cached BytesNodes.ToBytesNode toBytes, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] bytes = toBytes.execute(null, self); for (int i = 0; i < bytes.length; ++i) { bytes[i] = toUpper(bytes[i]); } - return create.execute(inliningTarget, factory, self, bytes); + return create.execute(inliningTarget, self, bytes); } } @@ -1608,10 +1599,10 @@ PList whitespace(Object self, @SuppressWarnings("unused") byte[] sep, int maxspl @Shared("toBytes") @Cached SequenceStorageNodes.GetInternalByteArrayNode selfToBytesNode, @Shared("append") @Cached ListNodes.AppendNode appendNode, @Shared("create") @Cached BytesNodes.CreateBytesNode createBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); byte[] splitBs = selfToBytesNode.execute(inliningTarget, storage); - return getBytesResult(splitWhitespace(splitBs, storage.length(), adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, factory); + return getBytesResult(splitWhitespace(splitBs, storage.length(), adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, language); } @Specialization(guards = {"!isWhitespace(sep)", "isSingleSep(sep)"}) @@ -1621,10 +1612,10 @@ PList single(Object self, byte[] sep, int maxsplit, @Shared("toBytes") @Cached SequenceStorageNodes.GetInternalByteArrayNode selfToBytesNode, @Shared("append") @Cached ListNodes.AppendNode appendNode, @Shared("create") @Cached BytesNodes.CreateBytesNode createBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); byte[] splitBs = selfToBytesNode.execute(inliningTarget, storage); - return getBytesResult(splitSingle(splitBs, storage.length(), sep[0], adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, factory); + return getBytesResult(splitSingle(splitBs, storage.length(), sep[0], adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, language); } @Specialization(guards = {"!isWhitespace(sep)", "!isEmptySep(sep)", "!isSingleSep(sep)"}) @@ -1634,10 +1625,10 @@ PList split(Object self, byte[] sep, int maxsplit, @Shared("toBytes") @Cached SequenceStorageNodes.GetInternalByteArrayNode selfToBytesNode, @Shared("append") @Cached ListNodes.AppendNode appendNode, @Shared("create") @Cached BytesNodes.CreateBytesNode createBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); byte[] splitBs = selfToBytesNode.execute(inliningTarget, storage); - return getBytesResult(splitDelimiter(splitBs, storage.length(), sep, adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, factory); + return getBytesResult(splitDelimiter(splitBs, storage.length(), sep, adjustMaxSplit(maxsplit)), appendNode, self, inliningTarget, createBytesNode, language); } @SuppressWarnings("unused") @@ -1648,11 +1639,11 @@ static PList error(Object bytes, byte[] sep, int maxsplit, } private static PList getBytesResult(List bytes, ListNodes.AppendNode appendNode, Object self, Node inliningTarget, BytesNodes.CreateBytesNode createBytesNode, - PythonObjectFactory factory) { - PList result = factory.createList(); + PythonLanguage language) { + PList result = PFactory.createList(language); Iterator it = iterator(bytes); while (hasNext(it)) { - appendNode.execute(result, createBytesNode.execute(inliningTarget, factory, self, next(it))); + appendNode.execute(result, createBytesNode.execute(inliningTarget, self, next(it))); } return result; } @@ -1864,14 +1855,14 @@ public abstract static class SplitLinesNode extends PythonBinaryBuiltinNode { @Specialization static PList doSplitlines(Object self, Object keependsObj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedBranchProfile isPNoneProfile, @Cached InlinedBranchProfile isBooleanProfile, @Cached InlinedConditionProfile keependsProfile, @Cached CastToJavaIntExactNode cast, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached ListNodes.AppendNode appendNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { boolean keepends; if (keependsObj instanceof Boolean b) { isBooleanProfile.enter(inliningTarget); @@ -1884,7 +1875,7 @@ static PList doSplitlines(Object self, Object keependsObj, } keepends = keependsProfile.profile(inliningTarget, keepends); byte[] bytes = toBytesNode.execute(null, self); - PList list = factory.createList(); + PList list = PFactory.createList(language); int sliceStart = 0; for (int i = 0; i < bytes.length; i++) { if (bytes[i] == '\n' || bytes[i] == '\r') { @@ -1896,14 +1887,14 @@ static PList doSplitlines(Object self, Object keependsObj, sliceEnd = i + 1; } byte[] slice = copySlice(bytes, sliceStart, sliceEnd); - appendNode.execute(list, create.execute(inliningTarget, factory, self, slice)); + appendNode.execute(list, create.execute(inliningTarget, self, slice)); sliceStart = i + 1; } } // Process the remaining part if any if (sliceStart != bytes.length) { byte[] slice = copySlice(bytes, sliceStart, bytes.length); - appendNode.execute(list, create.execute(inliningTarget, factory, self, slice)); + appendNode.execute(list, create.execute(inliningTarget, self, slice)); } return list; } @@ -1922,10 +1913,9 @@ abstract static class AStripNode extends PythonBinaryBuiltinNode { PBytesLike strip(VirtualFrame frame, Object self, @SuppressWarnings("unused") PNone bytes, @Bind("this") Node node, @Shared("createByte") @Cached BytesNodes.CreateBytesNode create, - @Shared("toByteSelf") @Cached BytesNodes.ToBytesNode toBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared("toByteSelf") @Cached BytesNodes.ToBytesNode toBytesNode) { byte[] bs = toBytesNode.execute(frame, self); - return create.execute(node, factory, self, getResultBytes(bs, findIndex(bs))); + return create.execute(node, self, getResultBytes(bs, findIndex(bs))); } @Specialization(guards = "!isPNone(object)") @@ -1935,14 +1925,13 @@ PBytesLike strip(VirtualFrame frame, Object self, Object object, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared("createByte") @Cached BytesNodes.CreateBytesNode create, - @Shared("toByteSelf") @Cached BytesNodes.ToBytesNode selfToBytesNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared("toByteSelf") @Cached BytesNodes.ToBytesNode selfToBytesNode) { Object buffer = bufferAcquireLib.acquireReadonly(object, frame, indirectCallData); try { byte[] stripBs = bufferLib.getInternalOrCopiedByteArray(buffer); int stripBsLen = bufferLib.getBufferLength(buffer); byte[] bs = selfToBytesNode.execute(frame, self); - return create.execute(node, factory, self, getResultBytes(bs, findIndex(bs, stripBs, stripBsLen))); + return create.execute(node, self, getResultBytes(bs, findIndex(bs, stripBs, stripBsLen))); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -2080,8 +2069,8 @@ public abstract static class MakeTransNode extends PythonBuiltinNode { @Specialization static PBytes maketrans(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object from, Object to, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached BytesNodes.ToBytesNode toByteNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { byte[] fromB = toByteNode.execute(frame, from); byte[] toB = toByteNode.execute(frame, to); @@ -2099,7 +2088,7 @@ static PBytes maketrans(VirtualFrame frame, @SuppressWarnings("unused") Object c table[value < 0 ? value + 256 : value] = toB[i]; } - return factory.createBytes(table); + return PFactory.createBytes(language, table); } } @@ -2112,17 +2101,16 @@ abstract static class CapitalizeNode extends PythonUnaryBuiltinNode { static PBytesLike capitalize(Object self, @Bind("this") Node inliningTarget, @Cached ToBytesNode toBytesNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] b = toBytesNode.execute(null, self); if (b.length == 0) { - return create.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + return create.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } b[0] = toUpper(b[0]); for (int i = 1; i < b.length; i++) { b[i] = toLower(b[i]); } - return create.execute(inliningTarget, factory, self, b); + return create.execute(inliningTarget, self, b); } } @@ -2134,11 +2122,10 @@ abstract static class TitleNode extends PythonUnaryBuiltinNode { static PBytesLike title(Object self, @Bind("this") Node inliningTarget, @Cached ToBytesNode toBytesNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] b = toBytesNode.execute(null, self); if (b.length == 0) { - return create.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + return create.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } boolean previousIsCased = false; @@ -2160,7 +2147,7 @@ static PBytesLike title(Object self, b[i] = c; } - return create.execute(inliningTarget, factory, self, b); + return create.execute(inliningTarget, self, b); } } @@ -2172,11 +2159,10 @@ abstract static class SwapCaseNode extends PythonUnaryBuiltinNode { static PBytesLike swapcase(Object self, @Bind("this") Node inliningTarget, @Cached ToBytesNode toBytesNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { byte[] b = toBytesNode.execute(null, self); if (b.length == 0) { - return create.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + return create.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } for (int i = 0; i < b.length; i++) { if (BytesUtils.isUpper(b[i])) { @@ -2185,7 +2171,7 @@ static PBytesLike swapcase(Object self, b[i] = toUpper(b[i]); } } - return create.execute(inliningTarget, factory, self, b); + return create.execute(inliningTarget, self, b); } } @@ -2205,12 +2191,11 @@ static PBytesLike expandtabs(Object self, int tabsize, @Cached GetBytesStorage getBytesStorage, @Cached GetInternalByteArrayNode getInternalByteArrayNode, @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); if (len == 0) { - return create.execute(inliningTarget, factory, self, PythonUtils.EMPTY_BYTE_ARRAY); + return create.execute(inliningTarget, self, PythonUtils.EMPTY_BYTE_ARRAY); } int max = SysModuleBuiltins.MAXSIZE; byte[] b = getInternalByteArrayNode.execute(inliningTarget, storage); @@ -2264,7 +2249,7 @@ static PBytesLike expandtabs(Object self, int tabsize, } } - return create.execute(inliningTarget, factory, self, q); + return create.execute(inliningTarget, self, q); } @Override @@ -2283,10 +2268,9 @@ static PBytesLike zfill(Object self, int width, @Bind("this") Node inliningTarget, @Cached GetBytesStorage getBytesStorage, @Cached GetInternalByteArrayNode getInternalByteArrayNode, - @Cached BytesNodes.CreateBytesNode create, - @Cached PythonObjectFactory factory) { + @Cached BytesNodes.CreateBytesNode create) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); - return create.execute(inliningTarget, factory, self, zfill(getInternalByteArrayNode.execute(inliningTarget, storage), storage.length(), width)); + return create.execute(inliningTarget, self, zfill(getInternalByteArrayNode.execute(inliningTarget, storage), storage.length(), width)); } private static byte[] zfill(byte[] self, int len, int width) { @@ -2361,9 +2345,9 @@ public abstract static class GetNewargsNode extends PythonUnaryBuiltinNode { @Specialization static PTuple doBytes(Object self, @Bind("this") Node inliningTarget, - @Cached GetBytesStorage getBytesStorage, - @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{factory.createBytes(getBytesStorage.execute(inliningTarget, self))}); + @Bind PythonLanguage language, + @Cached GetBytesStorage getBytesStorage) { + return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, getBytesStorage.execute(inliningTarget, self))}); } } @@ -2377,8 +2361,7 @@ static PBytesLike remove(VirtualFrame frame, Object self, Object prefix, @CachedLibrary(limit = "1") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached BytesNodes.CreateBytesNode create, - @Cached InlinedConditionProfile profile, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile profile) { Object selfBuffer = bufferAcquireLib.acquireReadonly(self, frame, indirectCallData); Object prefixBuffer = bufferAcquireLib.acquireReadonly(prefix, frame, indirectCallData); @@ -2394,15 +2377,15 @@ static PBytesLike remove(VirtualFrame frame, Object self, Object prefix, for (int i = 0; i < selfBsLen; i++) { if (i < prefixBsLen) { if (selfBs[i] != prefixBs[i]) { - return create.execute(node, factory, self, selfBs); + return create.execute(node, self, selfBs); } } else { result[j++] = selfBs[i]; } } - return create.execute(node, factory, self, result); + return create.execute(node, self, result); } - return create.execute(node, factory, self, selfBs); + return create.execute(node, self, selfBs); } finally { bufferLib.release(selfBuffer, frame, indirectCallData); bufferLib.release(prefixBuffer, frame, indirectCallData); @@ -2420,8 +2403,7 @@ static PBytesLike remove(VirtualFrame frame, Object self, Object suffix, @CachedLibrary(limit = "1") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached BytesNodes.CreateBytesNode create, - @Cached InlinedConditionProfile profile, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile profile) { Object selfBuffer = bufferAcquireLib.acquireReadonly(self, frame, indirectCallData); Object suffixBuffer = bufferAcquireLib.acquireReadonly(suffix, frame, indirectCallData); try { @@ -2436,15 +2418,15 @@ static PBytesLike remove(VirtualFrame frame, Object self, Object suffix, for (int i = selfBsLen - 1, j = 1; i >= 0; i--, j++) { if (i >= selfBsLen - suffixBsLen) { if (selfBs[i] != suffixBs[suffixBsLen - j]) { - return create.execute(node, factory, self, selfBs); + return create.execute(node, self, selfBs); } } else { result[result.length - k++] = selfBs[i]; } } - return create.execute(node, factory, self, result); + return create.execute(node, self, result); } - return create.execute(node, factory, self, selfBs); + return create.execute(node, self, selfBs); } finally { bufferLib.release(selfBuffer, frame, indirectCallData); bufferLib.release(suffixBuffer, frame, indirectCallData); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java index c384cd4a50..dfceba80ec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java @@ -58,6 +58,7 @@ import java.util.ArrayList; import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ClinicConverterFactory; import com.oracle.graal.python.annotations.ClinicConverterFactory.ArgumentIndex; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -98,7 +99,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.NativeByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -135,33 +136,37 @@ public abstract class BytesNodes { @GenerateCached(false) public abstract static class CreateBytesNode extends Node { - public final PBytesLike execute(Node inliningTarget, PythonObjectFactory factory, Object basedOn, byte[] bytes) { - return execute(inliningTarget, factory, basedOn, new ByteSequenceStorage(bytes)); + public final PBytesLike execute(Node inliningTarget, Object basedOn, byte[] bytes) { + return execute(inliningTarget, basedOn, new ByteSequenceStorage(bytes)); } - public abstract PBytesLike execute(Node inliningTarget, PythonObjectFactory factory, Object basedOn, SequenceStorage bytes); + public abstract PBytesLike execute(Node inliningTarget, Object basedOn, SequenceStorage bytes); @Specialization - static PBytesLike bytes(PythonObjectFactory factory, @SuppressWarnings("unused") PBytes basedOn, SequenceStorage bytes) { - return factory.createBytes(bytes); + static PBytesLike bytes(@SuppressWarnings("unused") PBytes basedOn, SequenceStorage bytes, + @Bind PythonLanguage language) { + return PFactory.createBytes(language, bytes); } @Specialization - static PBytesLike bytearray(PythonObjectFactory factory, @SuppressWarnings("unused") PByteArray basedOn, SequenceStorage bytes) { - return factory.createByteArray(bytes); + static PBytesLike bytearray(@SuppressWarnings("unused") PByteArray basedOn, SequenceStorage bytes, + @Bind PythonLanguage language) { + return PFactory.createByteArray(language, bytes); } @Specialization(guards = "checkBytes.execute(inliningTarget, basedOn)") - static PBytesLike bytes(@SuppressWarnings("unused") Node inliningTarget, PythonObjectFactory factory, @SuppressWarnings("unused") Object basedOn, SequenceStorage bytes, - @SuppressWarnings("unused") @Shared @Cached PyBytesCheckNode checkBytes) { - return factory.createBytes(bytes); + static PBytesLike bytes(@SuppressWarnings("unused") Node inliningTarget, @SuppressWarnings("unused") Object basedOn, SequenceStorage bytes, + @SuppressWarnings("unused") @Shared @Cached PyBytesCheckNode checkBytes, + @Bind PythonLanguage language) { + return PFactory.createBytes(language, bytes); } @Specialization(guards = "!checkBytes.execute(inliningTarget, basedOn)") - static PBytesLike bytearray(@SuppressWarnings("unused") Node inliningTarget, PythonObjectFactory factory, @SuppressWarnings("unused") Object basedOn, SequenceStorage bytes, - @SuppressWarnings("unused") @Shared @Cached PyBytesCheckNode checkBytes) { + static PBytesLike bytearray(@SuppressWarnings("unused") Node inliningTarget, @SuppressWarnings("unused") Object basedOn, SequenceStorage bytes, + @SuppressWarnings("unused") @Shared @Cached PyBytesCheckNode checkBytes, + @Bind PythonLanguage language) { assert PyByteArrayCheckNode.executeUncached(basedOn); - return factory.createByteArray(bytes); + return PFactory.createByteArray(language, bytes); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java index ab5b24922a..f060fadafc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -86,7 +86,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -279,7 +279,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Ob l -> new BuiltinFunctionRootNode(l, BUILTIN, new PrototypeNodeFactory<>(ReadMemberNodeGen.create(type, offset, asPythonObjectNode)), true), ReadMemberNode.class, BUILTIN.name(), type, offset); int flags = PBuiltinFunction.getFlags(BUILTIN, callTarget); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, owner, 0, flags, callTarget); + return PFactory.createBuiltinFunction(language, propertyName, owner, 0, flags, callTarget); } } @@ -305,7 +305,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr l -> new BuiltinFunctionRootNode(l, BUILTIN, new PrototypeNodeFactory<>(ReadOnlyMemberNodeGen.create(propertyName)), true), ReadOnlyMemberNode.class, BUILTIN.name()); int flags = PBuiltinFunction.getFlags(BUILTIN, builtinCt); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, builtinCt); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); } } @@ -329,7 +329,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr l -> new BuiltinFunctionRootNode(l, BUILTIN, new PrototypeNodeFactory<>(BadMemberDescrNodeGen.create()), true), BadMemberDescrNode.class, BUILTIN.name()); int flags = PBuiltinFunction.getFlags(BUILTIN, builtinCt); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, builtinCt); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); } } @@ -638,7 +638,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Ob l -> new BuiltinFunctionRootNode(l, BUILTIN, new PrototypeNodeFactory<>(WriteMemberNodeGen.create(type, offset)), true), WriteMemberNode.class, BUILTIN.name(), type, offset); int flags = PBuiltinFunction.getFlags(BUILTIN, callTarget); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, owner, 0, flags, callTarget); + return PFactory.createBuiltinFunction(language, propertyName, owner, 0, flags, callTarget); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java index 37563cd761..d875b2524b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java @@ -185,7 +185,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.graal.python.util.Function; @@ -405,8 +405,8 @@ static PInt doBoolNativeWrapper(Node inliningTarget, PrimitiveNativeWrapper obje @Specialization(guards = {"!isMaterialized(object)", "object.isInt()"}) static PInt doIntNativeWrapper(PrimitiveNativeWrapper object, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - PInt materializedInt = factory.createInt(object.getInt()); + @Bind PythonLanguage language) { + PInt materializedInt = PFactory.createInt(language, object.getInt()); object.setMaterializedObject(materializedInt); materializedInt.setNativeWrapper(object); return materializedInt; @@ -414,8 +414,8 @@ static PInt doIntNativeWrapper(PrimitiveNativeWrapper object, @Specialization(guards = {"!isMaterialized(object)", "object.isLong()"}) static PInt doLongNativeWrapper(PrimitiveNativeWrapper object, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - PInt materializedInt = factory.createInt(object.getLong()); + @Bind PythonLanguage language) { + PInt materializedInt = PFactory.createInt(language, object.getLong()); object.setMaterializedObject(materializedInt); materializedInt.setNativeWrapper(object); return materializedInt; @@ -423,8 +423,8 @@ static PInt doLongNativeWrapper(PrimitiveNativeWrapper object, @Specialization(guards = {"!isMaterialized(object)", "object.isDouble()", "!isNaN(object)"}) static PFloat doDoubleNativeWrapper(PrimitiveNativeWrapper object, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - PFloat materializedInt = factory.createFloat(object.getDouble()); + @Bind PythonLanguage language) { + PFloat materializedInt = PFactory.createFloat(language, object.getDouble()); materializedInt.setNativeWrapper(object); object.setMaterializedObject(materializedInt); return materializedInt; @@ -690,45 +690,45 @@ static PComplex doPComplex(PComplex value) { @Specialization static PComplex doBoolean(boolean value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value ? 1.0 : 0.0, 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value ? 1.0 : 0.0, 0.0); } @Specialization static PComplex doInt(int value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value, 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value, 0.0); } @Specialization static PComplex doLong(long value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value, 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value, 0.0); } @Specialization PComplex doDouble(double value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value, 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value, 0.0); } @Specialization static PComplex doPInt(PInt value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value.doubleValue(), 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value.doubleValue(), 0.0); } @Specialization static PComplex doPFloat(PFloat value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(value.getValue(), 0.0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, value.getValue(), 0.0); } @Specialization(replaces = {"doPComplex", "doBoolean", "doInt", "doLong", "doDouble", "doPInt", "doPFloat"}) static PComplex runGeneric(Node inliningTarget, Object value, @Cached PyFloatAsDoubleNode asDoubleNode, @Cached(inline = false) LookupAndCallUnaryDynamicNode callComplex, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object result = callComplex.executeObject(value, T___COMPLEX__); // TODO(fa) according to CPython's 'PyComplex_AsCComplex', they still allow subclasses @@ -740,7 +740,7 @@ static PComplex runGeneric(Node inliningTarget, Object value, throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.COMPLEX_RETURNED_NON_COMPLEX, value); } } else { - return factory.createComplex(asDoubleNode.execute(null, inliningTarget, value), 0.0); + return PFactory.createComplex(language, asDoubleNode.execute(null, inliningTarget, value), 0.0); } } } @@ -1714,7 +1714,7 @@ public abstract static class CreateModuleNode extends MultiPhaseExtensionModuleI @TruffleBoundary static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object moduleDefWrapper, Object library, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached CStructAccess.ReadPointerNode readPointer, @Cached CStructAccess.ReadI64Node readI64, @CachedLibrary(limit = "3") InteropLibrary interopLib, @@ -1815,7 +1815,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m ((PythonModule) module).setNativeModuleDef(moduleDef); } } else { - PythonModule pythonModule = factory.createPythonModule(mName); + PythonModule pythonModule = PFactory.createPythonModule(language, mName); pythonModule.setNativeModuleDef(moduleDef); module = pythonModule; } @@ -1827,7 +1827,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m if (fun == null) { break; } - PBuiltinMethod method = factory.createBuiltinMethod(module, fun); + PBuiltinMethod method = PFactory.createBuiltinMethod(language, module, fun); writeAttrToMethodNode.execute(method, SpecialAttributeNames.T___MODULE__, mName); writeAttrNode.execute(module, fun.getName(), method); } @@ -1954,7 +1954,7 @@ static PBuiltinFunction doIt(Node inliningTarget, Object methodDef, int element, @Cached(inline = false) CStructAccess.ReadPointerNode readPointerNode, @Cached(inline = false) CStructAccess.ReadI32Node readI32Node, @Cached(inline = false) FromCharPointerNode fromCharPointerNode, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached EnsureExecutableNode ensureCallableNode, @Cached HiddenAttr.WriteNode writeHiddenAttrNode, @Cached(inline = false) WriteAttributeToPythonObjectNode writeAttributeToPythonObjectNode) { @@ -1978,7 +1978,7 @@ static PBuiltinFunction doIt(Node inliningTarget, Object methodDef, int element, RootCallTarget callTarget = PExternalFunctionWrapper.getOrCreateCallTarget(sig, PythonLanguage.get(inliningTarget), methodName, true, CExtContext.isMethStatic(flags)); mlMethObj = ensureCallableNode.execute(inliningTarget, mlMethObj, sig); PKeyword[] kwDefaults = ExternalFunctionNodes.createKwDefaults(mlMethObj); - PBuiltinFunction function = factory.createBuiltinFunction(methodName, null, PythonUtils.EMPTY_OBJECT_ARRAY, kwDefaults, flags, callTarget); + PBuiltinFunction function = PFactory.createBuiltinFunction(language, methodName, null, PythonUtils.EMPTY_OBJECT_ARRAY, kwDefaults, flags, callTarget); writeHiddenAttrNode.execute(inliningTarget, function, METHOD_DEF_PTR, methodDef); // write doc string; we need to directly write to the storage otherwise it is disallowed @@ -2107,7 +2107,7 @@ static PythonObject doPythonCallable(TruffleString name, PythonNativeWrapper cal } doArgAndResultConversion = true; } - PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, language, context.factory(), doArgAndResultConversion); + PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, language, doArgAndResultConversion); return function != null ? function : castToPythonObject(managedCallable); } @@ -2118,7 +2118,7 @@ static PBuiltinFunction doPyCFunctionWrapper(TruffleString name, PyCFunctionWrap assert !(delegate instanceof PythonAbstractObject); PythonContext context = PythonContext.get(null); PythonLanguage language = context.getLanguage(); - return PExternalFunctionWrapper.createWrapperFunction(name, delegate, type, flags, signature, language, context.factory(), false); + return PExternalFunctionWrapper.createWrapperFunction(name, delegate, type, flags, signature, language, false); } @Specialization(guards = {"!isNativeWrapper(callable)"}) @@ -2167,7 +2167,7 @@ static PythonObject doNativeCallableWithWrapper(TruffleString name, Object calla resolvedCallable = callable; } PythonLanguage language = context.getLanguage(); - PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, resolvedCallable, type, flags, signature, language, context.factory(), doArgAndResultConversion); + PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, resolvedCallable, type, flags, signature, language, doArgAndResultConversion); return function != null ? function : castToPythonObject(resolvedCallable); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java index 18528ad4a6..6e118171d4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -126,7 +126,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; @@ -187,22 +187,6 @@ public static PKeyword[] createKwDefaults(Object callable, Object closure) { return new PKeyword[]{new PKeyword(KW_CALLABLE, callable), new PKeyword(KW_CLOSURE, closure)}; } - public static Object tryGetHiddenCallable(PBuiltinFunction function) { - if (function.getFunctionRootNode() instanceof MethodDescriptorRoot) { - return getHiddenCallable(function.getKwDefaults()); - } - return null; - } - - public static Object getHiddenCallable(PKeyword[] kwDefaults) { - if (kwDefaults.length >= KEYWORDS_HIDDEN_CALLABLE.length) { - PKeyword kwDefault = kwDefaults[0]; - assert KW_CALLABLE.equalsUncached(kwDefault.getName(), TS_ENCODING) : "invalid keyword defaults"; - return kwDefault.getValue(); - } - throw CompilerDirectives.shouldNotReachHere(); - } - public abstract static class FinishArgNode extends PNodeWithContext { public abstract void execute(Object value); @@ -627,9 +611,9 @@ static RootCallTarget getOrCreateCallTarget(PExternalFunctionWrapper sig, Python } public static PBuiltinFunction createWrapperFunction(TruffleString name, Object callable, Object enclosingType, int flags, int sig, - PythonLanguage language, PythonObjectFactory factory, boolean doArgAndResultConversion) { + PythonLanguage language, boolean doArgAndResultConversion) { return createWrapperFunction(name, callable, enclosingType, flags, PExternalFunctionWrapper.fromValue(sig), - language, factory, doArgAndResultConversion); + language, doArgAndResultConversion); } /** @@ -644,14 +628,12 @@ public static PBuiltinFunction createWrapperFunction(TruffleString name, Object * {@link RootCallTarget}, and (3) a {@link BuiltinMethodDescriptor}. * @param enclosingType The type the function belongs to (needed for checking of * {@code self}). - * @param factory Just an instance of {@link PythonObjectFactory} to create the function - * object. * @return A {@link PBuiltinFunction} implementing the semantics of the specified slot * wrapper. */ @TruffleBoundary public static PBuiltinFunction createWrapperFunction(TruffleString name, Object callable, Object enclosingType, int flags, PExternalFunctionWrapper sig, PythonLanguage language, - PythonObjectFactory factory, boolean doArgAndResultConversion) { + boolean doArgAndResultConversion) { LOGGER.finer(() -> PythonUtils.formatJString("ExternalFunctions.createWrapperFunction(%s, %s)", name, callable)); assert !isClosurePointer(PythonContext.get(null), callable, InteropLibrary.getUncached(callable)); if (flags < 0) { @@ -718,24 +700,23 @@ public static PBuiltinFunction createWrapperFunction(TruffleString name, Object case FASTCALL: case FASTCALL_WITH_KEYWORDS: case METHOD: - return factory.createBuiltinFunction(name, type, defaults, kwDefaults, flags, callTarget); + return PFactory.createBuiltinFunction(language, name, type, defaults, kwDefaults, flags, callTarget); } - return factory.createWrapperDescriptor(name, type, defaults, kwDefaults, flags, callTarget, slot, sig); + return PFactory.createWrapperDescriptor(language, name, type, defaults, kwDefaults, flags, callTarget, slot, sig); } /** - * {@link #createWrapperFunction(TruffleString, Object, Object, int, PExternalFunctionWrapper, PythonLanguage, PythonObjectFactory, boolean)}. + * {@link #createWrapperFunction(TruffleString, Object, Object, int, PExternalFunctionWrapper, PythonLanguage, boolean)}. */ @TruffleBoundary - public static PBuiltinFunction createWrapperFunction(TruffleString name, TpSlotCExtNative slot, Object enclosingType, PExternalFunctionWrapper sig, PythonLanguage language, - PythonObjectFactory factory) { + public static PBuiltinFunction createWrapperFunction(TruffleString name, TpSlotCExtNative slot, Object enclosingType, PExternalFunctionWrapper sig, PythonLanguage language) { RootCallTarget callTarget = getOrCreateCallTarget(sig, language, name, true, false); if (callTarget == null) { return null; } var kwDefaults = ExternalFunctionNodes.createKwDefaults(slot.getCallable()); Object[] defaults = PBuiltinFunction.generateDefaults(sig.numDefaults); - return factory.createWrapperDescriptor(name, enclosingType, defaults, kwDefaults, 0, callTarget, slot, sig); + return PFactory.createWrapperDescriptor(language, name, enclosingType, defaults, kwDefaults, 0, callTarget, slot, sig); } private static boolean isClosurePointer(PythonContext context, Object callable, InteropLibrary lib) { @@ -1129,7 +1110,6 @@ protected final Object readSelf(VirtualFrame frame) { public static final class MethKeywordsRoot extends MethodDescriptorRoot { private static final Signature SIGNATURE = createSignature(true, 1, tsArray("self"), true, true); - @Child private PythonObjectFactory factory; @Child private ReadVarArgsNode readVarargsNode; @Child private ReadVarKeywordsNode readKwargsNode; @Child private CreateArgsTupleNode createArgsTupleNode; @@ -1143,7 +1123,6 @@ public MethKeywordsRoot(PythonLanguage language, TruffleString name, boolean isS public MethKeywordsRoot(PythonLanguage language, TruffleString name, boolean isStatic, PExternalFunctionWrapper provider) { super(language, name, isStatic, provider); - this.factory = PythonObjectFactory.create(); this.readVarargsNode = ReadVarArgsNode.create(true); this.readKwargsNode = ReadVarKeywordsNode.create(PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); this.createArgsTupleNode = CreateArgsTupleNodeGen.create(); @@ -1155,7 +1134,8 @@ protected Object[] prepareCArguments(VirtualFrame frame) { Object self = readSelf(frame); Object[] args = readVarargsNode.executeObjectArray(frame); PKeyword[] kwargs = readKwargsNode.executePKeyword(frame); - return new Object[]{self, createArgsTupleNode.execute(factory, args, seenNativeArgsTupleStorage), factory.createDict(kwargs)}; + PythonLanguage language = getLanguage(PythonLanguage.class); + return new Object[]{self, createArgsTupleNode.execute(language, args, seenNativeArgsTupleStorage), PFactory.createDict(language, kwargs)}; } @Override @@ -1177,7 +1157,6 @@ public Signature getSignature() { public static final class MethVarargsRoot extends MethodDescriptorRoot { private static final Signature SIGNATURE = createSignature(false, 1, tsArray("self"), true, true); - @Child private PythonObjectFactory factory; @Child private ReadVarArgsNode readVarargsNode; @Child private CreateArgsTupleNode createArgsTupleNode; @Child private ReleaseNativeSequenceStorageNode freeNode; @@ -1190,7 +1169,6 @@ public MethVarargsRoot(PythonLanguage language, TruffleString name, boolean isSt public MethVarargsRoot(PythonLanguage language, TruffleString name, boolean isStatic, PExternalFunctionWrapper provider) { super(language, name, isStatic, provider); - this.factory = PythonObjectFactory.create(); this.readVarargsNode = ReadVarArgsNode.create(true); this.createArgsTupleNode = CreateArgsTupleNodeGen.create(); this.freeNode = ReleaseNativeSequenceStorageNodeGen.create(); @@ -1200,7 +1178,7 @@ public MethVarargsRoot(PythonLanguage language, TruffleString name, boolean isSt protected Object[] prepareCArguments(VirtualFrame frame) { Object self = readSelf(frame); Object[] args = readVarargsNode.executeObjectArray(frame); - return new Object[]{self, createArgsTupleNode.execute(factory, args, seenNativeArgsTupleStorage)}; + return new Object[]{self, createArgsTupleNode.execute(getLanguage(PythonLanguage.class), args, seenNativeArgsTupleStorage)}; } @Override @@ -1358,7 +1336,6 @@ public Signature getSignature() { public static final class MethFastcallWithKeywordsRoot extends MethodDescriptorRoot { private static final Signature SIGNATURE = createSignature(true, 1, tsArray("self"), true, true); - @Child private PythonObjectFactory factory; @Child private ReadVarArgsNode readVarargsNode; @Child private ReadVarKeywordsNode readKwargsNode; @@ -1368,7 +1345,6 @@ public MethFastcallWithKeywordsRoot(PythonLanguage language, TruffleString name, public MethFastcallWithKeywordsRoot(PythonLanguage language, TruffleString name, boolean isStatic, PExternalFunctionWrapper provider) { super(language, name, isStatic, provider); - this.factory = PythonObjectFactory.create(); this.readVarargsNode = ReadVarArgsNode.create(true); this.readKwargsNode = ReadVarKeywordsNode.create(PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); } @@ -1388,7 +1364,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) { fastcallKwnames[i] = kwargs[i].getName(); fastcallArgs[args.length + i] = kwargs[i].getValue(); } - kwnamesTuple = factory.createTuple(fastcallKwnames); + kwnamesTuple = PFactory.createTuple(PythonLanguage.get(this), fastcallKwnames); } return new Object[]{self, new CPyObjectArrayWrapper(fastcallArgs), args.length, kwnamesTuple}; } @@ -1410,7 +1386,6 @@ public Signature getSignature() { public static final class MethMethodRoot extends MethodDescriptorRoot { private static final Signature SIGNATURE = createSignature(true, 1, tsArray("self", "cls"), true, true); - @Child private PythonObjectFactory factory; @Child private ReadIndexedArgumentNode readClsNode; @Child private ReadVarArgsNode readVarargsNode; @Child private ReadVarKeywordsNode readKwargsNode; @@ -1421,7 +1396,6 @@ public MethMethodRoot(PythonLanguage language, TruffleString name, boolean isSta public MethMethodRoot(PythonLanguage language, TruffleString name, boolean isStatic, PExternalFunctionWrapper provider) { super(language, name, isStatic, provider); - this.factory = PythonObjectFactory.create(); this.readClsNode = ReadIndexedArgumentNode.create(1); this.readVarargsNode = ReadVarArgsNode.create(true); this.readKwargsNode = ReadVarKeywordsNode.create(PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); @@ -1440,7 +1414,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) { fastcallKwnames[i] = kwargs[i].getName(); fastcallArgs[args.length + i] = kwargs[i].getValue(); } - return new Object[]{self, cls, new CPyObjectArrayWrapper(fastcallArgs), args.length, factory.createTuple(fastcallKwnames)}; + return new Object[]{self, cls, new CPyObjectArrayWrapper(fastcallArgs), args.length, PFactory.createTuple(PythonLanguage.get(this), fastcallKwnames)}; } @Override @@ -2183,43 +2157,43 @@ private ReadIndexedArgumentNode ensureReadArgNode() { */ @GenerateInline(false) abstract static class CreateArgsTupleNode extends Node { - public abstract PTuple execute(PythonObjectFactory factory, Object[] args, boolean eagerNative); + public abstract PTuple execute(PythonLanguage language, Object[] args, boolean eagerNative); @Specialization(guards = {"args.length == cachedLen", "cachedLen <= 8", "!eagerNative"}, limit = "1") @ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL) - static PTuple doCachedLen(PythonObjectFactory factory, Object[] args, @SuppressWarnings("unused") boolean eagerNative, + static PTuple doCachedLen(PythonLanguage language, Object[] args, @SuppressWarnings("unused") boolean eagerNative, @Cached("args.length") int cachedLen, @Cached("createMaterializeNodes(args.length)") MaterializePrimitiveNode[] materializePrimitiveNodes) { for (int i = 0; i < cachedLen; i++) { - args[i] = materializePrimitiveNodes[i].execute(factory, args[i]); + args[i] = materializePrimitiveNodes[i].execute(language, args[i]); } - return factory.createTuple(args); + return PFactory.createTuple(language, args); } @Specialization(guards = {"args.length == cachedLen", "cachedLen <= 8", "eagerNative"}, limit = "1", replaces = "doCachedLen") @ExplodeLoop(kind = LoopExplosionKind.FULL_UNROLL) - static PTuple doCachedLenEagerNative(PythonObjectFactory factory, Object[] args, @SuppressWarnings("unused") boolean eagerNative, + static PTuple doCachedLenEagerNative(PythonLanguage language, Object[] args, @SuppressWarnings("unused") boolean eagerNative, @Bind("this") Node inliningTarget, @Cached("args.length") int cachedLen, @Cached("createMaterializeNodes(args.length)") MaterializePrimitiveNode[] materializePrimitiveNodes, @Exclusive @Cached StorageToNativeNode storageToNativeNode) { for (int i = 0; i < cachedLen; i++) { - args[i] = materializePrimitiveNodes[i].execute(factory, args[i]); + args[i] = materializePrimitiveNodes[i].execute(language, args[i]); } - return factory.createTuple(storageToNativeNode.execute(inliningTarget, args, cachedLen, true)); + return PFactory.createTuple(language, storageToNativeNode.execute(inliningTarget, args, cachedLen, true)); } @Specialization(replaces = {"doCachedLen", "doCachedLenEagerNative"}) - static PTuple doGeneric(PythonObjectFactory factory, Object[] args, boolean eagerNative, + static PTuple doGeneric(PythonLanguage language, Object[] args, boolean eagerNative, @Bind("this") Node inliningTarget, @Cached MaterializePrimitiveNode materializePrimitiveNode, @Exclusive @Cached StorageToNativeNode storageToNativeNode) { int n = args.length; for (int i = 0; i < n; i++) { - args[i] = materializePrimitiveNode.execute(factory, args[i]); + args[i] = materializePrimitiveNode.execute(language, args[i]); } SequenceStorage storage; if (eagerNative) { @@ -2227,7 +2201,7 @@ static PTuple doGeneric(PythonObjectFactory factory, Object[] args, boolean eage } else { storage = new ObjectSequenceStorage(args); } - return factory.createTuple(storage); + return PFactory.createTuple(language, storage); } static MaterializePrimitiveNode[] createMaterializeNodes(int length) { @@ -2237,14 +2211,6 @@ static MaterializePrimitiveNode[] createMaterializeNodes(int length) { } return materializePrimitiveNodes; } - - static PythonToNativeNode[] createPythonToNativeNodes(int length) { - PythonToNativeNode[] pythonToNativeNodes = new PythonToNativeNode[length]; - for (int i = 0; i < length; i++) { - pythonToNativeNodes[i] = PythonToNativeNodeGen.create(); - } - return pythonToNativeNodes; - } } @GenerateInline(false) @@ -2292,38 +2258,34 @@ static void doObjectGeneric(NativeObjectSequenceStorage storage, @GenerateInline(false) abstract static class MaterializePrimitiveNode extends Node { - public abstract Object execute(PythonObjectFactory factory, Object object); + public abstract Object execute(PythonLanguage language, Object object); // NOTE: Booleans don't need to be materialized because they are singletons. @Specialization - static PInt doInteger(PythonObjectFactory factory, int i) { - return factory.createInt(i); + static PInt doInteger(PythonLanguage language, int i) { + return PFactory.createInt(language, i); } @Specialization(replaces = "doInteger") - static PInt doLong(PythonObjectFactory factory, long l) { - return factory.createInt(l); + static PInt doLong(PythonLanguage language, long l) { + return PFactory.createInt(language, l); } @Specialization - static PFloat doDouble(PythonObjectFactory factory, double d) { - return factory.createFloat(d); + static PFloat doDouble(PythonLanguage language, double d) { + return PFactory.createFloat(language, d); } @Specialization - static PString doString(PythonObjectFactory factory, TruffleString s) { - return factory.createString(s); + static PString doString(PythonLanguage language, TruffleString s) { + return PFactory.createString(language, s); } - @Specialization(guards = "!needsMaterialization(object)") - static Object doObject(@SuppressWarnings("unused") PythonObjectFactory factory, Object object) { + @Fallback + static Object doObject(@SuppressWarnings("unused") PythonLanguage language, Object object) { return object; } - - static boolean needsMaterialization(Object object) { - return object instanceof Integer || object instanceof Long || PGuards.isDouble(object) || object instanceof TruffleString; - } } // roughly equivalent to _Py_CheckFunctionResult in Objects/call.c diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PThreadState.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PThreadState.java index aecabf4b00..cf70e5c5be 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PThreadState.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PThreadState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -52,6 +52,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.InteropLibrary; @@ -108,7 +109,7 @@ private static Object allocateCLayout(PythonThreadState threadState) { PythonContext pythonContext = PythonContext.get(null); PDict threadStateDict = threadState.getDict(); if (threadStateDict == null) { - threadStateDict = pythonContext.factory().createDict(); + threadStateDict = PFactory.createDict(pythonContext.getLanguage()); threadState.setDict(threadStateDict); } writePtrNode.write(ptr, CFields.PyThreadState__dict, toNative.execute(threadStateDict)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyDateTimeCAPIWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyDateTimeCAPIWrapper.java index 159a961e19..88dba50a3c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyDateTimeCAPIWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyDateTimeCAPIWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -61,6 +61,7 @@ import com.oracle.graal.python.lib.PyObjectSetAttr; import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.strings.TruffleString; @@ -118,7 +119,7 @@ public static PyCapsule initWrapper(PythonContext context, CApiContext capiConte Object pointerObject = allocatePyDatetimeCAPI(datetimeModule); - PyCapsule capsule = context.factory().createCapsuleJavaName(pointerObject, T_PYDATETIME_CAPSULE_NAME); + PyCapsule capsule = PFactory.createCapsuleJavaName(context.getLanguage(), pointerObject, T_PYDATETIME_CAPSULE_NAME); PyObjectSetAttr.executeUncached(datetimeModule, T_DATETIME_CAPI, capsule); assert PyObjectGetAttr.executeUncached(datetimeModule, T_DATETIME_CAPI) != context.getNativeNull(); return capsule; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index 3d2ffcb5fa..2be40e1b3d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -55,6 +55,7 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_vectorcall_offset; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_weaklistoffset; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.ctypes.StgDictObject; import com.oracle.graal.python.builtins.objects.PNone; @@ -101,7 +102,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.strings.TruffleString; @@ -204,7 +205,7 @@ static void initializeType(PythonClassNativeWrapper obj, Object mem, boolean hea GetTypeFlagsNode getTypeFlagsNode = GetTypeFlagsNodeGen.getUncached(); PythonContext ctx = PythonContext.get(null); - PythonObjectFactory factory = ctx.factory(); + PythonLanguage language = ctx.getLanguage(); Object nullValue = ctx.getNativeNull(); // make this object immortal @@ -331,11 +332,11 @@ static void initializeType(PythonClassNativeWrapper obj, Object mem, boolean hea writePtrNode.write(mem, CFields.PyTypeObject__tp_free, lookup(clazz, PyTypeObject__tp_free, HiddenAttr.FREE)); writePtrNode.write(mem, CFields.PyTypeObject__tp_clear, lookup(clazz, PyTypeObject__tp_clear, HiddenAttr.CLEAR)); if (clazz.basesTuple == null) { - clazz.basesTuple = factory.createTuple(GetBaseClassesNode.executeUncached(clazz)); + clazz.basesTuple = PFactory.createTuple(language, GetBaseClassesNode.executeUncached(clazz)); } writePtrNode.write(mem, CFields.PyTypeObject__tp_bases, toNative.execute(clazz.basesTuple)); if (clazz.mroStore == null) { - clazz.mroStore = factory.createTuple(GetMroStorageNode.executeUncached(clazz)); + clazz.mroStore = PFactory.createTuple(language, GetMroStorageNode.executeUncached(clazz)); } writePtrNode.write(mem, CFields.PyTypeObject__tp_mro, toNative.execute(clazz.mroStore)); writePtrNode.write(mem, CFields.PyTypeObject__tp_cache, nullValue); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/UnicodeObjectNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/UnicodeObjectNodes.java index b1437841b9..5e6d3be1bf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/UnicodeObjectNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/UnicodeObjectNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,10 +42,11 @@ import java.nio.ByteOrder; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.str.StringNodes.StringMaterializeNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -93,7 +94,7 @@ static PBytes doUnicode(TruffleString s, long elementSize, ByteOrder byteOrder) } else { throw new RuntimeException("unsupported wchar size; was: " + elementSize); } - return PythonObjectFactory.getUncached().createBytes(getBytes(s, encoding)); + return PFactory.createBytes(PythonLanguage.get(null), getBytes(s, encoding)); } private static byte[] getBytes(TruffleString s, TruffleString.Encoding encoding) { 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 5e86231f34..b2c0b9a338 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -104,7 +104,7 @@ import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage.StorageType; @@ -566,7 +566,7 @@ private static void processPyCapsuleReference(PyCapsuleReference reference) { LOGGER.fine(() -> PythonUtils.formatJString("releasing %s", reference.toString())); if (reference.data.getDestructor() != null) { // Our capsule is dead, so create a temporary copy that doesn't have a reference anymore - PyCapsule capsule = PythonObjectFactory.getUncached().createCapsule(reference.data); + PyCapsule capsule = PFactory.createCapsule(PythonLanguage.get(null), reference.data); PCallCapiFunction.callUncached(NativeCAPISymbol.FUN_PY_TRUFFLE_CAPSULE_CALL_DESTRUCTOR, PythonToNativeNode.executeUncached(capsule), capsule.getDestructor()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/GetNativeWrapperNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/GetNativeWrapperNode.java index 5e40dfd0f5..61b8ee5b88 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/GetNativeWrapperNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/GetNativeWrapperNode.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.cext.capi.transitions; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; @@ -61,7 +62,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -88,9 +89,9 @@ public static PythonNativeWrapper executeUncached(Object value) { @Specialization static PythonAbstractObjectNativeWrapper doString(TruffleString str, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached InlinedConditionProfile noWrapperProfile) { - return PythonObjectNativeWrapper.wrap(factory.createString(str), inliningTarget, noWrapperProfile); + return PythonObjectNativeWrapper.wrap(PFactory.createString(language, str), inliningTarget, noWrapperProfile); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java index 738bcc3494..06659c2b69 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java @@ -105,7 +105,7 @@ import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.exception.PythonExitException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CallTarget; @@ -610,9 +610,10 @@ private static PException raiseNullButNoError(Node node, TruffleString name, Tru @TruffleBoundary private static PException raiseResultWithError(Node node, TruffleString name, AbstractTruffleException currentException, TruffleString resultWithErrorMessage) { - PBaseException sysExc = PythonObjectFactory.getUncached().createBaseException(SystemError, resultWithErrorMessage, new Object[]{name}); + PythonLanguage language = PythonLanguage.get(null); + PBaseException sysExc = PFactory.createBaseException(language, SystemError, resultWithErrorMessage, new Object[]{name}); sysExc.setCause(GetEscapedExceptionNode.executeUncached(currentException)); - throw PRaiseNode.raiseExceptionObject(node, sysExc, PythonOptions.isPExceptionWithJavaStacktrace(PythonLanguage.get(null))); + throw PRaiseNode.raiseExceptionObject(node, sysExc, PythonOptions.isPExceptionWithJavaStacktrace(language)); } } @@ -1125,29 +1126,8 @@ static long doUnsignedLongPositive(long n) { @Specialization(guards = "n < 0") static Object doUnsignedLongNegative(long n, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createInt(PInt.longToUnsignedBigInteger(n)); - } - - @Specialization(replaces = {"doUnsignedIntPositive", "doUnsignedInt", "doUnsignedLongPositive", "doUnsignedLongNegative"}) - static Object doGeneric(Object n, - @Shared("factory") @Cached PythonObjectFactory factory) { - if (n instanceof Integer) { - int i = (int) n; - if (i >= 0) { - return i; - } else { - return doUnsignedInt(i); - } - } else if (n instanceof Long) { - long l = (long) n; - if (l >= 0) { - return l; - } else { - return doUnsignedLongNegative(l, factory); - } - } - throw CompilerDirectives.shouldNotReachHere(); + @Bind PythonLanguage language) { + return PFactory.createInt(language, PInt.longToUnsignedBigInteger(n)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java index 84a7b7b4fa..31306784eb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -49,6 +49,7 @@ import java.io.IOException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; import com.oracle.graal.python.builtins.objects.exception.PBaseException; @@ -58,7 +59,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.ExceptionUtils; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -211,7 +212,7 @@ protected static PException reportImportError(RuntimeException e, TruffleString @TruffleBoundary public static PException wrapJavaException(Throwable e, Node raisingNode) { TruffleString message = toTruffleStringUncached(e.getMessage()); - PBaseException excObject = PythonObjectFactory.getUncached().createBaseException(SystemError, message != null ? message : toTruffleStringUncached(e.toString()), + PBaseException excObject = PFactory.createBaseException(PythonLanguage.get(null), SystemError, message != null ? message : toTruffleStringUncached(e.toString()), PythonUtils.EMPTY_OBJECT_ARRAY); return ExceptionUtils.wrapJavaException(e, raisingNode, excObject); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java index 5be72a0746..0fdb508249 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java @@ -95,6 +95,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.PythonOptions.HPyBackendMode; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonSystemThreadTask; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; @@ -532,7 +533,7 @@ public void doRun() { PythonLanguage language = pythonContext.getLanguage(); GraalHPyContext hPyContext = pythonContext.getHPyContext(); RootCallTarget callTarget = hPyContext.getReferenceCleanerCallTarget(); - PDict dummyGlobals = pythonContext.factory().createDict(); + PDict dummyGlobals = PFactory.createDict(language); boolean isLoggable = LOGGER.isLoggable(Level.FINE); /* * Intentionally retrieve the thread state every time since this will kill the thread if diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java index d988655d42..1927550d25 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java @@ -302,6 +302,7 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.PythonClass; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; import com.oracle.graal.python.lib.PyCallableCheckNode; @@ -358,7 +359,7 @@ import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.graal.python.util.CharsetMapping; @@ -382,6 +383,7 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.profiles.InlinedExactClassProfile; @@ -1380,9 +1382,9 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ar public abstract static class GraalHPyDictNew extends HPyUnaryContextFunction { @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, - @Cached PythonObjectFactory factory) { - return factory.createDict(); + static Object doGeneric(GraalHPyContext hpyContext, + @Bind("this") Node inliningTarget) { + return PFactory.createDict(hpyContext.getContext().getLanguage(inliningTarget)); } } @@ -1391,14 +1393,14 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, public abstract static class GraalHPyListNew extends HPyBinaryContextFunction { @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, long len, - @Cached PythonObjectFactory factory, + static Object doGeneric(GraalHPyContext hpyContext, long len, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { try { Object[] data = new Object[PInt.intValueExact(len)]; // TODO(fa) maybe this should be NO_VALUE (representing native 'NULL') Arrays.fill(data, PNone.NONE); - return factory.createList(data); + return PFactory.createList(hpyContext.getContext().getLanguage(inliningTarget), data); } catch (OverflowException e) { throw raiseNode.raise(PythonBuiltinClassType.MemoryError); } @@ -1769,10 +1771,10 @@ static Object doGeneric(GraalHPyContext hpyContext, Object object, public abstract static class GraalHPyUnicodeAsUTF8String extends HPyBinaryContextFunction { @Specialization - static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object unicodeObject, - @Cached EncodeNativeStringNode encodeNativeStringNode, - @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeNativeStringNode.execute(StandardCharsets.UTF_8, unicodeObject, T_STRICT)); + static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, + @Bind("this") Node inliningTarget, + @Cached EncodeNativeStringNode encodeNativeStringNode) { + return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.UTF_8, unicodeObject, T_STRICT)); } } @@ -1781,10 +1783,10 @@ static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object un public abstract static class GraalHPyUnicodeAsLatin1String extends HPyBinaryContextFunction { @Specialization - static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object unicodeObject, - @Cached EncodeNativeStringNode encodeNativeStringNode, - @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeNativeStringNode.execute(StandardCharsets.ISO_8859_1, unicodeObject, T_STRICT)); + static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, + @Bind("this") Node inliningTarget, + @Cached EncodeNativeStringNode encodeNativeStringNode) { + return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.ISO_8859_1, unicodeObject, T_STRICT)); } } @@ -1793,10 +1795,10 @@ static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object un public abstract static class GraalHPyUnicodeAsASCIIString extends HPyBinaryContextFunction { @Specialization - static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object unicodeObject, - @Cached EncodeNativeStringNode encodeNativeStringNode, - @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeNativeStringNode.execute(StandardCharsets.US_ASCII, unicodeObject, T_STRICT)); + static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, + @Bind("this") Node inliningTarget, + @Cached EncodeNativeStringNode encodeNativeStringNode) { + return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.US_ASCII, unicodeObject, T_STRICT)); } } @@ -1804,10 +1806,10 @@ static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object un @GenerateUncached public abstract static class GraalHPyUnicodeEncodeFSDefault extends HPyBinaryContextFunction { @Specialization - static PBytes doGeneric(@SuppressWarnings("unused") Object hpyContext, Object unicodeObject, - @Cached EncodeNativeStringNode encodeNativeStringNode, - @Cached PythonObjectFactory factory) { - return factory.createBytes(encodeNativeStringNode.execute(getFSDefaultCharset(), unicodeObject, T_STRICT)); + static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, + @Bind("this") Node inliningTarget, + @Cached EncodeNativeStringNode encodeNativeStringNode) { + return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(getFSDefaultCharset(), unicodeObject, T_STRICT)); } @TruffleBoundary @@ -2037,8 +2039,7 @@ static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, @Cached CastToJavaIntExactNode castToJavaIntNode, @Cached(parameters = "hpyContext") HPyCallHelperFunctionNode callHelperNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { int size; try { size = castToJavaIntNode.execute(inliningTarget, callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_STRLEN, charPtr)); @@ -2046,7 +2047,7 @@ static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, throw raiseNode.raise(OverflowError, ErrorMessages.BYTE_STR_IS_TOO_LARGE); } byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, size); - return factory.createBytes(bytes); + return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), bytes); } } @@ -2056,21 +2057,22 @@ public abstract static class GraalHPyBytesFromStringAndSize extends HPyTernaryCo @Specialization static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, long lsize, + @Bind("this") Node inliningTarget, @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { if (isNullNode.execute(hpyContext, charPtr)) { throw raiseNode.raise(ValueError, ErrorMessages.NULL_CHAR_PASSED); } if (lsize < 0) { throw raiseNode.raise(SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); } + PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); if (lsize == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, lsize); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } } @@ -2300,7 +2302,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutV @Bind("this") Node inliningTarget, @Cached IsTypeNode isTypeNode, @Cached PRaiseNode.Lazy raiseNode, - @Cached PythonObjectFactory factory, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(parameters = "hpyContext") GraalHPyCAccess.AllocateNode allocateNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.WritePointerNode writePointerNode, @Cached InlinedExactClassProfile classProfile) { @@ -2335,7 +2337,8 @@ static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutV } int builtinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); - PythonObject pythonObject = createFromBuiltinShape(builtinShape, profiledTypeObject, dataPtr, factory); + PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); + PythonObject pythonObject = createFromBuiltinShape(builtinShape, profiledTypeObject, dataPtr, language, getInstanceShape); if (destroyFunc != null) { hpyContext.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); @@ -2347,15 +2350,16 @@ static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutV return pythonObject; } - static PythonObject createFromBuiltinShape(int builtinShape, Object type, Object dataPtr, PythonObjectFactory factory) { + static PythonObject createFromBuiltinShape(int builtinShape, Object type, Object dataPtr, PythonLanguage language, TypeNodes.GetInstanceShape getInstanceShape) { + Shape shape = getInstanceShape.execute(type); PythonObject result = switch (builtinShape) { - case HPyType_BUILTIN_SHAPE_LEGACY, HPyType_BUILTIN_SHAPE_OBJECT -> factory.createPythonHPyObject(type, dataPtr); + case HPyType_BUILTIN_SHAPE_LEGACY, HPyType_BUILTIN_SHAPE_OBJECT -> PFactory.createPythonHPyObject(language, type, shape, dataPtr); case HPyType_BUILTIN_SHAPE_TYPE -> throw CompilerDirectives.shouldNotReachHere("built-in shape type not yet implemented"); - case HPyType_BUILTIN_SHAPE_LONG -> factory.createInt(type, BigInteger.ZERO); - case HPyType_BUILTIN_SHAPE_FLOAT -> factory.createFloat(type, 0.0); - case HPyType_BUILTIN_SHAPE_UNICODE -> factory.createString(type, T_EMPTY_STRING); - case HPyType_BUILTIN_SHAPE_TUPLE -> factory.createEmptyTuple(type); - case HPyType_BUILTIN_SHAPE_LIST -> factory.createList(type); + case HPyType_BUILTIN_SHAPE_LONG -> PFactory.createInt(language, type, shape, BigInteger.ZERO); + case HPyType_BUILTIN_SHAPE_FLOAT -> PFactory.createFloat(language, type, shape, 0.0); + case HPyType_BUILTIN_SHAPE_UNICODE -> PFactory.createString(language, type, shape, T_EMPTY_STRING); + case HPyType_BUILTIN_SHAPE_TUPLE -> PFactory.createEmptyTuple(language, type, shape); + case HPyType_BUILTIN_SHAPE_LIST -> PFactory.createList(language, type, shape); default -> throw CompilerDirectives.shouldNotReachHere(INVALID_BUILT_IN_SHAPE); }; if (builtinShape != HPyType_BUILTIN_SHAPE_LEGACY && builtinShape != HPyType_BUILTIN_SHAPE_OBJECT) { @@ -2395,7 +2399,7 @@ public abstract static class GraalHPyTypeGenericNew extends HPy5ContextFunction @SuppressWarnings("unused") static Object doGeneric(GraalHPyContext hpyContext, Object type, Object args, long nargs, Object kw, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(parameters = "hpyContext") GraalHPyCAccess.AllocateNode allocateNode, @Cached InlinedExactClassProfile classProfile) { @@ -2418,7 +2422,8 @@ static Object doGeneric(GraalHPyContext hpyContext, Object type, Object args, lo } int builtinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); - PythonObject pythonObject = GraalHPyNew.createFromBuiltinShape(builtinShape, type, dataPtr, factory); + PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); + PythonObject pythonObject = GraalHPyNew.createFromBuiltinShape(builtinShape, type, dataPtr, language, getInstanceShape); if (destroyFunc != null) { hpyContext.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); @@ -2607,8 +2612,7 @@ public abstract static class GraalHPyTupleFromArray extends HPyTernaryContextFun static Object doGeneric(GraalHPyContext hpyContext, Object arrayPtr, long nelements, @Bind("this") Node inliningTarget, @Cached CastToJavaIntExactNode castToJavaIntExactNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadHPyArrayNode readHPyArrayNode, - @Cached PythonObjectFactory factory) { + @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadHPyArrayNode readHPyArrayNode) { int n; try { n = castToJavaIntExactNode.execute(inliningTarget, nelements); @@ -2618,7 +2622,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object arrayPtr, long neleme } Object[] elements = readHPyArrayNode.execute(hpyContext, arrayPtr, 0, n); - return factory.createTuple(elements); + return PFactory.createTuple(hpyContext.getContext().getLanguage(inliningTarget), elements); } } @@ -2677,10 +2681,9 @@ boolean isTupleBuilder() { } @Specialization - Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderHandle, + Object doGeneric(GraalHPyContext hpyContext, Object builderHandle, @Bind("this") Node inliningTarget, - @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode, - @Cached PythonObjectFactory factory) { + @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode) { ObjectSequenceStorage builder = cast(closeAndGetHandleNode.execute(inliningTarget, builderHandle)); if (builder == null) { /* @@ -2689,7 +2692,8 @@ Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderHa */ throw CompilerDirectives.shouldNotReachHere("invalid builder object"); } - return isTupleBuilder() ? factory.createTuple(builder) : factory.createList(builder); + PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); + return isTupleBuilder() ? PFactory.createTuple(language, builder) : PFactory.createList(language, builder); } static ObjectSequenceStorage cast(Object object) { @@ -3039,8 +3043,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object namePtr, Object docPt @Cached HashingStorageGetItem getHashingStorageItem, @Cached HashingStorageSetItem setHashingStorageItem, @Cached CallNode callTypeConstructorNode, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { TruffleString doc; if (!isNullNode.execute(hpyContext, docPtr)) { doc = fromCharPointerNode.execute(docPtr); @@ -3049,7 +3052,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object namePtr, Object docPt } return createNewExceptionWithDoc(inliningTarget, namePtr, base, dictObj, doc, fromCharPointerNode, indexOfCodepointNode, codepointLengthNode, substringNode, getHashingStorageItem, - setHashingStorageItem, callTypeConstructorNode, raiseNode, factory); + setHashingStorageItem, callTypeConstructorNode, raiseNode); } static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Object base, Object dictObj, TruffleString doc, @@ -3060,8 +3063,7 @@ static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Obj HashingStorageGetItem getHashingStorageItem, HashingStorageSetItem setHashingStorageItem, CallNode callTypeConstructorNode, - PRaiseNode raiseNode, - PythonObjectFactory factory) { + PRaiseNode raiseNode) { TruffleString name = fromCharPointerNode.execute(namePtr); int len = codepointLengthNode.execute(name, TS_ENCODING); @@ -3073,11 +3075,12 @@ static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Obj if (base == PNone.NO_VALUE) { base = PythonBuiltinClassType.Exception; } + PythonLanguage language = PythonLanguage.get(inliningTarget); PDict dict; HashingStorage dictStorage; if (dictObj == PNone.NO_VALUE) { dictStorage = new DynamicObjectStorage(PythonLanguage.get(inliningTarget)); - dict = factory.createDict(dictStorage); + dict = PFactory.createDict(language, dictStorage); } else { if (!(dictObj instanceof PDict)) { /* @@ -3102,7 +3105,7 @@ static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Obj if (base instanceof PTuple) { bases = (PTuple) base; } else { - bases = factory.createTuple(new Object[]{base}); + bases = PFactory.createTuple(language, new Object[]{base}); } return callTypeConstructorNode.executeWithoutFrame(PythonBuiltinClassType.PythonClass, substringNode.execute(name, dotIdx + 1, len - dotIdx - 1, TS_ENCODING, false), bases, dict); @@ -3123,11 +3126,10 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object na @Cached HashingStorageGetItem getHashingStorageItem, @Cached HashingStorageSetItem setHashingStorageItem, @Cached CallNode callTypeConstructorNode, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { return GraalHPyNewExceptionWithDoc.createNewExceptionWithDoc(inliningTarget, namePtr, base, dictObj, null, fromCharPointerNode, indexOfCodepointNode, codepointLengthNode, - substringNode, getHashingStorageItem, setHashingStorageItem, callTypeConstructorNode, raiseNode, factory); + substringNode, getHashingStorageItem, setHashingStorageItem, callTypeConstructorNode, raiseNode); } } @@ -3343,13 +3345,12 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object di @GenerateUncached public abstract static class GraalHPyDictCopy extends HPyBinaryContextFunction { @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object dictObj, + static Object doGeneric(GraalHPyContext hpyContext, Object dictObj, @Bind("this") Node inliningTarget, @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (dictObj instanceof PDict dict) { - return factory.createDict(copyNode.execute(inliningTarget, dict.getDictStorage())); + return PFactory.createDict(hpyContext.getContext().getLanguage(inliningTarget), copyNode.execute(inliningTarget, dict.getDictStorage())); } throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } @@ -3369,9 +3370,9 @@ public abstract static class GraalHPyCapsuleNew extends HPyQuaternaryContextFunc @Specialization static PyCapsule doGeneric(GraalHPyContext hpyContext, Object pointer, Object namePtr, Object dtorPtr, + @Bind("this") Node inliningTarget, @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadPointerNode readPointerNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode raiseNode) { if (isNullNode.execute(hpyContext, pointer)) { throw raiseNode.raise(ValueError, ErrorMessages.HPYCAPSULE_NEW_NULL_PTR_ERROR); @@ -3384,7 +3385,7 @@ static PyCapsule doGeneric(GraalHPyContext hpyContext, Object pointer, Object na throw raiseNode.raise(ValueError, ErrorMessages.INVALID_HPYCAPSULE_DESTRUCTOR); } } - PyCapsule capsule = factory.createCapsuleNativeName(pointer, namePtr); + PyCapsule capsule = PFactory.createCapsuleNativeName(hpyContext.getContext().getLanguage(inliningTarget), pointer, namePtr); if (hpyDestructor != null) { capsule.registerDestructor(hpyDestructor); } @@ -3533,8 +3534,7 @@ public abstract static class GraalHPyContextVarSet extends HPyTernaryContextFunc @Specialization static Object doGeneric(GraalHPyContext hpyContext, Object var, Object val, @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Cached PRaiseNode raiseNode) { if (!(var instanceof PContextVar contextVar)) { throw raiseNode.raise(TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } @@ -3542,7 +3542,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object var, Object val, PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); Object oldValue = contextVar.getValue(threadState); contextVar.setValue(threadState, val); - return factory.createContextVarsToken(contextVar, oldValue); + return PFactory.createContextVarsToken(hpyContext.getContext().getLanguage(inliningTarget), contextVar, oldValue); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java index c14fca967e..de9a964821 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -107,7 +107,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectExactProfile; import com.oracle.graal.python.nodes.object.IsNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -326,7 +326,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyReadMemberNodeGen.create(offset, type, asPythonObjectNode)), true), HPyReadMemberNode.class, builtin.name(), type, offset); int flags = PBuiltinFunction.getFlags(builtin, callTarget); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, callTarget); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, callTarget); } } @@ -351,7 +351,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr RootCallTarget builtinCt = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyReadOnlyMemberNodeGen.create(propertyName)), true), HPyReadOnlyMemberNode.class, builtin.name()); int flags = PBuiltinFunction.getFlags(builtin, builtinCt); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, builtinCt); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); } } @@ -374,7 +374,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr RootCallTarget builtinCt = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyBadMemberDescrNodeGen.create()), true), HPyBadMemberDescrNode.class, builtin.name()); int flags = PBuiltinFunction.getFlags(builtin, builtinCt); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, builtinCt); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); } } @@ -641,7 +641,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Tr l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyWriteMemberNodeGen.create(type, offset)), true), HPyWriteMemberNode.class, builtin.name(), type, offset); int flags = PBuiltinFunction.getFlags(builtin, callTarget); - return PythonObjectFactory.getUncached().createBuiltinFunction(propertyName, null, 0, flags, callTarget); + return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, callTarget); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java index 7575f0d193..9de14d1240 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -48,6 +48,7 @@ import java.io.IOException; import java.io.PrintStream; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; @@ -86,6 +87,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.ExceptionUtils; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.interop.ArityException; @@ -222,11 +224,11 @@ public static PException checkThrowableBeforeNative(Throwable t, String where1, CompilerDirectives.transferToInterpreter(); PythonContext context = PythonContext.get(null); context.ensureGilAfterFailure(); - PBaseException newException = context.factory().createBaseException(RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, EMPTY_OBJECT_ARRAY); + PBaseException newException = PFactory.createBaseException(context.getLanguage(), RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, EMPTY_OBJECT_ARRAY); throw ExceptionUtils.wrapJavaException(soe, null, newException); } if (t instanceof OutOfMemoryError oome) { - PBaseException newException = PythonContext.get(null).factory().createBaseException(MemoryError); + PBaseException newException = PFactory.createBaseException(PythonLanguage.get(null), MemoryError); throw ExceptionUtils.wrapJavaException(oome, null, newException); } // everything else: log and convert to PException (SystemError) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java index 30eb5a37ce..fbf5f3b277 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java @@ -156,7 +156,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; @@ -397,7 +397,6 @@ public abstract static class GraalHPyModuleCreate extends Node { @Specialization static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spec, Object moduleDefPtr, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, @@ -413,6 +412,8 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe @CachedLibrary(limit = "1") InteropLibrary createLib, @Cached PRaiseNode raiseNode) { + PythonLanguage language = context.getContext().getLanguage(); + TruffleString mDoc; long size; Object docPtr = readPointerNode.read(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__doc); @@ -509,7 +510,7 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe throw raiseNode.raise(SystemError, ErrorMessages.HPY_MOD_CREATE_RETURNED_BUILTIN_MOD); } } else { - PythonModule pmodule = factory.createPythonModule(mName); + PythonModule pmodule = PFactory.createPythonModule(language, mName); pmodule.setNativeModuleDef(executeSlots); module = pmodule; } @@ -517,7 +518,7 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe // process HPy methods for (Object methodDef : methodDefs) { PBuiltinFunction fun = addFunctionNode.execute(context, null, methodDef); - PBuiltinMethod method = factory.createBuiltinMethod(module, fun); + PBuiltinMethod method = PFactory.createBuiltinMethod(language, module, fun); writeAttrToMethodNode.execute(method, SpecialAttributeNames.T___MODULE__, mName); writeAttrNode.execute(module, fun.getName(), method); } @@ -529,7 +530,7 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe if (fun == null) { break; } - PBuiltinMethod method = factory.createBuiltinMethod(module, fun); + PBuiltinMethod method = PFactory.createBuiltinMethod(language, module, fun); writeAttrToMethodNode.execute(method, SpecialAttributeNames.T___MODULE__, mName); writeAttrNode.execute(module, fun.getName(), method); } @@ -671,7 +672,6 @@ static PBuiltinFunction doIt(GraalHPyContext context, Object enclosingType, Obje @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, @Cached FromCharPointerNode fromCharPointerNode, @Cached HPyAttachFunctionTypeNode attachFunctionTypeNode, - @Cached PythonObjectFactory factory, @Cached WriteAttributeToPythonObjectNode writeAttributeToPythonObjectNode, @Cached PRaiseNode raiseNode) { @@ -695,7 +695,7 @@ static PBuiltinFunction doIt(GraalHPyContext context, Object enclosingType, Obje methodFunctionPointer = attachFunctionTypeNode.execute(context, methodFunctionPointer, signature.getLLVMFunctionType()); PythonLanguage language = context.getContext().getLanguage(inliningTarget); - PBuiltinFunction function = HPyExternalFunctionNodes.createWrapperFunction(language, context, signature, methodName, methodFunctionPointer, enclosingType, factory); + PBuiltinFunction function = HPyExternalFunctionNodes.createWrapperFunction(language, context, signature, methodName, methodFunctionPointer, enclosingType); // write doc string; we need to directly write to the storage otherwise it is // disallowed writing to builtin types. @@ -730,10 +730,8 @@ static GetSetDescriptor doGeneric(GraalHPyContext context, Object owner, Object @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, @Cached FromCharPointerNode fromCharPointerNode, - @Cached PythonObjectFactory factory, @Cached EnsureExecutableNode ensureExecutableNode, - @Cached WriteAttributeToPythonObjectNode writeDocNode, - @Cached PRaiseNode raiseNode) { + @Cached WriteAttributeToPythonObjectNode writeDocNode) { // compute offset of name and read name pointer long nameOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__name); @@ -766,21 +764,22 @@ static GetSetDescriptor doGeneric(GraalHPyContext context, Object owner, Object */ Object closurePtr = context.nativeToInteropPointer(readPointerNode.execute(context, legacyGetSetDef, closureOffset)); - PythonLanguage lang = context.getContext().getLanguage(inliningTarget); + PythonLanguage language = context.getContext().getLanguage(inliningTarget); PBuiltinFunction getterObject = null; if (!isNullNode.execute(context, getterFunPtr)) { Object getterFunInteropPtr = ensureExecutableNode.execute(inliningTarget, context.nativeToInteropPointer(getterFunPtr), PExternalFunctionWrapper.GETTER); - getterObject = HPyLegacyGetSetDescriptorGetterRoot.createLegacyFunction(context, lang, owner, getSetDescrName, getterFunInteropPtr, closurePtr); + getterObject = HPyLegacyGetSetDescriptorGetterRoot.createLegacyFunction(language, owner, getSetDescrName, getterFunInteropPtr, closurePtr); } PBuiltinFunction setterObject = null; boolean hasSetter = !isNullNode.execute(context, setterFunPtr); if (hasSetter) { Object setterFunInteropPtr = ensureExecutableNode.execute(inliningTarget, context.nativeToInteropPointer(setterFunPtr), PExternalFunctionWrapper.SETTER); - setterObject = HPyLegacyGetSetDescriptorSetterRoot.createLegacyFunction(context, lang, owner, getSetDescrName, setterFunInteropPtr, closurePtr); + setterObject = HPyLegacyGetSetDescriptorSetterRoot.createLegacyFunction(language, owner, getSetDescrName, setterFunInteropPtr, closurePtr); } - GetSetDescriptor getSetDescriptor = factory.createGetSetDescriptor(getterObject, setterObject, getSetDescrName, owner, hasSetter); + context.getContext().getLanguage(inliningTarget); + GetSetDescriptor getSetDescriptor = PFactory.createGetSetDescriptor(language, getterObject, setterObject, getSetDescrName, owner, hasSetter); writeDocNode.execute(getSetDescriptor, SpecialAttributeNames.T___DOC__, getSetDescrDoc); return getSetDescriptor; } @@ -920,7 +919,6 @@ static HPyProperty doIt(GraalHPyContext context, Object enclosingType, Object me @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, @Cached FromCharPointerNode fromCharPointerNode, - @Cached PythonObjectFactory factory, @Cached WriteAttributeToPythonObjectNode writeDocNode) { // computes offsets like '&(memberDefArrPtr[i].name)' @@ -958,7 +956,7 @@ static HPyProperty doIt(GraalHPyContext context, Object enclosingType, Object me } // create a property - GetSetDescriptor memberDescriptor = factory.createMemberDescriptor(getterObject, setterObject, name, enclosingType); + GetSetDescriptor memberDescriptor = PFactory.createMemberDescriptor(language, getterObject, setterObject, name, enclosingType); writeDocNode.execute(memberDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); return new HPyProperty(name, memberDescriptor); } @@ -989,7 +987,6 @@ static HPyProperty doIt(GraalHPyContext context, PythonClass enclosingType, Obje @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, @Cached FromCharPointerNode fromCharPointerNode, @Cached TruffleString.EqualNode equalNode, - @Cached PythonObjectFactory factory, @Cached WriteAttributeToPythonObjectNode writeDocNode) { TruffleString name = fromCharPointerNode.execute(readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__member__name)); @@ -1018,7 +1015,7 @@ static HPyProperty doIt(GraalHPyContext context, PythonClass enclosingType, Obje } // create member descriptor - GetSetDescriptor memberDescriptor = factory.createMemberDescriptor(getterObject, setterObject, name, enclosingType); + GetSetDescriptor memberDescriptor = PFactory.createMemberDescriptor(language, getterObject, setterObject, name, enclosingType); writeDocNode.execute(memberDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); return new HPyProperty(name, memberDescriptor); } @@ -1047,11 +1044,11 @@ public abstract static class HPyCreateGetSetDescriptorNode extends PNodeWithCont @Specialization static GetSetDescriptor doIt(GraalHPyContext context, Object type, Object memberDef, + @Bind("this") Node inliningTarget, @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, @Cached FromCharPointerNode fromCharPointerNode, @Cached HPyAttachFunctionTypeNode attachFunctionTypeNode, - @Cached PythonObjectFactory factory, @Cached WriteAttributeToPythonObjectNode writeDocNode) { TruffleString name = fromCharPointerNode.execute(readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__name)); @@ -1093,7 +1090,8 @@ static GetSetDescriptor doIt(GraalHPyContext context, Object type, Object member setterObject = null; } - GetSetDescriptor getSetDescriptor = factory.createGetSetDescriptor(getterObject, setterObject, name, type, !hasSetter); + PythonLanguage language = context.getContext().getLanguage(inliningTarget); + GetSetDescriptor getSetDescriptor = PFactory.createGetSetDescriptor(language, getterObject, setterObject, name, type, !hasSetter); writeDocNode.execute(getSetDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); return getSetDescriptor; } @@ -1148,7 +1146,6 @@ public abstract static class HPyCreateSlotNode extends PNodeWithContext { static Object doIt(GraalHPyContext context, PythonClass enclosingType, TpSlots.Builder tpSlotsBuilder, Object slotDef, @Bind("this") Node inliningTarget, @Cached HPyReadSlotNode readSlotNode, - @Cached PythonObjectFactory factory, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, @Cached PRaiseNode raiseNode) { @@ -1193,7 +1190,7 @@ static Object doIt(GraalHPyContext context, PythonClass enclosingType, TpSlots.B Object enclosingTypeForFun = HPY_TP_NEW.equals(slot) ? null : enclosingType; PythonLanguage language = context.getContext().getLanguage(inliningTarget); - Object function = HPyExternalFunctionNodes.createWrapperFunction(language, context, slotWrapper, null, null, methodNameStr, slotData.impl(), enclosingTypeForFun, factory); + Object function = HPyExternalFunctionNodes.createWrapperFunction(language, context, slotWrapper, null, null, methodNameStr, slotData.impl(), enclosingTypeForFun); property = new HPyProperty(methodName, function, property); } } @@ -1246,7 +1243,6 @@ static boolean doIt(GraalHPyContext context, Object enclosingType, TpSlots.Build @Cached ReadPropertyNode readPropertyNode, @Cached WritePropertyNode writePropertyNode, @CachedLibrary(limit = "1") InteropLibrary lib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { // computes '&(slotDefArrPtr[i].slot)' @@ -1327,7 +1323,7 @@ static boolean doIt(GraalHPyContext context, Object enclosingType, TpSlots.Build callable = interopPFuncPtr; } PythonLanguage lang = context.getContext().getLanguage(inliningTarget); - method = PExternalFunctionWrapper.createWrapperFunction(attributeKey, callable, enclosingType, 0, slot.getSignature(), lang, factory, true); + method = PExternalFunctionWrapper.createWrapperFunction(attributeKey, callable, enclosingType, 0, slot.getSignature(), lang, true); } writeAttributeToObjectNode.execute(enclosingType, attributeKey, method); } else { @@ -2238,8 +2234,8 @@ static long doUnsignedLongPositive(long n, @SuppressWarnings("unused") boolean s @Specialization(guards = {"!signed", "n < 0"}) static Object doUnsignedLongNegative(long n, @SuppressWarnings("unused") boolean signed, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(convertToBigInteger(n)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, convertToBigInteger(n)); } @TruffleBoundary @@ -2249,8 +2245,8 @@ private static BigInteger convertToBigInteger(long n) { @Specialization static Object doPointer(PythonNativeObject n, @SuppressWarnings("unused") boolean signed, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createNativeVoidPtr(n.getPtr()); + @Bind PythonLanguage language) { + return PFactory.createNativeVoidPtr(language, n.getPtr()); } } @@ -2296,7 +2292,6 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe @Cached(parameters = "context") HPyAsCharPointerNode asCharPointerNode, @Cached HPyTypeSplitNameNode splitName, @Cached FromCharPointerNode fromCharPointerNode, - @Cached PythonObjectFactory factory, @Cached IsTypeNode isTypeNode, @Cached HasSameConstructorNode hasSameConstructorNode, @Cached CStructAccess.ReadI64Node getMetaSizeNode, @@ -2314,6 +2309,7 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe @Cached PRaiseNode raiseNode) { try { + PythonLanguage language = context.getContext().getLanguage(inliningTarget); // the name as given by the specification TruffleString specName = fromCharPointerNode.execute(readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__name), false); @@ -2327,15 +2323,15 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe Object doc = readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__doc); if (!isNullNode.execute(context, doc)) { TruffleString docString = fromCharPointerNode.execute(doc); - namespace = factory.createDict(new PKeyword[]{new PKeyword(SpecialAttributeNames.T___DOC__, docString)}); + namespace = PFactory.createDict(language, new PKeyword[]{new PKeyword(SpecialAttributeNames.T___DOC__, docString)}); } else { - namespace = factory.createDict(); + namespace = PFactory.createDict(language); } HPyTypeSpecParam[] typeSpecParams = extractTypeSpecParams(context, typeSpecParamArray); // extract bases from type spec params - PTuple bases = extractBases(typeSpecParams, factory); + PTuple bases = extractBases(typeSpecParams, language); // extract metaclass from type spec params Object metatype = getMetatype(typeSpecParams, raiseNode); @@ -2500,7 +2496,6 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe */ // Lookup the inherited constructor and pass it to the HPy decorator. Object inheritedConstructor = lookupNewNode.execute(baseClass); - PythonLanguage language = context.getContext().getLanguage(inliningTarget); PBuiltinFunction constructorDecorator = HPyObjectNewNode.createBuiltinFunction(language, inheritedConstructor, builtinShape); writeAttributeToObjectNode.execute(newType, SpecialMethodNames.T___NEW__, constructorDecorator); } @@ -2565,11 +2560,11 @@ private static HPyTypeSpecParam[] extractTypeSpecParams(GraalHPyContext context, * @return The bases tuple or {@code null} in case of an error. */ @TruffleBoundary - private static PTuple extractBases(HPyTypeSpecParam[] typeSpecParams, PythonObjectFactory factory) { + private static PTuple extractBases(HPyTypeSpecParam[] typeSpecParams, PythonLanguage language) { // if there are no type spec params, no bases have been explicitly specified if (typeSpecParams == null) { - return factory.createEmptyTuple(); + return PFactory.createEmptyTuple(language); } ArrayList basesList = new ArrayList<>(); @@ -2594,7 +2589,7 @@ private static PTuple extractBases(HPyTypeSpecParam[] typeSpecParams, PythonObje assert false : "unknown type spec param kind"; } } - return factory.createTuple(basesList.toArray()); + return PFactory.createTuple(language, basesList.toArray()); } /** diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java index 574b5642a3..393b2965ce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -68,7 +68,7 @@ import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode; import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -286,7 +286,7 @@ public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Ob } RootCallTarget callTarget = language.createCachedCallTarget(l -> new HPyObjectNewNode(language, builtinShape), HPyObjectNewNode.class, builtinShape); int flags = CExtContext.METH_KEYWORDS | CExtContext.METH_VARARGS; - return PythonObjectFactory.getUncached().createBuiltinFunction(SpecialMethodNames.T___NEW__, null, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(superConstructor), flags, callTarget); + return PFactory.createBuiltinFunction(language, SpecialMethodNames.T___NEW__, null, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(superConstructor), flags, callTarget); } public static Object getDecoratedSuperConstructor(PBuiltinFunction builtinFunction) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java index d61f11be8e..a51505dd58 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java @@ -101,7 +101,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; @@ -160,14 +160,10 @@ public static PKeyword[] createKwDefaults(Object callable, Object closure, Graal * @param name The name of the method. * @param callable The native function pointer. * @param enclosingType The type the function belongs to (needed for checking of {@code self}). - * @param factory Just an instance of {@link PythonObjectFactory} to create the function object. - * We could also use the uncached version but this way, the allocations are reported - * for the caller. * @return A {@link PBuiltinFunction} that accepts the given signature. */ @TruffleBoundary - static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyContext context, HPyFuncSignature signature, TruffleString name, Object callable, Object enclosingType, - PythonObjectFactory factory) { + static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyContext context, HPyFuncSignature signature, TruffleString name, Object callable, Object enclosingType) { assert InteropLibrary.getUncached(callable).isExecutable(callable) : "object is not callable"; RootCallTarget callTarget = language.createCachedCallTarget(l -> createRootNode(l, signature, name), signature, name, true); @@ -180,7 +176,7 @@ static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyC defaults = PythonUtils.EMPTY_OBJECT_ARRAY; } int flags = HPyFuncSignature.getFlags(signature); - return factory.createBuiltinFunction(name, enclosingType, defaults, createKwDefaults(callable, context), flags, callTarget); + return PFactory.createBuiltinFunction(language, name, enclosingType, defaults, createKwDefaults(callable, context), flags, callTarget); } private static PRootNode createRootNode(PythonLanguage language, HPyFuncSignature signature, TruffleString name) { @@ -230,13 +226,11 @@ private static PRootNode createRootNode(PythonLanguage language, HPyFuncSignatur * @param name The name of the method. * @param callable The native function pointer. * @param enclosingType The type the function belongs to (needed for checking of {@code self}). - * @param factory Just an instance of {@link PythonObjectFactory} to create the function object. * @return A {@link PBuiltinFunction} implementing the semantics of the specified slot wrapper. */ @TruffleBoundary public static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyContext context, HPySlotWrapper wrapper, TpSlotHPyNative slot, PExternalFunctionWrapper legacySlotWrapper, - TruffleString name, Object callable, Object enclosingType, - PythonObjectFactory factory) { + TruffleString name, Object callable, Object enclosingType) { assert InteropLibrary.getUncached(callable).isExecutable(callable) : "object is not callable"; RootCallTarget callTarget = language.createCachedCallTarget(l -> createSlotRootNode(l, wrapper, name), wrapper, name); Object[] defaults; @@ -257,7 +251,7 @@ public static PBuiltinFunction createWrapperFunction(PythonLanguage language, Gr kwDefaults = createKwDefaults(callable, context); } - return factory.createWrapperDescriptor(name, enclosingType, defaults, kwDefaults, 0, callTarget, slot, legacySlotWrapper); + return PFactory.createWrapperDescriptor(language, name, enclosingType, defaults, kwDefaults, 0, callTarget, slot, legacySlotWrapper); } private static PRootNode createSlotRootNode(PythonLanguage language, HPySlotWrapper wrapper, TruffleString name) { @@ -625,7 +619,6 @@ static final class HPyMethKeywordsRoot extends HPyMethodDescriptorRootNode { @Child private ReadVarArgsNode readVarargsNode; @Child private ReadVarKeywordsNode readKwargsNode; - @Child private PythonObjectFactory factory; @TruffleBoundary public HPyMethKeywordsRoot(PythonLanguage language, TruffleString name) { @@ -685,11 +678,7 @@ private PKeyword[] getKwargs(VirtualFrame frame) { } private PTuple getKwnamesTuple(TruffleString[] kwnames) { - if (factory == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - factory = insert(PythonObjectFactory.create()); - } - return factory.createTuple(kwnames); + return PFactory.createTuple(PythonLanguage.get(this), kwnames); } @Override @@ -1352,8 +1341,7 @@ public static PBuiltinFunction createFunction(GraalHPyContext hpyContext, Object PythonContext pythonContext = hpyContext.getContext(); PythonLanguage lang = pythonContext.getLanguage(); RootCallTarget callTarget = lang.createCachedCallTarget(l -> new HPyGetSetDescriptorGetterRootNode(l, propertyName), HPyGetSetDescriptorGetterRootNode.class, propertyName); - PythonObjectFactory factory = pythonContext.getCore().factory(); - return factory.createBuiltinFunction(propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); + return PFactory.createBuiltinFunction(lang, propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); } } @@ -1391,16 +1379,14 @@ protected Object[] prepareCArguments(VirtualFrame frame) { } @TruffleBoundary - public static PBuiltinFunction createLegacyFunction(GraalHPyContext context, PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { - PythonContext pythonContext = context.getContext(); - PythonObjectFactory factory = pythonContext.factory(); + public static PBuiltinFunction createLegacyFunction(PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { RootCallTarget rootCallTarget = lang.createCachedCallTarget(l -> new HPyLegacyGetSetDescriptorGetterRoot(l, propertyName, PExternalFunctionWrapper.GETTER), HPyLegacyGetSetDescriptorGetterRoot.class, propertyName); if (rootCallTarget == null) { throw CompilerDirectives.shouldNotReachHere("Calling non-native get descriptor functions is not support in HPy"); } target = EnsureExecutableNode.executeUncached(target, PExternalFunctionWrapper.GETTER); - return factory.createBuiltinFunction(propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); + return PFactory.createBuiltinFunction(lang, propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); } } @@ -1440,8 +1426,7 @@ public static PBuiltinFunction createFunction(GraalHPyContext hpyContext, Object PythonContext pythonContext = hpyContext.getContext(); PythonLanguage lang = pythonContext.getLanguage(); RootCallTarget callTarget = lang.createCachedCallTarget(l -> new HPyGetSetDescriptorSetterRootNode(l, propertyName), HPyGetSetDescriptorSetterRootNode.class, propertyName); - PythonObjectFactory factory = pythonContext.factory(); - return factory.createBuiltinFunction(propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); + return PFactory.createBuiltinFunction(lang, propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); } } @@ -1476,16 +1461,14 @@ protected Object[] prepareCArguments(VirtualFrame frame) { } @TruffleBoundary - public static PBuiltinFunction createLegacyFunction(GraalHPyContext context, PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { - PythonContext pythonContext = context.getContext(); - PythonObjectFactory factory = pythonContext.factory(); + public static PBuiltinFunction createLegacyFunction(PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { RootCallTarget rootCallTarget = lang.createCachedCallTarget(l -> new HPyLegacyGetSetDescriptorSetterRoot(l, propertyName, PExternalFunctionWrapper.SETTER), HPyLegacyGetSetDescriptorSetterRoot.class, propertyName); if (rootCallTarget == null) { throw CompilerDirectives.shouldNotReachHere("Calling non-native get descriptor functions is not support in HPy"); } target = EnsureExecutableNode.executeUncached(target, PExternalFunctionWrapper.SETTER); - return factory.createBuiltinFunction(propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); + return PFactory.createBuiltinFunction(lang, propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); } } @@ -1776,7 +1759,6 @@ static final class HPyMethCallRoot extends HPyMethodDescriptorRootNode { @Child private ReadVarArgsNode readVarargsNode; @Child private ReadVarKeywordsNode readKwargsNode; - @Child private PythonObjectFactory factory; @TruffleBoundary public HPyMethCallRoot(PythonLanguage language, TruffleString name) { @@ -1860,11 +1842,7 @@ private PKeyword[] getKwargs(VirtualFrame frame) { } private PTuple getKwnamesTuple(TruffleString[] kwnames) { - if (factory == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - factory = insert(PythonObjectFactory.create()); - } - return factory.createTuple(kwnames); + return PFactory.createTuple(PythonLanguage.get(this), kwnames); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java index 26be2d9259..1a703b622c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java @@ -172,6 +172,7 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; import com.oracle.graal.python.builtins.objects.type.PythonClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; import com.oracle.graal.python.lib.PyFloatAsDoubleNode; import com.oracle.graal.python.lib.PyLongAsDoubleNode; @@ -197,7 +198,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.PythonOptions.HPyBackendMode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; @@ -243,7 +244,6 @@ public final class GraalHPyJNIContext extends GraalHPyNativeContext { private static boolean jniBackendLoaded = false; - private final PythonObjectSlowPathFactory slowPathFactory; private final int[] counts; private final int[] ctypeSizes; @@ -271,7 +271,6 @@ public final class GraalHPyJNIContext extends GraalHPyNativeContext { public GraalHPyJNIContext(GraalHPyContext context, boolean traceUpcalls) { super(context, traceUpcalls); assert !PythonImageBuildOptions.WITHOUT_JNI; - this.slowPathFactory = context.getContext().factory(); this.counts = traceUpcalls ? new int[HPyJNIUpcall.VALUES.length] : null; this.ctypeSizes = new int[HPyContextSignatureType.values().length]; this.cfieldOffsets = new int[GraalHPyCField.values().length]; @@ -1245,6 +1244,7 @@ public static long expectPointer(Object value) { } private long createHPyObject(long typeHandle, long dataOutVar) { + PythonLanguage language = context.getContext().getLanguage(); Object type = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(typeHandle)); PythonObject pythonObject; @@ -1257,7 +1257,7 @@ private long createHPyObject(long typeHandle, long dataOutVar) { long basicSize = clazz.getBasicSize(); if (basicSize == -1) { // create the managed Python object - pythonObject = slowPathFactory.createPythonObject(clazz, clazz.getInstanceShape()); + pythonObject = PFactory.createPythonObject(language, clazz, clazz.getInstanceShape()); } else { /* * Since this is a JNI upcall method, we know that (1) we are not running in some @@ -1269,7 +1269,7 @@ private long createHPyObject(long typeHandle, long dataOutVar) { if (dataOutVar != 0) { UNSAFE.putAddress(dataOutVar, dataPtr); } - pythonObject = slowPathFactory.createPythonHPyObject(clazz, dataPtr); + pythonObject = PFactory.createPythonHPyObject(language, clazz, clazz.getInstanceShape(), dataPtr); Object destroyFunc = clazz.getHPyDestroyFunc(); context.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); } @@ -1283,7 +1283,7 @@ private long createHPyObject(long typeHandle, long dataOutVar) { return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_NEW_ARG_1_MUST_BE_A_TYPE); } // TODO(fa): this should actually call __new__ - pythonObject = slowPathFactory.createPythonObject(type); + pythonObject = PFactory.createPythonObject(language, type, TypeNodes.GetInstanceShape.executeUncached(type)); } return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(pythonObject)); } @@ -1363,7 +1363,7 @@ public long ctxUnicodeFromJCharArray(char[] arr) { public long ctxDictNew() { increment(HPyJNIUpcall.HPyDictNew); - PDict dict = slowPathFactory.createDict(); + PDict dict = PFactory.createDict(context.getContext().getLanguage()); return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(dict)); } @@ -1373,7 +1373,7 @@ public long ctxListNew(long llen) { int len = CastToJavaIntExactNode.executeUncached(llen); Object[] data = new Object[len]; Arrays.fill(data, PNone.NONE); - PList list = slowPathFactory.createList(data); + PList list = PFactory.createList(context.getContext().getLanguage(), data); return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(list)); } catch (PException e) { HPyTransformExceptionToNativeNode.executeUncached(context, e); @@ -1399,10 +1399,11 @@ public long ctxSequenceFromArray(long[] hItems, boolean steal, boolean create_li } } Object result; + PythonLanguage language = context.getContext().getLanguage(); if (create_list) { - result = slowPathFactory.createList(objects); + result = PFactory.createList(language, objects); } else { - result = slowPathFactory.createTuple(objects); + result = PFactory.createTuple(language, objects); } return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); } @@ -1521,7 +1522,7 @@ public long ctxCapsuleNew(long pointer, long name, long destructor) { } else { hpyDestructor = 0; } - PyCapsule result = slowPathFactory.createCapsuleNativeName(pointer, new NativePointer(name)); + PyCapsule result = PFactory.createCapsuleNativeName(context.getContext().getLanguage(), pointer, new NativePointer(name)); if (hpyDestructor != 0) { result.registerDestructor(hpyDestructor); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java index 013bdc4b46..6637816761 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -39,6 +39,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -63,8 +64,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -92,9 +92,8 @@ public abstract static class GetFreeVarsNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, @Bind("this") Node inliningTarget, - @Cached InternStringNode internStringNode, - @Cached PythonObjectFactory factory) { - return internStrings(inliningTarget, self.getFreeVars(), internStringNode, factory); + @Cached InternStringNode internStringNode) { + return internStrings(inliningTarget, self.getFreeVars(), internStringNode); } } @@ -104,9 +103,8 @@ public abstract static class GetCellVarsNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, @Bind("this") Node inliningTarget, - @Cached InternStringNode internStringNode, - @Cached PythonObjectFactory factory) { - return internStrings(inliningTarget, self.getCellVars(), internStringNode, factory); + @Cached InternStringNode internStringNode) { + return internStrings(inliningTarget, self.getCellVars(), internStringNode); } } @@ -215,8 +213,8 @@ static Object get(PCode self) { public abstract static class GetCodeNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, - @Cached PythonObjectFactory factory) { - return self.co_code(factory); + @Bind PythonLanguage language) { + return self.co_code(language); } } @@ -226,9 +224,8 @@ public abstract static class GetConstsNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, @Bind("this") Node inliningTarget, - @Cached InternStringNode internStringNode, - @Cached PythonObjectFactory factory) { - return internStrings(inliningTarget, self.getConstants(), internStringNode, factory); + @Cached InternStringNode internStringNode) { + return internStrings(inliningTarget, self.getConstants(), internStringNode); } } @@ -238,9 +235,8 @@ public abstract static class GetNamesNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, @Bind("this") Node inliningTarget, - @Cached InternStringNode internStringNode, - @Cached PythonObjectFactory factory) { - return internStrings(inliningTarget, self.getNames(), internStringNode, factory); + @Cached InternStringNode internStringNode) { + return internStrings(inliningTarget, self.getNames(), internStringNode); } } @@ -250,9 +246,8 @@ public abstract static class GetVarNamesNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, @Bind("this") Node inliningTarget, - @Cached InternStringNode internStringNode, - @Cached PythonObjectFactory factory) { - return internStrings(inliningTarget, self.getVarnames(), internStringNode, factory); + @Cached InternStringNode internStringNode) { + return internStrings(inliningTarget, self.getVarnames(), internStringNode); } } @@ -263,13 +258,13 @@ static Object get(PCode self, public abstract static class GetLineTableNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PCode self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { byte[] linetable = self.getLinetable(); if (linetable == null) { // TODO: this is for the moment undefined (see co_code) linetable = PythonUtils.EMPTY_BYTE_ARRAY; } - return factory.createBytes(linetable); + return PFactory.createBytes(language, linetable); } } @@ -279,9 +274,9 @@ abstract static class GetExceptionTableNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object get(PCode self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // We store our exception table together with the bytecode, not in this field - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } } @@ -296,7 +291,7 @@ private static final class IteratorData { @Specialization @TruffleBoundary static Object lines(PCode self) { - PythonObjectFactory factory = PythonContext.get(null).factory(); + PythonLanguage language = PythonLanguage.get(null); PTuple tuple; CodeUnit co = self.getCodeUnit(); if (co != null) { @@ -308,15 +303,15 @@ static Object lines(PCode self) { co.iterateBytecode((int bci, OpCodes op, int oparg, byte[] followingArgs) -> { int nextStart = bci + op.length(); if (map.startLineMap[bci] != data.line || nextStart == co.code.length) { - lines.add(factory.createTuple(new int[]{data.start, nextStart, data.line})); + lines.add(PFactory.createTuple(language, new int[]{data.start, nextStart, data.line})); data.line = map.startLineMap[bci]; data.start = nextStart; } }); } - tuple = factory.createTuple(lines.toArray()); + tuple = PFactory.createTuple(language, lines.toArray()); } else { - tuple = factory.createEmptyTuple(); + tuple = PFactory.createEmptyTuple(language); } return PyObjectGetIter.executeUncached(tuple); } @@ -329,7 +324,7 @@ abstract static class CoPositionsNode extends PythonUnaryBuiltinNode { @Specialization @TruffleBoundary Object positions(PCode self) { - PythonObjectFactory factory = PythonContext.get(null).factory(); + PythonLanguage language = PythonLanguage.get(null); PTuple tuple; CodeUnit co = self.getCodeUnit(); if (co != null) { @@ -338,13 +333,13 @@ Object positions(PCode self) { if (map != null && map.startLineMap.length > 0) { byte[] bytecode = co.code; for (int i = 0; i < bytecode.length;) { - lines.add(factory.createTuple(new int[]{map.startLineMap[i], map.endLineMap[i], map.startColumnMap[i], map.endColumnMap[i]})); + lines.add(PFactory.createTuple(language, new int[]{map.startLineMap[i], map.endLineMap[i], map.startColumnMap[i], map.endColumnMap[i]})); i += OpCodes.fromOpCode(bytecode[i]).length(); } } - tuple = factory.createTuple(lines.toArray()); + tuple = PFactory.createTuple(language, lines.toArray()); } else { - tuple = factory.createEmptyTuple(); + tuple = PFactory.createEmptyTuple(language); } return PyObjectGetIter.executeUncached(tuple); } @@ -405,17 +400,17 @@ public abstract static class CodeHashNode extends PythonUnaryBuiltinNode { @Specialization static long hash(VirtualFrame frame, PCode self, @Bind("this") Node inliningTarget, - @Cached PyObjectHashNode hashNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached PyObjectHashNode hashNode) { long h, h0, h1, h2, h3, h4, h5, h6; h0 = hashNode.execute(frame, inliningTarget, self.co_name()); - h1 = hashNode.execute(frame, inliningTarget, self.co_code(factory)); - h2 = hashNode.execute(frame, inliningTarget, self.co_consts(factory)); - h3 = hashNode.execute(frame, inliningTarget, self.co_names(factory)); - h4 = hashNode.execute(frame, inliningTarget, self.co_varnames(factory)); - h5 = hashNode.execute(frame, inliningTarget, self.co_freevars(factory)); - h6 = hashNode.execute(frame, inliningTarget, self.co_cellvars(factory)); + h1 = hashNode.execute(frame, inliningTarget, self.co_code(language)); + h2 = hashNode.execute(frame, inliningTarget, self.co_consts(language)); + h3 = hashNode.execute(frame, inliningTarget, self.co_names(language)); + h4 = hashNode.execute(frame, inliningTarget, self.co_varnames(language)); + h5 = hashNode.execute(frame, inliningTarget, self.co_freevars(language)); + h6 = hashNode.execute(frame, inliningTarget, self.co_cellvars(language)); h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ h6 ^ self.co_argcount() ^ self.co_posonlyargcount() ^ self.co_kwonlyargcount() ^ @@ -509,9 +504,10 @@ private static boolean hasStrings(Object[] values) { return false; } - private static PTuple internStrings(Node inliningTarget, Object[] values, InternStringNode internStringNode, PythonObjectFactory factory) { + private static PTuple internStrings(Node inliningTarget, Object[] values, InternStringNode internStringNode) { + PythonLanguage language = PythonLanguage.get(inliningTarget); if (values == null) { - return factory.createEmptyTuple(); + return PFactory.createEmptyTuple(language); } Object[] result; if (!hasStrings(values)) { @@ -526,6 +522,6 @@ private static PTuple internStrings(Node inliningTarget, Object[] values, Intern } } } - return factory.createTuple(result); + return PFactory.createTuple(language, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java index 5b0bf0374b..1869dc930c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java @@ -59,7 +59,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.Supplier; import com.oracle.truffle.api.CallTarget; @@ -143,19 +143,18 @@ private static PCode createCode(PythonLanguage language, PythonContext context, parameterNames, kwOnlyNames); } else { - ct = create().deserializeForBytecodeInterpreter(language, codedata, cellvars, freevars); + ct = create().deserializeForBytecodeInterpreter(context, codedata, cellvars, freevars); signature = ((PRootNode) ct.getRootNode()).getSignature(); } if (filename != null) { context.setCodeFilename(ct, filename); } - PythonObjectFactory factory = context.factory(); - return factory.createCode(ct, signature, nlocals, stacksize, flags, constants, names, varnames, freevars, cellvars, filename, name, qualname, firstlineno, linetable); + return PFactory.createCode(language, ct, signature, nlocals, stacksize, flags, constants, names, varnames, freevars, cellvars, filename, name, qualname, firstlineno, linetable); } @SuppressWarnings("static-method") - private RootCallTarget deserializeForBytecodeInterpreter(PythonLanguage language, byte[] data, TruffleString[] cellvars, TruffleString[] freevars) { - CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(data); + private RootCallTarget deserializeForBytecodeInterpreter(PythonContext context, byte[] data, TruffleString[] cellvars, TruffleString[] freevars) { + CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(context, data); if (cellvars != null && !Arrays.equals(code.cellvars, cellvars) || freevars != null && !Arrays.equals(code.freevars, freevars)) { code = new CodeUnit(code.name, code.qualname, code.argCount, code.kwOnlyArgCount, code.positionalOnlyArgCount, code.stacksize, code.code, code.srcOffsetTable, code.flags, code.names, code.varnames, @@ -165,9 +164,9 @@ private RootCallTarget deserializeForBytecodeInterpreter(PythonLanguage language code.outputCanQuicken, code.variableShouldUnbox, code.generalizeInputsMap, code.generalizeVarsMap); } - RootNode rootNode = PBytecodeRootNode.create(language, code, PythonUtils.createFakeSource()); + RootNode rootNode = PBytecodeRootNode.create(context.getLanguage(), code, PythonUtils.createFakeSource()); if (code.isGeneratorOrCoroutine()) { - rootNode = new PBytecodeGeneratorFunctionRootNode(language, rootNode.getFrameDescriptor(), (PBytecodeRootNode) rootNode, code.name); + rootNode = new PBytecodeGeneratorFunctionRootNode(context.getLanguage(), rootNode.getFrameDescriptor(), (PBytecodeRootNode) rootNode, code.name); } return PythonUtils.getOrCreateCallTarget(rootNode); } @@ -183,12 +182,11 @@ public static PCode createCode(PythonContext context, int flags, byte[] codedata return context.getEnv().parsePublic(source); }; - PythonObjectFactory factory = context.factory(); if (context.isCoreInitialized() || isNotAModule) { - return factory.createCode(createCode, flags, firstlineno, lnotab, filename); + return PFactory.createCode(language, createCode, flags, firstlineno, lnotab, filename); } else { RootCallTarget ct = (RootCallTarget) language.cacheCode(filename, createCode); - return factory.createCode(ct, flags, firstlineno, lnotab, filename); + return PFactory.createCode(language, ct, flags, firstlineno, lnotab, filename); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java index 90dfe41bac..fed0025ac1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -68,7 +68,7 @@ import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; @@ -527,31 +527,28 @@ public Object[] getConstants() { @TruffleBoundary private static Object convertConstantToPythonSpace(RootNode rootNode, Object o) { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - if (o instanceof CodeUnit) { - CodeUnit code = ((CodeUnit) o); - PBytecodeRootNode bytecodeRootNode = PBytecodeRootNode.create(PythonLanguage.get(rootNode), code, getSourceSection(rootNode).getSource()); - return factory.createCode(bytecodeRootNode.getCallTarget(), bytecodeRootNode.getSignature(), code); + PythonLanguage language = PythonLanguage.get(null); + if (o instanceof CodeUnit code) { + PBytecodeRootNode bytecodeRootNode = PBytecodeRootNode.create(language, code, getSourceSection(rootNode).getSource()); + return PFactory.createCode(language, bytecodeRootNode.getCallTarget(), bytecodeRootNode.getSignature(), code); } else if (o instanceof BigInteger) { - return factory.createInt((BigInteger) o); + return PFactory.createInt(language, (BigInteger) o); } else if (o instanceof int[]) { - return factory.createTuple((int[]) o); + return PFactory.createTuple(language, (int[]) o); } else if (o instanceof long[]) { - return factory.createTuple(new LongSequenceStorage((long[]) o)); + return PFactory.createTuple(language, new LongSequenceStorage((long[]) o)); } else if (o instanceof double[]) { - return factory.createTuple(new DoubleSequenceStorage((double[]) o)); + return PFactory.createTuple(language, new DoubleSequenceStorage((double[]) o)); } else if (o instanceof boolean[]) { - return factory.createTuple(new BoolSequenceStorage((boolean[]) o)); + return PFactory.createTuple(language, new BoolSequenceStorage((boolean[]) o)); } else if (o instanceof byte[]) { - return factory.createBytes((byte[]) o); - } else if (o instanceof TruffleString[]) { - TruffleString[] strings = (TruffleString[]) o; + return PFactory.createBytes(language, (byte[]) o); + } else if (o instanceof TruffleString[] strings) { Object[] array = new Object[strings.length]; System.arraycopy(strings, 0, array, 0, strings.length); - return factory.createTuple(array); - } else if (o instanceof Object[]) { - Object[] objects = (Object[]) o; - return factory.createTuple(objects.clone()); + return PFactory.createTuple(language, array); + } else if (o instanceof Object[] objects) { + return PFactory.createTuple(language, objects.clone()); } // Ensure no conversion is missing assert !IsForeignObjectNode.executeUncached(o) : o; @@ -709,20 +706,20 @@ public String toDisassembledString(boolean quickened) { return J_EMPTY_STRING; } - private static PTuple createTuple(Object[] array, PythonObjectFactory factory) { + private static PTuple createTuple(PythonLanguage language, Object[] array) { Object[] data = array; if (data == null) { data = PythonUtils.EMPTY_OBJECT_ARRAY; } - return factory.createTuple(data); + return PFactory.createTuple(language, data); } - private static PBytes createBytes(byte[] array, PythonObjectFactory factory) { + private static PBytes createBytes(byte[] array, PythonLanguage language) { byte[] bytes = array; if (bytes == null) { bytes = PythonUtils.EMPTY_BYTE_ARRAY; } - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } public TruffleString co_name() { @@ -743,32 +740,32 @@ public TruffleString co_filename() { return fName; } - public PBytes co_code(PythonObjectFactory factory) { - return createBytes(this.getCodestring(), factory); + public PBytes co_code(PythonLanguage language) { + return createBytes(this.getCodestring(), language); } - public PBytes co_lnotab(PythonObjectFactory factory) { - return createBytes(this.getLinetable(), factory); + public PBytes co_lnotab(PythonLanguage language) { + return createBytes(this.getLinetable(), language); } - public PTuple co_consts(PythonObjectFactory factory) { - return createTuple(this.getConstants(), factory); + public PTuple co_consts(PythonLanguage language) { + return createTuple(language, this.getConstants()); } - public PTuple co_names(PythonObjectFactory factory) { - return createTuple(this.getNames(), factory); + public PTuple co_names(PythonLanguage language) { + return createTuple(language, this.getNames()); } - public PTuple co_varnames(PythonObjectFactory factory) { - return createTuple(this.getVarnames(), factory); + public PTuple co_varnames(PythonLanguage language) { + return createTuple(language, this.getVarnames()); } - public PTuple co_freevars(PythonObjectFactory factory) { - return createTuple(this.getFreeVars(), factory); + public PTuple co_freevars(PythonLanguage language) { + return createTuple(language, this.getFreeVars()); } - public PTuple co_cellvars(PythonObjectFactory factory) { - return createTuple(this.getCellVars(), factory); + public PTuple co_cellvars(PythonLanguage language) { + return createTuple(language, this.getCellVars()); } public int co_argcount() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java index 70c5e1110e..3e1e1ee89c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java @@ -45,6 +45,7 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.ints.PInt; @@ -58,8 +59,9 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.nodes.util.CastToJavaUnsignedLongNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.BufferFormat; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -125,12 +127,12 @@ static long unpackSignedLong(@SuppressWarnings("unused") BufferFormat format, Ob @Specialization(guards = "format == UINT_64") static Object unpackUnsignedLong(Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object buffer, int offset, + @Bind PythonLanguage language, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached InlinedConditionProfile needsPIntProfile, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { + @Cached InlinedConditionProfile needsPIntProfile) { long signedLong = bufferLib.readLong(buffer, offset); if (needsPIntProfile.profile(inliningTarget, signedLong < 0)) { - return factory.createInt(PInt.longToUnsignedBigInteger(signedLong)); + return PFactory.createInt(language, PInt.longToUnsignedBigInteger(signedLong)); } else { return signedLong; } @@ -156,9 +158,9 @@ static boolean unpackBoolean(@SuppressWarnings("unused") BufferFormat format, Ob @Specialization(guards = "format == CHAR") static PBytes unpackChar(@SuppressWarnings("unused") BufferFormat format, Object buffer, int offset, - @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createBytes(new byte[]{bufferLib.readByte(buffer, offset)}); + @Bind PythonLanguage language, + @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib) { + return PFactory.createBytes(language, new byte[]{bufferLib.readByte(buffer, offset)}); } @Specialization(guards = "format == UNICODE") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/KeywordsStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/KeywordsStorage.java index 39f4671f52..2008765880 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/KeywordsStorage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/KeywordsStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -68,7 +68,7 @@ public class KeywordsStorage extends HashingStorage { final PKeyword[] keywords; - protected KeywordsStorage(PKeyword[] keywords) { + public KeywordsStorage(PKeyword[] keywords) { this.keywords = keywords; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index deadffaff8..3406fd3255 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -43,6 +43,7 @@ import java.lang.reflect.Array; import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.SysModuleBuiltins; import com.oracle.graal.python.builtins.objects.bytes.BytesNodes; @@ -112,7 +113,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.native_memory.NativeBuffer; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ArrayBasedSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; @@ -193,7 +194,7 @@ private static Object getItem(Node inliningTarget, SequenceStorage storage, int @FunctionalInterface public interface StorageWrapperFactory { - Object create(PythonObjectFactory factory, SequenceStorage newStorage); + Object create(PythonLanguage language, SequenceStorage newStorage); } @GenerateInline @@ -215,7 +216,7 @@ abstract Object executeImpl(VirtualFrame frame, Node inliningTarget, SequenceSto @Specialization(guards = "!isPSlice(idx)") static Object doNonSlice(VirtualFrame frame, Node inliningTarget, SequenceStorage storage, Object idx, - TruffleString indexBoundsErrorMessage, StorageWrapperFactory wrapperFactory, + TruffleString indexBoundsErrorMessage, @SuppressWarnings("unused") StorageWrapperFactory wrapperFactory, @Cached PyNumberAsSizeNode numberAsSizeNode, @Cached InlinedConditionProfile negativeIndexProfile, @Cached PRaiseNode.Lazy raiseNode, @@ -229,15 +230,15 @@ static Object doNonSlice(VirtualFrame frame, Node inliningTarget, SequenceStorag @Specialization static Object doSlice(VirtualFrame frame, Node inliningTarget, SequenceStorage storage, PSlice slice, - @SuppressWarnings("unused") TruffleString indexBoundsErrorMessage, StorageWrapperFactory wrapperFactory, - @Cached(inline = false) PythonObjectFactory factory, + TruffleString indexBoundsErrorMessage, StorageWrapperFactory wrapperFactory, + @Bind PythonLanguage language, @Cached CoerceToIntSlice sliceCast, @Cached(inline = false) ComputeIndices compute, @Cached(inline = false) GetItemSliceNode getItemSliceNode, @Cached LenOfRangeNode sliceLen) { SliceInfo info = compute.execute(frame, sliceCast.execute(inliningTarget, slice), storage.length()); SequenceStorage newStorage = getItemSliceNode.execute(storage, info.start, info.stop, info.step, sliceLen.len(inliningTarget, info)); - return wrapperFactory.create(factory, newStorage); + return wrapperFactory.create(language, newStorage); } } @@ -404,9 +405,9 @@ public abstract static class GetItemNode extends NormalizingNode { @Child private GetItemScalarNode getItemScalarNode; @Child private GetItemSliceNode getItemSliceNode; - private final BiFunction factoryMethod; + private final BiFunction factoryMethod; - public GetItemNode(NormalizeIndexNode normalizeIndexNode, BiFunction factoryMethod) { + public GetItemNode(NormalizeIndexNode normalizeIndexNode, BiFunction factoryMethod) { super(normalizeIndexNode); this.factoryMethod = factoryMethod; } @@ -462,13 +463,12 @@ protected Object doScalarGeneric(VirtualFrame frame, SequenceStorage storage, Ob @SuppressWarnings("truffle-static-method") protected Object doSlice(VirtualFrame frame, SequenceStorage storage, PSlice slice, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, @Cached CoerceToIntSlice sliceCast, @Cached ComputeIndices compute, @Cached LenOfRangeNode sliceLen) { SliceInfo info = compute.execute(frame, sliceCast.execute(inliningTarget, slice), storage.length()); if (factoryMethod != null) { - return factoryMethod.apply(getGetItemSliceNode().execute(storage, info.start, info.stop, info.step, sliceLen.len(inliningTarget, info)), factory); + return factoryMethod.apply(getGetItemSliceNode().execute(storage, info.start, info.stop, info.step, sliceLen.len(inliningTarget, info)), PythonLanguage.get(inliningTarget)); } CompilerDirectives.transferToInterpreterAndInvalidate(); throw new IllegalStateException(); @@ -506,18 +506,18 @@ public static GetItemNode create() { } @NeverDefault - public static GetItemNode create(NormalizeIndexNode normalizeIndexNode, BiFunction factoryMethod) { + public static GetItemNode create(NormalizeIndexNode normalizeIndexNode, BiFunction factoryMethod) { return GetItemNodeGen.create(normalizeIndexNode, factoryMethod); } @NeverDefault public static SequenceStorageNodes.GetItemNode createForList() { - return SequenceStorageNodes.GetItemNode.create(NormalizeIndexNode.forList(), (s, f) -> f.createList(s)); + return SequenceStorageNodes.GetItemNode.create(NormalizeIndexNode.forList(), (s, l) -> PFactory.createList(l, s)); } @NeverDefault public static SequenceStorageNodes.GetItemNode createForTuple() { - return SequenceStorageNodes.GetItemNode.create(NormalizeIndexNode.forTuple(), (s, f) -> f.createTuple(s)); + return SequenceStorageNodes.GetItemNode.create(NormalizeIndexNode.forTuple(), (s, l) -> PFactory.createTuple(l, s)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java index ae48d00b1a..c24a8823e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java @@ -60,6 +60,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -101,14 +102,13 @@ import com.oracle.graal.python.runtime.formatting.ComplexFormatter; import com.oracle.graal.python.runtime.formatting.InternalFormat; import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -213,13 +213,12 @@ abstract static class ComplexNode extends PythonUnaryBuiltinNode { static Object complex(Object self, @Bind("this") Node inliningTarget, @Cached PyComplexCheckExactNode check, - @Cached ToComplexValueNode toComplexValueNode, - @Cached PythonObjectFactory.Lazy factory) { + @Cached ToComplexValueNode toComplexValueNode) { if (check.execute(inliningTarget, self)) { return self; } else { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); - return factory.get(inliningTarget).createComplex(c.real, c.imag); + return PFactory.createComplex(PythonLanguage.get(inliningTarget), c.real, c.imag); } } } @@ -380,14 +379,14 @@ public static AbsNode create() { abstract static class AddNode extends BinaryOpBuiltinNode { @Specialization static PComplex doInt(PComplex left, int right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createComplex(left.getReal() + right, left.getImag()); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, left.getReal() + right, left.getImag()); } @Specialization static PComplex doDouble(PComplex left, double right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createComplex(left.getReal() + right, left.getImag()); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, left.getReal() + right, left.getImag()); } @Specialization @@ -396,13 +395,13 @@ static Object doGeneric(Object leftObj, Object rightObj, @Cached ToComplexValueNode toComplexLeft, @Cached ToComplexValueNode toComplexRight, @Cached InlinedConditionProfile notImplementedProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); if (notImplementedProfile.profile(inliningTarget, left == null || right == null)) { return PNotImplemented.NOT_IMPLEMENTED; } - return factory.createComplex(left.getReal() + right.getReal(), left.getImag() + right.getImag()); + return PFactory.createComplex(language, left.getReal() + right.getReal(), left.getImag() + right.getImag()); } } @@ -425,7 +424,7 @@ static Object doComplex(Object leftObj, Object rightObj, @Cached InlinedConditionProfile notImplementedProfile, @Cached InlinedConditionProfile topConditionProfile, @Cached InlinedConditionProfile zeroDivisionProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); @@ -453,16 +452,16 @@ static Object doComplex(Object leftObj, Object rightObj, real = (left.getReal() * ratio + left.getImag()) / denom; imag = (left.getImag() * ratio - left.getReal()) / denom; } - return factory.createComplex(real, imag); + return PFactory.createComplex(language, real, imag); } - static PComplex doubleDivComplex(double left, PComplex right, PythonObjectFactory factory) { + static PComplex doubleDivComplex(double left, PComplex right, PythonLanguage language) { double oprealSq = right.getReal() * right.getReal(); double opimagSq = right.getImag() * right.getImag(); double realPart = right.getReal() * left; double imagPart = right.getImag() * left; double denom = oprealSq + opimagSq; - return factory.createComplex(realPart / denom, -imagPart / denom); + return PFactory.createComplex(language, realPart / denom, -imagPart / denom); } } @@ -475,14 +474,14 @@ static Object doComplex(Object leftObj, Object rightObj, @Cached ToComplexValueNode toComplexLeft, @Cached ToComplexValueNode toComplexRight, @Cached InlinedConditionProfile notImplementedProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); if (notImplementedProfile.profile(inliningTarget, left == null || right == null)) { return PNotImplemented.NOT_IMPLEMENTED; } ComplexValue res = multiply(left, right); - return factory.createComplex(res.getReal(), res.getImag()); + return PFactory.createComplex(language, res.getReal(), res.getImag()); } static ComplexValue multiply(ComplexValue left, ComplexValue right) { @@ -496,14 +495,14 @@ static ComplexValue multiply(ComplexValue left, ComplexValue right) { @Slot(value = SlotKind.nb_subtract, isComplex = true) abstract static class SubNode extends BinaryOpBuiltinNode { static PComplex doComplex(PComplex left, double right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createComplex(left.getReal() - right, left.getImag()); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, left.getReal() - right, left.getImag()); } @Specialization static PComplex doComplex(PComplex left, int right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createComplex(left.getReal() - right, left.getImag()); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, left.getReal() - right, left.getImag()); } @Specialization @@ -512,13 +511,13 @@ static Object doComplex(Object leftObj, Object rightObj, @Cached ToComplexValueNode toComplexLeft, @Cached ToComplexValueNode toComplexRight, @Cached InlinedConditionProfile notImplementedProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); if (notImplementedProfile.profile(inliningTarget, left == null || right == null)) { return PNotImplemented.NOT_IMPLEMENTED; } - return factory.createComplex(left.getReal() - right.getReal(), left.getImag() - right.getImag()); + return PFactory.createComplex(language, left.getReal() - right.getReal(), left.getImag() - right.getImag()); } } @@ -537,7 +536,7 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus @Cached InlinedBranchProfile smallPositiveProfile, @Cached InlinedBranchProfile smallNegativeProfile, @Cached InlinedBranchProfile complexProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); @@ -547,24 +546,24 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus PComplex result; if (right.getReal() == 0.0 && right.getImag() == 0.0) { rightZeroProfile.enter(inliningTarget); - result = factory.createComplex(1.0, 0.0); + result = PFactory.createComplex(language, 1.0, 0.0); } else if (left.getReal() == 0.0 && left.getImag() == 0.0) { leftZeroProfile.enter(inliningTarget); if (right.getImag() != 0.0 || right.getReal() < 0.0) { throw PRaiseNode.raiseUncached(inliningTarget, ZeroDivisionError, ErrorMessages.COMPLEX_ZERO_TO_NEGATIVE_POWER); } - result = factory.createComplex(0.0, 0.0); + result = PFactory.createComplex(language, 0.0, 0.0); } else if (right.getImag() == 0.0 && right.getReal() == (int) right.getReal() && right.getReal() < 100 && right.getReal() > -100) { if (right.getReal() >= 0) { smallPositiveProfile.enter(inliningTarget); - result = complexToSmallPositiveIntPower(left, (int) right.getReal(), factory); + result = complexToSmallPositiveIntPower(left, (int) right.getReal(), language); } else { smallNegativeProfile.enter(inliningTarget); - result = DivNode.doubleDivComplex(1.0, complexToSmallPositiveIntPower(left, -(int) right.getReal(), factory), factory); + result = DivNode.doubleDivComplex(1.0, complexToSmallPositiveIntPower(left, -(int) right.getReal(), language), language); } } else { complexProfile.enter(inliningTarget); - result = complexToComplexBoundary(left.getReal(), left.getImag(), right.getReal(), right.getImag(), factory); + result = complexToComplexBoundary(left.getReal(), left.getImag(), right.getReal(), right.getImag(), language); } if (Double.isInfinite(result.getReal()) || Double.isInfinite(result.getImag())) { throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.COMPLEX_EXPONENTIATION); @@ -580,7 +579,7 @@ static Object error(Object left, Object right, Object mod, throw raiseNode.raise(ValueError, ErrorMessages.COMPLEX_MODULO); } - private static PComplex complexToSmallPositiveIntPower(ComplexValue x, long n, PythonObjectFactory factory) { + private static PComplex complexToSmallPositiveIntPower(ComplexValue x, long n, PythonLanguage language) { long mask = 1; ComplexValue r = new ComplexValue(1.0, 0.0); ComplexValue p = x; @@ -591,11 +590,11 @@ private static PComplex complexToSmallPositiveIntPower(ComplexValue x, long n, P mask <<= 1; p = MulNode.multiply(p, p); } - return factory.createComplex(r.getReal(), r.getImag()); + return PFactory.createComplex(language, r.getReal(), r.getImag()); } @TruffleBoundary - private static PComplex complexToComplexBoundary(double leftRead, double leftImag, double rightReal, double rightImag, PythonObjectFactory factory) { + private static PComplex complexToComplexBoundary(double leftRead, double leftImag, double rightReal, double rightImag, PythonLanguage language) { PComplex result; double vabs = Math.hypot(leftRead, leftImag); double len = Math.pow(vabs, rightReal); @@ -605,7 +604,7 @@ private static PComplex complexToComplexBoundary(double leftRead, double leftIma len /= Math.exp(at * rightImag); phase += rightImag * Math.log(vabs); } - result = factory.createComplex(len * Math.cos(phase), len * Math.sin(phase)); + result = PFactory.createComplex(language, len * Math.cos(phase), len * Math.sin(phase)); return result; } } @@ -806,9 +805,9 @@ abstract static class NegNode extends PythonUnaryBuiltinNode { static PComplex neg(Object self, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); - return factory.createComplex(-c.getReal(), -c.getImag()); + return PFactory.createComplex(language, -c.getReal(), -c.getImag()); } } @@ -819,9 +818,9 @@ abstract static class PosNode extends PythonUnaryBuiltinNode { static PComplex pos(Object self, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); - return factory.createComplex(c.getReal(), c.getImag()); + return PFactory.createComplex(language, c.getReal(), c.getImag()); } } @@ -832,9 +831,9 @@ abstract static class GetNewArgsNode extends PythonUnaryBuiltinNode { static PTuple get(Object self, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); - return factory.createTuple(new Object[]{c.getReal(), c.getImag()}); + return PFactory.createTuple(language, new Object[]{c.getReal(), c.getImag()}); } } @@ -893,9 +892,9 @@ abstract static class ConjugateNode extends PythonUnaryBuiltinNode { static PComplex hash(Object self, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); - return factory.createComplex(c.getReal(), -c.getImag()); + return PFactory.createComplex(language, c.getReal(), -c.getImag()); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java index 9e10d1ea1d..c63dbeaa3a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -64,7 +65,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -110,8 +111,8 @@ Object get(PContextVarsContext self, Object key, public abstract static class Iter extends PythonUnaryBuiltinNode { @Specialization static Object iter(PContextVarsContext self, - @Cached PythonObjectFactory factory) { - return factory.createContextIterator(self, PContextIterator.ItemKind.KEYS); + @Bind PythonLanguage language) { + return PFactory.createContextIterator(language, self, PContextIterator.ItemKind.KEYS); } } @@ -120,8 +121,8 @@ static Object iter(PContextVarsContext self, public abstract static class Keys extends PythonUnaryBuiltinNode { @Specialization static Object keys(PContextVarsContext self, - @Cached PythonObjectFactory factory) { - return factory.createContextIterator(self, PContextIterator.ItemKind.KEYS); + @Bind PythonLanguage language) { + return PFactory.createContextIterator(language, self, PContextIterator.ItemKind.KEYS); } } @@ -130,8 +131,8 @@ static Object keys(PContextVarsContext self, public abstract static class Values extends PythonUnaryBuiltinNode { @Specialization static Object values(PContextVarsContext self, - @Cached PythonObjectFactory factory) { - return factory.createContextIterator(self, PContextIterator.ItemKind.VALUES); + @Bind PythonLanguage language) { + return PFactory.createContextIterator(language, self, PContextIterator.ItemKind.VALUES); } } @@ -140,8 +141,8 @@ static Object values(PContextVarsContext self, public abstract static class Items extends PythonUnaryBuiltinNode { @Specialization static Object items(PContextVarsContext self, - @Cached PythonObjectFactory factory) { - return factory.createContextIterator(self, PContextIterator.ItemKind.ITEMS); + @Bind PythonLanguage language) { + return PFactory.createContextIterator(language, self, PContextIterator.ItemKind.ITEMS); } } @@ -169,8 +170,8 @@ static Object get(VirtualFrame frame, PContextVarsContext self, Object fun, Obje public abstract static class Copy extends PythonUnaryBuiltinNode { @Specialization static Object doCopy(PContextVarsContext self, - @Cached PythonObjectFactory factory) { - PContextVarsContext ret = factory.createContextVarsContext(); + @Bind PythonLanguage language) { + PContextVarsContext ret = PFactory.createContextVarsContext(language); ret.contextVarValues = self.contextVarValues; return ret; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java index fa79001cd4..cb57c10bfd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -52,7 +53,6 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -82,9 +82,9 @@ public abstract static class Next extends PythonUnaryBuiltinNode { @Specialization static Object next(PContextIterator self, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { - Object next = self.next(factory); + Object next = self.next(language); if (next == null) { throw raiseNode.get(inliningTarget).raiseStopIteration(); } else { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java index 8afad6b55f..9ed2bcdb6f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -58,7 +59,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -101,12 +102,12 @@ public abstract static class SetNode extends PythonBinaryBuiltinNode { @Specialization static Object set(PContextVar self, Object value, @Bind("this") Node inliningTarget, - @Bind PythonContext context, - @Cached PythonObjectFactory factory) { - PythonContext.PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); + @Bind PythonContext context) { + PythonLanguage language = context.getLanguage(inliningTarget); + PythonContext.PythonThreadState threadState = context.getThreadState(language); Object oldValue = self.getValue(threadState); self.setValue(threadState, value); - return factory.createContextVarsToken(self, oldValue); + return PFactory.createContextVarsToken(language, self, oldValue); } } @@ -150,8 +151,8 @@ static boolean isToken(Object obj) { public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextIterator.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextIterator.java index 17ab98a5e3..401b98a7f3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextIterator.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -40,8 +40,9 @@ */ package com.oracle.graal.python.builtins.objects.contextvars; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.object.Shape; @@ -51,14 +52,14 @@ public enum ItemKind { VALUES, ITEMS; - public Object apply(Hamt.Entry item, PythonObjectFactory factory) { + public Object apply(Hamt.Entry item, PythonLanguage language) { switch (this) { case KEYS: return item.key; case VALUES: return item.value; case ITEMS: - return factory.createTuple(new Object[]{item.key, item.value}); + return PFactory.createTuple(language, new Object[]{item.key, item.value}); default: throw CompilerDirectives.shouldNotReachHere("null ItemKind in PHamtIterator"); } @@ -76,8 +77,8 @@ public PContextIterator(Object cls, Shape instanceShape, PContextVarsContext ctx } // can return null - public Object next(PythonObjectFactory factory) { + public Object next(PythonLanguage language) { Hamt.Entry item = it.next(); - return item == null ? null : kind.apply(item, factory); + return item == null ? null : kind.apply(item, language); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/TokenBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/TokenBuiltins.java index 231f12ad28..8b7d248873 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/TokenBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/TokenBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -54,8 +55,8 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -101,8 +102,8 @@ public void postInitialize(Python3Core core) { public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java index afaec0767f..b9ad4d96ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java @@ -77,6 +77,7 @@ import java.util.Iterator; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -95,6 +96,7 @@ import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode; @@ -124,7 +126,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -290,9 +292,11 @@ public abstract static class DequeCopyNode extends PythonUnaryBuiltinNode { @Specialization static PDeque doGeneric(PDeque self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { - PDeque copy = factory.createDeque(getClassNode.execute(inliningTarget, self)); + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + Object cls = getClassNode.execute(inliningTarget, self); + PDeque copy = PFactory.createDeque(language, cls, getInstanceShape.execute(cls)); copy.setMaxLength(self.getMaxLength()); copy.addAll(self); return copy; @@ -720,7 +724,7 @@ public abstract static class DequeAddNode extends SqConcatBuiltinNode { @Specialization @TruffleBoundary static PDeque doDeque(PDeque self, PDeque other) { - PDeque newDeque = PythonObjectFactory.getUncached().createDeque(); + PDeque newDeque = PFactory.createDeque(PythonLanguage.get(null)); newDeque.setMaxLength(self.getMaxLength()); newDeque.addAll(self); newDeque.addAll(other); @@ -790,7 +794,7 @@ public abstract static class DequeMulNode extends SqRepeatBuiltinNode { @Specialization @TruffleBoundary PDeque doGeneric(PDeque self, int n) { - PDeque newDeque = PythonObjectFactory.getUncached().createDeque(); + PDeque newDeque = PFactory.createDeque(PythonLanguage.get(null)); newDeque.setMaxLength(self.getMaxLength()); newDeque.addAll(self); return DequeInplaceMulNode.doGeneric(this, newDeque, n); @@ -858,8 +862,8 @@ public abstract static class DequeIterNode extends PythonUnaryBuiltinNode { @Specialization static PDequeIter doGeneric(PDeque self, - @Cached PythonObjectFactory factory) { - return factory.createDequeIter(self); + @Bind PythonLanguage language) { + return PFactory.createDequeIter(language, self); } } @@ -870,8 +874,8 @@ public abstract static class DequeReversedNode extends PythonUnaryBuiltinNode { @Specialization static PDequeIter doGeneric(PDeque self, - @Cached PythonObjectFactory factory) { - return factory.createDequeRevIter(self); + @Bind PythonLanguage language) { + return PFactory.createDequeRevIter(language, self); } } @@ -890,7 +894,7 @@ TruffleString repr(PDeque self) { Node outerNode = ref.set(this); try { Object[] items = self.data.toArray(); - PList asList = PythonObjectFactory.getUncached().createList(items); + PList asList = PFactory.createList(PythonLanguage.get(null), items); int maxLength = self.getMaxLength(); TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); sb.appendStringUncached(GetNameNode.executeUncached(GetPythonObjectClassNode.executeUncached(self))); @@ -919,16 +923,16 @@ Object doGeneric(VirtualFrame frame, PDeque self, @Cached PyObjectGetIter getIter, @Cached PyObjectGetStateNode getStateNode, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object clazz = getClassNode.execute(inliningTarget, self); Object state = getStateNode.execute(frame, inliningTarget, self); Object it = getIter.execute(frame, inliningTarget, self); - PTuple emptyTuple = factory.createEmptyTuple(); + PTuple emptyTuple = PFactory.createEmptyTuple(language); int maxLength = self.getMaxLength(); if (maxLength != -1) { - return factory.createTuple(new Object[]{clazz, factory.createTuple(new Object[]{emptyTuple, maxLength}), state, it}); + return PFactory.createTuple(language, new Object[]{clazz, PFactory.createTuple(language, new Object[]{emptyTuple, maxLength}), state, it}); } - return factory.createTuple(new Object[]{clazz, emptyTuple, state, it}); + return PFactory.createTuple(language, new Object[]{clazz, emptyTuple, state, it}); } } @@ -1069,8 +1073,8 @@ static Object doCmp(VirtualFrame frame, Object self, Object other, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java index 66e8f2e586..4f247352db 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -50,6 +50,7 @@ import java.util.List; import java.util.NoSuchElementException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -60,7 +61,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -137,9 +138,9 @@ public abstract static class DequeIterReduceNode extends PythonUnaryBuiltinNode static PTuple doGeneric(PDequeIter self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object clazz = getClassNode.execute(inliningTarget, self); - return factory.createTuple(new Object[]{clazz, factory.createTuple(new Object[]{self.deque, self.deque.getSize() - self.lengthHint()})}); + return PFactory.createTuple(language, new Object[]{clazz, PFactory.createTuple(language, new Object[]{self.deque, self.deque.getSize() - self.lengthHint()})}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java index eefa3beb93..808dfc44b6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -75,7 +76,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -124,11 +125,11 @@ static Object reduce(VirtualFrame frame, PDefaultDict self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { final Object defaultFactory = self.getDefaultFactory(); - PTuple args = (defaultFactory == PNone.NONE) ? factory.createEmptyTuple() : factory.createTuple(new Object[]{defaultFactory}); - Object iter = getIter.execute(frame, inliningTarget, factory.createDictItemsView(self)); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args, PNone.NONE, PNone.NONE, iter}); + PTuple args = (defaultFactory == PNone.NONE) ? PFactory.createEmptyTuple(language) : PFactory.createTuple(language, new Object[]{defaultFactory}); + Object iter = getIter.execute(frame, inliningTarget, PFactory.createDictItemsView(language, self)); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args, PNone.NONE, PNone.NONE, iter}); } } @@ -140,8 +141,8 @@ public abstract static class CopyNode extends PythonUnaryBuiltinNode { static PDefaultDict copy(@SuppressWarnings("unused") VirtualFrame frame, PDefaultDict self, @Bind("this") Node inliningTarget, @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory) { - return factory.createDefaultDict(self.getDefaultFactory(), copyNode.execute(inliningTarget, self.getDictStorage())); + @Bind PythonLanguage language) { + return PFactory.createDefaultDict(language, self.getDefaultFactory(), copyNode.execute(inliningTarget, self.getDictStorage())); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java index 3a23d26d0b..d831723eb7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java @@ -42,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -236,14 +237,14 @@ static Object popItem(Object dict, @Bind("this") Node inliningTarget, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStoragePop popNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { var storage = getStorageNode.execute(inliningTarget, dict); Object[] result = popNode.execute(inliningTarget, storage, dict); if (result == null) { throw raiseNode.get(inliningTarget).raise(KeyError, ErrorMessages.IS_EMPTY, "popitem(): dictionary"); } - return factory.createTuple(result); + return PFactory.createTuple(language, result); } } @@ -254,14 +255,14 @@ public abstract static class KeysNode extends PythonUnaryBuiltinNode { @Specialization static PDictView keys(PDict self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictKeysView(self); + @Bind PythonLanguage language) { + return PFactory.createDictKeysView(language, self); } @Fallback static PDictView foreign(Object self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictKeysView(self, new ForeignHashingStorage(self)); + @Bind PythonLanguage language) { + return PFactory.createDictKeysView(language, self, new ForeignHashingStorage(self)); } } @@ -272,14 +273,14 @@ public abstract static class ItemsNode extends PythonUnaryBuiltinNode { @Specialization static PDictView items(PDict self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictItemsView(self); + @Bind PythonLanguage language) { + return PFactory.createDictItemsView(language, self); } @Fallback static PDictView foreign(Object self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictItemsView(self, new ForeignHashingStorage(self)); + @Bind PythonLanguage language) { + return PFactory.createDictItemsView(language, self, new ForeignHashingStorage(self)); } } @@ -382,9 +383,9 @@ static Object run(Object self, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetIterator getIterator, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { var storage = getStorageNode.execute(inliningTarget, self); - return factory.createDictKeyIterator(getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictKeyIterator(language, getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } @@ -397,9 +398,9 @@ static Object run(Object self, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetReverseIterator getReverseIterator, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { var storage = getStorageNode.execute(inliningTarget, self); - return factory.createDictKeyIterator(getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictKeyIterator(language, getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } @@ -468,9 +469,9 @@ static PDict copy(Object dict, @Bind("this") Node inliningTarget, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { var storage = getStorageNode.execute(inliningTarget, dict); - return factory.createDict(copyNode.execute(inliningTarget, storage)); + return PFactory.createDict(language, copyNode.execute(inliningTarget, storage)); } } @@ -499,14 +500,14 @@ public abstract static class ValuesNode extends PythonUnaryBuiltinNode { @Specialization static PDictView values(PDict self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictValuesView(self); + @Bind PythonLanguage language) { + return PFactory.createDictValuesView(language, self); } @Fallback static PDictView foreign(Object self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDictValuesView(self, new ForeignHashingStorage(self)); + @Bind PythonLanguage language) { + return PFactory.createDictValuesView(language, self, new ForeignHashingStorage(self)); } } @@ -561,13 +562,13 @@ static Object error(Object self, Object[] args, PKeyword[] kwargs, public abstract static class FromKeysNode extends PythonTernaryBuiltinNode { @Specialization(guards = "isBuiltinDict(inliningTarget, cls, isSameTypeNode)", limit = "1") - static Object doKeys(VirtualFrame frame, Object cls, Object iterable, Object value, + static Object doKeys(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object iterable, Object value, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Cached IsSameTypeNode isSameTypeNode, @Cached HashingCollectionNodes.GetClonedHashingStorageNode getHashingStorageNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage s = getHashingStorageNode.execute(frame, inliningTarget, iterable, value); - return factory.createDict(cls, s); + return PFactory.createDict(language, s); } @Fallback @@ -609,9 +610,9 @@ static PDict or(VirtualFrame frame, Object self, Object other, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStorageCopy copyNode, @Cached DictNodes.UpdateNode updateNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { var storage = getStorageNode.execute(inliningTarget, self); - PDict merged = factory.createDict(copyNode.execute(inliningTarget, storage)); + PDict merged = PFactory.createDict(language, copyNode.execute(inliningTarget, storage)); updateNode.execute(frame, merged, other); return merged; } @@ -639,8 +640,8 @@ Object or(VirtualFrame frame, Object self, Object other, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java index e442eb1674..010b4831f3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -30,6 +30,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -45,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -68,8 +69,8 @@ protected List> getNodeFa abstract static class MappingNode extends PythonUnaryBuiltinNode { @Specialization static Object mapping(PDictView self, - @Cached PythonObjectFactory factory) { - return factory.createMappingproxy(self.getWrappedDict()); + @Bind PythonLanguage language) { + return PFactory.createMappingproxy(language, self.getWrappedDict()); } } @@ -93,9 +94,9 @@ static Object doPDictValuesView(PDictValuesView self, @Bind("this") Node inliningTarget, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetIterator getIterator, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictValueIterator(getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictValueIterator(language, getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } @@ -107,9 +108,9 @@ static Object doPDictValuesView(PDictValuesView self, @Bind("this") Node inliningTarget, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetReverseIterator getReverseIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictValueIterator(getReverseIter.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictValueIterator(language, getReverseIter.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java index e93012e83c..f605099833 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.truffle.api.CompilerDirectives; @@ -131,8 +132,8 @@ protected List> getNodeFa abstract static class MappingNode extends PythonUnaryBuiltinNode { @Specialization static Object mapping(PDictView self, - @Cached PythonObjectFactory factory) { - return factory.createMappingproxy(self.getWrappedDict()); + @Bind PythonLanguage language) { + return PFactory.createMappingproxy(language, self.getWrappedDict()); } } @@ -156,9 +157,9 @@ static Object getKeysViewIter(@SuppressWarnings("unused") PDictKeysView self, @Bind("this") Node inliningTarget, @Shared("len") @Cached HashingStorageLen lenNode, @Shared("getit") @Cached HashingStorageGetIterator getIterator, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictKeyIterator(getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictKeyIterator(language, getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } @Specialization @@ -166,9 +167,9 @@ static Object getItemsViewIter(PDictItemsView self, @Bind("this") Node inliningTarget, @Shared("len") @Cached HashingStorageLen lenNode, @Shared("getit") @Cached HashingStorageGetIterator getIterator, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictItemIterator(getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictItemIterator(language, getIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } @@ -180,9 +181,9 @@ static Object getReversedKeysViewIter(PDictKeysView self, @Bind("this") Node inliningTarget, @Shared @Cached HashingStorageLen lenNode, @Shared @Cached HashingStorageGetReverseIterator getReverseIterator, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictKeyIterator(getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictKeyIterator(language, getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } @Specialization @@ -190,9 +191,9 @@ static Object getReversedItemsViewIter(PDictItemsView self, @Bind("this") Node inliningTarget, @Shared @Cached HashingStorageLen lenNode, @Shared @Cached HashingStorageGetReverseIterator getReverseIterator, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getWrappedStorage(); - return factory.createDictItemIterator(getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); + return PFactory.createDictItemIterator(language, getReverseIterator.execute(inliningTarget, storage), storage, lenNode.execute(inliningTarget, storage)); } } @@ -441,18 +442,18 @@ abstract static class SubNode extends BinaryOpBuiltinNode { static PBaseSet doKeysView(VirtualFrame frame, PDictKeysView self, PBaseSet other, @Bind("this") Node inliningTarget, @Shared("diff") @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = diffNode.execute(frame, inliningTarget, self.getWrappedStorage(), other.getDictStorage()); - return factory.createSet(storage); + return PFactory.createSet(language, storage); } @Specialization static PBaseSet doKeysView(VirtualFrame frame, PDictKeysView self, PDictKeysView other, @Bind("this") Node inliningTarget, @Shared("diff") @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = diffNode.execute(frame, inliningTarget, self.getWrappedStorage(), other.getWrappedStorage()); - return factory.createSet(storage); + return PFactory.createSet(language, storage); } @Specialization @@ -460,11 +461,11 @@ static PBaseSet doKeysView(VirtualFrame frame, PDictKeysView self, Object other, @Bind("this") Node inliningTarget, @Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode, @Shared("diff") @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage left = self.getWrappedStorage(); - HashingStorage right = constructSetNode.executeWith(frame, other).getDictStorage(); + HashingStorage right = constructSetNode.execute(frame, other).getDictStorage(); HashingStorage storage = diffNode.execute(frame, inliningTarget, left, right); - return factory.createSet(storage); + return PFactory.createSet(language, storage); } @Specialization @@ -472,10 +473,10 @@ static PBaseSet doItemsView(VirtualFrame frame, PDictItemsView self, PBaseSet ot @Bind("this") Node inliningTarget, @Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode, @Shared("diff") @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { - PSet selfSet = constructSetNode.executeWith(frame, self); + @Bind PythonLanguage language) { + PSet selfSet = constructSetNode.execute(frame, self); HashingStorage storage = diffNode.execute(frame, inliningTarget, selfSet.getDictStorage(), other.getDictStorage()); - return factory.createSet(storage); + return PFactory.createSet(language, storage); } @Specialization @@ -483,11 +484,11 @@ static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other, @Bind("this") Node inliningTarget, @Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode, @Shared("diff") @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { - HashingStorage left = constructSetNode.executeWith(frame, self).getDictStorage(); - HashingStorage right = constructSetNode.executeWith(frame, other).getDictStorage(); + @Bind PythonLanguage language) { + HashingStorage left = constructSetNode.execute(frame, self).getDictStorage(); + HashingStorage right = constructSetNode.execute(frame, other).getDictStorage(); HashingStorage storage = diffNode.execute(frame, inliningTarget, left, right); - return factory.createSet(storage); + return PFactory.createSet(language, storage); } } @@ -509,7 +510,7 @@ static HashingStorage doSet(PBaseSet obj) { @Fallback static HashingStorage doOther(VirtualFrame frame, Object obj, @Cached SetNodes.ConstructSetNode constructSetNode) { - return constructSetNode.executeWith(frame, obj).getDictStorage(); + return constructSetNode.execute(frame, obj).getDictStorage(); } } @@ -533,7 +534,7 @@ static HashingStorage doSet(Node inliningTarget, PBaseSet obj, @Fallback static HashingStorage doOther(VirtualFrame frame, Object obj, @Cached SetNodes.ConstructSetNode constructSetNode) { - return constructSetNode.executeWith(frame, obj).getDictStorage(); + return constructSetNode.execute(frame, obj).getDictStorage(); } } @@ -546,10 +547,10 @@ static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other, @Bind("this") Node inliningTarget, @Cached GetStorageForBinopNode getStorage, @Cached HashingStorageIntersect intersectNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage left = getStorage.execute(frame, inliningTarget, self); HashingStorage right = getStorage.execute(frame, inliningTarget, other); - return factory.createSet(intersectNode.execute(frame, inliningTarget, left, right)); + return PFactory.createSet(language, intersectNode.execute(frame, inliningTarget, left, right)); } } @@ -562,10 +563,10 @@ static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other, @Bind("this") Node inliningTarget, @Cached GetCopiedStorageForBinopNode getStorage, @Cached HashingStorageAddAllToOther addAllToOther, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage left = getStorage.execute(frame, inliningTarget, self); HashingStorage right = getStorage.execute(frame, inliningTarget, other); - return factory.createSet(addAllToOther.execute(frame, inliningTarget, left, right)); + return PFactory.createSet(language, addAllToOther.execute(frame, inliningTarget, left, right)); } } @@ -578,10 +579,10 @@ static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other, @Bind("this") Node inliningTarget, @Cached GetStorageForBinopNode getStorage, @Cached HashingStorageXor xor, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage left = getStorage.execute(frame, inliningTarget, self); HashingStorage right = getStorage.execute(frame, inliningTarget, other); - return factory.createSet(xor.execute(frame, inliningTarget, left, right)); + return PFactory.createSet(language, xor.execute(frame, inliningTarget, left, right)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java index 57f9e9dd34..1238532ef2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -32,6 +32,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -42,7 +43,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -67,12 +68,12 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization static Object doNext(VirtualFrame frame, PEnumerate self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile bigIntIndexProfile, - @Cached GetNextNode next, - @Cached PythonObjectFactory factory) { - Object index = self.getAndIncrementIndex(inliningTarget, factory, bigIntIndexProfile); + @Cached GetNextNode next) { + Object index = self.getAndIncrementIndex(inliningTarget, language, bigIntIndexProfile); Object nextValue = next.execute(frame, self.getDecoratedIterator()); - return factory.createTuple((new Object[]{index, nextValue})); + return PFactory.createTuple(language, (new Object[]{index, nextValue})); } } @@ -92,13 +93,13 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { @Specialization static Object reduce(PEnumerate self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile bigIntIndexProfile, - @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Cached GetClassNode getClassNode) { Object iterator = self.getDecoratedIterator(); Object index = self.getIndex(inliningTarget, bigIntIndexProfile); - PTuple contents = factory.createTuple(new Object[]{iterator, index}); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), contents}); + PTuple contents = PFactory.createTuple(language, new Object[]{iterator, index}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), contents}); } } @@ -107,8 +108,8 @@ static Object reduce(PEnumerate self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/PEnumerate.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/PEnumerate.java index 88d62ba68c..4cc18fb6e4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/PEnumerate.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/PEnumerate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -25,9 +25,10 @@ */ package com.oracle.graal.python.builtins.objects.enumerate; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.profiles.InlinedConditionProfile; @@ -53,10 +54,10 @@ public Object getDecoratedIterator() { return iterator; } - public Object getAndIncrementIndex(Node inliningTarget, PythonObjectFactory factory, InlinedConditionProfile bigIntIndexProfile) { + public Object getAndIncrementIndex(Node inliningTarget, PythonLanguage language, InlinedConditionProfile bigIntIndexProfile) { if (bigIntIndexProfile.profile(inliningTarget, bigIndex != null)) { PInt idx = bigIndex; - bigIndex = factory.createInt(bigIndex.inc()); + bigIndex = PFactory.createInt(language, bigIndex.inc()); return idx; } return index++; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionAttrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionAttrNode.java index 727aa9aa65..15bd3afcaa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionAttrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionAttrNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -59,11 +58,7 @@ @SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 20 public abstract class BaseExceptionAttrNode extends Node { public interface StorageFactory { - Object[] create(Object[] args, PythonObjectFactory factory); - - default Object[] create(Object[] args) { - return create(args, null); - } + Object[] create(Object[] args); default Object[] create() { return create(null); @@ -99,13 +94,12 @@ abstract static class EnsureAttrStorageNode extends Node { static Object[] ensure(PBaseException self, StorageFactory storageFactory, @Bind("this") Node inliningTarget, @Cached ExceptionNodes.GetArgsNode getArgsNode, - @Cached SequenceStorageNodes.GetInternalObjectArrayNode getInternalObjectArrayNode, - @Cached PythonObjectFactory factory) { + @Cached SequenceStorageNodes.GetInternalObjectArrayNode getInternalObjectArrayNode) { Object[] attributes = self.getExceptionAttributes(); if (attributes == null) { PTuple argsTuple = getArgsNode.execute(inliningTarget, self); Object[] args = getInternalObjectArrayNode.execute(inliningTarget, argsTuple.getSequenceStorage()); - attributes = storageFactory.create(args, factory); + attributes = storageFactory.create(args); self.setExceptionAttributes(attributes); } return attributes; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java index aa6f045310..dd9ab9aa4d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -93,7 +94,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.nodes.util.SplitArgsNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.ValueType; @@ -151,20 +152,22 @@ static Object doNoArguments(PBaseException self, @SuppressWarnings("unused") Obj } @Specialization(guards = {"args.length != 0", "keywords.length == 0"}) - Object doWithArguments(PBaseException self, Object[] args, @SuppressWarnings("unused") PKeyword[] keywords) { - self.setArgs(factory().createTuple(args)); + Object doWithArguments(PBaseException self, Object[] args, @SuppressWarnings("unused") PKeyword[] keywords, + @Bind PythonLanguage language) { + self.setArgs(PFactory.createTuple(language, args)); return PNone.NONE; } @Specialization(replaces = {"doNoArguments", "doWithArguments"}) - Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords) { + Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords, + @Bind PythonLanguage language) { if (keywords.length != 0) { throw raise(TypeError, P_TAKES_NO_KEYWORD_ARGS, self); } if (args.length == 0) { self.setArgs(null); } else { - self.setArgs(factory().createTuple(args)); + self.setArgs(PFactory.createTuple(language, args)); } return PNone.NONE; } @@ -172,14 +175,15 @@ Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords) { @Specialization Object doNative(PythonAbstractNativeObject self, Object[] args, PKeyword[] keywords, @Bind("this") Node inliningTarget, - @Cached ExceptionNodes.SetArgsNode setArgsNode) { + @Cached ExceptionNodes.SetArgsNode setArgsNode, + @Bind PythonLanguage language) { if (keywords.length != 0) { throw raise(TypeError, P_TAKES_NO_KEYWORD_ARGS, self); } if (args.length == 0) { - setArgsNode.execute(inliningTarget, self, factory().createEmptyTuple()); + setArgsNode.execute(inliningTarget, self, PFactory.createEmptyTuple(language)); } else { - setArgsNode.execute(inliningTarget, self, factory().createTuple(args)); + setArgsNode.execute(inliningTarget, self, PFactory.createTuple(language, args)); } return PNone.NONE; } @@ -202,9 +206,9 @@ static Object args(VirtualFrame frame, Object self, Object value, @Cached CastToListNode castToList, @Cached SequenceStorageNodes.CopyInternalArrayNode copy, @Cached ExceptionNodes.SetArgsNode setArgsNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PList list = castToList.execute(frame, value); - setArgsNode.execute(inliningTarget, self, factory.createTuple(copy.execute(inliningTarget, list.getSequenceStorage()))); + setArgsNode.execute(inliningTarget, self, PFactory.createTuple(language, copy.execute(inliningTarget, list.getSequenceStorage()))); return PNone.NONE; } } @@ -397,11 +401,11 @@ static Object reduce(VirtualFrame frame, Object self, @Cached GetClassNode getClassNode, @Cached ExceptionNodes.GetArgsNode argsNode, @Cached DictNode dictNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object clazz = getClassNode.execute(inliningTarget, self); PTuple args = argsNode.execute(inliningTarget, self); Object dict = dictNode.execute(frame, self, PNone.NO_VALUE); - return factory.createTuple(new Object[]{clazz, args, dict}); + return PFactory.createTuple(language, new Object[]{clazz, args, dict}); } } @@ -536,14 +540,14 @@ Object addNote(VirtualFrame frame, Object self, Object note, @Cached PyObjectLookupAttr lookupAttr, @Cached PyObjectSetAttr setAttr, @Cached ListNodes.AppendNode appendNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, note)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOTE_MUST_BE_A_STR_NOT_P, note); } Object notes = lookupAttr.execute(frame, inliningTarget, self, T___NOTES__); if (notes == PNone.NO_VALUE) { - notes = factory.createList(); + notes = PFactory.createList(language); setAttr.execute(frame, inliningTarget, self, T___NOTES__, notes); } if (notes instanceof PList notesList) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java index 6f59828fca..3192501836 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java @@ -88,8 +88,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -116,12 +115,12 @@ public void postInitialize(Python3Core core) { private static void createExceptionGroupType(Python3Core core) { PythonModule builtins = core.getBuiltins(); + PythonLanguage language = core.getLanguage(); Object typeBuiltin = builtins.getAttribute(T_TYPE); - PythonObjectSlowPathFactory factory = core.factory(); - PTuple bases = factory.createTuple(new Object[]{PythonBuiltinClassType.PBaseExceptionGroup, PythonBuiltinClassType.Exception}); + PTuple bases = PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PBaseExceptionGroup, PythonBuiltinClassType.Exception}); EconomicMapStorage dictStorage = EconomicMapStorage.create(1); dictStorage.putUncachedWithJavaEq(T___MODULE__, T_BUILTINS); - PDict dict = factory.createDict(dictStorage); + PDict dict = PFactory.createDict(language, dictStorage); Object exceptionGroupType = CallNode.executeUncached(typeBuiltin, T_EXCEPTION_GROUP, bases, dict); builtins.setAttribute(T_EXCEPTION_GROUP, exceptionGroupType); } @@ -166,8 +165,8 @@ static TruffleString message(PBaseExceptionGroup self) { abstract static class ExceptionsNode extends PythonUnaryBuiltinNode { @Specialization static Object exceptions(PBaseExceptionGroup self, - @Cached PythonObjectFactory factory) { - return factory.createTuple(self.getExceptions()); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, self.getExceptions()); } } @@ -188,8 +187,7 @@ private static PBaseExceptionGroup subset(Node inliningTarget, PBaseExceptionGro if (exceptions.length == 0) { return null; } - PythonObjectSlowPathFactory factory = PythonContext.get(inliningTarget).factory(); - Object egObj = PyObjectCallMethodObjArgs.executeUncached(orig, T_DERIVE, factory.createTuple(exceptions)); + Object egObj = PyObjectCallMethodObjArgs.executeUncached(orig, T_DERIVE, PFactory.createTuple(PythonLanguage.get(null), exceptions)); if (!(egObj instanceof PBaseExceptionGroup eg)) { throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.DERIVE_MUST_RETURN_AN_INSTANCE_OF_BASE_EXCEPTION_GROUP); } @@ -257,7 +255,7 @@ private static boolean splitCheckMatch(Object exception, MatcherType matcherType private record SplitResult(Object match, Object rest) { static final SplitResult EMPTY = new SplitResult(null, null); - }; + } @TruffleBoundary private static SplitResult splitRecursive(Node inliningTarget, Object exception, MatcherType matcherType, Object matcherValue, boolean constructRest) { @@ -310,8 +308,7 @@ abstract static class SplitNode extends PythonBinaryBuiltinNode { @Specialization static Object split(VirtualFrame frame, PBaseExceptionGroup self, Object matcherValue, @Bind("this") Node inliningTarget, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PythonObjectFactory factory) { + @Cached("createFor(this)") IndirectCallData indirectCallData) { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); @@ -327,7 +324,7 @@ static Object split(VirtualFrame frame, PBaseExceptionGroup self, Object matcher } Object match = result.match != null ? result.match : PNone.NONE; Object rest = result.rest != null ? result.rest : PNone.NONE; - return factory.createTuple(new Object[]{match, rest}); + return PFactory.createTuple(language, new Object[]{match, rest}); } } @@ -360,8 +357,8 @@ static Object subgroup(VirtualFrame frame, PBaseExceptionGroup self, Object matc abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java index 263294cf73..4a8bbdadcb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -47,6 +47,7 @@ import java.util.IllegalFormatException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; @@ -62,11 +63,11 @@ import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.formatting.ErrorMessageFormatter; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -382,17 +383,17 @@ private static String getFormattedMessage(TruffleString format, Object... args) @Specialization static PTuple doManaged(Node inliningTarget, PBaseException self, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached InlinedConditionProfile nullArgsProfile, @Cached InlinedConditionProfile hasMessageFormat, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode) { PTuple args = self.getArgs(); if (nullArgsProfile.profile(inliningTarget, args == null)) { if (hasMessageFormat.profile(inliningTarget, !self.hasMessageFormat())) { - args = factory.createEmptyTuple(); + args = PFactory.createEmptyTuple(language); } else { // lazily format the exception message: - args = factory.createTuple(new Object[]{fromJavaStringNode.execute(getFormattedMessage(self.getMessageFormat(), self.getMessageArgs()), TS_ENCODING)}); + args = PFactory.createTuple(language, new Object[]{fromJavaStringNode.execute(getFormattedMessage(self.getMessageFormat(), self.getMessageArgs()), TS_ENCODING)}); } self.setArgs(args); } @@ -408,7 +409,7 @@ static PTuple doNative(@SuppressWarnings("unused") Node inliningTarget, PythonAb @Specialization static PTuple doInterop(AbstractTruffleException exception, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode) { assert IsForeignObjectNode.executeUncached(exception); @@ -422,9 +423,9 @@ static PTuple doInterop(AbstractTruffleException exception, } if (interop.hasMetaObject(exception)) { - return factory.createTuple(new Object[]{concat(getMetaObjectName(exception), message)}); + return PFactory.createTuple(language, new Object[]{concat(getMetaObjectName(exception), message)}); } else { - return factory.createTuple(new Object[]{message}); + return PFactory.createTuple(language, new Object[]{message}); } } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java index f3a69f4d82..5622884d95 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -70,7 +71,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; import com.oracle.graal.python.nodes.util.SplitArgsNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -94,7 +95,7 @@ protected List> getNodeFa protected static final int IDX_PATH = 2; public static final int IMPORT_ERR_NUM_ATTRS = IDX_PATH + 1; - public static final BaseExceptionAttrNode.StorageFactory IMPORT_ERROR_ATTR_FACTORY = (args, factory) -> { + public static final BaseExceptionAttrNode.StorageFactory IMPORT_ERROR_ATTR_FACTORY = (args) -> { Object[] attrs = new Object[IMPORT_ERR_NUM_ATTRS]; if (args.length == 1) { attrs[IDX_MSG] = args[0]; @@ -136,7 +137,7 @@ Object init(PBaseException self, Object[] args, PKeyword[] kwargs, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode, @Cached TruffleString.EqualNode equalNode) { baseExceptionInitNode.execute(self, args); - Object[] attrs = IMPORT_ERROR_ATTR_FACTORY.create(args, null); + Object[] attrs = IMPORT_ERROR_ATTR_FACTORY.create(args); for (PKeyword kw : kwargs) { TruffleString kwName = kw.getName(); if (equalNode.execute(kwName, NAME, TS_ENCODING)) { @@ -186,7 +187,7 @@ Object generic(PBaseException self, Object value, @GenerateNodeFactory public abstract static class ImportErrorReduceNode extends PythonUnaryBuiltinNode { private static Object getState(Node inliningTarget, PBaseException self, GetDictIfExistsNode getDictIfExistsNode, HashingStorageSetItem setHashingStorageItem, - HashingStorageCopy copyStorageNode, BaseExceptionAttrNode attrNode, PythonObjectFactory factory) { + HashingStorageCopy copyStorageNode, BaseExceptionAttrNode attrNode, PythonLanguage language) { PDict dict = getDictIfExistsNode.execute(self); final Object name = attrNode.get(self, IDX_NAME, IMPORT_ERROR_ATTR_FACTORY); final Object path = attrNode.get(self, IDX_PATH, IMPORT_ERROR_ATTR_FACTORY); @@ -198,7 +199,7 @@ private static Object getState(Node inliningTarget, PBaseException self, GetDict if (path != null) { storage = setHashingStorageItem.execute(inliningTarget, storage, T_PATH, path); } - return factory.createDict(storage); + return PFactory.createDict(language, storage); } else if (dict != null) { return dict; } else { @@ -215,14 +216,14 @@ static Object reduce(PBaseException self, @Cached ExceptionNodes.GetArgsNode getArgsNode, @Cached HashingStorageSetItem setHashingStorageItem, @Cached HashingStorageCopy copyStorageNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object clazz = getClassNode.execute(inliningTarget, self); Object args = getArgsNode.execute(inliningTarget, self); - Object state = getState(inliningTarget, self, getDictIfExistsNode, setHashingStorageItem, copyStorageNode, attrNode, factory); + Object state = getState(inliningTarget, self, getDictIfExistsNode, setHashingStorageItem, copyStorageNode, attrNode, language); if (state == PNone.NONE) { - return factory.createTuple(new Object[]{clazz, args}); + return PFactory.createTuple(language, new Object[]{clazz, args}); } - return factory.createTuple(new Object[]{clazz, args, state}); + return PFactory.createTuple(language, new Object[]{clazz, args, state}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java index ba106fac08..0ce7bf5ca3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -62,6 +62,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -76,6 +77,7 @@ import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyArgCheckPositionalNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyNumberCheckNode; @@ -91,7 +93,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; @@ -117,7 +119,7 @@ public final class OsErrorBuiltins extends PythonBuiltins { public static final int IDX_WRITTEN = 5; public static final int OS_ERR_NUM_ATTRS = IDX_WRITTEN + 1; - public static final BaseExceptionAttrNode.StorageFactory OS_ERROR_ATTR_FACTORY = (args, factory) -> { + public static final BaseExceptionAttrNode.StorageFactory OS_ERROR_ATTR_FACTORY = (args) -> { final Object[] attrs = new Object[OS_ERR_NUM_ATTRS]; attrs[IDX_WRITTEN] = -1; return attrs; @@ -273,7 +275,8 @@ static Object newCData(VirtualFrame frame, Object subType, Object[] args, PKeywo @Cached PyNumberAsSizeNode pyNumberAsSizeNode, @Cached PyArgCheckPositionalNode checkPositionalNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { Object type = subType; Object[] parsedArgs = new Object[IDX_WRITTEN + 1]; @@ -295,11 +298,11 @@ static Object newCData(VirtualFrame frame, Object subType, Object[] args, PKeywo } } - PBaseException self = factory.createBaseException(type); + PBaseException self = PFactory.createBaseException(language, type, getInstanceShape.execute(type)); if (!osErrorUseInit(frame, inliningTarget, core, type, getAttr)) { osErrorInit(frame, inliningTarget, self, type, args, parsedArgs, pyNumberCheckNode, pyNumberAsSizeNode, baseInitNode); } else { - self.setArgs(factory.createEmptyTuple()); + self.setArgs(PFactory.createEmptyTuple(language)); } return self; } @@ -472,7 +475,7 @@ static Object reduce(PBaseException self, @Cached GetClassNode getClassNode, @Cached GetDictIfExistsNode getDictNode, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PTuple args = getArgsNode.execute(inliningTarget, self); final Object filename = attrNode.get(self, IDX_FILENAME, OS_ERROR_ATTR_FACTORY); final Object filename2 = attrNode.get(self, IDX_FILENAME2, OS_ERROR_ATTR_FACTORY); @@ -488,15 +491,15 @@ static Object reduce(PBaseException self, argData[3] = PNone.NONE; argData[4] = filename2; } - args = factory.createTuple(argData); + args = PFactory.createTuple(language, argData); } final Object type = getClassNode.execute(inliningTarget, self); final PDict dict = getDictNode.execute(self); if (dict != null) { - return factory.createTuple(new Object[]{type, args, dict}); + return PFactory.createTuple(language, new Object[]{type, args, dict}); } else { - return factory.createTuple(new Object[]{type, args}); + return PFactory.createTuple(language, new Object[]{type, args}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java index 68ea9891c9..6eb9abba49 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,6 +42,7 @@ import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +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; @@ -55,7 +56,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -172,7 +173,7 @@ private static PBaseException handleInstanceNotAnException(Object type, Object i * Instead of throwing the exception here, we replace the created exception with it. This is * done to match CPython's behavior of `generator.throw` */ - return PythonObjectFactory.getUncached().createBaseException(TypeError, ErrorMessages.CALLING_N_SHOULD_HAVE_RETURNED_AN_INSTANCE_OF_BASE_EXCEPTION_NOT_P, new Object[]{type, instance}); + return PFactory.createBaseException(PythonLanguage.get(null), TypeError, ErrorMessages.CALLING_N_SHOULD_HAVE_RETURNED_AN_INSTANCE_OF_BASE_EXCEPTION_NOT_P, new Object[]{type, instance}); } private static void checkExceptionClass(Object type, IsSubtypeNode isSubtypeNode, PRaiseNode raiseNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/StopIterationBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/StopIterationBuiltins.java index 2a4b436cbf..44b13078b1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/StopIterationBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/StopIterationBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -64,7 +64,7 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.StopIteration) public final class StopIterationBuiltins extends PythonBuiltins { - public static final BaseExceptionAttrNode.StorageFactory STOP_ITERATION_ATTR_FACTORY = (args, factory) -> new Object[]{(args != null && args.length > 0) ? args[0] : PNone.NONE}; + public static final BaseExceptionAttrNode.StorageFactory STOP_ITERATION_ATTR_FACTORY = (args) -> new Object[]{(args != null && args.length > 0) ? args[0] : PNone.NONE}; @Override protected List> getNodeFactories() { @@ -94,7 +94,7 @@ public final Object varArgExecute(VirtualFrame frame, Object self, Object[] argu static Object init(PBaseException self, Object[] args, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode) { baseExceptionInitNode.execute(self, args); - self.setExceptionAttributes(STOP_ITERATION_ATTR_FACTORY.create(args, null)); + self.setExceptionAttributes(STOP_ITERATION_ATTR_FACTORY.create(args)); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java index e929e4184f..76c04f6394 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -94,7 +94,7 @@ public final class SyntaxErrorBuiltins extends PythonBuiltins { public static final int IDX_PRINT_FILE_AND_LINE = 7; public static final int SYNTAX_ERR_NUM_ATTRS = IDX_PRINT_FILE_AND_LINE + 1; - public static final BaseExceptionAttrNode.StorageFactory SYNTAX_ERROR_ATTR_FACTORY = (args, factory) -> new Object[SYNTAX_ERR_NUM_ATTRS]; + public static final BaseExceptionAttrNode.StorageFactory SYNTAX_ERROR_ATTR_FACTORY = (args) -> new Object[SYNTAX_ERR_NUM_ATTRS]; @Override protected List> getNodeFactories() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SystemExitBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SystemExitBuiltins.java index 79b59ad75d..d1cbdc2a64 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SystemExitBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SystemExitBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -51,7 +52,7 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -65,7 +66,7 @@ protected List> getNodeFa return SystemExitBuiltinsFactory.getFactories(); } - public static final BaseExceptionAttrNode.StorageFactory SYSTEM_EXIT_ATTR_FACTORY = (args, factory) -> { + public static final BaseExceptionAttrNode.StorageFactory SYSTEM_EXIT_ATTR_FACTORY = (args) -> { Object code; switch (args.length) { case 0: @@ -75,7 +76,7 @@ protected List> getNodeFa code = args[0]; break; default: - code = factory.createTuple(args); + code = PFactory.createTuple(PythonLanguage.get(null), args); } return new Object[]{code}; }; @@ -85,10 +86,9 @@ protected List> getNodeFa public abstract static class InitNode extends PythonBuiltinNode { @Specialization static Object initNoArgs(PBaseException self, Object[] args, - @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode, - @Cached PythonObjectFactory factory) { + @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode) { baseExceptionInitNode.execute(self, args); - self.setExceptionAttributes(SYSTEM_EXIT_ATTR_FACTORY.create(args, factory)); + self.setExceptionAttributes(SYSTEM_EXIT_ATTR_FACTORY.create(args)); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java index ed6fa8973d..9420fe0832 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -60,7 +61,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -84,7 +85,7 @@ public final class UnicodeErrorBuiltins extends PythonBuiltins { public static final int IDX_REASON = 4; public static final int UNICODE_ERR_NUM_ATTRS = IDX_REASON + 1; - public static final BaseExceptionAttrNode.StorageFactory UNICODE_ERROR_ATTR_FACTORY = (args, factory) -> new Object[UNICODE_ERR_NUM_ATTRS]; + public static final BaseExceptionAttrNode.StorageFactory UNICODE_ERROR_ATTR_FACTORY = (args) -> new Object[UNICODE_ERR_NUM_ATTRS]; @Override protected List> getNodeFactories() { @@ -115,11 +116,11 @@ public abstract static class GetArgAsBytesNode extends PNodeWithContext { @Specialization @TruffleBoundary static PBytes doString(TruffleString value, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { // TODO GR-37601: cbasca cPython works directly with bytes while we have Java strings // which are encoded, here we decode using the system encoding but this might not be the // correct / ideal case - return factory.createBytes(value.toJavaStringUncached().getBytes()); + return PFactory.createBytes(language, value.toJavaStringUncached().getBytes()); } @Specialization @@ -131,11 +132,11 @@ static PBytes doBytes(PBytes value) { static PBytes doOther(VirtualFrame frame, Object value, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") PythonBufferAccessLibrary bufferLib, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { final byte[] buffer = bufferLib.getInternalOrCopiedByteArray(value); final int bufferLength = bufferLib.getBufferLength(value); - return factory.createBytes(buffer, 0, bufferLength); + return PFactory.createBytes(language, buffer, bufferLength); } finally { bufferLib.release(value, frame, indirectCallData); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java index 385c5254f5..8d15d6345f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java @@ -54,6 +54,7 @@ import java.nio.ByteOrder; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -95,7 +96,7 @@ import com.oracle.graal.python.runtime.formatting.FloatFormatter; import com.oracle.graal.python.runtime.formatting.InternalFormat; import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -403,8 +404,8 @@ static double doDD(VirtualFrame frame, double left, double right, @SuppressWarni if (left < 0 && Double.isFinite(left) && Double.isFinite(right) && (right % 1 != 0)) { CompilerDirectives.transferToInterpreterAndInvalidate(); // Negative numbers raised to fractional powers become complex. - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - throw new UnexpectedResultException(powerNode.execute(frame, inliningTarget, factory.createComplex(left, 0), factory.createComplex(right, 0), none)); + PythonLanguage language = PythonLanguage.get(inliningTarget); + throw new UnexpectedResultException(powerNode.execute(frame, inliningTarget, PFactory.createComplex(language, left, 0), PFactory.createComplex(language, right, 0), none)); } return Math.pow(left, right); } @@ -414,15 +415,14 @@ static double doDD(VirtualFrame frame, double left, double right, @SuppressWarni static Object doDDToComplex(VirtualFrame frame, double left, double right, PNone none, @Bind("this") Node inliningTarget, @Shared @Cached PyNumberPowerNode powerNode, - @Exclusive @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { return 1.0; } if (left < 0 && Double.isFinite(left) && Double.isFinite(right) && (right % 1 != 0)) { // Negative numbers raised to fractional powers become complex. - PythonObjectFactory pof = factory.get(inliningTarget); - return powerNode.execute(frame, inliningTarget, pof.createComplex(left, 0), pof.createComplex(right, 0), none); + PythonLanguage language = PythonLanguage.get(inliningTarget); + return powerNode.execute(frame, inliningTarget, PFactory.createComplex(language, left, 0), PFactory.createComplex(language, right, 0), none); } return Math.pow(left, right); } @@ -433,7 +433,6 @@ static Object doGeneric(VirtualFrame frame, Object left, Object right, Object mo @Bind("this") Node inliningTarget, @Cached CastToJavaDoubleNode castToJavaDoubleNode, @Shared @Cached PyNumberPowerNode powerNode, - @Exclusive @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (!(mod instanceof PNone)) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.POW_3RD_ARG_NOT_ALLOWED_UNLESS_INTEGERS); @@ -446,7 +445,7 @@ static Object doGeneric(VirtualFrame frame, Object left, Object right, Object mo } catch (CannotCastException e) { return PNotImplemented.NOT_IMPLEMENTED; } - return doDDToComplex(frame, leftDouble, rightDouble, PNone.NONE, inliningTarget, powerNode, factory, raiseNode); + return doDDToComplex(frame, leftDouble, rightDouble, PNone.NONE, inliningTarget, powerNode, raiseNode); } public static PowNode create() { @@ -467,12 +466,12 @@ protected Object op(double left, double right) { @Slot(value = SlotKind.nb_divmod, isComplex = true) @GenerateNodeFactory abstract static class DivModNode extends AbstractNumericBinaryBuiltin { - @Child private PythonObjectFactory factory = PythonObjectFactory.create(); @Override protected PTuple op(double left, double right) { raiseDivisionByZero(right == 0); - return factory.createTuple(new Object[]{Math.floor(left / right), ModNode.mod(left, right)}); + PythonLanguage language = PythonLanguage.get(this); + return PFactory.createTuple(language, new Object[]{Math.floor(left / right), ModNode.mod(left, right)}); } } @@ -700,11 +699,11 @@ static Object round(VirtualFrame frame, Object x, Object n, @Specialization static Object round(Object xObj, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached CastToJavaDoubleNode cast, @Cached InlinedConditionProfile nanProfile, @Cached InlinedConditionProfile infProfile, @Cached InlinedConditionProfile isLongProfile, - @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { double x = castToDoubleChecked(inliningTarget, xObj, cast); if (nanProfile.profile(inliningTarget, Double.isNaN(x))) { @@ -715,7 +714,7 @@ static Object round(Object xObj, @SuppressWarnings("unused") PNone none, } double result = round(x, 0, inliningTarget, raiseNode); if (isLongProfile.profile(inliningTarget, result > Long.MAX_VALUE || result < Long.MIN_VALUE)) { - return factory.get(inliningTarget).createInt(toBigInteger(result)); + return PFactory.createInt(language, toBigInteger(result)); } else { return (long) result; } @@ -963,10 +962,10 @@ abstract static class AsIntegerRatio extends PythonUnaryBuiltinNode { @Specialization static PTuple get(Object selfObj, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached CastToJavaDoubleNode cast, @Cached InlinedConditionProfile nanProfile, @Cached InlinedConditionProfile infProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { double self = castToDoubleChecked(inliningTarget, selfObj, cast); if (nanProfile.profile(inliningTarget, Double.isNaN(self))) { @@ -1007,11 +1006,11 @@ static PTuple get(Object selfObj, } // count the ratio - return factory.createTuple(countIt(mantissa, exponent)); + return PFactory.createTuple(language, countIt(language, mantissa, exponent)); } @TruffleBoundary - private static Object[] countIt(double mantissa, int exponent) { + private static Object[] countIt(PythonLanguage language, double mantissa, int exponent) { double m = mantissa; int e = exponent; for (int i = 0; i < 300 && Double.compare(m, Math.floor(m)) != 0; i++) { @@ -1030,8 +1029,7 @@ private static Object[] countIt(double mantissa, int exponent) { if (numerator.bitLength() < Long.SIZE && denominator.bitLength() < Long.SIZE) { return new Object[]{numerator.longValue(), denominator.longValue()}; } - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - return new Object[]{factory.createInt(numerator), factory.createInt(denominator)}; + return new Object[]{PFactory.createInt(language, numerator), PFactory.createInt(language, denominator)}; } } @@ -1097,11 +1095,10 @@ protected Object op(double value) { @Builtin(name = J___GETNEWARGS__, minNumOfPositionalArgs = 1) @GenerateNodeFactory abstract static class GetNewArgsNode extends AbstractNumericUnaryBuiltin { - @Child private PythonObjectFactory factory = PythonObjectFactory.create(); - @Override protected Object op(double self) { - return factory.createTuple(new Object[]{factory.createFloat(self)}); + PythonLanguage language = PythonLanguage.get(this); + return PFactory.createTuple(language, new Object[]{PFactory.createFloat(language, self)}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignAbstractClassBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignAbstractClassBuiltins.java index 48cfd68373..cbc0b82c5f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignAbstractClassBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignAbstractClassBuiltins.java @@ -26,6 +26,12 @@ package com.oracle.graal.python.builtins.objects.foreign; +import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___BASES__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__; + +import java.util.List; + +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -34,9 +40,9 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.GilNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.util.PythonUtils; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; @@ -45,11 +51,6 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.CachedLibrary; -import java.util.List; - -import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___BASES__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__; - /* * NOTE: We are not using IndirectCallContext here in this file * because it seems unlikely that these interop messages would call back to Python @@ -68,8 +69,8 @@ protected List> getNodeFa abstract static class BasesNode extends PythonUnaryBuiltinNode { @Specialization static Object getBases(Object self, - @Cached PythonObjectFactory factory) { - return factory.createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); + @Bind PythonLanguage language) { + return PFactory.createEmptyTuple(language); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index 86ef886d58..127f6073b4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -42,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -93,7 +94,7 @@ import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -170,13 +171,13 @@ long doLong(Object obj, @Specialization(guards = {"!lib.fitsInLong(obj)", "lib.fitsInBigInteger(obj)"}) PInt doBigInt(Object obj, + @Bind PythonLanguage language, @Shared @CachedLibrary(limit = "3") InteropLibrary lib, - @Shared @Cached(inline = false) GilNode gil, - @Cached(inline = false) PythonObjectFactory factory) { + @Shared @Cached(inline = false) GilNode gil) { assert !lib.isBoolean(obj); gil.release(true); try { - return factory.createInt(lib.asBigInteger(obj)); + return PFactory.createInt(language, lib.asBigInteger(obj)); } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); } finally { @@ -667,10 +668,10 @@ protected EqNode() { abstract static class IndexNode extends PythonUnaryBuiltinNode { @Specialization(limit = "3") protected static Object doIt(Object object, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode, @CachedLibrary("object") InteropLibrary lib, - @Cached GilNode gil, - @Cached PythonObjectFactory factory) { + @Cached GilNode gil) { assert !lib.isBoolean(object); gil.release(true); try { @@ -693,7 +694,7 @@ protected static Object doIt(Object object, if (lib.fitsInBigInteger(object)) { try { var big = lib.asBigInteger(object); - return factory.createInt(big); + return PFactory.createInt(PythonLanguage.get(inliningTarget), big); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new IllegalStateException("foreign value claims to be a big integer but isn't"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java index ea386f7fed..6f2172be6a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java @@ -68,7 +68,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -89,6 +89,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; /* @@ -276,8 +277,8 @@ protected Object doIt(Object object, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "3") InteropLibrary lib, @Cached GilNode gil, - @Cached PythonObjectFactory.Lazy factory) { - if (lib.hasMembers(object)) { + @Cached InlinedConditionProfile profile) { + if (profile.profile(inliningTarget, lib.hasMembers(object))) { gil.release(true); try { return lib.getMembers(object); @@ -288,7 +289,7 @@ protected Object doIt(Object object, gil.acquire(); } } else { - return factory.get(inliningTarget).createList(); + return PFactory.createList(PythonLanguage.get(inliningTarget)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java index e2e34ad12c..17fad7107d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java @@ -30,6 +30,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,7 +60,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaBooleanNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; @@ -110,8 +111,7 @@ public abstract static class GetGlobalsNode extends PythonBuiltinNode { public abstract Object execute(VirtualFrame frame, PFrame self); @Specialization - Object get(VirtualFrame curFrame, PFrame self, - @Cached PythonObjectFactory factory) { + Object get(VirtualFrame curFrame, PFrame self) { PythonObject globals = self.getGlobals(); if (globals instanceof PythonModule) { if (getDictNode == null) { @@ -120,7 +120,7 @@ Object get(VirtualFrame curFrame, PFrame self, } return getDictNode.execute(curFrame, globals, PNone.NO_VALUE); } else { - return globals != null ? globals : factory.createDict(); + return globals != null ? globals : PFactory.createDict(PythonLanguage.get(this)); } } @@ -274,10 +274,10 @@ public abstract static class GetCodeNode extends PythonBuiltinNode { @Specialization static PCode get(PFrame self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { RootCallTarget ct = self.getTarget(); assert ct != null; - return factory.createCode(ct); + return PFactory.createCode(language, ct); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java index 0582591478..a3263bbdb2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -71,7 +72,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -83,6 +84,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleStringBuilder; @@ -119,12 +121,12 @@ protected Object doIt(VirtualFrame frame, PBuiltinFunction self, Object[] argume public abstract static class GetClosureNode extends PythonBuiltinNode { @Specialization(guards = "!isBuiltinFunction(self)") Object getClosure(PFunction self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PCell[] closure = self.getClosure(); if (closure == null) { return PNone.NONE; } - return factory.createTuple(closure); + return PFactory.createTuple(language, closure); } @SuppressWarnings("unused") @@ -221,10 +223,11 @@ static Object getModule(PFunction self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Cached ReadAttributeFromObjectNode readObject, @Shared @Cached WriteAttributeToObjectNode writeObject, - @Cached PythonObjectFactory.Lazy factory) { + @Cached InlinedBranchProfile createAnnotations) { Object annotations = readObject.execute(self, T___ANNOTATIONS__); if (annotations == PNone.NO_VALUE) { - annotations = factory.get(inliningTarget).createDict(); + createAnnotations.enter(inliningTarget); + annotations = PFactory.createDict(PythonLanguage.get(inliningTarget)); writeObject.execute(self, T___ANNOTATIONS__, annotations); } return annotations; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java index 2a98c32ba2..eee179f311 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -41,6 +41,7 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,7 +60,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -133,11 +134,11 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { Object doBuiltinFunc(VirtualFrame frame, PBuiltinFunction func, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttr, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = getContext().getBuiltins(); Object getattr = getAttr.execute(frame, inliningTarget, builtins, T_GETATTR); - PTuple args = factory.createTuple(new Object[]{func.getEnclosingType(), func.getName()}); - return factory.createTuple(new Object[]{getattr, args}); + PTuple args = PFactory.createTuple(language, new Object[]{func.getEnclosingType(), func.getName()}); + return PFactory.createTuple(language, new Object[]{getattr, args}); } } @@ -214,7 +215,7 @@ public static Object createInspectSignature(Signature signature, boolean skipSel parameters.add(callNode.executeWithoutFrame(inspectParameter, StringLiterals.T_KWARGS, ParameterKinds.VAR_KEYWORD.get(parameterKinds, inspectParameter))); } - return callNode.executeWithoutFrame(inspectSignature, PythonObjectFactory.getUncached().createTuple(parameters.toArray())); + return callNode.executeWithoutFrame(inspectSignature, PFactory.createTuple(PythonLanguage.get(null), parameters.toArray())); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java index 95372770ba..9e6033f13a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -44,6 +44,7 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -106,8 +107,8 @@ protected List> getNodeFa public abstract static class GetNode extends DescrGetBuiltinNode { @Specialization(guards = {"!isPNone(instance)"}) static PMethod doMethod(PFunction self, Object instance, @SuppressWarnings("unused") Object klass, - @Cached PythonObjectFactory factory) { - return factory.createMethod(instance, self); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, instance, self); } @Specialization @@ -176,10 +177,10 @@ static Object setQualname(PFunction self, Object value, public abstract static class GetDefaultsNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(defaults)") static Object defaults(PFunction self, @SuppressWarnings("unused") PNone defaults, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] argDefaults = self.getDefaults(); assert argDefaults != null; - return (argDefaults.length == 0) ? PNone.NONE : factory.createTuple(argDefaults); + return (argDefaults.length == 0) ? PNone.NONE : PFactory.createTuple(language, argDefaults); } @Specialization @@ -215,9 +216,9 @@ static Object setDefaults(Object self, Object defaults, public abstract static class GetKeywordDefaultsNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(arg)") static Object get(PFunction self, @SuppressWarnings("unused") PNone arg, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PKeyword[] kwdefaults = self.getKwDefaults(); - return (kwdefaults.length > 0) ? factory.createDict(kwdefaults) : PNone.NONE; + return (kwdefaults.length > 0) ? PFactory.createDict(language, kwdefaults) : PNone.NONE; } @Specialization(guards = "!isNoValue(arg)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java index 7aa0278c7f..591a6b8b28 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -59,9 +60,9 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; @@ -85,8 +86,8 @@ protected List> getNodeFa public abstract static class GetNode extends DescrGetBuiltinNode { @Specialization(guards = "!isNoValue(instance)") static PMethod doMethod(PFunction self, Object instance, Object klass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createMethod(instance, self); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, instance, self); } @Specialization(guards = "isNoValue(instance)") @@ -96,14 +97,14 @@ static Object doFunction(PFunction self, Object instance, Object klass) { @Specialization(guards = {"!isNoValue(instance)", "!self.needsDeclaringType()"}) static PBuiltinMethod doBuiltinMethod(PBuiltinFunction self, Object instance, Object klass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBuiltinMethod(instance, self); + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, instance, self); } @Specialization(guards = {"!isNoValue(instance)", "self.needsDeclaringType()"}) static PBuiltinMethod doBuiltinMethodWithDeclaringClass(PBuiltinFunction self, Object instance, Object klass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBuiltinMethod(instance, self, self.getEnclosingType()); + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, instance, self, self.getEnclosingType()); } @Specialization(guards = "isNoValue(instance)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java index 9d452b879a..8cde706221 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -31,6 +31,7 @@ import java.lang.invoke.VarHandle; import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.BoundBuiltinCallable; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -45,7 +46,7 @@ import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -250,11 +251,11 @@ public String toString() { } @Override - public PBuiltinFunction boundToObject(PythonBuiltinClassType klass, PythonObjectFactory factory) { + public PBuiltinFunction boundToObject(PythonBuiltinClassType klass, PythonLanguage language) { if (klass == enclosingType) { return this; } else { - PBuiltinFunction func = factory.createBuiltinFunction(this, klass); + PBuiltinFunction func = PFactory.createBuiltinFunction(language, this, klass); func.setAttribute(T___DOC__, getAttribute(T___DOC__)); return func; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java index 64ebc9484e..973253baff 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +44,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -59,9 +60,9 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; @@ -85,8 +86,8 @@ protected List> getNodeFa public abstract static class GetNode extends DescrGetBuiltinNode { @Specialization(guards = {"!isNoValue(instance)"}) static PMethod doMethod(PFunction self, Object instance, Object klass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createMethod(PythonBuiltinClassType.MethodWrapper, instance, self); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, PythonBuiltinClassType.MethodWrapper, PythonBuiltinClassType.MethodWrapper.getInstanceShape(language), instance, self); } @Specialization(guards = "isNoValue(instance)") @@ -96,8 +97,8 @@ static Object doFunction(PFunction self, Object instance, Object klass) { @Specialization(guards = {"!isNoValue(instance)"}) static PBuiltinMethod doBuiltinMethod(PBuiltinFunction self, Object instance, Object klass, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBuiltinMethod(PythonBuiltinClassType.MethodWrapper, instance, self); + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, PythonBuiltinClassType.MethodWrapper, PythonBuiltinClassType.MethodWrapper.getInstanceShape(language), instance, self); } @Specialization(guards = "isNoValue(instance)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java index 0a204506da..21e76b2010 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -77,7 +77,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; @@ -288,7 +288,6 @@ static Object sendThrow(VirtualFrame frame, PGenerator self, Object typ, Object @Cached ExceptionNodes.GetTracebackNode getTracebackNode, @Cached ExceptionNodes.SetTracebackNode setTracebackNode, @Cached ExceptionNodes.SetContextNode setContextNode, - @Cached PythonObjectFactory.Lazy factory, @Cached PRaiseNode.Lazy raiseNode) { boolean hasTb = hasTbProfile.profile(inliningTarget, !(tb instanceof PNone)); if (hasTb && !(tb instanceof PTraceback)) { @@ -321,11 +320,11 @@ static Object sendThrow(VirtualFrame frame, PGenerator self, Object typ, Object self.markAsFinished(); Node location = self.getCurrentCallTarget().getRootNode(); MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(self.getArguments()); - PFrame pFrame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY, factory.get(inliningTarget)); + PFrame pFrame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY); FrameInfo info = (FrameInfo) generatorFrame.getFrameDescriptor().getInfo(); pFrame.setLine(info.getRootNode().getFirstLineno()); Object existingTracebackObj = getTracebackNode.execute(inliningTarget, instance); - PTraceback newTraceback = factory.get(inliningTarget).createTraceback(pFrame, pFrame.getLine(), + PTraceback newTraceback = PFactory.createTraceback(language, pFrame, pFrame.getLine(), (existingTracebackObj instanceof PTraceback existingTraceback) ? existingTraceback : null); setTracebackNode.execute(inliningTarget, instance, newTraceback); throw PException.fromObject(instance, location, PythonOptions.isPExceptionWithJavaStacktrace(language)); @@ -343,13 +342,12 @@ static Object close(VirtualFrame frame, PGenerator self, @Cached IsBuiltinObjectProfile isStopIteration, @Cached ResumeGeneratorNode resumeGeneratorNode, @Cached InlinedConditionProfile isStartedPorfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (self.isRunning()) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); } if (isStartedPorfile.profile(inliningTarget, self.isStarted() && !self.isFinished())) { - PBaseException pythonException = factory.createBaseException(GeneratorExit); + PBaseException pythonException = PFactory.createBaseException(PythonLanguage.get(inliningTarget), GeneratorExit); // Pass it to the generator where it will be thrown by the last yield, the location // will be filled there boolean withJavaStacktrace = PythonOptions.isPExceptionWithJavaStacktrace(PythonLanguage.get(inliningTarget)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java index 3ffbaacefe..495c3ed66f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -54,7 +55,7 @@ import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -78,9 +79,8 @@ public abstract static class GetCode extends PythonUnaryBuiltinNode { @Specialization static Object getCode(PGenerator self, @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile hasCodeProfile, - @Cached PythonObjectFactory.Lazy factory) { - return self.getOrCreateCode(inliningTarget, hasCodeProfile, factory); + @Cached InlinedConditionProfile hasCodeProfile) { + return self.getOrCreateCode(inliningTarget, hasCodeProfile); } } @@ -127,8 +127,8 @@ static boolean suspended(PGenerator self) { abstract static class AwaitNode extends PythonUnaryBuiltinNode { @Specialization static Object await(PGenerator self, - @Cached PythonObjectFactory factory) { - return factory.createCoroutineWrapper(self); + @Bind PythonLanguage language) { + return PFactory.createCoroutineWrapper(language, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java index f4dd2ac5af..18ebb0b5a0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -38,6 +38,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -55,7 +56,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -157,9 +158,8 @@ public abstract static class GetCodeNode extends PythonUnaryBuiltinNode { @Specialization static Object getCode(PGenerator self, @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile hasCodeProfile, - @Cached PythonObjectFactory.Lazy factory) { - return self.getOrCreateCode(inliningTarget, hasCodeProfile, factory); + @Cached InlinedConditionProfile hasCodeProfile) { + return self.getOrCreateCode(inliningTarget, hasCodeProfile); } } @@ -182,14 +182,13 @@ static Object setRunning(@SuppressWarnings("unused") PGenerator self, @SuppressW @GenerateNodeFactory public abstract static class GetFrameNode extends PythonUnaryBuiltinNode { @Specialization - static Object getFrame(PGenerator self, - @Cached PythonObjectFactory factory) { + static Object getFrame(PGenerator self) { if (self.isFinished()) { return PNone.NONE; } else { MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(self.getArguments()); Node location = ((FrameInfo) generatorFrame.getFrameDescriptor().getInfo()).getRootNode(); - PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY, factory); + PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY); FrameInfo info = (FrameInfo) generatorFrame.getFrameDescriptor().getInfo(); int bci = self.getBci(); frame.setBci(bci); @@ -233,8 +232,8 @@ static TruffleString repr(PGenerator self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java index 2325e7cfc9..89df69e533 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -35,7 +35,7 @@ import com.oracle.graal.python.nodes.bytecode.GeneratorYieldResult; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; @@ -155,11 +155,11 @@ public final String toString() { return ""; } - public final PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCodeProfile, PythonObjectFactory.Lazy factory) { + public final PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCodeProfile) { if (hasCodeProfile.profile(inliningTarget, code == null)) { RootCallTarget callTarget; callTarget = bytecodeRootNode.getCallTarget(); - code = factory.get(inliningTarget).createCode(callTarget); + code = PFactory.createCode(PythonLanguage.get(inliningTarget), callTarget); } return code; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptor.java index e148bf4e8c..c928893384 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -47,7 +47,7 @@ import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.nodes.SpecialAttributeNames; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.strings.TruffleString; @@ -102,11 +102,11 @@ public boolean allowsDelete() { return allowsDelete; } - public GetSetDescriptor boundToObject(PythonBuiltinClassType klass, PythonObjectFactory factory) { + public GetSetDescriptor boundToObject(PythonBuiltinClassType klass, PythonLanguage language) { if (klass == type) { return this; } else { - return factory.createGetSetDescriptor(get, set, getName(), klass, allowsDelete); + return PFactory.createGetSetDescriptor(language, get, set, getName(), klass, allowsDelete); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java index 880a385966..6771172fd3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -109,10 +110,10 @@ abstract static class MemberDescriptorReduceNode extends PythonUnaryBuiltinNode Object doGeneric(GetSetDescriptor descr, @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, @Cached GetIdNode getIdNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object getattr = readAttributeFromObjectNode.execute(getContext().getBuiltins(), BuiltinNames.T_GETATTR); Object id = getIdNode.execute(getattr); - return factory.createTuple(new Object[]{id, factory.createTuple(new Object[]{descr.getType(), descr.getName()})}); + return PFactory.createTuple(language, new Object[]{id, PFactory.createTuple(language, new Object[]{descr.getType(), descr.getName()})}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index 8b0ff103c2..896ce7003a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -69,6 +69,7 @@ import java.math.RoundingMode; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -118,7 +119,7 @@ import com.oracle.graal.python.runtime.formatting.IntegerFormatter; import com.oracle.graal.python.runtime.formatting.InternalFormat; import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; @@ -194,70 +195,70 @@ static long roundLongNone(long arg, PNone n) { @Specialization static PInt roundPIntNone(PInt arg, PNone n, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory.Lazy factory) { - return factory.get(inliningTarget).createInt(arg.getValue()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, arg.getValue()); } @Specialization static Object roundLongInt(long arg, int n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n >= 0) { return arg; } - return makeInt(inliningTarget, op(arg, n), intOverflow, factory); + return makeInt(inliningTarget, op(arg, n), intOverflow, longOverflow); } @Specialization static Object roundPIntInt(PInt arg, int n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n >= 0) { return arg; } - return makeInt(inliningTarget, op(arg.getValue(), n), intOverflow, factory); + return makeInt(inliningTarget, op(arg.getValue(), n), intOverflow, longOverflow); } @Specialization static Object roundLongLong(long arg, long n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n >= 0) { return arg; } if (n < Integer.MIN_VALUE) { return 0; } - return makeInt(inliningTarget, op(arg, (int) n), intOverflow, factory); + return makeInt(inliningTarget, op(arg, (int) n), intOverflow, longOverflow); } @Specialization static Object roundPIntLong(PInt arg, long n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n >= 0) { return arg; } if (n < Integer.MIN_VALUE) { return 0; } - return makeInt(inliningTarget, op(arg.getValue(), (int) n), intOverflow, factory); + return makeInt(inliningTarget, op(arg.getValue(), (int) n), intOverflow, longOverflow); } @Specialization static Object roundPIntLong(long arg, PInt n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n.isZeroOrPositive()) { return arg; } try { - return makeInt(inliningTarget, op(arg, n.intValueExact()), intOverflow, factory); + return makeInt(inliningTarget, op(arg, n.intValueExact()), intOverflow, longOverflow); } catch (OverflowException e) { // n is < -2^31, max. number of base-10 digits in BigInteger is 2^31 * log10(2) return 0; @@ -268,12 +269,12 @@ static Object roundPIntLong(long arg, PInt n, static Object roundPIntPInt(PInt arg, PInt n, @Bind("this") Node inliningTarget, @Shared("intOvf") @Cached InlinedBranchProfile intOverflow, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared("longOvf") @Cached InlinedBranchProfile longOverflow) { if (n.isZeroOrPositive()) { return arg; } try { - return makeInt(inliningTarget, op(arg.getValue(), n.intValueExact()), intOverflow, factory); + return makeInt(inliningTarget, op(arg.getValue(), n.intValueExact()), intOverflow, longOverflow); } catch (OverflowException e) { // n is < -2^31, max. number of base-10 digits in BigInteger is 2^31 * log10(2) return 0; @@ -287,7 +288,7 @@ static Object roundPIntPInt(Object arg, Object n, throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, n); } - private static Object makeInt(Node inliningTarget, BigDecimal d, InlinedBranchProfile intOverflow, PythonObjectFactory.Lazy factory) { + private static Object makeInt(Node inliningTarget, BigDecimal d, InlinedBranchProfile intOverflow, InlinedBranchProfile longOverflow) { try { return intValueExact(d); } catch (OverflowException e) { @@ -298,10 +299,10 @@ private static Object makeInt(Node inliningTarget, BigDecimal d, InlinedBranchPr return longValueExact(d); } catch (OverflowException e) { // does not fit long, try BigInteger + longOverflow.enter(inliningTarget); } try { - // lazy factory initialization should serve as branch profile - return factory.get(inliningTarget).createInt(toBigIntegerExact(d)); + return PFactory.createInt(PythonLanguage.get(inliningTarget), toBigIntegerExact(d)); } catch (OverflowException e) { // has non-zero fractional part, which should not happen throw CompilerDirectives.shouldNotReachHere("non-integer produced after rounding an integer", e); @@ -374,12 +375,12 @@ static long addLong(long left, long right) { @Specialization static Object addLongWithOverflow(long x, long y, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { /* Inlined version of Math.addExact(x, y) with BigInteger fallback. */ long r = x + y; // HD 2-12 Overflow iff both arguments have the opposite sign of the result if (((x ^ r) & (y ^ r)) < 0) { - return factory.createInt(op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + return PFactory.createInt(language, op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); } return r; } @@ -391,8 +392,8 @@ static Object addPIntLongAndNarrow(PInt left, long right) throws OverflowExcepti @Specialization(replaces = "addPIntLongAndNarrow") static Object addPIntLong(PInt left, long right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) @@ -402,8 +403,8 @@ static Object addLongPIntAndNarrow(long left, PInt right) throws OverflowExcepti @Specialization(replaces = "addLongPIntAndNarrow") static Object addLongPInt(long left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(PInt.longToBigInteger(left), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @Specialization(rewriteOn = OverflowException.class) @@ -413,8 +414,8 @@ static Object addPIntPIntAndNarrow(PInt left, PInt right) throws OverflowExcepti @Specialization(replaces = "addPIntPIntAndNarrow") static Object addPIntPInt(PInt left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @TruffleBoundary @@ -463,13 +464,13 @@ static long doLL(long x, long y) throws ArithmeticException { @Specialization static Object doLongWithOverflow(long x, long y, - @Shared @Cached PythonObjectFactory factory) { + @Bind("this") Node inliningTarget) { /* Inlined version of Math.subtractExact(x, y) with BigInteger fallback. */ long r = x - y; // HD 2-12 Overflow iff the arguments have different signs and // the sign of the result is different than the sign of x if (((x ^ y) & (x ^ r)) < 0) { - return factory.createInt(op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + return PFactory.createInt(PythonLanguage.get(inliningTarget), op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); } return r; } @@ -481,8 +482,8 @@ static long doPIntLongAndNarrow(PInt left, long right) throws OverflowException @Specialization(replaces = "doPIntLongAndNarrow") static PInt doPIntLong(PInt left, long right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) @@ -492,8 +493,8 @@ static long doLongPIntAndNarrow(long left, PInt right) throws OverflowException @Specialization(replaces = "doLongPIntAndNarrow") static PInt doLongPInt(long left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(PInt.longToBigInteger(left), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @Specialization(rewriteOn = OverflowException.class) @@ -503,8 +504,8 @@ static long doPIntPIntAndNarrow(PInt left, PInt right) throws OverflowException @Specialization(replaces = "doPIntPIntAndNarrow") static PInt doPIntPInt(PInt left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @TruffleBoundary @@ -663,12 +664,11 @@ static Object doLL(long left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); if (left == Long.MIN_VALUE && right == -1) { overflowValueProfile.enter(); - return factory.createInt(LONG_OVERFLOW_VALUE); + return PFactory.createInt(PythonLanguage.get(inliningTarget), LONG_OVERFLOW_VALUE); } return Math.floorDiv(left, right); } @@ -697,14 +697,13 @@ static Object doLPi(long left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { try { long rightValue = right.longValueExact(); raiseDivisionByZero(inliningTarget, rightValue == 0, divisionByZeroProfile, raiseNode); if (left == Long.MIN_VALUE && rightValue == -1) { overflowValueProfile.enter(); - return factory.createInt(LONG_OVERFLOW_VALUE); + return PFactory.createInt(PythonLanguage.get(inliningTarget), LONG_OVERFLOW_VALUE); } return Math.floorDiv(left, rightValue); } catch (OverflowException e) { @@ -724,11 +723,11 @@ static long doPiIAndNarrow(PInt left, int right, @Specialization(replaces = "doPiIAndNarrow") static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) @@ -743,11 +742,11 @@ static long doPiLAndNarrow(PInt left, long right, @Specialization(replaces = "doPiLAndNarrow") static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) @@ -762,11 +761,11 @@ static long doPiPiAndNarrow(PInt left, PInt right, @Specialization(replaces = "doPiPiAndNarrow") static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); - return factory.createInt(op(left.getValue(), right.getValue())); + return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @TruffleBoundary @@ -798,15 +797,15 @@ abstract static class DivModNode extends BinaryOpBuiltinNode { @Specialization static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Bind("this") Node inliningTarget, @Cached FloorDivNode floorDivNode, - @Cached ModNode modNode, - @Cached PythonObjectFactory factory) { + @Cached ModNode modNode) { Object div = floorDivNode.execute(frame, left, right); if (div == PNotImplemented.NOT_IMPLEMENTED) { return PNotImplemented.NOT_IMPLEMENTED; } Object mod = modNode.execute(frame, left, right); - return factory.createTuple(new Object[]{div, mod}); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{div, mod}); } } @@ -848,11 +847,11 @@ static long doLPiAndNarrow(long left, PInt right, @Specialization(guards = "right.isZeroOrPositive()", replaces = "doLPiAndNarrow") static PInt doLPi(long left, PInt right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); - return factory.createInt(op(PInt.longToBigInteger(left), right.getValue())); + return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @Specialization(guards = "!right.isZeroOrPositive()", rewriteOn = OverflowException.class) @@ -867,11 +866,11 @@ static long doLPiNegativeAndNarrow(long left, PInt right, @Specialization(guards = "!right.isZeroOrPositive()", replaces = "doLPiNegativeAndNarrow") static PInt doLPiNegative(long left, PInt right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); - return factory.createInt(opNeg(PInt.longToBigInteger(left), right.getValue())); + return PFactory.createInt(language, opNeg(PInt.longToBigInteger(left), right.getValue())); } @Specialization(guards = "right >= 0", rewriteOn = OverflowException.class) @@ -886,11 +885,11 @@ static long doPiLAndNarrow(PInt left, long right, @Specialization(guards = "right >= 0", replaces = "doPiLAndNarrow") static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(guards = "right < 0", rewriteOn = OverflowException.class) @@ -905,11 +904,11 @@ static long doPiLNegAndNarrow(PInt left, long right, @Specialization(guards = "right < 0", replaces = "doPiLNegAndNarrow") static PInt doPiLNeg(PInt left, long right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); - return factory.createInt(opNeg(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, opNeg(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(guards = "right.isZeroOrPositive()", rewriteOn = OverflowException.class) @@ -924,11 +923,11 @@ static long doPiPiAndNarrow(PInt left, PInt right, @Specialization(guards = "right.isZeroOrPositive()", replaces = "doPiPiAndNarrow") static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); - return factory.createInt(op(left.getValue(), right.getValue())); + return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @Specialization(guards = "!right.isZeroOrPositive()", rewriteOn = OverflowException.class) @@ -938,8 +937,8 @@ static long doPiPiNegAndNarrow(PInt left, PInt right) throws OverflowException { @Specialization(guards = "!right.isZeroOrPositive()", replaces = "doPiPiNegAndNarrow") static PInt doPiPiNeg(PInt left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(opNeg(left.getValue(), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, opNeg(left.getValue(), right.getValue())); } @TruffleBoundary @@ -994,7 +993,7 @@ static long doLL(long x, long y) { @Specialization static Object doLongWithOverflow(long x, long y, - @Shared @Cached PythonObjectFactory factory) { + @Bind("this") Node inliningTarget) { /* Inlined version of Math.multiplyExact(x, y) with BigInteger fallback. */ long r = x * y; long ax = Math.abs(x); @@ -1005,7 +1004,7 @@ static Object doLongWithOverflow(long x, long y, // and check for the special case of Long.MIN_VALUE * -1 if (((y != 0) && (r / y != x)) || (x == Long.MIN_VALUE && y == -1)) { - return factory.createInt(mul(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + return PFactory.createInt(PythonLanguage.get(inliningTarget), mul(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); } } return r; @@ -1023,33 +1022,33 @@ static int doPIntLongZero(@SuppressWarnings("unused") long left, @SuppressWarnin @Specialization(guards = "right == 1") static PInt doPIntLongOne(PInt left, @SuppressWarnings("unused") long right, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // we must return a new object with the same value - return factory.createInt(left.getValue()); + return PFactory.createInt(language, left.getValue()); } @Specialization(guards = "left == 1") PInt doPIntLongOne(@SuppressWarnings("unused") long left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(right.getValue()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, right.getValue()); } @Specialization(guards = {"right != 0", "right != 1"}) static PInt doPIntLong(PInt left, long right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(mul(left.getValue(), PInt.longToBigInteger(right))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, mul(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(guards = {"left != 0", "left != 1"}) PInt doPIntLong(long left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(mul(PInt.longToBigInteger(left), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, mul(PInt.longToBigInteger(left), right.getValue())); } @Specialization static PInt doPIntPInt(PInt left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(mul(left.getValue(), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, mul(left.getValue(), right.getValue())); } @TruffleBoundary @@ -1139,8 +1138,8 @@ static long doLLFast(long left, long right, @SuppressWarnings("unused") PNone no @Specialization(guards = "right >= 0", replaces = "doLLFast") @InliningCutoff PInt doLLPos(long left, long right, @SuppressWarnings("unused") PNone none, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(PInt.longToBigInteger(left), right)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(PInt.longToBigInteger(left), right)); } @Specialization(guards = "right < 0") @@ -1170,11 +1169,10 @@ Object doLPNarrow(long left, PInt right, @SuppressWarnings("unused") PNone none, @Specialization(replaces = "doLPNarrow") @InliningCutoff - Object doLP(long left, PInt right, @SuppressWarnings("unused") PNone none, - @Shared @Cached PythonObjectFactory factory) { + Object doLP(long left, PInt right, @SuppressWarnings("unused") PNone none) { Object result = op(PInt.longToBigInteger(left), right.getValue()); if (result instanceof BigInteger) { - return factory.createInt((BigInteger) result); + return PFactory.createInt(PythonLanguage.get(this), (BigInteger) result); } else { return result; } @@ -1189,8 +1187,8 @@ long doPLNarrow(PInt left, long right, @SuppressWarnings("unused") PNone none) t @Specialization(guards = "right >= 0", replaces = "doPLNarrow") @InliningCutoff PInt doPLPos(PInt left, long right, @SuppressWarnings("unused") PNone none, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), right)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), right)); } @Specialization(guards = "right < 0") @@ -1208,11 +1206,10 @@ PInt doPLPos(PInt left, long right, @SuppressWarnings("unused") PNone none, @Specialization @InliningCutoff - Object doPP(PInt left, PInt right, @SuppressWarnings("unused") PNone none, - @Shared @Cached PythonObjectFactory factory) { + Object doPP(PInt left, PInt right, @SuppressWarnings("unused") PNone none) { Object result = op(left.getValue(), right.getValue()); if (result instanceof BigInteger) { - return factory.createInt((BigInteger) result); + return PFactory.createInt(PythonLanguage.get(this), (BigInteger) result); } else { return result; } @@ -1254,8 +1251,7 @@ static long doLLPosLGeneric(long left, long right, long mod, // see cpython://Objects/longobject.c#long_pow @Specialization(replaces = "doPP") @InliningCutoff - Object powModulo(Object x, Object y, Object z, - @Shared @Cached PythonObjectFactory factory) { + Object powModulo(Object x, Object y, Object z) { if (!(MathGuards.isInteger(x) && MathGuards.isInteger(y))) { return PNotImplemented.NOT_IMPLEMENTED; } @@ -1268,7 +1264,7 @@ Object powModulo(Object x, Object y, Object z, return PNotImplemented.NOT_IMPLEMENTED; } if (result instanceof BigInteger) { - return factory.createInt((BigInteger) result); + return PFactory.createInt(PythonLanguage.get(this), (BigInteger) result); } else { return result; } @@ -1409,16 +1405,14 @@ static Object absInt(int arg) { @Specialization static Object absLong(long arg, - @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory.Lazy factory) { - return PInt.abs(inliningTarget, arg, factory); + @Bind("this") Node inliningTarget) { + return PInt.abs(inliningTarget, arg); } @Specialization static PInt absPInt(PInt arg, - @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory.Lazy factory) { - return factory.get(inliningTarget).createInt(arg.abs()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, arg.abs()); } @Specialization @@ -1463,8 +1457,8 @@ static long floor(long arg) { @Specialization static PInt floor(PInt arg, - @Cached PythonObjectFactory factory) { - return factory.createInt(arg.getValue()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, arg.getValue()); } } @@ -1483,8 +1477,8 @@ static Long pos(Long arg) { @Specialization static PInt pos(PInt arg, - @Cached PythonObjectFactory factory) { - return factory.createInt(arg.getValue()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, arg.getValue()); } @Specialization @@ -1515,15 +1509,15 @@ static long neg(long arg) { @Specialization static PInt negOvf(long arg, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { BigInteger value = arg == Long.MIN_VALUE ? negate(PInt.longToBigInteger(arg)) : PInt.longToBigInteger(-arg); - return factory.createInt(value); + return PFactory.createInt(language, value); } @Specialization static PInt doPInt(PInt operand, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(negate(operand.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, negate(operand.getValue())); } @Specialization @@ -1562,8 +1556,8 @@ static long neg(long arg) { @Specialization static PInt doPInt(PInt operand, - @Cached PythonObjectFactory factory) { - return factory.createInt(not(operand.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, not(operand.getValue())); } @TruffleBoundary @@ -1627,13 +1621,12 @@ static int doII(int left, int right, @Specialization static Object doIIOvf(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); try { return leftShiftExact(inliningTarget, left, right, raiseNode); } catch (OverflowException e) { - return doGuardedBiI(inliningTarget, PInt.longToBigInteger(left), right, factory, raiseNode); + return doGuardedBiI(inliningTarget, PInt.longToBigInteger(left), right, raiseNode); } } @@ -1648,23 +1641,20 @@ static long doLL(long left, long right, @Specialization static Object doILOvf(int left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doLLOvf(left, right, inliningTarget, factory, raiseNode); + return doLLOvf(left, right, inliningTarget, raiseNode); } @Specialization static Object doLIOvf(long left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doLLOvf(left, right, inliningTarget, factory, raiseNode); + return doLLOvf(left, right, inliningTarget, raiseNode); } @Specialization static Object doLLOvf(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); try { @@ -1673,7 +1663,7 @@ static Object doLLOvf(long left, long right, int rightI = (int) right; if (rightI == right) { try { - return factory.createInt(op(PInt.longToBigInteger(left), rightI)); + return PFactory.createInt(PythonLanguage.get(inliningTarget), op(PInt.longToBigInteger(left), rightI)); } catch (OverflowException ex) { // fallback to the raise of overflow error } @@ -1690,15 +1680,15 @@ static int doIPiZero(@SuppressWarnings("unused") int left, @SuppressWarnings("un @Specialization(replaces = "doIPiZero") static PInt doIPi(int left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); if (left == 0) { - return factory.createInt(BigInteger.ZERO); + return PFactory.createInt(language, BigInteger.ZERO); } try { int iright = right.intValueExact(); - return factory.createInt(op(PInt.longToBigInteger(left), iright)); + return PFactory.createInt(language, op(PInt.longToBigInteger(left), iright)); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); } @@ -1714,15 +1704,15 @@ static int doLPiZero(@SuppressWarnings("unused") long left, @SuppressWarnings("u @Specialization(replaces = "doLPiZero") static PInt doLPi(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); + PythonLanguage language = PythonLanguage.get(inliningTarget); if (left == 0) { - return factory.createInt(BigInteger.ZERO); + return PFactory.createInt(language, BigInteger.ZERO); } try { int iright = right.intValueExact(); - return factory.createInt(op(PInt.longToBigInteger(left), iright)); + return PFactory.createInt(language, op(PInt.longToBigInteger(left), iright)); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); } @@ -1731,15 +1721,14 @@ static PInt doLPi(long left, PInt right, @Specialization static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); - return doGuardedBiI(inliningTarget, left.getValue(), right, factory, raiseNode); + return doGuardedBiI(inliningTarget, left.getValue(), right, raiseNode); } - static PInt doGuardedBiI(Node inliningTarget, BigInteger left, int right, PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { + static PInt doGuardedBiI(Node inliningTarget, BigInteger left, int right, PRaiseNode.Lazy raiseNode) { try { - return factory.createInt(op(left, right)); + return PFactory.createInt(PythonLanguage.get(inliningTarget), op(left, right)); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); } @@ -1748,11 +1737,10 @@ static PInt doGuardedBiI(Node inliningTarget, BigInteger left, int right, Python @Specialization static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { int rightI = (int) right; if (rightI == right) { - return doPiI(left, rightI, inliningTarget, factory, raiseNode); + return doPiI(left, rightI, inliningTarget, raiseNode); } else { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); } @@ -1766,14 +1754,14 @@ static int doPiPiZero(@SuppressWarnings("unused") PInt left, @SuppressWarnings(" @Specialization(replaces = "doPiPiZero") static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); + PythonLanguage language = PythonLanguage.get(inliningTarget); if (left.isZero()) { - return factory.createInt(BigInteger.ZERO); + return PFactory.createInt(language, BigInteger.ZERO); } try { - return factory.createInt(op(left.getValue(), right.intValueExact())); + return PFactory.createInt(language, op(left.getValue(), right.intValueExact())); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); } @@ -1852,37 +1840,35 @@ static long doLL(long left, long right, @Specialization static Object doIPi(int left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, factory, raiseNode); + return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, raiseNode); } @Specialization static Object doLPi(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, factory, raiseNode); + return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, raiseNode); } @Specialization static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); - return factory.createInt(op(left.getValue(), right)); + return PFactory.createInt(language, op(left.getValue(), right)); } @Specialization static Object doPiL(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); int rightI = (int) right; if (rightI == right) { - return factory.createInt(op(left.getValue(), rightI)); + return PFactory.createInt(language, op(left.getValue(), rightI)); } // right is >= 2**31, BigInteger's bitLength is at most 2**31-1 // therefore the result of shifting right is just the sign bit @@ -1892,9 +1878,8 @@ static Object doPiL(PInt left, long right, @Specialization static Object doPInt(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return doHugeShift(inliningTarget, left.getValue(), right, factory, raiseNode); + return doHugeShift(inliningTarget, left.getValue(), right, raiseNode); } private static void raiseNegativeShiftCount(Node inliningTarget, boolean cond, PRaiseNode.Lazy raiseNode) { @@ -1909,10 +1894,10 @@ static PNotImplemented doGeneric(Object a, Object b) { return PNotImplemented.NOT_IMPLEMENTED; } - private static Object doHugeShift(Node inliningTarget, BigInteger left, PInt right, PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { + private static Object doHugeShift(Node inliningTarget, BigInteger left, PInt right, PRaiseNode.Lazy raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); try { - return factory.createInt(op(left, right.intValueExact())); + return PFactory.createInt(PythonLanguage.get(inliningTarget), op(left, right.intValueExact())); } catch (OverflowException e) { // right is >= 2**31, BigInteger's bitLength is at most 2**31-1 // therefore the result of shifting right is just the sign bit @@ -2008,20 +1993,20 @@ long voidPtrsManaged(VirtualFrame frame, PythonNativeVoidPtr a, PythonNativeVoid @Specialization PInt doPInt(long left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(PInt.longToBigInteger(left), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @Specialization PInt doPInt(PInt left, long right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), PInt.longToBigInteger(right))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization PInt doPInt(PInt left, PInt right, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(op(left.getValue(), right.getValue())); + @Bind PythonLanguage language) { + return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @SuppressWarnings("unused") @@ -2600,10 +2585,10 @@ private static boolean isBigEndian(Node raisingNode, TruffleString order) { @Specialization static PBytes fromLong(long self, int byteCount, TruffleString byteorder, boolean signed, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached InlinedConditionProfile negativeByteCountProfile, @Exclusive @Cached InlinedConditionProfile negativeNumberProfile, @Exclusive @Cached InlinedConditionProfile overflowProfile, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (negativeByteCountProfile.profile(inliningTarget, byteCount < 0)) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); @@ -2613,7 +2598,7 @@ static PBytes fromLong(long self, int byteCount, TruffleString byteorder, boolea throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); } } - return factory.createBytes(fromLong(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, + return PFactory.createBytes(language, fromLong(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, inliningTarget, overflowProfile, raiseNode)); } @@ -2680,14 +2665,14 @@ private static byte[] getBytes(BigInteger value) { @Specialization static PBytes fromPIntInt(PInt self, int byteCount, TruffleString byteorder, boolean signed, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached InlinedConditionProfile negativeByteCountProfile, @Exclusive @Cached InlinedConditionProfile overflowProfile, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (negativeByteCountProfile.profile(inliningTarget, byteCount < 0)) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); } - return factory.createBytes(fromBigInteger(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, + return PFactory.createBytes(language, fromBigInteger(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, inliningTarget, overflowProfile, raiseNode)); } @@ -2945,10 +2930,10 @@ static TruffleString formatI(int self, TruffleString formatString, @Specialization(guards = "!formatString.isEmpty()") static TruffleString formatL(VirtualFrame frame, long self, TruffleString formatString, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached PyNumberFloatNode floatNode, - @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return formatPI(frame, factory.createInt(self), formatString, inliningTarget, floatNode, raiseNode); + return formatPI(frame, PFactory.createInt(language, self), formatString, inliningTarget, floatNode, raiseNode); } @Specialization(guards = "!formatString.isEmpty()") @@ -3157,8 +3142,8 @@ static int get(@SuppressWarnings("unused") Object self) { abstract static class AsIntegerRatioNode extends PythonBuiltinNode { @Specialization static Object get(VirtualFrame frame, Object self, @Cached IntNode intNode, - @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{intNode.execute(frame, self), 1}); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, new Object[]{intNode.execute(frame, self), 1}); } } @@ -3185,21 +3170,11 @@ static Object doCopy(Object self, @GenerateNodeFactory abstract static class GetNewArgsNode extends PythonUnaryBuiltinNode { @Specialization - static Object doI(int self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{factory.createInt(self)}); - } - - @Specialization - static Object doL(long self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{factory.createInt(self)}); - } - - @Specialization - static Object getPI(PInt self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{factory.createInt(self.getValue())}); + static Object doI(Object self, + @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached PyLongCopy copy) { + return PFactory.createTuple(language, new Object[]{copy.execute(inliningTarget, self)}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java index 8f2ce4b2fb..a92f61f607 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,9 +45,10 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.NumericSupport; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.dsl.Cached; @@ -197,7 +198,6 @@ static Object doOther(Node inliningTarget, byte[] data, boolean littleEndian, bo @Cached InlinedBranchProfile fastPath4, @Cached InlinedBranchProfile fastPath8, @Cached InlinedBranchProfile generic, - @Cached(inline = false) PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { NumericSupport support = littleEndian ? NumericSupport.littleEndian() : NumericSupport.bigEndian(); if (signed) { @@ -227,7 +227,7 @@ static Object doOther(Node inliningTarget, byte[] data, boolean littleEndian, bo long longValue = PInt.longValue(integer); return PInt.isIntRange(longValue) ? (int) longValue : longValue; } else { - return factory.createInt(integer); + return PFactory.createInt(PythonLanguage.get(inliningTarget), integer); } } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.BYTE_ARRAY_TOO_LONG_TO_CONVERT_TO_INT); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java index 6bf68bcc18..7808530e9a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -30,6 +30,7 @@ import java.math.BigInteger; import java.util.Objects; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.SysModuleBuiltins; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; @@ -37,7 +38,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -616,9 +617,9 @@ public static Object abs(int v) { return Math.abs(v); } - public static Object abs(Node inliningTarget, long v, PythonObjectFactory.Lazy factory) { + public static Object abs(Node inliningTarget, long v) { if (v == Long.MIN_VALUE) { - return factory.get(inliningTarget).createInt(abs(PInt.longToBigInteger(v))); + return PFactory.createInt(PythonLanguage.get(inliningTarget), abs(PInt.longToBigInteger(v))); } return Math.abs(v); } @@ -695,8 +696,8 @@ private boolean fitsIn(BigInteger left, BigInteger right) { * @return either {@code Long} or {@code PInt} containing an unsigned value with bit pattern * matching that of {@code value} */ - public static Object createPythonIntFromUnsignedLong(Node inliningTarget, PythonObjectFactory factory, InlinedConditionProfile profile, long value) { - return profile.profile(inliningTarget, value >= 0) ? value : factory.createInt(longToUnsignedBigInt(value)); + public static Object createPythonIntFromUnsignedLong(Node inliningTarget, PythonLanguage language, InlinedConditionProfile profile, long value) { + return profile.profile(inliningTarget, value >= 0) ? value : PFactory.createInt(language, longToUnsignedBigInt(value)); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java index d8cc41b9e0..09427fc2b7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -40,6 +40,7 @@ import java.math.BigInteger; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -78,7 +79,7 @@ import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -208,10 +209,10 @@ static Object next(Node inliningTarget, PIntRangeIterator self, boolean throwSto @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PBigRangeIterator self, boolean throwStopIteration, - @Cached PythonObjectFactory.Lazy factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (self.hasNextBigInt()) { - return factory.get(inliningTarget).createInt(self.nextBigInt()); + return PFactory.createInt(language, self.nextBigInt()); } return stopIteration(inliningTarget, self, throwStopIteration, raiseNode); } @@ -340,10 +341,10 @@ static Object doDictKey(Node inliningTarget, @SuppressWarnings("unused") PDictVi @Specialization static PTuple doDictItem(Node inliningTarget, @SuppressWarnings("unused") PDictView.PDictItemIterator self, HashingStorage storage, HashingStorageIterator it, + @Bind PythonLanguage language, @Shared("val") @Cached HashingStorageIteratorValue itValueNode, - @Shared("key") @Cached HashingStorageIteratorKey itKeyNode, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createTuple(new Object[]{itKeyNode.execute(inliningTarget, storage, it), itValueNode.execute(inliningTarget, storage, it)}); + @Shared("key") @Cached HashingStorageIteratorKey itKeyNode) { + return PFactory.createTuple(language, new Object[]{itKeyNode.execute(inliningTarget, storage, it), itValueNode.execute(inliningTarget, storage, it)}); } @Specialization @@ -407,8 +408,8 @@ static int lengthHint(PIntRangeIterator self) { @Specialization(guards = "!self.isExhausted()") static Object lengthHint(PBigRangeIterator self, - @Cached PythonObjectFactory factory) { - return factory.createInt(self.getRemainingLength()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, self.getRemainingLength()); } @Specialization(guards = "!self.isExhausted()") @@ -482,119 +483,115 @@ static int foreign(Object self, public abstract static class ReduceNode extends PythonUnaryBuiltinNode { @Specialization - Object reduce(VirtualFrame frame, PArrayIterator self, + static Object reduce(VirtualFrame frame, PArrayIterator self, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Shared @Cached InlinedConditionProfile exhaustedProfile, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Shared @Cached PyObjectGetAttr getAttrNode) { if (!exhaustedProfile.profile(inliningTarget, self.isExhausted())) { - return reduceInternal(frame, inliningTarget, self.array, self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.array, self.getIndex(), context, getAttrNode); } else { - return reduceInternal(frame, inliningTarget, factory.createEmptyTuple(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, PFactory.createEmptyTuple(context.getLanguage(inliningTarget)), context, getAttrNode); } } @Specialization - Object reduce(VirtualFrame frame, PHashingStorageIterator self, + static Object reduce(VirtualFrame frame, PHashingStorageIterator self, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached SequenceStorageNodes.CreateStorageFromIteratorNode storageNode, // unused profile to avoid mixing shared and non-shared inlined nodes @SuppressWarnings("unused") @Shared @Cached InlinedConditionProfile exhaustedProfile, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PyObjectGetAttr getAttrNode) { int index = self.index; boolean isExhausted = self.isExhausted(); int state = self.getIterator().getState(); - PList list = factory.createList(storageNode.execute(frame, self)); + PList list = PFactory.createList(context.getLanguage(inliningTarget), storageNode.execute(frame, self)); self.getIterator().setState(state); self.setExhausted(isExhausted); self.index = index; - return reduceInternal(frame, inliningTarget, list, PythonContext.get(this), getAttrNode, factory); + return reduceInternal(frame, inliningTarget, list, context, getAttrNode); } @Specialization - Object reduce(VirtualFrame frame, PIntegerSequenceIterator self, + static Object reduce(VirtualFrame frame, PIntegerSequenceIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { if (self.isExhausted()) { - return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, PFactory.createList(context.getLanguage(inliningTarget)), null, context, getAttrNode); } - return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode); } @Specialization - Object reduce(VirtualFrame frame, PPrimitiveIterator self, + static Object reduce(VirtualFrame frame, PPrimitiveIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { if (self.isExhausted()) { - return reduceInternal(frame, inliningTarget, factory.createList(), null, context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, PFactory.createList(context.getLanguage(inliningTarget)), null, context, getAttrNode); } - return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode); } @Specialization - Object reduce(VirtualFrame frame, PStringIterator self, + static Object reduce(VirtualFrame frame, PStringIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { if (self.isExhausted()) { - return reduceInternal(frame, inliningTarget, T_EMPTY_STRING, null, context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, T_EMPTY_STRING, null, context, getAttrNode); } - return reduceInternal(frame, inliningTarget, self.value, self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.value, self.getIndex(), context, getAttrNode); } @Specialization - Object reduce(VirtualFrame frame, PIntRangeIterator self, + static Object reduce(VirtualFrame frame, PIntRangeIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { int start = self.getStart(); int stop = self.getStop(); int step = self.getStep(); int len = self.getLen(); - return reduceInternal(frame, inliningTarget, factory.createIntRange(start, stop, step, len), self.getIndex(), PythonContext.get(this), getAttrNode, factory); + PythonLanguage language = context.getLanguage(inliningTarget); + return reduceInternal(frame, inliningTarget, PFactory.createIntRange(language, start, stop, step, len), self.getIndex(), context, getAttrNode); } @Specialization - Object reduce(VirtualFrame frame, PBigRangeIterator self, + static Object reduce(VirtualFrame frame, PBigRangeIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { PInt start = self.getStart(); PInt stop = self.getStop(); PInt step = self.getStep(); PInt len = self.getLen(); - return reduceInternal(frame, inliningTarget, factory.createBigRange(start, stop, step, len), self.getLongIndex(factory), PythonContext.get(this), getAttrNode, factory); + PythonLanguage language = context.getLanguage(inliningTarget); + return reduceInternal(frame, inliningTarget, PFactory.createBigRange(language, start, stop, step, len), self.getLongIndex(language), context, getAttrNode); } @Specialization(guards = "self.isPSequence()") - Object reduce(VirtualFrame frame, PSequenceIterator self, + static Object reduce(VirtualFrame frame, PSequenceIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { if (self.isExhausted()) { - return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, PFactory.createTuple(context.getLanguage(inliningTarget), new Object[0]), null, context, getAttrNode); } - return reduceInternal(frame, inliningTarget, self.getPSequence(), self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.getPSequence(), self.getIndex(), context, getAttrNode); } @Specialization(guards = "!self.isPSequence()") - Object reduceNonSeq(@SuppressWarnings({"unused"}) VirtualFrame frame, PSequenceIterator self, + static Object reduceNonSeq(@SuppressWarnings({"unused"}) VirtualFrame frame, PSequenceIterator self, @Bind("this") Node inliningTarget, - @Shared @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { - PythonContext context = PythonContext.get(this); + @Bind PythonContext context, + @Shared @Cached PyObjectGetAttr getAttrNode) { if (!self.isExhausted()) { - return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, self.getObject(), self.getIndex(), context, getAttrNode); } else { - return reduceInternal(frame, inliningTarget, factory.createTuple(new Object[0]), null, context, getAttrNode, factory); + return reduceInternal(frame, inliningTarget, PFactory.createTuple(context.getLanguage(inliningTarget), new Object[0]), null, context, getAttrNode); } } @@ -605,19 +602,20 @@ static int other(Object self, throw raiseNode.get(inliningTarget).raise(TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "iterator", self); } - private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) { - return reduceInternal(frame, inliningTarget, arg, null, context, getAttrNode, factory); + private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, PythonContext context, PyObjectGetAttr getAttrNode) { + return reduceInternal(frame, inliningTarget, arg, null, context, getAttrNode); } - private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, Object state, PythonContext context, PyObjectGetAttr getAttrNode, PythonObjectFactory factory) { + private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, Object state, PythonContext context, PyObjectGetAttr getAttrNode) { PythonModule builtins = context.getBuiltins(); + PythonLanguage language = context.getLanguage(inliningTarget); Object iter = getAttrNode.execute(frame, inliningTarget, builtins, T_ITER); - PTuple args = factory.createTuple(new Object[]{arg}); + PTuple args = PFactory.createTuple(language, new Object[]{arg}); // callable, args, state (optional) if (state != null) { - return factory.createTuple(new Object[]{iter, args, state}); + return PFactory.createTuple(language, new Object[]{iter, args, state}); } else { - return factory.createTuple(new Object[]{iter, args}); + return PFactory.createTuple(language, new Object[]{iter, args}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PBigRangeIterator.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PBigRangeIterator.java index b5272521dc..21a3cff0ba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PBigRangeIterator.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PBigRangeIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,8 +42,9 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.object.Shape; @@ -98,8 +99,8 @@ public PInt getLen() { return len; } - public PInt getLongIndex(PythonObjectFactory factory) { - return factory.createInt(longIndex); + public PInt getLongIndex(PythonLanguage language) { + return PFactory.createInt(language, longIndex); } public void setLongIndex(BigInteger idx) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java index 8c2edd1b59..41f11490d7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java @@ -32,6 +32,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -48,7 +49,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -80,13 +81,13 @@ static Object doEmpty(@SuppressWarnings("unused") PZip self, @Specialization(guards = {"!isEmpty(self.getIterators())", "!self.isStrict()"}) static Object doNext(VirtualFrame frame, PZip self, @Shared @Cached GetNextNode next, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] iterators = self.getIterators(); Object[] tupleElements = new Object[iterators.length]; for (int i = 0; i < iterators.length; i++) { tupleElements[i] = next.execute(frame, iterators[i]); } - return factory.createTuple(tupleElements); + return PFactory.createTuple(language, tupleElements); } @Specialization(guards = {"!isEmpty(self.getIterators())", "self.isStrict()"}) @@ -94,7 +95,7 @@ static Object doNext(VirtualFrame frame, PZip self, @Bind("this") Node inliningTarget, @Shared @Cached GetNextNode next, @Cached IsBuiltinObjectProfile classProfile, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object[] iterators = self.getIterators(); Object[] tupleElements = new Object[iterators.length]; @@ -103,7 +104,7 @@ static Object doNext(VirtualFrame frame, PZip self, for (; i < iterators.length; i++) { tupleElements[i] = next.execute(frame, iterators[i]); } - return factory.createTuple(tupleElements); + return PFactory.createTuple(language, tupleElements); } catch (PException e) { e.expectStopIteration(inliningTarget, classProfile); if (i > 0) { @@ -141,11 +142,11 @@ static Object reduce(PZip self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile strictProfile, @Cached GetClassNode getClass, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClass.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(self.getIterators()); + PTuple tuple = PFactory.createTuple(language, self.getIterators()); Object[] elements = strictProfile.profile(inliningTarget, self.isStrict()) ? new Object[]{type, tuple, true} : new Object[]{type, tuple}; - return factory.createTuple(elements); + return PFactory.createTuple(language, elements); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java index 96d3fbb4a8..b419a5a504 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -32,6 +32,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -46,7 +47,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -110,16 +111,16 @@ abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(VirtualFrame frame, PSentinelIterator self, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttr, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = PythonContext.get(inliningTarget).getBuiltins(); Object iter = getAttr.execute(frame, inliningTarget, builtins, T_ITER); Object[] args; if (self.sentinelReached()) { - args = new Object[]{factory.createEmptyTuple()}; + args = new Object[]{PFactory.createEmptyTuple(language)}; } else { args = new Object[]{self.getCallable(), self.getSentinel()}; } - return factory.createTuple(new Object[]{iter, factory.createTuple(args)}); + return PFactory.createTuple(language, new Object[]{iter, PFactory.createTuple(language, args)}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java index ecd5340a1f..09d6d72a16 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -62,7 +63,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -136,7 +137,7 @@ static Object reduceNoFunc(VirtualFrame frame, PAccumulate self, @Cached InlinedBranchProfile totalMarkerProfile, @Cached InlinedBranchProfile elseProfile, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object func = self.getFunc(); if (func == null) { func = PNone.NONE; @@ -145,39 +146,39 @@ static Object reduceNoFunc(VirtualFrame frame, PAccumulate self, hasInitialProfile.enter(inliningTarget); Object type = getClassNode.execute(inliningTarget, self); - PChain chain = factory.createChain(PythonBuiltinClassType.PChain); - chain.setSource(getIter.execute(frame, inliningTarget, factory.createList(new Object[]{self.getIterable()}))); - PTuple initialTuple = factory.createTuple(new Object[]{self.getInitial()}); + PChain chain = PFactory.createChain(language); + chain.setSource(getIter.execute(frame, inliningTarget, PFactory.createList(language, new Object[]{self.getIterable()}))); + PTuple initialTuple = PFactory.createTuple(language, new Object[]{self.getInitial()}); chain.setActive(getIter.execute(frame, inliningTarget, initialTuple)); - PTuple tuple = factory.createTuple(new Object[]{chain, func}); - return factory.createTuple(new Object[]{type, tuple, PNone.NONE}); + PTuple tuple = PFactory.createTuple(language, new Object[]{chain, func}); + return PFactory.createTuple(language, new Object[]{type, tuple, PNone.NONE}); } else if (self.getTotal() == PNone.NONE) { totalNoneProfile.enter(inliningTarget); - PChain chain = factory.createChain(PythonBuiltinClassType.PChain); - PList noneList = factory.createList(new Object[]{PNone.NONE}); + PChain chain = PFactory.createChain(language); + PList noneList = PFactory.createList(language, new Object[]{PNone.NONE}); Object noneIter = getIter.execute(frame, inliningTarget, noneList); - chain.setSource(getIter.execute(frame, inliningTarget, factory.createList(new Object[]{noneIter, self.getIterable()}))); + chain.setSource(getIter.execute(frame, inliningTarget, PFactory.createList(language, new Object[]{noneIter, self.getIterable()}))); chain.setActive(PNone.NONE); - PAccumulate accumulate = factory.createAccumulate(PythonBuiltinClassType.PAccumulate); + PAccumulate accumulate = PFactory.createAccumulate(language); accumulate.setIterable(chain); accumulate.setFunc(func); - PTuple tuple = factory.createTuple(new Object[]{accumulate, 1, PNone.NONE}); - return factory.createTuple(new Object[]{PythonBuiltinClassType.PIslice, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{accumulate, 1, PNone.NONE}); + return PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PIslice, tuple}); } else if (self.getTotal() != null) { totalMarkerProfile.enter(inliningTarget); Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getIterable(), func}); - return factory.createTuple(new Object[]{type, tuple, self.getTotal()}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getIterable(), func}); + return PFactory.createTuple(language, new Object[]{type, tuple, self.getTotal()}); } else { elseProfile.enter(inliningTarget); Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getIterable(), func}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getIterable(), func}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java index 32e0311ef5..5b917c735b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -69,8 +70,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.util.PythonUtils; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -141,8 +141,8 @@ public abstract static class FromIterNode extends PythonBinaryBuiltinNode { static Object fromIter(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object arg, @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory) { - PChain instance = factory.createChain(PythonBuiltinClassType.PChain); + @Bind PythonLanguage language) { + PChain instance = PFactory.createChain(language); instance.setSource(getIter.execute(frame, inliningTarget, arg)); instance.setActive(PNone.NONE); return instance; @@ -158,19 +158,19 @@ static Object reducePos(PChain self, @Cached GetClassNode getClass, @Cached InlinedConditionProfile hasSourceProfile, @Cached InlinedConditionProfile hasActiveProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClass.execute(inliningTarget, self); - PTuple empty = factory.createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); + PTuple empty = PFactory.createEmptyTuple(language); if (hasSourceProfile.profile(inliningTarget, self.getSource() != PNone.NONE)) { if (hasActiveProfile.profile(inliningTarget, self.getActive() != PNone.NONE)) { - PTuple tuple = factory.createTuple(new Object[]{self.getSource(), self.getActive()}); - return factory.createTuple(new Object[]{type, empty, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getSource(), self.getActive()}); + return PFactory.createTuple(language, new Object[]{type, empty, tuple}); } else { - PTuple tuple = factory.createTuple(new Object[]{self.getSource()}); - return factory.createTuple(new Object[]{type, empty, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getSource()}); + return PFactory.createTuple(language, new Object[]{type, empty, tuple}); } } else { - return factory.createTuple(new Object[]{type, empty}); + return PFactory.createTuple(language, new Object[]{type, empty}); } } } @@ -217,8 +217,8 @@ private static void checkIterator(Node inliningTarget, PyIterCheckNode iterCheck public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java index 7380de3ab0..902aba2cbf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; @@ -111,7 +112,7 @@ static Object nextStopped(PAbstractCombinations self, @Specialization(guards = {"!self.isStopped()", "isLastResultNull(self)"}) static Object nextNoResult(PAbstractCombinations self, @Bind("this") Node inliningTarget, - @Cached @Shared PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached @Exclusive InlinedLoopConditionProfile loopConditionProfile) { // On the first pass, initialize result tuple using the indices Object[] result = new Object[self.getR()]; @@ -121,30 +122,28 @@ static Object nextNoResult(PAbstractCombinations self, result[i] = self.getPool()[idx]; } self.setLastResult(result); - return factory.createTuple(result); + return PFactory.createTuple(language, result); } @Specialization(guards = {"!self.isStopped()", "!isLastResultNull(self)"}) static Object next(PCombinations self, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached InlinedLoopConditionProfile indexLoopProfile, @Shared @Cached InlinedLoopConditionProfile resultLoopProfile, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return nextInternal(inliningTarget, self, factory, indexLoopProfile, resultLoopProfile, raiseNode); + return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode); } @Specialization(guards = {"!self.isStopped()", "!isLastResultNull(self)"}) static Object next(PCombinationsWithReplacement self, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached InlinedLoopConditionProfile indexLoopProfile, @Shared @Cached InlinedLoopConditionProfile resultLoopProfile, @Shared @Cached PRaiseNode.Lazy raiseNode) { - return nextInternal(inliningTarget, self, factory, indexLoopProfile, resultLoopProfile, raiseNode); + return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode); } - private static Object nextInternal(Node inliningTarget, PAbstractCombinations self, PythonObjectFactory factory, InlinedLoopConditionProfile indexLoopProfile, + private static Object nextInternal(Node inliningTarget, PAbstractCombinations self, InlinedLoopConditionProfile indexLoopProfile, InlinedLoopConditionProfile resultLoopProfile, PRaiseNode.Lazy raiseNode) throws PException { CompilerAsserts.partialEvaluationConstant(self.getClass()); @@ -182,7 +181,7 @@ private static Object nextInternal(Node inliningTarget, PAbstractCombinations se result[j] = elem; } self.setLastResult(result); - return factory.createTuple(result); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), result); } protected boolean isLastResultNull(PAbstractCombinations self) { @@ -200,18 +199,18 @@ static Object reduce(PAbstractCombinations self, @Cached InlinedConditionProfile hasNoLastResultProfile, @Cached InlinedConditionProfile stoppedProfile, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); if (hasNoLastResultProfile.profile(inliningTarget, self.getLastResult() == null)) { - PTuple args = factory.createTuple(new Object[]{factory.createTuple(self.getPool()), self.getR()}); - return factory.createTuple(new Object[]{type, args}); + PTuple args = PFactory.createTuple(language, new Object[]{PFactory.createTuple(language, self.getPool()), self.getR()}); + return PFactory.createTuple(language, new Object[]{type, args}); } else if (stoppedProfile.profile(inliningTarget, self.isStopped())) { - PTuple args = factory.createTuple(new Object[]{factory.createEmptyTuple(), self.getR()}); - return factory.createTuple(new Object[]{type, args}); + PTuple args = PFactory.createTuple(language, new Object[]{PFactory.createEmptyTuple(language), self.getR()}); + return PFactory.createTuple(language, new Object[]{type, args}); } - PTuple indices = factory.createTuple(PythonUtils.arrayCopyOf(self.getIndices(), self.getR())); - PTuple args = factory.createTuple(new Object[]{factory.createTuple(self.getPool()), self.getR()}); - return factory.createTuple(new Object[]{type, args, indices}); + PTuple indices = PFactory.createTuple(language, PythonUtils.arrayCopyOf(self.getIndices(), self.getR())); + PTuple args = PFactory.createTuple(language, new Object[]{PFactory.createTuple(language, self.getPool()), self.getR()}); + return PFactory.createTuple(language, new Object[]{type, args, indices}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java index 67996302fd..cb3238ec69 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -110,10 +111,10 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PCompress self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getData(), self.getSelectors()}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getData(), self.getSelectors()}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java index 9999eca821..2fe6c53551 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -63,7 +64,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -140,16 +141,16 @@ static Object reducePos(PCount self, @Cached CastToJavaLongExactNode castLongNode, @Cached PyObjectTypeCheck typeCheckNode, @Cached InlinedConditionProfile hasDefaultStep, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); PTuple tuple; if (hasDefaultStep.profile(inliningTarget, !typeCheckNode.execute(inliningTarget, self.getStep(), PythonBuiltinClassType.PInt) || castLongNode.execute(inliningTarget, self.getStep()) != 1)) { - tuple = factory.createTuple(new Object[]{self.getCnt(), self.getStep()}); + tuple = PFactory.createTuple(language, new Object[]{self.getCnt(), self.getStep()}); } else { - tuple = factory.createTuple(new Object[]{self.getCnt()}); + tuple = PFactory.createTuple(language, new Object[]{self.getCnt()}); } - return factory.createTuple(new Object[]{type, tuple}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java index 5a4955219f..a06f28a1b8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -53,6 +53,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -61,7 +62,6 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ToArrayNode; import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode; @@ -76,12 +76,11 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -170,11 +169,11 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PCycle self, @Bind("this") Node inliningTarget, @Exclusive @Cached GetClassNode getClass, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClass.execute(inliningTarget, self); - PTuple iterableTuple = factory.createTuple(new Object[]{self.getIterable()}); - PTuple tuple = factory.createTuple(new Object[]{getSavedList(self, factory), self.isFirstpass()}); - return factory.createTuple(new Object[]{type, iterableTuple, tuple}); + PTuple iterableTuple = PFactory.createTuple(language, new Object[]{self.getIterable()}); + PTuple tuple = PFactory.createTuple(language, new Object[]{getSavedList(self, language), self.isFirstpass()}); + return PFactory.createTuple(language, new Object[]{type, iterableTuple, tuple}); } @Specialization(guards = "!hasIterable(self)") @@ -185,22 +184,22 @@ static Object reduceNoIterable(VirtualFrame frame, PCycle self, @Cached CallUnaryMethodNode callNode, @Cached PyObjectGetIter getIterNode, @Cached InlinedBranchProfile indexProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClass.execute(inliningTarget, self); - PList savedList = getSavedList(self, factory); + PList savedList = getSavedList(self, language); Object it = getIterNode.execute(frame, inliningTarget, savedList); if (self.getIndex() > 0) { indexProfile.enter(inliningTarget); Object setStateCallable = lookupAttrNode.execute(frame, inliningTarget, it, T___SETSTATE__); callNode.executeObject(frame, setStateCallable, self.getIndex()); } - PTuple iteratorTuple = factory.createTuple(new Object[]{it}); - PTuple tuple = factory.createTuple(new Object[]{savedList, true}); - return factory.createTuple(new Object[]{type, iteratorTuple, tuple}); + PTuple iteratorTuple = PFactory.createTuple(language, new Object[]{it}); + PTuple tuple = PFactory.createTuple(language, new Object[]{savedList, true}); + return PFactory.createTuple(language, new Object[]{type, iteratorTuple, tuple}); } - static PList getSavedList(PCycle self, PythonObjectFactory factory) { - return factory.createList(toArray(self.getSaved())); + static PList getSavedList(PCycle self, PythonLanguage language) { + return PFactory.createList(language, toArray(self.getSaved())); } @TruffleBoundary @@ -216,8 +215,6 @@ protected boolean hasIterable(PCycle self) { @Builtin(name = J___SETSTATE__, minNumOfPositionalArgs = 2) @GenerateNodeFactory public abstract static class SetStateNode extends PythonBinaryBuiltinNode { - abstract Object execute(VirtualFrame frame, PythonObject self, Object state); - @Specialization static Object setState(VirtualFrame frame, PCycle self, Object state, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java index f25a0b534a..7243f932ad 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaBooleanNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -125,10 +126,10 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PDropwhile self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getPredicate(), self.getIterable()}); - return factory.createTuple(new Object[]{type, tuple, self.isDoneDropping()}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getPredicate(), self.getIterable()}); + return PFactory.createTuple(language, new Object[]{type, tuple, self.isDoneDropping()}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java index f38bbacfcf..b34b55e78f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -58,7 +59,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -130,14 +131,14 @@ Object reduce(PFilterfalse self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile hasNoFuncProfile, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object func = self.getFunc(); if (hasNoFuncProfile.profile(inliningTarget, func == null)) { func = PNone.NONE; } Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{func, self.getSequence()}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{func, self.getSequence()}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java index a00f7d7545..d3b061d25d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -64,7 +65,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -105,14 +106,14 @@ static Object next(VirtualFrame frame, PGroupBy self, @Cached InlinedBranchProfile eqProfile, @Cached InlinedConditionProfile hasFuncProfile, @Cached InlinedLoopConditionProfile loopConditionProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { self.setCurrGrouper(null); while (loopConditionProfile.profile(inliningTarget, doGroupByStep(frame, inliningTarget, self, eqProfile, eqNode))) { self.groupByStep(frame, inliningTarget, nextNode, callNode, hasFuncProfile); } self.setTgtKey(self.getCurrKey()); - PGrouper grouper = factory.createGrouper(self, self.getTgtKey()); - return factory.createTuple(new Object[]{self.getCurrKey(), grouper}); + PGrouper grouper = PFactory.createGrouper(language, self, self.getTgtKey()); + return PFactory.createTuple(language, new Object[]{self.getCurrKey(), grouper}); } private static boolean doGroupByStep(VirtualFrame frame, Node inliningTarget, PGroupBy self, InlinedBranchProfile eqProfile, PyObjectRichCompareBool.EqNode eqNode) { @@ -139,18 +140,18 @@ static Object reduceMarkerNotSet(PGroupBy self, @Cached InlinedConditionProfile noKeyFuncProfile, @Cached InlinedConditionProfile noValuesProfile, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object keyFunc = self.getKeyFunc(); if (noKeyFuncProfile.profile(inliningTarget, keyFunc == null)) { keyFunc = PNone.NONE; } Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple1 = factory.createTuple(new Object[]{self.getIt(), keyFunc}); + PTuple tuple1 = PFactory.createTuple(language, new Object[]{self.getIt(), keyFunc}); if (noValuesProfile.profile(inliningTarget, !valuesSet(self))) { - return factory.createTuple(new Object[]{type, tuple1}); + return PFactory.createTuple(language, new Object[]{type, tuple1}); } - PTuple tuple2 = factory.createTuple(new Object[]{self.getCurrValue(), self.getTgtKey(), self.getCurrKey()}); - return factory.createTuple(new Object[]{type, tuple1, tuple2}); + PTuple tuple2 = PFactory.createTuple(language, new Object[]{self.getCurrValue(), self.getTgtKey(), self.getCurrKey()}); + return PFactory.createTuple(language, new Object[]{type, tuple1, tuple2}); } private static boolean valuesSet(PGroupBy self) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java index 527efebabd..06a07127df 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -62,10 +63,9 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -131,21 +131,21 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PGrouper self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getParent(), self.getTgtKey()}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getParent(), self.getTgtKey()}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } @Specialization(guards = "!currValueIsSelf(self)") Object reduceCurrNotSelf(VirtualFrame frame, @SuppressWarnings("unused") PGrouper self, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttrNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = getContext().getCore().lookupBuiltinModule(BuiltinNames.T_BUILTINS); Object iterCallable = getAttrNode.execute(frame, inliningTarget, builtins, T_ITER); // return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter)); - return factory.createTuple(new Object[]{iterCallable, factory.createTuple(new Object[]{factory.createEmptyTuple()})}); + return PFactory.createTuple(language, new Object[]{iterCallable, PFactory.createTuple(language, new Object[]{PFactory.createEmptyTuple(language)})}); } protected boolean currValueIsSelf(PGrouper self) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java index bcc61d9783..b076d60e46 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -66,11 +67,10 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntLossyNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -158,22 +158,22 @@ static Object reduceNoIterable(VirtualFrame frame, PIslice self, @Bind("this") Node inliningTarget, @Exclusive @Cached GetClassNode getClassNode, @Cached PyObjectGetIter getIter, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // return type(self), (iter([]), 0), 0 Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{getIter.execute(frame, inliningTarget, factory.createList()), 0}); - return factory.createTuple(new Object[]{type, tuple, 0}); + PTuple tuple = PFactory.createTuple(language, new Object[]{getIter.execute(frame, inliningTarget, PFactory.createList(language)), 0}); + return PFactory.createTuple(language, new Object[]{type, tuple, 0}); } @Specialization(guards = "!isNone(self.getIterable())") static Object reduce(PIslice self, @Bind("this") Node inliningTarget, @Exclusive @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); Object stop = (self.getStop() == -1) ? PNone.NONE : self.getStop(); - PTuple tuple = factory.createTuple(new Object[]{self.getIterable(), self.getNext(), stop, self.getStep()}); - return factory.createTuple(new Object[]{type, tuple, self.getCnt()}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getIterable(), self.getNext(), stop, self.getStep()}); + return PFactory.createTuple(language, new Object[]{type, tuple, self.getCnt()}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java index 2fabb2896f..37ea4b0cbb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -43,12 +43,13 @@ import static com.oracle.graal.python.builtins.objects.itertools.TeeDataObjectBuiltins.LINKCELLS; import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_REENTER_TEE_ITERATOR; +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.object.PythonBuiltinObject; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; @@ -113,9 +114,9 @@ public void setNextlink(PTeeDataObject nextlink) { this.nextlink = nextlink; } - PTeeDataObject jumplink(PythonObjectFactory factory) { + PTeeDataObject jumplink(PythonLanguage language) { if (getNextlink() == null) { - PTeeDataObject dataObj = factory.createTeeDataObject(getIt()); + PTeeDataObject dataObj = PFactory.createTeeDataObject(language, getIt()); nextlink = dataObj; } return nextlink; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java index 775ebb45f6..5cb777aceb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -56,7 +57,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -90,7 +91,7 @@ static Object next(VirtualFrame frame, PPairwise self, @Bind("this") Node inliningTarget, @Cached BuiltinFunctions.NextNode nextNode, @Cached IsBuiltinObjectProfile isStopIterationProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object item; Object old = self.getOld(); if (self.getOld() == null) { @@ -106,7 +107,7 @@ static Object next(VirtualFrame frame, PPairwise self, self.setOld(null); throw e; } - return factory.createTuple(new Object[]{old, item}); + return PFactory.createTuple(language, new Object[]{old, item}); } @Specialization(guards = "self.getIterable() == null") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java index 3d3851bfb2..b1c9de1981 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -69,7 +70,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaBooleanNode; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -117,7 +118,7 @@ static Object next(PPermutations self, @Cached InlinedLoopConditionProfile resultLoopProfile, @Cached InlinedLoopConditionProfile mainLoopProfile, @Cached InlinedLoopConditionProfile shiftIndicesProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { int r = self.getR(); @@ -139,7 +140,7 @@ static Object next(PPermutations self, int tmp = indices[i]; indices[i] = indices[indices.length - j]; indices[indices.length - j] = tmp; - return factory.createTuple(result); + return PFactory.createTuple(language, result); } cycles[i] = indices.length - i; int n1 = indices.length - 1; @@ -159,7 +160,7 @@ static Object next(PPermutations self, } else { self.setStarted(true); } - return factory.createTuple(result); + return PFactory.createTuple(language, result); } } @@ -170,29 +171,29 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PPermutations self, @Bind("this") Node inliningTarget, @Shared @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PList poolList = factory.createList(self.getPool()); - PTuple tuple = factory.createTuple(new Object[]{poolList, self.getR()}); + PList poolList = PFactory.createList(language, self.getPool()); + PTuple tuple = PFactory.createTuple(language, new Object[]{poolList, self.getR()}); // we must pickle the indices and use them for setstate - PTuple indicesTuple = factory.createTuple(self.getIndices()); - PTuple cyclesTuple = factory.createTuple(self.getCycles()); - PTuple tuple2 = factory.createTuple(new Object[]{indicesTuple, cyclesTuple, self.isStarted()}); + PTuple indicesTuple = PFactory.createTuple(language, self.getIndices()); + PTuple cyclesTuple = PFactory.createTuple(language, self.getCycles()); + PTuple tuple2 = PFactory.createTuple(language, new Object[]{indicesTuple, cyclesTuple, self.isStarted()}); Object[] result = new Object[]{type, tuple, tuple2}; - return factory.createTuple(result); + return PFactory.createTuple(language, result); } @Specialization(guards = "self.isRaisedStopIteration()") static Object reduceStopped(PPermutations self, @Bind("this") Node inliningTarget, @Shared @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{factory.createEmptyTuple(), self.getR()}); + PTuple tuple = PFactory.createTuple(language, new Object[]{PFactory.createEmptyTuple(language), self.getR()}); Object[] result = new Object[]{type, tuple}; - return factory.createTuple(result); + return PFactory.createTuple(language, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java index 0496482d7a..8a412aadae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -61,12 +62,11 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -101,14 +101,14 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { static Object next(PProduct self, @Bind("this") Node inliningTarget, @Exclusive @Cached InlinedLoopConditionProfile loopProfile, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] lst = new Object[self.getGears().length]; loopProfile.profileCounted(inliningTarget, lst.length); for (int i = 0; loopProfile.inject(inliningTarget, i < lst.length); i++) { lst[i] = self.getGears()[i][0]; } self.setLst(lst); - return factory.createTuple(lst); + return PFactory.createTuple(language, lst); } @Specialization(guards = {"!self.isStopped()", "hasLst(self)"}) @@ -119,7 +119,7 @@ static Object next(PProduct self, @Cached InlinedBranchProfile wasStoppedProfile, @Exclusive @Cached InlinedLoopConditionProfile loopProfile, @Cached InlinedBranchProfile doneProfile, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object[][] gears = self.getGears(); int x = gears.length - 1; @@ -146,7 +146,7 @@ static Object next(PProduct self, // the existing lst array can be changed in a following next call Object[] ret = new Object[self.getLst().length]; PythonUtils.arraycopy(self.getLst(), 0, ret, 0, ret.length); - return factory.createTuple(ret); + return PFactory.createTuple(language, ret); } @SuppressWarnings("unused") @@ -198,26 +198,26 @@ static Object reduce(PProduct self, @Cached InlinedConditionProfile stoppedProfile, @Cached InlinedConditionProfile noLstProfile, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); if (stoppedProfile.profile(inliningTarget, self.isStopped())) { - PTuple empty = factory.createEmptyTuple(); - return factory.createTuple(new Object[]{type, factory.createTuple(new Object[]{empty})}); + PTuple empty = PFactory.createEmptyTuple(language); + return PFactory.createTuple(language, new Object[]{type, PFactory.createTuple(language, new Object[]{empty})}); } - PTuple gearTuples = createGearTuple(self, factory); + PTuple gearTuples = createGearTuple(self, language); if (noLstProfile.profile(inliningTarget, self.getLst() == null)) { - return factory.createTuple(new Object[]{type, gearTuples}); + return PFactory.createTuple(language, new Object[]{type, gearTuples}); } - PTuple indicesTuple = factory.createTuple(PythonUtils.arrayCopyOf(self.getIndices(), self.getIndices().length)); - return factory.createTuple(new Object[]{type, gearTuples, indicesTuple}); + PTuple indicesTuple = PFactory.createTuple(language, PythonUtils.arrayCopyOf(self.getIndices(), self.getIndices().length)); + return PFactory.createTuple(language, new Object[]{type, gearTuples, indicesTuple}); } - private static PTuple createGearTuple(PProduct self, PythonObjectFactory factory) { + private static PTuple createGearTuple(PProduct self, PythonLanguage language) { PList[] lists = new PList[self.getGears().length]; for (int i = 0; i < lists.length; i++) { - lists[i] = factory.createList(self.getGears()[i]); + lists[i] = PFactory.createList(language, self.getGears()[i]); } - return factory.createTuple(lists); + return PFactory.createTuple(language, lists); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java index 58f51d17dd..1a07d71706 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -64,7 +65,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -139,7 +140,7 @@ static Object reduce(PRepeat self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile negativeCountProfile, @Cached GetClassNode getClass, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClass.execute(inliningTarget, self); Object[] tupleElements; if (negativeCountProfile.profile(inliningTarget, self.getCnt() < 0)) { @@ -147,8 +148,8 @@ static Object reduce(PRepeat self, } else { tupleElements = new Object[]{self.getElement(), self.getCnt()}; } - PTuple tuple = factory.createTuple(tupleElements); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, tupleElements); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java index 96bbb96001..d656ba290c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,7 +60,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -106,11 +107,11 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reducePos(PStarmap self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); // return type(self), (self.fun, self.iterable) - PTuple tuple = factory.createTuple(new Object[]{self.getFun(), self.getIterable()}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getFun(), self.getIterable()}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java index cbaa174253..d0784fbad1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,7 +60,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -95,11 +96,11 @@ static Object next(VirtualFrame frame, PTakewhile self, @Cached BuiltinFunctions.NextNode nextNode, @Cached CallNode callNode, @Cached PyObjectIsTrueNode isTrue, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object value = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE); if (!isTrue.execute(frame, callNode.execute(frame, self.getPredicate(), value))) { - self.setIterable(factory.createSequenceIterator(factory.createList(PythonUtils.EMPTY_OBJECT_ARRAY))); + self.setIterable(PFactory.createSequenceIterator(language, PFactory.createList(language, PythonUtils.EMPTY_OBJECT_ARRAY))); throw raiseNode.get(inliningTarget).raiseStopIteration(); } return value; @@ -113,10 +114,10 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PTakewhile self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); - PTuple tuple = factory.createTuple(new Object[]{self.getPredicate(), self.getIterable()}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getPredicate(), self.getIterable()}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java index 29fad45e82..4fb2a302bb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -56,13 +56,13 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.modules.BuiltinFunctions; import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode; @@ -75,7 +75,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntLossyNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -105,13 +105,13 @@ static Object newTee(VirtualFrame frame, @SuppressWarnings("unused") Object cls, @Cached PyObjectGetIter getIter, @Cached("createCopyNode()") LookupAndCallUnaryNode copyNode, @Cached InlinedConditionProfile isTeeInstanceProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object it = getIter.execute(frame, inliningTarget, iterable); if (isTeeInstanceProfile.profile(inliningTarget, it instanceof PTee)) { return copyNode.executeObject(frame, it); } else { - PTeeDataObject dataObj = factory.createTeeDataObject(it); - return factory.createTee(dataObj, 0); + PTeeDataObject dataObj = PFactory.createTeeDataObject(language, it); + return PFactory.createTee(language, dataObj, 0); } } @@ -126,8 +126,8 @@ protected LookupAndCallUnaryNode createCopyNode() { public abstract static class CopyNode extends PythonUnaryBuiltinNode { @Specialization static Object copy(PTee self, - @Cached PythonObjectFactory factory) { - return factory.createTee(self.getDataobj(), self.getIndex()); + @Bind PythonLanguage language) { + return PFactory.createTee(language, self.getDataobj(), self.getIndex()); } } @@ -158,9 +158,9 @@ static Object next(VirtualFrame frame, PTee self, static Object nextNext(VirtualFrame frame, PTee self, @Bind("this") Node inliningTarget, @Shared @Cached BuiltinFunctions.NextNode nextNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { - self.setDataObj(self.getDataobj().jumplink(factory)); + self.setDataObj(self.getDataobj().jumplink(language)); Object value = self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode); self.setIndex(1); return value; @@ -170,25 +170,23 @@ static Object nextNext(VirtualFrame frame, PTee self, @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1) @GenerateNodeFactory public abstract static class ReduceNode extends PythonUnaryBuiltinNode { - abstract Object execute(VirtualFrame frame, PythonObject self); @Specialization static Object reduce(PTee self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClass, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { // return type(self), ((),), (self.dataobj, self.index) Object type = getClass.execute(inliningTarget, self); - PTuple tuple1 = factory.createTuple(new Object[]{factory.createEmptyTuple()}); - PTuple tuple2 = factory.createTuple(new Object[]{self.getDataobj(), self.getIndex()}); - return factory.createTuple(new Object[]{type, tuple1, tuple2}); + PTuple tuple1 = PFactory.createTuple(language, new Object[]{PFactory.createEmptyTuple(language)}); + PTuple tuple2 = PFactory.createTuple(language, new Object[]{self.getDataobj(), self.getIndex()}); + return PFactory.createTuple(language, new Object[]{type, tuple1, tuple2}); } } @Builtin(name = J___SETSTATE__, minNumOfPositionalArgs = 2) @GenerateNodeFactory public abstract static class SetStateNode extends PythonBinaryBuiltinNode { - abstract Object execute(VirtualFrame frame, PythonObject self, Object state); @Specialization static Object setState(VirtualFrame frame, PTee self, Object state, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java index 0ee4d51cdf..2fd392cea7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -48,10 +48,10 @@ import static com.oracle.graal.python.nodes.ErrorMessages.TDATAOBJECT_SHOULD_NOT_HAVE_MORE_LINKS; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___COPY__; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -64,13 +64,12 @@ import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonQuaternaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -159,10 +158,6 @@ static Object init(VirtualFrame frame, PTeeDataObject self, Object it, Object va @Cached PRaiseNode raiseNode) { throw raiseNode.raise(TypeError, ARG_D_MUST_BE_S_NOT_P, "teedataobject()", 2, "list", values); } - - protected LookupAndCallUnaryNode createCopyNode() { - return LookupAndCallUnaryNode.create(T___COPY__); - } } @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1) @@ -174,14 +169,14 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PTeeDataObject self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClass, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int numread = self.getNumread(); Object[] values = new Object[numread]; PythonUtils.arraycopy(self.getValues(), 0, values, 0, numread); Object type = getClass.execute(inliningTarget, self); Object nextlink = self.getNextlink(); - PTuple tuple = factory.createTuple(new Object[]{self.getIt(), factory.createList(values), nextlink == null ? PNone.NONE : nextlink}); - return factory.createTuple(new Object[]{type, tuple}); + PTuple tuple = PFactory.createTuple(language, new Object[]{self.getIt(), PFactory.createList(language, values), nextlink == null ? PNone.NONE : nextlink}); + return PFactory.createTuple(language, new Object[]{type, tuple}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java index 0384b449f1..b2383c162c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -48,6 +48,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -62,7 +63,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -109,14 +110,13 @@ static Object next(VirtualFrame frame, PZipLongest self, @Cached InlinedConditionProfile noActiveProfile, @Cached InlinedLoopConditionProfile loopProfile, @Cached InlinedConditionProfile isNullFillProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { Object fillValue = isNullFillProfile.profile(inliningTarget, isNullFillValue(self)) ? PNone.NONE : self.getFillValue(); - return next(frame, inliningTarget, self, fillValue, nextNode, isStopIterationProfile, loopProfile, noItProfile, noActiveProfile, factory, raiseNode); + return next(frame, inliningTarget, self, fillValue, nextNode, isStopIterationProfile, loopProfile, noItProfile, noActiveProfile, raiseNode); } private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest self, Object fillValue, BuiltinFunctions.NextNode nextNode, IsBuiltinObjectProfile isStopIterationProfile, - InlinedLoopConditionProfile loopProfile, InlinedConditionProfile noItProfile, InlinedConditionProfile noActiveProfile, PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { + InlinedLoopConditionProfile loopProfile, InlinedConditionProfile noItProfile, InlinedConditionProfile noActiveProfile, PRaiseNode.Lazy raiseNode) { Object[] result = new Object[self.getItTuple().length]; loopProfile.profileCounted(inliningTarget, result.length); for (int i = 0; loopProfile.inject(inliningTarget, i < result.length); i++) { @@ -144,7 +144,7 @@ private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest } result[i] = item; } - return factory.createTuple(result); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), result); } protected static boolean isNullFillValue(PZipLongest self) { @@ -166,7 +166,7 @@ static Object reduce(PZipLongest self, @Cached InlinedConditionProfile noFillValueProfile, @Cached InlinedLoopConditionProfile loopProfile, @Cached InlinedConditionProfile noItProfile, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object fillValue = self.getFillValue(); if (noFillValueProfile.profile(inliningTarget, fillValue == null)) { fillValue = PNone.NONE; @@ -177,13 +177,13 @@ static Object reduce(PZipLongest self, for (int i = 0; loopProfile.profile(inliningTarget, i < its.length); i++) { Object it = self.getItTuple()[i]; if (noItProfile.profile(inliningTarget, it == PNone.NONE)) { - its[i] = factory.createEmptyTuple(); + its[i] = PFactory.createEmptyTuple(language); } else { its[i] = it; } } - PTuple tuple = factory.createTuple(its); - return factory.createTuple(new Object[]{type, tuple, fillValue}); + PTuple tuple = PFactory.createTuple(language, its); + return PFactory.createTuple(language, new Object[]{type, tuple, fillValue}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index 4abd0e414c..764b804251 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -55,6 +55,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -80,6 +81,7 @@ import com.oracle.graal.python.builtins.objects.range.PIntRange; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode; @@ -111,7 +113,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; @@ -313,7 +315,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, } var sequenceStorage = getStorageNode.execute(inliningTarget, self); return subscriptNode.execute(frame, inliningTarget, sequenceStorage, idx, - ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PythonObjectFactory::createList); + ErrorMessages.LIST_INDEX_OUT_OF_RANGE, PFactory::createList); } @InliningCutoff @@ -458,10 +460,11 @@ static PList copySequence(Object list, @Cached GetListStorageNode getStorageNode, @Cached SequenceStorageNodes.CopyNode copy, @Cached GetClassForNewListNode getClassForNewListNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { var sequenceStorage = getStorageNode.execute(inliningTarget, list); Object newClass = getClassForNewListNode.execute(inliningTarget, list); - return factory.createList(newClass, copy.execute(inliningTarget, sequenceStorage)); + return PFactory.createList(language, newClass, getInstanceShape.execute(newClass), copy.execute(inliningTarget, sequenceStorage)); } } @@ -749,7 +752,8 @@ static PList doPList(Object left, Object right, @Cached GetListStorageNode getStorageNode, @Cached GetClassForNewListNode getClassForNewListNode, @Cached("createConcat()") SequenceStorageNodes.ConcatNode concatNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode.Lazy raiseNode) { if (!isListNode.execute(inliningTarget, right)) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "list", right, "list"); @@ -759,7 +763,7 @@ static PList doPList(Object left, Object right, var rightStorage = getStorageNode.execute(inliningTarget, right); SequenceStorage newStore = concatNode.execute(leftStorage, rightStorage); Object newClass = getClassForNewListNode.execute(inliningTarget, left); - return factory.createList(newClass, newStore); + return PFactory.createList(language, newClass, getInstanceShape.execute(newClass), newStore); } @NeverDefault @@ -800,7 +804,7 @@ static Object doPListInt(VirtualFrame frame, Object left, int right, @Cached PyListCheckNode isListNode, @Cached GetListStorageNode getStorageNode, @Cached SequenceStorageNodes.RepeatNode repeatNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (!isListNode.execute(inliningTarget, left)) { return PNotImplemented.NOT_IMPLEMENTED; @@ -809,7 +813,7 @@ static Object doPListInt(VirtualFrame frame, Object left, int right, var sequenceStorage = getStorageNode.execute(inliningTarget, left); try { SequenceStorage repeated = repeatNode.execute(frame, sequenceStorage, right); - return factory.createList(repeated); + return PFactory.createList(language, repeated); } catch (ArithmeticException | OutOfMemoryError e) { throw raiseNode.get(inliningTarget).raise(MemoryError); } @@ -830,10 +834,6 @@ static Object doGeneric(VirtualFrame frame, Object list, Object right, updateStorageNode.execute(inliningTarget, list, store, updated); return list; } - - protected IMulNode createIMulNode() { - return ListBuiltinsFactory.IMulNodeFactory.create(); - } } @Builtin(name = J___EQ__, minNumOfPositionalArgs = 2) @@ -1040,26 +1040,26 @@ public abstract static class IterNode extends PythonUnaryBuiltinNode { */ @Specialization(guards = {"isIntStorage(primary)"}) static PIntegerSequenceIterator doPListInt(PList primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createIntegerSequenceIterator((IntSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createIntegerSequenceIterator(language, (IntSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"isLongStorage(primary)"}) static PLongSequenceIterator doPListLong(PList primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createLongSequenceIterator((LongSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createLongSequenceIterator(language, (LongSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"isDoubleStorage(primary)"}) static PDoubleSequenceIterator doPListDouble(PList primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDoubleSequenceIterator((DoubleSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createDoubleSequenceIterator(language, (DoubleSequenceStorage) primary.getSequenceStorage(), primary); } @Fallback static PSequenceIterator doOther(Object primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createSequenceIterator(primary); + @Bind PythonLanguage language) { + return PFactory.createSequenceIterator(language, primary); } } @@ -1070,9 +1070,9 @@ abstract static class ReverseNode extends PythonUnaryBuiltinNode { static Object reverse(Object self, @Bind("this") Node inliningTarget, @Cached GetListStorageNode getStorage, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int len = getStorage.execute(inliningTarget, self).length(); - return factory.createSequenceReverseIterator(PythonBuiltinClassType.PReverseIterator, self, len); + return PFactory.createSequenceReverseIterator(language, self, len); } } @@ -1081,8 +1081,8 @@ static Object reverse(Object self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java index daea43de4e..dd43ef47c1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,7 +58,8 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -111,12 +113,12 @@ static PMap iter(PMap self) { public abstract static class ReduceNode extends PythonBuiltinNode { @Specialization static PTuple doit(PMap self, @SuppressWarnings("unused") Object ignored, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] iterators = self.getIterators(); Object[] args = new Object[iterators.length + 1]; args[0] = self.getFunction(); System.arraycopy(iterators, 0, args, 1, iterators.length); - return factory.createTuple(new Object[]{PythonBuiltinClassType.PMap, factory.createTuple(args)}); + return PFactory.createTuple(language, new Object[]{PythonBuiltinClassType.PMap, PFactory.createTuple(language, args)}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java index 1800a7ca6c..f57e595d9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -76,7 +77,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -259,8 +260,8 @@ static TruffleString repr(VirtualFrame frame, PMappingproxy self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java index 3e3f9510b7..8425934da2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java @@ -57,6 +57,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -100,7 +101,7 @@ import com.oracle.graal.python.runtime.AsyncHandler; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.BufferFormat; @@ -179,11 +180,11 @@ static Object getitem(VirtualFrame frame, PMemoryView self, Object index, @Specialization static Object getitemSlice(PMemoryView self, PSlice slice, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached InlinedConditionProfile zeroDimProfile, @Cached SliceNodes.SliceUnpack sliceUnpack, @Cached SliceNodes.AdjustIndices adjustIndices, @Cached MemoryViewNodes.InitFlagsNode initFlagsNode, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (zeroDimProfile.profile(inliningTarget, self.getDimensions() == 0)) { @@ -201,7 +202,7 @@ static Object getitemSlice(PMemoryView self, PSlice slice, int[] suboffsets = self.getBufferSuboffsets(); int length = self.getLength() - (shape[0] - newShape[0]) * self.getItemSize(); int flags = initFlagsNode.execute(inliningTarget, self.getDimensions(), self.getItemSize(), newShape, newStrides, suboffsets); - return factory.createMemoryView(PythonContext.get(inliningTarget), self.getLifecycleManager(), self.getBuffer(), self.getOwner(), length, self.isReadOnly(), + return PFactory.createMemoryView(language, PythonContext.get(inliningTarget), self.getLifecycleManager(), self.getBuffer(), self.getOwner(), length, self.isReadOnly(), self.getItemSize(), self.getFormat(), self.getFormatString(), self.getDimensions(), self.getBufferPointer(), self.getOffset() + sliceInfo.start * strides[0], newShape, newStrides, suboffsets, flags); } @@ -424,38 +425,38 @@ public abstract static class ToListNode extends PythonUnaryBuiltinNode { @Specialization(guards = {"self.getDimensions() == cachedDimensions", "cachedDimensions < 8"}, limit = "3") Object tolistCached(VirtualFrame frame, PMemoryView self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("self.getDimensions()") int cachedDimensions, @Shared @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (cachedDimensions == 0) { // That's not a list but CPython does it this way return readItemAtNode.execute(frame, self, self.getBufferPointer(), self.getOffset()); } else { - return recursive(frame, self, readItemAtNode, 0, cachedDimensions, self.getBufferPointer(), self.getOffset(), factory); + return recursive(frame, self, readItemAtNode, 0, cachedDimensions, self.getBufferPointer(), self.getOffset(), language); } } @Specialization(replaces = "tolistCached") Object tolist(VirtualFrame frame, PMemoryView self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (self.getDimensions() == 0) { return readItemAtNode.execute(frame, self, self.getBufferPointer(), self.getOffset()); } else { - return recursiveBoundary(frame, self, readItemAtNode, 0, self.getDimensions(), self.getBufferPointer(), self.getOffset(), factory); + return recursiveBoundary(frame, self, readItemAtNode, 0, self.getDimensions(), self.getBufferPointer(), self.getOffset(), language); } } - private PList recursiveBoundary(VirtualFrame frame, PMemoryView self, MemoryViewNodes.ReadItemAtNode readItemAtNode, int dim, int ndim, Object ptr, int offset, PythonObjectFactory factory) { - return recursive(frame, self, readItemAtNode, dim, ndim, ptr, offset, factory); + private PList recursiveBoundary(VirtualFrame frame, PMemoryView self, MemoryViewNodes.ReadItemAtNode readItemAtNode, int dim, int ndim, Object ptr, int offset, PythonLanguage language) { + return recursive(frame, self, readItemAtNode, dim, ndim, ptr, offset, language); } - private PList recursive(VirtualFrame frame, PMemoryView self, MemoryViewNodes.ReadItemAtNode readItemAtNode, int dim, int ndim, Object ptr, int initialOffset, PythonObjectFactory factory) { + private PList recursive(VirtualFrame frame, PMemoryView self, MemoryViewNodes.ReadItemAtNode readItemAtNode, int dim, int ndim, Object ptr, int initialOffset, PythonLanguage language) { int offset = initialOffset; Object[] objects = new Object[self.getBufferShape()[dim]]; for (int i = 0; i < self.getBufferShape()[dim]; i++) { @@ -468,11 +469,11 @@ private PList recursive(VirtualFrame frame, PMemoryView self, MemoryViewNodes.Re if (dim == ndim - 1) { objects[i] = readItemAtNode.execute(frame, self, xptr, xoffset); } else { - objects[i] = recursive(frame, self, readItemAtNode, dim + 1, ndim, xptr, xoffset, factory); + objects[i] = recursive(frame, self, readItemAtNode, dim + 1, ndim, xptr, xoffset, language); } offset += self.getBufferStrides()[dim]; } - return factory.createList(objects); + return PFactory.createList(language, objects); } private CExtNodes.PCallCapiFunction getCallCapiFunction() { @@ -499,8 +500,8 @@ public abstract static class ToBytesNode extends PythonBinaryClinicBuiltinNode { @Specialization PBytes tobytes(PMemoryView self, TruffleString order, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached TruffleString.EqualNode equalNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); byte[] bytes; @@ -512,7 +513,7 @@ PBytes tobytes(PMemoryView self, TruffleString order, } else { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ORDER_MUST_BE_C_F_OR_A); } - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } @Override @@ -584,11 +585,11 @@ public final Object call(VirtualFrame frame, Object arg) { @Specialization static PMemoryView toreadonly(PMemoryView self, + @Bind PythonLanguage language, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); - return factory.createMemoryView(PythonContext.get(inliningTarget), self.getLifecycleManager(), self.getBuffer(), self.getOwner(), self.getLength(), true, + return PFactory.createMemoryView(language, PythonContext.get(inliningTarget), self.getLifecycleManager(), self.getBuffer(), self.getOwner(), self.getLength(), true, self.getItemSize(), self.getFormat(), self.getFormatString(), self.getDimensions(), self.getBufferPointer(), self.getOffset(), self.getBufferShape(), self.getBufferStrides(), self.getBufferSuboffsets(), self.getFlags()); } @@ -604,10 +605,9 @@ static PMemoryView cast(PMemoryView self, TruffleString formatString, @SuppressW @Bind("this") Node inliningTarget, @Shared @Cached TruffleString.CodePointLengthNode lengthNode, @Shared @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); - return doCast(inliningTarget, self, formatString, 1, null, PythonContext.get(inliningTarget), lengthNode, atIndexNode, factory, raiseNode); + return doCast(inliningTarget, self, formatString, 1, null, PythonContext.get(inliningTarget), lengthNode, atIndexNode, raiseNode); } @Specialization(guards = "isPTuple(shapeObj) || isList(shapeObj)") @@ -618,7 +618,6 @@ static PMemoryView cast(VirtualFrame frame, PMemoryView self, TruffleString form @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached TruffleString.CodePointLengthNode lengthNode, @Shared @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, shapeObj); @@ -630,7 +629,7 @@ static PMemoryView cast(VirtualFrame frame, PMemoryView self, TruffleString form throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CAST_ELEMENTS_MUST_BE_POSITIVE_INTEGERS); } } - return doCast(inliningTarget, self, formatString, ndim, shape, PythonContext.get(inliningTarget), lengthNode, atIndexNode, factory, raiseNode); + return doCast(inliningTarget, self, formatString, ndim, shape, PythonContext.get(inliningTarget), lengthNode, atIndexNode, raiseNode); } @Specialization(guards = {"!isPTuple(shape)", "!isList(shape)", "!isPNone(shape)"}) @@ -641,7 +640,7 @@ static PMemoryView error(PMemoryView self, TruffleString format, Object shape, } private static PMemoryView doCast(Node inliningTarget, PMemoryView self, TruffleString formatString, int ndim, int[] shape, PythonContext context, TruffleString.CodePointLengthNode lengthNode, - TruffleString.CodePointAtIndexNode atIndexNode, PythonObjectFactory factory, PRaiseNode.Lazy raiseNode) { + TruffleString.CodePointAtIndexNode atIndexNode, PRaiseNode.Lazy raiseNode) { if (!self.isCContiguous()) { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CASTS_RESTRICTED_TO_C_CONTIGUOUS); } @@ -694,7 +693,7 @@ private static PMemoryView doCast(Node inliningTarget, PMemoryView self, Truffle } newStrides = PMemoryView.initStridesFromShape(ndim, itemsize, shape); } - return factory.createMemoryView(context, self.getLifecycleManager(), self.getBuffer(), self.getOwner(), self.getLength(), self.isReadOnly(), + return PFactory.createMemoryView(PythonLanguage.get(inliningTarget), context, self.getLifecycleManager(), self.getBuffer(), self.getOwner(), self.getLength(), self.isReadOnly(), itemsize, format, formatString, ndim, self.getBufferPointer(), self.getOffset(), newShape, newStrides, null, flags); } @@ -858,14 +857,14 @@ public abstract static class ShapeNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PMemoryView self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferShape() == null)) { - return factory.createEmptyTuple(); + return PFactory.createEmptyTuple(language); } - return factory.createTuple(new IntSequenceStorage(self.getBufferShape())); + return PFactory.createTuple(language, new IntSequenceStorage(self.getBufferShape())); } } @@ -876,14 +875,14 @@ public abstract static class StridesNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PMemoryView self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferStrides() == null)) { - return factory.createEmptyTuple(); + return PFactory.createEmptyTuple(language); } - return factory.createTuple(new IntSequenceStorage(self.getBufferStrides())); + return PFactory.createTuple(language, new IntSequenceStorage(self.getBufferStrides())); } } @@ -894,14 +893,14 @@ public abstract static class SuboffsetsNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PMemoryView self, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferSuboffsets() == null)) { - return factory.createEmptyTuple(); + return PFactory.createEmptyTuple(language); } - return factory.createTuple(new IntSequenceStorage(self.getBufferSuboffsets())); + return PFactory.createTuple(language, new IntSequenceStorage(self.getBufferSuboffsets())); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java index ab1ae548c8..c7405fdaa4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java @@ -76,7 +76,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; @@ -403,11 +403,11 @@ PTuple doSelfIsObject(VirtualFrame frame, PMethod method, @SuppressWarnings("unu @Shared("toStringNode") @Cached CastToTruffleStringNode toStringNode, @Shared("getGetAttr") @Cached PyObjectGetAttr getGetAttr, @Shared("getName") @Cached PyObjectGetAttr getName, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = getContext().getBuiltins(); Object getattr = getGetAttr.execute(frame, inliningTarget, builtins, T_GETATTR); - PTuple args = factory.createTuple(new Object[]{method.getSelf(), getName(frame, inliningTarget, method.getFunction(), toStringNode, getName)}); - return factory.createTuple(new Object[]{getattr, args}); + PTuple args = PFactory.createTuple(language, new Object[]{method.getSelf(), getName(frame, inliningTarget, method.getFunction(), toStringNode, getName)}); + return PFactory.createTuple(language, new Object[]{getattr, args}); } @Specialization(guards = "!isSelfModuleOrNull(method)") @@ -416,11 +416,11 @@ PTuple doSelfIsObject(VirtualFrame frame, PBuiltinMethod method, @SuppressWarnin @Shared("toStringNode") @Cached CastToTruffleStringNode toStringNode, @Shared("getGetAttr") @Cached PyObjectGetAttr getGetAttr, @Shared("getName") @Cached PyObjectGetAttr getName, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = getContext().getBuiltins(); Object getattr = getGetAttr.execute(frame, inliningTarget, builtins, T_GETATTR); - PTuple args = factory.createTuple(new Object[]{method.getSelf(), getName(frame, inliningTarget, method.getFunction(), toStringNode, getName)}); - return factory.createTuple(new Object[]{getattr, args}); + PTuple args = PFactory.createTuple(language, new Object[]{method.getSelf(), getName(frame, inliningTarget, method.getFunction(), toStringNode, getName)}); + return PFactory.createTuple(language, new Object[]{getattr, args}); } private static TruffleString getName(VirtualFrame frame, Node inliningTarget, Object func, CastToTruffleStringNode toStringNode, PyObjectGetAttr getName) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java index 9534170b94..ec4bf97bfe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -67,7 +68,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -167,26 +168,26 @@ abstract static class MakeMethodNode extends PNodeWithContext { @Specialization Object method(Object self, PFunction func, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createMethod(self, func); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); } @Specialization(guards = "!func.needsDeclaringType()") Object methodBuiltin(Object self, PBuiltinFunction func, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createBuiltinMethod(self, func); + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, self, func); } @Specialization(guards = "func.needsDeclaringType()") Object methodBuiltinWithDeclaringType(Object self, PBuiltinFunction func, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createBuiltinMethod(self, func, func.getEnclosingType()); + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, self, func, func.getEnclosingType()); } @Specialization(guards = "!isFunction(func)") Object generic(Object self, Object func, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createMethod(self, func); + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java index 77e7d15380..f74d62eb88 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -52,6 +52,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -77,7 +78,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -183,12 +184,11 @@ public abstract static class GetNode extends DescrGetBuiltinNode { @Specialization static Object doGeneric(PDecoratedMethod self, Object obj, @SuppressWarnings("unused") Object cls, @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile objIsNoneProfile, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile objIsNoneProfile) { if (objIsNoneProfile.profile(inliningTarget, obj == PNone.NO_VALUE)) { return self.getCallable(); } - return factory.createMethod(obj, self.getCallable()); + return PFactory.createMethod(PythonLanguage.get(inliningTarget), obj, self.getCallable()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java index 23b8f10f15..d3e2e1786a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -40,6 +40,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -69,7 +70,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -190,11 +191,10 @@ public abstract static class GetMethodDefaultsNode extends PythonUnaryBuiltinNod @Specialization static Object defaults(PMethod self, @Bind("this") Node inliningTarget, - @Cached GetDefaultsNode getDefaultsNode, - @Cached PythonObjectFactory.Lazy factory) { + @Cached GetDefaultsNode getDefaultsNode) { Object[] argDefaults = getDefaultsNode.execute(inliningTarget, self); assert argDefaults != null; - return (argDefaults.length == 0) ? PNone.NONE : factory.get(inliningTarget).createTuple(argDefaults); + return (argDefaults.length == 0) ? PNone.NONE : PFactory.createTuple(PythonLanguage.get(inliningTarget), argDefaults); } } @@ -204,10 +204,9 @@ public abstract static class GetMethodKwdefaultsNode extends PythonUnaryBuiltinN @Specialization static Object kwDefaults(PMethod self, @Bind("this") Node inliningTarget, - @Cached GetKeywordDefaultsNode getKeywordDefaultsNode, - @Cached PythonObjectFactory.Lazy factory) { + @Cached GetKeywordDefaultsNode getKeywordDefaultsNode) { PKeyword[] kwdefaults = getKeywordDefaultsNode.execute(inliningTarget, self); - return (kwdefaults.length > 0) ? factory.get(inliningTarget).createDict(kwdefaults) : PNone.NONE; + return (kwdefaults.length > 0) ? PFactory.createDict(PythonLanguage.get(inliningTarget), kwdefaults) : PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/PDecoratedMethod.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/PDecoratedMethod.java index e4462ae95b..c132d51694 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/PDecoratedMethod.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/PDecoratedMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -40,12 +40,13 @@ */ package com.oracle.graal.python.builtins.objects.method; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.BoundBuiltinCallable; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.object.Shape; @@ -74,14 +75,14 @@ public void setCallable(Object callable) { } @SuppressWarnings("unchecked") - public Object boundToObject(PythonBuiltinClassType binding, PythonObjectFactory factory) { + public Object boundToObject(PythonBuiltinClassType binding, PythonLanguage language) { if (GetPythonObjectClassNode.executeUncached(this) != PythonBuiltinClassType.PStaticmethod) { if (callable instanceof BoundBuiltinCallable) { - return factory.createBuiltinClassmethodFromCallableObj(((BoundBuiltinCallable) callable).boundToObject(binding, factory)); + return PFactory.createBuiltinClassmethodFromCallableObj(language, ((BoundBuiltinCallable) callable).boundToObject(binding, language)); } } else { if (callable instanceof PBuiltinMethod) { - return factory.createStaticmethodFromCallableObj(((PBuiltinMethod) callable).getBuiltinFunction().boundToObject(binding, factory)); + return PFactory.createStaticmethodFromCallableObj(language, ((PBuiltinMethod) callable).getBuiltinFunction().boundToObject(binding, language)); } } return this; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java index 671bf48097..6e54ed2e2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java @@ -121,7 +121,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; @@ -172,17 +172,17 @@ public abstract static class MMapSqItemNode extends SqItemBuiltinNode { @Specialization static PBytes doInt(VirtualFrame frame, PMMap self, int index, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached PRaiseNode.Lazy raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, - @Cached PythonObjectFactory factory) { + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib) { long len = self.getLength(); checkBounds(inliningTarget, raiseNode, MMAP_INDEX_OUT_OF_RANGE, index, len); try { - byte b = posixSupportLib.mmapReadByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), index); + byte b = posixSupportLib.mmapReadByte(context.getPosixSupport(), self.getPosixSupportHandle(), index); // CPython indeed returns bytes object from sq_item, although it returns single byte // value as integer from mp_subscript, see, e.g.: `for i in mmap_object: print(i)` - return factory.createBytes(new byte[]{b}); + return PFactory.createBytes(context.getLanguage(inliningTarget), new byte[]{b}); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -196,8 +196,9 @@ public abstract static class GetItemNode extends MpSubscriptBuiltinNode { @Specialization(guards = "!isPSlice(idxObj)") static int doSingle(VirtualFrame frame, PMMap self, Object idxObj, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Exclusive @Cached InlinedConditionProfile negativeIndexProfile, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Cached PyLongAsLongNode asLongNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { @@ -206,7 +207,7 @@ static int doSingle(VirtualFrame frame, PMMap self, Object idxObj, long idx = negativeIndexProfile.profile(inliningTarget, i < 0) ? i + len : i; checkBounds(inliningTarget, raiseNode, MMAP_INDEX_OUT_OF_RANGE, idx, len); try { - return posixSupportLib.mmapReadByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), idx) & 0xFF; + return posixSupportLib.mmapReadByte(context.getPosixSupport(), self.getPosixSupportHandle(), idx) & 0xFF; } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -215,22 +216,22 @@ static int doSingle(VirtualFrame frame, PMMap self, Object idxObj, @Specialization static Object doSlice(VirtualFrame frame, PMMap self, PSlice idx, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Exclusive @Cached InlinedConditionProfile emptyProfile, @Cached CoerceToIntSlice sliceCast, @Cached ComputeIndices compute, @Cached LenOfRangeNode sliceLenNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { try { SliceInfo info = compute.execute(frame, sliceCast.execute(inliningTarget, idx), PInt.intValueExact(self.getLength())); int len = sliceLenNode.len(inliningTarget, info); if (emptyProfile.profile(inliningTarget, len == 0)) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(context.getLanguage(inliningTarget)); } - byte[] result = readBytes(frame, inliningTarget, self, posixSupportLib, PosixSupport.get(inliningTarget), info.start, len, constructAndRaiseNode); - return factory.createBytes(result); + byte[] result = readBytes(frame, inliningTarget, self, posixSupportLib, context.getPosixSupport(), info.start, len, constructAndRaiseNode); + return PFactory.createBytes(context.getLanguage(inliningTarget), result); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, e); } @@ -244,7 +245,8 @@ public abstract static class SetItemNode extends SqAssItemBuiltinNode { @Specialization static void doSingle(VirtualFrame frame, PMMap self, int index, Object val, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached PyBytesCheckNode checkNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @@ -270,7 +272,7 @@ static void doSingle(VirtualFrame frame, PMMap self, int index, Object val, } byte b = bufferLib.readByte(val, 0); try { - posixSupportLib.mmapWriteByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), idx, b); + posixSupportLib.mmapWriteByte(context.getPosixSupport(), self.getPosixSupportHandle(), idx, b); } catch (PosixException ex) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, ex); } @@ -284,7 +286,8 @@ public abstract static class SetSubscriptNode extends MpAssSubscriptBuiltinNode @Specialization(guards = "!isPSlice(idxObj)") static void doSingle(VirtualFrame frame, PMMap self, Object idxObj, Object valueObj, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Cached PyIndexCheckNode checkNode, @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @@ -317,7 +320,7 @@ static void doSingle(VirtualFrame frame, PMMap self, Object idxObj, Object value throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, MMAP_ITEM_VALUE_MUST_BE_IN_RANGE); } try { - posixSupportLib.mmapWriteByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), idx, (byte) value); + posixSupportLib.mmapWriteByte(context.getPosixSupport(), self.getPosixSupportHandle(), idx, (byte) value); } catch (PosixException ex) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, ex); } @@ -326,7 +329,8 @@ static void doSingle(VirtualFrame frame, PMMap self, Object idxObj, Object value @Specialization static void doSlice(VirtualFrame frame, PMMap self, PSlice slice, Object valueObj, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached SliceNodes.SliceUnpack sliceUnpack, @@ -359,11 +363,11 @@ static void doSlice(VirtualFrame frame, PMMap self, PSlice slice, Object valueOb if (info.sliceLength > 0) { try { if (step1Profile.profile(inliningTarget, info.step == 1)) { - posixSupportLib.mmapWriteBytes(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), + posixSupportLib.mmapWriteBytes(context.getPosixSupport(), self.getPosixSupportHandle(), info.start, bufferLib.getInternalOrCopiedByteArray(buffer), bufferLen); } else { for (int cur = info.start, i = 0; i < info.sliceLength; cur += info.step, i++) { - posixSupportLib.mmapWriteByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), cur, bufferLib.readByte(buffer, i)); + posixSupportLib.mmapWriteByte(context.getPosixSupport(), self.getPosixSupportHandle(), cur, bufferLib.readByte(buffer, i)); } } } catch (PosixException ex) { @@ -415,9 +419,10 @@ static Object size(VirtualFrame frame, PMMap self, @SuppressWarnings("unused") O abstract static class CloseNode extends PythonUnaryBuiltinNode { @Specialization - PNone close(PMMap self, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib) { - self.close(posixSupportLib, getPosixSupport()); + static PNone close(PMMap self, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib) { + self.close(posixSupportLib, context.getPosixSupport()); return PNone.NONE; } } @@ -472,14 +477,15 @@ abstract static class ReadByteNode extends PythonUnaryBuiltinNode { @Specialization static int readByte(VirtualFrame frame, PMMap self, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupportLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { if (self.getPos() >= self.getLength()) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, READ_BYTE_OUT_OF_RANGE); } try { - byte res = posixSupportLib.mmapReadByte(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), self.getPos()); + byte res = posixSupportLib.mmapReadByte(context.getPosixSupport(), self.getPosixSupportHandle(), self.getPos()); self.setPos(self.getPos() + 1); return res & 0xFF; } catch (PosixException e) { @@ -496,14 +502,14 @@ abstract static class ReadNode extends PythonBuiltinNode { @Specialization static PBytes read(VirtualFrame frame, PMMap self, Object n, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached InlinedConditionProfile noneProfile, @Cached InlinedConditionProfile emptyProfile, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, @Cached InlinedConditionProfile negativeProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { long nread; // intentionally accept NO_VALUE and NONE; both mean that we read unlimited # of bytes @@ -523,12 +529,12 @@ static PBytes read(VirtualFrame frame, PMMap self, Object n, } } if (emptyProfile.profile(inliningTarget, nread == 0)) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(context.getLanguage(inliningTarget)); } try { - byte[] buffer = MMapBuiltins.readBytes(frame, inliningTarget, self, posixLib, PosixSupport.get(inliningTarget), self.getPos(), PythonUtils.toIntExact(nread), constructAndRaiseNode); + byte[] buffer = MMapBuiltins.readBytes(frame, inliningTarget, self, posixLib, context.getPosixSupport(), self.getPos(), PythonUtils.toIntExact(nread), constructAndRaiseNode); self.setPos(self.getPos() + buffer.length); - return factory.createBytes(buffer); + return PFactory.createBytes(context.getLanguage(inliningTarget), buffer); } catch (OverflowException e) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, ErrorMessages.TOO_MANY_REMAINING_BYTES_TO_BE_STORED); } @@ -541,12 +547,12 @@ abstract static class ReadlineNode extends PythonUnaryBuiltinNode { private static final int BUFFER_SIZE = 1024; @Specialization - Object readline(VirtualFrame frame, PMMap self, + static Object readline(VirtualFrame frame, PMMap self, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SequenceStorageNodes.AppendNode appendNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { // Posix abstraction is leaking here a bit: with read mmapped memory, we'd just read // byte by byte, but that would be very inefficient with emulated mmap, so we use a // small buffer @@ -555,7 +561,7 @@ Object readline(VirtualFrame frame, PMMap self, int nread; outer: while (self.getPos() < self.getLength()) { try { - nread = posixLib.mmapReadBytes(getPosixSupport(), self.getPosixSupportHandle(), self.getPos(), buffer, (int) Math.min(self.getRemaining(), buffer.length)); + nread = posixLib.mmapReadBytes(context.getPosixSupport(), self.getPosixSupportHandle(), self.getPos(), buffer, (int) Math.min(self.getRemaining(), buffer.length)); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -569,7 +575,7 @@ Object readline(VirtualFrame frame, PMMap self, } self.setPos(self.getPos() + nread); } - return factory.createBytes(res); + return PFactory.createBytes(context.getLanguage(inliningTarget), res); } } @@ -586,9 +592,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static int doIt(VirtualFrame frame, PMMap self, Object dataBuffer, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("dataBuffer") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { try { @@ -600,7 +607,7 @@ static int doIt(VirtualFrame frame, PMMap self, Object dataBuffer, if (self.getPos() > self.getLength() || self.getLength() - self.getPos() < dataLen) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.DATA_OUT_OF_RANGE); } - posixLib.mmapWriteBytes(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), self.getPos(), dataBytes, dataLen); + posixLib.mmapWriteBytes(context.getPosixSupport(), self.getPosixSupportHandle(), self.getPos(), dataBytes, dataLen); self.setPos(self.getPos() + dataLen); return dataLen; } catch (PosixException e) { @@ -615,7 +622,6 @@ static int doIt(VirtualFrame frame, PMMap self, Object dataBuffer, @ArgumentClinic(name = "dist", conversion = ClinicConversion.LongIndex) @ArgumentClinic(name = "how", conversion = ClinicConversion.Int) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class SeekNode extends PythonTernaryClinicBuiltinNode { @Override protected ArgumentClinicProvider getArgumentClinic() { @@ -665,11 +671,12 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startIn, Object endIn, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("subBuffer") PythonBufferAccessLibrary bufferLib, @Cached LongIndexConverterNode startConverter, @Cached LongIndexConverterNode endConverter, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { try { @@ -690,7 +697,7 @@ static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startI byte[] firstBuffer = new byte[bufferSize]; byte[] secondBuffer = new byte[bufferSize]; - readBytes(frame, inliningTarget, self, posixLib, start, secondBuffer, constructAndRaiseNode, raiseNode); + readBytes(frame, inliningTarget, self, posixLib, context.getPosixSupport(), start, secondBuffer, constructAndRaiseNode, raiseNode); for (long selfIdx = start; selfIdx <= end - subLen; selfIdx++, buffersIndex++) { // Make sure that the buffers have enough room for the search if (buffersIndex + subLen > bufferSize * 2) { @@ -699,7 +706,7 @@ static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startI secondBuffer = tmp; buffersIndex -= bufferSize; // move to the tail of the first buffer now long readIndex = selfIdx + subLen - 1; - readBytes(frame, inliningTarget, self, posixLib, readIndex, secondBuffer, constructAndRaiseNode, raiseNode); + readBytes(frame, inliningTarget, self, posixLib, context.getPosixSupport(), readIndex, secondBuffer, constructAndRaiseNode, raiseNode); // It's OK if we read less than buffer size, the outer loop condition // 'selfIdx <= end' and the check in readBytes should cover that we don't // read @@ -729,12 +736,12 @@ static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startI } } - private static void readBytes(VirtualFrame frame, Node inliningTarget, PMMap self, PosixSupportLibrary posixLib, long index, byte[] buffer, PConstructAndRaiseNode.Lazy constructAndRaiseNode, - PRaiseNode.Lazy raiseNode) { + private static void readBytes(VirtualFrame frame, Node inliningTarget, PMMap self, PosixSupportLibrary posixLib, PosixSupport posixSupport, long index, byte[] buffer, + PConstructAndRaiseNode.Lazy constructAndRaiseNode, PRaiseNode.Lazy raiseNode) { try { long remaining = self.getLength() - index; int toReadLen = remaining > buffer.length ? buffer.length : (int) remaining; - int nread = posixLib.mmapReadBytes(PosixSupport.get(inliningTarget), self.getPosixSupportHandle(), index, buffer, toReadLen); + int nread = posixLib.mmapReadBytes(posixSupport, self.getPosixSupportHandle(), index, buffer, toReadLen); if (toReadLen != nread) { throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, MMAP_CHANGED_LENGTH); } @@ -771,10 +778,11 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Specialization - Object flush(VirtualFrame frame, PMMap self, long offset, Object sizeObj, + static Object flush(VirtualFrame frame, PMMap self, long offset, Object sizeObj, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached LongIndexConverterNode sizeConversion, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { long size; @@ -792,7 +800,7 @@ Object flush(VirtualFrame frame, PMMap self, long offset, Object sizeObj, } try { - posixLib.mmapFlush(getPosixSupport(), self.getPosixSupportHandle(), offset, self.getLength()); + posixLib.mmapFlush(context.getPosixSupport(), self.getPosixSupportHandle(), offset, self.getLength()); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java index afd41e31b0..a6042bd83a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java @@ -60,6 +60,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -97,7 +98,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -110,6 +111,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -192,11 +194,10 @@ public abstract static class ModuleDictNode extends PythonBinaryBuiltinNode { static Object doManaged(PythonModule self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Exclusive @Cached GetDictIfExistsNode getDict, - @Cached SetDictNode setDict, - @Cached PythonObjectFactory factory) { + @Cached SetDictNode setDict) { PDict dict = getDict.execute(self); if (dict == null) { - dict = createDict(inliningTarget, self, setDict, factory); + dict = createDict(inliningTarget, self, setDict); } return dict; } @@ -219,8 +220,8 @@ static Object doError(Object self, @SuppressWarnings("unused") Object dict, throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.DESCRIPTOR_DICT_FOR_MOD_OBJ_DOES_NOT_APPLY_FOR_P, self); } - private static PDict createDict(Node inliningTarget, PythonModule self, SetDictNode setDict, PythonObjectFactory factory) { - PDict dict = factory.createDictFixedStorage(self); + private static PDict createDict(Node inliningTarget, PythonModule self, SetDictNode setDict) { + PDict dict = PFactory.createDictFixedStorage(PythonLanguage.get(inliningTarget), self); setDict.execute(inliningTarget, self, dict); return dict; } @@ -314,10 +315,11 @@ static Object get(Object self, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, @Shared("read") @Cached ReadAttributeFromObjectNode read, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Cached PythonObjectFactory.Lazy factory) { + @Cached InlinedBranchProfile createAnnotations) { Object annotations = read.execute(self, T___ANNOTATIONS__); if (annotations == PNone.NO_VALUE) { - annotations = factory.get(inliningTarget).createDict(); + createAnnotations.enter(inliningTarget); + annotations = PFactory.createDict(PythonLanguage.get(inliningTarget)); write.execute(self, T___ANNOTATIONS__, annotations); } return annotations; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonModule.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonModule.java index e080f455ea..ba26300675 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonModule.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -41,7 +41,7 @@ import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.object.SetDictNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.strings.TruffleString; @@ -109,9 +109,9 @@ private PythonModule(PythonLanguage lang, TruffleString moduleName) { */ @TruffleBoundary public static PythonModule createInternal(TruffleString moduleName) { - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - PythonModule pythonModule = new PythonModule(PythonLanguage.get(null), moduleName); - PDict dict = factory.createDictFixedStorage(pythonModule); + PythonLanguage language = PythonLanguage.get(null); + PythonModule pythonModule = new PythonModule(language, moduleName); + PDict dict = PFactory.createDictFixedStorage(language, pythonModule); SetDictNode.executeUncached(pythonModule, dict); return pythonModule; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java index 8a2222ac7c..ee95c8cd17 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -58,9 +58,9 @@ import java.util.Comparator; import java.util.List; -import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; import org.graalvm.collections.Pair; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -82,6 +82,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -94,7 +95,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -169,10 +170,10 @@ static Object reduce(PSimpleNamespace self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached GetOrCreateDictNode getDict, - @Cached PythonObjectFactory factory) { - PTuple args = factory.createEmptyTuple(); + @Bind PythonLanguage language) { + PTuple args = PFactory.createEmptyTuple(language); final PDict dict = getDict.execute(inliningTarget, self); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args, dict}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args, dict}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java index 373ce219f3..b57d9668a9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java @@ -64,6 +64,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.annotations.Slot; @@ -142,7 +143,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.nodes.util.SplitArgsNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -815,8 +816,8 @@ static Object dir(VirtualFrame frame, Object obj, @Cached GetClassNode getClassNode, @Cached IsSubtypeNode isSubtypeNode, @Cached com.oracle.graal.python.builtins.objects.type.TypeBuiltins.DirNode dirNode, - @Cached PythonObjectFactory factory) { - PSet names = factory.createSet(); + @Bind PythonLanguage language) { + PSet names = PFactory.createSet(language); Object updateCallable = lookupAttrNode.execute(frame, inliningTarget, names, T_UPDATE); Object ns = lookupAttrNode.execute(frame, inliningTarget, obj, T___DICT__); if (isSubtypeNode.execute(frame, getClassNode.execute(inliningTarget, ns), PythonBuiltinClassType.PDict)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java index 8d29113d7c..8e9de09698 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -140,7 +140,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.IDUtils; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -329,8 +329,8 @@ static Object id(boolean self, @Specialization static Object id(double self, - @Shared @Cached PythonObjectFactory factory) { - return IDUtils.getId(self, factory); + @Bind PythonLanguage language) { + return IDUtils.getId(language, self); } @Specialization @@ -342,8 +342,8 @@ static Object id(PFloat self, @Specialization static Object id(long self, - @Shared @Cached PythonObjectFactory factory) { - return IDUtils.getId(self, factory); + @Bind PythonLanguage language) { + return IDUtils.getId(language, self); } @Specialization @@ -556,7 +556,6 @@ static Object getstate(VirtualFrame frame, Node inliningTarget, Object obj, bool @Cached PyObjectLookupAttrO lookupAttr, @Cached HashingStorageSetItem setHashingStorageItem, @Cached CheckBasesizeForGetState checkBasesize, - @Cached PythonObjectFactory.Lazy factory, @Cached PRaiseNode.Lazy raiseNode) { Object state; Object type = getClassNode.execute(inliningTarget, obj); @@ -592,8 +591,9 @@ static Object getstate(VirtualFrame frame, Node inliningTarget, Object obj, bool * If we found some slot attributes, pack them in a tuple along the original * attribute dictionary. */ - PDict slotsState = factory.get(inliningTarget).createDict(slotsStorage); - state = factory.get(inliningTarget).createTuple(new Object[]{state, slotsState}); + PythonLanguage language = PythonLanguage.get(inliningTarget); + PDict slotsState = PFactory.createDict(language, slotsStorage); + state = PFactory.createTuple(language, new Object[]{state, slotsState}); } } @@ -675,7 +675,7 @@ static Object reduceNewObj(VirtualFrame frame, Node inliningTarget, Object obj, @Cached PyObjectSizeNode sizeNode, @Exclusive @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectGetIter getIter, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object cls = getClassNode.execute(inliningTarget, obj); if (lookupNew.execute(cls) == PNone.NO_VALUE) { @@ -703,10 +703,10 @@ static Object reduceNewObj(VirtualFrame frame, Node inliningTarget, Object obj, } else { newargsVals = new Object[]{cls}; } - newargs = factory.createTuple(newargsVals); + newargs = PFactory.createTuple(language, newargsVals); } else if (hasArgsProfile.profile(inliningTarget, hasargs)) { newobj = lookupAttr.execute(frame, inliningTarget, copyReg, T___NEWOBJ_EX__); - newargs = factory.createTuple(new Object[]{cls, args, kwargs}); + newargs = PFactory.createTuple(language, new Object[]{cls, args, kwargs}); } else { throw raiseNode.get(inliningTarget).raiseBadInternalCall(); } @@ -719,7 +719,7 @@ static Object reduceNewObj(VirtualFrame frame, Node inliningTarget, Object obj, Object listitems = objIsList ? getIter.execute(frame, inliningTarget, obj) : PNone.NONE; Object dictitems = objIsDict ? getIter.execute(frame, inliningTarget, callMethod.execute(frame, inliningTarget, obj, T_ITEMS)) : PNone.NONE; - return factory.createTuple(new Object[]{newobj, newargs, state, listitems, dictitems}); + return PFactory.createTuple(language, new Object[]{newobj, newargs, state, listitems, dictitems}); } @Specialization(guards = "proto < 2") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java index 3e04f31442..95fe5354c5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java @@ -64,6 +64,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -109,7 +110,7 @@ import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -292,14 +293,14 @@ static Object reduce(VirtualFrame frame, POrderedDict self, @Cached PyObjectGetStateNode getStateNode, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectGetIter getIter, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object type = getClassNode.execute(inliningTarget, self); Object state = getStateNode.execute(frame, inliningTarget, self); - Object args = factory.createEmptyTuple(); + Object args = PFactory.createEmptyTuple(language); // Might be overridden Object items = callMethod.execute(frame, inliningTarget, self, T_ITEMS); Object itemsIter = getIter.execute(frame, inliningTarget, items); - return factory.createTuple(new Object[]{type, args, state, PNone.NONE, itemsIter}); + return PFactory.createTuple(language, new Object[]{type, args, state, PNone.NONE, itemsIter}); } } @@ -360,7 +361,7 @@ static Object popitem(VirtualFrame frame, POrderedDict self, boolean last, @Bind("this") Node inliningTarget, @Cached HashingStorageNodes.HashingStorageDelItem delItem, @Cached ObjectHashMap.RemoveNode removeNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raise) { ODictNode node = last ? self.last : self.first; if (node == null) { @@ -370,7 +371,7 @@ static Object popitem(VirtualFrame frame, POrderedDict self, boolean last, removeNode.execute(frame, inliningTarget, self.nodes, node.key, node.hash); // TODO with hash Object value = delItem.executePop(frame, inliningTarget, self.getDictStorage(), node.key, self); - return factory.createTuple(new Object[]{node.key, value}); + return PFactory.createTuple(language, new Object[]{node.key, value}); } @Override @@ -453,8 +454,8 @@ protected ArgumentClinicProvider getArgumentClinic() { abstract static class KeysNode extends PythonUnaryBuiltinNode { @Specialization static Object keys(POrderedDict self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictKeys(self); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictKeys(language, self); } } @@ -463,8 +464,8 @@ static Object keys(POrderedDict self, abstract static class ValuesNode extends PythonUnaryBuiltinNode { @Specialization static Object values(POrderedDict self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictValues(self); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictValues(language, self); } } @@ -473,8 +474,8 @@ static Object values(POrderedDict self, abstract static class ItemsNode extends PythonUnaryBuiltinNode { @Specialization static Object items(POrderedDict self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictItems(self); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictItems(language, self); } } @@ -483,8 +484,8 @@ static Object items(POrderedDict self, abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(POrderedDict self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator(self, POrderedDictIterator.IteratorType.KEYS, false); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, self, POrderedDictIterator.IteratorType.KEYS, false); } } @@ -493,8 +494,8 @@ static Object iter(POrderedDict self, abstract static class ReversedNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(POrderedDict self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator(self, POrderedDictIterator.IteratorType.KEYS, true); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, self, POrderedDictIterator.IteratorType.KEYS, true); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java index e789b2024d..d54a72325c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -52,8 +53,8 @@ import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemsView; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -70,8 +71,8 @@ protected List> getNodeFa abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictItemsView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.ITEMS, false); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.ITEMS, false); } } @@ -80,8 +81,8 @@ static Object iter(PDictItemsView self, abstract static class ReversedNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictItemsView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.ITEMS, true); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.ITEMS, true); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java index 0ea2b63941..97e798523a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -64,7 +65,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -96,8 +97,7 @@ abstract static class NextNode extends PythonUnaryBuiltinNode { static Object next(VirtualFrame frame, POrderedDictIterator self, @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode, - @Cached HashingStorageNodes.HashingStorageGetItemWithHash getItem, - @Cached PythonObjectFactory factory) { + @Cached HashingStorageNodes.HashingStorageGetItemWithHash getItem) { if (self.current == null) { throw raiseNode.raise(StopIteration); } @@ -116,7 +116,7 @@ static Object next(VirtualFrame frame, POrderedDictIterator self, if (self.type == POrderedDictIterator.IteratorType.VALUES) { result = value; } else { - result = factory.createTuple(new Object[]{key, value}); + result = PFactory.createTuple(PythonLanguage.get(inliningTarget), new Object[]{key, value}); } } if (!self.reversed) { @@ -135,16 +135,16 @@ abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(VirtualFrame frame, POrderedDictIterator self, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttr, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached ListNodes.ConstructListNode constructListNode) { PythonContext context = PythonContext.get(inliningTarget); Object iterBuiltin = getAttr.execute(frame, inliningTarget, context.getBuiltins(), T_ITER); - POrderedDictIterator copy = factory.createOrderedDictIterator(self.dict, self.type, self.reversed); + POrderedDictIterator copy = PFactory.createOrderedDictIterator(language, self.dict, self.type, self.reversed); copy.current = self.current; /* iterate the temporary into a list */ PList list = constructListNode.execute(frame, copy); - PTuple args = factory.createTuple(new Object[]{list}); - return factory.createTuple(new Object[]{iterBuiltin, args}); + PTuple args = PFactory.createTuple(language, new Object[]{list}); + return PFactory.createTuple(language, new Object[]{iterBuiltin, args}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java index b394891511..0863121e61 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -52,8 +53,8 @@ import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeysView; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -70,8 +71,8 @@ protected List> getNodeFa abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictKeysView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.KEYS, false); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.KEYS, false); } } @@ -80,8 +81,8 @@ static Object iter(PDictKeysView self, abstract static class ReversedNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictKeysView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.KEYS, true); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.KEYS, true); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java index 66b74ea5b8..0d362211a6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -52,8 +53,8 @@ import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValuesView; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -70,8 +71,8 @@ protected List> getNodeFa abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictValuesView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.VALUES, false); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.VALUES, false); } } @@ -80,8 +81,8 @@ static Object iter(PDictValuesView self, abstract static class ReversedNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PDictValuesView self, - @Cached PythonObjectFactory factory) { - return factory.createOrderedDictIterator((POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.VALUES, true); + @Bind PythonLanguage language) { + return PFactory.createOrderedDictIterator(language, (POrderedDict) self.getWrappedDict(), POrderedDictIterator.IteratorType.VALUES, true); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java index a82890023e..cff17ec06d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java @@ -56,6 +56,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -80,7 +81,8 @@ import com.oracle.graal.python.runtime.PosixSupport; import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -108,17 +110,17 @@ protected List> getNodeFa @GenerateNodeFactory abstract static class NameNode extends PythonUnaryBuiltinNode { @Specialization - Object nameAsBytes(VirtualFrame frame, PDirEntry self, + static Object nameAsBytes(VirtualFrame frame, PDirEntry self, @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile produceBytesProfile, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { if (produceBytesProfile.profile(inliningTarget, self.produceBytes())) { - return opaquePathToBytes(posixLib.dirEntryGetName(getPosixSupport(), self.dirEntryData), posixLib, getPosixSupport(), factory); + return opaquePathToBytes(posixLib.dirEntryGetName(context.getPosixSupport(), self.dirEntryData), posixLib, context.getPosixSupport(), context.getLanguage(inliningTarget)); } else { - return posixLib.getPathAsString(getPosixSupport(), posixLib.dirEntryGetName(getPosixSupport(), self.dirEntryData)); + return posixLib.getPathAsString(context.getPosixSupport(), posixLib.dirEntryGetName(context.getPosixSupport(), self.dirEntryData)); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); @@ -153,25 +155,25 @@ static PosixPath cached(PDirEntry self) { @Specialization(guards = "self.pathCache == null") static PosixPath createBytes(VirtualFrame frame, Node inliningTarget, PDirEntry self, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile produceBytesProfile, @Cached InlinedConditionProfile posixPathProfile, - @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, - @Cached PythonObjectFactory.Lazy factory, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Object opaquePath; try { if (posixPathProfile.profile(inliningTarget, self.scandirPath instanceof PosixPath)) { - opaquePath = posixLib.dirEntryGetPath(PosixSupport.get(inliningTarget), self.dirEntryData, ((PosixPath) self.scandirPath).value); + opaquePath = posixLib.dirEntryGetPath(context.getPosixSupport(), self.dirEntryData, ((PosixPath) self.scandirPath).value); } else { - opaquePath = posixLib.dirEntryGetName(PosixSupport.get(inliningTarget), self.dirEntryData); + opaquePath = posixLib.dirEntryGetName(context.getPosixSupport(), self.dirEntryData); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } if (produceBytesProfile.profile(inliningTarget, self.produceBytes())) { - self.pathCache = new PosixPath(opaquePathToBytes(opaquePath, posixLib, PosixSupport.get(inliningTarget), factory.get(inliningTarget)), opaquePath, true); + self.pathCache = new PosixPath(opaquePathToBytes(opaquePath, posixLib, context.getPosixSupport(), context.getLanguage(inliningTarget)), opaquePath, true); } else { - self.pathCache = new PosixPath(posixLib.getPathAsString(PosixSupport.get(inliningTarget), opaquePath), opaquePath, false); + self.pathCache = new PosixPath(posixLib.getPathAsString(context.getPosixSupport(), opaquePath), opaquePath, false); } return self.pathCache; } @@ -252,32 +254,32 @@ static PTuple cachedLStat(PDirEntry self, boolean followSymlinks, boolean catchN @Specialization(guards = {"followSymlinks", "self.statCache == null", "isSymlink"}, limit = "1") static PTuple uncachedStatWithSymlink(VirtualFrame frame, PDirEntry self, boolean followSymlinks, boolean catchNoent, @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @SuppressWarnings("unused") @Cached IsSymlinkNode isSymlinkNode, @SuppressWarnings("unused") @Bind("isSymlinkNode.executeBoolean(frame, self)") boolean isSymlink, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, @Shared("cachedPosixPathNode") @Cached CachedPosixPathNode cachedPosixPathNode, @Shared("positiveLongProfile") @Cached InlinedConditionProfile positiveLongProfile, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { // There are two caches - one for `follow_symlinks=True` and the other for // 'follow_symlinks=False`. They are different only when the dir entry is a symlink. - return uncachedLStatWithSymlink(frame, self, followSymlinks, catchNoent, inliningTarget, posixLib, cachedPosixPathNode, positiveLongProfile, constructAndRaiseNode, factory); + return uncachedLStatWithSymlink(frame, self, followSymlinks, catchNoent, inliningTarget, context, posixLib, cachedPosixPathNode, positiveLongProfile, constructAndRaiseNode); } @Specialization(guards = {"!followSymlinks", "self.lstatCache == null"}) static PTuple uncachedLStatWithSymlink(VirtualFrame frame, PDirEntry self, boolean followSymlinks, boolean catchNoent, @Bind("this") Node inliningTarget, - @Shared @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared("cachedPosixPathNode") @Cached CachedPosixPathNode cachedPosixPathNode, @Shared("positiveLongProfile") @Cached InlinedConditionProfile positiveLongProfile, - @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { PTuple res; int dirFd = self.scandirPath instanceof PosixFd ? ((PosixFd) self.scandirPath).fd : AT_FDCWD.value; PosixPath posixPath = cachedPosixPathNode.execute(frame, inliningTarget, self); try { - long[] rawStat = posixLib.fstatat(PosixSupport.get(inliningTarget), dirFd, posixPath.value, followSymlinks); - res = PosixModuleBuiltins.createStatResult(inliningTarget, factory, positiveLongProfile, rawStat); + long[] rawStat = posixLib.fstatat(context.getPosixSupport(), dirFd, posixPath.value, followSymlinks); + res = PosixModuleBuiltins.createStatResult(inliningTarget, context.getLanguage(inliningTarget), positiveLongProfile, rawStat); } catch (PosixException e) { if (catchNoent && e.getErrorCode() == OSErrorEnum.ENOENT.getNumber()) { return null; @@ -423,8 +425,8 @@ static boolean isDir(VirtualFrame frame, PDirEntry self, boolean followSymlinks, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java index 89ba012a09..e903bc3407 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,7 +63,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.dsl.Bind; @@ -112,7 +112,7 @@ static PDirEntry next(VirtualFrame frame, PScandirIterator self, @Bind("this") Node inliningTarget, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { if (self.ref.isReleased()) { throw raiseNode.get(inliningTarget).raiseStopIteration(); @@ -124,7 +124,7 @@ static PDirEntry next(VirtualFrame frame, PScandirIterator self, self.ref.rewindAndClose(posixLib, posixSupport); throw raiseNode.get(inliningTarget).raiseStopIteration(); } - return factory.createDirEntry(dirEntryData, self.path); + return PFactory.createDirEntry(language, dirEntryData, self.path); } catch (PosixException e) { self.ref.rewindAndClose(posixLib, posixSupport); throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java index 488d1eef29..d52d7949ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -81,7 +82,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -256,7 +257,7 @@ static Object copy(PProperty pold, Object getArg, Object setArg, Object delArg) // shortcut: create new property object directly if (IsBuiltinClassProfile.profileClassSlowPath(type, PythonBuiltinClassType.PProperty)) { - PProperty copy = PythonObjectFactory.getUncached().createProperty(); + PProperty copy = PFactory.createProperty(PythonLanguage.get(null)); PropertyInitNode.doGeneric(copy, get, set, del, doc); return copy; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java index a149c1b169..3d4947b771 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -67,7 +68,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaDoubleNode; import com.oracle.graal.python.runtime.GilNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -294,8 +295,8 @@ static PNone doGeneric(PSimpleQueue self, Object item, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java index f17d91e9e0..13a8a35714 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -49,6 +49,7 @@ import java.security.SecureRandom; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; import com.oracle.graal.python.builtins.Builtin; @@ -69,7 +70,7 @@ import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToJavaUnsignedLongNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -191,8 +192,8 @@ public abstract static class GetStateNode extends PythonBuiltinNode { @Specialization static PTuple getstate(PRandom random, - @Cached PythonObjectFactory factory) { - return factory.createTuple(encodeState(random)); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, encodeState(random)); } @TruffleBoundary @@ -275,7 +276,7 @@ static PInt genBigInteger(PRandom random, int k) { bb.putInt(4 * i, x); } bb.putInt(0, random.nextInt() >>> (32 - (k % 32))); - return PythonObjectFactory.getUncached().createInt(new BigInteger(1, bb.array())); + return PFactory.createInt(PythonLanguage.get(null), new BigInteger(1, bb.array())); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java index 2fa9c621ed..ffaef39146 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -41,6 +41,7 @@ import java.math.BigInteger; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -91,7 +92,7 @@ import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaBigIntegerNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -128,8 +129,8 @@ public abstract static class HashNode extends PythonBuiltinNode { @Specialization static long hash(VirtualFrame frame, PIntRange self, @Bind("this") Node inliningTarget, - @Shared("hashNode") @Cached PyObjectHashNode hashNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared("hashNode") @Cached PyObjectHashNode hashNode) { Object[] content = new Object[3]; int intLength = self.getIntLength(); content[0] = intLength; @@ -143,14 +144,14 @@ static long hash(VirtualFrame frame, PIntRange self, content[1] = self.getIntStart(); content[2] = self.getIntStep(); } - return hashNode.execute(frame, inliningTarget, factory.createTuple(content)); + return hashNode.execute(frame, inliningTarget, PFactory.createTuple(language, content)); } @Specialization static long hash(VirtualFrame frame, PBigRange self, @Bind("this") Node inliningTarget, - @Shared("hashNode") @Cached PyObjectHashNode hashNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared("hashNode") @Cached PyObjectHashNode hashNode) { Object[] content = new Object[3]; PInt length = self.getPIntLength(); content[0] = length; @@ -164,7 +165,7 @@ static long hash(VirtualFrame frame, PBigRange self, content[1] = self.getStart(); content[2] = self.getStep(); } - return hashNode.execute(frame, inliningTarget, factory.createTuple(content)); + return hashNode.execute(frame, inliningTarget, PFactory.createTuple(language, content)); } } @@ -246,14 +247,14 @@ boolean doPBigRange(PBigRange self) { abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object doPIntRange(PIntRange self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createIntRangeIterator(self); + @Bind PythonLanguage language) { + return PFactory.createIntRangeIterator(language, self); } @Specialization static Object doPIntRange(PBigRange self, - @Shared @Cached PythonObjectFactory factory) { - return factory.createBigRangeIterator(self); + @Bind PythonLanguage language) { + return PFactory.createBigRangeIterator(language, self); } } @@ -296,10 +297,10 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { @Specialization static Object reduce(PRange self, @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { - PTuple args = factory.createTuple(new Object[]{self.getStart(), self.getStop(), self.getStep()}); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args}); + @Bind PythonLanguage language, + @Cached GetClassNode getClassNode) { + PTuple args = PFactory.createTuple(language, new Object[]{self.getStart(), self.getStop(), self.getStep()}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args}); } } @@ -421,8 +422,8 @@ static int doInt(PIntRange self, int index, @InliningCutoff static Object doBigInt(PBigRange self, int index, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory) { - return factory.createInt(self.getBigIntItemNormalized(GetItemNode.computeBigRangeItem(inliningTarget, self, index))); + @Bind PythonLanguage language) { + return PFactory.createInt(language, self.getBigIntItemNormalized(GetItemNode.computeBigRangeItem(inliningTarget, self, index))); } } @@ -464,9 +465,8 @@ static Object doPRange(VirtualFrame frame, PIntRange self, Object idx, static Object doPRange(PBigRange self, Object idx, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached CastToJavaBigIntegerNode toBigInt, - @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode, - @Shared @Cached PythonObjectFactory factory) { - return factory.createInt(self.getBigIntItemNormalized(computeBigRangeItem(inliningTarget, self, idx, toBigInt))); + @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode) { + return PFactory.createInt(PythonLanguage.get(inliningTarget), self.getBigIntItemNormalized(computeBigRangeItem(inliningTarget, self, idx, toBigInt))); } @Specialization(guards = "!canBeIndex(this, slice, indexCheckNode)") @@ -479,13 +479,12 @@ static Object doPRangeSliceSlowPath(VirtualFrame frame, PIntRange self, PSlice s @Shared @Cached CoerceToObjectSlice toBigIntSlice, @Shared @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode, - @Shared @Cached PythonObjectFactory factory) { + @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode) { try { final int rStart = self.getIntStart(); final int rStep = self.getIntStep(); SliceInfo info = compute.execute(frame, slice, self.getIntLength()); - return createRange(inliningTarget, info, rStart, rStep, lenOfRangeNodeExact, factory); + return createRange(inliningTarget, info, rStart, rStep, lenOfRangeNodeExact); } catch (PException pe) { pe.expect(inliningTarget, PythonBuiltinClassType.OverflowError, profileError); // pass @@ -496,7 +495,7 @@ static Object doPRangeSliceSlowPath(VirtualFrame frame, PIntRange self, PSlice s BigInteger rangeStart = rangeBI.getBigIntegerStart(); BigInteger rangeStep = rangeBI.getBigIntegerStep(); - SliceObjectInfo info = PObjectSlice.computeIndicesSlowPath(toBigIntSlice.execute(slice), rangeBI.getBigIntegerLength(), null); + SliceObjectInfo info = PObjectSlice.computeIndicesSlowPath(toBigIntSlice.execute(slice), rangeBI.getBigIntegerLength(), false); return createRange(inliningTarget, info, rangeStart, rangeStep, lenOfRangeNode); } @@ -514,14 +513,13 @@ static Object doPRangeSliceSlowPath(VirtualFrame frame, PBigRange self, PSlice s @Shared @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode, @Shared @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PythonObjectFactory factory, // unused node to avoid mixing shared and non-shared inlined nodes @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) { try { int rStart = asSizeNode.executeExact(frame, inliningTarget, self.getStart()); int rStep = asSizeNode.executeExact(frame, inliningTarget, self.getStep()); SliceInfo info = compute.execute(frame, slice, asSizeNode.executeExact(frame, inliningTarget, self.getLength())); - return createRange(inliningTarget, info, rStart, rStep, lenOfRangeNodeExact, factory); + return createRange(inliningTarget, info, rStart, rStep, lenOfRangeNodeExact); } catch (PException pe) { pe.expect(inliningTarget, PythonBuiltinClassType.OverflowError, profileError); // pass @@ -532,7 +530,7 @@ static Object doPRangeSliceSlowPath(VirtualFrame frame, PBigRange self, PSlice s BigInteger rangeStart = rangeBI.getBigIntegerStart(); BigInteger rangeStep = rangeBI.getBigIntegerStep(); - SliceObjectInfo info = PObjectSlice.computeIndicesSlowPath(toBigIntSlice.execute(slice), rangeBI.getBigIntegerLength(), null); + SliceObjectInfo info = PObjectSlice.computeIndicesSlowPath(toBigIntSlice.execute(slice), rangeBI.getBigIntegerLength(), false); return createRange(inliningTarget, info, rangeStart, rangeStep, lenOfRangeNode); } @@ -552,22 +550,21 @@ static Object doGeneric(VirtualFrame frame, PRange self, Object idx, @Shared @Cached PyIndexCheckNode indexCheckNode, @Shared @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached IndexNodes.NormalizeIndexCustomMessageNode normalize, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (isNumIndexProfile.profile(inliningTarget, canBeIndex(inliningTarget, idx, indexCheckNode))) { if (self instanceof PIntRange) { return doPRange(frame, (PIntRange) self, idx, inliningTarget, indexCheckNode, asSizeNode, normalize); } - return doPRange((PBigRange) self, idx, inliningTarget, toBigInt, indexCheckNode, factory); + return doPRange((PBigRange) self, idx, inliningTarget, toBigInt, indexCheckNode); } if (isSliceIndexProfile.profile(inliningTarget, idx instanceof PSlice)) { PSlice slice = (PSlice) idx; if (self instanceof PIntRange) { return doPRangeSliceSlowPath(frame, (PIntRange) self, slice, inliningTarget, compute, profileError, toBigIntRange, toBigIntSlice, lenOfRangeNodeExact, lenOfRangeNode, - indexCheckNode, factory); + indexCheckNode); } return doPRangeSliceSlowPath(frame, (PBigRange) self, slice, inliningTarget, isNumIndexProfile, isSliceIndexProfile, compute, profileError, toBigIntRange, toBigIntSlice, - lenOfRangeNodeExact, lenOfRangeNode, indexCheckNode, asSizeNode, factory, raiseNode); + lenOfRangeNodeExact, lenOfRangeNode, indexCheckNode, asSizeNode, raiseNode); } throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "range", idx); } @@ -599,12 +596,12 @@ private static BigInteger computeBigRangeItem(Node inliningTarget, PBigRange ran return i; } - private static PIntRange createRange(Node inliningTarget, SliceInfo info, int rStart, int rStep, LenOfIntRangeNodeExact lenOfRangeNode, PythonObjectFactory factory) throws OverflowException { + private static PIntRange createRange(Node inliningTarget, SliceInfo info, int rStart, int rStep, LenOfIntRangeNodeExact lenOfRangeNode) throws OverflowException { int newStep = rStep * info.step; int newStart = rStart + info.start * rStep; int newStop = rStart + info.stop * rStep; int len = lenOfRangeNode.executeInt(inliningTarget, newStart, newStop, newStep); - return factory.createIntRange(newStart, newStop, newStep, len); + return PFactory.createIntRange(PythonLanguage.get(inliningTarget), newStart, newStop, newStep, len); } @TruffleBoundary @@ -617,8 +614,8 @@ private static PBigRange createRange(Node inliningTarget, SliceObjectInfo info, BigInteger start = rStart.add(sliceStart.multiply(rStep)); BigInteger stop = rStart.add(sliceStop.multiply(rStep)); BigInteger len = lenOfRangeNode.execute(inliningTarget, start, stop, step); - PythonObjectFactory factory = PythonObjectFactory.getUncached(); - return factory.createBigRange(factory.createInt(start), factory.createInt(stop), factory.createInt(step), factory.createInt(len)); + PythonLanguage language = PythonLanguage.get(null); + return PFactory.createBigRange(language, PFactory.createInt(language, start), PFactory.createInt(language, stop), PFactory.createInt(language, step), PFactory.createInt(language, len)); } @NeverDefault @@ -874,12 +871,11 @@ static Object doLongRange(VirtualFrame frame, PBigRange self, Object elem, @Bind("this") Node inliningTarget, @Shared @Cached ContainsNode containsNode, @Cached CastToJavaBigIntegerNode castToBigInt, - @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { if (containsNode.execute(frame, self, elem)) { BigInteger index = slowIntIndex(inliningTarget, self, elem, castToBigInt); if (index != null) { - return factory.createInt(index); + return PFactory.createInt(PythonLanguage.get(inliningTarget), index); } } throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java index 057719c193..f139b88e3e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,12 +45,13 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.slice.PSlice.SliceInfo; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.util.CastToJavaBigIntegerNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -84,14 +85,15 @@ static PBigRange createBigRange(Node inliningTarget, Object start, Object stop, @Cached CastToJavaBigIntegerNode startToBI, @Cached CastToJavaBigIntegerNode stopToBI, @Cached CastToJavaBigIntegerNode stepToBI, - @Cached PRaiseNode.Lazy raise, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached PRaiseNode.Lazy raise) { BigInteger stepBI = stepToBI.execute(inliningTarget, step); checkStepZero(inliningTarget, stepBI, raise); BigInteger startBI = startToBI.execute(inliningTarget, start); BigInteger stopBI = stopToBI.execute(inliningTarget, stop); BigInteger len = lenOfRangeNode.execute(inliningTarget, startBI, stopBI, stepBI); - return factory.createBigRange(factory.createInt(startBI), factory.createInt(stopBI), factory.createInt(stepBI), factory.createInt(len)); + PythonLanguage language = PythonLanguage.get(inliningTarget); + return PFactory.createBigRange(language, PFactory.createInt(language, startBI), PFactory.createInt(language, stopBI), PFactory.createInt(language, stepBI), + PFactory.createInt(language, len)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java index 0cc8893301..f299f37366 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -53,6 +53,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -73,7 +74,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -242,8 +243,8 @@ Object eq(Object self, Object other) { public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java index 801dfb46d2..8dae6a67ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -36,6 +36,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -55,7 +56,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -179,22 +180,22 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PStringReverseIterator self, @Bind("this") Node inliningTarget, @Shared("getClassNode") @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.isExhausted()) { - return reduceInternal(inliningTarget, self, "", null, getClassNode, factory); + return reduceInternal(inliningTarget, self, "", null, getClassNode, language); } - return reduceInternal(inliningTarget, self, self.value, self.index, getClassNode, factory); + return reduceInternal(inliningTarget, self, self.value, self.index, getClassNode, language); } @Specialization(guards = "self.isPSequence()") static Object reduce(PSequenceReverseIterator self, @Bind("this") Node inliningTarget, @Shared("getClassNode") @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.isExhausted()) { - return reduceInternal(inliningTarget, self, factory.createList(), null, getClassNode, factory); + return reduceInternal(inliningTarget, self, PFactory.createList(language), null, getClassNode, language); } - return reduceInternal(inliningTarget, self, self.getPSequence(), self.index, getClassNode, factory); + return reduceInternal(inliningTarget, self, self.getPSequence(), self.index, getClassNode, language); } @Specialization(guards = "!self.isPSequence()") @@ -202,19 +203,19 @@ static Object reduce(VirtualFrame frame, PSequenceReverseIterator self, @Bind("this") Node inliningTarget, @Cached("create(T___REDUCE__)") LookupAndCallUnaryNode callReduce, @Shared("getClassNode") @Cached GetClassNode getClassNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object content = callReduce.executeObject(frame, self.getObject()); - return reduceInternal(inliningTarget, self, content, self.index, getClassNode, factory); + return reduceInternal(inliningTarget, self, content, self.index, getClassNode, language); } - private static PTuple reduceInternal(Node inliningTarget, Object self, Object arg, Object state, GetClassNode getClassNode, PythonObjectFactory factory) { + private static PTuple reduceInternal(Node inliningTarget, Object self, Object arg, Object state, GetClassNode getClassNode, PythonLanguage language) { Object revIter = getClassNode.execute(inliningTarget, self); - PTuple args = factory.createTuple(new Object[]{arg}); + PTuple args = PFactory.createTuple(language, new Object[]{arg}); // callable, args, state (optional) if (state != null) { - return factory.createTuple(new Object[]{revIter, args, state}); + return PFactory.createTuple(language, new Object[]{revIter, args, state}); } else { - return factory.createTuple(new Object[]{revIter, args}); + return PFactory.createTuple(language, new Object[]{revIter, args}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java index 43408ee3bb..efdb549f23 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java @@ -61,6 +61,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -101,10 +102,9 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -198,9 +198,9 @@ static Object doBaseSet(PBaseSet self, @Bind("this") Node inliningTarget, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetIterator getIterator, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getDictStorage(); - return factory.createBaseSetIterator(self, getIterator.execute(inliningTarget, storage), lenNode.execute(inliningTarget, storage)); + return PFactory.createBaseSetIterator(language, self, getIterator.execute(inliningTarget, storage), lenNode.execute(inliningTarget, storage)); } } @@ -229,7 +229,7 @@ static Object reduce(VirtualFrame frame, PBaseSet self, @Cached HashingStorageIteratorKey getIterKey, @Cached GetClassNode getClassNode, @Cached PyObjectGetStateNode getStateNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage storage = self.getDictStorage(); int len = lenNode.execute(inliningTarget, storage); Object[] keysArray = new Object[len]; @@ -239,9 +239,9 @@ static Object reduce(VirtualFrame frame, PBaseSet self, assert hasNext; keysArray[i] = getIterKey.execute(inliningTarget, storage, it); } - PTuple contents = factory.createTuple(new Object[]{factory.createList(keysArray)}); + PTuple contents = PFactory.createTuple(language, new Object[]{PFactory.createList(language, keysArray)}); Object state = getStateNode.execute(frame, inliningTarget, self); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), contents, state}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), contents, state}); } } @@ -282,14 +282,14 @@ abstract static class CreateSetNode extends Node { @Specialization static PBaseSet doSet(HashingStorage storage, @SuppressWarnings("unused") PSet template, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createSet(storage); + @Bind PythonLanguage language) { + return PFactory.createSet(language, storage); } @Specialization static PBaseSet doFrozenSet(HashingStorage storage, @SuppressWarnings("unused") PFrozenSet template, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createFrozenSet(storage); + @Bind PythonLanguage language) { + return PFactory.createFrozenSet(language, storage); } } @@ -556,10 +556,10 @@ static Object doPSet(Node inliningTarget, PSet key, @Cached HashingStorageCopy copyNode, @Cached GetClassNode getClassNode, @Cached(parameters = "Hash", inline = false) LookupCallableSlotInMRONode lookupHash, - @Cached PythonObjectFactory.Lazy factory) { + @Cached InlinedConditionProfile createSet) { Object hashDescr = lookupHash.execute(getClassNode.execute(inliningTarget, key)); - if (hashDescr instanceof PNone) { - return factory.get(inliningTarget).createFrozenSet(copyNode.execute(inliningTarget, key.getDictStorage())); + if (createSet.profile(inliningTarget, hashDescr instanceof PNone)) { + return PFactory.createFrozenSet(PythonLanguage.get(inliningTarget), copyNode.execute(inliningTarget, key.getDictStorage())); } else { return key; } @@ -571,8 +571,8 @@ static Object doPSet(Node inliningTarget, PSet key, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/FrozenSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/FrozenSetBuiltins.java index ecee481ff7..63062f42f0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/FrozenSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/FrozenSetBuiltins.java @@ -29,6 +29,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -38,6 +39,7 @@ import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes; import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes.GetSetStorageNode; import com.oracle.graal.python.builtins.objects.common.HashingStorage; +import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageAddAllToOther; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageCopy; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDiff; @@ -52,8 +54,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsAnyBuiltinObjectProfile; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -79,16 +80,17 @@ protected List> getNodeFa @GenerateNodeFactory public abstract static class CopyNode extends PythonUnaryBuiltinNode { - @Specialization - static PFrozenSet subFrozensetIdentity(PFrozenSet arg, + @Specialization(guards = "isBuiltinFrozenSet(self)") + static PFrozenSet frozenSetIdentity(PFrozenSet self) { + return self; + } + + @Specialization(guards = "!isBuiltinFrozenSet(self)") + static PFrozenSet doGeneric(PFrozenSet self, @Bind("this") Node inliningTarget, - @Cached IsAnyBuiltinObjectProfile isBuiltinClass, - @Cached PythonObjectFactory.Lazy factory) { - if (isBuiltinClass.profileIsAnyBuiltinObject(inliningTarget, arg)) { - return arg; - } else { - return factory.get(inliningTarget).createFrozenSet(arg.getDictStorage()); - } + @Bind PythonLanguage language, + @Cached HashingStorageNodes.HashingStorageCopy copy) { + return PFactory.createFrozenSet(language, copy.execute(inliningTarget, self.getDictStorage())); } } @@ -98,8 +100,8 @@ public abstract static class IntersectNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(other)") static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenSet self, @SuppressWarnings("unused") PNone other, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFrozenSet(self.getDictStorage()); + @Bind PythonLanguage language) { + return PFactory.createFrozenSet(language, self.getDictStorage()); } @Specialization(guards = {"args.length == len", "args.length < 32"}, limit = "3") @@ -109,12 +111,12 @@ static PBaseSet doCached(VirtualFrame frame, PFrozenSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = intersectNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } @Specialization(replaces = "doCached") @@ -123,12 +125,12 @@ static PBaseSet doGeneric(VirtualFrame frame, PFrozenSet self, Object[] args, @Shared @Cached GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = intersectNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } static boolean isOther(Object arg) { @@ -140,9 +142,9 @@ static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenS @Bind("this") Node inliningTarget, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = intersectNode.execute(frame, inliningTarget, self.getDictStorage(), getSetStorageNode.execute(frame, inliningTarget, other)); - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } } @@ -155,9 +157,9 @@ static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenS @Bind("this") Node inliningTarget, @Cached HashingCollectionNodes.GetSetStorageNode getHashingStorage, @Cached HashingStorageXor xorNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = xorNode.execute(frame, inliningTarget, self.getDictStorage(), getHashingStorage.execute(frame, inliningTarget, other)); - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } } @@ -167,8 +169,8 @@ public abstract static class DifferenceNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(other)") static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenSet self, @SuppressWarnings("unused") PNone other, - @Shared @Cached PythonObjectFactory factory) { - return factory.createFrozenSet(self.getDictStorage()); + @Bind PythonLanguage language) { + return PFactory.createFrozenSet(language, self.getDictStorage()); } @Specialization(guards = {"args.length == len", "args.length < 32"}, limit = "3") @@ -178,12 +180,12 @@ static PBaseSet doCached(VirtualFrame frame, PFrozenSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = diffNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } @Specialization(replaces = "doCached") @@ -192,12 +194,12 @@ static PBaseSet doGeneric(VirtualFrame frame, PFrozenSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = diffNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } static boolean isOther(Object arg) { @@ -209,9 +211,9 @@ static PFrozenSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PFrozenS @Bind("this") Node inliningTarget, @Shared @Cached GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = diffNode.execute(frame, inliningTarget, self.getDictStorage(), getSetStorageNode.execute(frame, inliningTarget, other)); - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } } @@ -226,12 +228,12 @@ static PBaseSet doCached(VirtualFrame frame, PBaseSet self, Object[] args, @Shared @Cached GetSetStorageNode getHashingStorage, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageAddAllToOther addAllToOther, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = addAllToOther.execute(frame, inliningTarget, getHashingStorage.execute(frame, inliningTarget, args[i]), result); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } @Specialization(replaces = "doCached") @@ -240,12 +242,12 @@ static PBaseSet doGeneric(VirtualFrame frame, PBaseSet self, Object[] args, @Shared @Cached GetSetStorageNode getHashingStorage, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageAddAllToOther addAllToOther, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = addAllToOther.execute(frame, inliningTarget, getHashingStorage.execute(frame, inliningTarget, args[i]), result); } - return factory.createFrozenSet(result); + return PFactory.createFrozenSet(language, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java index a789168129..bbe0f3ea1e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java @@ -36,6 +36,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -75,7 +76,7 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; @@ -149,8 +150,8 @@ public abstract static class CopyNode extends PythonBuiltinNode { static PSet doSet(PSet self, @Bind("this") Node inliningTarget, @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory) { - return factory.createSet(copyNode.execute(inliningTarget, self.getDictStorage())); + @Bind PythonLanguage language) { + return PFactory.createSet(language, copyNode.execute(inliningTarget, self.getDictStorage())); } } @@ -209,12 +210,12 @@ static PBaseSet doCached(VirtualFrame frame, PSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageAddAllToOther addAllToOther, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = addAllToOther.execute(frame, inliningTarget, getSetStorageNode.execute(frame, inliningTarget, args[i]), result); } - return factory.createSet(result); + return PFactory.createSet(language, result); } @Specialization(replaces = "doCached") @@ -223,12 +224,12 @@ static PBaseSet doGeneric(VirtualFrame frame, PSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageAddAllToOther addAllToOther, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = addAllToOther.execute(frame, inliningTarget, getSetStorageNode.execute(frame, inliningTarget, args[i]), result); } - return factory.createSet(result); + return PFactory.createSet(language, result); } } @@ -405,10 +406,9 @@ public abstract static class IntersectNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(other)") Object doSet(@SuppressWarnings("unused") VirtualFrame frame, PSet self, @SuppressWarnings("unused") PNone other, @Bind("this") Node inliningTarget, - @Shared @Cached HashingStorageCopy copyNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached HashingStorageCopy copyNode) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); - return createResult(self, result, factory); + return createResult(self, result); } @Specialization(guards = {"args.length == len", "args.length < 32"}, limit = "3") @@ -417,13 +417,12 @@ Object doCached(VirtualFrame frame, PSet self, Object[] args, @Cached("args.length") int len, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, - @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached HashingStorageIntersect intersectNode) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = intersectNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return createResult(self, result, factory); + return createResult(self, result); } @Specialization(replaces = "doCached") @@ -431,13 +430,12 @@ Object doGeneric(VirtualFrame frame, PSet self, Object[] args, @Bind("this") Node inliningTarget, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, - @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached HashingStorageIntersect intersectNode) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = intersectNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return createResult(self, result, factory); + return createResult(self, result); } static boolean isOther(Object arg) { @@ -450,14 +448,14 @@ Object doSet(VirtualFrame frame, PSet self, Object other, @Shared @Cached GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageIntersect intersectNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); result = intersectNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, other)); - return createResult(self, result, factory); + return PFactory.createSet(language, result); } - protected Object createResult(PSet self, HashingStorage result, PythonObjectFactory factory) { - return factory.createSet(result); + protected Object createResult(PSet self, HashingStorage result) { + return PFactory.createSet(PythonLanguage.get(this), result); } } @@ -465,8 +463,7 @@ protected Object createResult(PSet self, HashingStorage result, PythonObjectFact @GenerateNodeFactory @ImportStatic({SpecialMethodNames.class}) public abstract static class IntersectUpdateNode extends IntersectNode { - @Override - protected Object createResult(PSet self, HashingStorage result, PythonObjectFactory factory) { + protected Object createResult(PSet self, HashingStorage result) { // In order to be compatible w.r.t. __eq__ calls we cannot reuse self storage self.setDictStorage(result); return PNone.NONE; @@ -501,9 +498,9 @@ static PSet doSet(VirtualFrame frame, PSet self, Object other, @Bind("this") Node inliningTarget, @Cached GetSetStorageNode getHashingStorage, @Cached HashingStorageXor xorNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = xorNode.execute(frame, inliningTarget, self.getDictStorage(), getHashingStorage.execute(frame, inliningTarget, other)); - return factory.createSet(result); + return PFactory.createSet(language, result); } } @@ -584,8 +581,8 @@ public abstract static class DifferenceNode extends PythonBuiltinNode { @Specialization(guards = "isNoValue(other)") static PSet doSet(@SuppressWarnings("unused") VirtualFrame frame, PSet self, @SuppressWarnings("unused") PNone other, - @Shared @Cached PythonObjectFactory factory) { - return factory.createSet(self.getDictStorage()); + @Bind PythonLanguage language) { + return PFactory.createSet(language, self.getDictStorage()); } @Specialization(guards = {"args.length == len", "args.length < 32"}, limit = "3") @@ -595,12 +592,12 @@ static PBaseSet doCached(VirtualFrame frame, PSet self, Object[] args, @Shared @Cached HashingCollectionNodes.GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < len; i++) { result = diffNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createSet(result); + return PFactory.createSet(language, result); } @Specialization(replaces = "doCached") @@ -609,12 +606,12 @@ static PBaseSet doGeneric(VirtualFrame frame, PSet self, Object[] args, @Shared @Cached GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageCopy copyNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = copyNode.execute(inliningTarget, self.getDictStorage()); for (int i = 0; i < args.length; i++) { result = diffNode.execute(frame, inliningTarget, result, getSetStorageNode.execute(frame, inliningTarget, args[i])); } - return factory.createSet(result); + return PFactory.createSet(language, result); } static boolean isOther(Object arg) { @@ -626,9 +623,9 @@ static PSet doSet(VirtualFrame frame, PSet self, Object other, @Bind("this") Node inliningTarget, @Shared @Cached GetSetStorageNode getSetStorageNode, @Shared @Cached HashingStorageDiff diffNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { HashingStorage result = diffNode.execute(frame, inliningTarget, self.getDictStorage(), getSetStorageNode.execute(frame, inliningTarget, other)); - return factory.createSet(result); + return PFactory.createSet(language, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java index aa6dbc34b0..09fa381d61 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,9 +41,8 @@ package com.oracle.graal.python.builtins.objects.set; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDelItem; @@ -55,7 +54,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -66,53 +65,29 @@ import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleStringIterator; public abstract class SetNodes { @GenerateUncached @SuppressWarnings("truffle-inlining") // footprint reduction 116 -> 98 public abstract static class ConstructSetNode extends PNodeWithContext { - public abstract PSet execute(Frame frame, Object cls, Object value); + public abstract PSet execute(Frame frame, Object value); - public final PSet executeWith(Frame frame, Object value) { - return this.execute(frame, PythonBuiltinClassType.PSet, value); - } - - @Specialization - static PSet setString(VirtualFrame frame, Object cls, TruffleString arg, - @Bind("this") Node inliningTarget, - @Exclusive @Cached PythonObjectFactory factory, - @Exclusive @Cached HashingCollectionNodes.SetItemNode setItemNode, - @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, - @Cached TruffleStringIterator.NextNode nextNode, - @Cached TruffleString.FromCodePointNode fromCodePointNode) { - PSet set = factory.createSet(cls); - TruffleStringIterator it = createCodePointIteratorNode.execute(arg, TS_ENCODING); - while (it.hasNext()) { - int cp = nextNode.execute(it); - TruffleString s = fromCodePointNode.execute(cp, TS_ENCODING, true); - setItemNode.execute(frame, inliningTarget, set, s, PNone.NONE); - } - return set; - } - - @Specialization(guards = "emptyArguments(none)") - static PSet set(Object cls, @SuppressWarnings("unused") PNone none, - @Exclusive @Cached PythonObjectFactory factory) { - return factory.createSet(cls); + @Specialization(guards = "isNoValue(none)") + static PSet set(@SuppressWarnings("unused") PNone none, + @Bind PythonLanguage language) { + return PFactory.createSet(language); } @Specialization(guards = "!isNoValue(iterable)") - static PSet setIterable(VirtualFrame frame, Object cls, Object iterable, + static PSet setIterable(VirtualFrame frame, Object iterable, @Bind("this") Node inliningTarget, - @Exclusive @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached HashingCollectionNodes.SetItemNode setItemNode, @Cached PyObjectGetIter getIter, @Cached GetNextNode nextNode, @Cached IsBuiltinObjectProfile errorProfile) { - PSet set = factory.createSet(cls); + PSet set = PFactory.createSet(language); Object iterator = getIter.execute(frame, inliningTarget, iterable); while (true) { try { @@ -125,7 +100,7 @@ static PSet setIterable(VirtualFrame frame, Object cls, Object iterable, } @Fallback - static PSet setObject(@SuppressWarnings("unused") Object cls, Object value, + static PSet setObject(Object value, @Cached PRaiseNode raiseNode) { throw raiseNode.raise(TypeError, ErrorMessages.OBJ_NOT_ITERABLE, value); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java index 5379a81015..ba8805dfb4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -48,7 +48,7 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.ValueType; @@ -128,7 +128,7 @@ private static int pySign(BigInteger n) { * _PySlice_GetLongIndices */ @TruffleBoundary - public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object lengthIn, PythonObjectFactory factory) { + public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object lengthIn, boolean usePInt) { boolean stepIsNegative; BigInteger lower, upper; BigInteger start, stop, step, length; @@ -194,8 +194,9 @@ public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object } } - if (factory != null) { - return new SliceObjectInfo(factory.createInt(start), factory.createInt(stop), factory.createInt(step)); + if (usePInt) { + PythonLanguage language = PythonLanguage.get(null); + return new SliceObjectInfo(PFactory.createInt(language, start), PFactory.createInt(language, stop), PFactory.createInt(language, step)); } else { return new SliceObjectInfo(start, stop, step); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java index 59bdeab756..3a951b574e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -34,6 +34,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -54,7 +55,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -168,9 +169,9 @@ protected static Object get(PObjectSlice self) { @GenerateNodeFactory abstract static class IndicesNode extends PythonBinaryBuiltinNode { - private static PTuple doPSlice(VirtualFrame frame, PSlice self, int length, ComputeIndices compute, PythonObjectFactory factory) { + private static PTuple doPSlice(VirtualFrame frame, PSlice self, int length, ComputeIndices compute, PythonLanguage language) { SliceInfo sliceInfo = compute.execute(frame, self, length); - return factory.createTuple(new Object[]{sliceInfo.start, sliceInfo.stop, sliceInfo.step}); + return PFactory.createTuple(language, new Object[]{sliceInfo.start, sliceInfo.stop, sliceInfo.step}); } protected static boolean isSafeIntSlice(PSlice self, Object length) { @@ -179,31 +180,31 @@ protected static boolean isSafeIntSlice(PSlice self, Object length) { @Specialization static PTuple safeInt(VirtualFrame frame, PIntSlice self, int length, - @Shared @Cached ComputeIndices compute, - @Shared @Cached PythonObjectFactory factory) { - return doPSlice(frame, self, length, compute, factory); + @Bind PythonLanguage language, + @Shared @Cached ComputeIndices compute) { + return doPSlice(frame, self, length, compute, language); } @Specialization(guards = "!isPNone(length)", rewriteOn = PException.class) static PTuple doSliceObject(VirtualFrame frame, PSlice self, Object length, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached SliceExactCastToInt toInt, - @Shared @Cached ComputeIndices compute, - @Shared @Cached PythonObjectFactory factory) { - return doPSlice(frame, self, (int) toInt.execute(frame, inliningTarget, length), compute, factory); + @Shared @Cached ComputeIndices compute) { + return doPSlice(frame, self, (int) toInt.execute(frame, inliningTarget, length), compute, language); } @Specialization(guards = "!isPNone(length)", replaces = {"doSliceObject"}) static PTuple doSliceObjectWithSlowPath(VirtualFrame frame, PSlice self, Object length, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Exclusive @Cached SliceExactCastToInt toInt, @Shared @Cached ComputeIndices compute, @Cached IsBuiltinObjectProfile profileError, @Cached SliceCastToToBigInt castLengthNode, - @Cached CoerceToObjectSlice castNode, - @Shared @Cached PythonObjectFactory factory) { + @Cached CoerceToObjectSlice castNode) { try { - return doPSlice(frame, self, (int) toInt.execute(frame, inliningTarget, length), compute, factory); + return doPSlice(frame, self, (int) toInt.execute(frame, inliningTarget, length), compute, language); } catch (PException pe) { if (!profileError.profileException(inliningTarget, pe, PythonBuiltinClassType.OverflowError)) { throw pe; @@ -212,8 +213,8 @@ static PTuple doSliceObjectWithSlowPath(VirtualFrame frame, PSlice self, Object } Object lengthIn = castLengthNode.execute(inliningTarget, length); - PObjectSlice.SliceObjectInfo sliceInfo = PObjectSlice.computeIndicesSlowPath(castNode.execute(self), lengthIn, factory); - return factory.createTuple(new Object[]{sliceInfo.start, sliceInfo.stop, sliceInfo.step}); + PObjectSlice.SliceObjectInfo sliceInfo = PObjectSlice.computeIndicesSlowPath(castNode.execute(self), lengthIn, true); + return PFactory.createTuple(language, new Object[]{sliceInfo.start, sliceInfo.stop, sliceInfo.step}); } @Specialization(guards = {"isPNone(length)"}) @@ -240,10 +241,10 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { @Specialization static Object reduce(PSlice self, @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { - PTuple args = factory.createTuple(new Object[]{self.getStart(), self.getStop(), self.getStep()}); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args}); + @Bind PythonLanguage language, + @Cached GetClassNode getClassNode) { + PTuple args = PFactory.createTuple(language, new Object[]{self.getStart(), self.getStop(), self.getStep()}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java index 7432624a01..577f2b6b31 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +45,7 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.ints.IntNodes.PyLongSign; import com.oracle.graal.python.lib.PyIndexCheckNode; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaBigIntegerNode; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -84,34 +85,34 @@ public abstract static class CreateSliceNode extends PNodeWithContext { @SuppressWarnings("unused") static PSlice doInt(int start, int stop, PNone step, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createIntSlice(start, stop, 1, false, true); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, start, stop, 1, false, true); } @Specialization static PSlice doInt(int start, int stop, int step, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createIntSlice(start, stop, step); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, start, stop, step); } @Specialization @SuppressWarnings("unused") static PSlice doInt(PNone start, int stop, PNone step, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createIntSlice(0, stop, 1, true, true); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, 0, stop, 1, true, true); } @Specialization @SuppressWarnings("unused") static PSlice doInt(PNone start, int stop, int step, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createIntSlice(0, stop, step, true, false); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, 0, stop, step, true, false); } @Fallback static PSlice doGeneric(Object start, Object stop, Object step, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createObjectSlice(start, stop, step); + @Bind PythonLanguage language) { + return PFactory.createObjectSlice(language, start, stop, step); } @NeverDefault @@ -226,8 +227,8 @@ PObjectSlice doSliceInt(PIntSlice slice, @Shared @Cached SliceCastToToBigInt start, @Shared @Cached SliceCastToToBigInt stop, @Shared @Cached SliceCastToToBigInt step, - @Shared @Cached PythonObjectFactory factory) { - return factory.createObjectSlice(start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); + @Bind PythonLanguage language) { + return PFactory.createObjectSlice(language, start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); } protected static boolean isBigInt(PObjectSlice slice) { @@ -245,8 +246,8 @@ PObjectSlice doSliceObject(PObjectSlice slice, @Shared @Cached SliceCastToToBigInt start, @Shared @Cached SliceCastToToBigInt stop, @Shared @Cached SliceCastToToBigInt step, - @Shared @Cached PythonObjectFactory factory) { - return factory.createObjectSlice(start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); + @Bind PythonLanguage language) { + return PFactory.createObjectSlice(language, start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); } } @@ -271,8 +272,8 @@ static PSlice doSliceObject(Node inliningTarget, PObjectSlice slice, @Cached SliceLossyCastToInt start, @Cached SliceLossyCastToInt stop, @Cached SliceLossyCastToInt step, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createObjectSlice(start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); + @Bind PythonLanguage language) { + return PFactory.createObjectSlice(language, start.execute(inliningTarget, slice.getStart()), stop.execute(inliningTarget, slice.getStop()), step.execute(inliningTarget, slice.getStep())); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java index 9e114866d9..755c2c3b07 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java @@ -60,6 +60,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -97,7 +98,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.UniversalSockAddrLibrary; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.TimeUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -141,7 +142,8 @@ private static boolean isSelectable(PSocket socket) { public abstract static class InitNode extends PythonClinicBuiltinNode { @Specialization static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, int protoIn, @SuppressWarnings("unused") PNone fileno, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Exclusive @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, @@ -160,7 +162,6 @@ static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, i if (proto == -1) { proto = 0; } - PythonContext context = PythonContext.get(inliningTarget); try { // TODO SOCK_CLOEXEC? int fd; @@ -191,7 +192,8 @@ static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, i @Specialization(guards = "!isPNone(fileno)") static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, int protoIn, Object fileno, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "1") UniversalSockAddrLibrary addrLib, @Bind("this") Node inliningTarget, @Exclusive @Cached SysModuleBuiltins.AuditNode auditNode, @@ -200,7 +202,6 @@ static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, i @Cached PRaiseNode.Lazy raiseNode) { // sic! CPython really has __new__ there, even though it's in __init__ auditNode.audit(inliningTarget, "socket.__new__", self, familyIn, typeIn, protoIn); - PythonContext context = PythonContext.get(inliningTarget); int fd = asIntNode.execute(frame, inliningTarget, fileno); if (fd < 0) { @@ -281,23 +282,23 @@ abstract static class AcceptNode extends PythonUnaryBuiltinNode { @Specialization static Object accept(VirtualFrame frame, PSocket self, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { checkSelectable(inliningTarget, raiseNode, self); try { - PosixSupport posixSupport = PosixSupport.get(inliningTarget); + PosixSupport posixSupport = context.getPosixSupport(); PosixSupportLibrary.AcceptResult acceptResult = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, posixSupport, gil, self, (p, s) -> p.accept(s, self.getFd()), false, false); try { Object pythonAddr = makeSockAddrNode.execute(frame, inliningTarget, acceptResult.sockAddr); posixLib.setInheritable(posixSupport, acceptResult.socketFd, false); - return factory.createTuple(new Object[]{acceptResult.socketFd, pythonAddr}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{acceptResult.socketFd, pythonAddr}); } catch (Exception e) { // If we failed before giving the fd to python-land, close it CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -319,9 +320,10 @@ static Object accept(VirtualFrame frame, PSocket self, @GenerateNodeFactory abstract static class BindNode extends PythonBinaryBuiltinNode { @Specialization - Object bind(VirtualFrame frame, PSocket self, Object address, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLibrary, + static Object bind(VirtualFrame frame, PSocket self, Object address, @Bind("this") Node inliningTarget, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLibrary, @Cached SocketNodes.GetSockAddrArgNode getSockAddrArgNode, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, @@ -332,7 +334,7 @@ Object bind(VirtualFrame frame, PSocket self, Object address, try { gil.release(true); try { - posixLibrary.bind(getPosixSupport(), self.getFd(), addr); + posixLibrary.bind(context.getPosixSupport(), self.getFd(), addr); } finally { gil.acquire(); } @@ -348,9 +350,10 @@ Object bind(VirtualFrame frame, PSocket self, Object address, @GenerateNodeFactory abstract static class CloseNode extends PythonUnaryBuiltinNode { @Specialization - Object close(VirtualFrame frame, PSocket socket, + static Object close(VirtualFrame frame, PSocket socket, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { int fd = socket.getFd(); @@ -359,7 +362,7 @@ Object close(VirtualFrame frame, PSocket socket, socket.setFd(INVALID_FD); gil.release(true); try { - posixLib.close(getPosixSupport(), fd); + posixLib.close(context.getPosixSupport(), fd); } finally { gil.acquire(); } @@ -379,8 +382,9 @@ Object close(VirtualFrame frame, PSocket socket, @GenerateNodeFactory abstract static class ConnectNode extends PythonBinaryBuiltinNode { @Specialization - Object connect(VirtualFrame frame, PSocket self, Object address, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object connect(VirtualFrame frame, PSocket self, Object address, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SocketNodes.GetSockAddrArgNode getSockAddrArgNode, @Cached GilNode gil, @@ -391,7 +395,7 @@ Object connect(VirtualFrame frame, PSocket self, Object address, auditNode.audit(inliningTarget, "socket.connect", self, address); try { - doConnect(frame, inliningTarget, constructAndRaiseNode, posixLib, getPosixSupport(), gil, self, connectAddr); + doConnect(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, self, connectAddr); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -439,8 +443,9 @@ static void doConnect(Frame frame, Node inliningTarget, PConstructAndRaiseNode.L @GenerateNodeFactory abstract static class ConnectExNode extends PythonBinaryBuiltinNode { @Specialization - Object connectEx(VirtualFrame frame, PSocket self, Object address, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + static Object connectEx(VirtualFrame frame, PSocket self, Object address, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached SocketNodes.GetSockAddrArgNode getSockAddrArgNode, @Cached GilNode gil, @@ -451,7 +456,7 @@ Object connectEx(VirtualFrame frame, PSocket self, Object address, auditNode.audit(inliningTarget, "socket.connect", self, address); // sic! connect try { - ConnectNode.doConnect(frame, inliningTarget, constructAndRaiseNode, posixLib, getPosixSupport(), gil, self, connectAddr); + ConnectNode.doConnect(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, self, connectAddr); } catch (PosixException e) { return e.getErrorCode(); } @@ -464,9 +469,10 @@ Object connectEx(VirtualFrame frame, PSocket self, Object address, @GenerateNodeFactory abstract static class GetPeerNameNode extends PythonUnaryBuiltinNode { @Specialization - Object get(VirtualFrame frame, PSocket socket, + static Object get(VirtualFrame frame, PSocket socket, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { @@ -474,7 +480,7 @@ Object get(VirtualFrame frame, PSocket socket, UniversalSockAddr addr; gil.release(true); try { - addr = posixLib.getpeername(getPosixSupport(), socket.getFd()); + addr = posixLib.getpeername(context.getPosixSupport(), socket.getFd()); } finally { gil.acquire(); } @@ -490,9 +496,10 @@ Object get(VirtualFrame frame, PSocket socket, @GenerateNodeFactory abstract static class GetSockNameNode extends PythonUnaryBuiltinNode { @Specialization - Object get(VirtualFrame frame, PSocket socket, + static Object get(VirtualFrame frame, PSocket socket, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { @@ -500,7 +507,7 @@ Object get(VirtualFrame frame, PSocket socket, UniversalSockAddr addr; gil.release(true); try { - addr = posixLib.getsockname(getPosixSupport(), socket.getFd()); + addr = posixLib.getsockname(context.getPosixSupport(), socket.getFd()); } finally { gil.acquire(); } @@ -516,7 +523,7 @@ Object get(VirtualFrame frame, PSocket socket, @GenerateNodeFactory public abstract static class GetBlockingNode extends PythonUnaryBuiltinNode { @Specialization - public static boolean get(PSocket socket) { + static boolean get(PSocket socket) { return socket.getTimeoutNs() != 0; } } @@ -541,9 +548,10 @@ static Object get(PSocket socket) { @GenerateNodeFactory abstract static class ListenNode extends PythonBinaryClinicBuiltinNode { @Specialization - Object listen(VirtualFrame frame, PSocket self, int backlogIn, + static Object listen(VirtualFrame frame, PSocket self, int backlogIn, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { int backlog = backlogIn; @@ -553,7 +561,7 @@ Object listen(VirtualFrame frame, PSocket self, int backlogIn, try { gil.release(true); try { - posixLib.listen(getPosixSupport(), self.getFd(), backlog); + posixLib.listen(context.getPosixSupport(), self.getFd(), backlog); } finally { gil.acquire(); } @@ -576,19 +584,20 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class RecvNode extends PythonTernaryClinicBuiltinNode { @Specialization - Object recv(VirtualFrame frame, PSocket socket, int recvlen, int flags, + static Object recv(VirtualFrame frame, PSocket socket, int recvlen, int flags, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (recvlen < 0) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECV); } checkSelectable(inliningTarget, raiseNode, socket); + PythonLanguage language = context.getLanguage(inliningTarget); if (recvlen == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } byte[] bytes; @@ -599,14 +608,14 @@ Object recv(VirtualFrame frame, PSocket socket, int recvlen, int flags, } try { - int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, getPosixSupport(), gil, socket, + int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.recv(s, socket.getFd(), bytes, 0, bytes.length, flags), false, false); if (outlen == 0) { - return factory.createEmptyBytes(); + return PFactory.createEmptyBytes(language); } // TODO maybe resize if much smaller? - return factory.createBytes(bytes, outlen); + return PFactory.createBytes(language, bytes, outlen); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -625,13 +634,13 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class RecvFromNode extends PythonTernaryClinicBuiltinNode { @Specialization - Object recvFrom(VirtualFrame frame, PSocket socket, int recvlen, int flags, + static Object recvFrom(VirtualFrame frame, PSocket socket, int recvlen, int flags, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (recvlen < 0) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECVFROM); @@ -646,17 +655,18 @@ Object recvFrom(VirtualFrame frame, PSocket socket, int recvlen, int flags, } try { - RecvfromResult result = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, getPosixSupport(), gil, socket, + RecvfromResult result = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.recvfrom(s, socket.getFd(), bytes, 0, bytes.length, flags), false, false); PBytes resultBytes; + PythonLanguage language = context.getLanguage(inliningTarget); if (result.readBytes == 0) { - resultBytes = factory.createEmptyBytes(); + resultBytes = PFactory.createEmptyBytes(language); } else { // TODO maybe resize if much smaller? - resultBytes = factory.createBytes(bytes, result.readBytes); + resultBytes = PFactory.createBytes(language, bytes, result.readBytes); } - return factory.createTuple(new Object[]{resultBytes, makeSockAddrNode.execute(frame, inliningTarget, result.sockAddr)}); + return PFactory.createTuple(language, new Object[]{resultBytes, makeSockAddrNode.execute(frame, inliningTarget, result.sockAddr)}); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -677,10 +687,11 @@ abstract static class RecvIntoNode extends PythonQuaternaryClinicBuiltinNode { @Specialization(limit = "3") static Object recvInto(VirtualFrame frame, PSocket socket, Object bufferObj, int recvlenIn, int flags, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("bufferObj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { @@ -714,7 +725,7 @@ static Object recvInto(VirtualFrame frame, PSocket socket, Object bufferObj, int final int len = recvlen; try { - int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, PosixSupport.get(inliningTarget), gil, socket, + int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.recv(s, socket.getFd(), bytes, 0, len, flags), false, false); if (!directWrite) { @@ -744,14 +755,14 @@ abstract static class RecvFromIntoNode extends PythonQuaternaryClinicBuiltinNode @Specialization(limit = "3") static Object recvFromInto(VirtualFrame frame, PSocket socket, Object bufferObj, int recvlenIn, int flags, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("bufferObj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { Object buffer = bufferAcquireLib.acquireWritable(bufferObj, frame, indirectCallData); try { @@ -782,13 +793,13 @@ static Object recvFromInto(VirtualFrame frame, PSocket socket, Object bufferObj, } try { - RecvfromResult result = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, PosixSupport.get(inliningTarget), gil, socket, + RecvfromResult result = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.recvfrom(s, socket.getFd(), bytes, 0, bytes.length, flags), false, false); if (!directWrite) { bufferLib.writeFromByteArray(buffer, 0, bytes, 0, result.readBytes); } - return factory.createTuple(new Object[]{result.readBytes, makeSockAddrNode.execute(frame, inliningTarget, result.sockAddr)}); + return PFactory.createTuple(context.getLanguage(inliningTarget), new Object[]{result.readBytes, makeSockAddrNode.execute(frame, inliningTarget, result.sockAddr)}); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -811,10 +822,11 @@ abstract static class SendNode extends PythonTernaryClinicBuiltinNode { @Specialization(limit = "3") static int send(VirtualFrame frame, PSocket socket, Object bufferObj, int flags, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("bufferObj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { @@ -826,7 +838,7 @@ static int send(VirtualFrame frame, PSocket socket, Object bufferObj, int flags, byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); try { - return SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, PosixSupport.get(inliningTarget), gil, socket, + return SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.send(s, socket.getFd(), bytes, 0, len, flags), true, false); } catch (PosixException e) { @@ -851,10 +863,11 @@ abstract static class SendAllNode extends PythonTernaryClinicBuiltinNode { @Specialization(limit = "3") static Object sendAll(VirtualFrame frame, PSocket socket, Object bufferObj, int flags, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("bufferObj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode.Lazy raiseNode) { @@ -876,7 +889,7 @@ static Object sendAll(VirtualFrame frame, PSocket socket, Object bufferObj, int try { final int offset1 = offset; final int len1 = len; - int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, PosixSupport.get(inliningTarget), gil, socket, + int outlen = SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.send(s, socket.getFd(), bytes, offset1, len1, flags), true, false, timeoutHelper); offset += outlen; @@ -909,10 +922,11 @@ abstract static class SendToNode extends PythonBuiltinNode { @Specialization(limit = "3") static Object sendTo(VirtualFrame frame, PSocket socket, Object bufferObj, Object flagsOrAddress, Object maybeAddress, @Bind("this") Node inliningTarget, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("bufferObj") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile hasFlagsProfile, @Cached PyLongAsIntNode asIntNode, @Cached SocketNodes.GetSockAddrArgNode getSockAddrArgNode, @@ -941,7 +955,7 @@ static Object sendTo(VirtualFrame frame, PSocket socket, Object bufferObj, Objec byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); try { - return SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, PosixSupport.get(inliningTarget), gil, socket, + return SocketUtils.callSocketFunctionWithRetry(frame, inliningTarget, constructAndRaiseNode, posixLib, context.getPosixSupport(), gil, socket, (p, s) -> p.sendto(s, socket.getFd(), bytes, 0, len, flags, addr), true, false); } catch (PosixException e) { @@ -958,12 +972,13 @@ static Object sendTo(VirtualFrame frame, PSocket socket, Object bufferObj, Objec @GenerateNodeFactory public abstract static class SetBlockingNode extends PythonBinaryClinicBuiltinNode { @Specialization - PNone doBoolean(VirtualFrame frame, PSocket socket, boolean blocking, + static PNone doBoolean(VirtualFrame frame, PSocket socket, boolean blocking, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.setBlocking(getPosixSupport(), socket.getFd(), blocking); + posixLib.setBlocking(context.getPosixSupport(), socket.getFd(), blocking); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -982,15 +997,16 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class SetTimeoutNode extends PythonBinaryBuiltinNode { @Specialization - Object setTimeout(VirtualFrame frame, PSocket socket, Object seconds, + static Object setTimeout(VirtualFrame frame, PSocket socket, Object seconds, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached SocketNodes.ParseTimeoutNode parseTimeoutNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { long timeout = parseTimeoutNode.execute(frame, inliningTarget, seconds); socket.setTimeoutNs(timeout); try { - posixLib.setBlocking(getPosixSupport(), socket.getFd(), timeout < 0); + posixLib.setBlocking(context.getPosixSupport(), socket.getFd(), timeout < 0); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1004,12 +1020,13 @@ Object setTimeout(VirtualFrame frame, PSocket socket, Object seconds, @GenerateNodeFactory abstract static class ShutdownNode extends PythonBinaryClinicBuiltinNode { @Specialization - Object shutdown(VirtualFrame frame, PSocket socket, int how, + static Object shutdown(VirtualFrame frame, PSocket socket, int how, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { - posixLib.shutdown(getPosixSupport(), socket.getFd(), how); + posixLib.shutdown(context.getPosixSupport(), socket.getFd(), how); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1081,8 +1098,9 @@ int detach(PSocket socket) { abstract static class SetSockOptNode extends PythonClinicBuiltinNode { @Specialization(guards = "isNoValue(none)") static Object setInt(VirtualFrame frame, PSocket socket, int level, int option, Object value, @SuppressWarnings("unused") PNone none, + @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Bind("this") Node inliningTarget, @@ -1106,7 +1124,7 @@ static Object setInt(VirtualFrame frame, PSocket socket, int level, int option, } try { - posixLib.setsockopt(PosixSupport.get(inliningTarget), socket.getFd(), level, option, bytes, len); + posixLib.setsockopt(context.getPosixSupport(), socket.getFd(), level, option, bytes, len); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1115,7 +1133,8 @@ static Object setInt(VirtualFrame frame, PSocket socket, int level, int option, @Specialization(guards = "isNone(none)") static Object setNull(VirtualFrame frame, PSocket socket, int level, int option, @SuppressWarnings("unused") PNone none, Object buflenObj, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Exclusive @Cached PyLongAsIntNode asIntNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @@ -1126,7 +1145,7 @@ static Object setNull(VirtualFrame frame, PSocket socket, int level, int option, throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.SETSECKOPT_BUFF_OUT_OFRANGE); } try { - posixLib.setsockopt(PosixSupport.get(inliningTarget), socket.getFd(), level, option, null, buflen); + posixLib.setsockopt(context.getPosixSupport(), socket.getFd(), level, option, null, buflen); } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } @@ -1153,21 +1172,21 @@ protected ArgumentClinicProvider getArgumentClinic() { @GenerateNodeFactory abstract static class GetSockOptNode extends PythonQuaternaryClinicBuiltinNode { @Specialization - Object getSockOpt(VirtualFrame frame, PSocket socket, int level, int option, int buflen, + static Object getSockOpt(VirtualFrame frame, PSocket socket, int level, int option, int buflen, @Bind("this") Node inliningTarget, - @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, + @Bind PythonContext context, + @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { if (buflen == 0) { byte[] result = new byte[4]; - posixLib.getsockopt(getPosixSupport(), socket.getFd(), level, option, result, result.length); + posixLib.getsockopt(context.getPosixSupport(), socket.getFd(), level, option, result, result.length); return PythonUtils.ARRAY_ACCESSOR.getInt(result, 0); } else if (buflen > 0 && buflen < 1024) { byte[] result = new byte[buflen]; - int len = posixLib.getsockopt(getPosixSupport(), socket.getFd(), level, option, result, result.length); - return factory.createBytes(result, len); + int len = posixLib.getsockopt(context.getPosixSupport(), socket.getFd(), level, option, result, result.length); + return PFactory.createBytes(context.getLanguage(inliningTarget), result, len); } else { throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.GETSECKOPT_BUFF_OUT_OFRANGE); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java index db3af25fef..e6aad3fbcc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -62,6 +62,7 @@ import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; @@ -97,7 +98,7 @@ import com.oracle.graal.python.runtime.PosixSupportLibrary.UnsupportedPosixFeatureException; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.TimeUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -394,7 +395,6 @@ public abstract static class MakeSockAddrNode extends Node { static Object makeSockAddr(VirtualFrame frame, Node inliningTarget, UniversalSockAddr addr, @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, @CachedLibrary("addr") UniversalSockAddrLibrary addrLib, - @Cached(inline = false) PythonObjectFactory factory, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, @Cached(inline = false) TruffleString.FromByteArrayNode fromByteArrayNode, @@ -402,23 +402,24 @@ static Object makeSockAddr(VirtualFrame frame, Node inliningTarget, UniversalSoc @Cached PRaiseNode.Lazy raiseNode) { try { PythonContext context = PythonContext.get(inliningTarget); + PythonLanguage language = context.getLanguage(inliningTarget); int family = addrLib.getFamily(addr); if (family == AF_INET.value) { Inet4SockAddr inet4SockAddr = addrLib.asInet4SockAddr(addr); Object posixSupport = context.getPosixSupport(); TruffleString addressString = posixLib.getPathAsString(posixSupport, posixLib.inet_ntop(posixSupport, family, inet4SockAddr.getAddressAsBytes())); - return factory.createTuple(new Object[]{addressString, inet4SockAddr.getPort()}); + return PFactory.createTuple(language, new Object[]{addressString, inet4SockAddr.getPort()}); } else if (family == AF_INET6.value) { Inet6SockAddr inet6SockAddr = addrLib.asInet6SockAddr(addr); Object posixSupport = context.getPosixSupport(); TruffleString addressString = posixLib.getPathAsString(posixSupport, posixLib.inet_ntop(posixSupport, family, inet6SockAddr.getAddress())); - return factory.createTuple(new Object[]{addressString, inet6SockAddr.getPort(), inet6SockAddr.getFlowInfo(), inet6SockAddr.getScopeId()}); + return PFactory.createTuple(language, new Object[]{addressString, inet6SockAddr.getPort(), inet6SockAddr.getFlowInfo(), inet6SockAddr.getScopeId()}); } else if (family == AF_UNIX.value) { UnixSockAddr unixSockAddr = addrLib.asUnixSockAddr(addr); byte[] path = unixSockAddr.getPath(); if (PosixConstants.IS_LINUX && path.length > 0 && path[0] == 0) { // linux-specific "abstract" address - return factory.createBytes(arrayCopyOf(path, path.length)); + return PFactory.createBytes(language, arrayCopyOf(path, path.length)); } return bytesToString(path, fromByteArrayNode, switchEncodingNode); } else if (family == AF_UNSPEC.value) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java index 76902ffaf2..f0a7459c18 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -101,6 +101,7 @@ import org.bouncycastle.pkcs.PKCSException; import org.bouncycastle.util.encoders.DecoderException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; import com.oracle.graal.python.builtins.objects.dict.PDict; @@ -108,8 +109,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.strings.TruffleString; @@ -186,19 +186,19 @@ static boolean isCrl(boolean[] keyUsage) { * _ssl.c#_decode_certificate */ @TruffleBoundary - public static PDict decodeCertificate(PythonObjectSlowPathFactory factory, X509Certificate cert) throws CertificateParsingException { - PDict dict = factory.createDict(); + public static PDict decodeCertificate(X509Certificate cert, PythonLanguage language) throws CertificateParsingException { + PDict dict = PFactory.createDict(language); HashingStorage storage = dict.getDictStorage(); try { - storage = setItem(storage, T_JAVA_X509_OCSP, parseOCSP(cert, factory)); - storage = setItem(storage, T_JAVA_X509_CA_ISSUERS, parseCAIssuers(cert, factory)); - storage = setItem(storage, T_JAVA_X509_ISSUER, createTupleForX509Name(cert.getIssuerX500Principal().getName("RFC1779"), factory)); + storage = setItem(storage, T_JAVA_X509_OCSP, parseOCSP(cert, language)); + storage = setItem(storage, T_JAVA_X509_CA_ISSUERS, parseCAIssuers(cert, language)); + storage = setItem(storage, T_JAVA_X509_ISSUER, createTupleForX509Name(cert.getIssuerX500Principal().getName("RFC1779"), language)); storage = setItem(storage, T_JAVA_X509_NOT_AFTER, getNotAfter(cert)); storage = setItem(storage, T_JAVA_X509_NOT_BEFORE, getNotBefore(cert)); storage = setItem(storage, T_JAVA_X509_SERIAL_NUMBER, getSerialNumber(cert)); - storage = setItem(storage, T_JAVA_X509_CRL_DISTRIBUTION_POINTS, parseCRLPoints(cert, factory)); - storage = setItem(storage, T_JAVA_X509_SUBJECT, createTupleForX509Name(cert.getSubjectX500Principal().getName("RFC1779"), factory)); - storage = setItem(storage, T_JAVA_X509_SUBJECT_ALT_NAME, parseSubjectAltName(cert, factory)); + storage = setItem(storage, T_JAVA_X509_CRL_DISTRIBUTION_POINTS, parseCRLPoints(cert, language)); + storage = setItem(storage, T_JAVA_X509_SUBJECT, createTupleForX509Name(cert.getSubjectX500Principal().getName("RFC1779"), language)); + storage = setItem(storage, T_JAVA_X509_SUBJECT_ALT_NAME, parseSubjectAltName(cert, language)); storage = setItem(storage, T_JAVA_X509_VERSION, getVersion(cert)); } catch (RuntimeException re) { throw PConstructAndRaiseNode.raiseUncachedSSLError(SSLErrorCode.ERROR_SSL, re); @@ -246,23 +246,23 @@ private static TruffleString formatDate(Date d) { } @TruffleBoundary - private static PTuple createTupleForX509Name(String name, PythonObjectFactory factory) { + private static PTuple createTupleForX509Name(String name, PythonLanguage language) { List result = new ArrayList<>(); for (String component : name.split(",")) { String[] kv = component.split("="); if (kv.length == 2) { - PTuple innerTuple = factory.createTuple(new Object[]{ASN1Helper.translateKeyToPython(kv[0].trim()), toTruffleStringUncached(kv[1].trim())}); - result.add(factory.createTuple(new Object[]{innerTuple})); + PTuple innerTuple = PFactory.createTuple(language, new Object[]{ASN1Helper.translateKeyToPython(kv[0].trim()), toTruffleStringUncached(kv[1].trim())}); + result.add(PFactory.createTuple(language, new Object[]{innerTuple})); } } // The String form is in the LDAP format, where the elements are in reverse order from what // was in the certificate Collections.reverse(result); - return factory.createTuple(result.toArray(new Object[0])); + return PFactory.createTuple(language, result.toArray(new Object[0])); } @TruffleBoundary - private static PTuple parseSubjectAltName(X509Certificate certificate, PythonObjectFactory factory) throws CertificateParsingException { + private static PTuple parseSubjectAltName(X509Certificate certificate, PythonLanguage language) throws CertificateParsingException { List tuples = new ArrayList<>(16); Collection> altNames = certificate.getSubjectAlternativeNames(); if (altNames != null) { @@ -279,38 +279,39 @@ private static PTuple parseSubjectAltName(X509Certificate certificate, PythonObj switch (type) { // see openssl v3_alt.c#i2v_GENERAL_NAME() case 0: - tuples.add(factory.createTuple(new Object[]{T_OTHERNAME, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_OTHERNAME, stringValue})); break; case 1: - tuples.add(factory.createTuple(new Object[]{T_EMAIL, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_EMAIL, stringValue})); break; case 2: - tuples.add(factory.createTuple(new Object[]{T_DNS, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_DNS, stringValue})); break; case 3: - tuples.add(factory.createTuple(new Object[]{T_X_400_NAME, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_X_400_NAME, stringValue})); break; case 4: - tuples.add(factory.createTuple(new Object[]{T_DIR_NAME, value instanceof String ? createTupleForX509Name((String) value, factory) : factory.createEmptyTuple()})); + tuples.add(PFactory.createTuple(language, + new Object[]{T_DIR_NAME, value instanceof String ? createTupleForX509Name((String) value, language) : PFactory.createEmptyTuple(language)})); break; case 5: - tuples.add(factory.createTuple(new Object[]{T_EDI_PARTY_NAME, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_EDI_PARTY_NAME, stringValue})); break; case 6: - tuples.add(factory.createTuple(new Object[]{T_URI, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_URI, stringValue})); break; case 7: - tuples.add(factory.createTuple(new Object[]{T_IP_ADDRESS, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_IP_ADDRESS, stringValue})); break; case 8: - tuples.add(factory.createTuple(new Object[]{T_REGISTERED_ID, stringValue})); + tuples.add(PFactory.createTuple(language, new Object[]{T_REGISTERED_ID, stringValue})); break; default: continue; } } } - return factory.createTuple(tuples.toArray(new Object[tuples.size()])); + return PFactory.createTuple(language, tuples.toArray(new Object[tuples.size()])); } return null; } @@ -464,7 +465,7 @@ void iterateSequence(DerSequenceConsumer consumer, T value) thr } @TruffleBoundary - private static PTuple parseCRLPoints(X509Certificate cert, PythonObjectFactory factory) throws CertificateParsingException { + private static PTuple parseCRLPoints(X509Certificate cert, PythonLanguage language) throws CertificateParsingException { List result = new ArrayList<>(); byte[] bytes = cert.getExtensionValue(OID_CRL_DISTRIBUTION_POINTS); if (bytes == null) { @@ -502,14 +503,14 @@ private static PTuple parseCRLPoints(X509Certificate cert, PythonObjectFactory f } }, result); if (result.size() > 0) { - return factory.createTuple(result.toArray(new Object[result.size()])); + return PFactory.createTuple(language, result.toArray(new Object[result.size()])); } else { return null; } } @TruffleBoundary - private static PTuple parseCAIssuers(X509Certificate cert, PythonObjectFactory factory) throws CertificateParsingException { + private static PTuple parseCAIssuers(X509Certificate cert, PythonLanguage language) throws CertificateParsingException { List result = new ArrayList<>(); byte[] bytes = cert.getExtensionValue(OID_AUTHORITY_INFO_ACCESS); if (bytes == null) { @@ -538,14 +539,14 @@ private static PTuple parseCAIssuers(X509Certificate cert, PythonObjectFactory f } }, result); if (result.size() > 0) { - return factory.createTuple(result.toArray(new Object[result.size()])); + return PFactory.createTuple(language, result.toArray(new Object[result.size()])); } else { return null; } } @TruffleBoundary - private static PTuple parseOCSP(X509Certificate cert, PythonObjectFactory factory) throws CertificateParsingException { + private static PTuple parseOCSP(X509Certificate cert, PythonLanguage language) throws CertificateParsingException { List result = new ArrayList<>(); byte[] bytes = cert.getExtensionValue(OID_AUTHORITY_INFO_ACCESS); if (bytes == null) { @@ -574,7 +575,7 @@ private static PTuple parseOCSP(X509Certificate cert, PythonObjectFactory factor } }, result); if (result.size() > 0) { - return factory.createTuple(result.toArray(new Object[result.size()])); + return PFactory.createTuple(language, result.toArray(new Object[result.size()])); } else { return null; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java index b4c0a6403a..969e572c33 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +45,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -53,6 +54,7 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary; import com.oracle.graal.python.builtins.objects.bytes.PBytes; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -60,7 +62,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -83,8 +85,9 @@ protected List> getNodeFa abstract static class MemoryBIONode extends PythonUnaryBuiltinNode { @Specialization static PMemoryBIO create(Object type, - @Cached PythonObjectFactory factory) { - return factory.createMemoryBIO(type); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + return PFactory.createMemoryBIO(language, type, getInstanceShape.execute(type)); } } @@ -112,9 +115,9 @@ static boolean eof(PMemoryBIO self) { abstract static class ReadNode extends PythonBinaryClinicBuiltinNode { @Specialization static PBytes read(PMemoryBIO self, int size, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { int len = size >= 0 ? size : Integer.MAX_VALUE; - return factory.createBytes(self.read(len)); + return PFactory.createBytes(language, self.read(len)); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java index 7902bad812..786ec73cf6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java @@ -78,6 +78,7 @@ import org.bouncycastle.util.encoders.DecoderException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -101,6 +102,7 @@ import com.oracle.graal.python.builtins.objects.ssl.CertUtils.NeedsPasswordException; import com.oracle.graal.python.builtins.objects.ssl.CertUtils.NoCertificateFoundException; import com.oracle.graal.python.builtins.objects.str.StringNodes; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyCallableCheckNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyNumberIndexNode; @@ -127,7 +129,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.IPAddressUtil; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -165,8 +167,9 @@ abstract static class SSLContextNode extends PythonBinaryClinicBuiltinNode { @Specialization static PSSLContext createContext(VirtualFrame frame, Object type, int protocol, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { SSLMethod method = SSLMethod.fromPythonId(protocol); if (method == null) { @@ -182,7 +185,8 @@ static PSSLContext createContext(VirtualFrame frame, Object type, int protocol, checkHostname = false; verifyMode = SSLModuleBuiltins.SSL_CERT_NONE; } - PSSLContext context = factory.createSSLContext(type, method, SSLModuleBuiltins.X509_V_FLAG_TRUSTED_FIRST, checkHostname, verifyMode, createSSLContext()); + PSSLContext context = PFactory.createSSLContext(language, type, getInstanceShape.execute(type), method, SSLModuleBuiltins.X509_V_FLAG_TRUSTED_FIRST, checkHostname, verifyMode, + createSSLContext()); long options = SSLOptions.SSL_OP_ALL; if (method != SSLMethod.SSL3) { options |= SSLOptions.SSL_OP_NO_SSLv3; @@ -284,15 +288,15 @@ abstract static class WrapSocketNode extends PythonClinicBuiltinNode { @Specialization static Object wrap(PSSLContext context, PSocket sock, boolean serverSide, Object serverHostnameObj, Object owner, @SuppressWarnings("unused") PNone session, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached StringNodes.CastToTruffleStringCheckedNode cast, - @Cached TruffleString.ToJavaStringNode toJavaStringNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleString.ToJavaStringNode toJavaStringNode) { TruffleString serverHostname = null; if (!(serverHostnameObj instanceof PNone)) { serverHostname = cast.cast(inliningTarget, serverHostnameObj, ErrorMessages.S_MUST_BE_NONE_OR_STRING, "serverHostname", serverHostnameObj); } SSLEngine engine = createSSLEngine(inliningTarget, context, serverSide, serverHostname == null ? null : toJavaStringNode.execute(serverHostname)); - PSSLSocket sslSocket = factory.createSSLSocket(PythonBuiltinClassType.PSSLSocket, context, engine, sock); + PSSLSocket sslSocket = PFactory.createSSLSocket(language, context, engine, sock); if (!(owner instanceof PNone)) { sslSocket.setOwner(owner); } @@ -321,15 +325,15 @@ abstract static class WrapBIONode extends PythonClinicBuiltinNode { static Object wrap(PSSLContext context, PMemoryBIO incoming, PMemoryBIO outgoing, boolean serverSide, Object serverHostnameObj, Object owner, @SuppressWarnings("unused") PNone session, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached StringNodes.CastToTruffleStringCheckedNode cast, - @Cached TruffleString.ToJavaStringNode toJavaStringNode, - @Cached PythonObjectFactory factory) { + @Cached TruffleString.ToJavaStringNode toJavaStringNode) { TruffleString serverHostname = null; if (!(serverHostnameObj instanceof PNone)) { serverHostname = cast.cast(inliningTarget, serverHostnameObj, ErrorMessages.S_MUST_BE_NONE_OR_STRING, "serverHostname", serverHostnameObj); } SSLEngine engine = createSSLEngine(inliningTarget, context, serverSide, serverHostname == null ? null : toJavaStringNode.execute(serverHostname)); - PSSLSocket sslSocket = factory.createSSLSocket(PythonBuiltinClassType.PSSLSocket, context, engine, incoming, outgoing); + PSSLSocket sslSocket = PFactory.createSSLSocket(language, context, engine, incoming, outgoing); if (!(owner instanceof PNone)) { sslSocket.setOwner(owner); } @@ -517,13 +521,14 @@ static Object set(VirtualFrame frame, PSSLContext self, Object obj, abstract static class GetCiphersNode extends PythonUnaryBuiltinNode { @Specialization @TruffleBoundary - static PList getCiphers(PSSLContext self) { + static PList getCiphers(PSSLContext self, + @Bind PythonLanguage language) { List ciphers = self.computeEnabledCiphers(self.getContext().createSSLEngine()); Object[] dicts = new Object[ciphers.size()]; for (int i = 0; i < dicts.length; i++) { - dicts[i] = PythonObjectFactory.getUncached().createDict(ciphers.get(i).asKeywords()); + dicts[i] = PFactory.createDict(language, ciphers.get(i).asKeywords()); } - return PythonObjectFactory.getUncached().createList(dicts); + return PFactory.createList(language, dicts); } } @@ -641,13 +646,13 @@ Object set(VirtualFrame frame, PSSLContext self, @NeverDefault @TruffleBoundary protected PBytes createCertFileKey() { - return PythonObjectFactory.getUncached().createBytes("SSL_CERT_FILE".getBytes()); + return PFactory.createBytes(PythonLanguage.get(null), "SSL_CERT_FILE".getBytes()); } @NeverDefault @TruffleBoundary protected PBytes createCertDirKey() { - return PythonObjectFactory.getUncached().createBytes("SSL_CERT_DIR".getBytes()); + return PFactory.createBytes(PythonLanguage.get(null), "SSL_CERT_DIR".getBytes()); } @NeverDefault @@ -683,8 +688,8 @@ abstract static class CertStoreStatsNode extends PythonUnaryBuiltinNode { @Specialization static Object storeStats(VirtualFrame frame, PSSLContext self, @Bind("this") Node inliningTarget, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { int x509 = 0, crl = 0, ca = 0; for (X509Certificate cert : self.getCACerts()) { @@ -698,7 +703,7 @@ static Object storeStats(VirtualFrame frame, PSSLContext self, } } } - return factory.createDict(new PKeyword[]{new PKeyword(T_X509, x509), new PKeyword(T_CRL, crl), new PKeyword(T_X509_CA, ca)}); + return PFactory.createDict(language, new PKeyword[]{new PKeyword(T_X509, x509), new PKeyword(T_CRL, crl), new PKeyword(T_X509_CA, ca)}); } catch (Exception ex) { throw constructAndRaiseNode.get(inliningTarget).raiseSSLError(frame, SSLErrorCode.ERROR_SSL, ex); } @@ -1056,16 +1061,16 @@ abstract static class GetCACerts extends PythonBinaryClinicBuiltinNode { @Specialization(guards = "!binary_form") Object getCerts(VirtualFrame frame, PSSLContext self, @SuppressWarnings("unused") boolean binary_form, @Bind("this") Node inliningTarget, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { try { List result = PythonUtils.newList(); for (X509Certificate cert : self.getCACerts()) { if (CertUtils.isCA(cert, CertUtils.getKeyUsage(cert))) { - PythonUtils.add(result, CertUtils.decodeCertificate(getContext().factory(), cert)); + PythonUtils.add(result, CertUtils.decodeCertificate(cert, language)); } } - return factory.createList(PythonUtils.toArray(result)); + return PFactory.createList(language, PythonUtils.toArray(result)); } catch (KeyStoreException | NoSuchAlgorithmException | CertificateParsingException ex) { throw constructAndRaiseNode.get(inliningTarget).raiseSSLError(frame, SSLErrorCode.ERROR_SSL, ex); } @@ -1073,15 +1078,15 @@ Object getCerts(VirtualFrame frame, PSSLContext self, @SuppressWarnings("unused" @Specialization(guards = "binary_form") static Object getCertsBinary(PSSLContext self, @SuppressWarnings("unused") boolean binary_form, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { try { List result = PythonUtils.newList(); for (X509Certificate cert : self.getCACerts()) { if (CertUtils.isCA(cert, CertUtils.getKeyUsage(cert))) { - PythonUtils.add(result, factory.createBytes(CertUtils.getEncoded(cert))); + PythonUtils.add(result, PFactory.createBytes(language, CertUtils.getEncoded(cert))); } } - return factory.createList(PythonUtils.toArray(result)); + return PFactory.createList(language, PythonUtils.toArray(result)); } catch (KeyStoreException | NoSuchAlgorithmException | CertificateEncodingException ex) { throw PConstructAndRaiseNode.raiseUncachedSSLError(SSLErrorCode.ERROR_SSL, ex); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java index 4347b6ea97..e07cf6ab3e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -65,7 +65,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -85,7 +84,7 @@ public final class SSLErrorBuiltins extends PythonBuiltins { static final int IDX_VERIFY_MESSAGE = IDX_WRITTEN + 4; static final int SSL_ERR_NUM_ATTRS = IDX_VERIFY_MESSAGE + 1; - public static final BaseExceptionAttrNode.StorageFactory SSL_ERROR_ATTR_FACTORY = (args, factory) -> new Object[SSL_ERR_NUM_ATTRS]; + public static final BaseExceptionAttrNode.StorageFactory SSL_ERROR_ATTR_FACTORY = (args) -> new Object[SSL_ERR_NUM_ATTRS]; public static final TruffleString T_SSL_IN_BRACKETS = tsLiteral("[SSL]"); @Override @@ -123,10 +122,9 @@ public abstract static class SSLErrorInitNode extends PythonBuiltinNode { @Specialization static Object init(VirtualFrame frame, PBaseException self, Object[] args, PKeyword[] kwds, - @Cached OsErrorBuiltins.OSErrorInitNode initNode, - @Cached PythonObjectFactory factory) { + @Cached OsErrorBuiltins.OSErrorInitNode initNode) { initNode.execute(frame, self, args, kwds); - Object[] sslAttrs = SSL_ERROR_ATTR_FACTORY.create(args, factory); + Object[] sslAttrs = SSL_ERROR_ATTR_FACTORY.create(args); PythonUtils.arraycopy(self.getExceptionAttributes(), 0, sslAttrs, 0, self.getExceptionAttributes().length); self.setExceptionAttributes(sslAttrs); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java index 1acb11c3bf..8854f325f5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -57,6 +57,7 @@ import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -75,8 +76,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -104,18 +104,18 @@ abstract static class ReadNode extends PythonTernaryClinicBuiltinNode { @Specialization(guards = "isNoValue(buffer)") static Object read(VirtualFrame frame, PSSLSocket self, int len, @SuppressWarnings("unused") PNone buffer, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Shared @Cached SSLOperationNode sslOperationNode, - @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (len == 0) { - return factory.createBytes(new byte[0]); + return PFactory.createBytes(language, new byte[0]); } else if (len < 0) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SIZE_SHOULD_NOT_BE_NEGATIVE); } ByteBuffer output = PythonUtils.allocateByteBuffer(len); sslOperationNode.read(frame, inliningTarget, self, output); PythonUtils.flipBuffer(output); - return factory.createBytes(PythonUtils.getBufferArray(output), PythonUtils.getBufferLimit(output)); + return PFactory.createBytes(language, PythonUtils.getBufferArray(output), PythonUtils.getBufferLimit(output)); } @Specialization(guards = "!isNoValue(bufferObj)", limit = "3") @@ -316,7 +316,7 @@ abstract static class GetPeerCertNode extends PythonBinaryClinicBuiltinNode { @Specialization(guards = "der") static Object getPeerCertDER(PSSLSocket self, @SuppressWarnings("unused") boolean der, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory.Lazy factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (!self.isHandshakeComplete()) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); @@ -324,7 +324,7 @@ static Object getPeerCertDER(PSSLSocket self, @SuppressWarnings("unused") boolea Certificate certificate = getCertificate(self.getEngine()); if (certificate != null) { try { - return factory.get(inliningTarget).createBytes(getEncoded(certificate)); + return PFactory.createBytes(language, getEncoded(certificate)); } catch (CertificateEncodingException e) { // Fallthrough } @@ -337,7 +337,7 @@ static Object getPeerCertDER(PSSLSocket self, @SuppressWarnings("unused") boolea @Specialization(guards = "!der") static PDict getPeerCertDict(PSSLSocket self, @SuppressWarnings("unused") boolean der, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory.Lazy factory, + @Bind PythonLanguage language, @Shared @Cached PRaiseNode.Lazy raiseNode) { if (!self.isHandshakeComplete()) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); @@ -345,12 +345,12 @@ static PDict getPeerCertDict(PSSLSocket self, @SuppressWarnings("unused") boolea Certificate certificate = getCertificate(self.getEngine()); if (certificate instanceof X509Certificate) { try { - return CertUtils.decodeCertificate(PythonContext.get(inliningTarget).factory(), (X509Certificate) certificate); + return CertUtils.decodeCertificate((X509Certificate) certificate, language); } catch (CertificateParsingException e) { - return factory.get(inliningTarget).createDict(); + return PFactory.createDict(language); } } - return factory.get(inliningTarget).createDict(); + return PFactory.createDict(language); } @TruffleBoundary @@ -403,7 +403,7 @@ protected ArgumentClinicProvider getArgumentClinic() { abstract static class CipherNode extends PythonUnaryBuiltinNode { @Specialization static Object getCipher(PSSLSocket self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (!self.isHandshakeComplete()) { return PNone.NONE; } @@ -411,7 +411,7 @@ static Object getCipher(PSSLSocket self, if (cipher == null) { return PNone.NONE; } - return factory.createTuple(new Object[]{cipher.getOpensslName(), cipher.getProtocol(), cipher.getStrengthBits()}); + return PFactory.createTuple(language, new Object[]{cipher.getOpensslName(), cipher.getProtocol(), cipher.getStrengthBits()}); } @TruffleBoundary @@ -434,13 +434,14 @@ Object get(PSSLSocket socket) { if (!socket.isHandshakeComplete()) { return PNone.NONE; } + PythonLanguage language = PythonLanguage.get(null); List ciphers = socket.getContext().computeEnabledCiphers(socket.getEngine()); Object[] result = new Object[ciphers.size()]; for (int i = 0; i < ciphers.size(); i++) { SSLCipher cipher = ciphers.get(i); - result[i] = PythonObjectFactory.getUncached().createTuple(new Object[]{cipher.getOpensslName(), cipher.getProtocol(), cipher.getStrengthBits()}); + result[i] = PFactory.createTuple(language, new Object[]{cipher.getOpensslName(), cipher.getProtocol(), cipher.getStrengthBits()}); } - return PythonObjectFactory.getUncached().createList(result); + return PFactory.createList(language, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java index a94ccb4f20..effbd08d93 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java @@ -166,7 +166,7 @@ import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; import com.oracle.graal.python.runtime.formatting.StringFormatProcessor; import com.oracle.graal.python.runtime.formatting.TextFormatter; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ComparisonOp; import com.oracle.graal.python.util.IntPredicate; import com.oracle.truffle.api.CompilerAsserts; @@ -356,13 +356,13 @@ public abstract static class GetNewargsNode extends PythonUnaryBuiltinNode { @Specialization PTuple doGeneric(Object self, @Bind("this") Node inliningTarget, - @Cached CastToTruffleStringCheckedNode cast, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached CastToTruffleStringCheckedNode cast) { TruffleString selfStr = cast.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___GETNEWARGS__, self); // CPython requires the resulting string not to be the same object as the original for // some reason - PString copy = factory.createString(selfStr); - return factory.createTuple(new Object[]{copy}); + PString copy = PFactory.createString(language, selfStr); + return PFactory.createTuple(language, new Object[]{copy}); } } @@ -956,7 +956,6 @@ static PDict doString(VirtualFrame frame, Object cls, Object from, Object to, Ob @Cached TruffleStringIterator.NextNode nextNode, @Cached InlinedConditionProfile hasZProfile, @Exclusive @Cached HashingStorageSetItem setHashingStorageItem, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { TruffleString toStr = castToNode.cast(inliningTarget, to, ErrorMessages.ARG_S_MUST_BE_S_NOT_P, "2", "str", to); @@ -988,7 +987,7 @@ static PDict doString(VirtualFrame frame, Object cls, Object from, Object to, Ob storage = setHashingStorageItem.execute(frame, inliningTarget, storage, key, PNone.NONE); } } - return factory.createDict(storage); + return PFactory.createDict(PythonLanguage.get(inliningTarget), storage); } @Specialization(guards = {"isNoValue(to)", "isNoValue(z)"}) @@ -1004,7 +1003,6 @@ static PDict doDict(VirtualFrame frame, Object cls, PDict from, Object to, Objec @Cached HashingStorageIteratorNext iterHasNext, @Cached HashingStorageIteratorKey iterKey, @Cached HashingStorageIteratorValue iterValue, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { HashingStorage srcStorage = from.getDictStorage(); HashingStorage destStorage = PDict.createNewStorage(lenNode.execute(inliningTarget, srcStorage)); @@ -1023,7 +1021,7 @@ static PDict doDict(VirtualFrame frame, Object cls, PDict from, Object to, Objec destStorage = setHashingStorageItem.execute(frame, inliningTarget, destStorage, codePoint, currentValue); } } - return factory.createDict(destStorage); + return PFactory.createDict(PythonLanguage.get(inliningTarget), destStorage); } @Specialization(guards = {"!isDict(from)", "isNoValue(to)"}) @@ -1152,7 +1150,6 @@ static PTuple doGeneric(Object self, Object sep, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfStringNode indexOfStringNode, @Cached TruffleString.SubstringNode substringNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { TruffleString selfStr = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "partition", self); TruffleString sepStr = castSepNode.cast(inliningTarget, sep, ErrorMessages.MUST_BE_STR_NOT_P, sep); @@ -1172,7 +1169,7 @@ static PTuple doGeneric(Object self, Object sep, partitioned[1] = sepStr; partitioned[2] = substringNode.execute(selfStr, o, selfLen - o, TS_ENCODING, false); } - return factory.createTuple(partitioned); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), partitioned); } } @@ -1189,7 +1186,6 @@ static Object doGeneric(Object self, Object sep, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.LastIndexOfStringNode lastIndexOfStringNode, @Cached TruffleString.SubstringNode substringNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { TruffleString selfStr = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "rpartition", self); TruffleString sepStr = castSepNode.cast(inliningTarget, sep, ErrorMessages.MUST_BE_STR_NOT_P, sep); @@ -1209,7 +1205,7 @@ static Object doGeneric(Object self, Object sep, partitioned[1] = sepStr; partitioned[2] = substringNode.execute(selfStr, o, selfLen - o, TS_ENCODING, false); } - return factory.createTuple(partitioned); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), partitioned); } } @@ -1232,9 +1228,8 @@ static PList doStringNoSep(TruffleString self, PNone sep, int maxsplit, @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Shared("substring") @Cached TruffleString.SubstringNode substringNode, - @Shared("appendNode") @Cached AppendNode appendNode, - @Shared @Cached PythonObjectFactory factory) { - return splitfields(self, maxsplit, appendNode, codePointLengthNode, codePointAtIndexNode, substringNode, factory); + @Shared("appendNode") @Cached AppendNode appendNode) { + return splitfields(self, maxsplit, appendNode, codePointLengthNode, codePointAtIndexNode, substringNode); } @Specialization @@ -1244,14 +1239,13 @@ static PList doStringSep(TruffleString self, TruffleString sep, int maxsplit, @Cached TruffleString.IndexOfStringNode indexOfStringNode, @Shared("substring") @Cached TruffleString.SubstringNode substringNode, @Shared("appendNode") @Cached AppendNode appendNode, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (sep.isEmpty()) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); } int splits = maxsplit == -1 ? Integer.MAX_VALUE : maxsplit; - PList list = factory.createList(); + PList list = PFactory.createList(PythonLanguage.get(inliningTarget)); int lastEnd = 0; int selfLen = codePointLengthNode.execute(self, TS_ENCODING); int sepLen = codePointLengthNode.execute(sep, TS_ENCODING); @@ -1271,12 +1265,12 @@ static PList doStringSep(TruffleString self, TruffleString sep, int maxsplit, // See {@link PyString} private static PList splitfields(TruffleString s, int maxsplit, AppendNode appendNode, TruffleString.CodePointLengthNode codePointLengthNode, TruffleString.CodePointAtIndexNode codePointAtIndexNode, - TruffleString.SubstringNode substringNode, PythonObjectFactory factory) { + TruffleString.SubstringNode substringNode) { /* * Result built here is a list of split parts, exactly as required for s.split(None, * maxsplit). If there are to be n splits, there will be n+1 elements in L. */ - PList list = factory.createList(); + PList list = PFactory.createList(PythonLanguage.get(appendNode)); int length = codePointLengthNode.execute(s, TS_ENCODING); int start = 0; int splits = 0; @@ -1350,7 +1344,6 @@ static PList doStringSepMaxsplit(VirtualFrame frame, TruffleString self, Truffle @Shared("cpLen") @Cached CodePointLengthNode codePointLengthNode, @Cached TruffleString.LastIndexOfStringNode lastIndexOfStringNode, @Shared @Cached TruffleString.SubstringNode substringNode, - @Shared @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { if (sep.isEmpty()) { throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); @@ -1359,7 +1352,7 @@ static PList doStringSepMaxsplit(VirtualFrame frame, TruffleString self, Truffle if (maxsplitInput < 0) { maxsplit = Integer.MAX_VALUE; } - PList list = factory.createList(); + PList list = PFactory.createList(PythonLanguage.get(inliningTarget)); int splits = 0; int end = codePointLengthNode.execute(self, TS_ENCODING); int sepLength = codePointLengthNode.execute(sep, TS_ENCODING); @@ -1382,17 +1375,17 @@ static PList doStringSepMaxsplit(VirtualFrame frame, TruffleString self, Truffle @Specialization static PList doStringMaxsplit(VirtualFrame frame, TruffleString s, @SuppressWarnings("unused") PNone sep, int maxsplit, + @Bind("this") Node inliningTarget, @Shared("appendNode") @Cached AppendNode appendNode, @Shared("reverseNode") @Cached ListReverseNode reverseNode, @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Shared @Cached TruffleString.SubstringNode substringNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached TruffleString.SubstringNode substringNode) { /* * Result built here is a list of split parts, exactly as required for s.split(None, * maxsplit). If there are to be n splits, there will be n+1 elements in L. */ - PList list = factory.createList(); + PList list = PFactory.createList(PythonLanguage.get(inliningTarget)); int length = codePointLengthNode.execute(s, TS_ENCODING); int maxsplit2 = maxsplit; @@ -1441,19 +1434,17 @@ public abstract static class SplitLinesNode extends PythonBinaryBuiltinNode { static PList doString(TruffleString self, @SuppressWarnings("unused") PNone keepends, @Shared("ts2js") @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared @Cached AppendNode appendNode, - @Shared @Cached PythonObjectFactory factory) { - return doStringKeepends(self, false, toJavaStringNode, fromJavaStringNode, appendNode, factory); + @Shared @Cached AppendNode appendNode) { + return doStringKeepends(self, false, toJavaStringNode, fromJavaStringNode, appendNode); } @Specialization static PList doStringKeepends(TruffleString selfTs, boolean keepends, @Shared("ts2js") @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared @Cached AppendNode appendNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached AppendNode appendNode) { // TODO GR-37218: use TRegex or codepoint iterator + hand-written state machine - PList list = factory.createList(); + PList list = PFactory.createList(PythonLanguage.get(appendNode)); int lastEnd = 0; String self = toJavaStringNode.execute(selfTs); Matcher matcher = getMatcher(self); @@ -1512,11 +1503,10 @@ static PList doGeneric(Object self, Object keepends, @Cached CastToJavaIntExactNode castToJavaIntNode, @Shared("ts2js") @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared @Cached AppendNode appendNode, - @Shared @Cached PythonObjectFactory factory) { + @Shared @Cached AppendNode appendNode) { TruffleString selfStr = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "splitlines", self); boolean bKeepends = !PGuards.isPNone(keepends) && castToJavaIntNode.execute(inliningTarget, keepends) != 0; - return doStringKeepends(selfStr, bKeepends, toJavaStringNode, fromJavaStringNode, appendNode, factory); + return doStringKeepends(selfStr, bKeepends, toJavaStringNode, fromJavaStringNode, appendNode); } } @@ -1787,13 +1777,14 @@ static Object doIt(VirtualFrame frame, Object selfObj, TruffleString encoding, T @Cached CastToTruffleStringCheckedNode castSelfNode, @Cached CodecsModuleBuiltins.EncodeNode encodeNode, @Cached SequenceStorageNodes.CopyNode copyNode, - @Cached PythonObjectFactory.Lazy factory, + @Cached InlinedBranchProfile convertByteArray, @Cached PRaiseNode.Lazy raiseNode) { TruffleString self = castSelfNode.cast(inliningTarget, selfObj, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "index", selfObj); Object result = encodeNode.execute(frame, self, encoding, errors); if (!(result instanceof PBytes)) { if (result instanceof PByteArray) { - return factory.get(inliningTarget).createBytes(copyNode.execute(inliningTarget, ((PByteArray) result).getSequenceStorage())); + convertByteArray.enter(inliningTarget); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), copyNode.execute(inliningTarget, ((PByteArray) result).getSequenceStorage())); } throw raiseNode.get(inliningTarget).raise(TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, result); } @@ -2474,10 +2465,9 @@ public abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static PStringIterator doGeneric(Object self, @Bind("this") Node inliningTarget, - @Cached CastToTruffleStringCheckedNode castSelfNode, - @Cached PythonObjectFactory factory) { + @Cached CastToTruffleStringCheckedNode castSelfNode) { TruffleString string = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___ITER__, self); - return factory.createStringIterator(string); + return PFactory.createStringIterator(PythonLanguage.get(inliningTarget), string); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java index c1bd198c44..0ec5dbffac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -49,6 +49,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsbCapacity; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.bytes.BytesUtils; @@ -77,7 +78,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; @@ -483,9 +484,9 @@ public static PString executeUncached(Object string) { @Specialization static PString doString(Node inliningTarget, TruffleString string, - @Shared @Cached HiddenAttr.WriteNode writeNode, - @Cached(inline = false) PythonObjectFactory factory) { - final PString interned = factory.createString(string); + @Bind PythonLanguage language, + @Shared @Cached HiddenAttr.WriteNode writeNode) { + final PString interned = PFactory.createString(language, string); writeNode.execute(inliningTarget, interned, HiddenAttr.INTERNED, true); return interned; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringUtils.java index 7f6d5fd5de..6127930426 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -49,10 +49,10 @@ import java.util.Locale; import org.graalvm.nativeimage.ImageInfo; - import org.graalvm.shadowed.com.ibm.icu.lang.UCharacter; import org.graalvm.shadowed.com.ibm.icu.lang.UCharacterCategory; import org.graalvm.shadowed.com.ibm.icu.lang.UProperty; + import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; @@ -72,11 +72,6 @@ public final class StringUtils { - /** - * The maximum length of the source string when creating a sing-codepoint substring. - */ - public static final int LAZY_CODEPOINT_THRESHOLD = 20; - public enum StripKind { LEFT, RIGHT, @@ -153,24 +148,6 @@ public static boolean isUnicodeWhitespace(int ch) { } } - public static boolean isUnicodeLineBreak(char ch) { - switch (ch) { - case 0x000A: - case 0x000B: - case 0x000C: - case 0x000D: - case 0x001C: - case 0x001D: - case 0x001E: - case 0x0085: - case 0x2028: - case 0x2029: - return true; - default: - return false; - } - } - public static boolean isSpace(int ch) { if (ch < 128) { return ASCII_WHITESPACE[ch] == 1; @@ -241,19 +218,6 @@ public static TruffleString strip(TruffleString str, TruffleString chars, StripK return substringNode.execute(str, i, j - i, TS_ENCODING, false); } - public static Object[] toCharacterArray(TruffleString arg, TruffleString.CodePointLengthNode codePointLengthNode, TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, - TruffleStringIterator.NextNode nextNode, TruffleString.FromCodePointNode fromCodePointNode) { - Object[] values = new Object[codePointLengthNode.execute(arg, TS_ENCODING)]; - TruffleStringIterator it = createCodePointIteratorNode.execute(arg, TS_ENCODING); - int i = 0; - while (it.hasNext()) { - // TODO: GR-37219: use SubstringNode with lazy=true? - int codePoint = nextNode.execute(it); - values[i++] = fromCodePointNode.execute(codePoint, TS_ENCODING, true); - } - return values; - } - @TruffleBoundary public static boolean isPrintable(int codepoint) { if (ImageInfo.inImageBuildtimeCode()) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java index ef7ef6c4c9..6a423b6eeb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -13,14 +13,15 @@ import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_PACK_EXPECTED_N_ITEMS_GOT_K; import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_PACK_INTO_REQ_BUFFER_TO_PACK; import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_UNPACK_FROM_REQ_AT_LEAST_N_BYTES; -import static com.oracle.graal.python.nodes.ErrorMessages.UNPACK_REQ_A_BUFFER_OF_N_BYTES; import static com.oracle.graal.python.nodes.ErrorMessages.S_TAKES_NO_KEYWORD_ARGS; +import static com.oracle.graal.python.nodes.ErrorMessages.UNPACK_REQ_A_BUFFER_OF_N_BYTES; import static com.oracle.graal.python.runtime.exception.PythonErrorType.StructError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; @@ -40,7 +41,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -101,8 +102,8 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, @Specialization Object pack(VirtualFrame frame, PStruct self, Object[] args, PKeyword[] keywords, - @Cached StructNodes.PackValueNode packValueNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Cached StructNodes.PackValueNode packValueNode) { if (keywords.length != 0) { throw raise(TypeError, S_TAKES_NO_KEYWORD_ARGS, "pack()"); } @@ -111,7 +112,7 @@ Object pack(VirtualFrame frame, PStruct self, Object[] args, PKeyword[] keywords } byte[] bytes = new byte[self.getSize()]; packInternal(frame, self, packValueNode, args, bytes, 0); - return factory.createBytes(bytes); + return PFactory.createBytes(language, bytes); } } @@ -203,10 +204,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static Object unpack(VirtualFrame frame, PStruct self, Object buffer, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Cached StructNodes.UnpackValueNode unpackValueNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { int bytesLen = bufferLib.getBufferLength(buffer); @@ -214,7 +215,7 @@ static Object unpack(VirtualFrame frame, PStruct self, Object buffer, if (bytesLen != self.getSize()) { throw raiseNode.get(inliningTarget).raise(StructError, UNPACK_REQ_A_BUFFER_OF_N_BYTES, self.getSize()); } - return factory.createTuple(unpackInternal(self, unpackValueNode, bytes, 0)); + return PFactory.createTuple(language, unpackInternal(self, unpackValueNode, bytes, 0)); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -235,9 +236,9 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static Object iterUnpack(VirtualFrame frame, PStruct self, Object buffer, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { if (self.getSize() == 0) { @@ -253,7 +254,7 @@ static Object iterUnpack(VirtualFrame frame, PStruct self, Object buffer, } // The buffer ownership is transferred to the iterator // TODO: GR-54860 release it when iterator is collected - final PStructUnpackIterator structUnpackIterator = factory.createStructUnpackIterator(self, buffer); + final PStructUnpackIterator structUnpackIterator = PFactory.createStructUnpackIterator(language, self, buffer); structUnpackIterator.index = 0; return structUnpackIterator; } @@ -274,10 +275,10 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(limit = "3") static Object unpackFrom(VirtualFrame frame, PStruct self, Object buffer, int offset, @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Cached StructNodes.UnpackValueNode unpackValueNode, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode) { try { int bufferOffset = offset; @@ -300,7 +301,7 @@ static Object unpackFrom(VirtualFrame frame, PStruct self, Object buffer, int of throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_UNPACK_FROM_REQ_AT_LEAST_N_BYTES, size + bufferOffset, size, bufferOffset, bytesLen); } - return factory.createTuple(unpackInternal(self, unpackValueNode, bytes, bufferOffset)); + return PFactory.createTuple(language, unpackInternal(self, unpackValueNode, bytes, bufferOffset)); } finally { bufferLib.release(buffer, frame, indirectCallData); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java index 2c68a5d753..50a43415f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java @@ -6,12 +6,6 @@ package com.oracle.graal.python.builtins.objects.struct; import static com.oracle.graal.python.builtins.modules.StructModuleBuiltins.ConstructStructNode.NUM_BYTES_LIMIT; -import static com.oracle.graal.python.nodes.ErrorMessages.ARG_FOR_N_MUST_BE; -import static com.oracle.graal.python.nodes.ErrorMessages.ARG_NOT_T; -import static com.oracle.graal.python.nodes.ErrorMessages.ARG_O_O_RANGE; -import static com.oracle.graal.python.nodes.ErrorMessages.FMT_REQ_RANGE; -import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_CHR_FMT_BYTES_1; -import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_FMT_NOT_YET_SUPPORTED; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_BOOL; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_CHAR; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_DOUBLE; @@ -20,12 +14,19 @@ import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_PASCAL_STRING; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_STRING; import static com.oracle.graal.python.builtins.objects.struct.FormatCode.FMT_VOID_PTR; +import static com.oracle.graal.python.nodes.ErrorMessages.ARG_FOR_N_MUST_BE; +import static com.oracle.graal.python.nodes.ErrorMessages.ARG_NOT_T; +import static com.oracle.graal.python.nodes.ErrorMessages.ARG_O_O_RANGE; +import static com.oracle.graal.python.nodes.ErrorMessages.FMT_REQ_RANGE; +import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_CHR_FMT_BYTES_1; +import static com.oracle.graal.python.nodes.ErrorMessages.STRUCT_FMT_NOT_YET_SUPPORTED; import static com.oracle.graal.python.nodes.PGuards.isBytes; import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.StructError; import java.math.BigInteger; +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.bytes.PBytesLike; @@ -44,7 +45,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.util.CastToJavaBigIntegerNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.NumericSupport; import com.oracle.graal.python.util.OverflowException; import com.oracle.graal.python.util.PythonUtils; @@ -406,8 +407,7 @@ static Object unpack8Cached(FormatCode formatCode, @SuppressWarnings("unused") F @Cached("formatCode.numBytes()") int numBytes, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, @Shared @Cached InlinedConditionProfile profilePIntResult, - @Shared @Cached InlinedConditionProfile profileSigned, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared @Cached InlinedConditionProfile profileSigned) { long num; if (profileSigned.profile(inliningTarget, formatCode.isUnsigned())) { num = numericSupport.getLongUnsigned(buffer, offset, numBytes); @@ -416,7 +416,7 @@ static Object unpack8Cached(FormatCode formatCode, @SuppressWarnings("unused") F num = handleSign(formatCode, num); } if (profilePIntResult.profile(inliningTarget, formatCode.isUnsigned() && num < 0)) { - return factory.get(inliningTarget).createInt(getAsUnsignedBigInt(num)); + return PFactory.createInt(PythonLanguage.get(inliningTarget), getAsUnsignedBigInt(num)); } return num; } @@ -425,10 +425,9 @@ static Object unpack8Cached(FormatCode formatCode, @SuppressWarnings("unused") F static Object unpack8(FormatCode formatCode, @SuppressWarnings("unused") FormatAlignment formatAlignment, byte[] buffer, int offset, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile profilePIntResult, - @Shared @Cached InlinedConditionProfile profileSigned, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Shared @Cached InlinedConditionProfile profileSigned) { return unpack8Cached(formatCode, formatAlignment, buffer, offset, inliningTarget, formatCode.numBytes(), - getNumericSupport(formatAlignment), profilePIntResult, profileSigned, factory); + getNumericSupport(formatAlignment), profilePIntResult, profileSigned); } @Specialization(guards = {"isFmtFloat(formatCode)", "numericSupport == getNumericSupport(formatAlignment)"}, limit = "3") @@ -442,11 +441,10 @@ static Object unpackFloat8(FormatCode formatCode, @SuppressWarnings("unused") Fo static Object unpackVoidPtr(FormatCode formatCode, FormatAlignment formatAlignment, byte[] buffer, int offset, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile profilePIntResult, - @Shared @Cached PythonObjectFactory.Lazy factory, @Shared @Cached PRaiseNode raiseNode) { long num = getNumericSupport(formatAlignment).getLongUnsigned(buffer, offset, formatCode.numBytes()); if (profilePIntResult.profile(inliningTarget, num < 0)) { - return factory.get(inliningTarget).createInt(getAsUnsignedBigInt(num)); + return PFactory.createInt(PythonLanguage.get(inliningTarget), getAsUnsignedBigInt(num)); } return num; } @@ -459,8 +457,7 @@ static Object unpackBool(@SuppressWarnings("unused") FormatCode formatCode, @Sup @Specialization(guards = "isFmtBytes(formatCode)") static Object unpackBytes(@SuppressWarnings("unused") FormatCode formatCode, @SuppressWarnings("unused") FormatAlignment formatAlignment, byte[] buffer, int offset, @Bind("this") Node inliningTarget, - @Cached(value = "createIdentityProfile()", inline = false) ValueProfile formatProfile, - @Shared @Cached PythonObjectFactory.Lazy factory) { + @Cached(value = "createIdentityProfile()", inline = false) ValueProfile formatProfile) { byte[] bytes; switch (formatProfile.profile(formatCode.formatDef.format)) { case FMT_CHAR: @@ -479,7 +476,7 @@ static Object unpackBytes(@SuppressWarnings("unused") FormatCode formatCode, @Su bytes = new byte[n]; PythonUtils.arraycopy(buffer, offset + 1, bytes, 0, n); } - return factory.get(inliningTarget).createBytes(bytes); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), bytes); } @Specialization(guards = "!isSupportedFormat(formatCode)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java index 706ba0f621..b0718e01fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java @@ -1,12 +1,12 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 */ package com.oracle.graal.python.builtins.objects.struct; -import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_CREATE_P_OBJECTS; import static com.oracle.graal.python.builtins.objects.struct.StructBuiltins.unpackInternal; +import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_CREATE_P_OBJECTS; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; @@ -14,6 +14,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -26,7 +27,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -91,7 +92,7 @@ static Object next(VirtualFrame frame, PStructUnpackIterator self, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached StructNodes.UnpackValueNode unpackValueNode, @CachedLibrary("self.getBuffer()") PythonBufferAccessLibrary bufferLib, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { final PStruct struct = self.getStruct(); final Object buffer = self.getBuffer(); @@ -117,7 +118,7 @@ static Object next(VirtualFrame frame, PStructUnpackIterator self, } // TODO: GR-54860 handle buffers directly in unpack - Object result = factory.createTuple(unpackInternal(struct, unpackValueNode, bytes, offset)); + Object result = PFactory.createTuple(language, unpackInternal(struct, unpackValueNode, bytes, offset)); self.index += struct.getSize(); return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java index f35dac0ca0..da6208bc58 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -51,6 +51,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -99,7 +100,7 @@ import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -412,8 +413,10 @@ static Object doIt(Node inliningTarget, SuperObject self, Object obj, @Cached GetTypeNode getType, @Cached(inline = false) SuperInitNode superInit, @Cached GetClassNode getClass, - @Cached(inline = false) PythonObjectFactory factory) { - SuperObject newSuper = factory.createSuperObject(getClass.execute(inliningTarget, self)); + @Bind PythonLanguage language, + @Cached TypeNodes.GetInstanceShape getInstanceShape) { + Object cls = getClass.execute(inliningTarget, self); + SuperObject newSuper = PFactory.createSuperObject(language, cls, getInstanceShape.execute(cls)); superInit.execute(null, newSuper, getType.execute(inliningTarget, self), obj); return newSuper; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java index 845bf35846..3a200275b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,6 +42,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaUnsignedLongNode; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -121,13 +122,13 @@ abstract static class ReleaseSaveRLockNode extends PythonUnaryBuiltinNode { static Object releaseSave(PRLock self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile countProfile, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { int count = self.getCount(); if (countProfile.profile(inliningTarget, count == 0)) { throw raiseNode.get(inliningTarget).raise(PythonErrorType.RuntimeError, ErrorMessages.CANNOT_RELEASE_UNAQUIRED_LOCK); } - PTuple retVal = factory.createTuple(new Object[]{count, self.getOwnerId()}); + PTuple retVal = PFactory.createTuple(language, new Object[]{count, self.getOwnerId()}); self.releaseAll(); return retVal; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalNodes.java index b42bebeab3..de86e7ad21 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -40,17 +40,19 @@ */ package com.oracle.graal.python.builtins.objects.thread; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; public abstract class ThreadLocalNodes { @@ -61,12 +63,13 @@ public abstract static class GetThreadLocalDict extends PNodeWithContext { @Specialization PDict get(VirtualFrame frame, PThreadLocal self, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory, + @Cached InlinedBranchProfile create, @Cached PyObjectLookupAttr lookup, @Cached CallNode callNode) { PDict dict = self.getThreadLocalDict(); if (dict == null) { - dict = factory.createDict(); + create.enter(inliningTarget); + dict = PFactory.createDict(PythonLanguage.get(inliningTarget)); self.setThreadLocalDict(dict); Object initMethod = lookup.execute(frame, inliningTarget, self, SpecialMethodNames.T___INIT__); callNode.execute(frame, initMethod, self.getArgs(), self.getKeywords()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java index f7a393dcbb..36bba4c914 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -47,6 +47,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.pegparser.tokenizer.Token; import com.oracle.graal.python.pegparser.tokenizer.Token.Kind; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -92,7 +93,7 @@ abstract static class NextNode extends PythonUnaryBuiltinNode { static PTuple next(PTokenizerIter self, @Bind("this") Node inliningTarget, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Token token = self.getNextToken(); if (token.type == Kind.ERRORTOKEN || token.type == Kind.ENDMARKER) { @@ -110,7 +111,7 @@ static PTuple next(PTokenizerIter self, if (token.type == Kind.NEWLINE) { endColumn--; } - return factory.createTuple(new Object[]{ + return PFactory.createTuple(language, new Object[]{ fromJavaStringNode.execute(self.getTokenString(token), TS_ENCODING), token.type, token.sourceRange.startLine, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java index 0f90e1a881..eed52a94df 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -40,8 +40,9 @@ */ package com.oracle.graal.python.builtins.objects.traceback; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; @@ -134,7 +135,6 @@ static PTraceback getMaterialized(LazyTraceback tb) { @Fallback static PTraceback getTraceback(Node inliningTarget, LazyTraceback tb, - @Cached(inline = false) PythonObjectFactory factory, @Cached InlinedLoopConditionProfile loopConditionProfile) { PTraceback newTraceback = null; LazyTraceback current = tb; @@ -143,7 +143,7 @@ static PTraceback getTraceback(Node inliningTarget, LazyTraceback tb, if (current.isMaterialized()) { newTraceback = current.getTraceback(); } else { - newTraceback = factory.createTraceback(current); + newTraceback = PFactory.createTraceback(PythonLanguage.get(inliningTarget), current); } break; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java index 228a0a26ed..f847f3408c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -35,6 +35,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -53,7 +54,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleStackTrace; import com.oracle.truffle.api.TruffleStackTraceElement; @@ -85,8 +86,8 @@ protected List> getNodeFa public abstract static class DirNode extends PythonBuiltinNode { @Specialization static Object dir(@SuppressWarnings("unused") PTraceback self, - @Cached PythonObjectFactory factory) { - return factory.createList(PTraceback.getTbFieldNames()); + @Bind PythonLanguage language) { + return PFactory.createList(language, PTraceback.getTbFieldNames()); } } @@ -109,8 +110,7 @@ static void doExisting(@SuppressWarnings("unused") PTraceback tb) { @Specialization(guards = "!tb.isMaterialized()") static void doMaterialize(Node inliningTarget, PTraceback tb, @Cached(inline = false) MaterializeFrameNode materializeFrameNode, - @Cached MaterializeLazyTracebackNode materializeLazyTracebackNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached MaterializeLazyTracebackNode materializeLazyTracebackNode) { /* * Truffle stacktrace consists of the frames captured during the unwinding and the * frames that are now on the Java stack. We don't want the frames from the stack to @@ -136,7 +136,7 @@ static void doMaterialize(Node inliningTarget, PTraceback tb, TruffleStackTraceElement element = stackTrace.get(truffleIndex); if (LazyTraceback.elementWantedForTraceback(element)) { PFrame pFrame = materializeFrame(element, materializeFrameNode); - next = factory.createTraceback(pFrame, pFrame.getLine(), next); + next = PFactory.createTraceback(PythonLanguage.get(null), pFrame, pFrame.getLine(), next); next.setBci(pFrame.getBci()); pyIndex++; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java index 45fd01e7a8..8627fd8fbb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -104,10 +104,8 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -262,16 +260,11 @@ public record DescriptorCallTargets(RootCallTarget reprBuiltin, RootCallTarget r @TruffleBoundary public static void initType(Python3Core core, BuiltinTypeDescriptor desc) { - initType(core.factory(), core.getLanguage(), core.lookupType(desc.type), desc); + initType(core.getLanguage(), core.lookupType(desc.type), desc); } @TruffleBoundary public static void initType(PythonLanguage language, Object klass, Descriptor desc) { - initType(PythonContext.get(null).factory(), language, klass, desc); - } - - @TruffleBoundary - public static void initType(PythonObjectSlowPathFactory factory, PythonLanguage language, Object klass, Descriptor desc) { assert IsSubtypeNode.getUncached().execute(klass, PythonBuiltinClassType.PTuple); long flags = TypeNodes.GetTypeFlagsNode.executeUncached(klass); @@ -285,7 +278,7 @@ public static void initType(PythonObjectSlowPathFactory factory, PythonLanguage for (int idx = 0; idx < desc.fieldNames.length; ++idx) { if (desc.fieldNames[idx] != null) { TruffleString doc = desc.fieldDocStrings == null ? null : desc.fieldDocStrings[idx]; - createMember(factory, language, klass, desc.fieldNames[idx], doc, idx); + createMember(language, klass, desc.fieldNames[idx], doc, idx); } else { unnamedFields++; } @@ -298,8 +291,8 @@ public static void initType(PythonObjectSlowPathFactory factory, PythonLanguage createBuiltinCallTarget(language, desc, NewNode.class, NewNodeGen::create, false) : // createBuiltinCallTarget(language, desc, DisabledNewNode.class, ignore -> DisabledNewNodeGen.create(), false))); - createMethod(factory, klass, ReprNode.class, callTargets.reprBuiltin); - createMethod(factory, klass, ReduceNode.class, callTargets.reduceBuiltin); + createMethod(klass, ReprNode.class, callTargets.reprBuiltin); + createMethod(klass, ReduceNode.class, callTargets.reduceBuiltin); WriteAttributeToObjectNode writeAttrNode = WriteAttributeToObjectNode.getUncached(true); /* @@ -315,7 +308,7 @@ public static void initType(PythonObjectSlowPathFactory factory, PythonLanguage if (ReadAttributeFromObjectNode.getUncachedForceType().execute(klass, T___NEW__) == PNone.NO_VALUE) { Builtin builtin = NewNode.class.getAnnotation(Builtin.class); - PythonUtils.createConstructor(factory, klass, builtin, callTargets.newBuiltin); + PythonUtils.createConstructor(klass, builtin, callTargets.newBuiltin); } if ((flags & TypeFlags.IMMUTABLETYPE) != 0) { // Restore flags @@ -329,19 +322,19 @@ private static RootCallTarget createBuiltinCal return new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory(nodeFactory.apply(descriptor)), declaresExplicitSelf).getCallTarget(); } - private static void createMember(PythonObjectSlowPathFactory factory, PythonLanguage language, Object klass, TruffleString name, TruffleString doc, int idx) { + private static void createMember(PythonLanguage language, Object klass, TruffleString name, TruffleString doc, int idx) { RootCallTarget callTarget = language.createStructSeqIndexedMemberAccessCachedCallTarget((l) -> new GetStructMemberNode(l, idx), idx); - PBuiltinFunction getter = factory.createBuiltinFunction(name, klass, 0, 0, callTarget); - GetSetDescriptor callable = factory.createGetSetDescriptor(getter, null, name, klass, false); + PBuiltinFunction getter = PFactory.createBuiltinFunction(language, name, klass, 0, 0, callTarget); + GetSetDescriptor callable = PFactory.createGetSetDescriptor(language, getter, null, name, klass, false); if (doc != null) { callable.setAttribute(T___DOC__, doc); } WriteAttributeToObjectNode.getUncached(true).execute(klass, name, callable); } - private static void createMethod(PythonObjectSlowPathFactory factory, Object klass, Class nodeClass, RootCallTarget callTarget) { + private static void createMethod(Object klass, Class nodeClass, RootCallTarget callTarget) { Builtin builtin = nodeClass.getAnnotation(Builtin.class); - PythonUtils.createMethod(factory, klass, builtin, callTarget, PythonBuiltinClassType.PTuple, 0); + PythonUtils.createMethod(klass, builtin, callTarget, PythonBuiltinClassType.PTuple, 0); } @Builtin(name = J___NEW__, minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true) @@ -389,14 +382,15 @@ PTuple withoutDict(VirtualFrame frame, Object cls, Object sequence, @SuppressWar @Exclusive @Cached IsBuiltinObjectProfile notASequenceProfile, @Exclusive @Cached InlinedBranchProfile wrongLenProfile, @Exclusive @Cached InlinedBranchProfile needsReallocProfile, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); for (int i = src.length; i < dst.length; ++i) { dst[i] = PNone.NONE; } - return factory.createTuple(cls, new ObjectSequenceStorage(dst, inSequence)); + return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(dst, inSequence)); } @Specialization @@ -409,7 +403,8 @@ PTuple withDict(VirtualFrame frame, Object cls, Object sequence, PDict dict, @Exclusive @Cached InlinedBranchProfile wrongLenProfile, @Exclusive @Cached InlinedBranchProfile needsReallocProfile, @Cached HashingStorageGetItem getItem, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, + @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); @@ -418,7 +413,7 @@ PTuple withDict(VirtualFrame frame, Object cls, Object sequence, PDict dict, Object o = getItem.execute(inliningTarget, hs, fieldNames[i]); dst[i] = o == null ? PNone.NONE : o; } - return factory.createTuple(cls, new ObjectSequenceStorage(dst, inSequence)); + return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(dst, inSequence)); } @Specialization(guards = {"!isNoValue(dict)", "!isDict(dict)"}) @@ -483,25 +478,25 @@ PTuple reduce(PTuple self, @Bind("this") Node inliningTarget, @Cached HashingStorageSetItem setHashingStorageItem, @Cached GetClassNode getClass, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { assert self.getSequenceStorage() instanceof ObjectSequenceStorage; Object[] data = CompilerDirectives.castExact(self.getSequenceStorage(), ObjectSequenceStorage.class).getInternalObjectArray(); assert data.length == fieldNames.length; PTuple seq; PDict dict; if (fieldNames.length == inSequence) { - seq = factory.createTuple(data); - dict = factory.createDict(); + seq = PFactory.createTuple(language, data); + dict = PFactory.createDict(language); } else { HashingStorage storage = EconomicMapStorage.create(fieldNames.length - inSequence); for (int i = inSequence; i < fieldNames.length; ++i) { storage = setHashingStorageItem.execute(inliningTarget, storage, fieldNames[i], data[i]); } - seq = factory.createTuple(Arrays.copyOf(data, inSequence)); - dict = factory.createDict(storage); + seq = PFactory.createTuple(language, Arrays.copyOf(data, inSequence)); + dict = PFactory.createDict(language, storage); } - PTuple seqDictPair = factory.createTuple(new Object[]{seq, dict}); - return factory.createTuple(new Object[]{getClass.execute(inliningTarget, self), seqDictPair}); + PTuple seqDictPair = PFactory.createTuple(language, new Object[]{seq, dict}); + return PFactory.createTuple(language, new Object[]{getClass.execute(inliningTarget, self), seqDictPair}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java index 4c696b9e18..e96a6e6c41 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java @@ -50,6 +50,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; @@ -77,7 +78,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode; import com.oracle.graal.python.lib.PyIndexCheckNode; -import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.lib.PyObjectRichCompareBool; @@ -97,7 +97,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; @@ -296,7 +296,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, raiseNonIntIndex(inliningTarget, raiseNode, idx); } return subscriptNode.execute(frame, inliningTarget, getTupleStorage.execute(inliningTarget, self), idx, - ErrorMessages.TUPLE_OUT_OF_BOUNDS, PythonObjectFactory::createTuple); + ErrorMessages.TUPLE_OUT_OF_BOUNDS, PFactory::createTuple); } @InliningCutoff @@ -457,9 +457,9 @@ static PTuple doTuple(Object left, Object right, @Cached GetTupleStorage getLeft, @Cached GetTupleStorage getRight, @Cached("createConcat()") ConcatNode concatNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage concatenated = concatNode.execute(getLeft.execute(inliningTarget, left), getRight.execute(inliningTarget, right)); - return factory.createTuple(concatenated); + return PFactory.createTuple(language, concatenated); } @NeverDefault @@ -484,13 +484,11 @@ static Object doTuple(VirtualFrame frame, Object left, int repeats, @Cached PyTupleCheckExactNode checkTuple, @Cached GetTupleStorage getLeft, @Cached InlinedConditionProfile isSingleRepeat, - @Cached PyNumberAsSizeNode asSizeNode, - @Cached SequenceStorageNodes.RepeatNode repeatNode, - @Cached PythonObjectFactory.Lazy factory) { + @Cached SequenceStorageNodes.RepeatNode repeatNode) { if (isSingleRepeat.profile(inliningTarget, repeats == 1 && checkTuple.execute(inliningTarget, left))) { return left; } else { - return factory.get(inliningTarget).createTuple(repeatNode.execute(frame, getLeft.execute(inliningTarget, left), repeats)); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), repeatNode.execute(frame, getLeft.execute(inliningTarget, left), repeats)); } } } @@ -513,38 +511,38 @@ boolean contains(VirtualFrame frame, Object self, Object other, public abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization(guards = {"isIntStorage(primary)"}) static PIntegerSequenceIterator doPTupleInt(PTuple primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createIntegerSequenceIterator((IntSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createIntegerSequenceIterator(language, (IntSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"isObjectStorage(primary)"}) static PObjectSequenceIterator doPTupleObject(PTuple primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createObjectSequenceIterator((ObjectSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createObjectSequenceIterator(language, (ObjectSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"isLongStorage(primary)"}) static PLongSequenceIterator doPTupleLong(PTuple primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createLongSequenceIterator((LongSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createLongSequenceIterator(language, (LongSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"isDoubleStorage(primary)"}) static PDoubleSequenceIterator doPTupleDouble(PTuple primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createDoubleSequenceIterator((DoubleSequenceStorage) primary.getSequenceStorage(), primary); + @Bind PythonLanguage language) { + return PFactory.createDoubleSequenceIterator(language, (DoubleSequenceStorage) primary.getSequenceStorage(), primary); } @Specialization(guards = {"!isIntStorage(primary)", "!isLongStorage(primary)", "!isDoubleStorage(primary)"}) static PSequenceIterator doPTuple(PTuple primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createSequenceIterator(primary); + @Bind PythonLanguage language) { + return PFactory.createSequenceIterator(language, primary); } @Specialization static PSequenceIterator doNativeTuple(PythonAbstractNativeObject primary, - @Shared @Cached PythonObjectFactory factory) { - return factory.createSequenceIterator(primary); + @Bind PythonLanguage language) { + return PFactory.createSequenceIterator(language, primary); } } @@ -607,8 +605,8 @@ public abstract static class GetNewargsNode extends PythonUnaryBuiltinNode { static PTuple doIt(Object self, @Bind("this") Node inliningTarget, @Cached GetTupleStorage getTupleStorage, - @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{factory.createTuple(getTupleStorage.execute(inliningTarget, self))}); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, new Object[]{PFactory.createTuple(language, getTupleStorage.execute(inliningTarget, self))}); } } @@ -617,8 +615,8 @@ static PTuple doIt(Object self, public abstract static class ClassGetItemNode extends PythonBinaryBuiltinNode { @Specialization static Object classGetItem(Object cls, Object key, - @Cached PythonObjectFactory factory) { - return factory.createGenericAlias(cls, key); + @Bind PythonLanguage language) { + return PFactory.createGenericAlias(language, cls, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java index 33d8405fc1..e826238069 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -49,6 +49,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -66,7 +67,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -94,9 +95,9 @@ public abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(PTupleGetter self, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory) { - PTuple args = factory.createTuple(new Object[]{self.getIndex(), self.getDoc()}); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args}); + @Bind PythonLanguage language) { + PTuple args = PFactory.createTuple(language, new Object[]{self.getIndex(), self.getDoc()}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java index ddf02c227a..29bffb65bf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -45,7 +45,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerAsserts; @@ -131,7 +131,7 @@ protected PythonManagedClass(PythonLanguage lang, Object typeClass, Shape classS this.instanceShape = lang.getShapeForClass(this); } - this.subClasses = PythonObjectFactory.getUncached().createDict(); + this.subClasses = PFactory.createDict(lang); } public boolean isMROInitialized() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index c984c2a92d..9c0aa4e47d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -1322,7 +1322,6 @@ public void addOperators(PythonClass type) { assert GetDictIfExistsNode.getUncached().execute(type) == null; PythonContext context = PythonContext.get(null); - var factory = context.factory(); PythonLanguage language = context.getLanguage(); for (Entry slotDefEntry : SLOTDEFS.entrySet()) { TpSlotMeta tpSlotMeta = slotDefEntry.getKey(); @@ -1348,10 +1347,9 @@ public void addOperators(PythonClass type) { } else if (value instanceof TpSlotNative nativeSlot) { if (nativeSlot instanceof TpSlotHPyNative hpySlot) { wrapperDescriptor = HPyExternalFunctionNodes.createWrapperFunction(language, context.getHPyContext(), tpSlotDef.hpyWrapper, hpySlot, tpSlotDef.wrapper, tpSlotDef.name, - nativeSlot.getCallable(), type, - factory); + nativeSlot.getCallable(), type); } else { - wrapperDescriptor = PExternalFunctionWrapper.createWrapperFunction(tpSlotDef.name, (TpSlotCExtNative) nativeSlot, type, tpSlotDef.wrapper, language, factory); + wrapperDescriptor = PExternalFunctionWrapper.createWrapperFunction(tpSlotDef.name, (TpSlotCExtNative) nativeSlot, type, tpSlotDef.wrapper, language); } } assert wrapperDescriptor != null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java index 2c3e4fa940..0d86652c98 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java @@ -175,7 +175,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -307,13 +307,12 @@ abstract static class MroAttrNode extends PythonUnaryBuiltinNode { static Object doit(Object klass, @Bind("this") Node inliningTarget, @Cached TypeNodes.GetMroNode getMroNode, - @Cached InlinedConditionProfile notInitialized, - @Cached PythonObjectFactory factory) { + @Cached InlinedConditionProfile notInitialized) { if (notInitialized.profile(inliningTarget, klass instanceof PythonManagedClass && !((PythonManagedClass) klass).isMROInitialized())) { return PNone.NONE; } PythonAbstractClass[] mro = getMroNode.execute(inliningTarget, klass); - return factory.createTuple(mro); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), mro); } } @@ -324,10 +323,9 @@ public abstract static class MroNode extends PythonUnaryBuiltinNode { static Object doit(Object klass, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode, - @Cached GetMroNode getMroNode, - @Cached PythonObjectFactory factory) { + @Cached GetMroNode getMroNode) { PythonAbstractClass[] mro = getMroNode.execute(inliningTarget, klass); - return factory.createList(Arrays.copyOf(mro, mro.length, Object[].class)); + return PFactory.createList(PythonLanguage.get(inliningTarget), Arrays.copyOf(mro, mro.length, Object[].class)); } @Fallback @@ -771,8 +769,8 @@ public abstract static class PrepareNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization Object doIt(Object args, Object kwargs, - @Cached PythonObjectFactory factory) { - return factory.createDict(new DynamicObjectStorage(PythonLanguage.get(this))); + @Bind PythonLanguage language) { + return PFactory.createDict(language, new DynamicObjectStorage(language)); } } @@ -784,9 +782,9 @@ abstract static class BasesNode extends PythonBinaryBuiltinNode { @Specialization static Object getBases(Object self, @SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, - @Cached TypeNodes.GetBaseClassesNode getBaseClassesNode, - @Cached PythonObjectFactory factory) { - return factory.createTuple(getBaseClassesNode.execute(inliningTarget, self)); + @Bind PythonLanguage language, + @Cached TypeNodes.GetBaseClassesNode getBaseClassesNode) { + return PFactory.createTuple(language, getBaseClassesNode.execute(inliningTarget, self)); } @Specialization @@ -886,21 +884,21 @@ static Object base(Object self, abstract static class DictNode extends PythonUnaryBuiltinNode { @Specialization Object doType(PythonBuiltinClassType self, - @Shared @Cached GetDictIfExistsNode getDict, - @Shared @Cached PythonObjectFactory factory) { - return doManaged(getContext().lookupType(self), getDict, factory); + @Bind PythonLanguage language, + @Shared @Cached GetDictIfExistsNode getDict) { + return doManaged(getContext().lookupType(self), language, getDict); } @Specialization static Object doManaged(PythonManagedClass self, - @Shared @Cached GetDictIfExistsNode getDict, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language, + @Shared @Cached GetDictIfExistsNode getDict) { PDict dict = getDict.execute(self); if (dict == null) { - dict = factory.createDictFixedStorage(self, self.getMethodResolutionOrder()); + dict = PFactory.createDictFixedStorage(language, self, self.getMethodResolutionOrder()); // The mapping is unmodifiable, so we don't have to assign it back } - return factory.createMappingproxy(dict); + return PFactory.createMappingproxy(language, dict); } @Specialization @@ -1037,13 +1035,12 @@ abstract static class SubclassesNode extends PythonUnaryBuiltinNode { @Specialization static PList getSubclasses(Object cls, @Bind("this") Node inliningTarget, - @Cached(inline = true) GetSubclassesAsArrayNode getSubclassesNode, - @Cached PythonObjectFactory factory) { + @Cached(inline = true) GetSubclassesAsArrayNode getSubclassesNode) { // TODO: missing: keep track of subclasses PythonAbstractClass[] array = getSubclassesNode.execute(inliningTarget, cls); Object[] classes = new Object[array.length]; PythonUtils.arraycopy(array, 0, classes, 0, array.length); - return factory.createList(classes); + return PFactory.createList(PythonLanguage.get(inliningTarget), classes); } } @@ -1114,16 +1111,16 @@ static void set(PythonClass type, TruffleString value) { @Specialization static void set(PythonAbstractNativeObject type, TruffleString value, + @Bind PythonLanguage language, @Cached(inline = false) CStructAccess.WritePointerNode writePointerNode, @Cached(inline = false) CStructAccess.WriteObjectNewRefNode writeObject, @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached(inline = false) TruffleString.CopyToByteArrayNode copyToByteArrayNode, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached(inline = false) TruffleString.CopyToByteArrayNode copyToByteArrayNode) { value = switchEncodingNode.execute(value, TruffleString.Encoding.UTF_8); byte[] bytes = copyToByteArrayNode.execute(value, TruffleString.Encoding.UTF_8); - PBytes bytesObject = factory.createBytes(bytes); + PBytes bytesObject = PFactory.createBytes(language, bytes); writePointerNode.writeToObj(type, PyTypeObject__tp_name, PySequenceArrayWrapper.ensureNativeSequence(bytesObject)); - PString pString = factory.createString(value); + PString pString = PFactory.createString(language, value); pString.setUtf8Bytes(bytesObject); writeObject.writeToObject(type, PyHeapTypeObject__ht_name, pString); } @@ -1450,14 +1447,13 @@ static PSet dir(VirtualFrame frame, Object klass, @Cached PyObjectLookupAttr lookupAttrNode, @Cached com.oracle.graal.python.nodes.call.CallNode callNode, @Cached ToArrayNode toArrayNode, - @Cached("createGetAttrNode()") GetFixedAttributeNode getBasesNode, - @Cached PythonObjectFactory factory) { - return dir(frame, inliningTarget, klass, lookupAttrNode, callNode, getBasesNode, toArrayNode, factory); + @Cached("createGetAttrNode()") GetFixedAttributeNode getBasesNode) { + return dir(frame, inliningTarget, klass, lookupAttrNode, callNode, getBasesNode, toArrayNode); } private static PSet dir(VirtualFrame frame, Node inliningTarget, Object klass, PyObjectLookupAttr lookupAttrNode, com.oracle.graal.python.nodes.call.CallNode callNode, - GetFixedAttributeNode getBasesNode, ToArrayNode toArrayNode, PythonObjectFactory factory) { - PSet names = factory.createSet(); + GetFixedAttributeNode getBasesNode, ToArrayNode toArrayNode) { + PSet names = PFactory.createSet(PythonLanguage.get(inliningTarget)); Object updateCallable = lookupAttrNode.execute(frame, inliningTarget, names, T_UPDATE); Object ns = lookupAttrNode.execute(frame, inliningTarget, klass, T___DICT__); if (ns != NO_VALUE) { @@ -1469,7 +1465,7 @@ private static PSet dir(VirtualFrame frame, Node inliningTarget, Object klass, P for (Object cls : bases) { // Note that since we are only interested in the keys, the order // we merge classes is unimportant - Object baseNames = dir(frame, inliningTarget, cls, lookupAttrNode, callNode, getBasesNode, toArrayNode, factory); + Object baseNames = dir(frame, inliningTarget, cls, lookupAttrNode, callNode, getBasesNode, toArrayNode); callNode.execute(frame, updateCallable, baseNames); } } @@ -1503,13 +1499,14 @@ abstract static class AnnotationsNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNoValue(value)") static Object get(Object self, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, + @Cached InlinedBranchProfile createDict, @Shared("read") @Cached ReadAttributeFromObjectNode read, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Cached PythonObjectFactory.Lazy factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { Object annotations = read.execute(self, T___ANNOTATIONS__); if (annotations == NO_VALUE) { - annotations = factory.get(inliningTarget).createDict(); + createDict.enter(inliningTarget); + annotations = PFactory.createDict(PythonLanguage.get(inliningTarget)); try { write.execute(self, T___ANNOTATIONS__, annotations); } catch (PException e) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java index db9cbda3a4..122c4f757f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java @@ -207,7 +207,7 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; @@ -1840,6 +1840,10 @@ public abstract static class GetInstanceShape extends PNodeWithContext { public abstract Shape execute(Object clazz); + public static Shape executeUncached(Object clazz) { + return TypeNodesFactory.GetInstanceShapeNodeGen.getUncached().execute(clazz); + } + @Specialization(guards = "clazz == cachedClazz", limit = "1") @SuppressWarnings("unused") protected Shape doBuiltinClassTypeCached(PythonBuiltinClassType clazz, @@ -1899,6 +1903,9 @@ protected static Shape doError(@SuppressWarnings("unused") Object clazz, throw raise.raise(PythonBuiltinClassType.SystemError, ErrorMessages.CANNOT_GET_SHAPE_OF_NATIVE_CLS); } + public static GetInstanceShape getUncached() { + return TypeNodesFactory.GetInstanceShapeNodeGen.getUncached(); + } } @ImportStatic({SpecialMethodNames.class, SpecialAttributeNames.class, SpecialMethodSlot.class}) @@ -1949,13 +1956,12 @@ protected PythonClass makeType(VirtualFrame frame, PDict namespaceOrig, TruffleS @Cached CallNode callInitSubclassNode, @Cached("create(T___INIT_SUBCLASS__)") GetAttributeNode getInitSubclassNode, @Cached GetMroStorageNode getMroStorageNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode raise, @Cached AllocateTypeWithMetaclassNode typeMetaclass) { try { assert SpecialMethodSlot.pushInitializedTypePlaceholder(); - PDict namespace = factory.createDict(); - PythonLanguage language = PythonLanguage.get(this); + PDict namespace = PFactory.createDict(language); namespace.setDictStorage(initNode.execute(frame, namespaceOrig, PKeyword.EMPTY_KEYWORDS)); PythonClass newType = typeMetaclass.execute(frame, name, bases, namespace, metaclass); @@ -2032,7 +2038,7 @@ protected PythonClass makeType(VirtualFrame frame, PDict namespaceOrig, TruffleS } // Call __init_subclass__ on the parent of a newly generated type - SuperObject superObject = factory.createSuperObject(PythonBuiltinClassType.Super); + SuperObject superObject = PFactory.createSuperObject(language); superObject.init(newType, newType, newType); callInitSubclassNode.execute(frame, getInitSubclassNode.executeObject(frame, superObject), PythonUtils.EMPTY_OBJECT_ARRAY, kwds); @@ -2104,7 +2110,7 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached PRaiseNode raise, @Cached GetObjectArrayNode getObjectArray, - @Cached PythonObjectFactory factory, + @Cached GetInstanceShape getInstanceShape, @Cached CastToListNode castToListNode, @Cached PyUnicodeCheckNode stringCheck, @Cached TruffleString.IsValidNode isValidNode, @@ -2150,13 +2156,13 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple // 1.) create class, but avoid calling mro method - it might try to access __dict__ so // we have to copy dict slots first - PythonClass pythonClass = factory.createPythonClass(metaclass, name, false, base, basesArray); + PythonClass pythonClass = PFactory.createPythonClass(language, metaclass, getInstanceShape.execute(metaclass), name, false, base, basesArray); assert SpecialMethodSlot.replaceInitializedTypeTop(pythonClass); // 2.) copy the dictionary slots - copyDictSlots(frame, inliningTarget, ctx, pythonClass, namespace, setHashingStorageItem, + copyDictSlots(frame, inliningTarget, language, ctx, pythonClass, namespace, setHashingStorageItem, getHashingStorageIterator, hashingStorageItNext, hashingStorageItKey, hashingStorageItKeyHash, hashingStorageItValue, - constructAndRaiseNode, factory, raise, isValidNode, equalNode, codePointLengthNode, getOrCreateDictNode, stringCheck, castToStringNode); + constructAndRaiseNode, raise, isValidNode, equalNode, codePointLengthNode, getOrCreateDictNode, stringCheck, castToStringNode); if (!ctx.qualnameSet) { pythonClass.setQualName(name); } @@ -2227,7 +2233,7 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple throw raise.raise(TypeError, ErrorMessages.DICT_SLOT_DISALLOWED_WE_GOT_ONE); } ctx.addDict = true; - addDictDescrAttribute(basesArray, pythonClass, factory); + addDictDescrAttribute(basesArray, pythonClass, language); } else if (equalNode.execute(slotName, T___WEAKREF__, TS_ENCODING)) { if (!ctx.mayAddWeak || ctx.addWeak) { throw raise.raise(TypeError, ErrorMessages.WEAKREF_SLOT_DISALLOWED_WE_GOT_ONE); @@ -2252,19 +2258,19 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple int indexedSlotCount = getIndexedSlotsCountNode.execute(inliningTarget, base); if (ctx.copiedSlots != null) { for (TruffleString slotName : ctx.copiedSlots) { - IndexedSlotDescriptor slotDesc = factory.createIndexedSlotDescriptor(slotName, indexedSlotCount++, pythonClass); + IndexedSlotDescriptor slotDesc = PFactory.createIndexedSlotDescriptor(language, slotName, indexedSlotCount++, pythonClass); pythonClass.setAttribute(slotName, slotDesc); } } pythonClass.setIndexedSlotCount(indexedSlotCount); if (ctx.addDict) { - addDictDescrAttribute(basesArray, pythonClass, factory); + addDictDescrAttribute(basesArray, pythonClass, language); } else if (ctx.mayAddDict) { pythonClass.setHasSlotsButNoDictFlag(); } if (ctx.addWeak) { - addWeakrefDescrAttribute(pythonClass, factory); + addWeakrefDescrAttribute(pythonClass, language); } if (pythonClass.needsNativeAllocation()) { @@ -2296,31 +2302,31 @@ private static void typeNewSlotBases(TypeNewContext ctx, Object primaryBase, Pyt } @TruffleBoundary - private static void addDictDescrAttribute(PythonAbstractClass[] basesArray, PythonClass pythonClass, PythonObjectFactory factory) { + private static void addDictDescrAttribute(PythonAbstractClass[] basesArray, PythonClass pythonClass, PythonLanguage language) { // Note: we need to avoid MRO lookup of __dict__ using slots because they are not // initialized yet if ((!hasPythonClassBases(basesArray) && LookupAttributeInMRONode.lookupSlowPath(pythonClass, T___DICT__) == PNone.NO_VALUE) || basesHaveSlots(basesArray)) { Builtin dictBuiltin = ObjectBuiltins.DictNode.class.getAnnotation(Builtin.class); RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget( l -> new BuiltinFunctionRootNode(l, dictBuiltin, ObjectBuiltinsFactory.DictNodeFactory.getInstance(), true), ObjectBuiltins.DictNode.class); - setAttribute(T___DICT__, dictBuiltin, callTarget, pythonClass, factory); + setAttribute(T___DICT__, dictBuiltin, callTarget, pythonClass, language); } } @TruffleBoundary - private static void addWeakrefDescrAttribute(PythonClass pythonClass, PythonObjectFactory factory) { + private static void addWeakrefDescrAttribute(PythonClass pythonClass, PythonLanguage language) { if (LookupAttributeInMRONode.lookupSlowPath(pythonClass, T___WEAKREF__) == PNone.NO_VALUE) { Builtin builtin = GetWeakRefsNode.class.getAnnotation(Builtin.class); RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget( l -> new BuiltinFunctionRootNode(l, builtin, WeakRefModuleBuiltinsFactory.GetWeakRefsNodeFactory.getInstance(), true), GetWeakRefsNode.class); - setAttribute(T___WEAKREF__, builtin, callTarget, pythonClass, factory); + setAttribute(T___WEAKREF__, builtin, callTarget, pythonClass, language); } } - private static void setAttribute(TruffleString name, Builtin builtin, RootCallTarget callTarget, PythonClass pythonClass, PythonObjectFactory factory) { + private static void setAttribute(TruffleString name, Builtin builtin, RootCallTarget callTarget, PythonClass pythonClass, PythonLanguage language) { int flags = PBuiltinFunction.getFlags(builtin, callTarget); - PBuiltinFunction function = factory.createBuiltinFunction(name, pythonClass, 1, flags, callTarget); - GetSetDescriptor desc = factory.createGetSetDescriptor(function, function, name, pythonClass, true); + PBuiltinFunction function = PFactory.createBuiltinFunction(language, name, pythonClass, 1, flags, callTarget); + GetSetDescriptor desc = PFactory.createGetSetDescriptor(language, function, function, name, pythonClass, true); pythonClass.setAttribute(name, desc); } @@ -2410,10 +2416,11 @@ private static long installMemberDescriptors(PythonManagedClass pythonClass, Tru return slotOffset; } - private static void copyDictSlots(VirtualFrame frame, Node inliningTarget, TypeNewContext ctx, PythonClass pythonClass, PDict namespace, HashingStorageSetItemWithHash setHashingStorageItem, + private static void copyDictSlots(VirtualFrame frame, Node inliningTarget, PythonLanguage language, TypeNewContext ctx, PythonClass pythonClass, PDict namespace, + HashingStorageSetItemWithHash setHashingStorageItem, HashingStorageGetIterator getHashingStorageIterator, HashingStorageIteratorNext hashingStorageItNext, HashingStorageIteratorKey hashingStorageItKey, HashingStorageIteratorKeyHash hashingStorageItKeyHash, HashingStorageIteratorValue hashingStorageItValue, - PConstructAndRaiseNode.Lazy constructAndRaiseNode, PythonObjectFactory factory, PRaiseNode raise, IsValidNode isValidNode, + PConstructAndRaiseNode.Lazy constructAndRaiseNode, PRaiseNode raise, IsValidNode isValidNode, EqualNode equalNode, CodePointLengthNode codePointLengthNode, GetOrCreateDictNode getOrCreateDictNode, PyUnicodeCheckNode stringCheck, CastToTruffleStringNode castToStringNode) { // copy the dictionary slots over, as CPython does through PyDict_Copy @@ -2433,7 +2440,7 @@ private static void copyDictSlots(VirtualFrame frame, Node inliningTarget, TypeN if (equalNode.execute(T___NEW__, key, TS_ENCODING)) { // see CPython: if it's a plain function, make it a static function if (value instanceof PFunction) { - pythonClass.setAttribute(key, factory.createStaticmethodFromCallableObj(value)); + pythonClass.setAttribute(key, PFactory.createStaticmethodFromCallableObj(language, value)); } else { pythonClass.setAttribute(key, value); } @@ -2444,7 +2451,7 @@ private static void copyDictSlots(VirtualFrame frame, Node inliningTarget, TypeN // __class_getitem__: if they are plain functions, make them // classmethods if (value instanceof PFunction) { - pythonClass.setAttribute(key, factory.createClassmethodFromCallableObj(value)); + pythonClass.setAttribute(key, PFactory.createClassmethodFromCallableObj(language, value)); } else { pythonClass.setAttribute(key, value); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java index d74d2513c6..4e38bdbc9d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -60,6 +60,7 @@ import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLogger; @@ -335,7 +336,7 @@ final PBuiltinFunction createBuiltin(Python3Core core, Object type, TruffleStrin String name = tsName.toJavaStringUncached(); RootCallTarget callTarget = createBuiltinCallTarget(core.getLanguage(), signature, factory, name); Builtin builtin = ((BuiltinFunctionRootNode) callTarget.getRootNode()).getBuiltin(); - PBuiltinFunction function = core.factory().createWrapperDescriptor(tsName, type, numDefaults(builtin), 0, callTarget, this, wrapper); + PBuiltinFunction function = PFactory.createWrapperDescriptor(core.getLanguage(), tsName, type, numDefaults(builtin), 0, callTarget, this, wrapper); function.setAttribute(T___DOC__, PNone.NONE); return function; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java index 3f651dc67a..af05abce04 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java @@ -74,6 +74,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -116,7 +117,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -128,6 +129,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleStringBuilder; @@ -178,9 +180,10 @@ abstract static class ParametersNode extends PythonUnaryBuiltinNode { @Specialization static Object parameters(PGenericAlias self, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory.Lazy factory) { + @Cached InlinedBranchProfile createProfile) { if (self.getParameters() == null) { - self.setParameters(factory.get(inliningTarget).createTuple(GenericTypeNodes.makeParameters(self.getArgs()))); + createProfile.enter(inliningTarget); + self.setParameters(PFactory.createTuple(PythonLanguage.get(inliningTarget), GenericTypeNodes.makeParameters(self.getArgs()))); } return self.getParameters(); } @@ -334,8 +337,8 @@ static Object eq(Object self, Object other) { abstract static class MroEntriesNode extends PythonBinaryBuiltinNode { @Specialization static Object mro(PGenericAlias self, @SuppressWarnings("unused") Object bases, - @Cached PythonObjectFactory factory) { - return factory.createTuple(new Object[]{self.getOrigin()}); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, new Object[]{self.getOrigin()}); } } @@ -370,16 +373,16 @@ static Object reduce(VirtualFrame frame, PGenericAlias self, @Cached GetClassNode getClassNode, @Cached PyObjectGetIter getIter, @Cached PyObjectGetAttr getAttr, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.isStarred()) { - PGenericAlias copy = factory.createGenericAlias(self.getOrigin(), self.getArgs()); + PGenericAlias copy = PFactory.createGenericAlias(language, self.getOrigin(), self.getArgs()); PythonModule builtins = PythonContext.get(inliningTarget).getBuiltins(); Object next = getAttr.execute(frame, inliningTarget, builtins, T_NEXT); - Object args = factory.createTuple(new Object[]{getIter.execute(frame, inliningTarget, copy)}); - return factory.createTuple(new Object[]{next, args}); + Object args = PFactory.createTuple(language, new Object[]{getIter.execute(frame, inliningTarget, copy)}); + return PFactory.createTuple(language, new Object[]{next, args}); } - Object args = factory.createTuple(new Object[]{self.getOrigin(), self.getArgs()}); - return factory.createTuple(new Object[]{getClassNode.execute(inliningTarget, self), args}); + Object args = PFactory.createTuple(language, new Object[]{self.getOrigin(), self.getArgs()}); + return PFactory.createTuple(language, new Object[]{getClassNode.execute(inliningTarget, self), args}); } } @@ -409,13 +412,13 @@ abstract static class GetItemNode extends MpSubscriptBuiltinNode { @Specialization static Object getitem(PGenericAlias self, Object item, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.getParameters() == null) { - self.setParameters(factory.createTuple(GenericTypeNodes.makeParameters(self.getArgs()))); + self.setParameters(PFactory.createTuple(language, GenericTypeNodes.makeParameters(self.getArgs()))); } Object[] newargs = GenericTypeNodes.subsParameters(inliningTarget, self, self.getArgs(), self.getParameters(), item); - PTuple newargsTuple = factory.createTuple(newargs); - return factory.createGenericAlias(self.getOrigin(), newargsTuple, self.isStarred()); + PTuple newargsTuple = PFactory.createTuple(language, newargs); + return PFactory.createGenericAlias(language, self.getOrigin(), newargsTuple, self.isStarred()); } } @@ -438,8 +441,8 @@ static Object get(PGenericAlias self, abstract static class IterNode extends PythonUnaryBuiltinNode { @Specialization static Object iter(PGenericAlias self, - @Cached PythonObjectFactory factory) { - return factory.createGenericAliasIterator(self); + @Bind PythonLanguage language) { + return PFactory.createGenericAliasIterator(language, self); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java index 9904ac8ec5..511f48bce1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -46,6 +46,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -56,7 +57,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -78,12 +79,12 @@ abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization static Object next(PGenericAliasIterator self, @Cached PRaiseNode raiseNode, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.isExhausted()) { throw raiseNode.raise(PythonBuiltinClassType.StopIteration); } PGenericAlias alias = self.getObj(); - PGenericAlias starredAlias = factory.createGenericAlias(alias.getOrigin(), alias.getArgs(), true); + PGenericAlias starredAlias = PFactory.createGenericAlias(language, alias.getOrigin(), alias.getArgs(), true); self.markExhausted(); return starredAlias; } @@ -96,16 +97,16 @@ abstract static class ReduceNode extends PythonUnaryBuiltinNode { static Object reduce(VirtualFrame frame, PGenericAliasIterator self, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttr, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { PythonModule builtins = PythonContext.get(inliningTarget).getBuiltins(); Object iter = getAttr.execute(frame, inliningTarget, builtins, T_ITER); Object[] args; if (!self.isExhausted()) { args = new Object[]{self.getObj()}; } else { - args = new Object[]{factory.createEmptyTuple()}; + args = new Object[]{PFactory.createEmptyTuple(language)}; } - return factory.createTuple(new Object[]{iter, factory.createTuple(args)}); + return PFactory.createTuple(language, new Object[]{iter, PFactory.createTuple(language, args)}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java index 844b9d7b1f..f3429c434f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -52,6 +52,7 @@ import java.util.Arrays; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; @@ -76,8 +77,7 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.IsNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -264,6 +264,7 @@ private static void unpackArgsInner(List newargs, Object item) { // Equivalent of _Py_subs_parameters @TruffleBoundary static Object[] subsParameters(Node node, Object self, PTuple args, PTuple parameters, Object item) { + PythonLanguage language = PythonLanguage.get(null); SequenceStorage paramsStorage = parameters.getSequenceStorage(); int nparams = paramsStorage.length(); if (nparams == 0) { @@ -274,7 +275,7 @@ static Object[] subsParameters(Node node, Object self, PTuple args, PTuple param Object param = getItemUncached(paramsStorage, i); Object prepare = PyObjectLookupAttr.executeUncached(param, T___TYPING_PREPARE_SUBST__); if (!(prepare instanceof PNone)) { - Object itemarg = item instanceof PTuple ? item : PythonContext.get(node).factory().createTuple(new Object[]{item}); + Object itemarg = item instanceof PTuple ? item : PFactory.createTuple(language, new Object[]{item}); item = CallNode.executeUncached(prepare, self, itemarg); } } @@ -298,7 +299,7 @@ static Object[] subsParameters(Node node, Object self, PTuple args, PTuple param assert iparam >= 0; arg = CallNode.executeUncached(subst, argitems[iparam]); } else { - arg = subsTvars(node, arg, parameters, argitems); + arg = subsTvars(arg, parameters, argitems); } if (unpack && arg instanceof PTuple tuple /* CPython doesn't check the cast?! */) { listExtend(newargs, tuple); @@ -310,7 +311,7 @@ static Object[] subsParameters(Node node, Object self, PTuple args, PTuple param } @TruffleBoundary - private static Object subsTvars(Node node, Object obj, PTuple parameters, Object[] argitems) { + private static Object subsTvars(Object obj, PTuple parameters, Object[] argitems) { Object subparams = PyObjectLookupAttr.executeUncached(obj, T___PARAMETERS__); if (subparams instanceof PTuple tuple && tuple.getSequenceStorage().length() > 0) { SequenceStorage subparamsStorage = tuple.getSequenceStorage(); @@ -331,7 +332,7 @@ private static Object subsTvars(Node node, Object obj, PTuple parameters, Object } subargs.add(arg); } - PTuple subargsTuple = PythonContext.get(node).factory().createTuple(subargs.toArray()); + PTuple subargsTuple = PFactory.createTuple(PythonLanguage.get(null), subargs.toArray()); obj = PyObjectGetItem.executeUncached(obj, subargsTuple); } return obj; @@ -345,13 +346,13 @@ public abstract static class UnionTypeOrNode extends PNodeWithContext { static Object union(Object self, Object other, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Cached PyObjectTypeCheck typeCheck, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object[] args = dedupAndFlattenArgs(new Object[]{self, other}); if (args.length == 1) { return args[0]; } assert args.length > 1; - return factory.createUnionType(args); + return PFactory.createUnionType(language, args); } @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java index 86174747fa..2f9632bc54 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java @@ -54,6 +54,7 @@ import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; @@ -86,7 +87,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -97,6 +98,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleStringBuilder; @@ -123,9 +125,9 @@ Object args(PUnionType self) { abstract static class ParametersNode extends PythonUnaryBuiltinNode { @Specialization static Object parameters(PUnionType self, - @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { if (self.getParameters() == null) { - self.setParameters(factory.createTuple(GenericTypeNodes.makeParameters(self.getArgs()))); + self.setParameters(PFactory.createTuple(language, GenericTypeNodes.makeParameters(self.getArgs()))); } return self.getParameters(); } @@ -178,8 +180,8 @@ static long hash(VirtualFrame frame, PUnionType self, @Bind("this") Node inliningTarget, @Cached PyObjectHashNode hashNode, @Cached HashingCollectionNodes.GetClonedHashingStorageNode getHashingStorageNode, - @Cached PythonObjectFactory factory) { - PFrozenSet argSet = factory.createFrozenSet(getHashingStorageNode.doNoValue(frame, inliningTarget, self.getArgs())); + @Bind PythonLanguage language) { + PFrozenSet argSet = PFactory.createFrozenSet(language, getHashingStorageNode.doNoValue(frame, inliningTarget, self.getArgs())); return hashNode.execute(frame, inliningTarget, argSet); } } @@ -271,9 +273,9 @@ static boolean eq(VirtualFrame frame, PUnionType self, PUnionType other, @Bind("this") Node inliningTarget, @Cached HashingCollectionNodes.GetClonedHashingStorageNode getHashingStorageNode, @Cached PyObjectRichCompareBool.EqNode eqNode, - @Cached PythonObjectFactory factory) { - PFrozenSet argSet1 = factory.createFrozenSet(getHashingStorageNode.doNoValue(frame, inliningTarget, self.getArgs())); - PFrozenSet argSet2 = factory.createFrozenSet(getHashingStorageNode.doNoValue(frame, inliningTarget, other.getArgs())); + @Bind PythonLanguage language) { + PFrozenSet argSet1 = PFactory.createFrozenSet(language, getHashingStorageNode.doNoValue(frame, inliningTarget, self.getArgs())); + PFrozenSet argSet2 = PFactory.createFrozenSet(language, getHashingStorageNode.doNoValue(frame, inliningTarget, other.getArgs())); return eqNode.compare(frame, inliningTarget, argSet1, argSet2); } @@ -292,9 +294,10 @@ abstract static class GetItemNode extends MpSubscriptBuiltinNode { @Specialization Object getitem(VirtualFrame frame, PUnionType self, Object item, @Bind("this") Node inliningTarget, - @Cached PythonObjectFactory.Lazy factory) { + @Cached InlinedBranchProfile createProfile) { if (self.getParameters() == null) { - self.setParameters(factory.get(inliningTarget).createTuple(GenericTypeNodes.makeParameters(self.getArgs()))); + createProfile.enter(inliningTarget); + self.setParameters(PFactory.createTuple(PythonLanguage.get(inliningTarget), GenericTypeNodes.makeParameters(self.getArgs()))); } Object[] newargs = GenericTypeNodes.subsParameters(this, self, self.getArgs(), self.getParameters(), item); Object result = newargs[0]; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java index f8cfc842fd..ebf0356f9a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -196,7 +196,6 @@ import com.oracle.graal.python.pegparser.sst.UnaryOpTy; import com.oracle.graal.python.pegparser.sst.WithItemTy; import com.oracle.graal.python.pegparser.tokenizer.SourceRange; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.SuppressFBWarnings; import com.oracle.truffle.api.memory.ByteArraySupport; @@ -3138,7 +3137,7 @@ public Void visit(PatternTy.MatchMapping node, PatternContext pc) { errorCallback.onError(ErrorType.Syntax, unit.currentLocation, "mapping pattern keys may only match literals and attribute lookups"); } assert constantValue != null; - Object pythonValue = PythonUtils.pythonObjectFromConstantValue(constantValue, PythonObjectFactory.getUncached()); + Object pythonValue = PythonUtils.pythonObjectFromConstantValue(constantValue); for (Object o : seen) { // need python like equal - e.g. 1 equals True if (PyObjectRichCompareBool.EqNode.compareUncached(o, pythonValue)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/RaisePythonExceptionErrorCallback.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/RaisePythonExceptionErrorCallback.java index 1aef184604..7b806c4dab 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/RaisePythonExceptionErrorCallback.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/RaisePythonExceptionErrorCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -48,6 +48,7 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins; import com.oracle.graal.python.builtins.objects.PNone; @@ -61,7 +62,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PIncompleteSourceException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; @@ -163,7 +164,7 @@ public SourceSection getSourceSection() { cls = PythonBuiltinClassType.TabError; break; } - instance = PythonObjectFactory.getUncached().createBaseException(cls, message, PythonUtils.EMPTY_OBJECT_ARRAY); + instance = PFactory.createBaseException(PythonLanguage.get(null), cls, message, PythonUtils.EMPTY_OBJECT_ARRAY); final Object[] excAttrs = SyntaxErrorBuiltins.SYNTAX_ERROR_ATTR_FACTORY.create(); TruffleString filename = getFilename(source); excAttrs[SyntaxErrorBuiltins.IDX_FILENAME] = filename; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyContextCopyCurrent.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyContextCopyCurrent.java index cb3c4de41c..0159df5e47 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyContextCopyCurrent.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyContextCopyCurrent.java @@ -44,8 +44,7 @@ import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.Specialization; @@ -60,11 +59,10 @@ public abstract class PyContextCopyCurrent extends PNodeWithContext { public abstract PContextVarsContext execute(Node inliningTarget); @Specialization - static PContextVarsContext doIt(Node inliningTarget, - @Cached(inline = false) PythonObjectFactory factory) { + static PContextVarsContext doIt(Node inliningTarget) { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); PythonContext.PythonThreadState threadState = context.getThreadState(language); - return factory.copyContextVarsContext(threadState.getContextVarsContext()); + return PFactory.copyContextVarsContext(language, threadState.getContextVarsContext()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictKeys.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictKeys.java index f928bdc036..ea0ede1ae7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictKeys.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetIterator; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageIterator; @@ -47,7 +48,8 @@ import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageIteratorNext; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -67,7 +69,7 @@ public abstract class PyDictKeys extends Node { @Specialization static Object getString(Node inliningTarget, PDict dict, - @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached HashingStorageLen lenNode, @Cached HashingStorageGetIterator getIter, @Cached HashingStorageIteratorNext iterNext, @@ -80,6 +82,6 @@ static Object getString(Node inliningTarget, PDict dict, while (iterNext.execute(inliningTarget, storage, it)) { keys[i++] = iterKey.execute(inliningTarget, storage, it); } - return factory.createList(keys); + return PFactory.createList(language, keys); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportImport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportImport.java index 3db032bdf8..7c056c7d2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportImport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportImport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -47,13 +47,15 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T___IMPORT__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.GetDictFromGlobalsNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -86,7 +88,7 @@ static Object doGeneric(VirtualFrame frame, Node inliningTarget, TruffleString m @Cached(inline = false) AbstractImportNode.PyImportImportModuleLevelObject importModuleLevelObject, @Cached PyEvalGetGlobals getGlobals, @Cached(inline = false) GetDictFromGlobalsNode getDictFromGlobals, - @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { // Get the builtins from current globals Object globals = getGlobals.execute(frame, inliningTarget); Object builtins; @@ -95,7 +97,7 @@ static Object doGeneric(VirtualFrame frame, Node inliningTarget, TruffleString m } else { // No globals -- use standard builtins, and fake globals builtins = importModuleLevelObject.execute(frame, PythonContext.get(inliningTarget), T_BUILTINS, null, null, 0); - globals = factory.createDict(new PKeyword[]{new PKeyword(T___BUILTINS__, builtins)}); + globals = PFactory.createDict(language, new PKeyword[]{new PKeyword(T___BUILTINS__, builtins)}); } // Get the __import__ function from the builtins @@ -110,7 +112,7 @@ static Object doGeneric(VirtualFrame frame, Node inliningTarget, TruffleString m // here. Calling for side-effect of import. callNode.execute(frame, importFunc, new Object[]{moduleName}, new PKeyword[]{ new PKeyword(T_GLOBALS, globals), new PKeyword(T_LOCALS, globals), - new PKeyword(T_FROMLIST, factory.createList()), new PKeyword(T_LEVEL, 0) + new PKeyword(T_FROMLIST, PFactory.createList(language)), new PKeyword(T_LEVEL, 0) }); return importGetModule.execute(frame, inliningTarget, moduleName); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java index 5861c329e1..0c9af9ddc3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.iterator.PBigRangeIterator; import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator; @@ -52,7 +53,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -81,10 +82,10 @@ Object doIntRange(PIntRangeIterator iterator) { } @Specialization - Object doBigIntRange(PBigRangeIterator iterator, - @Cached PythonObjectFactory factory) { + static Object doBigIntRange(PBigRangeIterator iterator, + @Bind("this") Node inliningTarget) { if (iterator.hasNextBigInt()) { - return factory.createInt(iterator.nextBigInt()); + return PFactory.createInt(PythonLanguage.get(inliningTarget), iterator.nextBigInt()); } iterator.setExhausted(); return null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongCopy.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongCopy.java index 7c7698e273..b894177240 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongCopy.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongCopy.java @@ -40,12 +40,13 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.cext.PythonNativeVoidPtr; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -96,8 +97,8 @@ static long doPIntOverridenNarrowLong(PInt obj) throws OverflowException { @Specialization(guards = "!isBuiltinPInt(obj)", replaces = "doPIntOverridenNarrowLong") static PInt doPIntOverriden(PInt obj, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(obj.getValue()); + @Bind PythonLanguage language) { + return PFactory.createInt(language, obj.getValue()); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java index f633950d5c..7ce2c7818b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -47,11 +47,13 @@ import java.math.BigInteger; import java.math.MathContext; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.MathGuards; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -83,8 +85,8 @@ static long doLong(double value) { @Specialization(guards = {"!fitLong(value)", "isFinite(value)"}) static Object doFinite(double value, - @Cached(inline = false) PythonObjectFactory factory) { - return factory.createInt(toBigInteger(value)); + @Bind PythonLanguage language) { + return PFactory.createInt(language, toBigInteger(value)); } @Specialization(guards = "!isFinite(value)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java index c854537115..2a543b400a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java @@ -51,7 +51,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -127,7 +127,6 @@ static Object doGeneric(TruffleString numberTs, int base, byte[] originalBytes, @Cached InlinedBranchProfile invalidBase, @Cached InlinedBranchProfile notSimpleDecimalLiteralProfile, @Cached InlinedBranchProfile invalidValueProfile, - @Cached PythonObjectFactory factory, @Cached PRaiseNode.Lazy raiseNode, @Cached StringNodes.StringReprNode stringReprNode, @Cached BytesNodes.BytesReprNode bytesReprNode) { @@ -138,14 +137,14 @@ static Object doGeneric(TruffleString numberTs, int base, byte[] originalBytes, } notSimpleDecimalLiteralProfile.enter(inliningTarget); PythonContext context = PythonContext.get(inliningTarget); - Object value = stringToIntInternal(number, base, context, factory); + Object value = stringToIntInternal(number, base, context); if (value == null) { invalidValueProfile.enter(inliningTarget); Object repr; if (originalBytes == null) { repr = stringReprNode.execute(numberTs); } else { - repr = bytesReprNode.execute(inliningTarget, factory.createBytes(originalBytes, originalBytesLen)); + repr = bytesReprNode.execute(inliningTarget, PFactory.createBytes(context.getLanguage(inliningTarget), originalBytes, originalBytesLen)); } throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_LITERAL_FOR_INT_WITH_BASE, base, repr); } @@ -153,14 +152,14 @@ static Object doGeneric(TruffleString numberTs, int base, byte[] originalBytes, } @TruffleBoundary - private static Object stringToIntInternal(String num, int base, PythonContext context, PythonObjectFactory factory) { + private static Object stringToIntInternal(String num, int base, PythonContext context) { try { BigInteger bi = asciiToBigInteger(num, base, context); if (bi == null) { return null; } if (bi.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0 || bi.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) < 0) { - return factory.createInt(bi); + return PFactory.createInt(context.getLanguage(), bi); } else { return bi.intValue(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java index 2d02aa4da8..9447f3c01a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -64,7 +64,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeByteSequenceStorage; import com.oracle.graal.python.util.BufferFormat; import com.oracle.truffle.api.CompilerDirectives; @@ -89,10 +89,10 @@ public abstract class PyMemoryViewFromObject extends PNodeWithContext { @Specialization static PMemoryView fromMemoryView(PMemoryView object, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { object.checkReleased(inliningTarget, raiseNode); - return factory.createMemoryView(PythonContext.get(inliningTarget), object.getLifecycleManager(), object.getBuffer(), object.getOwner(), object.getLength(), + PythonContext context = PythonContext.get(inliningTarget); + return PFactory.createMemoryView(context.getLanguage(inliningTarget), context, object.getLifecycleManager(), object.getBuffer(), object.getOwner(), object.getLength(), object.isReadOnly(), object.getItemSize(), object.getFormat(), object.getFormatString(), object.getDimensions(), object.getBufferPointer(), object.getOffset(), object.getBufferShape(), object.getBufferStrides(), object.getBufferSuboffsets(), object.getFlags()); @@ -137,7 +137,6 @@ static PMemoryView fromManaged(VirtualFrame frame, Object object, @Cached HiddenAttr.ReadNode readGetBufferNode, @Cached HiddenAttr.ReadNode readReleaseBufferNode, @Cached CallNode callNode, - @Shared @Cached PythonObjectFactory factory, @Cached MemoryViewNodes.InitFlagsNode initFlagsNode, @Cached TruffleString.CodePointLengthNode lengthNode, @Cached TruffleString.CodePointAtIndexNode atIndexNode, @@ -145,8 +144,9 @@ static PMemoryView fromManaged(VirtualFrame frame, Object object, Object typeObj = getClassNode.execute(inliningTarget, object); assert typeObj instanceof PythonBuiltinClassType || typeObj instanceof PythonAbstractObject; PythonAbstractObject type; + PythonContext context = PythonContext.get(inliningTarget); if (isBuiltinClassTypeProfile.profile(inliningTarget, typeObj instanceof PythonBuiltinClassType)) { - type = PythonContext.get(inliningTarget).lookupType((PythonBuiltinClassType) typeObj); + type = context.lookupType((PythonBuiltinClassType) typeObj); } else { type = (PythonAbstractObject) typeObj; } @@ -179,13 +179,15 @@ static PMemoryView fromManaged(VirtualFrame frame, Object object, // TODO when Sulong allows exposing pointers as interop buffer, we can get rid of this Object pythonBuffer = NativeByteSequenceStorage.create(cBuffer.getBuf(), cBuffer.getLen(), cBuffer.getLen(), false); TruffleString format = cBuffer.getFormat(); - return factory.createMemoryView(PythonContext.get(inliningTarget), bufferLifecycleManager, pythonBuffer, cBuffer.getObj(), cBuffer.getLen(), cBuffer.isReadOnly(), cBuffer.getItemSize(), + return PFactory.createMemoryView(context.getLanguage(inliningTarget), context, bufferLifecycleManager, pythonBuffer, cBuffer.getObj(), cBuffer.getLen(), cBuffer.isReadOnly(), + cBuffer.getItemSize(), BufferFormat.forMemoryView(format, lengthNode, atIndexNode), format, cBuffer.getDims(), cBuffer.getBuf(), 0, shape, strides, suboffsets, flags); } else if (bufferAcquireLib.hasBuffer(object)) { // Managed object that implements PythonBufferAcquireLibrary Object buffer = bufferAcquireLib.acquire(object, BufferFlags.PyBUF_FULL_RO, frame, indirectCallData); - return factory.createMemoryViewForManagedObject(buffer, bufferLib.getOwner(buffer), bufferLib.getItemSize(buffer), bufferLib.getBufferLength(buffer), bufferLib.isReadonly(buffer), + return PFactory.createMemoryViewForManagedObject(context.getLanguage(inliningTarget), buffer, bufferLib.getOwner(buffer), bufferLib.getItemSize(buffer), bufferLib.getBufferLength(buffer), + bufferLib.isReadonly(buffer), bufferLib.getFormatString(buffer), lengthNode, atIndexNode); } else { throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_A_BYTES_LIKE_OBJECT_REQUIRED_NOT_P, object); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 91ee5c1a5d..221c0d2270 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -42,6 +42,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; @@ -59,9 +60,10 @@ import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -142,21 +144,20 @@ protected static SequenceStorageNodes.ConcatNode createConcat() { return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); } - @Specialization - static PList doPList(Node inliningTarget, PList left, PList right, - @Exclusive @Cached GetClassNode getClassNode, + @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"}) + static PList doPList(PList left, PList right, @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage newStore = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); - return factory.createList(getClassNode.execute(inliningTarget, left), newStore); + return PFactory.createList(language, newStore); } @Specialization(guards = {"isBuiltinTuple(left)", "isBuiltinTuple(right)"}) - static PTuple doTuple(Node inliningTarget, PTuple left, PTuple right, + static PTuple doTuple(PTuple left, PTuple right, @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage concatenated = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); - return factory.createTuple(concatenated); + return PFactory.createTuple(language, concatenated); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java index b783cf527c..fbd4580f62 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java @@ -43,6 +43,7 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CLASS_GETITEM__; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.dict.DictBuiltins; @@ -62,7 +63,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinClassExactProfile; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -155,7 +156,6 @@ static Object tryType(VirtualFrame frame, Node inliningTarget, Object maybeType, @Cached TypeNodes.IsTypeNode isTypeNode, @Cached PyObjectLookupAttr lookupClassGetItem, @Cached IsBuiltinClassExactProfile isBuiltinClassProfile, - @Cached(inline = false) PythonObjectFactory factory, @Cached(inline = false) CallNode callClassGetItem, @Cached PRaiseNode.Lazy raiseNode) { if (isTypeNode.execute(inliningTarget, maybeType)) { @@ -165,7 +165,7 @@ static Object tryType(VirtualFrame frame, Node inliningTarget, Object maybeType, } if (isBuiltinClassProfile.profileClass(inliningTarget, maybeType, PythonBuiltinClassType.PythonClass)) { // Special case type[int], but disallow other types so str[int] fails - return factory.createGenericAlias(maybeType, key); + return PFactory.createGenericAlias(PythonLanguage.get(inliningTarget), maybeType, key); } throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_NOT_SUBSCRIPTABLE, maybeType); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java index d6c04509b2..2b34a90c7a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +42,7 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.range.PIntRange; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; @@ -51,10 +52,10 @@ import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -84,8 +85,8 @@ public final Object executeCached(Frame frame, Object receiver) { @Specialization static Object getIterRange(PIntRange object, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntRangeIterator(object); + @Bind PythonLanguage language) { + return PFactory.createIntRangeIterator(language, object); } @Specialization @@ -94,7 +95,7 @@ static Object getIter(Frame frame, Node inliningTarget, Object receiver, @Cached GetClassNode getReceiverClass, @Cached(parameters = "Iter", inline = false) LookupSpecialMethodSlotNode lookupIter, @Cached PySequenceCheckNode sequenceCheckNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raise, @Cached(inline = false) CallUnaryMethodNode callIter, @Cached PyIterCheckNode checkNode) { @@ -107,7 +108,7 @@ static Object getIter(Frame frame, Node inliningTarget, Object receiver, } if (iterMethod instanceof PNone) { if (sequenceCheckNode.execute(inliningTarget, receiver)) { - return factory.createSequenceIterator(receiver); + return PFactory.createSequenceIterator(language, receiver); } } else { Object result = callIter.executeObject(frame, iterMethod, receiver); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java index bcc4a7c448..dc0c42ef60 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java @@ -42,6 +42,7 @@ import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; @@ -58,9 +59,10 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -84,21 +86,20 @@ protected static SequenceStorageNodes.ConcatNode createConcat() { return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); } - @Specialization - static PList doPList(Node inliningTarget, PList left, PList right, - @Exclusive @Cached GetClassNode getClassNode, + @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"}) + static PList doPList(PList left, PList right, @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage newStore = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); - return factory.createList(getClassNode.execute(inliningTarget, left), newStore); + return PFactory.createList(language, newStore); } @Specialization(guards = {"isBuiltinTuple(left)", "isBuiltinTuple(right)"}) static PTuple doTuple(PTuple left, PTuple right, @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { SequenceStorage concatenated = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); - return factory.createTuple(concatenated); + return PFactory.createTuple(language, concatenated); } @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySliceNew.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySliceNew.java index e4380f48dd..516c0b2c29 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySliceNew.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySliceNew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -40,12 +40,13 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.slice.PSlice; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -66,42 +67,42 @@ public abstract class PySliceNew extends PNodeWithContext { @SuppressWarnings("unused") static PSlice doInt(int start, int stop, PNone step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntSlice(start, stop, 1, false, true); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, start, stop, 1, false, true); } @Specialization static PSlice doInt(int start, int stop, int step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntSlice(start, stop, step); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, start, stop, step); } @Specialization @SuppressWarnings("unused") static PSlice doInt(PNone start, int stop, PNone step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntSlice(0, stop, 1, true, true); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, 0, stop, 1, true, true); } @Specialization @SuppressWarnings("unused") static PSlice doInt(PNone start, int stop, int step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntSlice(0, stop, step, true, false); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, 0, stop, step, true, false); } // This specialization is often used when called from C builtins @Specialization(guards = {"isIntRange(start)", "isIntRange(stop)"}) @SuppressWarnings("unused") static PSlice doLong(long start, long stop, PNone step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { - return factory.createIntSlice((int) start, (int) stop, 1, false, true); + @Bind PythonLanguage language) { + return PFactory.createIntSlice(language, (int) start, (int) stop, 1, false, true); } @Fallback static PSlice doGeneric(Object start, Object stop, Object step, - @Cached.Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { assert start != PNone.NO_VALUE && stop != PNone.NO_VALUE && step != PNone.NO_VALUE; - return factory.createObjectSlice(start, stop, step); + return PFactory.createObjectSlice(language, start, stop, step); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java index 292ed5e8d9..3d8e435398 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -55,6 +55,7 @@ import java.nio.charset.StandardCharsets; import com.oracle.graal.python.PythonFileDetector; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.code.PCode; import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; @@ -73,7 +74,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -229,9 +230,9 @@ public static TruffleString classNameNoDot(TruffleString name) { return (i > 0) ? name.substringUncached(i + 1, len - i - 1, TS_ENCODING, true) : name; } - public PCode getCode(VirtualFrame frame, PythonObjectFactory factory, TracebackBuiltins.GetTracebackFrameNode getTbFrameNode, PTraceback tb) { + public PCode getCode(VirtualFrame frame, PythonLanguage language, TracebackBuiltins.GetTracebackFrameNode getTbFrameNode, PTraceback tb) { final PFrame pFrame = getTbFrameNode.execute(frame, tb); - return factory.createCode(pFrame.getTarget()); + return PFactory.createCode(language, pFrame.getTarget()); } protected PTraceback getNextTb(Node inliningTarget, TracebackBuiltins.MaterializeTruffleStacktraceNode materializeStNode, PTraceback traceback) { @@ -333,7 +334,7 @@ private static String trimLeft(CharSequence sequence) { return (st > 0 ? sequence.subSequence(st, len) : sequence).toString(); } - private void printInternal(VirtualFrame frame, Node inliningTarget, PythonObjectFactory factory, TracebackBuiltins.GetTracebackFrameNode getTbFrameNode, + private void printInternal(VirtualFrame frame, Node inliningTarget, TracebackBuiltins.GetTracebackFrameNode getTbFrameNode, TracebackBuiltins.MaterializeTruffleStacktraceNode materializeStNode, Object out, PTraceback traceback, long limit, TruffleString.EqualNode equalNode) { int depth = 0; @@ -351,8 +352,9 @@ private void printInternal(VirtualFrame frame, Node inliningTarget, PythonObject depth--; tb = getNextTb(inliningTarget, materializeStNode, tb); } + PythonLanguage language = PythonLanguage.get(inliningTarget); while (tb != null) { - final PCode code = getCode(frame, factory, getTbFrameNode, tb); + final PCode code = getCode(frame, language, getTbFrameNode, tb); if (lastFile == null || !equalNode.execute(code.getFilename(), lastFile, TS_ENCODING) || lastLine == -1 || tb.getLineno() != lastLine || @@ -383,7 +385,6 @@ public void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, PTr @Bind("this") Node inliningTarget, @Cached TracebackBuiltins.GetTracebackFrameNode getTbFrameNode, @Cached TracebackBuiltins.MaterializeTruffleStacktraceNode materializeStNode, - @Cached PythonObjectFactory factory, @Cached TruffleString.EqualNode equalNode) { long limit = TRACEBACK_LIMIT; final Object limitv = objectReadAttr(sys, T_TRACEBACKLIMIT); @@ -394,7 +395,7 @@ public void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, PTr } } fileWriteString(frame, out, "Traceback (most recent call last):\n"); - printInternal(frame, inliningTarget, factory, getTbFrameNode, materializeStNode, out, tb, limit, equalNode); + printInternal(frame, inliningTarget, getTbFrameNode, materializeStNode, out, tb, limit, equalNode); } @Specialization(guards = "!isPTraceback(tb)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java index 4ec03aba27..7f33752253 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 +45,7 @@ import static com.oracle.graal.python.runtime.exception.PythonErrorType.RuntimeWarning; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins; import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins; import com.oracle.graal.python.builtins.objects.PNone; @@ -53,7 +54,7 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -137,7 +138,7 @@ static Object doRegistry(VirtualFrame frame, Node inliningTarget, Object unicode // If the codec returns a buffer, raise a warning and convert to bytes if (isByteArrayProfile.profile(inliningTarget, v instanceof PByteArray)) { warnNode.warnFormat(frame, RuntimeWarning, ENCODER_S_RETURNED_S_INSTEAD_OF_BYTES, encoding, "bytearray"); - return PythonContext.get(inliningTarget).factory().createBytes(copyNode.execute(inliningTarget, ((PByteArray) v).getSequenceStorage())); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), copyNode.execute(inliningTarget, ((PByteArray) v).getSequenceStorage())); } throw raiseNode.get(inliningTarget).raise(TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, v); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java index fc25919b70..70cc0d8e18 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java @@ -43,6 +43,7 @@ import static com.oracle.graal.python.nodes.ErrorMessages.DECODING_STR_NOT_SUPPORTED; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; +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.buffer.PythonBufferAcquireLibrary; @@ -52,7 +53,8 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -103,12 +105,12 @@ static Object doPString(VirtualFrame frame, PString object, Object encoding, Obj @Specialization(guards = {"!isPBytes(object)", "!isString(object)"}, limit = "3") static Object doBuffer(VirtualFrame frame, Node inliningTarget, Object object, Object encoding, Object errors, + @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallNode, @Exclusive @Cached InlinedConditionProfile emptyStringProfile, @CachedLibrary("object") PythonBufferAcquireLibrary bufferAcquireLib, @Exclusive @Cached PyUnicodeDecode decode, - @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached(inline = false) PythonObjectFactory factory) { + @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib) { PythonContext context = PythonContext.get(inliningTarget); Object buffer = bufferAcquireLib.acquireReadonly(object, frame, context, context.getLanguage(inliningTarget), indirectCallNode); try { @@ -116,7 +118,7 @@ static Object doBuffer(VirtualFrame frame, Node inliningTarget, Object object, O if (emptyStringProfile.profile(inliningTarget, len == 0)) { return T_EMPTY_STRING; } - PBytes bytes = factory.createBytes(bufferLib.getInternalOrCopiedByteArray(buffer), len); + PBytes bytes = PFactory.createBytes(language, bufferLib.getInternalOrCopiedByteArray(buffer), len); return decode.execute(frame, inliningTarget, bytes, encoding, errors); } finally { bufferLib.release(buffer, frame, indirectCallNode); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java index 4d0883a97f..5cf3878eec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -53,9 +53,10 @@ import com.oracle.graal.python.nodes.PRaiseNodeGen.LazyNodeGen; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; @@ -186,43 +187,43 @@ static PException doPythonBuiltinTypeCached(Node raisingNode, @SuppressWarnings( @SuppressWarnings("unused") PNone format, @SuppressWarnings("unused") Object[] arguments, @Cached("exceptionType") PythonBuiltinClassType cachedType, - @Shared("factory") @Cached PythonObjectFactory factory) { - throw raiseExceptionObject(raisingNode, factory.createBaseException(cachedType, data)); + @Bind PythonLanguage language) { + throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, cachedType, data)); } @Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0"}, replaces = "doPythonBuiltinTypeCached") static PException doPythonBuiltinType(Node raisingNode, PythonBuiltinClassType exceptionType, Object[] data, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format, @SuppressWarnings("unused") Object[] arguments, - @Shared("factory") @Cached PythonObjectFactory factory) { - throw raiseExceptionObject(raisingNode, factory.createBaseException(exceptionType, data)); + @Bind PythonLanguage language) { + throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, exceptionType, data)); } @Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length > 0"}) static PException doBuiltinType(Node raisingNode, PythonBuiltinClassType type, Object[] data, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format, Object[] arguments, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { ensureNoJavaStrings(arguments, fromJavaStringNode); - throw raiseExceptionObject(raisingNode, factory.createBaseException(type, data, factory.createTuple(arguments))); + throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, type, data, PFactory.createTuple(language, arguments))); } @Specialization(guards = {"isNoValue(cause)"}) static PException doBuiltinType(Node raisingNode, PythonBuiltinClassType type, Object[] data, @SuppressWarnings("unused") PNone cause, TruffleString format, Object[] arguments, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { assert format != null; ensureNoJavaStrings(arguments, fromJavaStringNode); - throw raiseExceptionObject(raisingNode, factory.createBaseException(type, data, format, arguments)); + throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, type, data, format, arguments)); } @Specialization(guards = {"!isNoValue(cause)"}) static PException doBuiltinTypeWithCause(Node raisingNode, PythonBuiltinClassType type, Object[] data, PBaseException cause, TruffleString format, Object[] arguments, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { assert format != null; ensureNoJavaStrings(arguments, fromJavaStringNode); - PBaseException baseException = factory.createBaseException(type, data, format, arguments); + PBaseException baseException = PFactory.createBaseException(language, type, data, format, arguments); baseException.setContext(cause); baseException.setCause(cause); throw raiseExceptionObject(raisingNode, baseException); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/WriteUnraisableNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/WriteUnraisableNode.java index 3d87604cbc..e25713eb89 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/WriteUnraisableNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/WriteUnraisableNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -46,6 +46,7 @@ import java.io.IOException; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.SysModuleBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; @@ -55,7 +56,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -89,7 +90,7 @@ static void writeUnraisable(VirtualFrame frame, Object exception, TruffleString @Cached PyObjectLookupAttr lookup, @Cached CallNode callNode, @Cached GetClassNode getClassNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached ExceptionNodes.GetTracebackNode getTracebackNode, @Cached TruffleString.ConcatNode concatNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode) { @@ -103,7 +104,8 @@ static void writeUnraisable(VirtualFrame frame, Object exception, TruffleString if (message != null) { messageObj = formatMessage(message, concatNode); } - Object hookArguments = factory.createStructSeq(SysModuleBuiltins.UNRAISABLEHOOK_ARGS_DESC, exceptionType, exception, traceback, messageObj, object != null ? object : PNone.NONE); + Object hookArguments = PFactory.createStructSeq(language, SysModuleBuiltins.UNRAISABLEHOOK_ARGS_DESC, exceptionType, exception, traceback, messageObj, + object != null ? object : PNone.NONE); callNode.execute(frame, unraisablehook, hookArguments); } catch (PException e) { ignoreException(context, message, concatNode, copyToByteArrayNode); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarArgsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarArgsNode.java index 716e488391..10f3ad8cc6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarArgsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarArgsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -25,16 +25,17 @@ */ package com.oracle.graal.python.nodes.argument; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; public abstract class ReadVarArgsNode extends ReadArgumentNode { - @Child private PythonObjectFactory factory; + private final boolean isBuiltin; ReadVarArgsNode(boolean isBuiltin) { - factory = isBuiltin ? null : PythonObjectFactory.create(); + this.isBuiltin = isBuiltin; } public static ReadVarArgsNode create() { @@ -56,11 +57,11 @@ private Object output(Object[] varArgs) { if (isBuiltin()) { return varArgs; } else { - return factory.createTuple(varArgs); + return PFactory.createTuple(PythonLanguage.get(this), varArgs); } } public boolean isBuiltin() { - return factory == null; + return isBuiltin; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarKeywordsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarKeywordsNode.java index e09a866e44..8f6a0f059b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarKeywordsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/ReadVarKeywordsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -33,7 +33,7 @@ import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -47,7 +47,7 @@ public abstract class ReadVarKeywordsNode extends ReadArgumentNode { @CompilationFinal(dimensions = 1) private final TruffleString[] keywordNames; - @Child private PythonObjectFactory factory; + private final boolean doWrap; public abstract PKeyword[] executePKeyword(VirtualFrame frame); @@ -65,7 +65,7 @@ public static ReadVarKeywordsNode createForUserFunction(TruffleString[] names) { ReadVarKeywordsNode(TruffleString[] keywordNames, boolean doWrap) { this.keywordNames = keywordNames; - this.factory = doWrap ? PythonObjectFactory.create() : null; + this.doWrap = doWrap; } protected int getLimit() { @@ -86,8 +86,8 @@ protected static int getKwargLen(VirtualFrame frame) { } private Object returnValue(PKeyword[] keywords) { - if (factory != null) { - return factory.createDict(keywords); + if (doWrap) { + return PFactory.createDict(PythonLanguage.get(this), keywords); } else { return keywords; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/capsule/CreateArrowPyCapsuleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/capsule/CreateArrowPyCapsuleNode.java index 0efc521654..6396414b85 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/capsule/CreateArrowPyCapsuleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/capsule/CreateArrowPyCapsuleNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -47,7 +47,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.arrow.ArrowArray; import com.oracle.graal.python.nodes.arrow.ArrowSchema; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -62,8 +62,7 @@ public abstract class CreateArrowPyCapsuleNode extends PNodeWithContext { @Specialization static PTuple doArrowCArray(Node inliningTarget, ArrowArray arrowArray, ArrowSchema arrowSchema, - @Cached PyCapsuleNewNode pyCapsuleNewNode, - @Cached(inline = false) PythonObjectFactory pythonObjectFactory) { + @Cached PyCapsuleNewNode pyCapsuleNewNode) { var ctx = getContext(inliningTarget); long arrayDestructor = ctx.arrowSupport.getArrowArrayDestructor(); var arrayCapsuleName = new CArrayWrappers.CByteArrayWrapper(ArrowArray.CAPSULE_NAME); @@ -73,6 +72,6 @@ static PTuple doArrowCArray(Node inliningTarget, ArrowArray arrowArray, ArrowSch var schemaCapsuleName = new CArrayWrappers.CByteArrayWrapper(ArrowSchema.CAPSULE_NAME); PyCapsule arrowSchemaCapsule = pyCapsuleNewNode.execute(inliningTarget, arrowSchema.memoryAddr, schemaCapsuleName, schemaDestructor); - return pythonObjectFactory.createTuple(new Object[]{arrowSchemaCapsule, arrowArrayCapsule}); + return PFactory.createTuple(ctx.getLanguage(inliningTarget), new Object[]{arrowSchemaCapsule, arrowArrayCapsule}); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java index eee49e41de..14f01bf355 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java @@ -46,6 +46,7 @@ import static com.oracle.graal.python.nodes.ErrorMessages.DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; @@ -54,10 +55,7 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.str.PString; -import com.oracle.graal.python.builtins.objects.str.StringUtils; import com.oracle.graal.python.lib.PyObjectGetIter; -import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.builtins.ListNodesFactory.AppendNodeGen; @@ -65,9 +63,7 @@ import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; -import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ArrayBasedSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; @@ -79,12 +75,10 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.Frame; @@ -96,8 +90,6 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleStringIterator; /** See the docs on {@link com.oracle.graal.python.builtins.objects.list.ListBuiltins}. */ public abstract class ListNodes { @@ -203,68 +195,35 @@ static Object doForeign(Object list) { } @GenerateUncached - @ImportStatic({PGuards.class, PythonOptions.class}) @GenerateInline(false) // footprint reduction 40 -> 21 public abstract static class ConstructListNode extends PNodeWithContext { - public final PList execute(Frame frame, Object value) { - return execute(frame, PythonBuiltinClassType.PList, value); - } - - protected abstract PList execute(Frame frame, Object cls, Object value); - - @Specialization - static PList listString(Object cls, TruffleString arg, - @Shared @Cached PythonObjectFactory factory, - @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Shared @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, - @Shared @Cached TruffleStringIterator.NextNode nextNode, - @Shared @Cached TruffleString.FromCodePointNode fromCodePointNode) { - return factory.createList(cls, StringUtils.toCharacterArray(arg, codePointLengthNode, createCodePointIteratorNode, nextNode, fromCodePointNode)); - } - - @Specialization - static PList listString(Object cls, PString arg, - @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, - @Cached CastToTruffleStringNode castToStringNode, - @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Shared @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, - @Shared @Cached TruffleStringIterator.NextNode nextNode, - @Shared @Cached TruffleString.FromCodePointNode fromCodePointNode) { - return listString(cls, castToStringNode.execute(inliningTarget, arg), factory, codePointLengthNode, createCodePointIteratorNode, nextNode, fromCodePointNode); - } + public abstract PList execute(Frame frame, Object value); @Specialization(guards = "isNoValue(none)") - static PList none(Object cls, @SuppressWarnings("unused") PNone none, - @Shared @Cached PythonObjectFactory factory) { - return factory.createList(cls); + static PList none(@SuppressWarnings("unused") PNone none, + @Bind PythonLanguage language) { + return PFactory.createList(language); } @Specialization(guards = "isBuiltinList(list)") // Don't use PSequence, that might copy storages that we don't allow for lists - static PList fromList(Object cls, PList list, + static PList fromList(PList list, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached SequenceStorageNodes.CopyNode copyNode) { - return factory.createList(cls, copyNode.execute(inliningTarget, list.getSequenceStorage())); + return PFactory.createList(language, copyNode.execute(inliningTarget, list.getSequenceStorage())); } - @Specialization(guards = {"!isNoValue(iterable)", "!isString(iterable)"}) - static PList listIterable(VirtualFrame frame, Object cls, Object iterable, + @Specialization(guards = "!isNoValue(iterable)") + static PList listIterable(VirtualFrame frame, Object iterable, @Bind("this") Node inliningTarget, @Cached PyObjectGetIter getIter, @Cached SequenceStorageNodes.CreateStorageFromIteratorNode createStorageFromIteratorNode, - @Shared @Cached PythonObjectFactory factory) { + @Bind PythonLanguage language) { Object iterObj = getIter.execute(frame, inliningTarget, iterable); SequenceStorage storage = createStorageFromIteratorNode.execute(frame, iterObj); - return factory.createList(cls, storage); - } - - @Fallback - static PList listObject(@SuppressWarnings("unused") Object cls, Object value) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere("list does not support iterable object " + value); + return PFactory.createList(language, storage); } @NeverDefault @@ -292,7 +251,7 @@ protected static PSequence doPList(PSequence value) { @Fallback protected PSequence doGeneric(VirtualFrame frame, Object value, @Cached(inline = false) ConstructListNode constructListNode) { - return constructListNode.execute(frame, PythonBuiltinClassType.PList, value); + return constructListNode.execute(frame, value); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/TupleNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/TupleNodes.java index 583ef42436..144d6c65bb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/TupleNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/TupleNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -43,23 +43,23 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTupleObject__ob_item; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyVarObject__ob_size; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.CreateStorageFromIteratorNode; +import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.lib.PyTupleCheckNode; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.NativeObjectSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -75,38 +75,36 @@ public abstract class TupleNodes { @GenerateUncached @GenerateInline(false) // footprint reduction 40 -> 21 public abstract static class ConstructTupleNode extends PNodeWithContext { - public final PTuple execute(VirtualFrame frame, Object value) { - return execute(frame, PythonBuiltinClassType.PTuple, value); - } - - public abstract PTuple execute(Frame frame, Object cls, Object value); + public abstract PTuple execute(Frame frame, Object value); @Specialization(guards = "isNoValue(none)") - static PTuple tuple(Object cls, @SuppressWarnings("unused") PNone none, - @Shared("factory") @Cached PythonObjectFactory factory) { - return factory.createEmptyTuple(cls); + static PTuple tuple(@SuppressWarnings("unused") PNone none, + @Bind PythonLanguage language) { + return PFactory.createEmptyTuple(language); } - @Specialization(guards = {"isBuiltinTupleType(inliningTarget, cls, isSameTypeNode)", "isBuiltinTuple(iterable)"}, limit = "1") - static PTuple tuple(@SuppressWarnings("unused") Object cls, PTuple iterable, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached TypeNodes.IsSameTypeNode isSameTypeNode) { + @Specialization(guards = "isBuiltinTuple(iterable)") + static PTuple tuple(PTuple iterable) { return iterable; } + @Specialization(guards = "isBuiltinList(iterable)") + static PTuple list(PList iterable, + @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached SequenceStorageNodes.CopyNode copyNode) { + return PFactory.createTuple(language, copyNode.execute(inliningTarget, iterable.getSequenceStorage())); + } + @Fallback @InliningCutoff - static PTuple tuple(VirtualFrame frame, Object cls, Object iterable, + static PTuple generic(VirtualFrame frame, Object iterable, @Bind("this") Node inliningTarget, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached CreateStorageFromIteratorNode storageNode, @Cached PyObjectGetIter getIter) { Object iterObj = getIter.execute(frame, inliningTarget, iterable); - return factory.createTuple(cls, storageNode.execute(frame, iterObj)); - } - - protected static boolean isBuiltinTupleType(Node inliningTarget, Object cls, TypeNodes.IsSameTypeNode isSameTypeNode) { - return isSameTypeNode.execute(inliningTarget, cls, PythonBuiltinClassType.PTuple); + return PFactory.createTuple(language, storageNode.execute(frame, iterObj)); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/CopyDictWithoutKeysNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/CopyDictWithoutKeysNode.java index e6694902f8..96d9628273 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/CopyDictWithoutKeysNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/CopyDictWithoutKeysNode.java @@ -40,11 +40,12 @@ */ package com.oracle.graal.python.nodes.bytecode; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.dict.DictNodes; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.lib.PyDictDelItem; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -65,10 +66,10 @@ public abstract class CopyDictWithoutKeysNode extends PNodeWithContext { static PDict copy(VirtualFrame frame, Object subject, @NeverDefault @SuppressWarnings("unused") Object[] keys, @Bind("this") Node inliningTarget, @Cached("keys.length") int keysLength, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached DictNodes.UpdateNode updateNode, @Shared @Cached PyDictDelItem delItem) { - PDict rest = factory.createDict(); + PDict rest = PFactory.createDict(language); updateNode.execute(frame, rest, subject); deleteKeys(frame, inliningTarget, keys, keysLength, delItem, rest); return rest; @@ -85,10 +86,10 @@ private static void deleteKeys(VirtualFrame frame, Node inliningTarget, Object[] @Specialization(guards = "keys.length > 32") static PDict copy(VirtualFrame frame, Object subject, Object[] keys, @Bind("this") Node inliningTarget, - @Shared @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared @Cached DictNodes.UpdateNode updateNode, @Shared @Cached PyDictDelItem delItem) { - PDict rest = factory.createDict(); + PDict rest = PFactory.createDict(language); updateNode.execute(frame, rest, subject); for (int i = 0; i < keys.length; i++) { delItem.execute(frame, inliningTarget, rest, keys[i]); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java index b032f7da80..637625706c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -53,12 +53,13 @@ import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.Assumption; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -83,7 +84,7 @@ public MakeFunctionNode(RootCallTarget callTarget, CodeUnit code, Signature sign @Specialization int makeFunction(VirtualFrame frame, Object globals, int initialStackTop, int flags, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached WriteAttributeToPythonObjectNode writeAttrNode) { int stackTop = initialStackTop; @@ -95,10 +96,10 @@ int makeFunction(VirtualFrame frame, Object globals, int initialStackTop, int fl * We cannot initialize the cached code in create, because that may be called * without langauge context when materializing nodes for instrumentation */ - cachedCode = codeObj = factory.createCode(callTarget, signature, code); + cachedCode = codeObj = PFactory.createCode(language, callTarget, signature, code); } else { // In multi-context mode we have to create the code for every execution - codeObj = factory.createCode(callTarget, signature, code); + codeObj = PFactory.createCode(language, callTarget, signature, code); } } @@ -133,7 +134,8 @@ int makeFunction(VirtualFrame frame, Object globals, int initialStackTop, int fl codeStableAssumption = Truffle.getRuntime().createAssumption(); defaultsStableAssumption = Truffle.getRuntime().createAssumption(); } - PFunction function = factory.createFunction(code.name, code.qualname, codeObj, (PythonObject) globals, defaults, kwdefaults, closure, codeStableAssumption, defaultsStableAssumption); + PFunction function = PFactory.createFunction(language, code.name, code.qualname, codeObj, (PythonObject) globals, defaults, kwdefaults, closure, codeStableAssumption, + defaultsStableAssumption); if (annotations != null) { writeAttrNode.execute(function, T___ANNOTATIONS__, annotations); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java index e943d7bf1e..c94084db5b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,6 +44,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATCH_ARGS; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.modules.BuiltinFunctions; import com.oracle.graal.python.builtins.objects.str.StringBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins; @@ -57,7 +58,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -85,7 +86,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD @Cached IsBuiltinObjectProfile isClassProfile, @Cached StringBuiltins.EqNode eqStrNode, @Cached PyTupleCheckExactNode tupleCheckExactNode, - @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PyTupleSizeNode tupleSizeNode, @Cached TupleBuiltins.GetItemNode getItemNode, @Cached PyUnicodeCheckNode unicodeCheckNode, @@ -118,7 +119,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD // it's as if __match_args__ is some "magic" value that is lost as // soon as they redefine it. e.expectAttributeError(inliningTarget, isClassProfile); - matchArgs = factory.createEmptyTuple(); + matchArgs = PFactory.createEmptyTuple(language); matchSelf = (getTypeFlagsNode.execute(type) & MATCH_SELF) != 0; } int allowed = matchSelf ? 1 : tupleSizeNode.execute(inliningTarget, matchArgs); @@ -138,7 +139,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD } // Finally, the keyword subpatterns: getKwArgs(frame, inliningTarget, subject, type, kwArgs, seen, seenLength, attrs, attrsLength, getAttr, eqStrNode, raise); - return factory.createList(attrs); + return PFactory.createList(language, attrs); } @ExplodeLoop diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java index 78329dbc91..b39adc032a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -43,13 +43,14 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T_GET; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; @@ -73,10 +74,9 @@ static Object matchCached(VirtualFrame frame, Object map, @NeverDefault Object[] @Cached("keys.length") int keysLen, @Shared @Cached PyObjectRichCompareBool.EqNode compareNode, @Shared @Cached PyObjectCallMethodObjArgs callMethod, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raise) { Object[] values = getValues(frame, inliningTarget, map, keys, keysLen, compareNode, callMethod, raise); - return values != null ? factory.createTuple(values) : PNone.NONE; + return values != null ? PFactory.createTuple(PythonLanguage.get(inliningTarget), values) : PNone.NONE; } @ExplodeLoop @@ -113,13 +113,12 @@ static Object match(VirtualFrame frame, Object map, Object[] keys, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectRichCompareBool.EqNode compareNode, @Shared @Cached PyObjectCallMethodObjArgs callMethod, - @Shared @Cached PythonObjectFactory factory, @Shared @Cached PRaiseNode.Lazy raise) { if (keys.length == 0) { - return factory.createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); + return PFactory.createTuple(PythonLanguage.get(inliningTarget), PythonUtils.EMPTY_OBJECT_ARRAY); } Object[] values = getValuesLongArray(frame, inliningTarget, map, keys, compareNode, callMethod, raise); - return values != null ? factory.createTuple(values) : PNone.NONE; + return values != null ? PFactory.createTuple(PythonLanguage.get(inliningTarget), values) : PNone.NONE; } private static Object[] getValuesLongArray(VirtualFrame frame, Node inliningTarget, Object map, Object[] keys, PyObjectRichCompareBool.EqNode compareNode, PyObjectCallMethodObjArgs callMethod, @@ -150,8 +149,8 @@ private static void checkSeenLongArray(VirtualFrame frame, Node inliningTarget, @Specialization(guards = "keys.length == 0") static Object matchNoKeys(@SuppressWarnings("unused") Object map, @SuppressWarnings("unused") Object[] keys, - @Shared @Cached PythonObjectFactory factory) { - return factory.createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); + @Bind PythonLanguage language) { + return PFactory.createTuple(language, PythonUtils.EMPTY_OBJECT_ARRAY); } public static MatchKeysNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeGeneratorFunctionRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeGeneratorFunctionRootNode.java index d3d8e9abe7..3487f3612c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeGeneratorFunctionRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeGeneratorFunctionRootNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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.builtins.objects.function.PFunction; import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.nodes.PRootNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; @@ -63,7 +63,6 @@ public class PBytecodeGeneratorFunctionRootNode extends PRootNode { @CompilationFinal(dimensions = 1) private final RootCallTarget[] callTargets; - @Child private PythonObjectFactory factory = PythonObjectFactory.create(); private final ConditionProfile isIterableCoroutine = ConditionProfile.create(); @TruffleBoundary @@ -80,6 +79,7 @@ public PBytecodeGeneratorFunctionRootNode(PythonLanguage language, FrameDescript public Object execute(VirtualFrame frame) { Object[] arguments = frame.getArguments(); + PythonLanguage language = PythonLanguage.get(this); // This is passed from InvokeNode node PFunction generatorFunction = PArguments.getGeneratorFunction(arguments); assert generatorFunction != null; @@ -88,14 +88,14 @@ public Object execute(VirtualFrame frame) { // pass the information to the generator // .gi_code.co_flags will still be wrong, but at least await will work correctly if (isIterableCoroutine.profile((generatorFunction.getCode().getFlags() & 0x100) != 0)) { - return factory.createIterableCoroutine(generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); + return PFactory.createIterableCoroutine(language, generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); } else { - return factory.createGenerator(generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); + return PFactory.createGenerator(language, generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); } } else if (rootNode.getCodeUnit().isCoroutine()) { - return factory.createCoroutine(generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); + return PFactory.createCoroutine(language, generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); } else if (rootNode.getCodeUnit().isAsyncGenerator()) { - return factory.createAsyncGenerator(generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); + return PFactory.createAsyncGenerator(language, generatorFunction.getName(), generatorFunction.getQualname(), rootNode, callTargets, arguments); } throw CompilerDirectives.shouldNotReachHere("Unknown generator/coroutine type"); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index ec48641f73..8ba1f3fb38 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -200,7 +200,7 @@ import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonExitException; import com.oracle.graal.python.runtime.exception.PythonThreadKillException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; @@ -516,7 +516,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod @CompilationFinal(dimensions = 1) private final TruffleString[] freevars; @CompilationFinal(dimensions = 1) private final TruffleString[] cellvars; @CompilationFinal(dimensions = 1) private final int[] cell2arg; - @CompilationFinal(dimensions = 1) protected final Assumption[] cellEffectivelyFinalAssumptions; + @CompilationFinal(dimensions = 1) private final Assumption[] cellEffectivelyFinalAssumptions; @CompilationFinal(dimensions = 1) private final int[] exceptionHandlerRanges; @@ -562,7 +562,6 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod @Children private final Node[] adoptedNodes; @Child private CalleeContext calleeContext = CalleeContext.create(); // TODO: make some of those lazy? - @Child private PythonObjectFactory factory = PythonObjectFactory.create(); @Child private ExceptionStateNodes.GetCaughtExceptionNode getCaughtExceptionNode; @Child private MaterializeFrameNode traceMaterializeFrameNode = null; @Child private ChainExceptionsNode chainExceptionsNode; @@ -570,7 +569,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod @CompilationFinal private Object osrMetadata; @CompilationFinal private boolean usingCachedNodes; - @CompilationFinal(dimensions = 1) private int[] conditionProfiles; + @CompilationFinal(dimensions = 1) private final int[] conditionProfiles; @Child private InstrumentationRoot instrumentationRoot = InstrumentationRoot.create(); @@ -868,6 +867,10 @@ private void doInsertChildNode(Node[] nodes, int nodeIndex, Node newNode) { } } + private PythonLanguage getLanguage() { + return getLanguage(PythonLanguage.class); + } + private static final int CONDITION_PROFILE_MAX_VALUE = 0x3fffffff; // Inlined from ConditionProfile.Counting#profile @@ -1052,10 +1055,10 @@ private void copyArgsAndCells(Frame localFrame, Object[] arguments) { copyArgs(arguments, localFrame); int varIdx = co.getRegularArgCount(); if (co.takesVarArgs()) { - localFrame.setObject(varIdx++, factory.createTuple(PArguments.getVariableArguments(arguments))); + localFrame.setObject(varIdx++, PFactory.createTuple(getLanguage(), PArguments.getVariableArguments(arguments))); } if (co.takesVarKeywordArgs()) { - localFrame.setObject(varIdx, factory.createDict(PArguments.getKeywordArguments(arguments))); + localFrame.setObject(varIdx, PFactory.createDict(getLanguage(), PArguments.getKeywordArguments(arguments))); } initCellVars(localFrame); initFreeVars(localFrame, arguments); @@ -1172,10 +1175,10 @@ private InstrumentationData getTraceData() { return instrumentationData; } - public PythonContext.PythonThreadState getThreadState(Node node) { + public PythonContext.PythonThreadState getThreadState(PBytecodeRootNode node) { if (this.getTraceData().threadState == null) { PythonContext context = PythonContext.get(node); - return this.getTraceData().threadState = context.getThreadState(context.getLanguage(node)); + return this.getTraceData().threadState = context.getThreadState(node.getLanguage()); } return this.getTraceData().threadState; } @@ -1381,7 +1384,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod } case OpCodesConstants.LOAD_BIGINT: { oparg |= Byte.toUnsignedInt(localBC[++bci]); - virtualFrame.setObject(++stackTop, factory.createInt((BigInteger) localConsts[oparg])); + virtualFrame.setObject(++stackTop, PFactory.createInt(language, (BigInteger) localConsts[oparg])); break; } case OpCodesConstants.LOAD_STRING: @@ -1392,7 +1395,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod } case OpCodesConstants.LOAD_BYTES: { oparg |= Byte.toUnsignedInt(localBC[++bci]); - virtualFrame.setObject(++stackTop, factory.createBytes((byte[]) localConsts[oparg])); + virtualFrame.setObject(++stackTop, PFactory.createBytes(language, (byte[]) localConsts[oparg])); break; } case OpCodesConstants.LOAD_CONST_COLLECTION: { @@ -1405,7 +1408,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod case OpCodesConstants.LOAD_COMPLEX: { oparg |= Byte.toUnsignedInt(localBC[++bci]); double[] num = (double[]) localConsts[oparg]; - virtualFrame.setObject(++stackTop, factory.createComplex(num[0], num[1])); + virtualFrame.setObject(++stackTop, PFactory.createComplex(language, num[0], num[1])); break; } case OpCodesConstants.MAKE_KEYWORD: { @@ -1892,7 +1895,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod } case OpCodesConstants.DELETE_FAST: { oparg |= Byte.toUnsignedInt(localBC[++bci]); - bytecodeDeleteFast(localFrame, beginBci, localNodes, oparg, useCachedNodes); + bytecodeDeleteFast(localFrame, beginBci, localNodes, oparg); break; } case OpCodesConstants.LOAD_ATTR: { @@ -2222,7 +2225,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod break; } case OpCodesConstants.ASYNCGEN_WRAP: { - bytecodeAsyncGenWrap(virtualFrame, useCachedNodes, stackTop, localNodes, beginBci); + virtualFrame.setObject(stackTop, PFactory.createAsyncGeneratorWrappedValue(language, virtualFrame.getObject(stackTop))); break; } case OpCodesConstants.PUSH_EXC_INFO: { @@ -2318,7 +2321,7 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod if (e instanceof AbstractTruffleException) { exception = (AbstractTruffleException) e; } else { - exception = wrapJavaExceptionIfApplicable(e); + exception = wrapJavaExceptionIfApplicable(language, e); if (exception == null) { throw e; } @@ -2382,11 +2385,6 @@ private Object bytecodeLoop(VirtualFrame virtualFrame, Frame localFrame, Bytecod } } - @BytecodeInterpreterSwitch - private void bytecodeAsyncGenWrap(VirtualFrame virtualFrame, boolean useCachedNodes, int stackTop, Node[] localNodes, int beginBci) { - virtualFrame.setObject(stackTop, factory.createAsyncGeneratorWrappedValue(virtualFrame.getObject(stackTop))); - } - @BytecodeInterpreterSwitch private int bytecodeGetAIter(VirtualFrame virtualFrame, boolean useCachedNodes, int stackTop, Node[] localNodes, int bci) { GetAIterNode node = insertChildNode(localNodes, bci, UNCACHED_GET_AITER, GetAIterNodeGen.class, NODE_GET_AITER, useCachedNodes); @@ -2877,7 +2875,7 @@ private void traceException(VirtualFrame virtualFrame, MutableLoopData mutableDa Object peType = GetClassNode.executeUncached(exceptionObject); Object traceback = ExceptionNodes.GetTracebackNode.executeUncached(exception); invokeTraceFunction(virtualFrame, - factory.createTuple(new Object[]{peType, exceptionObject, traceback}), mutableData.getThreadState(this), + PFactory.createTuple(getLanguage(), new Object[]{peType, exceptionObject, traceback}), mutableData.getThreadState(this), mutableData, PythonContext.TraceEvent.EXCEPTION, bciToLine(bci), true); } @@ -3142,7 +3140,7 @@ private void invokeTraceFunction(VirtualFrame virtualFrame, Object arg, PythonCo pyFrame.setLocalTraceFun(null); } } catch (Throwable e) { - threadState.setTraceFun(null, PythonLanguage.get(this)); + threadState.setTraceFun(null, getLanguage()); throw e; } finally { if (line != -1) { @@ -3203,7 +3201,7 @@ private void invokeProfileFunction(VirtualFrame virtualFrame, Object arg, Python Object realResult = result == PNone.NONE ? null : result; pyFrame.setLocalTraceFun(realResult); } catch (Throwable e) { - threadState.setProfileFun(null, PythonLanguage.get(this)); + threadState.setProfileFun(null, getLanguage()); throw e; } finally { threadState.profilingStop(); @@ -4630,17 +4628,17 @@ private void generalizeVariableStores(int index) { } @InliningCutoff - protected PException wrapJavaExceptionIfApplicable(Throwable e) { + private PException wrapJavaExceptionIfApplicable(PythonLanguage language, Throwable e) { if (e instanceof AbstractTruffleException) { return null; } if (e instanceof ControlFlowException) { return null; } - if (PythonLanguage.get(this).getEngineOption(PythonOptions.CatchAllExceptions) && (e instanceof Exception || e instanceof AssertionError)) { - return ExceptionUtils.wrapJavaException(e, this, factory.createBaseException(SystemError, ErrorMessages.M, new Object[]{e})); + if (language.getEngineOption(PythonOptions.CatchAllExceptions) && (e instanceof Exception || e instanceof AssertionError)) { + return ExceptionUtils.wrapJavaException(e, this, PFactory.createBaseException(language, SystemError, ErrorMessages.M, new Object[]{e})); } - return ExceptionUtils.wrapJavaExceptionIfApplicable(this, e, factory); + return ExceptionUtils.wrapJavaExceptionIfApplicable(this, e); } @ExplodeLoop @@ -4784,11 +4782,11 @@ private void bytecodeLoadAttr(VirtualFrame virtualFrame, int stackTop, int bci, virtualFrame.setObject(stackTop, value); } - private void bytecodeDeleteFast(Frame localFrame, int bci, Node[] localNodes, int oparg, boolean useCachedNodes) { + private void bytecodeDeleteFast(Frame localFrame, int bci, Node[] localNodes, int oparg) { if (localFrame.isObject(oparg)) { Object value = localFrame.getObject(oparg); if (value == null) { - raiseVarReferencedBeforeAssignment(localNodes, bci, oparg); + throw raiseVarReferencedBeforeAssignment(localNodes, bci, oparg); } } else { generalizeVariableStores(oparg); @@ -5033,10 +5031,11 @@ private void bytecodeLoadConstCollection(VirtualFrame virtualFrame, int stackTop int kind = CollectionBits.collectionKind(typeAndKind); assert kind == CollectionBits.KIND_LIST || kind == CollectionBits.KIND_TUPLE; boolean list = kind == CollectionBits.KIND_LIST; - var context = PythonContext.get(this); - boolean useNativePrimitiveStorage = context.getLanguage(this).getEngineOption(PythonOptions.UseNativePrimitiveStorageStrategy); + PythonLanguage language = getLanguage(); + boolean useNativePrimitiveStorage = language.getEngineOption(PythonOptions.UseNativePrimitiveStorageStrategy); switch (CollectionBits.elementType(typeAndKind)) { case CollectionBits.ELEMENT_INT: { + var context = PythonContext.get(this); int[] a = (int[]) array; if (useNativePrimitiveStorage) { storage = context.nativeBufferContext.toNativeIntStorage(a); @@ -5084,9 +5083,9 @@ private void bytecodeLoadConstCollection(VirtualFrame virtualFrame, int stackTop throw CompilerDirectives.shouldNotReachHere(); } if (list) { - result = factory.createList(storage); + result = PFactory.createList(language, storage); } else { - result = factory.createTuple(storage); + result = PFactory.createTuple(language, storage); } virtualFrame.setObject(stackTop, result); } @@ -5543,17 +5542,17 @@ private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int case CollectionBits.KIND_LIST: { ListFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, ListFromStackNodeGen.class, LIST_FROM_STACK_NODE, count); SequenceStorage store = storageFromStackNode.execute(virtualFrame, stackTop - count + 1, stackTop + 1); - res = factory.createList(store, storageFromStackNode); + res = PFactory.createList(getLanguage(), store, storageFromStackNode); break; } case CollectionBits.KIND_TUPLE: { TupleFromStackNode storageFromStackNode = insertChildNodeInt(localNodes, nodeIndex, TupleFromStackNodeGen.class, TUPLE_FROM_STACK_NODE, count); SequenceStorage store = storageFromStackNode.execute(virtualFrame, stackTop - count + 1, stackTop + 1); - res = factory.createTuple(store); + res = PFactory.createTuple(getLanguage(), store); break; } case CollectionBits.KIND_SET: { - PSet set = factory.createSet(); + PSet set = PFactory.createSet(getLanguage()); HashingCollectionNodes.SetItemNode newNode = insertChildNode(localNodes, nodeIndex, UNCACHED_SET_ITEM, HashingCollectionNodesFactory.SetItemNodeGen.class, NODE_SET_ITEM, useCachedNodes); moveFromStack(virtualFrame, stackTop - count + 1, stackTop + 1, set, newNode); @@ -5561,7 +5560,7 @@ private int bytecodeCollectionFromStack(VirtualFrame virtualFrame, int type, int break; } case CollectionBits.KIND_DICT: { - PDict dict = factory.createDict(); + PDict dict = PFactory.createDict(getLanguage()); HashingCollectionNodes.SetItemNode setItem = insertChildNode(localNodes, nodeIndex, UNCACHED_SET_ITEM, HashingCollectionNodesFactory.SetItemNodeGen.class, NODE_SET_ITEM, useCachedNodes); assert count % 2 == 0; @@ -5606,14 +5605,14 @@ private void bytecodeCollectionFromCollection(VirtualFrame virtualFrame, int typ } case CollectionBits.KIND_SET: { SetNodes.ConstructSetNode constructNode = insertChildNode(localNodes, nodeIndex, UNCACHED_CONSTRUCT_SET, SetNodesFactory.ConstructSetNodeGen.class, NODE_CONSTRUCT_SET, useCachedNodes); - result = constructNode.executeWith(virtualFrame, sourceCollection); + result = constructNode.execute(virtualFrame, sourceCollection); break; } case CollectionBits.KIND_DICT: { // TODO create uncached node HashingStorage.InitNode initNode = insertChildNode(localNodes, nodeIndex, HashingStorageFactory.InitNodeGen.class, NODE_HASHING_STORAGE_INIT); HashingStorage storage = initNode.execute(virtualFrame, sourceCollection, PKeyword.EMPTY_KEYWORDS); - result = factory.createDict(storage); + result = PFactory.createDict(getLanguage(), storage); break; } case CollectionBits.KIND_OBJECT: { @@ -5726,7 +5725,7 @@ private int bytecodeAddToCollection(VirtualFrame virtualFrame, int initialStackT @BytecodeInterpreterSwitch private void bytecodeTupleFromList(VirtualFrame virtualFrame, int stackTop) { PList list = (PList) virtualFrame.getObject(stackTop); - Object result = factory.createTuple(list.getSequenceStorage()); + Object result = PFactory.createTuple(getLanguage(), list.getSequenceStorage()); virtualFrame.setObject(stackTop, result); } @@ -5734,7 +5733,7 @@ private void bytecodeTupleFromList(VirtualFrame virtualFrame, int stackTop) { private void bytecodeFrozensetFromList(VirtualFrame virtualFrame, int stackTop, int nodeIndex, Node[] localNodes) { PList list = (PList) virtualFrame.getObject(stackTop); HashingStorageFromListSequenceStorageNode node = insertChildNode(localNodes, nodeIndex, HashingStorageFromListSequenceStorageNodeGen.class, NODE_HASHING_STORAGE_FROM_SEQUENCE); - Object result = factory.createFrozenSet(node.execute(virtualFrame, list.getSequenceStorage())); + Object result = PFactory.createFrozenSet(getLanguage(), node.execute(virtualFrame, list.getSequenceStorage())); virtualFrame.setObject(stackTop, result); } @@ -5890,7 +5889,7 @@ protected byte[] extractCode() { * * TODO We should revisit this when the AST interpreter is removed. */ - return MarshalModuleBuiltins.serializeCodeUnit(co); + return MarshalModuleBuiltins.serializeCodeUnit(PythonContext.get(this), co); } @Override @@ -5900,7 +5899,7 @@ protected boolean isCloneUninitializedSupported() { @Override protected RootNode cloneUninitialized() { - return new PBytecodeRootNode(PythonLanguage.get(this), getFrameDescriptor(), getSignature(), co, source, parserErrorCallback); + return new PBytecodeRootNode(getLanguage(), getFrameDescriptor(), getSignature(), co, source, parserErrorCallback); } public void triggerDeferredDeprecationWarnings() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java index ab7481b702..2fe1eb0988 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -43,6 +43,7 @@ import static com.oracle.graal.python.builtins.objects.function.PArguments.getSpecialArgument; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___ANNOTATIONS__; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.dict.PDict; @@ -57,10 +58,9 @@ import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -70,6 +70,7 @@ import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; @GenerateUncached @@ -98,13 +99,14 @@ public abstract static class SetupAnnotationsFromDictOrModuleNode extends PNodeW public abstract void execute(Frame frame, Node inliningTarget, Object locals); @Specialization - static void doModule(PythonModule locals, + static void doModule(Node inliningTarget, PythonModule locals, @Cached(inline = false) ReadAttributeFromObjectNode read, @Cached(inline = false) WriteAttributeToObjectNode write, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { + @Cached InlinedBranchProfile create) { Object annotations = read.execute(locals, T___ANNOTATIONS__); if (annotations == PNone.NO_VALUE) { - write.execute(locals, T___ANNOTATIONS__, factory.createDict()); + create.enter(inliningTarget); + write.execute(locals, T___ANNOTATIONS__, PFactory.createDict(PythonLanguage.get(inliningTarget))); } } @@ -112,10 +114,11 @@ static void doModule(PythonModule locals, static void doBuiltinDict(VirtualFrame frame, Node inliningTarget, PDict locals, @Cached PyDictGetItem getItem, @Cached PyDictSetItem setItem, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { + @Cached InlinedBranchProfile create) { Object annotations = getItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__); if (annotations == null) { - setItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__, factory.createDict()); + create.enter(inliningTarget); + setItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__, PFactory.createDict(PythonLanguage.get(inliningTarget))); } } @@ -123,13 +126,12 @@ static void doBuiltinDict(VirtualFrame frame, Node inliningTarget, PDict locals, static void doOther(VirtualFrame frame, Node inliningTarget, Object locals, @Cached PyObjectGetItem getItem, @Cached PyObjectSetItem setItem, - @Cached IsBuiltinObjectProfile errorProfile, - @Shared("factory") @Cached(inline = false) PythonObjectFactory factory) { + @Cached IsBuiltinObjectProfile errorProfile) { try { getItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__); } catch (PException e) { e.expect(inliningTarget, PythonBuiltinClassType.KeyError, errorProfile); - setItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__, factory.createDict()); + setItem.execute(frame, inliningTarget, locals, T___ANNOTATIONS__, PFactory.createDict(PythonLanguage.get(inliningTarget))); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java index 9813e6c1da..1ea71fe6c4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -43,6 +43,7 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.common.SequenceNodes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.list.PList; @@ -54,14 +55,13 @@ import com.oracle.graal.python.nodes.builtins.ListNodes; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -82,7 +82,7 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { CompilerAsserts.partialEvaluationConstant(countBefore); CompilerAsserts.partialEvaluationConstant(countAfter); @@ -95,7 +95,7 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, len); } stackTop = moveItemsToStack(frame, inliningTarget, storage, stackTop, 0, countBefore, getItemNode); - PList starList = factory.createList(getItemSliceNode.execute(storage, countBefore, countBefore + starLen, 1, starLen)); + PList starList = PFactory.createList(language, getItemSliceNode.execute(storage, countBefore, countBefore + starLen, 1, starLen)); frame.setObject(stackTop--, starList); moveItemsToStack(frame, inliningTarget, storage, stackTop, len - countAfter, countAfter, getItemNode); return resultStackTop; @@ -111,7 +111,7 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll @Cached ListNodes.ConstructListNode constructListNode, @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Exclusive @Cached PRaiseNode.Lazy raiseNode) { CompilerAsserts.partialEvaluationConstant(countBefore); CompilerAsserts.partialEvaluationConstant(countAfter); @@ -135,7 +135,7 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll frame.setObject(stackTop, starAndAfter); } else { int starLen = lenAfter - countAfter; - PList starList = factory.createList(getItemSliceNode.execute(storage, 0, starLen, 1, starLen)); + PList starList = PFactory.createList(language, getItemSliceNode.execute(storage, 0, starLen, 1, starLen)); frame.setObject(stackTop--, starList); moveItemsToStack(frame, inliningTarget, storage, stackTop, starLen, countAfter, getItemNode); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java index 53f1fe05d0..34eab35e83 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java @@ -72,7 +72,7 @@ import com.oracle.graal.python.runtime.exception.PythonExitException; import com.oracle.graal.python.runtime.exception.PythonInterruptedException; import com.oracle.graal.python.runtime.exception.PythonThreadKillException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -219,7 +219,7 @@ private static boolean isSystemExit(PBaseException pythonException) { @TruffleBoundary private void handleJavaException(Throwable e) { - PException pe = ExceptionUtils.wrapJavaExceptionIfApplicable(this, e, PythonObjectFactory.getUncached()); + PException pe = ExceptionUtils.wrapJavaExceptionIfApplicable(this, e); if (pe != null) { throw handlePythonException(pe); } @@ -308,9 +308,10 @@ private Object run(VirtualFrame frame) { } PythonContext pythonContext = getContext(); PythonModule mainModule = null; + PythonLanguage language = getPythonLanguage(); if (source.isInternal()) { // internal sources are not run in the main module - PArguments.setGlobals(arguments, pythonContext.factory().createDict()); + PArguments.setGlobals(arguments, PFactory.createDict(language)); } else { mainModule = pythonContext.getMainModule(); PDict mainDict = GetOrCreateDictNode.executeUncached(mainModule); @@ -318,7 +319,7 @@ private Object run(VirtualFrame frame) { PArguments.setSpecialArgument(arguments, mainDict); PArguments.setException(arguments, PException.NO_EXCEPTION); } - Object state = IndirectCalleeContext.enterIndirect(getPythonLanguage(), pythonContext, arguments); + Object state = IndirectCalleeContext.enterIndirect(language, pythonContext, arguments); try { Object result = innerCallTarget.call(arguments); if (mainModule != null && result == PNone.NONE && !source.isInteractive()) { @@ -327,7 +328,7 @@ private Object run(VirtualFrame frame) { return result; } } finally { - IndirectCalleeContext.exit(getPythonLanguage(), pythonContext, state); + IndirectCalleeContext.exit(language, pythonContext, state); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java index d172f0b484..2c74fe9c8c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java @@ -64,11 +64,10 @@ import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -98,7 +97,7 @@ public abstract static class CastToListNode extends Node { @Specialization(guards = {"isBuiltinTuple(v)", "cachedLength == getLength(v)", "cachedLength < 32"}, limit = "2") @ExplodeLoop static PList starredTupleCachedLength(PTuple v, - @Exclusive @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached("getLength(v)") int cachedLength, @Cached SequenceStorageNodes.GetItemNode getItemNode) { SequenceStorage s = v.getSequenceStorage(); @@ -106,15 +105,15 @@ static PList starredTupleCachedLength(PTuple v, for (int i = 0; i < cachedLength; i++) { array[i] = getItemNode.execute(s, i); } - return factory.createList(array); + return PFactory.createList(language, array); } @Specialization(replaces = "starredTupleCachedLength", guards = "isBuiltinTuple(v)") static PList starredTuple(PTuple v, @Bind("this") Node inliningTarget, - @Exclusive @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached GetObjectArrayNode getObjectArrayNode) { - return factory.createList(getObjectArrayNode.execute(inliningTarget, v).clone()); + return PFactory.createList(language, getObjectArrayNode.execute(inliningTarget, v).clone()); } @Specialization(guards = "isBuiltinList(v)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java index 34d03bad18..75e1129b3c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.nodes.frame; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.cell.PCell; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDelItem; @@ -49,7 +50,7 @@ import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.lib.PyDictGetItem; import com.oracle.graal.python.nodes.bytecode.FrameInfo; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -64,6 +65,7 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; /** @@ -86,14 +88,15 @@ public static Object executeUncached(PFrame pyFrame) { } @Specialization(guards = "!pyFrame.hasCustomLocals()") - static Object doLoop(PFrame pyFrame, - @Cached(inline = false) PythonObjectFactory factory, + static Object doLoop(Node inliningTarget, PFrame pyFrame, + @Cached InlinedBranchProfile create, @Cached(inline = false) CopyLocalsToDict copyLocalsToDict) { MaterializedFrame locals = pyFrame.getLocals(); // It doesn't have custom locals, so it has to be a builtin dict or null PDict localsDict = (PDict) pyFrame.getLocalsDict(); if (localsDict == null) { - localsDict = factory.createDict(); + create.enter(inliningTarget); + localsDict = PFactory.createDict(PythonLanguage.get(inliningTarget)); pyFrame.setLocalsDict(localsDict); } copyLocalsToDict.execute(locals, localsDict); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java index 113f6234cc..4fb26a1501 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -40,10 +40,11 @@ */ package com.oracle.graal.python.nodes.frame; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.frame.PFrame; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.nodes.bytecode.FrameInfo; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.dsl.Bind; @@ -107,37 +108,36 @@ public final PFrame execute(Frame frame, Node location, boolean markAsEscaped, b "!hasCustomLocals(frameToMaterialize)"}, limit = "1") static PFrame freshPFrameCachedFD(Node location, boolean markAsEscaped, boolean forceSync, Frame frameToMaterialize, @Cached(value = "frameToMaterialize.getFrameDescriptor()") FrameDescriptor cachedFD, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("syncValuesNode") @Cached SyncFrameValuesNode syncValuesNode) { MaterializedFrame locals = createLocalsFrame(cachedFD); - PFrame escapedFrame = factory.createPFrame(PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); + PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, syncValuesNode); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "!hasGeneratorFrame(frameToMaterialize)", "!hasCustomLocals(frameToMaterialize)"}, replaces = "freshPFrameCachedFD") static PFrame freshPFrame(Node location, boolean markAsEscaped, boolean forceSync, Frame frameToMaterialize, - @Shared("factory") @Cached PythonObjectFactory factory, + @Bind PythonLanguage language, @Shared("syncValuesNode") @Cached SyncFrameValuesNode syncValuesNode) { MaterializedFrame locals = createLocalsFrame(frameToMaterialize.getFrameDescriptor()); - PFrame escapedFrame = factory.createPFrame(PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); + PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, syncValuesNode); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "!hasGeneratorFrame(frameToMaterialize)", "hasCustomLocals(frameToMaterialize)"}) static PFrame freshPFrameCusstomLocals(Node location, boolean markAsEscaped, @SuppressWarnings("unused") boolean forceSync, Frame frameToMaterialize, - @Shared("factory") @Cached PythonObjectFactory factory) { - PFrame escapedFrame = factory.createPFrame(PArguments.getCurrentFrameInfo(frameToMaterialize), location, null); + @Bind PythonLanguage language) { + PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, null); escapedFrame.setLocalsDict(PArguments.getSpecialArgument(frameToMaterialize)); return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, null); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "hasGeneratorFrame(frameToMaterialize)"}) - static PFrame freshPFrameForGenerator(Node location, @SuppressWarnings("unused") boolean markAsEscaped, @SuppressWarnings("unused") boolean forceSync, Frame frameToMaterialize, - @Shared("factory") @Cached PythonObjectFactory factory) { + static PFrame freshPFrameForGenerator(Node location, @SuppressWarnings("unused") boolean markAsEscaped, @SuppressWarnings("unused") boolean forceSync, Frame frameToMaterialize) { MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(frameToMaterialize); PFrame.Reference frameRef = PArguments.getCurrentFrameInfo(frameToMaterialize); - PFrame escapedFrame = materializeGeneratorFrame(location, generatorFrame, frameRef, factory); + PFrame escapedFrame = materializeGeneratorFrame(location, generatorFrame, frameRef); frameRef.setPyFrame(escapedFrame); return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, null); } @@ -162,8 +162,8 @@ private static MaterializedFrame createLocalsFrame(FrameDescriptor cachedFD) { return Truffle.getRuntime().createMaterializedFrame(PythonUtils.EMPTY_OBJECT_ARRAY, cachedFD); } - public static PFrame materializeGeneratorFrame(Node location, MaterializedFrame generatorFrame, PFrame.Reference frameRef, PythonObjectFactory factory) { - PFrame escapedFrame = factory.createPFrame(frameRef, location, generatorFrame); + public static PFrame materializeGeneratorFrame(Node location, MaterializedFrame generatorFrame, PFrame.Reference frameRef) { + PFrame escapedFrame = PFactory.createPFrame(PythonLanguage.get(location), frameRef, location, generatorFrame); PArguments.synchronizeArgs(generatorFrame, escapedFrame); return escapedFrame; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java index 9e398bdd70..5deb4769c2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,6 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ControlFlowException; @@ -58,21 +57,8 @@ */ public abstract class PythonVarargsBuiltinNode extends PythonBuiltinBaseNode { - @Child private PythonObjectFactory objectFactory; @Child private PRaiseNode raiseNode; - protected final PythonObjectFactory factory() { - if (objectFactory == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (isAdoptable()) { - objectFactory = insert(PythonObjectFactory.create()); - } else { - objectFactory = getContext().factory(); - } - } - return objectFactory; - } - protected final PRaiseNode getRaiseNode() { if (raiseNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/DeleteDictNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/DeleteDictNode.java index 13f5adfde0..3c41dce9fb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/DeleteDictNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/DeleteDictNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.nodes.object; +import com.oracle.graal.python.PythonLanguage; 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.HashingStorageCopy; @@ -48,7 +49,7 @@ import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -66,8 +67,7 @@ static void doPythonObject(PythonObject object, @Bind("this") Node inliningTarget, @Cached HiddenAttr.ReadNode readHiddenAttrNode, @Cached HiddenAttr.WriteNode writeHiddenAttrNode, - @Cached HashingStorageCopy copyNode, - @Cached PythonObjectFactory factory) { + @Cached HashingStorageCopy copyNode) { /* There is no special handling for class MROs because type.__dict__ cannot be deleted. */ assert !PGuards.isPythonClass(object); PDict oldDict = (PDict) readHiddenAttrNode.execute(inliningTarget, object, HiddenAttr.DICT, null); @@ -86,7 +86,7 @@ static void doPythonObject(PythonObject object, * empty dict dissociated from this object seems like the cleanest option. The disadvantage * is that the current values won't get garbage collected. */ - PDict newDict = factory.createDict(); + PDict newDict = PFactory.createDict(PythonLanguage.get(inliningTarget)); object.setDict(inliningTarget, writeHiddenAttrNode, newDict); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java index f1f11eb81d..e705a89eb4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -43,6 +43,7 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_PY_OBJECT_GET_DICT_PTR; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes; @@ -56,7 +57,7 @@ import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -69,6 +70,7 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateUncached @SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 17 @@ -121,11 +123,12 @@ static PDict doPythonObject(PythonObject object, @Specialization @InliningCutoff PDict doNativeObject(PythonAbstractNativeObject object, + @Bind("this") Node inliningTarget, @CachedLibrary(limit = "1") InteropLibrary lib, @Cached PythonToNativeNode toNative, @Cached CStructAccess.ReadObjectNode readObjectNode, @Cached CStructAccess.WriteObjectNewRefNode writeObjectNode, - @Cached PythonObjectFactory factory, + @Cached InlinedBranchProfile createDict, @Cached CExtNodes.PCallCapiFunction callGetDictPtr) { Object dictPtr = callGetDictPtr.call(FUN_PY_OBJECT_GET_DICT_PTR, toNative.execute(object)); if (lib.isNull(dictPtr)) { @@ -133,7 +136,8 @@ PDict doNativeObject(PythonAbstractNativeObject object, } else { Object dictObject = readObjectNode.readGeneric(dictPtr, 0); if (dictObject == PNone.NO_VALUE) { - PDict dict = factory.createDict(); + createDict.enter(inliningTarget); + PDict dict = PFactory.createDict(PythonLanguage.get(inliningTarget)); writeObjectNode.write(dictPtr, dict); return dict; } else if (dictObject instanceof PDict dict) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java index f2ba18eb96..3bdb1cfd1b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java @@ -54,6 +54,7 @@ import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -249,7 +250,7 @@ private PythonManagedClass resolvePolyglotForeignClass(PythonContext context, in PythonModule polyglotModule = context.lookupBuiltinModule(T_POLYGLOT); - PythonClass pythonClass = context.factory().createPythonClassAndFixupSlots(context.getLanguage(), PythonBuiltinClassType.PythonClass, name, base, bases); + PythonClass pythonClass = PFactory.createPythonClassAndFixupSlots(context.getLanguage(), name, base, bases); pythonClass.setAttribute(T___MODULE__, T_POLYGLOT); assert polyglotModule.getAttribute(name) == PNone.NO_VALUE : name; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java index 9290b4d348..b5d569ad8a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,14 +42,16 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; @@ -81,11 +83,11 @@ static PDict doPythonObject(Node inliningTarget, PythonObject object, @Shared("getDict") @Cached(inline = false) GetDictIfExistsNode getDictIfExistsNode, @Cached SetDictNode setDictNode, @Cached InlinedBranchProfile createDict, - @Cached(inline = false) PythonObjectFactory factory) { + @Bind PythonLanguage language) { PDict dict = getDictIfExistsNode.execute(object); if (dict == null) { createDict.enter(inliningTarget); - dict = factory.createDictFixedStorage(object); + dict = PFactory.createDictFixedStorage(language, object); setDictNode.execute(inliningTarget, object, dict); } return dict; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java index 3158eff127..0b736e22e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java @@ -58,6 +58,7 @@ import com.oracle.graal.python.nodes.SpecialAttributeNames; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.ArrayBuilder; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; @@ -190,7 +191,7 @@ private static PythonClass buildClassAndRegister(Object foreignObject, PythonClass pythonClass; try { // The call might not succeed if, for instance, the MRO can't be constructed - pythonClass = context.factory().createPythonClassAndFixupSlots(context.getLanguage(), PythonBuiltinClassType.PythonClass, className, bases[0], basesWithForeign); + pythonClass = PFactory.createPythonClassAndFixupSlots(context.getLanguage(), className, bases[0], basesWithForeign); } catch (PException e) { // Catch the error to additionally print the collected classes and specify the error // occurred during class creation diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java index c5da70de2d..55e7bd700a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java @@ -79,7 +79,7 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.ValueType; @@ -113,7 +113,7 @@ public static PythonModule importModule(TruffleString name) { if (builtinImport == PNone.NO_VALUE) { throw PConstructAndRaiseNode.getUncached().raiseImportError(null, IMPORT_NOT_FOUND); } - Object fromList = context.factory().createTuple(PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); + Object fromList = PFactory.createTuple(context.getLanguage(), PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); CallNode.executeUncached(builtinImport, name, PNone.NONE, PNone.NONE, fromList, 0); PythonModule sysModule = context.lookupBuiltinModule(T_SYS); Object modules = sysModule.getAttribute(T_MODULES); @@ -170,7 +170,6 @@ static Object importName(VirtualFrame frame, PythonContext context, PythonModule @Cached PConstructAndRaiseNode.Lazy raiseNode, @Cached CallNode importCallNode, @Cached GetDictFromGlobalsNode getDictNode, - @Cached PythonObjectFactory factory, @Cached PyImportImportModuleLevelObject importModuleLevel) { Object importFunc = readAttrNode.execute(builtins, T___IMPORT__, null); if (importFunc == null) { @@ -183,7 +182,7 @@ static Object importName(VirtualFrame frame, PythonContext context, PythonModule } else { globalsArg = getDictNode.execute(inliningTarget, globals); } - return importCallNode.execute(frame, importFunc, name, globalsArg, PNone.NONE, factory.createTuple(fromList), level); + return importCallNode.execute(frame, importFunc, name, globalsArg, PNone.NONE, PFactory.createTuple(PythonLanguage.get(inliningTarget), fromList), level); } return importModuleLevel.execute(frame, context, name, globals, fromList, level); } @@ -259,7 +258,6 @@ static Object genericImport(VirtualFrame frame, PythonContext context, TruffleSt @Exclusive @Cached EnsureInitializedNode ensureInitialized, @Cached PyObjectLookupAttr getPathNode, @Cached PyObjectCallMethodObjArgs callHandleFromlist, - @Cached PythonObjectFactory factory, @Exclusive @Cached FindAndLoad findAndLoad, @Cached InlinedConditionProfile recursiveCase, @Exclusive @Cached TruffleString.CodePointLengthNode codePointLengthNode, @@ -324,7 +322,7 @@ static Object genericImport(VirtualFrame frame, PythonContext context, TruffleSt if (path != PNone.NO_VALUE) { return callHandleFromlist.execute(frame, inliningTarget, context.getImportlib(), T__HANDLE_FROMLIST, mod, - factory.createTuple(fromList), + PFactory.createTuple(PythonLanguage.get(inliningTarget), fromList), context.importFunc()); } else { return mod; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java index a601e6518a..3d37ed59d9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,6 +42,7 @@ import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.complex.PComplex; import com.oracle.graal.python.lib.PyFloatAsDoubleNode; @@ -51,9 +52,9 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.ImportStatic; @@ -72,14 +73,14 @@ public abstract class CoerceToComplexNode extends PNodeWithContext { @Specialization static PComplex doLong(long x, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(x, 0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, x, 0); } @Specialization static PComplex doDouble(double x, - @Shared @Cached(inline = false) PythonObjectFactory factory) { - return factory.createComplex(x, 0); + @Bind PythonLanguage language) { + return PFactory.createComplex(language, x, 0); } @Specialization @@ -91,7 +92,7 @@ static PComplex doComplex(PComplex x) { static PComplex toComplex(VirtualFrame frame, Node inliningTarget, Object x, @Cached(value = "create(T___COMPLEX__)", inline = false) LookupAndCallUnaryNode callComplexFunc, @Cached PyFloatAsDoubleNode asDoubleNode, - @Shared @Cached(inline = false) PythonObjectFactory factory, + @Bind PythonLanguage language, @Cached PRaiseNode.Lazy raiseNode) { Object result = callComplexFunc.executeObject(frame, x); if (result != PNone.NO_VALUE) { @@ -106,6 +107,6 @@ static PComplex toComplex(VirtualFrame frame, Node inliningTarget, Object x, throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_RETURN, "__complex__", "complex object"); } } - return factory.createComplex(asDoubleNode.execute(frame, inliningTarget, x), 0); + return PFactory.createComplex(language, asDoubleNode.execute(frame, inliningTarget, x), 0); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/NarrowBigIntegerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/NarrowBigIntegerNode.java index 66c6f99559..ba7025a57e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/NarrowBigIntegerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/NarrowBigIntegerNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,9 +42,10 @@ import java.math.BigInteger; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -72,14 +73,13 @@ static Object narrowBigInteger0(@SuppressWarnings("unused") BigInteger x) { @Specialization(guards = "x.signum() != 0") static Object narrowBigInteger(Node inliningTarget, BigInteger x, @Cached InlinedConditionProfile fitsIntProfile, - @Cached InlinedConditionProfile fitsLongProfile, - @Cached(inline = false) PythonObjectFactory factory) { + @Cached InlinedConditionProfile fitsLongProfile) { if (fitsIntProfile.profile(inliningTarget, PInt.fitsIn(x, PInt.MIN_INT, PInt.MAX_INT))) { return PInt.intValue(x); } if (fitsLongProfile.profile(inliningTarget, PInt.fitsIn(x, PInt.MIN_LONG, PInt.MAX_LONG))) { return PInt.longValue(x); } - return factory.createInt(x); + return PFactory.createInt(PythonLanguage.get(inliningTarget), x); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java index 2a27d077bf..2dc3794f47 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java @@ -160,7 +160,9 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; +import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntLossyNode; +import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.AsyncHandler.AsyncAction; import com.oracle.graal.python.runtime.PythonContextFactory.GetThreadStateNodeGen; import com.oracle.graal.python.runtime.arrow.ArrowSupport; @@ -170,7 +172,7 @@ import com.oracle.graal.python.runtime.exception.PythonThreadKillException; import com.oracle.graal.python.runtime.locale.PythonLocale; import com.oracle.graal.python.runtime.object.IDUtils; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.Consumer; import com.oracle.graal.python.util.PythonSystemThreadTask; import com.oracle.graal.python.util.PythonUtils; @@ -525,7 +527,7 @@ public void setNativeWrapper(PThreadState nativeWrapper) { public PContextVarsContext getContextVarsContext() { if (contextVarsContext == null) { - contextVarsContext = PythonObjectFactory.getUncached().createContextVarsContext(); + contextVarsContext = PFactory.createContextVarsContext(PythonLanguage.get(null)); } return contextVarsContext; } @@ -1672,21 +1674,16 @@ private void patchPackagePaths(TruffleString from, TruffleString to) { Object[] paths = SequenceStorageNodes.CopyInternalArrayNode.executeUncached(((PList) path).getSequenceStorage()); for (int i = 0; i < paths.length; i++) { Object pathElement = paths[i]; - TruffleString strPath; - if (pathElement instanceof PString) { - strPath = ((PString) pathElement).getValueUncached(); - } else if (isJavaString(pathElement)) { - strPath = toTruffleStringUncached((String) pathElement); - } else if (pathElement instanceof TruffleString) { - strPath = (TruffleString) pathElement; - } else { - continue; - } - if (strPath.regionEqualsUncached(0, from, 0, from.codePointLengthUncached(TS_ENCODING), TS_ENCODING)) { - paths[i] = StringReplaceNode.getUncached().execute(strPath, from, to, -1); + try { + TruffleString strPath = CastToTruffleStringNode.executeUncached(pathElement); + if (strPath.regionEqualsUncached(0, from, 0, from.codePointLengthUncached(TS_ENCODING), TS_ENCODING)) { + paths[i] = StringReplaceNode.getUncached().execute(strPath, from, to, -1); + } + } catch (CannotCastException e) { + // ignore } } - ((PythonModule) v).setAttribute(SpecialAttributeNames.T___PATH__, factory().createList(paths)); + ((PythonModule) v).setAttribute(SpecialAttributeNames.T___PATH__, PFactory.createList(PythonLanguage.get(null), paths)); } // Update module.__file__ @@ -1722,10 +1719,10 @@ private void setupRuntimeInformation(boolean isPatching) { nativeLZMA = NFILZMASupport.createNative(this, ""); } - mainModule = factory().createPythonModule(T___MAIN__); + mainModule = PFactory.createPythonModule(getLanguage(), T___MAIN__); mainModule.setAttribute(T___BUILTINS__, getBuiltins()); - mainModule.setAttribute(T___ANNOTATIONS__, factory().createDict()); - SetDictNode.executeUncached(mainModule, factory().createDictFixedStorage(mainModule)); + mainModule.setAttribute(T___ANNOTATIONS__, PFactory.createDict(getLanguage())); + SetDictNode.executeUncached(mainModule, PFactory.createDictFixedStorage(getLanguage(), mainModule)); getSysModules().setItem(T___MAIN__, mainModule); if (ImageInfo.inImageBuildtimeCode()) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java index a074375217..9c8802229f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java @@ -50,6 +50,7 @@ import java.util.List; import java.util.ListIterator; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; import com.oracle.graal.python.builtins.objects.exception.PBaseException; @@ -65,11 +66,10 @@ import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleStackTrace; @@ -272,16 +272,16 @@ public static PException wrapJavaException(Throwable e, Node node, PBaseExceptio return PException.fromObject(pythonException, node, e); } - @InliningCutoff - public static PException wrapJavaExceptionIfApplicable(Node location, Throwable e, PythonObjectFactory factory) { + public static PException wrapJavaExceptionIfApplicable(Node location, Throwable e) { if (e instanceof StackOverflowError) { CompilerDirectives.transferToInterpreterAndInvalidate(); - PythonContext.get(null).ensureGilAfterFailure(); - return ExceptionUtils.wrapJavaException(e, location, factory.createBaseException(RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, new Object[]{})); + PythonContext context = PythonContext.get(null); + context.ensureGilAfterFailure(); + return ExceptionUtils.wrapJavaException(e, location, PFactory.createBaseException(context.getLanguage(), RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, new Object[]{})); } if (e instanceof OutOfMemoryError) { CompilerDirectives.transferToInterpreterAndInvalidate(); - return ExceptionUtils.wrapJavaException(e, location, factory.createBaseException(MemoryError)); + return ExceptionUtils.wrapJavaException(e, location, PFactory.createBaseException(PythonLanguage.get(null), MemoryError)); } return null; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java index 2e7e18c640..5b16500d7c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -49,6 +49,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.buffer.BufferFlags; @@ -69,6 +70,7 @@ import com.oracle.graal.python.runtime.formatting.FormattingBuffer.BytesFormattingBuffer; import com.oracle.graal.python.runtime.formatting.InternalFormat.Formatter; import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -115,7 +117,7 @@ int parseNumber(int start, int end) { @Override Object parseMappingKey(int start, int end) { - return core.factory().createBytes(Arrays.copyOfRange(formatBytes, start, end)); + return PFactory.createBytes(PythonLanguage.get(null), Arrays.copyOfRange(formatBytes, start, end)); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java index a0bdb89c56..359ce10183 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java @@ -15,6 +15,7 @@ import java.math.BigInteger; import java.math.MathContext; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.function.PKeyword; @@ -37,6 +38,7 @@ import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.formatting.InternalFormat.Spec; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -180,7 +182,7 @@ protected final Object asNumber(Object arg, char specType) { if (allowsFloat(specType)) { // Fast path for simple double values, instead of __int__ BigDecimal decimal = new BigDecimal((Double) arg, MathContext.UNLIMITED); - return core.factory().createInt(decimal.toBigInteger()); + return PFactory.createInt(PythonLanguage.get(null), decimal.toBigInteger()); } else { // non-integer result indicates to the caller that it could not be converted return arg; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/IDUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/IDUtils.java index 1d9cd21891..d1cc7c2f89 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/IDUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/IDUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -46,6 +46,7 @@ import java.util.WeakHashMap; import java.util.concurrent.atomic.AtomicLong; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.util.WeakIdentityHashMap; import com.oracle.truffle.api.CompilerDirectives; @@ -106,11 +107,11 @@ private static BigInteger asMaskedBigIntId(long id, BigInteger mask) { return BigInteger.valueOf(id).shiftLeft(2).or(mask); } - private static Object asMaskedId(long id, PythonObjectFactory factory, long max, long mask, BigInteger biMask) { + private static Object asMaskedId(PythonLanguage language, long id, long max, long mask, BigInteger biMask) { if (Long.compareUnsigned(id, max) <= 0) { return (id << 2) | mask; } - return factory.createInt(asMaskedBigIntId(id, biMask)); + return PFactory.createInt(language, asMaskedBigIntId(id, biMask)); } private static long getId(ReservedID reservedID) { @@ -125,13 +126,13 @@ public static Object getId(int id) { return ((long) id << 2) | ID_MASK_LONG; } - public static Object getId(long id, PythonObjectFactory factory) { - return asMaskedId(id, factory, MAX_OBJECT_ID, ID_MASK_LONG, ID_MASK_LONG_BI); + public static Object getId(PythonLanguage language, long id) { + return asMaskedId(language, id, MAX_OBJECT_ID, ID_MASK_LONG, ID_MASK_LONG_BI); } - public static Object getId(double id, PythonObjectFactory factory) { + public static Object getId(PythonLanguage language, double id) { long ieee754 = Double.doubleToLongBits(id); - return asMaskedId(ieee754, factory, MAX_DOUBLE_ID, ID_MASK_DOUBLE, ID_MASK_DOUBLE_BI); + return asMaskedId(language, ieee754, MAX_DOUBLE_ID, ID_MASK_DOUBLE, ID_MASK_DOUBLE_BI); } @CompilerDirectives.TruffleBoundary(allowInlining = true) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java new file mode 100644 index 0000000000..2d139cbe55 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java @@ -0,0 +1,1695 @@ +/* + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. + * Copyright (c) 2013, Regents of the University of California + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.oracle.graal.python.runtime.object; + +import java.lang.ref.ReferenceQueue; +import java.math.BigInteger; +import java.util.LinkedHashMap; +import java.util.concurrent.Semaphore; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.PosixFileHandle; +import com.oracle.graal.python.builtins.modules.Profiler; +import com.oracle.graal.python.builtins.modules.bz2.BZ2Object; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteCodec; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteCodecObject; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteIncrementalDecoderObject; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteIncrementalEncoderObject; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteStreamReaderObject; +import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteStreamWriterObject; +import com.oracle.graal.python.builtins.modules.codecs.PEncodingMap; +import com.oracle.graal.python.builtins.modules.csv.CSVDialect; +import com.oracle.graal.python.builtins.modules.csv.CSVReader; +import com.oracle.graal.python.builtins.modules.csv.CSVWriter; +import com.oracle.graal.python.builtins.modules.csv.QuoteStyle; +import com.oracle.graal.python.builtins.modules.ctypes.CDataObject; +import com.oracle.graal.python.builtins.modules.ctypes.CFieldObject; +import com.oracle.graal.python.builtins.modules.ctypes.CThunkObject; +import com.oracle.graal.python.builtins.modules.ctypes.PyCArgObject; +import com.oracle.graal.python.builtins.modules.ctypes.PyCFuncPtrObject; +import com.oracle.graal.python.builtins.modules.ctypes.StgDictObject; +import com.oracle.graal.python.builtins.modules.ctypes.memory.Pointer; +import com.oracle.graal.python.builtins.modules.functools.LruCacheObject; +import com.oracle.graal.python.builtins.modules.functools.PKeyWrapper; +import com.oracle.graal.python.builtins.modules.functools.PPartial; +import com.oracle.graal.python.builtins.modules.hashlib.DigestObject; +import com.oracle.graal.python.builtins.modules.io.PBuffered; +import com.oracle.graal.python.builtins.modules.io.PBytesIO; +import com.oracle.graal.python.builtins.modules.io.PBytesIOBuffer; +import com.oracle.graal.python.builtins.modules.io.PFileIO; +import com.oracle.graal.python.builtins.modules.io.PNLDecoder; +import com.oracle.graal.python.builtins.modules.io.PRWPair; +import com.oracle.graal.python.builtins.modules.io.PStringIO; +import com.oracle.graal.python.builtins.modules.io.PTextIO; +import com.oracle.graal.python.builtins.modules.json.PJSONEncoder; +import com.oracle.graal.python.builtins.modules.json.PJSONEncoder.FastEncode; +import com.oracle.graal.python.builtins.modules.json.PJSONScanner; +import com.oracle.graal.python.builtins.modules.lzma.LZMAObject; +import com.oracle.graal.python.builtins.modules.multiprocessing.PGraalPySemLock; +import com.oracle.graal.python.builtins.modules.multiprocessing.PSemLock; +import com.oracle.graal.python.builtins.modules.pickle.PPickleBuffer; +import com.oracle.graal.python.builtins.modules.pickle.PPickler; +import com.oracle.graal.python.builtins.modules.pickle.PPicklerMemoProxy; +import com.oracle.graal.python.builtins.modules.pickle.PUnpickler; +import com.oracle.graal.python.builtins.modules.pickle.PUnpicklerMemoProxy; +import com.oracle.graal.python.builtins.modules.zlib.ZLibCompObject; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.array.PArray; +import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGen; +import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenASend; +import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenAThrow; +import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenWrappedValue; +import com.oracle.graal.python.builtins.objects.asyncio.PCoroutineWrapper; +import com.oracle.graal.python.builtins.objects.bytes.PByteArray; +import com.oracle.graal.python.builtins.objects.bytes.PBytes; +import com.oracle.graal.python.builtins.objects.capsule.PyCapsule; +import com.oracle.graal.python.builtins.objects.cell.PCell; +import com.oracle.graal.python.builtins.objects.cext.PythonNativeVoidPtr; +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; +import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers; +import com.oracle.graal.python.builtins.objects.cext.hpy.PythonHPyObject; +import com.oracle.graal.python.builtins.objects.code.PCode; +import com.oracle.graal.python.builtins.objects.common.DynamicObjectStorage; +import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; +import com.oracle.graal.python.builtins.objects.common.EmptyStorage; +import com.oracle.graal.python.builtins.objects.common.ForeignHashingStorage; +import com.oracle.graal.python.builtins.objects.common.HashingStorage; +import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes; +import com.oracle.graal.python.builtins.objects.common.KeywordsStorage; +import com.oracle.graal.python.builtins.objects.common.PHashingCollection; +import com.oracle.graal.python.builtins.objects.complex.PComplex; +import com.oracle.graal.python.builtins.objects.contextvars.PContextIterator; +import com.oracle.graal.python.builtins.objects.contextvars.PContextVar; +import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext; +import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsToken; +import com.oracle.graal.python.builtins.objects.deque.PDeque; +import com.oracle.graal.python.builtins.objects.deque.PDequeIter; +import com.oracle.graal.python.builtins.objects.dict.PDefaultDict; +import com.oracle.graal.python.builtins.objects.dict.PDict; +import com.oracle.graal.python.builtins.objects.dict.PDictView; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemIterator; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemsView; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeyIterator; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeysView; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValueIterator; +import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValuesView; +import com.oracle.graal.python.builtins.objects.enumerate.PEnumerate; +import com.oracle.graal.python.builtins.objects.exception.PBaseException; +import com.oracle.graal.python.builtins.objects.exception.PBaseExceptionGroup; +import com.oracle.graal.python.builtins.objects.floats.PFloat; +import com.oracle.graal.python.builtins.objects.frame.PFrame; +import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; +import com.oracle.graal.python.builtins.objects.function.PFunction; +import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.function.Signature; +import com.oracle.graal.python.builtins.objects.generator.PGenerator; +import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptor; +import com.oracle.graal.python.builtins.objects.getsetdescriptor.IndexedSlotDescriptor; +import com.oracle.graal.python.builtins.objects.ints.PInt; +import com.oracle.graal.python.builtins.objects.iterator.PArrayIterator; +import com.oracle.graal.python.builtins.objects.iterator.PBaseSetIterator; +import com.oracle.graal.python.builtins.objects.iterator.PBigRangeIterator; +import com.oracle.graal.python.builtins.objects.iterator.PDoubleSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator; +import com.oracle.graal.python.builtins.objects.iterator.PIntegerSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PLongSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PObjectSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PSentinelIterator; +import com.oracle.graal.python.builtins.objects.iterator.PSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PStringIterator; +import com.oracle.graal.python.builtins.objects.iterator.PStructUnpackIterator; +import com.oracle.graal.python.builtins.objects.iterator.PZip; +import com.oracle.graal.python.builtins.objects.itertools.PAccumulate; +import com.oracle.graal.python.builtins.objects.itertools.PChain; +import com.oracle.graal.python.builtins.objects.itertools.PCombinations; +import com.oracle.graal.python.builtins.objects.itertools.PCombinationsWithReplacement; +import com.oracle.graal.python.builtins.objects.itertools.PCompress; +import com.oracle.graal.python.builtins.objects.itertools.PCount; +import com.oracle.graal.python.builtins.objects.itertools.PCycle; +import com.oracle.graal.python.builtins.objects.itertools.PDropwhile; +import com.oracle.graal.python.builtins.objects.itertools.PFilterfalse; +import com.oracle.graal.python.builtins.objects.itertools.PGroupBy; +import com.oracle.graal.python.builtins.objects.itertools.PGrouper; +import com.oracle.graal.python.builtins.objects.itertools.PIslice; +import com.oracle.graal.python.builtins.objects.itertools.PPairwise; +import com.oracle.graal.python.builtins.objects.itertools.PPermutations; +import com.oracle.graal.python.builtins.objects.itertools.PProduct; +import com.oracle.graal.python.builtins.objects.itertools.PRepeat; +import com.oracle.graal.python.builtins.objects.itertools.PStarmap; +import com.oracle.graal.python.builtins.objects.itertools.PTakewhile; +import com.oracle.graal.python.builtins.objects.itertools.PTee; +import com.oracle.graal.python.builtins.objects.itertools.PTeeDataObject; +import com.oracle.graal.python.builtins.objects.itertools.PZipLongest; +import com.oracle.graal.python.builtins.objects.list.PList; +import com.oracle.graal.python.builtins.objects.map.PMap; +import com.oracle.graal.python.builtins.objects.mappingproxy.PMappingproxy; +import com.oracle.graal.python.builtins.objects.memoryview.BufferLifecycleManager; +import com.oracle.graal.python.builtins.objects.memoryview.PMemoryView; +import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; +import com.oracle.graal.python.builtins.objects.method.PDecoratedMethod; +import com.oracle.graal.python.builtins.objects.method.PMethod; +import com.oracle.graal.python.builtins.objects.mmap.PMMap; +import com.oracle.graal.python.builtins.objects.module.PythonModule; +import com.oracle.graal.python.builtins.objects.namespace.PSimpleNamespace; +import com.oracle.graal.python.builtins.objects.object.PythonObject; +import com.oracle.graal.python.builtins.objects.ordereddict.POrderedDict; +import com.oracle.graal.python.builtins.objects.ordereddict.POrderedDictIterator; +import com.oracle.graal.python.builtins.objects.posix.PDirEntry; +import com.oracle.graal.python.builtins.objects.posix.PScandirIterator; +import com.oracle.graal.python.builtins.objects.property.PProperty; +import com.oracle.graal.python.builtins.objects.queue.PSimpleQueue; +import com.oracle.graal.python.builtins.objects.random.PRandom; +import com.oracle.graal.python.builtins.objects.range.PBigRange; +import com.oracle.graal.python.builtins.objects.range.PIntRange; +import com.oracle.graal.python.builtins.objects.referencetype.PReferenceType; +import com.oracle.graal.python.builtins.objects.reversed.PSequenceReverseIterator; +import com.oracle.graal.python.builtins.objects.reversed.PStringReverseIterator; +import com.oracle.graal.python.builtins.objects.set.PBaseSet; +import com.oracle.graal.python.builtins.objects.set.PFrozenSet; +import com.oracle.graal.python.builtins.objects.set.PSet; +import com.oracle.graal.python.builtins.objects.slice.PIntSlice; +import com.oracle.graal.python.builtins.objects.slice.PObjectSlice; +import com.oracle.graal.python.builtins.objects.socket.PSocket; +import com.oracle.graal.python.builtins.objects.ssl.PMemoryBIO; +import com.oracle.graal.python.builtins.objects.ssl.PSSLContext; +import com.oracle.graal.python.builtins.objects.ssl.PSSLSocket; +import com.oracle.graal.python.builtins.objects.ssl.SSLMethod; +import com.oracle.graal.python.builtins.objects.str.NativeCharSequence; +import com.oracle.graal.python.builtins.objects.str.PString; +import com.oracle.graal.python.builtins.objects.struct.PStruct; +import com.oracle.graal.python.builtins.objects.superobject.SuperObject; +import com.oracle.graal.python.builtins.objects.thread.PLock; +import com.oracle.graal.python.builtins.objects.thread.PRLock; +import com.oracle.graal.python.builtins.objects.thread.PThread; +import com.oracle.graal.python.builtins.objects.thread.PThreadLocal; +import com.oracle.graal.python.builtins.objects.tokenize.PTokenizerIter; +import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback; +import com.oracle.graal.python.builtins.objects.traceback.PTraceback; +import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.tuple.PTupleGetter; +import com.oracle.graal.python.builtins.objects.tuple.StructSequence.BuiltinTypeDescriptor; +import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; +import com.oracle.graal.python.builtins.objects.type.PythonClass; +import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroStorageNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.types.PGenericAlias; +import com.oracle.graal.python.builtins.objects.types.PGenericAliasIterator; +import com.oracle.graal.python.builtins.objects.types.PUnionType; +import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.runtime.NFIZlibSupport; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.graal.python.util.BufferFormat; +import com.oracle.graal.python.util.OverflowException; +import com.oracle.graal.python.util.PythonUtils; +import com.oracle.graal.python.util.Supplier; +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CallTarget; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.instrumentation.AllocationReporter; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.tools.profiler.CPUSampler; + +public final class PFactory { + private PFactory() { + } + + private static T create(PythonLanguage language, Supplier constructor) { + AllocationReporter reporter = language.getAllocationReporter(); + if (reporter.isActive()) { + return createWithTrace(constructor, reporter); + } else { + return constructor.get(); + } + } + + @InliningCutoff + private static T createWithTrace(Supplier constructor, AllocationReporter reporter) { + reporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN); + T allocatedObject = constructor.get(); + reporter.onReturnValue(allocatedObject, 0, AllocationReporter.SIZE_UNKNOWN); + return allocatedObject; + } + + /* + * Python objects + */ + public static PythonObject createPythonObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> (new PythonObject(cls, shape))); + } + + /** + * Creates a PythonObject for the given class. This is potentially slightly slower than if the + * shape had been cached, due to the additional shape lookup. + */ + public static PythonObject createPythonHPyObject(PythonLanguage language, Object cls, Shape shape, Object hpyNativeSpace) { + return create(language, () -> new PythonHPyObject(cls, shape, hpyNativeSpace)); + } + + public static PythonNativeVoidPtr createNativeVoidPtr(PythonLanguage language, Object obj) { + return create(language, () -> new PythonNativeVoidPtr(obj)); + } + + public static PythonNativeVoidPtr createNativeVoidPtr(PythonLanguage language, Object obj, long nativePtr) { + return create(language, () -> new PythonNativeVoidPtr(obj, nativePtr)); + } + + public static SuperObject createSuperObject(PythonLanguage language) { + return createSuperObject(language, PythonBuiltinClassType.Super, PythonBuiltinClassType.Super.getInstanceShape(language)); + } + + public static SuperObject createSuperObject(PythonLanguage language, Object self, Shape shape) { + return create(language, () -> new SuperObject(self, shape)); + } + + public static PInt createInt(PythonLanguage language, long value) { + return createInt(language, PythonBuiltinClassType.PInt, language.getBuiltinTypeInstanceShape(PythonBuiltinClassType.PInt), asBigInt(value)); + } + + @TruffleBoundary + private static BigInteger asBigInt(long value) { + return BigInteger.valueOf(value); + } + + public static PInt createInt(PythonLanguage language, BigInteger value) { + return createInt(language, PythonBuiltinClassType.PInt, language.getBuiltinTypeInstanceShape(PythonBuiltinClassType.PInt), value); + } + + public static PInt createInt(PythonLanguage language, Object cls, Shape shape, long value) { + return createInt(language, cls, shape, asBigInt(value)); + } + + public static PInt createInt(PythonLanguage language, Object cls, Shape shape, BigInteger value) { + return create(language, () -> new PInt(cls, shape, value)); + } + + public static PFloat createFloat(PythonLanguage language, double value) { + return createFloat(language, PythonBuiltinClassType.PFloat, language.getBuiltinTypeInstanceShape(PythonBuiltinClassType.PFloat), value); + } + + public static PFloat createFloat(PythonLanguage language, Object cls, Shape shape, double value) { + return create(language, () -> new PFloat(cls, shape, value)); + } + + public static PString createString(PythonLanguage language, TruffleString string) { + return createString(language, PythonBuiltinClassType.PString, language.getBuiltinTypeInstanceShape(PythonBuiltinClassType.PString), string); + } + + public static PString createString(PythonLanguage language, Object cls, Shape shape, TruffleString string) { + return create(language, () -> new PString(cls, shape, string)); + } + + public static PString createString(PythonLanguage language, NativeCharSequence string) { + return createString(language, PythonBuiltinClassType.PString, language.getBuiltinTypeInstanceShape(PythonBuiltinClassType.PString), string); + } + + public static PString createString(PythonLanguage language, Object cls, Shape shape, NativeCharSequence string) { + return create(language, () -> new PString(cls, shape, string)); + } + + public static PBytes createEmptyBytes(PythonLanguage language) { + if (CompilerDirectives.inInterpreter()) { + return createBytes(language, PythonUtils.EMPTY_BYTE_ARRAY); + } else { + return createBytes(language, new byte[0]); + } + } + + public static PBytes createBytes(PythonLanguage language, byte[] array) { + return createBytes(language, array, array.length); + } + + public static PBytes createBytes(PythonLanguage language, byte[] array, int length) { + return createBytes(language, new ByteSequenceStorage(array, length)); + } + + public static PBytes createBytes(PythonLanguage language, SequenceStorage storage) { + return createBytes(language, PythonBuiltinClassType.PBytes, PythonBuiltinClassType.PBytes.getInstanceShape(language), storage); + } + + public static PBytes createBytes(PythonLanguage language, Object cls, Shape shape, byte[] bytes) { + return createBytes(language, cls, shape, new ByteSequenceStorage(bytes)); + } + + public static PBytes createBytes(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage) { + return create(language, () -> new PBytes(cls, shape, storage)); + } + + public static PTuple createEmptyTuple(PythonLanguage language) { + return createTuple(language, EmptySequenceStorage.INSTANCE); + } + + public static PTuple createEmptyTuple(PythonLanguage language, Object cls, Shape shape) { + return createTuple(language, cls, shape, EmptySequenceStorage.INSTANCE); + } + + public static PTuple createTuple(PythonLanguage language, Object[] objects) { + return createTuple(language, new ObjectSequenceStorage(objects)); + } + + public static PTuple createTuple(PythonLanguage language, int[] ints) { + return createTuple(language, new IntSequenceStorage(ints)); + } + + public static PTuple createTuple(PythonLanguage language, SequenceStorage store) { + return createTuple(language, PythonBuiltinClassType.PTuple, PythonBuiltinClassType.PTuple.getInstanceShape(language), store); + } + + public static PTuple createTuple(PythonLanguage language, Object cls, Shape shape, SequenceStorage store) { + return create(language, () -> new PTuple(cls, shape, store)); + } + + public static PTuple createStructSeq(PythonLanguage language, BuiltinTypeDescriptor desc, Object... values) { + assert desc.inSequence <= values.length && values.length <= desc.fieldNames.length; + return createTuple(language, desc.type, desc.type.getInstanceShape(language), new ObjectSequenceStorage(values, desc.inSequence)); + } + + public static PTupleGetter createTupleGetter(PythonLanguage language, int index, Object doc) { + return createTupleGetter(language, PythonBuiltinClassType.PTupleGetter, PythonBuiltinClassType.PTupleGetter.getInstanceShape(language), index, doc); + } + + public static PTupleGetter createTupleGetter(PythonLanguage language, Object cls, Shape shape, int index, Object doc) { + return create(language, () -> new PTupleGetter(cls, shape, index, doc)); + } + + public static PComplex createComplex(PythonLanguage language, Object cls, Shape shape, double real, double imag) { + return create(language, () -> new PComplex(cls, shape, real, imag)); + } + + public static PComplex createComplex(PythonLanguage language, double real, double imag) { + return createComplex(language, PythonBuiltinClassType.PComplex, PythonBuiltinClassType.PComplex.getInstanceShape(language), real, imag); + } + + public static PIntRange createIntRange(PythonLanguage language, int stop) { + return create(language, () -> new PIntRange(language, 0, stop, 1, stop)); + } + + public static PIntRange createIntRange(PythonLanguage language, int start, int stop, int step, int len) { + return create(language, () -> new PIntRange(language, start, stop, step, len)); + } + + public static PBigRange createBigRange(PythonLanguage language, PInt start, PInt stop, PInt step, PInt len) { + return create(language, () -> new PBigRange(language, start, stop, step, len)); + } + + public static PIntSlice createIntSlice(PythonLanguage language, int start, int stop, int step) { + return create(language, () -> new PIntSlice(language, start, stop, step)); + } + + public static PIntSlice createIntSlice(PythonLanguage language, int start, int stop, int step, boolean isStartNone, boolean isStepNone) { + return create(language, () -> new PIntSlice(language, start, stop, step, isStartNone, isStepNone)); + } + + public static PObjectSlice createObjectSlice(PythonLanguage language, Object start, Object stop, Object step) { + return create(language, () -> new PObjectSlice(language, start, stop, step)); + } + + public static PRandom createRandom(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PRandom(cls, shape)); + } + + /* + * Classes, methods and functions + */ + + /** + * Only to be used during context creation + */ + public static PythonModule createPythonModule(PythonLanguage language, TruffleString name) { + return create(language, () -> PythonModule.createInternal(name)); + } + + public static PythonModule createPythonModule(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PythonModule(cls, shape)); + } + + public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language, TruffleString name, Object base, PythonAbstractClass[] bases) { + return createPythonClassAndFixupSlots(language, PythonBuiltinClassType.PythonClass, PythonBuiltinClassType.PythonClass.getInstanceShape(language), name, base, bases); + } + + public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language, Object metaclass, Shape metaclassShape, TruffleString name, Object base, PythonAbstractClass[] bases) { + PythonClass result = create(language, () -> new PythonClass(language, metaclass, metaclassShape, name, base, bases)); + // Fixup tp slots + MroSequenceStorage mro = GetMroStorageNode.executeUncached(result); + SpecialMethodSlot.initializeSpecialMethodSlots(result, mro, language); + TpSlots.inherit(result, mro, true); + TpSlots.fixupSlotDispatchers(result); + result.initializeMroShape(language); + return result; + } + + public static PythonClass createPythonClass(PythonLanguage language, Object metaclass, Shape metaclassShape, TruffleString name, boolean invokeMro, Object base, PythonAbstractClass[] bases) { + // Note: called from type ctor, which itself will invoke setupSpecialMethodSlots at the + // right point + return create(language, () -> new PythonClass(language, metaclass, metaclassShape, name, invokeMro, base, bases)); + } + + public static PMemoryView createMemoryView(PythonLanguage language, PythonContext context, BufferLifecycleManager bufferLifecycleManager, Object buffer, Object owner, + int len, boolean readonly, int itemsize, BufferFormat format, TruffleString formatString, int ndim, Object bufPointer, + int offset, int[] shape, int[] strides, int[] suboffsets, int flags) { + PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; + return create(language, () -> new PMemoryView(cls, cls.getInstanceShape(language), context, bufferLifecycleManager, buffer, owner, len, readonly, itemsize, format, formatString, + ndim, bufPointer, offset, shape, strides, suboffsets, flags)); + } + + public static PMemoryView createMemoryViewForManagedObject(PythonLanguage language, Object buffer, Object owner, int itemsize, int length, boolean readonly, TruffleString format, + TruffleString.CodePointLengthNode lengthNode, TruffleString.CodePointAtIndexNode atIndexNode) { + PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; + return create(language, () -> new PMemoryView(cls, cls.getInstanceShape(language), null, null, buffer, owner, length, readonly, itemsize, + BufferFormat.forMemoryView(format, lengthNode, atIndexNode), format, 1, null, 0, new int[]{length / itemsize}, new int[]{itemsize}, null, + PMemoryView.FLAG_C | PMemoryView.FLAG_FORTRAN)); + } + + public static PMethod createMethod(PythonLanguage language, Object cls, Shape shape, Object self, Object function) { + return create(language, () -> new PMethod(cls, shape, self, function)); + } + + public static PMethod createMethod(PythonLanguage language, Object self, Object function) { + return createMethod(language, PythonBuiltinClassType.PMethod, PythonBuiltinClassType.PMethod.getInstanceShape(language), self, function); + } + + public static PMethod createBuiltinMethod(PythonLanguage language, Object self, PFunction function) { + return createMethod(language, PythonBuiltinClassType.PBuiltinFunctionOrMethod, PythonBuiltinClassType.PBuiltinFunctionOrMethod.getInstanceShape(language), self, function); + } + + public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object cls, Shape shape, Object self, PBuiltinFunction function) { + return create(language, () -> new PBuiltinMethod(cls, shape, self, function, null)); + } + + public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object self, PBuiltinFunction function, Object classObject) { + return create(language, () -> new PBuiltinMethod(PythonBuiltinClassType.PBuiltinMethod, PythonBuiltinClassType.PBuiltinMethod.getInstanceShape(language), self, function, classObject)); + } + + public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object self, PBuiltinFunction function) { + return createBuiltinMethod(language, PythonBuiltinClassType.PBuiltinFunctionOrMethod, PythonBuiltinClassType.PBuiltinFunctionOrMethod.getInstanceShape(language), self, function); + } + + public static PFunction createFunction(PythonLanguage language, TruffleString name, PCode code, PythonObject globals, PCell[] closure) { + return create(language, () -> new PFunction(language, name, name, code, globals, closure)); + } + + public static PFunction createFunction(PythonLanguage language, TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, + PCell[] closure) { + return create(language, () -> new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure)); + } + + public static PFunction createFunction(PythonLanguage language, TruffleString name, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure) { + return create(language, () -> new PFunction(language, name, name, code, globals, defaultValues, kwDefaultValues, closure)); + } + + public static PFunction createFunction(PythonLanguage language, TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, + PCell[] closure, + Assumption codeStableAssumption, Assumption defaultsStableAssumption) { + return create(language, () -> new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure, + codeStableAssumption, defaultsStableAssumption)); + } + + public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget) { + return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, + PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget)); + } + + public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget) { + return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, defaults, kw, flags, + callTarget)); + } + + public static PBuiltinFunction createWrapperDescriptor(PythonLanguage language, TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget, TpSlot slot, + PExternalFunctionWrapper slotWrapper) { + return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, + PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget, slot, slotWrapper)); + } + + public static PBuiltinFunction createWrapperDescriptor(PythonLanguage language, TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget, + TpSlot slot, PExternalFunctionWrapper slotWrapper) { + return create(language, + () -> new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, defaults, kw, flags, + callTarget, slot, slotWrapper)); + } + + public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, PBuiltinFunction function, Object klass) { + PythonBuiltinClassType type = (PythonBuiltinClassType) function.getInitialPythonClass(); + return create(language, () -> new PBuiltinFunction(type, type.getInstanceShape(language), function.getName(), klass, + function.getDefaults(), function.getKwDefaults(), function.getFlags(), function.getCallTarget(), + function.getSlot(), function.getSlotWrapper())); + } + + public static GetSetDescriptor createGetSetDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type) { + return create(language, () -> new GetSetDescriptor(language, get, set, name, type)); + } + + public static GetSetDescriptor createGetSetDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type, boolean allowsDelete) { + return create(language, () -> new GetSetDescriptor(language, get, set, name, type, allowsDelete)); + } + + public static GetSetDescriptor createMemberDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type) { + return create(language, + () -> new GetSetDescriptor(PythonBuiltinClassType.MemberDescriptor, PythonBuiltinClassType.MemberDescriptor.getInstanceShape(language), get, set, name, type, set != null)); + } + + public static IndexedSlotDescriptor createIndexedSlotDescriptor(PythonLanguage language, TruffleString name, int index, Object type) { + return create(language, () -> new IndexedSlotDescriptor(language, name, index, type)); + } + + public static PDecoratedMethod createClassmethod(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PDecoratedMethod(cls, shape)); + } + + public static PDecoratedMethod createClassmethodFromCallableObj(PythonLanguage language, Object callable) { + return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PClassmethod, PythonBuiltinClassType.PClassmethod.getInstanceShape(language), callable)); + } + + public static PDecoratedMethod createBuiltinClassmethodFromCallableObj(PythonLanguage language, Object callable) { + return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PBuiltinClassMethod, PythonBuiltinClassType.PBuiltinClassMethod.getInstanceShape(language), callable)); + } + + public static PDecoratedMethod createInstancemethod(PythonLanguage language) { + return createInstancemethod(language, PythonBuiltinClassType.PInstancemethod, PythonBuiltinClassType.PInstancemethod.getInstanceShape(language)); + } + + public static PDecoratedMethod createInstancemethod(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PDecoratedMethod(cls, shape)); + } + + public static PDecoratedMethod createStaticmethod(PythonLanguage language) { + return createStaticmethod(language, PythonBuiltinClassType.PStaticmethod, PythonBuiltinClassType.PStaticmethod.getInstanceShape(language)); + } + + public static PDecoratedMethod createStaticmethod(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PDecoratedMethod(cls, shape)); + } + + public static PDecoratedMethod createStaticmethodFromCallableObj(PythonLanguage language, Object callable) { + Object func; + if (callable instanceof PBuiltinFunction builtinFunction) { + /* + * CPython's C static methods contain an object of type `builtin_function_or_method` + * (our PBuiltinMethod). Their self points to their type, but when called they get NULL + * as the first argument instead. + */ + func = createBuiltinMethod(language, builtinFunction.getEnclosingType(), builtinFunction); + } else { + func = callable; + } + return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PStaticmethod, PythonBuiltinClassType.PStaticmethod.getInstanceShape(language), func)); + } + + /* + * Lists, sets and dicts + */ + + public static PList createList(PythonLanguage language) { + return createList(language, EmptySequenceStorage.INSTANCE); + } + + public static PList createList(PythonLanguage language, Object[] array) { + return createList(language, new ObjectSequenceStorage(array)); + } + + public static PList createList(PythonLanguage language, SequenceStorage storage) { + return createList(language, storage, (PList.ListOrigin) null); + } + + public static PList createList(PythonLanguage language, SequenceStorage storage, PList.ListOrigin origin) { + return createList(language, PythonBuiltinClassType.PList, PythonBuiltinClassType.PList.getInstanceShape(language), storage, origin); + } + + public static PList createList(PythonLanguage language, Object cls, Shape shape) { + return createList(language, cls, shape, EmptySequenceStorage.INSTANCE); + } + + public static PList createList(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage) { + return createList(language, cls, shape, storage, null); + } + + public static PList createList(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage, PList.ListOrigin origin) { + return create(language, () -> new PList(cls, shape, storage, origin)); + } + + public static PSet createSet(PythonLanguage language) { + return createSet(language, EmptyStorage.INSTANCE); + } + + public static PSet createSet(PythonLanguage language, HashingStorage storage) { + return createSet(language, PythonBuiltinClassType.PSet, PythonBuiltinClassType.PSet.getInstanceShape(language), storage); + } + + public static PSet createSet(PythonLanguage language, Object cls, Shape shape) { + return createSet(language, cls, shape, EmptyStorage.INSTANCE); + } + + public static PSet createSet(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { + return create(language, () -> new PSet(cls, shape, storage)); + } + + public static PFrozenSet createFrozenSet(PythonLanguage language) { + return createFrozenSet(language, EmptyStorage.INSTANCE); + } + + public static PFrozenSet createFrozenSet(PythonLanguage language, HashingStorage storage) { + return createFrozenSet(language, PythonBuiltinClassType.PFrozenSet, PythonBuiltinClassType.PFrozenSet.getInstanceShape(language), storage); + } + + public static PFrozenSet createFrozenSet(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { + return create(language, () -> new PFrozenSet(cls, shape, storage)); + } + + public static PDict createDict(PythonLanguage language) { + return createDict(language, EmptyStorage.INSTANCE); + } + + public static PDict createDict(PythonLanguage language, PKeyword[] keywords) { + return createDict(language, new KeywordsStorage(keywords)); + } + + public static PDict createDict(PythonLanguage language, HashingStorage storage) { + return createDict(language, PythonBuiltinClassType.PDict, PythonBuiltinClassType.PDict.getInstanceShape(language), storage); + } + + public static PDict createDict(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { + return create(language, () -> new PDict(cls, shape, storage)); + } + + public static POrderedDict createOrderedDict(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new POrderedDict(cls, shape)); + } + + public static PDictKeysView createOrderedDictKeys(PythonLanguage language, POrderedDict dict) { + PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictKeys; + return create(language, () -> new PDictKeysView(cls, cls.getInstanceShape(language), dict)); + } + + public static PDictValuesView createOrderedDictValues(PythonLanguage language, POrderedDict dict) { + PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictValues; + return create(language, () -> new PDictValuesView(cls, cls.getInstanceShape(language), dict)); + } + + public static PDictItemsView createOrderedDictItems(PythonLanguage language, POrderedDict dict) { + PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictItems; + return create(language, () -> new PDictItemsView(cls, cls.getInstanceShape(language), dict)); + } + + public static POrderedDictIterator createOrderedDictIterator(PythonLanguage language, POrderedDict dict, POrderedDictIterator.IteratorType type, boolean reversed) { + PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictIterator; + return create(language, () -> new POrderedDictIterator(cls, cls.getInstanceShape(language), dict, type, reversed)); + } + + public static PDict createDictFromMap(PythonLanguage language, LinkedHashMap map) { + return createDict(language, EconomicMapStorage.create(map)); + } + + /** + * Generic version of {@link #createDictFromMap(PythonLanguage, LinkedHashMap)} that allows any + * type of keys. Note that this means that unless the keys are known to be side effect free, + * e.g., builtin types, this may end up calling Python code, so indirect call context should be + * properly set-up. This helper is meant for Truffle boundary code, in PE code build a storage + * by setting elements one by one starting from empty storage. + */ + public static PDict createDictFromMapGeneric(PythonLanguage language, LinkedHashMap map) { + return createDict(language, EconomicMapStorage.createGeneric(map)); + } + + public static PDict createDictFixedStorage(PythonLanguage language, PythonObject pythonObject, MroSequenceStorage mroSequenceStorage) { + return createDict(language, new DynamicObjectStorage(pythonObject, mroSequenceStorage)); + } + + public static PDict createDictFixedStorage(PythonLanguage language, PythonObject pythonObject) { + return createDict(language, new DynamicObjectStorage(pythonObject)); + } + + public static PSimpleNamespace createSimpleNamespace(PythonLanguage language) { + return createSimpleNamespace(language, PythonBuiltinClassType.PSimpleNamespace, PythonBuiltinClassType.PSimpleNamespace.getInstanceShape(language)); + } + + public static PSimpleNamespace createSimpleNamespace(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PSimpleNamespace(cls, shape)); + } + + public static PKeyWrapper createKeyWrapper(PythonLanguage language, Object cmp) { + return create(language, () -> new PKeyWrapper(PythonBuiltinClassType.PKeyWrapper, PythonBuiltinClassType.PKeyWrapper.getInstanceShape(language), cmp)); + } + + public static PPartial createPartial(PythonLanguage language, Object cls, Shape shape, Object function, Object[] args, PDict kwDict) { + return create(language, () -> new PPartial(cls, shape, function, args, kwDict)); + } + + public static LruCacheObject createLruCacheObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new LruCacheObject(cls, shape)); + } + + public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape) { + return createDefaultDict(language, cls, shape, PNone.NONE); + } + + public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape, Object defaultFactory) { + return create(language, () -> new PDefaultDict(cls, shape, defaultFactory)); + } + + public static PDefaultDict createDefaultDict(PythonLanguage language, Object defaultFactory, HashingStorage storage) { + return createDefaultDict(language, PythonBuiltinClassType.PDefaultDict, PythonBuiltinClassType.PDefaultDict.getInstanceShape(language), defaultFactory, storage); + } + + public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape, Object defaultFactory, HashingStorage storage) { + return create(language, () -> new PDefaultDict(cls, shape, storage, defaultFactory)); + } + + public static PDictView createDictKeysView(PythonLanguage language, PHashingCollection dict) { + return create(language, () -> new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict)); + } + + public static PDictView createDictKeysView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { + return create(language, () -> new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict, foreignHashingStorage)); + } + + public static PDictView createDictValuesView(PythonLanguage language, PHashingCollection dict) { + return create(language, () -> new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict)); + } + + public static PDictView createDictValuesView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { + return create(language, () -> new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict, foreignHashingStorage)); + } + + public static PDictView createDictItemsView(PythonLanguage language, PHashingCollection dict) { + return create(language, () -> new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict)); + } + + public static PDictView createDictItemsView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { + return create(language, () -> new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict, foreignHashingStorage)); + } + + /* + * Special objects: generators, proxies, references, cells + */ + + public static PGenerator createGenerator(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { + return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator)); + } + + public static PGenerator createIterableCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, + Object[] arguments) { + return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator, true)); + } + + public static PGenerator createCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { + return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PCoroutine)); + } + + public static PCoroutineWrapper createCoroutineWrapper(PythonLanguage language, PGenerator generator) { + return create(language, () -> new PCoroutineWrapper(language, generator)); + } + + public static PAsyncGen createAsyncGenerator(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { + return create(language, () -> PAsyncGen.create(language, name, qualname, rootNode, callTargets, arguments)); + } + + public static PMappingproxy createMappingproxy(PythonLanguage language, Object object) { + return createMappingproxy(language, PythonBuiltinClassType.PMappingproxy, PythonBuiltinClassType.PMappingproxy.getInstanceShape(language), object); + } + + public static PMappingproxy createMappingproxy(PythonLanguage language, Object cls, Shape shape, Object object) { + return create(language, () -> new PMappingproxy(cls, shape, object)); + } + + public static PReferenceType createReferenceType(PythonLanguage language, Object cls, Shape shape, Object object, Object callback, ReferenceQueue queue) { + return create(language, () -> new PReferenceType(cls, shape, object, callback, queue)); + } + + public static PCell createCell(PythonLanguage language, Assumption effectivelyFinal) { + return create(language, () -> new PCell(effectivelyFinal)); + } + + /* + * Frames, traces and exceptions + */ + + public static PFrame createPFrame(PythonLanguage language, PFrame.Reference frameInfo, Node location, MaterializedFrame locals) { + return create(language, () -> new PFrame(language, frameInfo, location, locals)); + } + + public static PFrame createPFrame(PythonLanguage language, Object threadState, PCode code, PythonObject globals, Object localsDict) { + return create(language, () -> new PFrame(language, threadState, code, globals, localsDict)); + } + + public static PTraceback createTraceback(PythonLanguage language, PFrame frame, int lineno, PTraceback next) { + return create(language, () -> new PTraceback(language, frame, lineno, -1, next)); + } + + public static PTraceback createTracebackWithLasti(PythonLanguage language, PFrame frame, int lineno, int lasti, PTraceback next) { + return create(language, () -> new PTraceback(language, frame, lineno, lasti, next)); + } + + public static PTraceback createTraceback(PythonLanguage language, LazyTraceback tb) { + return create(language, () -> new PTraceback(language, tb)); + } + + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, PTuple args) { + return createBaseException(language, cls, shape, null, args); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType cls, PTuple args) { + return createBaseException(language, cls, cls.getInstanceShape(language), null, args); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, Object[] data, PTuple args) { + return createBaseException(language, type, type.getInstanceShape(language), data, args); + } + + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data, PTuple args) { + return create(language, () -> new PBaseException(cls, shape, data, args)); + } + + /* + * Note: we use this method to convert a Java StackOverflowError into a Python RecursionError. + * At the time when this is done, some Java stack frames were already unwinded but there is no + * guarantee on how many. Therefore, it is important that this method is simple. In particular, + * do not add calls if that can be avoided. + */ + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, TruffleString format, Object[] args) { + return createBaseException(language, cls, shape, null, format, args); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, TruffleString format, Object[] args) { + return createBaseException(language, type, type.getInstanceShape(language), null, format, args); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, Object[] data, TruffleString format, Object[] args) { + return createBaseException(language, type, type.getInstanceShape(language), data, format, args); + } + + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data, TruffleString format, Object[] args) { + assert format != null; + return create(language, () -> new PBaseException(cls, shape, data, format, args)); + } + + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PBaseException(cls, shape, null)); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type) { + return create(language, () -> new PBaseException(type, type.getInstanceShape(language), null)); + } + + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, Object[] data) { + return createBaseException(language, type, type.getInstanceShape(language), data); + } + + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data) { + return create(language, () -> new PBaseException(cls, shape, data)); + } + + public static PBaseExceptionGroup createBaseExceptionGroup(PythonLanguage language, Object cls, Shape shape, TruffleString message, Object[] exceptions, Object[] args) { + return create(language, () -> new PBaseExceptionGroup(cls, shape, message, exceptions, createTuple(language, args))); + } + + /* + * Arrays + */ + + public static PArray createArray(PythonLanguage language, Object cls, Shape shape, TruffleString formatString, BufferFormat format) { + assert format != null; + return create(language, () -> new PArray(cls, shape, formatString, format)); + } + + public static PArray createArray(PythonLanguage language, TruffleString formatString, BufferFormat format, int length) throws OverflowException { + return createArray(language, PythonBuiltinClassType.PArray, PythonBuiltinClassType.PArray.getInstanceShape(language), formatString, format, length); + } + + public static PArray createArray(PythonLanguage language, Object cls, Shape shape, TruffleString formatString, BufferFormat format, int length) throws OverflowException { + assert format != null; + int byteSize = PythonUtils.multiplyExact(length, format.bytesize); + return create(language, () -> new PArray(cls, shape, formatString, format, byteSize)); + } + + public static PByteArray createByteArray(PythonLanguage language, byte[] array) { + return createByteArray(language, array, array.length); + } + + public static PByteArray createByteArray(PythonLanguage language, Object cls, Shape shape, byte[] array) { + return createByteArray(language, cls, shape, array, array.length); + } + + public static PByteArray createByteArray(PythonLanguage language, byte[] array, int length) { + return createByteArray(language, new ByteSequenceStorage(array, length)); + } + + public static PByteArray createByteArray(PythonLanguage language, Object cls, Shape shape, byte[] array, int length) { + return createByteArray(language, cls, shape, new ByteSequenceStorage(array, length)); + } + + public static PByteArray createByteArray(PythonLanguage language, SequenceStorage storage) { + return createByteArray(language, PythonBuiltinClassType.PByteArray, PythonBuiltinClassType.PByteArray.getInstanceShape(language), storage); + } + + public static PByteArray createByteArray(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage) { + return create(language, () -> new PByteArray(cls, shape, storage)); + } + + /* + * Iterators + */ + + public static PStringIterator createStringIterator(PythonLanguage language, TruffleString str) { + return create(language, () -> new PStringIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), str)); + } + + public static PStringReverseIterator createStringReverseIterator(PythonLanguage language, Object cls, Shape shape, TruffleString str) { + return create(language, () -> new PStringReverseIterator(cls, shape, str)); + } + + public static PIntegerSequenceIterator createIntegerSequenceIterator(PythonLanguage language, IntSequenceStorage storage, Object list) { + return create(language, () -> new PIntegerSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + } + + public static PLongSequenceIterator createLongSequenceIterator(PythonLanguage language, LongSequenceStorage storage, Object list) { + return create(language, () -> new PLongSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + } + + public static PDoubleSequenceIterator createDoubleSequenceIterator(PythonLanguage language, DoubleSequenceStorage storage, Object list) { + return create(language, () -> new PDoubleSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + } + + public static PObjectSequenceIterator createObjectSequenceIterator(PythonLanguage language, ObjectSequenceStorage storage, Object list) { + return create(language, () -> new PObjectSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + } + + public static PSequenceIterator createSequenceIterator(PythonLanguage language, Object sequence) { + return create(language, () -> new PSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), sequence)); + } + + public static PSequenceReverseIterator createSequenceReverseIterator(PythonLanguage language, Object sequence, int lengthHint) { + return createSequenceReverseIterator(language, PythonBuiltinClassType.PReverseIterator, PythonBuiltinClassType.PReverseIterator.getInstanceShape(language), sequence, lengthHint); + } + + public static PSequenceReverseIterator createSequenceReverseIterator(PythonLanguage language, Object cls, Shape shape, Object sequence, int lengthHint) { + return create(language, () -> new PSequenceReverseIterator(cls, shape, sequence, lengthHint)); + } + + public static PIntRangeIterator createIntRangeIterator(PythonLanguage language, PIntRange fastRange) { + return createIntRangeIterator(language, fastRange.getIntStart(), fastRange.getIntStop(), fastRange.getIntStep(), fastRange.getIntLength()); + } + + public static PIntRangeIterator createIntRangeIterator(PythonLanguage language, int start, int stop, int step, int len) { + return create(language, () -> new PIntRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); + } + + public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, PInt start, PInt stop, PInt step, PInt len) { + return create(language, () -> new PBigRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); + } + + public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, PBigRange longRange) { + return createBigRangeIterator(language, longRange.getPIntStart(), longRange.getPIntStop(), longRange.getPIntStep(), longRange.getPIntLength()); + } + + public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, BigInteger start, BigInteger stop, BigInteger step, BigInteger len) { + return createBigRangeIterator(language, createInt(language, start), createInt(language, stop), createInt(language, step), createInt(language, len)); + } + + public static PArrayIterator createArrayIterator(PythonLanguage language, PArray array) { + return create(language, () -> new PArrayIterator(PythonBuiltinClassType.PArrayIterator, PythonBuiltinClassType.PArrayIterator.getInstanceShape(language), array)); + } + + public static PBaseSetIterator createBaseSetIterator(PythonLanguage language, PBaseSet set, HashingStorageNodes.HashingStorageIterator iterator, int initialSize) { + return create(language, () -> new PBaseSetIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), set, iterator, initialSize)); + } + + public static PDictItemIterator createDictItemIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { + return create(language, () -> new PDictItemIterator(PythonBuiltinClassType.PDictItemIterator, PythonBuiltinClassType.PDictItemIterator.getInstanceShape(language), iterator, hashingStorage, + initialSize)); + } + + public static PDictKeyIterator createDictKeyIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { + return create(language, + () -> new PDictKeyIterator(PythonBuiltinClassType.PDictKeyIterator, PythonBuiltinClassType.PDictKeyIterator.getInstanceShape(language), iterator, hashingStorage, initialSize)); + } + + public static PDictValueIterator createDictValueIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { + return create(language, () -> new PDictValueIterator(PythonBuiltinClassType.PDictValueIterator, PythonBuiltinClassType.PDictValueIterator.getInstanceShape(language), iterator, hashingStorage, + initialSize)); + } + + public static Object createSentinelIterator(PythonLanguage language, Object callable, Object sentinel) { + return create(language, () -> new PSentinelIterator(PythonBuiltinClassType.PSentinelIterator, PythonBuiltinClassType.PSentinelIterator.getInstanceShape(language), callable, sentinel)); + } + + public static PEnumerate createEnumerate(PythonLanguage language, Object cls, Shape shape, Object iterator, long start) { + return create(language, () -> new PEnumerate(cls, shape, iterator, start)); + } + + public static PEnumerate createEnumerate(PythonLanguage language, Object cls, Shape shape, Object iterator, PInt start) { + return create(language, () -> new PEnumerate(cls, shape, iterator, start)); + } + + public static PMap createMap(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PMap(cls, shape)); + } + + public static PZip createZip(PythonLanguage language, Object cls, Shape shape, Object[] iterables, boolean strict) { + return create(language, () -> new PZip(cls, shape, iterables, strict)); + } + + public static PCode createCode(PythonLanguage language, RootCallTarget ct) { + return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct)); + } + + public static PCode createCode(PythonLanguage language, RootCallTarget ct, int flags, int firstlineno, byte[] linetable, TruffleString filename) { + return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct, flags, firstlineno, linetable, filename)); + } + + public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, CodeUnit codeUnit) { + return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, codeUnit)); + } + + public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, int nlocals, + int stacksize, int flags, Object[] constants, + TruffleString[] names, TruffleString[] varnames, + TruffleString[] freevars, TruffleString[] cellvars, + TruffleString filename, TruffleString name, TruffleString qualname, + int firstlineno, byte[] linetable) { + return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, + nlocals, stacksize, flags, constants, names, varnames, freevars, cellvars, + filename, name, qualname, firstlineno, linetable)); + } + + public static PCode createCode(PythonLanguage language, Supplier createCode, int flags, int firstlineno, byte[] lnotab, TruffleString filename) { + return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), createCode, flags, firstlineno, lnotab, filename)); + } + + /* + * Socket + */ + + public static PSocket createSocket(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PSocket(cls, shape)); + } + + /* + * Threading + */ + + public static PThreadLocal createThreadLocal(PythonLanguage language, Object cls, Shape shape, Object[] args, PKeyword[] kwArgs) { + return create(language, () -> new PThreadLocal(cls, shape, args, kwArgs)); + } + + public static PLock createLock(PythonLanguage language) { + return createLock(language, PythonBuiltinClassType.PLock, PythonBuiltinClassType.PLock.getInstanceShape(language)); + } + + public static PLock createLock(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PLock(cls, shape)); + } + + public static PRLock createRLock(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PRLock(cls, shape)); + } + + public static PThread createPythonThread(PythonLanguage language, Thread thread) { + return createPythonThread(language, PythonBuiltinClassType.PThread, PythonBuiltinClassType.PThread.getInstanceShape(language), thread); + } + + public static PThread createPythonThread(PythonLanguage language, Object cls, Shape shape, Thread thread) { + return create(language, () -> new PThread(cls, shape, thread)); + } + + public static PSemLock createSemLock(PythonLanguage language, Object cls, Shape shape, long handle, int kind, int maxValue, TruffleString name) { + return create(language, () -> new PSemLock(cls, shape, handle, kind, maxValue, name)); + } + + public static PGraalPySemLock createGraalPySemLock(PythonLanguage language, TruffleString name, int kind, Semaphore sharedSemaphore) { + return createGraalPySemLock(language, PythonBuiltinClassType.PGraalPySemLock, PythonBuiltinClassType.PGraalPySemLock.getInstanceShape(language), name, kind, sharedSemaphore); + } + + public static PGraalPySemLock createGraalPySemLock(PythonLanguage language, Object cls, Shape shape, TruffleString name, int kind, Semaphore sharedSemaphore) { + return create(language, () -> new PGraalPySemLock(cls, shape, name, kind, sharedSemaphore)); + } + + public static PScandirIterator createScandirIterator(PythonLanguage language, PythonContext context, Object dirStream, PosixFileHandle path, boolean needsRewind) { + return create(language, + () -> new PScandirIterator(PythonBuiltinClassType.PScandirIterator, PythonBuiltinClassType.PScandirIterator.getInstanceShape(language), context, dirStream, path, needsRewind)); + } + + public static PDirEntry createDirEntry(PythonLanguage language, Object dirEntryData, PosixFileHandle path) { + return create(language, () -> new PDirEntry(PythonBuiltinClassType.PDirEntry, PythonBuiltinClassType.PDirEntry.getInstanceShape(language), dirEntryData, path)); + } + + public static PEncodingMap createEncodingMap(PythonLanguage language, int count2, int count3, byte[] level1, byte[] level23) { + return create(language, () -> new PEncodingMap(PythonBuiltinClassType.PEncodingMap, PythonBuiltinClassType.PEncodingMap.getInstanceShape(language), count2, count3, level1, level23)); + } + + public static PMMap createMMap(PythonLanguage language, PythonContext context, Object cls, Shape shape, Object mmapHandle, int fd, long length, int access) { + return create(language, () -> new PMMap(cls, shape, context, mmapHandle, fd, length, access)); + } + + public static BZ2Object.BZ2Compressor createBZ2Compressor(PythonLanguage language) { + return createBZ2Compressor(language, PythonBuiltinClassType.BZ2Compressor, PythonBuiltinClassType.BZ2Compressor.getInstanceShape(language)); + } + + public static BZ2Object.BZ2Compressor createBZ2Compressor(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> BZ2Object.createCompressor(cls, shape)); + } + + public static BZ2Object.BZ2Decompressor createBZ2Decompressor(PythonLanguage language) { + return createBZ2Decompressor(language, PythonBuiltinClassType.BZ2Decompressor, PythonBuiltinClassType.BZ2Decompressor.getInstanceShape(language)); + } + + public static BZ2Object.BZ2Decompressor createBZ2Decompressor(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> BZ2Object.createDecompressor(cls, shape)); + } + + public static ZLibCompObject createJavaZLibCompObjectCompress(PythonLanguage language, Object stream, int level, int wbits, int strategy, byte[] zdict) { + return createJavaZLibCompObject(language, PythonBuiltinClassType.ZlibCompress, PythonBuiltinClassType.ZlibCompress.getInstanceShape(language), stream, level, wbits, strategy, zdict); + } + + public static ZLibCompObject createJavaZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object stream, int level, int wbits, int strategy, byte[] zdict) { + return create(language, () -> ZLibCompObject.createJava(cls, shape, stream, level, wbits, strategy, zdict)); + } + + public static ZLibCompObject createJavaZLibCompObjectDecompress(PythonLanguage language, Object stream, int wbits, byte[] zdict) { + return createJavaZLibCompObject(language, PythonBuiltinClassType.ZlibDecompress, PythonBuiltinClassType.ZlibDecompress.getInstanceShape(language), stream, wbits, zdict); + } + + public static ZLibCompObject createJavaZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object stream, int wbits, byte[] zdict) { + return create(language, () -> ZLibCompObject.createJava(cls, shape, stream, wbits, zdict)); + } + + public static ZLibCompObject createNativeZLibCompObjectCompress(PythonLanguage language, Object zst, NFIZlibSupport zlibSupport) { + return createNativeZLibCompObject(language, PythonBuiltinClassType.ZlibCompress, PythonBuiltinClassType.ZlibCompress.getInstanceShape(language), zst, zlibSupport); + } + + public static ZLibCompObject createNativeZLibCompObjectDecompress(PythonLanguage language, Object zst, NFIZlibSupport zlibSupport) { + return createNativeZLibCompObject(language, PythonBuiltinClassType.ZlibDecompress, PythonBuiltinClassType.ZlibDecompress.getInstanceShape(language), zst, zlibSupport); + } + + public static ZLibCompObject createNativeZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object zst, NFIZlibSupport zlibSupport) { + return create(language, () -> ZLibCompObject.createNative(cls, shape, zst, zlibSupport)); + } + + public static LZMAObject.LZMADecompressor createLZMADecompressor(PythonLanguage language, Object cls, Shape shape, boolean isNative) { + return create(language, () -> LZMAObject.createDecompressor(cls, shape, isNative)); + } + + public static LZMAObject.LZMACompressor createLZMACompressor(PythonLanguage language, Object cls, Shape shape, boolean isNative) { + return create(language, () -> LZMAObject.createCompressor(cls, shape, isNative)); + } + + public static CSVReader createCSVReader(PythonLanguage language, Object inputIter, CSVDialect dialect) { + return createCSVReader(language, PythonBuiltinClassType.CSVReader, PythonBuiltinClassType.CSVReader.getInstanceShape(language), inputIter, dialect); + } + + public static CSVReader createCSVReader(PythonLanguage language, Object cls, Shape shape, Object inputIter, CSVDialect dialect) { + return create(language, () -> new CSVReader(cls, shape, inputIter, dialect)); + } + + public static CSVWriter createCSVWriter(PythonLanguage language, Object write, CSVDialect dialect) { + return createCSVWriter(language, PythonBuiltinClassType.CSVWriter, PythonBuiltinClassType.CSVWriter.getInstanceShape(language), write, dialect); + } + + public static CSVWriter createCSVWriter(PythonLanguage language, Object cls, Shape shape, Object write, CSVDialect dialect) { + return create(language, () -> new CSVWriter(cls, shape, write, dialect)); + } + + public static CSVDialect createCSVDialect(PythonLanguage language, Object cls, Shape shape, TruffleString delimiter, int delimiterCodePoint, boolean doubleQuote, TruffleString escapeChar, + int escapeCharCodePoint, + TruffleString lineTerminator, TruffleString quoteChar, int quoteCharCodePoint, QuoteStyle quoting, boolean skipInitialSpace, boolean strict) { + return create(language, + () -> new CSVDialect(cls, shape, delimiter, delimiterCodePoint, doubleQuote, escapeChar, escapeCharCodePoint, lineTerminator, quoteChar, quoteCharCodePoint, + quoting, + skipInitialSpace, strict)); + } + + public static PFileIO createFileIO(PythonLanguage language) { + return createFileIO(language, PythonBuiltinClassType.PFileIO, PythonBuiltinClassType.PFileIO.getInstanceShape(language)); + } + + public static PFileIO createFileIO(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PFileIO(cls, shape)); + } + + public static PChain createChain(PythonLanguage language) { + return createChain(language, PythonBuiltinClassType.PChain, PythonBuiltinClassType.PChain.getInstanceShape(language)); + } + + public static PChain createChain(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PChain(cls, shape)); + } + + public static PCount createCount(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PCount(cls, shape)); + } + + public static PIslice createIslice(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PIslice(cls, shape)); + } + + public static PPairwise createPairwise(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PPairwise(cls, shape)); + } + + public static PPermutations createPermutations(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PPermutations(cls, shape)); + } + + public static PProduct createProduct(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PProduct(cls, shape)); + } + + public static PRepeat createRepeat(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PRepeat(cls, shape)); + } + + public static PAccumulate createAccumulate(PythonLanguage language) { + return createAccumulate(language, PythonBuiltinClassType.PAccumulate, PythonBuiltinClassType.PAccumulate.getInstanceShape(language)); + } + + public static PAccumulate createAccumulate(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PAccumulate(cls, shape)); + } + + public static PDropwhile createDropwhile(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PDropwhile(cls, shape)); + } + + public static PCombinations createCombinations(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PCombinations(cls, shape)); + } + + public static PCombinationsWithReplacement createCombinationsWithReplacement(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PCombinationsWithReplacement(cls, shape)); + } + + public static PCompress createCompress(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PCompress(cls, shape)); + } + + public static PCycle createCycle(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PCycle(cls, shape)); + } + + public static PFilterfalse createFilterfalse(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PFilterfalse(cls, shape)); + } + + public static PGroupBy createGroupBy(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PGroupBy(cls, shape)); + } + + public static PGrouper createGrouper(PythonLanguage language, PGroupBy parent, Object tgtKey) { + return create(language, () -> new PGrouper(parent, tgtKey, PythonBuiltinClassType.PGrouper, PythonBuiltinClassType.PGrouper.getInstanceShape(language))); + } + + public static PTee createTee(PythonLanguage language, PTeeDataObject dataObj, int index) { + return create(language, () -> new PTee(dataObj, index, PythonBuiltinClassType.PTee, PythonBuiltinClassType.PTee.getInstanceShape(language))); + } + + public static PStarmap createStarmap(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PStarmap(cls, shape)); + } + + public static PTakewhile createTakewhile(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PTakewhile(cls, shape)); + } + + public static PTeeDataObject createTeeDataObject(PythonLanguage language) { + return create(language, () -> new PTeeDataObject(PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); + } + + public static PTeeDataObject createTeeDataObject(PythonLanguage language, Object it) { + return create(language, () -> new PTeeDataObject(it, PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); + } + + public static PZipLongest createZipLongest(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PZipLongest(cls, shape)); + } + + public static PTextIO createTextIO(PythonLanguage language) { + return createTextIO(language, PythonBuiltinClassType.PTextIOWrapper, PythonBuiltinClassType.PTextIOWrapper.getInstanceShape(language)); + } + + public static PTextIO createTextIO(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PTextIO(cls, shape)); + } + + public static PStringIO createStringIO(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PStringIO(cls, shape)); + } + + public static PBytesIO createBytesIO(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PBytesIO(cls, shape)); + } + + public static PBytesIOBuffer createBytesIOBuf(PythonLanguage language, PBytesIO source) { + return createBytesIOBuf(language, PythonBuiltinClassType.PBytesIOBuf, PythonBuiltinClassType.PBytesIOBuf.getInstanceShape(language), source); + } + + public static PBytesIOBuffer createBytesIOBuf(PythonLanguage language, Object cls, Shape shape, PBytesIO source) { + return create(language, () -> new PBytesIOBuffer(cls, shape, source)); + } + + public static PNLDecoder createNLDecoder(PythonLanguage language) { + return createNLDecoder(language, PythonBuiltinClassType.PIncrementalNewlineDecoder, PythonBuiltinClassType.PIncrementalNewlineDecoder.getInstanceShape(language)); + } + + public static PNLDecoder createNLDecoder(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PNLDecoder(cls, shape)); + } + + public static PBuffered createBufferedReader(PythonLanguage language) { + return createBufferedReader(language, PythonBuiltinClassType.PBufferedReader, PythonBuiltinClassType.PBufferedReader.getInstanceShape(language)); + } + + public static PBuffered createBufferedReader(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PBuffered(cls, shape, true, false)); + } + + public static PBuffered createBufferedWriter(PythonLanguage language) { + return createBufferedWriter(language, PythonBuiltinClassType.PBufferedWriter, PythonBuiltinClassType.PBufferedWriter.getInstanceShape(language)); + } + + public static PBuffered createBufferedWriter(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PBuffered(cls, shape, false, true)); + } + + public static PBuffered createBufferedRandom(PythonLanguage language) { + return createBufferedRandom(language, PythonBuiltinClassType.PBufferedRandom, PythonBuiltinClassType.PBufferedRandom.getInstanceShape(language)); + } + + public static PBuffered createBufferedRandom(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PBuffered(cls, shape, true, true)); + } + + public static PRWPair createRWPair(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PRWPair(cls, shape)); + } + + public static PyCArgObject createCArgObject(PythonLanguage language) { + return create(language, () -> new PyCArgObject(PythonBuiltinClassType.CArgObject, PythonBuiltinClassType.CArgObject.getInstanceShape(language))); + } + + public static CThunkObject createCThunkObject(PythonLanguage language, int nArgs) { + return createCThunkObject(language, PythonBuiltinClassType.CThunkObject, PythonBuiltinClassType.CThunkObject.getInstanceShape(language), nArgs); + } + + public static CThunkObject createCThunkObject(PythonLanguage language, Object cls, Shape shape, int nArgs) { + return create(language, () -> new CThunkObject(cls, shape, nArgs)); + } + + // Don't use directly, use CtypesNodes.CreateCDataObjectNode + public static CDataObject createCDataObject(PythonLanguage language, Object cls, Shape shape, Pointer b_ptr, int b_size, boolean b_needsfree) { + return create(language, () -> new CDataObject(cls, shape, b_ptr, b_size, b_needsfree)); + } + + // Don't use directly, use CtypesNodes.CreateCDataObjectNode + public static PyCFuncPtrObject createPyCFuncPtrObject(PythonLanguage language, Object cls, Shape shape, Pointer b_ptr, int b_size, boolean b_needsfree) { + return create(language, () -> new PyCFuncPtrObject(cls, shape, b_ptr, b_size, b_needsfree)); + } + + public static CFieldObject createCFieldObject(PythonLanguage language) { + return createCFieldObject(language, PythonBuiltinClassType.CField, PythonBuiltinClassType.CField.getInstanceShape(language)); + } + + public static CFieldObject createCFieldObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new CFieldObject(cls, shape)); + } + + public static StgDictObject createStgDictObject(PythonLanguage language) { + return createStgDictObject(language, PythonBuiltinClassType.StgDict, PythonBuiltinClassType.StgDict.getInstanceShape(language)); + } + + public static StgDictObject createStgDictObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new StgDictObject(cls, shape)); + } + + public static PSSLContext createSSLContext(PythonLanguage language, Object cls, Shape shape, SSLMethod method, int verifyFlags, boolean checkHostname, int verifyMode, SSLContext context) { + return create(language, () -> new PSSLContext(cls, shape, method, verifyFlags, checkHostname, verifyMode, context)); + } + + public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext context, SSLEngine engine, PSocket socket) { + return createSSLSocket(language, PythonBuiltinClassType.PSSLSocket, PythonBuiltinClassType.PSSLSocket.getInstanceShape(language), context, engine, socket); + } + + public static PSSLSocket createSSLSocket(PythonLanguage language, Object cls, Shape shape, PSSLContext context, SSLEngine engine, PSocket socket) { + return create(language, () -> new PSSLSocket(cls, shape, context, engine, socket, createMemoryBIO(language), createMemoryBIO(language), createMemoryBIO(language))); + } + + public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext context, SSLEngine engine, PMemoryBIO inbound, PMemoryBIO outbound) { + return createSSLSocket(language, PythonBuiltinClassType.PSSLSocket, PythonBuiltinClassType.PSSLSocket.getInstanceShape(language), context, engine, inbound, outbound); + } + + public static PSSLSocket createSSLSocket(PythonLanguage language, Object cls, Shape shape, PSSLContext context, SSLEngine engine, PMemoryBIO inbound, PMemoryBIO outbound) { + return create(language, () -> new PSSLSocket(cls, shape, context, engine, null, inbound, outbound, createMemoryBIO(language))); + } + + public static PMemoryBIO createMemoryBIO(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PMemoryBIO(cls, shape)); + } + + public static PMemoryBIO createMemoryBIO(PythonLanguage language) { + return create(language, () -> new PMemoryBIO(PythonBuiltinClassType.PMemoryBIO, PythonBuiltinClassType.PMemoryBIO.getInstanceShape(language))); + } + + public static PProperty createProperty(PythonLanguage language) { + return create(language, () -> new PProperty(PythonBuiltinClassType.PProperty, PythonBuiltinClassType.PProperty.getInstanceShape(language))); + } + + public static PProperty createProperty(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PProperty(cls, shape)); + } + + // JSON + // (not created on fast path, thus TruffleBoundary) + + @TruffleBoundary + public static PJSONScanner createJSONScanner(PythonLanguage language, Object cls, Shape shape, boolean strict, Object objectHook, Object objectPairsHook, Object parseFloat, Object parseInt, + Object parseConstant) { + return create(language, () -> new PJSONScanner(cls, shape, strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant)); + } + + @TruffleBoundary + public static PJSONEncoder createJSONEncoder(PythonLanguage language, Object cls, Shape shape, Object markers, Object defaultFn, Object encoder, Object indent, TruffleString keySeparator, + TruffleString itemSeparator, + boolean sortKeys, boolean skipKeys, boolean allowNan, FastEncode fastEncode) { + return create(language, () -> new PJSONEncoder(cls, shape, markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode)); + } + + public static PDeque createDeque(PythonLanguage language) { + return create(language, () -> new PDeque(PythonBuiltinClassType.PDeque, PythonBuiltinClassType.PDeque.getInstanceShape(language))); + } + + public static PDeque createDeque(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PDeque(cls, shape)); + } + + public static PDequeIter createDequeIter(PythonLanguage language, PDeque deque) { + return create(language, () -> new PDequeIter(PythonBuiltinClassType.PDequeIter, PythonBuiltinClassType.PDequeIter.getInstanceShape(language), deque, false)); + } + + public static PDequeIter createDequeRevIter(PythonLanguage language, PDeque deque) { + return create(language, () -> new PDequeIter(PythonBuiltinClassType.PDequeRevIter, PythonBuiltinClassType.PDequeRevIter.getInstanceShape(language), deque, true)); + } + + public static PSimpleQueue createSimpleQueue(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PSimpleQueue(cls, shape)); + } + + public static PContextVar createContextVar(PythonLanguage language, TruffleString name, Object def) { + return create(language, () -> new PContextVar(PythonBuiltinClassType.ContextVar, PythonBuiltinClassType.ContextVar.getInstanceShape(language), name, def)); + } + + public static PContextVarsContext createContextVarsContext(PythonLanguage language) { + return create(language, () -> new PContextVarsContext(PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); + } + + public static PContextIterator createContextIterator(PythonLanguage language, PContextVarsContext ctx, PContextIterator.ItemKind kind) { + return create(language, () -> new PContextIterator(PythonBuiltinClassType.ContextIterator, PythonBuiltinClassType.ContextIterator.getInstanceShape(language), ctx, kind)); + } + + public static PContextVarsContext copyContextVarsContext(PythonLanguage language, PContextVarsContext original) { + return create(language, () -> new PContextVarsContext(original, PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); + } + + public static PContextVarsToken createContextVarsToken(PythonLanguage language, PContextVar var, Object oldValue) { + return create(language, () -> new PContextVarsToken(var, oldValue, PythonBuiltinClassType.ContextVarsToken, PythonBuiltinClassType.ContextVarsToken.getInstanceShape(language))); + } + + public static PGenericAlias createGenericAlias(PythonLanguage language, Object cls, Shape shape, Object origin, Object arguments, boolean starred) { + PTuple argumentsTuple; + if (arguments instanceof PTuple) { + argumentsTuple = (PTuple) arguments; + } else { + argumentsTuple = createTuple(language, new Object[]{arguments}); + } + return create(language, () -> new PGenericAlias(cls, shape, origin, argumentsTuple, starred)); + } + + public static PGenericAlias createGenericAlias(PythonLanguage language, Object origin, Object arguments, boolean starred) { + return createGenericAlias(language, PythonBuiltinClassType.PGenericAlias, PythonBuiltinClassType.PGenericAlias.getInstanceShape(language), origin, arguments, starred); + } + + public static PGenericAlias createGenericAlias(PythonLanguage language, Object origin, Object arguments) { + return createGenericAlias(language, origin, arguments, false); + } + + public static PGenericAliasIterator createGenericAliasIterator(PythonLanguage language, PGenericAlias object) { + return create(language, () -> new PGenericAliasIterator(PythonBuiltinClassType.PGenericAliasIterator, PythonBuiltinClassType.PGenericAliasIterator.getInstanceShape(language), object)); + } + + public static PUnionType createUnionType(PythonLanguage language, Object[] args) { + return create(language, () -> new PUnionType(PythonBuiltinClassType.PUnionType, PythonBuiltinClassType.PUnionType.getInstanceShape(language), createTuple(language, args))); + } + + public static DigestObject createDigestObject(PythonLanguage language, PythonBuiltinClassType type, String name, Object digest) { + return create(language, () -> DigestObject.create(type, type.getInstanceShape(language), name, digest)); + } + + public static PyCapsule createCapsuleNativeName(PythonLanguage language, Object pointer, Object name) { + return createCapsule(language, new PyCapsule.CapsuleData(pointer, name)); + } + + public static PyCapsule createCapsuleJavaName(PythonLanguage language, Object pointer, byte[] name) { + return createCapsule(language, new PyCapsule.CapsuleData(pointer, new CArrayWrappers.CByteArrayWrapper(name))); + } + + public static PyCapsule createCapsule(PythonLanguage language, PyCapsule.CapsuleData data) { + return create(language, () -> new PyCapsule(language, data)); + } + + public static MultibyteIncrementalDecoderObject createMultibyteIncrementalDecoderObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new MultibyteIncrementalDecoderObject(cls, shape)); + } + + public static MultibyteIncrementalEncoderObject createMultibyteIncrementalEncoderObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new MultibyteIncrementalEncoderObject(cls, shape)); + } + + public static MultibyteStreamReaderObject createMultibyteStreamReaderObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new MultibyteStreamReaderObject(cls, shape)); + } + + public static MultibyteStreamWriterObject createMultibyteStreamWriterObject(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new MultibyteStreamWriterObject(cls, shape)); + } + + public static MultibyteCodecObject createMultibyteCodecObject(PythonLanguage language, MultibyteCodec codec) { + return createMultibyteCodecObject(language, PythonBuiltinClassType.MultibyteCodec, PythonBuiltinClassType.MultibyteCodec.getInstanceShape(language), codec); + } + + public static MultibyteCodecObject createMultibyteCodecObject(PythonLanguage language, Object cls, Shape shape, MultibyteCodec codec) { + return create(language, () -> new MultibyteCodecObject(cls, shape, codec)); + } + + public static PAsyncGenASend createAsyncGeneratorASend(PythonLanguage language, PAsyncGen receiver, Object message) { + return create(language, () -> new PAsyncGenASend(language, receiver, message)); + } + + public static PAsyncGenAThrow createAsyncGeneratorAThrow(PythonLanguage language, PAsyncGen receiver, Object arg1, Object arg2, Object arg3) { + return create(language, () -> new PAsyncGenAThrow(language, receiver, arg1, arg2, arg3)); + } + + public static PAsyncGenWrappedValue createAsyncGeneratorWrappedValue(PythonLanguage language, Object wrapped) { + return create(language, () -> new PAsyncGenWrappedValue(language, wrapped)); + } + + // pickle + + public static PPickleBuffer createPickleBuffer(PythonLanguage language, Object view) { + return createPickleBuffer(language, view, PythonBuiltinClassType.PickleBuffer, PythonBuiltinClassType.PickleBuffer.getInstanceShape(language)); + } + + public static PPickleBuffer createPickleBuffer(PythonLanguage language, Object view, Object cls, Shape shape) { + return create(language, () -> new PPickleBuffer(cls, shape, view)); + } + + public static PPickler createPickler(PythonLanguage language) { + return createPickler(language, PythonBuiltinClassType.Pickler, PythonBuiltinClassType.Pickler.getInstanceShape(language)); + } + + public static PPickler createPickler(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PPickler(cls, shape)); + } + + public static PUnpickler createUnpickler(PythonLanguage language) { + return createUnpickler(language, PythonBuiltinClassType.Unpickler, PythonBuiltinClassType.Unpickler.getInstanceShape(language)); + } + + public static PUnpickler createUnpickler(PythonLanguage language, Object cls, Shape shape) { + return create(language, () -> new PUnpickler(cls, shape)); + } + + public static PPicklerMemoProxy createPicklerMemoProxy(PythonLanguage language, PPickler pickler) { + return createPicklerMemoProxy(language, pickler, PythonBuiltinClassType.PicklerMemoProxy, PythonBuiltinClassType.PicklerMemoProxy.getInstanceShape(language)); + } + + public static PPicklerMemoProxy createPicklerMemoProxy(PythonLanguage language, PPickler pickler, Object cls, Shape shape) { + return create(language, () -> new PPicklerMemoProxy(cls, shape, pickler)); + } + + public static PUnpicklerMemoProxy createUnpicklerMemoProxy(PythonLanguage language, PUnpickler unpickler) { + return createUnpicklerMemoProxy(language, unpickler, PythonBuiltinClassType.UnpicklerMemoProxy, PythonBuiltinClassType.UnpicklerMemoProxy.getInstanceShape(language)); + } + + public static PUnpicklerMemoProxy createUnpicklerMemoProxy(PythonLanguage language, PUnpickler unpickler, Object cls, Shape shape) { + return create(language, () -> new PUnpicklerMemoProxy(cls, shape, unpickler)); + } + + public static PStruct createStruct(PythonLanguage language, PStruct.StructInfo structInfo) { + return create(language, () -> new PStruct(PythonBuiltinClassType.PStruct, PythonBuiltinClassType.PStruct.getInstanceShape(language), structInfo)); + } + + public static PStructUnpackIterator createStructUnpackIterator(PythonLanguage language, PStruct struct, Object buffer) { + return create(language, () -> new PStructUnpackIterator(PythonBuiltinClassType.PStructUnpackIterator, PythonBuiltinClassType.PStructUnpackIterator.getInstanceShape(language), struct, buffer)); + } + + public static PTokenizerIter createTokenizerIter(PythonLanguage language, String sourceString) { + return createTokenizerIter(language, PythonBuiltinClassType.PTokenizerIter, PythonBuiltinClassType.PTokenizerIter.getInstanceShape(language), sourceString); + } + + public static PTokenizerIter createTokenizerIter(PythonLanguage language, Object cls, Shape shape, String sourceString) { + return create(language, () -> new PTokenizerIter(cls, shape, sourceString)); + } + + public static Profiler createProfiler(PythonLanguage language, Object cls, Shape shape, CPUSampler sampler) { + return create(language, () -> new Profiler(cls, shape, sampler)); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java deleted file mode 100644 index ade6180bd8..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java +++ /dev/null @@ -1,1739 +0,0 @@ -/* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. - * Copyright (c) 2013, Regents of the University of California - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.graal.python.runtime.object; - -import java.lang.ref.ReferenceQueue; -import java.math.BigInteger; -import java.util.LinkedHashMap; -import java.util.concurrent.Semaphore; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.Python3Core; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.PosixFileHandle; -import com.oracle.graal.python.builtins.modules.bz2.BZ2Object; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteCodec; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteCodecObject; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteIncrementalDecoderObject; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteIncrementalEncoderObject; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteStreamReaderObject; -import com.oracle.graal.python.builtins.modules.cjkcodecs.MultibyteStreamWriterObject; -import com.oracle.graal.python.builtins.modules.codecs.PEncodingMap; -import com.oracle.graal.python.builtins.modules.csv.CSVDialect; -import com.oracle.graal.python.builtins.modules.csv.CSVReader; -import com.oracle.graal.python.builtins.modules.csv.CSVWriter; -import com.oracle.graal.python.builtins.modules.csv.QuoteStyle; -import com.oracle.graal.python.builtins.modules.ctypes.CDataObject; -import com.oracle.graal.python.builtins.modules.ctypes.CFieldObject; -import com.oracle.graal.python.builtins.modules.ctypes.CThunkObject; -import com.oracle.graal.python.builtins.modules.ctypes.PyCArgObject; -import com.oracle.graal.python.builtins.modules.ctypes.PyCFuncPtrObject; -import com.oracle.graal.python.builtins.modules.ctypes.StgDictObject; -import com.oracle.graal.python.builtins.modules.ctypes.StructParamObject; -import com.oracle.graal.python.builtins.modules.ctypes.memory.Pointer; -import com.oracle.graal.python.builtins.modules.functools.LruCacheObject; -import com.oracle.graal.python.builtins.modules.functools.PKeyWrapper; -import com.oracle.graal.python.builtins.modules.functools.PPartial; -import com.oracle.graal.python.builtins.modules.hashlib.DigestObject; -import com.oracle.graal.python.builtins.modules.io.PBuffered; -import com.oracle.graal.python.builtins.modules.io.PBytesIO; -import com.oracle.graal.python.builtins.modules.io.PBytesIOBuffer; -import com.oracle.graal.python.builtins.modules.io.PFileIO; -import com.oracle.graal.python.builtins.modules.io.PNLDecoder; -import com.oracle.graal.python.builtins.modules.io.PRWPair; -import com.oracle.graal.python.builtins.modules.io.PStringIO; -import com.oracle.graal.python.builtins.modules.io.PTextIO; -import com.oracle.graal.python.builtins.modules.json.PJSONEncoder; -import com.oracle.graal.python.builtins.modules.json.PJSONEncoder.FastEncode; -import com.oracle.graal.python.builtins.modules.json.PJSONScanner; -import com.oracle.graal.python.builtins.modules.lzma.LZMAObject; -import com.oracle.graal.python.builtins.modules.multiprocessing.PGraalPySemLock; -import com.oracle.graal.python.builtins.modules.multiprocessing.PSemLock; -import com.oracle.graal.python.builtins.modules.pickle.PPickleBuffer; -import com.oracle.graal.python.builtins.modules.pickle.PPickler; -import com.oracle.graal.python.builtins.modules.pickle.PPicklerMemoProxy; -import com.oracle.graal.python.builtins.modules.pickle.PUnpickler; -import com.oracle.graal.python.builtins.modules.pickle.PUnpicklerMemoProxy; -import com.oracle.graal.python.builtins.modules.zlib.ZLibCompObject; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.array.PArray; -import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGen; -import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenASend; -import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenAThrow; -import com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenWrappedValue; -import com.oracle.graal.python.builtins.objects.asyncio.PCoroutineWrapper; -import com.oracle.graal.python.builtins.objects.bytes.PByteArray; -import com.oracle.graal.python.builtins.objects.bytes.PBytes; -import com.oracle.graal.python.builtins.objects.capsule.PyCapsule; -import com.oracle.graal.python.builtins.objects.cell.PCell; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeVoidPtr; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers; -import com.oracle.graal.python.builtins.objects.cext.hpy.PythonHPyObject; -import com.oracle.graal.python.builtins.objects.code.PCode; -import com.oracle.graal.python.builtins.objects.common.DynamicObjectStorage; -import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; -import com.oracle.graal.python.builtins.objects.common.ForeignHashingStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes; -import com.oracle.graal.python.builtins.objects.common.PHashingCollection; -import com.oracle.graal.python.builtins.objects.complex.PComplex; -import com.oracle.graal.python.builtins.objects.contextvars.PContextIterator; -import com.oracle.graal.python.builtins.objects.contextvars.PContextVar; -import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext; -import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsToken; -import com.oracle.graal.python.builtins.objects.deque.PDeque; -import com.oracle.graal.python.builtins.objects.deque.PDequeIter; -import com.oracle.graal.python.builtins.objects.dict.PDefaultDict; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.dict.PDictView; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemIterator; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemsView; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeyIterator; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeysView; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValueIterator; -import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValuesView; -import com.oracle.graal.python.builtins.objects.enumerate.PEnumerate; -import com.oracle.graal.python.builtins.objects.exception.PBaseException; -import com.oracle.graal.python.builtins.objects.exception.PBaseExceptionGroup; -import com.oracle.graal.python.builtins.objects.floats.PFloat; -import com.oracle.graal.python.builtins.objects.frame.PFrame; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.builtins.objects.generator.PGenerator; -import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptor; -import com.oracle.graal.python.builtins.objects.getsetdescriptor.IndexedSlotDescriptor; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.iterator.PArrayIterator; -import com.oracle.graal.python.builtins.objects.iterator.PBaseSetIterator; -import com.oracle.graal.python.builtins.objects.iterator.PBigRangeIterator; -import com.oracle.graal.python.builtins.objects.iterator.PDoubleSequenceIterator; -import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator; -import com.oracle.graal.python.builtins.objects.iterator.PIntegerSequenceIterator; -import com.oracle.graal.python.builtins.objects.iterator.PLongSequenceIterator; -import com.oracle.graal.python.builtins.objects.iterator.PObjectSequenceIterator; -import com.oracle.graal.python.builtins.objects.iterator.PSentinelIterator; -import com.oracle.graal.python.builtins.objects.iterator.PSequenceIterator; -import com.oracle.graal.python.builtins.objects.iterator.PStringIterator; -import com.oracle.graal.python.builtins.objects.iterator.PStructUnpackIterator; -import com.oracle.graal.python.builtins.objects.iterator.PZip; -import com.oracle.graal.python.builtins.objects.itertools.PAccumulate; -import com.oracle.graal.python.builtins.objects.itertools.PChain; -import com.oracle.graal.python.builtins.objects.itertools.PCombinations; -import com.oracle.graal.python.builtins.objects.itertools.PCombinationsWithReplacement; -import com.oracle.graal.python.builtins.objects.itertools.PCompress; -import com.oracle.graal.python.builtins.objects.itertools.PCount; -import com.oracle.graal.python.builtins.objects.itertools.PCycle; -import com.oracle.graal.python.builtins.objects.itertools.PDropwhile; -import com.oracle.graal.python.builtins.objects.itertools.PFilterfalse; -import com.oracle.graal.python.builtins.objects.itertools.PGroupBy; -import com.oracle.graal.python.builtins.objects.itertools.PGrouper; -import com.oracle.graal.python.builtins.objects.itertools.PIslice; -import com.oracle.graal.python.builtins.objects.itertools.PPairwise; -import com.oracle.graal.python.builtins.objects.itertools.PPermutations; -import com.oracle.graal.python.builtins.objects.itertools.PProduct; -import com.oracle.graal.python.builtins.objects.itertools.PRepeat; -import com.oracle.graal.python.builtins.objects.itertools.PStarmap; -import com.oracle.graal.python.builtins.objects.itertools.PTakewhile; -import com.oracle.graal.python.builtins.objects.itertools.PTee; -import com.oracle.graal.python.builtins.objects.itertools.PTeeDataObject; -import com.oracle.graal.python.builtins.objects.itertools.PZipLongest; -import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.list.PList.ListOrigin; -import com.oracle.graal.python.builtins.objects.map.PMap; -import com.oracle.graal.python.builtins.objects.mappingproxy.PMappingproxy; -import com.oracle.graal.python.builtins.objects.memoryview.BufferLifecycleManager; -import com.oracle.graal.python.builtins.objects.memoryview.PMemoryView; -import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; -import com.oracle.graal.python.builtins.objects.method.PDecoratedMethod; -import com.oracle.graal.python.builtins.objects.method.PMethod; -import com.oracle.graal.python.builtins.objects.mmap.PMMap; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.namespace.PSimpleNamespace; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.ordereddict.POrderedDict; -import com.oracle.graal.python.builtins.objects.ordereddict.POrderedDictIterator; -import com.oracle.graal.python.builtins.objects.posix.PDirEntry; -import com.oracle.graal.python.builtins.objects.posix.PScandirIterator; -import com.oracle.graal.python.builtins.objects.property.PProperty; -import com.oracle.graal.python.builtins.objects.queue.PSimpleQueue; -import com.oracle.graal.python.builtins.objects.random.PRandom; -import com.oracle.graal.python.builtins.objects.range.PBigRange; -import com.oracle.graal.python.builtins.objects.range.PIntRange; -import com.oracle.graal.python.builtins.objects.referencetype.PReferenceType; -import com.oracle.graal.python.builtins.objects.reversed.PSequenceReverseIterator; -import com.oracle.graal.python.builtins.objects.reversed.PStringReverseIterator; -import com.oracle.graal.python.builtins.objects.set.PBaseSet; -import com.oracle.graal.python.builtins.objects.set.PFrozenSet; -import com.oracle.graal.python.builtins.objects.set.PSet; -import com.oracle.graal.python.builtins.objects.slice.PIntSlice; -import com.oracle.graal.python.builtins.objects.slice.PObjectSlice; -import com.oracle.graal.python.builtins.objects.socket.PSocket; -import com.oracle.graal.python.builtins.objects.ssl.PMemoryBIO; -import com.oracle.graal.python.builtins.objects.ssl.PSSLContext; -import com.oracle.graal.python.builtins.objects.ssl.PSSLSocket; -import com.oracle.graal.python.builtins.objects.ssl.SSLMethod; -import com.oracle.graal.python.builtins.objects.str.NativeCharSequence; -import com.oracle.graal.python.builtins.objects.str.PString; -import com.oracle.graal.python.builtins.objects.struct.FormatAlignment; -import com.oracle.graal.python.builtins.objects.struct.FormatCode; -import com.oracle.graal.python.builtins.objects.struct.PStruct; -import com.oracle.graal.python.builtins.objects.superobject.SuperObject; -import com.oracle.graal.python.builtins.objects.thread.PLock; -import com.oracle.graal.python.builtins.objects.thread.PRLock; -import com.oracle.graal.python.builtins.objects.thread.PThread; -import com.oracle.graal.python.builtins.objects.thread.PThreadLocal; -import com.oracle.graal.python.builtins.objects.tokenize.PTokenizerIter; -import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback; -import com.oracle.graal.python.builtins.objects.traceback.PTraceback; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.tuple.PTupleGetter; -import com.oracle.graal.python.builtins.objects.tuple.StructSequence.BuiltinTypeDescriptor; -import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.builtins.objects.type.TpSlots; -import com.oracle.graal.python.builtins.objects.type.TypeNodes; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroStorageNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; -import com.oracle.graal.python.builtins.objects.types.PGenericAlias; -import com.oracle.graal.python.builtins.objects.types.PGenericAliasIterator; -import com.oracle.graal.python.builtins.objects.types.PUnionType; -import com.oracle.graal.python.compiler.CodeUnit; -import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; -import com.oracle.graal.python.runtime.NFIZlibSupport; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.object.PythonObjectFactoryNodeGen.LazyNodeGen; -import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.MroSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.SequenceStorageFactory; -import com.oracle.graal.python.util.BufferFormat; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.Assumption; -import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.MaterializedFrame; -import com.oracle.truffle.api.instrumentation.AllocationReporter; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.object.Shape; -import com.oracle.truffle.api.strings.TruffleString; - -/** - * Factory for Python objects that also reports to Truffle's {@link AllocationReporter}. The - * reporting needs current context. There are several implementations of this abstract class. Use - * this rule of thumb when choosing which one to use: - *
    - *
  • In partially evaluated code: use adopted (@Child/@Cached) {@link PythonObjectFactory} node - *
  • - *
  • Behind {@code TruffleBoundary}: - *
      - *
    • When the current context is already available, use {@link Python3Core#factory()}. This avoids - * repeated context lookups inside the factory.
    • - *
    • When the current context is not available, but multiple objects will be created: lookup the - * context and use {@link Python3Core#factory()}. This executes only one context lookup. Note: first - * check if the caller could pass the context to avoid looking it up behind {@code TruffleBoundary}. - *
    • - *
    • When the current context is not available, and only one object is to be created: use - * {@link PythonObjectFactory#getUncached()}.
    • - *
    - *
  • - *
- */ -@GenerateUncached -@ImportStatic(PythonOptions.class) -@GenerateInline(false) // Footprint reduction 28 -> 9 -public abstract class PythonObjectFactory extends Node { - // Note: we're keeping this not inlined for now because: - // - overwhelming number of usages of non-execute entry points to refactor - // - often used lazily and as a @Child, most notably in all the builtins - - @NeverDefault - public static PythonObjectFactory create() { - return PythonObjectFactoryNodeGen.create(); - } - - public static PythonObjectFactory getUncached() { - return PythonObjectFactoryNodeGen.getUncached(); - } - - protected abstract AllocationReporter executeTrace(Object o, long size); - - protected abstract Shape executeGetShape(Object o, boolean flag); - - @Specialization - static Shape getShape(Object o, @SuppressWarnings("unused") boolean flag, - @Cached TypeNodes.GetInstanceShape getShapeNode) { - return getShapeNode.execute(o); - } - - @Specialization - static AllocationReporter doTrace(Object o, long size, - @Cached(value = "getAllocationReporter()", allowUncached = true) AllocationReporter reporter) { - if (reporter.isActive()) { - doTraceImpl(o, size, reporter); - } - return null; - } - - @InliningCutoff - private static void doTraceImpl(Object o, long size, AllocationReporter reporter) { - reporter.onEnter(null, 0, size); - reporter.onReturnValue(o, 0, size); - } - - @NeverDefault - protected AllocationReporter getAllocationReporter() { - return PythonContext.get(this).getAllocationReporter(); - } - - public PythonLanguage getLanguage() { - return PythonLanguage.get(this); - } - - public final Shape getShape(PythonBuiltinClassType cls) { - return cls.getInstanceShape(getLanguage()); - } - - public final Shape getShape(Object cls) { - return executeGetShape(cls, true); - } - - public final T trace(T allocatedObject) { - executeTrace(allocatedObject, AllocationReporter.SIZE_UNKNOWN); - return allocatedObject; - } - - /* - * Python objects - */ - - /** - * Creates a PythonObject for the given class. This is potentially slightly slower than if the - * shape had been cached, due to the additional shape lookup. - */ - public final PythonObject createPythonObject(Object cls) { - return createPythonObject(cls, getShape(cls)); - } - - /** - * Creates a PythonObject for the given class. This is potentially slightly slower than if the - * shape had been cached, due to the additional shape lookup. - */ - public final PythonObject createPythonHPyObject(Object cls, Object hpyNativeSpace) { - return trace(new PythonHPyObject(cls, getShape(cls), hpyNativeSpace)); - } - - /** - * Creates a Python object with the given shape. Python object shapes store the class in the - * shape if possible. - */ - public final PythonObject createPythonObject(Object klass, Shape instanceShape) { - return trace(new PythonObject(klass, instanceShape)); - } - - public final PythonNativeVoidPtr createNativeVoidPtr(Object obj) { - return trace(new PythonNativeVoidPtr(obj)); - } - - public final PythonNativeVoidPtr createNativeVoidPtr(Object obj, long nativePtr) { - return trace(new PythonNativeVoidPtr(obj, nativePtr)); - } - - public final SuperObject createSuperObject(Object self) { - return trace(new SuperObject(self, getShape(self))); - } - - /* - * Primitive types - */ - public final PInt createInt(int value) { - Shape shape = getLanguage().getBuiltinTypeInstanceShape(PythonBuiltinClassType.PInt); - return trace(new PInt(PythonBuiltinClassType.PInt, shape, PInt.longToBigInteger(value))); - } - - public final PInt createInt(long value) { - Shape shape = getLanguage().getBuiltinTypeInstanceShape(PythonBuiltinClassType.PInt); - return trace(new PInt(PythonBuiltinClassType.PInt, shape, PInt.longToBigInteger(value))); - } - - public final PInt createInt(BigInteger value) { - Shape shape = getLanguage().getBuiltinTypeInstanceShape(PythonBuiltinClassType.PInt); - return trace(new PInt(PythonBuiltinClassType.PInt, shape, value)); - } - - public final Object createInt(Object cls, int value) { - return createInt(cls, PInt.longToBigInteger(value)); - } - - public final Object createInt(Object cls, long value) { - return createInt(cls, PInt.longToBigInteger(value)); - } - - public final PInt createInt(Object cls, BigInteger value) { - return trace(new PInt(cls, getShape(cls), value)); - } - - public final PFloat createFloat(double value) { - Shape shape = getLanguage().getBuiltinTypeInstanceShape(PythonBuiltinClassType.PFloat); - return trace(new PFloat(PythonBuiltinClassType.PFloat, shape, value)); - } - - public final PFloat createFloat(Object cls, double value) { - return trace(new PFloat(cls, getShape(cls), value)); - } - - public final PString createString(TruffleString string) { - Shape shape = getLanguage().getBuiltinTypeInstanceShape(PythonBuiltinClassType.PString); - return trace(new PString(PythonBuiltinClassType.PString, shape, string)); - } - - public final PString createString(Object cls, TruffleString string) { - return trace(new PString(cls, getShape(cls), string)); - } - - public final PString createString(NativeCharSequence string) { - return createString(PythonBuiltinClassType.PString, string); - } - - public final PString createString(Object cls, NativeCharSequence string) { - return trace(new PString(cls, getShape(cls), string)); - } - - public final PBytes createEmptyBytes() { - if (CompilerDirectives.inInterpreter()) { - return createBytes(PythonUtils.EMPTY_BYTE_ARRAY); - } else { - return createBytes(new byte[0]); - } - } - - public final PBytes createBytes(byte[] array) { - return createBytes(array, array.length); - } - - public final PBytes createBytes(byte[] array, int offset, int length) { - if (length != array.length) { - byte[] buf = new byte[length]; - PythonUtils.arraycopy(array, offset, buf, 0, buf.length); - return createBytes(buf, length); - } - return createBytes(array, length); - } - - public final PBytes createBytes(Object cls, byte[] array) { - return createBytes(cls, array, array.length); - } - - public final PBytes createBytes(byte[] array, int length) { - return createBytes(new ByteSequenceStorage(array, length)); - } - - public final PBytes createBytes(Object cls, byte[] array, int length) { - return createBytes(cls, new ByteSequenceStorage(array, length)); - } - - public final PBytes createBytes(SequenceStorage storage) { - return trace(new PBytes(PythonBuiltinClassType.PBytes, getShape(PythonBuiltinClassType.PBytes), storage)); - } - - public final PBytes createBytes(Object cls, SequenceStorage storage) { - return trace(new PBytes(cls, getShape(cls), storage)); - } - - public final PTuple createEmptyTuple() { - return createTuple(PythonUtils.EMPTY_OBJECT_ARRAY); - } - - public final PTuple createEmptyTuple(Object cls) { - return createTuple(cls, EmptySequenceStorage.INSTANCE); - } - - public final PTuple createTuple(Object[] objects) { - Shape shape = PythonBuiltinClassType.PTuple.getInstanceShape(getLanguage()); - return trace(new PTuple(PythonBuiltinClassType.PTuple, shape, objects)); - } - - public final PTuple createTuple(int[] ints) { - return createTuple(new IntSequenceStorage(ints)); - } - - public final PTuple createTuple(SequenceStorage store) { - Shape shape = PythonBuiltinClassType.PTuple.getInstanceShape(getLanguage()); - return trace(new PTuple(PythonBuiltinClassType.PTuple, shape, store)); - } - - public final PTuple createTuple(Object cls, Shape instanceShape, Object[] objects) { - return trace(new PTuple(cls, instanceShape, objects)); - } - - public final PTuple createTuple(Object cls, Object[] objects) { - return trace(new PTuple(cls, getShape(cls), objects)); - } - - public final PTuple createTuple(Object cls, SequenceStorage store) { - return trace(new PTuple(cls, getShape(cls), store)); - } - - public final PTuple createStructSeq(BuiltinTypeDescriptor desc, Object... values) { - assert desc.inSequence <= values.length && values.length <= desc.fieldNames.length; - return createTuple(desc.type, new ObjectSequenceStorage(values, desc.inSequence)); - } - - public final PTupleGetter createTupleGetter(int index, Object doc) { - return createTupleGetter(PythonBuiltinClassType.PTupleGetter, index, doc); - } - - public final PTupleGetter createTupleGetter(Object cls, int index, Object doc) { - return trace(new PTupleGetter(cls, getShape(cls), index, doc)); - } - - public final PComplex createComplex(Object cls, double real, double imag) { - return trace(new PComplex(cls, getShape(cls), real, imag)); - } - - public final PComplex createComplex(double real, double imag) { - return createComplex(PythonBuiltinClassType.PComplex, real, imag); - } - - public final PIntRange createIntRange(int stop) { - return trace(new PIntRange(getLanguage(), 0, stop, 1, stop)); - } - - public final PIntRange createIntRange(int start, int stop, int step, int len) { - return trace(new PIntRange(getLanguage(), start, stop, step, len)); - } - - public final PBigRange createBigRange(BigInteger start, BigInteger stop, BigInteger step, BigInteger len) { - return createBigRange(createInt(start), createInt(stop), createInt(step), createInt(len)); - } - - public final PBigRange createBigRange(PInt start, PInt stop, PInt step, PInt len) { - return trace(new PBigRange(getLanguage(), start, stop, step, len)); - } - - public final PIntSlice createIntSlice(int start, int stop, int step) { - return trace(new PIntSlice(getLanguage(), start, stop, step)); - } - - public final PIntSlice createIntSlice(int start, int stop, int step, boolean isStartNone, boolean isStepNone) { - return trace(new PIntSlice(getLanguage(), start, stop, step, isStartNone, isStepNone)); - } - - public final PObjectSlice createObjectSlice(Object start, Object stop, Object step) { - return trace(new PObjectSlice(getLanguage(), start, stop, step)); - } - - public final PRandom createRandom(Object cls) { - return trace(new PRandom(cls, getShape(cls))); - } - - /* - * Classes, methods and functions - */ - - /** - * Only to be used during context creation - */ - public final PythonModule createPythonModule(TruffleString name) { - return trace(PythonModule.createInternal(name)); - } - - public final PythonModule createPythonModule(Object cls) { - return trace(new PythonModule(cls, getShape(cls))); - } - - public final PythonClass createPythonClassAndFixupSlots(PythonLanguage language, Object metaclass, TruffleString name, Object base, PythonAbstractClass[] bases) { - PythonClass result = trace(new PythonClass(language, metaclass, getShape(metaclass), name, base, bases)); - // Fixup tp slots - MroSequenceStorage mro = GetMroStorageNode.executeUncached(result); - SpecialMethodSlot.initializeSpecialMethodSlots(result, mro, language); - TpSlots.inherit(result, mro, true); - TpSlots.fixupSlotDispatchers(result); - result.initializeMroShape(language); - return result; - } - - public final PythonClass createPythonClass(Object metaclass, TruffleString name, boolean invokeMro, Object base, PythonAbstractClass[] bases) { - // Note: called from type ctor, which itself will invoke setupSpecialMethodSlots at the - // right point - return trace(new PythonClass(getLanguage(), metaclass, getShape(metaclass), name, invokeMro, base, bases)); - } - - public final PMemoryView createMemoryView(PythonContext context, BufferLifecycleManager bufferLifecycleManager, Object buffer, Object owner, - int len, boolean readonly, int itemsize, BufferFormat format, TruffleString formatString, int ndim, Object bufPointer, - int offset, int[] shape, int[] strides, int[] suboffsets, int flags) { - PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; - return trace(new PMemoryView(cls, getShape(cls), context, bufferLifecycleManager, buffer, owner, len, readonly, itemsize, format, formatString, - ndim, bufPointer, offset, shape, strides, suboffsets, flags)); - } - - private final PMemoryView createMemoryView(PythonContext context, BufferLifecycleManager bufferLifecycleManager, Object buffer, Object owner, - int len, boolean readonly, int itemsize, TruffleString formatString, int ndim, Object bufPointer, - int offset, int[] shape, int[] strides, int[] suboffsets, int flags, TruffleString.CodePointLengthNode lengthNode, TruffleString.CodePointAtIndexNode atIndexNode) { - PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; - return trace(new PMemoryView(cls, getShape(cls), context, bufferLifecycleManager, buffer, owner, len, readonly, itemsize, - BufferFormat.forMemoryView(formatString, lengthNode, atIndexNode), formatString, ndim, bufPointer, offset, shape, strides, suboffsets, flags)); - } - - public final PMemoryView createMemoryViewForManagedObject(Object buffer, Object owner, int itemsize, int length, boolean readonly, TruffleString format, - TruffleString.CodePointLengthNode lengthNode, TruffleString.CodePointAtIndexNode atIndexNode) { - return createMemoryView(null, null, buffer, owner, length, readonly, itemsize, format, 1, - null, 0, new int[]{length / itemsize}, new int[]{itemsize}, null, - PMemoryView.FLAG_C | PMemoryView.FLAG_FORTRAN, lengthNode, atIndexNode); - } - - public final PMemoryView createMemoryViewForManagedObject(Object owner, int itemsize, int length, boolean readonly, TruffleString format, TruffleString.CodePointLengthNode lengthNode, - TruffleString.CodePointAtIndexNode atIndexNode) { - return createMemoryViewForManagedObject(owner, owner, itemsize, length, readonly, format, lengthNode, atIndexNode); - } - - public final PMethod createMethod(Object cls, Object self, Object function) { - return trace(new PMethod(cls, getShape(cls), self, function)); - } - - public final PMethod createMethod(Object self, Object function) { - return createMethod(PythonBuiltinClassType.PMethod, self, function); - } - - public final PMethod createBuiltinMethod(Object self, PFunction function) { - return createMethod(PythonBuiltinClassType.PBuiltinFunctionOrMethod, self, function); - } - - public final PBuiltinMethod createBuiltinMethod(Object cls, Object self, PBuiltinFunction function) { - return trace(new PBuiltinMethod(cls, getShape(cls), self, function, null)); - } - - public final PBuiltinMethod createBuiltinMethod(Object self, PBuiltinFunction function, Object classObject) { - return trace(new PBuiltinMethod(PythonBuiltinClassType.PBuiltinMethod, getShape(PythonBuiltinClassType.PBuiltinMethod), self, function, classObject)); - } - - public final PBuiltinMethod createBuiltinMethod(Object self, PBuiltinFunction function) { - return createBuiltinMethod(PythonBuiltinClassType.PBuiltinFunctionOrMethod, self, function); - } - - public final PFunction createFunction(TruffleString name, PCode code, PythonObject globals, PCell[] closure) { - return trace(new PFunction(getLanguage(), name, name, code, globals, closure)); - } - - public final PFunction createFunction(TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure) { - return trace(new PFunction(getLanguage(), name, qualname, code, globals, defaultValues, kwDefaultValues, closure)); - } - - public final PFunction createFunction(TruffleString name, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure) { - return trace(new PFunction(getLanguage(), name, name, code, globals, defaultValues, kwDefaultValues, closure)); - } - - public final PFunction createFunction(TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure, - Assumption codeStableAssumption, Assumption defaultsStableAssumption) { - return trace(new PFunction(getLanguage(), name, qualname, code, globals, defaultValues, kwDefaultValues, closure, - codeStableAssumption, defaultsStableAssumption)); - } - - public final PBuiltinFunction createBuiltinFunction(TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget) { - return trace(new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(getLanguage()), name, type, - PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget)); - } - - public final PBuiltinFunction createBuiltinFunction(TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget) { - return trace(new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(getLanguage()), name, type, defaults, kw, flags, - callTarget)); - } - - public final PBuiltinFunction createWrapperDescriptor(TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget, TpSlot slot, PExternalFunctionWrapper slotWrapper) { - return trace(new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(getLanguage()), name, type, - PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget, slot, slotWrapper)); - } - - public final PBuiltinFunction createWrapperDescriptor(TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget, TpSlot slot, - PExternalFunctionWrapper slotWrapper) { - return trace(new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(getLanguage()), name, type, defaults, kw, flags, - callTarget, slot, slotWrapper)); - } - - public final PBuiltinFunction createBuiltinFunction(PBuiltinFunction function, Object klass) { - PythonBuiltinClassType type = (PythonBuiltinClassType) function.getInitialPythonClass(); - return trace(new PBuiltinFunction(type, type.getInstanceShape(getLanguage()), function.getName(), klass, - function.getDefaults(), function.getKwDefaults(), function.getFlags(), function.getCallTarget(), - function.getSlot(), function.getSlotWrapper())); - } - - public final GetSetDescriptor createGetSetDescriptor(Object get, Object set, TruffleString name, Object type) { - return trace(new GetSetDescriptor(getLanguage(), get, set, name, type)); - } - - public final GetSetDescriptor createGetSetDescriptor(Object get, Object set, TruffleString name, Object type, boolean allowsDelete) { - return trace(new GetSetDescriptor(getLanguage(), get, set, name, type, allowsDelete)); - } - - public final GetSetDescriptor createMemberDescriptor(Object get, Object set, TruffleString name, Object type) { - return trace(new GetSetDescriptor(PythonBuiltinClassType.MemberDescriptor, PythonBuiltinClassType.MemberDescriptor.getInstanceShape(getLanguage()), get, set, name, type, set != null)); - } - - public final IndexedSlotDescriptor createIndexedSlotDescriptor(TruffleString name, int index, Object type) { - return trace(new IndexedSlotDescriptor(getLanguage(), name, index, type)); - } - - public final PDecoratedMethod createClassmethod(Object cls) { - return trace(new PDecoratedMethod(cls, getShape(cls))); - } - - public final PDecoratedMethod createClassmethodFromCallableObj(Object callable) { - return trace(new PDecoratedMethod(PythonBuiltinClassType.PClassmethod, PythonBuiltinClassType.PClassmethod.getInstanceShape(getLanguage()), callable)); - } - - public final PDecoratedMethod createBuiltinClassmethodFromCallableObj(Object callable) { - return trace(new PDecoratedMethod(PythonBuiltinClassType.PBuiltinClassMethod, PythonBuiltinClassType.PBuiltinClassMethod.getInstanceShape(getLanguage()), callable)); - } - - public final PDecoratedMethod createInstancemethod(Object cls) { - return trace(new PDecoratedMethod(cls, getShape(cls))); - } - - public final PDecoratedMethod createStaticmethod(Object cls) { - return trace(new PDecoratedMethod(cls, getShape(cls))); - } - - public final PDecoratedMethod createStaticmethodFromCallableObj(Object callable) { - Object func = callable; - if (func instanceof PBuiltinFunction) { - /* - * CPython's C static methods contain an object of type `builtin_function_or_method` - * (our PBuiltinMethod). Their self points to their type, but when called they get NULL - * as the first argument instead. - */ - func = createBuiltinMethod(((PBuiltinFunction) func).getEnclosingType(), (PBuiltinFunction) func); - } - return trace(new PDecoratedMethod(PythonBuiltinClassType.PStaticmethod, PythonBuiltinClassType.PStaticmethod.getInstanceShape(getLanguage()), func)); - } - - /* - * Lists, sets and dicts - */ - - public final PList createList() { - return createList(PythonUtils.EMPTY_OBJECT_ARRAY); - } - - public final PList createList(SequenceStorage storage) { - return createList(PythonBuiltinClassType.PList, storage); - } - - public final PList createList(Object cls, Shape instanceShape, SequenceStorage storage) { - return trace(new PList(cls, instanceShape, storage)); - } - - public final PList createList(SequenceStorage storage, ListOrigin origin) { - return trace(new PList(PythonBuiltinClassType.PList, PythonBuiltinClassType.PList.getInstanceShape(getLanguage()), storage, origin)); - } - - public final PList createList(Object cls, SequenceStorage storage) { - return trace(new PList(cls, getShape(cls), storage)); - } - - public final PList createList(Object cls) { - return createList(cls, PythonUtils.EMPTY_OBJECT_ARRAY); - } - - public final PList createList(Object[] array) { - return createList(PythonBuiltinClassType.PList, array); - } - - public final PList createList(Object cls, Object[] array) { - return trace(new PList(cls, getShape(cls), SequenceStorageFactory.createStorage(array))); - } - - public final PSet createSet() { - Shape shape = PythonBuiltinClassType.PSet.getInstanceShape(getLanguage()); - return trace(new PSet(PythonBuiltinClassType.PSet, shape)); - } - - public final PSet createSet(Object cls) { - return trace(new PSet(cls, getShape(cls))); - } - - public final PSet createSet(Object cls, Shape instanceShape) { - return trace(new PSet(cls, instanceShape)); - } - - public final PSet createSet(HashingStorage storage) { - Shape shape = PythonBuiltinClassType.PSet.getInstanceShape(getLanguage()); - return trace(new PSet(PythonBuiltinClassType.PSet, shape, storage)); - } - - public final PFrozenSet createFrozenSet(Object cls) { - return trace(new PFrozenSet(cls, getShape(cls))); - } - - public final PFrozenSet createFrozenSet(Object cls, HashingStorage storage) { - return trace(new PFrozenSet(cls, getShape(cls), storage)); - } - - public final PFrozenSet createFrozenSet(HashingStorage storage) { - Shape shape = PythonBuiltinClassType.PFrozenSet.getInstanceShape(getLanguage()); - return trace(new PFrozenSet(PythonBuiltinClassType.PFrozenSet, shape, storage)); - } - - public final PDict createDict() { - Shape shape = PythonBuiltinClassType.PDict.getInstanceShape(getLanguage()); - return trace(new PDict(PythonBuiltinClassType.PDict, shape)); - } - - public final PDict createDict(PKeyword[] keywords) { - Shape shape = PythonBuiltinClassType.PDict.getInstanceShape(getLanguage()); - return trace(new PDict(PythonBuiltinClassType.PDict, shape, keywords)); - } - - public final PDict createDict(Object cls) { - return trace(new PDict(cls, getShape(cls))); - } - - public final POrderedDict createOrderedDict(Object cls) { - return trace(new POrderedDict(cls, getShape(cls))); - } - - public final PDictKeysView createOrderedDictKeys(POrderedDict dict) { - PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictKeys; - return trace(new PDictKeysView(cls, cls.getInstanceShape(getLanguage()), dict)); - } - - public final PDictValuesView createOrderedDictValues(POrderedDict dict) { - PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictValues; - return trace(new PDictValuesView(cls, cls.getInstanceShape(getLanguage()), dict)); - } - - public final PDictItemsView createOrderedDictItems(POrderedDict dict) { - PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictItems; - return trace(new PDictItemsView(cls, cls.getInstanceShape(getLanguage()), dict)); - } - - public POrderedDictIterator createOrderedDictIterator(POrderedDict dict, POrderedDictIterator.IteratorType type, boolean reversed) { - PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictIterator; - return trace(new POrderedDictIterator(cls, cls.getInstanceShape(getLanguage()), dict, type, reversed)); - } - - @SuppressWarnings("unchecked") - public final PDict createDictFromMap(LinkedHashMap map) { - return createDict(EconomicMapStorage.create(map)); - } - - /** - * Generic version of {@link #createDictFromMap(LinkedHashMap)} that allows any type of keys. - * Note that this means that unless the keys are known to be side effect free, e.g., builtin - * types, this may end up calling Python code, so indirect call context should be properly - * set-up. This helper is meant for Truffle boundary code, in PE code build a storage by setting - * elements one by one starting from empty storage. - */ - @SuppressWarnings("unchecked") - public final PDict createDictFromMapGeneric(LinkedHashMap map) { - return createDict(EconomicMapStorage.createGeneric(map)); - } - - public final PDict createDictFixedStorage(PythonObject pythonObject, MroSequenceStorage mroSequenceStorage) { - return createDict(new DynamicObjectStorage(pythonObject, mroSequenceStorage)); - } - - public final PDict createDictFixedStorage(PythonObject pythonObject) { - return createDict(new DynamicObjectStorage(pythonObject)); - } - - public final PDict createDict(Object cls, HashingStorage storage) { - return trace(new PDict(cls, getShape(cls), storage)); - } - - public final PDict createDict(HashingStorage storage) { - return createDict(PythonBuiltinClassType.PDict, storage); - } - - public final PDict createDict(Object cls, Shape instanceShape, HashingStorage storage) { - return trace(new PDict(cls, instanceShape, storage)); - } - - public final PSimpleNamespace createSimpleNamespace() { - return createSimpleNamespace(PythonBuiltinClassType.PSimpleNamespace); - } - - public final PSimpleNamespace createSimpleNamespace(Object cls) { - return createSimpleNamespace(cls, getShape(cls)); - } - - public final PSimpleNamespace createSimpleNamespace(Object cls, Shape instanceShape) { - return trace(new PSimpleNamespace(cls, instanceShape)); - } - - public final PKeyWrapper createKeyWrapper(Object cmp) { - return trace(new PKeyWrapper(PythonBuiltinClassType.PKeyWrapper, getShape(PythonBuiltinClassType.PKeyWrapper), cmp)); - } - - public final PPartial createPartial(Object cls, Object function, Object[] args, PDict kwDict) { - return trace(new PPartial(cls, getShape(cls), function, args, kwDict)); - } - - public LruCacheObject createLruCacheObject(Object cls) { - return trace(new LruCacheObject(cls, getShape(cls))); - } - - public final PDefaultDict createDefaultDict(Object cls) { - return createDefaultDict(cls, PNone.NONE); - } - - public final PDefaultDict createDefaultDict(Object cls, Object defaultFactory) { - return trace(new PDefaultDict(cls, getShape(cls), defaultFactory)); - } - - public final PDefaultDict createDefaultDict(Object defaultFactory, HashingStorage storage) { - return createDefaultDict(PythonBuiltinClassType.PDefaultDict, defaultFactory, storage); - } - - public final PDefaultDict createDefaultDict(Object cls, Object defaultFactory, HashingStorage storage) { - return trace(new PDefaultDict(cls, getShape(cls), storage, defaultFactory)); - } - - public final PDictView createDictKeysView(PHashingCollection dict) { - return trace(new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(getLanguage()), dict)); - } - - public final PDictView createDictKeysView(Object dict, ForeignHashingStorage foreignHashingStorage) { - return trace(new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(getLanguage()), dict, foreignHashingStorage)); - } - - public final PDictView createDictValuesView(PHashingCollection dict) { - return trace(new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(getLanguage()), dict)); - } - - public final PDictView createDictValuesView(Object dict, ForeignHashingStorage foreignHashingStorage) { - return trace(new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(getLanguage()), dict, foreignHashingStorage)); - } - - public final PDictView createDictItemsView(PHashingCollection dict) { - return trace(new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(getLanguage()), dict)); - } - - public final PDictView createDictItemsView(Object dict, ForeignHashingStorage foreignHashingStorage) { - return trace(new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(getLanguage()), dict, foreignHashingStorage)); - } - - /* - * Special objects: generators, proxies, references, cells - */ - - public final PGenerator createGenerator(TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return trace(PGenerator.create(getLanguage(), name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator)); - } - - public final PGenerator createIterableCoroutine(TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return trace(PGenerator.create(getLanguage(), name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator, true)); - } - - public final PGenerator createCoroutine(TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return trace(PGenerator.create(getLanguage(), name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PCoroutine)); - } - - public final PCoroutineWrapper createCoroutineWrapper(PGenerator generator) { - return trace(new PCoroutineWrapper(getLanguage(), generator)); - } - - public final PAsyncGen createAsyncGenerator(TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return trace(PAsyncGen.create(getLanguage(), name, qualname, rootNode, callTargets, arguments)); - } - - public final PMappingproxy createMappingproxy(Object object) { - PythonBuiltinClassType mpClass = PythonBuiltinClassType.PMappingproxy; - return trace(new PMappingproxy(mpClass, mpClass.getInstanceShape(getLanguage()), object)); - } - - public final PMappingproxy createMappingproxy(Object cls, Object object) { - return trace(new PMappingproxy(cls, getShape(cls), object)); - } - - public final PReferenceType createReferenceType(Object cls, Object object, Object callback, ReferenceQueue queue) { - return trace(new PReferenceType(cls, getShape(cls), object, callback, queue)); - } - - public final PReferenceType createReferenceType(Object object, Object callback, ReferenceQueue queue) { - return createReferenceType(PythonBuiltinClassType.PReferenceType, object, callback, queue); - } - - public final PCell createCell(Assumption effectivelyFinal) { - return trace(new PCell(effectivelyFinal)); - } - - /* - * Frames, traces and exceptions - */ - - public final PFrame createPFrame(PFrame.Reference frameInfo, Node location, MaterializedFrame locals) { - return trace(new PFrame(getLanguage(), frameInfo, location, locals)); - } - - public final PFrame createPFrame(Object threadState, PCode code, PythonObject globals, Object localsDict) { - return trace(new PFrame(getLanguage(), threadState, code, globals, localsDict)); - } - - public final PTraceback createTraceback(PFrame frame, int lineno, PTraceback next) { - return trace(new PTraceback(getLanguage(), frame, lineno, -1, next)); - } - - public final PTraceback createTracebackWithLasti(PFrame frame, int lineno, int lasti, PTraceback next) { - return trace(new PTraceback(getLanguage(), frame, lineno, lasti, next)); - } - - public final PTraceback createTraceback(LazyTraceback tb) { - return trace(new PTraceback(getLanguage(), tb)); - } - - public final PBaseException createBaseException(Object cls, PTuple args) { - return createBaseException(cls, null, args); - } - - public final PBaseException createBaseException(Object cls, Object[] data, PTuple args) { - return trace(new PBaseException(cls, getShape(cls), data, args)); - } - - /* - * Note: we use this method to convert a Java StackOverflowError into a Python RecursionError. - * At the time when this is done, some Java stack frames were already unwinded but there is no - * guarantee on how many. Therefore, it is important that this method is simple. In particular, - * do not add calls if that can be avoided. - */ - public final PBaseException createBaseException(Object cls, TruffleString format, Object[] args) { - return createBaseException(cls, null, format, args); - } - - public final PBaseException createBaseException(Object cls, Object[] data, TruffleString format, Object[] args) { - assert format != null; - return trace(new PBaseException(cls, getShape(cls), data, format, args)); - } - - public final PBaseException createBaseException(Object cls) { - return trace(new PBaseException(cls, getShape(cls), null)); - } - - public final PBaseException createBaseException(Object cls, Object[] data) { - return trace(new PBaseException(cls, getShape(cls), data)); - } - - public final PBaseExceptionGroup createBaseExceptionGroup(Object cls, TruffleString message, Object[] exceptions, Object[] args) { - return trace(new PBaseExceptionGroup(cls, getShape(cls), message, exceptions, createTuple(args))); - } - - /* - * Arrays - */ - - public final PArray createArray(Object cls, TruffleString formatString, BufferFormat format) { - assert format != null; - return trace(new PArray(cls, getShape(cls), formatString, format)); - } - - public final PArray createArray(TruffleString formatString, BufferFormat format, int length) throws OverflowException { - return createArray(PythonBuiltinClassType.PArray, formatString, format, length); - } - - public final PArray createArray(Object cls, TruffleString formatString, BufferFormat format, int length) throws OverflowException { - assert format != null; - return trace(new PArray(cls, getShape(cls), formatString, format, length)); - } - - public final PByteArray createByteArray(byte[] array) { - return createByteArray(array, array.length); - } - - public final PByteArray createByteArray(Object cls, byte[] array) { - return createByteArray(cls, array, array.length); - } - - public final PByteArray createByteArray(byte[] array, int length) { - return createByteArray(new ByteSequenceStorage(array, length)); - } - - public final PByteArray createByteArray(Object cls, byte[] array, int length) { - return createByteArray(cls, new ByteSequenceStorage(array, length)); - } - - public final PByteArray createByteArray(SequenceStorage storage) { - return createByteArray(PythonBuiltinClassType.PByteArray, storage); - } - - public final PByteArray createByteArray(Object cls, SequenceStorage storage) { - return trace(new PByteArray(cls, getShape(cls), storage)); - } - - /* - * Iterators - */ - - public final PStringIterator createStringIterator(TruffleString str) { - return trace(new PStringIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), str)); - } - - public final PStringReverseIterator createStringReverseIterator(Object cls, TruffleString str) { - return trace(new PStringReverseIterator(cls, getShape(cls), str)); - } - - public final PIntegerSequenceIterator createIntegerSequenceIterator(IntSequenceStorage storage, Object list) { - return trace(new PIntegerSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), storage, list)); - } - - public final PLongSequenceIterator createLongSequenceIterator(LongSequenceStorage storage, Object list) { - return trace(new PLongSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), storage, list)); - } - - public final PDoubleSequenceIterator createDoubleSequenceIterator(DoubleSequenceStorage storage, Object list) { - return trace(new PDoubleSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), storage, list)); - } - - public final PObjectSequenceIterator createObjectSequenceIterator(ObjectSequenceStorage storage, Object list) { - return trace(new PObjectSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), storage, list)); - } - - public final PSequenceIterator createSequenceIterator(Object sequence) { - return trace(new PSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), sequence)); - } - - public final PSequenceReverseIterator createSequenceReverseIterator(Object cls, Object sequence, int lengthHint) { - return trace(new PSequenceReverseIterator(cls, getShape(cls), sequence, lengthHint)); - } - - public final PIntRangeIterator createIntRangeIterator(PIntRange fastRange) { - return createIntRangeIterator(fastRange.getIntStart(), fastRange.getIntStop(), fastRange.getIntStep(), fastRange.getIntLength()); - } - - public final PIntRangeIterator createIntRangeIterator(int start, int stop, int step, int len) { - return trace(new PIntRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), start, stop, step, len)); - } - - public final PBigRangeIterator createBigRangeIterator(PInt start, PInt stop, PInt step, PInt len) { - return trace(new PBigRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), start, stop, step, len)); - } - - public final PBigRangeIterator createBigRangeIterator(PBigRange longRange) { - return createBigRangeIterator(longRange.getPIntStart(), longRange.getPIntStop(), longRange.getPIntStep(), longRange.getPIntLength()); - } - - public final PBigRangeIterator createBigRangeIterator(BigInteger start, BigInteger stop, BigInteger step, BigInteger len) { - return createBigRangeIterator(createInt(start), createInt(stop), createInt(step), createInt(len)); - } - - public final PArrayIterator createArrayIterator(PArray array) { - return trace(new PArrayIterator(PythonBuiltinClassType.PArrayIterator, PythonBuiltinClassType.PArrayIterator.getInstanceShape(getLanguage()), array)); - } - - public final PBaseSetIterator createBaseSetIterator(PBaseSet set, HashingStorageNodes.HashingStorageIterator iterator, int initialSize) { - return trace(new PBaseSetIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(getLanguage()), set, iterator, initialSize)); - } - - public final PDictItemIterator createDictItemIterator(HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return trace(new PDictItemIterator(PythonBuiltinClassType.PDictItemIterator, PythonBuiltinClassType.PDictItemIterator.getInstanceShape(getLanguage()), iterator, hashingStorage, initialSize)); - } - - public final PDictKeyIterator createDictKeyIterator(HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return trace(new PDictKeyIterator(PythonBuiltinClassType.PDictKeyIterator, PythonBuiltinClassType.PDictKeyIterator.getInstanceShape(getLanguage()), iterator, hashingStorage, initialSize)); - } - - public final PDictValueIterator createDictValueIterator(HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return trace(new PDictValueIterator(PythonBuiltinClassType.PDictValueIterator, PythonBuiltinClassType.PDictValueIterator.getInstanceShape(getLanguage()), iterator, hashingStorage, - initialSize)); - } - - public final Object createSentinelIterator(Object callable, Object sentinel) { - return trace(new PSentinelIterator(PythonBuiltinClassType.PSentinelIterator, PythonBuiltinClassType.PSentinelIterator.getInstanceShape(getLanguage()), callable, sentinel)); - } - - public final PEnumerate createEnumerate(Object cls, Object iterator, long start) { - return trace(new PEnumerate(cls, getShape(cls), iterator, start)); - } - - public final PEnumerate createEnumerate(Object cls, Object iterator, PInt start) { - return trace(new PEnumerate(cls, getShape(cls), iterator, start)); - } - - public final PMap createMap(Object cls) { - return trace(new PMap(cls, getShape(cls))); - } - - public final PZip createZip(Object cls, Object[] iterables, boolean strict) { - return trace(new PZip(cls, getShape(cls), iterables, strict)); - } - - public final PCode createCode(RootCallTarget ct) { - return trace(new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(getLanguage()), ct)); - } - - public final PCode createCode(RootCallTarget ct, int flags, int firstlineno, byte[] linetable, TruffleString filename) { - return trace(new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(getLanguage()), ct, flags, firstlineno, linetable, filename)); - } - - public final PCode createCode(RootCallTarget callTarget, Signature signature, CodeUnit codeUnit) { - return trace(new PCode(PythonBuiltinClassType.PCode, getShape(PythonBuiltinClassType.PCode), callTarget, signature, codeUnit)); - } - - public final PCode createCode(RootCallTarget callTarget, Signature signature, int nlocals, - int stacksize, int flags, Object[] constants, - TruffleString[] names, TruffleString[] varnames, - TruffleString[] freevars, TruffleString[] cellvars, - TruffleString filename, TruffleString name, TruffleString qualname, - int firstlineno, byte[] linetable) { - return trace(new PCode(PythonBuiltinClassType.PCode, getShape(PythonBuiltinClassType.PCode), callTarget, signature, - nlocals, stacksize, flags, constants, names, varnames, freevars, cellvars, - filename, name, qualname, firstlineno, linetable)); - } - - public PCode createCode(Supplier createCode, int flags, int firstlineno, byte[] lnotab, TruffleString filename) { - return trace(new PCode(PythonBuiltinClassType.PCode, getShape(PythonBuiltinClassType.PCode), createCode, flags, firstlineno, lnotab, filename)); - } - - /* - * Socket - */ - - public final PSocket createSocket(Object cls) { - return trace(new PSocket(cls, getShape(cls))); - } - - /* - * Threading - */ - - public PThreadLocal createThreadLocal(Object cls, Object[] args, PKeyword[] kwArgs) { - return trace(new PThreadLocal(cls, getShape(cls), args, kwArgs)); - } - - public final PLock createLock() { - return createLock(PythonBuiltinClassType.PLock); - } - - public final PLock createLock(Object cls) { - return trace(new PLock(cls, getShape(cls))); - } - - public final PRLock createRLock() { - return createRLock(PythonBuiltinClassType.PRLock); - } - - public final PRLock createRLock(Object cls) { - return trace(new PRLock(cls, getShape(cls))); - } - - public final PThread createPythonThread(Thread thread) { - return trace(new PThread(PythonBuiltinClassType.PThread, PythonBuiltinClassType.PThread.getInstanceShape(getLanguage()), thread)); - } - - public final PThread createPythonThread(Object cls, Thread thread) { - return trace(new PThread(cls, getShape(cls), thread)); - } - - public final PSemLock createSemLock(Object cls, long handle, int kind, int maxValue, TruffleString name) { - return trace(new PSemLock(cls, getShape(cls), handle, kind, maxValue, name)); - } - - public final PGraalPySemLock createGraalPySemLock(Object cls, TruffleString name, int kind, Semaphore sharedSemaphore) { - return trace(new PGraalPySemLock(cls, getShape(cls), name, kind, sharedSemaphore)); - } - - public final PScandirIterator createScandirIterator(PythonContext context, Object dirStream, PosixFileHandle path, boolean needsRewind) { - return trace(new PScandirIterator(PythonBuiltinClassType.PScandirIterator, PythonBuiltinClassType.PScandirIterator.getInstanceShape(getLanguage()), context, dirStream, path, needsRewind)); - } - - public final PDirEntry createDirEntry(Object dirEntryData, PosixFileHandle path) { - return trace(new PDirEntry(PythonBuiltinClassType.PDirEntry, PythonBuiltinClassType.PDirEntry.getInstanceShape(getLanguage()), dirEntryData, path)); - } - - public final PEncodingMap createEncodingMap(int count2, int count3, byte[] level1, byte[] level23) { - return trace(new PEncodingMap(PythonBuiltinClassType.PEncodingMap, PythonBuiltinClassType.PEncodingMap.getInstanceShape(getLanguage()), count2, count3, level1, level23)); - } - - public final PMMap createMMap(PythonContext context, Object clazz, Object mmapHandle, int fd, long length, int access) { - return trace(new PMMap(clazz, getShape(clazz), context, mmapHandle, fd, length, access)); - } - - public final BZ2Object.BZ2Compressor createBZ2Compressor(Object clazz) { - return trace(BZ2Object.createCompressor(clazz, getShape(clazz))); - } - - public final BZ2Object.BZ2Decompressor createBZ2Decompressor(Object clazz) { - return trace(BZ2Object.createDecompressor(clazz, getShape(clazz))); - } - - public final ZLibCompObject createJavaZLibCompObject(Object clazz, Object stream, int level, int wbits, int strategy, byte[] zdict) { - return trace(ZLibCompObject.createJava(clazz, getShape(clazz), stream, level, wbits, strategy, zdict)); - } - - public final ZLibCompObject createJavaZLibCompObject(Object clazz, Object stream, int wbits, byte[] zdict) { - return trace(ZLibCompObject.createJava(clazz, getShape(clazz), stream, wbits, zdict)); - } - - public final ZLibCompObject createNativeZLibCompObject(Object clazz, Object zst, NFIZlibSupport zlibSupport) { - return trace(ZLibCompObject.createNative(clazz, getShape(clazz), zst, zlibSupport)); - } - - public final LZMAObject.LZMADecompressor createLZMADecompressor(Object clazz, boolean isNative) { - return trace(LZMAObject.createDecompressor(clazz, getShape(clazz), isNative)); - } - - public final LZMAObject.LZMACompressor createLZMACompressor(Object clazz, boolean isNative) { - return trace(LZMAObject.createCompressor(clazz, getShape(clazz), isNative)); - } - - public final CSVReader createCSVReader(Object clazz, Object inputIter, CSVDialect dialect) { - return trace(new CSVReader(clazz, getShape(clazz), inputIter, dialect)); - } - - public final CSVWriter createCSVWriter(Object clazz, Object write, CSVDialect dialect) { - return trace(new CSVWriter(clazz, getShape(clazz), write, dialect)); - } - - public final CSVDialect createCSVDialect(Object clazz, TruffleString delimiter, int delimiterCodePoint, boolean doubleQuote, TruffleString escapeChar, int escapeCharCodePoint, - TruffleString lineTerminator, TruffleString quoteChar, int quoteCharCodePoint, QuoteStyle quoting, boolean skipInitialSpace, boolean strict) { - return trace(new CSVDialect(clazz, getShape(clazz), delimiter, delimiterCodePoint, doubleQuote, escapeChar, escapeCharCodePoint, lineTerminator, quoteChar, quoteCharCodePoint, quoting, - skipInitialSpace, strict)); - } - - public final PFileIO createFileIO(Object clazz) { - return trace(new PFileIO(clazz, getShape(clazz))); - } - - public final PChain createChain(Object cls) { - return trace(new PChain(cls, getShape(cls))); - } - - public final PCount createCount(Object cls) { - return trace(new PCount(cls, getShape(cls))); - } - - public final PIslice createIslice(Object cls) { - return trace(new PIslice(cls, getShape(cls))); - } - - public final PPairwise createPairwise(Object cls) { - return trace(new PPairwise(cls, getShape(cls))); - } - - public final PPermutations createPermutations(Object cls) { - return trace(new PPermutations(cls, getShape(cls))); - } - - public final PProduct createProduct(Object cls) { - return trace(new PProduct(cls, getShape(cls))); - } - - public final PRepeat createRepeat(Object cls) { - return trace(new PRepeat(cls, getShape(cls))); - } - - public final PAccumulate createAccumulate(Object cls) { - return trace(new PAccumulate(cls, getShape(cls))); - } - - public final PDropwhile createDropwhile(Object cls) { - return trace(new PDropwhile(cls, getShape(cls))); - } - - public final PCombinations createCombinations(Object cls) { - return trace(new PCombinations(cls, getShape(cls))); - } - - public final PCombinationsWithReplacement createCombinationsWithReplacement(Object cls) { - return trace(new PCombinationsWithReplacement(cls, getShape(cls))); - } - - public final PCompress createCompress(Object cls) { - return trace(new PCompress(cls, getShape(cls))); - } - - public final PCycle createCycle(Object cls) { - return trace(new PCycle(cls, getShape(cls))); - } - - public final PFilterfalse createFilterfalse(Object cls) { - return trace(new PFilterfalse(cls, getShape(cls))); - } - - public final PGroupBy createGroupBy(Object cls) { - return trace(new PGroupBy(cls, getShape(cls))); - } - - public final PGrouper createGrouper(Object cls) { - return trace(new PGrouper(cls, getShape(cls))); - } - - public final PGrouper createGrouper(PGroupBy parent, Object tgtKey) { - return trace(new PGrouper(parent, tgtKey, PythonBuiltinClassType.PGrouper, PythonBuiltinClassType.PGrouper.getInstanceShape(getLanguage()))); - } - - public final PTee createTee() { - return trace(new PTee(PythonBuiltinClassType.PTee, PythonBuiltinClassType.PTee.getInstanceShape(getLanguage()))); - } - - public final PTee createTee(PTeeDataObject dataObj, int index) { - return trace(new PTee(dataObj, index, PythonBuiltinClassType.PTee, PythonBuiltinClassType.PTee.getInstanceShape(getLanguage()))); - } - - public final PStarmap createStarmap(Object cls) { - return trace(new PStarmap(cls, getShape(cls))); - } - - public final PTakewhile createTakewhile(Object cls) { - return trace(new PTakewhile(cls, getShape(cls))); - } - - public final PTeeDataObject createTeeDataObject() { - return trace(new PTeeDataObject(PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(getLanguage()))); - } - - public final PTeeDataObject createTeeDataObject(Object it) { - return trace(new PTeeDataObject(it, PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(getLanguage()))); - } - - public final PZipLongest createZipLongest(Object cls) { - return trace(new PZipLongest(cls, getShape(cls))); - } - - public final PTextIO createTextIO(Object clazz) { - return trace(new PTextIO(clazz, getShape(clazz))); - } - - public final PStringIO createStringIO(Object clazz) { - return trace(new PStringIO(clazz, getShape(clazz))); - } - - public final PBytesIO createBytesIO(Object clazz) { - return trace(new PBytesIO(clazz, getShape(clazz))); - } - - public final PBytesIOBuffer createBytesIOBuf(Object clazz, PBytesIO source) { - return trace(new PBytesIOBuffer(clazz, getShape(clazz), source)); - } - - public final PNLDecoder createNLDecoder(Object clazz) { - return trace(new PNLDecoder(clazz, getShape(clazz))); - } - - public final PBuffered createBufferedReader(Object clazz) { - return trace(new PBuffered(clazz, getShape(clazz), true, false)); - } - - public final PBuffered createBufferedWriter(Object clazz) { - return trace(new PBuffered(clazz, getShape(clazz), false, true)); - } - - public final PBuffered createBufferedRandom(Object clazz) { - return trace(new PBuffered(clazz, getShape(clazz), true, true)); - } - - public final PRWPair createRWPair(Object clazz) { - return trace(new PRWPair(clazz, getShape(clazz))); - } - - public final PyCArgObject createCArgObject() { - return trace(new PyCArgObject(PythonBuiltinClassType.CArgObject, getShape(PythonBuiltinClassType.CArgObject))); - } - - public final CThunkObject createCThunkObject(Object clazz, int nArgs) { - return trace(new CThunkObject(clazz, getShape(clazz), nArgs)); - } - - public final StructParamObject createStructParamObject(Object clazz) { - return trace(new StructParamObject(clazz, getShape(clazz))); - } - - // Don't use directly, use CtypesNodes.CreateCDataObjectNode - public final CDataObject createCDataObject(Object clazz, Pointer b_ptr, int b_size, boolean b_needsfree) { - return trace(new CDataObject(clazz, getShape(clazz), b_ptr, b_size, b_needsfree)); - } - - // Don't use directly, use CtypesNodes.CreateCDataObjectNode - public final PyCFuncPtrObject createPyCFuncPtrObject(Object clazz, Pointer b_ptr, int b_size, boolean b_needsfree) { - return trace(new PyCFuncPtrObject(clazz, getShape(clazz), b_ptr, b_size, b_needsfree)); - } - - public final CFieldObject createCFieldObject(Object clazz) { - return trace(new CFieldObject(clazz, getShape(clazz))); - } - - public final StgDictObject createStgDictObject(Object clazz) { - return trace(new StgDictObject(clazz, getShape(clazz))); - } - - public final PSSLContext createSSLContext(Object clazz, SSLMethod method, int verifyFlags, boolean checkHostname, int verifyMode, SSLContext context) { - return trace(new PSSLContext(clazz, getShape(clazz), method, verifyFlags, checkHostname, verifyMode, context)); - } - - public final PSSLSocket createSSLSocket(Object clazz, PSSLContext context, SSLEngine engine, PSocket socket) { - return trace(new PSSLSocket(clazz, getShape(clazz), context, engine, socket, createMemoryBIO(), createMemoryBIO(), createMemoryBIO())); - } - - public final PSSLSocket createSSLSocket(Object clazz, PSSLContext context, SSLEngine engine, PMemoryBIO inbound, PMemoryBIO outbound) { - return trace(new PSSLSocket(clazz, getShape(clazz), context, engine, null, inbound, outbound, createMemoryBIO())); - } - - public final PMemoryBIO createMemoryBIO(Object clazz) { - return trace(new PMemoryBIO(clazz, getShape(clazz))); - } - - public final PMemoryBIO createMemoryBIO() { - return trace(new PMemoryBIO(PythonBuiltinClassType.PMemoryBIO, getShape(PythonBuiltinClassType.PMemoryBIO))); - } - - public final PProperty createProperty() { - return trace(new PProperty(PythonBuiltinClassType.PProperty, getShape(PythonBuiltinClassType.PProperty))); - } - - public final PProperty createProperty(Object cls) { - return trace(new PProperty(cls, getShape(cls))); - } - - // JSON - // (not created on fast path, thus TruffleBoundary) - - @TruffleBoundary - public final PJSONScanner createJSONScanner(Object clazz, boolean strict, Object objectHook, Object objectPairsHook, Object parseFloat, Object parseInt, Object parseConstant) { - return trace(new PJSONScanner(clazz, getShape(clazz), strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant)); - } - - @TruffleBoundary - public final PJSONEncoder createJSONEncoder(Object clazz, Object markers, Object defaultFn, Object encoder, Object indent, TruffleString keySeparator, TruffleString itemSeparator, - boolean sortKeys, boolean skipKeys, boolean allowNan, FastEncode fastEncode) { - return trace(new PJSONEncoder(clazz, getShape(clazz), markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode)); - } - - public final PDeque createDeque() { - return trace(new PDeque(PythonBuiltinClassType.PDeque, getShape(PythonBuiltinClassType.PDeque))); - } - - public final PDeque createDeque(Object cls) { - return trace(new PDeque(cls, getShape(cls))); - } - - public final PDequeIter createDequeIter(PDeque deque) { - return trace(new PDequeIter(PythonBuiltinClassType.PDequeIter, getShape(PythonBuiltinClassType.PDequeIter), deque, false)); - } - - public final PDequeIter createDequeRevIter(PDeque deque) { - return trace(new PDequeIter(PythonBuiltinClassType.PDequeRevIter, getShape(PythonBuiltinClassType.PDequeRevIter), deque, true)); - } - - public final PSimpleQueue createSimpleQueue(Object cls) { - return trace(new PSimpleQueue(cls, getShape(cls))); - } - - public final PContextVar createContextVar(TruffleString name, Object def) { - return trace(new PContextVar(PythonBuiltinClassType.ContextVar, getShape(PythonBuiltinClassType.ContextVar), name, def)); - } - - public final PContextVarsContext createContextVarsContext() { - return trace(new PContextVarsContext(PythonBuiltinClassType.ContextVarsContext, getShape(PythonBuiltinClassType.ContextVarsContext))); - } - - public final PContextIterator createContextIterator(PContextVarsContext ctx, PContextIterator.ItemKind kind) { - return trace(new PContextIterator(PythonBuiltinClassType.ContextIterator, getShape(PythonBuiltinClassType.ContextIterator), ctx, kind)); - } - - public final PContextVarsContext copyContextVarsContext(PContextVarsContext original) { - return trace(new PContextVarsContext(original, PythonBuiltinClassType.ContextVarsContext, getShape(PythonBuiltinClassType.ContextVarsContext))); - } - - public final PContextVarsToken createContextVarsToken(PContextVar var, Object oldValue) { - return trace(new PContextVarsToken(var, oldValue, PythonBuiltinClassType.ContextVarsToken, getShape(PythonBuiltinClassType.ContextVarsToken))); - } - - public final PGenericAlias createGenericAlias(Object cls, Object origin, Object arguments, boolean starred) { - PTuple argumentsTuple; - if (arguments instanceof PTuple) { - argumentsTuple = (PTuple) arguments; - } else { - argumentsTuple = createTuple(new Object[]{arguments}); - } - return trace(new PGenericAlias(cls, getShape(cls), origin, argumentsTuple, starred)); - } - - public final PGenericAlias createGenericAlias(Object origin, Object arguments, boolean starred) { - return createGenericAlias(PythonBuiltinClassType.PGenericAlias, origin, arguments, starred); - } - - public final PGenericAlias createGenericAlias(Object origin, Object arguments) { - return createGenericAlias(PythonBuiltinClassType.PGenericAlias, origin, arguments, false); - } - - public final PGenericAliasIterator createGenericAliasIterator(PGenericAlias object) { - PythonBuiltinClassType type = PythonBuiltinClassType.PGenericAliasIterator; - return trace(new PGenericAliasIterator(type, getShape(type), object)); - } - - public final PUnionType createUnionType(Object[] args) { - return trace(new PUnionType(PythonBuiltinClassType.PUnionType, getShape(PythonBuiltinClassType.PUnionType), createTuple(args))); - } - - public final DigestObject createDigestObject(PythonBuiltinClassType type, String name, Object digest) { - return trace(DigestObject.create(type, getShape(type), name, digest)); - } - - public final PyCapsule createCapsuleNativeName(Object pointer, Object name) { - return createCapsule(new PyCapsule.CapsuleData(pointer, name)); - } - - public final PyCapsule createCapsuleJavaName(Object pointer, byte[] name) { - return createCapsule(new PyCapsule.CapsuleData(pointer, new CArrayWrappers.CByteArrayWrapper(name))); - } - - public final PyCapsule createCapsule(PyCapsule.CapsuleData data) { - return trace(new PyCapsule(getLanguage(), data)); - } - - public final MultibyteIncrementalDecoderObject createMultibyteIncrementalDecoderObject(Object type) { - return trace(new MultibyteIncrementalDecoderObject(type, getShape(type))); - } - - public final MultibyteIncrementalEncoderObject createMultibyteIncrementalEncoderObject(Object type) { - return trace(new MultibyteIncrementalEncoderObject(type, getShape(type))); - } - - public final MultibyteStreamReaderObject createMultibyteStreamReaderObject(Object type) { - return trace(new MultibyteStreamReaderObject(type, getShape(type))); - } - - public final MultibyteStreamWriterObject createMultibyteStreamWriterObject(Object type) { - return trace(new MultibyteStreamWriterObject(type, getShape(type))); - } - - public final MultibyteCodecObject createMultibyteCodecObject(Object type, MultibyteCodec codec) { - return trace(new MultibyteCodecObject(type, getShape(type), codec)); - } - - public PAsyncGenASend createAsyncGeneratorASend(PAsyncGen receiver, Object message) { - return trace(new PAsyncGenASend(getLanguage(), receiver, message)); - } - - public PAsyncGenAThrow createAsyncGeneratorAThrow(PAsyncGen receiver, Object arg1, Object arg2, Object arg3) { - return trace(new PAsyncGenAThrow(getLanguage(), receiver, arg1, arg2, arg3)); - } - - public PAsyncGenWrappedValue createAsyncGeneratorWrappedValue(Object wrapped) { - return trace(new PAsyncGenWrappedValue(getLanguage(), wrapped)); - } - - // pickle - - public PPickleBuffer createPickleBuffer(Object view) { - return createPickleBuffer(view, PythonBuiltinClassType.PickleBuffer); - } - - public PPickleBuffer createPickleBuffer(Object view, Object cls) { - return trace(new PPickleBuffer(cls, getShape(cls), view)); - } - - public PPickler createPickler() { - return createPickler(PythonBuiltinClassType.Pickler); - } - - public PPickler createPickler(Object cls) { - return trace(new PPickler(cls, getShape(cls))); - } - - public PUnpickler createUnpickler() { - return createUnpickler(PythonBuiltinClassType.Unpickler); - } - - public PUnpickler createUnpickler(Object cls) { - return trace(new PUnpickler(cls, getShape(cls))); - } - - public PPicklerMemoProxy createPicklerMemoProxy(PPickler pickler) { - return createPicklerMemoProxy(pickler, PythonBuiltinClassType.PicklerMemoProxy); - } - - public PPicklerMemoProxy createPicklerMemoProxy(PPickler pickler, Object cls) { - return trace(new PPicklerMemoProxy(cls, getShape(cls), pickler)); - } - - public PUnpicklerMemoProxy createUnpicklerMemoProxy(PUnpickler unpickler) { - return createUnpicklerMemoProxy(unpickler, PythonBuiltinClassType.UnpicklerMemoProxy); - } - - public PUnpicklerMemoProxy createUnpicklerMemoProxy(PUnpickler unpickler, Object cls) { - return trace(new PUnpicklerMemoProxy(cls, getShape(cls), unpickler)); - } - - public PStruct createStruct(PStruct.StructInfo structInfo) { - return trace(new PStruct(PythonBuiltinClassType.PStruct, getShape(PythonBuiltinClassType.PStruct), structInfo)); - } - - public PStruct createStruct(byte[] format, int size, int len, FormatAlignment formatAlignment, FormatCode[] codes) { - return trace(new PStruct(PythonBuiltinClassType.PStruct, getShape(PythonBuiltinClassType.PStruct), format, size, len, formatAlignment, codes)); - } - - public PStructUnpackIterator createStructUnpackIterator(PStruct struct, Object buffer) { - return trace( - new PStructUnpackIterator(PythonBuiltinClassType.PStructUnpackIterator, getShape(PythonBuiltinClassType.PStructUnpackIterator), struct, buffer)); - } - - public final PTokenizerIter createTokenizerIter(Object cls, String sourceString) { - return trace(new PTokenizerIter(cls, getShape(cls), sourceString)); - } - - @GenerateInline - @GenerateUncached - @GenerateCached(false) - public abstract static class Lazy extends Node { - public static Lazy getUncached() { - return LazyNodeGen.getUncached(); - } - - public final PythonObjectFactory get(Node inliningTarget) { - return execute(inliningTarget); - } - - abstract PythonObjectFactory execute(Node inliningTarget); - - @Specialization - static PythonObjectFactory doIt(@Cached(inline = false) PythonObjectFactory node) { - return node; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectSlowPathFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectSlowPathFactory.java deleted file mode 100644 index 57bde9aff7..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectSlowPathFactory.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2021, 2024, 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.runtime.object; - -import java.util.Objects; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.instrumentation.AllocationReporter; -import com.oracle.truffle.api.object.Shape; - -/** - * A subclass of {@link PythonObjectFactory} which is basically an uncached version of it but - * directly stores a reference to the {@link AllocationReporter} instead of doing a context lookup - * and getting it from the context. This class is meant to be used on slow path where the context is - * explicitly available. - * - * Objects of this class should not be created directly, but retrieved from - * {@link com.oracle.graal.python.builtins.Python3Core}. Note that - * {@link PythonObjectSlowPathFactory} is context dependent object. It must not be stored in AST or - * in {@link com.oracle.graal.python.PythonLanguage}, for example. - */ -public final class PythonObjectSlowPathFactory extends PythonObjectFactory { - - private final AllocationReporter reporter; - private final PythonLanguage language; - private final SlowPathGetInstanceShapeNode getInstanceShapeNode; - - public PythonObjectSlowPathFactory(AllocationReporter reporter, PythonLanguage language) { - this.reporter = Objects.requireNonNull(reporter); - this.language = language; - this.getInstanceShapeNode = new SlowPathGetInstanceShapeNode(language); - } - - @Override - public PythonLanguage getLanguage() { - return language; - } - - @TruffleBoundary - @Override - protected AllocationReporter executeTrace(Object arg0Value, long arg1Value) { - assert PythonContext.get(null).getAllocationReporter() == reporter; - return PythonObjectFactory.doTrace(arg0Value, arg1Value, reporter); - } - - @TruffleBoundary - @Override - protected Shape executeGetShape(Object arg0Value, boolean arg1Value) { - return getInstanceShapeNode.execute(arg0Value); - } - - @Override - public boolean isAdoptable() { - return false; - } - -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java index 00c43e123d..2700fa86c3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -86,8 +86,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.pegparser.scope.ScopeEnvironment; import com.oracle.graal.python.pegparser.sst.ConstantValue; -import com.oracle.graal.python.runtime.object.PythonObjectFactory; -import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; @@ -223,7 +222,7 @@ public static TruffleString[] toTruffleStringArrayUncached(String[] s) { /** * Creates an array of {@link Object}'s. The intended use of this method is in slow-path in - * calls to methods like {@link PythonObjectFactory#createTuple(Object[])}. + * calls to methods like {@link PFactory#createTuple}. */ public static Object[] convertToObjectArray(TruffleString[] src) { if (src == null) { @@ -697,16 +696,15 @@ public static PBuiltinFunction createMethod(PythonLanguage language, Object klas Class nodeClass = nodeFactory.getNodeClass(); Builtin builtin = nodeClass.getAnnotation(Builtin.class); RootCallTarget callTarget = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, nodeFactory, true), nodeClass); - return createMethod(PythonObjectFactory.getUncached(), klass, builtin, callTarget, type, numDefaults); + return createMethod(klass, builtin, callTarget, type, numDefaults); } @TruffleBoundary - public static PBuiltinFunction createMethod(PythonObjectFactory factory, Object klass, Builtin builtin, RootCallTarget callTarget, Object type, - int numDefaults) { + public static PBuiltinFunction createMethod(Object klass, Builtin builtin, RootCallTarget callTarget, Object type, int numDefaults) { assert callTarget.getRootNode() instanceof BuiltinFunctionRootNode r && r.getBuiltin() == builtin; int flags = PBuiltinFunction.getFlags(builtin, callTarget); TruffleString name = toTruffleStringUncached(builtin.name()); - PBuiltinFunction function = factory.createBuiltinFunction(name, type, numDefaults, flags, callTarget); + PBuiltinFunction function = PFactory.createBuiltinFunction(PythonLanguage.get(null), name, type, numDefaults, flags, callTarget); if (klass != null) { WriteAttributeToObjectNode.getUncached(true).execute(klass, name, function); } @@ -714,22 +712,16 @@ public static PBuiltinFunction createMethod(PythonObjectFactory factory, Object } @TruffleBoundary - public static void createConstructor(PythonObjectSlowPathFactory factory, Object klass, Builtin builtin, RootCallTarget callTarget) { + public static void createConstructor(Object klass, Builtin builtin, RootCallTarget callTarget) { assert J___NEW__.equals(builtin.name()); assert IsSubtypeNode.getUncached().execute(klass, PythonBuiltinClassType.PTuple); int flags = PBuiltinFunction.getFlags(builtin, callTarget); - PBuiltinFunction function = factory.createBuiltinFunction(toTruffleStringUncached(builtin.name()), PythonBuiltinClassType.PTuple, 1, flags, callTarget); - PBuiltinMethod method = factory.createBuiltinMethod(PythonBuiltinClassType.PTuple, function); + PythonLanguage language = PythonLanguage.get(null); + PBuiltinFunction function = PFactory.createBuiltinFunction(language, toTruffleStringUncached(builtin.name()), PythonBuiltinClassType.PTuple, 1, flags, callTarget); + PBuiltinMethod method = PFactory.createBuiltinMethod(language, PythonBuiltinClassType.PTuple, function); WriteAttributeToObjectNode.getUncached(true).execute(klass, T___NEW__, method); } - private static Object[] createCalltargetKeys(Object[] callTargetCacheKeys, Class nodeClass) { - Object[] keys = new Object[callTargetCacheKeys.length + 1]; - keys[0] = nodeClass; - arraycopy(callTargetCacheKeys, 0, keys, 1, callTargetCacheKeys.length); - return keys; - } - public static Unsafe initUnsafe() { try { return Unsafe.getUnsafe(); @@ -842,7 +834,7 @@ public boolean isOverLimit() { } } - public static Object pythonObjectFromConstantValue(ConstantValue v, PythonObjectFactory factory) { + public static Object pythonObjectFromConstantValue(ConstantValue v) { switch (v.kind) { case BOOLEAN: return v.getBoolean(); @@ -857,16 +849,16 @@ public static Object pythonObjectFromConstantValue(ConstantValue v, PythonObject return v.getDouble(); case COMPLEX: { double[] c = v.getComplex(); - return factory.createComplex(c[0], c[1]); + return PFactory.createComplex(PythonLanguage.get(null), c[0], c[1]); } case NONE: return PNone.NONE; case ELLIPSIS: return PEllipsis.INSTANCE; case BIGINTEGER: - return factory.createInt(v.getBigInteger()); + return PFactory.createInt(PythonLanguage.get(null), v.getBigInteger()); case BYTES: - return factory.createBytes(v.getBytes()); + return PFactory.createBytes(PythonLanguage.get(null), v.getBytes()); case RAW: return v.getRaw(TruffleString.class); case TUPLE: diff --git a/mx.graalpython/copyrights/overrides b/mx.graalpython/copyrights/overrides index 7111d0cbab..99a7d617eb 100644 --- a/mx.graalpython/copyrights/overrides +++ b/mx.graalpython/copyrights/overrides @@ -708,7 +708,7 @@ graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatti graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/InternalFormat.java,jython.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/StringFormatProcessor.java,jython.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/TextFormatter.java,jython.copyright -graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PythonObjectFactory.java,zippy.copyright +graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/PSequence.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/BoolSequenceStorage.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ByteSequenceStorage.java,zippy.copyright From db8b9a1bd3fb6fe05613078264c36e3d94faa523 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 5 Feb 2025 15:55:23 +0100 Subject: [PATCH 014/512] Comment out failing assert for now --- .../src/com/oracle/graal/python/PythonLanguage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index c48c51e79d..f7ecc2a1ce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -526,7 +526,8 @@ protected PythonContext createContext(Env env) { if (allocationReporter == null) { allocationReporter = env.lookup(AllocationReporter.class); } else { - assert allocationReporter == env.lookup(AllocationReporter.class); + // GR-61960 + // assert allocationReporter == env.lookup(AllocationReporter.class); } return context; From 71d7031d142031a8c98c80b25e114be40f477c1c Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 5 Feb 2025 15:57:30 +0100 Subject: [PATCH 015/512] Simplify PythonContext.getLanguage --- .../com/oracle/graal/python/builtins/Python3Core.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index 7d6dd23d65..d785ce324b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -906,11 +906,12 @@ public final PythonLanguage getLanguage() { * multi-context mode. Can be null. */ public final PythonLanguage getLanguage(Node node) { - if (CompilerDirectives.inCompiledCode() && node != null && CompilerDirectives.isPartialEvaluationConstant(node) && node.getRootNode() != null) { - // This will make it PE-constant in multi-context mode - return PythonLanguage.get(node); + // The condition is always true in the interpreter + if (CompilerDirectives.isPartialEvaluationConstant(language)) { + return language; } - return language; + // This will make it PE-constant in multi-context mode + return PythonLanguage.get(node); } /** From 4a7b16ad65b6f2ad4cb0acafd7df39d24943eb42 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 5 Feb 2025 16:29:29 +0100 Subject: [PATCH 016/512] Make PRaiseNode inlined --- .../asdl/asdl_java.py | 6 +- .../oracle/graal/python/PythonLanguage.java | 2 +- .../builtins/modules/AbcModuleBuiltins.java | 4 +- .../builtins/modules/ArrayModuleBuiltins.java | 44 +-- .../modules/AsyncioModuleBuiltins.java | 6 +- .../modules/BinasciiModuleBuiltins.java | 33 ++- .../builtins/modules/BuiltinConstructors.java | 263 +++++++++--------- .../builtins/modules/BuiltinFunctions.java | 148 +++++----- .../builtins/modules/CmathModuleBuiltins.java | 70 ++--- .../modules/CodecsModuleBuiltins.java | 111 ++++---- .../modules/CodecsTruffleModuleBuiltins.java | 2 +- .../modules/CollectionsModuleBuiltins.java | 8 +- .../modules/ContextvarsModuleBuiltins.java | 4 +- .../builtins/modules/FcntlModuleBuiltins.java | 10 +- .../modules/GraalHPyDebugModuleBuiltins.java | 2 +- .../GraalHPyUniversalModuleBuiltins.java | 4 +- .../modules/GraalPythonModuleBuiltins.java | 14 +- .../builtins/modules/ImpModuleBuiltins.java | 10 +- .../modules/ItertoolsModuleBuiltins.java | 134 +++++---- .../modules/JArrayModuleBuiltins.java | 16 +- .../builtins/modules/JavaModuleBuiltins.java | 32 +-- .../modules/LocaleModuleBuiltins.java | 6 +- .../modules/LsprofModuleBuiltins.java | 2 +- .../builtins/modules/MMapModuleBuiltins.java | 18 +- .../modules/MarshalModuleBuiltins.java | 32 +-- .../builtins/modules/MathModuleBuiltins.java | 218 ++++++++------- .../modules/OperatorModuleBuiltins.java | 4 +- .../modules/PolyglotModuleBuiltins.java | 106 +++---- .../builtins/modules/PosixModuleBuiltins.java | 203 +++++++------- .../PosixSubprocessModuleBuiltins.java | 28 +- .../builtins/modules/PwdModuleBuiltins.java | 14 +- .../modules/ReadlineModuleBuiltins.java | 18 +- .../modules/ResourceModuleBuiltins.java | 4 +- .../builtins/modules/SREModuleBuiltins.java | 28 +- .../builtins/modules/SSLModuleBuiltins.java | 28 +- .../modules/SelectModuleBuiltins.java | 8 +- .../modules/SignalModuleBuiltins.java | 8 +- .../modules/SocketModuleBuiltins.java | 66 ++--- .../modules/StructModuleBuiltins.java | 16 +- .../builtins/modules/SysModuleBuiltins.java | 59 ++-- .../modules/ThreadModuleBuiltins.java | 8 +- .../builtins/modules/TimeModuleBuiltins.java | 66 ++--- .../modules/TracemallocModuleBuiltins.java | 13 +- .../modules/UnicodeDataModuleBuiltins.java | 10 +- .../modules/WarningsModuleBuiltins.java | 61 ++-- .../modules/WeakRefModuleBuiltins.java | 12 +- .../builtins/modules/ast/AstBuiltins.java | 13 +- .../modules/ast/AstModuleBuiltins.java | 11 +- .../python/builtins/modules/ast/Obj2Sst.java | 5 +- .../builtins/modules/ast/Obj2SstBase.java | 17 +- .../builtins/modules/ast/Validator.java | 26 +- .../modules/bz2/BZ2CompressorBuiltins.java | 16 +- .../modules/bz2/BZ2DecompressorBuiltins.java | 8 +- .../python/builtins/modules/bz2/Bz2Nodes.java | 34 +-- .../cext/PythonCextAbstractBuiltins.java | 43 ++- .../modules/cext/PythonCextBuiltins.java | 30 +- .../cext/PythonCextByteArrayBuiltins.java | 10 +- .../modules/cext/PythonCextBytesBuiltins.java | 46 +-- .../cext/PythonCextCapsuleBuiltins.java | 77 +++-- .../modules/cext/PythonCextClassBuiltins.java | 4 +- .../cext/PythonCextComplexBuiltins.java | 4 +- .../cext/PythonCextContextBuiltins.java | 6 +- .../modules/cext/PythonCextDictBuiltins.java | 14 +- .../modules/cext/PythonCextErrBuiltins.java | 9 +- .../modules/cext/PythonCextFileBuiltins.java | 4 +- .../modules/cext/PythonCextFloatBuiltins.java | 8 +- .../modules/cext/PythonCextListBuiltins.java | 8 +- .../modules/cext/PythonCextLongBuiltins.java | 26 +- .../cext/PythonCextMemoryViewBuiltins.java | 8 +- .../cext/PythonCextModuleBuiltins.java | 14 +- .../cext/PythonCextObjectBuiltins.java | 8 +- .../cext/PythonCextPickleBufferBuiltins.java | 6 +- .../cext/PythonCextPythonRunBuiltins.java | 38 ++- .../modules/cext/PythonCextSetBuiltins.java | 14 +- .../cext/PythonCextStructSeqBuiltins.java | 4 +- .../modules/cext/PythonCextTupleBuiltins.java | 12 +- .../modules/cext/PythonCextTypeBuiltins.java | 5 +- .../cext/PythonCextUnicodeBuiltins.java | 143 +++++----- .../modules/cjkcodecs/CodecCtxBuiltins.java | 8 +- .../cjkcodecs/CodecsCNModuleBuiltins.java | 6 +- .../cjkcodecs/CodecsHKModuleBuiltins.java | 6 +- .../CodecsISO2022ModuleBuiltins.java | 6 +- .../cjkcodecs/CodecsJPModuleBuiltins.java | 6 +- .../cjkcodecs/CodecsKRModuleBuiltins.java | 6 +- .../cjkcodecs/CodecsTWModuleBuiltins.java | 6 +- .../cjkcodecs/MultibyteCodecBuiltins.java | 4 +- .../modules/cjkcodecs/MultibyteCodecUtil.java | 32 +-- .../cjkcodecs/MultibyteDecodeBuffer.java | 2 +- .../cjkcodecs/MultibyteEncodeBuffer.java | 2 +- .../MultibyteIncrementalDecoderBuiltins.java | 16 +- .../MultibyteIncrementalEncoderBuiltins.java | 20 +- .../MultibyteStreamReaderBuiltins.java | 8 +- .../MultibyteStreamWriterBuiltins.java | 8 +- .../MultibytecodecModuleBuiltins.java | 10 +- .../builtins/modules/codecs/CharmapNodes.java | 20 +- .../modules/codecs/CodecsRegistry.java | 11 +- .../modules/codecs/ErrorHandlers.java | 97 +++---- .../modules/csv/CSVModuleBuiltins.java | 52 ++-- .../modules/csv/CSVReaderBuiltins.java | 18 +- .../modules/csv/CSVWriterBuiltins.java | 14 +- .../modules/ctypes/CDataBuiltins.java | 18 +- .../modules/ctypes/CDataTypeBuiltins.java | 48 ++-- .../ctypes/CDataTypeSequenceBuiltins.java | 8 +- .../modules/ctypes/CFieldBuiltins.java | 59 ++-- .../builtins/modules/ctypes/CThunkObject.java | 4 +- .../modules/ctypes/CtypesModuleBuiltins.java | 92 +++--- .../builtins/modules/ctypes/CtypesNodes.java | 2 +- .../ctypes/LazyPyCArrayTypeBuiltins.java | 20 +- .../ctypes/LazyPyCSimpleTypeBuiltins.java | 12 +- .../modules/ctypes/PyCArrayBuiltins.java | 35 ++- .../modules/ctypes/PyCArrayTypeBuiltins.java | 16 +- .../modules/ctypes/PyCFuncPtrBuiltins.java | 82 +++--- .../ctypes/PyCFuncPtrTypeBuiltins.java | 12 +- .../modules/ctypes/PyCPointerBuiltins.java | 41 ++- .../ctypes/PyCPointerTypeBuiltins.java | 20 +- .../modules/ctypes/PyCSimpleTypeBuiltins.java | 16 +- .../modules/ctypes/SimpleCDataBuiltins.java | 12 +- .../modules/ctypes/StgDictBuiltins.java | 16 +- .../ctypes/StructUnionTypeBuiltins.java | 32 +-- .../modules/ctypes/StructureBuiltins.java | 16 +- .../modules/ctypes/UnionTypeBuiltins.java | 2 +- .../modules/ctypes/memory/PointerNodes.java | 10 +- .../functools/FunctoolsModuleBuiltins.java | 6 +- .../modules/functools/KeyWrapperBuiltins.java | 6 +- .../functools/LruCacheWrapperBuiltins.java | 10 +- .../modules/functools/PartialBuiltins.java | 22 +- .../modules/hashlib/Blake2ModuleBuiltins.java | 12 +- .../modules/hashlib/DigestObjectBuiltins.java | 8 +- .../hashlib/HashlibModuleBuiltins.java | 46 +-- .../modules/hashlib/Md5ModuleBuiltins.java | 6 +- .../modules/hashlib/Sha1ModuleBuiltins.java | 6 +- .../modules/hashlib/Sha256ModuleBuiltins.java | 10 +- .../modules/hashlib/Sha3ModuleBuiltins.java | 6 +- .../modules/hashlib/Sha512ModuleBuiltins.java | 10 +- .../hashlib/ShakeDigestObjectBuiltins.java | 8 +- .../io/AbstractBufferedIOBuiltins.java | 22 +- .../modules/io/BufferedIOBaseBuiltins.java | 24 +- .../modules/io/BufferedIOMixinBuiltins.java | 21 +- .../builtins/modules/io/BufferedIONodes.java | 28 +- .../modules/io/BufferedRWPairBuiltins.java | 26 +- .../io/BufferedReaderMixinBuiltins.java | 21 +- .../modules/io/BufferedWriterNodes.java | 4 +- .../builtins/modules/io/BytesIOBuiltins.java | 68 ++--- .../builtins/modules/io/FileIOBuiltins.java | 86 +++--- .../builtins/modules/io/IOBaseBuiltins.java | 35 +-- .../modules/io/IOBaseDictBuiltins.java | 6 +- .../builtins/modules/io/IOModuleBuiltins.java | 39 ++- .../python/builtins/modules/io/IONodes.java | 25 +- .../io/IncrementalNewlineDecoderBuiltins.java | 18 +- .../python/builtins/modules/io/PBytesIO.java | 4 +- .../python/builtins/modules/io/PTextIO.java | 6 +- .../modules/io/RawIOBaseBuiltins.java | 12 +- .../builtins/modules/io/StringIOBuiltins.java | 86 +++--- .../modules/io/TextIOBaseBuiltins.java | 21 +- .../modules/io/TextIOWrapperBuiltins.java | 105 +++---- .../modules/io/TextIOWrapperNodes.java | 34 +-- .../modules/json/JSONEncoderBuiltins.java | 10 +- .../modules/json/JSONModuleBuiltins.java | 10 +- .../modules/json/JSONScannerBuiltins.java | 4 +- .../modules/lzma/LZMACompressorBuiltins.java | 20 +- .../lzma/LZMADecompressorBuiltins.java | 28 +- .../builtins/modules/lzma/LZMANodes.java | 161 ++++++----- .../GraalPySemLockBuiltins.java | 4 +- .../MultiprocessingGraalPyModuleBuiltins.java | 10 +- .../MultiprocessingModuleBuiltins.java | 4 +- .../multiprocessing/SemLockBuiltins.java | 12 +- .../builtins/modules/pickle/MemoTable.java | 4 +- .../python/builtins/modules/pickle/PData.java | 16 +- .../modules/pickle/PPickleBuffer.java | 7 +- .../builtins/modules/pickle/PPickler.java | 14 +- .../builtins/modules/pickle/PUnpickler.java | 6 +- .../modules/pickle/PickleBufferBuiltins.java | 6 +- .../modules/pickle/PickleModuleBuiltins.java | 6 +- .../builtins/modules/pickle/PickleState.java | 22 +- .../builtins/modules/pickle/PickleUtils.java | 4 +- .../modules/pickle/PicklerBuiltins.java | 30 +- .../builtins/modules/pickle/PicklerNodes.java | 24 +- .../modules/pickle/UnpicklerBuiltins.java | 24 +- .../builtins/modules/zlib/ZLibCompObject.java | 6 +- .../modules/zlib/ZLibModuleBuiltins.java | 28 +- .../modules/zlib/ZlibCompressBuiltins.java | 16 +- .../modules/zlib/ZlibDecompressBuiltins.java | 18 +- .../builtins/modules/zlib/ZlibNodes.java | 51 ++-- .../objects/PythonAbstractObject.java | 132 ++++----- .../builtins/objects/array/ArrayBuiltins.java | 123 ++++---- .../builtins/objects/array/ArrayNodes.java | 8 +- .../python/builtins/objects/array/PArray.java | 4 +- .../objects/asyncio/AsyncGenSendBuiltins.java | 23 +- .../asyncio/AsyncGenThrowBuiltins.java | 53 ++-- .../objects/asyncio/GetAwaitableNode.java | 20 +- .../buffer/PythonBufferAcquireLibrary.java | 6 +- .../objects/bytes/ByteArrayBuiltins.java | 93 +++---- .../builtins/objects/bytes/BytesBuiltins.java | 12 +- .../objects/bytes/BytesCommonBuiltins.java | 86 +++--- .../builtins/objects/bytes/BytesNodes.java | 54 ++-- .../builtins/objects/bytes/PByteArray.java | 6 +- .../python/builtins/objects/bytes/PBytes.java | 7 +- .../builtins/objects/cell/CellBuiltins.java | 34 +-- .../objects/cext/capi/CApiContext.java | 6 +- .../cext/capi/CApiMemberAccessNodes.java | 39 +-- .../builtins/objects/cext/capi/CExtNodes.java | 47 ++-- .../cext/capi/ExternalFunctionNodes.java | 9 +- .../cext/capi/PyMemoryViewWrapper.java | 4 +- .../objects/cext/capi/PyProcsWrapper.java | 4 +- .../capi/transitions/CApiTransitions.java | 2 +- .../objects/cext/common/CExtCommonNodes.java | 80 +++--- .../objects/cext/hpy/GraalHPyContext.java | 16 +- .../cext/hpy/GraalHPyContextFunctions.java | 104 +++---- .../cext/hpy/GraalHPyMemberAccessNodes.java | 28 +- .../cext/hpy/GraalHPyNativeContext.java | 2 +- .../objects/cext/hpy/GraalHPyNodes.java | 69 +++-- .../cext/hpy/HPyExternalFunctionNodes.java | 28 +- .../cext/hpy/jni/GraalHPyJNIContext.java | 16 +- .../cext/hpy/llvm/GraalHPyLLVMNodes.java | 10 +- .../objects/cext/structs/CConstants.java | 8 +- .../builtins/objects/code/CodeNodes.java | 2 +- .../objects/common/BufferStorageNodes.java | 41 ++- .../objects/common/ForeignHashingStorage.java | 27 +- .../objects/common/HashingStorage.java | 8 +- .../objects/common/HashingStorageNodes.java | 14 +- .../builtins/objects/common/IndexNodes.java | 35 ++- .../objects/common/SequenceNodes.java | 11 +- .../objects/common/SequenceStorageNodes.java | 71 ++--- .../objects/complex/ComplexBuiltins.java | 26 +- .../objects/contextvars/ContextBuiltins.java | 15 +- .../contextvars/ContextIteratorBuiltins.java | 4 +- .../contextvars/ContextVarBuiltins.java | 12 +- .../contextvars/PContextVarsContext.java | 6 +- .../contextvars/PContextVarsToken.java | 6 +- .../builtins/objects/deque/DequeBuiltins.java | 42 +-- .../objects/deque/DequeIterBuiltins.java | 4 +- .../objects/dict/DefaultDictBuiltins.java | 13 +- .../builtins/objects/dict/DictBuiltins.java | 28 +- .../builtins/objects/dict/DictNodes.java | 11 +- .../objects/dict/DictReprBuiltin.java | 14 +- .../exception/BaseExceptionBuiltins.java | 47 ++-- .../exception/BaseExceptionGroupBuiltins.java | 6 +- .../objects/exception/ExceptionNodes.java | 10 +- .../exception/ImportErrorBuiltins.java | 9 +- .../objects/exception/OsErrorBuiltins.java | 12 +- .../exception/PrepareExceptionNode.java | 20 +- .../exception/SyntaxErrorBuiltins.java | 4 +- .../exception/UnicodeDecodeErrorBuiltins.java | 18 +- .../exception/UnicodeEncodeErrorBuiltins.java | 16 +- .../exception/UnicodeErrorBuiltins.java | 20 +- .../UnicodeTranslateErrorBuiltins.java | 4 +- .../objects/floats/FloatBuiltins.java | 70 +++-- .../foreign/ForeignExecutableBuiltins.java | 4 +- .../foreign/ForeignInstantiableBuiltins.java | 4 +- .../foreign/ForeignNumberBuiltins.java | 3 +- .../foreign/ForeignObjectBuiltins.java | 20 +- .../builtins/objects/frame/FrameBuiltins.java | 16 +- .../function/AbstractFunctionBuiltins.java | 34 +-- .../function/BuiltinFunctionBuiltins.java | 14 +- .../objects/function/FunctionBuiltins.java | 14 +- .../generator/CommonGeneratorBuiltins.java | 50 ++-- .../objects/generator/GeneratorBuiltins.java | 12 +- .../getsetdescriptor/DescriptorBuiltins.java | 28 +- .../builtins/objects/ints/IntBuiltins.java | 224 +++++++-------- .../builtins/objects/ints/IntNodes.java | 12 +- .../python/builtins/objects/ints/PInt.java | 5 +- .../objects/iterator/IteratorBuiltins.java | 48 ++-- .../objects/iterator/IteratorNodes.java | 8 +- .../objects/iterator/PZipBuiltins.java | 10 +- .../iterator/SentinelIteratorBuiltins.java | 6 +- .../objects/itertools/ChainBuiltins.java | 14 +- .../itertools/CombinationsBuiltins.java | 19 +- .../objects/itertools/CycleBuiltins.java | 12 +- .../objects/itertools/DropwhileBuiltins.java | 4 +- .../objects/itertools/GroupByBuiltins.java | 4 +- .../objects/itertools/GrouperBuiltins.java | 6 +- .../objects/itertools/IsliceBuiltins.java | 13 +- .../objects/itertools/PTeeDataObject.java | 4 +- .../objects/itertools/PairwiseBuiltins.java | 4 +- .../itertools/PermutationsBuiltins.java | 17 +- .../objects/itertools/ProductBuiltins.java | 8 +- .../objects/itertools/RepeatBuiltins.java | 9 +- .../objects/itertools/TakewhileBuiltins.java | 4 +- .../objects/itertools/TeeBuiltins.java | 14 +- .../itertools/TeeDataObjectBuiltins.java | 12 +- .../objects/itertools/ZipLongestBuiltins.java | 10 +- .../builtins/objects/list/ListBuiltins.java | 34 +-- .../mappingproxy/MappingproxyBuiltins.java | 4 +- .../memoryview/MemoryViewBuiltins.java | 108 +++---- .../objects/memoryview/MemoryViewNodes.java | 49 ++-- .../objects/memoryview/PMemoryView.java | 28 +- .../method/AbstractBuiltinMethodBuiltins.java | 12 +- .../method/AbstractMethodBuiltins.java | 12 +- .../BuiltinFunctionOrMethodBuiltins.java | 4 +- .../objects/method/ClassmethodBuiltins.java | 8 +- .../method/DecoratedMethodBuiltins.java | 4 +- .../method/InstancemethodBuiltins.java | 4 +- .../objects/method/MethodBuiltins.java | 8 +- .../objects/method/StaticmethodBuiltins.java | 6 +- .../builtins/objects/mmap/MMapBuiltins.java | 86 +++--- .../objects/module/ModuleBuiltins.java | 28 +- .../objects/module/ModuleGetNameNode.java | 6 +- .../namespace/SimpleNamespaceBuiltins.java | 10 +- .../objects/object/ObjectBuiltins.java | 36 ++- .../builtins/objects/object/ObjectNodes.java | 48 ++-- .../ordereddict/OrderedDictBuiltins.java | 22 +- .../OrderedDictIteratorBuiltins.java | 6 +- .../posix/ScandirIteratorBuiltins.java | 6 +- .../objects/property/PropertyBuiltins.java | 8 +- .../objects/queue/SimpleQueueBuiltins.java | 24 +- .../objects/random/RandomBuiltins.java | 14 +- .../builtins/objects/range/RangeBuiltins.java | 36 +-- .../builtins/objects/range/RangeNodes.java | 6 +- .../referencetype/ReferenceTypeBuiltins.java | 8 +- .../objects/reversed/ReversedBuiltins.java | 16 +- .../builtins/objects/set/SetBuiltins.java | 12 +- .../python/builtins/objects/set/SetNodes.java | 4 +- .../builtins/objects/slice/PObjectSlice.java | 4 +- .../python/builtins/objects/slice/PSlice.java | 6 +- .../builtins/objects/slice/SliceBuiltins.java | 8 +- .../builtins/objects/slice/SliceNodes.java | 36 +-- .../objects/socket/SocketBuiltins.java | 56 ++-- .../builtins/objects/socket/SocketNodes.java | 52 ++-- .../objects/ssl/MemoryBIOBuiltins.java | 4 +- .../objects/ssl/SSLCipherSelector.java | 6 +- .../objects/ssl/SSLContextBuiltins.java | 90 +++--- .../objects/ssl/SSLOperationNode.java | 10 +- .../objects/ssl/SSLSocketBuiltins.java | 22 +- .../builtins/objects/str/StringBuiltins.java | 76 ++--- .../builtins/objects/str/StringNodes.java | 45 +-- .../objects/str/TemplateFormatter.java | 40 +-- .../objects/struct/StructBuiltins.java | 38 +-- .../builtins/objects/struct/StructNodes.java | 65 +++-- .../struct/StructUnpackIteratorBuiltins.java | 12 +- .../objects/superobject/SuperBuiltins.java | 48 ++-- .../builtins/objects/thread/LockBuiltins.java | 18 +- .../objects/thread/RLockBuiltins.java | 4 +- .../objects/thread/ThreadLocalBuiltins.java | 10 +- .../tokenize/TokenizerIterBuiltins.java | 4 +- .../objects/traceback/TracebackBuiltins.java | 8 +- .../objects/tuple/StructSequence.java | 22 +- .../builtins/objects/tuple/TupleBuiltins.java | 14 +- .../objects/tuple/TupleGetterBuiltins.java | 12 +- .../objects/type/PythonBuiltinClass.java | 4 +- .../objects/type/PythonManagedClass.java | 17 +- .../builtins/objects/type/TypeBuiltins.java | 161 +++++------ .../builtins/objects/type/TypeNodes.java | 93 +++---- .../objects/type/slots/TpSlotDescrGet.java | 13 +- .../objects/type/slots/TpSlotDescrSet.java | 10 +- .../objects/type/slots/TpSlotInquiry.java | 4 +- .../objects/type/slots/TpSlotLen.java | 25 +- .../type/slots/TpSlotMpAssSubscript.java | 8 +- .../objects/type/slots/TpSlotSetAttr.java | 8 +- .../objects/type/slots/TpSlotSqAssItem.java | 8 +- .../objects/types/GenericAliasBuiltins.java | 8 +- .../types/GenericAliasIteratorBuiltins.java | 3 +- .../objects/types/GenericTypeNodes.java | 7 +- .../objects/types/UnionTypeBuiltins.java | 10 +- .../graal/python/compiler/CodeUnit.java | 9 +- .../graal/python/compiler/Unparser.java | 4 +- .../oracle/graal/python/lib/GetNextNode.java | 10 +- .../python/lib/PyArgCheckPositionalNode.java | 12 +- .../lib/PyConvertOptionalToSizeNode.java | 6 +- .../graal/python/lib/PyDictDelItem.java | 4 +- .../graal/python/lib/PyFloatAsDoubleNode.java | 8 +- .../graal/python/lib/PyFloatFromString.java | 14 +- .../graal/python/lib/PyImportGetModule.java | 6 +- .../graal/python/lib/PyIterNextNode.java | 4 +- .../graal/python/lib/PyLongAsDoubleNode.java | 9 +- .../graal/python/lib/PyLongAsIntNode.java | 9 +- .../graal/python/lib/PyLongAsLongNode.java | 6 +- .../python/lib/PyLongFromDoubleNode.java | 8 +- .../python/lib/PyLongFromUnicodeObject.java | 21 +- .../python/lib/PyMemoryViewFromObject.java | 10 +- .../python/lib/PyNumberAbsoluteNode.java | 4 +- .../graal/python/lib/PyNumberAddNode.java | 7 +- .../graal/python/lib/PyNumberAndNode.java | 8 +- .../graal/python/lib/PyNumberAsSizeNode.java | 10 +- .../graal/python/lib/PyNumberDivmodNode.java | 8 +- .../python/lib/PyNumberFloorDivideNode.java | 8 +- .../graal/python/lib/PyNumberIndexNode.java | 8 +- .../graal/python/lib/PyNumberInvertNode.java | 4 +- .../graal/python/lib/PyNumberLongNode.java | 10 +- .../graal/python/lib/PyNumberLshiftNode.java | 8 +- .../lib/PyNumberMatrixMultiplyNode.java | 8 +- .../python/lib/PyNumberMultiplyNode.java | 13 +- .../python/lib/PyNumberNegativeNode.java | 4 +- .../graal/python/lib/PyNumberOrNode.java | 8 +- .../python/lib/PyNumberPositiveNode.java | 4 +- .../graal/python/lib/PyNumberPowerNode.java | 8 +- .../python/lib/PyNumberRemainderNode.java | 8 +- .../graal/python/lib/PyNumberRshiftNode.java | 9 +- .../python/lib/PyNumberSubtractNode.java | 8 +- .../python/lib/PyNumberTrueDivideNode.java | 8 +- .../graal/python/lib/PyNumberXorNode.java | 8 +- .../graal/python/lib/PyOSFSPathNode.java | 8 +- .../python/lib/PyObjectAsFileDescriptor.java | 16 +- .../graal/python/lib/PyObjectDelItem.java | 5 +- .../oracle/graal/python/lib/PyObjectDir.java | 6 +- .../graal/python/lib/PyObjectFormat.java | 15 +- .../graal/python/lib/PyObjectGetAttr.java | 4 +- .../graal/python/lib/PyObjectGetAttrO.java | 4 +- .../graal/python/lib/PyObjectGetItem.java | 6 +- .../graal/python/lib/PyObjectGetIter.java | 6 +- .../graal/python/lib/PyObjectGetMethod.java | 10 +- .../graal/python/lib/PyObjectHashNode.java | 10 +- .../python/lib/PyObjectReprAsObjectNode.java | 8 +- .../python/lib/PyObjectRichCompareBool.java | 25 +- .../graal/python/lib/PyObjectSetAttr.java | 11 +- .../graal/python/lib/PyObjectSetAttrO.java | 6 +- .../graal/python/lib/PyObjectSetItem.java | 5 +- .../python/lib/PyObjectSizeGenericNode.java | 6 +- .../graal/python/lib/PyObjectSizeNode.java | 10 +- .../python/lib/PyObjectStrAsObjectNode.java | 6 +- .../graal/python/lib/PySequenceConcat.java | 6 +- .../python/lib/PySequenceDelItemNode.java | 6 +- .../python/lib/PySequenceGetItemNode.java | 11 +- .../python/lib/PySequenceIterSearchNode.java | 12 +- .../python/lib/PySequenceSetItemNode.java | 6 +- .../graal/python/lib/PySequenceSizeNode.java | 9 +- .../python/lib/PyTimeFromObjectNode.java | 20 +- .../python/lib/PyTraceBackPrintNode.java | 6 +- .../graal/python/lib/PyTupleSizeNode.java | 7 +- .../python/lib/PyUnicodeAsEncodedString.java | 8 +- .../graal/python/lib/PyUnicodeDecode.java | 6 +- .../python/lib/PyUnicodeFSDecoderNode.java | 4 +- .../lib/PyUnicodeFromEncodedObject.java | 9 +- .../python/lib/PyUnicodeReadCharNode.java | 10 +- .../oracle/graal/python/nodes/PRaiseNode.java | 248 +++++++---------- .../nodes/argument/CreateArgumentsNode.java | 48 ++-- .../keywords/ExpandKeywordStarargsNode.java | 8 +- .../keywords/MappingToKeywordsNode.java | 4 +- .../ExecutePositionalStarargsNode.java | 10 +- .../ArrowSchemaReleaseCallbackNode.java | 12 +- .../VectorArrowArrayReleaseCallback.java | 12 +- .../WriteAttributeToObjectNode.java | 30 +- .../python/nodes/builtins/ListNodes.java | 5 +- .../nodes/bytecode/AbstractKwargsNode.java | 11 +- .../python/nodes/bytecode/ForIterINode.java | 4 +- .../python/nodes/bytecode/ForIterONode.java | 4 +- .../python/nodes/bytecode/GetAIterNode.java | 8 +- .../python/nodes/bytecode/GetANextNode.java | 6 +- .../python/nodes/bytecode/ImportStarNode.java | 6 +- .../python/nodes/bytecode/KeywordsNode.java | 8 +- .../nodes/bytecode/KwargsMergeNode.java | 8 +- .../python/nodes/bytecode/MatchClassNode.java | 16 +- .../python/nodes/bytecode/MatchKeysNode.java | 16 +- .../nodes/bytecode/PBytecodeRootNode.java | 32 +-- .../nodes/bytecode/PRaiseCachedNode.java | 73 +++++ .../python/nodes/bytecode/PrintExprNode.java | 4 +- .../python/nodes/bytecode/RaiseNode.java | 32 +-- .../python/nodes/bytecode/SetupAwithNode.java | 6 +- .../python/nodes/bytecode/SetupWithNode.java | 6 +- .../python/nodes/bytecode/UnpackExNode.java | 14 +- .../nodes/bytecode/UnpackSequenceNode.java | 12 +- .../graal/python/nodes/call/CallNode.java | 20 +- .../call/special/AbstractCallMethodNode.java | 2 +- .../LookupAndCallReversibleBinaryNode.java | 11 +- .../python/nodes/classes/IsSubtypeNode.java | 8 +- .../nodes/exception/ExceptMatchNode.java | 21 +- .../nodes/expression/BinaryArithmetic.java | 6 +- .../expression/BinaryComparisonNode.java | 12 +- .../expression/CastToListExpressionNode.java | 2 +- .../nodes/expression/InplaceArithmetic.java | 8 +- .../nodes/expression/TernaryArithmetic.java | 10 +- .../nodes/expression/UnaryArithmetic.java | 6 +- .../nodes/frame/ReadGlobalOrBuiltinNode.java | 14 +- .../builtins/PythonVarargsBuiltinNode.java | 27 -- .../nodes/function/builtins/WrapTpNew.java | 17 +- .../clinic/CodePointConversionNode.java | 6 +- .../clinic/SliceIndexConversionNode.java | 6 +- .../clinic/TruffleStringConverterNode.java | 6 +- .../builtins/clinic/TupleConversionNode.java | 6 +- .../clinic/WritableBufferConversionNode.java | 4 +- .../interop/GetInteropBehaviorValueNode.java | 30 +- .../nodes/object/GetDictIfExistsNode.java | 2 +- .../nodes/object/GetOrCreateDictNode.java | 2 +- .../nodes/object/GetRegisteredClassNode.java | 2 +- .../nodes/statement/AbstractImportNode.java | 28 +- .../python/nodes/util/BadOPCodeNode.java | 4 +- .../python/nodes/util/CastToByteNode.java | 39 +-- .../nodes/util/CastToJavaBigIntegerNode.java | 6 +- .../nodes/util/CastToJavaBooleanNode.java | 4 +- .../python/nodes/util/CastToJavaByteNode.java | 14 +- .../nodes/util/CastToJavaIntExactNode.java | 16 +- .../nodes/util/CastToJavaLongExactNode.java | 12 +- .../python/nodes/util/CastToJavaLongNode.java | 4 +- .../nodes/util/CastToJavaShortNode.java | 14 +- .../util/CastToJavaUnsignedLongNode.java | 17 +- .../nodes/util/CoerceToComplexNode.java | 4 +- .../graal/python/runtime/NFIPosixSupport.java | 4 +- .../graal/python/runtime/PythonContext.java | 4 +- .../formatting/BytesFormatProcessor.java | 12 +- .../runtime/formatting/FormatProcessor.java | 20 +- .../runtime/formatting/IntegerFormatter.java | 6 +- .../runtime/formatting/InternalFormat.java | 20 +- .../formatting/StringFormatProcessor.java | 6 +- .../graal/python/runtime/object/PFactory.java | 18 +- .../storage/ForeignSequenceStorage.java | 26 +- .../graal/python/util/NumericSupport.java | 12 +- .../oracle/graal/python/util/PythonUtils.java | 2 +- 496 files changed, 5414 insertions(+), 5461 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PRaiseCachedNode.java diff --git a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py index 465666c897..0b1c8e852f 100755 --- a/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py +++ b/graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py @@ -44,7 +44,6 @@ from asdl import java_file from asdl import model - SST_PACKAGE = 'com.oracle.graal.python.pegparser.sst' AST_PACKAGE = 'com.oracle.graal.python.builtins.modules.ast' @@ -338,6 +337,7 @@ def visit_module(self, module: model.Module): @staticmethod def emit_imports(module, emitter): emitter.println() + emitter.println('import com.oracle.truffle.api.nodes.Node;') emitter.println('import com.oracle.graal.python.builtins.objects.PNone;') emitter.println('import com.oracle.graal.python.pegparser.sst.ConstantValue;') top_level_class_names = [t.name.java for t in module.types] @@ -346,8 +346,8 @@ def emit_imports(module, emitter): emitter.println('import com.oracle.graal.python.pegparser.tokenizer.SourceRange;') def emit_constructor(self, emitter: java_file.Emitter): - with emitter.define(f'{self.CLASS_NAME}({AstStateGenerator.CLASS_NAME} state)'): - emitter.println('super(state);') + with emitter.define(f'{self.CLASS_NAME}(Node node, {AstStateGenerator.CLASS_NAME} state)'): + emitter.println('super(node, state);') @staticmethod def visit_enum(c: model.Enum, emitter: java_file.Emitter): diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index f7ecc2a1ce..328fe43789 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -607,7 +607,7 @@ protected CallTarget parse(ParsingRequest request) { } if (MIME_TYPE_BYTECODE.equals(source.getMimeType())) { byte[] bytes = source.getBytes().toByteArray(); - CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(context, bytes); + CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(null, context, bytes); boolean internal = shouldMarkSourceInternal(context); // The original file path should be passed as the name String name = source.getName(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java index 18b4c9bb56..51a5c1bbc3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -105,7 +105,7 @@ static Object init(Object object, return PNone.NONE; } if ((val & COLLECTION_FLAGS) == COLLECTION_FLAGS) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.ABC_FLAGS_CANNOT_BE_SEQUENCE_AND_MAPPING); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ABC_FLAGS_CANNOT_BE_SEQUENCE_AND_MAPPING); } long tpFlags = TypeNodes.GetTypeFlagsNode.getUncached().execute(object); tpFlags |= (val & COLLECTION_FLAGS); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java index fcf8ecaef9..7cb4676972 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java @@ -130,10 +130,10 @@ static Object array2(VirtualFrame frame, Object cls, Object[] args, PKeyword[] k @Cached IsBuiltinClassExactProfile isNotSubtypeProfile, @Cached CastToTruffleStringCheckedNode cast, @Cached ArrayNodeInternal arrayNodeInternal, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { if (isNotSubtypeProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.PArray)) { if (kwargs.length != 0) { - throw raise.get(inliningTarget).raise(TypeError, S_TAKES_NO_KEYWORD_ARGS, "array.array()"); + throw raise.raise(inliningTarget, TypeError, S_TAKES_NO_KEYWORD_ARGS, "array.array()"); } } Object initializer = hasInitializerProfile.profile(inliningTarget, args.length == 2) ? args[1] : PNone.NO_VALUE; @@ -144,9 +144,9 @@ static Object array2(VirtualFrame frame, Object cls, Object[] args, PKeyword[] k @SuppressWarnings("unused") Object error(Object cls, Object[] args, PKeyword[] kwargs) { if (args.length < 2) { - throw raise(TypeError, S_TAKES_AT_LEAST_D_ARGUMENTS_D_GIVEN, T_ARRAY, 2, args.length); + throw PRaiseNode.raiseStatic(this, TypeError, S_TAKES_AT_LEAST_D_ARGUMENTS_D_GIVEN, T_ARRAY, 2, args.length); } else { - throw raise(TypeError, S_TAKES_AT_MOST_D_ARGUMENTS_D_GIVEN, T_ARRAY, 3, args.length); + throw PRaiseNode.raiseStatic(this, TypeError, S_TAKES_AT_MOST_D_ARGUMENTS_D_GIVEN, T_ARRAY, 3, args.length); } } @@ -190,7 +190,7 @@ static PArray arrayWithRangeInitializer(Node inliningTarget, Object cls, Truffle array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format, range.getIntLength()); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } int start = range.getIntStart(); @@ -223,10 +223,10 @@ static PArray arrayWithStringInitializer(VirtualFrame frame, Node inliningTarget @Bind PythonLanguage language, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(inline = false) ArrayBuiltins.FromUnicodeNode fromUnicodeNode, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { BufferFormat format = getFormatCheckedNode.execute(inliningTarget, typeCode); if (format != BufferFormat.UNICODE) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_USE_STR_TO_INITIALIZE_ARRAY, typeCode); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_USE_STR_TO_INITIALIZE_ARRAY, typeCode); } PArray array = PFactory.createArray(language, cls, getInstanceShape.execute(cls), typeCode, format); fromUnicodeNode.execute(frame, array, initializer); @@ -251,7 +251,7 @@ static PArray arrayArrayInitializer(VirtualFrame frame, Node inliningTarget, Obj return array; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -275,7 +275,7 @@ static PArray arraySequenceInitializer(VirtualFrame frame, Node inliningTarget, return array; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -310,7 +310,7 @@ static PArray arrayIteratorInitializer(VirtualFrame frame, Node inliningTarget, ensureCapacityNode.execute(inliningTarget, array, length); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } putValueNode.execute(frame, inliningTarget, array, length - 1, nextValue); } @@ -328,14 +328,14 @@ abstract static class GetFormatCheckedNode extends Node { static BufferFormat get(Node inliningTarget, TruffleString typeCode, @Cached(inline = false) TruffleString.CodePointLengthNode lengthNode, @Cached(inline = false) TruffleString.CodePointAtIndexNode atIndexNode, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached(value = "createIdentityProfile()", inline = false) ValueProfile valueProfile) { if (lengthNode.execute(typeCode, TS_ENCODING) != 1) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.ARRAY_ARG_1_MUST_BE_UNICODE); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.ARRAY_ARG_1_MUST_BE_UNICODE); } BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode); if (format == null) { - throw raise.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_TYPECODE); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.BAD_TYPECODE); } return valueProfile.profile(format); } @@ -363,10 +363,10 @@ static Object reconstructCached(VirtualFrame frame, Object arrayType, TruffleStr @Exclusive @Cached TruffleString.CodePointLengthNode lengthNode, @Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode, @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode); if (format == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_TYPECODE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BAD_TYPECODE); } return doReconstruct(frame, inliningTarget, arrayType, typeCode, cachedCode, bytes, callDecode, fromBytesNode, fromUnicodeNode, isSubtypeNode, byteSwapNode, formatProfile.profile(format), getInstanceShape, raiseNode); @@ -383,10 +383,10 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty @Exclusive @Cached TruffleString.CodePointLengthNode lengthNode, @Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode, @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode); if (format == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_TYPECODE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BAD_TYPECODE); } return doReconstruct(frame, inliningTarget, arrayType, typeCode, mformatCode, bytes, callDecode, fromBytesNode, fromUnicodeNode, isSubtypeNode, byteSwapNode, format, getInstanceShape, raiseNode); @@ -395,9 +395,9 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty private static Object doReconstruct(VirtualFrame frame, Node inliningTarget, Object arrayType, TruffleString typeCode, int mformatCode, PBytes bytes, PyObjectCallMethodObjArgs callDecode, ArrayBuiltins.FromBytesNode fromBytesNode, ArrayBuiltins.FromUnicodeNode fromUnicodeNode, IsSubtypeNode isSubtypeNode, ArrayBuiltins.ByteSwapNode byteSwapNode, BufferFormat format, - TypeNodes.GetInstanceShape getInstanceShape, PRaiseNode.Lazy raiseNode) { + TypeNodes.GetInstanceShape getInstanceShape, PRaiseNode raiseNode) { if (!isSubtypeNode.execute(frame, arrayType, PythonBuiltinClassType.PArray)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_NOT_SUBTYPE_OF_ARRAY, arrayType); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_NOT_SUBTYPE_OF_ARRAY, arrayType); } MachineFormat machineFormat = MachineFormat.fromCode(mformatCode); if (machineFormat != null) { @@ -420,15 +420,15 @@ private static Object doReconstruct(VirtualFrame frame, Node inliningTarget, Obj } return array; } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.THIRD_ARG_MUST_BE_A_VALID_MACHINE_CODE_FMT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.THIRD_ARG_MUST_BE_A_VALID_MACHINE_CODE_FMT); } } @Specialization(guards = "!isPBytes(value)") @SuppressWarnings("unused") static Object error(Object arrayType, TruffleString typeCode, int mformatCode, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.FOURTH_ARG_SHOULD_BE_BYTES, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.FOURTH_ARG_SHOULD_BE_BYTES, value); } protected static boolean isPBytes(Object obj) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java index b0b39be693..c6a9900c1c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AsyncioModuleBuiltins.java @@ -99,7 +99,7 @@ static Object getCurrentLoop( @Cached PRaiseNode raise) { Object eventLoop = context.getThreadState(context.getLanguage(inliningTarget)).getRunningEventLoop(); if (eventLoop == null) { - throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.NO_RUNNING_EVENT_LOOP); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.NO_RUNNING_EVENT_LOOP); } else { return eventLoop; } @@ -189,7 +189,7 @@ public Object enterTask(VirtualFrame frame, PythonModule self, Object loop, Obje if (item == null) { set.execute(frame, inliningTarget, dict, loop, task); } else { - throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANT_ENTER_TASK_ALREADY_RUNNING, task, item); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANT_ENTER_TASK_ALREADY_RUNNING, task, item); } return PNone.NONE; } @@ -210,7 +210,7 @@ public Object leaveTask(VirtualFrame frame, PythonModule self, Object loop, Obje item = PNone.NONE; } if (item != task) { - throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.TASK_NOT_ENTERED, task, item); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.TASK_NOT_ENTERED, task, item); } del.execute(frame, inliningTarget, dict, loop); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java index 0511a7b818..aae17200d2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BinasciiModuleBuiltins.java @@ -154,9 +154,9 @@ static Object asciiString(TruffleString value, @Specialization(guards = "!isAscii(value, getCodeRangeNode)") static Object nonAsciiString(@SuppressWarnings("unused") TruffleString value, - @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.STRING_ARG_SHOULD_CONTAIN_ONLY_ASCII); + @Bind("this") Node inliningTarget, + @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.STRING_ARG_SHOULD_CONTAIN_ONLY_ASCII); } @Specialization @@ -164,20 +164,19 @@ static Object string(PString value, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode cast, @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, - @Cached InlinedConditionProfile asciiProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached InlinedConditionProfile asciiProfile) { TruffleString ts = cast.execute(inliningTarget, value); if (asciiProfile.profile(inliningTarget, isAscii(ts, getCodeRangeNode))) { return asciiString(ts, getCodeRangeNode); } else { - return nonAsciiString(ts, getCodeRangeNode, raiseNode.get(inliningTarget)); + return nonAsciiString(ts, inliningTarget, getCodeRangeNode); } } @Fallback static Object error(@SuppressWarnings("unused") Object value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ARG_SHOULD_BE_BYTES_BUFFER_OR_ASCII_NOT_P, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ARG_SHOULD_BE_BYTES_BUFFER_OR_ASCII_NOT_P, value); } @ClinicConverterFactory @@ -227,19 +226,19 @@ private ByteSequenceStorage b64decode(byte[] data, int dataLen, boolean strictMo } else if (c == '=') { padding++; } else if (strictMode) { - throw PRaiseNode.raiseUncached(this, BinasciiError, ErrorMessages.ONLY_BASE64_DATA_IS_ALLOWED); + throw PRaiseNode.raiseStatic(this, BinasciiError, ErrorMessages.ONLY_BASE64_DATA_IS_ALLOWED); } } int expectedPadding = 0; if (base64chars % 4 == 1) { - throw PRaiseNode.raiseUncached(this, BinasciiError, ErrorMessages.INVALID_BASE64_ENCODED_STRING); + throw PRaiseNode.raiseStatic(this, BinasciiError, ErrorMessages.INVALID_BASE64_ENCODED_STRING); } else if (base64chars % 4 == 2) { expectedPadding = 2; } else if (base64chars % 4 == 3) { expectedPadding = 1; } if (padding < expectedPadding) { - throw PRaiseNode.raiseUncached(this, BinasciiError, ErrorMessages.INCORRECT_PADDING); + throw PRaiseNode.raiseStatic(this, BinasciiError, ErrorMessages.INCORRECT_PADDING); } // Find the end of the expected padding, if any int decodeLen = lastBase64Char + 1; @@ -263,7 +262,7 @@ private ByteSequenceStorage b64decode(byte[] data, int dataLen, boolean strictMo ByteBuffer result = decoder.decode(ByteBuffer.wrap(data, 0, decodeLen)); return new ByteSequenceStorage(result.array(), result.limit()); } catch (IllegalArgumentException e) { - throw PRaiseNode.raiseUncached(this, BinasciiError, e); + throw PRaiseNode.raiseStatic(this, BinasciiError, e); } } @@ -293,7 +292,7 @@ PBytes a2b(VirtualFrame frame, Object buffer, @TruffleBoundary private byte[] a2b(byte[] bytes, int length) { if (length % 2 != 0) { - throw PRaiseNode.raiseUncached(this, BinasciiError, ErrorMessages.ODD_LENGTH_STRING); + throw PRaiseNode.raiseStatic(this, BinasciiError, ErrorMessages.ODD_LENGTH_STRING); } byte[] output = new byte[length / 2]; for (int i = 0; i < length / 2; i++) { @@ -310,7 +309,7 @@ private int digitValue(char b) { } else if (b >= 'A' && b <= 'F') { return b - 'A' + 10; } else { - throw PRaiseNode.raiseUncached(this, BinasciiError, ErrorMessages.NON_HEX_DIGIT_FOUND); + throw PRaiseNode.raiseStatic(this, BinasciiError, ErrorMessages.NON_HEX_DIGIT_FOUND); } } @@ -331,7 +330,7 @@ private PBytes b2a(byte[] data, int lenght, int newline, PythonLanguage language try { encoded = Base64.getEncoder().encode(ByteBuffer.wrap(data, 0, lenght)); } catch (IllegalArgumentException e) { - throw PRaiseNode.raiseUncached(this, BinasciiError, e); + throw PRaiseNode.raiseStatic(this, BinasciiError, e); } if (newline != 0) { byte[] encodedWithNL = Arrays.copyOf(encoded.array(), encoded.limit() + 1); @@ -373,10 +372,10 @@ static PBytes b2a(VirtualFrame frame, Object buffer, Object sep, int bytesPerSep @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (sep != PNone.NO_VALUE || bytesPerSep != 1) { // TODO implement sep and bytes_per_sep - throw raiseNode.get(inliningTarget).raise(NotImplementedError); + throw raiseNode.raise(inliningTarget, NotImplementedError); } try { return b2a(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), language); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java index 985c7f9d0d..5f86503a3b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java @@ -259,6 +259,7 @@ import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; @@ -321,7 +322,7 @@ static Object doCallBytes(VirtualFrame frame, Object cls, Object source, PNone e @Cached PyBytesCheckNode check, @Exclusive @Cached BytesNodes.BytesInitNode bytesInitNode, @Exclusive @Cached CreateBytes createBytes, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object bytesMethod = lookupBytes.execute(frame, getClassNode.execute(inliningTarget, source), source); if (hasBytes.profile(inliningTarget, bytesMethod != PNone.NO_VALUE)) { Object bytes = callBytes.executeObject(frame, bytesMethod, source); @@ -332,7 +333,7 @@ static Object doCallBytes(VirtualFrame frame, Object cls, Object source, PNone e return createBytes.execute(inliningTarget, cls, toBytesNode.execute(frame, bytes)); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, bytes); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, bytes); } } return createBytes.execute(inliningTarget, cls, bytesInitNode.execute(frame, inliningTarget, source, encoding, errors)); @@ -506,7 +507,7 @@ Object complexFromDouble(VirtualFrame frame, Object cls, PFloat real, @SuppressW @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode isBuiltinObjectProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return complexFromObject(frame, cls, real, imag, inliningTarget, createComplexNode, canBeDoubleNode, asDoubleNode, isComplexType, isResultComplexType, isPrimitiveProfile, isBuiltinObjectProfile, raiseNode); @@ -536,7 +537,7 @@ Object complexFromLong(VirtualFrame frame, Object cls, PInt real, @SuppressWarni @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode complexCheck, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return complexFromObject(frame, cls, real, imag, inliningTarget, createComplexNode, canBeDoubleNode, asDoubleNode, isComplexType, isResultComplexType, isPrimitiveProfile, complexCheck, raiseNode); } @@ -551,13 +552,13 @@ Object complexFromObject(VirtualFrame frame, Object cls, Object number, @Suppres @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, @Shared("isPrimitive") @Cached IsBuiltinClassExactProfile isPrimitiveProfile, @Shared("isBuiltinObj") @Cached PyComplexCheckExactNode complexCheck, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex value = getComplexNumberFromObject(frame, number, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { if (canBeDoubleNode.execute(inliningTarget, number)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, number), 0.0); } else { - throw raiseFirstArgError(number, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(number, inliningTarget, raiseNode); } } if (isPrimitiveProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.PComplex)) { @@ -598,13 +599,13 @@ Object complexFromComplexLong(VirtualFrame frame, Object cls, Object one, long t @Shared("floatAsDouble") @Cached PyFloatAsDoubleNode asDoubleNode, @Shared("isComplex") @Cached PyComplexCheckExactNode isComplexType, @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex value = getComplexNumberFromObject(frame, one, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { if (canBeDoubleNode.execute(inliningTarget, one)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, one), two); } else { - throw raiseFirstArgError(one, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(one, inliningTarget, raiseNode); } } return createComplexNode.execute(inliningTarget, cls, value.getReal(), value.getImag() + two); @@ -618,13 +619,13 @@ Object complexFromComplexDouble(VirtualFrame frame, Object cls, Object one, doub @Shared("floatAsDouble") @Cached PyFloatAsDoubleNode asDoubleNode, @Shared("isComplex") @Cached PyComplexCheckExactNode isComplexType, @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex value = getComplexNumberFromObject(frame, one, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { if (canBeDoubleNode.execute(inliningTarget, one)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, one), two); } else { - throw raiseFirstArgError(one, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(one, inliningTarget, raiseNode); } } return createComplexNode.execute(inliningTarget, cls, value.getReal(), value.getImag() + two); @@ -638,13 +639,13 @@ Object complexFromComplexPInt(VirtualFrame frame, Object cls, Object one, PInt t @Shared("floatAsDouble") @Cached PyFloatAsDoubleNode asDoubleNode, @Shared("isComplex") @Cached PyComplexCheckExactNode isComplexType, @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex value = getComplexNumberFromObject(frame, one, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { if (canBeDoubleNode.execute(inliningTarget, one)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, one), two.doubleValueWithOverflow(this)); } else { - throw raiseFirstArgError(one, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(one, inliningTarget, raiseNode); } } return createComplexNode.execute(inliningTarget, cls, value.getReal(), value.getImag() + two.doubleValueWithOverflow(this)); @@ -658,13 +659,13 @@ Object complexFromComplexComplex(VirtualFrame frame, Object cls, Object one, PCo @Shared("floatAsDouble") @Cached PyFloatAsDoubleNode asDoubleNode, @Shared("isComplex") @Cached PyComplexCheckExactNode isComplexType, @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex value = getComplexNumberFromObject(frame, one, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (value == null) { if (canBeDoubleNode.execute(inliningTarget, one)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, one) - two.getImag(), two.getReal()); } else { - throw raiseFirstArgError(one, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(one, inliningTarget, raiseNode); } } return createComplexNode.execute(inliningTarget, cls, value.getReal() - two.getImag(), value.getImag() + two.getReal()); @@ -679,7 +680,7 @@ Object complexFromComplexObject(VirtualFrame frame, Object cls, Object one, Obje @Shared("floatAsDouble") @Cached PyFloatAsDoubleNode asDoubleNode, @Shared("isComplex") @Cached PyComplexCheckExactNode isComplexType, @Shared("isComplexResult") @Cached PyComplexCheckExactNode isResultComplexType, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PComplex oneValue = getComplexNumberFromObject(frame, one, inliningTarget, isComplexType, isResultComplexType, raiseNode); if (canBeDoubleNode.execute(inliningTarget, two)) { double twoValue = asDoubleNode.execute(frame, inliningTarget, two); @@ -687,12 +688,12 @@ Object complexFromComplexObject(VirtualFrame frame, Object cls, Object one, Obje if (canBeDoubleNode.execute(inliningTarget, one)) { return createComplexNode.execute(inliningTarget, cls, asDoubleNode.execute(frame, inliningTarget, one), twoValue); } else { - throw raiseFirstArgError(one, raiseNode.get(inliningTarget)); + throw raiseFirstArgError(one, inliningTarget, raiseNode); } } return createComplexNode.execute(inliningTarget, cls, oneValue.getReal(), oneValue.getImag() + twoValue); } else { - throw raiseSecondArgError(two, raiseNode.get(inliningTarget)); + throw raiseSecondArgError(two, inliningTarget, raiseNode); } } @@ -700,9 +701,9 @@ Object complexFromComplexObject(VirtualFrame frame, Object cls, Object one, Obje Object complexFromString(VirtualFrame frame, Object cls, TruffleString real, Object imaginary, @Bind("this") Node inliningTarget, @Cached TruffleString.ToJavaStringNode toJavaStringNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (imaginary != PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.COMPLEX_CANT_TAKE_ARG); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.COMPLEX_CANT_TAKE_ARG); } return convertStringToComplex(frame, inliningTarget, toJavaStringNode.execute(real), cls, real, raiseNode); } @@ -711,9 +712,9 @@ Object complexFromString(VirtualFrame frame, Object cls, TruffleString real, Obj Object complexFromString(VirtualFrame frame, Object cls, PString real, Object imaginary, @Bind("this") Node inliningTarget, @Cached CastToJavaStringNode castToStringNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (imaginary != PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.COMPLEX_CANT_TAKE_ARG); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.COMPLEX_CANT_TAKE_ARG); } return convertStringToComplex(frame, inliningTarget, castToStringNode.execute(real), cls, real, raiseNode); } @@ -734,16 +735,16 @@ private WarnNode getWarnNode() { return warnNode; } - private static PException raiseFirstArgError(Object x, PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_NUMBER, "complex() first", x); + private static PException raiseFirstArgError(Object x, Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_NUMBER, "complex() first", x); } - private static PException raiseSecondArgError(Object x, PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARG_MUST_BE_NUMBER, "complex() second", x); + private static PException raiseSecondArgError(Object x, Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_MUST_BE_NUMBER, "complex() second", x); } private PComplex getComplexNumberFromObject(VirtualFrame frame, Object object, Node inliningTarget, - PyComplexCheckExactNode isComplexType, PyComplexCheckExactNode isResultComplexType, PRaiseNode.Lazy raiseNode) { + PyComplexCheckExactNode isComplexType, PyComplexCheckExactNode isResultComplexType, PRaiseNode raiseNode) { if (isComplexType.execute(inliningTarget, object)) { return (PComplex) object; } else { @@ -756,7 +757,7 @@ private PComplex getComplexNumberFromObject(VirtualFrame frame, Object object, N } return (PComplex) result; } else if (result != PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.COMPLEX_RETURNED_NON_COMPLEX, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.COMPLEX_RETURNED_NON_COMPLEX, result); } if (object instanceof PComplex) { // the class extending PComplex but doesn't have __complex__ method @@ -769,12 +770,12 @@ private PComplex getComplexNumberFromObject(VirtualFrame frame, Object object, N @Fallback @SuppressWarnings("unused") static Object complexGeneric(Object cls, Object realObj, Object imaginaryObj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "complex.__new__(X): X", cls); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "complex.__new__(X): X", cls); } // Adapted from CPython's complex_subtype_from_string - private Object convertStringToComplex(VirtualFrame frame, Node inliningTarget, String src, Object cls, Object origObj, PRaiseNode.Lazy raiseNode) { + private Object convertStringToComplex(VirtualFrame frame, Node inliningTarget, String src, Object cls, Object origObj, PRaiseNode raiseNode) { String str = FloatUtils.removeUnicodeAndUnderscores(src); if (str == null) { if (callReprNode == null) { @@ -783,18 +784,18 @@ private Object convertStringToComplex(VirtualFrame frame, Node inliningTarget, S } Object strStr = callReprNode.executeObject(frame, origObj); if (PGuards.isString(strStr)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.COULD_NOT_CONVERT_STRING_TO_COMPLEX, strStr); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COULD_NOT_CONVERT_STRING_TO_COMPLEX, strStr); } else { // During the formatting of "ValueError: invalid literal ..." exception, // CPython attempts to raise "TypeError: __repr__ returned non-string", // which gets later overwitten with the original "ValueError", // but without any message (since the message formatting failed) - throw raiseNode.get(inliningTarget).raise(ValueError); + throw raiseNode.raise(inliningTarget, ValueError); } } Object c = convertStringToComplexOrNull(str, cls); if (c == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.COMPLEX_ARG_IS_MALFORMED_STR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COMPLEX_ARG_IS_MALFORMED_STR); } return c; } @@ -992,8 +993,8 @@ static boolean isIntegerIndex(Object idx) { @Specialization(guards = "!isIntegerIndex(start)") static void enumerate(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object iterable, Object start, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, start); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, start); } } @@ -1072,12 +1073,12 @@ static Object reversed(VirtualFrame frame, Object cls, Object sequence, @Cached PySequenceCheckNode pySequenceCheck, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object sequenceKlass = getClassNode.execute(inliningTarget, sequence); Object reversed = lookupReversed.execute(frame, sequenceKlass, sequence); if (noReversedProfile.profile(inliningTarget, reversed == PNone.NO_VALUE)) { if (!pySequenceCheck.execute(inliningTarget, sequence)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_ISNT_REVERSIBLE, sequence); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_ISNT_REVERSIBLE, sequence); } else { int lengthHint = pySequenceSizeNode.execute(frame, inliningTarget, sequence); return PFactory.createSequenceReverseIterator(language, cls, getInstanceShape.execute(cls), sequence, lengthHint); @@ -1344,15 +1345,15 @@ static Object doWithBase(VirtualFrame frame, Node inliningTarget, Object x, Obje @Cached PyLongFromUnicodeObject longFromUnicode, @Cached BytesNodes.BytesLikeCheck bytesLikeCheck, @Cached PyNumberLongNode.LongFromBufferNode fromBufferNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (x == PNone.NO_VALUE) { missingArgument.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INT_MISSING_STRING_ARGUMENT); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INT_MISSING_STRING_ARGUMENT); } int base = asSizeNode.executeLossy(frame, inliningTarget, baseObj); if ((base != 0 && base < 2) || base > 36) { wrongBase.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INT_BASE_MUST_BE_2_AND_36_OR_0); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INT_BASE_MUST_BE_2_AND_36_OR_0); } if (unicodeCheckNode.execute(inliningTarget, x)) { return longFromUnicode.execute(inliningTarget, x, base); @@ -1360,7 +1361,7 @@ static Object doWithBase(VirtualFrame frame, Node inliningTarget, Object x, Obje return fromBufferNode.execute(frame, x, base); } cannotConvert.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INT_CANT_CONVERT_STRING_WITH_EXPL_BASE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INT_CANT_CONVERT_STRING_WITH_EXPL_BASE); } } } @@ -1438,7 +1439,7 @@ static PException report(VirtualFrame frame, Object type, int methodCount = sizeNode.execute(frame, inliningTarget, list); callSort.execute(frame, inliningTarget, list, T_SORT); TruffleString joined = cast.execute(inliningTarget, callJoin.execute(frame, inliningTarget, T_COMMA_SPACE, T_JOIN, list)); - throw raiseNode.raise(TypeError, ErrorMessages.CANT_INSTANTIATE_ABSTRACT_CLASS_WITH_ABSTRACT_METHODS, type, methodCount > 1 ? "s" : "", joined); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_INSTANTIATE_ABSTRACT_CLASS_WITH_ABSTRACT_METHODS, type, methodCount > 1 ? "s" : "", joined); } } @@ -1459,12 +1460,12 @@ static void check(Node inliningTarget, Object type, Object[] args, PKeyword[] kw @Cached(parameters = "Init", inline = false) LookupCallableSlotInMRONode lookupInit, @Cached(parameters = "New", inline = false) LookupCallableSlotInMRONode lookupNew, @Cached TypeNodes.CheckCallableIsSpecificBuiltinNode checkSlotIs, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!checkSlotIs.execute(inliningTarget, lookupNew.execute(type), BuiltinConstructorsFactory.ObjectNodeFactory.getInstance())) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NEW_TAKES_ONE_ARG); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NEW_TAKES_ONE_ARG); } if (checkSlotIs.execute(inliningTarget, lookupInit.execute(type), ObjectBuiltinsFactory.InitNodeFactory.getInstance())) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NEW_TAKES_NO_ARGS, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NEW_TAKES_NO_ARGS, type); } } } @@ -1547,7 +1548,7 @@ static Object call(Object cls, @SuppressWarnings("unused") @Fallback Object fallback(Object o, Object[] varargs, PKeyword[] kwargs) { - throw raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "object.__new__(X): X", o); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "object.__new__(X): X", o); } @InliningCutoff @@ -1582,7 +1583,7 @@ static Object doIntStop(Object cls, int stop, @SuppressWarnings("unused") PNone @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doInt(cls, 0, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, raiseNode); } @@ -1591,7 +1592,7 @@ static Object doPintStop(Object cls, PInt stop, @SuppressWarnings("unused") PNon @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doPint(cls, PFactory.createInt(language, BigInteger.ZERO), stop, PFactory.createInt(language, BigInteger.ONE), inliningTarget, language, lenOfRangeNode, raiseNode); } @@ -1605,7 +1606,7 @@ static Object doGenericStop(VirtualFrame frame, Object cls, Object stop, @Suppre @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doGeneric(frame, cls, 0, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, raiseNode); } @@ -1617,7 +1618,7 @@ static Object doIntStartStop(Object cls, int start, int stop, @SuppressWarnings( @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNodeExact, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doInt(cls, start, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, raiseNode); } @@ -1626,7 +1627,7 @@ static Object doPintStartStop(Object cls, PInt start, PInt stop, @SuppressWarnin @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doPint(cls, start, stop, PFactory.createInt(language, BigInteger.ONE), inliningTarget, language, lenOfRangeNode, raiseNode); } @@ -1640,7 +1641,7 @@ static Object doGenericStartStop(VirtualFrame frame, Object cls, Object start, O @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doGeneric(frame, cls, start, stop, 1, inliningTarget, language, exceptionProfile, lenOfRangeNodeExact, createBigRangeNode, cast, overflowProfile, indexNode, raiseNode); } @@ -1652,9 +1653,9 @@ static Object doInt(@SuppressWarnings("unused") Object cls, int start, int stop, @Shared("exceptionProfile") @Cached InlinedBranchProfile exceptionProfile, @Shared("lenOfRangeNodeExact") @Cached LenOfIntRangeNodeExact lenOfRangeNode, @Shared("createBigRangeNode") @Cached RangeNodes.CreateBigRangeNode createBigRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (step == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); + throw raiseNode.raise(inliningTarget, ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); } try { int len = lenOfRangeNode.executeInt(inliningTarget, start, stop, step); @@ -1670,9 +1671,9 @@ static Object doPint(@SuppressWarnings("unused") Object cls, PInt start, PInt st @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared("lenOfRangeNode") @Cached RangeNodes.LenOfRangeNode lenOfRangeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (step.isZero()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); + throw raiseNode.raise(inliningTarget, ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); } BigInteger len = lenOfRangeNode.execute(inliningTarget, start.getValue(), stop.getValue(), step.getValue()); return PFactory.createBigRange(language, start, stop, step, PFactory.createInt(language, len)); @@ -1688,7 +1689,7 @@ static Object doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object c @Shared("cast") @Cached CastToJavaIntExactNode cast, @Shared("overflowProfile") @Cached IsBuiltinObjectProfile overflowProfile, @Shared("indexNode") @Cached PyNumberIndexNode indexNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object lstart = indexNode.execute(frame, inliningTarget, start); Object lstop = indexNode.execute(frame, inliningTarget, stop); Object lstep = indexNode.execute(frame, inliningTarget, step); @@ -1823,12 +1824,12 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi @Exclusive @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = acquireLib.acquireReadonly(obj, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NEED_BYTELIKE_OBJ, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NEED_BYTELIKE_OBJ, obj); } try { // TODO(fa): we should directly call '_codecs.decode' @@ -1841,7 +1842,7 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi } else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) { return result; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.P_S_RETURNED_NON_STRING, bytesObj, "decode", result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.P_S_RETURNED_NON_STRING, bytesObj, "decode", result); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -1883,12 +1884,12 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o @Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode, @Shared @Cached(neverDefault = true) CExtNodes.StringSubtypeNew subtypeNew, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = acquireLib.acquireReadonly(obj, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NEED_BYTELIKE_OBJ, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NEED_BYTELIKE_OBJ, obj); } try { PBytes bytesObj = PFactory.createBytes(PythonLanguage.get(inliningTarget), bufferLib.getCopiedByteArray(buffer)); @@ -1899,7 +1900,7 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o } else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) { return subtypeNew.call(cls, result); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.P_S_RETURNED_NON_STRING, bytesObj, "decode", result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.P_S_RETURNED_NON_STRING, bytesObj, "decode", result); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -1978,8 +1979,8 @@ protected static boolean isSubtypeOfTuple(VirtualFrame frame, IsSubtypeNode isSu @Fallback static PTuple tupleObject(Object cls, @SuppressWarnings("unused") Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } } @@ -2019,17 +2020,17 @@ static PZip zip(VirtualFrame frame, Object cls, Object[] args, PKeyword[] kw, @Cached PyObjectIsTrueNode isTrueNode, @Cached InlinedConditionProfile profile, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (profile.profile(inliningTarget, eqNode.execute(kw[0].getName(), T_STRICT, TS_ENCODING))) { return zip(frame, inliningTarget, cls, args, isTrueNode.execute(frame, kw[0].getValue()), getIter, getInstanceShape); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_IS_AN_INVALID_ARG_FOR_S, kw[0].getName(), T_ZIP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_IS_AN_INVALID_ARG_FOR_S, kw[0].getName(), T_ZIP); } @Specialization(guards = "kw.length != 1") static Object zip(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object[] args, PKeyword[] kw, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.S_TAKES_AT_MOST_ONE_KEYWORD_ARGUMENT_D_GIVEN, T_ZIP, kw.length); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.S_TAKES_AT_MOST_ONE_KEYWORD_ARGUMENT_D_GIVEN, T_ZIP, kw.length); } private static PZip zip(VirtualFrame frame, Node inliningTarget, Object cls, Object[] args, boolean strict, PyObjectGetIter getIter, TypeNodes.GetInstanceShape getInstanceShape) { @@ -2113,8 +2114,8 @@ static PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD @Fallback @SuppressWarnings("unused") static PFunction function(@SuppressWarnings("unused") Object cls, Object code, Object globals, Object name, Object defaultArgs, Object closure, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.FUNC_CONSTRUCTION_NOT_SUPPORTED, cls, code, globals, name, defaultArgs, closure); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.FUNC_CONSTRUCTION_NOT_SUPPORTED, cls, code, globals, name, defaultArgs, closure); } } @@ -2125,8 +2126,8 @@ public abstract static class BuiltinFunctionNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static PFunction function(Object cls, Object method_def, Object def, Object name, Object module, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "method_descriptor"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "method_descriptor"); } } @@ -2136,6 +2137,7 @@ static PFunction function(Object cls, Object method_def, Object def, Object name public abstract static class TypeNode extends PythonVarargsBuiltinNode { @Child private IsSubtypeNode isSubtypeNode; @Child private IsAcceptableBaseNode isAcceptableBaseNode; + private final BranchProfile errorProfile = BranchProfile.create(); public abstract Object execute(VirtualFrame frame, Object cls, Object name, Object bases, Object dict, PKeyword[] kwds); @@ -2144,7 +2146,8 @@ public final Object execute(VirtualFrame frame, Object self, Object[] arguments, if (arguments.length == 3) { return execute(frame, self, arguments[0], arguments[1], arguments[2], keywords); } else { - throw raise(TypeError, ErrorMessages.TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, "type.__new__", 3, arguments.length); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, "type.__new__", 3, arguments.length); } } @@ -2155,7 +2158,8 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, } else if (arguments.length == 3) { return execute(frame, self, arguments[0], arguments[1], arguments[2], keywords); } else { - throw raise(TypeError, ErrorMessages.TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, "type.__new__", 3, arguments.length); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, "type.__new__", 3, arguments.length); } } @@ -2193,9 +2197,9 @@ Object typeNew(VirtualFrame frame, Object cls, Object wName, PTuple bases, PDict @Fallback Object generic(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object name, Object bases, Object namespace, @SuppressWarnings("unused") PKeyword[] kwds) { if (!(bases instanceof PTuple)) { - throw raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "type.__new__()", 2, "tuple", bases); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "type.__new__()", 2, "tuple", bases); } else if (!(namespace instanceof PDict)) { - throw raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "type.__new__()", 3, "dict", bases); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "type.__new__()", 3, "dict", bases); } else { throw CompilerDirectives.shouldNotReachHere("type fallback reached incorrectly"); } @@ -2206,10 +2210,10 @@ private Object calculateMetaclass(VirtualFrame frame, Node inliningTarget, Objec Object winner = cls; for (Object base : getObjectArrayNode.execute(inliningTarget, bases)) { if (!isTypeNode.execute(inliningTarget, base) && lookupMroEntries.execute(frame, inliningTarget, base, T___MRO_ENTRIES__) != PNone.NO_VALUE) { - throw raise(TypeError, ErrorMessages.TYPE_DOESNT_SUPPORT_MRO_ENTRY_RESOLUTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_SUPPORT_MRO_ENTRY_RESOLUTION); } if (!ensureIsAcceptableBaseNode().execute(base)) { - throw raise(TypeError, ErrorMessages.TYPE_IS_NOT_ACCEPTABLE_BASE_TYPE, base); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TYPE_IS_NOT_ACCEPTABLE_BASE_TYPE, base); } Object typ = getClassNode.execute(inliningTarget, base); if (isSubType(frame, winner, typ)) { @@ -2218,7 +2222,7 @@ private Object calculateMetaclass(VirtualFrame frame, Node inliningTarget, Objec winner = typ; continue; } - throw raise(TypeError, ErrorMessages.METACLASS_CONFLICT); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.METACLASS_CONFLICT); } return winner; } @@ -2240,16 +2244,17 @@ public static TypeNode create() { Object typeGeneric(VirtualFrame frame, Object cls, Object name, Object bases, Object dict, PKeyword[] kwds, @Bind("this") Node inliningTarget, @Cached TypeNode nextTypeNode, + @Cached PRaiseNode raiseNode, @Exclusive @Cached IsTypeNode isTypeNode) { if (!(name instanceof TruffleString || name instanceof PString)) { - throw raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 1", name); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 1", name); } else if (!(bases instanceof PTuple)) { - throw raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 2", bases); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 2", bases); } else if (!(dict instanceof PDict)) { - throw raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 3", dict); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 3", dict); } else if (!isTypeNode.execute(inliningTarget, cls)) { // TODO: this is actually allowed, deal with it - throw raise(NotImplementedError, ErrorMessages.CREATING_CLASS_NON_CLS_META_CLS); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.CREATING_CLASS_NON_CLS_META_CLS); } return nextTypeNode.execute(frame, cls, name, bases, dict, kwds); } @@ -2316,8 +2321,8 @@ public abstract static class DictKeysTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_KEYS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_KEYS); } } @@ -2327,8 +2332,8 @@ public abstract static class DictKeysIteratorTypeNode extends PythonBuiltinNode @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_KEYITERATOR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_KEYITERATOR); } } @@ -2338,8 +2343,8 @@ public abstract static class DictValuesTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_VALUES); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_VALUES); } } @@ -2349,8 +2354,8 @@ public abstract static class DictValuesIteratorTypeNode extends PythonBuiltinNod @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_VALUEITERATOR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_VALUEITERATOR); } } @@ -2360,8 +2365,8 @@ public abstract static class DictItemsTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_ITEMS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_ITEMS); } } @@ -2371,8 +2376,8 @@ public abstract static class DictItemsIteratorTypeNode extends PythonBuiltinNode @SuppressWarnings("unused") @Specialization static Object dictKeys(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_ITEMITERATOR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, J_DICT_ITEMITERATOR); } } @@ -2382,8 +2387,8 @@ public abstract static class IteratorTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object iterator(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "iterator"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "iterator"); } } @@ -2393,8 +2398,8 @@ public abstract static class ArrayIteratorTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object iterator(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "arrayiterator"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "arrayiterator"); } } @@ -2404,8 +2409,8 @@ public abstract static class CallableIteratorTypeNode extends PythonBuiltinNode @SuppressWarnings("unused") @Specialization static Object iterator(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "callable_iterator"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "callable_iterator"); } } @@ -2415,8 +2420,8 @@ public abstract static class GeneratorTypeNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object generator(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "generator"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "generator"); } } @@ -2440,11 +2445,11 @@ static Object methodGeneric(@SuppressWarnings("unused") Object cls, Object func, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached PyCallableCheckNode callableCheck, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (callableCheck.execute(inliningTarget, func)) { return PFactory.createMethod(language, self, func); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.FIRST_ARG_MUST_BE_CALLABLE_S, ""); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.FIRST_ARG_MUST_BE_CALLABLE_S, ""); } } } @@ -2464,8 +2469,8 @@ Object method(@SuppressWarnings("unused") Object cls, Object self, PBuiltinFunct public abstract static class FrameTypeNode extends PythonBuiltinNode { @Specialization static Object call( - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(RuntimeError, ErrorMessages.CANNOT_CALL_CTOR_OF, "frame type"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, RuntimeError, ErrorMessages.CANNOT_CALL_CTOR_OF, "frame type"); } } @@ -2490,15 +2495,15 @@ static Object createTraceback(@SuppressWarnings("unused") Object cls, @SuppressW @Specialization(guards = {"!isPTraceback(next)", "!isNone(next)"}) @SuppressWarnings("unused") static Object errorNext(Object cls, Object next, Object frame, Object lasti, Object lineno, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.EXPECTED_TRACEBACK_OBJ_OR_NONE, next); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_TRACEBACK_OBJ_OR_NONE, next); } @Specialization(guards = "!isPFrame(frame)") @SuppressWarnings("unused") static Object errorFrame(Object cls, Object next, Object frame, Object lasti, Object lineno, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.TRACEBACK_TYPE_ARG_MUST_BE_FRAME, frame); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TRACEBACK_TYPE_ARG_MUST_BE_FRAME, frame); } protected static boolean isPFrame(Object obj) { @@ -2565,8 +2570,8 @@ static PCode call(Object cls, Object argcount, Object kwonlyargcount, Object pos Object filename, Object name, Object qualname, Object firstlineno, Object linetable, Object exceptiontable, Object freevars, Object cellvars, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.INVALID_ARGS, "code"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INVALID_ARGS, "code"); } @Override @@ -2672,20 +2677,20 @@ static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Objec @Cached BuiltinClassProfiles.IsBuiltinClassProfile exceptionProfile, @Cached BuiltinClassProfiles.IsBuiltinClassProfile baseExceptionProfile, @Cached TypeNodes.IsSameTypeNode isSameTypeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString message; try { message = castToStringNode.execute(inliningTarget, messageObj); } catch (CannotCastException ex) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "BaseExceptionGroup", 1, "str", messageObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "BaseExceptionGroup", 1, "str", messageObj); } if (!sequenceCheckNode.execute(inliningTarget, exceptionsObj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SECOND_ARGUMENT_EXCEPTIONS_MUST_BE_A_SEQUENCE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SECOND_ARGUMENT_EXCEPTIONS_MUST_BE_A_SEQUENCE); } PTuple exceptionsTuple = toTupleNode.execute(frame, exceptionsObj); Object[] exceptions = toArrayNode.execute(inliningTarget, exceptionsTuple.getSequenceStorage()); if (exceptions.length == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SECOND_ARGUMENT_EXCEPTIONS_MUST_BE_A_NON_EMPTY_SEQUENCE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SECOND_ARGUMENT_EXCEPTIONS_MUST_BE_A_NON_EMPTY_SEQUENCE); } PythonContext context = PythonContext.get(inliningTarget); Object exceptionGroupType = getAttr.execute(inliningTarget, context.getBuiltins(), T_EXCEPTION_GROUP); @@ -2699,7 +2704,7 @@ static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Objec if (baseExceptionProfile.profileClass(inliningTarget, exceptionType, PythonBuiltinClassType.PBaseException)) { nestedBaseExceptions = true; } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ITEM_D_OF_SECOND_ARGUMENT_EXCEPTIONS_IS_NOT_AN_EXCEPTION, i); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ITEM_D_OF_SECOND_ARGUMENT_EXCEPTIONS_IS_NOT_AN_EXCEPTION, i); } } if (isSameTypeNode.execute(inliningTarget, cls, PythonBuiltinClassType.PBaseExceptionGroup)) { @@ -2712,12 +2717,12 @@ static Object doManaged(VirtualFrame frame, Object cls, Object messageObj, Objec } } else if (isSameTypeNode.execute(inliningTarget, cls, exceptionGroupType)) { if (nestedBaseExceptions) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_NEST_BASE_EXCEPTIONS_IN_AN_EXCEPTION_GROUP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_NEST_BASE_EXCEPTIONS_IN_AN_EXCEPTION_GROUP); } } else { /* user-defined subclass */ if (nestedBaseExceptions && exceptionProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.Exception)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_NEST_BASE_EXCEPTIONS_IN_N, cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_NEST_BASE_EXCEPTIONS_IN_N, cls); } } return PFactory.createBaseExceptionGroup(language, cls, getInstanceShape.execute(cls), message, exceptions, new Object[]{messageObj, exceptionsObj}); @@ -2732,19 +2737,19 @@ static Object doMapping(@SuppressWarnings("unused") Object cls, Object obj, @Bind("this") Node inliningTarget, @Cached PyMappingCheckNode mappingCheckNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // descrobject.c mappingproxy_check_mapping() if (!(obj instanceof PList || obj instanceof PTuple) && mappingCheckNode.execute(inliningTarget, obj)) { return PFactory.createMappingproxy(language, obj); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ARG_MUST_BE_S_NOT_P, "mappingproxy()", "mapping", obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ARG_MUST_BE_S_NOT_P, "mappingproxy()", "mapping", obj); } @Specialization(guards = "isNoValue(none)") @SuppressWarnings("unused") static Object doMissing(Object klass, PNone none, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_POS, "mappingproxy()", "mapping", 1); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_POS, "mappingproxy()", "mapping", 1); } } @@ -2752,7 +2757,7 @@ abstract static class DescriptorNode extends PythonBuiltinNode { @TruffleBoundary protected final void denyInstantiationAfterInitialization(TruffleString name) { if (getContext().isCoreInitialized()) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, name); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, name); } } @@ -2975,12 +2980,12 @@ static PMap doit(VirtualFrame frame, Object cls, Object[] args, PKeyword[] keywo @Cached PyObjectGetIter getIter, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "map()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "map()"); } if (args.length < 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MAP_MUST_HAVE_AT_LEAST_TWO_ARGUMENTS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MAP_MUST_HAVE_AT_LEAST_TWO_ARGUMENTS); } PMap map = PFactory.createMap(language, cls, getInstanceShape.execute(cls)); map.setFunction(args[0]); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 35ea14c64c..98b69fb966 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -288,6 +288,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; @@ -594,8 +595,8 @@ static TruffleString doL(Node inliningTarget, long x, TruffleString prefix, int @Specialization @SuppressWarnings("unused") static TruffleString doD(double x, TruffleString prefix, int radix, LongToString longToString, - @Cached(inline = false) PRaiseNode raise) { - throw raise.raiseIntegerInterpretationError(x); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, (Object) x); } @Specialization @@ -626,7 +627,7 @@ static TruffleString doO(VirtualFrame frame, Node inliningTarget, Object x, Truf return doPI((PInt) index, prefix, radix, longToString, fromJavaStringNode); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.NotImplementedError, toTruffleStringUncached("bin/oct/hex with native integer subclasses")); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError, toTruffleStringUncached("bin/oct/hex with native integer subclasses")); } } } @@ -718,11 +719,11 @@ public abstract static class ChrNode extends PythonUnaryClinicBuiltinNode { static TruffleString charFromInt(int arg, @Bind("this") Node inliningTarget, @Cached TruffleString.FromCodePointNode fromCodePointNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (arg >= 0 && arg <= Character.MAX_CODE_POINT) { return fromCodePointNode.execute(arg, TS_ENCODING, true); } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ARG_NOT_IN_RANGE, "chr()", "0x110000"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ARG_NOT_IN_RANGE, "chr()", "0x110000"); } } @@ -793,10 +794,10 @@ public abstract static class EvalNode extends PythonBuiltinNode { @Child private GenericInvokeNode invokeNode = GenericInvokeNode.create(); @Child private GetOrCreateDictNode getOrCreateDictNode; - final void assertNoFreeVars(Node inliningTarget, PCode code, PRaiseNode.Lazy raiseNode) { + final void assertNoFreeVars(Node inliningTarget, PCode code, PRaiseNode raiseNode) { Object[] freeVars = code.getFreeVars(); if (freeVars.length > 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CODE_OBJ_NO_FREE_VARIABLES, getMode()); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CODE_OBJ_NO_FREE_VARIABLES, getMode()); } } @@ -812,7 +813,7 @@ static boolean isAnyNone(Object object) { return object instanceof PNone; } - final PCode createAndCheckCode(VirtualFrame frame, Node inliningTarget, Object source, PRaiseNode.Lazy raiseNode) { + final PCode createAndCheckCode(VirtualFrame frame, Node inliningTarget, Object source, PRaiseNode raiseNode) { PCode code = getCompileNode().compile(frame, source, T_STRING_SOURCE, getMode(), -1, -1); assertNoFreeVars(inliningTarget, code, raiseNode); return code; @@ -854,7 +855,7 @@ Object execInheritGlobalsInheritLocals(VirtualFrame frame, Object source, @Suppr @Exclusive @Cached ReadCallerFrameNode readCallerFrameNode, @Exclusive @Cached CodeNodes.GetCodeCallTargetNode getCt, @Cached GetFrameLocalsNode getFrameLocalsNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PCode code = createAndCheckCode(frame, inliningTarget, source, raiseNode); PFrame callerFrame = readCallerFrameNode.executeWith(frame, 0); Object[] args = PArguments.create(); @@ -869,14 +870,14 @@ Object execCustomGlobalsGlobalLocals(VirtualFrame frame, Object source, PDict gl @Bind("this") Node inliningTarget, @Shared @Cached HashingCollectionNodes.SetItemNode setBuiltins, @Shared("getCt") @Cached CodeNodes.GetCodeCallTargetNode getCt, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PCode code = createAndCheckCode(frame, inliningTarget, source, raiseNode); Object[] args = PArguments.create(); setCustomGlobals(frame, inliningTarget, globals, setBuiltins, args); setCustomLocals(args, globals); RootCallTarget rootCallTarget = getCt.execute(inliningTarget, code); if (rootCallTarget == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_CREATE_CALL_TARGET, code); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_CREATE_CALL_TARGET, code); } return invokeNode.execute(frame, rootCallTarget, args); @@ -889,7 +890,7 @@ Object execInheritGlobalsCustomLocals(VirtualFrame frame, Object source, @Suppre @SuppressWarnings("unused") @Shared @Cached PyMappingCheckNode mappingCheckNode, @Exclusive @Cached ReadCallerFrameNode readCallerFrameNode, @Shared("getCt") @Cached CodeNodes.GetCodeCallTargetNode getCt, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PCode code = createAndCheckCode(frame, inliningTarget, source, raiseNode); PFrame callerFrame = readCallerFrameNode.executeWith(frame, 0); Object[] args = PArguments.create(); @@ -906,7 +907,7 @@ Object execCustomGlobalsCustomLocals(VirtualFrame frame, Object source, PDict gl @SuppressWarnings("unused") @Shared @Cached PyMappingCheckNode mappingCheckNode, @Shared @Cached HashingCollectionNodes.SetItemNode setBuiltins, @Shared("getCt") @Cached CodeNodes.GetCodeCallTargetNode getCt, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PCode code = createAndCheckCode(frame, inliningTarget, source, raiseNode); Object[] args = PArguments.create(); setCustomGlobals(frame, inliningTarget, globals, setBuiltins, args); @@ -918,17 +919,16 @@ Object execCustomGlobalsCustomLocals(VirtualFrame frame, Object source, PDict gl @Specialization(guards = {"!isAnyNone(globals)", "!isDict(globals)"}) @SuppressWarnings({"unused", "truffle-static-method"}) PNone badGlobals(Object source, Object globals, Object locals, - @Shared("raise") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.GLOBALS_MUST_BE_DICT, getMode(), globals); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.GLOBALS_MUST_BE_DICT, getMode(), globals); } @Specialization(guards = {"isAnyNone(globals) || isDict(globals)", "!isAnyNone(locals)", "!isMapping(inliningTarget, mappingCheckNode, locals)"}) @SuppressWarnings({"unused", "truffle-static-method"}) PNone badLocals(Object source, PDict globals, Object locals, @Bind("this") Node inliningTarget, - @Shared @Cached PyMappingCheckNode mappingCheckNode, - @Shared("raise") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.LOCALS_MUST_BE_MAPPING, getMode(), locals); + @Shared @Cached PyMappingCheckNode mappingCheckNode) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.LOCALS_MUST_BE_MAPPING, getMode(), locals); } private CompileNode getCompileNode() { @@ -1056,7 +1056,7 @@ Object compile(TruffleString expression, TruffleString filename, TruffleString m InputType type = getParserInputType(mode, flags); if (type == InputType.FUNCTION_TYPE) { if ((flags & PyCF_ONLY_AST) == 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.COMPILE_MODE_FUNC_TYPE_REQUIED_FLAG_ONLY_AST); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.COMPILE_MODE_FUNC_TYPE_REQUIED_FLAG_ONLY_AST); } } if (lstrip && !code.isEmpty()) { @@ -1122,7 +1122,7 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri @Cached TruffleString.FromByteArrayNode fromByteArrayNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Shared @Cached ReadCallerFrameNode readCallerFrame, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (wSource instanceof PCode) { return wSource; } @@ -1150,7 +1150,7 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri } if (AstModuleBuiltins.isAst(context, wSource)) { - ModTy mod = AstModuleBuiltins.obj2sst(context, wSource, getParserInputType(mode, flags)); + ModTy mod = AstModuleBuiltins.obj2sst(inliningTarget, context, wSource, getParserInputType(mode, flags)); Source source = PythonUtils.createFakeSource(filename); RootCallTarget rootCallTarget = context.getLanguage(inliningTarget).compileForBytecodeInterpreter(context, mod, source, false, optimize, null, null, flags); return wrapRootCallTarget(rootCallTarget); @@ -1179,14 +1179,14 @@ private void checkSource(TruffleString source) throws PException { @TruffleBoundary private void checkOptimize(int optimize, Object kwOptimize) throws PException { if (optimize < -1 || optimize > 2) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.INVALID_OPTIMIZE_VALUE, kwOptimize); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.INVALID_OPTIMIZE_VALUE, kwOptimize); } } @TruffleBoundary private void checkFlags(int flags) { if ((flags & ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_COMPILE_MASK)) != 0) { - throw PRaiseNode.raiseUncached(this, ValueError, null, NO_VALUE, ErrorMessages.UNRECOGNIZED_FLAGS, PythonUtils.EMPTY_OBJECT_ARRAY); + throw PRaiseNode.raiseStatic(this, ValueError, null, NO_VALUE, ErrorMessages.UNRECOGNIZED_FLAGS, PythonUtils.EMPTY_OBJECT_ARRAY); } } @@ -1202,9 +1202,9 @@ private InputType getParserInputType(TruffleString mode, int flags) { return InputType.FUNCTION_TYPE; } else { if ((flags & PyCF_ONLY_AST) != 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.COMPILE_MODE_MUST_BE_AST_ONLY); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.COMPILE_MODE_MUST_BE_AST_ONLY); } else { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.COMPILE_MODE_MUST_BE); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.COMPILE_MODE_MUST_BE); } } } @@ -1212,7 +1212,7 @@ private InputType getParserInputType(TruffleString mode, int flags) { // modeled after _Py_SourceAsString TruffleString sourceAsString(VirtualFrame frame, Node inliningTarget, Object source, TruffleString filename, InteropLibrary interopLib, PythonBufferAcquireLibrary acquireLib, PythonBufferAccessLibrary bufferLib, CodecsModuleBuiltins.HandleDecodingErrorNode handleDecodingErrorNode, PyObjectStrAsTruffleStringNode asStrNode, - TruffleString.SwitchEncodingNode switchEncodingNode, PRaiseNode.Lazy raiseNode, IndirectCallData indirectCallData) { + TruffleString.SwitchEncodingNode switchEncodingNode, PRaiseNode raiseNode, IndirectCallData indirectCallData) { if (interopLib.isString(source)) { try { return switchEncodingNode.execute(interopLib.asTruffleString(source), TS_ENCODING); @@ -1226,7 +1226,7 @@ TruffleString sourceAsString(VirtualFrame frame, Node inliningTarget, Object sou try { buffer = acquireLib.acquireReadonly(source, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S, "compile()", 1, "string, bytes or AST object"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_D_MUST_BE_S, "compile()", 1, "string, bytes or AST object"); } try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(source); @@ -1547,8 +1547,8 @@ static Object iter(Object callable, Object sentinel, @Fallback @SuppressWarnings("unused") static Object iterNotCallable(Object callable, Object sentinel, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ITER_V_MUST_BE_CALLABLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ITER_V_MUST_BE_CALLABLE); } } @@ -1582,7 +1582,7 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj @Exclusive @Cached IsBuiltinObjectProfile errorProfile1, @Exclusive @Cached IsBuiltinObjectProfile errorProfile2, @Exclusive @Cached InlinedConditionProfile hasDefaultProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { boolean kwArgsAreNone = keywordArgIsNone.profile(inliningTarget, PGuards.isPNone(keywordArgIn)); Object keywordArg = kwArgsAreNone ? null : keywordArgIn; @@ -1593,7 +1593,7 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj } catch (PException e) { e.expectStopIteration(inliningTarget, errorProfile1); if (hasDefaultProfile.profile(inliningTarget, isNoValue(defaultVal))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.ARG_IS_EMPTY_SEQ, name); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.ARG_IS_EMPTY_SEQ, name); } else { return defaultVal; } @@ -1642,13 +1642,13 @@ static Object minmaxBinaryWithKey(VirtualFrame frame, Node inliningTarget, Objec @Exclusive @Cached InlinedConditionProfile moreThanTwo, @Exclusive @Cached InlinedLoopConditionProfile loopProfile, @Exclusive @Cached InlinedConditionProfile hasDefaultProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { boolean kwArgsAreNone = keywordArgIsNone.profile(inliningTarget, PGuards.isPNone(keywordArgIn)); Object keywordArg = kwArgsAreNone ? null : keywordArgIn; if (!hasDefaultProfile.profile(inliningTarget, isNoValue(defaultVal))) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_SPECIFY_DEFAULT_FOR_S, name); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_SPECIFY_DEFAULT_FOR_S, name); } Object currentValue = arg1; Object currentKey = applyKeyFunction(frame, inliningTarget, keywordArg, keyCall, currentValue); @@ -1756,11 +1756,12 @@ public Object next(VirtualFrame frame, Object iterator, Object defaultObject, @NeverDefault protected LookupAndCallUnaryNode createNextCall() { return LookupAndCallUnaryNode.create(T___NEXT__, () -> new LookupAndCallUnaryNode.NoAttributeHandler() { - @Child PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object iterator) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_ISNT_ITERATOR, iterator); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.OBJ_ISNT_ITERATOR, iterator); } }); } @@ -1778,7 +1779,7 @@ static int ord(Object chrObj, @Cached CastToTruffleStringNode castToStringNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString chr; try { chr = castToStringNode.execute(inliningTarget, chrObj); @@ -1787,7 +1788,7 @@ static int ord(Object chrObj, } int len = codePointLengthNode.execute(chr, TS_ENCODING); if (len != 1) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_CHARACTER_BUT_STRING_FOUND, "ord()", len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_CHARACTER_BUT_STRING_FOUND, "ord()", len); } return codePointAtIndexNode.execute(chr, 0, TS_ENCODING); } @@ -1797,18 +1798,18 @@ static long ord(PBytesLike chr, @Bind("this") Node inliningTarget, @Cached CastToJavaLongExactNode castNode, @Cached SequenceStorageNodes.GetItemNode getItemNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int len = chr.getSequenceStorage().length(); if (len != 1) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_CHARACTER_BUT_STRING_FOUND, "ord()", len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_CHARACTER_BUT_STRING_FOUND, "ord()", len); } return castNode.execute(inliningTarget, getItemNode.execute(chr.getSequenceStorage(), 0)); } @Specialization(guards = {"!isString(obj)", "!isBytes(obj)"}) static Object ord(@SuppressWarnings("unused") Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.S_EXPECTED_STRING_OF_LEN_BUT_P, "ord()", "1", "obj"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_STRING_OF_LEN_BUT_P, "ord()", "1", "obj"); } } @@ -1879,19 +1880,19 @@ PNone printGeneric(VirtualFrame frame, Object[] values, Object sepIn, Object end @Exclusive @Cached CallNode callWrite, @Exclusive @Cached PyObjectCallMethodObjArgs callFlush, @Exclusive @Cached PyObjectStrAsObjectNode strNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString sep; try { sep = sepIn instanceof PNone ? T_SPACE : castSep.execute(inliningTarget, sepIn); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.SEP_MUST_BE_NONE_OR_STRING, sepIn); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.SEP_MUST_BE_NONE_OR_STRING, sepIn); } TruffleString end; try { end = endIn instanceof PNone ? T_NEWLINE : castEnd.execute(inliningTarget, endIn); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_MUST_BE_NONE_OR_STRING, "end", sepIn); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_MUST_BE_NONE_OR_STRING, "end", sepIn); } Object file; @@ -1935,7 +1936,7 @@ private Object getStdout() { Object stdout = readStdout.execute(sys, T_STDOUT); if (stdout == NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.LOST_SYSSTDOUT); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.LOST_SYSSTDOUT); } return stdout; } @@ -1965,14 +1966,14 @@ public static Object format(VirtualFrame frame, Object obj, Object formatSpec, @Bind("this") Node inliningTarget, @Cached("create(Format)") LookupAndCallBinaryNode callFormat, @Cached InlinedConditionProfile formatIsNoValueProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object format = formatIsNoValueProfile.profile(inliningTarget, isNoValue(formatSpec)) ? T_EMPTY_STRING : formatSpec; Object res = callFormat.executeObject(frame, obj, format); if (res == NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj); } if (!PGuards.isString(res)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); } return res; } @@ -2004,10 +2005,10 @@ public abstract static class RoundNode extends PythonBuiltinNode { static Object round(VirtualFrame frame, Object x, @SuppressWarnings("unused") PNone n, @Bind("this") Node inliningTarget, @Cached("create(Round)") LookupAndCallUnaryNode callRound, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object result = callRound.executeObject(frame, x); if (result == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, T___ROUND__); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, T___ROUND__); } return result; } @@ -2016,10 +2017,10 @@ static Object round(VirtualFrame frame, Object x, @SuppressWarnings("unused") PN static Object round(VirtualFrame frame, Object x, Object n, @Bind("this") Node inliningTarget, @Cached("create(Round)") LookupAndCallBinaryNode callRound, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object result = callRound.executeObject(frame, x, n); if (result == NOT_IMPLEMENTED) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, T___ROUND__); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, T___ROUND__); } return result; } @@ -2083,7 +2084,7 @@ public abstract static class BreakPointNode extends PythonBuiltinNode { Object doIt(VirtualFrame frame, Object[] args, PKeyword[] kwargs, @Bind("this") Node inliningTarget, @Cached HashingStorageGetItem getItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (getDebuggerSessionCount() > 0) { // we already have a Truffle debugger attached, it'll stop here return PNone.NONE; @@ -2097,7 +2098,7 @@ Object doIt(VirtualFrame frame, Object[] args, PKeyword[] kwargs, Object sysModule = getItem.execute(inliningTarget, sysModules.getDictStorage(), T_SYS); Object breakpointhook = getBreakpointhookNode.execute(sysModule, T_BREAKPOINTHOOK); if (breakpointhook == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.LOST_SYSBREAKPOINTHOOK); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.LOST_SYSBREAKPOINTHOOK); } return callNode.execute(frame, breakpointhook, args, kwargs); } else { @@ -2177,7 +2178,7 @@ private int sumIntInternal(VirtualFrame frame, Node inliningTarget, Object arg1, @SuppressWarnings("unused") @Shared @Cached InlinedConditionProfile hasStart, @Shared("getIter") @Cached PyObjectGetIter getIter, // dummy raiseNode, so it can be @Shared, to optimize generated code: - @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) throws UnexpectedResultException { + @SuppressWarnings("unused") @Shared @Cached PRaiseNode raiseNode) throws UnexpectedResultException { return sumDoubleInternal(frame, inliningTarget, arg1, start, addNode, getIter, errorProfile); } @@ -2211,13 +2212,13 @@ Object sum(VirtualFrame frame, Object arg1, Object start, @Shared @Cached IsBuiltinObjectProfile errorProfile, @Shared("getIter") @Cached PyObjectGetIter getIter, @Shared @Cached InlinedConditionProfile hasStart, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (PGuards.isString(start)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SUM_STRINGS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_STRINGS); } else if (start instanceof PBytes) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SUM_BYTES); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTES); } else if (start instanceof PByteArray) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SUM_BYTEARRAY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTEARRAY); } Object iterator = getIter.execute(frame, inliningTarget, arg1); return iterateGeneric(frame, inliningTarget, iterator, hasStart.profile(inliningTarget, start != NO_VALUE) ? start : 0, addNode, errorProfile); @@ -2284,10 +2285,10 @@ static Object vars(VirtualFrame frame, @SuppressWarnings("unused") PNone none, static Object vars(VirtualFrame frame, Object obj, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookupAttr, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object dict = lookupAttr.execute(frame, inliningTarget, obj, T___DICT__); if (dict == NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.VARS_ARGUMENT_MUST_HAVE_DICT); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.VARS_ARGUMENT_MUST_HAVE_DICT); } return dict; } @@ -2328,7 +2329,7 @@ static PTuple update(PTuple bases, Object[] arguments, int nargs, @Bind PythonLanguage language, @Cached PyObjectLookupAttr getMroEntries, @Cached CallUnaryMethodNode callMroEntries, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { CompilerAsserts.neverPartOfCompilation(); ArrayList newBases = null; for (int i = 0; i < nargs; i++) { @@ -2351,7 +2352,7 @@ static PTuple update(PTuple bases, Object[] arguments, int nargs, } Object newBase = callMroEntries.executeObject(null, meth, bases); if (!PGuards.isPTuple(newBase)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.MRO_ENTRIES_MUST_RETURN_TUPLE); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.MRO_ENTRIES_MUST_RETURN_TUPLE); } PTuple newBaseTuple = (PTuple) newBase; if (newBases == null) { @@ -2386,7 +2387,7 @@ static Object calculate(Object metatype, PTuple bases, @Cached GetClassNode getClass, @Cached IsSubtypeNode isSubType, @Cached IsSubtypeNode isSubTypeReverse, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { CompilerAsserts.neverPartOfCompilation(); /* * Determine the proper metatype to deal with this, and check for metatype conflicts @@ -2405,7 +2406,7 @@ static Object calculate(Object metatype, PTuple bases, } else if (isSubTypeReverse.execute(tmpType, winner)) { winner = tmpType; } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.METACLASS_CONFLICT); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.METACLASS_CONFLICT); } } return winner; @@ -2451,20 +2452,21 @@ protected Object doItNonFunction(VirtualFrame frame, Object function, Object[] a @Cached UpdateBasesNode update, @Cached PyObjectSetItem setOrigBases, @Cached GetClassNode getClass, - @Cached IsBuiltinObjectProfile noAttributeProfile) { + @Cached IsBuiltinObjectProfile noAttributeProfile, + @Cached PRaiseNode raiseNode) { if (arguments.length < 1) { - throw raise(PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_NOT_ENOUGH_ARGS); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_NOT_ENOUGH_ARGS); } if (!PGuards.isFunction(function)) { - throw raise(PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_FUNC_MUST_BE_FUNC); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_FUNC_MUST_BE_FUNC); } TruffleString name; try { name = castToTruffleStringNode.execute(inliningTarget, arguments[0]); } catch (CannotCastException e) { - throw raise(PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_NAME_NOT_STRING); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.BUILD_CLS_NAME_NOT_STRING); } PythonContext ctx = PythonContext.get(inliningTarget); @@ -2561,9 +2563,9 @@ class InitializeBuildClass { @InliningCutoff private PException raiseNoMapping(boolean isClass, Object meta, Object ns) { if (isClass) { - throw raise(PythonErrorType.TypeError, ErrorMessages.N_PREPARE_MUST_RETURN_MAPPING, meta, ns); + throw PRaiseNode.raiseStatic(this, PythonErrorType.TypeError, ErrorMessages.N_PREPARE_MUST_RETURN_MAPPING, meta, ns); } else { - throw raise(PythonErrorType.TypeError, ErrorMessages.MTCLS_PREPARE_MUST_RETURN_MAPPING, ns); + throw PRaiseNode.raiseStatic(this, PythonErrorType.TypeError, ErrorMessages.MTCLS_PREPARE_MUST_RETURN_MAPPING, ns); } } } @@ -2576,14 +2578,14 @@ public Object doGeneric(VirtualFrame frame, Object asyncIter, @Bind("this") Node inliningTarget, @Cached(parameters = "ANext") LookupSpecialMethodSlotNode getANext, @Cached GetClassNode getAsyncIterType, - @Cached PRaiseNode.Lazy raiseNoANext, + @Cached PRaiseNode raiseNoANext, @Cached CallUnaryMethodNode callANext, @Cached TypeNodes.GetNameNode getName) { // TODO: two argument anext Object type = getAsyncIterType.execute(inliningTarget, asyncIter); Object getter = getANext.execute(frame, type, asyncIter); if (getter == NO_VALUE) { - throw raiseNoANext.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJECT_NOT_ASYNCGEN, getName.execute(inliningTarget, type)); + throw raiseNoANext.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJECT_NOT_ASYNCGEN, getName.execute(inliningTarget, type)); } return callANext.executeObject(frame, getter, asyncIter); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java index 1fe9d7865d..1d20d28c2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java @@ -173,7 +173,7 @@ abstract static class CmathComplexUnaryHelperNode extends Node { @FunctionalInterface interface Op { - ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode); + ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode); } abstract PComplex execute(VirtualFrame frame, Node inliningTarget, Object value, Op op); @@ -181,21 +181,21 @@ interface Op { @Specialization static PComplex doL(Node inliningTarget, long value, Op op, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(language); } @Specialization static PComplex doD(Node inliningTarget, double value, Op op, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op.compute(inliningTarget, value, 0, raiseNode).toPComplex(language); } @Specialization static PComplex doC(Node inliningTarget, PComplex value, Op op, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op.compute(inliningTarget, value.getReal(), value.getImag(), raiseNode).toPComplex(language); } @@ -203,7 +203,7 @@ static PComplex doC(Node inliningTarget, PComplex value, Op op, static PComplex doGeneral(VirtualFrame frame, Node inliningTarget, Object value, Op op, @Cached CoerceToComplexNode coerceToComplex, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return doC(inliningTarget, coerceToComplex.execute(frame, inliningTarget, value), op, language, raiseNode); } } @@ -399,7 +399,7 @@ private static PComplex rect(Node raisingNode, double r, double phi) { if (!Double.isFinite(r) || !Double.isFinite(phi)) { // need to raise an exception if r is a nonzero number and phi is infinite if (r != 0.0 && !Double.isNaN(r) && Double.isInfinite(phi)) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } // if r is +/-infinity and phi is finite but nonzero then @@ -503,7 +503,7 @@ private double computeRealPart(double real, double imag) { final double scaleUp = 0x1.0p53; return Math.log(Math.hypot(ax * scaleUp, ay * scaleUp)) - 53 * LN_2; } - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } double h = Math.hypot(ax, ay); if (0.71 <= h && h <= 1.73) { @@ -562,7 +562,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SqrtNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue result = specialValue(SPECIAL_VALUES, real, imag); if (result != null) { return result; @@ -616,7 +616,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AcosNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue result = specialValue(SPECIAL_VALUES, real, imag); if (result != null) { return result; @@ -666,7 +666,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AcoshNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue result = specialValue(SPECIAL_VALUES, real, imag); if (result != null) { return result; @@ -697,7 +697,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AsinNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue s = AsinhNode.compute(inliningTarget, -imag, real, raiseNode); return new ComplexValue(s.imag, -s.real); } @@ -727,7 +727,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AsinhNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue result = specialValue(SPECIAL_VALUES, real, imag); if (result != null) { return result; @@ -763,7 +763,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AtanNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue s = AtanhNode.compute(inliningTarget, -imag, real, raiseNode); return new ComplexValue(s.imag, -s.real); } @@ -796,7 +796,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AtanhNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue result = specialValue(SPECIAL_VALUES, real, imag); if (result != null) { return result; @@ -807,7 +807,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais return computeWithRealPositive(inliningTarget, real, imag, 1.0, raiseNode); } - private static ComplexValue computeWithRealPositive(Node inliningTarget, double real, double imag, double resultScale, PRaiseNode.Lazy raiseNode) { + private static ComplexValue computeWithRealPositive(Node inliningTarget, double real, double imag, double resultScale, PRaiseNode raiseNode) { double rreal; double rimag; double ay = Math.abs(imag); @@ -817,7 +817,7 @@ private static ComplexValue computeWithRealPositive(Node inliningTarget, double rimag = -Math.copySign(Math.PI / 2.0, -imag); } else if (real == 1.0 && ay < CM_SQRT_DBL_MIN) { if (ay == 0.0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } rreal = -Math.log(Math.sqrt(ay) / Math.sqrt(Math.hypot(ay, 2.0))); rimag = Math.copySign(Math.atan2(2.0, -ay) / 2, imag); @@ -853,7 +853,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, ExpNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { if (!Double.isFinite(real) || !Double.isFinite(imag)) { ComplexValue r; if (Double.isInfinite(real) && Double.isFinite(imag) && imag != 0.0) { @@ -866,7 +866,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais r = specialValue(SPECIAL_VALUES, real, imag); } if (Double.isInfinite(imag) && (Double.isFinite(real) || (Double.isInfinite(real) && real > 0))) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } return r; } @@ -882,7 +882,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais rimag = l * Math.sin(imag); } if (Double.isInfinite(rreal) || Double.isInfinite(rimag)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } return new ComplexValue(rreal, rimag); } @@ -899,7 +899,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, CosNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { return CoshNode.compute(inliningTarget, -imag, real, raiseNode); } } @@ -928,10 +928,10 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, CoshNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { if (!Double.isFinite(real) || !Double.isFinite(imag)) { if (Double.isInfinite(imag) && !Double.isNaN(real)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } if (Double.isInfinite(real) && Double.isFinite(imag) && imag != 0.0) { double r = Math.copySign(INF, Math.sin(imag)); @@ -951,7 +951,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais rimag = Math.sin(imag) * Math.sinh(real); } if (Double.isInfinite(rreal) || Double.isInfinite(rimag)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } return new ComplexValue(rreal, rimag); } @@ -968,7 +968,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SinNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue s = SinhNode.compute(inliningTarget, -imag, real, raiseNode); return new ComplexValue(s.imag, -s.real); } @@ -998,10 +998,10 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SinhNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { if (!Double.isFinite(real) || !Double.isFinite(imag)) { if (Double.isInfinite(imag) && !Double.isNaN(real)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } if (Double.isInfinite(real) && Double.isFinite(imag) && imag != 0.0) { double r = Math.copySign(INF, Math.cos(imag)); @@ -1021,7 +1021,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais rimag = Math.sin(imag) * Math.cosh(real); } if (Double.isInfinite(rreal) || Double.isInfinite(rimag)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } return new ComplexValue(rreal, rimag); } @@ -1038,7 +1038,7 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, TanNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { ComplexValue s = TanhNode.compute(inliningTarget, -imag, real, raiseNode); return new ComplexValue(s.imag, -s.real); } @@ -1068,10 +1068,10 @@ static PComplex doIt(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, TanhNode::compute); } - static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode.Lazy raiseNode) { + static ComplexValue compute(Node inliningTarget, double real, double imag, PRaiseNode raiseNode) { if (!Double.isFinite(real) || !Double.isFinite(imag)) { if (Double.isInfinite(imag) && Double.isFinite(real)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } if (Double.isInfinite(real) && Double.isFinite(imag) && imag != 0.0) { return new ComplexValue(real > 0 ? 1.0 : -1.0, Math.copySign(0.0, 2.0 * Math.sin(imag) * Math.cos(imag))); @@ -1105,7 +1105,7 @@ abstract static class IsCloseNode extends PythonBuiltinNode { static boolean doCCDD(PComplex a, PComplex b, double relTolObj, double absTolObj, @Bind("this") Node inliningTarget, @Shared @Cached AbsNode absNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return isClose(inliningTarget, a, b, relTolObj, absTolObj, absNode, raiseNode); } @@ -1114,7 +1114,7 @@ static boolean doCCDD(PComplex a, PComplex b, double relTolObj, double absTolObj static boolean doCCNN(PComplex a, PComplex b, PNone relTolObj, PNone absTolObj, @Bind("this") Node inliningTarget, @Shared @Cached AbsNode absNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return isClose(inliningTarget, a, b, DEFAULT_REL_TOL, DEFAULT_ABS_TOL, absNode, raiseNode); } @@ -1126,7 +1126,7 @@ static boolean doGeneral(VirtualFrame frame, Object aObj, Object bObj, Object re @Cached PyFloatAsDoubleNode relAsDoubleNode, @Cached PyFloatAsDoubleNode absAsDoubleNode, @Shared @Cached AbsNode absNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PComplex a = coerceAToComplex.execute(frame, inliningTarget, aObj); PComplex b = coerceBToComplex.execute(frame, inliningTarget, bObj); double relTol = PGuards.isNoValue(relTolObj) ? DEFAULT_REL_TOL : relAsDoubleNode.execute(frame, inliningTarget, relTolObj); @@ -1134,9 +1134,9 @@ static boolean doGeneral(VirtualFrame frame, Object aObj, Object bObj, Object re return isClose(inliningTarget, a, b, relTol, absTol, absNode, raiseNode); } - private static boolean isClose(Node inliningTarget, PComplex a, PComplex b, double relTol, double absTol, AbsNode absNode, PRaiseNode.Lazy raiseNode) { + private static boolean isClose(Node inliningTarget, PComplex a, PComplex b, double relTol, double absTol, AbsNode absNode, PRaiseNode raiseNode) { if (relTol < 0.0 || absTol < 0.0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TOLERANCE_MUST_NON_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOLERANCE_MUST_NON_NEGATIVE); } if (a.getReal() == b.getReal() && a.getImag() == b.getImag()) { return true; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java index 21d8ae4162..df01b7ccc4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java @@ -222,9 +222,9 @@ static void handle(Node inliningTarget, TruffleEncoder encoder, TruffleString er @Cached InlinedConditionProfile surrogatepassProfile, @Cached InlinedConditionProfile surrogateescapeProfile, @Cached InlinedConditionProfile xmlcharrefreplaceProfile, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached(inline = false) TruffleString.EqualNode equalNode, - // TODO: (blocked by GR-46101) make this CallNode.Lazy + // TODO: (blocked by GR-46101) make this CallNode.PRaiseNode @Cached(inline = false) CallNode lazyCallNode) { boolean fixed; try { @@ -240,24 +240,24 @@ static void handle(Node inliningTarget, TruffleEncoder encoder, TruffleString er } else if (xmlcharrefreplaceProfile.profile(inliningTarget, equalNode.execute(T_XMLCHARREFREPLACE, errorAction, TS_ENCODING))) { fixed = xmlcharrefreplace(encoder); } else { - throw raiseNode.get(inliningTarget).raise(LookupError, ErrorMessages.UNKNOWN_ERROR_HANDLER, errorAction); + throw raiseNode.raise(inliningTarget, LookupError, ErrorMessages.UNKNOWN_ERROR_HANDLER, errorAction); } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } if (!fixed) { int start = encoder.getInputPosition(); int end = start + encoder.getErrorLength(); Object exception = lazyCallNode.executeWithoutFrame(UnicodeEncodeError, encoder.getEncodingName(), inputObject, start, end, encoder.getErrorReason()); if (exception instanceof PBaseException) { - throw raiseNode.get(inliningTarget).raiseExceptionObject((PBaseException) exception); + throw raiseNode.raiseExceptionObject(inliningTarget, (PBaseException) exception); } else { // Shouldn't happen unless the user manually replaces the method, which is // really // unexpected and shouldn't be permitted at all, but currently it is CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeEncodeError, exception); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeEncodeError, exception); } } } @@ -368,7 +368,7 @@ public Object raise(Node inliningTarget, TruffleDecoder decoder, Object inputObj @Specialization static Object doRaise(Node inliningTarget, TruffleDecoder decoder, Object inputObject, boolean justMakeExcept, @Cached(inline = false) CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int start = decoder.getInputPosition(); int end = start + decoder.getErrorLength(); Object exception = callNode.executeWithoutFrame(UnicodeDecodeError, decoder.getEncodingName(), inputObject, start, end, decoder.getErrorReason()); @@ -376,12 +376,12 @@ static Object doRaise(Node inliningTarget, TruffleDecoder decoder, Object inputO return exception; } if (exception instanceof PBaseException) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } else { // Shouldn't happen unless the user manually replaces the method, which is really // unexpected and shouldn't be permitted at all, but currently it is CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeDecodeError, exception); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeDecodeError, exception); } } } @@ -441,7 +441,7 @@ void doBackslashreplace(TruffleDecoder decoder, @SuppressWarnings("unused") Truf } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - PRaiseNode.raiseUncached(this, MemoryError); + PRaiseNode.raiseStatic(this, MemoryError); } } @@ -457,7 +457,7 @@ static void doSurrogatepass(TruffleDecoder decoder, @SuppressWarnings("unused") } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -472,7 +472,7 @@ static void doSurrogateescape(TruffleDecoder decoder, @SuppressWarnings("unused" } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -487,23 +487,23 @@ static void doCustom(VirtualFrame frame, TruffleDecoder decoder, TruffleString e @Cached PyLongAsIntNode asIntNode, @Exclusive @Cached RaiseDecodingErrorNode raiseDecodingErrorNode, @Cached PyCodecLookupErrorNode lookupErrorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { Object errorHandler = lookupErrorNode.execute(inliningTarget, errorAction); if (errorHandler == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, UNKNOWN_ERROR_HANDLER, errorAction); + throw raiseNode.raise(inliningTarget, LookupError, UNKNOWN_ERROR_HANDLER, errorAction); } Object exceptionObject = raiseDecodingErrorNode.makeDecodeException(inliningTarget, decoder, inputObject); Object restuple = callNode.execute(frame, errorHandler, exceptionObject); if (!PGuards.isPTuple(restuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); + throw raiseNode.raise(inliningTarget, TypeError, DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); } SequenceStorage storage = ((PTuple) restuple).getSequenceStorage(); Object[] t = getArray.execute(inliningTarget, storage); if (storage.length() != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); + throw raiseNode.raise(inliningTarget, TypeError, DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); } int newpos = asIntNode.execute(null, inliningTarget, t[1]); /*- Copy back the bytes variables, which might have been modified by the callback */ @@ -517,16 +517,16 @@ static void doCustom(VirtualFrame frame, TruffleDecoder decoder, TruffleString e newpos = insize + newpos; } if (newpos < 0 || newpos > insize) { - throw raiseNode.get(inliningTarget).raise(IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); + throw raiseNode.raise(inliningTarget, IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); } if (!custom(decoder, input, insize, newpos)) { - throw raiseNode.get(inliningTarget).raise(SystemError); + throw raiseNode.raise(inliningTarget, SystemError); } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -608,14 +608,14 @@ byte[] encode(Object self, TruffleString encoding, TruffleString errors, @Cached CastToJavaStringNode castStr, @Cached TruffleString.EqualNode equalNode, @Cached HandleEncodingErrorNode errorHandler, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached NormalizeEncodingNameNode normalizeEncodingNameNode) { String input = castStr.execute(self); CodingErrorAction errorAction = convertCodingErrorAction(errors, equalNode); TruffleString normalizedEncoding = normalizeEncodingNameNode.execute(inliningTarget, encoding); Charset charset = CharsetMapping.getCharsetNormalized(normalizedEncoding); if (charset == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, ErrorMessages.UNKNOWN_ENCODING, encoding); + throw raiseNode.raise(inliningTarget, LookupError, ErrorMessages.UNKNOWN_ENCODING, encoding); } TruffleEncoder encoder; try { @@ -625,7 +625,7 @@ byte[] encode(Object self, TruffleString encoding, TruffleString errors, } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, MemoryError); + throw PRaiseNode.raiseStatic(this, MemoryError); } return encoder.getBytes(); } @@ -658,9 +658,8 @@ static Object encode(Object self, TruffleString encoding, TruffleString errors, @Fallback static Object encode(Object str, @SuppressWarnings("unused") Object encoding, @SuppressWarnings("unused") Object errors, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_CONVERT_TO_STR_IMPLICITLY, str); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_CONVERT_TO_STR_IMPLICITLY, str); } } @@ -701,7 +700,7 @@ static Object decode(VirtualFrame frame, Object input, TruffleString encoding, T TruffleString normalizedEncoding = normalizeEncodingNameNode.execute(inliningTarget, encoding); Charset charset = CharsetMapping.getCharsetForDecodingNormalized(normalizedEncoding, bytes, len); if (charset == null) { - throw raiseNode.raise(LookupError, ErrorMessages.UNKNOWN_ENCODING, encoding); + throw raiseNode.raise(inliningTarget, LookupError, ErrorMessages.UNKNOWN_ENCODING, encoding); } TruffleDecoder decoder; try { @@ -711,7 +710,7 @@ static Object decode(VirtualFrame frame, Object input, TruffleString encoding, T } } catch (OutOfMemoryError e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } return PFactory.createTuple(language, new Object[]{decoder.getString(), decoder.getInputPosition()}); } finally { @@ -768,7 +767,7 @@ private ByteArrayBuffer doDecode(byte[] bytes, int bytesLen, TruffleString error i++; if (i >= bytesLen) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.TRAILING_S_IN_STR, "\\"); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.TRAILING_S_IN_STR, "\\"); } chr = (char) bytes[i]; @@ -843,14 +842,14 @@ private ByteArrayBuffer doDecode(byte[] bytes, int bytesLen, TruffleString error } // invalid hexadecimal digits if (T_STRICT.equalsUncached(errors, TS_ENCODING)) { - throw PRaiseNode.raiseUncached(this, ValueError, INVALID_ESCAPE_AT, "\\x", i - 2); + throw PRaiseNode.raiseStatic(this, ValueError, INVALID_ESCAPE_AT, "\\x", i - 2); } if (T_REPLACE.equalsUncached(errors, TS_ENCODING)) { buffer.append('?'); } else if (T_IGNORE.equalsUncached(errors, TS_ENCODING)) { // do nothing } else { - throw PRaiseNode.raiseUncached(this, ValueError, ENCODING_ERROR_WITH_CODE, errors); + throw PRaiseNode.raiseStatic(this, ValueError, ENCODING_ERROR_WITH_CODE, errors); } // skip \x @@ -926,8 +925,8 @@ Object encode(PBytes data, @SuppressWarnings("unused") TruffleString errors, @Fallback static Object encode(Object data, @SuppressWarnings("unused") Object errors, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BYTESLIKE_OBJ_REQUIRED, data); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BYTESLIKE_OBJ_REQUIRED, data); } } @@ -982,7 +981,7 @@ static PTuple lookup(VirtualFrame frame, Node inliningTarget, TruffleString enco @Cached InlinedConditionProfile hasTruffleEncodingProfile, @Cached InlinedConditionProfile isTupleProfile, @Cached NormalizeEncodingNameNode normalizeEncodingNameNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString normalizedEncoding = normalizeEncodingNameNode.execute(inliningTarget, encoding); PythonContext context = PythonContext.get(inliningTarget); ensureRegistryInitialized(context); @@ -999,7 +998,7 @@ static PTuple lookup(VirtualFrame frame, Node inliningTarget, TruffleString enco Object obj = callNode.executeObject(func, normalizedEncoding); if (obj != PNone.NONE) { if (isTupleProfile.profile(inliningTarget, !isTupleInstanceCheck(frame, inliningTarget, obj, 4, typeCheck, sizeNode))) { - throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_SEARCH_MUST_RETURN_4); + throw raiseNode.raise(inliningTarget, TypeError, CODEC_SEARCH_MUST_RETURN_4); } result = (PTuple) obj; break; @@ -1010,7 +1009,7 @@ static PTuple lookup(VirtualFrame frame, Node inliningTarget, TruffleString enco putSearchPath(context, normalizedEncoding, result); return result; } - throw raiseNode.get(inliningTarget).raise(LookupError, UNKNOWN_ENCODING, encoding); + throw raiseNode.raise(inliningTarget, LookupError, UNKNOWN_ENCODING, encoding); } @TruffleBoundary @@ -1045,14 +1044,14 @@ abstract static class RegisterNode extends PythonUnaryBuiltinNode { static Object lookup(Object searchFunction, @Bind("this") Node inliningTarget, @Cached PyCallableCheckNode callableCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (callableCheckNode.execute(inliningTarget, searchFunction)) { PythonContext context = PythonContext.get(inliningTarget); ensureRegistryInitialized(context); add(context, searchFunction); return PNone.NONE; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ARG_MUST_BE_CALLABLE); + throw raiseNode.raise(inliningTarget, TypeError, ARG_MUST_BE_CALLABLE); } } @@ -1157,11 +1156,11 @@ static Object encode(VirtualFrame frame, Object obj, TruffleString encoding, Tru @Cached PyObjectSizeNode sizeNode, @Cached PyObjectTypeCheck typeCheck, @Cached InlinedConditionProfile isTupleProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object encoder = CodecsModuleBuiltins.encoder(frame, encoding, lookupNode, getItemNode); Object result = callEncoderNode.executeObject(encoder, obj, errors); if (isTupleProfile.profile(inliningTarget, !isTupleInstanceCheck(frame, inliningTarget, result, 2, typeCheck, sizeNode))) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_MUST_RETURN_TUPLE, "encoder"); + throw raiseNode.raise(inliningTarget, TypeError, S_MUST_RETURN_TUPLE, "encoder"); } return getResultItemNode.execute(((PTuple) result).getSequenceStorage(), 0); } @@ -1190,11 +1189,11 @@ static Object decode(VirtualFrame frame, Object obj, TruffleString encoding, Tru @Cached PyObjectSizeNode sizeNode, @Cached PyObjectTypeCheck typeCheck, @Cached InlinedConditionProfile isTupleProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object decoder = CodecsModuleBuiltins.decoder(frame, encoding, lookupNode, getItemNode); Object result = callEncoderNode.executeObject(decoder, obj, errors); if (isTupleProfile.profile(inliningTarget, !isTupleInstanceCheck(frame, inliningTarget, result, 2, typeCheck, sizeNode))) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_MUST_RETURN_TUPLE, "decoder"); + throw raiseNode.raise(inliningTarget, TypeError, S_MUST_RETURN_TUPLE, "decoder"); } return getResultItemNode.execute(((PTuple) result).getSequenceStorage(), 0); } @@ -1319,8 +1318,8 @@ abstract static class UTF16EXDecodeNode extends PythonQuaternaryBuiltinNode { @SuppressWarnings("unused") @Specialization static Object encode(VirtualFrame frame, Object obj, Object errors, Object byteorder, Object ffinal, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, toTruffleStringUncached("utf_16_ex_decode")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("utf_16_ex_decode")); } } @@ -1391,7 +1390,7 @@ abstract static class UTF32EXDecodeNode extends PythonQuaternaryBuiltinNode { @Specialization @TruffleBoundary Object encode(Object obj, Object errors, Object byteorder, Object ffinal) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, toTruffleStringUncached("utf_32_ex_decode")); + throw PRaiseNode.raiseStatic(this, NotImplementedError, toTruffleStringUncached("utf_32_ex_decode")); } } @@ -1402,7 +1401,7 @@ abstract static class UnicodeInternalEncodeNode extends PythonBinaryBuiltinNode @Specialization @TruffleBoundary Object encode(Object obj, Object errors) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, toTruffleStringUncached("unicode_internal_encode")); + throw PRaiseNode.raiseStatic(this, NotImplementedError, toTruffleStringUncached("unicode_internal_encode")); } } @@ -1413,7 +1412,7 @@ abstract static class UnicodeInternalDecodeNode extends PythonBinaryBuiltinNode @Specialization @TruffleBoundary Object encode(Object obj, Object errors) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, toTruffleStringUncached("unicode_internal_decode")); + throw PRaiseNode.raiseStatic(this, NotImplementedError, toTruffleStringUncached("unicode_internal_decode")); } } @@ -1557,7 +1556,7 @@ abstract static class ReadbufferEncodeNode extends PythonBinaryBuiltinNode { @Specialization @TruffleBoundary Object encode(Object obj, Object errors) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, toTruffleStringUncached("readbuffer_encode")); + throw PRaiseNode.raiseStatic(this, NotImplementedError, toTruffleStringUncached("readbuffer_encode")); } } @@ -1593,7 +1592,7 @@ abstract static class OEMEncodeNode extends PythonBinaryBuiltinNode { @Specialization @TruffleBoundary Object encode(Object obj, Object errors) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, toTruffleStringUncached("oem_encode")); + throw PRaiseNode.raiseStatic(this, NotImplementedError, toTruffleStringUncached("oem_encode")); } } @@ -1603,8 +1602,8 @@ abstract static class OEMDecodeNode extends PythonTernaryBuiltinNode { @SuppressWarnings("unused") @Specialization static Object decode(Object obj, Object errors, Object ffinal, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, toTruffleStringUncached("oem_decode")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("oem_decode")); } } @@ -1614,8 +1613,8 @@ abstract static class CodePageEncodeNode extends PythonTernaryBuiltinNode { @SuppressWarnings("unused") @Specialization static Object encode(Object code_page, Object string, Object errors, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, toTruffleStringUncached("code_page_encode")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("code_page_encode")); } } @@ -1625,8 +1624,8 @@ abstract static class CodePageDecodeNode extends PythonQuaternaryBuiltinNode { @SuppressWarnings("unused") @Specialization static Object decode(Object code_page, Object obj, Object errors, Object ffinal, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, toTruffleStringUncached("code_page_decode")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("code_page_decode")); } } @@ -1654,8 +1653,8 @@ abstract static class EncodingMapNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object encodingMap(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "EncodingMap"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "EncodingMap"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java index ffc8d512c0..ed10d4c240 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java @@ -432,7 +432,7 @@ Object lookup(VirtualFrame frame, TruffleString encoding, TruffleString alternat PTuple codecInfo = lookupNode.execute(frame, inliningTarget, encoding); Object isTextObj = getAttributeNode.execute(frame, inliningTarget, codecInfo, T_IS_TEXT_ENCODING); if (!((isTextObj instanceof Boolean) && (boolean) isTextObj)) { - throw raiseNode.raise(LookupError, IS_NOT_TEXT_ENCODING, encoding, alternateCommand); + throw raiseNode.raise(inliningTarget, LookupError, IS_NOT_TEXT_ENCODING, encoding, alternateCommand); } return codecInfo; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java index 934e08654b..98f42ed7e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CollectionsModuleBuiltins.java @@ -117,9 +117,9 @@ static PDequeIter doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Obje @Cached CastToJavaIntExactNode castToJavaIntExactNode, @Cached DequeIterNextNode getNextNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!dequeProfile.profile(inliningTarget, deque instanceof PDeque)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); } PDequeIter dequeIter = PFactory.createDequeIter(language, (PDeque) deque); if (indexNoneProfile.profile(inliningTarget, indexObj != PNone.NO_VALUE)) { @@ -146,9 +146,9 @@ static PDequeIter doGeneric(VirtualFrame frame, @SuppressWarnings("unused") Obje @Cached CastToJavaIntExactNode castToJavaIntExactNode, @Cached DequeIterNextNode getNextNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!dequeProfile.profile(inliningTarget, deque instanceof PDeque)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_OBJ_TYPE_S_GOT_P, BuiltinNames.T_DEQUE, deque); } PDequeIter dequeIter = PFactory.createDequeRevIter(language, (PDeque) deque); if (indexNoneProfile.profile(inliningTarget, indexObj != PNone.NO_VALUE)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java index 33c5ff36ea..a257283410 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java @@ -127,8 +127,8 @@ static Object construct(@SuppressWarnings("unused") Object cls, public abstract static class TokenNode extends PythonUnaryBuiltinNode { @Specialization Object construct(@SuppressWarnings("unused") Object cls, - @Cached PRaiseNode raise) { - throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.TOKEN_ONLY_BY_CONTEXTVAR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.TOKEN_ONLY_BY_CONTEXTVAR); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java index c20cc0a987..947eca1ea7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FcntlModuleBuiltins.java @@ -153,7 +153,7 @@ PNone lockf(VirtualFrame frame, int fd, int code, Object lenObj, Object startObj @Cached SysModuleBuiltins.AuditNode auditNode, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posix, @Cached PyLongAsLongNode asLongNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { auditNode.audit(inliningTarget, "fcntl.lockf", fd, code, lenObj != PNone.NO_VALUE ? lenObj : PNone.NONE, startObj != PNone.NO_VALUE ? startObj : PNone.NONE, whence); int lockType; @@ -164,7 +164,7 @@ PNone lockf(VirtualFrame frame, int fd, int code, Object lenObj, Object startObj } else if ((code & LOCK_EX.value) != 0) { lockType = F_WRLCK.getValueIfDefined(); } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNRECOGNIZED_LOCKF_ARGUMENT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNRECOGNIZED_LOCKF_ARGUMENT); } long start = 0; if (startObj != PNone.NO_VALUE) { @@ -209,7 +209,7 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Cached GilNode gilNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached SysModuleBuiltins.AuditNode auditNode) { auditNode.audit(inliningTarget, "fcnt.ioctl", fd, request, arg); @@ -249,7 +249,7 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat } } else { if (len > IOCTL_BUFSZ) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IOCTL_STRING_ARG_TOO_LONG); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IOCTL_STRING_ARG_TOO_LONG); } } if (ioctlArg == null) { @@ -285,7 +285,7 @@ Object ioctl(VirtualFrame frame, int fd, long request, Object arg, boolean mutat stringArg = switchEncodingNode.execute(stringArg, utf8); int len = stringArg.byteLength(utf8); if (len > IOCTL_BUFSZ) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IOCTL_STRING_ARG_TOO_LONG); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IOCTL_STRING_ARG_TOO_LONG); } byte[] ioctlArg = new byte[len + 1]; copyToByteArrayNode.execute(stringArg, 0, ioctlArg, 0, len, utf8); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java index ed28573a80..70ac43ebaf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java @@ -130,7 +130,7 @@ static final class NotAvailable extends PythonBuiltinNode { @Override public Object execute(VirtualFrame frame) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_DEBUG); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_DEBUG); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java index 339859f6a8..2933df3032 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java @@ -188,7 +188,7 @@ static Object doGeneric(VirtualFrame frame, TruffleString name, TruffleString ex @Cached TruffleString.EqualNode eqNode, @Cached WriteAttributeToObjectNode writeAttrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object module; PythonContext context = PythonContext.get(inliningTarget); @@ -199,7 +199,7 @@ static Object doGeneric(VirtualFrame frame, TruffleString name, TruffleString ex module = GraalHPyContext.loadHPyModule(inliningTarget, context, name, file, spec, hmode); } catch (CannotCastException e) { // thrown by getHPyModeFromEnviron if value is not a string - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.HPY_MODE_VALUE_MUST_BE_STRING); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_MODE_VALUE_MUST_BE_STRING); } catch (ApiInitException ie) { throw ie.reraise(frame, inliningTarget, constructAndRaiseNode); } catch (ImportException ie) { 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 5bc287952d..9cc60db297 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 @@ -827,13 +827,13 @@ private HashingStorage getStrategy(TruffleString tname, PythonLanguage lang) { case "economicmap": return EconomicMapStorage.create(); default: - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ValueError, ErrorMessages.UNKNOWN_STORAGE_STRATEGY); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.UNKNOWN_STORAGE_STRATEGY); } } private void validate(HashingStorage dictStorage) { if (HashingStorageLen.executeUncached(dictStorage) != 0) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ValueError, ErrorMessages.SHOULD_BE_USED_ONLY_NEW_SETS); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.SHOULD_BE_USED_ONLY_NEW_SETS); } } } @@ -868,25 +868,25 @@ public abstract static class JavaExtendNode extends PythonUnaryBuiltinNode { static Object doIt(Object value, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "3") InteropLibrary lib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (ImageInfo.inImageBuildtimeCode()) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnsupportedOperationException(ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM.toJavaStringUncached()); } if (ImageInfo.inImageRuntimeCode()) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM); } Env env = PythonContext.get(inliningTarget).getEnv(); if (!isType(value, env, lib)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_TYPE, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_TYPE, value); } try { return env.createHostAdapter(new Object[]{value}); } catch (Exception ex) { - throw raiseNode.get(inliningTarget).raise(TypeError, PythonUtils.getMessage(ex), ex); + throw raiseNode.raise(inliningTarget, TypeError, PythonUtils.getMessage(ex), ex); } } @@ -1194,7 +1194,7 @@ static Object replicate(TruffleString venvPath, int count, try { NativeLibraryLocator.replicate(context.getEnv().getPublicTruffleFile(venvPath.toJavaStringUncached()), context, count); } catch (IOException | InterruptedException e) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.ValueError, e); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, e); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java index ff40c6724b..7337778755 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java @@ -350,7 +350,7 @@ static int doPythonModule(VirtualFrame frame, PythonModule extensionModule, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "1") InteropLibrary lib, @Cached ExecModuleNode execModuleNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object nativeModuleDef = extensionModule.getNativeModuleDef(); if (nativeModuleDef == null) { return 0; @@ -367,7 +367,7 @@ static int doPythonModule(VirtualFrame frame, PythonModule extensionModule, PythonContext context = PythonContext.get(inliningTarget); if (!context.hasCApiContext()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.CAPI_NOT_YET_INITIALIZED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.CAPI_NOT_YET_INITIALIZED); } /* @@ -448,7 +448,7 @@ static Object run(VirtualFrame frame, PythonObject moduleSpec, return builtinModule; } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, toTruffleStringUncached("_imp.create_builtin")); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("_imp.create_builtin")); } } @@ -545,7 +545,7 @@ static Object run(VirtualFrame frame, TruffleString name, Object dataObj, @Cached TruffleString.EqualNode equalNode, @Cached InlinedConditionProfile isCodeObjectProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { FrozenInfo info; if (dataObj != PNone.NONE) { try { @@ -573,7 +573,7 @@ static Object run(VirtualFrame frame, TruffleString name, Object dataObj, } if (!isCodeObjectProfile.profile(inliningTarget, code instanceof PCode)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOT_A_CODE_OBJECT, name); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOT_A_CODE_OBJECT, name); } return code; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java index c7b724608d..9b2b721099 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java @@ -161,12 +161,12 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, @Cached InlinedConditionProfile negativeProfile, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (negativeProfile.profile(inliningTarget, r < 0)) { - throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); + throw raiseNode.raise(inliningTarget, ValueError, MUST_BE_NON_NEGATIVE, "r"); } PCombinations self = PFactory.createCombinations(language, cls, getInstanceShape.execute(cls)); @@ -209,12 +209,12 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, int r, @Cached InlinedConditionProfile negativeProfile, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (negativeProfile.profile(inliningTarget, r < 0)) { - throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); + throw raiseNode.raise(inliningTarget, ValueError, MUST_BE_NON_NEGATIVE, "r"); } PCombinationsWithReplacement self = PFactory.createCombinationsWithReplacement(language, cls, getInstanceShape.execute(cls)); self.setPool(toArrayNode.execute(frame, iterable)); @@ -246,9 +246,9 @@ static PCompress construct(VirtualFrame frame, Object cls, Object data, Object s @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } PCompress self = PFactory.createCompress(language, cls, getInstanceShape.execute(cls)); self.setData(getIter.execute(frame, inliningTarget, data)); @@ -280,15 +280,15 @@ static PCycle construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "cycle()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "cycle()"); } if (args.length != 1) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "cycle", 1); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "cycle", 1); } Object iterable = args[0]; PCycle self = PFactory.createCycle(language, cls, getInstanceShape.execute(cls)); @@ -313,15 +313,15 @@ static PDropwhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "dropwhile()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "dropwhile()"); } if (args.length != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "dropwhile", 2); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "dropwhile", 2); } Object predicate = args[0]; Object iterable = args[1]; @@ -347,15 +347,15 @@ static PFilterfalse construct(VirtualFrame frame, Object cls, Object[] args, PKe @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "filterfalse()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "filterfalse()"); } if (args.length != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "filterfalse", 2); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "filterfalse", 2); } Object func = args[0]; Object sequence = args[1]; @@ -398,9 +398,9 @@ static PGroupBy construct(VirtualFrame frame, Object cls, Object iterable, Objec @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } PGroupBy self = PFactory.createGroupBy(language, cls, getInstanceShape.execute(cls)); self.setKeyFunc(PGuards.isNone(key) ? null : key); @@ -419,12 +419,12 @@ static PGrouper construct(Object cls, Object parent, Object tgtKey, @Cached InlinedConditionProfile isPGroupByProfile, @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (!isPGroupByProfile.profile(inliningTarget, parent instanceof PGroupBy)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INCORRECT_USAGE_OF_INTERNAL_GROUPER); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INCORRECT_USAGE_OF_INTERNAL_GROUPER); } return PFactory.createGrouper(language, (PGroupBy) parent, tgtKey); } @@ -443,15 +443,15 @@ static PTakewhile construct(VirtualFrame frame, Object cls, Object[] args, PKeyw @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "takewhile()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "takewhile()"); } if (args.length != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "takewhile", 2); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "takewhile", 2); } Object predicate = args[0]; Object iterable = args[1]; @@ -474,8 +474,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @SuppressWarnings("unused") @Specialization(guards = "n < 0") static Object negativeN(Object iterable, int n, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, S_MUST_BE_S, "n", ">=0"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, S_MUST_BE_S, "n", ">=0"); } @SuppressWarnings("unused") @@ -528,7 +528,7 @@ PTeeDataObject construct(Object cls, Object[] arguments, PKeyword[] keywords, @Bind PythonLanguage language) { if (!isTypeNode.execute(inliningTarget, cls)) { errorProfile.enter(inliningTarget); - throw raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } return PFactory.createTeeDataObject(language); } @@ -560,9 +560,9 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, Object @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!wrongTypeProfile.profile(inliningTarget, isTypeNode.execute(inliningTarget, cls))) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } int r; Object[] pool = toArrayNode.execute(frame, iterable); @@ -573,11 +573,11 @@ static Object construct(VirtualFrame frame, Object cls, Object iterable, Object r = castToInt.execute(inliningTarget, rArg); } catch (CannotCastException e) { wrongRprofile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_INT_AS_R); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_INT_AS_R); } if (r < 0) { negRprofile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, MUST_BE_NON_NEGATIVE, "r"); + throw raiseNode.raise(inliningTarget, ValueError, MUST_BE_NON_NEGATIVE, "r"); } } PPermutations self = PFactory.createPermutations(language, cls, getInstanceShape.execute(cls)); @@ -689,9 +689,8 @@ static Object constructNoRepeat(Object cls, @SuppressWarnings("unused") Object[] @Specialization(guards = {"isTypeNode.execute(inliningTarget, cls)", "repeat < 0"}, limit = "1") static Object constructNeg(Object cls, Object[] iterables, int repeat, @Bind("this") Node inliningTarget, - @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARG_CANNOT_BE_NEGATIVE, "repeat"); + @Exclusive @Cached IsTypeNode isTypeNode) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARG_CANNOT_BE_NEGATIVE, "repeat"); } private static void constructOneRepeat(VirtualFrame frame, PProduct self, Object[] iterables, ToArrayNode toArrayNode) { @@ -726,9 +725,8 @@ private static Object[][] unpackIterables(VirtualFrame frame, Object[] iterables @SuppressWarnings("unused") static Object construct(Object cls, Object iterables, Object repeat, @Bind("this") Node inliningTarget, - @Shared("typeNode") @Cached IsTypeNode isTypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + @Shared("typeNode") @Cached IsTypeNode isTypeNode) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } } @@ -746,7 +744,7 @@ static Object construct(VirtualFrame frame, Object cls, Object object, Object ti @Cached TypeNodes.GetInstanceShape getInstanceShape) { PRepeat self = PFactory.createRepeat(language, cls, getInstanceShape.execute(cls)); self.setElement(object); - if (timesObj != PNone.NONE) { + if (timesObj != PNone.NO_VALUE) { int times = asSizeNode.executeExact(frame, inliningTarget, timesObj); self.setCnt(times > 0 ? times : 0); } else { @@ -769,12 +767,12 @@ static PChain construct(VirtualFrame frame, Object cls, Object[] args, PKeyword[ @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "chain()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "chain()"); } PChain self = PFactory.createChain(language, cls, getInstanceShape.execute(cls)); self.setSource(getIter.execute(frame, inliningTarget, PFactory.createList(language, args))); @@ -801,15 +799,15 @@ static Object construct(Object cls, Object start, Object step, @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (!checkNode.execute(inliningTarget, start)) { - throw raiseNode.get(inliningTarget).raise(TypeError, NUMBER_IS_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, NUMBER_IS_REQUIRED); } if (!checkNode.execute(inliningTarget, step)) { - throw raiseNode.get(inliningTarget).raise(TypeError, NUMBER_IS_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, NUMBER_IS_REQUIRED); } PCount self = PFactory.createCount(language, cls, getInstanceShape.execute(cls)); self.setCnt(start); @@ -831,15 +829,15 @@ static PStarmap construct(VirtualFrame frame, Object cls, Object[] args, PKeywor @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "starmap()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "starmap()"); } if (args.length != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "starmap", 2); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_EXPECTED_D_ARGS, "starmap", 2); } Object fun = args[0]; Object iterable = args[1]; @@ -876,17 +874,17 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { wrongTypeBranch.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } if (keywords.length > 0 && hasObjectInitNode.executeCached(cls)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "islice()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "islice()"); } if (args.length < 2 || args.length > 4) { wrongArgsBranch.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ISLICE_WRONG_ARGS); + throw raiseNode.raise(inliningTarget, TypeError, ISLICE_WRONG_ARGS); } int start = 0; int step = 1; @@ -898,12 +896,12 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo stop = asIntNode.executeExact(frame, inliningTarget, args[1], OverflowError); } catch (PException e) { stopNotInt.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); + throw raiseNode.raise(inliningTarget, ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); } } if (stop < -1 || stop > SysModuleBuiltins.MAXSIZE) { stopWrongValue.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); + throw raiseNode.raise(inliningTarget, ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); } } else if (argsLen2.profile(inliningTarget, args.length == 3) || argsLen3.profile(inliningTarget, args.length == 4)) { if (args[1] != PNone.NONE) { @@ -912,7 +910,7 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo start = asIntNode.executeExact(frame, inliningTarget, args[1], OverflowError); } catch (PException e) { startNotInt.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); + throw raiseNode.raise(inliningTarget, ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); } } if (args[2] != PNone.NONE) { @@ -921,12 +919,12 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo stop = asIntNode.executeExact(frame, inliningTarget, args[2], OverflowError); } catch (PException e) { stopNotInt.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, S_FOR_ISLICE_MUST_BE, "Stop argument"); + throw raiseNode.raise(inliningTarget, ValueError, S_FOR_ISLICE_MUST_BE, "Stop argument"); } } if (start < 0 || stop < -1 || start > SysModuleBuiltins.MAXSIZE || stop > SysModuleBuiltins.MAXSIZE) { wrongValue.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); + throw raiseNode.raise(inliningTarget, ValueError, S_FOR_ISLICE_MUST_BE, "Indices"); } } if (argsLen3.profile(inliningTarget, args.length == 4)) { @@ -941,7 +939,7 @@ static Object constructOne(VirtualFrame frame, Object cls, Object[] args, PKeywo } if (step < 1) { stepWrongValue.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, STEP_FOR_ISLICE_MUST_BE); + throw raiseNode.raise(inliningTarget, ValueError, STEP_FOR_ISLICE_MUST_BE); } } Object iterable = args[0]; @@ -975,11 +973,11 @@ static Object construct(VirtualFrame frame, Object cls, Object[] args, Object fi @Cached InlinedBranchProfile errorProfile, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { // Note: @Fallback or other @Specialization generate data-class errorProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } Object fillValue = fillValueIn; @@ -1013,10 +1011,10 @@ static PPairwise construct(VirtualFrame frame, Object cls, Object iterable, @Cached IsTypeNode isTypeNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, cls)) { // Note: @Fallback or other @Specialization generate data-class - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls); } PPairwise self = PFactory.createPairwise(language, cls, getInstanceShape.execute(cls)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JArrayModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JArrayModuleBuiltins.java index 263d6183e9..5f236f1b85 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JArrayModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JArrayModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -150,8 +150,8 @@ static Object d(int length, @SuppressWarnings("unused") String typeCode) { @Fallback @SuppressWarnings("unused") static Object error(int length, String typeCode, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.INVALID_TYPE_CODE, typeCode); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.INVALID_TYPE_CODE, typeCode); } protected static boolean eq(String a, String b) { @@ -178,7 +178,7 @@ static Object fromTypeCode(int length, Object typeCodeObj, @Specialization(guards = "!isString(classObj)") static Object fromClass(int length, Object classObj, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleLanguage.Env env = PythonContext.get(inliningTarget).getEnv(); if (env.isHostObject(classObj)) { Object clazz = env.asHostObject(classObj); @@ -187,7 +187,7 @@ static Object fromClass(int length, Object classObj, return env.asGuestValue(array); } } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SECOND_ARG_MUST_BE_STR_OR_JAVA_CLS, classObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SECOND_ARG_MUST_BE_STR_OR_JAVA_CLS, classObj); } @Override @@ -206,7 +206,7 @@ static Object fromSequence(PSequence sequence, Object type, @Shared @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemScalarNode, @Shared @Cached ZerosNode zerosNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, sequence); int length = storage.length(); Object array = zerosNode.execute(length, type); @@ -215,7 +215,7 @@ static Object fromSequence(PSequence sequence, Object type, try { lib.writeArrayElement(array, i, value); } catch (UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); } catch (UnsupportedMessageException | InvalidArrayIndexException e) { throw CompilerDirectives.shouldNotReachHere("failed to set array item"); } @@ -231,7 +231,7 @@ static Object fromIterable(VirtualFrame frame, Object sequence, Object type, @Shared @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemScalarNode, @Shared @Cached ZerosNode zerosNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PList list = constructListNode.execute(frame, sequence); return fromSequence(list, type, inliningTarget, lib, getSequenceStorageNode, getItemScalarNode, zerosNode, raiseNode); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JavaModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JavaModuleBuiltins.java index 4f9f74f27b..f3a83edf88 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JavaModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/JavaModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -128,10 +128,10 @@ abstract static class TypeNode extends PythonUnaryBuiltinNode { static Object type(Object name, @Bind("this") Node inliningTarget, @Cached CastToJavaStringNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Env env = PythonContext.get(inliningTarget).getEnv(); if (!env.isHostLookupAllowed()) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.NotImplementedError, ErrorMessages.HOST_LOOKUP_NOT_ALLOWED); + throw raiseNode.raise(inliningTarget, PythonErrorType.NotImplementedError, ErrorMessages.HOST_LOOKUP_NOT_ALLOWED); } String javaString = castToStringNode.execute(name); Object hostValue; @@ -141,7 +141,7 @@ static Object type(Object name, hostValue = null; } if (hostValue == null) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.KeyError, ErrorMessages.HOST_SYM_NOT_DEFINED, javaString); + throw raiseNode.raise(inliningTarget, PythonErrorType.KeyError, ErrorMessages.HOST_SYM_NOT_DEFINED, javaString); } else { return hostValue; } @@ -149,8 +149,8 @@ static Object type(Object name, @Fallback static Object doError(Object object, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_P, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_P, object); } } @@ -161,10 +161,10 @@ abstract static class AddToClassPathNode extends PythonBuiltinNode { static PNone add(Object[] args, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castToString, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Env env = PythonContext.get(inliningTarget).getEnv(); if (!env.isHostLookupAllowed()) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.NotImplementedError, ErrorMessages.HOST_ACCESS_NOT_ALLOWED); + throw raiseNode.raise(inliningTarget, PythonErrorType.NotImplementedError, ErrorMessages.HOST_ACCESS_NOT_ALLOWED); } for (int i = 0; i < args.length; i++) { Object arg = args[i]; @@ -175,9 +175,9 @@ static PNone add(Object[] args, // implicitly env.addToHostClassPath(PythonContext.get(inliningTarget).getPublicTruffleFileRelaxed(entry, T_JAR)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CLASSPATH_ARG_MUST_BE_STRING, i + 1, arg); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CLASSPATH_ARG_MUST_BE_STRING, i + 1, arg); } catch (SecurityException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INVALD_OR_UNREADABLE_CLASSPATH, entry, e); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INVALD_OR_UNREADABLE_CLASSPATH, entry, e); } } return PNone.NONE; @@ -232,7 +232,7 @@ static boolean check(Object object, Object klass, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared("isForeign1") @Cached IsForeignObjectNode isForeign1, @SuppressWarnings("unused") @Shared("isForeign2") @Cached IsForeignObjectNode isForeign2, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Env env = PythonContext.get(inliningTarget).getEnv(); try { Object hostKlass = env.asHostObject(klass); @@ -240,7 +240,7 @@ static boolean check(Object object, Object klass, return ((Class) hostKlass).isInstance(object); } } catch (ClassCastException cce) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.KLASS_ARG_IS_NOT_HOST_OBJ, klass); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.KLASS_ARG_IS_NOT_HOST_OBJ, klass); } return false; } @@ -250,7 +250,7 @@ static boolean checkForeign(Object object, Object klass, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared("isForeign1") @Cached IsForeignObjectNode isForeign1, @SuppressWarnings("unused") @Shared("isForeign2") @Cached IsForeignObjectNode isForeign2, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Env env = PythonContext.get(inliningTarget).getEnv(); try { Object hostObject = env.asHostObject(object); @@ -259,15 +259,15 @@ static boolean checkForeign(Object object, Object klass, return ((Class) hostKlass).isInstance(hostObject); } } catch (ClassCastException cce) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.OBJ_OR_KLASS_ARGS_IS_NOT_HOST_OBJ, object, klass); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.OBJ_OR_KLASS_ARGS_IS_NOT_HOST_OBJ, object, klass); } return false; } @Fallback static boolean fallback(Object object, Object klass, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.UNSUPPORTED_INSTANCEOF, object, klass); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.UNSUPPORTED_INSTANCEOF, object, klass); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java index 67fce07408..24a7747f03 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java @@ -192,7 +192,7 @@ private static String setCurrent(PythonContext ctx, int category, String posixLo if (newLocale != null) { ctx.setCurrentLocale(current.withCategory(category, newLocale)); } else { - throw PRaiseNode.raiseUncached(nodeForRaise, PythonErrorType.ValueError, ErrorMessages.UNSUPPORTED_LOCALE_SETTING); + throw PRaiseNode.raiseStatic(nodeForRaise, PythonErrorType.ValueError, ErrorMessages.UNSUPPORTED_LOCALE_SETTING); } return LocaleUtils.toPosix(newLocale); } @@ -204,10 +204,10 @@ static TruffleString doGeneric(VirtualFrame frame, Object category, Object posix @Cached CastToTruffleStringNode castToStringNode, @Cached FromJavaStringNode resultAsTruffleStringNode, @Cached ToJavaStringNode toJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long l = asLongNode.execute(frame, inliningTarget, category); if (!isValidCategory(l)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.INVALID_LOCALE_CATEGORY); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.INVALID_LOCALE_CATEGORY); } TruffleString posixLocaleIDStr = null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java index a8c503b1da..4637f001af 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LsprofModuleBuiltins.java @@ -146,7 +146,7 @@ Profiler doit(Object cls, @SuppressWarnings("unused") Object[] args, @SuppressWa return PFactory.createProfiler(context.getLanguage(), cls, TypeNodes.GetInstanceShape.executeUncached(cls), sampler); } } - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.NotImplementedError, ErrorMessages.COVERAGE_TRACKER_NOT_AVAILABLE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.NotImplementedError, ErrorMessages.COVERAGE_TRACKER_NOT_AVAILABLE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java index 962926ddc9..2cc96ed78e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MMapModuleBuiltins.java @@ -169,12 +169,12 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixSupport, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (lengthIn < 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MEM_MAPPED_LENGTH_MUST_BE_POSITIVE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MEM_MAPPED_LENGTH_MUST_BE_POSITIVE); } if (offset < 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MEM_MAPPED_OFFSET_MUST_BE_POSITIVE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MEM_MAPPED_OFFSET_MUST_BE_POSITIVE); } int flags = flagsIn; int prot = protIn; @@ -203,7 +203,7 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int } break; default: - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEM_MAPPED_OFFSET_INVALID_ACCESS); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEM_MAPPED_OFFSET_INVALID_ACCESS); } auditNode.audit(inliningTarget, "mmap.__new__", fd, lengthIn, access, offset); @@ -220,15 +220,15 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int } if (fstatResult != null && length == 0) { if (fstatResult[ST_SIZE] == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_MMAP_AN_EMPTY_FILE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_MMAP_AN_EMPTY_FILE); } if (offset >= fstatResult[ST_SIZE]) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MMAP_S_IS_GREATER_THAN_FILE_SIZE, "offset"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MMAP_S_IS_GREATER_THAN_FILE_SIZE, "offset"); } // Unlike in CPython, this always fits in the long range length = fstatResult[ST_SIZE] - offset; } else if (fstatResult != null && (offset > fstatResult[ST_SIZE] || fstatResult[ST_SIZE] - offset < length)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MMAP_S_IS_GREATER_THAN_FILE_SIZE, "length"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MMAP_S_IS_GREATER_THAN_FILE_SIZE, "length"); } } @@ -260,8 +260,8 @@ static PMMap doFile(VirtualFrame frame, Object clazz, int fd, long lengthIn, int @Specialization(guards = "isIllegal(fd)") @SuppressWarnings("unused") static PMMap doIllegal(Object clazz, int fd, long lengthIn, int flagsIn, int protIn, int accessIn, long offset, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.OSError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.OSError); } protected static boolean isIllegal(int fd) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java index dbe0c43be8..d858f0ee50 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java @@ -162,7 +162,7 @@ static Object doit(VirtualFrame frame, Object value, Object file, int version, @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached("createCallWriteNode()") LookupAndCallBinaryNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonLanguage language = context.getLanguage(inliningTarget); PythonContext.PythonThreadState threadState = context.getThreadState(language); Object savedState = IndirectCallContext.enter(frame, threadState, indirectCallData); @@ -171,7 +171,7 @@ static Object doit(VirtualFrame frame, Object value, Object file, int version, } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { - throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); + throw raiseNode.raise(inliningTarget, me.type, me.message, me.arguments); } finally { IndirectCallContext.exit(frame, threadState, savedState); } @@ -192,7 +192,7 @@ static Object doit(VirtualFrame frame, Object value, int version, @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonLanguage language = context.getLanguage(inliningTarget); PythonContext.PythonThreadState threadState = context.getThreadState(language); Object savedState = IndirectCallContext.enter(frame, threadState, indirectCallData); @@ -201,7 +201,7 @@ static Object doit(VirtualFrame frame, Object value, int version, } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { - throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); + throw raiseNode.raise(inliningTarget, me.type, me.message, me.arguments); } finally { IndirectCallContext.exit(frame, threadState, savedState); } @@ -222,17 +222,17 @@ static Object doit(VirtualFrame frame, Object file, @Bind PythonContext context, @Cached("createCallReadNode()") LookupAndCallBinaryNode callNode, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = callNode.executeObject(frame, file, 0); if (!bufferLib.hasBuffer(buffer)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.READ_RETURNED_NOT_BYTES, buffer); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.READ_RETURNED_NOT_BYTES, buffer); } try { return Marshal.loadFile(context, file); } catch (NumberFormatException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } catch (Marshal.MarshalError me) { - throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); + throw raiseNode.raise(inliningTarget, me.type, me.message, me.arguments); } } } @@ -248,13 +248,13 @@ static Object doit(VirtualFrame frame, Object buffer, @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return Marshal.load(context, bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer)); } catch (NumberFormatException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } catch (Marshal.MarshalError me) { - throw raiseNode.get(inliningTarget).raise(me.type, me.message, me.arguments); + throw raiseNode.raise(inliningTarget, me.type, me.message, me.arguments); } finally { bufferLib.release(buffer, frame, indirectCallData); } @@ -1348,7 +1348,7 @@ private PCode readCode() { } @TruffleBoundary - public static byte[] serializeCodeUnit(PythonContext context, CodeUnit code) { + public static byte[] serializeCodeUnit(Node node, PythonContext context, CodeUnit code) { try { Marshal marshal = new Marshal(context, CURRENT_VERSION, null, null); marshal.writeCodeUnit(code); @@ -1356,19 +1356,19 @@ public static byte[] serializeCodeUnit(PythonContext context, CodeUnit code) { } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { - throw PRaiseNode.getUncached().raise(me.type, me.message, me.arguments); + throw PRaiseNode.raiseStatic(node, me.type, me.message, me.arguments); } } @TruffleBoundary - public static CodeUnit deserializeCodeUnit(PythonContext context, byte[] bytes) { + public static CodeUnit deserializeCodeUnit(Node node, PythonContext context, byte[] bytes) { try { Marshal marshal = new Marshal(context, bytes, bytes.length); return marshal.readCodeUnit(); } catch (Marshal.MarshalError me) { - throw PRaiseNode.getUncached().raise(me.type, me.message, me.arguments); + throw PRaiseNode.raiseStatic(node, me.type, me.message, me.arguments); } catch (NumberFormatException e) { - throw PRaiseNode.getUncached().raise(ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); + throw PRaiseNode.raiseStatic(node, ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java index 4e98b5bb38..19899dc92b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java @@ -125,21 +125,21 @@ public MathModuleBuiltins() { addBuiltinConstant("nan", Double.NaN); } - static void checkMathRangeError(boolean con, Node inliningTarget, PRaiseNode.Lazy raiseNode) { + static void checkMathRangeError(boolean con, Node inliningTarget, PRaiseNode raiseNode) { if (con) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } } - static void checkMathDomainError(boolean con, Node inliningTarget, PRaiseNode.Lazy raiseNode) { + static void checkMathDomainError(boolean con, Node inliningTarget, PRaiseNode raiseNode) { if (con) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } } static void checkMathDomainErrorUncached(boolean con, Node raisingNode) { if (con) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } } @@ -151,37 +151,37 @@ public abstract static class MathUnaryHelperNode extends Node { @FunctionalInterface interface Op { - double compute(Node inliningTarget, double arg, PRaiseNode.Lazy raiseNode); + double compute(Node inliningTarget, double arg, PRaiseNode raiseNode); } abstract double execute(VirtualFrame frame, Node inliningTarget, Object value, Op op); @Specialization static double doL(Node inliningTarget, long value, Op op, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return computeAndCheckDomain(inliningTarget, value, op, raiseNode); } @Specialization static double doD(Node inliningTarget, double value, Op op, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return computeAndCheckDomain(inliningTarget, value, op, raiseNode); } @Specialization static double doPI(Node inliningTarget, PInt value, Op op, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return computeAndCheckDomain(inliningTarget, value.doubleValueWithOverflow(inliningTarget), op, raiseNode); } @Specialization(guards = "!isNumber(value)") static double doGeneral(VirtualFrame frame, Node inliningTarget, Object value, Op op, @Cached PyFloatAsDoubleNode asDoubleNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return computeAndCheckDomain(inliningTarget, asDoubleNode.execute(frame, inliningTarget, value), op, raiseNode); } - private static double computeAndCheckDomain(Node inliningTarget, double arg, Op op, PRaiseNode.Lazy raiseNode) { + private static double computeAndCheckDomain(Node inliningTarget, double arg, Op op, PRaiseNode raiseNode) { double res = op.compute(inliningTarget, arg, raiseNode); checkMathDomainError(Double.isNaN(res) && !Double.isNaN(arg), inliningTarget, raiseNode); return res; @@ -238,7 +238,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SqrtNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(value < 0, inliningTarget, raiseNode); return Math.sqrt(value); } @@ -255,7 +255,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, ExpNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double result = Math.exp(value); checkMathRangeError(Double.isFinite(value) && Double.isInfinite(result), inliningTarget, raiseNode); return result; @@ -273,7 +273,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, Expm1Node::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double result = Math.expm1(value); checkMathRangeError(Double.isFinite(value) && Double.isInfinite(result), inliningTarget, raiseNode); return result; @@ -352,8 +352,8 @@ private static BigInteger factorialPart(long start, long n) { @Specialization(guards = {"value < 0"}) static long factorialNegativeInt(@SuppressWarnings("unused") int value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); } @Specialization(guards = {"0 <= value", "value < SMALL_FACTORIALS.length"}) @@ -369,8 +369,8 @@ static PInt factorialInt(int value, @Specialization(guards = {"value < 0"}) static long factorialNegativeLong(@SuppressWarnings("unused") long value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); } @Specialization(guards = {"0 <= value", "value < SMALL_FACTORIALS.length"}) @@ -390,14 +390,14 @@ static Object factorialObject(VirtualFrame frame, Object value, @Cached PyLongAsLongAndOverflowNode convert, @Cached PyNumberAsSizeNode asSizeNode, @Cached FactorialNode recursiveNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return recursiveNode.execute(frame, convert.execute(frame, inliningTarget, value)); } catch (OverflowException e) { if (asSizeNode.executeLossy(frame, inliningTarget, value) >= 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.FACTORIAL_ARGUMENT_SHOULD_NOT_EXCEED_D, Long.MAX_VALUE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.FACTORIAL_ARGUMENT_SHOULD_NOT_EXCEED_D, Long.MAX_VALUE); } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.FACTORIAL_NOT_DEFINED_FOR_NEGATIVE); } } } @@ -413,10 +413,10 @@ public abstract static class CombNode extends PythonBinaryBuiltinNode { @TruffleBoundary private BigInteger calculateComb(BigInteger n, BigInteger k) { if (n.signum() < 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "n"); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "n"); } if (k.signum() < 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "k"); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "k"); } BigInteger factors = k.min(n.subtract(k)); @@ -483,10 +483,10 @@ public abstract static class PermNode extends PythonBinaryBuiltinNode { @TruffleBoundary private BigInteger calculatePerm(BigInteger n, BigInteger k) { if (n.signum() < 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "n"); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "n"); } if (k.signum() < 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "k"); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE_INTEGER, "k"); } if (n.compareTo(k) < 0) { return BigInteger.ZERO; @@ -590,15 +590,15 @@ static double fmodDD(double left, double right, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile infProfile, @Cached InlinedConditionProfile zeroProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { raiseMathDomainError(inliningTarget, Double.isInfinite(left), infProfile, raiseNode); raiseMathDomainError(inliningTarget, right == 0, zeroProfile, raiseNode); return left % right; } - static void raiseMathDomainError(Node inliningTarget, boolean con, InlinedConditionProfile profile, PRaiseNode.Lazy raiseNode) { + static void raiseMathDomainError(Node inliningTarget, boolean con, InlinedConditionProfile profile, PRaiseNode raiseNode) { if (profile.profile(inliningTarget, con)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } } @@ -617,10 +617,10 @@ public abstract static class RemainderNode extends PythonBinaryClinicBuiltinNode @Specialization static double remainderDD(double x, double y, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (Double.isFinite(x) && Double.isFinite(y)) { if (y == 0.0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } double absx = Math.abs(x); double absy = Math.abs(y); @@ -643,7 +643,7 @@ static double remainderDD(double x, double y, return y; } if (Double.isInfinite(x)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } return x; } @@ -754,11 +754,11 @@ public abstract static class IsCloseNode extends PythonClinicBuiltinNode { @Specialization static boolean isCloseDouble(double a, double b, double rel_tol, double abs_tol, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { double diff; if (rel_tol < 0.0 || abs_tol < 0.0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TOLERANCE_MUST_NON_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOLERANCE_MUST_NON_NEGATIVE); } if (a == b) { @@ -797,9 +797,9 @@ private static int makeInt(long x) { return (int) result; } - private static double exceptInfinity(Node inliningTarget, double result, double arg, PRaiseNode.Lazy raiseNode) { + private static double exceptInfinity(Node inliningTarget, double result, double arg, PRaiseNode raiseNode) { if (Double.isInfinite(result) && !Double.isInfinite(arg)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } else { return result; } @@ -808,7 +808,7 @@ private static double exceptInfinity(Node inliningTarget, double result, double @Specialization static double ldexp(double mantissa, long exp, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return exceptInfinity(inliningTarget, Math.scalb(mantissa, makeInt(exp)), mantissa, raiseNode); } @@ -819,12 +819,12 @@ static double ldexp(VirtualFrame frame, double mantissa, Object exp, @Cached IsSubtypeNode isSubtypeNode, @Cached PyNumberIndexNode indexNode, @Cached CastToJavaLongLossyNode cast, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (isSubtypeNode.execute(getClassNode.execute(inliningTarget, exp), PythonBuiltinClassType.PInt)) { long longExp = cast.execute(inliningTarget, indexNode.execute(frame, inliningTarget, exp)); return ldexp(mantissa, longExp, inliningTarget, raiseNode); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_INT_MESSAGE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_INT_MESSAGE); } } @@ -870,7 +870,7 @@ static double doIt(VirtualFrame frame, Object iterable, @Cached("create(Next)") LookupAndCallUnaryNode callNextNode, @Cached PyFloatAsDoubleNode asDoubleNode, @Cached IsBuiltinObjectProfile stopProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object iterator = getIter.execute(frame, inliningTarget, iterable); return fsum(frame, iterator, callNextNode, asDoubleNode, inliningTarget, stopProfile, raiseNode); } @@ -886,7 +886,7 @@ static double doIt(VirtualFrame frame, Object iterable, * CPython ~0.6s CurrentImpl: ~14.3s Using BigDecimal: ~15.1 */ private static double fsum(VirtualFrame frame, Object iterator, LookupAndCallUnaryNode next, - PyFloatAsDoubleNode asDoubleNode, Node inliningTarget, IsBuiltinObjectProfile stopProfile, PRaiseNode.Lazy raiseNode) { + PyFloatAsDoubleNode asDoubleNode, Node inliningTarget, IsBuiltinObjectProfile stopProfile, PRaiseNode raiseNode) { double x, y, t, hi, lo = 0, yr, inf_sum = 0, special_sum = 0, sum; double xsave; int i, j, n = 0, arayLength = 32; @@ -923,7 +923,7 @@ private static double fsum(VirtualFrame frame, Object iterator, LookupAndCallUna * as a result of a nan or inf in the summands */ if (Double.isFinite(xsave)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.INTERMEDIATE_OVERFLOW_IN, "fsum"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.INTERMEDIATE_OVERFLOW_IN, "fsum"); } if (Double.isInfinite(xsave)) { inf_sum += xsave; @@ -942,7 +942,7 @@ private static double fsum(VirtualFrame frame, Object iterator, LookupAndCallUna if (special_sum != 0.0) { if (Double.isNaN(inf_sum)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_INF_PLUS_INF_IN); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_INF_PLUS_INF_IN); } else { sum = special_sum; return sum; @@ -1029,7 +1029,7 @@ public static int gcdEmpty(Object self, Object[] args, PKeyword[] keywords) { @Specialization(guards = "keywords.length != 0") @SuppressWarnings("unused") public int gcdKeywords(Object self, Object[] args, PKeyword[] keywords) { - throw raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "gcd()"); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "gcd()"); } } @@ -1082,32 +1082,32 @@ PInt gcd(PInt x, PInt y, @Specialization static int gcd(@SuppressWarnings("unused") double x, @SuppressWarnings("unused") double y, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); } @Specialization static int gcd(@SuppressWarnings("unused") long x, @SuppressWarnings("unused") double y, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); } @Specialization static int gcd(@SuppressWarnings("unused") double x, @SuppressWarnings("unused") long y, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); } @Specialization static int gcd(@SuppressWarnings("unused") double x, @SuppressWarnings("unused") PInt y, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); } @Specialization(guards = "!isRecursive") static int gcd(@SuppressWarnings("unused") PInt x, @SuppressWarnings("unused") double y, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float"); } @Specialization(guards = {"!isRecursive", "!isNumber(x) || !isNumber(y)"}) @@ -1123,7 +1123,7 @@ static Object gcd(VirtualFrame frame, Object x, Object y, @Specialization Object gcdNative(@SuppressWarnings("unused") PythonAbstractNativeObject a, @SuppressWarnings("unused") Object b) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.GCD_FOR_NATIVE_NOT_SUPPORTED); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.GCD_FOR_NATIVE_NOT_SUPPORTED); } @NeverDefault @@ -1186,7 +1186,7 @@ public static int gcdEmpty(Object self, Object[] args, PKeyword[] keywords) { @Specialization(guards = "keywords.length != 0") @SuppressWarnings("unused") public int gcdKeywords(Object self, Object[] args, PKeyword[] keywords) { - throw raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "gcd()"); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "gcd()"); } } @@ -1250,7 +1250,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AcosNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(Double.isInfinite(value) || -1 > value || value > 1, inliningTarget, raiseNode); return Math.acos(value); } @@ -1284,7 +1284,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AcoshNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(value < 1, inliningTarget, raiseNode); return MathUtils.acosh(value); } @@ -1301,7 +1301,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AsinNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(value < -1 || value > 1, inliningTarget, raiseNode); return Math.asin(value); } @@ -1318,7 +1318,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, CosNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return Math.cos(value); } } @@ -1334,7 +1334,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, CoshNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double result = Math.cosh(value); checkMathRangeError(Double.isInfinite(result) && Double.isFinite(value), inliningTarget, raiseNode); return result; @@ -1352,7 +1352,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SinNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return Math.sin(value); } } @@ -1368,7 +1368,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, SinhNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double result = Math.sinh(value); checkMathRangeError(Double.isInfinite(result) && Double.isFinite(value), inliningTarget, raiseNode); return result; @@ -1386,7 +1386,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, TanNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return Math.tan(value); } } @@ -1402,7 +1402,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, TanhNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return Math.tanh(value); } } @@ -1418,7 +1418,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AtanNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return Math.atan(value); } } @@ -1434,7 +1434,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AtanhNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double abs = Math.abs(value); checkMathDomainError(abs >= 1.0, inliningTarget, raiseNode); return MathUtils.atanh(value); @@ -1454,7 +1454,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, AsinhNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return MathUtils.asinh(value); } @@ -1549,18 +1549,18 @@ protected static double logBigInteger(BigInteger val) { return blex > 0 ? res + blex * LOG2 : res; } - private static double countBase(double base, Node inliningTarget, InlinedConditionProfile divByZero, PRaiseNode.Lazy raiseNode) { + private static double countBase(double base, Node inliningTarget, InlinedConditionProfile divByZero, PRaiseNode raiseNode) { double logBase = Math.log(base); if (divByZero.profile(inliningTarget, logBase == 0)) { - throw raiseNode.get(inliningTarget).raise(ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "float"); + throw raiseNode.raise(inliningTarget, ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "float"); } return logBase; } - private static double countBase(BigInteger base, Node inliningTarget, InlinedConditionProfile divByZero, PRaiseNode.Lazy raiseNode) { + private static double countBase(BigInteger base, Node inliningTarget, InlinedConditionProfile divByZero, PRaiseNode raiseNode) { double logBase = logBigInteger(base); if (divByZero.profile(inliningTarget, logBase == 0)) { - throw raiseNode.get(inliningTarget).raise(ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "float"); + throw raiseNode.raise(inliningTarget, ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "float"); } return logBase; } @@ -1569,7 +1569,7 @@ private static double countBase(BigInteger base, Node inliningTarget, InlinedCon static double log(long value, PNone novalue, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return logDN(value, novalue, inliningTarget, doNotFit, raiseNode); } @@ -1577,7 +1577,7 @@ static double log(long value, PNone novalue, static double logDN(double value, @SuppressWarnings("unused") PNone novalue, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseMathError(inliningTarget, doNotFit, value <= 0, raiseNode); return Math.log(value); } @@ -1587,7 +1587,7 @@ static double logDN(double value, @SuppressWarnings("unused") PNone novalue, static double logPIN(PInt value, @SuppressWarnings("unused") PNone novalue, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { BigInteger bValue = value.getValue(); raiseMathError(inliningTarget, doNotFit, bValue.compareTo(BigInteger.ZERO) < 0, raiseNode); return logBigInteger(bValue); @@ -1598,7 +1598,7 @@ static double logLL(long value, long base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return logDD(value, base, inliningTarget, doNotFit, divByZero, raiseNode); } @@ -1607,7 +1607,7 @@ static double logDL(double value, long base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return logDD(value, base, inliningTarget, doNotFit, divByZero, raiseNode); } @@ -1616,7 +1616,7 @@ static double logLD(long value, double base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return logDD(value, base, inliningTarget, doNotFit, divByZero, raiseNode); } @@ -1625,7 +1625,7 @@ static double logDD(double value, double base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseMathError(inliningTarget, doNotFit, value < 0 || base <= 0, raiseNode); double logBase = countBase(base, inliningTarget, divByZero, raiseNode); return Math.log(value) / logBase; @@ -1637,7 +1637,7 @@ static double logDPI(double value, PInt base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { BigInteger bBase = base.getValue(); raiseMathError(inliningTarget, doNotFit, value < 0 || bBase.compareTo(BigInteger.ZERO) <= 0, raiseNode); double logBase = countBase(bBase, inliningTarget, divByZero, raiseNode); @@ -1649,7 +1649,7 @@ static double logPIL(PInt value, long base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return logPID(value, base, inliningTarget, doNotFit, divByZero, raiseNode); } @@ -1659,7 +1659,7 @@ static double logPID(PInt value, double base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { BigInteger bValue = value.getValue(); raiseMathError(inliningTarget, doNotFit, bValue.compareTo(BigInteger.ZERO) < 0 || base <= 0, raiseNode); double logBase = countBase(base, inliningTarget, divByZero, raiseNode); @@ -1672,7 +1672,7 @@ static double logLPI(long value, PInt base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { BigInteger bBase = base.getValue(); raiseMathError(inliningTarget, doNotFit, value < 0 || bBase.compareTo(BigInteger.ZERO) <= 0, raiseNode); double logBase = countBase(bBase, inliningTarget, divByZero, raiseNode); @@ -1685,7 +1685,7 @@ static double logPIPI(PInt value, PInt base, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile doNotFit, @Shared @Cached InlinedConditionProfile divByZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { BigInteger bValue = value.getValue(); BigInteger bBase = base.getValue(); raiseMathError(inliningTarget, doNotFit, bValue.compareTo(BigInteger.ZERO) < 0 || bBase.compareTo(BigInteger.ZERO) <= 0, raiseNode); @@ -1728,9 +1728,9 @@ static double logPIPI(PInt value, PInt base, return executeRecursiveLogNode(frame, value, asDoubleNode.execute(frame, inliningTarget, base)); } - private static void raiseMathError(Node inliningTarget, InlinedConditionProfile doNotFit, boolean con, PRaiseNode.Lazy raiseNode) { + private static void raiseMathError(Node inliningTarget, InlinedConditionProfile doNotFit, boolean con, PRaiseNode raiseNode) { if (doNotFit.profile(inliningTarget, con)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } } @@ -1750,7 +1750,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, Log1pNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { if (value == 0 || value == Double.POSITIVE_INFINITY || Double.isNaN(value)) { return value; } @@ -1786,7 +1786,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, Log2Node::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(value <= 0, inliningTarget, raiseNode); double[] frexpR = FrexpNode.frexp(value); double m = frexpR[0]; @@ -1833,7 +1833,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, Log10Node::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { checkMathDomainError(value <= 0, inliningTarget, raiseNode); return Math.log10(value); } @@ -1862,7 +1862,7 @@ public abstract static class PowNode extends PythonBinaryClinicBuiltinNode { @Specialization static double pow(double left, double right, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { double result = 0; if (!Double.isFinite(left) || !Double.isFinite(right)) { if (Double.isNaN(left)) { @@ -1893,12 +1893,12 @@ static double pow(double left, double right, result = Math.pow(left, right); if (!Double.isFinite(result)) { if (Double.isNaN(result)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } else if (Double.isInfinite(result)) { if (left == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MATH_DOMAIN_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MATH_DOMAIN_ERROR); } else { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MATH_RANGE_ERROR); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MATH_RANGE_ERROR); } } } @@ -1920,10 +1920,10 @@ public abstract static class TruncNode extends PythonUnaryBuiltinNode { static Object trunc(VirtualFrame frame, Object obj, @Bind("this") Node inliningTarget, @Cached("create(T___TRUNC__)") LookupAndCallUnaryNode callTrunc, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = callTrunc.executeObject(frame, obj); if (result == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, obj, "__trunc__"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, obj, "__trunc__"); } return result; } @@ -1957,7 +1957,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, DegreesNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return value * RAD_TO_DEG; } } @@ -1974,7 +1974,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, RadiansNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { return value * DEG_TO_RAD; } } @@ -1993,10 +1993,11 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, @Specialization(guards = "arguments.length == 2") public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords, @Bind("this") Node inliningTarget, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PyFloatAsDoubleNode xAsDouble, @Exclusive @Cached PyFloatAsDoubleNode yAsDouble) { if (keywords.length != 0) { - throw raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "hypot()"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "hypot()"); } double x = xAsDouble.execute(frame, inliningTarget, arguments[0]); double y = yAsDouble.execute(frame, inliningTarget, arguments[1]); @@ -2007,9 +2008,10 @@ public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self @SuppressWarnings("truffle-static-method") double hypotGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords, @Bind("this") Node inliningTarget, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PyFloatAsDoubleNode asDoubleNode) { if (keywords.length != 0) { - throw raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "hypot()"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_TAKES_NO_KEYWORD_ARGS, "hypot()"); } double max = 0.0; boolean foundNan = false; @@ -2114,7 +2116,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, ErfNode::compute); } - private static double compute(Node inliningTarget, double value, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double value, PRaiseNode raiseNode) { double absx, cf; if (Double.isNaN(value)) { @@ -2141,7 +2143,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, ErfcNode::compute); } - private static double compute(Node inliningTarget, double x, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double x, PRaiseNode raiseNode) { double absx, cf; if (Double.isNaN(x)) { @@ -2261,7 +2263,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, GammaNode::compute); } - private static double compute(Node inliningTarget, double x, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double x, PRaiseNode raiseNode) { double absx, r, y, z, sqrtpow; /* special cases */ @@ -2354,7 +2356,7 @@ static double doGeneric(VirtualFrame frame, Object value, return helperNode.execute(frame, inliningTarget, value, LgammaNode::compute); } - private static double compute(Node inliningTarget, double x, PRaiseNode.Lazy raiseNode) { + private static double compute(Node inliningTarget, double x, PRaiseNode raiseNode) { double r; double absx; @@ -2407,7 +2409,7 @@ public abstract static class IsqrtNode extends PythonUnaryBuiltinNode { static Object isqrtLong(long x, @Bind("this") Node inliningTarget, @Shared @Cached NarrowBigIntegerNode makeInt, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseIfNegative(inliningTarget, x < 0, raiseNode); return makeInt.execute(inliningTarget, op(PInt.longToBigInteger(x))); } @@ -2416,7 +2418,7 @@ static Object isqrtLong(long x, static Object isqrtPInt(PInt x, @Bind("this") Node inliningTarget, @Shared @Cached NarrowBigIntegerNode makeInt, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseIfNegative(inliningTarget, x.isNegative(), raiseNode); return makeInt.execute(inliningTarget, op(x.getValue())); } @@ -2455,9 +2457,9 @@ private static BigInteger op(BigInteger x) { return result; } - private static void raiseIfNegative(Node inliningTarget, boolean condition, PRaiseNode.Lazy raiseNode) { + private static void raiseIfNegative(Node inliningTarget, boolean condition, PRaiseNode raiseNode) { if (condition) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE, "isqrt() argument"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE, "isqrt() argument"); } } } @@ -2506,13 +2508,13 @@ static double doGeneric(VirtualFrame frame, Object p, Object q, @Cached InlinedConditionProfile infProfile, @Cached InlinedConditionProfile nanProfile, @Cached InlinedConditionProfile trivialProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // adapted from CPython math_dist_impl and vector_norm Object[] ps = getObjectArray.execute(inliningTarget, tupleCtor.execute(frame, p)); Object[] qs = getObjectArray.execute(inliningTarget, tupleCtor.execute(frame, q)); int len = ps.length; if (len != qs.length) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BOTH_POINTS_MUST_HAVE_THE_SAME_NUMBER_OF_DIMENSIONS); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BOTH_POINTS_MUST_HAVE_THE_SAME_NUMBER_OF_DIMENSIONS); } double[] diffs = new double[len]; double max = 0.0; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java index 5a0322e8dc..d4ac204674 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java @@ -142,14 +142,14 @@ static boolean compare(VirtualFrame frame, Object left, Object right, @Cached CastToJavaStringNode cast, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { String leftString = cast.execute(left); String rightString = cast.execute(right); return tscmp(leftString, rightString); } catch (CannotCastException e) { if (!bufferAcquireLib.hasBuffer(left) || !bufferAcquireLib.hasBuffer(right)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_OR_COMBINATION_OF_TYPES, left, right); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_OR_COMBINATION_OF_TYPES, left, right); } Object savedState = IndirectCallContext.enter(frame, indirectCallData); Object leftBuffer = bufferAcquireLib.acquireReadonly(left); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java index 2310c287c7..e5ed3dad0c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java @@ -205,7 +205,7 @@ Object importSymbol(TruffleString name, @Cached PForeignToPTypeNode convert) { Env env = getContext().getEnv(); if (!env.isPolyglotBindingsAccessAllowed()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } Object object = env.importSymbol(name.toJavaStringUncached()); if (object == null) { @@ -222,19 +222,19 @@ abstract static class EvalInteropNode extends PythonTernaryBuiltinNode { @Specialization Object eval(Object pathObj, Object stringObj, Object languageObj) { if (languageObj instanceof PNone) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH); } boolean hasString = !(stringObj instanceof PNone); boolean hasPath = !(pathObj instanceof PNone); if (!hasString && !hasPath || hasString && hasPath) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.POLYGLOT_EVAL_MUST_PASS_LANG_AND_STRING_OR_PATH); } String languageName = toJavaString(languageObj, "language"); String string = hasString ? toJavaString(stringObj, "string") : null; String path = hasPath ? toJavaString(pathObj, "path") : null; Env env = getContext().getEnv(); if (!env.isPolyglotEvalAllowed(null)) { - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } Map languages = env.getPublicLanguages(); String mimeType = null; @@ -244,10 +244,10 @@ Object eval(Object pathObj, Object stringObj, Object languageObj) { } LanguageInfo language = languages.get(languageName); if (language == null) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POLYGLOT_LANGUAGE_S_NOT_FOUND, languageName); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.POLYGLOT_LANGUAGE_S_NOT_FOUND, languageName); } if (!env.isPolyglotEvalAllowed(language)) { - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED_FOR_LANGUAGE_S, languageName); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED_FOR_LANGUAGE_S, languageName); } try { SourceBuilder builder; @@ -264,9 +264,9 @@ Object eval(Object pathObj, Object stringObj, Object languageObj) { } catch (AbstractTruffleException e) { throw e; } catch (IOException e) { - throw PRaiseNode.raiseUncached(this, OSError, ErrorMessages.S, e); + throw PRaiseNode.raiseStatic(this, OSError, ErrorMessages.S, e); } catch (RuntimeException e) { - throw PRaiseNode.raiseUncached(this, RuntimeError, e); + throw PRaiseNode.raiseStatic(this, RuntimeError, e); } } @@ -274,7 +274,7 @@ private String toJavaString(Object object, String parameterName) { try { return CastToJavaStringNode.getUncached().execute(object); } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.S_BRACKETS_ARG_S_MUST_BE_S_NOT_P, "polyglot.eval", parameterName, "str", object); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.S_BRACKETS_ARG_S_MUST_BE_S_NOT_P, "polyglot.eval", parameterName, "str", object); } } @@ -304,7 +304,7 @@ public abstract static class ExportSymbolNode extends PythonBuiltinNode { Object exportSymbolKeyValue(TruffleString name, Object value) { Env env = getContext().getEnv(); if (!env.isPolyglotBindingsAccessAllowed()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } env.exportSymbol(name.toJavaStringUncached(), value); return value; @@ -332,7 +332,7 @@ Object exportSymbolAmbiguous(Object arg1, TruffleString arg2) { Object exportSymbol(PFunction fun, @SuppressWarnings("unused") PNone name) { Env env = getContext().getEnv(); if (!env.isPolyglotBindingsAccessAllowed()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } env.exportSymbol(fun.getName().toJavaStringUncached(), fun); return fun; @@ -343,7 +343,7 @@ Object exportSymbol(PFunction fun, @SuppressWarnings("unused") PNone name) { Object exportSymbol(PBuiltinFunction fun, @SuppressWarnings("unused") PNone name) { Env env = getContext().getEnv(); if (!env.isPolyglotBindingsAccessAllowed()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(this, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } env.exportSymbol(fun.getName().toJavaStringUncached(), fun); return fun; @@ -354,13 +354,13 @@ static Object exportSymbol(VirtualFrame frame, Object fun, @SuppressWarnings("un @Bind("this") Node inliningTarget, @Cached("create(T___NAME__)") GetAttributeNode.GetFixedAttributeNode getNameAttributeNode, @Cached CastToJavaStringNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object attrNameValue = getNameAttributeNode.executeObject(frame, fun); String methodName; try { methodName = castToStringNode.execute(attrNameValue); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.METHOD_NAME_MUST_BE, attrNameValue); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.METHOD_NAME_MUST_BE, attrNameValue); } export(inliningTarget, methodName, fun); return fun; @@ -368,8 +368,8 @@ static Object exportSymbol(VirtualFrame frame, Object fun, @SuppressWarnings("un @Fallback static Object exportSymbol(Object value, Object name, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_ARG_TYPES_S_S_BUT_NOT_P_P, "function", "object, str", value, name); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_ARG_TYPES_S_S_BUT_NOT_P_P, "function", "object, str", value, name); } protected static boolean isModuleMethod(Object o) { @@ -380,7 +380,7 @@ protected static boolean isModuleMethod(Object o) { private static void export(Node raisingNode, String name, Object obj) { Env env = PythonContext.get(raisingNode).getEnv(); if (!env.isPolyglotBindingsAccessAllowed()) { - throw PRaiseNode.raiseUncached(raisingNode, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); + throw PRaiseNode.raiseStatic(raisingNode, PythonErrorType.NotImplementedError, ErrorMessages.POLYGLOT_ACCESS_NOT_ALLOWED); } env.exportSymbol(name, obj); } @@ -407,8 +407,8 @@ static boolean isWhole(double number) { @Specialization(guards = {"!isSupportedNumber(number)"}) static boolean unsupported(PythonAbstractObject number, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ARG_MUST_BE_NUMBER, "given", number); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ARG_MUST_BE_NUMBER, "given", number); } } @@ -642,7 +642,7 @@ PList get(PythonAbstractObject klass, } return PFactory.createList(language); } - throw raiseNode.raise(ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a type", klass); + throw raiseNode.raise(inliningTarget, ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a type", klass); } } @@ -686,17 +686,17 @@ void handleArg(Object value, InteropBehaviorMethod method, InteropBehavior inter Signature signature = function.getCode().getSignature(); // validate the function if (function.getKwDefaults().length != 0) { - throw raiseNode.raise(ValueError, S_TAKES_NO_KEYWORD_ARGS, method.name); + throw raiseNode.raise(this, ValueError, S_TAKES_NO_KEYWORD_ARGS, method.name); } else if (function.getCode().getCellVars().length != 0) { - throw raiseNode.raise(ValueError, S_CANNOT_HAVE_S, method.name, "cell vars"); + throw raiseNode.raise(this, ValueError, S_CANNOT_HAVE_S, method.name, "cell vars"); } else if (function.getCode().getFreeVars().length != 0) { - throw raiseNode.raise(ValueError, S_CANNOT_HAVE_S, method.name, "free vars"); + throw raiseNode.raise(this, ValueError, S_CANNOT_HAVE_S, method.name, "free vars"); } else { // check signature if (method.takesVarArgs != signature.takesVarArgs()) { - throw raiseNode.raise(ValueError, method.takesVarArgs ? S_TAKES_VARARGS : S_DOES_NOT_TAKE_VARARGS, method.name); + throw raiseNode.raise(this, ValueError, method.takesVarArgs ? S_TAKES_VARARGS : S_DOES_NOT_TAKE_VARARGS, method.name); } else if (signature.getMaxNumOfPositionalArgs() != method.getNumPositionalArguments()) { - throw raiseNode.raise(ValueError, S_TAKES_EXACTLY_D_ARGS, method.name, method.getNumPositionalArguments(), signature.getMaxNumOfPositionalArgs()); + throw raiseNode.raise(this, ValueError, S_TAKES_EXACTLY_D_ARGS, method.name, method.getNumPositionalArguments(), signature.getMaxNumOfPositionalArgs()); } } } @@ -777,7 +777,7 @@ Object register(PythonAbstractObject receiver, Object is_boolean, Object is_date HiddenAttr.WriteNode.executeUncached(receiver, HiddenAttr.HOST_INTEROP_BEHAVIOR, interopBehavior); return PNone.NONE; } - throw raiseNode.raise(ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a type", receiver); + throw raiseNode.raise(inliningTarget, ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a type", receiver); } } @@ -837,10 +837,10 @@ Object register(Object foreignClass, PythonClass pythonClass, boolean allowMetho @Cached ObjectHashMap.PutNode putNode, @Cached ObjectHashMap.GetNode getNode, @Cached PRaiseNode raiseNode) { - foreignClass = checkAndCleanForeignClass(foreignClass, interopLibrary, raiseNode, getContext().getEnv()); + foreignClass = checkAndCleanForeignClass(inliningTarget, foreignClass, interopLibrary, raiseNode, getContext().getEnv()); if (!isClassTypeNode.execute(inliningTarget, pythonClass)) { - throw raiseNode.raise(ValueError, S_ARG_MUST_BE_S_NOT_P, "second", "a python class", pythonClass); + throw raiseNode.raise(inliningTarget, ValueError, S_ARG_MUST_BE_S_NOT_P, "second", "a python class", pythonClass); } // Contains foreignClasses as keys and PythonClass[] as values ObjectHashMap interopTypeRegistry = getContext().interopTypeRegistry; @@ -857,11 +857,11 @@ Object register(Object foreignClass, PythonClass pythonClass, boolean allowMetho // found one or more classes for the key, insert the new class in at first place // The logic for the class lookup should be LIFO if (checkIfAlreadyRegistered(pythonClass, registeredClasses, interopLibrary)) { - throw raiseNode.raise(KeyError, INTEROP_TYPE_ALREADY_REGISTERED, interopLibrary.getMetaQualifiedName(foreignClass)); + throw raiseNode.raise(inliningTarget, KeyError, INTEROP_TYPE_ALREADY_REGISTERED, interopLibrary.getMetaQualifiedName(foreignClass)); } if (!allowMethodOverwrites) { // method overwrite not allowed, check if there is a conflict - checkForMethodConflict(pythonClass, registeredClasses, raiseNode); + checkForMethodConflict(inliningTarget, pythonClass, registeredClasses, raiseNode); } var newClasses = new PythonManagedClass[registeredClasses.length + 1]; newClasses[0] = pythonClass; @@ -889,21 +889,21 @@ private static boolean checkIfAlreadyRegistered(PythonManagedClass pythonManaged return false; } - private static void checkForMethodConflict(PythonManagedClass toCheck, PythonManagedClass[] registeredClasses, PRaiseNode raiseNode) { + private static void checkForMethodConflict(Node inliningTarget, PythonManagedClass toCheck, PythonManagedClass[] registeredClasses, PRaiseNode raiseNode) { for (TruffleString name : toCheck.getAttributeNames()) { if (toCheck.getAttribute(name) instanceof PFunction) { for (PythonManagedClass registeredClass : registeredClasses) { if (registeredClass.getAttribute(name) instanceof PFunction) { - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, INTEROP_TYPE_NOT_MERGABLE, toCheck, registeredClass, name); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, INTEROP_TYPE_NOT_MERGABLE, toCheck, registeredClass, name); } } } } } - private static Object checkAndCleanForeignClass(Object object, InteropLibrary interopLibrary, PRaiseNode raiseNode, Env env) { + private static Object checkAndCleanForeignClass(Node inliningTarget, Object object, InteropLibrary interopLibrary, PRaiseNode raiseNode, Env env) { if (!interopLibrary.isMetaObject(object)) { - throw raiseNode.raise(ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a class or interface", object); + throw raiseNode.raise(inliningTarget, ValueError, S_ARG_MUST_BE_S_NOT_P, "first", "a class or interface", object); } if (!env.isHostObject(object)) { return object; @@ -944,10 +944,10 @@ Object read(Object receiver, Object key) { } else if (key instanceof Number) { return getInterop().readArrayElement(receiver, ((Number) key).longValue()); } else { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); } } catch (UnknownIdentifierException | UnsupportedMessageException | InvalidArrayIndexException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, e); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, e); } } } @@ -966,10 +966,10 @@ Object write(Object receiver, Object key, Object value) { } else if (key instanceof Number) { getInterop().writeArrayElement(receiver, ((Number) key).longValue(), value); } else { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); } } catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | InvalidArrayIndexException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, e); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, e); } return PNone.NONE; } @@ -989,10 +989,10 @@ Object remove(Object receiver, Object key) { } else if (key instanceof Number) { getInterop().removeArrayElement(receiver, ((Number) key).longValue()); } else { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, ErrorMessages.UNKNOWN_ATTR, key); } } catch (UnknownIdentifierException | UnsupportedMessageException | InvalidArrayIndexException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.AttributeError, e); + throw PRaiseNode.raiseStatic(this, PythonErrorType.AttributeError, e); } return PNone.NONE; } @@ -1004,11 +1004,11 @@ public abstract static class executeNode extends PythonBuiltinNode { @Specialization static Object exec(Object receiver, Object[] arguments, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return getInterop().execute(receiver, arguments); } catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.AttributeError, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.AttributeError, e); } } } @@ -1019,11 +1019,11 @@ public abstract static class newNode extends PythonBuiltinNode { @Specialization static Object instantiate(Object receiver, Object[] arguments, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return getInterop().instantiate(receiver, arguments); } catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.AttributeError, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.AttributeError, e); } } } @@ -1035,11 +1035,11 @@ public abstract static class invokeNode extends PythonBuiltinNode { static Object invoke(Object receiver, TruffleString key, Object[] arguments, @Bind("this") Node inliningTarget, @Cached TruffleString.ToJavaStringNode toJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return getInterop().invokeMember(receiver, toJavaStringNode.execute(key), arguments); } catch (UnsupportedMessageException | UnsupportedTypeException | ArityException | UnknownIdentifierException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.AttributeError, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.AttributeError, e); } } } @@ -1068,11 +1068,11 @@ public abstract static class GetSizeNode extends PythonBuiltinNode { @Specialization static Object getSize(Object receiver, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return getInterop().getArraySize(receiver); } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, e); } } } @@ -1135,11 +1135,11 @@ public abstract static class KeysNode extends PythonBuiltinNode { @Specialization static Object remove(Object receiver, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return getInterop().getMembers(receiver); } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, e); } } } @@ -1184,15 +1184,15 @@ static Object doSequence(PSequence seq, } else if (storage instanceof ArrayBasedSequenceStorage basicStorage) { arrayObject = basicStorage.getInternalArrayObject(); } else { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.NotImplementedError, ErrorMessages.GETTING_POLYGLOT_STORAGE_FOR_NATIVE_STORAGE_NOT_IMPLEMENTED); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError, ErrorMessages.GETTING_POLYGLOT_STORAGE_FOR_NATIVE_STORAGE_NOT_IMPLEMENTED); } return PythonContext.get(inliningTarget).getEnv().asGuestValue(arrayObject); } @Fallback static Object doError(Object object, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_P, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_P, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index 1855f6b7cc..c49b42d59b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -450,7 +450,7 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, PBytes valueBytes, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // Unlike in other posix builtins, we go through str -> bytes -> byte[] -> String // conversions for emulated backend because the bytes version after fsencode conversion // is subject to sys.audit. @@ -469,17 +469,17 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, PBytes valueBytes, return PNone.NONE; } - private static Object checkNull(Node inliningTarget, Object value, PRaiseNode.Lazy raiseNode) { + private static Object checkNull(Node inliningTarget, Object value, PRaiseNode raiseNode) { if (value == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } return value; } - private static void checkEqualSign(Node inliningTarget, byte[] bytes, PRaiseNode.Lazy raiseNode) { + private static void checkEqualSign(Node inliningTarget, byte[] bytes, PRaiseNode raiseNode) { for (byte b : bytes) { if (b == '=') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ILLEGAL_ENVIRONMENT_VARIABLE_NAME); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ILLEGAL_ENVIRONMENT_VARIABLE_NAME); } } } @@ -503,7 +503,7 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, @Cached SysModuleBuiltins.AuditNode auditNode, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] name = toBytesNode.execute(nameBytes); Object nameOpaque = checkNull(inliningTarget, posixLib.createPathFromBytes(context.getPosixSupport(), name), raiseNode); auditNode.audit(inliningTarget, "os.unsetenv", nameBytes); @@ -515,9 +515,9 @@ static PNone putenv(VirtualFrame frame, PBytes nameBytes, return PNone.NONE; } - private static Object checkNull(Node inliningTarget, Object value, PRaiseNode.Lazy raiseNode) { + private static Object checkNull(Node inliningTarget, Object value, PRaiseNode raiseNode) { if (value == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } return value; } @@ -543,7 +543,7 @@ static Object execvArgsList(VirtualFrame frame, PosixPath path, PList argv, @Shared @Cached SysModuleBuiltins.AuditNode auditNode, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, context.getPosixSupport(), toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); throw CompilerDirectives.shouldNotReachHere("execv should not return normally"); } @@ -558,7 +558,7 @@ static Object execvArgsTuple(VirtualFrame frame, PosixPath path, PTuple argv, @Shared @Cached AuditNode auditNode, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { execv(frame, path, argv, argv.getSequenceStorage(), inliningTarget, posixLib, context.getPosixSupport(), toArrayNode, toOpaquePathNode, auditNode, gil, constructAndRaiseNode, raiseNode); throw CompilerDirectives.shouldNotReachHere("execv should not return normally"); } @@ -566,8 +566,8 @@ static Object execvArgsTuple(VirtualFrame frame, PosixPath path, PTuple argv, @Specialization(guards = {"!isList(argv)", "!isPTuple(argv)"}) @SuppressWarnings("unused") static Object execvInvalidArgs(VirtualFrame frame, PosixPath path, Object argv, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S, "execv()", 2, "tuple or list"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ARG_D_MUST_BE_S, "execv()", 2, "tuple or list"); } private static void execv(VirtualFrame frame, PosixPath path, Object argv, SequenceStorage argvStorage, @@ -579,10 +579,10 @@ private static void execv(VirtualFrame frame, PosixPath path, Object argv, Seque SysModuleBuiltins.AuditNode auditNode, GilNode gil, PConstructAndRaiseNode.Lazy constructAndRaiseNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object[] args = toArrayNode.execute(inliningTarget, argvStorage); if (args.length < 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ARG_MUST_NOT_BE_EMPTY, "execv()", 2); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ARG_MUST_NOT_BE_EMPTY, "execv()", 2); } Object[] opaqueArgs = new Object[args.length]; for (int i = 0; i < args.length; ++i) { @@ -686,7 +686,7 @@ static PTuple getloadavg(@Bind("this") Node inliningTarget, load = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); } if (load < 0) { - PRaiseNode.raiseUncached(inliningTarget, OSError); + PRaiseNode.raiseStatic(inliningTarget, OSError); } return PFactory.createTuple(language, new Object[]{load, load, load}); } @@ -1447,15 +1447,15 @@ static PTuple doStatPath(VirtualFrame frame, PosixPath path, int dirFd, boolean @Specialization(guards = "!isDefault(dirFd)") @SuppressWarnings("unused") static PTuple doStatFdWithDirFd(PosixFd fd, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANT_SPECIFY_DIRFD_WITHOUT_PATH, "stat"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANT_SPECIFY_DIRFD_WITHOUT_PATH, "stat"); } @Specialization(guards = {"isDefault(dirFd)", "!followSymlinks"}) @SuppressWarnings("unused") static PTuple doStatFdWithFollowSymlinks(VirtualFrame frame, PosixFd fd, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "stat"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "stat"); } @Specialization(guards = {"isDefault(dirFd)", "followSymlinks"}) @@ -1920,8 +1920,8 @@ abstract static class ScandirIteratorNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object scandirIterator(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "posix.ScandirIterator"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "posix.ScandirIterator"); } } @@ -1931,8 +1931,8 @@ abstract static class DirEntryNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object dirEntry(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "posix.DirEntry"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "posix.DirEntry"); } } @@ -2093,7 +2093,7 @@ static long[] times(VirtualFrame frame, PTuple times, @SuppressWarnings("unused" @Exclusive @Cached LenNode lenNode, @Shared @Cached("createNotNormalized()") GetItemNode getItemNode, @Cached ObjectToTimespecNode objectToTimespecNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return convertToTimespec(frame, inliningTarget, times, lenNode, getItemNode, objectToTimespecNode, raiseNode); } @@ -2103,42 +2103,43 @@ static long[] ns(VirtualFrame frame, @SuppressWarnings("unused") PNone times, PT @Exclusive @Cached LenNode lenNode, @Shared @Cached("createNotNormalized()") GetItemNode getItemNode, @Cached SplitLongToSAndNsNode splitLongToSAndNsNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return convertToTimespec(frame, inliningTarget, ns, lenNode, getItemNode, splitLongToSAndNsNode, raiseNode); } @Specialization(guards = {"!isPNone(times)", "!isNoValue(ns)"}) @SuppressWarnings("unused") static long[] bothSpecified(VirtualFrame frame, Object times, Object ns, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.YOU_MAY_SPECIFY_EITHER_OR_BUT_NOT_BOTH, "utime", "times", "ns"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.YOU_MAY_SPECIFY_EITHER_OR_BUT_NOT_BOTH, "utime", "times", "ns"); } @Specialization(guards = {"!isPNone(times)", "!isPTuple(times)", "isNoValue(ns)"}) @SuppressWarnings("unused") static long[] timesNotATuple(VirtualFrame frame, Object times, PNone ns, - @Shared @Cached PRaiseNode raiseNode) { - throw timesTupleError(raiseNode); + @Bind("this") Node inliningTarget, + @Cached PRaiseNode raiseNode) { + throw timesTupleError(inliningTarget, raiseNode); } @Specialization(guards = {"!isNoValue(ns)", "!isPTuple(ns)"}) @SuppressWarnings("unused") static long[] nsNotATuple(VirtualFrame frame, PNone times, Object ns, - @Shared @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // ns can actually also contain objects implementing __divmod__, but CPython produces // this error message - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE, "utime", "ns", "a tuple of two ints"); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE, "utime", "ns", "a tuple of two ints"); } - private static PException timesTupleError(PRaiseNode raiseNode) { + private static PException timesTupleError(Node inliningTarget, PRaiseNode raiseNode) { // times can actually also contain floats, but CPython produces this error message - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_EITHER_OR, "utime", "times", "a tuple of two ints", "None"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_EITHER_OR, "utime", "times", "a tuple of two ints", "None"); } private static long[] convertToTimespec(VirtualFrame frame, Node inliningTarget, PTuple times, LenNode lenNode, GetItemNode getItemNode, ConvertToTimespecBaseNode convertToTimespecBaseNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (lenNode.execute(inliningTarget, times) != 2) { - throw timesTupleError(raiseNode.get(inliningTarget)); + throw timesTupleError(inliningTarget, raiseNode); } long[] timespec = new long[4]; convertToTimespecBaseNode.execute(frame, inliningTarget, getItemNode.execute(times.getSequenceStorage(), 0), timespec, 0); @@ -2224,15 +2225,15 @@ static PNone lutimes(VirtualFrame frame, PosixPath path, Object times, Object ns @Specialization(guards = {"!HAVE_UTIMENSAT.value", "!isDefault(dirFd)", "followSymlinks"}) @SuppressWarnings("unused") static PNone dirFdNotSupported(VirtualFrame frame, PosixPath path, Object times, Object ns, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, ErrorMessages.UNAVAILABLE_ON_THIS_PLATFORM_NO_FUNC, "dir_fd"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.UNAVAILABLE_ON_THIS_PLATFORM_NO_FUNC, "dir_fd"); } @Specialization(guards = {"!HAVE_UTIMENSAT.value", "!isDefault(dirFd)", "!followSymlinks"}) @SuppressWarnings("unused") static PNone dirFdAndFollowSymlinksNotSupported(VirtualFrame frame, PosixPath path, Object times, Object ns, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.UTIME_CANNOT_USE_DIR_FD_AND_FOLLOW_SYMLINKS, "dir_fd"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.UTIME_CANNOT_USE_DIR_FD_AND_FOLLOW_SYMLINKS, "dir_fd"); } @Specialization(guards = {"HAVE_FUTIMENS.value", "isDefault(dirFd)", "followSymlinks"}) @@ -2276,15 +2277,15 @@ static PNone futimes(VirtualFrame frame, PosixFd fd, Object times, Object ns, in @Specialization(guards = {"isPNone(times) || isNoValue(ns)", "!isDefault(dirFd)"}) @SuppressWarnings("unused") static PNone fdWithDirFd(VirtualFrame frame, PosixFd fd, Object times, Object ns, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANT_SPECIFY_DIRFD_WITHOUT_PATH, "utime"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANT_SPECIFY_DIRFD_WITHOUT_PATH, "utime"); } @Specialization(guards = {"isPNone(times) || isNoValue(ns)", "isDefault(dirFd)", "!followSymlinks"}) @SuppressWarnings("unused") static PNone fdWithFollowSymlinks(VirtualFrame frame, PosixFd fd, Object times, Object ns, int dirFd, boolean followSymlinks, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "utime"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "utime"); } protected static boolean isDefault(int dirFd) { @@ -2408,7 +2409,7 @@ static PNone chmodFollow(VirtualFrame frame, PosixPath path, int mode, int dirFd @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { auditNode.audit(inliningTarget, "os.chmod", path.originalObject, mode, dirFdForAudit(dirFd)); try { posixLib.fchmodat(context.getPosixSupport(), dirFd, path.value, mode, followSymlinks); @@ -2416,9 +2417,9 @@ static PNone chmodFollow(VirtualFrame frame, PosixPath path, int mode, int dirFd // TODO CPython checks for ENOTSUP as well if (e.getErrorCode() == OSErrorEnum.EOPNOTSUPP.getNumber() && !followSymlinks) { if (dirFd != AT_FDCWD.value) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "chmod"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "chmod"); } else { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.UNAVAILABLE_ON_THIS_PLATFORM, "chmod", "follow_symlinks"); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.UNAVAILABLE_ON_THIS_PLATFORM, "chmod", "follow_symlinks"); } } throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e, path.originalObject); @@ -2434,7 +2435,7 @@ static PNone chmodFollow(VirtualFrame frame, PosixFd fd, int mode, int dirFd, @S @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, // unused node to avoid mixing shared and non-shared inlined nodes - @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) { + @SuppressWarnings("unused") @Shared @Cached PRaiseNode raiseNode) { auditNode.audit(inliningTarget, "os.chmod", fd.originalObject, mode, dirFdForAudit(dirFd)); // Unlike stat and utime which raise CANT_SPECIFY_DIRFD_WITHOUT_PATH or // CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER when an inappropriate combination of @@ -2534,7 +2535,7 @@ static Object chown(VirtualFrame frame, PosixPath path, long uid, long gid, int @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, // unused node to avoid mixing shared and non-shared inlined nodes - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { auditNode.audit(inliningTarget, "os.chown", path.originalObject, uid, gid, dirFd != AT_FDCWD.value ? dirFd : -1); try { gil.release(true); @@ -2557,12 +2558,12 @@ static Object chown(VirtualFrame frame, PosixFd fd, long uid, long gid, int dirF @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Shared @Cached GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (dirFd != AT_FDCWD.value) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANT_SPECIFY_BOTH_DIR_FD_AND_FD); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANT_SPECIFY_BOTH_DIR_FD_AND_FD); } if (followSymlinks) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "chown"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_USE_FD_AND_FOLLOW_SYMLINKS_TOGETHER, "chown"); } auditNode.audit(inliningTarget, "os.chown", fd.originalObject, uid, gid, -1); try { @@ -2719,28 +2720,28 @@ static int waitstatusToExitcode(VirtualFrame frame, Object statusObj, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Bind("this") Node inliningTarget, @Cached PyLongAsIntNode longAsInt, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int status = longAsInt.execute(frame, inliningTarget, statusObj); PosixSupport posixSupport = context.getPosixSupport(); if (posixLib.wifexited(posixSupport, status)) { int exitcode = posixLib.wexitstatus(posixSupport, status); if (exitcode < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WEXITSTATUS, exitcode); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WEXITSTATUS, exitcode); } return exitcode; } if (posixLib.wifsignaled(posixSupport, status)) { int signum = posixLib.wtermsig(posixSupport, status); if (signum <= 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WTERMSIG, signum); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WTERMSIG, signum); } return -signum; } if (posixLib.wifstopped(posixSupport, status)) { int signum = posixLib.wstopsig(posixSupport, status); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.PROCESS_STOPPED_BY_DELIVERY_OF_SIGNAL, signum); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.PROCESS_STOPPED_BY_DELIVERY_OF_SIGNAL, signum); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WAIT_STATUS, status); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_WAIT_STATUS, status); } } @@ -2928,8 +2929,8 @@ static PBytes urandom(int size, @Specialization(guards = "size < 0") static Object urandomNeg(@SuppressWarnings("unused") int size, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.NEG_ARG_NOT_ALLOWED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.NEG_ARG_NOT_ALLOWED); } @TruffleBoundary @@ -2975,7 +2976,7 @@ static int sysconf(VirtualFrame frame, Object arg, @Cached PyLongAsIntNode asIntNode, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached HashingStorageNodes.HashingStorageGetItem getItem, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { int id; if (longCheckNode.execute(inliningTarget, arg)) { @@ -2985,10 +2986,10 @@ static int sysconf(VirtualFrame frame, Object arg, if (idObj instanceof Integer idInt) { id = idInt; } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNRECOGNIZED_CONF_NAME); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNRECOGNIZED_CONF_NAME); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CONFIGURATION_NAMES_MUST_BE_STRINGS_OR_INTEGERS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CONFIGURATION_NAMES_MUST_BE_STRINGS_OR_INTEGERS); } if (id == SC_CLK_TCK) { return 100; // it's 100 on most default kernel configs. TODO: use real value through @@ -3169,7 +3170,7 @@ static Object doString(Node inliningTarget, Object strObj, @Cached CastToTruffleStringNode castToStringNode, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString str = castToStringNode.execute(inliningTarget, strObj); return checkPath(inliningTarget, posixLib.createPathFromString(context.getPosixSupport(), str), raiseNode); } @@ -3179,13 +3180,13 @@ static Object doBytes(Node inliningTarget, PBytes bytes, @Cached(inline = false) BytesNodes.ToBytesNode toBytesNode, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return checkPath(inliningTarget, posixLib.createPathFromBytes(context.getPosixSupport(), toBytesNode.execute(bytes)), raiseNode); } - private static Object checkPath(Node inliningTarget, Object path, PRaiseNode.Lazy raiseNode) { + private static Object checkPath(Node inliningTarget, Object path, PRaiseNode raiseNode) { if (path == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } return path; } @@ -3212,10 +3213,10 @@ static Object withCheck(VirtualFrame frame, Node inliningTarget, Object obj, @Su @Exclusive @Cached PyOSFSPathNode fspathNode, @Cached PyObjectSizeNode sizeNode, @Exclusive @Cached StringOrBytesToOpaquePathNode stringOrBytesToOpaquePathNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object stringOrBytes = fspathNode.execute(frame, inliningTarget, obj); if (sizeNode.execute(frame, inliningTarget, obj) == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EXECV_ARG2_FIRST_ELEMENT_CANNOT_BE_EMPTY); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EXECV_ARG2_FIRST_ELEMENT_CANNOT_BE_EMPTY); } return stringOrBytesToOpaquePathNode.execute(inliningTarget, stringOrBytes); } @@ -3235,9 +3236,9 @@ abstract static class ObjectToTimespecNode extends ConvertToTimespecBaseNode { @Specialization static void doDouble(Node inliningTarget, double value, long[] timespec, int offset, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (Double.isNaN(value)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_VALUE_NAN); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_VALUE_NAN); } double denominator = 1000000000.0; @@ -3254,7 +3255,7 @@ static void doDouble(Node inliningTarget, double value, long[] timespec, int off } assert 0.0 <= floatPart && floatPart < denominator; if (!MathGuards.fitLong(intPart)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.TIMESTAMP_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.TIMESTAMP_OUT_OF_RANGE); } timespec[offset] = (long) intPart; timespec[offset + 1] = (long) floatPart; @@ -3263,7 +3264,7 @@ static void doDouble(Node inliningTarget, double value, long[] timespec, int off @Specialization static void doPFloat(Node inliningTarget, PFloat obj, long[] timespec, int offset, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { doDouble(inliningTarget, obj.getValue(), timespec, offset, raiseNode); } @@ -3282,11 +3283,11 @@ static void doLong(long value, long[] timespec, int offset) { @Specialization(guards = {"!isDouble(value)", "!isPFloat(value)", "!isInteger(value)"}) static void doGeneric(VirtualFrame frame, Node inliningTarget, Object value, long[] timespec, int offset, @Cached PyLongAsLongAndOverflowNode asLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { timespec[offset] = asLongNode.execute(frame, inliningTarget, value); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.TIMESTAMP_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.TIMESTAMP_OUT_OF_RANGE); } timespec[offset + 1] = 0; } @@ -3319,10 +3320,10 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object value, lon @Cached LenNode lenNode, @Cached(value = "createNotNormalized()", inline = false) GetItemNode getItemNode, @Cached PyLongAsLongNode asLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object divmod = callDivmod.executeObject(frame, value, BILLION); if (!PGuards.isPTuple(divmod) || lenNode.execute(inliningTarget, (PSequence) divmod) != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_RETURN_2TUPLE, value, divmod); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_RETURN_2TUPLE, value, divmod); } SequenceStorage storage = ((PTuple) divmod).getSequenceStorage(); timespec[offset] = asLongNode.execute(frame, inliningTarget, getItemNode.execute(storage, 0)); @@ -3411,7 +3412,7 @@ static int doFdInt(int value) { @Specialization static int doFdLong(long value, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return longToFd(inliningTarget, value, raiseNode); } @@ -3420,7 +3421,7 @@ static int doFdLong(long value, static int doFdPInt(PInt value, @Bind("this") Node inliningTarget, @Exclusive @Cached CastToJavaLongLossyNode castToLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return doFdLong(castToLongNode.execute(inliningTarget, value), inliningTarget, raiseNode); } @@ -3431,21 +3432,21 @@ static int doIndex(VirtualFrame frame, Object value, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberIndexNode indexNode, @Exclusive @Cached CastToJavaLongLossyNode castToLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, value)) { Object o = indexNode.execute(frame, inliningTarget, value); return doFdLong(castToLongNode.execute(inliningTarget, o), inliningTarget, raiseNode); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, value); } } - private static int longToFd(Node inliningTarget, long value, PRaiseNode.Lazy raiseNode) { + private static int longToFd(Node inliningTarget, long value, PRaiseNode raiseNode) { if (value > Integer.MAX_VALUE) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.FD_IS_GREATER_THAN_MAXIMUM); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.FD_IS_GREATER_THAN_MAXIMUM); } if (value < Integer.MIN_VALUE) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.FD_IS_LESS_THAN_MINIMUM); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.FD_IS_LESS_THAN_MINIMUM); } return (int) value; } @@ -3480,7 +3481,7 @@ PosixFileHandle doNone(@SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object path = posixLib.createPathFromString(context.getPosixSupport(), T_DOT); return new PosixPath(null, checkPath(inliningTarget, path, raiseNode), false); } @@ -3498,7 +3499,7 @@ static PosixFileHandle doFdInt(int value) { @Specialization(guards = "allowFd") static PosixFileHandle doFdLong(long value, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return new PosixFd(value, DirFdConversionNode.longToFd(inliningTarget, value, raiseNode)); } @@ -3506,7 +3507,7 @@ static PosixFileHandle doFdLong(long value, static PosixFileHandle doFdPInt(PInt value, @Bind("this") Node inliningTarget, @Exclusive @Cached CastToJavaLongLossyNode castToLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return new PosixFd(value, DirFdConversionNode.longToFd(inliningTarget, castToLongNode.execute(inliningTarget, value), raiseNode)); } @@ -3517,7 +3518,7 @@ PosixFileHandle doUnicode(Object value, @Exclusive @Cached CastToTruffleStringNode castToStringNode, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString str = castToStringNode.execute(inliningTarget, value); Object path = posixLib.createPathFromString(context.getPosixSupport(), str); return new PosixPath(value, checkPath(inliningTarget, path, raiseNode), false); @@ -3530,7 +3531,7 @@ PosixFileHandle doBytes(PBytes value, @Exclusive @Cached BytesNodes.ToBytesNode toByteArrayNode, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object path = posixLib.createPathFromBytes(context.getPosixSupport(), toByteArrayNode.execute(value)); return new PosixPath(value, checkPath(inliningTarget, path, raiseNode), true); } @@ -3545,7 +3546,7 @@ PosixFileHandle doBuffer(VirtualFrame frame, Object value, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached WarningsModuleBuiltins.WarnNode warningNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PythonLanguage language = context.getLanguage(inliningTarget); Object buffer = bufferAcquireLib.acquireReadonly(value, frame, context, language, indirectCallData); try { @@ -3566,7 +3567,7 @@ PosixFileHandle doIndex(VirtualFrame frame, Object value, @SuppressWarnings("unused") @Exclusive @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberIndexNode indexNode, @Exclusive @Cached CastToJavaLongLossyNode castToLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object o = indexNode.execute(frame, inliningTarget, value); return new PosixFd(value, DirFdConversionNode.longToFd(inliningTarget, castToLongNode.execute(inliningTarget, o), raiseNode)); } @@ -3582,10 +3583,10 @@ PosixFileHandle doGeneric(VirtualFrame frame, Object value, @Exclusive @Cached CastToTruffleStringNode castToStringNode, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object pathObject = callFSPath.executeObject(frame, value); if (pathObject == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_S_SHOULD_BE_S_NOT_P, functionNameWithColon, argumentName, + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_S_SHOULD_BE_S_NOT_P, functionNameWithColon, argumentName, getAllowedTypes(), value); } // 'pathObject' replaces 'value' as the PosixPath.originalObject for auditing purposes @@ -3596,7 +3597,7 @@ PosixFileHandle doGeneric(VirtualFrame frame, Object value, if (PGuards.isString(pathObject)) { return doUnicode(pathObject, inliningTarget, castToStringNode, context, posixLib, raiseNode); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, value, pathObject); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, value, pathObject); } protected boolean isHandled(Object value) { @@ -3608,9 +3609,9 @@ private String getAllowedTypes() { : allowFd ? "string, bytes, os.PathLike or integer" : nullable ? "string, bytes, os.PathLike or None" : "string, bytes or os.PathLike"; } - private Object checkPath(Node inliningTarget, Object path, PRaiseNode.Lazy raiseNode) { + private Object checkPath(Node inliningTarget, Object path, PRaiseNode raiseNode) { if (path == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.S_EMBEDDED_NULL_CHARACTER_IN_S, functionNameWithColon, argumentName); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.S_EMBEDDED_NULL_CHARACTER_IN_S, functionNameWithColon, argumentName); } return path; } @@ -3712,14 +3713,14 @@ public abstract static class AbstractIdConversionNode extends ArgumentCastNode { @Specialization long doInt(int value, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return checkValue(inliningTarget, value, raiseNode); } @Specialization long doLong(long value, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return checkValue(inliningTarget, value, raiseNode); } @@ -3729,12 +3730,12 @@ long doGeneric(VirtualFrame frame, Object value, @Bind("this") Node inliningTarget, @Cached PyNumberIndexNode pyNumberIndexNode, @Cached PyLongAsLongNode asLongNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object index; try { index = pyNumberIndexNode.execute(frame, inliningTarget, value); } catch (PException ex) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_INTEGER_NOT_P, getIdName(), value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_INTEGER_NOT_P, getIdName(), value); } /* * We have no means to distinguish overflow/underflow, so we just let any OverflowError @@ -3744,13 +3745,13 @@ long doGeneric(VirtualFrame frame, Object value, return checkValue(inliningTarget, asLongNode.execute(frame, inliningTarget, index), raiseNode); } - private long checkValue(Node inliningTarget, long value, PRaiseNode.Lazy raiseNode) { + private long checkValue(Node inliningTarget, long value, PRaiseNode raiseNode) { // Note that -1 is intentionally allowed if (value < -1) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_IS_LESS_THAN_MINIMUM, getIdName()); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_IS_LESS_THAN_MINIMUM, getIdName()); } else if (value > MAX_UINT32) { /* uid_t is uint32_t on Linux */ - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_IS_GREATER_THAN_MAXIUMUM, getIdName()); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_IS_GREATER_THAN_MAXIUMUM, getIdName()); } return value; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java index 36c6a82161..e78b40382a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java @@ -126,13 +126,13 @@ static Object[] doSequence(VirtualFrame frame, Object processArgs, @Cached IsBuiltinObjectProfile isBuiltinClassProfile, @Cached ObjectToOpaquePathNode objectToOpaquePathNode, @Cached("createNotNormalized()") GetItemNode getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PSequence argsSequence; try { argsSequence = fastConstructListNode.execute(frame, inliningTarget, processArgs); } catch (PException e) { e.expect(inliningTarget, TypeError, isBuiltinClassProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_MUST_BE_S, "argv", "a tuple"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_BE_S, "argv", "a tuple"); } SequenceStorage argsStorage = getSequenceStorageNode.execute(inliningTarget, argsSequence); @@ -142,7 +142,7 @@ static Object[] doSequence(VirtualFrame frame, Object processArgs, SequenceStorage newStorage = getSequenceStorageNode.execute(inliningTarget, argsSequence); if (newStorage != argsStorage || newStorage.length() != len) { // TODO write a test for this - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.ARGS_CHANGED_DURING_ITERATION); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.ARGS_CHANGED_DURING_ITERATION); } Object o = getItemNode.execute(argsStorage, i); argsArray[i] = objectToOpaquePathNode.execute(frame, inliningTarget, o, false); @@ -171,7 +171,7 @@ static Object doSequence(VirtualFrame frame, Object env, @Cached ToBytesNode toBytesNode, @Cached PyObjectGetItem getItem, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // TODO unlike CPython, this accepts a dict (if the keys are integers (0, 1, ..., len-1) int length = sizeNode.execute(frame, inliningTarget, env); Object[] result = new Object[length]; @@ -180,7 +180,7 @@ static Object doSequence(VirtualFrame frame, Object env, byte[] bytes = toBytesNode.execute(frame, o); Object o1 = posixLib.createPathFromBytes(context.getPosixSupport(), bytes); if (o1 == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } result[i] = o1; } @@ -230,13 +230,13 @@ private static byte[] fsEncode(String s) { return s.getBytes(); } - private static Object createPathFromBytes(Node inliningTarget, byte[] bytes, PosixSupportLibrary posixLib, PRaiseNode.Lazy raiseNode) { + private static Object createPathFromBytes(Node inliningTarget, byte[] bytes, PosixSupportLibrary posixLib, PRaiseNode raiseNode) { Object o = posixLib.createPathFromBytes(PosixSupport.get(inliningTarget), bytes); if (o == null) { // TODO reconsider the contract of PosixSupportLibrary#createPathFromBytes w.r.t. // embedded null checks (we need to review that anyway since PosixSupportLibrary // cannot do Python-specific fsencode) - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } return o; } @@ -259,15 +259,15 @@ static int forkExec(VirtualFrame frame, Object[] args, Object executableList, bo @Cached GilNode gil, @Cached ToBytesNode toBytesNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(preexecFn instanceof PNone)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.S_NOT_SUPPORTED, "preexec_fn"); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.S_NOT_SUPPORTED, "preexec_fn"); } if (closeFds && errPipeWrite < 3) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.S_MUST_BE_S, "errpipe_write", ">= 3"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.S_MUST_BE_S, "errpipe_write", ">= 3"); } if (!(fdsToKeepObj instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "fork_exec()", 4, "tuple", fdsToKeepObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "fork_exec()", 4, "tuple", fdsToKeepObj); } Object[] processArgs = args; int[] fdsToKeep = convertFdSequence(inliningTarget, (PTuple) fdsToKeepObj, tupleGetItem, castToIntNode, raiseNode); @@ -284,7 +284,7 @@ static int forkExec(VirtualFrame frame, Object[] args, Object executableList, bo if (Arrays.equals(bytes, sysExecutable)) { TruffleString[] additionalArgs = PythonOptions.getExecutableList(context); if (length != 1 && additionalArgs.length != 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNSUPPORTED_USE_OF_SYS_EXECUTABLE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNSUPPORTED_USE_OF_SYS_EXECUTABLE); } Object[] extendedArgs = new Object[additionalArgs.length + (processArgs.length == 0 ? 0 : processArgs.length - 1)]; for (int j = 0; j < additionalArgs.length; ++j) { @@ -319,7 +319,7 @@ static int forkExec(VirtualFrame frame, Object[] args, Object executableList, bo * Checks that the tuple contains only valid fds (positive integers fitting into an int) in * ascending order. */ - private static int[] convertFdSequence(Node inliningTarget, PTuple fdSequence, GetItemNode getItemNode, CastToJavaIntExactNode castToIntNode, PRaiseNode.Lazy raiseNode) { + private static int[] convertFdSequence(Node inliningTarget, PTuple fdSequence, GetItemNode getItemNode, CastToJavaIntExactNode castToIntNode, PRaiseNode raiseNode) { SequenceStorage storage = fdSequence.getSequenceStorage(); int len = storage.length(); int[] fds = new int[len]; @@ -334,7 +334,7 @@ private static int[] convertFdSequence(Node inliningTarget, PTuple fdSequence, G } catch (PException | CannotCastException e) { // 'handled' by raise() below } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BAD_VALUES_IN_FDS_TO_KEEP); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BAD_VALUES_IN_FDS_TO_KEEP); } return fds; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java index 30994df2cf..71a25ec7c8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PwdModuleBuiltins.java @@ -152,13 +152,13 @@ static Object doGetpwuid(VirtualFrame frame, Object uidObj, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached InlinedConditionProfile unsignedConversionProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long uid; try { uid = uidConversionNode.executeLong(frame, uidObj); } catch (PException ex) { if (classProfile.profileException(inliningTarget, ex, PythonBuiltinClassType.OverflowError)) { - throw raiseUidNotFound(raiseNode.get(inliningTarget)); + throw raiseUidNotFound(inliningTarget, raiseNode); } throw ex; } @@ -174,14 +174,14 @@ static Object doGetpwuid(VirtualFrame frame, Object uidObj, throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } if (pwd == null) { - throw raiseUidNotFound(raiseNode.get(inliningTarget)); + throw raiseUidNotFound(inliningTarget, raiseNode); } PythonLanguage language = context.getLanguage(inliningTarget); return PFactory.createStructSeq(language, STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, language, unsignedConversionProfile)); } - private static PException raiseUidNotFound(PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.KeyError, ErrorMessages.GETPWUID_NOT_FOUND); + private static PException raiseUidNotFound(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.KeyError, ErrorMessages.GETPWUID_NOT_FOUND); } } @@ -205,7 +205,7 @@ static Object doGetpwname(VirtualFrame frame, TruffleString name, @Cached InlinedConditionProfile unsignedConversionProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // Note: CPython also takes only Strings, not bytes, and then encodes the String // StringOrBytesToOpaquePathNode already checks for embedded '\0' Object nameEncoded = encodeFSDefault.execute(inliningTarget, name); @@ -221,7 +221,7 @@ static Object doGetpwname(VirtualFrame frame, TruffleString name, throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } if (pwd == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, ErrorMessages.GETPWNAM_NAME_NOT_FOUND, name); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.KeyError, ErrorMessages.GETPWNAM_NAME_NOT_FOUND, name); } return PFactory.createStructSeq(language, STRUCT_PASSWD_DESC, createPwuidObject(inliningTarget, pwd, context.getLanguage(inliningTarget), unsignedConversionProfile)); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ReadlineModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ReadlineModuleBuiltins.java index 97c29ed086..c04088a8bb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ReadlineModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ReadlineModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -138,7 +138,7 @@ PNone setCompleter(PythonModule self, TruffleString tspec) { data.bindings.put("tab", spec.split(":")[1].trim()); return PNone.NONE; } else { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.NotImplementedError, toTruffleStringUncached("any other binding than 'tab'")); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.NotImplementedError, toTruffleStringUncached("any other binding than 'tab'")); } } } @@ -148,8 +148,8 @@ PNone setCompleter(PythonModule self, TruffleString tspec) { abstract static class ReadInitNode extends PythonUnaryBuiltinNode { @Specialization static PNone setCompleter(@SuppressWarnings("unused") PythonModule self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.OSError, ErrorMessages.NOT_IMPLEMENTED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.OSError, ErrorMessages.NOT_IMPLEMENTED); } } @@ -174,7 +174,7 @@ TruffleString setCompleter(PythonModule self, int index) { try { return data.history.get(index); } catch (IndexOutOfBoundsException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); + throw PRaiseNode.raiseStatic(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); } } } @@ -196,7 +196,7 @@ TruffleString setCompleter(PythonModule self, int index, TruffleString string) { try { return data.history.set(index, string); } catch (IndexOutOfBoundsException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); + throw PRaiseNode.raiseStatic(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); } } } @@ -211,7 +211,7 @@ TruffleString setCompleter(PythonModule self, int index) { try { return data.history.remove(index); } catch (IndexOutOfBoundsException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); + throw PRaiseNode.raiseStatic(this, PythonErrorType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); } } } @@ -258,7 +258,7 @@ PNone setCompleter(PythonModule self, TruffleString path) { } reader.close(); } catch (IOException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.IOError, e); + throw PRaiseNode.raiseStatic(this, PythonErrorType.IOError, e); } return PNone.NONE; } @@ -286,7 +286,7 @@ PNone setCompleter(PythonModule self, TruffleString path) { } writer.close(); } catch (IOException e) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.IOError, e); + throw PRaiseNode.raiseStatic(this, PythonErrorType.IOError, e); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java index 44d8d756aa..932fa7b785 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java @@ -164,14 +164,14 @@ static PTuple getruusage(VirtualFrame frame, int who, @Bind PythonContext context, @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PosixSupport posixSupport = context.getPosixSupport(); RusageResult rusage; try { rusage = posixLib.getrusage(posixSupport, who); } catch (PosixException e) { if (e.getErrorCode() == OSErrorEnum.EINVAL.getNumber()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.RUSAGE_INVALID_WHO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.RUSAGE_INVALID_WHO); } else { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java index 3f82f666a6..5f929437c2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java @@ -195,7 +195,7 @@ public static final class TRegexCache { private static final int FLAG_ASCII = 256; @TruffleBoundary - public TRegexCache(Object pattern, int flags) { + public TRegexCache(Node node, Object pattern, int flags) { this.originalPattern = pattern; String patternStr; boolean binary = true; @@ -207,7 +207,7 @@ public TRegexCache(Object pattern, int flags) { try { buffer = PythonBufferAcquireLibrary.getUncached().acquireReadonly(pattern); } catch (PException e) { - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.EXPECTED_STR_OR_BYTESLIKE_OBJ); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.EXPECTED_STR_OR_BYTESLIKE_OBJ); } PythonBufferAccessLibrary bufferLib = PythonBufferAccessLibrary.getUncached(); try { @@ -383,7 +383,7 @@ private String getTRegexOptions(String encoding, PythonMethod pythonMethod, bool } @TruffleBoundary - public Object compile(PythonContext context, PythonMethod method, boolean mustAdvance, TruffleString locale) { + public Object compile(Node node, PythonContext context, PythonMethod method, boolean mustAdvance, TruffleString locale) { String encoding = isBinary() ? ENCODING_LATIN_1 : ENCODING_UTF_32; String options = getTRegexOptions(encoding, method, mustAdvance, locale); InteropLibrary lib = InteropLibrary.getUncached(); @@ -397,7 +397,7 @@ public Object compile(PythonContext context, PythonMethod method, boolean mustAd regexp = compiledRegex; } } catch (RuntimeException e) { - throw handleCompilationError(e, lib, context); + throw handleCompilationError(node, e, lib, context); } if (isLocaleSensitive()) { setLocaleSensitiveRegexp(method, mustAdvance, locale, regexp); @@ -407,7 +407,7 @@ public Object compile(PythonContext context, PythonMethod method, boolean mustAd return regexp; } - private RuntimeException handleCompilationError(RuntimeException e, InteropLibrary lib, PythonContext context) { + private RuntimeException handleCompilationError(Node node, RuntimeException e, InteropLibrary lib, PythonContext context) { try { if (lib.isException(e)) { if (lib.getExceptionType(e) == ExceptionType.PARSE_ERROR) { @@ -416,14 +416,14 @@ private RuntimeException handleCompilationError(RuntimeException e, InteropLibra reason.equalsUncached(T_VALUE_ERROR_LOCALE_FLAG_STR_PATTERN, TS_ENCODING) || reason.equalsUncached(T_VALUE_ERROR_ASCII_UNICODE_INCOMPATIBLE, TS_ENCODING) || reason.equalsUncached(T_VALUE_ERROR_ASCII_LOCALE_INCOMPATIBLE, TS_ENCODING)) { - return PRaiseNode.getUncached().raise(ValueError, reason); + return PRaiseNode.raiseStatic(node, ValueError, reason); } else { SourceSection sourceSection = lib.getSourceLocation(e); int position = sourceSection.getCharIndex(); PythonModule module = context.lookupBuiltinModule(BuiltinNames.T__SRE); Object errorConstructor = PyObjectLookupAttr.executeUncached(module, T_ERROR); PBaseException exception = (PBaseException) CallNode.executeUncached(errorConstructor, reason, originalPattern, position); - return PRaiseNode.getUncached().raiseExceptionObject(exception); + return PRaiseNode.raiseExceptionObject(node, exception); } } } @@ -472,7 +472,7 @@ Object call(VirtualFrame frame, PythonObject patternObject, Object pattern, Obje @Cached PyLongAsIntNode flagsToIntNode, @Cached HiddenAttr.WriteNode writeCacheNode) { int flagsStr = flagsToIntNode.execute(frame, inliningTarget, flags); - TRegexCache tRegexCache = new TRegexCache(pattern, flagsStr); + TRegexCache tRegexCache = new TRegexCache(inliningTarget, pattern, flagsStr); writeCacheNode.execute(inliningTarget, patternObject, HiddenAttr.TREGEX_CACHE, tRegexCache); return PNone.NONE; } @@ -514,7 +514,7 @@ Object localeNonSensitive(PythonObject pattern, PythonMethod method, boolean mus if (tRegex != null) { return tRegex; } else { - return tRegexCache.compile(getContext(), method, mustAdvance, null); + return tRegexCache.compile(this, getContext(), method, mustAdvance, null); } } @@ -533,7 +533,7 @@ Object localeSensitive(VirtualFrame frame, PythonObject pattern, PythonMethod me if (tRegex != null) { return tRegex; } else { - return tRegexCache.compile(getContext(), method, mustAdvance, locale); + return tRegexCache.compile(this, getContext(), method, mustAdvance, locale); } } @@ -566,17 +566,17 @@ static void check(VirtualFrame frame, Object input, boolean expectBytes, @Cached BuiltinFunctions.IsInstanceNode isBytesNode, @Cached InlinedConditionProfile unsupportedInputTypeProfile, @Cached InlinedConditionProfile unexpectedInputTypeProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean isString = (boolean) isStringNode.execute(frame, input, PythonBuiltinClassType.PString); boolean isBytes = !isString && (boolean) isBytesNode.execute(frame, input, supportedBinaryInputTypes); if (unsupportedInputTypeProfile.profile(inliningTarget, !isString && !isBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, T_UNSUPPORTED_INPUT_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, T_UNSUPPORTED_INPUT_TYPE); } if (unexpectedInputTypeProfile.profile(inliningTarget, expectBytes != isBytes)) { if (expectBytes) { - throw raiseNode.get(inliningTarget).raise(TypeError, T_UNEXPECTED_STR); + throw raiseNode.raise(inliningTarget, TypeError, T_UNEXPECTED_STR); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, T_UNEXPECTED_BYTES); + throw raiseNode.raise(inliningTarget, TypeError, T_UNEXPECTED_BYTES); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java index 2260a423dd..3b500ccdac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java @@ -310,14 +310,14 @@ static Object txt2obj(TruffleString txt, boolean name, @Bind("this") Node inliningTarget, @Cached TruffleString.EqualNode equalNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // TODO implement properly if (equalNode.execute(T_OID_TLS_SERVER, txt, TS_ENCODING)) { return PFactory.createTuple(language, new Object[]{129, T_SERVER_AUTH, T_TLS_WEB_SERVER_AUTHENTICATION, txt}); } else if (equalNode.execute(T_OID_TLS_CLIENT, txt, TS_ENCODING)) { return PFactory.createTuple(language, new Object[]{130, T_CLIENT_AUTH, T_TLS_WEB_CLIENT_AUTHENTICATION, txt}); } - throw raiseNode.get(inliningTarget).raise(NotImplementedError); + throw raiseNode.raise(inliningTarget, NotImplementedError); } @Override @@ -332,8 +332,8 @@ abstract static class Nid2ObjNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object nid2obj(Object nid, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -342,8 +342,8 @@ static Object nid2obj(Object nid, abstract static class RandStatusNode extends PythonBuiltinNode { @Specialization static Object randStatus( - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -353,8 +353,8 @@ abstract static class RandAddNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object randAdd(Object string, Object entropy, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -364,8 +364,8 @@ abstract static class RandBytesNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object randBytes(Object n, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -375,8 +375,8 @@ abstract static class RandPseudoBytesNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object randPseudoBytes(Object n, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -408,8 +408,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static Object fail(TruffleString argument, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PermissionError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PermissionError); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java index 6f41808631..28281d1d0d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SelectModuleBuiltins.java @@ -134,7 +134,7 @@ static PTuple doGeneric(VirtualFrame frame, Object rlist, Object wlist, Object x @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ObjAndFDList readFDs = seq2set(frame, inliningTarget, rlist, sizeNode, asFileDescriptor, callGetItemNode, constructListNode, raiseNode); ObjAndFDList writeFDs = seq2set(frame, inliningTarget, wlist, sizeNode, asFileDescriptor, callGetItemNode, constructListNode, raiseNode); ObjAndFDList xFDs = seq2set(frame, inliningTarget, xlist, sizeNode, asFileDescriptor, callGetItemNode, constructListNode, raiseNode); @@ -144,7 +144,7 @@ static PTuple doGeneric(VirtualFrame frame, Object rlist, Object wlist, Object x isNotNoneTimeout.enter(inliningTarget); timeoutval = TimeUtils.pyTimeAsTimeval(pyTimeFromObjectNode.execute(frame, inliningTarget, timeout, RoundType.TIMEOUT, SEC_TO_NS)); if (timeoutval.getSeconds() < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE, "timeout"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.MUST_BE_NON_NEGATIVE, "timeout"); } } @@ -186,7 +186,7 @@ private static PList toList(boolean[] result, ObjAndFDList fds, PythonLanguage l private static ObjAndFDList seq2set(VirtualFrame frame, Node inliningTarget, Object sequence, PyObjectSizeNode sizeNode, PyObjectAsFileDescriptor asFileDescriptor, PyObjectGetItem callGetItemNode, - FastConstructListNode constructListNode, PRaiseNode.Lazy raiseNode) { + FastConstructListNode constructListNode, PRaiseNode raiseNode) { // We cannot assume any size of those two arrays, because the sequence may change as a // side effect of the invocation of fileno. We also need to call PyObjectSizeNode // repeatedly in the loop condition @@ -198,7 +198,7 @@ private static ObjAndFDList seq2set(VirtualFrame frame, Node inliningTarget, Obj objects.add(pythonObject); int fd = asFileDescriptor.execute(frame, inliningTarget, pythonObject); if (fd >= FD_SETSIZE.value) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.FILE_DESCRIPTOR_OUT_OF_RANGE_IN_SELECT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.FILE_DESCRIPTOR_OUT_OF_RANGE_IN_SELECT); } fds.add(fd); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java index 654b436933..2520389596 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java @@ -334,8 +334,8 @@ protected ArgumentClinicProvider getArgumentClinic() { abstract static class DefaultIntHandlerNode extends PythonBuiltinNode { @Specialization static Object defaultIntHandler(@SuppressWarnings("unused") Object[] args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.KeyboardInterrupt); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.KeyboardInterrupt); } } @@ -376,7 +376,7 @@ static Object signal(Node raisingNode, int signum, Object handler, ModuleData da data.signalSema.release(); }); } catch (IllegalArgumentException e) { - throw PRaiseNode.raiseUncached(raisingNode, PythonErrorType.ValueError, e); + throw PRaiseNode.raiseStatic(raisingNode, PythonErrorType.ValueError, e); } Object result = handlerToPython(oldHandler, signum, data); data.signalHandlers.put(signum, handler); @@ -393,7 +393,7 @@ private static Object signal(Node raisingNode, int signum, int id, ModuleData da oldHandler = Signals.setSignalHandler(signum, id); } } catch (IllegalArgumentException e) { - throw PRaiseNode.raiseUncached(raisingNode, PythonErrorType.TypeError, ErrorMessages.SIGNAL_MUST_BE_SIGIGN_SIGDFL_OR_CALLABLE_OBJ); + throw PRaiseNode.raiseStatic(raisingNode, PythonErrorType.TypeError, ErrorMessages.SIGNAL_MUST_BE_SIGIGN_SIGDFL_OR_CALLABLE_OBJ); } Object result = handlerToPython(oldHandler, signum, data); data.signalHandlers.remove(signum); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java index 20a289e4ce..a60a03f073 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java @@ -154,7 +154,7 @@ static int findProtocolByName(Node raisingNode, String protocolName) { return constant.getValueIfDefined(); } } - throw PRaiseNode.raiseUncached(raisingNode, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); + throw PRaiseNode.raiseStatic(raisingNode, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); } @Override @@ -428,7 +428,7 @@ static Object getServByName(TruffleString serviceName, Object protocolNameObj, @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString protocolName; if (noneProtocol.profile(inliningTarget, PGuards.isNoValue(protocolNameObj))) { protocolName = null; @@ -464,7 +464,7 @@ static Object getServByName(TruffleString serviceName, Object protocolNameObj, addrInfoCursorLib.release(cursor); } } catch (GetAddrInfoException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); } } @@ -490,7 +490,7 @@ Object getServByPort(int port, Object protocolNameObj, @Cached TruffleString.EqualNode equalNode, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString protocolName; if (nonProtocol.profile(inliningTarget, PGuards.isNoValue(protocolNameObj))) { protocolName = null; @@ -504,7 +504,7 @@ Object getServByPort(int port, Object protocolNameObj, * the legacy API in the future */ if (port < 0 || port > 0xffff) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_PORT_RANGE, "getservbyport"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_PORT_RANGE, "getservbyport"); } auditNode.audit(inliningTarget, "socket.getservbyport", port, protocolName != null ? protocolName : ""); @@ -524,14 +524,14 @@ Object getServByPort(int port, Object protocolNameObj, gil.acquire(); } } catch (GetAddrInfoException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); } } @TruffleBoundary private void checkName(TruffleString name) { if (name.toJavaStringUncached().matches("^\\d+$")) { - throw PRaiseNode.raiseUncached(this, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); + throw PRaiseNode.raiseStatic(this, OSError, ErrorMessages.SERVICE_PROTO_NOT_FOUND); } } @@ -559,11 +559,11 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached TruffleString.FromLongNode fromLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage addr = sockaddr.getSequenceStorage(); int addrLen = addr.length(); if (addrLen < 2 || addrLen > 4) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ILLEGAL_SOCKET_ADDR_ARG, "getnameinfo()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ILLEGAL_SOCKET_ADDR_ARG, "getnameinfo()"); } TruffleString address; int port, flowinfo = 0, scopeid = 0; @@ -571,13 +571,13 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, try { address = castAddress.execute(inliningTarget, arg0); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, arg0); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, arg0); } port = asIntNode.execute(frame, inliningTarget, getItem.execute(inliningTarget, addr, 1)); if (addrLen > 2) { flowinfo = asIntNode.execute(frame, inliningTarget, getItem.execute(inliningTarget, addr, 2)); if (flowinfo < 0 || flowinfo > 0xfffff) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_FLOWINFO_RANGE, "getnameinfo"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_FLOWINFO_RANGE, "getnameinfo"); } } if (addrLen > 3) { @@ -600,7 +600,7 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, family = addrInfoCursorLib.getFamily(cursor); resolvedAddr = addrInfoCursorLib.getSockAddr(cursor); if (addrInfoCursorLib.next(cursor)) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.SOCKADDR_RESOLVED_TO_MULTIPLE_ADDRESSES); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.SOCKADDR_RESOLVED_TO_MULTIPLE_ADDRESSES); } } finally { addrInfoCursorLib.release(cursor); @@ -612,13 +612,13 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, UniversalSockAddr queryAddr; if (family == AF_INET.value) { if (addrLen != 2) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.IPV4_MUST_BE_2_TUPLE); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.IPV4_MUST_BE_2_TUPLE); } queryAddr = posixLib.createUniversalSockAddrInet4(posixSupport, new Inet4SockAddr(port, sockAddrLibrary.asInet4SockAddr(resolvedAddr).getAddress())); } else if (family == AF_INET6.value) { queryAddr = posixLib.createUniversalSockAddrInet6(posixSupport, new Inet6SockAddr(port, sockAddrLibrary.asInet6SockAddr(resolvedAddr).getAddress(), flowinfo, scopeid)); } else { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.UNKNOWN_FAMILY); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.UNKNOWN_FAMILY); } Object[] getnameinfo = posixLib.getnameinfo(posixSupport, queryAddr, flags); @@ -633,8 +633,8 @@ static Object getNameInfo(VirtualFrame frame, PTuple sockaddr, int flags, @Fallback @SuppressWarnings("unused") static Object error(Object sockaddr, Object flags, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.GETNAMEINFO_ARG1_MUST_BE_TUPLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.GETNAMEINFO_ARG1_MUST_BE_TUPLE); } @Override @@ -667,7 +667,7 @@ static Object getAddrInfo(VirtualFrame frame, Object hostObject, Object portObje @Cached SequenceStorageNodes.AppendNode appendNode, @Cached TruffleString.FromLongNode fromLongNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object host = null; PosixSupport posixSupport = context.getPosixSupport(); if (hostObject != PNone.NONE) { @@ -685,7 +685,7 @@ static Object getAddrInfo(VirtualFrame frame, Object hostObject, Object portObje } else if (portObject == PNone.NONE) { port = null; } else { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.INT_OR_STRING_EXPECTED); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.INT_OR_STRING_EXPECTED); } auditNode.audit(inliningTarget, "socket.getaddrinfo", hostObject, portObjectProfiled, family, type, proto, flags); @@ -804,7 +804,7 @@ static PBytes doConvert(TruffleString addr, @Bind("this") Node inliningTarget, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PosixSupport posixSupport = context.getPosixSupport(); int converted = posixLib.inet_aton(posixSupport, posixLib.createPathFromString(posixSupport, addr)); @@ -812,7 +812,7 @@ static PBytes doConvert(TruffleString addr, ByteArraySupport.bigEndian().putInt(bytes, 0, converted); return PFactory.createBytes(context.getLanguage(inliningTarget), bytes); } catch (PosixSupportLibrary.InvalidAddressException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.ILLEGAL_IP_ADDR_STRING_TO_INET_ATON); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.ILLEGAL_IP_ADDR_STRING_TO_INET_ATON); } } @@ -833,13 +833,13 @@ static TruffleString doGeneric(VirtualFrame frame, Object addr, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(addr, frame, indirectCallData); try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); if (len != 4) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.PACKED_IP_WRONG_LENGTH, "inet_ntoa"); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.PACKED_IP_WRONG_LENGTH, "inet_ntoa"); } PosixSupport posixSupport = context.getPosixSupport(); Object result = posixLib.inet_ntoa(posixSupport, ByteArraySupport.bigEndian().getInt(bytes, 0)); @@ -861,7 +861,7 @@ static PBytes doConvert(VirtualFrame frame, int family, TruffleString addr, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PosixSupport posixSupport = context.getPosixSupport(); byte[] bytes = posixLib.inet_pton(posixSupport, family, posixLib.createPathFromString(posixSupport, addr)); @@ -869,7 +869,7 @@ static PBytes doConvert(VirtualFrame frame, int family, TruffleString addr, } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } catch (PosixSupportLibrary.InvalidAddressException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.ILLEGAL_IP_ADDR_STRING_TO_INET_PTON); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.ILLEGAL_IP_ADDR_STRING_TO_INET_PTON); } } @@ -892,21 +892,21 @@ static TruffleString doGeneric(VirtualFrame frame, int family, Object obj, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(obj, frame, indirectCallData); try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); if (family == AF_INET.value) { if (len != 4) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ILLEGAL_LENGTH_OF_PACKED_IP_ADDRS); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ILLEGAL_LENGTH_OF_PACKED_IP_ADDRS); } } else if (family == AF_INET6.value) { if (len != 16) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ILLEGAL_LENGTH_OF_PACKED_IP_ADDRS); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ILLEGAL_LENGTH_OF_PACKED_IP_ADDRS); } } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNKNOWN_ADDR_FAMILY, family); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNKNOWN_ADDR_FAMILY, family); } try { PosixSupport posixSupport = context.getPosixSupport(); @@ -935,10 +935,10 @@ static int convert(VirtualFrame frame, Object xObj, @Bind("this") Node inliningTarget, @Cached PyLongAsIntNode asIntNode, @Cached WarningsModuleBuiltins.WarnNode warnNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int x = asIntNode.execute(frame, inliningTarget, xObj); if (x < 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.NTOHS_CANT_CONVERT_NEG_PYTHON_INT); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.NTOHS_CANT_CONVERT_NEG_PYTHON_INT); } if (x > 0xFFFF) { warnNode.warnEx(frame, DeprecationWarning, ErrorMessages.NTOH_PYTHON_STRING_TOO_LARGE_TO_CONVERT, 1); @@ -959,13 +959,13 @@ abstract static class NToHLNode extends PythonUnaryBuiltinNode { static long convert(VirtualFrame frame, Object xObj, @Bind("this") Node inliningTarget, @Cached PyLongAsLongNode asLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long x = asLongNode.execute(frame, inliningTarget, xObj); if (x < 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); } if (x > 0xFFFFFFFFL) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.INT_LATGER_THAN_32_BITS); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.INT_LATGER_THAN_32_BITS); } int i = (int) x; if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java index d70b4ad778..6db62a371c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/StructModuleBuiltins.java @@ -262,8 +262,8 @@ static PStruct struct(@SuppressWarnings("unused") Object cls, PBytes format, @Specialization(guards = {"!isPBytes(format)", "!isPString(format)", "!isAsciiTruffleString(format, getCodeRangeNode)"}) static PStruct fallback(@SuppressWarnings("unused") Object cls, Object format, @SuppressWarnings("unused") @Shared @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(StructError, ARG_MUST_BE_STR_OR_BYTES, "Struct()", format); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, StructError, ARG_MUST_BE_STR_OR_BYTES, "Struct()", format); } protected static boolean isAsciiTruffleString(Object o, TruffleString.GetCodeRangeNode getCodeRangeNode) { @@ -278,7 +278,7 @@ private static PStruct.StructInfo createStructInternal(Node raisingNode, byte[] int num; if (containsNullCharacter(format)) { - throw PRaiseNode.raiseUncached(raisingNode, PythonBuiltinClassType.StructError, EMBEDDED_NULL_CHARACTER); + throw PRaiseNode.raiseStatic(raisingNode, PythonBuiltinClassType.StructError, EMBEDDED_NULL_CHARACTER); } char alignment = DEFAULT_ALIGNMENT; @@ -301,12 +301,12 @@ private static PStruct.StructInfo createStructInternal(Node raisingNode, byte[] num = c - '0'; while (++i < format.length && '0' <= (c = (char) format[i]) && c <= '9') { if (num >= Integer.MAX_VALUE / 10 && (num > Integer.MAX_VALUE / 10 || (c - '0') > Integer.MAX_VALUE % 10)) { - throw PRaiseNode.raiseUncached(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); + throw PRaiseNode.raiseStatic(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); } num = num * 10 + (c - '0'); } if (i == format.length) { - throw PRaiseNode.raiseUncached(raisingNode, StructError, REPEAT_COUNT_WITHOUT_FMT); + throw PRaiseNode.raiseStatic(raisingNode, StructError, REPEAT_COUNT_WITHOUT_FMT); } } else { num = 1; @@ -333,11 +333,11 @@ private static PStruct.StructInfo createStructInternal(Node raisingNode, byte[] int itemSize = formatDef.size; size = align(size, c, formatDef); if (size == -1) { - throw PRaiseNode.raiseUncached(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); + throw PRaiseNode.raiseStatic(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); } if (num > (Integer.MAX_VALUE - size) / itemSize) { - throw PRaiseNode.raiseUncached(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); + throw PRaiseNode.raiseStatic(raisingNode, StructError, ErrorMessages.STRUCT_SIZE_TOO_LONG); } size += num * itemSize; } @@ -383,7 +383,7 @@ private static FormatDef getEntry(Node raisingNode, char format, FormatDef[] tab if (formatDef != null) { return formatDef; } - throw PRaiseNode.raiseUncached(raisingNode, StructError, BAD_CHR_IN_STRUCT_FMT, format); + throw PRaiseNode.raiseStatic(raisingNode, StructError, BAD_CHR_IN_STRUCT_FMT, format); } private static boolean isAlignment(char alignment) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java index ef559ae7f6..e05902b286 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java @@ -253,6 +253,7 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -899,10 +900,10 @@ static PFrame counted(VirtualFrame frame, int num, @Bind("this") Node inliningTarget, @Cached ReadCallerFrameNode readCallerNode, @Cached InlinedConditionProfile callStackDepthProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PFrame requested = escapeFrame(frame, num, readCallerNode); if (callStackDepthProfile.profile(inliningTarget, requested == null)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CALL_STACK_NOT_DEEP_ENOUGH); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CALL_STACK_NOT_DEEP_ENOUGH); } return requested; } @@ -967,18 +968,18 @@ public abstract static class InternNode extends PythonUnaryBuiltinNode { static Object doPString(Object s, @Bind("this") Node inliningTarget, @Cached StringNodes.InternStringNode internNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final PString interned = internNode.execute(inliningTarget, s); if (interned == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_INTERN_P, s); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_INTERN_P, s); } return interned; } @Fallback static Object doOthers(Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.S_ARG_MUST_BE_S_NOT_P, "intern()", "str", obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.S_ARG_MUST_BE_S_NOT_P, "intern()", "str", obj); } } @@ -1030,7 +1031,7 @@ static Object doGeneric(VirtualFrame frame, Object object, @SuppressWarnings("un @Bind("this") Node inliningTarget, @Shared @Cached PyNumberAsSizeNode asSizeNode, @Cached("createWithError()") LookupAndCallUnaryNode callSizeofNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return checkResult(frame, inliningTarget, asSizeNode, callSizeofNode.executeObject(frame, object), raiseNode); } @@ -1039,7 +1040,7 @@ static Object doGeneric(VirtualFrame frame, Object object, Object dflt, @Bind("this") Node inliningTarget, @Shared @Cached PyNumberAsSizeNode asSizeNode, @Cached("createWithoutError()") LookupAndCallUnaryNode callSizeofNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object result = callSizeofNode.executeObject(frame, object); if (result == PNone.NO_VALUE) { return dflt; @@ -1047,10 +1048,10 @@ static Object doGeneric(VirtualFrame frame, Object object, Object dflt, return checkResult(frame, inliningTarget, asSizeNode, result, raiseNode); } - private static Object checkResult(VirtualFrame frame, Node inliningTarget, PyNumberAsSizeNode asSizeNode, Object result, PRaiseNode.Lazy raiseNode) { + private static Object checkResult(VirtualFrame frame, Node inliningTarget, PyNumberAsSizeNode asSizeNode, Object result, PRaiseNode raiseNode) { int value = asSizeNode.executeExact(frame, inliningTarget, result); if (value < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SHOULD_RETURN, "__sizeof__()", ">= 0"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SHOULD_RETURN, "__sizeof__()", ">= 0"); } return value; } @@ -1058,11 +1059,12 @@ private static Object checkResult(VirtualFrame frame, Node inliningTarget, PyNum @NeverDefault protected LookupAndCallUnaryNode createWithError() { return LookupAndCallUnaryNode.create(T___SIZEOF__, () -> new NoAttributeHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object receiver) { - throw raiseNode.raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, receiver, T___SIZEOF__); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, receiver, T___SIZEOF__); } }); } @@ -1342,10 +1344,10 @@ private void writeUnraisableExc(MaterializedFrame frame, PythonModule sys, Objec Object doit(VirtualFrame frame, PythonModule sys, Object args, @Bind("this") Node inliningTarget, @Cached PyTupleGetItem getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final Object cls = getObjectClass(args); if (cls != PythonBuiltinClassType.PUnraisableHookArgs) { - throw raiseNode.get(inliningTarget).raise(TypeError, ARG_TYPE_MUST_BE, "sys.unraisablehook", "UnraisableHookArgs"); + throw raiseNode.raise(inliningTarget, TypeError, ARG_TYPE_MUST_BE, "sys.unraisablehook", "UnraisableHookArgs"); } final Object excType = getItemNode.execute(inliningTarget, args, 0); final Object excValue = getItemNode.execute(inliningTarget, args, 1); @@ -1687,10 +1689,10 @@ static Object doHook(VirtualFrame frame, PythonModule sys, Object obj, @Cached CastToTruffleStringNode castToStringNode, @Cached PyUnicodeAsEncodedString pyUnicodeAsEncodedString, @Cached PyUnicodeFromEncodedObject pyUnicodeFromEncodedObject, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final PythonModule builtins = PythonContext.get(inliningTarget).getBuiltins(); if (builtins == null) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, LOST_S, "builtins module"); + throw raiseNode.raise(inliningTarget, RuntimeError, LOST_S, "builtins module"); } // Print value except if None // After printing, also assign to '_' @@ -1702,7 +1704,7 @@ static Object doHook(VirtualFrame frame, PythonModule sys, Object obj, setAttr.execute(frame, inliningTarget, builtins, T___, PNone.NONE); Object stdOut = objectLookupAttr(frame, inliningTarget, sys, T_STDOUT, lookupAttr); if (PGuards.isPNone(stdOut)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, LOST_S, "sys.stdout"); + throw raiseNode.raise(inliningTarget, RuntimeError, LOST_S, "sys.stdout"); } Object reprVal = null; @@ -1855,9 +1857,9 @@ static Object setRecLim(VirtualFrame frame, @SuppressWarnings("unused") PythonMo @Bind("this") Node inliningTarget, @Cached PyLongAsIntNode longAsIntNode, @Cached PyFloatCheckExactNode floatCheckExactNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (floatCheckExactNode.execute(inliningTarget, limit)) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_EXPECTED_GOT_P, "integer", limit); + throw raiseNode.raise(inliningTarget, TypeError, S_EXPECTED_GOT_P, "integer", limit); } int newLimit; @@ -1868,7 +1870,7 @@ static Object setRecLim(VirtualFrame frame, @SuppressWarnings("unused") PythonMo } if (newLimit < 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, REC_LIMIT_GREATER_THAN_1); + throw raiseNode.raise(inliningTarget, ValueError, REC_LIMIT_GREATER_THAN_1); } // TODO: check to see if Issue #25274 applies @@ -1908,9 +1910,9 @@ static Object setCheckInterval(VirtualFrame frame, @SuppressWarnings("unused") P @Cached WarningsModuleBuiltins.WarnNode warnNode, @Cached PyLongAsIntNode longAsIntNode, @Cached PyFloatCheckExactNode floatCheckExactNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (floatCheckExactNode.execute(inliningTarget, arg)) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_EXPECTED_GOT_P, "integer", arg); + throw raiseNode.raise(inliningTarget, TypeError, S_EXPECTED_GOT_P, "integer", arg); } try { @@ -1956,10 +1958,10 @@ abstract static class SetSwitchIntervalNode extends PythonBuiltinNode { static Object setCheckInterval(VirtualFrame frame, @SuppressWarnings("unused") PythonModule sys, Object arg, @Bind("this") Node inliningTarget, @Cached PyFloatAsDoubleNode floatAsDoubleNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { double interval = floatAsDoubleNode.execute(frame, inliningTarget, arg); if (interval <= 0.0) { - throw raiseNode.get(inliningTarget).raise(ValueError, SWITCH_INTERVAL_MUST_BE_POSITIVE); + throw raiseNode.raise(inliningTarget, ValueError, SWITCH_INTERVAL_MUST_BE_POSITIVE); } PythonContext.get(inliningTarget).getSysModuleState().setSwitchInterval(FACTOR * interval); return PNone.NONE; @@ -1980,8 +1982,8 @@ abstract static class ExitNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object exitNoCode(PythonModule sys, PNone status, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseSystemExit(PNone.NONE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseSystemExitStatic(inliningTarget, PNone.NONE); } @Specialization(guards = "!isPNone(status)") @@ -1989,15 +1991,14 @@ static Object exit(VirtualFrame frame, @SuppressWarnings("unused") PythonModule @Bind("this") Node inliningTarget, @Cached PyTupleCheckNode tupleCheckNode, @Cached TupleBuiltins.LenNode tupleLenNode, - @Cached PyTupleGetItem getItemNode, - @Shared @Cached PRaiseNode raiseNode) { + @Cached PyTupleGetItem getItemNode) { Object code = status; if (tupleCheckNode.execute(inliningTarget, status)) { if (tupleLenNode.executeInt(frame, status) == 1) { code = getItemNode.execute(inliningTarget, status, 0); } } - throw raiseNode.raiseSystemExit(code); + throw PRaiseNode.raiseSystemExitStatic(inliningTarget, code); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java index 59a4cad38c..e7aef1644f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java @@ -199,9 +199,9 @@ long getStackSize(@SuppressWarnings("unused") PNone stackSize) { @Specialization static long getStackSize(long stackSize, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (stackSize < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SIZE_MUST_BE_D_OR_S, 0, "a positive value"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SIZE_MUST_BE_D_OR_S, 0, "a positive value"); } return PythonContext.get(inliningTarget).getAndSetPythonsThreadStackSize(stackSize); } @@ -303,8 +303,8 @@ protected ArgumentClinicProvider getArgumentClinic() { abstract static class ExitThreadNode extends PythonBuiltinNode { @Specialization static Object exit( - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseSystemExit(PNone.NONE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseSystemExitStatic(inliningTarget, PNone.NONE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java index 043be4b730..10f9383697 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java @@ -271,21 +271,21 @@ static long doNone(VirtualFrame frame, Node inliningTarget, PNone none) { @Specialization static long doLong(Node inliningTarget, long t, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { check(inliningTarget, t, raiseNode); return t; } @Specialization static long doDouble(Node inliningTarget, double t, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { check(inliningTarget, t, raiseNode); return (long) t; } @Specialization(guards = "!isPNone(obj)") static long doObject(VirtualFrame frame, Node inliningTarget, Object obj, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached CastToJavaDoubleNode castToDouble, @Cached PyLongAsLongNode asLongNode) { long t; @@ -302,9 +302,9 @@ private static boolean isValidTime(double t) { return t >= MIN_TIME && t <= MAX_TIME; } - private static void check(Node inliningTarget, double time, PRaiseNode.Lazy raiseNode) { + private static void check(Node inliningTarget, double time, PRaiseNode raiseNode) { if (!isValidTime(time)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, TIMESTAMP_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, OverflowError, TIMESTAMP_OUT_OF_RANGE); } } } @@ -339,7 +339,7 @@ Object tzset() { } TimeZone.setDefault(TimeZone.getTimeZone(tzEnv)); } else { - PRaiseNode.raiseUncached(this, PythonBuiltinClassType.AttributeError, SET_TIMEZONE_ERROR); + PRaiseNode.raiseStatic(this, PythonBuiltinClassType.AttributeError, SET_TIMEZONE_ERROR); } return PNone.NONE; } @@ -523,8 +523,8 @@ Object sleep(PythonModule self, long seconds, @SuppressWarnings("unused") @Specialization(guards = "!isPositive(seconds)") static Object err(PythonModule self, long seconds, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MUST_BE_NON_NEGATIVE, "sleep length"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_BE_NON_NEGATIVE, "sleep length"); } @Specialization(guards = "isPositive(seconds)") @@ -547,8 +547,8 @@ Object sleep(PythonModule self, double seconds, @SuppressWarnings("unused") @Specialization(guards = "!isPositive(seconds)") static Object err(PythonModule self, double seconds, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MUST_BE_NON_NEGATIVE, "sleep length"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_BE_NON_NEGATIVE, "sleep length"); } @Specialization(guards = "!isInteger(secondsObj)") @@ -630,10 +630,10 @@ private static String timeFormat(int[] date) { protected static int[] checkStructtime(VirtualFrame frame, Node inliningTarget, PTuple time, SequenceStorageNodes.GetInternalObjectArrayNode getInternalObjectArrayNode, PyNumberAsSizeNode asSizeNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object[] otime = getInternalObjectArrayNode.execute(inliningTarget, time.getSequenceStorage()); if (time.getSequenceStorage().length() != 9) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ILLEGAL_TIME_TUPLE_ARG, "asctime()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ILLEGAL_TIME_TUPLE_ARG, "asctime()"); } int[] date = new int[9]; for (int i = 0; i < 9; i++) { @@ -642,37 +642,37 @@ protected static int[] checkStructtime(VirtualFrame frame, Node inliningTarget, // This is specific to java if (date[TM_YEAR] < Year.MIN_VALUE || date[TM_YEAR] > Year.MAX_VALUE) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.YEAR_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.YEAR_OUT_OF_RANGE); } if (date[TM_MON] == 0) { date[TM_MON] = 1; } else if (date[TM_MON] < 0 || date[TM_MON] > 12) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MONTH_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MONTH_OUT_OF_RANGE); } if (date[TM_MDAY] == 0) { date[TM_MDAY] = 1; } else if (date[TM_MDAY] < 0 || date[TM_MDAY] > 31) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.DAY_OF_MONTH_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.DAY_OF_MONTH_OUT_OF_RANGE); } if (date[TM_HOUR] < 0 || date[TM_HOUR] > 23) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.HOUR_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HOUR_OUT_OF_RANGE); } if (date[TM_MIN] < 0 || date[TM_MIN] > 59) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MINUTE_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MINUTE_OUT_OF_RANGE); } if (date[TM_SEC] < 0 || date[TM_SEC] > 61) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SECONDS_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SECONDS_OUT_OF_RANGE); } if (date[TM_WDAY] == -1) { date[TM_WDAY] = 6; } else if (date[TM_WDAY] < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.DAY_OF_WEEK_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.DAY_OF_WEEK_OUT_OF_RANGE); } else if (date[TM_WDAY] > 6) { date[TM_WDAY] = date[TM_WDAY] % 7; } @@ -680,7 +680,7 @@ protected static int[] checkStructtime(VirtualFrame frame, Node inliningTarget, if (date[TM_YDAY] == 0) { date[TM_YDAY] = 1; } else if (date[TM_YDAY] < 0 || date[TM_YDAY] > 366) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.DAY_OF_YEAR_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.DAY_OF_YEAR_OUT_OF_RANGE); } if (date[TM_ISDST] < -1) { @@ -945,9 +945,9 @@ static TruffleString formatTime(PythonModule module, TruffleString format, @Supp @Shared("byteIndexOfCp") @Cached TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode, @Shared("ts2js") @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (byteIndexOfCodePointNode.execute(format, 0, 0, format.byteLength(TS_ENCODING), TS_ENCODING) >= 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.EMBEDDED_NULL_CHARACTER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EMBEDDED_NULL_CHARACTER); } ModuleState moduleState = module.getModuleState(ModuleState.class); return format(toJavaStringNode.execute(format), getIntLocalTimeStruct(moduleState.currentZoneId, (long) timeSeconds()), fromJavaStringNode); @@ -961,9 +961,9 @@ static TruffleString formatTime(VirtualFrame frame, @SuppressWarnings("unused") @Shared("byteIndexOfCp") @Cached TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode, @Shared("ts2js") @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (byteIndexOfCodePointNode.execute(format, 0, 0, format.byteLength(TS_ENCODING), TS_ENCODING) >= 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.EMBEDDED_NULL_CHARACTER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EMBEDDED_NULL_CHARACTER); } int[] date = checkStructtime(frame, inliningTarget, time, getArray, asSizeNode, raiseNode); return format(toJavaStringNode.execute(format), date, fromJavaStringNode); @@ -972,8 +972,8 @@ static TruffleString formatTime(VirtualFrame frame, @SuppressWarnings("unused") @Specialization @SuppressWarnings("unused") static TruffleString formatTime(PythonModule module, TruffleString format, Object time, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.TUPLE_OR_STRUCT_TIME_ARG_REQUIRED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.TUPLE_OR_STRUCT_TIME_ARG_REQUIRED); } } @@ -992,10 +992,10 @@ static double mktime(VirtualFrame frame, PythonModule module, PTuple tuple, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, @Cached GetObjectArrayNode getObjectArrayNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] items = getObjectArrayNode.execute(inliningTarget, tuple); if (items.length != ELEMENT_COUNT) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.FUNC_TAKES_EXACTLY_D_ARGS, ELEMENT_COUNT, items.length); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.FUNC_TAKES_EXACTLY_D_ARGS, ELEMENT_COUNT, items.length); } int[] integers = new int[ELEMENT_COUNT]; for (int i = 0; i < ELEMENT_COUNT; i++) { @@ -1058,15 +1058,15 @@ static TruffleString localtime(VirtualFrame frame, @SuppressWarnings("unused") P @Cached SequenceStorageNodes.GetInternalObjectArrayNode getArray, @Cached PyNumberAsSizeNode asSizeNode, @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { return format(StrfTimeNode.checkStructtime(frame, inliningTarget, time, getArray, asSizeNode, raiseNode), fromJavaStringNode); } @Fallback @SuppressWarnings("unused") static Object localtime(Object module, Object time, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.TUPLE_OR_STRUCT_TIME_ARG_REQUIRED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TUPLE_OR_STRUCT_TIME_ARG_REQUIRED); } protected static TruffleString format(int[] tm, TruffleString.FromJavaStringNode fromJavaStringNode) { @@ -1115,7 +1115,7 @@ static Object getClockInfo(TruffleString name, @Cached WriteAttributeToPythonObjectNode writeAttrNode, @Cached TruffleString.EqualNode equalNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final boolean adjustable; final boolean monotonic; @@ -1127,7 +1127,7 @@ static Object getClockInfo(TruffleString name, adjustable = true; monotonic = false; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, UNKNOWN_CLOCK); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, UNKNOWN_CLOCK); } final PSimpleNamespace ns = PFactory.createSimpleNamespace(language); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TracemallocModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TracemallocModuleBuiltins.java index 7ba1ed0fbc..ae552073fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TracemallocModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TracemallocModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -52,10 +52,11 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; @CoreFunctions(defineModule = J__TRACEMALLOC) public final class TracemallocModuleBuiltins extends PythonBuiltins { @@ -75,8 +76,8 @@ public void initialize(Python3Core core) { abstract static class GetObjectTracebackNode extends PythonBuiltinNode { @Specialization static Object getObjectTraceback(Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError); } } @@ -85,8 +86,8 @@ static Object getObjectTraceback(Object obj, abstract static class GetTracesNode extends PythonBuiltinNode { @Specialization static Object getTraces( - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/UnicodeDataModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/UnicodeDataModuleBuiltins.java index 354414ca22..50bb3f8d0b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/UnicodeDataModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/UnicodeDataModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -141,7 +141,7 @@ static TruffleString normalize(@SuppressWarnings("unused") TruffleString form, T @Specialization(guards = "getNormalizer(form) == null") TruffleString invalidForm(@SuppressWarnings("unused") TruffleString form, @SuppressWarnings("unused") TruffleString unistr) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.INVALID_NORMALIZATION_FORM); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.INVALID_NORMALIZATION_FORM); } @TruffleBoundary @@ -173,7 +173,7 @@ boolean isNormalized(@SuppressWarnings("unused") TruffleString form, TruffleStri @Specialization(guards = "getNormalizer(form) == null") TruffleString invalidForm(@SuppressWarnings("unused") TruffleString form, @SuppressWarnings("unused") TruffleString unistr) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.INVALID_NORMALIZATION_FORM); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.INVALID_NORMALIZATION_FORM); } @Override @@ -192,11 +192,11 @@ public abstract static class NameNode extends PythonBinaryClinicBuiltinNode { static Object name(int cp, Object defaultValue, @Bind("this") Node inliningTarget, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { String result = getUnicodeName(cp); if (result == null) { if (defaultValue == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NO_SUCH_NAME); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NO_SUCH_NAME); } return defaultValue; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java index 469e070bb9..efc34f1b3a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WarningsModuleBuiltins.java @@ -204,7 +204,6 @@ private static PList initFilters(PythonLanguage language) { static final class WarningsModuleNode extends Node { @Child CastToTruffleStringNode castStr; - @Child PRaiseNode raiseNode; @Child PyObjectRichCompareBool.EqNode eqNode; @Child GetClassNode getClassNode; @Child PyNumberAsSizeNode asSizeNode; @@ -376,15 +375,6 @@ private TruffleString.SubstringNode getSubstringNode() { return substringNode; } - private PRaiseNode getRaise() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - reportPolymorphicSpecialize(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } - private IsSubClassNode getIsSubClass() { if (isSubClassNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -465,7 +455,7 @@ private boolean checkMatched(VirtualFrame frame, Object obj, Object arg) { return getEqualNode().execute(objStr, getCastStr().executeCached(arg), TS_ENCODING); } catch (CannotCastException e) { // Python calls PyUnicode_Compare directly, which raises this error - throw getRaise().raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANT_COMPARE, obj, arg); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.CANT_COMPARE, obj, arg); } } catch (CannotCastException e) { Object result = getCallMethodNode().executeCached(frame, obj, T_MATCH, arg); @@ -529,7 +519,7 @@ private static PDict getOnceRegistry(Node node, PythonContext context, PythonMod registry = getStateOnceRegistry(module); } if (!(registry instanceof PDict)) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.TypeError, ErrorMessages.WARN_ONCE_REG_MUST_BE_DICT, registry); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.TypeError, ErrorMessages.WARN_ONCE_REG_MUST_BE_DICT, registry); } return (PDict) registry; } @@ -545,7 +535,7 @@ private TruffleString getDefaultAction(VirtualFrame frame, PythonModule module) try { return getCastStr().executeCached(defaultAction); } catch (CannotCastException e) { - throw getRaise().raise(PythonBuiltinClassType.TypeError, ErrorMessages.WARN_DEF_ACTION_MUST_BE_STRING, defaultAction); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.WARN_DEF_ACTION_MUST_BE_STRING, defaultAction); } } @@ -560,18 +550,18 @@ private TruffleString getFilter(VirtualFrame frame, PythonModule _warnings, Obje filters = getStateFilters(_warnings); } if (!(filters instanceof PList)) { - throw getRaise().raise(PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_MUST_BE_LIST); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_MUST_BE_LIST); } SequenceStorage filtersStorage = ((PList) filters).getSequenceStorage(); SequenceStorageNodes.GetItemScalarNode sequenceGetItem = getSequenceGetItemNode(); for (int i = 0; i < filtersStorage.length(); i++) { Object tmpItem = sequenceGetItem.executeCached(filtersStorage, i); if (!(tmpItem instanceof PTuple)) { - throw getRaise().raise(PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_IETM_ISNT_5TUPLE, i); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_IETM_ISNT_5TUPLE, i); } SequenceStorage tmpStorage = ((PTuple) tmpItem).getSequenceStorage(); if (tmpStorage.length() != 5) { - throw getRaise().raise(PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_IETM_ISNT_5TUPLE, i); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.WARN_FILTERS_IETM_ISNT_5TUPLE, i); } Object actionObj = sequenceGetItem.executeCached(tmpStorage, 0); @@ -581,7 +571,7 @@ private TruffleString getFilter(VirtualFrame frame, PythonModule _warnings, Obje } catch (CannotCastException e) { // CPython does this check after the other __getitem__ calls, but we know it's a // tuple so... - throw getRaise().raise(PythonBuiltinClassType.TypeError, ErrorMessages.ACTION_MUST_BE_STRING, actionObj); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.ACTION_MUST_BE_STRING, actionObj); } Object msg = sequenceGetItem.executeCached(tmpStorage, 1); Object cat = sequenceGetItem.executeCached(tmpStorage, 2); @@ -713,10 +703,8 @@ private static void showWarning(Object filename, int lineno, Object text, Object } @TruffleBoundary - private static void callShowWarning(PythonContext context, Object category, Object text, Object message, + private void callShowWarning(PythonContext context, Object category, Object text, Object message, TruffleString filename, int lineno, TruffleString sourceline, Object sourceIn) { - PRaiseNode raise = PRaiseNode.getUncached(); - Object showFn = getWarningsAttr(context, T__SHOWWARNMSG, sourceIn != null); if (showFn == null) { showWarning(filename, lineno, text, category, sourceline); @@ -724,12 +712,12 @@ private static void callShowWarning(PythonContext context, Object category, Obje } if (!PyCallableCheckNode.executeUncached(showFn)) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.WARN_MUST_BE_SET_CALLABLE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.WARN_MUST_BE_SET_CALLABLE); } Object warnmsgCls = getWarningsAttr(context, T_WARNING_MESSAGE, false); if (warnmsgCls == null) { - throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.UNABLE_GET_WARN_MSG); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNABLE_GET_WARN_MSG); } Object source = sourceIn == null ? PNone.NONE : sourceIn; @@ -765,7 +753,7 @@ private void warnExplicit(VirtualFrame frame, PythonModule warnings, } else if (registryObj instanceof PDict) { registry = (PDict) registryObj; } else { - throw getRaise().raise(PythonBuiltinClassType.TypeError, ErrorMessages.REGISTRY_MUST_BE_DICT); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.REGISTRY_MUST_BE_DICT); } if (module == null) { @@ -806,22 +794,21 @@ private void warnExplicit(VirtualFrame frame, PythonModule warnings, PythonLanguage language = context.getLanguage(this); Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); try { - warnExplicitPart2(context, this, warnings, filename, lineno, registry, globals, source, category, message, text, key, item[0], action); + warnExplicitPart2(context, warnings, filename, lineno, registry, globals, source, category, message, text, key, item[0], action); } finally { IndirectCallContext.exit(frame, language, context, state); } } @TruffleBoundary - private static void warnExplicitPart2(PythonContext context, Node node, PythonModule warnings, TruffleString filename, int lineno, PDict registry, PDict globals, Object source, + private void warnExplicitPart2(PythonContext context, PythonModule warnings, TruffleString filename, int lineno, PDict registry, PDict globals, Object source, Object category, Object message, Object text, Object key, Object item, TruffleString action) { if (action.equalsUncached(T_ERROR, TS_ENCODING)) { if (!PyExceptionInstanceCheckNode.executeUncached(message)) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, - PyObjectReprAsTruffleStringNode.executeUncached(message)); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, PyObjectReprAsTruffleStringNode.executeUncached(message)); } else { - throw PRaiseNode.raiseExceptionObject(node, message); + throw PRaiseNode.raiseExceptionObject(this, message); } } @@ -833,7 +820,7 @@ private static void warnExplicitPart2(PythonContext context, Node node, PythonMo boolean alreadyWarned = false; if (action.equalsUncached(T_ONCE, TS_ENCODING)) { if (registry == null) { - PDict currentRegistry = getOnceRegistry(node, context, warnings); + PDict currentRegistry = getOnceRegistry(this, context, warnings); alreadyWarned = updateRegistry(context.getLanguage(), warnings, currentRegistry, text, category, false); } else { alreadyWarned = updateRegistry(context.getLanguage(), warnings, registry, text, category, false); @@ -843,7 +830,7 @@ private static void warnExplicitPart2(PythonContext context, Node node, PythonMo alreadyWarned = updateRegistry(context.getLanguage(), warnings, registry, text, category, false); } } else if (!action.equalsUncached(T_DEFAULT, TS_ENCODING)) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNRECOGNIZED_ACTION_IN_WARNINGS, action, + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNRECOGNIZED_ACTION_IN_WARNINGS, action, PyObjectReprAsTruffleStringNode.executeUncached(item)); } @@ -856,7 +843,7 @@ private static void warnExplicitPart2(PythonContext context, Node node, PythonMo // to delay it TruffleString sourceline = null; if (globals != null) { - sourceline = getSourceLine(node, globals, lineno); + sourceline = getSourceLine(this, globals, lineno); } callShowWarning(context, category, text, message, filename, lineno, sourceline, source); @@ -912,7 +899,7 @@ private Object getCategory(VirtualFrame frame, Object message, Object category) } else if (category == null || category == PNone.NONE) { return PythonBuiltinClassType.UserWarning; } else if (!getIsTypeNode().executeCached(category) || !getIsSubClass().executeBoolean(frame, category, PythonBuiltinClassType.Warning)) { - throw getRaise().raise(PythonBuiltinClassType.TypeError, ErrorMessages.CATEGORY_MUST_BE_WARN_SUBCLS, category); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.CATEGORY_MUST_BE_WARN_SUBCLS, category); } else { return category; } @@ -958,13 +945,13 @@ private static TruffleString getSourceLine(Node node, PDict globals, int lineno) try { src = CastToJavaStringNode.getUncached().execute(source); } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_S_NOT_P, "str", source); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.TypeError, ErrorMessages.EXPECTED_S_NOT_P, "str", source); } String[] lines = src.split("\n"); if (lines.length >= lineno) { return toTruffleStringUncached(lines[lineno - 1]); } else { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS); } } } @@ -1010,12 +997,12 @@ static Object doWarn(VirtualFrame frame, PythonModule mod, Object message, Objec @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached CastToTruffleStringNode castStr, @Cached WarningsModuleNode moduleFunctionsNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString filename; try { filename = castStr.execute(inliningTarget, flname); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "warn_explicit()", 3, "str", flname); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, "warn_explicit()", 3, "str", flname); } PDict globalsDict; if (globals instanceof PNone) { @@ -1023,7 +1010,7 @@ static Object doWarn(VirtualFrame frame, PythonModule mod, Object message, Objec } else if (globals instanceof PDict) { globalsDict = (PDict) globals; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.MOD_GLOBALS_MUST_BE_DICT, globals); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MOD_GLOBALS_MUST_BE_DICT, globals); } // CPython calls get_source_line here. But since that's potentially slow, maybe we can // get away with doing that lazily diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java index 298854a1e0..85a05e4c0d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/WeakRefModuleBuiltins.java @@ -263,7 +263,7 @@ static PReferenceType refType(Object cls, Object object, @SuppressWarnings("unus @Bind PythonLanguage language, @Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached HiddenAttr.ReadNode readQueueNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object obj = object; if (object instanceof PythonBuiltinClassType tobj) { obj = PythonContext.get(inliningTarget).getCore().lookupType(tobj); @@ -275,7 +275,7 @@ static PReferenceType refType(Object cls, Object object, @SuppressWarnings("unus allowed = type.getWeaklistoffset() != 0; } if (!allowed) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CREATE_WEAK_REFERENCE_TO, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_WEAK_REFERENCE_TO, obj); } assert obj instanceof PythonAbstractObject; Object wr = readWeaklistNode.execute(inliningTarget, (PythonAbstractObject) obj, WEAKLIST, null); @@ -307,7 +307,7 @@ PReferenceType refType(Object cls, PythonAbstractNativeObject pythonObject, Obje @Bind PythonLanguage language, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, @Exclusive @Cached HiddenAttr.ReadNode readQueueNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object actualCallback = callback instanceof PNone ? null : callback; Object clazz = getClassNode.execute(inliningTarget, pythonObject); @@ -341,14 +341,14 @@ PReferenceType refType(Object cls, PythonAbstractNativeObject pythonObject, Obje CApiTransitions.addNativeWeakRef(getContext(), pythonObject); return PFactory.createReferenceType(language, cls, getInstanceShape.execute(cls), pythonObject, actualCallback, getWeakReferenceQueue(inliningTarget, readQueueNode)); } else { - return refType(cls, pythonObject, actualCallback, raiseNode.get(inliningTarget)); + return refType(cls, pythonObject, actualCallback, raiseNode); } } @Fallback static PReferenceType refType(@SuppressWarnings("unused") Object cls, Object object, @SuppressWarnings("unused") Object callback, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CREATE_WEAK_REFERENCE_TO, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_WEAK_REFERENCE_TO, object); } @SuppressWarnings("unchecked") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java index b67a26f384..a5cd3e7ba7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java @@ -108,26 +108,27 @@ protected Object doIt(VirtualFrame frame, Object self, Object[] args, PKeyword[] @Cached PyObjectLookupAttr lookupAttrNode, @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @Cached PyObjectSetAttrO setAttrNode, - @Cached TruffleString.EqualNode equalNode) { + @Cached TruffleString.EqualNode equalNode, + @Cached PRaiseNode raiseNode) { Object fieldsObj = lookupAttrNode.execute(frame, inliningTarget, self, T__FIELDS); Object[] fields; if (fieldsObj == PNone.NO_VALUE) { fields = EMPTY_OBJECT_ARRAY; } else { if (!(fieldsObj instanceof PSequence)) { - throw raise(TypeError, IS_NOT_A_SEQUENCE, fieldsObj); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A_SEQUENCE, fieldsObj); } fields = getObjectArrayNode.execute(inliningTarget, fieldsObj); } if (fields.length < args.length) { - throw raise(TypeError, S_CONSTRUCTOR_TAKES_AT_MOST_D_POSITIONAL_ARGUMENT_S, self, fields.length, fields.length == 1 ? "" : "s"); + throw raiseNode.raise(inliningTarget, TypeError, S_CONSTRUCTOR_TAKES_AT_MOST_D_POSITIONAL_ARGUMENT_S, self, fields.length, fields.length == 1 ? "" : "s"); } for (int i = 0; i < args.length; ++i) { setAttrNode.execute(frame, inliningTarget, self, fields[i], args[i]); } for (PKeyword kwArg : kwArgs) { if (contains(fields, args.length, kwArg.getName(), equalNode)) { - throw raise(TypeError, P_GOT_MULTIPLE_VALUES_FOR_ARGUMENT_S, self, kwArg.getName()); + throw raiseNode.raise(inliningTarget, TypeError, P_GOT_MULTIPLE_VALUES_FOR_ARGUMENT_S, self, kwArg.getName()); } setAttrNode.execute(frame, inliningTarget, self, kwArg.getName(), kwArg.getValue()); } @@ -167,8 +168,8 @@ static Object dict(PythonObject self, PDict dict, @Specialization(guards = {"!isNoValue(d)", "!isDict(d)"}) @SuppressWarnings("unused") static Object setDict(PythonObject self, Object d, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, d); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, d); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java index 841d0e853d..ed66e9f5e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstModuleBuiltins.java @@ -63,6 +63,7 @@ import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; import com.oracle.graal.python.builtins.objects.type.PythonClass; import com.oracle.graal.python.builtins.objects.type.TypeNodes; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.pegparser.InputType; @@ -75,6 +76,7 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(defineModule = AstModuleBuiltins.J__AST, isEager = true) @@ -136,7 +138,7 @@ public static Object sst2Obj(PythonContext context, ModTy mod) { } @TruffleBoundary - public static ModTy obj2sst(PythonContext context, Object obj, InputType type) { + public static ModTy obj2sst(Node node, PythonContext context, Object obj, InputType type) { AstState state = getAstState(context); PythonClass expectedClass; switch (type) { @@ -153,11 +155,12 @@ public static ModTy obj2sst(PythonContext context, Object obj, InputType type) { throw shouldNotReachHere(); } if (!Obj2SstBase.isInstanceOf(obj, expectedClass)) { - throw Obj2SstBase.raiseTypeError(EXPECTED_S_NODE_GOT_P, expectedClass.getName(), obj); + Object[] arguments = new Object[]{expectedClass.getName(), obj}; + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.TypeError, EXPECTED_S_NODE_GOT_P, arguments); } - ModTy mod = new Obj2Sst(state).obj2ModTy(obj); - Validator.validateMod(mod); + ModTy mod = new Obj2Sst(node, state).obj2ModTy(obj); + Validator.validateMod(node, mod); return mod; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java index 243cd7c5e8..1166363cdf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2Sst.java @@ -45,6 +45,7 @@ // Generated from Python.asdl by main_asdl_gen.py package com.oracle.graal.python.builtins.modules.ast; +import com.oracle.truffle.api.nodes.Node; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.pegparser.sst.ConstantValue; import com.oracle.graal.python.pegparser.sst.ModTy; @@ -69,8 +70,8 @@ final class Obj2Sst extends Obj2SstBase { - Obj2Sst(AstState state) { - super(state); + Obj2Sst(Node node, AstState state) { + super(node, state); } ModTy obj2ModTy(Object obj) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java index 9f41864f94..9d8ca154cb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -91,13 +91,16 @@ import com.oracle.graal.python.pegparser.sst.ConstantValue; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; abstract class Obj2SstBase { final AstState state; + private final Node node; - protected Obj2SstBase(AstState state) { + protected Obj2SstBase(Node node, AstState state) { + this.node = node; this.state = state; } @@ -305,7 +308,7 @@ ConstantValue obj2ConstantValue(Object obj) { throw raiseTypeError(ErrorMessages.GOT_AN_INVALID_TYPE_IN_CONSTANT, obj); } - static PException unexpectedNodeType(TruffleString expected, Object obj) { + protected PException unexpectedNodeType(TruffleString expected, Object obj) { throw raiseTypeError(EXPECTED_SOME_SORT_OF_S_BUT_GOT_S, expected, repr(obj)); } @@ -317,15 +320,15 @@ private static TruffleString repr(Object o) { return PyObjectReprAsTruffleStringNode.executeUncached(o); } - private static PException raise(PythonBuiltinClassType type, TruffleString format, Object... arguments) { - throw PRaiseNode.getUncached().raise(type, format, arguments); + private PException raise(PythonBuiltinClassType type, TruffleString format, Object... arguments) { + throw PRaiseNode.raiseStatic(node, type, format, arguments); } - static PException raiseTypeError(TruffleString format, Object... arguments) { + protected PException raiseTypeError(TruffleString format, Object... arguments) { throw raise(PythonBuiltinClassType.TypeError, format, arguments); } - private static PException raiseValueError(TruffleString format, Object... arguments) { + protected PException raiseValueError(TruffleString format, Object... arguments) { throw raise(PythonBuiltinClassType.ValueError, format, arguments); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Validator.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Validator.java index 0c6265010d..c6259fbf05 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Validator.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Validator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -93,13 +93,17 @@ import com.oracle.graal.python.pegparser.sst.UnaryOpTy; import com.oracle.graal.python.pegparser.sst.WithItemTy; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; final class Validator implements SSTreeVisitor { private static final String[] FORBIDDEN_NAMES = {"None", "True", "False"}; - private Validator() { + private final Node node; + + private Validator(Node node) { + this.node = node; } /*- @@ -107,9 +111,9 @@ private Validator() { */ // Equivalent of _PyAST_Validate - entry point of the validation - static void validateMod(ModTy mod) { + static void validateMod(Node node, ModTy mod) { // TODO recursion checks - mod.accept(new Validator()); + mod.accept(new Validator(node)); } @Override @@ -754,7 +758,7 @@ private void validatePatternMatchValue(ExprTy expr) { throw raiseValueError(ErrorMessages.PATTERNS_MAY_ONLY_MATCH_LITERALS_AND_ATTRIBUTE_LOOKUPS); } - private static void validateCapture(String name) { + private void validateCapture(String name) { if (name.equals("_")) { throw raiseValueError(ErrorMessages.CANT_CAPTURE_NAME_UNDERSCORE_IN_PATTERNS); } @@ -1023,7 +1027,7 @@ private void validateAssignList(ExprTy[] targets, ExprContextTy ctx) { } // Equivalent of _validate_nonempty_seq - private static void validateNonEmptySeq(Object[] seq, TruffleString what, TruffleString owner) { + private void validateNonEmptySeq(Object[] seq, TruffleString what, TruffleString owner) { if (seqLen(seq) == 0) { throw raiseValueError(ErrorMessages.EMPTY_S_ON_S, what, owner); } @@ -1049,7 +1053,7 @@ private static int seqLen(Object[] seq) { } // Equivalent of validate_name - private static void validateName(String id) { + private void validateName(String id) { for (String f : FORBIDDEN_NAMES) { if (f.equals(id)) { throw raiseValueError(ErrorMessages.IDENTIFIER_FIELD_CANT_REPRESENT_S_CONSTANT, f); @@ -1062,11 +1066,11 @@ private void validateConstant(@SuppressWarnings("unused") ConstantValue value) { // Already done in Obj2SstBase#obj2ConstantValue() } - private static PException raiseValueError(TruffleString format, Object... args) { - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.ValueError, format, args); + private PException raiseValueError(TruffleString format, Object... args) { + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, format, args); } - private static PException raiseTypeError(TruffleString format, Object... args) { - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.TypeError, format, args); + private PException raiseTypeError(TruffleString format, Object... args) { + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.TypeError, format, args); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java index 28865aeb0d..203cb0c65e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2CompressorBuiltins.java @@ -105,14 +105,14 @@ PNone init(BZ2Object.BZ2Compressor self, int compresslevel, @Cached NativeLibrary.InvokeNativeFunction createStream, @Cached NativeLibrary.InvokeNativeFunction compressInit, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { gil.release(true); try { NFIBz2Support bz2Support = PythonContext.get(this).getNFIBz2Support(); Object bzst = bz2Support.createStream(createStream); int err = bz2Support.compressInit(bzst, compresslevel, compressInit); if (err != BZ_OK) { - errorHandling(err, raiseNode.get(inliningTarget)); + errorHandling(inliningTarget, err, raiseNode); } self.init(bzst, bz2Support); return PNone.NONE; @@ -124,8 +124,8 @@ PNone init(BZ2Object.BZ2Compressor self, int compresslevel, @SuppressWarnings("unused") @Fallback static Object err(Object self, Object compresslevel, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, COMPRESSLEVEL_MUST_BE_BETWEEN_1_AND_9); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, COMPRESSLEVEL_MUST_BE_BETWEEN_1_AND_9); } } @@ -158,8 +158,8 @@ static PBytes doNativeObject(VirtualFrame frame, BZ2Object.BZ2Compressor self, O @SuppressWarnings("unused") @Specialization(guards = "self.isFlushed()") static PNone error(BZ2Object.BZ2Compressor self, Object data, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, COMPRESSOR_HAS_BEEN_FLUSHED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, COMPRESSOR_HAS_BEEN_FLUSHED); } } @@ -179,8 +179,8 @@ static PBytes doit(BZ2Object.BZ2Compressor self, @SuppressWarnings("unused") @Specialization(guards = "self.isFlushed()") static PNone error(BZ2Object.BZ2Compressor self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, REPEATED_CALL_TO_FLUSH); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, REPEATED_CALL_TO_FLUSH); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java index e33951bfd7..8fba6e2f51 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/BZ2DecompressorBuiltins.java @@ -93,12 +93,12 @@ static PNone init(BZ2Object.BZ2Decompressor self, @Bind("this") Node inliningTarget, @Cached NativeLibrary.InvokeNativeFunction createStream, @Cached NativeLibrary.InvokeNativeFunction compressInit, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { NFIBz2Support bz2Support = PythonContext.get(inliningTarget).getNFIBz2Support(); Object bzst = bz2Support.createStream(createStream); int err = bz2Support.decompressInit(bzst, compressInit); if (err != BZ_OK) { - errorHandling(err, raiseNode.get(inliningTarget)); + errorHandling(inliningTarget, err, raiseNode); } self.init(bzst, bz2Support); return PNone.NONE; @@ -144,8 +144,8 @@ static PBytes doNativeObject(VirtualFrame frame, BZ2Object.BZ2Decompressor self, @SuppressWarnings("unused") @Specialization(guards = {"self.isEOF()"}) static Object err(BZ2Object.BZ2Decompressor self, PBytesLike data, int maxLength, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(EOFError, END_OF_STREAM_ALREADY_REACHED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, EOFError, END_OF_STREAM_ALREADY_REACHED); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/Bz2Nodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/Bz2Nodes.java index dcc065e578..8b102a71c6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/Bz2Nodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/bz2/Bz2Nodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -112,12 +112,12 @@ static byte[] nativeCompress(BZ2Object.BZ2Compressor self, PythonContext context @Bind("this") Node inliningTarget, @Cached NativeLibrary.InvokeNativeFunction compress, @Cached GetOutputNativeBufferNode getBuffer, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { NFIBz2Support bz2Support = context.getNFIBz2Support(); Object inGuest = context.getEnv().asGuestValue(bytes); int err = bz2Support.compress(self.getBzs(), inGuest, len, action, INITIAL_BUFFER_SIZE, compress); if (err != BZ_OK) { - errorHandling(err, raiseNode.get(inliningTarget)); + errorHandling(inliningTarget, err, raiseNode); } return getBuffer.execute(inliningTarget, self.getBzs(), context); } @@ -236,7 +236,7 @@ static byte[] nativeInternalDecompress(BZ2Object.BZ2Decompressor self, int maxLe @Cached GetOutputNativeBufferNode getBuffer, @Cached InlinedConditionProfile errProfile, @Cached InlinedBranchProfile ofProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); NFIBz2Support bz2Support = context.getNFIBz2Support(); Object inGuest = self.getNextInGuest(context); @@ -249,12 +249,12 @@ static byte[] nativeInternalDecompress(BZ2Object.BZ2Decompressor self, int maxLe self.setBzsAvailInReal(bzsAvailInReal); } catch (OverflowException of) { ofProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); + throw raiseNode.raise(inliningTarget, SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); } if (err == BZ_STREAM_END) { self.setEOF(); } else if (errProfile.profile(inliningTarget, err != BZ_OK)) { - errorHandling(err, raiseNode.get(inliningTarget)); + errorHandling(inliningTarget, err, raiseNode); } return getBuffer.execute(inliningTarget, self.getBzs(), context); } @@ -271,14 +271,14 @@ static byte[] getBuffer(Node inliningTarget, Object bzst, PythonContext context, @Cached(inline = false) NativeLibrary.InvokeNativeFunction getBufferSize, @Cached(inline = false) NativeLibrary.InvokeNativeFunction getBuffer, @Cached InlinedBranchProfile ofProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { NFIBz2Support bz2Support = context.getNFIBz2Support(); int size; try { size = PInt.intValueExact(bz2Support.getOutputBufferSize(bzst, getBufferSize)); } catch (OverflowException of) { ofProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); + throw raiseNode.raise(inliningTarget, SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); } if (size == 0) { return PythonUtils.EMPTY_BYTE_ARRAY; @@ -291,25 +291,25 @@ static byte[] getBuffer(Node inliningTarget, Object bzst, PythonContext context, } } - protected static void errorHandling(int bzerror, PRaiseNode raise) { + protected static void errorHandling(Node inliningTarget, int bzerror, PRaiseNode raise) { switch (bzerror) { case BZ_PARAM_ERROR: - throw raise.raise(ValueError, INVALID_PARAMETERS_PASSED_TO_LIBBZIP2); + throw raise.raise(inliningTarget, ValueError, INVALID_PARAMETERS_PASSED_TO_LIBBZIP2); case BZ_MEM_ERROR: - throw raise.raise(MemoryError); + throw raise.raise(inliningTarget, MemoryError); case BZ_DATA_ERROR: case BZ_DATA_ERROR_MAGIC: - throw raise.raise(OSError, INVALID_DATA_STREAM); + throw raise.raise(inliningTarget, OSError, INVALID_DATA_STREAM); case BZ_IO_ERROR: - throw raise.raise(OSError, UNKNOWN_IO_ERROR); + throw raise.raise(inliningTarget, OSError, UNKNOWN_IO_ERROR); case BZ_UNEXPECTED_EOF: - throw raise.raise(EOFError, COMPRESSED_FILE_ENDED_BEFORE_EOS); + throw raise.raise(inliningTarget, EOFError, COMPRESSED_FILE_ENDED_BEFORE_EOS); case BZ_SEQUENCE_ERROR: - throw raise.raise(RuntimeError, INVALID_SEQUENCE_OF_COMMANDS); + throw raise.raise(inliningTarget, RuntimeError, INVALID_SEQUENCE_OF_COMMANDS); case BZ_CONFIG_ERROR: - throw raise.raise(ValueError, LIBBZIP2_WAS_NOT_COMPILED_CORRECTLY); + throw raise.raise(inliningTarget, ValueError, LIBBZIP2_WAS_NOT_COMPILED_CORRECTLY); default: - throw raise.raise(OSError, UNRECOGNIZED_ERROR_FROM_LIBBZIP2_D, bzerror); + throw raise.raise(inliningTarget, OSError, UNRECOGNIZED_ERROR_FROM_LIBBZIP2_D, bzerror); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 05d971d18c..2dfa351af1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -40,7 +40,6 @@ */ package com.oracle.graal.python.builtins.modules.cext; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiCallPath.Direct; @@ -140,6 +139,7 @@ import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.TruffleLogger; import com.oracle.truffle.api.dsl.Bind; @@ -187,7 +187,7 @@ abstract static class PyNumber_Index extends CApiUnaryBuiltinNode { static Object index(Object obj, @Bind("this") Node inliningTarget, @Cached PyNumberIndexNode indexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, obj, raiseNode); return indexNode.execute(null, inliningTarget, obj); } @@ -261,8 +261,8 @@ static Object toBase(Object n, @SuppressWarnings("unused") int base, @Specialization(guards = "!checkBase(base)") static Object toBase(@SuppressWarnings("unused") Object n, @SuppressWarnings("unused") int base, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BASE_MUST_BE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BASE_MUST_BE); } protected boolean checkBase(int base) { @@ -493,7 +493,7 @@ static Object setItem(Object obj, long key, Object value, @Bind("this") Node inliningTarget, @Cached PySequenceSetItemNode setItemNode) { if ((int) key != key) { - throw PRaiseNode.raiseUncached(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, key); + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, key); } setItemNode.execute(null, inliningTarget, obj, (int) key, value); return 0; @@ -517,10 +517,9 @@ static Object getSlice(Object obj, long iLow, long iHigh, @Specialization(guards = "!checkNode.execute(inliningTarget, obj)", limit = "1") static Object getSlice(Object obj, @SuppressWarnings("unused") Object key, @SuppressWarnings("unused") Object value, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_IS_UNSLICEABLE, obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_IS_UNSLICEABLE, obj); } } @@ -554,10 +553,9 @@ static Object repeat(Object obj, long n, @Specialization(guards = "!checkNode.execute(inliningTarget, obj)", limit = "1") static Object repeat(Object obj, @SuppressWarnings("unused") Object n, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANT_BE_REPEATED, obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANT_BE_REPEATED, obj); } } @@ -590,10 +588,9 @@ static Object concat(Object s1, Object s2, @Specialization(guards = "!checkNode.execute(inliningTarget, s1)", limit = "1") static Object concat(Object s1, @SuppressWarnings("unused") Object s2, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, s1); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, s1); } } @@ -604,7 +601,7 @@ static Object run(Object o, long i, @Bind("this") Node inliningTarget, @Cached PySequenceDelItemNode delItemNode) { if ((int) i != i) { - throw PRaiseNode.raiseUncached(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, i); + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, i); } delItemNode.execute(null, inliningTarget, o, (int) i); return 0; @@ -618,7 +615,7 @@ static Object doManaged(Object delegate, long position, @Bind("this") Node inliningTarget, @Cached PySequenceGetItemNode getItemNode) { if ((int) position != position) { - throw PRaiseNode.raiseUncached(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, position); + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, position); } return getItemNode.execute(null, delegate, (int) position); } @@ -643,14 +640,14 @@ static int setSlice(Object sequence, Object iLow, Object iHigh, Object s, @Cached GetObjectSlotsNode getSlotsNode, @Cached CallSlotMpAssSubscriptNode callSetItem, @Cached PySliceNew sliceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getSlotsNode.execute(inliningTarget, sequence); if (slots.mp_ass_subscript() != null) { PSlice slice = sliceNode.execute(inliningTarget, iLow, iHigh, PNone.NONE); callSetItem.execute(null, inliningTarget, slots.mp_ass_subscript(), sequence, slice, s); return 0; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.P_OBJECT_DOESNT_SUPPORT_SLICE_ASSIGNMENT, sequence); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.P_OBJECT_DOESNT_SUPPORT_SLICE_ASSIGNMENT, sequence); } } } @@ -663,14 +660,14 @@ static int setSlice(Object sequence, Object iLow, Object iHigh, @Cached GetObjectSlotsNode getSlotsNode, @Cached CallSlotMpAssSubscriptNode callSetItem, @Cached PySliceNew sliceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getSlotsNode.execute(inliningTarget, sequence); if (slots.mp_ass_subscript() != null) { PSlice slice = sliceNode.execute(inliningTarget, iLow, iHigh, PNone.NONE); callSetItem.execute(null, inliningTarget, slots.mp_ass_subscript(), sequence, slice, PNone.NO_VALUE); return 0; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.P_OBJECT_DOESNT_SUPPORT_SLICE_DELETION, sequence); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.P_OBJECT_DOESNT_SUPPORT_SLICE_DELETION, sequence); } } } @@ -803,7 +800,7 @@ static Object values(Object obj, @Cached PyObjectGetAttr getAttrNode, @Cached CallNode callNode, @Shared @Cached ConstructListNode listNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, obj, raiseNode); Object attr = getAttrNode.execute(inliningTarget, obj, T_VALUES); return listNode.execute(null, callNode.executeWithoutFrame(attr)); @@ -822,12 +819,12 @@ static int doMapping(Object obj, @Cached com.oracle.graal.python.lib.PyObjectSizeNode sizeNode, @Cached IsSameTypeNode isSameType, @Cached GetClassNode getClassNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object cls = getClassNode.execute(inliningTarget, obj); if (isSameType.execute(inliningTarget, cls, PythonBuiltinClassType.PSet) || isSameType.execute(inliningTarget, cls, PythonBuiltinClassType.PFrozenSet) || isSameType.execute(inliningTarget, cls, PythonBuiltinClassType.PDeque)) { - throw raiseNode.get(inliningTarget).raise(TypeError, OBJ_ISNT_MAPPING, obj); + throw raiseNode.raise(inliningTarget, TypeError, OBJ_ISNT_MAPPING, obj); } else { return sizeNode.execute(null, inliningTarget, obj); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java index b44f6287df..a651521214 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java @@ -323,7 +323,7 @@ public static PException checkThrowableBeforeNative(Throwable t, String where1, out.println("ERROR: Native API called without Truffle context. This can happen when called from C-level atexit, C++ global destructor or an unregistered native thread"); } out.flush(); - throw PRaiseNode.raiseUncached(null, SystemError, ErrorMessages.INTERNAL_EXCEPTION_OCCURED); + throw PRaiseNode.raiseStatic(null, SystemError, ErrorMessages.INTERNAL_EXCEPTION_OCCURED); } public abstract static class CApiBuiltinNode extends PNodeWithContext { @@ -374,7 +374,7 @@ protected final CApiContext getCApiContext() { protected final PException badInternalCall(String argName) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.S_S_BAD_ARG_TO_INTERNAL_FUNC, getName(), argName); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.S_S_BAD_ARG_TO_INTERNAL_FUNC, getName(), argName); } @NonIdempotent @@ -394,25 +394,25 @@ private String getName() { @TruffleBoundary protected PException raiseFallback(Object obj, PythonBuiltinClassType type) { if (obj == PNone.NO_VALUE) { - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_S, getName()); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_S, getName()); } if (IsSubtypeNode.getUncached().execute(GetClassNode.executeUncached(obj), type)) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, type.getName()); + throw PRaiseNode.raiseStatic(this, NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, type.getName()); } else { - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.EXPECTED_S_NOT_P, type.getName(), obj); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.EXPECTED_S_NOT_P, type.getName(), obj); } } @TruffleBoundary protected PException raiseFallback(Object obj, PythonBuiltinClassType type1, PythonBuiltinClassType type2) { if (obj == PNone.NO_VALUE) { - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_S, getName()); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC_S, getName()); } Object objType = GetClassNode.executeUncached(obj); if (IsSubtypeNode.getUncached().execute(objType, type1) || IsSubtypeNode.getUncached().execute(objType, type2)) { - throw PRaiseNode.raiseUncached(this, NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, type1.getName()); + throw PRaiseNode.raiseStatic(this, NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, type1.getName()); } else { - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.EXPECTED_S_NOT_P, type1.getName(), obj); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.EXPECTED_S_NOT_P, type1.getName(), obj); } } @@ -425,18 +425,18 @@ protected final int castToInt(long elementSize) { return (int) elementSize; } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, INDEX_OUT_OF_RANGE); + throw PRaiseNode.raiseStatic(this, SystemError, INDEX_OUT_OF_RANGE); } - protected static void checkNonNullArg(Node inliningTarget, Object obj, PRaiseNode.Lazy raiseNode) { + protected static void checkNonNullArg(Node inliningTarget, Object obj, PRaiseNode raiseNode) { if (obj == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.NULL_ARG_INTERNAL); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NULL_ARG_INTERNAL); } } - protected static void checkNonNullArg(Node inliningTarget, Object obj1, Object obj2, PRaiseNode.Lazy raiseNode) { + protected static void checkNonNullArg(Node inliningTarget, Object obj1, Object obj2, PRaiseNode raiseNode) { if (obj1 == PNone.NO_VALUE || obj2 == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.NULL_ARG_INTERNAL); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NULL_ARG_INTERNAL); } } } @@ -992,7 +992,7 @@ abstract static class PyTruffle_Type extends CApiUnaryBuiltinNode { static Object doI(TruffleString typeName, @Bind("this") Node inliningTarget, @Cached TruffleString.EqualNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Python3Core core = PythonContext.get(inliningTarget); for (PythonBuiltinClassType type : PythonBuiltinClassType.VALUES) { if (eqNode.execute(type.getName(), typeName, TS_ENCODING)) { @@ -1005,7 +1005,7 @@ static Object doI(TruffleString typeName, return attribute; } } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.KeyError, ErrorMessages.APOSTROPHE_S, typeName); + throw raiseNode.raise(inliningTarget, PythonErrorType.KeyError, ErrorMessages.APOSTROPHE_S, typeName); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextByteArrayBuiltins.java index 8cfbb409bb..fbe4cc493a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextByteArrayBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -78,17 +78,17 @@ static Object doNative(PythonAbstractNativeObject obj, @Cached GetPythonObjectClassNode getClassNode, @Cached IsSubtypeNode isSubtypeNode, @Cached CStructAccess.GetElementPtrNode getArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isSubtypeNode.execute(getClassNode.execute(inliningTarget, obj), PythonBuiltinClassType.PByteArray)) { return getArray.getElementPtr(obj.getPtr(), CFields.PyByteArrayObject__ob_start); } - return doError(obj, raiseNode.get(inliningTarget)); + return doError(obj, raiseNode); } @Fallback static Object doError(Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.EXPECTED_S_P_FOUND, "bytearray", obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.EXPECTED_S_P_FOUND, "bytearray", obj); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java index f3d47b9596..b89d3af482 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java @@ -142,7 +142,7 @@ static long doOther(PythonAbstractNativeObject obj, @TruffleBoundary static long fallback(Object obj, @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, obj); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, obj); } } @@ -184,7 +184,7 @@ static Object fromObject(Object obj, @Cached IsSubtypeNode isSubtypeNode, @Cached BytesNode bytesNode, @Cached PyObjectLookupAttr lookupAttrNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (PGuards.isPBytes(obj)) { return obj; } else { @@ -194,7 +194,7 @@ static Object fromObject(Object obj, } else if (isAcceptedSubtype(inliningTarget, obj, klass, isSubtypeNode, lookupAttrNode)) { return bytesNode.execute(null, PythonBuiltinClassType.PBytes, obj, PNone.NO_VALUE, PNone.NO_VALUE); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_CONVERT_P_OBJ_TO_S, obj, "bytes"); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_CONVERT_P_OBJ_TO_S, obj, "bytes"); } } } @@ -235,13 +235,13 @@ static Object doNativePointer(Object nativePointer, long size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Exclusive @Cached GetByteArrayNode getByteArrayNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, nativePointer, size)); } catch (InteropException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); } } } @@ -268,13 +268,13 @@ static Object doNativePointer(Object nativePointer, long size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Exclusive @Cached GetByteArrayNode getByteArrayNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return PFactory.createByteArray(language, getByteArrayNode.execute(inliningTarget, nativePointer, size)); } catch (InteropException e) { - return raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + return raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { - return raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); + return raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); } } } @@ -303,8 +303,8 @@ static int resize(PBytesLike self, long newSizeL, @Fallback static int fallback(Object self, @SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, ErrorMessages.EXPECTED_S_NOT_P, "a bytes object", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.EXPECTED_S_NOT_P, "a bytes object", self); } } @@ -327,11 +327,11 @@ static PBytes doLong(long size, static PBytes doLongOvf(long size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return doInt(PInt.intValueExact(size), language); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); } } @@ -345,11 +345,11 @@ static PBytes doPInt(PInt size, static PBytes doPIntOvf(PInt size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return doInt(size.intValueExact(), language); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); } } } @@ -373,11 +373,11 @@ static PByteArray doLong(long size, static PByteArray doLongOvf(long size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return doInt(PInt.intValueExact(size), language); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); } } @@ -391,11 +391,11 @@ static PByteArray doPInt(PInt size, static PByteArray doPIntOvf(PInt size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return doInt(size.intValueExact(), language); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(IndexError, size); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); } } } @@ -436,17 +436,17 @@ static Object doNative(PythonAbstractNativeObject obj, @Cached GetPythonObjectClassNode getClassNode, @Cached IsSubtypeNode isSubtypeNode, @Cached CStructAccess.GetElementPtrNode getArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isSubtypeNode.execute(getClassNode.execute(inliningTarget, obj), PythonBuiltinClassType.PBytes)) { return getArray.getElementPtr(obj.getPtr(), CFields.PyBytesObject__ob_sval); } - return doError(obj, raiseNode.get(inliningTarget)); + return doError(obj, raiseNode); } @Fallback static Object doError(Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.EXPECTED_S_P_FOUND, "bytes", obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.EXPECTED_S_P_FOUND, "bytes", obj); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java index 410ef50f24..acf80b9b04 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCapsuleBuiltins.java @@ -102,9 +102,9 @@ public abstract static class PyCapsuleNewNode extends Node { static PyCapsule doGeneric(Node inliningTarget, Object pointer, Object namePtr, Object destructor, @CachedLibrary(limit = "1") InteropLibrary interopLibrary, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (interopLibrary.isNull(pointer)) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT); } PyCapsule capsule = PFactory.createCapsuleNativeName(language, pointer, interopLibrary.isNull(namePtr) ? null : namePtr); if (!interopLibrary.isNull(destructor)) { @@ -155,20 +155,19 @@ public abstract static class PyCapsuleGetPointerNode extends Node { @Specialization static Object doCapsule(Node inliningTarget, PyCapsule o, Object name, @Cached PyCapsuleNameMatchesNode nameMatchesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); } if (!nameMatchesNode.execute(inliningTarget, name, o.getNamePtr())) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INCORRECT_NAME, "PyCapsule_GetPointer"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INCORRECT_NAME, "PyCapsule_GetPointer"); } return o.getPointer(); } @Fallback - static Object doError(Node inliningTarget, @SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); + static Object doError(Node inliningTarget, @SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); } } @@ -178,17 +177,17 @@ abstract static class PyCapsule_GetName extends CApiUnaryBuiltinNode { @Specialization Object get(PyCapsule o, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetName"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetName"); } return o.getNamePtr() == null ? getNULL() : o.getNamePtr(); } @Fallback static Object doit(@SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetName"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetName"); } } @@ -197,9 +196,9 @@ abstract static class PyCapsule_GetDestructor extends CApiUnaryBuiltinNode { @Specialization Object doCapsule(PyCapsule o, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetDestructor"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetDestructor"); } if (o.getDestructor() == null) { return getNULL(); @@ -209,8 +208,8 @@ Object doCapsule(PyCapsule o, @Fallback static Object doError(@SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); } } @@ -219,9 +218,9 @@ abstract static class PyCapsule_GetContext extends CApiUnaryBuiltinNode { @Specialization Object doCapsule(PyCapsule o, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetContext"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetContext"); } if (o.getContext() == null) { return getNULL(); @@ -231,8 +230,8 @@ Object doCapsule(PyCapsule o, @Fallback static Object doError(@SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_GetPointer"); } } @@ -242,13 +241,13 @@ abstract static class PyCapsule_SetPointer extends CApiBinaryBuiltinNode { static int doCapsule(PyCapsule o, Object pointer, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "2") InteropLibrary interopLibrary, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (interopLibrary.isNull(pointer)) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_NULL_POINTER, "PyCapsule_SetPointer"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_NULL_POINTER, "PyCapsule_SetPointer"); } if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetPointer"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetPointer"); } o.setPointer(pointer); @@ -257,8 +256,8 @@ static int doCapsule(PyCapsule o, Object pointer, @Fallback static Object doError(@SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetPointer"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetPointer"); } } @@ -268,9 +267,9 @@ abstract static class PyCapsule_SetName extends CApiBinaryBuiltinNode { static int set(PyCapsule o, Object namePtr, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "1") InteropLibrary lib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetName"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetName"); } o.setNamePtr(lib.isNull(namePtr) ? null : namePtr); return 0; @@ -278,8 +277,8 @@ static int set(PyCapsule o, Object namePtr, @Fallback static Object doError(@SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetName"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetName"); } } @@ -289,9 +288,9 @@ abstract static class PyCapsule_SetDestructor extends CApiBinaryBuiltinNode { static int doCapsule(PyCapsule o, Object destructor, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "1") InteropLibrary lib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetDestructor"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetDestructor"); } o.registerDestructor(lib.isNull(destructor) ? null : destructor); return 0; @@ -299,8 +298,8 @@ static int doCapsule(PyCapsule o, Object destructor, @Fallback static Object doError(@SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetDestructor"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetDestructor"); } } @@ -309,9 +308,9 @@ abstract static class PyCapsule_SetContext extends CApiBinaryBuiltinNode { @Specialization static int doCapsule(PyCapsule o, Object context, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (o.getPointer() == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetContext"); + throw raiseNode.raise(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetContext"); } o.setContext(context); return 0; @@ -319,8 +318,8 @@ static int doCapsule(PyCapsule o, Object context, @Fallback static Object doError(@SuppressWarnings("unused") Object o, @SuppressWarnings("unused") Object name, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetContext"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CALLED_WITH_INVALID_PY_CAPSULE_OBJECT, "PyCapsule_SetContext"); } } @@ -335,7 +334,7 @@ static Object doGeneric(Object namePtr, @SuppressWarnings("unused") int noBlock, @Cached TruffleString.IndexOfStringNode indexOfStringNode, @Cached TruffleString.SubstringNode substringNode, @Cached ReadAttributeFromObjectNode getAttrNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString name = (TruffleString) charPtrToPythonNode.execute(namePtr); TruffleString trace = name; Object object = null; @@ -361,7 +360,7 @@ static Object doGeneric(Object namePtr, @SuppressWarnings("unused") int noBlock, if (capsule != null && PyCapsule_IsValid.doCapsule(capsule, namePtr, inliningTarget, nameMatchesNode) == 1) { return capsule.getPointer(); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, PY_CAPSULE_IMPORT_S_IS_NOT_VALID, name); + throw raiseNode.raise(inliningTarget, AttributeError, PY_CAPSULE_IMPORT_S_IS_NOT_VALID, name); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java index a7a603d441..d542cf7d3b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextClassBuiltins.java @@ -64,7 +64,7 @@ abstract static class PyInstanceMethod_New extends CApiUnaryBuiltinNode { static Object staticmethod(Object func, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, func, raiseNode); PDecoratedMethod res = PFactory.createInstancemethod(language); res.setCallable(func); @@ -78,7 +78,7 @@ abstract static class PyMethod_New extends CApiBinaryBuiltinNode { static Object methodNew(Object func, Object self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, func, self, raiseNode); // Note: CPython also constructs the object directly, without running the constructor or // checking the inputs diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java index cf805f5aca..de47d11bf8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextComplexBuiltins.java @@ -123,7 +123,7 @@ static Object asDouble(Object obj, @Cached CallNode callNode, @Cached GetClassNode getClassNode, @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString name; if (isComplexSubtypeProfile.profile(inliningTarget, isComplexSubtype(inliningTarget, obj, getClassNode, isSubtypeNode))) { name = T_REAL; @@ -133,7 +133,7 @@ static Object asDouble(Object obj, try { return callNode.executeWithoutFrame(getAttr.execute(null, inliningTarget, obj, name)); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError); + throw raiseNode.raise(inliningTarget, TypeError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java index b131a49166..18842442b5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextContextBuiltins.java @@ -135,9 +135,9 @@ abstract static class PyContextVar_Set extends CApiBinaryBuiltinNode { static Object doGeneric(Object var, Object val, @Bind("this") Node inliningTarget, @Bind PythonContext pythonContext, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(var instanceof PContextVar pvar)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } PythonLanguage language = pythonContext.getLanguage(inliningTarget); PythonContext.PythonThreadState threadState = pythonContext.getThreadState(language); @@ -181,7 +181,7 @@ abstract static class PyContext_Enter extends CApiUnaryBuiltinNode { static Object doGeneric(PContextVarsContext context, @Bind("this") Node inliningTarget, @Bind PythonContext pythonContext, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext.PythonThreadState threadState = pythonContext.getThreadState(pythonContext.getLanguage(inliningTarget)); context.enter(inliningTarget, threadState, raiseNode); return 0; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java index 9edf930793..ca5ebd1eb0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextDictBuiltins.java @@ -330,9 +330,9 @@ static Object getItem(PDict dict, Object key, @Specialization(guards = "!isDict(obj)") static Object getItem(Object obj, @SuppressWarnings("unused") Object key, - @Cached StrNode strNode, - @Cached PRaiseNode raiseNode) { - return raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(null, obj), obj); + @Bind("this") Node inliningTarget, + @Cached StrNode strNode) { + return PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(null, obj), obj); } protected boolean isDict(Object obj) { @@ -394,10 +394,10 @@ static int setItem(PDict dict, Object key, Object value, Object givenHash, @Cached CastToJavaLongExactNode castToLong, @Cached SetItemNode setItemNode, @Cached InlinedBranchProfile wrongHashProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (hashNode.execute(null, inliningTarget, key) != castToLong.execute(inliningTarget, givenHash)) { wrongHashProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AssertionError, HASH_MISMATCH); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AssertionError, HASH_MISMATCH); } setItemNode.execute(null, inliningTarget, dict, key, value); return 0; @@ -524,10 +524,10 @@ static int merge(PDict a, Object b, @SuppressWarnings("unused") int override, @Cached PyObjectLookupAttr lookupKeys, @Cached PyObjectLookupAttr lookupAttr, @Shared @Cached CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // lookup "keys" to raise the right error: if (lookupKeys.execute(null, inliningTarget, b, T_KEYS) == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, OBJ_P_HAS_NO_ATTR_S, b, T_KEYS); + throw raiseNode.raise(inliningTarget, AttributeError, OBJ_P_HAS_NO_ATTR_S, b, T_KEYS); } Object updateCallable = lookupAttr.execute(null, inliningTarget, a, T_UPDATE); callNode.executeWithoutFrame(updateCallable, new Object[]{b}); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java index 407591b9e2..d1998526b6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java @@ -308,11 +308,10 @@ Object run(Object typ, PBaseException val, Object tb) { abstract static class _PyTruffleErr_CreateAndSetException extends CApiBinaryBuiltinNode { @Specialization(guards = "!isExceptionClass(inliningTarget, type, isTypeNode, isSubClassNode)") static Object create(Object type, @SuppressWarnings("unused") Object value, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached IsTypeNode isTypeNode, @SuppressWarnings("unused") @Shared @Cached IsSubClassNode isSubClassNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.SystemError, EXCEPTION_NOT_BASEEXCEPTION, new Object[]{type}); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, EXCEPTION_NOT_BASEEXCEPTION, new Object[]{type}); } @Specialization(guards = "isExceptionClass(inliningTarget, type, isTypeNode, isSubClassNode)") @@ -346,7 +345,7 @@ static Object newEx(TruffleString name, Object base, Object dict, @Cached InlinedBranchProfile notDotProfile, @Cached InlinedBranchProfile notModuleProfile, @Cached InlinedConditionProfile baseProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (base == PNone.NO_VALUE) { base = PythonErrorType.Exception; } @@ -357,7 +356,7 @@ static Object newEx(TruffleString name, Object base, Object dict, int dotIdx = indexOfCodepointNode.execute(name, '.', 0, length, TS_ENCODING); if (dotIdx < 0) { notDotProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(SystemError, MUST_BE_MODULE_CLASS, "PyErr_NewException", "name"); + throw raiseNode.raise(inliningTarget, SystemError, MUST_BE_MODULE_CLASS, "PyErr_NewException", "name"); } if (getItem.execute(null, inliningTarget, ((PDict) dict).getDictStorage(), base) == null) { notModuleProfile.enter(inliningTarget); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFileBuiltins.java index 4bf832f020..05633e8c4d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFileBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFileBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -71,7 +71,7 @@ static int writeStr(Object obj, Object f, int flags, @Cached ReprNode reprNode, @Cached PyObjectGetAttr getAttr, @Cached CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, obj, raiseNode); checkNonNullArg(inliningTarget, f, raiseNode); Object value; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFloatBuiltins.java index bdbaa62a28..9e083a04c5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextFloatBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -73,10 +73,10 @@ static double fromDouble(double d) { @Specialization(guards = "!isDouble(obj)") static Object fromDouble(Object obj, - @Cached StrNode strNode, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget, + @Cached StrNode strNode) { // cpython PyFloat_FromDouble takes only 'double' - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(null, obj), obj); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(null, obj), obj); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java index 4e3c3b4657..57603cb639 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextListBuiltins.java @@ -98,8 +98,8 @@ public final class PythonCextListBuiltins { abstract static class PyList_New extends CApiUnaryBuiltinNode { @Specialization(guards = "size < 0") static Object newListError(long size, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC_S, size); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC_S, size); } @SuppressWarnings("unused") @@ -132,11 +132,11 @@ static Object doPList(PList list, long key, @Cached ListGeneralizationNode generalizationNode, @Cached SetItemScalarNode setItemNode, @Cached GetItemScalarNode getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage sequenceStorage = list.getSequenceStorage(); // we must do a bounds-check but we must not normalize the index if (key < 0 || key >= sequenceStorage.length()) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.LIST_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.LIST_INDEX_OUT_OF_RANGE); } Object result = getItemNode.execute(inliningTarget, sequenceStorage, (int) key); Object promotedValue = promoteNode.execute(inliningTarget, result); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java index 168e515605..9552018377 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextLongBuiltins.java @@ -229,7 +229,7 @@ static Object doGeneric(Object object, int mode, long targetTypeSize, @Cached GetClassNode getClassNode, @Cached ConvertPIntToPrimitiveNode convertPIntToPrimitiveNode, @Cached CastToNativeLongNode castToNativeLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { /* * The 'mode' parameter is usually a constant since this function is primarily used @@ -237,7 +237,7 @@ static Object doGeneric(Object object, int mode, long targetTypeSize, * profile the value and even if it is not constant, it is profiled implicitly. */ if (requiredPInt(mode) && !isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } // the 'ConvertPIntToPrimitiveNode' uses 'AsNativePrimitive' which does coercion Object coerced = convertPIntToPrimitiveNode.execute(inliningTarget, object, signed(mode), PInt.intValueExact(targetTypeSize), exact(mode)); @@ -353,13 +353,13 @@ static long doPointer(long n) { long doPointer(PInt n, @Bind("this") Node inliningTarget, @Cached InlinedBranchProfile overflowProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { return n.longValueExact(); } catch (OverflowException e) { overflowProfile.enter(inliningTarget); try { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); } catch (PException pe) { ensureTransformExcNode().executeCached(pe); return 0; @@ -375,7 +375,7 @@ static Object doPointer(PythonNativeVoidPtr n) { @Fallback long doGeneric(Object n, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (asPrimitiveNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); asPrimitiveNode = insert(ConvertPIntToPrimitiveNodeGen.create()); @@ -384,7 +384,7 @@ long doGeneric(Object n, try { return asPrimitiveNode.executeLongCached(n, 0, Long.BYTES); } catch (UnexpectedResultException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); } } catch (PException e) { ensureTransformExcNode().executeCached(e); @@ -403,10 +403,10 @@ private TransformExceptionToNativeNode ensureTransformExcNode() { @CApiBuiltin(ret = Int, args = {PyLongObject, UNSIGNED_CHAR_PTR, SIZE_T, Int, Int}, call = Direct) abstract static class _PyLong_AsByteArray extends CApi5BuiltinNode { - private static void checkSign(Node inliningTarget, boolean negative, int isSigned, PRaiseNode.Lazy raiseNode) { + private static void checkSign(Node inliningTarget, boolean negative, int isSigned, PRaiseNode raiseNode) { if (negative) { if (isSigned == 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); } } } @@ -416,7 +416,7 @@ static Object get(int value, Object bytes, long n, int littleEndian, int isSigne @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile profile, @Shared @Cached CStructAccess.WriteByteNode write, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkSign(inliningTarget, value < 0, isSigned, raiseNode); byte[] array = IntBuiltins.ToBytesNode.fromLong(value, PythonUtils.toIntError(n), littleEndian == 0, isSigned != 0, inliningTarget, profile, raiseNode); write.writeByteArray(bytes, array); @@ -428,7 +428,7 @@ static Object get(long value, Object bytes, long n, int littleEndian, int isSign @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile profile, @Shared @Cached CStructAccess.WriteByteNode write, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkSign(inliningTarget, value < 0, isSigned, raiseNode); byte[] array = IntBuiltins.ToBytesNode.fromLong(value, PythonUtils.toIntError(n), littleEndian == 0, isSigned != 0, inliningTarget, profile, raiseNode); write.writeByteArray(bytes, array); @@ -440,7 +440,7 @@ static Object get(PInt value, Object bytes, long n, int littleEndian, int isSign @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile profile, @Shared @Cached CStructAccess.WriteByteNode write, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkSign(inliningTarget, value.isNegative(), isSigned, raiseNode); byte[] array = IntBuiltins.ToBytesNode.fromBigInteger(value, PythonUtils.toIntError(n), littleEndian == 0, isSigned != 0, inliningTarget, profile, raiseNode); write.writeByteArray(bytes, array); @@ -465,9 +465,9 @@ static Object convert(Object charPtr, long size, int littleEndian, int signed, @Bind("this") Node inliningTarget, @Cached CStructAccess.ReadByteNode readByteNode, @Cached IntNodes.PyLongFromByteArray fromByteArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (size != (int) size) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.BYTE_ARRAY_TOO_LONG_TO_CONVERT_TO_INT); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.BYTE_ARRAY_TOO_LONG_TO_CONVERT_TO_INT); } byte[] bytes = readByteNode.readByteArray(charPtr, (int) size); return fromByteArray.execute(inliningTarget, bytes, littleEndian != 0, signed != 0); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMemoryViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMemoryViewBuiltins.java index a2c42d09ae..4a3b96e430 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMemoryViewBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextMemoryViewBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -85,7 +85,7 @@ static Object get(Object obj, int buffertype, byte orderByte, @Cached ContiguousNode contiguousNode, @Cached TruffleString.EqualNode eqNode, @Cached TruffleString.FromCodePointNode fromCodePointNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { assert buffertype == PY_BUF_READ || buffertype == PY_BUF_WRITE; char order = (char) orderByte; assert order == 'C' || order == 'F' || order == 'A'; @@ -94,14 +94,14 @@ static Object get(Object obj, int buffertype, byte orderByte, boolean release = true; try { if (buffertype == PY_BUF_WRITE && mv.isReadOnly()) { - throw raiseNode.get(inliningTarget).raise(BufferError, UNDERLYING_BUFFER_IS_NOT_WRITABLE); + throw raiseNode.raise(inliningTarget, BufferError, UNDERLYING_BUFFER_IS_NOT_WRITABLE); } if ((boolean) contiguousNode.execute(null, mv)) { release = false; return mv; } if (buffertype == PY_BUF_WRITE) { - throw raiseNode.get(inliningTarget).raise(BufferError, WRITABLE_CONTIGUES_FOR_NON_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, WRITABLE_CONTIGUES_FOR_NON_CONTIGUOUS); } PMemoryView mvBytes = memoryViewFromObject.execute(null, toBytesNode.execute(null, mv, fromCodePointNode.execute(order, TS_ENCODING, true))); if (eqNode.execute(T_UINT_8_TYPE_CODE, mv.getFormatString(), TS_ENCODING)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java index 7f59cc181f..ec82881d57 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -177,7 +177,7 @@ static Object getName(PythonModule module, Object nameAttr = read.execute(module, T___NAME__); if (!pyUnicodeCheckNode.execute(inliningTarget, nameAttr)) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.NAMELESS_MODULE); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.NAMELESS_MODULE); } Object promotedName = promoteBorrowedValue.execute(inliningTarget, nameAttr); if (promotedName == null) { @@ -209,11 +209,10 @@ static Object addObject(Object m, TruffleString k, Object o, @SuppressWarnings("unused") @Specialization(guards = "!isModuleSubtype(inliningTarget, m, getClassNode, isSubtypeNode)") static Object pop(Object m, Object key, Object defaultValue, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, S_NEEDS_S_AS_FIRST_ARG, "PyModule_AddObjectRef", "module"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, S_NEEDS_S_AS_FIRST_ARG, "PyModule_AddObjectRef", "module"); } } @@ -232,11 +231,10 @@ static Object addObject(Object m, TruffleString k, long o, @Specialization(guards = "!isModuleSubtype(inliningTarget, m, getClassNode, isSubtypeNode)") static Object pop(@SuppressWarnings("unused") Object m, @SuppressWarnings("unused") Object key, @SuppressWarnings("unused") Object defaultValue, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, S_NEEDS_S_AS_FIRST_ARG, "PyModule_AddIntConstant", "module"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, S_NEEDS_S_AS_FIRST_ARG, "PyModule_AddIntConstant", "module"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java index bb596034d9..d2ff8dc9e6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java @@ -433,7 +433,7 @@ static Object asFileDescriptor(Object obj, @CachedLibrary(limit = "1") PosixSupportLibrary posixLib, @Cached TruffleString.EqualNode eqNode, @Cached PyObjectAsFileDescriptor asFileDescriptorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!longCheckNode.execute(inliningTarget, obj)) { Object posixSupport = PythonContext.get(inliningTarget).getPosixSupport(); if (eqNode.execute(T_JAVA, posixLib.getBackend(posixSupport), TS_ENCODING)) { @@ -441,7 +441,7 @@ static Object asFileDescriptor(Object obj, * For non Python 'int' objects, we refuse to hand out the fileno field when * using the emulated Posix backend, because it is likely a fake. */ - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.S_NOT_SUPPORTED_ON_JAVA_POSIX_BACKEND, "PyObject_AsFileDescriptor"); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.S_NOT_SUPPORTED_ON_JAVA_POSIX_BACKEND, "PyObject_AsFileDescriptor"); } } return asFileDescriptorNode.execute(null, inliningTarget, obj); @@ -488,8 +488,8 @@ static int hasAttr(Object obj, Object attr, abstract static class PyObject_HashNotImplemented extends CApiUnaryBuiltinNode { @Specialization static Object unhashable(Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, UNHASHABLE_TYPE_P, obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, UNHASHABLE_TYPE_P, obj); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPickleBufferBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPickleBufferBuiltins.java index 34e56c14f5..e3e6b1731e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPickleBufferBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPickleBufferBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -65,13 +65,13 @@ abstract static class PyTruffle_PickleBuffer_viewobj extends CApiUnaryBuiltinNod static Object getviewobj(PPickleBuffer object, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object owner = null; if (object.getView() != null) { owner = bufferLib.getOwner(object.getView()); } if (owner == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); } return owner; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPythonRunBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPythonRunBuiltins.java index df7d577fd7..69a83f53f5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPythonRunBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextPythonRunBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -69,7 +69,6 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -89,7 +88,7 @@ static Object run(Object source, int type, Object globals, Object locals, @Suppr @SuppressWarnings("unused") @Exclusive @Cached PyMappingCheckNode isMapping, @Cached PyObjectLookupAttr lookupNode, @Cached CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonModule builtins = PythonContext.get(inliningTarget).getBuiltins(); Object compileCallable = lookupNode.execute(null, inliningTarget, builtins, T_COMPILE); TruffleString stype; @@ -100,7 +99,7 @@ static Object run(Object source, int type, Object globals, Object locals, @Suppr } else if (type == Py_eval_input) { stype = StringLiterals.T_EVAL; } else { - throw raiseNode.get(inliningTarget).raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } Object code = callNode.executeWithoutFrame(compileCallable, source, stype, stype); Object execCallable = lookupNode.execute(null, inliningTarget, builtins, type == Py_eval_input ? T_EVAL : T_EXEC); @@ -110,17 +109,16 @@ static Object run(Object source, int type, Object globals, Object locals, @Suppr @Specialization(guards = "!isString(source) || !isDict(globals)") static Object run(@SuppressWarnings("unused") Object source, @SuppressWarnings("unused") int type, @SuppressWarnings("unused") Object globals, @SuppressWarnings("unused") Object locals, @SuppressWarnings("unused") Object flags, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } @Specialization(guards = {"isString(source)", "isDict(globals)", "!isMapping.execute(inliningTarget, locals)"}, limit = "1") static Object run(@SuppressWarnings("unused") Object source, @SuppressWarnings("unused") int type, @SuppressWarnings("unused") Object globals, Object locals, @SuppressWarnings("unused") Object flags, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Exclusive @Cached PyMappingCheckNode isMapping, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, P_OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, locals); + @Bind("this") Node inliningTarget, + @SuppressWarnings("unused") @Exclusive @Cached PyMappingCheckNode isMapping) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, P_OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, locals); } protected static boolean checkArgs(Object source, Object globals, Object locals, Node inliningTarget, PyMappingCheckNode isMapping) { @@ -133,7 +131,7 @@ abstract static class Py_CompileString extends CApiTernaryBuiltinNode { @Specialization(guards = {"isString(source)", "isString(filename)"}) static Object compile(Object source, Object filename, int type, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectLookupAttr lookupNode, @Cached CallNode callNode) { return Py_CompileStringExFlags.compile(source, filename, type, null, -1, inliningTarget, raiseNode, lookupNode, callNode); @@ -142,8 +140,8 @@ static Object compile(Object source, Object filename, int type, @SuppressWarnings("unused") @Specialization(guards = "!isString(source) || !isString(filename)") static Object fail(Object source, Object filename, Object type, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } } @@ -153,7 +151,7 @@ abstract static class Py_CompileStringExFlags extends CApi5BuiltinNode { static Object compile(Object source, Object filename, int type, @SuppressWarnings("unused") Object flags, int optimizationLevel, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectLookupAttr lookupNode, @Cached CallNode callNode) { PythonModule builtins = PythonContext.get(lookupNode).getCore().getBuiltins(); @@ -166,7 +164,7 @@ static Object compile(Object source, Object filename, int type, } else if (type == Py_eval_input) { stype = StringLiterals.T_EVAL; } else { - throw raiseNode.get(inliningTarget).raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } int defaultFlags = 0; boolean dontInherit = false; @@ -176,8 +174,8 @@ static Object compile(Object source, Object filename, int type, @SuppressWarnings("unused") @Specialization(guards = "!isString(source) || !isString(filename)") static Object fail(Object source, Object filename, Object type, Object flags, Object optimizationLevel, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } } @@ -188,7 +186,7 @@ static Object compile(Object source, Object filename, int type, @SuppressWarnings("unused") Object flags, int optimizationLevel, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectLookupAttr lookupNode, @Cached CallNode callNode) { return Py_CompileStringExFlags.compile(source, filename, type, null, optimizationLevel, inliningTarget, raiseNode, lookupNode, callNode); @@ -197,8 +195,8 @@ static Object compile(Object source, Object filename, int type, @SuppressWarnings("unused") @Specialization(guards = "!isString(source)") static Object fail(Object source, Object filename, Object type, Object flags, Object optimizationLevel, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java index c887fbe379..e52002b3f0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java @@ -169,21 +169,19 @@ static Object nextEntry(@SuppressWarnings("unused") Object set, @SuppressWarning @Specialization(guards = {"!isPSet(anyset)", "!isPFrozenSet(anyset)", "isSetSubtype(inliningTarget, anyset, getClassNode, isSubtypeNode)"}) static Object nextNative(@SuppressWarnings("unused") Object anyset, @SuppressWarnings("unused") Object pos, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "set"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "set"); } @Specialization(guards = {"!isPSet(anyset)", "!isPFrozenSet(anyset)", "!isSetSubtype(inliningTarget, anyset, getClassNode, isSubtypeNode)"}) static Object nextEntry(Object anyset, @SuppressWarnings("unused") Object pos, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, @Cached StrNode strNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(anyset), anyset); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC_WAS_S_P, strNode.executeWith(anyset), anyset); } protected boolean isSetSubtype(Node inliningTarget, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { @@ -285,8 +283,8 @@ static int add(PBaseSet self, Object o, @Specialization(guards = "!isAnySet(self)") static int add(Object self, @SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, EXPECTED_S_NOT_P, "a set object", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, EXPECTED_S_NOT_P, "a set object", self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java index 19fd093562..81c957989e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java @@ -161,11 +161,11 @@ static Object doGeneric(Object cls, @Cached CastToJavaIntExactNode castToIntNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { Object realSizeObj = readRealSizeNode.execute(cls, StructSequence.T_N_FIELDS); if (realSizeObj == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC, EMPTY_OBJECT_ARRAY); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC, EMPTY_OBJECT_ARRAY); } else { int realSize = castToIntNode.execute(inliningTarget, realSizeObj); Object[] values = new Object[realSize]; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java index 94356e0df5..8ef9b5e324 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTupleBuiltins.java @@ -88,11 +88,11 @@ abstract static class PyTuple_New extends CApiUnaryBuiltinNode { static PTuple doGeneric(long longSize, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached CStructAccess.AllocateNode alloc) { int size = (int) longSize; if (longSize != size) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.MemoryError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.MemoryError); } /* * Already allocate the tuple with native memory, since it has to be populated from the @@ -116,7 +116,7 @@ static Object doPTuple(PTuple tuple, long key, @Cached ListGeneralizationNode generalizationNode, @Shared @Cached SetItemScalarNode setItemNode, @Shared @Cached GetItemScalarNode getItemNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage sequenceStorage = tuple.getSequenceStorage(); int index = checkIndex(inliningTarget, key, sequenceStorage, raiseNode); Object result = getItemNode.execute(inliningTarget, sequenceStorage, index); @@ -138,7 +138,7 @@ static Object doNative(PythonAbstractNativeObject tuple, long key, @Shared("promote") @Cached PromoteBorrowedValue promoteNode, @Shared @Cached SetItemScalarNode setItemNode, @Shared @Cached GetItemScalarNode getItemNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage sequenceStorage = asNativeStorage.execute(tuple); int index = checkIndex(inliningTarget, key, sequenceStorage, raiseNode); Object result = getItemNode.execute(inliningTarget, sequenceStorage, index); @@ -158,10 +158,10 @@ Object fallback(Object tuple, @SuppressWarnings("unused") Object pos) { throw raiseFallback(tuple, PythonBuiltinClassType.PTuple); } - private static int checkIndex(Node inliningTarget, long key, SequenceStorage sequenceStorage, PRaiseNode.Lazy raiseNode) { + private static int checkIndex(Node inliningTarget, long key, SequenceStorage sequenceStorage, PRaiseNode raiseNode) { // we must do a bounds-check but we must not normalize the index if (key < 0 || key >= sequenceStorage.length()) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.TUPLE_OUT_OF_BOUNDS); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.TUPLE_OUT_OF_BOUNDS); } return (int) key; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java index d7cc998246..9ec25257b8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java @@ -188,8 +188,9 @@ abstract static class PyTruffle_Compute_Mro extends CApiBinaryBuiltinNode { @Specialization @TruffleBoundary - static Object doIt(PythonNativeClass self, TruffleString className) { - PythonAbstractClass[] doSlowPath = TypeNodes.ComputeMroNode.doSlowPath(self); + static Object doIt(PythonNativeClass self, TruffleString className, + @Bind("this") Node inliningTarget) { + PythonAbstractClass[] doSlowPath = TypeNodes.ComputeMroNode.doSlowPath(inliningTarget, self); return PFactory.createTuple(PythonLanguage.get(null), new MroSequenceStorage(className, doSlowPath)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java index 4dbf93ba44..340340700e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java @@ -227,11 +227,10 @@ static Object fromObject(Object obj, @Specialization(guards = {"!isStringSubtype(inliningTarget, obj, getClassNode, isSubtypeNode)"}) static Object fromObject(Object obj, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_CONVERT_TO_STR_IMPLICITLY, obj); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_CONVERT_TO_STR_IMPLICITLY, obj); } protected boolean isPStringType(Node inliningTarget, Object obj, GetClassNode getClassNode) { @@ -255,20 +254,18 @@ static Object concat(Object left, Object right, @Specialization(guards = {"!isString(left)", "!isStringSubtype(inliningTarget, left, getClassNode, isSubtypeNode)"}) static Object leftNotString(Object left, @SuppressWarnings("unused") Object right, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, left); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, left); } @Specialization(guards = {"!isString(right)", "!isStringSubtype(inliningTarget, right, getClassNode, isSubtypeNode)"}) static Object rightNotString(@SuppressWarnings("unused") Object left, Object right, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, right); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, right); } } @@ -301,7 +298,7 @@ static Object doGeneric(Object obj, Object encodingObj, Object errorsObj, errors = (TruffleString) errorsObjProfiled; } if (nullProfile.profile(inliningTarget, obj == PNone.NO_VALUE)) { - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } return decodeNode.execute(null, inliningTarget, obj, encoding, errors); } @@ -364,7 +361,7 @@ static Object find(Object format, Object args, @Cached ModNode modNode, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, format, args, raiseNode); return modNode.execute(null, format, args); } @@ -374,9 +371,9 @@ static Object find(Object format, @SuppressWarnings("unused") Object args, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkNonNullArg(inliningTarget, format, args, raiseNode); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, format); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, format); } } @@ -407,11 +404,10 @@ static Object find(Object string, Object c, long start, long end, @SuppressWarni @Specialization(guards = {"!isTruffleString(string)", "!isStringSubtype(inliningTarget, string, getClassNode, isSubtypeNode)"}) static Object find(Object string, @SuppressWarnings("unused") Object c, @SuppressWarnings("unused") Object start, @SuppressWarnings("unused") Object end, @SuppressWarnings("unused") Object direction, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, string); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, string); } } @@ -429,7 +425,7 @@ static Object doString(Object s, long start, long end, @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode) { if (profile.profile(inliningTarget, start < 0 || end < 0)) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw PRaiseNode.raiseStatic(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } Object getItemCallable = lookupAttrNode.execute(null, inliningTarget, s, T___GETITEM__); return callNode.executeWithoutFrame(getItemCallable, sliceNode.execute(inliningTarget, start, end, PNone.NONE)); @@ -437,11 +433,10 @@ static Object doString(Object s, long start, long end, @Specialization(guards = {"!isTruffleString(s)", "isStringSubtype(s, inliningTarget, getClassNode, isSubtypeNode)"}, limit = "1") static Object doError(Object s, @SuppressWarnings("unused") Object start, @SuppressWarnings("unused") Object end, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, s); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, s); } protected static boolean isStringSubtype(Object obj, Node n, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { @@ -463,11 +458,10 @@ static Object find(Object separator, Object seq, @Specialization(guards = {"!isTruffleString(separator)", "isStringSubtype(inliningTarget, separator, getClassNode, isSubtypeNode)"}) static Object find(Object separator, @SuppressWarnings("unused") Object seq, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, separator); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, separator); } } @@ -487,11 +481,10 @@ static Object compare(Object left, Object right, @Specialization(guards = {"!isAnyString(inliningTarget, left, getClassNode, isSubtypeNode) || !isAnyString(inliningTarget, right, getClassNode, isSubtypeNode)"}) static Object compare(Object left, Object right, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_COMPARE, left, right); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_COMPARE, left, right); } } @@ -526,11 +519,10 @@ static Object compare(Object left, Object right, @Specialization(guards = {"!isAnyString(inliningTarget, left, getClassNode, isSubtypeNode) || !isAnyString(inliningTarget, right, getClassNode, isSubtypeNode)"}) static Object compare(Object left, Object right, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_COMPARE, left, right); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_COMPARE, left, right); } } @@ -569,11 +561,10 @@ static int tailmatch(Object string, Object substring, long start, long end, @Sup @SuppressWarnings("unused") @Specialization(guards = {"!isAnyString(inliningTarget, string, getClassNode, isSubtypeNode) || !isAnyString(inliningTarget, substring, getClassNode, isSubtypeNode)"}) static Object find(Object string, Object substring, Object start, Object end, Object direction, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached GetClassNode getClassNode, @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_STR_NOT_P, string); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_STR_NOT_P, string); } } @@ -591,11 +582,10 @@ static Object encode(Object obj, Object encoding, Object errors, @Specialization(guards = {"!isString(obj)", "!isStringSubtype(inliningTarget, obj, getClassNode, isSubtypeNode)"}) static Object encode(@SuppressWarnings("unused") Object obj, @SuppressWarnings("unused") Object encoding, @SuppressWarnings("unused") Object errors, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -657,11 +647,10 @@ static Object escape(Object s, @Specialization(guards = {"!isString(obj)", "!isStringSubtype(inliningTarget, obj, getClassNode, isSubtypeNode)"}) static Object escape(@SuppressWarnings("unused") Object obj, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode, @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -673,19 +662,19 @@ static int doGeneric(Object type, long lindex, @Cached CastToTruffleStringNode castToStringNode, @Cached TruffleString.CodePointLengthNode lengthNode, @Cached TruffleString.CodePointAtIndexNode codepointAtIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { TruffleString s = castToStringNode.execute(inliningTarget, type); int index = PInt.intValueExact(lindex); // avoid StringIndexOutOfBoundsException if (index < 0 || index >= lengthNode.execute(s, TS_ENCODING)) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } return codepointAtIndexNode.execute(s, index, TS_ENCODING); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } } } @@ -702,12 +691,12 @@ static Object doGeneric(Object ptr, long elements, long elementSize, int isAscii @CApiBuiltin(ret = PyObjectTransfer, args = {Pointer, Py_ssize_t, Int}, call = Ignored) abstract static class PyTruffleUnicode_FromUCS extends CApiTernaryBuiltinNode { - private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNode.Lazy raiseNode) throws PException { + private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNode raiseNode) throws PException { return switch (kind) { case 1 -> ISO_8859_1; case 2 -> UTF_16; case 4 -> TS_ENCODING; - default -> throw raiseNode.get(inliningTarget).raiseBadInternalCall(); + default -> throw raiseNode.raiseBadInternalCall(inliningTarget); }; } @@ -717,7 +706,7 @@ static Object doNative(Object ptr, long byteLength, int kind, @SuppressWarnings("unused") @Shared("ptrLib") @CachedLibrary(limit = "1") InteropLibrary ptrLib, @Cached FromNativePointerNode fromNativePointerNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { int iByteLength = PInt.intValueExact(byteLength); Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); @@ -729,7 +718,7 @@ static Object doNative(Object ptr, long byteLength, int kind, TruffleString ts = fromNativePointerNode.execute(ptr, 0, iByteLength, srcEncoding, true); return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -740,7 +729,7 @@ static Object doManaged(Object ptr, long byteLength, int kind, @Cached GetByteArrayNode getByteArrayNode, @Cached FromByteArrayNode fromByteArrayNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); byte[] ucsBytes = getByteArrayNode.execute(inliningTarget, ptr, byteLength); @@ -751,9 +740,9 @@ static Object doManaged(Object ptr, long byteLength, int kind, * This means that we cannot read the array-like foreign object or the foreign * elements cannot be interpreted as bytes. In any case, that's a fatal error. */ - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.M, e); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } } @@ -761,12 +750,12 @@ static Object doManaged(Object ptr, long byteLength, int kind, @CApiBuiltin(ret = PyObjectTransfer, args = {Pointer, Py_ssize_t, Int}, call = Ignored) abstract static class PyTruffleUnicode_FromUTF extends CApiTernaryBuiltinNode { - private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNode.Lazy raiseNode) throws PException { + private static Encoding encodingFromKind(Node inliningTarget, int kind, PRaiseNode raiseNode) throws PException { return switch (kind) { case 1 -> UTF_8; case 2 -> UTF_16LE; case 4 -> UTF_32LE; - default -> throw raiseNode.get(inliningTarget).raiseBadInternalCall(); + default -> throw raiseNode.raiseBadInternalCall(inliningTarget); }; } @@ -776,14 +765,14 @@ static Object doNative(Object ptr, long byteLength, int kind, @SuppressWarnings("unused") @Shared("ptrLib") @CachedLibrary(limit = "1") InteropLibrary ptrLib, @Cached FromNativePointerNode fromNativePointerNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { int iByteLength = PInt.intValueExact(byteLength); Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); TruffleString ts = fromNativePointerNode.execute(ptr, 0, iByteLength, srcEncoding, true); return PFactory.createString(PythonLanguage.get(inliningTarget), switchEncodingNode.execute(ts, TS_ENCODING)); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -794,7 +783,7 @@ static Object doManaged(Object ptr, long byteLength, int kind, @Cached GetByteArrayNode getByteArrayNode, @Cached FromByteArrayNode fromByteArrayNode, @Shared("switchEncodingNode") @Cached SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { Encoding srcEncoding = encodingFromKind(inliningTarget, kind, raiseNode); byte[] ucsBytes = getByteArrayNode.execute(inliningTarget, ptr, byteLength); @@ -805,9 +794,9 @@ static Object doManaged(Object ptr, long byteLength, int kind, * This means that we cannot read the array-like foreign object or the foreign * elements cannot be interpreted as bytes. In any case, that's a fatal error. */ - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.M, e); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } } @@ -852,14 +841,14 @@ static Object doUtf8Decode(Object cByteArray, long size, TruffleString errors, i @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); return decode.call(null, bytes, T_UTF8, errors, reportConsumed == 0); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); } catch (InteropException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } } } @@ -873,7 +862,7 @@ static Object decode(Object cByteArray, long size, TruffleString errors, int byt @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); TruffleString encoding; @@ -886,9 +875,9 @@ static Object decode(Object cByteArray, long size, TruffleString errors, int byt } return decode.call(null, bytes, encoding, errors, reportConsumed == 0); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); } catch (InteropException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } } } @@ -902,7 +891,7 @@ static Object decode(Object cByteArray, long size, TruffleString errors, int byt @Bind PythonLanguage language, @Cached GetByteArrayNode getByteArrayNode, @Cached CodecsModuleBuiltins.CodecsDecodeNode decode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PBytes bytes = PFactory.createBytes(language, getByteArrayNode.execute(inliningTarget, cByteArray, size)); TruffleString encoding; @@ -915,9 +904,9 @@ static Object decode(Object cByteArray, long size, TruffleString errors, int byt } return decode.call(null, bytes, encoding, errors, reportConsumed == 0); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.INPUT_TOO_LONG); } catch (InteropException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } } } @@ -989,8 +978,8 @@ Object doUnicode(Object s, TruffleString errors, @Fallback static Object doUnicode(@SuppressWarnings("unused") Object s, @SuppressWarnings("unused") Object errors, - @Cached PRaiseNode raiseNode) { - return raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -1045,8 +1034,8 @@ static Object doUnicode(PString s, Object sizePtr, @Fallback @SuppressWarnings("unused") static Object doError(Object s, Object sizePtr, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -1096,8 +1085,8 @@ static Object doUnicode(PString s, Object sizePtr, @Fallback @SuppressWarnings("unused") static Object doError(Object s, Object sizePtr, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -1133,17 +1122,17 @@ static Object doUnicode(Object s, long elementSize, @Bind("this") Node inliningTarget, @Cached UnicodeAsWideCharNode asWideCharNode, @Cached CastToTruffleStringNode castStr, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PBytes wchars = asWideCharNode.executeLittleEndian(inliningTarget, castStr.execute(inliningTarget, s), elementSize); if (wchars != null) { return wchars; } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.UNSUPPORTED_SIZE_WAS, "wchar", elementSize); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.UNSUPPORTED_SIZE_WAS, "wchar", elementSize); } } catch (IllegalArgumentException e) { // TODO - throw raiseNode.get(inliningTarget).raise(PythonErrorType.LookupError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.LookupError, ErrorMessages.M, e); } } } @@ -1180,14 +1169,14 @@ static Object doit(Object encoding, Object object, long length, long start, long @Bind("this") Node inliningTarget, @Cached GetByteArrayNode getByteArrayNode, @Cached CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PBytes bytes; try { bytes = PFactory.createBytes(PythonLanguage.get(inliningTarget), getByteArrayNode.execute(inliningTarget, object, length)); } catch (InteropException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.M, e); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); } return callNode.executeWithoutFrame(UnicodeDecodeError, encoding, bytes, start, end, reason); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecCtxBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecCtxBuiltins.java index d92537ce8c..cae8468c93 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecCtxBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecCtxBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -97,13 +97,13 @@ static Object codecctxErrorsSet(MultibyteStatefulCodecContext self, Object value @Cached TruffleString.EqualNode isEqual, @Cached CastToTruffleStringNode castToStringNode, @Cached PyUnicodeCheckNode unicodeCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (value == PNone.NONE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, CANNOT_DELETE); + throw raiseNode.raise(inliningTarget, AttributeError, CANNOT_DELETE); } if (!unicodeCheckNode.execute(inliningTarget, value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ERRORS_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ERRORS_MUST_BE_A_STRING); } TruffleString str = castToStringNode.execute(inliningTarget, value); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java index 2a7e28741d..8a0a6123e9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsCNModuleBuiltins.java @@ -126,15 +126,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java index 79329e4033..c1a8c13e16 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsHKModuleBuiltins.java @@ -118,15 +118,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java index fdf58b9d1e..a6ce7e5163 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsISO2022ModuleBuiltins.java @@ -128,15 +128,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java index 7555de5d80..59352af1c5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsJPModuleBuiltins.java @@ -150,15 +150,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java index 25f99a0321..33e5a58157 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsKRModuleBuiltins.java @@ -123,15 +123,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java index 8a71f69d73..283810add0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/CodecsTWModuleBuiltins.java @@ -118,15 +118,15 @@ static Object getcodec(Object encoding, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached CastToTruffleStringNode asUTF8Node, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_NAME_MUST_BE_A_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_NAME_MUST_BE_A_STRING); } MultibyteCodec codec = findCodec(CODEC_LIST, asUTF8Node.execute(inliningTarget, encoding), isEqual); if (codec == null) { - throw raiseNode.get(inliningTarget).raise(LookupError, NO_SUCH_CODEC_IS_SUPPORTED); + throw raiseNode.raise(inliningTarget, LookupError, NO_SUCH_CODEC_IS_SUPPORTED); } PyCapsule codecobj = PFactory.createCapsuleJavaName(language, codec, PyMultibyteCodec_CAPSULE_NAME); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java index 126804b23c..6a31839447 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecBuiltins.java @@ -142,12 +142,12 @@ static Object notTS(VirtualFrame frame, MultibyteCodecObject self, Object input, @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared @Cached TruffleString.EqualNode isEqual, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object ucvt = input; if (!unicodeCheck.execute(inliningTarget, input)) { ucvt = strNode.execute(frame, inliningTarget, input); if (!unicodeCheck.execute(inliningTarget, ucvt)) { - throw raiseNode.get(inliningTarget).raise(TypeError, COULDN_T_CONVERT_THE_OBJECT_TO_UNICODE); + throw raiseNode.raise(inliningTarget, TypeError, COULDN_T_CONVERT_THE_OBJECT_TO_UNICODE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java index 207f24926a..a62459db0f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteCodecUtil.java @@ -183,7 +183,7 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, @Cached(inline = true) CallErrorCallbackNode callErrorCallbackNode, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached EncodeNode encodeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString reason = ILLEGAL_MULTIBYTE_SEQUENCE; int esize = e; @@ -197,9 +197,9 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, esize = buf.getInpos(); break; case MBERR_INTERNAL: - throw raiseNode.get(inliningTarget).raise(RuntimeError, INTERNAL_CODEC_ERROR); + throw raiseNode.raise(inliningTarget, RuntimeError, INTERNAL_CODEC_ERROR); default: - throw raiseNode.get(inliningTarget).raise(RuntimeError, UNKNOWN_RUNTIME_ERROR); + throw raiseNode.raise(inliningTarget, RuntimeError, UNKNOWN_RUNTIME_ERROR); } } @@ -246,7 +246,7 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, } if (errors == ERROR_STRICT) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(buf.excobj); + throw raiseNode.raiseExceptionObject(inliningTarget, buf.excobj); // PyCodec_StrictErrors(buf.excobj); } @@ -271,7 +271,7 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, } if (isError) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODING_ERROR_HANDLER_MUST_RETURN); + throw raiseNode.raise(inliningTarget, TypeError, ENCODING_ERROR_HANDLER_MUST_RETURN); } PBytes retstr; @@ -301,10 +301,10 @@ static int encerror(VirtualFrame frame, MultibyteCodec codec, newpos += buf.getInlen(); } } catch (PException exception) { - throw raiseNode.get(inliningTarget).raise(IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); + throw raiseNode.raise(inliningTarget, IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); } if (newpos < 0 || newpos > buf.getInlen()) { - throw raiseNode.get(inliningTarget).raise(IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); + throw raiseNode.raise(inliningTarget, IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); } buf.setInpos(newpos); @@ -334,7 +334,7 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, @Cached PyLongAsIntNode asSizeNode, @Cached CastToJavaStringNode toString, @Cached(inline = true) CallErrorCallbackNode callErrorCallbackNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString reason = ILLEGAL_MULTIBYTE_SEQUENCE; int esize = e; @@ -349,9 +349,9 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, esize = buf.remaining(); break; case MBERR_INTERNAL: - throw raiseNode.get(inliningTarget).raise(RuntimeError, INTERNAL_CODEC_ERROR); + throw raiseNode.raise(inliningTarget, RuntimeError, INTERNAL_CODEC_ERROR); default: - throw raiseNode.get(inliningTarget).raise(RuntimeError, UNKNOWN_RUNTIME_ERROR); + throw raiseNode.raise(inliningTarget, RuntimeError, UNKNOWN_RUNTIME_ERROR); } } @@ -381,7 +381,7 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, } if (errors == ERROR_STRICT) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(buf.excobj); + throw raiseNode.raiseExceptionObject(inliningTarget, buf.excobj); // PyCodec_StrictErrors(buf.excobj); } @@ -404,7 +404,7 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, } if (isError) { - throw raiseNode.get(inliningTarget).raise(TypeError, DECODING_ERROR_HANDLER_MUST_RETURN); + throw raiseNode.raise(inliningTarget, TypeError, DECODING_ERROR_HANDLER_MUST_RETURN); } buf.writeStr(toString.execute(retuni)); @@ -416,10 +416,10 @@ static void decerror(VirtualFrame frame, MultibyteCodec codec, newpos += buf.getInpos(); } } catch (PException ee) { - throw raiseNode.get(inliningTarget).raise(IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); + throw raiseNode.raise(inliningTarget, IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); } if (newpos > buf.getInSize()) { - throw raiseNode.get(inliningTarget).raise(IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); + throw raiseNode.raise(inliningTarget, IndexError, POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newpos); } buf.setInpos(newpos); @@ -443,14 +443,14 @@ abstract static class EncodeNode extends Node { @Specialization static PBytes encode(VirtualFrame frame, Node inliningTarget, MultibyteCodec codec, MultibyteCodecState state, MultibyteEncodeBuffer buf, Object errors, int flags, @Cached(inline = false) EncodeErrorNode encodeErrorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // if (buf.inlen == 0 && (flags & MBENC_RESET) == 0) { // return PFactory.createBytes(language, EMPTY_BYTE_ARRAY); // } if (buf.getInlen() > (MAXSIZE - 16) / 2) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } while (!buf.isFull()) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java index 94672160ec..265d0c66d8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteDecodeBuffer.java @@ -129,7 +129,7 @@ protected TruffleString toTString() { protected void grow(Node raisingNode) { int newCapacity = 2 * writer.capacity() + 1; if (newCapacity < 0) { - throw PRaiseNode.raiseUncached(raisingNode, MemoryError); + throw PRaiseNode.raiseStatic(raisingNode, MemoryError); } CharBuffer newBuffer = CharBuffer.allocate(newCapacity); writer.flip(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java index 34f298cf23..8bcaaaadce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteEncodeBuffer.java @@ -128,7 +128,7 @@ protected void expandOutputBuffer(int esize, Node raisingNode) { int orgsize = outputBuffer.capacity(); int incsize = esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize; if (orgsize > MAXSIZE - incsize) { - throw PRaiseNode.raiseUncached(raisingNode, MemoryError); + throw PRaiseNode.raiseStatic(raisingNode, MemoryError); } ByteBuffer newBuffer = ByteBuffer.allocate(incsize); outputBuffer.flip(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java index 8e471c805d..f1458916fe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalDecoderBuiltins.java @@ -113,7 +113,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, @Cached TruffleString.EqualNode isEqual, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { // "|s:IncrementalDecoder" + @Cached PRaiseNode raiseNode) { // "|s:IncrementalDecoder" TruffleString errors = null; if (err != PNone.NO_VALUE) { errors = castToStringNode.execute(inliningTarget, err); @@ -123,7 +123,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_IS_UNEXPECTED_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, CODEC_IS_UNEXPECTED_TYPE); } self.codec = ((MultibyteCodecObject) codec).codec; @@ -164,7 +164,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object decode(VirtualFrame frame, MultibyteIncrementalDecoderObject self, byte[] input, int end, @Bind("this") Node inliningTarget, @Cached MultibyteCodecUtil.DecodeErrorNode decodeErrorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] data = input; int size = input.length; @@ -174,7 +174,7 @@ static Object decode(VirtualFrame frame, MultibyteIncrementalDecoderObject self, byte[] wdata = data; if (self.pendingsize != 0) { if (size > MAXSIZE - self.pendingsize) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } wsize = size + self.pendingsize; wdata = new byte[wsize]; @@ -208,11 +208,11 @@ static Object decode(VirtualFrame frame, MultibyteIncrementalDecoderObject self, static int decoderAppendPending(Node inliningTarge, MultibyteStatefulDecoderContext ctx, MultibyteDecodeBuffer buf, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { int npendings = buf.remaining(); if (npendings + ctx.pendingsize > MAXDECPENDING || npendings > MAXSIZE - ctx.pendingsize) { - throw raiseNode.get(inliningTarge).raise(UnicodeError, PENDING_BUFFER_OVERFLOW); + throw raiseNode.raise(inliningTarge, UnicodeError, PENDING_BUFFER_OVERFLOW); } buf.getRemaining(ctx.pending, ctx.pendingsize, npendings); ctx.pendingsize += npendings; @@ -270,7 +270,7 @@ static Object setstate(VirtualFrame frame, MultibyteIncrementalDecoderObject sel @Cached HiddenAttr.ReadNode readHiddenAttrNode, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached SequenceStorageNodes.GetInternalObjectArrayNode getArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] array = getArray.execute(inliningTarget, state.getSequenceStorage()); Object buffer = array[0]; Object statelong = array[1]; @@ -278,7 +278,7 @@ static Object setstate(VirtualFrame frame, MultibyteIncrementalDecoderObject sel byte[] bufferstr = toBytesNode.execute(frame, buffer); int buffersize = bufferstr.length; if (buffersize > MAXDECPENDING) { - throw raiseNode.get(inliningTarget).raise(UnicodeError, PENDING_BUFFER_TOO_LARGE); + throw raiseNode.raise(inliningTarget, UnicodeError, PENDING_BUFFER_TOO_LARGE); } self.pendingsize = buffersize; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java index 5302fc7ae5..a4ed3ffacb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteIncrementalEncoderBuiltins.java @@ -126,7 +126,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, @Cached TruffleString.EqualNode isEqual, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { // "|s:IncrementalEncoder" + @Cached PRaiseNode raiseNode) { // "|s:IncrementalEncoder" TruffleString errors = null; if (err != PNone.NO_VALUE) { @@ -137,7 +137,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object err, Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_IS_UNEXPECTED_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, CODEC_IS_UNEXPECTED_TYPE); } self.codec = ((MultibyteCodecObject) codec).codec; @@ -172,7 +172,7 @@ static Object ts(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Truffl @Shared @Cached TruffleString.ConcatNode concatNode, @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared @Cached TruffleString.SubstringNode substringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString inbuf = ucvt; TruffleString origpending = null; if (ctx.pending != null) { @@ -192,7 +192,7 @@ static Object ts(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Truffl if (buf.getInpos() < datalen) { if (datalen - buf.getInpos() > MAXENCPENDING) { /* normal codecs can't reach here */ - throw raiseNode.get(inliningTarget).raise(UnicodeError, PENDING_BUFFER_OVERFLOW); + throw raiseNode.raise(inliningTarget, UnicodeError, PENDING_BUFFER_OVERFLOW); } ctx.pending = substringNode.execute(inbuf, buf.getInpos(), datalen, TS_ENCODING, false); } @@ -216,12 +216,12 @@ static Object notTS(VirtualFrame frame, MultibyteStatefulEncoderContext ctx, Obj @Shared @Cached TruffleString.ConcatNode concatNode, @Shared @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared @Cached TruffleString.SubstringNode substringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object ucvt = unistr; if (!unicodeCheckNode.execute(inliningTarget, unistr)) { ucvt = strNode.execute(frame, inliningTarget, unistr); if (!unicodeCheckNode.execute(inliningTarget, unistr)) { - throw raiseNode.get(inliningTarget).raise(TypeError, COULDN_T_CONVERT_THE_OBJECT_TO_STR); + throw raiseNode.raise(inliningTarget, TypeError, COULDN_T_CONVERT_THE_OBJECT_TO_STR); } } TruffleString str = toTruffleStringNode.execute(inliningTarget, ucvt); @@ -259,7 +259,7 @@ static Object getstate(MultibyteIncrementalEncoderObject self, @Cached HiddenAttr.WriteNode writeHiddenAttrNode, @Cached CodecsModuleBuiltins.CodecsEncodeToJavaBytesNode asUTF8AndSize, @Cached IntNodes.PyLongFromByteArray fromByteArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * state made up of 1 byte for buffer size, up to MAXENCPENDING*4 bytes for UTF-8 * encoded buffer (each character can use up to 4 bytes), and required bytes for @@ -274,7 +274,7 @@ static Object getstate(MultibyteIncrementalEncoderObject self, byte[] pendingbuffer = asUTF8AndSize.execute(self.pending, T_UTF8, T_STRICT); int pendingsize = pendingbuffer.length; if (pendingsize > MAXENCPENDING * 4) { - throw raiseNode.get(inliningTarget).raise(UnicodeError, PENDING_BUFFER_TOO_LARGE); + throw raiseNode.raise(inliningTarget, UnicodeError, PENDING_BUFFER_TOO_LARGE); } statebytes[0] = (byte) pendingsize; PythonUtils.arraycopy(pendingbuffer, 0, statebytes, 1, pendingsize); @@ -301,13 +301,13 @@ static Object setstate(MultibyteIncrementalEncoderObject self, PInt statelong, @Bind("this") Node inliningTarget, @Cached HiddenAttr.ReadNode readHiddenAttrNode, @Cached IntNodes.PyLongAsByteArray asByteArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int sizeOfStateBytes = 1 + MAXENCPENDING * 4 + MULTIBYTECODECSTATE; byte[] statebytes = asByteArray.execute(inliningTarget, statelong, sizeOfStateBytes, false); if (statebytes[0] > MAXENCPENDING * 4) { - throw raiseNode.get(inliningTarget).raise(UnicodeError, PENDING_BUFFER_TOO_LARGE); + throw raiseNode.raise(inliningTarget, UnicodeError, PENDING_BUFFER_TOO_LARGE); } self.pending = decodeUTF8(statebytes, 1, statebytes[0]); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java index 02e9cf81ac..e99bb6d1ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamReaderBuiltins.java @@ -109,7 +109,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object stream, @Cached TruffleString.EqualNode isEqual, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { // "O|s:StreamReader" + @Cached PRaiseNode raiseNode) { // "O|s:StreamReader" TruffleString errors = null; if (err != PNone.NO_VALUE) { @@ -119,7 +119,7 @@ static Object mbstreamreaderNew(VirtualFrame frame, Object type, Object stream, MultibyteStreamReaderObject self = PFactory.createMultibyteStreamReaderObject(language, type, getInstanceShape.execute(type)); Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_IS_UNEXPECTED_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, CODEC_IS_UNEXPECTED_TYPE); } self.codec = ((MultibyteCodecObject) codec).codec; @@ -156,7 +156,7 @@ static TruffleString iread(VirtualFrame frame, MultibyteStreamReaderObject self, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached TypeNodes.GetNameNode getNameNode, @Cached MultibyteCodecUtil.DecodeErrorNode decodeErrorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (sizehint == 0) { return T_EMPTY_STRING; @@ -173,7 +173,7 @@ static TruffleString iread(VirtualFrame frame, MultibyteStreamReaderObject self, if (!(cres instanceof PBytes)) { Object crestType = getClassNode.execute(inliningTarget, cres); if (!bytesCheckNode.execute(inliningTarget, crestType)) { - throw raiseNode.get(inliningTarget).raise(TypeError, STREAM_FUNCTION_RETURNED_A_NON_BYTES_OBJECT_S, getNameNode.execute(inliningTarget, cres)); + throw raiseNode.raise(inliningTarget, TypeError, STREAM_FUNCTION_RETURNED_A_NON_BYTES_OBJECT_S, getNameNode.execute(inliningTarget, cres)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java index f00753fc89..f18ce75768 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibyteStreamWriterBuiltins.java @@ -108,7 +108,7 @@ static Object mbstreamwriterNew(VirtualFrame frame, Object type, Object stream, @Cached TruffleString.EqualNode isEqual, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { // "O|s:StreamWriter" + @Cached PRaiseNode raiseNode) { // "O|s:StreamWriter" TruffleString errors = null; if (err != PNone.NO_VALUE) { errors = castToStringNode.execute(inliningTarget, err); @@ -118,7 +118,7 @@ static Object mbstreamwriterNew(VirtualFrame frame, Object type, Object stream, Object codec = getAttr.execute(frame, inliningTarget, type, StringLiterals.T_CODEC); if (!(codec instanceof MultibyteCodecObject)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CODEC_IS_UNEXPECTED_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, CODEC_IS_UNEXPECTED_TYPE); } self.codec = ((MultibyteCodecObject) codec).codec; @@ -185,8 +185,8 @@ static Object writelines(VirtualFrame frame, MultibyteStreamWriterObject self, P // assuming !pySequenceCheck.execute(lines) @Fallback static Object writelines(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object lines, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARG_MUST_BE_A_SEQUENCE_OBJECT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARG_MUST_BE_A_SEQUENCE_OBJECT); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java index 2ad485b8a1..0089eb2fcb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cjkcodecs/MultibytecodecModuleBuiltins.java @@ -127,14 +127,14 @@ abstract static class CreateCodecNode extends PythonUnaryBuiltinNode { @Specialization static Object createCodec(PyCapsule arg, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { return createCodec(inliningTarget, arg, raiseNode); } static Object createCodec(Node inliningTarget, PyCapsule arg, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (!PyCapsule.capsuleJavaNameIs(arg, PyMultibyteCodec_CAPSULE_NAME)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ARGUMENT_TYPE_INVALID); + throw raiseNode.raise(inliningTarget, ValueError, ARGUMENT_TYPE_INVALID); } MultibyteCodec codec; codec = (MultibyteCodec) arg.getPointer(); @@ -144,8 +144,8 @@ static Object createCodec(Node inliningTarget, PyCapsule arg, @Fallback static Object createCodec(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ARGUMENT_TYPE_INVALID); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ARGUMENT_TYPE_INVALID); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java index 548ef01be4..813b5abc0e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CharmapNodes.java @@ -120,10 +120,10 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @Cached(inline = false) TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached(inline = false) HashingStorageSetItem setItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int len = Math.min(codePointLengthNode.execute(map, TS_ENCODING), 256); if (len == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } byte[] level1 = new byte[32]; byte[] level2 = new byte[512]; @@ -196,9 +196,9 @@ public abstract static class PyUnicodeEncodeCharmapNode extends Node { @Specialization static byte[] doLatin1(TruffleString src, TruffleString errors, PNone mapping, - @Cached(inline = false) PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // TODO latin1 - throw raiseNode.raise(NotImplementedError, toTruffleStringUncached("latin1")); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("latin1")); } @Fallback @@ -328,7 +328,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, int cp, Object mappi @Cached PyLongCheckNode pyLongCheckNode, @Cached PyLongAsLongNode pyLongAsLongNode, @Cached PyBytesCheckNode pyBytesCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object item; try { item = pyObjectGetItemNode.execute(frame, inliningTarget, mapping, cp); @@ -342,14 +342,14 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, int cp, Object mappi if (pyLongCheckNode.execute(inliningTarget, item)) { long value = pyLongAsLongNode.execute(frame, inliningTarget, item); if (value < 0 || value > 255) { - raiseNode.get(inliningTarget).raise(TypeError, CHARACTER_MAPPING_MUST_BE_IN_RANGE_256); + raiseNode.raise(inliningTarget, TypeError, CHARACTER_MAPPING_MUST_BE_IN_RANGE_256); } return value; } if (pyBytesCheckNode.execute(inliningTarget, item)) { return item; } - throw raiseNode.get(inliningTarget).raise(TypeError, CHARACTER_MAPPING_MUST_RETURN_INT_BYTES_OR_NONE_NOT_P, item); + throw raiseNode.raise(inliningTarget, TypeError, CHARACTER_MAPPING_MUST_RETURN_INT_BYTES_OR_NONE_NOT_P, item); } } @@ -463,7 +463,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff @Cached InlinedConditionProfile longValuesProfile, @Cached InlinedConditionProfile strValuesProfile, @Cached InlinedConditionProfile errProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // equivalent of charmap_decode_mapping PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); @@ -501,7 +501,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff break; } if (value < 0 || value > Character.MAX_CODE_POINT) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_BE_IN_RANGE, PInt.toHexString(Character.MAX_CODE_POINT + 1)); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_BE_IN_RANGE, PInt.toHexString(Character.MAX_CODE_POINT + 1)); } else { appendCodePointNode.execute(tsb, (int) value, 1, true); } @@ -518,7 +518,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff appendStringNode.execute(tsb, castToTruffleStringNode.execute(inliningTarget, item)); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_RETURN_INT_NONE_OR_STR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_RETURN_INT_NONE_OR_STR); } } } finally { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CodecsRegistry.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CodecsRegistry.java index 205bbde344..66ff758337 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CodecsRegistry.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CodecsRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -93,7 +93,7 @@ public abstract static class PyCodecLookupErrorNode extends Node { @Specialization static Object lookup(Node inliningTarget, TruffleString name, @Cached InlinedConditionProfile resultProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); ensureRegistryInitialized(context); if (name == null) { @@ -101,7 +101,7 @@ static Object lookup(Node inliningTarget, TruffleString name, } Object result = getErrorHandler(context, name); if (resultProfile.profile(inliningTarget, result == null)) { - throw raiseNode.get(inliningTarget).raise(LookupError, UNKNOWN_ERROR_HANDLER, name); + throw raiseNode.raise(inliningTarget, LookupError, UNKNOWN_ERROR_HANDLER, name); } return result; } @@ -124,9 +124,8 @@ static void register(Node inliningTarget, TruffleString name, Object handler, @Specialization(guards = "!callableCheckNode.execute(inliningTarget, handler)") static void registerNoCallable(@SuppressWarnings("unused") Node inliningTarget, @SuppressWarnings("unused") TruffleString name, @SuppressWarnings("unused") Object handler, - @SuppressWarnings("unused") @Cached @Shared("callableCheck") PyCallableCheckNode callableCheckNode, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, HANDLER_MUST_BE_CALLABLE); + @SuppressWarnings("unused") @Cached @Shared("callableCheck") PyCallableCheckNode callableCheckNode) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, HANDLER_MUST_BE_CALLABLE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java index 3c893aaced..112036bd11 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/ErrorHandlers.java @@ -258,8 +258,8 @@ static boolean isNeither(Node inliningTarget, Object o, PyObjectTypeCheck pyObje return !isDecode(inliningTarget, o, pyObjectTypeCheck) && !isEncode(inliningTarget, o, pyObjectTypeCheck) && !isTranslate(inliningTarget, o, pyObjectTypeCheck); } - static PException wrongExceptionType(Object o, PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DONT_KNOW_HOW_TO_HANDLE_P_IN_ERROR_CALLBACK, o); + static PException wrongExceptionType(Node inliningTarget, Object o) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DONT_KNOW_HOW_TO_HANDLE_P_IN_ERROR_CALLBACK, o); } } @@ -268,14 +268,14 @@ static PException wrongExceptionType(Object o, PRaiseNode raiseNode) { abstract static class StrictErrorHandlerNode extends ErrorHandlerBaseNode { @Specialization static Object doException(PBaseException exception, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseExceptionObject(exception); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseExceptionObject(inliningTarget, exception); } @Fallback static Object doFallback(@SuppressWarnings("unused") Object o, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CODEC_MUST_PASS_EXCEPTION_INSTANCE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CODEC_MUST_PASS_EXCEPTION_INSTANCE); } } @@ -303,9 +303,8 @@ static Object doEncodeOrTranslateException(PBaseException exception, @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -344,9 +343,8 @@ static Object doEncodeOrTranslateException(PBaseException exception, @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -384,9 +382,8 @@ static Object doEncode(PBaseException exception, @Specialization(guards = "!isEncode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -469,9 +466,8 @@ static Object doEncodeOrTranslateException(PBaseException exception, @Specialization(guards = "isNeither(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -522,9 +518,8 @@ static Object doEncode(PBaseException exception, @Specialization(guards = "!isEncode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -543,14 +538,14 @@ static Object doEncode(PBaseException exception, @Cached PyUnicodeEncodeErrorGetEncodingNode getEncodingNode, @Exclusive @Cached GetStandardEncodingNode getStandardEncodingNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); TruffleString src = getObjectNode.execute(inliningTarget, exception); TruffleString encodingName = getEncodingNode.execute(inliningTarget, exception); StandardEncoding encoding = getStandardEncodingNode.execute(inliningTarget, encodingName); if (encoding == StandardEncoding.UNKNOWN) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } if (start >= end) { return PFactory.createTuple(language, new Object[]{PFactory.createBytes(language, new byte[0]), end}); @@ -560,7 +555,7 @@ static Object doEncode(PBaseException exception, for (int i = start; i < end; ++i) { int cp = codePointAtIndexNode.execute(src, i, TS_ENCODING, ErrorHandling.BEST_EFFORT); if (!isSurrogate(cp)) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } encodeCodepoint(encoding, result, pos, cp); pos += encoding.byteLength; @@ -582,14 +577,14 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached TruffleString.FromCodePointNode fromCodePointNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int start = getStartNode.execute(inliningTarget, exception); getEndNode.execute(inliningTarget, exception); // called for side effects only Object object = getObjectNode.execute(inliningTarget, exception); TruffleString encodingName = getEncodingNode.execute(inliningTarget, exception); StandardEncoding encoding = getStandardEncodingNode.execute(inliningTarget, encodingName); if (encoding == StandardEncoding.UNKNOWN) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } Object srcBuf = acquireLib.acquireReadonly(object, frame, indirectCallData); try { @@ -599,7 +594,7 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, cp = decodeCodepoint(encoding, accessLib.getInternalOrCopiedByteArray(srcBuf), start); } if (!isSurrogate(cp)) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } return PFactory.createTuple(language, new Object[]{fromCodePointNode.execute(cp, TS_ENCODING, true), start + encoding.byteLength}); } finally { @@ -610,9 +605,8 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @Specialization(guards = "!isEncodeOrDecode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } private static void encodeCodepoint(StandardEncoding encoding, byte[] result, int pos, int cp) { @@ -678,7 +672,7 @@ static Object doEncode(PBaseException exception, @Cached PyUnicodeEncodeOrTranslateErrorGetStartNode getStartNode, @Cached PyUnicodeEncodeOrTranslateErrorGetEndNode getEndNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); TruffleString src = getObjectNode.execute(inliningTarget, exception); @@ -690,7 +684,7 @@ static Object doEncode(PBaseException exception, for (int i = start; i < end; ++i) { int cp = codePointAtIndexNode.execute(src, i, TS_ENCODING, ErrorHandling.BEST_EFFORT); if (cp < 0xdc80 || cp > 0xdcff) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } result[pos++] = (byte) (cp - 0xdc00); } @@ -710,7 +704,7 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int start = getStartNode.execute(inliningTarget, exception); int end = getEndNode.execute(inliningTarget, exception); Object object = getObjectNode.execute(inliningTarget, exception); @@ -728,7 +722,7 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, consumed++; } if (consumed == 0) { - throw raiseNode.get(inliningTarget).raiseExceptionObject(exception); + throw raiseNode.raiseExceptionObject(inliningTarget, exception); } return PFactory.createTuple(language, new Object[]{toStringNode.execute(tsb), start + consumed}); } finally { @@ -739,9 +733,8 @@ static Object doDecode(VirtualFrame frame, PBaseException exception, @Specialization(guards = "!isEncodeOrDecode(inliningTarget, o, pyObjectTypeCheck)", limit = "1") static Object doFallback(Object o, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck, - @Cached PRaiseNode raiseNode) { - throw wrongExceptionType(o, raiseNode); + @SuppressWarnings("unused") @Cached @Exclusive PyObjectTypeCheck pyObjectTypeCheck) { + throw wrongExceptionType(inliningTarget, o); } } @@ -861,9 +854,9 @@ static DecodingErrorHandlerResult doTuple(Node inliningTarget, PTuple result, @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @Cached CastToTruffleStringCheckedNode castToTruffleStringCheckedNode, @Cached CastToJavaIntExactNode castToJavaIntExactNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (lenNode.execute(inliningTarget, result) != 2) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); } Object[] array = getObjectArrayNode.execute(inliningTarget, result); TruffleString str = castToTruffleStringCheckedNode.cast(inliningTarget, array[0], ErrorMessages.DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); @@ -872,9 +865,8 @@ static DecodingErrorHandlerResult doTuple(Node inliningTarget, PTuple result, } @Fallback - static DecodingErrorHandlerResult doOther(@SuppressWarnings("unused") Object result, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); + static DecodingErrorHandlerResult doOther(Node inliningTarget, @SuppressWarnings("unused") Object result) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.DECODING_ERROR_HANDLER_MUST_RETURN_STR_INT_TUPLE); } } @@ -895,7 +887,7 @@ static DecodingErrorHandlerResult doIt(VirtualFrame frame, Node inliningTarget, @Cached ParseDecodingErrorHandlerResultNode parseResultNode, @Cached PyUnicodeDecodeErrorGetObjectNode getObjectNode, @Cached PyObjectSizeNode sizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { cache.errorHandlerObject = cache.errorHandlerObject == null ? lookupErrorNode.execute(inliningTarget, errors) : cache.errorHandlerObject; cache.exceptionObject = makeDecodeExceptionNode.execute(frame, inliningTarget, cache.exceptionObject, encoding, srcObj, startPos, endPos, reason); Object resultObj = callNode.execute(frame, cache.errorHandlerObject, cache.exceptionObject); @@ -932,9 +924,9 @@ static EncodingErrorHandlerResult doTuple(Node inliningTarget, PTuple result, @Cached CastToJavaIntExactNode castToJavaIntExactNode, @Cached PyUnicodeCheckNode pyUnicodeCheckNode, @Cached PyBytesCheckNode pyBytesCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (lenNode.execute(inliningTarget, result) != 2) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); } Object[] array = getObjectArrayNode.execute(inliningTarget, result); boolean isUnicode; @@ -943,16 +935,15 @@ static EncodingErrorHandlerResult doTuple(Node inliningTarget, PTuple result, } else if (pyBytesCheckNode.execute(inliningTarget, array[0])) { isUnicode = false; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); } int pos = castToJavaIntExactNode.execute(inliningTarget, array[1]); return new EncodingErrorHandlerResult(array[0], pos, isUnicode); } @Fallback - static EncodingErrorHandlerResult doOther(@SuppressWarnings("unused") Object result, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); + static EncodingErrorHandlerResult doOther(Node inliningTarget, @SuppressWarnings("unused") Object result) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ENCODING_ERROR_HANDLER_MUST_RETURN_STR_BYTES_INT_TUPLE); } } @@ -972,7 +963,7 @@ static EncodingErrorHandlerResult doIt(VirtualFrame frame, Node inliningTarget, @Cached(inline = false) CallNode callNode, @Cached ParseEncodingErrorHandlerResultNode parseResultNode, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { cache.errorHandlerObject = cache.errorHandlerObject == null ? lookupErrorNode.execute(inliningTarget, errors) : cache.errorHandlerObject; int len = codePointLengthNode.execute(srcObj, TS_ENCODING); cache.exceptionObject = makeEncodeExceptionNode.execute(frame, inliningTarget, cache.exceptionObject, encoding, srcObj, startPos, endPos, reason); @@ -993,18 +984,18 @@ abstract static class RaiseEncodeException extends Node { @Specialization static void doIt(VirtualFrame frame, Node inliningTarget, ErrorHandlerCache cache, TruffleString encoding, TruffleString srcObj, int startPos, int endPos, TruffleString reason, @Cached MakeEncodeExceptionNode makeEncodeExceptionNode, - @Cached(inline = false) PRaiseNode raiseNode) { + @Cached PRaiseNode raiseNode) { cache.exceptionObject = makeEncodeExceptionNode.execute(frame, inliningTarget, cache.exceptionObject, encoding, srcObj, startPos, endPos, reason); raiseNode.raiseExceptionObject(cache.exceptionObject); } } - private static int adjustAndCheckPos(int newPos, int len, Node inliningTarget, PRaiseNode.Lazy raiseNode) { + private static int adjustAndCheckPos(int newPos, int len, Node inliningTarget, PRaiseNode raiseNode) { if (newPos < 0) { newPos += len; } if (newPos < 0 || newPos > len) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newPos); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.POSITION_D_FROM_ERROR_HANDLER_OUT_OF_BOUNDS, newPos); } return newPos; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java index 3361d93597..371d09f82a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVModuleBuiltins.java @@ -165,12 +165,12 @@ static PNone register(VirtualFrame frame, PythonModule module, Object nameObj, O @Cached ReadAttributeFromObjectNode readNode, @Cached CallNode callNode, @Cached PyDictSetItem setItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString name; try { name = nameNode.execute(inliningTarget, nameObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_STRING, "dialect name"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_STRING, "dialect name"); } Object result = callNode.execute(frame, PythonBuiltinClassType.CSVDialect, new Object[]{dialectObj}, keywords); @@ -195,7 +195,7 @@ static PNone unregister(VirtualFrame frame, PythonModule module, Object nameObj, @Cached ReadAttributeFromObjectNode readNode, @Cached PyDictDelItem delItem, @Cached HashingStorageGetItem getItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // TODO GR-38165: unchecked cast to PDict PDict dialects = (PDict) readNode.execute(module, T__DIALECTS); @@ -203,7 +203,7 @@ static PNone unregister(VirtualFrame frame, PythonModule module, Object nameObj, if (getItem.hasKey(frame, inliningTarget, (dialects).getDictStorage(), nameObj)) { delItem.execute(frame, inliningTarget, dialects, nameObj); } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.UNKNOWN_DIALECT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.UNKNOWN_DIALECT); } return PNone.NONE; @@ -227,7 +227,7 @@ static CSVDialect get(VirtualFrame frame, PythonModule module, Object nameObj, @Bind("this") Node inliningTarget, @Cached PyDictGetItem getItemNode, @Cached ReadAttributeFromObjectNode readNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // TODO GR-38165: unchecked cast to PDict PDict dialects = (PDict) readNode.execute(module, T__DIALECTS); @@ -235,7 +235,7 @@ static CSVDialect get(VirtualFrame frame, PythonModule module, Object nameObj, CSVDialect dialect = (CSVDialect) getItemNode.execute(frame, inliningTarget, dialects, nameObj); if (dialect == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.UNKNOWN_DIALECT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.UNKNOWN_DIALECT); } return dialect; @@ -281,10 +281,10 @@ static Object createReader(VirtualFrame frame, Object outputFile, Object dialect @Cached PyObjectLookupAttr lookupAttr, @Cached PyCallableCheckNode checkCallable, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object write = lookupAttr.execute(frame, inliningTarget, outputFile, T_WRITE); if (write == PNone.NO_VALUE || !checkCallable.execute(inliningTarget, write)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_MUST_HAVE_WRITE_METHOD, "argument 1"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_MUST_HAVE_WRITE_METHOD, "argument 1"); } CSVDialect dialect = (CSVDialect) callNode.execute(frame, PythonBuiltinClassType.CSVDialect, new Object[]{dialectObj}, kwargs); return PFactory.createCSVWriter(language, write, dialect); @@ -303,13 +303,13 @@ static long getOrSetFieldSizeLimit(VirtualFrame frame, PythonModule self, Object @Bind("this") Node inliningTarget, @Cached PyLongCheckExactNode checkLongNode, @Cached PyLongAsLongNode castToLong, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { CSVModuleBuiltins csvModuleBuiltins = (CSVModuleBuiltins) self.getBuiltins(); long oldLimit = csvModuleBuiltins.fieldLimit; if (newLimit != PNone.NO_VALUE) { if (!checkLongNode.execute(inliningTarget, newLimit)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_INTEGER, "limit"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_INTEGER, "limit"); } csvModuleBuiltins.fieldLimit = castToLong.execute(frame, inliningTarget, newLimit); } @@ -346,7 +346,7 @@ static Object doNoDialectObj(VirtualFrame frame, PythonBuiltinClassType cls, @Su @Exclusive @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached PyLongCheckExactNode pyLongCheckExactNode, @Exclusive @Cached PyLongAsIntNode pyLongAsIntNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return createCSVDialect(frame, inliningTarget, cls, delimiterObj, doublequoteObj, escapecharObj, lineterminatorObj, quotecharObj, quotingObj, skipinitialspaceObj, strictObj, isTrueNode, pyLongCheckExactNode, pyLongAsIntNode, raiseNode); } @@ -359,7 +359,7 @@ static Object doStringWithKeywords(VirtualFrame frame, PythonBuiltinClassType cl @Exclusive @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached PyLongCheckExactNode pyLongCheckExactNode, @Exclusive @Cached PyLongAsIntNode pyLongAsIntNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PythonModule module = PythonContext.get(inliningTarget).lookupBuiltinModule(T__CSV); CSVDialect dialectObj = getDialect.execute(frame, module, dialectName); @@ -402,7 +402,7 @@ static Object doDialectClassWithKeywords(VirtualFrame frame, PythonBuiltinClassT @Exclusive @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached PyLongCheckExactNode pyLongCheckExactNode, @Exclusive @Cached PyLongAsIntNode pyLongAsIntNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { // We use multiple AttributeNodes to be able to cache all attributes as current // CACHE_SIZE is 3. @@ -428,7 +428,7 @@ static Object doPStringWithKeywords(VirtualFrame frame, PythonBuiltinClassType c @Exclusive @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached PyLongCheckExactNode pyLongCheckExactNode, @Exclusive @Cached PyLongAsIntNode pyLongAsIntNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString dialectNameStr = castToStringNode.execute(inliningTarget, dialectName); PythonModule module = PythonContext.get(inliningTarget).lookupBuiltinModule(T__CSV); @@ -473,7 +473,7 @@ static Object doGeneric(VirtualFrame frame, PythonBuiltinClassType cls, Object d @Exclusive @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached PyLongCheckExactNode pyLongCheckExactNode, @Exclusive @Cached PyLongAsIntNode pyLongAsIntNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { delimiterObj = getAttributeValue(frame, inliningTarget, dialectObj, delimiterObj, T_ATTR_DELIMITER, getFirstAttributesNode); doublequoteObj = getAttributeValue(frame, inliningTarget, dialectObj, doublequoteObj, T_ATTR_DOUBLEQUOTE, getFirstAttributesNode); @@ -494,7 +494,7 @@ protected static boolean isCSVDialect(Object dialect) { private static Object createCSVDialect(VirtualFrame frame, Node inliningTarget, PythonBuiltinClassType cls, Object delimiterObj, Object doublequoteObj, Object escapecharObj, Object lineterminatorObj, Object quotecharObj, Object quotingObj, Object skipinitialspaceObj, Object strictObj, - PyObjectIsTrueNode isTrueNode, PyLongCheckExactNode pyLongCheckExactNode, PyLongAsIntNode pyLongAsIntNode, PRaiseNode.Lazy raiseNode) { + PyObjectIsTrueNode isTrueNode, PyLongCheckExactNode pyLongCheckExactNode, PyLongAsIntNode pyLongAsIntNode, PRaiseNode raiseNode) { TruffleString delimiter = getChar(inliningTarget, T_ATTR_DELIMITER, delimiterObj, T_COMMA, false); boolean doubleQuote = getBoolean(frame, doublequoteObj, true, isTrueNode); TruffleString escapeChar = getChar(inliningTarget, T_ATTR_ESCAPECHAR, escapecharObj, T_NOT_SET, true); @@ -513,15 +513,15 @@ private static Object createCSVDialect(VirtualFrame frame, Node inliningTarget, private static Object createCSVDialect(Node raisingNode, PythonBuiltinClassType cls, TruffleString delimiter, boolean doubleQuote, TruffleString escapeChar, TruffleString lineTerminator, TruffleString quoteChar, QuoteStyle quoting, boolean skipInitialSpace, boolean strict) { if (TruffleString.EqualNode.getUncached().execute(delimiter, T_NOT_SET, TS_ENCODING)) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.DELIMITER_MUST_BE_ONE_CHAR_STRING); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.DELIMITER_MUST_BE_ONE_CHAR_STRING); } if (quoting != QUOTE_NONE && TruffleString.EqualNode.getUncached().execute(quoteChar, T_NOT_SET, TS_ENCODING)) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.QUOTECHAR_MUST_BE_SET_IF_QUOTING_ENABLED); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.QUOTECHAR_MUST_BE_SET_IF_QUOTING_ENABLED); } if (lineTerminator == null) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.LINETERMINATOR_MUST_BE_SET); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.LINETERMINATOR_MUST_BE_SET); } // delimiter cannot be NOT_SET @@ -557,8 +557,8 @@ private static TruffleString getChar(Node raisingNode, TruffleString name, Objec try { charValue = CastToTruffleStringNode.executeUncached(valueObj); } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, optional ? ErrorMessages.S_MUST_BE_STRING_OR_NONE_NOT_S : ErrorMessages.S_MUST_BE_STRING_NOT_S, name, - GetClassNode.executeUncached(valueObj)); + TruffleString format = optional ? ErrorMessages.S_MUST_BE_STRING_OR_NONE_NOT_S : ErrorMessages.S_MUST_BE_STRING_NOT_S; + throw PRaiseNode.raiseStatic(raisingNode, TypeError, format, name, GetClassNode.executeUncached(valueObj)); } if (optional && TruffleString.EqualNode.getUncached().execute(charValue, T_NOT_SET, TS_ENCODING)) { @@ -566,7 +566,7 @@ private static TruffleString getChar(Node raisingNode, TruffleString name, Objec } if (TruffleString.CodePointLengthNode.getUncached().execute(charValue, TS_ENCODING) != 1) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.MUST_BE_ONE_CHARACTER_STRING, name); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.MUST_BE_ONE_CHARACTER_STRING, name); } return charValue; @@ -595,14 +595,14 @@ private static TruffleString getString(Node raisingNode, TruffleString attribute try { value = CastToTruffleStringNode.executeUncached(valueObj); } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.MUST_BE_STRING_QUOTED, attribute); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.MUST_BE_STRING_QUOTED, attribute); } return value; } private static QuoteStyle getQuotingValue(VirtualFrame frame, Node inliningTarget, TruffleString name, Object valueObj, QuoteStyle defaultValue, - PyLongCheckExactNode pyLongCheckExactNode, PyLongAsIntNode pyLongAsIntNode, PRaiseNode.Lazy raiseNode) { + PyLongCheckExactNode pyLongCheckExactNode, PyLongAsIntNode pyLongAsIntNode, PRaiseNode raiseNode) { if (valueObj == PNone.NO_VALUE) { return defaultValue; @@ -613,13 +613,13 @@ private static QuoteStyle getQuotingValue(VirtualFrame frame, Node inliningTarge } if (!pyLongCheckExactNode.execute(inliningTarget, valueObj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_INTEGER_QUOTED_ATTR, name); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_INTEGER_QUOTED_ATTR, name); } int value = pyLongAsIntNode.execute(frame, inliningTarget, valueObj); if (!QuoteStyle.containsOrdinalValue(value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_QUOTING_VALUE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_QUOTING_VALUE); } return QuoteStyle.getQuoteStyle(value); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java index 8ee12c5684..8a5394ec37 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java @@ -132,7 +132,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self, @Cached GetClassNode getClassNode, @Cached IsBuiltinObjectProfile isBuiltinClassProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PList fields = PFactory.createList(language); CSVModuleBuiltins csvModuleBuiltins = (CSVModuleBuiltins) PythonContext.get(inliningTarget).lookupBuiltinModule(T__CSV).getBuiltins(); self.parseReset(); @@ -145,7 +145,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self, self.fieldLimit = csvModuleBuiltins.fieldLimit; if (!self.field.isEmpty() || self.state == IN_QUOTED_FIELD) { if (self.dialect.strict) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.UNEXPECTED_END_OF_DATA); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.UNEXPECTED_END_OF_DATA); } else { try { parseSaveField(inliningTarget, self, fields, toStringNode, pyNumberFloatNode, appendNode); @@ -155,7 +155,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self, break; } } - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } self.fieldLimit = csvModuleBuiltins.fieldLimit; @@ -163,7 +163,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self, try { line = castToStringNode.execute(inliningTarget, lineObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.WRONG_ITERATOR_RETURN_TYPE, getClassNode.execute(inliningTarget, lineObj)); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.WRONG_ITERATOR_RETURN_TYPE, getClassNode.execute(inliningTarget, lineObj)); } self.lineNum++; @@ -180,7 +180,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self, @SuppressWarnings("fallthrough") private static void parseProcessCodePoint(Node inliningTarget, CSVReader self, PList fields, int codePoint, AppendCodePointNode appendCodePointNode, ToStringNode toStringNode, - PyNumberFloatNode pyNumberFloatNode, AppendNode appendNode, PRaiseNode.Lazy raiseNode) { + PyNumberFloatNode pyNumberFloatNode, AppendNode appendNode, PRaiseNode raiseNode) { CSVDialect dialect = self.dialect; switch (self.state) { @@ -315,7 +315,7 @@ private static void parseProcessCodePoint(Node inliningTarget, CSVReader self, P self.state = IN_FIELD; } else { /* illegal */ - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.S_EXPECTED_AFTER_S, dialect.delimiter, dialect.quoteChar); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.S_EXPECTED_AFTER_S, dialect.delimiter, dialect.quoteChar); } break; @@ -325,7 +325,7 @@ private static void parseProcessCodePoint(Node inliningTarget, CSVReader self, P } else if (codePoint == EOL) { self.state = START_RECORD; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.NEWLINE_IN_UNQOUTED_FIELD); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.NEWLINE_IN_UNQOUTED_FIELD); } break; } @@ -342,11 +342,11 @@ private static void parseSaveField(Node inliningTarget, CSVReader self, PList fi } } - private static void parseAddCodePoint(Node inliningTarget, CSVReader self, int codePoint, TruffleStringBuilder.AppendCodePointNode appendCodePointNode, PRaiseNode.Lazy raise) { + private static void parseAddCodePoint(Node inliningTarget, CSVReader self, int codePoint, TruffleStringBuilder.AppendCodePointNode appendCodePointNode, PRaiseNode raise) { assert TS_ENCODING == TruffleString.Encoding.UTF_32; int cpLen = self.field.byteLength() / 4; // assumes UTF-32 if (cpLen + 1 > self.fieldLimit) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.LARGER_THAN_FIELD_SIZE_LIMIT, self.fieldLimit); + throw raise.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.LARGER_THAN_FIELD_SIZE_LIMIT, self.fieldLimit); } appendCodePointNode.execute(self.field, codePoint, 1, true); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java index 1a11fd9916..498c5edcea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -103,14 +103,14 @@ static Object doIt(VirtualFrame frame, CSVWriter self, Object seq, @Cached PyNumberCheckNode pyNumberCheckNode, @Cached GetNextNode getNextNode, @Cached IsBuiltinObjectProfile isBuiltinClassProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object iter; try { iter = getIter.execute(frame, inliningTarget, seq); } catch (PException e) { e.expect(inliningTarget, PythonBuiltinClassType.TypeError, errorProfile); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.EXPECTED_ITERABLE_NOT_S, getClass.execute(inliningTarget, seq)); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.EXPECTED_ITERABLE_NOT_S, getClass.execute(inliningTarget, seq)); } // Join all fields of passed in sequence in internal buffer. @@ -135,7 +135,7 @@ static Object doIt(VirtualFrame frame, CSVWriter self, Object seq, } if (!first && sb.isEmpty()) { if (dialect.quoting == QUOTE_NONE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.EMPTY_FIELD_RECORD_MUST_BE_QUOTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.EMPTY_FIELD_RECORD_MUST_BE_QUOTED); } joinAppend(inliningTarget, sb, dialect, null, true, createCodePointIteratorNode, nextNode, byteIndexOfCodePointNode, appendCodePointNode, appendStringNode, raiseNode); } @@ -146,7 +146,7 @@ static Object doIt(VirtualFrame frame, CSVWriter self, Object seq, private static void joinField(Node inliningTarget, TruffleStringBuilder sb, CSVDialect dialect, Object field, TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, TruffleStringIterator.NextNode nextNode, TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode, TruffleStringBuilder.AppendCodePointNode appendCodePointNode, TruffleStringBuilder.AppendStringNode appendStringNode, PyObjectStrAsTruffleStringNode objectStrAsTruffleStringNode, PyNumberCheckNode pyNumberCheckNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { boolean quoted; switch (dialect.quoting) { @@ -171,7 +171,7 @@ private static void joinField(Node inliningTarget, TruffleStringBuilder sb, CSVD private static void joinAppend(Node inliningTarget, TruffleStringBuilder sb, CSVDialect dialect, TruffleString field, boolean quoted, TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, TruffleStringIterator.NextNode nextNode, TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode, - TruffleStringBuilder.AppendCodePointNode appendCodePointNode, TruffleStringBuilder.AppendStringNode appendStringNode, PRaiseNode.Lazy raiseNode) { + TruffleStringBuilder.AppendCodePointNode appendCodePointNode, TruffleStringBuilder.AppendStringNode appendStringNode, PRaiseNode raiseNode) { /* * If we don't already know that the field must be quoted due to dialect settings, check * if the field contains characters due to which it must be quoted. @@ -214,7 +214,7 @@ private static void joinAppend(Node inliningTarget, TruffleStringBuilder sb, CSV } if (wantEscape) { if (dialect.escapeCharCodePoint == NOT_SET_CODEPOINT) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.CSVError, ErrorMessages.ESCAPE_WITHOUT_ESCAPECHAR); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.ESCAPE_WITHOUT_ESCAPECHAR); } appendStringNode.execute(sb, dialect.escapeChar); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java index 6381bad907..2751615735 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataBuiltins.java @@ -158,8 +158,8 @@ static Object PyCData_from_outparam(CDataObject self) { protected abstract static class HashNode extends PythonBuiltinNode { @Specialization static long hash(@SuppressWarnings("unused") CDataObject self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, UNHASHABLE_TYPE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, UNHASHABLE_TYPE); } } @@ -176,10 +176,10 @@ static Object reduce(VirtualFrame frame, CDataObject self, @Cached ReadAttributeFromPythonObjectNode readAttrNode, @Cached PointerNodes.ReadBytesNode readBytesNode, @Cached GetClassNode getClassNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject stgDict = pyObjectStgDictNode.execute(inliningTarget, self); if ((stgDict.flags & (TYPEFLAG_ISPOINTER | TYPEFLAG_HASPOINTER)) != 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, CTYPES_OBJECTS_CONTAINING_POINTERS_CANNOT_BE_PICKLED); + throw raiseNode.raise(inliningTarget, ValueError, CTYPES_OBJECTS_CONTAINING_POINTERS_CANNOT_BE_PICKLED); } Object dict = getAttributeNode.executeObject(frame, self); Object[] t1 = new Object[]{dict, null}; @@ -190,7 +190,7 @@ static Object reduce(VirtualFrame frame, CDataObject self, Object unpickle = readAttrNode.execute(ctypes, T_UNPICKLE, null); if (unpickle == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, toTruffleStringUncached("unpickle isn't supported yet.")); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("unpickle isn't supported yet.")); } Object[] t3 = new Object[]{unpickle, PFactory.createTuple(language, t2)}; return PFactory.createTuple(language, t3); // "O(O(NN))" @@ -211,11 +211,11 @@ static Object PyCData_setstate(VirtualFrame frame, CDataObject self, PTuple args @Cached GetNameNode getNameNode, @Cached PyNumberAsSizeNode asSizeNode, @Cached HashingStorageAddAllToOther addAllToOtherNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = args.getSequenceStorage(); Object[] array = getArray.execute(inliningTarget, storage); if (storage.length() < 3 || !PGuards.isDict(array[0]) || !PGuards.isInteger(array[2])) { - throw raiseNode.get(inliningTarget).raise(TypeError); + throw raiseNode.raise(inliningTarget, TypeError); } PDict dict = (PDict) array[0]; Object data = array[1]; @@ -228,7 +228,7 @@ static Object PyCData_setstate(VirtualFrame frame, CDataObject self, PTuple args memmove(inliningTarget, self.b_ptr, data, len); Object mydict = getAttributeNode.executeObject(frame, self); if (!PGuards.isDict(mydict)) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_DICT_MUST_BE_A_DICTIONARY_NOT_S, + throw raiseNode.raise(inliningTarget, TypeError, S_DICT_MUST_BE_A_DICTIONARY_NOT_S, getNameNode.execute(inliningTarget, getClassNode.execute(inliningTarget, self)), getNameNode.execute(inliningTarget, getClassNode.execute(inliningTarget, mydict))); } @@ -240,7 +240,7 @@ static Object PyCData_setstate(VirtualFrame frame, CDataObject self, PTuple args @SuppressWarnings("unused") private static void memmove(Node raisingNode, Object dest, Object src, int len) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(raisingNode, NotImplementedError, toTruffleStringUncached("memmove is partially supported.")); // TODO + throw PRaiseNode.raiseStatic(raisingNode, NotImplementedError, toTruffleStringUncached("memmove is partially supported.")); // TODO } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java index 878c21408f..61dfe2cc68 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeBuiltins.java @@ -157,7 +157,7 @@ static Object CDataType_from_param(VirtualFrame frame, Object type, Object value @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectLookupAttr lookupAttr, @Cached IsInstanceNode isInstanceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isInstanceNode.executeWith(frame, value, type)) { return value; } @@ -175,7 +175,7 @@ static Object CDataType_from_param(VirtualFrame frame, Object type, Object value return value; } } - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_P_INSTANCE_INSTEAD_OF_POINTER_TO_P, type, ob != null ? ob : PNone.NONE); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_P_INSTANCE_INSTEAD_OF_POINTER_TO_P, type, ob != null ? ob : PNone.NONE); } Object as_parameter = lookupAttr.execute(frame, inliningTarget, value, T__AS_PARAMETER_); @@ -184,7 +184,7 @@ static Object CDataType_from_param(VirtualFrame frame, Object type, Object value return CDataType_from_param(frame, type, as_parameter, inliningTarget, pyTypeStgDictNode, lookupAttr, isInstanceNode, raiseNode); } - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_P_INSTANCE_INSTEAD_OF_P, type, value); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_P_INSTANCE_INSTEAD_OF_P, type, value); } } @@ -232,25 +232,25 @@ static Object CDataType_from_buffer(VirtualFrame frame, Object type, Object obj, @Cached PyCDataAtAddress atAddress, @Cached KeepRefNode keepRefNode, @Cached AuditNode auditNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); PMemoryView mv = memoryViewNode.execute(frame, obj); if (mv.isReadOnly()) { - throw raiseNode.get(inliningTarget).raise(TypeError, UNDERLYING_BUFFER_IS_NOT_WRITABLE); + throw raiseNode.raise(inliningTarget, TypeError, UNDERLYING_BUFFER_IS_NOT_WRITABLE); } if (!mv.isCContiguous()) { - throw raiseNode.get(inliningTarget).raise(TypeError, UNDERLYING_BUFFER_IS_NOT_C_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, TypeError, UNDERLYING_BUFFER_IS_NOT_C_CONTIGUOUS); } if (offset < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, OFFSET_CANNOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, OFFSET_CANNOT_BE_NEGATIVE); } if (dict.size > mv.getLength() - offset) { - throw raiseNode.get(inliningTarget).raise(ValueError, BUFFER_SIZE_TOO_SMALL_D_INSTEAD_OF_AT_LEAST_D_BYTES, mv.getLength(), dict.size + offset); + throw raiseNode.raise(inliningTarget, ValueError, BUFFER_SIZE_TOO_SMALL_D_INSTEAD_OF_AT_LEAST_D_BYTES, mv.getLength(), dict.size + offset); } auditNode.audit(inliningTarget, "ctypes.cdata/buffer", mv, mv.getLength(), offset); @@ -283,18 +283,18 @@ static Object CDataType_from_buffer_copy(Object type, Object buffer, int offset, @Cached AuditNode auditNode, @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); if (offset < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, OFFSET_CANNOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, OFFSET_CANNOT_BE_NEGATIVE); } int bufferLen = bufferLib.getBufferLength(buffer); if (dict.size > bufferLen - offset) { - throw raiseNode.get(inliningTarget).raise(ValueError, BUFFER_SIZE_TOO_SMALL_D_INSTEAD_OF_AT_LEAST_D_BYTES, bufferLen, dict.size + offset); + throw raiseNode.raise(inliningTarget, ValueError, BUFFER_SIZE_TOO_SMALL_D_INSTEAD_OF_AT_LEAST_D_BYTES, bufferLen, dict.size + offset); } // This prints the raw pointer in C, so just print 0 @@ -332,17 +332,17 @@ static Object CDataType_in_dll(VirtualFrame frame, Object type, Object dll, Truf @Cached AuditNode auditNode, @Cached PointerNodes.PointerFromLongNode pointerFromLongNode, @Cached CtypesDlSymNode dlSymNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { auditNode.audit(inliningTarget, "ctypes.dlsym", dll, name); Object obj = getAttributeNode.executeObject(frame, dll); if (!longCheckNode.execute(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, THE_HANDLE_ATTRIBUTE_OF_THE_SECOND_ARGUMENT_MUST_BE_AN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, THE_HANDLE_ATTRIBUTE_OF_THE_SECOND_ARGUMENT_MUST_BE_AN_INTEGER); } Pointer handlePtr; try { handlePtr = pointerFromLongNode.execute(inliningTarget, obj); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.COULD_NOT_CONVERT_THE_HANDLE_ATTRIBUTE_TO_A_POINTER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COULD_NOT_CONVERT_THE_HANDLE_ATTRIBUTE_TO_A_POINTER); } Object address = dlSymNode.execute(frame, handlePtr, name, ValueError); if (address instanceof PythonNativeVoidPtr ptr) { @@ -366,7 +366,7 @@ static CDataObject PyCData_AtAddress(Object type, Pointer pointer, @Cached PyTypeCheck pyTypeCheck, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CtypesNodes.CreateCDataObjectNode createCDataObjectNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // auditNode.audit("ctypes.cdata", buf); // assert(PyType_Check(type)); StgDictObject stgdict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); @@ -431,9 +431,9 @@ static void PyCData_set(VirtualFrame frame, CDataObject dst, Object type, FieldS @Cached KeepRefNode keepRefNode, @Cached PointerNodes.MemcpyNode memcpyNode, @Cached PointerNodes.WritePointerNode writePointerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, dst)) { - throw raiseNode.get(inliningTarget).raise(TypeError, NOT_A_CTYPE_INSTANCE); + throw raiseNode.raise(inliningTarget, TypeError, NOT_A_CTYPE_INSTANCE); } Object result = PyCDataSetInternal(frame, inliningTarget, type, setfunc, value, size, ptr, @@ -465,7 +465,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object PyObjectStgDictNode pyObjectStgDictNode, PointerNodes.MemcpyNode memcpyNode, PointerNodes.WritePointerNode writePointerNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (setfunc != FieldSet.nil) { return setFuncNode.execute(frame, setfunc, ptr, value, size); } @@ -495,7 +495,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object writePointerNode.execute(inliningTarget, ptr, Pointer.NULL); return PNone.NONE; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_P_INSTANCE_GOT_P, type, value); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_P_INSTANCE_GOT_P, type, value); } } CDataObject src = (CDataObject) value; @@ -512,7 +512,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object assert p2 != null : "Cannot be NULL for pointer types"; if (p1.proto != p2.proto) { - throw raiseNode.get(inliningTarget).raise(TypeError, INCOMPATIBLE_TYPES_P_INSTANCE_INSTEAD_OF_P_INSTANCE, value, type); + throw raiseNode.raise(inliningTarget, TypeError, INCOMPATIBLE_TYPES_P_INSTANCE_INSTEAD_OF_P_INSTANCE, value, type); } writePointerNode.execute(inliningTarget, ptr, src.b_ptr); @@ -528,7 +528,7 @@ static Object PyCDataSetInternal(VirtualFrame frame, Node inliningTarget, Object */ return PFactory.createTuple(language, new Object[]{keep, value}); } - throw raiseNode.get(inliningTarget).raise(TypeError, INCOMPATIBLE_TYPES_P_INSTANCE_INSTEAD_OF_P_INSTANCE, value, type); + throw raiseNode.raise(inliningTarget, TypeError, INCOMPATIBLE_TYPES_P_INSTANCE_INSTEAD_OF_P_INSTANCE, value, type); } } @@ -591,7 +591,7 @@ static void KeepRef(VirtualFrame frame, Node inliningTarget, CDataObject target, @Cached(inline = false) TruffleStringBuilder.ToStringNode toStringNode, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, @Cached HashingStorageSetItem setItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { CDataObject ob = PyCData_GetContainer(target, language); if (!PGuards.isDict(ob.b_objects)) { ob.b_objects = keep; @@ -606,7 +606,7 @@ static void KeepRef(VirtualFrame frame, Node inliningTarget, CDataObject target, private static final int MAX_KEY_SIZE = 256; static TruffleString unique_key(Node inliningTarget, CDataObject cdata, int index, - PRaiseNode.Lazy raiseNode, TruffleStringBuilder.AppendStringNode appendStringNode, + PRaiseNode raiseNode, TruffleStringBuilder.AppendStringNode appendStringNode, TruffleStringBuilder.ToStringNode toStringNode, TruffleString.FromJavaStringNode fromJavaStringNode) { assert TS_ENCODING == Encoding.UTF_32; final int bytesPerCodepoint = 4; // assumes utf-32 @@ -618,7 +618,7 @@ static TruffleString unique_key(Node inliningTarget, CDataObject cdata, int inde int bytesLeft = MAX_KEY_SIZE - sb.byteLength() / bytesPerCodepoint - 1; /* Hex format needs 2 characters per byte */ if (bytesLeft < Integer.BYTES * 2) { - throw raiseNode.get(inliningTarget).raise(ValueError, CTYPES_OBJECT_STRUCTURE_TOO_DEEP); + throw raiseNode.raise(inliningTarget, ValueError, CTYPES_OBJECT_STRUCTURE_TOO_DEEP); } appendStringNode.execute(sb, T_COLON); appendStringNode.execute(sb, fromJavaStringNode.execute(toHex(target.b_index), TS_ENCODING)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java index 1602d3d3ed..c522f5fee0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CDataTypeSequenceBuiltins.java @@ -118,7 +118,7 @@ static Object PyCArrayType_from_ctype(VirtualFrame frame, Object itemtype, int l @Cached GetNameNode getNameNode, @Cached SimpleTruffleStringFormatNode simpleFormatNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object key = PFactory.createTuple(language, new Object[]{itemtype, length}); CtypesThreadState ctypes = CtypesThreadState.get(context, context.getLanguage(inliningTarget)); Object result = getItem.execute(frame, inliningTarget, ctypes.cache, key); @@ -127,7 +127,7 @@ static Object PyCArrayType_from_ctype(VirtualFrame frame, Object itemtype, int l } if (!isTypeNode.execute(inliningTarget, itemtype)) { - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_A_TYPE_OBJECT); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_A_TYPE_OBJECT); } TruffleString name = simpleFormatNode.format("%s_Array_%d", getNameNode.execute(inliningTarget, itemtype), length); PDict dict = PFactory.createDict(language, new PKeyword[]{new PKeyword(T__LENGTH_, length), new PKeyword(T__TYPE_, itemtype)}); @@ -140,8 +140,8 @@ static Object PyCArrayType_from_ctype(VirtualFrame frame, Object itemtype, int l @Specialization(guards = "length < 0") static Object error(@SuppressWarnings("unused") Object self, int length, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ARRAY_LENGTH_MUST_BE_0_NOT_D, length); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ARRAY_LENGTH_MUST_BE_0_NOT_D, length); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java index 593e499b8d..cc37e4ce67 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java @@ -154,9 +154,9 @@ static void doit(VirtualFrame frame, CFieldObject self, Object inst, Object valu @Bind("this") Node inliningTarget, @Cached PyTypeCheck pyTypeCheck, @Cached PyCDataSetNode cDataSetNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, inst)) { - throw raiseNode.get(inliningTarget).raise(TypeError, NOT_A_CTYPE_INSTANCE); + throw raiseNode.raise(inliningTarget, TypeError, NOT_A_CTYPE_INSTANCE); } CDataObject dst = (CDataObject) inst; cDataSetNode.execute(frame, dst, self.proto, self.setfunc, value, self.index, self.size, dst.b_ptr.withOffset(self.offset)); @@ -165,8 +165,8 @@ static void doit(VirtualFrame frame, CFieldObject self, Object inst, Object valu @Specialization(guards = "isNoValue(value)") @InliningCutoff static void doit(CFieldObject self, Object inst, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, CANT_DELETE_ATTRIBUTE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, CANT_DELETE_ATTRIBUTE); } } @@ -181,12 +181,12 @@ static Object doit(CFieldObject self, Object inst, @SuppressWarnings("unused") O @Cached InlinedConditionProfile instIsNoValueProfile, @Cached PyCDataGetNode pyCDataGetNode, @Cached PyTypeCheck pyTypeCheck, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (instIsNoValueProfile.profile(inliningTarget, inst == PNone.NO_VALUE)) { return self; } if (!pyTypeCheck.isCDataObject(inliningTarget, inst)) { - throw raiseNode.get(inliningTarget).raise(TypeError, NOT_A_CTYPE_INSTANCE); + throw raiseNode.raise(inliningTarget, TypeError, NOT_A_CTYPE_INSTANCE); } CDataObject src = (CDataObject) inst; return pyCDataGetNode.execute(inliningTarget, self.proto, self.getfunc, src, self.index, self.size, src.b_ptr.withOffset(self.offset)); @@ -245,11 +245,11 @@ static CFieldObject PyCField_FromDesc(Node inliningTarget, Object desc, int inde @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, @Cached PyTypeStgDictNode pyTypeStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { CFieldObject self = PFactory.createCFieldObject(language); StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, desc); if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, HAS_NO_STGINFO); + throw raiseNode.raise(inliningTarget, TypeError, HAS_NO_STGINFO); } int fieldtype; if (bitsize != 0 /* this is a bitfield request */ @@ -289,7 +289,7 @@ static CFieldObject PyCField_FromDesc(Node inliningTarget, Object desc, int inde if (adict != null && adict.proto != null) { StgDictObject idict = pyTypeStgDictNode.execute(inliningTarget, adict.proto); if (idict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, HAS_NO_STGINFO); + throw raiseNode.raise(inliningTarget, TypeError, HAS_NO_STGINFO); } if (idict.getfunc == FieldDesc.c.getfunc) { FieldDesc fd = FieldDesc.s; @@ -571,7 +571,7 @@ static Object c_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Bind("this") Node inliningTarget, @Cached GetInternalByteArrayNode getBytes, @Exclusive @Cached PointerNodes.WriteByteNode writeByteNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (PGuards.isBytes(value)) { PBytesLike bytes = (PBytesLike) value; if (bytes.getSequenceStorage().length() == 1) { @@ -588,7 +588,7 @@ static Object c_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O } } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ONE_CHARACTER_BYTES_BYTEARRAY_INTEGER_EXPECTED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ONE_CHARACTER_BYTES_BYTEARRAY_INTEGER_EXPECTED); } /* u - a single wchar_t character */ @@ -599,14 +599,14 @@ static Object u_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Shared @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode, @Exclusive @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { // CTYPES_UNICODE + @Exclusive @Cached PRaiseNode raiseNode) { // CTYPES_UNICODE if (!PGuards.isString(value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); } TruffleString str = switchEncodingNode.execute(toString.execute(inliningTarget, value), WCHAR_T_ENCODING); InternalByteArray bytes = getInternalByteArrayNode.execute(str, WCHAR_T_ENCODING); if (bytes.getLength() != WCHAR_T_SIZE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ONE_CHARACTER_UNICODE_EXPECTED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ONE_CHARACTER_UNICODE_EXPECTED); } writeBytesNode.execute(inliningTarget, ptr, bytes.getArray(), bytes.getOffset(), bytes.getLength()); return PNone.NONE; @@ -619,15 +619,15 @@ static Object U_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Shared @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode, @Exclusive @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { // CTYPES_UNICODE + @Exclusive @Cached PRaiseNode raiseNode) { // CTYPES_UNICODE if (!PGuards.isString(value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); } TruffleString str = switchEncodingNode.execute(toString.execute(inliningTarget, value), WCHAR_T_ENCODING); InternalByteArray bytes = getInternalByteArrayNode.execute(str, WCHAR_T_ENCODING); if (bytes.getLength() > size) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.STR_TOO_LONG, bytes.getLength(), size); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.STR_TOO_LONG, bytes.getLength(), size); } writeBytesNode.execute(inliningTarget, ptr, bytes.getArray(), bytes.getOffset(), bytes.getLength()); return value; @@ -638,9 +638,9 @@ static Object s_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Bind("this") Node inliningTarget, @Cached ToBytesWithoutFrameNode getBytes, @Exclusive @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (!PGuards.isPBytes(value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, value); } byte[] data = getBytes.execute(inliningTarget, value); @@ -651,7 +651,7 @@ static Object s_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O */ ++size; } else if (size > length) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BYTES_TOO_LONG, size, length); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BYTES_TOO_LONG, size, length); } writeBytesNode.execute(inliningTarget, ptr, data); @@ -665,7 +665,7 @@ static Object z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Exclusive @Cached PointerNodes.PointerFromLongNode pointerFromLongNode, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (value == PNone.NONE) { writePointerNode.execute(inliningTarget, ptr, Pointer.NULL); return PNone.NONE; @@ -687,7 +687,7 @@ static Object z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O new PointerReference(value, valuePtr, PythonContext.get(inliningTarget).getSharedFinalizer()); return value; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BYTES_OR_INT_ADDR_EXPECTED_INSTEAD_OF_P, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BYTES_OR_INT_ADDR_EXPECTED_INSTEAD_OF_P, value); } @Specialization(guards = "setfunc == Z_set") @@ -700,7 +700,7 @@ static Object Z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { // CTYPES_UNICODE + @Exclusive @Cached PRaiseNode raiseNode) { // CTYPES_UNICODE if (value == PNone.NONE) { writePointerNode.execute(inliningTarget, ptr, Pointer.NULL); return PNone.NONE; @@ -709,7 +709,7 @@ static Object Z_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O return PNone.NONE; } if (!PGuards.isString(value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNICODE_STR_OR_INT_ADDR_EXPECTED_INSTEAD_OF_P, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNICODE_STR_OR_INT_ADDR_EXPECTED_INSTEAD_OF_P, value); } TruffleString str = switchEncodingNode.execute(toString.execute(inliningTarget, value), WCHAR_T_ENCODING); @@ -729,14 +729,14 @@ static Object P_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @Exclusive @Cached PyLongCheckNode longCheckNode, @Exclusive @Cached PointerNodes.PointerFromLongNode pointerFromLongNode, @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Pointer valuePtr; if (value == PNone.NONE) { valuePtr = Pointer.NULL; } else if (longCheckNode.execute(inliningTarget, value)) { valuePtr = pointerFromLongNode.execute(inliningTarget, value); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_BE_CONVERTED_TO_POINTER); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_BE_CONVERTED_TO_POINTER); } writePointerNode.execute(inliningTarget, ptr, valuePtr); @@ -745,9 +745,10 @@ static Object P_set(@SuppressWarnings("unused") FieldSet setfunc, Pointer ptr, O @SuppressWarnings("unused") @Fallback - static Object error(VirtualFrame frame, FieldSet setfunc, Pointer ptr, Object value, int size) { + static Object error(VirtualFrame frame, FieldSet setfunc, Pointer ptr, Object value, int size, + @Bind("this") Node inliningTarget) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.getUncached().raise(NotImplementedError, toTruffleStringUncached("Field setter %s is not supported yet."), setfunc.name()); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("Field setter %s is not supported yet."), setfunc.name()); } private static final byte[] CTYPES_CFIELD_CAPSULE_NAME_PYMEM = PyCapsule.capsuleName("_ctypes/cfield.c pymem"); @@ -935,7 +936,7 @@ static Object O_get(@SuppressWarnings("unused") FieldGet getfunc, Pointer ptr, @ @Cached PRaiseNode raiseNode) { Pointer valuePtr = readPointerNode.execute(inliningTarget, ptr); if (valuePtr.isNull()) { - throw raiseNode.raise(ValueError, ErrorMessages.PY_OBJ_IS_NULL); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.PY_OBJ_IS_NULL); } return readPythonObject.execute(inliningTarget, valuePtr); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CThunkObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CThunkObject.java index 5c8fe53714..307dd8fc86 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CThunkObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CThunkObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -167,7 +167,7 @@ Object execute(Object[] pArgs, memcpyNode.execute(inliningTarget, obj.b_ptr, value, dict.size); arglist[i] = obj; } else { - throw raiseNode.raise(TypeError, CANNOT_BUILD_PARAMETER); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_BUILD_PARAMETER); // PrintError("Parsing argument %zd\n", i); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java index 5c3bd3442d..c026873eb9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java @@ -509,7 +509,7 @@ static Object POINTER(VirtualFrame frame, Object cls, @Cached GetNameNode getNameNode, @Cached CastToTruffleStringNode toTruffleStringNode, @Cached SimpleTruffleStringFormatNode formatNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonLanguage language = context.getLanguage(inliningTarget); CtypesThreadState ctypes = CtypesThreadState.get(context, language); Object result = getItem.execute(frame, inliningTarget, ctypes.ptrtype_cache, cls); @@ -530,7 +530,7 @@ static Object POINTER(VirtualFrame frame, Object cls, result = callNode.execute(frame, PyCPointerType, args, PKeyword.EMPTY_KEYWORDS); key = cls; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_A_CTYPES_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_A_CTYPES_TYPE); } HashingStorage newStorage = setItem.execute(frame, inliningTarget, ctypes.ptrtype_cache, key, result); assert newStorage == ctypes.ptrtype_cache; @@ -588,13 +588,13 @@ static Object buffer_info(Object arg, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, arg); if (dict == null) { dict = pyObjectStgDictNode.execute(inliningTarget, arg); } if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, NOT_A_CTYPES_TYPE_OR_OBJECT); + throw raiseNode.raise(inliningTarget, TypeError, NOT_A_CTYPES_TYPE_OR_OBJECT); } Object[] shape = new Object[dict.ndim]; for (int i = 0; i < dict.ndim; ++i) { @@ -619,16 +619,16 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object resize(CDataObject obj, int size, @Bind("this") Node inliningTarget, @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyObjectStgDictNode.execute(inliningTarget, obj); if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, EXCEPTED_CTYPES_INSTANCE); + throw raiseNode.raise(inliningTarget, TypeError, EXCEPTED_CTYPES_INSTANCE); } if (size < dict.size) { - throw raiseNode.get(inliningTarget).raise(ValueError, MINIMUM_SIZE_IS_D, dict.size); + throw raiseNode.raise(inliningTarget, ValueError, MINIMUM_SIZE_IS_D, dict.size); } if (obj.b_needsfree) { - throw raiseNode.get(inliningTarget).raise(ValueError, MEMORY_CANNOT_BE_RESIZED_BECAUSE_THIS_OBJECT_DOESN_T_OWN_IT); + throw raiseNode.raise(inliningTarget, ValueError, MEMORY_CANNOT_BE_RESIZED_BECAUSE_THIS_OBJECT_DOESN_T_OWN_IT); } obj.b_size = size; return PNone.NONE; @@ -746,7 +746,7 @@ static Object py_dl_open(PythonModule self, TruffleString name, int m, } catch (Exception e) { exception = e; } - throw PRaiseNode.raiseUncached(inliningTarget, OSError, getErrMsg(exception)); + throw PRaiseNode.raiseStatic(inliningTarget, OSError, getErrMsg(exception)); } } @@ -758,13 +758,13 @@ protected abstract static class DlCloseNode extends PythonUnaryBuiltinNode { static Object py_dl_close(Object pointerObj, @Bind("this") Node inliningTarget, @Cached CtypesNodes.HandleFromLongNode handleFromLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { DLHandler handle = handleFromLongNode.getDLHandler(inliningTarget, pointerObj); if (handle != null) { handle.isClosed = true; return PNone.NONE; } - throw raiseNode.get(inliningTarget).raise(OSError, T_DL_ERROR); + throw raiseNode.raise(inliningTarget, OSError, T_DL_ERROR); } } @@ -781,11 +781,11 @@ static Object ctypes_dlsym(VirtualFrame frame, Pointer handlePtr, Object n, Pyth @Cached PyObjectHashNode hashNode, @Cached CastToJavaStringNode asString, @CachedLibrary(limit = "1") InteropLibrary ilib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { DLHandler handle = handleFromPointerNode.getDLHandler(inliningTarget, handlePtr); String name = asString.execute(n); if (handle == null || handle.isClosed) { - throw raiseNode.get(inliningTarget).raise(error, T_DL_ERROR); + throw raiseNode.raise(inliningTarget, error, T_DL_ERROR); } try { Object sym = ilib.readMember(handle.library, name); @@ -801,7 +801,7 @@ static Object ctypes_dlsym(VirtualFrame frame, Pointer handlePtr, Object n, Pyth return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func); } } catch (UnsupportedMessageException | UnknownIdentifierException e) { - throw raiseNode.get(inliningTarget).raise(error, e); + throw raiseNode.raise(inliningTarget, error, e); } } } @@ -864,9 +864,9 @@ static Object doBytes(PythonModule self, PBytes path, @Cached ToBytesNode toBytesNode, @CachedLibrary(limit = "1") InteropLibrary ilib, @CachedLibrary(limit = "1") InteropLibrary resultLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!hasDynamicLoaderCache()) { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, S_SYMBOL_IS_MISSING, DYLD_SHARED_CACHE_CONTAINS_PATH); + throw raiseNode.raise(inliningTarget, NotImplementedError, S_SYMBOL_IS_MISSING, DYLD_SHARED_CACHE_CONTAINS_PATH); } CtypesModuleBuiltins builtins = (CtypesModuleBuiltins) self.getBuiltins(); @@ -920,7 +920,7 @@ static Object align_func(Object obj, @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, obj); if (dict != null) { return dict.align; @@ -931,7 +931,7 @@ static Object align_func(Object obj, return dict.align; } - throw raiseNode.get(inliningTarget).raise(TypeError, NO_ALIGNMENT_INFO); + throw raiseNode.raise(inliningTarget, TypeError, NO_ALIGNMENT_INFO); } } @@ -944,7 +944,7 @@ static Object doit(Object obj, @Bind("this") Node inliningTarget, @Cached PyTypeCheck pyTypeCheck, @Cached PyTypeStgDictNode pyTypeStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, obj); if (dict != null) { return dict.size; @@ -953,7 +953,7 @@ static Object doit(Object obj, if (pyTypeCheck.isCDataObject(inliningTarget, obj)) { return ((CDataObject) obj).b_size; } - throw raiseNode.get(inliningTarget).raise(TypeError, THIS_TYPE_HAS_NO_SIZE); + throw raiseNode.raise(inliningTarget, TypeError, THIS_TYPE_HAS_NO_SIZE); } } @@ -973,7 +973,7 @@ Object doit(CDataObject obj, int offset, @Exclusive @Cached GetClassNode getClassNode, @Cached PyTypeCheck pyTypeCheck, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { return error(null, obj, offset, inliningTarget, getClassNode, raiseNode); } @@ -991,10 +991,10 @@ Object doit(CDataObject obj, int offset, static Object error(VirtualFrame frame, Object obj, Object off, @Bind("this") Node inliningTarget, @Exclusive @Cached GetClassNode getClassNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object clazz = getClassNode.execute(inliningTarget, obj); TruffleString name = GetNameNode.executeUncached(clazz); - throw raiseNode.get(inliningTarget).raise(TypeError, BYREF_ARGUMENT_MUST_BE_A_CTYPES_INSTANCE_NOT_S, name); + throw raiseNode.raise(inliningTarget, TypeError, BYREF_ARGUMENT_MUST_BE_A_CTYPES_INSTANCE_NOT_S, name); } } @@ -1038,9 +1038,9 @@ static Object doit(CDataObject obj, @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, @Cached AuditNode auditNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { - return error(obj, raiseNode.get(inliningTarget)); + return error(obj, raiseNode); } auditNode.audit(inliningTarget, "ctypes.addressof", obj); return PFactory.createNativeVoidPtr(language, obj.b_ptr); @@ -1048,8 +1048,8 @@ static Object doit(CDataObject obj, @Fallback static Object error(@SuppressWarnings("unused") Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, INVALID_TYPE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, INVALID_TYPE); } } @@ -1081,8 +1081,8 @@ static Object call_function(VirtualFrame frame, Object pointerObj, PTuple argume protected abstract static class FormatErrorNode extends PythonUnaryBuiltinNode { @Specialization static Object doit(@SuppressWarnings("unused") Object errorCode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -1152,10 +1152,10 @@ Object _ctypes_callproc(VirtualFrame frame, NativeFunction pProc, Object[] argar @Cached CallNode callNode, @Cached GetResultNode getResultNode, @CachedLibrary(limit = "1") InteropLibrary ilib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int argcount = argarray.length; if (argcount > CTYPES_MAX_ARGCOUNT) { - throw raiseNode.get(inliningTarget).raise(ArgError, TOO_MANY_ARGUMENTS_D_MAXIMUM_IS_D, argcount, CTYPES_MAX_ARGCOUNT); + throw raiseNode.raise(inliningTarget, ArgError, TOO_MANY_ARGUMENTS_D_MAXIMUM_IS_D, argcount, CTYPES_MAX_ARGCOUNT); } CTypesCallArgument[] args = new CTypesCallArgument[argcount]; @@ -1184,7 +1184,7 @@ Object _ctypes_callproc(VirtualFrame frame, NativeFunction pProc, Object[] argar try { v = callNode.execute(frame, converters[i], arg); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(ArgError, ARGUMENT_D, i + 1); + throw raiseNode.raise(inliningTarget, ArgError, ARGUMENT_D, i + 1); } } convParamNode.execute(frame, v, i + 1, args[i]); @@ -1227,11 +1227,11 @@ static Object callManagedFunction(Node inliningTarget, NativeFunction pProc, Obj throw e; } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException | AbstractTruffleException e) { CompilerDirectives.transferToInterpreter(); - throw PRaiseNode.raiseUncached(inliningTarget, RuntimeError, FFI_CALL_FAILED); + throw PRaiseNode.raiseStatic(inliningTarget, RuntimeError, FFI_CALL_FAILED); } catch (UnsupportedSpecializationException ee) { // TODO: llvm/GR-??? CompilerDirectives.transferToInterpreter(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, toTruffleStringUncached("require backend support.")); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("require backend support.")); } } @@ -1246,7 +1246,7 @@ protected Object getFunction(NativeFunction pProc, String signature) throws Exce * NFI compatible native function calls (temporary replacement) */ Object callNativeFunction(Node inliningTarget, NativeFunction pProc, Object[] avalues, FFIType[] atypes, FFIType restype, - InteropLibrary ilib, PRaiseNode.Lazy raiseNode) { + InteropLibrary ilib, PRaiseNode raiseNode) { Object function; if (pProc.function != null && equals(atypes, pProc.atypes) && restype == pProc.rtype) { function = pProc.function; @@ -1255,7 +1255,7 @@ Object callNativeFunction(Node inliningTarget, NativeFunction pProc, Object[] av try { function = getFunction(pProc, signature.toJavaStringUncached()); } catch (Exception e) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, FFI_PREP_CIF_FAILED); + throw raiseNode.raise(inliningTarget, RuntimeError, FFI_PREP_CIF_FAILED); } pProc.atypes = atypes; pProc.rtype = restype; @@ -1266,7 +1266,7 @@ Object callNativeFunction(Node inliningTarget, NativeFunction pProc, Object[] av return ilib.execute(function, avalues); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); - throw PRaiseNode.raiseUncached(inliningTarget, RuntimeError, FFI_CALL_FAILED); + throw PRaiseNode.raiseStatic(inliningTarget, RuntimeError, FFI_CALL_FAILED); } } @@ -1412,7 +1412,7 @@ static Object callGetFunc(VirtualFrame frame, Object restype, FFIType rtype, Obj // value for large structs, because NFI still needs to allocate and pass the // buffer for the result to the callee. CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.RETURNING_STRUCT_BY_VALUE_NOT_SUPPORTED); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.RETURNING_STRUCT_BY_VALUE_NOT_SUPPORTED); } case FFI_TYPE_POINTER -> { // NOTE: we are returning pointer to the result buffer and the result buffer @@ -1487,7 +1487,7 @@ void convParam(VirtualFrame frame, Object obj, int index, CTypesCallArgument pa, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached CArgObjectBuiltins.ParamFuncNode paramFuncNode, @Cached ConvParamNode recursive, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (obj instanceof CDataObject cdata) { pa.stgDict = pyObjectStgDictNode.execute(inliningTarget, cdata); PyCArgObject carg = paramFuncNode.execute(inliningTarget, cdata, pa.stgDict); @@ -1520,7 +1520,7 @@ void convParam(VirtualFrame frame, Object obj, int index, CTypesCallArgument pa, pa.valuePointer = Pointer.create(pa.ffi_type, pa.ffi_type.size, asInt.executeExact(frame, inliningTarget, obj), 0); } catch (PException e) { e.expectOverflowError(inliningTarget, profile); - throw raiseNode.get(inliningTarget).raise(OverflowError, INT_TOO_LONG_TO_CONVERT); + throw raiseNode.raise(inliningTarget, OverflowError, INT_TOO_LONG_TO_CONVERT); } return; } @@ -1560,7 +1560,7 @@ void convParam(VirtualFrame frame, Object obj, int index, CTypesCallArgument pa, recursive.execute(frame, arg, index, pa, false); return; } - throw raiseNode.get(inliningTarget).raise(TypeError, DON_T_KNOW_HOW_TO_CONVERT_PARAMETER_D, index); + throw raiseNode.raise(inliningTarget, TypeError, DON_T_KNOW_HOW_TO_CONVERT_PARAMETER_D, index); } } @@ -1640,9 +1640,8 @@ static Object doIntrinsicPointer(Node inliningTarget, CTypesCallArgument arg, @S @Specialization(guards = {"mode == NFI", "isFFIType(arg, FFI_TYPE_STRUCT)"}) @SuppressWarnings("unused") - static Object doNFIStruct(Node inliningTarget, CTypesCallArgument arg, @SuppressWarnings("unused") BackendMode mode, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError, ErrorMessages.PASSING_STRUCTS_BY_VALUE_NOT_SUPPORTED); + static Object doNFIStruct(Node inliningTarget, CTypesCallArgument arg, @SuppressWarnings("unused") BackendMode mode) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.NotImplementedError, ErrorMessages.PASSING_STRUCTS_BY_VALUE_NOT_SUPPORTED); } @Specialization(guards = {"mode == LLVM", "isFFIType(arg, FFI_TYPE_STRUCT)"}) @@ -1730,6 +1729,7 @@ boolean isExecutable() { @ExportMessage Object execute(Object[] arguments, + @Bind("$node") Node inliningTarget, @Cached TruffleString.ToJavaStringNode toJavaStringNode, @CachedLibrary("this.llvmSym") InteropLibrary ilib) { try { @@ -1740,7 +1740,7 @@ Object execute(Object[] arguments, } return ilib.execute(llvmSym, arguments); } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { - throw PRaiseNode.getUncached().raise(RuntimeError, e); + throw PRaiseNode.raiseStatic(inliningTarget, RuntimeError, e); } } } @@ -1758,7 +1758,7 @@ static void raiseError(Object arg, @Cached GetClassNode getClassNode, @Cached GetNameNode getNameNode) { Object clazz = isTypeNode.execute(inliningTarget, arg) ? arg : getClassNode.execute(inliningTarget, arg); - throw raiseNode.raise(TypeError, CAST_ARGUMENT_2_MUST_BE_A_POINTER_TYPE_NOT_S, getNameNode.execute(inliningTarget, clazz)); + throw raiseNode.raise(inliningTarget, TypeError, CAST_ARGUMENT_2_MUST_BE_A_POINTER_TYPE_NOT_S, getNameNode.execute(inliningTarget, clazz)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java index b01f95d28b..90ce8009fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesNodes.java @@ -316,7 +316,7 @@ public abstract static class PyCDataFromBaseObjNode extends Node { @Specialization static CDataObject PyCData_FromBaseObj(Node inliningTarget, Object type, CDataObject base, int index, Pointer adr, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached StgDictBuiltins.PyTypeStgDictNode pyTypeStgDictNode, @Cached CreateCDataObjectNode createCDataObjectNode, @Cached PyCDataMallocBufferNode mallocBufferNode, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java index d9910ce92a..956b8676c9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCArrayTypeBuiltins.java @@ -157,13 +157,13 @@ static Object doSet(VirtualFrame frame, CDataObject self, Object value, @CachedLibrary("value") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = acquireLib.acquire(value, BufferFlags.PyBUF_SIMPLE, frame, indirectCallData); try { byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); if (len > self.b_size) { - throw raiseNode.get(inliningTarget).raise(ValueError, BYTE_STRING_TOO_LONG); + throw raiseNode.raise(inliningTarget, ValueError, BYTE_STRING_TOO_LONG); } writeBytesNode.execute(inliningTarget, self.b_ptr, bytes, 0, len); return PNone.NONE; @@ -191,11 +191,11 @@ static Object doSet(CDataObject self, PBytes value, @Bind("this") Node inliningTarget, @Cached GetInternalByteArrayNode getBytes, @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = value.getSequenceStorage(); int len = storage.length(); if (len > self.b_size) { - throw raiseNode.get(inliningTarget).raise(ValueError, BYTE_STRING_TOO_LONG); + throw raiseNode.raise(inliningTarget, ValueError, BYTE_STRING_TOO_LONG); } byte[] bytes = getBytes.execute(inliningTarget, storage); writeBytesNode.execute(inliningTarget, self.b_ptr, bytes, 0, len); @@ -204,8 +204,8 @@ static Object doSet(CDataObject self, PBytes value, @Fallback static Object error(@SuppressWarnings("unused") Object self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BYTES_EXPECTED_INSTEAD_OF_P_INSTANCE, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BYTES_EXPECTED_INSTEAD_OF_P_INSTANCE, value); } } @@ -232,11 +232,11 @@ static Object doSet(CDataObject self, Object value, @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode, @Cached PointerNodes.WriteBytesNode writeBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString str = switchEncodingNode.execute(toTruffleStringNode.execute(inliningTarget, value), WCHAR_T_ENCODING); int len = str.byteLength(WCHAR_T_ENCODING); if (len > self.b_size) { - throw raiseNode.get(inliningTarget).raise(ValueError, STRING_TOO_LONG); + throw raiseNode.raise(inliningTarget, ValueError, STRING_TOO_LONG); } InternalByteArray bytes = getInternalByteArrayNode.execute(str, WCHAR_T_ENCODING); writeBytesNode.execute(inliningTarget, self.b_ptr, bytes.getArray(), bytes.getOffset(), bytes.getLength()); @@ -245,8 +245,8 @@ static Object doSet(CDataObject self, Object value, @Fallback static Object error(@SuppressWarnings("unused") Object self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, UNICODE_STRING_EXPECTED_INSTEAD_OF_P_INSTANCE, value); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java index 6ad818bd6a..2315806713 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java @@ -157,7 +157,7 @@ static Object c_wchar_p_from_param(VirtualFrame frame, Object type, Object value @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached CWCharPFromParamNode cwCharPFromParamNode, @Cached PyObjectLookupAttr lookupAttr, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (PGuards.isString(value)) { PyCArgObject parg = PFactory.createCArgObject(PythonLanguage.get(inliningTarget)); parg.pffi_type = ffi_type_pointer; @@ -192,7 +192,7 @@ static Object c_wchar_p_from_param(VirtualFrame frame, Object type, Object value if (as_parameter != PNone.NO_VALUE) { return cwCharPFromParamNode.execute(frame, type, as_parameter); } - throw raiseNode.get(inliningTarget).raise(TypeError, WRONG_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, WRONG_TYPE); } } @@ -267,7 +267,7 @@ static Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached PyObjectLookupAttr lookupAttr, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* c_void_p instance (or subclass) */ boolean res = isInstanceNode.executeWith(frame, value, type); if (res) { @@ -316,7 +316,7 @@ static Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, if (as_parameter != PNone.NO_VALUE) { return cVoidPFromParamNode.execute(frame, type, as_parameter); } - throw raiseNode.get(inliningTarget).raise(TypeError, WRONG_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, WRONG_TYPE); } } @@ -354,7 +354,7 @@ static Object c_char_p_from_param(VirtualFrame frame, Object type, Object value, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached CCharPFromParamNode cCharPFromParamNode, @Cached PyObjectLookupAttr lookupAttr, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean res = isInstanceNode.executeWith(frame, value, type); if (res) { return value; @@ -381,7 +381,7 @@ static Object c_char_p_from_param(VirtualFrame frame, Object type, Object value, if (as_parameter != PNone.NO_VALUE) { return cCharPFromParamNode.execute(frame, type, as_parameter); } - throw raiseNode.get(inliningTarget).raise(TypeError, WRONG_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, WRONG_TYPE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java index 43c604be2f..eab04c7cb8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayBuiltins.java @@ -91,7 +91,6 @@ import com.oracle.graal.python.lib.PyObjectSetItem; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -135,7 +134,7 @@ static Object newCData(Object type, @SuppressWarnings("unused") Object[] args, @ @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CtypesNodes.GenericPyCDataNewNode newNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); return newNode.execute(inliningTarget, type, dict); } @@ -166,11 +165,11 @@ static void Array_ass_item(VirtualFrame frame, CDataObject self, int index, Obje @Bind("this") Node inliningTarget, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached PyCDataSetNode pyCDataSetNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject stgdict = pyObjectStgDictNode.execute(inliningTarget, self); assert stgdict != null : "Cannot be NULL for array object instances"; if (index < 0 || index >= stgdict.length) { - throw raiseNode.get(inliningTarget).raise(IndexError, INVALID_INDEX); + throw raiseNode.raise(inliningTarget, IndexError, INVALID_INDEX); } int size = stgdict.size / stgdict.length; // self.b_ptr.createStorage(stgdict.ffi_type_pointer, stgdict.size, value); @@ -182,8 +181,8 @@ static void Array_ass_item(VirtualFrame frame, CDataObject self, int index, Obje @SuppressWarnings("unused") @Specialization(guards = "isNoValue(value)") static void error(CDataObject self, int index, PNone value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARRAY_DOES_NOT_SUPPORT_ITEM_DELETION); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARRAY_DOES_NOT_SUPPORT_ITEM_DELETION); } } @@ -197,7 +196,7 @@ static void Array_ass_subscript(VirtualFrame frame, CDataObject self, Object ind @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSint, @Shared @Cached PyCArraySetItemNode setItemNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, indexObj)) { int index = asSint.executeExact(frame, inliningTarget, indexObj, IndexError); if (index < 0) { @@ -205,7 +204,7 @@ static void Array_ass_subscript(VirtualFrame frame, CDataObject self, Object ind } setItemNode.executeIntKey(frame, self, index, value); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, INDICES_MUST_BE_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, INDICES_MUST_BE_INTEGER); } } @@ -217,14 +216,14 @@ static void Array_ass_subscript(VirtualFrame frame, CDataObject self, PSlice sli @Cached SliceUnpack sliceUnpack, @Cached AdjustIndices adjustIndices, @Shared @Cached PyCArraySetItemNode setItemNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PSlice.SliceInfo sliceInfo = adjustIndices.execute(inliningTarget, self.b_length, sliceUnpack.execute(inliningTarget, slice)); int start = sliceInfo.start, step = sliceInfo.step; int slicelen = sliceInfo.sliceLength; int otherlen = pySequenceLength.execute(frame, inliningTarget, value); if (otherlen != slicelen) { - throw raiseNode.get(inliningTarget).raise(ValueError, CAN_ONLY_ASSIGN_SEQUENCE_OF_SAME_SIZE); + throw raiseNode.raise(inliningTarget, ValueError, CAN_ONLY_ASSIGN_SEQUENCE_OF_SAME_SIZE); } for (int cur = start, i = 0; i < otherlen; cur += step, i++) { Object item = pySequenceGetItem.execute(frame, inliningTarget, value, i); @@ -235,8 +234,8 @@ static void Array_ass_subscript(VirtualFrame frame, CDataObject self, PSlice sli @SuppressWarnings("unused") @Specialization(guards = "isNoValue(value)") static void error(CDataObject self, Object index, PNone value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARRAY_DOES_NOT_SUPPORT_ITEM_DELETION); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARRAY_DOES_NOT_SUPPORT_ITEM_DELETION); } } @@ -246,7 +245,7 @@ abstract static class PyCArrayGetItemNode extends SqItemBuiltinNode { @Specialization static Object doIt(CDataObject self, int index, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyCDataGetNode pyCDataGetNode, @Cached PyObjectStgDictNode pyObjectStgDictNode) { checkIndex(inliningTarget, self, index, raiseNode); @@ -261,15 +260,15 @@ static Object getItem(Node inliningTarget, CDataObject self, int index, PyCDataG return pyCDataGetNode.execute(inliningTarget, stgdict.proto, stgdict.getfunc, self, index, size, self.b_ptr.withOffset(offset)); } - private static void checkIndex(Node inliningTarget, CDataObject self, int index, Lazy raiseNode) { + private static void checkIndex(Node inliningTarget, CDataObject self, int index, PRaiseNode raiseNode) { if (index < 0 || index >= self.b_length) { raiseInvalidIndex(inliningTarget, raiseNode); } } @InliningCutoff - private static void raiseInvalidIndex(Node inliningTarget, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(IndexError, INVALID_INDEX); + private static void raiseInvalidIndex(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, IndexError, INVALID_INDEX); } } @@ -362,9 +361,9 @@ static Object doGeneric(VirtualFrame frame, CDataObject self, Object item, @Cached InlinedConditionProfile negativeIndexProfile, @Exclusive @Cached PyCDataGetNode pyCDataGetNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!indexCheckNode.execute(inliningTarget, item)) { - throw raiseNode.get(inliningTarget).raise(TypeError, INDICES_MUST_BE_INTEGERS); + throw raiseNode.raise(inliningTarget, TypeError, INDICES_MUST_BE_INTEGERS); } Object idx = indexNode.execute(frame, inliningTarget, item); int index = asSizeNode.executeExact(frame, inliningTarget, idx); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java index c50d24a0b9..e0ca0bb57f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCArrayTypeBuiltins.java @@ -121,14 +121,14 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P @Cached HashingStorageAddAllToOther addAllToOtherNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * create the new instance (which is a class, since we are a metatype!) */ Object result = typeNew.execute(frame, type, args[0], args[1], args[2], kwds); Object length_attr = lookupAttrLength.execute(frame, inliningTarget, result, T__LENGTH_); if (length_attr == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, CLASS_MUST_DEFINE_A_LENGTH_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, AttributeError, CLASS_MUST_DEFINE_A_LENGTH_ATTRIBUTE); } int length; @@ -136,26 +136,26 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P length = asSizeNode.executeExact(frame, inliningTarget, length_attr); } catch (PException e) { if (e.expectTypeOrOverflowError(inliningTarget, profile)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, THE_LENGTH_ATTRIBUTE_IS_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, THE_LENGTH_ATTRIBUTE_IS_TOO_LARGE); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, THE_LENGTH_ATTRIBUTE_MUST_BE_AN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, THE_LENGTH_ATTRIBUTE_MUST_BE_AN_INTEGER); } } if (length < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, THE_LENGTH_ATTRIBUTE_MUST_NOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, THE_LENGTH_ATTRIBUTE_MUST_NOT_BE_NEGATIVE); } Object type_attr = lookupAttrType.execute(frame, inliningTarget, result, T__TYPE_); if (type_attr == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, CLASS_MUST_DEFINE_A_TYPE_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, AttributeError, CLASS_MUST_DEFINE_A_TYPE_ATTRIBUTE); } StgDictObject stgdict = PFactory.createStgDictObject(language); StgDictObject itemdict = pyTypeStgDictNode.execute(inliningTarget, type_attr); if (itemdict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, TYPE_MUST_HAVE_STORAGE_INFO); + throw raiseNode.raise(inliningTarget, TypeError, TYPE_MUST_HAVE_STORAGE_INFO); } assert itemdict.format != null; @@ -171,7 +171,7 @@ static Object PyCArrayType_new(VirtualFrame frame, Object type, Object[] args, P int itemsize = itemdict.size; if (itemsize != 0 && length > Integer.MAX_VALUE / itemsize) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ARRAY_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, ARRAY_TOO_LARGE); } int itemalign = itemdict.align; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java index 8ffc0a903e..252f1d06f7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java @@ -199,7 +199,7 @@ static Object simple(Object type, @SuppressWarnings("unused") Object[] args, @Su @Bind("this") Node inliningTarget, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); return pyCDataNewNode.execute(inliningTarget, type, dict); } @@ -218,7 +218,7 @@ static Object usingNativePointer(Object type, Object[] args, @SuppressWarnings(" @Exclusive @Cached PointerNodes.WritePointerNode writePointerNode, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); CDataObject cdata = pyCDataNewNode.execute(inliningTarget, type, dict); Pointer value = pointerFromLongNode.execute(inliningTarget, args[0]); @@ -235,15 +235,15 @@ static Object callback(VirtualFrame frame, Object type, Object[] args, @Suppress @Cached PyCallableCheckNode callableCheck, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object callable = args[0]; if (!callableCheck.execute(inliningTarget, callable)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ARGUMENT_MUST_BE_CALLABLE_OR_INTEGER_FUNCTION_ADDRESS); + throw raiseNode.raise(inliningTarget, TypeError, ARGUMENT_MUST_BE_CALLABLE_OR_INTEGER_FUNCTION_ADDRESS); } StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); if (dict == null || dict.argtypes == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_CONSTRUCT_INSTANCE_OF_THIS_CLASS_NO_ARGTYPES); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_CONSTRUCT_INSTANCE_OF_THIS_CLASS_NO_ARGTYPES); } CThunkObject thunk = _ctypes_alloc_callback(inliningTarget, callable, dict.argtypes, dict.restype, dict.flags); PyCFuncPtrObject self = (PyCFuncPtrObject) pyCDataNewNode.execute(inliningTarget, type, dict); @@ -256,10 +256,9 @@ static Object callback(VirtualFrame frame, Object type, Object[] args, @Suppress @Specialization(guards = {"args.length > 1", "!isPTuple(args)", "isLong(this, args, longCheckNode)"}, limit = "1") static Object error(@SuppressWarnings("unused") Object type, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] kwds, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Exclusive @Cached PyLongCheckNode longCheckNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARGUMENT_MUST_BE_CALLABLE_OR_INTEGER_FUNCTION_ADDRESS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARGUMENT_MUST_BE_CALLABLE_OR_INTEGER_FUNCTION_ADDRESS); } static CThunkObject CThunkObjectNew(int nArgs) { @@ -311,7 +310,7 @@ static CThunkObject _ctypes_alloc_callback(Node raisingNode, Object callable, Ob } else { StgDictObject dict = PyTypeStgDictNode.executeUncached(restype); if (dict == null || dict.setfunc == FieldSet.nil) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, INVALID_RESULT_TYPE_FOR_CALLBACK_FUNCTION); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, INVALID_RESULT_TYPE_FOR_CALLBACK_FUNCTION); } thunk.setfunc = dict.setfunc; thunk.ffi_restype = dict.ffi_type_pointer; @@ -356,9 +355,9 @@ Object PyCFuncPtr_get_errcheck(PyCFuncPtrObject self, @SuppressWarnings("unused" static Object PyCFuncPtr_set_errcheck(PyCFuncPtrObject self, Object value, @Bind("this") Node inliningTarget, @Cached PyCallableCheckNode callableCheck, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (value != PNone.NONE && !callableCheck.execute(inliningTarget, value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, THE_ERRCHECK_ATTRIBUTE_MUST_BE_CALLABLE); + throw raiseNode.raise(inliningTarget, TypeError, THE_ERRCHECK_ATTRIBUTE_MUST_BE_CALLABLE); } self.errcheck = value; return PNone.NONE; @@ -392,14 +391,14 @@ static Object PyCFuncPtr_set_restype(VirtualFrame frame, PyCFuncPtrObject self, @Cached PyObjectLookupAttr lookupAttr, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyCallableCheckNode callableCheck, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (value == PNone.NONE) { self.checker = null; self.restype = null; return PNone.NONE; } if (pyTypeStgDictNode.execute(inliningTarget, value) == null && !callableCheck.execute(inliningTarget, value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, RESTYPE_MUST_BE_A_TYPE_A_CALLABLE_OR_NONE); + throw raiseNode.raise(inliningTarget, TypeError, RESTYPE_MUST_BE_A_TYPE_A_CALLABLE_OR_NONE); } if (!PGuards.isPFunction(value)) { Object checker = lookupAttr.execute(frame, inliningTarget, value, T__CHECK_RETVAL_); @@ -446,7 +445,7 @@ static Object PyCFuncPtr_set_argtypes(VirtualFrame frame, PyCFuncPtrObject self, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectLookupAttr lookupAttr, @Shared @Cached GetInternalObjectArrayNode getArray, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage storage = value.getSequenceStorage(); Object[] ob = getArray.execute(inliningTarget, value.getSequenceStorage()); self.converters = converters_from_argtypes(frame, inliningTarget, ob, storage.length(), raiseNode, lookupAttr); @@ -459,7 +458,7 @@ static Object PyCFuncPtr_set_argtypes(VirtualFrame frame, PyCFuncPtrObject self, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectLookupAttr lookupAttr, @Shared @Cached GetInternalObjectArrayNode getArray, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage storage = value.getSequenceStorage(); Object[] ob = getArray.execute(inliningTarget, value.getSequenceStorage()); self.converters = converters_from_argtypes(frame, inliningTarget, ob, storage.length(), raiseNode, lookupAttr); @@ -469,8 +468,8 @@ static Object PyCFuncPtr_set_argtypes(VirtualFrame frame, PyCFuncPtrObject self, @Fallback static Object error(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARGTYPES_MUST_BE_A_SEQUENCE_OF_TYPES); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARGTYPES_MUST_BE_A_SEQUENCE_OF_TYPES); } } @@ -510,7 +509,8 @@ Object PyCFuncPtr_call(VirtualFrame frame, PyCFuncPtrObject self, Object[] inarg @Cached CallProcNode callProcNode, @Cached TruffleString.EqualNode equalNode, @Cached PointerNodes.ReadPointerNode readPointerNode, - @Cached CtypesNodes.HandleFromPointerNode handleFromPointerNode) { + @Cached CtypesNodes.HandleFromPointerNode handleFromPointerNode, + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyObjectStgDictNode.execute(inliningTarget, self); assert dict != null : "Cannot be NULL for PyCFuncPtrObject instances"; Object restype = self.restype != null ? self.restype : dict.restype; @@ -528,10 +528,10 @@ Object PyCFuncPtr_call(VirtualFrame frame, PyCFuncPtrObject self, Object[] inarg * TODO this happens in a numpy tests that use structs with function pointers: * numpy/core/tests/test_ufunc.py::TestLowlevelAPIAccess::test_loop_access */ - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CTYPES_FUNCTION_CALL_COULD_NOT_OBTAIN_FUNCTION_POINTER); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CTYPES_FUNCTION_CALL_COULD_NOT_OBTAIN_FUNCTION_POINTER); } Object[] callargs = _build_callargs(frame, inliningTarget, self, argtypes, inargs, kwds, props, - pyTypeCheck, getArray, castToJavaIntExactNode, castToTruffleStringNode, pyTypeStgDictNode, callNode, getNameNode, equalNode); + pyTypeCheck, getArray, castToJavaIntExactNode, castToTruffleStringNode, pyTypeStgDictNode, callNode, getNameNode, equalNode, raiseNode); int inoutmask = props[pinoutmask_idx]; int outmask = props[poutmask_idx]; int numretvals = props[pnumretvals_idx]; @@ -546,11 +546,11 @@ Object PyCFuncPtr_call(VirtualFrame frame, PyCFuncPtrObject self, Object[] inarg * argtypes tuple. */ if (required > actual) { - throw raise(TypeError, THIS_FUNCTION_TAKES_AT_LEAST_D_ARGUMENT_S_D_GIVEN, + throw raiseNode.raise(inliningTarget, TypeError, THIS_FUNCTION_TAKES_AT_LEAST_D_ARGUMENT_S_D_GIVEN, required, required == 1 ? "" : "s", actual); } } else if (required != actual) { - throw raise(TypeError, THIS_FUNCTION_TAKES_D_ARGUMENT_S_D_GIVEN, + throw raiseNode.raise(inliningTarget, TypeError, THIS_FUNCTION_TAKES_D_ARGUMENT_S_D_GIVEN, required, required == 1 ? "" : "s", actual); } } @@ -576,7 +576,7 @@ Object PyCFuncPtr_call(VirtualFrame frame, PyCFuncPtrObject self, Object[] inarg return _build_result(frame, inliningTarget, result, callargs, outmask, inoutmask, numretvals, callMethodObjArgs); } - protected Object _get_arg(int[] pindex, TruffleString name, Object defval, Object[] inargs, PKeyword[] kwds, TruffleString.EqualNode equalNode) { + protected Object _get_arg(Node inliningTarget, int[] pindex, TruffleString name, Object defval, Object[] inargs, PKeyword[] kwds, TruffleString.EqualNode equalNode, PRaiseNode raiseNode) { if (pindex[0] < inargs.length) { return inargs[pindex[0]++]; } @@ -592,9 +592,9 @@ protected Object _get_arg(int[] pindex, TruffleString name, Object defval, Objec } /* we can't currently emit a better error message */ if (name != null) { - throw raise(TypeError, REQUIRED_ARGUMENT_S_MISSING, name); + throw raiseNode.raise(inliningTarget, TypeError, REQUIRED_ARGUMENT_S_MISSING, name); } else { - throw raise(TypeError, NOT_ENOUGH_ARGUMENTS); + throw raiseNode.raise(inliningTarget, TypeError, NOT_ENOUGH_ARGUMENTS); } } @@ -627,7 +627,7 @@ Object[] _build_callargs(VirtualFrame frame, Node inliningTarget, PyCFuncPtrObje PyTypeStgDictNode pyTypeStgDictNode, CallNode callNode, GetNameNode getNameNode, - TruffleString.EqualNode equalNode) { + TruffleString.EqualNode equalNode, PRaiseNode raiseNode) { /* * It's a little bit difficult to determine how many arguments the function call * requires/accepts. For simplicity, we count the consumed args and compare this to the @@ -676,7 +676,7 @@ Object[] _build_callargs(VirtualFrame frame, Node inliningTarget, PyCFuncPtrObje case 0: case PARAMFLAG_FIN: /* 'in' parameter. Copy it from inargs. */ - ob = _get_arg(inargs_index, name, defval, inargs, kwds, equalNode); + ob = _get_arg(inliningTarget, inargs_index, name, defval, inargs, kwds, equalNode, raiseNode); callargs[i] = ob; break; case PARAMFLAG_FOUT: @@ -702,10 +702,10 @@ Object[] _build_callargs(VirtualFrame frame, Node inliningTarget, PyCFuncPtrObje /* * Cannot happen: _validate_paramflags() would not accept such an object */ - throw raise(RuntimeError, NULL_STGDICT_UNEXPECTED); + throw raiseNode.raise(inliningTarget, RuntimeError, NULL_STGDICT_UNEXPECTED); } if (PGuards.isString(dict.proto)) { // TODO Py_TPFLAGS_UNICODE_SUBCLASS - throw raise(TypeError, S_OUT_PARAMETER_MUST_BE_PASSED_AS_DEFAULT_VALUE, getNameNode.execute(inliningTarget, ob)); + throw raiseNode.raise(inliningTarget, TypeError, S_OUT_PARAMETER_MUST_BE_PASSED_AS_DEFAULT_VALUE, getNameNode.execute(inliningTarget, ob)); } if (pyTypeCheck.isPyCArrayTypeObject(inliningTarget, ob)) { ob = callNode.execute(frame, ob); @@ -722,7 +722,7 @@ Object[] _build_callargs(VirtualFrame frame, Node inliningTarget, PyCFuncPtrObje props[pnumretvals_idx]++; break; default: - throw raise(ValueError, PARAMFLAG_D_NOT_YET_IMPLEMENTED, flag); + throw raiseNode.raise(inliningTarget, ValueError, PARAMFLAG_D_NOT_YET_IMPLEMENTED, flag); } } @@ -738,7 +738,7 @@ Object[] _build_callargs(VirtualFrame frame, Node inliningTarget, PyCFuncPtrObje * When we have default values or named parameters, this error message is * misleading. See unittests/test_paramflags.py */ - throw raise(TypeError, CALL_TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, inargs_index, actual_args); + throw raiseNode.raise(inliningTarget, TypeError, CALL_TAKES_EXACTLY_D_ARGUMENTS_D_GIVEN, inargs_index, actual_args); } /* @@ -822,7 +822,7 @@ static Object PyCFuncPtr_FromDll(VirtualFrame frame, Object type, Object[] args, @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, @Cached AuditNode auditNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // PyArg_ParseTuple(args, "O|O", &tuple, ¶mflags); PTuple tuple = (PTuple) args[0]; Object[] paramflags = null; @@ -838,13 +838,13 @@ static Object PyCFuncPtr_FromDll(VirtualFrame frame, Object type, Object[] args, Object obj = getAttributeNode.execute(frame, inliningTarget, dll, T__HANDLE); if (!longCheckNode.execute(inliningTarget, obj)) { // PyLong_Check - throw raiseNode.get(inliningTarget).raise(TypeError, THE_HANDLE_ATTRIBUTE_OF_THE_SECOND_ARGUMENT_MUST_BE_AN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, THE_HANDLE_ATTRIBUTE_OF_THE_SECOND_ARGUMENT_MUST_BE_AN_INTEGER); } Pointer handlePtr; try { handlePtr = pointerFromLongNode.execute(inliningTarget, obj); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.COULD_NOT_CONVERT_THE_HANDLE_ATTRIBUTE_TO_A_POINTER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COULD_NOT_CONVERT_THE_HANDLE_ATTRIBUTE_TO_A_POINTER); } Object address = dlSymNode.execute(frame, handlePtr, name, AttributeError); _validate_paramflags(inliningTarget, type, paramflags, pyTypeCheck, getArray, pyTypeStgDictNode, codePointAtIndexNode, raiseNode); @@ -867,7 +867,7 @@ static void _validate_paramflags(Node inliningTarget, Object type, Object[] para GetInternalObjectArrayNode getArray, PyTypeStgDictNode pyTypeStgDictNode, TruffleString.CodePointAtIndexNode codePointAtIndexNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); Object[] argtypes = dict.argtypes; @@ -876,12 +876,12 @@ static void _validate_paramflags(Node inliningTarget, Object type, Object[] para } if (!PGuards.isPTuple(paramflags)) { - throw raiseNode.get(inliningTarget).raise(TypeError, PARAMFLAGS_MUST_BE_A_TUPLE_OR_NONE); + throw raiseNode.raise(inliningTarget, TypeError, PARAMFLAGS_MUST_BE_A_TUPLE_OR_NONE); } int len = paramflags.length; if (len != dict.argtypes.length) { - throw raiseNode.get(inliningTarget).raise(ValueError, PARAMFLAGS_MUST_HAVE_THE_SAME_LENGTH_AS_ARGTYPES); + throw raiseNode.raise(inliningTarget, ValueError, PARAMFLAGS_MUST_HAVE_THE_SAME_LENGTH_AS_ARGTYPES); } for (int i = 0; i < len; ++i) { @@ -891,7 +891,7 @@ static void _validate_paramflags(Node inliningTarget, Object type, Object[] para int flag = (int) array[0]; if (array.length > 1) { if (!PGuards.isString(array[1])) { - throw raiseNode.get(inliningTarget).raise(TypeError, PARAMFLAGS_MUST_BE_A_SEQUENCE_OF_INT_STRING_VALUE_TUPLES); + throw raiseNode.raise(inliningTarget, TypeError, PARAMFLAGS_MUST_BE_A_SEQUENCE_OF_INT_STRING_VALUE_TUPLES); } } Object typ = argtypes[i]; @@ -905,7 +905,7 @@ static void _validate_paramflags(Node inliningTarget, Object type, Object[] para _check_outarg_type(inliningTarget, typ, i + 1, pyTypeCheck, pyTypeStgDictNode, codePointAtIndexNode, raiseNode); break; default: - throw raiseNode.get(inliningTarget).raise(TypeError, PARAMFLAG_VALUE_D_NOT_SUPPORTED, flag); + throw raiseNode.raise(inliningTarget, TypeError, PARAMFLAG_VALUE_D_NOT_SUPPORTED, flag); } } } @@ -915,7 +915,7 @@ static void _check_outarg_type(Node inliningTarget, Object arg, int index, PyTypeCheck pyTypeCheck, PyTypeStgDictNode pyTypeStgDictNode, TruffleString.CodePointAtIndexNode codePointAtIndexNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (pyTypeCheck.isPyCPointerTypeObject(inliningTarget, arg)) { return; } @@ -935,7 +935,7 @@ && strchr(PzZ, codePointAtIndexNode.execute((TruffleString) dict.proto, 0, TS_EN return; } - throw raiseNode.get(inliningTarget).raise(TypeError, OUT_PARAMETER_D_MUST_BE_A_POINTER_TYPE_NOT_S, index, GetNameNode.executeUncached(arg)); + throw raiseNode.raise(inliningTarget, TypeError, OUT_PARAMETER_D_MUST_BE_A_POINTER_TYPE_NOT_S, index, GetNameNode.executeUncached(arg)); } protected static boolean strchr(char[] chars, int code) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java index 6a289c5bfc..c3d6f9ef14 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrTypeBuiltins.java @@ -129,7 +129,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, @Cached HashingStorageGetItem getItem, @Cached HashingStorageAddAllToOther addAllToOtherNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject stgdict = PFactory.createStgDictObject(language); stgdict.paramfunc = CArgObjectBuiltins.PyCFuncPtrTypeParamFunc; @@ -160,7 +160,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, Object ob = getItem.execute(inliningTarget, stgdict.getDictStorage(), T_FLAGS_); if (!PGuards.isInteger(ob)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CLASS_MUST_DEFINE_FLAGS_WHICH_MUST_BE_AN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, CLASS_MUST_DEFINE_FLAGS_WHICH_MUST_BE_AN_INTEGER); } stgdict.flags = asNumber.execute(inliningTarget, ob) | TYPEFLAG_ISPOINTER; @@ -168,7 +168,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, ob = getItem.execute(inliningTarget, stgdict.getDictStorage(), T_ARGTYPES_); if (ob != null) { if (!PGuards.isPTuple(ob)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ARGTYPES_MUST_BE_A_SEQUENCE_OF_TYPES); + throw raiseNode.raise(inliningTarget, TypeError, ARGTYPES_MUST_BE_A_SEQUENCE_OF_TYPES); } SequenceStorage storage = ((PTuple) ob).getSequenceStorage(); Object[] obtuple = getArray.execute(inliningTarget, storage); @@ -181,7 +181,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, if (!PGuards.isPNone(ob)) { StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, ob); if (dict == null && !callableCheck.execute(inliningTarget, ob)) { - throw raiseNode.get(inliningTarget).raise(TypeError, RESTYPE_MUST_BE_A_TYPE_A_CALLABLE_OR_NONE1); + throw raiseNode.raise(inliningTarget, TypeError, RESTYPE_MUST_BE_A_TYPE_A_CALLABLE_OR_NONE1); } stgdict.restype = ob; Object checker = lookupAttr.execute(frame, inliningTarget, ob, T__CHECK_RETVAL_); @@ -192,7 +192,7 @@ static Object PyCFuncPtrType_new(VirtualFrame frame, Object type, Object[] args, } static Object[] converters_from_argtypes(VirtualFrame frame, Node inliningTarget, Object[] args, int nArgs, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, PyObjectLookupAttr lookupAttr) { Object[] converters = new Object[nArgs]; @@ -202,7 +202,7 @@ static Object[] converters_from_argtypes(VirtualFrame frame, Node inliningTarget cnv = lookupAttr.execute(frame, inliningTarget, tp, T_FROM_PARAM); if (cnv == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ITEM_D_IN_ARGTYPES_HAS_NO_FROM_PARAM_METHOD, i + 1); + throw raiseNode.raise(inliningTarget, TypeError, ITEM_D_IN_ARGTYPES_HAS_NO_FROM_PARAM_METHOD, i + 1); } converters[i] = cnv; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java index d03ce6ebfd..0f34e1b54a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerBuiltins.java @@ -91,7 +91,6 @@ import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -135,13 +134,13 @@ abstract static class PointerSetContentsNode extends Node { static void set(VirtualFrame frame, Node inliningTarget, CDataObject self, Object value, @Bind PythonLanguage language, @Cached PyTypeCheck pyTypeCheck, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached(inline = false) IsInstanceNode isInstanceNode, @Cached KeepRefNode keepRefNode, @Cached PointerNodes.WritePointerNode writePointerNode) { if (value == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, POINTER_DOES_NOT_SUPPORT_ITEM_DELETION); + throw raiseNode.raise(inliningTarget, TypeError, POINTER_DOES_NOT_SUPPORT_ITEM_DELETION); } StgDictObject stgdict = pyObjectStgDictNode.execute(inliningTarget, self); assert stgdict != null : "Cannot be NULL for pointer instances"; @@ -149,7 +148,7 @@ static void set(VirtualFrame frame, Node inliningTarget, CDataObject self, Objec if (!pyTypeCheck.isCDataObject(inliningTarget, value)) { boolean res = isInstanceNode.executeWith(frame, value, stgdict.proto); if (!res) { - raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_N_INSTEAD_OF_P, stgdict.proto, value); + raiseNode.raise(inliningTarget, TypeError, EXPECTED_N_INSTEAD_OF_P, stgdict.proto, value); } } @@ -176,10 +175,10 @@ static Object Pointer_new(Object type, @SuppressWarnings("unused") Object[] args @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); if (dict.proto == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_CREATE_INSTANCE_HAS_NO_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_CREATE_INSTANCE_HAS_NO_TYPE); } return pyCDataNewNode.execute(inliningTarget, type, dict); } @@ -210,9 +209,9 @@ static Object get_contents(CDataObject self, @SuppressWarnings("unused") PNone v @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached CtypesNodes.PyCDataFromBaseObjNode fromBaseObjNode, @Cached PointerNodes.ReadPointerNode readPointerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.b_ptr.isNull()) { - throw raiseNode.get(inliningTarget).raise(ValueError, NULL_POINTER_ACCESS); + throw raiseNode.raise(inliningTarget, ValueError, NULL_POINTER_ACCESS); } StgDictObject stgdict = pyObjectStgDictNode.execute(inliningTarget, self); @@ -253,13 +252,13 @@ static void Pointer_ass_item(VirtualFrame frame, CDataObject self, int index, Ob @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PointerNodes.ReadPointerNode readPointerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (value == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, POINTER_DOES_NOT_SUPPORT_ITEM_DELETION); + throw raiseNode.raise(inliningTarget, TypeError, POINTER_DOES_NOT_SUPPORT_ITEM_DELETION); } if (self.b_ptr.isNull()) { - throw raiseNode.get(inliningTarget).raise(ValueError, NULL_POINTER_ACCESS); + throw raiseNode.raise(inliningTarget, ValueError, NULL_POINTER_ACCESS); } StgDictObject stgdict = pyObjectStgDictNode.execute(inliningTarget, self); @@ -289,7 +288,7 @@ static Object Pointer_item(CDataObject self, int index, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, @Exclusive @Cached PointerNodes.ReadPointerNode readPointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.b_ptr.isNull()) { raiseNullPtr(inliningTarget, raiseNode); } @@ -309,8 +308,8 @@ static Object Pointer_item(CDataObject self, int index, } @InliningCutoff - private static void raiseNullPtr(Node inliningTarget, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(ValueError, NULL_POINTER_ACCESS); + private static void raiseNullPtr(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, ValueError, NULL_POINTER_ACCESS); } } @@ -325,7 +324,7 @@ static Object doInt(CDataObject self, int index, @Exclusive @Cached PyTypeStgDictNode pyTypeStgDictNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, @Exclusive @Cached PointerNodes.ReadPointerNode readPointerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return PointerGetItemNode.Pointer_item(self, index, inliningTarget, pyCDataGetNode, pyTypeStgDictNode, pyObjectStgDictNode, readPointerNode, raiseNode); } @@ -342,7 +341,7 @@ static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, @Cached TruffleString.FromByteArrayNode fromByteArrayNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { /* * Since pointers have no length, and we want to apply different semantics to negative * indices than normal slicing, we have to dissect the slice object ourselves. @@ -353,19 +352,19 @@ static Object doSubscript(VirtualFrame frame, CDataObject self, PSlice slice, } else { step = asSizeNode.executeExact(frame, inliningTarget, slice.getStep(), ValueError); if (step == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, SLICE_STEP_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, SLICE_STEP_CANNOT_BE_ZERO); } } if (slice.getStart() == PNone.NONE) { if (step < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, SLICE_START_IS_REQUIRED_FOR_STEP_0); + throw raiseNode.raise(inliningTarget, ValueError, SLICE_START_IS_REQUIRED_FOR_STEP_0); } start = 0; } else { start = asSizeNode.executeExact(frame, inliningTarget, slice.getStart(), ValueError); } if (slice.getStop() == PNone.NONE) { - throw raiseNode.get(inliningTarget).raise(ValueError, SLICE_STOP_IS_REQUIRED); + throw raiseNode.raise(inliningTarget, ValueError, SLICE_STOP_IS_REQUIRED); } stop = asSizeNode.executeExact(frame, inliningTarget, slice.getStop(), ValueError); int len; @@ -432,12 +431,12 @@ static Object doGeneric(VirtualFrame frame, CDataObject self, Object item, @Exclusive @Cached PointerNodes.ReadPointerNode readPointerNode, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, @Cached PyIndexCheckNode indexCheckNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, item)) { int i = asSizeNode.executeExact(frame, inliningTarget, item, IndexError); return PointerGetItemNode.Pointer_item(self, i, inliningTarget, pyCDataGetNode, pyTypeStgDictNode, pyObjectStgDictNode, readPointerNode, raiseNode); } - throw raiseNode.get(inliningTarget).raise(TypeError, POINTER_INDICES_MUST_BE_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, POINTER_INDICES_MUST_BE_INTEGER); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java index 885b2586f8..252b5288ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCPointerTypeBuiltins.java @@ -130,7 +130,7 @@ static Object PyCPointerType_new(VirtualFrame frame, Object type, Object[] args, @Cached TruffleStringBuilder.ToStringNode toStringNode, @Cached StringUtils.SimpleTruffleStringFormatNode formatNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * stgdict items size, align, length contain info about pointers itself, stgdict.proto * has info about the pointed to type! @@ -186,9 +186,9 @@ protected abstract static class FromParamNode extends PythonBinaryBuiltinNode { /* _byref consumes a refcount to its argument */ static PyCArgObject byref(Node inliningTarget, Object obj, PyTypeCheck pyTypeCheck, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (!pyTypeCheck.isCDataObject(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, EXPECTED_CDATA_INSTANCE); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, EXPECTED_CDATA_INSTANCE); } CDataObject cdata = (CDataObject) obj; @@ -217,7 +217,7 @@ static Object PyCPointerType_from_param(VirtualFrame frame, Object type, Object @Cached PyObjectStgDictNode pyObjectStgDictNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CDataTypeFromParamNode fromParamNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject typedict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); /* * If we expect POINTER(), but receive a instance, accept it by calling @@ -251,7 +251,7 @@ static Object PyCPointerType_set_type(Object self, TruffleString type, @Cached HashingStorageSetItem setItem, @Cached IsTypeNode isTypeNode, @Cached PyTypeStgDictNode pyTypeStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, self, raiseNode); PyCPointerType_SetProto(inliningTarget, dict, type, isTypeNode, pyTypeStgDictNode, raiseNode); dict.setDictStorage(setItem.execute(inliningTarget, dict.getDictStorage(), T__TYPE_, type)); @@ -261,8 +261,8 @@ static Object PyCPointerType_set_type(Object self, TruffleString type, @SuppressWarnings("unused") @Specialization(guards = "!isString(type)") static Object error(Object self, Object type, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, TYPE_MUST_BE_A_TYPE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, TYPE_MUST_BE_A_TYPE); } } @@ -281,12 +281,12 @@ static Object error(Object self, Object type, static void PyCPointerType_SetProto(Node inliningTarget, StgDictObject stgdict, Object proto, IsTypeNode isTypeNode, PyTypeStgDictNode pyTypeStgDictNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (proto == null || !isTypeNode.execute(inliningTarget, proto)) { - throw raiseNode.get(inliningTarget).raise(TypeError, TYPE_MUST_BE_A_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, TYPE_MUST_BE_A_TYPE); } if (pyTypeStgDictNode.execute(inliningTarget, proto) == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, TYPE_MUST_HAVE_STORAGE_INFO); + throw raiseNode.raise(inliningTarget, TypeError, TYPE_MUST_HAVE_STORAGE_INFO); } stgdict.proto = proto; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java index fefdf623ac..7e479d1484 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCSimpleTypeBuiltins.java @@ -152,7 +152,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, @Cached TruffleString.EqualNode eqNode, @Cached TruffleString.FromCharArrayUTF16Node fromCharArrayNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * create the new instance (which is a class, since we are a metatype!) @@ -161,7 +161,7 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, Object proto = lookupAttrType.execute(frame, inliningTarget, result, T__TYPE_); if (proto == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, CLASS_MUST_DEFINE_A_TYPE_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, AttributeError, CLASS_MUST_DEFINE_A_TYPE_ATTRIBUTE); } TruffleString proto_str; int proto_len; @@ -169,19 +169,19 @@ static Object PyCSimpleType_new(VirtualFrame frame, Object type, Object[] args, proto_str = toTruffleStringNode.execute(inliningTarget, proto); proto_len = codePointLengthNode.execute(proto_str, TS_ENCODING); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, CLASS_MUST_DEFINE_A_TYPE_STRING_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, TypeError, CLASS_MUST_DEFINE_A_TYPE_STRING_ATTRIBUTE); } if (proto_len != 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, A_TYPE_ATTRIBUTE_WHICH_MUST_BE_A_STRING_OF_LENGTH_1); + throw raiseNode.raise(inliningTarget, ValueError, A_TYPE_ATTRIBUTE_WHICH_MUST_BE_A_STRING_OF_LENGTH_1); } if (indexOfStringNode.execute(T_SIMPLE_TYPE_CHARS, proto_str, 0, SIMPLE_TYPE_CHARS_LENGTH, TS_ENCODING) < 0) { - throw raiseNode.get(inliningTarget).raise(AttributeError, WHICH_MUST_BE_A_SINGLE_CHARACTER_STRING_CONTAINING_ONE_OF_S, T_SIMPLE_TYPE_CHARS); + throw raiseNode.raise(inliningTarget, AttributeError, WHICH_MUST_BE_A_SINGLE_CHARACTER_STRING_CONTAINING_ONE_OF_S, T_SIMPLE_TYPE_CHARS); } char code = (char) codePointAtIndexNode.execute(proto_str, 0, TS_ENCODING); FieldDesc fmt = FFIType._ctypes_get_fielddesc(code); if (fmt == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, TYPE_S_NOT_SUPPORTED, proto_str); + throw raiseNode.raise(inliningTarget, ValueError, TYPE_S_NOT_SUPPORTED, proto_str); } StgDictObject stgdict = PFactory.createStgDictObject(language); @@ -309,7 +309,7 @@ static Object PyCSimpleType_from_param(VirtualFrame frame, Object type, Object v @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached PyObjectLookupAttr lookupAsParam, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * If the value is already an instance of the requested type, we can use it as is */ @@ -345,7 +345,7 @@ static Object PyCSimpleType_from_param(VirtualFrame frame, Object type, Object v // Py_LeaveRecursiveCall(); return r; } - throw raiseNode.get(inliningTarget).raise(TypeError, WRONG_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, WRONG_TYPE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java index 1b6d2405f8..6a212a881f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -110,13 +110,13 @@ public void postInitialize(Python3Core core) { } static void Simple_set_value(VirtualFrame frame, Node inliningTarget, CDataObject self, Object value, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, PyObjectStgDictNode pyObjectStgDictNode, SetFuncNode setFuncNode, KeepRefNode keepRefNode) { StgDictObject dict = pyObjectStgDictNode.execute(inliningTarget, self); if (value == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANT_DELETE_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, TypeError, CANT_DELETE_ATTRIBUTE); } assert dict != null : "Cannot be NULL for CDataObject instances"; assert dict.setfunc != FieldSet.nil; @@ -133,7 +133,7 @@ static Object newCData(Object type, @SuppressWarnings("unused") Object[] args, @ @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); return pyCDataNewNode.execute(inliningTarget, type, dict); } @@ -149,7 +149,7 @@ static Object Simple_init(VirtualFrame frame, CDataObject self, Object[] args, @ @Cached SetFuncNode setFuncNode, @Cached KeepRefNode keepRefNode, @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (args.length > 0) { Simple_set_value(frame, inliningTarget, self, args[0], raiseNode, pyObjectStgDictNode, setFuncNode, keepRefNode); } @@ -178,7 +178,7 @@ static Object set_value(VirtualFrame frame, CDataObject self, Object value, @Cached SetFuncNode setFuncNode, @Cached KeepRefNode keepRefNode, @Exclusive @Cached PyObjectStgDictNode pyObjectStgDictNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Simple_set_value(frame, inliningTarget, self, value, raiseNode, pyObjectStgDictNode, setFuncNode, keepRefNode); return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java index 5be831605e..42a22fdc9e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StgDictBuiltins.java @@ -197,10 +197,10 @@ static void MakeFields(VirtualFrame frame, Object type, CFieldObject descr, int @Cached("create(T__FIELDS_)") GetAttributeNode getAttrString, @Cached MakeFieldsNode recursiveNode, @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object fields = getAttrString.executeObject(frame, descr.proto); if (!sequenceCheckNode.execute(inliningTarget, fields)) { - throw raiseNode.get(inliningTarget).raise(TypeError, FIELDS_MUST_BE_A_SEQUENCE); + throw raiseNode.raise(inliningTarget, TypeError, FIELDS_MUST_BE_A_SEQUENCE); } PythonContext context = PythonContext.get(inliningTarget); @@ -215,7 +215,7 @@ static void MakeFields(VirtualFrame frame, Object type, CFieldObject descr, int Object fname = array[0]; CFieldObject fdescr = (CFieldObject) getAttributeNode.execute(frame, inliningTarget, descr.proto, fname); if (getClassNode.execute(inliningTarget, fdescr) != context.lookupType(CField)) { - throw raiseNode.get(inliningTarget).raise(TypeError, UNEXPECTED_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, UNEXPECTED_TYPE); } if (fdescr.anonymous != 0) { Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); @@ -252,10 +252,10 @@ static StgDictObject executeUncached(Object type) { return PyTypeStgDictNodeGen.getUncached().execute(null, type); } - protected StgDictObject checkAbstractClass(Node inliningTarget, Object type, PRaiseNode.Lazy raiseNode) { + protected StgDictObject checkAbstractClass(Node inliningTarget, Object type, PRaiseNode raiseNode) { StgDictObject dict = execute(inliningTarget, type); if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ABSTRACT_CLASS); + throw raiseNode.raise(inliningTarget, TypeError, ABSTRACT_CLASS); } return dict; } @@ -320,20 +320,20 @@ static void MakeAnonFields(VirtualFrame frame, Object type, @Cached GetClassNode getClassNode, @Cached PyObjectGetAttrO getAttr, @Cached PyObjectLookupAttr lookupAnon, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object anon = lookupAnon.execute(frame, inliningTarget, type, T__ANONYMOUS_); if (PGuards.isPNone(anon)) { return; } if (!sequenceCheckNode.execute(inliningTarget, anon)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ANONYMOUS_MUST_BE_A_SEQUENCE); + throw raiseNode.raise(inliningTarget, TypeError, ANONYMOUS_MUST_BE_A_SEQUENCE); } for (int i = 0; i < sizeNode.execute(frame, inliningTarget, anon); ++i) { Object fname = getItemNode.execute(frame, inliningTarget, anon, i); /* borrowed */ CFieldObject descr = (CFieldObject) getAttr.execute(frame, inliningTarget, type, fname); if (getClassNode.execute(inliningTarget, descr) != CField) { - throw raiseNode.get(inliningTarget).raise(AttributeError, S_IS_SPECIFIED_IN_ANONYMOUS_BUT_NOT_IN_FIELDS, fname); + throw raiseNode.raise(inliningTarget, AttributeError, S_IS_SPECIFIED_IN_ANONYMOUS_BUT_NOT_IN_FIELDS, fname); } descr.anonymous = 1; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java index 76692aed21..cdace3dd84 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructUnionTypeBuiltins.java @@ -236,7 +236,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O @Cached CastToTruffleStringNode castToTruffleStringNode, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * HACK Alert: I cannot be bothered to fix ctypes.com, so there has to be a way to use * the old, broken semantics: _fields_ are not extended but replaced in subclasses. @@ -260,7 +260,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O pack = asSizeNode.executeLossy(frame, inliningTarget, tmp); } catch (PException e) { e.expectTypeOrOverflowError(inliningTarget, isBuiltinClassProfile); - throw raiseNode.get(inliningTarget).raise(ValueError, PACK_MUST_BE_A_NON_NEGATIVE_INTEGER); + throw raiseNode.raise(inliningTarget, ValueError, PACK_MUST_BE_A_NON_NEGATIVE_INTEGER); } } @@ -270,14 +270,14 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O len = sizeNode.execute(frame, inliningTarget, fields); } catch (PException e) { e.expectTypeError(inliningTarget, isBuiltinClassProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, FIELDS_MUST_BE_A_SEQUENCE_OF_PAIRS); + throw raiseNode.raise(inliningTarget, TypeError, FIELDS_MUST_BE_A_SEQUENCE_OF_PAIRS); } StgDictObject stgdict = pyTypeStgDictNode.execute(inliningTarget, type); /* If this structure/union is already marked final we cannot assign _fields_ anymore. */ if ((stgdict.flags & DICTFLAG_FINAL) != 0) { /* is final ? */ - throw raiseNode.get(inliningTarget).raise(AttributeError, FIELDS_IS_FINAL); + throw raiseNode.raise(inliningTarget, AttributeError, FIELDS_IS_FINAL); } stgdict.format = null; @@ -346,13 +346,13 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O Object pair = getItemNode.execute(frame, inliningTarget, fields, i); // !PyArg_ParseTuple(pair, "UO|i", & name, &desc, &bitsize) if (!PGuards.isPTuple(pair)) { - fieldsError(raiseNode.get(inliningTarget)); + fieldsError(inliningTarget, raiseNode); } SequenceStorage storage = ((PTuple) pair).getSequenceStorage(); Object[] tuple = getArray.execute(inliningTarget, storage); int tupleLen = storage.length(); if (tupleLen < 2 || !PGuards.isString(tuple[0]) || (tupleLen > 2 && !PGuards.isInteger(tuple[2]))) { - fieldsError(raiseNode.get(inliningTarget)); + fieldsError(inliningTarget, raiseNode); } Object name = tuple[0]; Object desc = tuple[1]; @@ -363,7 +363,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O } StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, desc); if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); + throw raiseNode.raise(inliningTarget, TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); } stgdict.ffi_type_pointer.elements[ffi_ofs + i] = dict.ffi_type_pointer; if ((dict.flags & (TYPEFLAG_ISPOINTER | TYPEFLAG_HASPOINTER)) != 0) { @@ -389,10 +389,10 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O } /* else fall through */ default: - throw raiseNode.get(inliningTarget).raise(TypeError, BIT_FIELDS_NOT_ALLOWED_FOR_TYPE_S, getNameNode.execute(inliningTarget, desc)); + throw raiseNode.raise(inliningTarget, TypeError, BIT_FIELDS_NOT_ALLOWED_FOR_TYPE_S, getNameNode.execute(inliningTarget, desc)); } if (bitsize <= 0 || bitsize > dict.size * 8) { - throw raiseNode.get(inliningTarget).raise(ValueError, NUMBER_OF_BITS_INVALID_FOR_BIT_FIELD); + throw raiseNode.raise(inliningTarget, ValueError, NUMBER_OF_BITS_INVALID_FOR_BIT_FIELD); } } else { bitsize = 0; @@ -556,19 +556,19 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O */ // !PyArg_ParseTuple(pair, "UO|i", & name, &desc, &bitsize) if (!PGuards.isPTuple(pair)) { - fieldsError(raiseNode.get(inliningTarget)); + fieldsError(inliningTarget, raiseNode); } SequenceStorage storage = ((PTuple) pair).getSequenceStorage(); Object[] tuple = getArray.execute(inliningTarget, storage); int tupleLen = storage.length(); if (tupleLen < 2 || !PGuards.isString(tuple[0]) || (tupleLen > 2 && !PGuards.isInteger(tuple[2]))) { - fieldsError(raiseNode.get(inliningTarget)); + fieldsError(inliningTarget, raiseNode); } Object desc = tuple[1]; StgDictObject dict = pyTypeStgDictNode.execute(inliningTarget, desc); /* Possibly this check could be avoided, but see above comment. */ if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); + throw raiseNode.raise(inliningTarget, TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); } assert (element_index < (ffi_ofs + len)); /* will be used below */ if (!pyTypeCheck.isPyCArrayTypeObject(inliningTarget, desc)) { @@ -578,7 +578,7 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O int length = dict.length; StgDictObject edict = pyTypeStgDictNode.execute(inliningTarget, dict.proto); if (edict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); + throw raiseNode.raise(inliningTarget, TypeError, SECOND_ITEM_IN_FIELDS_TUPLE_INDEX_D_MUST_BE_A_C_TYPE, i); } FFIType ffiType = new FFIType( length * edict.ffi_type_pointer.size, @@ -607,15 +607,15 @@ static void PyCStructUnionType_update_stgdict(VirtualFrame frame, Object type, O * We did check that this flag was NOT set above, it must not have been set until now. */ if ((stgdict.flags & DICTFLAG_FINAL) != 0) { - throw raiseNode.get(inliningTarget).raise(AttributeError, STRUCTURE_OR_UNION_CANNOT_CONTAIN_ITSELF); + throw raiseNode.raise(inliningTarget, AttributeError, STRUCTURE_OR_UNION_CANNOT_CONTAIN_ITSELF); } stgdict.flags |= DICTFLAG_FINAL; makeAnonFieldsNode.execute(frame, type); } - static void fieldsError(PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, FIELDS_MUST_BE_A_SEQUENCE_OF_NAME_C_TYPE_PAIRS); + static void fieldsError(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, TypeError, FIELDS_MUST_BE_A_SEQUENCE_OF_NAME_C_TYPE_PAIRS); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructureBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructureBuiltins.java index b778fed0c6..100b4c048a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructureBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/StructureBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -113,7 +113,7 @@ static Object GenericPyCDataNew(Object type, @SuppressWarnings("unused") Object[ @Bind("this") Node inliningTarget, @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached CtypesNodes.GenericPyCDataNewNode pyCDataNewNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { StgDictObject dict = pyTypeStgDictNode.checkAbstractClass(inliningTarget, type, raiseNode); return pyCDataNewNode.execute(inliningTarget, type, dict); } @@ -136,12 +136,12 @@ static Object Struct_init(VirtualFrame frame, CDataObject self, Object[] args, P @Cached PyTypeStgDictNode pyTypeStgDictNode, @Cached GetBaseClassNode getBaseClassNode, @Cached TruffleString.EqualNode equalNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (args.length > 0) { int res = _init_pos_args(frame, inliningTarget, self, getClassNode.execute(inliningTarget, self), args, kwds, 0, indirectCallData, setAttr, getItemNode, toString, getItem, pyTypeStgDictNode, getBaseClassNode, equalNode, raiseNode, RECURSION_LIMIT); if (res < args.length) { - throw raiseNode.get(inliningTarget).raise(TypeError, TOO_MANY_INITIALIZERS); + throw raiseNode.raise(inliningTarget, TypeError, TOO_MANY_INITIALIZERS); } } @@ -173,7 +173,7 @@ static int _init_pos_args(VirtualFrame frame, Node inliningTarget, Object self, PyTypeStgDictNode pyTypeStgDictNode, GetBaseClassNode getBaseClassNode, EqualNode equalNode, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, int recursionLimit) { Object fields; int index = idx; @@ -206,9 +206,7 @@ static int _init_pos_args(VirtualFrame frame, Node inliningTarget, Object self, Object val = args[i + index]; if (kwds.length > 0) { if (KeywordsStorage.findStringKey(kwds, name, equalNode) != -1) { - // using execute() instead of raise() because we need to pass raisingNode - // explicitly (raiseNode might be uncached) - throw raiseNode.get(inliningTarget).execute(inliningTarget, TypeError, null, PNone.NO_VALUE, DUPLICATE_VALUES_FOR_FIELD_S, new Object[]{name}); + throw raiseNode.raise(inliningTarget, TypeError, DUPLICATE_VALUES_FOR_FIELD_S, name); } } @@ -225,7 +223,7 @@ static int _init_pos_args_boundary(Object self, Object type, Object[] args, PKey return _init_pos_args(null, null, self, type, args, kwds, idx, indirectCallData, setAttr, getItemNode, CastToTruffleStringNode.getUncached(), HashingStorageGetItemNodeGen.getUncached(), PyTypeStgDictNodeGen.getUncached(), - GetBaseClassNode.getUncached(), TruffleString.EqualNode.getUncached(), PRaiseNode.Lazy.getUncached(), 0); + GetBaseClassNode.getUncached(), TruffleString.EqualNode.getUncached(), PRaiseNode.getUncached(), 0); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java index 2f7f6f3093..a48fc8965c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/UnionTypeBuiltins.java @@ -112,7 +112,7 @@ static void doStringKey(VirtualFrame frame, Object object, TruffleString key, Ob static void doGenericKey(VirtualFrame frame, Object object, Object keyObject, Object value, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castKeyNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Exclusive @Cached ObjectNodes.GenericSetAttrNode genericSetAttrNode, @Shared @Cached WriteAttributeToObjectNode write, @Shared @Cached TruffleString.EqualNode equalNode, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory/PointerNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory/PointerNodes.java index f018dbe61e..bd13e21cf8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory/PointerNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory/PointerNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -671,7 +671,7 @@ static long doMemoryView(Node inliningTarget, MemoryBlock memory, MemoryViewStor throw CompilerDirectives.shouldNotReachHere(e); } } else { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_CANNOT_BE_CONVERTED_TO_NATIVE_MEMORY); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_CANNOT_BE_CONVERTED_TO_NATIVE_MEMORY); } memory.storage = new LongPointerStorage(nativePointer); return nativePointer + offset; @@ -689,7 +689,7 @@ static long doPythonObject(Node inliningTarget, @SuppressWarnings("unused") Memo if (!lib.isPointer(nativeObject)) { lib.toNative(nativeObject); if (!lib.isPointer(nativeObject)) { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_CONVERT_OBJECT_POINTER_TO_NATIVE); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_CONVERT_OBJECT_POINTER_TO_NATIVE); } } try { @@ -716,7 +716,7 @@ public final Object execute(Node inliningTarget, Pointer ptr) { @Specialization static Object doObjectPointer(Node inliningTarget, @SuppressWarnings("unused") MemoryBlock memory, ObjectPointerStorage storage, int offset) { if (offset != 0) { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_APPLY_OFFSET_TO_AN_OBJECT_POINTER); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_APPLY_OFFSET_TO_AN_OBJECT_POINTER); } return storage.pointer; } @@ -734,7 +734,7 @@ public final long execute(Node inliningTarget, Pointer ptr) { @Specialization @SuppressWarnings("unused") static long doObjectPointer(Node inliningTarget, MemoryBlock memory, ObjectPointerStorage storage, int offset) { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_CONVERT_OBJECT_POINTER_TO_NATIVE); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CANNOT_CONVERT_OBJECT_POINTER_TO_NATIVE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java index 3c0ca89832..7c84fcadaf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java @@ -124,14 +124,14 @@ Object doReduce(VirtualFrame frame, Object function, Object sequence, Object ini @Cached InlinedConditionProfile initialNoValueProfile, @Cached IsBuiltinObjectProfile stopIterProfile, @Cached IsBuiltinObjectProfile typeError, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object initial = initialNoValueProfile.profile(inliningTarget, PGuards.isNoValue(initialIn)) ? null : initialIn; Object seqIterator, result = initial; try { seqIterator = getIter.execute(frame, inliningTarget, sequence); } catch (PException pe) { pe.expectTypeError(inliningTarget, typeError); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_ARG_N_MUST_SUPPORT_ITERATION, "reduce()", 2); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_ARG_N_MUST_SUPPORT_ITERATION, "reduce()", 2); } Object[] args = new Object[2]; @@ -160,7 +160,7 @@ Object doReduce(VirtualFrame frame, Object function, Object sequence, Object ini reportLoopCount(this, count >= 0 ? count : Integer.MAX_VALUE); if (result == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, REDUCE_EMPTY_SEQ); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, REDUCE_EMPTY_SEQ); } return result; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java index 22456534d6..8a9614ee78 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java @@ -66,12 +66,14 @@ import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; @CoreFunctions(extendClasses = PythonBuiltinClassType.PKeyWrapper) public final class KeyWrapperBuiltins extends PythonBuiltins { @@ -120,8 +122,8 @@ boolean doCompare(VirtualFrame frame, PKeyWrapper self, PKeyWrapper other, @Fallback @SuppressWarnings("unused") static boolean fallback(Object self, Object other, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, OTHER_ARG_MUST_BE_KEY); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, OTHER_ARG_MUST_BE_KEY); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java index 9d540461cd..0891a08e92 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/LruCacheWrapperBuiltins.java @@ -150,10 +150,10 @@ static Object lruCacheNew(VirtualFrame frame, Object type, @Cached PyIndexCheckNode indexCheck, @Cached PyNumberAsSizeNode numberAsSize, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!callableCheck.execute(inliningTarget, func)) { - throw raiseNode.get(inliningTarget).raise(TypeError, THE_FIRST_ARGUMENT_MUST_BE_CALLABLE); + throw raiseNode.raise(inliningTarget, TypeError, THE_FIRST_ARGUMENT_MUST_BE_CALLABLE); } /* select the caching function, and make/inc maxsize_O */ @@ -174,7 +174,7 @@ static Object lruCacheNew(VirtualFrame frame, Object type, wrapper = WrapperType.BOUNDED; } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, MAXSIZE_SHOULD_BE_INTEGER_OR_NONE); + throw raiseNode.raise(inliningTarget, TypeError, MAXSIZE_SHOULD_BE_INTEGER_OR_NONE); } PythonContext context = PythonContext.get(inliningTarget); @@ -258,8 +258,8 @@ static Object setDict(LruCacheObject self, PDict mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static Object setDict(@SuppressWarnings("unused") LruCacheObject self, Object mapping, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java index b7bfb230c8..612145e5f5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java @@ -238,10 +238,10 @@ static Object createGeneric(Object cls, Object[] args, PKeyword[] keywords, @Cached PyCallableCheckNode callableCheckNode, @Bind PythonLanguage language, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object function = args[0]; if (!callableCheckNode.execute(inliningTarget, function)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_ARG_MUST_BE_CALLABLE, "the first"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_ARG_MUST_BE_CALLABLE, "the first"); } final Object[] funcArgs = PythonUtils.arrayCopyOfRange(args, 1, args.length); @@ -257,8 +257,8 @@ static Object createGeneric(Object cls, Object[] args, PKeyword[] keywords, @Specialization(guards = "!atLeastOneArg(args)") @SuppressWarnings("unused") static Object noCallable(Object cls, Object[] args, PKeyword[] keywords, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, TYPE_S_TAKES_AT_LEAST_ONE_ARGUMENT, "partial"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, TYPE_S_TAKES_AT_LEAST_ONE_ARGUMENT, "partial"); } } @@ -302,8 +302,8 @@ static Object setDict(PPartial self, PDict mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static Object setDict(@SuppressWarnings("unused") PPartial self, Object mapping, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } } @@ -358,9 +358,9 @@ static Object setState(VirtualFrame frame, PPartial self, PTuple state, @Cached TupleNodes.ConstructTupleNode constructTupleNode, @Cached HashingStorageCopy copyStorageNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (state.getSequenceStorage().length() != 4) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); } final Object function = getItemNode.execute(inliningTarget, state, 0); @@ -371,7 +371,7 @@ static Object setState(VirtualFrame frame, PPartial self, PTuple state, if (!callableCheckNode.execute(inliningTarget, function) || !PGuards.isPTuple(fnArgs) || (fnKwargs != PNone.NONE && !PGuards.isDict(fnKwargs))) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); } self.setFn(function); @@ -407,8 +407,8 @@ static Object setState(VirtualFrame frame, PPartial self, PTuple state, @Fallback @SuppressWarnings("unused") static Object fallback(Object self, Object state, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, INVALID_PARTIAL_STATE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Blake2ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Blake2ModuleBuiltins.java index 7cef0d745d..fb55766a3c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Blake2ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Blake2ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -129,9 +129,9 @@ static Object newDigest(VirtualFrame frame, Object type, Object data, int digest PNone key, PNone salt, PNone person, int fanout, int depth, int leafSize, int nodeOffset, int nodeDepth, int innerSize, boolean lastNode, boolean usedforsecurity, @Bind("this") Node inliningTarget, @Cached HashlibModuleBuiltins.CreateDigestNode createNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (fanout != 1 || depth != 1 || leafSize != 0 || nodeOffset != 0 || nodeDepth != 0 || innerSize != 0 || lastNode) { - throw fail(frame, type, data, digestSize, key, salt, person, fanout, depth, leafSize, nodeOffset, nodeDepth, innerSize, lastNode, usedforsecurity, raiseNode.get(inliningTarget)); + throw fail(frame, type, data, digestSize, key, salt, person, fanout, depth, leafSize, nodeOffset, nodeDepth, innerSize, lastNode, usedforsecurity, raiseNode); } PythonBuiltinClassType resultType = null; if (type instanceof PythonBuiltinClass builtinType) { @@ -139,7 +139,7 @@ static Object newDigest(VirtualFrame frame, Object type, Object data, int digest } else if (type instanceof PythonBuiltinClassType enumType) { resultType = enumType; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.WRONG_TYPE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.WRONG_TYPE); } String javaName; String pythonName; @@ -164,8 +164,8 @@ static Object newDigest(VirtualFrame frame, Object type, Object data, int digest static PException fail(VirtualFrame frame, Object type, Object data, Object digestSize, Object key, Object salt, Object person, Object fanout, Object depth, Object leafSize, Object nodeOffset, Object nodeDepth, Object innerSize, Object lastNode, Object usedforsecurity, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DIGEST_SIZE_BLAKE_ARGUMENT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DIGEST_SIZE_BLAKE_ARGUMENT); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java index a8678ca506..7cb16c038e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/DigestObjectBuiltins.java @@ -90,11 +90,11 @@ abstract static class CopyNode extends PythonUnaryBuiltinNode { @Specialization static DigestObject copy(DigestObject self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return self.copy(); } catch (CloneNotSupportedException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError); } } } @@ -135,9 +135,9 @@ static PNone update(VirtualFrame frame, DigestObject self, Object buffer, @Bind("this") Node inliningTarget, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.wasReset()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.UPDATING_FINALIZED_DIGEST_IS_NOT_SUPPORTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UPDATING_FINALIZED_DIGEST_IS_NOT_SUPPORTED); } try { self.update(bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java index 9dff6e5708..eaabeb4ff1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashlibModuleBuiltins.java @@ -201,13 +201,13 @@ static Object cmpStrings(Object a, Object b, @Cached TruffleString.GetCodeRangeNode getCodeRangeNode, @Cached CastToTruffleStringNode castA, @Cached CastToTruffleStringNode castB, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString tsA = castA.execute(inliningTarget, a); TruffleString tsB = castB.execute(inliningTarget, b); CodeRange crA = getCodeRangeNode.execute(tsA, TS_ENCODING); CodeRange crB = getCodeRangeNode.execute(tsB, TS_ENCODING); if (!(crA.isSubsetOf(CodeRange.ASCII) && crB.isSubsetOf(CodeRange.ASCII))) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.COMPARING_STRINGS_WITH_NON_ASCII); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.COMPARING_STRINGS_WITH_NON_ASCII); } byte[] bytesA = getByteArrayNode.execute(tsA, TS_ENCODING); byte[] bytesB = getByteArrayNode.execute(castB.execute(inliningTarget, b), TS_ENCODING); @@ -220,7 +220,7 @@ static boolean cmpBuffers(VirtualFrame frame, Object a, Object b, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary accessLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (acquireLib.hasBuffer(a) && acquireLib.hasBuffer(b)) { Object bufferA = acquireLib.acquireReadonly(a, frame, indirectCallData); try { @@ -236,7 +236,7 @@ static boolean cmpBuffers(VirtualFrame frame, Object a, Object b, accessLib.release(bufferA, frame, indirectCallData); } } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_OR_COMBINATION_OF_TYPES, a, b); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_OR_COMBINATION_OF_TYPES, a, b); } } @@ -254,10 +254,10 @@ static Object hmacDigest(VirtualFrame frame, PythonModule self, Object key, Obje @Bind("this") Node inliningTarget, @Cached HmacNewNode newNode, @Cached DigestObjectBuiltins.DigestNode digestNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (msg instanceof PNone) { // hmac_digest is a bit more strict - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, msg); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, msg); } Object hmacObject = newNode.execute(frame, self, key, msg, digest); return digestNode.execute(frame, hmacObject); @@ -272,8 +272,8 @@ abstract static class HmacNewNode extends PythonQuaternaryBuiltinNode { @SuppressWarnings("unused") @Specialization static Object hmacNewError(PythonModule self, Object key, Object msg, PNone digest, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_POS, "hmac_new", "digestmod", 3); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_POS, "hmac_new", "digestmod", 3); } @Specialization(guards = "!isString(digestmod)") @@ -285,7 +285,7 @@ static Object hmacNewFromFunction(VirtualFrame frame, PythonModule self, Object @Shared("concatStr") @Cached TruffleString.ConcatNode concatStr, @Shared("acquireLib") @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @Shared("bufferLib") @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { // cast guaranteed in our initialize EconomicMapStorage constructors = self.getModuleState(EconomicMapStorage.class); Object name = getItemNode.execute(frame, inliningTarget, constructors, digestmod); @@ -293,7 +293,7 @@ static Object hmacNewFromFunction(VirtualFrame frame, PythonModule self, Object assert name instanceof TruffleString; // guaranteed in our initialize return hmacNew(self, key, msg, name, inliningTarget, castStr, castJStr, concatStr, acquireLib, bufferLib, raiseNode); } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnsupportedDigestmodError); } } @@ -305,11 +305,11 @@ static Object hmacNew(@SuppressWarnings("unused") PythonModule self, Object keyO @Shared("concatStr") @Cached TruffleString.ConcatNode concatStr, @Shared("acquireLib") @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @Shared("bufferLib") @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString digestmod = castStr.execute(inliningTarget, digestmodObj); Object key; if (!acquireLib.hasBuffer(keyObj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, keyObj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, keyObj); } else { key = acquireLib.acquireReadonly(keyObj); } @@ -320,7 +320,7 @@ static Object hmacNew(@SuppressWarnings("unused") PythonModule self, Object keyO } else if (acquireLib.hasBuffer(msgObj)) { msg = acquireLib.acquireReadonly(msgObj); } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, msgObj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, msgObj); } try { byte[] msgBytes = msg == null ? null : bufferLib.getInternalOrCopiedByteArray(msg); @@ -329,7 +329,7 @@ static Object hmacNew(@SuppressWarnings("unused") PythonModule self, Object keyO return PFactory.createDigestObject(PythonLanguage.get(inliningTarget), PythonBuiltinClassType.HashlibHmac, castJStr.execute(concatStr.execute(HMAC_PREFIX, digestmod, TS_ENCODING, true)), mac); } catch (InvalidKeyException | NoSuchAlgorithmException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError, e); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnsupportedDigestmodError, e); } finally { if (msg != null) { bufferLib.release(msg); @@ -365,14 +365,14 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, PythonBuiltinClassTy @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary(limit = "2") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { Object buffer; if (value instanceof PNone) { buffer = null; } else if (acquireLib.hasBuffer(value)) { buffer = acquireLib.acquireReadonly(value, frame, indirectCallData); } else { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, value); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, value); } try { byte[] bytes = buffer == null ? null : bufferLib.getInternalOrCopiedByteArray(buffer); @@ -381,7 +381,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, PythonBuiltinClassTy try { digest = createDigest(javaName, bytes, bytesLen); } catch (NoSuchAlgorithmException e) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.UnsupportedDigestmodError, e); + throw raise.raise(inliningTarget, PythonBuiltinClassType.UnsupportedDigestmodError, e); } return PFactory.createDigestObject(PythonLanguage.get(inliningTarget), type, pythonName, digest); } finally { @@ -458,8 +458,8 @@ abstract static class HashNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object hash(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HASH"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HASH"); } } @@ -469,8 +469,8 @@ abstract static class HashXofNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object hash(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HASHXOF"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HASHXOF"); } } @@ -480,8 +480,8 @@ abstract static class HmacNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object hash(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HMAC"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_hashlib.HMAC"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Md5ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Md5ModuleBuiltins.java index 4dd0f06807..f944f595f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Md5ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Md5ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -82,8 +82,8 @@ abstract static class Md5Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object md5(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_md5.md5"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_md5.md5"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha1ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha1ModuleBuiltins.java index 98e8ef5064..34ec8c3856 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha1ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha1ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -82,8 +82,8 @@ abstract static class Sha1Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object sha1(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha1.sha1"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha1.sha1"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha256ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha256ModuleBuiltins.java index 738dfd11c0..f62bbde73e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha256ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha256ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -93,8 +93,8 @@ abstract static class Sha224Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object sha224(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha256.sha224"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha256.sha224"); } } @@ -104,8 +104,8 @@ abstract static class Sha256Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object sha256(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha256.sha256"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha256.sha256"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha3ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha3ModuleBuiltins.java index 66e35129f7..56cae0bf8f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha3ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha3ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -87,14 +87,14 @@ abstract static class ShaNode extends PythonBuiltinNode { static Object newDigest(VirtualFrame frame, Object type, Object buffer, @SuppressWarnings("unused") Object usedForSecurity, @Bind("this") Node inliningTarget, @Cached HashlibModuleBuiltins.CreateDigestNode createNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonBuiltinClassType resultType; if (type instanceof PythonBuiltinClass builtinType) { resultType = builtinType.getType(); } else if (type instanceof PythonBuiltinClassType enumType) { resultType = enumType; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.WRONG_TYPE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.WRONG_TYPE); } return createNode.execute(frame, inliningTarget, resultType, pythonNameFromType(resultType), javaNameFromType(resultType), buffer); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha512ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha512ModuleBuiltins.java index bb60193f76..43721c3b30 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha512ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/Sha512ModuleBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -93,8 +93,8 @@ abstract static class Sha384Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object sha384(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha512.sha384"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha512.sha384"); } } @@ -104,8 +104,8 @@ abstract static class Sha512Node extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static Object sha512(Object args, Object kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha512.sha512"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, "_sha512.sha512"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java index 268a976356..7e18f650da 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/ShakeDigestObjectBuiltins.java @@ -96,9 +96,9 @@ protected ArgumentClinicProvider getArgumentClinic() { static PBytes digest(DigestObject self, int length, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getDigestLength() != length) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFAULT_DIGEST_LENGTHS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFAULT_DIGEST_LENGTHS); } return PFactory.createBytes(language, self.digest()); } @@ -117,9 +117,9 @@ protected ArgumentClinicProvider getArgumentClinic() { static TruffleString hexdigest(DigestObject self, int length, @Bind("this") Node inliningTarget, @Cached BytesNodes.ByteToHexNode toHexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getDigestLength() != length) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFAULT_DIGEST_LENGTHS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFAULT_DIGEST_LENGTHS); } byte[] digest = self.digest(); return toHexNode.execute(inliningTarget, digest, digest.length, (byte) 0, 0); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java index 10d38fa1fc..71f1cc86c9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java @@ -100,8 +100,8 @@ static void bufferedInit(VirtualFrame frame, Node inliningTarget, PBuffered self @SuppressWarnings("unused") @Specialization(guards = "bufferSize <= 0") static void bufferSizeError(PBuffered self, int bufferSize, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, BUF_SIZE_POS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, BUF_SIZE_POS); } private static void init(PBuffered self, int bufferSize, PythonLanguage language) { @@ -165,11 +165,11 @@ protected ArgumentClinicProvider getArgumentClinic() { @SuppressWarnings("unused") @Specialization(guards = "!self.isOK()") static Object initError(PBuffered self, Object o, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (self.isDetached()) { - throw raiseNode.raise(ValueError, IO_STREAM_DETACHED); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_STREAM_DETACHED); } else { - throw raiseNode.raise(ValueError, IO_UNINIT); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } } @@ -179,11 +179,11 @@ abstract static class PythonBinaryWithInitErrorBuiltinNode extends PythonBinaryB @SuppressWarnings("unused") @Specialization(guards = "!self.isOK()") static Object initError(PBuffered self, Object buffer, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (self.isDetached()) { - throw raiseNode.raise(ValueError, IO_STREAM_DETACHED); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_STREAM_DETACHED); } else { - throw raiseNode.raise(ValueError, IO_UNINIT); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } } @@ -192,11 +192,11 @@ abstract static class PythonUnaryWithInitErrorBuiltinNode extends PythonUnaryBui @SuppressWarnings("unused") @Specialization(guards = "!self.isOK()") static Object initError(PBuffered self, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (self.isDetached()) { - throw raiseNode.raise(ValueError, IO_STREAM_DETACHED); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_STREAM_DETACHED); } else { - throw raiseNode.raise(ValueError, IO_UNINIT); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOBaseBuiltins.java index d2c08166f0..150cdc080d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOBaseBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -100,8 +100,8 @@ abstract static class DetachNode extends PythonBuiltinNode { */ @Specialization static Object detach(@SuppressWarnings("unused") Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_DETACH); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_DETACH); } } @@ -115,8 +115,8 @@ abstract static class ReadNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object read(Object self, Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_READ); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_READ); } } @@ -130,8 +130,8 @@ abstract static class Read1Node extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object read1(Object self, Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_READ1); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_READ1); } } @@ -153,18 +153,18 @@ Object readinto(VirtualFrame frame, Object self, Object buffer, @Cached PyObjectCallMethodObjArgs callMethod, @Cached InlinedConditionProfile isBytes, @Cached InlinedConditionProfile oversize, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int len = bufferLib.getBufferLength(buffer); Object data = callMethod.execute(frame, inliningTarget, self, getMethodName(), len); if (isBytes.profile(inliningTarget, !(data instanceof PBytes))) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_SHOULD_RETURN_BYTES, "read()"); + throw raiseNode.raise(inliningTarget, ValueError, S_SHOULD_RETURN_BYTES, "read()"); } // Directly using data as buffer because CPython also accesses the underlying memory // of the bytes object int dataLen = bufferLib.getBufferLength(data); if (oversize.profile(inliningTarget, dataLen > len)) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_RETURNED_TOO_MUCH_DATA, "read()", len, dataLen); + throw raiseNode.raise(inliningTarget, ValueError, S_RETURNED_TOO_MUCH_DATA, "read()", len, dataLen); } bufferLib.readIntoBuffer(data, 0, buffer, 0, dataLen, bufferLib); return dataLen; @@ -219,8 +219,8 @@ abstract static class WriteNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization static Object write(Object self, Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_WRITE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_WRITE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java index 16089c404f..2d56ea743f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -110,7 +110,6 @@ import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.ImportStatic; @@ -283,17 +282,17 @@ static long doit(VirtualFrame frame, PBuffered self, Object off, int whence, @Specialization(guards = {"self.isOK()", "!isSupportedWhence(whence)"}) static Object whenceError(@SuppressWarnings("unused") PBuffered self, @SuppressWarnings("unused") int off, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, UNSUPPORTED_WHENCE, whence); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, UNSUPPORTED_WHENCE, whence); } @Specialization(guards = "!self.isOK()") static Object initError(PBuffered self, @SuppressWarnings("unused") int off, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (self.isDetached()) { - throw raiseNode.raise(ValueError, IO_STREAM_DETACHED); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_STREAM_DETACHED); } else { - throw raiseNode.raise(ValueError, IO_UNINIT); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } } @@ -345,8 +344,8 @@ static Object doit(VirtualFrame frame, PBuffered self, Object pos, @Specialization(guards = {"self.isOK()", "!self.isWritable()"}) static Object notWritable(@SuppressWarnings("unused") PBuffered self, @SuppressWarnings("unused") Object pos, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_TRUNCATE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_TRUNCATE); } } @@ -413,7 +412,7 @@ static TruffleString repr(VirtualFrame frame, PBuffered self, @Cached IsBuiltinObjectProfile isValueError, @Cached PyObjectReprAsTruffleStringNode repr, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString typeName = getNameNode.execute(inliningTarget, getClassNode.execute(inliningTarget, self)); Object nameobj = PNone.NO_VALUE; try { @@ -426,7 +425,7 @@ static TruffleString repr(VirtualFrame frame, PBuffered self, return simpleTruffleStringFormatNode.format("<%s>", typeName); } else { if (!PythonContext.get(inliningTarget).reprEnter(self)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, REENTRANT_CALL_INSIDE_S_REPR, typeName); + throw raiseNode.raise(inliningTarget, RuntimeError, REENTRANT_CALL_INSIDE_S_REPR, typeName); } else { try { TruffleString name = repr.execute(frame, inliningTarget, nameobj); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java index 1604b1a4dd..7dbf414744 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java @@ -109,10 +109,10 @@ public CheckIsClosedNode(TruffleString method) { @Specialization boolean isClosedBuffered(VirtualFrame frame, PBuffered self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached IsClosedNode isClosedNode) { if (isClosedNode.execute(frame, inliningTarget, self)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, messageFmt, method); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, messageFmt, method); } return false; } @@ -155,11 +155,11 @@ static boolean isSeekable(VirtualFrame frame, PBuffered self, @Bind("this") Node inliningTarget, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectIsTrueNode isTrue, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { assert self.isOK(); Object res = callMethod.execute(frame, inliningTarget, self.getRaw(), T_SEEKABLE); if (!isTrue.execute(frame, res)) { - throw raiseNode.get(inliningTarget).raise(IOUnsupportedOperation, FILE_OR_STREAM_IS_NOT_SEEKABLE); + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, FILE_OR_STREAM_IS_NOT_SEEKABLE); } return true; } @@ -181,7 +181,7 @@ static long doInt(long number, @SuppressWarnings("unused") PythonBuiltinClassTyp @Specialization static long toLong(VirtualFrame frame, Node inliningTarget, Object number, PythonBuiltinClassType err, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyNumberIndexNode indexNode, @Cached CastToJavaLongExactNode cast, @Cached IsBuiltinObjectProfile errorProfile) { @@ -190,7 +190,7 @@ static long toLong(VirtualFrame frame, Node inliningTarget, Object number, Pytho return cast.execute(inliningTarget, index); } catch (PException e) { e.expect(inliningTarget, OverflowError, errorProfile); - throw raiseNode.get(inliningTarget).raise(err, CANNOT_FIT_P_IN_OFFSET_SIZE, number); + throw raiseNode.raise(inliningTarget, err, CANNOT_FIT_P_IN_OFFSET_SIZE, number); } catch (CannotCastException e) { throw CompilerDirectives.shouldNotReachHere(); } @@ -218,12 +218,12 @@ public final long executeCached(VirtualFrame frame, PBuffered self) { */ @Specialization static long bufferedRawTell(VirtualFrame frame, Node inliningTarget, PBuffered self, - @Cached PRaiseNode.Lazy lazyRaiseNode, + @Cached PRaiseNode lazyRaiseNode, @Cached PyObjectCallMethodObjArgs callMethod, @Cached AsOffNumberNode asOffNumberNode) { long n = tell(frame, inliningTarget, self.getRaw(), callMethod, asOffNumberNode); if (n < 0) { - throw lazyRaiseNode.get(inliningTarget).raise(OSError, IO_STREAM_INVALID_POS, n); + throw lazyRaiseNode.raise(inliningTarget, OSError, IO_STREAM_INVALID_POS, n); } self.setAbsPos(n); return n; @@ -278,13 +278,13 @@ abstract static class RawSeekNode extends PNodeWithContext { @Specialization static long bufferedRawSeek(VirtualFrame frame, PBuffered self, long target, int whence, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached PyObjectCallMethodObjArgs callMethod, @Cached AsOffNumberNode asOffNumberNode) { Object res = callMethod.execute(frame, inliningTarget, self.getRaw(), T_SEEK, target, whence); long n = asOffNumberNode.execute(frame, inliningTarget, res, ValueError); if (n < 0) { - raise.get(inliningTarget).raise(OSError, IO_STREAM_INVALID_POS, n); + raise.raise(inliningTarget, OSError, IO_STREAM_INVALID_POS, n); } self.setAbsPos(n); return n; @@ -456,7 +456,7 @@ static void normal(Node inliningTarget, PBuffered self, @Specialization(guards = {"!self.isOwn()", "getContext().isFinalizing()"}) static void finalizing(Node inliningTarget, PBuffered self, - @Shared @Cached PRaiseNode.Lazy lazyRaise) { + @Shared @Cached PRaiseNode lazyRaise) { /* * When finalizing, we don't want a deadlock to happen with daemon threads abruptly shut * down while they owned the lock. Therefore, only wait for a grace period (1 s.). Note @@ -464,14 +464,14 @@ static void finalizing(Node inliningTarget, PBuffered self, * written threaded I/O code. */ if (!self.getLock().acquireTimeout(inliningTarget, (long) 1e3)) { - throw lazyRaise.get(inliningTarget).raise(SystemError, SHUTDOWN_POSSIBLY_DUE_TO_DAEMON_THREADS); + throw lazyRaise.raise(inliningTarget, SystemError, SHUTDOWN_POSSIBLY_DUE_TO_DAEMON_THREADS); } } @Specialization(guards = "self.isOwn()") static void error(Node inliningTarget, PBuffered self, - @Shared @Cached PRaiseNode.Lazy lazyRaise) { - throw lazyRaise.get(inliningTarget).raise(RuntimeError, REENTRANT_CALL_INSIDE_P, self); + @Shared @Cached PRaiseNode lazyRaise) { + throw lazyRaise.raise(inliningTarget, RuntimeError, REENTRANT_CALL_INSIDE_P, self); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java index 4a6189b539..145befb24e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedRWPairBuiltins.java @@ -147,8 +147,8 @@ protected static boolean isInit(PRWPair self) { @SuppressWarnings("unused") @Specialization(guards = "!isInit(self)") static Object error(VirtualFrame frame, PRWPair self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -161,8 +161,8 @@ protected static boolean isInit(PRWPair self) { @SuppressWarnings("unused") @Specialization(guards = "!isInit(self)") static Object error(VirtualFrame frame, PRWPair self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -175,8 +175,8 @@ protected static boolean isInit(PRWPair self) { @SuppressWarnings("unused") @Specialization(guards = "!isInit(self)") static Object error(VirtualFrame frame, PRWPair self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -189,8 +189,8 @@ protected static boolean isInit(PRWPair self) { @SuppressWarnings("unused") @Specialization(guards = "!isInit(self)") static Object error(VirtualFrame frame, PRWPair self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -305,7 +305,7 @@ static Object close(VirtualFrame frame, PRWPair self, @Cached InlinedConditionProfile gotException, @Cached InlinedBranchProfile hasException, @Cached PyErrChainExceptions chainExceptions, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PException writeEx = null; if (self.getWriter() != null) { try { @@ -315,7 +315,7 @@ static Object close(VirtualFrame frame, PRWPair self, writeEx = e; } } else { - writeEx = raiseNode.get(inliningTarget).raise(ValueError, IO_UNINIT); + writeEx = raiseNode.raise(inliningTarget, ValueError, IO_UNINIT); } PException readEx; @@ -330,7 +330,7 @@ static Object close(VirtualFrame frame, PRWPair self, readEx = e; } } else { - readEx = raiseNode.get(inliningTarget).raise(ValueError, IO_UNINIT); + readEx = raiseNode.raise(inliningTarget, ValueError, IO_UNINIT); } hasException.enter(inliningTarget); @@ -379,8 +379,8 @@ static Object doit(VirtualFrame frame, PRWPair self, @SuppressWarnings("unused") @Fallback static Object error(VirtualFrame frame, Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(RuntimeError, THE_S_OBJECT_IS_BEING_GARBAGE_COLLECTED, "BufferedRWPair"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, RuntimeError, THE_S_OBJECT_IS_BEING_GARBAGE_COLLECTED, "BufferedRWPair"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java index 6e9a6459af..c619347623 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java @@ -75,6 +75,7 @@ import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode; import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.EnterBufferedNode; import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.FlushAndRewindUnlockedNode; @@ -141,7 +142,7 @@ static byte[] bufferedreaderRawRead(VirtualFrame frame, Node inliningTarget, PBu @Cached PyObjectCallMethodObjArgs callMethodReadInto, @Cached PyNumberAsSizeNode asSizeNode, @Cached InlinedConditionProfile osError, - @Cached PRaiseNode.Lazy lazyRaiseNode) { + @Cached PRaiseNode lazyRaiseNode) { PByteArray memobj = PFactory.createByteArray(language, new byte[len]); // TODO _PyIO_trap_eintr [GR-23297] Object res = callMethodReadInto.execute(frame, inliningTarget, self.getRaw(), T_READINTO, memobj); @@ -153,10 +154,10 @@ static byte[] bufferedreaderRawRead(VirtualFrame frame, Node inliningTarget, PBu try { n = asSizeNode.executeExact(frame, inliningTarget, res, ValueError); } catch (PException e) { - throw lazyRaiseNode.get(inliningTarget).raiseWithCause(OSError, e, ErrorMessages.RAW_READINTO_FAILED); + throw lazyRaiseNode.raiseWithCause(inliningTarget, OSError, e, ErrorMessages.RAW_READINTO_FAILED); } if (osError.profile(inliningTarget, n < 0 || n > len)) { - throw lazyRaiseNode.get(inliningTarget).raise(OSError, IO_S_INVALID_LENGTH, "readinto()", n, len); + throw lazyRaiseNode.raise(inliningTarget, OSError, IO_S_INVALID_LENGTH, "readinto()", n, len); } if (n > 0 && self.getAbsPos() != -1) { self.incAbsPos(n); @@ -394,7 +395,7 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin @Cached GetClassNode getClassNode, @Cached PyObjectCallMethodObjArgs callMethod, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkIsClosedNode.execute(frame, self); try { lock.enter(inliningTarget, self); @@ -418,7 +419,7 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin if (hasReadallProfile.profile(inliningTarget, readall != PNone.NO_VALUE)) { Object tmp = dispatchGetattribute.executeObject(frame, readall, self.getRaw()); if (tmp != PNone.NONE && !(tmp instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, IO_S_SHOULD_RETURN_BYTES, "readall()"); + throw raiseNode.raise(inliningTarget, TypeError, IO_S_SHOULD_RETURN_BYTES, "readall()"); } if (currentSize0Profile.profile(inliningTarget, currentSize != 0)) { if (tmp != PNone.NONE) { @@ -446,7 +447,7 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin /* Read until EOF or until read() would block. */ Object r = callMethod.execute(frame, inliningTarget, self.getRaw(), T_READ); if (r != PNone.NONE && !(r instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, IO_S_SHOULD_RETURN_BYTES, "read()"); + throw raiseNode.raise(inliningTarget, TypeError, IO_S_SHOULD_RETURN_BYTES, "read()"); } if (r != PNone.NONE) { dataLen = bufferLib.getBufferLength(r); @@ -472,8 +473,8 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin @SuppressWarnings("unused") @Specialization(guards = {"self.isOK()", "!isValidSize(size)"}) static Object initError(VirtualFrame frame, PBuffered self, int size, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MUST_BE_NON_NEG_OR_NEG_1); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_BE_NON_NEG_OR_NEG_1); } } @@ -824,11 +825,11 @@ static PBytes doit(VirtualFrame frame, PBuffered self, @Bind("this") Node inliningTarget, @Cached("create(T_READLINE)") CheckIsClosedNode checkIsClosedNode, @Cached BufferedReadlineNode readlineNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkIsClosedNode.execute(frame, self); byte[] line = readlineNode.execute(frame, inliningTarget, self, -1); if (line.length == 0) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return PFactory.createBytes(PythonLanguage.get(inliningTarget), line); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java index af283f1837..30404126c1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterNodes.java @@ -227,7 +227,7 @@ static int bufferedwriterRawWrite(VirtualFrame frame, Node inliningTarget, PBuff @Bind PythonLanguage language, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy lazyRaiseNode) { + @Cached PRaiseNode lazyRaiseNode) { PBytes memobj = PFactory.createBytes(language, buf, len); Object res = callMethod.execute(frame, inliningTarget, self.getRaw(), T_WRITE, memobj); if (res == PNone.NONE) { @@ -238,7 +238,7 @@ static int bufferedwriterRawWrite(VirtualFrame frame, Node inliningTarget, PBuff } int n = asSizeNode.executeExact(frame, inliningTarget, res, ValueError); if (n < 0 || n > len) { - throw lazyRaiseNode.get(inliningTarget).raise(OSError, IO_S_INVALID_LENGTH, "write()", n, len); + throw lazyRaiseNode.raise(inliningTarget, OSError, IO_S_INVALID_LENGTH, "write()", n, len); } if (n > 0 && self.getAbsPos() != -1) { self.incAbsPos(n); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java index f5d34eac5f..fab9fb561e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java @@ -142,8 +142,8 @@ abstract static class ClosedCheckPythonUnaryBuiltinNode extends PythonUnaryBuilt @Specialization(guards = "!self.hasBuf()") @SuppressWarnings("unused") static Object closedError(PBytesIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -151,8 +151,8 @@ abstract static class ClosedCheckPythonBinaryBuiltinNode extends PythonBinaryBui @Specialization(guards = "!self.hasBuf()") @SuppressWarnings("unused") static Object closedError(PBytesIO self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -166,8 +166,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "!self.hasBuf()") @SuppressWarnings("unused") static Object closedError(PBytesIO self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -181,7 +181,7 @@ public abstract static class InitNode extends PythonBinaryBuiltinNode { @SuppressWarnings("unused") static PNone init(PBytesIO self, PNone initvalue, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); self.setPos(0); return PNone.NONE; @@ -191,7 +191,7 @@ static PNone init(PBytesIO self, PNone initvalue, static PNone init(VirtualFrame frame, PBytesIO self, Object initvalue, @Bind("this") Node inliningTarget, @Cached WriteNode writeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { /* In case, __init__ is called multiple times. */ self.setStringSize(0); self.setPos(0); @@ -399,10 +399,10 @@ static Object truncate(PBytesIO self, int size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); if (size < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, NEGATIVE_SIZE_VALUE_D, size); + throw raiseNode.raise(inliningTarget, ValueError, NEGATIVE_SIZE_VALUE_D, size); } if (size < self.getStringSize()) { self.unshareAndResize(bufferLib, language, size, true); @@ -416,7 +416,7 @@ static Object truncate(PBytesIO self, @SuppressWarnings("unused") PNone size, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return truncate(self, self.getPos(), inliningTarget, language, bufferLib, raiseNode); } @@ -426,7 +426,7 @@ static Object truncate(VirtualFrame frame, PBytesIO self, Object size, @Bind PythonLanguage language, @Cached PyNumberAsSizeNode asSizeNode, @Shared("lib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return truncate(self, asSizeNode.executeExact(frame, inliningTarget, size), inliningTarget, language, bufferLib, raiseNode); } } @@ -442,7 +442,7 @@ static Object doWrite(VirtualFrame frame, PBytesIO self, Object b, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("b") PythonBufferAcquireLibrary acquireLib, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); Object buffer = acquireLib.acquireReadonly(b, frame, indirectCallData); try { @@ -475,7 +475,7 @@ static Object writeLines(VirtualFrame frame, PBytesIO self, Object lines, @Cached WriteNode writeNode, @Cached IsBuiltinObjectProfile errorProfile, @Cached PyObjectGetIter getIter, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); Object iter = getIter.execute(frame, inliningTarget, lines); while (true) { @@ -560,35 +560,35 @@ static Object seek(PBytesIO self, int pos, int whence) { @Specialization(guards = {"self.hasBuf()", "!isSupportedWhence(whence)"}) static Object whenceError(@SuppressWarnings("unused") PBytesIO self, @SuppressWarnings("unused") int pos, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, INVALID_WHENCE_D_SHOULD_BE_0_1_OR_2, whence); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INVALID_WHENCE_D_SHOULD_BE_0_1_OR_2, whence); } @SuppressWarnings("unused") @Specialization(guards = {"self.hasBuf()", "isLargePos(pos, self.getPos())", "whence == 1"}) static Object largePos1(PBytesIO self, int pos, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(OverflowError, NEW_POSITION_TOO_LARGE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, OverflowError, NEW_POSITION_TOO_LARGE); } @SuppressWarnings("unused") @Specialization(guards = {"self.hasBuf()", "isLargePos(pos, self.getStringSize())", "whence == 2"}) static Object largePos2(PBytesIO self, int pos, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(OverflowError, NEW_POSITION_TOO_LARGE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, OverflowError, NEW_POSITION_TOO_LARGE); } @Specialization(guards = {"self.hasBuf()", "pos < 0", "whence == 0"}) static Object negPos(@SuppressWarnings("unused") PBytesIO self, int pos, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, NEGATIVE_SEEK_VALUE_D, pos); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, NEGATIVE_SEEK_VALUE_D, pos); } @SuppressWarnings("unused") @Specialization(guards = "!self.hasBuf()") static Object closedError(PBytesIO self, int pos, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -650,12 +650,12 @@ static Object doit(VirtualFrame frame, PBytesIO self, PTuple state, @Cached PyNumberAsSizeNode asSizeNode, @Cached GetOrCreateDictNode getDict, @Cached HashingStorageAddAllToOther addAllToOtherNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); SequenceStorage storage = state.getSequenceStorage(); Object[] array = getArray.execute(inliningTarget, storage); if (storage.length() < 3) { - return notTuple(self, state, raiseNode.get(inliningTarget)); + return notTuple(self, state, raiseNode); } /* * Reset the object to its default state. This is only needed to handle the case of @@ -674,18 +674,18 @@ static Object doit(VirtualFrame frame, PBytesIO self, PTuple state, * against erroneous (or malicious) inputs. */ if (!indexCheckNode.execute(inliningTarget, array[1])) { - throw raiseNode.get(inliningTarget).raise(TypeError, SECOND_ITEM_OF_STATE_MUST_BE_AN_INTEGER_NOT_P, array[1]); + throw raiseNode.raise(inliningTarget, TypeError, SECOND_ITEM_OF_STATE_MUST_BE_AN_INTEGER_NOT_P, array[1]); } int pos = asSizeNode.executeExact(frame, inliningTarget, array[1]); if (pos < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, POSITION_VALUE_CANNOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, POSITION_VALUE_CANNOT_BE_NEGATIVE); } self.setPos(pos); /* Set the dictionary of the instance variables. */ if (!PGuards.isNone(array[2])) { if (!PGuards.isDict(array[2])) { - throw raiseNode.get(inliningTarget).raise(TypeError, THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P, array[2]); + throw raiseNode.raise(inliningTarget, TypeError, THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P, array[2]); } /* * Alternatively, we could replace the internal dictionary completely. However, it @@ -699,8 +699,8 @@ static Object doit(VirtualFrame frame, PBytesIO self, PTuple state, @Specialization(guards = "!isPTuple(state)") static Object notTuple(PBytesIO self, Object state, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, P_SETSTATE_ARGUMENT_SHOULD_BE_D_TUPLE_GOT_P, self, 3, state); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, P_SETSTATE_ARGUMENT_SHOULD_BE_D_TUPLE_GOT_P, self, 3, state); } } @@ -761,7 +761,7 @@ abstract static class CloseNode extends PythonUnaryBuiltinNode { @Specialization static Object close(PBytesIO self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkExports(inliningTarget, raiseNode); self.setBuf(null); return PNone.NONE; @@ -777,10 +777,10 @@ static Object doit(PBytesIO self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int n = scanEOL(self, -1, bufferLib); if (n == 0) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return readBytes(self, n, bufferLib, language); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java index 85aa552c4b..2fee23d480 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java @@ -238,11 +238,11 @@ private static int open(VirtualFrame frame, TruffleString name, int flags, int m PosixSupportLibrary posixLib, GilNode gil, InlinedBranchProfile errorProfile, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, PConstructAndRaiseNode.Lazy constructAndRaiseNode) { Object path = posixLib.createPathFromString(ctxt.getPosixSupport(), name); if (path == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, EMBEDDED_NULL_BYTE); + throw raiseNode.raise(inliningTarget, ValueError, EMBEDDED_NULL_BYTE); } while (true) { try { @@ -328,7 +328,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object @Cached InlinedConditionProfile errorProfile, @Cached(inline = false) GilNode gil, @Cached(inline = false) TruffleString.FromLongNode fromLongNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { if (self.getFD() >= 0) { if (self.isCloseFD()) { @@ -358,7 +358,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object } else { self.setCloseFD(true); if (errorProfile.profile(inliningTarget, !closefd)) { - throw raiseNode.get(inliningTarget).raise(ValueError, CANNOT_USE_CLOSEFD); + throw raiseNode.raise(inliningTarget, ValueError, CANNOT_USE_CLOSEFD); } if (opener instanceof PNone) { @@ -366,7 +366,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object } else { Object fdobj = callOpener.execute(frame, opener, nameobj, flags); if (!indexCheckNode.execute(inliningTarget, fdobj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_INT_FROM_OPENER); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_INT_FROM_OPENER); } self.setFD(asSizeNode.executeExact(frame, inliningTarget, fdobj), context); @@ -375,7 +375,7 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object * The opener returned a negative but didn't set an exception. See issue * #27066 */ - throw raiseNode.get(inliningTarget).raise(ValueError, OPENER_RETURNED_D, self.getFD()); + throw raiseNode.raise(inliningTarget, ValueError, OPENER_RETURNED_D, self.getFD()); } } try { @@ -461,15 +461,15 @@ static void doInit(VirtualFrame frame, Node inliningTarget, PFileIO self, Object @Specialization(guards = "isInvalidMode(mode)") static void invalidMode(@SuppressWarnings("unused") PFileIO self, @SuppressWarnings("unused") Object nameobj, IONodes.IOMode mode, @SuppressWarnings("unused") boolean closefd, @SuppressWarnings("unused") Object opener, - @Shared @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, INVALID_MODE_S, mode.mode); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INVALID_MODE_S, mode.mode); } @SuppressWarnings("unused") @Specialization(guards = "isBadMode(mode)") static void badMode(PFileIO self, Object nameobj, IONodes.IOMode mode, boolean closefd, Object opener, - @Shared @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, BAD_MODE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, BAD_MODE); } } @@ -540,14 +540,14 @@ static Object read(VirtualFrame frame, PFileIO self, int size, @Specialization(guards = {"!self.isClosed()", "!self.isReadable()"}) static Object notReadable(@SuppressWarnings("unused") PFileIO self, @SuppressWarnings("unused") int size, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "reading"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "reading"); } @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, @SuppressWarnings("unused") int size, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -565,7 +565,7 @@ static Object readall(VirtualFrame frame, PFileIO self, @Cached InlinedBranchProfile multipleReadsProfile, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int bufsize = SMALLCHUNK; boolean mayBeQuick = false; try { @@ -612,7 +612,7 @@ static Object readall(VirtualFrame frame, PFileIO self, // see CPython's function 'fileio.c: new_buffersize' bufsize = bytesRead + Math.max(SMALLCHUNK, bytesRead + 256); if (bufsize <= 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, UNBOUNDED_READ_RETURNED_MORE_BYTES); + throw raiseNode.raise(inliningTarget, OverflowError, UNBOUNDED_READ_RETURNED_MORE_BYTES); } } @@ -646,8 +646,8 @@ static Object readall(VirtualFrame frame, PFileIO self, @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -690,15 +690,15 @@ static Object readinto(VirtualFrame frame, PFileIO self, Object buffer, @SuppressWarnings("unused") @Specialization(guards = {"!self.isClosed()", "!self.isReadable()"}) static Object notReadable(PFileIO self, Object buffer, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "reading"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "reading"); } @SuppressWarnings("unused") @Specialization(guards = "self.isClosed()") static Object closedError(PFileIO self, Object buffer, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } @Override @@ -721,13 +721,13 @@ static Object write(VirtualFrame frame, PFileIO self, Object buffer, @Cached InlinedBranchProfile errorProfile, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (self.isClosed()) { - throw raiseNode.get(inliningTarget).raise(ValueError, IO_CLOSED); + throw raiseNode.raise(inliningTarget, ValueError, IO_CLOSED); } if (!self.isWritable()) { - throw raiseNode.get(inliningTarget).raise(IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "writing"); + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "writing"); } try { return PosixModuleBuiltins.WriteNode.write(self.getFD(), bufferLib.getInternalOrCopiedByteArray(buffer), bufferLib.getBufferLength(buffer), @@ -779,8 +779,8 @@ Object seek(VirtualFrame frame, PFileIO self, long pos, int whence, @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, @SuppressWarnings("unused") Object pos, @SuppressWarnings("unused") int whence, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } protected static long internalSeek(PFileIO self, long pos, int whence, @@ -851,15 +851,15 @@ static Object none(VirtualFrame frame, PFileIO self, @SuppressWarnings("unused") @SuppressWarnings("unused") @Specialization(guards = {"!self.isClosed()", "!self.isWritable()"}) static Object notWritable(PFileIO self, Object posobj, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "writing"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, FILE_NOT_OPEN_FOR_S, "writing"); } @SuppressWarnings("unused") @Specialization(guards = "self.isClosed()") static Object closedError(PFileIO self, Object posobj, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -959,8 +959,8 @@ static Object known(PFileIO self) { @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -974,8 +974,8 @@ static Object readable(PFileIO self) { @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -989,8 +989,8 @@ static Object writable(PFileIO self) { @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -1004,8 +1004,8 @@ static Object fileno(PFileIO self) { @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -1026,8 +1026,8 @@ boolean isatty(@SuppressWarnings("unused") PFileIO self, @Specialization(guards = "self.isClosed()") static boolean closedError(@SuppressWarnings("unused") PFileIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -1141,7 +1141,7 @@ static TruffleString doit(VirtualFrame frame, PFileIO self, @Cached("create(Repr)") LookupAndCallUnaryNode repr, @Cached CastToTruffleStringNode castToTruffleStringNode, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString mode = ModeNode.modeString(self); TruffleString closefd = self.isCloseFD() ? T_TRUE : T_FALSE; Object nameobj = lookupName.execute(frame, inliningTarget, self, T_NAME); @@ -1149,7 +1149,7 @@ static TruffleString doit(VirtualFrame frame, PFileIO self, return simpleTruffleStringFormatNode.format("<_io.FileIO fd=%d mode='%s' closefd=%s>", self.getFD(), mode, closefd); } if (!PythonContext.get(inliningTarget).reprEnter(self)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, REENTRANT_CALL_INSIDE_P_REPR, self); + throw raiseNode.raise(inliningTarget, RuntimeError, REENTRANT_CALL_INSIDE_P_REPR, self); } try { TruffleString name = castToTruffleStringNode.execute(inliningTarget, repr.executeObject(frame, nameobj)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java index 6535c80d7d..c9059dccef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java @@ -201,9 +201,9 @@ abstract static class CheckClosedHelperNode extends Node { static PNone doIt(VirtualFrame frame, Node inliningTarget, PythonObject self, @Cached PyObjectGetAttr getAttr, @Cached PyObjectIsTrueNode isTrueNode, - @Cached PRaiseNode.Lazy lazyRaiseNode) { + @Cached PRaiseNode raiseNode) { if (isTrueNode.execute(frame, getAttr.execute(frame, inliningTarget, self, T_CLOSED))) { - throw lazyRaiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IO_CLOSED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IO_CLOSED); } return PNone.NONE; } @@ -242,14 +242,14 @@ final boolean checkReadable(VirtualFrame frame, Node inliningTarget, Object self static boolean doIt(VirtualFrame frame, Node inliningTarget, Object self, TruffleString method, TruffleString errorMessage, @Cached PyObjectCallMethodObjArgs callMethod, @Cached(inline = false) IsNode isNode, - @Cached PRaiseNode.Lazy lazyRaiseNode) { + @Cached PRaiseNode raiseNode) { CompilerAsserts.partialEvaluationConstant(method); CompilerAsserts.partialEvaluationConstant(errorMessage); Object v = callMethod.execute(frame, inliningTarget, self, method); if (isNode.isTrue(v)) { return true; } - throw unsupported(lazyRaiseNode.get(inliningTarget), errorMessage); + throw unsupported(inliningTarget, raiseNode, errorMessage); } } @@ -324,9 +324,9 @@ abstract static class FlushNode extends PythonUnaryBuiltinNode { static PNone flush(VirtualFrame frame, PythonObject self, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookup, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isClosed(inliningTarget, self, frame, lookup)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IO_CLOSED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IO_CLOSED); } return PNone.NONE; } @@ -337,8 +337,9 @@ static PNone flush(VirtualFrame frame, PythonObject self, abstract static class SeekNode extends PythonBuiltinNode { @Specialization static Object seek(@SuppressWarnings("unused") PythonObject self, @SuppressWarnings("unused") Object args, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { - throw unsupported(raiseNode, T_SEEK); + throw unsupported(inliningTarget, raiseNode, T_SEEK); } } @@ -347,8 +348,9 @@ static Object seek(@SuppressWarnings("unused") PythonObject self, @SuppressWarni abstract static class TruncateNode extends PythonBuiltinNode { @Specialization static Object truncate(@SuppressWarnings("unused") PythonObject self, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { - throw unsupported(raiseNode, T_TRUNCATE); + throw unsupported(inliningTarget, raiseNode, T_TRUNCATE); } } @@ -391,8 +393,9 @@ static Object exit(VirtualFrame frame, PythonObject self, abstract static class FilenoNode extends PythonUnaryBuiltinNode { @Specialization static Object fileno(@SuppressWarnings("unused") PythonObject self, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { - throw unsupported(raiseNode, T_FILENO); + throw unsupported(inliningTarget, raiseNode, T_FILENO); } } @@ -428,10 +431,10 @@ static Object next(VirtualFrame frame, PythonObject self, @Bind("this") Node inliningTarget, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectSizeNode sizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object line = callMethod.execute(frame, inliningTarget, self, T_READLINE); if (sizeNode.execute(frame, inliningTarget, line) <= 0) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return line; } @@ -488,7 +491,7 @@ static PBytes readline(VirtualFrame frame, Object self, int limit, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached InlinedConditionProfile hasPeek, @Cached InlinedConditionProfile isBytes, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* For backwards compatibility, a (slowish) readline(). */ Object peek = lookupPeek.execute(frame, inliningTarget, self, T_PEEK); ByteArrayOutputStream buffer = createOutputStream(); @@ -498,7 +501,7 @@ static PBytes readline(VirtualFrame frame, Object self, int limit, Object readahead = callPeek.execute(frame, peek, 1); // TODO _PyIO_trap_eintr [GR-23297] if (isBytes.profile(inliningTarget, !(readahead instanceof PBytes))) { - throw raiseNode.get(inliningTarget).raise(OSError, S_SHOULD_RETURN_BYTES_NOT_P, "peek()", readahead); + throw raiseNode.raise(inliningTarget, OSError, S_SHOULD_RETURN_BYTES_NOT_P, "peek()", readahead); } byte[] buf = bufferLib.getInternalOrCopiedByteArray(readahead); int bufLen = bufferLib.getBufferLength(readahead); @@ -515,7 +518,7 @@ static PBytes readline(VirtualFrame frame, Object self, int limit, Object b = callRead.execute(frame, inliningTarget, self, T_READ, nreadahead); if (isBytes.profile(inliningTarget, !(b instanceof PBytes))) { - throw raiseNode.get(inliningTarget).raise(OSError, S_SHOULD_RETURN_BYTES_NOT_P, "read()", b); + throw raiseNode.raise(inliningTarget, OSError, S_SHOULD_RETURN_BYTES_NOT_P, "read()", b); } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(b); int bytesLen = bufferLib.getBufferLength(b); @@ -586,7 +589,7 @@ private static boolean isClosed(Node inliningTarget, PythonObject self, VirtualF /** * Equivalent of {@code iobase_unsupported}. */ - private static PException unsupported(PRaiseNode raiseNode, TruffleString message) { - throw raiseNode.raise(IOUnsupportedOperation, message); + private static PException unsupported(Node inliningTarget, PRaiseNode raiseNode, TruffleString message) { + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, message); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseDictBuiltins.java index c219e42c9c..e4d5253fec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseDictBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -94,8 +94,8 @@ static Object doit(PythonObject self, @SuppressWarnings("unused") PNone none, @Specialization static Object setDict(PythonObject self, @SuppressWarnings("unused") Object d, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.AssertionError, ErrorMessages.ATTR_DICT_IS_NOT_WRITABLE, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AssertionError, ErrorMessages.ATTR_DICT_IS_NOT_WRITABLE, self); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java index 9a7709f4fd..b8fc0ecf8e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOModuleBuiltins.java @@ -110,7 +110,6 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.ImportStatic; @@ -139,7 +138,7 @@ public void initialize(Python3Core core) { addBuiltinConstant("DEFAULT_BUFFER_SIZE", DEFAULT_BUFFER_SIZE); PythonBuiltinClass unsupportedOpExcType = core.lookupType(IOUnsupportedOperation); PythonBuiltinClass osError = core.lookupType(OSError); - unsupportedOpExcType.setBases(osError, new PythonAbstractClass[]{osError, core.lookupType(ValueError)}); + unsupportedOpExcType.setBases(null, osError, new PythonAbstractClass[]{osError, core.lookupType(ValueError)}); addBuiltinConstant(IOUnsupportedOperation.getName(), unsupportedOpExcType); addBuiltinConstant(BlockingIOError.getName(), core.lookupType(BlockingIOError)); @@ -330,7 +329,7 @@ protected static Object openText(VirtualFrame frame, Object file, IONodes.IOMode @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, initFileIO); Object result = fileIO; try { @@ -359,12 +358,12 @@ protected static Object openText(VirtualFrame frame, Object file, IONodes.IOMode buffering = fileIO.getBlksize(); } if (buffering < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_BUFFERING_SIZE); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_BUFFERING_SIZE); } /* if not buffering, returns the raw file object */ if (buffering == 0) { - invalidunbuf(file, mode, bufferingValue, encoding, errors, newline, closefd, opener, raiseNode.get(inliningTarget)); + invalidunbuf(file, mode, bufferingValue, encoding, errors, newline, closefd, opener, raiseNode); } /* wraps into a buffered file */ @@ -411,7 +410,7 @@ protected static Object openBinaryB1(VirtualFrame frame, Object file, IONodes.IO @Exclusive @Cached IONodes.CreateBufferedIONode createBufferedIO, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { warnNode.warnEx(frame, RuntimeWarning, LINE_BUFFERING_ISNT_SUPPORTED, 1); return openBinary(frame, file, mode, bufferingValue, encoding, errors, newline, closefd, opener, inliningTarget, initFileIO, createBufferedIO, posixLib, callClose, raiseNode); } @@ -427,7 +426,7 @@ protected static Object openBinary(VirtualFrame frame, Object file, IONodes.IOMo @Exclusive @Cached IONodes.CreateBufferedIONode createBufferedIO, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Exclusive @Cached PyObjectCallMethodObjArgs callClose, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PFileIO fileIO = createFileIO(frame, inliningTarget, file, mode, closefd, opener, initFileIO); try { /* buffering */ @@ -451,7 +450,7 @@ protected static Object openBinary(VirtualFrame frame, Object file, IONodes.IOMo buffering = fileIO.getBlksize(); } if (buffering < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_BUFFERING_SIZE); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_BUFFERING_SIZE); } /* if not buffering, returns the raw file object */ @@ -472,35 +471,35 @@ protected static Object openBinary(VirtualFrame frame, Object file, IONodes.IOMo @SuppressWarnings("unused") @Specialization(guards = "isUnknown(mode)") protected static Object unknownMode(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, UNKNOWN_MODE_S, mode.mode); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, UNKNOWN_MODE_S, mode.mode); } @SuppressWarnings("unused") @Specialization(guards = "isTB(mode)") protected static Object invalidTB(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CAN_T_HAVE_TEXT_AND_BINARY_MODE_AT_ONCE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CAN_T_HAVE_TEXT_AND_BINARY_MODE_AT_ONCE); } @SuppressWarnings("unused") @Specialization(guards = "!isValidUniveral(mode)") protected static Object invalidUniversal(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MODE_U_CANNOT_BE_COMBINED_WITH_X_W_A_OR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MODE_U_CANNOT_BE_COMBINED_WITH_X_W_A_OR); } @SuppressWarnings("unused") @Specialization(guards = "isXRWA(mode)") protected static Object invalidxrwa(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MUST_HAVE_EXACTLY_ONE_OF_CREATE_READ_WRITE_APPEND_MODE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_HAVE_EXACTLY_ONE_OF_CREATE_READ_WRITE_APPEND_MODE); } @SuppressWarnings("unused") @Specialization(guards = {"isBinary(mode)", "isAnyNotNone(encoding, errors, newline)"}) protected static Object invalidBinary(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { String s; if (encoding != PNone.NONE) { s = "encoding"; @@ -509,14 +508,14 @@ protected static Object invalidBinary(Object file, IONodes.IOMode mode, int buff } else { s = "newline"; } - throw raiseNode.raise(ValueError, BINARY_MODE_DOESN_T_TAKE_AN_S_ARGUMENT, s); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, BINARY_MODE_DOESN_T_TAKE_AN_S_ARGUMENT, s); } @SuppressWarnings("unused") @Specialization(guards = {"!isBinary(mode)", "bufferingValue == 0"}) protected static Object invalidunbuf(Object file, IONodes.IOMode mode, int bufferingValue, Object encoding, Object errors, Object newline, boolean closefd, Object opener, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CAN_T_HAVE_UNBUFFERED_TEXT_IO); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CAN_T_HAVE_UNBUFFERED_TEXT_IO); } public static boolean isAnyNotNone(Object encoding, Object errors, Object newline) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java index 57b90112fd..792011dc9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IONodes.java @@ -69,7 +69,6 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -377,21 +376,21 @@ IOMode generic(VirtualFrame frame, Object modeObj, @Cached InlinedBranchProfile errProfile2, @Cached InlinedBranchProfile errProfile3, @Cached WarningsModuleBuiltins.WarnNode warnNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString mode; try { mode = toString.execute(inliningTarget, modeObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } IOMode m = new IOMode(mode, createCodePointIteratorNode, nextNode); if (m.hasNil) { errProfile1.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, EMBEDDED_NULL_CHARACTER); + throw raiseNode.raise(inliningTarget, ValueError, EMBEDDED_NULL_CHARACTER); } if (m.isInvalid) { errProfile2.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_MODE_S, mode); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_MODE_S, mode); } if (warnUniversal && m.universal) { errProfile3.enter(inliningTarget); @@ -431,11 +430,11 @@ static Object generic(VirtualFrame frame, Object nameobj, @Cached BytesNodes.DecodeUTF8FSPathNode fspath, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, nameobj)) { int fd = asSizeNode.executeExact(frame, inliningTarget, nameobj); if (fd < 0) { - err(fd, raiseNode.get(inliningTarget)); + err(fd, raiseNode); } return fd; } else { @@ -445,14 +444,14 @@ static Object generic(VirtualFrame frame, Object nameobj, @Specialization(guards = "fd < 0") static int err(int fd, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, OPENER_RETURNED_D, fd); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, OPENER_RETURNED_D, fd); } @Specialization(guards = "fd < 0") static int err(long fd, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, OPENER_RETURNED_D, fd); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, OPENER_RETURNED_D, fd); } @ClinicConverterFactory @@ -524,11 +523,11 @@ static TruffleString string(TruffleString s) { @Specialization(guards = "!isString(s)") static TruffleString str(Node inliningTarget, Object s, @Cached CastToTruffleStringNode str, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return str.execute(inliningTarget, s); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_OBJ_TYPE_S_GOT_P, "str", s); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_OBJ_TYPE_S_GOT_P, "str", s); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java index 0010e47da7..72cc54ac5d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IncrementalNewlineDecoderBuiltins.java @@ -298,14 +298,14 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object state = callMethod.execute(frame, inliningTarget, self.getDecoder(), T_GETSTATE); if (!(state instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_STATE_ARGUMENT); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_STATE_ARGUMENT); } Object[] objects = getObjectArrayNode.execute(inliningTarget, state); if (objects.length != 2 || !indexCheckNode.execute(inliningTarget, objects[1])) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_STATE_ARGUMENT); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_STATE_ARGUMENT); } int flag = asSizeNode.executeExact(frame, inliningTarget, objects[1]); flag <<= 1; @@ -326,10 +326,10 @@ static Object noDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, @Exclusive @Cached SequenceNodes.GetObjectArrayNode getObjectArrayNode, @Exclusive @Cached PyIndexCheckNode indexCheckNode, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object[] objects = getObjectArrayNode.execute(inliningTarget, state); if (objects.length != 2 || !indexCheckNode.execute(inliningTarget, objects[1])) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_STATE_ARGUMENT); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_STATE_ARGUMENT); } int flag = asSizeNode.executeExact(frame, inliningTarget, objects[1]); self.setPendingCR((flag & 1) != 0); @@ -344,10 +344,10 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, @Exclusive @Cached PyIndexCheckNode indexCheckNode, @Exclusive @Cached PyNumberAsSizeNode asSizeNode, @Cached PyObjectCallMethodObjArgs callMethod, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object[] objects = getObjectArrayNode.execute(inliningTarget, state); if (objects.length != 2 || !indexCheckNode.execute(inliningTarget, objects[1])) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_STATE_ARGUMENT); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_STATE_ARGUMENT); } int flag = asSizeNode.executeExact(frame, inliningTarget, objects[1]); self.setPendingCR((flag & 1) != 0); @@ -358,8 +358,8 @@ static Object withDecoder(VirtualFrame frame, PNLDecoder self, PTuple state, @Fallback static Object err(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object state, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, STATE_ARGUMENT_MUST_BE_A_TUPLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, STATE_ARGUMENT_MUST_BE_A_TUPLE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java index 9b5a9a650f..225f228bdc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PBytesIO.java @@ -101,9 +101,9 @@ public int getExports() { return exports.getExports().get(); } - public void checkExports(Node inliningTarget, PRaiseNode.Lazy raiseNode) { + public void checkExports(Node inliningTarget, PRaiseNode raiseNode) { if (getExports() != 0) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.EXISTING_EXPORTS_OF_DATA_OBJECT_CANNOT_BE_RE_SIZED); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.EXISTING_EXPORTS_OF_DATA_OBJECT_CANNOT_BE_RE_SIZED); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PTextIO.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PTextIO.java index e0bda2dbdc..200ff15b56 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PTextIO.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/PTextIO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -424,12 +424,12 @@ public static Object build(CookieType cookie) { return IntNodes.PyLongFromByteArray.executeUncached(buffer, true, false); } - public static CookieType parse(long v, Node inliningTarget, InlinedConditionProfile overflow, PRaiseNode.Lazy raise) { + public static CookieType parse(long v, Node inliningTarget, InlinedConditionProfile overflow, PRaiseNode raise) { byte[] buffer = IntBuiltins.ToBytesNode.fromLong(v, COOKIE_BUF_LEN, false, false, inliningTarget, overflow, raise); return parse(buffer); } - public static CookieType parse(PInt v, Node inliningTarget, InlinedConditionProfile overflow, PRaiseNode.Lazy raise) { + public static CookieType parse(PInt v, Node inliningTarget, InlinedConditionProfile overflow, PRaiseNode raise) { byte[] buffer = IntBuiltins.ToBytesNode.fromBigInteger(v, COOKIE_BUF_LEN, false, false, inliningTarget, overflow, raise); return parse(buffer); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java index ee5e07aa9f..36b8db7086 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/RawIOBaseBuiltins.java @@ -158,7 +158,7 @@ static Object readall(VirtualFrame frame, Object self, @Cached InlinedConditionProfile chunksSize0Profile, @Cached InlinedCountingConditionProfile bytesLen0Profile, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ByteArrayOutputStream chunks = createOutputStream(); while (true) { Object data = callMethodRead.execute(frame, inliningTarget, self, T_READ, DEFAULT_BUFFER_SIZE); @@ -170,7 +170,7 @@ static Object readall(VirtualFrame frame, Object self, break; } if (!(data instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_SHOULD_RETURN_BYTES, "read()"); + throw raiseNode.raise(inliningTarget, TypeError, S_SHOULD_RETURN_BYTES, "read()"); } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(data); int bytesLen = bufferLib.getBufferLength(data); @@ -193,8 +193,8 @@ abstract static class ReadIntoNode extends PythonBuiltinNode { */ @Specialization static Object readinto(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -207,8 +207,8 @@ abstract static class WriteNode extends PythonBuiltinNode { */ @Specialization static Object write(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java index 1f0ef51ac2..5cefff275f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java @@ -146,14 +146,14 @@ protected List> getNodeFa abstract static class ClosedCheckPythonUnaryBuiltinNode extends PythonUnaryBuiltinNode { @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PStringIO self, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PStringIO self, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -166,19 +166,19 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") Object arg, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") Object arg, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } static void writeString(VirtualFrame frame, Node inliningTarget, PStringIO self, TruffleString obj, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, IncrementalNewlineDecoderBuiltins.DecodeNode decodeNode, StringReplaceNode replaceNode, TruffleString.CodePointLengthNode codePointLengthNode, @@ -205,7 +205,7 @@ static void writeString(VirtualFrame frame, Node inliningTarget, PStringIO self, * things like comparing an unsigned and a signed integer. */ if (self.getPos() > Integer.MAX_VALUE - decodedLen) { - throw raiseNode.get(inliningTarget).raise(OverflowError, NEW_POSITION_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, NEW_POSITION_TOO_LARGE); } if (self.isAccumulating()) { @@ -272,7 +272,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization static PNone init(VirtualFrame frame, PStringIO self, TruffleString initialValue, Object newlineArg, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy lazyRaiseNode, + @Cached PRaiseNode lazyRaiseNode, @Cached IncrementalNewlineDecoderBuiltins.DecodeNode decodeNode, @Cached IncrementalNewlineDecoderBuiltins.InitNode initNode, @Cached StringReplaceNode replaceNode, @@ -284,7 +284,7 @@ static PNone init(VirtualFrame frame, PStringIO self, TruffleString initialValue @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached IONodes.ToTruffleStringNode toTruffleStringNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString newline; if (newlineArg == PNone.NO_VALUE) { @@ -479,7 +479,7 @@ static Object obj(VirtualFrame frame, PStringIO self, Object arg, @Shared @Cached TruffleString.SubstringNode substringNode, @Shared @Cached TruffleStringBuilder.ToStringNode toStringNode, @Shared @Cached TruffleStringBuilder.AppendStringNode appendStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int size = asSizeNode.executeExact(frame, inliningTarget, indexNode.execute(frame, inliningTarget, arg), OverflowError); if (size >= 0) { if (size < self.getStringSize()) { @@ -487,13 +487,13 @@ static Object obj(VirtualFrame frame, PStringIO self, Object arg, } return size; } - return negSize(self, size, raiseNode.get(inliningTarget)); + return negSize(self, size, raiseNode); } @Specialization(guards = {"self.isOK()", "!self.isClosed()", "size < 0"}) static Object negSize(@SuppressWarnings("unused") PStringIO self, int size, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, NEGATIVE_SIZE_VALUE_D, size); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, NEGATIVE_SIZE_VALUE_D, size); } } @@ -517,7 +517,7 @@ static Object doWrite(VirtualFrame frame, PStringIO self, TruffleString s, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int size = codePointLengthNode.execute(s, TS_ENCODING); if (size > 0) { writeString(frame, inliningTarget, self, s, raiseNode, decodeNode, replaceNode, codePointLengthNode, @@ -576,32 +576,32 @@ static Object seek(PStringIO self, int pos, int whence) { @SuppressWarnings("unused") @Specialization(guards = {"self.isOK()", "!self.isClosed()", "!isSupportedWhence(whence)"}) static Object whenceError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") int pos, int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, INVALID_WHENCE_D_SHOULD_BE_0_1_OR_2, whence); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INVALID_WHENCE_D_SHOULD_BE_0_1_OR_2, whence); } @Specialization(guards = {"self.isOK()", "!self.isClosed()", "isSupportedWhence(whence)", "pos != 0", "whence != 0"}) static Object largePos1(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") int pos, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(OSError, CAN_T_DO_NONZERO_CUR_RELATIVE_SEEKS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, OSError, CAN_T_DO_NONZERO_CUR_RELATIVE_SEEKS); } @Specialization(guards = {"self.isOK()", "!self.isClosed()", "pos < 0", "whence == 0"}) static Object negPos(@SuppressWarnings("unused") PStringIO self, int pos, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, NEGATIVE_SEEK_VALUE_D, pos); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, NEGATIVE_SEEK_VALUE_D, pos); } @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") int pos, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") int pos, @SuppressWarnings("unused") int whence, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -656,11 +656,11 @@ static Object doit(VirtualFrame frame, PStringIO self, PTuple state, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached HashingStorageAddAllToOther addAllToOtherNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = state.getSequenceStorage(); Object[] array = getArray.execute(inliningTarget, storage); if (storage.length() < 4) { - return notTuple(self, state, raiseNode.get(inliningTarget)); + return notTuple(self, state, raiseNode); } initNode.execute(frame, self, array[0], array[1]); /* @@ -685,18 +685,18 @@ static Object doit(VirtualFrame frame, PStringIO self, PTuple state, * erroneous (or malicious) inputs. */ if (!indexCheckNode.execute(inliningTarget, array[2])) { - throw raiseNode.get(inliningTarget).raise(TypeError, THIRD_ITEM_OF_STATE_MUST_BE_AN_INTEGER_GOT_P, array[2]); + throw raiseNode.raise(inliningTarget, TypeError, THIRD_ITEM_OF_STATE_MUST_BE_AN_INTEGER_GOT_P, array[2]); } int pos = asSizeNode.executeExact(frame, inliningTarget, array[2]); if (pos < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, POSITION_VALUE_CANNOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, POSITION_VALUE_CANNOT_BE_NEGATIVE); } self.setPos(pos); /* Set the dictionary of the instance variables. */ if (!PGuards.isNone(array[3])) { if (!PGuards.isDict(array[3])) { - throw raiseNode.get(inliningTarget).raise(TypeError, THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P, array[3]); + throw raiseNode.raise(inliningTarget, TypeError, THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P, array[3]); } /* * Alternatively, we could replace the internal dictionary completely. However, it @@ -711,14 +711,14 @@ static Object doit(VirtualFrame frame, PStringIO self, PTuple state, @Specialization(guards = {"!self.isClosed()", "!isPTuple(state)"}) static Object notTuple(PStringIO self, Object state, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, P_SETSTATE_ARGUMENT_SHOULD_BE_D_TUPLE_GOT_P, self, 4, state); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, P_SETSTATE_ARGUMENT_SHOULD_BE_D_TUPLE_GOT_P, self, 4, state); } @Specialization(guards = "self.isClosed()") static Object closedError(@SuppressWarnings("unused") PStringIO self, @SuppressWarnings("unused") Object arg, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_CLOSED); } } @@ -788,8 +788,8 @@ static boolean closed(PStringIO self) { @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PStringIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -820,11 +820,11 @@ static Object builtin(PStringIO self, @Cached TruffleStringBuilder.ToStringNode toStringNode, @Cached FindLineEndingNode findLineEndingNode, @Cached TruffleString.SubstringNode substringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.realize(); TruffleString line = stringioReadline(inliningTarget, self, -1, findLineEndingNode, substringNode, toStringNode); if (line.isEmpty()) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return line; } @@ -838,15 +838,15 @@ static Object slowpath(VirtualFrame frame, PStringIO self, @SuppressWarnings("unused") @Exclusive @Cached IsBuiltinObjectExactProfile profile, @Cached PyObjectCallMethodObjArgs callMethodReadline, @Cached CastToTruffleStringNode toString, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.realize(); Object res = callMethodReadline.execute(frame, inliningTarget, self, T_READLINE); if (!PGuards.isString(res)) { - throw raiseNode.get(inliningTarget).raise(OSError, S_SHOULD_HAVE_RETURNED_A_STR_OBJECT_NOT_P, T_READLINE, res); + throw raiseNode.raise(inliningTarget, OSError, S_SHOULD_HAVE_RETURNED_A_STR_OBJECT_NOT_P, T_READLINE, res); } TruffleString line = toString.execute(inliningTarget, res); if (line.isEmpty()) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return line; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOBaseBuiltins.java index 8636fbeb8d..0c2e88189a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOBaseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOBaseBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -64,10 +64,11 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; @CoreFunctions(extendClasses = PythonBuiltinClassType.PTextIOBase) public final class TextIOBaseBuiltins extends PythonBuiltins { @@ -82,8 +83,8 @@ protected List> getNodeFa abstract static class DetachNode extends PythonBuiltinNode { @Specialization static Object detach(@SuppressWarnings("unused") Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_DETACH); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_DETACH); } } @@ -92,8 +93,8 @@ static Object detach(@SuppressWarnings("unused") Object self, abstract static class ReadNode extends PythonBuiltinNode { @Specialization static Object read(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_READ); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_READ); } } @@ -102,8 +103,8 @@ static Object read(@SuppressWarnings("unused") Object self, @SuppressWarnings("u abstract static class ReadlineNode extends PythonBuiltinNode { @Specialization static Object read(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_READLINE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_READLINE); } } @@ -112,8 +113,8 @@ static Object read(@SuppressWarnings("unused") Object self, @SuppressWarnings("u abstract static class WriteNode extends PythonBuiltinNode { @Specialization static Object write(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object args, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, T_WRITE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, T_WRITE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java index 2374247068..a8606b2935 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java @@ -133,6 +133,7 @@ import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.modules.io.TextIOWrapperNodes.WriteFlushNode; import com.oracle.graal.python.builtins.objects.PNone; @@ -197,8 +198,8 @@ abstract static class InitCheckPythonUnaryBuiltinNode extends PythonUnaryBuiltin @Specialization(guards = "!self.isOK()") @SuppressWarnings("unused") static Object initError(PTextIO self, - @Exclusive @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Exclusive @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -210,8 +211,8 @@ protected static boolean checkAttached(PTextIO self) { @Specialization(guards = {"self.isOK()", "self.isDetached()"}) @SuppressWarnings("unused") static Object attachError(PTextIO self, - @Exclusive @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, DETACHED_BUFFER); + @Exclusive @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, DETACHED_BUFFER); } } @@ -234,8 +235,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "!self.isOK()") @SuppressWarnings("unused") static Object initError(PTextIO self, Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } } @@ -247,8 +248,8 @@ protected static boolean checkAttached(PTextIO self) { @Specialization(guards = {"self.isOK()", "self.isDetached()"}) @SuppressWarnings("unused") static Object attachError(PTextIO self, Object o, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, DETACHED_BUFFER); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, DETACHED_BUFFER); } } @@ -315,7 +316,7 @@ static Object reconfigure(VirtualFrame frame, PTextIO self, Object encodingObj, Object errorsObj, Object newlineObj, Object lineBufferingObj, Object writeThroughObj, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy lazyRaiseNode, + @Cached PRaiseNode lazyRaiseNode, @Cached IONodes.ToTruffleStringNode toStringNode, @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectIsTrueNode isTrueNode, @@ -355,8 +356,8 @@ static Object reconfigure(VirtualFrame frame, PTextIO self, Object encodingObj, @SuppressWarnings("unused") @Specialization(guards = "!isValid(self, encodingObj, errorsObj, newlineObj)") static Object error(VirtualFrame frame, PTextIO self, Object encodingObj, Object errorsObj, Object newlineObj, Object lineBufferingObj, Object writeThroughObj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, NOT_POSSIBLE_TO_SET_THE_ENCODING_OR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, NOT_POSSIBLE_TO_SET_THE_ENCODING_OR); } } @@ -372,8 +373,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = {"checkAttached(self)", "isOpen(frame, self)", "!self.hasEncoder()"}) static Object write(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") TruffleString data, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, NOT_WRITABLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, NOT_WRITABLE); } @Specialization(guards = {"checkAttached(self)", "isOpen(frame, self)", "self.hasEncoder()"}) @@ -387,7 +388,7 @@ static Object write(VirtualFrame frame, PTextIO self, TruffleString data, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfCodePointNode indexOfCodePointNode, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean haslf = false; boolean needflush = false; TruffleString text = data; @@ -421,7 +422,7 @@ static Object write(VirtualFrame frame, PTextIO self, TruffleString data, Object b = callMethodEncode.execute(frame, inliningTarget, self.getEncoder(), T_ENCODE, text); if (b != text && !(b instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ENCODER_SHOULD_RETURN_A_BYTES_OBJECT_NOT_P, b); + throw raiseNode.raise(inliningTarget, TypeError, ENCODER_SHOULD_RETURN_A_BYTES_OBJECT_NOT_P, b); } byte[] encodedText = bufferLib.getInternalOrCopiedByteArray(b); @@ -520,8 +521,8 @@ static TruffleString read(VirtualFrame frame, PTextIO self, int n, @Specialization(guards = {"checkAttached(self)", "isOpen(frame, self)", "!self.hasDecoder()"}) static Object noDecoder(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") int n, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, NOT_READABLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, NOT_READABLE); } } @@ -679,10 +680,10 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkClosedNode.execute(frame, self); if (!self.isSeekable()) { - throw raiseNode.get(inliningTarget).raise(IOUnsupportedOperation, UNDERLYING_STREAM_IS_NOT_SEEKABLE); + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, UNDERLYING_STREAM_IS_NOT_SEEKABLE); } Object cookieObj = c; @@ -691,7 +692,7 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, case SEEK_CUR: /* seek relative to current position */ if (!eqNode.compare(frame, inliningTarget, cookieObj, 0)) { - throw raiseNode.get(inliningTarget).raise(IOUnsupportedOperation, CAN_T_DO_NONZERO_CUR_RELATIVE_SEEKS); + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, CAN_T_DO_NONZERO_CUR_RELATIVE_SEEKS); } /* @@ -704,7 +705,7 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, case SEEK_END: /* seek relative to end of file */ if (!eqNode.compare(frame, inliningTarget, cookieObj, 0)) { - throw raiseNode.get(inliningTarget).raise(IOUnsupportedOperation, CAN_T_DO_NONZERO_END_RELATIVE_SEEKS); + throw raiseNode.raise(inliningTarget, IOUnsupportedOperation, CAN_T_DO_NONZERO_END_RELATIVE_SEEKS); } callMethodFlush.execute(frame, inliningTarget, self, T_FLUSH); @@ -726,20 +727,20 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, break; default: - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_WHENCE_D_SHOULD_BE_D_D_OR_D, whence, SEEK_SET, SEEK_CUR, SEEK_END); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_WHENCE_D_SHOULD_BE_D_D_OR_D, whence, SEEK_SET, SEEK_CUR, SEEK_END); } Object cookieLong = longNode.execute(frame, inliningTarget, cookieObj); PTextIO.CookieType cookie; if (cookieLong instanceof PInt) { if (((PInt) cookieLong).isNegative()) { - throw raiseNode.get(inliningTarget).raise(ValueError, NEGATIVE_SEEK_POSITION_D, cookieLong); + throw raiseNode.raise(inliningTarget, ValueError, NEGATIVE_SEEK_POSITION_D, cookieLong); } cookie = PTextIO.CookieType.parse((PInt) cookieLong, inliningTarget, overflow, raiseNode); } else { long l = toLong.execute(inliningTarget, cookieLong); if (l < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, NEGATIVE_SEEK_POSITION_D, cookieLong); + throw raiseNode.raise(inliningTarget, ValueError, NEGATIVE_SEEK_POSITION_D, cookieLong); } cookie = PTextIO.CookieType.parse(l, inliningTarget, overflow, raiseNode); } @@ -765,7 +766,7 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, Object inputChunk = callMethodRead.execute(frame, inliningTarget, self.getBuffer(), T_READ, cookie.bytesToFeed); if (!(inputChunk instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, UNDERLYING_READ_SHOULD_HAVE_RETURNED_A_BYTES_OBJECT_NOT_S, inputChunk); + throw raiseNode.raise(inliningTarget, TypeError, UNDERLYING_READ_SHOULD_HAVE_RETURNED_A_BYTES_OBJECT_NOT_S, inputChunk); } self.setSnapshotDecFlags(cookie.decFlags); @@ -777,7 +778,7 @@ static Object seek(VirtualFrame frame, PTextIO self, Object c, int whence, /* Skip chars_to_skip of the decoded characters. */ if (decodedLen < cookie.charsToSkip) { - throw raiseNode.get(inliningTarget).raise(OSError, CAN_T_RESTORE_LOGICAL_FILE_POSITION); + throw raiseNode.raise(inliningTarget, OSError, CAN_T_RESTORE_LOGICAL_FILE_POSITION); } self.incDecodedCharsUsed(cookie.charsToSkip); } else { @@ -798,14 +799,14 @@ protected static boolean checkAttached(PTextIO self) { @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") Object o1, @SuppressWarnings("unused") Object o2, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } @Specialization(guards = {"self.isOK()", "self.isDetached()"}) static Object attachError(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") Object o1, @SuppressWarnings("unused") Object o2, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, DETACHED_BUFFER); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, DETACHED_BUFFER); } } @@ -815,11 +816,11 @@ abstract static class TellNode extends ClosedCheckPythonUnaryBuiltinNode { @Specialization(guards = "!self.isSeekable() || !self.isTelling()") static Object error(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") PTextIO self, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (!self.isSeekable()) { - throw raiseNode.raise(IOUnsupportedOperation, UNDERLYING_STREAM_IS_NOT_SEEKABLE); + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, UNDERLYING_STREAM_IS_NOT_SEEKABLE); } else { - throw raiseNode.raise(OSError, TELLING_POSITION_DISABLED_BY_NEXT_CALL); + throw PRaiseNode.raiseStatic(inliningTarget, OSError, TELLING_POSITION_DISABLED_BY_NEXT_CALL); } } @@ -907,7 +908,7 @@ static Object tell(VirtualFrame frame, PTextIO self, @Exclusive @Cached PyLongAsLongNode asLongNode, @Cached PyObjectSizeNode sizeNode, @CachedLibrary(limit = "2") InteropLibrary isString, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PTextIO.CookieType cookie = getCookie(frame, inliningTarget, self, writeFlushNode, callMethodFlush, callMethodTell, asLongNode); byte[] snapshotNextInput = self.getSnapshotNextInput(); int nextInputLength = self.getSnapshotNextInput().length; @@ -991,7 +992,7 @@ static Object tell(VirtualFrame frame, PTextIO self, if (!isString.isString(decoded)) { fail(frame, inliningTarget, self, savedState, callMethodSetState); - throw raiseNode.get(inliningTarget).raise(TypeError, DECODER_SHOULD_RETURN_A_STRING_RESULT_NOT_P, decoded); + throw raiseNode.raise(inliningTarget, TypeError, DECODER_SHOULD_RETURN_A_STRING_RESULT_NOT_P, decoded); } charsDecoded += sizeNode.execute(frame, inliningTarget, decoded); @@ -999,7 +1000,7 @@ static Object tell(VirtualFrame frame, PTextIO self, if (charsDecoded < decodedCharsUsed) { fail(frame, inliningTarget, self, savedState, callMethodSetState); - throw raiseNode.get(inliningTarget).raise(OSError, CAN_T_RECONSTRUCT_LOGICAL_FILE_POSITION); + throw raiseNode.raise(inliningTarget, OSError, CAN_T_RECONSTRUCT_LOGICAL_FILE_POSITION); } } callMethodSetState.execute(frame, inliningTarget, self.getDecoder(), T_SETSTATE, savedState); @@ -1018,21 +1019,21 @@ static Object[] decoderGetstate(VirtualFrame frame, Node inliningTarget, PTextIO SequenceNodes.GetObjectArrayNode getArray, PyObjectCallMethodObjArgs callMethodGetState, PyObjectCallMethodObjArgs callMethodSetState, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object state = callMethodGetState.execute(frame, inliningTarget, self.getDecoder(), T_GETSTATE); if (!(state instanceof PTuple)) { fail(frame, inliningTarget, self, saved_state, callMethodSetState); - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE); } Object[] array = getArray.execute(inliningTarget, state); if (array.length < 2) { fail(frame, inliningTarget, self, saved_state, callMethodSetState); - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE); } if (!(array[0] instanceof PBytes)) { fail(frame, inliningTarget, self, saved_state, callMethodSetState); - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE_THE_FIRST, array[0]); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE_THE_FIRST, array[0]); } return array; } @@ -1172,10 +1173,10 @@ static Object none(PTextIO self, @SuppressWarnings("unused") PNone none) { static Object chunkSize(VirtualFrame frame, PTextIO self, Object arg, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int size = asSizeNode.executeExact(frame, inliningTarget, arg, ValueError); if (size <= 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, A_STRICTLY_POSITIVE_INTEGER_IS_REQUIRED); + throw raiseNode.raise(inliningTarget, ValueError, A_STRICTLY_POSITIVE_INTEGER_IS_REQUIRED); } self.setChunkSize(size); return 0; @@ -1183,20 +1184,20 @@ static Object chunkSize(VirtualFrame frame, PTextIO self, Object arg, @Specialization(guards = {"self.isOK()", "!self.isDetached()"}) static Object noDelete(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") DescriptorDeleteMarker marker, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, CANNOT_DELETE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, CANNOT_DELETE); } @Specialization(guards = "!self.isOK()") static Object initError(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") Object arg, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, IO_UNINIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, IO_UNINIT); } @Specialization(guards = {"self.isOK()", "self.isDetached()"}) static Object attachError(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") Object arg, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, DETACHED_BUFFER); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, DETACHED_BUFFER); } } @@ -1207,13 +1208,13 @@ abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode { static TruffleString doit(VirtualFrame frame, PTextIO self, @Bind("this") Node inliningTarget, @Cached TextIOWrapperNodes.ReadlineNode readlineNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.setTelling(false); TruffleString line = readlineNode.execute(frame, self, -1); if (line.isEmpty()) { self.clearSnapshot(); self.setTelling(self.isSeekable()); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return line; } @@ -1231,9 +1232,9 @@ static Object doit(VirtualFrame frame, PTextIO self, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, @Cached IONodes.ToTruffleStringNode toString, @Cached IsBuiltinObjectProfile isValueError, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!PythonContext.get(inliningTarget).reprEnter(self)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, REENTRANT_CALL_INSIDE_P_REPR, self); + throw raiseNode.raise(inliningTarget, RuntimeError, REENTRANT_CALL_INSIDE_P_REPR, self); } try { Object nameobj = PNone.NO_VALUE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java index a614ee75ac..252b9fb6ad 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperNodes.java @@ -121,7 +121,7 @@ public abstract class TextIOWrapperNodes { public static final TruffleString T_CODECS_OPEN = tsLiteral("codecs.open()"); - protected static void validateNewline(TruffleString str, Node inliningTarget, PRaiseNode.Lazy raise, TruffleString.CodePointLengthNode codePointLengthNode, + protected static void validateNewline(TruffleString str, Node inliningTarget, PRaiseNode raise, TruffleString.CodePointLengthNode codePointLengthNode, TruffleString.CodePointAtIndexNode codePointAtIndexNode) { int len = codePointLengthNode.execute(str, TS_ENCODING); int c = len == 0 ? '\0' : codePointAtIndexNode.execute(str, 0, TS_ENCODING); @@ -129,7 +129,7 @@ protected static void validateNewline(TruffleString str, Node inliningTarget, PR !(c == '\n' && len == 1) && !(c == '\r' && len == 1) && !(c == '\r' && len == 2 && codePointAtIndexNode.execute(str, 1, TS_ENCODING) == '\n')) { - throw raise.get(inliningTarget).raise(ValueError, ILLEGAL_NEWLINE_VALUE_S, str); + throw raise.raise(inliningTarget, ValueError, ILLEGAL_NEWLINE_VALUE_S, str); } } @@ -169,8 +169,8 @@ static void ideal(@SuppressWarnings("unused") PTextIO self) { @Specialization(guards = {"self.isFileIO()", "self.getFileIO().isClosed()"}) static void error(@SuppressWarnings("unused") PTextIO self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.IO_CLOSED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.IO_CLOSED); } @Specialization(guards = "!self.isFileIO()") @@ -178,10 +178,10 @@ static void checkGeneric(VirtualFrame frame, PTextIO self, @Bind("this") Node inliningTarget, @Cached PyObjectGetAttr getAttr, @Cached PyObjectIsTrueNode isTrueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object res = getAttr.execute(frame, inliningTarget, self.getBuffer(), T_CLOSED); if (isTrueNode.execute(frame, res)) { - error(self, raiseNode.get(inliningTarget)); + error(self, raiseNode); } } } @@ -504,7 +504,7 @@ static boolean readChunk(VirtualFrame frame, Node inliningTarget, PTextIO self, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* * The return value is True unless EOF was reached. The decoded string is placed in * self._decoded_chars (replacing its previous value). The entire input chunk is sent to @@ -524,15 +524,15 @@ static boolean readChunk(VirtualFrame frame, Node inliningTarget, PTextIO self, * with decoder state (b'', decFlags). */ if (!(state instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE); } Object[] array = getArray.execute(inliningTarget, state); if (array.length < 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE); } if (!(array[0] instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ILLEGAL_DECODER_STATE_THE_FIRST, array[0]); + throw raiseNode.raise(inliningTarget, TypeError, ILLEGAL_DECODER_STATE_THE_FIRST, array[0]); } decBuffer = (PBytes) array[0]; @@ -557,7 +557,7 @@ static boolean readChunk(VirtualFrame frame, Node inliningTarget, PTextIO self, try { inputChunkBuf = bufferAcquireLib.acquireReadonly(inputChunk, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, S_SHOULD_HAVE_RETURNED_A_BYTES_LIKE_OBJECT_NOT_P, (self.isHasRead1() ? T_READ1 : T_READ), inputChunk); + throw raiseNode.raise(inliningTarget, TypeError, S_SHOULD_HAVE_RETURNED_A_BYTES_LIKE_OBJECT_NOT_P, (self.isHasRead1() ? T_READ1 : T_READ), inputChunk); } try { int nbytes = bufferLib.getBufferLength(inputChunkBuf); @@ -598,8 +598,8 @@ static boolean readChunk(VirtualFrame frame, Node inliningTarget, PTextIO self, @Specialization(guards = "!self.hasDecoder()") static boolean error(@SuppressWarnings("unused") PTextIO self, @SuppressWarnings("unused") int size_hint, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(IOUnsupportedOperation, NOT_READABLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, IOUnsupportedOperation, NOT_READABLE); } } @@ -816,7 +816,7 @@ static void init(VirtualFrame frame, Node inliningTarget, PTextIO self, Object b @Cached(inline = false) TruffleString.IndexOfCodePointNode indexOfCodePointNode, @Cached(inline = false) TruffleString.EqualNode equalNode, @Cached(inline = false) WarningsModuleBuiltins.WarnNode warnNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.setOK(false); self.setDetached(false); // encoding and newline are processed through arguments clinic and safe to cast. @@ -830,13 +830,13 @@ static void init(VirtualFrame frame, Node inliningTarget, PTextIO self, Object b encoding = null; } else { if (indexOfCodePointNode.execute(encoding, 0, 0, codePointLengthNode.execute(encoding, TS_ENCODING), TS_ENCODING) != -1) { - throw raiseNode.get(inliningTarget).raise(ValueError, EMBEDDED_NULL_CHARACTER); + throw raiseNode.raise(inliningTarget, ValueError, EMBEDDED_NULL_CHARACTER); } } if (newline != null) { if (indexOfCodePointNode.execute(newline, 0, 0, codePointLengthNode.execute(newline, TS_ENCODING), TS_ENCODING) != -1) { - throw raiseNode.get(inliningTarget).raise(ValueError, EMBEDDED_NULL_CHARACTER); + throw raiseNode.raise(inliningTarget, ValueError, EMBEDDED_NULL_CHARACTER); } validateNewline(newline, inliningTarget, raiseNode, codePointLengthNode, codePointAtIndexNode); } @@ -856,7 +856,7 @@ static void init(VirtualFrame frame, Node inliningTarget, PTextIO self, Object b } else if (encoding != null) { self.setEncoding(encoding); } else { - throw raiseNode.get(inliningTarget).raise(OSError, COULD_NOT_DETERMINE_DEFAULT_ENCODING); + throw raiseNode.raise(inliningTarget, OSError, COULD_NOT_DETERMINE_DEFAULT_ENCODING); } /* Check we have been asked for a real text encoding */ diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java index 59cc6e6a1d..333cd0283a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java @@ -134,7 +134,7 @@ private void appendConst(TruffleStringBuilderUTF32 builder, Object obj) { private void appendFloat(PJSONEncoder encoder, TruffleStringBuilderUTF32 builder, double obj) { if (!Double.isFinite(obj)) { if (!encoder.allowNan) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.OUT_OF_RANGE_FLOAT_NOT_JSON_COMPLIANT); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.OUT_OF_RANGE_FLOAT_NOT_JSON_COMPLIANT); } if (obj > 0) { builder.appendStringUncached(T_POSITIVE_INFINITY); @@ -165,7 +165,7 @@ private void appendString(PJSONEncoder encoder, TruffleStringBuilderUTF32 builde case None: Object result = CallUnaryMethodNode.getUncached().executeObject(encoder.encoder, obj); if (!isString(result)) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.ENCODER_MUST_RETURN_STR, result); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.ENCODER_MUST_RETURN_STR, result); } builder.appendStringUncached(CastToTruffleStringNode.executeUncached(result)); break; @@ -230,7 +230,7 @@ private static void endRecursion(PJSONEncoder encoder, Object obj) { private void startRecursion(PJSONEncoder encoder, Object obj) { if (encoder.markers != PNone.NONE) { if (!encoder.tryAddCircular(obj)) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.CIRCULAR_REFERENCE_DETECTED); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.CIRCULAR_REFERENCE_DETECTED); } } } @@ -277,7 +277,7 @@ private void appendDictSlowPath(PJSONEncoder encoder, TruffleStringBuilderUTF32 break; } if (!(item instanceof PTuple itemTuple) || itemTuple.getSequenceStorage().length() != 2) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.ITEMS_MUST_RETURN_2_TUPLES); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.ITEMS_MUST_RETURN_2_TUPLES); } SequenceStorage sequenceStorage = itemTuple.getSequenceStorage(); Object key = SequenceStorageNodes.GetItemScalarNode.executeUncached(sequenceStorage, 0); @@ -297,7 +297,7 @@ private boolean appendDictEntry(PJSONEncoder encoder, TruffleStringBuilderUTF32 if (encoder.skipKeys) { return true; } - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.KEYS_MUST_BE_STR_INT___NOT_P, key); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.KEYS_MUST_BE_STR_INT___NOT_P, key); } builder.appendCodePointUncached('"'); appendSimpleObj(encoder, builder, key); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java index 2de099ac51..f5e5884b28 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONModuleBuiltins.java @@ -126,7 +126,7 @@ static TruffleString call(TruffleString string, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleString.SubstringNode substringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int len = string.byteLength(TS_ENCODING); // 12.5% overallocated, TruffleStringBuilder.ToStringNode will copy anyway @@ -134,7 +134,7 @@ static TruffleString call(TruffleString string, JSONUtils.appendString(string, createCodePointIteratorNode.execute(string, TS_ENCODING), builder, false, nextNode, appendCodePointNode, appendStringNode, substringNode); return toStringNode.execute(builder); } catch (OutOfMemoryError | NegativeArraySizeException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, ErrorMessages.STR_TOO_LONG_TO_ESCAPE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.STR_TOO_LONG_TO_ESCAPE); } } @@ -162,7 +162,7 @@ static TruffleString call(TruffleString string, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleString.SubstringNode substringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int len = string.byteLength(TS_ENCODING); // 12.5% overallocated, TruffleStringBuilder.ToStringNode will copy anyway @@ -171,7 +171,7 @@ static TruffleString call(TruffleString string, nextNode, appendCodePointNode, appendStringNode, substringNode); return toStringNode.execute(builder); } catch (OutOfMemoryError | NegativeArraySizeException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, ErrorMessages.STR_TOO_LONG_TO_ESCAPE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.STR_TOO_LONG_TO_ESCAPE); } } } @@ -226,7 +226,7 @@ protected ArgumentClinicProvider getArgumentClinic() { PJSONEncoder doNew(Object cls, Object markers, Object defaultFn, Object encoder, Object indent, TruffleString keySeparator, TruffleString itemSeparator, boolean sortKeys, boolean skipKeys, boolean allowNan) { if (markers != PNone.NONE && !(markers instanceof PDict)) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.MAKE_ENCODER_ARG_1_MUST_BE_DICT, markers); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.MAKE_ENCODER_ARG_1_MUST_BE_DICT, markers); } FastEncode fastEncode = FastEncode.None; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java index 48838a024b..8861be6638 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONScannerBuiltins.java @@ -349,7 +349,7 @@ private Object scanOnceUnicode(PJSONScanner scanner, String string, int idx, Int * Returns a new PyObject representation of the term. */ if (idx < 0) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ValueError, ErrorMessages.IDX_CANNOT_BE_NEG); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ValueError, ErrorMessages.IDX_CANNOT_BE_NEG); } int length = string.length(); if (idx >= length) { @@ -431,7 +431,7 @@ static TruffleString scanStringUnicode(String string, int start, boolean strict, StringBuilder builder = null; if (start < 0 || start > string.length()) { - throw PRaiseNode.raiseUncached(raisingNode, PythonBuiltinClassType.ValueError, ErrorMessages.END_IS_OUT_OF_BOUNDS); + throw PRaiseNode.raiseStatic(raisingNode, PythonBuiltinClassType.ValueError, ErrorMessages.END_IS_OUT_OF_BOUNDS); } int idx = start; while (idx < string.length()) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java index d5644b074a..875ca50e13 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java @@ -136,22 +136,22 @@ static PNone init(VirtualFrame frame, LZMACompressor self, int format, int check @Specialization(guards = "badIntegrity(format, check)") @SuppressWarnings("unused") static PNone integrityError(LZMACompressor self, long format, long check, Object preset, Object filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, INTEGRITY_CHECKS_ONLY_SUPPORTED_BY); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INTEGRITY_CHECKS_ONLY_SUPPORTED_BY); } @Specialization(guards = {"!badIntegrity(format, check)", "badPresetFilters(preset, filters)"}) @SuppressWarnings("unused") static PNone presetError(LZMACompressor self, long format, long check, Object preset, Object filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, CANNOT_SPECIFY_PREST_AND_FILTER_CHAIN); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CANNOT_SPECIFY_PREST_AND_FILTER_CHAIN); } @Specialization(guards = {"!badIntegrity(format, check)", "!badPresetFilters(preset, filters)", "badRawFilter(format, filters)"}) @SuppressWarnings("unused") static PNone rawError(LZMACompressor self, long format, long check, Object preset, PNone filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, MUST_SPECIFY_FILTERS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_SPECIFY_FILTERS); } protected static boolean badIntegrity(long format, long check) { @@ -189,8 +189,8 @@ static PBytes doBytes(VirtualFrame frame, LZMACompressor self, Object data, @SuppressWarnings("unused") @Specialization(guards = "self.isFlushed()") static PNone error(LZMACompressor self, Object data, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, COMPRESSOR_HAS_BEEN_FLUSHED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, COMPRESSOR_HAS_BEEN_FLUSHED); } @ValueType @@ -236,8 +236,8 @@ static PBytes doit(LZMACompressor self, @SuppressWarnings("unused") @Specialization(guards = "self.isFlushed()") static PNone error(LZMACompressor self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, REPEATED_CALL_TO_FLUSH); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, REPEATED_CALL_TO_FLUSH); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java index 17983e6658..be0e92dd3f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java @@ -117,12 +117,12 @@ static PNone notRaw(VirtualFrame frame, LZMADecompressor self, int format, Objec @Bind("this") Node inliningTarget, @Cached CastToJavaIntExactNode cast, @Shared("d") @Cached LZMANodes.LZMADecompressInit decompressInit, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int memlimit; try { memlimit = cast.execute(inliningTarget, memlimitObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } return doNotRaw(frame, self, format, memlimit, decompressInit); @@ -155,29 +155,29 @@ static PNone raw(VirtualFrame frame, LZMADecompressor self, int format, PNone me @SuppressWarnings("unused") @Specialization(guards = {"isRaw(format)", "!isPNone(memlimit)"}) static PNone rawError(LZMADecompressor self, int format, Object memlimit, Object filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANNOT_SPECIFY_MEM_LIMIT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANNOT_SPECIFY_MEM_LIMIT); } @SuppressWarnings("unused") @Specialization(guards = "isRaw(format)") static PNone rawFilterError(LZMADecompressor self, int format, Object memlimit, PNone filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.MUST_SPECIFY_FILTERS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.MUST_SPECIFY_FILTERS); } @SuppressWarnings("unused") @Specialization(guards = {"!isRaw(format)", "!isPNone(filters)"}) static PNone rawFilterError(LZMADecompressor self, int format, Object memlimit, Object filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANNOT_SPECIFY_FILTERS); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANNOT_SPECIFY_FILTERS); } @SuppressWarnings("unused") @Specialization(guards = "!validFormat(format)") static PNone invalidFormat(LZMADecompressor self, int format, Object memlimit, Object filters, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.INVALID_CONTAINER_FORMAT, format); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.INVALID_CONTAINER_FORMAT, format); } protected static boolean validFormat(int format) { @@ -229,8 +229,8 @@ static PBytes doObject(VirtualFrame frame, LZMADecompressor self, Object data, i @SuppressWarnings("unused") @Specialization(guards = {"self.isEOF()"}) static Object err(LZMADecompressor self, Object data, int maxLength, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(EOFError, ALREADY_AT_END_OF_STREAM); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, EOFError, ALREADY_AT_END_OF_STREAM); } } @@ -270,8 +270,8 @@ int doCheck(LZMADecompressor.Native self) { @Specialization static int doCheck(@SuppressWarnings("unused") LZMADecompressor.Java self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, T_LZMA_JAVA_ERROR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, T_LZMA_JAVA_ERROR); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMANodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMANodes.java index 723990fb85..3519e4e58e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMANodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMANodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -204,12 +204,12 @@ long l(long l) { @Specialization long ll(long l, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (l < 0) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.CANT_CONVERT_NEG_INT_TO_UNSIGNED); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANT_CONVERT_NEG_INT_TO_UNSIGNED); } if (l > MAX_UINT32 && with32BitLimit) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.VALUE_TOO_LARGE_FOR_UINT32); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.VALUE_TOO_LARGE_FOR_UINT32); } return l; } @@ -219,11 +219,11 @@ long ll(long l, long o(Object o, @Bind("this") Node inliningTarget, @Cached CastToJavaLongExactNode cast, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { return ll(cast.execute(inliningTarget, o), inliningTarget, raiseNode); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, INTEGER_REQUIRED); } } @@ -247,10 +247,10 @@ public abstract static class GetOptionsDict extends Node { static HashingStorage fast(VirtualFrame frame, PDict dict, @Bind("this") Node inliningTarget, @Shared("getItem") @Cached HashingStorageGetItem getItem, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { HashingStorage storage = dict.getDictStorage(); if (!getItem.hasKey(frame, inliningTarget, storage, T_ID)) { - throw raiseNode.get(inliningTarget).raise(ValueError, FILTER_SPECIFIER_MUST_HAVE); + throw raiseNode.raise(inliningTarget, ValueError, FILTER_SPECIFIER_MUST_HAVE); } return storage; } @@ -260,10 +260,10 @@ static HashingStorage slow(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, @Shared("getItem") @Cached HashingStorageGetItem getItem, @Cached GetDictIfExistsNode getDict, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PDict dict = getDict.execute(object); if (dict == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, FILTER_SPEC_MUST_BE_DICT); + throw raiseNode.raise(inliningTarget, TypeError, FILTER_SPEC_MUST_BE_DICT); } return fast(frame, dict, inliningTarget, getItem, raiseNode); } @@ -292,23 +292,23 @@ static OptionsState doit(Frame frame, Node inliningTarget, HashingStorage storag @Cached CastToJavaLongLossyNode toLong, @Cached InlinedConditionProfile errProfile, @Cached HashingStorageGetItem getItem, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached(inline = false) TruffleString.EqualNode equalNode) { Object key = itKey.execute(inliningTarget, storage, it); TruffleString skey = strNode.execute(frame, inliningTarget, key); int idx = getOptionIndex(skey, s, equalNode); if (errProfile.profile(inliningTarget, idx == -1)) { - throw raise.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_FILTER_SPECIFIED_FOR_FILTER, s.filterType); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.INVALID_FILTER_SPECIFIED_FOR_FILTER, s.filterType); } long l = toLong.execute(inliningTarget, getItem.execute(inliningTarget, s.dictStorage, skey)); if (errProfile.profile(inliningTarget, l < 0)) { - throw raise.get(inliningTarget).raise(OverflowError, ErrorMessages.CANT_CONVERT_NEG_INT_TO_UNSIGNED); + throw raise.raise(inliningTarget, OverflowError, ErrorMessages.CANT_CONVERT_NEG_INT_TO_UNSIGNED); } if (errProfile.profile(inliningTarget, l > MAX_UINT32 && idx > 0) /* * filters are special * case */) { - throw raise.get(inliningTarget).raise(OverflowError, ErrorMessages.VALUE_TOO_LARGE_FOR_UINT32); + throw raise.raise(inliningTarget, OverflowError, ErrorMessages.VALUE_TOO_LARGE_FOR_UINT32); } s.options[idx] = l; return s; @@ -421,7 +421,7 @@ static long[] converter(VirtualFrame frame, Object spec, @Cached GetOptionsDict getOptionsDict, @Cached HashingStorageGetItem getItem, @Cached HashingStorageForEach forEachNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { HashingStorage dict = getOptionsDict.execute(frame, spec); Object idObj = getItem.execute(inliningTarget, dict, T_ID); long id = toLong.execute(inliningTarget, idObj); @@ -451,7 +451,7 @@ static long[] converter(VirtualFrame frame, Object spec, state = new OptionsState("BCJ", BCJOption.values(), options, dict); break; default: - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_FILTER, id); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_FILTER, id); } options[0] = id; forEachNode.execute(frame, inliningTarget, dict, getOptions, state); @@ -472,11 +472,11 @@ long[][] parseFilter(VirtualFrame frame, Object filterSpecs, @Cached LZMAFilterConverter converter, @Cached SequenceNodes.CheckIsSequenceNode checkIsSequenceNode, @Cached PyObjectSizeNode sizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkIsSequenceNode.execute(inliningTarget, filterSpecs); int numFilters = sizeNode.execute(frame, inliningTarget, filterSpecs); if (numFilters > LZMA_FILTERS_MAX) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TOO_MAMNY_FILTERS_LZMA_SUPPORTS_MAX_S, LZMA_FILTERS_MAX); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MAMNY_FILTERS_LZMA_SUPPORTS_MAX_S, LZMA_FILTERS_MAX); } long[][] filters = new long[numFilters][0]; for (int i = 0; i < numFilters; i++) { @@ -498,7 +498,7 @@ static void parseFilterChainSpec(VirtualFrame frame, Object lzmast, PythonContex @Cached NativeLibrary.InvokeNativeFunction setFilterSpecDelta, @Cached NativeLibrary.InvokeNativeFunction setFilterSpecBCJ, @Cached LZMAParseFilterChain parseFilterChain, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long[][] filters = parseFilterChain.execute(frame, filterSpecs); for (int i = 0; i < filters.length; i++) { setFilterOptions(inliningTarget, lzmast, filters[i], i, context, setFilterSpecLZMA, setFilterSpecDelta, setFilterSpecBCJ, raiseNode); @@ -509,7 +509,7 @@ private static void setFilterOptions(Node inliningTarget, Object lzmast, long[] NativeLibrary.InvokeNativeFunction setFilterSpecLZMA, NativeLibrary.InvokeNativeFunction setFilterSpecDelta, NativeLibrary.InvokeNativeFunction setFilterSpecBCJ, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = context.getNFILZMASupport(); Object opts = context.getEnv().asGuestValue(filter); int err; @@ -521,7 +521,7 @@ private static void setFilterOptions(Node inliningTarget, Object lzmast, long[] err = lzmaSupport.setFilterSpecLZMA(lzmast, fidx, opts, setFilterSpecLZMA); if (err != LZMA_OK) { if (err == LZMA_PRESET_ERROR) { - throw raiseNode.get(inliningTarget).raise(LZMAError, INVALID_COMPRESSION_PRESET, filter[LZMAOption.preset.ordinal()]); + throw raiseNode.raise(inliningTarget, LZMAError, INVALID_COMPRESSION_PRESET, filter[LZMAOption.preset.ordinal()]); } errorHandling(inliningTarget, err, raiseNode); } @@ -546,7 +546,7 @@ private static void setFilterOptions(Node inliningTarget, Object lzmast, long[] } return; } - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_FILTER, id); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_FILTER, id); } } @@ -559,14 +559,14 @@ protected abstract static class JavaFilterChain extends Node { @Specialization static FilterOptions[] parseFilterChainSpec(VirtualFrame frame, Node inliningTarget, Object filterSpecs, @Cached(inline = false) LZMAParseFilterChain parseFilterChain, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long[][] filters = parseFilterChain.execute(frame, filterSpecs); FilterOptions[] optionsChain = new FilterOptions[filters.length]; for (int i = 0; i < filters.length; i++) { try { optionsChain[i] = getFilterOptions(filters[i], inliningTarget); } catch (UnsupportedOptionsException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.M, e); } } @@ -592,7 +592,7 @@ private static FilterOptions getFilterOptions(long[] longFilter, Node raisingNod try { lzma2Options = new LZMA2Options(filter[1]); } catch (UnsupportedOptionsException e) { - throw PRaiseNode.raiseUncached(raisingNode, LZMAError, INVALID_COMPRESSION_PRESET, filter[LZMAOption.preset.ordinal()]); + throw PRaiseNode.raiseStatic(raisingNode, LZMAError, INVALID_COMPRESSION_PRESET, filter[LZMAOption.preset.ordinal()]); } for (int j = 2; j < filter.length; j++) { setLZMAOption(lzma2Options, j, filter[j]); @@ -643,7 +643,7 @@ private static FilterOptions getFilterOptions(long[] longFilter, Node raisingNod } return sparcOptions; } - throw PRaiseNode.raiseUncached(raisingNode, ValueError, INVALID_FILTER, longFilter[0]); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, INVALID_FILTER, longFilter[0]); } @TruffleBoundary @@ -692,7 +692,7 @@ static void xz(LZMACompressor.Native self, @SuppressWarnings("unused") int forma @Shared("cs") @Cached NativeLibrary.InvokeNativeFunction createStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaEasyEncoder, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = PythonContext.get(inliningTarget).getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); self.init(lzmast, lzmaSupport); @@ -709,7 +709,7 @@ static void xz(VirtualFrame frame, LZMACompressor.Native self, @SuppressWarnings @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaStreamEncoder, @Exclusive @Cached NativeFilterChain filterChain, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PythonContext ctxt = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = ctxt.getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); @@ -728,7 +728,7 @@ static void alone(LZMACompressor.Native self, int format, long preset, PNone fil @Shared("cs") @Cached NativeLibrary.InvokeNativeFunction createStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaAloneEncoderPreset, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = PythonContext.get(inliningTarget).getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); self.init(lzmast, lzmaSupport); @@ -746,7 +746,7 @@ static void alone(VirtualFrame frame, LZMACompressor.Native self, int format, lo @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaAloneEncoder, @Exclusive @Cached NativeFilterChain filterChain, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PythonContext ctxt = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = ctxt.getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); @@ -766,7 +766,7 @@ static void raw(VirtualFrame frame, LZMACompressor.Native self, int format, long @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaRawEncoder, @Exclusive @Cached NativeFilterChain filterChain, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PythonContext ctxt = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = ctxt.getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); @@ -781,11 +781,11 @@ static void raw(VirtualFrame frame, LZMACompressor.Native self, int format, long @Specialization(guards = "format == FORMAT_XZ") static void xz(LZMACompressor.Java self, @SuppressWarnings("unused") int format, long preset, @SuppressWarnings("unused") PNone filters, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { self.lzmaEasyEncoder(parseLZMAOptions(preset)); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.M, e); } } @@ -793,11 +793,11 @@ static void xz(LZMACompressor.Java self, @SuppressWarnings("unused") int format, static void xz(VirtualFrame frame, LZMACompressor.Java self, @SuppressWarnings("unused") int format, @SuppressWarnings("unused") long preset, Object filters, @Bind("this") Node inliningTarget, @Shared @Cached JavaFilterChain filterChain, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { self.lzmaStreamEncoder(filterChain.execute(frame, inliningTarget, filters)); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.M, e); } } @@ -805,11 +805,11 @@ static void xz(VirtualFrame frame, LZMACompressor.Java self, @SuppressWarnings(" @Specialization(guards = "format == FORMAT_ALONE") static void alone(LZMACompressor.Java self, int format, long preset, PNone filters, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { self.lzmaAloneEncoder(parseLZMAOptions(preset)); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.M, e); } } @@ -818,15 +818,15 @@ static void alone(LZMACompressor.Java self, int format, long preset, PNone filte static void alone(VirtualFrame frame, LZMACompressor.Java self, int format, long preset, Object filters, @Bind("this") Node inliningTarget, @Shared @Cached JavaFilterChain filterChain, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { FilterOptions[] optionsChain = filterChain.execute(frame, inliningTarget, filters); if (optionsChain.length != 1 && !(optionsChain[0] instanceof LZMA2Options)) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_FILTER_CHAIN_FOR_FORMAT); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_FILTER_CHAIN_FOR_FORMAT); } try { self.lzmaAloneEncoder((LZMA2Options) optionsChain[0]); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.M, e); } } @@ -835,24 +835,23 @@ static void alone(VirtualFrame frame, LZMACompressor.Java self, int format, long static void raw(VirtualFrame frame, LZMACompressor.Java self, int format, long preset, Object filters, @Bind("this") Node inliningTarget, @Shared @Cached JavaFilterChain filterChain, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { FilterOptions[] optionsChain = filterChain.execute(frame, inliningTarget, filters); if (optionsChain.length != 1 && !(optionsChain[0] instanceof LZMA2Options)) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_FILTER_CHAIN_FOR_FORMAT); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_FILTER_CHAIN_FOR_FORMAT); } try { self.lzmaRawEncoder(optionsChain); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.M, e); } } @Fallback @SuppressWarnings("unused") static void error(VirtualFrame frame, LZMACompressor self, int format, long preset, Object filters, - @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_CONTAINER_FORMAT, format); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INVALID_CONTAINER_FORMAT, format); } } @@ -876,7 +875,7 @@ static byte[] nativeCompress(Node inliningTarget, LZMACompressor.Native self, Py @Cached(inline = false) NativeLibrary.InvokeNativeFunction compress, @Cached GetOutputNativeBufferNode getBuffer, @Cached InlinedConditionProfile errProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = context.getNFILZMASupport(); Object inGuest = context.getEnv().asGuestValue(bytes); int err = lzmaSupport.compress(self.getLzs(), inGuest, len, action, INITIAL_BUFFER_SIZE, compress); @@ -889,26 +888,26 @@ static byte[] nativeCompress(Node inliningTarget, LZMACompressor.Native self, Py @SuppressWarnings("unused") @Specialization(guards = "action == LZMA_RUN") static byte[] javaCompress(Node inliningTarget, LZMACompressor.Java self, PythonContext context, byte[] bytes, int len, int action, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { self.write(bytes, 0, len); byte[] result = self.getByteArray(); self.resetBuffer(); return result; } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.M, e); } } @SuppressWarnings("unused") @Specialization(guards = "action == LZMA_FINISH") static byte[] javaFlush(Node inliningTarget, LZMACompressor.Java self, PythonContext context, byte[] bytes, int len, int action, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { self.finish(); return self.getByteArray(); } catch (IOException e) { - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.M, e); } } } @@ -930,7 +929,7 @@ static void auto(LZMADecompressor.Native self, @SuppressWarnings("unused") int f @Shared("cs") @Cached NativeLibrary.InvokeNativeFunction createStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaAutoDecoder, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = PythonContext.get(inliningTarget).getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); self.init(lzmast, lzmaSupport); @@ -947,7 +946,7 @@ static void xz(LZMADecompressor.Native self, @SuppressWarnings("unused") int for @Shared("cs") @Cached NativeLibrary.InvokeNativeFunction createStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaStreamDecoder, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = PythonContext.get(inliningTarget).getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); self.init(lzmast, lzmaSupport); @@ -964,7 +963,7 @@ static void alone(LZMADecompressor.Native self, @SuppressWarnings("unused") int @Shared("cs") @Cached NativeLibrary.InvokeNativeFunction createStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction lzmaAloneDecoder, @Shared @Cached InlinedConditionProfile errProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = PythonContext.get(inliningTarget).getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); self.init(lzmast, lzmaSupport); @@ -985,8 +984,8 @@ public abstract static class LZMARawDecompressInit extends Node { @SuppressWarnings("unused") @Specialization static void rawJava(VirtualFrame frame, LZMADecompressor.Java self, Object filters, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, T_LZMA_JAVA_ERROR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, T_LZMA_JAVA_ERROR); } @Specialization @@ -995,7 +994,7 @@ static void rawNative(VirtualFrame frame, Node inliningTarget, LZMADecompressor. @Cached(inline = false) NativeLibrary.InvokeNativeFunction lzmaRawDecoder, @Cached(inline = false) NativeFilterChain filterChain, @Cached InlinedConditionProfile errProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = context.getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); @@ -1116,7 +1115,7 @@ static byte[] nativeInternalDecompress(Node inliningTarget, LZMADecompressor.Nat @Cached(inline = false) NativeLibrary.InvokeNativeFunction getNextInIndex, @Cached(inline = false) NativeLibrary.InvokeNativeFunction getLzsCheck, @Cached GetOutputNativeBufferNode getBuffer, - @Exclusive @Cached PRaiseNode.Lazy lazyRaiseNode, + @Exclusive @Cached PRaiseNode lazyRaiseNode, @Cached InlinedConditionProfile errProfile) { PythonContext context = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = context.getNFILZMASupport(); @@ -1132,7 +1131,7 @@ static byte[] nativeInternalDecompress(Node inliningTarget, LZMADecompressor.Nat self.setLzsAvailIn(lzsAvailIn); self.setLzsAvailOut(lzsAvailOut); } catch (OverflowException of) { - throw lazyRaiseNode.get(inliningTarget).raise(SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); + throw lazyRaiseNode.raise(inliningTarget, SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); } if (err == LZMA_STREAM_END) { self.setEOF(); @@ -1145,7 +1144,7 @@ static byte[] nativeInternalDecompress(Node inliningTarget, LZMADecompressor.Nat @TruffleBoundary @Specialization static byte[] javaInternalDecompress(Node inliningTarget, LZMADecompressor.Java self, int maxLength, - @Exclusive @Cached PRaiseNode.Lazy lazyRaiseNode) { + @Exclusive @Cached PRaiseNode lazyRaiseNode) { if (maxLength == 0) { return PythonUtils.EMPTY_BYTE_ARRAY; } @@ -1191,7 +1190,7 @@ static byte[] javaInternalDecompress(Node inliningTarget, LZMADecompressor.Java } catch (EOFException eof) { self.setEOF(); } catch (IOException e) { - PRaiseNode.raiseUncached(inliningTarget, OSError, e); + PRaiseNode.raiseStatic(inliningTarget, OSError, e); } byte[] ret = toByteArray(baos); self.decompressedData(ret.length); @@ -1231,13 +1230,13 @@ public abstract static class GetOutputNativeBufferNode extends Node { static byte[] getBuffer(Node inliningTarget, Object lzmast, PythonContext context, @Cached(inline = false) NativeLibrary.InvokeNativeFunction getBufferSize, @Cached(inline = false) NativeLibrary.InvokeNativeFunction getBuffer, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { NFILZMASupport lzmaSupport = context.getNFILZMASupport(); int size; try { size = PInt.intValueExact(lzmaSupport.getOutputBufferSize(lzmast, getBufferSize)); } catch (OverflowException of) { - throw raiseNode.get(inliningTarget).raise(SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); + throw raiseNode.raise(inliningTarget, SystemError, VALUE_TOO_LARGE_TO_FIT_INTO_INDEX); } if (size == 0) { return PythonUtils.EMPTY_BYTE_ARRAY; @@ -1298,7 +1297,7 @@ static byte[] encodeNative(VirtualFrame frame, Object filter, @Cached NativeLibrary.InvokeNativeFunction encodeFilter, @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Cached InlinedConditionProfile errProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext ctxt = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = ctxt.getNFILZMASupport(); Object lzmast = lzmaSupport.createStream(createStream); @@ -1307,7 +1306,7 @@ static byte[] encodeNative(VirtualFrame frame, Object filter, if (errProfile.profile(inliningTarget, lzret != LZMA_OK)) { lzmaSupport.deallocateStream(lzmast, deallocateStream); if (lzret == LZMA_PRESET_ERROR) { - throw raiseNode.get(inliningTarget).raise(LZMAError, INVALID_COMPRESSION_PRESET, opts[LZMAOption.preset.ordinal()]); + throw raiseNode.raise(inliningTarget, LZMAError, INVALID_COMPRESSION_PRESET, opts[LZMAOption.preset.ordinal()]); } errorHandling(inliningTarget, lzret, raiseNode); } @@ -1319,8 +1318,8 @@ static byte[] encodeNative(VirtualFrame frame, Object filter, @SuppressWarnings("unused") @Specialization(guards = "!useNativeContext()") static byte[] encodeJava(Object filter, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, T_LZMA_JAVA_ERROR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, T_LZMA_JAVA_ERROR); } } @@ -1340,7 +1339,7 @@ static void decodeNative(VirtualFrame frame, long id, byte[] encoded, PDict dict @Cached NativeLibrary.InvokeNativeFunction decodeFilter, @Cached HashingStorageSetItem setItem, @Cached InlinedConditionProfile errProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext ctxt = PythonContext.get(inliningTarget); NFILZMASupport lzmaSupport = ctxt.getNFILZMASupport(); long[] opts = new long[MAX_OPTS_INDEX]; @@ -1350,7 +1349,7 @@ static void decodeNative(VirtualFrame frame, long id, byte[] encoded, PDict dict int lzret = lzmaSupport.decodeFilter(id, encodedProps, len, filter, decodeFilter); if (errProfile.profile(inliningTarget, lzret != LZMA_OK)) { if (lzret == LZMA_ID_ERROR) { - throw raiseNode.get(inliningTarget).raise(LZMAError, INVALID_FILTER, opts[LZMAOption.id.ordinal()]); + throw raiseNode.raise(inliningTarget, LZMAError, INVALID_FILTER, opts[LZMAOption.id.ordinal()]); } errorHandling(inliningTarget, lzret, raiseNode); } @@ -1360,8 +1359,8 @@ static void decodeNative(VirtualFrame frame, long id, byte[] encoded, PDict dict @SuppressWarnings("unused") @Specialization(guards = "!useNativeContext()") static void decodeJava(long id, byte[] encoded, PDict dict, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, T_LZMA_JAVA_ERROR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, T_LZMA_JAVA_ERROR); } static void buildFilterSpec(VirtualFrame frame, Node inliningTarget, long[] opts, PDict dict, HashingStorageSetItem setItem) { @@ -1435,7 +1434,7 @@ public int getAvailIn() { } } - protected static int errorHandling(Node inliningTarget, int lzret, PRaiseNode.Lazy raiseNode) { + protected static int errorHandling(Node inliningTarget, int lzret, PRaiseNode raiseNode) { switch (lzret) { case LZMA_OK: case LZMA_GET_CHECK: @@ -1443,23 +1442,23 @@ protected static int errorHandling(Node inliningTarget, int lzret, PRaiseNode.La case LZMA_STREAM_END: return 0; case LZMA_UNSUPPORTED_CHECK: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.UNSUPPORTED_INTEGRITY_CHECK); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.UNSUPPORTED_INTEGRITY_CHECK); case LZMA_MEM_ERROR: - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); case LZMA_MEMLIMIT_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.MEM_USAGE_LIMIT_EXCEEDED); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.MEM_USAGE_LIMIT_EXCEEDED); case LZMA_FORMAT_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.INPUT_FMT_NOT_SUPPORTED_BY_DECODER); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.INPUT_FMT_NOT_SUPPORTED_BY_DECODER); case LZMA_OPTIONS_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.INVALID_UNSUPPORTED_OPTIONS); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.INVALID_UNSUPPORTED_OPTIONS); case LZMA_DATA_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.CORRUPT_INPUT_DATA); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.CORRUPT_INPUT_DATA); case LZMA_BUF_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.INSUFFICIENT_BUFFER_SPACE); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.INSUFFICIENT_BUFFER_SPACE); case LZMA_PROG_ERROR: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.INTERNAL_ERROR); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.INTERNAL_ERROR); default: - throw raiseNode.get(inliningTarget).raise(LZMAError, ErrorMessages.UNRECOGNIZED_ERROR_FROM_LIBLZMA, lzret); + throw raiseNode.raise(inliningTarget, LZMAError, ErrorMessages.UNRECOGNIZED_ERROR_FROM_LIBLZMA, lzret); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java index 41e7a60abf..cc66ccc62c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/GraalPySemLockBuiltins.java @@ -264,10 +264,10 @@ abstract static class ReleaseLockNode extends PythonUnaryBuiltinNode { @Specialization static Object doRelease(PGraalPySemLock self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getKind() == PGraalPySemLock.RECURSIVE_MUTEX) { if (!self.isMine()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AssertionError, ErrorMessages.ATTEMP_TO_RELEASE_RECURSIVE_LOCK); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AssertionError, ErrorMessages.ATTEMP_TO_RELEASE_RECURSIVE_LOCK); } if (self.getCount() > 1) { self.decreaseCount(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java index 86d2466c87..44ab5a02d0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingGraalPyModuleBuiltins.java @@ -136,9 +136,9 @@ static PGraalPySemLock construct(Object cls, int kind, int value, @SuppressWarni @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (kind != PGraalPySemLock.RECURSIVE_MUTEX && kind != PGraalPySemLock.SEMAPHORE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.UNRECOGNIZED_KIND); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UNRECOGNIZED_KIND); } Semaphore semaphore = newSemaphore(value); if (!unlink) { @@ -149,7 +149,7 @@ static PGraalPySemLock construct(Object cls, int kind, int value, @SuppressWarni // semaphores, so a conflict raises. SharedMultiprocessingData multiprocessing = PythonContext.get(inliningTarget).getSharedMultiprocessingData(); if (multiprocessing.getNamedSemaphore(name) != null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.FileExistsError, ErrorMessages.SEMAPHORE_NAME_TAKEN, name); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.FileExistsError, ErrorMessages.SEMAPHORE_NAME_TAKEN, name); } else { multiprocessing.putNamedSemaphore(name, semaphore); } @@ -305,7 +305,7 @@ Object doWrite(int fd, PBytes data, byte[] bytes = bufferLib.getCopiedByteArray(data); sharedData.addPipeData(fd, bytes, () -> { - throw PRaiseNode.raiseUncached(this, OSError, ErrorMessages.BAD_FILE_DESCRIPTOR); + throw PRaiseNode.raiseStatic(this, OSError, ErrorMessages.BAD_FILE_DESCRIPTOR); }, () -> { throw PConstructAndRaiseNode.getUncached().raiseOSError(null, OSErrorEnum.EPIPE); @@ -335,7 +335,7 @@ Object doReadInt(int fd, @SuppressWarnings("unused") Object length, gil.release(true); try { Object data = sharedData.takePipeData(this, fd, () -> { - throw PRaiseNode.raiseUncached(this, OSError, ErrorMessages.BAD_FILE_DESCRIPTOR); + throw PRaiseNode.raiseStatic(this, OSError, ErrorMessages.BAD_FILE_DESCRIPTOR); }); if (data == PNone.NONE) { return PFactory.createEmptyBytes(language); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java index 503ec392a6..57ef5fa43e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/MultiprocessingModuleBuiltins.java @@ -97,9 +97,9 @@ static PSemLock construct(VirtualFrame frame, Object cls, int kind, int value, i @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (kind != PGraalPySemLock.RECURSIVE_MUTEX && kind != PGraalPySemLock.SEMAPHORE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.UNRECOGNIZED_KIND); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UNRECOGNIZED_KIND); } Object posixName = posixLib.createPathFromString(posixSupport, name); long handle; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java index 6b25b671de..fd6fe707cd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/multiprocessing/SemLockBuiltins.java @@ -207,11 +207,11 @@ static PNone release(VirtualFrame frame, PSemLock self, @Bind("this") Node inliningTarget, @Bind("getPosixSupport()") PosixSupport posixSupport, @CachedLibrary("posixSupport") PosixSupportLibrary posixLib, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { if (self.getKind() == PSemLock.RECURSIVE_MUTEX) { if (!self.isMine()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AssertionError, ErrorMessages.ATTEMP_TO_RELEASE_RECURSIVE_LOCK); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AssertionError, ErrorMessages.ATTEMP_TO_RELEASE_RECURSIVE_LOCK); } if (self.getCount() > 1) { self.decreaseCount(); @@ -223,7 +223,7 @@ static PNone release(VirtualFrame frame, PSemLock self, try { sval = posixLib.semGetValue(posixSupport, self.getHandle()); if (sval >= self.getMaxValue()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES); } } catch (UnsupportedPosixFeatureException e) { /* We will only check properly the maxvalue == 1 case */ @@ -231,7 +231,7 @@ static PNone release(VirtualFrame frame, PSemLock self, if (posixLib.semTryWait(posixSupport, self.getHandle())) { /* it was not locked so undo wait and raise */ posixLib.semPost(posixSupport, self.getHandle()); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SEMAPHORE_RELEASED_TOO_MANY_TIMES); } } } @@ -296,7 +296,7 @@ int get(VirtualFrame frame, PSemLock self, @Bind("getPosixSupport()") PosixSupport posixSupport, @CachedLibrary("posixSupport") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int sval = posixLib.semGetValue(posixSupport, self.getHandle()); /* @@ -311,7 +311,7 @@ int get(VirtualFrame frame, PSemLock self, throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); } catch (UnsupportedPosixFeatureException e) { // Not available on Darwin - throw raiseNode.get(inliningTarget).raise(NotImplementedError); + throw raiseNode.raise(inliningTarget, NotImplementedError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/MemoTable.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/MemoTable.java index 595da28de2..4393f54f42 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/MemoTable.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/MemoTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -173,7 +173,7 @@ private void resize() { if (newLength <= keys.length) { CompilerDirectives.transferToInterpreterAndInvalidate(); // overflow - throw PRaiseNode.raiseUncached(null, PicklingError, ErrorMessages.STRUCT_SIZE_TOO_LONG); + throw PRaiseNode.raiseStatic(null, PicklingError, ErrorMessages.STRUCT_SIZE_TOO_LONG); } MemoIterator iterator = iterator(); // captures the current contents diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java index 61a1f25b8f..c53e006ed1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PData.java @@ -98,8 +98,8 @@ public void grow() throws OverflowException { } public abstract static class PDataBaseNode extends PNodeWithContext { - static PException raiseUnderflow(PData self, PRaiseNode raiseNode) { - return raiseNode.raise(PythonBuiltinClassType.UnpicklingError, + static PException raiseUnderflow(PData self, Node inliningTarget, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnpicklingError, self.mark ? ErrorMessages.PDATA_UNEXPECTED_MARK_FOUND : ErrorMessages.PDATA_UNPICKLING_STACK_UNDERFLOW); } } @@ -112,9 +112,9 @@ public abstract static class PDataPopNode extends PDataBaseNode { @Specialization static Object pop(PData self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.size <= self.fence) { - throw raiseUnderflow(self, raiseNode.get(inliningTarget)); + throw raiseUnderflow(self, inliningTarget, raiseNode); } return self.data[--self.size]; } @@ -132,12 +132,12 @@ public abstract static class PDataPushNode extends PDataBaseNode { @Specialization static void push(PData self, Object obj, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.size == self.data.length) { try { self.grow(); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseOverflow(); + throw raiseNode.raiseOverflow(inliningTarget); } } self.data[self.size++] = obj; @@ -157,11 +157,11 @@ public abstract static class PDataPopTupleNode extends PDataBaseNode { static PTuple popTuple(PData self, int start, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int len, i, j; if (start < self.fence) { - throw raiseUnderflow(self, raiseNode.get(inliningTarget)); + throw raiseUnderflow(self, inliningTarget, raiseNode); } len = self.size - start; Object[] items = new Object[len]; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickleBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickleBuffer.java index d9bf079ce6..456c130bd1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickleBuffer.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickleBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -47,10 +47,12 @@ import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; @ExportLibrary(PythonBufferAcquireLibrary.class) @@ -80,6 +82,7 @@ boolean hasBuffer() { @ExportMessage Object acquire(int flags, + @Bind("$node") Node inliningTarget, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @CachedLibrary(limit = "3") PythonBufferAcquireLibrary acquireLib, @Cached PRaiseNode raise) { @@ -88,7 +91,7 @@ Object acquire(int flags, owner = bufferLib.getOwner(view); } if (owner == null) { - throw raise.raise(ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); } return acquireLib.acquire(owner, flags); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java index 673b820c03..c47ce7a2d1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java @@ -273,32 +273,32 @@ private void fastMemoRemove(Object object) { } // helper methods - public void setProtocol(Node inliningTarget, PRaiseNode.Lazy raiseNode, int protocol, boolean fixImports) { + public void setProtocol(Node inliningTarget, PRaiseNode raiseNode, int protocol, boolean fixImports) { proto = protocol; if (proto < 0) { proto = PickleUtils.PICKLE_PROTOCOL_HIGHEST; } else if (proto > PickleUtils.PICKLE_PROTOCOL_HIGHEST) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.PICKLE_PROTO_MUST_BE_LE, PickleUtils.PICKLE_PROTOCOL_HIGHEST); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.PICKLE_PROTO_MUST_BE_LE, PickleUtils.PICKLE_PROTOCOL_HIGHEST); } this.bin = (proto > 0) ? 1 : 0; this.fixImports = fixImports && proto < 3; } - public void setOutputStream(VirtualFrame frame, Node inliningTarget, PRaiseNode.Lazy raiseNode, PyObjectLookupAttr lookup, Object file) { + public void setOutputStream(VirtualFrame frame, Node inliningTarget, PRaiseNode raiseNode, PyObjectLookupAttr lookup, Object file) { write = lookup.execute(frame, inliningTarget, file, PickleUtils.T_METHOD_WRITE); if (write == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.FILE_MUST_HAVE_WRITE_ATTR); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.FILE_MUST_HAVE_WRITE_ATTR); } } - public void setBufferCallback(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object callback) { + public void setBufferCallback(Node inliningTarget, PRaiseNode raiseNode, Object callback) { bufferCallback = callback; if (PGuards.isNone(callback) || PGuards.isNoValue(callback)) { bufferCallback = null; } if (bufferCallback != null && proto < 5) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.BUFFCB_NEEDS_PROTO_GE_5); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.BUFFCB_NEEDS_PROTO_GE_5); } } @@ -951,7 +951,7 @@ private void saveReduce(VirtualFrame frame, PythonContext ctx, PPickler pickler, boolean useNewobj = false, useNewobjEx = false; if (!(arguments instanceof PTuple)) { - throw getRaiseNode().raiseBadInternalCall(); + throw raise(PythonBuiltinClassType.SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } int size = length(frame, arguments); if (size < 2 || size > 6) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java index f655fa1a01..f4729ecb59 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java @@ -294,7 +294,7 @@ public void initInternals(VirtualFrame frame, Node inliningTarget, PyObjectLooku this.persFuncSelf = pair.getRight(); } - public void setInputStream(VirtualFrame frame, Node inliningTarget, PRaiseNode.Lazy raiseNode, PyObjectLookupAttr lookup, Object file) { + public void setInputStream(VirtualFrame frame, Node inliningTarget, PRaiseNode raiseNode, PyObjectLookupAttr lookup, Object file) { this.peek = lookup.execute(frame, inliningTarget, file, T_METHOD_PEEK); if (this.peek == PNone.NO_VALUE) { this.peek = null; @@ -306,7 +306,7 @@ public void setInputStream(VirtualFrame frame, Node inliningTarget, PRaiseNode.L this.read = lookup.execute(frame, inliningTarget, file, T_METHOD_READ); this.readline = lookup.execute(frame, inliningTarget, file, T_METHOD_READLINE); if (this.readline == PNone.NO_VALUE || this.read == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.FILE_MUST_HAVE_A_AND_B_ATTRS, T_METHOD_READ, T_METHOD_READLINE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.FILE_MUST_HAVE_A_AND_B_ATTRS, T_METHOD_READ, T_METHOD_READLINE); } } @@ -926,7 +926,7 @@ private void loadFloat(VirtualFrame frame, PUnpickler self) { // TODO: (cbasca) we skip an entire branch from _pickle.c:load_float // TODO: (cbasca) should we return a PFloat ? (same for load_int/long variants) - value = PickleUtils.asciiBytesToDouble(s, getRaiseNode(), PythonBuiltinClassType.OverflowError); + value = PickleUtils.asciiBytesToDouble(this, s, PythonBuiltinClassType.OverflowError); pDataPush(self, value); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java index 6c64e33abb..f663f3150c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleBufferBuiltins.java @@ -86,16 +86,16 @@ Object raw(VirtualFrame frame, PPickleBuffer self, @Cached PyMemoryViewFromObject memoryViewFromObject, @Cached MemoryViewNodes.ReleaseNode releaseNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final Object view = self.getView(); if (view == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); } PMemoryView mv = memoryViewFromObject.execute(frame, self); // Make it into raw (1-dimensional bytes) memoryview try { if (!mv.isAnyContiguous()) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.CANNOT_EXTRACT_RAW_BUFFER_FROM_NON_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.CANNOT_EXTRACT_RAW_BUFFER_FROM_NON_CONTIGUOUS); } int[] shape = new int[]{mv.getLength()}; int[] strides = new int[]{1}; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java index 4f7a0a56c9..61d8bd3c95 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleModuleBuiltins.java @@ -173,7 +173,7 @@ static Object dump(VirtualFrame frame, @SuppressWarnings("unused") PythonModule @Cached PPickler.DumpNode dumpNode, @Cached PPickler.FlushToFileNode flushToFileNode, @Cached PyObjectLookupAttr lookup, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PPickler pickler = PFactory.createPickler(language); pickler.setProtocol(inliningTarget, raiseNode, protocol, fixImports); pickler.setOutputStream(frame, inliningTarget, raiseNode, lookup, file); @@ -201,7 +201,7 @@ static Object dump(VirtualFrame frame, @SuppressWarnings("unused") PythonModule @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached PPickler.DumpNode dumpNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PPickler pickler = PFactory.createPickler(language); pickler.setProtocol(inliningTarget, raiseNode, protocol, fixImports); pickler.setBufferCallback(inliningTarget, raiseNode, bufferCallback); @@ -230,7 +230,7 @@ static Object load(VirtualFrame frame, @SuppressWarnings("unused") PythonModule @Cached PUnpickler.LoadNode loadNode, @Cached PyObjectLookupAttr lookup, @Cached PyObjectGetIter getIter, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PUnpickler unpickler = PFactory.createUnpickler(language); unpickler.setInputStream(frame, inliningTarget, raiseNode, lookup, file); unpickler.setInputEncoding(encoding, errors); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleState.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleState.java index 5f8e057b40..9d72cf64e9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleState.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -99,7 +99,7 @@ public abstract static class PickleStateInitNode extends Node { @Specialization void init(PickleState state, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectGetAttr getAttr, @Cached PyCallableCheckNode callableCheck) { PythonContext context = PythonContext.get(this); @@ -111,28 +111,28 @@ void init(PickleState state, if (dispatchTable instanceof PDict dispatchTableDict) { state.dispatchTable = dispatchTableDict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg.dispatch_table", "dict", dispatchTable); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg.dispatch_table", "dict", dispatchTable); } var extensionRegistry = getAttr.execute(null, inliningTarget, copyreg, PickleUtils.T_ATTR_EXT_REGISTRY); if (extensionRegistry instanceof PDict extensionRegistryDict) { state.extensionRegistry = extensionRegistryDict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._extension_registry", "dict", extensionRegistry); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._extension_registry", "dict", extensionRegistry); } var invertedRegistry = getAttr.execute(null, inliningTarget, copyreg, PickleUtils.T_ATTR_INV_REGISTRY); if (invertedRegistry instanceof PDict invertedRegistryDict) { state.invertedRegistry = invertedRegistryDict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._inverted_registry", "dict", invertedRegistry); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._inverted_registry", "dict", invertedRegistry); } var extensionCache = getAttr.execute(null, inliningTarget, copyreg, PickleUtils.T_ATTR_EXT_CACHE); if (extensionCache instanceof PDict extensionCacheDict) { state.extensionCache = extensionCacheDict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._extension_cache", "dict", extensionCache); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "copyreg._extension_cache", "dict", extensionCache); } final Object codecs = importModule(PickleUtils.T_MOD_CODECS); @@ -140,7 +140,7 @@ void init(PickleState state, if (callableCheck.execute(inliningTarget, codecsEncode)) { state.codecsEncode = codecsEncode; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "codecs.encode", "callable", codecsEncode); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, "codecs.encode", "callable", codecsEncode); } final Object functools = importModule(PickleUtils.T_MOD_FUNCTOOLS); @@ -152,14 +152,14 @@ void init(PickleState state, if (nameMapping2To3 instanceof PDict nameMapping2To3Dict) { state.nameMapping2To3 = nameMapping2To3Dict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_NAME_MAPPING, "dict", nameMapping2To3); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_NAME_MAPPING, "dict", nameMapping2To3); } var importMapping2To3 = getAttr.execute(null, inliningTarget, compatPickle, PickleUtils.T_ATTR_IMPORT_MAPPING); if (importMapping2To3 instanceof PDict importMapping2To3Dict) { state.importMapping2To3 = importMapping2To3Dict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_IMPORT_MAPPING, "dict", importMapping2To3); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_IMPORT_MAPPING, "dict", importMapping2To3); } // ... and the 3.x -> 2.x mapping tables @@ -167,13 +167,13 @@ void init(PickleState state, if (nameMapping3To2 instanceof PDict nameMapping3To2Dict) { state.nameMapping3To2 = nameMapping3To2Dict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_REVERSE_NAME_MAPPING, "dict", nameMapping3To2); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_REVERSE_NAME_MAPPING, "dict", nameMapping3To2); } var importMapping3To2 = getAttr.execute(null, inliningTarget, compatPickle, PickleUtils.T_ATTR_REVERSE_IMPORT_MAPPING); if (importMapping3To2 instanceof PDict importMapping3To2Dict) { state.importMapping3To2 = importMapping3To2Dict; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_REVERSE_IMPORT_MAPPING, "dict", + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.S_SHOULD_BE_A_S_NOT_A_P, PickleUtils.T_CP_REVERSE_IMPORT_MAPPING, "dict", importMapping3To2); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java index 3efa079792..ba48abdb2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PickleUtils.java @@ -287,11 +287,11 @@ public static double asciiBytesToDouble(byte[] bytes) { } @TruffleBoundary - public static double asciiBytesToDouble(byte[] bytes, PRaiseNode raiseNode, PythonBuiltinClassType errorType) { + public static double asciiBytesToDouble(Node node, byte[] bytes, PythonBuiltinClassType errorType) { try { return asciiBytesToDouble(bytes); } catch (NumberFormatException nfe) { - throw raiseNode.raise(errorType); + throw PRaiseNode.raiseStatic(node, errorType); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java index 0fd7fffb30..fe48592c84 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerBuiltins.java @@ -118,7 +118,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object init(VirtualFrame frame, PPickler self, Object file, int protocol, boolean fixImports, Object bufferCallback, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookup, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.setProtocol(inliningTarget, raiseNode, protocol, fixImports); self.setOutputStream(frame, inliningTarget, raiseNode, lookup, file); self.setBufferCallback(inliningTarget, raiseNode, bufferCallback); @@ -137,9 +137,9 @@ static Object dump(VirtualFrame frame, PPickler self, Object obj, @Bind("this") Node inliningTarget, @Cached PPickler.FlushToFileNode flushToFileNode, @Cached PPickler.DumpNode dumpNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getWrite() == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.PicklingError, ErrorMessages.INIT_CALLED_WITH, "Pickler", self); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.PicklingError, ErrorMessages.INIT_CALLED_WITH, "Pickler", self); } self.clearBuffer(); dumpNode.execute(frame, self, obj); @@ -175,10 +175,10 @@ public abstract static class PicklerDispatchTableNode extends PythonBuiltinNode @Specialization(guards = "isNoValue(none)") static Object get(PPickler self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { final Object dispatchTable = self.getDispatchTable(); if (dispatchTable == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_ATTR_DISPATCH_TABLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, T_ATTR_DISPATCH_TABLE); } return dispatchTable; } @@ -186,10 +186,10 @@ static Object get(PPickler self, @SuppressWarnings("unused") PNone none, @Specialization(guards = "isDeleteMarker(marker)") static Object delete(PPickler self, @SuppressWarnings("unused") Object marker, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { final Object dispatchTable = self.getDispatchTable(); if (dispatchTable == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_ATTR_DISPATCH_TABLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, T_ATTR_DISPATCH_TABLE); } self.setDispatchTable(null); return PNone.NONE; @@ -259,7 +259,7 @@ static Object set(VirtualFrame frame, PPickler self, Object obj, @Cached HashingStorageGetIterator getIter, @Cached HashingStorageIteratorNext iterNext, @Cached HashingStorageIteratorValue iterValue, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { MemoTable newMemo; if (obj instanceof PPicklerMemoProxy) { final PPickler pickler = ((PPicklerMemoProxy) obj).getPickler(); @@ -271,7 +271,7 @@ static Object set(VirtualFrame frame, PPickler self, Object obj, while (iterNext.execute(inliningTarget, dictStorage, it)) { Object value = iterValue.execute(inliningTarget, dictStorage, it); if (!(value instanceof PTuple) || sizeNode.execute(frame, inliningTarget, value) != 2) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.VALUES_MUST_BE_2TUPLES, "memo"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.VALUES_MUST_BE_2TUPLES, "memo"); } SequenceStorage tupleStorage = getSequenceStorageNode.execute(inliningTarget, value); int memoId = asSizeNode.executeExact(frame, inliningTarget, getItemNode.execute(frame, tupleStorage, 0)); @@ -279,7 +279,7 @@ static Object set(VirtualFrame frame, PPickler self, Object obj, newMemo.set(memoObj, memoId); } } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_OR_B_NOT_C, "memo", "PicklerMemoProxy", "dict", obj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_OR_B_NOT_C, "memo", "PicklerMemoProxy", "dict", obj); } self.setMemo(newMemo); return PNone.NONE; @@ -293,10 +293,10 @@ public abstract static class PicklerPersistentIdNode extends PythonBuiltinNode { static Object get(PPickler self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { final Object persFunc = self.getPersFunc(); if (persFunc == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_ID); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_ID); } return PickleUtils.reconstructMethod(language, persFunc, self.getPersFuncSelf()); } @@ -305,12 +305,12 @@ static Object get(PPickler self, @SuppressWarnings("unused") PNone none, static Object set(PPickler self, Object obj, @Bind("this") Node inliningTarget, @Cached PyCallableCheckNode callableCheck, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (PGuards.isDeleteMarker(obj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATRIBUTE_DELETION_NOT_SUPPORTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATRIBUTE_DELETION_NOT_SUPPORTED); } if (!callableCheck.execute(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_CALLABLE, T_METHOD_PERSISTENT_ID, "one argument"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_CALLABLE, T_METHOD_PERSISTENT_ID, "one argument"); } self.setPersFuncSelf(null); self.setPersFunc(obj); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java index 74c5c9e9ec..7e68d843d9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java @@ -111,6 +111,7 @@ import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; public final class PicklerNodes { @@ -164,30 +165,21 @@ abstract static class BasePickleNode extends Node { @Child private HashingStorageIteratorNext hashingStorageItNext; @Child private HashingStorageIteratorKey hashingStorageItKey; @Child private HashingStorageIteratorValue hashingStorageItValue; - @Child private PRaiseNode raiseNode; - - protected final PRaiseNode getRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (isAdoptable()) { - raiseNode = insert(PRaiseNode.create()); - } else { - raiseNode = PRaiseNode.getUncached(); - } - } - return raiseNode; - } + private final BranchProfile errorProfile = BranchProfile.create(); protected PException raise(PythonBuiltinClassType type, TruffleString string) { - return getRaiseNode().raise(type, string); + errorProfile.enter(); + return PRaiseNode.raiseStatic(this, type, string); } protected PException raise(PythonBuiltinClassType exceptionType) { - return getRaiseNode().raise(exceptionType); + errorProfile.enter(); + return PRaiseNode.raiseStatic(this, exceptionType); } protected final PException raise(PythonBuiltinClassType type, TruffleString format, Object... arguments) { - return getRaiseNode().raise(type, format, arguments); + errorProfile.enter(); + return PRaiseNode.raiseStatic(this, type, format, arguments); } protected TruffleString.FromByteArrayNode ensureTsFromByteArray() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java index 051c0a9d16..27240d4785 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/UnpicklerBuiltins.java @@ -113,7 +113,7 @@ static Object load(VirtualFrame frame, PUnpickler self, Object file, boolean fix @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookup, @Cached PyObjectGetIter getIter, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.setInputStream(frame, inliningTarget, raiseNode, lookup, file); self.setInputEncoding(encoding, errors); self.setBuffers(frame, inliningTarget, getIter, buffers); @@ -132,9 +132,9 @@ public abstract static class UnpicklerLoadNode extends PythonUnaryBuiltinNode { static Object load(VirtualFrame frame, PUnpickler self, @Bind("this") Node inliningTarget, @Cached PUnpickler.LoadNode loadNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getRead() == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.UnpicklingError, ErrorMessages.INIT_CALLED_WITH, "Unpickler", self); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnpicklingError, ErrorMessages.INIT_CALLED_WITH, "Unpickler", self); } return loadNode.execute(frame, self); } @@ -164,10 +164,10 @@ public abstract static class UnpicklerPersistentLoadNode extends PythonBuiltinNo static Object get(PUnpickler self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { final Object persFunc = self.getPersFunc(); if (persFunc == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_LOAD); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, T_METHOD_PERSISTENT_LOAD); } return PickleUtils.reconstructMethod(language, persFunc, self.getPersFuncSelf()); } @@ -176,12 +176,12 @@ static Object get(PUnpickler self, @SuppressWarnings("unused") PNone none, static Object set(PUnpickler self, Object obj, @Bind("this") Node inliningTarget, @Cached PyCallableCheckNode callableCheck, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (PGuards.isDeleteMarker(obj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATRIBUTE_DELETION_NOT_SUPPORTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATRIBUTE_DELETION_NOT_SUPPORTED); } if (!callableCheck.execute(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_CALLABLE, T_METHOD_PERSISTENT_LOAD, "one argument"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_CALLABLE, T_METHOD_PERSISTENT_LOAD, "one argument"); } self.setPersFuncSelf(null); self.setPersFunc(obj); @@ -207,7 +207,7 @@ static Object set(VirtualFrame frame, PUnpickler self, Object obj, @Cached HashingStorageIteratorNext storageIterNext, @Cached HashingStorageIteratorKey storageIterKey, @Cached HashingStorageIteratorValue storageIterValue, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (obj instanceof PUnpicklerMemoProxy) { final PUnpickler unpickler = ((PUnpicklerMemoProxy) obj).getUnpickler(); self.setMemo(unpickler.getMemoCopy()); @@ -219,16 +219,16 @@ static Object set(VirtualFrame frame, PUnpickler self, Object obj, Object key = storageIterKey.execute(inliningTarget, dictStorage, it); Object value = storageIterValue.execute(inliningTarget, dictStorage, it); if (!PGuards.canBeInteger(key)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.MEMO_KEY_MUST_BE_INT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MEMO_KEY_MUST_BE_INT); } final int idx = asSizeNode.executeExact(frame, inliningTarget, key); if (idx < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.MEMO_KEY_MUST_BE_POS_INT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.MEMO_KEY_MUST_BE_POS_INT); } self.memoPut(idx, value); } } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_OR_B_NOT_C, "memo", "UnpicklerMemoProxy", "dict", obj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_MUST_BE_A_OR_B_NOT_C, "memo", "UnpicklerMemoProxy", "dict", obj); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java index c68a766994..2cd7ea0328 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibCompObject.java @@ -242,12 +242,12 @@ private static int gzipHeader(byte[] bytes, Node node) { int idx = 0; // Check header magic if (readShort(bytes, idx, crc) != GZIP_MAGIC) { - throw PRaiseNode.raiseUncached(node, ZLibError, ErrorMessages.NOT_IN_GZIP_FORMAT); + throw PRaiseNode.raiseStatic(node, ZLibError, ErrorMessages.NOT_IN_GZIP_FORMAT); } idx += 2; // Check compression method if (getValue(bytes[idx++], crc) != 8) { - throw PRaiseNode.raiseUncached(node, ZLibError, ErrorMessages.UNSUPPORTED_COMPRESSION_METHOD); + throw PRaiseNode.raiseStatic(node, ZLibError, ErrorMessages.UNSUPPORTED_COMPRESSION_METHOD); } // Read flags int flg = getValue(bytes[idx++], crc); @@ -278,7 +278,7 @@ private static int gzipHeader(byte[] bytes, Node node) { if ((flg & FHCRC) == FHCRC) { int v = (int) crc.getValue() & 0xffff; if (readShort(bytes, idx, crc) != v) { - throw PRaiseNode.raiseUncached(node, ZLibError, ErrorMessages.CORRUPT_GZIP_HEADER); + throw PRaiseNode.raiseStatic(node, ZLibError, ErrorMessages.CORRUPT_GZIP_HEADER); } idx += 2; n += 2; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java index eaadef3527..6eae81e755 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java @@ -310,8 +310,8 @@ static byte[] doMemView(VirtualFrame frame, PMemoryView bytesLike, @Fallback static byte[] error(@SuppressWarnings("unused") VirtualFrame frame, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, value); } @ClinicConverterFactory @@ -387,8 +387,8 @@ static long doJavaObject(VirtualFrame frame, Object data, int value, @Fallback static long error(Object data, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, EXPECTED_BYTESLIKE_GOT_P, data); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, EXPECTED_BYTESLIKE_GOT_P, data); } long nativeCrc32(byte[] bytes, int len, int value, @@ -576,10 +576,10 @@ static PBytes decompress(VirtualFrame frame, Object buffer, int wbits, int bufsi @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached DecompressInnerNode innerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (bufsize < 0) { - throw raiseNode.get(inliningTarget).raise(ZLibError, ErrorMessages.MUST_BE_NON_NEGATIVE, "bufsize"); + throw raiseNode.raise(inliningTarget, ZLibError, ErrorMessages.MUST_BE_NON_NEGATIVE, "bufsize"); } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); @@ -622,14 +622,14 @@ static byte[] doJava(Node inliningTarget, byte[] bytes, int length, int wbits, i while (!decompresser.finished()) { int howmany = decompresser.inflate(resultArray); if (howmany == 0 && decompresser.needsInput()) { - throw PRaiseNode.raiseUncached(inliningTarget, ZLibError, ErrorMessages.ERROR_5_WHILE_DECOMPRESSING); + throw PRaiseNode.raiseStatic(inliningTarget, ZLibError, ErrorMessages.ERROR_5_WHILE_DECOMPRESSING); } baos.write(resultArray, 0, howmany); } decompresser.end(); return baos.toByteArray(); } catch (DataFormatException e) { - throw PRaiseNode.raiseUncached(inliningTarget, ZLibError, ErrorMessages.WHILE_PREPARING_TO_S_DATA, "decompress"); + throw PRaiseNode.raiseStatic(inliningTarget, ZLibError, ErrorMessages.WHILE_PREPARING_TO_S_DATA, "decompress"); } } } @@ -707,15 +707,15 @@ static Object doJava(int level, @SuppressWarnings("unused") int method, int wbit @SuppressWarnings("unused") @Specialization(guards = {"method == DEFLATED", "!useNative()", "!isValidWBitRange(wbits)"}) static Object invalid(int level, int method, int wbits, int memLevel, int strategy, byte[] zdict, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_INITIALIZATION_OPTION); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_INITIALIZATION_OPTION); } @SuppressWarnings("unused") @Specialization(guards = {"method != DEFLATED"}) static Object methodErr(int level, int method, int wbits, int memLevel, int strategy, byte[] zdict, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFLATED_ALLOWED_AS_METHOD, DEFLATED, method); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ONLY_DEFLATED_ALLOWED_AS_METHOD, DEFLATED, method); } } @@ -782,8 +782,8 @@ static Object doJava(int wbits, byte[] zdict) { @SuppressWarnings("unused") @Specialization(guards = {"!useNative()", "!isValidWBitRange(wbits)"}) static Object invalid(int wbits, byte[] zdict, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_INITIALIZATION_OPTION); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_INITIALIZATION_OPTION); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java index 7c35370221..d3093d5d81 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibCompressBuiltins.java @@ -109,10 +109,10 @@ static PBytes compress(VirtualFrame frame, ZLibCompObject self, Object buffer, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached CompressInnerNode innerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (!self.isInitialized()) { - throw raiseNode.get(inliningTarget).raise(ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while compressing data", "inconsistent stream state"); + throw raiseNode.raise(inliningTarget, ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while compressing data", "inconsistent stream state"); } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); @@ -183,15 +183,15 @@ static Object doJava(ZLibCompObject.JavaZlibCompObject self) { @SuppressWarnings("unused") @Specialization(guards = {"self.isInitialized()", "!self.canCopy()"}) static PNone error(ZLibCompObject.JavaZlibCompObject self, - @Cached.Shared @Cached(inline = false) PRaiseNode raise) { - throw raise.raise(NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); } @SuppressWarnings("unused") @Specialization(guards = "!self.isInitialized()") static PNone error(ZLibCompObject self, - @Cached.Shared @Cached(inline = false) PRaiseNode raise) { - throw raise.raise(ValueError, ErrorMessages.INCONSISTENT_STREAM_STATE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.INCONSISTENT_STREAM_STATE); } } @@ -283,8 +283,8 @@ static PBytes doit(ZLibCompObject.JavaZlibCompObject self, int mode, @SuppressWarnings("unused") @Specialization(guards = "!self.isInitialized()") static PNone error(ZLibCompObject self, int mode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while compressing data", "inconsistent stream state"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while compressing data", "inconsistent stream state"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java index eec33b9332..b43e5fd4a0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibDecompressBuiltins.java @@ -115,13 +115,13 @@ static PBytes decompress(VirtualFrame frame, ZLibCompObject self, Object buffer, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached DecompressInnerNode innerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (!self.isInitialized()) { - throw raiseNode.get(inliningTarget).raise(ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while decompressing data", "inconsistent stream state"); + throw raiseNode.raise(inliningTarget, ZLibError, ERROR_D_S_S, Z_STREAM_ERROR, "while decompressing data", "inconsistent stream state"); } if (maxLength < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_MUST_BE_GREATER_THAN_ZERO, "max_length"); + throw raiseNode.raise(inliningTarget, ValueError, S_MUST_BE_GREATER_THAN_ZERO, "max_length"); } byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); int len = bufferLib.getBufferLength(buffer); @@ -188,15 +188,15 @@ static Object doJava(Node inliningTarget, ZLibCompObject.JavaZlibCompObject self @SuppressWarnings("unused") @Specialization(guards = {"self.isInitialized()", "!self.canCopy()"}) static PNone error(ZLibCompObject.JavaZlibCompObject self, - @Cached.Shared @Cached(inline = false) PRaiseNode raise) { - throw raise.raise(NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, toTruffleStringUncached("JDK based zlib doesn't support copying")); } @SuppressWarnings("unused") @Specialization(guards = "!self.isInitialized()") static PNone error(ZLibCompObject self, - @Cached.Shared @Cached(inline = false) PRaiseNode raise) { - throw raise.raise(ValueError, INCONSISTENT_STREAM_STATE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INCONSISTENT_STREAM_STATE); } } @@ -295,8 +295,8 @@ static PBytes empty(ZLibCompObject.NativeZlibCompObject self, int length, @SuppressWarnings("unused") @Specialization(guards = "length <= 0") static PBytes error(ZLibCompObject self, int length, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, S_MUST_BE_GREATER_THAN_ZERO, "length"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, S_MUST_BE_GREATER_THAN_ZERO, "length"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java index 2b4a974768..65fce92816 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZlibNodes.java @@ -88,6 +88,7 @@ import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -243,6 +244,7 @@ public abstract static class ZlibNativeErrorMsg extends Node { @SuppressWarnings("unused") @Specialization(guards = "err == Z_VERSION_ERROR") static void doVersionError(Object zst, int err, TruffleString msg, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("r") @Cached PRaiseNode raise) { /* @@ -250,11 +252,12 @@ static void doVersionError(Object zst, int err, TruffleString msg, NFIZlibSuppor * first, before looking at comp->zst.msg. */ deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ZLibError, ERROR_D_S_S, err, msg, LIBRARY_VERSION_MISMATCH); + throw raise.raise(inliningTarget, ZLibError, ERROR_D_S_S, err, msg, LIBRARY_VERSION_MISMATCH); } @Specialization(guards = "err != Z_VERSION_ERROR") static void doError(Object zst, int err, TruffleString msg, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Exclusive @Cached NativeLibrary.InvokeNativeFunction hasStreamErrorMsg, @@ -277,9 +280,9 @@ static void doError(Object zst, int err, TruffleString msg, NFIZlibSupport zlibS } deallocateStream(zst, zlibSupport, deallocateStream, deallocate); if (zmsg == null) { - throw raise.raise(ZLibError, ERROR_D_S, err, msg); + throw raise.raise(inliningTarget, ZLibError, ERROR_D_S, err, msg); } else { - throw raise.raise(ZLibError, ERROR_D_S_S, err, msg, zmsg); + throw raise.raise(inliningTarget, ZLibError, ERROR_D_S_S, err, msg, zmsg); } } } @@ -293,68 +296,72 @@ public abstract static class ZlibFunctionNativeErrorHandling extends Node { @Specialization(guards = "function == DEFLATE_INIT_ERROR") static void deflateInitError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, OUT_OF_MEMORY_WHILE_S_DATA, "compressing"); + throw raise.raise(inliningTarget, MemoryError, OUT_OF_MEMORY_WHILE_S_DATA, "compressing"); } if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ZLibError, ErrorMessages.BAD_COMPRESSION_LEVEL); + throw raise.raise(inliningTarget, ZLibError, ErrorMessages.BAD_COMPRESSION_LEVEL); } zlibError.execute(zst, err, formatNode.format(WHILE_S_DATA, "compressing"), zlibSupport, deallocate); } @Specialization(guards = "function == DEFLATE_OBJ_ERROR") static void deflateObjInitError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "compression"); + throw raise.raise(inliningTarget, MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "compression"); } if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ValueError, INVALID_INITIALIZATION_OPTION); + throw raise.raise(inliningTarget, ValueError, INVALID_INITIALIZATION_OPTION); } zlibError.execute(zst, err, formatNode.format(WHILE_CREATING_S_OBJECT, "compression"), zlibSupport, deallocate); } @Specialization(guards = "function == DEFLATE_COPY_ERROR") static void deflateCopyError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "compression"); + throw raise.raise(inliningTarget, MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "compression"); } if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ValueError, INCONSISTENT_STREAM_STATE); + throw raise.raise(inliningTarget, ValueError, INCONSISTENT_STREAM_STATE); } zlibError.execute(zst, err, formatNode.format(WHILE_COPYING_S_OBJECT, "compression"), zlibSupport, deallocate); } @Specialization(guards = "function == INFLATE_COPY_ERROR") static void inflateCopyError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "decompression"); + throw raise.raise(inliningTarget, MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "decompression"); } if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ValueError, INCONSISTENT_STREAM_STATE); + throw raise.raise(inliningTarget, ValueError, INCONSISTENT_STREAM_STATE); } zlibError.execute(zst, err, formatNode.format(WHILE_COPYING_S_OBJECT, "compression"), zlibSupport, deallocate); } @@ -362,25 +369,27 @@ static void inflateCopyError(Object zst, @SuppressWarnings("unused") int functio @SuppressWarnings("unused") @Specialization(guards = "function == DEFLATE_DICT_ERROR") static void deflateDictError(Object zst, int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("r") @Cached PRaiseNode raise) { if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ValueError, INVALID_DICTIONARY); + throw raise.raise(inliningTarget, ValueError, INVALID_DICTIONARY); } - throw raise.raise(ValueError, ErrorMessages.DEFLATED_SET_DICT); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.DEFLATED_SET_DICT); } @Specialization(guards = "function == INFLATE_INIT_ERROR") static void inflateInitError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, OUT_OF_MEMORY_WHILE_S_DATA, "decompressing"); + throw raise.raise(inliningTarget, MemoryError, OUT_OF_MEMORY_WHILE_S_DATA, "decompressing"); } zlibError.execute(zst, err, formatNode.format(WHILE_PREPARING_TO_S_DATA, "decompress"), zlibSupport, deallocate); @@ -388,17 +397,18 @@ static void inflateInitError(Object zst, @SuppressWarnings("unused") int functio @Specialization(guards = "function == INFLATE_OBJ_ERROR") static void inflateObjInitError(Object zst, @SuppressWarnings("unused") int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("r") @Cached PRaiseNode raise, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("err") @Cached ZlibNativeErrorMsg zlibError, @Shared("format") @Cached SimpleTruffleStringFormatNode formatNode) { if (err == Z_MEM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "decompression"); + throw raise.raise(inliningTarget, MemoryError, CANT_ALLOCATE_MEMORY_FOR_S_OBJECT, "decompression"); } if (err == Z_STREAM_ERROR) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(ValueError, INVALID_INITIALIZATION_OPTION); + throw raise.raise(inliningTarget, ValueError, INVALID_INITIALIZATION_OPTION); } zlibError.execute(zst, err, formatNode.format(WHILE_CREATING_S_OBJECT, "decompression"), zlibSupport, deallocate); } @@ -452,16 +462,17 @@ static void inflateFlushError(Object zst, @SuppressWarnings("unused") int functi @SuppressWarnings("unused") @Specialization(guards = "function == MEMORY_ERROR") static void memError(Object zst, int function, int err, NFIZlibSupport zlibSupport, boolean deallocate, + @Bind("this") Node inliningTarget, @Shared("d") @Cached NativeLibrary.InvokeNativeFunction deallocateStream, @Shared("r") @Cached PRaiseNode raise) { deallocateStream(zst, zlibSupport, deallocateStream, deallocate); - throw raise.raise(MemoryError); + throw raise.raise(inliningTarget, MemoryError); } @SuppressWarnings("unused") @Fallback void fallback(Object zst, int function, int err, NFIZlibSupport zlibSupport, boolean deallocate) { - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.UNHANDLED_ERROR); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.UNHANDLED_ERROR); } } @@ -584,11 +595,11 @@ private static byte[] createByteArray(ZLibCompObject.JavaZlibCompObject self, In // we inflate again with a dictionary bytesWritten = inflater.inflate(result, 0, len); } else { - throw PRaiseNode.raiseUncached(nodeForRaise, ZLibError, WHILE_SETTING_ZDICT); + throw PRaiseNode.raiseStatic(nodeForRaise, ZLibError, WHILE_SETTING_ZDICT); } } } catch (DataFormatException e) { - throw PRaiseNode.raiseUncached(nodeForRaise, ZLibError, e); + throw PRaiseNode.raiseStatic(nodeForRaise, ZLibError, e); } baos.write(result, 0, bytesWritten); } 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 6152dda06f..1cf346883a 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 @@ -291,7 +291,7 @@ public boolean hasArrayElements( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetObjectSlotsNode getSlotsNode, @Exclusive @Cached PySequenceCheckNode sequenceCheck, @Exclusive @Cached GilNode gil) { @@ -406,7 +406,7 @@ public long getArraySize( // GR-44020: make shared: @Exclusive @Cached CastToJavaLongExactNode toLongNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); try { @@ -441,7 +441,7 @@ public boolean isArrayElementReadable(long idx, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PySequenceSizeNode sequenceSizeNode, @Shared("getBehavior") @Cached GetInteropBehaviorNode getBehavior, @Shared("getValue") @Cached GetInteropBehaviorValueNode getValue, @@ -471,7 +471,7 @@ public boolean isArrayElementModifiable(long idx, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PySequenceSizeNode sequenceSizeNode, @Shared("getBehavior") @Cached GetInteropBehaviorNode getBehavior, @Shared("getValue") @Cached GetInteropBehaviorValueNode getValue, @@ -503,7 +503,7 @@ public boolean isArrayElementInsertable(long idx, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PySequenceSizeNode sequenceSizeNode, @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -533,7 +533,7 @@ public boolean isArrayElementRemovable(long idx, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PySequenceSizeNode sequenceSizeNode, @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -659,7 +659,7 @@ public boolean isExecutable( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached PyCallableCheckNode callableCheck, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { @@ -852,7 +852,7 @@ public boolean isDate( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -878,7 +878,7 @@ public LocalDate asDate( // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode castToIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached SequenceStorageNodes.GetItemDynamicNode getItemNode, // GR-44020: make shared: @@ -893,7 +893,7 @@ public LocalDate asDate( Object value = getValue.execute(inliningTarget, behavior, method, this); if (value instanceof PTuple tuple) { if (pyTupleSizeNode.execute(inliningTarget, tuple) != 3) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_MUST_BE_A_S_TUPLE, "return value", "3"); + throw raiseNode.raise(inliningTarget, ValueError, S_MUST_BE_A_S_TUPLE, "return value", "3"); } SequenceStorage storage = tuple.getSequenceStorage(); int year = castToIntNode.executeWithThrowSystemError(inliningTarget, getItemNode.execute(inliningTarget, storage, 0), raiseNode); @@ -902,10 +902,10 @@ public LocalDate asDate( try { return createLocalDate(year, month, day); } catch (Exception e) { - throw raiseNode.get(inliningTarget).raise(SystemError, e); + throw raiseNode.raise(inliningTarget, SystemError, e); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); } } else { @@ -925,7 +925,7 @@ public boolean isTime( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -951,7 +951,7 @@ public LocalTime asTime( // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode castToIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached SequenceStorageNodes.GetItemDynamicNode getItemNode, // GR-44020: make shared: @@ -966,7 +966,7 @@ public LocalTime asTime( Object value = getValue.execute(inliningTarget, behavior, method, this); if (value instanceof PTuple tuple) { if (pyTupleSizeNode.execute(inliningTarget, tuple) != 4) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_MUST_BE_A_S_TUPLE, "return value", "4"); + throw raiseNode.raise(inliningTarget, ValueError, S_MUST_BE_A_S_TUPLE, "return value", "4"); } SequenceStorage storage = tuple.getSequenceStorage(); int hour = castToIntNode.executeWithThrowSystemError(inliningTarget, getItemNode.execute(inliningTarget, storage, 0), raiseNode); @@ -976,10 +976,10 @@ public LocalTime asTime( try { return createLocalTime(hour, min, sec, micro); } catch (Exception e) { - throw raiseNode.get(inliningTarget).raise(SystemError, e); + throw raiseNode.raise(inliningTarget, SystemError, e); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); } } else { throw UnsupportedMessageException.create(); @@ -999,7 +999,7 @@ public boolean isTimeZone( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1025,7 +1025,7 @@ public ZoneId asTimeZone( // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode castToIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached TruffleString.ToJavaStringNode toJavaStringNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { @@ -1045,10 +1045,10 @@ public ZoneId asTimeZone( return createZoneId(utcDeltaInSeconds); } } catch (Exception e) { - throw raiseNode.get(inliningTarget).raise(SystemError, e); + throw raiseNode.raise(inliningTarget, SystemError, e); } } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "str or int", value); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "str or int", value); } } else { throw UnsupportedMessageException.create(); @@ -1087,7 +1087,7 @@ public boolean isDuration( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1113,7 +1113,7 @@ public Duration asDuration( // GR-44020: make shared: @Exclusive @Cached CastToJavaLongExactNode castToLongNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached SequenceStorageNodes.GetItemDynamicNode getItemNode, // GR-44020: make shared: @@ -1128,7 +1128,7 @@ public Duration asDuration( Object value = getValue.execute(inliningTarget, behavior, method, this); if (value instanceof PTuple tuple) { if (pyTupleSizeNode.execute(inliningTarget, tuple) != 2) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_MUST_BE_A_S_TUPLE, "return value", "2"); + throw raiseNode.raise(inliningTarget, ValueError, S_MUST_BE_A_S_TUPLE, "return value", "2"); } SequenceStorage storage = tuple.getSequenceStorage(); long sec = castToLongNode.executeWithThrowSystemError(inliningTarget, getItemNode.execute(inliningTarget, storage, 0), raiseNode); @@ -1136,10 +1136,10 @@ public Duration asDuration( try { return createDuration(sec, nano); } catch (Exception e) { - throw raiseNode.get(inliningTarget).raise(SystemError, e); + throw raiseNode.raise(inliningTarget, SystemError, e); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "return value", "tuple", value); } } else { throw UnsupportedMessageException.create(); @@ -1672,7 +1672,7 @@ public boolean hasIterator( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("getClass") @Cached(inline = false) GetClassNode getClassNode, @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter, // GR-44020: make shared: @@ -1727,7 +1727,7 @@ public boolean isIterator( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("getClass") @Cached(inline = false) GetClassNode getClassNode, @Cached(parameters = "Next") LookupCallableSlotInMRONode lookupNext, // GR-44020: make shared: @@ -1755,7 +1755,7 @@ public boolean hasIteratorNextElement( // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetNextNode getNextNode, @Exclusive @Cached IsBuiltinObjectProfile exceptionProfile, @Exclusive @Cached GilNode gil, @@ -1830,7 +1830,7 @@ public boolean isBoolean(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1855,7 +1855,7 @@ public boolean isNumber(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1880,7 +1880,7 @@ public boolean isString(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1905,7 +1905,7 @@ public boolean fitsInByte(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1930,7 +1930,7 @@ public boolean fitsInShort(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1955,7 +1955,7 @@ public boolean fitsInInt(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -1980,7 +1980,7 @@ public boolean fitsInLong(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2005,7 +2005,7 @@ public boolean fitsInFloat(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2030,7 +2030,7 @@ public boolean fitsInDouble(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2055,7 +2055,7 @@ public boolean fitsInBigInteger(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2080,7 +2080,7 @@ public boolean asBoolean(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2105,7 +2105,7 @@ public byte asByte(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaByteNode toByteNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2130,7 +2130,7 @@ public short asShort(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaShortNode toShortNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2155,7 +2155,7 @@ public int asInt(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2180,7 +2180,7 @@ public long asLong(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaLongExactNode toLongNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2205,7 +2205,7 @@ public float asFloat(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaDoubleNode toDoubleNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2230,7 +2230,7 @@ public double asDouble(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaDoubleNode toDoubleNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2277,7 +2277,7 @@ public String asString(@Bind("$node") Node inliningTarget, @Shared("getValue") @Cached GetInteropBehaviorValueNode getValue, @Cached CastToJavaStringNode toStringNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2302,7 +2302,7 @@ public boolean hasHashEntries(@Bind("$node") Node inliningTarget, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2328,7 +2328,7 @@ public long getHashSize( // GR-44020: make shared: @Exclusive @Cached CastToJavaLongExactNode toLongNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) throws UnsupportedMessageException { boolean mustRelease = gil.acquire(); @@ -2442,7 +2442,7 @@ public boolean isHashEntryReadable(Object key, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2468,7 +2468,7 @@ public boolean isHashEntryRemovable(Object key, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, // GR-44020: make shared: @Exclusive @Cached GilNode gil) { boolean mustRelease = gil.acquire(); @@ -2514,7 +2514,7 @@ public boolean isHashEntryModifiable(Object key, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("getBehavior") @Cached GetInteropBehaviorNode getBehavior, @Shared("getValue") @Cached GetInteropBehaviorValueNode getValue, // GR-44020: make shared: @@ -2540,7 +2540,7 @@ public boolean isHashEntryInsertable(Object key, // GR-44020: make shared: @Exclusive @Cached CastToJavaBooleanNode toBooleanNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("getBehavior") @Cached GetInteropBehaviorNode getBehavior, @Shared("getValue") @Cached GetInteropBehaviorValueNode getValue, // GR-44020: make shared: @@ -2611,7 +2611,7 @@ public byte readBufferByte(long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2627,7 +2627,7 @@ public void writeBufferByte(long byteOffset, byte value, @Bind("$node") Node inl // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2644,7 +2644,7 @@ public short readBufferShort(ByteOrder order, long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2660,7 +2660,7 @@ public void writeBufferShort(ByteOrder order, long byteOffset, short value, @Bin // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2677,7 +2677,7 @@ public int readBufferInt(ByteOrder order, long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2693,7 +2693,7 @@ public void writeBufferInt(ByteOrder order, long byteOffset, int value, @Bind("$ // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2710,7 +2710,7 @@ public long readBufferLong(ByteOrder order, long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2726,7 +2726,7 @@ public void writeBufferLong(ByteOrder order, long byteOffset, long value, @Bind( // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2743,7 +2743,7 @@ public float readBufferFloat(ByteOrder order, long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2760,7 +2760,7 @@ public void writeBufferFloat(ByteOrder order, long byteOffset, float value, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2777,7 +2777,7 @@ public double readBufferDouble(ByteOrder order, long byteOffset, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2794,7 +2794,7 @@ public void writeBufferDouble(ByteOrder order, long byteOffset, double value, // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { int offset = toIntNode.executeWithThrow(inliningTarget, byteOffset, raiseNode, PythonBuiltinClassType.OverflowError); @@ -2811,7 +2811,7 @@ public void readBuffer(long byteOffset, byte[] destination, int destinationOffse // GR-44020: make shared: @Exclusive @Cached CastToJavaIntExactNode toIntNode, // GR-44020: make shared: - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Shared("bufferLib") @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) throws UnsupportedMessageException, InvalidBufferOffsetException { if (bufferLib.isBuffer(this)) { if (length < 0 || (destination.length - destinationOffset > length)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index 0710f48b4d..24deb2c7e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -108,7 +108,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.builtins.ListNodes; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; @@ -189,21 +188,21 @@ Object concat(PArray left, PArray right, return newArray; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, MemoryError); + throw PRaiseNode.raiseStatic(this, MemoryError); } } @Specialization(guards = "left.getFormat() != right.getFormat()") @SuppressWarnings("unused") static Object error(PArray left, PArray right, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } @Fallback static Object error(@SuppressWarnings("unused") Object left, Object right, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CAN_ONLY_APPEND_ARRAY_TO_ARRAY, right); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_APPEND_ARRAY_TO_ARRAY, right); } } @@ -219,8 +218,8 @@ static Object concat(VirtualFrame frame, PArray left, PArray right, @Fallback static Object error(@SuppressWarnings("unused") Object left, Object right, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CAN_ONLY_EXTEND_ARRAY_WITH_ARRAY, right); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_EXTEND_ARRAY_WITH_ARRAY, right); } } @@ -250,7 +249,7 @@ static PArray concat(PArray self, int valueIn, return newArray; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -270,7 +269,7 @@ static Object concat(PArray self, int value, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Cached ArrayNodes.SetLengthNode setLengthNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int newLength = Math.max(PythonUtils.multiplyExact(self.getLength(), value), 0); if (newLength != self.getLength()) { @@ -285,7 +284,7 @@ static Object concat(PArray self, int value, return self; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -359,8 +358,8 @@ static Object eq(PArray left, Object right, ComparisonOp op) { @Specialization(guards = "!isArray(left)") @SuppressWarnings("unused") static Object error(Object left, Object right, ComparisonOp op, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_ARRAY + "." + J_ARRAY, left); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_ARRAY + "." + J_ARRAY, left); } } @@ -438,8 +437,8 @@ static Object cmp(PArray left, Object right, ComparisonOp op, BinaryComparisonNo @Specialization(guards = "!isArray(left)") @SuppressWarnings("unused") static Object error(Object left, Object right, ComparisonOp op, BinaryComparisonNode compareNode, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_ARRAY + "." + J_ARRAY, left); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_ARRAY + "." + J_ARRAY, left); } } @@ -562,12 +561,12 @@ abstract static class SqItemNode extends SqItemBuiltinNode { @Specialization static Object doIt(PArray self, int index, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached ArrayNodes.GetValueNode getValueNode) { return getItem(inliningTarget, self, index, raiseNode, getValueNode); } - private static Object getItem(Node inliningTarget, PArray self, int index, PRaiseNode.Lazy raiseNode, GetValueNode getValueNode) { + private static Object getItem(Node inliningTarget, PArray self, int index, PRaiseNode raiseNode, GetValueNode getValueNode) { checkBounds(inliningTarget, raiseNode, ErrorMessages.ARRAY_OUT_OF_BOUNDS, index, self.getLength()); return getValueNode.execute(inliningTarget, self, index); } @@ -580,7 +579,7 @@ abstract static class MpSubscriptNode extends MpSubscriptBuiltinNode { static Object doIndex(VirtualFrame frame, PArray self, Object idx, @Bind("this") Node inliningTarget, @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyNumberAsSizeNode numberAsSizeNode, @Exclusive @Cached InlinedConditionProfile negativeIndexProfile, @Cached ArrayNodes.GetValueNode getValueNode) { @@ -625,8 +624,8 @@ static Object doSlice(PArray self, PSlice slice, } @InliningCutoff - private static PException raiseNonIntIndex(Node inliningTarget, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARRAY_INDICES_MUST_BE_INTS); + private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARRAY_INDICES_MUST_BE_INTS); } } @@ -638,7 +637,7 @@ abstract static class SetItemNode extends SqAssItemBuiltinNode { static void setitem(VirtualFrame frame, PArray self, int index, Object value, @Bind("this") Node inliningTarget, @Cached ArrayNodes.PutValueNode putValueNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkBounds(inliningTarget, raiseNode, ErrorMessages.ARRAY_ASSIGN_OUT_OF_BOUNDS, index, self.getLength()); putValueNode.execute(frame, inliningTarget, self, index, value); } @@ -647,7 +646,7 @@ static void setitem(VirtualFrame frame, PArray self, int index, Object value, static void delitem(PArray self, int index, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, @Cached DeleteArraySliceNode deleteSliceNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkBounds(inliningTarget, raiseNode, ErrorMessages.ARRAY_ASSIGN_OUT_OF_BOUNDS, index, self.getLength()); self.checkCanResize(inliningTarget, raiseNode); deleteSliceNode.execute(inliningTarget, self, index, 1); @@ -674,7 +673,7 @@ static void delitem(VirtualFrame frame, PArray self, Object idx, @SuppressWarnin @Shared @Cached PyNumberIndexNode indexNode, @Shared @Cached("forArrayAssign()") NormalizeIndexNode normalizeIndexNode, @Shared @Cached DeleteArraySliceNode deleteSliceNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); int index = normalizeIndexNode.execute(indexNode.execute(frame, inliningTarget, idx), self.getLength()); deleteSliceNode.execute(inliningTarget, self, index, 1); @@ -701,7 +700,7 @@ static void setitem(PArray self, PSlice slice, Object other, @Shared @Cached DeleteArraySliceNode deleteSliceNode, @Cached ArrayNodes.ShiftNode shiftNode, @Cached ArrayNodes.SetLengthNode setLengthNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int length = self.getLength(); PSlice.SliceInfo sliceInfo = adjustIndices.execute(inliningTarget, length, sliceUnpack.execute(inliningTarget, slice)); int start = sliceInfo.start; @@ -715,7 +714,7 @@ static void setitem(PArray self, PSlice slice, Object other, if (other instanceof PArray otherArray) { hasOtherProfile.enter(inliningTarget); if (self.getFormat() != otherArray.getFormat()) { - throw raiseNode.get(inliningTarget).raise(TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, BAD_ARG_TYPE_FOR_BUILTIN_OP); } sourceBuffer = otherArray.getBuffer(); needed = otherArray.getLength(); @@ -731,7 +730,7 @@ static void setitem(PArray self, PSlice slice, Object other, needed = 0; } else { otherTypeErrorProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_ASSIGN_ARRAY, other); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_ASSIGN_ARRAY, other); } if (step == 1) { simpleStepProfile.enter(inliningTarget); @@ -772,7 +771,7 @@ static void setitem(PArray self, PSlice slice, Object other, } } else { wrongLengthProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ATTEMPT_ASSIGN_ARRAY_OF_SIZE, needed, sliceLength); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ATTEMPT_ASSIGN_ARRAY_OF_SIZE, needed, sliceLength); } } } @@ -883,7 +882,7 @@ static Object bufferinfo(PArray self, nativePointer = lib.asPointer(nativePointer); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } return PFactory.createTuple(language, new Object[]{nativePointer, self.getLength()}); @@ -899,7 +898,7 @@ static Object append(VirtualFrame frame, PArray self, Object value, @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Cached ArrayNodes.SetLengthNode setLengthNode, @Cached ArrayNodes.PutValueNode putValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int index = self.getLength(); int newLength = PythonUtils.addExact(index, 1); @@ -910,7 +909,7 @@ static Object append(VirtualFrame frame, PArray self, Object value, return PNone.NONE; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } } @@ -924,7 +923,7 @@ static Object extend(PArray self, PArray value, @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Exclusive @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Exclusive @Cached ArrayNodes.SetLengthNode setLengthNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { int newLength = PythonUtils.addExact(self.getLength(), value.getLength()); if (newLength != self.getLength()) { @@ -937,7 +936,7 @@ static Object extend(PArray self, PArray value, return PNone.NONE; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @@ -949,7 +948,7 @@ static Object extend(VirtualFrame frame, PArray self, PSequence value, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, @Exclusive @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Exclusive @Cached ArrayNodes.SetLengthNode setLengthNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, value); int storageLength = storage.length(); try { @@ -960,7 +959,7 @@ static Object extend(VirtualFrame frame, PArray self, PSequence value, } } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } int length = self.getLength(); for (int i = 0; i < storageLength; i++) { @@ -982,7 +981,7 @@ static Object extend(VirtualFrame frame, PArray self, Object value, @Cached IsBuiltinObjectProfile errorProfile, @Exclusive @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Exclusive @Cached ArrayNodes.SetLengthNode setLengthNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object iter = getIter.execute(frame, inliningTarget, value); int length = self.getLength(); while (true) { @@ -1001,7 +1000,7 @@ static Object extend(VirtualFrame frame, PArray self, Object value, ensureCapacityNode.execute(inliningTarget, self, length); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } putValueNode.execute(frame, inliningTarget, self, length - 1, nextValue); setLengthNode.execute(inliningTarget, self, length); @@ -1013,10 +1012,10 @@ static Object extend(VirtualFrame frame, PArray self, Object value, @Specialization(guards = "self.getFormat() != value.getFormat()") @SuppressWarnings("unused") static Object error(PArray self, PArray value, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // CPython allows extending an array with an arbitrary iterable. Except a differently // formatted array. Weird - throw raiseNode.raise(TypeError, ErrorMessages.CAN_ONLY_EXTEND_WITH_ARRAY_OF_SAME_KIND); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_EXTEND_WITH_ARRAY_OF_SAME_KIND); } } @@ -1031,7 +1030,7 @@ static Object insert(VirtualFrame frame, PArray self, int inputIndex, Object val @Cached ArrayNodes.CheckValueNode checkValueNode, @Cached ArrayNodes.PutValueNode putValueNode, @Cached ArrayNodes.ShiftNode shiftNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int index = normalizeIndexNode.execute(inputIndex, self.getLength()); if (index > self.getLength()) { index = self.getLength(); @@ -1062,7 +1061,7 @@ static Object remove(VirtualFrame frame, PArray self, Object value, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached ArrayNodes.GetValueNode getValueNode, @Cached DeleteArraySliceNode deleteSliceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { for (int i = 0; i < self.getLength(); i++) { Object item = getValueNode.execute(inliningTarget, self, i); if (eqNode.compare(frame, inliningTarget, item, value)) { @@ -1071,7 +1070,7 @@ static Object remove(VirtualFrame frame, PArray self, Object value, return PNone.NONE; } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ARRAY_REMOVE_X_NOT_IN_ARRAY); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ARRAY_REMOVE_X_NOT_IN_ARRAY); } } @@ -1085,9 +1084,9 @@ static Object pop(PArray self, int inputIndex, @Cached("forPop()") NormalizeIndexNode normalizeIndexNode, @Cached ArrayNodes.GetValueNode getValueNode, @Cached DeleteArraySliceNode deleteSliceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getLength() == 0) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.POP_FROM_EMPTY_ARRAY); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.POP_FROM_EMPTY_ARRAY); } int index = normalizeIndexNode.execute(inputIndex, self.getLength()); Object value = getValueNode.execute(inliningTarget, self, index); @@ -1118,14 +1117,14 @@ static Object frombytes(VirtualFrame frame, PArray self, Object buffer, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Cached ArrayNodes.SetLengthNode setLengthNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int itemShift = self.getItemSizeShift(); int oldSize = self.getLength(); try { int bufferLength = bufferLib.getBufferLength(buffer); if (!PythonUtils.isDivisible(bufferLength, itemShift)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BYTES_ARRAY_NOT_MULTIPLE_OF_ARRAY_SIZE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BYTES_ARRAY_NOT_MULTIPLE_OF_ARRAY_SIZE); } int newLength = PythonUtils.addExact(oldSize, bufferLength >> itemShift); self.checkCanResize(inliningTarget, raiseNode); @@ -1134,7 +1133,7 @@ static Object frombytes(VirtualFrame frame, PArray self, Object buffer, bufferLib.readIntoBuffer(buffer, 0, self.getBuffer(), oldSize << itemShift, bufferLength, bufferLib); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } return PNone.NONE; } finally { @@ -1159,9 +1158,9 @@ static Object fromfile(VirtualFrame frame, PArray self, Object file, int n, @Cached PyObjectSizeNode sizeNode, @Cached InlinedConditionProfile nNegativeProfile, @Cached FromBytesNode fromBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (nNegativeProfile.profile(inliningTarget, n < 0)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEGATIVE_COUNT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEGATIVE_COUNT); } int nbytes = n << self.getItemSizeShift(); Object readResult = callMethod.execute(frame, inliningTarget, file, T_READ, nbytes); @@ -1171,10 +1170,10 @@ static Object fromfile(VirtualFrame frame, PArray self, Object file, int n, // It would make more sense to check this before the frombytes call, but CPython // does it this way if (readLength != nbytes) { - throw raiseNode.get(inliningTarget).raise(EOFError, ErrorMessages.READ_DIDNT_RETURN_ENOUGH_BYTES); + throw raiseNode.raise(inliningTarget, EOFError, ErrorMessages.READ_DIDNT_RETURN_ENOUGH_BYTES); } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.READ_DIDNT_RETURN_BYTES); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.READ_DIDNT_RETURN_BYTES); } return PNone.NONE; } @@ -1196,7 +1195,7 @@ static Object fromlist(VirtualFrame frame, PArray self, PList list, @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode, @Cached ArrayNodes.SetLengthNode setLengthNode, @Cached ArrayNodes.PutValueNode putValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, list); int length = storage.length(); @@ -1210,15 +1209,15 @@ static Object fromlist(VirtualFrame frame, PArray self, PList list, return PNone.NONE; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @Fallback @SuppressWarnings("unused") static Object error(Object self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ARG_MUST_BE_LIST); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ARG_MUST_BE_LIST); } } @@ -1236,7 +1235,7 @@ static Object fromunicode(VirtualFrame frame, PArray self, TruffleString str, @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, @Cached TruffleStringIterator.NextNode nextNode, @Cached TruffleString.FromCodePointNode fromCodePointNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int length = codePointLengthNode.execute(str, TS_ENCODING); int newLength = PythonUtils.addExact(self.getLength(), length); @@ -1252,15 +1251,15 @@ static Object fromunicode(VirtualFrame frame, PArray self, TruffleString str, return PNone.NONE; } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } @Fallback @SuppressWarnings("unused") static Object error(Object self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.FROMUNICODE_ARG_MUST_BE_STR_NOT_P, arg); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.FROMUNICODE_ARG_MUST_BE_STR_NOT_P, arg); } @Override @@ -1302,9 +1301,9 @@ static TruffleString tounicode(PArray self, @Cached ArrayNodes.GetValueNode getValueNode, @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (formatProfile.profile(inliningTarget, self.getFormat() != BufferFormat.UNICODE)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MAY_ONLY_BE_CALLED_ON_UNICODE_TYPE_ARRAYS); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MAY_ONLY_BE_CALLED_ON_UNICODE_TYPE_ARRAYS); } TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); int length = self.getLength(); @@ -1400,7 +1399,7 @@ static int index(VirtualFrame frame, PArray self, Object value, int start, int s @Bind("this") Node inliningTarget, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached ArrayNodes.GetValueNode getValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int length = self.getLength(); if (start < 0) { start += length; @@ -1416,7 +1415,7 @@ static int index(VirtualFrame frame, PArray self, Object value, int start, int s return i; } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ARRAY_INDEX_X_NOT_IN_ARRAY); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ARRAY_INDEX_X_NOT_IN_ARRAY); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayNodes.java index 5cbe44a9d6..f4570c743e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -112,7 +112,7 @@ static void ensure(Node inliningTarget, PArray array, int newCapacity, ensureCapacityNode.execute(inliningTarget, array.getSequenceStorage(), internalCapacity); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.MemoryError); + PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); } } } @@ -130,7 +130,7 @@ static void set(Node inliningTarget, PArray array, int newLength, setLenNode.execute(inliningTarget, array.getSequenceStorage(), internalLength); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.MemoryError); + PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); } } } @@ -170,7 +170,7 @@ static void shift(Node inliningTarget, PArray array, int from, int by, setLengthNode.execute(inliningTarget, array, newLength); } catch (OverflowException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.MemoryError); + PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java index 87c31b135b..7e9ca190ec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/PArray.java @@ -140,9 +140,9 @@ public AtomicLong getExports() { return exports; } - public void checkCanResize(Node inliningTarget, PRaiseNode.Lazy raiseNode) { + public void checkCanResize(Node inliningTarget, PRaiseNode raiseNode) { if (exports.get() != 0) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.EXPORTS_CANNOT_RESIZE); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.EXPORTS_CANNOT_RESIZE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java index db641813be..52ee2d072d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -107,16 +107,15 @@ public Object send(VirtualFrame frame, PAsyncGenASend self, Object sent, @Cached CommonGeneratorBuiltins.SendNode send, @Cached IsBuiltinObjectProfile isStopIteration, @Cached IsBuiltinObjectProfile isGenExit, - @Cached IsBuiltinObjectExactProfile isAsyncGenWrappedValue, - @Cached PRaiseNode raiseStopIteration) { + @Cached IsBuiltinObjectExactProfile isAsyncGenWrappedValue) { Object result; if (self.getState() == AwaitableState.CLOSED) { - throw raiseReuse.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ASEND); + throw raiseReuse.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ASEND); } if (self.getState() == AwaitableState.INIT) { if (self.receiver.isRunningAsync()) { - throw raiseAlreadyRunning.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.AGEN_ALREADY_RUNNING); + throw raiseAlreadyRunning.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.AGEN_ALREADY_RUNNING); } if (sent == null || sent == PNone.NONE) { sent = self.message; @@ -131,7 +130,7 @@ public Object send(VirtualFrame frame, PAsyncGenASend self, Object sent, throw handleAGError(self.receiver, e, inliningTarget, isStopIteration, isGenExit); } try { - return unwrapAGYield(self.receiver, result, inliningTarget, isAsyncGenWrappedValue, raiseStopIteration); + return unwrapAGYield(self.receiver, result, inliningTarget, isAsyncGenWrappedValue); } catch (PException e) { self.setState(AwaitableState.CLOSED); throw e; @@ -159,12 +158,11 @@ static PException handleAGError(PAsyncGen self, PException exception, static Object unwrapAGYield(PAsyncGen self, Object result, Node inliningTarget, - IsBuiltinObjectExactProfile isAGWrappedValue, - PRaiseNode raise) { + IsBuiltinObjectExactProfile isAGWrappedValue) { if (isAGWrappedValue.profileObject(inliningTarget, result, PythonBuiltinClassType.PAsyncGenAWrappedValue)) { self.setRunningAsync(false); Object wrapped = ((PAsyncGenWrappedValue) result).getWrapped(); - throw raise.raise(PythonBuiltinClassType.StopIteration, new Object[]{wrapped}); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration, new Object[]{wrapped}); } return result; } @@ -181,12 +179,11 @@ public Object doThrow(VirtualFrame frame, PAsyncGenASend self, Object arg1, Obje @Cached CommonGeneratorBuiltins.ThrowNode throwNode, @Cached IsBuiltinObjectProfile isStopIteration, @Cached IsBuiltinObjectProfile isGeneratorExit, - @Cached IsBuiltinObjectExactProfile isAGWrappedValue, - @Cached PRaiseNode raiseStopIteration) { + @Cached IsBuiltinObjectExactProfile isAGWrappedValue) { Object result; if (self.getState() == AwaitableState.CLOSED) { - throw raiseReuse.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ASEND); + throw raiseReuse.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ASEND); } try { result = throwNode.execute(frame, self.receiver, arg1, arg2, arg3); @@ -195,7 +192,7 @@ public Object doThrow(VirtualFrame frame, PAsyncGenASend self, Object arg1, Obje throw handleAGError(self.receiver, e, inliningTarget, isStopIteration, isGeneratorExit); } try { - return unwrapAGYield(self.receiver, result, inliningTarget, isAGWrappedValue, raiseStopIteration); + return unwrapAGYield(self.receiver, result, inliningTarget, isAGWrappedValue); } catch (PException e) { self.setState(AwaitableState.CLOSED); throw e; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java index 5d22de9a24..a26f24fb45 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -122,14 +122,13 @@ public Object send(VirtualFrame frame, PAsyncGenAThrow self, Object sent, @Cached IsBuiltinObjectExactProfile isAGWrappedValue, @Cached IsBuiltinObjectProfile isStopAsyncIter, @Cached IsBuiltinObjectProfile isGeneratorExit, - @Cached PRaiseNode raiseIgnoreExit, @Cached PRaiseNode raiseStopIteration, @Cached CommonGeneratorBuiltins.SendNode sendNode) { PAsyncGen gen = self.receiver; Object retval; if (self.getState() == AwaitableState.CLOSED) { - throw raiseReuse.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ATHROW); + throw raiseReuse.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ATHROW); } // CPython checks for gi_frame_state here, but we don't have gi_frame_state. @@ -137,24 +136,24 @@ public Object send(VirtualFrame frame, PAsyncGenAThrow self, Object sent, // https://github.com/python/cpython/blob/main/Objects/genobject.c#L2082-L2086 if (self.receiver.isFinished()) { self.setState(AwaitableState.CLOSED); - throw raiseStopIteration.raise(PythonBuiltinClassType.StopIteration); + throw raiseStopIteration.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } if (self.getState() == AwaitableState.INIT) { if (gen.isRunningAsync()) { self.setState(AwaitableState.CLOSED); - throw raiseAlreadyRunning.raise(PythonBuiltinClassType.RuntimeError); // todo - // error - // msg + throw raiseAlreadyRunning.raise(inliningTarget, PythonBuiltinClassType.RuntimeError); // todo + // error + // msg } if (gen.isClosed()) { self.setState(AwaitableState.CLOSED); - throw raiseStopAsyncIteraion.raise(PythonBuiltinClassType.StopAsyncIteration); + throw raiseStopAsyncIteraion.raise(inliningTarget, PythonBuiltinClassType.StopAsyncIteration); } if (sent != PNone.NONE) { - throw raiseNonNodeToNewCoro.raise(PythonBuiltinClassType.RuntimeError, SEND_NON_NONE_TO_UNSTARTED_GENERATOR); + throw raiseNonNodeToNewCoro.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, SEND_NON_NONE_TO_UNSTARTED_GENERATOR); } self.setState(AwaitableState.ITER); @@ -167,10 +166,10 @@ public Object send(VirtualFrame frame, PAsyncGenAThrow self, Object sent, try { retval = throwNode.execute(frame, gen, PythonBuiltinClassType.GeneratorExit, PNone.NO_VALUE, PNone.NO_VALUE); } catch (PException e) { - throw checkError(self, gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit, raiseStopIteration); + throw checkError(self, gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit); } if (isAGWrappedValue.profileObject(inliningTarget, retval, PythonBuiltinClassType.PAsyncGenAWrappedValue)) { - throw yieldClose(self, gen, raiseIgnoreExit); + throw yieldClose(inliningTarget, self, gen); } } else { // athrow mode @@ -178,9 +177,9 @@ public Object send(VirtualFrame frame, PAsyncGenAThrow self, Object sent, retval = throwNode.execute(frame, gen, self.arg1, self.arg2, self.arg3); } catch (PException e) { PException exception = AsyncGenSendBuiltins.handleAGError(gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit); - throw checkError(self, gen, exception, inliningTarget, isStopAsyncIter, isGeneratorExit, raiseStopIteration); + throw checkError(self, gen, exception, inliningTarget, isStopAsyncIter, isGeneratorExit); } - return AsyncGenSendBuiltins.unwrapAGYield(gen, retval, inliningTarget, isAGWrappedValue, raiseStopIteration); + return AsyncGenSendBuiltins.unwrapAGYield(gen, retval, inliningTarget, isAGWrappedValue); } } @@ -192,38 +191,36 @@ public Object send(VirtualFrame frame, PAsyncGenAThrow self, Object sent, throw AsyncGenSendBuiltins.handleAGError(gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit); } else { // aclose - throw checkError(self, gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit, raiseStopIteration); + throw checkError(self, gen, e, inliningTarget, isStopAsyncIter, isGeneratorExit); } } if (self.arg1 != null) { - return AsyncGenSendBuiltins.unwrapAGYield(gen, retval, inliningTarget, isAGWrappedValue, raiseStopIteration); + return AsyncGenSendBuiltins.unwrapAGYield(gen, retval, inliningTarget, isAGWrappedValue); } else { // aclose if (isAGWrappedValue.profileObject(inliningTarget, retval, PythonBuiltinClassType.PAsyncGenAWrappedValue)) { - throw yieldClose(self, gen, raiseIgnoreExit); + throw yieldClose(inliningTarget, self, gen); } else { return retval; } } } - static PException yieldClose(PAsyncGenAThrow athrow, PAsyncGen gen, - PRaiseNode raiseIgnoreExit) { + static PException yieldClose(Node inliningTarget, PAsyncGenAThrow athrow, PAsyncGen gen) { gen.setRunningAsync(false); athrow.setState(AwaitableState.CLOSED); - return raiseIgnoreExit.raise(PythonBuiltinClassType.RuntimeError, GENERATOR_IGNORED_EXIT); + return PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.RuntimeError, GENERATOR_IGNORED_EXIT); } static PException checkError(PAsyncGenAThrow athrow, PAsyncGen gen, PException exception, Node inliningTarget, IsBuiltinObjectProfile isStopAsyncIter, - IsBuiltinObjectProfile isGenExit, - PRaiseNode raiseStopIteration) { + IsBuiltinObjectProfile isGenExit) { gen.setRunningAsync(false); athrow.setState(AwaitableState.CLOSED); if (athrow.arg1 == null && (isStopAsyncIter.profileException(inliningTarget, exception, PythonBuiltinClassType.StopAsyncIteration) || isGenExit.profileException(inliningTarget, exception, PythonBuiltinClassType.GeneratorExit))) { - return raiseStopIteration.raise(PythonBuiltinClassType.StopIteration); + return PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } return exception; } @@ -246,13 +243,11 @@ public Object doThrow(VirtualFrame frame, PAsyncGenAThrow self, Object arg1, Obj @Cached CommonGeneratorBuiltins.ThrowNode throwNode, @Cached IsBuiltinObjectProfile isStopAsyncIteration, @Cached IsBuiltinObjectProfile isGeneratorExit, - @Cached IsBuiltinObjectExactProfile isAGWrappedValue, - @Cached PRaiseNode raiseStopIteration, - @Cached PRaiseNode raiseIgnoredExit) { + @Cached IsBuiltinObjectExactProfile isAGWrappedValue) { Object retval; if (self.getState() == AwaitableState.CLOSED) { - throw raiseReuse.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ATHROW); + throw raiseReuse.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_ATHROW); } try { @@ -264,16 +259,16 @@ public Object doThrow(VirtualFrame frame, PAsyncGenAThrow self, Object arg1, Obj // aclose() if (isStopAsyncIteration.profileException(inliningTarget, e, PythonBuiltinClassType.StopAsyncIteration) || isGeneratorExit.profileException(inliningTarget, e, PythonBuiltinClassType.GeneratorExit)) { - throw raiseStopIteration.raise(PythonBuiltinClassType.StopIteration); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } throw e; } } if (self.arg1 != null) { - return AsyncGenSendBuiltins.unwrapAGYield(self.receiver, retval, inliningTarget, isAGWrappedValue, raiseStopIteration); + return AsyncGenSendBuiltins.unwrapAGYield(self.receiver, retval, inliningTarget, isAGWrappedValue); } else { if (isAGWrappedValue.profileObject(inliningTarget, retval, PythonBuiltinClassType.PAsyncGenAWrappedValue)) { - throw Send.yieldClose(self, self.receiver, raiseIgnoredExit); + throw Send.yieldClose(inliningTarget, self, self.receiver); } return retval; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java index f48c021293..9b98d618b4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -69,24 +69,24 @@ public abstract class GetAwaitableNode extends Node { @Specialization public static Object doGenerator(PGenerator generator, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raise, - @Exclusive @Cached PRaiseNode.Lazy raiseReusedCoro) { + @Exclusive @Cached PRaiseNode raise, + @Exclusive @Cached PRaiseNode raiseReusedCoro) { if (generator.isCoroutine()) { if (generator.getYieldFrom() != null) { - throw raiseReusedCoro.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CORO_ALREADY_AWAITED); + throw raiseReusedCoro.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CORO_ALREADY_AWAITED); } else { return generator; } } else { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, "generator"); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, "generator"); } } @Specialization public static Object doGeneric(Frame frame, Object awaitable, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNoAwait, - @Exclusive @Cached PRaiseNode.Lazy raiseNotIter, + @Exclusive @Cached PRaiseNode raiseNoAwait, + @Exclusive @Cached PRaiseNode raiseNotIter, @Cached(parameters = "Await") LookupSpecialMethodSlotNode findAwait, @Cached TypeNodes.GetNameNode getName, @Cached GetClassNode getAwaitableType, @@ -96,7 +96,7 @@ public static Object doGeneric(Frame frame, Object awaitable, Object type = getAwaitableType.execute(inliningTarget, awaitable); Object getter = findAwait.execute(frame, type, awaitable); if (getter == PNone.NO_VALUE) { - throw raiseNoAwait.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, getName.execute(inliningTarget, type)); + throw raiseNoAwait.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_BE_USED_AWAIT, getName.execute(inliningTarget, type)); } Object iterator = callAwait.executeObject(getter, awaitable); if (iterCheck.execute(inliningTarget, iterator)) { @@ -104,9 +104,9 @@ public static Object doGeneric(Frame frame, Object awaitable, } Object itType = getIteratorType.execute(inliningTarget, iterator); if (itType == PythonBuiltinClassType.PCoroutine) { - throw raiseNotIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_COROUTINE); + throw raiseNotIter.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_COROUTINE); } else { - throw raiseNotIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_NON_ITER, getName.execute(inliningTarget, itType)); + throw raiseNotIter.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.AWAIT_RETURN_NON_ITER, getName.execute(inliningTarget, itType)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/buffer/PythonBufferAcquireLibrary.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/buffer/PythonBufferAcquireLibrary.java index 3c1edf8028..2aa92be08f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/buffer/PythonBufferAcquireLibrary.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/buffer/PythonBufferAcquireLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -202,7 +202,7 @@ public final Object acquireWritableWithTypeError(Object receiver, String callerN try { return acquireWritable(receiver); } catch (PException e) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_READ_WRITE_BYTES_LIKE_NOT_P, callerName, receiver); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_READ_WRITE_BYTES_LIKE_NOT_P, callerName, receiver); } finally { IndirectCallContext.exit(frame, indirectCallData, savedState); } @@ -225,7 +225,7 @@ public final Object acquireWritableWithTypeError(Object receiver, String callerN */ @Abstract public Object acquire(Object receiver, int flags) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, receiver); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.BYTESLIKE_OBJ_REQUIRED, receiver); } /** diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index a50c5fc9f6..c48cd23418 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -185,14 +185,14 @@ static PNone doInit(VirtualFrame frame, PByteArray self, Object source, Object e @Specialization(guards = "isNone(self)") static PNone doInit(@SuppressWarnings("unused") PByteArray self, Object source, @SuppressWarnings("unused") Object encoding, @SuppressWarnings("unused") Object errors, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_CONVERT_P_OBJ_TO_S, source, "bytearray"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_CONVERT_P_OBJ_TO_S, source, "bytearray"); } @Specialization(guards = "!isBytes(self)") static PNone doInit(Object self, @SuppressWarnings("unused") Object source, @SuppressWarnings("unused") Object encoding, @SuppressWarnings("unused") Object errors, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___INIT__, "bytearray", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___INIT__, "bytearray", self); } } @@ -217,7 +217,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile validProfile, @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached BytesNodes.GetBytesStorage getBytesStorage, @Cached SequenceStorageMpSubscriptNode subscriptNode) { if (!validProfile.profile(inliningTarget, SequenceStorageMpSubscriptNode.isValidIndex(inliningTarget, idx, indexCheckNode))) { @@ -228,8 +228,8 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, } @InliningCutoff - private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object index) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "bytearray", index); + private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode raiseNode, Object index) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "bytearray", index); } } @@ -267,13 +267,13 @@ static void set(VirtualFrame frame, PByteArray self, Object indexObj, Object val @Cached PyNumberAsSizeNode asSizeNode, @Cached("forBytearray()") NormalizeIndexNode normalizeIndexNode, @Cached SequenceStorageNodes.SetItemScalarNode setItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, indexObj)) { int index = asSizeNode.executeExact(frame, inliningTarget, indexObj); index = normalizeIndexNode.execute(index, self.getSequenceStorage().length()); setItemNode.execute(inliningTarget, self.getSequenceStorage(), index, value); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "bytearray", indexObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "bytearray", indexObj); } } @@ -286,7 +286,7 @@ static void doSliceSequence(VirtualFrame frame, PByteArray self, PSlice slice, P @Cached @Shared SliceNodes.CoerceToIntSlice sliceCast, @Cached @Shared SliceNodes.SliceUnpack unpack, @Cached @Shared SliceNodes.AdjustIndices adjustIndices, - @Cached @Shared PRaiseNode.Lazy raiseNode) { + @Cached @Shared PRaiseNode raiseNode) { SequenceStorage storage = self.getSequenceStorage(); int otherLen = getSequenceStorageNode.execute(inliningTarget, value).length(); SliceInfo unadjusted = unpack.execute(inliningTarget, sliceCast.execute(inliningTarget, slice)); @@ -310,7 +310,7 @@ static void doSliceBuffer(VirtualFrame frame, PByteArray self, PSlice slice, Obj @Cached @Shared SliceNodes.CoerceToIntSlice sliceCast, @Cached @Shared SliceNodes.SliceUnpack unpack, @Cached @Shared SliceNodes.AdjustIndices adjustIndices, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(value, frame, indirectCallData); try { // TODO avoid copying if possible. Note that it is possible that value is self @@ -331,7 +331,7 @@ static void doSliceGeneric(VirtualFrame frame, PByteArray self, PSlice slice, Ob @Cached @Shared SliceNodes.SliceUnpack unpack, @Cached @Shared SliceNodes.AdjustIndices adjustIndices, @Cached ListNodes.ConstructListNode constructListNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PList values = constructListNode.execute(frame, value); doSliceSequence(frame, self, slice, values, inliningTarget, differentLenProfile, getSequenceStorageNode, setItemSliceNode, sliceCast, unpack, adjustIndices, raiseNode); } @@ -340,7 +340,7 @@ static void doSliceGeneric(VirtualFrame frame, PByteArray self, PSlice slice, Ob static void doDelete(VirtualFrame frame, PByteArray self, Object key, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, @Cached SequenceStorageNodes.DeleteNode deleteNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); deleteNode.execute(frame, self.getSequenceStorage(), key); } @@ -358,7 +358,7 @@ public abstract static class InsertNode extends PythonTernaryClinicBuiltinNode { static PNone insert(VirtualFrame frame, PByteArray self, int index, int value, @Bind("this") Node inliningTarget, @Shared @Cached CastToByteNode toByteNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); byte v = toByteNode.execute(frame, value); ByteSequenceStorage target = (ByteSequenceStorage) self.getSequenceStorage(); @@ -372,7 +372,7 @@ static PNone insert(VirtualFrame frame, PByteArray self, int index, int value, @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Cached SequenceStorageNodes.InsertItemNode insertItemNode, @Shared @Cached CastToByteNode toByteNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); byte v = toByteNode.execute(frame, value); SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, self); @@ -433,7 +433,7 @@ public abstract static class IAddNode extends PythonBinaryBuiltinNode { static PByteArray add(PByteArray self, PBytesLike other, @Bind("this") Node inliningTarget, @Cached @Shared SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage()); updateSequenceStorage(self, res); @@ -448,12 +448,12 @@ static PByteArray add(VirtualFrame frame, PByteArray self, Object other, @CachedLibrary("other") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached @Shared SequenceStorageNodes.ConcatNode concatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); } try { self.checkCanResize(inliningTarget, raiseNode); @@ -481,7 +481,7 @@ public abstract static class IMulNode extends PythonBinaryBuiltinNode { static Object mul(VirtualFrame frame, PByteArray self, int times, @Bind("this") Node inliningTarget, @Cached @Shared SequenceStorageNodes.RepeatNode repeatNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), times); self.setSequenceStorage(res); @@ -493,7 +493,7 @@ static Object mul(VirtualFrame frame, PByteArray self, Object times, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, @Cached @Shared SequenceStorageNodes.RepeatNode repeatNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), asSizeNode.executeExact(frame, inliningTarget, times)); self.setSequenceStorage(res); @@ -503,8 +503,8 @@ static Object mul(VirtualFrame frame, PByteArray self, Object times, @SuppressWarnings("unused") @Fallback static Object mul(Object self, Object other, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, other); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, other); } } @@ -518,7 +518,7 @@ static PNone remove(VirtualFrame frame, PByteArray self, Object value, @Cached("createCast()") CastToByteNode cast, @Cached SequenceStorageNodes.GetInternalByteArrayNode getBytes, @Cached SequenceStorageNodes.DeleteNode deleteNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage storage = self.getSequenceStorage(); int len = storage.length(); @@ -527,22 +527,22 @@ static PNone remove(VirtualFrame frame, PByteArray self, Object value, deleteNode.execute(frame, storage, pos); return PNone.NONE; } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NOT_IN_BYTEARRAY); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_IN_BYTEARRAY); } @NeverDefault static CastToByteNode createCast() { - return CastToByteNode.create((val, raiseNode) -> { - throw raiseNode.raise(ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); - }, (val, raiseNode) -> { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "bytes"); + return CastToByteNode.create((node, val) -> { + throw PRaiseNode.raiseStatic(node, ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + }, (node, val) -> { + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "bytes"); }); } @Fallback static Object doError(@SuppressWarnings("unused") Object self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); } } @@ -555,7 +555,7 @@ static Object popLast(VirtualFrame frame, PByteArray self, @SuppressWarnings("un @Bind("this") Node inliningTarget, @Shared("getItem") @Cached SequenceStorageNodes.GetItemNode getItemNode, @Shared @Cached("createDelete()") SequenceStorageNodes.DeleteNode deleteNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage store = self.getSequenceStorage(); Object ret = getItemNode.execute(store, -1); @@ -568,7 +568,7 @@ static Object doIndex(VirtualFrame frame, PByteArray self, Object idx, @Bind("this") Node inliningTarget, @Shared("getItem") @Cached SequenceStorageNodes.GetItemNode getItemNode, @Shared @Cached("createDelete()") SequenceStorageNodes.DeleteNode deleteNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage store = self.getSequenceStorage(); Object ret = getItemNode.execute(frame, store, idx); @@ -578,8 +578,8 @@ static Object doIndex(VirtualFrame frame, PByteArray self, Object idx, @Fallback static Object doError(@SuppressWarnings("unused") Object self, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); } @NeverDefault @@ -602,7 +602,7 @@ static PNone append(VirtualFrame frame, PByteArray byteArray, Object arg, @Bind("this") Node inliningTarget, @Cached("createCast()") CastToByteNode toByteNode, @Cached SequenceStorageNodes.AppendNode appendNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byteArray.checkCanResize(inliningTarget, raiseNode); appendNode.execute(inliningTarget, byteArray.getSequenceStorage(), toByteNode.execute(frame, arg), BytesNodes.BytesLikeNoGeneralizationNode.SUPPLIER); return PNone.NONE; @@ -610,10 +610,10 @@ static PNone append(VirtualFrame frame, PByteArray byteArray, Object arg, @NeverDefault static CastToByteNode createCast() { - return CastToByteNode.create((val, raiseNode) -> { - throw raiseNode.raise(ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); - }, (val, raiseNode) -> { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "bytes"); + return CastToByteNode.create((node, val) -> { + throw PRaiseNode.raiseStatic(node, ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + }, (node, val) -> { + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "bytes"); }); } } @@ -628,7 +628,7 @@ static PNone doBytes(VirtualFrame frame, PByteArray self, PBytesLike source, @Bind("this") Node inliningTarget, @Cached IteratorNodes.GetLength lenNode, @Cached("createExtend()") @Shared SequenceStorageNodes.ExtendNode extendNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); int len = lenNode.execute(frame, inliningTarget, source); extend(frame, self, source, len, extendNode); @@ -646,7 +646,7 @@ static PNone doGeneric(VirtualFrame frame, PByteArray self, Object source, @Cached BytesNodes.IterableToByteNode iterableToByteNode, @Cached IsBuiltinObjectProfile errorProfile, @Cached("createExtend()") @Shared SequenceStorageNodes.ExtendNode extendNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); byte[] b; if (bufferProfile.profile(inliningTarget, bufferAcquireLib.hasBuffer(source))) { @@ -662,7 +662,7 @@ static PNone doGeneric(VirtualFrame frame, PByteArray self, Object source, b = iterableToByteNode.execute(frame, source); } catch (PException e) { e.expect(inliningTarget, TypeError, errorProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_EXTEND_BYTEARRAY_WITH_P, source); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_EXTEND_BYTEARRAY_WITH_P, source); } } PByteArray bytes = PFactory.createByteArray(language, b); @@ -722,7 +722,7 @@ static PNone clear(VirtualFrame frame, PByteArray byteArray, @Bind("this") Node inliningTarget, @Cached SequenceStorageNodes.DeleteNode deleteNode, @Cached PySliceNew sliceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byteArray.checkCanResize(inliningTarget, raiseNode); deleteNode.execute(frame, byteArray.getSequenceStorage(), sliceNode.execute(inliningTarget, PNone.NONE, PNone.NONE, 1)); return PNone.NONE; @@ -774,7 +774,7 @@ static PByteArray translate(VirtualFrame frame, PByteArray self, Object table, O @Cached InlinedBranchProfile hasTable, @Cached InlinedBranchProfile hasDelete, @Cached BytesNodes.ToBytesNode toBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] bTable = null; if (table != PNone.NONE) { hasTable.enter(inliningTarget); @@ -899,9 +899,8 @@ static Object cmp(VirtualFrame frame, Node inliningTarget, Object self, Object o @InliningCutoff @SuppressWarnings("unused") static Object error(VirtualFrame frame, Node inliningTarget, Object self, Object other, ComparisonOp op, - @Shared @Cached PyByteArrayCheckNode check, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_BYTEARRAY, self); + @Shared @Cached PyByteArrayCheckNode check) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_BYTEARRAY, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java index f2f0b369ec..1d2117c3d0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java @@ -137,7 +137,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile validProfile, @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached BytesNodes.GetBytesStorage getBytesStorage, @Cached SequenceStorageMpSubscriptNode subscriptNode) { if (!validProfile.profile(inliningTarget, SequenceStorageMpSubscriptNode.isValidIndex(inliningTarget, idx, indexCheckNode))) { @@ -148,8 +148,8 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, } @InliningCutoff - private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object index) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "byte", index); + private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode raiseNode, Object index) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "byte", index); } } @@ -178,7 +178,7 @@ static Object translate(VirtualFrame frame, Object self, Object table, Object de @Cached InlinedBranchProfile hasDelete, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached PyBytesCheckExactNode checkExactNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] bTable = null; if (table != PNone.NONE) { hasTable.enter(inliningTarget); @@ -264,7 +264,7 @@ static Object cmp(Node inliningTarget, Object self, Object other, ComparisonOp o @SuppressWarnings("unused") @Cached PyBytesCheckNode check, @Cached BytesNodes.GetBytesStorage getBytesStorage, @Exclusive @Cached SequenceStorageNodes.GetInternalByteArrayNode getArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (check.execute(inliningTarget, self)) { if (check.execute(inliningTarget, other)) { SequenceStorage selfStorage = getBytesStorage.execute(inliningTarget, self); @@ -274,7 +274,7 @@ static Object cmp(Node inliningTarget, Object self, Object other, ComparisonOp o return PNotImplemented.NOT_IMPLEMENTED; } } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_BYTES, self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.builtinName, J_BYTES, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java index ddd6c980a9..9e4733c4d3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java @@ -198,12 +198,12 @@ public static CodingErrorAction toCodingErrorAction(TruffleString errors, Truffl return null; } - public static CodingErrorAction toCodingErrorAction(Node inliningTarget, TruffleString errors, PRaiseNode.Lazy raiseNode, TruffleString.EqualNode eqNode) { + public static CodingErrorAction toCodingErrorAction(Node inliningTarget, TruffleString errors, PRaiseNode raiseNode, TruffleString.EqualNode eqNode) { CodingErrorAction action = toCodingErrorAction(errors, eqNode); if (action != null) { return action; } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.LookupError, ErrorMessages.UNKNOWN_ERROR_HANDLER, errors); + throw raiseNode.raise(inliningTarget, PythonErrorType.LookupError, ErrorMessages.UNKNOWN_ERROR_HANDLER, errors); } @TruffleBoundary @@ -244,10 +244,10 @@ static Object decode(VirtualFrame frame, Object self, TruffleString encoding, Tr @Bind("this") Node inliningTarget, @Cached CodecsModuleBuiltins.DecodeNode decodeNode, @Cached IsInstanceNode isInstanceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = decodeNode.executeWithStrings(frame, self, encoding, errors); if (!isInstanceNode.executeWith(frame, result, PythonBuiltinClassType.PString)) { - throw raiseNode.get(inliningTarget).raise(TypeError, DECODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, result); + throw raiseNode.raise(inliningTarget, TypeError, DECODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, result); } return result; } @@ -305,12 +305,12 @@ static PBytesLike add(VirtualFrame frame, Object self, Object other, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached("createWithOverflowError()") @Shared SequenceStorageNodes.ConcatNode concatNode, @Cached @Exclusive BytesNodes.CreateBytesNode create, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); } try { // TODO avoid copying @@ -449,8 +449,8 @@ boolean doIt(VirtualFrame frame, Object self, Object substrs, int start, int end @Fallback static boolean doGeneric(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object substr, @SuppressWarnings("unused") Object start, @SuppressWarnings("unused") Object end, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, METHOD_REQUIRES_A_BYTES_OBJECT_GOT_P, substr); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, METHOD_REQUIRES_A_BYTES_OBJECT_GOT_P, substr); } protected abstract boolean doIt(byte[] bytes, int len, byte[] prefix, int start, int end); @@ -578,10 +578,10 @@ protected ArgumentClinicProvider getArgumentClinic() { static int index(VirtualFrame frame, Object self, Object arg, int start, int end, @Bind("this") Node inliningTarget, @Cached BytesNodes.FindNode findNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int result = findNode.execute(frame, inliningTarget, self, arg, start, end); if (result == -1) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SUBSECTION_NOT_FOUND); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SUBSECTION_NOT_FOUND); } return result; } @@ -603,10 +603,10 @@ protected ArgumentClinicProvider getArgumentClinic() { static int indexWithStartEnd(VirtualFrame frame, Object self, Object arg, int start, int end, @Bind("this") Node inliningTarget, @Cached BytesNodes.FindNode findNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int result = findNode.executeReverse(frame, inliningTarget, self, arg, start, end); if (result == -1) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SUBSECTION_NOT_FOUND); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SUBSECTION_NOT_FOUND); } return result; } @@ -627,7 +627,7 @@ PTuple partition(VirtualFrame frame, Object self, Object sep, @Cached InlinedConditionProfile notFound, @Cached BytesNodes.ToBytesNode toBytesNode, @Cached BytesNodes.CreateBytesNode createBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); byte[] bytes = toBytesNode.execute(frame, self); @@ -635,7 +635,7 @@ PTuple partition(VirtualFrame frame, Object self, Object sep, try { int lenSep = bufferLib.getBufferLength(sepBuffer); if (lenSep == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_SEPARATOR); } byte[] sepBytes = bufferLib.getCopiedByteArray(sepBuffer); int idx = BytesNodes.FindNode.find(bytes, len, sepBytes, 0, bytes.length, isRight()); @@ -805,14 +805,14 @@ static byte pstring(Object strObj, @Cached CastToTruffleStringNode toStr, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString str = toStr.execute(inliningTarget, strObj); if (codePointLengthNode.execute(str, TS_ENCODING) != 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, SEP_MUST_BE_LENGTH_1); + throw raiseNode.raise(inliningTarget, ValueError, SEP_MUST_BE_LENGTH_1); } int cp = codePointAtIndexNode.execute(str, 0, TS_ENCODING); if (cp > 127) { - throw raiseNode.get(inliningTarget).raise(ValueError, SEP_MUST_BE_ASCII); + throw raiseNode.raise(inliningTarget, ValueError, SEP_MUST_BE_ASCII); } return (byte) cp; } @@ -823,17 +823,17 @@ static byte doBuffer(VirtualFrame frame, Object object, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("object") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); Object buffer = bufferAcquireLib.acquireReadonly(object, frame, context, language, indirectCallData); try { if (bufferLib.getBufferLength(buffer) != 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, SEP_MUST_BE_LENGTH_1); + throw raiseNode.raise(inliningTarget, ValueError, SEP_MUST_BE_LENGTH_1); } byte b = bufferLib.readByte(buffer, 0); if (b < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, SEP_MUST_BE_ASCII); + throw raiseNode.raise(inliningTarget, ValueError, SEP_MUST_BE_ASCII); } return b; } finally { @@ -844,8 +844,8 @@ static byte doBuffer(VirtualFrame frame, Object object, @SuppressWarnings("unused") @Fallback static byte error(VirtualFrame frame, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.SEP_MUST_BE_STR_OR_BYTES); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.SEP_MUST_BE_STR_OR_BYTES); } @ClinicConverterFactory @@ -897,8 +897,8 @@ static TruffleString hex(Object self, byte sep, int bytesPerSepGroup, @SuppressWarnings("unused") @Fallback static TruffleString err(Object self, Object sep, Object bytesPerSepGroup, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, DESCRIPTOR_NEED_OBJ, "hex", "bytes"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, DESCRIPTOR_NEED_OBJ, "hex", "bytes"); } } @@ -1206,7 +1206,7 @@ PBytesLike bytes(VirtualFrame frame, Object self, Object widthObj, Object fillOb @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, @Cached InlinedBranchProfile hasFill, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int width = asSizeNode.executeExact(frame, inliningTarget, widthObj); SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); @@ -1216,7 +1216,7 @@ PBytesLike bytes(VirtualFrame frame, Object self, Object widthObj, Object fillOb if (fillObj instanceof PBytesLike && bufferLib.getBufferLength(fillObj) == 1) { fillByte = bufferLib.readByte(fillObj, 0); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BYTE_STRING_OF_LEN_ONE_ONLY, methodName(), fillObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BYTE_STRING_OF_LEN_ONE_ONLY, methodName(), fillObj); } } if (checkSkip(len, width)) { @@ -1360,8 +1360,8 @@ static PBytesLike replace(Object self, Object substrBuffer, Object replacementBu @Fallback static boolean error(@SuppressWarnings("unused") Object self, Object substr, @SuppressWarnings("unused") Object replacement, @SuppressWarnings("unused") Object count, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, BYTESLIKE_OBJ_REQUIRED, substr); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, BYTESLIKE_OBJ_REQUIRED, substr); } @TruffleBoundary(allowInlining = true) @@ -1482,22 +1482,22 @@ static int doInt(int i) { @Specialization static int toInt(long x, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { return PInt.intValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); } } @Specialization static int toInt(PInt x, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { return x.intValueExact(); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "C long"); } } @@ -1634,8 +1634,8 @@ PList split(Object self, byte[] sep, int maxsplit, @SuppressWarnings("unused") @Specialization(guards = {"isEmptySep(sep)"}) static PList error(Object bytes, byte[] sep, int maxsplit, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.ValueError, ErrorMessages.EMPTY_SEPARATOR); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.ValueError, ErrorMessages.EMPTY_SEPARATOR); } private static PList getBytesResult(List bytes, ListNodes.AppendNode appendNode, Object self, Node inliningTarget, BytesNodes.CreateBytesNode createBytesNode, @@ -1940,8 +1940,8 @@ PBytesLike strip(VirtualFrame frame, Object self, Object object, @Fallback @SuppressWarnings("unused") static Object strip(Object self, Object object, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, ErrorMessages.INVALID_ARGS, "lstrip/rstrip"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_ARGS, "lstrip/rstrip"); } protected abstract int mod(); @@ -2071,11 +2071,11 @@ static PBytes maketrans(VirtualFrame frame, @SuppressWarnings("unused") Object c @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached BytesNodes.ToBytesNode toByteNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] fromB = toByteNode.execute(frame, from); byte[] toB = toByteNode.execute(frame, to); if (fromB.length != toB.length) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.ARGS_MUST_HAVE_SAME_LENGTH, "maketrans"); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.ARGS_MUST_HAVE_SAME_LENGTH, "maketrans"); } byte[] table = new byte[256]; @@ -2191,7 +2191,7 @@ static PBytesLike expandtabs(Object self, int tabsize, @Cached GetBytesStorage getBytesStorage, @Cached GetInternalByteArrayNode getInternalByteArrayNode, @Cached BytesNodes.CreateBytesNode create, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = getBytesStorage.execute(inliningTarget, self); int len = storage.length(); if (len == 0) { @@ -2206,18 +2206,18 @@ static PBytesLike expandtabs(Object self, int tabsize, if (tabsize > 0) { int incr = tabsize - (j % tabsize); if (j > max - incr) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.RESULT_TOO_LONG); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.RESULT_TOO_LONG); } j += incr; } } else { if (j > max - 1) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.RESULT_TOO_LONG); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.RESULT_TOO_LONG); } j++; if (p == N || p == R) { if (i > max - j) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.RESULT_TOO_LONG); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.RESULT_TOO_LONG); } i += j; j = 0; @@ -2225,7 +2225,7 @@ static PBytesLike expandtabs(Object self, int tabsize, } } if (i > max - j) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.RESULT_TOO_LONG); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.RESULT_TOO_LONG); } byte[] q = new byte[i + j]; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java index dfceba80ec..21b49d787f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java @@ -252,12 +252,12 @@ byte[] doBuffer(VirtualFrame frame, Object object, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("object") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = bufferAcquireLib.acquireReadonly(object, frame, indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(errorType, errorMessageFormat, object); + throw raiseNode.raise(inliningTarget, errorType, errorMessageFormat, object); } try { return bufferLib.getCopiedByteArray(buffer); @@ -287,12 +287,12 @@ public abstract static class ToBytesWithoutFrameNode extends Node { static byte[] doBuffer(Node inliningTarget, Object object, @CachedLibrary("object") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer; try { buffer = bufferAcquireLib.acquireReadonly(object); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, EXPECTED_BYTESLIKE_GOT_P, object); + throw raiseNode.raise(inliningTarget, TypeError, EXPECTED_BYTESLIKE_GOT_P, object); } try { return bufferLib.getCopiedByteArray(buffer); @@ -528,8 +528,8 @@ static Object str(PString str, @Fallback Object doOthers(@SuppressWarnings("unused") VirtualFrame frame, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, className, argNum, PythonBuiltinClassType.PString, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ARG_D_MUST_BE_S_NOT_P, className, argNum, PythonBuiltinClassType.PString, value); } @ClinicConverterFactory @@ -560,7 +560,7 @@ static byte[] doGeneric(VirtualFrame frame, Object object, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached BytesNodes.IterableToByteNode iterableToByteNode, @Cached IsBuiltinObjectProfile errorProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (bufferAcquireLib.hasBuffer(object)) { // TODO PyBUF_FULL_RO Object buffer = bufferAcquireLib.acquire(object, BufferFlags.PyBUF_ND, frame, indirectCallData); @@ -577,7 +577,7 @@ static byte[] doGeneric(VirtualFrame frame, Object object, e.expect(inliningTarget, TypeError, errorProfile); } } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CONVERT_P_OBJ_TO_S, object, "bytes"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_CONVERT_P_OBJ_TO_S, object, "bytes"); } } @@ -605,18 +605,18 @@ static byte[] fromObject(VirtualFrame frame, Node inliningTarget, Object source, @Cached PyNumberAsSizeNode asSizeNode, @Cached(inline = false) BytesFromObject bytesFromObject, // Exclusive as a workaround for GR-44836 - @Cached @Exclusive PRaiseNode.Lazy raiseNode) { + @Cached @Exclusive PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, source)) { try { int size = asSizeNode.executeExact(frame, inliningTarget, source); if (size < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEGATIVE_COUNT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEGATIVE_COUNT); } try { return new byte[size]; } catch (OutOfMemoryError error) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } catch (PException e) { e.expect(inliningTarget, TypeError, errorProfile); @@ -643,18 +643,18 @@ static byte[] fromString(Node inliningTarget, Object source, Object encoding, Ob @Specialization(guards = "isString(source)") @SuppressWarnings("unused") static byte[] fromString(Node inliningTarget, Object source, PNone encoding, Object errors, - @Cached @Shared PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.STRING_ARG_WO_ENCODING); + @Cached @Shared PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.STRING_ARG_WO_ENCODING); } @Fallback @SuppressWarnings("unused") public static byte[] error(Node inliningTarget, Object source, Object encoding, Object errors, - @Cached @Shared PRaiseNode.Lazy raiseNode) { + @Cached @Shared PRaiseNode raiseNode) { if (PGuards.isNone(encoding)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ENCODING_ARG_WO_STRING); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ENCODING_ARG_WO_STRING); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ERRORS_WITHOUT_STR_ARG); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ERRORS_WITHOUT_STR_ARG); } } @@ -686,7 +686,7 @@ static TruffleString negative(Node inliningTarget, byte[] argbuf, int arglen, by @Shared @Cached InlinedConditionProfile earlyExit, @Shared @Cached(inline = false) TruffleString.FromByteArrayNode fromByteArrayNode, @Shared @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (earlyExit.profile(inliningTarget, arglen == 0)) { return T_EMPTY_STRING; } @@ -694,7 +694,7 @@ static TruffleString negative(Node inliningTarget, byte[] argbuf, int arglen, by /* How many sep characters we'll be inserting. */ int resultlen = (arglen - 1) / absBytesPerSepGroup; if (arglen >= SysModuleBuiltins.MAXSIZE / 2 - resultlen) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } resultlen += arglen * 2; @@ -728,7 +728,7 @@ static TruffleString positive(Node inliningTarget, byte[] argbuf, int arglen, by @Shared @Cached InlinedConditionProfile earlyExit, @Shared @Cached(inline = false) TruffleString.FromByteArrayNode fromByteArrayNode, @Shared @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (earlyExit.profile(inliningTarget, arglen == 0)) { return T_EMPTY_STRING; } @@ -736,7 +736,7 @@ static TruffleString positive(Node inliningTarget, byte[] argbuf, int arglen, by int resultlen = (arglen - 1) / absBytesPerSepGroup; if (arglen >= SysModuleBuiltins.MAXSIZE / 2 - resultlen) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } resultlen += arglen * 2; @@ -884,7 +884,7 @@ static byte[] ascii(TruffleString str, @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { TruffleString ascii = switchEncodingNode.execute(str, Encoding.US_ASCII); InternalByteArray iba = getInternalByteArrayNode.execute(ascii, Encoding.US_ASCII); byte[] bytes = new byte[iba.getLength() / 2]; @@ -897,13 +897,13 @@ static byte[] ascii(TruffleString str, } int top = BytesUtils.digitValue(c); if (top >= 16 || top < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); } c = i + 1 < iba.getEnd() ? strchar[++i] : 0; int bottom = BytesUtils.digitValue(c); if (bottom >= 16 || bottom < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); } bytes[n++] = (byte) ((top << 4) | bottom); @@ -920,12 +920,12 @@ static byte[] nonAscii(TruffleString str, @Shared("getCodeRange") @Cached @SuppressWarnings("unused") TruffleString.GetCodeRangeNode getCodeRangeNode, @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode, @Cached TruffleStringIterator.NextNode nextNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { TruffleStringIterator it = createCodePointIteratorNode.execute(str, TS_ENCODING); int i = 0; while (it.hasNext()) { if (nextNode.execute(it) > 127) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, NON_HEX_NUMBER_IN_FROMHEX, i); } ++i; } @@ -1006,9 +1006,9 @@ static boolean compareByteArrays(ComparisonOp op, byte[] selfArray, int selfLeng @GenerateCached(false) public abstract static class BaseTranslateNode extends PythonBuiltinNode { - static void checkLengthOfTable(Node inliningTarget, byte[] table, InlinedConditionProfile isLenTable256Profile, PRaiseNode.Lazy raiseNode) { + static void checkLengthOfTable(Node inliningTarget, byte[] table, InlinedConditionProfile isLenTable256Profile, PRaiseNode raiseNode) { if (isLenTable256Profile.profile(inliningTarget, table.length != 256)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.TRANS_TABLE_MUST_BE_256); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.TRANS_TABLE_MUST_BE_256); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PByteArray.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PByteArray.java index 039317f973..dc1a8f7e83 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PByteArray.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PByteArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -94,9 +94,9 @@ public void setExports(long exports) { this.exports = exports; } - public void checkCanResize(Node inliningTarget, PRaiseNode.Lazy raiseNode) { + public void checkCanResize(Node inliningTarget, PRaiseNode raiseNode) { if (exports != 0) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.EXPORTS_CANNOT_RESIZE); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.EXPORTS_CANNOT_RESIZE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PBytes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PBytes.java index be372e2f33..64317fe78a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PBytes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/PBytes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -35,12 +35,14 @@ import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; @SuppressWarnings("truffle-abstract-export") @@ -99,9 +101,10 @@ public static void removeArrayElement(PBytes self, long key) throws UnsupportedM @ExportMessage Object acquire(int flags, + @Bind("$node") Node inliningTarget, @Cached PRaiseNode raiseNode) { if ((flags & BufferFlags.PyBUF_WRITABLE) != 0) { - throw raiseNode.raise(BufferError, ErrorMessages.OBJ_IS_NOT_WRITABLE); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.OBJ_IS_NOT_WRITABLE); } return this; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java index 56edf4e0a3..420c927db9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -117,11 +117,11 @@ static boolean eq(VirtualFrame frame, PCell self, PCell other, @Fallback static Object eq(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___EQ__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___EQ__, "cell", self); } } @@ -147,11 +147,11 @@ static boolean ne(VirtualFrame frame, PCell self, PCell other, @Fallback static Object eq(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___NE__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___NE__, "cell", self); } } @@ -177,11 +177,11 @@ static boolean lt(VirtualFrame frame, PCell self, PCell other, @Fallback static Object notImplemented(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___LT__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___LT__, "cell", self); } } @@ -207,11 +207,11 @@ static boolean le(VirtualFrame frame, PCell self, PCell other, @Fallback static Object notImplemented(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___LE__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___LE__, "cell", self); } } @@ -237,11 +237,11 @@ static boolean gt(VirtualFrame frame, PCell self, PCell other, @Fallback static Object notImplemented(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GT__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GT__, "cell", self); } } @@ -267,11 +267,11 @@ static boolean ge(VirtualFrame frame, PCell self, PCell other, @Fallback static Object notImplemented(Object self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GE__, "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GE__, "cell", self); } } @@ -297,11 +297,11 @@ static TruffleString repr(PCell self, @Fallback static Object eq(Object self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self instanceof PCell) { return PNotImplemented.NOT_IMPLEMENTED; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, "__repr__", "cell", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, "__repr__", "cell", self); } } @@ -312,10 +312,10 @@ public abstract static class CellContentsNode extends PythonBuiltinNode { static Object get(PCell self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Cached GetRefNode getRef, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object ref = getRef.execute(inliningTarget, self); if (ref == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IS_EMPTY, "Cell"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IS_EMPTY, "Cell"); } return ref; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java index f788fa4500..93fc71e8ca 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -1115,7 +1115,7 @@ public static Object loadCExtModule(Node location, PythonContext context, Module interopLib = InteropLibrary.getUncached(library); try { if (interopLib.getLanguage(library).toString().startsWith("class com.oracle.truffle.nfi")) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.SystemError, ErrorMessages.NO_BITCODE_FOUND, spec.path); + throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.SystemError, ErrorMessages.NO_BITCODE_FOUND, spec.path); } } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); @@ -1297,7 +1297,7 @@ public Object initCApiModule(Node location, Object sharedLibrary, TruffleString */ Object clazz = GetClassNode.executeUncached(result); if (clazz == PNone.NO_VALUE) { - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.SystemError, ErrorMessages.INIT_FUNC_RETURNED_UNINT_OBJ, initFuncName); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.SystemError, ErrorMessages.INIT_FUNC_RETURNED_UNINT_OBJ, initFuncName); } return CreateModuleNodeGen.getUncached().execute(cApiContext, spec, result, sharedLibrary); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java index f060fadafc..ead440a621 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiMemberAccessNodes.java @@ -82,7 +82,6 @@ import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -213,8 +212,6 @@ public abstract static class ReadMemberNode extends PythonUnaryBuiltinNode { @Child private PythonToNativeNode toSulongNode; @Child private CExtAsPythonObjectNode asPythonObjectNode; - @Child private PForeignToPTypeNode fromForeign; - @Child private PRaiseNode raiseNode; @Child private CStructAccess.ReadBaseNode read; @@ -229,13 +226,12 @@ protected ReadMemberNode(int type, int offset, CExtAsPythonObjectNode asPythonOb this.read = getReadNode(type); this.offset = offset; this.asPythonObjectNode = asPythonObjectNode; - if (asPythonObjectNode == null) { - fromForeign = PForeignToPTypeNode.create(); - } } @Specialization - Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self) { + Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self, + @Bind("this") Node inliningTarget, + @Cached PRaiseNode raiseNode) { if (read == null) { return PNone.NONE; } else { @@ -243,7 +239,7 @@ Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self) { assert !(nativeResult instanceof Byte || nativeResult instanceof Short || nativeResult instanceof Float || nativeResult instanceof Character || nativeResult instanceof PException || nativeResult instanceof String) : nativeResult + " " + nativeResult.getClass(); if (type == T_OBJECT_EX && nativeResult == PNone.NO_VALUE) { - throw ensureRaiseNode().raise(PythonBuiltinClassType.AttributeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError); } if (type == T_OBJECT && nativeResult == PNone.NO_VALUE) { nativeResult = PNone.NONE; @@ -264,14 +260,6 @@ private PythonToNativeNode ensureToSulongNode() { return toSulongNode; } - private PRaiseNode ensureRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } - @TruffleBoundary public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Object owner, TruffleString propertyName, int type, int offset) { CExtAsPythonObjectNode asPythonObjectNode = getReadConverterNode(type); @@ -295,8 +283,8 @@ protected ReadOnlyMemberNode(TruffleString propertyName) { @Specialization @SuppressWarnings("unused") Object doGeneric(Object self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, propertyName, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, propertyName, self); } @TruffleBoundary @@ -315,12 +303,12 @@ protected abstract static class BadMemberDescrNode extends PythonBinaryBuiltinNo @Specialization static Object doGeneric(Object self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (value == DescriptorDeleteMarker.INSTANCE) { // This node is actually only used for T_NONE, so this error message is right. - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); } - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_P, self); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_P, self); } @TruffleBoundary @@ -495,12 +483,13 @@ abstract static class WriteObjectExNode extends WriteTypeNode { @Specialization static void write(Object pointer, Object newValue, + @Bind("this") Node inliningTarget, @Cached CStructAccess.ReadObjectNode read, @Cached CStructAccess.WriteObjectNewRefNode write, @Cached PRaiseNode raise) { Object current = read.readGeneric(pointer, 0); if (newValue == DescriptorDeleteMarker.INSTANCE && current == PNone.NO_VALUE) { - throw raise.raise(PythonBuiltinClassType.AttributeError); + throw raise.raise(inliningTarget, PythonBuiltinClassType.AttributeError); } write.write(pointer, newValue); } @@ -586,7 +575,7 @@ protected WriteMemberNode(int type, int offset) { @Specialization Object doGeneric(Object self, Object value, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object selfPtr = toSulongNode.execute(self); selfPtr = getElement.readGeneric(selfPtr, offset); @@ -598,12 +587,12 @@ Object doGeneric(Object self, Object value, */ if (type != T_OBJECT && type != T_OBJECT_EX) { if (value == DescriptorDeleteMarker.INSTANCE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); } } if (type == T_BOOL && !ensureIsSameTypeNode().executeCached(PythonBuiltinClassType.Boolean, ensureGetClassNode().executeCached(value))) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_TYPE_VALUE_MUST_BE_BOOL); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_TYPE_VALUE_MUST_BE_BOOL); } write.execute(selfPtr, value); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java index d875b2524b..1121c22ab5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java @@ -729,7 +729,7 @@ static PComplex runGeneric(Node inliningTarget, Object value, @Cached PyFloatAsDoubleNode asDoubleNode, @Cached(inline = false) LookupAndCallUnaryDynamicNode callComplex, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = callComplex.executeObject(value, T___COMPLEX__); // TODO(fa) according to CPython's 'PyComplex_AsCComplex', they still allow subclasses // of PComplex @@ -737,7 +737,7 @@ static PComplex runGeneric(Node inliningTarget, Object value, if (result instanceof PComplex) { return (PComplex) result; } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.COMPLEX_RETURNED_NON_COMPLEX, value); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.COMPLEX_RETURNED_NON_COMPLEX, value); } } else { return PFactory.createComplex(language, asDoubleNode.execute(null, inliningTarget, value), 0.0); @@ -1148,7 +1148,7 @@ static Object doObject(Frame frame, Object errorValue, PythonBuiltinClassType er private static void raiseNative(Frame frame, Node inliningTarget, PythonBuiltinClassType errType, TruffleString format, Object[] arguments, PRaiseNode raiseNode, TransformExceptionToNativeNode transformExceptionToNativeNode) { try { - throw raiseNode.raise(errType, format, arguments); + throw raiseNode.raise(inliningTarget, errType, format, arguments); } catch (PException p) { transformExceptionToNativeNode.execute(frame, inliningTarget, p); } @@ -1431,7 +1431,6 @@ Object doGeneric(TruffleString f, Object vaList) { CastToJavaStringNode castToJavaStringNode = CastToJavaStringNodeGen.getUncached(); FromCharPointerNode fromCharPointerNode = FromCharPointerNodeGen.getUncached(); InteropLibrary interopLibrary = InteropLibrary.getUncached(); - PRaiseNode raiseNode = PRaiseNode.getUncached(); StringBuilder result = new StringBuilder(); int vaArgIdx = 0; @@ -1453,7 +1452,7 @@ Object doGeneric(TruffleString f, Object vaList) { int prec = getPrec(matcher.group("prec")); assert spec.length() == 1; char la = spec.charAt(0); - PythonContext context = PythonContext.get(raiseNode); + PythonContext context = PythonContext.get(null); switch (la) { case '%': // %% @@ -1461,9 +1460,9 @@ Object doGeneric(TruffleString f, Object vaList) { valid = true; break; case 'c': - int ordinal = getAndCastToInt(interopLibrary, raiseNode, vaList); + int ordinal = getAndCastToInt(interopLibrary, vaList); if (ordinal < 0 || ordinal > 0x110000) { - throw raiseNode.raise(PythonBuiltinClassType.OverflowError, ErrorMessages.CHARACTER_ARG_NOT_IN_RANGE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.OverflowError, ErrorMessages.CHARACTER_ARG_NOT_IN_RANGE); } result.append((char) ordinal); vaArgIdx++; @@ -1478,12 +1477,12 @@ Object doGeneric(TruffleString f, Object vaList) { case "l": case "z": vaArgIdx++; - result.append(castToLong(interopLibrary, raiseNode, GetNextVaArgNode.executeUncached(vaList))); + result.append(castToLong(interopLibrary, GetNextVaArgNode.executeUncached(vaList))); valid = true; break; } } else { - result.append(getAndCastToInt(interopLibrary, raiseNode, vaList)); + result.append(getAndCastToInt(interopLibrary, vaList)); vaArgIdx++; valid = true; } @@ -1496,19 +1495,19 @@ Object doGeneric(TruffleString f, Object vaList) { case "l": case "z": vaArgIdx++; - result.append(castToLong(interopLibrary, raiseNode, GetNextVaArgNode.executeUncached(vaList))); + result.append(castToLong(interopLibrary, GetNextVaArgNode.executeUncached(vaList))); valid = true; break; } } else { - result.append(Integer.toUnsignedString(getAndCastToInt(interopLibrary, raiseNode, vaList))); + result.append(Integer.toUnsignedString(getAndCastToInt(interopLibrary, vaList))); vaArgIdx++; valid = true; } break; case 'x': // %x - result.append(Integer.toHexString(getAndCastToInt(interopLibrary, raiseNode, vaList))); + result.append(Integer.toHexString(getAndCastToInt(interopLibrary, vaList))); vaArgIdx++; valid = true; break; @@ -1600,7 +1599,7 @@ Object doGeneric(TruffleString f, Object vaList) { // matched) result.append(format, cur, format.length()); } catch (InteropException e) { - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.ERROR_WHEN_ACCESSING_VAR_ARG_AT_POS, vaArgIdx); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.ERROR_WHEN_ACCESSING_VAR_ARG_AT_POS, vaArgIdx); } return toTruffleStringUncached(result.toString()); } @@ -1616,7 +1615,7 @@ private static int getPrec(String prec) { * Read an element from the {@code va_list} with the specified type and cast it to a Java * {@code int}. Throws a {@code SystemError} if this is not possible. */ - private static int getAndCastToInt(InteropLibrary lib, PRaiseNode raiseNode, Object vaList) throws InteropException { + private int getAndCastToInt(InteropLibrary lib, Object vaList) throws InteropException { Object value = GetNextVaArgNode.executeUncached(vaList); if (lib.fitsInInt(value)) { try { @@ -1635,14 +1634,14 @@ private static int getAndCastToInt(InteropLibrary lib, PRaiseNode raiseNode, Obj throw shouldNotReachHere(); } } - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.P_OBJ_CANT_BE_INTEPRETED_AS_INTEGER, value); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.P_OBJ_CANT_BE_INTEPRETED_AS_INTEGER, value); } /** * Cast a value to a Java {@code long}. Throws a {@code SystemError} if this is not * possible. */ - private static long castToLong(InteropLibrary lib, PRaiseNode raiseNode, Object value) { + private long castToLong(InteropLibrary lib, Object value) { if (lib.fitsInLong(value)) { try { return lib.asLong(value); @@ -1660,7 +1659,7 @@ private static long castToLong(InteropLibrary lib, PRaiseNode raiseNode, Object throw shouldNotReachHere(); } } - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.P_OBJ_CANT_BE_INTEPRETED_AS_INTEGER, value); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.P_OBJ_CANT_BE_INTEPRETED_AS_INTEGER, value); } private static Object getPyObject(Object vaList) throws InteropException { @@ -1727,7 +1726,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m @Cached CStructAccess.ReadI32Node readI32Node, @Cached GetThreadStateNode getThreadStateNode, @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // call to type the pointer Object moduleDef = moduleDefWrapper instanceof PythonAbstractNativeObject ? ((PythonAbstractNativeObject) moduleDefWrapper).getPtr() : moduleDefWrapper; @@ -1749,7 +1748,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m mSize = readI64.read(moduleDef, PyModuleDef__m_size); if (mSize < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.M_SIZE_CANNOT_BE_NEGATIVE, mName); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.M_SIZE_CANNOT_BE_NEGATIVE, mName); } // parse slot definitions @@ -1764,7 +1763,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m break loop; case SLOT_PY_MOD_CREATE: if (createFunction != null) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.MODULE_HAS_MULTIPLE_CREATE_SLOTS, mName); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.MODULE_HAS_MULTIPLE_CREATE_SLOTS, mName); } createFunction = readPointerNode.readStructArrayElement(slotDefinitions, i, PyModuleDef_Slot__value); break; @@ -1772,7 +1771,7 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m hasExecutionSlots = true; break; default: - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.MODULE_USES_UNKNOW_SLOT_ID, mName, slotId); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.MODULE_USES_UNKNOW_SLOT_ID, mName, slotId); } } } @@ -1805,10 +1804,10 @@ static Object doGeneric(CApiContext capiContext, ModuleSpec moduleSpec, Object m */ if (!(module instanceof PythonModule)) { if (mSize > 0) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.NOT_A_MODULE_OBJECT_BUT_REQUESTS_MODULE_STATE, mName); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NOT_A_MODULE_OBJECT_BUT_REQUESTS_MODULE_STATE, mName); } if (hasExecutionSlots) { - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.MODULE_SPECIFIES_EXEC_SLOTS_BUT_DIDNT_CREATE_INSTANCE, mName); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.MODULE_SPECIFIES_EXEC_SLOTS_BUT_DIDNT_CREATE_INSTANCE, mName); } // otherwise CPython is just fine } else { @@ -1920,7 +1919,7 @@ static int doGeneric(CApiContext capiContext, PythonModule module, Object module ErrorMessages.EXECUTION_RAISED_EXCEPTION); break; default: - throw raiseNode.raise(SystemError, ErrorMessages.MODULE_INITIALIZED_WITH_UNKNOWN_SLOT, mName, slotId); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.MODULE_INITIALIZED_WITH_UNKNOWN_SLOT, mName, slotId); } } } catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java index 6e118171d4..419eabe0a2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java @@ -61,6 +61,7 @@ import static com.oracle.graal.python.util.PythonUtils.tsLiteral; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; @@ -860,10 +861,10 @@ static Object invoke(VirtualFrame frame, Node inliningTarget, PythonThreadState return lib.execute(callable, cArguments); } catch (UnsupportedTypeException | UnsupportedMessageException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, name, e); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, name, e); } catch (ArityException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, name, e.getExpectedMinArity(), e.getActualArity()); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, name, e.getExpectedMinArity(), e.getActualArity()); } catch (Throwable exception) { /* * Always re-acquire the GIL here. This is necessary because it could happen that C @@ -2418,7 +2419,7 @@ static Object doGeneric(PythonThreadState state, @SuppressWarnings("unused") Tru AbstractTruffleException currentException = state.getCurrentException(); // if no exception occurred, the iterator is exhausted -> raise StopIteration if (currentException == null) { - throw raiseNode.raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } else { throw clearCurrentExceptionNode.getCurrentExceptionForReraise(inliningTarget, state); } @@ -2558,7 +2559,7 @@ static boolean doGeneric(PythonThreadState threadState, TruffleString name, Obje } } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.FUNC_DIDNT_RETURN_INT, name); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.FUNC_DIDNT_RETURN_INT, name); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyMemoryViewWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyMemoryViewWrapper.java index 08f3b241f7..37afca237d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyMemoryViewWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyMemoryViewWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -92,7 +92,7 @@ private static Object intArrayToNativePySSizeArray(int[] intArray) { @TruffleBoundary private static Object allocate(PMemoryView object) { if (object.isReleased()) { - throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.MEMORYVIEW_FORBIDDEN_RELEASED); + throw PRaiseNode.raiseStatic(null, ValueError, ErrorMessages.MEMORYVIEW_FORBIDDEN_RELEASED); } GetElementPtrNode getElementNode = GetElementPtrNode.getUncached(); CStructAccess.WritePointerNode writePointerNode = CStructAccess.WritePointerNode.getUncached(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java index 66a8204fd9..5d97a74122 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java @@ -1026,7 +1026,7 @@ static int doL(Node inliningTarget, long l, return (int) l; } errorBranch.enter(inliningTarget); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, l); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, l); } @Fallback @@ -1165,7 +1165,7 @@ long execute(Object[] arguments, Object result = executeNode.executeObject(null, getDelegate(), toJavaNode.execute(arguments[0])); return PyObjectHashNode.avoidNegative1(cast.execute(inliningTarget, result)); } catch (CannotCastException e) { - throw raiseNode.raise(TypeError, ErrorMessages.HASH_SHOULD_RETURN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HASH_SHOULD_RETURN_INTEGER); } catch (Throwable t) { throw checkThrowableBeforeNative(t, "HashfuncWrapper", getDelegate()); } 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 b2c0b9a338..3d811fd88d 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 @@ -1065,7 +1065,7 @@ static long doGeneric(Node inliningTarget, PythonAbstractObjectNativeWrapper wra * Python-level MemoryError. */ CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.MemoryError); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); } finally { gil.release(acquired); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java index 06659c2b69..e8ffc7c7a4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java @@ -202,18 +202,18 @@ static byte[] doGeneric(Charset charset, Object unicodeObject, TruffleString err @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castToTruffleStringNode, @Cached TruffleString.EqualNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString str; try { str = castToTruffleStringNode.execute(inliningTarget, unicodeObject); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_MUST_BE_S_NOT_P, "argument", "a string", unicodeObject); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_BE_S_NOT_P, "argument", "a string", unicodeObject); } try { CodingErrorAction action = BytesCommonBuiltins.toCodingErrorAction(inliningTarget, errors, raiseNode, eqNode); return BytesCommonBuiltins.doEncode(charset, str, action); } catch (CharacterCodingException e) { - throw raiseNode.get(inliningTarget).raise(UnicodeEncodeError, ErrorMessages.M, e); + throw raiseNode.raise(inliningTarget, UnicodeEncodeError, ErrorMessages.M, e); } } } @@ -605,7 +605,7 @@ private static void checkFunctionResultSlowpath(Node inliningTarget, PythonThrea @TruffleBoundary private static PException raiseNullButNoError(Node node, TruffleString name, TruffleString nullButNoErrorMessage) { - throw PRaiseNode.raiseUncached(node, SystemError, nullButNoErrorMessage, name); + throw PRaiseNode.raiseStatic(node, SystemError, nullButNoErrorMessage, name); } @TruffleBoundary @@ -697,9 +697,10 @@ static int doIntToUInt32Pos(int value, int signed, int targetTypeSize, boolean e @Specialization(guards = {"targetTypeSize == 4", "signed == 0"}, replaces = "doIntToUInt32Pos") @SuppressWarnings("unused") static int doIntToUInt32(int value, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNativeNode") @Cached PRaiseNode raiseNativeNode) { if (exact && value < 0) { - throw raiseNegativeValue(raiseNativeNode); + throw raiseNegativeValue(inliningTarget, raiseNativeNode); } return value; } @@ -719,9 +720,10 @@ static long doIntToUInt64Pos(int value, int signed, int targetTypeSize, boolean @Specialization(guards = {"targetTypeSize == 8", "signed == 0"}, replaces = "doIntToUInt64Pos") @SuppressWarnings("unused") static long doIntToUInt64(int value, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNativeNode") @Cached PRaiseNode raiseNativeNode) { if (exact && value < 0) { - throw raiseNegativeValue(raiseNativeNode); + throw raiseNegativeValue(inliningTarget, raiseNativeNode); } return value; } @@ -741,9 +743,10 @@ static long doLongToUInt64Pos(long value, int signed, int targetTypeSize, boolea @Specialization(guards = {"targetTypeSize == 8", "signed == 0"}, replaces = "doLongToUInt64Pos") @SuppressWarnings("unused") static long doLongToUInt64(long value, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNativeNode") @Cached PRaiseNode raiseNativeNode) { if (exact && value < 0) { - throw raiseNegativeValue(raiseNativeNode); + throw raiseNegativeValue(inliningTarget, raiseNativeNode); } return value; } @@ -751,33 +754,36 @@ static long doLongToUInt64(long value, int signed, int targetTypeSize, boolean e @Specialization(guards = {"exact", "targetTypeSize == 4", "signed != 0"}) @SuppressWarnings("unused") static int doLongToInt32Exact(long obj, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return PInt.intValueExact(obj); } catch (OverflowException e) { - throw raiseNode.raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); } } @Specialization(guards = {"exact", "targetTypeSize == 4", "signed == 0", "obj >= 0"}) @SuppressWarnings("unused") static int doLongToUInt32PosExact(long obj, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNode") @Cached PRaiseNode raiseNode) { if (Integer.toUnsignedLong((int) obj) == obj) { return (int) obj; } else { - throw raiseNode.raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); } } @Specialization(guards = {"exact", "targetTypeSize == 4", "signed == 0"}, replaces = "doLongToUInt32PosExact") @SuppressWarnings("unused") static int doLongToUInt32Exact(long obj, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNode") @Cached PRaiseNode raiseNode) { if (obj < 0) { - throw raiseNegativeValue(raiseNode); + throw raiseNegativeValue(inliningTarget, raiseNode); } - return doLongToUInt32PosExact(obj, signed, targetTypeSize, exact, raiseNode); + return doLongToUInt32PosExact(obj, signed, targetTypeSize, exact, inliningTarget, raiseNode); } @Specialization(guards = {"!exact", "targetTypeSize == 4"}) @@ -796,40 +802,42 @@ static Object doVoidPtrToI64(PythonNativeVoidPtr obj, int signed, int targetType @SuppressWarnings("unused") @TruffleBoundary static int doPIntTo32Bit(PInt obj, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { if (signed != 0) { return obj.intValueExact(); } else if (obj.bitLength() <= 32) { if (obj.isNegative()) { - throw raiseNegativeValue(raiseNode); + throw raiseNegativeValue(inliningTarget, raiseNode); } return obj.intValue(); } } catch (OverflowException e) { // fall through } - throw raiseNode.raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); } @Specialization(guards = {"exact", "targetTypeSize == 8"}) @SuppressWarnings("unused") @TruffleBoundary static long doPIntTo64Bit(PInt obj, int signed, int targetTypeSize, boolean exact, + @Bind("this") Node inliningTarget, @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { if (signed != 0) { return obj.longValueExact(); } else if (obj.bitLength() <= 64) { if (obj.isNegative()) { - throw raiseNegativeValue(raiseNode); + throw raiseNegativeValue(inliningTarget, raiseNode); } return obj.longValue(); } } catch (OverflowException e) { // fall through } - throw raiseNode.raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, targetTypeSize); } @Specialization(guards = {"!exact", "targetTypeSize == 4"}) @@ -864,84 +872,84 @@ static Object doGeneric(Object obj, int signed, int targetTypeSize, boolean exac * 'signed', 'targetTypeSize', and 'exact' are usually constants. */ if (targetTypeSize == 4) { - return toInt32(result, signed, exact, raiseNode); + return toInt32(inliningTarget, result, signed, exact, raiseNode); } else if (targetTypeSize == 8) { - return toInt64(result, signed, exact, raiseNode); + return toInt64(inliningTarget, result, signed, exact, raiseNode); } - throw raiseNode.raise(SystemError, ErrorMessages.UNSUPPORTED_TARGET_SIZE, targetTypeSize); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.UNSUPPORTED_TARGET_SIZE, targetTypeSize); } @Specialization(guards = {"targetTypeSize != 4", "targetTypeSize != 8"}) @SuppressWarnings("unused") static int doUnsupportedTargetSize(Object obj, int signed, int targetTypeSize, boolean exact, - @Shared("raiseNode") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, ErrorMessages.UNSUPPORTED_TARGET_SIZE, targetTypeSize); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.UNSUPPORTED_TARGET_SIZE, targetTypeSize); } - private static PException raiseNegativeValue(PRaiseNode raiseNativeNode) { - throw raiseNativeNode.raise(OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); + private static PException raiseNegativeValue(Node inliningTarget, PRaiseNode raiseNativeNode) { + throw raiseNativeNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); } /** * Slow-path conversion of an object to a signed or unsigned 32-bit value. */ - private static int toInt32(Object object, int signed, boolean exact, + private static int toInt32(Node inliningTarget, Object object, int signed, boolean exact, PRaiseNode raiseNode) { if (object instanceof Integer) { int ival = (int) object; if (signed != 0) { return ival; } - return doIntToUInt32(ival, signed, 4, exact, raiseNode); + return doIntToUInt32(ival, signed, 4, exact, inliningTarget, raiseNode); } else if (object instanceof Long) { long lval = (long) object; if (exact) { if (signed != 0) { - return doLongToInt32Exact(lval, 1, 4, true, raiseNode); + return doLongToInt32Exact(lval, 1, 4, true, inliningTarget, raiseNode); } - return doLongToUInt32Exact(lval, signed, 4, true, raiseNode); + return doLongToUInt32Exact(lval, signed, 4, true, inliningTarget, raiseNode); } return doLongToInt32Lossy(lval, 0, 4, false); } else if (object instanceof PInt) { PInt pval = (PInt) object; if (exact) { - return doPIntTo32Bit(pval, signed, 4, true, raiseNode); + return doPIntTo32Bit(pval, signed, 4, true, inliningTarget, raiseNode); } return doPIntToInt32Lossy(pval, signed, 4, false); } else if (object instanceof PythonNativeVoidPtr) { // that's just not possible - throw raiseNode.raise(PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, 4); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO_C_TYPE, 4); } - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, object); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, object); } /** * Slow-path conversion of an object to a signed or unsigned 64-bit value. */ - private static Object toInt64(Object object, int signed, boolean exact, + private static Object toInt64(Node inliningTarget, Object object, int signed, boolean exact, PRaiseNode raiseNode) { if (object instanceof Integer) { Integer ival = (Integer) object; if (signed != 0) { return ival.longValue(); } - return doIntToUInt64(ival, signed, 8, exact, raiseNode); + return doIntToUInt64(ival, signed, 8, exact, inliningTarget, raiseNode); } else if (object instanceof Long) { long lval = (long) object; if (signed != 0) { return doLongToInt64(lval, 1, 8, exact); } - return doLongToUInt64(lval, signed, 8, exact, raiseNode); + return doLongToUInt64(lval, signed, 8, exact, inliningTarget, raiseNode); } else if (object instanceof PInt) { PInt pval = (PInt) object; if (exact) { - return doPIntTo64Bit(pval, signed, 8, true, raiseNode); + return doPIntTo64Bit(pval, signed, 8, true, inliningTarget, raiseNode); } return doPIntToInt64Lossy(pval, signed, 8, false); } else if (object instanceof PythonNativeVoidPtr) { return doVoidPtrToI64((PythonNativeVoidPtr) object, signed, 8, exact); } - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, object); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, object); } } @@ -1146,10 +1154,10 @@ public abstract static class AsNativeCharNode extends CExtToNativeNode { static byte doGeneric(Object value, @Bind("this") Node inliningTarget, @Cached EncodeNativeStringNode encodeNativeStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { byte[] encoded = encodeNativeStringNode.execute(StandardCharsets.UTF_8, value, T_STRICT); if (encoded.length != 1) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } return encoded[0]; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java index 0fdb508249..c658e0a093 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java @@ -210,8 +210,8 @@ public static Object loadHPyModule(Node location, PythonContext context, Truffle try { abiVersion = backend.getHPyABIVersion(llvmLibrary, hpyMajorVersionFuncName, hpyMinorVersionFuncName); } catch (Exception e) { - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ERROR_LOADING_EXT_MODULE, - path, hpyMajorVersionFuncName, hpyMinorVersionFuncName, e.getMessage()); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ERROR_LOADING_EXT_MODULE, path, hpyMajorVersionFuncName, hpyMinorVersionFuncName, + e.getMessage()); } /* @@ -219,8 +219,8 @@ public static Object loadHPyModule(Node location, PythonContext context, Truffle * which HPyContext to create. */ if (abiVersion.major != HPY_ABI_VERSION || abiVersion.minor > HPY_ABI_VERSION_MINOR) { - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_VERSION_ERROR, - name, abiVersion.major, abiVersion.minor, HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_VERSION_ERROR, name, abiVersion.major, abiVersion.minor, HPY_ABI_VERSION, + HPY_ABI_VERSION_MINOR); } // Sanity check of the tag in the shared object filename @@ -233,7 +233,7 @@ public static Object loadHPyModule(Node location, PythonContext context, Truffle // HPy only supports multi-phase extension module initialization. assert !(hpyModuleDefPtr instanceof PythonModule); if (InteropLibrary.getUncached().isNull(hpyModuleDefPtr)) { - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.ERROR_LOADING_HPY_EXT_S_S, path, name); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.ERROR_LOADING_HPY_EXT_S_S, path, name); } Object module = GraalHPyModuleCreateNodeGen.getUncached().execute(context.getHPyContext(), name, spec, hpyModuleDefPtr); @@ -255,14 +255,12 @@ private static void validateABITag(Node location, String shortname, String sonam String abiTagVersion = matcher.group(1); int abiTag = Integer.parseInt(abiTagVersion); if (abiTag != abiVersion.major) { - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_TAG_MISMATCH, - shortname, soname, abiTag, abiVersion.major, abiVersion.minor); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_TAG_MISMATCH, shortname, soname, abiTag, abiVersion.major, abiVersion.minor); } // major version fits -> validation successful return; } - throw PRaiseNode.raiseUncached(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_NO_ABI_TAG, - shortname, soname, abiVersion.major, abiVersion.minor); + throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_NO_ABI_TAG, shortname, soname, abiVersion.major, abiVersion.minor); } public Object createArgumentsArray(Object[] args) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java index 1927550d25..872b8ea638 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java @@ -1293,7 +1293,7 @@ static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object o @Cached PRaiseNode raiseNode, @Cached AsNativePrimitiveNode asNativePrimitiveNode) { if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT32, true); } @@ -1332,7 +1332,7 @@ static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object o @Cached PRaiseNode raiseNode, @Cached AsNativePrimitiveNode asNativePrimitiveNode) { if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT64, true); } @@ -1359,7 +1359,7 @@ static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object o @Cached PRaiseNode raiseNode, @Cached AsNativePrimitiveNode asNativePrimitiveNode) { if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } return asNativePrimitiveNode.execute(object, 1, SIZEOF_INTPTR, true); } @@ -1402,7 +1402,7 @@ static Object doGeneric(GraalHPyContext hpyContext, long len, Arrays.fill(data, PNone.NONE); return PFactory.createList(hpyContext.getContext().getLanguage(inliningTarget), data); } catch (OverflowException e) { - throw raiseNode.raise(PythonBuiltinClassType.MemoryError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.MemoryError); } } } @@ -1413,10 +1413,11 @@ public abstract static class GraalHPyListAppend extends HPyTernaryContextFunctio @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object left, Object value, + @Bind("this") Node inliningTarget, @Cached ListNodes.AppendNode appendNode, @Cached PRaiseNode raiseNode) { if (!PGuards.isList(left)) { - throw raiseNode.raise(SystemError, ErrorMessages.BAD_INTERNAL_CALL); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_INTERNAL_CALL); } appendNode.execute((PList) left, value); return 0; @@ -1522,8 +1523,8 @@ public abstract static class GraalHPyErrNoMemory extends HPyUnaryContextFunction @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.MemoryError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); } } @@ -1541,7 +1542,7 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object er @Cached PyExceptionInstanceCheckNode exceptionCheckNode, @Cached PRaiseNode raiseNode) { if (!(PGuards.isPythonClass(errTypeObj) && isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException))) { - return raiseNode.raise(SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); + return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); } Object exception; // If the exception value is already an exception object, just take it. @@ -1566,13 +1567,14 @@ public abstract static class GraalHPyErrSetString extends HPyTernaryContextFunct @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object errTypeObj, Object charPtr, + @Bind("this") Node inliningTarget, @Cached FromCharPointerNode fromCharPointerNode, @Cached IsSubtypeNode isSubtypeNode, @Cached CallNode callExceptionConstructorNode, @Cached PyExceptionInstanceCheckNode exceptionCheckNode, @Cached PRaiseNode raiseNode) { if (!(PGuards.isPythonClass(errTypeObj) && isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException))) { - return raiseNode.raise(SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); + return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); } Object exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, fromCharPointerNode.execute(charPtr)); @@ -1602,7 +1604,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object errTypeObj, Object er Object i = callHelperFunctionNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_ERRNO); Object message = fromCharPointerNode.execute(hpyContext, callHelperFunctionNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_STRERROR, i), true); if (!isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException)) { - return raiseNode.raise(SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); + return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); } Object exception = null; if (!isNullNode.execute(hpyContext, errMessagePtr)) { @@ -1639,7 +1641,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object errTypeObj, Object fi Object i = callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_ERRNO); Object message = fromCharPointerNode.execute(callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_STRERROR, i)); if (!isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException)) { - return raiseNode.raise(SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); + return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); } Object exception = null; if (filenameObject1 != NULL_HANDLE_DELEGATE) { @@ -1836,7 +1838,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object unicodeObject, Object try { tsUtf8 = switchEncodingNode.execute(castToTruffleStringNode.execute(inliningTarget, unicodeObject), Encoding.UTF_8); } catch (CannotCastException e) { - throw raiseNode.raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } InternalByteArray internalByteArray = getInternalByteArrayNode.execute(tsUtf8, Encoding.UTF_8); if (!isNullNode.execute(hpyContext, sizePtr)) { @@ -1924,6 +1926,7 @@ public abstract static class GraalHPyUnicodeDecodeASCII extends HPyQuaternaryCon @Specialization static Object doGeneric(GraalHPyContext hpyContext, Object charPtr, long size, Object errorsPtr, + @Bind("this") Node inliningTarget, @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, @@ -1943,7 +1946,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object charPtr, long size, O return fromJavaStringNode.execute(decoded, TS_ENCODING); } // TODO: refactor helper nodes for CodecsModuleBuiltins to use them here - throw raiseNode.raise(PythonBuiltinClassType.UnicodeDecodeError, ErrorMessages.MALFORMED_INPUT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnicodeDecodeError, ErrorMessages.MALFORMED_INPUT); } @TruffleBoundary @@ -2004,11 +2007,12 @@ public abstract static class GraalHPyBytesAsString extends HPyBinaryContextFunct @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { if (object instanceof PBytes bytes) { return PySequenceArrayWrapper.ensureNativeSequence(bytes); } - throw raiseNode.raise(TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); } } @@ -2025,7 +2029,7 @@ static long doGeneric(@SuppressWarnings("unused") Object hpyContext, Object obje if (object instanceof PBytes) { return lenNode.execute(inliningTarget, (PSequence) object); } - throw raiseNode.raise(TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); } } @@ -2044,7 +2048,7 @@ static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, try { size = castToJavaIntNode.execute(inliningTarget, callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_STRLEN, charPtr)); } catch (PException e) { - throw raiseNode.raise(OverflowError, ErrorMessages.BYTE_STR_IS_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.BYTE_STR_IS_TOO_LARGE); } byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, size); return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), bytes); @@ -2062,10 +2066,10 @@ static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, long lsize, @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, @Cached PRaiseNode raiseNode) { if (isNullNode.execute(hpyContext, charPtr)) { - throw raiseNode.raise(ValueError, ErrorMessages.NULL_CHAR_PASSED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NULL_CHAR_PASSED); } if (lsize < 0) { - throw raiseNode.raise(SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); } PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); if (lsize == 0) { @@ -2301,7 +2305,7 @@ public abstract static class GraalHPyNew extends HPyTernaryContextFunction { static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutVar, @Bind("this") Node inliningTarget, @Cached IsTypeNode isTypeNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached(parameters = "hpyContext") GraalHPyCAccess.AllocateNode allocateNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.WritePointerNode writePointerNode, @@ -2311,7 +2315,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutV // check if argument is actually a type if (!isTypeNode.execute(inliningTarget, profiledTypeObject)) { - return raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.HPY_NEW_ARG_1_MUST_BE_A_TYPE); + return raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_NEW_ARG_1_MUST_BE_A_TYPE); } Object dataPtr = null; @@ -2618,7 +2622,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object arrayPtr, long neleme n = castToJavaIntExactNode.execute(inliningTarget, nelements); } catch (CannotCastException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(castToJavaIntExactNode, PythonBuiltinClassType.MemoryError); + throw PRaiseNode.raiseStatic(castToJavaIntExactNode, PythonBuiltinClassType.MemoryError); } Object[] elements = readHPyArrayNode.execute(hpyContext, arrayPtr, 0, n); @@ -2854,13 +2858,13 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ca @Cached CallNode callNode, @Cached PRaiseNode raiseNode) { // check and expand args - Object[] args = castArgs(argsObject, expandArgsNode, raiseNode); + Object[] args = castArgs(inliningTarget, argsObject, expandArgsNode, raiseNode); // check and expand kwargs PKeyword[] keywords = castKwargs(inliningTarget, kwargsObject, lenNode, expandKwargsNode, raiseNode); return callNode.executeWithoutFrame(callable, args, keywords); } - private static Object[] castArgs(Object args, + private static Object[] castArgs(Node inliningTarget, Object args, ExecutePositionalStarargsNode expandArgsNode, PRaiseNode raiseNode) { // this indicates that a NULL handle was passed (which is valid) @@ -2870,7 +2874,7 @@ private static Object[] castArgs(Object args, if (PGuards.isPTuple(args)) { return expandArgsNode.executeWith(null, args); } - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_ARGS_TUPLE_OR_NULL); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_ARGS_TUPLE_OR_NULL); } private static PKeyword[] castKwargs(Node inliningTarget, Object kwargs, @@ -2884,7 +2888,7 @@ private static PKeyword[] castKwargs(Node inliningTarget, Object kwargs, if (PGuards.isDict(kwargs)) { return expandKwargsNode.execute(inliningTarget, kwargs); } - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_KW_DICT_OR_NULL); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_KW_DICT_OR_NULL); } private static boolean isEmptyDict(Node inliningTarget, Object delegate, HashingStorageLen lenNode) { @@ -2905,7 +2909,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object callable, Object args @Cached PRaiseNode raiseNode) { if (!PInt.isIntRange(lnargs)) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); } int nargs = (int) lnargs; PTuple kwnames; @@ -2955,7 +2959,7 @@ static Object doGeneric(GraalHPyContext hpyContext, TruffleString name, Object a @Cached PRaiseNode raiseNode) { if (!PInt.isIntRange(lnargs)) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); } int nargs = (int) lnargs; int nkw = kwnames != PNone.NO_VALUE ? tupleSizeNode.execute(inliningTarget, kwnames) : 0; @@ -3069,7 +3073,7 @@ static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Obj int len = codepointLengthNode.execute(name, TS_ENCODING); int dotIdx = indexOfCodepointNode.execute(name, '.', 0, len, TS_ENCODING); if (dotIdx < 0) { - throw raiseNode.raise(SystemError, ErrorMessages.NAME_MUST_BE_MOD_CLS); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NAME_MUST_BE_MOD_CLS); } if (base == PNone.NO_VALUE) { @@ -3087,7 +3091,7 @@ static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Obj * CPython expects a PyDictObject and if not, it raises a * ErrorMessages.BAD_INTERNAL_CALL. */ - throw raiseNode.raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } dict = (PDict) dictObj; dictStorage = dict.getDictStorage(); @@ -3333,11 +3337,11 @@ public abstract static class GraalHPyDictKeys extends HPyBinaryContextFunction { static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object dictObj, @Bind("this") Node inliningTarget, @Cached PyDictKeys keysNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (dictObj instanceof PDict dict) { return keysNode.execute(inliningTarget, dict); } - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } } @@ -3348,11 +3352,11 @@ public abstract static class GraalHPyDictCopy extends HPyBinaryContextFunction { static Object doGeneric(GraalHPyContext hpyContext, Object dictObj, @Bind("this") Node inliningTarget, @Cached HashingStorageCopy copyNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (dictObj instanceof PDict dict) { return PFactory.createDict(hpyContext.getContext().getLanguage(inliningTarget), copyNode.execute(inliningTarget, dict.getDictStorage())); } - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } } @@ -3375,14 +3379,14 @@ static PyCapsule doGeneric(GraalHPyContext hpyContext, Object pointer, Object na @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, @Cached PRaiseNode raiseNode) { if (isNullNode.execute(hpyContext, pointer)) { - throw raiseNode.raise(ValueError, ErrorMessages.HPYCAPSULE_NEW_NULL_PTR_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HPYCAPSULE_NEW_NULL_PTR_ERROR); } Object hpyDestructor = null; if (!isNullNode.execute(hpyContext, dtorPtr)) { Object cpyTrampoline = readPointerNode.read(hpyContext, dtorPtr, GraalHPyCField.HPyCapsule_Destructor__cpy_trampoline); hpyDestructor = readPointerNode.read(hpyContext, dtorPtr, GraalHPyCField.HPyCapsule_Destructor__impl); if (isNullNode.execute(hpyContext, cpyTrampoline) || isNullNode.execute(hpyContext, hpyDestructor)) { - throw raiseNode.raise(ValueError, ErrorMessages.INVALID_HPYCAPSULE_DESTRUCTOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_HPYCAPSULE_DESTRUCTOR); } } PyCapsule capsule = PFactory.createCapsuleNativeName(hpyContext.getContext().getLanguage(inliningTarget), pointer, namePtr); @@ -3403,13 +3407,13 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ca @Bind("this") Node inliningTarget, @Cached PyCapsuleNameMatchesNode nameMatchesNode, @Cached PRaiseNode raiseNode) { - isLegalCapsule(capsule, key, raiseNode); + isLegalCapsule(inliningTarget, capsule, key, raiseNode); PyCapsule pyCapsule = (PyCapsule) capsule; Object result; switch (key) { case CapsuleKey.Pointer -> { if (!nameMatchesNode.execute(inliningTarget, pyCapsule.getNamePtr(), namePtr)) { - throw raiseNode.raise(ValueError, INCORRECT_NAME); + throw raiseNode.raise(inliningTarget, ValueError, INCORRECT_NAME); } result = pyCapsule.getPointer(); } @@ -3425,9 +3429,9 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ca return result; } - public static void isLegalCapsule(Object object, int key, PRaiseNode raiseNode) { + public static void isLegalCapsule(Node inliningTarget, Object object, int key, PRaiseNode raiseNode) { if (!(object instanceof PyCapsule) || ((PyCapsule) object).getPointer() == null) { - throw raiseNode.raise(ValueError, getErrorMessage(key)); + throw raiseNode.raise(inliningTarget, ValueError, getErrorMessage(key)); } } @@ -3448,15 +3452,16 @@ public static TruffleString getErrorMessage(int key) { public abstract static class GraalHPyCapsuleSet extends HPyQuaternaryContextFunction { @Specialization static int doGeneric(GraalHPyContext hpyContext, Object capsule, int key, Object valuePtr, + @Bind("this") Node inliningTarget, @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, @Cached FromCharPointerNode fromCharPointerNode, @Cached PRaiseNode raiseNode) { - GraalHPyCapsuleGet.isLegalCapsule(capsule, key, raiseNode); + GraalHPyCapsuleGet.isLegalCapsule(inliningTarget, capsule, key, raiseNode); PyCapsule pyCapsule = (PyCapsule) capsule; switch (key) { case CapsuleKey.Pointer -> { if (isNullNode.execute(hpyContext, valuePtr)) { - throw raiseNode.raise(ValueError, ErrorMessages.CAPSULE_SETPOINTER_CALLED_WITH_NULL_POINTER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CAPSULE_SETPOINTER_CALLED_WITH_NULL_POINTER); } pyCapsule.setPointer(valuePtr); } @@ -3504,7 +3509,7 @@ static int doGeneric(GraalHPyContext hpyContext, Object var, Object def, Object @Cached PRaiseNode raiseNode, @Cached(parameters = "hpyContext") GraalHPyCAccess.WriteHPyNode writeHPyNode) { if (!(var instanceof PContextVar contextVar)) { - throw raiseNode.raise(TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } PythonContext context = hpyContext.getContext(); PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); @@ -3536,7 +3541,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object var, Object val, @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode) { if (!(var instanceof PContextVar contextVar)) { - throw raiseNode.raise(TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } PythonContext context = hpyContext.getContext(); PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); @@ -3557,7 +3562,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object obj, Object encodingP @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromNativeCharPointerNode, @Cached PyUnicodeFromEncodedObject libNode) { if (nullProfile.profile(inliningTarget, obj == PNone.NO_VALUE)) { - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } TruffleString encoding; if (!isNullNode.execute(hpyContext, encodingPtr)) { @@ -3592,7 +3597,7 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ob int start = castStart.execute(inliningTarget, lstart); int end = castEnd.execute(inliningTarget, lend); if (profile.profile(inliningTarget, start < 0 || end < 0)) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } SliceInfo sliceInfo = PSlice.computeIndices(start, end, 1, codePointLengthNode.execute(value, TS_ENCODING)); return getSlice.execute(value, sliceInfo); @@ -3630,7 +3635,7 @@ static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object typeO Object profiledTypeObject = classProfile.profile(inliningTarget, typeObject); int result = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); if (result == -2) { - throw raiseNode.raise(TypeError, ErrorMessages.S_MUST_BE_S, "arg", "type"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_BE_S, "arg", "type"); } return result; } @@ -3641,6 +3646,7 @@ static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object typeO public abstract static class GraalHPyCompile extends HPyQuaternaryContextFunction { @Specialization static Object doGeneric(GraalHPyContext hpyContext, Object srcPtr, Object filenamePtr, int kind, + @Bind("this") Node inliningTarget, @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, @Cached FromCharPointerNode fromCharPointerNode, @Cached CallNode callNode, @@ -3650,7 +3656,7 @@ static Object doGeneric(GraalHPyContext hpyContext, Object srcPtr, Object filena Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_COMPILE); GraalHPySourceKind sourceKind = GraalHPySourceKind.fromValue(kind); if (sourceKind == null) { - throw raiseNode.raise(SystemError, ErrorMessages.HPY_INVALID_SOURCE_KIND); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_INVALID_SOURCE_KIND); } return callNode.executeWithoutFrame(builtinFunction, src, filename, sourceKind.getMode()); } @@ -3679,7 +3685,7 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, PCode cod if (globals instanceof PythonObject) { PArguments.setGlobals(pArguments, (PythonObject) globals); } else { - throw raiseNode.raise(SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); } RootCallTarget rootCallTarget = getCallTargetNode.execute(inliningTarget, code); @@ -3700,7 +3706,7 @@ static int doGeneric(GraalHPyContext hpyContext, PythonObject object, Object cal Object clazz = getClassNode.execute(inliningTarget, object); if (!(clazz instanceof PythonClass pythonClass) || !pythonClass.isHPyType()) { errorProfile.enter(inliningTarget); - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.HPY_TYPE_DOES_NOT_IMPLEMENT_CALL_PROTOCOL, clazz); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.HPY_TYPE_DOES_NOT_IMPLEMENT_CALL_PROTOCOL, clazz); } Object callFunction = readCallFunctionNode.execute(inliningTarget, hpyContext, callFunctionDefPtr); GraalHPyData.setHPyCallFunction(object, callFunction); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java index de9a964821..b343ff1d62 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java @@ -220,13 +220,13 @@ protected HPyReadMemberNode(int offset, int type, CExtAsPythonObjectNode asPytho @Specialization Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { GraalHPyContext hPyContext = getContext().getHPyContext(); Object nativeSpacePtr = ensureReadNativeSpaceNode().executeCached(self); if (nativeSpacePtr == PNone.NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_READ_FROM_OFFSET_D, offset, self); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_READ_FROM_OFFSET_D, offset, self); } Object nativeResult; switch (type) { @@ -237,7 +237,7 @@ Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self, if (type == HPY_MEMBER_OBJECT) { return PNone.NONE; } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError); } } return fieldValue; @@ -342,8 +342,8 @@ protected HPyReadOnlyMemberNode(TruffleString propertyName) { @Specialization @SuppressWarnings("unused") Object doGeneric(Object self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, propertyName, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, propertyName, self); } @TruffleBoundary @@ -361,12 +361,12 @@ protected abstract static class HPyBadMemberDescrNode extends PythonBinaryBuilti @Specialization static Object doGeneric(Object self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { if (value == DescriptorDeleteMarker.INSTANCE) { // This node is actually only used for T_NONE, so this error message is right. - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); } - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_P, self); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_P, self); } @TruffleBoundary @@ -407,14 +407,14 @@ protected HPyWriteMemberNode(int type, int offset) { @Specialization Object doGeneric(VirtualFrame frame, Object self, Object value, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = getContext(); GraalHPyContext hPyContext = context.getHPyContext(); Object nativeSpacePtr = ensureReadNativeSpaceNode().executeCached(self); if (nativeSpacePtr == PNone.NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_WRITE_OFFSET_D, offset, self); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_WRITE_OFFSET_D, offset, self); } /* @@ -427,13 +427,13 @@ Object doGeneric(VirtualFrame frame, Object self, Object value, if (self instanceof PythonObject pythonObject) { Object oldValue = ensureReadHPyFieldNode(hPyContext).read(hPyContext, pythonObject, nativeSpacePtr, offset); if (oldValue == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError); } } else { throw CompilerDirectives.shouldNotReachHere("Cannot have HPyField on non-Python object"); } } else if (type != HPY_MEMBER_OBJECT) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); } // NO_VALUE will be converted to the NULL handle newValue = PNone.NO_VALUE; @@ -524,7 +524,7 @@ Object doGeneric(VirtualFrame frame, Object self, Object value, case HPY_MEMBER_BOOL: // note: exact type check is sufficient; bool cannot be subclassed if (!ensureIsBuiltinObjectProfile().profileObject(this, newValue, PythonBuiltinClassType.Boolean)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_VALUE_MUST_BE_BOOL); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_VALUE_MUST_BE_BOOL); } val = ensureIsNode().isTrue(newValue) ? 1 : 0; ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Bool, val); @@ -544,7 +544,7 @@ Object doGeneric(VirtualFrame frame, Object self, Object value, ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, HPyContextSignatureType.HPy_ssize_t, val); break; default: - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_S, ""); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_S, ""); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java index 9de14d1240..2a36d5cf01 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java @@ -239,7 +239,7 @@ public static PException checkThrowableBeforeNative(Throwable t, String where1, out.println("should not throw exceptions apart from PException"); t.printStackTrace(out); out.flush(); - throw PRaiseNode.raiseUncached(null, SystemError, ErrorMessages.INTERNAL_EXCEPTION_OCCURED); + throw PRaiseNode.raiseStatic(null, SystemError, ErrorMessages.INTERNAL_EXCEPTION_OCCURED); } public abstract AllocateNode createAllocateNode(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java index fbf5f3b277..5228f2d329 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java @@ -297,10 +297,9 @@ public static int raiseIntUncached(GraalHPyContext nativeContext, int errorValue @Specialization static int doInt(Frame frame, GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments, @Bind("this") Node inliningTarget, - @Shared("raiseNode") @Cached PRaiseNode raiseNode, @Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) { try { - throw raiseNode.execute(raiseNode, errType, PNone.NO_VALUE, format, arguments); + throw PRaiseNode.raiseStatic(inliningTarget, errType, format, arguments); } catch (PException p) { transformExceptionToNativeNode.execute(frame, inliningTarget, nativeContext, p); } @@ -310,10 +309,9 @@ static int doInt(Frame frame, GraalHPyContext nativeContext, int errorValue, Pyt @Specialization static Object doObject(Frame frame, GraalHPyContext nativeContext, Object errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments, @Bind("this") Node inliningTarget, - @Shared("raiseNode") @Cached PRaiseNode raiseNode, @Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) { try { - throw raiseNode.execute(raiseNode, errType, PNone.NO_VALUE, format, arguments); + throw PRaiseNode.raiseStatic(inliningTarget, errType, format, arguments); } catch (PException p) { transformExceptionToNativeNode.execute(frame, inliningTarget, nativeContext, p); } @@ -425,9 +423,10 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe size = readGenericNode.readLong(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__size); if (size < 0) { - throw raiseNode.raise(PythonBuiltinClassType.SystemError, tsLiteral("HPy does not permit HPyModuleDef.size < 0")); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, tsLiteral("HPy does not permit HPyModuleDef.size < 0")); } else if (size > 0) { - throw raiseNode.raise(PythonBuiltinClassType.SystemError, tsLiteral("Module state is not supported yet in HPy, set HPyModuleDef.size = 0 if module state is not needed")); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, + tsLiteral("Module state is not supported yet in HPy, set HPyModuleDef.size = 0 if module state is not needed")); } // process HPy module slots @@ -453,13 +452,13 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe switch (slotData.slot) { case HPY_MOD_CREATE -> { if (createFunction != null) { - throw raiseNode.raise(PythonErrorType.SystemError, ErrorMessages.MODULE_HAS_MULTIPLE_CREATE_SLOTS, mName); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.MODULE_HAS_MULTIPLE_CREATE_SLOTS, mName); } createFunction = slotData.impl; } case HPY_MOD_EXEC -> { if (createFunction != null) { - throw raiseNode.raise(PythonErrorType.SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_OTHER_SLOTS, mName); + throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_OTHER_SLOTS, mName); } /* * In contrast to CPython, we already parse and store the @@ -468,7 +467,7 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe */ executeSlots.add(slotData.impl); } - default -> throw raiseNode.raise(PythonErrorType.SystemError, ErrorMessages.MODULE_USES_UNKNOW_SLOT_ID, mName, slotData.slot); + default -> throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.MODULE_USES_UNKNOW_SLOT_ID, mName, slotData.slot); } break; case GraalHPyDef.HPY_DEF_KIND_MEMBER: @@ -503,11 +502,11 @@ static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spe * 'size > 0') */ if (hasLegacyMethods || mDoc != null || nModuleGlobals != 0) { - throw raiseNode.raise(SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_NON_DEFAULT); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_NON_DEFAULT); } module = callCreate(inliningTarget, createFunction, context, spec, checkFunctionResultNode, asHandleNode, createLib); if (module instanceof PythonModule) { - throw raiseNode.raise(SystemError, ErrorMessages.HPY_MOD_CREATE_RETURNED_BUILTIN_MOD); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_MOD_CREATE_RETURNED_BUILTIN_MOD); } } else { PythonModule pmodule = PFactory.createPythonModule(language, mName); @@ -583,9 +582,9 @@ static Object callCreate(Node inliningTarget, Object callable, GraalHPyContext h try { return checkFunctionResultNode.execute(pythonThreadState, CREATE, lib.execute(callable, hPyContext.getBackend(), hSpec)); } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, CREATE, e); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, CREATE, e); } catch (ArityException e) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, CREATE, e.getExpectedMinArity(), e.getActualArity()); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, CREATE, e.getExpectedMinArity(), e.getActualArity()); } finally { // close all handles (if necessary) if (hSpec.isAllocated()) { @@ -635,9 +634,9 @@ static void callExec(Node node, GraalHPyContext hPyContext, Object callable, Pyt try { checkFunctionResultNode.execute(pythonThreadState, T_EXEC, lib.execute(callable, hPyContext.getBackend(), hModule)); } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, T_EXEC, e); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, T_EXEC, e); } catch (ArityException e) { - throw PRaiseNode.raiseUncached(node, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, T_EXEC, e.getExpectedMinArity(), e.getActualArity()); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, T_EXEC, e.getExpectedMinArity(), e.getActualArity()); } finally { // close all handles (if necessary) if (hModule.isAllocated()) { @@ -688,7 +687,7 @@ static PBuiltinFunction doIt(GraalHPyContext context, Object enclosingType, Obje Object methodFunctionPointer; signature = HPyFuncSignature.fromValue(readGenericNode.readInt(context, methodDef, GraalHPyCField.HPyDef__meth__signature)); if (signature == null) { - throw raiseNode.raise(PythonBuiltinClassType.ValueError, ErrorMessages.UNSUPPORTED_HYPMETH_SIG); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UNSUPPORTED_HYPMETH_SIG); } methodFunctionPointer = readPointerNode.read(context, methodDef, GraalHPyCField.HPyDef__meth__impl); @@ -1126,7 +1125,7 @@ static HPySlotData doIt(Node inliningTarget, GraalHPyContext context, Object slo HPySlot slot = HPySlot.fromValue(slotNr); if (slot == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotNr); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotNr); } // read and check the function pointer @@ -1203,10 +1202,10 @@ static Object doIt(GraalHPyContext context, PythonClass enclosingType, TpSlots.B */ if (HPY_TP_CALL.equals(slot)) { if (enclosingType.getItemSize() > 0) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_VAR_OBJECTS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_VAR_OBJECTS); } if (enclosingType.getBuiltinShape() == GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY && enclosingType.getBasicSize() == 0) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_LEGACY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_LEGACY); } enclosingType.setHPyDefaultCallFunc(slotData.impl()); } @@ -1243,7 +1242,7 @@ static boolean doIt(GraalHPyContext context, Object enclosingType, TpSlots.Build @Cached ReadPropertyNode readPropertyNode, @Cached WritePropertyNode writePropertyNode, @CachedLibrary(limit = "1") InteropLibrary lib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // computes '&(slotDefArrPtr[i].slot)' long slotIdOffset = ReadGenericNode.getElementPtr(context, i, context.getCTypeSize(HPyContextSignatureType.PyType_Slot), GraalHPyCField.PyType_Slot__slot); @@ -1255,7 +1254,7 @@ static boolean doIt(GraalHPyContext context, Object enclosingType, TpSlots.Build HPyLegacySlot slot = HPyLegacySlot.fromValue(slotId); if (slot == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotId); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotId); } // computes '&(slotDefArrPtr[i].pfunc)' @@ -2333,14 +2332,14 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe // extract bases from type spec params PTuple bases = extractBases(typeSpecParams, language); // extract metaclass from type spec params - Object metatype = getMetatype(typeSpecParams, raiseNode); + Object metatype = getMetatype(inliningTarget, typeSpecParams); if (metatype != null) { if (!isTypeNode.execute(inliningTarget, metatype)) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, metatype); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, metatype); } if (!hasSameConstructorNode.execute(inliningTarget, metatype, PythonBuiltinClassType.PythonClass)) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_METACLASS_WITH_CUSTOM_CONS_NOT_SUPPORTED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_WITH_CUSTOM_CONS_NOT_SUPPORTED); } } @@ -2383,7 +2382,7 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe long flags = readI32Node.readUnsigned(context, typeSpec, GraalHPyCField.HPyType_Spec__flags); int builtinShape = readI32Node.read(context, typeSpec, GraalHPyCField.HPyType_Spec__builtin_shape); if (!GraalHPyDef.isValidBuiltinShape(builtinShape)) { - throw raiseNode.raise(ValueError, ErrorMessages.HPY_INVALID_BUILTIN_SHAPE, builtinShape); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HPY_INVALID_BUILTIN_SHAPE, builtinShape); } long basicSize = readI32Node.read(context, typeSpec, GraalHPyCField.HPyType_Spec__basicsize); @@ -2448,18 +2447,18 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe * '__vectorcalloffset__'. */ if (newType.getHPyVectorcallOffset() != Long.MIN_VALUE && newType.getHPyDefaultCallFunc() != null) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CANNOT_HAVE_CALL_AND_VECTORCALLOFFSET); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_HAVE_CALL_AND_VECTORCALLOFFSET); } if (needsTpTraverse) { - throw raiseNode.raise(ValueError, ErrorMessages.TRAVERSE_FUNCTION_NEEDED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TRAVERSE_FUNCTION_NEEDED); } // process legacy slots; this is of type 'cpy_PyTypeSlot legacy_slots[]' Object legacySlotsArrPtr = readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__legacy_slots); if (!isNullNode.execute(context, legacySlotsArrPtr)) { if (builtinShape != GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_CANNOT_SPECIFY_LEG_SLOTS_WO_SETTING_LEG); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_SPECIFY_LEG_SLOTS_WO_SETTING_LEG); } for (int i = 0;; i++) { if (!createLegacySlotNode.execute(context, newType, tpSlotsBuilder, legacySlotsArrPtr, i)) { @@ -2507,10 +2506,10 @@ static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpe baseFlags = 0; } int baseBuiltinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(baseClass); - checkInheritanceConstraints(flags, baseFlags, builtinShape, baseBuiltinShape > GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY, raiseNode); + checkInheritanceConstraints(inliningTarget, flags, baseFlags, builtinShape, baseBuiltinShape > GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY, raiseNode); return newType; } catch (CannotCastException e) { - throw raiseNode.raise(SystemError, ErrorMessages.COULD_NOT_CREATE_TYPE_FROM_SPEC_BECAUSE, e); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.COULD_NOT_CREATE_TYPE_FROM_SPEC_BECAUSE, e); } } @@ -2596,17 +2595,17 @@ private static PTuple extractBases(HPyTypeSpecParam[] typeSpecParams, PythonLang * Reference implementation can be found in {@code ctx_type.c:get_metatype} */ @TruffleBoundary - private static Object getMetatype(HPyTypeSpecParam[] typeSpecParams, PRaiseNode raiseNode) { + private static Object getMetatype(Node inliningTarget, HPyTypeSpecParam[] typeSpecParams) { Object result = null; if (typeSpecParams != null) { for (HPyTypeSpecParam typeSpecParam : typeSpecParams) { if (typeSpecParam.kind() == GraalHPyDef.HPyType_SPEC_PARAM_METACLASS) { if (result != null) { - throw raiseNode.raise(ValueError, ErrorMessages.HPY_METACLASS_SPECIFIED_MULTIPLE_TIMES); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.HPY_METACLASS_SPECIFIED_MULTIPLE_TIMES); } result = typeSpecParam.object(); if (!IsTypeNode.executeUncached(result)) { - throw raiseNode.raise(TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, result); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, result); } } } @@ -2614,7 +2613,7 @@ private static Object getMetatype(HPyTypeSpecParam[] typeSpecParams, PRaiseNode return result; } - private static void checkInheritanceConstraints(long flags, long baseFlags, int builtinShape, boolean baseIsPure, PRaiseNode raiseNode) { + private static void checkInheritanceConstraints(Node inliningTarget, long flags, long baseFlags, int builtinShape, boolean baseIsPure, PRaiseNode raiseNode) { // Pure types may inherit from: // // * pure types, or @@ -2627,7 +2626,7 @@ private static void checkInheritanceConstraints(long flags, long baseFlags, int // See https://github.com/hpyproject/hpy/issues/169 for details. assert GraalHPyDef.isValidBuiltinShape(builtinShape); if (builtinShape == GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY && baseIsPure) { - throw raiseNode.raise(TypeError, ErrorMessages.LEG_TYPE_SHOULDNT_INHERIT_MEM_LAYOUT_FROM_PURE_TYPE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.LEG_TYPE_SHOULDNT_INHERIT_MEM_LAYOUT_FROM_PURE_TYPE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java index a51505dd58..a270b04aed 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java @@ -121,6 +121,7 @@ import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; public abstract class HPyExternalFunctionNodes { @@ -365,6 +366,7 @@ public abstract static class HPyExternalFunctionInvokeNode extends Node { @Specialization(limit = "1") Object doIt(VirtualFrame frame, TruffleString name, Object callable, GraalHPyContext hPyContext, Object[] arguments, + @Bind("this") Node inliningTarget, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("callable") InteropLibrary lib, @Cached PRaiseNode raiseNode) { @@ -385,9 +387,9 @@ Object doIt(VirtualFrame frame, TruffleString name, Object callable, GraalHPyCon try { return checkFunctionResultNode.execute(pythonThreadState, name, lib.execute(callable, convertedArguments)); } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, name, e); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, name, e); } catch (ArityException e) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, name, e.getExpectedMinArity(), e.getActualArity()); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, name, e.getExpectedMinArity(), e.getActualArity()); } finally { // special case after calling a C function: transfer caught exception back to frame // to simulate the global state semantics @@ -926,7 +928,7 @@ static final class HPyMethObjObjArgProcRoot extends HPyMethodDescriptorRootNode @Child private ReadIndexedArgumentNode readArg1Node; @Child private ReadVarArgsNode readVarargsNode; - @Child private PRaiseNode raiseNode; + private final BranchProfile errorProfile = BranchProfile.create(); public HPyMethObjObjArgProcRoot(PythonLanguage language, TruffleString name) { super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); @@ -940,20 +942,12 @@ protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unus } else if (varargs.length == 1) { return new Object[]{getSelf(frame), getArg1(frame), varargs[0]}; } else { - throw getRaiseNode().raise(PythonBuiltinClassType.TypeError, + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_S_GIVEN_S, getName(), 2, 3, "s", 1 + varargs.length, "were", ""); } } - private PRaiseNode getRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } - private Object[] getVarargs(VirtualFrame frame) { if (readVarargsNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -1135,7 +1129,7 @@ static long doLong(PythonThreadState pythonThreadState, TruffleString name, long static Object doObject(PythonThreadState pythonThreadState, TruffleString name, Object value, @Bind("this") Node inliningTarget, @CachedLibrary("value") InteropLibrary lib, - @Shared @Cached PRaiseNode.Lazy raiseNode, + @Shared @Cached PRaiseNode raiseNode, @Shared @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { if (lib.fitsInLong(value)) { try { @@ -1146,7 +1140,7 @@ static Object doObject(PythonThreadState pythonThreadState, TruffleString name, throw CompilerDirectives.shouldNotReachHere(); } } - throw raiseNode.get(inliningTarget).raise(SystemError, ErrorMessages.FUNC_S_DIDNT_RETURN_INT, name); + throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.FUNC_S_DIDNT_RETURN_INT, name); } } @@ -1372,7 +1366,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) { Object nativeSpacePtr = getNativeSpacePointerNode.executeCached(objects[0]); if (nativeSpacePtr == PNone.NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.ATTEMPTING_GETTER_NO_NATIVE_SPACE); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.ATTEMPTING_GETTER_NO_NATIVE_SPACE); } objects[0] = new PythonAbstractNativeObject(nativeSpacePtr); return objects; @@ -1454,7 +1448,7 @@ protected Object[] prepareCArguments(VirtualFrame frame) { Object nativeSpacePtr = getNativeSpacePointerNode.executeCached(objects[0]); if (nativeSpacePtr == PNone.NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.ATTEMPTING_SETTER_NO_NATIVE_SPACE); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.ATTEMPTING_SETTER_NO_NATIVE_SPACE); } objects[0] = new PythonAbstractNativeObject(nativeSpacePtr); return objects; @@ -1777,7 +1771,7 @@ public Object execute(VirtualFrame frame) { callable = null; } if (callable == null) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.HPY_OBJECT_DOES_NOT_SUPPORT_CALL, self); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.HPY_OBJECT_DOES_NOT_SUPPORT_CALL, self); } getCalleeContext().enter(frame); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java index 1a703b622c..7289ec2e46 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java @@ -1470,7 +1470,7 @@ public long ctxContextVarGet(long varBits, long defBits, long errBits) { Object var = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(varBits)); if (!(var instanceof PContextVar)) { try { - throw PRaiseNode.raiseUncached(null, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); } catch (PException e) { HPyTransformExceptionToNativeNode.executeUncached(context, e); } @@ -1550,7 +1550,7 @@ public long ctxCapsuleGet(long capsuleBits, int key, long namePtr) { if (!(capsule instanceof PyCapsule pyCapsule) || pyCapsule.getPointer() == null) { return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, ValueError, GraalHPyCapsuleGet.getErrorMessage(key)); } - GraalHPyCapsuleGet.isLegalCapsule(capsule, key, PRaiseNode.getUncached()); + GraalHPyCapsuleGet.isLegalCapsule(null, capsule, key, PRaiseNode.getUncached()); Object result; switch (key) { case CapsuleKey.Pointer -> { @@ -1839,13 +1839,13 @@ public long ctxGetItemi(long hCollection, long lidx) { try { // If handle 'hCollection' is a boxed int or double, the object is not subscriptable. if (!GraalHPyBoxing.isBoxedHandle(hCollection)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, 0); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, 0); } Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hCollection)); Object clazz = GetClassNode.executeUncached(receiver); if (clazz == PythonBuiltinClassType.PList || clazz == PythonBuiltinClassType.PTuple) { if (!PInt.isIntRange(lidx)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); + throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); } int idx = (int) lidx; PSequence sequence = (PSequence) receiver; @@ -1893,7 +1893,7 @@ public int ctxSetItem(long hSequence, long hKey, long hValue) { try { // If handle 'hSequence' is a boxed int or double, the object is not a sequence. if (!GraalHPyBoxing.isBoxedHandle(hSequence)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); } Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hSequence)); Object clazz = GetClassNode.executeUncached(receiver); @@ -1937,7 +1937,7 @@ public int ctxSetItemi(long hSequence, long lidx, long hValue) { try { // If handle 'hSequence' is a boxed int or double, the object is not a sequence. if (!GraalHPyBoxing.isBoxedHandle(hSequence)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); } Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hSequence)); Object clazz = GetClassNode.executeUncached(receiver); @@ -1958,7 +1958,7 @@ public int ctxSetItemi(long hSequence, long lidx, long hValue) { private boolean ctxListSetItem(Object receiver, long lidx, long hValue) { // fast path for list if (!PInt.isIntRange(lidx)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); + throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); } int idx = (int) lidx; PList sequence = (PList) receiver; @@ -2603,7 +2603,7 @@ public long ctxCall(long callable, long args, long lnargs, long kwnames) { assert args != 0 || lnargs == 0; try { if (!PInt.isIntRange(lnargs)) { - throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); } int nargs = (int) lnargs; Object callableObj = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(callable)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java index f48b29dcc6..e05918ba65 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -322,7 +322,7 @@ static Object[] doPointer(GraalHPyContext ctx, Object pointer, long offset, long throw CompilerDirectives.shouldNotReachHere(e); } catch (InvalidArrayIndexException e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(arrayLib, SystemError, ErrorMessages.CANNOT_ACCESS_IDX, e.getInvalidIndex(), n); + throw PRaiseNode.raiseStatic(arrayLib, SystemError, ErrorMessages.CANNOT_ACCESS_IDX, e.getInvalidIndex(), n); } } @@ -900,14 +900,14 @@ static Object doIt(Node inliningTarget, GraalHPyContext context, GraalHPyNativeS @CachedLibrary(limit = "1") InteropLibrary interopLibrary, @Cached HPyLLVMImportSymbolNode importCExtSymbolNode, @Cached EnsureTruffleStringNode ensureTruffleStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { Object llvmFunction = importCExtSymbolNode.execute(inliningTarget, context, name); return ensureTruffleStringNode.execute(inliningTarget, interopLibrary.execute(llvmFunction, args)); } catch (UnsupportedTypeException | ArityException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, e); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, e); } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.HPY_CAPI_SYM_NOT_CALLABLE, name); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_CAPI_SYM_NOT_CALLABLE, name); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/structs/CConstants.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/structs/CConstants.java index 47f21f9fb1..f4ee44d620 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/structs/CConstants.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/structs/CConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -90,7 +90,7 @@ public int intValue() { CompilerDirectives.transferToInterpreterAndInvalidate(); resolve(); if (intValue == -1) { - throw PRaiseNode.raiseUncached(null, SystemError, INTERNAL_INT_OVERFLOW); + throw PRaiseNode.raiseStatic(null, SystemError, INTERNAL_INT_OVERFLOW); } return intValue; } @@ -104,10 +104,10 @@ private static void resolve() { for (CConstants constant : VALUES) { constant.longValue = constants[constant.ordinal()]; if (constant.longValue == -1) { - throw PRaiseNode.raiseUncached(null, SystemError, toTruffleStringUncached("internal limitation - cannot extract constants with value '-1'")); + throw PRaiseNode.raiseStatic(null, SystemError, toTruffleStringUncached("internal limitation - cannot extract constants with value '-1'")); } if ((constant.longValue & 0xFFFF0000L) == 0xDEAD0000L) { - throw PRaiseNode.raiseUncached(null, SystemError, toTruffleStringUncached("marker value reached, regenerate C code (mx python-capi)")); + throw PRaiseNode.raiseStatic(null, SystemError, toTruffleStringUncached("marker value reached, regenerate C code (mx python-capi)")); } if (constant.longValue == (int) constant.longValue) { constant.intValue = (int) constant.longValue; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java index 1869dc930c..157a5e2429 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java @@ -154,7 +154,7 @@ private static PCode createCode(PythonLanguage language, PythonContext context, @SuppressWarnings("static-method") private RootCallTarget deserializeForBytecodeInterpreter(PythonContext context, byte[] data, TruffleString[] cellvars, TruffleString[] freevars) { - CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(context, data); + CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(null, context, data); if (cellvars != null && !Arrays.equals(code.cellvars, cellvars) || freevars != null && !Arrays.equals(code.freevars, freevars)) { code = new CodeUnit(code.name, code.qualname, code.argCount, code.kwOnlyArgCount, code.positionalOnlyArgCount, code.stacksize, code.code, code.srcOffsetTable, code.flags, code.names, code.varnames, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java index 3e1e1ee89c..4c5652bd89 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/BufferStorageNodes.java @@ -166,11 +166,11 @@ static PBytes unpackChar(@SuppressWarnings("unused") BufferFormat format, Object @Specialization(guards = "format == UNICODE") static TruffleString unpackUnicode(Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached(inline = false) TruffleString.FromCodePointNode fromCodePointNode) { int codePoint = bufferLib.readInt(buffer, offset); if (!Character.isValidCodePoint(codePoint)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNMAPPABLE_CHARACTER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNMAPPABLE_CHARACTER); } return fromCodePointNode.execute(codePoint, TS_ENCODING, true); } @@ -186,9 +186,9 @@ public abstract static class PackValueNode extends Node { @Specialization(guards = "format == UINT_8") static void packUnsignedByteInt(Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, int value, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (value < 0 || value > 0xFF) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeByte(buffer, offset, (byte) value); } @@ -197,10 +197,10 @@ static void packUnsignedByteInt(Node inliningTarget, @SuppressWarnings("unused") static void packUnsignedByteGeneric(VirtualFrame frame, Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object object, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int value = asSizeNode.executeExact(frame, inliningTarget, object); if (value < 0 || value > 0xFF) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeByte(buffer, offset, (byte) value); } @@ -209,10 +209,10 @@ static void packUnsignedByteGeneric(VirtualFrame frame, Node inliningTarget, @Su static void packSignedByteGeneric(VirtualFrame frame, Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object object, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int value = asSizeNode.executeExact(frame, inliningTarget, object); if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeByte(buffer, offset, (byte) value); } @@ -221,10 +221,10 @@ static void packSignedByteGeneric(VirtualFrame frame, Node inliningTarget, @Supp static void packSignedShortGeneric(VirtualFrame frame, Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object object, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int value = asSizeNode.executeExact(frame, inliningTarget, object); if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeShort(buffer, offset, (short) value); } @@ -233,10 +233,10 @@ static void packSignedShortGeneric(VirtualFrame frame, Node inliningTarget, @Sup static void packUnsignedShortGeneric(VirtualFrame frame, Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, Object object, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int value = asSizeNode.executeExact(frame, inliningTarget, object); if (value < 0 || value > (Short.MAX_VALUE << 1) + 1) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeShort(buffer, offset, (short) value); } @@ -260,10 +260,10 @@ static void packUnsignedIntGeneric(VirtualFrame frame, Node inliningTarget, @Sup @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PyNumberIndexNode indexNode, @Shared @Cached CastToJavaLongExactNode castToLong, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { long value = castToLong.execute(inliningTarget, indexNode.execute(frame, inliningTarget, object)); if (value < 0 || value > ((long) (Integer.MAX_VALUE) << 1L) + 1L) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } bufferLib.writeInt(buffer, offset, (int) value); } @@ -313,9 +313,9 @@ static void packBoolean(VirtualFrame frame, @SuppressWarnings("unused") BufferFo @Specialization(guards = "format == CHAR") static void packChar(Node inliningTarget, @SuppressWarnings("unused") BufferFormat format, PBytes object, Object buffer, int offset, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (bufferLib.getBufferLength(object) != 1) { - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } byte value = bufferLib.readByte(object, 0); bufferLib.writeByte(buffer, offset, value); @@ -323,9 +323,8 @@ static void packChar(Node inliningTarget, @SuppressWarnings("unused") BufferForm @Specialization(guards = {"format == CHAR", "!isPBytes(object)"}) @SuppressWarnings("unused") - static void packChar(Node inliningTarget, BufferFormat format, Object object, Object buffer, int offset, - @Shared @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError); + static void packChar(Node inliningTarget, BufferFormat format, Object object, Object buffer, int offset) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError); } @Specialization(guards = "format == UNICODE") @@ -334,13 +333,13 @@ static void packDouble(Node inliningTarget, @SuppressWarnings("unused") BufferFo @Cached StringNodes.CastToTruffleStringCheckedNode cast, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @Cached(inline = false) TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString str = cast.cast(inliningTarget, object, ErrorMessages.ARRAY_ITEM_MUST_BE_UNICODE); if (codePointLengthNode.execute(str, TS_ENCODING) == 1) { int codePoint = codePointAtIndexNode.execute(str, 0, TS_ENCODING); bufferLib.writeInt(buffer, offset, codePoint); } else { - throw raiseNode.get(inliningTarget).raise(TypeError); + throw raiseNode.raise(inliningTarget, TypeError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/ForeignHashingStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/ForeignHashingStorage.java index 721a463be6..9aee630703 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/ForeignHashingStorage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/ForeignHashingStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -48,7 +48,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.GilNode; @@ -121,7 +120,7 @@ static Object get(Node inliningTarget, ForeignHashingStorage storage, Object key @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, @Cached(inline = false) PForeignToPTypeNode toPythonNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var dict = storage.foreignDict; Object value; gil.release(true); @@ -130,7 +129,7 @@ static Object get(Node inliningTarget, ForeignHashingStorage storage, Object key } catch (UnknownKeyException e) { return null; } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_READABLE, key, dict); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_READABLE, key, dict); } finally { gil.acquire(); } @@ -150,21 +149,21 @@ public abstract static class PutNode extends PNodeWithContext { static void put(Node inliningTarget, ForeignHashingStorage storage, Object key, Object value, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var dict = storage.foreignDict; gil.release(true); try { interop.writeHashEntry(dict, key, value); } catch (UnknownKeyException e) { - throw raiseNode.get(inliningTarget).raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } catch (UnsupportedMessageException e) { if (interop.isHashEntryExisting(dict, key)) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_WRITABLE, key, dict); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_WRITABLE, key, dict); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_INSERTABLE, key, dict); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_INSERTABLE, key, dict); } } catch (UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); } finally { gil.acquire(); } @@ -182,7 +181,7 @@ public abstract static class RemoveNode extends PNodeWithContext { static boolean remove(Node inliningTarget, ForeignHashingStorage storage, Object key, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var dict = storage.foreignDict; gil.release(true); @@ -191,7 +190,7 @@ static boolean remove(Node inliningTarget, ForeignHashingStorage storage, Object } catch (UnknownKeyException e) { return false; } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_REMOVABLE, key, dict); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_REMOVABLE, key, dict); } finally { gil.acquire(); } @@ -233,7 +232,7 @@ static void clear(Node inliningTarget, ForeignHashingStorage storage, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary iteratorInterop, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // We cannot just remove while iterating otherwise we get e.g. // ConcurrentModificationException with java.util.HashMap // So we remove keys by batch of 32 keys. @@ -262,13 +261,13 @@ static void clear(Node inliningTarget, ForeignHashingStorage storage, } } - private static void remove(Node inliningTarget, Object dict, Object key, InteropLibrary interop, Lazy raiseNode) { + private static void remove(Node inliningTarget, Object dict, Object key, InteropLibrary interop, PRaiseNode raiseNode) { try { interop.removeHashEntry(dict, key); } catch (UnknownKeyException e) { // already removed concurrently } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_REMOVABLE, key, dict); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_REMOVABLE, key, dict); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java index 0da6b4a46f..2930148360 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -232,7 +232,7 @@ static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object it @Shared @Cached PyObjectGetItem getItemNode, @Cached FastConstructListNode createListNode, @Cached LenNode seqLenNode, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached InlinedConditionProfile lengthTwoProfile, @Cached IsBuiltinObjectProfile isTypeErrorProfile) throws PException { Object it = getIter.execute(frame, inliningTarget, iterable); @@ -248,7 +248,7 @@ static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object it len = seqLenNode.execute(inliningTarget, element); if (lengthTwoProfile.profile(inliningTarget, len != 2)) { - throw raise.get(inliningTarget).raise(ValueError, ErrorMessages.DICT_UPDATE_SEQ_ELEM_HAS_LENGTH_2_REQUIRED, elements.size(), len); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.DICT_UPDATE_SEQ_ELEM_HAS_LENGTH_2_REQUIRED, elements.size(), len); } Object key = getItemNode.execute(frame, inliningTarget, element, 0); Object value = getItemNode.execute(frame, inliningTarget, element, 1); @@ -257,7 +257,7 @@ static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object it } catch (PException e) { if (!lengthTwoProfile.profile(inliningTarget, len != 2) && isTypeErrorProfile.profileException(inliningTarget, e, TypeError)) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CONVERT_DICT_UPDATE_SEQ, elements.size()); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_CONVERT_DICT_UPDATE_SEQ, elements.size()); } throw e; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageNodes.java index 06a19bd600..d9050b2d12 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorageNodes.java @@ -40,6 +40,9 @@ */ package com.oracle.graal.python.builtins.objects.common; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; +import static com.oracle.graal.python.nodes.ErrorMessages.FOREIGN_OBJ_ISNT_REVERSE_ITERABLE; + import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage.EconomicMapSetStringKey; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodesFactory.CachedHashingStorageGetItemNodeGen; @@ -98,9 +101,6 @@ import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; import com.oracle.truffle.api.strings.TruffleString; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; -import static com.oracle.graal.python.nodes.ErrorMessages.FOREIGN_OBJ_ISNT_REVERSE_ITERABLE; - public class HashingStorageNodes { public abstract static class HashingStorageGuards { @@ -908,9 +908,9 @@ static HashingStorageIterator keywords(@SuppressWarnings("unused") KeywordsStora @Specialization static HashingStorageIterator foreign(@SuppressWarnings("unused") ForeignHashingStorage self, - @Cached(inline = false) PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // InteropLibrary does not provide a reverse HashEntriesIterator - throw raiseNode.raise(TypeError, FOREIGN_OBJ_ISNT_REVERSE_ITERABLE); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, FOREIGN_OBJ_ISNT_REVERSE_ITERABLE); } } @@ -1039,9 +1039,9 @@ static boolean foreign(ForeignHashingStorage self, HashingStorageIterator it, @Specialization(guards = "it.isReverse") static boolean foreignReverse(@SuppressWarnings("unused") ForeignHashingStorage self, HashingStorageIterator it, - @Cached(inline = false) PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // InteropLibrary does not provide a reverse HashEntriesIterator - throw raiseNode.raise(TypeError, FOREIGN_OBJ_ISNT_REVERSE_ITERABLE); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, FOREIGN_OBJ_ISNT_REVERSE_ITERABLE); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/IndexNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/IndexNodes.java index a651a07fa3..88544ace1f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/IndexNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/IndexNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -46,7 +46,6 @@ import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -193,7 +192,7 @@ abstract static class NormalizeIndexWithBoundsCheckNode extends NormalizeIndexCu static int doInt(int index, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int normalizedIndex = index; if (negativeIndexProfile.profile(inliningTarget, normalizedIndex < 0)) { normalizedIndex += length; @@ -205,7 +204,7 @@ static int doInt(int index, int length, TruffleString errorMessage, @Specialization static int doBool(boolean bIndex, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int index = PInt.intValue(bIndex); checkBounds(inliningTarget, raiseNode, errorMessage, index, length); return index; @@ -215,7 +214,7 @@ static int doBool(boolean bIndex, int length, TruffleString errorMessage, static int doLong(long lIndex, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { int index = PInt.intValueExact(lIndex); return doInt(index, length, errorMessage, inliningTarget, negativeIndexProfile, raiseNode); } @@ -224,11 +223,11 @@ static int doLong(long lIndex, int length, TruffleString errorMessage, int doLongOvf(long index, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { return doLong(index, length, errorMessage, inliningTarget, negativeIndexProfile, raiseNode); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, index); } } @@ -236,7 +235,7 @@ int doLongOvf(long index, int length, TruffleString errorMessage, static int doPInt(PInt index, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { int idx = index.intValueExact(); return doInt(idx, length, errorMessage, inliningTarget, negativeIndexProfile, raiseNode); } @@ -245,11 +244,11 @@ static int doPInt(PInt index, int length, TruffleString errorMessage, int doPIntOvf(PInt index, int length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { return doPInt(index, length, errorMessage, inliningTarget, negativeIndexProfile, raiseNode); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, index); } } @@ -257,7 +256,7 @@ int doPIntOvf(PInt index, int length, TruffleString errorMessage, static long doLongLong(long lIndex, long length, TruffleString errorMessage, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile negativeIndexProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { long normalizedIndex = lIndex; if (negativeIndexProfile.profile(inliningTarget, normalizedIndex < 0)) { normalizedIndex += length; @@ -306,7 +305,7 @@ static int doLongOvf(long index, int length, TruffleString errorMessage, try { return doLong(index, length, errorMessage, inliningTarget, negativeIndexProfile); } catch (OverflowException e) { - throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, index); } } @@ -326,7 +325,7 @@ static int doPIntOvf(PInt index, int length, TruffleString errorMessage, try { return doPInt(index, length, errorMessage, inliningTarget, negativeIndexProfile); } catch (OverflowException e) { - throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, index); } } @@ -342,26 +341,26 @@ static long doLongLong(long index, long length, @SuppressWarnings("unused") Truf } } - public static void checkBounds(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString errorMessage, int idx, int length) { + public static void checkBounds(Node inliningTarget, PRaiseNode raiseNode, TruffleString errorMessage, int idx, int length) { if (idx < 0 || idx >= length) { raiseIndexError(inliningTarget, errorMessage, raiseNode); } } - public static void checkBounds(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString errorMessage, long idx, long length) { + public static void checkBounds(Node inliningTarget, PRaiseNode raiseNode, TruffleString errorMessage, long idx, long length) { if (idx < 0 || idx >= length) { raiseIndexError(inliningTarget, errorMessage, raiseNode); } } - public static void checkBounds(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString errorMessage, int idx, long length) { + public static void checkBounds(Node inliningTarget, PRaiseNode raiseNode, TruffleString errorMessage, int idx, long length) { if (idx < 0 || idx >= length) { raiseIndexError(inliningTarget, errorMessage, raiseNode); } } @InliningCutoff - private static void raiseIndexError(Node inliningTarget, TruffleString errorMessage, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, errorMessage); + private static void raiseIndexError(Node inliningTarget, TruffleString errorMessage, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, errorMessage); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceNodes.java index 7e2783727f..686169d706 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -163,9 +163,8 @@ static SequenceStorage doForeign(Node inliningTarget, Object seq, } @Fallback - static SequenceStorage doFallback(Node inliningTarget, Object seq, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A_SEQUENCE, seq); + static SequenceStorage doFallback(Node inliningTarget, Object seq) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, IS_NOT_A_SEQUENCE, seq); } @NeverDefault @@ -247,9 +246,9 @@ public abstract static class CheckIsSequenceNode extends Node { @Specialization static void check(Node inliningTarget, Object obj, @Cached PySequenceCheckNode sequenceCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!sequenceCheckNode.execute(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A_SEQUENCE, obj); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A_SEQUENCE, obj); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 3406fd3255..2e9807b5f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -181,12 +181,12 @@ public abstract static class SequenceStorageSqItemNode extends Node { @Specialization static Object doIt(Node inliningTarget, SequenceStorage self, int index, TruffleString errorMessage, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode) { return getItem(inliningTarget, self, index, errorMessage, raiseNode, getItemNode); } - private static Object getItem(Node inliningTarget, SequenceStorage storage, int index, TruffleString errorMessage, PRaiseNode.Lazy raiseNode, GetItemScalarNode getItemNode) { + private static Object getItem(Node inliningTarget, SequenceStorage storage, int index, TruffleString errorMessage, PRaiseNode raiseNode, GetItemScalarNode getItemNode) { checkBounds(inliningTarget, raiseNode, errorMessage, index, storage.length()); return getItemNode.execute(inliningTarget, storage, index); } @@ -219,7 +219,7 @@ static Object doNonSlice(VirtualFrame frame, Node inliningTarget, SequenceStorag TruffleString indexBoundsErrorMessage, @SuppressWarnings("unused") StorageWrapperFactory wrapperFactory, @Cached PyNumberAsSizeNode numberAsSizeNode, @Cached InlinedConditionProfile negativeIndexProfile, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode) { int index = numberAsSizeNode.executeExact(frame, inliningTarget, idx, PythonBuiltinClassType.IndexError); if (negativeIndexProfile.profile(inliningTarget, index < 0)) { @@ -1749,7 +1749,7 @@ static void multiStep(SequenceStorage self, SliceInfo sinfo, SequenceStorage val } else { /*- Assign slice */ if (wrongLength.profile(inliningTarget, needed != slicelen)) { - raiseNode.raise(ValueError, ErrorMessages.ATTEMPT_TO_ASSIGN_SEQ_OF_SIZE_TO_SLICE_OF_SIZE, needed, slicelen); + raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ATTEMPT_TO_ASSIGN_SEQ_OF_SIZE_TO_SLICE_OF_SIZE, needed, slicelen); } for (int cur = start, i = 0; i < slicelen; cur += step, i++) { setLeftItemNode.execute(inliningTarget, self, cur, getRightItemNode.execute(inliningTarget, data, i)); @@ -1814,7 +1814,7 @@ static void singleStep(SequenceStorage self, int lo, int hi, SequenceStorage dat ensureCapacityNode.execute(inliningTarget, self, len + growth); if (memoryError.profile(inliningTarget, len > Integer.MAX_VALUE - growth)) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } len += growth; @@ -2197,7 +2197,7 @@ static SequenceStorage doLeftEmpty(@SuppressWarnings("unused") EmptySequenceStor try { return copyNode.execute(inliningTarget, right); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -2209,7 +2209,7 @@ static SequenceStorage doRightEmpty(@SuppressWarnings("unused") EmptySequenceSto try { return copyNode.execute(inliningTarget, left); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -2354,14 +2354,14 @@ SequenceStorage doRight(SequenceStorage left, SequenceStorage right, destlen = PythonUtils.addExact(len1, len2); if (errorForOverflow == OverflowError && shouldOverflow.profile(inliningTarget, destlen >= SysModuleBuiltins.MAXSIZE)) { // cpython raises an overflow error when this happens - throw raiseNode.raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } SequenceStorage generalized = generalizeStore(createEmpty(createEmptyNode, inliningTarget, left, right, destlen), right); return doConcat(generalized, left, right); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } @@ -2547,95 +2547,102 @@ static SequenceStorage doZeroRepeat(SequenceStorage s, @SuppressWarnings("unused /* special but common case: something like '[False] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) BoolSequenceStorage doBoolSingleElement(BoolSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { boolean[] repeated = new boolean[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getBoolItemNormalized(0)); return new BoolSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } /* special but common case: something like '["\x00"] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) ByteSequenceStorage doByteSingleElement(ByteSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { byte[] repeated = new byte[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getByteItemNormalized(0)); return new ByteSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } /* special but common case: something like '[0] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) IntSequenceStorage doIntSingleElement(IntSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { int[] repeated = new int[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getIntItemNormalized(0)); return new IntSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } /* special but common case: something like '[0L] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) LongSequenceStorage doLongSingleElement(LongSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { long[] repeated = new long[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getLongItemNormalized(0)); return new LongSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } /* special but common case: something like '[0.0] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) DoubleSequenceStorage doDoubleSingleElement(DoubleSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { double[] repeated = new double[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getDoubleItemNormalized(0)); return new DoubleSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } /* special but common case: something like '[None] * n' */ @Specialization(guards = {"s.length() == 1", "times > 0"}) ObjectSequenceStorage doObjectSingleElement(ObjectSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode) { try { Object[] repeated = new Object[PythonUtils.multiplyExact(s.length(), times)]; Arrays.fill(repeated, s.getObjectItemNormalized(0)); return new ObjectSequenceStorage(repeated); } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } @Specialization(limit = "MAX_BASIC_STORAGES", guards = {"times > 0", "!isNative(s)", "s.getClass() == cachedClass"}) SequenceStorage doArrayBasedManaged(ArrayBasedSequenceStorage s, int times, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raiseNode, @Cached("s.getClass()") Class cachedClass) { try { @@ -2649,9 +2656,9 @@ SequenceStorage doArrayBasedManaged(ArrayBasedSequenceStorage s, int times, repeated.setNewLength(newLength); return repeated; } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } @@ -2683,9 +2690,9 @@ SequenceStorage doGeneric(SequenceStorage s, int times, repeated.setNewLength(newLen); return repeated; } catch (OutOfMemoryError e) { - throw raiseNode.raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } catch (OverflowException e) { - throw raiseNode.raise(errorForOverflow); + throw raiseNode.raise(inliningTarget, errorForOverflow); } } @@ -2697,7 +2704,7 @@ SequenceStorage doNonInt(VirtualFrame frame, SequenceStorage s, Object times, @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached PRaiseNode raiseNode) { if (!indexCheckNode.execute(inliningTarget, times)) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, times); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, times); } int i = asSizeNode.executeExact(frame, inliningTarget, times); if (recursive == null) { @@ -2843,7 +2850,7 @@ protected SequenceStorage doGeneric(SequenceStorage s, Object indicationVal, return s; } - throw raiseNode.raise(TypeError, getErrorMessage()); + throw raiseNode.raise(inliningTarget, TypeError, getErrorMessage()); } protected TruffleString getErrorMessage() { @@ -3226,7 +3233,7 @@ static void doNativeByte(NativeByteSequenceStorage s, int cap, @Shared @CachedLibrary(limit = "2") InteropLibrary lib, @Shared @Cached CStructAccess.AllocateNode alloc, @Shared @Cached CStructAccess.FreeNode free, - @Shared @Cached PRaiseNode.Lazy raiseNode, + @Shared @Cached PRaiseNode raiseNode, @Cached CStructAccess.ReadByteNode read, @Cached CStructAccess.WriteByteNode write) { int oldCapacity = s.getCapacity(); @@ -3235,7 +3242,7 @@ static void doNativeByte(NativeByteSequenceStorage s, int cap, Object oldMem = s.getPtr(); Object newMem = alloc.alloc(newCapacity); if (lib.isNull(newMem)) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } // TODO: turn this into a memcpy for (long i = 0; i < oldCapacity; i++) { @@ -3253,7 +3260,7 @@ static void doNativeObject(NativeObjectSequenceStorage s, int cap, @Shared @CachedLibrary(limit = "2") InteropLibrary lib, @Shared @Cached CStructAccess.AllocateNode alloc, @Shared @Cached CStructAccess.FreeNode free, - @Shared @Cached PRaiseNode.Lazy raiseNode, + @Shared @Cached PRaiseNode raiseNode, @Cached CStructAccess.ReadPointerNode read, @Cached CStructAccess.WritePointerNode write) { int oldCapacity = s.getCapacity(); @@ -3263,7 +3270,7 @@ static void doNativeObject(NativeObjectSequenceStorage s, int cap, long bytes = newCapacity * 8; Object newMem = alloc.alloc(bytes); if (lib.isNull(newMem)) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } // TODO: turn this into a memcpy for (long i = 0; i < oldCapacity; i++) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java index c24a8823e8..a14a8f779e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java @@ -234,7 +234,7 @@ public abstract static class AbsNode extends PythonUnaryBuiltinNode { static double abs(Object self, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); double x = c.getReal(); double y = c.getImag(); @@ -268,7 +268,7 @@ static double abs(Object self, // remove scaling double r = scalb(scaledH, middleExp); if (Double.isInfinite(r)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.ABSOLUTE_VALUE_TOO_LARGE); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.ABSOLUTE_VALUE_TOO_LARGE); } return r; } @@ -425,7 +425,7 @@ static Object doComplex(Object leftObj, Object rightObj, @Cached InlinedConditionProfile topConditionProfile, @Cached InlinedConditionProfile zeroDivisionProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); if (notImplementedProfile.profile(inliningTarget, left == null || right == null)) { @@ -438,7 +438,7 @@ static Object doComplex(Object leftObj, Object rightObj, if (topConditionProfile.profile(inliningTarget, absRightReal >= absRightImag)) { /* divide tops and bottom by right.real */ if (zeroDivisionProfile.profile(inliningTarget, absRightReal == 0.0)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "complex"); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.S_DIVISION_BY_ZERO, "complex"); } else { double ratio = right.getImag() / right.getReal(); double denom = right.getReal() + right.getImag() * ratio; @@ -537,7 +537,7 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus @Cached InlinedBranchProfile smallNegativeProfile, @Cached InlinedBranchProfile complexProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ComplexValue left = toComplexLeft.execute(inliningTarget, leftObj); ComplexValue right = toComplexRight.execute(inliningTarget, rightObj); if (notImplementedProfile.profile(inliningTarget, left == null || right == null)) { @@ -550,7 +550,7 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus } else if (left.getReal() == 0.0 && left.getImag() == 0.0) { leftZeroProfile.enter(inliningTarget); if (right.getImag() != 0.0 || right.getReal() < 0.0) { - throw PRaiseNode.raiseUncached(inliningTarget, ZeroDivisionError, ErrorMessages.COMPLEX_ZERO_TO_NEGATIVE_POWER); + throw PRaiseNode.raiseStatic(inliningTarget, ZeroDivisionError, ErrorMessages.COMPLEX_ZERO_TO_NEGATIVE_POWER); } result = PFactory.createComplex(language, 0.0, 0.0); } else if (right.getImag() == 0.0 && right.getReal() == (int) right.getReal() && right.getReal() < 100 && right.getReal() > -100) { @@ -566,7 +566,7 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus result = complexToComplexBoundary(left.getReal(), left.getImag(), right.getReal(), right.getImag(), language); } if (Double.isInfinite(result.getReal()) || Double.isInfinite(result.getImag())) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.COMPLEX_EXPONENTIATION); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.COMPLEX_EXPONENTIATION); } return result; } @@ -575,8 +575,8 @@ static Object doGeneric(Object leftObj, Object rightObj, @SuppressWarnings("unus @InliningCutoff @SuppressWarnings("unused") static Object error(Object left, Object right, Object mod, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.COMPLEX_MODULO); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.COMPLEX_MODULO); } private static PComplex complexToSmallPositiveIntPower(ComplexValue x, long n, PythonLanguage language) { @@ -759,7 +759,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static TruffleString format(Object self, TruffleString formatString, @Bind("this") Node inliningTarget, @Cached ToComplexValueNode toComplexValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ComplexValue c = toComplexValueNode.execute(inliningTarget, self); InternalFormat.Spec spec = InternalFormat.fromText(formatString, Spec.NONE, '>', inliningTarget); validateSpec(inliningTarget, spec, raiseNode); @@ -773,14 +773,14 @@ private static TruffleString doFormat(Node raisingNode, double real, double imag return formatter.pad().getResult(); } - private static void validateSpec(Node inliningTarget, Spec spec, PRaiseNode.Lazy raiseNode) { + private static void validateSpec(Node inliningTarget, Spec spec, PRaiseNode raiseNode) { if (spec.getFill(' ') == '0') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ZERO_PADDING_NOT_ALLOWED_FOR_COMPLEX_FMT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ZERO_PADDING_NOT_ALLOWED_FOR_COMPLEX_FMT); } char align = spec.getAlign('>'); if (align == '=') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.S_ALIGNMENT_FLAG_NOT_ALLOWED_FOR_COMPLEX_FMT, align); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.S_ALIGNMENT_FLAG_NOT_ALLOWED_FOR_COMPLEX_FMT, align); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java index c63dbeaa3a..9fa115934f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java @@ -101,7 +101,7 @@ public abstract static class GetContextVar extends MpSubscriptBuiltinNode { @Specialization Object get(PContextVarsContext self, Object key, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { return getContextVar(inliningTarget, self, key, null, raise); } } @@ -154,7 +154,7 @@ static Object get(VirtualFrame frame, PContextVarsContext self, Object fun, Obje @Bind("this") Node inliningTarget, @Bind PythonContext context, @Cached CallNode call, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { PythonContext.PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); self.enter(inliningTarget, threadState, raise); try { @@ -185,7 +185,7 @@ public abstract static class GetMethod extends PythonBuiltinNode { Object doGetDefault(PContextVarsContext self, Object key, Object def, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile noValueProfile, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { Object defVal = noValueProfile.profile(inliningTarget, isNoValue(def)) ? PNone.NONE : def; return getContextVar(inliningTarget, self, key, defVal, raise); } @@ -197,20 +197,21 @@ Object doGetDefault(PContextVarsContext self, Object key, Object def, public abstract static class Contains extends PythonBuiltinNode { @Specialization boolean doIn(PContextVarsContext self, Object key, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raise) { if (key instanceof PContextVar var) { return self.contextVarValues.lookup(var, var.getHash()) != null; } - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CONTEXTVAR_KEY_EXPECTED, key); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CONTEXTVAR_KEY_EXPECTED, key); } } - private static Object getContextVar(Node inliningTarget, PContextVarsContext self, Object key, Object def, PRaiseNode.Lazy raise) { + private static Object getContextVar(Node inliningTarget, PContextVarsContext self, Object key, Object def, PRaiseNode raise) { if (key instanceof PContextVar ctxVar) { Object value = self.contextVarValues.lookup(key, ctxVar.getHash()); if (value == null) { if (def == null) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, new Object[]{key}); + throw raise.raise(inliningTarget, PythonBuiltinClassType.KeyError, new Object[]{key}); } else { return def; } @@ -218,7 +219,7 @@ private static Object getContextVar(Node inliningTarget, PContextVarsContext sel return value; } } else { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CONTEXTVAR_KEY_EXPECTED, key); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CONTEXTVAR_KEY_EXPECTED, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java index cb57c10bfd..6b2da34c1c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java @@ -83,10 +83,10 @@ public abstract static class Next extends PythonUnaryBuiltinNode { static Object next(PContextIterator self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object next = self.next(language); if (next == null) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } else { return next; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java index 9ed2bcdb6f..f5e6d5c1e1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java @@ -84,7 +84,7 @@ public abstract static class GetNode extends PythonBinaryBuiltinNode { static Object get(PContextVar self, Object def, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile defIsNoValueProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object defValue = defIsNoValueProfile.profile(inliningTarget, isNoValue(def)) ? PContextVar.NO_DEFAULT : def; PythonContext context = PythonContext.get(inliningTarget); PythonContext.PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); @@ -92,7 +92,7 @@ static Object get(PContextVar self, Object def, if (value != null) { return value; } - throw raiseNode.get(inliningTarget).raise(LookupError); + throw raiseNode.raise(inliningTarget, LookupError); } } @@ -118,7 +118,7 @@ public abstract static class ResetNode extends PythonBinaryBuiltinNode { static Object reset(PContextVar self, PContextVarsToken token, @Bind("this") Node inliningTarget, @Bind PythonContext pythonContext, - @Shared @Cached PRaiseNode.Lazy raise) { + @Shared @Cached PRaiseNode raise) { if (self == token.getVar()) { token.use(inliningTarget, raise); PythonContext.PythonThreadState threadState = pythonContext.getThreadState(pythonContext.getLanguage(inliningTarget)); @@ -129,7 +129,7 @@ static Object reset(PContextVar self, PContextVarsToken token, self.setValue(threadState, token.getOldValue()); } } else { - throw raise.get(inliningTarget).raise(ValueError, ErrorMessages.TOKEN_FOR_DIFFERENT_CONTEXTVAR, token); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.TOKEN_FOR_DIFFERENT_CONTEXTVAR, token); } return PNone.NONE; } @@ -137,8 +137,8 @@ static Object reset(PContextVar self, PContextVarsToken token, @Specialization(guards = "!isToken(token)") Object doError(@SuppressWarnings("unused") PContextVar self, Object token, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raise) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.INSTANCE_OF_TOKEN_EXPECTED, token); + @Shared @Cached PRaiseNode raise) { + throw raise.raise(inliningTarget, TypeError, ErrorMessages.INSTANCE_OF_TOKEN_EXPECTED, token); } static boolean isToken(Object obj) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsContext.java index d26463bb45..9896cf8266 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -52,9 +52,9 @@ public class PContextVarsContext extends PythonBuiltinObject { Hamt contextVarValues; private PContextVarsContext previousContext = null; - public void enter(Node inliningTarget, PythonContext.PythonThreadState threadState, PRaiseNode.Lazy raise) { + public void enter(Node inliningTarget, PythonContext.PythonThreadState threadState, PRaiseNode raise) { if (previousContext != null) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_ENTER_CONTEXT_ALREADY_ENTERED, this); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_ENTER_CONTEXT_ALREADY_ENTERED, this); } previousContext = threadState.getContextVarsContext(); assert previousContext != null : "ThreadState had null Context. This should not happen"; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsToken.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsToken.java index 1c0e80d1a8..ea4b0c6c90 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsToken.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVarsToken.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -60,9 +60,9 @@ public PContextVarsToken(PContextVar var, Object oldValue, Object cls, Shape ins this.oldValue = oldValue; } - public void use(Node inliningTarget, PRaiseNode.Lazy raise) { + public void use(Node inliningTarget, PRaiseNode raise) { if (used) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.TOKEN_ALREADY_USED, this); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.TOKEN_ALREADY_USED, this); } used = true; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java index b9ad4d96ac..2715e62fde 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java @@ -204,12 +204,12 @@ static PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object @Exclusive @Cached GetNextNode getNextNode, @Exclusive @Cached IsBuiltinObjectProfile isTypeErrorProfile, @Exclusive @Cached IsBuiltinObjectProfile isStopIterationProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!PGuards.isPNone(maxlenObj)) { try { int maxlen = castToIntNode.execute(inliningTarget, maxlenObj); if (maxlen < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MAXLEN_MUST_BE_NONNEG); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MAXLEN_MUST_BE_NONNEG); } self.setMaxLength(maxlen); } catch (PException e) { @@ -218,9 +218,9 @@ static PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object * OverflowError */ e.expect(inliningTarget, TypeError, isTypeErrorProfile); - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } } @@ -318,7 +318,7 @@ int doGeneric(PDeque self, Object value) { n++; } if (startState != self.getState()) { - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); } } return n; @@ -405,7 +405,7 @@ public abstract static class DequeIndexNode extends PythonQuaternaryBuiltinNode static int doWithoutSlice(VirtualFrame frame, PDeque self, Object value, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone stop, @Bind("this") Node inliningTarget, @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doWithIntSlice(frame, self, value, 0, self.getSize(), inliningTarget, eqNode, raiseNode); } @@ -413,7 +413,7 @@ static int doWithoutSlice(VirtualFrame frame, PDeque self, Object value, @Suppre static int doWithIntSlice(VirtualFrame frame, PDeque self, Object value, int start, int stop, @Bind("this") Node inliningTarget, @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int size = self.getSize(); int normStart = normalize(start, size); int normStop = normalize(stop, size); @@ -436,11 +436,11 @@ static int doWithIntSlice(VirtualFrame frame, PDeque self, Object value, int sta return idx; } if (startState != self.getState()) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); } } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.S_IS_NOT_DEQUE, value); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.S_IS_NOT_DEQUE, value); } @Specialization @@ -450,7 +450,7 @@ static int doGeneric(VirtualFrame frame, PDeque self, Object value, Object start @Cached CastToJavaIntExactNode castToIntNode, @Cached PyNumberAsSizeNode startIndexNode, @Cached PyNumberAsSizeNode stopIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int istart; int istop; if (start != PNone.NO_VALUE) { @@ -496,7 +496,7 @@ protected ArgumentClinicProvider getArgumentClinic() { PNone doGeneric(PDeque self, int index, Object value) { int n = self.getSize(); if (self.getMaxLength() == n) { - throw PRaiseNode.raiseUncached(this, IndexError, ErrorMessages.DEQUE_AT_MAX_SIZE); + throw PRaiseNode.raiseStatic(this, IndexError, ErrorMessages.DEQUE_AT_MAX_SIZE); } // shortcuts for simple cases @@ -526,10 +526,10 @@ public abstract static class DequePopNode extends PythonUnaryBuiltinNode { @Specialization static Object doGeneric(PDeque self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object value = self.pop(); if (value == null) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.POP_FROM_EMPTY_DEQUE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.POP_FROM_EMPTY_DEQUE); } return value; } @@ -543,10 +543,10 @@ public abstract static class DequePopLeftNode extends PythonUnaryBuiltinNode { @Specialization static Object doGeneric(PDeque self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object value = self.popLeft(); if (value == null) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.POP_FROM_EMPTY_DEQUE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.POP_FROM_EMPTY_DEQUE); } return value; } @@ -566,7 +566,7 @@ Object doGeneric(PDeque self, Object value) { try { boolean result = PyObjectRichCompareBool.EqNode.compareUncached(self.peekLeft(), value); if (n != self.getSize()) { - throw PRaiseNode.raiseUncached(this, IndexError, DEQUE_MUTATED_DURING_REMOVE); + throw PRaiseNode.raiseStatic(this, IndexError, DEQUE_MUTATED_DURING_REMOVE); } if (result) { Object removed = self.popLeft(); @@ -586,7 +586,7 @@ Object doGeneric(PDeque self, Object value) { throw e; } } - throw PRaiseNode.raiseUncached(this, ValueError, DEQUE_REMOVE_X_NOT_IN_DEQUE); + throw PRaiseNode.raiseStatic(this, ValueError, DEQUE_REMOVE_X_NOT_IN_DEQUE); } } @@ -734,9 +734,9 @@ static PDeque doDeque(PDeque self, PDeque other) { @Specialization(replaces = "doDeque") static PDeque doGeneric(PDeque self, Object other, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(other instanceof PDeque)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_CONCATENATE_DEQUE_NOT_P_TO_DEQUE, other); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_CONCATENATE_DEQUE_NOT_P_TO_DEQUE, other); } return doDeque(self, (PDeque) other); } @@ -770,7 +770,7 @@ static PDeque doGeneric(Node node, PDeque self, int n) { } if (size > Integer.MAX_VALUE / n) { - throw PRaiseNode.raiseUncached(node, MemoryError); + throw PRaiseNode.raiseStatic(node, MemoryError); } // Reduce the number of repetitions when maxlen would be exceeded @@ -814,7 +814,7 @@ boolean doGeneric(PDeque self, Object value) { return true; } if (startState != self.getState()) { - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); } } return false; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java index 4f247352db..f0db1b3b0b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java @@ -104,7 +104,7 @@ Object doGeneric(PDequeIter self) { if (self.startState == self.deque.getState()) { if (!self.hasNext()) { assert self.lengthHint() == 0; - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.StopIteration); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.StopIteration); } return self.next(); } @@ -114,7 +114,7 @@ Object doGeneric(PDequeIter self) { // fall through } self.reset(); - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.DEQUE_MUTATED_DURING_ITERATION); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java index 808dfc44b6..6aa6a1a045 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java @@ -151,9 +151,8 @@ static PDefaultDict copy(@SuppressWarnings("unused") VirtualFrame frame, PDefaul public abstract static class MissingNode extends PythonBinaryBuiltinNode { @Specialization(guards = "isNone(self.getDefaultFactory())") static Object doNoFactory(@SuppressWarnings("unused") PDefaultDict self, Object key, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, new Object[]{key}); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.KeyError, new Object[]{key}); } @Specialization(guards = "!isNone(self.getDefaultFactory())") @@ -175,13 +174,13 @@ static Object doInit(VirtualFrame frame, PDefaultDict self, Object[] args, PKeyw @Bind("this") Node inliningTarget, @Cached DictBuiltins.InitNode dictInitNode, @Cached PyCallableCheckNode callableCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] newArgs = args; Object newDefault = PNone.NONE; if (newArgs.length > 0) { newDefault = newArgs[0]; if (newDefault != PNone.NONE && !callableCheckNode.execute(inliningTarget, newDefault)) { - throw raiseNode.get(inliningTarget).raise(TypeError, FIRST_ARG_MUST_BE_CALLABLE_S, " or None"); + throw raiseNode.raise(inliningTarget, TypeError, FIRST_ARG_MUST_BE_CALLABLE_S, " or None"); } newArgs = PythonUtils.arrayCopyOfRange(args, 1, args.length); } @@ -216,7 +215,7 @@ static Object or(VirtualFrame frame, PDict self, PDict other, @Cached GetClassNode getClassNode, @Cached CallNode callNode, @Cached DictNodes.UpdateNode updateNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PDefaultDict dd = (PDefaultDict) (self instanceof PDefaultDict ? self : other); Object type = getClassNode.execute(inliningTarget, dd); Object result = callNode.execute(frame, type, dd.getDefaultFactory(), self); @@ -225,7 +224,7 @@ static Object or(VirtualFrame frame, PDict self, PDict other, return result; } else { /* Cpython doesn't check for this and ends up with SystemError */ - throw raiseNode.get(inliningTarget).raise(TypeError); + throw raiseNode.raise(inliningTarget, TypeError); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java index d831723eb7..325a06fd49 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java @@ -179,7 +179,7 @@ static Object doEmpty(Object self, Object[] args, PKeyword[] kwargs) { @Specialization(guards = "args.length > 1") Object doGeneric(@SuppressWarnings("unused") Object self, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs) { - throw raise(TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, "dict", 1, args.length); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, "dict", 1, args.length); } } @@ -212,14 +212,14 @@ static Object popDefault(VirtualFrame frame, Object dict, Object key, Object def @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached InlinedConditionProfile hasKeyProfile, @Cached HashingStorageDelItem delItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var storage = getStorageNode.execute(inliningTarget, dict); Object retVal = delItem.executePop(frame, inliningTarget, storage, key, dict); if (hasKeyProfile.profile(inliningTarget, retVal != null)) { return retVal; } else { if (PGuards.isNoValue(defaultValue)) { - throw raiseNode.get(inliningTarget).raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } else { return defaultValue; } @@ -238,11 +238,11 @@ static Object popItem(Object dict, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStoragePop popNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var storage = getStorageNode.execute(inliningTarget, dict); Object[] result = popNode.execute(inliningTarget, storage, dict); if (result == null) { - throw raiseNode.get(inliningTarget).raise(KeyError, ErrorMessages.IS_EMPTY, "popitem(): dictionary"); + throw raiseNode.raise(inliningTarget, KeyError, ErrorMessages.IS_EMPTY, "popitem(): dictionary"); } return PFactory.createTuple(language, result); } @@ -314,13 +314,13 @@ Object getItem(VirtualFrame frame, Object self, Object key, var storage = getStorageNode.execute(inliningTarget, self); final Object result = getItem.execute(frame, inliningTarget, storage, key); if (notFoundProfile.profile(inliningTarget, result == null)) { - return handleMissing(frame, self, key, raiseNode); + return handleMissing(frame, inliningTarget, self, key, raiseNode); } return result; } @InliningCutoff - private Object handleMissing(VirtualFrame frame, Object self, Object key, PRaiseNode raiseNode) { + private Object handleMissing(VirtualFrame frame, Node inliningTarget, Object self, Object key, PRaiseNode raiseNode) { if (self instanceof PDict dict && !PGuards.isBuiltinDict(dict)) { if (missing == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -328,7 +328,7 @@ private Object handleMissing(VirtualFrame frame, Object self, Object key, PRaise } return missing.execute(frame, dict, key); } - throw raiseNode.raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } } @@ -342,10 +342,10 @@ protected abstract static class DispatchMissingNode extends Node { static Object missing(VirtualFrame frame, Object self, Object key, @Bind("this") Node inliningTarget, @Cached("create(Missing)") LookupAndCallBinaryNode callMissing, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = callMissing.executeObject(frame, self, key); if (result == PNotImplemented.NOT_IMPLEMENTED) { - throw raiseNode.get(inliningTarget).raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } return result; } @@ -366,10 +366,10 @@ static void run(VirtualFrame frame, Object self, Object key, @SuppressWarnings(" @Bind("this") Node inliningTarget, @Cached DictNodes.GetDictStorageNode getStorageNode, @Cached HashingStorageDelItem delItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { var storage = getStorageNode.execute(inliningTarget, self); if (!delItem.execute(frame, inliningTarget, storage, key, self)) { - throw raiseNode.get(inliningTarget).raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } } } @@ -550,8 +550,8 @@ static Object update(VirtualFrame frame, Object self, Object[] args, PKeyword[] @Specialization(guards = "args.length > 1") @SuppressWarnings("unused") static Object error(Object self, Object[] args, PKeyword[] kwargs, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, "update", 1, args.length); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, "update", 1, args.length); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictNodes.java index 2ef65b2cac..39eb1e090f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -103,9 +103,8 @@ static HashingStorage doForeign(Node inliningTarget, Object dict, } @Fallback - static HashingStorage doFallback(Node inliningTarget, Object object, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "dict", object); + static HashingStorage doFallback(Node inliningTarget, Object object) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "dict", object); } } @@ -183,14 +182,14 @@ public static void updateDictGeneric(VirtualFrame frame, Node inliningTarget, Ob @Cached HashingStorageGetIterator getOtherIter, @Cached HashingStorageIteratorNext iterNext, @Cached HashingStorageLen otherLenNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int initialSize = otherLenNode.execute(inliningTarget, otherStorage); HashingStorageIterator itOther = getOtherIter.execute(inliningTarget, otherStorage); var newStorage = selfStorage; while (iterNext.execute(inliningTarget, otherStorage, itOther)) { newStorage = transferItem.execute(frame, inliningTarget, otherStorage, itOther, newStorage); if (initialSize != otherLenNode.execute(inliningTarget, otherStorage)) { - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.MUTATED_DURING_UPDATE, "dict"); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.MUTATED_DURING_UPDATE, "dict"); } } updateStorageNode.execute(inliningTarget, self, selfStorage, newStorage); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java index 4da9323000..2dda3e591f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -139,12 +139,12 @@ protected final int getLimit() { protected static TruffleString getReprString(Node inliningTarget, Object obj, ReprState s, LookupAndCallUnaryDynamicNode reprNode, CastToTruffleStringNode castStr, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object reprObj = s == null || obj != s.self ? reprNode.executeObject(obj, T___REPR__) : T_ELLIPSIS_IN_BRACES; try { return castStr.execute(inliningTarget, reprObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.RETURNED_NON_STRING, "__repr__", reprObj); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.RETURNED_NON_STRING, "__repr__", reprObj); } } @@ -165,7 +165,7 @@ public static ReprState append(@SuppressWarnings("unused") Node node, HashingSto @Bind("this") Node inliningTarget, @Cached LookupAndCallUnaryDynamicNode reprNode, @Cached CastToTruffleStringNode castStr, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached InlinedConditionProfile lengthCheck, @Cached HashingStorageIteratorKey itKey, @Cached TruffleStringBuilder.AppendStringNode appendStringNode) { @@ -186,7 +186,7 @@ public static ReprState dict(Frame frame, @SuppressWarnings("unused") Node node, @Bind("this") Node inliningTarget, @Cached LookupAndCallUnaryDynamicNode reprNode, @Cached CastToTruffleStringNode castStr, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached InlinedConditionProfile lengthCheck, @Cached HashingStorageIteratorValue itValue, @Cached TruffleStringBuilder.AppendStringNode appendStringNode) { @@ -208,7 +208,7 @@ public static ReprState dict(Frame frame, @SuppressWarnings("unused") Node node, @Cached LookupAndCallUnaryDynamicNode keyReprNode, @Cached LookupAndCallUnaryDynamicNode valueReprNode, @Cached CastToTruffleStringNode castStr, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached InlinedConditionProfile lengthCheck, @Cached HashingStorageIteratorKey itKey, @Cached HashingStorageIteratorValue itValue, @@ -236,7 +236,7 @@ public static ReprState dict(Frame frame, @SuppressWarnings("unused") Node node, @Cached LookupAndCallUnaryDynamicNode keyReprNode, @Cached LookupAndCallUnaryDynamicNode valueReprNode, @Cached CastToTruffleStringNode castStr, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached InlinedConditionProfile lengthCheck, @Cached HashingStorageIteratorKey itKey, @Cached HashingStorageIteratorValue itValue, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java index dd9ab9aa4d..cd0b6eea75 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java @@ -159,10 +159,12 @@ Object doWithArguments(PBaseException self, Object[] args, @SuppressWarnings("un } @Specialization(replaces = {"doNoArguments", "doWithArguments"}) - Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords, - @Bind PythonLanguage language) { + static Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords, + @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached PRaiseNode raiseNode) { if (keywords.length != 0) { - throw raise(TypeError, P_TAKES_NO_KEYWORD_ARGS, self); + throw raiseNode.raise(inliningTarget, TypeError, P_TAKES_NO_KEYWORD_ARGS, self); } if (args.length == 0) { self.setArgs(null); @@ -173,12 +175,13 @@ Object doGeneric(PBaseException self, Object[] args, PKeyword[] keywords, } @Specialization - Object doNative(PythonAbstractNativeObject self, Object[] args, PKeyword[] keywords, + static Object doNative(PythonAbstractNativeObject self, Object[] args, PKeyword[] keywords, @Bind("this") Node inliningTarget, @Cached ExceptionNodes.SetArgsNode setArgsNode, - @Bind PythonLanguage language) { + @Bind PythonLanguage language, + @Cached PRaiseNode raiseNode) { if (keywords.length != 0) { - throw raise(TypeError, P_TAKES_NO_KEYWORD_ARGS, self); + throw raiseNode.raise(inliningTarget, TypeError, P_TAKES_NO_KEYWORD_ARGS, self); } if (args.length == 0) { setArgsNode.execute(inliningTarget, self, PFactory.createEmptyTuple(language)); @@ -242,10 +245,9 @@ public static Object setCause(Object self, @SuppressWarnings("unused") PNone val @Specialization(guards = {"!isNoValue(value)", "!check.execute(inliningTarget, value)"}) public static Object cause(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object value, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached PyExceptionInstanceCheckNode check, - @Cached PRaiseNode raise) { - throw raise.raise(TypeError, ErrorMessages.EXCEPTION_CAUSE_MUST_BE_NONE_OR_DERIVE_FROM_BASE_EX); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXCEPTION_CAUSE_MUST_BE_NONE_OR_DERIVE_FROM_BASE_EX); } } @@ -278,10 +280,9 @@ public static Object setContext(Object self, @SuppressWarnings("unused") PNone v @Specialization(guards = {"!isNoValue(value)", "!check.execute(inliningTarget, value)"}) public static Object context(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object value, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached PyExceptionInstanceCheckNode check, - @Cached PRaiseNode raise) { - throw raise.raise(TypeError, ErrorMessages.EXCEPTION_CONTEXT_MUST_BE_NONE_OR_DERIVE_FROM_BASE_EX); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXCEPTION_CONTEXT_MUST_BE_NONE_OR_DERIVE_FROM_BASE_EX); } } @@ -300,12 +301,12 @@ static Object setSuppressContext(Object self, Object valueObj, @Bind("this") Node inliningTarget, @Cached ExceptionNodes.SetSuppressContextNode setSuppressContextNode, @Cached CastToJavaBooleanNode castToJavaBooleanNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean value; try { value = castToJavaBooleanNode.execute(inliningTarget, valueObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ATTR_VALUE_MUST_BE_BOOL); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ATTR_VALUE_MUST_BE_BOOL); } setSuppressContextNode.execute(inliningTarget, self, value); return PNone.NONE; @@ -341,8 +342,8 @@ static Object setTraceback(Object self, PTraceback tb, @Fallback static Object setTraceback(@SuppressWarnings("unused") Object self, @SuppressWarnings("unused") Object tb, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.MUST_BE_S_OR_S, "__traceback__", "a traceback", "None"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.MUST_BE_S_OR_S, "__traceback__", "a traceback", "None"); } } @@ -387,8 +388,8 @@ static Object dict(Object self, @SuppressWarnings("unused") PNone mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static PNone dict(@SuppressWarnings("unused") Object self, Object mapping, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } } @@ -522,9 +523,9 @@ static Object setDict(VirtualFrame frame, Object self, PDict state, @Specialization(guards = "!isDict(state)") static Object generic(@SuppressWarnings("unused") Object self, Object state, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (state != PNone.NONE) { - throw raiseNode.get(inliningTarget).raise(TypeError, STATE_IS_NOT_A_DICT); + throw raiseNode.raise(inliningTarget, TypeError, STATE_IS_NOT_A_DICT); } return PNone.NONE; } @@ -541,9 +542,9 @@ Object addNote(VirtualFrame frame, Object self, Object note, @Cached PyObjectSetAttr setAttr, @Cached ListNodes.AppendNode appendNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!unicodeCheckNode.execute(inliningTarget, note)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOTE_MUST_BE_A_STR_NOT_P, note); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOTE_MUST_BE_A_STR_NOT_P, note); } Object notes = lookupAttr.execute(frame, inliningTarget, self, T___NOTES__); if (notes == PNone.NO_VALUE) { @@ -553,7 +554,7 @@ Object addNote(VirtualFrame frame, Object self, Object note, if (notes instanceof PList notesList) { appendNode.execute(notesList, note); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_ADD_NOTE_NOTES_IS_NOT_A_LIST); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_ADD_NOTE_NOTES_IS_NOT_A_LIST); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java index 3192501836..ecd281fc2f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java @@ -189,7 +189,7 @@ private static PBaseExceptionGroup subset(Node inliningTarget, PBaseExceptionGro } Object egObj = PyObjectCallMethodObjArgs.executeUncached(orig, T_DERIVE, PFactory.createTuple(PythonLanguage.get(null), exceptions)); if (!(egObj instanceof PBaseExceptionGroup eg)) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.DERIVE_MUST_RETURN_AN_INSTANCE_OF_BASE_EXCEPTION_GROUP); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DERIVE_MUST_RETURN_AN_INSTANCE_OF_BASE_EXCEPTION_GROUP); } Object tb = ExceptionNodes.GetTracebackNode.executeUncached(orig); if (tb instanceof PTraceback) { @@ -230,12 +230,12 @@ private static MatcherType getMatcherType(Node inliningTarget, Object value) { for (int i = 0; i < storage.length(); i++) { Object elem = SequenceStorageNodes.GetItemScalarNode.executeUncached(storage, i); if (!isExceptionTypeUncached(elem)) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.EXPECTED_A_FUNCTION_EXCEPTION_TYPE_OR_TUPLE_OF_EXCEPTION_TYPES); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_A_FUNCTION_EXCEPTION_TYPE_OR_TUPLE_OF_EXCEPTION_TYPES); } } return MatcherType.BY_TYPE; } - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.EXPECTED_A_FUNCTION_EXCEPTION_TYPE_OR_TUPLE_OF_EXCEPTION_TYPES); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_A_FUNCTION_EXCEPTION_TYPE_OR_TUPLE_OF_EXCEPTION_TYPES); } private static boolean isExceptionTypeUncached(Object value) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java index 4a8bbdadcb..7765db96c0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ExceptionNodes.java @@ -157,7 +157,7 @@ static void doNative(Node inliningTarget, PythonAbstractNativeObject exception, @Specialization @SuppressWarnings("unused") static void doInterop(Node inliningTarget, AbstractTruffleException exception, Object value) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); } } @@ -221,7 +221,7 @@ static void doNative(Node inliningTarget, PythonAbstractNativeObject exception, @Specialization @SuppressWarnings("unused") static void doInterop(Node inliningTarget, AbstractTruffleException exception, Object value) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); } } @@ -280,7 +280,7 @@ static void doNative(@SuppressWarnings("unused") Node inliningTarget, PythonAbst @Specialization @SuppressWarnings("unused") static void doInterop(Node inliningTarget, AbstractTruffleException exception, boolean value) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); } } @@ -352,7 +352,7 @@ static void doNative(Node inliningTarget, PythonAbstractNativeObject exception, @Specialization @SuppressWarnings("unused") static void doInterop(Node inliningTarget, AbstractTruffleException exception, Object value) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); } } @@ -479,7 +479,7 @@ static void doNative(@SuppressWarnings("unused") Node inliningTarget, PythonAbst @Specialization @SuppressWarnings("unused") static void doInterop(Node inliningTarget, AbstractTruffleException exception, PTuple argsTuple) { - throw PRaiseNode.raiseUncached(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_SET_PROPERTY_ON_INTEROP_EXCEPTION); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java index 5622884d95..bb42438e2a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java @@ -64,6 +64,7 @@ import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.lib.PyUnicodeCheckExactNode; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; @@ -133,9 +134,11 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, } @Specialization - Object init(PBaseException self, Object[] args, PKeyword[] kwargs, + static Object init(PBaseException self, Object[] args, PKeyword[] kwargs, + @Bind("this") Node inliningTarget, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode, - @Cached TruffleString.EqualNode equalNode) { + @Cached TruffleString.EqualNode equalNode, + @Cached PRaiseNode raiseNode) { baseExceptionInitNode.execute(self, args); Object[] attrs = IMPORT_ERROR_ATTR_FACTORY.create(args); for (PKeyword kw : kwargs) { @@ -145,7 +148,7 @@ Object init(PBaseException self, Object[] args, PKeyword[] kwargs, } else if (equalNode.execute(kwName, PATH, TS_ENCODING)) { attrs[IDX_PATH] = kw.getValue(); } else { - throw raise(PythonBuiltinClassType.TypeError, S_IS_AN_INVALID_ARG_FOR_S, kw.getName(), "ImportError"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_IS_AN_INVALID_ARG_FOR_S, kw.getName(), "ImportError"); } } self.setExceptionAttributes(attrs); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java index 0ce7bf5ca3..fcef70114f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java @@ -277,13 +277,13 @@ static Object newCData(VirtualFrame frame, Object subType, Object[] args, PKeywo @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = subType; Object[] parsedArgs = new Object[IDX_WRITTEN + 1]; final Python3Core core = PythonContext.get(inliningTarget); if (!osErrorUseInit(frame, inliningTarget, core, type, getAttr)) { if (kwds.length != 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, P_TAKES_NO_KEYWORD_ARGS, type); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, P_TAKES_NO_KEYWORD_ARGS, type); } parsedArgs = osErrorParseArgs(args, inliningTarget, checkPositionalNode); @@ -322,7 +322,7 @@ static Object initNoArgs(VirtualFrame frame, PBaseException self, Object[] args, @Cached PyNumberAsSizeNode pyNumberAsSizeNode, @Cached PyArgCheckPositionalNode checkPositionalNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final Object type = getClassNode.execute(inliningTarget, self); if (!osErrorUseInit(frame, inliningTarget, PythonContext.get(inliningTarget), type, getAttr)) { // Everything already done in OSError_new @@ -330,7 +330,7 @@ static Object initNoArgs(VirtualFrame frame, PBaseException self, Object[] args, } if (kwds.length != 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, P_TAKES_NO_KEYWORD_ARGS, type); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, P_TAKES_NO_KEYWORD_ARGS, type); } Object[] parsedArgs = osErrorParseArgs(args, inliningTarget, checkPositionalNode); @@ -411,8 +411,8 @@ boolean isInvalid(PBaseException self) { @Specialization(guards = "isInvalid(self)") @SuppressWarnings("unused") static Object generic(PBaseException self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.CHARACTERS_WRITTEN); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.CHARACTERS_WRITTEN); } @Specialization(guards = "!isInvalid(self)") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java index 6eb9abba49..bc6cf47604 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/PrepareExceptionNode.java @@ -91,10 +91,9 @@ static Object doException(PythonAbstractNativeObject exc, @SuppressWarnings("unu @Specialization(guards = {"check.execute(inliningTarget, exc)", "!isPNone(value)"}) static Object doException(@SuppressWarnings("unused") PBaseException exc, @SuppressWarnings("unused") Object value, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared @Cached PyExceptionInstanceCheckNode check, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.INSTANCE_EX_MAY_NOT_HAVE_SEP_VALUE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INSTANCE_EX_MAY_NOT_HAVE_SEP_VALUE); } @Specialization(guards = {"isTypeNode.execute(inliningTarget, type)", "!isPNone(value)", "!isPTuple(value)"}, limit = "1") @@ -107,7 +106,7 @@ static Object doExceptionOrCreate(VirtualFrame frame, Object type, Object value, @Shared @Cached IsSubtypeNode isSubtypeNode, @Shared @Cached PRaiseNode raiseNode, @Shared("callCtor") @Cached CallNode callConstructor) { - checkExceptionClass(type, isSubtypeNode, raiseNode); + checkExceptionClass(inliningTarget, type, isSubtypeNode, raiseNode); if (isInstanceProfile.profile(inliningTarget, isInstanceNode.executeWith(frame, value, type))) { return value; } else { @@ -128,7 +127,7 @@ static Object doCreate(VirtualFrame frame, Object type, @SuppressWarnings("unuse @Shared @Cached IsSubtypeNode isSubtypeNode, @Shared @Cached PRaiseNode raiseNode, @Shared("callCtor") @Cached CallNode callConstructor) { - checkExceptionClass(type, isSubtypeNode, raiseNode); + checkExceptionClass(inliningTarget, type, isSubtypeNode, raiseNode); Object instance = callConstructor.execute(frame, type); if (check.execute(inliningTarget, instance)) { return instance; @@ -146,7 +145,7 @@ static Object doCreateTuple(VirtualFrame frame, Object type, PTuple value, @Shared @Cached IsSubtypeNode isSubtypeNode, @Shared @Cached PRaiseNode raiseNode, @Shared("callCtor") @Cached CallNode callConstructor) { - checkExceptionClass(type, isSubtypeNode, raiseNode); + checkExceptionClass(inliningTarget, type, isSubtypeNode, raiseNode); Object[] args = getObjectArrayNode.execute(inliningTarget, value); Object instance = callConstructor.execute(frame, type, args); if (check.execute(inliningTarget, instance)) { @@ -159,9 +158,8 @@ static Object doCreateTuple(VirtualFrame frame, Object type, PTuple value, @Specialization(guards = "fallbackGuard(type, inliningTarget, isTypeNode)", limit = "1") static Object doError(Object type, @SuppressWarnings("unused") Object value, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.EXCEPTIONS_MUST_BE_CLASSES_OR_INSTANCES_DERIVING_FROM_BASE_EX, type); + @SuppressWarnings("unused") @Exclusive @Cached IsTypeNode isTypeNode) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXCEPTIONS_MUST_BE_CLASSES_OR_INSTANCES_DERIVING_FROM_BASE_EX, type); } static boolean fallbackGuard(Object type, Node inliningTarget, IsTypeNode isTypeNode) { @@ -176,9 +174,9 @@ private static PBaseException handleInstanceNotAnException(Object type, Object i return PFactory.createBaseException(PythonLanguage.get(null), TypeError, ErrorMessages.CALLING_N_SHOULD_HAVE_RETURNED_AN_INSTANCE_OF_BASE_EXCEPTION_NOT_P, new Object[]{type, instance}); } - private static void checkExceptionClass(Object type, IsSubtypeNode isSubtypeNode, PRaiseNode raiseNode) { + private static void checkExceptionClass(Node inliningTarget, Object type, IsSubtypeNode isSubtypeNode, PRaiseNode raiseNode) { if (!isSubtypeNode.execute(type, PythonBuiltinClassType.PBaseException)) { - throw raiseNode.raise(TypeError, ErrorMessages.EXCEPTIONS_MUST_BE_CLASSES_OR_INSTANCES_DERIVING_FROM_BASE_EX, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXCEPTIONS_MUST_BE_CLASSES_OR_INSTANCES_DERIVING_FROM_BASE_EX, type); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java index 76c04f6394..509dc4c3ab 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java @@ -189,7 +189,7 @@ static Object init(VirtualFrame frame, PBaseException self, Object[] args, @Cached TupleNodes.ConstructTupleNode constructTupleNode, @Cached SequenceStorageNodes.GetItemNode getItemNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseExceptionInitNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { baseExceptionInitNode.execute(self, args); Object[] attrs = SYNTAX_ERROR_ATTR_FACTORY.create(); if (args.length >= 1) { @@ -200,7 +200,7 @@ static Object init(VirtualFrame frame, PBaseException self, Object[] args, final SequenceStorage storage = info.getSequenceStorage(); if (storage.length() != 4) { // not a very good error message, but it's what Python 2.4 gives - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, TUPLE_OUT_OF_BOUNDS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, TUPLE_OUT_OF_BOUNDS); } attrs[IDX_FILENAME] = getItemNode.execute(storage, 0); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java index a3d7b4c833..181595c89e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -110,7 +110,7 @@ static Object initNoArgs(VirtualFrame frame, PBaseException self, Object[] args, @Cached CastToTruffleStringNode toStringNode, @Cached CastToJavaIntExactNode toJavaIntExactNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { baseInitNode.execute(self, args); // PyArg_ParseTuple(args, "UOnnU"), TODO: add proper error messages self.setExceptionAttributes(new Object[]{ @@ -177,14 +177,14 @@ static PBaseException createNew(VirtualFrame frame, Node inliningTarget, @Suppre int endPos, TruffleString reason, @Cached(inline = false) CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = callNode.execute(frame, UnicodeDecodeError, encoding, inputObject, startPos, endPos, reason); if (obj instanceof PBaseException exception) { return exception; } // Shouldn't happen unless the user manually replaces the method, which is really // unexpected and shouldn't be permitted at all, but currently it is - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeDecodeError, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeDecodeError, obj); } @Specialization(guards = "exceptionObject != null") @@ -214,13 +214,13 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, PBaseException excep @Cached(inline = false) BaseExceptionAttrNode attrNode, @Cached GetClassNode getClassNode, @Cached(inline = false) IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = attrNode.get(exceptionObject, IDX_OBJECT, UNICODE_ERROR_ATTR_FACTORY); if (obj == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "object"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "object"); } if (!isSubtypeNode.execute(frame, getClassNode.execute(inliningTarget, obj), PythonBuiltinClassType.PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ATTRIBUTE_MUST_BE_BYTES, "object"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ATTRIBUTE_MUST_BE_BYTES, "object"); } return obj; } @@ -297,10 +297,10 @@ public abstract static class PyUnicodeDecodeErrorGetEncodingNode extends Node { static TruffleString doIt(Node inliningTarget, PBaseException exceptionObject, @Cached(inline = false) BaseExceptionAttrNode attrNode, @Cached CastToTruffleStringCheckedNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = attrNode.get(exceptionObject, IDX_ENCODING, UNICODE_ERROR_ATTR_FACTORY); if (obj == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "encoding"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "encoding"); } return castToStringNode.cast(inliningTarget, obj, ErrorMessages.S_ATTRIBUTE_MUST_BE_UNICODE, "encoding"); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java index 36f7588105..6ee7334eb3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -102,7 +102,7 @@ static Object initNoArgs(PBaseException self, Object[] args, @Cached CastToTruffleStringNode toStringNode, @Cached CastToJavaIntExactNode toJavaIntExactNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { baseInitNode.execute(self, args); // PyArg_ParseTuple(args, "UUnnU"), TODO: add proper error messages self.setExceptionAttributes(new Object[]{ @@ -178,14 +178,14 @@ static PBaseException createNew(VirtualFrame frame, Node inliningTarget, @Suppre int startPos, int endPos, TruffleString reason, @Cached(inline = false) CallNode callNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = callNode.execute(frame, UnicodeEncodeError, encoding, inputObject, startPos, endPos, reason); if (obj instanceof PBaseException exception) { return exception; } // Shouldn't happen unless the user manually replaces the method, which is really // unexpected and shouldn't be permitted at all, but currently it is - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeEncodeError, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, UnicodeEncodeError, obj); } @Specialization(guards = "exceptionObject != null") @@ -214,10 +214,10 @@ public abstract static class PyUnicodeEncodeOrTranslateErrorGetObjectNode extend static TruffleString doIt(Node inliningTarget, PBaseException exceptionObject, @Cached(inline = false) BaseExceptionAttrNode attrNode, @Cached CastToTruffleStringCheckedNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = attrNode.get(exceptionObject, IDX_OBJECT, UNICODE_ERROR_ATTR_FACTORY); if (obj == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "object"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "object"); } return castToStringNode.cast(inliningTarget, obj, ErrorMessages.S_ATTRIBUTE_MUST_BE_UNICODE, "object"); } @@ -294,10 +294,10 @@ public abstract static class PyUnicodeEncodeErrorGetEncodingNode extends Node { static TruffleString doIt(Node inliningTarget, PBaseException exceptionObject, @Cached(inline = false) BaseExceptionAttrNode attrNode, @Cached CastToTruffleStringCheckedNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object obj = attrNode.get(exceptionObject, IDX_ENCODING, UNICODE_ERROR_ATTR_FACTORY); if (obj == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "encoding"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_ATTRIBUTE_NOT_SET, "encoding"); } return castToStringNode.cast(inliningTarget, obj, ErrorMessages.S_ATTRIBUTE_MUST_BE_UNICODE, "encoding"); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java index 9420fe0832..38d08d7198 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeErrorBuiltins.java @@ -92,17 +92,17 @@ protected List> getNodeFa return UnicodeErrorBuiltinsFactory.getFactories(); } - public static TruffleString getArgAsString(Node inliningTarget, Object[] args, int index, PRaiseNode.Lazy raiseNode, CastToTruffleStringNode castNode) { + public static TruffleString getArgAsString(Node inliningTarget, Object[] args, int index, PRaiseNode raiseNode, CastToTruffleStringNode castNode) { if (args.length < index + 1 || !PGuards.isString(args[index])) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError); } else { return castNode.execute(inliningTarget, args[index]); } } - public static int getArgAsInt(Node inliningTarget, Object[] args, int index, PRaiseNode.Lazy raiseNode, CastToJavaIntExactNode castNode) { + public static int getArgAsInt(Node inliningTarget, Object[] args, int index, PRaiseNode raiseNode, CastToJavaIntExactNode castNode) { if (args.length < index + 1 || !(PGuards.isInteger(args[index]) || PGuards.isPInt(args[index]))) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError); } else { return castNode.execute(inliningTarget, args[index]); } @@ -143,9 +143,9 @@ static PBytes doOther(VirtualFrame frame, Object value, } } - public static Object getArgAsBytes(VirtualFrame frame, Node inliningTarget, Object[] args, int index, PRaiseNode.Lazy raiseNode, GetArgAsBytesNode getArgAsBytesNode) { + public static Object getArgAsBytes(VirtualFrame frame, Node inliningTarget, Object[] args, int index, PRaiseNode raiseNode, GetArgAsBytesNode getArgAsBytesNode) { if (args.length < index + 1) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError); } else { return getArgAsBytesNode.execute(frame, inliningTarget, args[index]); } @@ -209,8 +209,8 @@ static Object setPInt(PBaseException self, PInt value, @Specialization(guards = {"!isNoValue(value)", "!canBeInteger(value)"}) @SuppressWarnings("unused") static Object generic(PBaseException self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, INTEGER_REQUIRED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, INTEGER_REQUIRED); } } @@ -246,8 +246,8 @@ static Object setPInt(PBaseException self, PInt value, @Specialization(guards = {"!isNoValue(value)", "!canBeInteger(value)"}) @SuppressWarnings("unused") static Object generic(PBaseException self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, INTEGER_REQUIRED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, INTEGER_REQUIRED); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java index 3ffffd7c75..9e0eb7cafe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -96,7 +96,7 @@ static Object initNoArgs(PBaseException self, Object[] args, @Cached CastToTruffleStringNode toStringNode, @Cached CastToJavaIntExactNode toJavaIntExactNode, @Cached BaseExceptionBuiltins.BaseExceptionInitNode baseInitNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { baseInitNode.execute(self, args); // PyArg_ParseTuple(args, "UnnU"), TODO: add proper error messages self.setExceptionAttributes(new Object[]{ diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java index 8d15d6345f..fd44d02fcc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java @@ -115,6 +115,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.FromJavaStringNode; @@ -136,13 +137,13 @@ private static double castToDoubleChecked(Node inliningTarget, Object obj, CastT try { return cast.execute(inliningTarget, obj); } catch (CannotCastException e) { - throw raiseWrongSelf(obj); + throw raiseWrongSelf(inliningTarget, obj); } } @InliningCutoff - private static PException raiseWrongSelf(Object obj) { - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "float", obj); + private static PException raiseWrongSelf(Node inliningTarget, Object obj) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "float", obj); } @GenerateCached(false) @@ -165,7 +166,7 @@ Object doOther(Object object, @GenerateCached(false) abstract static class AbstractNumericBinaryBuiltin extends BinaryOpBuiltinNode { - @Child private PRaiseNode raiseNode; + private final BranchProfile errorProfile = BranchProfile.create(); protected abstract Object op(double a, double b); @@ -197,15 +198,8 @@ Object doOther(Object a, Object b, void raiseDivisionByZero(boolean cond) { if (cond) { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (isAdoptable()) { - raiseNode = insert(PRaiseNode.create()); - } else { - raiseNode = PRaiseNode.getUncached(); - } - } - throw raiseNode.raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } } } @@ -360,7 +354,7 @@ public final Object execute(double left, double right) { @Specialization static double doDI(double left, int right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doOperation(inliningTarget, left, right, raiseNode); } @@ -368,7 +362,7 @@ static double doDI(double left, int right, @SuppressWarnings("unused") PNone non * The special cases we need to deal with always return 1, so 0 means no special case, not a * result. */ - private static double doSpecialCases(Node inliningTarget, double left, double right, PRaiseNode.Lazy raiseNode) { + private static double doSpecialCases(Node inliningTarget, double left, double right, PRaiseNode raiseNode) { // see cpython://Objects/floatobject.c#float_pow for special cases if (Double.isNaN(right) && left == 1) { // 1**nan = 1, unlike on Java @@ -380,12 +374,12 @@ private static double doSpecialCases(Node inliningTarget, double left, double ri } if (left == 0 && right < 0 && Double.isFinite(right)) { // 0**w is an error if w is finite and negative, unlike Java - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } return 0; } - private static double doOperation(Node inliningTarget, double left, double right, PRaiseNode.Lazy raiseNode) { + private static double doOperation(Node inliningTarget, double left, double right, PRaiseNode raiseNode) { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { return 1.0; } @@ -397,7 +391,7 @@ private static double doOperation(Node inliningTarget, double left, double right static double doDD(VirtualFrame frame, double left, double right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Shared @Cached PyNumberPowerNode powerNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws UnexpectedResultException { + @Shared @Cached PRaiseNode raiseNode) throws UnexpectedResultException { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { return 1.0; } @@ -415,7 +409,7 @@ static double doDD(VirtualFrame frame, double left, double right, @SuppressWarni static Object doDDToComplex(VirtualFrame frame, double left, double right, PNone none, @Bind("this") Node inliningTarget, @Shared @Cached PyNumberPowerNode powerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (doSpecialCases(inliningTarget, left, right, raiseNode) == 1) { return 1.0; } @@ -433,9 +427,9 @@ static Object doGeneric(VirtualFrame frame, Object left, Object right, Object mo @Bind("this") Node inliningTarget, @Cached CastToJavaDoubleNode castToJavaDoubleNode, @Shared @Cached PyNumberPowerNode powerNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (!(mod instanceof PNone)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.POW_3RD_ARG_NOT_ALLOWED_UNLESS_INTEGERS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.POW_3RD_ARG_NOT_ALLOWED_UNLESS_INTEGERS); } double leftDouble, rightDouble; @@ -495,7 +489,7 @@ private double fromHex(String arg) { String str = arg.trim().toLowerCase(); if (str.isEmpty()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); + throw PRaiseNode.raiseStatic(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); } else if (str.equals("inf") || str.equals("infinity") || str.equals("+inf") || str.equals("+infinity")) { return Double.POSITIVE_INFINITY; } else if (str.equals("-inf") || str.equals("-infinity")) { @@ -512,7 +506,7 @@ private double fromHex(String arg) { } if (str.isEmpty()) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); + throw PRaiseNode.raiseStatic(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); } if (!str.startsWith("0x")) { @@ -530,12 +524,12 @@ private double fromHex(String arg) { try { double result = Double.parseDouble(str); if (Double.isInfinite(result)) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.OverflowError, ErrorMessages.HEX_VALUE_TOO_LARGE_AS_FLOAT); + throw PRaiseNode.raiseStatic(this, PythonErrorType.OverflowError, ErrorMessages.HEX_VALUE_TOO_LARGE_AS_FLOAT); } return result; } catch (NumberFormatException ex) { - throw PRaiseNode.raiseUncached(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); + throw PRaiseNode.raiseStatic(this, PythonErrorType.ValueError, ErrorMessages.INVALID_STRING); } } @@ -556,8 +550,8 @@ Object fromhexO(Object cl, TruffleString arg, @Fallback @SuppressWarnings("unused") static double fromhex(Object object, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } } @@ -675,14 +669,14 @@ private static double op(double x, int n) { @Specialization static double round(double x, int n, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (Double.isNaN(x) || Double.isInfinite(x) || x == 0.0) { // nans, infinities and zeros round to themselves return x; } double d = op(x, n); if (Double.isInfinite(d)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.ROUNDED_VALUE_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.ROUNDED_VALUE_TOO_LARGE); } return d; } @@ -692,7 +686,7 @@ static Object round(VirtualFrame frame, Object x, Object n, @Bind("this") Node inliningTarget, @Exclusive @Cached CastToJavaDoubleNode cast, @Cached PyNumberAsSizeNode asSizeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { return round(castToDoubleChecked(inliningTarget, x, cast), asSizeNode.executeLossy(frame, inliningTarget, n), inliningTarget, raiseNode); } @@ -704,13 +698,13 @@ static Object round(Object xObj, @SuppressWarnings("unused") PNone none, @Cached InlinedConditionProfile nanProfile, @Cached InlinedConditionProfile infProfile, @Cached InlinedConditionProfile isLongProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { double x = castToDoubleChecked(inliningTarget, xObj, cast); if (nanProfile.profile(inliningTarget, Double.isNaN(x))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.CANNOT_CONVERT_S_TO_INT, "float NaN"); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.CANNOT_CONVERT_S_TO_INT, "float NaN"); } if (infProfile.profile(inliningTarget, Double.isInfinite(x))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.CANNOT_CONVERT_S_TO_INT, "float infinity"); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.CANNOT_CONVERT_S_TO_INT, "float infinity"); } double result = round(x, 0, inliningTarget, raiseNode); if (isLongProfile.profile(inliningTarget, result > Long.MAX_VALUE || result < Long.MIN_VALUE)) { @@ -966,13 +960,13 @@ static PTuple get(Object selfObj, @Cached CastToJavaDoubleNode cast, @Cached InlinedConditionProfile nanProfile, @Cached InlinedConditionProfile infProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { double self = castToDoubleChecked(inliningTarget, selfObj, cast); if (nanProfile.profile(inliningTarget, Double.isNaN(self))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.CANNOT_CONVERT_S_TO_INT_RATIO, "NaN"); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.CANNOT_CONVERT_S_TO_INT_RATIO, "NaN"); } if (infProfile.profile(inliningTarget, Double.isInfinite(self))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.CANNOT_CONVERT_S_TO_INT_RATIO, "Infinity"); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.CANNOT_CONVERT_S_TO_INT_RATIO, "Infinity"); } // At the first time find mantissa and exponent. This is functionality of @@ -1073,8 +1067,8 @@ static TruffleString getFormat(@SuppressWarnings("unused") Object cls, @Suppress @Fallback static TruffleString getFormat(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused") Object typeStr, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.ValueError, ErrorMessages.ARG_D_MUST_BE_S_OR_S, "__getformat__()", 1, "double", "float"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.ValueError, ErrorMessages.ARG_D_MUST_BE_S_OR_S, "__getformat__()", 1, "double", "float"); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java index b9c054c701..5b7b7ecc96 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java @@ -76,7 +76,7 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument @CachedLibrary(limit = "4") InteropLibrary lib, @Cached PForeignToPTypeNode toPTypeNode, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); try { @@ -89,7 +89,7 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument IndirectCallContext.exit(frame, language, context, state); } } catch (ArityException | UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignInstantiableBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignInstantiableBuiltins.java index 2e259e80ca..bad5fb6f03 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignInstantiableBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignInstantiableBuiltins.java @@ -78,7 +78,7 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument @CachedLibrary(limit = "4") InteropLibrary lib, @Cached PForeignToPTypeNode toPTypeNode, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); try { @@ -91,7 +91,7 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument IndirectCallContext.exit(frame, language, context, state); } } catch (ArityException | UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index 127f6073b4..f4dce3ab2a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -79,6 +79,7 @@ import com.oracle.graal.python.lib.PyNumberTrueDivideNode; import com.oracle.graal.python.lib.PyNumberXorNode; import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; +import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; @@ -700,7 +701,7 @@ protected static Object doIt(Object object, throw new IllegalStateException("foreign value claims to be a big integer but isn't"); } } - throw raiseNode.raiseIntegerInterpretationError(object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, object); } finally { gil.acquire(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java index 6f2172be6a..078ffd4076 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java @@ -169,14 +169,14 @@ static Object doIt(Node inliningTarget, Object object, Object memberObj, @Cached(inline = false) CastToJavaStringNode castToString, @Cached(inline = false) GilNode gil, @Cached(inline = false) PForeignToPTypeNode toPythonNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { gil.release(true); try { String member; try { member = castToString.execute(memberObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, memberObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, memberObj); } if (read.isMemberReadable(object, member)) { @@ -198,7 +198,7 @@ static Object doIt(Node inliningTarget, Object object, Object memberObj, } finally { gil.acquire(); } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, memberObj); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, memberObj); } } @@ -212,13 +212,13 @@ static void doSet(Object object, Object key, Object value, @Shared @CachedLibrary(limit = "3") InteropLibrary lib, @Shared @Cached CastToJavaStringNode castToString, @Shared @Cached GilNode gil, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { gil.release(true); String member; try { member = castToString.execute(key); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, key); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, key); } try { try { @@ -241,11 +241,11 @@ static void doSet(Object object, Object key, Object value, } } } catch (UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.INVALID_TYPE_FOR_S, key); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INVALID_TYPE_FOR_S, key); } finally { gil.acquire(); } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, key); + throw raiseNode.raise(inliningTarget, PythonErrorType.AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, key); } @Specialization(guards = "isNoValue(value)") @@ -254,14 +254,14 @@ static void doDelete(Object object, Object key, @SuppressWarnings("unused") PNon @Shared @CachedLibrary(limit = "3") InteropLibrary lib, @Shared @Cached CastToJavaStringNode castToString, @Shared @Cached GilNode gil, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { gil.release(true); try { lib.removeMember(object, castToString.execute(key)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, key); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, key); } catch (UnknownIdentifierException | UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, key); + throw raiseNode.raise(inliningTarget, PythonErrorType.AttributeError, ErrorMessages.FOREIGN_OBJ_HAS_NO_ATTR_S, key); } finally { gil.acquire(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java index 17fad7107d..978c84e856 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java @@ -156,8 +156,8 @@ public abstract static class LinenoNode extends PythonBinaryBuiltinNode { @Specialization Object delete(VirtualFrame frame, PFrame self, DescriptorDeleteMarker ignored, @Bind("this") Node inliningTarget, - @Cached @Cached.Exclusive PRaiseNode.Lazy raise) { - raise.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, ErrorMessages.CANNOT_DELETE); + @Cached @Cached.Exclusive PRaiseNode raise) { + raise.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.CANNOT_DELETE); return PNone.NONE; } @@ -187,7 +187,7 @@ PNone set(VirtualFrame frame, PFrame self, Object newLineno, @Bind("this") Node inliningTarget, @Cached @Cached.Exclusive InlinedConditionProfile isCurrentFrameProfile, @Cached @Cached.Exclusive MaterializeFrameNode materializeNode, - @Cached @Cached.Exclusive PRaiseNode.Lazy raise, + @Cached @Cached.Exclusive PRaiseNode raise, @Cached PyLongCheckExactNode isLong, @Cached PyLongAsLongAndOverflowNode toLong) { syncLocationIfNeeded(frame, self, this, inliningTarget, isCurrentFrameProfile, materializeNode); @@ -198,17 +198,17 @@ PNone set(VirtualFrame frame, PFrame self, Object newLineno, if (lineno <= Integer.MAX_VALUE && lineno >= Integer.MIN_VALUE) { self.setJumpDestLine((int) lineno); } else { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_OUT_OF_RANGE); + throw raise.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_OUT_OF_RANGE); } } catch (OverflowException e) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_OUT_OF_RANGE); + throw raise.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_OUT_OF_RANGE); } } else { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_MUST_BE_AN_INTEGER); + throw raise.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.LINENO_MUST_BE_AN_INTEGER); } } else { PythonContext context = getContext(); - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.CANT_JUMP_FROM_S_EVENT, + throw raise.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.CANT_JUMP_FROM_S_EVENT, context.getThreadState(context.getLanguage(inliningTarget)).getTracingWhat().pythonName); } return PNone.NONE; @@ -261,7 +261,7 @@ static Object doSet(PFrame self, Object v, @Bind("this") Node inliningTarget, try { self.setTraceLine(cast.execute(inliningTarget, v)); } catch (CannotCastException e) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_VALUE_MUST_BE_BOOL); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_VALUE_MUST_BE_BOOL); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java index a3263bbdb2..21bf7bdab2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/AbstractFunctionBuiltins.java @@ -132,8 +132,8 @@ Object getClosure(PFunction self, @SuppressWarnings("unused") @Fallback static Object getClosure(Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__closure__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__closure__"); } } @@ -157,8 +157,8 @@ Object getGlobals(PFunction self, @SuppressWarnings("unused") @Fallback static Object getGlobals(Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__globals__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__globals__"); } } @@ -210,8 +210,8 @@ static Object setModule(PFunction self, Object value, @SuppressWarnings("unused") @Specialization static Object getModule(PBuiltinFunction self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__module__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__module__"); } } @@ -243,8 +243,8 @@ static Object getModule(PFunction self, Object value, @SuppressWarnings("unused") @Specialization static Object getModule(PBuiltinFunction self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__annotations__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__annotations__"); } } @@ -268,15 +268,15 @@ static Object dict(PFunction self, @SuppressWarnings("unused") PNone mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static PNone dict(@SuppressWarnings("unused") PFunction self, Object mapping, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } @Specialization @SuppressWarnings("unused") static Object builtinCode(PBuiltinFunction self, Object mapping, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__dict__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__dict__"); } } @@ -288,10 +288,10 @@ public abstract static class TextSignatureNode extends PythonBinaryBuiltinNode { static Object getFunction(PFunction self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Cached ReadAttributeFromObjectNode readNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object signature = readNode.execute(self, T___TEXT_SIGNATURE__); if (signature == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "function", "__text_signature__"); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "function", "__text_signature__"); } return signature; } @@ -309,7 +309,7 @@ static TruffleString getBuiltin(PBuiltinFunction self, @SuppressWarnings("unused @Bind("this") Node inliningTarget) { Signature signature = self.getSignature(); if (signature.isHidden()) { - throw PRaiseNode.raiseUncached(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, self, T___TEXT_SIGNATURE__); + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, self, T___TEXT_SIGNATURE__); } return signatureToText(signature, false); } @@ -378,8 +378,8 @@ private static boolean appendCommaIfNeeded(TruffleStringBuilder sb, boolean firs @Specialization(guards = "!isNoValue(value)") static Object setBuiltin(@SuppressWarnings("unused") PBuiltinFunction self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__text_signature__", "builtin_function_or_method"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__text_signature__", "builtin_function_or_method"); } public static TextSignatureNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java index eee179f311..3b7cf6e569 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java @@ -91,8 +91,8 @@ static TruffleString getName(PBuiltinFunction self, @SuppressWarnings("unused") @Specialization(guards = "!isNoValue(value)") static TruffleString setName(@SuppressWarnings("unused") PBuiltinFunction self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__name__", "builtin function"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__name__", "builtin function"); } } @@ -106,8 +106,8 @@ static TruffleString getQualname(PBuiltinFunction self, @SuppressWarnings("unuse @Specialization(guards = "!isNoValue(value)") static TruffleString setQualname(@SuppressWarnings("unused") PBuiltinFunction self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__qualname__", "builtin function"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_WRITABLE, "__qualname__", "builtin function"); } } @@ -117,8 +117,8 @@ static TruffleString setQualname(@SuppressWarnings("unused") PBuiltinFunction se public abstract static class ObjclassNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getEnclosingType() == null") static Object objclassMissing(@SuppressWarnings("unused") PBuiltinFunction self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__objclass__"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "builtin_function_or_method", "__objclass__"); } @Specialization(guards = "self.getEnclosingType() != null") @@ -151,7 +151,7 @@ public abstract static class SignatureNode extends PythonUnaryBuiltinNode { static Object doIt(PBuiltinFunction fun, @Bind("this") Node inliningTarget) { if (fun.getSignature().isHidden()) { - throw PRaiseNode.raiseUncached(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__); + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__); } return createInspectSignature(fun.getSignature(), false); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java index 9e6033f13a..fde1aecc90 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java @@ -206,8 +206,8 @@ static Object setDefaults(PFunction self, @SuppressWarnings("unused") PNone defa @Fallback @SuppressWarnings("unused") static Object setDefaults(Object self, Object defaults, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.MUST_BE_SET_TO_S_NOT_P, T___DEFAULTS__, "tuple"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.MUST_BE_SET_TO_S_NOT_P, T___DEFAULTS__, "tuple"); } } @@ -238,7 +238,7 @@ Object set(PFunction self, PDict arg) { if (key instanceof PString) { key = ((PString) key).getValueUncached(); } else if (!(key instanceof TruffleString)) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, ErrorMessages.KEYWORD_NAMES_MUST_BE_STR_GOT_P, key); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.KEYWORD_NAMES_MUST_BE_STR_GOT_P, key); } keywords.add(new PKeyword((TruffleString) key, HashingStorageIteratorValue.executeUncached(storage, it))); } @@ -275,8 +275,8 @@ static Object doMethod(PMethod method, @Fallback static Object doGeneric(Object object, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.GETTING_THER_SOURCE_NOT_SUPPORTED_FOR_P, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.GETTING_THER_SOURCE_NOT_SUPPORTED_FOR_P, object); } } @@ -294,11 +294,11 @@ static Object getCodeU(PFunction self, @SuppressWarnings("unused") PNone none, @Specialization static Object setCode(PFunction self, PCode code, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int closureLength = self.getClosure() == null ? 0 : self.getClosure().length; int freeVarsLength = code.getFreeVars().length; if (closureLength != freeVarsLength) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.REQUIRES_CODE_OBJ, self.getName(), closureLength, freeVarsLength); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.REQUIRES_CODE_OBJ, self.getName(), closureLength, freeVarsLength); } self.setCode(code); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java index 21e76b2010..def38180b9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java @@ -135,18 +135,18 @@ protected List> getNodeFa return CommonGeneratorBuiltinsFactory.getFactories(); } - private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseNode.Lazy raiseNode) { + private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseNode raiseNode) { if (self.isFinished()) { if (self.isAsyncGen()) { - throw raiseNode.get(inliningTarget).raise(StopAsyncIteration); + throw raiseNode.raise(inliningTarget, StopAsyncIteration); } if (self.isCoroutine()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_CORO); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_CORO); } - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } if (self.isRunning()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); } } @@ -161,7 +161,7 @@ static Object cached(VirtualFrame frame, Node inliningTarget, PGenerator self, O @Cached(value = "createDirectCall(self.getCurrentCallTarget())", inline = false) CallTargetInvokeNode call, @Exclusive @Cached InlinedBranchProfile returnProfile, @Exclusive @Cached IsBuiltinObjectProfile errorProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.setRunning(true); Object[] arguments = prepareArguments(self); if (sendValue != null) { @@ -174,7 +174,7 @@ static Object cached(VirtualFrame frame, Node inliningTarget, PGenerator self, O throw handleException(self, inliningTarget, errorProfile, raiseNode, e); } catch (GeneratorReturnException e) { returnProfile.enter(inliningTarget); - throw handleReturn(self, e, raiseNode.get(inliningTarget)); + throw handleReturn(inliningTarget, self, e); } finally { self.setRunning(false); } @@ -188,7 +188,7 @@ static Object generic(VirtualFrame frame, Node inliningTarget, PGenerator self, @Cached(inline = false) GenericInvokeNode call, @Exclusive @Cached InlinedBranchProfile returnProfile, @Exclusive @Cached IsBuiltinObjectProfile errorProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.setRunning(true); Object[] arguments = prepareArguments(self); if (sendValue != null) { @@ -205,25 +205,25 @@ static Object generic(VirtualFrame frame, Node inliningTarget, PGenerator self, throw handleException(self, inliningTarget, errorProfile, raiseNode, e); } catch (GeneratorReturnException e) { returnProfile.enter(inliningTarget); - throw handleReturn(self, e, raiseNode.get(inliningTarget)); + throw handleReturn(inliningTarget, self, e); } finally { self.setRunning(false); } return handleResult(inliningTarget, self, result); } - private static PException handleException(PGenerator self, Node inliningTarget, IsBuiltinObjectProfile profile, PRaiseNode.Lazy raiseNode, PException e) { + private static PException handleException(PGenerator self, Node inliningTarget, IsBuiltinObjectProfile profile, PRaiseNode raiseNode, PException e) { self.markAsFinished(); if (self.isAsyncGen()) { // Async generators need to wrap StopAsyncIteration in a runtime error if (profile.profileException(inliningTarget, e, StopAsyncIteration)) { - throw raiseNode.get(inliningTarget).raiseWithCause(RuntimeError, e.getEscapedException(), ErrorMessages.ASYNCGEN_RAISED_ASYNCSTOPITER); + throw raiseNode.raiseWithCause(inliningTarget, RuntimeError, e, ErrorMessages.ASYNCGEN_RAISED_ASYNCSTOPITER); } } // PEP 479 - StopIteration raised from generator body needs to be wrapped in // RuntimeError e.expectStopIteration(inliningTarget, profile); - throw raiseNode.get(inliningTarget).raiseWithCause(RuntimeError, e.getEscapedException(), ErrorMessages.GENERATOR_RAISED_STOPITER); + throw raiseNode.raiseWithCause(inliningTarget, RuntimeError, e, ErrorMessages.GENERATOR_RAISED_STOPITER); } private static Object handleResult(Node node, PGenerator self, GeneratorYieldResult result) { @@ -231,15 +231,15 @@ private static Object handleResult(Node node, PGenerator self, GeneratorYieldRes return result.yieldValue; } - private static PException handleReturn(PGenerator self, GeneratorReturnException e, PRaiseNode raiseNode) { + private static PException handleReturn(Node inliningTarget, PGenerator self, GeneratorReturnException e) { self.markAsFinished(); if (self.isAsyncGen()) { - throw raiseNode.raise(StopAsyncIteration); + throw PRaiseNode.raiseStatic(inliningTarget, StopAsyncIteration); } if (e.value != PNone.NONE) { - throw raiseNode.raise(StopIteration, new Object[]{e.value}); + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration, new Object[]{e.value}); } else { - throw raiseNode.raise(StopIteration); + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } } @@ -260,12 +260,12 @@ public abstract static class SendNode extends PythonBinaryBuiltinNode { static Object send(VirtualFrame frame, PGenerator self, Object value, @Bind("this") Node inliningTarget, @Cached ResumeGeneratorNode resumeGeneratorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // even though this isn't a builtin for async generators, SendNode is used on async // generators by PAsyncGenSend checkResumable(inliningTarget, self, raiseNode); if (!self.isStarted() && value != PNone.NONE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SEND_NON_NONE_TO_UNSTARTED_GENERATOR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SEND_NON_NONE_TO_UNSTARTED_GENERATOR); } return resumeGeneratorNode.execute(frame, inliningTarget, self, value); } @@ -288,15 +288,15 @@ static Object sendThrow(VirtualFrame frame, PGenerator self, Object typ, Object @Cached ExceptionNodes.GetTracebackNode getTracebackNode, @Cached ExceptionNodes.SetTracebackNode setTracebackNode, @Cached ExceptionNodes.SetContextNode setContextNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean hasTb = hasTbProfile.profile(inliningTarget, !(tb instanceof PNone)); if (hasTb && !(tb instanceof PTraceback)) { invalidTbProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.THROW_THIRD_ARG_MUST_BE_TRACEBACK); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.THROW_THIRD_ARG_MUST_BE_TRACEBACK); } if (self.isRunning()) { runningProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); } Object instance = prepareExceptionNode.execute(frame, typ, val); if (hasTb) { @@ -306,7 +306,7 @@ static Object sendThrow(VirtualFrame frame, PGenerator self, Object typ, Object setContextNode.execute(inliningTarget, instance, PNone.NONE); // Will be filled when // caught if (self.isCoroutine() && self.isFinished()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_CORO); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.CANNOT_REUSE_CORO); } if (startedProfile.profile(inliningTarget, self.isStarted() && !self.isFinished())) { // Pass it to the generator where it will be thrown by the last yield, the location @@ -342,9 +342,9 @@ static Object close(VirtualFrame frame, PGenerator self, @Cached IsBuiltinObjectProfile isStopIteration, @Cached ResumeGeneratorNode resumeGeneratorNode, @Cached InlinedConditionProfile isStartedPorfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.isRunning()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); } if (isStartedPorfile.profile(inliningTarget, self.isStarted() && !self.isFinished())) { PBaseException pythonException = PFactory.createBaseException(PythonLanguage.get(inliningTarget), GeneratorExit); @@ -362,7 +362,7 @@ static Object close(VirtualFrame frame, PGenerator self, } finally { self.markAsFinished(); } - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.GENERATOR_IGNORED_EXIT); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.GENERATOR_IGNORED_EXIT); } else { self.markAsFinished(); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java index 18ebb0b5a0..7f49e23bd3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java @@ -71,12 +71,12 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PGenerator) public final class GeneratorBuiltins extends PythonBuiltins { - private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseNode.Lazy raiseNode) { + private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseNode raiseNode) { if (self.isFinished()) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } if (self.isRunning()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING); } } @@ -146,7 +146,7 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { static Object next(VirtualFrame frame, PGenerator self, @Bind("this") Node inliningTarget, @Cached CommonGeneratorBuiltins.ResumeGeneratorNode resumeGeneratorNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkResumable(inliningTarget, self, raiseNode); return resumeGeneratorNode.execute(frame, inliningTarget, self, null); } @@ -173,8 +173,8 @@ static Object getRunning(PGenerator self, @SuppressWarnings("unused") PNone none @Specialization(guards = "!isNoValue(obj)") static Object setRunning(@SuppressWarnings("unused") PGenerator self, @SuppressWarnings("unused") Object obj, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, "gi_running", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, "gi_running", self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/DescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/DescriptorBuiltins.java index 09f580f2da..360e880e8f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/DescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/DescriptorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -142,10 +142,10 @@ abstract static class DescriptorCheckNode extends Node { static void check(Node inliningTarget, Object descrType, Object name, Object obj, @Cached GetClassNode getClassNode, @Cached(inline = false) IsSubtypeNode isSubtypeNode, - @Cached(inline = false) PRaiseNode raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, obj); if (!isSubtypeNode.execute(type, descrType)) { - throw raiseNode.raise(TypeError, ErrorMessages.DESC_S_FOR_N_DOESNT_APPLY_TO_N, name, descrType, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESC_S_FOR_N_DOESNT_APPLY_TO_N, name, descrType, type); } } } @@ -158,27 +158,27 @@ public abstract static class DescrGetNode extends Node { @Specialization Object doGetSetDescriptor(VirtualFrame frame, GetSetDescriptor descr, Object obj, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetNameNode getNameNode, @Cached CallUnaryMethodNode callNode) { if (descr.getGet() != null) { return callNode.executeObject(frame, descr.getGet(), obj); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_READABLE, descr.getName(), getNameNode.execute(inliningTarget, descr.getType())); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_IS_NOT_READABLE, descr.getName(), getNameNode.execute(inliningTarget, descr.getType())); } } @Specialization Object doIndexedSlotDescriptor(IndexedSlotDescriptor descr, PythonAbstractObject obj, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetOrCreateIndexedSlots getSlotsNode) { Object[] slots = getSlotsNode.execute(inliningTarget, obj); Object val = slots[descr.getIndex()]; if (val != null) { return val; } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, descr.getType(), descr.getName()); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, descr.getType(), descr.getName()); } } @@ -190,12 +190,12 @@ public abstract static class DescrSetNode extends Node { Object doGetSetDescriptor(VirtualFrame frame, GetSetDescriptor descr, Object obj, Object value, @Bind("this") Node inliningTarget, @Cached GetNameNode getNameNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached CallBinaryMethodNode callNode) { if (descr.getSet() != null) { return callNode.executeObject(frame, descr.getSet(), obj, value); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_WRITABLE, descr.getName(), getNameNode.execute(inliningTarget, descr.getType())); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_OF_S_OBJ_IS_NOT_WRITABLE, descr.getName(), getNameNode.execute(inliningTarget, descr.getType())); } } @@ -215,7 +215,7 @@ public abstract static class DescrDeleteNode extends Node { @Specialization Object doGetSetDescriptor(VirtualFrame frame, GetSetDescriptor descr, Object obj, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetNameNode getNameNode, @Cached CallBinaryMethodNode callNode, @Cached InlinedBranchProfile branchProfile) { @@ -224,9 +224,9 @@ Object doGetSetDescriptor(VirtualFrame frame, GetSetDescriptor descr, Object obj } else { branchProfile.enter(inliningTarget); if (descr.getSet() != null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_DELETE_ATTRIBUTE, getNameNode.execute(inliningTarget, descr.getType()), descr.getName()); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_DELETE_ATTRIBUTE, getNameNode.execute(inliningTarget, descr.getType()), descr.getName()); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, descr.getName(), obj); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, descr.getName(), obj); } } } @@ -234,7 +234,7 @@ Object doGetSetDescriptor(VirtualFrame frame, GetSetDescriptor descr, Object obj @Specialization Object doIndexedSlotDescriptor(IndexedSlotDescriptor descr, PythonAbstractObject obj, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached GetOrCreateIndexedSlots getSlotsNode, @Cached InlinedConditionProfile profile) { // PyMember_SetOne - Check if the attribute is set. @@ -243,7 +243,7 @@ Object doIndexedSlotDescriptor(IndexedSlotDescriptor descr, PythonAbstractObject slots[descr.getIndex()] = null; return PNone.NONE; } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, ErrorMessages.S, descr.getName()); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.S, descr.getName()); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index 896ce7003a..fc97c6d276 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -157,16 +157,16 @@ public final class IntBuiltins extends PythonBuiltins { public static final TpSlots SLOTS = IntBuiltinsSlotsGen.SLOTS; - private static void raiseDivisionByZero(Node inliningTarget, boolean cond, InlinedBranchProfile divisionByZeroProfile, PRaiseNode.Lazy raiseNode) { + private static void raiseDivisionByZero(Node inliningTarget, boolean cond, InlinedBranchProfile divisionByZeroProfile, PRaiseNode raiseNode) { if (cond) { - raiseDivisionByZero(inliningTarget, divisionByZeroProfile, raiseNode.get(inliningTarget)); + raiseDivisionByZero(inliningTarget, divisionByZeroProfile, raiseNode); } } @InliningCutoff private static void raiseDivisionByZero(Node inliningTarget, InlinedBranchProfile divisionByZeroProfile, PRaiseNode raiseNode) { divisionByZeroProfile.enter(inliningTarget); - throw raiseNode.raise(PythonErrorType.ZeroDivisionError, ErrorMessages.S_DIVISION_OR_MODULO_BY_ZERO, "integer"); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.S_DIVISION_OR_MODULO_BY_ZERO, "integer"); } @Override @@ -284,8 +284,8 @@ static Object roundPIntPInt(PInt arg, PInt n, @Specialization(guards = {"!isInteger(n)"}) @SuppressWarnings("unused") static Object roundPIntPInt(Object arg, Object n, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, n); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, n); } private static Object makeInt(Node inliningTarget, BigDecimal d, InlinedBranchProfile intOverflow, InlinedBranchProfile longOverflow) { @@ -534,32 +534,32 @@ public abstract static class TrueDivNode extends BinaryOpBuiltinNode { @Specialization static double divII(int x, int y, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return divDD(x, y, inliningTarget, raiseNode); } @Specialization(guards = {"fitsIntoDouble(x)", "fitsIntoDouble(y)"}) static double divLL(long x, long y, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return divDD(x, y, inliningTarget, raiseNode); } @Specialization(guards = {"!fitsIntoDouble(x) || !fitsIntoDouble(y)"}) static double divLLLarge(long x, long y, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (y == 0) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } return op(inliningTarget, PInt.longToBigInteger(x), PInt.longToBigInteger(y)); } static double divDD(double x, double y, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (y == 0) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } return x / y; } @@ -567,9 +567,9 @@ static double divDD(double x, double y, @Specialization static double doPI(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (right.isZero()) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } return op(inliningTarget, PInt.longToBigInteger(left), right.getValue()); } @@ -577,9 +577,9 @@ static double doPI(long left, PInt right, @Specialization static double doPL(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (right == 0) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } return op(inliningTarget, left.getValue(), PInt.longToBigInteger(right)); } @@ -587,9 +587,9 @@ static double doPL(PInt left, long right, @Specialization static double doPP(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (right.isZero()) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); + throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } return op(inliningTarget, left.getValue(), right.getValue()); } @@ -611,7 +611,7 @@ private static double op(Node raisingNode, BigInteger a, BigInteger b) { BigDecimal result = aDecimal.divide(bDecimal, bPrec - aPrec + precisionOfDouble, RoundingMode.HALF_EVEN); double d = result.doubleValue(); if (Double.isInfinite(d)) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.INTEGER_DIVISION_RESULT_TOO_LARGE); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.INTEGER_DIVISION_RESULT_TOO_LARGE); } return d; } @@ -650,7 +650,7 @@ static Object doII(int left, int right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); if (left == Integer.MIN_VALUE && right == -1) { overflowValueProfile.enter(); @@ -664,7 +664,7 @@ static Object doLL(long left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); if (left == Long.MIN_VALUE && right == -1) { overflowValueProfile.enter(); @@ -678,7 +678,7 @@ static Object doIPi(int left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { int rightValue = right.intValueExact(); raiseDivisionByZero(inliningTarget, rightValue == 0, divisionByZeroProfile, raiseNode); @@ -697,7 +697,7 @@ static Object doLPi(long left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { long rightValue = right.longValueExact(); raiseDivisionByZero(inliningTarget, rightValue == 0, divisionByZeroProfile, raiseNode); @@ -715,7 +715,7 @@ static Object doLPi(long left, PInt right, static long doPiIAndNarrow(PInt left, int right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -725,7 +725,7 @@ static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @@ -734,7 +734,7 @@ static PInt doPiI(PInt left, int right, static long doPiLAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -744,7 +744,7 @@ static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @@ -753,7 +753,7 @@ static PInt doPiL(PInt left, long right, static long doPiPiAndNarrow(PInt left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(left.getValue(), right.getValue())); } @@ -763,7 +763,7 @@ static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @@ -821,7 +821,7 @@ public abstract static class ModNode extends BinaryOpBuiltinNode { static int doII(int left, int right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return Math.floorMod(left, right); } @@ -830,7 +830,7 @@ static int doII(int left, int right, static long doLL(long left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return Math.floorMod(left, right); } @@ -839,7 +839,7 @@ static long doLL(long left, long right, static long doLPiAndNarrow(long left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(PInt.longToBigInteger(left), right.getValue())); } @@ -849,7 +849,7 @@ static PInt doLPi(long left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @@ -858,7 +858,7 @@ static PInt doLPi(long left, PInt right, static long doLPiNegativeAndNarrow(long left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PInt.longValueExact(opNeg(PInt.longToBigInteger(left), right.getValue())); } @@ -868,7 +868,7 @@ static PInt doLPiNegative(long left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PFactory.createInt(language, opNeg(PInt.longToBigInteger(left), right.getValue())); } @@ -877,7 +877,7 @@ static PInt doLPiNegative(long left, PInt right, static long doPiLAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -887,7 +887,7 @@ static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @@ -896,7 +896,7 @@ static PInt doPiL(PInt left, long right, static long doPiLNegAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PInt.longValueExact(opNeg(left.getValue(), PInt.longToBigInteger(right))); } @@ -906,7 +906,7 @@ static PInt doPiLNeg(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); return PFactory.createInt(language, opNeg(left.getValue(), PInt.longToBigInteger(right))); } @@ -915,7 +915,7 @@ static PInt doPiLNeg(PInt left, long right, static long doPiPiAndNarrow(PInt left, PInt right, @Bind("this") Node inliningTarget, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PInt.longValueExact(op(left.getValue(), right.getValue())); } @@ -925,7 +925,7 @@ static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached InlinedBranchProfile divisionByZeroProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @@ -1147,9 +1147,9 @@ PInt doLLPos(long left, long right, @SuppressWarnings("unused") PNone none, double doLLNeg(long left, long right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Shared("leftIsZero") @Cached InlinedConditionProfile leftIsZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (leftIsZero.profile(inliningTarget, left == 0)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } return Math.pow(left, right); } @@ -1159,7 +1159,7 @@ PInt doLLPos(long left, long right, @SuppressWarnings("unused") PNone none, Object doLPNarrow(long left, PInt right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Shared("leftIsZero") @Cached InlinedConditionProfile leftIsZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { long lright = right.longValueExact(); if (lright >= 0) { return doLLFast(left, lright, none); @@ -1196,10 +1196,10 @@ PInt doPLPos(PInt left, long right, @SuppressWarnings("unused") PNone none, double doPLNeg(PInt left, long right, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Shared("leftIsZero") @Cached InlinedConditionProfile leftIsZero, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { double leftDouble = PInt.doubleValueWithOverflow(this, left.getValue()); if (leftIsZero.profile(inliningTarget, leftDouble == 0.0)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } return Math.pow(leftDouble, right); } @@ -1232,9 +1232,9 @@ static long doLLPosLPos(long left, long right, long mod) { static long doLLPosLGeneric(long left, long right, long mod, @Bind("this") Node inliningTarget, @Exclusive @Cached InlinedConditionProfile modNegativeProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (mod == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.POW_THIRD_ARG_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.POW_THIRD_ARG_CANNOT_BE_ZERO); } try { if (modNegativeProfile.profile(inliningTarget, mod < 0)) { @@ -1283,7 +1283,7 @@ private Object objectOp(Object left, Object right, Object mod) { BigInteger bigRight = integerToBigInteger(right); BigInteger bigMod = integerToBigInteger(mod); if (bigMod.signum() == 0) { - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POW_THIRD_ARG_CANNOT_BE_ZERO); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.POW_THIRD_ARG_CANNOT_BE_ZERO); } else { BigInteger bigModPos; if (bigMod.signum() < 0) { @@ -1301,7 +1301,7 @@ private Object objectOp(Object left, Object right, Object mod) { } catch (ArithmeticException e) { // a positive mod was used, so this exception must mean the exponent was // negative and the base is not relatively prime to the exponent - throw PRaiseNode.raiseUncached(this, ValueError, ErrorMessages.POW_BASE_NOT_INVERTIBLE); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.POW_BASE_NOT_INVERTIBLE); } } } @@ -1356,7 +1356,7 @@ private Object op(BigInteger left, BigInteger right) { double leftDouble = PInt.doubleValueWithOverflow(this, left); double rightDouble = PInt.doubleValueWithOverflow(this, right); if (leftDouble == 0.0) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.ZeroDivisionError, ErrorMessages.POW_ZERO_CANNOT_RAISE_TO_NEGATIVE_POWER); } return Math.pow(leftDouble, rightDouble); } @@ -1384,7 +1384,7 @@ private BigInteger op(BigInteger a, long b) { } if (b != (int) b) { // exponent does not fit in an int, this is likely going to cause out-of-memory - throw PRaiseNode.raiseUncached(this, PythonErrorType.ArithmeticError, ErrorMessages.EXPONENT_TOO_LARGE); + throw PRaiseNode.raiseStatic(this, PythonErrorType.ArithmeticError, ErrorMessages.EXPONENT_TOO_LARGE); } return a.pow((int) b); } @@ -1574,7 +1574,7 @@ public abstract static class LShiftNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); - private static long leftShiftExact(Node inliningTarget, long left, long right, PRaiseNode.Lazy raiseNode) throws OverflowException { + private static long leftShiftExact(Node inliningTarget, long left, long right, PRaiseNode raiseNode) throws OverflowException { if (right >= Long.SIZE || right < 0) { shiftError(inliningTarget, right, raiseNode); } @@ -1588,7 +1588,7 @@ private static long leftShiftExact(Node inliningTarget, long left, long right, P return result; } - private static int leftShiftExact(Node inliningTarget, int left, int right, PRaiseNode.Lazy raiseNode) throws OverflowException { + private static int leftShiftExact(Node inliningTarget, int left, int right, PRaiseNode raiseNode) throws OverflowException { if (right >= Integer.SIZE || right < 0) { shiftError(inliningTarget, right, raiseNode); } @@ -1602,18 +1602,18 @@ private static int leftShiftExact(Node inliningTarget, int left, int right, PRai return result; } - private static void shiftError(Node inliningTarget, long shiftCount, PRaiseNode.Lazy raiseNode) throws OverflowException { + private static void shiftError(Node inliningTarget, long shiftCount, PRaiseNode raiseNode) throws OverflowException { if (shiftCount >= Integer.SIZE) { throw OverflowException.INSTANCE; } else if (shiftCount < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); } } @Specialization(rewriteOn = OverflowException.class) static int doII(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return leftShiftExact(inliningTarget, left, right, raiseNode); } @@ -1621,7 +1621,7 @@ static int doII(int left, int right, @Specialization static Object doIIOvf(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); try { return leftShiftExact(inliningTarget, left, right, raiseNode); @@ -1633,7 +1633,7 @@ static Object doIIOvf(int left, int right, @Specialization(rewriteOn = OverflowException.class) static long doLL(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) throws OverflowException { + @Shared @Cached PRaiseNode raiseNode) throws OverflowException { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return leftShiftExact(inliningTarget, left, right, raiseNode); } @@ -1641,21 +1641,21 @@ static long doLL(long left, long right, @Specialization static Object doILOvf(int left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doLLOvf(left, right, inliningTarget, raiseNode); } @Specialization static Object doLIOvf(long left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doLLOvf(left, right, inliningTarget, raiseNode); } @Specialization static Object doLLOvf(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); try { return leftShiftExact(inliningTarget, left, right, raiseNode); @@ -1668,7 +1668,7 @@ static Object doLLOvf(long left, long right, // fallback to the raise of overflow error } } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @@ -1681,7 +1681,7 @@ static int doIPiZero(@SuppressWarnings("unused") int left, @SuppressWarnings("un static PInt doIPi(int left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); if (left == 0) { return PFactory.createInt(language, BigInteger.ZERO); @@ -1690,7 +1690,7 @@ static PInt doIPi(int left, PInt right, int iright = right.intValueExact(); return PFactory.createInt(language, op(PInt.longToBigInteger(left), iright)); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @@ -1704,7 +1704,7 @@ static int doLPiZero(@SuppressWarnings("unused") long left, @SuppressWarnings("u @Specialization(replaces = "doLPiZero") static PInt doLPi(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); PythonLanguage language = PythonLanguage.get(inliningTarget); if (left == 0) { @@ -1714,35 +1714,35 @@ static PInt doLPi(long left, PInt right, int iright = right.intValueExact(); return PFactory.createInt(language, op(PInt.longToBigInteger(left), iright)); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @Specialization static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return doGuardedBiI(inliningTarget, left.getValue(), right, raiseNode); } - static PInt doGuardedBiI(Node inliningTarget, BigInteger left, int right, PRaiseNode.Lazy raiseNode) { + static PInt doGuardedBiI(Node inliningTarget, BigInteger left, int right, PRaiseNode raiseNode) { try { return PFactory.createInt(PythonLanguage.get(inliningTarget), op(left, right)); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @Specialization static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int rightI = (int) right; if (rightI == right) { return doPiI(left, rightI, inliningTarget, raiseNode); } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @@ -1754,7 +1754,7 @@ static int doPiPiZero(@SuppressWarnings("unused") PInt left, @SuppressWarnings(" @Specialization(replaces = "doPiPiZero") static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); PythonLanguage language = PythonLanguage.get(inliningTarget); if (left.isZero()) { @@ -1763,7 +1763,7 @@ static PInt doPiPi(PInt left, PInt right, try { return PFactory.createInt(language, op(left.getValue(), right.intValueExact())); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError); } } @@ -1782,9 +1782,9 @@ static BigInteger op(BigInteger left, int right) throws OverflowException { } } - private static void raiseNegativeShiftCount(Node inliningTarget, boolean cond, PRaiseNode.Lazy raiseNode) { + private static void raiseNegativeShiftCount(Node inliningTarget, boolean cond, PRaiseNode raiseNode) { if (cond) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); } } @@ -1805,7 +1805,7 @@ public abstract static class RShiftNode extends BinaryOpBuiltinNode { @Specialization(guards = "right < 32") static int doIISmall(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return left >> right; } @@ -1813,7 +1813,7 @@ static int doIISmall(int left, int right, @Specialization(replaces = "doIISmall") static int doII(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); // Note: according to JLS, if 'left' is an int, then only the 5 LSBs of 'right' are // considered. However, Python would consider more bits, so do the max possible shift. @@ -1823,7 +1823,7 @@ static int doII(int left, int right, @Specialization(guards = "right < 64") static long doLLSmall(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return left >> right; } @@ -1831,7 +1831,7 @@ static long doLLSmall(long left, long right, @Specialization(replaces = "doLLSmall") static long doLL(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); // for explanation, see 'doII' return left >> (right >= 64 ? 63 : right); @@ -1840,14 +1840,14 @@ static long doLL(long left, long right, @Specialization static Object doIPi(int left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, raiseNode); } @Specialization static Object doLPi(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doHugeShift(inliningTarget, PInt.longToBigInteger(left), right, raiseNode); } @@ -1855,7 +1855,7 @@ static Object doLPi(long left, PInt right, static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); return PFactory.createInt(language, op(left.getValue(), right)); } @@ -1864,7 +1864,7 @@ static PInt doPiI(PInt left, int right, static Object doPiL(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, right < 0, raiseNode); int rightI = (int) right; if (rightI == right) { @@ -1878,13 +1878,13 @@ static Object doPiL(PInt left, long right, @Specialization static Object doPInt(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doHugeShift(inliningTarget, left.getValue(), right, raiseNode); } - private static void raiseNegativeShiftCount(Node inliningTarget, boolean cond, PRaiseNode.Lazy raiseNode) { + private static void raiseNegativeShiftCount(Node inliningTarget, boolean cond, PRaiseNode raiseNode) { if (cond) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.NEGATIVE_SHIFT_COUNT); } } @@ -1894,7 +1894,7 @@ static PNotImplemented doGeneric(Object a, Object b) { return PNotImplemented.NOT_IMPLEMENTED; } - private static Object doHugeShift(Node inliningTarget, BigInteger left, PInt right, PRaiseNode.Lazy raiseNode) { + private static Object doHugeShift(Node inliningTarget, BigInteger left, PInt right, PRaiseNode raiseNode) { raiseNegativeShiftCount(inliningTarget, !right.isZeroOrPositive(), raiseNode); try { return PFactory.createInt(PythonLanguage.get(inliningTarget), op(left, right.intValueExact())); @@ -2579,7 +2579,7 @@ private static boolean isBigEndian(Node raisingNode, TruffleString order) { if (order.equalsUncached(T_LITTLE, TS_ENCODING)) { return false; } - throw PRaiseNode.raiseUncached(raisingNode, PythonErrorType.ValueError, ErrorMessages.BYTEORDER_MUST_BE_LITTLE_OR_BIG); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.BYTEORDER_MUST_BE_LITTLE_OR_BIG); } @Specialization @@ -2589,13 +2589,13 @@ static PBytes fromLong(long self, int byteCount, TruffleString byteorder, boolea @Exclusive @Cached InlinedConditionProfile negativeByteCountProfile, @Exclusive @Cached InlinedConditionProfile negativeNumberProfile, @Exclusive @Cached InlinedConditionProfile overflowProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (negativeByteCountProfile.profile(inliningTarget, byteCount < 0)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); } if (self < 0) { if (negativeNumberProfile.profile(inliningTarget, !signed)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); } } return PFactory.createBytes(language, fromLong(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, @@ -2605,7 +2605,7 @@ static PBytes fromLong(long self, int byteCount, TruffleString byteorder, boolea public static byte[] fromLong(long self, int byteCount, boolean isBigEndian, boolean signed, Node inliningTarget, InlinedConditionProfile overflowProfile, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { byte signByte = 0; if (self < 0) { assert signed : ErrorMessages.MESSAGE_CONVERT_NEGATIVE; @@ -2634,7 +2634,7 @@ public static byte[] fromLong(long self, int byteCount, boolean isBigEndian, boo } if (overflowProfile.profile(inliningTarget, !signed && number != 0 || (signed && bytes.length == 1 && bytes[0] != self) || (byteCount == 0 && self != 0 && self != -1))) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.MESSAGE_INT_TO_BIG); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.MESSAGE_INT_TO_BIG); } if (signed) { @@ -2650,7 +2650,7 @@ public static byte[] fromLong(long self, int byteCount, boolean isBigEndian, boo private static byte getSignByte(BigInteger value, boolean signed, Node raisingNode) { if (value.compareTo(BigInteger.ZERO) < 0) { if (!signed) { - throw PRaiseNode.raiseUncached(raisingNode, PythonErrorType.OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.MESSAGE_CONVERT_NEGATIVE); } return -1; } @@ -2668,9 +2668,9 @@ static PBytes fromPIntInt(PInt self, int byteCount, TruffleString byteorder, boo @Bind PythonLanguage language, @Exclusive @Cached InlinedConditionProfile negativeByteCountProfile, @Exclusive @Cached InlinedConditionProfile overflowProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (negativeByteCountProfile.profile(inliningTarget, byteCount < 0)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.MESSAGE_LENGTH_ARGUMENT); } return PFactory.createBytes(language, fromBigInteger(self, byteCount, isBigEndian(inliningTarget, byteorder), signed, inliningTarget, overflowProfile, raiseNode)); @@ -2679,7 +2679,7 @@ static PBytes fromPIntInt(PInt self, int byteCount, TruffleString byteorder, boo public static byte[] fromBigInteger(PInt self, int byteCount, boolean isBigEndian, boolean signed, Node inliningTarget, InlinedConditionProfile overflowProfile, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { BigInteger value = self.getValue(); byte signByte = getSignByte(value, signed, inliningTarget); byte[] bytes = getBytes(value); @@ -2697,7 +2697,7 @@ public static byte[] fromBigInteger(PInt self, int byteCount, boolean isBigEndia } if (overflowProfile.profile(inliningTarget, len > byteCount)) { // the corrected len is still bigger then we need. - throw raiseNode.get(inliningTarget).raise(PythonErrorType.OverflowError, ErrorMessages.MESSAGE_INT_TO_BIG); + throw raiseNode.raise(inliningTarget, PythonErrorType.OverflowError, ErrorMessages.MESSAGE_INT_TO_BIG); } // the array starts with sign bytes and has to be truncated to the requested // size @@ -2761,21 +2761,21 @@ static Object fromObject(VirtualFrame frame, Object cl, Object object, TruffleSt @Cached BytesNodes.BytesFromObject bytesFromObject, @Cached IntNodes.PyLongFromByteArray fromByteArray, @Cached CallNode callCtor, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { boolean littleEndian; if (equalNode.execute(byteorder, T_BIG, TS_ENCODING)) { littleEndian = false; } else if (equalNode.execute(byteorder, T_LITTLE, TS_ENCODING)) { littleEndian = true; } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.BYTEORDER_MUST_BE_LITTLE_OR_BIG); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.BYTEORDER_MUST_BE_LITTLE_OR_BIG); } byte[] bytes; Object bytesObj = callBytes.executeObject(frame, object); if (bytesObj != PNone.NO_VALUE) { hasBytesProfile.enter(inliningTarget); if (!(bytesObj instanceof PBytes)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__); } bytes = bufferLib.getCopiedByteArray(bytesObj); } else { @@ -2843,7 +2843,7 @@ static TruffleString doPInt(PInt self, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, @Cached InlinedIntValueProfile maxDigitsProfile, @Cached InlinedIntValueProfile maxDigitsBitLengthProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); int intMaxStrDigits = maxDigitsProfile.profile(inliningTarget, context.getIntMaxStrDigits()); /* @@ -2861,7 +2861,7 @@ static TruffleString doPInt(PInt self, if (intMaxStrDigits > 0) { int bitLength = positiveBitLength(self); if (bitLength >= maxDigitsBitLengthProfile.profile(inliningTarget, context.getMinIntBitLengthOverLimit())) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION, intMaxStrDigits); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION, intMaxStrDigits); } } String value = self.toString(); @@ -2872,7 +2872,7 @@ static TruffleString doPInt(PInt self, if (intMaxStrDigits > 0) { int digits = self.isNegative() ? value.length() - 1 : value.length(); if (digits > intMaxStrDigits) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION); } } return fromJavaStringNode.execute(value, TS_ENCODING); @@ -2911,14 +2911,14 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "!formatString.isEmpty()") static TruffleString formatB(boolean self, TruffleString formatString, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return formatI(self ? 1 : 0, formatString, inliningTarget, raiseNode); } @Specialization(guards = "!formatString.isEmpty()") static TruffleString formatI(int self, TruffleString formatString, @Bind("this") Node inliningTarget, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Spec spec = getSpec(formatString, inliningTarget); if (isDoubleSpec(spec)) { return formatDouble(spec, self, inliningTarget); @@ -2932,7 +2932,7 @@ static TruffleString formatL(VirtualFrame frame, long self, TruffleString format @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached PyNumberFloatNode floatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return formatPI(frame, PFactory.createInt(language, self), formatString, inliningTarget, floatNode, raiseNode); } @@ -2940,7 +2940,7 @@ static TruffleString formatL(VirtualFrame frame, long self, TruffleString format static TruffleString formatPI(VirtualFrame frame, PInt self, TruffleString formatString, @Bind("this") Node inliningTarget, @Shared @Cached PyNumberFloatNode floatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Spec spec = getSpec(formatString, inliningTarget); if (isDoubleSpec(spec)) { // lazy init of floatNode serves as branch profile @@ -2987,15 +2987,15 @@ private static TruffleString formatPInt(PInt self, Spec spec, Node raisingNode) return formatter.pad().getResult(); } - private static void validateIntegerSpec(Node inliningTarget, PRaiseNode.Lazy raiseNode, Spec spec) { + private static void validateIntegerSpec(Node inliningTarget, PRaiseNode raiseNode, Spec spec) { if (Spec.specified(spec.precision)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.PRECISION_NOT_ALLOWED_FOR_INT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.PRECISION_NOT_ALLOWED_FOR_INT); } if (spec.type == 'c') { if (Spec.specified(spec.sign)) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SIGN_NOT_ALLOWED_WITH_C_FOR_INT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SIGN_NOT_ALLOWED_WITH_C_FOR_INT); } else if (spec.alternate) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ALTERNATE_NOT_ALLOWED_WITH_C_FOR_INT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ALTERNATE_NOT_ALLOWED_WITH_C_FOR_INT); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java index a92f61f607..4cd53ffff2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntNodes.java @@ -150,26 +150,26 @@ static byte[] doPrimitive(long value, int size, boolean bigEndian, @Specialization static byte[] doArbitraryBytesLong(Node inliningTarget, long value, int size, boolean bigEndian, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { final byte[] bytes = new byte[size]; NumericSupport support = bigEndian ? NumericSupport.bigEndian() : NumericSupport.littleEndian(); try { support.putBigInteger(bytes, 0, PInt.longToBigInteger(value), size); } catch (OverflowException oe) { - throw raiseNode.get(inliningTarget).raise(OverflowError, TOO_LARGE_TO_CONVERT, "int"); + throw raiseNode.raise(inliningTarget, OverflowError, TOO_LARGE_TO_CONVERT, "int"); } return bytes; } @Specialization static byte[] doPInt(Node inliningTarget, PInt value, int size, boolean bigEndian, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { final byte[] bytes = new byte[size]; NumericSupport support = bigEndian ? NumericSupport.bigEndian() : NumericSupport.littleEndian(); try { support.putBigInteger(bytes, 0, value.getValue(), size); } catch (OverflowException oe) { - throw raiseNode.get(inliningTarget).raise(OverflowError, TOO_LARGE_TO_CONVERT, "int"); + throw raiseNode.raise(inliningTarget, OverflowError, TOO_LARGE_TO_CONVERT, "int"); } return bytes; } @@ -198,7 +198,7 @@ static Object doOther(Node inliningTarget, byte[] data, boolean littleEndian, bo @Cached InlinedBranchProfile fastPath4, @Cached InlinedBranchProfile fastPath8, @Cached InlinedBranchProfile generic, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { NumericSupport support = littleEndian ? NumericSupport.littleEndian() : NumericSupport.bigEndian(); if (signed) { switch (data.length) { @@ -230,7 +230,7 @@ static Object doOther(Node inliningTarget, byte[] data, boolean littleEndian, bo return PFactory.createInt(PythonLanguage.get(inliningTarget), integer); } } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.BYTE_ARRAY_TOO_LONG_TO_CONVERT_TO_INT); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.BYTE_ARRAY_TOO_LONG_TO_CONVERT_TO_INT); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java index 7808530e9a..1b8e62a498 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java @@ -403,7 +403,7 @@ public double doubleValueWithOverflow(Node raisingNode) { public static double doubleValueWithOverflow(Node raisingNode, BigInteger value) { double d = value.doubleValue(); if (Double.isInfinite(d)) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.INT_TOO_LARGE_TO_CONVERT_TO_FLOAT); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.INT_TOO_LARGE_TO_CONVERT_TO_FLOAT); } return d; } @@ -605,7 +605,7 @@ public static int long2int(Node inliningTarget, long size, InlinedBranchProfile int intSize = (int) size; if (intSize != size) { errorProfile.enter(inliningTarget); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, size); } return intSize; } @@ -689,7 +689,6 @@ private boolean fitsIn(BigInteger left, BigInteger right) { * Creates a Python {@code int} object from a Java {@code long} value by interpreting it as an * unsigned number. * - * @param factory Python object factory * @param profile condition profile for the case when the unsigned value fits into Java * {@code long} * @param value the value diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java index 09427fc2b7..bb0cd3889d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java @@ -140,18 +140,18 @@ public abstract static class NextHelperNode extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object iterator, boolean throwStopIteration); - private static Object stopIteration(Node inliningTarget, PBuiltinIterator self, boolean throwStopIteration, PRaiseNode.Lazy raiseNode) { + private static Object stopIteration(Node inliningTarget, PBuiltinIterator self, boolean throwStopIteration, PRaiseNode raiseNode) { self.setExhausted(); if (throwStopIteration) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } else { return STOP_MARKER; } } - private static Object stopIterationForeign(Node inliningTarget, boolean throwStopIteration, PRaiseNode.Lazy raiseNode) { + private static Object stopIterationForeign(Node inliningTarget, boolean throwStopIteration, PRaiseNode raiseNode) { if (throwStopIteration) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } else { return STOP_MARKER; } @@ -159,9 +159,9 @@ private static Object stopIterationForeign(Node inliningTarget, boolean throwSto @Specialization(guards = "self.isExhausted()") static Object exhausted(Node inliningTarget, @SuppressWarnings("unused") PBuiltinIterator self, boolean throwStopIteration, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (throwStopIteration) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } else { return STOP_MARKER; } @@ -171,7 +171,7 @@ static Object exhausted(Node inliningTarget, @SuppressWarnings("unused") PBuilti static Object next(Node inliningTarget, PArrayIterator self, boolean throwStopIteration, @Cached InlinedExactClassProfile itemTypeProfile, @Cached ArrayNodes.GetValueNode getValueNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { PArray array = self.array; if (self.getIndex() < array.getLength()) { return itemTypeProfile.profile(inliningTarget, getValueNode.execute(inliningTarget, array, self.index++)); @@ -181,7 +181,7 @@ static Object next(Node inliningTarget, PArrayIterator self, boolean throwStopIt @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PIntegerSequenceIterator self, boolean throwStopIteration, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getIndex() < self.sequence.length()) { return self.sequence.getIntItemNormalized(self.index++); } @@ -190,7 +190,7 @@ static Object next(Node inliningTarget, PIntegerSequenceIterator self, boolean t @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PObjectSequenceIterator self, boolean throwStopIteration, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getIndex() < self.sequence.length()) { return self.sequence.getObjectItemNormalized(self.index++); } @@ -200,7 +200,7 @@ static Object next(Node inliningTarget, PObjectSequenceIterator self, boolean th @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PIntRangeIterator self, boolean throwStopIteration, @Exclusive @Cached InlinedConditionProfile profile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (profile.profile(inliningTarget, self.hasNextInt())) { return self.nextInt(); } @@ -210,7 +210,7 @@ static Object next(Node inliningTarget, PIntRangeIterator self, boolean throwSto @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PBigRangeIterator self, boolean throwStopIteration, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.hasNextBigInt()) { return PFactory.createInt(language, self.nextBigInt()); } @@ -219,7 +219,7 @@ static Object next(Node inliningTarget, PBigRangeIterator self, boolean throwSto @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PDoubleSequenceIterator self, boolean throwStopIteration, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getIndex() < self.sequence.length()) { return self.sequence.getDoubleItemNormalized(self.index++); } @@ -228,7 +228,7 @@ static Object next(Node inliningTarget, PDoubleSequenceIterator self, boolean th @Specialization(guards = "!self.isExhausted()") static Object next(Node inliningTarget, PLongSequenceIterator self, boolean throwStopIteration, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getIndex() < self.sequence.length()) { return self.sequence.getLongItemNormalized(self.index++); } @@ -239,7 +239,7 @@ static Object next(Node inliningTarget, PLongSequenceIterator self, boolean thro static Object next(Node inliningTarget, PStringIterator self, boolean throwStopIteration, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @Cached(inline = false) TruffleString.SubstringNode substringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.getIndex() < codePointLengthNode.execute(self.value, TS_ENCODING)) { return substringNode.execute(self.value, self.index++, 1, TS_ENCODING, false); } @@ -253,13 +253,13 @@ static Object nextHashingStorageIter(Node inliningTarget, PHashingStorageIterato @Cached HashingStorageIteratorNext nextNode, @Cached PHashingStorageIteratorNextValue itValueNode, @Exclusive @Cached InlinedConditionProfile profile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { HashingStorage storage = self.getHashingStorage(); final HashingStorageIterator it = self.getIterator(); if (profile.profile(inliningTarget, nextNode.execute(inliningTarget, storage, it))) { if (sizeChanged.profile(inliningTarget, self.checkSizeChanged(inliningTarget, lenNode))) { String name = PBaseSetIterator.isInstance(self) ? "Set" : "dictionary"; - throw raiseNode.get(inliningTarget).raise(RuntimeError, ErrorMessages.CHANGED_SIZE_DURING_ITERATION, name); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.CHANGED_SIZE_DURING_ITERATION, name); } self.index++; return itValueNode.execute(inliningTarget, self, storage, it); @@ -271,7 +271,7 @@ static Object nextHashingStorageIter(Node inliningTarget, PHashingStorageIterato static Object next(Node inliningTarget, PSequenceIterator self, boolean throwStopIteration, @Cached SequenceNodes.GetSequenceStorageNode getStorage, @Cached(value = "createNotNormalized()", inline = false) SequenceStorageNodes.GetItemNode getItemNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { SequenceStorage s = getStorage.execute(inliningTarget, self.getPSequence()); if (self.getIndex() < s.length()) { return getItemNode.execute(s, self.index++); @@ -283,7 +283,7 @@ static Object next(Node inliningTarget, PSequenceIterator self, boolean throwSto static Object next(VirtualFrame frame, Node inliningTarget, PSequenceIterator self, boolean throwStopIteration, @Cached(inline = false) PySequenceGetItemNode getItem, @Cached IsBuiltinObjectProfile profile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { /* * This must use PySequence_GetItem and not any other get item nodes. The reason is @@ -305,7 +305,7 @@ static Object foreign(Node inliningTarget, Object self, boolean throwStopIterati @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, @Cached(inline = false) PForeignToPTypeNode toPythonNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { final Object element; gil.release(true); @@ -597,9 +597,8 @@ static Object reduceNonSeq(@SuppressWarnings({"unused"}) VirtualFrame frame, PSe @Fallback static int other(Object self, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "iterator", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "iterator", self); } private static PTuple reduceInternal(VirtualFrame frame, Node inliningTarget, Object arg, PythonContext context, PyObjectGetAttr getAttrNode) { @@ -650,9 +649,8 @@ static Object setstate(VirtualFrame frame, PBuiltinIterator self, Object index, @Fallback static Object other(Object self, Object index, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "iterator", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "iterator", self); } protected static boolean isPBigRangeIterator(Object obj) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java index 00f0bb40e7..12b75fb4d9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -177,7 +177,7 @@ static int length(VirtualFrame frame, Node inliningTarget, Object iterable, @Cached IsBuiltinObjectProfile errorProfile, @Cached InlinedConditionProfile hasLenProfile, @Cached InlinedConditionProfile hasLengthHintProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object clazz = getClassNode.execute(inliningTarget, iterable); TpSlots slots = getSlotsNode.execute(inliningTarget, clazz); if (hasLenProfile.profile(inliningTarget, slots.combined_sq_mp_length() != null)) { @@ -204,11 +204,11 @@ static int length(VirtualFrame frame, Node inliningTarget, Object iterable, if (indexCheckNode.execute(inliningTarget, len)) { int intLen = asSizeNode.executeExact(frame, inliningTarget, len); if (intLen < 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.LENGTH_HINT_SHOULD_RETURN_MT_ZERO); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.LENGTH_HINT_SHOULD_RETURN_MT_ZERO); } return intLen; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_INTEGER_NOT_P, T___LENGTH_HINT__, len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_INTEGER_NOT_P, T___LENGTH_HINT__, len); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java index 41f11490d7..f48f59267f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java @@ -74,8 +74,8 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization(guards = "isEmpty(self.getIterators())") static Object doEmpty(@SuppressWarnings("unused") PZip self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } @Specialization(guards = {"!isEmpty(self.getIterators())", "!self.isStrict()"}) @@ -96,7 +96,7 @@ static Object doNext(VirtualFrame frame, PZip self, @Shared @Cached GetNextNode next, @Cached IsBuiltinObjectProfile classProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] iterators = self.getIterators(); Object[] tupleElements = new Object[iterators.length]; int i = 0; @@ -108,12 +108,12 @@ static Object doNext(VirtualFrame frame, PZip self, } catch (PException e) { e.expectStopIteration(inliningTarget, classProfile); if (i > 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_SHORTER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_SHORTER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i); } for (i = 1; i < iterators.length; i++) { try { next.execute(frame, iterators[i]); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_LONGER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_LONGER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i); } catch (PException e2) { e2.expectStopIteration(inliningTarget, classProfile); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java index b419a5a504..a93f9c27ef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java @@ -73,9 +73,9 @@ static Object doIterator(VirtualFrame frame, PSentinelIterator iterator, @Cached CallNode callNode, @Cached IsBuiltinObjectProfile errorProfile, @Cached PyObjectRichCompareBool.EqNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (iterator.sentinelReached()) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } Object nextValue; try { @@ -88,7 +88,7 @@ static Object doIterator(VirtualFrame frame, PSentinelIterator iterator, boolean iteratorDone = eqNode.compare(frame, inliningTarget, nextValue, iterator.getSentinel()); if (iteratorDone) { iterator.markSentinelReached(); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return nextValue; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java index 5b917c735b..09c0ffd1e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java @@ -110,7 +110,7 @@ static Object next(VirtualFrame frame, PChain self, @Cached IsBuiltinObjectProfile isStopIterationProfile, @Cached InlinedBranchProfile nextExceptioProfile, @Cached InlinedLoopConditionProfile loopProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { while (loopProfile.profile(inliningTarget, self.getSource() != PNone.NONE)) { if (self.getActive() == PNone.NONE) { try { @@ -130,7 +130,7 @@ static Object next(VirtualFrame frame, PChain self, self.setActive(PNone.NONE); } } - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } } @@ -185,13 +185,13 @@ static Object setState(VirtualFrame frame, PChain self, Object state, @Cached GetItemNode getItemNode, @Cached InlinedBranchProfile len2Profile, @Cached PyIterCheckNode iterCheckNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(state instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple"); } int len = (int) lenNode.execute(frame, state); if (len < 1 || len > 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "a length 1 or 2 tuple"); } Object source = getItemNode.execute(frame, state, 0); checkIterator(inliningTarget, iterCheckNode, source, raiseNode); @@ -205,9 +205,9 @@ static Object setState(VirtualFrame frame, PChain self, Object state, return PNone.NONE; } - private static void checkIterator(Node inliningTarget, PyIterCheckNode iterCheckNode, Object obj, PRaiseNode.Lazy raiseNode) throws PException { + private static void checkIterator(Node inliningTarget, PyIterCheckNode iterCheckNode, Object obj, PRaiseNode raiseNode) throws PException { if (!iterCheckNode.execute(inliningTarget, obj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ARGUMENTS_MUST_BE_ITERATORS); + throw raiseNode.raise(inliningTarget, TypeError, ARGUMENTS_MUST_BE_ITERATORS); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java index 902aba2cbf..932733c7fc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.itertools; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; @@ -105,8 +106,8 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "self.isStopped()") static Object nextStopped(PAbstractCombinations self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } @Specialization(guards = {"!self.isStopped()", "isLastResultNull(self)"}) @@ -130,7 +131,7 @@ static Object next(PCombinations self, @Bind("this") Node inliningTarget, @Shared @Cached InlinedLoopConditionProfile indexLoopProfile, @Shared @Cached InlinedLoopConditionProfile resultLoopProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode); } @@ -139,12 +140,12 @@ static Object next(PCombinationsWithReplacement self, @Bind("this") Node inliningTarget, @Shared @Cached InlinedLoopConditionProfile indexLoopProfile, @Shared @Cached InlinedLoopConditionProfile resultLoopProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode); } private static Object nextInternal(Node inliningTarget, PAbstractCombinations self, InlinedLoopConditionProfile indexLoopProfile, - InlinedLoopConditionProfile resultLoopProfile, PRaiseNode.Lazy raiseNode) throws PException { + InlinedLoopConditionProfile resultLoopProfile, PRaiseNode raiseNode) throws PException { CompilerAsserts.partialEvaluationConstant(self.getClass()); @@ -161,7 +162,7 @@ private static Object nextInternal(Node inliningTarget, PAbstractCombinations se // If i is negative, then the indices are all at their maximum value and we're done if (i < 0) { self.setStopped(true); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, StopIteration); } // Increment the current index which we know is not at its maximum. @@ -223,7 +224,7 @@ static Object setState(PAbstractCombinations self, Object stateObj, @Bind("this") Node inliningTarget, @Cached CastToJavaIntExactNode cast, @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int n = self.getPool().length; if (stateObj instanceof PTuple state && state.getSequenceStorage().length() == self.getR()) { SequenceStorage storage = state.getSequenceStorage(); @@ -240,7 +241,7 @@ static Object setState(PAbstractCombinations self, Object stateObj, self.getIndices()[i] = index; } } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } Object[] result = new Object[self.getR()]; for (int i = 0; i < self.getR(); i++) { @@ -249,7 +250,7 @@ static Object setState(PAbstractCombinations self, Object stateObj, self.setLastResult(result); return PNone.NONE; } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_ARGS, T___SETSTATE__); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_ARGS, T___SETSTATE__); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java index a06f28a1b8..6562eb0817 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java @@ -115,7 +115,7 @@ static Object next(VirtualFrame frame, PCycle self, @Cached IsBuiltinObjectProfile isStopIterationProfile, @Cached InlinedBranchProfile iterableProfile, @Cached InlinedBranchProfile firstPassProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getIterable() != null) { iterableProfile.enter(inliningTarget); try { @@ -131,7 +131,7 @@ static Object next(VirtualFrame frame, PCycle self, } } if (isEmpty(self.getSaved())) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } Object item = get(self.getSaved(), self.getIndex()); self.setIndex(self.getIndex() + 1); @@ -223,13 +223,13 @@ static Object setState(VirtualFrame frame, PCycle self, Object state, @Cached IsBuiltinObjectProfile isTypeErrorProfile, @Cached ToArrayNode toArrayNode, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!((state instanceof PTuple) && ((int) lenNode.execute(frame, state) == 2))) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "2-tuple"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "2-tuple"); } Object obj = getItemNode.execute(frame, state, 0); if (!(obj instanceof PList)) { - throw raiseNode.get(inliningTarget).raise(TypeError, STATE_ARGUMENT_D_MUST_BE_A_S, 1, "Plist"); + throw raiseNode.raise(inliningTarget, TypeError, STATE_ARGUMENT_D_MUST_BE_A_S, 1, "Plist"); } PList saved = (PList) obj; @@ -238,7 +238,7 @@ static Object setState(VirtualFrame frame, PCycle self, Object state, firstPass = asSizeNode.executeLossy(frame, inliningTarget, getItemNode.execute(frame, state, 1)) != 0; } catch (PException e) { e.expectTypeError(inliningTarget, isTypeErrorProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, STATE_ARGUMENT_D_MUST_BE_A_S, 2, "int"); + throw raiseNode.raise(inliningTarget, TypeError, STATE_ARGUMENT_D_MUST_BE_A_S, 2, "int"); } Object[] savedArray = toArrayNode.execute(inliningTarget, saved.getSequenceStorage()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java index 7243f932ad..3609a583f3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java @@ -140,11 +140,11 @@ public abstract static class SetStateNode extends PythonBinaryBuiltinNode { static Object setState(PDropwhile self, Object state, @Bind("this") Node inliningTarget, @Cached CastToJavaBooleanNode castToBoolean, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { self.setDoneDropping(castToBoolean.execute(inliningTarget, state)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_ARGS, T___SETSTATE__); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_ARGS, T___SETSTATE__); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java index d3b061d25d..1b5ac87fba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java @@ -168,9 +168,9 @@ static Object setState(VirtualFrame frame, PGroupBy self, Object state, @Bind("this") Node inliningTarget, @Cached TupleBuiltins.LenNode lenNode, @Cached TupleBuiltins.GetItemNode getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(state instanceof PTuple) || (int) lenNode.execute(frame, state) != 3) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "3-tuple"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "3-tuple"); } Object currValue = getItemNode.execute(frame, state, 0); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java index 06a07127df..80a5206723 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java @@ -104,11 +104,11 @@ static Object next(VirtualFrame frame, PGrouper self, @Cached InlinedBranchProfile currValueMarkerProfile, @Cached InlinedBranchProfile currValueTgtProfile, @Cached InlinedConditionProfile hasFuncProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PGroupBy gbo = self.getParent(); if (gbo.getCurrGrouper() != self) { currGrouperProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } if (gbo.getCurrValue() == null) { currValueMarkerProfile.enter(inliningTarget); @@ -116,7 +116,7 @@ static Object next(VirtualFrame frame, PGrouper self, } if (!eqNode.compare(frame, inliningTarget, self.getTgtKey(), gbo.getCurrKey())) { currValueTgtProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } Object r = gbo.getCurrValue(); gbo.setCurrValue(null); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java index b076d60e46..8a1d726f33 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.itertools; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; @@ -101,8 +102,8 @@ static Object iter(PIslice self) { public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization(guards = "isNone(self.getIterable())") static Object next(@SuppressWarnings("unused") PIslice self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } @Specialization(guards = "!isNone(self.getIterable())") @@ -113,7 +114,7 @@ static Object next(VirtualFrame frame, PIslice self, @Cached InlinedBranchProfile nextExceptionProfile, @Cached InlinedBranchProfile nextExceptionProfile2, @Cached InlinedBranchProfile setNextProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object it = self.getIterable(); int stop = self.getStop(); Object item; @@ -130,7 +131,7 @@ static Object next(VirtualFrame frame, PIslice self, } if (stop != -1 && self.getCnt() >= stop) { self.setIterable(PNone.NONE); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, StopIteration); } try { item = nextNode.execute(frame, it, PNone.NO_VALUE); @@ -184,11 +185,11 @@ public abstract static class SetStateNode extends PythonBinaryBuiltinNode { static Object setState(PIslice self, Object state, @Bind("this") Node inliningTarget, @Cached CastToJavaIntLossyNode castInt, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { self.setCnt(castInt.execute(inliningTarget, state)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_ARGS, T___SETSTATE__); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_ARGS, T___SETSTATE__); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java index 37ea4b0cbb..cb20fc0baa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java @@ -122,14 +122,14 @@ PTeeDataObject jumplink(PythonLanguage language) { return nextlink; } - Object getItem(VirtualFrame frame, Node inliningTarget, int i, BuiltinFunctions.NextNode nextNode, PRaiseNode.Lazy raiseNode) { + Object getItem(VirtualFrame frame, Node inliningTarget, int i, BuiltinFunctions.NextNode nextNode, PRaiseNode raiseNode) { assert i < TeeDataObjectBuiltins.LINKCELLS; if (i < numread) { return values[i]; } else { assert i == numread; if (running) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, CANNOT_REENTER_TEE_ITERATOR); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, CANNOT_REENTER_TEE_ITERATOR); } running = true; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java index 5cb777aceb..1f0b789210 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java @@ -112,8 +112,8 @@ static Object next(VirtualFrame frame, PPairwise self, @Specialization(guards = "self.getIterable() == null") static Object next(@SuppressWarnings("unused") PPairwise self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java index b1c9de1981..3500aa3628 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.itertools; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS; @@ -105,9 +106,9 @@ static Object iter(PPermutations self) { public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.isStopped()") static Object next(PPermutations self, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { self.setRaisedStopIteration(true); - throw raiseNode.raiseStopIteration(); + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } @Specialization(guards = "!self.isStopped()") @@ -119,7 +120,7 @@ static Object next(PPermutations self, @Cached InlinedLoopConditionProfile mainLoopProfile, @Cached InlinedLoopConditionProfile shiftIndicesProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int r = self.getR(); int[] indices = self.getIndices(); @@ -156,7 +157,7 @@ static Object next(PPermutations self, self.setStopped(true); if (isStartedProfile.profile(inliningTarget, self.isStarted())) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, StopIteration); } else { self.setStarted(true); } @@ -210,16 +211,16 @@ static Object setState(VirtualFrame frame, PPermutations self, Object state, @Cached InlinedLoopConditionProfile cyclesProfile, @Cached CastToJavaBooleanNode castBoolean, @Cached CastToJavaIntExactNode castInt, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (sizeNode.execute(frame, inliningTarget, state) != 3) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_ARGS, T___SETSTATE__); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_ARGS, T___SETSTATE__); } Object indices = getItemNode.execute(frame, state, 0); Object cycles = getItemNode.execute(frame, state, 1); int poolLen = self.getPool().length; if (sizeNode.execute(frame, inliningTarget, indices) != poolLen || sizeNode.execute(frame, inliningTarget, cycles) != self.getR()) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_ARGS, T___SETSTATE__); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_ARGS, T___SETSTATE__); } self.setStarted(castBoolean.execute(inliningTarget, getItemNode.execute(frame, state, 2))); @@ -247,7 +248,7 @@ static Object setState(VirtualFrame frame, PPermutations self, Object state, return PNone.NONE; } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java index 8a412aadae..73e109e2ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java @@ -120,7 +120,7 @@ static Object next(PProduct self, @Exclusive @Cached InlinedLoopConditionProfile loopProfile, @Cached InlinedBranchProfile doneProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[][] gears = self.getGears(); int x = gears.length - 1; if (gearsProfile.profile(inliningTarget, x >= 0)) { @@ -140,7 +140,7 @@ static Object next(PProduct self, if (self.isStopped()) { wasStoppedProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } // the existing lst array can be changed in a following next call @@ -152,8 +152,8 @@ static Object next(PProduct self, @SuppressWarnings("unused") @Specialization(guards = "self.isStopped()") static Object nextStopped(PProduct self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } private static void rotatePreviousGear(Node inliningTarget, PProduct self, InlinedLoopConditionProfile loopProfile, InlinedBranchProfile doneProfile) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java index 1a07d71706..a5e805f45f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.itertools; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.nodes.ErrorMessages.LEN_OF_UNSIZED_OBJECT; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; @@ -106,8 +107,8 @@ static Object nextPos(PRepeat self) { @SuppressWarnings("unused") @Specialization(guards = "self.getCnt() == 0") static Object nextZero(PRepeat self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } @Specialization(guards = "self.getCnt() < 0") @@ -127,8 +128,8 @@ static Object hintPos(PRepeat self) { @SuppressWarnings("unused") @Specialization(guards = "self.getCnt() < 0") static Object hintNeg(PRepeat self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, LEN_OF_UNSIZED_OBJECT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, LEN_OF_UNSIZED_OBJECT); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java index d0784fbad1..fc50ba486f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java @@ -97,11 +97,11 @@ static Object next(VirtualFrame frame, PTakewhile self, @Cached CallNode callNode, @Cached PyObjectIsTrueNode isTrue, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object value = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE); if (!isTrue.execute(frame, callNode.execute(frame, self.getPredicate(), value))) { self.setIterable(PFactory.createSequenceIterator(language, PFactory.createList(language, PythonUtils.EMPTY_OBJECT_ARRAY))); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return value; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java index 4fb2a302bb..775263a32a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java @@ -148,7 +148,7 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { static Object next(VirtualFrame frame, PTee self, @Bind("this") Node inliningTarget, @Shared @Cached BuiltinFunctions.NextNode nextNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object value = self.getDataobj().getItem(frame, inliningTarget, self.getIndex(), nextNode, raiseNode); self.setIndex(self.getIndex() + 1); return value; @@ -159,7 +159,7 @@ static Object nextNext(VirtualFrame frame, PTee self, @Bind("this") Node inliningTarget, @Shared @Cached BuiltinFunctions.NextNode nextNode, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.setDataObj(self.getDataobj().jumplink(language)); Object value = self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode); self.setIndex(1); @@ -194,14 +194,14 @@ static Object setState(VirtualFrame frame, PTee self, Object state, @Cached LenNode lenNode, @Cached TupleBuiltins.GetItemNode getItemNode, @Cached CastToJavaIntLossyNode castToIntNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!(state instanceof PTuple) || (int) lenNode.execute(frame, state) != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "2-tuple"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "2-tuple"); } Object dataObject = getItemNode.execute(frame, state, 0); if (!(dataObject instanceof PTeeDataObject)) { - throw raiseNode.get(inliningTarget).raise(TypeError, IS_NOT_A, "state", "_tee_dataobject"); + throw raiseNode.raise(inliningTarget, TypeError, IS_NOT_A, "state", "_tee_dataobject"); } self.setDataObj((PTeeDataObject) dataObject); Object secondElement = getItemNode.execute(frame, state, 1); @@ -209,10 +209,10 @@ static Object setState(VirtualFrame frame, PTee self, Object state, try { index = castToIntNode.execute(inliningTarget, secondElement); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, INTEGER_REQUIRED_GOT, secondElement); + throw raiseNode.raise(inliningTarget, TypeError, INTEGER_REQUIRED_GOT, secondElement); } if (index < 0 || index > LINKCELLS) { - throw raiseNode.get(inliningTarget).raise(ValueError, INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, INDEX_OUT_OF_RANGE); } self.setIndex(index); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java index 2fd392cea7..279dd0dfbf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeDataObjectBuiltins.java @@ -129,17 +129,17 @@ static Object init(VirtualFrame frame, PTeeDataObject self, Object it, PList val @Cached LenNode lenNode, @Cached SequenceStorageNodes.GetInternalObjectArrayNode getInternalObjectArrayNode, @Cached InlinedBranchProfile numreadLCProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int numread = (int) lenNode.execute(frame, values); if (numread == LINKCELLS) { numreadLCProfile.enter(inliningTarget); if (!(nxt instanceof PTeeDataObject)) { - throw raiseNode.get(inliningTarget).raise(ValueError, S_MUST_BE_S, "_tee_dataobject next link", "_tee_dataobject"); + throw raiseNode.raise(inliningTarget, ValueError, S_MUST_BE_S, "_tee_dataobject next link", "_tee_dataobject"); } } else if (numread > LINKCELLS) { - throw raiseNode.get(inliningTarget).raise(ValueError, TDATAOBJECT_SHOULD_NOT_HAVE_MORE_LINKS, LINKCELLS); + throw raiseNode.raise(inliningTarget, ValueError, TDATAOBJECT_SHOULD_NOT_HAVE_MORE_LINKS, LINKCELLS); } else if (!(nxt instanceof PNone)) { - throw raiseNode.get(inliningTarget).raise(ValueError, TDATAOBJECT_SHOULDNT_HAVE_NEXT); + throw raiseNode.raise(inliningTarget, ValueError, TDATAOBJECT_SHOULDNT_HAVE_NEXT); } self.setIt(it); Object[] valuesArray = getInternalObjectArrayNode.execute(inliningTarget, values.getSequenceStorage()); @@ -155,8 +155,8 @@ static Object init(VirtualFrame frame, PTeeDataObject self, Object it, PList val @SuppressWarnings("unused") @Specialization(guards = {"!isList(values)", "!isNone(values)"}) static Object init(VirtualFrame frame, PTeeDataObject self, Object it, Object values, Object nxt, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ARG_D_MUST_BE_S_NOT_P, "teedataobject()", 2, "list", values); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ARG_D_MUST_BE_S_NOT_P, "teedataobject()", 2, "list", values); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java index b2383c162c..ba82bf8630 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java @@ -97,8 +97,8 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "zeroSize(self)") static Object nextNoFillValue(VirtualFrame frame, PZipLongest self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, StopIteration); } @Specialization(guards = "!zeroSize(self)") @@ -110,13 +110,13 @@ static Object next(VirtualFrame frame, PZipLongest self, @Cached InlinedConditionProfile noActiveProfile, @Cached InlinedLoopConditionProfile loopProfile, @Cached InlinedConditionProfile isNullFillProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object fillValue = isNullFillProfile.profile(inliningTarget, isNullFillValue(self)) ? PNone.NONE : self.getFillValue(); return next(frame, inliningTarget, self, fillValue, nextNode, isStopIterationProfile, loopProfile, noItProfile, noActiveProfile, raiseNode); } private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest self, Object fillValue, BuiltinFunctions.NextNode nextNode, IsBuiltinObjectProfile isStopIterationProfile, - InlinedLoopConditionProfile loopProfile, InlinedConditionProfile noItProfile, InlinedConditionProfile noActiveProfile, PRaiseNode.Lazy raiseNode) { + InlinedLoopConditionProfile loopProfile, InlinedConditionProfile noItProfile, InlinedConditionProfile noActiveProfile, PRaiseNode raiseNode) { Object[] result = new Object[self.getItTuple().length]; loopProfile.profileCounted(inliningTarget, result.length); for (int i = 0; loopProfile.inject(inliningTarget, i < result.length); i++) { @@ -131,7 +131,7 @@ private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest if (isStopIterationProfile.profileException(inliningTarget, e, StopIteration)) { self.setNumActive(self.getNumActive() - 1); if (noActiveProfile.profile(inliningTarget, self.getNumActive() == 0)) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, StopIteration); } else { item = fillValue; self.getItTuple()[i] = PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index 764b804251..f3916c4527 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -308,7 +308,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, @Cached GetListStorageNode getStorageNode, @Cached InlinedConditionProfile validProfile, @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached SequenceStorageMpSubscriptNode subscriptNode) { if (!validProfile.profile(inliningTarget, SequenceStorageMpSubscriptNode.isValidIndex(inliningTarget, idx, indexCheckNode))) { raiseNonIntIndex(inliningTarget, raiseNode, idx); @@ -319,8 +319,8 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, } @InliningCutoff - private static void raiseNonIntIndex(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object index) { - raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "list", index); + private static void raiseNonIntIndex(Node inliningTarget, PRaiseNode raiseNode, Object index) { + raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "list", index); } } @@ -394,8 +394,8 @@ static void doGenericDel(VirtualFrame frame, Object list, Object key, @SuppressW @Specialization(guards = "!isIndexOrSlice(this, indexCheckNode, key)") static void doError(Object self, Object key, Object value, @Shared("indexCheckNode") @SuppressWarnings("unused") @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "list", key); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "list", key); } @NeverDefault @@ -519,7 +519,7 @@ static PNone remove(VirtualFrame frame, Object list, Object value, @Cached("createNotNormalized()") SequenceStorageNodes.GetItemNode getItemNode, @Cached SequenceStorageNodes.DeleteNode deleteNode, @Cached PyObjectRichCompareBool.EqNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage listStore = getStorageNode.execute(inliningTarget, list); int len = listStore.length(); for (int i = 0; i < len; i++) { @@ -529,7 +529,7 @@ static PNone remove(VirtualFrame frame, Object list, Object value, return PNone.NONE; } } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.NOT_IN_LIST_MESSAGE); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.NOT_IN_LIST_MESSAGE); } } @@ -564,8 +564,8 @@ static Object doIndex(VirtualFrame frame, Object list, Object idx, @Fallback static Object doError(@SuppressWarnings("unused") Object list, Object arg, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, arg); } @NeverDefault @@ -593,7 +593,7 @@ static Object index(VirtualFrame frame, Object self, Object value, int start, in @Cached InlinedBranchProfile startAdjust, @Cached InlinedBranchProfile stopAdjust, @Cached SequenceStorageNodes.ItemIndexNode indexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage s = getListStorageNode.execute(inliningTarget, self); start = adjustIndex(inliningTarget, s, start, startAdjust); stop = adjustIndex(inliningTarget, s, stop, stopAdjust); @@ -601,7 +601,7 @@ static Object index(VirtualFrame frame, Object self, Object value, int start, in if (idx != -1) { return idx; } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.X_NOT_IN_LIST); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.X_NOT_IN_LIST); } private static int adjustIndex(Node inliningTarget, SequenceStorage s, int index, InlinedBranchProfile profile) { @@ -692,14 +692,14 @@ public final Object execute(VirtualFrame frame, Object list) { static Object doPList(VirtualFrame frame, PList list, Object keyfunc, boolean reverse, @Bind("this") Node inliningTarget, @Shared @Cached SortSequenceStorageNode sortSequenceStorageNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = list.getSequenceStorage(); // Make the list temporarily empty to prevent concurrent modification list.setSequenceStorage(EmptySequenceStorage.INSTANCE); try { sortSequenceStorageNode.execute(frame, storage, keyfunc, reverse); if (list.getSequenceStorage() != EmptySequenceStorage.INSTANCE) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.LIST_MODIFIED_DURING_SORT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.LIST_MODIFIED_DURING_SORT); } } finally { list.setSequenceStorage(storage); @@ -754,9 +754,9 @@ static PList doPList(Object left, Object right, @Cached("createConcat()") SequenceStorageNodes.ConcatNode concatNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isListNode.execute(inliningTarget, right)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "list", right, "list"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "list", right, "list"); } var leftStorage = getStorageNode.execute(inliningTarget, left); @@ -805,7 +805,7 @@ static Object doPListInt(VirtualFrame frame, Object left, int right, @Cached GetListStorageNode getStorageNode, @Cached SequenceStorageNodes.RepeatNode repeatNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isListNode.execute(inliningTarget, left)) { return PNotImplemented.NOT_IMPLEMENTED; } @@ -815,7 +815,7 @@ static Object doPListInt(VirtualFrame frame, Object left, int right, SequenceStorage repeated = repeatNode.execute(frame, sequenceStorage, right); return PFactory.createList(language, repeated); } catch (ArithmeticException | OutOfMemoryError e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java index f57e595d9c..41fe34298e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java @@ -287,8 +287,8 @@ Object or(VirtualFrame frame, Object self, Object other) { abstract static class IOrNode extends PythonBinaryBuiltinNode { @Specialization static Object or(Object self, @SuppressWarnings("unused") Object other, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IOR_IS_NOT_SUPPORTED_BY_P_USE_INSTEAD, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.IOR_IS_NOT_SUPPORTED_BY_P_USE_INSTEAD, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java index 8425934da2..1cc0102b31 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java @@ -153,7 +153,7 @@ public abstract static class MemoryViewSqItemNode extends SqItemBuiltinNode { @Specialization static Object doInt(VirtualFrame frame, PMemoryView self, int index, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached MemoryViewNodes.PointerLookupNode pointerFromIndexNode, @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode) { self.checkReleased(inliningTarget, raiseNode); @@ -171,7 +171,7 @@ static Object getitem(VirtualFrame frame, PMemoryView self, Object index, @Bind("this") Node inliningTarget, @Cached MemoryViewNodes.PointerLookupNode pointerFromIndexNode, @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); MemoryViewNodes.MemoryPointer ptr = pointerFromIndexNode.execute(frame, self, index); return readItemAtNode.execute(frame, self, ptr.ptr, ptr.offset); @@ -185,10 +185,10 @@ static Object getitemSlice(PMemoryView self, PSlice slice, @Cached SliceNodes.SliceUnpack sliceUnpack, @Cached SliceNodes.AdjustIndices adjustIndices, @Cached MemoryViewNodes.InitFlagsNode initFlagsNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (zeroDimProfile.profile(inliningTarget, self.getDimensions() == 0)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); } int[] shape = self.getBufferShape(); PSlice.SliceInfo sliceInfo = adjustIndices.execute(inliningTarget, shape[0], sliceUnpack.execute(inliningTarget, slice)); @@ -211,12 +211,12 @@ static Object getitemSlice(PMemoryView self, PSlice slice, static Object getitemEllipsis(PMemoryView self, @SuppressWarnings("unused") PEllipsis ellipsis, @Bind("this") Node inliningTarget, @Exclusive @Cached InlinedConditionProfile zeroDimProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (zeroDimProfile.profile(inliningTarget, self.getDimensions() == 0)) { return self; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_INVALID_SLICE_KEY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_INVALID_SLICE_KEY); } } @@ -228,7 +228,7 @@ static void setitem(VirtualFrame frame, PMemoryView self, Object index, Object o @Bind("this") Node inliningTarget, @Shared @Cached MemoryViewNodes.PointerLookupNode pointerLookupNode, @Shared @Cached MemoryViewNodes.WriteItemAtNode writeItemAtNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); checkReadonly(inliningTarget, self, raiseNode); @@ -245,18 +245,18 @@ static void setitem(VirtualFrame frame, PMemoryView self, PSlice slice, Object o @Shared @Cached MemoryViewNodes.PointerLookupNode pointerLookupNode, @Cached MemoryViewNodes.ToJavaBytesNode toJavaBytesNode, @Cached MemoryViewNodes.WriteBytesAtNode writeBytesAtNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); checkReadonly(inliningTarget, self, raiseNode); if (self.getDimensions() != 1) { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.MEMORYVIEW_SLICE_ASSIGNMENT_RESTRICTED_TO_DIM_1); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_SLICE_ASSIGNMENT_RESTRICTED_TO_DIM_1); } PMemoryView srcView = createMemoryView.execute(frame, object); try { PMemoryView destView = (PMemoryView) getItemNode.execute(frame, self, slice); try { if (srcView.getDimensions() != destView.getDimensions() || srcView.getBufferShape()[0] != destView.getBufferShape()[0] || srcView.getFormat() != destView.getFormat()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEMORYVIEW_DIFFERENT_STRUCTURES); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEMORYVIEW_DIFFERENT_STRUCTURES); } // The intermediate array is necessary for overlapping views (where src and dest // are the same buffer) @@ -279,26 +279,26 @@ static void setitem(VirtualFrame frame, PMemoryView self, @SuppressWarnings("unu @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile zeroDimProfile, @Shared @Cached MemoryViewNodes.WriteItemAtNode writeItemAtNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); checkReadonly(inliningTarget, self, raiseNode); if (zeroDimProfile.profile(inliningTarget, self.getDimensions() == 0)) { writeItemAtNode.execute(frame, self, self.getBufferPointer(), 0, object); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); } } @Specialization(guards = "isNoValue(value)") static void error(@SuppressWarnings("unused") PMemoryView self, @SuppressWarnings("unused") Object key, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_DELETE_MEMORY); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_DELETE_MEMORY); } - private static void checkReadonly(Node inliningTarget, PMemoryView self, PRaiseNode.Lazy raiseNode) { + private static void checkReadonly(Node inliningTarget, PMemoryView self, PRaiseNode raiseNode) { if (self.isReadOnly()) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_MODIFY_READONLY_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_MODIFY_READONLY_MEMORY); } } @@ -428,7 +428,7 @@ Object tolistCached(VirtualFrame frame, PMemoryView self, @Bind PythonLanguage language, @Cached("self.getDimensions()") int cachedDimensions, @Shared @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (cachedDimensions == 0) { // That's not a list but CPython does it this way @@ -443,7 +443,7 @@ Object tolist(VirtualFrame frame, PMemoryView self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached MemoryViewNodes.ReadItemAtNode readItemAtNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (self.getDimensions() == 0) { return readItemAtNode.execute(frame, self, self.getBufferPointer(), self.getOffset()); @@ -502,7 +502,7 @@ PBytes tobytes(PMemoryView self, TruffleString order, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached TruffleString.EqualNode equalNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); byte[] bytes; // The nodes act as branch profiles @@ -511,7 +511,7 @@ PBytes tobytes(PMemoryView self, TruffleString order, } else if (equalNode.execute(order, T_F, TS_ENCODING)) { bytes = getToJavaBytesFortranOrderNode().execute(self); } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ORDER_MUST_BE_C_F_OR_A); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ORDER_MUST_BE_C_F_OR_A); } return PFactory.createBytes(language, bytes); } @@ -550,7 +550,7 @@ TruffleString none(PMemoryView self, @SuppressWarnings("unused") PNone sep, @Sup @Shared("p") @Cached InlinedConditionProfile earlyExit, @Shared("b") @Cached MemoryViewNodes.ToJavaBytesNode toJavaBytesNode, @Shared("h") @Cached BytesNodes.ByteToHexNode toHexNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return hex(self, (byte) 0, 0, inliningTarget, earlyExit, toJavaBytesNode, toHexNode, raiseNode); } @@ -560,7 +560,7 @@ TruffleString hex(PMemoryView self, byte sep, int bytesPerSepGroup, @Shared("p") @Cached InlinedConditionProfile earlyExit, @Shared("b") @Cached MemoryViewNodes.ToJavaBytesNode toJavaBytesNode, @Shared("h") @Cached BytesNodes.ByteToHexNode toHexNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (earlyExit.profile(inliningTarget, self.getLength() == 0)) { return T_EMPTY_STRING; @@ -587,7 +587,7 @@ public final Object call(VirtualFrame frame, Object arg) { static PMemoryView toreadonly(PMemoryView self, @Bind PythonLanguage language, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return PFactory.createMemoryView(language, PythonContext.get(inliningTarget), self.getLifecycleManager(), self.getBuffer(), self.getOwner(), self.getLength(), true, self.getItemSize(), self.getFormat(), self.getFormatString(), self.getDimensions(), self.getBufferPointer(), @@ -605,7 +605,7 @@ static PMemoryView cast(PMemoryView self, TruffleString formatString, @SuppressW @Bind("this") Node inliningTarget, @Shared @Cached TruffleString.CodePointLengthNode lengthNode, @Shared @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return doCast(inliningTarget, self, formatString, 1, null, PythonContext.get(inliningTarget), lengthNode, atIndexNode, raiseNode); } @@ -618,7 +618,7 @@ static PMemoryView cast(VirtualFrame frame, PMemoryView self, TruffleString form @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached TruffleString.CodePointLengthNode lengthNode, @Shared @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, shapeObj); int ndim = storage.length(); @@ -626,7 +626,7 @@ static PMemoryView cast(VirtualFrame frame, PMemoryView self, TruffleString form for (int i = 0; i < ndim; i++) { shape[i] = asSizeNode.executeExact(frame, inliningTarget, getItemScalarNode.execute(inliningTarget, storage, i)); if (shape[i] <= 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CAST_ELEMENTS_MUST_BE_POSITIVE_INTEGERS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CAST_ELEMENTS_MUST_BE_POSITIVE_INTEGERS); } } return doCast(inliningTarget, self, formatString, ndim, shape, PythonContext.get(inliningTarget), lengthNode, atIndexNode, raiseNode); @@ -635,30 +635,30 @@ static PMemoryView cast(VirtualFrame frame, PMemoryView self, TruffleString form @Specialization(guards = {"!isPTuple(shape)", "!isList(shape)", "!isPNone(shape)"}) @SuppressWarnings("unused") static PMemoryView error(PMemoryView self, TruffleString format, Object shape, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ARG_S_MUST_BE_A_LIST_OR_TUPLE, "shape"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ARG_S_MUST_BE_A_LIST_OR_TUPLE, "shape"); } private static PMemoryView doCast(Node inliningTarget, PMemoryView self, TruffleString formatString, int ndim, int[] shape, PythonContext context, TruffleString.CodePointLengthNode lengthNode, - TruffleString.CodePointAtIndexNode atIndexNode, PRaiseNode.Lazy raiseNode) { + TruffleString.CodePointAtIndexNode atIndexNode, PRaiseNode raiseNode) { if (!self.isCContiguous()) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CASTS_RESTRICTED_TO_C_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CASTS_RESTRICTED_TO_C_CONTIGUOUS); } BufferFormat format = BufferFormat.forMemoryView(formatString, lengthNode, atIndexNode); int itemsize = format.bytesize; if (itemsize < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEMORYVIEW_DESTINATION_FORMAT_ERROR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEMORYVIEW_DESTINATION_FORMAT_ERROR); } if (!MemoryViewNodes.isByteFormat(format) && !MemoryViewNodes.isByteFormat(self.getFormat())) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CANNOT_CAST_NON_BYTE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CANNOT_CAST_NON_BYTE); } if (self.getLength() % itemsize != 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_LENGTH_NOT_MULTIPLE_OF_ITEMSIZE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_LENGTH_NOT_MULTIPLE_OF_ITEMSIZE); } if (shape != null || self.getDimensions() != 1) { for (int i = 0; i < self.getDimensions(); i++) { if (self.getBufferShape()[i] == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CANNOT_CAST_VIEW_WITH_ZEROS_IN_SHAPE_OR_STRIDES); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CANNOT_CAST_VIEW_WITH_ZEROS_IN_SHAPE_OR_STRIDES); } } } @@ -670,24 +670,24 @@ private static PMemoryView doCast(Node inliningTarget, PMemoryView self, Truffle newStrides = null; flags |= PMemoryView.FLAG_SCALAR; if (self.getLength() != itemsize) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CAST_WRONG_LENGTH); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CAST_WRONG_LENGTH); } } else { if (shape == null) { newShape = new int[]{self.getLength() / itemsize}; } else { if (ndim != 1 && self.getDimensions() != 1) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CAST_MUST_BE_1D_TO_ND_OR_ND_TO_1D); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CAST_MUST_BE_1D_TO_ND_OR_ND_TO_1D); } if (ndim > PMemoryView.MAX_DIM) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEMORYVIEW_NUMBER_OF_DIMENSIONS_MUST_NOT_EXCEED_D, ndim); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEMORYVIEW_NUMBER_OF_DIMENSIONS_MUST_NOT_EXCEED_D, ndim); } int newLength = itemsize; for (int i = 0; i < ndim; i++) { newLength *= shape[i]; } if (newLength != self.getLength()) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_CAST_WRONG_LENGTH); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_CAST_WRONG_LENGTH); } newShape = shape; } @@ -713,7 +713,7 @@ public abstract static class LenNode extends LenBuiltinNode { static int len(PMemoryView self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile zeroDimProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return zeroDimProfile.profile(inliningTarget, self.getDimensions() == 0) ? 1 : self.getBufferShape()[0]; } @@ -742,13 +742,13 @@ static int hash(PMemoryView self, @Cached InlinedConditionProfile cachedProfile, @Cached InlinedConditionProfile writableProfile, @Cached MemoryViewNodes.ToJavaBytesNode toJavaBytesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (cachedProfile.profile(inliningTarget, self.getCachedHash() != -1)) { return self.getCachedHash(); } self.checkReleased(inliningTarget, raiseNode); if (writableProfile.profile(inliningTarget, !self.isReadOnly())) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_HASH_WRITEABLE_MEMORYVIEW); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_HASH_WRITEABLE_MEMORYVIEW); } else { // TODO avoid copying int hash = hashArray(toJavaBytesNode.execute(self)); @@ -769,7 +769,7 @@ public abstract static class EnterNode extends PythonUnaryBuiltinNode { @Specialization static Object enter(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self; } @@ -805,7 +805,7 @@ public abstract static class ItemSizeNode extends PythonUnaryBuiltinNode { @Specialization static int get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.getItemSize(); } @@ -818,7 +818,7 @@ public abstract static class NBytesNode extends PythonUnaryBuiltinNode { @Specialization static int get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.getLength(); } @@ -831,7 +831,7 @@ public abstract static class ObjNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.getOwner() != null ? self.getOwner() : PNone.NONE; } @@ -844,7 +844,7 @@ public abstract static class FormatNode extends PythonUnaryBuiltinNode { @Specialization static Object get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.getFormatString() != null ? self.getFormatString() : T_UINT_8_TYPE_CODE; } @@ -859,7 +859,7 @@ static Object get(PMemoryView self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferShape() == null)) { return PFactory.createEmptyTuple(language); @@ -877,7 +877,7 @@ static Object get(PMemoryView self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferStrides() == null)) { return PFactory.createEmptyTuple(language); @@ -895,7 +895,7 @@ static Object get(PMemoryView self, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Cached InlinedConditionProfile nullProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); if (nullProfile.profile(inliningTarget, self.getBufferSuboffsets() == null)) { return PFactory.createEmptyTuple(language); @@ -911,7 +911,7 @@ public abstract static class ReadonlyNode extends PythonUnaryBuiltinNode { @Specialization static boolean get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.isReadOnly(); } @@ -924,7 +924,7 @@ public abstract static class NDimNode extends PythonUnaryBuiltinNode { @Specialization static int get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.getDimensions(); } @@ -937,7 +937,7 @@ public abstract static class CContiguousNode extends PythonUnaryBuiltinNode { @Specialization static boolean get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.isCContiguous(); } @@ -950,7 +950,7 @@ public abstract static class FContiguousNode extends PythonUnaryBuiltinNode { @Specialization static boolean get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.isFortranContiguous(); } @@ -963,7 +963,7 @@ public abstract static class ContiguousNode extends PythonUnaryBuiltinNode { @Specialization static boolean get(PMemoryView self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); return self.isAnyContiguous(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewNodes.java index 227216af94..00d5a649ba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewNodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -103,7 +103,7 @@ static void checkBufferBounds(Node node, PMemoryView self, PythonBufferAccessLib * reference counting. */ CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(node, IndexError, ErrorMessages.INVALID_BUFFER_ACCESS); + throw PRaiseNode.raiseStatic(node, IndexError, ErrorMessages.INVALID_BUFFER_ACCESS); } } @@ -158,7 +158,7 @@ static Object unpack(Node inliningTarget, BufferFormat format, @SuppressWarnings @Fallback @SuppressWarnings("unused") static Object notImplemented(Node inliningTarget, BufferFormat format, TruffleString formatStr, Object buffer, int offset) { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_FORMAT_S_NOT_SUPPORTED, formatStr); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_FORMAT_S_NOT_SUPPORTED, formatStr); } } @@ -172,19 +172,19 @@ public abstract static class PackValueNode extends Node { static void pack(VirtualFrame frame, Node inliningTarget, BufferFormat format, TruffleString formatStr, Object value, Object buffer, int offset, @Cached IsBuiltinObjectProfile errorProfile, @Cached BufferStorageNodes.PackValueNode packValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { packValueNode.execute(frame, inliningTarget, format, value, buffer, offset); } catch (PException e) { e.expect(inliningTarget, OverflowError, errorProfile); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEMORYVIEW_INVALID_VALUE_FOR_FORMAT_S, formatStr); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEMORYVIEW_INVALID_VALUE_FOR_FORMAT_S, formatStr); } } @Fallback @SuppressWarnings("unused") static void notImplemented(Node inliningTarget, BufferFormat format, TruffleString formatStr, Object object, Object buffer, int offset) { - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_FORMAT_S_NOT_SUPPORTED, formatStr); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.MEMORYVIEW_FORMAT_S_NOT_SUPPORTED, formatStr); } } @@ -340,7 +340,7 @@ abstract static class PointerLookupNode extends Node { public abstract MemoryPointer execute(VirtualFrame frame, PMemoryView self, int index); - private void lookupDimension(Node inliningTarget, PMemoryView self, MemoryPointer ptr, int dim, int initialIndex, InlinedConditionProfile hasSuboffsetsProfile, PRaiseNode.Lazy raiseNode) { + private void lookupDimension(Node inliningTarget, PMemoryView self, MemoryPointer ptr, int dim, int initialIndex, InlinedConditionProfile hasSuboffsetsProfile, PRaiseNode raiseNode) { int index = initialIndex; int[] shape = self.getBufferShape(); int nitems = shape[dim]; @@ -348,7 +348,7 @@ private void lookupDimension(Node inliningTarget, PMemoryView self, MemoryPointe index += nitems; } if (index < 0 || index >= nitems) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS_ON_DIMENSION_D, dim + 1); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.INDEX_OUT_OF_BOUNDS_ON_DIMENSION_D, dim + 1); } ptr.offset += self.getBufferStrides()[dim] * index; @@ -367,17 +367,17 @@ MemoryPointer resolveInt(PMemoryView self, int index, @Bind("this") Node inliningTarget, @Shared @Cached InlinedConditionProfile hasOneDimensionProfile, @Shared @Cached InlinedConditionProfile hasSuboffsetsProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (hasOneDimensionProfile.profile(inliningTarget, self.getDimensions() == 1)) { MemoryPointer ptr = new MemoryPointer(self.getBufferPointer(), self.getOffset()); lookupDimension(inliningTarget, self, ptr, 0, index, hasSuboffsetsProfile, raiseNode); return ptr; } if (self.getDimensions() == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); } else { // CPython doesn't implement this either, as of 3.8 - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.MULTI_DIMENSIONAL_SUB_VIEWS_NOT_IMPLEMENTED); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.MULTI_DIMENSIONAL_SUB_VIEWS_NOT_IMPLEMENTED); } } @@ -391,7 +391,7 @@ MemoryPointer resolveTupleCached(VirtualFrame frame, PMemoryView self, PTuple in @Cached("self.getDimensions()") int cachedDimensions, @Shared @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage indicesStorage = getSequenceStorageNode.execute(inliningTarget, indices); checkTupleLength(inliningTarget, indicesStorage, cachedDimensions, raiseNode); MemoryPointer ptr = new MemoryPointer(self.getBufferPointer(), self.getOffset()); @@ -410,7 +410,7 @@ MemoryPointer resolveTupleGeneric(VirtualFrame frame, PMemoryView self, PTuple i @Shared @Cached PyIndexCheckNode indexCheckNode, @Shared @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { SequenceStorage indicesStorage = getSequenceStorageNode.execute(inliningTarget, indices); int ndim = self.getDimensions(); checkTupleLength(inliningTarget, indicesStorage, ndim, raiseNode); @@ -429,30 +429,30 @@ MemoryPointer resolveIntObj(VirtualFrame frame, PMemoryView self, Object indexOb @Shared @Cached InlinedConditionProfile hasOneDimensionProfile, @Shared @Cached InlinedConditionProfile hasSuboffsetsProfile, @Shared @Cached PyIndexCheckNode indexCheckNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { final int index = convertIndex(frame, inliningTarget, indexCheckNode, indexObj, raiseNode); return resolveInt(self, index, inliningTarget, hasOneDimensionProfile, hasSuboffsetsProfile, raiseNode); } - private static void checkTupleLength(Node inliningTarget, SequenceStorage indicesStorage, int ndim, PRaiseNode.Lazy raiseNode) { + private static void checkTupleLength(Node inliningTarget, SequenceStorage indicesStorage, int ndim, PRaiseNode raiseNode) { int length = indicesStorage.length(); if (length == ndim) { return; } // Error cases if (ndim == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INVALID_INDEXING_OF_0_DIM_MEMORY); } else if (length > ndim) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_INDEX_D_DIMENSION_VIEW_WITH_D, ndim, length); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_INDEX_D_DIMENSION_VIEW_WITH_D, ndim, length); } else { // CPython doesn't implement this either, as of 3.8 - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.SUB_VIEWS_NOT_IMPLEMENTED); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.SUB_VIEWS_NOT_IMPLEMENTED); } } - private int convertIndex(VirtualFrame frame, Node inliningTarget, PyIndexCheckNode indexCheckNode, Object indexObj, PRaiseNode.Lazy raiseNode) { + private int convertIndex(VirtualFrame frame, Node inliningTarget, PyIndexCheckNode indexCheckNode, Object indexObj, PRaiseNode raiseNode) { if (!indexCheckNode.execute(inliningTarget, indexObj)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_INVALID_SLICE_KEY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_INVALID_SLICE_KEY); } return getAsSizeNode().executeExact(frame, inliningTarget, indexObj, IndexError); } @@ -486,7 +486,7 @@ byte[] tobytesCached(PMemoryView self, @Cached("self.getDimensions()") int cachedDimensions, @Shared @Cached ReadBytesAtNode readBytesAtNode, @Shared @Cached CExtNodes.PCallCapiFunction callCapiFunction, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); byte[] bytes = new byte[self.getLength()]; if (cachedDimensions == 0) { @@ -502,7 +502,7 @@ byte[] tobytesGeneric(PMemoryView self, @Bind("this") Node inliningTarget, @Shared @Cached ReadBytesAtNode readBytesAtNode, @Shared @Cached CExtNodes.PCallCapiFunction callCapiFunction, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { self.checkReleased(inliningTarget, raiseNode); byte[] bytes = new byte[self.getLength()]; if (self.getDimensions() == 0) { @@ -596,8 +596,9 @@ public final void execute(PMemoryView self) { @Specialization(guards = "self.getReference() == null") static void releaseSimple(PMemoryView self, + @Bind("this") Node inliningTarget, @Shared("raise") @Cached PRaiseNode raiseNode) { - self.checkExports(raiseNode); + self.checkExports(inliningTarget, raiseNode); self.setReleased(); } @@ -607,7 +608,7 @@ static void releaseNative(VirtualFrame frame, PMemoryView self, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached ReleaseBufferNode releaseNode, @Shared("raise") @Cached PRaiseNode raiseNode) { - self.checkExports(raiseNode); + self.checkExports(inliningTarget, raiseNode); if (self.checkShouldReleaseBuffer()) { releaseNode.execute(frame, inliningTarget, indirectCallData, self.getLifecycleManager()); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/PMemoryView.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/PMemoryView.java index fb958911da..f0eed188e5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/PMemoryView.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/PMemoryView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -250,9 +250,9 @@ public void setShouldReleaseImmediately(boolean shouldReleaseImmediately) { this.shouldReleaseImmediately = shouldReleaseImmediately; } - public void checkReleased(Node inliningTarget, PRaiseNode.Lazy raiseNode) { + public void checkReleased(Node inliningTarget, PRaiseNode raiseNode) { if (isReleased()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.MEMORYVIEW_FORBIDDEN_RELEASED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.MEMORYVIEW_FORBIDDEN_RELEASED); } } @@ -263,10 +263,10 @@ boolean checkShouldReleaseBuffer() { return false; } - void checkExports(PRaiseNode node) { + void checkExports(Node inliningTarget, PRaiseNode node) { long exportsValue = getExports().get(); if (exportsValue > 0) { - throw node.raise(BufferError, ErrorMessages.MEMORYVIEW_HAS_D_EXPORTED_BUFFERS, exportsValue); + throw node.raise(inliningTarget, BufferError, ErrorMessages.MEMORYVIEW_HAS_D_EXPORTED_BUFFERS, exportsValue); } } @@ -290,29 +290,29 @@ int getBufferLength() { @ExportMessage Object acquire(int requestedFlags, @Bind("$node") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkReleased(inliningTarget, raiseNode); if (BufferFlags.requestsWritable(requestedFlags) && readonly) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_WRITABLE); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_WRITABLE); } if (BufferFlags.requestsCContiguous(requestedFlags) && !isCContiguous()) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_C_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_C_CONTIGUOUS); } if (BufferFlags.requestsFContiguous(requestedFlags) && !isFortranContiguous()) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_FORTRAN_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_FORTRAN_CONTIGUOUS); } if (BufferFlags.requestsAnyContiguous(requestedFlags) && !isAnyContiguous()) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_CONTIGUOUS); } if (!BufferFlags.requestsIndirect(requestedFlags) && (flags & FLAG_PIL) != 0) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_REQUIRES_SUBOFFSETS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_REQUIRES_SUBOFFSETS); } if (!BufferFlags.requestsStrides(requestedFlags) && !isCContiguous()) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_C_CONTIGUOUS); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_UNDERLYING_BUF_ISNT_C_CONTIGUOUS); } // TODO should reflect the cast to unsigned bytes if necessary if (!BufferFlags.requestsShape(requestedFlags) && BufferFlags.requestsFormat(requestedFlags)) { - throw raiseNode.get(inliningTarget).raise(BufferError, ErrorMessages.MV_CANNOT_CAST_UNSIGNED_BYTES_IF_FMT_FLAG); + throw raiseNode.raise(inliningTarget, BufferError, ErrorMessages.MV_CANNOT_CAST_UNSIGNED_BYTES_IF_FMT_FLAG); } exports.incrementAndGet(); return this; @@ -329,7 +329,7 @@ void release( * should be no such helper memoryviews, the C buffer should have a separate implementation. */ if (shouldReleaseImmediately) { - checkExports(raiseNode); + checkExports(inliningTarget, raiseNode); if (checkShouldReleaseBuffer()) { releaseNode.execute(inliningTarget, getLifecycleManager()); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractBuiltinMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractBuiltinMethodBuiltins.java index 19861c30e8..815e3ca134 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractBuiltinMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractBuiltinMethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -116,7 +116,7 @@ static TruffleString getQualName(VirtualFrame frame, PMethod method, @Shared @Cached InlinedConditionProfile isGlobalProfile, @Shared @Cached GetClassNode getClassNode, @Shared @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return makeQualname(frame, inliningTarget, method, method.getSelf(), getQualNameAttrNode, getNameAttrNode, castToStringNode, getClassNode, isTypeNode, isGlobalProfile, simpleTruffleStringFormatNode, raiseNode); } @@ -131,19 +131,19 @@ static TruffleString getQualName(VirtualFrame frame, PBuiltinMethod method, @Shared @Cached InlinedConditionProfile isGlobalProfile, @Shared @Cached GetClassNode getClassNode, @Shared @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return makeQualname(frame, inliningTarget, method, method.getSelf(), getQualNameAttrNode, getNameAttrNode, castToStringNode, getClassNode, isTypeNode, isGlobalProfile, simpleTruffleStringFormatNode, raiseNode); } private static TruffleString makeQualname(VirtualFrame frame, Node inliningTarget, Object method, Object self, GetAttributeNode getQualNameAttrNode, GetAttributeNode getNameAttrNode, CastToTruffleStringNode castToStringNode, GetClassNode getClassNode, TypeNodes.IsTypeNode isTypeNode, InlinedConditionProfile isGlobalProfile, - SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, PRaiseNode.Lazy raiseNode) { + SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, PRaiseNode raiseNode) { TruffleString methodName; try { methodName = castToStringNode.execute(inliningTarget, getNameAttrNode.executeObject(frame, method)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___NAME__); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___NAME__); } if (isGlobalProfile.profile(inliningTarget, self == PNone.NO_VALUE || self instanceof PythonModule)) { return methodName; @@ -154,7 +154,7 @@ private static TruffleString makeQualname(VirtualFrame frame, Node inliningTarge try { typeQualName = castToStringNode.execute(inliningTarget, getQualNameAttrNode.executeObject(frame, type)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___QUALNAME__); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___QUALNAME__); } return simpleTruffleStringFormatNode.format("%s.%s", typeQualName, methodName); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java index c7405fdaa4..1591ecff5b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/AbstractMethodBuiltins.java @@ -245,8 +245,8 @@ static Object getModule(VirtualFrame frame, PMethod self, @SuppressWarnings("unu @Specialization(guards = "!isNoValue(value)") static Object getModule(@SuppressWarnings("unused") PMethod self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "method", T___MODULE__); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_S_HAS_NO_ATTR_S, "method", T___MODULE__); } } @@ -333,7 +333,7 @@ static TruffleString doSelfIsObject(VirtualFrame frame, PMethod method, @Shared("getQualname") @Cached PyObjectGetAttr getQualname, @Shared("lookupName") @Cached PyObjectLookupAttr lookupName, @Shared("formatter") @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return getQualName(frame, inliningTarget, method.getSelf(), method.getFunction(), getClassNode, isTypeNode, toStringNode, getQualname, lookupName, simpleTruffleStringFormatNode, raiseNode); } @@ -347,21 +347,21 @@ static TruffleString doSelfIsObject(VirtualFrame frame, PBuiltinMethod method, @Shared("getQualname") @Cached PyObjectGetAttr getQualname, @Shared("lookupName") @Cached PyObjectLookupAttr lookupName, @Shared("formatter") @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return getQualName(frame, inliningTarget, method.getSelf(), method.getFunction(), getClassNode, isTypeNode, toStringNode, getQualname, lookupName, simpleTruffleStringFormatNode, raiseNode); } private static TruffleString getQualName(VirtualFrame frame, Node inliningTarget, Object self, Object func, GetClassNode getClassNode, TypeNodes.IsTypeNode isTypeNode, CastToTruffleStringNode toStringNode, PyObjectGetAttr getQualname, PyObjectLookupAttr lookupName, SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object type = isTypeNode.execute(inliningTarget, self) ? self : getClassNode.execute(inliningTarget, self); try { TruffleString typeQualName = toStringNode.execute(inliningTarget, getQualname.execute(frame, inliningTarget, type, T___QUALNAME__)); return simpleTruffleStringFormatNode.format("%s.%s", typeQualName, getName(frame, inliningTarget, func, toStringNode, lookupName)); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___QUALNAME__); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_UNICODE_OBJECT, T___QUALNAME__); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java index b0c80b9bc1..5aef32c3ca 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -152,7 +152,7 @@ public Object doIt(Object fun, @Bind("this") Node inliningTarget) { Signature signature = GetSignatureNode.executeUncached(fun); if (signature.isHidden()) { - throw PRaiseNode.raiseUncached(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__); + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__); } return BuiltinFunctionBuiltins.SignatureNode.createInspectSignature(signature, true); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java index ec4bf97bfe..631db6babe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java @@ -127,7 +127,7 @@ static Object get(PDecoratedMethod self, Object obj, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached GetClassNode getClass, @Shared @Cached MakeMethodNode makeMethod, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doGet(inliningTarget, self, getClass.execute(inliningTarget, obj), makeMethod, raiseNode); } @@ -145,14 +145,14 @@ static Object getTypeCached(@SuppressWarnings("unused") PDecoratedMethod self, @ static Object getType(PDecoratedMethod self, @SuppressWarnings("unused") Object obj, Object type, @Bind("this") Node inliningTarget, @Shared @Cached MakeMethodNode makeMethod, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return doGet(inliningTarget, self, type, makeMethod, raiseNode); } - private static Object doGet(Node inliningTarget, PDecoratedMethod self, Object type, MakeMethodNode makeMethod, PRaiseNode.Lazy raiseNode) { + private static Object doGet(Node inliningTarget, PDecoratedMethod self, Object type, MakeMethodNode makeMethod, PRaiseNode raiseNode) { Object callable = self.getCallable(); if (callable == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); } return makeMethod.execute(inliningTarget, type, callable); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/DecoratedMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/DecoratedMethodBuiltins.java index b45360f89f..9411e45cf3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/DecoratedMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/DecoratedMethodBuiltins.java @@ -155,8 +155,8 @@ static Object setDict(PDecoratedMethod self, PDict mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static Object setDict(@SuppressWarnings("unused") PDecoratedMethod self, Object mapping, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java index f74d62eb88..bd573df628 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java @@ -116,8 +116,8 @@ static PNone init(PDecoratedMethod self, Object callable, @Specialization(guards = "!checkCallableNode.execute(this, callable)") static PNone noCallble(@SuppressWarnings("unused") PDecoratedMethod self, Object callable, @Shared("checkCallable") @SuppressWarnings("unused") @Cached PyCallableCheckNode checkCallableNode, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, FIRST_ARG_MUST_BE_CALLABLE_S, callable); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, FIRST_ARG_MUST_BE_CALLABLE_S, callable); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java index d3e2e1786a..e7fac1ff3f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java @@ -133,14 +133,14 @@ static Object doIt(VirtualFrame frame, PMethod self, Object keyObj, @Cached ObjectBuiltins.GetAttributeNode objectGetattrNode, @Cached IsBuiltinObjectProfile errorProfile, @Cached CastToTruffleStringNode castKeyToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // TODO: (GR-53090) this is different to what CPython does and CPython also does not // define tp_descrget for method TruffleString key; try { key = castKeyToStringNode.execute(inliningTarget, keyObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); } try { @@ -154,8 +154,8 @@ static Object doIt(VirtualFrame frame, PMethod self, Object keyObj, @Specialization(guards = "!isPMethod(self)") @InliningCutoff static Object getattribute(Object self, @SuppressWarnings("unused") Object key, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GETATTRIBUTE__, "method", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GETATTRIBUTE__, "method", self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java index 5ef47ed787..c219c00123 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -103,10 +103,10 @@ static Object getCached(@SuppressWarnings("unused") PDecoratedMethod self, @Supp @Specialization(replaces = "getCached") static Object get(PDecoratedMethod self, @SuppressWarnings("unused") Object obj, @SuppressWarnings("unused") Object type, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object callable = self.getCallable(); if (callable == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); } return callable; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java index 6e54ed2e2c..370ecb228a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java @@ -173,7 +173,7 @@ public abstract static class MMapSqItemNode extends SqItemBuiltinNode { static PBytes doInt(VirtualFrame frame, PMMap self, int index, @Bind("this") Node inliningTarget, @Bind PythonContext context, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib) { long len = self.getLength(); @@ -201,7 +201,7 @@ static int doSingle(VirtualFrame frame, PMMap self, Object idxObj, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Cached PyLongAsLongNode asLongNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { long i = asLongNode.execute(frame, inliningTarget, idxObj); long len = self.getLength(); long idx = negativeIndexProfile.profile(inliningTarget, i < 0) ? i + len : i; @@ -223,7 +223,7 @@ static Object doSlice(VirtualFrame frame, PMMap self, PSlice idx, @Cached ComputeIndices compute, @Cached LenOfRangeNode sliceLenNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { try { SliceInfo info = compute.execute(frame, sliceCast.execute(inliningTarget, idx), PInt.intValueExact(self.getLength())); int len = sliceLenNode.len(inliningTarget, info); @@ -233,7 +233,7 @@ static Object doSlice(VirtualFrame frame, PMMap self, PSlice idx, byte[] result = readBytes(frame, inliningTarget, self, posixSupportLib, context.getPosixSupport(), info.start, len, constructAndRaiseNode); return PFactory.createBytes(context.getLanguage(inliningTarget), result); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, e); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, e); } } } @@ -250,25 +250,25 @@ static void doSingle(VirtualFrame frame, PMMap self, int index, Object val, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Cached PyBytesCheckNode checkNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // NB: sq_ass_item and mp_ass_subscript implementations behave differently even with // integer indices if (self.isClosed()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); } long len = self.getLength(); long idx = index < 0 ? index + len : index; if (idx < 0 || idx >= len) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, MMAP_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, MMAP_INDEX_OUT_OF_RANGE); } if (val == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_ITEM_DELETION); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_ITEM_DELETION); } if (!(checkNode.execute(inliningTarget, val) && bufferLib.getBufferLength(val) == 1)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, MMAP_ASSIGNMENT_MUST_BE_LENGTH_1_BYTES); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, MMAP_ASSIGNMENT_MUST_BE_LENGTH_1_BYTES); } if (self.isReadonly()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); } byte b = bufferLib.readByte(val, 0); try { @@ -291,33 +291,33 @@ static void doSingle(VirtualFrame frame, PMMap self, Object idxObj, Object value @Cached PyIndexCheckNode checkNode, @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { // NB: sq_ass_item and mp_ass_subscript implementations behave differently even with // integer indices if (self.isClosed()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); } if (self.isReadonly()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); } if (!checkNode.execute(inliningTarget, idxObj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_INDICES_MUST_BE_INTEGER); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_INDICES_MUST_BE_INTEGER); } long idx = asSizeNode.executeExact(frame, inliningTarget, idxObj, PythonBuiltinClassType.IndexError); long len = self.getLength(); idx = idx < 0 ? idx + len : idx; if (idx < 0 || idx >= len) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, MMAP_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, MMAP_INDEX_OUT_OF_RANGE); } if (valueObj == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_ITEM_DELETION); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_ITEM_DELETION); } if (!checkNode.execute(inliningTarget, valueObj)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_ITEM_VALUE_MUST_BE_AN_INT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_ITEM_VALUE_MUST_BE_AN_INT); } int value = asSizeNode.executeExact(frame, inliningTarget, valueObj, PythonBuiltinClassType.TypeError); if (value < 0 || value > 255) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, MMAP_ITEM_VALUE_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, MMAP_ITEM_VALUE_MUST_BE_IN_RANGE); } try { posixSupportLib.mmapWriteByte(context.getPosixSupport(), self.getPosixSupportHandle(), idx, (byte) value); @@ -337,28 +337,28 @@ static void doSlice(VirtualFrame frame, PMMap self, PSlice slice, Object valueOb @Cached SliceNodes.AdjustIndices adjustIndices, @Cached InlinedConditionProfile step1Profile, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (self.isClosed()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, MMAP_CLOSED_OR_INVALID); } if (self.isReadonly()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_CANNOT_MODIFY_READONLY_MEMORY); } int len; try { len = PInt.intValueExact(self.getLength()); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError); } SliceInfo info = adjustIndices.execute(inliningTarget, len, sliceUnpack.execute(inliningTarget, slice)); if (valueObj == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_SLICE_DELETION); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, MMAP_OBJECT_DOESNT_SUPPORT_SLICE_DELETION); } Object buffer = acquireLib.acquireReadonly(valueObj); try { int bufferLen = bufferLib.getBufferLength(buffer); if (info.sliceLength != bufferLen) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, MMAP_SLICE_ASSIGNMENT_IS_WRONG_SIZE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, MMAP_SLICE_ASSIGNMENT_IS_WRONG_SIZE); } if (info.sliceLength > 0) { try { @@ -388,7 +388,7 @@ public abstract static class LenNode extends LenBuiltinNode { @Specialization static int len(PMMap self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { return PyNumberAsSizeNode.doLongExact(inliningTarget, self.getLength(), PythonBuiltinClassType.OverflowError, raiseNode); } } @@ -454,9 +454,9 @@ abstract static class ResizeNode extends PythonBuiltinNode { @Specialization @SuppressWarnings("unused") static long resize(PMMap self, Object n, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // TODO: implement resize in NFI - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.RESIZING_NOT_AVAILABLE); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.RESIZING_NOT_AVAILABLE); } } @@ -480,9 +480,9 @@ static int readByte(VirtualFrame frame, PMMap self, @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixSupportLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.getPos() >= self.getLength()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, READ_BYTE_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, READ_BYTE_OUT_OF_RANGE); } try { byte res = posixSupportLib.mmapReadByte(context.getPosixSupport(), self.getPosixSupportHandle(), self.getPos()); @@ -510,7 +510,7 @@ static PBytes read(VirtualFrame frame, PMMap self, Object n, @Cached PyNumberAsSizeNode asSizeNode, @Cached InlinedConditionProfile negativeProfile, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long nread; // intentionally accept NO_VALUE and NONE; both mean that we read unlimited # of bytes if (noneProfile.profile(inliningTarget, isPNone(n))) { @@ -518,7 +518,7 @@ static PBytes read(VirtualFrame frame, PMMap self, Object n, } else { // _Py_convert_optional_to_ssize_t: if (!indexCheckNode.execute(inliningTarget, n)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, n); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, n); } nread = asSizeNode.executeExact(frame, inliningTarget, n); @@ -536,7 +536,7 @@ static PBytes read(VirtualFrame frame, PMMap self, Object n, self.setPos(self.getPos() + buffer.length); return PFactory.createBytes(context.getLanguage(inliningTarget), buffer); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, ErrorMessages.TOO_MANY_REMAINING_BYTES_TO_BE_STORED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.TOO_MANY_REMAINING_BYTES_TO_BE_STORED); } } } @@ -597,15 +597,15 @@ static int doIt(VirtualFrame frame, PMMap self, Object dataBuffer, @CachedLibrary("dataBuffer") PythonBufferAccessLibrary bufferLib, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (!self.isWriteable()) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MMAP_CANNOT_MODIFY_READONLY_MEMORY); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MMAP_CANNOT_MODIFY_READONLY_MEMORY); } byte[] dataBytes = bufferLib.getInternalOrCopiedByteArray(dataBuffer); int dataLen = bufferLib.getBufferLength(dataBuffer); if (self.getPos() > self.getLength() || self.getLength() - self.getPos() < dataLen) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.DATA_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.DATA_OUT_OF_RANGE); } posixLib.mmapWriteBytes(context.getPosixSupport(), self.getPosixSupportHandle(), self.getPos(), dataBytes, dataLen); self.setPos(self.getPos() + dataLen); @@ -632,7 +632,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object seek(PMMap self, long dist, int how, @Bind("this") Node inliningTarget, @Cached InlinedBranchProfile errorProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long where; switch (how) { case 0: // relative to start @@ -646,10 +646,10 @@ static Object seek(PMMap self, long dist, int how, break; default: errorProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.UNKNOWN_S_TYPE, "seek"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UNKNOWN_S_TYPE, "seek"); } if (where > self.getLength() || where < 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SEEK_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SEEK_OUT_OF_RANGE); } self.setPos(where); return PNone.NONE; @@ -678,7 +678,7 @@ static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startI @Cached LongIndexConverterNode endConverter, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { long start = normalizeIndex(frame, startConverter, startIn, self.getLength(), self.getPos()); long end = normalizeIndex(frame, endConverter, endIn, self.getLength(), self.getLength()); @@ -737,13 +737,13 @@ static long find(VirtualFrame frame, PMMap self, Object subBuffer, Object startI } private static void readBytes(VirtualFrame frame, Node inliningTarget, PMMap self, PosixSupportLibrary posixLib, PosixSupport posixSupport, long index, byte[] buffer, - PConstructAndRaiseNode.Lazy constructAndRaiseNode, PRaiseNode.Lazy raiseNode) { + PConstructAndRaiseNode.Lazy constructAndRaiseNode, PRaiseNode raiseNode) { try { long remaining = self.getLength() - index; int toReadLen = remaining > buffer.length ? buffer.length : (int) remaining; int nread = posixLib.mmapReadBytes(posixSupport, self.getPosixSupportHandle(), index, buffer, toReadLen); if (toReadLen != nread) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, MMAP_CHANGED_LENGTH); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, MMAP_CHANGED_LENGTH); } } catch (PosixException ex) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, ex); @@ -784,7 +784,7 @@ static Object flush(VirtualFrame frame, PMMap self, long offset, Object sizeObj, @Cached LongIndexConverterNode sizeConversion, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long size; if (sizeObj == PNone.NO_VALUE) { size = self.getLength(); @@ -793,7 +793,7 @@ static Object flush(VirtualFrame frame, PMMap self, long offset, Object sizeObj, } if (size < 0 || offset < 0 || self.getLength() - offset < size) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.FLUSH_VALUES_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.FLUSH_VALUES_OUT_OF_RANGE); } if (self.getAccess() == ACCESS_READ || self.getAccess() == ACCESS_COPY) { return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java index a6042bd83a..afb659abcf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java @@ -171,7 +171,7 @@ static Object dir(VirtualFrame frame, PythonModule self, @Cached ListNodes.ConstructListNode constructListNode, @Cached CallNode callNode, @Cached PyObjectLookupAttr lookup, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object dictObj = lookup.execute(frame, inliningTarget, self, T___DICT__); if (dictObj instanceof PDict dict) { Object dirFunc = pyDictGetItem.execute(frame, inliningTarget, dict, T___DIR__); @@ -181,7 +181,7 @@ static Object dir(VirtualFrame frame, PythonModule self, return constructListNode.execute(frame, dict); } } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_DICTIONARY, ".__dict__"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_DICTIONARY, ".__dict__"); } } } @@ -206,18 +206,18 @@ static Object doManaged(PythonModule self, @SuppressWarnings("unused") PNone non static Object doNativeObject(PythonAbstractNativeObject self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Exclusive @Cached GetDictIfExistsNode getDict, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PDict dict = getDict.execute(self); if (dict == null) { - doError(self, none, raiseNode.get(inliningTarget)); + doError(self, none, raiseNode); } return dict; } @Fallback static Object doError(Object self, @SuppressWarnings("unused") Object dict, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.DESCRIPTOR_DICT_FOR_MOD_OBJ_DOES_NOT_APPLY_FOR_P, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.DESCRIPTOR_DICT_FOR_MOD_OBJ_DOES_NOT_APPLY_FOR_P, self); } private static PDict createDict(Node inliningTarget, PythonModule self, SetDictNode setDict) { @@ -272,7 +272,7 @@ static Object getattribute(VirtualFrame frame, PythonModule self, TruffleString @Cached CallNode callNode, @Cached PyObjectIsTrueNode castToBooleanNode, @Cached CastToTruffleStringNode castNameToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { e.expect(inliningTarget, PythonBuiltinClassType.AttributeError, isAttrError); Object getAttr = readGetattr.execute(self, T___GETATTR__); if (customGetAttr.profile(inliningTarget, getAttr != PNone.NO_VALUE)) { @@ -290,20 +290,20 @@ static Object getattribute(VirtualFrame frame, PythonModule self, TruffleString if (moduleSpec != PNone.NO_VALUE) { Object isInitializing = readGetattr.execute(moduleSpec, T__INITIALIZING); if (isInitializing != PNone.NO_VALUE && castToBooleanNode.execute(frame, isInitializing)) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.MODULE_PARTIALLY_INITIALIZED_S_HAS_NO_ATTR_S, moduleName, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.MODULE_PARTIALLY_INITIALIZED_S_HAS_NO_ATTR_S, moduleName, key); } } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.MODULE_S_HAS_NO_ATTR_S, moduleName, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.MODULE_S_HAS_NO_ATTR_S, moduleName, key); } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.MODULE_HAS_NO_ATTR_S, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.MODULE_HAS_NO_ATTR_S, key); } } } @Specialization(guards = "!isPythonModule(self)") static Object getattribute(Object self, @SuppressWarnings("unused") Object key, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GETATTRIBUTE__, "module", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GETATTRIBUTE__, "module", self); } } @@ -330,10 +330,10 @@ static Object delete(Object self, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, @Shared("read") @Cached ReadAttributeFromObjectNode read, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object annotations = read.execute(self, T___ANNOTATIONS__); if (annotations == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___ANNOTATIONS__}); + throw raiseNode.raise(inliningTarget, AttributeError, new Object[]{T___ANNOTATIONS__}); } write.execute(self, T___ANNOTATIONS__, PNone.NO_VALUE); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleGetNameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleGetNameNode.java index 547ad995af..88118ab53b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleGetNameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleGetNameNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -69,13 +69,13 @@ public abstract class ModuleGetNameNode extends Node { static TruffleString doPythonModule(Node inliningTarget, PythonModule module, @Cached(inline = false) ReadAttributeFromObjectNode readNameNode, @Cached CastToTruffleStringNode castToTruffleStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { Object name = readNameNode.execute(module, SpecialAttributeNames.T___NAME__); return castToTruffleStringNode.execute(inliningTarget, name); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.NAMELESS_MODULE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.NAMELESS_MODULE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java index ee95c8cd17..293519e099 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/namespace/SimpleNamespaceBuiltins.java @@ -121,10 +121,12 @@ protected List> getNodeFa @GenerateNodeFactory protected abstract static class SimpleNamespaceInitNode extends PythonVarargsBuiltinNode { @Specialization - Object init(PSimpleNamespace self, Object[] args, PKeyword[] kwargs, - @Cached WriteAttributeToPythonObjectNode writeAttrNode) { + static Object init(PSimpleNamespace self, Object[] args, PKeyword[] kwargs, + @Bind("this") Node inliningTarget, + @Cached WriteAttributeToPythonObjectNode writeAttrNode, + @Cached PRaiseNode raiseNode) { if (args.length > 0) { - throw raise(PythonBuiltinClassType.TypeError, NO_POSITIONAL_ARGUMENTS_EXPECTED); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, NO_POSITIONAL_ARGUMENTS_EXPECTED); } for (PKeyword keyword : kwargs) { writeAttrNode.execute(self, keyword.getName(), keyword.getValue()); @@ -233,7 +235,7 @@ protected static TruffleString getReprString(Node inliningTarget, Object obj, try { return castStr.execute(inliningTarget, reprObj); } catch (CannotCastException e) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.RETURNED_NON_STRING, "__repr__", reprObj); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.RETURNED_NON_STRING, "__repr__", reprObj); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java index b57d9668a9..b76f4a73bc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java @@ -112,7 +112,6 @@ import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; @@ -197,16 +196,16 @@ static PNone setClass(VirtualFrame frame, Object self, Object value, @Cached CheckCompatibleForAssigmentNode checkCompatibleForAssigmentNode, @Exclusive @Cached GetClassNode getClassNode, @Cached SetClassNode setClassNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, value)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CLASS_MUST_BE_SET_TO_CLASS, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CLASS_MUST_BE_SET_TO_CLASS, value); } Object type = getClassNode.execute(inliningTarget, self); boolean bothModuleSubtypes = isModuleProfile.profileClass(inliningTarget, type, PythonBuiltinClassType.PythonModule) && isModuleProfile.profileClass(inliningTarget, value, PythonBuiltinClassType.PythonModule); boolean bothMutable = (getTypeFlagsNode.execute(type) & TypeFlags.IMMUTABLETYPE) == 0 && (getTypeFlagsNode.execute(value) & TypeFlags.IMMUTABLETYPE) == 0; if (!bothModuleSubtypes && !bothMutable) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CLASS_ASSIGNMENT_ONLY_SUPPORTED_FOR_HEAP_TYPES_OR_MODTYPE_SUBCLASSES); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CLASS_ASSIGNMENT_ONLY_SUPPORTED_FOR_HEAP_TYPES_OR_MODTYPE_SUBCLASSES); } checkCompatibleForAssigmentNode.execute(frame, type, value); @@ -263,15 +262,15 @@ static PNone init(Object self, Object[] arguments, PKeyword[] keywords, @Cached(parameters = "Init") LookupCallableSlotInMRONode lookupInit, @Cached(parameters = "New") LookupCallableSlotInMRONode lookupNew, @Cached TypeNodes.CheckCallableIsSpecificBuiltinNode checkSlotIs, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (arguments.length != 0 || keywords.length != 0) { Object type = getClassNode.execute(inliningTarget, self); if (!checkSlotIs.execute(inliningTarget, lookupInit.execute(type), ObjectBuiltinsFactory.InitNodeFactory.getInstance())) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INIT_TAKES_ONE_ARG_OBJECT); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INIT_TAKES_ONE_ARG_OBJECT); } if (checkSlotIs.execute(inliningTarget, lookupNew.execute(type), BuiltinConstructorsFactory.ObjectNodeFactory.getInstance())) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INIT_TAKES_ONE_ARG, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INIT_TAKES_ONE_ARG, type); } } return PNone.NONE; @@ -395,7 +394,7 @@ Object doItTruffleString(VirtualFrame frame, Object object, @SuppressWarnings("u @Exclusive @Cached GetClassNode getClassNode, @Exclusive @Cached GetObjectSlotsNode getSlotsNode, @Cached("create(cachedKey)") LookupAttributeInMRONode lookup, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); Object descr = lookup.execute(type); return fullLookup(frame, inliningTarget, object, cachedKey, type, descr, getSlotsNode, raiseNode); @@ -409,12 +408,12 @@ Object doIt(VirtualFrame frame, Object object, Object keyObj, @Exclusive @Cached GetClassNode getClassNode, @Exclusive @Cached GetObjectSlotsNode getSlotsNode, @Cached CastToTruffleStringNode castKeyToStringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString key; try { key = castKeyToStringNode.execute(inliningTarget, keyObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); } Object type = getClassNode.execute(inliningTarget, object); @@ -422,7 +421,7 @@ Object doIt(VirtualFrame frame, Object object, Object keyObj, return fullLookup(frame, inliningTarget, object, key, type, descr, getSlotsNode, raiseNode); } - private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object, TruffleString key, Object type, Object descr, GetObjectSlotsNode getSlotsNode, Lazy raiseNode) { + private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object, TruffleString key, Object type, Object descr, GetObjectSlotsNode getSlotsNode, PRaiseNode raiseNode) { boolean hasDescr = descr != PNone.NO_VALUE; if (hasDescr && (profileFlags & HAS_DESCR) == 0) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -456,7 +455,7 @@ private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object return dispatch(frame, object, type, descr, descrGetSlot); } } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } private Object readAttribute(Object object, TruffleString key) { @@ -608,8 +607,8 @@ private static Object getDescrFromBuiltinBase(Node inliningTarget, Object type, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)", "!isDeleteMarker(mapping)"}) static Object dict(@SuppressWarnings("unused") Object self, Object mapping, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } @Specialization(guards = "isFallback(self, mapping, inliningTarget, getClassNode, otherBuiltinClassProfile, isBuiltinClassProfile)", limit = "1") @@ -618,9 +617,8 @@ static Object raise(Object self, Object mapping, @Bind("this") Node inliningTarget, @Exclusive @Cached IsOtherBuiltinClassProfile otherBuiltinClassProfile, @Exclusive @Cached IsBuiltinClassExactProfile isBuiltinClassProfile, - @Exclusive @Cached GetClassNode getClassNode, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, self, "__dict__"); + @Exclusive @Cached GetClassNode getClassNode) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, self, "__dict__"); } static boolean isFallback(Object self, Object mapping, Node inliningTarget, @@ -652,8 +650,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "!formatString.isEmpty()") static Object format(Object self, @SuppressWarnings("unused") TruffleString formatString, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_FORMAT_STRING_PASSED_TO_P_FORMAT, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_FORMAT_STRING_PASSED_TO_P_FORMAT, self); } @Specialization(guards = "formatString.isEmpty()") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java index 8e9de09698..e2f81ebc48 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectNodes.java @@ -461,14 +461,14 @@ static Pair doNewArgsEx(VirtualFrame frame, Object getNewArgsExA @Cached SequenceStorageNodes.GetItemNode getItemNode, @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, @Cached PyObjectSizeNode sizeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object newargs = callNode.execute(frame, getNewArgsExAttr); if (!tupleCheckNode.execute(inliningTarget, newargs)) { - throw raiseNode.get(inliningTarget).raise(TypeError, SHOULD_RETURN_TYPE_A_NOT_TYPE_B, T___GETNEWARGS_EX__, "tuple", newargs); + throw raiseNode.raise(inliningTarget, TypeError, SHOULD_RETURN_TYPE_A_NOT_TYPE_B, T___GETNEWARGS_EX__, "tuple", newargs); } int length = sizeNode.execute(frame, inliningTarget, newargs); if (length != 2) { - throw raiseNode.get(inliningTarget).raise(ValueError, SHOULD_RETURN_A_NOT_B, T___GETNEWARGS_EX__, "tuple of length 2", length); + throw raiseNode.raise(inliningTarget, ValueError, SHOULD_RETURN_A_NOT_B, T___GETNEWARGS_EX__, "tuple of length 2", length); } SequenceStorage sequenceStorage = getSequenceStorageNode.execute(inliningTarget, newargs); @@ -476,10 +476,10 @@ static Pair doNewArgsEx(VirtualFrame frame, Object getNewArgsExA Object kwargs = getItemNode.execute(sequenceStorage, 1); if (!tupleCheckNode.execute(inliningTarget, args)) { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "first item of the tuple returned by __getnewargs_ex__", "tuple", args); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "first item of the tuple returned by __getnewargs_ex__", "tuple", args); } if (!isDictSubClassNode.execute(inliningTarget, kwargs)) { - throw raiseNode.get(inliningTarget).raise(TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "second item of the tuple returned by __getnewargs_ex__", "dict", kwargs); + throw raiseNode.raise(inliningTarget, TypeError, MUST_BE_TYPE_A_NOT_TYPE_B, "second item of the tuple returned by __getnewargs_ex__", "dict", kwargs); } return Pair.create(args, kwargs); @@ -490,10 +490,10 @@ static Pair doNewArgs(VirtualFrame frame, @SuppressWarnings("unu @Bind("this") Node inliningTarget, @Exclusive @Cached CallNode callNode, @Exclusive @Cached PyTupleCheckNode tupleCheckNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object args = callNode.execute(frame, getNewArgsAttr); if (!tupleCheckNode.execute(inliningTarget, args)) { - throw raiseNode.get(inliningTarget).raise(TypeError, SHOULD_RETURN_TYPE_A_NOT_TYPE_B, T___GETNEWARGS__, "tuple", args); + throw raiseNode.raise(inliningTarget, TypeError, SHOULD_RETURN_TYPE_A_NOT_TYPE_B, T___GETNEWARGS__, "tuple", args); } return Pair.create(args, PNone.NONE); } @@ -519,7 +519,7 @@ static Object[] getstate(VirtualFrame frame, Node inliningTarget, Object type, @Cached SequenceStorageNodes.ToArrayNode toArrayNode, @Cached PyImportImport importNode, @Cached PyObjectCallMethodObjArgs callMethod, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object slotnames = read.execute(type, T___SLOTNAMES__); boolean hadCachedSlotnames = false; if (slotnames != PNone.NO_VALUE) { @@ -533,9 +533,9 @@ static Object[] getstate(VirtualFrame frame, Node inliningTarget, Object type, } else if (slotnames == PNone.NONE) { return EMPTY_OBJECT_ARRAY; } else if (hadCachedSlotnames) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.COPYREG_SLOTNAMES_DIDN_T_RETURN_A_LIST_OR_NONE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.COPYREG_SLOTNAMES_DIDN_T_RETURN_A_LIST_OR_NONE); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.N_SLOTNAMES_SHOULD_BE_A_LIST_OR_NONE_NOT_P, type, slotnames); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_SLOTNAMES_SHOULD_BE_A_LIST_OR_NONE_NOT_P, type, slotnames); } } } @@ -556,11 +556,11 @@ static Object getstate(VirtualFrame frame, Node inliningTarget, Object obj, bool @Cached PyObjectLookupAttrO lookupAttr, @Cached HashingStorageSetItem setHashingStorageItem, @Cached CheckBasesizeForGetState checkBasesize, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object state; Object type = getClassNode.execute(inliningTarget, obj); if (required && getItemsizeNode.execute(inliningTarget, type) != 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); } Object dict = lookupAttr.execute(frame, inliningTarget, obj, T___DICT__); @@ -573,7 +573,7 @@ static Object getstate(VirtualFrame frame, Node inliningTarget, Object obj, bool Object[] slotnames = getSlotNamesNode.execute(frame, inliningTarget, type); if (required && !checkBasesize.execute(inliningTarget, obj, type, slotnames.length)) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); } if (slotnames.length > 0) { @@ -676,10 +676,10 @@ static Object reduceNewObj(VirtualFrame frame, Node inliningTarget, Object obj, @Exclusive @Cached PyObjectCallMethodObjArgs callMethod, @Cached PyObjectGetIter getIter, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object cls = getClassNode.execute(inliningTarget, obj); if (lookupNew.execute(cls) == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); + throw raiseNode.raise(inliningTarget, TypeError, CANNOT_PICKLE_OBJECT_TYPE, obj); } Pair rv = getNewArgsNode.execute(frame, obj); @@ -708,7 +708,7 @@ static Object reduceNewObj(VirtualFrame frame, Node inliningTarget, Object obj, newobj = lookupAttr.execute(frame, inliningTarget, copyReg, T___NEWOBJ_EX__); newargs = PFactory.createTuple(language, new Object[]{cls, args, kwargs}); } else { - throw raiseNode.get(inliningTarget).raiseBadInternalCall(); + throw raiseNode.raiseBadInternalCall(inliningTarget); } boolean objIsList = isSubClassNode.executeWith(frame, cls, PythonBuiltinClassType.PList); @@ -847,7 +847,7 @@ static void doStringKey(Node inliningTarget, VirtualFrame frame, Object object, @Shared @Cached(inline = false) LookupAttributeInMRONode.Dynamic getExisting, @Shared @Cached(inline = false) ReadAttributeFromObjectNode attrRead, @Shared @Cached InlinedBranchProfile deleteNonExistingBranchProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { setAttr(inliningTarget, frame, object, key, value, writeNode, getClassNode, hasDescriptor, getDescrSlotsNode, callSetNode, getExisting, attrRead, deleteNonExistingBranchProfile, raiseNode); @@ -864,18 +864,18 @@ static void doGeneric(Node inliningTarget, VirtualFrame frame, Object object, Ob @Shared @Cached(inline = false) LookupAttributeInMRONode.Dynamic getExisting, @Shared @Cached(inline = false) ReadAttributeFromObjectNode attrRead, @Shared @Cached InlinedBranchProfile deleteNonExistingBranchProfile, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { TruffleString key = castAttributeKey(inliningTarget, keyObject, castKeyToStringNode, raiseNode); setAttr(inliningTarget, frame, object, key, value, writeNode, getClassNode, hasDescriptor, getDescrSlotsNode, callSetNode, getExisting, attrRead, deleteNonExistingBranchProfile, raiseNode); } - public static TruffleString castAttributeKey(Node inliningTarget, Object keyObject, CastToTruffleStringNode castKeyToStringNode, PRaiseNode.Lazy raiseNode) { + public static TruffleString castAttributeKey(Node inliningTarget, Object keyObject, CastToTruffleStringNode castKeyToStringNode, PRaiseNode raiseNode) { try { return castKeyToStringNode.execute(inliningTarget, keyObject); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ATTR_NAME_MUST_BE_STRING, keyObject); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ATTR_NAME_MUST_BE_STRING, keyObject); } } @@ -884,7 +884,7 @@ private static void setAttr(Node inliningTarget, VirtualFrame frame, Object obje InlinedConditionProfile hasDescriptor, GetObjectSlotsNode getDescrSlotsNode, CallSlotDescrSet callSetNode, LookupAttributeInMRONode.Dynamic getExisting, ReadAttributeFromObjectNode attrRead, InlinedBranchProfile deleteNonExistingBranchProfile, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); Object descr = getExisting.execute(type, key); if (hasDescriptor.profile(inliningTarget, !PGuards.isNoValue(descr))) { @@ -912,9 +912,9 @@ private static void setAttr(Node inliningTarget, VirtualFrame frame, Object obje } if (descr != PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.ATTR_S_READONLY, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.ATTR_S_READONLY, key); } else { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.HAS_NO_ATTR, object, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, object, key); } } @@ -998,7 +998,7 @@ static void doIt(Object object, Object key, Object type, message = ErrorMessages.HAS_NO_ATTR; firstArg = object; } - raiseNode.raise(PythonBuiltinClassType.AttributeError, message, firstArg, key); + raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, message, firstArg, key); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java index 95fe5354c5..19018ae0c8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java @@ -146,12 +146,12 @@ abstract static class InitNode extends PythonBuiltinNode { static PNone update(VirtualFrame frame, PDict self, Object[] args, PKeyword[] kwargs, @Bind("this") Node inliningTarget, @Cached UpdateFromArgsNode update, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object mapping = PNone.NO_VALUE; if (args.length == 1) { mapping = args[0]; } else if (args.length > 1) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, 1, args.length); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_AT_MOST_D_ARGS_GOT_D, 1, args.length); } update.execute(frame, inliningTarget, self, mapping, kwargs); return PNone.NONE; @@ -192,7 +192,7 @@ static void delitem(VirtualFrame frame, POrderedDict self, Object key, @Suppress long hash = hashNode.execute(frame, inliningTarget, key); ODictNode node = (ODictNode) removeNode.execute(frame, inliningTarget, self.nodes, key, hash); if (node == null) { - throw raiseNode.raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } self.remove(node); // TODO with hash @@ -338,7 +338,7 @@ static Object pop(VirtualFrame frame, POrderedDict self, Object key, Object defa @Cached PySequenceContainsNode containsNode, @Cached PyObjectGetItem getItem, @Cached PyObjectDelItem delItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // XXX the CPython implementation is weird when self is a subclass if (containsNode.execute(frame, inliningTarget, self, key)) { Object value = getItem.execute(frame, inliningTarget, self, key); @@ -347,7 +347,7 @@ static Object pop(VirtualFrame frame, POrderedDict self, Object key, Object defa } else if (defaultValue != PNone.NO_VALUE) { return defaultValue; } else { - throw raiseNode.get(inliningTarget).raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } } } @@ -362,10 +362,10 @@ static Object popitem(VirtualFrame frame, POrderedDict self, boolean last, @Cached HashingStorageNodes.HashingStorageDelItem delItem, @Cached ObjectHashMap.RemoveNode removeNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { ODictNode node = last ? self.last : self.first; if (node == null) { - throw raise.get(inliningTarget).raise(KeyError, ErrorMessages.IS_EMPTY, "dictionary"); + throw raise.raise(inliningTarget, KeyError, ErrorMessages.IS_EMPTY, "dictionary"); } self.remove(node); removeNode.execute(frame, inliningTarget, self.nodes, node.key, node.hash); @@ -420,13 +420,13 @@ static PNone move(VirtualFrame frame, POrderedDict self, Object key, boolean las @Cached PRaiseNode raiseNode) { if (self.first == null) { // Empty - throw raiseNode.raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } if ((last ? self.last : self.first).key != key) { long hash = hashNode.execute(frame, inliningTarget, key); ODictNode node = (ODictNode) getNode.execute(frame, inliningTarget, self.nodes, key, hash); if (node == null) { - throw raiseNode.raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } if (last) { if (self.last != node) { @@ -630,8 +630,8 @@ static Object dict(Object self, @SuppressWarnings("unused") PNone mapping, @Specialization(guards = {"!isNoValue(mapping)", "!isDict(mapping)"}) static PNone dict(@SuppressWarnings("unused") Object self, Object mapping, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, mapping); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java index 97e798523a..cf5dc45c52 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java @@ -99,10 +99,10 @@ static Object next(VirtualFrame frame, POrderedDictIterator self, @Cached PRaiseNode raiseNode, @Cached HashingStorageNodes.HashingStorageGetItemWithHash getItem) { if (self.current == null) { - throw raiseNode.raise(StopIteration); + throw raiseNode.raise(inliningTarget, StopIteration); } if (self.size != self.dict.nodes.size()) { - throw raiseNode.raise(RuntimeError, ErrorMessages.CHANGED_SIZE_DURING_ITERATION, "OrderedDict"); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.CHANGED_SIZE_DURING_ITERATION, "OrderedDict"); } Object result; Object key = self.current.key; @@ -111,7 +111,7 @@ static Object next(VirtualFrame frame, POrderedDictIterator self, } else { Object value = getItem.execute(frame, inliningTarget, self.dict.getDictStorage(), key, self.current.hash); if (value == null) { - throw raiseNode.raise(KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, KeyError, new Object[]{key}); } if (self.type == POrderedDictIterator.IteratorType.VALUES) { result = value; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java index e903bc3407..75dcd10d55 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java @@ -113,16 +113,16 @@ static PDirEntry next(VirtualFrame frame, PScandirIterator self, @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (self.ref.isReleased()) { - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } PosixSupport posixSupport = PosixSupport.get(inliningTarget); try { Object dirEntryData = posixLib.readdir(posixSupport, self.ref.getReference()); if (dirEntryData == null) { self.ref.rewindAndClose(posixLib, posixSupport); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } return PFactory.createDirEntry(language, dirEntryData, self.path); } catch (PosixException e) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java index d52d7949ae..9aebab77c0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/property/PropertyBuiltins.java @@ -157,7 +157,7 @@ abstract static class PropertyFuncNode extends PythonBinaryBuiltinNode { @Specialization(guards = "!isNoValue(value)") @SuppressWarnings("unused") static Object doSet(PProperty self, Object value, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { /* * That's a bit unfortunate: if we define 'isGetter = true' and 'isSetter = false' then * this will use a GetSetDescriptor which has a slightly different error message for @@ -165,7 +165,7 @@ static Object doSet(PProperty self, Object value, * with expected message. This should be fixed by distinguishing between getset and * member descriptors. */ - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.READONLY_ATTRIBUTE); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.READONLY_ATTRIBUTE); } } @@ -314,9 +314,9 @@ PException error(VirtualFrame frame, PProperty self, Object obj, String what, TruffleString qualName = getQualNameNode.execute(inliningTarget, getClassNode.execute(inliningTarget, obj)); if (self.getPropertyName() != null) { TruffleString propertyName = reprNode.execute(frame, inliningTarget, self.getPropertyName()); - throw raiseNode.raise(AttributeError, ErrorMessages.PROPERTY_S_OF_S_OBJECT_HAS_NO_S, propertyName, qualName, what); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.PROPERTY_S_OF_S_OBJECT_HAS_NO_S, propertyName, qualName, what); } else { - throw raiseNode.raise(AttributeError, ErrorMessages.PROPERTY_OF_S_OBJECT_HAS_NO_S, qualName, what); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.PROPERTY_OF_S_OBJECT_HAS_NO_S, qualName, what); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java index 3d4947b771..8b8b133f55 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/queue/SimpleQueueBuiltins.java @@ -128,12 +128,12 @@ public abstract static class SimpleQueueGetNoWaitNode extends PythonUnaryBuiltin @Specialization static Object doNoTimeout(PSimpleQueue self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = self.poll(); if (result != null) { return result; } - throw raiseNode.get(inliningTarget).raise(Empty); + throw raiseNode.raise(inliningTarget, Empty); } } @@ -165,7 +165,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static Object doNoTimeout(PSimpleQueue self, boolean block, @SuppressWarnings("unused") Object timeout, @Bind("this") Node inliningTarget, @Shared @Cached GilNode gil, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { // CPython first tries a non-blocking get without releasing the GIL Object result = self.poll(); if (result != null) { @@ -183,7 +183,7 @@ static Object doNoTimeout(PSimpleQueue self, boolean block, @SuppressWarnings("u gil.acquire(); } } - throw raiseNode.get(inliningTarget).raise(Empty); + throw raiseNode.raise(inliningTarget, Empty); } @Specialization(guards = "withTimeout(block, timeout)") @@ -192,7 +192,7 @@ static Object doTimeout(VirtualFrame frame, PSimpleQueue self, boolean block, Ob @Cached PyLongAsLongAndOverflowNode asLongNode, @Cached CastToJavaDoubleNode castToDouble, @Shared @Cached GilNode gil, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { assert block; // convert timeout object (given in seconds) to a Java long in microseconds @@ -203,12 +203,12 @@ static Object doTimeout(VirtualFrame frame, PSimpleQueue self, boolean block, Ob try { ltimeout = PythonUtils.multiplyExact(asLongNode.execute(frame, inliningTarget, timeout), 1000000); } catch (OverflowException oe) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.TIMEOUT_VALUE_TOO_LARGE); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.TIMEOUT_VALUE_TOO_LARGE); } } if (ltimeout < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TIMEOUT_MUST_BE_NON_NEG_NUM); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TIMEOUT_MUST_BE_NON_NEG_NUM); } // CPython first tries a non-blocking get without releasing the GIL @@ -229,7 +229,7 @@ static Object doTimeout(VirtualFrame frame, PSimpleQueue self, boolean block, Ob } finally { gil.acquire(); } - throw raiseNode.get(inliningTarget).raise(Empty); + throw raiseNode.raise(inliningTarget, Empty); } static boolean withTimeout(boolean block, Object timeout) { @@ -253,13 +253,13 @@ public abstract static class SimpleQueuePutNode extends PythonQuaternaryBuiltinN @Specialization static PNone doGeneric(PSimpleQueue self, Object item, @SuppressWarnings("unused") Object block, @SuppressWarnings("unused") Object timeout, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!self.put(item)) { /* * CPython uses a Python list as backing storage. This will throw an OverflowError * if no more elements can be added to the list. */ - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } return PNone.NONE; } @@ -278,13 +278,13 @@ public abstract static class SimpleQueuePutNoWaitNode extends PythonBinaryBuilti @Specialization static PNone doGeneric(PSimpleQueue self, Object item, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!self.put(item)) { /* * CPython uses a Python list as backing storage. This will throw an OverflowError * if no more elements can be added to the list. */ - throw raiseNode.get(inliningTarget).raise(OverflowError); + throw raiseNode.raise(inliningTarget, OverflowError); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java index 13a8a35714..beed98da00 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java @@ -160,10 +160,10 @@ static PNone setstate(PRandom random, PTuple tuple, @Bind("this") Node inliningTarget, @Cached GetObjectArrayNode getObjectArrayNode, @Cached CastToJavaUnsignedLongNode castNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] arr = getObjectArrayNode.execute(inliningTarget, tuple); if (arr.length != PRandom.N + 1) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.STATE_VECTOR_INVALID); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.STATE_VECTOR_INVALID); } int[] state = new int[PRandom.N]; for (int i = 0; i < PRandom.N; ++i) { @@ -172,7 +172,7 @@ static PNone setstate(PRandom random, PTuple tuple, } long index = castNode.execute(inliningTarget, arr[PRandom.N]); if (index < 0 || index > PRandom.N) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.STATE_VECTOR_INVALID); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.STATE_VECTOR_INVALID); } random.restore(state, (int) index); return PNone.NONE; @@ -181,8 +181,8 @@ static PNone setstate(PRandom random, PTuple tuple, @Fallback @SuppressWarnings("unused") static Object setstate(Object random, Object state, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.STATE_VECTOR_MUST_BE_A_TUPLE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.STATE_VECTOR_MUST_BE_A_TUPLE); } } @@ -236,8 +236,8 @@ protected ArgumentClinicProvider getArgumentClinic() { @Specialization(guards = "k < 0") @SuppressWarnings("unused") static int negative(PRandom random, int k, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.NUMBER_OF_BITS_MUST_BE_NON_NEGATIVE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.NUMBER_OF_BITS_MUST_BE_NON_NEGATIVE); } @Specialization(guards = "k == 0") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java index ffaef39146..79c58f9caa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java @@ -208,12 +208,12 @@ static int doPBigRange(VirtualFrame frame, PBigRange self, @Bind("this") Node inliningTarget, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object length = self.getLength(); if (indexCheckNode.execute(inliningTarget, length)) { return asSizeNode.executeExact(frame, inliningTarget, length); } - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, length); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, length); } @NeverDefault @@ -410,7 +410,7 @@ public abstract static class RangeSqItemNode extends SqItemBuiltinNode { static int doInt(PIntRange self, int index, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile negativeIndexProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (negativeIndexProfile.profile(inliningTarget, index < 0)) { index += self.getIntLength(); } @@ -514,7 +514,7 @@ static Object doPRangeSliceSlowPath(VirtualFrame frame, PBigRange self, PSlice s @SuppressWarnings("unused") @Shared @Cached PyIndexCheckNode indexCheckNode, @Shared @Cached PyNumberAsSizeNode asSizeNode, // unused node to avoid mixing shared and non-shared inlined nodes - @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) { + @SuppressWarnings("unused") @Shared @Cached PRaiseNode raiseNode) { try { int rStart = asSizeNode.executeExact(frame, inliningTarget, self.getStart()); int rStep = asSizeNode.executeExact(frame, inliningTarget, self.getStep()); @@ -550,7 +550,7 @@ static Object doGeneric(VirtualFrame frame, PRange self, Object idx, @Shared @Cached PyIndexCheckNode indexCheckNode, @Shared @Cached PyNumberAsSizeNode asSizeNode, @Shared @Cached IndexNodes.NormalizeIndexCustomMessageNode normalize, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (isNumIndexProfile.profile(inliningTarget, canBeIndex(inliningTarget, idx, indexCheckNode))) { if (self instanceof PIntRange) { return doPRange(frame, (PIntRange) self, idx, inliningTarget, indexCheckNode, asSizeNode, normalize); @@ -566,7 +566,7 @@ static Object doGeneric(VirtualFrame frame, PRange self, Object idx, return doPRangeSliceSlowPath(frame, (PBigRange) self, slice, inliningTarget, isNumIndexProfile, isSliceIndexProfile, compute, profileError, toBigIntRange, toBigIntSlice, lenOfRangeNodeExact, lenOfRangeNode, indexCheckNode, asSizeNode, raiseNode); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "range", idx); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "range", idx); } @TruffleBoundary @@ -591,7 +591,7 @@ private static BigInteger computeBigRangeItem(Node inliningTarget, PBigRange ran } if (i.compareTo(BigInteger.ZERO) < 0 || i.compareTo(length) >= 0) { - throw PRaiseNode.raiseUncached(inliningTarget, IndexError, ErrorMessages.RANGE_OBJ_IDX_OUT_OF_RANGE); + throw PRaiseNode.raiseStatic(inliningTarget, IndexError, ErrorMessages.RANGE_OBJ_IDX_OUT_OF_RANGE); } return i; } @@ -840,14 +840,14 @@ private static BigInteger slowIntIndex(Node inliningTarget, PBigRange self, Obje static int doFastRange(VirtualFrame frame, PIntRange self, int elem, @Bind("this") Node inliningTarget, @Shared @Cached ContainsNode containsNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (containsNode.execute(frame, self, elem)) { int index = fastIntIndex(self, elem); if (index != -1) { return index; } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); } @Specialization(guards = "canBeInteger(elem)") @@ -855,7 +855,7 @@ static Object doFastRangeGeneric(VirtualFrame frame, PIntRange self, Object elem @Bind("this") Node inliningTarget, @Shared @Cached ContainsNode containsNode, @Cached PyNumberAsSizeNode asSizeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (containsNode.execute(frame, self, elem)) { int value = asSizeNode.executeExact(frame, inliningTarget, elem); int index = fastIntIndex(self, value); @@ -863,7 +863,7 @@ static Object doFastRangeGeneric(VirtualFrame frame, PIntRange self, Object elem return index; } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.IS_NOT_IN_RANGE, elem); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.IS_NOT_IN_RANGE, elem); } @Specialization(guards = "canBeInteger(elem)") @@ -871,14 +871,14 @@ static Object doLongRange(VirtualFrame frame, PBigRange self, Object elem, @Bind("this") Node inliningTarget, @Shared @Cached ContainsNode containsNode, @Cached CastToJavaBigIntegerNode castToBigInt, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (containsNode.execute(frame, self, elem)) { BigInteger index = slowIntIndex(inliningTarget, self, elem, castToBigInt); if (index != null) { return PFactory.createInt(PythonLanguage.get(inliningTarget), index); } } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); } /** @@ -892,7 +892,7 @@ static Object containsIterator(VirtualFrame frame, PIntRange self, Object elem, @Cached PyObjectGetIter getIter, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached IsBuiltinObjectProfile errorProfile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { int idx = 0; Object iter = getIter.execute(frame, inliningTarget, self); while (true) { @@ -906,11 +906,11 @@ static Object containsIterator(VirtualFrame frame, PIntRange self, Object elem, break; } if (idx == SysModuleBuiltins.MAXSIZE) { - throw raiseNode.get(inliningTarget).raiseOverflow(); + throw raiseNode.raiseOverflow(inliningTarget); } idx++; } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.D_IS_NOT_IN_RANGE, elem); } } @@ -991,7 +991,7 @@ static int doGeneric(VirtualFrame frame, PRange self, Object elem, @Cached GetNextNode nextNode, @Cached PyObjectRichCompareBool.EqNode eqNode, @Cached IsBuiltinObjectProfile errorProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int count = 0; Object iter = getIter.execute(frame, inliningTarget, self); while (true) { @@ -999,7 +999,7 @@ static int doGeneric(VirtualFrame frame, PRange self, Object elem, Object item = nextNode.execute(frame, iter); if (eqNode.compare(frame, inliningTarget, elem, item)) { if (count == SysModuleBuiltins.MAXSIZE) { - throw raiseNode.get(inliningTarget).raiseOverflow(); + throw raiseNode.raiseOverflow(inliningTarget); } count = count + 1; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java index f139b88e3e..ef29cc7899 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeNodes.java @@ -73,9 +73,9 @@ public abstract static class CreateBigRangeNode extends Node { public abstract PBigRange execute(Node inliningTarget, Object start, Object stop, Object step); @TruffleBoundary - private static void checkStepZero(Node inliningTarget, BigInteger stepBI, PRaiseNode.Lazy raise) { + private static void checkStepZero(Node inliningTarget, BigInteger stepBI, PRaiseNode raise) { if (stepBI.compareTo(BigInteger.ZERO) == 0) { - throw raise.get(inliningTarget).raise(ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); + throw raise.raise(inliningTarget, ValueError, ARG_MUST_NOT_BE_ZERO, "range()", 3); } } @@ -85,7 +85,7 @@ static PBigRange createBigRange(Node inliningTarget, Object start, Object stop, @Cached CastToJavaBigIntegerNode startToBI, @Cached CastToJavaBigIntegerNode stopToBI, @Cached CastToJavaBigIntegerNode stepToBI, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { BigInteger stepBI = stepToBI.execute(inliningTarget, step); checkStepZero(inliningTarget, stepBI, raise); BigInteger startBI = startToBI.execute(inliningTarget, start); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java index f299f37366..a713daa3eb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java @@ -141,21 +141,21 @@ static long computeHash(VirtualFrame frame, PReferenceType self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile referentProfile, @Cached PyObjectHashNode hashNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object referent = self.getObject(); if (referentProfile.profile(inliningTarget, referent != null)) { long hash = hashNode.execute(frame, inliningTarget, referent); self.setHash(hash); return hash; } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.WEAK_OBJ_GONE_AWAY); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.WEAK_OBJ_GONE_AWAY); } } @Fallback static int hashWrong(@SuppressWarnings("unused") Object self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, "__hash__", "weakref", self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, "__hash__", "weakref", self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java index 8dae6a67ea..c7fc519f6e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java @@ -87,8 +87,8 @@ public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.isExhausted()") static Object exhausted(@SuppressWarnings("unused") PBuiltinIterator self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseStopIteration(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } @Specialization(guards = "!self.isExhausted()") @@ -96,7 +96,7 @@ static Object next(VirtualFrame frame, PSequenceReverseIterator self, @Bind("this") Node inliningTarget, @Cached PySequenceGetItemNode getItemNode, @Cached IsBuiltinObjectProfile profile, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.index >= 0) { try { return getItemNode.execute(frame, self.getObject(), self.index--); @@ -105,19 +105,19 @@ static Object next(VirtualFrame frame, PSequenceReverseIterator self, } } self.setExhausted(); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } @Specialization(guards = "!self.isExhausted()") static Object next(PStringReverseIterator self, @Bind("this") Node inliningTarget, @Cached TruffleString.SubstringNode substringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (self.index >= 0) { return substringNode.execute(self.value, self.index--, 1, TS_ENCODING, false); } self.setExhausted(); - throw raiseNode.get(inliningTarget).raiseStopIteration(); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } } @@ -149,10 +149,10 @@ static int lengthHint(PStringReverseIterator self) { static int lengthHint(PSequenceReverseIterator self, @Bind("this") Node inliningTarget, @Cached SequenceNodes.LenNode lenNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int len = lenNode.execute(inliningTarget, self.getPSequence()); if (len == -1) { - throw raiseNode.get(inliningTarget).raise(TypeError, OBJ_HAS_NO_LEN, self); + throw raiseNode.raise(inliningTarget, TypeError, OBJ_HAS_NO_LEN, self); } if (len < self.index) { return 0; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java index bbe0f3ea1e..4cb3141a30 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java @@ -137,8 +137,8 @@ static PNone doGeneric(VirtualFrame frame, PSet self, Object iterable, @Fallback static PNone fail(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") Object self, Object iterable, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.SET_DOES_NOT_SUPPORT_ITERABLE_OBJ, iterable); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.SET_DOES_NOT_SUPPORT_ITERABLE_OBJ, iterable); } } @@ -684,9 +684,9 @@ abstract static class RemoveNode extends PythonBinaryBuiltinNode { static Object remove(VirtualFrame frame, PSet self, Object key, @Bind("this") Node inliningTarget, @Cached com.oracle.graal.python.builtins.objects.set.SetNodes.DiscardNode discardNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!discardNode.execute(frame, self, key)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, PythonErrorType.KeyError, new Object[]{key}); } return PNone.NONE; } @@ -710,12 +710,12 @@ public abstract static class PopNode extends PythonUnaryBuiltinNode { static Object remove(PSet self, @Bind("this") Node inliningTarget, @Cached HashingStoragePop popNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] result = popNode.execute(inliningTarget, self.getDictStorage(), self); if (result != null) { return result[0]; } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.KeyError, ErrorMessages.POP_FROM_EMPTY_SET); + throw raiseNode.raise(inliningTarget, PythonErrorType.KeyError, ErrorMessages.POP_FROM_EMPTY_SET); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java index 09fa381d61..c5348cb4f3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java @@ -101,8 +101,8 @@ static PSet setIterable(VirtualFrame frame, Object iterable, @Fallback static PSet setObject(Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_NOT_ITERABLE, value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_NOT_ITERABLE, value); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java index ba8805dfb4..c66da77e16 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PObjectSlice.java @@ -134,7 +134,7 @@ public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object BigInteger start, stop, step, length; length = (BigInteger) lengthIn; if (pySign(length) < 0) { - throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); + throw PRaiseNode.raiseStatic(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); } if (slice.getStep() == PNone.NONE) { step = ONE; @@ -143,7 +143,7 @@ public static SliceObjectInfo computeIndicesSlowPath(PObjectSlice slice, Object step = (BigInteger) slice.getStep(); stepIsNegative = pySign(step) < 0; if (pySign(step) == 0) { - throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw PRaiseNode.raiseStatic(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PSlice.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PSlice.java index 2989727c5e..d49fed28e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PSlice.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/PSlice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -110,7 +110,7 @@ public record SliceInfoLong(long start, long stop, long step) { protected static void checkNegative(int length) { if (length < 0) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); + throw PRaiseNode.raiseStatic(null, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); } } @@ -142,7 +142,7 @@ public static SliceInfo computeIndices(Object startIn, Object stopIn, Object ste stepIsNegative = pySign(step) < 0; if (pySign(step) == 0) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw PRaiseNode.raiseStatic(null, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java index 3a951b574e..6e3df887c1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java @@ -219,8 +219,8 @@ static PTuple doSliceObjectWithSlowPath(VirtualFrame frame, PSlice self, Object @Specialization(guards = {"isPNone(length)"}) static PTuple lengthNone(@SuppressWarnings("unused") PSlice self, @SuppressWarnings("unused") Object length, - @Cached PRaiseNode raise) { - throw raise.raise(ValueError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError); } } @@ -230,8 +230,8 @@ public abstract static class HashNode extends PythonBuiltinNode { @SuppressWarnings("unused") @Specialization public static long hash(PSlice self, - @Cached PRaiseNode raise) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNHASHABLE_TYPE_P, PythonBuiltinClassType.PSlice); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNHASHABLE_TYPE_P, PythonBuiltinClassType.PSlice); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java index 577f2b6b31..e867c633bd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceNodes.java @@ -137,13 +137,13 @@ public abstract static class AdjustIndices extends PNodeWithContext { @Specialization static PSlice.SliceInfo calc(Node inliningTarget, int length, PSlice.SliceInfo slice, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int start = slice.start; int stop = slice.stop; int step = slice.step; if (step == 0) { - raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } assert step > Integer.MIN_VALUE : "step must not be minimum integer value"; @@ -207,8 +207,8 @@ PSlice.SliceInfo doSliceObject(VirtualFrame frame, PObjectSlice slice, int lengt @Specialization(guards = "length < 0") PSlice.SliceInfo doSliceInt(@SuppressWarnings("unused") PSlice slice, @SuppressWarnings("unused") int length, - @Cached PRaiseNode raise) { - throw raise.raise(ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.LENGTH_SHOULD_NOT_BE_NEG); } } @@ -297,7 +297,7 @@ static PSlice.SliceInfo doSliceInt(PIntSlice slice) { @InliningCutoff static PSlice.SliceInfo doSliceObject(Node inliningTarget, PObjectSlice slice, @Cached SliceLossyCastToInt toInt, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* this is harder to get right than you might think */ int start, stop, step; if (slice.getStep() == PNone.NONE) { @@ -305,7 +305,7 @@ static PSlice.SliceInfo doSliceObject(Node inliningTarget, PObjectSlice slice, } else { step = (int) toInt.execute(inliningTarget, slice.getStep()); if (step == 0) { - raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } } @@ -339,10 +339,10 @@ public abstract static class SliceUnpackLong extends PNodeWithContext { @Specialization static PSlice.SliceInfoLong doSliceInt(Node inliningTarget, PIntSlice slice, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { long step = slice.getIntStep(); if (step == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } long start; @@ -357,7 +357,7 @@ static PSlice.SliceInfoLong doSliceInt(Node inliningTarget, PIntSlice slice, @Specialization static PSlice.SliceInfoLong doSliceObject(Node inliningTarget, PObjectSlice slice, @Cached SliceLossyCastToLong toInt, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { /* this is harder to get right than you might think */ long start, stop, step; if (slice.getStep() == PNone.NONE) { @@ -365,7 +365,7 @@ static PSlice.SliceInfoLong doSliceObject(Node inliningTarget, PObjectSlice slic } else { step = toInt.execute(inliningTarget, slice.getStep()); if (step == 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SLICE_STEP_CANNOT_BE_ZERO); } /* * Same as in CPython 'PySlice_Unpack': Here step might be -Long.MAX_VALUE-1; in @@ -410,13 +410,13 @@ protected static Object doNone(@SuppressWarnings("unused") PNone i) { @Specialization(guards = "!isPNone(i)") protected static Object doGeneric(Node inliningTarget, Object i, @Cached InlinedBranchProfile exceptionProfile, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached CastToJavaBigIntegerNode cast) { try { return cast.execute(inliningTarget, i); } catch (PException e) { exceptionProfile.enter(inliningTarget); - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); } } } @@ -436,13 +436,13 @@ protected static Object doNone(@SuppressWarnings("unused") PNone i) { @Specialization(guards = "!isPNone(i)") protected static Object doGeneric(Node inliningTarget, Object i, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode) { if (indexCheckNode.execute(inliningTarget, i)) { return asSizeNode.executeExact(null, inliningTarget, i); } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); } } @@ -462,14 +462,14 @@ protected static Object doNone(@SuppressWarnings("unused") PNone i) { @Specialization(guards = "!isPNone(i)") protected static Object doGeneric(Node inliningTarget, Object i, @Cached InlinedBranchProfile exceptionProfile, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode) { if (indexCheckNode.execute(inliningTarget, i)) { return asSizeNode.executeLossy(null, inliningTarget, i); } exceptionProfile.enter(inliningTarget); - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); } } @@ -483,7 +483,7 @@ public abstract static class SliceLossyCastToLong extends Node { @Specialization(guards = "!isPNone(i)") static long doGeneric(Node inliningTarget, Object i, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached PyIndexCheckNode indexCheckNode, @Cached(inline = false) PyLongSign signNode, @Cached PyLongAsLongAndOverflowNode asSizeNode) { @@ -497,7 +497,7 @@ static long doGeneric(Node inliningTarget, Object i, return Long.MAX_VALUE; } } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SLICE_INDICES_MUST_BE_INT_NONE_HAVE_INDEX); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java index 755c2c3b07..7456dd77cf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java @@ -124,9 +124,9 @@ protected List> getNodeFa return SocketBuiltinsFactory.getFactories(); } - private static void checkSelectable(Node inliningTarget, PRaiseNode.Lazy raiseNode, PSocket socket) { + private static void checkSelectable(Node inliningTarget, PRaiseNode raiseNode, PSocket socket) { if (!isSelectable(socket)) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.UNABLE_TO_SELECT_ON_SOCKET); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.UNABLE_TO_SELECT_ON_SOCKET); } } @@ -199,13 +199,13 @@ static Object init(VirtualFrame frame, PSocket self, int familyIn, int typeIn, i @Exclusive @Cached SysModuleBuiltins.AuditNode auditNode, @Cached PyLongAsIntNode asIntNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // sic! CPython really has __new__ there, even though it's in __init__ auditNode.audit(inliningTarget, "socket.__new__", self, familyIn, typeIn, protoIn); int fd = asIntNode.execute(frame, inliningTarget, fileno); if (fd < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_FILE_DESC); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_FILE_DESC); } int family = familyIn; try { @@ -287,7 +287,7 @@ static Object accept(VirtualFrame frame, PSocket self, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { checkSelectable(inliningTarget, raiseNode, self); try { @@ -590,9 +590,9 @@ static Object recv(VirtualFrame frame, PSocket socket, int recvlen, int flags, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (recvlen < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECV); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECV); } checkSelectable(inliningTarget, raiseNode, socket); PythonLanguage language = context.getLanguage(inliningTarget); @@ -604,7 +604,7 @@ static Object recv(VirtualFrame frame, PSocket socket, int recvlen, int flags, try { bytes = new byte[recvlen]; } catch (OutOfMemoryError error) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } try { @@ -641,9 +641,9 @@ static Object recvFrom(VirtualFrame frame, PSocket socket, int recvlen, int flag @Cached GilNode gil, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (recvlen < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECVFROM); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECVFROM); } checkSelectable(inliningTarget, raiseNode, socket); @@ -651,7 +651,7 @@ static Object recvFrom(VirtualFrame frame, PSocket socket, int recvlen, int flag try { bytes = new byte[recvlen]; } catch (OutOfMemoryError error) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } try { @@ -694,11 +694,11 @@ static Object recvInto(VirtualFrame frame, PSocket socket, Object bufferObj, int @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireWritable(bufferObj, frame, indirectCallData); try { if (recvlenIn < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECV_INTO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECV_INTO); } int buflen = bufferLib.getBufferLength(buffer); int recvlen = recvlenIn; @@ -706,7 +706,7 @@ static Object recvInto(VirtualFrame frame, PSocket socket, Object bufferObj, int recvlen = buflen; } if (buflen < recvlen) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.BUFF_TOO_SMALL); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.BUFF_TOO_SMALL); } checkSelectable(inliningTarget, raiseNode, socket); @@ -719,7 +719,7 @@ static Object recvInto(VirtualFrame frame, PSocket socket, Object bufferObj, int try { bytes = new byte[recvlen]; } catch (OutOfMemoryError error) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -763,11 +763,11 @@ static Object recvFromInto(VirtualFrame frame, PSocket socket, Object bufferObj, @Cached GilNode gil, @Cached SocketNodes.MakeSockAddrNode makeSockAddrNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireWritable(bufferObj, frame, indirectCallData); try { if (recvlenIn < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECVFROM_INTO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NEG_BUFF_SIZE_IN_RECVFROM_INTO); } int buflen = bufferLib.getBufferLength(buffer); int recvlen = recvlenIn; @@ -775,7 +775,7 @@ static Object recvFromInto(VirtualFrame frame, PSocket socket, Object bufferObj, recvlen = buflen; } if (buflen < recvlen) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NBYTES_GREATER_THAT_BUFF); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NBYTES_GREATER_THAT_BUFF); } checkSelectable(inliningTarget, raiseNode, socket); @@ -788,7 +788,7 @@ static Object recvFromInto(VirtualFrame frame, PSocket socket, Object bufferObj, try { bytes = new byte[recvlen]; } catch (OutOfMemoryError error) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } @@ -829,7 +829,7 @@ static int send(VirtualFrame frame, PSocket socket, Object bufferObj, int flags, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(bufferObj, frame, indirectCallData); try { checkSelectable(inliningTarget, raiseNode, socket); @@ -870,7 +870,7 @@ static Object sendAll(VirtualFrame frame, PSocket socket, Object bufferObj, int @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireReadonly(bufferObj, frame, indirectCallData); try { checkSelectable(inliningTarget, raiseNode, socket); @@ -933,7 +933,7 @@ static Object sendTo(VirtualFrame frame, PSocket socket, Object bufferObj, Objec @Cached SysModuleBuiltins.AuditNode auditNode, @Cached GilNode gil, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int flags; Object address; if (hasFlagsProfile.profile(inliningTarget, maybeAddress == PNone.NO_VALUE)) { @@ -1138,11 +1138,11 @@ static Object setNull(VirtualFrame frame, PSocket socket, int level, int option, @Bind("this") Node inliningTarget, @Exclusive @Cached PyLongAsIntNode asIntNode, @Exclusive @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int buflen = asIntNode.execute(frame, inliningTarget, buflenObj); if (buflen < 0) { // GraalPython-specific because we don't have unsigned integers - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.SETSECKOPT_BUFF_OUT_OFRANGE); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.SETSECKOPT_BUFF_OUT_OFRANGE); } try { posixLib.setsockopt(context.getPosixSupport(), socket.getFd(), level, option, null, buflen); @@ -1155,8 +1155,8 @@ static Object setNull(VirtualFrame frame, PSocket socket, int level, int option, @Fallback @SuppressWarnings("unused") static Object error(Object self, Object level, Object option, Object flag1, Object flag2, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.SETSECKOPT_REQUIRERS_3RD_ARG_NULL); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.SETSECKOPT_REQUIRERS_3RD_ARG_NULL); } @Override @@ -1177,7 +1177,7 @@ static Object getSockOpt(VirtualFrame frame, PSocket socket, int level, int opti @Bind PythonContext context, @CachedLibrary("context.getPosixSupport()") PosixSupportLibrary posixLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (buflen == 0) { byte[] result = new byte[4]; @@ -1188,7 +1188,7 @@ static Object getSockOpt(VirtualFrame frame, PSocket socket, int level, int opti int len = posixLib.getsockopt(context.getPosixSupport(), socket.getFd(), level, option, result, result.length); return PFactory.createBytes(context.getLanguage(inliningTarget), result, len); } else { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.GETSECKOPT_BUFF_OUT_OFRANGE); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.GETSECKOPT_BUFF_OUT_OFRANGE); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSErrorFromPosixException(frame, e); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java index e6aad3fbcc..3bd1e0eac4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketNodes.java @@ -133,14 +133,14 @@ static UniversalSockAddr doInet(VirtualFrame frame, @SuppressWarnings("unused") @Cached @Shared("idnaConverter") IdnaFromStringOrBytesConverterNode idnaConverter, @Cached @Shared("errorProfile") IsBuiltinObjectProfile errorProfile, @Cached @Shared("setIpAddr") SetIpAddrNode setIpAddrNode, - @Cached @Shared PRaiseNode.Lazy raiseNode) { + @Cached @Shared PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); if (!(address instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_AF_INET_VALUES_MUST_BE_TUPLE_NOT_P, caller, address); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_AF_INET_VALUES_MUST_BE_TUPLE_NOT_P, caller, address); } Object[] hostAndPort = getObjectArrayNode.execute(inliningTarget, address); if (hostAndPort.length != 2) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.AF_INET_VALUES_MUST_BE_PAIR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.AF_INET_VALUES_MUST_BE_PAIR); } byte[] host = idnaConverter.execute(frame, hostAndPort[0]); int port = parsePort(frame, caller, asIntNode, inliningTarget, errorProfile, hostAndPort[1], raiseNode); @@ -159,14 +159,14 @@ static UniversalSockAddr doInet6(VirtualFrame frame, @SuppressWarnings("unused") @Cached @Shared("idnaConverter") IdnaFromStringOrBytesConverterNode idnaConverter, @Cached @Shared("errorProfile") IsBuiltinObjectProfile errorProfile, @Cached @Shared("setIpAddr") SetIpAddrNode setIpAddrNode, - @Cached @Shared PRaiseNode.Lazy raiseNode) { + @Cached @Shared PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); if (!(address instanceof PTuple)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_AF_INET_VALUES_MUST_BE_TUPLE_NOT_S, caller, address); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_AF_INET_VALUES_MUST_BE_TUPLE_NOT_S, caller, address); } Object[] hostAndPort = getObjectArrayNode.execute(inliningTarget, address); if (hostAndPort.length < 2 || hostAndPort.length > 4) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.AF_INET6_ADDR_MUST_BE_TUPLE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.AF_INET6_ADDR_MUST_BE_TUPLE); } byte[] host = idnaConverter.execute(frame, hostAndPort[0]); int port = parsePort(frame, caller, asIntNode, inliningTarget, errorProfile, hostAndPort[1], raiseNode); @@ -174,7 +174,7 @@ static UniversalSockAddr doInet6(VirtualFrame frame, @SuppressWarnings("unused") if (hostAndPort.length > 2) { flowinfo = asIntNode.execute(frame, inliningTarget, hostAndPort[2]); if (flowinfo < 0 || flowinfo > 0xfffff) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_FLOWINFO_RANGE, caller); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_FLOWINFO_RANGE, caller); } } int scopeid = 0; @@ -197,7 +197,7 @@ static UniversalSockAddr doUnix(VirtualFrame frame, @SuppressWarnings("unused") @CachedLibrary(limit = "1") PythonBufferAcquireLibrary bufferAcquireLib, @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @CachedLibrary(limit = "1") @Shared("posixLib") PosixSupportLibrary posixLib, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { byte[] path; if (unicodeCheckNode.execute(inliningTarget, address)) { // PyUnicode_EncodeFSDefault @@ -220,17 +220,17 @@ static UniversalSockAddr doUnix(VirtualFrame frame, @SuppressWarnings("unused") try { return posixLib.createUniversalSockAddrUnix(posixSupport, new UnixSockAddr(path)); } catch (UnsupportedPosixFeatureException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.AF_UNIX_NOT_SUPPORTED, caller); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.AF_UNIX_NOT_SUPPORTED, caller); } catch (InvalidUnixSocketPathException e) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.AF_UNIX_PATH_TOO_LONG, caller); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.AF_UNIX_PATH_TOO_LONG, caller); } } @Specialization(guards = {"!isInet(socket)", "!isInet6(socket)", "!isUnix(socket)"}) @SuppressWarnings("unused") static UniversalSockAddr getSockAddr(VirtualFrame frame, PSocket socket, Object address, String caller, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(OSError, ErrorMessages.BAD_FAMILY, caller); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, OSError, ErrorMessages.BAD_FAMILY, caller); } static boolean isInet(PSocket socket) { @@ -246,7 +246,7 @@ static boolean isUnix(PSocket socket) { } private static int parsePort(VirtualFrame frame, String caller, PyLongAsIntNode asIntNode, Node inliningTarget, IsBuiltinObjectProfile errorProfile, Object portObj, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { int port; try { port = asIntNode.execute(frame, inliningTarget, portObj); @@ -255,7 +255,7 @@ private static int parsePort(VirtualFrame frame, String caller, PyLongAsIntNode port = -1; } if (port < 0 || port > 0xffff) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.S_PORT_RANGE, caller); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.S_PORT_RANGE, caller); } return port; } @@ -280,7 +280,7 @@ static UniversalSockAddr setipaddr(VirtualFrame frame, byte[] name, int family, @Cached InetPtoNCachedPNode inetPtoNCachedPNode, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { PythonContext context = PythonContext.get(inliningTarget); Object posixSupport = context.getPosixSupport(); try { @@ -292,7 +292,7 @@ static UniversalSockAddr setipaddr(VirtualFrame frame, byte[] name, int family, family, SOCK_DGRAM.value, 0, AI_PASSIVE.value); try { if (addrInfoLib.next(cursor)) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.WILD_CARD_RESOLVED_TO_MULTIPLE_ADDRESS); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.WILD_CARD_RESOLVED_TO_MULTIPLE_ADDRESS); } return addrInfoLib.getSockAddr(cursor); } finally { @@ -305,7 +305,7 @@ static UniversalSockAddr setipaddr(VirtualFrame frame, byte[] name, int family, /* special-case broadcast - inet_addr() below can return INADDR_NONE for this */ if (Arrays.equals(name, BROADCAST_IP) || Arrays.equals(name, BROADCAST)) { if (family != AF_INET.value && family != AF_UNSPEC.value) { - throw raiseNode.get(inliningTarget).raise(OSError, ErrorMessages.ADDRESS_FAMILY_MISMATCHED); + throw raiseNode.raise(inliningTarget, OSError, ErrorMessages.ADDRESS_FAMILY_MISMATCHED); } return posixLib.createUniversalSockAddrInet4(posixSupport, new Inet4SockAddr(0, INADDR_BROADCAST.value)); } @@ -399,7 +399,7 @@ static Object makeSockAddr(VirtualFrame frame, Node inliningTarget, UniversalSoc @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, @Cached(inline = false) TruffleString.FromByteArrayNode fromByteArrayNode, @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PythonContext context = PythonContext.get(inliningTarget); PythonLanguage language = context.getLanguage(inliningTarget); @@ -426,7 +426,7 @@ static Object makeSockAddr(VirtualFrame frame, Node inliningTarget, UniversalSoc // Can be returned from recvfrom when used on a connected socket return PNone.NONE; } else { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, toTruffleStringUncached("makesockaddr: unknown address family")); + throw raiseNode.raise(inliningTarget, NotImplementedError, toTruffleStringUncached("makesockaddr: unknown address family")); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, e.getErrorCode(), fromJavaStringNode.execute(e.getMessage(), TS_ENCODING)); @@ -458,7 +458,7 @@ static Object makeAddr(VirtualFrame frame, Node inliningTarget, UniversalSockAdd @CachedLibrary("addr") UniversalSockAddrLibrary addrLib, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { PythonContext context = PythonContext.get(inliningTarget); int family = addrLib.getFamily(addr); @@ -471,7 +471,7 @@ static Object makeAddr(VirtualFrame frame, Node inliningTarget, UniversalSockAdd Object posixSupport = context.getPosixSupport(); return posixLib.getPathAsString(posixSupport, posixLib.inet_ntop(posixSupport, family, inet6SockAddr.getAddress())); } else { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, toTruffleStringUncached("makesockaddr: unknown address family")); + throw raiseNode.raise(inliningTarget, NotImplementedError, toTruffleStringUncached("makesockaddr: unknown address family")); } } catch (PosixException e) { throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, e.getErrorCode(), fromJavaStringNode.execute(e.getMessage(), TS_ENCODING)); @@ -501,7 +501,7 @@ byte[] convert(VirtualFrame frame, Object value, @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached TruffleString.CopyToByteArrayNode copyToByteArrayNode, @Cached CodecsModuleBuiltins.EncodeNode encodeNode, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { Object bytes; if (unicodeCheckNode.execute(inliningTarget, value)) { TruffleString string = castToString.execute(inliningTarget, value); @@ -518,9 +518,9 @@ byte[] convert(VirtualFrame frame, Object value, bytes = value; } else { if (builtinName != null) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_BYTELIKE_OR_BYTEARRAY, builtinName, argumentIndex, value); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_BYTELIKE_OR_BYTEARRAY, builtinName, argumentIndex, value); } else { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.STR_BYTES_OR_BYTEARRAY_EXPECTED, value); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.STR_BYTES_OR_BYTEARRAY_EXPECTED, value); } } return bufferLib.getCopiedByteArray(bytes); @@ -554,10 +554,10 @@ static long parse(@SuppressWarnings("unused") PNone none) { @Specialization(guards = "!isNone(seconds)") static long parse(VirtualFrame frame, Node inliningTarget, Object seconds, @Cached PyTimeFromObjectNode timeFromObjectNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { long timeout = timeFromObjectNode.execute(frame, inliningTarget, seconds, RoundType.TIMEOUT, TimeUtils.SEC_TO_NS); if (timeout < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TIMEOUT_VALUE_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TIMEOUT_VALUE_OUT_OF_RANGE); } return timeout; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java index 969e572c33..bb02505f09 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/MemoryBIOBuiltins.java @@ -136,7 +136,7 @@ static int write(VirtualFrame frame, PMemoryBIO self, Object buffer, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (self.didWriteEOF()) { throw constructAndRaiseNode.get(inliningTarget).raiseSSLError(frame, SSL_CANNOT_WRITE_AFTER_EOF); @@ -147,7 +147,7 @@ static int write(VirtualFrame frame, PMemoryBIO self, Object buffer, self.write(bytes, len); return len; } catch (OverflowException | OutOfMemoryError e) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } finally { bufferLib.release(buffer, frame, indirectCallData); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLCipherSelector.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLCipherSelector.java index b69faff792..7ef0a4df79 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLCipherSelector.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLCipherSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -111,7 +111,7 @@ private static void selectSingle(Node node, String cipherString, List if (cipherString.startsWith("@STRENGTH")) { selected.sort(Comparator.comparingInt(SSLCipher::getStrengthBits).reversed()); } else if (cipherString.startsWith("@SECLEVEL=")) { - throw PRaiseNode.raiseUncached(node, NotImplementedError, toTruffleStringUncached("@SECLEVEL not implemented")); + throw PRaiseNode.raiseStatic(node, NotImplementedError, toTruffleStringUncached("@SECLEVEL not implemented")); } else { throw PConstructAndRaiseNode.raiseUncachedSSLError(ErrorMessages.NO_CIPHER_CAN_BE_SELECTED); } @@ -133,7 +133,7 @@ private static List getCiphersForCipherString(Node node, String ciphe List ciphers = SSLCipherStringMapping.get(component); if (ciphers == null) { if (component.equals("PROFILE=SYSTEM")) { - throw PRaiseNode.raiseUncached(node, NotImplementedError, toTruffleStringUncached("PROFILE=SYSTEM not implemented")); + throw PRaiseNode.raiseStatic(node, NotImplementedError, toTruffleStringUncached("PROFILE=SYSTEM not implemented")); } return Collections.emptyList(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java index 786ec73cf6..86d8a854e1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java @@ -170,10 +170,10 @@ static PSSLContext createContext(VirtualFrame frame, Object type, int protocol, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SSLMethod method = SSLMethod.fromPythonId(protocol); if (method == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_OR_UNSUPPORTED_PROTOCOL_VERSION, "NULL"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_OR_UNSUPPORTED_PROTOCOL_VERSION, "NULL"); } try { boolean checkHostname; @@ -194,7 +194,7 @@ static PSSLContext createContext(VirtualFrame frame, Object type, int protocol, context.setOptions(options); return context; } catch (NoSuchAlgorithmException e) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_OR_UNSUPPORTED_PROTOCOL_VERSION, e); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_OR_UNSUPPORTED_PROTOCOL_VERSION, e); } catch (KeyManagementException e) { throw constructAndRaiseNode.get(inliningTarget).raiseSSLError(frame, SSLErrorCode.ERROR_SSL, e); } @@ -231,9 +231,9 @@ static SSLEngine createSSLEngine(Node raisingNode, PSSLContext context, boolean parameters.setServerNames(Collections.singletonList(new SNIHostName(serverHostname))); } catch (IllegalArgumentException e) { if (serverHostname.contains("\0")) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.ARG_MUST_BE_ENCODED_NON_NULL); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.ARG_MUST_BE_ENCODED_NON_NULL); } - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.INVALID_HOSTNAME); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.INVALID_HOSTNAME); } if (context.getCheckHostname()) { parameters.setEndpointIdentificationAlgorithm("HTTPS"); @@ -307,8 +307,8 @@ static Object wrap(PSSLContext context, PSocket sock, boolean serverSide, Object @Fallback @SuppressWarnings("unused") static Object wrap(Object context, Object sock, Object serverSide, Object serverHostname, Object owner, Object session, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.INVALID_WRAP_SOCKET_CALL); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INVALID_WRAP_SOCKET_CALL); } @Override @@ -344,8 +344,8 @@ static Object wrap(PSSLContext context, PMemoryBIO incoming, PMemoryBIO outgoing @Fallback @SuppressWarnings("unused") static Object wrap(Object context, Object incoming, Object outgoing, Object serverSide, Object serverHostname, Object owner, Object session, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.INVALID_WRAP_BIO_CALL); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INVALID_WRAP_BIO_CALL); } @Override @@ -433,10 +433,10 @@ static int get(PSSLContext self, @SuppressWarnings("unused") PNone value) { static Object set(VirtualFrame frame, PSSLContext self, Object value, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int mode = asSizeNode.executeLossy(frame, inliningTarget, value); if (mode == SSLModuleBuiltins.SSL_CERT_NONE && self.getCheckHostname()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CANNOT_SET_VERIFY_MODE_TO_CERT_NONE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_SET_VERIFY_MODE_TO_CERT_NONE); } switch (mode) { case SSLModuleBuiltins.SSL_CERT_NONE: @@ -445,14 +445,14 @@ static Object set(VirtualFrame frame, PSSLContext self, Object value, self.setVerifyMode(mode); return PNone.NONE; default: - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.INVALID_VALUE_FOR_VERIFY_MODE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_VALUE_FOR_VERIFY_MODE); } } } - private static void setMinMaxVersion(Node inliningTarget, PRaiseNode.Lazy raiseNode, PSSLContext context, boolean maximum, int value) { + private static void setMinMaxVersion(Node inliningTarget, PRaiseNode raiseNode, PSSLContext context, boolean maximum, int value) { if (context.getMethod().isSingleVersion()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.CONTEXT_DOESNT_SUPPORT_MIN_MAX); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CONTEXT_DOESNT_SUPPORT_MIN_MAX); } SSLProtocol selected = null; switch (value) { @@ -470,7 +470,7 @@ private static void setMinMaxVersion(Node inliningTarget, PRaiseNode.Lazy raiseN } } if (selected == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNSUPPORTED_PROTOCOL_VERSION, value); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNSUPPORTED_PROTOCOL_VERSION, value); } } if (maximum) { @@ -492,7 +492,7 @@ static int get(PSSLContext self, @SuppressWarnings("unused") Object none) { static Object set(VirtualFrame frame, PSSLContext self, Object obj, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { setMinMaxVersion(inliningTarget, raiseNode, self, false, asSizeNode.executeExact(frame, inliningTarget, obj)); return PNone.NONE; } @@ -510,7 +510,7 @@ static int get(PSSLContext self, @SuppressWarnings("unused") Object none) { static Object set(VirtualFrame frame, PSSLContext self, Object obj, @Bind("this") Node inliningTarget, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { setMinMaxVersion(inliningTarget, raiseNode, self, true, asSizeNode.executeExact(frame, inliningTarget, obj)); return PNone.NONE; } @@ -556,17 +556,17 @@ abstract static class NumTicketsNode extends PythonBinaryBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "isNoValue(value)") static int get(PSSLContext self, PNone value, - @Shared @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // not used yet so rather raise error - throw raiseNode.raise(NotImplementedError); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } @SuppressWarnings("unused") @Specialization(guards = "!isNoValue(value)") static Object set(VirtualFrame frame, PSSLContext self, Object value, - @Shared @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // not used yet so rather raise error - throw raiseNode.raise(NotImplementedError); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); // int num; // try { // num = (int) castToLong.execute(lib.asIndexWithFrame(value, frame)); @@ -589,8 +589,8 @@ static Object set(VirtualFrame frame, PSSLContext self, Object value, abstract static class SNICallbackNode extends PythonBinaryBuiltinNode { @Specialization static Object notImplemented(@SuppressWarnings("unused") PSSLContext self, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -723,15 +723,15 @@ Object load(VirtualFrame frame, PSSLContext self, Object cafile, Object capath, @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Cached TruffleString.EqualNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (cafile instanceof PNone && capath instanceof PNone && cadata instanceof PNone) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CA_FILE_PATH_DATA_CANNOT_BE_ALL_OMMITED); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CA_FILE_PATH_DATA_CANNOT_BE_ALL_OMMITED); } if (!(cafile instanceof PNone) && !PGuards.isString(cafile) && !PGuards.isBytes(cafile)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "cafile"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "cafile"); } if (!(capath instanceof PNone) && !PGuards.isString(capath) && !PGuards.isBytes(capath)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "capath"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "capath"); } final TruffleFile file; if (!(cafile instanceof PNone)) { @@ -758,7 +758,7 @@ Object load(VirtualFrame frame, PSSLContext self, Object cafile, Object capath, if (cadata instanceof PBytesLike) { certificates = fromBytesLike(toBytes.execute(inliningTarget, ((PBytesLike) cadata).getSequenceStorage())); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_ASCII_OR_BYTELIKE, "cadata"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_ASCII_OR_BYTELIKE, "cadata"); } } self.setCAEntries(certificates); @@ -790,10 +790,10 @@ private TruffleFile toTruffleFile(VirtualFrame frame, Node inliningTarget, PyUni } } - private static List fromString(Node inliningTarget, String dataString, PRaiseNode.Lazy raiseNode) + private static List fromString(Node inliningTarget, String dataString, PRaiseNode raiseNode) throws IOException, CertificateException, CRLException { if (dataString.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_CERTIFICATE_DATA); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_CERTIFICATE_DATA); } return getCertificates(dataString); } @@ -845,12 +845,12 @@ Object load(VirtualFrame frame, PSSLContext self, Object certfile, Object keyfil @Cached GetPasswordNode getPasswordNode, @Cached TruffleString.ToJavaStringNode toJavaStringNode, @Cached TruffleString.EqualNode eqNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!PGuards.isString(certfile) && !PGuards.isBytes(certfile)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "certfile"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "certfile"); } if (!(keyfile instanceof PNone) && !PGuards.isString(keyfile) && !PGuards.isBytes(keyfile)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "keyfile"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, "keyfile"); } Object kf = keyfile instanceof PNone ? certfile : keyfile; TruffleFile certTruffleFile = toTruffleFile(frame, inliningTarget, asPath.execute(frame, certfile), toJavaStringNode, eqNode, constructAndRaiseNode); @@ -867,7 +867,7 @@ Object load(VirtualFrame frame, PSSLContext self, Object certfile, Object keyfil throw CompilerDirectives.shouldNotReachHere(); } } - throw raiseNode.get(inliningTarget).raise(NotImplementedError, ErrorMessages.PASSWORD_NOT_IMPLEMENTED); + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.PASSWORD_NOT_IMPLEMENTED); } } catch (IOException ex) { throw constructAndRaiseNode.get(inliningTarget).raiseSSLError(frame, SSLErrorCode.ERROR_SSL, ex); @@ -888,7 +888,7 @@ private BufferedReader getReader(TruffleFile file, String arg) throws IOExceptio LOGGER.fine(() -> String.format("load_cert_chain %s:%s", arg, file.getPath())); return file.newBufferedReader(); } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, arg); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.S_SHOULD_BE_A_VALID_FILESYSTEMPATH, arg); } } @@ -937,20 +937,22 @@ abstract static class GetPasswordNode extends PNodeWithContext { @Specialization(guards = "isString(password)") static char[] doString(Object password, + @Bind("this") Node inliningTarget, @Cached CastToJavaStringNode cast, @Shared @Cached PRaiseNode raiseNode) { String str = cast.execute(password); - checkPasswordLength(raiseNode, str.length()); + checkPasswordLength(raiseNode, str.length(), inliningTarget); return stringToChars(str); } @Specialization(limit = "2") static char[] doBytes(PBytesLike bytes, + @Bind("this") Node inliningTarget, @CachedLibrary("bytes") PythonBufferAccessLibrary bufferLib, @Shared @Cached PRaiseNode raiseNode) { byte[] data = bufferLib.getInternalOrCopiedByteArray(bytes); int length = bufferLib.getBufferLength(bytes); - checkPasswordLength(raiseNode, length); + checkPasswordLength(raiseNode, length, inliningTarget); char[] res = new char[length]; for (int i = 0; i < res.length; i++) { res[i] = (char) data[i]; @@ -970,9 +972,9 @@ static char[] doCallable(VirtualFrame frame, Object callable, if (PGuards.isString(result) || result instanceof PBytesLike) { return recursive.execute(frame, result); } - throw raiseNode.raise(TypeError, ErrorMessages.PSSWD_CALLBACK_MUST_RETURN_STR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.PSSWD_CALLBACK_MUST_RETURN_STR); } - throw raiseNode.raise(TypeError, ErrorMessages.PSSWD_SHOULD_BE_STR_OR_CALLABLE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.PSSWD_SHOULD_BE_STR_OR_CALLABLE); } @TruffleBoundary @@ -980,9 +982,9 @@ private static char[] stringToChars(String str) { return str.toCharArray(); } - private static void checkPasswordLength(PRaiseNode raiseNode, int length) { + private static void checkPasswordLength(PRaiseNode raiseNode, int length, Node inliningTarget) { if (length > MAX_LEN) { - throw raiseNode.raise(ValueError, ErrorMessages.PSSWD_CANNOT_BE_LONGER_THAN_D_BYTES, MAX_LEN); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.PSSWD_CANNOT_BE_LONGER_THAN_D_BYTES, MAX_LEN); } } } @@ -993,11 +995,11 @@ abstract static class LoadDhParamsNode extends PythonBinaryBuiltinNode { @SuppressWarnings("unused") @Specialization static PNone load(VirtualFrame frame, PSSLContext self, Object pathObject, - @Cached PyUnicodeFSDecoderNode asPath, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget, + @Cached PyUnicodeFSDecoderNode asPath) { TruffleString path = asPath.execute(frame, pathObject); // not used yet so rather raise error - throw raiseNode.raise(NotImplementedError); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); // File file = new File(path); // if (!file.exists()) { // throw raiseOSError(frame, OSErrorEnum.ENOENT); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLOperationNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLOperationNode.java index fc04f6d46f..8dc68a63fb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLOperationNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLOperationNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -177,7 +177,7 @@ static void doSocket(VirtualFrame frame, Node inliningTarget, PSSLSocket socket, @Cached(inline = false) GilNode gil, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { assert socket.getSocket() != null; prepare(socket); TimeoutHelper timeoutHelper = null; @@ -270,7 +270,7 @@ static void doSocket(VirtualFrame frame, Node inliningTarget, PSSLSocket socket, } catch (SSLException e) { throw handleSSLException(e); } catch (OverflowException | OutOfMemoryError node) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } PythonContext.triggerAsyncActions(inliningTarget); } @@ -279,7 +279,7 @@ static void doSocket(VirtualFrame frame, Node inliningTarget, PSSLSocket socket, @Specialization(guards = "socket.getSocket() == null") static void doMemory(VirtualFrame frame, Node inliningTarget, PSSLSocket socket, ByteBuffer appInput, ByteBuffer targetBuffer, SSLOperation operation, @Shared @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { prepare(socket); SSLOperationStatus status; try { @@ -312,7 +312,7 @@ static void doMemory(VirtualFrame frame, Node inliningTarget, PSSLSocket socket, } catch (SSLException e) { throw handleSSLException(e); } catch (OverflowException | OutOfMemoryError node) { - throw raiseNode.get(inliningTarget).raise(MemoryError); + throw raiseNode.raise(inliningTarget, MemoryError); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java index 8854f325f5..1e25fb80b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLSocketBuiltins.java @@ -106,11 +106,11 @@ static Object read(VirtualFrame frame, PSSLSocket self, int len, @SuppressWarnin @Bind("this") Node inliningTarget, @Bind PythonLanguage language, @Shared @Cached SSLOperationNode sslOperationNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (len == 0) { return PFactory.createBytes(language, new byte[0]); } else if (len < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SIZE_SHOULD_NOT_BE_NEGATIVE); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SIZE_SHOULD_NOT_BE_NEGATIVE); } ByteBuffer output = PythonUtils.allocateByteBuffer(len); sslOperationNode.read(frame, inliningTarget, self, output); @@ -126,7 +126,7 @@ static Object readInto(VirtualFrame frame, PSSLSocket self, int len, Object buff @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, @Shared @Cached SSLOperationNode sslOperationNode, // unused node to avoid mixing shared and non-shared inlined nodes - @SuppressWarnings("unused") @Shared @Cached PRaiseNode.Lazy raiseNode) { + @SuppressWarnings("unused") @Shared @Cached PRaiseNode raiseNode) { Object buffer = bufferAcquireLib.acquireWritableWithTypeError(bufferObj, "read", frame, indirectCallData); try { int bufferLen = bufferLib.getBufferLength(buffer); @@ -294,9 +294,9 @@ static Object get(@SuppressWarnings("unused") PSSLSocket self, @SuppressWarnings @Specialization(guards = "!isNoValue(obj)") static Object set(@SuppressWarnings("unused") PSSLSocket self, @SuppressWarnings("unused") Object obj, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // JDK API doesn't support setting session ID - throw raiseNode.raise(NotImplementedError); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError); } } @@ -317,9 +317,9 @@ abstract static class GetPeerCertNode extends PythonBinaryClinicBuiltinNode { static Object getPeerCertDER(PSSLSocket self, @SuppressWarnings("unused") boolean der, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (!self.isHandshakeComplete()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); } Certificate certificate = getCertificate(self.getEngine()); if (certificate != null) { @@ -338,9 +338,9 @@ static Object getPeerCertDER(PSSLSocket self, @SuppressWarnings("unused") boolea static PDict getPeerCertDict(PSSLSocket self, @SuppressWarnings("unused") boolean der, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (!self.isHandshakeComplete()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HANDSHAKE_NOT_DONE_YET); } Certificate certificate = getCertificate(self.getEngine()); if (certificate instanceof X509Certificate) { @@ -387,9 +387,9 @@ abstract static class GetChannelBinding extends PythonBinaryClinicBuiltinNode { @Specialization @SuppressWarnings("unused") static Object getChannelBinding(PSSLSocket self, TruffleString sbType, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { // JDK doesn't have an API to access what we need. BouncyCastle could provide this - throw raiseNode.raise(ValueError, ErrorMessages.S_CHANNEL_BINDING_NOT_IMPLEMENTED, sbType); + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.S_CHANNEL_BINDING_NOT_IMPLEMENTED, sbType); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java index effbd08d93..a525f5a831 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java @@ -245,7 +245,7 @@ protected ArgumentClinicProvider getArgumentClinic() { static TruffleString format(Object self, TruffleString formatString, @Bind("this") Node inliningTarget, @Cached CastToJavaStringCheckedNode castToJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // We cannot cast self via argument clinic, because we need to keep it as-is for the // empty format string case, which should call __str__, which may be overridden String str = castToJavaStringNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___STR__, self); @@ -259,23 +259,23 @@ private static TruffleString formatString(Node raisingNode, Spec spec, String st return formatter.pad().getResult(); } - private static Spec getAndValidateSpec(Node inliningTarget, TruffleString formatString, PRaiseNode.Lazy raiseNode) { + private static Spec getAndValidateSpec(Node inliningTarget, TruffleString formatString, PRaiseNode raiseNode) { Spec spec = InternalFormat.fromText(formatString, 's', '<', inliningTarget); if (Spec.specified(spec.type) && spec.type != 's') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.UNKNOWN_FORMAT_CODE, spec.type, "str"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.UNKNOWN_FORMAT_CODE, spec.type, "str"); } if (Spec.specified(spec.sign)) { if (spec.sign == ' ') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SPACE_NOT_ALLOWED_IN_STRING_FORMAT_SPECIFIER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SPACE_NOT_ALLOWED_IN_STRING_FORMAT_SPECIFIER); } else { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SIGN_NOT_ALLOWED_FOR_STRING_FMT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SIGN_NOT_ALLOWED_FOR_STRING_FMT); } } if (spec.alternate) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.ALTERNATE_NOT_ALLOWED_WITH_STRING_FMT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ALTERNATE_NOT_ALLOWED_WITH_STRING_FMT); } if (Spec.specified(spec.align) && spec.align == '=') { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EQUALS_ALIGNMENT_FLAG_NOT_ALLOWED_FOR_STRING_FMT); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EQUALS_ALIGNMENT_FLAG_NOT_ALLOWED_FOR_STRING_FMT); } return spec; } @@ -296,7 +296,7 @@ static TruffleString format(VirtualFrame frame, Object self, Object[] args, PKey try { string = castToStringNode.execute(inliningTarget, self); } catch (CannotCastException e) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T_FORMAT, "str", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T_FORMAT, "str", self); } TemplateFormatter template = new TemplateFormatter(string); PythonContext context = PythonContext.get(inliningTarget); @@ -561,18 +561,18 @@ static TruffleString doSS(Object self, Object other, @Cached CastToTruffleStringNode castToStringLeftNode, @Cached CastToTruffleStringNode castToStringRightNode, @Shared @Cached TruffleString.ConcatNode concatNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString left; TruffleString right; try { left = castToStringLeftNode.execute(inliningTarget, self); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___ADD__, "str", self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___ADD__, "str", self); } try { right = castToStringRightNode.execute(inliningTarget, other); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "str", other, "str"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "str", other, "str"); } return doIt(left, right, concatNode); } @@ -956,7 +956,7 @@ static PDict doString(VirtualFrame frame, Object cls, Object from, Object to, Ob @Cached TruffleStringIterator.NextNode nextNode, @Cached InlinedConditionProfile hasZProfile, @Exclusive @Cached HashingStorageSetItem setHashingStorageItem, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TruffleString toStr = castToNode.cast(inliningTarget, to, ErrorMessages.ARG_S_MUST_BE_S_NOT_P, "2", "str", to); TruffleString fromStr = castFromNode.cast(inliningTarget, from, ErrorMessages.FIRST_MAKETRANS_ARGS_MUST_BE_A_STR); @@ -968,7 +968,7 @@ static PDict doString(VirtualFrame frame, Object cls, Object from, Object to, Ob int toLen = codePointLengthNode.execute(toStr, TS_ENCODING); int fromLen = codePointLengthNode.execute(fromStr, TS_ENCODING); if (toLen != fromLen) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.FIRST_TWO_MAKETRANS_ARGS_MUST_HAVE_EQ_LENGTH); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.FIRST_TWO_MAKETRANS_ARGS_MUST_HAVE_EQ_LENGTH); } HashingStorage storage = PDict.createNewStorage(fromLen); TruffleStringIterator fromIt = createCodePointIteratorNode.execute(fromStr, TS_ENCODING); @@ -1003,7 +1003,7 @@ static PDict doDict(VirtualFrame frame, Object cls, PDict from, Object to, Objec @Cached HashingStorageIteratorNext iterHasNext, @Cached HashingStorageIteratorKey iterKey, @Cached HashingStorageIteratorValue iterValue, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { HashingStorage srcStorage = from.getDictStorage(); HashingStorage destStorage = PDict.createNewStorage(lenNode.execute(inliningTarget, srcStorage)); HashingStorageIterator it = getIter.execute(inliningTarget, srcStorage); @@ -1015,7 +1015,7 @@ static PDict doDict(VirtualFrame frame, Object cls, PDict from, Object to, Objec } else { TruffleString strKey = cast.cast(inliningTarget, currentKey, ErrorMessages.KEYS_IN_TRANSLATE_TABLE_MUST_BE_STRINGS_OR_INTEGERS); if (codePointLengthNode.execute(strKey, TS_ENCODING) != 1) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.STRING_KEYS_MUST_BE_LENGTH_1); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.STRING_KEYS_MUST_BE_LENGTH_1); } int codePoint = codePointAtIndexNode.execute(strKey, 0, TS_ENCODING); destStorage = setHashingStorageItem.execute(frame, inliningTarget, destStorage, codePoint, currentValue); @@ -1027,8 +1027,8 @@ static PDict doDict(VirtualFrame frame, Object cls, PDict from, Object to, Objec @Specialization(guards = {"!isDict(from)", "isNoValue(to)"}) @SuppressWarnings("unused") static PDict doFail(Object cls, Object from, Object to, Object z, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.IF_YOU_GIVE_ONLY_ONE_ARG_TO_DICT); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.IF_YOU_GIVE_ONLY_ONE_ARG_TO_DICT); } } @@ -1150,11 +1150,11 @@ static PTuple doGeneric(Object self, Object sep, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfStringNode indexOfStringNode, @Cached TruffleString.SubstringNode substringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString selfStr = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "partition", self); TruffleString sepStr = castSepNode.cast(inliningTarget, sep, ErrorMessages.MUST_BE_STR_NOT_P, sep); if (sepStr.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_SEPARATOR); } int selfLen = codePointLengthNode.execute(selfStr, TS_ENCODING); int indexOf = indexOfStringNode.execute(selfStr, sepStr, 0, selfLen, TS_ENCODING); @@ -1186,11 +1186,11 @@ static Object doGeneric(Object self, Object sep, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.LastIndexOfStringNode lastIndexOfStringNode, @Cached TruffleString.SubstringNode substringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString selfStr = castSelfNode.cast(inliningTarget, self, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "rpartition", self); TruffleString sepStr = castSepNode.cast(inliningTarget, sep, ErrorMessages.MUST_BE_STR_NOT_P, sep); if (sepStr.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_SEPARATOR); } int selfLen = codePointLengthNode.execute(selfStr, TS_ENCODING); int lastIndexOf = lastIndexOfStringNode.execute(selfStr, sepStr, selfLen, 0, TS_ENCODING); @@ -1239,9 +1239,9 @@ static PList doStringSep(TruffleString self, TruffleString sep, int maxsplit, @Cached TruffleString.IndexOfStringNode indexOfStringNode, @Shared("substring") @Cached TruffleString.SubstringNode substringNode, @Shared("appendNode") @Cached AppendNode appendNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (sep.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_SEPARATOR); } int splits = maxsplit == -1 ? Integer.MAX_VALUE : maxsplit; @@ -1344,9 +1344,9 @@ static PList doStringSepMaxsplit(VirtualFrame frame, TruffleString self, Truffle @Shared("cpLen") @Cached CodePointLengthNode codePointLengthNode, @Cached TruffleString.LastIndexOfStringNode lastIndexOfStringNode, @Shared @Cached TruffleString.SubstringNode substringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (sep.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.EMPTY_SEPARATOR); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.EMPTY_SEPARATOR); } int maxsplit = maxsplitInput; if (maxsplitInput < 0) { @@ -1712,13 +1712,13 @@ static int index(Object selfObj, Object subObj, int start, int end, @Cached CastToTruffleStringCheckedNode castNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfStringNode indexOfStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString self = castNode.cast(inliningTarget, selfObj, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "index", selfObj); TruffleString sub = castNode.cast(inliningTarget, subObj, ErrorMessages.MUST_BE_STR_NOT_P, subObj); int idx = indexOf(self, sub, start, end, codePointLengthNode, indexOfStringNode); if (idx < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SUBSTRING_NOT_FOUND); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SUBSTRING_NOT_FOUND); } return idx; } @@ -1740,12 +1740,12 @@ static int rindex(Object selfObj, Object subObj, int start, int end, @Cached CastToTruffleStringCheckedNode castNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.LastIndexOfStringNode lastIndexOfStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString self = castNode.cast(inliningTarget, selfObj, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "rindex", selfObj); TruffleString sub = castNode.cast(inliningTarget, subObj, ErrorMessages.MUST_BE_STR_NOT_P, subObj); int idx = lastIndexOf(self, sub, start, end, codePointLengthNode, lastIndexOfStringNode); if (idx < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.SUBSTRING_NOT_FOUND); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.SUBSTRING_NOT_FOUND); } return idx; } @@ -1778,7 +1778,7 @@ static Object doIt(VirtualFrame frame, Object selfObj, TruffleString encoding, T @Cached CodecsModuleBuiltins.EncodeNode encodeNode, @Cached SequenceStorageNodes.CopyNode copyNode, @Cached InlinedBranchProfile convertByteArray, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString self = castSelfNode.cast(inliningTarget, selfObj, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, "index", selfObj); Object result = encodeNode.execute(frame, self, encoding, errors); if (!(result instanceof PBytes)) { @@ -1786,7 +1786,7 @@ static Object doIt(VirtualFrame frame, Object selfObj, TruffleString encoding, T convertByteArray.enter(inliningTarget); return PFactory.createBytes(PythonLanguage.get(inliningTarget), copyNode.execute(inliningTarget, ((PByteArray) result).getSequenceStorage())); } - throw raiseNode.get(inliningTarget).raise(TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, result); + throw raiseNode.raise(inliningTarget, TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, result); } return result; } @@ -2271,7 +2271,7 @@ TruffleString doIt(VirtualFrame frame, Object selfObj, Object width, Object fill @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Cached TruffleStringBuilder.ToStringNode toStringNode, @Cached InlinedConditionProfile errorProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString self = castSelfNode.cast(inliningTarget, selfObj, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___ITER__, selfObj); int fillChar; if (PGuards.isNoValue(fill)) { @@ -2279,7 +2279,7 @@ TruffleString doIt(VirtualFrame frame, Object selfObj, Object width, Object fill } else { TruffleString fillStr = castFillNode.cast(inliningTarget, fill, FILL_CHAR_MUST_BE_UNICODE_CHAR_NOT_P, fill); if (errorProfile.profile(inliningTarget, codePointLengthNode.execute(fillStr, TS_ENCODING) != 1)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.FILL_CHAR_MUST_BE_LENGTH_1); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.FILL_CHAR_MUST_BE_LENGTH_1); } fillChar = codePointAtIndexNode.execute(fillStr, 0, TS_ENCODING); } @@ -2436,7 +2436,7 @@ static TruffleString doString(VirtualFrame frame, Object self, Object idx, @Cached PyNumberAsSizeNode asSizeNode, @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.SubstringNode substringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString str = castToString.cast(inliningTarget, self, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T___GETITEM__, "str", self); int len = codePointLengthNode.execute(str, TS_ENCODING); int index; @@ -2444,7 +2444,7 @@ static TruffleString doString(VirtualFrame frame, Object self, Object idx, index = asSizeNode.executeExact(frame, inliningTarget, idx); } catch (PException e) { if (!indexCheckNode.execute(inliningTarget, idx)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.STRING_INDICES_MUST_BE_INTEGERS_NOT_P, idx); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.STRING_INDICES_MUST_BE_INTEGERS_NOT_P, idx); } throw e; } @@ -2452,7 +2452,7 @@ static TruffleString doString(VirtualFrame frame, Object self, Object idx, index += len; } if (index < 0 || index >= len) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } return substringNode.execute(str, index, 1, TS_ENCODING, false); } @@ -2624,11 +2624,11 @@ static long doGeneric(Object self, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode cast, @Shared("hashCode") @Cached TruffleString.HashCodeNode hashCodeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return doString(cast.execute(inliningTarget, self), hashCodeNode); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___HASH__, self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.REQUIRES_STR_OBJECT_BUT_RECEIVED_P, T___HASH__, self); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java index 0ec5dbffac..a9e71272bf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java @@ -194,7 +194,7 @@ static int doNativeObject(PythonNativeObject x, return intValue((Number) result); } // the object's type is not a subclass of 'str' - throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } @Specialization @@ -232,11 +232,11 @@ static String doConvert(TruffleString self, @SuppressWarnings("unused") TruffleS @Specialization(guards = "!isTruffleString(self)") static String doConvert(Node inliningTarget, Object self, TruffleString errMsgFormat, Object[] errMsgArgs, @Cached(inline = false) CastToJavaStringNode castToJavaStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return castToJavaStringNode.execute(self); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, errMsgFormat, errMsgArgs); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, errMsgFormat, errMsgArgs); } } } @@ -259,11 +259,11 @@ static TruffleString doTruffleString(TruffleString self, @SuppressWarnings("unus @Specialization(guards = "!isTruffleString(self)") static TruffleString doConvert(Node inliningTarget, Object self, TruffleString errMsgFormat, Object[] errMsgArgs, @Cached CastToTruffleStringNode castToTruffleStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return castToTruffleStringNode.execute(inliningTarget, self); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, errMsgFormat, errMsgArgs); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, errMsgFormat, errMsgArgs); } } } @@ -306,7 +306,7 @@ static TruffleString doPSequence(TruffleString self, PSequence sequence, @Cached InlinedConditionProfile isSingleItemProfile, @Cached SequenceStorageNodes.GetItemNode getItemNode, @Exclusive @Cached CastToTruffleStringNode castToStringNode, - @Exclusive @Cached PRaiseNode.Lazy raise, + @Exclusive @Cached PRaiseNode raise, @Shared @Cached TruffleStringBuilder.AppendStringNode appendStringNode, @Shared @Cached TruffleStringBuilder.ToStringNode toStringNode) { @@ -337,16 +337,16 @@ static TruffleString doPSequence(TruffleString self, PSequence sequence, } return toStringNode.execute(sb); } catch (OutOfMemoryError e) { - throw raise.get(inliningTarget).raise(MemoryError); + throw raise.raise(inliningTarget, MemoryError); } catch (CannotCastException e) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, INVALID_SEQ_ITEM, i, item); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, INVALID_SEQ_ITEM, i, item); } } @Specialization static TruffleString doGeneric(VirtualFrame frame, TruffleString string, Object iterable, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raise, + @Exclusive @Cached PRaiseNode raise, @Cached PyObjectGetIter getIter, @Cached GetNextNode nextNode, @Cached IsBuiltinObjectProfile errorProfile0, @@ -360,7 +360,7 @@ static TruffleString doGeneric(VirtualFrame frame, TruffleString string, Object iterator = getIter.execute(frame, inliningTarget, iterable); } catch (PException e) { e.expect(inliningTarget, PythonBuiltinClassType.TypeError, errorProfile0); - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_JOIN_ITERABLE); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_JOIN_ITERABLE); } try { TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); @@ -383,15 +383,15 @@ static TruffleString doGeneric(VirtualFrame frame, TruffleString string, Object appendStringNode.execute(sb, checkItem(inliningTarget, value, i++, castToStringNode, raise)); } } catch (OutOfMemoryError e) { - throw raise.get(inliningTarget).raise(MemoryError); + throw raise.raise(inliningTarget, MemoryError); } } - private static TruffleString checkItem(Node inliningTarget, Object item, int pos, CastToTruffleStringNode castNode, PRaiseNode.Lazy raise) { + private static TruffleString checkItem(Node inliningTarget, Object item, int pos, CastToTruffleStringNode castNode, PRaiseNode raise) { try { return castNode.execute(inliningTarget, item); } catch (CannotCastException e) { - throw raise.get(inliningTarget).raise(TypeError, INVALID_SEQ_ITEM, pos, item); + throw raise.raise(inliningTarget, TypeError, INVALID_SEQ_ITEM, pos, item); } } @@ -414,34 +414,37 @@ static void doNone(TruffleStringBuilder sb, PNone none) { @Specialization static void doInt(TruffleStringBuilder sb, int translated, + @Bind("this") Node inliningTarget, @Shared("raise") @Cached PRaiseNode raise, @Shared @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode) { if (Character.isValidCodePoint(translated)) { appendCodePointNode.execute(sb, translated, 1, true); } else { - throw raise.raise(ValueError, ErrorMessages.INVALID_UNICODE_CODE_POINT); + throw raise.raise(inliningTarget, ValueError, ErrorMessages.INVALID_UNICODE_CODE_POINT); } } @Specialization static void doLong(TruffleStringBuilder sb, long translated, + @Bind("this") Node inliningTarget, @Shared("raise") @Cached PRaiseNode raise, @Shared @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode) { try { - doInt(sb, PInt.intValueExact(translated), raise, appendCodePointNode); + doInt(sb, PInt.intValueExact(translated), inliningTarget, raise, appendCodePointNode); } catch (OverflowException e) { - throw raiseError(raise); + throw raiseError(inliningTarget, raise); } } @Specialization static void doPInt(TruffleStringBuilder sb, PInt translated, + @Bind("this") Node inliningTarget, @Shared("raise") @Cached PRaiseNode raise, @Shared @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode) { try { - doInt(sb, translated.intValueExact(), raise, appendCodePointNode); + doInt(sb, translated.intValueExact(), inliningTarget, raise, appendCodePointNode); } catch (OverflowException e) { - throw raiseError(raise); + throw raiseError(inliningTarget, raise); } } @@ -462,12 +465,12 @@ static void doObject(TruffleStringBuilder sb, Object translated, TruffleString translatedStr = castToStringNode.execute(inliningTarget, translated); doString(sb, translatedStr, appendStringNode); } catch (CannotCastException e) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_RETURN_INT_NONE_OR_STR); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CHARACTER_MAPPING_MUST_RETURN_INT_NONE_OR_STR); } } - private static PException raiseError(PRaiseNode raise) { - return raise.raise(ValueError, ErrorMessages.CHARACTER_MAPPING_MUST_BE_IN_RANGE, PInt.toHexString(Character.MAX_CODE_POINT + 1)); + private static PException raiseError(Node inliningTarget, PRaiseNode raise) { + return raise.raise(inliningTarget, ValueError, ErrorMessages.CHARACTER_MAPPING_MUST_BE_IN_RANGE, PInt.toHexString(Character.MAX_CODE_POINT + 1)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/TemplateFormatter.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/TemplateFormatter.java index f65ae7907b..644561c894 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/TemplateFormatter.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/TemplateFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -113,7 +113,7 @@ public TruffleString build(Node node, Object[] argsArg, Object kwArgs, FormatNod private TruffleString buildString(Node node, int start, int end, int level, FormatNode formatNode) { if (level == 0) { - throw PRaiseNode.raiseUncached(node, ValueError, RECURSION_DEPTH_EXCEEDED); + throw PRaiseNode.raiseStatic(node, ValueError, RECURSION_DEPTH_EXCEEDED); } return doBuildString(node, start, end, level - 1, this.template, formatNode); } @@ -131,14 +131,14 @@ private TruffleString doBuildString(Node node, int start, int end, int level, St boolean markupFollows = true; if (c == '}') { if (atEnd || s.charAt(i) != '}') { - throw PRaiseNode.raiseUncached(node, ValueError, SINGLE_RBRACE_ENCOUNTERED_IN_FORMAT_STRING); + throw PRaiseNode.raiseStatic(node, ValueError, SINGLE_RBRACE_ENCOUNTERED_IN_FORMAT_STRING); } i += 1; markupFollows = false; } if (c == '{') { if (atEnd) { - throw PRaiseNode.raiseUncached(node, ValueError, SINGLE_RBRACE_ENCOUNTERED_IN_FORMAT_STRING); + throw PRaiseNode.raiseStatic(node, ValueError, SINGLE_RBRACE_ENCOUNTERED_IN_FORMAT_STRING); } if (s.charAt(i) == '{') { i += 1; @@ -181,7 +181,7 @@ private TruffleString doBuildString(Node node, int start, int end, int level, St i += 1; } if (nested > 0) { - throw PRaiseNode.raiseUncached(node, ValueError, EXPECTED_RBRACE_BEFORE_END_OF_STRING); + throw PRaiseNode.raiseStatic(node, ValueError, EXPECTED_RBRACE_BEFORE_END_OF_STRING); } Object rendered = renderField(node, fieldStart, i, recursive, level, formatNode); out.append(rendered); @@ -217,13 +217,13 @@ private Field parseField(Node node, int start, int end) { if (c == '!') { i += 1; if (i == end) { - throw PRaiseNode.raiseUncached(node, ValueError, EXPECTED_CONVERSION); + throw PRaiseNode.raiseStatic(node, ValueError, EXPECTED_CONVERSION); } conversion = s.charAt(i); i += 1; if (i < end) { if (s.charAt(i) != ':') { - throw PRaiseNode.raiseUncached(node, ValueError, EXPECTED_S_AFTER_FORMAT_CONVERSION, ':'); + throw PRaiseNode.raiseStatic(node, ValueError, EXPECTED_S_AFTER_FORMAT_CONVERSION, ':'); } i += 1; } @@ -237,7 +237,7 @@ private Field parseField(Node node, int start, int end) { i += 1; } } else if (c == '{') { - throw PRaiseNode.raiseUncached(node, ValueError, UNEXPECTED_S_IN_FIELD_NAME, "'{'"); + throw PRaiseNode.raiseStatic(node, ValueError, UNEXPECTED_S_IN_FIELD_NAME, "'{'"); } i += 1; } @@ -274,10 +274,10 @@ private Object getArgument(Node node, String name) { if (useNumeric) { if (this.autoNumberingState == ANS_MANUAL) { if (isEmpty) { - throw PRaiseNode.raiseUncached(node, ValueError, SWITCHING_FROM_MANUAL_TO_AUTOMATIC_NUMBERING); + throw PRaiseNode.raiseStatic(node, ValueError, SWITCHING_FROM_MANUAL_TO_AUTOMATIC_NUMBERING); } } else if (!isEmpty) { - throw PRaiseNode.raiseUncached(node, ValueError, SWITCHING_FROM_AUTOMATIC_TO_MANUAL_NUMBERING); + throw PRaiseNode.raiseStatic(node, ValueError, SWITCHING_FROM_AUTOMATIC_TO_MANUAL_NUMBERING); } } if (isEmpty) { @@ -289,13 +289,13 @@ private Object getArgument(Node node, String name) { String kwarg = intString; arg = getKeyword(node, kwarg); } else if (index > SysModuleBuiltins.MAXSIZE) { - throw PRaiseNode.raiseUncached(node, ValueError, TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); + throw PRaiseNode.raiseStatic(node, ValueError, TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); } else { if (this.args == null) { - throw PRaiseNode.raiseUncached(node, ValueError, FORMAT_STR_CONTAINS_POS_FIELDS); + throw PRaiseNode.raiseStatic(node, ValueError, FORMAT_STR_CONTAINS_POS_FIELDS); } if (index >= this.args.length) { - throw PRaiseNode.raiseUncached(node, IndexError, REPLACEMENT_INDEX_S_OUT_OF_RANGE, index); + throw PRaiseNode.raiseStatic(node, IndexError, REPLACEMENT_INDEX_S_OUT_OF_RANGE, index); } arg = this.args[index]; } @@ -320,7 +320,7 @@ private Object resolveLookups(Node node, Object obj, String name, int startArg, i += 1; } if (start == i) { - throw PRaiseNode.raiseUncached(node, ValueError, EMPTY_ATTR_IN_FORMAT_STR); + throw PRaiseNode.raiseStatic(node, ValueError, EMPTY_ATTR_IN_FORMAT_STR); } TruffleString attr = toTruffleStringUncached(name.substring(start, i)); if (result != null) { @@ -341,11 +341,11 @@ private Object resolveLookups(Node node, Object obj, String name, int startArg, i += 1; } if (!gotBracket) { - throw PRaiseNode.raiseUncached(node, ValueError, MISSING_S, "']'"); + throw PRaiseNode.raiseStatic(node, ValueError, MISSING_S, "']'"); } String s = name.substring(start, i); if (s.isEmpty()) { - throw PRaiseNode.raiseUncached(node, ValueError, EMPTY_ATTR_IN_FORMAT_STR); + throw PRaiseNode.raiseStatic(node, ValueError, EMPTY_ATTR_IN_FORMAT_STR); } int index = toInt(node, s); Object item = index != -1 ? index : toTruffleStringUncached(s); @@ -356,7 +356,7 @@ private Object resolveLookups(Node node, Object obj, String name, int startArg, this.parserList.add(new Object[]{false, item}); } } else { - throw PRaiseNode.raiseUncached(node, ValueError, ONLY_S_AND_S_AMY_FOLLOW_S, "'['", "'.'", "']'"); + throw PRaiseNode.raiseStatic(node, ValueError, ONLY_S_AND_S_AMY_FOLLOW_S, "'['", "'.'", "']'"); } } return result; @@ -372,7 +372,7 @@ private static int toInt(Node node, String s) { } catch (NumberFormatException e) { return -1; } catch (ArithmeticException e) { - throw PRaiseNode.raiseUncached(node, ValueError, TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); + throw PRaiseNode.raiseStatic(node, ValueError, TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); } } @@ -462,7 +462,7 @@ private static Object convert(Node node, Object obj, char conversion) { case 'a': return PyObjectAsciiNode.executeUncached(obj); default: - throw PRaiseNode.raiseUncached(node, ValueError, INVALID_CONVERSION); + throw PRaiseNode.raiseStatic(node, ValueError, INVALID_CONVERSION); } } @@ -491,7 +491,7 @@ private Object getKeyword(Node node, String key) { return result; } } - throw PRaiseNode.raiseUncached(node, KeyError, tKey); + throw PRaiseNode.raiseStatic(node, KeyError, tKey); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java index 6a423b6eeb..48cb26dc28 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructBuiltins.java @@ -101,14 +101,16 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, } @Specialization - Object pack(VirtualFrame frame, PStruct self, Object[] args, PKeyword[] keywords, + static Object pack(VirtualFrame frame, PStruct self, Object[] args, PKeyword[] keywords, + @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Cached StructNodes.PackValueNode packValueNode) { + @Cached StructNodes.PackValueNode packValueNode, + @Cached PRaiseNode raiseNode) { if (keywords.length != 0) { - throw raise(TypeError, S_TAKES_NO_KEYWORD_ARGS, "pack()"); + throw raiseNode.raise(inliningTarget, TypeError, S_TAKES_NO_KEYWORD_ARGS, "pack()"); } if (args.length != self.getLen()) { - throw raise(StructError, STRUCT_PACK_EXPECTED_N_ITEMS_GOT_K, self.getLen(), args.length); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_PACK_EXPECTED_N_ITEMS_GOT_K, self.getLen(), args.length); } byte[] bytes = new byte[self.getSize()]; packInternal(frame, self, packValueNode, args, bytes, 0); @@ -134,11 +136,11 @@ static Object packInto(VirtualFrame frame, PStruct self, Object buffer, int offs @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Cached StructNodes.PackValueNode packValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { final long size = self.getUnsignedSize(); if (args.length != self.getLen()) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_PACK_EXPECTED_N_ITEMS_GOT_K, size, args.length); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_PACK_EXPECTED_N_ITEMS_GOT_K, size, args.length); } int bufferOffset = offset; int bufferLen = bufferLib.getBufferLength(buffer); @@ -154,12 +156,12 @@ static Object packInto(VirtualFrame frame, PStruct self, Object buffer, int offs if (bufferOffset < 0) { // Check that negative offset is low enough to fit data if (bufferOffset + size > 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_NO_SPACE_TO_PACK_N_BYTES, size, bufferOffset); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_NO_SPACE_TO_PACK_N_BYTES, size, bufferOffset); } // Check that negative offset is not crossing buffer boundary if (bufferOffset + bufferLen < 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_OFFSET_OUT_OF_RANGE, bufferOffset, bufferLen); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_OFFSET_OUT_OF_RANGE, bufferOffset, bufferLen); } bufferOffset += bufferLen; @@ -170,7 +172,7 @@ static Object packInto(VirtualFrame frame, PStruct self, Object buffer, int offs assert bufferOffset >= 0; assert size >= 0; - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_PACK_INTO_REQ_BUFFER_TO_PACK, size + bufferOffset, size, bufferOffset, bufferLen); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_PACK_INTO_REQ_BUFFER_TO_PACK, size + bufferOffset, size, bufferOffset, bufferLen); } // TODO: GR-54860 use buffer API in the packing process @@ -208,12 +210,12 @@ static Object unpack(VirtualFrame frame, PStruct self, Object buffer, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Cached StructNodes.UnpackValueNode unpackValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int bytesLen = bufferLib.getBufferLength(buffer); byte[] bytes = bufferLib.getInternalOrCopiedByteArray(buffer); if (bytesLen != self.getSize()) { - throw raiseNode.get(inliningTarget).raise(StructError, UNPACK_REQ_A_BUFFER_OF_N_BYTES, self.getSize()); + throw raiseNode.raise(inliningTarget, StructError, UNPACK_REQ_A_BUFFER_OF_N_BYTES, self.getSize()); } return PFactory.createTuple(language, unpackInternal(self, unpackValueNode, bytes, 0)); } finally { @@ -239,14 +241,14 @@ static Object iterUnpack(VirtualFrame frame, PStruct self, Object buffer, @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { if (self.getSize() == 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_ITER_CANNOT_UNPACK_FROM_STRUCT_OF_SIZE_0); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_ITER_CANNOT_UNPACK_FROM_STRUCT_OF_SIZE_0); } int bufferLen = bufferLib.getBufferLength(buffer); if (bufferLen % self.getSize() != 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_ITER_UNPACK_REQ_A_BUFFER_OF_A_MUL_OF_BYTES, self.getSize()); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_ITER_UNPACK_REQ_A_BUFFER_OF_A_MUL_OF_BYTES, self.getSize()); } } catch (Exception e) { bufferLib.release(buffer, frame, indirectCallData); @@ -279,7 +281,7 @@ static Object unpackFrom(VirtualFrame frame, PStruct self, Object buffer, int of @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib, @Cached StructNodes.UnpackValueNode unpackValueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { int bufferOffset = offset; int bytesLen = bufferLib.getBufferLength(buffer); @@ -288,17 +290,17 @@ static Object unpackFrom(VirtualFrame frame, PStruct self, Object buffer, int of final long size = self.getUnsignedSize(); if (bufferOffset < 0) { if (bufferOffset + size > 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_NOT_ENOUGH_DATA_TO_UNPACK_N_BYTES, size, bufferOffset); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_NOT_ENOUGH_DATA_TO_UNPACK_N_BYTES, size, bufferOffset); } if (bufferOffset + bytesLen < 0) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_OFFSET_OUT_OF_RANGE, bufferOffset, bytesLen); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_OFFSET_OUT_OF_RANGE, bufferOffset, bytesLen); } bufferOffset += bytesLen; } if ((bytesLen - bufferOffset) < size) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_UNPACK_FROM_REQ_AT_LEAST_N_BYTES, size + bufferOffset, size, bufferOffset, bytesLen); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_UNPACK_FROM_REQ_AT_LEAST_N_BYTES, size + bufferOffset, size, bufferOffset, bytesLen); } return PFactory.createTuple(language, unpackInternal(self, unpackValueNode, bytes, bufferOffset)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java index 50a43415f6..ad5ddd92f6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructNodes.java @@ -82,13 +82,13 @@ static long get(VirtualFrame frame, Object value, boolean unsigned, @Cached PyLongCheckNode pyLongCheckNode, @Cached PyNumberIndexNode indexNode, @Cached PyLongAsLongNode pyLongAsLongNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object longValue; if (!pyLongCheckNode.execute(inliningTarget, value)) { if (indexCheckNode.execute(inliningTarget, value)) { longValue = indexNode.execute(frame, inliningTarget, value); } else { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_NOT_T, "an integer"); + throw raiseNode.raise(inliningTarget, StructError, ARG_NOT_T, "an integer"); } } else { longValue = value; @@ -99,10 +99,10 @@ static long get(VirtualFrame frame, Object value, boolean unsigned, x = pyLongAsLongNode.execute(frame, inliningTarget, longValue); } catch (PException pe) { pe.expect(inliningTarget, PythonBuiltinClassType.OverflowError, errorProfile); - throw raiseNode.get(inliningTarget).raise(StructError, ARG_O_O_RANGE); + throw raiseNode.raise(inliningTarget, StructError, ARG_O_O_RANGE); } if (unsigned && x < 0) { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_O_O_RANGE); + throw raiseNode.raise(inliningTarget, StructError, ARG_O_O_RANGE); } return x; } @@ -159,30 +159,30 @@ public static boolean isSupportedFormat(FormatCode formatCode) { } // checks - private static PException raiseNumberError(FormatCode formatCode, PRaiseNode raiseNode) { + private static PException raiseNumberError(Node inliningTarget, FormatCode formatCode, PRaiseNode raiseNode) { if (formatCode.formatDef.name == null) { - return raiseNode.raise(StructError, ARG_O_O_RANGE); + return raiseNode.raise(inliningTarget, StructError, ARG_O_O_RANGE); } - return raiseNode.raise(StructError, FMT_REQ_RANGE, formatCode.formatDef.name, formatCode.formatDef.min, formatCode.formatDef.max); + return raiseNode.raise(inliningTarget, StructError, FMT_REQ_RANGE, formatCode.formatDef.name, formatCode.formatDef.min, formatCode.formatDef.max); } private static PException raiseNumberErrorUncached(Node raisingNode, FormatCode formatCode) { if (formatCode.formatDef.name == null) { - return PRaiseNode.raiseUncached(raisingNode, StructError, ARG_O_O_RANGE); + return PRaiseNode.raiseStatic(raisingNode, StructError, ARG_O_O_RANGE); } - return PRaiseNode.raiseUncached(raisingNode, StructError, FMT_REQ_RANGE, formatCode.formatDef.name, formatCode.formatDef.min, formatCode.formatDef.max); + return PRaiseNode.raiseStatic(raisingNode, StructError, FMT_REQ_RANGE, formatCode.formatDef.name, formatCode.formatDef.min, formatCode.formatDef.max); } - public static long checkLong(Node inliningTarget, FormatCode formatCode, long value, PRaiseNode.Lazy raiseNode) { + public static long checkLong(Node inliningTarget, FormatCode formatCode, long value, PRaiseNode raiseNode) { if (value < formatCode.formatDef.min || value > formatCode.formatDef.max) { - throw raiseNumberError(formatCode, raiseNode.get(inliningTarget)); + throw raiseNumberError(inliningTarget, formatCode, raiseNode); } return value; } - public static long checkLongUnsigned(Node inliningTarget, FormatCode formatCode, long value, PRaiseNode.Lazy raiseNode) { + public static long checkLongUnsigned(Node inliningTarget, FormatCode formatCode, long value, PRaiseNode raiseNode) { if (value < formatCode.formatDef.min || Long.compareUnsigned(value, formatCode.formatDef.max) > 0) { - throw raiseNumberError(formatCode, raiseNode.get(inliningTarget)); + throw raiseNumberError(inliningTarget, formatCode, raiseNode); } return value; } @@ -222,7 +222,7 @@ public abstract static class PackValueNode extends StructBaseNode { public abstract void execute(VirtualFrame frame, FormatCode formatCode, FormatAlignment formatAlignment, Object value, byte[] buffer, int offset); private static void packLongInternal(Node inliningTarget, FormatCode formatCode, long value, byte[] buffer, int offset, NumericSupport numericSupport, int numBytes, - InlinedConditionProfile profileSigned, PRaiseNode.Lazy raiseNode) { + InlinedConditionProfile profileSigned, PRaiseNode raiseNode) { final long num; if (profileSigned.profile(inliningTarget, formatCode.isUnsigned())) { num = checkLongUnsigned(inliningTarget, formatCode, value, raiseNode); @@ -237,7 +237,7 @@ static void packLong(FormatCode formatCode, @SuppressWarnings("unused") FormatAl @Bind("this") Node inliningTarget, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, @Shared @Cached InlinedConditionProfile profileSigned, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { packLongInternal(inliningTarget, formatCode, value, buffer, offset, numericSupport, formatCode.numBytes(), profileSigned, raiseNode); } @@ -246,7 +246,7 @@ static void packInt(FormatCode formatCode, @SuppressWarnings("unused") FormatAli @Bind("this") Node inliningTarget, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, @Shared @Cached InlinedConditionProfile profileSigned, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { packLongInternal(inliningTarget, formatCode, value, buffer, offset, numericSupport, formatCode.numBytes(), profileSigned, raiseNode); } @@ -255,12 +255,12 @@ static void packPInt(FormatCode formatCode, @SuppressWarnings("unused") FormatAl @Bind("this") Node inliningTarget, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, @Shared @Cached CastToJavaBigIntegerNode toJavaBigIntegerNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { BigInteger num = checkBigInt(inliningTarget, formatCode, toJavaBigIntegerNode.execute(inliningTarget, value)); numericSupport.putBigInteger(buffer, offset, num, formatCode.numBytes()); } catch (OverflowException oe) { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_O_O_RANGE); + throw raiseNode.raise(inliningTarget, StructError, ARG_O_O_RANGE); } } @@ -268,7 +268,7 @@ static void packPInt(FormatCode formatCode, @SuppressWarnings("unused") FormatAl static void packFloat(FormatCode formatCode, @SuppressWarnings("unused") FormatAlignment formatAlignment, double value, byte[] buffer, int offset, @Bind("this") Node inliningTarget, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { numericSupport.putDouble(inliningTarget, buffer, offset, value, formatCode.numBytes(), raiseNode); } @@ -276,7 +276,7 @@ static void packFloat(FormatCode formatCode, @SuppressWarnings("unused") FormatA static void packPFloat(FormatCode formatCode, FormatAlignment formatAlignment, PFloat value, byte[] buffer, int offset, @Bind("this") Node inliningTarget, @Cached("getNumericSupport(formatAlignment)") NumericSupport numericSupport, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { packFloat(formatCode, formatAlignment, value.getValue(), buffer, offset, inliningTarget, numericSupport, raiseNode); } @@ -291,13 +291,13 @@ static void packBytes(FormatCode formatCode, @SuppressWarnings("unused") FormatA @Bind("this") Node inliningTarget, @Shared @Cached("createEqualityProfile()") PrimitiveValueProfile formatProfile, @CachedLibrary("value") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { int n = bufferLib.getBufferLength(value); switch (formatProfile.profile(formatCode.formatDef.format)) { case FMT_CHAR: if (n != 1) { - throw raiseNode.get(inliningTarget).raise(StructError, STRUCT_CHR_FMT_BYTES_1); + throw raiseNode.raise(inliningTarget, StructError, STRUCT_CHR_FMT_BYTES_1); } assert n <= buffer.length - offset; bufferLib.readIntoByteArray(value, 0, buffer, offset, n); @@ -340,7 +340,7 @@ static void packObjectCached(VirtualFrame frame, FormatCode formatCode, FormatAl @Shared @Cached InlinedConditionProfile profileSigned, @Shared @Cached IsBuiltinObjectProfile errorProfile, @Shared @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { if (isNumberUpToSize8Unsigned(formatCode)) { packLong(formatCode, formatAlignment, getLongNode.execute(frame, value, formatCode.isUnsigned()), buffer, offset, inliningTarget, numericSupport, profileSigned, raiseNode); } else if (isNumberSize8Unsigned(formatCode)) { @@ -351,15 +351,15 @@ static void packObjectCached(VirtualFrame frame, FormatCode formatCode, FormatAl BigInteger num = checkBigInt(inliningTarget, formatCode, toJavaBigIntegerNode.execute(inliningTarget, value)); getNumericSupport(formatAlignment).putBigInteger(buffer, offset, num, formatCode.numBytes()); } catch (OverflowException oe) { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_O_O_RANGE); + throw raiseNode.raise(inliningTarget, StructError, ARG_O_O_RANGE); } catch (PException pe) { pe.expect(inliningTarget, PythonBuiltinClassType.TypeError, errorProfile); - throw raiseNode.get(inliningTarget).raise(StructError, ARG_NOT_T, "an integer"); + throw raiseNode.raise(inliningTarget, StructError, ARG_NOT_T, "an integer"); } } } else if (isFmtFloat(formatCode)) { if (!canBeDoubleNode.execute(inliningTarget, value)) { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_NOT_T, "a float"); + throw raiseNode.raise(inliningTarget, StructError, ARG_NOT_T, "a float"); } packFloat(formatCode, formatAlignment, asDoubleNode.execute(frame, inliningTarget, value), buffer, offset, inliningTarget, numericSupport, raiseNode); } else if (isFmtVoidPtr(formatCode)) { @@ -369,11 +369,11 @@ static void packObjectCached(VirtualFrame frame, FormatCode formatCode, FormatAl packBoolean(formatCode, formatAlignment, isTrueNode.execute(frame, value), buffer, offset); } else if (isFmtBytes(formatCode)) { if (!isBytes(value)) { - throw raiseNode.get(inliningTarget).raise(StructError, ARG_FOR_N_MUST_BE, formatCode.formatDef.format, "bytes"); + throw raiseNode.raise(inliningTarget, StructError, ARG_FOR_N_MUST_BE, formatCode.formatDef.format, "bytes"); } packBytes(formatCode, formatAlignment, (PBytesLike) value, buffer, offset, inliningTarget, formatProfile, bufferLib, raiseNode); } else { - throw raiseNode.get(inliningTarget).raise(NotImplementedError, STRUCT_FMT_NOT_YET_SUPPORTED, formatCode); + throw raiseNode.raise(inliningTarget, NotImplementedError, STRUCT_FMT_NOT_YET_SUPPORTED, formatCode); } } @@ -389,7 +389,7 @@ static void packObject(VirtualFrame frame, FormatCode formatCode, FormatAlignmen @Shared @Cached InlinedConditionProfile profileSigned, @Shared @Cached IsBuiltinObjectProfile errorProfile, @Shared @CachedLibrary(limit = "2") PythonBufferAccessLibrary bufferLib, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { packObjectCached(frame, formatCode, formatAlignment, value, buffer, offset, inliningTarget, getLongNode, toJavaBigIntegerNode, canBeDoubleNode, asDoubleNode, isTrueNode, getNumericSupport(formatAlignment), formatProfile, profileSigned, errorProfile, bufferLib, raiseNode); @@ -440,8 +440,7 @@ static Object unpackFloat8(FormatCode formatCode, @SuppressWarnings("unused") Fo @SuppressWarnings("unused") static Object unpackVoidPtr(FormatCode formatCode, FormatAlignment formatAlignment, byte[] buffer, int offset, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedConditionProfile profilePIntResult, - @Shared @Cached PRaiseNode raiseNode) { + @Shared @Cached InlinedConditionProfile profilePIntResult) { long num = getNumericSupport(formatAlignment).getLongUnsigned(buffer, offset, formatCode.numBytes()); if (profilePIntResult.profile(inliningTarget, num < 0)) { return PFactory.createInt(PythonLanguage.get(inliningTarget), getAsUnsignedBigInt(num)); @@ -482,8 +481,8 @@ static Object unpackBytes(@SuppressWarnings("unused") FormatCode formatCode, @Su @Specialization(guards = "!isSupportedFormat(formatCode)") @SuppressWarnings("unused") static byte[] unpackUnsupported(FormatCode formatCode, FormatAlignment formatAlignment, byte[] buffer, int offset, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(NotImplementedError, STRUCT_FMT_NOT_YET_SUPPORTED, formatCode); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, STRUCT_FMT_NOT_YET_SUPPORTED, formatCode); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java index b0718e01fa..d0ab50aa91 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java @@ -49,8 +49,8 @@ protected List> getNodeFa protected abstract static class NewNode extends PythonBuiltinNode { @Specialization static Object createNew(Object type, @SuppressWarnings("unused") Object[] args, @SuppressWarnings("unused") PKeyword[] kwds, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, CANNOT_CREATE_P_OBJECTS, type); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, CANNOT_CREATE_P_OBJECTS, type); } } @@ -82,8 +82,8 @@ static int lenHint(PStructUnpackIterator self, public abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.isExhausted()") static Object nextExhausted(@SuppressWarnings("unused") PStructUnpackIterator self, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.StopIteration); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration); } @Specialization(guards = "!self.isExhausted()", limit = "3") @@ -93,7 +93,7 @@ static Object next(VirtualFrame frame, PStructUnpackIterator self, @Cached StructNodes.UnpackValueNode unpackValueNode, @CachedLibrary("self.getBuffer()") PythonBufferAccessLibrary bufferLib, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final PStruct struct = self.getStruct(); final Object buffer = self.getBuffer(); final int bufferLen = bufferLib.getBufferLength(buffer); @@ -101,7 +101,7 @@ static Object next(VirtualFrame frame, PStructUnpackIterator self, if (struct == null || self.index >= bufferLen) { self.setExhausted(); bufferLib.release(buffer, frame, indirectCallData); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.StopIteration); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } assert self.index + struct.getSize() <= bufferLen; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java index da6208bc58..f54b1c517f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java @@ -85,6 +85,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PNodeWithContext; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.SpecialAttributeNames; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; import com.oracle.graal.python.nodes.bytecode.FrameInfo; @@ -117,6 +118,7 @@ import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -201,11 +203,13 @@ public abstract static class SuperInitNode extends PythonVarargsBuiltinNode { @Child private GetClassNode getClassNode; @Child private PyObjectLookupAttr getAttrNode; @Child private TypeNodes.IsTypeNode isTypeNode; + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { if (keywords.length != 0) { - throw raise(RuntimeError, ErrorMessages.UNEXPECTED_KEYWORD_ARGS, "super()"); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.UNEXPECTED_KEYWORD_ARGS, "super()"); } if (arguments.length == 1) { return execute(frame, arguments[0], PNone.NO_VALUE, PNone.NO_VALUE); @@ -214,14 +218,16 @@ public Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused") Obje } else if (arguments.length == 3) { return execute(frame, arguments[0], arguments[1], arguments[2]); } else { - throw raise(RuntimeError, ErrorMessages.INVALID_NUMBER_OF_ARGUMENTS, "super()"); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.INVALID_NUMBER_OF_ARGUMENTS, "super()"); } } @Override public final Object execute(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords) { if (keywords.length != 0) { - throw raise(RuntimeError, ErrorMessages.UNEXPECTED_KEYWORD_ARGS, "super()"); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.UNEXPECTED_KEYWORD_ARGS, "super()"); } if (arguments.length == 0) { return execute(frame, self, PNone.NO_VALUE, PNone.NO_VALUE); @@ -230,16 +236,19 @@ public final Object execute(VirtualFrame frame, Object self, Object[] arguments, } else if (arguments.length == 2) { return execute(frame, self, arguments[0], arguments[1]); } else { - throw raise(RuntimeError, ErrorMessages.TOO_MANY_ARG, "super()"); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.TOO_MANY_ARG, "super()"); } } protected abstract Object execute(VirtualFrame frame, Object self, Object cls, Object obj); @Specialization(guards = "!isNoValue(cls)") - PNone init(VirtualFrame frame, SuperObject self, Object cls, Object obj) { + PNone init(VirtualFrame frame, SuperObject self, Object cls, Object obj, + @Bind("this") Node inliningTarget, + @Cached PRaiseNode raiseNode) { if (!(obj instanceof PNone)) { - Object type = supercheck(frame, cls, obj); + Object type = supercheck(frame, inliningTarget, cls, obj, raiseNode); self.init(cls, type, obj); } else { self.init(cls, null, null); @@ -258,13 +267,14 @@ protected boolean isInBuiltinFunctionRoot() { @Specialization(guards = {"!isInBuiltinFunctionRoot()", "isNoValue(clsArg)", "isNoValue(objArg)"}) PNone initInPlace(VirtualFrame frame, SuperObject self, @SuppressWarnings("unused") PNone clsArg, @SuppressWarnings("unused") PNone objArg, @Bind("this") Node inliningTarget, + @Shared @Cached PRaiseNode raiseNode, @Shared @Cached CellBuiltins.GetRefNode getRefNode) { PBytecodeRootNode rootNode = (PBytecodeRootNode) getRootNode(); Frame localFrame = frame; if (rootNode.getCodeUnit().isGeneratorOrCoroutine()) { localFrame = PArguments.getGeneratorFrame(frame); } - return initFromLocalFrame(frame, inliningTarget, self, rootNode, localFrame, getRefNode); + return initFromLocalFrame(frame, inliningTarget, self, rootNode, localFrame, getRefNode, raiseNode); } /** @@ -273,41 +283,43 @@ PNone initInPlace(VirtualFrame frame, SuperObject self, @SuppressWarnings("unuse @Specialization(guards = {"isInBuiltinFunctionRoot()", "isNoValue(clsArg)", "isNoValue(objArg)"}) PNone init(VirtualFrame frame, SuperObject self, @SuppressWarnings("unused") PNone clsArg, @SuppressWarnings("unused") PNone objArg, @Bind("this") Node inliningTarget, + @Shared @Cached PRaiseNode raiseNode, @Cached ReadCallerFrameNode readCaller, @Shared @Cached CellBuiltins.GetRefNode getRefNode) { PFrame target = readCaller.executeWith(frame, FrameSelector.SKIP_PYTHON_BUILTIN, 0); if (target == null) { - throw raise(RuntimeError, ErrorMessages.NO_CURRENT_FRAME, "super()"); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.NO_CURRENT_FRAME, "super()"); } MaterializedFrame locals = target.getLocals(); if (locals == null) { - throw raise(RuntimeError, ErrorMessages.SUPER_NO_CLASS); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_NO_CLASS); } FrameInfo frameInfo = (FrameInfo) locals.getFrameDescriptor().getInfo(); - return initFromLocalFrame(frame, inliningTarget, self, frameInfo.getRootNode(), locals, getRefNode); + return initFromLocalFrame(frame, inliningTarget, self, frameInfo.getRootNode(), locals, getRefNode, raiseNode); } - private PNone initFromLocalFrame(VirtualFrame frame, Node inliningTarget, SuperObject self, PBytecodeRootNode rootNode, Frame localFrame, CellBuiltins.GetRefNode getRefNode) { + private PNone initFromLocalFrame(VirtualFrame frame, Node inliningTarget, SuperObject self, PBytecodeRootNode rootNode, Frame localFrame, CellBuiltins.GetRefNode getRefNode, + PRaiseNode raiseNode) { PCell classCell = rootNode.readClassCell(localFrame); if (classCell == null) { - throw raise(RuntimeError, ErrorMessages.SUPER_NO_CLASS); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_NO_CLASS); } Object cls = getRefNode.execute(inliningTarget, classCell); if (cls == null) { // the cell is empty - throw raise(RuntimeError, ErrorMessages.SUPER_EMPTY_CLASS); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_EMPTY_CLASS); } Object obj = rootNode.readSelf(localFrame); if (obj == null) { - throw raise(RuntimeError, ErrorMessages.NO_ARGS, "super()"); + throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.NO_ARGS, "super()"); } - return init(frame, self, cls, obj); + return init(frame, self, cls, obj, inliningTarget, raiseNode); } @SuppressWarnings("unused") @Fallback PNone initFallback(Object self, Object cls, Object obj) { - throw raise(RuntimeError, ErrorMessages.INVALID_ARGS, "super()"); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.INVALID_ARGS, "super()"); } private IsSubtypeNode getIsSubtype() { @@ -342,7 +354,7 @@ private PyObjectLookupAttr getGetAttr() { return getAttrNode; } - private Object supercheck(VirtualFrame frame, Object cls, Object object) { + private Object supercheck(VirtualFrame frame, Node inliningTarget, Object cls, Object object, PRaiseNode raiseNode) { /* * Check that a super() call makes sense. Return a type object. * @@ -379,7 +391,7 @@ private Object supercheck(VirtualFrame frame, Object cls, Object object) { // error is ignored } - throw raise(PythonErrorType.TypeError, ErrorMessages.SUPER_OBJ_MUST_BE_INST_SUB_OR_TYPE); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.SUPER_OBJ_MUST_BE_INST_SUB_OR_TYPE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java index 41c435b6b4..339f1d6a72 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/LockBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -152,22 +152,22 @@ boolean acTimeOut(AbstractPythonLock self, @SuppressWarnings("unused") boolean b @SuppressWarnings("unused") @Specialization(guards = {"invalidArgs(blocking, timeout)", "timeout != UNSET_TIMEOUT", "!blocking"}) static boolean err1(AbstractPythonLock self, boolean blocking, double timeout, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.CANT_SPECIFY_TIMEOUT_FOR_NONBLOCKING); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.CANT_SPECIFY_TIMEOUT_FOR_NONBLOCKING); } @SuppressWarnings("unused") @Specialization(guards = {"invalidArgs(blocking, timeout)", "timeout != UNSET_TIMEOUT", "isNeg(timeout)"}) static boolean err2(AbstractPythonLock self, boolean blocking, double timeout, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(ValueError, ErrorMessages.TIMEOUT_VALUE_MUST_BE_POSITIVE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.TIMEOUT_VALUE_MUST_BE_POSITIVE); } @SuppressWarnings("unused") @Specialization(guards = {"invalidArgs(blocking, timeout)", "timeout != UNSET_TIMEOUT", "timeout > TIMEOUT_MAX"}) static boolean err3(AbstractPythonLock self, boolean blocking, double timeout, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(OverflowError, ErrorMessages.TIMEOUT_VALUE_TOO_LARGE); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, OverflowError, ErrorMessages.TIMEOUT_VALUE_TOO_LARGE); } protected static boolean invalidArgs(boolean blocking, double timeout) { @@ -211,9 +211,9 @@ static Object doRelease(PLock self) { @Specialization static Object doRelease(PRLock self, @Bind("this") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!self.isOwned()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.LOCK_NOT_HELD); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.LOCK_NOT_HELD); } self.release(); return PNone.NONE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java index 3a200275b3..fdbbdca3a7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/RLockBuiltins.java @@ -123,10 +123,10 @@ static Object releaseSave(PRLock self, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile countProfile, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int count = self.getCount(); if (countProfile.profile(inliningTarget, count == 0)) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.RuntimeError, ErrorMessages.CANNOT_RELEASE_UNAQUIRED_LOCK); + throw raiseNode.raise(inliningTarget, PythonErrorType.RuntimeError, ErrorMessages.CANNOT_RELEASE_UNAQUIRED_LOCK); } PTuple retVal = PFactory.createTuple(language, new Object[]{count, self.getOwnerId()}); self.releaseAll(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalBuiltins.java index 947e2607c1..f1f6562e1c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/ThreadLocalBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -133,14 +133,14 @@ Object doIt(VirtualFrame frame, PThreadLocal object, Object keyObj, @Cached InlinedConditionProfile hasDescrProfile, @Cached InlinedConditionProfile hasDescrGetProfile, @Cached InlinedConditionProfile hasValueProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // Note: getting thread local dict has potential side-effects, don't move PDict localDict = getThreadLocalDict.execute(frame, object); TruffleString key; try { key = castKeyToStringNode.execute(inliningTarget, keyObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); } Object type = getClassNode.execute(inliningTarget, object); @@ -167,7 +167,7 @@ Object doIt(VirtualFrame frame, PThreadLocal object, Object keyObj, return dispatch(frame, object, type, descr, descrGetSlot); } } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } private Object dispatch(VirtualFrame frame, Object object, Object type, Object descr, TpSlot get) { @@ -199,7 +199,7 @@ static void doGeneric(VirtualFrame frame, PThreadLocal object, Object keyObject, @Bind("this") Node inliningTarget, @Exclusive @Cached ThreadLocalNodes.GetThreadLocalDict getThreadLocalDict, @Cached CastToTruffleStringNode castKeyToStringNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached GenericSetAttrWithDictNode setAttrWithDictNode) { // Note: getting thread local dict has potential side-effects, don't move PDict localDict = getThreadLocalDict.execute(frame, object); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java index 36bba4c914..a1ea04b3fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java @@ -94,10 +94,10 @@ static PTuple next(PTokenizerIter self, @Bind("this") Node inliningTarget, @Cached TruffleString.FromJavaStringNode fromJavaStringNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Token token = self.getNextToken(); if (token.type == Kind.ERRORTOKEN || token.type == Kind.ENDMARKER) { - throw raiseNode.get(inliningTarget).raiseStopIteration(T_EOF); + throw raiseNode.raiseStopIteration(inliningTarget, T_EOF); } int startColumn; int endColumn; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java index f847f3408c..634fe02311 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java @@ -272,12 +272,12 @@ static Object set(PTraceback self, PTraceback next, @Bind("this") Node inliningTarget, @Cached InlinedLoopConditionProfile loopProfile, @Exclusive @Cached MaterializeTruffleStacktraceNode materializeTruffleStacktraceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { // Check for loops PTraceback tb = next; while (loopProfile.profile(inliningTarget, tb != null)) { if (tb == self) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.TRACEBACK_LOOP_DETECTED); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TRACEBACK_LOOP_DETECTED); } tb = tb.getNext(); } @@ -301,8 +301,8 @@ static Object clear(PTraceback self, @SuppressWarnings("unused") PNone next, @Specialization(guards = {"!isPNone(next)", "!isPTraceback(next)"}) static Object setError(@SuppressWarnings("unused") PTraceback self, Object next, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.EXPECTED_TRACEBACK_OBJ, next); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.EXPECTED_TRACEBACK_OBJ, next); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java index 8627fd8fbb..473aff97db 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java @@ -353,7 +353,7 @@ public final Object varArgExecute(VirtualFrame frame, Object self, Object[] argu @Specialization @SuppressWarnings("unused") Object error(Object cls, Object[] arguments, PKeyword[] keywords) { - throw raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, StructSequence.getTpName(cls)); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, StructSequence.getTpName(cls)); } } @@ -384,7 +384,7 @@ PTuple withoutDict(VirtualFrame frame, Object cls, Object sequence, @SuppressWar @Exclusive @Cached InlinedBranchProfile needsReallocProfile, @Bind PythonLanguage language, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); for (int i = src.length; i < dst.length; ++i) { @@ -405,7 +405,7 @@ PTuple withDict(VirtualFrame frame, Object cls, Object sequence, PDict dict, @Cached HashingStorageGetItem getItem, @Bind PythonLanguage language, @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); HashingStorage hs = dict.getDictStorage(); @@ -419,23 +419,23 @@ PTuple withDict(VirtualFrame frame, Object cls, Object sequence, PDict dict, @Specialization(guards = {"!isNoValue(dict)", "!isDict(dict)"}) @SuppressWarnings("unused") static PTuple doDictError(VirtualFrame frame, Object cls, Object sequence, Object dict, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.TAKES_A_DICT_AS_SECOND_ARG_IF_ANY, StructSequence.getTpName(cls)); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TAKES_A_DICT_AS_SECOND_ARG_IF_ANY, StructSequence.getTpName(cls)); } private static Object[] sequenceToArray(VirtualFrame frame, Node inliningTarget, Object sequence, FastConstructListNode fastConstructListNode, - ToArrayNode toArrayNode, IsBuiltinObjectProfile notASequenceProfile, PRaiseNode.Lazy raiseNode) { + ToArrayNode toArrayNode, IsBuiltinObjectProfile notASequenceProfile, PRaiseNode raiseNode) { PSequence seq; try { seq = fastConstructListNode.execute(frame, inliningTarget, sequence); } catch (PException e) { e.expect(inliningTarget, TypeError, notASequenceProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CONSTRUCTOR_REQUIRES_A_SEQUENCE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CONSTRUCTOR_REQUIRES_A_SEQUENCE); } return toArrayNode.execute(inliningTarget, seq.getSequenceStorage()); } - private Object[] processSequence(Node inliningTarget, Object cls, Object[] src, InlinedBranchProfile wrongLenProfile, InlinedBranchProfile needsReallocProfile, PRaiseNode.Lazy raiseNode) { + private Object[] processSequence(Node inliningTarget, Object cls, Object[] src, InlinedBranchProfile wrongLenProfile, InlinedBranchProfile needsReallocProfile, PRaiseNode raiseNode) { int len = src.length; int minLen = inSequence; int maxLen = fieldNames.length; @@ -443,12 +443,12 @@ private Object[] processSequence(Node inliningTarget, Object cls, Object[] src, if (len < minLen || len > maxLen) { wrongLenProfile.enter(inliningTarget); if (minLen == maxLen) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TAKES_A_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_A_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); } if (len < minLen) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TAKES_AN_AT_LEAST_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_LEAST_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); } else { // len > maxLen - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TAKES_AN_AT_MOST_D_SEQUENCE, StructSequence.getTpName(cls), maxLen, len); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_MOST_D_SEQUENCE, StructSequence.getTpName(cls), maxLen, len); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java index e96a6e6c41..e8835f56b6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java @@ -153,7 +153,7 @@ int index(VirtualFrame frame, Object self, Object value, int startIn, int endIn, @Cached InlinedBranchProfile startLe0Profile, @Cached InlinedBranchProfile endLe0Profile, @Cached SequenceStorageNodes.ItemIndexNode itemIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage storage = getTupleStorage.execute(inliningTarget, self); int start = startIn; if (start < 0) { @@ -175,7 +175,7 @@ int index(VirtualFrame frame, Object self, Object value, int startIn, int endIn, if (idx != -1) { return idx; } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.ValueError, ErrorMessages.X_NOT_IN_TUPLE); + throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.X_NOT_IN_TUPLE); } } @@ -289,7 +289,7 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile validProfile, @Cached PyIndexCheckNode indexCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached GetTupleStorage getTupleStorage, @Cached SequenceStorageMpSubscriptNode subscriptNode) { if (!validProfile.profile(inliningTarget, SequenceStorageMpSubscriptNode.isValidIndex(inliningTarget, idx, indexCheckNode))) { @@ -300,8 +300,8 @@ static Object doIt(VirtualFrame frame, Object self, Object idx, } @InliningCutoff - private static void raiseNonIntIndex(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object index) { - raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "tuple", index); + private static void raiseNonIntIndex(Node inliningTarget, PRaiseNode raiseNode, Object index) { + raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_INDEX_MUST_BE_INT_OR_SLICES, "tuple", index); } } @@ -469,8 +469,8 @@ protected static SequenceStorageNodes.ConcatNode createConcat() { @Fallback static Object doGeneric(@SuppressWarnings("unused") Object left, Object right, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "tuple", right, "tuple"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_CONCAT_S_NOT_P_TO_S, "tuple", right, "tuple"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java index e826238069..ced2e38cf8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleGetterBuiltins.java @@ -109,10 +109,10 @@ static Object getTuple(VirtualFrame frame, PTupleGetter self, PTuple instance, @ @Bind("this") Node inliningTarget, @Cached PyObjectSizeNode sizeNode, @Cached TupleBuiltins.GetItemNode getItemNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final int index = self.getIndex(); if (index >= sizeNode.execute(frame, inliningTarget, instance)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.IndexError, TUPLE_OUT_OF_BOUNDS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.IndexError, TUPLE_OUT_OF_BOUNDS); } return getItemNode.execute(frame, instance, index); } @@ -125,9 +125,9 @@ static Object getNone(@SuppressWarnings("unused") VirtualFrame frame, PTupleGett @Fallback @InliningCutoff static Object getOthers(@SuppressWarnings("unused") VirtualFrame frame, Object self, Object instance, @SuppressWarnings("unused") Object owner, - @Cached PRaiseNode raiseNode) { + @Bind("this") Node inliningTarget) { final int index = ((PTupleGetter) self).getIndex(); - throw raiseNode.raise(PythonBuiltinClassType.TypeError, DESC_FOR_INDEX_S_FOR_S_DOESNT_APPLY_TO_P, + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, DESC_FOR_INDEX_S_FOR_S_DOESNT_APPLY_TO_P, index, "tuple subclasses", instance); } } @@ -140,9 +140,9 @@ abstract static class DescrSet extends DescrSetBuiltinNode { @SuppressWarnings("unused") void set(PTupleGetter self, Object instance, Object value) { if (PGuards.isNoValue(value)) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.AttributeError, CANT_DELETE_ATTRIBUTE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.AttributeError, CANT_DELETE_ATTRIBUTE); } else { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.AttributeError, CANT_SET_ATTRIBUTE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.AttributeError, CANT_SET_ATTRIBUTE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonBuiltinClass.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonBuiltinClass.java index 259834f2be..71e53b9f46 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonBuiltinClass.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonBuiltinClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -78,7 +78,7 @@ public void setAttribute(TruffleString name, Object value) { if (!PythonContext.get(null).isCoreInitialized()) { setAttributeUnsafe(name, value); } else { - throw PRaiseNode.raiseUncached(null, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(name), this); + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(name), this); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java index 29bffb65bf..b98201849a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java @@ -52,6 +52,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.CodePointAtIndexNode; @@ -113,7 +114,8 @@ protected PythonManagedClass(PythonLanguage lang, Object typeClass, Shape classS unsafeSetSuperClass(baseClasses); } - this.setMRO(ComputeMroNode.doSlowPath(this, invokeMro)); + // TODO should pass node for exception location + this.setMRO(ComputeMroNode.doSlowPath(null, this, invokeMro)); if (invokeMro) { mroInitialized = true; } @@ -142,8 +144,8 @@ public boolean isMROInitialized() { * Invoke metaclass mro() method and set the result as new method resolution order. */ @TruffleBoundary - public void invokeMro() { - PythonAbstractClass[] mro = ComputeMroNode.invokeMro(this); + public void invokeMro(Node node) { + PythonAbstractClass[] mro = ComputeMroNode.invokeMro(node, this); if (mro != null) { this.setMRO(mro); } @@ -294,7 +296,8 @@ private void unsafeSetSuperClass(PythonAbstractClass... newBaseClasses) { for (PythonAbstractClass base : getBaseClasses()) { if (base instanceof PythonManagedClass && !((PythonManagedClass) base).mroInitialized) { - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.CANNOT_EXTEND_INCOMPLETE_P, base); + // TODO should pass node for exception location + throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.CANNOT_EXTEND_INCOMPLETE_P, base); } } for (PythonAbstractClass base : getBaseClasses()) { @@ -309,7 +312,7 @@ private void unsafeSetSuperClass(PythonAbstractClass... newBaseClasses) { } @TruffleBoundary - public final void setBases(Object newBaseClass, PythonAbstractClass[] newBaseClasses) { + public final void setBases(Node node, Object newBaseClass, PythonAbstractClass[] newBaseClasses) { Object oldBase = getBase(); PythonAbstractClass[] oldBaseClasses = getBaseClasses(); PythonAbstractClass[] oldMRO = this.methodResolutionOrder.getInternalClassArray(); @@ -328,12 +331,12 @@ public final void setBases(Object newBaseClass, PythonAbstractClass[] newBaseCla this.base = newBaseClass; this.baseClasses = newBaseClasses; this.methodResolutionOrder.lookupChanged(); - this.setMRO(ComputeMroNode.doSlowPath(this)); + this.setMRO(ComputeMroNode.doSlowPath(node, this)); for (PythonAbstractClass scls : subclassesArray) { if (scls instanceof PythonManagedClass pmc) { pmc.methodResolutionOrder.lookupChanged(); - pmc.setMRO(ComputeMroNode.doSlowPath(scls)); + pmc.setMRO(ComputeMroNode.doSlowPath(node, scls)); } } } catch (PException pe) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java index 0d86652c98..9268bd9af5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java @@ -197,6 +197,7 @@ import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -289,14 +290,14 @@ static Object setDoc(PythonClass self, Object value) { @Specialization(guards = {"!isNoValue(value)", "!isDeleteMarker(value)", "isKindOfBuiltinClass(self)"}) static Object doc(Object self, @SuppressWarnings("unused") Object value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___DOC__, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___DOC__, self); } @Specialization static Object doc(Object self, @SuppressWarnings("unused") DescriptorDeleteMarker marker, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.CANT_DELETE_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___DOC__, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.CANT_DELETE_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___DOC__, self); } } @@ -331,8 +332,8 @@ static Object doit(Object klass, @Fallback @SuppressWarnings("unused") static Object doit(Object object, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T_MRO, "type", object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, T_MRO, "type", object); } } @@ -340,6 +341,7 @@ static Object doit(Object object, @GenerateNodeFactory public abstract static class InitNode extends PythonVarargsBuiltinNode { @Child private SplitArgsNode splitArgsNode; + private final BranchProfile errorProfile = BranchProfile.create(); @Override public final Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { @@ -353,7 +355,8 @@ public final Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused" @Specialization Object init(@SuppressWarnings("unused") Object self, Object[] arguments, @SuppressWarnings("unused") PKeyword[] kwds) { if (arguments.length != 1 && arguments.length != 3) { - throw raise(TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type.__init__()", 1, 3); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type.__init__()", 1, 3); } return PNone.NONE; } @@ -388,12 +391,13 @@ Object selfInArgs(VirtualFrame frame, @SuppressWarnings("unused") Object self, O @Cached CallNodeHelper callNodeHelper, @Cached SplitArgsNode splitArgsNode, @Exclusive @Cached IsSameTypeNode isSameTypeNode, - @Exclusive @Cached GetClassNode getClassNode) { + @Exclusive @Cached GetClassNode getClassNode, + @Shared @Cached PRaiseNode raiseNode) { if (isSameTypeNode.execute(inliningTarget, PythonBuiltinClassType.PythonClass, arguments[0])) { if (arguments.length == 2 && keywords.length == 0) { return getClassNode.execute(inliningTarget, arguments[1]); } else if (arguments.length != 4) { - throw raise(TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type()", 1, 3); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type()", 1, 3); } } return callNodeHelper.execute(frame, arguments[0], splitArgsNode.execute(inliningTarget, arguments), keywords); @@ -403,12 +407,13 @@ Object selfInArgs(VirtualFrame frame, @SuppressWarnings("unused") Object self, O Object selfSeparate(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords, @Bind("this") Node inliningTarget, @Exclusive @Cached IsSameTypeNode isSameTypeNode, - @Exclusive @Cached GetClassNode getClassNode) { + @Exclusive @Cached GetClassNode getClassNode, + @Shared @Cached PRaiseNode raiseNode) { if (isSameTypeNode.execute(inliningTarget, PythonBuiltinClassType.PythonClass, self)) { if (arguments.length == 1 && keywords.length == 0) { return getClassNode.execute(inliningTarget, arguments[0]); } else if (arguments.length != 3) { - throw raise(TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type()", 1, 3); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type()", 1, 3); } } return getCallNodeHelper().execute(frame, self, arguments, keywords); @@ -467,7 +472,7 @@ protected Object doIt0BuiltinSingle(VirtualFrame frame, @SuppressWarnings("unuse @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PythonBuiltinClassType type = cachedSelf.getType(); return op(frame, inliningTarget, type, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -480,7 +485,7 @@ protected Object doIt0User(VirtualFrame frame, @SuppressWarnings("unused") Pytho @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op(frame, inliningTarget, cachedSelf, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -492,7 +497,7 @@ protected Object doIt0BuiltinMulti(VirtualFrame frame, @SuppressWarnings("unused @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op(frame, inliningTarget, cachedType, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -504,7 +509,7 @@ protected Object doIt0BuiltinType(VirtualFrame frame, @SuppressWarnings("unused" @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op(frame, inliningTarget, cachedType, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -515,7 +520,7 @@ protected Object doItIndirect0Builtin(VirtualFrame frame, PythonBuiltinClass sel @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { PythonBuiltinClassType type = self.getType(); return op(frame, inliningTarget, type, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -527,7 +532,7 @@ protected Object doItIndirect0BuiltinType(VirtualFrame frame, PythonBuiltinClass @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op(frame, inliningTarget, self, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -538,7 +543,7 @@ protected Object doItIndirect0User(VirtualFrame frame, PythonClass self, Object[ @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return op(frame, inliningTarget, self, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -552,7 +557,7 @@ protected Object doIt1(VirtualFrame frame, @SuppressWarnings("unused") PythonAbs @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkFlags(self, inliningTarget, getTypeFlagsNode, raiseNode); return op(frame, inliningTarget, PythonNativeClass.cast(cachedSelf), arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @@ -565,19 +570,19 @@ protected Object doItIndirect1(VirtualFrame frame, PythonAbstractNativeObject se @Shared @Cached InlinedConditionProfile hasInit, @Shared @Cached InlinedConditionProfile gotInitResult, @Shared @Cached BindNew bindNew, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkFlags(self, inliningTarget, getTypeFlagsNode, raiseNode); return op(frame, inliningTarget, PythonNativeClass.cast(self), arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } - private void checkFlags(PythonAbstractNativeObject self, Node inliningTarget, GetTypeFlagsNode getTypeFlagsNode, PRaiseNode.Lazy raiseNode) { + private void checkFlags(PythonAbstractNativeObject self, Node inliningTarget, GetTypeFlagsNode getTypeFlagsNode, PRaiseNode raiseNode) { if ((getTypeFlagsNode.execute(self) & TypeFlags.DISALLOW_INSTANTIATION) != 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, getTypeName(self)); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, getTypeName(self)); } } private Object op(VirtualFrame frame, Node inliningTarget, Object self, Object[] arguments, PKeyword[] keywords, GetClassNode getInstanceClassNode, - InlinedConditionProfile hasInit, InlinedConditionProfile gotInitResult, BindNew bindNew, PRaiseNode.Lazy raiseNode) { + InlinedConditionProfile hasInit, InlinedConditionProfile gotInitResult, BindNew bindNew, PRaiseNode raiseNode) { Object newMethod = lookupNew.execute(self); assert newMethod != NO_VALUE; Object[] newArgs = PythonUtils.prependArgument(self, arguments); @@ -587,7 +592,7 @@ private Object op(VirtualFrame frame, Node inliningTarget, Object self, Object[] } private void callInit(Node inliningTarget, Object newInstance, Object self, VirtualFrame frame, Object[] arguments, PKeyword[] keywords, GetClassNode getInstanceClassNode, - InlinedConditionProfile hasInit, InlinedConditionProfile gotInitResult, PRaiseNode.Lazy raiseNode) { + InlinedConditionProfile hasInit, InlinedConditionProfile gotInitResult, PRaiseNode raiseNode) { Object newInstanceKlass = getInstanceClassNode.execute(inliningTarget, newInstance); if (isSubType(newInstanceKlass, self)) { Object initMethod = getInitNode().execute(frame, newInstanceKlass, newInstance); @@ -595,7 +600,7 @@ private void callInit(Node inliningTarget, Object newInstance, Object self, Virt Object[] initArgs = PythonUtils.prependArgument(newInstance, arguments); Object initResult = getDispatchNode().execute(frame, initMethod, initArgs, keywords); if (gotInitResult.profile(inliningTarget, initResult != PNone.NONE && initResult != NO_VALUE)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_RETURN_NONE, "__init__()"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_RETURN_NONE, "__init__()"); } } } @@ -655,12 +660,12 @@ protected Object doIt(VirtualFrame frame, Object object, Object keyObj, @Cached InlinedBranchProfile hasValueProfile, @Cached InlinedBranchProfile hasNonDescriptorValueProfile, @Cached InlinedBranchProfile errorProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TruffleString key; try { key = castToString.execute(inliningTarget, keyObj); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, keyObj); } Object metatype = getClassNode.execute(inliningTarget, object); @@ -697,7 +702,7 @@ protected Object doIt(VirtualFrame frame, Object object, Object keyObj, } } errorProfile.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, object, key); } private Object readAttribute(Object object, TruffleString key) { @@ -751,7 +756,7 @@ static void set(VirtualFrame frame, Object object, Object key, Object value, @TruffleBoundary void setBuiltin(Object object, Object key, Object value) { if (PythonContext.get(this).isInitialized()) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(key), object); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(key), object); } else { set(null, object, key, value, null, ObjectNodes.GenericSetAttrNode.getUncached(), WriteAttributeToObjectNode.getUncached(true)); } @@ -798,18 +803,18 @@ static Object setBases(VirtualFrame frame, PythonClass cls, PTuple value, @Cached IsSubtypeNode isSubtypeNode, @Cached IsSameTypeNode isSameTypeNode, @Cached GetMroNode getMroNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object[] a = getArray.execute(inliningTarget, value); if (a.length == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CAN_ONLY_ASSIGN_NON_EMPTY_TUPLE_TO_P, cls); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_ASSIGN_NON_EMPTY_TUPLE_TO_P, cls); } PythonAbstractClass[] baseClasses = new PythonAbstractClass[a.length]; for (int i = 0; i < a.length; i++) { if (PGuards.isPythonClass(a[i])) { if (isSubtypeNode.execute(frame, a[i], cls) || hasMRO(inliningTarget, getMroNode, a[i]) && typeIsSubtypeBaseChain(inliningTarget, a[i], cls, getBase, isSameTypeNode)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BASES_ITEM_CAUSES_INHERITANCE_CYCLE); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BASES_ITEM_CAUSES_INHERITANCE_CYCLE); } if (a[i] instanceof PythonBuiltinClassType) { baseClasses[i] = PythonContext.get(inliningTarget).lookupType((PythonBuiltinClassType) a[i]); @@ -817,7 +822,7 @@ static Object setBases(VirtualFrame frame, PythonClass cls, PTuple value, baseClasses[i] = (PythonAbstractClass) a[i]; } } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_TUPLE_OF_CLASSES_NOT_P, getName.execute(inliningTarget, cls), "__bases__", a[i]); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_TUPLE_OF_CLASSES_NOT_P, getName.execute(inliningTarget, cls), "__bases__", a[i]); } } @@ -829,7 +834,7 @@ static Object setBases(VirtualFrame frame, PythonClass cls, PTuple value, Object oldBase = getBase.execute(inliningTarget, cls); checkCompatibleForAssigment.execute(frame, oldBase, newBestBase); - cls.setBases(newBestBase, baseClasses); + cls.setBases(inliningTarget, newBestBase, baseClasses); SpecialMethodSlot.reinitializeSpecialMethodSlots(cls, PythonLanguage.get(inliningTarget)); TpSlots.updateAllSlots(cls); @@ -855,14 +860,14 @@ private static boolean typeIsSubtypeBaseChain(Node inliningTarget, Object a, Obj @Specialization(guards = "!isPTuple(value)") static Object setObject(@SuppressWarnings("unused") PythonClass cls, @SuppressWarnings("unused") Object value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CAN_ONLY_ASSIGN_S_TO_S_S_NOT_P, "tuple", GetNameNode.executeUncached(cls), "__bases__", value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CAN_ONLY_ASSIGN_S_TO_S_S_NOT_P, "tuple", GetNameNode.executeUncached(cls), "__bases__", value); } @Specialization static Object setBuiltin(@SuppressWarnings("unused") PythonBuiltinClass cls, @SuppressWarnings("unused") Object value, - @Shared @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___BASES__, cls); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___BASES__, cls); } } @@ -953,9 +958,9 @@ boolean isInstance(VirtualFrame frame, Object cls, Object instance, @Cached InlinedConditionProfile typeErrorProfile, @Cached AbstractObjectIsSubclassNode abstractIsSubclassNode, @Cached AbstractObjectGetBasesNode getBasesNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (typeErrorProfile.profile(inliningTarget, getBasesNode.execute(frame, cls) == null)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ISINSTANCE_ARG_2_MUST_BE_TYPE_OR_TUPLE_OF_TYPE, instance); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ISINSTANCE_ARG_2_MUST_BE_TYPE_OR_TUPLE_OF_TYPE, instance); } PythonObject instanceClass = getInstanceClassAttr(frame, instance); @@ -985,7 +990,7 @@ static boolean doObjectObject(VirtualFrame frame, Object cls, Object derived, @Cached PyTupleCheckNode tupleCheck, @Cached TypeNodes.IsTypeNode isClsTypeNode, @Cached TypeNodes.IsTypeNode isDerivedTypeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isSameTypeNode.execute(inliningTarget, cls, derived)) { return true; } @@ -995,10 +1000,10 @@ static boolean doObjectObject(VirtualFrame frame, Object cls, Object derived, return isSubtypeNode.execute(frame, derived, cls); } if (!checkClass(frame, inliningTarget, derived, getBasesAttrNode, tupleCheck, isAttrErrorProfile)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARG_D_MUST_BE_S, "issubclass()", 1, "class"); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_D_MUST_BE_S, "issubclass()", 1, "class"); } if (!checkClass(frame, inliningTarget, cls, getBasesAttrNode, tupleCheck, isAttrErrorProfile)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.ISSUBCLASS_MUST_BE_CLASS_OR_TUPLE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ISSUBCLASS_MUST_BE_CLASS_OR_TUPLE); } return false; } @@ -1056,15 +1061,15 @@ abstract static class CheckSetSpecialTypeAttrNode extends Node { @Specialization static void check(Node inliningTarget, Object type, Object value, TruffleString name, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached(inline = false) GetTypeFlagsNode getTypeFlagsNode, @Cached SysModuleBuiltins.AuditNode auditNode) { if (PGuards.isKindOfBuiltinClass(type) || (getTypeFlagsNode.execute(type) & TypeFlags.IMMUTABLETYPE) != 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, name, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, name, type); } if (value == DescriptorDeleteMarker.INSTANCE) { // Sic, it's not immutable, but CPython has this message - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_DELETE_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, name, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_DELETE_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, name, type); } auditNode.audit(inliningTarget, "object.__setattr__", type, name, value); } @@ -1136,16 +1141,16 @@ static Object setName(VirtualFrame frame, Object cls, Object value, @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfCodePointNode indexOfCodePointNode, @Cached SetNameInnerNode innerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { check.execute(inliningTarget, cls, value, T___NAME__); TruffleString string; try { string = castToTruffleStringNode.execute(inliningTarget, value); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_ASSIGN_S_TO_P_S_NOT_P, "string", cls, T___NAME__, value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_ASSIGN_S_TO_P_S_NOT_P, "string", cls, T___NAME__, value); } if (indexOfCodePointNode.execute(string, 0, 0, codePointLengthNode.execute(string, TS_ENCODING), TS_ENCODING) >= 0) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.TYPE_NAME_NO_NULL_CHARS); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.TYPE_NAME_NO_NULL_CHARS); } if (!isValidNode.execute(string, TS_ENCODING)) { throw constructAndRaiseNode.get(inliningTarget).raiseUnicodeEncodeError(frame, "utf-8", string, 0, string.codePointLengthUncached(TS_ENCODING), "can't encode classname"); @@ -1173,10 +1178,10 @@ static TruffleString getModuleBuiltin(PythonBuiltinClass cls, @SuppressWarnings( static Object getModule(PythonClass cls, @SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, @Cached ReadAttributeFromObjectNode readAttrNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object module = readAttrNode.execute(cls, T___MODULE__); if (module == NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError); + throw raiseNode.raise(inliningTarget, AttributeError); } return module; } @@ -1197,12 +1202,12 @@ static Object getModule(PythonNativeClass cls, @SuppressWarnings("unused") PNone @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.IndexOfCodePointNode indexOfCodePointNode, @Cached TruffleString.SubstringNode substringNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { // see function 'typeobject.c: type_module' if ((getFlags.execute(cls) & TypeFlags.HEAPTYPE) != 0) { Object module = readAttr.execute(cls, T___MODULE__); if (module == NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError); + throw raiseNode.raise(inliningTarget, AttributeError); } return module; } else { @@ -1222,10 +1227,10 @@ static Object setNative(PythonNativeClass cls, Object value, @Bind("this") Node inliningTarget, @Shared @Cached GetTypeFlagsNode getFlags, @Cached("createForceType()") WriteAttributeToObjectNode writeAttr, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { long flags = getFlags.execute(cls); if ((flags & TypeFlags.HEAPTYPE) == 0) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SET_N_S, cls, T___MODULE__); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SET_N_S, cls, T___MODULE__); } writeAttr.execute(cls, T___MODULE__, value); return PNone.NONE; @@ -1233,14 +1238,14 @@ static Object setNative(PythonNativeClass cls, Object value, @Specialization(guards = "!isNoValue(value)") static Object setModuleType(@SuppressWarnings("unused") PythonBuiltinClassType cls, @SuppressWarnings("unused") Object value, - @Shared("raise") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTES_OF_TYPE, "built-in/extension 'type'"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTES_OF_TYPE, "built-in/extension 'type'"); } @Specialization(guards = "!isNoValue(value)") static Object setModuleBuiltin(@SuppressWarnings("unused") PythonBuiltinClass cls, @SuppressWarnings("unused") Object value, - @Shared("raise") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTES_OF_TYPE, "built-in/extension 'type'"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.CANT_SET_ATTRIBUTES_OF_TYPE, "built-in/extension 'type'"); } } @@ -1302,13 +1307,13 @@ static Object setName(Object cls, Object value, @Cached CheckSetSpecialTypeAttrNode check, @Cached CastToTruffleStringNode castToStringNode, @Cached SetQualNameInnerNode innerNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { check.execute(inliningTarget, cls, value, T___QUALNAME__); TruffleString stringValue; try { stringValue = castToStringNode.execute(inliningTarget, value); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_ASSIGN_STR_TO_QUALNAME, cls, value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_ASSIGN_STR_TO_QUALNAME, cls, value); } innerNode.execute(inliningTarget, cls, stringValue); return PNone.NONE; @@ -1368,11 +1373,11 @@ static Object doGeneric(Object self, @Bind("this") Node inliningTarget, @Cached IsTypeNode isTypeNode, @Cached GetTypeFlagsNode getTypeFlagsNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (PGuards.isClass(inliningTarget, self, isTypeNode)) { return getTypeFlagsNode.execute(self); } - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.DESC_FLAG_FOR_TYPE_DOESNT_APPLY_TO_OBJ, self); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.DESC_FLAG_FOR_TYPE_DOESNT_APPLY_TO_OBJ, self); } } @@ -1384,7 +1389,7 @@ static Object get(Object self, @SuppressWarnings("unused") PNone none, @Bind("this") Node inliningTarget, @Exclusive @Cached IsSameTypeNode isSameTypeNode, @Exclusive @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { // Avoid returning this descriptor if (!isSameTypeNode.execute(inliningTarget, self, PythonBuiltinClassType.PythonClass)) { Object result = readAttributeFromObjectNode.execute(self, T___ABSTRACTMETHODS__); @@ -1392,7 +1397,7 @@ static Object get(Object self, @SuppressWarnings("unused") PNone none, return result; } } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, self, T___ABSTRACTMETHODS__); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_N_HAS_NO_ATTR_S, self, T___ABSTRACTMETHODS__); } @Specialization(guards = {"!isNoValue(value)", "!isDeleteMarker(value)"}) @@ -1401,13 +1406,13 @@ static Object set(VirtualFrame frame, PythonClass self, Object value, @Cached PyObjectIsTrueNode isTrueNode, @Exclusive @Cached IsSameTypeNode isSameTypeNode, @Exclusive @Cached WriteAttributeToObjectNode writeAttributeToObjectNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (!isSameTypeNode.execute(inliningTarget, self, PythonBuiltinClassType.PythonClass)) { writeAttributeToObjectNode.execute(self, T___ABSTRACTMETHODS__, value); self.setAbstractClass(isTrueNode.execute(frame, value)); return PNone.NONE; } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); } @Specialization(guards = "!isNoValue(value)") @@ -1416,7 +1421,7 @@ static Object delete(PythonClass self, @SuppressWarnings("unused") DescriptorDel @Exclusive @Cached IsSameTypeNode isSameTypeNode, @Exclusive @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, @Exclusive @Cached WriteAttributeToObjectNode writeAttributeToObjectNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { if (!isSameTypeNode.execute(inliningTarget, self, PythonBuiltinClassType.PythonClass)) { if (readAttributeFromObjectNode.execute(self, T___ABSTRACTMETHODS__) != NO_VALUE) { writeAttributeToObjectNode.execute(self, T___ABSTRACTMETHODS__, NO_VALUE); @@ -1424,14 +1429,14 @@ static Object delete(PythonClass self, @SuppressWarnings("unused") DescriptorDel return PNone.NONE; } } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); } @Fallback @SuppressWarnings("unused") static Object set(Object self, Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, J___ABSTRACTMETHODS__, self); } } @@ -1502,7 +1507,7 @@ static Object get(Object self, @SuppressWarnings("unused") Object value, @Cached InlinedBranchProfile createDict, @Shared("read") @Cached ReadAttributeFromObjectNode read, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object annotations = read.execute(self, T___ANNOTATIONS__); if (annotations == NO_VALUE) { createDict.enter(inliningTarget); @@ -1510,7 +1515,7 @@ static Object get(Object self, @SuppressWarnings("unused") Object value, try { write.execute(self, T___ANNOTATIONS__, annotations); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, self, T___ANNOTATIONS__); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, self, T___ANNOTATIONS__); } } return annotations; @@ -1521,15 +1526,15 @@ static Object delete(Object self, @SuppressWarnings("unused") Object value, @Bind("this") Node inliningTarget, @Shared("read") @Cached ReadAttributeFromObjectNode read, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { Object annotations = read.execute(self, T___ANNOTATIONS__); try { write.execute(self, T___ANNOTATIONS__, NO_VALUE); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___ANNOTATIONS__, self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___ANNOTATIONS__, self); } if (annotations == NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(AttributeError, new Object[]{T___ANNOTATIONS__}); + throw raiseNode.raise(inliningTarget, AttributeError, new Object[]{T___ANNOTATIONS__}); } return PNone.NONE; } @@ -1538,11 +1543,11 @@ static Object delete(Object self, @SuppressWarnings("unused") Object value, static Object set(Object self, Object value, @Bind("this") Node inliningTarget, @Shared("write") @Cached WriteAttributeToObjectNode write, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { write.execute(self, T___ANNOTATIONS__, value); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___ANNOTATIONS__, self); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_S_OF_IMMUTABLE_TYPE_N, T___ANNOTATIONS__, self); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java index 122c4f757f..d10697b51f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java @@ -590,7 +590,7 @@ private static MroSequenceStorage doPythonClass(PythonManagedClass obj, Node inl @InliningCutoff private static void initializeMRO(PythonManagedClass obj, Node inliningTarget, InlinedConditionProfile isPythonClass, PythonLanguage language) { - PythonAbstractClass[] mro = ComputeMroNode.doSlowPath(obj, false); + PythonAbstractClass[] mro = ComputeMroNode.doSlowPath(inliningTarget, obj, false); if (isPythonClass.profile(inliningTarget, obj instanceof PythonClass)) { ((PythonClass) obj).setMRO(mro, language); } else { @@ -632,7 +632,7 @@ static MroSequenceStorage doNativeClass(Node inliningTarget, PythonNativeClass o } } raiseSystemErrorBranch.enter(inliningTarget); - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_MRO_OBJ); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_MRO_OBJ); } private static Object initializeType(Node inliningTarget, PythonNativeClass obj, CStructAccess.ReadObjectNode getTpMroNode) { @@ -642,7 +642,7 @@ private static Object initializeType(Node inliningTarget, PythonNativeClass obj, // call 'PyType_Ready' on the type int res = (int) PCallCapiFunction.callUncached(NativeCAPISymbol.FUN_PY_TYPE_READY, PythonToNativeNodeGen.getUncached().execute(obj)); if (res < 0) { - PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.LAZY_INITIALIZATION_FAILED, GetNameNode.executeUncached(obj)); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.LAZY_INITIALIZATION_FAILED, GetNameNode.executeUncached(obj)); } Object tupleObj = getTpMroNode.readFromObj(obj, PyTypeObject__tp_mro); @@ -669,7 +669,7 @@ static MroSequenceStorage doSlowPath(Node inliningTarget, Object obj) { return (MroSequenceStorage) sequenceStorage; } } - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_MRO_OBJ); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_MRO_OBJ); } throw new IllegalStateException("unknown type " + obj.getClass().getName()); } @@ -924,7 +924,7 @@ PythonAbstractClass[] doPythonClass(PythonBuiltinClassType obj) { @Specialization static PythonAbstractClass[] doNative(Node inliningTarget, PythonNativeClass obj, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached(inline = false) CStructAccess.ReadObjectNode getTpBasesNode, @Cached InlinedExactClassProfile resultTypeProfile, @Cached GetInternalObjectArrayNode toArrayNode) { @@ -935,10 +935,10 @@ static PythonAbstractClass[] doNative(Node inliningTarget, PythonNativeClass obj try { return cast(values, storage); } catch (ClassCastException e) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.UNSUPPORTED_OBJ_IN, "tp_bases"); + throw raise.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.UNSUPPORTED_OBJ_IN, "tp_bases"); } } - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.SystemError, ErrorMessages.TYPE_DOES_NOT_PROVIDE_BASES); + throw raise.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.TYPE_DOES_NOT_PROVIDE_BASES); } // TODO: get rid of this @@ -983,7 +983,7 @@ static Object doNative(Node inliningTarget, PythonNativeClass obj, return result; } CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.INVALID_BASE_TYPE_OBJ_FOR_CLASS, GetNameNode.doSlowPath(obj), result); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_BASE_TYPE_OBJ_FOR_CLASS, GetNameNode.doSlowPath(obj), result); } public static GetBaseClassNode getUncached() { @@ -1013,7 +1013,7 @@ static PythonAbstractClass getOne(PythonAbstractClass[] bases) { static PythonAbstractClass getBestBase(Node inliningTarget, PythonAbstractClass[] bases, @Cached(inline = false) IsSubtypeNode isSubTypeNode, @Cached GetSolidBaseNode getSolidBaseNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { return bestBase(inliningTarget, bases, getSolidBaseNode, isSubTypeNode, raiseNode); } @@ -1028,7 +1028,7 @@ static PythonAbstractClass fallback(PythonAbstractClass[] bases) { /** * Aims to get as close as possible to typeobject.best_base(). */ - private static PythonAbstractClass bestBase(Node inliningTarget, PythonAbstractClass[] bases, GetSolidBaseNode getSolidBaseNode, IsSubtypeNode isSubTypeNode, PRaiseNode.Lazy raiseNode) + private static PythonAbstractClass bestBase(Node inliningTarget, PythonAbstractClass[] bases, GetSolidBaseNode getSolidBaseNode, IsSubtypeNode isSubTypeNode, PRaiseNode raiseNode) throws PException { PythonAbstractClass base = null; Object winner = null; @@ -1044,7 +1044,7 @@ private static PythonAbstractClass bestBase(Node inliningTarget, PythonAbstractC winner = candidate; base = basei; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MULTIPLE_BASES_LAYOUT_CONFLICT); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MULTIPLE_BASES_LAYOUT_CONFLICT); } } return base; @@ -1084,7 +1084,6 @@ public abstract static class CheckCompatibleForAssigmentNode extends PNodeWithCo @Child private LookupAttributeInMRONode lookupSlotsNode; @Child private LookupAttributeInMRONode lookupNewNode; @Child private PyObjectSizeNode sizeNode; - @Child private PRaiseNode raiseNode; @Child private GetNameNode getTypeNameNode; @Child private ReadAttributeFromObjectNode readAttr; @Child private InstancesOfTypeHaveDictNode instancesHaveDictNode; @@ -1099,7 +1098,7 @@ boolean isCompatible(VirtualFrame frame, Object oldBase, Object newBase, @Cached GetBaseClassNode getBaseClassNode) { if (!compatibleForAssignment(frame, inliningTarget, oldBase, newBase, isSameTypeNode, getBaseClassNode)) { errorSlotsBranch.enter(inliningTarget); - throw getRaiseNode().raise(TypeError, ErrorMessages.CLASS_ASSIGNMENT_S_LAYOUT_DIFFERS_FROM_S, getTypeName(newBase), getTypeName(oldBase)); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CLASS_ASSIGNMENT_S_LAYOUT_DIFFERS_FROM_S, getTypeName(newBase), getTypeName(oldBase)); } return true; } @@ -1246,14 +1245,6 @@ private LookupAttributeInMRONode getLookupNewNode() { } return lookupNewNode; } - - private PRaiseNode getRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } } /** @@ -1596,17 +1587,17 @@ static final class NotSameTypeException extends ControlFlowException { public abstract static class ComputeMroNode extends Node { @TruffleBoundary - public static PythonAbstractClass[] doSlowPath(PythonAbstractClass cls) { - return doSlowPath(cls, true); + public static PythonAbstractClass[] doSlowPath(Node node, PythonAbstractClass cls) { + return doSlowPath(node, cls, true); } @TruffleBoundary - public static PythonAbstractClass[] doSlowPath(PythonAbstractClass cls, boolean invokeMro) { - return computeMethodResolutionOrder(cls, invokeMro); + public static PythonAbstractClass[] doSlowPath(Node node, PythonAbstractClass cls, boolean invokeMro) { + return computeMethodResolutionOrder(node, cls, invokeMro); } @TruffleBoundary - static PythonAbstractClass[] invokeMro(PythonAbstractClass cls) { + static PythonAbstractClass[] invokeMro(Node node, PythonAbstractClass cls) { Object type = GetClassNode.executeUncached(cls); if (IsTypeNode.executeUncached(type) && type instanceof PythonClass) { Object mroMeth = LookupAttributeInMRONode.Dynamic.getUncached().execute(type, T_MRO); @@ -1614,20 +1605,20 @@ static PythonAbstractClass[] invokeMro(PythonAbstractClass cls) { Object mroObj = CallUnaryMethodNode.getUncached().executeObject(mroMeth, cls); if (mroObj instanceof PSequence mroSequence) { SequenceStorage mroStorage = mroSequence.getSequenceStorage(); - return mroCheck(cls, GetInternalObjectArrayNode.executeUncached(mroStorage), mroStorage); + return mroCheck(node, cls, GetInternalObjectArrayNode.executeUncached(mroStorage), mroStorage); } - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.OBJ_NOT_ITERABLE, cls); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.OBJ_NOT_ITERABLE, cls); } } return null; } - private static PythonAbstractClass[] computeMethodResolutionOrder(PythonAbstractClass cls, boolean invokeMro) { + private static PythonAbstractClass[] computeMethodResolutionOrder(Node node, PythonAbstractClass cls, boolean invokeMro) { CompilerAsserts.neverPartOfCompilation(); PythonAbstractClass[] currentMRO; if (invokeMro) { - PythonAbstractClass[] mro = invokeMro(cls); + PythonAbstractClass[] mro = invokeMro(node, cls); if (mro != null) { return mro; } @@ -1656,12 +1647,12 @@ private static PythonAbstractClass[] computeMethodResolutionOrder(PythonAbstract toMerge[baseClasses.length] = new MROMergeState(baseClasses); ArrayList mro = new ArrayList<>(); mro.add(cls); - currentMRO = mergeMROs(toMerge, mro); + currentMRO = mergeMROs(node, toMerge, mro); } return currentMRO; } - private static PythonAbstractClass[] mroCheck(Object cls, Object[] mro, SequenceStorage storage) { + private static PythonAbstractClass[] mroCheck(Node node, Object cls, Object[] mro, SequenceStorage storage) { List resultMro = new ArrayList<>(storage.length()); Object solid = GetSolidBaseNode.executeUncached(cls); for (int i = 0; i < storage.length(); i++) { @@ -1670,17 +1661,17 @@ private static PythonAbstractClass[] mroCheck(Object cls, Object[] mro, Sequence continue; } if (!IsTypeNode.executeUncached(object)) { - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.S_RETURNED_NON_CLASS, "mro()", object); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.S_RETURNED_NON_CLASS, "mro()", object); } if (!IsSubtypeNode.getUncached().execute(solid, GetSolidBaseNode.executeUncached(object))) { - throw PRaiseNode.getUncached().raise(TypeError, ErrorMessages.S_RETURNED_BASE_WITH_UNSUITABLE_LAYOUT, "mro()", object); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.S_RETURNED_BASE_WITH_UNSUITABLE_LAYOUT, "mro()", object); } resultMro.add((PythonAbstractClass) object); } return resultMro.toArray(new PythonAbstractClass[resultMro.size()]); } - private static PythonAbstractClass[] mergeMROs(MROMergeState[] toMerge, List mro) { + private static PythonAbstractClass[] mergeMROs(Node node, MROMergeState[] toMerge, List mro) { int idx; scan: for (idx = 0; idx < toMerge.length; idx++) { if (toMerge[idx].isMerged()) { @@ -1719,7 +1710,7 @@ private static PythonAbstractClass[] mergeMROs(MROMergeState[] toMerge, List= 0) { - throw raise.raise(PythonBuiltinClassType.ValueError, ErrorMessages.TYPE_NAME_NO_NULL_CHARS); + throw raise.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.TYPE_NAME_NO_NULL_CHARS); } // 1.) create class, but avoid calling mro method - it might try to access __dict__ so @@ -2168,7 +2159,7 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple } // 3.) invoke metaclass mro() method - pythonClass.invokeMro(); + pythonClass.invokeMro(inliningTarget); // CPython masks the __hash__ method with None when __eq__ is overriden, but __hash__ is // not @@ -2213,7 +2204,7 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple int slotlen = slotsStorage.length(); if (slotlen > 0 && hasItemSize) { - throw raise.raise(TypeError, ErrorMessages.NONEMPTY_SLOTS_NOT_ALLOWED_FOR_SUBTYPE_OF_S, base); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.NONEMPTY_SLOTS_NOT_ALLOWED_FOR_SUBTYPE_OF_S, base); } for (int i = 0; i < slotlen; i++) { @@ -2223,20 +2214,20 @@ static PythonClass typeMetaclass(VirtualFrame frame, TruffleString name, PTuple if (stringCheck.execute(inliningTarget, element)) { slotName = castToStringNode.execute(inliningTarget, element); if (!(boolean) isIdentifier.execute(frame, slotName)) { - throw raise.raise(TypeError, ErrorMessages.SLOTS_MUST_BE_IDENTIFIERS); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SLOTS_MUST_BE_IDENTIFIERS); } } else { - throw raise.raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "__slots__ items", element); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "__slots__ items", element); } if (equalNode.execute(slotName, T___DICT__, TS_ENCODING)) { if (!ctx.mayAddDict || ctx.addDict) { - throw raise.raise(TypeError, ErrorMessages.DICT_SLOT_DISALLOWED_WE_GOT_ONE); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.DICT_SLOT_DISALLOWED_WE_GOT_ONE); } ctx.addDict = true; addDictDescrAttribute(basesArray, pythonClass, language); } else if (equalNode.execute(slotName, T___WEAKREF__, TS_ENCODING)) { if (!ctx.mayAddWeak || ctx.addWeak) { - throw raise.raise(TypeError, ErrorMessages.WEAKREF_SLOT_DISALLOWED_WE_GOT_ONE); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.WEAKREF_SLOT_DISALLOWED_WE_GOT_ONE); } ctx.addWeak = true; } @@ -2478,7 +2469,7 @@ private static void copyDictSlots(VirtualFrame frame, Node inliningTarget, Pytho pythonClass.setQualName(castToStringNode.execute(inliningTarget, value)); ctx.qualnameSet = true; } catch (CannotCastException e) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_S_NOT_P, "type __qualname__", "str", value); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MUST_BE_S_NOT_P, "type __qualname__", "str", value); } continue; } @@ -2517,7 +2508,7 @@ private static TruffleString[] copySlots(Node inliningTarget, TypeNewContext ctx try { slotName = PythonUtils.mangleName(className, slotName); } catch (OutOfMemoryError e) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.PRIVATE_IDENTIFIER_TOO_LARGE_TO_BE_MANGLED); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.PRIVATE_IDENTIFIER_TOO_LARGE_TO_BE_MANGLED); } if (slotName == null) { return null; @@ -2529,7 +2520,7 @@ private static TruffleString[] copySlots(Node inliningTarget, TypeNewContext ctx if (!T___CLASSCELL__.equalsUncached(slotName, TS_ENCODING) && !T___QUALNAME__.equalsUncached(slotName, TS_ENCODING) && HashingStorageGetItem.hasKeyUncached(namespace.getDictStorage(), slotName)) { // __qualname__ and __classcell__ will be deleted later - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.S_S_CONFLICTS_WITH_CLASS_VARIABLE, slotName, "__slots__"); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.S_S_CONFLICTS_WITH_CLASS_VARIABLE, slotName, "__slots__"); } j++; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrGet.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrGet.java index 52dc42ff18..8ff5790f59 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrGet.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrGet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -73,7 +73,6 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.RootCallTarget; @@ -87,6 +86,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.IndirectCallNode; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.profiles.ConditionProfile; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -152,7 +152,7 @@ public void initialize(PythonLanguage language) { static final class DescrGetWrapperNode extends PythonTernaryBuiltinNode { private final ConditionProfile objIsNoneProfile = ConditionProfile.create(); private final ConditionProfile typeIsNoneProfile = ConditionProfile.create(); - @Child private PRaiseNode raiseNode; + private final BranchProfile errorProfile = BranchProfile.create(); @Child private DescrGetBuiltinNode wrapped; DescrGetWrapperNode(DescrGetBuiltinNode wrapped) { @@ -168,11 +168,8 @@ public Object execute(VirtualFrame frame, Object self, Object objIn, Object type Object obj = normalizeNone(objIsNoneProfile, objIn); Object type = normalizeNone(typeIsNoneProfile, typeIn); if (obj == PNone.NO_VALUE && type == PNone.NO_VALUE) { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.GET_NONE_NONE_IS_INVALID); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.GET_NONE_NONE_IS_INVALID); } return wrapped.execute(frame, self, obj, type); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrSet.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrSet.java index b336adedd6..3a80efeb55 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrSet.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotDescrSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -210,8 +210,8 @@ static void callNative(VirtualFrame frame, Node inliningTarget, TpSlotNative slo } } - private static PException raiseAttributeError(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString attrName) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, attrName); + private static PException raiseAttributeError(Node inliningTarget, PRaiseNode raiseNode, TruffleString attrName) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, attrName); } @GenerateInline(inlineByDefault = true) @@ -241,7 +241,7 @@ static void callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") Tp @Specialization(guards = "!isNoValue(value)") static void callPythonSet(VirtualFrame frame, Node inliningTarget, TpSlotDescrSetPython slot, Object self, Object obj, Object value, @Cached TernaryPythonSlotDispatcherNode dispatcherNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object callable = slot.getSetCallable(); if (callable == null) { throw raiseAttributeError(inliningTarget, raiseNode, T___SET__); @@ -253,7 +253,7 @@ static void callPythonSet(VirtualFrame frame, Node inliningTarget, TpSlotDescrSe @InliningCutoff static void callPythonDel(VirtualFrame frame, Node inliningTarget, TpSlotDescrSetPython slot, Object self, Object obj, @SuppressWarnings("unused") Object value, @Cached BinaryPythonSlotDispatcherNode dispatcherNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object callable = slot.getDelCallable(); if (callable == null) { throw raiseAttributeError(inliningTarget, raiseNode, T___DEL__); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotInquiry.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotInquiry.java index 982f7127e7..9f0d8244b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotInquiry.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotInquiry.java @@ -152,7 +152,7 @@ static boolean doIt(VirtualFrame frame, TpSlotPythonSingle slot, Object self, @Bind("this") Node inliningTarget, @Cached UnaryPythonSlotDispatcherNode dispatcherNode, @Cached PyBoolCheckNode pyBoolCheckNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyObjectIsTrueNode pyObjectIsTrueNode) { // See CPython: slot_nb_bool // TODO: it is not clear to me why CPython lookups __len__ in the slot wrapper although @@ -160,7 +160,7 @@ static boolean doIt(VirtualFrame frame, TpSlotPythonSingle slot, Object self, // __len__. We ignore the __len__ lookup for now. Object result = dispatcherNode.execute(frame, inliningTarget, slot.getCallable(), slot.getType(), self); if (!pyBoolCheckNode.execute(inliningTarget, result)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BOOL_SHOULD_RETURN_BOOL, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BOOL_SHOULD_RETURN_BOOL, result); } return pyObjectIsTrueNode.execute(frame, result); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java index faca264b47..12e49e7e98 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -66,7 +66,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.util.CastToJavaIntLossyNode; import com.oracle.graal.python.runtime.ExecutionContext.CallContext; @@ -175,7 +174,7 @@ static int callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative @Exclusive @Cached GetThreadStateNode getThreadStateNode, @Cached(inline = false) PythonToNativeNode toNativeNode, @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached(inline = false) CheckPrimitiveFunctionResultNode checkResultNode) { PythonContext ctx = PythonContext.get(inliningTarget); PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); @@ -192,7 +191,7 @@ static int callNative(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative s @Exclusive @Cached GetThreadStateNode getThreadStateNode, @Cached(inline = false) HPyAsHandleNode toNativeNode, @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached(inline = false) CheckPrimitiveFunctionResultNode checkResultNode) { PythonContext ctx = PythonContext.get(inliningTarget); PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); @@ -205,8 +204,8 @@ static int callNative(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative s } @InliningCutoff - private static void raiseOverflow(Node inliningTarget, Lazy raiseNode, long l) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, l); + private static void raiseOverflow(Node inliningTarget, PRaiseNode raiseNode, long l) { + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, l); } @Specialization(replaces = "callCachedBuiltin") @@ -231,7 +230,7 @@ static int callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, Tp static int callHPy(VirtualFrame frame, Node inliningTarget, TpSlotNative slot, Object self, @Cached GetThreadStateNode getThreadStateNode, @Cached UnaryHPySlotDispatcherNode hpyDispatcher, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached(inline = false) CheckPrimitiveFunctionResultNode checkResultNode) { PythonContext ctx = PythonContext.get(inliningTarget); PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); @@ -257,7 +256,7 @@ static int doIt(VirtualFrame frame, TpSlotPythonSingle slot, Object self, @Bind("this") Node inliningTarget, @Cached UnaryPythonSlotDispatcherNode dispatcherNode, @Cached InlinedBranchProfile genericCheck, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyNumberIndexNode indexNode, @Cached CastToJavaIntLossyNode castLossy, @Cached PyNumberAsSizeNode asSizeNode) { @@ -274,7 +273,7 @@ static int doIt(VirtualFrame frame, TpSlotPythonSingle slot, Object self, return convertAndCheckLen(frame, inliningTarget, result, indexNode, castLossy, asSizeNode, raiseNode); } - static int checkLen(Node inliningTarget, PRaiseNode.Lazy raiseNode, int len) { + static int checkLen(Node inliningTarget, PRaiseNode raiseNode, int len) { if (len < 0) { raiseLenGt0(inliningTarget, raiseNode); } @@ -282,12 +281,12 @@ static int checkLen(Node inliningTarget, PRaiseNode.Lazy raiseNode, int len) { } @InliningCutoff - private static void raiseLenGt0(Node inliningTarget, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.LEN_SHOULD_RETURN_GT_ZERO); + private static void raiseLenGt0(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.LEN_SHOULD_RETURN_GT_ZERO); } public static int convertAndCheckLen(VirtualFrame frame, Node inliningTarget, Object result, PyNumberIndexNode indexNode, - CastToJavaIntLossyNode castLossy, PyNumberAsSizeNode asSizeNode, PRaiseNode.Lazy raiseNode) { + CastToJavaIntLossyNode castLossy, PyNumberAsSizeNode asSizeNode, PRaiseNode raiseNode) { int len; Object index = indexNode.execute(frame, inliningTarget, result); try { @@ -305,7 +304,7 @@ public static int convertAndCheckLen(VirtualFrame frame, Node inliningTarget, Ob } @InliningCutoff - private static PException checkNegative(Node inliningTarget, CastToJavaIntLossyNode castLossy, Lazy raiseNode, PException e, Object index) { + private static PException checkNegative(Node inliningTarget, CastToJavaIntLossyNode castLossy, PRaiseNode raiseNode, PException e, Object index) { int len; len = castLossy.execute(inliningTarget, index); checkLen(inliningTarget, raiseNode, len); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotMpAssSubscript.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotMpAssSubscript.java index 5225165777..f1d4f8ada2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotMpAssSubscript.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotMpAssSubscript.java @@ -237,7 +237,7 @@ static void callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") Tp @Specialization(guards = "!isNoValue(value)") static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotMpAssSubscriptPython slot, Object self, Object key, Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached TernaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getSetitem(); if (callable == null) { @@ -249,7 +249,7 @@ static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotM @Specialization(guards = "isNoValue(value)") @InliningCutoff static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotMpAssSubscriptPython slot, Object self, Object key, @SuppressWarnings("unused") Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached BinaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getDelitem(); if (callable == null) { @@ -259,8 +259,8 @@ static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotM } @InliningCutoff - private static PException raiseAttributeError(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString attrName) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, attrName); + private static PException raiseAttributeError(Node inliningTarget, PRaiseNode raiseNode, TruffleString attrName) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, attrName); } @Specialization(replaces = "callCachedBuiltin") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSetAttr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSetAttr.java index 910745cf17..a1a3a31715 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSetAttr.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSetAttr.java @@ -318,7 +318,7 @@ static void callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") Tp @Specialization(guards = "!isNoValue(value)") static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotSetAttrPython slot, Object self, Object name, Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached TernaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getSetattr(); if (callable == null) { @@ -330,7 +330,7 @@ static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotS @Specialization(guards = "isNoValue(value)") @InliningCutoff static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotSetAttrPython slot, Object self, Object name, @SuppressWarnings("unused") Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached BinaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getDelattr(); if (callable == null) { @@ -340,8 +340,8 @@ static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotS } @InliningCutoff - private static PException raiseAttributeError(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString attrName) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, attrName); + private static PException raiseAttributeError(Node inliningTarget, PRaiseNode raiseNode, TruffleString attrName) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, attrName); } @Specialization(replaces = "callCachedBuiltin") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqAssItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqAssItem.java index 02e951b321..873f81a75e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqAssItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqAssItem.java @@ -314,7 +314,7 @@ static void callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") Tp @Specialization(guards = "!isNoValue(value)") static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotSqAssItemPython slot, Object self, int key, Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached TernaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getSetitem(); if (callable == null) { @@ -326,7 +326,7 @@ static void callPythonSimpleSet(VirtualFrame frame, Node inliningTarget, TpSlotS @Specialization(guards = "isNoValue(value)") @InliningCutoff static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotSqAssItemPython slot, Object self, int key, @SuppressWarnings("unused") Object value, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached BinaryPythonSlotDispatcherNode callPythonFun) { Object callable = slot.getDelitem(); if (callable == null) { @@ -336,8 +336,8 @@ static void callPythonSimpleDel(VirtualFrame frame, Node inliningTarget, TpSlotS } @InliningCutoff - private static PException raiseAttributeError(Node inliningTarget, PRaiseNode.Lazy raiseNode, TruffleString attrName) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.AttributeError, attrName); + private static PException raiseAttributeError(Node inliningTarget, PRaiseNode raiseNode, TruffleString attrName) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, attrName); } @Specialization(replaces = "callCachedBuiltin") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java index af05abce04..f4c492f342 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java @@ -348,8 +348,8 @@ abstract static class InstanceCheckNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object check(PGenericAlias self, Object other, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ISINSTANCE_ARG_2_CANNOT_BE_A_PARAMETERIZED_GENERIC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ISINSTANCE_ARG_2_CANNOT_BE_A_PARAMETERIZED_GENERIC); } } @@ -359,8 +359,8 @@ abstract static class SubclassCheckNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object check(PGenericAlias self, Object other, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.ISSUBCLASS_ARG_2_CANNOT_BE_A_PARAMETERIZED_GENERIC); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.ISSUBCLASS_ARG_2_CANNOT_BE_A_PARAMETERIZED_GENERIC); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java index 511f48bce1..bba33da549 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java @@ -78,10 +78,11 @@ protected List> getNodeFa abstract static class NextNode extends PythonUnaryBuiltinNode { @Specialization static Object next(PGenericAliasIterator self, + @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode, @Bind PythonLanguage language) { if (self.isExhausted()) { - throw raiseNode.raise(PythonBuiltinClassType.StopIteration); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration); } PGenericAlias alias = self.getObj(); PGenericAlias starredAlias = PFactory.createGenericAlias(language, alias.getOrigin(), alias.getArgs(), true); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java index f3429c434f..cd265a0b03 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java @@ -268,7 +268,7 @@ static Object[] subsParameters(Node node, Object self, PTuple args, PTuple param SequenceStorage paramsStorage = parameters.getSequenceStorage(); int nparams = paramsStorage.length(); if (nparams == 0) { - throw PRaiseNode.raiseUncached(node, TypeError, ErrorMessages.S_IS_NOT_A_GENERIC_CLASS, PyObjectReprAsTruffleStringNode.executeUncached(self)); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.S_IS_NOT_A_GENERIC_CLASS, PyObjectReprAsTruffleStringNode.executeUncached(self)); } Object[] argitems = unpackArgs(item); for (int i = 0; i < nparams; i++) { @@ -280,9 +280,8 @@ static Object[] subsParameters(Node node, Object self, PTuple args, PTuple param } } if (argitems.length != nparams) { - throw PRaiseNode.raiseUncached(node, TypeError, ErrorMessages.TOO_S_ARGUMENTS_FOR_S_ACTUAL_D_EXPECTED_D, - argitems.length > nparams ? "many" : "few", PyObjectReprAsTruffleStringNode.executeUncached(self), - argitems.length, nparams); + throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.TOO_S_ARGUMENTS_FOR_S_ACTUAL_D_EXPECTED_D, argitems.length > nparams ? "many" : "few", + PyObjectReprAsTruffleStringNode.executeUncached(self), argitems.length, nparams); } SequenceStorage argsStorage = args.getSequenceStorage(); List newargs = new ArrayList<>(argsStorage.length()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java index 2f9632bc54..f0e7343f7b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java @@ -219,13 +219,13 @@ static boolean check(VirtualFrame frame, PUnionType self, Object other, @Bind("this") Node inliningTarget, @Cached SequenceStorageNodes.GetItemScalarNode getItem, @Cached BuiltinFunctions.IsInstanceNode isInstanceNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { SequenceStorage argsStorage = self.getArgs().getSequenceStorage(); boolean result = false; for (int i = 0; i < argsStorage.length(); i++) { Object arg = getItem.execute(inliningTarget, argsStorage, i); if (arg instanceof PGenericAlias) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ISINSTANCE_ARG_2_CANNOT_CONTAIN_A_PARAMETERIZED_GENERIC); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ISINSTANCE_ARG_2_CANNOT_CONTAIN_A_PARAMETERIZED_GENERIC); } if (!result) { result = isInstanceNode.executeWith(frame, other, arg); @@ -245,16 +245,16 @@ static boolean check(VirtualFrame frame, PUnionType self, Object other, @Cached TypeNodes.IsTypeNode isTypeNode, @Cached SequenceStorageNodes.GetItemScalarNode getItem, @Cached BuiltinFunctions.IsSubClassNode isSubClassNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isTypeNode.execute(inliningTarget, other)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ISSUBCLASS_ARG_1_MUST_BE_A_CLASS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ISSUBCLASS_ARG_1_MUST_BE_A_CLASS); } SequenceStorage argsStorage = self.getArgs().getSequenceStorage(); boolean result = false; for (int i = 0; i < argsStorage.length(); i++) { Object arg = getItem.execute(inliningTarget, argsStorage, i); if (arg instanceof PGenericAlias) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ISSUBCLASS_ARG_2_CANNOT_CONTAIN_A_PARAMETERIZED_GENERIC); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ISSUBCLASS_ARG_2_CANNOT_CONTAIN_A_PARAMETERIZED_GENERIC); } if (!result) { result = isSubClassNode.executeWith(frame, other, arg); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java index a9f29ef5fb..6e3a92b444 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -58,6 +58,7 @@ import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; @@ -604,15 +605,15 @@ private static ArrayList popStack(ArrayList blocks) { } // returns null if the jump is fine - public String checkJump(List> stackElems, int from, int to) { + public String checkJump(Node node, List> stackElems, int from, int to) { ArrayList blkFrom = stackElems.get(from); if (blkFrom == null) { // this should not happen - PRaiseNode.getUncached().raise(PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, bciToLine(from)); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, bciToLine(from)); } ArrayList blkTo = stackElems.get(to); if (blkTo == null) { - PRaiseNode.getUncached().raise(PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, bciToLine(from)); + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, bciToLine(from)); } if (blkTo.size() > blkFrom.size()) { return blkTo.get(blkTo.size() - 1).error; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Unparser.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Unparser.java index 8f8502ff61..5bbd6d1753 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Unparser.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Unparser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -652,7 +652,7 @@ public Void visit(ExprTy.FormattedValue node) { conversion = "!s"; break; default: - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.SystemError, ErrorMessages.UNKNOWN_F_VALUE_CONVERSION_KIND); + throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.SystemError, ErrorMessages.UNKNOWN_F_VALUE_CONVERSION_KIND); } appendStr(conversion); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java index e36648c901..136c62578d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -59,6 +59,7 @@ import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.profiles.BranchProfile; public abstract class GetNextNode extends PNodeWithContext { public abstract Object execute(Frame frame, Object iterator); @@ -78,11 +79,12 @@ public Object execute(Object iterator) { private static final class GetNextCached extends GetNextNode { @Child private LookupAndCallUnaryNode nextCall = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next, () -> new NoAttributeHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object receiver) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver); } }); @@ -125,7 +127,7 @@ public Object execute(Frame frame, Object iterator) { private Object executeImpl(Object iterator) { Object nextMethod = LookupSpecialMethodSlotNode.getUncached(SpecialMethodSlot.Next).execute(null, GetClassNode.executeUncached(iterator), iterator); if (nextMethod == PNone.NO_VALUE) { - throw PRaiseNode.getUncached().raise(PythonErrorType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, iterator, T___NEXT__); + throw PRaiseNode.raiseStatic(null, PythonErrorType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, iterator, T___NEXT__); } return CallUnaryMethodNode.getUncached().executeObject(nextMethod, iterator); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyArgCheckPositionalNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyArgCheckPositionalNode.java index dbc3fec985..70fa3f5d5b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyArgCheckPositionalNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyArgCheckPositionalNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -66,16 +66,16 @@ public final boolean execute(Node inliningTarget, TruffleString name, Object[] a @Specialization static boolean doGeneric(Node inliningTarget, TruffleString name, int nargs, int min, int max, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { assert min >= 0; assert min <= max; if (nargs < min) { if (name != null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_EXPECTED_SD_ARGS_GOT_D, + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_EXPECTED_SD_ARGS_GOT_D, name, (min == max ? "" : "at least "), min, min == 1 ? "" : "s", nargs); } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, UNPACKED_TUPLE_SHOULD_HAVE_D_ELEMS, + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, UNPACKED_TUPLE_SHOULD_HAVE_D_ELEMS, (min == max ? "" : "at least "), min, min == 1 ? "" : "s", nargs); } } @@ -86,10 +86,10 @@ static boolean doGeneric(Node inliningTarget, TruffleString name, int nargs, int if (nargs > max) { if (name != null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_EXPECTED_SD_ARGS_GOT_D, + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_EXPECTED_SD_ARGS_GOT_D, name, (min == max ? "" : "at most "), max, max == 1 ? "" : "s", nargs); } else { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, UNPACKED_TUPLE_SHOULD_HAVE_D_ELEMS, + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, UNPACKED_TUPLE_SHOULD_HAVE_D_ELEMS, (min == max ? "" : "at most "), max, max == 1 ? "" : "s", nargs); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyConvertOptionalToSizeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyConvertOptionalToSizeNode.java index 5fc303b88c..fab20906aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyConvertOptionalToSizeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyConvertOptionalToSizeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -69,14 +69,14 @@ int doOptional(@SuppressWarnings("unused") PNone value, int defaultValue) { @Specialization(guards = {"!isNone(value)", "!isNoValue(value)"}) static int doObject(VirtualFrame frame, Node inliningTarget, Object value, @SuppressWarnings("unused") int defaultValue, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode) { int limit; if (indexCheckNode.execute(inliningTarget, value)) { limit = asSizeNode.executeExact(frame, inliningTarget, value); } else { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, value); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ARG_SHOULD_BE_INT_OR_NONE, value); } return limit; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictDelItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictDelItem.java index 4e65a647d1..db133c06ef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictDelItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyDictDelItem.java @@ -68,9 +68,9 @@ public abstract class PyDictDelItem extends Node { @Specialization static void delItem(VirtualFrame frame, Node inliningTarget, PDict dict, Object key, @Cached HashingStorageDelItem delItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!delItem.execute(frame, inliningTarget, dict.getDictStorage(), key, dict)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, new Object[]{key}); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.KeyError, new Object[]{key}); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatAsDoubleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatAsDoubleNode.java index 5f2d3f6a34..4419f196c0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatAsDoubleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatAsDoubleNode.java @@ -133,7 +133,7 @@ static double doObject(VirtualFrame frame, Node inliningTarget, Object object, @Cached PyNumberIndexNode indexNode, @Cached PyLongAsDoubleNode asDoubleNode, @Cached HandleFloatResultNode handleFloatResultNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_float() != null) { @@ -147,7 +147,7 @@ static double doObject(VirtualFrame frame, Node inliningTarget, Object object, Object index = indexNode.execute(frame, inliningTarget, object); return asDoubleNode.execute(inliningTarget, index); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, object); } @InliningCutoff @@ -172,11 +172,11 @@ static double handle(VirtualFrame frame, Object result, Object original, @Cached IsSubtypeNode resultSubtypeNode, @Cached CastToJavaDoubleNode cast, @Cached WarningsModuleBuiltins.WarnNode warnNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object resultType = resultClassNode.execute(inliningTarget, result); if (!resultProfile.profileClass(inliningTarget, resultType, PythonBuiltinClassType.PFloat)) { if (!resultSubtypeNode.execute(resultType, PythonBuiltinClassType.PFloat)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NON_FLOAT, original, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_FLOAT, original, result); } else { warnNode.warnFormat(frame, null, DeprecationWarning, 1, ErrorMessages.WARN_P_RETURNED_NON_P, original, T___FLOAT__, "float", result, "float"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatFromString.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatFromString.java index 87542d43eb..3d4c9b99ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatFromString.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatFromString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -82,7 +82,7 @@ public abstract class PyFloatFromString extends PNodeWithContext { static double doString(VirtualFrame frame, Node inliningTarget, TruffleString object, @Cached(inline = false) TruffleString.ToJavaStringNode toJavaStringNode, @Shared @Cached PyObjectReprAsTruffleStringNode reprNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { return convertStringToDouble(frame, inliningTarget, toJavaStringNode.execute(object), object, reprNode, raiseNode); } @@ -93,7 +93,7 @@ static double doGeneric(VirtualFrame frame, Node inliningTarget, Object object, @CachedLibrary(limit = "3") PythonBufferAccessLibrary accessLib, @Cached(inline = false) CastToJavaStringNode cast, @Shared @Cached PyObjectReprAsTruffleStringNode reprNode, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { String string = null; try { string = cast.execute(object); @@ -117,7 +117,7 @@ static double doGeneric(VirtualFrame frame, Node inliningTarget, Object object, if (string != null) { return convertStringToDouble(frame, inliningTarget, string, object, reprNode, raiseNode); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_NUMBER, "float()", object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_NUMBER, "float()", object); } @TruffleBoundary(allowInlining = true) @@ -125,7 +125,7 @@ private static String newString(byte[] bytes, int offset, int length) { return new String(bytes, offset, length); } - private static double convertStringToDouble(VirtualFrame frame, Node inliningTarget, String src, Object origObj, PyObjectReprAsTruffleStringNode reprNode, PRaiseNode.Lazy raiseNode) { + private static double convertStringToDouble(VirtualFrame frame, Node inliningTarget, String src, Object origObj, PyObjectReprAsTruffleStringNode reprNode, PRaiseNode raiseNode) { String str = FloatUtils.removeUnicodeAndUnderscores(src); // Adapted from CPython's float_from_string_inner if (str != null) { @@ -144,9 +144,9 @@ private static double convertStringToDouble(VirtualFrame frame, Node inliningTar repr = reprNode.execute(frame, inliningTarget, origObj); } catch (PException e) { // Failed to format the message. Mirrors CPython behavior when the repr fails - throw raiseNode.get(inliningTarget).raise(ValueError); + throw raiseNode.raise(inliningTarget, ValueError); } - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.COULD_NOT_CONVERT_STRING_TO_FLOAT, repr); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COULD_NOT_CONVERT_STRING_TO_FLOAT, repr); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportGetModule.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportGetModule.java index 309647e411..76e4cfc828 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportGetModule.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyImportGetModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -70,10 +70,10 @@ static Object doGeneric(VirtualFrame frame, Node node, Object name, @Bind("this") Node inliningTarget, @Cached InlinedConditionProfile noSysModulesProfile, @Cached(inline = false) DictBuiltins.GetItemNode getDictItemNode, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { final PDict sysModules = PythonContext.get(node).getSysModules(); if (noSysModulesProfile.profile(inliningTarget, sysModules == null)) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.RuntimeError, UNABLE_TO_GET_S, "sys.modules"); + throw raise.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, UNABLE_TO_GET_S, "sys.modules"); } return getDictItemNode.execute(frame, sysModules, name); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java index 0c9af9ddc3..a3f0f97ebb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java @@ -100,10 +100,10 @@ static Object doGeneric(VirtualFrame frame, Object iterator, @Cached(parameters = "Next") LookupSpecialMethodSlotNode lookupNext, @Cached CallUnaryMethodNode callNext, @Cached IsBuiltinObjectProfile stopIterationProfile, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator); if (nextMethod == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); } try { return callNext.executeObject(frame, nextMethod, iterator); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsDoubleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsDoubleNode.java index 4f4efd8c6b..464655747d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsDoubleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsDoubleNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -97,14 +97,13 @@ static double doPInt(Node inliningTarget, PInt self) { static double doNative(Node inliningTarget, @SuppressWarnings("unused") PythonAbstractNativeObject self, @SuppressWarnings("unused") @Cached PyLongCheckNode check) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); } @Fallback @InliningCutoff @SuppressWarnings("unused") - static double fallback(Node inliningTarget, Object object, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + static double fallback(Node inliningTarget, Object object) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsIntNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsIntNode.java index c230fe81ab..f4134e8506 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsIntNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsIntNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -81,7 +80,7 @@ static int doInt(int object) { @Specialization static int doObject(VirtualFrame frame, Node inliningTarget, Object object, @Cached PyLongAsLongAndOverflowNode pyLongAsLongAndOverflow, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { long result = pyLongAsLongAndOverflow.execute(frame, inliningTarget, object); int intResult = (int) result; @@ -95,7 +94,7 @@ static int doObject(VirtualFrame frame, Node inliningTarget, Object object, } @InliningCutoff - private static PException raiseOverflow(Node inliningTarget, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "Java int"); + private static PException raiseOverflow(Node inliningTarget, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "Java int"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsLongNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsLongNode.java index 1656ee5464..0e08ac4a5f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsLongNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongAsLongNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -73,11 +73,11 @@ public final long executeCached(Frame frame, Object object) { @Specialization static long doObject(VirtualFrame frame, Node inliningTarget, Object object, @Cached PyLongAsLongAndOverflowNode pyLongAsLongAndOverflow, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return pyLongAsLongAndOverflow.execute(frame, inliningTarget, object); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "Java long"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "Java long"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java index 7ce2c7818b..9ee63ec787 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromDoubleNode.java @@ -90,13 +90,13 @@ static Object doFinite(double value, } @Specialization(guards = "!isFinite(value)") - static Object doInfinite(double value, - @Cached(inline = false) PRaiseNode raiseNode) { + static Object doInfinite(Node inliningTarget, double value, + @Cached PRaiseNode raiseNode) { if (Double.isNaN(value)) { - throw raiseNode.raise(ValueError, ErrorMessages.CANNOT_CONVERT_FLOAT_NAN_TO_INTEGER); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CANNOT_CONVERT_FLOAT_NAN_TO_INTEGER); } assert Double.isInfinite(value); - throw raiseNode.raise(OverflowError, ErrorMessages.CANNOT_CONVERT_FLOAT_INFINITY_TO_INTEGER); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_CONVERT_FLOAT_INFINITY_TO_INTEGER); } @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java index 2a543b400a..34f6d556eb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyLongFromUnicodeObject.java @@ -127,17 +127,17 @@ static Object doGeneric(TruffleString numberTs, int base, byte[] originalBytes, @Cached InlinedBranchProfile invalidBase, @Cached InlinedBranchProfile notSimpleDecimalLiteralProfile, @Cached InlinedBranchProfile invalidValueProfile, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached StringNodes.StringReprNode stringReprNode, @Cached BytesNodes.BytesReprNode bytesReprNode) { String number = toJavaStringNode.execute(numberTs); if ((base != 0 && base < 2) || base > 36) { invalidBase.enter(inliningTarget); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INT_BASE_MUST_BE_2_AND_36_OR_0); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INT_BASE_MUST_BE_2_AND_36_OR_0); } notSimpleDecimalLiteralProfile.enter(inliningTarget); PythonContext context = PythonContext.get(inliningTarget); - Object value = stringToIntInternal(number, base, context); + Object value = stringToIntInternal(inliningTarget, number, base, context); if (value == null) { invalidValueProfile.enter(inliningTarget); Object repr; @@ -146,15 +146,15 @@ static Object doGeneric(TruffleString numberTs, int base, byte[] originalBytes, } else { repr = bytesReprNode.execute(inliningTarget, PFactory.createBytes(context.getLanguage(inliningTarget), originalBytes, originalBytesLen)); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_LITERAL_FOR_INT_WITH_BASE, base, repr); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.INVALID_LITERAL_FOR_INT_WITH_BASE, base, repr); } return value; } @TruffleBoundary - private static Object stringToIntInternal(String num, int base, PythonContext context) { + private static Object stringToIntInternal(Node inliningTarget, String num, int base, PythonContext context) { try { - BigInteger bi = asciiToBigInteger(num, base, context); + BigInteger bi = asciiToBigInteger(inliningTarget, num, base, context); if (bi == null) { return null; } @@ -169,7 +169,7 @@ private static Object stringToIntInternal(String num, int base, PythonContext co } @TruffleBoundary - private static BigInteger asciiToBigInteger(String str, int possibleBase, PythonContext context) throws NumberFormatException { + private static BigInteger asciiToBigInteger(Node inliningTarget, String str, int possibleBase, PythonContext context) throws NumberFormatException { int base = possibleBase; int b = 0; int e = str.length(); @@ -239,7 +239,7 @@ private static BigInteger asciiToBigInteger(String str, int possibleBase, Python } s = s.replace("_", ""); - checkMaxDigits(context, s.length(), base); + checkMaxDigits(inliningTarget, context, s.length(), base); BigInteger bi; if (sign == '-') { @@ -254,11 +254,12 @@ private static BigInteger asciiToBigInteger(String str, int possibleBase, Python return bi; } - private static void checkMaxDigits(PythonContext context, int digits, int base) { + private static void checkMaxDigits(Node inliningTarget, PythonContext context, int digits, int base) { if (digits > SysModuleBuiltins.INT_MAX_STR_DIGITS_THRESHOLD && Integer.bitCount(base) != 1) { int maxDigits = context.getIntMaxStrDigits(); if (maxDigits > 0 && digits > maxDigits) { - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION_D, maxDigits, digits); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EXCEEDS_THE_LIMIT_FOR_INTEGER_STRING_CONVERSION_D, maxDigits, + digits); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java index 9447f3c01a..d9a2ae7cfe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMemoryViewFromObject.java @@ -89,7 +89,7 @@ public abstract class PyMemoryViewFromObject extends PNodeWithContext { @Specialization static PMemoryView fromMemoryView(PMemoryView object, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { object.checkReleased(inliningTarget, raiseNode); PythonContext context = PythonContext.get(inliningTarget); return PFactory.createMemoryView(context.getLanguage(inliningTarget), context, object.getLifecycleManager(), object.getBuffer(), object.getOwner(), object.getLength(), @@ -110,7 +110,7 @@ static PMemoryView fromPickleBuffer(VirtualFrame frame, PPickleBuffer object, @Bind("this") Node inliningTarget, @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached PyMemoryViewFromObject recursive, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { /* * PickleBuffer is just a buffer proxy for other objects, including native objects or other * memoryviews, we need to process the delegate recursively. @@ -120,7 +120,7 @@ static PMemoryView fromPickleBuffer(VirtualFrame frame, PPickleBuffer object, owner = bufferLib.getOwner(object.getView()); } if (owner == null) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.OP_FORBIDDEN_ON_OBJECT, "PickleBuffer"); } return recursive.execute(frame, owner); } @@ -140,7 +140,7 @@ static PMemoryView fromManaged(VirtualFrame frame, Object object, @Cached MemoryViewNodes.InitFlagsNode initFlagsNode, @Cached TruffleString.CodePointLengthNode lengthNode, @Cached TruffleString.CodePointAtIndexNode atIndexNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object typeObj = getClassNode.execute(inliningTarget, object); assert typeObj instanceof PythonBuiltinClassType || typeObj instanceof PythonAbstractObject; PythonAbstractObject type; @@ -190,7 +190,7 @@ static PMemoryView fromManaged(VirtualFrame frame, Object object, bufferLib.isReadonly(buffer), bufferLib.getFormatString(buffer), lengthNode, atIndexNode); } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.MEMORYVIEW_A_BYTES_LIKE_OBJECT_REQUIRED_NOT_P, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MEMORYVIEW_A_BYTES_LIKE_OBJECT_REQUIRED_NOT_P, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAbsoluteNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAbsoluteNode.java index 8d33936398..9c634f5901 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAbsoluteNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAbsoluteNode.java @@ -92,13 +92,13 @@ static Object doObject(VirtualFrame frame, Object object, @Cached GetClassNode getClassNode, @Cached GetCachedTpSlotsNode getSlots, @Cached CallSlotUnaryNode callSlot, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_absolute() != null) { return callSlot.execute(frame, inliningTarget, slots.nb_absolute(), object); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "abs()", "", object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "abs()", "", object); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 221c0d2270..d14256f4c6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -56,7 +56,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -175,7 +174,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached CallBinaryOp1Node callBinaryOp1Node, @Cached InlinedBranchProfile hasNbAddResult, @Cached CallSlotBinaryFuncNode callBinarySlotNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlots slotsV = getVSlots.execute(inliningTarget, classV); @@ -196,8 +195,8 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index 6f8083ce72..a355cc7ddd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -88,7 +88,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_and(); @@ -103,8 +103,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "&", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "&", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAsSizeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAsSizeNode.java index 4f311bd2dd..483c15d20c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAsSizeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAsSizeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -124,12 +124,12 @@ static int doInt(int object, @SuppressWarnings("unused") Object errorClass) { @Specialization public static int doLongExact(Node inliningTarget, long object, PythonBuiltinClassType errorClass, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { int converted = (int) object; if (object == converted) { return converted; } - throw raiseNode.get(inliningTarget).raise(errorClass, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, object); + throw raiseNode.raise(inliningTarget, errorClass, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, object); } @Specialization @@ -157,13 +157,13 @@ abstract static class PyNumberAsSizeObjectNode extends Node { static int doObjectExact(VirtualFrame frame, Object object, PythonBuiltinClassType errorClass, @Bind("this") Node inliningTarget, @Exclusive @Cached PyNumberIndexNode indexNode, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached CastToJavaIntExactNode cast) { Object index = indexNode.execute(frame, inliningTarget, object); try { return cast.execute(inliningTarget, index); } catch (PException pe) { - throw raiseNode.get(inliningTarget).raise(errorClass, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, object); + throw raiseNode.raise(inliningTarget, errorClass, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, object); } catch (CannotCastException cannotCastException) { throw CompilerDirectives.shouldNotReachHere("PyNumberIndexNode didn't return a python integer"); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java index fdf765a769..1b113ff484 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -78,7 +78,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_divmod(); @@ -93,8 +93,8 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "divmod()", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "divmod()", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index dbce52a051..780808a84f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -116,7 +116,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_floor_divide(); @@ -131,8 +131,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "//", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "//", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberIndexNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberIndexNode.java index 718c2a9d06..96b8dcd0f4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberIndexNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberIndexNode.java @@ -104,7 +104,7 @@ static Object doCallIndex(VirtualFrame frame, Node inliningTarget, Object object @Cached TpSlots.GetCachedTpSlotsNode getSlots, @Cached CallSlotUnaryNode callIndex, @Cached(inline = false) IsSubtypeNode isSubtype, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached PyLongCheckExactNode checkNode, @Cached CheckIndexResultNotInt checkResult, @Cached PyLongCopy copy) { @@ -114,7 +114,7 @@ static Object doCallIndex(VirtualFrame frame, Node inliningTarget, Object object } TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_index() == null) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, object); } Object result = callIndex.execute(frame, inliningTarget, slots.nb_index(), object); if (checkNode.execute(inliningTarget, result)) { @@ -138,11 +138,11 @@ static Object doGeneric(VirtualFrame frame, Object original, Object result, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached IsSubtypeNode isSubtype, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached WarningsModuleBuiltins.WarnNode warnNode, @Cached PyLongCopy copy) { if (!isSubtype.execute(getClassNode.execute(inliningTarget, result), PythonBuiltinClassType.PInt)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, result); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.INDEX_RETURNED_NON_INT, result); } warnNode.warnFormat(frame, null, DeprecationWarning, 1, ErrorMessages.WARN_P_RETURNED_NON_P, original, T___INDEX__, "int", result, "int"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java index e46d1003e8..7ef7f93f4c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java @@ -80,13 +80,13 @@ public static Object doObject(VirtualFrame frame, Object object, @Cached GetClassNode getClassNode, @Cached GetCachedTpSlotsNode getSlots, @Cached CallSlotUnaryNode callSlot, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_invert() != null) { return callSlot.execute(frame, inliningTarget, slots.nb_invert(), object); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "~", object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "~", object); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLongNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLongNode.java index 2b10b32afb..7023f671ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLongNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLongNode.java @@ -166,11 +166,11 @@ static Object doGeneric(VirtualFrame frame, Object original, Object result, @Bind("this") Node inliningTarget, @Cached GetClassNode getClassNode, @Cached IsSubtypeNode isSubtype, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached WarningsModuleBuiltins.WarnNode warnNode, @Cached PyLongCopy copy) { if (!isSubtype.execute(getClassNode.execute(inliningTarget, result), PythonBuiltinClassType.PInt)) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.RETURNED_NON_INT, J___INT__, result); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.RETURNED_NON_INT, J___INT__, result); } warnNode.warnFormat(frame, null, PythonBuiltinClassType.DeprecationWarning, 1, ErrorMessages.WARN_P_RETURNED_NON_P, original, J___INT__, "int", result, "int"); @@ -199,7 +199,7 @@ static Object doGeneric(VirtualFrame frame, Object object, @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached PyLongFromUnicodeObject fromUnicodeObject, @Cached LongFromBufferNode fromBufferNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); Object truncMethod = lookup.execute(type, T___TRUNC__); if (truncMethod != PNone.NO_VALUE) { @@ -214,7 +214,7 @@ static Object doGeneric(VirtualFrame frame, Object object, return longCopy.execute(inliningTarget, result); } if (!indexCheckNode.execute(inliningTarget, result)) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NON_INTEGRAL, J___TRUNC__, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_INTEGRAL, J___TRUNC__, result); } return indexNode.execute(frame, inliningTarget, result); } @@ -228,7 +228,7 @@ static Object doGeneric(VirtualFrame frame, Object object, return result; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_BYTELIKE_OR_NUMBER, "int()", object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.ARG_MUST_BE_STRING_OR_BYTELIKE_OR_NUMBER, "int()", object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index 9a7f29497d..5174b5e343 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -96,7 +96,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_lshift(); @@ -111,8 +111,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "<<", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "<<", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java index 2076c14976..7595406b11 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -76,7 +76,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_matrix_multiply(); @@ -91,8 +91,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "@", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "@", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index 78ad860388..784deff635 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -49,7 +49,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -130,7 +129,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, @Cached CallSlotSizeArgFun callSlotNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlots slotsV = getVSlots.execute(inliningTarget, classV); @@ -157,15 +156,15 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); } private static Object sequenceRepeat(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object seq, Object n, PyIndexCheckNode indexCheckNode, PyNumberAsSizeNode asSizeNode, CallSlotSizeArgFun callSlotNode, - PRaiseNode.Lazy raiseNode) { + PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, n)) { int count = asSizeNode.execute(frame, inliningTarget, n, PythonBuiltinClassType.OverflowError); return callSlotNode.execute(frame, inliningTarget, slot, seq, count); @@ -175,8 +174,8 @@ private static Object sequenceRepeat(VirtualFrame frame, Node inliningTarget, Tp } @InliningCutoff - private static PException raiseNonIntSqMul(Node inliningTarget, Object n, Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, n); + private static PException raiseNonIntSqMul(Node inliningTarget, Object n, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, n); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java index a11cae150f..5f0fcddf32 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java @@ -93,13 +93,13 @@ public static Object doObject(VirtualFrame frame, Object object, @Cached GetClassNode getClassNode, @Cached GetCachedTpSlotsNode getSlots, @Cached CallSlotUnaryNode callSlot, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_negative() != null) { return callSlot.execute(frame, inliningTarget, slots.nb_negative(), object); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "-", object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "-", object); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index 29a24b4396..d79c83a043 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -87,7 +87,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_or(); @@ -102,8 +102,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "|", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "|", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java index 9dee19a666..897fc6ae2a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java @@ -75,13 +75,13 @@ public static Object doObject(VirtualFrame frame, Object object, @Cached GetClassNode getClassNode, @Cached GetCachedTpSlotsNode getSlots, @Cached CallSlotUnaryNode callSlot, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); TpSlots slots = getSlots.execute(inliningTarget, type); if (slots.nb_positive() != null) { return callSlot.execute(frame, inliningTarget, slots.nb_positive(), object); } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "+", object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary", "+", object); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java index 08567bf55d..fe4a46e0ce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java @@ -81,7 +81,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached GetCachedTpSlotsNode getVSlots, @Cached GetCachedTpSlotsNode getWSlots, @Cached CallTernaryOpNode callTernaryOpNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_power(); @@ -94,11 +94,11 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Object z, PRaiseNode.Lazy raiseNode) { + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Object z, PRaiseNode raiseNode) { if (z == PNone.NONE) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "** or pow()", v, w); + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "** or pow()", v, w); } else { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, "** or pow()", v, w, z); + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, "** or pow()", v, w, z); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index 9d1f89d2ef..e8af02f81c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -47,7 +47,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -93,7 +93,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_remainder(); @@ -108,8 +108,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "%", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "%", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index cc39873f8d..a4b7d9be6f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -51,7 +51,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -93,7 +92,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_rshift(); @@ -108,17 +107,17 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { if (v instanceof PBuiltinMethod) { handlePossiblePrint(inliningTarget, v, w); } - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, ">>", v, w); + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, ">>", v, w); } @TruffleBoundary private static void handlePossiblePrint(Node inliningTarget, Object v, Object w) { if (v instanceof PBuiltinMethod method && method.getBuiltinFunction().getName().equalsUncached(T_PRINT, TS_ENCODING)) { - throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P_PRINT, ">>", v, w); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P_PRINT, ">>", v, w); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index 0711269403..87548bc511 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -122,7 +122,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_subtract(); @@ -137,8 +137,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "-", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "-", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index f759484415..a4986c6c72 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -105,7 +105,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_true_divide(); @@ -120,8 +120,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "/", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "/", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index 06c67afdf1..a7de7a2959 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -46,7 +46,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; +import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; @@ -87,7 +87,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached GetCachedTpSlotsNode getWSlots, @Cached GetClassNode getWClass, @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_xor(); @@ -102,8 +102,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "^", v, w); + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "^", v, w); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyOSFSPathNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyOSFSPathNode.java index 9e7c546a56..dd49945815 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyOSFSPathNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyOSFSPathNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -94,17 +94,17 @@ static Object callFspath(VirtualFrame frame, Node inliningTarget, Object object, @Cached GetClassNode getClassNode, @Cached LookupSpecialMethodNode.Dynamic lookupFSPath, @Cached(inline = false) CallUnaryMethodNode callFSPath, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, object); Object fspathMethod = lookupFSPath.execute(frame, inliningTarget, type, T___FSPATH__, object); if (fspathMethod == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_STR_BYTE_OSPATHLIKE_OBJ, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_STR_BYTE_OSPATHLIKE_OBJ, object); } Object result = callFSPath.executeObject(frame, fspathMethod, object); assert !isJavaString(result); if (result instanceof TruffleString || result instanceof PString || result instanceof PBytes) { return result; } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, object, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_FSPATH_TO_RETURN_STR_OR_BYTES, object, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectAsFileDescriptor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectAsFileDescriptor.java index c3c9d73083..3efcae5e8c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectAsFileDescriptor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectAsFileDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -71,7 +71,7 @@ public abstract class PyObjectAsFileDescriptor extends PNodeWithContext { @Specialization static int doInt(Node inliningTarget, @SuppressWarnings("unused") int object, - @Exclusive @Cached PRaiseNode.Lazy raise) { + @Exclusive @Cached PRaiseNode raise) { return checkResult(object, inliningTarget, raise); } @@ -79,7 +79,7 @@ static int doInt(Node inliningTarget, @SuppressWarnings("unused") int object, static int doPyLong(VirtualFrame frame, @SuppressWarnings("unused") Node inliningTarget, Object object, @SuppressWarnings("unused") @Exclusive @Cached PyLongCheckNode longCheckNode, @Exclusive @Cached PyLongAsIntNode asIntNode, - @Exclusive @Cached PRaiseNode.Lazy raise) { + @Exclusive @Cached PRaiseNode raise) { return checkResult(asIntNode.execute(frame, inliningTarget, object), inliningTarget, raise); } @@ -89,21 +89,21 @@ static int doNotLong(VirtualFrame frame, Node inliningTarget, Object object, @Cached(inline = false) CallNode callFileno, @Exclusive @Cached PyLongCheckNode checkResultNode, @Exclusive @Cached PyLongAsIntNode asIntNode, - @Exclusive @Cached PRaiseNode.Lazy raise) { + @Exclusive @Cached PRaiseNode raise) { Object filenoMethod = lookupFileno.execute(frame, inliningTarget, object, T_FILENO); if (filenoMethod != PNone.NO_VALUE) { Object result = callFileno.execute(frame, filenoMethod); if (checkResultNode.execute(inliningTarget, result)) { return checkResult(asIntNode.execute(frame, inliningTarget, result), inliningTarget, raise); } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NON_INTEGER, "fileno()"); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_INTEGER, "fileno()"); } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.ARG_MUST_BE_INT_OR_HAVE_FILENO_METHOD); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.ARG_MUST_BE_INT_OR_HAVE_FILENO_METHOD); } - private static int checkResult(int result, Node inliningTarget, PRaiseNode.Lazy raiseNode) { + private static int checkResult(int result, Node inliningTarget, PRaiseNode raiseNode) { if (result < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.S_CANNOT_BE_NEGATIVE_INTEGER_D, "file descriptor", result); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.S_CANNOT_BE_NEGATIVE_INTEGER_D, "file descriptor", result); } return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDelItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDelItem.java index 2f5bb76803..dc74ce0ebe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDelItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDelItem.java @@ -54,6 +54,7 @@ import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; @@ -126,8 +127,8 @@ static void doSequence(VirtualFrame frame, Node inliningTarget, Object object, T @Fallback @InliningCutoff static void error(Object object, @SuppressWarnings("unused") TpSlots slots, @SuppressWarnings("unused") Object key, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_DELETION, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_DELETION, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDir.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDir.java index 2184d0bb60..93f75625cd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDir.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectDir.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -71,10 +71,10 @@ static PList dir(VirtualFrame frame, Node inliningTarget, Object object, @Cached(inline = false) ListBuiltins.ListSortNode sortNode, @Cached(inline = false) ListNodes.ConstructListNode constructListNode, @Cached(value = "create(T___DIR__)", inline = false) LookupAndCallUnaryNode callDir, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = callDir.executeObject(frame, object); if (result == PNone.NO_VALUE) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_DOES_NOT_PROVIDE_DIR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_DOES_NOT_PROVIDE_DIR); } PList list = constructListNode.execute(frame, result); sortNode.execute(frame, list); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectFormat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectFormat.java index c4c295dfea..4f8069bcbb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectFormat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -57,6 +57,7 @@ import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -120,15 +121,15 @@ static Object doLong(long obj, Object formatSpec) { // Note: PRaiseNode is @Exclusive to workaround a bug in DSL @Specialization(guards = "isString(formatSpec)") - static Object doGeneric(VirtualFrame frame, Object obj, Object formatSpec, + static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object obj, Object formatSpec, @Cached(parameters = "Format", inline = false) LookupAndCallBinaryNode callFormat, - @Exclusive @Cached(inline = false) PRaiseNode raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { Object res = callFormat.executeObject(frame, obj, formatSpec); if (res == NO_VALUE) { - throw raiseNode.raise(TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj); } if (!PGuards.isString(res)) { - throw raiseNode.raise(TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); } return res; } @@ -144,8 +145,8 @@ static Object doGenericUncached(VirtualFrame frame, Object obj, Object formatSpe // Note: PRaiseNode is @Exclusive to workaround a bug in DSL @Fallback static Object doNonStringFormat(Object obj, Object formatSpec, - @Exclusive @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.SystemError, ErrorMessages.S_MUST_BE_S_NOT_P, "Format specifier", "a string", formatSpec); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.S_MUST_BE_S_NOT_P, "Format specifier", "a string", formatSpec); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttr.java index 1cbd75ed35..d3d27ab8f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttr.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -108,7 +108,7 @@ static Object getDynamicAttr(Frame frame, Node inliningTarget, Object receiver, Object result = PyObjectLookupAttr.readAttributeQuickly(type, slots, receiver, name, codePointLengthNode, codePointAtIndexNode); if (result != null) { if (result == PNone.NO_VALUE) { - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); } return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttrO.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttrO.java index a2e0f0cd42..86d8f6da84 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttrO.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetAttrO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -84,7 +84,7 @@ static Object getDynamicAttr(Frame frame, Node inliningTarget, Object receiver, Object result = PyObjectLookupAttr.readAttributeQuickly(type, slots, receiver, tsName, codePointLengthNode, codePointAtIndexNode); if (result != null) { if (result == PNone.NO_VALUE) { - throw PRaiseNode.getUncached().raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); } return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java index fbd4580f62..d995374dc0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetItem.java @@ -157,7 +157,7 @@ static Object tryType(VirtualFrame frame, Node inliningTarget, Object maybeType, @Cached PyObjectLookupAttr lookupClassGetItem, @Cached IsBuiltinClassExactProfile isBuiltinClassProfile, @Cached(inline = false) CallNode callClassGetItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (isTypeNode.execute(inliningTarget, maybeType)) { Object classGetitem = lookupClassGetItem.execute(frame, inliningTarget, maybeType, T___CLASS_GETITEM__); if (!(classGetitem instanceof PNone)) { @@ -167,9 +167,9 @@ static Object tryType(VirtualFrame frame, Node inliningTarget, Object maybeType, // Special case type[int], but disallow other types so str[int] fails return PFactory.createGenericAlias(PythonLanguage.get(inliningTarget), maybeType, key); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_NOT_SUBSCRIPTABLE, maybeType); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_NOT_SUBSCRIPTABLE, maybeType); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, maybeType); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, maybeType); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java index 2b34a90c7a..3c800f40a5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java @@ -96,7 +96,7 @@ static Object getIter(Frame frame, Node inliningTarget, Object receiver, @Cached(parameters = "Iter", inline = false) LookupSpecialMethodSlotNode lookupIter, @Cached PySequenceCheckNode sequenceCheckNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached(inline = false) CallUnaryMethodNode callIter, @Cached PyIterCheckNode checkNode) { Object type = getReceiverClass.execute(inliningTarget, receiver); @@ -113,11 +113,11 @@ static Object getIter(Frame frame, Node inliningTarget, Object receiver, } else { Object result = callIter.executeObject(frame, iterMethod, receiver); if (!checkNode.execute(inliningTarget, result)) { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NONITER, result); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NONITER, result); } return result; } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetMethod.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetMethod.java index 3940bb317b..8b2ce62621 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetMethod.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -120,7 +120,7 @@ static Object getFixedAttr(VirtualFrame frame, Node inliningTarget, Object recei @Exclusive @Cached GetObjectSlotsNode getSlotsNode, @Exclusive @Cached CallSlotDescrGet callGetNode, @Shared("readAttr") @Cached(inline = false) ReadAttributeFromObjectNode readAttr, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached InlinedBranchProfile hasDescr, @Cached InlinedBranchProfile returnDataDescr, @Cached InlinedBranchProfile returnAttr, @@ -163,7 +163,7 @@ static Object getFixedAttr(VirtualFrame frame, Node inliningTarget, Object recei if (descr != PNone.NO_VALUE) { return new BoundDescriptor(descr); } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); } // No explicit branch profiling when we're looking up multiple things @@ -178,7 +178,7 @@ static Object getDynamicAttr(Frame frame, Node inliningTarget, Object receiver, @Exclusive @Cached GetObjectSlotsNode getSlotsNode, @Exclusive @Cached CallSlotDescrGet callGetNode, @Shared("readAttr") @Cached(inline = false) ReadAttributeFromObjectNode readAttr, - /* Truffle bug: @Shared("raiseNode") */ @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + /* Truffle bug: @Shared("raiseNode") */ @Exclusive @Cached PRaiseNode raiseNode) { boolean methodFound = false; Object descr = lookupNode.execute(lazyClass, name); TpSlot getMethod = null; @@ -208,7 +208,7 @@ static Object getDynamicAttr(Frame frame, Node inliningTarget, Object receiver, if (descr != PNone.NO_VALUE) { return new BoundDescriptor(descr); } - throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); + throw raiseNode.raise(inliningTarget, AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, receiver, name); } @Specialization(guards = "isForeignObject(inliningTarget, isForeignObjectNode, receiver)", limit = "1") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectHashNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectHashNode.java index 72334ce735..e4af870bd4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectHashNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectHashNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -166,7 +166,7 @@ static long hash(VirtualFrame frame, Node inliningTarget, Object object, @Cached MaybeBindDescriptorNode bindDescriptorNode, @Cached(inline = false) CallUnaryMethodNode callHash, @Cached CastUnsignedToJavaLongHashNode cast, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { /* This combines the logic from abstract.c:PyObject_Hash and typeobject.c:slot_tp_hash */ Object type = getClassNode.execute(inliningTarget, object); // We have to do the lookup and bind steps separately to avoid binding possible None @@ -175,16 +175,16 @@ static long hash(VirtualFrame frame, Node inliningTarget, Object object, try { hashDescr = bindDescriptorNode.execute(frame, inliningTarget, hashDescr, object, type); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNHASHABLE_TYPE_P, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNHASHABLE_TYPE_P, object); } Object result = callHash.executeObject(frame, hashDescr, object); try { return avoidNegative1(cast.execute(inliningTarget, result)); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.HASH_SHOULD_RETURN_INTEGER); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HASH_SHOULD_RETURN_INTEGER); } } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.UNHASHABLE_TYPE_P, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.UNHASHABLE_TYPE_P, object); } public static PyObjectHashNode getUncached() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java index 8dd2e460cc..640d2abfd4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -105,7 +105,7 @@ static Object repr(VirtualFrame frame, Node inliningTarget, Object obj, @Cached(inline = false) ObjectNodes.DefaultObjectReprNode defaultRepr, @Cached InlinedConditionProfile isString, @Cached InlinedConditionProfile isPString, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, obj); Object reprMethod; try { @@ -128,8 +128,8 @@ static Object repr(VirtualFrame frame, Node inliningTarget, Object obj, } @InliningCutoff - private static PException raiseTypeError(Node inliningTarget, Object obj, PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NON_STRING, T___REPR__, obj); + private static PException raiseTypeError(Node inliningTarget, Object obj, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_STRING, T___REPR__, obj); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectRichCompareBool.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectRichCompareBool.java index e2091decdc..d7e7e3ccd2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectRichCompareBool.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectRichCompareBool.java @@ -53,7 +53,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode; import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; @@ -121,7 +120,7 @@ protected boolean identityComparisonResult() { throw CompilerDirectives.shouldNotReachHere("abstract method"); } - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { throw CompilerDirectives.shouldNotReachHere("abstract method"); } } @@ -265,7 +264,7 @@ static boolean doGeneric(VirtualFrame frame, Node inliningTarget, Object a, Obje @Cached(inline = false) CallBinaryMethodNode callMethod, @Cached(inline = false) CallBinaryMethodNode callReverseMethod, @Cached PyObjectIsTrueNode isTrueNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (cmp.needsIdentityComparison()) { if (isNode.execute(a, b)) { return cmp.identityComparisonResult(); @@ -358,7 +357,7 @@ protected boolean identityComparisonResult() { } @Override - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { // Already compared for identity return false; } @@ -443,7 +442,7 @@ protected boolean identityComparisonResult() { @Override @SuppressWarnings("unused") - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { // Already compared for identity return true; } @@ -501,8 +500,8 @@ protected SpecialMethodSlot getReverseSlot() { @Override @SuppressWarnings("unused") - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, "<", a, b); + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, "<", a, b); } } @@ -556,8 +555,8 @@ protected SpecialMethodSlot getReverseSlot() { } @Override - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, "<=", a, b); + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, "<=", a, b); } } @@ -612,8 +611,8 @@ protected SpecialMethodSlot getReverseSlot() { } @Override - protected boolean doDefault(Node inliningTarget, PRaiseNode.Lazy raiseNode, Object a, Object b) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, ">", a, b); + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, ">", a, b); } } @@ -668,8 +667,8 @@ protected SpecialMethodSlot getReverseSlot() { } @Override - protected boolean doDefault(Node inliningTarget, Lazy raiseNode, Object a, Object b) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, ">=", a, b); + protected boolean doDefault(Node inliningTarget, PRaiseNode raiseNode, Object a, Object b) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, ">=", a, b); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java index f760e83822..36da362ca1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -53,7 +53,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.CallSlotSetAttrNode; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -104,7 +103,7 @@ public final void delete(Frame frame, Node inliningTarget, Object receiver, Truf static void setFixedAttr(Frame frame, Node inliningTarget, Object self, @SuppressWarnings("unused") TruffleString name, Object value, @SuppressWarnings("unused") @Cached("name") TruffleString cachedName, @Shared @Cached GetObjectSlotsNode getSlotsNode, - @Shared @Cached PRaiseNode.Lazy raise, + @Shared @Cached PRaiseNode raise, @Shared @Cached CallSlotSetAttrNode callSetAttr) { assert value != null; // should use PNone.NO_VALUE TpSlots slots = getSlotsNode.execute(inliningTarget, self); @@ -119,13 +118,13 @@ static void setFixedAttr(Frame frame, Node inliningTarget, Object self, @Suppres @InliningCutoff static void doDynamicAttr(Frame frame, Node inliningTarget, Object self, TruffleString name, Object value, @Shared @Cached GetObjectSlotsNode getSlotsNode, - @Shared @Cached PRaiseNode.Lazy raise, + @Shared @Cached PRaiseNode raise, @Shared @Cached CallSlotSetAttrNode callSetAttr) { setFixedAttr(frame, inliningTarget, self, name, value, name, getSlotsNode, raise, callSetAttr); } @InliningCutoff - static void raiseNoSlotError(Node inliningTarget, Object self, Object name, Object value, Lazy raise, TpSlots slots) { + static void raiseNoSlotError(Node inliningTarget, Object self, Object name, Object value, PRaiseNode raise, TpSlots slots) { TruffleString message; boolean isDelete = value == PNone.NO_VALUE; if (slots.combined_tp_getattro_getattr() == null) { @@ -133,7 +132,7 @@ static void raiseNoSlotError(Node inliningTarget, Object self, Object name, Obje } else { message = isDelete ? P_HAS_RO_ATTRS_S_TO_DELETE : P_HAS_RO_ATTRS_S_TO_ASSIGN; } - throw raise.get(inliningTarget).raise(TypeError, message, self, name); + throw raise.raise(inliningTarget, TypeError, message, self, name); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttrO.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttrO.java index 11f29f6414..562586b664 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttrO.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttrO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -117,11 +117,11 @@ public abstract static class PyObjectSetAttrOGeneric extends Node { static void doIt(Frame frame, Object self, Object nameObj, Object value, @Bind("this") Node inliningTarget, @Cached PyUnicodeCheckNode unicodeCheckNode, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached GetObjectSlotsNode getSlotsNode, @Cached CallSlotSetAttrONode callSetAttr) { if (!unicodeCheckNode.execute(inliningTarget, nameObj)) { - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ATTR_NAME_MUST_BE_STRING, nameObj); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ATTR_NAME_MUST_BE_STRING, nameObj); } assert value != null; // should use PNone.NO_VALUE TpSlots slots = getSlotsNode.execute(inliningTarget, self); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetItem.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetItem.java index 1b5def6586..67e44e2ca2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetItem.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetItem.java @@ -53,6 +53,7 @@ import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; @@ -133,8 +134,8 @@ static void doSequence(VirtualFrame frame, Node inliningTarget, Object object, T @Fallback @InliningCutoff static void error(Object object, @SuppressWarnings("unused") TpSlots slots, @SuppressWarnings("unused") Object key, @SuppressWarnings("unused") Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, object); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeGenericNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeGenericNode.java index c4fe6172d2..98ed0b50c5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeGenericNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeGenericNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -70,11 +70,11 @@ static int doIt(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, @Cached GetObjectSlotsNode getTpSlotsNode, @Cached TpSlotLen.CallSlotLenNode callSlotLenNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getTpSlotsNode.execute(inliningTarget, object); if (slots.combined_sq_mp_length() != null) { return callSlotLenNode.execute(frame, inliningTarget, slots.combined_sq_mp_length(), object); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_HAS_NO_LEN, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_HAS_NO_LEN, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeNode.java index c77ef6c297..612f8909b8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSizeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -146,9 +146,9 @@ static int doOthers(VirtualFrame frame, Object object, return genericNode.execute(frame, object); } - static int checkLen(PRaiseNode raiseNode, int len) { + static int checkLen(Node inliningTarget, PRaiseNode raiseNode, int len) { if (len < 0) { - throw raiseNode.raise(ValueError, ErrorMessages.LEN_SHOULD_RETURN_GT_ZERO); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.LEN_SHOULD_RETURN_GT_ZERO); } return len; } @@ -167,10 +167,10 @@ public static int convertAndCheckLen(VirtualFrame frame, Node inliningTarget, Ob * error. */ len = castLossy.execute(inliningTarget, index); - checkLen(raiseNode, len); + checkLen(inliningTarget, raiseNode, len); throw e; } - return checkLen(raiseNode, len); + return checkLen(inliningTarget, raiseNode, len); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java index dfb4dfb002..a5b7c3f35e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -116,7 +116,7 @@ static Object str(VirtualFrame frame, Node inliningTarget, Object obj, @Cached(inline = false) CallUnaryMethodNode callStr, @Cached GetClassNode getResultClassNode, @Cached(inline = false) IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object type = getClassNode.execute(inliningTarget, obj); Object strDescr = lookupStr.execute(frame, type, obj); // All our objects should have __str__ @@ -126,7 +126,7 @@ static Object str(VirtualFrame frame, Node inliningTarget, Object obj, if (result instanceof TruffleString || isSubtypeNode.execute(getResultClassNode.execute(inliningTarget, result), PythonBuiltinClassType.PString)) { return result; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.RETURNED_NON_STRING, T___STR__, result); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_STRING, T___STR__, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java index dc0c42ef60..14c8941b9d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java @@ -120,7 +120,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached InlinedBranchProfile hasNbAddSlot, @Cached InlinedBranchProfile hasNbAddResult, @Cached CallSlotBinaryFuncNode callBinarySlotNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); TpSlots slotsV = getVSlots.execute(inliningTarget, classV); if (slotsV.sq_concat() != null) { @@ -144,7 +144,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, PRaiseNode.Lazy raiseNode) { - return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, v); + private static PException raiseNotSupported(Node inliningTarget, Object v, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, v); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceDelItemNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceDelItemNode.java index bb92067feb..582aa71259 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceDelItemNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceDelItemNode.java @@ -87,7 +87,7 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object object, in @Cached GetObjectSlotsNode getSlotsNode, @Cached IndexForSqSlotInt indexForSqSlot, @Cached CallSlotSqAssItemNode callSetItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getSlotsNode.execute(inliningTarget, object); index = indexForSqSlot.execute(frame, inliningTarget, object, slots, index); if (slots.sq_ass_item() != null) { @@ -98,11 +98,11 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object object, in } @InliningCutoff - static PException raiseNotSupported(Object object, Node inliningTarget, PRaiseNode.Lazy raiseNode, TpSlots slots) { + static PException raiseNotSupported(Object object, Node inliningTarget, PRaiseNode raiseNode, TpSlots slots) { TruffleString message = ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_DELETION; if (slots.mp_subscript() != null) { message = ErrorMessages.IS_NOT_A_SEQUENCE; } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, message, object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, message, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceGetItemNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceGetItemNode.java index 33462f56a3..0a5f9164a1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceGetItemNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceGetItemNode.java @@ -52,7 +52,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; @@ -90,7 +89,7 @@ static Object doGeneric(VirtualFrame frame, Object object, int index, @Cached GetObjectSlotsNode getSlotsNode, @Cached IndexForSqSlotInt indexForSqSlot, @Cached CallSlotSizeArgFun callSqItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getSlotsNode.execute(inliningTarget, object); index = indexForSqSlot.execute(frame, inliningTarget, object, slots, index); if (slots.sq_item() != null) { @@ -101,12 +100,12 @@ static Object doGeneric(VirtualFrame frame, Object object, int index, } @InliningCutoff - private static PException raiseNotSupported(Object object, Node inliningTarget, Lazy raiseNode, TpSlots slots) { + private static PException raiseNotSupported(Object object, Node inliningTarget, PRaiseNode raiseNode, TpSlots slots) { TruffleString message = ErrorMessages.OBJ_DOES_NOT_SUPPORT_INDEXING; if (slots.mp_subscript() != null) { message = ErrorMessages.IS_NOT_A_SEQUENCE; } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, message, object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, message, object); } @GenerateInline @@ -153,9 +152,9 @@ static int doGeneric(VirtualFrame frame, Node inliningTarget, Object object, TpS @Cached PyIndexCheckNode checkNode, @Cached PyNumberAsSizeNode asSizeNode, @Exclusive @Cached IndexForSqSlotInt indexForSqSlotInt, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!checkNode.execute(inliningTarget, indexObj)) { - raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SEQUENCE_INDEX_MUST_BE_INT_NOT_P, indexObj); + raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SEQUENCE_INDEX_MUST_BE_INT_NOT_P, indexObj); } int index = asSizeNode.executeExact(frame, inliningTarget, indexObj, PythonBuiltinClassType.IndexError); return indexForSqSlotInt.execute(frame, inliningTarget, object, slots, index); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java index 8d96d229df..b95177f102 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -91,7 +91,7 @@ public final int execute(Node inliningTarget, Object container, Object key, int static int search(Frame frame, Node inliningTarget, Object container, Object key, int operation, @Cached PyObjectGetIter getIter, @Cached IsBuiltinObjectProfile noIterProfile, - @Cached PRaiseNode.Lazy raiseNode, + @Cached PRaiseNode raiseNode, @Cached GetClassNode getIterClass, @Cached(parameters = "Next", inline = false) LookupSpecialMethodSlotNode lookupIternext, @Cached IsBuiltinObjectProfile noNextProfile, @@ -104,7 +104,7 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key iterator = getIter.execute(frame, inliningTarget, container); } catch (PException e) { e.expectTypeError(inliningTarget, noIterProfile); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_CONTAINER, container); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_CONTAINER, container); } Object next = PNone.NO_VALUE; try { @@ -113,7 +113,7 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key e.expect(inliningTarget, PythonBuiltinClassType.AttributeError, noNextProfile); } if (next instanceof PNone) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); } int i = 0; int n = 0; @@ -130,7 +130,7 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1); } if (wrapped) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.OverflowError, ErrorMessages.INDEX_EXCEEDS_INT); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.INDEX_EXCEEDS_INT); } else { return i; } @@ -147,7 +147,7 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1); } if (opProfile.profile(inliningTarget, operation) == PY_ITERSEARCH_INDEX) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.X_NOT_IN_SEQUENCE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.X_NOT_IN_SEQUENCE); } return n; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSetItemNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSetItemNode.java index ae6e2e7b1f..aa3ccaab98 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSetItemNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSetItemNode.java @@ -86,7 +86,7 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object object, in @Cached GetObjectSlotsNode getSlotsNode, @Cached IndexForSqSlotInt indexForSqSlot, @Cached CallSlotSqAssItemNode callSetItem, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { TpSlots slots = getSlotsNode.execute(inliningTarget, object); index = indexForSqSlot.execute(frame, inliningTarget, object, slots, index); if (slots.sq_ass_item() != null) { @@ -97,11 +97,11 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object object, in } @InliningCutoff - static PException raiseNotSupported(Object object, Node inliningTarget, PRaiseNode.Lazy raiseNode, TpSlots slots) { + static PException raiseNotSupported(Object object, Node inliningTarget, PRaiseNode raiseNode, TpSlots slots) { TruffleString message = ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT; if (slots.mp_subscript() != null) { message = ErrorMessages.IS_NOT_A_SEQUENCE; } - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, message, object); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, message, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSizeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSizeNode.java index 652ec34014..b48b8b0a62 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSizeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceSizeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -56,7 +56,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode.Lazy; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; @@ -125,7 +124,7 @@ static int doPBytes(PBytesLike object) { static int doOthers(Frame frame, Node inliningTarget, Object object, @Cached GetObjectSlotsNode getTpSlotsNode, @Cached TpSlotLen.CallSlotLenNode callSlotLenNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { TpSlots slots = getTpSlotsNode.execute(inliningTarget, object); if (slots.sq_length() != null) { return callSlotLenNode.execute((VirtualFrame) frame, inliningTarget, slots.sq_length(), object); @@ -134,11 +133,11 @@ static int doOthers(Frame frame, Node inliningTarget, Object object, } @InliningCutoff - private static PException raiseError(Object object, Node inliningTarget, Lazy raiseNode, TpSlots slots) { + private static PException raiseError(Object object, Node inliningTarget, PRaiseNode raiseNode, TpSlots slots) { TruffleString error = ErrorMessages.OBJ_HAS_NO_LEN; if (slots.mp_length() == null) { error = ErrorMessages.IS_NOT_A_SEQUENCE; } - throw raiseNode.get(inliningTarget).raise(TypeError, error, object); + throw raiseNode.raise(inliningTarget, TypeError, error, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java index 629782b3bd..76f2d6e886 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -82,10 +82,10 @@ public enum RoundType { @Specialization static long doDouble(Node inliningTarget, double d, RoundType round, long unitToNs, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { // Implements _PyTime_FromDouble, rounding mode (HALF_UP) is hard-coded for now if (Double.isNaN(d)) { - throw raiseNode.get(inliningTarget).raise(ValueError, INVALID_VALUE_NAN); + throw raiseNode.raise(inliningTarget, ValueError, INVALID_VALUE_NAN); } double value = d * unitToNs; @@ -102,25 +102,25 @@ static long doDouble(Node inliningTarget, double d, RoundType round, long unitTo break; } if (value < Long.MIN_VALUE || value > Long.MAX_VALUE) { - throw raiseTimeOverflow(raiseNode.get(inliningTarget)); + throw raiseTimeOverflow(inliningTarget, raiseNode); } return (long) value; } @Specialization static long doLong(Node inliningTarget, long l, @SuppressWarnings("unused") RoundType round, long unitToNs, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { try { return PythonUtils.multiplyExact(l, unitToNs); } catch (OverflowException e) { - throw raiseTimeOverflow(raiseNode.get(inliningTarget)); + throw raiseTimeOverflow(inliningTarget, raiseNode); } } @Specialization static long doOther(VirtualFrame frame, Node inliningTarget, Object value, RoundType round, long unitToNs, @Cached CastToJavaDoubleNode castToDouble, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Cached PyLongAsLongAndOverflowNode asLongNode) { try { return doDouble(inliningTarget, castToDouble.execute(inliningTarget, value), round, unitToNs, raiseNode); @@ -128,12 +128,12 @@ static long doOther(VirtualFrame frame, Node inliningTarget, Object value, Round try { return doLong(inliningTarget, asLongNode.execute(frame, inliningTarget, value), round, unitToNs, raiseNode); } catch (OverflowException e1) { - throw raiseTimeOverflow(raiseNode.get(inliningTarget)); + throw raiseTimeOverflow(inliningTarget, raiseNode); } } } - private static PException raiseTimeOverflow(PRaiseNode raise) { - throw raise.raise(PythonBuiltinClassType.OverflowError, TOO_LARGE_TO_CONVERT_TO, "timestamp", "long"); + private static PException raiseTimeOverflow(Node inliningTarget, PRaiseNode raise) { + throw raise.raise(inliningTarget, PythonBuiltinClassType.OverflowError, TOO_LARGE_TO_CONVERT_TO, "timestamp", "long"); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java index 3d8e435398..27cd29be60 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTraceBackPrintNode.java @@ -44,6 +44,7 @@ import static com.oracle.graal.python.builtins.modules.io.IONodes.T_FLUSH; import static com.oracle.graal.python.builtins.modules.io.IONodes.T_WRITE; import static com.oracle.graal.python.nodes.BuiltinNames.T_TRACEBACKLIMIT; +import static com.oracle.graal.python.nodes.ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC; import static com.oracle.graal.python.nodes.StringLiterals.J_NEWLINE; import static com.oracle.graal.python.nodes.StringLiterals.T_SPACE; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -56,6 +57,7 @@ import com.oracle.graal.python.PythonFileDetector; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.code.PCode; import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; @@ -401,8 +403,8 @@ public void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, PTr @Specialization(guards = "!isPTraceback(tb)") @SuppressWarnings("unused") public void printTraceBack(VirtualFrame frame, PythonModule sys, Object out, Object tb, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raiseBadInternalCall(); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, BAD_ARG_TO_INTERNAL_FUNC); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTupleSizeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTupleSizeNode.java index b90c4c9b89..11dcd453dc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTupleSizeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTupleSizeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -54,6 +54,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; @@ -86,8 +87,8 @@ static int sizeNative(Node inliningTarget, PythonAbstractNativeObject tuple, @Fallback @InliningCutoff static int size(Object obj, - @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(SystemError, BAD_ARG_TO_INTERNAL_FUNC_S, "PyTuple_Size"); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, BAD_ARG_TO_INTERNAL_FUNC_S, "PyTuple_Size"); } protected boolean isTupleSubtype(Object obj, Node inliningTarget, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java index 7f33752253..44e1c12f05 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeAsEncodedString.java @@ -128,7 +128,7 @@ static Object doRegistry(VirtualFrame frame, Node inliningTarget, Object unicode @Cached InlinedConditionProfile isByteArrayProfile, @Cached SequenceStorageNodes.CopyNode copyNode, @Cached(inline = false) WarningsModuleBuiltins.WarnNode warnNode, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @SuppressWarnings("unused") @Shared("ts2js") @Cached(inline = false) TruffleString.ToJavaStringNode toJavaStringNode) { final Object v = encodeNode.execute(frame, unicode, encoding, errors); // the normal path @@ -141,7 +141,7 @@ static Object doRegistry(VirtualFrame frame, Node inliningTarget, Object unicode return PFactory.createBytes(PythonLanguage.get(inliningTarget), copyNode.execute(inliningTarget, ((PByteArray) v).getSequenceStorage())); } - throw raiseNode.get(inliningTarget).raise(TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, v); + throw raiseNode.raise(inliningTarget, TypeError, S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES, encoding, v); } @Specialization(guards = {"isString(unicode)", "isNoValue(encoding)"}) @@ -153,7 +153,7 @@ static Object doNoEncoding(VirtualFrame frame, Object unicode, @SuppressWarnings @Specialization(guards = "!isString(unicode)") @SuppressWarnings("unused") static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object unicode, Object encoding, Object errors, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raiseBadInternalCall(); + @Exclusive @Cached PRaiseNode raiseNode) { + throw raiseNode.raiseBadInternalCall(inliningTarget); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeDecode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeDecode.java index 4dac6d3f1a..fc22e2ecae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeDecode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeDecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -73,10 +73,10 @@ public abstract class PyUnicodeDecode extends PNodeWithContext { @Specialization(guards = "frame != null") static Object doFast(VirtualFrame frame, Node inliningTarget, Object object, Object encoding, Object errors, @Cached(inline = false) CodecsModuleBuiltins.DecodeNode decodeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { final Object unicode = decodeNode.execute(frame, object, encoding, errors); if (!PGuards.isString(unicode)) { - throw raiseNode.get(inliningTarget).raise(TypeError, DECODER_S_RETURNED_P_INSTEAD_OF_STR, encoding, unicode); + throw raiseNode.raise(inliningTarget, TypeError, DECODER_S_RETURNED_P_INSTEAD_OF_STR, encoding, unicode); } return unicode; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFSDecoderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFSDecoderNode.java index 6f73e45799..e75124026e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFSDecoderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFSDecoderNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -110,7 +110,7 @@ static TruffleString doPathLike(VirtualFrame frame, Object object, private static TruffleString checkString(Node raisingNode, TruffleString str, TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode) { if (byteIndexOfCodePointNode.execute(str, 0, 0, str.byteLength(TS_ENCODING), TS_ENCODING) >= 0) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.EMBEDDED_NULL_BYTE); } return str; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java index 70cc0d8e18..30858aa95d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeFromEncodedObject.java @@ -57,7 +57,6 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -92,15 +91,15 @@ static Object doBytes(VirtualFrame frame, Node inliningTarget, PBytes object, Ob @Specialization @SuppressWarnings("unused") static Object doString(VirtualFrame frame, TruffleString object, Object encoding, Object errors, - @Shared @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, DECODING_STR_NOT_SUPPORTED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, DECODING_STR_NOT_SUPPORTED); } @Specialization @SuppressWarnings("unused") static Object doPString(VirtualFrame frame, PString object, Object encoding, Object errors, - @Shared @Cached(inline = false) PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, DECODING_STR_NOT_SUPPORTED); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, DECODING_STR_NOT_SUPPORTED); } @Specialization(guards = {"!isPBytes(object)", "!isString(object)"}, limit = "3") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeReadCharNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeReadCharNode.java index c34ceb59ad..789eda9bee 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeReadCharNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyUnicodeReadCharNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -74,19 +74,19 @@ static int doGeneric(Node inliningTarget, Object type, long lindex, @Cached CastToTruffleStringNode castToStringNode, @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode, @Cached(inline = false) TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { TruffleString s = castToStringNode.execute(inliningTarget, type); int index = PInt.intValueExact(lindex); // avoid StringIndexOutOfBoundsException if (index < 0 || index >= codePointLengthNode.execute(s, TS_ENCODING)) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } return codePointAtIndexNode.execute(s, index, TS_ENCODING); } catch (CannotCastException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java index 5cf3878eec..c6b7288a57 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java @@ -41,129 +41,165 @@ package com.oracle.graal.python.nodes; import static com.oracle.graal.python.nodes.ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC; -import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.exception.PBaseException; -import com.oracle.graal.python.nodes.PRaiseNodeGen.LazyNodeGen; +import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; -@ImportStatic(PGuards.class) +@GenerateInline +@GenerateCached(false) @GenerateUncached -@SuppressWarnings("truffle-inlining") // footprint reduction 32 -> 13 public abstract class PRaiseNode extends Node { - public final PException execute(Node raisingNode, PythonBuiltinClassType type, Object cause, Object format, Object[] arguments) { - return execute(raisingNode, type, null, cause, format, arguments); + protected abstract void executeEnterProfile(Node inliningTarget); + + @Specialization + static void doProfile(Node inliningTarget, + @Cached InlinedBranchProfile profile) { + profile.enter(inliningTarget); } - public abstract PException execute(Node raisingNode, PythonBuiltinClassType type, Object[] data, Object cause, Object format, Object[] arguments); + public final PException raise(Node inliningTarget, PythonBuiltinClassType type) { + executeEnterProfile(inliningTarget); + throw raiseStatic(inliningTarget, type); + } - public final PException raise(PythonBuiltinClassType type) { - throw execute(this, type, null, PNone.NO_VALUE, PNone.NO_VALUE, PythonUtils.EMPTY_OBJECT_ARRAY); + public static PException raiseStatic(Node node, PythonBuiltinClassType type) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raise(PythonBuiltinClassType type, TruffleString message) { - throw execute(this, type, null, PNone.NO_VALUE, message, PythonUtils.EMPTY_OBJECT_ARRAY); + public final PException raise(Node inliningTarget, PythonBuiltinClassType type, TruffleString message) { + executeEnterProfile(inliningTarget); + throw raiseStatic(inliningTarget, type, message); } - public final PException raise(PythonBuiltinClassType type, TruffleString format, Object... arguments) { - throw execute(this, type, null, PNone.NO_VALUE, format, arguments); + public static PException raiseStatic(Node node, PythonBuiltinClassType type, TruffleString message) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, message); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raise(PythonBuiltinClassType type, Object[] arguments) { - throw execute(this, type, null, PNone.NO_VALUE, PNone.NO_VALUE, arguments); + public final PException raise(Node inliningTarget, PythonBuiltinClassType type, TruffleString format, Object... formatArgs) { + executeEnterProfile(inliningTarget); + throw raiseStatic(inliningTarget, type, format, formatArgs); } - public final PException raiseWithData(PythonBuiltinClassType type, Object[] data, Object... arguments) { - throw execute(this, type, data, PNone.NO_VALUE, PNone.NO_VALUE, arguments); + public static PException raiseStatic(Node node, PythonBuiltinClassType type, TruffleString message, Object... formatArgs) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, message, formatArgs); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raise(PythonBuiltinClassType type, Exception e) { - throw execute(this, type, null, PNone.NO_VALUE, getMessage(e), PythonUtils.EMPTY_OBJECT_ARRAY); + public final PException raise(Node inliningTarget, PythonBuiltinClassType type, Object[] arguments) { + executeEnterProfile(inliningTarget); + throw raiseStatic(inliningTarget, type, arguments); } - public final PException raiseWithCause(PythonBuiltinClassType type, Object cause, TruffleString format, Object... arguments) { - throw execute(this, type, null, cause, format, arguments); + public static PException raiseStatic(Node node, PythonBuiltinClassType type, Object[] arguments) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, PFactory.createTuple(language, arguments)); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raiseWithCause(PythonBuiltinClassType errorType, PException e, TruffleString message, Object... arguments) { - return raiseWithCause(errorType, e.getEscapedException(), message, arguments); + public final PException raiseWithData(Node inliningTarget, PythonBuiltinClassType type, Object[] data) { + executeEnterProfile(inliningTarget); + throw raiseWithDataStatic(inliningTarget, type, data); } - public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType exceptionType) { - throw PRaiseNodeGen.getUncached().execute(raisingNode, exceptionType, null, PNone.NO_VALUE, PNone.NO_VALUE, PythonUtils.EMPTY_OBJECT_ARRAY); + public static PException raiseWithDataStatic(Node node, PythonBuiltinClassType type, Object[] data) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, data, null); + throw raiseExceptionObject(node, pythonException, language); } - public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType exceptionType, TruffleString message) { - throw PRaiseNodeGen.getUncached().execute(raisingNode, exceptionType, null, PNone.NO_VALUE, assertNoJavaString(message), PythonUtils.EMPTY_OBJECT_ARRAY); + public final PException raiseWithData(Node inliningTarget, PythonBuiltinClassType type, Object[] data, Object... arguments) { + executeEnterProfile(inliningTarget); + throw raiseWithDataStatic(inliningTarget, type, data, arguments); } - public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType type, TruffleString format, Object... arguments) { - throw PRaiseNodeGen.getUncached().execute(raisingNode, type, null, PNone.NO_VALUE, format, arguments); + public static PException raiseWithDataStatic(Node node, PythonBuiltinClassType type, Object[] data, Object[] arguments) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, data, PFactory.createTuple(language, arguments)); + throw raiseExceptionObject(node, pythonException, language); } - public static PException raiseUncached(Node raisingNode, PythonBuiltinClassType type, Exception e) { - throw PRaiseNodeGen.getUncached().execute(raisingNode, type, null, PNone.NO_VALUE, getMessage(e), PythonUtils.EMPTY_OBJECT_ARRAY); + public final PException raise(Node inliningTarget, PythonBuiltinClassType type, Exception e) { + executeEnterProfile(inliningTarget); + throw raiseStatic(inliningTarget, type, e); } - /** - * Raise an error saying that the {@code result} cannot fit into an index-sized integer. Use the - * specified {@code type} as exception class. - */ - public final PException raiseNumberTooLarge(PythonBuiltinClassType type, Object result) { - return execute(this, type, null, PNone.NO_VALUE, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, new Object[]{result}); + public static PException raiseStatic(Node node, PythonBuiltinClassType type, Exception e) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, ErrorMessages.M, new Object[]{e}); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raiseOverflow() { - return raiseNumberTooLarge(OverflowError, 0); + private static void setCause(PBaseException pythonException, PException cause) { + // _PyErr_FormatFromCause sets both cause and context + Object causePythonException = cause.getEscapedException(); + pythonException.setCause(causePythonException); + pythonException.setContext(causePythonException); } - public final PException raiseSystemExit(Object code) { - return raiseWithData(PythonBuiltinClassType.SystemExit, new Object[]{code}, code); + public final PException raiseWithCause(Node inliningTarget, PythonBuiltinClassType type, PException cause, TruffleString format) { + executeEnterProfile(inliningTarget); + throw raiseWithCauseStatic(inliningTarget, type, cause, format); } - public final PException raiseStopIteration() { - return raise(PythonBuiltinClassType.StopIteration); + public static PException raiseWithCauseStatic(Node node, PythonBuiltinClassType type, PException cause, TruffleString format) { + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, format); + setCause(pythonException, cause); + throw raiseExceptionObject(node, pythonException, language); } - public final PException raiseStopIteration(Object value) { - final Object retVal = value != null ? value : PNone.NONE; - final Object[] args = {retVal}; - return raiseWithData(PythonBuiltinClassType.StopIteration, args, retVal); + public final PException raiseWithCause(Node inliningTarget, PythonBuiltinClassType type, PException cause, TruffleString format, Object... arguments) { + assert PyExceptionInstanceCheckNode.executeUncached(cause); + executeEnterProfile(inliningTarget); + throw raiseWithCauseStatic(inliningTarget, type, cause, format, arguments); + } + + public static PException raiseWithCauseStatic(Node node, PythonBuiltinClassType type, PException cause, TruffleString format, Object... formatArgs) { + assert PyExceptionInstanceCheckNode.executeUncached(cause); + PythonLanguage language = PythonLanguage.get(node); + PBaseException pythonException = PFactory.createBaseException(language, type, format, formatArgs); + setCause(pythonException, cause); + throw raiseExceptionObject(node, pythonException, language); + } + + public final PException raiseOverflow(Node inliningTarget) { + throw raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, 0); } - public final PException raiseIntegerInterpretationError(Object result) { - return raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, result); + public static PException raiseSystemExitStatic(Node inliningTarget, Object code) { + throw raiseWithDataStatic(inliningTarget, PythonBuiltinClassType.SystemExit, new Object[]{code}, new Object[]{code}); } - public final PException raiseBadInternalCall() { - return raise(PythonBuiltinClassType.SystemError, BAD_ARG_TO_INTERNAL_FUNC); + public final PException raiseStopIteration(Node inliningTarget, Object value) { + final Object retVal = value != null ? value : PNone.NONE; + final Object[] args = {retVal}; + throw raiseWithData(inliningTarget, PythonBuiltinClassType.StopIteration, args, retVal); } - public final PException raiseMemoryError() { - return raise(PythonBuiltinClassType.MemoryError); + public final PException raiseBadInternalCall(Node inliningTarget) { + throw raise(inliningTarget, PythonBuiltinClassType.SystemError, BAD_ARG_TO_INTERNAL_FUNC); } public final PException raiseExceptionObject(Object exc) { @@ -174,6 +210,10 @@ public static PException raiseExceptionObject(Node raisingNode, Object exc) { throw raiseExceptionObject(raisingNode, exc, PythonOptions.isPExceptionWithJavaStacktrace(PythonLanguage.get(raisingNode))); } + public static PException raiseExceptionObject(Node raisingNode, Object exc, PythonLanguage language) { + throw raiseExceptionObject(raisingNode, exc, PythonOptions.isPExceptionWithJavaStacktrace(language)); + } + public static PException raiseExceptionObject(Node raisingNode, Object exc, boolean withJavaStacktrace) { if (raisingNode != null && raisingNode.isAdoptable()) { throw PException.fromObject(exc, raisingNode, withJavaStacktrace); @@ -182,93 +222,7 @@ public static PException raiseExceptionObject(Node raisingNode, Object exc, bool } } - @Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0", "exceptionType == cachedType"}, limit = "8") - static PException doPythonBuiltinTypeCached(Node raisingNode, @SuppressWarnings("unused") PythonBuiltinClassType exceptionType, Object[] data, @SuppressWarnings("unused") PNone cause, - @SuppressWarnings("unused") PNone format, - @SuppressWarnings("unused") Object[] arguments, - @Cached("exceptionType") PythonBuiltinClassType cachedType, - @Bind PythonLanguage language) { - throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, cachedType, data)); - } - - @Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length == 0"}, replaces = "doPythonBuiltinTypeCached") - static PException doPythonBuiltinType(Node raisingNode, PythonBuiltinClassType exceptionType, Object[] data, @SuppressWarnings("unused") PNone cause, - @SuppressWarnings("unused") PNone format, - @SuppressWarnings("unused") Object[] arguments, - @Bind PythonLanguage language) { - throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, exceptionType, data)); - } - - @Specialization(guards = {"isNoValue(cause)", "isNoValue(format)", "arguments.length > 0"}) - static PException doBuiltinType(Node raisingNode, PythonBuiltinClassType type, Object[] data, @SuppressWarnings("unused") PNone cause, @SuppressWarnings("unused") PNone format, - Object[] arguments, - @Bind PythonLanguage language, - @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { - ensureNoJavaStrings(arguments, fromJavaStringNode); - throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, type, data, PFactory.createTuple(language, arguments))); - } - - @Specialization(guards = {"isNoValue(cause)"}) - static PException doBuiltinType(Node raisingNode, PythonBuiltinClassType type, Object[] data, @SuppressWarnings("unused") PNone cause, TruffleString format, Object[] arguments, - @Bind PythonLanguage language, - @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { - assert format != null; - ensureNoJavaStrings(arguments, fromJavaStringNode); - throw raiseExceptionObject(raisingNode, PFactory.createBaseException(language, type, data, format, arguments)); - } - - @Specialization(guards = {"!isNoValue(cause)"}) - static PException doBuiltinTypeWithCause(Node raisingNode, PythonBuiltinClassType type, Object[] data, PBaseException cause, TruffleString format, Object[] arguments, - @Bind PythonLanguage language, - @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode) { - assert format != null; - ensureNoJavaStrings(arguments, fromJavaStringNode); - PBaseException baseException = PFactory.createBaseException(language, type, data, format, arguments); - baseException.setContext(cause); - baseException.setCause(cause); - throw raiseExceptionObject(raisingNode, baseException); - } - - @TruffleBoundary - private static TruffleString getMessage(Exception e) { - String msg = e.getMessage(); - return toTruffleStringUncached(msg != null ? msg : e.getClass().getSimpleName()); - } - - @NeverDefault - public static PRaiseNode create() { - return PRaiseNodeGen.create(); - } - public static PRaiseNode getUncached() { return PRaiseNodeGen.getUncached(); } - - private static void ensureNoJavaStrings(Object[] arguments, TruffleString.FromJavaStringNode fromJavaStringNode) { - for (int i = 0; i < arguments.length; i++) { - if (arguments[i] instanceof String) { - arguments[i] = fromJavaStringNode.execute((String) arguments[i], TS_ENCODING); - } - } - } - - @GenerateInline - @GenerateUncached - @GenerateCached(false) - public abstract static class Lazy extends Node { - public static Lazy getUncached() { - return LazyNodeGen.getUncached(); - } - - public final PRaiseNode get(Node inliningTarget) { - return execute(inliningTarget); - } - - abstract PRaiseNode execute(Node inliningTarget); - - @Specialization - static PRaiseNode doIt(@Cached(inline = false) PRaiseNode node) { - return node; - } - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java index 162112edf4..12e133ff45 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/CreateArgumentsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -407,6 +407,7 @@ public abstract PException execute(Object[] scope_w, Object callable, Signature @ExplodeLoop static PException doCached(Object[] scope_w, Object callable, Signature signature, int co_argcount, @SuppressWarnings("unused") int co_kwonlyargcount, int ndefaults, int avail, boolean methodcall, int adjustCount, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raise, @Shared @Cached TruffleString.EqualNode equalNode, @Cached("co_kwonlyargcount") int cachedKwOnlyArgCount) { @@ -418,11 +419,12 @@ static PException doCached(Object[] scope_w, Object callable, Signature signatur } boolean forgotSelf = methodcall && avail + 1 == co_argcount && (signature.getParameterIds().length == 0 || !equalNode.execute(signature.getParameterIds()[0], T_SELF, TS_ENCODING)); TruffleString name = signature.getRaiseErrorName().isEmpty() ? getName(callable) : signature.getRaiseErrorName(); - throw raiseTooManyArguments(name, co_argcount - adjustCount, ndefaults, avail - adjustCount, forgotSelf, kwonly_given, raise); + throw raiseTooManyArguments(inliningTarget, name, co_argcount - adjustCount, ndefaults, avail - adjustCount, forgotSelf, kwonly_given, raise); } @Specialization(replaces = "doCached") static PException doUncached(Object[] scope_w, Object callable, Signature signature, int co_argcount, int co_kwonlyargcount, int ndefaults, int avail, boolean methodcall, int adjustCount, + @Bind("this") Node inliningTarget, @Shared @Cached PRaiseNode raise, @Shared @Cached TruffleString.EqualNode equalNode) { int kwonly_given = 0; @@ -433,14 +435,14 @@ static PException doUncached(Object[] scope_w, Object callable, Signature signat } boolean forgotSelf = methodcall && avail + 1 == co_argcount && (signature.getParameterIds().length == 0 || !equalNode.execute(signature.getParameterIds()[0], T_SELF, TS_ENCODING)); TruffleString name = signature.getRaiseErrorName().isEmpty() ? getName(callable) : signature.getRaiseErrorName(); - throw raiseTooManyArguments(name, co_argcount - adjustCount, ndefaults, avail - adjustCount, forgotSelf, kwonly_given, raise); + throw raiseTooManyArguments(inliningTarget, name, co_argcount - adjustCount, ndefaults, avail - adjustCount, forgotSelf, kwonly_given, raise); } - private static PException raiseTooManyArguments(TruffleString name, int co_argcount, int ndefaults, int avail, boolean forgotSelf, int kwonly_given, PRaiseNode raise) { + private static PException raiseTooManyArguments(Node inliningTarget, TruffleString name, int co_argcount, int ndefaults, int avail, boolean forgotSelf, int kwonly_given, PRaiseNode raise) { String forgotSelfMsg = forgotSelf ? ". Did you forget 'self' in the function definition?" : ""; if (ndefaults > 0) { if (kwonly_given == 0) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_S_GIVEN_S, + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_S_GIVEN_S, name, co_argcount - ndefaults, co_argcount, @@ -449,7 +451,7 @@ private static PException raiseTooManyArguments(TruffleString name, int co_argco avail == 1 ? "was" : "were", forgotSelfMsg); } else { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_POS_ARG_S, + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_POS_ARG_S, name, co_argcount - ndefaults, co_argcount, @@ -462,7 +464,7 @@ private static PException raiseTooManyArguments(TruffleString name, int co_argco } } else { if (kwonly_given == 0) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_D_POS_ARG_S_BUT_GIVEN_S, + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_D_POS_ARG_S_BUT_GIVEN_S, name, co_argcount - ndefaults, co_argcount == 1 ? "" : "s", @@ -470,7 +472,7 @@ private static PException raiseTooManyArguments(TruffleString name, int co_argco avail == 1 ? "was" : "were", forgotSelfMsg); } else { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_D_POS_ARG_S_BUT_D_POS_ARG_S, + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.TAKES_D_POS_ARG_S_BUT_D_POS_ARG_S, name, co_argcount, co_argcount == 1 ? "" : "s", @@ -501,10 +503,10 @@ static void doEnclosingTypeCheck(Node inliningTarget, @SuppressWarnings("unused" @Bind("getSelf(scope_w)") Object self, @Cached GetClassNode getClassNode, @Cached(inline = false) IsSubtypeNode isSubtypeMRONode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (!isSubtypeMRONode.execute(getClassNode.execute(inliningTarget, self), callable.getEnclosingType())) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.DESCR_S_FOR_P_OBJ_DOESNT_APPLY_TO_P, + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.DESCR_S_FOR_P_OBJ_DOESNT_APPLY_TO_P, callable.getName(), callable.getEnclosingType(), self); } } @@ -623,7 +625,7 @@ static Object[] applyCached(Object callee, @SuppressWarnings("unused") Signature } } else { if (PArguments.getArgument(arguments, kwIdx) != null) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_PAREN_GOT_MULTIPLE_VALUES_FOR_ARG, CreateArgumentsNode.getName(callee), name); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_PAREN_GOT_MULTIPLE_VALUES_FOR_ARG, CreateArgumentsNode.getName(callee), name); } PArguments.setArgument(arguments, kwIdx, kwArg.getValue()); } @@ -679,7 +681,7 @@ static Object[] applyUncached(Object callee, Signature calleeSignature, Object[] } } else { if (PArguments.getArgument(arguments, kwIdx) != null) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_PAREN_GOT_MULTIPLE_VALUES_FOR_ARG, CreateArgumentsNode.getName(callee), name); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_PAREN_GOT_MULTIPLE_VALUES_FOR_ARG, CreateArgumentsNode.getName(callee), name); } PArguments.setArgument(arguments, kwIdx, kwArg.getValue()); } @@ -709,13 +711,13 @@ private static List addPosArgOnlyPassedAsKeyword(List posArgOnlyPassedAsKeywordNames, Node inliningTarget, InlinedBranchProfile posArgOnlyPassedAsKeywordProfile, PRaiseNode raise) { if (tooManyKeywords == 1) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.GOT_UNEXPECTED_KEYWORD_ARG, CreateArgumentsNode.getName(callee), lastWrongKeyword); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.GOT_UNEXPECTED_KEYWORD_ARG, CreateArgumentsNode.getName(callee), lastWrongKeyword); } else if (tooManyKeywords > 1) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.GOT_UNEXPECTED_KEYWORD_ARG, CreateArgumentsNode.getName(callee), tooManyKeywords); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.GOT_UNEXPECTED_KEYWORD_ARG, CreateArgumentsNode.getName(callee), tooManyKeywords); } else if (posArgOnlyPassedAsKeywordNames != null) { posArgOnlyPassedAsKeywordProfile.enter(inliningTarget); TruffleString names = joinUncached(T_COMMA_SPACE, posArgOnlyPassedAsKeywordNames); - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.GOT_SOME_POS_ONLY_ARGS_PASSED_AS_KEYWORD, CreateArgumentsNode.getName(callee), names); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.GOT_SOME_POS_ONLY_ARGS_PASSED_AS_KEYWORD, CreateArgumentsNode.getName(callee), names); } else if (unusedKeywords != null) { PArguments.setKeywordArguments(arguments, Arrays.copyOf(unusedKeywords, unusedKeywordCount)); } @@ -771,8 +773,8 @@ static int uncached(TruffleString[] parameters, TruffleString name, protected abstract static class FillBaseNode extends PNodeWithContext { - protected static PException raiseMissing(Object callable, TruffleString[] missingNames, int missingCnt, TruffleString type, PRaiseNode raise) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_S, + protected static PException raiseMissing(Node inliningTarget, Object callable, TruffleString[] missingNames, int missingCnt, TruffleString type, PRaiseNode raise) { + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.MISSING_D_REQUIRED_S_ARGUMENT_S_S, getName(callable), missingCnt, type, @@ -849,7 +851,7 @@ static void doCached(Object callable, Signature signature, Object[] scope_w, Obj } } if (missingProfile.profile(inliningTarget, missingCnt > 0)) { - throw raiseMissing(callable, missingNames, missingCnt, toTruffleStringUncached("positional"), raise); + throw raiseMissing(inliningTarget, callable, missingNames, missingCnt, toTruffleStringUncached("positional"), raise); } } @@ -873,7 +875,7 @@ static void doUncached(Object callable, Signature signature, Object[] scope_w, O } } if (missingProfile.profile(inliningTarget, missingCnt > 0)) { - throw raiseMissing(callable, missingNames, missingCnt, toTruffleStringUncached("positional"), raise); + throw raiseMissing(inliningTarget, callable, missingNames, missingCnt, toTruffleStringUncached("positional"), raise); } } } @@ -904,7 +906,7 @@ protected abstract static class FillKwDefaultsNode extends FillBaseNode { static void doCached(Object callable, Object[] scope_w, Signature signature, PKeyword[] kwdefaults, @SuppressWarnings("unused") int co_argcount, @SuppressWarnings("unused") int co_kwonlyargcount, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raise, + @Exclusive @Cached PRaiseNode raise, @Exclusive @Cached FindKwDefaultNode findKwDefaultNode, @Cached("co_argcount") int cachedArgcount, @Cached("co_kwonlyargcount") int cachedKwOnlyArgcount, @@ -925,14 +927,14 @@ static void doCached(Object callable, Object[] scope_w, Signature signature, PKe } } if (missingProfile.profile(inliningTarget, missingCnt > 0)) { - throw raiseMissing(callable, missingNames, missingCnt, toTruffleStringUncached("keyword-only"), raise.get(inliningTarget)); + throw raiseMissing(inliningTarget, callable, missingNames, missingCnt, toTruffleStringUncached("keyword-only"), raise); } } @Specialization(replaces = "doCached") static void doUncached(Object callable, Object[] scope_w, Signature signature, PKeyword[] kwdefaults, int co_argcount, int co_kwonlyargcount, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raise, + @Exclusive @Cached PRaiseNode raise, @Exclusive @Cached FindKwDefaultNode findKwDefaultNode, @Exclusive @Cached InlinedConditionProfile missingProfile) { TruffleString[] missingNames = new TruffleString[co_kwonlyargcount]; @@ -951,7 +953,7 @@ static void doUncached(Object callable, Object[] scope_w, Signature signature, P } } if (missingProfile.profile(inliningTarget, missingCnt > 0)) { - throw raiseMissing(callable, missingNames, missingCnt, toTruffleStringUncached("keyword-only"), raise.get(inliningTarget)); + throw raiseMissing(inliningTarget, callable, missingNames, missingCnt, toTruffleStringUncached("keyword-only"), raise); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ExpandKeywordStarargsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ExpandKeywordStarargsNode.java index 4e62c70612..76e6d8b836 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ExpandKeywordStarargsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ExpandKeywordStarargsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -75,13 +75,13 @@ static PKeyword[] convert(@SuppressWarnings("unused") Object starargs) { @Specialization(guards = "!isNoValue(starargs)") static PKeyword[] convert(VirtualFrame frame, Node inliningTarget, Object starargs, @Cached MappingToKeywordsNode convertNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return convertNode.execute(frame, inliningTarget, starargs); } catch (SameDictKeyException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.GOT_MULTIPLE_VALUES_FOR_KEYWORD_ARG, e.getKey()); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.GOT_MULTIPLE_VALUES_FOR_KEYWORD_ARG, e.getKey()); } catch (NonMappingException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_ISNT_MAPPING, starargs); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.OBJ_ISNT_MAPPING, starargs); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java index 9f94f25a8c..23206eb134 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -118,7 +118,7 @@ public CopyKeywordsState add(Frame frame, @SuppressWarnings("unused") Node node, try { state.addKeyword(castToTruffleStringNode.execute(inliningTarget, key), value); } catch (CannotCastException e) { - throw raiseNode.raise(TypeError, ErrorMessages.KEYWORDS_S_MUST_BE_STRINGS); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.KEYWORDS_S_MUST_BE_STRINGS); } return state; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java index c9b2e9118e..e6e59a5326 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -118,14 +118,14 @@ static Object[] doSet(PSet starargs, @Specialization static Object[] doNone(PNone none, - @Shared("raise") @Cached PRaiseNode raise) { - throw raise.raise(PythonErrorType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_ITERABLE, none); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_ITERABLE, none); } @Specialization static Object[] starargs(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, - @Shared("raise") @Cached PRaiseNode raise, + @Cached PRaiseNode raise, @Cached PyObjectGetIter getIter, @Cached GetNextNode nextNode, @Cached IsBuiltinObjectProfile errorProfile) { @@ -141,7 +141,7 @@ static Object[] starargs(VirtualFrame frame, Object object, } } } - throw raise.raise(PythonErrorType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_ITERABLE, object); + throw raise.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_ITERABLE, object); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/release_callback/ArrowSchemaReleaseCallbackNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/release_callback/ArrowSchemaReleaseCallbackNode.java index c7063bc21a..b2e5c0e079 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/release_callback/ArrowSchemaReleaseCallbackNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/release_callback/ArrowSchemaReleaseCallbackNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -40,6 +40,9 @@ */ package com.oracle.graal.python.nodes.arrow.release_callback; +import static com.oracle.graal.python.nodes.ErrorMessages.ARROW_SCHEMA_ALREADY_RELEASED; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; + import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.arrow.ArrowSchema; import com.oracle.graal.python.runtime.PythonContext; @@ -50,9 +53,6 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.nodes.Node; -import static com.oracle.graal.python.nodes.ErrorMessages.ARROW_SCHEMA_ALREADY_RELEASED; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; - @GenerateCached(false) @GenerateInline @GenerateUncached @@ -62,9 +62,9 @@ public abstract class ArrowSchemaReleaseCallbackNode extends Node { @Specialization static void release(Node inliningTarget, ArrowSchema arrowSchema, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (arrowSchema.isReleased()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ARROW_SCHEMA_ALREADY_RELEASED); + throw raiseNode.raise(inliningTarget, ValueError, ARROW_SCHEMA_ALREADY_RELEASED); } var unsafe = PythonContext.get(inliningTarget).getUnsafe(); /* diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/vector/VectorArrowArrayReleaseCallback.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/vector/VectorArrowArrayReleaseCallback.java index 286334f1a5..a2088bb291 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/vector/VectorArrowArrayReleaseCallback.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/arrow/vector/VectorArrowArrayReleaseCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -40,6 +40,9 @@ */ package com.oracle.graal.python.nodes.arrow.vector; +import static com.oracle.graal.python.nodes.ErrorMessages.ARROW_ARRAY_ALREADY_RELEASED; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; + import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.arrow.ArrowArray; @@ -54,9 +57,6 @@ import com.oracle.truffle.api.library.ExportMessage; import com.oracle.truffle.api.nodes.Node; -import static com.oracle.graal.python.nodes.ErrorMessages.ARROW_ARRAY_ALREADY_RELEASED; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; - @ExportLibrary(InteropLibrary.class) public class VectorArrowArrayReleaseCallback implements TruffleObject { @@ -71,10 +71,10 @@ static class Execute { @Specialization(guards = "validateArgs(args)") static Object doRelease(VectorArrowArrayReleaseCallback self, Object[] args, @Bind("$node") Node inliningTarget, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { ArrowArray arrowArray = ArrowArray.wrap((long) args[0]); if (arrowArray.isReleased()) { - throw raiseNode.get(inliningTarget).raise(ValueError, ARROW_ARRAY_ALREADY_RELEASED); + throw raiseNode.raise(inliningTarget, ValueError, ARROW_ARRAY_ALREADY_RELEASED); } arrowArray.markReleased(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java index 012300b2b4..f2ebdb7050 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -151,7 +151,7 @@ boolean writeToDynamicStorageBuiltinType(PythonBuiltinClass klass, TruffleString @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared("cpAtIndex") @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode) { if (PythonContext.get(this).isInitialized()) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, klass); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, klass); } else { return writeToDynamicStorageManagedClass(klass, key, value, inliningTarget, callAttrUpdate, dylib, codePointLengthNode, codePointAtIndexNode); } @@ -210,7 +210,7 @@ boolean writeToDictBuiltinType(PythonBuiltinClass klass, TruffleString key, Obje @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Shared("cpAtIndex") @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode) { if (PythonContext.get(this).isInitialized()) { - throw PRaiseNode.raiseUncached(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(key), klass); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, PyObjectReprAsTruffleStringNode.executeUncached(key), klass); } else { return writeToDictManagedClass(klass, dict, key, value, inliningTarget, callAttrUpdate, updateStorage, setHashingStorageItem, codePointLengthNode, codePointAtIndexNode); } @@ -292,7 +292,7 @@ static boolean writeNativeObject(PythonAbstractNativeObject object, TruffleStrin @Shared("getDict") @Cached GetDictIfExistsNode getDict, @Shared("setHashingStorageItem") @Cached HashingStorageSetItem setHashingStorageItem, @Shared("updateStorage") @Cached InlinedBranchProfile updateStorage, - @Shared("raiseNode") @Cached PRaiseNode raiseNode) { + @Cached PRaiseNode raiseNode) { /* * The dict of native objects that stores the object attributes is located at 'objectPtr * + Py_TYPE(objectPtr)->tp_dictoffset'. 'PythonObjectLibrary.getDict' will exactly load @@ -302,14 +302,14 @@ static boolean writeNativeObject(PythonAbstractNativeObject object, TruffleStrin if (dict != null) { return writeToDict(dict, key, value, inliningTarget, updateStorage, setHashingStorageItem); } - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } @Specialization(guards = "isErrorCase(getDict, object)") static boolean doError(Object object, TruffleString key, @SuppressWarnings("unused") Object value, @SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict, - @Shared("raiseNode") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } } @@ -318,12 +318,12 @@ static boolean doError(Object object, TruffleString key, @SuppressWarnings("unus @GenerateInline(false) // footprint reduction 132 -> 115 protected abstract static class WriteAttributeToObjectTpDictNode extends WriteAttributeToObjectNode { - private static void checkNativeImmutable(PythonAbstractNativeObject object, TruffleString key, + private static void checkNativeImmutable(Node inliningTarget, PythonAbstractNativeObject object, TruffleString key, CStructAccess.ReadI64Node getNativeFlags, PRaiseNode raiseNode) { long flags = getNativeFlags.readFromObj(object, CFields.PyTypeObject__tp_flags); if ((flags & TypeFlags.IMMUTABLETYPE) != 0) { - throw raiseNode.raise(TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, object); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, object); } } @@ -341,7 +341,7 @@ static boolean writeNativeClassSimple(PythonAbstractNativeObject object, Truffle @Shared("raiseNode") @Cached PRaiseNode raiseNode, @SuppressWarnings("unused") @Shared("cpLen") @Cached TruffleString.CodePointLengthNode codePointLengthNode, @SuppressWarnings("unused") @Shared("cpAtIndex") @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode) { - checkNativeImmutable(object, key, getNativeFlags, raiseNode); + checkNativeImmutable(inliningTarget, object, key, getNativeFlags, raiseNode); /* * For native types, the type attributes are stored in a dict that is located in * 'typePtr->tp_dict'. So, this is different to a native object (that is not a type) and @@ -352,7 +352,7 @@ static boolean writeNativeClassSimple(PythonAbstractNativeObject object, Truffle if (dict instanceof PDict) { return writeToDict((PDict) dict, key, value, inliningTarget, updateStorage, setHashingStorageItem); } - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } @Specialization(replaces = "writeNativeClassSimple") @@ -369,7 +369,7 @@ static boolean writeNativeClassGeneric(PythonAbstractNativeObject object, Truffl @Shared("cpAtIndex") @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, @Cached TruffleString.EqualNode equalNode) { try { - checkNativeImmutable(object, key, getNativeFlags, raiseNode); + checkNativeImmutable(inliningTarget, object, key, getNativeFlags, raiseNode); /* * For native types, the type attributes are stored in a dict that is located in * 'typePtr->tp_dict'. So, this is different to a native object (that is not a type) @@ -380,7 +380,7 @@ static boolean writeNativeClassGeneric(PythonAbstractNativeObject object, Truffl if (dict instanceof PDict) { return writeToDict((PDict) dict, key, value, inliningTarget, updateStorage, setHashingStorageItem); } - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } finally { if (TpSlots.canBeSpecialMethod(key, codePointLengthNode, codePointAtIndexNode)) { canBeSpecialSlot.enter(inliningTarget); @@ -403,8 +403,8 @@ static boolean writeNativeClassGeneric(PythonAbstractNativeObject object, Truffl @Specialization(guards = "isErrorCase(getDict, object)") static boolean doError(Object object, TruffleString key, @SuppressWarnings("unused") Object value, @SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict, - @Shared("raiseNode") @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java index 14f01bf355..bb5d974679 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java @@ -119,9 +119,8 @@ static SequenceStorage doForeign(Node inliningTarget, Object seq, } @Fallback - static SequenceStorage doFallback(Node inliningTarget, Object seq, - @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "list", seq); + static SequenceStorage doFallback(Node inliningTarget, Object seq) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P, "list", seq); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/AbstractKwargsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/AbstractKwargsNode.java index 49408f54df..251ea87c36 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/AbstractKwargsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/AbstractKwargsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -49,16 +49,17 @@ import com.oracle.graal.python.nodes.argument.keywords.SameDictKeyException; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; public class AbstractKwargsNode extends PNodeWithContext { - protected static PException handleNonMapping(VirtualFrame frame, PRaiseNode raise, int stackTop, NonMappingException e) { + protected static PException handleNonMapping(VirtualFrame frame, Node inliningTarget, PRaiseNode raise, int stackTop, NonMappingException e) { Object functionName = AbstractKwargsNode.getFunctionName(frame, stackTop); - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_MAPPING, functionName, e.getObject()); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_MAPPING, functionName, e.getObject()); } - protected static PException handleSameKey(VirtualFrame frame, PRaiseNode raise, int stackTop, SameDictKeyException e) { + protected static PException handleSameKey(VirtualFrame frame, Node inliningTarget, PRaiseNode raise, int stackTop, SameDictKeyException e) { Object functionName = AbstractKwargsNode.getFunctionName(frame, stackTop); - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_GOT_MULTIPLE_VALUES_FOR_KEYWORD_ARG, functionName, e.getKey()); + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_GOT_MULTIPLE_VALUES_FOR_KEYWORD_ARG, functionName, e.getKey()); } private static Object getFunctionName(VirtualFrame frame, int stackTop) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java index 701a7839a8..debb8cbcac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -102,7 +102,7 @@ static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop, @Cached PRaiseNode raiseNode) throws QuickeningGeneralizeException { Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator); if (nextMethod == PNone.NO_VALUE) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); } try { Object res = callNext.executeObject(frame, nextMethod, iterator); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java index 06f8a9dabe..7429b330e9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -101,7 +101,7 @@ static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop, assert iterator != null; Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator); if (nextMethod == PNone.NO_VALUE) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); + throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator); } try { frame.setObject(stackTop, callNext.executeObject(frame, nextMethod, iterator)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetAIterNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetAIterNode.java index 2465b85a28..2117964ea1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetAIterNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetAIterNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -83,7 +83,7 @@ Object doGeneric(Frame frame, Object receiver, @Bind("this") Node inliningTarget, @Cached(parameters = "AIter") LookupSpecialMethodSlotNode getAIter, @Cached GetClassNode getAsyncIterType, - @Cached PRaiseNode.Lazy raiseNoAIter, + @Cached PRaiseNode raiseNoAIter, @Cached TypeNodes.GetNameNode getName, @Cached InlinedBranchProfile errorProfile, @Cached CallUnaryMethodNode callAIter, @@ -93,13 +93,13 @@ Object doGeneric(Frame frame, Object receiver, Object getter = getAIter.execute(frame, type, receiver); if (getter == PNone.NO_VALUE) { errorProfile.enter(this); - throw raiseNoAIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_AITER, getName.execute(inliningTarget, type)); + throw raiseNoAIter.raise(inliningTarget, PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_AITER, getName.execute(inliningTarget, type)); } Object asyncIterator = callAIter.executeObject(frame, getter, receiver); Object anext = lookupANext.execute(inliningTarget, asyncIterator, T___ANEXT__); if (anext == PNone.NO_VALUE) { errorProfile.enter(this); - throw raiseNoAIter.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_ANEXT_INITIAL, getName.execute(inliningTarget, type)); + throw raiseNoAIter.raise(inliningTarget, PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_ANEXT_INITIAL, getName.execute(inliningTarget, type)); } return asyncIterator; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetANextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetANextNode.java index deb1141529..4718f84405 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetANextNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetANextNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -91,14 +91,14 @@ Object doGeneric(Frame frame, Object receiver, Object getter = getANext.execute(frame, type, receiver); if (getter == PNone.NO_VALUE) { errorProfile.enter(inliningTarget); - throw raiseNoANext.raise(PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_ANEXT_ITERATION, receiver); + throw raiseNoANext.raise(inliningTarget, PythonBuiltinClassType.TypeError, ASYNC_FOR_NO_ANEXT_ITERATION, receiver); } Object anext = callANext.executeObject(frame, getter, receiver); try { return getAwaitable.execute(frame, anext); } catch (PException e) { errorProfile.enter(inliningTarget); - throw raiseInvalidObject.raiseWithCause(PythonBuiltinClassType.TypeError, e, ANEXT_INVALID_OBJECT, anext); + throw raiseInvalidObject.raiseWithCause(inliningTarget, PythonBuiltinClassType.TypeError, e, ANEXT_INVALID_OBJECT, anext); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java index 5210ab2ea2..00e1ebba9e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -164,8 +164,8 @@ private void writeAttributeToLocals(VirtualFrame frame, Node inliningTarget, Tru writeAttribute(frame, inliningTarget, locals, name, moduleAttr, dictWriteNode, setAttrNode); } } catch (CannotCastException cce) { - throw PRaiseNode.raiseUncached(this, TypeError, fromAll ? ErrorMessages.ITEM_IN_S_MUST_BE_STRING : ErrorMessages.KEY_IN_S_MUST_BE_STRING, - moduleName, fromAll ? T___ALL__ : T___DICT__, attrName); + TruffleString format = fromAll ? ErrorMessages.ITEM_IN_S_MUST_BE_STRING : ErrorMessages.KEY_IN_S_MUST_BE_STRING; + throw PRaiseNode.raiseStatic(this, TypeError, format, moduleName, fromAll ? T___ALL__ : T___DICT__, attrName); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KeywordsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KeywordsNode.java index 5dd96fb4bf..480590e93a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KeywordsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KeywordsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -66,15 +66,15 @@ static PKeyword[] kwords(VirtualFrame frame, Object sourceCollection, int stackT @Cached MappingToKeywordsNode expandKeywordStarargsNode, @Cached InlinedBranchProfile keywordsError1, @Cached InlinedBranchProfile keywordsError2, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { try { return expandKeywordStarargsNode.execute(frame, inliningTarget, sourceCollection); } catch (SameDictKeyException e) { keywordsError1.enter(inliningTarget); - throw handleSameKey(frame, raise.get(inliningTarget), stackTop, e); + throw handleSameKey(frame, inliningTarget, raise, stackTop, e); } catch (NonMappingException e) { keywordsError2.enter(inliningTarget); - throw handleNonMapping(frame, raise.get(inliningTarget), stackTop, e); + throw handleNonMapping(frame, inliningTarget, raise, stackTop, e); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KwargsMergeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KwargsMergeNode.java index f0326ea589..b6165bc651 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KwargsMergeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/KwargsMergeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -65,7 +65,7 @@ public abstract class KwargsMergeNode extends AbstractKwargsNode { static int merge(VirtualFrame frame, int initialStackTop, @Bind("this") Node inliningTarget, @Cached ConcatDictToStorageNode concatNode, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached InlinedBranchProfile keywordsError1, @Cached InlinedBranchProfile keywordsError2) { int stackTop = initialStackTop; @@ -77,10 +77,10 @@ static int merge(VirtualFrame frame, int initialStackTop, dict.setDictStorage(resultStorage); } catch (SameDictKeyException e) { keywordsError1.enter(inliningTarget); - throw handleSameKey(frame, raise.get(inliningTarget), stackTop, e); + throw handleSameKey(frame, inliningTarget, raise, stackTop, e); } catch (NonMappingException e) { keywordsError2.enter(inliningTarget); - throw handleNonMapping(frame, raise.get(inliningTarget), stackTop, e); + throw handleNonMapping(frame, inliningTarget, raise, stackTop, e); } return stackTop; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java index c94084db5b..260f08ab12 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchClassNode.java @@ -93,7 +93,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD @Cached PRaiseNode raise) { if (!isTypeNode.execute(inliningTarget, type)) { - throw raise.raise(TypeError, ErrorMessages.CALLED_MATCH_PAT_MUST_BE_TYPE); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.CALLED_MATCH_PAT_MUST_BE_TYPE); } if (!isInstanceNode.executeWith(frame, subject, type)) { @@ -111,7 +111,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD try { matchArgs = getAttr.execute(frame, inliningTarget, type, T___MATCH_ARGS); if (!tupleCheckExactNode.execute(inliningTarget, matchArgs)) { - throw raise.raise(TypeError, ErrorMessages.P_MATCH_ARGS_MUST_BE_A_TUPLE_GOT_P, type, matchArgs); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.P_MATCH_ARGS_MUST_BE_A_TUPLE_GOT_P, type, matchArgs); } } catch (PException e) { // _Py_TPFLAGS_MATCH_SELF is only acknowledged if the type does not @@ -124,7 +124,7 @@ Object match(VirtualFrame frame, Object subject, Object type, int nargs, @NeverD } int allowed = matchSelf ? 1 : tupleSizeNode.execute(inliningTarget, matchArgs); if (allowed < nargs) { - throw raise.raise(TypeError, ErrorMessages.P_ACCEPTS_D_POS_SUBARG_S_D_GIVEN, type, allowed, (allowed == 1) ? "" : "s", nargs); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.P_ACCEPTS_D_POS_SUBARG_S_D_GIVEN, type, allowed, (allowed == 1) ? "" : "s", nargs); } if (matchSelf) { // Easy. Copy the subject itself, and move on to kwargs. @@ -150,9 +150,9 @@ private static void getArgs(VirtualFrame frame, Node inliningTarget, Object subj for (int i = 0; i < nargs; i++) { Object name = getItemNode.execute(frame, matchArgs, i); if (!unicodeCheckNode.execute(inliningTarget, name)) { - throw raise.raise(TypeError, ErrorMessages.MATCH_ARGS_ELEMENTS_MUST_BE_STRINGS_GOT_P, name); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.MATCH_ARGS_ELEMENTS_MUST_BE_STRINGS_GOT_P, name); } - setName(frame, type, name, seen, seenLength, eqStrNode, raise); + setName(frame, inliningTarget, type, name, seen, seenLength, eqStrNode, raise); attrs[attrsLength[0]++] = getAttr.execute(frame, inliningTarget, subject, name); } } @@ -165,14 +165,14 @@ private static void getKwArgs(VirtualFrame frame, Node inliningTarget, Object su for (int i = 0; i < kwArgs.length; i++) { TruffleString name = kwArgs[i]; CompilerAsserts.partialEvaluationConstant(name); - setName(frame, type, name, seen, seenLength, eqStrNode, raise); + setName(frame, inliningTarget, type, name, seen, seenLength, eqStrNode, raise); attrs[attrsLength[0]++] = getAttr.execute(frame, inliningTarget, subject, name); } } - private static void setName(VirtualFrame frame, Object type, Object name, Object[] seen, int[] seenLength, StringBuiltins.EqNode eqNode, PRaiseNode raise) { + private static void setName(VirtualFrame frame, Node inliningTarget, Object type, Object name, Object[] seen, int[] seenLength, StringBuiltins.EqNode eqNode, PRaiseNode raise) { if (seenLength[0] > 0 && contains(frame, seen, name, eqNode)) { - throw raise.raise(TypeError, ErrorMessages.S_GOT_MULTIPLE_SUBPATTERNS_FOR_ATTR_S, type, name); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.S_GOT_MULTIPLE_SUBPATTERNS_FOR_ATTR_S, type, name); } seen[seenLength[0]++] = name; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java index b39adc032a..e377122bba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MatchKeysNode.java @@ -74,14 +74,14 @@ static Object matchCached(VirtualFrame frame, Object map, @NeverDefault Object[] @Cached("keys.length") int keysLen, @Shared @Cached PyObjectRichCompareBool.EqNode compareNode, @Shared @Cached PyObjectCallMethodObjArgs callMethod, - @Shared @Cached PRaiseNode.Lazy raise) { + @Shared @Cached PRaiseNode raise) { Object[] values = getValues(frame, inliningTarget, map, keys, keysLen, compareNode, callMethod, raise); return values != null ? PFactory.createTuple(PythonLanguage.get(inliningTarget), values) : PNone.NONE; } @ExplodeLoop private static Object[] getValues(VirtualFrame frame, Node inliningTarget, Object map, Object[] keys, int keysLen, PyObjectRichCompareBool.EqNode compareNode, PyObjectCallMethodObjArgs callMethod, - PRaiseNode.Lazy raise) { + PRaiseNode raise) { CompilerAsserts.partialEvaluationConstant(keysLen); Object[] values = new Object[keysLen]; Object dummy = new Object(); @@ -100,10 +100,10 @@ private static Object[] getValues(VirtualFrame frame, Node inliningTarget, Objec } @ExplodeLoop - private static void checkSeen(VirtualFrame frame, Node inliningTarget, PRaiseNode.Lazy raise, Object[] seen, Object key, PyObjectRichCompareBool.EqNode compareNode) { + private static void checkSeen(VirtualFrame frame, Node inliningTarget, PRaiseNode raise, Object[] seen, Object key, PyObjectRichCompareBool.EqNode compareNode) { for (int i = 0; i < seen.length; i++) { if (seen[i] != null && compareNode.compare(frame, inliningTarget, seen[i], key)) { - raise.get(inliningTarget).raise(ValueError, ErrorMessages.MAPPING_PATTERN_CHECKS_DUPE_KEY_S, key); + raise.raise(inliningTarget, ValueError, ErrorMessages.MAPPING_PATTERN_CHECKS_DUPE_KEY_S, key); } } } @@ -113,7 +113,7 @@ static Object match(VirtualFrame frame, Object map, Object[] keys, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectRichCompareBool.EqNode compareNode, @Shared @Cached PyObjectCallMethodObjArgs callMethod, - @Shared @Cached PRaiseNode.Lazy raise) { + @Shared @Cached PRaiseNode raise) { if (keys.length == 0) { return PFactory.createTuple(PythonLanguage.get(inliningTarget), PythonUtils.EMPTY_OBJECT_ARRAY); } @@ -122,7 +122,7 @@ static Object match(VirtualFrame frame, Object map, Object[] keys, } private static Object[] getValuesLongArray(VirtualFrame frame, Node inliningTarget, Object map, Object[] keys, PyObjectRichCompareBool.EqNode compareNode, PyObjectCallMethodObjArgs callMethod, - PRaiseNode.Lazy raise) { + PRaiseNode raise) { Object[] values = new Object[keys.length]; Object dummy = new Object(); Object[] seen = new Object[keys.length]; @@ -139,10 +139,10 @@ private static Object[] getValuesLongArray(VirtualFrame frame, Node inliningTarg return values; } - private static void checkSeenLongArray(VirtualFrame frame, Node inliningTarget, PRaiseNode.Lazy raise, Object[] seen, Object key, PyObjectRichCompareBool.EqNode compareNode) { + private static void checkSeenLongArray(VirtualFrame frame, Node inliningTarget, PRaiseNode raise, Object[] seen, Object key, PyObjectRichCompareBool.EqNode compareNode) { for (int i = 0; i < seen.length; i++) { if (seen[i] != null && compareNode.compare(frame, inliningTarget, seen[i], key)) { - raise.get(inliningTarget).raise(ValueError, ErrorMessages.MAPPING_PATTERN_CHECKS_DUPE_KEY_S, key); + raise.raise(inliningTarget, ValueError, ErrorMessages.MAPPING_PATTERN_CHECKS_DUPE_KEY_S, key); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 8ba1f3fb38..925af3cb16 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -139,7 +139,6 @@ import com.oracle.graal.python.lib.PyObjectStrAsObjectNodeGen; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNodeGen; import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode; import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNodeGen; @@ -262,8 +261,8 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod private static final NodeSupplier NODE_IMPORT_STAR = ImportStarNode::create; private static final NodeSupplier NODE_OBJECT_GET_ATTR = PyObjectGetAttr::create; private static final PyObjectGetAttr UNCACHED_OBJECT_GET_ATTR = PyObjectGetAttr.getUncached(); - private static final NodeSupplier NODE_RAISE = PRaiseNode::create; - private static final PRaiseNode UNCACHED_RAISE = PRaiseNode.getUncached(); + private static final NodeSupplier NODE_RAISE = PRaiseCachedNode::create; + private static final PRaiseCachedNode UNCACHED_RAISE = PRaiseCachedNode.getUncached(); private static final NodeSupplier NODE_CALL = CallNode::create; private static final CallNode UNCACHED_CALL = CallNode.getUncached(); private static final NodeSupplier NODE_CALL_QUATERNARY_METHOD = CallQuaternaryMethodNode::create; @@ -2948,10 +2947,10 @@ private int traceLine(VirtualFrame virtualFrame, MutableLoopData mutableData, by mutableData.setPastBci(bci); if (newBci == CodeUnit.LINE_TO_BCI_LINE_AFTER_CODEBLOCK) { // line after the code block - throw PRaiseNode.getUncached().raise(ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, pyFrame.getLine()); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, pyFrame.getLine()); } else if (newBci == CodeUnit.LINE_TO_BCI_LINE_BEFORE_CODEBLOCK) { // line before the code block - throw PRaiseNode.getUncached().raise(ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, pyFrame.getJumpDestLine()); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, pyFrame.getJumpDestLine()); } else { ret = computeJumpStackDifference(bci, newBci); mutableData.setJumpBci(newBci); @@ -2968,9 +2967,9 @@ private int traceLine(VirtualFrame virtualFrame, MutableLoopData mutableData, by private int computeJumpStackDifference(int bci, int newBci) { int ret; var stacks = co.computeStackElems(); - String error = co.checkJump(stacks, bci, newBci); + String error = co.checkJump(this, stacks, bci, newBci); if (error != null) { - throw PRaiseNode.getUncached().raise(ValueError, ErrorMessages.CANT_JUMP_INTO_S, error); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.CANT_JUMP_INTO_S, error); } ret = stacks.get(newBci).size() - stacks.get(bci).size(); return ret; @@ -3274,7 +3273,8 @@ private void chainPythonExceptions(PException current, PException context) { private PException raiseUnknownBytecodeError(byte bc) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, toTruffleStringUncached("not implemented bytecode %s"), OpCodes.fromOpCode(bc)); + TruffleString format = toTruffleStringUncached("not implemented bytecode %s"); + throw PRaiseNode.raiseStatic(this, SystemError, format, OpCodes.fromOpCode(bc)); } private void generalizeForIterI(int bci, QuickeningGeneralizeException e) { @@ -3661,7 +3661,7 @@ private void bytecodeBinaryOpIII(VirtualFrame virtualFrame, int stackTop, int bc @InliningCutoff private void raiseDivOrModByZero(int bci, Node[] localNodes, boolean useCachedNodes) { - PRaiseNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseNodeGen.class, NODE_RAISE, useCachedNodes); + PRaiseCachedNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseCachedNodeGen.class, NODE_RAISE, useCachedNodes); throw raiseNode.raise(ZeroDivisionError, ErrorMessages.S_DIVISION_OR_MODULO_BY_ZERO, "integer"); } @@ -3811,7 +3811,7 @@ private void bytecodeBinaryOpDDO(VirtualFrame virtualFrame, int stackTop, int bc @InliningCutoff private void raiseDivByZero(int bci, Node[] localNodes, boolean useCachedNodes) { - PRaiseNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseNodeGen.class, NODE_RAISE, useCachedNodes); + PRaiseCachedNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseCachedNodeGen.class, NODE_RAISE, useCachedNodes); throw raiseNode.raise(ZeroDivisionError, ErrorMessages.DIVISION_BY_ZERO); } @@ -4559,7 +4559,7 @@ private void bytecodeLoadFastO(VirtualFrame virtualFrame, Frame localFrame, int @InliningCutoff private PException raiseVarReferencedBeforeAssignment(Node[] localNodes, int bci, int index) { - PRaiseNode raiseNode = insertChildNode(localNodes, bci, PRaiseNodeGen.class, NODE_RAISE); + PRaiseCachedNode raiseNode = insertChildNode(localNodes, bci, PRaiseCachedNodeGen.class, NODE_RAISE); throw raiseNode.raise(PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, varnames[index]); } @@ -4846,7 +4846,7 @@ private void bytecodeDeleteName(VirtualFrame virtualFrame, Object globals, Objec try { delItemNode.executeCached(virtualFrame, locals, varname); } catch (PException e) { - PRaiseNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseNodeGen.class, NODE_RAISE, useCachedNodes); + PRaiseCachedNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseCachedNodeGen.class, NODE_RAISE, useCachedNodes); throw raiseNode.raise(NameError, ErrorMessages.NAME_NOT_DEFINED, varname); } } else { @@ -5426,7 +5426,7 @@ private AbstractTruffleException bytecodeRaiseVarargs(VirtualFrame virtualFrame, @InliningCutoff private void raiseUnboundCell(Node[] localNodes, int bci, int oparg, boolean useCachedNodes) { - PRaiseNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseNodeGen.class, NODE_RAISE, useCachedNodes); + PRaiseCachedNode raiseNode = insertChildNode(localNodes, bci, UNCACHED_RAISE, PRaiseCachedNodeGen.class, NODE_RAISE, useCachedNodes); if (oparg < cellvars.length) { throw raiseNode.raise(PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, cellvars[oparg]); } else { @@ -5683,7 +5683,7 @@ private int bytecodeCollectionAddCollection(VirtualFrame virtualFrame, int type, } default: CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.getUncached().raise(SystemError, ErrorMessages.INVALID_TYPE_FOR_S, "COLLECTION_ADD_COLLECTION"); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.INVALID_TYPE_FOR_S, "COLLECTION_ADD_COLLECTION"); } virtualFrame.setObject(stackTop--, null); virtualFrame.setObject(stackTop, result); @@ -5716,7 +5716,7 @@ private int bytecodeAddToCollection(VirtualFrame virtualFrame, int initialStackT } default: CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.getUncached().raise(SystemError, ErrorMessages.INVALID_TYPE_FOR_S, "ADD_TO_COLLECTION"); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.INVALID_TYPE_FOR_S, "ADD_TO_COLLECTION"); } virtualFrame.setObject(stackTop--, null); return stackTop; @@ -5889,7 +5889,7 @@ protected byte[] extractCode() { * * TODO We should revisit this when the AST interpreter is removed. */ - return MarshalModuleBuiltins.serializeCodeUnit(PythonContext.get(this), co); + return MarshalModuleBuiltins.serializeCodeUnit(this, PythonContext.get(this), co); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PRaiseCachedNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PRaiseCachedNode.java new file mode 100644 index 0000000000..965bae46d2 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PRaiseCachedNode.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025, 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.bytecode; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.strings.TruffleString; + +@GenerateUncached +abstract class PRaiseCachedNode extends Node { + public final PException raise(PythonBuiltinClassType type, TruffleString format, Object... formatArgs) { + throw execute(type, format, formatArgs); + } + + protected abstract PException execute(PythonBuiltinClassType type, TruffleString format, Object[] formatArgs); + + @Specialization + PException doRaise(PythonBuiltinClassType type, TruffleString format, Object[] formatArgs) { + throw PRaiseNode.raiseStatic(this, type, format, formatArgs); + } + + @NeverDefault + public static PRaiseCachedNode create() { + return PRaiseCachedNodeGen.create(); + } + + public static PRaiseCachedNode getUncached() { + return PRaiseCachedNodeGen.getUncached(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PrintExprNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PrintExprNode.java index c8e0576ba8..a3a05f05f7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PrintExprNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PrintExprNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -74,7 +74,7 @@ void print(VirtualFrame frame, Object object, Object displayhook = lookupAttr.execute(frame, inliningTarget, sysModule, BuiltinNames.T_DISPLAYHOOK); if (displayhook == PNone.NO_VALUE) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, RuntimeError, ErrorMessages.LOST_SYSDISPLAYHOOK); + throw PRaiseNode.raiseStatic(this, RuntimeError, ErrorMessages.LOST_SYSDISPLAYHOOK); } callNode.execute(frame, displayhook, object); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java index 4202c74e1e..12066f8483 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -95,12 +95,11 @@ static void setCause(VirtualFrame frame, Object exception, Object causeClass, @Exclusive @Cached InlinedBranchProfile baseCheckFailedProfile, @Exclusive @Cached ValidExceptionNode validException, @Exclusive @Cached CallNode callConstructor, - @Exclusive @Cached PRaiseNode.Lazy raise, @Exclusive @Cached PyExceptionInstanceCheckNode check, @Exclusive @Cached ExceptionNodes.SetCauseNode setCauseNode) { if (!validException.execute(frame, causeClass)) { baseCheckFailedProfile.enter(inliningTarget); - throw raise.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX); + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX); } Object cause = callConstructor.execute(frame, causeClass); if (check.execute(inliningTarget, cause)) { @@ -118,11 +117,10 @@ static void setCause(VirtualFrame frame, Object exception, Object causeClass, // raise * from @Specialization(guards = {"!check.execute(inliningTarget, cause)", "!isTypeNode.execute(inliningTarget, cause)"}, limit = "1") static void setCause(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") Object exception, @SuppressWarnings("unused") Object cause, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Exclusive @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode, @SuppressWarnings("unused") @Exclusive @Cached PyExceptionInstanceCheckNode check, - @Cached PRaiseNode raise) { - throw raise.raise(PythonBuiltinClassType.TypeError, ErrorMessages.EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX); } } @@ -139,7 +137,7 @@ static void reraise(VirtualFrame frame, @SuppressWarnings("unused") PNone type, } else if (caughtException != null) { throw caughtException; } else { - throw raise.raise(RuntimeError, ErrorMessages.NO_ACTIVE_EX_TO_RERAISE); + throw raise.raise(inliningTarget, RuntimeError, ErrorMessages.NO_ACTIVE_EX_TO_RERAISE); } } @@ -178,11 +176,11 @@ public static void doRaiseNative(@SuppressWarnings("unused") VirtualFrame frame, throw PRaiseNode.raiseExceptionObject(inliningTarget, exception); } - private static void checkBaseClass(VirtualFrame frame, Node inliningTarget, Object pythonClass, ValidExceptionNode validException, PRaiseNode.Lazy raise, + private static void checkBaseClass(VirtualFrame frame, Node inliningTarget, Object pythonClass, ValidExceptionNode validException, PRaiseNode raise, InlinedBranchProfile baseCheckFailedProfile) { if (!validException.execute(frame, pythonClass)) { baseCheckFailedProfile.enter(inliningTarget); - throw raiseNoException(raise.get(inliningTarget)); + throw raiseNoException(inliningTarget, raise); } } @@ -195,13 +193,13 @@ public static void doRaise(@SuppressWarnings("unused") VirtualFrame frame, Objec @Exclusive @Cached CallNode callConstructor, @Exclusive @Cached PyExceptionInstanceCheckNode check, @Exclusive @Cached InlinedBranchProfile baseCheckFailedProfile, - @Exclusive @Cached PRaiseNode.Lazy raise) { + @Exclusive @Cached PRaiseNode raise) { checkBaseClass(frame, inliningTarget, pythonClass, validException, raise, baseCheckFailedProfile); Object newException = callConstructor.execute(frame, pythonClass); if (check.execute(inliningTarget, newException)) { throw PRaiseNode.raiseExceptionObject(inliningTarget, newException); } else { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, pythonClass, newException); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, pythonClass, newException); } } @@ -211,7 +209,7 @@ public static void doRaise(@SuppressWarnings("unused") VirtualFrame frame, Objec @Bind("this") Node inliningTarget, @Exclusive @SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode, @Exclusive @Cached ValidExceptionNode validException, - @Exclusive @Cached PRaiseNode.Lazy raise, + @Exclusive @Cached PRaiseNode raise, @Exclusive @Cached CallNode callConstructor, @Exclusive @Cached PyExceptionInstanceCheckNode check, @Exclusive @Cached InlinedBranchProfile baseCheckFailedProfile, @@ -222,7 +220,7 @@ public static void doRaise(@SuppressWarnings("unused") VirtualFrame frame, Objec setExceptionCauseNode.execute(frame, newException, cause); throw PRaiseNode.raiseExceptionObject(inliningTarget, newException); } else { - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, pythonClass, newException); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_HAVE_RETURNED_EXCEPTION, pythonClass, newException); } } @@ -232,7 +230,7 @@ public static void doRaise(@SuppressWarnings("unused") VirtualFrame frame, Objec public static void doRaise(VirtualFrame frame, Object exception, Object cause, @SuppressWarnings("unused") boolean rootNodeVisible, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "1") InteropLibrary lib, - @Exclusive @Cached PRaiseNode.Lazy raise) { + @Exclusive @Cached PRaiseNode raise) { if (lib.isException(exception)) { try { throw lib.throwException(exception); @@ -240,11 +238,11 @@ public static void doRaise(VirtualFrame frame, Object exception, Object cause, @ throw CompilerDirectives.shouldNotReachHere(); } } - throw raiseNoException(raise.get(inliningTarget)); + throw raiseNoException(inliningTarget, raise); } - private static PException raiseNoException(PRaiseNode raise) { - throw raise.raise(TypeError, ErrorMessages.EXCEPTIONS_MUST_DERIVE_FROM_BASE_EX); + private static PException raiseNoException(Node inliningTarget, PRaiseNode raise) { + throw raise.raise(inliningTarget, TypeError, ErrorMessages.EXCEPTIONS_MUST_DERIVE_FROM_BASE_EX); } public static RaiseNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAwithNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAwithNode.java index b680d4ea7e..a98c14d1b7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAwithNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAwithNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -79,11 +79,11 @@ static int setup(VirtualFrame frame, int stackTopIn, Object type = getClassNode.execute(inliningTarget, contextManager); Object enter = lookupAEnter.execute(frame, type, contextManager); if (enter == PNone.NO_VALUE) { - throw raiseNode.raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_THE_ASYNC_CONTEXT_MANAGER_PROTOCOL, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_THE_ASYNC_CONTEXT_MANAGER_PROTOCOL, type); } Object exit = lookupAExit.execute(frame, type, contextManager); if (exit == PNone.NO_VALUE) { - throw raiseNode.raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_THE_ASYNC_CONTEXT_MANAGER_PROTOCOL_AEXIT, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_THE_ASYNC_CONTEXT_MANAGER_PROTOCOL_AEXIT, type); } Object res = callEnter.executeObject(frame, enter, contextManager); frame.setObject(++stackTop, exit); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupWithNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupWithNode.java index ab61c3e4f6..3a70e3cadb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupWithNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupWithNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -79,11 +79,11 @@ static int setup(VirtualFrame frame, int stackTopIn, Object type = getClassNode.execute(inliningTarget, contextManager); Object enter = lookupEnter.execute(frame, type, contextManager); if (enter == PNone.NO_VALUE) { - throw raiseNode.raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL, type); } Object exit = lookupExit.execute(frame, type, contextManager); if (exit == PNone.NO_VALUE) { - throw raiseNode.raise(TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL_EXIT, type); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL_EXIT, type); } Object res = callEnter.executeObject(frame, enter, contextManager); frame.setObject(++stackTop, exit); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java index 1ea71fe6c4..581f455c90 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java @@ -83,7 +83,7 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { CompilerAsserts.partialEvaluationConstant(countBefore); CompilerAsserts.partialEvaluationConstant(countAfter); int resultStackTop = initialStackTop + countBefore + 1 + countAfter; @@ -92,7 +92,7 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s int len = storage.length(); int starLen = len - countBefore - countAfter; if (starLen < 0) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, len); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, len); } stackTop = moveItemsToStack(frame, inliningTarget, storage, stackTop, 0, countBefore, getItemNode); PList starList = PFactory.createList(language, getItemSliceNode.execute(storage, countBefore, countBefore + starLen, 1, starLen)); @@ -112,7 +112,7 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, @Bind PythonLanguage language, - @Exclusive @Cached PRaiseNode.Lazy raiseNode) { + @Exclusive @Cached PRaiseNode raiseNode) { CompilerAsserts.partialEvaluationConstant(countBefore); CompilerAsserts.partialEvaluationConstant(countAfter); int resultStackTop = initialStackTop + countBefore + 1 + countAfter; @@ -122,14 +122,14 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll iterator = getIter.execute(frame, inliningTarget, collection); } catch (PException e) { e.expectTypeError(inliningTarget, notIterableProfile); - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); } stackTop = moveItemsToStack(frame, inliningTarget, iterator, stackTop, 0, countBefore, countBefore + countAfter, getNextNode, stopIterationProfile, raiseNode); PList starAndAfter = constructListNode.execute(frame, iterator); SequenceStorage storage = starAndAfter.getSequenceStorage(); int lenAfter = storage.length(); if (lenAfter < countAfter) { - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, countBefore + lenAfter); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, countBefore + lenAfter); } if (countAfter == 0) { frame.setObject(stackTop, starAndAfter); @@ -144,7 +144,7 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll @ExplodeLoop private static int moveItemsToStack(VirtualFrame frame, Node inliningTarget, Object iterator, int initialStackTop, int offset, int length, int totalLength, GetNextNode getNextNode, - IsBuiltinObjectProfile stopIterationProfile, PRaiseNode.Lazy raiseNode) { + IsBuiltinObjectProfile stopIterationProfile, PRaiseNode raiseNode) { CompilerAsserts.partialEvaluationConstant(length); int stackTop = initialStackTop; for (int i = 0; i < length; i++) { @@ -153,7 +153,7 @@ private static int moveItemsToStack(VirtualFrame frame, Node inliningTarget, Obj frame.setObject(stackTop--, item); } catch (PException e) { e.expectStopIteration(inliningTarget, stopIterationProfile); - throw raiseNode.get(inliningTarget).raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, totalLength, offset + i); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, totalLength, offset + i); } } return stackTop; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java index ba0058e701..fb9a606338 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -90,9 +90,9 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s } } else { if (len < count) { - throw raiseNode.raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, len); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, len); } else { - throw raiseNode.raise(ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); } } return resultStackTop; @@ -116,7 +116,7 @@ static int doUnpackIterable(Frame frame, int initialStackTop, Object collection, iterator = getIter.execute(frame, inliningTarget, collection); } catch (PException e) { e.expectTypeError(inliningTarget, notIterableProfile); - throw raiseNode.raise(TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); } for (int i = 0; i < count; i++) { try { @@ -124,7 +124,7 @@ static int doUnpackIterable(Frame frame, int initialStackTop, Object collection, frame.setObject(stackTop--, item); } catch (PException e) { e.expectStopIteration(inliningTarget, stopIterationProfile1); - throw raiseNode.raise(ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, i); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, i); } } try { @@ -133,7 +133,7 @@ static int doUnpackIterable(Frame frame, int initialStackTop, Object collection, e.expectStopIteration(inliningTarget, stopIterationProfile2); return resultStackTop; } - throw raiseNode.raise(ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); } public static UnpackSequenceNode create() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java index 05bd298067..2677b7ea7c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -165,7 +165,7 @@ protected static Object doType(VirtualFrame frame, PythonBuiltinClassType callab @Shared("lookupCall") @Cached(parameters = "Call") LookupSpecialMethodSlotNode lookupCall, @Shared("callCall") @Cached CallVarargsMethodNode callCallNode) { Object call = lookupCall.execute(frame, getClassNode.execute(inliningTarget, callableObject), callableObject); - return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, call); + return callCall(frame, inliningTarget, callableObject, arguments, keywords, raise, callCallNode, call); } @Specialization(guards = "isPythonClass(callableObject)", replaces = "doType") @@ -176,7 +176,7 @@ protected static Object doPythonClass(VirtualFrame frame, Object callableObject, @Shared("lookupCall") @Cached(parameters = "Call") LookupSpecialMethodSlotNode lookupCall, @Shared("callCall") @Cached CallVarargsMethodNode callCallNode) { Object call = lookupCall.execute(frame, getClassNode.execute(inliningTarget, callableObject), callableObject); - return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, call); + return callCall(frame, inliningTarget, callableObject, arguments, keywords, raise, callCallNode, call); } @Specialization(guards = {"!isCallable(callableObject)", "!isForeignMethod(callableObject)"}, replaces = {"doType", "doPythonClass"}) @@ -187,14 +187,13 @@ protected static Object doObjectAndType(VirtualFrame frame, Object callableObjec @Shared("lookupCall") @Cached(parameters = "Call") LookupSpecialMethodSlotNode lookupCall, @Shared("callCall") @Cached CallVarargsMethodNode callCallNode) { Object call = lookupCall.execute(frame, getClassNode.execute(inliningTarget, callableObject), callableObject); - return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, call); + return callCall(frame, inliningTarget, callableObject, arguments, keywords, raise, callCallNode, call); } @Specialization @InliningCutoff protected static Object doForeignMethod(ForeignMethod callable, Object[] arguments, PKeyword[] keywords, @Bind("this") Node inliningTarget, - @Shared("raise") @Cached PRaiseNode raise, @Cached PForeignToPTypeNode fromForeign, @Cached InlinedBranchProfile keywordsError, @Cached InlinedBranchProfile typeError, @@ -202,14 +201,14 @@ protected static Object doForeignMethod(ForeignMethod callable, Object[] argumen @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop) { if (keywords.length != 0) { keywordsError.enter(inliningTarget); - throw raise.raise(PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ); } gil.release(true); try { return fromForeign.executeConvert(interop.invokeMember(callable.receiver, callable.methodName, arguments)); } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) { typeError.enter(inliningTarget); - throw raise.raise(TypeError, e); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, e); } catch (UnknownIdentifierException e) { // PyObjectGetMethod is supposed to have checked isMemberInvocable throw CompilerDirectives.shouldNotReachHere("Cannot invoke member"); @@ -218,9 +217,10 @@ protected static Object doForeignMethod(ForeignMethod callable, Object[] argumen } } - private static Object callCall(VirtualFrame frame, Object callableObject, Object[] arguments, PKeyword[] keywords, PRaiseNode raise, CallVarargsMethodNode callCallNode, Object call) { + private static Object callCall(VirtualFrame frame, Node inliningTarget, Object callableObject, Object[] arguments, PKeyword[] keywords, PRaiseNode raise, CallVarargsMethodNode callCallNode, + Object call) { if (call == PNone.NO_VALUE) { - throw raise.raise(TypeError, ErrorMessages.OBJ_ISNT_CALLABLE, callableObject); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.OBJ_ISNT_CALLABLE, callableObject); } return callCallNode.execute(frame, call, PythonUtils.prependArgument(callableObject, arguments), keywords); } @@ -311,7 +311,7 @@ protected static Object doGeneric(VirtualFrame frame, Object callableObject, Obj inliningTarget, dispatch, createArgs, raise, getClassNode, lookupCall, callCallNode); } Object callableType = getClassNode.execute(inliningTarget, callableObject); - return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, lookupCall.execute(frame, callableType, callableObject)); + return callCall(frame, inliningTarget, callableObject, arguments, keywords, raise, callCallNode, lookupCall.execute(frame, callableType, callableObject)); } protected static boolean isForeignMethod(Object object) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java index eedc98b468..0d52b0e88b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java @@ -279,7 +279,7 @@ protected void raiseInvalidArgsNumUncached(boolean hasValidArgsNum, BuiltinMetho @TruffleBoundary private void raiseInvalidArgsNumUncached(BuiltinMethodDescriptor descr) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, EXPECTED_D_ARGS, descr.minNumOfPositionalArgs()); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, EXPECTED_D_ARGS, descr.minNumOfPositionalArgs()); } protected static Object callUnaryBuiltin(VirtualFrame frame, PythonBuiltinBaseNode builtin, Object arg1) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleBinaryNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleBinaryNode.java index 81d18936e9..b9151a55d3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleBinaryNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleBinaryNode.java @@ -80,7 +80,6 @@ abstract class LookupAndCallReversibleBinaryNode extends LookupAndCallBinaryNode protected final SpecialMethodSlot rslot; private final boolean alwaysCheckReverse; - @Child private PRaiseNode raiseNode; @Child private GetNameNode getNameNode; @Child private CallBinaryMethodNode reverseDispatchNode; @@ -93,14 +92,6 @@ abstract class LookupAndCallReversibleBinaryNode extends LookupAndCallBinaryNode this.alwaysCheckReverse = alwaysCheckReverse; } - private PRaiseNode ensureRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } - private GetNameNode ensureGetNameNode() { if (getNameNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -238,7 +229,7 @@ private Object dispatch(VirtualFrame frame, Node inliningTarget, CallBinaryMetho // see descrobject.c/wrapperdescr_call() Object enclosing = getEnclosingType.execute(inliningTarget, callable); if (enclosing != null && !isSubtype.execute(leftClass, enclosing)) { - throw ensureRaiseNode().raise(TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.getName(), ensureGetNameNode().executeCached(leftClass), leftValue); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.DESCRIPTOR_S_REQUIRES_S_OBJ_RECEIVED_P, op.getName(), ensureGetNameNode().executeCached(leftClass), leftValue); } return dispatch.executeObject(frame, callable, leftValue, rightValue); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/IsSubtypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/IsSubtypeNode.java index 5522c20922..01f3c2587f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/IsSubtypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/IsSubtypeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -335,13 +335,13 @@ static boolean fallback(VirtualFrame frame, Object derived, Object cls, @Cached AbstractObjectIsSubclassNode abstractIsSubclassNode, @Exclusive @Cached InlinedConditionProfile exceptionDerivedProfile, @Exclusive @Cached InlinedConditionProfile exceptionClsProfile, - @Cached PRaiseNode.Lazy raise) { + @Cached PRaiseNode raise) { if (exceptionDerivedProfile.profile(inliningTarget, getBasesNode.execute(frame, derived) == null)) { - throw raise.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.ARG_D_MUST_BE_S, "issubclass()", 1, "class"); + throw raise.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ARG_D_MUST_BE_S, "issubclass()", 1, "class"); } if (exceptionClsProfile.profile(inliningTarget, getBasesNode.execute(frame, cls) == null)) { - throw raise.get(inliningTarget).raise(PythonErrorType.TypeError, ErrorMessages.ISSUBCLASS_MUST_BE_CLASS_OR_TUPLE); + throw raise.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ISSUBCLASS_MUST_BE_CLASS_OR_TUPLE); } return abstractIsSubclassNode.execute(frame, derived, cls); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java index 589bae4724..3c71e78374 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -72,35 +72,30 @@ public abstract class ExceptMatchNode extends Node { public abstract boolean executeMatch(Frame frame, Object exception, Object clause); - private static void raiseIfNoException(VirtualFrame frame, Object clause, ValidExceptionNode isValidException, PRaiseNode raiseNode) { + private static void raiseIfNoException(VirtualFrame frame, Node inliningTarget, Object clause, ValidExceptionNode isValidException) { if (!isValidException.execute(frame, clause)) { - raiseNoException(raiseNode); + throw PRaiseNode.raiseStatic(inliningTarget, PythonErrorType.TypeError, ErrorMessages.CATCHING_CLS_NOT_ALLOWED); } } - private static void raiseNoException(PRaiseNode raiseNode) { - throw raiseNode.raise(PythonErrorType.TypeError, ErrorMessages.CATCHING_CLS_NOT_ALLOWED); - } - @Specialization(guards = "!isPTuple(clause)") public static boolean matchPythonSingle(VirtualFrame frame, PException e, Object clause, @Bind("this") Node inliningTarget, @Shared @Cached ValidExceptionNode isValidException, @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtype, - @Shared @Cached PRaiseNode raiseNode) { - raiseIfNoException(frame, clause, isValidException, raiseNode); + @Cached IsSubtypeNode isSubtype) { + raiseIfNoException(frame, inliningTarget, clause, isValidException); return isSubtype.execute(frame, getClassNode.execute(inliningTarget, e.getUnreifiedException()), clause); } @Specialization(guards = {"!isPTuple(clause)", "!isPException(e)"}, limit = "1") public static boolean matchJava(VirtualFrame frame, AbstractTruffleException e, Object clause, + @Bind("this") Node inliningTarget, @Shared @Cached ValidExceptionNode isValidException, - @CachedLibrary("clause") InteropLibrary clauseLib, - @Shared @Cached PRaiseNode raiseNode) { + @CachedLibrary("clause") InteropLibrary clauseLib) { // n.b.: we can only allow Java exceptions in clauses, because we cannot tell for other // foreign exception types if they *are* exception types - raiseIfNoException(frame, clause, isValidException, raiseNode); + raiseIfNoException(frame, inliningTarget, clause, isValidException); if (clauseLib.isMetaObject(clause)) { try { return clauseLib.isMetaInstance(clause, e); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java index 6f5d23cdbc..7de2eb29de 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java @@ -77,6 +77,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; @SuppressWarnings("truffle-inlining") @@ -155,11 +156,12 @@ public abstract static class BinaryArithmeticNode extends BinaryOpNode { static Supplier createHandler(String operator) { return () -> new NotImplementedHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(VirtualFrame frame, Object arg, Object arg2) { - throw raiseNode.raise(TypeError, getErrorMessage(arg), operator, arg, arg2); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, getErrorMessage(arg), operator, arg, arg2); } @CompilerDirectives.TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java index 535b57ecf4..63b453e941 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -49,20 +49,18 @@ import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; @TypeSystemReference(PythonArithmeticTypes.class) public abstract class BinaryComparisonNode extends BinaryOpNode { private abstract static class ErrorNode extends BinaryComparisonNode { - @Child private PRaiseNode raiseNode; + private final BranchProfile notSupportedProfile = BranchProfile.create(); protected final RuntimeException noSupported(Object left, Object right) { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - throw raiseNode.raise(TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, operator(), left, right); + notSupportedProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, operator(), left, right); } protected abstract String operator(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java index 2c74fe9c8c..0d5a521230 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CastToListExpressionNode.java @@ -150,7 +150,7 @@ static PList starredGeneric(VirtualFrame frame, Object v, return constructListNode.execute(frame, v); } catch (PException e) { e.expectAttributeError(inliningTarget, attrProfile); - throw raise.raise(TypeError, ErrorMessages.OBJ_NOT_ITERABLE, v); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.OBJ_NOT_ITERABLE, v); } finally { IndirectCallContext.exit(frame, language, context, state); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java index 4bf4b17619..7248ea944d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -78,6 +78,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; public enum InplaceArithmetic { @@ -123,11 +124,12 @@ public enum InplaceArithmetic { this.slot = slot; this.notImplementedHandler = () -> new LookupAndCallInplaceNode.NotImplementedHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object arg, Object arg2) { - throw raiseNode.raise(TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, operator, arg, arg2); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, operator, arg, arg2); } }; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java index 1a83d7d96e..142e626203 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -56,6 +56,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; public enum TernaryArithmetic { @@ -67,14 +68,15 @@ public enum TernaryArithmetic { TernaryArithmetic(TruffleString methodName, @SuppressWarnings("unused") String operator, String operatorFunction) { this.methodName = methodName; this.notImplementedHandler = () -> new NotImplementedHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object arg, Object arg2, Object arg3) { + errorProfile.enter(); if (arg3 instanceof PNone) { - throw raiseNode.raise(TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_PR_S_P_AND_P, operator, operatorFunction, arg, arg2); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_PR_S_P_AND_P, operator, operatorFunction, arg, arg2); } else { - throw raiseNode.raise(TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, operatorFunction, arg, arg2, arg3); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, operatorFunction, arg, arg2, arg3); } } }; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java index fc64f03be0..e3836dc3fd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java @@ -64,6 +64,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; public enum UnaryArithmetic { @@ -132,11 +133,12 @@ public abstract static class UnaryArithmeticNode extends UnaryOpNode { static Supplier createHandler(String operator) { return () -> new NoAttributeHandler() { - @Child private PRaiseNode raiseNode = PRaiseNode.create(); + private final BranchProfile errorProfile = BranchProfile.create(); @Override public Object execute(Object receiver) { - throw raiseNode.raise(TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary ", operator, receiver); + errorProfile.enter(); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary ", operator, receiver); } }; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java index 465481c0aa..d91eaef145 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -215,7 +215,7 @@ abstract class ReadBuiltinNode extends PNodeWithContext { @Specialization(guards = "isSingleContext(this)") Object returnBuiltinFromConstantModule(TruffleString attributeId, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached InlinedConditionProfile isBuiltinProfile, @Shared @Cached ReadAttributeFromObjectNode readFromBuiltinsNode, @SuppressWarnings("unused") @Cached("getBuiltins()") PythonModule builtins) { @@ -223,15 +223,15 @@ Object returnBuiltinFromConstantModule(TruffleString attributeId, } @InliningCutoff - private static PException raiseNameNotDefined(PRaiseNode raiseNode, TruffleString attributeId) { - throw raiseNode.raise(NameError, ErrorMessages.NAME_NOT_DEFINED, attributeId); + private static PException raiseNameNotDefined(Node inliningTarget, PRaiseNode raiseNode, TruffleString attributeId) { + throw raiseNode.raise(inliningTarget, NameError, ErrorMessages.NAME_NOT_DEFINED, attributeId); } @InliningCutoff @Specialization(replaces = "returnBuiltinFromConstantModule") Object returnBuiltin(TruffleString attributeId, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached InlinedConditionProfile isBuiltinProfile, @Shared @Cached ReadAttributeFromObjectNode readFromBuiltinsNode, @Exclusive @Cached InlinedConditionProfile ctxInitializedProfile) { @@ -239,14 +239,14 @@ Object returnBuiltin(TruffleString attributeId, return returnBuiltinFromConstantModule(attributeId, inliningTarget, raiseNode, isBuiltinProfile, readFromBuiltinsNode, builtins); } - private static Object readBuiltinFromModule(TruffleString attributeId, PRaiseNode.Lazy raiseNode, Node inliningTarget, + private static Object readBuiltinFromModule(TruffleString attributeId, PRaiseNode raiseNode, Node inliningTarget, InlinedConditionProfile isBuiltinProfile, PythonModule builtins, ReadAttributeFromObjectNode readFromBuiltinsNode) { Object builtin = readFromBuiltinsNode.execute(builtins, attributeId); if (isBuiltinProfile.profile(inliningTarget, builtin != PNone.NO_VALUE)) { return builtin; } else { - throw raiseNameNotDefined(raiseNode.get(inliningTarget), attributeId); + throw raiseNameNotDefined(inliningTarget, raiseNode, attributeId); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java index 5deb4769c2..94336bfc54 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/PythonVarargsBuiltinNode.java @@ -40,15 +40,10 @@ */ package com.oracle.graal.python.nodes.function.builtins; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ControlFlowException; -import com.oracle.truffle.api.strings.TruffleString; /** * Subclasses must override {@link #varArgExecute(VirtualFrame, Object, Object[], PKeyword[])} to @@ -57,28 +52,6 @@ */ public abstract class PythonVarargsBuiltinNode extends PythonBuiltinBaseNode { - @Child private PRaiseNode raiseNode; - - protected final PRaiseNode getRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - if (isAdoptable()) { - raiseNode = insert(PRaiseNode.create()); - } else { - raiseNode = PRaiseNode.getUncached(); - } - } - return raiseNode; - } - - public PException raise(PythonBuiltinClassType type, TruffleString string) { - return getRaiseNode().raise(type, string); - } - - public final PException raise(PythonBuiltinClassType type, TruffleString format, Object... arguments) { - return getRaiseNode().raise(type, format, arguments); - } - public static final class VarargsBuiltinDirectInvocationNotSupported extends ControlFlowException { public static final VarargsBuiltinDirectInvocationNotSupported INSTANCE = new VarargsBuiltinDirectInvocationNotSupported(); private static final long serialVersionUID = 1L; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/WrapTpNew.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/WrapTpNew.java index 828d30d799..882fcf99ab 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/WrapTpNew.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/WrapTpNew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -67,7 +67,6 @@ public final class WrapTpNew extends SlotWrapper { @Child private IsTypeNode isType; @Child private IsSubtypeNode isSubtype; - @Child private PRaiseNode raiseNode; @Child private LookupAttributeInMRONode lookupNewNode; @CompilationFinal private ValueProfile builtinProfile; @CompilationFinal private byte state = 0; @@ -106,7 +105,7 @@ public Object execute(VirtualFrame frame) { reportPolymorphicSpecialize(); state |= NOT_CLASS_STATE; } - throw getRaiseNode().raise(PythonBuiltinClassType.TypeError, ErrorMessages.NEW_X_ISNT_TYPE_OBJ, owner.getName(), cls); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.NEW_X_ISNT_TYPE_OBJ, owner.getName(), cls); } if (isSubtype == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); @@ -119,7 +118,7 @@ public Object execute(VirtualFrame frame) { reportPolymorphicSpecialize(); state |= NOT_SUBTP_STATE; } - throw getRaiseNode().raise(PythonBuiltinClassType.TypeError, + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_SUBTYPE_OF, owner.getName(), cls, cls, owner.getName()); } @@ -145,7 +144,7 @@ public Object execute(VirtualFrame frame) { reportPolymorphicSpecialize(); state |= IS_UNSAFE_STATE; } - throw getRaiseNode().raise(PythonBuiltinClassType.TypeError, ErrorMessages.NEW_IS_NOT_SAFE_USE_ELSE, owner.getName(), cls, cls); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.NEW_IS_NOT_SAFE_USE_ELSE, owner.getName(), cls, cls); } } // we explicitly allow non-Java functions to pass here, since a PythonBuiltinClass @@ -177,12 +176,4 @@ private final Class getFactoryNodeClass(NodeFac private static final Class getFactoryNodeClassUncached(NodeFactory factory) { return factory.getNodeClass(); } - - private PRaiseNode getRaiseNode() { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } - return raiseNode; - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/CodePointConversionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/CodePointConversionNode.java index 51625b80c1..0d85c0e369 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/CodePointConversionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/CodePointConversionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -87,7 +87,7 @@ int doOthers(Object value, @Cached CastToTruffleStringNode castToStringNode, @Cached TruffleString.CodePointLengthNode codePointLengthNode, @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { TruffleString str = castToStringNode.execute(inliningTarget, value); if (codePointLengthNode.execute(str, TS_ENCODING) == 1) { @@ -96,7 +96,7 @@ int doOthers(Object value, } catch (CannotCastException ex) { // handled below } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_S_NOT_P, builtinName, "unicode character", value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_S_NOT_P, builtinName, "unicode character", value); } @ClinicConverterFactory diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/SliceIndexConversionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/SliceIndexConversionNode.java index cc1758b9b4..71c314477b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/SliceIndexConversionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/SliceIndexConversionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -68,11 +68,11 @@ static int doOthers(VirtualFrame frame, Object value, @Bind("this") Node inliningTarget, @Cached PyIndexCheckNode indexCheckNode, @Cached PyNumberAsSizeNode asSizeNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { if (indexCheckNode.execute(inliningTarget, value)) { return asSizeNode.executeLossy(frame, inliningTarget, value); } - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SLICE_INDICES_TYPE_ERROR); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SLICE_INDICES_TYPE_ERROR); } @ClinicConverterFactory(shortCircuitPrimitive = PrimitiveType.Int) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TruffleStringConverterNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TruffleStringConverterNode.java index 23b5470c1e..5a54fe5b76 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TruffleStringConverterNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TruffleStringConverterNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -71,11 +71,11 @@ static Object doString(TruffleString value) { Object doOthers(Object value, @Bind("this") Node inliningTarget, @Cached CastToTruffleStringNode castToStringNode, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return castToStringNode.execute(inliningTarget, value); } catch (CannotCastException ex) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_S_NOT_P, builtinName, "str", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_S_NOT_P, builtinName, "str", value); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TupleConversionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TupleConversionNode.java index e1f61306a5..173b0e94de 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TupleConversionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/TupleConversionNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -71,8 +71,8 @@ static Object[] doTuple(PTuple t, @Fallback static Object doOthers(Object value, - @Cached PRaiseNode raiseNode) { - throw raiseNode.raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, value, "a tuple", value); + @Bind("this") Node inliningTarget) { + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, value, "a tuple", value); } @ClinicConverterFactory diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/WritableBufferConversionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/WritableBufferConversionNode.java index eb793e1e79..1462c5e602 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/WritableBufferConversionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/builtins/clinic/WritableBufferConversionNode.java @@ -72,11 +72,11 @@ Object doObject(VirtualFrame frame, Object value, @Bind PythonContext context, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("value") PythonBufferAcquireLibrary acquireLib, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return acquireLib.acquireWritable(value, frame, context, context.getLanguage(inliningTarget), indirectCallData); } catch (PException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_READ_WRITE_BYTES_LIKE_NOT_P, builtinName, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_BRACKETS_ARG_MUST_BE_READ_WRITE_BYTES_LIKE_NOT_P, builtinName, value); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/interop/GetInteropBehaviorValueNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/interop/GetInteropBehaviorValueNode.java index c7e5dfa45f..efa8715cf0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/interop/GetInteropBehaviorValueNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/interop/GetInteropBehaviorValueNode.java @@ -77,7 +77,7 @@ @SuppressWarnings("truffle-inlining") // some of the cached nodes in the specialization are not // inlineable public abstract class GetInteropBehaviorValueNode extends PNodeWithContext { - public final boolean executeBoolean(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaBooleanNode toBooleanNode, PRaiseNode.Lazy raiseNode, + public final boolean executeBoolean(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaBooleanNode toBooleanNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; try { @@ -85,76 +85,76 @@ public final boolean executeBoolean(Node inliningTarget, InteropBehavior behavio try { return toBooleanNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a boolean", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a boolean", value); } } catch (UnsupportedMessageException usm) { return false; } } - public final byte executeByte(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaByteNode toByteNode, PRaiseNode.Lazy raiseNode, PythonAbstractObject receiver, + public final byte executeByte(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaByteNode toByteNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toByteNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a byte", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a byte", value); } } - public final short executeShort(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaShortNode toShortNode, PRaiseNode.Lazy raiseNode, + public final short executeShort(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaShortNode toShortNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toShortNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a short", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a short", value); } } - public final int executeInt(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaIntExactNode toIntNode, PRaiseNode.Lazy raiseNode, PythonAbstractObject receiver, + public final int executeInt(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaIntExactNode toIntNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toIntNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "an int", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "an int", value); } } - public final long executeLong(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaLongExactNode toLongNode, PRaiseNode.Lazy raiseNode, + public final long executeLong(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaLongExactNode toLongNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toLongNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a long", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a long", value); } } - public final double executeDouble(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaDoubleNode toDoubleNode, PRaiseNode.Lazy raiseNode, + public final double executeDouble(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaDoubleNode toDoubleNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toDoubleNode.execute(inliningTarget, value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a double", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a double", value); } } - public final String executeString(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaStringNode toStringNode, PRaiseNode.Lazy raiseNode, + public final String executeString(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, CastToJavaStringNode toStringNode, PRaiseNode raiseNode, PythonAbstractObject receiver, Object... extraArguments) throws UnsupportedMessageException { assert extraArguments.length == method.extraArguments : "number of passed arguments to GetInteropBehaviorValueNode does not match expected number of arguments for method"; Object value = execute(inliningTarget, behavior, method, receiver, extraArguments); try { return toStringNode.execute(value); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a string", value); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, S_MUST_BE_S_NOT_P, "return value", "a string", value); } } @@ -209,7 +209,7 @@ static Object getValue(Node inliningTarget, InteropBehavior behavior, InteropBeh static Object getValueComputedWrongArity(Node inliningTarget, InteropBehavior behavior, InteropBehaviorMethod method, PythonAbstractObject receiver, Object[] extraArguments, @Cached PRaiseNode raiseNode) throws UnsupportedMessageException { assert behavior.isDefined(method) : "interop behavior method is not defined!"; - throw raiseNode.raise(PythonBuiltinClassType.TypeError, FUNC_TAKES_EXACTLY_D_ARGS, method.extraArguments, extraArguments.length); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, FUNC_TAKES_EXACTLY_D_ARGS, method.extraArguments, extraArguments.length); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java index e705a89eb4..701091e9b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetDictIfExistsNode.java @@ -144,7 +144,7 @@ PDict doNativeObject(PythonAbstractNativeObject object, return dict; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(this, SystemError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, dictObject); + throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.DICT_MUST_BE_SET_TO_DICT, dictObject); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java index b5d569ad8a..cdf3323ca0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetOrCreateDictNode.java @@ -99,7 +99,7 @@ static PDict doOther(Node inliningTarget, Object object, PDict dict = getDict.execute(object); if (dict == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, SystemError, ErrorMessages.UNABLE_SET_DICT_OF_OBJ, object); + throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.UNABLE_SET_DICT_OF_OBJ, object); } return dict; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java index 0b736e22e8..08631874bd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetRegisteredClassNode.java @@ -195,7 +195,7 @@ private static PythonClass buildClassAndRegister(Object foreignObject, } catch (PException e) { // Catch the error to additionally print the collected classes and specify the error // occurred during class creation - throw PRaiseNode.getUncached().raiseWithCause(PythonBuiltinClassType.TypeError, e, ErrorMessages.INTEROP_CLASS_CREATION_NOT_POSSIBLE, + throw PRaiseNode.raiseWithCauseStatic(inliningTarget, PythonBuiltinClassType.TypeError, e, ErrorMessages.INTEROP_CLASS_CREATION_NOT_POSSIBLE, interopLibrary.getMetaQualifiedName(metaObject), Arrays.toString(basesWithForeign)); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java index 55e7bd700a..3679765bb6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java @@ -118,14 +118,14 @@ public static PythonModule importModule(TruffleString name) { PythonModule sysModule = context.lookupBuiltinModule(T_SYS); Object modules = sysModule.getAttribute(T_MODULES); if (modules == PNone.NO_VALUE) { - throw PRaiseNode.getUncached().raise(RuntimeError, ErrorMessages.UNABLE_TO_GET_S, "sys.modules"); + throw PRaiseNode.raiseStatic(null, RuntimeError, ErrorMessages.UNABLE_TO_GET_S, "sys.modules"); } Object module = PyObjectGetItem.executeUncached(modules, name); if (module instanceof PythonModule pythonModule) { return pythonModule; } // FIXME CPython allows putting any object in sys.modules - throw PRaiseNode.getUncached().raise(NotImplementedError, ErrorMessages.PUTTING_NON_MODULE_OBJECTS_IN_SYS_MODULES_IS_NOT_SUPPORTED); + throw PRaiseNode.raiseStatic(null, NotImplementedError, ErrorMessages.PUTTING_NON_MODULE_OBJECTS_IN_SYS_MODULES_IS_NOT_SUPPORTED); } protected final Object importModule(VirtualFrame frame, TruffleString name, Object globals, TruffleString[] fromList, int level, ImportName importNameNode) { @@ -205,7 +205,7 @@ public abstract static class PyImportImportModuleLevelObject extends Node { @SuppressWarnings("unused") @Specialization(guards = "level < 0") Object levelLtZero(VirtualFrame frame, PythonContext context, TruffleString name, Object globals, TruffleString[] fromList, int level) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, ErrorMessages.LEVEL_MUST_BE_AT_LEAST_ZERO); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.LEVEL_MUST_BE_AT_LEAST_ZERO); } protected static boolean containsDot(TruffleString name, TruffleString.CodePointLengthNode codePointLengthNode, TruffleString.IndexOfCodePointNode indexOfCodePointNode) { @@ -217,7 +217,7 @@ public static Object levelZeroNoFromlist(VirtualFrame frame, PythonContext conte @SuppressWarnings("unused") TruffleString[] fromList, @SuppressWarnings("unused") int level, @Bind("this") Node inliningTarget, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PyDictGetItem getModuleNode, @Exclusive @Cached EnsureInitializedNode ensureInitialized, @Exclusive @Cached FindAndLoad findAndLoad, @@ -225,7 +225,7 @@ public static Object levelZeroNoFromlist(VirtualFrame frame, PythonContext conte @Exclusive @Cached @SuppressWarnings("unused") TruffleString.IndexOfCodePointNode indexOfCodePointNode) { final TruffleString absName = name; if (name.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); } PDict sysModules = context.getSysModules(); Object mod = getModuleNode.execute(frame, inliningTarget, sysModules, absName); // import_get_module @@ -253,7 +253,7 @@ private ModuleFront(TruffleString front) { static Object genericImport(VirtualFrame frame, PythonContext context, TruffleString name, Object globals, TruffleString[] fromList, int level, @Bind("this") Node inliningTarget, @Cached ResolveName resolveName, - @Exclusive @Cached PRaiseNode.Lazy raiseNode, + @Exclusive @Cached PRaiseNode raiseNode, @Exclusive @Cached PyDictGetItem getModuleNode, @Exclusive @Cached EnsureInitializedNode ensureInitialized, @Cached PyObjectLookupAttr getPathNode, @@ -268,7 +268,7 @@ static Object genericImport(VirtualFrame frame, PythonContext context, TruffleSt absName = resolveName.execute(frame, name, globals, level); } else { if (name.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); } absName = name; } @@ -310,7 +310,7 @@ static Object genericImport(VirtualFrame frame, PythonContext context, TruffleSt TruffleString toReturn = substringNode.execute(absName, 0, codePointLengthNode.execute(absName, TS_ENCODING) - cutoff, TS_ENCODING, true); Object finalModule = getModuleNode.execute(frame, inliningTarget, sysModules, toReturn); // import_get_module if (finalModule == null) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.KeyError, ErrorMessages.S_NOT_IN_SYS_MODS, toReturn); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.KeyError, ErrorMessages.S_NOT_IN_SYS_MODS, toReturn); } return finalModule; } @@ -331,7 +331,7 @@ static Object genericImport(VirtualFrame frame, PythonContext context, TruffleSt } static Object genericImportRecursion(VirtualFrame frame, Node inliningTarget, PythonContext context, ModuleFront front, - PRaiseNode.Lazy raiseNode, + PRaiseNode raiseNode, PyDictGetItem getModuleNode, EnsureInitializedNode ensureInitialized, FindAndLoad findAndLoad, @@ -340,7 +340,7 @@ static Object genericImportRecursion(VirtualFrame frame, Node inliningTarget, Py TruffleString.SubstringNode substringNode) { TruffleString absName = front.front; if (absName.isEmpty()) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.EMPTY_MOD_NAME); } PDict sysModules = context.getSysModules(); Object mod = getModuleNode.execute(frame, inliningTarget, sysModules, absName); // import_get_module @@ -480,7 +480,7 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals CompilerDirectives.transferToInterpreterAndInvalidate(); branchStates[0] |= CANNOT_CAST; } - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, ErrorMessages.PACKAGE_MUST_BE_A_STRING); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.PACKAGE_MUST_BE_A_STRING); } if (spec != null && spec != PNone.NONE) { if ((branchStates[0] & SPEC_IS_STH) == 0) { @@ -506,7 +506,7 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals CompilerDirectives.transferToInterpreterAndInvalidate(); branchStates[0] |= CANNOT_CAST; } - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, ErrorMessages.SPEC_PARENT_MUST_BE_A_STRING); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.SPEC_PARENT_MUST_BE_A_STRING); } } else { if ((branchStates[0] & NO_SPEC_PKG) == 0) { @@ -526,7 +526,7 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals CompilerDirectives.transferToInterpreterAndInvalidate(); branchStates[0] |= GOT_NO_NAME; } - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.KeyError, ErrorMessages.NAME_NOT_IN_GLOBALS); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.KeyError, ErrorMessages.NAME_NOT_IN_GLOBALS); } try { pkgString = castPackageNode.execute(inliningTarget, pkg); @@ -535,7 +535,7 @@ TruffleString resolveName(VirtualFrame frame, TruffleString name, Object globals CompilerDirectives.transferToInterpreterAndInvalidate(); branchStates[0] |= CANNOT_CAST; } - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.TypeError, ErrorMessages.NAME_MUST_BE_A_STRING); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, ErrorMessages.NAME_MUST_BE_A_STRING); } Object path = getPackageOrNameNode.execute(frame, inliningTarget, globalsDict, SpecialAttributeNames.T___PATH__); if (path == null) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/BadOPCodeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/BadOPCodeNode.java index 6bf32be4ca..9af5d0866a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/BadOPCodeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/BadOPCodeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -66,7 +66,7 @@ public BadOPCodeNode(TruffleLanguage language, TruffleString name) { @Override public Object execute(VirtualFrame frame) { - throw PRaiseNode.raiseUncached(this, PythonBuiltinClassType.SystemError, ErrorMessages.UNKNOWN_OPCODE); + throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.UNKNOWN_OPCODE); } @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToByteNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToByteNode.java index f3d49fb712..70db749531 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToByteNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToByteNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -53,7 +53,6 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.util.BiFunction; import com.oracle.graal.python.util.OverflowException; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.ImportStatic; @@ -61,18 +60,19 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.BranchProfile; @ImportStatic(PGuards.class) public abstract class CastToByteNode extends Node { public static final CastToByteNode UNCACHED_INSTANCE = CastToByteNode.create(); - @Child private PRaiseNode raiseNode; + private final BranchProfile errorProfile = BranchProfile.create(); - private final BiFunction rangeErrorHandler; - private final BiFunction typeErrorHandler; + private final BiFunction rangeErrorHandler; + private final BiFunction typeErrorHandler; protected final boolean coerce; - protected CastToByteNode(BiFunction rangeErrorHandler, BiFunction typeErrorHandler, boolean coerce) { + protected CastToByteNode(BiFunction rangeErrorHandler, BiFunction typeErrorHandler, boolean coerce) { this.rangeErrorHandler = rangeErrorHandler; this.typeErrorHandler = typeErrorHandler; this.coerce = coerce; @@ -170,27 +170,21 @@ protected byte doObject(VirtualFrame frame, Object value, return doError(value); } - private byte doError(@SuppressWarnings("unused") Object val) { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } + private byte doError(Object val) { + errorProfile.enter(); if (typeErrorHandler != null) { - return typeErrorHandler.apply(val, raiseNode); + return typeErrorHandler.apply(this, val); } else { - throw raiseNode.raise(TypeError, ErrorMessages.INTEGER_REQUIRED_GOT, val); + throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.INTEGER_REQUIRED_GOT, val); } } private byte handleRangeError(Object val) { - if (raiseNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - raiseNode = insert(PRaiseNode.create()); - } + errorProfile.enter(); if (rangeErrorHandler != null) { - return rangeErrorHandler.apply(val, raiseNode); + return rangeErrorHandler.apply(this, val); } else { - throw raiseNode.raise(ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); } } @@ -209,12 +203,7 @@ public static CastToByteNode create(boolean coerce) { } @NeverDefault - public static CastToByteNode create(BiFunction rangeErrorHandler, BiFunction typeErrorHandler) { + public static CastToByteNode create(BiFunction rangeErrorHandler, BiFunction typeErrorHandler) { return CastToByteNodeGen.create(rangeErrorHandler, typeErrorHandler, false); } - - @NeverDefault - public static CastToByteNode create(BiFunction rangeErrorHandler, BiFunction typeErrorHandler, boolean coerce) { - return CastToByteNodeGen.create(rangeErrorHandler, typeErrorHandler, coerce); - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java index a51aebe08b..00e3280a87 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -101,7 +101,7 @@ protected static BigInteger fromPInt(PInt x) { @Specialization protected static BigInteger generic(Node inliningTarget, Object x, - @Cached PRaiseNode.Lazy raise, + @Cached PRaiseNode raise, @Cached(inline = false) CastToJavaBigIntegerNode rec, @Cached GetClassNode getClassNode, @Cached PyIndexCheckNode indexCheckNode, @@ -109,6 +109,6 @@ protected static BigInteger generic(Node inliningTarget, Object x, if (indexCheckNode.execute(inliningTarget, x)) { return rec.execute(null, indexNode.execute(null, inliningTarget, x)); } - throw raise.get(inliningTarget).raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, getClassNode.execute(inliningTarget, x)); + throw raise.raise(inliningTarget, TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, getClassNode.execute(inliningTarget, x)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBooleanNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBooleanNode.java index 40fa79e60c..78ee5de6ac 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBooleanNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBooleanNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -106,7 +106,7 @@ static boolean doNativeObject(Node inliningTarget, PythonNativeObject x, @Shared @Cached(inline = false) IsSubtypeNode isSubtypeNode) { if (isSubtypeNode.execute(getClassNode.execute(inliningTarget, x), PythonBuiltinClassType.Boolean)) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); } // the object's type is not a subclass of 'int' throw CannotCastException.INSTANCE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaByteNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaByteNode.java index 4e90ebee00..84ecb014d8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaByteNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaByteNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -94,33 +94,33 @@ static byte fromPInt(PInt x) { @Specialization(replaces = "fromInt") @InliningCutoff static byte fromIntErr(Node inliningTarget, int x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return PInt.byteValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); } } @Specialization(replaces = "fromLong") @InliningCutoff static byte fromLongErr(Node inliningTarget, long x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return PInt.byteValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); } } @Specialization(replaces = "fromPInt") @InliningCutoff static byte fromPIntErr(Node inliningTarget, PInt x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return x.byteValueExact(); } catch (ArithmeticException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.BYTE_MUST_BE_IN_RANGE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntExactNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntExactNode.java index 310b6d7e15..c9b3c77218 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntExactNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntExactNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -67,15 +67,15 @@ @GenerateCached public abstract class CastToJavaIntExactNode extends CastToJavaIntNode { - public final int executeWithThrowSystemError(Node inliningTarget, Object x, PRaiseNode.Lazy raiseNode) { + public final int executeWithThrowSystemError(Node inliningTarget, Object x, PRaiseNode raiseNode) { return executeWithThrow(inliningTarget, x, raiseNode, SystemError); } - public final int executeWithThrow(Node inliningTarget, Object x, PRaiseNode.Lazy raiseNode, PythonBuiltinClassType errType) { + public final int executeWithThrow(Node inliningTarget, Object x, PRaiseNode raiseNode, PythonBuiltinClassType errType) { try { return execute(inliningTarget, x); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(errType, MUST_BE_S_NOT_P, "an int", x); + throw raiseNode.raise(inliningTarget, errType, MUST_BE_S_NOT_P, "an int", x); } } @@ -117,21 +117,21 @@ static int pIntToInt(PInt x) throws OverflowException { @Specialization(replaces = "longToInt") static int longToIntOverflow(Node inliningTarget, long x, - @Shared("raise") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raise") @Cached PRaiseNode raiseNode) { try { return PInt.intValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); } } @Specialization(replaces = "pIntToInt") static int pIntToIntOverflow(Node inliningTarget, PInt x, - @Shared("raise") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raise") @Cached PRaiseNode raiseNode) { try { return x.intValueExact(); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "int"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongExactNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongExactNode.java index 5557e336df..0bae6be64f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongExactNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongExactNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -65,15 +65,15 @@ @GenerateCached(false) public abstract class CastToJavaLongExactNode extends CastToJavaLongNode { - public final long executeWithThrowSystemError(Node inliningTarget, Object x, PRaiseNode.Lazy raiseNode) { + public final long executeWithThrowSystemError(Node inliningTarget, Object x, PRaiseNode raiseNode) { return executeWithThrow(inliningTarget, x, raiseNode, SystemError); } - public final long executeWithThrow(Node inliningTarget, Object x, PRaiseNode.Lazy raiseNode, PythonBuiltinClassType errType) { + public final long executeWithThrow(Node inliningTarget, Object x, PRaiseNode raiseNode, PythonBuiltinClassType errType) { try { return execute(inliningTarget, x); } catch (CannotCastException cce) { - throw raiseNode.get(inliningTarget).raise(errType, MUST_BE_S_NOT_P, "a long", x); + throw raiseNode.raise(inliningTarget, errType, MUST_BE_S_NOT_P, "a long", x); } } @@ -88,11 +88,11 @@ protected static long toLongNoOverflow(PInt x) throws OverflowException { @Specialization(replaces = "toLongNoOverflow") protected static long toLong(Node inliningTarget, PInt x, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { try { return x.longValueExact(); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "long"); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "long"); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongNode.java index 65f49c412c..42d2c10365 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaLongNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -94,7 +94,7 @@ static long doNativeObject(Node inliningTarget, PythonNativeObject x, @Cached(inline = false) IsSubtypeNode isSubtypeNode) { if (isSubtypeNode.execute(getClassNode.execute(inliningTarget, x), PythonBuiltinClassType.PInt)) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); + throw PRaiseNode.raiseStatic(inliningTarget, NotImplementedError, ErrorMessages.CASTING_A_NATIVE_INT_OBJECT_IS_NOT_IMPLEMENTED_YET); } // the object's type is not a subclass of 'int' throw CannotCastException.INSTANCE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaShortNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaShortNode.java index a5f9b5c724..44c254f575 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaShortNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaShortNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -92,31 +92,31 @@ static short fromPInt(PInt x) { @Specialization(replaces = "fromInt") static short fromIntErr(Node inliningTarget, int x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return PInt.shortValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); } } @Specialization(replaces = "fromLong") static short fromLongErr(Node inliningTarget, long x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return PInt.shortValueExact(x); } catch (OverflowException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); } } @Specialization(replaces = "fromPInt") static short fromPIntErr(Node inliningTarget, PInt x, - @Shared("raiseNode") @Cached PRaiseNode.Lazy raiseNode) { + @Shared("raiseNode") @Cached PRaiseNode raiseNode) { try { return x.shortValueExact(); } catch (ArithmeticException e) { - throw raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SHORT_MUST_BE_IN_RANGE); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java index 729cf92e31..44f8d1bf73 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -85,34 +85,33 @@ public static long executeUncached(Object arg) { @Specialization static long toUnsignedLong(Node inliningTarget, long x, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkNegative(x < 0, inliningTarget, raiseNode); return x; } @Specialization static long toUnsignedLong(Node inliningTarget, PInt x, - @Shared @Cached PRaiseNode.Lazy raiseNode) { + @Shared @Cached PRaiseNode raiseNode) { checkNegative(x.isNegative(), inliningTarget, raiseNode); return convertBigInt(x.getValue(), inliningTarget); } @Fallback - static long doUnsupported(Node inliningTarget, @SuppressWarnings("unused") Object x, - @Shared @Cached PRaiseNode.Lazy raiseNode) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.INTEGER_REQUIRED); + static long doUnsupported(Node inliningTarget, @SuppressWarnings("unused") Object x) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); } - private static void checkNegative(boolean negative, Node inliningTarget, PRaiseNode.Lazy raiseNode) { + private static void checkNegative(boolean negative, Node inliningTarget, PRaiseNode raiseNode) { if (negative) { - throw raiseNode.get(inliningTarget).raise(OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); + throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_CONVERT_NEGATIVE_VALUE_TO_UNSIGNED_INT); } } @TruffleBoundary private static long convertBigInt(BigInteger bi, Node nodeForRaise) { if (bi.bitLength() > 64) { - throw PRaiseNode.raiseUncached(nodeForRaise, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "unsigned long"); + throw PRaiseNode.raiseStatic(nodeForRaise, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "unsigned long"); } return bi.longValue(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java index 3d37ed59d9..94265ee82b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java @@ -93,7 +93,7 @@ static PComplex toComplex(VirtualFrame frame, Node inliningTarget, Object x, @Cached(value = "create(T___COMPLEX__)", inline = false) LookupAndCallUnaryNode callComplexFunc, @Cached PyFloatAsDoubleNode asDoubleNode, @Bind PythonLanguage language, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { Object result = callComplexFunc.executeObject(frame, x); if (result != PNone.NO_VALUE) { if (result instanceof PComplex) { @@ -104,7 +104,7 @@ static PComplex toComplex(VirtualFrame frame, Node inliningTarget, Object x, // and may be removed in a future version of Python. return (PComplex) result; } else { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.SHOULD_RETURN, "__complex__", "complex object"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.SHOULD_RETURN, "__complex__", "complex object"); } } return PFactory.createComplex(language, asDoubleNode.execute(frame, inliningTarget, x), 0); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java index f38d0d289a..4abb27fdc0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -1902,7 +1902,7 @@ public TruffleString crypt(TruffleString word, TruffleString salt, cryptLibrary = InvokeNativeFunction.loadLibrary(this, PythonOS.getPythonOS() != PythonOS.PLATFORM_DARWIN ? "libcrypt.so" : null); } catch (Throwable e) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(invokeNode, PythonBuiltinClassType.SystemError, ErrorMessages.UNABLE_TO_LOAD_LIBCRYPT); + throw PRaiseNode.raiseStatic(invokeNode, PythonBuiltinClassType.SystemError, ErrorMessages.UNABLE_TO_LOAD_LIBCRYPT); } } PosixNativeFunction function = PosixNativeFunction.crypt; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java index 2dc3794f47..4047597076 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java @@ -2737,13 +2737,13 @@ public long getDeserializationId(TruffleString fileName) { public void ensureLLVMLanguage(Node nodeForRaise) { if (!env.getInternalLanguages().containsKey(J_LLVM_LANGUAGE)) { - throw PRaiseNode.raiseUncached(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.LLVM_NOT_AVAILABLE); + throw PRaiseNode.raiseStatic(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.LLVM_NOT_AVAILABLE); } } public void ensureNFILanguage(Node nodeForRaise, String optionName, String optionValue) { if (!env.getInternalLanguages().containsKey(J_NFI_LANGUAGE)) { - throw PRaiseNode.raiseUncached(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.NFI_NOT_AVAILABLE, optionName, optionValue); + throw PRaiseNode.raiseStatic(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.NFI_NOT_AVAILABLE, optionName, optionValue); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java index 5b16500d7c..692621f783 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/BytesFormatProcessor.java @@ -100,7 +100,7 @@ char pop() { try { return (char) formatBytes[index++]; } catch (ArrayIndexOutOfBoundsException e) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.INCOMPLETE_FORMAT); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.INCOMPLETE_FORMAT); } } @@ -132,7 +132,7 @@ protected double asFloat(Object arg) { return super.asFloat(arg); } catch (PException ex) { // exactly like in CPython, all errors are translated to this - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.FLOAT_ARG_REQUIRED, arg); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.FLOAT_ARG_REQUIRED, arg); } } @@ -182,7 +182,7 @@ protected Formatter handleSingleCharacterFormat(Spec spec) { } if (!foundByte) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.C_REQUIRES_INT_IN_BYTE_RANGE_OR_SINGLE_BYTE); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.C_REQUIRES_INT_IN_BYTE_RANGE_OR_SINGLE_BYTE); } BytesFormatter f = new BytesFormatter(buffer, spec, raisingNode); @@ -191,7 +191,7 @@ protected Formatter handleSingleCharacterFormat(Spec spec) { } private PException raiseOverflow() { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE256_DECIMAL); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE256_DECIMAL); } @Override @@ -228,14 +228,14 @@ private byte[] asBytes(Object arg) { if (attribute != PNone.NO_VALUE) { Object bytesResult = call(attribute, arg); if (!(bytesResult instanceof PBytes)) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, arg); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, arg); } return toBytes((PBytes) bytesResult); } // otherwise: use the buffer protocol byte[] result = byteBufferAsBytesOrNull(arg); if (result == null) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.B_REQUIRES_BYTES_OR_OBJ_THAT_IMPLEMENTS_S_NOT_P, T___BYTES__, arg); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.B_REQUIRES_BYTES_OR_OBJ_THAT_IMPLEMENTS_S_NOT_P, T___BYTES__, arg); } return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java index 359ce10183..7d2bb423b9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/FormatProcessor.java @@ -128,7 +128,7 @@ Object getArg() { break; } if (ret == null) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.NOT_ENOUGH_ARGS_FOR_FORMAT_STRING); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.NOT_ENOUGH_ARGS_FOR_FORMAT_STRING); } return ret; } @@ -140,11 +140,11 @@ int getNumber() { try { long value = CastToJavaLongLossyNode.executeUncached(o); if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "size"); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.PYTHON_INT_TOO_LARGE_TO_CONV_TO, "size"); } return (int) value; } catch (CannotCastException e) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.STAR_WANTS_INT); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.STAR_WANTS_INT); } } else { if (Character.isDigit(c)) { @@ -156,7 +156,7 @@ int getNumber() { try { return parseNumber(numStart, index); } catch (NumberFormatException e) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.TOO_MANY_DECIMAL_DIGITS_IN_FORMAT_STRING); } } index -= 1; @@ -247,7 +247,7 @@ public T format(Object args1) { try { return formatImpl(args1); } catch (OutOfMemoryError e) { - throw PRaiseNode.raiseUncached(raisingNode, MemoryError); + throw PRaiseNode.raiseStatic(raisingNode, MemoryError); } } @@ -311,7 +311,7 @@ private T formatImpl(Object args1) { if (c == '(') { // Mapping key, consisting of a parenthesised sequence of characters. if (mapping == null) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.FORMAT_REQUIRES_MAPPING); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.FORMAT_REQUIRES_MAPPING); } // Scan along until a matching close parenthesis is found int parens = 1; @@ -450,9 +450,9 @@ private T formatImpl(Object args1) { f = formatInteger(asNumber(arg, spec.type), spec); if (f == null) { if (allowsFloat(spec.type)) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.S_FORMAT_NUMBER_IS_REQUIRED_NOT_S, spec.type, arg); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.S_FORMAT_NUMBER_IS_REQUIRED_NOT_S, spec.type, arg); } else { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.S_FORMAT_INTEGER_IS_REQUIRED_NOT_S, spec.type, arg); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.S_FORMAT_INTEGER_IS_REQUIRED_NOT_S, spec.type, arg); } } break; @@ -474,7 +474,7 @@ private T formatImpl(Object args1) { default: f = handleRemainingFormats(spec); if (f == null) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.UNSUPPORTED_FORMAT_CHAR_AT_INDEX, spec.type, (int) spec.type, index - 1); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.UNSUPPORTED_FORMAT_CHAR_AT_INDEX, spec.type, (int) spec.type, index - 1); } } @@ -490,7 +490,7 @@ private T formatImpl(Object args1) { * that has not yet been used. */ if (argIndex == -1 || (argIndex >= 0 && PyObjectSizeNode.executeUncached(args1) >= argIndex + 1)) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.NOT_ALL_ARGS_CONVERTED_DURING_FORMATTING, getFormatType()); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.NOT_ALL_ARGS_CONVERTED_DURING_FORMATTING, getFormatType()); } // Return the final buffer contents as a str or unicode as appropriate. diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/IntegerFormatter.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/IntegerFormatter.java index 8d382e375d..d8b79363e7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/IntegerFormatter.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/IntegerFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) -2016 Jython Developers * * Licensed under PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -286,7 +286,7 @@ void format_b(BigInteger value) { final void format_c(BigInteger value) { assert !bytes; // for bytes we use directly BytesFormatter if (value.signum() < 0 || value.compareTo(LIMIT_UNICODE) >= 0) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE, toHexString(LIMIT_UNICODE)); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE, toHexString(LIMIT_UNICODE)); } result.appendCodePoint(value.intValue()); } @@ -466,7 +466,7 @@ void format_b(int value) { final void format_c(int value) { assert !bytes; // for bytes we use directly BytesFormatter if (value < 0 || value >= LIMIT_UNICODE.intValue()) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE, toHexString(LIMIT_UNICODE)); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.C_ARG_NOT_IN_RANGE, toHexString(LIMIT_UNICODE)); } result.appendCodePoint(value); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/InternalFormat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/InternalFormat.java index e9b7ef25a6..ca4d7e6df3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/InternalFormat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/InternalFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) -2016 Jython Developers * * Licensed under PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -508,7 +508,7 @@ protected void zeroPadAfterSignWithGroupingFixup(int groupSize, char comma) { * @return exception to throw */ public static PException unknownFormat(char code, String forType, Node raisingNode) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.UNKNOWN_FORMAT_CODE, code, forType); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.UNKNOWN_FORMAT_CODE, code, forType); } /** @@ -520,7 +520,7 @@ public static PException unknownFormat(char code, String forType, Node raisingNo * @return exception to throw */ public PException precisionTooLarge(String type) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, ErrorMessages.FORMATED_S_TOO_LONG, type); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, ErrorMessages.FORMATED_S_TOO_LONG, type); } } @@ -806,7 +806,7 @@ Spec parse(char defaultType, char defaultAlignment, Node raisingNode) { width = scanInteger(); } catch (NumberFormatException ex) { // CPython seems to happily parse big ints and then it chokes on the allocation - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.WIDTH_TOO_BIG); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.WIDTH_TOO_BIG); } } @@ -816,11 +816,11 @@ Spec parse(char defaultType, char defaultAlignment, Node raisingNode) { } if (scanPast('_')) { if (specified(grouping)) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_BOTH_COMMA_AND_UNDERSCORE); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_BOTH_COMMA_AND_UNDERSCORE); } grouping = '_'; if (scanPast(',')) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_BOTH_COMMA_AND_UNDERSCORE); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_BOTH_COMMA_AND_UNDERSCORE); } } @@ -830,10 +830,10 @@ Spec parse(char defaultType, char defaultAlignment, Node raisingNode) { try { precision = scanInteger(); } catch (NumberFormatException ex) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.PRECISION_TOO_BIG); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.PRECISION_TOO_BIG); } } else { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.FMT_SPECIFIER_MISSING_PRECISION); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.FMT_SPECIFIER_MISSING_PRECISION); } } @@ -844,7 +844,7 @@ Spec parse(char defaultType, char defaultAlignment, Node raisingNode) { // If we haven't reached the end, something is wrong if (ptr != spec.length()) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.INVALID_CONVERSION_SPECIFICATION); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.INVALID_CONVERSION_SPECIFICATION); } // Some basic validation @@ -875,7 +875,7 @@ Spec parse(char defaultType, char defaultAlignment, Node raisingNode) { valid = false; } if (!valid) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_C_WITH_C, grouping, type); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.CANNOT_SPECIFY_C_WITH_C, grouping, type); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/StringFormatProcessor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/StringFormatProcessor.java index 29d67a20a4..b16ebcdc2b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/StringFormatProcessor.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/formatting/StringFormatProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) -2016 Jython Developers * * Licensed under PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -45,7 +45,7 @@ public char pop() { try { return formatText.charAt(index++); } catch (StringIndexOutOfBoundsException e) { - throw PRaiseNode.raiseUncached(raisingNode, ValueError, ErrorMessages.INCOMPLETE_FORMAT); + throw PRaiseNode.raiseStatic(raisingNode, ValueError, ErrorMessages.INCOMPLETE_FORMAT); } } @@ -91,7 +91,7 @@ protected InternalFormat.Formatter handleSingleCharacterFormat(Spec spec) { } else { f = formatInteger(asNumber(arg, spec.type), spec); if (f == null) { - throw PRaiseNode.raiseUncached(raisingNode, TypeError, ErrorMessages.REQUIRES_INT_OR_CHAR, spec.type); + throw PRaiseNode.raiseStatic(raisingNode, TypeError, ErrorMessages.REQUIRES_INT_OR_CHAR, spec.type); } } return f; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java index 2d139cbe55..d071d14823 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java @@ -25,6 +25,8 @@ */ package com.oracle.graal.python.runtime.object; +import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY; + import java.lang.ref.ReferenceQueue; import java.math.BigInteger; import java.util.LinkedHashMap; @@ -907,12 +909,12 @@ public static PBaseException createBaseException(PythonLanguage language, Object * guarantee on how many. Therefore, it is important that this method is simple. In particular, * do not add calls if that can be avoided. */ - public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, TruffleString format, Object[] args) { - return createBaseException(language, cls, shape, null, format, args); + public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, TruffleString format, Object[] formatArgs) { + return createBaseException(language, cls, shape, null, format, formatArgs); } - public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, TruffleString format, Object[] args) { - return createBaseException(language, type, type.getInstanceShape(language), null, format, args); + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, TruffleString format, Object[] formatArgs) { + return createBaseException(language, type, type.getInstanceShape(language), null, format, formatArgs); } public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, Object[] data, TruffleString format, Object[] args) { @@ -932,12 +934,8 @@ public static PBaseException createBaseException(PythonLanguage language, Python return create(language, () -> new PBaseException(type, type.getInstanceShape(language), null)); } - public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, Object[] data) { - return createBaseException(language, type, type.getInstanceShape(language), data); - } - - public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data) { - return create(language, () -> new PBaseException(cls, shape, data)); + public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, TruffleString format) { + return create(language, () -> new PBaseException(type, type.getInstanceShape(language), null, format, EMPTY_OBJECT_ARRAY)); } public static PBaseExceptionGroup createBaseExceptionGroup(PythonLanguage language, Object cls, Shape shape, TruffleString message, Object[] exceptions, Object[] args) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ForeignSequenceStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ForeignSequenceStorage.java index 427909f13f..95dca71385 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ForeignSequenceStorage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/sequence/storage/ForeignSequenceStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -40,6 +40,9 @@ */ package com.oracle.graal.python.runtime.sequence.storage; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.IndexError; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; + import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; @@ -63,9 +66,6 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.IndexError; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; - /* * NOTE: We are not using IndirectCallContext here in this file because it seems unlikely that these interop messages * would call back to Python and that we would also need precise frame info for that case. @@ -131,14 +131,14 @@ public abstract static class ReadNoConversionNode extends PNodeWithContext { static Object read(Node inliningTarget, ForeignSequenceStorage storage, int index, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { gil.release(true); try { return interop.readArrayElement(storage.foreignArray, index); } catch (UnsupportedMessageException ex) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_READABLE, index, storage.foreignArray); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_READABLE, index, storage.foreignArray); } catch (InvalidArrayIndexException ex) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.INVALID_INDEX_S, index); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.INVALID_INDEX_S, index); } finally { gil.acquire(); } @@ -172,16 +172,16 @@ public abstract static class WriteNode extends PNodeWithContext { static void write(Node inliningTarget, ForeignSequenceStorage storage, int index, Object value, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { gil.release(true); try { interop.writeArrayElement(storage.foreignArray, index, value); } catch (InvalidArrayIndexException e) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.INVALID_INDEX_S, index); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.INVALID_INDEX_S, index); } catch (UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_WRITABLE, index, storage.foreignArray); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_WRITABLE, index, storage.foreignArray); } catch (UnsupportedTypeException e) { - throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_P_NOT_SUPPORTED_BY_FOREIGN_OBJ, value); } finally { gil.acquire(); } @@ -199,12 +199,12 @@ public abstract static class RemoveNode extends PNodeWithContext { static void remove(Node inliningTarget, ForeignSequenceStorage storage, int index, @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop, @Cached(inline = false) GilNode gil, - @Cached PRaiseNode.Lazy raiseNode) { + @Cached PRaiseNode raiseNode) { gil.release(true); try { interop.removeArrayElement(storage.foreignArray, index); } catch (InvalidArrayIndexException | UnsupportedMessageException e) { - throw raiseNode.get(inliningTarget).raise(IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_REMOVABLE, index, storage.foreignArray); + throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.ITEM_S_OF_S_OBJ_IS_NOT_REMOVABLE, index, storage.foreignArray); } finally { gil.acquire(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/NumericSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/NumericSupport.java index 1d99d9a29f..adba7ba6bc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/NumericSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/NumericSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -127,7 +127,7 @@ static short floatToShortBits(double value, Node raisingNode) { e = (int) fraction[1]; if (f < 0.5 || f >= 1.0) { - throw PRaiseNode.raiseUncached(raisingNode, SystemError, RES_O_O_RANGE, "frexp()"); + throw PRaiseNode.raiseStatic(raisingNode, SystemError, RES_O_O_RANGE, "frexp()"); } // Normalize f to be in the range [1.0, 2.0) @@ -135,7 +135,7 @@ static short floatToShortBits(double value, Node raisingNode) { e--; if (e >= 16) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "e"); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "e"); } else if (e < -25) { // |x| < 2**-25. Underflow to zero. f = 0.0; @@ -162,7 +162,7 @@ static short floatToShortBits(double value, Node raisingNode) { bits = 0; ++e; if (e == 31) { - throw PRaiseNode.raiseUncached(raisingNode, OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "e"); + throw PRaiseNode.raiseStatic(raisingNode, OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "e"); } } } @@ -391,7 +391,7 @@ public double getDouble(byte[] buffer, int index, int numBytes) throws IndexOutO } } - public void putDouble(Node inliningTarget, byte[] buffer, int index, double value, int numBytes, PRaiseNode.Lazy raiseNode) throws IndexOutOfBoundsException { + public void putDouble(Node inliningTarget, byte[] buffer, int index, double value, int numBytes, PRaiseNode raiseNode) throws IndexOutOfBoundsException { switch (numBytes) { case 2: putHalfFloat(buffer, index, value, inliningTarget); @@ -399,7 +399,7 @@ public void putDouble(Node inliningTarget, byte[] buffer, int index, double valu case 4: final float fValue = (float) value; if (Float.isInfinite(fValue) && Double.isFinite(value)) { - throw raiseNode.get(inliningTarget).raise(OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "f"); + throw raiseNode.raise(inliningTarget, OverflowError, FLOAT_TO_LARGE_TO_PACK_WITH_S_FMT, "f"); } putFloat(buffer, index, fValue); break; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java index 2700fa86c3..d47f9bf51f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java @@ -471,7 +471,7 @@ public static int toIntError(long x) { int r = (int) x; if (r != x) { CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseUncached(null, SystemError, ErrorMessages.INTERNAL_INT_OVERFLOW); + throw PRaiseNode.raiseStatic(null, SystemError, ErrorMessages.INTERNAL_INT_OVERFLOW); } return r; } From 02e6a9012db1347facf61b4cf5a5f5902e76d6a1 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Mon, 10 Feb 2025 09:48:49 +0100 Subject: [PATCH 017/512] Don't use lambdas in PFactory for now --- .../graal/python/runtime/object/PFactory.java | 457 +++++++++--------- 1 file changed, 225 insertions(+), 232 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java index d071d14823..55aa0456f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java @@ -259,28 +259,25 @@ public final class PFactory { private PFactory() { } - private static T create(PythonLanguage language, Supplier constructor) { + private static T trace(PythonLanguage language, T newInstance) { AllocationReporter reporter = language.getAllocationReporter(); if (reporter.isActive()) { - return createWithTrace(constructor, reporter); - } else { - return constructor.get(); + doTrace(newInstance, reporter); } + return newInstance; } @InliningCutoff - private static T createWithTrace(Supplier constructor, AllocationReporter reporter) { + private static void doTrace(T newInstance, AllocationReporter reporter) { reporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN); - T allocatedObject = constructor.get(); - reporter.onReturnValue(allocatedObject, 0, AllocationReporter.SIZE_UNKNOWN); - return allocatedObject; + reporter.onReturnValue(newInstance, 0, AllocationReporter.SIZE_UNKNOWN); } /* * Python objects */ public static PythonObject createPythonObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> (new PythonObject(cls, shape))); + return trace(language, new PythonObject(cls, shape)); } /** @@ -288,15 +285,15 @@ public static PythonObject createPythonObject(PythonLanguage language, Object cl * shape had been cached, due to the additional shape lookup. */ public static PythonObject createPythonHPyObject(PythonLanguage language, Object cls, Shape shape, Object hpyNativeSpace) { - return create(language, () -> new PythonHPyObject(cls, shape, hpyNativeSpace)); + return trace(language, new PythonHPyObject(cls, shape, hpyNativeSpace)); } public static PythonNativeVoidPtr createNativeVoidPtr(PythonLanguage language, Object obj) { - return create(language, () -> new PythonNativeVoidPtr(obj)); + return trace(language, new PythonNativeVoidPtr(obj)); } public static PythonNativeVoidPtr createNativeVoidPtr(PythonLanguage language, Object obj, long nativePtr) { - return create(language, () -> new PythonNativeVoidPtr(obj, nativePtr)); + return trace(language, new PythonNativeVoidPtr(obj, nativePtr)); } public static SuperObject createSuperObject(PythonLanguage language) { @@ -304,7 +301,7 @@ public static SuperObject createSuperObject(PythonLanguage language) { } public static SuperObject createSuperObject(PythonLanguage language, Object self, Shape shape) { - return create(language, () -> new SuperObject(self, shape)); + return trace(language, new SuperObject(self, shape)); } public static PInt createInt(PythonLanguage language, long value) { @@ -325,7 +322,7 @@ public static PInt createInt(PythonLanguage language, Object cls, Shape shape, l } public static PInt createInt(PythonLanguage language, Object cls, Shape shape, BigInteger value) { - return create(language, () -> new PInt(cls, shape, value)); + return trace(language, new PInt(cls, shape, value)); } public static PFloat createFloat(PythonLanguage language, double value) { @@ -333,7 +330,7 @@ public static PFloat createFloat(PythonLanguage language, double value) { } public static PFloat createFloat(PythonLanguage language, Object cls, Shape shape, double value) { - return create(language, () -> new PFloat(cls, shape, value)); + return trace(language, new PFloat(cls, shape, value)); } public static PString createString(PythonLanguage language, TruffleString string) { @@ -341,7 +338,7 @@ public static PString createString(PythonLanguage language, TruffleString string } public static PString createString(PythonLanguage language, Object cls, Shape shape, TruffleString string) { - return create(language, () -> new PString(cls, shape, string)); + return trace(language, new PString(cls, shape, string)); } public static PString createString(PythonLanguage language, NativeCharSequence string) { @@ -349,7 +346,7 @@ public static PString createString(PythonLanguage language, NativeCharSequence s } public static PString createString(PythonLanguage language, Object cls, Shape shape, NativeCharSequence string) { - return create(language, () -> new PString(cls, shape, string)); + return trace(language, new PString(cls, shape, string)); } public static PBytes createEmptyBytes(PythonLanguage language) { @@ -377,7 +374,7 @@ public static PBytes createBytes(PythonLanguage language, Object cls, Shape shap } public static PBytes createBytes(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage) { - return create(language, () -> new PBytes(cls, shape, storage)); + return trace(language, new PBytes(cls, shape, storage)); } public static PTuple createEmptyTuple(PythonLanguage language) { @@ -401,7 +398,7 @@ public static PTuple createTuple(PythonLanguage language, SequenceStorage store) } public static PTuple createTuple(PythonLanguage language, Object cls, Shape shape, SequenceStorage store) { - return create(language, () -> new PTuple(cls, shape, store)); + return trace(language, new PTuple(cls, shape, store)); } public static PTuple createStructSeq(PythonLanguage language, BuiltinTypeDescriptor desc, Object... values) { @@ -414,11 +411,11 @@ public static PTupleGetter createTupleGetter(PythonLanguage language, int index, } public static PTupleGetter createTupleGetter(PythonLanguage language, Object cls, Shape shape, int index, Object doc) { - return create(language, () -> new PTupleGetter(cls, shape, index, doc)); + return trace(language, new PTupleGetter(cls, shape, index, doc)); } public static PComplex createComplex(PythonLanguage language, Object cls, Shape shape, double real, double imag) { - return create(language, () -> new PComplex(cls, shape, real, imag)); + return trace(language, new PComplex(cls, shape, real, imag)); } public static PComplex createComplex(PythonLanguage language, double real, double imag) { @@ -426,31 +423,31 @@ public static PComplex createComplex(PythonLanguage language, double real, doubl } public static PIntRange createIntRange(PythonLanguage language, int stop) { - return create(language, () -> new PIntRange(language, 0, stop, 1, stop)); + return trace(language, new PIntRange(language, 0, stop, 1, stop)); } public static PIntRange createIntRange(PythonLanguage language, int start, int stop, int step, int len) { - return create(language, () -> new PIntRange(language, start, stop, step, len)); + return trace(language, new PIntRange(language, start, stop, step, len)); } public static PBigRange createBigRange(PythonLanguage language, PInt start, PInt stop, PInt step, PInt len) { - return create(language, () -> new PBigRange(language, start, stop, step, len)); + return trace(language, new PBigRange(language, start, stop, step, len)); } public static PIntSlice createIntSlice(PythonLanguage language, int start, int stop, int step) { - return create(language, () -> new PIntSlice(language, start, stop, step)); + return trace(language, new PIntSlice(language, start, stop, step)); } public static PIntSlice createIntSlice(PythonLanguage language, int start, int stop, int step, boolean isStartNone, boolean isStepNone) { - return create(language, () -> new PIntSlice(language, start, stop, step, isStartNone, isStepNone)); + return trace(language, new PIntSlice(language, start, stop, step, isStartNone, isStepNone)); } public static PObjectSlice createObjectSlice(PythonLanguage language, Object start, Object stop, Object step) { - return create(language, () -> new PObjectSlice(language, start, stop, step)); + return trace(language, new PObjectSlice(language, start, stop, step)); } public static PRandom createRandom(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PRandom(cls, shape)); + return trace(language, new PRandom(cls, shape)); } /* @@ -461,11 +458,11 @@ public static PRandom createRandom(PythonLanguage language, Object cls, Shape sh * Only to be used during context creation */ public static PythonModule createPythonModule(PythonLanguage language, TruffleString name) { - return create(language, () -> PythonModule.createInternal(name)); + return trace(language, PythonModule.createInternal(name)); } public static PythonModule createPythonModule(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PythonModule(cls, shape)); + return trace(language, new PythonModule(cls, shape)); } public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language, TruffleString name, Object base, PythonAbstractClass[] bases) { @@ -473,7 +470,7 @@ public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language } public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language, Object metaclass, Shape metaclassShape, TruffleString name, Object base, PythonAbstractClass[] bases) { - PythonClass result = create(language, () -> new PythonClass(language, metaclass, metaclassShape, name, base, bases)); + PythonClass result = trace(language, new PythonClass(language, metaclass, metaclassShape, name, base, bases)); // Fixup tp slots MroSequenceStorage mro = GetMroStorageNode.executeUncached(result); SpecialMethodSlot.initializeSpecialMethodSlots(result, mro, language); @@ -486,27 +483,27 @@ public static PythonClass createPythonClassAndFixupSlots(PythonLanguage language public static PythonClass createPythonClass(PythonLanguage language, Object metaclass, Shape metaclassShape, TruffleString name, boolean invokeMro, Object base, PythonAbstractClass[] bases) { // Note: called from type ctor, which itself will invoke setupSpecialMethodSlots at the // right point - return create(language, () -> new PythonClass(language, metaclass, metaclassShape, name, invokeMro, base, bases)); + return trace(language, new PythonClass(language, metaclass, metaclassShape, name, invokeMro, base, bases)); } public static PMemoryView createMemoryView(PythonLanguage language, PythonContext context, BufferLifecycleManager bufferLifecycleManager, Object buffer, Object owner, int len, boolean readonly, int itemsize, BufferFormat format, TruffleString formatString, int ndim, Object bufPointer, int offset, int[] shape, int[] strides, int[] suboffsets, int flags) { PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; - return create(language, () -> new PMemoryView(cls, cls.getInstanceShape(language), context, bufferLifecycleManager, buffer, owner, len, readonly, itemsize, format, formatString, + return trace(language, new PMemoryView(cls, cls.getInstanceShape(language), context, bufferLifecycleManager, buffer, owner, len, readonly, itemsize, format, formatString, ndim, bufPointer, offset, shape, strides, suboffsets, flags)); } public static PMemoryView createMemoryViewForManagedObject(PythonLanguage language, Object buffer, Object owner, int itemsize, int length, boolean readonly, TruffleString format, TruffleString.CodePointLengthNode lengthNode, TruffleString.CodePointAtIndexNode atIndexNode) { PythonBuiltinClassType cls = PythonBuiltinClassType.PMemoryView; - return create(language, () -> new PMemoryView(cls, cls.getInstanceShape(language), null, null, buffer, owner, length, readonly, itemsize, + return trace(language, new PMemoryView(cls, cls.getInstanceShape(language), null, null, buffer, owner, length, readonly, itemsize, BufferFormat.forMemoryView(format, lengthNode, atIndexNode), format, 1, null, 0, new int[]{length / itemsize}, new int[]{itemsize}, null, PMemoryView.FLAG_C | PMemoryView.FLAG_FORTRAN)); } public static PMethod createMethod(PythonLanguage language, Object cls, Shape shape, Object self, Object function) { - return create(language, () -> new PMethod(cls, shape, self, function)); + return trace(language, new PMethod(cls, shape, self, function)); } public static PMethod createMethod(PythonLanguage language, Object self, Object function) { @@ -518,11 +515,11 @@ public static PMethod createBuiltinMethod(PythonLanguage language, Object self, } public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object cls, Shape shape, Object self, PBuiltinFunction function) { - return create(language, () -> new PBuiltinMethod(cls, shape, self, function, null)); + return trace(language, new PBuiltinMethod(cls, shape, self, function, null)); } public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object self, PBuiltinFunction function, Object classObject) { - return create(language, () -> new PBuiltinMethod(PythonBuiltinClassType.PBuiltinMethod, PythonBuiltinClassType.PBuiltinMethod.getInstanceShape(language), self, function, classObject)); + return trace(language, new PBuiltinMethod(PythonBuiltinClassType.PBuiltinMethod, PythonBuiltinClassType.PBuiltinMethod.getInstanceShape(language), self, function, classObject)); } public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object self, PBuiltinFunction function) { @@ -530,82 +527,80 @@ public static PBuiltinMethod createBuiltinMethod(PythonLanguage language, Object } public static PFunction createFunction(PythonLanguage language, TruffleString name, PCode code, PythonObject globals, PCell[] closure) { - return create(language, () -> new PFunction(language, name, name, code, globals, closure)); + return trace(language, new PFunction(language, name, name, code, globals, closure)); } public static PFunction createFunction(PythonLanguage language, TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure) { - return create(language, () -> new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure)); + return trace(language, new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure)); } public static PFunction createFunction(PythonLanguage language, TruffleString name, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure) { - return create(language, () -> new PFunction(language, name, name, code, globals, defaultValues, kwDefaultValues, closure)); + return trace(language, new PFunction(language, name, name, code, globals, defaultValues, kwDefaultValues, closure)); } public static PFunction createFunction(PythonLanguage language, TruffleString name, TruffleString qualname, PCode code, PythonObject globals, Object[] defaultValues, PKeyword[] kwDefaultValues, PCell[] closure, Assumption codeStableAssumption, Assumption defaultsStableAssumption) { - return create(language, () -> new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure, + return trace(language, new PFunction(language, name, qualname, code, globals, defaultValues, kwDefaultValues, closure, codeStableAssumption, defaultsStableAssumption)); } public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget) { - return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, + return trace(language, new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget)); } public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget) { - return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, defaults, kw, flags, + return trace(language, new PBuiltinFunction(PythonBuiltinClassType.PBuiltinFunction, PythonBuiltinClassType.PBuiltinFunction.getInstanceShape(language), name, type, defaults, kw, flags, callTarget)); } public static PBuiltinFunction createWrapperDescriptor(PythonLanguage language, TruffleString name, Object type, int numDefaults, int flags, RootCallTarget callTarget, TpSlot slot, PExternalFunctionWrapper slotWrapper) { - return create(language, () -> new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, + return trace(language, new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, PBuiltinFunction.generateDefaults(numDefaults), null, flags, callTarget, slot, slotWrapper)); } public static PBuiltinFunction createWrapperDescriptor(PythonLanguage language, TruffleString name, Object type, Object[] defaults, PKeyword[] kw, int flags, RootCallTarget callTarget, TpSlot slot, PExternalFunctionWrapper slotWrapper) { - return create(language, - () -> new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, defaults, kw, flags, - callTarget, slot, slotWrapper)); + return trace(language, new PBuiltinFunction(PythonBuiltinClassType.WrapperDescriptor, PythonBuiltinClassType.WrapperDescriptor.getInstanceShape(language), name, type, defaults, kw, flags, + callTarget, slot, slotWrapper)); } public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, PBuiltinFunction function, Object klass) { PythonBuiltinClassType type = (PythonBuiltinClassType) function.getInitialPythonClass(); - return create(language, () -> new PBuiltinFunction(type, type.getInstanceShape(language), function.getName(), klass, + return trace(language, new PBuiltinFunction(type, type.getInstanceShape(language), function.getName(), klass, function.getDefaults(), function.getKwDefaults(), function.getFlags(), function.getCallTarget(), function.getSlot(), function.getSlotWrapper())); } public static GetSetDescriptor createGetSetDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type) { - return create(language, () -> new GetSetDescriptor(language, get, set, name, type)); + return trace(language, new GetSetDescriptor(language, get, set, name, type)); } public static GetSetDescriptor createGetSetDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type, boolean allowsDelete) { - return create(language, () -> new GetSetDescriptor(language, get, set, name, type, allowsDelete)); + return trace(language, new GetSetDescriptor(language, get, set, name, type, allowsDelete)); } public static GetSetDescriptor createMemberDescriptor(PythonLanguage language, Object get, Object set, TruffleString name, Object type) { - return create(language, - () -> new GetSetDescriptor(PythonBuiltinClassType.MemberDescriptor, PythonBuiltinClassType.MemberDescriptor.getInstanceShape(language), get, set, name, type, set != null)); + return trace(language, new GetSetDescriptor(PythonBuiltinClassType.MemberDescriptor, PythonBuiltinClassType.MemberDescriptor.getInstanceShape(language), get, set, name, type, set != null)); } public static IndexedSlotDescriptor createIndexedSlotDescriptor(PythonLanguage language, TruffleString name, int index, Object type) { - return create(language, () -> new IndexedSlotDescriptor(language, name, index, type)); + return trace(language, new IndexedSlotDescriptor(language, name, index, type)); } public static PDecoratedMethod createClassmethod(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PDecoratedMethod(cls, shape)); + return trace(language, new PDecoratedMethod(cls, shape)); } public static PDecoratedMethod createClassmethodFromCallableObj(PythonLanguage language, Object callable) { - return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PClassmethod, PythonBuiltinClassType.PClassmethod.getInstanceShape(language), callable)); + return trace(language, new PDecoratedMethod(PythonBuiltinClassType.PClassmethod, PythonBuiltinClassType.PClassmethod.getInstanceShape(language), callable)); } public static PDecoratedMethod createBuiltinClassmethodFromCallableObj(PythonLanguage language, Object callable) { - return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PBuiltinClassMethod, PythonBuiltinClassType.PBuiltinClassMethod.getInstanceShape(language), callable)); + return trace(language, new PDecoratedMethod(PythonBuiltinClassType.PBuiltinClassMethod, PythonBuiltinClassType.PBuiltinClassMethod.getInstanceShape(language), callable)); } public static PDecoratedMethod createInstancemethod(PythonLanguage language) { @@ -613,7 +608,7 @@ public static PDecoratedMethod createInstancemethod(PythonLanguage language) { } public static PDecoratedMethod createInstancemethod(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PDecoratedMethod(cls, shape)); + return trace(language, new PDecoratedMethod(cls, shape)); } public static PDecoratedMethod createStaticmethod(PythonLanguage language) { @@ -621,7 +616,7 @@ public static PDecoratedMethod createStaticmethod(PythonLanguage language) { } public static PDecoratedMethod createStaticmethod(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PDecoratedMethod(cls, shape)); + return trace(language, new PDecoratedMethod(cls, shape)); } public static PDecoratedMethod createStaticmethodFromCallableObj(PythonLanguage language, Object callable) { @@ -636,7 +631,7 @@ public static PDecoratedMethod createStaticmethodFromCallableObj(PythonLanguage } else { func = callable; } - return create(language, () -> new PDecoratedMethod(PythonBuiltinClassType.PStaticmethod, PythonBuiltinClassType.PStaticmethod.getInstanceShape(language), func)); + return trace(language, new PDecoratedMethod(PythonBuiltinClassType.PStaticmethod, PythonBuiltinClassType.PStaticmethod.getInstanceShape(language), func)); } /* @@ -668,7 +663,7 @@ public static PList createList(PythonLanguage language, Object cls, Shape shape, } public static PList createList(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage, PList.ListOrigin origin) { - return create(language, () -> new PList(cls, shape, storage, origin)); + return trace(language, new PList(cls, shape, storage, origin)); } public static PSet createSet(PythonLanguage language) { @@ -684,7 +679,7 @@ public static PSet createSet(PythonLanguage language, Object cls, Shape shape) { } public static PSet createSet(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { - return create(language, () -> new PSet(cls, shape, storage)); + return trace(language, new PSet(cls, shape, storage)); } public static PFrozenSet createFrozenSet(PythonLanguage language) { @@ -696,7 +691,7 @@ public static PFrozenSet createFrozenSet(PythonLanguage language, HashingStorage } public static PFrozenSet createFrozenSet(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { - return create(language, () -> new PFrozenSet(cls, shape, storage)); + return trace(language, new PFrozenSet(cls, shape, storage)); } public static PDict createDict(PythonLanguage language) { @@ -712,31 +707,31 @@ public static PDict createDict(PythonLanguage language, HashingStorage storage) } public static PDict createDict(PythonLanguage language, Object cls, Shape shape, HashingStorage storage) { - return create(language, () -> new PDict(cls, shape, storage)); + return trace(language, new PDict(cls, shape, storage)); } public static POrderedDict createOrderedDict(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new POrderedDict(cls, shape)); + return trace(language, new POrderedDict(cls, shape)); } public static PDictKeysView createOrderedDictKeys(PythonLanguage language, POrderedDict dict) { PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictKeys; - return create(language, () -> new PDictKeysView(cls, cls.getInstanceShape(language), dict)); + return trace(language, new PDictKeysView(cls, cls.getInstanceShape(language), dict)); } public static PDictValuesView createOrderedDictValues(PythonLanguage language, POrderedDict dict) { PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictValues; - return create(language, () -> new PDictValuesView(cls, cls.getInstanceShape(language), dict)); + return trace(language, new PDictValuesView(cls, cls.getInstanceShape(language), dict)); } public static PDictItemsView createOrderedDictItems(PythonLanguage language, POrderedDict dict) { PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictItems; - return create(language, () -> new PDictItemsView(cls, cls.getInstanceShape(language), dict)); + return trace(language, new PDictItemsView(cls, cls.getInstanceShape(language), dict)); } public static POrderedDictIterator createOrderedDictIterator(PythonLanguage language, POrderedDict dict, POrderedDictIterator.IteratorType type, boolean reversed) { PythonBuiltinClassType cls = PythonBuiltinClassType.POrderedDictIterator; - return create(language, () -> new POrderedDictIterator(cls, cls.getInstanceShape(language), dict, type, reversed)); + return trace(language, new POrderedDictIterator(cls, cls.getInstanceShape(language), dict, type, reversed)); } public static PDict createDictFromMap(PythonLanguage language, LinkedHashMap map) { @@ -767,19 +762,19 @@ public static PSimpleNamespace createSimpleNamespace(PythonLanguage language) { } public static PSimpleNamespace createSimpleNamespace(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PSimpleNamespace(cls, shape)); + return trace(language, new PSimpleNamespace(cls, shape)); } public static PKeyWrapper createKeyWrapper(PythonLanguage language, Object cmp) { - return create(language, () -> new PKeyWrapper(PythonBuiltinClassType.PKeyWrapper, PythonBuiltinClassType.PKeyWrapper.getInstanceShape(language), cmp)); + return trace(language, new PKeyWrapper(PythonBuiltinClassType.PKeyWrapper, PythonBuiltinClassType.PKeyWrapper.getInstanceShape(language), cmp)); } public static PPartial createPartial(PythonLanguage language, Object cls, Shape shape, Object function, Object[] args, PDict kwDict) { - return create(language, () -> new PPartial(cls, shape, function, args, kwDict)); + return trace(language, new PPartial(cls, shape, function, args, kwDict)); } public static LruCacheObject createLruCacheObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new LruCacheObject(cls, shape)); + return trace(language, new LruCacheObject(cls, shape)); } public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape) { @@ -787,7 +782,7 @@ public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls } public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape, Object defaultFactory) { - return create(language, () -> new PDefaultDict(cls, shape, defaultFactory)); + return trace(language, new PDefaultDict(cls, shape, defaultFactory)); } public static PDefaultDict createDefaultDict(PythonLanguage language, Object defaultFactory, HashingStorage storage) { @@ -795,31 +790,31 @@ public static PDefaultDict createDefaultDict(PythonLanguage language, Object def } public static PDefaultDict createDefaultDict(PythonLanguage language, Object cls, Shape shape, Object defaultFactory, HashingStorage storage) { - return create(language, () -> new PDefaultDict(cls, shape, storage, defaultFactory)); + return trace(language, new PDefaultDict(cls, shape, storage, defaultFactory)); } public static PDictView createDictKeysView(PythonLanguage language, PHashingCollection dict) { - return create(language, () -> new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict)); + return trace(language, new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict)); } public static PDictView createDictKeysView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { - return create(language, () -> new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict, foreignHashingStorage)); + return trace(language, new PDictKeysView(PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictKeysView.getInstanceShape(language), dict, foreignHashingStorage)); } public static PDictView createDictValuesView(PythonLanguage language, PHashingCollection dict) { - return create(language, () -> new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict)); + return trace(language, new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict)); } public static PDictView createDictValuesView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { - return create(language, () -> new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict, foreignHashingStorage)); + return trace(language, new PDictValuesView(PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDictValuesView.getInstanceShape(language), dict, foreignHashingStorage)); } public static PDictView createDictItemsView(PythonLanguage language, PHashingCollection dict) { - return create(language, () -> new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict)); + return trace(language, new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict)); } public static PDictView createDictItemsView(PythonLanguage language, Object dict, ForeignHashingStorage foreignHashingStorage) { - return create(language, () -> new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict, foreignHashingStorage)); + return trace(language, new PDictItemsView(PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictItemsView.getInstanceShape(language), dict, foreignHashingStorage)); } /* @@ -827,24 +822,24 @@ public static PDictView createDictItemsView(PythonLanguage language, Object dict */ public static PGenerator createGenerator(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator)); + return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator)); } public static PGenerator createIterableCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator, true)); + return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator, true)); } public static PGenerator createCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return create(language, () -> PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PCoroutine)); + return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PCoroutine)); } public static PCoroutineWrapper createCoroutineWrapper(PythonLanguage language, PGenerator generator) { - return create(language, () -> new PCoroutineWrapper(language, generator)); + return trace(language, new PCoroutineWrapper(language, generator)); } public static PAsyncGen createAsyncGenerator(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - return create(language, () -> PAsyncGen.create(language, name, qualname, rootNode, callTargets, arguments)); + return trace(language, PAsyncGen.create(language, name, qualname, rootNode, callTargets, arguments)); } public static PMappingproxy createMappingproxy(PythonLanguage language, Object object) { @@ -852,15 +847,15 @@ public static PMappingproxy createMappingproxy(PythonLanguage language, Object o } public static PMappingproxy createMappingproxy(PythonLanguage language, Object cls, Shape shape, Object object) { - return create(language, () -> new PMappingproxy(cls, shape, object)); + return trace(language, new PMappingproxy(cls, shape, object)); } public static PReferenceType createReferenceType(PythonLanguage language, Object cls, Shape shape, Object object, Object callback, ReferenceQueue queue) { - return create(language, () -> new PReferenceType(cls, shape, object, callback, queue)); + return trace(language, new PReferenceType(cls, shape, object, callback, queue)); } public static PCell createCell(PythonLanguage language, Assumption effectivelyFinal) { - return create(language, () -> new PCell(effectivelyFinal)); + return trace(language, new PCell(effectivelyFinal)); } /* @@ -868,23 +863,23 @@ public static PCell createCell(PythonLanguage language, Assumption effectivelyFi */ public static PFrame createPFrame(PythonLanguage language, PFrame.Reference frameInfo, Node location, MaterializedFrame locals) { - return create(language, () -> new PFrame(language, frameInfo, location, locals)); + return trace(language, new PFrame(language, frameInfo, location, locals)); } public static PFrame createPFrame(PythonLanguage language, Object threadState, PCode code, PythonObject globals, Object localsDict) { - return create(language, () -> new PFrame(language, threadState, code, globals, localsDict)); + return trace(language, new PFrame(language, threadState, code, globals, localsDict)); } public static PTraceback createTraceback(PythonLanguage language, PFrame frame, int lineno, PTraceback next) { - return create(language, () -> new PTraceback(language, frame, lineno, -1, next)); + return trace(language, new PTraceback(language, frame, lineno, -1, next)); } public static PTraceback createTracebackWithLasti(PythonLanguage language, PFrame frame, int lineno, int lasti, PTraceback next) { - return create(language, () -> new PTraceback(language, frame, lineno, lasti, next)); + return trace(language, new PTraceback(language, frame, lineno, lasti, next)); } public static PTraceback createTraceback(PythonLanguage language, LazyTraceback tb) { - return create(language, () -> new PTraceback(language, tb)); + return trace(language, new PTraceback(language, tb)); } public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, PTuple args) { @@ -900,7 +895,7 @@ public static PBaseException createBaseException(PythonLanguage language, Python } public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data, PTuple args) { - return create(language, () -> new PBaseException(cls, shape, data, args)); + return trace(language, new PBaseException(cls, shape, data, args)); } /* @@ -923,23 +918,23 @@ public static PBaseException createBaseException(PythonLanguage language, Python public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape, Object[] data, TruffleString format, Object[] args) { assert format != null; - return create(language, () -> new PBaseException(cls, shape, data, format, args)); + return trace(language, new PBaseException(cls, shape, data, format, args)); } public static PBaseException createBaseException(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PBaseException(cls, shape, null)); + return trace(language, new PBaseException(cls, shape, null)); } public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type) { - return create(language, () -> new PBaseException(type, type.getInstanceShape(language), null)); + return trace(language, new PBaseException(type, type.getInstanceShape(language), null)); } public static PBaseException createBaseException(PythonLanguage language, PythonBuiltinClassType type, TruffleString format) { - return create(language, () -> new PBaseException(type, type.getInstanceShape(language), null, format, EMPTY_OBJECT_ARRAY)); + return trace(language, new PBaseException(type, type.getInstanceShape(language), null, format, EMPTY_OBJECT_ARRAY)); } public static PBaseExceptionGroup createBaseExceptionGroup(PythonLanguage language, Object cls, Shape shape, TruffleString message, Object[] exceptions, Object[] args) { - return create(language, () -> new PBaseExceptionGroup(cls, shape, message, exceptions, createTuple(language, args))); + return trace(language, new PBaseExceptionGroup(cls, shape, message, exceptions, createTuple(language, args))); } /* @@ -948,7 +943,7 @@ public static PBaseExceptionGroup createBaseExceptionGroup(PythonLanguage langua public static PArray createArray(PythonLanguage language, Object cls, Shape shape, TruffleString formatString, BufferFormat format) { assert format != null; - return create(language, () -> new PArray(cls, shape, formatString, format)); + return trace(language, new PArray(cls, shape, formatString, format)); } public static PArray createArray(PythonLanguage language, TruffleString formatString, BufferFormat format, int length) throws OverflowException { @@ -958,7 +953,7 @@ public static PArray createArray(PythonLanguage language, TruffleString formatSt public static PArray createArray(PythonLanguage language, Object cls, Shape shape, TruffleString formatString, BufferFormat format, int length) throws OverflowException { assert format != null; int byteSize = PythonUtils.multiplyExact(length, format.bytesize); - return create(language, () -> new PArray(cls, shape, formatString, format, byteSize)); + return trace(language, new PArray(cls, shape, formatString, format, byteSize)); } public static PByteArray createByteArray(PythonLanguage language, byte[] array) { @@ -982,7 +977,7 @@ public static PByteArray createByteArray(PythonLanguage language, SequenceStorag } public static PByteArray createByteArray(PythonLanguage language, Object cls, Shape shape, SequenceStorage storage) { - return create(language, () -> new PByteArray(cls, shape, storage)); + return trace(language, new PByteArray(cls, shape, storage)); } /* @@ -990,31 +985,31 @@ public static PByteArray createByteArray(PythonLanguage language, Object cls, Sh */ public static PStringIterator createStringIterator(PythonLanguage language, TruffleString str) { - return create(language, () -> new PStringIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), str)); + return trace(language, new PStringIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), str)); } public static PStringReverseIterator createStringReverseIterator(PythonLanguage language, Object cls, Shape shape, TruffleString str) { - return create(language, () -> new PStringReverseIterator(cls, shape, str)); + return trace(language, new PStringReverseIterator(cls, shape, str)); } public static PIntegerSequenceIterator createIntegerSequenceIterator(PythonLanguage language, IntSequenceStorage storage, Object list) { - return create(language, () -> new PIntegerSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + return trace(language, new PIntegerSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); } public static PLongSequenceIterator createLongSequenceIterator(PythonLanguage language, LongSequenceStorage storage, Object list) { - return create(language, () -> new PLongSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + return trace(language, new PLongSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); } public static PDoubleSequenceIterator createDoubleSequenceIterator(PythonLanguage language, DoubleSequenceStorage storage, Object list) { - return create(language, () -> new PDoubleSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + return trace(language, new PDoubleSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); } public static PObjectSequenceIterator createObjectSequenceIterator(PythonLanguage language, ObjectSequenceStorage storage, Object list) { - return create(language, () -> new PObjectSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); + return trace(language, new PObjectSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), storage, list)); } public static PSequenceIterator createSequenceIterator(PythonLanguage language, Object sequence) { - return create(language, () -> new PSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), sequence)); + return trace(language, new PSequenceIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), sequence)); } public static PSequenceReverseIterator createSequenceReverseIterator(PythonLanguage language, Object sequence, int lengthHint) { @@ -1022,7 +1017,7 @@ public static PSequenceReverseIterator createSequenceReverseIterator(PythonLangu } public static PSequenceReverseIterator createSequenceReverseIterator(PythonLanguage language, Object cls, Shape shape, Object sequence, int lengthHint) { - return create(language, () -> new PSequenceReverseIterator(cls, shape, sequence, lengthHint)); + return trace(language, new PSequenceReverseIterator(cls, shape, sequence, lengthHint)); } public static PIntRangeIterator createIntRangeIterator(PythonLanguage language, PIntRange fastRange) { @@ -1030,11 +1025,11 @@ public static PIntRangeIterator createIntRangeIterator(PythonLanguage language, } public static PIntRangeIterator createIntRangeIterator(PythonLanguage language, int start, int stop, int step, int len) { - return create(language, () -> new PIntRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); + return trace(language, new PIntRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); } public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, PInt start, PInt stop, PInt step, PInt len) { - return create(language, () -> new PBigRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); + return trace(language, new PBigRangeIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), start, stop, step, len)); } public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, PBigRange longRange) { @@ -1046,58 +1041,58 @@ public static PBigRangeIterator createBigRangeIterator(PythonLanguage language, } public static PArrayIterator createArrayIterator(PythonLanguage language, PArray array) { - return create(language, () -> new PArrayIterator(PythonBuiltinClassType.PArrayIterator, PythonBuiltinClassType.PArrayIterator.getInstanceShape(language), array)); + return trace(language, new PArrayIterator(PythonBuiltinClassType.PArrayIterator, PythonBuiltinClassType.PArrayIterator.getInstanceShape(language), array)); } public static PBaseSetIterator createBaseSetIterator(PythonLanguage language, PBaseSet set, HashingStorageNodes.HashingStorageIterator iterator, int initialSize) { - return create(language, () -> new PBaseSetIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), set, iterator, initialSize)); + return trace(language, new PBaseSetIterator(PythonBuiltinClassType.PIterator, PythonBuiltinClassType.PIterator.getInstanceShape(language), set, iterator, initialSize)); } public static PDictItemIterator createDictItemIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return create(language, () -> new PDictItemIterator(PythonBuiltinClassType.PDictItemIterator, PythonBuiltinClassType.PDictItemIterator.getInstanceShape(language), iterator, hashingStorage, + return trace(language, new PDictItemIterator(PythonBuiltinClassType.PDictItemIterator, PythonBuiltinClassType.PDictItemIterator.getInstanceShape(language), iterator, hashingStorage, initialSize)); } public static PDictKeyIterator createDictKeyIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return create(language, - () -> new PDictKeyIterator(PythonBuiltinClassType.PDictKeyIterator, PythonBuiltinClassType.PDictKeyIterator.getInstanceShape(language), iterator, hashingStorage, initialSize)); + return trace(language, + new PDictKeyIterator(PythonBuiltinClassType.PDictKeyIterator, PythonBuiltinClassType.PDictKeyIterator.getInstanceShape(language), iterator, hashingStorage, initialSize)); } public static PDictValueIterator createDictValueIterator(PythonLanguage language, HashingStorageNodes.HashingStorageIterator iterator, HashingStorage hashingStorage, int initialSize) { - return create(language, () -> new PDictValueIterator(PythonBuiltinClassType.PDictValueIterator, PythonBuiltinClassType.PDictValueIterator.getInstanceShape(language), iterator, hashingStorage, + return trace(language, new PDictValueIterator(PythonBuiltinClassType.PDictValueIterator, PythonBuiltinClassType.PDictValueIterator.getInstanceShape(language), iterator, hashingStorage, initialSize)); } public static Object createSentinelIterator(PythonLanguage language, Object callable, Object sentinel) { - return create(language, () -> new PSentinelIterator(PythonBuiltinClassType.PSentinelIterator, PythonBuiltinClassType.PSentinelIterator.getInstanceShape(language), callable, sentinel)); + return trace(language, new PSentinelIterator(PythonBuiltinClassType.PSentinelIterator, PythonBuiltinClassType.PSentinelIterator.getInstanceShape(language), callable, sentinel)); } public static PEnumerate createEnumerate(PythonLanguage language, Object cls, Shape shape, Object iterator, long start) { - return create(language, () -> new PEnumerate(cls, shape, iterator, start)); + return trace(language, new PEnumerate(cls, shape, iterator, start)); } public static PEnumerate createEnumerate(PythonLanguage language, Object cls, Shape shape, Object iterator, PInt start) { - return create(language, () -> new PEnumerate(cls, shape, iterator, start)); + return trace(language, new PEnumerate(cls, shape, iterator, start)); } public static PMap createMap(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PMap(cls, shape)); + return trace(language, new PMap(cls, shape)); } public static PZip createZip(PythonLanguage language, Object cls, Shape shape, Object[] iterables, boolean strict) { - return create(language, () -> new PZip(cls, shape, iterables, strict)); + return trace(language, new PZip(cls, shape, iterables, strict)); } public static PCode createCode(PythonLanguage language, RootCallTarget ct) { - return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct)); + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct)); } public static PCode createCode(PythonLanguage language, RootCallTarget ct, int flags, int firstlineno, byte[] linetable, TruffleString filename) { - return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct, flags, firstlineno, linetable, filename)); + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct, flags, firstlineno, linetable, filename)); } public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, CodeUnit codeUnit) { - return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, codeUnit)); + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, codeUnit)); } public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, int nlocals, @@ -1106,13 +1101,13 @@ public static PCode createCode(PythonLanguage language, RootCallTarget callTarge TruffleString[] freevars, TruffleString[] cellvars, TruffleString filename, TruffleString name, TruffleString qualname, int firstlineno, byte[] linetable) { - return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, nlocals, stacksize, flags, constants, names, varnames, freevars, cellvars, filename, name, qualname, firstlineno, linetable)); } public static PCode createCode(PythonLanguage language, Supplier createCode, int flags, int firstlineno, byte[] lnotab, TruffleString filename) { - return create(language, () -> new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), createCode, flags, firstlineno, lnotab, filename)); + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), createCode, flags, firstlineno, lnotab, filename)); } /* @@ -1120,7 +1115,7 @@ public static PCode createCode(PythonLanguage language, Supplier cre */ public static PSocket createSocket(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PSocket(cls, shape)); + return trace(language, new PSocket(cls, shape)); } /* @@ -1128,7 +1123,7 @@ public static PSocket createSocket(PythonLanguage language, Object cls, Shape sh */ public static PThreadLocal createThreadLocal(PythonLanguage language, Object cls, Shape shape, Object[] args, PKeyword[] kwArgs) { - return create(language, () -> new PThreadLocal(cls, shape, args, kwArgs)); + return trace(language, new PThreadLocal(cls, shape, args, kwArgs)); } public static PLock createLock(PythonLanguage language) { @@ -1136,11 +1131,11 @@ public static PLock createLock(PythonLanguage language) { } public static PLock createLock(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PLock(cls, shape)); + return trace(language, new PLock(cls, shape)); } public static PRLock createRLock(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PRLock(cls, shape)); + return trace(language, new PRLock(cls, shape)); } public static PThread createPythonThread(PythonLanguage language, Thread thread) { @@ -1148,11 +1143,11 @@ public static PThread createPythonThread(PythonLanguage language, Thread thread) } public static PThread createPythonThread(PythonLanguage language, Object cls, Shape shape, Thread thread) { - return create(language, () -> new PThread(cls, shape, thread)); + return trace(language, new PThread(cls, shape, thread)); } public static PSemLock createSemLock(PythonLanguage language, Object cls, Shape shape, long handle, int kind, int maxValue, TruffleString name) { - return create(language, () -> new PSemLock(cls, shape, handle, kind, maxValue, name)); + return trace(language, new PSemLock(cls, shape, handle, kind, maxValue, name)); } public static PGraalPySemLock createGraalPySemLock(PythonLanguage language, TruffleString name, int kind, Semaphore sharedSemaphore) { @@ -1160,24 +1155,24 @@ public static PGraalPySemLock createGraalPySemLock(PythonLanguage language, Truf } public static PGraalPySemLock createGraalPySemLock(PythonLanguage language, Object cls, Shape shape, TruffleString name, int kind, Semaphore sharedSemaphore) { - return create(language, () -> new PGraalPySemLock(cls, shape, name, kind, sharedSemaphore)); + return trace(language, new PGraalPySemLock(cls, shape, name, kind, sharedSemaphore)); } public static PScandirIterator createScandirIterator(PythonLanguage language, PythonContext context, Object dirStream, PosixFileHandle path, boolean needsRewind) { - return create(language, - () -> new PScandirIterator(PythonBuiltinClassType.PScandirIterator, PythonBuiltinClassType.PScandirIterator.getInstanceShape(language), context, dirStream, path, needsRewind)); + return trace(language, + new PScandirIterator(PythonBuiltinClassType.PScandirIterator, PythonBuiltinClassType.PScandirIterator.getInstanceShape(language), context, dirStream, path, needsRewind)); } public static PDirEntry createDirEntry(PythonLanguage language, Object dirEntryData, PosixFileHandle path) { - return create(language, () -> new PDirEntry(PythonBuiltinClassType.PDirEntry, PythonBuiltinClassType.PDirEntry.getInstanceShape(language), dirEntryData, path)); + return trace(language, new PDirEntry(PythonBuiltinClassType.PDirEntry, PythonBuiltinClassType.PDirEntry.getInstanceShape(language), dirEntryData, path)); } public static PEncodingMap createEncodingMap(PythonLanguage language, int count2, int count3, byte[] level1, byte[] level23) { - return create(language, () -> new PEncodingMap(PythonBuiltinClassType.PEncodingMap, PythonBuiltinClassType.PEncodingMap.getInstanceShape(language), count2, count3, level1, level23)); + return trace(language, new PEncodingMap(PythonBuiltinClassType.PEncodingMap, PythonBuiltinClassType.PEncodingMap.getInstanceShape(language), count2, count3, level1, level23)); } public static PMMap createMMap(PythonLanguage language, PythonContext context, Object cls, Shape shape, Object mmapHandle, int fd, long length, int access) { - return create(language, () -> new PMMap(cls, shape, context, mmapHandle, fd, length, access)); + return trace(language, new PMMap(cls, shape, context, mmapHandle, fd, length, access)); } public static BZ2Object.BZ2Compressor createBZ2Compressor(PythonLanguage language) { @@ -1185,7 +1180,7 @@ public static BZ2Object.BZ2Compressor createBZ2Compressor(PythonLanguage languag } public static BZ2Object.BZ2Compressor createBZ2Compressor(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> BZ2Object.createCompressor(cls, shape)); + return trace(language, BZ2Object.createCompressor(cls, shape)); } public static BZ2Object.BZ2Decompressor createBZ2Decompressor(PythonLanguage language) { @@ -1193,7 +1188,7 @@ public static BZ2Object.BZ2Decompressor createBZ2Decompressor(PythonLanguage lan } public static BZ2Object.BZ2Decompressor createBZ2Decompressor(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> BZ2Object.createDecompressor(cls, shape)); + return trace(language, BZ2Object.createDecompressor(cls, shape)); } public static ZLibCompObject createJavaZLibCompObjectCompress(PythonLanguage language, Object stream, int level, int wbits, int strategy, byte[] zdict) { @@ -1201,7 +1196,7 @@ public static ZLibCompObject createJavaZLibCompObjectCompress(PythonLanguage lan } public static ZLibCompObject createJavaZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object stream, int level, int wbits, int strategy, byte[] zdict) { - return create(language, () -> ZLibCompObject.createJava(cls, shape, stream, level, wbits, strategy, zdict)); + return trace(language, ZLibCompObject.createJava(cls, shape, stream, level, wbits, strategy, zdict)); } public static ZLibCompObject createJavaZLibCompObjectDecompress(PythonLanguage language, Object stream, int wbits, byte[] zdict) { @@ -1209,7 +1204,7 @@ public static ZLibCompObject createJavaZLibCompObjectDecompress(PythonLanguage l } public static ZLibCompObject createJavaZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object stream, int wbits, byte[] zdict) { - return create(language, () -> ZLibCompObject.createJava(cls, shape, stream, wbits, zdict)); + return trace(language, ZLibCompObject.createJava(cls, shape, stream, wbits, zdict)); } public static ZLibCompObject createNativeZLibCompObjectCompress(PythonLanguage language, Object zst, NFIZlibSupport zlibSupport) { @@ -1221,15 +1216,15 @@ public static ZLibCompObject createNativeZLibCompObjectDecompress(PythonLanguage } public static ZLibCompObject createNativeZLibCompObject(PythonLanguage language, Object cls, Shape shape, Object zst, NFIZlibSupport zlibSupport) { - return create(language, () -> ZLibCompObject.createNative(cls, shape, zst, zlibSupport)); + return trace(language, ZLibCompObject.createNative(cls, shape, zst, zlibSupport)); } public static LZMAObject.LZMADecompressor createLZMADecompressor(PythonLanguage language, Object cls, Shape shape, boolean isNative) { - return create(language, () -> LZMAObject.createDecompressor(cls, shape, isNative)); + return trace(language, LZMAObject.createDecompressor(cls, shape, isNative)); } public static LZMAObject.LZMACompressor createLZMACompressor(PythonLanguage language, Object cls, Shape shape, boolean isNative) { - return create(language, () -> LZMAObject.createCompressor(cls, shape, isNative)); + return trace(language, LZMAObject.createCompressor(cls, shape, isNative)); } public static CSVReader createCSVReader(PythonLanguage language, Object inputIter, CSVDialect dialect) { @@ -1237,7 +1232,7 @@ public static CSVReader createCSVReader(PythonLanguage language, Object inputIte } public static CSVReader createCSVReader(PythonLanguage language, Object cls, Shape shape, Object inputIter, CSVDialect dialect) { - return create(language, () -> new CSVReader(cls, shape, inputIter, dialect)); + return trace(language, new CSVReader(cls, shape, inputIter, dialect)); } public static CSVWriter createCSVWriter(PythonLanguage language, Object write, CSVDialect dialect) { @@ -1245,16 +1240,14 @@ public static CSVWriter createCSVWriter(PythonLanguage language, Object write, C } public static CSVWriter createCSVWriter(PythonLanguage language, Object cls, Shape shape, Object write, CSVDialect dialect) { - return create(language, () -> new CSVWriter(cls, shape, write, dialect)); + return trace(language, new CSVWriter(cls, shape, write, dialect)); } public static CSVDialect createCSVDialect(PythonLanguage language, Object cls, Shape shape, TruffleString delimiter, int delimiterCodePoint, boolean doubleQuote, TruffleString escapeChar, int escapeCharCodePoint, TruffleString lineTerminator, TruffleString quoteChar, int quoteCharCodePoint, QuoteStyle quoting, boolean skipInitialSpace, boolean strict) { - return create(language, - () -> new CSVDialect(cls, shape, delimiter, delimiterCodePoint, doubleQuote, escapeChar, escapeCharCodePoint, lineTerminator, quoteChar, quoteCharCodePoint, - quoting, - skipInitialSpace, strict)); + return trace(language, new CSVDialect(cls, shape, delimiter, delimiterCodePoint, doubleQuote, escapeChar, escapeCharCodePoint, lineTerminator, quoteChar, quoteCharCodePoint, quoting, + skipInitialSpace, strict)); } public static PFileIO createFileIO(PythonLanguage language) { @@ -1262,7 +1255,7 @@ public static PFileIO createFileIO(PythonLanguage language) { } public static PFileIO createFileIO(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PFileIO(cls, shape)); + return trace(language, new PFileIO(cls, shape)); } public static PChain createChain(PythonLanguage language) { @@ -1270,31 +1263,31 @@ public static PChain createChain(PythonLanguage language) { } public static PChain createChain(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PChain(cls, shape)); + return trace(language, new PChain(cls, shape)); } public static PCount createCount(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PCount(cls, shape)); + return trace(language, new PCount(cls, shape)); } public static PIslice createIslice(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PIslice(cls, shape)); + return trace(language, new PIslice(cls, shape)); } public static PPairwise createPairwise(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PPairwise(cls, shape)); + return trace(language, new PPairwise(cls, shape)); } public static PPermutations createPermutations(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PPermutations(cls, shape)); + return trace(language, new PPermutations(cls, shape)); } public static PProduct createProduct(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PProduct(cls, shape)); + return trace(language, new PProduct(cls, shape)); } public static PRepeat createRepeat(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PRepeat(cls, shape)); + return trace(language, new PRepeat(cls, shape)); } public static PAccumulate createAccumulate(PythonLanguage language) { @@ -1302,63 +1295,63 @@ public static PAccumulate createAccumulate(PythonLanguage language) { } public static PAccumulate createAccumulate(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PAccumulate(cls, shape)); + return trace(language, new PAccumulate(cls, shape)); } public static PDropwhile createDropwhile(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PDropwhile(cls, shape)); + return trace(language, new PDropwhile(cls, shape)); } public static PCombinations createCombinations(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PCombinations(cls, shape)); + return trace(language, new PCombinations(cls, shape)); } public static PCombinationsWithReplacement createCombinationsWithReplacement(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PCombinationsWithReplacement(cls, shape)); + return trace(language, new PCombinationsWithReplacement(cls, shape)); } public static PCompress createCompress(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PCompress(cls, shape)); + return trace(language, new PCompress(cls, shape)); } public static PCycle createCycle(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PCycle(cls, shape)); + return trace(language, new PCycle(cls, shape)); } public static PFilterfalse createFilterfalse(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PFilterfalse(cls, shape)); + return trace(language, new PFilterfalse(cls, shape)); } public static PGroupBy createGroupBy(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PGroupBy(cls, shape)); + return trace(language, new PGroupBy(cls, shape)); } public static PGrouper createGrouper(PythonLanguage language, PGroupBy parent, Object tgtKey) { - return create(language, () -> new PGrouper(parent, tgtKey, PythonBuiltinClassType.PGrouper, PythonBuiltinClassType.PGrouper.getInstanceShape(language))); + return trace(language, new PGrouper(parent, tgtKey, PythonBuiltinClassType.PGrouper, PythonBuiltinClassType.PGrouper.getInstanceShape(language))); } public static PTee createTee(PythonLanguage language, PTeeDataObject dataObj, int index) { - return create(language, () -> new PTee(dataObj, index, PythonBuiltinClassType.PTee, PythonBuiltinClassType.PTee.getInstanceShape(language))); + return trace(language, new PTee(dataObj, index, PythonBuiltinClassType.PTee, PythonBuiltinClassType.PTee.getInstanceShape(language))); } public static PStarmap createStarmap(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PStarmap(cls, shape)); + return trace(language, new PStarmap(cls, shape)); } public static PTakewhile createTakewhile(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PTakewhile(cls, shape)); + return trace(language, new PTakewhile(cls, shape)); } public static PTeeDataObject createTeeDataObject(PythonLanguage language) { - return create(language, () -> new PTeeDataObject(PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); + return trace(language, new PTeeDataObject(PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); } public static PTeeDataObject createTeeDataObject(PythonLanguage language, Object it) { - return create(language, () -> new PTeeDataObject(it, PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); + return trace(language, new PTeeDataObject(it, PythonBuiltinClassType.PTeeDataObject, PythonBuiltinClassType.PTeeDataObject.getInstanceShape(language))); } public static PZipLongest createZipLongest(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PZipLongest(cls, shape)); + return trace(language, new PZipLongest(cls, shape)); } public static PTextIO createTextIO(PythonLanguage language) { @@ -1366,15 +1359,15 @@ public static PTextIO createTextIO(PythonLanguage language) { } public static PTextIO createTextIO(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PTextIO(cls, shape)); + return trace(language, new PTextIO(cls, shape)); } public static PStringIO createStringIO(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PStringIO(cls, shape)); + return trace(language, new PStringIO(cls, shape)); } public static PBytesIO createBytesIO(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PBytesIO(cls, shape)); + return trace(language, new PBytesIO(cls, shape)); } public static PBytesIOBuffer createBytesIOBuf(PythonLanguage language, PBytesIO source) { @@ -1382,7 +1375,7 @@ public static PBytesIOBuffer createBytesIOBuf(PythonLanguage language, PBytesIO } public static PBytesIOBuffer createBytesIOBuf(PythonLanguage language, Object cls, Shape shape, PBytesIO source) { - return create(language, () -> new PBytesIOBuffer(cls, shape, source)); + return trace(language, new PBytesIOBuffer(cls, shape, source)); } public static PNLDecoder createNLDecoder(PythonLanguage language) { @@ -1390,7 +1383,7 @@ public static PNLDecoder createNLDecoder(PythonLanguage language) { } public static PNLDecoder createNLDecoder(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PNLDecoder(cls, shape)); + return trace(language, new PNLDecoder(cls, shape)); } public static PBuffered createBufferedReader(PythonLanguage language) { @@ -1398,7 +1391,7 @@ public static PBuffered createBufferedReader(PythonLanguage language) { } public static PBuffered createBufferedReader(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PBuffered(cls, shape, true, false)); + return trace(language, new PBuffered(cls, shape, true, false)); } public static PBuffered createBufferedWriter(PythonLanguage language) { @@ -1406,7 +1399,7 @@ public static PBuffered createBufferedWriter(PythonLanguage language) { } public static PBuffered createBufferedWriter(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PBuffered(cls, shape, false, true)); + return trace(language, new PBuffered(cls, shape, false, true)); } public static PBuffered createBufferedRandom(PythonLanguage language) { @@ -1414,15 +1407,15 @@ public static PBuffered createBufferedRandom(PythonLanguage language) { } public static PBuffered createBufferedRandom(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PBuffered(cls, shape, true, true)); + return trace(language, new PBuffered(cls, shape, true, true)); } public static PRWPair createRWPair(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PRWPair(cls, shape)); + return trace(language, new PRWPair(cls, shape)); } public static PyCArgObject createCArgObject(PythonLanguage language) { - return create(language, () -> new PyCArgObject(PythonBuiltinClassType.CArgObject, PythonBuiltinClassType.CArgObject.getInstanceShape(language))); + return trace(language, new PyCArgObject(PythonBuiltinClassType.CArgObject, PythonBuiltinClassType.CArgObject.getInstanceShape(language))); } public static CThunkObject createCThunkObject(PythonLanguage language, int nArgs) { @@ -1430,17 +1423,17 @@ public static CThunkObject createCThunkObject(PythonLanguage language, int nArgs } public static CThunkObject createCThunkObject(PythonLanguage language, Object cls, Shape shape, int nArgs) { - return create(language, () -> new CThunkObject(cls, shape, nArgs)); + return trace(language, new CThunkObject(cls, shape, nArgs)); } // Don't use directly, use CtypesNodes.CreateCDataObjectNode public static CDataObject createCDataObject(PythonLanguage language, Object cls, Shape shape, Pointer b_ptr, int b_size, boolean b_needsfree) { - return create(language, () -> new CDataObject(cls, shape, b_ptr, b_size, b_needsfree)); + return trace(language, new CDataObject(cls, shape, b_ptr, b_size, b_needsfree)); } // Don't use directly, use CtypesNodes.CreateCDataObjectNode public static PyCFuncPtrObject createPyCFuncPtrObject(PythonLanguage language, Object cls, Shape shape, Pointer b_ptr, int b_size, boolean b_needsfree) { - return create(language, () -> new PyCFuncPtrObject(cls, shape, b_ptr, b_size, b_needsfree)); + return trace(language, new PyCFuncPtrObject(cls, shape, b_ptr, b_size, b_needsfree)); } public static CFieldObject createCFieldObject(PythonLanguage language) { @@ -1448,7 +1441,7 @@ public static CFieldObject createCFieldObject(PythonLanguage language) { } public static CFieldObject createCFieldObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new CFieldObject(cls, shape)); + return trace(language, new CFieldObject(cls, shape)); } public static StgDictObject createStgDictObject(PythonLanguage language) { @@ -1456,11 +1449,11 @@ public static StgDictObject createStgDictObject(PythonLanguage language) { } public static StgDictObject createStgDictObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new StgDictObject(cls, shape)); + return trace(language, new StgDictObject(cls, shape)); } public static PSSLContext createSSLContext(PythonLanguage language, Object cls, Shape shape, SSLMethod method, int verifyFlags, boolean checkHostname, int verifyMode, SSLContext context) { - return create(language, () -> new PSSLContext(cls, shape, method, verifyFlags, checkHostname, verifyMode, context)); + return trace(language, new PSSLContext(cls, shape, method, verifyFlags, checkHostname, verifyMode, context)); } public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext context, SSLEngine engine, PSocket socket) { @@ -1468,7 +1461,7 @@ public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext co } public static PSSLSocket createSSLSocket(PythonLanguage language, Object cls, Shape shape, PSSLContext context, SSLEngine engine, PSocket socket) { - return create(language, () -> new PSSLSocket(cls, shape, context, engine, socket, createMemoryBIO(language), createMemoryBIO(language), createMemoryBIO(language))); + return trace(language, new PSSLSocket(cls, shape, context, engine, socket, createMemoryBIO(language), createMemoryBIO(language), createMemoryBIO(language))); } public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext context, SSLEngine engine, PMemoryBIO inbound, PMemoryBIO outbound) { @@ -1476,23 +1469,23 @@ public static PSSLSocket createSSLSocket(PythonLanguage language, PSSLContext co } public static PSSLSocket createSSLSocket(PythonLanguage language, Object cls, Shape shape, PSSLContext context, SSLEngine engine, PMemoryBIO inbound, PMemoryBIO outbound) { - return create(language, () -> new PSSLSocket(cls, shape, context, engine, null, inbound, outbound, createMemoryBIO(language))); + return trace(language, new PSSLSocket(cls, shape, context, engine, null, inbound, outbound, createMemoryBIO(language))); } public static PMemoryBIO createMemoryBIO(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PMemoryBIO(cls, shape)); + return trace(language, new PMemoryBIO(cls, shape)); } public static PMemoryBIO createMemoryBIO(PythonLanguage language) { - return create(language, () -> new PMemoryBIO(PythonBuiltinClassType.PMemoryBIO, PythonBuiltinClassType.PMemoryBIO.getInstanceShape(language))); + return trace(language, new PMemoryBIO(PythonBuiltinClassType.PMemoryBIO, PythonBuiltinClassType.PMemoryBIO.getInstanceShape(language))); } public static PProperty createProperty(PythonLanguage language) { - return create(language, () -> new PProperty(PythonBuiltinClassType.PProperty, PythonBuiltinClassType.PProperty.getInstanceShape(language))); + return trace(language, new PProperty(PythonBuiltinClassType.PProperty, PythonBuiltinClassType.PProperty.getInstanceShape(language))); } public static PProperty createProperty(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PProperty(cls, shape)); + return trace(language, new PProperty(cls, shape)); } // JSON @@ -1501,54 +1494,54 @@ public static PProperty createProperty(PythonLanguage language, Object cls, Shap @TruffleBoundary public static PJSONScanner createJSONScanner(PythonLanguage language, Object cls, Shape shape, boolean strict, Object objectHook, Object objectPairsHook, Object parseFloat, Object parseInt, Object parseConstant) { - return create(language, () -> new PJSONScanner(cls, shape, strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant)); + return trace(language, new PJSONScanner(cls, shape, strict, objectHook, objectPairsHook, parseFloat, parseInt, parseConstant)); } @TruffleBoundary public static PJSONEncoder createJSONEncoder(PythonLanguage language, Object cls, Shape shape, Object markers, Object defaultFn, Object encoder, Object indent, TruffleString keySeparator, TruffleString itemSeparator, boolean sortKeys, boolean skipKeys, boolean allowNan, FastEncode fastEncode) { - return create(language, () -> new PJSONEncoder(cls, shape, markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode)); + return trace(language, new PJSONEncoder(cls, shape, markers, defaultFn, encoder, indent, keySeparator, itemSeparator, sortKeys, skipKeys, allowNan, fastEncode)); } public static PDeque createDeque(PythonLanguage language) { - return create(language, () -> new PDeque(PythonBuiltinClassType.PDeque, PythonBuiltinClassType.PDeque.getInstanceShape(language))); + return trace(language, new PDeque(PythonBuiltinClassType.PDeque, PythonBuiltinClassType.PDeque.getInstanceShape(language))); } public static PDeque createDeque(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PDeque(cls, shape)); + return trace(language, new PDeque(cls, shape)); } public static PDequeIter createDequeIter(PythonLanguage language, PDeque deque) { - return create(language, () -> new PDequeIter(PythonBuiltinClassType.PDequeIter, PythonBuiltinClassType.PDequeIter.getInstanceShape(language), deque, false)); + return trace(language, new PDequeIter(PythonBuiltinClassType.PDequeIter, PythonBuiltinClassType.PDequeIter.getInstanceShape(language), deque, false)); } public static PDequeIter createDequeRevIter(PythonLanguage language, PDeque deque) { - return create(language, () -> new PDequeIter(PythonBuiltinClassType.PDequeRevIter, PythonBuiltinClassType.PDequeRevIter.getInstanceShape(language), deque, true)); + return trace(language, new PDequeIter(PythonBuiltinClassType.PDequeRevIter, PythonBuiltinClassType.PDequeRevIter.getInstanceShape(language), deque, true)); } public static PSimpleQueue createSimpleQueue(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PSimpleQueue(cls, shape)); + return trace(language, new PSimpleQueue(cls, shape)); } public static PContextVar createContextVar(PythonLanguage language, TruffleString name, Object def) { - return create(language, () -> new PContextVar(PythonBuiltinClassType.ContextVar, PythonBuiltinClassType.ContextVar.getInstanceShape(language), name, def)); + return trace(language, new PContextVar(PythonBuiltinClassType.ContextVar, PythonBuiltinClassType.ContextVar.getInstanceShape(language), name, def)); } public static PContextVarsContext createContextVarsContext(PythonLanguage language) { - return create(language, () -> new PContextVarsContext(PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); + return trace(language, new PContextVarsContext(PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); } public static PContextIterator createContextIterator(PythonLanguage language, PContextVarsContext ctx, PContextIterator.ItemKind kind) { - return create(language, () -> new PContextIterator(PythonBuiltinClassType.ContextIterator, PythonBuiltinClassType.ContextIterator.getInstanceShape(language), ctx, kind)); + return trace(language, new PContextIterator(PythonBuiltinClassType.ContextIterator, PythonBuiltinClassType.ContextIterator.getInstanceShape(language), ctx, kind)); } public static PContextVarsContext copyContextVarsContext(PythonLanguage language, PContextVarsContext original) { - return create(language, () -> new PContextVarsContext(original, PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); + return trace(language, new PContextVarsContext(original, PythonBuiltinClassType.ContextVarsContext, PythonBuiltinClassType.ContextVarsContext.getInstanceShape(language))); } public static PContextVarsToken createContextVarsToken(PythonLanguage language, PContextVar var, Object oldValue) { - return create(language, () -> new PContextVarsToken(var, oldValue, PythonBuiltinClassType.ContextVarsToken, PythonBuiltinClassType.ContextVarsToken.getInstanceShape(language))); + return trace(language, new PContextVarsToken(var, oldValue, PythonBuiltinClassType.ContextVarsToken, PythonBuiltinClassType.ContextVarsToken.getInstanceShape(language))); } public static PGenericAlias createGenericAlias(PythonLanguage language, Object cls, Shape shape, Object origin, Object arguments, boolean starred) { @@ -1558,7 +1551,7 @@ public static PGenericAlias createGenericAlias(PythonLanguage language, Object c } else { argumentsTuple = createTuple(language, new Object[]{arguments}); } - return create(language, () -> new PGenericAlias(cls, shape, origin, argumentsTuple, starred)); + return trace(language, new PGenericAlias(cls, shape, origin, argumentsTuple, starred)); } public static PGenericAlias createGenericAlias(PythonLanguage language, Object origin, Object arguments, boolean starred) { @@ -1570,15 +1563,15 @@ public static PGenericAlias createGenericAlias(PythonLanguage language, Object o } public static PGenericAliasIterator createGenericAliasIterator(PythonLanguage language, PGenericAlias object) { - return create(language, () -> new PGenericAliasIterator(PythonBuiltinClassType.PGenericAliasIterator, PythonBuiltinClassType.PGenericAliasIterator.getInstanceShape(language), object)); + return trace(language, new PGenericAliasIterator(PythonBuiltinClassType.PGenericAliasIterator, PythonBuiltinClassType.PGenericAliasIterator.getInstanceShape(language), object)); } public static PUnionType createUnionType(PythonLanguage language, Object[] args) { - return create(language, () -> new PUnionType(PythonBuiltinClassType.PUnionType, PythonBuiltinClassType.PUnionType.getInstanceShape(language), createTuple(language, args))); + return trace(language, new PUnionType(PythonBuiltinClassType.PUnionType, PythonBuiltinClassType.PUnionType.getInstanceShape(language), createTuple(language, args))); } public static DigestObject createDigestObject(PythonLanguage language, PythonBuiltinClassType type, String name, Object digest) { - return create(language, () -> DigestObject.create(type, type.getInstanceShape(language), name, digest)); + return trace(language, DigestObject.create(type, type.getInstanceShape(language), name, digest)); } public static PyCapsule createCapsuleNativeName(PythonLanguage language, Object pointer, Object name) { @@ -1590,23 +1583,23 @@ public static PyCapsule createCapsuleJavaName(PythonLanguage language, Object po } public static PyCapsule createCapsule(PythonLanguage language, PyCapsule.CapsuleData data) { - return create(language, () -> new PyCapsule(language, data)); + return trace(language, new PyCapsule(language, data)); } public static MultibyteIncrementalDecoderObject createMultibyteIncrementalDecoderObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new MultibyteIncrementalDecoderObject(cls, shape)); + return trace(language, new MultibyteIncrementalDecoderObject(cls, shape)); } public static MultibyteIncrementalEncoderObject createMultibyteIncrementalEncoderObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new MultibyteIncrementalEncoderObject(cls, shape)); + return trace(language, new MultibyteIncrementalEncoderObject(cls, shape)); } public static MultibyteStreamReaderObject createMultibyteStreamReaderObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new MultibyteStreamReaderObject(cls, shape)); + return trace(language, new MultibyteStreamReaderObject(cls, shape)); } public static MultibyteStreamWriterObject createMultibyteStreamWriterObject(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new MultibyteStreamWriterObject(cls, shape)); + return trace(language, new MultibyteStreamWriterObject(cls, shape)); } public static MultibyteCodecObject createMultibyteCodecObject(PythonLanguage language, MultibyteCodec codec) { @@ -1614,19 +1607,19 @@ public static MultibyteCodecObject createMultibyteCodecObject(PythonLanguage lan } public static MultibyteCodecObject createMultibyteCodecObject(PythonLanguage language, Object cls, Shape shape, MultibyteCodec codec) { - return create(language, () -> new MultibyteCodecObject(cls, shape, codec)); + return trace(language, new MultibyteCodecObject(cls, shape, codec)); } public static PAsyncGenASend createAsyncGeneratorASend(PythonLanguage language, PAsyncGen receiver, Object message) { - return create(language, () -> new PAsyncGenASend(language, receiver, message)); + return trace(language, new PAsyncGenASend(language, receiver, message)); } public static PAsyncGenAThrow createAsyncGeneratorAThrow(PythonLanguage language, PAsyncGen receiver, Object arg1, Object arg2, Object arg3) { - return create(language, () -> new PAsyncGenAThrow(language, receiver, arg1, arg2, arg3)); + return trace(language, new PAsyncGenAThrow(language, receiver, arg1, arg2, arg3)); } public static PAsyncGenWrappedValue createAsyncGeneratorWrappedValue(PythonLanguage language, Object wrapped) { - return create(language, () -> new PAsyncGenWrappedValue(language, wrapped)); + return trace(language, new PAsyncGenWrappedValue(language, wrapped)); } // pickle @@ -1636,7 +1629,7 @@ public static PPickleBuffer createPickleBuffer(PythonLanguage language, Object v } public static PPickleBuffer createPickleBuffer(PythonLanguage language, Object view, Object cls, Shape shape) { - return create(language, () -> new PPickleBuffer(cls, shape, view)); + return trace(language, new PPickleBuffer(cls, shape, view)); } public static PPickler createPickler(PythonLanguage language) { @@ -1644,7 +1637,7 @@ public static PPickler createPickler(PythonLanguage language) { } public static PPickler createPickler(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PPickler(cls, shape)); + return trace(language, new PPickler(cls, shape)); } public static PUnpickler createUnpickler(PythonLanguage language) { @@ -1652,7 +1645,7 @@ public static PUnpickler createUnpickler(PythonLanguage language) { } public static PUnpickler createUnpickler(PythonLanguage language, Object cls, Shape shape) { - return create(language, () -> new PUnpickler(cls, shape)); + return trace(language, new PUnpickler(cls, shape)); } public static PPicklerMemoProxy createPicklerMemoProxy(PythonLanguage language, PPickler pickler) { @@ -1660,7 +1653,7 @@ public static PPicklerMemoProxy createPicklerMemoProxy(PythonLanguage language, } public static PPicklerMemoProxy createPicklerMemoProxy(PythonLanguage language, PPickler pickler, Object cls, Shape shape) { - return create(language, () -> new PPicklerMemoProxy(cls, shape, pickler)); + return trace(language, new PPicklerMemoProxy(cls, shape, pickler)); } public static PUnpicklerMemoProxy createUnpicklerMemoProxy(PythonLanguage language, PUnpickler unpickler) { @@ -1668,15 +1661,15 @@ public static PUnpicklerMemoProxy createUnpicklerMemoProxy(PythonLanguage langua } public static PUnpicklerMemoProxy createUnpicklerMemoProxy(PythonLanguage language, PUnpickler unpickler, Object cls, Shape shape) { - return create(language, () -> new PUnpicklerMemoProxy(cls, shape, unpickler)); + return trace(language, new PUnpicklerMemoProxy(cls, shape, unpickler)); } public static PStruct createStruct(PythonLanguage language, PStruct.StructInfo structInfo) { - return create(language, () -> new PStruct(PythonBuiltinClassType.PStruct, PythonBuiltinClassType.PStruct.getInstanceShape(language), structInfo)); + return trace(language, new PStruct(PythonBuiltinClassType.PStruct, PythonBuiltinClassType.PStruct.getInstanceShape(language), structInfo)); } public static PStructUnpackIterator createStructUnpackIterator(PythonLanguage language, PStruct struct, Object buffer) { - return create(language, () -> new PStructUnpackIterator(PythonBuiltinClassType.PStructUnpackIterator, PythonBuiltinClassType.PStructUnpackIterator.getInstanceShape(language), struct, buffer)); + return trace(language, new PStructUnpackIterator(PythonBuiltinClassType.PStructUnpackIterator, PythonBuiltinClassType.PStructUnpackIterator.getInstanceShape(language), struct, buffer)); } public static PTokenizerIter createTokenizerIter(PythonLanguage language, String sourceString) { @@ -1684,10 +1677,10 @@ public static PTokenizerIter createTokenizerIter(PythonLanguage language, String } public static PTokenizerIter createTokenizerIter(PythonLanguage language, Object cls, Shape shape, String sourceString) { - return create(language, () -> new PTokenizerIter(cls, shape, sourceString)); + return trace(language, new PTokenizerIter(cls, shape, sourceString)); } public static Profiler createProfiler(PythonLanguage language, Object cls, Shape shape, CPUSampler sampler) { - return create(language, () -> new Profiler(cls, shape, sampler)); + return trace(language, new Profiler(cls, shape, sampler)); } } From eadbc4bfb3ab5e49d69908b1af0c77ad5e28916b Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Fri, 14 Feb 2025 15:45:20 +0100 Subject: [PATCH 018/512] Enable _PyObject_AssertFailed to print some info at least when we fail. --- .../com.oracle.graal.python.cext/src/object.c | 9 ++- .../cpyext/module_with_exiting_functions.py | 68 ++++++++++++++++++ .../src/tests/cpyext/test_fatal_exit.py | 72 +++++++++++++++++++ .../objects/cext/capi/CApiFunction.java | 4 +- 4 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/cpyext/module_with_exiting_functions.py create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_fatal_exit.py diff --git a/graalpython/com.oracle.graal.python.cext/src/object.c b/graalpython/com.oracle.graal.python.cext/src/object.c index 9ad7908e8a..eb22c9e94d 100644 --- a/graalpython/com.oracle.graal.python.cext/src/object.c +++ b/graalpython/com.oracle.graal.python.cext/src/object.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2018, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2018, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2022 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -2370,7 +2370,6 @@ _PyTrash_cond(PyObject *op, destructor dealloc) } -#if 0 // GraalPy change void _Py_NO_RETURN _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, const char *file, int line, const char *function) @@ -2395,6 +2394,7 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, fprintf(stderr, "\n"); fflush(stderr); +#if 0 // GraalPy change if (_PyObject_IsFreed(obj)) { /* It seems like the object memory has been freed: don't access it to prevent a segmentation fault. */ @@ -2415,17 +2415,20 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, } _PyMem_DumpTraceback(fileno(stderr), ptr); +#endif // GraalPy change /* This might succeed or fail, but we're about to abort, so at least try to provide any extra info we can: */ + if (obj) // GraalPy change, guard call to _PyObject_Dump _PyObject_Dump(obj); +#if 0 // GraalPy change fprintf(stderr, "\n"); fflush(stderr); } +#endif // GraalPy change Py_FatalError("_PyObject_AssertFailed"); } -#endif // GraalPy change void diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/module_with_exiting_functions.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/module_with_exiting_functions.py new file mode 100644 index 0000000000..99b5e47fd4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/module_with_exiting_functions.py @@ -0,0 +1,68 @@ +# Copyright (c) 2025, 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. + +import sys +import time + +from tests.cpyext import CPyExtType + + +ExitObject = CPyExtType( + "ExitObjext", + """ + static PyObject *test_FatalError(PyObject *self, PyObject *arg) { + Py_FatalError(PyUnicode_AsUTF8(arg)); + return NULL; + } + + static PyObject* test_assert_failure(PyObject *self, PyObject *arg) { + _PyObject_AssertFailed(arg, "0", PyUnicode_AsUTF8(arg), "filename", 0, "function"); + return NULL; + } + + """, + tp_methods=''' + {"Py_FatalError", (PyCFunction)test_FatalError, METH_O, NULL}, + {"_PyObject_ASSERT_WITH_MSG", (PyCFunction)test_assert_failure, METH_O, NULL} + ''' + ) + + +if __name__ == "__main__": + getattr(ExitObject(), sys.argv[1])(sys.argv[2]) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_fatal_exit.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_fatal_exit.py new file mode 100644 index 0000000000..0a27547b92 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_fatal_exit.py @@ -0,0 +1,72 @@ +# Copyright (c) 2025, 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. + +import os +import signal +import subprocess +from pathlib import Path + +import sys + + +def call_in_subprocess(method, argument): + dir = Path(__file__).parent + module_path = dir / 'module_with_exiting_functions.py' + env = dict(os.environ) + env['PYTHONPATH'] = str(dir.parent.parent) + args = [sys.executable] + if sys.implementation.name == 'graalpy': + args += ['--experimental-options', '--python.EnableDebuggingBuiltins'] + args += [str(module_path), method, argument] + return subprocess.run(args, env=env, capture_output=True, text=True) + + +def test_fatal_error(): + proc = call_in_subprocess("Py_FatalError", "my fatal error") + assert proc.returncode != 0 + assert "my fatal error" in proc.stderr, proc.stderr + + +def test_assert_failed(): + proc = call_in_subprocess("_PyObject_ASSERT_WITH_MSG", "some assert failed") + assert proc.returncode != 0 + assert "some assert failed" in proc.stderr, proc.stderr + assert "refcount" in proc.stderr, proc.stderr + assert "object type" in proc.stderr, proc.stderr + assert "object type name" in proc.stderr, proc.stderr diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java index 90e9394e37..d1a5ba18f0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java @@ -592,6 +592,8 @@ public final class CApiFunction { @CApiBuiltin(name = "_PyLong_UnsignedLong_Converter", ret = Int, args = {PyObject, Pointer}, call = CImpl) @CApiBuiltin(name = "_PyModule_Add", ret = Int, args = {PyObject, ConstCharPtrAsTruffleString, PyObject}, call = CImpl) @CApiBuiltin(name = "_PyModule_CreateInitialized", ret = PyObject, args = {PYMODULEDEF_PTR, Int}, call = CImpl) + @CApiBuiltin(name = "_PyObject_AssertFailed", ret = VoidNoReturn, args = {PyObject, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Int, + ConstCharPtrAsTruffleString}, call = CImpl) @CApiBuiltin(name = "_PyObject_CallFunction_SizeT", ret = PyObject, args = {PyObject, ConstCharPtrAsTruffleString, VARARGS}, call = CImpl) @CApiBuiltin(name = "_PyObject_CallMethodIdObjArgs", ret = PyObject, args = {PyObject, _PY_IDENTIFIER_PTR, VARARGS}, call = CImpl) @CApiBuiltin(name = "_PyObject_CallMethodIdObjArgs", ret = PyObject, args = {PyObject, _PY_IDENTIFIER_PTR, VARARGS}, call = CImpl) @@ -1098,8 +1100,6 @@ public final class CApiFunction { @CApiBuiltin(name = "_PyOS_IsMainThread", ret = Int, args = {}, call = NotImplemented) @CApiBuiltin(name = "_PyOS_URandom", ret = Int, args = {Pointer, Py_ssize_t}, call = NotImplemented) @CApiBuiltin(name = "_PyOS_URandomNonblock", ret = Int, args = {Pointer, Py_ssize_t}, call = NotImplemented) - @CApiBuiltin(name = "_PyObject_AssertFailed", ret = VoidNoReturn, args = {PyObject, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Int, - ConstCharPtrAsTruffleString}, call = NotImplemented) @CApiBuiltin(name = "_PyObject_CallMethod", ret = PyObject, args = {PyObject, PyObject, ConstCharPtrAsTruffleString, VARARGS}, call = NotImplemented) @CApiBuiltin(name = "_PyObject_CallMethodId", ret = PyObject, args = {PyObject, PY_IDENTIFIER, ConstCharPtrAsTruffleString, VARARGS}, call = NotImplemented) @CApiBuiltin(name = "_PyObject_CallMethodId_SizeT", ret = PyObject, args = {PyObject, PY_IDENTIFIER, ConstCharPtrAsTruffleString, VARARGS}, call = NotImplemented) From afcda3c988c9be7704dae29e9ea830b2ba580153 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 13 Feb 2025 13:31:38 +0100 Subject: [PATCH 019/512] Implement simple numeric binary inplace slots --- .../oracle/graal/python/annotations/Slot.java | 24 +++ .../graal/python/processor/SlotsMapping.java | 21 ++- .../src/tests/cpyext/test_tp_slots.py | 7 +- .../builtins/PythonBuiltinClassType.java | 3 +- .../builtins/modules/BuiltinFunctions.java | 6 +- .../builtins/modules/MathModuleBuiltins.java | 4 +- .../builtins/modules/PosixModuleBuiltins.java | 2 +- .../cext/PythonCextAbstractBuiltins.java | 4 +- .../modules/functools/KeyWrapperBuiltins.java | 2 +- .../builtins/objects/array/ArrayBuiltins.java | 4 +- .../objects/cext/capi/SlotMethodDef.java | 42 +---- .../objects/cext/capi/ToNativeTypeNode.java | 10 -- .../cext/hpy/GraalHPyArithmeticNode.java | 2 +- .../objects/common/SequenceStorageNodes.java | 2 +- .../builtins/objects/common/SortNodes.java | 4 +- .../builtins/objects/dict/DictBuiltins.java | 5 +- .../foreign/ForeignNumberBuiltins.java | 6 +- .../mappingproxy/MappingproxyBuiltins.java | 9 +- .../objects/object/ObjectBuiltins.java | 2 +- .../ordereddict/OrderedDictBuiltins.java | 5 +- .../referencetype/ReferenceTypeBuiltins.java | 4 +- .../builtins/objects/set/SetBuiltins.java | 26 ++-- .../python/builtins/objects/type/TpSlots.java | 145 ++++++++++++++++++ .../objects/type/slots/TpSlotBinaryFunc.java | 3 +- .../objects/type/slots/TpSlotBinaryOp.java | 75 +++++++++ .../objects/types/UnionTypeBuiltins.java | 2 +- .../graal/python/lib/CallBinaryIOp1Node.java | 83 ++++++++++ .../graal/python/lib/CallBinaryIOpNode.java | 86 +++++++++++ .../graal/python/lib/CallBinaryOp1Node.java | 58 +++---- .../graal/python/lib/CallBinaryOpNode.java | 93 +++++++++++ .../graal/python/lib/PyNumberAddNode.java | 63 ++++---- .../graal/python/lib/PyNumberAndNode.java | 49 ++---- .../graal/python/lib/PyNumberDivmodNode.java | 39 +---- .../python/lib/PyNumberFloorDivideNode.java | 51 ++---- .../python/lib/PyNumberInplaceAndNode.java | 69 +++++++++ .../lib/PyNumberInplaceFloorDivideNode.java | 67 ++++++++ .../python/lib/PyNumberInplaceLshiftNode.java | 67 ++++++++ .../PyNumberInplaceMatrixMultiplyNode.java | 68 ++++++++ .../python/lib/PyNumberInplaceOrNode.java | 69 +++++++++ .../lib/PyNumberInplaceRemainderNode.java | 67 ++++++++ .../python/lib/PyNumberInplaceRshiftNode.java | 67 ++++++++ .../lib/PyNumberInplaceSubtractNode.java | 67 ++++++++ .../lib/PyNumberInplaceTrueDivideNode.java | 67 ++++++++ .../python/lib/PyNumberInplaceXorNode.java | 69 +++++++++ .../graal/python/lib/PyNumberLshiftNode.java | 48 ++---- .../lib/PyNumberMatrixMultiplyNode.java | 41 +---- .../python/lib/PyNumberMultiplyNode.java | 59 ++++--- .../graal/python/lib/PyNumberOrNode.java | 50 ++---- .../graal/python/lib/PyNumberPowerNode.java | 2 +- .../python/lib/PyNumberRemainderNode.java | 48 ++---- .../graal/python/lib/PyNumberRshiftNode.java | 31 ++-- .../python/lib/PyNumberSubtractNode.java | 49 ++---- .../python/lib/PyNumberTrueDivideNode.java | 48 ++---- .../graal/python/lib/PyNumberXorNode.java | 50 ++---- .../graal/python/lib/PySequenceConcat.java | 15 +- .../nodes/bytecode/PBytecodeRootNode.java | 72 ++++++--- .../nodes/expression/BinaryArithmetic.java | 2 +- .../python/nodes/expression/BinaryOp.java | 4 +- .../python/nodes/expression/BinaryOpNode.java | 4 +- .../expression/LookupAndCallInplaceNode.java | 8 +- .../graal/python/nodes/object/IsNode.java | 4 +- 61 files changed, 1515 insertions(+), 638 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOp1Node.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOpNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOpNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index 4d9f5c834d..c6bbb59f74 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -137,6 +137,30 @@ enum SlotKind { nb_matrix_multiply("__matmul__, __rmatmul__"), /** foo ** bar */ nb_power("__pow__, __rpow__"), + /** foo += bar */ + nb_inplace_add("__iadd__"), + /** foo -= bar */ + nb_inplace_subtract("__isub__"), + /** foo *= bar */ + nb_inplace_multiply("__imul__"), + /** foo %= bar */ + nb_inplace_remainder("__imod__"), + /** foo <<= bar */ + nb_inplace_lshift("__ilshift__"), + /** foo >>= bar */ + nb_inplace_rshift("__irshift__"), + /** foo &= bar */ + nb_inplace_and("__iand__"), + /** foo ^= bar */ + nb_inplace_xor("__ixor__"), + /** foo |= bar */ + nb_inplace_or("__ior__"), + /** foo //= bar */ + nb_inplace_floor_divide("__ifloordiv__"), + /** foo /= bar */ + nb_inplace_true_divide("__itruediv__"), + /** foo @= bar */ + nb_inplace_matrix_multiply("__imatmul__"), /** sequence length/size */ sq_length("__len__"), /** sequence item: read element at index */ diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index a9281af8b7..5e2c1b93e7 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -56,6 +56,10 @@ static String getSlotBaseClass(Slot s) { case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> "TpSlotBinaryOp.TpSlotBinaryOpBuiltin"; + case nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, + nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, + nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply -> + "TpSlotBinaryOp.TpSlotBinaryIOpBuiltin"; case nb_power -> "TpSlotNbPower.TpSlotNbPowerBuiltin"; case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat"; case sq_length, mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix(s.isComplex()); @@ -76,7 +80,10 @@ static String getSlotNodeBaseClass(Slot s) { case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode"; case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert -> "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode"; case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, - nb_floor_divide, nb_true_divide, nb_matrix_multiply -> + nb_floor_divide, nb_true_divide, nb_matrix_multiply, + nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, + nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, + nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode"; case nb_power -> "com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode"; case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode"; @@ -146,6 +153,18 @@ public static String getExtraCtorArgs(TpSlotData slot) { case nb_floor_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___FLOORDIV__"; case nb_true_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUEDIV__"; case nb_matrix_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MATMUL__"; + case nb_inplace_add -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__"; + case nb_inplace_subtract -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ISUB__"; + case nb_inplace_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__"; + case nb_inplace_remainder -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMOD__"; + case nb_inplace_lshift -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ILSHIFT__"; + case nb_inplace_rshift -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IRSHIFT__"; + case nb_inplace_and -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IAND__"; + case nb_inplace_xor -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IXOR__"; + case nb_inplace_or -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IOR__"; + case nb_inplace_floor_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IFLOORDIV__"; + case nb_inplace_true_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ITRUEDIV__"; + case nb_inplace_matrix_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMATMUL__"; default -> ""; }; } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index 0a7479f806..8ffd21fcb6 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -929,10 +929,9 @@ def __rmatmul__(self, other): obj = NativeNbSlotProxy(PureSlotProxy(3)) obj /= 2 assert obj.delegate.delegate == 1.5 - # TODO fix on graalpy - # obj = NativeNbSlotProxy(PureSlotProxy(ObjWithMatmul())) - # obj @= 1 - # assert obj.delegate.delegate == '@' + obj = NativeNbSlotProxy(PureSlotProxy(ObjWithMatmul())) + obj @= 1 + assert obj.delegate.delegate == '@' def test_sq_slot_calls(): diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java index 07881f7807..13c5fcb87c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java @@ -160,6 +160,7 @@ import com.oracle.graal.python.builtins.objects.property.PropertyBuiltins; import com.oracle.graal.python.builtins.objects.range.RangeBuiltins; import com.oracle.graal.python.builtins.objects.set.BaseSetBuiltins; +import com.oracle.graal.python.builtins.objects.set.SetBuiltins; import com.oracle.graal.python.builtins.objects.str.StringBuiltins; import com.oracle.graal.python.builtins.objects.superobject.SuperBuiltins; import com.oracle.graal.python.builtins.objects.thread.ThreadLocalBuiltins; @@ -263,7 +264,7 @@ public enum PythonBuiltinClassType implements TruffleObject { PReferenceType("ReferenceType", "_weakref"), PSentinelIterator("callable_iterator", Flags.PRIVATE_DERIVED_WODICT), PReverseIterator("reversed", J_BUILTINS), - PSet("set", J_BUILTINS, SET_M_FLAGS, BaseSetBuiltins.SLOTS), + PSet("set", J_BUILTINS, SET_M_FLAGS, TpSlots.merge(BaseSetBuiltins.SLOTS, SetBuiltins.SLOTS)), PSlice("slice", J_BUILTINS), PString("str", J_BUILTINS, STRING_M_FLAGS, StringBuiltins.SLOTS), PTraceback("traceback"), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 98b69fb966..116d0aac2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -1619,7 +1619,7 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj isTrue = castToBooleanNode.execute(frame, e.getResult()); } } else { - isTrue = castToBooleanNode.execute(frame, compare.executeObject(frame, nextKey, currentKey)); + isTrue = castToBooleanNode.execute(frame, compare.execute(frame, nextKey, currentKey)); } if (isTrue) { currentKey = nextKey; @@ -1663,7 +1663,7 @@ static Object minmaxBinaryWithKey(VirtualFrame frame, Node inliningTarget, Objec isTrue = castToBooleanNode.execute(frame, e.getResult()); } } else { - isTrue = castToBooleanNode.execute(frame, compare.executeObject(frame, nextKey, currentKey)); + isTrue = castToBooleanNode.execute(frame, compare.execute(frame, nextKey, currentKey)); } if (isTrue) { currentKey = nextKey; @@ -1683,7 +1683,7 @@ static Object minmaxBinaryWithKey(VirtualFrame frame, Node inliningTarget, Objec isTrue = castToBooleanNode.execute(frame, e.getResult()); } } else { - isTrue = castToBooleanNode.execute(frame, compare.executeObject(frame, nextKey, currentKey)); + isTrue = castToBooleanNode.execute(frame, compare.execute(frame, nextKey, currentKey)); } if (isTrue) { currentKey = nextKey; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java index 19899dc92b..aec6c98c51 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java @@ -1158,7 +1158,7 @@ public static Object gcd(VirtualFrame frame, @SuppressWarnings("unused") Object profile.profileCounted(args.length); for (int i = 1; profile.inject(i < args.length); i++) { Object b = indexNode.execute(frame, inliningTarget, args[i]); - if ((boolean) eqNode.executeObject(frame, a, 0)) { + if ((boolean) eqNode.execute(frame, a, 0)) { continue; } Object g = gcdNode.execute(frame, a, b); @@ -2488,7 +2488,7 @@ public Object doGeneric(VirtualFrame frame, Object iterable, Object startIn, e.expectStopIteration(inliningTarget, errorProfile); return value; } - value = mul.executeObject(frame, value, nextValue); + value = mul.execute(frame, value, nextValue); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index c49b42d59b..1720e5b837 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -3321,7 +3321,7 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object value, lon @Cached(value = "createNotNormalized()", inline = false) GetItemNode getItemNode, @Cached PyLongAsLongNode asLongNode, @Cached PRaiseNode raiseNode) { - Object divmod = callDivmod.executeObject(frame, value, BILLION); + Object divmod = callDivmod.execute(frame, value, BILLION); if (!PGuards.isPTuple(divmod) || lenNode.execute(inliningTarget, (PSequence) divmod) != 2) { throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_RETURN_2TUPLE, value, divmod); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 2dfa351af1..0ccaff8da1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -332,7 +332,7 @@ abstract static class PyTruffleNumber_BinOp extends CApiTernaryBuiltinNode { static Object doIntLikePrimitiveWrapper(Object left, Object right, @SuppressWarnings("unused") int op, @Cached("op") @SuppressWarnings("unused") int cachedOp, @Cached("createCallNode(op)") BinaryOpNode callNode) { - return callNode.executeObject(null, left, right); + return callNode.execute(null, left, right); } /** @@ -541,7 +541,7 @@ static Object repeat(Object obj, long n, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookupNode, @Cached CallNode callNode, - @Cached("createMul()") PyNumberMultiplyNode mulNode, + @Cached PyNumberMultiplyNode mulNode, @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode) { Object imulCallable = lookupNode.execute(null, inliningTarget, obj, T___IMUL__); if (imulCallable != PNone.NO_VALUE) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java index 8a9614ee78..dfe4188108 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/KeyWrapperBuiltins.java @@ -116,7 +116,7 @@ BinaryComparisonNode createCmp() { boolean doCompare(VirtualFrame frame, PKeyWrapper self, PKeyWrapper other, @Cached PyObjectIsTrueNode isTrueNode) { final Object cmpResult = ensureCallNode().execute(frame, self.getCmp(), self.getObject(), other.getObject()); - return isTrueNode.execute(frame, ensureComparisonNode().executeObject(frame, cmpResult, 0)); + return isTrueNode.execute(frame, ensureComparisonNode().execute(frame, cmpResult, 0)); } @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index 24deb2c7e2..fe7c0fcdff 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -405,7 +405,7 @@ static boolean cmpItems(VirtualFrame frame, Node inliningTarget, PArray left, PA Object leftValue = getLeft.execute(inliningTarget, left, i); Object rightValue = getRight.execute(inliningTarget, right, i); if (!eqNode.compare(frame, inliningTarget, leftValue, rightValue)) { - return coerceToBooleanNode.execute(frame, compareNode.executeObject(frame, leftValue, rightValue)); + return coerceToBooleanNode.execute(frame, compareNode.execute(frame, leftValue, rightValue)); } } return op.cmpResultToBool(left.getLength() - right.getLength()); @@ -422,7 +422,7 @@ static boolean cmpDoubles(VirtualFrame frame, Node inliningTarget, PArray left, double leftValue = (Double) getLeft.execute(inliningTarget, left, i); double rightValue = (Double) getRight.execute(inliningTarget, right, i); if (leftValue != rightValue) { - return coerceToBooleanNode.execute(frame, compareNode.executeObject(frame, leftValue, rightValue)); + return coerceToBooleanNode.execute(frame, compareNode.execute(frame, leftValue, rightValue)); } } return op.cmpResultToBool(left.getLength() - right.getLength()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java index 1b0fb038d6..96624251a1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java @@ -44,17 +44,8 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_anext; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_await; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_add; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_and; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_floor_divide; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_lshift; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_multiply; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_or; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_power; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_remainder; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_rshift; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_subtract; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_true_divide; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_xor; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_hash; @@ -70,29 +61,20 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUFFLE_RICHCOMPARE__; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.BinaryFuncWrapper; +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.CallFunctionWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.HashfuncWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InitWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.RichcmpFunctionWrapper; -import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.CallFunctionWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.UnaryFuncLegacyWrapper; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.type.MethodsFlags; @@ -117,17 +99,8 @@ public enum SlotMethodDef { /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, CallFunctionWrapper::new, MethodsFlags.AM_SEND), */ NB_INPLACE_ADD(PyNumberMethods__nb_inplace_add, T___IADD__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_ADD), - NB_INPLACE_AND(PyNumberMethods__nb_inplace_and, T___IAND__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_AND), - NB_INPLACE_FLOOR_DIVIDE(PyNumberMethods__nb_inplace_floor_divide, T___IFLOORDIV__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_FLOOR_DIVIDE), - NB_INPLACE_LSHIFT(PyNumberMethods__nb_inplace_lshift, T___ILSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_LSHIFT), NB_INPLACE_MULTIPLY(PyNumberMethods__nb_inplace_multiply, T___IMUL__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_MULTIPLY), - NB_INPLACE_OR(PyNumberMethods__nb_inplace_or, T___IOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_OR), - NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER), - NB_INPLACE_REMAINDER(PyNumberMethods__nb_inplace_remainder, T___IMOD__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_REMAINDER), - NB_INPLACE_RSHIFT(PyNumberMethods__nb_inplace_rshift, T___IRSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_RSHIFT), - NB_INPLACE_SUBTRACT(PyNumberMethods__nb_inplace_subtract, T___ISUB__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_SUBTRACT), - NB_INPLACE_TRUE_DIVIDE(PyNumberMethods__nb_inplace_true_divide, T___ITRUEDIV__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_TRUE_DIVIDE), - NB_INPLACE_XOR(PyNumberMethods__nb_inplace_xor, T___IXOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_XOR); + NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER); public final TruffleString methodName; public final Function wrapperFactory; @@ -161,17 +134,8 @@ public enum SlotMethodDef { initGroup( PyTypeObject__tp_as_number, NB_INPLACE_ADD, - NB_INPLACE_AND, - NB_INPLACE_FLOOR_DIVIDE, - NB_INPLACE_LSHIFT, NB_INPLACE_MULTIPLY, - NB_INPLACE_OR, - NB_INPLACE_POWER, - NB_INPLACE_REMAINDER, - NB_INPLACE_RSHIFT, - NB_INPLACE_SUBTRACT, - NB_INPLACE_TRUE_DIVIDE, - NB_INPLACE_XOR); + NB_INPLACE_POWER); } private static void initGroup(CFields typeField, SlotMethodDef... slots) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index 2be40e1b3d..c56444436b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -152,18 +152,8 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl writeGroupSlots(CFields.PyTypeObject__tp_as_number, slots, writePointerNode, mem, nullValue); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_add, getSlot(obj, SlotMethodDef.NB_INPLACE_ADD)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_and, getSlot(obj, SlotMethodDef.NB_INPLACE_AND)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_floor_divide, getSlot(obj, SlotMethodDef.NB_INPLACE_FLOOR_DIVIDE)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_lshift, getSlot(obj, SlotMethodDef.NB_INPLACE_LSHIFT)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_matrix_multiply, nullValue); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_multiply, getSlot(obj, SlotMethodDef.NB_INPLACE_MULTIPLY)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_or, getSlot(obj, SlotMethodDef.NB_INPLACE_OR)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_power, getSlot(obj, SlotMethodDef.NB_INPLACE_POWER)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_remainder, getSlot(obj, SlotMethodDef.NB_INPLACE_REMAINDER)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_rshift, getSlot(obj, SlotMethodDef.NB_INPLACE_RSHIFT)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_subtract, getSlot(obj, SlotMethodDef.NB_INPLACE_SUBTRACT)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_true_divide, getSlot(obj, SlotMethodDef.NB_INPLACE_TRUE_DIVIDE)); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_xor, getSlot(obj, SlotMethodDef.NB_INPLACE_XOR)); return mem; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java index 1c01a5fdd6..35dd7429b0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java @@ -141,7 +141,7 @@ private HPyBinaryArithmeticCached(BinaryArithmetic operator) { @Override public Object execute(Object arg0, Object arg1) { - return opNode.executeObject(null, arg0, arg1); + return opNode.execute(null, arg0, arg1); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 2e9807b5f6..8c4a246fb1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -2015,7 +2015,7 @@ boolean doGeneric(VirtualFrame frame, SequenceStorage left, SequenceStorage righ } private boolean cmpGeneric(VirtualFrame frame, Object left, Object right) { - return castToBoolean(frame, cmpOp.executeObject(frame, left, right)); + return castToBoolean(frame, cmpOp.execute(frame, left, right)); } private boolean castToBoolean(VirtualFrame frame, Object value) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SortNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SortNodes.java index 241d0d724b..0b0b9510cc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SortNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SortNodes.java @@ -131,9 +131,9 @@ public Object execute(VirtualFrame frame) { Object[] arguments = frame.getArguments(); Object a = arguments[PArguments.USER_ARGUMENTS_OFFSET]; Object b = arguments[PArguments.USER_ARGUMENTS_OFFSET + 1]; - if (isTrueNode.execute(frame, ltNodeA.executeObject(frame, a, b))) { + if (isTrueNode.execute(frame, ltNodeA.execute(frame, a, b))) { return Result.LT; - } else if (isTrueNode.execute(frame, ltNodeB.executeObject(frame, b, a))) { + } else if (isTrueNode.execute(frame, ltNodeB.execute(frame, b, a))) { return Result.GT; } else { return Result.EQ; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java index 325a06fd49..f5c7fcd4ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; @@ -624,9 +623,9 @@ static Object or(Object self, Object other) { } } - @Builtin(name = J___IOR__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends PythonBinaryBuiltinNode { + abstract static class IOrNode extends BinaryOpBuiltinNode { @Specialization Object or(VirtualFrame frame, Object self, Object other, @Cached DictNodes.UpdateNode updateNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index f4dce3ab2a..b53ff2dc93 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -292,9 +292,9 @@ Object doGeneric(VirtualFrame frame, Object left, Object right, Object unboxed = unboxNode.execute(inliningTarget, left); if (unboxed != null) { if (!reverse) { - return op.executeObject(frame, unboxed, right); + return op.execute(frame, unboxed, right); } else { - return op.executeObject(frame, right, unboxed); + return op.execute(frame, right, unboxed); } } else { return PNotImplemented.NOT_IMPLEMENTED; @@ -324,7 +324,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object left, Object if (newLeft == null || newRight == null) { return PNotImplemented.NOT_IMPLEMENTED; } - return op.executeObject(frame, newLeft, newRight); + return op.execute(frame, newLeft, newRight); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java index 41fe34298e..2a2c2c902a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java @@ -35,7 +35,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__; @@ -192,7 +191,7 @@ public abstract static class ContainsNode extends PythonBuiltinNode { @Specialization Object run(VirtualFrame frame, PMappingproxy self, Object key, @Cached com.oracle.graal.python.nodes.expression.ContainsNode containsNode) { - return containsNode.executeObject(frame, key, self.getMapping()); + return containsNode.execute(frame, key, self.getMapping()); } } @@ -278,13 +277,13 @@ Object or(VirtualFrame frame, Object self, Object other) { if (other instanceof PMappingproxy) { other = ((PMappingproxy) other).getMapping(); } - return orNode.executeObject(frame, self, other); + return orNode.execute(frame, self, other); } } - @Builtin(name = J___IOR__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends PythonBinaryBuiltinNode { + abstract static class IOrNode extends BinaryOpBuiltinNode { @Specialization static Object or(Object self, @SuppressWarnings("unused") Object other, @Bind("this") Node inliningTarget) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java index b76f4a73bc..c834e651c7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java @@ -702,7 +702,7 @@ boolean richcmp(VirtualFrame frame, Object left, Object right, @SuppressWarnings return castToBooleanNode.execute(frame, e.getResult()); } } else { - return castToBooleanNode.execute(frame, node.executeObject(frame, left, right)); + return castToBooleanNode.execute(frame, node.execute(frame, left, right)); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java index 19018ae0c8..4608ea7a72 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java @@ -48,7 +48,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J_VALUES; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; @@ -271,9 +270,9 @@ static Object or(Object self, Object other) { } } - @Builtin(name = J___IOR__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends PythonBinaryBuiltinNode { + abstract static class IOrNode extends BinaryOpBuiltinNode { @Specialization static Object or(VirtualFrame frame, POrderedDict self, Object other, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java index a713daa3eb..35030b8572 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java @@ -201,7 +201,7 @@ public abstract static class RefTypeEqNode extends PythonBuiltinNode { @Specialization(guards = {"self.getObject() != null", "other.getObject() != null"}) Object eq(VirtualFrame frame, PReferenceType self, PReferenceType other, @Cached BinaryComparisonNode.EqNode eqNode) { - return eqNode.executeObject(frame, self.getObject(), other.getObject()); + return eqNode.execute(frame, self.getObject(), other.getObject()); } @Specialization(guards = "self.getObject() == null || other.getObject() == null") @@ -223,7 +223,7 @@ public abstract static class RefTypeNeNode extends PythonBuiltinNode { @Specialization(guards = {"self.getObject() != null", "other.getObject() != null"}) Object ne(VirtualFrame frame, PReferenceType self, PReferenceType other, @Cached BinaryComparisonNode.NeNode neNode) { - return neNode.executeObject(frame, self.getObject(), other.getObject()); + return neNode.execute(frame, self.getObject(), other.getObject()); } @Specialization(guards = "self.getObject() == null || other.getObject() == null") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java index 4cb3141a30..87287d8c35 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java @@ -26,17 +26,15 @@ package com.oracle.graal.python.builtins.objects.set; import static com.oracle.graal.python.nodes.BuiltinNames.J_ADD; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IAND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ISUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -61,6 +59,8 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.dict.PDictView; import com.oracle.graal.python.builtins.objects.str.PString; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.lib.GetNextNode; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.nodes.ErrorMessages; @@ -101,6 +101,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PSet) public final class SetBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = SetBuiltinsSlotsGen.SLOTS; + @Override public void initialize(Python3Core core) { super.initialize(core); @@ -181,9 +183,9 @@ public static Object add(VirtualFrame frame, PSet self, Object o, } } - @Builtin(name = J___IOR__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - public abstract static class IOrNode extends PythonBinaryBuiltinNode { + public abstract static class IOrNode extends BinaryOpBuiltinNode { @Specialization Object doSet(VirtualFrame frame, PSet self, PBaseSet other, @Bind("this") Node inliningTarget, @@ -369,9 +371,9 @@ static PNone doSet(VirtualFrame frame, PSet self, Object other, } } - @Builtin(name = J___IAND__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_and, isComplex = true) @GenerateNodeFactory - public abstract static class IAndNode extends PythonBinaryBuiltinNode { + public abstract static class IAndNode extends BinaryOpBuiltinNode { @Specialization static PBaseSet doPBaseSet(VirtualFrame frame, PSet left, PBaseSet right, @@ -470,9 +472,9 @@ protected Object createResult(PSet self, HashingStorage result) { } } - @Builtin(name = J___IXOR__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_xor, isComplex = true) @GenerateNodeFactory - public abstract static class IXorNode extends PythonBinaryBuiltinNode { + public abstract static class IXorNode extends BinaryOpBuiltinNode { @Specialization static Object doSet(VirtualFrame frame, PSet self, PBaseSet other, @@ -556,9 +558,9 @@ static PNone doSetOther(VirtualFrame frame, PSet self, Object other, } } - @Builtin(name = J___ISUB__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.nb_inplace_subtract, isComplex = true) @GenerateNodeFactory - abstract static class ISubNode extends PythonBinaryBuiltinNode { + abstract static class ISubNode extends BinaryOpBuiltinNode { @Specialization static PBaseSet doPBaseSet(VirtualFrame frame, PSet left, PBaseSet right, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index 9c0aa4e47d..dc54a17acb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -54,9 +54,21 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GET__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INDEX__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LEN__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; @@ -143,6 +155,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotBinaryFuncBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotSqConcat; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotBinaryIOpBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotBinaryOpBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotReversiblePython; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.TpSlotDescrGetBuiltin; @@ -263,6 +276,18 @@ public record TpSlots(TpSlot nb_bool, // TpSlot nb_divmod, // TpSlot nb_matrix_multiply, // TpSlot nb_power, // + TpSlot nb_inplace_add, // + TpSlot nb_inplace_subtract, // + TpSlot nb_inplace_multiply, // + TpSlot nb_inplace_remainder, // + TpSlot nb_inplace_lshift, // + TpSlot nb_inplace_rshift, // + TpSlot nb_inplace_and, // + TpSlot nb_inplace_xor, // + TpSlot nb_inplace_or, // + TpSlot nb_inplace_floor_divide, // + TpSlot nb_inplace_true_divide, // + TpSlot nb_inplace_matrix_multiply, // TpSlot sq_length, // TpSlot sq_item, // TpSlot sq_ass_item, // @@ -537,6 +562,102 @@ public enum TpSlotMeta { CFields.PyNumberMethods__nb_power, PExternalFunctionWrapper.TERNARYFUNC, NbPowerWrapper::new), + NB_INPLACE_ADD( + TpSlots::nb_inplace_add, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_add, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_SUBTRACT( + TpSlots::nb_inplace_subtract, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_subtract, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_MULTIPLY( + TpSlots::nb_inplace_multiply, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_multiply, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_REMAINDER( + TpSlots::nb_inplace_remainder, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_remainder, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_LSHIFT( + TpSlots::nb_inplace_lshift, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_lshift, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_RSHIFT( + TpSlots::nb_inplace_rshift, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_rshift, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_AND( + TpSlots::nb_inplace_and, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_and, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_XOR( + TpSlots::nb_inplace_xor, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_xor, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_OR( + TpSlots::nb_inplace_or, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_or, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_FLOOR_DIVIDE( + TpSlots::nb_inplace_floor_divide, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_floor_divide, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_TRUE_DIVIDE( + TpSlots::nb_inplace_true_divide, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_true_divide, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), + NB_INPLACE_MATRIX_MULTIPLY( + TpSlots::nb_inplace_matrix_multiply, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_matrix_multiply, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), SQ_LENGTH( TpSlots::sq_length, TpSlotPythonSingle.class, @@ -870,6 +991,18 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.NB_POWER, TpSlotDef.withoutHPy(T___POW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC), TpSlotDef.withoutHPy(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); + // addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_SUBTRACT, TpSlotDef.withSimpleFunction(T___ISUB__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + // addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_REMAINDER, TpSlotDef.withSimpleFunction(T___IMOD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_LSHIFT, TpSlotDef.withSimpleFunction(T___ILSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_RSHIFT, TpSlotDef.withSimpleFunction(T___IRSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_AND, TpSlotDef.withSimpleFunction(T___IAND__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_XOR, TpSlotDef.withSimpleFunction(T___IXOR__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_OR, TpSlotDef.withSimpleFunction(T___IOR__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE, TpSlotDef.withSimpleFunction(T___IFLOORDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_TRUE_DIVIDE, TpSlotDef.withSimpleFunction(T___ITRUEDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMATMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_BOOL, TpSlotDef.withSimpleFunction(T___BOOL__, PExternalFunctionWrapper.INQUIRY)); addSlotDef(s, TpSlotMeta.NB_INDEX, TpSlotDef.withSimpleFunction(T___INDEX__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INT, TpSlotDef.withSimpleFunction(T___INT__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1490,6 +1623,18 @@ public TpSlots build() { get(TpSlotMeta.NB_DIVMOD), // get(TpSlotMeta.NB_MATRIX_MULTIPLY), // get(TpSlotMeta.NB_POWER), // + get(TpSlotMeta.NB_INPLACE_ADD), // + get(TpSlotMeta.NB_INPLACE_SUBTRACT), // + get(TpSlotMeta.NB_INPLACE_MULTIPLY), // + get(TpSlotMeta.NB_INPLACE_REMAINDER), // + get(TpSlotMeta.NB_INPLACE_LSHIFT), // + get(TpSlotMeta.NB_INPLACE_RSHIFT), // + get(TpSlotMeta.NB_INPLACE_AND), // + get(TpSlotMeta.NB_INPLACE_XOR), // + get(TpSlotMeta.NB_INPLACE_OR), // + get(TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE), // + get(TpSlotMeta.NB_INPLACE_TRUE_DIVIDE), // + get(TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY), // get(TpSlotMeta.SQ_LENGTH), // get(TpSlotMeta.SQ_ITEM), // get(TpSlotMeta.SQ_ASS_ITEM), // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java index eeaee95aef..016ce83ae9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.objects.type.slots; +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -111,7 +112,7 @@ protected TpSlotMpSubscript(NodeFactory nodeFactory) { public abstract static class TpSlotSqConcat extends TpSlotBinaryFuncBuiltin { protected TpSlotSqConcat(NodeFactory nodeFactory) { - super(nodeFactory, PExternalFunctionWrapper.BINARYFUNC, J___GETITEM__); + super(nodeFactory, PExternalFunctionWrapper.BINARYFUNC, J___ADD__); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java index 462a7da957..b8189ba239 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java @@ -44,6 +44,18 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DIVMOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; @@ -91,6 +103,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPython; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotBinaryFuncBuiltin; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; @@ -182,6 +195,61 @@ public static ReversibleSlot fromCallableNames(TruffleString[] names) { } } + public enum InplaceSlot { + NB_INPLACE_ADD(T___IADD__, ReversibleSlot.NB_ADD), + NB_INPLACE_SUBTRACT(T___ISUB__, ReversibleSlot.NB_SUBTRACT), + NB_INPLACE_MULTIPLY(T___IMUL__, ReversibleSlot.NB_MULTIPLY), + NB_INPLACE_REMAINDER(T___IMOD__, ReversibleSlot.NB_REMAINDER), + NB_INPLACE_LSHIFT(T___ILSHIFT__, ReversibleSlot.NB_LSHIFT), + NB_INPLACE_RSHIFT(T___IRSHIFT__, ReversibleSlot.NB_RSHIFT), + NB_INPLACE_AND(T___IAND__, ReversibleSlot.NB_AND), + NB_INPLACE_XOR(T___IXOR__, ReversibleSlot.NB_XOR), + NB_INPLACE_OR(T___IOR__, ReversibleSlot.NB_OR), + NB_INPLACE_FLOOR_DIVIDE(T___IFLOORDIV__, ReversibleSlot.NB_FLOOR_DIVIDE), + NB_INPLACE_TRUE_DIVIDE(T___ITRUEDIV__, ReversibleSlot.NB_TRUE_DIVIDE), + NB_INPLACE_MATRIX_MULTIPLY(T___IMATMUL__, ReversibleSlot.NB_MATRIX_MULTIPLY); + + private static final InplaceSlot[] VALUES = values(); + private final TruffleString name; + private final ReversibleSlot reversibleSlot; + + InplaceSlot(TruffleString name, ReversibleSlot reversibleSlot) { + this.name = name; + this.reversibleSlot = reversibleSlot; + } + + public TpSlot getSlotValue(TpSlots slots) { + // switch instead of using TpSlotMeta for better inlining on fast-path + return switch (this) { + case NB_INPLACE_ADD -> slots.nb_inplace_add(); + case NB_INPLACE_SUBTRACT -> slots.nb_inplace_subtract(); + case NB_INPLACE_MULTIPLY -> slots.nb_inplace_multiply(); + case NB_INPLACE_REMAINDER -> slots.nb_inplace_remainder(); + case NB_INPLACE_LSHIFT -> slots.nb_inplace_lshift(); + case NB_INPLACE_RSHIFT -> slots.nb_inplace_rshift(); + case NB_INPLACE_AND -> slots.nb_inplace_and(); + case NB_INPLACE_XOR -> slots.nb_inplace_xor(); + case NB_INPLACE_OR -> slots.nb_inplace_or(); + case NB_INPLACE_FLOOR_DIVIDE -> slots.nb_inplace_floor_divide(); + case NB_INPLACE_TRUE_DIVIDE -> slots.nb_inplace_true_divide(); + case NB_INPLACE_MATRIX_MULTIPLY -> slots.nb_inplace_matrix_multiply(); + }; + } + + public static InplaceSlot fromCallableNames(TruffleString[] names) { + for (InplaceSlot op : VALUES) { + if (names[0].equals(op.name)) { + return op; + } + } + return null; + } + + public ReversibleSlot getReversibleSlot() { + return reversibleSlot; + } + } + public abstract static class TpSlotBinaryOpBuiltin extends TpSlotBuiltin { private final int callTargetIndex = TpSlotBuiltinCallTargetRegistry.getNextCallTargetIndex(); private final String builtinName; @@ -216,6 +284,13 @@ private PBuiltinFunction createRBuiltin(Python3Core core, Object type, TruffleSt } } + public abstract static class TpSlotBinaryIOpBuiltin extends TpSlotBinaryFuncBuiltin { + + protected TpSlotBinaryIOpBuiltin(NodeFactory nodeFactory, String builtinName) { + super(nodeFactory, PExternalFunctionWrapper.BINARYFUNC, builtinName); + } + } + static final class SwapArgumentsNode extends PythonBinaryBuiltinNode { @Child private BinaryOpBuiltinNode wrapped; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java index f0e7343f7b..92cb0e4033 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java @@ -302,7 +302,7 @@ Object getitem(VirtualFrame frame, PUnionType self, Object item, Object[] newargs = GenericTypeNodes.subsParameters(this, self, self.getArgs(), self.getParameters(), item); Object result = newargs[0]; for (int i = 1; i < newargs.length; i++) { - result = orNode.executeObject(frame, result, newargs[i]); + result = orNode.execute(frame, result, newargs[i]); } return result; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOp1Node.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOp1Node.java new file mode 100644 index 0000000000..a873681881 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOp1Node.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.PNodeWithContext; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; + +/** + * Equivalent of cpython://Objects/abstract.c#binary_iop1. + */ +@GenerateInline +@GenerateCached(false) +@GenerateUncached +public abstract class CallBinaryIOp1Node extends PNodeWithContext { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlots slotsV, + Object w, Object classW, TpSlots slotsW, InplaceSlot op); + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlots slotsV, Object w, Object classW, TpSlots slotsW, InplaceSlot iop, + @Cached CallSlotBinaryFuncNode callSlotNode, + @Cached InlinedBranchProfile resultProfile, + @Cached CallBinaryOp1Node callBinaryOp1Node) { + TpSlot slot = iop.getSlotValue(slotsV); + if (slot != null) { + Object result = callSlotNode.execute(frame, inliningTarget, slot, v, w); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + resultProfile.enter(inliningTarget); + return result; + } + } + return callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, iop.getReversibleSlot()); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOpNode.java new file mode 100644 index 0000000000..b52455725d --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryIOpNode.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025, 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.lib; + +import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; + +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +/** + * Equivalent of cpython://Objects/abstract.c#binary_op. + */ +@GenerateInline +@GenerateCached(false) +@GenerateUncached +public abstract class CallBinaryIOpNode extends Node { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, InplaceSlot slot, String opName); + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, InplaceSlot slot, String opName, + @Cached GetClassNode getVClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Cached GetClassNode getWClass, + @Cached CallBinaryIOp1Node callBinaryIOp1Node, + @Cached PRaiseNode raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + Object classW = getWClass.execute(inliningTarget, w); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + Object result = callBinaryIOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, slot); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; + } + throw raiseNotSupported(inliningTarget, v, w, opName, raiseNode); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java index 3071008a18..8db781fbb2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOp1Node.java @@ -41,16 +41,18 @@ package com.oracle.graal.python.lib; import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.IsSameSlotNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.CallSlotBinaryOpNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -62,9 +64,10 @@ */ @GenerateInline @GenerateCached(false) +@GenerateUncached public abstract class CallBinaryOp1Node extends PNodeWithContext { - public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, - Object w, Object classW, TpSlot slotW, ReversibleSlot op); + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlots slotsV, + Object w, Object classW, TpSlots slotsW, ReversibleSlot op); // CPython binary_op1 may end up calling SLOT1BINFULL - wrapper around the dunder methods, which // duplicates some of the logic checking the right operand, its slot, and whether it is subtype. @@ -86,47 +89,50 @@ public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v // we just try __rxxx__, again, without any subclass check. @Specialization - static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlot slotV, Object w, Object classW, TpSlot slotWIn, ReversibleSlot op, + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object classV, TpSlots slotsV, Object w, Object classW, TpSlots slotsW, ReversibleSlot op, @Cached IsSameTypeNode isSameTypeNode, @Cached IsSameSlotNode isSameSlotNode, @Cached InlinedConditionProfile isSameTypeProfile, @Cached InlinedConditionProfile isSameSlotProfile, @Cached(inline = false) IsSubtypeNode isSubtypeNode, - @Cached InlinedBranchProfile wResultBranch, - @Cached InlinedBranchProfile vResultBranch, + @Cached InlinedConditionProfile vResultProfile, + @Cached InlinedConditionProfile wResultProfile, @Cached InlinedBranchProfile notImplementedBranch, @Cached CallSlotBinaryOpNode callSlotWNode, @Cached CallSlotBinaryOpNode callSlotVNode) { - TpSlot slotW = null; - boolean sameTypes = isSameTypeProfile.profile(inliningTarget, isSameTypeNode.execute(inliningTarget, classW, classV)); - if (!sameTypes) { - slotW = slotWIn; - if (isSameSlotProfile.profile(inliningTarget, slotV != null && slotW != null && isSameSlotNode.execute(inliningTarget, slotW, slotV))) { - slotW = null; - } - } + final TpSlot slotV = op.getSlotValue(slotsV); + final TpSlot slotW = op.getSlotValue(slotsW); + boolean skipReverse = false; // Note: we call slotW with v as the receiver. This appears to be the semantics of // CPython reversible binop slots. This is supposed to allow the slot to handle // the reversible case, if the slot does not want to handle it, it should detect that // the first receiver argument is not of the right type and just return NotImplemented. if (slotV != null) { - if (slotW != null && isSubtypeNode.execute(frame, classW, classV)) { - assert !sameTypes; - Object result = callSlotWNode.execute(frame, inliningTarget, slotW, v, classV, w, slotW, classW, false, op); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - wResultBranch.enter(inliningTarget); - return result; + boolean sameTypes = false; + if (slotW != null) { + sameTypes = isSameTypeProfile.profile(inliningTarget, isSameTypeNode.execute(inliningTarget, classW, classV)); + if (!sameTypes) { + if (!isSameSlotProfile.profile(inliningTarget, isSameSlotNode.execute(inliningTarget, slotW, slotV))) { + if (isSubtypeNode.execute(frame, classW, classV)) { + Object result = callSlotWNode.execute(frame, inliningTarget, slotW, v, classV, w, slotW, classW, false, op); + if (wResultProfile.profile(inliningTarget, result != PNotImplemented.NOT_IMPLEMENTED)) { + return result; + } + skipReverse = true; + } + } else { + skipReverse = true; + } + } else { + skipReverse = true; } - slotW = null; } - Object result = callSlotVNode.execute(frame, inliningTarget, slotV, v, classV, w, slotWIn, classW, sameTypes, op); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - vResultBranch.enter(inliningTarget); + Object result = callSlotVNode.execute(frame, inliningTarget, slotV, v, classV, w, slotW, classW, sameTypes, op); + if (vResultProfile.profile(inliningTarget, result != PNotImplemented.NOT_IMPLEMENTED)) { return result; } } - if (slotW != null) { - assert !sameTypes; + if (slotW != null && !skipReverse) { return callSlotWNode.execute(frame, inliningTarget, slotW, v, classV, w, slotW, classW, false, op); } notImplementedBranch.enter(inliningTarget); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOpNode.java new file mode 100644 index 0000000000..e09fb2c59d --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallBinaryOpNode.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +/** + * Equivalent of cpython://Objects/abstract.c#binary_op. + */ +@GenerateInline +@GenerateCached(false) +@GenerateUncached +public abstract class CallBinaryOpNode extends Node { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, ReversibleSlot slot, String opName); + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, ReversibleSlot slot, String opName, + @Cached GetClassNode getVClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Cached GetClassNode getWClass, + @Cached CallBinaryOp1Node callBinaryOp1Node, + @Cached PRaiseNode raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + Object classW = getWClass.execute(inliningTarget, w); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, slot); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; + } + throw raiseNotSupported(inliningTarget, v, w, opName, raiseNode); + } + + @InliningCutoff + static PException raiseNotSupported(Node inliningTarget, Object v, Object w, String opName, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, opName, v, w); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index d14256f4c6..a169ce7770 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -40,10 +40,10 @@ */ package com.oracle.graal.python.lib; +import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode; @@ -51,22 +51,19 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; @@ -76,28 +73,13 @@ import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; -@GenerateInline(inlineByDefault = true) -public abstract class PyNumberAddNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return executeCached(frame, left, right); - } - - public final Object executeCached(VirtualFrame frame, Object v, Object w) { - return execute(frame, this, v, w); - } - - public abstract int executeInt(VirtualFrame frame, Node inliningTarget, int left, int right) throws UnexpectedResultException; - - public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException; +@GenerateCached(false) +abstract class PyNumberAddBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, FloatBuiltins, ListBuiltins, ... */ - @Specialization(rewriteOn = ArithmeticException.class) public static int add(int left, int right) { return Math.addExact(left, right); @@ -137,6 +119,24 @@ public static double doDI(double left, int right) { public static double doID(int left, double right) { return left + right; } +} + +@GenerateInline(inlineByDefault = true) +public abstract class PyNumberAddNode extends PyNumberAddBaseNode { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); + + @Override + public final Object execute(VirtualFrame frame, Object left, Object right) { + return executeCached(frame, left, right); + } + + public final Object executeCached(VirtualFrame frame, Object v, Object w) { + return execute(frame, this, v, w); + } + + public abstract int executeInt(VirtualFrame frame, Node inliningTarget, int left, int right) throws UnexpectedResultException; + + public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException; @NeverDefault protected static SequenceStorageNodes.ConcatNode createConcat() { @@ -179,24 +179,15 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object classW = getWClass.execute(inliningTarget, w); TpSlots slotsV = getVSlots.execute(inliningTarget, classV); TpSlots slotsW = getWSlots.execute(inliningTarget, classW); - TpSlot slotV = slotsV.nb_add(); - TpSlot slotW = slotsW.nb_add(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_ADD); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - hasNbAddResult.enter(inliningTarget); - return result; - } + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, ReversibleSlot.NB_ADD); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbAddResult.enter(inliningTarget); + return result; } if (slotsV.sq_concat() != null) { return callBinarySlotNode.execute(frame, inliningTarget, slotsV.sq_concat(), v, w); } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); + return raiseNotSupported(inliningTarget, v, w, "+", raiseNode); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index a355cc7ddd..1a714d901b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -40,34 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberAndNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberAndBaseNode extends BinaryOpNode { @Specialization public static int op(int left, int right) { @@ -78,33 +66,18 @@ public static int op(int left, int right) { public static long op(long left, long right) { return left & right; } +} + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberAndNode extends PyNumberAndBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_and(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_and(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_AND); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "&", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_AND, "&"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java index 1b113ff484..37f65cd7f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java @@ -40,30 +40,23 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(inlineByDefault = true) +@GenerateUncached public abstract class PyNumberDivmodNode extends BinaryOpNode { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { + public final Object execute(VirtualFrame frame, Object left, Object right) { return executeCached(frame, left, right); } @@ -72,29 +65,9 @@ public final Object executeCached(VirtualFrame frame, Object v, Object w) { } @Specialization - static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_divmod(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_divmod(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_DIVMOD); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "divmod()", v, w); + public static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_DIVMOD, "divmod()"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index 780808a84f..d0502ec191 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -40,35 +40,20 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.util.OverflowException; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberFloorDivideNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberFloorDivideBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions @@ -107,32 +92,16 @@ public static double doDD(double left, double right) throws OverflowException { } return Math.floor(left / right); } +} - @Fallback +@GenerateInline(false) +public abstract class PyNumberFloorDivideNode extends PyNumberFloorDivideBaseNode { + + @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_floor_divide(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_floor_divide(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_FLOOR_DIVIDE); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "//", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_FLOOR_DIVIDE, "//"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java new file mode 100644 index 0000000000..85992c10f8 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberInplaceAndNode extends PyNumberAndBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_AND, "&="); + } + + @NeverDefault + public static PyNumberInplaceAndNode create() { + return PyNumberInplaceAndNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java new file mode 100644 index 0000000000..079c4c3796 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceFloorDivideNode extends PyNumberFloorDivideBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_FLOOR_DIVIDE, "//="); + } + + @NeverDefault + public static PyNumberInplaceFloorDivideNode create() { + return PyNumberInplaceFloorDivideNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java new file mode 100644 index 0000000000..38bd68ff5c --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceLshiftNode extends PyNumberLshiftBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_LSHIFT, "<<="); + } + + @NeverDefault + public static PyNumberInplaceLshiftNode create() { + return PyNumberInplaceLshiftNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java new file mode 100644 index 0000000000..8851785e01 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberInplaceMatrixMultiplyNode extends BinaryOpNode { + @Specialization + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_MATRIX_MULTIPLY, "@="); + } + + @NeverDefault + public static PyNumberInplaceMatrixMultiplyNode create() { + return PyNumberInplaceMatrixMultiplyNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java new file mode 100644 index 0000000000..bf5d14e578 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberInplaceOrNode extends PyNumberOrBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_OR, "|="); + } + + @NeverDefault + public static PyNumberInplaceOrNode create() { + return PyNumberInplaceOrNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java new file mode 100644 index 0000000000..c8cb9a6cdc --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceRemainderNode extends PyNumberRemainderBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_REMAINDER, "%="); + } + + @NeverDefault + public static PyNumberInplaceRemainderNode create() { + return PyNumberInplaceRemainderNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java new file mode 100644 index 0000000000..3ae084345e --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceRshiftNode extends PyNumberRshiftBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_RSHIFT, ">>="); + } + + @NeverDefault + public static PyNumberInplaceRshiftNode create() { + return PyNumberInplaceRshiftNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java new file mode 100644 index 0000000000..61be233988 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceSubtractNode extends PyNumberSubtractBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_SUBTRACT, "-="); + } + + @NeverDefault + public static PyNumberInplaceSubtractNode create() { + return PyNumberInplaceSubtractNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java new file mode 100644 index 0000000000..b038bc42d0 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +public abstract class PyNumberInplaceTrueDivideNode extends PyNumberTrueDivideBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_TRUE_DIVIDE, "/="); + } + + @NeverDefault + public static PyNumberInplaceTrueDivideNode create() { + return PyNumberInplaceTrueDivideNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java new file mode 100644 index 0000000000..0f5654ff61 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberInplaceXorNode extends PyNumberXorBaseNode { + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Cached CallBinaryIOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, InplaceSlot.NB_INPLACE_XOR, "^="); + } + + @NeverDefault + public static PyNumberInplaceXorNode create() { + return PyNumberInplaceXorNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index 5174b5e343..e78acaab90 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -40,35 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberLshiftNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberLshiftBaseNode extends BinaryOpNode { @Specialization(guards = {"right < 32", "right >= 0"}, rewriteOn = OverflowException.class) public static int doII(int left, int right) throws OverflowException { @@ -87,32 +74,17 @@ public static long doLL(long left, long right) throws OverflowException { } return result; } +} + +@GenerateInline(false) +public abstract class PyNumberLshiftNode extends PyNumberLshiftBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_lshift(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_lshift(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_LSHIFT); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "<<", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_LSHIFT, "<<"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java index 7595406b11..a0e3f6041c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java @@ -40,59 +40,26 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberMatrixMultiplyNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_matrix_multiply(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_matrix_multiply(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_MATRIX_MULTIPLY); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "@", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_MATRIX_MULTIPLY, "@"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index 784deff635..ee19d86660 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -40,6 +40,8 @@ */ package com.oracle.graal.python.lib; +import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; + import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots; @@ -56,6 +58,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; @@ -64,28 +67,13 @@ import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.profiles.InlinedBranchProfile; -@GenerateInline(inlineByDefault = true) -public abstract class PyNumberMultiplyNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return executeCached(frame, left, right); - } - - public final Object executeCached(VirtualFrame frame, Object v, Object w) { - return execute(frame, this, v, w); - } - - public abstract int executeInt(VirtualFrame frame, Node inliningTarget, int left, int right) throws UnexpectedResultException; - - public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException; +@GenerateCached(false) +abstract class PyNumberMultiplyBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, FloatBuiltins, ListBuiltins, ... */ - @Specialization(rewriteOn = ArithmeticException.class) public static int doII(int x, int y) throws ArithmeticException { return Math.multiplyExact(x, y); @@ -115,6 +103,24 @@ public static double doLD(long left, double right) { public static double doDD(double left, double right) { return left * right; } +} + +@GenerateInline(inlineByDefault = true) +public abstract class PyNumberMultiplyNode extends PyNumberMultiplyBaseNode { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); + + @Override + public final Object execute(VirtualFrame frame, Object left, Object right) { + return executeCached(frame, left, right); + } + + public final Object executeCached(VirtualFrame frame, Object v, Object w) { + return execute(frame, this, v, w); + } + + public abstract int executeInt(VirtualFrame frame, Node inliningTarget, int left, int right) throws UnexpectedResultException; + + public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException; @Fallback static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @@ -134,14 +140,10 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object classW = getWClass.execute(inliningTarget, w); TpSlots slotsV = getVSlots.execute(inliningTarget, classV); TpSlots slotsW = getWSlots.execute(inliningTarget, classW); - TpSlot slotV = slotsV.nb_multiply(); - TpSlot slotW = slotsW.nb_multiply(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_MULTIPLY); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - hasNbMulResult.enter(inliningTarget); - return result; - } + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, ReversibleSlot.NB_MULTIPLY); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbMulResult.enter(inliningTarget); + return result; } if (slotsV.sq_repeat() != null) { vHasSqRepeat.enter(inliningTarget); @@ -152,12 +154,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, return sequenceRepeat(frame, inliningTarget, slotsW.sq_repeat(), w, v, indexCheckNode, asSizeNode, callSlotNode, raiseNode); } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "+", v, w); + return raiseNotSupported(inliningTarget, v, w, "*", raiseNode); } private static Object sequenceRepeat(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object seq, Object n, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index d79c83a043..2b66915680 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -40,34 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberOrNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberOrBaseNode extends BinaryOpNode { @Specialization public static int op(int left, int right) { @@ -78,32 +66,18 @@ public static int op(int left, int right) { public static long op(long left, long right) { return left | right; } +} + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberOrNode extends PyNumberOrBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_or(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_or(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_OR); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "|", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_OR, "|"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java index fe4a46e0ce..18d3a87e3d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java @@ -66,7 +66,7 @@ public abstract class PyNumberPowerNode extends BinaryOpNode { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z); @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { + public final Object execute(VirtualFrame frame, Object left, Object right) { return executeCached(frame, left, right, PNone.NONE); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index e8af02f81c..78dba84ea7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -40,35 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.floats.FloatBuiltins; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberRemainderNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberRemainderBaseNode extends BinaryOpNode { @Specialization(rewriteOn = ArithmeticException.class) public static int doII(int left, int right) { @@ -84,32 +71,17 @@ public static long doLL(long left, long right) { public static double doDL(double left, long right) { return FloatBuiltins.ModNode.mod(left, right); } +} + +@GenerateInline(false) +public abstract class PyNumberRemainderNode extends PyNumberRemainderBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_remainder(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_remainder(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_REMAINDER); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "%", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_REMAINDER, "%"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index a4b7d9be6f..9203c8a04d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -46,8 +46,8 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -59,20 +59,15 @@ import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberRshiftNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberRshiftBaseNode extends BinaryOpNode { @Specialization(guards = {"right < 32", "right >= 0"}) public static int doIISmall(int left, int right) { @@ -83,6 +78,10 @@ public static int doIISmall(int left, int right) { public static long doIISmall(long left, long right) { return left >> right; } +} + +@GenerateInline(false) +public abstract class PyNumberRshiftNode extends PyNumberRshiftBaseNode { @Fallback public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -95,15 +94,13 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_rshift(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_rshift(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_RSHIFT); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, ReversibleSlot.NB_RSHIFT); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; } - return raiseNotSupported(inliningTarget, v, w, raiseNode); + throw raiseNotSupported(inliningTarget, v, w, raiseNode); } @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index 87548bc511..9144468818 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -40,40 +40,26 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberSubtractNode extends BinaryOpNode { - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } - - public abstract Object execute(VirtualFrame frame, Object v, Object w); +@GenerateCached(false) +abstract class PyNumberSubtractBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, FloatBuiltins, ListBuiltins, ... */ - @Specialization(rewriteOn = ArithmeticException.class) public static int doII(int x, int y) throws ArithmeticException { return Math.subtractExact(x, y); @@ -113,32 +99,17 @@ public static double doDI(double left, int right) { public static double doID(int left, double right) { return left - right; } +} + +@GenerateInline(false) +public abstract class PyNumberSubtractNode extends PyNumberSubtractBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_subtract(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_subtract(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_SUBTRACT); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "-", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_SUBTRACT, "-"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index a4986c6c72..bf9dff20a6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -40,35 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberTrueDivideNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberTrueDivideBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions @@ -96,32 +83,17 @@ public static double doDD(double left, double right) throws OverflowException { } return left / right; } +} + +@GenerateInline(false) +public abstract class PyNumberTrueDivideNode extends PyNumberTrueDivideBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_true_divide(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_true_divide(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_TRUE_DIVIDE); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "/", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_TRUE_DIVIDE, "/"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index a7de7a2959..5fb858c7a7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -40,34 +40,22 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(false) -public abstract class PyNumberXorNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Object v, Object w); - - @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } +@GenerateCached(false) +abstract class PyNumberXorBaseNode extends BinaryOpNode { @Specialization public static int op(int left, int right) { @@ -78,32 +66,18 @@ public static int op(int left, int right) { public static long op(long left, long right) { return left ^ right; } +} + +@GenerateInline(false) +@GenerateUncached +public abstract class PyNumberXorNode extends PyNumberXorBaseNode { @Fallback + @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, - @Cached GetClassNode getVClass, - @Cached GetCachedTpSlotsNode getVSlots, - @Cached GetCachedTpSlotsNode getWSlots, - @Cached GetClassNode getWClass, - @Cached CallBinaryOp1Node callBinaryOp1Node, - @Cached PRaiseNode raiseNode) { - Object classV = getVClass.execute(inliningTarget, v); - Object classW = getWClass.execute(inliningTarget, w); - TpSlot slotV = getVSlots.execute(inliningTarget, classV).nb_xor(); - TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_xor(); - if (slotV != null || slotW != null) { - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_XOR); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - return raiseNotSupported(inliningTarget, v, w, raiseNode); - } - - @InliningCutoff - private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, PRaiseNode raiseNode) { - return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "^", v, w); + @Cached CallBinaryOpNode callBinaryOpNode) { + return callBinaryOpNode.execute(frame, inliningTarget, v, w, ReversibleSlot.NB_XOR, "^"); } @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java index 14c8941b9d..9b77279aa3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java @@ -51,7 +51,6 @@ import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.ErrorMessages; @@ -129,15 +128,11 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, if (pySeqCheckV.execute(inliningTarget, v) && pySeqCheckW.execute(inliningTarget, w)) { Object classW = getWClass.execute(inliningTarget, w); TpSlots slotsW = getWSlots.execute(inliningTarget, classW); - TpSlot slotV = slotsV.nb_add(); - TpSlot slotW = slotsW.nb_add(); - if (slotV != null || slotW != null) { - hasNbAddSlot.enter(inliningTarget); - Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, ReversibleSlot.NB_ADD); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - hasNbAddResult.enter(inliningTarget); - return result; - } + hasNbAddSlot.enter(inliningTarget); + Object result = callBinaryOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, ReversibleSlot.NB_ADD); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbAddResult.enter(inliningTarget); + return result; } } return raiseNotSupported(inliningTarget, v, raiseNode); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 925af3cb16..767247dc68 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -109,9 +109,32 @@ import com.oracle.graal.python.compiler.QuickeningTypes; import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback; import com.oracle.graal.python.compiler.UnaryOpsConstants; +import com.oracle.graal.python.lib.PyNumberAddNode; +import com.oracle.graal.python.lib.PyNumberAndNode; +import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInplaceAndNode; +import com.oracle.graal.python.lib.PyNumberInplaceFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInplaceLshiftNode; +import com.oracle.graal.python.lib.PyNumberInplaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInplaceOrNode; +import com.oracle.graal.python.lib.PyNumberInplaceRemainderNode; +import com.oracle.graal.python.lib.PyNumberInplaceRshiftNode; +import com.oracle.graal.python.lib.PyNumberInplaceSubtractNode; +import com.oracle.graal.python.lib.PyNumberInplaceTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberInplaceXorNode; import com.oracle.graal.python.lib.PyNumberInvertNode; +import com.oracle.graal.python.lib.PyNumberLshiftNode; +import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyNumberNegativeNode; +import com.oracle.graal.python.lib.PyNumberOrNode; import com.oracle.graal.python.lib.PyNumberPositiveNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; +import com.oracle.graal.python.lib.PyNumberRemainderNode; +import com.oracle.graal.python.lib.PyNumberRshiftNode; +import com.oracle.graal.python.lib.PyNumberSubtractNode; +import com.oracle.graal.python.lib.PyNumberTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberXorNode; import com.oracle.graal.python.lib.PyObjectAsciiNode; import com.oracle.graal.python.lib.PyObjectAsciiNodeGen; import com.oracle.graal.python.lib.PyObjectDelItem; @@ -167,7 +190,6 @@ import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNodeGen; import com.oracle.graal.python.nodes.exception.ExceptMatchNode; import com.oracle.graal.python.nodes.exception.ExceptMatchNodeGen; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; import com.oracle.graal.python.nodes.expression.BinaryOp; import com.oracle.graal.python.nodes.expression.ContainsNode; @@ -413,57 +435,57 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod private static final IntNodeFunction BINARY_OP_FACTORY = (int op) -> { switch (op) { case BinaryOpsConstants.ADD: - return BinaryArithmetic.Add.create(); + return PyNumberAddNode.create(); case BinaryOpsConstants.SUB: - return BinaryArithmetic.Sub.create(); + return PyNumberSubtractNode.create(); case BinaryOpsConstants.MUL: - return BinaryArithmetic.Mul.create(); + return PyNumberMultiplyNode.create(); case BinaryOpsConstants.TRUEDIV: - return BinaryArithmetic.TrueDiv.create(); + return PyNumberTrueDivideNode.create(); case BinaryOpsConstants.FLOORDIV: - return BinaryArithmetic.FloorDiv.create(); + return PyNumberFloorDivideNode.create(); case BinaryOpsConstants.MOD: - return BinaryArithmetic.Mod.create(); + return PyNumberRemainderNode.create(); case BinaryOpsConstants.LSHIFT: - return BinaryArithmetic.LShift.create(); + return PyNumberLshiftNode.create(); case BinaryOpsConstants.RSHIFT: - return BinaryArithmetic.RShift.create(); + return PyNumberRshiftNode.create(); case BinaryOpsConstants.AND: - return BinaryArithmetic.And.create(); + return PyNumberAndNode.create(); case BinaryOpsConstants.OR: - return BinaryArithmetic.Or.create(); + return PyNumberOrNode.create(); case BinaryOpsConstants.XOR: - return BinaryArithmetic.Xor.create(); + return PyNumberXorNode.create(); case BinaryOpsConstants.POW: - return BinaryArithmetic.Pow.create(); + return PyNumberPowerNode.create(); case BinaryOpsConstants.MATMUL: - return BinaryArithmetic.MatMul.create(); + return PyNumberMatrixMultiplyNode.create(); case BinaryOpsConstants.INPLACE_ADD: return InplaceArithmetic.IAdd.create(); case BinaryOpsConstants.INPLACE_SUB: - return InplaceArithmetic.ISub.create(); + return PyNumberInplaceSubtractNode.create(); case BinaryOpsConstants.INPLACE_MUL: return InplaceArithmetic.IMul.create(); case BinaryOpsConstants.INPLACE_TRUEDIV: - return InplaceArithmetic.ITrueDiv.create(); + return PyNumberInplaceTrueDivideNode.create(); case BinaryOpsConstants.INPLACE_FLOORDIV: - return InplaceArithmetic.IFloorDiv.create(); + return PyNumberInplaceFloorDivideNode.create(); case BinaryOpsConstants.INPLACE_MOD: - return InplaceArithmetic.IMod.create(); + return PyNumberInplaceRemainderNode.create(); case BinaryOpsConstants.INPLACE_LSHIFT: - return InplaceArithmetic.ILShift.create(); + return PyNumberInplaceLshiftNode.create(); case BinaryOpsConstants.INPLACE_RSHIFT: - return InplaceArithmetic.IRShift.create(); + return PyNumberInplaceRshiftNode.create(); case BinaryOpsConstants.INPLACE_AND: - return InplaceArithmetic.IAnd.create(); + return PyNumberInplaceAndNode.create(); case BinaryOpsConstants.INPLACE_OR: - return InplaceArithmetic.IOr.create(); + return PyNumberInplaceOrNode.create(); case BinaryOpsConstants.INPLACE_XOR: - return InplaceArithmetic.IXor.create(); + return PyNumberInplaceXorNode.create(); case BinaryOpsConstants.INPLACE_POW: return InplaceArithmetic.IPow.create(); case BinaryOpsConstants.INPLACE_MATMUL: - return InplaceArithmetic.IMatMul.create(); + return PyNumberInplaceMatrixMultiplyNode.create(); case BinaryOpsConstants.EQ: return BinaryComparisonNode.EqNode.create(); case BinaryOpsConstants.NE: @@ -3849,7 +3871,7 @@ private void bytecodeBinaryOpOOO(VirtualFrame virtualFrame, int stackTop, int bc left = virtualFrame.getValue(stackTop - 1); } virtualFrame.setObject(stackTop, null); - Object result = opNode.executeObject(virtualFrame, left, right); + Object result = opNode.execute(virtualFrame, left, right); virtualFrame.setObject(stackTop - 1, result); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java index 7de2eb29de..e73fcb5874 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java @@ -134,7 +134,7 @@ protected Object doCall(VirtualFrame frame) { CompilerDirectives.transferToInterpreterAndInvalidate(); callBinaryNode = insert(binaryOperator.create()); } - return callBinaryNode.executeObject(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1)); + return callBinaryNode.execute(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1)); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOp.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOp.java index de1eb5746b..4dce665264 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOp.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -43,5 +43,5 @@ import com.oracle.truffle.api.frame.VirtualFrame; public interface BinaryOp { - Object executeObject(VirtualFrame frame, Object left, Object right); + Object execute(VirtualFrame frame, Object left, Object right); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOpNode.java index f0b51431bd..86039e7a50 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOpNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryOpNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -30,5 +30,5 @@ public abstract class BinaryOpNode extends PNodeWithContext implements BinaryOp { @Override - public abstract Object executeObject(VirtualFrame frame, Object left, Object right); + public abstract Object execute(VirtualFrame frame, Object left, Object right); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java index 5753161223..098bf33c3d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -104,10 +104,6 @@ private LookupAndCallTernaryNode ensureLookupAndCallTernaryNode() { } @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { - return execute(frame, left, right); - } - public final Object execute(VirtualFrame frame, Object left, Object right) { return executeTernary(frame, left, right, PNone.NO_VALUE); } @@ -142,7 +138,7 @@ Object doBinary(VirtualFrame frame, Object left, Object right, Object z, // try non-inplace variant boolean isBinary = PGuards.isPNone(z); if (isBinary) { - result = ensureLookupAndCallBinaryNode().executeObject(frame, left, right); + result = ensureLookupAndCallBinaryNode().execute(frame, left, right); } else { result = ensureLookupAndCallTernaryNode().execute(frame, left, right, z); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java index fb5dd6d72e..ce311acf65 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -87,7 +87,7 @@ public abstract class IsNode extends Node implements BinaryOp { protected abstract boolean executeInternal(boolean left, Object right); @Override - public final Object executeObject(VirtualFrame frame, Object left, Object right) { + public final Object execute(VirtualFrame frame, Object left, Object right) { return execute(left, right); } From d83de55c8322922fc3fea4bcebfe9eb1608c300d Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Feb 2025 11:13:30 +0100 Subject: [PATCH 020/512] Implement sq_inplace_concat and nb_inplace_add slots --- .../oracle/graal/python/annotations/Slot.java | 2 + .../graal/python/processor/SlotsMapping.java | 14 ++- .../src/tests/cpyext/test_tp_slots.py | 99 ++++++++++++++- .../modules/OperatorModuleBuiltins.java | 12 ++ .../cext/PythonCextAbstractBuiltins.java | 23 +--- .../builtins/objects/array/ArrayBuiltins.java | 3 +- .../objects/bytes/ByteArrayBuiltins.java | 3 +- .../objects/cext/capi/SlotMethodDef.java | 4 - .../objects/cext/capi/ToNativeTypeNode.java | 1 - .../builtins/objects/deque/DequeBuiltins.java | 3 +- .../builtins/objects/dict/DictBuiltins.java | 2 +- .../builtins/objects/list/ListBuiltins.java | 3 +- .../mappingproxy/MappingproxyBuiltins.java | 2 +- .../ordereddict/OrderedDictBuiltins.java | 2 +- .../builtins/objects/set/SetBuiltins.java | 9 +- .../python/builtins/objects/type/TpSlots.java | 17 ++- .../objects/type/slots/TpSlotBinaryOp.java | 54 +++------ .../python/lib/PyNumberInplaceAddNode.java | 107 ++++++++++++++++ .../python/lib/PySequenceInplaceConcat.java | 114 ++++++++++++++++++ .../nodes/bytecode/PBytecodeRootNode.java | 3 +- 20 files changed, 386 insertions(+), 91 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index c6bbb59f74..8d0a2b14db 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -171,6 +171,8 @@ enum SlotKind { sq_concat("__add__"), /** seq * number, nb_multiply is tried before */ sq_repeat("__mul__"), + /** seq += seq */ + sq_inplace_concat("__iadd__"), /** mapping length */ mp_length("__len__"), /** mapping subscript, e.g. o[key], o[i:j] */ diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index 5e2c1b93e7..2061b0b798 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -58,7 +58,8 @@ static String getSlotBaseClass(Slot s) { "TpSlotBinaryOp.TpSlotBinaryOpBuiltin"; case nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, - nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply -> + nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply, + sq_inplace_concat -> "TpSlotBinaryOp.TpSlotBinaryIOpBuiltin"; case nb_power -> "TpSlotNbPower.TpSlotNbPowerBuiltin"; case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat"; @@ -80,13 +81,15 @@ static String getSlotNodeBaseClass(Slot s) { case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode"; case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert -> "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode"; case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, - nb_floor_divide, nb_true_divide, nb_matrix_multiply, - nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, - nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, - nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply -> + nb_floor_divide, nb_true_divide, nb_matrix_multiply -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode"; case nb_power -> "com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode"; case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode"; + case nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, + nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, + nb_inplace_floor_divide, nb_inplace_true_divide, nb_inplace_matrix_multiply, + sq_inplace_concat -> + "com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode"; case sq_length, mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode"; case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode"; case sq_ass_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode"; @@ -165,6 +168,7 @@ public static String getExtraCtorArgs(TpSlotData slot) { case nb_inplace_floor_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IFLOORDIV__"; case nb_inplace_true_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ITRUEDIV__"; case nb_inplace_matrix_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMATMUL__"; + case sq_inplace_concat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__"; default -> ""; }; } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index 8ffd21fcb6..ba4e70da6d 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -293,14 +293,14 @@ def test_concat_vs_add(): x = SqAdd() assert x + x is x - # TODO: assert _operator.concat(x, x) is x when _operator.concat is implemented + assert operator.concat(x, x) is x assert x.__add__(x) is x class SqAddManaged(SqAdd): pass x = SqAddManaged() assert x + x is x assert x.__add__(x) is x - # TODO: assert _operator.concat(x, x) is x when _operator.concat is implemented + assert operator.concat(x, x) is x SqAddAndNbAdd = CPyExtHeapType("SqAddAndNbAdd", slots= [ @@ -314,7 +314,100 @@ class SqAddManaged(SqAdd): pass x = SqAddAndNbAdd() y = SqAddAndNbAdd() assert x + y is y - # TODO: assert _operator.concat(x, x) is x when _operator.concat is implemented + assert operator.concat(x, y) is x + + SqAddAndNbAddNoImplemented = CPyExtHeapType("SqAddAndNbAddNoImplemented", + slots= [ + '{Py_sq_concat, &concat}', + '{Py_nb_add, &myadd}', + ], + code= + 'PyObject* concat(PyObject* a, PyObject *b) { Py_INCREF(a); return a; }' + + 'PyObject* myadd(PyObject* a, PyObject *b) { Py_RETURN_NOTIMPLEMENTED; }') + x = SqAddAndNbAddNoImplemented() + assert x + 1 is x + + +def test_sq_inplace_concat_vs_nb_inplace_add(): + SqInplaceConcat = CPyExtHeapType( + "SqInplaceConcat", + slots=['{Py_sq_inplace_concat, &inplace_concat}'], + code='PyObject* inplace_concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_concat"); }', + ) + x = SqInplaceConcat() + x += 1 + assert x == "inplace_concat" + x = SqInplaceConcat() + assert operator.iconcat(x, []) == "inplace_concat" + + SqInplaceConcatAndNbInplaceAdd = CPyExtHeapType( + "SqInplaceConcatAndNbInplaceAdd", + slots=['{Py_sq_inplace_concat, &inplace_concat}', '{Py_nb_inplace_add, &inplace_add}'], + code=''' + PyObject* inplace_concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_concat"); } + PyObject* inplace_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_add"); } + ''', + ) + + x = SqInplaceConcatAndNbInplaceAdd() + x += 1 + assert x == "inplace_add" + x = SqInplaceConcatAndNbInplaceAdd() + assert operator.iconcat(x, 1) == "inplace_concat" + + SqInplaceConcatAndNbInplaceAddNotImplemented = CPyExtHeapType( + "InplaceConcatAddNotImpl", + slots=['{Py_sq_inplace_concat, &inplace_concat}', '{Py_nb_inplace_add, &inplace_add}'], + code=''' + PyObject* inplace_concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_concat"); } + PyObject* inplace_add(PyObject* a, PyObject *b) { Py_RETURN_NOTIMPLEMENTED; } + ''', + ) + + x = SqInplaceConcatAndNbInplaceAddNotImplemented() + x += 1 + assert x == "inplace_concat" + + class InplaceConcatSubclass(SqInplaceConcat): + pass + + x = InplaceConcatSubclass() + assert operator.iconcat(x, 1) == "inplace_concat" + + SqConcat = CPyExtHeapType( + "SqConcat", + slots=['{Py_sq_concat, &concat}'], + code='PyObject* concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("concat"); }', + ) + + x = SqConcat() + x += 1 + assert x == "concat" + x = SqConcat() + assert operator.iconcat(x, 1) == "concat" + + NbInplaceAdd = CPyExtHeapType( + "NbInplaceAdd", + slots=['{Py_nb_inplace_add, &inplace_add}'], + code='PyObject* inplace_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_add"); }', + ) + + x = NbInplaceAdd() + assert_raises(TypeError, operator.iconcat, x, 1) + assert_raises(TypeError, operator.iconcat, x, []) + + SequenceWithNbInplaceAdd = CPyExtHeapType( + "SequenceWithNbInplaceAdd", + slots=['{Py_nb_inplace_add, &inplace_add}', '{Py_sq_item, &item}'], + code=''' + PyObject* inplace_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_add"); } + PyObject* item(PyObject* a, PyObject *b) { return PyUnicode_FromString("item"); } + ''', + ) + + x = SequenceWithNbInplaceAdd() + assert_raises(TypeError, operator.iconcat, x, 1) + assert operator.iconcat(x, []) == "inplace_add" def test_incompatible_slots_assignment(): diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java index d4ac204674..cb467297d7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java @@ -55,6 +55,7 @@ import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PySequenceConcat; +import com.oracle.graal.python.lib.PySequenceInplaceConcat; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -118,6 +119,17 @@ static Object doObject(VirtualFrame frame, Object left, Object right, } } + @Builtin(name = "iconcat", minNumOfPositionalArgs = 2) + @GenerateNodeFactory + abstract static class IConcatNode extends PythonBinaryBuiltinNode { + @Specialization + static Object doObject(VirtualFrame frame, Object left, Object right, + @Bind("this") Node inliningTarget, + @Cached PySequenceInplaceConcat concatNode) { + return concatNode.execute(frame, inliningTarget, left, right); + } + } + @Builtin(name = "mul", minNumOfPositionalArgs = 2) @GenerateNodeFactory abstract static class MulNode extends PythonBinaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 0ccaff8da1..b4e924537c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -59,7 +59,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T_KEYS; import static com.oracle.graal.python.nodes.SpecialMethodNames.T_VALUES; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -102,7 +101,6 @@ import com.oracle.graal.python.lib.GetNextNode; import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.lib.PyIterCheckNode; -import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberCheckNode; import com.oracle.graal.python.lib.PyNumberFloatNode; import com.oracle.graal.python.lib.PyNumberIndexNode; @@ -118,6 +116,7 @@ import com.oracle.graal.python.lib.PySequenceContainsNode; import com.oracle.graal.python.lib.PySequenceDelItemNode; import com.oracle.graal.python.lib.PySequenceGetItemNode; +import com.oracle.graal.python.lib.PySequenceInplaceConcat; import com.oracle.graal.python.lib.PySequenceIterSearchNode; import com.oracle.graal.python.lib.PySequenceSetItemNode; import com.oracle.graal.python.lib.PySequenceSizeNode; @@ -572,25 +571,11 @@ Object doIt(Object s1, Object s2, @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) abstract static class PySequence_InPlaceConcat extends CApiBinaryBuiltinNode { - @Specialization(guards = {"checkNode.execute(inliningTarget, s1)"}, limit = "1") + @Specialization static Object concat(Object s1, Object s2, @Bind("this") Node inliningTarget, - @Cached PyObjectLookupAttr lookupNode, - @Cached CallNode callNode, - @Cached PyNumberAddNode addNode, - @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode) { - Object iaddCallable = lookupNode.execute(null, inliningTarget, s1, T___IADD__); - if (iaddCallable != PNone.NO_VALUE) { - return callNode.executeWithoutFrame(iaddCallable, s2); - } - return addNode.execute(null, inliningTarget, s1, s2); - } - - @Specialization(guards = "!checkNode.execute(inliningTarget, s1)", limit = "1") - static Object concat(Object s1, @SuppressWarnings("unused") Object s2, - @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, s1); + @Cached PySequenceInplaceConcat concat) { + return concat.execute(null, inliningTarget, s1, s2); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index fe7c0fcdff..d2c9a7b11a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -44,7 +44,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; @@ -206,7 +205,7 @@ static Object error(@SuppressWarnings("unused") Object left, Object right, } } - @Builtin(name = J___IADD__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_concat, isComplex = true) @GenerateNodeFactory abstract static class IAddNode extends PythonBinaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index c48cd23418..1ae2c8c094 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; @@ -426,7 +425,7 @@ static Object repr(PByteArray self, } } - @Builtin(name = J___IADD__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_concat, isComplex = true) @GenerateNodeFactory public abstract static class IAddNode extends PythonBinaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java index 96624251a1..4db8393b60 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java @@ -43,7 +43,6 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_aiter; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_anext; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_await; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_add; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_multiply; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_power; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number; @@ -60,7 +59,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AWAIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; @@ -98,7 +96,6 @@ public enum SlotMethodDef { // (mq) AM_SEND is an internal function and mostly called from within AWAIT, AITER, ANEXT. /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, CallFunctionWrapper::new, MethodsFlags.AM_SEND), */ - NB_INPLACE_ADD(PyNumberMethods__nb_inplace_add, T___IADD__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_ADD), NB_INPLACE_MULTIPLY(PyNumberMethods__nb_inplace_multiply, T___IMUL__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_MULTIPLY), NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER); @@ -133,7 +130,6 @@ public enum SlotMethodDef { static { initGroup( PyTypeObject__tp_as_number, - NB_INPLACE_ADD, NB_INPLACE_MULTIPLY, NB_INPLACE_POWER); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index c56444436b..c5b136e96c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -151,7 +151,6 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl writeGroupSlots(CFields.PyTypeObject__tp_as_number, slots, writePointerNode, mem, nullValue); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_add, getSlot(obj, SlotMethodDef.NB_INPLACE_ADD)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_multiply, getSlot(obj, SlotMethodDef.NB_INPLACE_MULTIPLY)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_power, getSlot(obj, SlotMethodDef.NB_INPLACE_POWER)); return mem; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java index 2715e62fde..740e3763a4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java @@ -57,7 +57,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; @@ -674,7 +673,7 @@ static int doGeneric(PDeque self) { } // deque.__iadd__(v) - @Builtin(name = J___IADD__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_concat, isComplex = true) @GenerateNodeFactory public abstract static class DequeInplaceAddNode extends PythonBinaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java index f5c7fcd4ae..dea70bcd88 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java @@ -625,7 +625,7 @@ static Object or(Object self, Object other) { @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends BinaryOpBuiltinNode { + abstract static class IOrNode extends PythonBinaryBuiltinNode { @Specialization Object or(VirtualFrame frame, Object self, Object other, @Cached DictNodes.UpdateNode updateNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index f3916c4527..604a1f8a3f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; @@ -772,7 +771,7 @@ protected static SequenceStorageNodes.ConcatNode createConcat() { } } - @Builtin(name = J___IADD__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_concat, isComplex = true) @GenerateNodeFactory abstract static class IAddNode extends PythonBinaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java index 2a2c2c902a..f4e552d8d0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java @@ -283,7 +283,7 @@ Object or(VirtualFrame frame, Object self, Object other) { @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends BinaryOpBuiltinNode { + abstract static class IOrNode extends PythonBinaryBuiltinNode { @Specialization static Object or(Object self, @SuppressWarnings("unused") Object other, @Bind("this") Node inliningTarget) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java index 4608ea7a72..ca6ad00107 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java @@ -272,7 +272,7 @@ static Object or(Object self, Object other) { @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - abstract static class IOrNode extends BinaryOpBuiltinNode { + abstract static class IOrNode extends PythonBinaryBuiltinNode { @Specialization static Object or(VirtualFrame frame, POrderedDict self, Object other, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java index 87287d8c35..fa4f679213 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java @@ -60,7 +60,6 @@ import com.oracle.graal.python.builtins.objects.dict.PDictView; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.type.TpSlots; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.lib.GetNextNode; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.nodes.ErrorMessages; @@ -185,7 +184,7 @@ public static Object add(VirtualFrame frame, PSet self, Object o, @Slot(value = SlotKind.nb_inplace_or, isComplex = true) @GenerateNodeFactory - public abstract static class IOrNode extends BinaryOpBuiltinNode { + public abstract static class IOrNode extends PythonBinaryBuiltinNode { @Specialization Object doSet(VirtualFrame frame, PSet self, PBaseSet other, @Bind("this") Node inliningTarget, @@ -373,7 +372,7 @@ static PNone doSet(VirtualFrame frame, PSet self, Object other, @Slot(value = SlotKind.nb_inplace_and, isComplex = true) @GenerateNodeFactory - public abstract static class IAndNode extends BinaryOpBuiltinNode { + public abstract static class IAndNode extends PythonBinaryBuiltinNode { @Specialization static PBaseSet doPBaseSet(VirtualFrame frame, PSet left, PBaseSet right, @@ -474,7 +473,7 @@ protected Object createResult(PSet self, HashingStorage result) { @Slot(value = SlotKind.nb_inplace_xor, isComplex = true) @GenerateNodeFactory - public abstract static class IXorNode extends BinaryOpBuiltinNode { + public abstract static class IXorNode extends PythonBinaryBuiltinNode { @Specialization static Object doSet(VirtualFrame frame, PSet self, PBaseSet other, @@ -560,7 +559,7 @@ static PNone doSetOther(VirtualFrame frame, PSet self, Object other, @Slot(value = SlotKind.nb_inplace_subtract, isComplex = true) @GenerateNodeFactory - abstract static class ISubNode extends BinaryOpBuiltinNode { + abstract static class ISubNode extends PythonBinaryBuiltinNode { @Specialization static PBaseSet doPBaseSet(VirtualFrame frame, PSet left, PBaseSet right, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index dc54a17acb..766168d131 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -60,7 +60,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INDEX__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; @@ -293,6 +292,7 @@ public record TpSlots(TpSlot nb_bool, // TpSlot sq_ass_item, // TpSlot sq_concat, // TpSlot sq_repeat, // + TpSlot sq_inplace_concat, // TpSlot mp_length, // TpSlot mp_subscript, // TpSlot mp_ass_subscript, // @@ -698,6 +698,14 @@ public enum TpSlotMeta { CFields.PySequenceMethods__sq_repeat, PExternalFunctionWrapper.SSIZE_ARG, SsizeargfuncSlotWrapper::new), + SQ_INPLACE_CONCAT( + TpSlots::sq_inplace_concat, + TpSlotPythonSingle.class, + TpSlotBinaryIOpBuiltin.class, + TpSlotGroup.AS_SEQUENCE, + CFields.PySequenceMethods__sq_inplace_concat, + PExternalFunctionWrapper.BINARYFUNC, + BinarySlotFuncWrapper::new), MP_LENGTH( TpSlots::mp_length, TpSlotPythonSingle.class, @@ -991,9 +999,10 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.NB_POWER, TpSlotDef.withoutHPy(T___POW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC), TpSlotDef.withoutHPy(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); - // addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_SUBTRACT, TpSlotDef.withSimpleFunction(T___ISUB__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - // addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + // addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, + // PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_REMAINDER, TpSlotDef.withSimpleFunction(T___IMOD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_LSHIFT, TpSlotDef.withSimpleFunction(T___ILSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_RSHIFT, TpSlotDef.withSimpleFunction(T___IRSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); @@ -1029,6 +1038,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.SQ_ASS_ITEM, TpSlotDef.withoutHPy(T___SETITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.SETITEM), TpSlotDef.withoutHPy(T___DELITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.DELITEM)); + addSlotDef(s, TpSlotMeta.SQ_INPLACE_CONCAT, TpSlotDef.withNoFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC)); SLOTDEFS = s; SPECIAL2SLOT = new HashMap<>(SLOTDEFS.size() * 2); @@ -1640,6 +1650,7 @@ public TpSlots build() { get(TpSlotMeta.SQ_ASS_ITEM), // get(TpSlotMeta.SQ_CONCAT), // get(TpSlotMeta.SQ_REPEAT), // + get(TpSlotMeta.SQ_INPLACE_CONCAT), // get(TpSlotMeta.MP_LENGTH), // get(TpSlotMeta.MP_SUBSCRIPT), // get(TpSlotMeta.MP_ASS_SUBSCRIPT), // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java index b8189ba239..fb7fbfb542 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java @@ -44,18 +44,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DIVMOD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; @@ -196,25 +184,22 @@ public static ReversibleSlot fromCallableNames(TruffleString[] names) { } public enum InplaceSlot { - NB_INPLACE_ADD(T___IADD__, ReversibleSlot.NB_ADD), - NB_INPLACE_SUBTRACT(T___ISUB__, ReversibleSlot.NB_SUBTRACT), - NB_INPLACE_MULTIPLY(T___IMUL__, ReversibleSlot.NB_MULTIPLY), - NB_INPLACE_REMAINDER(T___IMOD__, ReversibleSlot.NB_REMAINDER), - NB_INPLACE_LSHIFT(T___ILSHIFT__, ReversibleSlot.NB_LSHIFT), - NB_INPLACE_RSHIFT(T___IRSHIFT__, ReversibleSlot.NB_RSHIFT), - NB_INPLACE_AND(T___IAND__, ReversibleSlot.NB_AND), - NB_INPLACE_XOR(T___IXOR__, ReversibleSlot.NB_XOR), - NB_INPLACE_OR(T___IOR__, ReversibleSlot.NB_OR), - NB_INPLACE_FLOOR_DIVIDE(T___IFLOORDIV__, ReversibleSlot.NB_FLOOR_DIVIDE), - NB_INPLACE_TRUE_DIVIDE(T___ITRUEDIV__, ReversibleSlot.NB_TRUE_DIVIDE), - NB_INPLACE_MATRIX_MULTIPLY(T___IMATMUL__, ReversibleSlot.NB_MATRIX_MULTIPLY); - - private static final InplaceSlot[] VALUES = values(); - private final TruffleString name; + NB_INPLACE_ADD(ReversibleSlot.NB_ADD), + NB_INPLACE_SUBTRACT(ReversibleSlot.NB_SUBTRACT), + NB_INPLACE_MULTIPLY(ReversibleSlot.NB_MULTIPLY), + NB_INPLACE_REMAINDER(ReversibleSlot.NB_REMAINDER), + NB_INPLACE_LSHIFT(ReversibleSlot.NB_LSHIFT), + NB_INPLACE_RSHIFT(ReversibleSlot.NB_RSHIFT), + NB_INPLACE_AND(ReversibleSlot.NB_AND), + NB_INPLACE_XOR(ReversibleSlot.NB_XOR), + NB_INPLACE_OR(ReversibleSlot.NB_OR), + NB_INPLACE_FLOOR_DIVIDE(ReversibleSlot.NB_FLOOR_DIVIDE), + NB_INPLACE_TRUE_DIVIDE(ReversibleSlot.NB_TRUE_DIVIDE), + NB_INPLACE_MATRIX_MULTIPLY(ReversibleSlot.NB_MATRIX_MULTIPLY); + private final ReversibleSlot reversibleSlot; - InplaceSlot(TruffleString name, ReversibleSlot reversibleSlot) { - this.name = name; + InplaceSlot(ReversibleSlot reversibleSlot) { this.reversibleSlot = reversibleSlot; } @@ -236,15 +221,6 @@ public TpSlot getSlotValue(TpSlots slots) { }; } - public static InplaceSlot fromCallableNames(TruffleString[] names) { - for (InplaceSlot op : VALUES) { - if (names[0].equals(op.name)) { - return op; - } - } - return null; - } - public ReversibleSlot getReversibleSlot() { return reversibleSlot; } @@ -284,7 +260,7 @@ private PBuiltinFunction createRBuiltin(Python3Core core, Object type, TruffleSt } } - public abstract static class TpSlotBinaryIOpBuiltin extends TpSlotBinaryFuncBuiltin { + public abstract static class TpSlotBinaryIOpBuiltin extends TpSlotBinaryFuncBuiltin { protected TpSlotBinaryIOpBuiltin(NodeFactory nodeFactory, String builtinName) { super(nodeFactory, PExternalFunctionWrapper.BINARYFUNC, builtinName); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java new file mode 100644 index 0000000000..3e0798ba8e --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2025, 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.lib; + +import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; + +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; + +@GenerateInline(false) +public abstract class PyNumberInplaceAddNode extends PyNumberAddBaseNode { + + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Exclusive @Cached GetClassNode getVClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Exclusive @Cached GetClassNode getWClass, + @Cached CallBinaryIOp1Node callBinaryIOp1Node, + @Cached InlinedBranchProfile hasNbAddResult, + @Cached InlinedBranchProfile hasInplaceConcat, + @Cached InlinedBranchProfile hasConcat, + @Cached CallSlotBinaryFuncNode callBinarySlotNode, + @Cached PRaiseNode raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + Object classW = getWClass.execute(inliningTarget, w); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + Object result = callBinaryIOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, InplaceSlot.NB_INPLACE_ADD); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbAddResult.enter(inliningTarget); + return result; + } + TpSlot concatSlot; + if (slotsV.sq_inplace_concat() != null) { + hasInplaceConcat.enter(inliningTarget); + concatSlot = slotsV.sq_inplace_concat(); + } else if (slotsV.sq_concat() != null) { + hasConcat.enter(inliningTarget); + concatSlot = slotsV.sq_concat(); + } else { + return raiseNotSupported(inliningTarget, v, w, "+=", raiseNode); + } + return callBinarySlotNode.execute(frame, inliningTarget, concatSlot, v, w); + } + + @NeverDefault + public static PyNumberInplaceAddNode create() { + return PyNumberInplaceAddNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java new file mode 100644 index 0000000000..f7bde9967f --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PNodeWithContext; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; + +@GenerateInline +@GenerateCached(false) +public abstract class PySequenceInplaceConcat extends PNodeWithContext { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, + @Cached GetClassNode getVClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Cached GetClassNode getWClass, + @Cached PySequenceCheckNode pySeqCheckV, + @Cached PySequenceCheckNode pySeqCheckW, + @Cached CallBinaryIOp1Node callBinaryIOp1Node, + @Cached InlinedBranchProfile hasInplaceConcat, + @Cached InlinedBranchProfile hasConcat, + @Cached InlinedBranchProfile hasNbAddSlot, + @Cached InlinedBranchProfile hasNbAddResult, + @Cached CallSlotBinaryFuncNode callBinarySlotNode, + @Cached PRaiseNode raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlot concatSlot = null; + if (slotsV.sq_inplace_concat() != null) { + hasInplaceConcat.enter(inliningTarget); + concatSlot = slotsV.sq_inplace_concat(); + } else if (slotsV.sq_concat() != null) { + hasConcat.enter(inliningTarget); + concatSlot = slotsV.sq_concat(); + } + if (concatSlot != null) { + return callBinarySlotNode.execute(frame, inliningTarget, concatSlot, v, w); + } + if (pySeqCheckV.execute(inliningTarget, v) && pySeqCheckW.execute(inliningTarget, w)) { + Object classW = getWClass.execute(inliningTarget, w); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + hasNbAddSlot.enter(inliningTarget); + Object result = callBinaryIOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, InplaceSlot.NB_INPLACE_ADD); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbAddResult.enter(inliningTarget); + return result; + } + } + return raiseNotSupported(inliningTarget, v, raiseNode); + } + + @InliningCutoff + private static PException raiseNotSupported(Node inliningTarget, Object v, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANT_BE_CONCATENATED, v); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 767247dc68..a6c9538c47 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -112,6 +112,7 @@ import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInplaceAddNode; import com.oracle.graal.python.lib.PyNumberInplaceAndNode; import com.oracle.graal.python.lib.PyNumberInplaceFloorDivideNode; import com.oracle.graal.python.lib.PyNumberInplaceLshiftNode; @@ -461,7 +462,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod case BinaryOpsConstants.MATMUL: return PyNumberMatrixMultiplyNode.create(); case BinaryOpsConstants.INPLACE_ADD: - return InplaceArithmetic.IAdd.create(); + return PyNumberInplaceAddNode.create(); case BinaryOpsConstants.INPLACE_SUB: return PyNumberInplaceSubtractNode.create(); case BinaryOpsConstants.INPLACE_MUL: From d8d281b8e0024dcfb8ccd59a70f190f6ff88baf0 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Feb 2025 16:54:01 +0100 Subject: [PATCH 021/512] Implement sq_inplace_repeat and nb_inplace_multiply --- .../oracle/graal/python/annotations/Slot.java | 2 + .../graal/python/processor/SlotsMapping.java | 7 +- .../src/tests/cpyext/test_tp_slots.py | 252 ++++++++++++++++-- .../cext/PythonCextAbstractBuiltins.java | 27 +- .../builtins/objects/array/ArrayBuiltins.java | 11 +- .../objects/bytes/ByteArrayBuiltins.java | 29 +- .../objects/cext/capi/SlotMethodDef.java | 5 - .../objects/cext/capi/ToNativeTypeNode.java | 1 - .../objects/common/SequenceStorageNodes.java | 22 -- .../builtins/objects/deque/DequeBuiltins.java | 14 +- .../builtins/objects/list/ListBuiltins.java | 7 +- .../python/builtins/objects/type/TpSlots.java | 15 +- .../objects/type/slots/TpSlotSizeArgFun.java | 7 +- .../lib/PyNumberInplaceMultiplyNode.java | 119 +++++++++ .../python/lib/PyNumberMultiplyNode.java | 34 +-- .../python/lib/PySequenceInplaceRepeat.java | 110 ++++++++ .../python/lib/SequenceRepeatHelperNode.java | 82 ++++++ .../nodes/bytecode/PBytecodeRootNode.java | 3 +- 18 files changed, 592 insertions(+), 155 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/SequenceRepeatHelperNode.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index 8d0a2b14db..dc664b5a35 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -173,6 +173,8 @@ enum SlotKind { sq_repeat("__mul__"), /** seq += seq */ sq_inplace_concat("__iadd__"), + /** seq *= seq */ + sq_inplace_repeat("__imul__"), /** mapping length */ mp_length("__len__"), /** mapping subscript, e.g. o[key], o[i:j] */ diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index 2061b0b798..4b75ede981 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -64,7 +64,7 @@ static String getSlotBaseClass(Slot s) { case nb_power -> "TpSlotNbPower.TpSlotNbPowerBuiltin"; case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat"; case sq_length, mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix(s.isComplex()); - case sq_item, sq_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin"; + case sq_item, sq_repeat, sq_inplace_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin"; case sq_ass_item -> "TpSlotSqAssItem.TpSlotSqAssItemBuiltin"; case mp_subscript -> "TpSlotBinaryFunc.TpSlotMpSubscript"; case mp_ass_subscript -> "TpSlotMpAssSubscript.TpSlotMpAssSubscriptBuiltin"; @@ -93,7 +93,7 @@ static String getSlotNodeBaseClass(Slot s) { case sq_length, mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode"; case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode"; case sq_ass_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode"; - case sq_repeat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode"; + case sq_repeat, sq_inplace_repeat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode"; case mp_subscript -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode"; case mp_ass_subscript -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode"; case tp_getattro -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode"; @@ -168,7 +168,10 @@ public static String getExtraCtorArgs(TpSlotData slot) { case nb_inplace_floor_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IFLOORDIV__"; case nb_inplace_true_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ITRUEDIV__"; case nb_inplace_matrix_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMATMUL__"; + case sq_item -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___GETITEM__"; + case sq_repeat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MUL__"; case sq_inplace_concat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__"; + case sq_inplace_repeat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__"; default -> ""; }; } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index ba4e70da6d..534f2e2c4f 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -328,11 +328,51 @@ class SqAddManaged(SqAdd): pass assert x + 1 is x +def test_inplace_fallback(): + WithSlot = CPyExtHeapType( + "NbAdd1", + slots=[ + '{Py_nb_add, &nb_add}', + ], + code=''' + PyObject* nb_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("add1"); } + ''', + ) + WithInplaceSlot = CPyExtHeapType( + "NbInplaceAdd1", + slots=[ + '{Py_nb_add, &nb_add}', + '{Py_nb_inplace_add, &nb_inplace_add}', + ], + code=''' + PyObject* nb_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("add2"); } + PyObject* nb_inplace_add(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_add"); } + ''', + ) + x = WithSlot() + y = WithInplaceSlot() + x += y + assert x == "add1" + x = WithSlot() + y += x + assert y == "inplace_add" + x = object() + y = WithInplaceSlot() + x += y + assert x == "add2" + + def test_sq_inplace_concat_vs_nb_inplace_add(): SqInplaceConcat = CPyExtHeapType( "SqInplaceConcat", - slots=['{Py_sq_inplace_concat, &inplace_concat}'], - code='PyObject* inplace_concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_concat"); }', + slots=[ + '{Py_sq_concat, &concat}', + '{Py_sq_inplace_concat, &inplace_concat}', + ], + code=''' + PyObject* concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("concat"); } + PyObject* inplace_concat(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_concat"); } + ''', ) x = SqInplaceConcat() x += 1 @@ -409,6 +449,179 @@ class InplaceConcatSubclass(SqInplaceConcat): assert_raises(TypeError, operator.iconcat, x, 1) assert operator.iconcat(x, []) == "inplace_add" +CallRepeatHelper = CPyExtType( + "CallRepeatHelper", + code=''' + PyObject* call_repeat(PyObject* unused, PyObject* args) { + PyObject* obj; + Py_ssize_t times; + if (!PyArg_ParseTuple(args, "On", &obj, ×)) + return NULL; + return PySequence_Repeat(obj, times); + } + PyObject* call_inplace_repeat(PyObject* unused, PyObject* args) { + PyObject* obj; + Py_ssize_t times; + if (!PyArg_ParseTuple(args, "On", &obj, ×)) + return NULL; + return PySequence_InPlaceRepeat(obj, times); + } + ''', + tp_methods=''' + {"PySequence_Repeat", (PyCFunction)call_repeat, METH_VARARGS | METH_STATIC, ""}, + {"PySequence_InPlaceRepeat", (PyCFunction)call_inplace_repeat, METH_VARARGS | METH_STATIC, ""} + ''' +) + + +def test_repeat_vs_multiply(): + SqRepeat = CPyExtHeapType( + "SqRepeat", + slots=['{Py_sq_repeat, &repeat}'], + code='PyObject* repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("repeat"); }', + ) + + x = SqRepeat() + assert x * 2 == "repeat" + assert 2 * x == "repeat" + assert CallRepeatHelper.PySequence_Repeat(x, 2) == "repeat" + assert x.__mul__(2) == "repeat" + assert x.__rmul__(2) == "repeat" + assert_raises(TypeError, operator.mul, x, x) + + class SqRepeatManaged(SqRepeat): pass + + x = SqRepeatManaged() + assert x * 2 == "repeat" + assert 2 * x == "repeat" + assert CallRepeatHelper.PySequence_Repeat(x, 2) == "repeat" + assert x.__mul__(2) == "repeat" + assert x.__rmul__(2) == "repeat" + assert_raises(TypeError, operator.mul, x, x) + + SqRepeatAndNbMultiply = CPyExtHeapType( + "SqRepeatAndNbMultiply", + slots=[ + '{Py_sq_repeat, &repeat}', + '{Py_nb_multiply, &mymultiply}', + ], + code=''' + PyObject* repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("repeat"); } + PyObject* mymultiply(PyObject* a, PyObject *b) { return PyUnicode_FromString("multiply"); } + ''', + ) + + x = SqRepeatAndNbMultiply() + assert x * 2 == "multiply" + assert 2 * x == "multiply" + assert CallRepeatHelper.PySequence_Repeat(x, 2) == "repeat" + + SqRepeatAndNbMultiplyNoImplemented = CPyExtHeapType( + "SqRepeatAndNbMultiplyNoImplemented", + slots=[ + '{Py_sq_repeat, &repeat}', + '{Py_nb_multiply, &mymultiply}', + ], + code=''' + PyObject* repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("repeat"); } + PyObject* mymultiply(PyObject* a, PyObject *b) { Py_RETURN_NOTIMPLEMENTED; } + ''', + ) + x = SqRepeatAndNbMultiplyNoImplemented() + assert x * 2 == "repeat" + + +def test_sq_inplace_repeat_vs_nb_inplace_multiply(): + SqInplaceRepeat = CPyExtHeapType( + "SqInplaceRepeat", + slots=[ + '{Py_sq_repeat, &repeat}', + '{Py_sq_inplace_repeat, &inplace_repeat}' + ], + code=''' + PyObject* repeat(PyObject* a, PyObject *b) { return PyUnicode_FromString("repeat"); } + PyObject* inplace_repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("inplace_repeat"); } + ''', + ) + x = SqInplaceRepeat() + x *= 1 + assert x == "inplace_repeat" + x = SqInplaceRepeat() + assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "inplace_repeat" + + x = 1 + x *= SqInplaceRepeat() + assert x == "repeat" + + SqInplaceRepeatAndNbInplaceMultiply = CPyExtHeapType( + "SqInplaceRepeatAndNbInplaceMultiply", + slots=['{Py_sq_inplace_repeat, &inplace_repeat}', '{Py_nb_inplace_multiply, &inplace_multiply}'], + code=''' + PyObject* inplace_repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("inplace_repeat"); } + PyObject* inplace_multiply(PyObject* a, PyObject* b) { return PyUnicode_FromString("inplace_multiply"); } + ''', + ) + + x = SqInplaceRepeatAndNbInplaceMultiply() + x *= 1 + assert x == "inplace_multiply" + x = SqInplaceRepeatAndNbInplaceMultiply() + assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "inplace_repeat" + + SqInplaceRepeatAndNbInplaceMultiplyNotImplemented = CPyExtHeapType( + "SqInplaceRepeatAndNbInplaceMultiplyNotImplemented", + slots=['{Py_sq_inplace_repeat, &inplace_repeat}', '{Py_nb_inplace_multiply, &inplace_multiply}'], + code=''' + PyObject* inplace_repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("inplace_repeat"); } + PyObject* inplace_multiply(PyObject* a, PyObject *b) { Py_RETURN_NOTIMPLEMENTED; } + ''', + ) + + x = SqInplaceRepeatAndNbInplaceMultiplyNotImplemented() + x *= 1 + assert x == "inplace_repeat" + + class InplaceRepeatSubclass(SqInplaceRepeat): + pass + + x = InplaceRepeatSubclass() + assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "inplace_repeat" + + SqRepeat = CPyExtHeapType( + "SqRepeat2", + slots=['{Py_sq_repeat, &repeat}'], + code='PyObject* repeat(PyObject* a, PyObject *b) { return PyUnicode_FromString("repeat"); }', + ) + + x = SqRepeat() + x *= 1 + assert x == "repeat" + x = SqRepeat() + assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "repeat" + + NbInplaceMultiply = CPyExtHeapType( + "NbInplaceMultiply", + slots=['{Py_nb_inplace_multiply, &inplace_multiply}'], + code='PyObject* inplace_multiply(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_multiply"); }', + ) + + x = NbInplaceMultiply() + assert_raises(TypeError, CallRepeatHelper.PySequence_InPlaceRepeat, x, 1) + assert_raises(TypeError, CallRepeatHelper.PySequence_InPlaceRepeat, x, []) + + SequenceWithNbInplaceMultiply = CPyExtHeapType( + "SequenceWithNbInplaceMultiply", + slots=['{Py_nb_inplace_multiply, &inplace_multiply}', '{Py_sq_item, &item}'], + code=''' + PyObject* inplace_multiply(PyObject* a, PyObject *b) { return PyUnicode_FromString("inplace_multiply"); } + PyObject* item(PyObject* a, PyObject *b) { return PyUnicode_FromString("item"); } + ''', + ) + + x = SequenceWithNbInplaceMultiply() + assert_raises(TypeError, CallRepeatHelper.PySequence_InPlaceRepeat, x, []) + assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "inplace_multiply" + def test_incompatible_slots_assignment(): def assert_type_error(code): @@ -1152,30 +1365,27 @@ def __contains__(self, item): obj = NativeSqSlotProxy([1]) assert obj + [2] == [1, 2] - # TODO fix on graalpy - # obj += [2] - # assert obj.delegate == [1, 2] + obj += [2] + assert obj.delegate == [1, 2] obj = NativeSqSlotProxy([1]) assert obj * 2 == [1, 1] - # TODO fix on graalpy - # obj *= 2 - # assert obj.delegate == [1, 1] + obj *= 2 + assert obj.delegate == [1, 1] obj = NativeSqSlotProxy([1]) assert_raises(TypeError, operator.mul, obj, "a") assert_raises(OverflowError, operator.mul, obj, 1 << 65) - # TODO fix on graalpy - # try: - # obj *= "a" - # except TypeError: - # pass - # else: - # assert False - # try: - # obj *= 1 << 65 - # except OverflowError: - # pass - # else: - # assert False + try: + obj *= "a" + except TypeError: + pass + else: + assert False + try: + obj *= 1 << 65 + except OverflowError: + pass + else: + assert False assert get_delegate(obj) == [1] diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index b4e924537c..32e7520017 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -40,6 +40,7 @@ */ package com.oracle.graal.python.builtins.modules.cext; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiCallPath.Direct; @@ -59,7 +60,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T_KEYS; import static com.oracle.graal.python.nodes.SpecialMethodNames.T_VALUES; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.StrNode; @@ -105,7 +105,6 @@ import com.oracle.graal.python.lib.PyNumberFloatNode; import com.oracle.graal.python.lib.PyNumberIndexNode; import com.oracle.graal.python.lib.PyNumberLongNode; -import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetAttr; @@ -117,6 +116,7 @@ import com.oracle.graal.python.lib.PySequenceDelItemNode; import com.oracle.graal.python.lib.PySequenceGetItemNode; import com.oracle.graal.python.lib.PySequenceInplaceConcat; +import com.oracle.graal.python.lib.PySequenceInplaceRepeat; import com.oracle.graal.python.lib.PySequenceIterSearchNode; import com.oracle.graal.python.lib.PySequenceSetItemNode; import com.oracle.graal.python.lib.PySequenceSizeNode; @@ -535,26 +535,15 @@ static int contains(Object haystack, Object needle, @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Py_ssize_t}, call = Direct) abstract static class PySequence_InPlaceRepeat extends CApiBinaryBuiltinNode { - @Specialization(guards = {"checkNode.execute(inliningTarget, obj)"}, limit = "1") + @Specialization static Object repeat(Object obj, long n, @Bind("this") Node inliningTarget, - @Cached PyObjectLookupAttr lookupNode, - @Cached CallNode callNode, - @Cached PyNumberMultiplyNode mulNode, - @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode) { - Object imulCallable = lookupNode.execute(null, inliningTarget, obj, T___IMUL__); - if (imulCallable != PNone.NO_VALUE) { - Object ret = callNode.executeWithoutFrame(imulCallable, n); - return ret; + @Cached PRaiseNode raiseNode, + @Cached PySequenceInplaceRepeat repeat) { + if (!PInt.isIntRange(n)) { + throw raiseNode.raise(inliningTarget, OverflowError); } - return mulNode.execute(null, inliningTarget, obj, n); - } - - @Specialization(guards = "!checkNode.execute(inliningTarget, obj)", limit = "1") - static Object repeat(Object obj, @SuppressWarnings("unused") Object n, - @SuppressWarnings("unused") @Exclusive @Cached PySequenceCheckNode checkNode, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.OBJ_CANT_BE_REPEATED, obj); + return repeat.execute(null, inliningTarget, obj, (int) n); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index d2c9a7b11a..789313778e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -44,7 +44,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; @@ -258,10 +257,9 @@ static PArray doZeroSize(Object self, @SuppressWarnings("unused") int value) { } } - @Builtin(name = J___IMUL__, minNumOfPositionalArgs = 2, numOfPositionalOnlyArgs = 2, parameterNames = {"$self", "value"}) - @ArgumentClinic(name = "value", conversion = ArgumentClinic.ClinicConversion.Index) + @Slot(value = SlotKind.sq_inplace_repeat, isComplex = true) @GenerateNodeFactory - abstract static class IMulNode extends PythonBinaryClinicBuiltinNode { + abstract static class IMulNode extends SqRepeatBuiltinNode { @Specialization static Object concat(PArray self, int value, @Bind("this") Node inliningTarget, @@ -286,11 +284,6 @@ static Object concat(PArray self, int value, throw PRaiseNode.raiseStatic(inliningTarget, MemoryError); } } - - @Override - protected ArgumentClinicProvider getArgumentClinic() { - return ArrayBuiltinsClinicProviders.IMulNodeClinicProviderGen.INSTANCE; - } } @GenerateInline diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index 1ae2c8c094..d4da0d121d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; @@ -81,6 +80,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode; import com.oracle.graal.python.lib.PyByteArrayCheckNode; import com.oracle.graal.python.lib.PyIndexCheckNode; @@ -473,38 +473,19 @@ private static void updateSequenceStorage(PByteArray array, SequenceStorage s) { } } - @Builtin(name = J___IMUL__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_repeat, isComplex = true) @GenerateNodeFactory - public abstract static class IMulNode extends PythonBinaryBuiltinNode { + public abstract static class IMulNode extends SqRepeatBuiltinNode { @Specialization static Object mul(VirtualFrame frame, PByteArray self, int times, @Bind("this") Node inliningTarget, - @Cached @Shared SequenceStorageNodes.RepeatNode repeatNode, - @Exclusive @Cached PRaiseNode raiseNode) { + @Cached SequenceStorageNodes.RepeatNode repeatNode, + @Cached PRaiseNode raiseNode) { self.checkCanResize(inliningTarget, raiseNode); SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), times); self.setSequenceStorage(res); return self; } - - @Specialization - static Object mul(VirtualFrame frame, PByteArray self, Object times, - @Bind("this") Node inliningTarget, - @Cached PyNumberAsSizeNode asSizeNode, - @Cached @Shared SequenceStorageNodes.RepeatNode repeatNode, - @Exclusive @Cached PRaiseNode raiseNode) { - self.checkCanResize(inliningTarget, raiseNode); - SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), asSizeNode.executeExact(frame, inliningTarget, times)); - self.setSequenceStorage(res); - return self; - } - - @SuppressWarnings("unused") - @Fallback - static Object mul(Object self, Object other, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, other); - } } @Builtin(name = "remove", minNumOfPositionalArgs = 2) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java index 4db8393b60..53f05294b0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java @@ -43,7 +43,6 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_aiter; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_anext; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_await; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_multiply; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_power; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call; @@ -59,7 +58,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AWAIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; @@ -68,7 +66,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUFFLE_RICHCOMPARE__; -import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.BinaryFuncWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.CallFunctionWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.HashfuncWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InitWrapper; @@ -96,7 +93,6 @@ public enum SlotMethodDef { // (mq) AM_SEND is an internal function and mostly called from within AWAIT, AITER, ANEXT. /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, CallFunctionWrapper::new, MethodsFlags.AM_SEND), */ - NB_INPLACE_MULTIPLY(PyNumberMethods__nb_inplace_multiply, T___IMUL__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_MULTIPLY), NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER); public final TruffleString methodName; @@ -130,7 +126,6 @@ public enum SlotMethodDef { static { initGroup( PyTypeObject__tp_as_number, - NB_INPLACE_MULTIPLY, NB_INPLACE_POWER); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index c5b136e96c..14f79c2106 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -151,7 +151,6 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl writeGroupSlots(CFields.PyTypeObject__tp_as_number, slots, writePointerNode, mem, nullValue); - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_multiply, getSlot(obj, SlotMethodDef.NB_INPLACE_MULTIPLY)); writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_power, getSlot(obj, SlotMethodDef.NB_INPLACE_POWER)); return mem; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 8c4a246fb1..0d9f1b9597 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -2515,8 +2515,6 @@ public static ExtendNode create(GenNodeSupplier genNodeProvider) { } public abstract static class RepeatNode extends SequenceStorageBaseNode { - @Child private RepeatNode recursive; - /* * CPython is inconsistent when too repeats are done. Most types raise MemoryError, but e.g. * bytes raises OverflowError when the memory might be available but the size overflows @@ -2528,8 +2526,6 @@ protected RepeatNode(PythonBuiltinClassType errorForOverflow) { this.errorForOverflow = errorForOverflow; } - public abstract SequenceStorage execute(VirtualFrame frame, SequenceStorage left, Object times); - public abstract SequenceStorage execute(VirtualFrame frame, SequenceStorage left, int times); @Specialization @@ -2696,24 +2692,6 @@ SequenceStorage doGeneric(SequenceStorage s, int times, } } - @Specialization(guards = "!isInt(times)") - @SuppressWarnings("truffle-static-method") - SequenceStorage doNonInt(VirtualFrame frame, SequenceStorage s, Object times, - @Bind("this") Node inliningTarget, - @Cached PyIndexCheckNode indexCheckNode, - @Cached PyNumberAsSizeNode asSizeNode, - @Shared @Cached PRaiseNode raiseNode) { - if (!indexCheckNode.execute(inliningTarget, times)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, times); - } - int i = asSizeNode.executeExact(frame, inliningTarget, times); - if (recursive == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - recursive = insert(RepeatNodeGen.create(errorForOverflow)); - } - return recursive.execute(frame, s, i); - } - private static void repeat(Object dest, Object src, int len, int times) { for (int i = 0; i < times; i++) { PythonUtils.arraycopy(src, 0, dest, i * len, len); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java index 740e3763a4..51048cba13 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java @@ -57,7 +57,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; @@ -89,7 +88,6 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.IndexNodes.NormalizeIndexCustomMessageNode; -import com.oracle.graal.python.builtins.objects.deque.DequeBuiltinsClinicProviders.DequeInplaceMulNodeClinicProviderGen; import com.oracle.graal.python.builtins.objects.deque.DequeBuiltinsClinicProviders.DequeInsertNodeClinicProviderGen; import com.oracle.graal.python.builtins.objects.deque.DequeBuiltinsClinicProviders.DequeRotateNodeClinicProviderGen; import com.oracle.graal.python.builtins.objects.list.PList; @@ -741,16 +739,10 @@ static PDeque doGeneric(PDeque self, Object other, } } - // deque.__mul__(v) - @Builtin(name = J___IMUL__, minNumOfPositionalArgs = 2, parameterNames = {"$self", "n"}) + // deque.__imul__(v) + @Slot(value = SlotKind.sq_inplace_repeat, isComplex = true) @GenerateNodeFactory - @ArgumentClinic(name = "n", conversion = ClinicConversion.Index) - public abstract static class DequeInplaceMulNode extends PythonBinaryClinicBuiltinNode { - - @Override - protected ArgumentClinicProvider getArgumentClinic() { - return DequeInplaceMulNodeClinicProviderGen.INSTANCE; - } + public abstract static class DequeInplaceMulNode extends SqRepeatBuiltinNode { @Specialization PDeque doGeneric(PDeque self, int n) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index 604a1f8a3f..ced67e1c9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; @@ -819,11 +818,11 @@ static Object doPListInt(VirtualFrame frame, Object left, int right, } } - @Builtin(name = J___IMUL__, minNumOfPositionalArgs = 2) + @Slot(value = SlotKind.sq_inplace_repeat, isComplex = true) @GenerateNodeFactory - abstract static class IMulNode extends PythonBinaryBuiltinNode { + abstract static class IMulNode extends SqRepeatBuiltinNode { @Specialization - static Object doGeneric(VirtualFrame frame, Object list, Object right, + static Object doGeneric(VirtualFrame frame, Object list, int right, @Bind("this") Node inliningTarget, @Cached GetListStorageNode getStorageNode, @Cached ListNodes.UpdateListStorageNode updateStorageNode, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index 766168d131..96ea48f9f5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -60,6 +60,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INDEX__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; @@ -293,6 +294,7 @@ public record TpSlots(TpSlot nb_bool, // TpSlot sq_concat, // TpSlot sq_repeat, // TpSlot sq_inplace_concat, // + TpSlot sq_inplace_repeat, // TpSlot mp_length, // TpSlot mp_subscript, // TpSlot mp_ass_subscript, // @@ -706,6 +708,14 @@ public enum TpSlotMeta { CFields.PySequenceMethods__sq_inplace_concat, PExternalFunctionWrapper.BINARYFUNC, BinarySlotFuncWrapper::new), + SQ_INPLACE_REPEAT( + TpSlots::sq_inplace_repeat, + TpSlotPythonSingle.class, + TpSlotSizeArgFunBuiltin.class, + TpSlotGroup.AS_SEQUENCE, + CFields.PySequenceMethods__sq_inplace_repeat, + PExternalFunctionWrapper.SSIZE_ARG, + SsizeargfuncSlotWrapper::new), MP_LENGTH( TpSlots::mp_length, TpSlotPythonSingle.class, @@ -1001,8 +1011,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl TpSlotDef.withoutHPy(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_SUBTRACT, TpSlotDef.withSimpleFunction(T___ISUB__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - // addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, - // PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_REMAINDER, TpSlotDef.withSimpleFunction(T___IMOD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_LSHIFT, TpSlotDef.withSimpleFunction(T___ILSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_RSHIFT, TpSlotDef.withSimpleFunction(T___IRSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); @@ -1039,6 +1048,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl TpSlotDef.withoutHPy(T___SETITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.SETITEM), TpSlotDef.withoutHPy(T___DELITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.DELITEM)); addSlotDef(s, TpSlotMeta.SQ_INPLACE_CONCAT, TpSlotDef.withNoFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.SQ_INPLACE_REPEAT, TpSlotDef.withNoFunction(T___IMUL__, PExternalFunctionWrapper.SSIZE_ARG, HPySlotWrapper.INDEXARGFUNC)); SLOTDEFS = s; SPECIAL2SLOT = new HashMap<>(SLOTDEFS.size() * 2); @@ -1651,6 +1661,7 @@ public TpSlots build() { get(TpSlotMeta.SQ_CONCAT), // get(TpSlotMeta.SQ_REPEAT), // get(TpSlotMeta.SQ_INPLACE_CONCAT), // + get(TpSlotMeta.SQ_INPLACE_REPEAT), // get(TpSlotMeta.MP_LENGTH), // get(TpSlotMeta.MP_SUBSCRIPT), // get(TpSlotMeta.MP_ASS_SUBSCRIPT), // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java index 59685c5755..5557ec7820 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java @@ -40,7 +40,6 @@ */ package com.oracle.graal.python.builtins.objects.type.slots; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; import java.util.Objects; @@ -100,9 +99,11 @@ private TpSlotSizeArgFun() { public abstract static class TpSlotSizeArgFunBuiltin extends TpSlotBuiltin { private final int callTargetIndex = TpSlotBuiltinCallTargetRegistry.getNextCallTargetIndex(); + private final String name; - protected TpSlotSizeArgFunBuiltin(NodeFactory nodeFactory) { + protected TpSlotSizeArgFunBuiltin(NodeFactory nodeFactory, String name) { super(nodeFactory); + this.name = name; } final SizeArgFunBuiltinNode createSlotNode() { @@ -111,7 +112,7 @@ final SizeArgFunBuiltinNode createSlotNode() { @Override public void initialize(PythonLanguage language) { - RootCallTarget target = createBuiltinCallTarget(language, BuiltinSlotWrapperSignature.BINARY, getNodeFactory(), J___GETITEM__); + RootCallTarget target = createBuiltinCallTarget(language, BuiltinSlotWrapperSignature.BINARY, getNodeFactory(), name); language.setBuiltinSlotCallTarget(callTargetIndex, target); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java new file mode 100644 index 0000000000..93cf5564e8 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2025, 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.lib; + +import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; + +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; + +@GenerateInline(false) +public abstract class PyNumberInplaceMultiplyNode extends PyNumberMultiplyBaseNode { + + @Fallback + @InliningCutoff + public static Object doIt(VirtualFrame frame, Object v, Object w, + @Bind Node inliningTarget, + @Exclusive @Cached GetClassNode getVClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Exclusive @Cached GetClassNode getWClass, + @Cached CallBinaryIOp1Node callBinaryIOp1Node, + @Cached InlinedBranchProfile hasNbMultiplyResult, + @Cached InlinedBranchProfile hasInplaceRepeat, + @Cached InlinedBranchProfile hasRepeat, + @Cached InlinedBranchProfile wHasRepeat, + @Cached SequenceRepeatHelperNode sequenceRepeatNode, + @Cached PRaiseNode raiseNode) { + Object classV = getVClass.execute(inliningTarget, v); + Object classW = getWClass.execute(inliningTarget, w); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlots slotsW = getWSlots.execute(inliningTarget, classW); + Object result = callBinaryIOp1Node.execute(frame, inliningTarget, v, classV, slotsV, w, classW, slotsW, InplaceSlot.NB_INPLACE_MULTIPLY); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbMultiplyResult.enter(inliningTarget); + return result; + } + if (slotsV.has_as_sequence()) { + TpSlot repeatSlot = null; + if (slotsV.sq_inplace_repeat() != null) { + hasInplaceRepeat.enter(inliningTarget); + repeatSlot = slotsV.sq_inplace_repeat(); + } else if (slotsV.sq_repeat() != null) { + hasRepeat.enter(inliningTarget); + repeatSlot = slotsV.sq_repeat(); + } + if (repeatSlot != null) { + return sequenceRepeatNode.execute(frame, repeatSlot, v, w); + } + } else if (slotsW.has_as_sequence()) { + /* + * Note that the right hand operand should not be mutated in this case so + * sq_inplace_repeat is not used. + */ + if (slotsW.sq_repeat() != null) { + wHasRepeat.enter(inliningTarget); + return sequenceRepeatNode.execute(frame, slotsW.sq_repeat(), w, v); + } + } + return raiseNotSupported(inliningTarget, v, w, "*=", raiseNode); + } + + @NeverDefault + public static PyNumberInplaceMultiplyNode create() { + return PyNumberInplaceMultiplyNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index ee19d86660..df047a134a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -42,19 +42,13 @@ import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; -import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; @@ -132,9 +126,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, @Cached InlinedBranchProfile hasNbMulResult, @Cached InlinedBranchProfile vHasSqRepeat, @Cached InlinedBranchProfile wHasSqRepeat, - @Cached PyIndexCheckNode indexCheckNode, - @Cached PyNumberAsSizeNode asSizeNode, - @Cached CallSlotSizeArgFun callSlotNode, + @Cached SequenceRepeatHelperNode sequenceRepeatNode, @Cached PRaiseNode raiseNode) { Object classV = getVClass.execute(inliningTarget, v); Object classW = getWClass.execute(inliningTarget, w); @@ -147,34 +139,14 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, } if (slotsV.sq_repeat() != null) { vHasSqRepeat.enter(inliningTarget); - return sequenceRepeat(frame, inliningTarget, slotsV.sq_repeat(), v, w, - indexCheckNode, asSizeNode, callSlotNode, raiseNode); + return sequenceRepeatNode.execute(frame, slotsV.sq_repeat(), v, w); } else if (slotsW.sq_repeat() != null) { wHasSqRepeat.enter(inliningTarget); - return sequenceRepeat(frame, inliningTarget, slotsW.sq_repeat(), w, v, - indexCheckNode, asSizeNode, callSlotNode, raiseNode); + return sequenceRepeatNode.execute(frame, slotsW.sq_repeat(), w, v); } return raiseNotSupported(inliningTarget, v, w, "*", raiseNode); } - private static Object sequenceRepeat(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object seq, Object n, - PyIndexCheckNode indexCheckNode, - PyNumberAsSizeNode asSizeNode, - CallSlotSizeArgFun callSlotNode, - PRaiseNode raiseNode) { - if (indexCheckNode.execute(inliningTarget, n)) { - int count = asSizeNode.execute(frame, inliningTarget, n, PythonBuiltinClassType.OverflowError); - return callSlotNode.execute(frame, inliningTarget, slot, seq, count); - } else { - throw raiseNonIntSqMul(inliningTarget, n, raiseNode); - } - } - - @InliningCutoff - private static PException raiseNonIntSqMul(Node inliningTarget, Object n, PRaiseNode raiseNode) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, n); - } - @NeverDefault public static PyNumberMultiplyNode create() { return PyNumberMultiplyNodeGen.create(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java new file mode 100644 index 0000000000..154171769c --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PNodeWithContext; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; + +@GenerateInline +@GenerateCached(false) +public abstract class PySequenceInplaceRepeat extends PNodeWithContext { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object o, int count); + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object o, int count, + @Cached GetClassNode getClassNode, + @Cached GetCachedTpSlotsNode slotsNode, + @Cached PySequenceCheckNode sequenceCheckNode, + @Cached CallBinaryIOp1Node callBinaryIOp1Node, + @Cached InlinedBranchProfile hasInplaceRepeat, + @Cached InlinedBranchProfile hasRepeat, + @Cached InlinedBranchProfile isSequence, + @Cached InlinedBranchProfile hasNbMultiplyResult, + @Cached CallSlotSizeArgFun callSlot, + @Cached PRaiseNode raiseNode) { + Object classV = getClassNode.execute(inliningTarget, o); + TpSlots slotsV = slotsNode.execute(inliningTarget, classV); + TpSlot repeatSlot = null; + if (slotsV.sq_inplace_repeat() != null) { + hasInplaceRepeat.enter(inliningTarget); + repeatSlot = slotsV.sq_inplace_repeat(); + } else if (slotsV.sq_repeat() != null) { + hasRepeat.enter(inliningTarget); + repeatSlot = slotsV.sq_repeat(); + } + if (repeatSlot != null) { + return callSlot.execute(frame, inliningTarget, repeatSlot, o, count); + } + if (sequenceCheckNode.execute(inliningTarget, o)) { + isSequence.enter(inliningTarget); + PythonBuiltinClassType countType = PythonBuiltinClassType.PInt; + Object result = callBinaryIOp1Node.execute(frame, inliningTarget, o, classV, slotsV, count, countType, countType.getSlots(), InplaceSlot.NB_INPLACE_MULTIPLY); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + hasNbMultiplyResult.enter(inliningTarget); + return result; + } + } + return raiseNotSupported(inliningTarget, o, raiseNode); + } + + @InliningCutoff + private static PException raiseNotSupported(Node inliningTarget, Object v, PRaiseNode raiseNode) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANT_BE_REPEATED, v); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/SequenceRepeatHelperNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/SequenceRepeatHelperNode.java new file mode 100644 index 0000000000..07213af746 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/SequenceRepeatHelperNode.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(false) +@GenerateUncached +public abstract class SequenceRepeatHelperNode extends Node { + abstract Object execute(VirtualFrame frame, TpSlot slot, Object seq, Object n); + + @Specialization + static Object sequenceRepeat(VirtualFrame frame, TpSlot slot, Object seq, Object n, + @Bind Node inliningTarget, + @Cached PyIndexCheckNode indexCheckNode, + @Cached PyNumberAsSizeNode asSizeNode, + @Cached TpSlotSizeArgFun.CallSlotSizeArgFun callSlotNode, + @Cached PRaiseNode raiseNode) { + if (indexCheckNode.execute(inliningTarget, n)) { + int count = asSizeNode.execute(frame, inliningTarget, n, PythonBuiltinClassType.OverflowError); + return callSlotNode.execute(frame, inliningTarget, slot, seq, count); + } else { + throw raiseNonIntSqMul(inliningTarget, n, raiseNode); + } + } + + @InliningCutoff + private static PException raiseNonIntSqMul(Node inliningTarget, Object n, PRaiseNode raiseNode) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANT_MULTIPLY_SEQ_BY_NON_INT, n); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index a6c9538c47..e96afc0875 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -117,6 +117,7 @@ import com.oracle.graal.python.lib.PyNumberInplaceFloorDivideNode; import com.oracle.graal.python.lib.PyNumberInplaceLshiftNode; import com.oracle.graal.python.lib.PyNumberInplaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInplaceMultiplyNode; import com.oracle.graal.python.lib.PyNumberInplaceOrNode; import com.oracle.graal.python.lib.PyNumberInplaceRemainderNode; import com.oracle.graal.python.lib.PyNumberInplaceRshiftNode; @@ -466,7 +467,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod case BinaryOpsConstants.INPLACE_SUB: return PyNumberInplaceSubtractNode.create(); case BinaryOpsConstants.INPLACE_MUL: - return InplaceArithmetic.IMul.create(); + return PyNumberInplaceMultiplyNode.create(); case BinaryOpsConstants.INPLACE_TRUEDIV: return PyNumberInplaceTrueDivideNode.create(); case BinaryOpsConstants.INPLACE_FLOORDIV: From e700a0bf405e9b3219af8d1271a60c86f64ee984 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Feb 2025 16:54:24 +0100 Subject: [PATCH 022/512] Fix slot group inheritance --- .../python/builtins/objects/type/TpSlots.java | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index 96ea48f9f5..aeb3a22d75 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -370,18 +370,35 @@ public TpSlot create(Object[] callables, TruffleString[] names, Object klass) { } public enum TpSlotGroup { - AS_NUMBER(CFields.PyTypeObject__tp_as_number), - AS_SEQUENCE(CFields.PyTypeObject__tp_as_sequence), - AS_MAPPING(CFields.PyTypeObject__tp_as_mapping), - NO_GROUP(null); // Must be last + AS_NUMBER(TpSlots::has_as_number, CFields.PyTypeObject__tp_as_number), + AS_SEQUENCE(TpSlots::has_as_sequence, CFields.PyTypeObject__tp_as_sequence), + AS_MAPPING(TpSlots::has_as_mapping, CFields.PyTypeObject__tp_as_mapping), + NO_GROUP(null, null); // Must be last public static final TpSlotGroup[] VALID_VALUES = Arrays.copyOf(values(), values().length - 1); + private final GroupGetter getter; private final CFields cField; - TpSlotGroup(CFields cField) { + TpSlotGroup(GroupGetter getter, CFields cField) { + this.getter = getter; this.cField = cField; } + + public boolean getValue(TpSlots slots) { + assert this != NO_GROUP; + return getter.get(slots); + } + + public boolean readFromNative(PythonAbstractNativeObject pythonClass) { + Object ptr = ReadPointerNode.getUncached().readFromObj(pythonClass, cField); + return !InteropLibrary.getUncached().isNull(ptr); + } + } + + @FunctionalInterface + interface GroupGetter { + boolean get(TpSlots slot); } /** @@ -1071,6 +1088,11 @@ public static TpSlots createEmpty() { */ public static TpSlots fromNative(PythonAbstractNativeObject pythonClass, PythonContext ctx) { var builder = TpSlots.newBuilder(); + for (TpSlotGroup group : TpSlotGroup.VALID_VALUES) { + if (group.readFromNative(pythonClass)) { + builder.setExplicitGroup(group); + } + } for (TpSlotMeta def : TpSlotMeta.VALUES) { if (!def.hasNativeWrapperFactory()) { continue; @@ -1518,7 +1540,9 @@ public Builder copy() { result.set(def, def.getValue(this)); } for (TpSlotGroup group : TpSlotGroup.VALID_VALUES) { - result.setExplicitGroup(group); + if (group.getValue(this)) { + result.setExplicitGroup(group); + } } return result; } From 252198a27a7a94c973498a4c8a9161ba2afaa8d9 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Feb 2025 17:15:52 +0100 Subject: [PATCH 023/512] Disable user-site in startup test --- .../com.oracle.graal.python.test/src/tests/test_startup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py b/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py index 5e0fb21c8a..68aaf4c87f 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_startup.py @@ -84,7 +84,7 @@ def test_startup_nosite(self): @unittest.skipUnless(sys.implementation.name == 'graalpy', "GraalPy-specific test") def test_startup_full(self): - result = subprocess.check_output([sys.executable, '--log.level=FINE', '-v', '-c', 'print("Hello")'], stderr=subprocess.STDOUT, text=True) + result = subprocess.check_output([sys.executable, '--log.level=FINE', '-s', '-v', '-c', 'print("Hello")'], stderr=subprocess.STDOUT, text=True) assert 'Hello' in result imports = re.findall("import '(\S+)'", result) self.assertEqual(expected_full_startup_modules, imports) From f1b71fdec9f65825984e0519df6e8ddc1cb5dcb3 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Mon, 17 Feb 2025 14:03:42 +0100 Subject: [PATCH 024/512] Shorten test class names to avoid long filenames on windows --- .../src/tests/cpyext/test_tp_slots.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index 534f2e2c4f..edf344dedf 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -517,7 +517,7 @@ class SqRepeatManaged(SqRepeat): pass assert CallRepeatHelper.PySequence_Repeat(x, 2) == "repeat" SqRepeatAndNbMultiplyNoImplemented = CPyExtHeapType( - "SqRepeatAndNbMultiplyNoImplemented", + "RepeatAndMulNotImpl", slots=[ '{Py_sq_repeat, &repeat}', '{Py_nb_multiply, &mymultiply}', @@ -554,7 +554,7 @@ def test_sq_inplace_repeat_vs_nb_inplace_multiply(): assert x == "repeat" SqInplaceRepeatAndNbInplaceMultiply = CPyExtHeapType( - "SqInplaceRepeatAndNbInplaceMultiply", + "SqInplaceRepeatAndNbInMul", slots=['{Py_sq_inplace_repeat, &inplace_repeat}', '{Py_nb_inplace_multiply, &inplace_multiply}'], code=''' PyObject* inplace_repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("inplace_repeat"); } @@ -569,7 +569,7 @@ def test_sq_inplace_repeat_vs_nb_inplace_multiply(): assert CallRepeatHelper.PySequence_InPlaceRepeat(x, 1) == "inplace_repeat" SqInplaceRepeatAndNbInplaceMultiplyNotImplemented = CPyExtHeapType( - "SqInplaceRepeatAndNbInplaceMultiplyNotImplemented", + "InplaceRepeatAndMulNotImpl", slots=['{Py_sq_inplace_repeat, &inplace_repeat}', '{Py_nb_inplace_multiply, &inplace_multiply}'], code=''' PyObject* inplace_repeat(PyObject* a, Py_ssize_t times) { return PyUnicode_FromString("inplace_repeat"); } From ae7f983de9179373f2659b1d091421ae25d0c9d1 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Mon, 17 Feb 2025 15:50:26 +0100 Subject: [PATCH 025/512] Fix PyObject_Bytes specialization consistency Fixes #476 --- .../modules/cext/PythonCextBytesBuiltins.java | 40 +++------- .../cext/PythonCextObjectBuiltins.java | 76 +++++++++---------- .../builtins/objects/bytes/BytesNodes.java | 4 +- 3 files changed, 46 insertions(+), 74 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java index b89d3af482..7dd9b9c07f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBytesBuiltins.java @@ -53,14 +53,11 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Py_ssize_t; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyVarObject__ob_size; -import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_CONVERT_P_OBJ_TO_S; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; import java.util.Arrays; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.modules.BuiltinConstructors.BytesNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiCallPath; @@ -88,13 +85,10 @@ import com.oracle.graal.python.builtins.objects.str.StringBuiltins.ModNode; import com.oracle.graal.python.lib.PyBytesCheckNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; -import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.nodes.util.CastToByteNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; @@ -177,33 +171,17 @@ static Object fromFormat(TruffleString fmt, Object args, @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) abstract static class PyBytes_FromObject extends CApiUnaryBuiltinNode { - @Specialization - static Object fromObject(Object obj, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached BytesNode bytesNode, - @Cached PyObjectLookupAttr lookupAttrNode, - @Cached PRaiseNode raiseNode) { - if (PGuards.isPBytes(obj)) { - return obj; - } else { - Object klass = getClassNode.execute(inliningTarget, obj); - if (isSubtypeNode.execute(klass, PythonBuiltinClassType.PBytes)) { - return obj; - } else if (isAcceptedSubtype(inliningTarget, obj, klass, isSubtypeNode, lookupAttrNode)) { - return bytesNode.execute(null, PythonBuiltinClassType.PBytes, obj, PNone.NO_VALUE, PNone.NO_VALUE); - } else { - throw raiseNode.raise(inliningTarget, TypeError, CANNOT_CONVERT_P_OBJ_TO_S, obj, "bytes"); - } - } + @Specialization(guards = "isBuiltinBytes(bytes)") + static Object bytes(PBytes bytes) { + return bytes; } - private static boolean isAcceptedSubtype(Node inliningTarget, Object obj, Object klass, IsSubtypeNode isSubtypeNode, PyObjectLookupAttr lookupAttrNode) { - return isSubtypeNode.execute(klass, PythonBuiltinClassType.PList) || - isSubtypeNode.execute(klass, PythonBuiltinClassType.PTuple) || - isSubtypeNode.execute(klass, PythonBuiltinClassType.PMemoryView) || - (!isSubtypeNode.execute(klass, PythonBuiltinClassType.PString) && lookupAttrNode.execute(null, inliningTarget, obj, T___ITER__) != PNone.NO_VALUE); + @Fallback + static Object fromObject(Object obj, + @Bind("this") Node inliningTarget, + @Cached BytesNodes.BytesFromObject fromObject) { + byte[] bytes = fromObject.execute(null, obj); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), bytes); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java index d2ff8dc9e6..06f7b89603 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java @@ -41,6 +41,7 @@ package com.oracle.graal.python.builtins.modules.cext; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.NotImplementedError; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; import static com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiCallPath.Direct; import static com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiCallPath.Ignored; import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.ConstCharPtrAsTruffleString; @@ -66,7 +67,6 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.modules.BuiltinConstructors.BytesNode; 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; @@ -79,11 +79,11 @@ import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CastArgsNode; import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CastKwargsNode; -import com.oracle.graal.python.builtins.modules.cext.PythonCextBytesBuiltins.PyBytes_FromObject; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.bytes.BytesNodes; import com.oracle.graal.python.builtins.objects.bytes.BytesUtils; -import com.oracle.graal.python.builtins.objects.bytes.PBytesLike; +import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.cext.capi.CApiGuards; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ResolvePointerNode; import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper; @@ -104,7 +104,9 @@ import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins.GetAttributeNode; import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins.SetattrNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; import com.oracle.graal.python.builtins.objects.type.TypeNodes; +import com.oracle.graal.python.lib.PyBytesCheckNode; import com.oracle.graal.python.lib.PyCallableCheckNode; import com.oracle.graal.python.lib.PyLongCheckNode; import com.oracle.graal.python.lib.PyObjectAsFileDescriptor; @@ -116,7 +118,6 @@ import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.lib.PyObjectIsTrueNode; -import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PyObjectLookupAttrO; import com.oracle.graal.python.lib.PyObjectReprAsObjectNode; import com.oracle.graal.python.lib.PyObjectSetItem; @@ -127,7 +128,8 @@ import com.oracle.graal.python.nodes.StringLiterals; import com.oracle.graal.python.nodes.argument.keywords.ExpandKeywordStarargsNode; import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; +import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; +import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.util.CannotCastException; @@ -147,13 +149,15 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.interop.InteropException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; public abstract class PythonCextObjectBuiltins { @@ -503,40 +507,13 @@ static int isTrue(Object obj, } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) + @ImportStatic(SpecialMethodSlot.class) abstract static class PyObject_Bytes extends CApiUnaryBuiltinNode { - @Specialization - static Object bytes(PBytesLike bytes) { - return bytes; - } - - @Specialization(guards = {"!isBytes(bytes)", "isBytesSubtype(inliningTarget, bytes, getClassNode, isSubtypeNode)"}, limit = "1") - static Object bytes(Object bytes, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, - @SuppressWarnings("unused") @Exclusive @Cached IsSubtypeNode isSubtypeNode) { + @Specialization(guards = "isBuiltinBytes(bytes)") + static Object bytes(PBytes bytes) { return bytes; } - @Specialization(guards = {"!isBytes(obj)", "!isBytesSubtype(this, obj, getClassNode, isSubtypeNode)", "!isNoValue(obj)", "hasBytes(inliningTarget, obj, lookupAttrNode)"}, limit = "1") - static Object bytes(Object obj, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, - @SuppressWarnings("unused") @Exclusive @Cached IsSubtypeNode isSubtypeNode, - @SuppressWarnings("unused") @Exclusive @Cached PyObjectLookupAttr lookupAttrNode, - @Cached BytesNode bytesNode) { - return bytesNode.execute(null, PythonBuiltinClassType.PBytes, obj, PNone.NO_VALUE, PNone.NO_VALUE); - } - - @Specialization(guards = {"!isBytes(obj)", "!isBytesSubtype(this, obj, getClassNode, isSubtypeNode)", "!isNoValue(obj)", "!hasBytes(inliningTarget, obj, lookupAttrNode)"}, limit = "1") - static Object bytes(Object obj, - @SuppressWarnings("unused") @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, - @SuppressWarnings("unused") @Exclusive @Cached IsSubtypeNode isSubtypeNode, - @SuppressWarnings("unused") @Exclusive @Cached PyObjectLookupAttr lookupAttrNode, - @Cached PyBytes_FromObject fromObjectNode) { - return fromObjectNode.execute(obj); - } - @Specialization(guards = "isNoValue(obj)") static Object bytesNoValue(@SuppressWarnings("unused") Object obj, @Bind PythonLanguage language) { @@ -547,12 +524,27 @@ static Object bytesNoValue(@SuppressWarnings("unused") Object obj, return PFactory.createBytes(language, BytesUtils.NULL_STRING); } - protected static boolean hasBytes(Node inliningTarget, Object obj, PyObjectLookupAttr lookupAttrNode) { - return lookupAttrNode.execute(null, inliningTarget, obj, T___BYTES__) != PNone.NO_VALUE; - } - - protected static boolean isBytesSubtype(Node inliningTarget, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { - return isSubtypeNode.execute(getClassNode.execute(inliningTarget, obj), PythonBuiltinClassType.PBytes); + @Fallback + static Object doGeneric(Object obj, + @Bind("this") Node inliningTarget, + @Cached GetClassNode getClassNode, + @Cached InlinedConditionProfile hasBytes, + @Cached("create(Bytes)") LookupSpecialMethodSlotNode lookupBytes, + @Cached CallUnaryMethodNode callBytes, + @Cached PyBytesCheckNode check, + @Cached BytesNodes.BytesFromObject fromObject, + @Cached PRaiseNode raiseNode) { + Object bytesMethod = lookupBytes.execute(null, getClassNode.execute(inliningTarget, obj), obj); + if (hasBytes.profile(inliningTarget, bytesMethod != PNone.NO_VALUE)) { + Object bytes = callBytes.executeObject(null, bytesMethod, obj); + if (check.execute(inliningTarget, bytes)) { + return bytes; + } else { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, bytes); + } + } + byte[] bytes = fromObject.execute(null, obj); + return PFactory.createBytes(PythonLanguage.get(inliningTarget), bytes); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java index 21b49d787f..bfeaa560dd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java @@ -83,6 +83,7 @@ import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyOSFSPathNode; import com.oracle.graal.python.lib.PyObjectGetIter; +import com.oracle.graal.python.lib.PyUnicodeCheckNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PNodeWithContext; @@ -560,6 +561,7 @@ static byte[] doGeneric(VirtualFrame frame, Object object, @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Cached BytesNodes.IterableToByteNode iterableToByteNode, @Cached IsBuiltinObjectProfile errorProfile, + @Cached PyUnicodeCheckNode unicodeCheckNode, @Cached PRaiseNode raiseNode) { if (bufferAcquireLib.hasBuffer(object)) { // TODO PyBUF_FULL_RO @@ -570,7 +572,7 @@ static byte[] doGeneric(VirtualFrame frame, Object object, bufferLib.release(buffer, frame, indirectCallData); } } - if (!PGuards.isString(object)) { + if (!unicodeCheckNode.execute(inliningTarget, object)) { try { return iterableToByteNode.execute(frame, object); } catch (PException e) { From 75c11f3c44513153aebb8ac519cd46b0efb06561 Mon Sep 17 00:00:00 2001 From: stepan Date: Wed, 19 Feb 2025 14:27:35 +0100 Subject: [PATCH 026/512] Fix: Maven plugin incorrectly prints warning about default resources directory. Fix few typos in warning messages. --- .../src/tests/standalone/test_gradle_plugin.py | 6 +++++- .../src/tests/standalone/test_maven_plugin.py | 2 ++ .../python/maven/plugin/ManageResourcesMojo.java | 4 ++-- .../java/org/graalvm/python/GraalPyGradlePlugin.java | 10 +++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index 52d95fc704..b50be878dc 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -133,6 +133,8 @@ def check_gradle_generated_app(self, community): cmd = gradlew_cmd + ["build"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, logger=log) util.check_ouput("BUILD SUCCESS", out, logger=log) + util.check_ouput("Virtual filesystem is deployed to default resources directory", out, logger=log) + util.check_ouput("This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem", out, logger=log) self.check_filelist(target_dir, log) cmd = gradlew_cmd + ["nativeCompile"] @@ -413,7 +415,7 @@ def check_gradle_python_resources_dir_and_external_dir_error(self): gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) cmd = gradle_cmd + ["graalPyResources"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("Cannot set both 'externalDirectory' and 'resourcesDirectory' at the same time", out) + util.check_ouput("Cannot set both 'externalDirectory' and 'resourceDirectory' at the same time", out) assert return_code != 0, out @@ -478,6 +480,8 @@ def check_gradle_namespaced_vfs(self): app1_gradle_cmd = util.get_gradle_wrapper(app1_dir, self.env) out, return_code = util.run_cmd(app1_gradle_cmd + ['publishToMavenLocal'], self.env, cwd=app1_dir) + util.check_ouput("Virtual filesystem is deployed to default resources directory", out, contains=False) + util.check_ouput("This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem", out, contains=False) assert return_code == 0, out app2_gradle_cmd = util.get_gradle_wrapper(app2_dir, self.env) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index 4b2cdb5c04..5c4f9e34cb 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -115,6 +115,8 @@ def check_generated_app(self, use_default_vfs_path, use_utils_pkg=False): cmd = mvnw_cmd + ["package", "-Pnative", "-DmainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("Virtual filesystem is deployed to default resources directory", out, contains=use_default_vfs_path) + util.check_ouput("This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem.", out, contains=use_default_vfs_path) # check fileslist.txt fl_path = os.path.join(target_dir, "target", "classes", vfs_prefix, "fileslist.txt") diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index bc2b69ceae..d81b78b861 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -145,7 +145,7 @@ public void execute() throws MojoExecutionException { } if (resourceDirectory == null) { - if (externalDirectory != null) { + if (externalDirectory == null) { getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " + @@ -162,7 +162,7 @@ public void execute() throws MojoExecutionException { getLog().warn("The GraalPy plugin configuration setting was deprecated and has no effect anymore.\n" + "For execution in jvm mode, the python language home is always available.\n" + "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + - "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources documentation."); + "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); } manageVenv(); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index f0ff56f0e1..0b964a9720 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -117,11 +117,11 @@ public void apply(Project project) { if (extension.getPythonResourcesDirectory().isPresent() && extension.getExternalDirectory().isPresent()) { throw new GradleException( - "Cannot set both 'externalDirectory' and 'resourcesDirectory' at the same time. " + + "Cannot set both 'externalDirectory' and 'resourceDirectory' at the same time. " + "New property 'externalDirectory' is a replacement for deprecated 'pythonResourcesDirectory'. " + "If you want to deploy the virtual environment into physical filesystem, use 'externalDirectory'. " + "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + - "If you wish to bundle the virtual filesystem in Java resources, use 'resourcesDirectory'. " + + "If you wish to bundle the virtual filesystem in Java resources, use 'resourceDirectory'. " + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); } @@ -132,9 +132,9 @@ public void apply(Project project) { // Run the vfsFilesListTask conditionally only if 'externalDirectory' is not set if (!extension.getPythonResourcesDirectory().isPresent() && !extension.getExternalDirectory().isPresent()) { if (!extension.getResourceDirectory().isPresent()) { - proj.getLogger().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + + proj.getLogger().warn(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + - "Consider adding `resourcesDirectory = \"GRAALPY-VFS/${groupId}/${artifactId}\"` to your build.gradle script " + + "Consider adding `resourceDirectory = \"GRAALPY-VFS/${groupId}/${artifactId}\"` to your build.gradle script " + "(replace the placeholders with values specific to your project), " + "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", @@ -192,7 +192,7 @@ private TaskProvider registerResourcesTask(Project project, Confi t.getLogger().warn("The GraalPy plugin pythonHome configuration setting was deprecated and has no effect anymore.\n" + "For execution in jvm mode, the python language home is always available.\n" + "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + - "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources documentation."); + "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); } t.getPackages().set(extension.getPackages()); From 1ec809444b62db8d2de3b550aaaecd6ed2c8423b Mon Sep 17 00:00:00 2001 From: stepan Date: Wed, 19 Feb 2025 14:51:56 +0100 Subject: [PATCH 027/512] Improve the GraalPyResources docs --- .../python/embedding/GraalPyResources.java | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java index 7efc01cd3a..fa26d06389 100644 --- a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java +++ b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java @@ -198,7 +198,12 @@ private GraalPyResources() { * location *
  • /org.graalvm.python.vfs/src - is set as the python sources location
  • * - *

    + *

    + * When the virtual filesystem is located in other than the default resource directory, + * {@code org.graalvm.python.vfs}, i.e., using Maven or Gradle option {@code resourceDirectory}, + * use {@link #contextBuilder(VirtualFileSystem)} and + * {@link VirtualFileSystem.Builder#resourceDirectory(String)} when building the + * {@link VirtualFileSystem}. * * @return a new {@link Context} instance * @since 24.2.0 @@ -233,6 +238,12 @@ public static Context createContext() { * } * } * + *

    + * When the virtual filesystem is located in other than the default resource directory, + * {@code org.graalvm.python.vfs}, i.e., using Maven or Gradle option {@code resourceDirectory}, + * use {@link #contextBuilder(VirtualFileSystem)} and + * {@link VirtualFileSystem.Builder#resourceDirectory(String)} when building the + * {@link VirtualFileSystem}. * * @see PythonOptions @@ -308,13 +319,14 @@ public static Context.Builder contextBuilder(VirtualFileSystem vfs) { /** * Creates a GraalPy context preconfigured with GraalPy and polyglot Context configuration - * options for use with resources located in a real filesystem. + * options for use with resources located in an external directory in real filesystem. *

    * Following resource paths are preconfigured: *

      - *
    • ${resourcesDirectory}/venv - is set as the python virtual environment + *
    • ${externalResourcesDirectory}/venv - is set as the python virtual + * environment location
    • + *
    • ${externalResourcesDirectory}/src - is set as the python sources * location
    • - *
    • ${resourcesDirectory}/src - is set as the python sources location
    • *
    *

    *

    @@ -343,19 +355,20 @@ public static Context.Builder contextBuilder(VirtualFileSystem vfs) { * *

    * - * @param resourcesDirectory the root directory with GraalPy specific embedding resources + * @param externalResourcesDirectory the root directory with GraalPy specific embedding + * resources * @return a new {@link org.graalvm.polyglot.Context.Builder} instance * @since 24.2.0 */ - public static Context.Builder contextBuilder(Path resourcesDirectory) { + public static Context.Builder contextBuilder(Path externalResourcesDirectory) { String execPath; if (VirtualFileSystemImpl.isWindows()) { - execPath = resourcesDirectory.resolve(VirtualFileSystemImpl.VFS_VENV).resolve("Scripts").resolve("python.exe").toAbsolutePath().toString(); + execPath = externalResourcesDirectory.resolve(VirtualFileSystemImpl.VFS_VENV).resolve("Scripts").resolve("python.exe").toAbsolutePath().toString(); } else { - execPath = resourcesDirectory.resolve(VirtualFileSystemImpl.VFS_VENV).resolve("bin").resolve("python").toAbsolutePath().toString(); + execPath = externalResourcesDirectory.resolve(VirtualFileSystemImpl.VFS_VENV).resolve("bin").resolve("python").toAbsolutePath().toString(); } - String srcPath = resourcesDirectory.resolve(VirtualFileSystemImpl.VFS_SRC).toAbsolutePath().toString(); + String srcPath = externalResourcesDirectory.resolve(VirtualFileSystemImpl.VFS_SRC).toAbsolutePath().toString(); return createContextBuilder(). // allow all IO access allowIO(IOAccess.ALL). @@ -437,8 +450,9 @@ public static Path getNativeExecutablePath() { * The structure of the created resource directory will stay the same like the embedded Python * resources structure: *
      - *
    • ${resourcesDirectory}/venv - the python virtual environment location
    • - *
    • ${resourcesDirectory}/src - the python sources location
    • + *
    • ${externalResourcesDirectory}/venv - the python virtual environment + * location
    • + *
    • ${externalResourcesDirectory}/src - the python sources location
    • *
    *

    *

    @@ -456,17 +470,17 @@ public static Path getNativeExecutablePath() { *

    * * @param vfs the {@link VirtualFileSystem} from which resources are to be extracted - * @param resourcesDirectory the target directory to extract the resources to + * @param externalResourcesDirectory the target directory to extract the resources to * @throws IOException if resources isn't a directory * @see #contextBuilder(Path) * @see VirtualFileSystem.Builder#resourceLoadingClass(Class) * * @since 24.2.0 */ - public static void extractVirtualFileSystemResources(VirtualFileSystem vfs, Path resourcesDirectory) throws IOException { - if (Files.exists(resourcesDirectory) && !Files.isDirectory(resourcesDirectory)) { - throw new IOException(String.format("%s has to be a directory", resourcesDirectory.toString())); + public static void extractVirtualFileSystemResources(VirtualFileSystem vfs, Path externalResourcesDirectory) throws IOException { + if (Files.exists(externalResourcesDirectory) && !Files.isDirectory(externalResourcesDirectory)) { + throw new IOException(String.format("%s has to be a directory", externalResourcesDirectory.toString())); } - vfs.impl.extractResources(resourcesDirectory); + vfs.impl.extractResources(externalResourcesDirectory); } } From 00abb91c5ad06d11a5e2049c191bae5f380a2e0a Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 27 Jan 2025 18:18:39 +0100 Subject: [PATCH 028/512] Make dir(foreign_object) return both foreign methods and Python methods --- CHANGELOG.md | 3 ++ .../src/tests/test_interop.py | 8 +++ .../foreign/ForeignObjectBuiltins.java | 49 +++++++++++++++---- graalpython/lib-graalpython/_sre.py | 7 ++- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b01a9454..a892ba0b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ This changelog summarizes major changes between GraalVM versions of the Python language runtime. The main focus is on user-observable behavior of the engine. +## Version 25.0.0 +* `dir(foreign_object)` now returns both foreign methods and Python methods (it used to return only foreign methods). + ## Version 24.2.0 * Updated developer metadata of Maven artifacts. * Added gradle plugin for polyglot embedding of Python packages into Java. diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_interop.py b/graalpython/com.oracle.graal.python.test/src/tests/test_interop.py index 6ea5c7e6f6..7d16bed853 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_interop.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_interop.py @@ -771,6 +771,14 @@ def test_java_array(self): assert il == [1, 2, 3] # unchanged + def test_dir(self): + from java.util import ArrayList + + l = ArrayList() + self.assertIn('addAll', dir(l)) # a Java method + self.assertIn('extend', dir(l)) # a Python method + self.assertEqual(sorted(dir(l)), dir(l)) + def test_java_list(self): from java.util import ArrayList diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java index 078ffd4076..f245425f3a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java @@ -46,15 +46,21 @@ import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; +import com.oracle.graal.python.builtins.objects.list.ListBuiltins; +import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins; import com.oracle.graal.python.builtins.objects.object.ObjectNodes; +import com.oracle.graal.python.builtins.objects.set.PSet; +import com.oracle.graal.python.builtins.objects.set.SetNodes; import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeBuiltins; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; +import com.oracle.graal.python.nodes.builtins.ListNodes; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; @@ -68,7 +74,6 @@ import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; @@ -83,6 +88,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.interop.InvalidArrayIndexException; import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedTypeException; @@ -268,29 +274,54 @@ static void doDelete(Object object, Object key, @SuppressWarnings("unused") PNon } } - // TODO dir(foreign) should list both foreign object members and attributes from class @Builtin(name = J___DIR__, minNumOfPositionalArgs = 1) @GenerateNodeFactory abstract static class DirNode extends PythonUnaryBuiltinNode { @Specialization - protected Object doIt(Object object, + protected Object doIt(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "3") InteropLibrary lib, + @CachedLibrary(limit = "3") InteropLibrary arrayInterop, + @CachedLibrary(limit = "3") InteropLibrary stringInterop, + @Cached TruffleString.SwitchEncodingNode switchEncodingNode, @Cached GilNode gil, - @Cached InlinedConditionProfile profile) { + @Cached InlinedConditionProfile profile, + @Cached GetClassNode getClassNode, + @Cached TypeBuiltins.DirNode typeDirNode, + @Cached SetNodes.AddNode addNode, + @Cached(inline = false) ListBuiltins.ListSortNode sortNode, + @Cached(inline = false) ListNodes.ConstructListNode constructListNode) { + // Inspired by ObjectBuiltins.DirNode + var pythonClass = getClassNode.execute(inliningTarget, object); + PSet attributes = typeDirNode.execute(frame, pythonClass); + if (profile.profile(inliningTarget, lib.hasMembers(object))) { + final Object members; gil.release(true); try { - return lib.getMembers(object); + members = lib.getMembers(object); } catch (UnsupportedMessageException e) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new IllegalStateException("foreign object claims to have members, but does not return them"); + throw CompilerDirectives.shouldNotReachHere("foreign object claims to have members, but does not return them"); } finally { gil.acquire(); } - } else { - return PFactory.createList(PythonLanguage.get(inliningTarget)); + + try { + long size = arrayInterop.getArraySize(members); + for (int i = 0; i < size; i++) { + TruffleString memberString = stringInterop.asTruffleString(arrayInterop.readArrayElement(members, i)); + memberString = switchEncodingNode.execute(memberString, TS_ENCODING); + addNode.execute(frame, attributes, memberString); + } + } catch (UnsupportedMessageException | InvalidArrayIndexException e) { + throw CompilerDirectives.shouldNotReachHere(e); + } } + + // set to sorted list, like in PyObjectDir + PList list = constructListNode.execute(frame, attributes); + sortNode.execute(frame, list); + return list; } } diff --git a/graalpython/lib-graalpython/_sre.py b/graalpython/lib-graalpython/_sre.py index 316cb8af6f..e0f0be492d 100644 --- a/graalpython/lib-graalpython/_sre.py +++ b/graalpython/lib-graalpython/_sre.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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,6 +44,9 @@ from sys import maxsize +# This does not load _polyglot.py (as desired for faster startup), due to AbstractImportNode.importModule(), +# when the context is not initialized, only looking up builtin modules (and not running their postInitialize()). +import polyglot def _check_pos(pos): if pos > maxsize: @@ -265,7 +268,7 @@ def __init__(self, pattern, flags): self.groupindex = {} self.__indexgroup = {} else: - group_names = dir(groups) + group_names = polyglot.__keys__(groups) self.groupindex = _mappingproxy({name: getattr(groups, name) for name in group_names}) self.__indexgroup = {getattr(groups, name): name for name in group_names} From bad6a4e9ee63a1b7eb3b50ca4576b96078554745 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 12 Feb 2025 15:30:37 +0100 Subject: [PATCH 029/512] Also log imports when not using frozen modules --- .../src/com/oracle/graal/python/builtins/Python3Core.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index d785ce324b..e488973ee4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -1318,6 +1318,8 @@ private void loadFile(TruffleString s, TruffleString prefix, PythonModule mod) { LOGGER.log(Level.FINE, () -> "import '" + s + "' # "); return; } + + LOGGER.log(Level.FINE, () -> "import '" + s + "'"); Supplier getCode = () -> { Source source = getInternalSource(s, prefix); return getLanguage().parse(getContext(), source, InputType.FILE, false, 0, false, null, EnumSet.noneOf(FutureFeature.class)); From 387115599b7b272f85ba8c2342b1c165a8ea0a4b Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Wed, 12 Feb 2025 15:49:11 +0100 Subject: [PATCH 030/512] Log files being parsed when --ParserLogFiles is given * The option used to noop before this commit. --- .../src/com/oracle/graal/python/PythonLanguage.java | 5 ++++- .../graal/python/builtins/modules/BuiltinFunctions.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index 328fe43789..89417ea024 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -312,7 +312,7 @@ private static boolean mimeTypesComplete(ArrayList mimeJavaStrings) { public static final TruffleString[] T_DEFAULT_PYTHON_EXTENSIONS = new TruffleString[]{T_PY_EXTENSION, tsLiteral(".pyc")}; - private static final TruffleLogger LOGGER = TruffleLogger.getLogger(ID, PythonLanguage.class); + public static final TruffleLogger LOGGER = TruffleLogger.getLogger(ID, PythonLanguage.class); private static final LanguageReference REFERENCE = LanguageReference.create(PythonLanguage.class); @@ -671,6 +671,9 @@ public RootCallTarget parse(PythonContext context, Source source, InputType type EnumSet futureFeatures) { RaisePythonExceptionErrorCallback errorCb = new RaisePythonExceptionErrorCallback(source, PythonOptions.isPExceptionWithJavaStacktrace(this)); try { + if (context.getEnv().getOptions().get(PythonOptions.ParserLogFiles)) { + LOGGER.log(Level.FINE, () -> "parse '" + source.getName() + "'"); + } Parser parser = Compiler.createParser(source.getCharacters().toString(), errorCb, type, interactiveTerminal); ModTy mod = (ModTy) parser.parse(); assert mod != null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 116d0aac2c..b95cf26761 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -109,6 +109,7 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.List; +import java.util.logging.Level; import com.oracle.graal.python.PythonFileDetector; import com.oracle.graal.python.PythonLanguage; @@ -1079,6 +1080,9 @@ Object compile(TruffleString expression, TruffleString filename, TruffleString m if (featureVersion < 7) { compilerFlags.add(AbstractParser.Flags.ASYNC_HACKS); } + if (context.getEnv().getOptions().get(PythonOptions.ParserLogFiles)) { + PythonLanguage.LOGGER.log(Level.FINE, () -> "parse '" + source.getName() + "'"); + } Parser parser = Compiler.createParser(code.toJavaStringUncached(), errorCb, type, compilerFlags, featureVersion); ModTy mod = (ModTy) parser.parse(); errorCb.triggerDeprecationWarnings(); From cf1d996c59d1a8c65ea74e1b8f42e0e26909bdba Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 18 Feb 2025 14:08:35 +0100 Subject: [PATCH 031/512] Implement nb_inplace_power --- .../oracle/graal/python/annotations/Slot.java | 2 + .../graal/python/processor/SlotsMapping.java | 3 +- .../src/tests/cpyext/test_tp_slots.py | 7 +- .../cext/PythonCextAbstractBuiltins.java | 23 +---- .../objects/cext/capi/PyProcsWrapper.java | 53 +++++++++- .../objects/cext/capi/SlotMethodDef.java | 21 +--- .../objects/cext/capi/ToNativeTypeNode.java | 13 +-- .../python/builtins/objects/type/TpSlots.java | 13 +++ .../objects/type/slots/TpSlotNbPower.java | 37 +++++++ .../graal/python/lib/CallTernaryIOpNode.java | 85 ++++++++++++++++ .../python/lib/PyNumberInPlacePowerNode.java | 98 +++++++++++++++++++ .../nodes/bytecode/PBytecodeRootNode.java | 4 +- 12 files changed, 302 insertions(+), 57 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryIOpNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index dc664b5a35..20e7d98081 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -161,6 +161,8 @@ enum SlotKind { nb_inplace_true_divide("__itruediv__"), /** foo @= bar */ nb_inplace_matrix_multiply("__imatmul__"), + /** foo **= bar */ + nb_inplace_power("__ipow__"), /** sequence length/size */ sq_length("__len__"), /** sequence item: read element at index */ diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index 4b75ede981..7f4296fcbf 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -62,6 +62,7 @@ static String getSlotBaseClass(Slot s) { sq_inplace_concat -> "TpSlotBinaryOp.TpSlotBinaryIOpBuiltin"; case nb_power -> "TpSlotNbPower.TpSlotNbPowerBuiltin"; + case nb_inplace_power -> null; // No builtin implementations case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat"; case sq_length, mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix(s.isComplex()); case sq_item, sq_repeat, sq_inplace_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin"; @@ -83,7 +84,7 @@ static String getSlotNodeBaseClass(Slot s) { case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode"; - case nb_power -> "com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode"; + case nb_power, nb_inplace_power -> "com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode"; case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode"; case nb_inplace_add, nb_inplace_subtract, nb_inplace_multiply, nb_inplace_remainder, nb_inplace_lshift, nb_inplace_rshift, nb_inplace_and, nb_inplace_xor, nb_inplace_or, diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py index edf344dedf..294a870f26 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py @@ -1210,10 +1210,9 @@ def __rmatmul__(self, other): obj = NativeNbSlotProxy(PureSlotProxy(3)) obj %= 2 assert obj.delegate.delegate == 1 - # TODO fix on graalpy - # obj = NativeNbSlotProxy(PureSlotProxy(3)) - # obj **= 2 - # assert obj.delegate.delegate == 9 + obj = NativeNbSlotProxy(PureSlotProxy(3)) + obj **= 2 + assert obj.delegate.delegate == 9 obj = NativeNbSlotProxy(PureSlotProxy(3)) obj <<= 2 assert obj.delegate.delegate == 12 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 32e7520017..d7e831dc6b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -79,7 +79,6 @@ import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.AsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.capi.PrimitiveNativeWrapper; import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; import com.oracle.graal.python.builtins.objects.dict.DictBuiltins.ItemsNode; @@ -103,6 +102,7 @@ import com.oracle.graal.python.lib.PyIterCheckNode; import com.oracle.graal.python.lib.PyNumberCheckNode; import com.oracle.graal.python.lib.PyNumberFloatNode; +import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; import com.oracle.graal.python.lib.PyNumberIndexNode; import com.oracle.graal.python.lib.PyNumberLongNode; import com.oracle.graal.python.lib.PyNumberPowerNode; @@ -126,7 +126,6 @@ import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; import com.oracle.graal.python.nodes.builtins.ListNodes.ConstructListNode; import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.expression.InplaceArithmetic; @@ -146,7 +145,6 @@ import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; @@ -428,27 +426,16 @@ private static InplaceArithmetic getInplaceArithmetic(int op) { @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Direct) abstract static class PyNumber_InPlacePower extends CApiTernaryBuiltinNode { - @Specialization(guards = {"o1.isIntLike()", "o2.isIntLike()", "o3.isIntLike()"}) - static Object doIntLikePrimitiveWrapper(PrimitiveNativeWrapper o1, PrimitiveNativeWrapper o2, PrimitiveNativeWrapper o3, - @Shared @Cached("createIPow()") LookupAndCallInplaceNode callNode) { - return callNode.executeTernary(null, o1.getLong(), o2.getLong(), o3.getLong()); - } - - @Specialization(replaces = "doIntLikePrimitiveWrapper") + @Specialization static Object doGeneric(Object o1, Object o2, Object o3, - @Shared @Cached("createIPow()") LookupAndCallInplaceNode callNode) { - return callNode.executeTernary(null, o1, o2, o3); - } - - @NeverDefault - static LookupAndCallInplaceNode createIPow() { - return InplaceArithmetic.IPow.create(); + @Bind Node inliningTarget, + @Cached PyNumberInPlacePowerNode powerNode) { + return powerNode.execute(null, inliningTarget, o1, o2, o3); } } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Direct) abstract static class PyNumber_Power extends CApiTernaryBuiltinNode { - @Child private LookupAndCallTernaryNode callNode; @Specialization Object doGeneric(Object o1, Object o2, Object o3, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java index 5d97a74122..826b572f0f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java @@ -65,7 +65,8 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.CallSlotNbBoolNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.CallSlotMpAssSubscriptNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.CallSlotNbInPlacePowerNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.CallSlotNbPowerNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.CallManagedSlotSetAttrNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.CallSlotSqAssItemNode; @@ -827,7 +828,7 @@ static Object execute(NbPowerWrapper self, Object[] arguments, @Cached GetClassNode wGetClassNode, @Cached IsSameTypeNode isSameTypeNode, @Cached GetCachedTpSlotsNode wGetSlots, - @Cached TpSlotNbPower.CallSlotNbPowerNode callSlot, + @Cached CallSlotNbPowerNode callSlot, @Cached GilNode gil) { boolean mustRelease = gil.acquire(); CApiTiming.enter(); @@ -861,6 +862,54 @@ protected String getSignature() { } } + @ExportLibrary(InteropLibrary.class) + public static final class NbInPlacePowerWrapper extends TpSlotWrapper { + + public NbInPlacePowerWrapper(TpSlotManaged delegate) { + super(delegate); + } + + @Override + public TpSlotWrapper cloneWith(TpSlotManaged slot) { + return new NbInPlacePowerWrapper(slot); + } + + @ExportMessage + static Object execute(NbInPlacePowerWrapper self, Object[] arguments, + @Bind("$node") Node inliningTarget, + @Cached NativeToPythonNode toJavaNode, + @Cached PythonToNativeNewRefNode toNativeNode, + @Cached TransformExceptionToNativeNode transformExceptionToNativeNode, + @Cached CallSlotNbInPlacePowerNode callSlot, + @Cached GilNode gil) { + boolean mustRelease = gil.acquire(); + CApiTiming.enter(); + try { + try { + // convert args + Object v = toJavaNode.execute(arguments[0]); + Object w = toJavaNode.execute(arguments[1]); + Object z = toJavaNode.execute(arguments[2]); + Object result = callSlot.execute(null, inliningTarget, self.getSlot(), v, w, z); + return toNativeNode.execute(result); + } catch (Throwable t) { + throw checkThrowableBeforeNative(t, "NbInPlacePowerWrapper", self.getDelegate()); + } + } catch (PException e) { + transformExceptionToNativeNode.execute(inliningTarget, e); + return PythonContext.get(gil).getNativeNull(); + } finally { + CApiTiming.exit(self.timing); + gil.release(mustRelease); + } + } + + @Override + protected String getSignature() { + return "(POINTER,POINTER,POINTER):POINTER"; + } + } + @ExportLibrary(InteropLibrary.class) public static final class RichcmpFunctionWrapper extends PyProcsWrapper { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java index 53f05294b0..2b87b1cbdf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java @@ -43,8 +43,6 @@ import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_aiter; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_anext; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_await; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_power; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_hash; import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_init; @@ -59,7 +57,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; @@ -89,12 +86,10 @@ public enum SlotMethodDef { AM_AWAIT(PyAsyncMethods__am_await, T___AWAIT__, UnaryFuncLegacyWrapper::new, MethodsFlags.AM_AWAIT), AM_AITER(PyAsyncMethods__am_aiter, T___AITER__, UnaryFuncLegacyWrapper::new, MethodsFlags.AM_AITER), - AM_ANEXT(PyAsyncMethods__am_anext, T___ANEXT__, PyProcsWrapper.UnaryFuncLegacyWrapper::new, MethodsFlags.AM_ANEXT), + AM_ANEXT(PyAsyncMethods__am_anext, T___ANEXT__, PyProcsWrapper.UnaryFuncLegacyWrapper::new, MethodsFlags.AM_ANEXT); // (mq) AM_SEND is an internal function and mostly called from within AWAIT, AITER, ANEXT. /*- AM_SEND(PyAsyncMethods__am_send, ASYNC_AM_SEND, CallFunctionWrapper::new, MethodsFlags.AM_SEND), */ - NB_INPLACE_POWER(PyNumberMethods__nb_inplace_power, T___IPOW__, CallFunctionWrapper::new, MethodsFlags.NB_INPLACE_POWER); - public final TruffleString methodName; public final Function wrapperFactory; public final long methodFlag; @@ -122,18 +117,4 @@ public enum SlotMethodDef { this.wrapperFactory = wrapperFactory; this.methodFlag = methodFlag; } - - static { - initGroup( - PyTypeObject__tp_as_number, - NB_INPLACE_POWER); - } - - private static void initGroup(CFields typeField, SlotMethodDef... slots) { - for (SlotMethodDef slot : slots) { - assert slot.methodsField == null && slot.typeField != null; - slot.methodsField = slot.typeField; - slot.typeField = typeField; - } - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java index 14f79c2106..20bd1161a8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java @@ -116,10 +116,6 @@ private static boolean hasAsyncMethods(PythonManagedClass obj) { return (obj.getMethodsFlags() & MethodsFlags.ASYNC_METHODS) != 0; } - private static boolean hasSequenceMethods(PythonManagedClass obj) { - return (obj.getMethodsFlags() & MethodsFlags.SEQUENCE_METHODS) != 0; - } - private static Object allocatePyAsyncMethods(PythonManagedClass obj, Object nullValue) { Object mem = CStructAccess.AllocateNode.allocUncached(CStructs.PyAsyncMethods); CStructAccess.WritePointerNode writePointerNode = CStructAccess.WritePointerNode.getUncached(); @@ -145,13 +141,10 @@ private static Object allocatePyMappingMethods(TpSlots slots, Object nullValue) return mem; } - private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots slots, Object nullValue) { + private static Object allocatePyNumberMethods(TpSlots slots, Object nullValue) { Object mem = CStructAccess.AllocateNode.allocUncached(CStructs.PyNumberMethods); CStructAccess.WritePointerNode writePointerNode = CStructAccess.WritePointerNode.getUncached(); - writeGroupSlots(CFields.PyTypeObject__tp_as_number, slots, writePointerNode, mem, nullValue); - - writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_power, getSlot(obj, SlotMethodDef.NB_INPLACE_POWER)); return mem; } @@ -239,8 +232,8 @@ static void initializeType(PythonClassNativeWrapper obj, Object mem, boolean hea weaklistoffset = lookupNativeI64MemberInMRO(clazz, PyTypeObject__tp_weaklistoffset, SpecialAttributeNames.T___WEAKLISTOFFSET__); } Object asAsync = hasAsyncMethods(clazz) ? allocatePyAsyncMethods(clazz, nullValue) : nullValue; - Object asNumber = IsBuiltinClassExactProfile.profileClassSlowPath(clazz, PythonBuiltinClassType.PythonObject) ? nullValue : allocatePyNumberMethods(clazz, slots, nullValue); - Object asSequence = (slots.has_as_sequence() || hasSequenceMethods(clazz)) ? allocatePySequenceMethods(slots, nullValue) : nullValue; + Object asNumber = slots.has_as_number() ? allocatePyNumberMethods(slots, nullValue) : nullValue; + Object asSequence = slots.has_as_sequence() ? allocatePySequenceMethods(slots, nullValue) : nullValue; Object asMapping = slots.has_as_mapping() ? allocatePyMappingMethods(slots, nullValue) : nullValue; Object asBuffer = lookup(clazz, PyTypeObject__tp_as_buffer, HiddenAttr.AS_BUFFER); writeI64Node.write(mem, CFields.PyTypeObject__tp_weaklistoffset, weaklistoffset); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index aeb3a22d75..b5901965ba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -65,6 +65,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; @@ -127,6 +128,7 @@ import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.GetAttrWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InquiryWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.LenfuncWrapper; +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbInPlacePowerWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbPowerWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.ObjobjargWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SetattrWrapper; @@ -288,6 +290,7 @@ public record TpSlots(TpSlot nb_bool, // TpSlot nb_inplace_floor_divide, // TpSlot nb_inplace_true_divide, // TpSlot nb_inplace_matrix_multiply, // + TpSlot nb_inplace_power, // TpSlot sq_length, // TpSlot sq_item, // TpSlot sq_ass_item, // @@ -677,6 +680,14 @@ public enum TpSlotMeta { CFields.PyNumberMethods__nb_inplace_matrix_multiply, PExternalFunctionWrapper.BINARYFUNC, BinarySlotFuncWrapper::new), + NB_INPLACE_POWER( + TpSlots::nb_inplace_power, + TpSlotPythonSingle.class, + null, // No builtin implementations + TpSlotGroup.AS_NUMBER, + CFields.PyNumberMethods__nb_inplace_power, + PExternalFunctionWrapper.TERNARYFUNC, + NbInPlacePowerWrapper::new), SQ_LENGTH( TpSlots::sq_length, TpSlotPythonSingle.class, @@ -1038,6 +1049,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE, TpSlotDef.withSimpleFunction(T___IFLOORDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_TRUE_DIVIDE, TpSlotDef.withSimpleFunction(T___ITRUEDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMATMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_POWER, TpSlotDef.withSimpleFunction(T___IPOW__, PExternalFunctionWrapper.TERNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_BOOL, TpSlotDef.withSimpleFunction(T___BOOL__, PExternalFunctionWrapper.INQUIRY)); addSlotDef(s, TpSlotMeta.NB_INDEX, TpSlotDef.withSimpleFunction(T___INDEX__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INT, TpSlotDef.withSimpleFunction(T___INT__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1679,6 +1691,7 @@ public TpSlots build() { get(TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE), // get(TpSlotMeta.NB_INPLACE_TRUE_DIVIDE), // get(TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY), // + get(TpSlotMeta.NB_INPLACE_POWER), // get(TpSlotMeta.SQ_LENGTH), // get(TpSlotMeta.SQ_ITEM), // get(TpSlotMeta.SQ_ASS_ITEM), // diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java index 0272498c35..ee5344f50f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotNbPower.java @@ -41,6 +41,7 @@ package com.oracle.graal.python.builtins.objects.type.slots; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___POW__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; import com.oracle.graal.python.PythonLanguage; @@ -58,9 +59,11 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.NodeFactoryUtils.WrapperNodeFactory; +import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.BinaryPythonSlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.TernaryPythonSlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.CallReversiblePythonSlotNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.TpSlotReversiblePython; @@ -227,4 +230,38 @@ static Object callPythonAsTernary(VirtualFrame frame, TpSlotReversiblePython slo return PNotImplemented.NOT_IMPLEMENTED; } } + + @GenerateInline + @GenerateCached(false) + @GenerateUncached + public abstract static class CallSlotNbInPlacePowerNode extends Node { + private static final CApiTiming C_API_TIMING = CApiTiming.create(true, "ternaryfunc"); + + public abstract Object execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object v, Object w, Object z); + + // There are no builtin implementations + + @Specialization + static Object callPython(VirtualFrame frame, Node inliningTarget, TpSlotPythonSingle slot, Object v, Object w, @SuppressWarnings("unused") Object z, + @Cached BinaryPythonSlotDispatcherNode dispatcherNode) { + // CPython doesn't pass the third argument to __ipow__ + return dispatcherNode.execute(frame, inliningTarget, slot.getCallable(), slot.getType(), v, w); + } + + @Specialization + static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, Object v, Object w, Object z, + @Cached GetThreadStateNode getThreadStateNode, + @Cached(inline = false) PythonToNativeNode vToNative, + @Cached(inline = false) PythonToNativeNode wToNative, + @Cached(inline = false) PythonToNativeNode zToNative, + @Cached ExternalFunctionInvokeNode externalInvokeNode, + @Cached(inline = false) NativeToPythonTransferNode toPythonNode, + @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { + PythonContext ctx = PythonContext.get(inliningTarget); + PythonContext.PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); + Object result = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___IPOW__, slot.callable, + vToNative.execute(v), wToNative.execute(w), zToNative.execute(z)); + return checkResultNode.execute(state, T___IPOW__, toPythonNode.execute(result)); + } + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryIOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryIOpNode.java new file mode 100644 index 0000000000..eda627ab2d --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/CallTernaryIOpNode.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.CallSlotNbInPlacePowerNode; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline +@GenerateCached(false) +@GenerateUncached +public abstract class CallTernaryIOpNode extends Node { + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z); + + @Specialization + static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z, + @Cached GetClassNode getVClass, + @Cached GetClassNode getWClass, + @Cached GetCachedTpSlotsNode getVSlots, + @Cached GetCachedTpSlotsNode getWSlots, + @Cached CallSlotNbInPlacePowerNode callInplacePower, + @Cached CallTernaryOpNode callTernaryOpNode) { + Object classV = getVClass.execute(inliningTarget, v); + TpSlots slotsV = getVSlots.execute(inliningTarget, classV); + TpSlot slotV = slotsV.nb_inplace_power(); + if (slotV != null) { + Object result = callInplacePower.execute(frame, inliningTarget, slotV, v, w, z); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; + } + } + slotV = slotsV.nb_power(); + Object classW = getWClass.execute(inliningTarget, w); + TpSlot slotW = getWSlots.execute(inliningTarget, classW).nb_power(); + return callTernaryOpNode.execute(frame, inliningTarget, v, classV, slotV, w, classW, slotW, z); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java new file mode 100644 index 0000000000..9e9a2776bf --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025, 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.lib; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; + +@GenerateInline(inlineByDefault = true) +@GenerateUncached +public abstract class PyNumberInPlacePowerNode extends BinaryOpNode { + + public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z); + + @Override + public final Object execute(VirtualFrame frame, Object left, Object right) { + return executeCached(frame, left, right, PNone.NONE); + } + + public final Object executeCached(VirtualFrame frame, Object v, Object w, Object z) { + return execute(frame, this, v, w, z); + } + + @Specialization + static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z, + @Cached CallTernaryIOpNode callTernaryOpNode, + @Cached PRaiseNode raiseNode) { + Object result = callTernaryOpNode.execute(frame, inliningTarget, v, w, z); + if (result != PNotImplemented.NOT_IMPLEMENTED) { + return result; + } + return raiseNotSupported(inliningTarget, v, w, z, raiseNode); + } + + @InliningCutoff + private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Object z, PRaiseNode raiseNode) { + if (z == PNone.NONE) { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, "**=", v, w); + } else { + return raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, "**=", v, w, z); + } + } + + @NeverDefault + public static PyNumberInPlacePowerNode create() { + return PyNumberInPlacePowerNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index e96afc0875..4564907c50 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -112,6 +112,7 @@ import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; import com.oracle.graal.python.lib.PyNumberInplaceAddNode; import com.oracle.graal.python.lib.PyNumberInplaceAndNode; import com.oracle.graal.python.lib.PyNumberInplaceFloorDivideNode; @@ -195,7 +196,6 @@ import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; import com.oracle.graal.python.nodes.expression.BinaryOp; import com.oracle.graal.python.nodes.expression.ContainsNode; -import com.oracle.graal.python.nodes.expression.InplaceArithmetic; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.frame.DeleteGlobalNode; import com.oracle.graal.python.nodes.frame.DeleteGlobalNodeGen; @@ -485,7 +485,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod case BinaryOpsConstants.INPLACE_XOR: return PyNumberInplaceXorNode.create(); case BinaryOpsConstants.INPLACE_POW: - return InplaceArithmetic.IPow.create(); + return PyNumberInPlacePowerNode.create(); case BinaryOpsConstants.INPLACE_MATMUL: return PyNumberInplaceMatrixMultiplyNode.create(); case BinaryOpsConstants.EQ: From 3d5ec84bac68b25e85c9fbb8ba12764858242fa2 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 18 Feb 2025 15:14:04 +0100 Subject: [PATCH 032/512] Remove use of NaryArithmetic enums from C API --- .../src/abstract.c | 268 +++++------ .../builtins/modules/BuiltinFunctions.java | 2 +- .../modules/OperatorModuleBuiltins.java | 8 +- .../cext/PythonCextAbstractBuiltins.java | 436 ++++++++++++------ .../objects/cext/capi/CApiFunction.java | 27 -- .../cext/hpy/GraalHPyArithmeticNode.java | 2 +- .../foreign/ForeignNumberBuiltins.java | 2 +- .../objects/object/ObjectBuiltins.java | 5 +- ...dNode.java => PyNumberInPlaceAddNode.java} | 6 +- ...dNode.java => PyNumberInPlaceAndNode.java} | 6 +- ...va => PyNumberInPlaceFloorDivideNode.java} | 6 +- ...de.java => PyNumberInPlaceLshiftNode.java} | 6 +- ...=> PyNumberInPlaceMatrixMultiplyNode.java} | 6 +- ....java => PyNumberInPlaceMultiplyNode.java} | 6 +- ...OrNode.java => PyNumberInPlaceOrNode.java} | 6 +- ...java => PyNumberInPlaceRemainderNode.java} | 6 +- ...de.java => PyNumberInPlaceRshiftNode.java} | 6 +- ....java => PyNumberInPlaceSubtractNode.java} | 6 +- ...ava => PyNumberInPlaceTrueDivideNode.java} | 6 +- ...rNode.java => PyNumberInPlaceXorNode.java} | 6 +- .../graal/python/lib/PyObjectIsTrueNode.java | 8 +- ...eConcat.java => PySequenceConcatNode.java} | 2 +- ....java => PySequenceInPlaceConcatNode.java} | 2 +- ....java => PySequenceInPlaceRepeatNode.java} | 2 +- .../bytecode/NotNode.java} | 18 +- .../nodes/bytecode/PBytecodeRootNode.java | 53 ++- .../nodes/expression/UnaryArithmetic.java | 9 +- .../python/nodes/expression/UnaryOpNode.java | 2 +- 28 files changed, 490 insertions(+), 428 deletions(-) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceAddNode.java => PyNumberInPlaceAddNode.java} (96%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceAndNode.java => PyNumberInPlaceAndNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceFloorDivideNode.java => PyNumberInPlaceFloorDivideNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceLshiftNode.java => PyNumberInPlaceLshiftNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceMatrixMultiplyNode.java => PyNumberInPlaceMatrixMultiplyNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceMultiplyNode.java => PyNumberInPlaceMultiplyNode.java} (96%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceOrNode.java => PyNumberInPlaceOrNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceRemainderNode.java => PyNumberInPlaceRemainderNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceRshiftNode.java => PyNumberInPlaceRshiftNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceSubtractNode.java => PyNumberInPlaceSubtractNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceTrueDivideNode.java => PyNumberInPlaceTrueDivideNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PyNumberInplaceXorNode.java => PyNumberInPlaceXorNode.java} (94%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PySequenceConcat.java => PySequenceConcatNode.java} (99%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PySequenceInplaceConcat.java => PySequenceInPlaceConcatNode.java} (98%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/{PySequenceInplaceRepeat.java => PySequenceInPlaceRepeatNode.java} (98%) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/{lib/PyObjectIsNotTrueNode.java => nodes/bytecode/NotNode.java} (91%) diff --git a/graalpython/com.oracle.graal.python.cext/src/abstract.c b/graalpython/com.oracle.graal.python.cext/src/abstract.c index de966ccf55..2437c8433f 100644 --- a/graalpython/com.oracle.graal.python.cext/src/abstract.c +++ b/graalpython/com.oracle.graal.python.cext/src/abstract.c @@ -22,37 +22,6 @@ #include // offsetof() -// GraalPy-specific -typedef enum e_binop { - ADD=0, SUB, MUL, TRUEDIV, LSHIFT, RSHIFT, OR, AND, XOR, FLOORDIV, MOD, - INPLACE_OFFSET, MATRIX_MUL -} BinOp; - -// GraalPy-specific -typedef enum e_unaryop { - POS=0, NEG, INVERT -} UnaryOp; - -// GraalPy-specific -static PyObject * -do_unaryop(PyObject *v, UnaryOp unaryop) -{ - return GraalPyTruffleNumber_UnaryOp(v, (int) unaryop); -} - -// GraalPy-specific -MUST_INLINE static PyObject * -do_binop(PyObject *v, PyObject *w, BinOp binop) -{ - return GraalPyTruffleNumber_BinOp(v, w, (int) binop); -} - -// GraalPy-specific -MUST_INLINE static PyObject * -do_inplace_binop(PyObject *v, PyObject *w, BinOp binop) -{ - return GraalPyTruffleNumber_InPlaceBinOp(v, w, (int) binop); -} /* Shorthands to return certain errors */ @@ -1117,16 +1086,26 @@ BINARY_FUNC(PyNumber_Lshift, nb_lshift, "<<") BINARY_FUNC(PyNumber_Rshift, nb_rshift, ">>") BINARY_FUNC(PyNumber_Subtract, nb_subtract, "-") BINARY_FUNC(PyNumber_Divmod, nb_divmod, "divmod()") -#endif // GraalPy change PyObject * PyNumber_Add(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, ADD); + PyObject *result = BINARY_OP1(v, w, NB_SLOT(nb_add), "+"); + if (result != Py_NotImplemented) { + return result; + } + Py_DECREF(result); + + PySequenceMethods *m = Py_TYPE(v)->tp_as_sequence; + if (m && m->sq_concat) { + result = (*m->sq_concat)(v, w); + assert(_Py_CheckSlotResult(v, "+", result != NULL)); + return result; + } + + return binop_type_error(v, w, "+"); } -#if 0 // GraalPy change static PyObject * sequence_repeat(ssizeargfunc repeatfunc, PyObject *seq, PyObject *n) { @@ -1145,44 +1124,50 @@ sequence_repeat(ssizeargfunc repeatfunc, PyObject *seq, PyObject *n) assert(_Py_CheckSlotResult(seq, "*", res != NULL)); return res; } -#endif // GraalPy change PyObject * PyNumber_Multiply(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, MUL); + PyObject *result = BINARY_OP1(v, w, NB_SLOT(nb_multiply), "*"); + if (result == Py_NotImplemented) { + PySequenceMethods *mv = Py_TYPE(v)->tp_as_sequence; + PySequenceMethods *mw = Py_TYPE(w)->tp_as_sequence; + Py_DECREF(result); + if (mv && mv->sq_repeat) { + return sequence_repeat(mv->sq_repeat, v, w); + } + else if (mw && mw->sq_repeat) { + return sequence_repeat(mw->sq_repeat, w, v); + } + result = binop_type_error(v, w, "*"); + } + return result; } PyObject * PyNumber_MatrixMultiply(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, MATRIX_MUL); + return binary_op(v, w, NB_SLOT(nb_matrix_multiply), "@"); } PyObject * PyNumber_FloorDivide(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, FLOORDIV); + return binary_op(v, w, NB_SLOT(nb_floor_divide), "//"); } PyObject * PyNumber_TrueDivide(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, TRUEDIV); + return binary_op(v, w, NB_SLOT(nb_true_divide), "/"); } PyObject * PyNumber_Remainder(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_binop(v, w, MOD); + return binary_op(v, w, NB_SLOT(nb_remainder), "%"); } -#if 0 // GraalPy change PyObject * PyNumber_Power(PyObject *v, PyObject *w, PyObject *z) { @@ -1289,23 +1274,59 @@ INPLACE_BINOP(PyNumber_InPlaceMatrixMultiply, nb_inplace_matrix_multiply, nb_mat INPLACE_BINOP(PyNumber_InPlaceFloorDivide, nb_inplace_floor_divide, nb_floor_divide, "//=") INPLACE_BINOP(PyNumber_InPlaceTrueDivide, nb_inplace_true_divide, nb_true_divide, "/=") INPLACE_BINOP(PyNumber_InPlaceRemainder, nb_inplace_remainder, nb_remainder, "%=") -#endif // GraalPy change PyObject * PyNumber_InPlaceAdd(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_inplace_binop(v, w, ADD); + PyObject *result = BINARY_IOP1(v, w, NB_SLOT(nb_inplace_add), + NB_SLOT(nb_add), "+="); + if (result == Py_NotImplemented) { + PySequenceMethods *m = Py_TYPE(v)->tp_as_sequence; + Py_DECREF(result); + if (m != NULL) { + binaryfunc func = m->sq_inplace_concat; + if (func == NULL) + func = m->sq_concat; + if (func != NULL) { + result = func(v, w); + assert(_Py_CheckSlotResult(v, "+=", result != NULL)); + return result; + } + } + result = binop_type_error(v, w, "+="); + } + return result; } PyObject * PyNumber_InPlaceMultiply(PyObject *v, PyObject *w) { - // GraalPy change: different implementation - return do_inplace_binop(v, w, MUL); + PyObject *result = BINARY_IOP1(v, w, NB_SLOT(nb_inplace_multiply), + NB_SLOT(nb_multiply), "*="); + if (result == Py_NotImplemented) { + ssizeargfunc f = NULL; + PySequenceMethods *mv = Py_TYPE(v)->tp_as_sequence; + PySequenceMethods *mw = Py_TYPE(w)->tp_as_sequence; + Py_DECREF(result); + if (mv != NULL) { + f = mv->sq_inplace_repeat; + if (f == NULL) + f = mv->sq_repeat; + if (f != NULL) + return sequence_repeat(f, v, w); + } + else if (mw != NULL) { + /* Note that the right hand operand should not be + * mutated in this case so sq_inplace_repeat is not + * used. */ + if (mw->sq_repeat) + return sequence_repeat(mw->sq_repeat, w, v); + } + result = binop_type_error(v, w, "*="); + } + return result; } -# if 0 // GraalPy change PyObject * PyNumber_InPlacePower(PyObject *v, PyObject *w, PyObject *z) { @@ -1318,7 +1339,6 @@ _PyNumber_InPlacePowerNoMod(PyObject *lhs, PyObject *rhs) { return PyNumber_InPlacePower(lhs, rhs, Py_None); } -#endif // GraalPy change /* Unary operators and functions */ @@ -1326,25 +1346,54 @@ _PyNumber_InPlacePowerNoMod(PyObject *lhs, PyObject *rhs) PyObject * PyNumber_Negative(PyObject *o) { - // GraalPy change: different implementation - return do_unaryop(o, NEG); + if (o == NULL) { + return null_error(); + } + + PyNumberMethods *m = Py_TYPE(o)->tp_as_number; + if (m && m->nb_negative) { + PyObject *res = (*m->nb_negative)(o); + assert(_Py_CheckSlotResult(o, "__neg__", res != NULL)); + return res; + } + + return type_error("bad operand type for unary -: '%.200s'", o); } PyObject * PyNumber_Positive(PyObject *o) { - // GraalPy change: different implementation - return do_unaryop(o, POS); + if (o == NULL) { + return null_error(); + } + + PyNumberMethods *m = Py_TYPE(o)->tp_as_number; + if (m && m->nb_positive) { + PyObject *res = (*m->nb_positive)(o); + assert(_Py_CheckSlotResult(o, "__pos__", res != NULL)); + return res; + } + + return type_error("bad operand type for unary +: '%.200s'", o); } PyObject * PyNumber_Invert(PyObject *o) { - // GraalPy change: different implementation - return do_unaryop(o, INVERT); + if (o == NULL) { + return null_error(); + } + + PyNumberMethods *m = Py_TYPE(o)->tp_as_number; + if (m && m->nb_invert) { + PyObject *res = (*m->nb_invert)(o); + assert(_Py_CheckSlotResult(o, "__invert__", res != NULL)); + return res; + } + + return type_error("bad operand type for unary ~: '%.200s'", o); } -# if 0 // GraalPy change PyObject * PyNumber_Absolute(PyObject *o) { @@ -2964,103 +3013,6 @@ _Py_FreeCharPArray(char *const array[]) } #endif // GraalPy change -// GraalPy note: The following functions are declared in CPython via macros, so we declare them separate here -PyObject * -PyNumber_Subtract(PyObject *v, PyObject *w) -{ - return do_binop(v, w, SUB); -} - -PyObject * -PyNumber_Lshift(PyObject *v, PyObject *w) -{ - return do_binop(v, w, LSHIFT); -} - -PyObject * -PyNumber_Rshift(PyObject *v, PyObject *w) -{ - return do_binop(v, w, RSHIFT); -} - -PyObject * -PyNumber_Or(PyObject *v, PyObject *w) -{ - return do_binop(v, w, OR); -} - -PyObject * -PyNumber_And(PyObject *v, PyObject *w) -{ - return do_binop(v, w, AND); -} - -PyObject * -PyNumber_Xor(PyObject *v, PyObject *w) -{ - return do_binop(v, w, XOR); -} - -PyObject * -PyNumber_InPlaceSubtract(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, SUB); -} - -PyObject * -PyNumber_InPlaceMatrixMultiply(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, MATRIX_MUL); -} - -PyObject * -PyNumber_InPlaceFloorDivide(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, FLOORDIV); -} - -PyObject * -PyNumber_InPlaceTrueDivide(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, TRUEDIV); -} - -PyObject* -PyNumber_InPlaceRemainder(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, MOD); -} - -PyObject* -PyNumber_InPlaceLshift(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, LSHIFT); -} - -PyObject* -PyNumber_InPlaceRshift(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, RSHIFT); -} - -PyObject* -PyNumber_InPlaceAnd(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, AND); -} - -PyObject* -PyNumber_InPlaceXor(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, XOR); -} - -PyObject* -PyNumber_InPlaceOr(PyObject *v, PyObject *w) -{ - return do_inplace_binop(v, w, OR); -} - // GraalPy additions PyObject ** PyTruffleSequence_Fast_ITEMS(PyObject *o) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index b95cf26761..252a9e6740 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -333,7 +333,7 @@ public abstract static class AbsNode extends PythonUnaryBuiltinNode { @Specialization static Object absObject(VirtualFrame frame, Object object, @Cached PyNumberAbsoluteNode absoluteNode) { - return absoluteNode.executeCached(frame, object); + return absoluteNode.execute(frame, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java index cb467297d7..15921a5507 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java @@ -54,8 +54,8 @@ import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectIsTrueNode; -import com.oracle.graal.python.lib.PySequenceConcat; -import com.oracle.graal.python.lib.PySequenceInplaceConcat; +import com.oracle.graal.python.lib.PySequenceConcatNode; +import com.oracle.graal.python.lib.PySequenceInPlaceConcatNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -114,7 +114,7 @@ abstract static class ConcatNode extends PythonBinaryBuiltinNode { @Specialization static Object doObject(VirtualFrame frame, Object left, Object right, @Bind("this") Node inliningTarget, - @Cached PySequenceConcat concatNode) { + @Cached PySequenceConcatNode concatNode) { return concatNode.execute(frame, inliningTarget, left, right); } } @@ -125,7 +125,7 @@ abstract static class IConcatNode extends PythonBinaryBuiltinNode { @Specialization static Object doObject(VirtualFrame frame, Object left, Object right, @Bind("this") Node inliningTarget, - @Cached PySequenceInplaceConcat concatNode) { + @Cached PySequenceInPlaceConcatNode concatNode) { return concatNode.execute(frame, inliningTarget, left, right); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index d7e831dc6b..56e6b7ef98 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -100,23 +100,50 @@ import com.oracle.graal.python.lib.GetNextNode; import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.lib.PyIterCheckNode; +import com.oracle.graal.python.lib.PyNumberAddNode; +import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberCheckNode; import com.oracle.graal.python.lib.PyNumberFloatNode; +import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAndNode; +import com.oracle.graal.python.lib.PyNumberInPlaceFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceLshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceOrNode; import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRemainderNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceSubtractNode; +import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; import com.oracle.graal.python.lib.PyNumberIndexNode; +import com.oracle.graal.python.lib.PyNumberInvertNode; import com.oracle.graal.python.lib.PyNumberLongNode; +import com.oracle.graal.python.lib.PyNumberLshiftNode; +import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberMultiplyNode; +import com.oracle.graal.python.lib.PyNumberNegativeNode; +import com.oracle.graal.python.lib.PyNumberOrNode; +import com.oracle.graal.python.lib.PyNumberPositiveNode; import com.oracle.graal.python.lib.PyNumberPowerNode; +import com.oracle.graal.python.lib.PyNumberRemainderNode; +import com.oracle.graal.python.lib.PyNumberRshiftNode; +import com.oracle.graal.python.lib.PyNumberSubtractNode; +import com.oracle.graal.python.lib.PyNumberTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberXorNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PySequenceCheckNode; -import com.oracle.graal.python.lib.PySequenceConcat; +import com.oracle.graal.python.lib.PySequenceConcatNode; import com.oracle.graal.python.lib.PySequenceContainsNode; import com.oracle.graal.python.lib.PySequenceDelItemNode; import com.oracle.graal.python.lib.PySequenceGetItemNode; -import com.oracle.graal.python.lib.PySequenceInplaceConcat; -import com.oracle.graal.python.lib.PySequenceInplaceRepeat; +import com.oracle.graal.python.lib.PySequenceInPlaceConcatNode; +import com.oracle.graal.python.lib.PySequenceInPlaceRepeatNode; import com.oracle.graal.python.lib.PySequenceIterSearchNode; import com.oracle.graal.python.lib.PySequenceSetItemNode; import com.oracle.graal.python.lib.PySequenceSizeNode; @@ -126,12 +153,6 @@ import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; import com.oracle.graal.python.nodes.builtins.ListNodes.ConstructListNode; import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.expression.InplaceArithmetic; -import com.oracle.graal.python.nodes.expression.LookupAndCallInplaceNode; -import com.oracle.graal.python.nodes.expression.UnaryArithmetic; -import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.truffle.PythonTypes; @@ -288,139 +309,276 @@ static Object doGeneric(Object object, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Int}, call = Ignored) - abstract static class PyTruffleNumber_UnaryOp extends CApiBinaryBuiltinNode { - static int MAX_CACHE_SIZE = UnaryArithmetic.values().length; - - @Specialization(guards = {"cachedOp == op"}, limit = "MAX_CACHE_SIZE") - static Object doIntLikePrimitiveWrapper(Object left, @SuppressWarnings("unused") int op, - @Cached("op") @SuppressWarnings("unused") int cachedOp, - @Cached("createCallNode(op)") UnaryOpNode callNode) { - return callNode.executeCached(null, left); - } - - /** - * This needs to stay in sync with {@code abstract.c: enum e_unaryop}. - */ - static UnaryOpNode createCallNode(int op) { - UnaryArithmetic unaryArithmetic; - switch (op) { - case 0: - unaryArithmetic = UnaryArithmetic.Pos; - break; - case 1: - unaryArithmetic = UnaryArithmetic.Neg; - break; - case 2: - unaryArithmetic = UnaryArithmetic.Invert; - break; - default: - throw CompilerDirectives.shouldNotReachHere("invalid unary operator"); - } - return unaryArithmetic.create(); - } - } - - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, Int}, call = Ignored) - abstract static class PyTruffleNumber_BinOp extends CApiTernaryBuiltinNode { - static int MAX_CACHE_SIZE = BinaryArithmetic.values().length; - - @Specialization(guards = {"cachedOp == op"}, limit = "MAX_CACHE_SIZE") - static Object doIntLikePrimitiveWrapper(Object left, Object right, @SuppressWarnings("unused") int op, - @Cached("op") @SuppressWarnings("unused") int cachedOp, - @Cached("createCallNode(op)") BinaryOpNode callNode) { - return callNode.execute(null, left, right); - } - - /** - * This needs to stay in sync with {@code abstract.c: enum e_binop}. - */ - static BinaryOpNode createCallNode(int op) { - return getBinaryArithmetic(op).create(); - } - - private static BinaryArithmetic getBinaryArithmetic(int op) { - switch (op) { - case 0: - return BinaryArithmetic.Add; - case 1: - return BinaryArithmetic.Sub; - case 2: - return BinaryArithmetic.Mul; - case 3: - return BinaryArithmetic.TrueDiv; - case 4: - return BinaryArithmetic.LShift; - case 5: - return BinaryArithmetic.RShift; - case 6: - return BinaryArithmetic.Or; - case 7: - return BinaryArithmetic.And; - case 8: - return BinaryArithmetic.Xor; - case 9: - return BinaryArithmetic.FloorDiv; - case 10: - return BinaryArithmetic.Mod; - case 12: - return BinaryArithmetic.MatMul; - default: - throw CompilerDirectives.shouldNotReachHere("invalid binary operator"); - } + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) + abstract static class PyNumber_Positive extends CApiUnaryBuiltinNode { + + @Specialization + static Object doGeneric(Object obj, + @Cached PyNumberPositiveNode positiveNode) { + return positiveNode.execute(null, obj); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) + abstract static class PyNumber_Negative extends CApiUnaryBuiltinNode { + + @Specialization + static Object doGeneric(Object obj, + @Cached PyNumberNegativeNode negativeNode) { + return negativeNode.execute(null, obj); } + } + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) + abstract static class PyNumber_Invert extends CApiUnaryBuiltinNode { + + @Specialization + static Object doGeneric(Object obj, + @Cached PyNumberInvertNode invertNode) { + return invertNode.execute(null, obj); + } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, Int}, call = Ignored) - abstract static class PyTruffleNumber_InPlaceBinOp extends CApiTernaryBuiltinNode { - static int MAX_CACHE_SIZE = InplaceArithmetic.values().length; - - @Specialization(guards = {"cachedOp == op"}, limit = "MAX_CACHE_SIZE") - static Object doIntLikePrimitiveWrapper(Object left, Object right, @SuppressWarnings("unused") int op, - @Cached("op") @SuppressWarnings("unused") int cachedOp, - @Cached("createCallNode(op)") LookupAndCallInplaceNode callNode) { - return callNode.execute(null, left, right); - } - - /** - * This needs to stay in sync with {@code abstract.c: enum e_binop}. - */ - static LookupAndCallInplaceNode createCallNode(int op) { - return getInplaceArithmetic(op).create(); - } - - private static InplaceArithmetic getInplaceArithmetic(int op) { - switch (op) { - case 0: - return InplaceArithmetic.IAdd; - case 1: - return InplaceArithmetic.ISub; - case 2: - return InplaceArithmetic.IMul; - case 3: - return InplaceArithmetic.ITrueDiv; - case 4: - return InplaceArithmetic.ILShift; - case 5: - return InplaceArithmetic.IRShift; - case 6: - return InplaceArithmetic.IOr; - case 7: - return InplaceArithmetic.IAnd; - case 8: - return InplaceArithmetic.IXor; - case 9: - return InplaceArithmetic.IFloorDiv; - case 10: - return InplaceArithmetic.IMod; - case 12: - return InplaceArithmetic.IMatMul; - default: - throw CompilerDirectives.shouldNotReachHere("invalid binary operator"); - } + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Add extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Bind Node inliningTarget, + @Cached PyNumberAddNode addNode) { + return addNode.execute(null, inliningTarget, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Subtract extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberSubtractNode subtractNode) { + return subtractNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Multiply extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Bind Node inliningTarget, + @Cached PyNumberMultiplyNode multiplyNode) { + return multiplyNode.execute(null, inliningTarget, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Remainder extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberRemainderNode remainderNode) { + return remainderNode.execute(null, o1, o2); } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_TrueDivide extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberTrueDivideNode trueDivideNode) { + return trueDivideNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_FloorDivide extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberFloorDivideNode floorDivideNode) { + return floorDivideNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_And extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberAndNode andNode) { + return andNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Or extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberOrNode orNode) { + return orNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Xor extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberXorNode xorNode) { + return xorNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Lshift extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberLshiftNode lshiftNode) { + return lshiftNode.execute(null, o1, o2); + } + } + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_Rshift extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberRshiftNode rshiftNode) { + return rshiftNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_MatrixMultiply extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberMatrixMultiplyNode matrixMultiplyNode) { + return matrixMultiplyNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceAdd extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceAddNode addNode) { + return addNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceSubtract extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceSubtractNode subtractNode) { + return subtractNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceMultiply extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceMultiplyNode multiplyNode) { + return multiplyNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceRemainder extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceRemainderNode remainderNode) { + return remainderNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceTrueDivide extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceTrueDivideNode trueDivideNode) { + return trueDivideNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceFloorDivide extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceFloorDivideNode floorDivideNode) { + return floorDivideNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceAnd extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceAndNode andNode) { + return andNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceOr extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceOrNode orNode) { + return orNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceXor extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceXorNode xorNode) { + return xorNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceLshift extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceLshiftNode lshiftNode) { + return lshiftNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceRshift extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceRshiftNode rshiftNode) { + return rshiftNode.execute(null, o1, o2); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) + abstract static class PyNumber_InPlaceMatrixMultiply extends CApiBinaryBuiltinNode { + + @Specialization + static Object doGeneric(Object o1, Object o2, + @Cached PyNumberInPlaceMatrixMultiplyNode matrixMultiplyNode) { + return matrixMultiplyNode.execute(null, o1, o2); + } } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Direct) @@ -526,7 +684,7 @@ abstract static class PySequence_InPlaceRepeat extends CApiBinaryBuiltinNode { static Object repeat(Object obj, long n, @Bind("this") Node inliningTarget, @Cached PRaiseNode raiseNode, - @Cached PySequenceInplaceRepeat repeat) { + @Cached PySequenceInPlaceRepeatNode repeat) { if (!PInt.isIntRange(n)) { throw raiseNode.raise(inliningTarget, OverflowError); } @@ -539,7 +697,7 @@ abstract static class PySequence_Concat extends CApiBinaryBuiltinNode { @Specialization Object doIt(Object s1, Object s2, @Bind("this") Node inliningTarget, - @Cached PySequenceConcat pySeqConcat) { + @Cached PySequenceConcatNode pySeqConcat) { return pySeqConcat.execute(null, inliningTarget, s1, s2); } } @@ -550,7 +708,7 @@ abstract static class PySequence_InPlaceConcat extends CApiBinaryBuiltinNode { @Specialization static Object concat(Object s1, Object s2, @Bind("this") Node inliningTarget, - @Cached PySequenceInplaceConcat concat) { + @Cached PySequenceInPlaceConcatNode concat) { return concat.execute(null, inliningTarget, s1, s2); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java index d1a5ba18f0..0e07fa832d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java @@ -349,34 +349,7 @@ public final class CApiFunction { @CApiBuiltin(name = "PyModule_GetDict", ret = PyObject, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyModule_GetName", ret = ConstCharPtrAsTruffleString, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyModule_GetState", ret = Pointer, args = {PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Add", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_And", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) @CApiBuiltin(name = "PyNumber_AsSsize_t", ret = Py_ssize_t, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_FloorDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceAdd", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceAnd", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceFloorDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceLshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceMatrixMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceOr", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceRemainder", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceRshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceSubtract", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceTrueDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_InPlaceXor", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Invert", ret = PyObject, args = {PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Lshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_MatrixMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Multiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Negative", ret = PyObject, args = {PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Or", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Positive", ret = PyObject, args = {PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Remainder", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Rshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Subtract", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_TrueDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) - @CApiBuiltin(name = "PyNumber_Xor", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) @CApiBuiltin(name = "PyOS_double_to_string", ret = CHAR_PTR, args = {Double, CHAR, Int, Int, INT_LIST}, call = CImpl) @CApiBuiltin(name = "PyOS_mystricmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = CImpl) @CApiBuiltin(name = "PyOS_mystrnicmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Py_ssize_t}, call = CImpl) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java index 35dd7429b0..765d516527 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java @@ -83,7 +83,7 @@ private HPyUnaryArithmeticCached(UnaryArithmetic operator) { @Override public Object execute(Object object) { - return opNode.executeCached(null, object); + return opNode.execute(null, object); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index b53ff2dc93..88f2b2a367 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -269,7 +269,7 @@ Object doGeneric(VirtualFrame frame, Object value, @Cached UnboxNode unboxNode) { Object unboxed = unboxNode.execute(inliningTarget, value); if (unboxed != null) { - return op.executeCached(frame, unboxed); + return op.execute(frame, unboxed); } else { return PNotImplemented.NOT_IMPLEMENTED; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java index c834e651c7..0b21e0e991 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java @@ -104,7 +104,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; -import com.oracle.graal.python.lib.PyObjectIsNotTrueNode; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PyObjectSizeNode; @@ -318,12 +317,12 @@ public abstract static class NeNode extends PythonBinaryBuiltinNode { @Specialization static Object doGeneric(VirtualFrame frame, Object self, Object other, @Cached(parameters = "Eq") LookupAndCallBinaryNode eqNode, - @Cached PyObjectIsNotTrueNode ifFalseNode) { + @Cached PyObjectIsTrueNode isTrueNode) { Object result = eqNode.executeObject(frame, self, other); if (result == PNotImplemented.NOT_IMPLEMENTED) { return result; } - return ifFalseNode.execute(frame, result); + return !isTrueNode.execute(frame, result); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java similarity index 96% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java index 3e0798ba8e..aa7c6a8613 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java @@ -62,7 +62,7 @@ import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateInline(false) -public abstract class PyNumberInplaceAddNode extends PyNumberAddBaseNode { +public abstract class PyNumberInPlaceAddNode extends PyNumberAddBaseNode { @Fallback @InliningCutoff @@ -101,7 +101,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceAddNode create() { - return PyNumberInplaceAddNodeGen.create(); + public static PyNumberInPlaceAddNode create() { + return PyNumberInPlaceAddNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java index 85992c10f8..3819e8dd73 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java @@ -53,7 +53,7 @@ @GenerateInline(false) @GenerateUncached -public abstract class PyNumberInplaceAndNode extends PyNumberAndBaseNode { +public abstract class PyNumberInPlaceAndNode extends PyNumberAndBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -63,7 +63,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceAndNode create() { - return PyNumberInplaceAndNodeGen.create(); + public static PyNumberInPlaceAndNode create() { + return PyNumberInPlaceAndNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java index 079c4c3796..6ae4492358 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceFloorDivideNode extends PyNumberFloorDivideBaseNode { +public abstract class PyNumberInPlaceFloorDivideNode extends PyNumberFloorDivideBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceFloorDivideNode create() { - return PyNumberInplaceFloorDivideNodeGen.create(); + public static PyNumberInPlaceFloorDivideNode create() { + return PyNumberInPlaceFloorDivideNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java index 38bd68ff5c..a8d32b4d1b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceLshiftNode extends PyNumberLshiftBaseNode { +public abstract class PyNumberInPlaceLshiftNode extends PyNumberLshiftBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceLshiftNode create() { - return PyNumberInplaceLshiftNodeGen.create(); + public static PyNumberInPlaceLshiftNode create() { + return PyNumberInPlaceLshiftNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java index 8851785e01..890fc52a71 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java @@ -53,7 +53,7 @@ @GenerateInline(false) @GenerateUncached -public abstract class PyNumberInplaceMatrixMultiplyNode extends BinaryOpNode { +public abstract class PyNumberInPlaceMatrixMultiplyNode extends BinaryOpNode { @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, @@ -62,7 +62,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceMatrixMultiplyNode create() { - return PyNumberInplaceMatrixMultiplyNodeGen.create(); + public static PyNumberInPlaceMatrixMultiplyNode create() { + return PyNumberInPlaceMatrixMultiplyNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java similarity index 96% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java index 93cf5564e8..c246a01add 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java @@ -61,7 +61,7 @@ import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateInline(false) -public abstract class PyNumberInplaceMultiplyNode extends PyNumberMultiplyBaseNode { +public abstract class PyNumberInPlaceMultiplyNode extends PyNumberMultiplyBaseNode { @Fallback @InliningCutoff @@ -113,7 +113,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceMultiplyNode create() { - return PyNumberInplaceMultiplyNodeGen.create(); + public static PyNumberInPlaceMultiplyNode create() { + return PyNumberInPlaceMultiplyNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java index bf5d14e578..b1c046876a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java @@ -53,7 +53,7 @@ @GenerateInline(false) @GenerateUncached -public abstract class PyNumberInplaceOrNode extends PyNumberOrBaseNode { +public abstract class PyNumberInPlaceOrNode extends PyNumberOrBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -63,7 +63,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceOrNode create() { - return PyNumberInplaceOrNodeGen.create(); + public static PyNumberInPlaceOrNode create() { + return PyNumberInPlaceOrNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java index c8cb9a6cdc..4b7263eb99 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceRemainderNode extends PyNumberRemainderBaseNode { +public abstract class PyNumberInPlaceRemainderNode extends PyNumberRemainderBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceRemainderNode create() { - return PyNumberInplaceRemainderNodeGen.create(); + public static PyNumberInPlaceRemainderNode create() { + return PyNumberInPlaceRemainderNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java index 3ae084345e..a7c44535aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceRshiftNode extends PyNumberRshiftBaseNode { +public abstract class PyNumberInPlaceRshiftNode extends PyNumberRshiftBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceRshiftNode create() { - return PyNumberInplaceRshiftNodeGen.create(); + public static PyNumberInPlaceRshiftNode create() { + return PyNumberInPlaceRshiftNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java index 61be233988..0909180b46 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceSubtractNode extends PyNumberSubtractBaseNode { +public abstract class PyNumberInPlaceSubtractNode extends PyNumberSubtractBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceSubtractNode create() { - return PyNumberInplaceSubtractNodeGen.create(); + public static PyNumberInPlaceSubtractNode create() { + return PyNumberInPlaceSubtractNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java index b038bc42d0..6e09431bc4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java @@ -51,7 +51,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInplaceTrueDivideNode extends PyNumberTrueDivideBaseNode { +public abstract class PyNumberInPlaceTrueDivideNode extends PyNumberTrueDivideBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -61,7 +61,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceTrueDivideNode create() { - return PyNumberInplaceTrueDivideNodeGen.create(); + public static PyNumberInPlaceTrueDivideNode create() { + return PyNumberInPlaceTrueDivideNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java similarity index 94% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java index 0f5654ff61..4449af193d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInplaceXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java @@ -53,7 +53,7 @@ @GenerateInline(false) @GenerateUncached -public abstract class PyNumberInplaceXorNode extends PyNumberXorBaseNode { +public abstract class PyNumberInPlaceXorNode extends PyNumberXorBaseNode { @Fallback @InliningCutoff public static Object doIt(VirtualFrame frame, Object v, Object w, @@ -63,7 +63,7 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, } @NeverDefault - public static PyNumberInplaceXorNode create() { - return PyNumberInplaceXorNodeGen.create(); + public static PyNumberInPlaceXorNode create() { + return PyNumberInPlaceXorNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java index 97e9460cdf..8d05d54b82 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java @@ -52,7 +52,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.CallSlotNbBoolNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -77,14 +76,9 @@ @GenerateUncached @GenerateInline(false) @GenerateCached -public abstract class PyObjectIsTrueNode extends UnaryOpNode { +public abstract class PyObjectIsTrueNode extends PNodeWithContext { public abstract boolean execute(Frame frame, Object object); - @Override - public final Object executeCached(VirtualFrame frame, Object value) { - return execute(frame, value); - } - public static boolean executeUncached(Object object) { return getUncached().execute(null, object); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java similarity index 99% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java index 9b77279aa3..26699f9e77 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java @@ -77,7 +77,7 @@ @GenerateInline @GenerateCached(false) -public abstract class PySequenceConcat extends PNodeWithContext { +public abstract class PySequenceConcatNode extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); @NeverDefault diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceConcatNode.java similarity index 98% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceConcatNode.java index f7bde9967f..e1b4970142 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceConcat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceConcatNode.java @@ -63,7 +63,7 @@ @GenerateInline @GenerateCached(false) -public abstract class PySequenceInplaceConcat extends PNodeWithContext { +public abstract class PySequenceInPlaceConcatNode extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceRepeatNode.java similarity index 98% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceRepeatNode.java index 154171769c..e33fe8544a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInplaceRepeat.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceInPlaceRepeatNode.java @@ -63,7 +63,7 @@ @GenerateInline @GenerateCached(false) -public abstract class PySequenceInplaceRepeat extends PNodeWithContext { +public abstract class PySequenceInPlaceRepeatNode extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object o, int count); @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java similarity index 91% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java index 4784aa8526..0da78402b5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java @@ -38,7 +38,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.oracle.graal.python.lib; +package com.oracle.graal.python.nodes.bytecode; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; @@ -46,6 +46,7 @@ import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.set.PBaseSet; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectIsTrueNode.PyObjectIsTrueNodeGeneric; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -55,7 +56,6 @@ import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -63,16 +63,10 @@ /** * Equivalent of a negation of CPython's {@code PyObject_IsTrue}. This class exists only so that we * can have quickening fast-paths for this operation. The fast-paths should be synchronized with - * {@link PyObjectIsNotTrueNode}. + * {@link PyObjectIsTrueNode}. */ @GenerateInline(false) -public abstract class PyObjectIsNotTrueNode extends UnaryOpNode { - public abstract boolean execute(Frame frame, Object object); - - @Override - public final Object executeCached(VirtualFrame frame, Object value) { - return execute(frame, value); - } +public abstract class NotNode extends UnaryOpNode { @Specialization public static boolean doBoolean(boolean object) { @@ -138,7 +132,7 @@ public static boolean doOthers(VirtualFrame frame, Object object, } @NeverDefault - public static PyObjectIsNotTrueNode create() { - return PyObjectIsNotTrueNodeGen.create(); + public static NotNode create() { + return NotNodeGen.create(); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 4564907c50..d1fda4b40f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -112,19 +112,19 @@ import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAndNode; +import com.oracle.graal.python.lib.PyNumberInPlaceFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceLshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceOrNode; import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; -import com.oracle.graal.python.lib.PyNumberInplaceAddNode; -import com.oracle.graal.python.lib.PyNumberInplaceAndNode; -import com.oracle.graal.python.lib.PyNumberInplaceFloorDivideNode; -import com.oracle.graal.python.lib.PyNumberInplaceLshiftNode; -import com.oracle.graal.python.lib.PyNumberInplaceMatrixMultiplyNode; -import com.oracle.graal.python.lib.PyNumberInplaceMultiplyNode; -import com.oracle.graal.python.lib.PyNumberInplaceOrNode; -import com.oracle.graal.python.lib.PyNumberInplaceRemainderNode; -import com.oracle.graal.python.lib.PyNumberInplaceRshiftNode; -import com.oracle.graal.python.lib.PyNumberInplaceSubtractNode; -import com.oracle.graal.python.lib.PyNumberInplaceTrueDivideNode; -import com.oracle.graal.python.lib.PyNumberInplaceXorNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRemainderNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceSubtractNode; +import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; import com.oracle.graal.python.lib.PyNumberInvertNode; import com.oracle.graal.python.lib.PyNumberLshiftNode; import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; @@ -150,7 +150,6 @@ import com.oracle.graal.python.lib.PyObjectGetIterNodeGen; import com.oracle.graal.python.lib.PyObjectGetMethod; import com.oracle.graal.python.lib.PyObjectGetMethodNodeGen; -import com.oracle.graal.python.lib.PyObjectIsNotTrueNode; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectIsTrueNodeGen; import com.oracle.graal.python.lib.PyObjectReprAsObjectNode; @@ -422,7 +421,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod private static final IntNodeFunction UNARY_OP_FACTORY = (int op) -> { switch (op) { case UnaryOpsConstants.NOT: - return PyObjectIsNotTrueNode.create(); + return NotNode.create(); case UnaryOpsConstants.POSITIVE: return PyNumberPositiveNode.create(); case UnaryOpsConstants.NEGATIVE: @@ -463,31 +462,31 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod case BinaryOpsConstants.MATMUL: return PyNumberMatrixMultiplyNode.create(); case BinaryOpsConstants.INPLACE_ADD: - return PyNumberInplaceAddNode.create(); + return PyNumberInPlaceAddNode.create(); case BinaryOpsConstants.INPLACE_SUB: - return PyNumberInplaceSubtractNode.create(); + return PyNumberInPlaceSubtractNode.create(); case BinaryOpsConstants.INPLACE_MUL: - return PyNumberInplaceMultiplyNode.create(); + return PyNumberInPlaceMultiplyNode.create(); case BinaryOpsConstants.INPLACE_TRUEDIV: - return PyNumberInplaceTrueDivideNode.create(); + return PyNumberInPlaceTrueDivideNode.create(); case BinaryOpsConstants.INPLACE_FLOORDIV: - return PyNumberInplaceFloorDivideNode.create(); + return PyNumberInPlaceFloorDivideNode.create(); case BinaryOpsConstants.INPLACE_MOD: - return PyNumberInplaceRemainderNode.create(); + return PyNumberInPlaceRemainderNode.create(); case BinaryOpsConstants.INPLACE_LSHIFT: - return PyNumberInplaceLshiftNode.create(); + return PyNumberInPlaceLshiftNode.create(); case BinaryOpsConstants.INPLACE_RSHIFT: - return PyNumberInplaceRshiftNode.create(); + return PyNumberInPlaceRshiftNode.create(); case BinaryOpsConstants.INPLACE_AND: - return PyNumberInplaceAndNode.create(); + return PyNumberInPlaceAndNode.create(); case BinaryOpsConstants.INPLACE_OR: - return PyNumberInplaceOrNode.create(); + return PyNumberInPlaceOrNode.create(); case BinaryOpsConstants.INPLACE_XOR: - return PyNumberInplaceXorNode.create(); + return PyNumberInPlaceXorNode.create(); case BinaryOpsConstants.INPLACE_POW: return PyNumberInPlacePowerNode.create(); case BinaryOpsConstants.INPLACE_MATMUL: - return PyNumberInplaceMatrixMultiplyNode.create(); + return PyNumberInPlaceMatrixMultiplyNode.create(); case BinaryOpsConstants.EQ: return BinaryComparisonNode.EqNode.create(); case BinaryOpsConstants.NE: @@ -4091,7 +4090,7 @@ private void bytecodeUnaryOpOO(VirtualFrame virtualFrame, int stackTop, int bci, generalizeInputs(bci); value = virtualFrame.getValue(stackTop); } - Object result = opNode.executeCached(virtualFrame, value); + Object result = opNode.execute(virtualFrame, value); virtualFrame.setObject(stackTop, result); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java index e3836dc3fd..a60c3167d3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java @@ -62,7 +62,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -111,7 +110,7 @@ protected Object doCall(VirtualFrame frame) { CompilerDirectives.transferToInterpreterAndInvalidate(); callUnaryNode = insert(unaryOperator.create()); } - return callUnaryNode.executeCached(frame, PArguments.getArgument(frame, 0)); + return callUnaryNode.execute(frame, PArguments.getArgument(frame, 0)); } } @@ -158,12 +157,6 @@ protected GenericUnaryArithmeticNode(TruffleString specialMethodName) { this.specialMethodName = specialMethodName; } - public final Object execute(VirtualFrame frame, Node inliningTarget, Object value) { - return execute(frame, value); - } - - protected abstract Object execute(VirtualFrame frame, Object value); - @Specialization public static Object doGeneric(VirtualFrame frame, Object arg, @Cached("createCallNode()") LookupAndCallUnaryNode callNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryOpNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryOpNode.java index 15e1bdd0ed..23d41297ca 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryOpNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryOpNode.java @@ -29,5 +29,5 @@ import com.oracle.truffle.api.frame.VirtualFrame; public abstract class UnaryOpNode extends PNodeWithContext { - public abstract Object executeCached(VirtualFrame frame, Object value); + public abstract Object execute(VirtualFrame frame, Object value); } From fc369f3de050f0521793e5d11bb862c9f4c04b7c Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 18 Feb 2025 18:09:01 +0100 Subject: [PATCH 033/512] Add uncached node to PyNumberAddNode --- .../objects/common/SequenceStorageNodes.java | 83 +++++++++++++++-- .../builtins/objects/ints/IntBuiltins.java | 44 ++++----- .../builtins/objects/list/ListBuiltins.java | 9 +- .../builtins/objects/tuple/TupleBuiltins.java | 13 +-- .../graal/python/lib/PyNumberAddNode.java | 90 ++++++++++++++----- .../python/lib/PySequenceConcatNode.java | 19 ++-- 6 files changed, 178 insertions(+), 80 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 0d9f1b9597..1a2c29b059 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -2185,6 +2185,7 @@ static boolean isByteSequenceStorage(SequenceStorage s) { } @SuppressWarnings("truffle-inlining") // footprint reduction 68 -> 49 + @GenerateUncached public abstract static class ConcatBaseNode extends SequenceStorageBaseNode { public abstract SequenceStorage execute(SequenceStorage dest, SequenceStorage left, SequenceStorage right); @@ -2400,18 +2401,37 @@ public static ConcatNode createWithOverflowError() { } @NeverDefault - public static ConcatNode create(TruffleString msg) { - return create(() -> NoGeneralizationCustomMessageNode.create(msg), MemoryError); + private static ConcatNode create(Supplier genNodeProvider, PythonBuiltinClassType errorForOverflow) { + return ConcatNodeGen.create(genNodeProvider, errorForOverflow); } + } - @NeverDefault - public static ConcatNode create(Supplier genNodeProvider) { - return create(genNodeProvider, MemoryError); - } + @GenerateInline + @GenerateCached(false) + @GenerateUncached + public abstract static class ConcatListOrTupleNode extends Node { - @NeverDefault - private static ConcatNode create(Supplier genNodeProvider, PythonBuiltinClassType errorForOverflow) { - return ConcatNodeGen.create(genNodeProvider, errorForOverflow); + public abstract SequenceStorage execute(Node inliningTarget, SequenceStorage left, SequenceStorage right); + + @Specialization + static SequenceStorage concat(Node inliningTarget, SequenceStorage left, SequenceStorage right, + @Cached CreateEmpty2Node create, + @Cached(inline = false) ConcatBaseNode concat, + @Cached PRaiseNode raiseNode) { + try { + int len1 = left.length(); + int len2 = right.length(); + int destlen = PythonUtils.addExact(len1, len2); + SequenceStorage empty = create.execute(inliningTarget, left, right, destlen); + empty.setNewLength(destlen); + try { + return concat.execute(empty, left, right); + } catch (SequenceStoreException e) { + throw CompilerDirectives.shouldNotReachHere(); + } + } catch (OutOfMemoryError | OverflowException e) { + throw raiseNode.raise(inliningTarget, MemoryError); + } } } @@ -3099,6 +3119,23 @@ static ArrayBasedSequenceStorage doIt(Node inliningTarget, SequenceStorage s, in @GenerateInline @GenerateCached(false) + @GenerateUncached + public abstract static class CreateEmpty2Node extends SequenceStorageBaseNode { + + public abstract ArrayBasedSequenceStorage execute(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap); + + @Specialization + static ArrayBasedSequenceStorage doIt(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap, + @Cached GetElementType getElementType1, + @Cached GetElementType getElementType2, + @Cached CreateEmptyForTypesNode create) { + return create.execute(inliningTarget, getElementType1.execute(inliningTarget, s1), getElementType2.execute(inliningTarget, s2), cap); + } + } + + @GenerateInline + @GenerateCached(false) + @GenerateUncached abstract static class CreateEmptyForTypeNode extends SequenceStorageBaseNode { public abstract ArrayBasedSequenceStorage execute(Node inliningTarget, StorageType type, int cap); @@ -3134,6 +3171,34 @@ static ObjectSequenceStorage doObject(@SuppressWarnings("unused") StorageType ty } } + @GenerateInline + @GenerateCached(false) + @GenerateUncached + abstract static class CreateEmptyForTypesNode extends SequenceStorageBaseNode { + + public abstract ArrayBasedSequenceStorage execute(Node inliningTarget, StorageType type1, StorageType type2, int cap); + + @Specialization(guards = "type1 == type2") + static ArrayBasedSequenceStorage doSame(Node inliningTarget, StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap, + @Cached CreateEmptyForTypeNode create) { + return create.execute(inliningTarget, type1, cap); + } + + @Specialization(guards = "generalizeToLong(type1, type2)") + static LongSequenceStorage doLong(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { + return new LongSequenceStorage(cap); + } + + @Fallback + static ObjectSequenceStorage doObject(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { + return new ObjectSequenceStorage(cap); + } + + protected static boolean generalizeToLong(StorageType type1, StorageType type2) { + return isInt(type1) && isLong(type2) || isLong(type1) && isInt(type2); + } + } + @GenerateUncached @GenerateInline @GenerateCached(false) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index fc97c6d276..cac36977a7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -364,62 +364,62 @@ public abstract static class AddNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @Specialization(rewriteOn = ArithmeticException.class) - static int add(int left, int right) { + static int doII(int left, int right) { return Math.addExact(left, right); } - @Specialization(rewriteOn = ArithmeticException.class) - static long addLong(long left, long right) { + @Specialization(replaces = "doII", rewriteOn = ArithmeticException.class) + static long doLL(long left, long right) { return Math.addExact(left, right); } - @Specialization - static Object addLongWithOverflow(long x, long y, + @Specialization(replaces = "doLL") + static Object doLLOvf(long x, long y, @Bind PythonLanguage language) { /* Inlined version of Math.addExact(x, y) with BigInteger fallback. */ long r = x + y; // HD 2-12 Overflow iff both arguments have the opposite sign of the result if (((x ^ r) & (y ^ r)) < 0) { - return PFactory.createInt(language, op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + return PFactory.createInt(language, add(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); } return r; } @Specialization(rewriteOn = OverflowException.class) - static Object addPIntLongAndNarrow(PInt left, long right) throws OverflowException { - return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); + static Object doPLNarrow(PInt left, long right) throws OverflowException { + return PInt.longValueExact(add(left.getValue(), PInt.longToBigInteger(right))); } - @Specialization(replaces = "addPIntLongAndNarrow") - static Object addPIntLong(PInt left, long right, + @Specialization(replaces = "doPLNarrow") + static Object doPL(PInt left, long right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, add(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) - static Object addLongPIntAndNarrow(long left, PInt right) throws OverflowException { - return PInt.longValueExact(op(PInt.longToBigInteger(left), right.getValue())); + static Object doLPNarrow(long left, PInt right) throws OverflowException { + return PInt.longValueExact(add(PInt.longToBigInteger(left), right.getValue())); } - @Specialization(replaces = "addLongPIntAndNarrow") - static Object addLongPInt(long left, PInt right, + @Specialization(replaces = "doLPNarrow") + static Object doLP(long left, PInt right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); + return PFactory.createInt(language, add(PInt.longToBigInteger(left), right.getValue())); } @Specialization(rewriteOn = OverflowException.class) - static Object addPIntPIntAndNarrow(PInt left, PInt right) throws OverflowException { - return PInt.longValueExact(op(left.getValue(), right.getValue())); + static Object doPPNarrow(PInt left, PInt right) throws OverflowException { + return PInt.longValueExact(add(left.getValue(), right.getValue())); } - @Specialization(replaces = "addPIntPIntAndNarrow") - static Object addPIntPInt(PInt left, PInt right, + @Specialization(replaces = "doPPNarrow") + static Object doPP(PInt left, PInt right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(left.getValue(), right.getValue())); + return PFactory.createInt(language, add(left.getValue(), right.getValue())); } @TruffleBoundary - static BigInteger op(BigInteger left, BigInteger right) { + public static BigInteger add(BigInteger left, BigInteger right) { return left.add(right); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index ced67e1c9c..a29702df43 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -749,7 +749,7 @@ static PList doPList(Object left, Object right, @Cached PyListCheckNode isListNode, @Cached GetListStorageNode getStorageNode, @Cached GetClassForNewListNode getClassForNewListNode, - @Cached("createConcat()") SequenceStorageNodes.ConcatNode concatNode, + @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language, @Cached TypeNodes.GetInstanceShape getInstanceShape, @Cached PRaiseNode raiseNode) { @@ -759,15 +759,10 @@ static PList doPList(Object left, Object right, var leftStorage = getStorageNode.execute(inliningTarget, left); var rightStorage = getStorageNode.execute(inliningTarget, right); - SequenceStorage newStore = concatNode.execute(leftStorage, rightStorage); + SequenceStorage newStore = concatNode.execute(inliningTarget, leftStorage, rightStorage); Object newClass = getClassForNewListNode.execute(inliningTarget, left); return PFactory.createList(language, newClass, getInstanceShape.execute(newClass), newStore); } - - @NeverDefault - protected static SequenceStorageNodes.ConcatNode createConcat() { - return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); - } } @Slot(value = SlotKind.sq_inplace_concat, isComplex = true) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java index e8835f56b6..7a0bb1eb5b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java @@ -62,8 +62,6 @@ import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.CmpNode; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ConcatNode; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.SequenceStorageMpSubscriptNode; import com.oracle.graal.python.builtins.objects.iterator.PDoubleSequenceIterator; import com.oracle.graal.python.builtins.objects.iterator.PIntegerSequenceIterator; @@ -456,17 +454,14 @@ static PTuple doTuple(Object left, Object right, @SuppressWarnings("unused") @Cached PyTupleCheckNode checkRight, @Cached GetTupleStorage getLeft, @Cached GetTupleStorage getRight, - @Cached("createConcat()") ConcatNode concatNode, + @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language) { - SequenceStorage concatenated = concatNode.execute(getLeft.execute(inliningTarget, left), getRight.execute(inliningTarget, right)); + SequenceStorage leftStorage = getLeft.execute(inliningTarget, left); + SequenceStorage rightStorage = getRight.execute(inliningTarget, right); + SequenceStorage concatenated = concatNode.execute(inliningTarget, leftStorage, rightStorage); return PFactory.createTuple(language, concatenated); } - @NeverDefault - protected static SequenceStorageNodes.ConcatNode createConcat() { - return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); - } - @Fallback static Object doGeneric(@SuppressWarnings("unused") Object left, Object right, @Bind("this") Node inliningTarget) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index a169ce7770..5aed080f1e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -40,24 +40,27 @@ */ package com.oracle.graal.python.lib; +import static com.oracle.graal.python.builtins.objects.ints.IntBuiltins.AddNode.add; import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode; +import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; +import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -65,6 +68,8 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -74,27 +79,76 @@ import com.oracle.truffle.api.strings.TruffleString; @GenerateCached(false) +@ImportStatic(PGuards.class) abstract class PyNumberAddBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions - * in IntBuiltins, FloatBuiltins, ListBuiltins, ... + * in IntBuiltins, but it additionally needs to check PInts for only builtin ints */ + // XXX this could benefit from the type system conversions, but that would also unpack PFloat + // which we don't want + @Specialization(rewriteOn = ArithmeticException.class) - public static int add(int left, int right) { + static int doII(int left, int right) { return Math.addExact(left, right); } - @Specialization - public static long doIIOvf(int x, int y) { - return x + (long) y; + @Specialization(replaces = "doII", rewriteOn = ArithmeticException.class) + static long doLL(long left, long right) { + return Math.addExact(left, right); } - @Specialization(rewriteOn = ArithmeticException.class) - public static long addLong(long left, long right) { - return Math.addExact(left, right); + @Specialization(replaces = "doLL") + static Object doLLOvf(long x, long y, + @Bind PythonLanguage language) { + /* Inlined version of Math.addExact(x, y) with BigInteger fallback. */ + long r = x + y; + // HD 2-12 Overflow iff both arguments have the opposite sign of the result + if (((x ^ r) & (y ^ r)) < 0) { + return PFactory.createInt(language, add(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + } + return r; } + @Specialization(guards = "isBuiltinPInt(left)", rewriteOn = OverflowException.class) + static Object doPLNarrow(PInt left, long right) throws OverflowException { + return PInt.longValueExact(add(left.getValue(), PInt.longToBigInteger(right))); + } + + @Specialization(guards = "isBuiltinPInt(left)", replaces = "doPLNarrow") + static Object doPL(PInt left, long right, + @Bind PythonLanguage language) { + return PFactory.createInt(language, add(left.getValue(), PInt.longToBigInteger(right))); + } + + @Specialization(guards = "isBuiltinPInt(right)", rewriteOn = OverflowException.class) + static Object doLPNarrow(long left, PInt right) throws OverflowException { + return PInt.longValueExact(add(PInt.longToBigInteger(left), right.getValue())); + } + + @Specialization(guards = "isBuiltinPInt(right)", replaces = "doLPNarrow") + static Object doLP(long left, PInt right, + @Bind PythonLanguage language) { + return PFactory.createInt(language, add(PInt.longToBigInteger(left), right.getValue())); + } + + @Specialization(guards = {"isBuiltinPInt(left)", "isBuiltinPInt(right)"}, rewriteOn = OverflowException.class) + static Object doPPNarrow(PInt left, PInt right) throws OverflowException { + return PInt.longValueExact(add(left.getValue(), right.getValue())); + } + + @Specialization(guards = {"isBuiltinPInt(left)", "isBuiltinPInt(right)"}, replaces = "doPPNarrow") + static Object doPP(PInt left, PInt right, + @Bind PythonLanguage language) { + return PFactory.createInt(language, add(left.getValue(), right.getValue())); + } + + /* + * All the following fast paths need to be kept in sync with the corresponding builtin functions + * in FloatBuiltins + */ + @Specialization public static double doDD(double left, double right) { return left + right; @@ -122,6 +176,7 @@ public static double doID(int left, double right) { } @GenerateInline(inlineByDefault = true) +@GenerateUncached public abstract class PyNumberAddNode extends PyNumberAddBaseNode { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); @@ -138,24 +193,19 @@ public final Object executeCached(VirtualFrame frame, Object v, Object w) { public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException; - @NeverDefault - protected static SequenceStorageNodes.ConcatNode createConcat() { - return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); - } - @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"}) - static PList doPList(PList left, PList right, - @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, + static PList doPList(Node inliningTarget, PList left, PList right, + @Shared @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language) { - SequenceStorage newStore = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); + SequenceStorage newStore = concatNode.execute(inliningTarget, left.getSequenceStorage(), right.getSequenceStorage()); return PFactory.createList(language, newStore); } @Specialization(guards = {"isBuiltinTuple(left)", "isBuiltinTuple(right)"}) - static PTuple doTuple(PTuple left, PTuple right, - @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, + static PTuple doTuple(Node inliningTarget, PTuple left, PTuple right, + @Shared @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language) { - SequenceStorage concatenated = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); + SequenceStorage concatenated = concatNode.execute(inliningTarget, left.getSequenceStorage(), right.getSequenceStorage()); return PFactory.createTuple(language, concatenated); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java index 26699f9e77..e7984682bb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceConcatNode.java @@ -46,7 +46,6 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ListGeneralizationNode; import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.TpSlots; @@ -68,7 +67,6 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -80,24 +78,19 @@ public abstract class PySequenceConcatNode extends PNodeWithContext { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); - @NeverDefault - protected static SequenceStorageNodes.ConcatNode createConcat() { - return SequenceStorageNodes.ConcatNode.create(ListGeneralizationNode::create); - } - @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"}) - static PList doPList(PList left, PList right, - @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, + static PList doPList(Node inliningTarget, PList left, PList right, + @Shared @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language) { - SequenceStorage newStore = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); + SequenceStorage newStore = concatNode.execute(inliningTarget, left.getSequenceStorage(), right.getSequenceStorage()); return PFactory.createList(language, newStore); } @Specialization(guards = {"isBuiltinTuple(left)", "isBuiltinTuple(right)"}) - static PTuple doTuple(PTuple left, PTuple right, - @Shared @Cached(value = "createConcat()", inline = false) SequenceStorageNodes.ConcatNode concatNode, + static PTuple doTuple(Node inliningTarget, PTuple left, PTuple right, + @Shared @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode, @Bind PythonLanguage language) { - SequenceStorage concatenated = concatNode.execute(left.getSequenceStorage(), right.getSequenceStorage()); + SequenceStorage concatenated = concatNode.execute(inliningTarget, left.getSequenceStorage(), right.getSequenceStorage()); return PFactory.createTuple(language, concatenated); } From 12d1bc51ef8aef8058c6c7c46f8313f0e14dfa1a Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 09:49:11 +0100 Subject: [PATCH 034/512] Refactor bytes concat --- .../objects/bytes/ByteArrayBuiltins.java | 45 +++++---- .../objects/bytes/BytesCommonBuiltins.java | 46 +++++---- .../objects/common/SequenceStorageNodes.java | 94 ------------------- .../graal/python/nodes/ErrorMessages.java | 1 + 4 files changed, 55 insertions(+), 131 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index d4da0d121d..bd719d0915 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -41,6 +41,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.MemoryError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -110,6 +111,8 @@ import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.ComparisonOp; +import com.oracle.graal.python.util.OverflowException; +import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -431,44 +434,46 @@ public abstract static class IAddNode extends PythonBinaryBuiltinNode { @Specialization static PByteArray add(PByteArray self, PBytesLike other, @Bind("this") Node inliningTarget, - @Cached @Shared SequenceStorageNodes.ConcatNode concatNode, + @Shared @Cached SequenceStorageNodes.EnsureCapacityNode ensureCapacityNode, + @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PRaiseNode raiseNode) { - self.checkCanResize(inliningTarget, raiseNode); - SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage()); - updateSequenceStorage(self, res); - return self; + return extendWithBuffer(self, other, inliningTarget, ensureCapacityNode, bufferLib, raiseNode); } @Specialization(guards = "!isBytes(other)", limit = "3") static PByteArray add(VirtualFrame frame, PByteArray self, Object other, @Bind("this") Node inliningTarget, - @Bind PythonLanguage language, @Cached("createFor(this)") IndirectCallData indirectCallData, @CachedLibrary("other") PythonBufferAcquireLibrary bufferAcquireLib, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached @Shared SequenceStorageNodes.ConcatNode concatNode, + @Shared @Cached SequenceStorageNodes.EnsureCapacityNode ensureCapacityNode, + @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, @Shared @Cached PRaiseNode raiseNode) { - Object buffer; + Object otherBuffer; try { - buffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); + otherBuffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); } catch (PException e) { throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); } try { - self.checkCanResize(inliningTarget, raiseNode); - // TODO avoid copying - PBytes bytes = PFactory.createBytes(language, bufferLib.getCopiedByteArray(buffer)); - SequenceStorage res = concatNode.execute(self.getSequenceStorage(), bytes.getSequenceStorage()); - updateSequenceStorage(self, res); - return self; + return extendWithBuffer(self, otherBuffer, inliningTarget, ensureCapacityNode, bufferLib, raiseNode); } finally { - bufferLib.release(buffer, frame, indirectCallData); + bufferLib.release(otherBuffer, frame, indirectCallData); } } - private static void updateSequenceStorage(PByteArray array, SequenceStorage s) { - if (array.getSequenceStorage() != s) { - array.setSequenceStorage(s); + private static PByteArray extendWithBuffer(PByteArray self, Object otherBuffer, Node inliningTarget, SequenceStorageNodes.EnsureCapacityNode ensureCapacityNode, + PythonBufferAccessLibrary bufferLib, PRaiseNode raiseNode) { + self.checkCanResize(inliningTarget, raiseNode); + try { + int len = self.getSequenceStorage().length(); + int otherLen = bufferLib.getBufferLength(otherBuffer); + int newLen = PythonUtils.addExact(len, otherLen); + ensureCapacityNode.execute(inliningTarget, self.getSequenceStorage(), newLen); + self.getSequenceStorage().setNewLength(newLen); + bufferLib.readIntoBuffer(otherBuffer, 0, self, len, otherLen, bufferLib); + return self; + } catch (OverflowException e) { + throw raiseNode.raise(inliningTarget, MemoryError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java index 9e4733c4d3..fad33a8aa9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java @@ -289,11 +289,11 @@ public abstract static class ConcatNode extends SqConcatBuiltinNode { @Specialization static PBytesLike add(PBytesLike self, PBytesLike other, - @Bind("this") Node node, - @Cached("createWithOverflowError()") @Shared SequenceStorageNodes.ConcatNode concatNode, - @Cached @Exclusive BytesNodes.CreateBytesNode create) { - SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage()); - return create.execute(node, self, res); + @Bind Node inliningTarget, + @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, + @Shared @Cached BytesNodes.CreateBytesNode create, + @Shared @Cached PRaiseNode raiseNode) { + return concatBuffers(self, self, other, inliningTarget, bufferLib, create, raiseNode); } @Specialization(limit = "3") @@ -302,23 +302,35 @@ static PBytesLike add(VirtualFrame frame, Object self, Object other, @Cached("createFor(this)") IndirectCallData indirectCallData, @Cached GetBytesStorage getBytesStorage, @CachedLibrary("other") PythonBufferAcquireLibrary bufferAcquireLib, - @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib, - @Cached("createWithOverflowError()") @Shared SequenceStorageNodes.ConcatNode concatNode, - @Cached @Exclusive BytesNodes.CreateBytesNode create, - @Cached PRaiseNode raiseNode) { - Object buffer; + @Shared @CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib, + @Shared @Cached BytesNodes.CreateBytesNode create, + @Shared @Cached PRaiseNode raiseNode) { + Object otherBuffer; try { - buffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); + otherBuffer = bufferAcquireLib.acquireReadonly(other, frame, indirectCallData); } catch (PException e) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_CONCAT_P_TO_S, other, "bytearray"); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_CONCAT_P_TO_P, other, self); } try { - // TODO avoid copying - byte[] bytes = bufferLib.getCopiedByteArray(buffer); - SequenceStorage res = concatNode.execute(getBytesStorage.execute(inliningTarget, self), new ByteSequenceStorage(bytes)); - return create.execute(inliningTarget, self, res); + SequenceStorage selfBuffer = getBytesStorage.execute(inliningTarget, self); + return concatBuffers(self, selfBuffer, otherBuffer, inliningTarget, bufferLib, create, raiseNode); } finally { - bufferLib.release(buffer, frame, indirectCallData); + bufferLib.release(otherBuffer, frame, indirectCallData); + } + } + + private static PBytesLike concatBuffers(Object self, Object selfBuffer, Object otherBuffer, Node inliningTarget, PythonBufferAccessLibrary bufferLib, BytesNodes.CreateBytesNode create, + PRaiseNode raiseNode) { + try { + int len = bufferLib.getBufferLength(selfBuffer); + int otherLen = bufferLib.getBufferLength(otherBuffer); + int newLen = PythonUtils.addExact(len, otherLen); + byte[] newBytes = new byte[newLen]; + bufferLib.readIntoByteArray(selfBuffer, 0, newBytes, 0, len); + bufferLib.readIntoByteArray(otherBuffer, 0, newBytes, len, otherLen); + return create.execute(inliningTarget, self, new ByteSequenceStorage(newBytes)); + } catch (OverflowException e) { + throw raiseNode.raise(inliningTarget, OverflowError); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 1a2c29b059..b432d53661 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -45,7 +45,6 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.modules.SysModuleBuiltins; import com.oracle.graal.python.builtins.objects.bytes.BytesNodes; import com.oracle.graal.python.builtins.objects.bytes.PBytesLike; import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes; @@ -57,8 +56,6 @@ import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetSequenceStorageNode; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.AppendNodeGen; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.CmpNodeGen; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.ConcatBaseNodeGen; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.ConcatNodeGen; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.CreateStorageFromIteratorNodeFactory.CreateStorageFromIteratorNodeCachedNodeGen; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.DeleteNodeGen; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodesFactory.ExtendNodeGen; @@ -2315,97 +2312,6 @@ private static void concat(Object dest, Object arr1, int len1, Object arr2, int } } - /** - * Concatenates two sequence storages; creates a storage of a suitable type and writes the - * result to the new storage. - */ - public abstract static class ConcatNode extends SequenceStorageBaseNode { - private static final TruffleString DEFAULT_ERROR_MSG = ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP; - - @Child private ConcatBaseNode concatBaseNode = ConcatBaseNodeGen.create(); - @Child private GeneralizationNode genNode; - - private final Supplier genNodeProvider; - - /* - * CPython is inconsistent when too repeats are done. Most types raise MemoryError, but e.g. - * bytes raises OverflowError when the memory might be available but the size overflows - * sys.maxint - */ - private final PythonBuiltinClassType errorForOverflow; - - ConcatNode(Supplier genNodeProvider, PythonBuiltinClassType errorForOverflow) { - this.genNodeProvider = genNodeProvider; - this.errorForOverflow = errorForOverflow; - } - - public abstract SequenceStorage execute(SequenceStorage left, SequenceStorage right); - - @Specialization - SequenceStorage doRight(SequenceStorage left, SequenceStorage right, - @Bind("this") Node inliningTarget, - @Cached CreateEmptyNode createEmptyNode, - @Cached InlinedConditionProfile shouldOverflow, - @Cached PRaiseNode raiseNode) { - int destlen = 0; - try { - int len1 = left.length(); - int len2 = right.length(); - // we eagerly generalize the store to avoid possible cascading generalizations - destlen = PythonUtils.addExact(len1, len2); - if (errorForOverflow == OverflowError && shouldOverflow.profile(inliningTarget, destlen >= SysModuleBuiltins.MAXSIZE)) { - // cpython raises an overflow error when this happens - throw raiseNode.raise(inliningTarget, OverflowError); - } - SequenceStorage generalized = generalizeStore(createEmpty(createEmptyNode, inliningTarget, left, right, destlen), right); - return doConcat(generalized, left, right); - } catch (OutOfMemoryError e) { - throw raiseNode.raise(inliningTarget, MemoryError); - } catch (OverflowException e) { - throw raiseNode.raise(inliningTarget, errorForOverflow); - } - } - - private SequenceStorage createEmpty(CreateEmptyNode createEmptyNode, Node inliningTarget, SequenceStorage l, SequenceStorage r, int len) { - if (l instanceof EmptySequenceStorage) { - return createEmptyNode.execute(inliningTarget, r, len, -1); - } - return createEmptyNode.execute(inliningTarget, l, len, len); - } - - private SequenceStorage doConcat(SequenceStorage dest, SequenceStorage leftProfiled, SequenceStorage rightProfiled) { - try { - return concatBaseNode.execute(dest, leftProfiled, rightProfiled); - } catch (SequenceStoreException e) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new IllegalStateException("generalized sequence storage cannot take value: " + e.getIndicationValue()); - } - } - - private SequenceStorage generalizeStore(SequenceStorage storage, Object value) { - if (genNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - genNode = insert(genNodeProvider.get()); - } - return genNode.executeCached(storage, value); - } - - @NeverDefault - public static ConcatNode create() { - return create(() -> NoGeneralizationCustomMessageNode.create(DEFAULT_ERROR_MSG), MemoryError); - } - - @NeverDefault - public static ConcatNode createWithOverflowError() { - return create(() -> NoGeneralizationCustomMessageNode.create(DEFAULT_ERROR_MSG), OverflowError); - } - - @NeverDefault - private static ConcatNode create(Supplier genNodeProvider, PythonBuiltinClassType errorForOverflow) { - return ConcatNodeGen.create(genNodeProvider, errorForOverflow); - } - } - @GenerateInline @GenerateCached(false) @GenerateUncached diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java index 7804fc3b01..3dc120280a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java @@ -205,6 +205,7 @@ public abstract class ErrorMessages { public static final TruffleString CANNOT_CONVERT_FLOAT_NAN_TO_INTEGER = tsLiteral("cannot convert float NaN to integer"); public static final TruffleString CANT_CAPTURE_NAME_UNDERSCORE_IN_PATTERNS = tsLiteral("can't capture name '_' in patterns"); public static final TruffleString CANT_CONCAT_P_TO_S = tsLiteral("can't concat %p to %s"); + public static final TruffleString CANT_CONCAT_P_TO_P = tsLiteral("can't concat %p to %p"); public static final TruffleString CANT_CONVERT_TO_STR_IMPLICITLY = tsLiteral("Can't convert '%p' object to str implicitly"); public static final TruffleString CANT_COMPARE = tsLiteral("Can't compare %p and %p"); public static final TruffleString CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE = tsLiteral("can't delete numeric/char attribute"); From ea93541af29e8a37e7cafeb436f5f816818cc3c7 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 11:16:01 +0100 Subject: [PATCH 035/512] Split PythonArithmeticTypes --- .../builtins/modules/BuiltinFunctions.java | 16 +---- .../builtins/modules/CmathModuleBuiltins.java | 18 +++--- .../modules/GraalPythonModuleBuiltins.java | 5 -- .../builtins/modules/MathModuleBuiltins.java | 30 ++++----- .../modules/OperatorModuleBuiltins.java | 3 - .../modules/PolyglotModuleBuiltins.java | 5 +- .../builtins/modules/PosixModuleBuiltins.java | 14 +++-- .../builtins/modules/SREModuleBuiltins.java | 6 -- .../modules/ThreadModuleBuiltins.java | 13 ++-- .../builtins/modules/TimeModuleBuiltins.java | 12 +--- .../cext/PythonCextUnicodeBuiltins.java | 4 +- .../modules/io/BufferedIOMixinBuiltins.java | 3 - .../builtins/modules/io/BufferedIONodes.java | 4 +- .../builtins/modules/io/StringIOBuiltins.java | 3 - .../modules/lzma/LZMACompressorBuiltins.java | 15 ++--- .../lzma/LZMADecompressorBuiltins.java | 8 --- .../modules/lzma/LZMAModuleBuiltins.java | 5 -- .../modules/zlib/ZLibModuleBuiltins.java | 3 - .../builtins/objects/bool/BoolBuiltins.java | 12 ++-- .../objects/bytes/BytesCommonBuiltins.java | 4 -- .../objects/complex/ComplexBuiltins.java | 4 +- .../objects/floats/FloatBuiltins.java | 4 -- .../function/BuiltinFunctionBuiltins.java | 3 - .../objects/function/FunctionBuiltins.java | 3 - .../function/MethodDescriptorBuiltins.java | 3 - .../function/WrapperDescriptorBuiltins.java | 3 - .../builtins/objects/ints/IntBuiltins.java | 62 +++++++++---------- .../builtins/objects/mmap/MMapBuiltins.java | 5 -- .../objects/random/RandomBuiltins.java | 4 +- .../builtins/objects/range/RangeBuiltins.java | 4 +- .../objects/ssl/SSLContextBuiltins.java | 5 -- .../builtins/objects/str/StringBuiltins.java | 6 -- .../graal/python/lib/PyNumberAddNode.java | 15 +---- .../python/lib/PyTimeFromObjectNode.java | 4 +- .../expression/BinaryComparisonNode.java | 4 +- .../truffle/PythonIntegerAndFloatTypes.java | 59 ++++++++++++++++++ ...eticTypes.java => PythonIntegerTypes.java} | 46 ++------------ .../nodes/util/CastToJavaBigIntegerNode.java | 3 - .../nodes/util/CastToJavaDoubleNode.java | 6 +- .../python/nodes/util/CastToJavaIntNode.java | 6 +- .../util/CastToJavaUnsignedLongNode.java | 4 +- .../nodes/util/CoerceToComplexNode.java | 4 +- mx.graalpython/copyrights/overrides | 2 +- 43 files changed, 180 insertions(+), 262 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerAndFloatTypes.java rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/{PythonArithmeticTypes.java => PythonIntegerTypes.java} (50%) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 252a9e6740..1669baa4b4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -231,7 +231,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; @@ -552,7 +552,7 @@ static boolean doObject(VirtualFrame frame, Object object, @GenerateInline @GenerateCached(false) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class BinOctHexHelperNode extends Node { @FunctionalInterface @@ -593,13 +593,6 @@ static TruffleString doL(Node inliningTarget, long x, TruffleString prefix, int return buildString(x < 0, prefix, fromJavaStringNode.execute(longToString.convert(Math.abs(x)), TS_ENCODING)); } - @Specialization - @SuppressWarnings("unused") - static TruffleString doD(double x, TruffleString prefix, int radix, LongToString longToString, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, (Object) x); - } - @Specialization static TruffleString doPI(PInt x, TruffleString prefix, int radix, @SuppressWarnings("unused") LongToString longToString, @Shared @Cached(inline = false) TruffleString.FromJavaStringNode fromJavaStringNode) { @@ -607,7 +600,7 @@ static TruffleString doPI(PInt x, TruffleString prefix, int radix, @SuppressWarn return buildString(value.signum() < 0, prefix, fromJavaStringNode.execute(bigToString(radix, PInt.abs(value)), TS_ENCODING)); } - @Specialization(replaces = {"doL", "doD", "doPI"}) + @Specialization(replaces = {"doL", "doPI"}) static TruffleString doO(VirtualFrame frame, Node inliningTarget, Object x, TruffleString prefix, int radix, LongToString longToString, @Exclusive @Cached InlinedConditionProfile isMinLong, @Cached PyNumberIndexNode indexNode, @@ -635,7 +628,6 @@ static TruffleString doO(VirtualFrame frame, Node inliningTarget, Object x, Truf // bin(object) @Builtin(name = J_BIN, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class BinNode extends PythonUnaryBuiltinNode { static final TruffleString T_BIN_PREFIX = tsLiteral("0b"); @@ -655,7 +647,6 @@ private static String longToString(long x) { // oct(object) @Builtin(name = J_OCT, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class OctNode extends PythonUnaryBuiltinNode { static final TruffleString T_OCT_PREFIX = tsLiteral("0o"); @@ -675,7 +666,6 @@ private static String longToString(long x) { // hex(object) @Builtin(name = J_HEX, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class HexNode extends PythonUnaryBuiltinNode { static final TruffleString T_HEX_PREFIX = tsLiteral("0x"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java index 1d20d28c2c..13b7746df0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CmathModuleBuiltins.java @@ -28,7 +28,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.nodes.util.CoerceToComplexNode; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CompilerDirectives; @@ -167,7 +167,7 @@ static SpecialType ofDouble(double d) { @GenerateInline @GenerateCached(false) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) abstract static class CmathComplexUnaryHelperNode extends Node { @@ -208,7 +208,7 @@ static PComplex doGeneral(VirtualFrame frame, Node inliningTarget, Object value, } } - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateInline @GenerateCached(false) @@ -277,7 +277,7 @@ static boolean doIt(VirtualFrame frame, Object o, } @Builtin(name = "phase", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class PhaseNode extends PythonUnaryBuiltinNode { @@ -306,7 +306,7 @@ static double doGeneral(VirtualFrame frame, Object value, } @Builtin(name = "polar", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class PolarNode extends PythonUnaryBuiltinNode { @@ -346,7 +346,7 @@ private static PTuple toPolar(PComplex value, ComplexBuiltins.AbsNode absNode, P } @Builtin(name = "rect", minNumOfPositionalArgs = 2) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class RectNode extends PythonBinaryBuiltinNode { @@ -421,7 +421,7 @@ private static PComplex rect(Node raisingNode, double r, double phi) { } @Builtin(name = "log", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class LogNode extends PythonBinaryBuiltinNode { @@ -516,7 +516,7 @@ private double computeRealPart(double real, double imag) { } @Builtin(name = "log10", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class Log10Node extends PythonUnaryBuiltinNode { @@ -1093,7 +1093,7 @@ static ComplexValue compute(Node inliningTarget, double real, double imag, PRais } @Builtin(name = "isclose", minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 2, varArgsMarker = true, keywordOnlyNames = {"rel_tol", "abs_tol"}) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory abstract static class IsCloseNode extends PythonBuiltinNode { 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 9cc60db297..882a36875c 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 @@ -156,7 +156,6 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.nodes.util.ToNativePrimitiveStorageNode; import com.oracle.graal.python.runtime.ExecutionContext; @@ -188,7 +187,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; @@ -595,7 +593,6 @@ public Object doIt(PFunction func) { } @Builtin(name = "get_toolchain_tools_for_venv") - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class GetToolchainToolsForVenv extends PythonBuiltinNode { private static final class Tool { @@ -668,7 +665,6 @@ Object getToolPath() { } @Builtin(name = "get_toolchain_tool_path", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class GetToolPathNode extends PythonUnaryBuiltinNode { @Specialization @@ -686,7 +682,6 @@ protected Object getToolPath(TruffleString tool) { } @Builtin(name = "get_toolchain_paths", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class GetToolchainPathsNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java index aec6c98c51..38a0d39fad 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java @@ -79,7 +79,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.nodes.util.NarrowBigIntegerNode; import com.oracle.graal.python.runtime.exception.PException; @@ -145,7 +145,7 @@ static void checkMathDomainErrorUncached(boolean con, Node raisingNode) { @GenerateInline @GenerateCached(false) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) public abstract static class MathUnaryHelperNode extends Node { @@ -405,7 +405,7 @@ static Object factorialObject(VirtualFrame frame, Object value, } @Builtin(name = "comb", minNumOfPositionalArgs = 2) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class CombNode extends PythonBinaryBuiltinNode { @@ -475,7 +475,7 @@ static Object comb(VirtualFrame frame, Object n, Object k, } @Builtin(name = "perm", minNumOfPositionalArgs = 1, parameterNames = {"n", "k"}) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class PermNode extends PythonBinaryBuiltinNode { @@ -717,7 +717,7 @@ protected ArgumentClinicProvider getArgumentClinic() { } @Builtin(name = "isnan", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory public abstract static class IsNanNode extends PythonUnaryBuiltinNode { @@ -783,7 +783,7 @@ protected ArgumentClinicProvider getArgumentClinic() { @Builtin(name = "ldexp", minNumOfPositionalArgs = 2, numOfPositionalOnlyArgs = 2, parameterNames = {"x", "i"}) @ArgumentClinic(name = "x", conversion = ArgumentClinic.ClinicConversion.Double) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory public abstract static class LdexpNode extends PythonBinaryClinicBuiltinNode { @@ -1033,7 +1033,7 @@ public int gcdKeywords(Object self, Object[] args, PKeyword[] keywords) { } } - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) public abstract static class Gcd2Node extends Node { @@ -1193,7 +1193,7 @@ public int gcdKeywords(Object self, Object[] args, PKeyword[] keywords) { @Builtin(name = "nextafter", minNumOfPositionalArgs = 2, parameterNames = {"start", "direction"}) @ArgumentClinic(name = "start", conversion = ArgumentClinic.ClinicConversion.Double) @ArgumentClinic(name = "direction", conversion = ArgumentClinic.ClinicConversion.Double) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class NextAfterNode extends PythonBinaryClinicBuiltinNode { @@ -1211,7 +1211,7 @@ static double nextAfter(double start, double direction) { @Builtin(name = "ulp", minNumOfPositionalArgs = 1, parameterNames = {"x"}) @ArgumentClinic(name = "x", conversion = ArgumentClinic.ClinicConversion.Double) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class UlpNode extends PythonUnaryClinicBuiltinNode { @@ -1442,7 +1442,7 @@ private static double compute(Node inliningTarget, double value, PRaiseNode rais } @Builtin(name = "asinh", minNumOfPositionalArgs = 1, doc = "Return the inverse hyperbolic sine of x.") - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory public abstract static class AsinhNode extends PythonUnaryBuiltinNode { @@ -1464,7 +1464,7 @@ public static AsinhNode create() { } @Builtin(name = "isfinite", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory public abstract static class IsFiniteNode extends PythonUnaryBuiltinNode { @@ -1493,7 +1493,7 @@ public static boolean isinf(VirtualFrame frame, Object value, } @Builtin(name = "isinf", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory public abstract static class IsInfNode extends PythonUnaryBuiltinNode { @@ -1522,7 +1522,7 @@ public static boolean isinf(VirtualFrame frame, Object value, } @Builtin(name = "log", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(MathGuards.class) @GenerateNodeFactory @SuppressWarnings("truffle-static-method") @@ -1980,7 +1980,7 @@ private static double compute(Node inliningTarget, double value, PRaiseNode rais } @Builtin(name = "hypot", minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, declaresExplicitSelf = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class HypotNode extends PythonVarargsBuiltinNode { @@ -2400,7 +2400,7 @@ private static double compute(Node inliningTarget, double x, PRaiseNode raiseNod } @Builtin(name = "isqrt", minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateNodeFactory @ImportStatic(MathGuards.class) public abstract static class IsqrtNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java index 15921a5507..8ad0cd329e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/OperatorModuleBuiltins.java @@ -61,7 +61,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; @@ -72,7 +71,6 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; @@ -143,7 +141,6 @@ static Object doObject(VirtualFrame frame, Object left, Object right, // _compare_digest @Builtin(name = "_compare_digest", minNumOfPositionalArgs = 2) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class CompareDigestNode extends PythonBinaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java index e5ed3dad0c..9f2a8457b8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PolyglotModuleBuiltins.java @@ -114,7 +114,7 @@ import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.GetForeignObjectClassNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.runtime.PythonContext; @@ -1146,7 +1146,7 @@ static Object remove(Object receiver, @Builtin(name = "__element_info__", minNumOfPositionalArgs = 3) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class ArrayElementInfoNode extends PythonBuiltinNode { @Specialization static boolean keyInfo(Object receiver, long member, TruffleString info, @@ -1171,7 +1171,6 @@ static boolean keyInfo(Object receiver, long member, TruffleString info, @Builtin(name = "storage", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class StorageNode extends PythonUnaryBuiltinNode { @Specialization @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index 1720e5b837..b83c26208c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -110,7 +110,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.GilNode; @@ -148,7 +147,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; @@ -2635,10 +2633,10 @@ static TruffleString getStrError(int code, } } - @Builtin(name = "_exit", minNumOfPositionalArgs = 1) + @Builtin(name = "_exit", minNumOfPositionalArgs = 1, parameterNames = {"status"}) + @ArgumentClinic(name = "status", conversion = ClinicConversion.Int) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) - public abstract static class ExitNode extends PythonUnaryBuiltinNode { + public abstract static class ExitNode extends PythonUnaryClinicBuiltinNode { @TruffleBoundary @Specialization Object exit(int status) { @@ -2667,6 +2665,11 @@ protected void perform(Access access) { } throw new ThreadDeath(); } + + @Override + protected ArgumentClinicProvider getArgumentClinic() { + return PosixModuleBuiltinsClinicProviders.ExitNodeClinicProviderGen.INSTANCE; + } } @Builtin(name = "waitpid", minNumOfPositionalArgs = 2, parameterNames = {"pid", "options"}) @@ -2916,7 +2919,6 @@ static int system(PBytes command, @Builtin(name = "urandom", minNumOfPositionalArgs = 1, numOfPositionalOnlyArgs = 1, parameterNames = {"size"}) @ArgumentClinic(name = "size", conversion = ClinicConversion.Index) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class URandomNode extends PythonUnaryClinicBuiltinNode { @Specialization(guards = "size >= 0") static PBytes urandom(int size, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java index 5f929437c2..8ff287face 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java @@ -82,7 +82,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonSenaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; @@ -104,7 +103,6 @@ import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.ExceptionType; @@ -462,7 +460,6 @@ public int hashCode() { } @Builtin(name = "tregex_init_cache", minNumOfPositionalArgs = 3) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class TRegexInitCache extends PythonTernaryBuiltinNode { @@ -479,7 +476,6 @@ Object call(VirtualFrame frame, PythonObject patternObject, Object pattern, Obje } @Builtin(name = "tregex_compile", minNumOfPositionalArgs = 3) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory @ImportStatic(PythonMethod.class) abstract static class TRegexCompile extends PythonTernaryBuiltinNode { @@ -625,7 +621,6 @@ protected Object lookupMatchConstructor() { } @Builtin(name = "tregex_search", minNumOfPositionalArgs = 6) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory @ImportStatic(PythonMethod.class) abstract static class TRegexSearch extends PythonSenaryBuiltinNode { @@ -783,7 +778,6 @@ private PyObjectGetItem getGetItemNode() { } @Builtin(name = "tregex_call_exec", minNumOfPositionalArgs = 3) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class TRegexCallExec extends PythonTernaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java index e7aef1644f..39da448c39 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java @@ -64,6 +64,7 @@ import com.oracle.graal.python.builtins.objects.thread.PThread; import com.oracle.graal.python.builtins.objects.thread.PThreadLocal; import com.oracle.graal.python.builtins.objects.type.TypeNodes; +import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.WriteUnraisableNode; @@ -77,7 +78,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; @@ -88,10 +88,10 @@ import com.oracle.truffle.api.TruffleThreadBuilder; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -188,18 +188,19 @@ long getCount(PythonModule self) { @Builtin(name = "stack_size", minNumOfPositionalArgs = 0, maxNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class GetThreadStackSizeNode extends PythonUnaryBuiltinNode { - @Specialization + @Specialization(guards = "isNoValue(stackSize)") long getStackSize(@SuppressWarnings("unused") PNone stackSize) { return getContext().getPythonThreadStackSize(); } - @Specialization - static long getStackSize(long stackSize, + @Fallback + static long getStackSize(VirtualFrame frame, Object stackSizeObj, @Bind("this") Node inliningTarget, + @Cached PyNumberAsSizeNode asSizeNode, @Cached PRaiseNode raiseNode) { + int stackSize = asSizeNode.executeExact(frame, inliningTarget, stackSizeObj); if (stackSize < 0) { throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.SIZE_MUST_BE_D_OR_S, 0, "a positive value"); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java index 10f9383697..18dcd246ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java @@ -49,7 +49,6 @@ import java.util.List; import java.util.TimeZone; -import com.oracle.graal.python.nodes.statement.AbstractImportNode; import org.graalvm.nativeimage.ImageInfo; import com.oracle.graal.python.PythonLanguage; @@ -87,7 +86,8 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.statement.AbstractImportNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaDoubleNode; import com.oracle.graal.python.runtime.GilNode; @@ -312,7 +312,6 @@ private static void check(Node inliningTarget, double time, PRaiseNode raiseNode // time.gmtime([seconds]) @Builtin(name = "gmtime", maxNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class PythonGMTimeNode extends PythonBuiltinNode { @Specialization @@ -348,7 +347,6 @@ Object tzset() { // time.localtime([seconds]) @Builtin(name = "localtime", maxNumOfPositionalArgs = 2, declaresExplicitSelf = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class PythonLocalTimeNode extends PythonBinaryBuiltinNode { @Specialization @@ -452,7 +450,6 @@ public long counter() { @Builtin(name = "process_time", minNumOfPositionalArgs = 1, declaresExplicitSelf = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ProcessTimeNode extends PythonBuiltinNode { @Specialization @TruffleBoundary @@ -464,7 +461,6 @@ Object getProcesTime(PythonModule self) { @Builtin(name = "process_time_ns", minNumOfPositionalArgs = 1, declaresExplicitSelf = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ProcessTimeNsNode extends PythonBuiltinNode { @Specialization @TruffleBoundary @@ -476,7 +472,6 @@ Object getProcesNsTime(PythonModule self) { @Builtin(name = "thread_time") @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ThreadTimeNode extends PythonBuiltinNode { @Specialization @TruffleBoundary @@ -487,7 +482,6 @@ Object getProcesTime() { @Builtin(name = "thread_time_ns") @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ThreadTimeNsNode extends PythonBuiltinNode { @Specialization @TruffleBoundary @@ -498,7 +492,7 @@ Object getProcesNsTime() { @Builtin(name = "sleep", minNumOfPositionalArgs = 2, declaresExplicitSelf = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) abstract static class SleepNode extends PythonBuiltinNode { // see: https://github.com/python/cpython/blob/master/Modules/timemodule.c#L1741 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java index 340340700e..7e162ce88c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java @@ -145,7 +145,6 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; @@ -1115,10 +1114,9 @@ static Object doNative(PythonAbstractNativeObject s, } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Int}, call = Ignored) - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class PyTruffle_Unicode_AsWideChar extends CApiBinaryBuiltinNode { @Specialization - static Object doUnicode(Object s, long elementSize, + static Object doUnicode(Object s, int elementSize, @Bind("this") Node inliningTarget, @Cached UnicodeAsWideCharNode asWideCharNode, @Cached CastToTruffleStringNode castStr, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java index 2d56ea743f..f94807b80d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java @@ -105,7 +105,6 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.dsl.Bind; @@ -115,7 +114,6 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedConditionProfile; @@ -255,7 +253,6 @@ static Object none(@SuppressWarnings("unused") Object self, @SuppressWarnings("u @ArgumentClinic(name = "whence", conversion = ArgumentClinic.ClinicConversion.Int, defaultValue = "BufferedIOUtil.SEEK_SET", useDefaultForNone = true) @GenerateNodeFactory @ImportStatic(IONodes.class) - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class SeekNode extends PythonTernaryClinicBuiltinNode { @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java index 7dbf414744..37c778a932 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java @@ -73,7 +73,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.runtime.GilNode; @@ -166,7 +166,7 @@ static boolean isSeekable(VirtualFrame frame, PBuffered self, } @ImportStatic(PGuards.class) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateInline @GenerateCached(false) // PyNumber_AsOff_t diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java index 5cefff275f..186ec651cf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java @@ -115,7 +115,6 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectExactProfile; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -127,7 +126,6 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -435,7 +433,6 @@ static TruffleString readline(PStringIO self, int size, @Builtin(name = J_TRUNCATE, minNumOfPositionalArgs = 1, parameterNames = {"$self", "size"}) @ArgumentClinic(name = "size", defaultValue = "PNone.NONE", useDefaultForNone = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class TruncateNode extends ClosedCheckPythonBinaryClinicBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java index 875ca50e13..6f3e42d57a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMACompressorBuiltins.java @@ -77,7 +77,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -92,7 +91,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -109,7 +107,6 @@ protected List> getNodeFa @ArgumentClinic(name = "check", conversion = ClinicConversion.Int, defaultValue = "-1", useDefaultForNone = true) @ArgumentClinic(name = "preset", conversionClass = ExpectUINT32Node.class, defaultValue = "PNone.NO_VALUE") @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class InitNode extends PythonClinicBuiltinNode { @Override @@ -135,26 +132,26 @@ static PNone init(VirtualFrame frame, LZMACompressor self, int format, int check @Specialization(guards = "badIntegrity(format, check)") @SuppressWarnings("unused") - static PNone integrityError(LZMACompressor self, long format, long check, Object preset, Object filters, + static PNone integrityError(LZMACompressor self, int format, int check, Object preset, Object filters, @Bind("this") Node inliningTarget) { throw PRaiseNode.raiseStatic(inliningTarget, ValueError, INTEGRITY_CHECKS_ONLY_SUPPORTED_BY); } @Specialization(guards = {"!badIntegrity(format, check)", "badPresetFilters(preset, filters)"}) @SuppressWarnings("unused") - static PNone presetError(LZMACompressor self, long format, long check, Object preset, Object filters, + static PNone presetError(LZMACompressor self, int format, int check, Object preset, Object filters, @Bind("this") Node inliningTarget) { throw PRaiseNode.raiseStatic(inliningTarget, ValueError, CANNOT_SPECIFY_PREST_AND_FILTER_CHAIN); } @Specialization(guards = {"!badIntegrity(format, check)", "!badPresetFilters(preset, filters)", "badRawFilter(format, filters)"}) @SuppressWarnings("unused") - static PNone rawError(LZMACompressor self, long format, long check, Object preset, PNone filters, + static PNone rawError(LZMACompressor self, int format, int check, Object preset, PNone filters, @Bind("this") Node inliningTarget) { throw PRaiseNode.raiseStatic(inliningTarget, ValueError, MUST_SPECIFY_FILTERS); } - protected static boolean badIntegrity(long format, long check) { + protected static boolean badIntegrity(int format, int check) { return format != FORMAT_XZ && check != -1 && check != CHECK_NONE; } @@ -166,14 +163,13 @@ protected static boolean badRawFilter(long format, Object filters) { return format == FORMAT_RAW && PGuards.isPNone(filters); } - protected static boolean isValid(long format, long check, Object preset, Object filters) { + protected static boolean isValid(int format, int check, Object preset, Object filters) { return !badIntegrity(format, check) && !badPresetFilters(preset, filters) && !badRawFilter(format, filters); } } @Builtin(name = "compress", minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class CompressNode extends PythonBinaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) @@ -221,7 +217,6 @@ static ArrayAndLength doObject(VirtualFrame frame, Object data, @Builtin(name = "flush", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class FlushNode extends PythonUnaryBuiltinNode { @Specialization(guards = {"!self.isFlushed()"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java index be0e92dd3f..ee3b3138e5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMADecompressorBuiltins.java @@ -76,7 +76,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.runtime.object.PFactory; @@ -88,7 +87,6 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -104,7 +102,6 @@ protected List> getNodeFa @Builtin(name = J___INIT__, minNumOfPositionalArgs = 1, parameterNames = {"$self", "format", "memlimit", "filters"}) @ArgumentClinic(name = "format", conversion = ArgumentClinic.ClinicConversion.Int, defaultValue = "LZMAModuleBuiltins.FORMAT_AUTO", useDefaultForNone = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class InitNode extends PythonQuaternaryClinicBuiltinNode { @Override @@ -195,7 +192,6 @@ protected static boolean isRaw(int format) { @Builtin(name = "decompress", minNumOfPositionalArgs = 2, parameterNames = {"$self", "$data", "max_length"}, needsFrame = true) @ArgumentClinic(name = "max_length", conversion = ArgumentClinic.ClinicConversion.Int, defaultValue = "-1", useDefaultForNone = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class DecompressNode extends PythonTernaryClinicBuiltinNode { @Override @@ -236,7 +232,6 @@ static Object err(LZMADecompressor self, Object data, int maxLength, @Builtin(name = "eof", minNumOfPositionalArgs = 1, parameterNames = {"self"}, isGetter = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class EofNode extends PythonUnaryBuiltinNode { @Specialization @@ -248,7 +243,6 @@ boolean doEof(LZMADecompressor self) { @Builtin(name = "needs_input", minNumOfPositionalArgs = 1, parameterNames = {"self"}, isGetter = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class NeedsInputNode extends PythonUnaryBuiltinNode { @Specialization @@ -260,7 +254,6 @@ boolean doNeedsInput(LZMADecompressor self) { @Builtin(name = "check", minNumOfPositionalArgs = 1, parameterNames = {"self"}, isGetter = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class CheckNode extends PythonUnaryBuiltinNode { @Specialization @@ -278,7 +271,6 @@ static int doCheck(@SuppressWarnings("unused") LZMADecompressor.Java self, @Builtin(name = "unused_data", minNumOfPositionalArgs = 1, parameterNames = {"self"}, isGetter = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class UnusedDataNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java index 7574a24ee4..6fad856c29 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAModuleBuiltins.java @@ -95,7 +95,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode; import com.oracle.graal.python.runtime.NFILZMASupport; import com.oracle.graal.python.runtime.NativeLibrary; @@ -107,7 +106,6 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -291,7 +289,6 @@ LZMAObject doNew(Object cls, @SuppressWarnings("unused") Object arg, @Builtin(name = "is_check_supported", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class IsCheckSupportedNode extends PythonUnaryBuiltinNode { @Specialization @@ -305,7 +302,6 @@ static boolean doInt(VirtualFrame frame, Object checkID, @Builtin(name = "_encode_filter_properties", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class EncodeFilterPropertiesNode extends PythonUnaryBuiltinNode { @Specialization @@ -318,7 +314,6 @@ static PBytes encode(VirtualFrame frame, Object filter, @Builtin(name = "_decode_filter_properties", minNumOfPositionalArgs = 2, maxNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class DecodeFilterPropertiesNode extends PythonBinaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java index 6eae81e755..b0986e0b33 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/zlib/ZLibModuleBuiltins.java @@ -86,7 +86,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.NFIZlibSupport; import com.oracle.graal.python.runtime.NativeLibrary; @@ -106,7 +105,6 @@ import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.NonIdempotent; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.UnsupportedMessageException; @@ -402,7 +400,6 @@ long nativeCrc32(byte[] bytes, int len, int value, // zlib.adler32(data[, value]) @Builtin(name = "adler32", minNumOfPositionalArgs = 1, numOfPositionalOnlyArgs = 2, parameterNames = {"data", "value"}) @ArgumentClinic(name = "value", conversionClass = ZLibModuleBuiltins.ExpectIntNode.class, defaultValue = "PNone.NO_VALUE", useDefaultForNone = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class Adler32Node extends PythonBinaryClinicBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java index c418fc27cc..39d1418252 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java @@ -44,7 +44,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -65,9 +65,14 @@ protected List> getNodeFa } @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory abstract static class StrNode extends PythonBuiltinNode { + @Specialization + static TruffleString doBoolean(boolean self) { + return self ? T_TRUE : T_FALSE; + } + @Specialization public static TruffleString doLong(long self) { return self == 1 ? T_TRUE : T_FALSE; @@ -85,7 +90,6 @@ abstract static class RepNode extends StrNode { } @Slot(value = SlotKind.nb_and, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class AndNode extends BinaryOpBuiltinNode { @Specialization @@ -101,7 +105,6 @@ static Object doOther(VirtualFrame frame, Object self, Object other, } @Slot(value = SlotKind.nb_or, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class OrNode extends BinaryOpBuiltinNode { @Specialization @@ -117,7 +120,6 @@ static Object doOther(VirtualFrame frame, Object self, Object other, } @Slot(value = SlotKind.nb_xor, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class XorNode extends BinaryOpBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java index fad33a8aa9..73c05dea87 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java @@ -124,7 +124,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentCastNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; @@ -152,7 +151,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; @@ -1665,7 +1663,6 @@ private static PList getBytesResult(List bytes, ListNodes.AppendNode app @ArgumentClinic(name = "sep", conversionClass = ExpectByteLikeNode.class, defaultValue = "BytesCommonBuiltins.AbstractSplitNode.WHITESPACE") @ArgumentClinic(name = "maxsplit", conversionClass = ExpectIntNode.class, defaultValue = "Integer.MAX_VALUE") @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class SplitNode extends AbstractSplitNode { protected int find(byte[] bytes, int len, byte[] sep, int start, int end) { @@ -1760,7 +1757,6 @@ protected List splitDelimiter(byte[] bytes, int len, byte[] sep, int max @ArgumentClinic(name = "sep", conversionClass = ExpectByteLikeNode.class, defaultValue = "BytesCommonBuiltins.AbstractSplitNode.WHITESPACE") @ArgumentClinic(name = "maxsplit", conversionClass = ExpectIntNode.class, defaultValue = "Integer.MAX_VALUE") @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class RSplitNode extends AbstractSplitNode { protected int find(byte[] bytes, int len, byte[] sep, int start, int end) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java index a14a8f779e..94785edf82 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java @@ -97,7 +97,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.formatting.ComplexFormatter; import com.oracle.graal.python.runtime.formatting.InternalFormat; @@ -611,7 +611,7 @@ private static PComplex complexToComplexBoundary(double leftRead, double leftIma @GenerateInline @GenerateCached(false) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerAndFloatTypes.class) abstract static class ComplexEqNode extends Node { public abstract Object execute(Node inliningTarget, Object left, Object right); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java index fd44d02fcc..17854e35d6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java @@ -88,7 +88,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaDoubleNode; import com.oracle.graal.python.runtime.exception.PException; @@ -480,7 +479,6 @@ protected Object op(double self) { @Builtin(name = "fromhex", minNumOfPositionalArgs = 2, isClassmethod = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class FromHexNode extends PythonBuiltinNode { @TruffleBoundary @@ -909,7 +907,6 @@ protected Object op(double arg) { @Builtin(name = J___FLOOR__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class FloorNode extends PythonUnaryBuiltinNode { @Specialization static Object floor(Object self, @@ -922,7 +919,6 @@ static Object floor(Object self, @Builtin(name = J___CEIL__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class CeilNode extends PythonUnaryBuiltinNode { @Specialization static Object ceil(Object self, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java index 3b7cf6e569..80081e8bea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java @@ -58,7 +58,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; @@ -68,7 +67,6 @@ import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -112,7 +110,6 @@ static TruffleString setQualname(@SuppressWarnings("unused") PBuiltinFunction se } @Builtin(name = J___OBJCLASS__, minNumOfPositionalArgs = 1, isGetter = true) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory public abstract static class ObjclassNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getEnclosingType() == null") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java index fde1aecc90..bfaf3ba982 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java @@ -76,7 +76,6 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -88,7 +87,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -118,7 +116,6 @@ static Object doFunction(PFunction self, @SuppressWarnings("unused") PNone insta } @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java index 591a6b8b28..cb85579bf7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java @@ -59,7 +59,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -67,7 +66,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(extendClasses = PythonBuiltinClassType.PBuiltinFunction) @@ -114,7 +112,6 @@ static Object doBuiltinFunction(PBuiltinFunction self, Object instance, Object k } @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getEnclosingType() == null") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java index 973253baff..ce2ee82afd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java @@ -59,7 +59,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -67,7 +66,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(extendClasses = PythonBuiltinClassType.WrapperDescriptor) @@ -108,7 +106,6 @@ static Object doBuiltinFunction(PBuiltinFunction self, Object instance, Object k } @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) - @TypeSystemReference(PythonArithmeticTypes.class) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index cac36977a7..6681cda914 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -112,7 +112,7 @@ import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.formatting.FloatFormatter; @@ -177,7 +177,7 @@ protected List> getNodeFa @Builtin(name = J___ROUND__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) @GenerateNodeFactory @ImportStatic(MathGuards.class) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class RoundNode extends PythonBinaryBuiltinNode { @SuppressWarnings("unused") @Specialization @@ -359,7 +359,7 @@ private static BigDecimal op(BigInteger arg, int n) { @Slot(value = SlotKind.nb_add, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class AddNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @@ -443,7 +443,7 @@ public static AddNode create() { @Slot(value = SlotKind.nb_subtract, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class SubNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @@ -527,7 +527,7 @@ public static SubNode create() { @Slot(value = SlotKind.nb_true_divide, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class TrueDivNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @@ -637,7 +637,7 @@ public static TrueDivNode create() { } @Slot(value = SlotKind.nb_floor_divide, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class FloorDivNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @@ -810,7 +810,7 @@ static Object doGeneric(VirtualFrame frame, Object left, Object right, } @Slot(value = SlotKind.nb_remainder, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class ModNode extends BinaryOpBuiltinNode { public abstract int executeInt(int left, int right) throws UnexpectedResultException; @@ -972,7 +972,7 @@ public static ModNode create() { @Slot(value = SlotKind.nb_multiply, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class MulNode extends BinaryOpBuiltinNode { public abstract Object execute(int left, int right); @@ -1084,7 +1084,7 @@ public static MulNode create() { @Slot(value = SlotKind.nb_power, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @ImportStatic(MathGuards.class) @ReportPolymorphism public abstract static class PowNode extends PythonTernaryBuiltinNode { @@ -1423,7 +1423,7 @@ static int absBoolean(boolean arg) { @Builtin(name = J___CEIL__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class CeilNode extends PythonUnaryBuiltinNode { @Specialization static int ceil(int arg) { @@ -1443,7 +1443,7 @@ static PInt ceil(PInt arg) { @Builtin(name = J___FLOOR__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class FloorNode extends PythonUnaryBuiltinNode { @Specialization static int floor(int arg) { @@ -1568,7 +1568,7 @@ static BigInteger not(BigInteger value) { @Slot(value = SlotKind.nb_lshift, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class LShiftNode extends BinaryOpBuiltinNode { public abstract int executeInt(int left, int right) throws UnexpectedResultException; @@ -1795,7 +1795,7 @@ public static LShiftNode create() { } @Slot(value = SlotKind.nb_rshift, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class RShiftNode extends BinaryOpBuiltinNode { public abstract int executeInt(int left, int right) throws UnexpectedResultException; @@ -2017,7 +2017,7 @@ static PNotImplemented doGeneric(Object a, Object b) { } @Slot(value = SlotKind.nb_and, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class AndNode extends BinaryBitwiseNode { @@ -2044,7 +2044,7 @@ public static AndNode create() { } @Slot(value = SlotKind.nb_or, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class OrNode extends BinaryBitwiseNode { @@ -2071,7 +2071,7 @@ public static OrNode create() { } @Slot(value = SlotKind.nb_xor, isComplex = true) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory public abstract static class XorNode extends BinaryBitwiseNode { @Override @@ -2098,7 +2098,7 @@ public static XorNode create() { @Builtin(name = J___EQ__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class EqNode extends PythonBinaryBuiltinNode { @Specialization static boolean eqLL(long a, long b) { @@ -2234,7 +2234,7 @@ static PNotImplemented eq(Object a, Object b) { @Builtin(name = J___NE__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class NeNode extends PythonBinaryBuiltinNode { @Specialization static boolean eqLL(long a, long b) { @@ -2283,7 +2283,7 @@ static PNotImplemented eq(Object a, Object b) { @Builtin(name = J___LT__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) @ImportStatic(FromNativeSubclassNode.class) public abstract static class LtNode extends PythonBinaryBuiltinNode { @Specialization @@ -2365,7 +2365,7 @@ static PNotImplemented doGeneric(Object a, Object b) { @Builtin(name = J___LE__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class LeNode extends PythonBinaryBuiltinNode { @Specialization static boolean doII(int left, int right) { @@ -2409,7 +2409,7 @@ static PNotImplemented doGeneric(Object a, Object b) { @Builtin(name = J___GT__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class GtNode extends PythonBinaryBuiltinNode { @Specialization @@ -2454,7 +2454,7 @@ static PNotImplemented doGeneric(Object a, Object b) { @Builtin(name = J___GE__, minNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class GeNode extends PythonBinaryBuiltinNode { @Specialization @@ -2499,7 +2499,7 @@ static PNotImplemented doGeneric(Object a, Object b) { @GenerateInline @GenerateCached(false) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class RichCompareHelperNode extends Node { abstract Object execute(Node inliningTarget, Object left, Object right, ComparisonOp op); @@ -2568,7 +2568,7 @@ static Object doCached(Object left, Object right, @SuppressWarnings("unused") in @ArgumentClinic(name = "signed", conversion = ClinicConversion.Boolean, defaultValue = "false") @GenerateNodeFactory @SuppressWarnings("unused") - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class ToBytesNode extends PythonClinicBuiltinNode { @TruffleBoundary @@ -2828,7 +2828,7 @@ static boolean toBoolean(PythonNativeVoidPtr self, @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class StrNode extends PythonBuiltinNode { @Specialization @@ -2906,7 +2906,7 @@ protected ArgumentClinicProvider getArgumentClinic() { return FormatNodeClinicProviderGen.INSTANCE; } - // We cannot use PythonArithmeticTypes, because for empty format string we need to call the + // We cannot use PythonIntegerTypes, because for empty format string we need to call the // boolean's __str__ and not int's __str__ (that specialization is inherited) @Specialization(guards = "!formatString.isEmpty()") static TruffleString formatB(boolean self, TruffleString formatString, @@ -3003,7 +3003,7 @@ private static void validateIntegerSpec(Node inliningTarget, PRaiseNode raiseNod @Builtin(name = J___HASH__, minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class HashNode extends PythonUnaryBuiltinNode { @Specialization @@ -3043,7 +3043,7 @@ private static long hashCodeBoundary(Object object) { @Builtin(name = "bit_count", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class BitCountNode extends PythonBuiltinNode { @Specialization static int bitCount(int i) { @@ -3064,7 +3064,7 @@ static int bitCount(PInt i) { @Builtin(name = "bit_length", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class BitLengthNode extends PythonUnaryBuiltinNode { public abstract int execute(Object argument); @@ -3087,7 +3087,7 @@ static int bitLength(PInt argument) { @Builtin(name = "is_integer", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class IsIntegerNode extends PythonUnaryBuiltinNode { @Specialization static boolean doLong(long argument) { @@ -3180,7 +3180,7 @@ static Object doI(Object self, @Slot(value = SlotKind.nb_float, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class FloatNode extends PythonUnaryBuiltinNode { @Specialization static double doBoolean(boolean self) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java index 370ecb228a..e40525b5af 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mmap/MMapBuiltins.java @@ -114,7 +114,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.function.builtins.clinic.LongIndexConverterNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.runtime.AsyncHandler; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PosixSupport; @@ -135,7 +134,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; @@ -471,7 +469,6 @@ static long readline(PMMap self) { @Builtin(name = "read_byte", minNumOfPositionalArgs = 1) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ReadByteNode extends PythonUnaryBuiltinNode { @Specialization @@ -496,7 +493,6 @@ static int readByte(VirtualFrame frame, PMMap self, @Builtin(name = "read", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class ReadNode extends PythonBuiltinNode { @Specialization @@ -659,7 +655,6 @@ static Object seek(PMMap self, long dist, int how, @Builtin(name = "find", minNumOfPositionalArgs = 2, parameterNames = {"$self", "sub", "start", "end"}) @ArgumentClinic(name = "sub", conversion = ClinicConversion.ReadableBuffer) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class FindNode extends PythonQuaternaryClinicBuiltinNode { private static final int BUFFER_SIZE = 1024; // keep in sync with test_mmap.py diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java index beed98da00..bf12a815e4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/random/RandomBuiltins.java @@ -67,7 +67,7 @@ import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.nodes.util.CastToJavaUnsignedLongNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.object.PFactory; @@ -91,7 +91,7 @@ protected List> getNodeFa @Builtin(name = "seed", minNumOfPositionalArgs = 1, parameterNames = {"$self", "seed"}) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) public abstract static class SeedNode extends PythonBuiltinNode { @Specialization @TruffleBoundary diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java index 79c58f9caa..3e678b5c7a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java @@ -88,7 +88,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaBigIntegerNode; import com.oracle.graal.python.runtime.exception.PException; @@ -631,7 +631,7 @@ public static GetItemNode getUncached() { @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2) @GenerateNodeFactory @ImportStatic(PGuards.class) - @TypeSystemReference(PythonArithmeticTypes.class) + @TypeSystemReference(PythonIntegerTypes.class) abstract static class ContainsNode extends PythonBinaryBuiltinNode { private static final BigInteger MINUS_ONE = BigInteger.ONE.negate(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java index 86d8a854e1..812fbc7876 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLContextBuiltins.java @@ -122,7 +122,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonQuaternaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; @@ -143,7 +142,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; @@ -551,7 +549,6 @@ protected ArgumentClinicProvider getArgumentClinic() { @Builtin(name = "num_tickets", minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2, isGetter = true, isSetter = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class NumTicketsNode extends PythonBinaryBuiltinNode { @SuppressWarnings("unused") @Specialization(guards = "isNoValue(value)") @@ -712,7 +709,6 @@ static Object storeStats(VirtualFrame frame, PSSLContext self, @Builtin(name = "load_verify_locations", minNumOfPositionalArgs = 1, parameterNames = {"$self", "cafile", "capath", "cadata"}) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class LoadVerifyLocationsNode extends PythonQuaternaryBuiltinNode { @Specialization Object load(VirtualFrame frame, PSSLContext self, Object cafile, Object capath, Object cadata, @@ -835,7 +831,6 @@ private static Collection fromBytesLike(byte[] bytes) { @Builtin(name = "load_cert_chain", minNumOfPositionalArgs = 2, parameterNames = {"$self", "certfile", "keyfile", "password"}) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class LoadCertChainNode extends PythonQuaternaryBuiltinNode { @Specialization Object load(VirtualFrame frame, PSSLContext self, Object certfile, Object keyfile, Object passwordObj, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java index a525f5a831..91aa28c98c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java @@ -154,7 +154,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; @@ -184,7 +183,6 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @@ -234,7 +232,6 @@ static TruffleString doGeneric(Object self, @Builtin(name = J___FORMAT__, minNumOfPositionalArgs = 2, parameterNames = {"$self", "format_spec"}) @ArgumentClinic(name = "format_spec", conversion = ClinicConversion.TString) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class FormatNode extends FormatNodeBase { @Override protected ArgumentClinicProvider getArgumentClinic() { @@ -1763,7 +1760,6 @@ static int rindex(Object selfObj, Object subObj, int start, int end, @ArgumentClinic(name = "encoding", conversion = ClinicConversion.TString, defaultValue = "T_UTF8", useDefaultForNone = true) @ArgumentClinic(name = "errors", conversion = ClinicConversion.TString, defaultValue = "T_STRICT", useDefaultForNone = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class EncodeNode extends PythonTernaryClinicBuiltinNode { @Override @@ -1794,7 +1790,6 @@ static Object doIt(VirtualFrame frame, Object selfObj, TruffleString encoding, T @Slot(value = SlotKind.sq_repeat, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) abstract static class MulNode extends SqRepeatBuiltinNode { @Specialization(guards = "right <= 0") @@ -2412,7 +2407,6 @@ static Object doIt(VirtualFrame frame, Object self, int index, @Slot(value = SlotKind.mp_subscript, isComplex = true) @GenerateNodeFactory - @TypeSystemReference(PythonArithmeticTypes.class) public abstract static class StrGetItemNode extends MpSubscriptBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 5aed080f1e..2c0ccc6716 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -58,6 +58,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.graal.python.util.OverflowException; @@ -72,6 +73,7 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; @@ -80,14 +82,13 @@ @GenerateCached(false) @ImportStatic(PGuards.class) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberAddBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, but it additionally needs to check PInts for only builtin ints */ - // XXX this could benefit from the type system conversions, but that would also unpack PFloat - // which we don't want @Specialization(rewriteOn = ArithmeticException.class) static int doII(int left, int right) { @@ -163,16 +164,6 @@ public static double doDL(double left, long right) { public static double doLD(long left, double right) { return left + right; } - - @Specialization - public static double doDI(double left, int right) { - return left + right; - } - - @Specialization - public static double doID(int left, double right) { - return left + right; - } } @GenerateInline(inlineByDefault = true) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java index 76f2d6e886..ebd030ea24 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyTimeFromObjectNode.java @@ -47,7 +47,7 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaDoubleNode; import com.oracle.graal.python.runtime.exception.PException; @@ -66,7 +66,7 @@ /** * Equivalent of {@code _PyTime_FromObject} from CPython. */ -@TypeSystemReference(PythonArithmeticTypes.class) +@TypeSystemReference(PythonIntegerAndFloatTypes.class) @GenerateInline @GenerateCached(false) public abstract class PyTimeFromObjectNode extends PNodeWithContext { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java index 63b453e941..8e0bf95150 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryComparisonNode.java @@ -41,7 +41,7 @@ import com.oracle.graal.python.nodes.expression.BinaryComparisonNodeFactory.LtNodeGen; import com.oracle.graal.python.nodes.expression.BinaryComparisonNodeFactory.NeNodeGen; import com.oracle.graal.python.nodes.object.IsNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.NeverDefault; @@ -52,7 +52,7 @@ import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; -@TypeSystemReference(PythonArithmeticTypes.class) +@TypeSystemReference(PythonIntegerTypes.class) public abstract class BinaryComparisonNode extends BinaryOpNode { private abstract static class ErrorNode extends BinaryComparisonNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerAndFloatTypes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerAndFloatTypes.java new file mode 100644 index 0000000000..fe6433b80f --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerAndFloatTypes.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025, 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.graal.python.builtins.objects.floats.PFloat; +import com.oracle.truffle.api.dsl.ImplicitCast; +import com.oracle.truffle.api.dsl.TypeSystem; + +/** + * Type system that automatically unpacks PFloat object to the contained double value. Should only + * be used in nodes where CPython directly accesses f_val. + */ +@TypeSystem +public class PythonIntegerAndFloatTypes extends PythonIntegerTypes { + @ImplicitCast + public static double PFloatToDouble(PFloat value) { + // NOTE: That's correct because we just use it in arithmetic operations where CPython also + // access the value ('f_val') directly. So, even if the object is subclassed, it is ignored. + return value.getValue(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonArithmeticTypes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerTypes.java similarity index 50% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonArithmeticTypes.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerTypes.java index c8b5d6b682..054c7a4508 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonArithmeticTypes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -25,34 +25,16 @@ */ package com.oracle.graal.python.nodes.truffle; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject; -import com.oracle.graal.python.builtins.objects.floats.PFloat; -import com.oracle.graal.python.nodes.PGuards; import com.oracle.truffle.api.dsl.ImplicitCast; -import com.oracle.truffle.api.dsl.TypeCast; -import com.oracle.truffle.api.dsl.TypeCheck; import com.oracle.truffle.api.dsl.TypeSystem; /** * This type system is supposed to be used in builtin nodes to reduce the number of specializations - * due to type combinations. A node that needs to handle all combinations of Python {@code int} and - * {@code float} types can just use the most general primitive type, i.e., in case of Python type - * {@code int} use Java {@code long} and in case of Python type {@code float} use Java - * {@code double}. {@code PInt} needs to be treated separately because of its arbitrary precision. - * - * Only use in nodes where it is known that {@code PInt} and {@code PFloat} objects are not - * subclassed! + * due to type combinations. Booleans and ints are converted to long. PInt needs to be handled + * separately. */ @TypeSystem -public abstract class PythonArithmeticTypes { - - @ImplicitCast - public static double PFloatToDouble(PFloat value) { - // NOTE: That's correct because we just use it in arithmetic operations where CPython also - // access the value ('f_val') directly. So, even if the object is subclassed, it is ignored. - return value.getValue(); - } +public abstract class PythonIntegerTypes { @ImplicitCast public static int booleanToInt(boolean value) { @@ -68,24 +50,4 @@ public static long booleanToLong(boolean value) { public static long intToLong(int value) { return value; } - - @TypeCheck(PythonNativeObject.class) - public static boolean isNativeObject(Object object) { - return PythonNativeObject.isInstance(object); - } - - @TypeCast(PythonNativeObject.class) - public static PythonNativeObject asNativeObject(Object object) { - return PythonNativeObject.cast(object); - } - - @TypeCheck(PythonNativeClass.class) - public static boolean isNativeClass(Object object) { - return PGuards.isNativeClass(object); - } - - @TypeCast(PythonNativeClass.class) - public static PythonNativeClass asNativeClass(Object object) { - return PythonNativeClass.cast(object); - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java index 00e3280a87..2b1f875931 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaBigIntegerNode.java @@ -51,7 +51,6 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; @@ -59,10 +58,8 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; -@TypeSystemReference(PythonArithmeticTypes.class) @GenerateUncached @GenerateInline(inlineByDefault = true) @GenerateCached diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaDoubleNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaDoubleNode.java index baadf51e10..7f9f6b80e1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaDoubleNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaDoubleNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -50,7 +50,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; @@ -73,8 +73,8 @@ @GenerateUncached @GenerateInline @GenerateCached(false) -@TypeSystemReference(PythonArithmeticTypes.class) @ImportStatic(MathGuards.class) +@TypeSystemReference(PythonIntegerAndFloatTypes.class) public abstract class CastToJavaDoubleNode extends PNodeWithContext { public abstract double execute(Node inliningTarget, Object x); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntNode.java index d9584d01b7..7ab4b8ba5f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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.modules.MathGuards; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -51,7 +51,7 @@ import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; -@TypeSystemReference(PythonArithmeticTypes.class) +@TypeSystemReference(PythonIntegerTypes.class) @ImportStatic(MathGuards.class) @GenerateInline @GenerateCached(false) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java index 44f8d1bf73..c825a8e1ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaUnsignedLongNode.java @@ -49,7 +49,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -72,7 +72,7 @@ * Note that since Java {@code long} is signed, the values in the between 2^63 and 2^64-1 are * returned as negative numbers. */ -@TypeSystemReference(PythonArithmeticTypes.class) +@TypeSystemReference(PythonIntegerTypes.class) @GenerateUncached @GenerateInline @GenerateCached(false) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java index 94265ee82b..848adfa7c2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CoerceToComplexNode.java @@ -51,7 +51,7 @@ import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; -import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes; +import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -65,7 +65,7 @@ @GenerateInline @GenerateCached(false) -@TypeSystemReference(PythonArithmeticTypes.class) +@TypeSystemReference(PythonIntegerAndFloatTypes.class) @ImportStatic(PGuards.class) public abstract class CoerceToComplexNode extends PNodeWithContext { diff --git a/mx.graalpython/copyrights/overrides b/mx.graalpython/copyrights/overrides index 99a7d617eb..e385ca0023 100644 --- a/mx.graalpython/copyrights/overrides +++ b/mx.graalpython/copyrights/overrides @@ -697,7 +697,7 @@ graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/BuiltinFunctionRootNode.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/PythonBuiltinNode.java,zippy.copyright -graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonArithmeticTypes.java,zippy.copyright +graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerTypes.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java,zippy.copyright From e0be41d49f0adeec7b6212b483a709f8ab6a457b Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 12:07:13 +0100 Subject: [PATCH 036/512] Remove PythonTypes --- .../cext/PythonCextAbstractBuiltins.java | 3 - .../modules/cext/PythonCextSetBuiltins.java | 3 - .../cext/PythonCextUnicodeBuiltins.java | 14 ++--- .../cext/capi/ExternalFunctionNodes.java | 5 +- .../builtins/objects/type/TypeBuiltins.java | 18 +++--- .../builtins/objects/type/TypeNodes.java | 5 +- .../graal/python/nodes/call/CallNode.java | 3 - .../call/special/AbstractCallMethodNode.java | 3 - .../python/nodes/object/GetClassNode.java | 5 +- .../nodes/object/IsForeignObjectNode.java | 5 +- .../python/nodes/truffle/PythonTypes.java | 63 ------------------- mx.graalpython/copyrights/overrides | 1 - 12 files changed, 15 insertions(+), 113 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 56e6b7ef98..6cfaff3a52 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -155,7 +155,6 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.exception.PythonErrorType; @@ -167,7 +166,6 @@ import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -645,7 +643,6 @@ static Object setItem(Object obj, long key, Object value, } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Py_ssize_t, Py_ssize_t}, call = Direct) - @TypeSystemReference(PythonTypes.class) abstract static class PySequence_GetSlice extends CApiTernaryBuiltinNode { @Specialization(guards = "checkNode.execute(inliningTarget, obj)", limit = "1") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java index e52002b3f0..e3468a04ed 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextSetBuiltins.java @@ -79,14 +79,12 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; @@ -134,7 +132,6 @@ int fallback(@SuppressWarnings("unused") Object anyset, @SuppressWarnings("unuse } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Py_ssize_t}, call = Ignored) - @TypeSystemReference(PythonTypes.class) abstract static class _PyTruffleSet_NextEntry extends CApiBinaryBuiltinNode { @Specialization(guards = "pos < size(inliningTarget, set, sizeNode)") static Object nextEntry(PSet set, long pos, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java index 7e162ce88c..35a98ccc94 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextUnicodeBuiltins.java @@ -145,7 +145,6 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.exception.PException; @@ -160,7 +159,6 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.interop.InteropException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.library.CachedLibrary; @@ -377,11 +375,10 @@ static Object find(Object format, @SuppressWarnings("unused") Object args, } @CApiBuiltin(ret = Py_ssize_t, args = {PyObject, PY_UCS4, Py_ssize_t, Py_ssize_t, Int}, call = Direct) - @TypeSystemReference(PythonTypes.class) @ImportStatic(PythonCextUnicodeBuiltins.class) abstract static class PyUnicode_FindChar extends CApi5BuiltinNode { @Specialization(guards = {"isString(string) || isStringSubtype(inliningTarget, string, getClassNode, isSubtypeNode)", "direction > 0"}) - static Object find(Object string, Object c, long start, long end, @SuppressWarnings("unused") long direction, + static Object find(Object string, Object c, long start, long end, @SuppressWarnings("unused") int direction, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached ChrNode chrNode, @Cached FindNode findNode, @@ -391,7 +388,7 @@ static Object find(Object string, Object c, long start, long end, @SuppressWarni } @Specialization(guards = {"isString(string) || isStringSubtype(inliningTarget, string, getClassNode, isSubtypeNode)", "direction <= 0"}) - static Object find(Object string, Object c, long start, long end, @SuppressWarnings("unused") long direction, + static Object find(Object string, Object c, long start, long end, @SuppressWarnings("unused") int direction, @SuppressWarnings("unused") @Bind("this") Node inliningTarget, @Shared @Cached ChrNode chrNode, @Cached RFindNode rFindNode, @@ -411,7 +408,6 @@ static Object find(Object string, @SuppressWarnings("unused") Object c, @Suppres } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Py_ssize_t, Py_ssize_t}, call = Direct) - @TypeSystemReference(PythonTypes.class) @ImportStatic(PythonCextUnicodeBuiltins.class) abstract static class PyUnicode_Substring extends CApiTernaryBuiltinNode { @Specialization(guards = {"isString(s) || isStringSubtype(s, inliningTarget, getClassNode, isSubtypeNode)"}, limit = "1") @@ -526,11 +522,10 @@ static Object compare(Object left, Object right, } @CApiBuiltin(ret = Py_ssize_t, args = {PyObject, PyObject, Py_ssize_t, Py_ssize_t, Int}, call = Direct) - @TypeSystemReference(PythonTypes.class) @ImportStatic(PythonCextUnicodeBuiltins.class) abstract static class PyUnicode_Tailmatch extends CApi5BuiltinNode { @Specialization(guards = {"isAnyString(inliningTarget, string, getClassNode, isSubtypeNode)", "isAnyString(inliningTarget, substring, getClassNode, isSubtypeNode)", "direction > 0"}) - static int tailmatch(Object string, Object substring, long start, long end, @SuppressWarnings("unused") long direction, + static int tailmatch(Object string, Object substring, long start, long end, @SuppressWarnings("unused") int direction, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectLookupAttr lookupAttrNode, @Shared @Cached PySliceNew sliceNode, @@ -544,7 +539,7 @@ static int tailmatch(Object string, Object substring, long start, long end, @Sup } @Specialization(guards = {"isAnyString(inliningTarget, string, getClassNode, isSubtypeNode)", "isAnyString(inliningTarget, substring, getClassNode, isSubtypeNode)", "direction <= 0"}) - static int tailmatch(Object string, Object substring, long start, long end, @SuppressWarnings("unused") long direction, + static int tailmatch(Object string, Object substring, long start, long end, @SuppressWarnings("unused") int direction, @Bind("this") Node inliningTarget, @Shared @Cached PyObjectLookupAttr lookupAttrNode, @Shared @Cached PySliceNew sliceNode, @@ -589,7 +584,6 @@ static Object encode(@SuppressWarnings("unused") Object obj, @SuppressWarnings(" } @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject, Py_ssize_t}, call = Direct) - @TypeSystemReference(PythonTypes.class) @ImportStatic(PythonCextUnicodeBuiltins.class) abstract static class PyUnicode_Replace extends CApiQuaternaryBuiltinNode { @Specialization(guards = {"isString(s)", "isString(substr)", "isString(replstr)"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java index 419eabe0a2..a90f7e1ce4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ExternalFunctionNodes.java @@ -118,7 +118,6 @@ import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; @@ -152,7 +151,6 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; @@ -2255,7 +2253,6 @@ static void doObjectGeneric(NativeObjectSequenceStorage storage, * Special helper nodes that materializes any primitive that would leak the wrapper if the * reference is owned by managed code only. */ - @TypeSystemReference(PythonTypes.class) @GenerateInline(false) abstract static class MaterializePrimitiveNode extends Node { @@ -2268,7 +2265,7 @@ static PInt doInteger(PythonLanguage language, int i) { return PFactory.createInt(language, i); } - @Specialization(replaces = "doInteger") + @Specialization static PInt doLong(PythonLanguage language, long l) { return PFactory.createInt(language, l); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java index 9268bd9af5..46d1be5146 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java @@ -92,7 +92,6 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.bytes.PBytes; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass; import com.oracle.graal.python.builtins.objects.cext.capi.PySequenceArrayWrapper; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; @@ -168,7 +167,6 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.nodes.util.SplitArgsNode; @@ -194,7 +192,6 @@ import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.BranchProfile; @@ -278,7 +275,7 @@ static Object getDoc(VirtualFrame frame, PythonClass self, @SuppressWarnings("un } @Specialization - static Object getDoc(PythonNativeClass self, @SuppressWarnings("unused") PNone value) { + static Object getDoc(PythonAbstractNativeObject self, @SuppressWarnings("unused") PNone value) { return ReadAttributeFromObjectNode.getUncachedForceType().execute(self, T___DOC__); } @@ -559,7 +556,7 @@ protected Object doIt1(VirtualFrame frame, @SuppressWarnings("unused") PythonAbs @Shared @Cached BindNew bindNew, @Shared @Cached PRaiseNode raiseNode) { checkFlags(self, inliningTarget, getTypeFlagsNode, raiseNode); - return op(frame, inliningTarget, PythonNativeClass.cast(cachedSelf), arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); + return op(frame, inliningTarget, cachedSelf, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } @Specialization(replaces = "doIt1") @@ -572,7 +569,7 @@ protected Object doItIndirect1(VirtualFrame frame, PythonAbstractNativeObject se @Shared @Cached BindNew bindNew, @Shared @Cached PRaiseNode raiseNode) { checkFlags(self, inliningTarget, getTypeFlagsNode, raiseNode); - return op(frame, inliningTarget, PythonNativeClass.cast(self), arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); + return op(frame, inliningTarget, self, arguments, keywords, getInstanceClassNode, hasInit, gotInitResult, bindNew, raiseNode); } private void checkFlags(PythonAbstractNativeObject self, Node inliningTarget, GetTypeFlagsNode getTypeFlagsNode, PRaiseNode raiseNode) { @@ -907,7 +904,7 @@ static Object doManaged(PythonManagedClass self, } @Specialization - static Object doNative(PythonNativeClass self, + static Object doNative(PythonAbstractNativeObject self, @Cached CStructAccess.ReadObjectNode getTpDictNode) { return getTpDictNode.readFromObj(self, CFields.PyTypeObject__tp_dict); } @@ -1050,7 +1047,6 @@ static PList getSubclasses(Object cls, } @GenerateNodeFactory - @TypeSystemReference(PythonTypes.class) abstract static class AbstractSlotNode extends PythonBinaryBuiltinNode { } @@ -1194,7 +1190,7 @@ static Object setModule(PythonClass cls, Object value, } @Specialization(guards = "isNoValue(value)") - static Object getModule(PythonNativeClass cls, @SuppressWarnings("unused") PNone value, + static Object getModule(PythonAbstractNativeObject cls, @SuppressWarnings("unused") PNone value, @Bind("this") Node inliningTarget, @Cached("createForceType()") ReadAttributeFromObjectNode readAttr, @Shared @Cached GetTypeFlagsNode getFlags, @@ -1223,7 +1219,7 @@ static Object getModule(PythonNativeClass cls, @SuppressWarnings("unused") PNone } @Specialization(guards = "!isNoValue(value)") - static Object setNative(PythonNativeClass cls, Object value, + static Object setNative(PythonAbstractNativeObject cls, Object value, @Bind("this") Node inliningTarget, @Shared @Cached GetTypeFlagsNode getFlags, @Cached("createForceType()") WriteAttributeToObjectNode writeAttr, @@ -1263,7 +1259,7 @@ static TruffleString getName(PythonManagedClass cls, @SuppressWarnings("unused") } @Specialization(guards = "isNoValue(value)") - static Object getNative(PythonNativeClass cls, @SuppressWarnings("unused") PNone value, + static Object getNative(PythonAbstractNativeObject cls, @SuppressWarnings("unused") PNone value, @Cached GetTypeFlagsNode getTypeFlagsNode, @Cached CStructAccess.ReadObjectNode getHtName, @Cached CStructAccess.ReadCharPtrNode getTpNameNode, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java index d10697b51f..89d5bf5c7c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java @@ -200,7 +200,6 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; @@ -232,7 +231,6 @@ import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.InteropLibrary; @@ -767,7 +765,6 @@ static TruffleString getQualName(Node inliningTarget, PythonAbstractNativeObject } } - @TypeSystemReference(PythonTypes.class) @GenerateUncached @GenerateInline @GenerateCached(false) @@ -820,7 +817,7 @@ static PDict doPythonClass(Node inliningTarget, PythonBuiltinClassType obj) { } @Specialization - static PDict doNativeClass(Node inliningTarget, PythonNativeClass obj, + static PDict doNativeClass(Node inliningTarget, PythonAbstractNativeObject obj, @Cached(inline = false) CStructAccess.ReadObjectNode getTpSubclassesNode, @Cached InlinedExactClassProfile profile) { Object tpSubclasses = getTpSubclassesNode.readFromObj(obj, PyTypeObject__tp_subclasses); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java index 2677b7ea7c..3c7b04830e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java @@ -59,7 +59,6 @@ import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.util.PythonUtils; @@ -75,7 +74,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.ReportPolymorphism.Megamorphic; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; @@ -87,7 +85,6 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; -@TypeSystemReference(PythonTypes.class) @ImportStatic({PGuards.class, SpecialMethodNames.class}) @GenerateUncached @SuppressWarnings("truffle-inlining") // footprint reduction 60 -> 44 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java index 0d52b0e88b..62545c1325 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/AbstractCallMethodNode.java @@ -67,7 +67,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.util.PythonUtils.NodeCounterWithLimit; import com.oracle.truffle.api.CompilerAsserts; @@ -77,12 +76,10 @@ import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.NodeField; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.RootNode; -@TypeSystemReference(PythonTypes.class) @ImportStatic({PythonOptions.class, PGuards.class}) @NodeField(name = "maxSizeExceeded", type = boolean.class) abstract class AbstractCallMethodNode extends PNodeWithContext { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java index 966bcf711b..accbcc9309 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -55,7 +55,6 @@ import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -65,12 +64,10 @@ import com.oracle.truffle.api.dsl.Idempotent; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.strings.TruffleString; -@TypeSystemReference(PythonTypes.class) @GenerateUncached @GenerateInline(inlineByDefault = true) public abstract class GetClassNode extends PNodeWithContext { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsForeignObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsForeignObjectNode.java index b34fda5084..8dfe622eb8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsForeignObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsForeignObjectNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -43,13 +43,11 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.truffle.PythonTypes; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; @@ -57,7 +55,6 @@ * Checks whether the object is a foreign object, i.e. is neither a python primitive value, nor a * python object. */ -@TypeSystemReference(PythonTypes.class) @GenerateUncached @GenerateInline @GenerateCached(false) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java deleted file mode 100644 index 7815ff437a..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. - * Copyright (c) 2013, Regents of the University of California - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other materials provided - * with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.oracle.graal.python.nodes.truffle; - -import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.truffle.api.dsl.ImplicitCast; -import com.oracle.truffle.api.dsl.TypeCast; -import com.oracle.truffle.api.dsl.TypeCheck; -import com.oracle.truffle.api.dsl.TypeSystem; - -@TypeSystem -public abstract class PythonTypes { - - @ImplicitCast - public static long intToLong(int value) { - return value; - } - - @TypeCheck(PythonNativeObject.class) - public static boolean isNativeObject(Object object) { - return PythonNativeObject.isInstance(object); - } - - @TypeCast(PythonNativeObject.class) - public static PythonNativeObject asNativeObject(Object object) { - return PythonNativeObject.cast(object); - } - - @TypeCheck(PythonNativeClass.class) - public static boolean isNativeClass(Object object) { - return PGuards.isNativeClass(object); - } - - @TypeCast(PythonNativeClass.class) - public static PythonNativeClass asNativeClass(Object object) { - return PythonNativeClass.cast(object); - } -} diff --git a/mx.graalpython/copyrights/overrides b/mx.graalpython/copyrights/overrides index e385ca0023..c7a5988bd7 100644 --- a/mx.graalpython/copyrights/overrides +++ b/mx.graalpython/copyrights/overrides @@ -698,7 +698,6 @@ graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/Read graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/BuiltinFunctionRootNode.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/PythonBuiltinNode.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonIntegerTypes.java,zippy.copyright -graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/truffle/PythonTypes.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java,zippy.copyright graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PythonErrorType.java,zippy.copyright From 53a21571443cb815dbda50d4370c5604d03e1485 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 15:11:05 +0100 Subject: [PATCH 037/512] Add uncached for PyNumber nodes --- .../builtins/objects/ints/IntBuiltins.java | 99 +++++++------------ .../graal/python/lib/PyNumberAddNode.java | 41 +------- .../graal/python/lib/PyNumberAndNode.java | 8 ++ .../python/lib/PyNumberFloorDivideNode.java | 47 +++++---- .../python/lib/PyNumberInPlaceAddNode.java | 2 + .../lib/PyNumberInPlaceFloorDivideNode.java | 2 + .../python/lib/PyNumberInPlaceLshiftNode.java | 11 ++- .../lib/PyNumberInPlaceMultiplyNode.java | 2 + .../lib/PyNumberInPlaceRemainderNode.java | 2 + .../python/lib/PyNumberInPlaceRshiftNode.java | 2 + .../lib/PyNumberInPlaceSubtractNode.java | 2 + .../lib/PyNumberInPlaceTrueDivideNode.java | 2 + .../graal/python/lib/PyNumberLshiftNode.java | 33 +------ .../python/lib/PyNumberMultiplyNode.java | 41 +++++++- .../graal/python/lib/PyNumberOrNode.java | 8 ++ .../python/lib/PyNumberRemainderNode.java | 19 ++-- .../graal/python/lib/PyNumberRshiftNode.java | 5 + .../python/lib/PyNumberSubtractNode.java | 46 ++++++--- .../python/lib/PyNumberTrueDivideNode.java | 40 +++++--- .../graal/python/lib/PyNumberXorNode.java | 8 ++ 20 files changed, 223 insertions(+), 197 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index 6681cda914..9e811dce30 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -157,15 +157,14 @@ public final class IntBuiltins extends PythonBuiltins { public static final TpSlots SLOTS = IntBuiltinsSlotsGen.SLOTS; - private static void raiseDivisionByZero(Node inliningTarget, boolean cond, InlinedBranchProfile divisionByZeroProfile, PRaiseNode raiseNode) { + private static void raiseDivisionByZero(Node inliningTarget, boolean cond, PRaiseNode raiseNode) { if (cond) { - raiseDivisionByZero(inliningTarget, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, raiseNode); } } @InliningCutoff - private static void raiseDivisionByZero(Node inliningTarget, InlinedBranchProfile divisionByZeroProfile, PRaiseNode raiseNode) { - divisionByZeroProfile.enter(inliningTarget); + private static void raiseDivisionByZero(Node inliningTarget, PRaiseNode raiseNode) { throw raiseNode.raise(inliningTarget, PythonErrorType.ZeroDivisionError, ErrorMessages.S_DIVISION_OR_MODULO_BY_ZERO, "integer"); } @@ -452,7 +451,7 @@ static int doII(int x, int y) throws ArithmeticException { return Math.subtractExact(x, y); } - @Specialization + @Specialization(replaces = "doII") static long doIIOvf(int x, int y) { return (long) x - (long) y; } @@ -462,7 +461,7 @@ static long doLL(long x, long y) throws ArithmeticException { return Math.subtractExact(x, y); } - @Specialization + @Specialization(replaces = "doLL") static Object doLongWithOverflow(long x, long y, @Bind("this") Node inliningTarget) { /* Inlined version of Math.subtractExact(x, y) with BigInteger fallback. */ @@ -470,46 +469,46 @@ static Object doLongWithOverflow(long x, long y, // HD 2-12 Overflow iff the arguments have different signs and // the sign of the result is different than the sign of x if (((x ^ y) & (x ^ r)) < 0) { - return PFactory.createInt(PythonLanguage.get(inliningTarget), op(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + return PFactory.createInt(PythonLanguage.get(inliningTarget), sub(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); } return r; } @Specialization(rewriteOn = OverflowException.class) static long doPIntLongAndNarrow(PInt left, long right) throws OverflowException { - return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); + return PInt.longValueExact(sub(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(replaces = "doPIntLongAndNarrow") static PInt doPIntLong(PInt left, long right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); + return PFactory.createInt(language, sub(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) static long doLongPIntAndNarrow(long left, PInt right) throws OverflowException { - return PInt.longValueExact(op(PInt.longToBigInteger(left), right.getValue())); + return PInt.longValueExact(sub(PInt.longToBigInteger(left), right.getValue())); } @Specialization(replaces = "doLongPIntAndNarrow") static PInt doLongPInt(long left, PInt right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); + return PFactory.createInt(language, sub(PInt.longToBigInteger(left), right.getValue())); } @Specialization(rewriteOn = OverflowException.class) static long doPIntPIntAndNarrow(PInt left, PInt right) throws OverflowException { - return PInt.longValueExact(op(left.getValue(), right.getValue())); + return PInt.longValueExact(sub(left.getValue(), right.getValue())); } @Specialization(replaces = "doPIntPIntAndNarrow") static PInt doPIntPInt(PInt left, PInt right, @Bind PythonLanguage language) { - return PFactory.createInt(language, op(left.getValue(), right.getValue())); + return PFactory.createInt(language, sub(left.getValue(), right.getValue())); } @TruffleBoundary - private static BigInteger op(BigInteger left, BigInteger right) { + public static BigInteger sub(BigInteger left, BigInteger right) { return left.subtract(right); } @@ -616,7 +615,7 @@ private static double op(Node raisingNode, BigInteger a, BigInteger b) { return d; } - protected static boolean fitsIntoDouble(long x) { + public static boolean fitsIntoDouble(long x) { return x < (1L << 52) && x > -(1L << 52); } @@ -648,10 +647,9 @@ public abstract static class FloorDivNode extends BinaryOpBuiltinNode { @Specialization static Object doII(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); if (left == Integer.MIN_VALUE && right == -1) { overflowValueProfile.enter(); return INT_OVERFLOW_VALUE; @@ -662,10 +660,9 @@ static Object doII(int left, int right, @Specialization static Object doLL(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); if (left == Long.MIN_VALUE && right == -1) { overflowValueProfile.enter(); return PFactory.createInt(PythonLanguage.get(inliningTarget), LONG_OVERFLOW_VALUE); @@ -676,12 +673,11 @@ static Object doLL(long left, long right, @Specialization static Object doIPi(int left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, @Shared @Cached PRaiseNode raiseNode) { try { int rightValue = right.intValueExact(); - raiseDivisionByZero(inliningTarget, rightValue == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, rightValue == 0, raiseNode); if (left == Integer.MIN_VALUE && rightValue == -1) { overflowValueProfile.enter(); return INT_OVERFLOW_VALUE; @@ -695,12 +691,11 @@ static Object doIPi(int left, PInt right, @Specialization static Object doLPi(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached BranchProfile overflowValueProfile, @Shared @Cached PRaiseNode raiseNode) { try { long rightValue = right.longValueExact(); - raiseDivisionByZero(inliningTarget, rightValue == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, rightValue == 0, raiseNode); if (left == Long.MIN_VALUE && rightValue == -1) { overflowValueProfile.enter(); return PFactory.createInt(PythonLanguage.get(inliningTarget), LONG_OVERFLOW_VALUE); @@ -714,9 +709,8 @@ static Object doLPi(long left, PInt right, @Specialization(rewriteOn = OverflowException.class) static long doPiIAndNarrow(PInt left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -724,18 +718,16 @@ static long doPiIAndNarrow(PInt left, int right, static PInt doPiI(PInt left, int right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) static long doPiLAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -743,18 +735,16 @@ static long doPiLAndNarrow(PInt left, long right, static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(rewriteOn = OverflowException.class) static long doPiPiAndNarrow(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PInt.longValueExact(op(left.getValue(), right.getValue())); } @@ -762,9 +752,8 @@ static long doPiPiAndNarrow(PInt left, PInt right, static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @@ -820,27 +809,24 @@ public abstract static class ModNode extends BinaryOpBuiltinNode { @Specialization static int doII(int left, int right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return Math.floorMod(left, right); } @Specialization static long doLL(long left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return Math.floorMod(left, right); } @Specialization(guards = "right.isZeroOrPositive()", rewriteOn = OverflowException.class) static long doLPiAndNarrow(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PInt.longValueExact(op(PInt.longToBigInteger(left), right.getValue())); } @@ -848,18 +834,16 @@ static long doLPiAndNarrow(long left, PInt right, static PInt doLPi(long left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PFactory.createInt(language, op(PInt.longToBigInteger(left), right.getValue())); } @Specialization(guards = "!right.isZeroOrPositive()", rewriteOn = OverflowException.class) static long doLPiNegativeAndNarrow(long left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PInt.longValueExact(opNeg(PInt.longToBigInteger(left), right.getValue())); } @@ -867,18 +851,16 @@ static long doLPiNegativeAndNarrow(long left, PInt right, static PInt doLPiNegative(long left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PFactory.createInt(language, opNeg(PInt.longToBigInteger(left), right.getValue())); } @Specialization(guards = "right >= 0", rewriteOn = OverflowException.class) static long doPiLAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PInt.longValueExact(op(left.getValue(), PInt.longToBigInteger(right))); } @@ -886,18 +868,16 @@ static long doPiLAndNarrow(PInt left, long right, static PInt doPiL(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PFactory.createInt(language, op(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(guards = "right < 0", rewriteOn = OverflowException.class) static long doPiLNegAndNarrow(PInt left, long right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PInt.longValueExact(opNeg(left.getValue(), PInt.longToBigInteger(right))); } @@ -905,18 +885,16 @@ static long doPiLNegAndNarrow(PInt left, long right, static PInt doPiLNeg(PInt left, long right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right == 0, divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right == 0, raiseNode); return PFactory.createInt(language, opNeg(left.getValue(), PInt.longToBigInteger(right))); } @Specialization(guards = "right.isZeroOrPositive()", rewriteOn = OverflowException.class) static long doPiPiAndNarrow(PInt left, PInt right, @Bind("this") Node inliningTarget, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) throws OverflowException { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PInt.longValueExact(op(left.getValue(), right.getValue())); } @@ -924,9 +902,8 @@ static long doPiPiAndNarrow(PInt left, PInt right, static PInt doPiPi(PInt left, PInt right, @Bind("this") Node inliningTarget, @Bind PythonLanguage language, - @Shared @Cached InlinedBranchProfile divisionByZeroProfile, @Shared @Cached PRaiseNode raiseNode) { - raiseDivisionByZero(inliningTarget, right.isZero(), divisionByZeroProfile, raiseNode); + raiseDivisionByZero(inliningTarget, right.isZero(), raiseNode); return PFactory.createInt(language, op(left.getValue(), right.getValue())); } @@ -991,7 +968,7 @@ static long doLL(long x, long y) { return Math.multiplyExact(x, y); } - @Specialization + @Specialization(replaces = "doLL") static Object doLongWithOverflow(long x, long y, @Bind("this") Node inliningTarget) { /* Inlined version of Math.multiplyExact(x, y) with BigInteger fallback. */ @@ -1052,7 +1029,7 @@ static PInt doPIntPInt(PInt left, PInt right, } @TruffleBoundary - static BigInteger mul(BigInteger a, BigInteger b) { + public static BigInteger mul(BigInteger a, BigInteger b) { if (!BigInteger.ZERO.equals(b) && b.and(b.subtract(BigInteger.ONE)).equals(BigInteger.ZERO)) { return bigIntegerShift(a, b.getLowestSetBit()); } else { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 2c0ccc6716..2d51703278 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -54,14 +54,12 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.CallSlotBinaryFuncNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -70,7 +68,6 @@ import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.TypeSystemReference; @@ -81,15 +78,13 @@ import com.oracle.truffle.api.strings.TruffleString; @GenerateCached(false) -@ImportStatic(PGuards.class) @TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberAddBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions - * in IntBuiltins, but it additionally needs to check PInts for only builtin ints + * in IntBuiltins */ - @Specialization(rewriteOn = ArithmeticException.class) static int doII(int left, int right) { return Math.addExact(left, right); @@ -112,44 +107,10 @@ static Object doLLOvf(long x, long y, return r; } - @Specialization(guards = "isBuiltinPInt(left)", rewriteOn = OverflowException.class) - static Object doPLNarrow(PInt left, long right) throws OverflowException { - return PInt.longValueExact(add(left.getValue(), PInt.longToBigInteger(right))); - } - - @Specialization(guards = "isBuiltinPInt(left)", replaces = "doPLNarrow") - static Object doPL(PInt left, long right, - @Bind PythonLanguage language) { - return PFactory.createInt(language, add(left.getValue(), PInt.longToBigInteger(right))); - } - - @Specialization(guards = "isBuiltinPInt(right)", rewriteOn = OverflowException.class) - static Object doLPNarrow(long left, PInt right) throws OverflowException { - return PInt.longValueExact(add(PInt.longToBigInteger(left), right.getValue())); - } - - @Specialization(guards = "isBuiltinPInt(right)", replaces = "doLPNarrow") - static Object doLP(long left, PInt right, - @Bind PythonLanguage language) { - return PFactory.createInt(language, add(PInt.longToBigInteger(left), right.getValue())); - } - - @Specialization(guards = {"isBuiltinPInt(left)", "isBuiltinPInt(right)"}, rewriteOn = OverflowException.class) - static Object doPPNarrow(PInt left, PInt right) throws OverflowException { - return PInt.longValueExact(add(left.getValue(), right.getValue())); - } - - @Specialization(guards = {"isBuiltinPInt(left)", "isBuiltinPInt(right)"}, replaces = "doPPNarrow") - static Object doPP(PInt left, PInt right, - @Bind PythonLanguage language) { - return PFactory.createInt(language, add(left.getValue(), right.getValue())); - } - /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in FloatBuiltins */ - @Specialization public static double doDD(double left, double right) { return left + right; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index 1a714d901b..b804237704 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -51,12 +52,19 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberAndBaseNode extends BinaryOpNode { + @Specialization + public static boolean op(boolean left, boolean right) { + return left && right; + } + @Specialization public static int op(int left, int right) { return left & right; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index d0502ec191..c3afbf9219 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -42,59 +42,66 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.util.OverflowException; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberFloorDivideBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, FloatBuiltins, ... */ - @Specialization(rewriteOn = OverflowException.class) - public static int doII(int left, int right) throws OverflowException { - if (right == 0 || (left == Integer.MIN_VALUE && right == -1)) { - throw OverflowException.INSTANCE; - } + @Specialization(guards = "!specialCase(left, right)") + public static int doII(int left, int right) { return Math.floorDiv(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static long doLL(long left, long right) throws OverflowException { - if (right == 0 || (left == Long.MIN_VALUE && right == -1)) { - throw OverflowException.INSTANCE; - } + @Specialization(guards = "!specialCase(left, right)") + public static long doLL(long left, long right) { return Math.floorDiv(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doID(int left, double right) throws OverflowException { + @Specialization(guards = "!isZero(right)") + public static double doLD(long left, double right) { return doDD(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doDI(double left, int right) throws OverflowException { + @Specialization(guards = "right != 0") + public static double doDL(double left, long right) { return doDD(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doDD(double left, double right) throws OverflowException { - if (right == 0.0) { - throw OverflowException.INSTANCE; - } + @Specialization(guards = "!isZero(right)") + public static double doDD(double left, double right) { return Math.floor(left / right); } + + protected static boolean specialCase(int left, int right) { + return right == 0 || left == Integer.MIN_VALUE && right == -1; + } + + protected static boolean specialCase(long left, long right) { + return right == 0 || left == Long.MIN_VALUE && right == -1; + } + + protected static boolean isZero(double right) { + return right == 0.0; + } } @GenerateInline(false) +@GenerateUncached public abstract class PyNumberFloorDivideNode extends PyNumberFloorDivideBaseNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java index aa7c6a8613..5bad03d7aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java @@ -56,12 +56,14 @@ import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceAddNode extends PyNumberAddBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java index 6ae4492358..d48df26c10 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java @@ -46,11 +46,13 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceFloorDivideNode extends PyNumberFloorDivideBaseNode { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java index a8d32b4d1b..360a60c7ca 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java @@ -41,19 +41,20 @@ package com.oracle.graal.python.lib; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) -public abstract class PyNumberInPlaceLshiftNode extends PyNumberLshiftBaseNode { - @Fallback - @InliningCutoff +@GenerateUncached +public abstract class PyNumberInPlaceLshiftNode extends BinaryOpNode { + @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, @Cached CallBinaryIOpNode callBinaryOpNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java index c246a01add..8ec92574e7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java @@ -55,12 +55,14 @@ import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceMultiplyNode extends PyNumberMultiplyBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java index 4b7263eb99..7d4d0ceb25 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java @@ -46,11 +46,13 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceRemainderNode extends PyNumberRemainderBaseNode { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java index a7c44535aa..92e716a405 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java @@ -46,11 +46,13 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceRshiftNode extends PyNumberRshiftBaseNode { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java index 0909180b46..ef43c8ba2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java @@ -46,11 +46,13 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceSubtractNode extends PyNumberSubtractBaseNode { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java index 6e09431bc4..231b052dd0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java @@ -46,11 +46,13 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) +@GenerateUncached public abstract class PyNumberInPlaceTrueDivideNode extends PyNumberTrueDivideBaseNode { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index e78acaab90..b792a9b2bc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -42,45 +42,20 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateCached(false) -abstract class PyNumberLshiftBaseNode extends BinaryOpNode { - - @Specialization(guards = {"right < 32", "right >= 0"}, rewriteOn = OverflowException.class) - public static int doII(int left, int right) throws OverflowException { - int result = left << right; - if (left != result >> right) { - throw OverflowException.INSTANCE; - } - return result; - } - - @Specialization(guards = {"right < 64", "right >= 0"}, rewriteOn = OverflowException.class) - public static long doLL(long left, long right) throws OverflowException { - long result = left << right; - if (left != result >> right) { - throw OverflowException.INSTANCE; - } - return result; - } -} - @GenerateInline(false) -public abstract class PyNumberLshiftNode extends PyNumberLshiftBaseNode { +@GenerateUncached +public abstract class PyNumberLshiftNode extends BinaryOpNode { - @Fallback - @InliningCutoff + @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, @Cached CallBinaryOpNode callBinaryOpNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index df047a134a..643081f0da 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -40,49 +40,81 @@ */ package com.oracle.graal.python.lib; +import static com.oracle.graal.python.builtins.objects.ints.IntBuiltins.MulNode.mul; import static com.oracle.graal.python.lib.CallBinaryOpNode.raiseNotSupported; +import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNotImplemented; +import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.UnexpectedResultException; import com.oracle.truffle.api.profiles.InlinedBranchProfile; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberMultiplyBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions - * in IntBuiltins, FloatBuiltins, ListBuiltins, ... + * in IntBuiltins */ @Specialization(rewriteOn = ArithmeticException.class) - public static int doII(int x, int y) throws ArithmeticException { + static int doII(int x, int y) throws ArithmeticException { return Math.multiplyExact(x, y); } @Specialization(replaces = "doII") - public static long doIIL(int x, int y) { + static long doIIL(int x, int y) { return x * (long) y; } @Specialization(rewriteOn = ArithmeticException.class) - public static long doLL(long x, long y) { + static long doLL(long x, long y) { return Math.multiplyExact(x, y); } + @Specialization(replaces = "doLL") + static Object doLongWithOverflow(long x, long y, + @Bind("this") Node inliningTarget) { + /* Inlined version of Math.multiplyExact(x, y) with BigInteger fallback. */ + long r = x * y; + long ax = Math.abs(x); + long ay = Math.abs(y); + if (((ax | ay) >>> 31 != 0)) { + // Some bits greater than 2^31 that might cause overflow + // Check the result using the divide operator + // and check for the special case of Long.MIN_VALUE * -1 + if (((y != 0) && (r / y != x)) || + (x == Long.MIN_VALUE && y == -1)) { + return PFactory.createInt(PythonLanguage.get(inliningTarget), mul(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + } + } + return r; + } + + /* + * All the following fast paths need to be kept in sync with the corresponding builtin functions + * in FloatBuiltins + */ @Specialization public static double doDL(double left, long right) { return left * right; @@ -100,6 +132,7 @@ public static double doDD(double left, double right) { } @GenerateInline(inlineByDefault = true) +@GenerateUncached public abstract class PyNumberMultiplyNode extends PyNumberMultiplyBaseNode { public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index 2b66915680..5136d6640f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -51,12 +52,19 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberOrBaseNode extends BinaryOpNode { + @Specialization + public static boolean op(boolean left, boolean right) { + return left || right; + } + @Specialization public static int op(int left, int right) { return left | right; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index 78dba84ea7..403269c6fc 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -40,40 +40,39 @@ */ package com.oracle.graal.python.lib; -import com.oracle.graal.python.builtins.objects.floats.FloatBuiltins; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberRemainderBaseNode extends BinaryOpNode { - @Specialization(rewriteOn = ArithmeticException.class) - public static int doII(int left, int right) { - return Math.floorMod(left, right); - } - - @Specialization(rewriteOn = ArithmeticException.class) - public static long doLL(long left, long right) { + @Specialization(guards = "right != 0") + static int doII(int left, int right) { return Math.floorMod(left, right); } @Specialization(guards = "right != 0") - public static double doDL(double left, long right) { - return FloatBuiltins.ModNode.mod(left, right); + static long doLL(long left, long right) { + return Math.floorMod(left, right); } } @GenerateInline(false) +@GenerateUncached public abstract class PyNumberRemainderNode extends PyNumberRemainderBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index 9203c8a04d..8e36dad6e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -53,6 +53,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -61,12 +62,15 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberRshiftBaseNode extends BinaryOpNode { @Specialization(guards = {"right < 32", "right >= 0"}) @@ -81,6 +85,7 @@ public static long doIISmall(long left, long right) { } @GenerateInline(false) +@GenerateUncached public abstract class PyNumberRshiftNode extends PyNumberRshiftBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index 9144468818..3f392cc598 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -40,41 +40,66 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.objects.ints.IntBuiltins; +import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; +import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberSubtractBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions - * in IntBuiltins, FloatBuiltins, ListBuiltins, ... + * in IntBuiltins */ @Specialization(rewriteOn = ArithmeticException.class) - public static int doII(int x, int y) throws ArithmeticException { + static int doII(int x, int y) throws ArithmeticException { return Math.subtractExact(x, y); } - @Specialization - public static long doIIOvf(int x, int y) { + @Specialization(replaces = "doII") + static long doIIOvf(int x, int y) { return (long) x - (long) y; } @Specialization(rewriteOn = ArithmeticException.class) - public static long doLL(long x, long y) throws ArithmeticException { + static long doLL(long x, long y) throws ArithmeticException { return Math.subtractExact(x, y); } + @Specialization(replaces = "doLL") + static Object doLongWithOverflow(long x, long y, + @Bind("this") Node inliningTarget) { + /* Inlined version of Math.subtractExact(x, y) with BigInteger fallback. */ + long r = x - y; + // HD 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different than the sign of x + if (((x ^ y) & (x ^ r)) < 0) { + return PFactory.createInt(PythonLanguage.get(inliningTarget), IntBuiltins.SubNode.sub(PInt.longToBigInteger(x), PInt.longToBigInteger(y))); + } + return r; + } + + /* + * All the following fast paths need to be kept in sync with the corresponding builtin functions + * in FloatBuiltins + */ @Specialization public static double doDD(double left, double right) { return left - right; @@ -89,19 +114,10 @@ public static double doDL(double left, long right) { public static double doLD(long left, double right) { return left - right; } - - @Specialization - public static double doDI(double left, int right) { - return left - right; - } - - @Specialization - public static double doID(int left, double right) { - return left - right; - } } @GenerateInline(false) +@GenerateUncached public abstract class PyNumberSubtractNode extends PyNumberSubtractBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index bf9dff20a6..8f59f003a7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -40,52 +40,66 @@ */ package com.oracle.graal.python.lib; +import com.oracle.graal.python.builtins.objects.ints.IntBuiltins; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.util.OverflowException; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) +@ImportStatic(IntBuiltins.TrueDivNode.class) abstract class PyNumberTrueDivideBaseNode extends BinaryOpNode { /* * All the following fast paths need to be kept in sync with the corresponding builtin functions * in IntBuiltins, FloatBuiltins, ... */ - @Specialization(rewriteOn = OverflowException.class) - public static double doII(int left, int right) throws OverflowException { + + @Specialization(guards = "!isZero(right)") + public static double doDD(double left, double right) { + return left / right; + } + + @Specialization(guards = "right != 0") + public static double doDL(double left, long right) { return doDD(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doDI(double left, int right) throws OverflowException { + @Specialization(guards = "!isZero(right)") + public static double doLD(long left, double right) { return doDD(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doID(int left, double right) throws OverflowException { + @Specialization(guards = "right != 0") + public static double doII(int left, int right) { return doDD(left, right); } - @Specialization(rewriteOn = OverflowException.class) - public static double doDD(double left, double right) throws OverflowException { - if (right == 0.0) { - throw OverflowException.INSTANCE; - } - return left / right; + @Specialization(guards = {"right != 0", "fitsIntoDouble(left)", "fitsIntoDouble(right)"}) + public static double doLL(long left, long right) { + return doDD(left, right); + } + + protected static boolean isZero(double right) { + return right == 0.0; } } @GenerateInline(false) +@GenerateUncached public abstract class PyNumberTrueDivideNode extends PyNumberTrueDivideBaseNode { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index 5fb858c7a7..18633e77f2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -51,12 +52,19 @@ import com.oracle.truffle.api.dsl.GenerateUncached; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @GenerateCached(false) +@TypeSystemReference(PythonIntegerTypes.class) abstract class PyNumberXorBaseNode extends BinaryOpNode { + @Specialization + public static boolean op(boolean left, boolean right) { + return left != right; + } + @Specialization public static int op(int left, int right) { return left ^ right; From 3415eb88868139de525daa76cf1c944bffed47c3 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 15:44:46 +0100 Subject: [PATCH 038/512] Remove GraalHPyArithmeticNode --- .../cext/PythonCextAbstractBuiltins.java | 3 +- .../cext/hpy/GraalHPyArithmeticNode.java | 441 ------------------ .../cext/hpy/GraalHPyContextFunctions.java | 182 ++++---- .../graal/python/lib/PyNumberAddNode.java | 4 + .../graal/python/lib/PyNumberAndNode.java | 4 + .../graal/python/lib/PyNumberDivmodNode.java | 4 + .../python/lib/PyNumberFloorDivideNode.java | 4 + .../python/lib/PyNumberInPlaceAddNode.java | 4 + .../python/lib/PyNumberInPlaceAndNode.java | 4 + .../lib/PyNumberInPlaceFloorDivideNode.java | 4 + .../python/lib/PyNumberInPlaceLshiftNode.java | 4 + .../PyNumberInPlaceMatrixMultiplyNode.java | 4 + .../lib/PyNumberInPlaceMultiplyNode.java | 4 + .../python/lib/PyNumberInPlaceOrNode.java | 4 + .../python/lib/PyNumberInPlacePowerNode.java | 18 +- .../lib/PyNumberInPlaceRemainderNode.java | 4 + .../python/lib/PyNumberInPlaceRshiftNode.java | 4 + .../lib/PyNumberInPlaceSubtractNode.java | 4 + .../lib/PyNumberInPlaceTrueDivideNode.java | 4 + .../python/lib/PyNumberInPlaceXorNode.java | 4 + .../graal/python/lib/PyNumberInvertNode.java | 4 + .../graal/python/lib/PyNumberLshiftNode.java | 4 + .../lib/PyNumberMatrixMultiplyNode.java | 4 + .../python/lib/PyNumberMultiplyNode.java | 4 + .../python/lib/PyNumberNegativeNode.java | 4 + .../graal/python/lib/PyNumberOrNode.java | 4 + .../python/lib/PyNumberPositiveNode.java | 4 + .../graal/python/lib/PyNumberPowerNode.java | 4 + .../python/lib/PyNumberRemainderNode.java | 4 + .../graal/python/lib/PyNumberRshiftNode.java | 4 + .../python/lib/PyNumberSubtractNode.java | 4 + .../python/lib/PyNumberTrueDivideNode.java | 4 + .../graal/python/lib/PyNumberXorNode.java | 4 + 33 files changed, 216 insertions(+), 544 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 6cfaff3a52..013bafe4d5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -584,9 +584,8 @@ abstract static class PyNumber_InPlacePower extends CApiTernaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, Object o3, - @Bind Node inliningTarget, @Cached PyNumberInPlacePowerNode powerNode) { - return powerNode.execute(null, inliningTarget, o1, o2, o3); + return powerNode.execute(null, o1, o2, o3); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java deleted file mode 100644 index 765d516527..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyArithmeticNode.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Copyright (c) 2023, 2025, 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.builtins.objects.cext.hpy; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.nodes.call.GenericInvokeNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.expression.InplaceArithmetic; -import com.oracle.graal.python.nodes.expression.LookupAndCallInplaceNode; -import com.oracle.graal.python.nodes.expression.UnaryArithmetic; -import com.oracle.graal.python.nodes.expression.UnaryOpNode; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.nodes.Node; - -public abstract class GraalHPyArithmeticNode { - - private GraalHPyArithmeticNode() { - } - - public abstract static class HPyUnaryArithmeticNode extends Node { - - public abstract Object execute(Object object); - - @NeverDefault - public static HPyUnaryArithmeticNode create(UnaryArithmetic operator) { - return new HPyUnaryArithmeticCached(operator); - } - - public static HPyUnaryArithmeticNode getUncached(UnaryArithmetic operator) { - return HPyUnaryArithmeticUncached.UNCACHEDS[operator.ordinal()]; - } - } - - static final class HPyUnaryArithmeticCached extends HPyUnaryArithmeticNode { - @Child private UnaryOpNode opNode; - - private HPyUnaryArithmeticCached(UnaryArithmetic operator) { - opNode = operator.create(); - } - - @Override - public Object execute(Object object) { - return opNode.execute(null, object); - } - } - - private static final class HPyUnaryArithmeticUncached extends HPyUnaryArithmeticNode { - final UnaryArithmetic operator; - - public HPyUnaryArithmeticUncached(UnaryArithmetic operator) { - this.operator = operator; - } - - @TruffleBoundary - @Override - public Object execute(Object object) { - Object[] pythonArguments = PArguments.create(1); - PArguments.setArgument(pythonArguments, 0, object); - RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); - return GenericInvokeNode.invokeUncached(callTarget, pythonArguments); - } - - @Override - public boolean isAdoptable() { - return false; - } - - private static final HPyUnaryArithmeticUncached[] UNCACHEDS; - static { - UnaryArithmetic[] values = UnaryArithmetic.values(); - UNCACHEDS = new HPyUnaryArithmeticUncached[values.length]; - for (int i = 0; i < values.length; i++) { - UNCACHEDS[i] = new HPyUnaryArithmeticUncached(values[i]); - } - } - } - - public abstract static class HPyBinaryArithmeticNode extends Node { - - public abstract Object execute(Object arg0, Object arg1); - - @NeverDefault - public static HPyBinaryArithmeticNode create(BinaryArithmetic operator) { - return new HPyBinaryArithmeticCached(operator); - } - - public static HPyBinaryArithmeticNode getUncached(BinaryArithmetic operator) { - return HPyBinaryArithmeticUncached.UNCACHEDS[operator.ordinal()]; - } - } - - private static final class HPyBinaryArithmeticCached extends HPyBinaryArithmeticNode { - @Child private BinaryOpNode opNode; - - private HPyBinaryArithmeticCached(BinaryArithmetic operator) { - opNode = operator.create(); - } - - @Override - public Object execute(Object arg0, Object arg1) { - return opNode.execute(null, arg0, arg1); - } - } - - private static final class HPyBinaryArithmeticUncached extends HPyBinaryArithmeticNode { - final BinaryArithmetic operator; - - public HPyBinaryArithmeticUncached(BinaryArithmetic operator) { - this.operator = operator; - } - - @TruffleBoundary - @Override - public Object execute(Object arg0, Object arg1) { - Object[] pythonArguments = PArguments.create(2); - PArguments.setArgument(pythonArguments, 0, arg0); - PArguments.setArgument(pythonArguments, 1, arg1); - RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); - return GenericInvokeNode.invokeUncached(callTarget, pythonArguments); - } - - @Override - public boolean isAdoptable() { - return false; - } - - private static final HPyBinaryArithmeticUncached[] UNCACHEDS; - static { - BinaryArithmetic[] values = BinaryArithmetic.values(); - UNCACHEDS = new HPyBinaryArithmeticUncached[values.length]; - for (int i = 0; i < values.length; i++) { - UNCACHEDS[i] = new HPyBinaryArithmeticUncached(values[i]); - } - } - } - - public abstract static class HPyInplaceArithmeticNode extends Node { - - public abstract Object execute(Object arg0, Object arg1, Object arg2); - - public final Object execute(Object arg0, Object arg1) { - return execute(arg0, arg1, PNone.NO_VALUE); - } - - @NeverDefault - public static HPyInplaceArithmeticNode create(InplaceArithmetic operator) { - return new HPyInplaceArithmeticCached(operator); - } - - public static HPyInplaceArithmeticNode getUncached(InplaceArithmetic operator) { - return HPyInplaceArithmeticUncached.UNCACHEDS[operator.ordinal()]; - } - } - - private static final class HPyInplaceArithmeticCached extends HPyInplaceArithmeticNode { - @Child private LookupAndCallInplaceNode opNode; - - private final boolean isTernary; - - private HPyInplaceArithmeticCached(InplaceArithmetic operator) { - opNode = operator.create(); - this.isTernary = operator.isTernary(); - } - - @Override - public Object execute(Object arg0, Object arg1, Object arg2) { - if (isTernary) { - return opNode.executeTernary(null, arg0, arg1, arg2); - } else { - return opNode.execute(null, arg0, arg1); - } - } - } - - private static final class HPyInplaceArithmeticUncached extends HPyInplaceArithmeticNode { - final InplaceArithmetic operator; - - public HPyInplaceArithmeticUncached(InplaceArithmetic operator) { - this.operator = operator; - } - - @TruffleBoundary - @Override - public Object execute(Object arg0, Object arg1, Object arg2) { - Object[] pythonArguments = PArguments.create(3); - PArguments.setArgument(pythonArguments, 0, arg0); - PArguments.setArgument(pythonArguments, 1, arg1); - PArguments.setArgument(pythonArguments, 2, arg2); - RootCallTarget callTarget = PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); - return GenericInvokeNode.invokeUncached(callTarget, pythonArguments); - } - - @Override - public boolean isAdoptable() { - return false; - } - - private static final HPyInplaceArithmeticUncached[] UNCACHEDS; - static { - InplaceArithmetic[] values = InplaceArithmetic.values(); - UNCACHEDS = new HPyInplaceArithmeticUncached[values.length]; - for (int i = 0; i < values.length; i++) { - UNCACHEDS[i] = new HPyInplaceArithmeticUncached(values[i]); - } - } - } - -// @NeverDefault -// public static GraalHPyBinaryArithmeticCached create(BinaryArithmetic operator) { -// return new GraalHPyBinaryArithmeticCached(operator); -// } -// -// public static GraalHPyBinaryArithmeticUncached getUncached(BinaryArithmetic operator) { -// return GraalHPyBinaryArithmeticUncached.UNCACHEDS[operator.ordinal()]; -// } -// -// static final class GraalHPyBinaryArithmeticCached extends GraalHPyArithmeticCachedNode { -// @Child private BinaryOpNode opNode; -// -// GraalHPyBinaryArithmeticCached(BinaryArithmetic operator) { -// opNode = operator.create(); -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// checkArity(arguments, EXPECTED_ARITY_BINARY); -// } -// -// @Override -// Object doOperator(Object[] arguments) { -// return opNode.executeObject(null, asPythonObjectNode.execute(arguments[1]), -// asPythonObjectNode.execute(arguments[2])); -// } -// } -// -// private static final class GraalHPyBinaryArithmeticUncached extends -// GraalHPyArithmeticUncachedNode { -// final BinaryArithmetic operator; -// -// public GraalHPyBinaryArithmeticUncached(BinaryArithmetic operator) { -// this.operator = operator; -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// checkArity(arguments, EXPECTED_ARITY_BINARY); -// } -// -// @Override -// RootCallTarget ensureCallTarget() { -// return PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); -// } -// -// private static final GraalHPyBinaryArithmeticUncached[] UNCACHEDS; -// static { -// BinaryArithmetic[] values = BinaryArithmetic.values(); -// UNCACHEDS = new GraalHPyBinaryArithmeticUncached[values.length]; -// for (int i = 0; i < values.length; i++) { -// UNCACHEDS[i] = new GraalHPyBinaryArithmeticUncached(values[i]); -// } -// } -// } -// -// @NeverDefault -// public static GraalHPyTernaryArithmeticCached create(TernaryArithmetic operator) { -// return new GraalHPyTernaryArithmeticCached(operator); -// } -// -// public static GraalHPyTernaryArithmeticUncached getUncached(TernaryArithmetic operator) { -// return GraalHPyTernaryArithmeticUncached.UNCACHEDS[operator.ordinal()]; -// } -// -// static final class GraalHPyTernaryArithmeticCached extends GraalHPyArithmeticCachedNode { -// @Child private LookupAndCallTernaryNode opNode; -// -// GraalHPyTernaryArithmeticCached(TernaryArithmetic operator) { -// opNode = operator.create(); -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// checkArity(arguments, EXPECTED_ARITY_TERNARY); -// } -// -// @Override -// Object doOperator(Object[] arguments) { -// return opNode.execute(null, asPythonObjectNode.execute(arguments[1]), -// asPythonObjectNode.execute(arguments[2]), asPythonObjectNode.execute(arguments[3])); -// } -// } -// -// private static final class GraalHPyTernaryArithmeticUncached extends -// GraalHPyArithmeticUncachedNode { -// final TernaryArithmetic operator; -// -// public GraalHPyTernaryArithmeticUncached(TernaryArithmetic operator) { -// this.operator = operator; -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// checkArity(arguments, EXPECTED_ARITY_TERNARY); -// } -// -// @Override -// RootCallTarget ensureCallTarget() { -// return PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); -// } -// -// private static final GraalHPyTernaryArithmeticUncached[] UNCACHEDS; -// static { -// TernaryArithmetic[] values = TernaryArithmetic.values(); -// UNCACHEDS = new GraalHPyTernaryArithmeticUncached[values.length]; -// for (int i = 0; i < values.length; i++) { -// UNCACHEDS[i] = new GraalHPyTernaryArithmeticUncached(values[i]); -// } -// } -// } -// -// @NeverDefault -// public static GraalHPyInplaceArithmeticCached create(InplaceArithmetic operator) { -// return new GraalHPyInplaceArithmeticCached(operator); -// } -// -// public static GraalHPyInplaceArithmeticUncached getUncached(InplaceArithmetic operator) { -// return GraalHPyInplaceArithmeticUncached.UNCACHEDS[operator.ordinal()]; -// } -// -// static final class GraalHPyInplaceArithmeticCached extends GraalHPyArithmeticCachedNode { -// @Child private LookupAndCallInplaceNode opNode; -// private final boolean ternary; -// -// GraalHPyInplaceArithmeticCached(InplaceArithmetic operator) { -// opNode = operator.create(); -// ternary = operator.isTernary(); -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// GraalHPyInplaceArithmeticCached.checkInplaceArity(arguments, ternary); -// } -// -// private static void checkInplaceArity(Object[] arguments, boolean ternary) throws ArityException -// { -// // we also need to account for the HPy context -// if (ternary && arguments.length != 4) { -// CompilerDirectives.transferToInterpreterAndInvalidate(); -// throw ArityException.create(EXPECTED_ARITY_TERNARY, EXPECTED_ARITY_TERNARY, arguments.length); -// } -// if (!ternary && arguments.length != 3) { -// CompilerDirectives.transferToInterpreterAndInvalidate(); -// throw ArityException.create(EXPECTED_ARITY_BINARY, EXPECTED_ARITY_BINARY, arguments.length); -// } -// } -// -// @Override -// Object doOperator(Object[] arguments) { -// return opNode.execute(null, asPythonObjectNode.execute(arguments[1]), -// asPythonObjectNode.execute(arguments[2])); -// } -// } -// -// private static final class GraalHPyInplaceArithmeticUncached extends -// GraalHPyArithmeticUncachedNode { -// final InplaceArithmetic operator; -// -// public GraalHPyInplaceArithmeticUncached(InplaceArithmetic operator) { -// this.operator = operator; -// } -// -// @Override -// void checkArity(Object[] arguments) throws ArityException { -// GraalHPyInplaceArithmeticCached.checkInplaceArity(arguments, operator.isTernary()); -// } -// -// @Override -// RootCallTarget ensureCallTarget() { -// return PythonLanguage.get(null).createCachedCallTarget(operator::createRootNode, operator); -// } -// -// private static final GraalHPyInplaceArithmeticUncached[] UNCACHEDS; -// static { -// InplaceArithmetic[] values = InplaceArithmetic.values(); -// UNCACHEDS = new GraalHPyInplaceArithmeticUncached[values.length]; -// for (int i = 0; i < values.length; i++) { -// UNCACHEDS[i] = new GraalHPyInplaceArithmeticUncached(values[i]); -// } -// } -// } -// -// static void checkArity(Object[] arguments, int expectedArity) throws ArityException { -// if (arguments.length != expectedArity) { -// CompilerDirectives.transferToInterpreterAndInvalidate(); -// throw ArityException.create(expectedArity, expectedArity, arguments.length); -// } -// } - -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java index 872b8ea638..e5ef187d6d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java @@ -95,9 +95,6 @@ import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ClearCurrentExceptionNode; import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EncodeNativeStringNode; import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ReadUnicodeArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyBinaryArithmeticNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyInplaceArithmeticNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyArithmeticNode.HPyUnaryArithmeticNode; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyASCIINodeGen; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAbsoluteNodeGen; import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAddNodeGen; @@ -310,9 +307,38 @@ import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode; import com.oracle.graal.python.lib.PyFloatAsDoubleNode; import com.oracle.graal.python.lib.PyLongAsDoubleNode; +import com.oracle.graal.python.lib.PyNumberAddNode; +import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberCheckNode; +import com.oracle.graal.python.lib.PyNumberDivmodNode; +import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAndNode; +import com.oracle.graal.python.lib.PyNumberInPlaceFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceLshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceOrNode; +import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRemainderNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceSubtractNode; +import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; import com.oracle.graal.python.lib.PyNumberIndexNode; +import com.oracle.graal.python.lib.PyNumberInvertNode; +import com.oracle.graal.python.lib.PyNumberLshiftNode; +import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberMultiplyNode; +import com.oracle.graal.python.lib.PyNumberNegativeNode; +import com.oracle.graal.python.lib.PyNumberOrNode; +import com.oracle.graal.python.lib.PyNumberPositiveNode; import com.oracle.graal.python.lib.PyNumberPowerNode; +import com.oracle.graal.python.lib.PyNumberRemainderNode; +import com.oracle.graal.python.lib.PyNumberRshiftNode; +import com.oracle.graal.python.lib.PyNumberSubtractNode; +import com.oracle.graal.python.lib.PyNumberTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberXorNode; import com.oracle.graal.python.lib.PyObjectDelItem; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectGetAttrO; @@ -344,9 +370,6 @@ import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.InplaceArithmetic; -import com.oracle.graal.python.nodes.expression.UnaryArithmetic; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; import com.oracle.graal.python.nodes.object.IsNode; @@ -830,193 +853,179 @@ static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object handl @HPyContextFunction("ctx_Positive") @GenerateUncached - @ImportStatic(UnaryArithmetic.class) public abstract static class GraalHPyPositive extends HPyBinaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached(parameters = "Pos") HPyUnaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg); + @Cached PyNumberPositiveNode arithmeticNode) { + return arithmeticNode.execute(null, arg); } } @HPyContextFunction("ctx_Negative") @GenerateUncached - @ImportStatic(UnaryArithmetic.class) public abstract static class GraalHPyNegative extends HPyBinaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached(parameters = "Neg") HPyUnaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg); + @Cached PyNumberNegativeNode arithmeticNode) { + return arithmeticNode.execute(null, arg); } } @HPyContextFunction("ctx_Invert") @GenerateUncached - @ImportStatic(UnaryArithmetic.class) public abstract static class GraalHPyInvert extends HPyBinaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached(parameters = "Invert") HPyUnaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg); + @Cached PyNumberInvertNode arithmeticNode) { + return arithmeticNode.execute(null, arg); } } @HPyContextFunction("ctx_Add") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyAdd extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Add") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Bind Node inliningTarget, + @Cached PyNumberAddNode arithmeticNode) { + return arithmeticNode.execute(null, inliningTarget, arg0, arg1); } } @HPyContextFunction("ctx_Subtract") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPySubtract extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Sub") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberSubtractNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Multiply") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyMultiply extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Mul") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Bind Node inliningTarget, + @Cached PyNumberMultiplyNode arithmeticNode) { + return arithmeticNode.execute(null, inliningTarget, arg0, arg1); } } @HPyContextFunction("ctx_MatrixMultiply") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyMatrixMultiply extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "MatMul") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberMatrixMultiplyNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_FloorDivide") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyFloorDivide extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "FloorDiv") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberFloorDivideNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_TrueDivide") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyTrueDivide extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "TrueDiv") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberTrueDivideNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Remainder") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyRemainder extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Mod") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberRemainderNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Divmod") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyDivmod extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "DivMod") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberDivmodNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_And") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyAnd extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "And") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberAndNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Xor") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyXor extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Xor") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberXorNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Or") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyOr extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "Or") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberOrNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Lshift") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyLshift extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "LShift") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberLshiftNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_Rshift") @GenerateUncached - @ImportStatic(BinaryArithmetic.class) public abstract static class GraalHPyRshift extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "RShift") HPyBinaryArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberRshiftNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @@ -1034,157 +1043,144 @@ static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object ar @HPyContextFunction("ctx_InPlaceAdd") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceAdd extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IAdd") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceAddNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceSubtract") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceSubtract extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "ISub") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceSubtractNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceMultiply") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceMultiply extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IMul") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceMultiplyNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceMatrixMultiply") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceMatrixMultiply extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IMatMul") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceMatrixMultiplyNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceFloorDivide") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceFloorDivide extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IFloorDiv") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceFloorDivideNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceTrueDivide") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceTrueDivide extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "ITrueDiv") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceTrueDivideNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceRemainder") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceRemainder extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IMod") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceRemainderNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlacePower") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlacePower extends HPyQuaternaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, Object arg2, - @Cached(parameters = "IPow") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1, arg2); + @Cached PyNumberInPlacePowerNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1, arg2); } } @HPyContextFunction("ctx_InPlaceLshift") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceLshift extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "ILShift") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceLshiftNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceRshift") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceRshift extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IRShift") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceRshiftNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceAnd") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceAnd extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IAnd") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceAndNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceXor") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceXor extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IXor") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceXorNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } @HPyContextFunction("ctx_InPlaceOr") @GenerateUncached - @ImportStatic(InplaceArithmetic.class) public abstract static class GraalHPyInPlaceOr extends HPyTernaryContextFunction { @Specialization static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached(parameters = "IOr") HPyInplaceArithmeticNode arithmeticNode) { - return arithmeticNode.execute(arg0, arg1); + @Cached PyNumberInPlaceOrNode arithmeticNode) { + return arithmeticNode.execute(null, arg0, arg1); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 2d51703278..d46dc198c3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -196,4 +196,8 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, public static PyNumberAddNode create() { return PyNumberAddNodeGen.create(); } + + public static PyNumberAddNode getUncached() { + return PyNumberAddNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index b804237704..be1c30f26d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -92,4 +92,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberAndNode create() { return PyNumberAndNodeGen.create(); } + + public static PyNumberAndNode getUncached() { + return PyNumberAndNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java index 37f65cd7f9..0cc37fd903 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberDivmodNode.java @@ -74,4 +74,8 @@ public static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Obj public static PyNumberDivmodNode create() { return PyNumberDivmodNodeGen.create(); } + + public static PyNumberDivmodNode getUncached() { + return PyNumberDivmodNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index c3afbf9219..f484ad823e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -115,4 +115,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberFloorDivideNode create() { return PyNumberFloorDivideNodeGen.create(); } + + public static PyNumberFloorDivideNode getUncached() { + return PyNumberFloorDivideNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java index 5bad03d7aa..12a554c883 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java @@ -106,4 +106,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceAddNode create() { return PyNumberInPlaceAddNodeGen.create(); } + + public static PyNumberInPlaceAddNode getUncached() { + return PyNumberInPlaceAddNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java index 3819e8dd73..deb370d592 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceAndNode create() { return PyNumberInPlaceAndNodeGen.create(); } + + public static PyNumberInPlaceAndNode getUncached() { + return PyNumberInPlaceAndNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java index d48df26c10..7f0d0f321a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceFloorDivideNode create() { return PyNumberInPlaceFloorDivideNodeGen.create(); } + + public static PyNumberInPlaceFloorDivideNode getUncached() { + return PyNumberInPlaceFloorDivideNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java index 360a60c7ca..e0342b4be0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java @@ -65,4 +65,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceLshiftNode create() { return PyNumberInPlaceLshiftNodeGen.create(); } + + public static PyNumberInPlaceLshiftNode getUncached() { + return PyNumberInPlaceLshiftNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java index 890fc52a71..3f65419a60 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java @@ -65,4 +65,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceMatrixMultiplyNode create() { return PyNumberInPlaceMatrixMultiplyNodeGen.create(); } + + public static PyNumberInPlaceMatrixMultiplyNode getUncached() { + return PyNumberInPlaceMatrixMultiplyNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java index 8ec92574e7..532bce5be3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java @@ -118,4 +118,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceMultiplyNode create() { return PyNumberInPlaceMultiplyNodeGen.create(); } + + public static PyNumberInPlaceMultiplyNode getUncached() { + return PyNumberInPlaceMultiplyNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java index b1c046876a..856b0f582c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceOrNode create() { return PyNumberInPlaceOrNodeGen.create(); } + + public static PyNumberInPlaceOrNode getUncached() { + return PyNumberInPlaceOrNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java index 9e9a2776bf..f984f6c890 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java @@ -48,6 +48,7 @@ import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; @@ -56,23 +57,20 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -@GenerateInline(inlineByDefault = true) +@GenerateInline(false) @GenerateUncached public abstract class PyNumberInPlacePowerNode extends BinaryOpNode { - public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z); + public abstract Object execute(VirtualFrame frame, Object v, Object w, Object z); @Override public final Object execute(VirtualFrame frame, Object left, Object right) { - return executeCached(frame, left, right, PNone.NONE); - } - - public final Object executeCached(VirtualFrame frame, Object v, Object w, Object z) { - return execute(frame, this, v, w, z); + return execute(frame, left, right, PNone.NONE); } @Specialization - static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z, + static Object doIt(VirtualFrame frame, Object v, Object w, Object z, + @Bind Node inliningTarget, @Cached CallTernaryIOpNode callTernaryOpNode, @Cached PRaiseNode raiseNode) { Object result = callTernaryOpNode.execute(frame, inliningTarget, v, w, z); @@ -95,4 +93,8 @@ private static PException raiseNotSupported(Node inliningTarget, Object v, Objec public static PyNumberInPlacePowerNode create() { return PyNumberInPlacePowerNodeGen.create(); } + + public static PyNumberInPlacePowerNode getUncached() { + return PyNumberInPlacePowerNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java index 7d4d0ceb25..ff1dc9027e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceRemainderNode create() { return PyNumberInPlaceRemainderNodeGen.create(); } + + public static PyNumberInPlaceRemainderNode getUncached() { + return PyNumberInPlaceRemainderNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java index 92e716a405..a65c78118b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceRshiftNode create() { return PyNumberInPlaceRshiftNodeGen.create(); } + + public static PyNumberInPlaceRshiftNode getUncached() { + return PyNumberInPlaceRshiftNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java index ef43c8ba2c..01f0922d5b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceSubtractNode create() { return PyNumberInPlaceSubtractNodeGen.create(); } + + public static PyNumberInPlaceSubtractNode getUncached() { + return PyNumberInPlaceSubtractNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java index 231b052dd0..6283e33d15 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceTrueDivideNode create() { return PyNumberInPlaceTrueDivideNodeGen.create(); } + + public static PyNumberInPlaceTrueDivideNode getUncached() { + return PyNumberInPlaceTrueDivideNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java index 4449af193d..066f430cec 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberInPlaceXorNode create() { return PyNumberInPlaceXorNodeGen.create(); } + + public static PyNumberInPlaceXorNode getUncached() { + return PyNumberInPlaceXorNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java index 7ef7f93f4c..a920f76837 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java @@ -93,4 +93,8 @@ public static Object doObject(VirtualFrame frame, Object object, public static PyNumberInvertNode create() { return PyNumberInvertNodeGen.create(); } + + public static PyNumberInvertNode getUncached() { + return PyNumberInvertNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index b792a9b2bc..0ce424836e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberLshiftNode create() { return PyNumberLshiftNodeGen.create(); } + + public static PyNumberLshiftNode getUncached() { + return PyNumberLshiftNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java index a0e3f6041c..0262c2ad33 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java @@ -66,4 +66,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberMatrixMultiplyNode create() { return PyNumberMatrixMultiplyNodeGen.create(); } + + public static PyNumberMatrixMultiplyNode getUncached() { + return PyNumberMatrixMultiplyNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index 643081f0da..f8818b387f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -184,4 +184,8 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w, public static PyNumberMultiplyNode create() { return PyNumberMultiplyNodeGen.create(); } + + public static PyNumberMultiplyNode getUncached() { + return PyNumberMultiplyNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java index 5f0fcddf32..cca2839be7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java @@ -106,4 +106,8 @@ public static Object doObject(VirtualFrame frame, Object object, public static PyNumberNegativeNode create() { return PyNumberNegativeNodeGen.create(); } + + public static PyNumberNegativeNode getUncached() { + return PyNumberNegativeNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index 5136d6640f..07e1a56b8d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -92,4 +92,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberOrNode create() { return PyNumberOrNodeGen.create(); } + + public static PyNumberOrNode getUncached() { + return PyNumberOrNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java index 897fc6ae2a..833297afea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java @@ -88,4 +88,8 @@ public static Object doObject(VirtualFrame frame, Object object, public static PyNumberPositiveNode create() { return PyNumberPositiveNodeGen.create(); } + + public static PyNumberPositiveNode getUncached() { + return PyNumberPositiveNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java index 18d3a87e3d..4920cd8347 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java @@ -106,4 +106,8 @@ private static PException raiseNotSupported(Node inliningTarget, Object v, Objec public static PyNumberPowerNode create() { return PyNumberPowerNodeGen.create(); } + + public static PyNumberPowerNode getUncached() { + return PyNumberPowerNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index 403269c6fc..786f3ac78b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -87,4 +87,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberRemainderNode create() { return PyNumberRemainderNodeGen.create(); } + + public static PyNumberRemainderNode getUncached() { + return PyNumberRemainderNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index 8e36dad6e2..3ee97ad394 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -127,4 +127,8 @@ private static void handlePossiblePrint(Node inliningTarget, Object v, Object w) public static PyNumberRshiftNode create() { return PyNumberRshiftNodeGen.create(); } + + public static PyNumberRshiftNode getUncached() { + return PyNumberRshiftNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index 3f392cc598..4d853bb56f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -132,4 +132,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberSubtractNode create() { return PyNumberSubtractNodeGen.create(); } + + public static PyNumberSubtractNode getUncached() { + return PyNumberSubtractNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index 8f59f003a7..c81523634b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -114,4 +114,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberTrueDivideNode create() { return PyNumberTrueDivideNodeGen.create(); } + + public static PyNumberTrueDivideNode getUncached() { + return PyNumberTrueDivideNodeGen.getUncached(); + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index 18633e77f2..247d296251 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -92,4 +92,8 @@ public static Object doIt(VirtualFrame frame, Object v, Object w, public static PyNumberXorNode create() { return PyNumberXorNodeGen.create(); } + + public static PyNumberXorNode getUncached() { + return PyNumberXorNodeGen.getUncached(); + } } From fc87def07fe840a255f5976d6a1fbc3a22f5d253 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 16:28:07 +0100 Subject: [PATCH 039/512] Remove arithmetic root nodes and LookupAndCallReversibleTernary --- ...LookupAndCallNonReversibleTernaryNode.java | 16 +- .../LookupAndCallReversibleTernaryNode.java | 206 ------------------ .../special/LookupAndCallTernaryNode.java | 33 +-- .../nodes/expression/BinaryArithmetic.java | 50 ----- .../nodes/expression/InplaceArithmetic.java | 195 ----------------- .../expression/LookupAndCallInplaceNode.java | 154 ------------- .../nodes/expression/TernaryArithmetic.java | 133 ----------- .../nodes/expression/UnaryArithmetic.java | 47 ---- 8 files changed, 2 insertions(+), 832 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleTernaryNode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallNonReversibleTernaryNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallNonReversibleTernaryNode.java index e6b0a0413f..d6b23ded91 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallNonReversibleTernaryNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallNonReversibleTernaryNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,9 +41,7 @@ package com.oracle.graal.python.nodes.call.special; import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.TernaryBuiltinDescriptor; import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; @@ -68,10 +66,6 @@ public abstract class LookupAndCallNonReversibleTernaryNode extends LookupAndCal super(name); } - LookupAndCallNonReversibleTernaryNode(SpecialMethodSlot slot) { - super(slot); - } - protected static PythonBuiltinClassType getBuiltinClass(Node inliningTarget, Object receiver, GetClassNode getClassNode) { Object clazz = getClassNode.execute(inliningTarget, receiver); return clazz instanceof PythonBuiltinClassType ? (PythonBuiltinClassType) clazz : null; @@ -82,14 +76,6 @@ protected static boolean isClazz(Node inliningTarget, PythonBuiltinClassType cla } protected final PythonTernaryBuiltinNode getTernaryBuiltin(PythonBuiltinClassType clazz) { - if (slot != null) { - Object attribute = slot.getValue(clazz); - if (attribute instanceof TernaryBuiltinDescriptor) { - return ((TernaryBuiltinDescriptor) attribute).createNode(); - } - // If the slot does not contain builtin, full lookup wouldn't find a builtin either - return null; - } Object attribute = LookupAttributeInMRONode.Dynamic.getUncached().execute(clazz, name); if (attribute instanceof PBuiltinFunction) { PBuiltinFunction builtinFunction = (PBuiltinFunction) attribute; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleTernaryNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleTernaryNode.java deleted file mode 100644 index 9bf7623ace..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallReversibleTernaryNode.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2018, 2023, 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.call.special; - -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.ReportPolymorphism.Megamorphic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedBranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -@ImportStatic({SpecialMethodNames.class, PythonOptions.class}) -public abstract class LookupAndCallReversibleTernaryNode extends LookupAndCallTernaryNode { - - @Child private CallTernaryMethodNode reverseDispatchNode; - @Child private CallTernaryMethodNode thirdDispatchNode; - @Child protected LookupSpecialMethodNode getThirdAttrNode; - - @Child protected NotImplementedHandler handler; - protected final Supplier handlerFactory; - - LookupAndCallReversibleTernaryNode(TruffleString name, Supplier handlerFactory) { - super(name); - this.handlerFactory = handlerFactory; - } - - public LookupAndCallReversibleTernaryNode(SpecialMethodSlot slot, Supplier handlerFactory) { - super(slot); - this.handlerFactory = handlerFactory; - } - - @Specialization(guards = "v.getClass() == cachedVClass", limit = "getCallSiteInlineCacheMaxDepth()") - @SuppressWarnings("truffle-static-method") - Object callObjectR(VirtualFrame frame, Object v, Object w, Object z, - @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached("v.getClass()") Class cachedVClass, - @Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattr, - @Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattrR, - @Exclusive @Cached GetClassNode getClass, - @Exclusive @Cached GetClassNode getClassR, - @Exclusive @Cached GetClassNode getThirdClass, - @Exclusive @Cached IsSubtypeNode isSubtype, - @Exclusive @Cached IsSameTypeNode isSameTypeNode, - @Exclusive @Cached InlinedBranchProfile notImplementedBranch, - @Exclusive @Cached CallTernaryMethodNode dispatchNode) { - return doCallObjectR(frame, inliningTarget, v, w, z, getattr, getattrR, getClass, getClassR, getThirdClass, isSubtype, isSameTypeNode, notImplementedBranch, dispatchNode); - } - - @Specialization(replaces = "callObjectR") - @Megamorphic - @SuppressWarnings("truffle-static-method") - Object callObjectRMegamorphic(VirtualFrame frame, Object v, Object w, Object z, - @Bind("this") Node inliningTarget, - @Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattr, - @Exclusive @Cached("createLookup()") LookupSpecialBaseNode getattrR, - @Exclusive @Cached GetClassNode getClass, - @Exclusive @Cached GetClassNode getClassR, - @Exclusive @Cached GetClassNode getThirdClass, - @Exclusive @Cached IsSubtypeNode isSubtype, - @Exclusive @Cached IsSameTypeNode isSameTypeNode, - @Exclusive @Cached InlinedBranchProfile notImplementedBranch, - @Exclusive @Cached CallTernaryMethodNode dispatchNode) { - return doCallObjectR(frame, inliningTarget, v, w, z, getattr, getattrR, getClass, getClassR, getThirdClass, isSubtype, isSameTypeNode, notImplementedBranch, dispatchNode); - } - - private Object doCallObjectR(VirtualFrame frame, Node inliningTarget, Object v, Object w, Object z, LookupSpecialBaseNode getattr, - LookupSpecialBaseNode getattrR, GetClassNode getClass, GetClassNode getClassR, GetClassNode getThirdClass, - IsSubtypeNode isSubtype, IsSameTypeNode isSameTypeNode, InlinedBranchProfile notImplementedBranch, - CallTernaryMethodNode dispatchNode) { - // c.f. mostly slot_nb_power and wrap_ternaryfunc_r. like - // cpython://Object/abstract.c#ternary_op we try all three combinations, and the structure - // of this method is modeled after this. However, this method also merges the logic from - // slot_nb_power/wrap_ternaryfunc_r in that it swaps arguments around. The reversal is - // undone for builtin functions in BuiltinFunctionRootNode, just like it would be undone in - // CPython using its slot wrappers - Object leftClass = getClass.execute(inliningTarget, v); - Object rightClass = getClassR.execute(inliningTarget, w); - - Object result = PNotImplemented.NOT_IMPLEMENTED; - Object leftCallable = getattr.execute(frame, leftClass, v); - Object rightCallable = PNone.NO_VALUE; - - if (!isSameTypeNode.execute(inliningTarget, leftClass, rightClass)) { - rightCallable = getattrR.execute(frame, rightClass, w); - if (rightCallable == leftCallable) { - rightCallable = PNone.NO_VALUE; - } - } - if (leftCallable != PNone.NO_VALUE) { - if (rightCallable != PNone.NO_VALUE && isSubtype.execute(frame, rightClass, leftClass)) { - result = ensureReverseDispatch().execute(frame, rightCallable, v, w, z); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - rightCallable = PNone.NO_VALUE; - } - result = dispatchNode.execute(frame, leftCallable, v, w, z); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - if (rightCallable != PNone.NO_VALUE) { - result = ensureReverseDispatch().execute(frame, rightCallable, v, w, z); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - - Object zCallable = ensureGetAttrZ().execute(frame, getThirdClass.execute(inliningTarget, z), z); - if (zCallable != PNone.NO_VALUE && zCallable != leftCallable && zCallable != rightCallable) { - result = ensureThirdDispatch().execute(frame, zCallable, v, w, z); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - - notImplementedBranch.enter(inliningTarget); - if (handlerFactory != null) { - if (handler == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - handler = insert(handlerFactory.get()); - } - return handler.execute(v, w, z); - } - return result; - } - - protected CallTernaryMethodNode ensureReverseDispatch() { - // this also serves as a branch profile - if (reverseDispatchNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - reverseDispatchNode = insert(CallTernaryMethodNode.create()); - } - return reverseDispatchNode; - } - - protected CallTernaryMethodNode ensureThirdDispatch() { - // this also serves as a branch profile - if (thirdDispatchNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - thirdDispatchNode = insert(CallTernaryMethodNode.create()); - } - return thirdDispatchNode; - } - - protected LookupSpecialMethodNode ensureGetAttrZ() { - // this also serves as a branch profile - if (getThirdAttrNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getThirdAttrNode = insert(LookupSpecialMethodNode.create(name)); - } - return getThirdAttrNode; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallTernaryNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallTernaryNode.java index 07ca21e71c..51be3c8c75 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallTernaryNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallTernaryNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,25 +41,18 @@ package com.oracle.graal.python.nodes.call.special; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.util.Supplier; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; -// actual implementation is in the subclasses: one for reversible, other for non-reversible. @ImportStatic({SpecialMethodNames.class, PythonOptions.class}) public abstract class LookupAndCallTernaryNode extends Node { - public abstract static class NotImplementedHandler extends PNodeWithContext { - public abstract Object execute(Object arg, Object arg2, Object arg3); - } protected final TruffleString name; - protected final SpecialMethodSlot slot; public abstract Object execute(VirtualFrame frame, Object arg1, Object arg2, Object arg3); @@ -72,36 +65,12 @@ public static LookupAndCallTernaryNode create(TruffleString name) { return LookupAndCallNonReversibleTernaryNodeGen.create(name); } - @NeverDefault - public static LookupAndCallTernaryNode create(SpecialMethodSlot slot) { - return LookupAndCallNonReversibleTernaryNodeGen.create(slot); - } - - @NeverDefault - public static LookupAndCallTernaryNode createReversible(TruffleString name, Supplier handlerFactory) { - return LookupAndCallReversibleTernaryNodeGen.create(name, handlerFactory); - } - - @NeverDefault - public static LookupAndCallTernaryNode createReversible(SpecialMethodSlot slot, Supplier handlerFactory) { - return LookupAndCallReversibleTernaryNodeGen.create(slot, handlerFactory); - } - LookupAndCallTernaryNode(TruffleString name) { this.name = name; - this.slot = null; - } - - LookupAndCallTernaryNode(SpecialMethodSlot slot) { - this.slot = slot; - this.name = slot.getName(); } @NeverDefault protected final LookupSpecialBaseNode createLookup() { - if (slot != null) { - return LookupSpecialMethodSlotNode.create(slot); - } return LookupSpecialMethodNode.create(name); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java index e73fcb5874..cc8c33b374 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java @@ -43,11 +43,7 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T_PRINT; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsArray; -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; import com.oracle.graal.python.lib.PyNumberAddNode; @@ -76,7 +72,6 @@ import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -107,50 +102,11 @@ interface CreateBinaryOp { this.create = create; } - /** - * A helper root node that dispatches to {@link LookupAndCallBinaryNode} to execute the provided - * ternary operator. Note: this is just a root node and won't do any signature checking. - */ - static final class CallBinaryArithmeticRootNode extends CallArithmeticRootNode { - static final Signature SIGNATURE_BINARY = new Signature(2, false, -1, false, tsArray("$self", "other"), null); - - @Child private BinaryOpNode callBinaryNode; - - private final BinaryArithmetic binaryOperator; - - CallBinaryArithmeticRootNode(PythonLanguage language, BinaryArithmetic binaryOperator) { - super(language); - this.binaryOperator = binaryOperator; - } - - @Override - public Signature getSignature() { - return SIGNATURE_BINARY; - } - - @Override - protected Object doCall(VirtualFrame frame) { - if (callBinaryNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callBinaryNode = insert(binaryOperator.create()); - } - return callBinaryNode.execute(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1)); - } - } - @NeverDefault public BinaryOpNode create() { return create.create(); } - /** - * Creates a root node for this binary operator such that the operator can be executed via a - * full call. - */ - public RootNode createRootNode(PythonLanguage language) { - return new CallBinaryArithmeticRootNode(language, this); - } - @ImportStatic(SpecialMethodNames.class) public abstract static class BinaryArithmeticNode extends BinaryOpNode { @@ -174,12 +130,6 @@ private TruffleString getErrorMessage(Object arg) { }; } - @NeverDefault - public static LookupAndCallBinaryNode createCallNode(SpecialMethodSlot slot, Supplier handler) { - assert slot.getReverse() != null; - return LookupAndCallBinaryNode.createReversible(slot, slot.getReverse(), handler); - } - } public abstract static class GenericBinaryArithmeticNode extends BinaryArithmeticNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java deleted file mode 100644 index 7248ea944d..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/InplaceArithmetic.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2018, 2025, 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.expression; - -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___XOR__; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic.CallBinaryArithmeticRootNode; -import com.oracle.graal.python.nodes.expression.TernaryArithmetic.CallTernaryArithmeticRootNode; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -public enum InplaceArithmetic { - IAdd(SpecialMethodSlot.IAdd, T___ADD__, "+=", BinaryArithmetic.Add), - ISub(T___ISUB__, T___SUB__, "-=", BinaryArithmetic.Sub), - IMul(SpecialMethodSlot.IMul, T___MUL__, "*=", BinaryArithmetic.Mul), - ITrueDiv(T___ITRUEDIV__, T___TRUEDIV__, "/=", BinaryArithmetic.TrueDiv), - IFloorDiv(T___IFLOORDIV__, T___FLOORDIV__, "//=", BinaryArithmetic.FloorDiv), - IMod(T___IMOD__, T___MOD__, "%=", BinaryArithmetic.Mod), - IPow(T___IPOW__, T___POW__, "**=", BinaryArithmetic.Pow, true), - ILShift(T___ILSHIFT__, T___LSHIFT__, "<<=", BinaryArithmetic.LShift), - IRShift(T___IRSHIFT__, T___RSHIFT__, ">>=", BinaryArithmetic.RShift), - IAnd(T___IAND__, T___AND__, "&=", BinaryArithmetic.And), - IOr(T___IOR__, T___OR__, "|=", BinaryArithmetic.Or), - IXor(T___IXOR__, T___XOR__, "^=", BinaryArithmetic.Xor), - IMatMul(T___IMATMUL__, T___MATMUL__, "@", BinaryArithmetic.MatMul); - - final TruffleString methodName; - final SpecialMethodSlot slot; - final boolean isTernary; - final Supplier notImplementedHandler; - final BinaryArithmetic binary; - final TruffleString binaryOpName; - - InplaceArithmetic(TruffleString methodName, TruffleString binaryOpName, String operator, BinaryArithmetic binary) { - this(methodName, binaryOpName, operator, binary, false); - } - - InplaceArithmetic(SpecialMethodSlot slot, TruffleString binaryOpName, String operator, BinaryArithmetic binary) { - this(slot.getName(), binaryOpName, operator, binary, false, slot); - } - - InplaceArithmetic(TruffleString methodName, TruffleString binaryOpName, String operator, BinaryArithmetic binary, boolean isTernary) { - this(methodName, binaryOpName, operator, binary, isTernary, null); - } - - InplaceArithmetic(TruffleString methodName, TruffleString binaryOpName, @SuppressWarnings("unused") String operator, BinaryArithmetic binary, boolean isTernary, SpecialMethodSlot slot) { - assert methodName.toJavaStringUncached().startsWith("__i") && methodName.toJavaStringUncached().substring(3).equals(binaryOpName.toJavaStringUncached().substring(2)); - this.methodName = methodName; - this.binary = binary; - this.isTernary = isTernary; - this.binaryOpName = binaryOpName; - this.slot = slot; - - this.notImplementedHandler = () -> new LookupAndCallInplaceNode.NotImplementedHandler() { - private final BranchProfile errorProfile = BranchProfile.create(); - - @Override - public Object execute(Object arg, Object arg2) { - errorProfile.enter(); - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, operator, arg, arg2); - } - }; - } - - public TruffleString getMethodName() { - return methodName; - } - - public boolean isTernary() { - return isTernary; - } - - /** - * A helper root node that dispatches to {@link LookupAndCallInplaceNode} to execute the - * provided in-place operator. This node is mostly useful to use such operators from a location - * without a frame (e.g. from interop). Note: this is just a root node and won't do any - * signature checking. - */ - static final class CallInplaceArithmeticRootNode extends CallArithmeticRootNode { - - @Child private LookupAndCallInplaceNode callInplaceNode; - - private final InplaceArithmetic inplaceOperator; - - CallInplaceArithmeticRootNode(PythonLanguage language, InplaceArithmetic inplaceOperator) { - super(language); - this.inplaceOperator = inplaceOperator; - } - - @Override - public Signature getSignature() { - if (inplaceOperator.isTernary()) { - return CallTernaryArithmeticRootNode.SIGNATURE_TERNARY; - } - return CallBinaryArithmeticRootNode.SIGNATURE_BINARY; - } - - @Override - protected Object doCall(VirtualFrame frame) { - if (callInplaceNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callInplaceNode = insert(inplaceOperator.create()); - } - // most of the in-place operators are binary but there can also be ternary - if (inplaceOperator.isTernary()) { - return callInplaceNode.executeTernary(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1), PArguments.getArgument(frame, 2)); - } - return callInplaceNode.execute(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1)); - } - } - - public LookupAndCallInplaceNode create() { - return LookupAndCallInplaceNode.create(this); - } - - /** - * Creates a root node for this in-place operator such that the operator can be executed via a - * full call. - */ - public RootNode createRootNode(PythonLanguage language) { - return new CallInplaceArithmeticRootNode(language, this); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java deleted file mode 100644 index 098bf33c3d..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/LookupAndCallInplaceNode.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2018, 2025, 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.expression; - -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode; -import com.oracle.graal.python.nodes.attributes.LookupInMROBaseNode; -import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; - -public abstract class LookupAndCallInplaceNode extends PNodeWithContext implements BinaryOp { - - public abstract static class NotImplementedHandler extends PNodeWithContext { - public abstract Object execute(Object arg, Object arg2); - } - - @Child private CallBinaryMethodNode callBinaryMethodNode; - @Child private BinaryOpNode binaryOpNode; - @Child private LookupAndCallTernaryNode lookupAndCallTernaryNode; - @Child private NotImplementedHandler handler; - - final InplaceArithmetic arithmetic; - - LookupAndCallInplaceNode(InplaceArithmetic arithmetic) { - this.arithmetic = arithmetic; - } - - public static LookupAndCallInplaceNode create(InplaceArithmetic arithmetic) { - return LookupAndCallInplaceNodeGen.create(arithmetic); - } - - private CallBinaryMethodNode ensureBinaryCallNode() { - if (callBinaryMethodNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callBinaryMethodNode = insert(CallBinaryMethodNode.create()); - } - return callBinaryMethodNode; - } - - private BinaryOpNode ensureLookupAndCallBinaryNode() { - if (binaryOpNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - binaryOpNode = insert(arithmetic.binary.create()); - } - return binaryOpNode; - } - - private LookupAndCallTernaryNode ensureLookupAndCallTernaryNode() { - if (lookupAndCallTernaryNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - lookupAndCallTernaryNode = insert(LookupAndCallTernaryNode.createReversible(arithmetic.binaryOpName, null)); - } - return lookupAndCallTernaryNode; - } - - @Override - public final Object execute(VirtualFrame frame, Object left, Object right) { - return executeTernary(frame, left, right, PNone.NO_VALUE); - } - - public abstract Object executeTernary(VirtualFrame frame, Object x, Object y, Object z); - - @NeverDefault - protected final LookupInMROBaseNode createInplaceLookup() { - if (arithmetic.slot != null) { - return LookupCallableSlotInMRONode.create(arithmetic.slot); - } else { - return LookupAttributeInMRONode.create(arithmetic.methodName); - } - } - - @Specialization - Object doBinary(VirtualFrame frame, Object left, Object right, Object z, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached("createInplaceLookup()") LookupInMROBaseNode lookupInplace) { - Object result; - Object inplaceCallable = lookupInplace.execute(getClassNode.execute(inliningTarget, left)); - if (inplaceCallable != PNone.NO_VALUE) { - // nb.: The only ternary in-place operator is '__ipow__' but according to 'typeobject.c: - // slot_nb_inplace_power', this is always called as binary. - result = ensureBinaryCallNode().executeObject(frame, inplaceCallable, left, right); - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - } - - // try non-inplace variant - boolean isBinary = PGuards.isPNone(z); - if (isBinary) { - result = ensureLookupAndCallBinaryNode().execute(frame, left, right); - } else { - result = ensureLookupAndCallTernaryNode().execute(frame, left, right, z); - } - if (result != PNotImplemented.NOT_IMPLEMENTED) { - return result; - } - if (handler == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - handler = insert(arithmetic.notImplementedHandler.get()); - } - return handler.execute(left, right); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java deleted file mode 100644 index 142e626203..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/TernaryArithmetic.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2018, 2025, 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.expression; - -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; -import static com.oracle.graal.python.util.PythonUtils.tsArray; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode.NotImplementedHandler; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -public enum TernaryArithmetic { - Pow(SpecialMethodNames.T___POW__, "**", "pow"); - - private final TruffleString methodName; - private final Supplier notImplementedHandler; - - TernaryArithmetic(TruffleString methodName, @SuppressWarnings("unused") String operator, String operatorFunction) { - this.methodName = methodName; - this.notImplementedHandler = () -> new NotImplementedHandler() { - private final BranchProfile errorProfile = BranchProfile.create(); - - @Override - public Object execute(Object arg, Object arg2, Object arg3) { - errorProfile.enter(); - if (arg3 instanceof PNone) { - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_PR_S_P_AND_P, operator, operatorFunction, arg, arg2); - } else { - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_P_P, operatorFunction, arg, arg2, arg3); - } - } - }; - } - - public TruffleString getMethodName() { - return methodName; - } - - /** - * A helper root node that dispatches to {@link LookupAndCallTernaryNode} to execute the - * provided ternary operator. This node is mostly useful to use such operators from a location - * without a frame (e.g. from interop). Note: this is just a root node and won't do any - * signature checking. - */ - static final class CallTernaryArithmeticRootNode extends CallArithmeticRootNode { - static final Signature SIGNATURE_TERNARY = new Signature(3, false, -1, false, tsArray("x", "y", "z"), null); - - @Child private LookupAndCallTernaryNode callTernaryNode; - - private final TernaryArithmetic ternaryOperator; - - private CallTernaryArithmeticRootNode(PythonLanguage language, TernaryArithmetic ternaryOperator) { - super(language); - this.ternaryOperator = ternaryOperator; - } - - @Override - public Signature getSignature() { - return SIGNATURE_TERNARY; - } - - @Override - protected Object doCall(VirtualFrame frame) { - if (callTernaryNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callTernaryNode = insert(ternaryOperator.create()); - } - return callTernaryNode.execute(frame, PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1), PArguments.getArgument(frame, 2)); - } - } - - public LookupAndCallTernaryNode create() { - return LookupAndCallTernaryNode.createReversible(methodName, notImplementedHandler); - } - - /** - * Creates a root node for this ternary operator such that the operator can be executed via a - * full call. - */ - public RootNode createRootNode(PythonLanguage language) { - return new CallTernaryArithmeticRootNode(language, this); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java index a60c3167d3..f6d45c140b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java @@ -41,11 +41,7 @@ package com.oracle.graal.python.nodes.expression; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; -import static com.oracle.graal.python.util.PythonUtils.tsArray; -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.lib.PyNumberInvertNode; import com.oracle.graal.python.lib.PyNumberNegativeNode; import com.oracle.graal.python.lib.PyNumberPositiveNode; @@ -55,14 +51,12 @@ import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.NoAttributeHandler; import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.api.strings.TruffleString; @@ -81,51 +75,10 @@ interface CreateUnaryOp { this.create = create; } - /** - * A helper root node that dispatches to {@link LookupAndCallUnaryNode} to execute the provided - * unary operator. This node is mostly useful to use such operators from a location without a - * frame (e.g. from interop). Note: this is just a root node and won't do any signature - * checking. - */ - static final class CallUnaryArithmeticRootNode extends CallArithmeticRootNode { - private static final Signature SIGNATURE_UNARY = new Signature(1, false, -1, false, tsArray("$self"), null); - - @Child private UnaryOpNode callUnaryNode; - - private final UnaryArithmetic unaryOperator; - - CallUnaryArithmeticRootNode(PythonLanguage language, UnaryArithmetic unaryOperator) { - super(language); - this.unaryOperator = unaryOperator; - } - - @Override - public Signature getSignature() { - return SIGNATURE_UNARY; - } - - @Override - protected Object doCall(VirtualFrame frame) { - if (callUnaryNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callUnaryNode = insert(unaryOperator.create()); - } - return callUnaryNode.execute(frame, PArguments.getArgument(frame, 0)); - } - } - public UnaryOpNode create() { return create.create(); } - /** - * Creates a root node for this unary operator such that the operator can be executed via a full - * call. - */ - public RootNode createRootNode(PythonLanguage language) { - return new CallUnaryArithmeticRootNode(language, this); - } - @ImportStatic(SpecialMethodNames.class) public abstract static class UnaryArithmeticNode extends UnaryOpNode { From 56b614a5984e1156d6947f5bec2c81e7118bdcd2 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 16:36:45 +0100 Subject: [PATCH 040/512] Remove old delattr slot --- .../builtins/modules/AbcModuleBuiltins.java | 8 +- .../builtins/modules/BuiltinFunctions.java | 5 +- .../objects/type/SpecialMethodSlot.java | 8 -- .../graal/python/lib/PyObjectSetAttr.java | 4 + .../nodes/attributes/DeleteAttributeNode.java | 76 ------------------- .../python/nodes/frame/DeleteGlobalNode.java | 12 +-- 6 files changed, 15 insertions(+), 98 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/DeleteAttributeNode.java diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java index 51a5c1bbc3..ac6be1a5ce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/AbcModuleBuiltins.java @@ -58,10 +58,10 @@ import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetSubclassesAsArrayNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectSetAttr; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.attributes.DeleteAttributeNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; @@ -70,7 +70,6 @@ import com.oracle.graal.python.runtime.PythonContext; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -94,8 +93,7 @@ abstract static class AbcInitCollectionFlagsNode extends PythonUnaryBuiltinNode @TruffleBoundary @Specialization static Object init(Object object, - @Bind("this") Node inliningTarget, - @Cached DeleteAttributeNode deleteAttributeNode) { + @Bind("this") Node inliningTarget) { if (TypeNodes.IsTypeNode.executeUncached(object)) { Object flags = PyObjectLookupAttr.executeUncached(object, ABC_TPFLAGS); long val; @@ -117,7 +115,7 @@ static Object init(Object object, type = (PythonAbstractObject) object; } HiddenAttr.WriteNode.executeUncached(type, HiddenAttr.FLAGS, tpFlags); - deleteAttributeNode.execute(null, inliningTarget, object, ABC_TPFLAGS); + PyObjectSetAttr.deleteUncached(object, ABC_TPFLAGS); } return PNone.NONE; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 1669baa4b4..721debf322 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -200,7 +200,6 @@ import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.StringLiterals; import com.oracle.graal.python.nodes.argument.ReadArgumentNode; -import com.oracle.graal.python.nodes.attributes.DeleteAttributeNode; import com.oracle.graal.python.nodes.attributes.GetAttributeNode; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; import com.oracle.graal.python.nodes.builtins.ListNodes; @@ -1276,8 +1275,8 @@ abstract static class DelAttrNode extends PythonBinaryBuiltinNode { @Specialization Object delattr(VirtualFrame frame, Object object, Object name, @Bind("this") Node inliningTarget, - @Cached DeleteAttributeNode delNode) { - delNode.execute(frame, inliningTarget, object, name); + @Cached PyObjectSetAttrO setAttr) { + setAttr.execute(frame, inliningTarget, object, name, NO_VALUE); return PNone.NONE; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java index 6e3969706a..f46ae14faa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java @@ -57,7 +57,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BYTES__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELATTR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ENTER__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EXIT__; @@ -151,8 +150,6 @@ * initialized. */ public enum SpecialMethodSlot { - DelAttr(T___DELATTR__), - Dict(T___DICT__), Iter(T___ITER__), @@ -750,11 +747,6 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin return SetName; } break; - case 'd' * 26 + 'e': // de - if (eqNode.execute(name, T___DELATTR__, TS_ENCODING)) { - return DelAttr; - } - break; case 'd' * 26 + 'i': // di if (eqNode.execute(name, T___DICT__, TS_ENCODING)) { return Dict; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java index 36da362ca1..21b82c45a0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectSetAttr.java @@ -95,6 +95,10 @@ public final void deleteCached(Frame frame, Object receiver, TruffleString name) execute(frame, null, receiver, name, PNone.NO_VALUE); } + public static void deleteUncached(Object receiver, TruffleString name) { + executeUncached(receiver, name, PNone.NO_VALUE); + } + public final void delete(Frame frame, Node inliningTarget, Object receiver, TruffleString name) { execute(frame, inliningTarget, receiver, name, PNone.NO_VALUE); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/DeleteAttributeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/DeleteAttributeNode.java deleted file mode 100644 index 0878e51610..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/DeleteAttributeNode.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2017, 2023, 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.attributes; - -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; - -@GenerateUncached -@GenerateInline -@GenerateCached(false) -public abstract class DeleteAttributeNode extends PNodeWithContext { - public abstract void execute(VirtualFrame frame, Node inliningTarget, Object object, Object key); - - @Specialization - protected void doIt(VirtualFrame frame, Object object, Object key, - @Cached(value = "create(DelAttr)", inline = false) LookupAndCallBinaryNode call) { - call.executeObject(frame, object, key); - } - - @Specialization(replaces = "doIt") - protected void doItUncached(VirtualFrame frame, Object object, Object key) { - PythonUtils.assertUncached(); - Object klass = GetClassNode.executeUncached(object); - Object method = LookupCallableSlotInMRONode.getUncached(SpecialMethodSlot.DelAttr).execute(klass); - CallBinaryMethodNode.getUncached().executeObject(frame, method, object, key); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/DeleteGlobalNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/DeleteGlobalNode.java index e24332f33f..8c5589cc2f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/DeleteGlobalNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/DeleteGlobalNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -43,8 +43,8 @@ import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.lib.PyObjectDelItem; +import com.oracle.graal.python.lib.PyObjectSetAttr; import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.attributes.DeleteAttributeNode; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -88,14 +88,14 @@ static void deleteDict(VirtualFrame frame, PDict globals, TruffleString attribut static void deleteModuleCached(VirtualFrame frame, @SuppressWarnings("unused") PythonModule globals, TruffleString attributeId, @Bind("this") Node inliningTarget, @Cached(value = "globals", weak = true) PythonModule cachedGlobals, - @Shared @Cached DeleteAttributeNode storeNode) { - storeNode.execute(frame, inliningTarget, cachedGlobals, attributeId); + @Shared @Cached PyObjectSetAttr setAttr) { + setAttr.delete(frame, inliningTarget, cachedGlobals, attributeId); } @Specialization(replaces = "deleteModuleCached") static void deleteModule(VirtualFrame frame, PythonModule globals, TruffleString attributeId, @Bind("this") Node inliningTarget, - @Shared @Cached DeleteAttributeNode storeNode) { - storeNode.execute(frame, inliningTarget, globals, attributeId); + @Shared @Cached PyObjectSetAttr setAttr) { + setAttr.delete(frame, inliningTarget, globals, attributeId); } } From 81460392dac5e06d3e1bda6d7a772ebf054e38c7 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Wed, 19 Feb 2025 17:07:44 +0100 Subject: [PATCH 041/512] Remove *naryArithmetic classes --- .../builtins/modules/MathModuleBuiltins.java | 9 +- .../builtins/modules/PosixModuleBuiltins.java | 9 +- .../foreign/ForeignNumberBuiltins.java | 52 +++--- .../mappingproxy/MappingproxyBuiltins.java | 7 +- .../objects/types/UnionTypeBuiltins.java | 7 +- .../call/special/LookupAndCallUnaryNode.java | 10 +- .../nodes/expression/BinaryArithmetic.java | 159 ------------------ .../nodes/expression/UnaryArithmetic.java | 129 -------------- 8 files changed, 55 insertions(+), 327 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java index 38a0d39fad..33cde1d47e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java @@ -56,6 +56,7 @@ import com.oracle.graal.python.lib.PyLongFromDoubleNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; import com.oracle.graal.python.lib.PyNumberIndexNode; +import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; @@ -65,9 +66,7 @@ import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -2469,14 +2468,14 @@ private static void raiseIfNegative(Node inliningTarget, boolean condition, PRai public abstract static class ProdNode extends PythonBuiltinNode { @Child private LookupAndCallUnaryNode callNextNode = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next); - @Child private BinaryOpNode mul = BinaryArithmetic.Mul.create(); @Specialization public Object doGeneric(VirtualFrame frame, Object iterable, Object startIn, @Bind("this") Node inliningTarget, @Cached IsBuiltinObjectProfile errorProfile, @Cached InlinedConditionProfile startIsNoValueProfile, - @Cached PyObjectGetIter getIter) { + @Cached PyObjectGetIter getIter, + @Cached PyNumberMultiplyNode multiplyNode) { Object start = startIsNoValueProfile.profile(inliningTarget, PGuards.isNoValue(startIn)) ? 1 : startIn; Object iterator = getIter.execute(frame, inliningTarget, iterable); Object value = start; @@ -2488,7 +2487,7 @@ public Object doGeneric(VirtualFrame frame, Object iterable, Object startIn, e.expectStopIteration(inliningTarget, errorProfile); return value; } - value = mul.execute(frame, value, nextValue); + value = multiplyNode.execute(frame, inliningTarget, value, nextValue); } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index b83c26208c..0877f1c927 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -88,6 +88,7 @@ import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode; import com.oracle.graal.python.lib.PyLongAsLongNode; import com.oracle.graal.python.lib.PyLongCheckNode; +import com.oracle.graal.python.lib.PyNumberDivmodNode; import com.oracle.graal.python.lib.PyNumberIndexNode; import com.oracle.graal.python.lib.PyOSFSPathNode; import com.oracle.graal.python.lib.PyObjectAsFileDescriptor; @@ -98,8 +99,6 @@ import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; @@ -3300,7 +3299,7 @@ static void doGeneric(VirtualFrame frame, Node inliningTarget, Object value, lon */ @GenerateInline @GenerateCached(false) - @ImportStatic({BinaryArithmetic.class, PGuards.class}) + @ImportStatic(PGuards.class) abstract static class SplitLongToSAndNsNode extends ConvertToTimespecBaseNode { private static final long BILLION = 1000000000; @@ -3318,12 +3317,12 @@ static void doLong(long value, long[] timespec, int offset) { @Specialization(guards = {"!isInteger(value)"}) static void doGeneric(VirtualFrame frame, Node inliningTarget, Object value, long[] timespec, int offset, - @Cached(value = "DivMod.create()", inline = false) BinaryOpNode callDivmod, + @Cached PyNumberDivmodNode divmodNode, @Cached LenNode lenNode, @Cached(value = "createNotNormalized()", inline = false) GetItemNode getItemNode, @Cached PyLongAsLongNode asLongNode, @Cached PRaiseNode raiseNode) { - Object divmod = callDivmod.execute(frame, value, BILLION); + Object divmod = divmodNode.execute(frame, inliningTarget, value, BILLION); if (!PGuards.isPTuple(divmod) || lenNode.execute(inliningTarget, (PSequence) divmod) != 2) { throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.MUST_RETURN_2TUPLE, value, divmod); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index 88f2b2a367..9cff1707f4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -65,8 +65,10 @@ import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberAndNode; import com.oracle.graal.python.lib.PyNumberDivmodNode; +import com.oracle.graal.python.lib.PyNumberFloatNode; import com.oracle.graal.python.lib.PyNumberFloorDivideNode; import com.oracle.graal.python.lib.PyNumberInvertNode; +import com.oracle.graal.python.lib.PyNumberLongNode; import com.oracle.graal.python.lib.PyNumberLshiftNode; import com.oracle.graal.python.lib.PyNumberMultiplyNode; import com.oracle.graal.python.lib.PyNumberNegativeNode; @@ -83,9 +85,8 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; +import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.expression.BinaryOpNode; -import com.oracle.graal.python.nodes.expression.UnaryArithmetic; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -268,11 +269,8 @@ Object doGeneric(VirtualFrame frame, Object value, @Bind("this") Node inliningTarget, @Cached UnboxNode unboxNode) { Object unboxed = unboxNode.execute(inliningTarget, value); - if (unboxed != null) { - return op.execute(frame, unboxed); - } else { - return PNotImplemented.NOT_IMPLEMENTED; - } + assert unboxed != null; + return op.execute(frame, unboxed); } } @@ -393,7 +391,7 @@ abstract static class AbsNode extends ForeignUnaryNode { @GenerateNodeFactory abstract static class CeilNode extends ForeignUnaryNode { CeilNode() { - super(UnaryArithmetic.GenericUnaryArithmeticNode.create(SpecialMethodNames.T___CEIL__)); + super(LookupAndCallUnaryNode.create(SpecialMethodNames.T___CEIL__)); } } @@ -401,7 +399,7 @@ abstract static class CeilNode extends ForeignUnaryNode { @GenerateNodeFactory abstract static class FloorNode extends ForeignUnaryNode { FloorNode() { - super(UnaryArithmetic.GenericUnaryArithmeticNode.create(SpecialMethodNames.T___FLOOR__)); + super(LookupAndCallUnaryNode.create(SpecialMethodNames.T___FLOOR__)); } } @@ -409,23 +407,33 @@ abstract static class FloorNode extends ForeignUnaryNode { @GenerateNodeFactory abstract static class TruncNode extends ForeignUnaryNode { TruncNode() { - super(UnaryArithmetic.GenericUnaryArithmeticNode.create(SpecialMethodNames.T___TRUNC__)); + super(LookupAndCallUnaryNode.create(SpecialMethodNames.T___TRUNC__)); } } @Slot(value = SlotKind.nb_int, isComplex = true) @GenerateNodeFactory - abstract static class IntNode extends ForeignUnaryNode { - IntNode() { - super(UnaryArithmetic.GenericUnaryArithmeticNode.create(SpecialMethodNames.T___INT__)); + abstract static class IntNode extends PythonUnaryBuiltinNode { + @Specialization + Object doGeneric(VirtualFrame frame, Object self, + @Bind("this") Node inliningTarget, + @Cached UnboxNode unboxNode, + @Cached PyNumberLongNode longNode) { + Object unboxed = unboxNode.execute(inliningTarget, self); + return longNode.execute(frame, inliningTarget, unboxed); } } @Slot(value = SlotKind.nb_float, isComplex = true) @GenerateNodeFactory - abstract static class FloatNode extends ForeignUnaryNode { - FloatNode() { - super(UnaryArithmetic.GenericUnaryArithmeticNode.create(SpecialMethodNames.T___FLOAT__)); + abstract static class FloatNode extends PythonUnaryBuiltinNode { + @Specialization + Object doGeneric(VirtualFrame frame, Object self, + @Bind("this") Node inliningTarget, + @Cached UnboxNode unboxNode, + @Cached PyNumberFloatNode floatNode) { + Object unboxed = unboxNode.execute(inliningTarget, self); + return floatNode.execute(frame, inliningTarget, unboxed); } } @@ -598,9 +606,15 @@ static Object doIt(VirtualFrame frame, Object v, Object w, Object z, @Builtin(name = J___ROUND__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) @GenerateNodeFactory - abstract static class RoundNode extends ForeignBinaryNode { - RoundNode() { - super(BinaryArithmetic.GenericBinaryArithmeticNode.create(SpecialMethodSlot.Round), false); + abstract static class RoundNode extends PythonBinaryBuiltinNode { + + @Specialization + Object doGeneric(VirtualFrame frame, Object self, Object n, + @Bind("this") Node inliningTarget, + @Cached UnboxNode unboxNode, + @Cached("create(Round)") LookupAndCallBinaryNode callRound) { + Object unboxed = unboxNode.execute(inliningTarget, self); + return callRound.executeObject(frame, unboxed, n); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java index f4e552d8d0..6d7c857758 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java @@ -61,6 +61,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode; +import com.oracle.graal.python.lib.PyNumberOrNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectGetItem; import com.oracle.graal.python.lib.PyObjectGetIter; @@ -70,8 +71,6 @@ import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -267,10 +266,10 @@ static Object classGetItem(Object cls, Object key, @Slot(value = SlotKind.nb_or, isComplex = true) @GenerateNodeFactory abstract static class OrNode extends BinaryOpBuiltinNode { - @Child BinaryOpNode orNode = BinaryArithmetic.Or.create(); @Specialization - Object or(VirtualFrame frame, Object self, Object other) { + static Object or(VirtualFrame frame, Object self, Object other, + @Cached PyNumberOrNode orNode) { if (self instanceof PMappingproxy) { self = ((PMappingproxy) self).getMapping(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java index 92cb0e4033..f638494029 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java @@ -73,14 +73,13 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; +import com.oracle.graal.python.lib.PyNumberOrNode; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.StringLiterals; -import com.oracle.graal.python.nodes.expression.BinaryArithmetic; -import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; @@ -289,12 +288,12 @@ Object eq(Object self, Object other) { @Slot(value = SlotKind.mp_subscript, isComplex = true) @GenerateNodeFactory abstract static class GetItemNode extends MpSubscriptBuiltinNode { - @Child BinaryOpNode orNode = BinaryArithmetic.Or.create(); @Specialization Object getitem(VirtualFrame frame, PUnionType self, Object item, @Bind("this") Node inliningTarget, - @Cached InlinedBranchProfile createProfile) { + @Cached InlinedBranchProfile createProfile, + @Cached PyNumberOrNode orNode) { if (self.getParameters() == null) { createProfile.enter(inliningTarget); self.setParameters(PFactory.createTuple(PythonLanguage.get(inliningTarget), GenericTypeNodes.makeParameters(self.getArgs()))); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallUnaryNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallUnaryNode.java index 6b0549a2b0..e906b0a994 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallUnaryNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallUnaryNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -47,6 +47,7 @@ import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; +import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonOptions; @@ -66,7 +67,7 @@ import com.oracle.truffle.api.strings.TruffleString; @ImportStatic(PythonOptions.class) -public abstract class LookupAndCallUnaryNode extends Node { +public abstract class LookupAndCallUnaryNode extends UnaryOpNode { public abstract static class NoAttributeHandler extends PNodeWithContext { public abstract Object execute(Object receiver); @@ -79,6 +80,11 @@ public abstract static class NoAttributeHandler extends PNodeWithContext { public abstract Object executeObject(VirtualFrame frame, Object receiver); + @Override + public Object execute(VirtualFrame frame, Object receiver) { + return executeObject(frame, receiver); + } + @NeverDefault public static LookupAndCallUnaryNode create(TruffleString name) { return LookupAndCallUnaryNodeGen.create(name, null); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java deleted file mode 100644 index cc8c33b374..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/BinaryArithmetic.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2018, 2025, 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.expression; - -import static com.oracle.graal.python.nodes.BuiltinNames.T_PRINT; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; - -import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.lib.PyNumberAddNode; -import com.oracle.graal.python.lib.PyNumberAndNode; -import com.oracle.graal.python.lib.PyNumberDivmodNode; -import com.oracle.graal.python.lib.PyNumberFloorDivideNode; -import com.oracle.graal.python.lib.PyNumberLshiftNode; -import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; -import com.oracle.graal.python.lib.PyNumberMultiplyNode; -import com.oracle.graal.python.lib.PyNumberOrNode; -import com.oracle.graal.python.lib.PyNumberPowerNode; -import com.oracle.graal.python.lib.PyNumberRemainderNode; -import com.oracle.graal.python.lib.PyNumberRshiftNode; -import com.oracle.graal.python.lib.PyNumberSubtractNode; -import com.oracle.graal.python.lib.PyNumberTrueDivideNode; -import com.oracle.graal.python.lib.PyNumberXorNode; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; -import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode.NotImplementedHandler; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -@SuppressWarnings("truffle-inlining") -public enum BinaryArithmetic { - Add(PyNumberAddNode::create), - Sub(PyNumberSubtractNode::create), - Mul(PyNumberMultiplyNode::create), - TrueDiv(PyNumberTrueDivideNode::create), - FloorDiv(PyNumberFloorDivideNode::create), - Mod(PyNumberRemainderNode::create), - LShift(PyNumberLshiftNode::create), - RShift(PyNumberRshiftNode::create), - And(PyNumberAndNode::create), - Or(PyNumberOrNode::create), - Xor(PyNumberXorNode::create), - MatMul(PyNumberMatrixMultiplyNode::create), - Pow(PyNumberPowerNode::create), - DivMod(PyNumberDivmodNode::create); - - interface CreateBinaryOp { - BinaryOpNode create(); - } - - private final CreateBinaryOp create; - - BinaryArithmetic(CreateBinaryOp create) { - this.create = create; - } - - @NeverDefault - public BinaryOpNode create() { - return create.create(); - } - - @ImportStatic(SpecialMethodNames.class) - public abstract static class BinaryArithmeticNode extends BinaryOpNode { - - static Supplier createHandler(String operator) { - return () -> new NotImplementedHandler() { - private final BranchProfile errorProfile = BranchProfile.create(); - - @Override - public Object execute(VirtualFrame frame, Object arg, Object arg2) { - errorProfile.enter(); - throw PRaiseNode.raiseStatic(this, TypeError, getErrorMessage(arg), operator, arg, arg2); - } - - @CompilerDirectives.TruffleBoundary - private TruffleString getErrorMessage(Object arg) { - if (operator.equals(">>") && arg instanceof PBuiltinMethod && ((PBuiltinMethod) arg).getBuiltinFunction().getName().equalsUncached(T_PRINT, TS_ENCODING)) { - return ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P_PRINT; - } - return ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P; - } - }; - } - - } - - public abstract static class GenericBinaryArithmeticNode extends BinaryArithmeticNode { - - private final SpecialMethodSlot slot; - - protected GenericBinaryArithmeticNode(SpecialMethodSlot slot) { - this.slot = slot; - } - - @Specialization - public static Object doGeneric(VirtualFrame frame, Object left, Object right, - @Cached("createCallNode()") LookupAndCallBinaryNode callNode) { - return callNode.executeObject(frame, left, right); - } - - @NeverDefault - protected LookupAndCallBinaryNode createCallNode() { - return LookupAndCallBinaryNode.create(slot, createHandler(slot.getName().toString())); - } - - @NeverDefault - public static GenericBinaryArithmeticNode create(SpecialMethodSlot slot) { - return BinaryArithmeticFactory.GenericBinaryArithmeticNodeGen.create(slot); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java deleted file mode 100644 index f6d45c140b..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/UnaryArithmetic.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2018, 2025, 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.expression; - -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; - -import com.oracle.graal.python.lib.PyNumberInvertNode; -import com.oracle.graal.python.lib.PyNumberNegativeNode; -import com.oracle.graal.python.lib.PyNumberPositiveNode; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.NoAttributeHandler; -import com.oracle.graal.python.util.Supplier; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -public enum UnaryArithmetic { - Pos(PyNumberPositiveNode::create), - Neg(PyNumberNegativeNode::create), - Invert(PyNumberInvertNode::create); - - interface CreateUnaryOp { - UnaryOpNode create(); - } - - private final CreateUnaryOp create; - - UnaryArithmetic(CreateUnaryOp create) { - this.create = create; - } - - public UnaryOpNode create() { - return create.create(); - } - - @ImportStatic(SpecialMethodNames.class) - public abstract static class UnaryArithmeticNode extends UnaryOpNode { - - static Supplier createHandler(String operator) { - - return () -> new NoAttributeHandler() { - private final BranchProfile errorProfile = BranchProfile.create(); - - @Override - public Object execute(Object receiver) { - errorProfile.enter(); - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.BAD_OPERAND_FOR, "unary ", operator, receiver); - } - }; - } - - @NeverDefault - public static LookupAndCallUnaryNode createCallNode(TruffleString name, Supplier handler) { - return LookupAndCallUnaryNode.create(name, handler); - } - } - - @GenerateCached - public abstract static class GenericUnaryArithmeticNode extends UnaryArithmeticNode { - - private final TruffleString specialMethodName; - - protected GenericUnaryArithmeticNode(TruffleString specialMethodName) { - this.specialMethodName = specialMethodName; - } - - @Specialization - public static Object doGeneric(VirtualFrame frame, Object arg, - @Cached("createCallNode()") LookupAndCallUnaryNode callNode) { - return callNode.executeObject(frame, arg); - } - - @NeverDefault - protected LookupAndCallUnaryNode createCallNode() { - return createCallNode(specialMethodName, createHandler(specialMethodName.toString())); - } - - @NeverDefault - public static GenericUnaryArithmeticNode create(TruffleString specialMethodName) { - return UnaryArithmeticFactory.GenericUnaryArithmeticNodeGen.create(specialMethodName); - } - } -} From a9632e4ef2a22408a2d1676cde8377faf4f03ad3 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 20 Feb 2025 14:36:56 +0100 Subject: [PATCH 042/512] Try to avoid upcalls for numeric ops on managed objects --- .../src/abstract.c | 59 +++++- .../com.oracle.graal.python.cext/src/call.c | 4 +- .../cext/PythonCextAbstractBuiltins.java | 192 ++++++------------ .../objects/cext/capi/CApiFunction.java | 33 +++ 4 files changed, 150 insertions(+), 138 deletions(-) diff --git a/graalpython/com.oracle.graal.python.cext/src/abstract.c b/graalpython/com.oracle.graal.python.cext/src/abstract.c index 2437c8433f..f121109d7e 100644 --- a/graalpython/com.oracle.graal.python.cext/src/abstract.c +++ b/graalpython/com.oracle.graal.python.cext/src/abstract.c @@ -7,8 +7,8 @@ #include "Python.h" #include "capi.h" // GraalPy change -#if 0 // GraalPy change #include "pycore_abstract.h" // _PyIndex_Check() +#if 0 // GraalPy change #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate() #include "pycore_object.h" // _Py_CheckSlotResult() @@ -844,6 +844,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec) Py_XDECREF(empty); return result; } +#endif // GraalPy /* Operations on numbers */ int @@ -854,7 +855,6 @@ PyNumber_Check(PyObject *o) PyNumberMethods *nb = Py_TYPE(o)->tp_as_number; return nb && (nb->nb_index || nb->nb_int || nb->nb_float || PyComplex_Check(o)); } -#endif // GraalPy /* Binary operators */ @@ -1072,13 +1072,16 @@ ternary_op(PyObject *v, return NULL; } +// GraalPy change: upcall when both managed to save on doing multiple upcalls #define BINARY_FUNC(func, op, op_name) \ PyObject * \ func(PyObject *v, PyObject *w) { \ + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { \ + return GraalPyTruffle##func(v, w); \ + } \ return binary_op(v, w, NB_SLOT(op), op_name); \ } -#if 0 // GraalPy BINARY_FUNC(PyNumber_Or, nb_or, "|") BINARY_FUNC(PyNumber_Xor, nb_xor, "^") BINARY_FUNC(PyNumber_And, nb_and, "&") @@ -1090,6 +1093,10 @@ BINARY_FUNC(PyNumber_Divmod, nb_divmod, "divmod()") PyObject * PyNumber_Add(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_Add(v, w); + } PyObject *result = BINARY_OP1(v, w, NB_SLOT(nb_add), "+"); if (result != Py_NotImplemented) { return result; @@ -1128,6 +1135,10 @@ sequence_repeat(ssizeargfunc repeatfunc, PyObject *seq, PyObject *n) PyObject * PyNumber_Multiply(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_Multiply(v, w); + } PyObject *result = BINARY_OP1(v, w, NB_SLOT(nb_multiply), "*"); if (result == Py_NotImplemented) { PySequenceMethods *mv = Py_TYPE(v)->tp_as_sequence; @@ -1147,30 +1158,50 @@ PyNumber_Multiply(PyObject *v, PyObject *w) PyObject * PyNumber_MatrixMultiply(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_MatrixMultiply(v, w); + } return binary_op(v, w, NB_SLOT(nb_matrix_multiply), "@"); } PyObject * PyNumber_FloorDivide(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_FloorDivide(v, w); + } return binary_op(v, w, NB_SLOT(nb_floor_divide), "//"); } PyObject * PyNumber_TrueDivide(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_TrueDivide(v, w); + } return binary_op(v, w, NB_SLOT(nb_true_divide), "/"); } PyObject * PyNumber_Remainder(PyObject *v, PyObject *w) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_Remainder(v, w); + } return binary_op(v, w, NB_SLOT(nb_remainder), "%"); } PyObject * PyNumber_Power(PyObject *v, PyObject *w, PyObject *z) { + // GraalPy change: upcall when both managed to save on doing multiple upcalls + if (points_to_py_handle_space(v) && points_to_py_handle_space(w)) { + return GraalPyTrufflePyNumber_Power(v, w, z); + } return ternary_op(v, w, z, NB_SLOT(nb_power), "** or pow()"); } @@ -1258,9 +1289,13 @@ ternary_iop(PyObject *v, PyObject *w, PyObject *z, const int iop_slot, const int return ternary_op(v, w, z, op_slot, op_name); } +// GraalPy change: upcall when v is managed to avoid multiple upcalls #define INPLACE_BINOP(func, iop, op, op_name) \ PyObject * \ func(PyObject *v, PyObject *w) { \ + if (points_to_py_handle_space(v)) { \ + return GraalPyTruffle##func(v, w); \ + } \ return binary_iop(v, w, NB_SLOT(iop), NB_SLOT(op), op_name); \ } @@ -1278,6 +1313,10 @@ INPLACE_BINOP(PyNumber_InPlaceRemainder, nb_inplace_remainder, nb_remainder, "%= PyObject * PyNumber_InPlaceAdd(PyObject *v, PyObject *w) { + // GraalPy change: upcall when v is managed to avoid multiple upcalls + if (points_to_py_handle_space(v)) { + return GraalPyTrufflePyNumber_InPlaceAdd(v, w); + } PyObject *result = BINARY_IOP1(v, w, NB_SLOT(nb_inplace_add), NB_SLOT(nb_add), "+="); if (result == Py_NotImplemented) { @@ -1301,6 +1340,10 @@ PyNumber_InPlaceAdd(PyObject *v, PyObject *w) PyObject * PyNumber_InPlaceMultiply(PyObject *v, PyObject *w) { + // GraalPy change: upcall when v is managed to avoid multiple upcalls + if (points_to_py_handle_space(v)) { + return GraalPyTrufflePyNumber_InPlaceMultiply(v, w); + } PyObject *result = BINARY_IOP1(v, w, NB_SLOT(nb_inplace_multiply), NB_SLOT(nb_multiply), "*="); if (result == Py_NotImplemented) { @@ -1330,6 +1373,10 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w) PyObject * PyNumber_InPlacePower(PyObject *v, PyObject *w, PyObject *z) { + // GraalPy change: upcall when v is managed to avoid multiple upcalls + if (points_to_py_handle_space(v)) { + return GraalPyTrufflePyNumber_InPlacePower(v, w, z); + } return ternary_iop(v, w, z, NB_SLOT(nb_inplace_power), NB_SLOT(nb_power), "**="); } @@ -1340,7 +1387,6 @@ _PyNumber_InPlacePowerNoMod(PyObject *lhs, PyObject *rhs) return PyNumber_InPlacePower(lhs, rhs, Py_None); } - /* Unary operators and functions */ PyObject * @@ -1419,6 +1465,7 @@ PyIndex_Check(PyObject *obj) } +#if 0 // GraalPy change /* Return a Python int from the object item. Can return an instance of int subclass. Raise TypeError if the result is not an int @@ -3027,6 +3074,6 @@ PyTruffleSequence_Fast_ITEMS(PyObject *o) PyObject* PyTruffleSequence_ITEM(PyObject* obj, Py_ssize_t index) { - PySequenceMethods* methods = Py_TYPE(obj)->tp_as_sequence; - return methods->sq_item(obj, index); + PySequenceMethods* methods = Py_TYPE(obj)->tp_as_sequence; + return methods->sq_item(obj, index); } diff --git a/graalpython/com.oracle.graal.python.cext/src/call.c b/graalpython/com.oracle.graal.python.cext/src/call.c index edcdbe0aa0..bd837d6827 100644 --- a/graalpython/com.oracle.graal.python.cext/src/call.c +++ b/graalpython/com.oracle.graal.python.cext/src/call.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2023, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2023, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2022 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -87,7 +87,6 @@ _Py_CheckFunctionResult(PyThreadState *tstate, PyObject *callable, } -#if 0 // GraalPy change int _Py_CheckSlotResult(PyObject *obj, const char *slot_name, int success) { @@ -110,7 +109,6 @@ _Py_CheckSlotResult(PyObject *obj, const char *slot_name, int success) } return 1; } -#endif // GraalPy change /* --- Core PyObject call functions ------------------------------- */ diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java index 013bafe4d5..c06e057308 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java @@ -64,9 +64,7 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.StrNode; import com.oracle.graal.python.builtins.modules.BuiltinConstructors.TupleNode; -import com.oracle.graal.python.builtins.modules.BuiltinFunctions.AbsNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.BinNode; -import com.oracle.graal.python.builtins.modules.BuiltinFunctions.DivModNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.HexNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.NextNode; import com.oracle.graal.python.builtins.modules.BuiltinFunctions.OctNode; @@ -98,11 +96,10 @@ import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.CallSlotMpAssSubscriptNode; import com.oracle.graal.python.lib.GetNextNode; -import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.lib.PyIterCheckNode; import com.oracle.graal.python.lib.PyNumberAddNode; import com.oracle.graal.python.lib.PyNumberAndNode; -import com.oracle.graal.python.lib.PyNumberCheckNode; +import com.oracle.graal.python.lib.PyNumberDivmodNode; import com.oracle.graal.python.lib.PyNumberFloatNode; import com.oracle.graal.python.lib.PyNumberFloorDivideNode; import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; @@ -119,14 +116,11 @@ import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; import com.oracle.graal.python.lib.PyNumberIndexNode; -import com.oracle.graal.python.lib.PyNumberInvertNode; import com.oracle.graal.python.lib.PyNumberLongNode; import com.oracle.graal.python.lib.PyNumberLshiftNode; import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; import com.oracle.graal.python.lib.PyNumberMultiplyNode; -import com.oracle.graal.python.lib.PyNumberNegativeNode; import com.oracle.graal.python.lib.PyNumberOrNode; -import com.oracle.graal.python.lib.PyNumberPositiveNode; import com.oracle.graal.python.lib.PyNumberPowerNode; import com.oracle.graal.python.lib.PyNumberRemainderNode; import com.oracle.graal.python.lib.PyNumberRshiftNode; @@ -172,30 +166,8 @@ public final class PythonCextAbstractBuiltins { - /////// PyIndex /////// - - @CApiBuiltin(ret = Int, args = {PyObject}, call = Direct) - abstract static class PyIndex_Check extends CApiUnaryBuiltinNode { - @Specialization - static Object check(Object obj, - @Bind("this") Node inliningTarget, - @Cached PyIndexCheckNode checkNode) { - return checkNode.execute(inliningTarget, obj) ? 1 : 0; - } - } - /////// PyNumber /////// - @CApiBuiltin(ret = Int, args = {PyObject}, call = Direct) - abstract static class PyNumber_Check extends CApiUnaryBuiltinNode { - @Specialization - static Object check(Object obj, - @Bind("this") Node inliningTarget, - @Cached PyNumberCheckNode checkNode) { - return PInt.intValue(checkNode.execute(inliningTarget, obj)); - } - } - @CApiBuiltin(name = "_PyNumber_Index", ret = PyObjectTransfer, args = {PyObject}, call = Direct) @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) abstract static class PyNumber_Index extends CApiUnaryBuiltinNode { @@ -220,24 +192,6 @@ static Object nlong(Object object, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) - abstract static class PyNumber_Absolute extends CApiUnaryBuiltinNode { - @Specialization - static Object abs(Object obj, - @Cached AbsNode absNode) { - return absNode.execute(null, obj); - } - } - - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Divmod extends CApiBinaryBuiltinNode { - @Specialization - static Object div(Object a, Object b, - @Cached DivModNode divNode) { - return divNode.execute(null, a, b); - } - } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, Int}, call = Direct) abstract static class PyNumber_ToBase extends CApiBinaryBuiltinNode { @Specialization(guards = "base == 2") @@ -307,38 +261,8 @@ static Object doGeneric(Object object, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) - abstract static class PyNumber_Positive extends CApiUnaryBuiltinNode { - - @Specialization - static Object doGeneric(Object obj, - @Cached PyNumberPositiveNode positiveNode) { - return positiveNode.execute(null, obj); - } - } - - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) - abstract static class PyNumber_Negative extends CApiUnaryBuiltinNode { - - @Specialization - static Object doGeneric(Object obj, - @Cached PyNumberNegativeNode negativeNode) { - return negativeNode.execute(null, obj); - } - } - - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject}, call = Direct) - abstract static class PyNumber_Invert extends CApiUnaryBuiltinNode { - - @Specialization - static Object doGeneric(Object obj, - @Cached PyNumberInvertNode invertNode) { - return invertNode.execute(null, obj); - } - } - - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Add extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Add extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -348,8 +272,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Subtract extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Subtract extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -358,8 +282,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Multiply extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Multiply extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -369,8 +293,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Remainder extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Remainder extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -379,8 +303,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_TrueDivide extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_TrueDivide extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -389,8 +313,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_FloorDivide extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_FloorDivide extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -399,8 +323,18 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_And extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Divmod extends CApiBinaryBuiltinNode { + @Specialization + static Object div(Object a, Object b, + @Bind Node inliningTarget, + @Cached PyNumberDivmodNode divmodNode) { + return divmodNode.execute(null, inliningTarget, a, b); + } + } + + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_And extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -409,8 +343,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Or extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Or extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -419,8 +353,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Xor extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Xor extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -429,8 +363,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Lshift extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Lshift extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -439,8 +373,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Rshift extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Rshift extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -449,8 +383,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_MatrixMultiply extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_MatrixMultiply extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -459,8 +393,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceAdd extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceAdd extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -469,8 +403,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceSubtract extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceSubtract extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -479,8 +413,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceMultiply extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceMultiply extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -489,8 +423,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceRemainder extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceRemainder extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -499,8 +433,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceTrueDivide extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceTrueDivide extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -509,8 +443,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceFloorDivide extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceFloorDivide extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -519,8 +453,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceAnd extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceAnd extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -529,8 +463,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceOr extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceOr extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -539,8 +473,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceXor extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceXor extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -549,8 +483,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceLshift extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceLshift extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -559,8 +493,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceRshift extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceRshift extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -569,8 +503,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlaceMatrixMultiply extends CApiBinaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlaceMatrixMultiply extends CApiBinaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, @@ -579,8 +513,8 @@ static Object doGeneric(Object o1, Object o2, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Direct) - abstract static class PyNumber_InPlacePower extends CApiTernaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_InPlacePower extends CApiTernaryBuiltinNode { @Specialization static Object doGeneric(Object o1, Object o2, Object o3, @@ -589,8 +523,8 @@ static Object doGeneric(Object o1, Object o2, Object o3, } } - @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Direct) - abstract static class PyNumber_Power extends CApiTernaryBuiltinNode { + @CApiBuiltin(ret = PyObjectTransfer, args = {PyObject, PyObject, PyObject}, call = Ignored) + abstract static class PyTrufflePyNumber_Power extends CApiTernaryBuiltinNode { @Specialization Object doGeneric(Object o1, Object o2, Object o3, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java index 0e07fa832d..d71eb1b0f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java @@ -296,6 +296,7 @@ public final class CApiFunction { @CApiBuiltin(name = "PyImport_AddModule", ret = PyObject, args = {ConstCharPtrAsTruffleString}, call = CImpl) @CApiBuiltin(name = "PyImport_AddModuleObject", ret = PyObject, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyImport_ImportModuleLevel", ret = PyObject, args = {ConstCharPtrAsTruffleString, PyObject, PyObject, PyObject, Int}, call = CImpl) + @CApiBuiltin(name = "PyIndex_Check", ret = Int, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyInstanceMethod_Function", ret = PyObject, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyInterpreterState_GetDict", ret = PyObject, args = {PyInterpreterState}, call = CImpl) @CApiBuiltin(name = "PyInterpreterState_GetID", ret = INT64_T, args = {PyInterpreterState}, call = CImpl) @@ -349,7 +350,39 @@ public final class CApiFunction { @CApiBuiltin(name = "PyModule_GetDict", ret = PyObject, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyModule_GetName", ret = ConstCharPtrAsTruffleString, args = {PyObject}, call = CImpl) @CApiBuiltin(name = "PyModule_GetState", ret = Pointer, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Absolute", ret = PyObject, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Add", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_And", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) @CApiBuiltin(name = "PyNumber_AsSsize_t", ret = Py_ssize_t, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Check", ret = Int, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Divmod", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_FloorDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceAdd", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceAnd", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceFloorDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceLshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceMatrixMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceOr", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlacePower", ret = PyObject, args = {PyObject, PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceRemainder", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceRshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceSubtract", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceTrueDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_InPlaceXor", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Invert", ret = PyObject, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Lshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_MatrixMultiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Multiply", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Negative", ret = PyObject, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Or", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Positive", ret = PyObject, args = {PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Power", ret = PyObject, args = {PyObject, PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Remainder", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Rshift", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Subtract", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_TrueDivide", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) + @CApiBuiltin(name = "PyNumber_Xor", ret = PyObject, args = {PyObject, PyObject}, call = CImpl) @CApiBuiltin(name = "PyOS_double_to_string", ret = CHAR_PTR, args = {Double, CHAR, Int, Int, INT_LIST}, call = CImpl) @CApiBuiltin(name = "PyOS_mystricmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = CImpl) @CApiBuiltin(name = "PyOS_mystrnicmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Py_ssize_t}, call = CImpl) From 44cf93171490efc87197a37acf8089115752d866 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Mon, 30 Dec 2024 11:53:31 +0100 Subject: [PATCH 043/512] made VFSUtils.delete private --- .../src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 46637889eb..a3b9ec66ab 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -186,7 +186,7 @@ public interface Log { void info(String s); } - public static void delete(Path dir) throws IOException { + private static void delete(Path dir) throws IOException { if (!Files.exists(dir)) { return; } From 5ff17063e3160c6fd1d27a280db3f402daa8da1c Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 3 Jan 2025 15:01:09 +0100 Subject: [PATCH 044/512] merged VFSUtil.Log and SubprocessLog --- .../cext/test/MultiContextCExtTest.java | 16 ++-- .../maven/plugin/ManageResourcesMojo.java | 2 +- .../python/maven/plugin/MavenDelegateLog.java | 10 +-- .../embedding/tools/exec/BuildToolLog.java | 45 ++++++++++ .../embedding/tools/exec/GraalPyRunner.java | 24 ++--- .../embedding/tools/exec/SubprocessLog.java | 87 ------------------- .../python/embedding/tools/vfs/VFSUtils.java | 41 ++++----- .../java/org/graalvm/python/GradleLogger.java | 8 +- .../graalvm/python/tasks/ResourcesTask.java | 2 +- .../python/jbang/JBangIntegration.java | 9 +- 10 files changed, 97 insertions(+), 147 deletions(-) create mode 100644 graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java delete mode 100644 graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/SubprocessLog.java diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java index 86165c3fa0..56b8a0c3cb 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java @@ -61,13 +61,12 @@ import org.graalvm.polyglot.Engine; import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; -import org.graalvm.python.embedding.tools.exec.SubprocessLog; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; -import org.graalvm.python.embedding.tools.vfs.VFSUtils.Log; import org.junit.Test; public class MultiContextCExtTest { - static final class TestLog extends Handler implements SubprocessLog, Log { + static final class TestLog extends Handler implements BuildToolLog { final StringBuilder logCharSequence = new StringBuilder(); final StringBuilder logThrowable = new StringBuilder(); final StringBuilder stderr = new StringBuilder(); @@ -81,13 +80,8 @@ static void println(CharSequence... args) { } } - public void log(CharSequence txt) { - println("[log]", txt); - logCharSequence.append(txt); - } - - public void log(CharSequence txt, Throwable t) { - println("[log]", txt); + public void warning(CharSequence txt, Throwable t) { + println("[warning]", txt); println("[throwable]", t.getMessage()); logThrowable.append(txt).append(t.getMessage()); } @@ -128,7 +122,7 @@ private static Path createVenv(TestLog log, String... packages) throws IOExcepti deleteDirOnShutdown(tmpdir); var venvdir = tmpdir.resolve("venv"); try { - VFSUtils.createVenv(venvdir, Arrays.asList(packages), tmpdir.resolve("graalpy.exe"), () -> getClasspath(), "", log, log); + VFSUtils.createVenv(venvdir, Arrays.asList(packages), tmpdir.resolve("graalpy.exe"), () -> getClasspath(), "", log); } catch (RuntimeException e) { System.err.println(getClasspath()); throw e; diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index d81b78b861..51868cbf9b 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -230,7 +230,7 @@ private void manageVenv() throws MojoExecutionException { return; } - VFSUtils.createVenv(venvDirectory, new ArrayList(packages), getLauncherPath(), () -> calculateLauncherClasspath(project), getGraalPyVersion(project), new MavenDelegateLog(getLog()), (s) -> getLog().info(s)); + VFSUtils.createVenv(venvDirectory, new ArrayList(packages), getLauncherPath(), () -> calculateLauncherClasspath(project), getGraalPyVersion(project), new MavenDelegateLog(getLog())); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java index 139f7b13fa..9fdb21178a 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java @@ -41,20 +41,20 @@ package org.graalvm.python.maven.plugin; import org.apache.maven.plugin.logging.Log; -import org.graalvm.python.embedding.tools.exec.SubprocessLog; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; -final class MavenDelegateLog implements SubprocessLog { +final class MavenDelegateLog implements BuildToolLog { private final Log delegate; MavenDelegateLog(Log delegate) { this.delegate = delegate; } - public void log(CharSequence var1) { + public void info(String var1) { delegate.info(var1); } - public void log(CharSequence var1, Throwable t) { - delegate.error(var1, t); + public void warning(String var1, Throwable t) { + delegate.warn(var1, t); } } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java new file mode 100644 index 0000000000..877a9c09f3 --- /dev/null +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java @@ -0,0 +1,45 @@ +package org.graalvm.python.embedding.tools.exec; + +import java.util.ArrayList; +import java.util.List; + +public interface BuildToolLog { + default void subProcessOut(CharSequence out) { + System.out.println(out); + } + + default void subProcessErr(CharSequence err) { + System.err.println(err); + } + + default void info(String s) { + System.out.println(s); + }; + + default void warning(String s) { + System.out.println(s); + } + + default void warning(String s, Throwable t) { + System.out.println(s); + t.printStackTrace(); + } + + final class CollectOutputLog implements BuildToolLog { + private final List output = new ArrayList<>(); + + public List getOutput() { + return output; + } + + @Override + public void subProcessOut(CharSequence var1) { + output.add(var1.toString()); + } + + @Override + public void subProcessErr(CharSequence var1) { + System.err.println(var1); + } + } +} diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java index f9bef8a7b3..4e0af653a4 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java @@ -60,11 +60,11 @@ public class GraalPyRunner { private static final String BIN_DIR = IS_WINDOWS ? "Scripts" : "bin"; private static final String EXE_SUFFIX = IS_WINDOWS ? ".exe" : ""; - public static void run(Set classpath, SubprocessLog log, String... args) throws IOException, InterruptedException { + public static void run(Set classpath, BuildToolLog log, String... args) throws IOException, InterruptedException { run(String.join(File.pathSeparator, classpath), log, args); } - public static void run(String classpath, SubprocessLog log, String... args) throws IOException, InterruptedException { + public static void run(String classpath, BuildToolLog log, String... args) throws IOException, InterruptedException { String workdir = System.getProperty("exec.workingdir"); Path java = Paths.get(System.getProperty("java.home"), "bin", "java"); List cmd = new ArrayList<>(); @@ -77,20 +77,20 @@ public static void run(String classpath, SubprocessLog log, String... args) thro if (workdir != null) { pb.directory(new File(workdir)); } - log.log(String.format("Running GraalPy: %s", String.join(" ", cmd))); + log.info(String.format("Running GraalPy: %s", String.join(" ", cmd))); runProcess(pb, log); } - public static void runLauncher(String launcherPath, SubprocessLog log, String... args) throws IOException, InterruptedException { + public static void runLauncher(String launcherPath, BuildToolLog log, String... args) throws IOException, InterruptedException { var cmd = new ArrayList(); cmd.add(launcherPath); cmd.addAll(List.of(args)); - log.log(String.format("Running: %s", String.join(" ", cmd))); + log.info(String.format("Running: %s", String.join(" ", cmd))); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } - public static void runPip(Path venvDirectory, String command, SubprocessLog log, String... args) throws IOException, InterruptedException { + public static void runPip(Path venvDirectory, String command, BuildToolLog log, String... args) throws IOException, InterruptedException { var newArgs = new ArrayList(); newArgs.add("-m"); newArgs.add("pip"); @@ -101,15 +101,15 @@ public static void runPip(Path venvDirectory, String command, SubprocessLog log, runVenvBin(venvDirectory, "graalpy", log, newArgs); } - public static void runVenvBin(Path venvDirectory, String command, SubprocessLog log, String... args) throws IOException, InterruptedException { + public static void runVenvBin(Path venvDirectory, String command, BuildToolLog log, String... args) throws IOException, InterruptedException { runVenvBin(venvDirectory, command, log, List.of(args)); } - private static void runVenvBin(Path venvDirectory, String command, SubprocessLog log, List args) throws IOException, InterruptedException { + private static void runVenvBin(Path venvDirectory, String command, BuildToolLog log, List args) throws IOException, InterruptedException { var cmd = new ArrayList(); cmd.add(venvDirectory.resolve(BIN_DIR).resolve(command + EXE_SUFFIX).toString()); cmd.addAll(args); - log.log(String.join(" ", cmd)); + log.info(String.join(" ", cmd)); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } @@ -139,7 +139,7 @@ private static String fixProtocol(String proxyAddress, String protocol) { return proxyAddress.startsWith(protocol) ? proxyAddress : protocol + "://" + proxyAddress; } - private static void runProcess(ProcessBuilder pb, SubprocessLog log) throws IOException, InterruptedException { + private static void runProcess(ProcessBuilder pb, BuildToolLog log) throws IOException, InterruptedException { pb.redirectError(); pb.redirectOutput(); Process process = pb.start(); @@ -152,7 +152,7 @@ private static void runProcess(ProcessBuilder pb, SubprocessLog log) throws IOEx } catch (IOException e) { // Do nothing for now. Probably is not good idea to stop the // execution at this moment - log.log("exception while reading subprocess out", e); + log.warning("exception while reading subprocess out", e); } }); outputReader.start(); @@ -167,7 +167,7 @@ private static void runProcess(ProcessBuilder pb, SubprocessLog log) throws IOEx } catch (IOException e) { // Do nothing for now. Probably is not good idea to stop the // execution at this moment - log.log("exception while reading subprocess err", e); + log.warning("exception while reading subprocess err", e); } }); errorReader.start(); diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/SubprocessLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/SubprocessLog.java deleted file mode 100644 index 1bedf4d2a9..0000000000 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/SubprocessLog.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2023, 2025, 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 org.graalvm.python.embedding.tools.exec; - -import java.util.ArrayList; -import java.util.List; - -public interface SubprocessLog { - - default void subProcessOut(CharSequence out) { - System.out.println(out); - } - - default void subProcessErr(CharSequence err) { - System.err.println(err); - } - - default void log(CharSequence txt) { - System.out.println(txt); - } - - default void log(CharSequence txt, Throwable t) { - System.out.println(txt); - t.printStackTrace(); - } - - final class CollectOutputLog implements SubprocessLog { - private final List output = new ArrayList<>(); - - public List getOutput() { - return output; - } - - @Override - public void subProcessOut(CharSequence var1) { - output.add(var1.toString()); - } - - @Override - public void subProcessErr(CharSequence var1) { - System.err.println(var1); - } - - @Override - public void log(CharSequence var1) { - } - } - -} diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index a3b9ec66ab..3224de3d9d 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -58,9 +58,9 @@ import java.util.TreeSet; import java.util.function.Consumer; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; +import org.graalvm.python.embedding.tools.exec.BuildToolLog.CollectOutputLog; import org.graalvm.python.embedding.tools.exec.GraalPyRunner; -import org.graalvm.python.embedding.tools.exec.SubprocessLog; -import org.graalvm.python.embedding.tools.exec.SubprocessLog.CollectOutputLog; public final class VFSUtils { @@ -182,10 +182,6 @@ public interface LauncherClassPath { Set get() throws IOException; } - public interface Log { - void info(String s); - } - private static void delete(Path dir) throws IOException { if (!Files.exists(dir)) { return; @@ -199,12 +195,12 @@ private static void delete(Path dir) throws IOException { } } - public static void createVenv(Path venvDirectory, List packages, Path launcher, LauncherClassPath launcherClassPath, String graalPyVersion, SubprocessLog subprocessLog, Log log) + public static void createVenv(Path venvDirectory, List packages, Path launcher, LauncherClassPath launcherClassPath, String graalPyVersion, BuildToolLog log) throws IOException { Path launcherPath = launcher; String externalLauncher = System.getProperty("graalpy.vfs.venvLauncher"); if (externalLauncher == null || externalLauncher.trim().isEmpty()) { - generateLaunchers(launcherPath, launcherClassPath, subprocessLog, log); + generateLaunchers(launcherPath, launcherClassPath, log); } else { launcherPath = Path.of(externalLauncher); } @@ -239,15 +235,15 @@ public static void createVenv(Path venvDirectory, List packages, Path la if (!Files.exists(venvDirectory)) { log.info(String.format("Creating GraalPy %s venv", graalPyVersion)); - runLauncher(launcherPath.toString(), subprocessLog, "-m", "venv", venvDirectory.toString(), "--without-pip"); - runVenvBin(venvDirectory, "graalpy", subprocessLog, "-I", "-m", "ensurepip"); + runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); + runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } Iterable frozenPkgs = null; if (packages != null) { boolean needsUpdate = false; - needsUpdate |= deleteUnwantedPackages(venvDirectory, packages, installedPackages, subprocessLog); - needsUpdate |= installWantedPackages(venvDirectory, packages, installedPackages, subprocessLog); + needsUpdate |= deleteUnwantedPackages(venvDirectory, packages, installedPackages, log); + needsUpdate |= installWantedPackages(venvDirectory, packages, installedPackages, log); if (needsUpdate) { var freezeLog = new CollectOutputLog(); runPip(venvDirectory, "freeze", freezeLog, "--local"); @@ -269,7 +265,7 @@ public static void createVenv(Path venvDirectory, List packages, Path la } } - private static void checkLauncher(Path venvDirectory, Path launcherPath, Log log) throws IOException { + private static void checkLauncher(Path venvDirectory, Path launcherPath, BuildToolLog log) throws IOException { if (!Files.exists(launcherPath)) { throw new IOException(String.format("Launcher file does not exist '%s'", launcherPath)); } @@ -301,7 +297,7 @@ private static void checkLauncher(Path venvDirectory, Path launcherPath, Log log } } - private static void generateLaunchers(Path laucherPath, LauncherClassPath launcherClassPath, SubprocessLog subprocessLog, Log log) throws IOException { + private static void generateLaunchers(Path laucherPath, LauncherClassPath launcherClassPath, BuildToolLog log) throws IOException { if (!Files.exists(laucherPath)) { log.info("Generating GraalPy launchers"); createParentDirectories(laucherPath); @@ -356,7 +352,7 @@ with open(pyvenvcfg, 'w', encoding='utf-8') as f: } try { - GraalPyRunner.run(classpath, subprocessLog, tmp.getAbsolutePath()); + GraalPyRunner.run(classpath, log, tmp.getAbsolutePath()); } catch (InterruptedException e) { throw new IOException(String.format("failed to run Graalpy launcher"), e); } @@ -364,28 +360,29 @@ with open(pyvenvcfg, 'w', encoding='utf-8') as f: } } - private static boolean installWantedPackages(Path venvDirectory, List packages, List installedPackages, SubprocessLog subprocessLog) throws IOException { + private static boolean installWantedPackages(Path venvDirectory, List packages, List installedPackages, BuildToolLog log) throws IOException { Set pkgsToInstall = new HashSet<>(packages); pkgsToInstall.removeAll(installedPackages); if (pkgsToInstall.isEmpty()) { return false; } - runPip(venvDirectory, "install", subprocessLog, pkgsToInstall.toArray(new String[pkgsToInstall.size()])); + runPip(venvDirectory, "install", log, pkgsToInstall.toArray(new String[pkgsToInstall.size()])); return true; } - private static boolean deleteUnwantedPackages(Path venvDirectory, List packages, List installedPackages, SubprocessLog subprocessLog) throws IOException { + private static boolean deleteUnwantedPackages(Path venvDirectory, List packages, List installedPackages, BuildToolLog log) throws IOException { List args = new ArrayList<>(installedPackages); args.removeAll(packages); if (args.isEmpty()) { return false; } args.add(0, "-y"); - runPip(venvDirectory, "uninstall", subprocessLog, args.toArray(new String[args.size()])); + + runPip(venvDirectory, "uninstall", log, args.toArray(new String[args.size()])); return true; } - private static void runLauncher(String launcherPath, SubprocessLog log, String... args) throws IOException { + private static void runLauncher(String launcherPath, BuildToolLog log, String... args) throws IOException { try { GraalPyRunner.runLauncher(launcherPath, log, args); } catch (IOException | InterruptedException e) { @@ -393,7 +390,7 @@ private static void runLauncher(String launcherPath, SubprocessLog log, String.. } } - private static void runPip(Path venvDirectory, String command, SubprocessLog log, String... args) throws IOException { + private static void runPip(Path venvDirectory, String command, BuildToolLog log, String... args) throws IOException { try { GraalPyRunner.runPip(venvDirectory, command, log, args); } catch (IOException | InterruptedException e) { @@ -401,7 +398,7 @@ private static void runPip(Path venvDirectory, String command, SubprocessLog log } } - private static void runVenvBin(Path venvDirectory, String bin, SubprocessLog log, String... args) throws IOException { + private static void runVenvBin(Path venvDirectory, String bin, BuildToolLog log, String... args) throws IOException { try { GraalPyRunner.runVenvBin(venvDirectory, bin, log, args); } catch (IOException | InterruptedException e) { diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java index 1612dc9ffa..ccd03c80da 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java @@ -40,10 +40,10 @@ */ package org.graalvm.python; -import org.graalvm.python.embedding.tools.exec.SubprocessLog; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.gradle.api.logging.Logger; -public class GradleLogger implements SubprocessLog { +public class GradleLogger implements BuildToolLog { private Logger logger; private GradleLogger(Logger logger) { @@ -61,12 +61,12 @@ public void subProcessErr(CharSequence err) { } @Override - public void log(CharSequence txt) { + public void info(String txt) { logger.lifecycle(txt.toString()); } @Override - public void log(CharSequence txt, Throwable t) { + public void warning(String txt, Throwable t) { logger.lifecycle(txt.toString(), t); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java index 132e3ee43b..e9721ec9ad 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java @@ -132,7 +132,7 @@ private void manageVenv() { List packages = getPackages().getOrElse(null); try { VFSUtils.createVenv(getVenvDirectory(), new ArrayList(packages), getLauncherPath(), this::calculateLauncherClasspath, getPolyglotVersion().get(), - GradleLogger.of(getLogger()), (s) -> getLogger().lifecycle(s)); + GradleLogger.of(getLogger())); } catch (IOException e) { throw new GradleException(String.format("failed to create venv %s", getVenvDirectory()), e); } diff --git a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java index 17822c07b3..60f71f8bbe 100644 --- a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java +++ b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java @@ -41,7 +41,7 @@ package org.graalvm.python.jbang; -import org.graalvm.python.embedding.tools.exec.SubprocessLog; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; import java.io.File; @@ -75,8 +75,9 @@ public class JBangIntegration { private static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows"); private static final String LAUNCHER = IS_WINDOWS ? "graalpy.exe" : "graalpy.sh"; - private static final SubprocessLog LOG = new SubprocessLog() { + private static final BuildToolLog BUILD_TOOL_LOG = new BuildToolLog() { }; + private static final String JBANG_COORDINATES = "org.graalvm.python:jbang:jar"; /** @@ -170,7 +171,7 @@ private static void handleVenv(Path venv, List> dependen // perhaps already checked by jbang throw new IllegalStateException("could not resolve parent for venv path: " + venv); } - VFSUtils.createVenv(venv, pkgs, getLauncherPath(venvParent.toString()), () -> calculateClasspath(dependencies), graalPyVersion, LOG, (txt) -> LOG.log(txt)); + VFSUtils.createVenv(venv, pkgs, getLauncherPath(venvParent.toString()), () -> calculateClasspath(dependencies), graalPyVersion, BUILD_TOOL_LOG); if (dropPip) { try { @@ -234,6 +235,6 @@ private static HashSet calculateClasspath(List> } private static void log(String txt) { - LOG.log("[graalpy jbang integration] " + txt); + BUILD_TOOL_LOG.info("[graalpy jbang integration] " + txt); } } From d88dec55c7e3e79c2cd2f07fff7d9c5deeae43ad Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 16 Jan 2025 11:12:28 +0100 Subject: [PATCH 045/512] fixed VirtualFileSystemTest to run also on windows --- .../embedding/test/VirtualFileSystemTest.java | 218 +++++++++++------- 1 file changed, 135 insertions(+), 83 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java index b4b4fc19a9..c7189d6269 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java @@ -171,7 +171,9 @@ public void toRealPath() throws Exception { for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { assertTrue(Files.isSameFile(realFSPath, fs.toRealPath(realFSPath))); withCWD(fs, realFSDir, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.getParent().getFileName().toString(), "extractme"))))); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.toString()))))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.toString()))))); + } } checkException(SecurityException.class, () -> noHostIOVFS.toRealPath(realFSPath), "expected error for no host io fs"); } @@ -227,8 +229,10 @@ public void toAbsolutePath() throws Exception { // absolute path starting with VFS, pointing to real FS // /VFS_ROOT/../real/fs/path/ - p = Path.of(VFS_MOUNT_POINT, "..", realFSPath.toString()); - assertEquals(p, fs.toAbsolutePath(p)); + if (!IS_WINDOWS) { + p = Path.of(VFS_MOUNT_POINT, "..", realFSPath.toString()); + assertEquals(p, fs.toAbsolutePath(p)); + } // absolute path starting with real FS, pointing to VFS // /real/fs/path/../../../VFS_MOUNT_POINT @@ -242,9 +246,11 @@ public void toAbsolutePath() throws Exception { // no CWD set, so relative path starting in real FS, pointing to VFS // ../../../VFS_ROOT Path cwd = Path.of(".").toAbsolutePath(); - p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME)); - assertTrue(p.isAbsolute()); - assertEquals(VFS_ROOT_PATH, p.normalize()); + if (!IS_WINDOWS) { + p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME)); + assertTrue(p.isAbsolute()); + assertEquals(VFS_ROOT_PATH, p.normalize()); + } // ../../../VFS_ROOT/../real/fs/path p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME, "..", realFSPath.toString())); @@ -253,11 +259,13 @@ public void toAbsolutePath() throws Exception { // CWD is VFS_ROOT, relative path pointing to real FS // ../real/fs/path - withCWD(fs, VFS_ROOT_PATH, (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("..", realFSPath.toString())); - assertTrue(pp.isAbsolute()); - assertEquals(realFSPath, pp.normalize()); - }); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("..", realFSPath.toString())); + assertTrue(pp.isAbsolute()); + assertEquals(realFSPath, pp.normalize()); + }); + } // CWD is VFS_ROOT, relative path pointing through real FS back to VFS // ../some/path/../../VFS_ROOT_PATH @@ -379,7 +387,9 @@ public void checkAccess() throws Exception { for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { fs.checkAccess(realFSPath, Set.of(AccessMode.READ)); withCWD(fs, realFSPath.getParent(), (fst) -> fst.checkAccess(realFSPath.getFileName(), Set.of(AccessMode.READ))); - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.checkAccess(Path.of("..", realFSPath.toString()), Set.of(AccessMode.READ))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.checkAccess(Path.of("..", realFSPath.toString()), Set.of(AccessMode.READ))); + } } checkException(SecurityException.class, () -> noHostIOVFS.checkAccess(realFSPath, Set.of(AccessMode.READ)), "expected error for no host io fs"); } @@ -440,12 +450,14 @@ public void createDirectory() throws Exception { fs.createDirectory(newDir2.getFileName()); assertTrue(Files.exists(newDir2)); }); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> { - Path newDir3 = newDir.getParent().resolve("newdir3"); - assertFalse(Files.exists(newDir3)); - fs.createDirectory(Path.of("..", newDir3.toString())); - assertTrue(Files.exists(newDir3)); - }); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> { + Path newDir3 = newDir.getParent().resolve("newdir3"); + assertFalse(Files.exists(newDir3)); + fs.createDirectory(Path.of("..", newDir3.toString())); + assertTrue(Files.exists(newDir3)); + }); + } } @Test @@ -479,10 +491,12 @@ public void delete() throws Exception { withCWD(rwHostIOVFS, realFSPath.getParent(), (fs) -> rwHostIOVFS.delete(realFSPath.getFileName())); assertFalse(Files.exists(realFSPath)); - Files.createFile(realFSPath); - assertTrue(Files.exists(realFSPath)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.delete(Path.of("..", realFSPath.toString()))); - assertFalse(Files.exists(realFSPath)); + if (!IS_WINDOWS) { + Files.createFile(realFSPath); + assertTrue(Files.exists(realFSPath)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.delete(Path.of("..", realFSPath.toString()))); + assertFalse(Files.exists(realFSPath)); + } } private static void deleteVFS(FileSystem fs, String pathPrefix) { @@ -515,13 +529,17 @@ public void newByteChannel() throws Exception { Path realFSPath = Files.createTempDirectory("graalpy.vfs.test").resolve("extractme"); Files.createFile(realFSPath); checkException(SecurityException.class, () -> rHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE)), "cant write into a read-only host FS"); - rwHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("text".getBytes())); + } assertTrue(Files.exists(realFSPath)); for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { newByteChannelRealFS(fs, realFSPath, "text"); withCWD(fs, realFSPath.getParent(), (fst) -> newByteChannelRealFS(fs, realFSPath.getFileName(), "text")); - withCWD(fs, VFS_ROOT_PATH, (fst) -> newByteChannelRealFS(fs, Path.of("..", realFSPath.toString()), "text")); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> newByteChannelRealFS(fs, Path.of("..", realFSPath.toString()), "text")); + } } } @@ -544,26 +562,28 @@ private static void newByteChannelVFS(FileSystem fs, String pathPrefix) throws I } private static void newByteChannelVFS(FileSystem fs, Path path, Set options) throws IOException { - SeekableByteChannel bch = fs.newByteChannel(path, options); - ByteBuffer buffer = ByteBuffer.allocate(1024); - bch.read(buffer); - String s = new String(buffer.array()); - String[] ss = s.split(System.lineSeparator()); - assertTrue(ss.length >= 2); - assertEquals("text1", ss[0]); - assertEquals("text2", ss[1]); - checkException(NonWritableChannelException.class, () -> bch.write(buffer), "should not be able to write to VFS"); - checkException(NonWritableChannelException.class, () -> bch.truncate(0), "should not be able to write to VFS"); + try (SeekableByteChannel bch = fs.newByteChannel(path, options)) { + ByteBuffer buffer = ByteBuffer.allocate(1024); + bch.read(buffer); + String s = new String(buffer.array()); + String[] ss = s.split(System.lineSeparator()); + assertTrue(ss.length >= 2); + assertEquals("text1", ss[0]); + assertEquals("text2", ss[1]); + checkException(NonWritableChannelException.class, () -> bch.write(buffer), "should not be able to write to VFS"); + checkException(NonWritableChannelException.class, () -> bch.truncate(0), "should not be able to write to VFS"); + } } private static void newByteChannelRealFS(FileSystem fs, Path path, String expectedText) throws IOException { - SeekableByteChannel bch = fs.newByteChannel(path, Set.of(StandardOpenOption.READ)); - ByteBuffer buffer = ByteBuffer.allocate(expectedText.length()); - bch.read(buffer); - String s = new String(buffer.array()); - String[] ss = s.split(System.lineSeparator()); - assertTrue(ss.length >= 1); - assertEquals(expectedText, ss[0]); + try (SeekableByteChannel bch = fs.newByteChannel(path, Set.of(StandardOpenOption.READ))) { + ByteBuffer buffer = ByteBuffer.allocate(expectedText.length()); + bch.read(buffer); + String s = new String(buffer.array()); + String[] ss = s.split(System.lineSeparator()); + assertTrue(ss.length >= 1); + assertEquals(expectedText, ss[0]); + } } private static void checkCanOnlyRead(FileSystem fs, Path path, StandardOpenOption... options) { @@ -590,11 +610,13 @@ public void newDirectoryStream() throws Exception { checkException(NotDirectoryException.class, () -> fs.newDirectoryStream(realFSFile, (p) -> true)); newDirectoryStreamRealFS(fs, realFSDir, realFSFile); withCWD(fs, realFSDir.getParent(), (fst) -> newDirectoryStreamRealFS(fs, realFSDir.getFileName(), realFSFile)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); - // from real fs to VFS - withCWD(fs, realFSDir, (fst) -> newDirectoryStreamVFS(fs, Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT).toString())); - // from VFS to real FS - withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + // from real fs to VFS + withCWD(fs, realFSDir, (fst) -> newDirectoryStreamVFS(fs, Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT).toString())); + // from VFS to real FS + withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + } } checkException(SecurityException.class, () -> noHostIOVFS.newDirectoryStream(realFSDir, null), "expected error for no host io fs"); } @@ -645,7 +667,9 @@ public void readAttributes() throws Exception { for (FileSystem fs : new FileSystem[]{rHostIOVFS, rwHostIOVFS}) { assertTrue(((FileTime) fs.readAttributes(realFSPath, "creationTime").get("creationTime")).toMillis() > 0); withCWD(fs, realFSPath.getParent(), (fst) -> assertTrue(((FileTime) fs.readAttributes(realFSPath.getFileName(), "creationTime").get("creationTime")).toMillis() > 0)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(((FileTime) fs.readAttributes(Path.of("..", realFSPath.toString()), "creationTime").get("creationTime")).toMillis() > 0)); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(((FileTime) fs.readAttributes(Path.of("..", realFSPath.toString()), "creationTime").get("creationTime")).toMillis() > 0)); + } } checkException(SecurityException.class, () -> noHostIOVFS.readAttributes(realFSPath, "creationTime"), "expected error for no host io fs"); @@ -822,8 +846,10 @@ public void getMimeType() throws Exception { checkException(NullPointerException.class, () -> fs.getMimeType(null)); Assert.assertNull(fs.getMimeType(VFS_ROOT_PATH)); fs.getMimeType(realFSPath); - // whatever the return value, just check it does not fail - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getMimeType(Path.of("..", realFSPath.toString()))); + if (!IS_WINDOWS) { + // whatever the return value, just check it does not fail + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getMimeType(Path.of("..", realFSPath.toString()))); + } } } @@ -835,8 +861,10 @@ public void getEncoding() throws Exception { checkException(NullPointerException.class, () -> fs.getEncoding(null)); Assert.assertNull(fs.getEncoding(VFS_ROOT_PATH)); fs.getEncoding(realFSPath); - // whatever the return value, just check it does not fail - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getEncoding(Path.of("..", realFSPath.toString()))); + if (!IS_WINDOWS) { + // whatever the return value, just check it does not fail + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getEncoding(Path.of("..", realFSPath.toString()))); + } } } @@ -853,7 +881,9 @@ public void setAttribute() throws Exception { // just check it does not fail for real FS paths rwHostIOVFS.setAttribute(realFSPath, "creationTime", FileTime.fromMillis(42)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.setAttribute(Path.of("..", realFSPath.toString()), "creationTime", FileTime.fromMillis(43))); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.setAttribute(Path.of("..", realFSPath.toString()), "creationTime", FileTime.fromMillis(43))); + } } @Test @@ -871,9 +901,13 @@ public void isSameFile() throws Exception { assertFalse(fs.isSameFile(realFSDir, VFS_ROOT_PATH)); assertFalse(fs.isSameFile(VFS_ROOT_PATH, realFSDir)); if (fs == noHostIOVFS) { - withCWD(fs, VFS_ROOT_PATH, (fst) -> checkException(SecurityException.class, () -> fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> checkException(SecurityException.class, () -> fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + } } else { - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + } withCWD(fs, realFSDir, (fst) -> assertTrue(fs.isSameFile(realFSFile1.getFileName(), realFSFile1.getFileName()))); withCWD(fs, realFSDir, (fst) -> assertFalse(fs.isSameFile(realFSFile1.getFileName(), realFSFile2.getFileName()))); } @@ -901,8 +935,10 @@ public void createLink() throws Exception { assertTrue(Files.exists(link)); Path link2 = realFSDir.resolve("link2"); assertFalse(Files.exists(link2)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.createLink(Path.of("..", link2.toString()), Path.of("..", realFSFile.toString()))); - assertTrue(Files.exists(link2)); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.createLink(Path.of("..", link2.toString()), Path.of("..", realFSFile.toString()))); + assertTrue(Files.exists(link2)); + } checkException(SecurityException.class, () -> rHostIOVFS.createLink(realFSDir.resolve("link3"), realFSFile)); checkException(SecurityException.class, () -> noHostIOVFS.createLink(realFSDir.resolve("link4"), realFSFile)); @@ -931,10 +967,12 @@ public void createAndReadSymbolicLink() throws Exception { rwHostIOVFS.createSymbolicLink(symlink, realFSLinkTarget); checkSymlink(realFSDir, realFSLinkTarget, symlink); - Files.delete(symlink); - assertFalse(Files.exists(symlink)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.createSymbolicLink(Path.of("..", symlink.toString()), realFSLinkTarget)); - checkSymlink(realFSDir, realFSLinkTarget, symlink); + if (!IS_WINDOWS) { + Files.delete(symlink); + assertFalse(Files.exists(symlink)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.createSymbolicLink(Path.of("..", symlink.toString()), realFSLinkTarget)); + checkSymlink(realFSDir, realFSLinkTarget, symlink); + } } private void checkSymlink(Path dir, Path target, Path symlink) throws Exception { @@ -942,8 +980,10 @@ private void checkSymlink(Path dir, Path target, Path symlink) throws Exception checkException(SecurityException.class, () -> noHostIOVFS.readSymbolicLink(symlink)); for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { assertEquals(target, fs.readSymbolicLink(symlink)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of("..", symlink.toString())))); - withCWD(fs, dir, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of(dotdot(dir.getNameCount()), "..", VFS_MOUNT_POINT, "..", symlink.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of("..", symlink.toString())))); + withCWD(fs, dir, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of(dotdot(dir.getNameCount()), "..", VFS_MOUNT_POINT, "..", symlink.toString())))); + } } } @@ -986,7 +1026,9 @@ public void move() throws Exception { checkException(SecurityException.class, () -> fs.move(VFS_ROOT_PATH.resolve("file1"), VFS_ROOT_PATH.resolve("file2"))); } - rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("moved text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("moved text".getBytes())); + } assertTrue(Files.exists(realFSSource)); assertFalse(Files.exists(realFSTarget)); rwHostIOVFS.move(realFSSource, realFSTarget); @@ -999,12 +1041,15 @@ public void move() throws Exception { assertTrue(Files.exists(realFSSource2)); assertFalse(Files.exists(realFSTarget2)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.move(Path.of("..", realFSSource2.toString()), Path.of("..", realFSTarget2.toString()))); - assertFalse(Files.exists(realFSSource2)); - assertTrue(Files.exists(realFSTarget2)); - newByteChannelRealFS(rwHostIOVFS, realFSSource, "moved text"); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.move(Path.of("..", realFSSource2.toString()), Path.of("..", realFSTarget2.toString()))); + assertFalse(Files.exists(realFSSource2)); + assertTrue(Files.exists(realFSTarget2)); + newByteChannelRealFS(rwHostIOVFS, realFSSource, "moved text"); + } - checkException(IOException.class, () -> rHostIOVFS.move(realFSSource2, realFSTarget2)); + Class exCls = IS_WINDOWS ? SecurityException.class : IOException.class; + checkException(exCls, () -> rHostIOVFS.move(realFSSource2, realFSTarget2)); checkException(SecurityException.class, () -> noHostIOVFS.move(realFSSource2, realFSTarget2)); } @@ -1028,7 +1073,9 @@ public void copy() throws Exception { checkException(SecurityException.class, () -> noHostIOVFS.copy(realFSSource, realFSTarget)); Files.createFile(realFSSource); - rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("copied text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("copied text".getBytes())); + } assertTrue(Files.exists(realFSSource)); rwHostIOVFS.copy(realFSSource, realFSTarget); @@ -1036,11 +1083,13 @@ public void copy() throws Exception { assertTrue(Files.exists(realFSTarget)); newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); - Files.delete(realFSTarget); - assertFalse(Files.exists(realFSTarget)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("..", realFSSource.toString()), Path.of("..", realFSTarget.toString()))); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); + if (!IS_WINDOWS) { + Files.delete(realFSTarget); + assertFalse(Files.exists(realFSTarget)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("..", realFSSource.toString()), Path.of("..", realFSTarget.toString()))); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); + } Files.delete(realFSTarget); assertFalse(Files.exists(realFSTarget)); @@ -1054,11 +1103,13 @@ public void copy() throws Exception { assertTrue(Files.exists(realFSTarget)); newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); - Files.delete(realFSTarget); - assertFalse(Files.exists(realFSTarget)); - withCWD(rwHostIOVFS, realFSDir, (fs) -> fs.copy(Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT, "file1"), realFSTarget)); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + if (!IS_WINDOWS) { + Files.delete(realFSTarget); + assertFalse(Files.exists(realFSTarget)); + withCWD(rwHostIOVFS, realFSDir, (fs) -> fs.copy(Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT, "file1"), realFSTarget)); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + } Files.delete(realFSTarget); assertFalse(Files.exists(realFSTarget)); @@ -1073,10 +1124,11 @@ public void copy() throws Exception { assertFalse(Files.exists(realFSTarget)); // no host IO - - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("..", realFSTarget.toString()))); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("..", realFSTarget.toString()))); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + } } From 42dc7443d8008f09cacd0593fe51249984f763a3 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 16 Jan 2025 11:16:32 +0100 Subject: [PATCH 046/512] improved logging in GraalPyRunner --- .../graalvm/python/embedding/tools/exec/GraalPyRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java index 4e0af653a4..a39260e6a0 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -109,7 +109,7 @@ private static void runVenvBin(Path venvDirectory, String command, BuildToolLog var cmd = new ArrayList(); cmd.add(venvDirectory.resolve(BIN_DIR).resolve(command + EXE_SUFFIX).toString()); cmd.addAll(args); - log.info(String.join(" ", cmd)); + log.info("executing: " + String.join(" ", cmd)); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } From 89286569567f4d9c60a733e1e716044ed4d07044 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 16 Jan 2025 11:17:33 +0100 Subject: [PATCH 047/512] more methods in BuildToolLog --- .../python/maven/plugin/MavenDelegateLog.java | 26 +++++++-- .../embedding/tools/exec/BuildToolLog.java | 53 +++++++++++++++++++ .../java/org/graalvm/python/GradleLogger.java | 14 ++++- 3 files changed, 86 insertions(+), 7 deletions(-) diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java index 9fdb21178a..2f09c511d5 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -50,11 +50,27 @@ final class MavenDelegateLog implements BuildToolLog { this.delegate = delegate; } - public void info(String var1) { - delegate.info(var1); + public void info(String txt) { + delegate.info(txt); } - public void warning(String var1, Throwable t) { - delegate.warn(var1, t); + public void warning(String txt) { + delegate.warn(txt); + } + + public void warning(String txt, Throwable t) { + delegate.warn(txt, t); + } + + public void error(String txt) { + delegate.error(txt); + } + + public boolean isDebugEnabled() { + return delegate.isDebugEnabled(); + } + + public void debug(String txt) { + delegate.debug(txt); } } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java index 877a9c09f3..e64a35d99c 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java @@ -1,3 +1,44 @@ +/* + * Copyright (c) 2025, 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 org.graalvm.python.embedding.tools.exec; import java.util.ArrayList; @@ -25,6 +66,18 @@ default void warning(String s, Throwable t) { t.printStackTrace(); } + default void error(String s) { + System.err.println(s); + } + + default public boolean isDebugEnabled() { + return false; + } + + default void debug(String s) { + System.out.println(s); + } + final class CollectOutputLog implements BuildToolLog { private final List output = new ArrayList<>(); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java index ccd03c80da..dd21a8ce8d 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -67,7 +67,17 @@ public void info(String txt) { @Override public void warning(String txt, Throwable t) { - logger.lifecycle(txt.toString(), t); + logger.warn(txt, t); + } + + @Override + public void warning(String txt) { + logger.warn(txt); + } + + @Override + public void error(String txt) { + logger.error(txt); } public static GradleLogger of(Logger logger) { From a595a6d23d1878bbd5c561ae65301df384c94e3b Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 24 Jan 2025 15:29:27 +0100 Subject: [PATCH 048/512] minor javadoc improvement --- .../embedding/test/integration/GraalPyResourcesUtilsTests.java | 2 +- .../integration/VirtualFileSystemIntegrationUtilsTest.java | 2 +- .../python/embedding/test/VirtualFileSystemUtilsTest.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/GraalPyResourcesUtilsTests.java b/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/GraalPyResourcesUtilsTests.java index 50e91ed4b8..2402887d80 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/GraalPyResourcesUtilsTests.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/GraalPyResourcesUtilsTests.java @@ -48,7 +48,7 @@ import java.nio.file.Path; /** - * Siple copy of GraalPyResourcesTests to test also the deprecated + * Simple copy of GraalPyResourcesTests to test also the deprecated * org.graalvm.python.embedding.utils pkg */ @SuppressWarnings("deprecation") diff --git a/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/VirtualFileSystemIntegrationUtilsTest.java b/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/VirtualFileSystemIntegrationUtilsTest.java index 8033697bc0..287884b39b 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/VirtualFileSystemIntegrationUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/org/graalvm/python/embedding/test/integration/VirtualFileSystemIntegrationUtilsTest.java @@ -71,7 +71,7 @@ import static org.junit.Assert.assertTrue; /** - * Siple copy of VirtualFileSystemIntegrationTest to test also the deprecated + * Simple copy of VirtualFileSystemIntegrationTest to test also the deprecated * org.graalvm.python.embedding.utils pkg */ @SuppressWarnings("deprecation") diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java index b662bc2b5b..d21538f877 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java @@ -90,9 +90,10 @@ import static org.junit.Assert.assertTrue; /** - * Siple copy of VirtualFileSystemTest to test also the deprecated + * Simple copy of VirtualFileSystemTest to test also the deprecated * org.graalvm.python.embedding.utils pkg */ +@SuppressWarnings("deprecation") public class VirtualFileSystemUtilsTest { private static String MOUNT_POINT_NAME = "test_mount_point"; From fa0ddb4baf2852ce9b5af8c5601c97f21080aef5 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 24 Jan 2025 15:23:12 +0100 Subject: [PATCH 049/512] handle requirements files in VFSUtils.createVenv() --- .../cext/test/MultiContextCExtTest.java | 79 +-- .../embedding/test/EmbeddingTestUtils.java | 111 +++ .../embedding/vfs/test/VFSUtilsTest.java | 645 ++++++++++++++++++ .../standalone/test_jbang_integration.py | 5 +- .../maven/plugin/ManageResourcesMojo.java | 16 +- .../embedding/tools/exec/BuildToolLog.java | 2 +- .../python/embedding/tools/vfs/VFSUtils.java | 401 +++++++++-- .../graalvm/python/GraalPyGradlePlugin.java | 18 +- .../graalvm/python/tasks/ResourcesTask.java | 9 +- .../python/jbang/JBangIntegration.java | 17 +- mx.graalpython/mx_graalpython.py | 7 +- 11 files changed, 1172 insertions(+), 138 deletions(-) create mode 100644 graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java create mode 100644 graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java index 56b8a0c3cb..d9472b3652 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -46,14 +46,10 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Set; import java.util.logging.Handler; import java.util.logging.LogRecord; @@ -62,9 +58,11 @@ import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; import org.graalvm.python.embedding.tools.exec.BuildToolLog; -import org.graalvm.python.embedding.tools.vfs.VFSUtils; import org.junit.Test; +import static org.graalvm.python.embedding.test.EmbeddingTestUtils.deleteDirOnShutdown; +import static org.graalvm.python.embedding.test.EmbeddingTestUtils.createVenv; + public class MultiContextCExtTest { static final class TestLog extends Handler implements BuildToolLog { final StringBuilder logCharSequence = new StringBuilder(); @@ -117,61 +115,30 @@ public void close() { } } - private static Path createVenv(TestLog log, String... packages) throws IOException { - var tmpdir = Files.createTempDirectory("graalpytest"); - deleteDirOnShutdown(tmpdir); - var venvdir = tmpdir.resolve("venv"); - try { - VFSUtils.createVenv(venvdir, Arrays.asList(packages), tmpdir.resolve("graalpy.exe"), () -> getClasspath(), "", log); - } catch (RuntimeException e) { - System.err.println(getClasspath()); - throw e; - } - return venvdir; - } - - private static void deleteDirOnShutdown(Path tmpdir) { - Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try (var fs = Files.walk(tmpdir)) { - fs.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); - } catch (IOException e) { - } - })); - } - - private static Set getClasspath() { - var sb = new ArrayList(); - var modPath = System.getProperty("jdk.module.path"); - if (modPath != null) { - sb.add(modPath); - } - var classPath = System.getProperty("java.class.path"); - if (classPath != null) { - sb.add(classPath); - } - var cp = String.join(File.pathSeparator, sb); - return Set.copyOf(Arrays.stream(cp.split(File.pathSeparator)).toList()); - } - @Test public void testCreatingVenvForMulticontext() throws IOException { var log = new TestLog(); - Path venv; + Path tmpdir = Files.createTempDirectory("MultiContextCExtTest"); + Path venvDir = tmpdir.resolve("venv"); + deleteDirOnShutdown(tmpdir); String pythonNative; String exe; if (System.getProperty("os.name").toLowerCase().contains("win")) { pythonNative = "python-native.dll"; - venv = createVenv(log, "delvewheel==1.9.0"); - exe = venv.resolve("Scripts").resolve("python.exe").toString().replace('\\', '/'); + createVenv(venvDir, "0.1", log, "delvewheel==1.9.0"); + + exe = venvDir.resolve("Scripts").resolve("python.exe").toString().replace('\\', '/'); } else if (System.getProperty("os.name").toLowerCase().contains("mac")) { pythonNative = "libpython-native.dylib"; - venv = createVenv(log); - exe = venv.resolve("bin").resolve("python").toString(); + createVenv(venvDir, "0.1", log); + + exe = venvDir.resolve("bin").resolve("python").toString(); } else { pythonNative = "libpython-native.so"; - venv = createVenv(log, "patchelf"); - exe = venv.resolve("bin").resolve("python").toString(); + createVenv(venvDir, "0.1", log, "patchelf"); + + exe = venvDir.resolve("bin").resolve("python").toString(); } var engine = Engine.newBuilder("python").logHandler(log).build(); @@ -182,11 +149,11 @@ public void testCreatingVenvForMulticontext() throws IOException { Context c0, c1, c2, c3, c4, c5; contexts.add(c0 = builder.build()); c0.initialize("python"); - c0.eval("python", String.format("__graalpython__.replicate_extensions_in_venv('%s', 2)", venv.toString().replace('\\', '/'))); + c0.eval("python", String.format("__graalpython__.replicate_extensions_in_venv('%s', 2)", venvDir.toString().replace('\\', '/'))); - assertTrue("created a copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup0"))); - assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup1"))); - assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); + assertTrue("created a copy of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup0"))); + assertTrue("created another copy of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup1"))); + assertFalse("created no more copies of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); builder.option("python.IsolateNativeModules", "true"); contexts.add(c1 = builder.build()); @@ -205,7 +172,7 @@ public void testCreatingVenvForMulticontext() throws IOException { // First one works var r1 = c1.eval(code); assertEquals("tiny_sha3", r1.asString()); - assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); + assertFalse("created no more copies of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); // Second one works because of isolation var r2 = c2.eval(code); assertEquals("tiny_sha3", r2.asString()); @@ -215,10 +182,10 @@ public void testCreatingVenvForMulticontext() throws IOException { // first context is unaffected r1 = c1.eval(code); assertEquals("tiny_sha3", r1.asString()); - assertFalse("created no more copies of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); + assertFalse("created no more copies of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); // Third one works and triggers a dynamic relocation c3.eval(code); - assertTrue("created another copy of the capi", Files.list(venv).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); + assertTrue("created another copy of the capi", Files.list(venvDir).anyMatch((p) -> p.getFileName().toString().startsWith(pythonNative) && p.getFileName().toString().endsWith(".dup2"))); // Fourth one does not work because we changed the sys.prefix c4.eval("python", "import sys; sys.prefix = 12"); try { diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java new file mode 100644 index 0000000000..bb4014c785 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025, 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 org.graalvm.python.embedding.test; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Set; + +import org.graalvm.python.embedding.tools.exec.BuildToolLog; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; + +public final class EmbeddingTestUtils { + private EmbeddingTestUtils() { + } + + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException { + createVenv(venvDir, graalPyVersion, log, null, null, null, packages); + } + + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, String iconsistentPackagesError, String wrongPackageVersionError, String... packages) + throws IOException { + try { + log.info("<<< creating test venv <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + + Path launcherFile = venvDir.getParent().resolve(VFSUtils.LAUNCHER_NAME); + Launcher launcher = new Launcher(launcherFile) { + public Set computeClassPath() { + return getClasspath(); + }; + }; + if (requirements != null) { + VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, iconsistentPackagesError, wrongPackageVersionError, launcher, graalPyVersion, log); + } else { + VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); + } + } catch (RuntimeException e) { + System.err.println(getClasspath()); + throw e; + } finally { + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + } + } + + public static void deleteDirOnShutdown(Path tmpdir) { + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + try (var fs = Files.walk(tmpdir)) { + fs.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } catch (IOException e) { + } + })); + } + + private static Set getClasspath() { + var sb = new ArrayList(); + var modPath = System.getProperty("jdk.module.path"); + if (modPath != null) { + sb.add(modPath); + } + var classPath = System.getProperty("java.class.path"); + if (classPath != null) { + sb.add(classPath); + } + var cp = String.join(File.pathSeparator, sb); + return Set.copyOf(Arrays.stream(cp.split(File.pathSeparator)).toList()); + } +} diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java new file mode 100644 index 0000000000..7f3249535f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2025, 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 org.graalvm.python.embedding.vfs.test; + +import org.graalvm.python.embedding.test.EmbeddingTestUtils; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.junit.Test; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.graalvm.python.embedding.test.EmbeddingTestUtils.deleteDirOnShutdown; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +public class VFSUtilsTest { + + private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; + private static final String INCONSISTENT_PKGS_ERROR = "inconsistent package %s"; + private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; + + private static final class TestLog implements BuildToolLog { + private final StringBuilder output = new StringBuilder(); + + private void addLine(String s) { + this.output.append('\n').append(s); + } + + private void clearOutput() { + output.delete(0, output.length()); + } + + public void subProcessOut(CharSequence s) { + System.out.println(s); + addLine(s.toString()); + } + + public void subProcessErr(CharSequence s) { + System.err.println(s); + addLine(s.toString()); + } + + public void info(String s) { + System.out.println(s); + addLine(s); + }; + + public void warning(String s) { + System.out.println(s); + addLine(s); + } + + public void warning(String s, Throwable t) { + System.out.println(s); + t.printStackTrace(); + addLine(s); + } + + public void error(String s) { + System.err.println(s); + addLine(s); + } + + @Override + public boolean isDebugEnabled() { + return true; + } + + public String getOutput() { + return output.toString(); + } + } + + /** + * tests scenarios when packages are declared only in plugin config + */ + @Test + public void testWithPackagesOnlyFromPluginConfig() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_testWithPackagesOnlyFromPluginConfig"); + Path venvDir = tmpDir.resolve("venv"); + deleteDirOnShutdown(tmpDir); + + // test with a not existing requirements path + // the maven and gradle plugins always send the default requirements path, no matter if the + // file exists or not + Path requirements = tmpDir.resolve("requirements.txt"); + Path contents = venvDir.resolve("contents"); + + // no packages, requirements file does not exist - does nothing + log.clearOutput(); + createVenv(venvDir, "0.1", log, requirements); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + + // install packages + log.clearOutput(); + createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); + checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); + + // install packages again, assert that venv wasn't created and packages weren't installed + log.clearOutput(); + createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.output.toString().contains("hello-world")); + assertFalse(log.output.toString().contains("tiny-tiny")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); + checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); + + // remove tiny-tiny, assert that venv wasn't created and only tiny-tiny was removed + log.clearOutput(); + createVenv(venvDir, "0.1", log, requirements, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.output.toString().contains("hello-world")); + assertTrue(log.output.toString().contains("Uninstalling tiny-tiny")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + + // install only hello-world again, assert that venv wasn't created and packages weren't + // installed + log.clearOutput(); + createVenv(venvDir, "0.1", log, requirements, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.output.toString().contains("hello-world")); + assertFalse(log.output.toString().contains("tiny-tiny")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + + // change version, assert that new venv created and packages installed + log.clearOutput(); + createVenv(venvDir, "0.2", log, requirements, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); + assertTrue(log.output.toString().contains("pip install")); + assertTrue(log.output.toString().contains("hello-world")); + assertFalse(log.output.toString().contains("tiny-tiny")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.2", "hello-world"); + } + + /** + * when called from jbang, which does not work with requirements file + */ + @Test + public void testWithoutRequirementsFile() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_testWithoutRequirementsFile"); + Path venvDir = tmpDir.resolve("venv"); + Path contents = venvDir.resolve("contents"); + deleteDirOnShutdown(tmpDir); + + createVenv(venvDir, "0.1", log); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + log.clearOutput(); + + createVenv(venvDir, "0.1", log, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + log.clearOutput(); + + createVenv(venvDir, "0.1", log, "hello-world==0.1"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + log.clearOutput(); + + createVenv(venvDir, "0.1", log, "hello-world", "tiny-tiny"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); + checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); + log.clearOutput(); + + createVenv(venvDir, "0.1", log, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + log.clearOutput(); + + // new graalPy version + createVenv(venvDir, "0.2", log, "hello-world"); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.2", "hello-world"); + log.clearOutput(); + } + + @Test + public void emptyRequirements() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_emptyRequirements"); + Path venvDir = tmpDir.resolve("venv"); + Path contents = venvDir.resolve("contents"); + deleteDirOnShutdown(tmpDir); + + Path requirements = tmpDir.resolve("requirements.txt"); + Files.createFile(requirements); + + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); + assertFalse(log.output.toString().contains("pip install")); + log.clearOutput(); + + createVenv(venvDir, "0.1", log, requirements); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + log.clearOutput(); + + createVenv(venvDir, "0.2", log, requirements); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + log.clearOutput(); + } + + /** + * python packages managed only by requirements file + */ + @Test + public void onlyRequirementsFile() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_onlyRequirementsFile"); + Path venvDir = tmpDir.resolve("venv"); + Path contents = venvDir.resolve("contents"); + deleteDirOnShutdown(tmpDir); + + Path requirements = tmpDir.resolve("requirements.txt"); + + writeRequirementsFile(requirements); + createVenv(venvDir, "0.1", log, requirements); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertFalse(Files.exists(venvDir.resolve("installed.txt"))); + log.clearOutput(); + + writeRequirementsFile(requirements, "hello-world"); + createVenv(venvDir, "0.1", log, requirements); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("pip install -r")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1"); + log.clearOutput(); + + writeRequirementsFile(requirements, "tiny-tiny"); + createVenv(venvDir, "0.1", log, requirements); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install -r")); + assertTrue(log.output.toString().contains("pip uninstall")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny"); + checkVenvContentsFile(contents, "0.1"); + log.clearOutput(); + + writeRequirementsFile(requirements, "tiny-tiny", "hello-world"); + createVenv(venvDir, "0.1", log, requirements); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install -r")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); + checkVenvContentsFile(contents, "0.1"); + log.clearOutput(); + + writeRequirementsFile(requirements, "tiny-tiny==0.1", "hello-world"); + createVenv(venvDir, "0.1", log, requirements); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install -r")); + assertTrue(log.output.toString().contains("pip uninstall")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); + checkVenvContentsFile(contents, "0.1"); + log.clearOutput(); + + // new graalpy version + createVenv(venvDir, "0.2", log, requirements); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); + assertTrue(log.output.toString().contains("pip install -r")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); + checkVenvContentsFile(contents, "0.2"); + log.clearOutput(); + + // check that freeze rewrites an existing requirements file + writeRequirementsFile(requirements); // no packages + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "hello-world", "tiny-tiny==0.1"); + log.clearOutput(); + } + + private void writeRequirementsFile(Path requirements, String... packages) throws IOException { + List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); + lines.addAll(Arrays.asList(packages)); + Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + } + + @Test + public void installAndFreeze() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_installAndFreeze"); + Path venvDir = tmpDir.resolve("venv"); + Path contents = venvDir.resolve("contents"); + deleteDirOnShutdown(tmpDir); + + Path requirements = tmpDir.resolve("requirements.txt"); + + // install package from plugin config + createVenv(venvDir, "0.1", log, requirements, "hello-world"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + // freeze requirements + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "hello-world"); + log.clearOutput(); + + // reinstall without exact version declared - fails + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); + assertFalse(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world"); + log.clearOutput(); + + // reinstall with exact version declared - ok + Files.delete(requirements); + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1"); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + log.clearOutput(); + // freeze requirements + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "hello-world==0.1"); + log.clearOutput(); + + // add tiny-tiny - fails because inconsistent with requirements file + assert Files.exists(requirements); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2")); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'tiny-tiny==0.2'"))); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + + // delete requirements and try again tiny-tiny - now ok + Files.delete(requirements); + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + // freeze requirements - hello-world, tiny-tiny + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.2"); + log.clearOutput(); + + // install again - OK + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + log.clearOutput(); + + // update hello-world version - fails + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2")); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'hello-world==0.2'", requirements))); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + log.clearOutput(); + + // delete requirements and try again new hello-world version - now ok + Files.delete(requirements); + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); + log.clearOutput(); + // freeze requirements with new hello-world + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "hello-world==0.2", "tiny-tiny==0.2"); + log.clearOutput(); + + // install again - OK + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.output.toString().contains("pip install")); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); + log.clearOutput(); + + // reinstall with new graalpy version + createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); + assertTrue(log.output.toString().contains("pip install -r")); // requirements file is used + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.2", "hello-world==0.2", "tiny-tiny==0.2"); + log.clearOutput(); + } + + @Test + public void invalidVersionFormatTest() throws Exception { + TestLog log = new TestLog(); + + checkWrongPkgVersionFormat("", log); + checkWrongPkgVersionFormat("==2.2", log); + checkWrongPkgVersionFormat("==", log); + checkWrongPkgVersionFormat("somepkg==", log); + + checkWrongPkgVersionFormat("somepkg", log); + checkWrongPkgVersionFormat("somepkg==2.*", log); + checkWrongPkgVersionFormat("==*", log); + for (String v : new String[]{"", "<=", ">=", "~="}) { + checkWrongPkgVersionFormat("somepkg" + v + "2.2.0", log); + } + } + + private static void checkWrongPkgVersionFormat(String pkg, TestLog log) { + checkException(IOException.class, () -> VFSUtils.checkVersionFormat(Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'" + pkg + "'"))); + log.clearOutput(); + } + + @Test + public void packageConsistency() throws Exception { + TestLog log = new TestLog(); + + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_packageConsistency"); + deleteDirOnShutdown(tmpDir); + Path requirements = tmpDir.resolve("requirements.txt"); + Files.createFile(requirements); + + callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST); + assertFalse(log.output.toString().contains("inconsistent package")); + + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST, "pkg1")); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); + log.clearOutput(); + + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST, "pkg1==1")); + assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg1==1'", requirements))); + log.clearOutput(); + + final List requirementsList = Arrays.asList("pkg1==1.0.0"); + Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); + + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1")); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); + log.clearOutput(); + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg2")); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); + log.clearOutput(); + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg2==1")); + assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==1'", requirements))); + log.clearOutput(); + callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1==1.0"); + log.clearOutput(); + callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1==1.0.0"); + log.clearOutput(); + + final List requirementsList2 = Arrays.asList("pkg1==1.0.0", "pkg2==1.0.0"); + Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); + + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg2")); + assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); + log.clearOutput(); + checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg2==2")); + assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==2'", requirements))); + log.clearOutput(); + callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg1==1.0"); + log.clearOutput(); + callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg1==1.0", "pkg2==1.0.0"); + log.clearOutput(); + } + + private static void callPackageConsistencyCheck(Path requirements, TestLog log, List requirementsList, String... packages) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Method m = VFSUtils.class.getDeclaredMethod("checkPackagesConsistent", List.class, Path.class, List.class, String.class, String.class, BuildToolLog.class); + m.setAccessible(true); + m.invoke(VFSUtils.class, Arrays.asList(packages), requirements, requirementsList, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, log); + } + + private interface ExceptionCall { + void call() throws Exception; + } + + private static void checkException(Class cls, ExceptionCall c) { + try { + c.call(); + } catch (Exception e) { + if (e instanceof InvocationTargetException) { + assertEquals(cls, e.getCause().getClass()); + } else { + assertEquals(cls, e.getClass()); + } + } + } + + private static void checkVenvCreate(String output, boolean b) { + if (b) { + assertTrue(output.contains("-m venv")); + assertTrue(output.contains("-m ensurepip")); + } else { + assertFalse(output.contains("-m venv")); + assertFalse(output.contains("-m ensurepip")); + } + } + + private static void checkInstalledPackages(Path requirements, String... packages) throws IOException { + checkPackages(requirements, null, packages); + } + + private static void checkRequirementsFile(Path requirements, String... packages) throws IOException { + checkPackages(requirements, REQUIREMENTS_HEADER, packages); + } + + private static void checkPackages(Path file, String header, String... packages) throws IOException { + assertTrue(Files.exists(file)); + List lines = Files.readAllLines(file); + + if (header != null) { + String[] h = header.split("\n"); + assertTrue(lines.size() >= h.length); + for (int i = 0; i < h.length; i++) { + assertEquals("# " + h[i], lines.get(i)); + } + } + + lines = lines.stream().filter(line -> !line.trim().startsWith("#")).toList(); + assertEquals(packages.length, lines.size()); + for (String pkg : packages) { + boolean found = false; + String pkgDef = pkg.indexOf("==") >= 0 ? pkgDef = pkg : pkg + "=="; + for (String line : lines) { + assert line.contains("=="); + if (line.startsWith(pkgDef)) { + found = true; + break; + } + } + if (!found) { + fail("file " + file + " does not contain package " + pkg); + } + } + } + + private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, String... packages) throws IOException { + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, packages); + } + + private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path requirements, String... packages) throws IOException { + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, packages); + } + + private static void checkVenvContentsFile(Path contents, String graalPyVersion, String... packages) throws IOException { + assertTrue(Files.exists(contents)); + List lines = Files.readAllLines(contents); + + assertEquals(graalPyVersion, lines.get(0)); + lines.remove(0); + assertEquals(packages.length, lines.size()); + assertTrue(lines.containsAll(Arrays.asList(packages))); + } + +} diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py index e9f1e02c8f..1fee24f38c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2024, 2025, 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 @@ -401,7 +401,8 @@ def test_no_pkgs_but_resource_dir(self): self.assertTrue(result == 0, f"Execution failed with code {result}\n command: {command}\n stdout: {out}") self.assertFalse("[graalpy jbang integration] python packages" in out, f"Did not expect text:\n[graalpy jbang integration] python packages") self.assertTrue("[graalpy jbang integration] python resources directory: python-resources" in out, f"Expected text:\n[graalpy jbang integration] python resources directory: python-resources") - self.assertTrue("-m ensurepip" in out, f"-m ensurepip") + self.assertFalse("-m ensurepip" in out) + self.assertFalse("pip install" in out) @unittest.skipUnless(is_enabled, "ENABLE_JBANG_INTEGRATION_UNITTESTS is not true") def test_two_resource_dirs(self): diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index 51868cbf9b..979c2ab9e3 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -55,11 +55,15 @@ import org.apache.maven.model.Resource; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.plugins.annotations.*; import org.apache.maven.project.*; import org.eclipse.aether.graph.Dependency; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; import static org.graalvm.python.embedding.tools.vfs.VFSUtils.GRAALPY_GROUP_ID; import static org.graalvm.python.embedding.tools.vfs.VFSUtils.LAUNCHER_NAME; @@ -172,7 +176,7 @@ public void execute() throws MojoExecutionException { for(Resource r : project.getBuild().getResources()) { if (Files.exists(Path.of(r.getDirectory(), resourceDirectory, "proj"))) { getLog().warn(String.format("usage of %s is deprecated, use %s instead", Path.of(resourceDirectory, "proj"), Path.of(resourceDirectory, "src"))); - } + } if (!Files.exists(Path.of(r.getDirectory(), resourceDirectory)) && Files.exists(Path.of(r.getDirectory(), "vfs", "proj"))) { // there isn't the actual vfs resource root "org.graalvm.python.vfs" (VFS_ROOT), and there is only the outdated "vfs/proj" // => looks like a project created < 24.1.0 @@ -229,8 +233,14 @@ private void manageVenv() throws MojoExecutionException { delete(venvDirectory); return; } - - VFSUtils.createVenv(venvDirectory, new ArrayList(packages), getLauncherPath(), () -> calculateLauncherClasspath(project), getGraalPyVersion(project), new MavenDelegateLog(getLog())); + + Launcher launcher = new Launcher( getLauncherPath()) { + public Set computeClassPath() throws IOException { + return calculateLauncherClasspath(project); + } + }; + + VFSUtils.createVenv(venvDirectory, new ArrayList(packages), launcher, getGraalPyVersion(project), new MavenDelegateLog(getLog())); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java index e64a35d99c..6edc062f55 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java @@ -77,7 +77,7 @@ default public boolean isDebugEnabled() { default void debug(String s) { System.out.println(s); } - + final class CollectOutputLog implements BuildToolLog { private final List output = new ArrayList<>(); diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 3224de3d9d..c1deae3898 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -50,13 +50,17 @@ import java.nio.file.StandardOpenOption; import java.nio.file.attribute.PosixFilePermission; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.exec.BuildToolLog.CollectOutputLog; @@ -86,6 +90,8 @@ public final class VFSUtils { private static final String GRAALPY_MAIN_CLASS = "com.oracle.graal.python.shell.GraalPythonMain"; + private static final String FOR_MORE_INFO_REFERENCE_MSG = "For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools"; + public static void writeNativeImageConfig(Path metaInfRoot, String pluginId) throws IOException { writeNativeImageConfig(metaInfRoot, pluginId, VFS_ROOT); } @@ -177,11 +183,6 @@ private static String makeDirPath(Path p) { return ret; } - @FunctionalInterface - public interface LauncherClassPath { - Set get() throws IOException; - } - private static void delete(Path dir) throws IOException { if (!Files.exists(dir)) { return; @@ -195,42 +196,194 @@ private static void delete(Path dir) throws IOException { } } - public static void createVenv(Path venvDirectory, List packages, Path launcher, LauncherClassPath launcherClassPath, String graalPyVersion, BuildToolLog log) - throws IOException { - Path launcherPath = launcher; - String externalLauncher = System.getProperty("graalpy.vfs.venvLauncher"); - if (externalLauncher == null || externalLauncher.trim().isEmpty()) { - generateLaunchers(launcherPath, launcherClassPath, log); - } else { - launcherPath = Path.of(externalLauncher); + public static void warnMissingRequirementsFile(Path requirementsFile, String missingRequirementsFileWarning, BuildToolLog log) { + if (!Files.exists(requirementsFile)) { + warning(String.format(missingRequirementsFileWarning, requirementsFile) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); } + } - if (packages != null) { - trim(packages); + public static abstract class Launcher { + private final Path launcherPath; + + protected Launcher(Path launcherPath) { + Objects.requireNonNull(launcherPath); + this.launcherPath = launcherPath; } - List installedPackages = new ArrayList<>(); - var tag = venvDirectory.resolve("contents"); + protected abstract Set computeClassPath() throws IOException; + } - if (Files.exists(venvDirectory)) { - checkLauncher(venvDirectory, launcherPath, log); + private static class InstalledPackages { + final Path venvDirectory; + final Path installedFile; + List packages; - if (Files.isReadable(tag)) { - List lines = null; - try { - lines = Files.readAllLines(tag); - } catch (IOException e) { - throw new IOException(String.format("failed to read tag file %s", tag), e); + private InstalledPackages(Path venvDirectory, Path installedFile, List packages) { + this.venvDirectory = venvDirectory; + this.installedFile = venvDirectory.resolve("installed.txt"); + this.packages = packages; + } + + static InstalledPackages fromVenv(Path venvDirectory) throws IOException { + Path installed = venvDirectory.resolve("installed.txt"); + List pkgs = Files.exists(installed) ? readPackagesFromFile(installed) : Collections.EMPTY_LIST; + return new InstalledPackages(venvDirectory, installed, pkgs); + } + + void freeze(BuildToolLog log) throws IOException { + CollectOutputLog collectOutputLog = new CollectOutputLog(); + runPip(venvDirectory, "freeze", collectOutputLog, "--local"); + packages = new ArrayList<>(collectOutputLog.getOutput()); + + String toWrite = "# Generated by GraalPy Maven or Gradle plugin using pip freeze\n" + + "# This file is used by GraalPy VirtualFileSystem\n" + + String.join("\n", packages); + Files.write(installedFile, toWrite.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + + if (log.isDebugEnabled()) { + log.debug("VFSUtils.createVenv installed python packages:"); + for (String p : packages) { + log.debug(" " + p); } - if (lines.isEmpty() || !graalPyVersion.equals(lines.get(0))) { - log.info(String.format("Stale GraalPy venv, updating to %s", graalPyVersion)); - delete(venvDirectory); - } else { - for (int i = 1; i < lines.size(); i++) { - installedPackages.add(lines.get(i)); - } + } + } + } + + private static class VenvContents { + private final static String CONTENTS_FILE_NAME = "contents"; + final Path contentsFile; + List packages; + final String graalPyVersion; + + private VenvContents(Path contentsFile, List packages, String graalPyVersion) { + this.contentsFile = contentsFile; + this.packages = packages; + this.graalPyVersion = graalPyVersion; + } + + static VenvContents create(Path venvDirectory, String graalPyVersion) { + return new VenvContents(venvDirectory.resolve(CONTENTS_FILE_NAME), Collections.EMPTY_LIST, graalPyVersion); + } + + static VenvContents fromVenv(Path venvDirectory) throws IOException { + Path contentsFile = venvDirectory.resolve(CONTENTS_FILE_NAME); + List packages = new ArrayList<>(); + String graalPyVersion = null; + if (Files.isReadable(contentsFile)) { + List lines = Files.readAllLines(contentsFile); + if (lines.isEmpty()) { + return null; + } + Iterator it = lines.iterator(); + graalPyVersion = it.next(); + while (it.hasNext()) { + packages.add(it.next()); } } + return new VenvContents(contentsFile, packages, graalPyVersion); + } + + void write(List packages) throws IOException { + Files.write(contentsFile, List.of(graalPyVersion), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + if (packages != null) { + Files.write(contentsFile, packages, StandardOpenOption.APPEND); + this.packages = packages; + } + } + } + + public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { + createVenv(venvDirectory, packagesArgs, null, null, null, launcherArgs, graalPyVersion, log); + } + + public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, String inconsistentPackagesError, String wrongPackageVersionFormatError, + Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { + Objects.requireNonNull(venvDirectory); + Objects.requireNonNull(packages); + Objects.requireNonNull(launcherArgs); + Objects.requireNonNull(graalPyVersion); + Objects.requireNonNull(log); + + logVenvArgs(venvDirectory, packages, requirementsFile, launcherArgs, graalPyVersion, log); + + List pluginPackages = trim(packages); + List requirementsPackages = requirementsFile != null && Files.exists(requirementsFile) ? readPackagesFromFile(requirementsFile) : null; + if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, wrongPackageVersionFormatError, log)) { + return; + } + + VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcherArgs, log)); + + boolean installed = requirementsPackages != null ? install(venvDirectory, requirementsFile, requirementsPackages, log) : install(venvDirectory, pluginPackages, venvContents, log); + if (installed) { + venvContents.write(pluginPackages); + } + } + + private static void logVenvArgs(Path venvDirectory, List packages, Path requirementsFile, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) + throws IOException { + if (log.isDebugEnabled()) { + Set lcp = launcherArgs.computeClassPath(); + log.debug("VFSUtils.createVenv():"); + log.debug(" graalPyVersion: " + graalPyVersion); + log.debug(" venvDirectory: " + venvDirectory); + log.debug(" packages: " + packages); + log.debug(" requirements file: " + requirementsFile); + log.debug(" launcher: " + launcherArgs.launcherPath); + log.debug(" launcher classpath: " + lcp); + } + } + + private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String inconsistentPackagesError, + String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + if (requirementsPackages != null) { + checkPackagesConsistent(pluginPackages, requirementsPackages, inconsistentPackagesError, wrongPackageVersionFormatError, log); + logPackages(requirementsPackages, requirementsFile, log); + return needVenv(venvDirectory, requirementsPackages, log); + } else { + logPackages(pluginPackages, null, log); + return needVenv(venvDirectory, pluginPackages, log); + } + } + + private static boolean needVenv(Path venvDirectory, List packages, BuildToolLog log) throws IOException { + if ((packages.isEmpty())) { + if (Files.exists(venvDirectory)) { + log.info(String.format("No packages to install, deleting venv")); + delete(venvDirectory); + } else { + log.debug("VFSUtils.createVenv: skipping - no package or requirements file provided"); + } + return false; + } + return true; + } + + private static void logPackages(List packages, Path requirementsFile, BuildToolLog log) { + if (requirementsFile != null) { + log.info(String.format("Installing %s python packages from requirements file: %s", packages.size(), requirementsFile)); + } else { + log.info(String.format("Installing %s python packages from GraalPy plugin configuration", packages.size())); + } + } + + private static List readPackagesFromFile(Path file) throws IOException { + return Files.readAllLines(file).stream().filter((s) -> s != null && !s.trim().startsWith("#")).toList(); + } + + private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion, BuildToolLog log, Path launcherPath) throws IOException { + VenvContents contents = null; + if (Files.exists(venvDirectory)) { + checkVenvLauncher(venvDirectory, launcherPath, log); + contents = VenvContents.fromVenv(venvDirectory); + if (contents == null) { + log.warning(String.format("Reinstalling GraalPy venv due to corrupt contents file")); + delete(venvDirectory); + } else if (!graalPyVersion.equals(contents.graalPyVersion)) { + contents = null; + log.info(String.format("Stale GraalPy venv, updating to %s", graalPyVersion)); + delete(venvDirectory); + } } if (!Files.exists(venvDirectory)) { @@ -239,33 +392,130 @@ public static void createVenv(Path venvDirectory, List packages, Path la runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } - Iterable frozenPkgs = null; - if (packages != null) { - boolean needsUpdate = false; - needsUpdate |= deleteUnwantedPackages(venvDirectory, packages, installedPackages, log); - needsUpdate |= installWantedPackages(venvDirectory, packages, installedPackages, log); - if (needsUpdate) { - var freezeLog = new CollectOutputLog(); - runPip(venvDirectory, "freeze", freezeLog, "--local"); - frozenPkgs = freezeLog.getOutput(); + if (contents == null) { + contents = VenvContents.create(venvDirectory, graalPyVersion); + } + + return contents; + } + + private static boolean install(Path venvDirectory, Path requirementsFile, List requiredPkgs, BuildToolLog log) throws IOException { + InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); + if (installedPackages.packages.size() != requiredPkgs.size() || deleteUnwantedPackages(venvDirectory, requiredPkgs, installedPackages.packages, log)) { + runPip(venvDirectory, "install", log, "-r", requirementsFile.toString()); + installedPackages.freeze(log); + return true; + } else { + log.info("Python packages up to date, skipping install from requirements file"); + } + return false; + } + + private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, BuildToolLog log) throws IOException { + boolean needsUpdate = false; + needsUpdate |= deleteUnwantedPackages(venvDirectory, newPackages, venvContents.packages, log); + needsUpdate |= installWantedPackages(venvDirectory, newPackages, venvContents.packages, log); + if (needsUpdate) { + InstalledPackages.fromVenv(venvDirectory).freeze(log); + return true; + } + return false; + } + + public static void createRequirementsFile(Path venvDirectory, Path requirementsFile, String requirementsFileHeader, BuildToolLog log) throws IOException { + Objects.requireNonNull(venvDirectory); + Objects.requireNonNull(requirementsFile); + Objects.requireNonNull(requirementsFileHeader); + Objects.requireNonNull(log); + + assert Files.exists(venvDirectory); + + log.info(String.format("Creating %s", requirementsFile)); + + InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); + List header = getHeaderList(requirementsFileHeader); + Files.write(requirementsFile, header, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + Files.write(requirementsFile, installedPackages.packages, StandardOpenOption.APPEND); + + if (log.isDebugEnabled()) { + log.debug("VFSUtils created requirements file: " + requirementsFile); + for (String p : installedPackages.packages) { + log.debug(" " + p); } } + } - try { - Files.write(tag, List.of(graalPyVersion), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - Files.write(tag, packages, StandardOpenOption.APPEND); - if (frozenPkgs != null) { - String toWrite = "# Generated by GraalPy Maven or Gradle plugin using pip freeze\n" + - "# This file is used by GraalPy VirtualFileSystem\n" + - String.join("\n", frozenPkgs); - Files.write(venvDirectory.resolve("installed.txt"), toWrite.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + private static List getHeaderList(String requirementsFileHeader) { + List list = new ArrayList<>(); + String[] lines = requirementsFileHeader.split("\n"); + for (String l : lines) { + list.add("# " + l); + } + return list; + } + + public static void checkVersionFormat(List packages, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + Objects.requireNonNull(packages); + Objects.requireNonNull(wrongPackageVersionFormatError); + Objects.requireNonNull(log); + + StringBuilder sb = new StringBuilder(); + for (String pkg : packages) { + if (!checkValidPackageVersion(pkg)) { + sb.append(!sb.isEmpty() ? ", " : "").append("'").append(pkg).append("'"); } - } catch (IOException e) { - throw new IOException(String.format("failed to write tag file %s", tag), e); + } + if (!sb.isEmpty()) { + wrongPackageVersionError(sb.toString(), wrongPackageVersionFormatError, log); } } - private static void checkLauncher(Path venvDirectory, Path launcherPath, BuildToolLog log) throws IOException { + private static boolean checkValidPackageVersion(String pkg) throws IOException { + int idx = pkg.indexOf("=="); + if (idx <= 0) { + return false; + } else { + String version = pkg.substring(idx + 2).trim(); + if (version.isEmpty() || version.contains("*")) { + return false; + } + } + return true; + } + + private static void wrongPackageVersionError(String pkgs, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + error(String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); + throw new IOException("invalid package format: " + pkgs); + } + + private static void checkPackagesConsistent(List packages, Path requirementsFile, List requiredPackages, String inconsistentPackagesError, + String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + if (packages.isEmpty()) { + return; + } + + checkVersionFormat(packages, wrongPackageVersionFormatError, log); + + Map requiredPackagesMap = requiredPackages.stream().filter(p -> p.contains("==")).map(p -> p.split("==")).collect(Collectors.toMap(parts -> parts[0], parts -> parts[1])); + StringBuilder sb = new StringBuilder(); + for (String pkg : packages) { + String[] s = pkg.split("=="); + String pName = s[0]; + String pVersion = s[1]; + String rVersion = requiredPackagesMap.get(pName); + if (rVersion != null && rVersion.startsWith(pVersion)) { + continue; + } + sb.append(!sb.isEmpty() ? ", " : "").append("'").append(pkg).append("'"); + } + + if (!sb.isEmpty()) { + error(String.format(inconsistentPackagesError, sb) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); + throw new IOException("inconsistent packages"); + } + } + + private static void checkVenvLauncher(Path venvDirectory, Path launcherPath, BuildToolLog log) throws IOException { if (!Files.exists(launcherPath)) { throw new IOException(String.format("Launcher file does not exist '%s'", launcherPath)); } @@ -293,16 +543,26 @@ private static void checkLauncher(Path venvDirectory, Path launcherPath, BuildTo throw new IOException(String.format("failed to read config file %s", cfg), e); } } else { - log.info(String.format("missing venv config file: '%s'", cfg)); + log.info(String.format("Missing venv config file: '%s'", cfg)); } } - private static void generateLaunchers(Path laucherPath, LauncherClassPath launcherClassPath, BuildToolLog log) throws IOException { - if (!Files.exists(laucherPath)) { + private static Path ensureLauncher(Launcher launcherArgs, BuildToolLog log) throws IOException { + String externalLauncher = System.getProperty("graalpy.vfs.venvLauncher"); + if (externalLauncher == null || externalLauncher.trim().isEmpty()) { + generateLaunchers(launcherArgs, log); + return launcherArgs.launcherPath; + } else { + return Path.of(externalLauncher); + } + } + + private static void generateLaunchers(Launcher launcherArgs, BuildToolLog log) throws IOException { + if (!Files.exists(launcherArgs.launcherPath)) { log.info("Generating GraalPy launchers"); - createParentDirectories(laucherPath); + createParentDirectories(launcherArgs.launcherPath); Path java = Paths.get(System.getProperty("java.home"), "bin", "java"); - String classpath = String.join(File.pathSeparator, launcherClassPath.get()); + String classpath = String.join(File.pathSeparator, launcherArgs.computeClassPath()); if (!IS_WINDOWS) { var script = String.format(""" #!/usr/bin/env bash @@ -312,12 +572,12 @@ private static void generateLaunchers(Path laucherPath, LauncherClassPath launch String.join(File.pathSeparator, classpath), GRAALPY_MAIN_CLASS); try { - Files.writeString(laucherPath, script); - var perms = Files.getPosixFilePermissions(laucherPath); + Files.writeString(launcherArgs.launcherPath, script); + var perms = Files.getPosixFilePermissions(launcherArgs.launcherPath); perms.addAll(List.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_EXECUTE)); - Files.setPosixFilePermissions(laucherPath, perms); + Files.setPosixFilePermissions(launcherArgs.launcherPath, perms); } catch (IOException e) { - throw new IOException(String.format("failed to create launcher %s", laucherPath), e); + throw new IOException(String.format("failed to create launcher %s", launcherArgs.launcherPath), e); } } else { // on windows, generate a venv launcher that executes our mvn target @@ -334,7 +594,7 @@ with open(pyvenvcfg, 'w', encoding='utf-8') as f: f.write('venvlauncher_command = ') f.write(cmd) """, - laucherPath, + launcherArgs.launcherPath, java, classpath, GRAALPY_MAIN_CLASS); @@ -416,4 +676,21 @@ public static List trim(List l) { } return l; } + + private static void warning(String txt, BuildToolLog log) { + String prefix = txt.startsWith("WARNING:") ? "WARNING:" : ""; + log.warning(""); + for (String t : txt.split("\n")) { + log.warning(t.startsWith(prefix) ? t : prefix + " " + t); + } + log.warning(""); + } + + private static void error(String txt, BuildToolLog log) { + log.error(""); + for (String t : txt.split("\n")) { + log.error(t); + } + log.error(""); + } } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index 0b964a9720..eebba107aa 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -194,17 +194,17 @@ private TaskProvider registerResourcesTask(Project project, Confi "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); } - t.getPackages().set(extension.getPackages()); + t.getPackages().set(extension.getPackages()); - t.getOutput().convention( - extension.getExternalDirectory().orElse( - extension.getPythonResourcesDirectory() - .orElse(project.getLayout().getBuildDirectory().dir(DEFAULT_RESOURCES_DIRECTORY)))); - t.getIncludeVfsRoot().convention(extension.getExternalDirectory().map(d -> false) - .orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true))); - t.getResourceDirectory().set(extension.getResourceDirectory()); + t.getOutput().convention( + extension.getExternalDirectory().orElse( + extension.getPythonResourcesDirectory() + .orElse(project.getLayout().getBuildDirectory().dir(DEFAULT_RESOURCES_DIRECTORY)))); + t.getIncludeVfsRoot().convention(extension.getExternalDirectory().map(d -> false) + .orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true))); + t.getResourceDirectory().set(extension.getResourceDirectory()); - t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP); + t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP); }); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java index e9721ec9ad..72dc897bf2 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java @@ -44,6 +44,7 @@ import org.graalvm.python.GradleLogger; import org.graalvm.python.dsl.GraalPyExtension; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.file.ConfigurableFileCollection; @@ -131,8 +132,12 @@ public void exec() throws IOException { private void manageVenv() { List packages = getPackages().getOrElse(null); try { - VFSUtils.createVenv(getVenvDirectory(), new ArrayList(packages), getLauncherPath(), this::calculateLauncherClasspath, getPolyglotVersion().get(), - GradleLogger.of(getLogger())); + Launcher launcher = new Launcher( getLauncherPath()) { + public Set computeClassPath() { + return calculateLauncherClasspath(); + } + }; + VFSUtils.createVenv(getVenvDirectory(), new ArrayList(packages), launcher, getPolyglotVersion().get(), GradleLogger.of(getLogger())); } catch (IOException e) { throw new GradleException(String.format("failed to create venv %s", getVenvDirectory()), e); } diff --git a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java index 60f71f8bbe..e5d64c5d15 100644 --- a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java +++ b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -43,6 +43,7 @@ import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; import java.io.File; import java.io.IOException; @@ -58,6 +59,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -76,6 +78,12 @@ public class JBangIntegration { private static final String LAUNCHER = IS_WINDOWS ? "graalpy.exe" : "graalpy.sh"; private static final BuildToolLog BUILD_TOOL_LOG = new BuildToolLog() { + private static final boolean debugEnabled = Boolean.getBoolean("org.graalvm.python.jbang.log.debug"); + + @Override + public boolean isDebugEnabled() { + return debugEnabled; + } }; private static final String JBANG_COORDINATES = "org.graalvm.python:jbang:jar"; @@ -171,7 +179,12 @@ private static void handleVenv(Path venv, List> dependen // perhaps already checked by jbang throw new IllegalStateException("could not resolve parent for venv path: " + venv); } - VFSUtils.createVenv(venv, pkgs, getLauncherPath(venvParent.toString()), () -> calculateClasspath(dependencies), graalPyVersion, BUILD_TOOL_LOG); + Launcher launcher = new Launcher(getLauncherPath(venvParent.toString())) { + public Set computeClassPath() { + return calculateClasspath(dependencies); + }; + }; + VFSUtils.createVenv(venv, pkgs, launcher, graalPyVersion, BUILD_TOOL_LOG); if (dropPip) { try { diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index 7f00af0ec6..e52c7987ad 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -415,6 +415,10 @@ def __str__(self): TestConfig("multi-cext", vm_args + ['org.graalvm.python.embedding.cext.test'] + args + (["--use-graalvm"] if has_compiler else []), True), ) + configs.append( + TestConfig("vfsutil", vm_args + ['org.graalvm.python.embedding.vfs.test'] + args + (["--use-graalvm"] if has_compiler else []), True), + ) + if '--regex' not in args: async_regex = ['--regex', r'com\.oracle\.graal\.python\.test\.integration\.advanced\.AsyncActionThreadingTest'] configs.append(TestConfig("async", vm_args + ['-Dpython.AutomaticAsyncActions=false', 'com.oracle.graal.python.test', 'org.graalvm.python.embedding.test'] + async_regex + args, True, False)) @@ -1209,7 +1213,7 @@ def graalpython_gate_runner(args, tasks): "--verbose", "--no-leak-tests", "--regex", - r'((graal\.python\.test\.integration)|(graal\.python\.test\.(builtin|interop|util)))' + r'((graal\.python\.test\.integration)|(graal\.python\.test\.(builtin|interop|util))|(org\.graalvm\.python\.embedding\.(test|test\.integration))|(org\.graalvm\.python\.embedding\.vfs\.test))' ], report=True ) @@ -2985,6 +2989,7 @@ def apply(self, config): mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.py/*=ALL-UNNAMED']) # for Python internals mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.py.launcher/*=ALL-UNNAMED']) # for Python launcher internals mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.python.embedding/*=ALL-UNNAMED']) + mainClassArgs.extend(['-JUnitOpenPackages', 'org.graalvm.python.embedding.tools/*=ALL-UNNAMED']) if not PythonMxUnittestConfig.useResources: vmArgs.append('-Dorg.graalvm.language.python.home=' + mx.dependency("GRAALPYTHON_GRAALVM_SUPPORT").get_output()) if mx._opts.verbose: From aa6850d63fb54897ac2d8e8faf95ad929a073a61 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 24 Jan 2025 18:13:36 +0100 Subject: [PATCH 050/512] added support for requirement file to maven plugin --- .../src/tests/standalone/check_home_pom.xml | 6 +- .../tests/standalone/check_packages_pom.xml | 10 +- .../standalone/check_plugin_configuration.xml | 88 ++++ .../src/tests/standalone/test_maven_plugin.py | 133 ++++-- .../maven/plugin/AbstractGraalPyMojo.java | 380 ++++++++++++++++++ .../plugin/FreezeInstalledPackagesMojo.java | 117 ++++++ .../maven/plugin/ManageResourcesMojo.java | 304 +------------- 7 files changed, 701 insertions(+), 337 deletions(-) create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/standalone/check_plugin_configuration.xml create mode 100644 graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java create mode 100644 graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_home_pom.xml b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_home_pom.xml index 37b5a27ec3..b8ae79cddc 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_home_pom.xml +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_home_pom.xml @@ -72,14 +72,14 @@ SOFTWARE. ${env.GRAALPY_VERSION} - - - process-graalpy-resources + + + diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_packages_pom.xml b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_packages_pom.xml index fd3468edcc..9e380b16be 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_packages_pom.xml +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_packages_pom.xml @@ -72,16 +72,16 @@ SOFTWARE. ${env.GRAALPY_VERSION} - - - - - process-graalpy-resources + + + + + diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_plugin_configuration.xml b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_plugin_configuration.xml new file mode 100644 index 0000000000..90d0557729 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/check_plugin_configuration.xml @@ -0,0 +1,88 @@ + + + + 4.0.0 + + org.apache.maven.plugin.my.unit + project-check-packages + 1.0-SNAPSHOT + jar + Test MyMojo + + + + org.graalvm.polyglot + python-community + ${env.GRAALPY_VERSION} + pom + + + org.graalvm.python + python-launcher + ${env.GRAALPY_VERSION} + + + + + + + org.graalvm.python + graalpy-maven-plugin + ${env.GRAALPY_VERSION} + + + + process-graalpy-resources + + + + termcolor + + + + + + + + diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index 5c4f9e34cb..4f3806ca72 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -181,6 +181,104 @@ def test_generated_app_with_default_vfs_path(self): def test_generated_app_utils_pkg(self): self.check_generated_app(use_default_vfs_path=True, use_utils_pkg=True) + @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") + def test_wrong_configuration(self): + with util.TemporaryTestDirectory() as tmpdir: + + target_name = "test_wrong_configuration" + target_dir = os.path.join(str(tmpdir), target_name) + pom_template = os.path.join(os.path.dirname(__file__), "check_plugin_configuration.xml") + self.generate_app(tmpdir, target_dir, target_name, pom_template) + + mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env) + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out, contains=True) + assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") + def test_freeze_requirements(self): + with util.TemporaryTestDirectory() as tmpdir: + + target_name = "test_freeze_requirements" + target_dir = os.path.join(str(tmpdir), target_name) + self.generate_app(tmpdir, target_dir, target_name) + + mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env) + # run with java asserts on + if self.env.get("MAVEN_OPTS"): + self.env["MAVEN_OPTS"] = self.env.get("MAVEN_OPTS") + " -ea -esa" + else: + self.env["MAVEN_OPTS"] = "-ea -esa" + + # start with requests package without version + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "termcolor==2.2", "requests") + + # build + cmd = mvnw_cmd + ["package", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("pip install", out) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("Missing python requirements file", out) + assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze - fails due to no version + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("Missing python requirements file", out, contains=False) + util.check_ouput("Some python package(s) in graalpy-maven-plugin configuration have no exact version declared", out) + assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze with correct version + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "requests", "requests==2.32.3") + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=True) + util.check_ouput("Missing python requirements file", out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # add termcolor and build - fails as it is not part of requirements + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "termcolor==2.2\n") + cmd = mvnw_cmd + ["package", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("are either missing or have a different version in python requirements file", out) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze with termcolor + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=True) + util.check_ouput("Missing python requirements file", out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # rebuild with requirements and exec + cmd = mvnw_cmd + ["package", "exec:java", "-DrequirementsFile=test-requirements.txt", "-Dexec.mainClass=it.pkg.GraalPy"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("pip install", out, False) + util.check_ouput("hello java", out) + util.check_ouput("Missing python requirements file", out, contains=False) + + # disable packages config in pom + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "") + + # should be able to import ujson if installed + util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "it", "pkg", "GraalPy.java"), + "import hello", + "import requests; import hello") + + # clean and rebuild with requirements and exec + cmd = mvnw_cmd + ["clean", "package", "exec:java", "-DrequirementsFile=test-requirements.txt", "-Dexec.mainClass=it.pkg.GraalPy"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("pip install", out) + util.check_ouput("hello java", out) + util.check_ouput("Missing python requirements file", out, contains=False) + @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") def test_generated_app_external_resources(self): with util.TemporaryTestDirectory() as tmpdir: @@ -251,41 +349,6 @@ def test_fail_without_graalpy_dep(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("Missing GraalPy dependency. Please add to your pom either org.graalvm.polyglot:python-community or org.graalvm.polyglot:python", out) - @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") - def test_gen_launcher_and_venv(self): - with util.TemporaryTestDirectory() as tmpdir: - target_name = "gen_launcher_and_venv_test" - target_dir = os.path.join(str(tmpdir), target_name) - pom_template = os.path.join(os.path.dirname(__file__), "prepare_venv_pom.xml") - self.generate_app(tmpdir, target_dir, target_name, pom_template) - - mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env) - - cmd = mvnw_cmd + ["process-resources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out) - util.check_ouput("-m ensurepip",out) - util.check_ouput("ujson", out) - util.check_ouput("termcolor", out) - - # run again and assert that we do not regenerate the venv - cmd = mvnw_cmd + ["process-resources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out, False) - util.check_ouput("-m ensurepip", out, False) - util.check_ouput("ujson", out, False) - util.check_ouput("termcolor", out, False) - - # remove ujson pkg from plugin config and check if unistalled - util.replace_in_file(os.path.join(target_dir, "pom.xml"), "ujson", "") - - cmd = mvnw_cmd + ["process-resources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out, False) - util.check_ouput("-m ensurepip", out, False) - util.check_ouput("Uninstalling ujson", out) - util.check_ouput("termcolor", out, False) - @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") def test_check_home_warning(self): with util.TemporaryTestDirectory() as tmpdir: diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java new file mode 100644 index 0000000000..383daf396f --- /dev/null +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2025, 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 org.graalvm.python.maven.plugin; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Resource; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.*; +import org.eclipse.aether.graph.Dependency; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; + +import static org.graalvm.python.embedding.tools.vfs.VFSUtils.*; + +public abstract class AbstractGraalPyMojo extends AbstractMojo { + + private static final String PYTHON_LAUNCHER_ARTIFACT_ID = "python-launcher"; + + private static final String POLYGLOT_GROUP_ID = "org.graalvm.polyglot"; + private static final String PYTHON_COMMUNITY_ARTIFACT_ID = "python-community"; + private static final String PYTHON_ARTIFACT_ID = "python"; + private static final String GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID = "graalpy-maven-plugin"; + + protected static final String REQUIREMENTS_FILE_HEADER = """ + generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages' + + A complete list of python packages declared in graalpy-maven-plugin configuration and + their transitive dependencies which are to be installed in GraalPy virtual filessytem. + """; + + protected static final String MISSING_REQUIREMENTS_FILE_WARNING = """ + Missing python requirements file '%s'. + + It is highly recommended to freeze transitive python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages' + """; + + protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ + Some python package(s) in graalpy-maven-plugin configuration have no exact version declared: %s + + When using the graalpy-maven-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + """; + + protected static final String INCONSISTENT_PACKAGES_ERROR = """ + Some python package(s) from graalpy-maven-plugin configuration are either missing or have a different version in python requirements file: %s. + + The requirements file can be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + """; + + @Parameter(defaultValue = "${project}", required = true, readonly = true) + MavenProject project; + + @Parameter + String pythonResourcesDirectory; + + @Parameter(property = "externalDirectory") + String externalDirectory; + + @Parameter(property = "resourceDirectory") + String resourceDirectory; + + @Parameter(property = "requirementsFile", defaultValue = "requirements.txt") + String requirementsFile; + + @Parameter + List packages; + + public static class PythonHome { + private List includes; + private List excludes; + } + + @Parameter + PythonHome pythonHome; + + @Parameter(defaultValue = "${session}", readonly = true, required = true) + private MavenSession session; + + @Component + private ProjectBuilder projectBuilder; + + private Set launcherClassPath; + + protected void manageNativeImageConfig() throws MojoExecutionException { + try { + VFSUtils.writeNativeImageConfig(Path.of(project.getBuild().getOutputDirectory(), "META-INF"), GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID, resourceDirectory); + } catch (IOException e) { + throw new MojoExecutionException("failed to create native image configuration files", e); + } + } + + protected void listGraalPyResources() throws MojoExecutionException { + Path vfs = Path.of(project.getBuild().getOutputDirectory(), resourceDirectory); + if (Files.exists(vfs)) { + try { + VFSUtils.generateVFSFilesList(Path.of(project.getBuild().getOutputDirectory()), vfs); + } catch (IOException e) { + throw new MojoExecutionException(String.format("Failed to generate files list in '%s'", vfs), e); + } + } + } + + protected void preExec() throws MojoExecutionException { + pythonResourcesDirectory = normalizeEmpty(pythonResourcesDirectory); + externalDirectory = normalizeEmpty(externalDirectory); + resourceDirectory = normalizeEmpty(resourceDirectory); + requirementsFile = normalizeEmpty(requirementsFile); + packages = packages != null ? new ArrayList<>(packages) : Collections.EMPTY_LIST; + + if(pythonResourcesDirectory != null) { + if (externalDirectory != null) { + throw new MojoExecutionException( + "Cannot use and at the same time. " + + "New option is a replacement for deprecated . " + + "If you want to deploy the virtual environment into physical filesystem, use . " + + "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + + "If you want to bundle the virtual filesystem in Java resources, use . " + + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); + } + getLog().warn("Option is deprecated and will be removed. Use instead."); + externalDirectory = pythonResourcesDirectory; + } + + if (resourceDirectory != null) { + if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) { + throw new MojoExecutionException( + "Value of should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'"); + } + } + + if (resourceDirectory == null) { + if (externalDirectory == null) { + getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + + "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + + "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " + + "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", + VFS_ROOT, + Path.of(VFS_ROOT, "src"), + Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId()))); + } + resourceDirectory = VFS_ROOT; + } + + if(pythonHome != null) { + getLog().warn("The GraalPy plugin configuration setting was deprecated and has no effect anymore.\n" + + "For execution in jvm mode, the python language home is always available.\n" + + "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + + "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); + } + } + + protected void postExec() throws MojoExecutionException { + for(Resource r : project.getBuild().getResources()) { + if (Files.exists(Path.of(r.getDirectory(), resourceDirectory, "proj"))) { + getLog().warn(String.format("usage of %s is deprecated, use %s instead", Path.of(resourceDirectory, "proj"), Path.of(resourceDirectory, "src"))); + } + if (!Files.exists(Path.of(r.getDirectory(), resourceDirectory)) && Files.exists(Path.of(r.getDirectory(), "vfs", "proj"))) { + // there isn't the actual vfs resource root "org.graalvm.python.vfs" (VFS_ROOT), and there is only the outdated "vfs/proj" + // => looks like a project created < 24.1.0 + throw new MojoExecutionException(String.format( + "Wrong virtual filesystem root!\n" + + "Since 24.1.0 the virtual filesystem root has to be '%s'.\n" + + "Please rename the resource directory '%s' to '%s'", resourceDirectory, Path.of(r.getDirectory(), "vfs"), Path.of(r.getDirectory(), resourceDirectory))); + } + Path srcPath = Path.of(r.getDirectory(), resourceDirectory, "src"); + if (externalDirectory != null && Files.exists(srcPath)) { + getLog().warn(String.format( + "Found Java resources directory %s, however, the GraalPy Maven plugin is configured to use instead of Java resources. " + + "The files from %s will not be available in Contexts created using GraalPyResources#contextBuilder(Path). Move them to '%s' if " + + "you want to make them available when using external directory, or use Java resources by removing option.", + srcPath, + srcPath, + Path.of(externalDirectory, "src") + )); + } + } + } + + protected Path getVenvDirectory() { + Path venvDirectory; + if(externalDirectory == null) { + venvDirectory = Path.of(project.getBuild().getOutputDirectory(), resourceDirectory, VFS_VENV); + } else { + venvDirectory = Path.of(externalDirectory, VFS_VENV); + } + return venvDirectory; + } + + private static String normalizeEmpty(String s) { + if (s == null) { + return s; + } + String trimmed = s.trim(); + return trimmed.isEmpty() ? null : trimmed; + } + + protected Launcher createLauncher() { + Launcher launcherArg = new Launcher(getLauncherPath()) { + public Set computeClassPath() throws IOException { + return calculateLauncherClasspath(project); + } + }; + return launcherArg; + } + + protected Path getRequirementsFile() { + Path rfp = Path.of(requirementsFile); + if(rfp.isAbsolute()) { + return rfp; + } else { + return project.getBasedir().toPath().resolve(requirementsFile); + } + } + + private void delete(Path dir) throws MojoExecutionException { + try { + try (var s = Files.walk(dir)) { + s.sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } + } catch (IOException e) { + new MojoExecutionException(String.format("failed to delete %s", dir), e); + } + } + + private Path getLauncherPath() { + return Paths.get(project.getBuild().getDirectory(), LAUNCHER_NAME); + } + + protected static String getGraalPyVersion(MavenProject project) throws IOException { + DefaultArtifact a = (DefaultArtifact) getGraalPyArtifact(project); + String version = a.getVersion(); + if(a.isSnapshot()) { + // getVersion for a snapshot artefact returns base version + timestamp - e.g. 24.2.0-20240808.200816-1 + // and there might be snapshot artefacts with different timestamps in the repository. + // We should use $baseVersion + "-SNAPSHOT" as maven is in such case + // able to properly resolve all project artefacts. + version = a.getBaseVersion(); + if(!version.endsWith("-SNAPSHOT")) { + // getBaseVersion is expected to return a version without any additional metadata, e.g. 24.2.0-20240808.200816-1 -> 24.2.0, + // but also saw getBaseVersion() already returning version with -SNAPSHOT suffix + version = version + "-SNAPSHOT"; + } + } + return version; + } + + private static Artifact getGraalPyArtifact(MavenProject project) throws IOException { + var projectArtifacts = resolveProjectDependencies(project); + Artifact graalPyArtifact = projectArtifacts.stream(). + filter(a -> isPythonArtifact(a)) + .findFirst() + .orElse(null); + return Optional.ofNullable(graalPyArtifact).orElseThrow(() -> new IOException("Missing GraalPy dependency. Please add to your pom either %s:%s or %s:%s".formatted(POLYGLOT_GROUP_ID, PYTHON_COMMUNITY_ARTIFACT_ID, POLYGLOT_GROUP_ID, PYTHON_ARTIFACT_ID))); + } + + private static boolean isPythonArtifact(Artifact a) { + return (POLYGLOT_GROUP_ID.equals(a.getGroupId()) || GRAALPY_GROUP_ID.equals(a.getGroupId())) && + (PYTHON_COMMUNITY_ARTIFACT_ID.equals(a.getArtifactId()) || PYTHON_ARTIFACT_ID.equals(a.getArtifactId())); + } + + private static Collection resolveProjectDependencies(MavenProject project) { + return project.getArtifacts() + .stream() + .filter(a -> !"test".equals(a.getScope())) + .collect(Collectors.toList()); + } + + private Set calculateLauncherClasspath(MavenProject project) throws IOException { + if(launcherClassPath == null) { + String version = getGraalPyVersion(project); + launcherClassPath = new HashSet(); + + // 1.) python-launcher and transitive dependencies + // get the artifact from its direct dependency in graalpy-maven-plugin + getLog().debug("calculateLauncherClasspath based on " + GRAALPY_GROUP_ID + ":" + GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID + ":" + version); + DefaultArtifact mvnPlugin = new DefaultArtifact(GRAALPY_GROUP_ID, GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID, version, "compile", "jar", null, new DefaultArtifactHandler("pom")); + ProjectBuildingResult result = buildProjectFromArtifact(mvnPlugin); + Artifact graalPyLauncherArtifact = result.getProject().getArtifacts().stream().filter(a -> GRAALPY_GROUP_ID.equals(a.getGroupId()) && PYTHON_LAUNCHER_ARTIFACT_ID.equals(a.getArtifactId())) + .findFirst() + .orElse(null); + // python-launcher artifact + launcherClassPath.add(graalPyLauncherArtifact.getFile().getAbsolutePath()); + // and transitively all its dependencies + launcherClassPath.addAll(resolveDependencies(graalPyLauncherArtifact)); + + // 2.) graalpy dependencies + Artifact graalPyArtifact = getGraalPyArtifact(project); + assert graalPyArtifact != null; + launcherClassPath.addAll(resolveDependencies(graalPyArtifact)); + } + return launcherClassPath; + } + + private Set resolveDependencies(Artifact artifact) throws IOException { + Set dependencies = new HashSet<>(); + ProjectBuildingResult result = buildProjectFromArtifact(artifact); + for(Dependency d : result.getDependencyResolutionResult().getResolvedDependencies()) { + addDependency(d, dependencies); + } + return dependencies; + } + + private ProjectBuildingResult buildProjectFromArtifact(Artifact artifact) throws IOException{ + try{ + ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); + buildingRequest.setProject(null); + buildingRequest.setResolveDependencies(true); + buildingRequest.setPluginArtifactRepositories(project.getPluginArtifactRepositories()); + buildingRequest.setRemoteRepositories(project.getRemoteArtifactRepositories()); + + return projectBuilder.build(artifact, buildingRequest); + } catch (ProjectBuildingException e) { + throw new IOException("Error while building project", e); + } + } + + private void addDependency(Dependency d, Set dependencies) { + File f = d.getArtifact().getFile(); + if(f != null) { + dependencies.add(f.getAbsolutePath()); + } else { + getLog().warn("could not retrieve local file for artifact " + d.getArtifact()); + } + } +} + + diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java new file mode 100644 index 0000000000..b4b85155db --- /dev/null +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025, 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 org.graalvm.python.maven.plugin; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +import org.graalvm.python.embedding.tools.vfs.VFSUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +@Mojo(name = "freeze-installed-packages", + requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, + requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) +public class FreezeInstalledPackagesMojo extends AbstractGraalPyMojo { + + public void execute() throws MojoExecutionException { + checkEmptyPackages(); + + preExec(); + + manageVenv(); + listGraalPyResources(); + + postExec(); + } + + protected void manageVenv() throws MojoExecutionException { + Path venvDirectory = getVenvDirectory(); + MavenDelegateLog log = new MavenDelegateLog(getLog()); + Path requirements = getRequirementsFile(); + + try { + VFSUtils.checkVersionFormat(packages, WRONG_PACKAGE_VERSION_FORMAT_ERROR, log); + + VFSUtils.createVenv(venvDirectory, packages, createLauncher(), getGraalPyVersion(project), log); + + if(Files.exists(venvDirectory)) { + VFSUtils.createRequirementsFile(venvDirectory, requirements, REQUIREMENTS_FILE_HEADER, log); + } else { + // how comes? + log.warning("did not generate new python requirements file due to missing venv"); + } + } catch (IOException e) { + throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); + } + } + + private void checkEmptyPackages() throws MojoExecutionException { + if((packages == null || packages.isEmpty())) { + getLog().error(""); + getLog().error("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration."); + getLog().error(""); + getLog().error("NOTE that the section has to be declared for the whole graalpy-maven-plugin"); + getLog().error("and not specifically for the process-graalpy-resources execution goal."); + getLog().error(""); + getLog().error("Please add the section to your configuration as follows:"); + getLog().error(""); + getLog().error(" org.graalvm.python"); + getLog().error(" graalpy-maven-plugin"); + getLog().error(" "); + getLog().error(" "); + getLog().error(" {package_name}=={package_version}"); + getLog().error(" "); + getLog().error(" ..."); + getLog().error(" "); + getLog().error(""); + + getLog().error("For more information, please refer to https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md"); + getLog().error(""); + + throw new MojoExecutionException("missing packages"); + } + } +} diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index 979c2ab9e3..93082fad94 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -40,324 +40,40 @@ */ package org.graalvm.python.maven.plugin; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Collectors; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; - -import org.apache.maven.plugins.annotations.*; -import org.apache.maven.project.*; -import org.eclipse.aether.graph.Dependency; import org.graalvm.python.embedding.tools.vfs.VFSUtils; -import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; - -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.GRAALPY_GROUP_ID; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.LAUNCHER_NAME; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV; +import java.io.IOException; +import java.nio.file.Path; @Mojo(name = "process-graalpy-resources", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class ManageResourcesMojo extends AbstractMojo { - - private static final String PYTHON_LAUNCHER_ARTIFACT_ID = "python-launcher"; - - private static final String POLYGLOT_GROUP_ID = "org.graalvm.polyglot"; - private static final String PYTHON_COMMUNITY_ARTIFACT_ID = "python-community"; - private static final String PYTHON_ARTIFACT_ID = "python"; - private static final String GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID = "graalpy-maven-plugin"; - - @Parameter(defaultValue = "${project}", required = true, readonly = true) - MavenProject project; - - @Parameter - String pythonResourcesDirectory; - - @Parameter - String externalDirectory; - - @Parameter - String resourceDirectory; - - @Parameter - List packages; - - public static class PythonHome { - private List includes; - private List excludes; - } - - @Parameter - PythonHome pythonHome; - - @Parameter(defaultValue = "${session}", readonly = true, required = true) - private MavenSession session; - - @Component - private ProjectBuilder projectBuilder; - - private Set launcherClassPath; - - private static String normalizeEmpty(String s) { - if (s == null) { - return s; - } - String trimmed = s.trim(); - return trimmed.isEmpty() ? null : trimmed; - } +public class ManageResourcesMojo extends AbstractGraalPyMojo { public void execute() throws MojoExecutionException { - pythonResourcesDirectory = normalizeEmpty(pythonResourcesDirectory); - externalDirectory = normalizeEmpty(externalDirectory); - resourceDirectory = normalizeEmpty(resourceDirectory); - - if(pythonResourcesDirectory != null) { - if (externalDirectory != null) { - throw new MojoExecutionException( - "Cannot use and at the same time. " + - "New option is a replacement for deprecated . " + - "If you want to deploy the virtual environment into physical filesystem, use . " + - "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + - "If you want to bundle the virtual filesystem in Java resources, use . " + - "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); - } - getLog().warn("Option is deprecated and will be removed. Use instead."); - externalDirectory = pythonResourcesDirectory; - } - - if (resourceDirectory != null) { - if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) { - throw new MojoExecutionException( - "Value of should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'"); - } - } - - if (resourceDirectory == null) { - if (externalDirectory == null) { - getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + - "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + - "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " + - "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + - "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", - VFS_ROOT, - Path.of(VFS_ROOT, "src"), - Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId()))); - } - resourceDirectory = VFS_ROOT; - } - - if(pythonHome != null) { - getLog().warn("The GraalPy plugin configuration setting was deprecated and has no effect anymore.\n" + - "For execution in jvm mode, the python language home is always available.\n" + - "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + - "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); - } + preExec(); manageVenv(); listGraalPyResources(); manageNativeImageConfig(); - for(Resource r : project.getBuild().getResources()) { - if (Files.exists(Path.of(r.getDirectory(), resourceDirectory, "proj"))) { - getLog().warn(String.format("usage of %s is deprecated, use %s instead", Path.of(resourceDirectory, "proj"), Path.of(resourceDirectory, "src"))); - } - if (!Files.exists(Path.of(r.getDirectory(), resourceDirectory)) && Files.exists(Path.of(r.getDirectory(), "vfs", "proj"))) { - // there isn't the actual vfs resource root "org.graalvm.python.vfs" (VFS_ROOT), and there is only the outdated "vfs/proj" - // => looks like a project created < 24.1.0 - throw new MojoExecutionException(String.format( - "Wrong virtual filesystem root!\n" + - "Since 24.1.0 the virtual filesystem root has to be '%s'.\n" + - "Please rename the resource directory '%s' to '%s'", resourceDirectory, Path.of(r.getDirectory(), "vfs"), Path.of(r.getDirectory(), resourceDirectory))); - } - Path srcPath = Path.of(r.getDirectory(), resourceDirectory, "src"); - if (externalDirectory != null && Files.exists(srcPath)) { - getLog().warn(String.format( - "Found Java resources directory %s, however, the GraalPy Maven plugin is configured to use instead of Java resources. " + - "The files from %s will not be available in Contexts created using GraalPyResources#contextBuilder(Path). Move them to '%s' if " + - "you want to make them available when using external directory, or use Java resources by removing option.", - srcPath, - srcPath, - Path.of(externalDirectory, "src") - )); - } - } - - } - - private void manageNativeImageConfig() throws MojoExecutionException { - try { - VFSUtils.writeNativeImageConfig(Path.of(project.getBuild().getOutputDirectory(), "META-INF"), GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID, resourceDirectory); - } catch (IOException e) { - throw new MojoExecutionException("failed to create native image configuration files", e); - } - } - - private void listGraalPyResources() throws MojoExecutionException { - Path vfs = Path.of(project.getBuild().getOutputDirectory(), resourceDirectory); - if (Files.exists(vfs)) { - try { - VFSUtils.generateVFSFilesList(Path.of(project.getBuild().getOutputDirectory()), vfs); - } catch (IOException e) { - throw new MojoExecutionException(String.format("Failed to generate files list in '%s'", vfs), e); - } - } + postExec(); } private void manageVenv() throws MojoExecutionException { - Path venvDirectory; - if(externalDirectory == null) { - venvDirectory = Path.of(project.getBuild().getOutputDirectory(), resourceDirectory, VFS_VENV); - } else { - venvDirectory = Path.of(externalDirectory, VFS_VENV); - } - + Path venvDirectory = getVenvDirectory(); + MavenDelegateLog log = new MavenDelegateLog(getLog()); + Path requirements = getRequirementsFile(); try { - if (packages == null && externalDirectory == null) { - getLog().info(String.format("No venv packages declared, deleting %s", venvDirectory)); - delete(venvDirectory); - return; - } - - Launcher launcher = new Launcher( getLauncherPath()) { - public Set computeClassPath() throws IOException { - return calculateLauncherClasspath(project); - } - }; - - VFSUtils.createVenv(venvDirectory, new ArrayList(packages), launcher, getGraalPyVersion(project), new MavenDelegateLog(getLog())); + VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.warnMissingRequirementsFile(requirements, MISSING_REQUIREMENTS_FILE_WARNING, log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } } - private void delete(Path dir) throws MojoExecutionException { - try { - try (var s = Files.walk(dir)) { - s.sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); - } - } catch (IOException e) { - new MojoExecutionException(String.format("failed to delete %s", dir), e); - } - } - - private Path getLauncherPath() { - return Paths.get(project.getBuild().getDirectory(), LAUNCHER_NAME); - } - - private static String getGraalPyVersion(MavenProject project) throws IOException { - DefaultArtifact a = (DefaultArtifact) getGraalPyArtifact(project); - String version = a.getVersion(); - if(a.isSnapshot()) { - // getVersion for a snapshot artefact returns base version + timestamp - e.g. 24.2.0-20240808.200816-1 - // and there might be snapshot artefacts with different timestamps in the repository. - // We should use $baseVersion + "-SNAPSHOT" as maven is in such case - // able to properly resolve all project artefacts. - version = a.getBaseVersion(); - if(!version.endsWith("-SNAPSHOT")) { - // getBaseVersion is expected to return a version without any additional metadata, e.g. 24.2.0-20240808.200816-1 -> 24.2.0, - // but also saw getBaseVersion() already returning version with -SNAPSHOT suffix - version = version + "-SNAPSHOT"; - } - } - return version; - } - - private static Artifact getGraalPyArtifact(MavenProject project) throws IOException { - var projectArtifacts = resolveProjectDependencies(project); - Artifact graalPyArtifact = projectArtifacts.stream(). - filter(a -> isPythonArtifact(a)) - .findFirst() - .orElse(null); - return Optional.ofNullable(graalPyArtifact).orElseThrow(() -> new IOException("Missing GraalPy dependency. Please add to your pom either %s:%s or %s:%s".formatted(POLYGLOT_GROUP_ID, PYTHON_COMMUNITY_ARTIFACT_ID, POLYGLOT_GROUP_ID, PYTHON_ARTIFACT_ID))); - } - - private static boolean isPythonArtifact(Artifact a) { - return (POLYGLOT_GROUP_ID.equals(a.getGroupId()) || GRAALPY_GROUP_ID.equals(a.getGroupId())) && - (PYTHON_COMMUNITY_ARTIFACT_ID.equals(a.getArtifactId()) || PYTHON_ARTIFACT_ID.equals(a.getArtifactId())); - } - - private static Collection resolveProjectDependencies(MavenProject project) { - return project.getArtifacts() - .stream() - .filter(a -> !"test".equals(a.getScope())) - .collect(Collectors.toList()); - } - - private Set calculateLauncherClasspath(MavenProject project) throws IOException { - if(launcherClassPath == null) { - String version = getGraalPyVersion(project); - launcherClassPath = new HashSet(); - - // 1.) python-launcher and transitive dependencies - // get the artifact from its direct dependency in graalpy-maven-plugin - getLog().debug("calculateLauncherClasspath based on " + GRAALPY_GROUP_ID + ":" + GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID + ":" + version); - DefaultArtifact mvnPlugin = new DefaultArtifact(GRAALPY_GROUP_ID, GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID, version, "compile", "jar", null, new DefaultArtifactHandler("pom")); - ProjectBuildingResult result = buildProjectFromArtifact(mvnPlugin); - Artifact graalPyLauncherArtifact = result.getProject().getArtifacts().stream().filter(a -> GRAALPY_GROUP_ID.equals(a.getGroupId()) && PYTHON_LAUNCHER_ARTIFACT_ID.equals(a.getArtifactId())) - .findFirst() - .orElse(null); - // python-launcher artifact - launcherClassPath.add(graalPyLauncherArtifact.getFile().getAbsolutePath()); - // and transitively all its dependencies - launcherClassPath.addAll(resolveDependencies(graalPyLauncherArtifact)); - - // 2.) graalpy dependencies - Artifact graalPyArtifact = getGraalPyArtifact(project); - assert graalPyArtifact != null; - launcherClassPath.addAll(resolveDependencies(graalPyArtifact)); - } - return launcherClassPath; - } - - private Set resolveDependencies(Artifact artifact) throws IOException { - Set dependencies = new HashSet<>(); - ProjectBuildingResult result = buildProjectFromArtifact(artifact); - for(Dependency d : result.getDependencyResolutionResult().getResolvedDependencies()) { - addDependency(d, dependencies); - } - return dependencies; - } - - private ProjectBuildingResult buildProjectFromArtifact(Artifact artifact) throws IOException{ - try{ - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - buildingRequest.setProject(null); - buildingRequest.setResolveDependencies(true); - buildingRequest.setPluginArtifactRepositories(project.getPluginArtifactRepositories()); - buildingRequest.setRemoteRepositories(project.getRemoteArtifactRepositories()); - - return projectBuilder.build(artifact, buildingRequest); - } catch (ProjectBuildingException e) { - throw new IOException("Error while building project", e); - } - } - - private void addDependency(Dependency d, Set dependencies) { - File f = d.getArtifact().getFile(); - if(f != null) { - dependencies.add(f.getAbsolutePath()); - } else { - getLog().warn("could not retrieve local file for artifact " + d.getArtifact()); - } - } } - - From d4476c1d1e48f7fe87c2c02be72de393afa2bdb8 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Mon, 27 Jan 2025 14:51:51 +0100 Subject: [PATCH 051/512] fixed VirtualFileSystemTest to run also on windows --- .../embedding/test/VirtualFileSystemTest.java | 48 ++- .../test/VirtualFileSystemUtilsTest.java | 283 +++++++++++------- .../embedding/vfs/test/VFSUtilsTest.java | 30 +- .../python/embedding/tools/vfs/VFSUtils.java | 2 +- 4 files changed, 206 insertions(+), 157 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java index c7189d6269..d4225c11d6 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemTest.java @@ -250,21 +250,36 @@ public void toAbsolutePath() throws Exception { p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME)); assertTrue(p.isAbsolute()); assertEquals(VFS_ROOT_PATH, p.normalize()); - } - // ../../../VFS_ROOT/../real/fs/path - p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME, "..", realFSPath.toString())); - assertTrue(p.isAbsolute()); - assertEquals(realFSPath, p.normalize()); + // ../../../VFS_ROOT/../real/fs/path + p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME, "..", realFSPath.toString())); + assertTrue(p.isAbsolute()); + assertEquals(realFSPath, p.normalize()); - // CWD is VFS_ROOT, relative path pointing to real FS - // ../real/fs/path - if (!IS_WINDOWS) { + // CWD is VFS_ROOT, relative path pointing to real FS + // ../real/fs/path withCWD(fs, VFS_ROOT_PATH, (fst) -> { Path pp = fst.toAbsolutePath(Path.of("..", realFSPath.toString())); assertTrue(pp.isAbsolute()); assertEquals(realFSPath, pp.normalize()); }); + + // CWD is real FS, relative path pointing to VFS + // real/fs/path/../../ + withCWD(fs, realFSPath.getParent(), (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME)); + assertTrue(pp.isAbsolute()); + assertEquals(VFS_ROOT_PATH, pp.normalize()); + }); + + // CWD is real FS, relative path pointing through VFS to real FS + // real/fs/path/../../../VFS + withCWD(fs, realFSPath.getParent(), + (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME, "..", realFSPath.toString())); + assertTrue(pp.isAbsolute()); + assertEquals(realFSPath, pp.normalize()); + }); } // CWD is VFS_ROOT, relative path pointing through real FS back to VFS @@ -275,23 +290,6 @@ public void toAbsolutePath() throws Exception { assertEquals(VFS_ROOT_PATH, pp.normalize()); }); - // CWD is real FS, relative path pointing to VFS - // real/fs/path/../../ - withCWD(fs, realFSPath.getParent(), (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME)); - assertTrue(pp.isAbsolute()); - assertEquals(VFS_ROOT_PATH, pp.normalize()); - }); - - // CWD is real FS, relative path pointing through VFS to real FS - // real/fs/path/../../../VFS - withCWD(fs, realFSPath.getParent(), - (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME, "..", realFSPath.toString())); - assertTrue(pp.isAbsolute()); - assertEquals(realFSPath, pp.normalize()); - }); - assertEquals(Path.of("extractme").toAbsolutePath(), fs.toAbsolutePath(Path.of("extractme"))); withCWD(fs, realFSPath.getParent(), (fst) -> assertEquals(realFSPath, fst.toAbsolutePath(realFSPath.getFileName()))); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java index d21538f877..26413f70a1 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java @@ -88,6 +88,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Simple copy of VirtualFileSystemTest to test also the deprecated @@ -132,23 +133,23 @@ public VirtualFileSystemUtilsTest() { @Before public void initFS() throws Exception { rwHostIOVFS = getDelegatingFS(VirtualFileSystem.newBuilder().// - allowHostIO(READ_WRITE).// + allowHostIO(VirtualFileSystem.HostIO.READ_WRITE).// unixMountPoint(VFS_UNIX_MOUNT_POINT).// windowsMountPoint(VFS_WIN_MOUNT_POINT).// extractFilter(p -> p.getFileName().toString().endsWith("extractme")).// - resourceLoadingClass(VirtualFileSystemUtilsTest.class).build()); + resourceLoadingClass(VirtualFileSystemTest.class).build()); rHostIOVFS = getDelegatingFS(VirtualFileSystem.newBuilder().// - allowHostIO(READ).// + allowHostIO(VirtualFileSystem.HostIO.READ).// unixMountPoint(VFS_UNIX_MOUNT_POINT).// windowsMountPoint(VFS_WIN_MOUNT_POINT).// extractFilter(p -> p.getFileName().toString().endsWith("extractme")).// - resourceLoadingClass(VirtualFileSystemUtilsTest.class).build()); + resourceLoadingClass(VirtualFileSystemTest.class).build()); noHostIOVFS = getDelegatingFS(VirtualFileSystem.newBuilder().// - allowHostIO(NONE).// + allowHostIO(VirtualFileSystem.HostIO.NONE).// unixMountPoint(VFS_UNIX_MOUNT_POINT).// windowsMountPoint(VFS_WIN_MOUNT_POINT).// extractFilter(p -> p.getFileName().toString().endsWith("extractme")).// - resourceLoadingClass(VirtualFileSystemUtilsTest.class).build()); + resourceLoadingClass(VirtualFileSystemTest.class).build()); } @After @@ -176,7 +177,9 @@ public void toRealPath() throws Exception { for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { assertTrue(Files.isSameFile(realFSPath, fs.toRealPath(realFSPath))); withCWD(fs, realFSDir, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.getParent().getFileName().toString(), "extractme"))))); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.toString()))))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(Files.isSameFile(realFSPath, fst.toRealPath(Path.of("..", realFSPath.toString()))))); + } } checkException(SecurityException.class, () -> noHostIOVFS.toRealPath(realFSPath), "expected error for no host io fs"); } @@ -232,8 +235,10 @@ public void toAbsolutePath() throws Exception { // absolute path starting with VFS, pointing to real FS // /VFS_ROOT/../real/fs/path/ - p = Path.of(VFS_MOUNT_POINT, "..", realFSPath.toString()); - assertEquals(p, fs.toAbsolutePath(p)); + if (!IS_WINDOWS) { + p = Path.of(VFS_MOUNT_POINT, "..", realFSPath.toString()); + assertEquals(p, fs.toAbsolutePath(p)); + } // absolute path starting with real FS, pointing to VFS // /real/fs/path/../../../VFS_MOUNT_POINT @@ -247,22 +252,41 @@ public void toAbsolutePath() throws Exception { // no CWD set, so relative path starting in real FS, pointing to VFS // ../../../VFS_ROOT Path cwd = Path.of(".").toAbsolutePath(); - p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME)); - assertTrue(p.isAbsolute()); - assertEquals(VFS_ROOT_PATH, p.normalize()); - - // ../../../VFS_ROOT/../real/fs/path - p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME, "..", realFSPath.toString())); - assertTrue(p.isAbsolute()); - assertEquals(realFSPath, p.normalize()); - - // CWD is VFS_ROOT, relative path pointing to real FS - // ../real/fs/path - withCWD(fs, VFS_ROOT_PATH, (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("..", realFSPath.toString())); - assertTrue(pp.isAbsolute()); - assertEquals(realFSPath, pp.normalize()); - }); + if (!IS_WINDOWS) { + p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME)); + assertTrue(p.isAbsolute()); + assertEquals(VFS_ROOT_PATH, p.normalize()); + + // ../../../VFS_ROOT/../real/fs/path + p = fs.toAbsolutePath(Path.of(dotdot(cwd.getNameCount()).toString(), MOUNT_POINT_NAME, "..", realFSPath.toString())); + assertTrue(p.isAbsolute()); + assertEquals(realFSPath, p.normalize()); + + // CWD is VFS_ROOT, relative path pointing to real FS + // ../real/fs/path + withCWD(fs, VFS_ROOT_PATH, (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("..", realFSPath.toString())); + assertTrue(pp.isAbsolute()); + assertEquals(realFSPath, pp.normalize()); + }); + + // CWD is real FS, relative path pointing to VFS + // real/fs/path/../../ + withCWD(fs, realFSPath.getParent(), (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME)); + assertTrue(pp.isAbsolute()); + assertEquals(VFS_ROOT_PATH, pp.normalize()); + }); + + // CWD is real FS, relative path pointing through VFS to real FS + // real/fs/path/../../../VFS + withCWD(fs, realFSPath.getParent(), + (fst) -> { + Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME, "..", realFSPath.toString())); + assertTrue(pp.isAbsolute()); + assertEquals(realFSPath, pp.normalize()); + }); + } // CWD is VFS_ROOT, relative path pointing through real FS back to VFS // ../some/path/../../VFS_ROOT_PATH @@ -272,23 +296,6 @@ public void toAbsolutePath() throws Exception { assertEquals(VFS_ROOT_PATH, pp.normalize()); }); - // CWD is real FS, relative path pointing to VFS - // real/fs/path/../../ - withCWD(fs, realFSPath.getParent(), (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME)); - assertTrue(pp.isAbsolute()); - assertEquals(VFS_ROOT_PATH, pp.normalize()); - }); - - // CWD is real FS, relative path pointing through VFS to real FS - // real/fs/path/../../../VFS - withCWD(fs, realFSPath.getParent(), - (fst) -> { - Path pp = fst.toAbsolutePath(Path.of("dir", dotdot(realFSDirDir.getNameCount()), MOUNT_POINT_NAME, "..", realFSPath.toString())); - assertTrue(pp.isAbsolute()); - assertEquals(realFSPath, pp.normalize()); - }); - assertEquals(Path.of("extractme").toAbsolutePath(), fs.toAbsolutePath(Path.of("extractme"))); withCWD(fs, realFSPath.getParent(), (fst) -> assertEquals(realFSPath, fst.toAbsolutePath(realFSPath.getFileName()))); @@ -384,7 +391,9 @@ public void checkAccess() throws Exception { for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { fs.checkAccess(realFSPath, Set.of(AccessMode.READ)); withCWD(fs, realFSPath.getParent(), (fst) -> fst.checkAccess(realFSPath.getFileName(), Set.of(AccessMode.READ))); - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.checkAccess(Path.of("..", realFSPath.toString()), Set.of(AccessMode.READ))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.checkAccess(Path.of("..", realFSPath.toString()), Set.of(AccessMode.READ))); + } } checkException(SecurityException.class, () -> noHostIOVFS.checkAccess(realFSPath, Set.of(AccessMode.READ)), "expected error for no host io fs"); } @@ -445,12 +454,14 @@ public void createDirectory() throws Exception { fs.createDirectory(newDir2.getFileName()); assertTrue(Files.exists(newDir2)); }); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> { - Path newDir3 = newDir.getParent().resolve("newdir3"); - assertFalse(Files.exists(newDir3)); - fs.createDirectory(Path.of("..", newDir3.toString())); - assertTrue(Files.exists(newDir3)); - }); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> { + Path newDir3 = newDir.getParent().resolve("newdir3"); + assertFalse(Files.exists(newDir3)); + fs.createDirectory(Path.of("..", newDir3.toString())); + assertTrue(Files.exists(newDir3)); + }); + } } @Test @@ -484,10 +495,12 @@ public void delete() throws Exception { withCWD(rwHostIOVFS, realFSPath.getParent(), (fs) -> rwHostIOVFS.delete(realFSPath.getFileName())); assertFalse(Files.exists(realFSPath)); - Files.createFile(realFSPath); - assertTrue(Files.exists(realFSPath)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.delete(Path.of("..", realFSPath.toString()))); - assertFalse(Files.exists(realFSPath)); + if (!IS_WINDOWS) { + Files.createFile(realFSPath); + assertTrue(Files.exists(realFSPath)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.delete(Path.of("..", realFSPath.toString()))); + assertFalse(Files.exists(realFSPath)); + } } private static void deleteVFS(FileSystem fs, String pathPrefix) { @@ -520,13 +533,17 @@ public void newByteChannel() throws Exception { Path realFSPath = Files.createTempDirectory("graalpy.vfs.test").resolve("extractme"); Files.createFile(realFSPath); checkException(SecurityException.class, () -> rHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE)), "cant write into a read-only host FS"); - rwHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSPath, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("text".getBytes())); + } assertTrue(Files.exists(realFSPath)); for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { newByteChannelRealFS(fs, realFSPath, "text"); withCWD(fs, realFSPath.getParent(), (fst) -> newByteChannelRealFS(fs, realFSPath.getFileName(), "text")); - withCWD(fs, VFS_ROOT_PATH, (fst) -> newByteChannelRealFS(fs, Path.of("..", realFSPath.toString()), "text")); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> newByteChannelRealFS(fs, Path.of("..", realFSPath.toString()), "text")); + } } } @@ -549,26 +566,28 @@ private static void newByteChannelVFS(FileSystem fs, String pathPrefix) throws I } private static void newByteChannelVFS(FileSystem fs, Path path, Set options) throws IOException { - SeekableByteChannel bch = fs.newByteChannel(path, options); - ByteBuffer buffer = ByteBuffer.allocate(1024); - bch.read(buffer); - String s = new String(buffer.array()); - String[] ss = s.split(System.lineSeparator()); - assertTrue(ss.length >= 2); - assertEquals("text1", ss[0]); - assertEquals("text2", ss[1]); - checkException(NonWritableChannelException.class, () -> bch.write(buffer), "should not be able to write to VFS"); - checkException(NonWritableChannelException.class, () -> bch.truncate(0), "should not be able to write to VFS"); + try (SeekableByteChannel bch = fs.newByteChannel(path, options)) { + ByteBuffer buffer = ByteBuffer.allocate(1024); + bch.read(buffer); + String s = new String(buffer.array()); + String[] ss = s.split(System.lineSeparator()); + assertTrue(ss.length >= 2); + assertEquals("text1", ss[0]); + assertEquals("text2", ss[1]); + checkException(NonWritableChannelException.class, () -> bch.write(buffer), "should not be able to write to VFS"); + checkException(NonWritableChannelException.class, () -> bch.truncate(0), "should not be able to write to VFS"); + } } private static void newByteChannelRealFS(FileSystem fs, Path path, String expectedText) throws IOException { - SeekableByteChannel bch = fs.newByteChannel(path, Set.of(StandardOpenOption.READ)); - ByteBuffer buffer = ByteBuffer.allocate(expectedText.length()); - bch.read(buffer); - String s = new String(buffer.array()); - String[] ss = s.split(System.lineSeparator()); - assertTrue(ss.length >= 1); - assertEquals(expectedText, ss[0]); + try (SeekableByteChannel bch = fs.newByteChannel(path, Set.of(StandardOpenOption.READ))) { + ByteBuffer buffer = ByteBuffer.allocate(expectedText.length()); + bch.read(buffer); + String s = new String(buffer.array()); + String[] ss = s.split(System.lineSeparator()); + assertTrue(ss.length >= 1); + assertEquals(expectedText, ss[0]); + } } private static void checkCanOnlyRead(FileSystem fs, Path path, StandardOpenOption... options) { @@ -595,11 +614,13 @@ public void newDirectoryStream() throws Exception { checkException(NotDirectoryException.class, () -> fs.newDirectoryStream(realFSFile, (p) -> true)); newDirectoryStreamRealFS(fs, realFSDir, realFSFile); withCWD(fs, realFSDir.getParent(), (fst) -> newDirectoryStreamRealFS(fs, realFSDir.getFileName(), realFSFile)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); - // from real fs to VFS - withCWD(fs, realFSDir, (fst) -> newDirectoryStreamVFS(fs, Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT).toString())); - // from VFS to real FS - withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + // from real fs to VFS + withCWD(fs, realFSDir, (fst) -> newDirectoryStreamVFS(fs, Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT).toString())); + // from VFS to real FS + withCWD(fs, VFS_ROOT_PATH, (fst) -> newDirectoryStreamRealFS(fs, Path.of("..", realFSDir.toString()), realFSFile)); + } } checkException(SecurityException.class, () -> noHostIOVFS.newDirectoryStream(realFSDir, null), "expected error for no host io fs"); } @@ -650,7 +671,9 @@ public void readAttributes() throws Exception { for (FileSystem fs : new FileSystem[]{rHostIOVFS, rwHostIOVFS}) { assertTrue(((FileTime) fs.readAttributes(realFSPath, "creationTime").get("creationTime")).toMillis() > 0); withCWD(fs, realFSPath.getParent(), (fst) -> assertTrue(((FileTime) fs.readAttributes(realFSPath.getFileName(), "creationTime").get("creationTime")).toMillis() > 0)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(((FileTime) fs.readAttributes(Path.of("..", realFSPath.toString()), "creationTime").get("creationTime")).toMillis() > 0)); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(((FileTime) fs.readAttributes(Path.of("..", realFSPath.toString()), "creationTime").get("creationTime")).toMillis() > 0)); + } } checkException(SecurityException.class, () -> noHostIOVFS.readAttributes(realFSPath, "creationTime"), "expected error for no host io fs"); @@ -683,7 +706,7 @@ public void libsExtract() throws Exception { unixMountPoint(VFS_MOUNT_POINT).// windowsMountPoint(VFS_WIN_MOUNT_POINT).// extractFilter(p -> p.getFileName().toString().endsWith(".tso")).// - resourceLoadingClass(VirtualFileSystemUtilsTest.class).build()) { + resourceLoadingClass(VirtualFileSystemTest.class).build()) { FileSystem fs = getDelegatingFS(vfs); Path p = fs.toRealPath(VFS_ROOT_PATH.resolve("site-packages/testpkg/file.tso")); checkExtractedFile(p, null); @@ -721,7 +744,7 @@ public void noExtractFilter() throws Exception { unixMountPoint(VFS_MOUNT_POINT).// windowsMountPoint(VFS_WIN_MOUNT_POINT).// extractFilter(null).// - resourceLoadingClass(VirtualFileSystemUtilsTest.class).build()) { + resourceLoadingClass(VirtualFileSystemTest.class).build()) { FileSystem fs = getDelegatingFS(vfs); assertEquals(23, checkNotExtracted(fs, VFS_ROOT_PATH)); } @@ -827,8 +850,10 @@ public void getMimeType() throws Exception { checkException(NullPointerException.class, () -> fs.getMimeType(null)); Assert.assertNull(fs.getMimeType(VFS_ROOT_PATH)); fs.getMimeType(realFSPath); - // whatever the return value, just check it does not fail - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getMimeType(Path.of("..", realFSPath.toString()))); + if (!IS_WINDOWS) { + // whatever the return value, just check it does not fail + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getMimeType(Path.of("..", realFSPath.toString()))); + } } } @@ -840,8 +865,10 @@ public void getEncoding() throws Exception { checkException(NullPointerException.class, () -> fs.getEncoding(null)); Assert.assertNull(fs.getEncoding(VFS_ROOT_PATH)); fs.getEncoding(realFSPath); - // whatever the return value, just check it does not fail - withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getEncoding(Path.of("..", realFSPath.toString()))); + if (!IS_WINDOWS) { + // whatever the return value, just check it does not fail + withCWD(fs, VFS_ROOT_PATH, (fst) -> fst.getEncoding(Path.of("..", realFSPath.toString()))); + } } } @@ -858,7 +885,9 @@ public void setAttribute() throws Exception { // just check it does not fail for real FS paths rwHostIOVFS.setAttribute(realFSPath, "creationTime", FileTime.fromMillis(42)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.setAttribute(Path.of("..", realFSPath.toString()), "creationTime", FileTime.fromMillis(43))); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.setAttribute(Path.of("..", realFSPath.toString()), "creationTime", FileTime.fromMillis(43))); + } } @Test @@ -876,9 +905,13 @@ public void isSameFile() throws Exception { assertFalse(fs.isSameFile(realFSDir, VFS_ROOT_PATH)); assertFalse(fs.isSameFile(VFS_ROOT_PATH, realFSDir)); if (fs == noHostIOVFS) { - withCWD(fs, VFS_ROOT_PATH, (fst) -> checkException(SecurityException.class, () -> fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> checkException(SecurityException.class, () -> fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + } } else { - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertTrue(fst.isSameFile(realFSDir, Path.of("..", realFSDir.toString())))); + } withCWD(fs, realFSDir, (fst) -> assertTrue(fs.isSameFile(realFSFile1.getFileName(), realFSFile1.getFileName()))); withCWD(fs, realFSDir, (fst) -> assertFalse(fs.isSameFile(realFSFile1.getFileName(), realFSFile2.getFileName()))); } @@ -906,8 +939,10 @@ public void createLink() throws Exception { assertTrue(Files.exists(link)); Path link2 = realFSDir.resolve("link2"); assertFalse(Files.exists(link2)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.createLink(Path.of("..", link2.toString()), Path.of("..", realFSFile.toString()))); - assertTrue(Files.exists(link2)); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> rwHostIOVFS.createLink(Path.of("..", link2.toString()), Path.of("..", realFSFile.toString()))); + assertTrue(Files.exists(link2)); + } checkException(SecurityException.class, () -> rHostIOVFS.createLink(realFSDir.resolve("link3"), realFSFile)); checkException(SecurityException.class, () -> noHostIOVFS.createLink(realFSDir.resolve("link4"), realFSFile)); @@ -936,10 +971,12 @@ public void createAndReadSymbolicLink() throws Exception { rwHostIOVFS.createSymbolicLink(symlink, realFSLinkTarget); checkSymlink(realFSDir, realFSLinkTarget, symlink); - Files.delete(symlink); - assertFalse(Files.exists(symlink)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.createSymbolicLink(Path.of("..", symlink.toString()), realFSLinkTarget)); - checkSymlink(realFSDir, realFSLinkTarget, symlink); + if (!IS_WINDOWS) { + Files.delete(symlink); + assertFalse(Files.exists(symlink)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fst) -> fst.createSymbolicLink(Path.of("..", symlink.toString()), realFSLinkTarget)); + checkSymlink(realFSDir, realFSLinkTarget, symlink); + } } private void checkSymlink(Path dir, Path target, Path symlink) throws Exception { @@ -947,8 +984,10 @@ private void checkSymlink(Path dir, Path target, Path symlink) throws Exception checkException(SecurityException.class, () -> noHostIOVFS.readSymbolicLink(symlink)); for (FileSystem fs : new FileSystem[]{rwHostIOVFS, rHostIOVFS}) { assertEquals(target, fs.readSymbolicLink(symlink)); - withCWD(fs, VFS_ROOT_PATH, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of("..", symlink.toString())))); - withCWD(fs, dir, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of(dotdot(dir.getNameCount()), "..", VFS_MOUNT_POINT, "..", symlink.toString())))); + if (!IS_WINDOWS) { + withCWD(fs, VFS_ROOT_PATH, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of("..", symlink.toString())))); + withCWD(fs, dir, (fst) -> assertEquals(target, fst.readSymbolicLink(Path.of(dotdot(dir.getNameCount()), "..", VFS_MOUNT_POINT, "..", symlink.toString())))); + } } } @@ -991,7 +1030,9 @@ public void move() throws Exception { checkException(SecurityException.class, () -> fs.move(VFS_ROOT_PATH.resolve("file1"), VFS_ROOT_PATH.resolve("file2"))); } - rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("moved text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("moved text".getBytes())); + } assertTrue(Files.exists(realFSSource)); assertFalse(Files.exists(realFSTarget)); rwHostIOVFS.move(realFSSource, realFSTarget); @@ -1004,12 +1045,15 @@ public void move() throws Exception { assertTrue(Files.exists(realFSSource2)); assertFalse(Files.exists(realFSTarget2)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.move(Path.of("..", realFSSource2.toString()), Path.of("..", realFSTarget2.toString()))); - assertFalse(Files.exists(realFSSource2)); - assertTrue(Files.exists(realFSTarget2)); - newByteChannelRealFS(rwHostIOVFS, realFSSource, "moved text"); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.move(Path.of("..", realFSSource2.toString()), Path.of("..", realFSTarget2.toString()))); + assertFalse(Files.exists(realFSSource2)); + assertTrue(Files.exists(realFSTarget2)); + newByteChannelRealFS(rwHostIOVFS, realFSSource, "moved text"); + } - checkException(IOException.class, () -> rHostIOVFS.move(realFSSource2, realFSTarget2)); + Class exCls = IS_WINDOWS ? SecurityException.class : IOException.class; + checkException(exCls, () -> rHostIOVFS.move(realFSSource2, realFSTarget2)); checkException(SecurityException.class, () -> noHostIOVFS.move(realFSSource2, realFSTarget2)); } @@ -1033,7 +1077,9 @@ public void copy() throws Exception { checkException(SecurityException.class, () -> noHostIOVFS.copy(realFSSource, realFSTarget)); Files.createFile(realFSSource); - rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE)).write(ByteBuffer.wrap("copied text".getBytes())); + try (SeekableByteChannel ch = rwHostIOVFS.newByteChannel(realFSSource, Set.of(StandardOpenOption.WRITE))) { + ch.write(ByteBuffer.wrap("copied text".getBytes())); + } assertTrue(Files.exists(realFSSource)); rwHostIOVFS.copy(realFSSource, realFSTarget); @@ -1041,11 +1087,13 @@ public void copy() throws Exception { assertTrue(Files.exists(realFSTarget)); newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); - Files.delete(realFSTarget); - assertFalse(Files.exists(realFSTarget)); - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("..", realFSSource.toString()), Path.of("..", realFSTarget.toString()))); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); + if (!IS_WINDOWS) { + Files.delete(realFSTarget); + assertFalse(Files.exists(realFSTarget)); + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("..", realFSSource.toString()), Path.of("..", realFSTarget.toString()))); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "copied text"); + } Files.delete(realFSTarget); assertFalse(Files.exists(realFSTarget)); @@ -1059,11 +1107,13 @@ public void copy() throws Exception { assertTrue(Files.exists(realFSTarget)); newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); - Files.delete(realFSTarget); - assertFalse(Files.exists(realFSTarget)); - withCWD(rwHostIOVFS, realFSDir, (fs) -> fs.copy(Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT, "file1"), realFSTarget)); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + if (!IS_WINDOWS) { + Files.delete(realFSTarget); + assertFalse(Files.exists(realFSTarget)); + withCWD(rwHostIOVFS, realFSDir, (fs) -> fs.copy(Path.of(dotdot(realFSDir.getNameCount()), VFS_MOUNT_POINT, "file1"), realFSTarget)); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + } Files.delete(realFSTarget); assertFalse(Files.exists(realFSTarget)); @@ -1078,10 +1128,11 @@ public void copy() throws Exception { assertFalse(Files.exists(realFSTarget)); // no host IO - - withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("..", realFSTarget.toString()))); - assertTrue(Files.exists(realFSTarget)); - newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + if (!IS_WINDOWS) { + withCWD(rwHostIOVFS, VFS_ROOT_PATH, (fs) -> fs.copy(Path.of("file1"), Path.of("..", realFSTarget.toString()))); + assertTrue(Files.exists(realFSTarget)); + newByteChannelRealFS(rwHostIOVFS, realFSTarget, "text1"); + } } diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 7f3249535f..5c77509d4d 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -510,54 +510,54 @@ public void packageConsistency() throws Exception { Path requirements = tmpDir.resolve("requirements.txt"); Files.createFile(requirements); - callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST); + callPackageConsistencyCheck(log, Collections.EMPTY_LIST); assertFalse(log.output.toString().contains("inconsistent package")); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST, "pkg1")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.EMPTY_LIST, "pkg1")); assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, Collections.EMPTY_LIST, "pkg1==1")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.EMPTY_LIST, "pkg1==1")); assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg1==1'", requirements))); log.clearOutput(); final List requirementsList = Arrays.asList("pkg1==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg1")); assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg2")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg2")); assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList, "pkg2==1")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg2==1")); assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==1'", requirements))); log.clearOutput(); - callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1==1.0"); + callPackageConsistencyCheck(log, requirementsList, "pkg1==1.0"); log.clearOutput(); - callPackageConsistencyCheck(requirements, log, requirementsList, "pkg1==1.0.0"); + callPackageConsistencyCheck(log, requirementsList, "pkg1==1.0.0"); log.clearOutput(); final List requirementsList2 = Arrays.asList("pkg1==1.0.0", "pkg2==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg2")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, "pkg2")); assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg2==2")); + checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, "pkg2==2")); assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==2'", requirements))); log.clearOutput(); - callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg1==1.0"); + callPackageConsistencyCheck(log, requirementsList2, "pkg1==1.0"); log.clearOutput(); - callPackageConsistencyCheck(requirements, log, requirementsList2, "pkg1==1.0", "pkg2==1.0.0"); + callPackageConsistencyCheck(log, requirementsList2, "pkg1==1.0", "pkg2==1.0.0"); log.clearOutput(); } - private static void callPackageConsistencyCheck(Path requirements, TestLog log, List requirementsList, String... packages) + private static void callPackageConsistencyCheck(TestLog log, List requirementsList, String... packages) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method m = VFSUtils.class.getDeclaredMethod("checkPackagesConsistent", List.class, Path.class, List.class, String.class, String.class, BuildToolLog.class); + Method m = VFSUtils.class.getDeclaredMethod("checkPackagesConsistent", List.class, List.class, String.class, String.class, BuildToolLog.class); m.setAccessible(true); - m.invoke(VFSUtils.class, Arrays.asList(packages), requirements, requirementsList, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, log); + m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, log); } private interface ExceptionCall { diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index c1deae3898..cf6fa0d8b1 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -488,7 +488,7 @@ private static void wrongPackageVersionError(String pkgs, String wrongPackageVer throw new IOException("invalid package format: " + pkgs); } - private static void checkPackagesConsistent(List packages, Path requirementsFile, List requiredPackages, String inconsistentPackagesError, + private static void checkPackagesConsistent(List packages, List requiredPackages, String inconsistentPackagesError, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { if (packages.isEmpty()) { return; From 8b57b5ee873578b35de1444e2bfc07c5629ce2fa Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 28 Jan 2025 13:53:13 +0100 Subject: [PATCH 052/512] renamed ResourcesTask to InstallPackagesTask --- .../tests/standalone/test_gradle_plugin.py | 53 ++----------------- .../graalvm/python/GraalPyGradlePlugin.java | 18 +++---- ...rcesTask.java => InstallPackagesTask.java} | 18 +++++-- 3 files changed, 26 insertions(+), 63 deletions(-) rename graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/{ResourcesTask.java => InstallPackagesTask.java} (92%) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index b50be878dc..384d01a04e 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -236,43 +236,6 @@ def check_gradle_generated_app_external_resources(self): def check_gradle_fail_with_mismatching_graalpy_dep(self): pass # TODO: once the CI job builds enterprise - def check_gradle_gen_launcher_and_venv(self, community): - with TemporaryTestDirectory() as tmpdir: - target_dir = os.path.join(str(tmpdir), "gradle_gen_launcher_and_venv" + self.target_dir_name_sufix()) - self.generate_app(target_dir) - - build_file = os.path.join(target_dir, self.build_file_name) - - gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) - - append(build_file, self.packages_termcolor_ujson(community)) - - cmd = gradle_cmd + ["graalPyResources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out) - util.check_ouput("-m ensurepip",out) - util.check_ouput("ujson", out) - util.check_ouput("termcolor", out) - - # run again and assert that we do not regenerate the venv - cmd = gradle_cmd + ["graalPyResources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out, False) - util.check_ouput("-m ensurepip", out, False) - util.check_ouput("ujson", out, False) - util.check_ouput("termcolor", out, False) - - # remove ujson pkg from plugin config and check if unistalled - self.copy_build_files(target_dir) - append(build_file, self.packages_termcolor(community)) - - cmd = gradle_cmd + ["graalPyResources"] - out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("-m venv", out, False) - util.check_ouput("-m ensurepip", out, False) - util.check_ouput("Uninstalling ujson", out) - util.check_ouput("termcolor", out, False) - def check_tagfile(self, home, expected, log=''): with open(os.path.join(home, "tagfile")) as f: lines = f.readlines() @@ -286,7 +249,7 @@ def check_gradle_check_home_warning(self, community): build_file = os.path.join(target_dir, self.build_file_name) gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) - process_resources_cmd = gradle_cmd + ["--stacktrace", "graalPyResources"] + process_resources_cmd = gradle_cmd + ["--stacktrace", "graalPyInstallPackages"] # 1. process-resources with no pythonHome config - no warning printed log = Logger() @@ -364,7 +327,7 @@ def check_gradle_empty_packages(self): append(build_file, self.empty_packages()) gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) - cmd = gradle_cmd + ["graalPyResources"] + cmd = gradle_cmd + ["graalPyInstallPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) assert return_code == 0, out @@ -388,7 +351,7 @@ def check_gradle_python_resources_dir_deprecation(self): ''') gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) - cmd = gradle_cmd + ["graalPyResources"] + cmd = gradle_cmd + ["graalPyInstallPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("Property 'pythonResourcesDirectory' is deprecated and will be removed. Use property 'externalDirectory' instead.", out) assert return_code == 0, out @@ -413,7 +376,7 @@ def check_gradle_python_resources_dir_and_external_dir_error(self): ''') gradle_cmd = util.get_gradle_wrapper(target_dir, self.env) - cmd = gradle_cmd + ["graalPyResources"] + cmd = gradle_cmd + ["graalPyInstallPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("Cannot set both 'externalDirectory' and 'resourceDirectory' at the same time", out) assert return_code != 0, out @@ -515,10 +478,6 @@ def test_gradle_generated_app(self): def test_gradle_generated_app_external_resources(self): self.check_gradle_generated_app_external_resources() - @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") - def test_gradle_gen_launcher_and_venv(self): - self.check_gradle_gen_launcher_and_venv(community=True) - @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") def test_gradle_check_home_warning(self): self.check_gradle_check_home_warning(community=True) @@ -689,10 +648,6 @@ def test_gradle_generated_app(self): def test_gradle_generated_app_external_resources(self): self.check_gradle_generated_app_external_resources() - @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") - def test_gradle_gen_launcher_and_venv(self): - self.check_gradle_gen_launcher_and_venv(community=True) - @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") def test_gradle_check_home_warning(self): self.check_gradle_check_home_warning(community=True) diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index eebba107aa..a528edf000 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -42,7 +42,7 @@ import org.graalvm.python.dsl.GraalPyExtension; import org.graalvm.python.tasks.MetaInfTask; -import org.graalvm.python.tasks.ResourcesTask; +import org.graalvm.python.tasks.InstallPackagesTask; import org.graalvm.python.tasks.VFSFilesListTask; import org.gradle.api.GradleException; import org.gradle.api.Plugin; @@ -84,7 +84,7 @@ public abstract class GraalPyGradlePlugin implements Plugin { private static final String DEFAULT_RESOURCES_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "resources"; private static final String DEFAULT_FILESLIST_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "fileslist"; private static final String GRAALPY_META_INF_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "META-INF"; - private static final String GRAALPY_RESOURCES_TASK = "graalPyResources"; + private static final String GRAALPY_INSTALL_PACKAGES_TASK = "graalPyInstallPackages"; private static final String GRAALPY_META_INF_TASK_TASK = "graalPyMetaInf"; private static final String GRAALPY_VFS_FILESLIST_TASK = "graalPyVFSFilesList"; @@ -102,12 +102,12 @@ public void apply(Project project) { var launcherClasspath = createLauncherClasspath(); var javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class); - var resourcesTask = registerResourcesTask(project, launcherClasspath, extension); + TaskProvider installPackagesTask = registerInstallPackagesTask(project, launcherClasspath, extension); registerMetaInfTask(extension); - var vfsFilesListTask = registerCreateVfsFilesListTask(resourcesTask, javaPluginExtension, extension); + var vfsFilesListTask = registerCreateVfsFilesListTask(installPackagesTask, javaPluginExtension, extension); var mainSourceSet = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); - mainSourceSet.getResources().srcDir(resourcesTask); + mainSourceSet.getResources().srcDir(installPackagesTask); addDependencies(); project.afterEvaluate(proj -> { @@ -153,12 +153,12 @@ public void apply(Project project) { * @param resourcesTask the resources task * @return the task provider */ - private TaskProvider registerCreateVfsFilesListTask(TaskProvider resourcesTask, JavaPluginExtension javaPluginExtension, GraalPyExtension extension) { + private TaskProvider registerCreateVfsFilesListTask(TaskProvider installPackagesTask, JavaPluginExtension javaPluginExtension, GraalPyExtension extension) { var srcDirs = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getResources().getSrcDirs(); return project.getTasks().register(GRAALPY_VFS_FILESLIST_TASK, VFSFilesListTask.class, t -> { t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP); t.getResourceDirectory().set(extension.getResourceDirectory()); - t.getVfsDirectories().from(resourcesTask.flatMap(ResourcesTask::getOutput)); + t.getVfsDirectories().from(installPackagesTask.flatMap(InstallPackagesTask::getOutput)); srcDirs.forEach(t.getVfsDirectories()::from); t.getVfsFilesListOutputDir().convention(project.getLayout().getBuildDirectory().dir(DEFAULT_FILESLIST_DIRECTORY)); }); @@ -182,8 +182,8 @@ private void registerMetaInfTask(GraalPyExtension extension) { * @param launcherClasspath the classpath of the Python launcher * @return the resources task provider */ - private TaskProvider registerResourcesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) { - return project.getTasks().register(GRAALPY_RESOURCES_TASK, ResourcesTask.class, t -> { + private TaskProvider registerInstallPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) { + return project.getTasks().register(GRAALPY_INSTALL_PACKAGES_TASK, InstallPackagesTask.class, t -> { t.getLauncherClasspath().from(launcherClasspath); t.getLauncherDirectory().convention(project.getLayout().getBuildDirectory().dir("python-launcher")); t.getPolyglotVersion().convention(extension.getPolyglotVersion().orElse(determineGraalPyDefaultVersion())); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java similarity index 92% rename from graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java rename to graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 72dc897bf2..12fdb5b6e0 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/ResourcesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -40,7 +40,6 @@ */ package org.graalvm.python.tasks; -import org.graalvm.python.GraalPyGradlePlugin; import org.graalvm.python.GradleLogger; import org.graalvm.python.dsl.GraalPyExtension; import org.graalvm.python.embedding.tools.vfs.VFSUtils; @@ -74,12 +73,21 @@ import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV; /** - * This task is responsible for setting up the Python launcher and installing the dependencies which - * were requested by the user. This is either done in generated resources folder or in external - * directory provided by the user in {@link GraalPyExtension#getExternalDirectory()}. + * This task is responsible installing the dependencies which were requested by the user. + * This is either done in generated resources folder or in external directory provided by the user + * in {@link GraalPyExtension#getExternalDirectory()}. + * + *

    + * In scope of this task: + *

      + *
    1. The GraalPy launcher is set up.
    2. + *
    3. A python venv is created.
    4. + *
    5. Python packages are installed into the venv.
    6. + *
    + * */ @CacheableTask -public abstract class ResourcesTask extends DefaultTask { +public abstract class InstallPackagesTask extends DefaultTask { /** @see #getOutput() */ @Input From a753ad433b3626bf4e15f1bdfbba477c289e6df2 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 29 Jan 2025 14:07:39 +0100 Subject: [PATCH 053/512] fixed minor spelling typo in GraalPyRunner loggin message --- .../org/graalvm/python/embedding/tools/exec/GraalPyRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java index a39260e6a0..1d1a275e2c 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java @@ -109,7 +109,7 @@ private static void runVenvBin(Path venvDirectory, String command, BuildToolLog var cmd = new ArrayList(); cmd.add(venvDirectory.resolve(BIN_DIR).resolve(command + EXE_SUFFIX).toString()); cmd.addAll(args); - log.info("executing: " + String.join(" ", cmd)); + log.info("Executing: " + String.join(" ", cmd)); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } From 3c409d434ed1e9317ee992c6fff648e6555c40fd Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 29 Jan 2025 19:39:48 +0100 Subject: [PATCH 054/512] added missing requirements file check to VFSUtil.createVenv() --- .../embedding/test/EmbeddingTestUtils.java | 17 +- .../embedding/vfs/test/VFSUtilsTest.java | 164 ++++++++++++------ .../maven/plugin/AbstractGraalPyMojo.java | 5 +- .../maven/plugin/ManageResourcesMojo.java | 3 +- .../python/embedding/tools/vfs/VFSUtils.java | 26 +-- 5 files changed, 139 insertions(+), 76 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index bb4014c785..adce95adee 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -59,10 +59,11 @@ private EmbeddingTestUtils() { } public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException { - createVenv(venvDir, graalPyVersion, log, null, null, null, packages); + createVenv(venvDir, graalPyVersion, log, null, null, null, null, packages); } - public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, String iconsistentPackagesError, String wrongPackageVersionError, String... packages) + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, String iconsistentPackagesError, String wrongPackageVersionError, + String missingRequirementsFileWarning, String... packages) throws IOException { try { log.info("<<< creating test venv <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); @@ -74,7 +75,7 @@ public Set computeClassPath() { }; }; if (requirements != null) { - VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, iconsistentPackagesError, wrongPackageVersionError, launcher, graalPyVersion, log); + VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, iconsistentPackagesError, wrongPackageVersionError, missingRequirementsFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); } @@ -88,13 +89,19 @@ public Set computeClassPath() { public static void deleteDirOnShutdown(Path tmpdir) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { - try (var fs = Files.walk(tmpdir)) { - fs.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + try { + delete(tmpdir); } catch (IOException e) { } })); } + public static void delete(Path dir) throws IOException { + try (var fs = Files.walk(dir)) { + fs.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } + } + private static Set getClasspath() { var sb = new ArrayList(); var modPath = System.getProperty("jdk.module.path"); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 5c77509d4d..20fc0ba4c9 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -57,6 +57,7 @@ import java.util.Collections; import java.util.List; +import static org.graalvm.python.embedding.test.EmbeddingTestUtils.delete; import static org.graalvm.python.embedding.test.EmbeddingTestUtils.deleteDirOnShutdown; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -68,6 +69,7 @@ public class VFSUtilsTest { private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; private static final String INCONSISTENT_PKGS_ERROR = "inconsistent package %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; + private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; private static final class TestLog implements BuildToolLog { private final StringBuilder output = new StringBuilder(); @@ -142,14 +144,14 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); // install packages log.clearOutput(); createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); @@ -158,9 +160,9 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); - assertFalse(log.output.toString().contains("hello-world")); - assertFalse(log.output.toString().contains("tiny-tiny")); + assertFalse(log.getOutput().contains("pip install")); + assertFalse(log.getOutput().contains("hello-world")); + assertFalse(log.getOutput().contains("tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); @@ -169,9 +171,9 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.1", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); - assertFalse(log.output.toString().contains("hello-world")); - assertTrue(log.output.toString().contains("Uninstalling tiny-tiny")); + assertFalse(log.getOutput().contains("pip install")); + assertFalse(log.getOutput().contains("hello-world")); + assertTrue(log.getOutput().contains("Uninstalling tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); @@ -181,9 +183,9 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.1", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); - assertFalse(log.output.toString().contains("hello-world")); - assertFalse(log.output.toString().contains("tiny-tiny")); + assertFalse(log.getOutput().contains("pip install")); + assertFalse(log.getOutput().contains("hello-world")); + assertFalse(log.getOutput().contains("tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); @@ -192,10 +194,10 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.2", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); - assertTrue(log.output.toString().contains("pip install")); - assertTrue(log.output.toString().contains("hello-world")); - assertFalse(log.output.toString().contains("tiny-tiny")); + assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains("hello-world")); + assertFalse(log.getOutput().contains("tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.2", "hello-world"); } @@ -214,7 +216,7 @@ public void testWithoutRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); createVenv(venvDir, "0.1", log, "hello-world"); @@ -248,7 +250,7 @@ public void testWithoutRequirementsFile() throws IOException { // new graalPy version createVenv(venvDir, "0.2", log, "hello-world"); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.2", "hello-world"); log.clearOutput(); @@ -268,20 +270,20 @@ public void emptyRequirements() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); - assertFalse(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); createVenv(venvDir, "0.1", log, requirements); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); createVenv(venvDir, "0.2", log, requirements); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); } @@ -302,7 +304,7 @@ public void onlyRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); assertFalse(Files.exists(venvDir.resolve("installed.txt"))); log.clearOutput(); @@ -310,7 +312,7 @@ public void onlyRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("pip install -r")); + assertTrue(log.getOutput().contains("pip install -r")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1"); log.clearOutput(); @@ -319,8 +321,8 @@ public void onlyRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install -r")); - assertTrue(log.output.toString().contains("pip uninstall")); + assertTrue(log.getOutput().contains("pip install -r")); + assertTrue(log.getOutput().contains("pip uninstall")); checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny"); checkVenvContentsFile(contents, "0.1"); log.clearOutput(); @@ -329,7 +331,7 @@ public void onlyRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install -r")); + assertTrue(log.getOutput().contains("pip install -r")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1"); log.clearOutput(); @@ -338,8 +340,8 @@ public void onlyRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, requirements); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install -r")); - assertTrue(log.output.toString().contains("pip uninstall")); + assertTrue(log.getOutput().contains("pip install -r")); + assertTrue(log.getOutput().contains("pip uninstall")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); checkVenvContentsFile(contents, "0.1"); log.clearOutput(); @@ -347,8 +349,8 @@ public void onlyRequirementsFile() throws IOException { // new graalpy version createVenv(venvDir, "0.2", log, requirements); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); - assertTrue(log.output.toString().contains("pip install -r")); + assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains("pip install -r")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); checkVenvContentsFile(contents, "0.2"); log.clearOutput(); @@ -366,6 +368,42 @@ private void writeRequirementsFile(Path requirements, String... packages) throws Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } + @Test + public void missingRequirementsWarning() throws IOException { + TestLog log = new TestLog(); + Path tmpDir = Files.createTempDirectory("VFSUtilsTest_missingRequirementsWarning"); + Path venvDir = tmpDir.resolve("venv"); + Path contents = venvDir.resolve("contents"); + deleteDirOnShutdown(tmpDir); + + Path requirements = tmpDir.resolve("requirements.txt"); + + // install request, it pulls in transitive pkgs and we get the missing requirements file + // warning + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.3"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); + assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + + // freeze requirements + VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + + // install again - no more warning + delete(venvDir); + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.3"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + } + @Test public void installAndFreeze() throws IOException { TestLog log = new TestLog(); @@ -382,104 +420,120 @@ public void installAndFreeze() throws IOException { checkVenvCreate(log.getOutput(), true); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); // freeze requirements VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); checkRequirementsFile(requirements, "hello-world"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); // reinstall without exact version declared - fails checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); - assertFalse(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); + assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // reinstall with exact version declared - ok Files.delete(requirements); createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1"); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); checkRequirementsFile(requirements, "hello-world==0.1"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // add tiny-tiny - fails because inconsistent with requirements file assert Files.exists(requirements); checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); - assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'tiny-tiny==0.2'"))); + assertFalse(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, "'tiny-tiny==0.2'"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); // delete requirements and try again tiny-tiny - now ok Files.delete(requirements); createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); // freeze requirements - hello-world, tiny-tiny VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // install again - OK createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // update hello-world version - fails checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); - assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'hello-world==0.2'", requirements))); + assertFalse(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, "'hello-world==0.2'", requirements))); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // delete requirements and try again new hello-world version - now ok Files.delete(requirements); createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); - assertTrue(log.output.toString().contains("pip install")); + assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements with new hello-world VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); checkRequirementsFile(requirements, "hello-world==0.2", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // install again - OK createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); - assertFalse(log.output.toString().contains("pip install")); + assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // reinstall with new graalpy version createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), true); - assertTrue(log.output.toString().contains("Stale GraalPy venv, updating to")); - assertTrue(log.output.toString().contains("pip install -r")); // requirements file is used + assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains("pip install -r")); // requirements file is used checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.2", "hello-world==0.2", "tiny-tiny==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); } @Test - public void invalidVersionFormatTest() throws Exception { + public void invalidVersionFormatTest() { TestLog log = new TestLog(); checkWrongPkgVersionFormat("", log); @@ -497,7 +551,7 @@ public void invalidVersionFormatTest() throws Exception { private static void checkWrongPkgVersionFormat(String pkg, TestLog log) { checkException(IOException.class, () -> VFSUtils.checkVersionFormat(Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'" + pkg + "'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'" + pkg + "'"))); log.clearOutput(); } @@ -511,27 +565,27 @@ public void packageConsistency() throws Exception { Files.createFile(requirements); callPackageConsistencyCheck(log, Collections.EMPTY_LIST); - assertFalse(log.output.toString().contains("inconsistent package")); + assertFalse(log.getOutput().contains("inconsistent package")); checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.EMPTY_LIST, "pkg1")); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.EMPTY_LIST, "pkg1==1")); - assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg1==1'", requirements))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg1==1'", requirements))); log.clearOutput(); final List requirementsList = Arrays.asList("pkg1==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg1")); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg2")); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, "pkg2==1")); - assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==1'", requirements))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==1'", requirements))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList, "pkg1==1.0"); log.clearOutput(); @@ -542,10 +596,10 @@ public void packageConsistency() throws Exception { Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, "pkg2")); - assertTrue(log.output.toString().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, "pkg2==2")); - assertTrue(log.output.toString().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==2'", requirements))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, "'pkg2==2'", requirements))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList2, "pkg1==1.0"); log.clearOutput(); @@ -610,7 +664,7 @@ private static void checkPackages(Path file, String header, String... packages) assertEquals(packages.length, lines.size()); for (String pkg : packages) { boolean found = false; - String pkgDef = pkg.indexOf("==") >= 0 ? pkgDef = pkg : pkg + "=="; + String pkgDef = pkg.indexOf("==") >= 0 ? pkg : pkg + "=="; for (String line : lines) { assert line.contains("=="); if (line.startsWith(pkgDef)) { @@ -629,7 +683,7 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, } private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path requirements, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, packages); + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, packages); } private static void checkVenvContentsFile(Path contents, String graalPyVersion, String... packages) throws IOException { diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index 383daf396f..dd63bf33ad 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -80,9 +80,10 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { """; protected static final String MISSING_REQUIREMENTS_FILE_WARNING = """ - Missing python requirements file '%s'. + Missing python requirements file. + It looks like some transitive python dependencies were installed together with the packages declared in graalpy-maven-plugin configuration. - It is highly recommended to freeze transitive python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages' + It is highly recommended to freeze python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. """; protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index 93082fad94..590d1ff994 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -69,8 +69,7 @@ private void manageVenv() throws MojoExecutionException { MavenDelegateLog log = new MavenDelegateLog(getLog()); Path requirements = getRequirementsFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); - VFSUtils.warnMissingRequirementsFile(requirements, MISSING_REQUIREMENTS_FILE_WARNING, log); + VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index cf6fa0d8b1..93a66185c1 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -196,12 +196,6 @@ private static void delete(Path dir) throws IOException { } } - public static void warnMissingRequirementsFile(Path requirementsFile, String missingRequirementsFileWarning, BuildToolLog log) { - if (!Files.exists(requirementsFile)) { - warning(String.format(missingRequirementsFileWarning, requirementsFile) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); - } - } - public static abstract class Launcher { private final Path launcherPath; @@ -230,7 +224,7 @@ static InstalledPackages fromVenv(Path venvDirectory) throws IOException { return new InstalledPackages(venvDirectory, installed, pkgs); } - void freeze(BuildToolLog log) throws IOException { + List freeze(BuildToolLog log) throws IOException { CollectOutputLog collectOutputLog = new CollectOutputLog(); runPip(venvDirectory, "freeze", collectOutputLog, "--local"); packages = new ArrayList<>(collectOutputLog.getOutput()); @@ -246,6 +240,7 @@ void freeze(BuildToolLog log) throws IOException { log.debug(" " + p); } } + return packages; } } @@ -293,10 +288,11 @@ void write(List packages) throws IOException { } public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { - createVenv(venvDirectory, packagesArgs, null, null, null, launcherArgs, graalPyVersion, log); + createVenv(venvDirectory, packagesArgs, null, null, null, null, launcherArgs, graalPyVersion, log); } - public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, String inconsistentPackagesError, String wrongPackageVersionFormatError, + public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, + String inconsistentPackagesError, String wrongPackageVersionFormatError, String missingRequirementsFileWarning, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); @@ -314,7 +310,8 @@ public static void createVenv(Path venvDirectory, List packages, Path re VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcherArgs, log)); - boolean installed = requirementsPackages != null ? install(venvDirectory, requirementsFile, requirementsPackages, log) : install(venvDirectory, pluginPackages, venvContents, log); + boolean installed = requirementsPackages != null ? install(venvDirectory, requirementsFile, requirementsPackages, log) + : install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); if (installed) { venvContents.write(pluginPackages); } @@ -411,12 +408,17 @@ private static boolean install(Path venvDirectory, Path requirementsFile, List newPackages, VenvContents venvContents, BuildToolLog log) throws IOException { + private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, String missingRequirementsFileWarning, BuildToolLog log) throws IOException { boolean needsUpdate = false; needsUpdate |= deleteUnwantedPackages(venvDirectory, newPackages, venvContents.packages, log); needsUpdate |= installWantedPackages(venvDirectory, newPackages, venvContents.packages, log); if (needsUpdate) { - InstalledPackages.fromVenv(venvDirectory).freeze(log); + List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); + if (missingRequirementsFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingRequirementsWarning")) { + if (installedPackages.size() != newPackages.size()) { + warning(String.format(missingRequirementsFileWarning) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); + } + } return true; } return false; From a39edca8f7b6f992f63df124d2a8f4d73889cfaf Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 29 Jan 2025 21:56:12 +0100 Subject: [PATCH 055/512] added VFSUtils.freezePackages --- .../embedding/test/EmbeddingTestUtils.java | 15 ++++---- .../embedding/vfs/test/VFSUtilsTest.java | 35 ++++++++++++------- .../plugin/FreezeInstalledPackagesMojo.java | 12 ++----- .../python/embedding/tools/vfs/VFSUtils.java | 26 ++++++++++---- 4 files changed, 54 insertions(+), 34 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index adce95adee..808d766cb7 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -68,12 +68,7 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog try { log.info("<<< creating test venv <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); - Path launcherFile = venvDir.getParent().resolve(VFSUtils.LAUNCHER_NAME); - Launcher launcher = new Launcher(launcherFile) { - public Set computeClassPath() { - return getClasspath(); - }; - }; + Launcher launcher = createLauncher(venvDir); if (requirements != null) { VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, iconsistentPackagesError, wrongPackageVersionError, missingRequirementsFileWarning, launcher, graalPyVersion, log); } else { @@ -87,6 +82,14 @@ public Set computeClassPath() { } } + public static Launcher createLauncher(Path venvDir) { + return new Launcher(venvDir.getParent().resolve(VFSUtils.LAUNCHER_NAME)) { + public Set computeClassPath() { + return getClasspath(); + }; + }; + } + public static void deleteDirOnShutdown(Path tmpdir) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 20fc0ba4c9..d1deda87de 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -57,6 +57,7 @@ import java.util.Collections; import java.util.List; +import static org.graalvm.python.embedding.test.EmbeddingTestUtils.createLauncher; import static org.graalvm.python.embedding.test.EmbeddingTestUtils.delete; import static org.graalvm.python.embedding.test.EmbeddingTestUtils.deleteDirOnShutdown; import static org.junit.Assert.assertEquals; @@ -357,11 +358,15 @@ public void onlyRequirementsFile() throws IOException { // check that freeze rewrites an existing requirements file writeRequirementsFile(requirements); // no packages - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); - checkRequirementsFile(requirements, "hello-world", "tiny-tiny==0.1"); + freeze(venvDir, requirements, log, "hello-world==0.1", "tiny-tiny==0.1"); + checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.1"); log.clearOutput(); } + private static void freeze(Path venvDir, Path requirements, TestLog log, String... packages) throws IOException { + VFSUtils.freezePackages(venvDir, Arrays.asList(packages), requirements, REQUIREMENTS_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); + } + private void writeRequirementsFile(Path requirements, String... packages) throws IOException { List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); lines.addAll(Arrays.asList(packages)); @@ -389,7 +394,7 @@ public void missingRequirementsWarning() throws IOException { log.clearOutput(); // freeze requirements - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + freeze(venvDir, requirements, log, "requests==2.32.3"); checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); @@ -415,17 +420,23 @@ public void installAndFreeze() throws IOException { Path requirements = tmpDir.resolve("requirements.txt"); // install package from plugin config - createVenv(venvDir, "0.1", log, requirements, "hello-world"); + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + // freeze requirements - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); - checkRequirementsFile(requirements, "hello-world"); + checkException(IOException.class, () -> freeze(venvDir, requirements, log, "hello-world")); + assertFalse(Files.exists(requirements)); + assertFalse(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "hello-world"))); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + freeze(venvDir, requirements, log, "hello-world==0.2"); + checkRequirementsFile(requirements, "hello-world==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // reinstall without exact version declared - fails @@ -433,8 +444,8 @@ public void installAndFreeze() throws IOException { checkVenvCreate(log.getOutput(), false); assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); assertFalse(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); @@ -448,7 +459,7 @@ public void installAndFreeze() throws IOException { assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + freeze(venvDir, requirements, log, "hello-world==0.1"); checkRequirementsFile(requirements, "hello-world==0.1"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); @@ -473,7 +484,7 @@ public void installAndFreeze() throws IOException { checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); // freeze requirements - hello-world, tiny-tiny - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + freeze(venvDir, requirements, log, "hello-world==0.1", "tiny-tiny==0.2"); checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); @@ -507,7 +518,7 @@ public void installAndFreeze() throws IOException { assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements with new hello-world - VFSUtils.createRequirementsFile(venvDir, requirements, REQUIREMENTS_HEADER, log); + freeze(venvDir, requirements, log, "hello-world==0.2", "tiny-tiny==0.2"); checkRequirementsFile(requirements, "hello-world==0.2", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java index b4b85155db..c33159a14e 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java @@ -45,6 +45,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; import java.io.IOException; @@ -73,16 +74,7 @@ protected void manageVenv() throws MojoExecutionException { Path requirements = getRequirementsFile(); try { - VFSUtils.checkVersionFormat(packages, WRONG_PACKAGE_VERSION_FORMAT_ERROR, log); - - VFSUtils.createVenv(venvDirectory, packages, createLauncher(), getGraalPyVersion(project), log); - - if(Files.exists(venvDirectory)) { - VFSUtils.createRequirementsFile(venvDirectory, requirements, REQUIREMENTS_FILE_HEADER, log); - } else { - // how comes? - log.warning("did not generate new python requirements file due to missing venv"); - } + VFSUtils.freezePackages(venvDirectory, packages, requirements, REQUIREMENTS_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 93a66185c1..0e847fd463 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -293,14 +293,14 @@ public static void createVenv(Path venvDirectory, List packagesArgs, Lau public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, String inconsistentPackagesError, String wrongPackageVersionFormatError, String missingRequirementsFileWarning, - Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { + Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); - Objects.requireNonNull(launcherArgs); + Objects.requireNonNull(launcher); Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); - logVenvArgs(venvDirectory, packages, requirementsFile, launcherArgs, graalPyVersion, log); + logVenvArgs(venvDirectory, packages, requirementsFile, launcher, graalPyVersion, log); List pluginPackages = trim(packages); List requirementsPackages = requirementsFile != null && Files.exists(requirementsFile) ? readPackagesFromFile(requirementsFile) : null; @@ -308,7 +308,7 @@ public static void createVenv(Path venvDirectory, List packages, Path re return; } - VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcherArgs, log)); + VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcher, log)); boolean installed = requirementsPackages != null ? install(venvDirectory, requirementsFile, requirementsPackages, log) : install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); @@ -317,6 +317,20 @@ public static void createVenv(Path venvDirectory, List packages, Path re } } + public static void freezePackages(Path venvDirectory, List packages, Path requirementsFile, String requirementsHeader, String wrongPackageVersionFormatError, Launcher launcher, + String graalPyVersion, BuildToolLog log) throws IOException { + checkVersionFormat(packages, wrongPackageVersionFormatError, log); + + createVenv(venvDirectory, packages, launcher, graalPyVersion, log); + + if (Files.exists(venvDirectory)) { + VFSUtils.createRequirementsFile(venvDirectory, requirementsFile, requirementsHeader, log); + } else { + // how comes? + log.warning("did not generate new python requirements file due to missing venv"); + } + } + private static void logVenvArgs(Path venvDirectory, List packages, Path requirementsFile, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { if (log.isDebugEnabled()) { @@ -403,7 +417,7 @@ private static boolean install(Path venvDirectory, Path requirementsFile, List newPackages, Ven return false; } - public static void createRequirementsFile(Path venvDirectory, Path requirementsFile, String requirementsFileHeader, BuildToolLog log) throws IOException { + private static void createRequirementsFile(Path venvDirectory, Path requirementsFile, String requirementsFileHeader, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(requirementsFile); Objects.requireNonNull(requirementsFileHeader); From e336defb42dee6e7b859ff53ad8a6dc50a70b930 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 30 Jan 2025 14:23:58 +0100 Subject: [PATCH 056/512] improved logging in VFSTestUtils --- .../cext/test/MultiContextCExtTest.java | 50 +++++++- .../embedding/test/EmbeddingTestUtils.java | 12 +- .../test/VirtualFileSystemUtilsTest.java | 4 - .../embedding/vfs/test/VFSUtilsTest.java | 54 ++++++-- .../python/maven/plugin/MavenDelegateLog.java | 25 +++- .../embedding/tools/exec/BuildToolLog.java | 93 ++++++++++---- .../embedding/tools/exec/GraalPyRunner.java | 37 +++++- .../python/embedding/tools/vfs/VFSUtils.java | 121 +++++++++++------- .../java/org/graalvm/python/GradleLogger.java | 42 +++++- .../python/jbang/JBangIntegration.java | 44 ++++++- 10 files changed, 377 insertions(+), 105 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java index d9472b3652..6bfcc08be6 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java @@ -70,6 +70,8 @@ static final class TestLog extends Handler implements BuildToolLog { final StringBuilder stderr = new StringBuilder(); final StringBuilder stdout = new StringBuilder(); final StringBuilder info = new StringBuilder(); + final StringBuilder warn = new StringBuilder(); + final StringBuilder debug = new StringBuilder(); final StringBuilder truffleLog = new StringBuilder(); static void println(CharSequence... args) { @@ -78,27 +80,69 @@ static void println(CharSequence... args) { } } - public void warning(CharSequence txt, Throwable t) { + @Override + public void warning(String txt, Throwable t) { println("[warning]", txt); println("[throwable]", t.getMessage()); logThrowable.append(txt).append(t.getMessage()); } - public void subProcessErr(CharSequence err) { + @Override + public void error(String s) { + println("[err]", s); + stderr.append(s); + } + + @Override + public void debug(String s) { + println("[debug]", s); + debug.append(s); + } + + @Override + public void subProcessErr(String err) { println("[err]", err); stderr.append(err); } - public void subProcessOut(CharSequence out) { + @Override + public void subProcessOut(String out) { println("[out]", out); stdout.append(out); } + @Override public void info(String s) { println("[info]", s); info.append(s); } + @Override + public void warning(String s) { + println("[warning]", s); + warn.append(s); + } + + @Override + public boolean isDebugEnabled() { + return true; + } + + @Override + public boolean isWarningEnabled() { + return true; + } + + @Override + public boolean isInfoEnabled() { + return true; + } + + @Override + public boolean isErrorEnabled() { + return true; + } + @Override public void publish(LogRecord record) { var msg = String.format("[%s] %s: %s", record.getLoggerName(), record.getLevel().getName(), String.format(record.getMessage(), record.getParameters())); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index 808d766cb7..1d4c431301 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -66,7 +66,7 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog String missingRequirementsFileWarning, String... packages) throws IOException { try { - log.info("<<< creating test venv <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); + info(log, "<<<<<< create test venv %s <<<<<<", venvDir); Launcher launcher = createLauncher(venvDir); if (requirements != null) { @@ -78,7 +78,13 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog System.err.println(getClasspath()); throw e; } finally { - log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + info(log, ">>>>>> create test venv %s >>>>>>", venvDir); + } + } + + private static void info(BuildToolLog log, String txt, Object... args) { + if (log.isInfoEnabled()) { + log.info(String.format(txt, args)); } } @@ -86,7 +92,7 @@ public static Launcher createLauncher(Path venvDir) { return new Launcher(venvDir.getParent().resolve(VFSUtils.LAUNCHER_NAME)) { public Set computeClassPath() { return getClasspath(); - }; + } }; } diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java index 26413f70a1..3c73392695 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/VirtualFileSystemUtilsTest.java @@ -81,14 +81,10 @@ import java.util.stream.Stream; import static com.oracle.graal.python.test.integration.Utils.IS_WINDOWS; -import static org.graalvm.python.embedding.utils.VirtualFileSystem.HostIO.NONE; -import static org.graalvm.python.embedding.utils.VirtualFileSystem.HostIO.READ; -import static org.graalvm.python.embedding.utils.VirtualFileSystem.HostIO.READ_WRITE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; /** * Simple copy of VirtualFileSystemTest to test also the deprecated diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index d1deda87de..71a58ac697 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -83,45 +83,76 @@ private void clearOutput() { output.delete(0, output.length()); } - public void subProcessOut(CharSequence s) { - System.out.println(s); + public void subProcessOut(String s) { + println("[subout] ", s); addLine(s.toString()); } - public void subProcessErr(CharSequence s) { - System.err.println(s); + public void subProcessErr(String s) { + println("[suberr] ", s); addLine(s.toString()); } public void info(String s) { - System.out.println(s); + println("[info] ", s); addLine(s); - }; + } public void warning(String s) { - System.out.println(s); + println("[warn] ", s); addLine(s); } public void warning(String s, Throwable t) { - System.out.println(s); + println("[warn] ", s); t.printStackTrace(); addLine(s); } public void error(String s) { - System.err.println(s); + println("[err] ", s); addLine(s); } @Override - public boolean isDebugEnabled() { + public void debug(String s) { + println("[debug] ", s); + addLine(s); + } + + @Override + public boolean isWarningEnabled() { + return true; + } + + @Override + public boolean isInfoEnabled() { + return true; + } + + @Override + public boolean isErrorEnabled() { return true; } + @Override + public boolean isDebugEnabled() { + return isVerbose(); + } + public String getOutput() { return output.toString(); } + + static void println(String... args) { + if (isVerbose()) { + System.out.println(String.join(" ", args)); + } + } + + private static boolean isVerbose() { + return Boolean.getBoolean("com.oracle.graal.python.test.verbose"); + } } /** @@ -262,7 +293,6 @@ public void emptyRequirements() throws IOException { TestLog log = new TestLog(); Path tmpDir = Files.createTempDirectory("VFSUtilsTest_emptyRequirements"); Path venvDir = tmpDir.resolve("venv"); - Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); Path requirements = tmpDir.resolve("requirements.txt"); @@ -367,7 +397,7 @@ private static void freeze(Path venvDir, Path requirements, TestLog log, String. VFSUtils.freezePackages(venvDir, Arrays.asList(packages), requirements, REQUIREMENTS_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); } - private void writeRequirementsFile(Path requirements, String... packages) throws IOException { + private static void writeRequirementsFile(Path requirements, String... packages) throws IOException { List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); lines.addAll(Arrays.asList(packages)); Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java index 2f09c511d5..dac3e20f3c 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/MavenDelegateLog.java @@ -50,27 +50,48 @@ final class MavenDelegateLog implements BuildToolLog { this.delegate = delegate; } + @Override public void info(String txt) { delegate.info(txt); } + @Override public void warning(String txt) { delegate.warn(txt); } + @Override public void warning(String txt, Throwable t) { delegate.warn(txt, t); } + @Override public void error(String txt) { delegate.error(txt); } + @Override + public void debug(String txt) { + delegate.debug(txt); + } + + @Override public boolean isDebugEnabled() { return delegate.isDebugEnabled(); } - public void debug(String txt) { - delegate.debug(txt); + @Override + public boolean isWarningEnabled() { + return delegate.isWarnEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return delegate.isErrorEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return delegate.isInfoEnabled(); } } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java index 6edc062f55..1fdf4268ec 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java @@ -45,54 +45,97 @@ import java.util.List; public interface BuildToolLog { - default void subProcessOut(CharSequence out) { + default void subProcessOut(String out) { System.out.println(out); } - default void subProcessErr(CharSequence err) { + default void subProcessErr(String err) { System.err.println(err); } - default void info(String s) { - System.out.println(s); - }; + void info(String s); - default void warning(String s) { - System.out.println(s); - } + void warning(String s); - default void warning(String s, Throwable t) { - System.out.println(s); - t.printStackTrace(); - } + void warning(String s, Throwable t); - default void error(String s) { - System.err.println(s); - } + void error(String s); - default public boolean isDebugEnabled() { - return false; - } + void debug(String s); - default void debug(String s) { - System.out.println(s); - } + boolean isWarningEnabled(); + + boolean isInfoEnabled(); + + boolean isErrorEnabled(); + + boolean isDebugEnabled(); final class CollectOutputLog implements BuildToolLog { private final List output = new ArrayList<>(); + private final BuildToolLog delegate; + + public CollectOutputLog(BuildToolLog delegate) { + this.delegate = delegate; + } public List getOutput() { return output; } @Override - public void subProcessOut(CharSequence var1) { - output.add(var1.toString()); + public boolean isDebugEnabled() { + return delegate.isDebugEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return delegate.isInfoEnabled(); + } + + @Override + public void info(String s) { + delegate.info(s); + } + + @Override + public void warning(String s) { + delegate.warning(s); + } + + @Override + public void warning(String s, Throwable t) { + delegate.warning(s, t); + } + + @Override + public void error(String s) { + delegate.error(s); + } + + @Override + public void debug(String s) { + delegate.debug(s); + } + + @Override + public boolean isWarningEnabled() { + return delegate.isWarningEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return delegate.isErrorEnabled(); + } + + @Override + public void subProcessOut(String s) { + output.add(s); } @Override - public void subProcessErr(CharSequence var1) { - System.err.println(var1); + public void subProcessErr(String s) { + delegate.error(s); } } } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java index 1d1a275e2c..951394f34d 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java @@ -77,7 +77,7 @@ public static void run(String classpath, BuildToolLog log, String... args) throw if (workdir != null) { pb.directory(new File(workdir)); } - log.info(String.format("Running GraalPy: %s", String.join(" ", cmd))); + infoCmd(log, "Running GraalPy:", cmd); runProcess(pb, log); } @@ -85,7 +85,7 @@ public static void runLauncher(String launcherPath, BuildToolLog log, String... var cmd = new ArrayList(); cmd.add(launcherPath); cmd.addAll(List.of(args)); - log.info(String.format("Running: %s", String.join(" ", cmd))); + infoCmd(log, "Running:", cmd); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } @@ -109,7 +109,7 @@ private static void runVenvBin(Path venvDirectory, String command, BuildToolLog var cmd = new ArrayList(); cmd.add(venvDirectory.resolve(BIN_DIR).resolve(command + EXE_SUFFIX).toString()); cmd.addAll(args); - log.info("Executing: " + String.join(" ", cmd)); + infoCmd(log, "Executing:", cmd); var pb = new ProcessBuilder(cmd); runProcess(pb, log); } @@ -147,12 +147,12 @@ private static void runProcess(ProcessBuilder pb, BuildToolLog log) throws IOExc try (InputStream is = process.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { String line; while ((line = reader.readLine()) != null) { - log.subProcessOut(line); + subProcessOut(log, line); } } catch (IOException e) { // Do nothing for now. Probably is not good idea to stop the // execution at this moment - log.warning("exception while reading subprocess out", e); + warn(log, "exception while reading subprocess out", e); } }); outputReader.start(); @@ -162,12 +162,12 @@ private static void runProcess(ProcessBuilder pb, BuildToolLog log) throws IOExc BufferedReader errorBufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); String line; while ((line = errorBufferedReader.readLine()) != null) { - log.subProcessErr(line); + subProcessErr(log, line); } } catch (IOException e) { // Do nothing for now. Probably is not good idea to stop the // execution at this moment - log.warning("exception while reading subprocess err", e); + warn(log, "exception while reading subprocess err", e); } }); errorReader.start(); @@ -181,4 +181,27 @@ private static void runProcess(ProcessBuilder pb, BuildToolLog log) throws IOExc } } + private static void warn(BuildToolLog log, String txt, Throwable t) { + if (log.isWarningEnabled()) { + log.warning(txt, t); + } + } + + private static void infoCmd(BuildToolLog log, String msg, List cmd) { + if (log.isInfoEnabled()) { + log.info(String.format("%s %s", msg, String.join(" ", cmd))); + } + } + + private static void subProcessOut(BuildToolLog log, String txt) { + if (log.isInfoEnabled()) { + log.subProcessOut(txt); + } + } + + private static void subProcessErr(BuildToolLog log, String txt) { + if (log.isErrorEnabled()) { + log.subProcessErr(txt); + } + } } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 0e847fd463..329fa34c3e 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -214,7 +214,7 @@ private static class InstalledPackages { private InstalledPackages(Path venvDirectory, Path installedFile, List packages) { this.venvDirectory = venvDirectory; - this.installedFile = venvDirectory.resolve("installed.txt"); + this.installedFile = installedFile; this.packages = packages; } @@ -225,7 +225,7 @@ static InstalledPackages fromVenv(Path venvDirectory) throws IOException { } List freeze(BuildToolLog log) throws IOException { - CollectOutputLog collectOutputLog = new CollectOutputLog(); + CollectOutputLog collectOutputLog = new CollectOutputLog(log); runPip(venvDirectory, "freeze", collectOutputLog, "--local"); packages = new ArrayList<>(collectOutputLog.getOutput()); @@ -234,12 +234,8 @@ List freeze(BuildToolLog log) throws IOException { String.join("\n", packages); Files.write(installedFile, toWrite.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - if (log.isDebugEnabled()) { - log.debug("VFSUtils.createVenv installed python packages:"); - for (String p : packages) { - log.debug(" " + p); - } - } + logDebug(log, packages, "VFSUtils.createVenv installed python packages:"); + return packages; } } @@ -327,13 +323,14 @@ public static void freezePackages(Path venvDirectory, List packages, Pat VFSUtils.createRequirementsFile(venvDirectory, requirementsFile, requirementsHeader, log); } else { // how comes? - log.warning("did not generate new python requirements file due to missing venv"); + warning(log, "did not generate new python requirements file due to missing venv"); } } private static void logVenvArgs(Path venvDirectory, List packages, Path requirementsFile, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { if (log.isDebugEnabled()) { + // avoid computing classpath if not necessary Set lcp = launcherArgs.computeClassPath(); log.debug("VFSUtils.createVenv():"); log.debug(" graalPyVersion: " + graalPyVersion); @@ -360,10 +357,10 @@ private static boolean checkPackages(Path venvDirectory, List pluginPack private static boolean needVenv(Path venvDirectory, List packages, BuildToolLog log) throws IOException { if ((packages.isEmpty())) { if (Files.exists(venvDirectory)) { - log.info(String.format("No packages to install, deleting venv")); + info(log, "No packages to install, deleting venv"); delete(venvDirectory); } else { - log.debug("VFSUtils.createVenv: skipping - no package or requirements file provided"); + debug(log, "VFSUtils.createVenv: skipping - no package or requirements file provided"); } return false; } @@ -372,9 +369,9 @@ private static boolean needVenv(Path venvDirectory, List packages, Build private static void logPackages(List packages, Path requirementsFile, BuildToolLog log) { if (requirementsFile != null) { - log.info(String.format("Installing %s python packages from requirements file: %s", packages.size(), requirementsFile)); + info(log, "Installing %s python packages from requirements file: %s", packages.size(), requirementsFile); } else { - log.info(String.format("Installing %s python packages from GraalPy plugin configuration", packages.size())); + info(log, "Installing %s python packages from GraalPy plugin configuration", packages.size()); } } @@ -388,17 +385,17 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion checkVenvLauncher(venvDirectory, launcherPath, log); contents = VenvContents.fromVenv(venvDirectory); if (contents == null) { - log.warning(String.format("Reinstalling GraalPy venv due to corrupt contents file")); + warning(log, "Reinstalling GraalPy venv due to corrupt contents file"); delete(venvDirectory); } else if (!graalPyVersion.equals(contents.graalPyVersion)) { contents = null; - log.info(String.format("Stale GraalPy venv, updating to %s", graalPyVersion)); + info(log, "Stale GraalPy venv, updating to %s", graalPyVersion); delete(venvDirectory); } } if (!Files.exists(venvDirectory)) { - log.info(String.format("Creating GraalPy %s venv", graalPyVersion)); + info(log, "Creating GraalPy %s venv", graalPyVersion); runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } @@ -417,7 +414,7 @@ private static boolean install(Path venvDirectory, Path requirementsFile, List newPackages, Ven List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); if (missingRequirementsFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingRequirementsWarning")) { if (installedPackages.size() != newPackages.size()) { - warning(String.format(missingRequirementsFileWarning) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); + missingRequirementsWarning(log, missingRequirementsFileWarning); } } return true; @@ -438,6 +435,18 @@ private static boolean install(Path venvDirectory, List newPackages, Ven return false; } + private static void missingRequirementsWarning(BuildToolLog log, String missingRequirementsFileWarning) { + if (log.isWarningEnabled()) { + String txt = missingRequirementsFileWarning + "\n" + FOR_MORE_INFO_REFERENCE_MSG; + String prefix = txt.startsWith("WARNING:") ? "WARNING:" : ""; + log.warning(""); + for (String t : txt.split("\n")) { + log.warning(t.startsWith(prefix) ? t : prefix + " " + t); + } + log.warning(""); + } + } + private static void createRequirementsFile(Path venvDirectory, Path requirementsFile, String requirementsFileHeader, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(requirementsFile); @@ -446,19 +455,14 @@ private static void createRequirementsFile(Path venvDirectory, Path requirements assert Files.exists(venvDirectory); - log.info(String.format("Creating %s", requirementsFile)); + info(log, "Creating %s", requirementsFile); InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); List header = getHeaderList(requirementsFileHeader); Files.write(requirementsFile, header, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); Files.write(requirementsFile, installedPackages.packages, StandardOpenOption.APPEND); - if (log.isDebugEnabled()) { - log.debug("VFSUtils created requirements file: " + requirementsFile); - for (String p : installedPackages.packages) { - log.debug(" " + p); - } - } + logDebug(log, installedPackages.packages, "VFSUtils created requirements file: %s", installedPackages.installedFile); } private static List getHeaderList(String requirementsFileHeader) { @@ -482,7 +486,7 @@ public static void checkVersionFormat(List packages, String wrongPackage } } if (!sb.isEmpty()) { - wrongPackageVersionError(sb.toString(), wrongPackageVersionFormatError, log); + wrongPackageVersionError(log, wrongPackageVersionFormatError, sb.toString()); } } @@ -499,8 +503,10 @@ private static boolean checkValidPackageVersion(String pkg) throws IOException { return true; } - private static void wrongPackageVersionError(String pkgs, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { - error(String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); + private static void wrongPackageVersionError(BuildToolLog log, String wrongPackageVersionFormatError, String pkgs) throws IOException { + if (log.isErrorEnabled()) { + extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); + } throw new IOException("invalid package format: " + pkgs); } @@ -526,9 +532,15 @@ private static void checkPackagesConsistent(List packages, List } if (!sb.isEmpty()) { - error(String.format(inconsistentPackagesError, sb) + "\n" + FOR_MORE_INFO_REFERENCE_MSG, log); - throw new IOException("inconsistent packages"); + inconsistentPackagesError(log, inconsistentPackagesError, sb.toString()); + } + } + + private static void inconsistentPackagesError(BuildToolLog log, String inconsistentPackagesError, String packages) throws IOException { + if (log.isErrorEnabled()) { + extendedError(log, String.format(inconsistentPackagesError, packages) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); } + throw new IOException("inconsistent packages"); } private static void checkVenvLauncher(Path venvDirectory, Path launcherPath, BuildToolLog log) throws IOException { @@ -547,7 +559,7 @@ private static void checkVenvLauncher(Path venvDirectory, Path launcherPath, Bui if (l.trim().equals("executable")) { Path cfgLauncherPath = Path.of(r); if (!Files.exists(cfgLauncherPath) || !Files.isSameFile(launcherPath, cfgLauncherPath)) { - log.info(String.format("Deleting GraalPy venv due to changed launcher path")); + info(log, "Deleting GraalPy venv due to changed launcher path"); delete(venvDirectory); } break; @@ -559,7 +571,7 @@ private static void checkVenvLauncher(Path venvDirectory, Path launcherPath, Bui throw new IOException(String.format("failed to read config file %s", cfg), e); } } else { - log.info(String.format("Missing venv config file: '%s'", cfg)); + info(log, "Missing venv config file: '%s'", cfg); } } @@ -575,7 +587,7 @@ private static Path ensureLauncher(Launcher launcherArgs, BuildToolLog log) thro private static void generateLaunchers(Launcher launcherArgs, BuildToolLog log) throws IOException { if (!Files.exists(launcherArgs.launcherPath)) { - log.info("Generating GraalPy launchers"); + info(log, "Generating GraalPy launchers"); createParentDirectories(launcherArgs.launcherPath); Path java = Paths.get(System.getProperty("java.home"), "bin", "java"); String classpath = String.join(File.pathSeparator, launcherArgs.computeClassPath()); @@ -693,20 +705,41 @@ public static List trim(List l) { return l; } - private static void warning(String txt, BuildToolLog log) { - String prefix = txt.startsWith("WARNING:") ? "WARNING:" : ""; - log.warning(""); - for (String t : txt.split("\n")) { - log.warning(t.startsWith(prefix) ? t : prefix + " " + t); + private static void warning(BuildToolLog log, String txt) { + if (log.isWarningEnabled()) { + log.warning(txt); } - log.warning(""); } - private static void error(String txt, BuildToolLog log) { - log.error(""); - for (String t : txt.split("\n")) { - log.error(t); + private static void extendedError(BuildToolLog log, String txt) { + if (log.isErrorEnabled()) { + log.error(""); + for (String t : txt.split("\n")) { + log.error(t); + } + log.error(""); + } + } + + private static void info(BuildToolLog log, String txt, Object... args) { + if (log.isInfoEnabled()) { + log.info(String.format(txt, args)); + } + } + + private static void debug(BuildToolLog log, String txt) { + if (log.isDebugEnabled()) { + log.debug(txt); } - log.error(""); } + + private static void logDebug(BuildToolLog log, List l, String msg, Object... args) { + if (log.isDebugEnabled()) { + log.debug(String.format(msg, args)); + for (String p : l) { + log.debug(" " + p); + } + } + } + } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java index dd21a8ce8d..d762476044 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GradleLogger.java @@ -43,6 +43,15 @@ import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.gradle.api.logging.Logger; +/** + * XXX how to handle gradle logger finer level granularity? + * ERROR - Error messages + * QUIET - Important information messages + * WARNING - Warning messages + * LIFECYCLE - Progress information messages + * INFO - Information messages + * DEBUG - Debug messages + */ public class GradleLogger implements BuildToolLog { private Logger logger; @@ -51,18 +60,18 @@ private GradleLogger(Logger logger) { } @Override - public void subProcessOut(CharSequence out) { - logger.lifecycle(out.toString()); + public void subProcessOut(String out) { + logger.info(out.toString()); } @Override - public void subProcessErr(CharSequence err) { + public void subProcessErr(String err) { logger.warn(err.toString()); } @Override public void info(String txt) { - logger.lifecycle(txt.toString()); + logger.info(txt.toString()); } @Override @@ -80,6 +89,31 @@ public void error(String txt) { logger.error(txt); } + @Override + public void debug(String txt) { + logger.debug(txt); + } + + @Override + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + @Override + public boolean isWarningEnabled() { + return logger.isWarnEnabled(); + } + + @Override + public boolean isErrorEnabled() { + return logger.isErrorEnabled(); + } + + @Override + public boolean isInfoEnabled() { + return logger.isInfoEnabled(); + } + public static GradleLogger of(Logger logger) { return new GradleLogger(logger); } diff --git a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java index e5d64c5d15..2897ec4bad 100644 --- a/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java +++ b/graalpython/org.graalvm.python.jbang/src/org/graalvm/python/jbang/JBangIntegration.java @@ -80,6 +80,46 @@ public class JBangIntegration { private static final BuildToolLog BUILD_TOOL_LOG = new BuildToolLog() { private static final boolean debugEnabled = Boolean.getBoolean("org.graalvm.python.jbang.log.debug"); + @Override + public void info(String s) { + System.out.println(s); + } + + @Override + public void warning(String s) { + System.out.println(s); + } + + @Override + public void warning(String s, Throwable t) { + System.out.println(s); + } + + @Override + public void error(String s) { + System.err.println(s); + } + + @Override + public void debug(String s) { + System.out.println(s); + } + + @Override + public boolean isWarningEnabled() { + return true; + } + + @Override + public boolean isInfoEnabled() { + return true; + } + + @Override + public boolean isErrorEnabled() { + return true; + } + @Override public boolean isDebugEnabled() { return debugEnabled; @@ -248,6 +288,8 @@ private static HashSet calculateClasspath(List> } private static void log(String txt) { - BUILD_TOOL_LOG.info("[graalpy jbang integration] " + txt); + if (BUILD_TOOL_LOG.isInfoEnabled()) { + BUILD_TOOL_LOG.info("[graalpy jbang integration] " + txt); + } } } From 61bd3246bde8a6daf8eb09dd6b8828ed93736bc2 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 31 Jan 2025 12:14:28 +0100 Subject: [PATCH 057/512] reworded requirements file header and some warnings from maven plugin --- .../embedding/vfs/test/VFSUtilsTest.java | 2 +- .../src/tests/standalone/test_maven_plugin.py | 22 +++++++------ .../maven/plugin/AbstractGraalPyMojo.java | 21 ++++++------ .../python/embedding/tools/vfs/VFSUtils.java | 32 +++++++++++-------- 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 71a58ac697..b744d187fc 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -701,7 +701,7 @@ private static void checkPackages(Path file, String header, String... packages) } } - lines = lines.stream().filter(line -> !line.trim().startsWith("#")).toList(); + lines = lines.stream().filter(line -> !line.trim().startsWith("#") && !line.trim().isEmpty()).toList(); assertEquals(packages.length, lines.size()); for (String pkg : packages) { boolean found = false; diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index 4f3806ca72..abdd7221c0 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -48,6 +48,10 @@ from tests.standalone import util from tests.standalone.util import TemporaryTestDirectory, Logger +MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-maven-plugin configuration" +WRONG_PACKAGE_VERSION_FORMAT = "Some python package(s) in graalpy-maven-plugin configuration have no exact version declared" +PACKAGES_INCONSISTENT_ERROR = "are either missing or have a different version in python requirements file" + class MavenPluginTest(util.BuildToolTestBase): def generate_app(self, tmpdir, target_dir, target_name, pom_template=None, group_id="archetype.it", package="it.pkg"): @@ -220,15 +224,15 @@ def test_freeze_requirements(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("pip install", out) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("Missing python requirements file", out) + util.check_ouput(MISSING_FILE_WARNING, out) assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) # freeze - fails due to no version cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("Missing python requirements file", out, contains=False) - util.check_ouput("Some python package(s) in graalpy-maven-plugin configuration have no exact version declared", out) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) # freeze with correct version @@ -236,7 +240,7 @@ def test_freeze_requirements(self): cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) - util.check_ouput("Missing python requirements file", out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) # add termcolor and build - fails as it is not part of requirements @@ -244,23 +248,23 @@ def test_freeze_requirements(self): cmd = mvnw_cmd + ["package", "-DrequirementsFile=test-requirements.txt"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("are either missing or have a different version in python requirements file", out) + util.check_ouput(PACKAGES_INCONSISTENT_ERROR, out) assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) # freeze with termcolor cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) - util.check_ouput("Missing python requirements file", out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) # rebuild with requirements and exec cmd = mvnw_cmd + ["package", "exec:java", "-DrequirementsFile=test-requirements.txt", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("pip install", out, False) + util.check_ouput("pip install -r", out) util.check_ouput("hello java", out) - util.check_ouput("Missing python requirements file", out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) # disable packages config in pom util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "") - # should be able to import ujson if installed + # should be able to import requests if installed util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "it", "pkg", "GraalPy.java"), "import hello", "import requests; import hello") # clean and rebuild with requirements and exec - cmd = mvnw_cmd + ["clean", "package", "exec:java", "-DrequirementsFile=test-requirements.txt", "-Dexec.mainClass=it.pkg.GraalPy"] + cmd = mvnw_cmd + ["clean", "package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) util.check_ouput("pip install", out) @@ -451,12 +437,24 @@ def test_empty_packages(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) + cmd = mvnw_cmd + ["-X", "org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) + assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "
    ") cmd = mvnw_cmd + ["process-resources"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) + assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") def test_python_resources_dir_deprecation(self): with util.TemporaryTestDirectory() as tmpdir: From eabcbb6d3923529ad37a323b7c0aa592768e3bd4 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 31 Jan 2025 22:46:59 +0100 Subject: [PATCH 060/512] added support for requirement file to gradle plugin --- .../tests/standalone/test_gradle_plugin.py | 131 +++++++++++ .../src/tests/standalone/util.py | 2 +- .../graalvm/python/GraalPyGradlePlugin.java | 44 +++- .../graalvm/python/dsl/GraalPyExtension.java | 18 +- .../python/tasks/AbstractPackagesTask.java | 211 ++++++++++++++++++ .../tasks/FreezeInstalledPackagesTask.java | 87 ++++++++ .../python/tasks/InstallPackagesTask.java | 112 +--------- 7 files changed, 491 insertions(+), 114 deletions(-) create mode 100644 graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java create mode 100644 graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index 384d01a04e..a321535f10 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -46,6 +46,10 @@ from tests.standalone import util from tests.standalone.util import TemporaryTestDirectory, Logger +MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-gradle-plugin configuration" +WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-gradle-plugin configuration have no exact version declared" +PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-gradle-plugin configuration are either missing or have a different version" + def append(file, txt): with open(file, "a") as f: f.write(txt) @@ -92,6 +96,9 @@ def native_image_with_bogus_include(self): def native_image_with_exlude_email(self): pass + def freeze_requirements_config(self, community, pkgs, requirements): + pass + def generate_app(self, target_dir): shutil.copytree(self.test_prj_path, target_dir) for root, dirs, files in os.walk(target_dir): @@ -181,6 +188,92 @@ def check_gradle_generated_app(self, community): util.check_ouput("hello java", out, logger=log) self.check_filelist(target_dir2, log) + @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") + def check_freeze_requirements(self, community): + with util.TemporaryTestDirectory() as tmpdir: + + target_dir = os.path.join(str(tmpdir), "freeze_requirements" + self.target_dir_name_sufix()) + self.generate_app(target_dir) + build_file = os.path.join(target_dir, self.build_file_name) + + gradlew_cmd = util.get_gradle_wrapper(target_dir, self.env) + + # start with requests package without version + append(build_file, self.freeze_requirements_config(pkgs=["requests"], requirements="test-requirements.txt", community=True)) + + # build + cmd = gradlew_cmd + ["build"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("pip install", out) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze - fails due to no version + cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) + assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze with correct version + log = Logger() + self.copy_build_files(target_dir) + append(build_file, self.freeze_requirements_config(pkgs=["requests==2.32.3"], requirements="test-requirements.txt", community=True)) + cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=True) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # add termcolor and build - fails as it is not part of requirements + log = Logger() + self.copy_build_files(target_dir) + append(build_file, self.freeze_requirements_config(pkgs=["requests==2.32.3", "termcolor==2.2"], requirements="test-requirements.txt", community=True)) + cmd = gradlew_cmd + ["build"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput(PACKAGES_INCONSISTENT_ERROR, out) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # freeze with termcolor + log = Logger() + cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=True) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + + # rebuild with requirements and exec + cmd = gradlew_cmd + ["build", "run"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("Python packages up to date, skipping install", out) + util.check_ouput("hello java", out) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + + # run with no packages, only requirements file + self.copy_build_files(target_dir) + append(build_file, self.empty_packages()) + + # stop using requirementsFile field and test with default value {project_root}/requirements.txt + shutil.move(os.path.join(target_dir, "test-requirements.txt"), os.path.join(target_dir, "requirements.txt")) + + # should be able to import requests if installed + util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "org", "example", "GraalPy.java"), + "import hello", + "import requests; import hello") + + # clean and rebuild with requirements and exec + cmd = gradlew_cmd + ["clean", "build", "run"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out) + util.check_ouput("pip install", out) + util.check_ouput("hello java", out) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + def check_gradle_generated_app_external_resources(self): with TemporaryTestDirectory() as tmpdir: target_dir = os.path.join(str(tmpdir), "generated_gradle_app_external_resources" + self.target_dir_name_sufix()) @@ -332,6 +425,12 @@ def check_gradle_empty_packages(self): util.check_ouput("BUILD SUCCESS", out) assert return_code == 0, out + cmd = gradle_cmd + ["graalpyFreezeInstalledPackages"] + out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) + util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("In order to run the graalpyFreezeInstalledPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration.", out) + assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + def check_gradle_python_resources_dir_deprecation(self): with TemporaryTestDirectory() as tmpdir: @@ -474,6 +573,10 @@ def setUpClass(cls): def test_gradle_generated_app(self): self.check_gradle_generated_app(community=True) + @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") + def test_gradle_freeze_requirements(self): + self.check_freeze_requirements(community=True) + @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") def test_gradle_generated_app_external_resources(self): self.check_gradle_generated_app_external_resources() @@ -530,6 +633,17 @@ def packages_termcolor(self, community): }} """) + def freeze_requirements_config(self, community, pkgs, requirements=None): + requirements_file = f"requirementsFile = file(\"{requirements}\")" if requirements else "" + packages = "packages = [\"" + "\",\"".join(pkgs) + "\"]" + return textwrap.dedent(f""" + graalPy {{ + {packages} + {requirements_file} + {_community_as_property(community)} + }} + """) + def packages_termcolor_ujson(self, community): return textwrap.dedent(f""" graalPy {{ @@ -644,6 +758,10 @@ def setUpClass(cls): def test_gradle_generated_app(self): self.check_gradle_generated_app(community=True) + @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") + def test_gradle_freeze_requirements(self): + self.check_freeze_requirements(community=True) + @unittest.skipUnless(util.is_gradle_plugin_long_running_test_enabled, "ENABLE_GRADLE_PLUGIN_LONG_RUNNING_UNITTESTS is not true") def test_gradle_generated_app_external_resources(self): self.check_gradle_generated_app_external_resources() @@ -691,6 +809,19 @@ def copy_build_files(self, target_dir): def empty_plugin(self, community): return f"graalPy {{ {_community_as_property(community) } }}" + def freeze_requirements_config(self, community, pkgs, requirements=None): + requirements_file = f"requirementsFile = file(\"{requirements}\")" if requirements else "" + packages = "" + for p in pkgs: + packages += f" packages.add(\"{p}\")\n" + return textwrap.dedent(f""" + graalPy {{ + {packages} + {requirements_file} + {_community_as_property(community)} + }} + """) + def packages_termcolor(self, community): return textwrap.dedent(f""" graalPy {{ diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py index f652a66bb6..33a77dc7cd 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py @@ -232,7 +232,7 @@ def get_gradle_wrapper(project_dir, env): cmd = gradle_cmd + ["--version"] out, return_code = run_cmd(cmd, env, cwd=project_dir) check_ouput(GRADLE_VERSION, out) - return gradle_cmd + return gradle_cmd + ["-i"] def get_gp(): if "PYTHON_STANDALONE_HOME" not in os.environ: diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index a528edf000..36acf2cee4 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -41,6 +41,8 @@ package org.graalvm.python; import org.graalvm.python.dsl.GraalPyExtension; +import org.graalvm.python.tasks.AbstractPackagesTask; +import org.graalvm.python.tasks.FreezeInstalledPackagesTask; import org.graalvm.python.tasks.MetaInfTask; import org.graalvm.python.tasks.InstallPackagesTask; import org.graalvm.python.tasks.VFSFilesListTask; @@ -51,6 +53,9 @@ import org.gradle.api.artifacts.ConfigurationContainer; import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ExternalModuleDependency; +import org.gradle.api.file.Directory; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.file.ProjectLayout; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.provider.Provider; @@ -85,8 +90,10 @@ public abstract class GraalPyGradlePlugin implements Plugin { private static final String DEFAULT_FILESLIST_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "fileslist"; private static final String GRAALPY_META_INF_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "META-INF"; private static final String GRAALPY_INSTALL_PACKAGES_TASK = "graalPyInstallPackages"; + private static final String GRAALPY_FREEZE_DEPENDENCIES_TASK = "graalPyFreezeInstalledPackages"; private static final String GRAALPY_META_INF_TASK_TASK = "graalPyMetaInf"; private static final String GRAALPY_VFS_FILESLIST_TASK = "graalPyVFSFilesList"; + private static final String PYTHON_REQUIREMENTS_FILE = "requirements.txt"; GraalPyExtension extension; Project project; @@ -105,9 +112,12 @@ public void apply(Project project) { TaskProvider installPackagesTask = registerInstallPackagesTask(project, launcherClasspath, extension); registerMetaInfTask(extension); - var vfsFilesListTask = registerCreateVfsFilesListTask(installPackagesTask, javaPluginExtension, extension); + TaskProvider vfsFilesListTask = registerCreateVfsFilesListTask(installPackagesTask, javaPluginExtension, extension); var mainSourceSet = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); mainSourceSet.getResources().srcDir(installPackagesTask); + + registerFreezeInstalledPackagesTask(project, launcherClasspath, extension); + addDependencies(); project.afterEvaluate(proj -> { @@ -194,18 +204,36 @@ private TaskProvider registerInstallPackagesTask(Project pr "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + "For more details, please refer to the documentation of GraalVM Native Image options IncludeLanguageResources and CopyLanguageResources."); } + registerPackagesTask(project, launcherClasspath, extension, t); + }); + } + + private TaskProvider registerFreezeInstalledPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) { + return project.getTasks().register(GRAALPY_FREEZE_DEPENDENCIES_TASK, FreezeInstalledPackagesTask.class, t -> { + registerPackagesTask(project, launcherClasspath, extension, t); + // TODO probably not necessary + // t.getOutputs().upToDateWhen(tt -> false); + }); + } + + private void registerPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension, AbstractPackagesTask t) { + ProjectLayout layout = project.getLayout(); + DirectoryProperty buildDirectory = layout.getBuildDirectory(); + Directory projectDirectory = layout.getProjectDirectory(); + + t.getLauncherClasspath().from(launcherClasspath); + t.getLauncherDirectory().convention(buildDirectory.dir("python-launcher")); + t.getPolyglotVersion().convention(extension.getPolyglotVersion().orElse(determineGraalPyDefaultVersion())); t.getPackages().set(extension.getPackages()); - t.getOutput().convention( - extension.getExternalDirectory().orElse( - extension.getPythonResourcesDirectory() - .orElse(project.getLayout().getBuildDirectory().dir(DEFAULT_RESOURCES_DIRECTORY)))); - t.getIncludeVfsRoot().convention(extension.getExternalDirectory().map(d -> false) - .orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true))); + DirectoryProperty externalDirectory = extension.getExternalDirectory(); + t.getOutput().convention(externalDirectory.orElse(extension.getPythonResourcesDirectory().orElse(buildDirectory.dir(DEFAULT_RESOURCES_DIRECTORY)))); + t.getIncludeVfsRoot().convention(externalDirectory.map(d -> false).orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true))); t.getResourceDirectory().set(extension.getResourceDirectory()); + t.getRequirementsFile().convention(extension.getRequirementsFile().orElse(projectDirectory.file(PYTHON_REQUIREMENTS_FILE))); + t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP); - }); } private boolean userPythonHome() { diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java index 3b54b2bd71..477e34cc85 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java @@ -43,6 +43,7 @@ import org.gradle.api.Action; import org.gradle.api.Incubating; import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; import org.gradle.api.provider.SetProperty; import org.gradle.api.tasks.Nested; @@ -62,7 +63,7 @@ public interface GraalPyExtension { /** * Optional external directory supposed to be populated with python resources, namely the - * virtual environment in the "venv" subdirectory. Existing files and directories other + * virtual environment in the "venv" subdirectory. Existing files and directories other * than the "venv" subdirectory will not be touched by the plugin and can be maintained manually. * Mutually exclusive with {@link #getResourceDirectory()}. */ @@ -75,6 +76,16 @@ public interface GraalPyExtension { */ Property getResourceDirectory(); + /** + * A python requirements file. + * + * If present then used as exclusive input when installing python packages + * for GraalPy usage instead of {@link #getPackages()}. + * + * @see #getPackages() + */ + RegularFileProperty getRequirementsFile(); + /** * Experimental property. Allows overriding the default Polyglot and GraalPy version. * This is intended only for testing of new unreleased versions. It is recommended @@ -84,7 +95,10 @@ public interface GraalPyExtension { Property getPolyglotVersion(); /** - * Determines third party python packages to be installed for graalpy usage. + * Determines third party python packages to be installed for GraalPy usage in case + * no python requirements file is provided by {@link #getRequirementsFile()}. + * + * @see #getRequirementsFile() */ SetProperty getPackages(); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java new file mode 100644 index 0000000000..0011887a09 --- /dev/null +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2024, 2025, 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 org.graalvm.python.tasks; + +import org.graalvm.python.GradleLogger; +import org.graalvm.python.dsl.GraalPyExtension; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; +import org.gradle.api.DefaultTask; +import org.gradle.api.file.ConfigurableFileCollection; +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.file.RegularFileProperty; +import org.gradle.api.provider.ListProperty; +import org.gradle.api.provider.Property; +import org.gradle.api.tasks.*; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.nio.file.Path; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.graalvm.python.embedding.tools.vfs.VFSUtils.LAUNCHER_NAME; +import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT; +import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV; + +/** + * This task is responsible installing the dependencies which were requested by the user. + * This is either done in generated resources folder or in external directory provided by the user + * in {@link GraalPyExtension#getExternalDirectory()}. + * + *

    + * In scope of this task: + *

      + *
    1. The GraalPy launcher is set up.
    2. + *
    3. A python venv is created.
    4. + *
    5. Python packages are installed into the venv.
    6. + *
    + * + */ +@CacheableTask +public abstract class AbstractPackagesTask extends DefaultTask { + + protected static final String REQUIREMENTS_FILE_HEADER = """ + This file was generated by gradle task 'graalpyFreezeInstalledPackages'. + + This file contains a list of all required Python packages with their specific versions, + based on the packages defined in the plugin configuration and their dependencies. + + WARNING: Any manual changes are done at your own risk. + + """; + + protected static final String MISSING_REQUIREMENTS_FILE_WARNING = """ + + WARNING: Additional python dependencies were installed besides the packages declared in graalpy-gradle-plugin configuration. + + WARNING: It is highly recommended to freeze python dependencies by running the gradle task 'graalpyFreezeInstalledPackages'. + """; + + protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ + Some python packages in graalpy-gradle-plugin configuration have no exact version declared: %s + + When using the graalpy-gradle-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + """; + + protected static final String INCONSISTENT_PACKAGES_ERROR = """ + Install of python packages is based on requirements file %s, + but some packages in graalpy-gradle-plugin configuration are either missing or have a different version: %s. + + The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + """; + + /** @see #getOutput() */ + @Input + @Optional + public abstract Property getIncludeVfsRoot(); + + @Input + public abstract ListProperty getPackages(); + + @Internal + public abstract DirectoryProperty getLauncherDirectory(); + + @Classpath + public abstract ConfigurableFileCollection getLauncherClasspath(); + + /** + * The directory where the virtual filesystem should be generated. If {@link #getIncludeVfsRoot()} is set, + * then this is the parent directory where the actual VFS directory should be created and populated with + * "venv" subdirectory (this is the case when we generate the VFS to Java resources). Otherwise, this path + * is used as is. + */ + @OutputDirectory + public abstract DirectoryProperty getOutput(); + + /** + * The directory where the VFS should be generated within Java resources, i.e., applied only when + * {@link #getIncludeVfsRoot()} is set. + */ + @Input + @Optional + public abstract Property getResourceDirectory(); + + // XXX String or file or RegularFileProperty? + // XXX cached ? +// @Input + @InputFiles + @Optional + @PathSensitive(PathSensitivity.RELATIVE) +// public abstract Property getRequirementsFile(); + public abstract RegularFileProperty getRequirementsFile(); + + /** + * Desired polyglot runtime and GraalPy version. + */ + @Input + public abstract Property getPolyglotVersion(); + + @Input + protected String getOperatingSystem() { + // XXX what is this? + return System.getProperty("os.name"); + } + + protected Set calculateLauncherClasspath() { + return getLauncherClasspath().getFiles().stream().map(File::getAbsolutePath).collect(Collectors.toUnmodifiableSet()); + } + + protected Launcher createLauncher() { + return new Launcher( getLauncherPath()) { + public Set computeClassPath() { + return calculateLauncherClasspath(); + } + }; + } + + @Internal + protected GradleLogger getLog() { + return GradleLogger.of(getLogger()); + } + + private Path getLauncherPath() { + return computeLauncherDirectory().resolve(LAUNCHER_NAME); + } + + @NotNull + protected Path computeLauncherDirectory() { + return getLauncherDirectory().get().getAsFile().toPath(); + } + + @Internal + protected Path getVenvDirectory() { + // XXX why not convention? + // XXX skip external/resouces dir and set venv dir from task config + String path = ""; + if (getIncludeVfsRoot().getOrElse(true)) { + path = getResourceDirectory().getOrElse(VFS_ROOT); + } + + return Path.of(getOutput().get().getAsFile().toURI()).resolve(path).resolve(VFS_VENV); + } + + @Internal + protected Path getRequirementsPath() { + Path rfp = getRequirementsFile().get().getAsFile().toPath(); + if(rfp.isAbsolute()) { + return rfp; + } else { + return getProject().file(getRequirementsFile().get()).toPath(); + } + } +} diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java new file mode 100644 index 0000000000..9d89ba6ea1 --- /dev/null +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024, 2025, 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 org.graalvm.python.tasks; + +import org.gradle.api.GradleException; +import org.gradle.api.tasks.CacheableTask; +import org.gradle.api.tasks.TaskAction; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; + +import org.graalvm.python.embedding.tools.vfs.VFSUtils; + +/** + * Creates a python requirements file from all user packages installed in the python virtual environment. + * + * If there is no virtual environment preset then it is first created and packages are installed the same way + * as in scope of {@link InstallPackagesTask}. + */ +@CacheableTask +public abstract class FreezeInstalledPackagesTask extends AbstractPackagesTask { + @TaskAction + public void exec() throws GradleException { + checkEmptyPackages(); + + Path venvDirectory = getVenvDirectory(); + try { + VFSUtils.freezePackages(getVenvDirectory(), getPackages().get(), getRequirementsPath(), + REQUIREMENTS_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, + createLauncher(), getPolyglotVersion().get(), getLog()); + } catch (IOException e) { + throw new GradleException(String.format("failed to freeze packages in python virtual environment %s", venvDirectory), e); + } + } + + private void checkEmptyPackages() throws GradleException { + List packages = getPackages().get(); + if((packages == null || packages.isEmpty())) { + getLog().error(""); + getLog().error("In order to run the graalpyFreezeInstalledPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration."); + getLog().error(""); + getLog().error("For more information, please refer to https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md"); + getLog().error(""); + + throw new GradleException("missing python packages in plugin configuration"); + } + } +} diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 12fdb5b6e0..17caae09ea 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -40,37 +40,15 @@ */ package org.graalvm.python.tasks; -import org.graalvm.python.GradleLogger; import org.graalvm.python.dsl.GraalPyExtension; -import org.graalvm.python.embedding.tools.vfs.VFSUtils; -import org.graalvm.python.embedding.tools.vfs.VFSUtils.Launcher; -import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; -import org.gradle.api.file.ConfigurableFileCollection; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.provider.ListProperty; -import org.gradle.api.provider.Property; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.Optional; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.TaskAction; -import org.jetbrains.annotations.NotNull; +import org.gradle.api.tasks.*; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.LAUNCHER_NAME; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT; -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; /** * This task is responsible installing the dependencies which were requested by the user. @@ -87,88 +65,16 @@ * */ @CacheableTask -public abstract class InstallPackagesTask extends DefaultTask { - - /** @see #getOutput() */ - @Input - @Optional - public abstract Property getIncludeVfsRoot(); - - @Input - public abstract ListProperty getPackages(); - - @Internal - public abstract DirectoryProperty getLauncherDirectory(); - - @Classpath - public abstract ConfigurableFileCollection getLauncherClasspath(); - - /** - * The directory where the virtual filesystem should be generated. If {@link #getIncludeVfsRoot()} is set, - * then this is the parent directory where the actual VFS directory should be created and populated with - * "venv" subdirectory (this is the case when we generate the VFS to Java resources). Otherwise, this path - * is used as is. - */ - @OutputDirectory - public abstract DirectoryProperty getOutput(); - - /** - * The directory where the VFS should be generated within Java resources, i.e., applied only when - * {@link #getIncludeVfsRoot()} is set. - */ - @Input - @Optional - public abstract Property getResourceDirectory(); - - /** - * Desired polyglot runtime and GraalPy version. - */ - @Input - public abstract Property getPolyglotVersion(); - - @Input - protected String getOperatingSystem() { - return System.getProperty("os.name"); - } - +public abstract class InstallPackagesTask extends AbstractPackagesTask { @TaskAction - public void exec() throws IOException { - Files.createDirectories(computeLauncherDirectory()); - manageVenv(); - } - - private void manageVenv() { - List packages = getPackages().getOrElse(null); + public void exec() throws GradleException { + Path venvDirectory = getVenvDirectory(); try { - Launcher launcher = new Launcher( getLauncherPath()) { - public Set computeClassPath() { - return calculateLauncherClasspath(); - } - }; - VFSUtils.createVenv(getVenvDirectory(), new ArrayList(packages), launcher, getPolyglotVersion().get(), GradleLogger.of(getLogger())); + VFSUtils.createVenv(venvDirectory, getPackages().get(), getRequirementsPath(), + INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, + createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { - throw new GradleException(String.format("failed to create venv %s", getVenvDirectory()), e); - } - } - - private Set calculateLauncherClasspath() { - return getLauncherClasspath().getFiles().stream().map(File::getAbsolutePath).collect(Collectors.toUnmodifiableSet()); - } - - private Path getLauncherPath() { - return computeLauncherDirectory().resolve(LAUNCHER_NAME); - } - - @NotNull - private Path computeLauncherDirectory() { - return getLauncherDirectory().get().getAsFile().toPath(); - } - - private Path getVenvDirectory() { - String path = ""; - if (getIncludeVfsRoot().getOrElse(true)) { - path = getResourceDirectory().getOrElse(VFS_ROOT); + throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); } - return Path.of(getOutput().get().getAsFile().toURI()).resolve(path).resolve(VFS_VENV); } } From 5e5fe5feecf958b815e0e453a5016d7154c782f9 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 4 Feb 2025 16:29:40 +0100 Subject: [PATCH 061/512] removed some unused functionality from VFSUtils --- .../org/graalvm/python/embedding/tools/vfs/VFSUtils.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 5b005fde4e..2394b2423e 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -136,13 +136,6 @@ private static String normalizeResourcePath(String path) { return REPLACE_BACKSLASHES ? path.replace("\\", "/") : path; } - /** - * Adds the VFS filelist entries to given set. Caller may provide a non-empty set. - */ - public static void generateVFSFilesList(Path vfs, Set ret, Consumer duplicateHandler) throws IOException { - generateVFSFilesList(null, vfs, ret, duplicateHandler); - } - public static void generateVFSFilesList(Path resourcesRoot, Path vfs, Set ret, Consumer duplicateHandler) throws IOException { if (!Files.isDirectory(vfs)) { throw new IOException(String.format("'%s' has to exist and be a directory.\n", vfs)); @@ -697,7 +690,7 @@ private static void runVenvBin(Path venvDirectory, String bin, BuildToolLog log, } } - public static List trim(List l) { + private static List trim(List l) { Iterator it = l.iterator(); while (it.hasNext()) { String p = it.next(); From 7c29bab5ce6d1062efa8ce4c1f08fea136bbbb31 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 5 Feb 2025 12:55:01 +0100 Subject: [PATCH 062/512] check if plugin packages are still the same as the packages previously used to generate the requirements file --- .../embedding/test/EmbeddingTestUtils.java | 11 +-- .../embedding/vfs/test/VFSUtilsTest.java | 72 ++++++++++--------- .../maven/plugin/AbstractGraalPyMojo.java | 66 ++++++++++------- .../maven/plugin/ManageResourcesMojo.java | 2 +- .../python/embedding/tools/vfs/VFSUtils.java | 62 ++++++++++------ .../graalvm/python/GraalPyGradlePlugin.java | 4 +- .../python/tasks/AbstractPackagesTask.java | 16 +++-- .../python/tasks/InstallPackagesTask.java | 2 +- 8 files changed, 140 insertions(+), 95 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index a13efff436..ab725140ba 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -59,18 +59,21 @@ private EmbeddingTestUtils() { } public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException { - createVenv(venvDir, graalPyVersion, log, null, null, null, null, packages); + createVenv(venvDir, graalPyVersion, log, null, null, null, null, null, packages); } - public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, String iconsistentPackagesError, String wrongPackageVersionError, - String missingRequirementsFileWarning, String... packages) + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, + String inconsistentPackagesError, String wrongPackageVersionError, String missingRequirementsFileWarning, String packagesListChangedError, + String... packages) throws IOException { try { info(log, "<<<<<< create test venv %s <<<<<<", venvDir); Launcher launcher = createLauncher(venvDir); if (requirements != null) { - VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, iconsistentPackagesError, wrongPackageVersionError, missingRequirementsFileWarning, launcher, graalPyVersion, log); + VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, + inconsistentPackagesError, wrongPackageVersionError, missingRequirementsFileWarning, packagesListChangedError, + launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); } diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 7045822c85..5cd53e760f 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -69,6 +69,7 @@ public class VFSUtilsTest { private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; private static final String INCONSISTENT_PKGS_ERROR = "requirements %s inconsistent with packages %s"; + private static final String PACKAGES_CHANGED_ERROR = "packages changed requirements file %s, current packages %s, previous packages %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; @@ -504,7 +505,7 @@ public void installAndFreeze() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "'tiny-tiny==0.2'"))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "tiny-tiny==0.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); @@ -537,7 +538,7 @@ public void installAndFreeze() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "'hello-world==0.2'"))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "hello-world==0.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); @@ -567,26 +568,39 @@ public void installAndFreeze() throws IOException { assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); + // remove tiny-tiny from packages list - fails because it is still in requirements + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2")); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, requirements, "hello-world==0.2", "hello-world==0.2, tiny-tiny==0.2"))); + log.clearOutput(); + // freeze requirements with new hello-world + freeze(venvDir, requirements, log, "hello-world==0.2"); + checkRequirementsFile(requirements, "hello-world==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + // try again + createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2"); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains("Virtual environment is up to date with requirements file")); + log.clearOutput(); + // reinstall with new graalpy version - createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); + createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2"); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); assertTrue(log.getOutput().contains("pip install -r")); // requirements file is used - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.2", "hello-world==0.2", "tiny-tiny==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); + checkVenvContentsFile(contents, "0.2", "hello-world==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); } - // XXX test and fix: - // - mvn package with 2 pkgs in pom - // - freeze - // - remove 1 pkg from pom - // - mvn package keeps the removed pkg in venv because installing from req file!!! - // at least warning? - @Test - public void invalidVersionFormatTest() { + public void invalidVersionFormatTest() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException { TestLog log = new TestLog(); checkWrongPkgVersionFormat("", log); @@ -602,8 +616,10 @@ public void invalidVersionFormatTest() { } } - private static void checkWrongPkgVersionFormat(String pkg, TestLog log) { - checkException(IOException.class, () -> VFSUtils.checkVersionFormat(Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); + private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Method m = VFSUtils.class.getDeclaredMethod("checkVersionFormat", List.class, String.class, BuildToolLog.class); + m.setAccessible(true); + checkException(IOException.class, () -> m.invoke(VFSUtils.class, Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'" + pkg + "'"))); log.clearOutput(); } @@ -619,25 +635,15 @@ public void packageConsistency() throws Exception { callPackageConsistencyCheck(log, Collections.emptyList(), requirements); - checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.emptyList(), requirements, "pkg1")); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); - log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.emptyList(), requirements, "pkg1==1")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "'pkg1==1'"))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg1==1"))); log.clearOutput(); final List requirementsList = Arrays.asList("pkg1==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, requirements, "pkg1")); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg1'"))); - log.clearOutput(); - checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, requirements, "pkg2")); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); - log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, requirements, "pkg2==1")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "'pkg2==1'"))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg2==1"))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList, requirements, "pkg1==1.0"); log.clearOutput(); @@ -647,11 +653,8 @@ public void packageConsistency() throws Exception { final List requirementsList2 = Arrays.asList("pkg1==1.0.0", "pkg2==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg2")); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'pkg2'"))); - log.clearOutput(); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg2==2")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "'pkg2==2'"))); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg2==2"))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg1==1.0"); log.clearOutput(); @@ -661,9 +664,9 @@ public void packageConsistency() throws Exception { private static void callPackageConsistencyCheck(TestLog log, List requirementsList, Path requirements, String... packages) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method m = VFSUtils.class.getDeclaredMethod("checkPackagesConsistent", List.class, List.class, Path.class, String.class, String.class, BuildToolLog.class); + Method m = VFSUtils.class.getDeclaredMethod("checkPluginPackagesInRequirementsFile", List.class, List.class, Path.class, String.class, BuildToolLog.class); m.setAccessible(true); - m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, log); + m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, INCONSISTENT_PKGS_ERROR, log); } private interface ExceptionCall { @@ -735,7 +738,8 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, } private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path requirements, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, packages); + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_CHANGED_ERROR, + packages); } private static void checkVenvContentsFile(Path contents, String graalPyVersion, String... packages) throws IOException { diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index c5ed0b9664..eeb9c92116 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -97,7 +97,17 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { protected static final String INCONSISTENT_PACKAGES_ERROR = """ Install of python packages is based on requirements file %s, - but some packages from graalpy-maven-plugin configuration are either missing or have a different version: %s. + but some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version: %s. + + The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + """; + + protected static final String PACKAGES_LIST_CHANGED_ERROR = """ + Install of python packages is based on requirements file %s, + but some packages in graalpy-maven-plugin configuration are different then previously used to generate the requirements file. + + Packages currently declared in graalpy-maven-plugin configuration: %s + Packages which were used to generate the requirements file: %s The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. """; @@ -162,46 +172,48 @@ protected void preExec(boolean checkFields) throws MojoExecutionException { requirementsFile = normalizeEmpty(requirementsFile); packages = packages != null ? packages.stream().filter(p -> p != null && !p.trim().isEmpty()).toList() : Collections.EMPTY_LIST; - if(!checkFields) { - return; - } - if(pythonResourcesDirectory != null) { - if (externalDirectory != null) { - throw new MojoExecutionException( - "Cannot use and at the same time. " + - "New option is a replacement for deprecated . " + - "If you want to deploy the virtual environment into physical filesystem, use . " + - "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + - "If you want to bundle the virtual filesystem in Java resources, use . " + - "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); + if(checkFields) { + if (externalDirectory != null) { + throw new MojoExecutionException( + "Cannot use and at the same time. " + + "New option is a replacement for deprecated . " + + "If you want to deploy the virtual environment into physical filesystem, use . " + + "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + + "If you want to bundle the virtual filesystem in Java resources, use . " + + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); + } + getLog().warn("Option is deprecated and will be removed. Use instead."); } - getLog().warn("Option is deprecated and will be removed. Use instead."); externalDirectory = pythonResourcesDirectory; } if (resourceDirectory != null) { - if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) { - throw new MojoExecutionException( - "Value of should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'"); + if(checkFields) { + if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) { + throw new MojoExecutionException( + "Value of should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'"); + } } } if (resourceDirectory == null) { - if (externalDirectory == null) { - getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + - "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + - "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " + - "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + - "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", - VFS_ROOT, - Path.of(VFS_ROOT, "src"), - Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId()))); + if(checkFields) { + if (externalDirectory == null) { + getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " + + "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + + "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " + + "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", + VFS_ROOT, + Path.of(VFS_ROOT, "src"), + Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId()))); + } } resourceDirectory = VFS_ROOT; } - if(pythonHome != null) { + if(checkFields && pythonHome != null) { getLog().warn("The GraalPy plugin configuration setting was deprecated and has no effect anymore.\n" + "For execution in jvm mode, the python language home is always available.\n" + "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" + diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index 0f5246f6c7..3f00552ed5 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -69,7 +69,7 @@ private void manageVenv() throws MojoExecutionException { MavenDelegateLog log = new MavenDelegateLog(getLog()); Path requirements = getRequirementsFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_LIST_CHANGED_ERROR, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 2394b2423e..cef9564596 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -277,11 +277,11 @@ void write(List pkgs) throws IOException { } public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { - createVenv(venvDirectory, packagesArgs, null, null, null, null, launcherArgs, graalPyVersion, log); + createVenv(venvDirectory, packagesArgs, null, null, null, null, null, launcherArgs, graalPyVersion, log); } public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, - String inconsistentPackagesError, String wrongPackageVersionFormatError, String missingRequirementsFileWarning, + String inconsistentPackagesError, String wrongPackageVersionFormatError, String missingRequirementsFileWarning, String packagesListChangedError, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); @@ -299,13 +299,32 @@ public static void createVenv(Path venvDirectory, List packages, Path re VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcher, log)); - boolean installed = requirementsPackages != null ? install(venvDirectory, requirementsFile, requirementsPackages, log) - : install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); + boolean installed; + if (requirementsPackages != null) { + checkPluginPackagesChanged(venvContents, pluginPackages, requirementsFile, packagesListChangedError, log); + installed = install(venvDirectory, requirementsFile, requirementsPackages, log); + } else { + installed = install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); + } if (installed) { venvContents.write(pluginPackages); } } + /** + * checks if plugin packages are still the same as the packages previously used to generate the + * requirements file + */ + private static void checkPluginPackagesChanged(VenvContents venvContents, List pluginPackages, Path requirementsFile, String packagesListChangedError, BuildToolLog log) + throws IOException { + if (packagesListChangedError != null && venvContents.packages != null && + venvContents.packages.size() != pluginPackages.size() && venvContents.packages.containsAll(pluginPackages)) { + extendedError(log, String.format(packagesListChangedError, requirementsFile, + String.join(", ", pluginPackages.stream().sorted().toList()), String.join(", ", venvContents.packages.stream().sorted().toList()))); + throw new IOException("packages from plugin configuration changed"); + } + } + public static void freezePackages(Path venvDirectory, List packages, Path requirementsFile, String requirementsHeader, String wrongPackageVersionFormatError, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { checkVersionFormat(packages, wrongPackageVersionFormatError, log); @@ -338,7 +357,8 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String inconsistentPackagesError, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { if (requirementsPackages != null) { - checkPackagesConsistent(pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, wrongPackageVersionFormatError, log); + checkVersionFormat(pluginPackages, wrongPackageVersionFormatError, log); + checkPluginPackagesInRequirementsFile(pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, log); logPackages(requirementsPackages, requirementsFile, log); return needVenv(venvDirectory, requirementsPackages, log); } else { @@ -413,7 +433,7 @@ private static boolean install(Path venvDirectory, Path requirementsFile, List getHeaderList(String requirementsFileHeader) { return list; } - public static void checkVersionFormat(List packages, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + /** + * check that packages are declared with a specific version - package_name==version + */ + private static void checkVersionFormat(List packages, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { Objects.requireNonNull(packages); Objects.requireNonNull(wrongPackageVersionFormatError); Objects.requireNonNull(log); @@ -500,22 +523,21 @@ private static boolean checkValidPackageVersion(String pkg) { } private static void wrongPackageVersionError(BuildToolLog log, String wrongPackageVersionFormatError, String pkgs) throws IOException { - if (log.isErrorEnabled()) { - extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); - } + extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); throw new IOException("invalid package format: " + pkgs); } - private static void checkPackagesConsistent(List packages, List requiredPackages, Path requirementsFile, String inconsistentPackagesError, - String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + /** + * check that there are no plugin packages missing in requirements file + */ + private static void checkPluginPackagesInRequirementsFile(List packages, List requiredPackages, Path requirementsFile, String inconsistentPackagesError, BuildToolLog log) + throws IOException { if (packages.isEmpty()) { return; } - checkVersionFormat(packages, wrongPackageVersionFormatError, log); - Map requiredPackagesMap = requiredPackages.stream().filter(p -> p.contains("==")).map(p -> p.split("==")).collect(Collectors.toMap(parts -> parts[0], parts -> parts[1])); - StringBuilder sb = new StringBuilder(); + List inconsistent = new ArrayList<>(); for (String pkg : packages) { String[] s = pkg.split("=="); String pName = s[0]; @@ -524,18 +546,16 @@ private static void checkPackagesConsistent(List packages, List if (rVersion != null && rVersion.startsWith(pVersion)) { continue; } - sb.append(!sb.isEmpty() ? ", " : "").append("'").append(pkg).append("'"); + inconsistent.add(pkg); } - if (!sb.isEmpty()) { - inconsistentPackagesError(log, inconsistentPackagesError, requirementsFile, sb.toString()); + if (!inconsistent.isEmpty()) { + inconsistentPackagesError(log, inconsistentPackagesError, requirementsFile, String.join(", ", inconsistent)); } } private static void inconsistentPackagesError(BuildToolLog log, String inconsistentPackagesError, Object... args) throws IOException { - if (log.isErrorEnabled()) { - extendedError(log, String.format(inconsistentPackagesError, args) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); - } + extendedError(log, String.format(inconsistentPackagesError, args) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); throw new IOException("inconsistent packages"); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index 36acf2cee4..965d391415 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -131,7 +131,7 @@ public void apply(Project project) { "New property 'externalDirectory' is a replacement for deprecated 'pythonResourcesDirectory'. " + "If you want to deploy the virtual environment into physical filesystem, use 'externalDirectory'. " + "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." + - "If you wish to bundle the virtual filesystem in Java resources, use 'resourceDirectory'. " + + "If you wish to bundle the virtual filesystem in Java resources, use 'resourcesDirectory'. \n" + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. "); } @@ -146,7 +146,7 @@ public void apply(Project project) { "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " + "Consider adding `resourceDirectory = \"GRAALPY-VFS/${groupId}/${artifactId}\"` to your build.gradle script " + "(replace the placeholders with values specific to your project), " + - "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." + + "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory.\n" + "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ", VFS_ROOT, Path.of(VFS_ROOT, "src"), diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 0011887a09..10981028d8 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -104,11 +104,21 @@ public abstract class AbstractPackagesTask extends DefaultTask { protected static final String INCONSISTENT_PACKAGES_ERROR = """ Install of python packages is based on requirements file %s, - but some packages in graalpy-gradle-plugin configuration are either missing or have a different version: %s. + but some packages in graalpy-gradle-plugin configuration are either missing in requirements file or have a different version: %s. The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. """; + protected static final String PACKAGES_LIST_CHANGED_ERROR = """ + Install of python packages is based on requirements file %s, + but some packages in graalpy-gradle-plugin configuration are different then previously used to generate the requirements file. + + Packages currently declared in graalpy-gradle-plugin configuration: %s + Packages which were used to generate the requirements file: %s + + The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + """; + /** @see #getOutput() */ @Input @Optional @@ -140,13 +150,9 @@ public abstract class AbstractPackagesTask extends DefaultTask { @Optional public abstract Property getResourceDirectory(); - // XXX String or file or RegularFileProperty? - // XXX cached ? -// @Input @InputFiles @Optional @PathSensitive(PathSensitivity.RELATIVE) -// public abstract Property getRequirementsFile(); public abstract RegularFileProperty getRequirementsFile(); /** diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 17caae09ea..0d694b26ab 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -71,7 +71,7 @@ public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { VFSUtils.createVenv(venvDirectory, getPackages().get(), getRequirementsPath(), - INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, + INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_LIST_CHANGED_ERROR, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); From 66b208a4c6ecc1a27eba18ba54df2b2acc371713 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 5 Feb 2025 13:43:32 +0100 Subject: [PATCH 063/512] removed obsolete method from AbstarctPackagesTask --- .../java/org/graalvm/python/tasks/AbstractPackagesTask.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 10981028d8..65f08c926a 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -161,12 +161,6 @@ public abstract class AbstractPackagesTask extends DefaultTask { @Input public abstract Property getPolyglotVersion(); - @Input - protected String getOperatingSystem() { - // XXX what is this? - return System.getProperty("os.name"); - } - protected Set calculateLauncherClasspath() { return getLauncherClasspath().getFiles().stream().map(File::getAbsolutePath).collect(Collectors.toUnmodifiableSet()); } From 06f83c70b7031842d189f2d9d432d060ccaa0132 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 6 Feb 2025 11:05:07 +0100 Subject: [PATCH 064/512] minor refactoring in VFSUtils --- .../graalvm/python/embedding/tools/vfs/VFSUtils.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index cef9564596..4890055d9f 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -297,7 +297,7 @@ public static void createVenv(Path venvDirectory, List packages, Path re return; } - VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, log, ensureLauncher(launcher, log)); + VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, launcher, log); boolean installed; if (requirementsPackages != null) { @@ -398,7 +398,8 @@ private static List readPackagesFromFile(Path file) throws IOException { }).toList(); } - private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion, BuildToolLog log, Path launcherPath) throws IOException { + private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion, Launcher launcher, BuildToolLog log) throws IOException { + Path launcherPath = ensureLauncher(launcher, log); VenvContents contents = null; if (Files.exists(venvDirectory)) { checkVenvLauncher(venvDirectory, launcherPath, log); @@ -414,9 +415,9 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion } if (!Files.exists(venvDirectory)) { - info(log, "Creating GraalPy %s venv", graalPyVersion); - runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); - runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); + info(log, "Creating GraalPy %s venv", graalPyVersion); + runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); + runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } if (contents == null) { From e2f995b525bcd84e9638bfac1185238c5f652376 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Thu, 6 Feb 2025 21:24:48 +0100 Subject: [PATCH 065/512] delete whole venv if a package was removed since last install as we don't know what other transitive dependencies are left behind --- .../embedding/test/EmbeddingTestUtils.java | 2 +- .../embedding/vfs/test/VFSUtilsTest.java | 156 +++++++++++++----- .../tests/standalone/test_gradle_plugin.py | 5 +- .../standalone/test_jbang_integration.py | 4 +- .../src/tests/standalone/test_maven_plugin.py | 5 +- .../maven/plugin/ManageResourcesMojo.java | 2 +- .../python/embedding/tools/vfs/VFSUtils.java | 89 ++++++++-- .../python/tasks/InstallPackagesTask.java | 2 +- 8 files changed, 198 insertions(+), 67 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index ab725140ba..a887428d2d 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -72,7 +72,7 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog Launcher launcher = createLauncher(venvDir); if (requirements != null) { VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, - inconsistentPackagesError, wrongPackageVersionError, missingRequirementsFileWarning, packagesListChangedError, + inconsistentPackagesError, wrongPackageVersionError, packagesListChangedError, missingRequirementsFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 5cd53e760f..8c82bfba6c 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -67,11 +67,13 @@ public class VFSUtilsTest { + private static final String PACKAGE_WAS_REMOVED = "A package with unknown dependencies was removed since last install, setting up a clean venv"; private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; private static final String INCONSISTENT_PKGS_ERROR = "requirements %s inconsistent with packages %s"; private static final String PACKAGES_CHANGED_ERROR = "packages changed requirements file %s, current packages %s, previous packages %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; + private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; private static final class TestLog implements BuildToolLog { private final StringBuilder output = new StringBuilder(); @@ -162,12 +164,13 @@ private static boolean isVerbose() { } /** - * tests scenarios when packages are declared only in plugin config + * tests scenarios when packages are declared only in plugin config, and requirement file logic + * is available, even though no used */ @Test - public void testWithPackagesOnlyFromPluginConfig() throws IOException { + public void withPackagesOnlyFromPluginConfig() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_testWithPackagesOnlyFromPluginConfig"); + Path tmpDir = Files.createTempDirectory("withPackagesOnlyFromPluginConfig"); Path venvDir = tmpDir.resolve("venv"); deleteDirOnShutdown(tmpDir); @@ -184,6 +187,8 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); + log.clearOutput(); + // install packages log.clearOutput(); createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); @@ -204,19 +209,21 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); - // remove tiny-tiny, assert that venv wasn't created and only tiny-tiny was removed + // remove tiny-tiny, assert that venv was deleted and created anew as we don't know if there + // were any transitive deps left log.clearOutput(); createVenv(venvDir, "0.1", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - assertFalse(log.getOutput().contains("hello-world")); - assertTrue(log.getOutput().contains("Uninstalling tiny-tiny")); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.getOutput().contains(PACKAGE_WAS_REMOVED)); + assertTrue(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains("hello-world")); + assertFalse(log.getOutput().contains("tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); - // install only hello-world again, assert that venv wasn't created and packages weren't - // installed + // install only hello-world again, assert that venv wasn't created and + // packages weren't installed log.clearOutput(); createVenv(venvDir, "0.1", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); @@ -232,7 +239,7 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { createVenv(venvDir, "0.2", log, requirements, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains(STALE_VENV)); assertTrue(log.getOutput().contains("pip install")); assertTrue(log.getOutput().contains("hello-world")); assertFalse(log.getOutput().contains("tiny-tiny")); @@ -241,12 +248,12 @@ public void testWithPackagesOnlyFromPluginConfig() throws IOException { } /** - * when called from jbang, which does not work with requirements file + * tests scenarios without requirements file logic - e.g. when called from jbang */ @Test - public void testWithoutRequirementsFile() throws IOException { + public void withoutRequirementsFile() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_testWithoutRequirementsFile"); + Path tmpDir = Files.createTempDirectory("withoutRequirementsFile"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); @@ -257,51 +264,48 @@ public void testWithoutRequirementsFile() throws IOException { assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); - createVenv(venvDir, "0.1", log, "hello-world"); + createVenv(venvDir, "0.1", log, "hello-world==0.1"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world"); - log.clearOutput(); - - createVenv(venvDir, "0.1", log, "hello-world==0.1"); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); log.clearOutput(); - createVenv(venvDir, "0.1", log, "hello-world", "tiny-tiny"); + createVenv(venvDir, "0.1", log, "hello-world==0.1", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); - checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny"); log.clearOutput(); - createVenv(venvDir, "0.1", log, "hello-world"); + createVenv(venvDir, "0.1", log, "hello-world==0.1"); assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); + checkVenvCreate(log.getOutput(), true); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); log.clearOutput(); // new graalPy version - createVenv(venvDir, "0.2", log, "hello-world"); + createVenv(venvDir, "0.2", log, "hello-world==0.1"); checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains(STALE_VENV)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.2", "hello-world"); + checkVenvContentsFile(contents, "0.2", "hello-world==0.1"); log.clearOutput(); } @Test public void emptyRequirements() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_emptyRequirements"); + Path tmpDir = Files.createTempDirectory("emptyRequirements"); Path venvDir = tmpDir.resolve("venv"); deleteDirOnShutdown(tmpDir); Path requirements = tmpDir.resolve("requirements.txt"); + Files.createFile(requirements); checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); @@ -330,7 +334,7 @@ public void emptyRequirements() throws IOException { @Test public void onlyRequirementsFile() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_onlyRequirementsFile"); + Path tmpDir = Files.createTempDirectory("onlyRequirementsFile"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); @@ -386,7 +390,7 @@ public void onlyRequirementsFile() throws IOException { // new graalpy version createVenv(venvDir, "0.2", log, requirements); checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains(STALE_VENV)); assertTrue(log.getOutput().contains("pip install -r")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); checkVenvContentsFile(contents, "0.2"); @@ -412,15 +416,15 @@ private static void writeRequirementsFile(Path requirements, String... packages) @Test public void missingRequirementsWarning() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_missingRequirementsWarning"); + Path tmpDir = Files.createTempDirectory("missingRequirementsWarning"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); Path requirements = tmpDir.resolve("requirements.txt"); - // install request, it pulls in transitive pkgs and we get the missing requirements file - // warning + // install request, it pulls in transitive pkgs and + // we get the missing requirements file warning createVenv(venvDir, "0.1", log, requirements, "requests==2.32.3"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); @@ -432,6 +436,7 @@ public void missingRequirementsWarning() throws IOException { // freeze requirements freeze(venvDir, requirements, log, "requests==2.32.3"); checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); @@ -443,12 +448,30 @@ public void missingRequirementsWarning() throws IOException { checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + + // 1.) first freeze requests which pulls in transitive deps + freeze(venvDir, requirements, log, "requests==2.32.3", "hello-world==0.2"); + checkVenvCreate(log.getOutput(), false); + checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi", "hello-world==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi", "hello-world==0.2"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.3", "hello-world==0.2"); + log.clearOutput(); + // 2.) then freeze without it - its transitive deps have to be gone as well + freeze(venvDir, requirements, log, "hello-world==0.2"); + checkVenvCreate(log.getOutput(), true); + assertTrue(log.getOutput().contains(PACKAGE_WAS_REMOVED)); + checkRequirementsFile(requirements, "hello-world==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); + log.clearOutput(); + } @Test public void installAndFreeze() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_installAndFreeze"); + Path tmpDir = Files.createTempDirectory("installAndFreeze"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); @@ -488,7 +511,9 @@ public void installAndFreeze() throws IOException { // reinstall with exact version declared - ok Files.delete(requirements); createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1"); - checkVenvCreate(log.getOutput(), false); + // we changed hello-world from 01. to 0.2, we do not know if the prev version did not leave + // any transitive deps, so the venv is deleted and created again + checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); @@ -547,7 +572,9 @@ public void installAndFreeze() throws IOException { // delete requirements and try again new hello-world version - now ok Files.delete(requirements); createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); - checkVenvCreate(log.getOutput(), false); + // we changed hello-world from 01. to 0.2, we do not know if the prev version did not leave + // any transitive deps, so the venv is deleted and created again + checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); @@ -576,6 +603,7 @@ public void installAndFreeze() throws IOException { log.clearOutput(); // freeze requirements with new hello-world freeze(venvDir, requirements, log, "hello-world==0.2"); + checkVenvCreate(log.getOutput(), true); checkRequirementsFile(requirements, "hello-world==0.2"); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); @@ -591,7 +619,7 @@ public void installAndFreeze() throws IOException { // reinstall with new graalpy version createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2"); checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains("Stale GraalPy venv, updating to")); + assertTrue(log.getOutput().contains(STALE_VENV)); assertTrue(log.getOutput().contains("pip install -r")); // requirements file is used checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); checkVenvContentsFile(contents, "0.2", "hello-world==0.2"); @@ -600,9 +628,8 @@ public void installAndFreeze() throws IOException { } @Test - public void invalidVersionFormatTest() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException { + public void invalidVersionFormatTest() throws NoSuchMethodException { TestLog log = new TestLog(); - checkWrongPkgVersionFormat("", log); checkWrongPkgVersionFormat("==2.2", log); checkWrongPkgVersionFormat("==", log); @@ -616,7 +643,7 @@ public void invalidVersionFormatTest() throws InvocationTargetException, NoSuchM } } - private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws NoSuchMethodException { Method m = VFSUtils.class.getDeclaredMethod("checkVersionFormat", List.class, String.class, BuildToolLog.class); m.setAccessible(true); checkException(IOException.class, () -> m.invoke(VFSUtils.class, Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); @@ -628,7 +655,7 @@ private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws N public void packageConsistency() throws Exception { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("VFSUtilsTest_packageConsistency"); + Path tmpDir = Files.createTempDirectory("packageConsistency"); deleteDirOnShutdown(tmpDir); Path requirements = tmpDir.resolve("requirements.txt"); Files.createFile(requirements); @@ -669,6 +696,43 @@ private static void callPackageConsistencyCheck(TestLog log, List requir m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, INCONSISTENT_PKGS_ERROR, log); } + @Test + public void packageRemoved() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException { + Path tmpDir = Files.createTempDirectory("packageRemoved"); + Path venvDir = tmpDir.resolve("venv"); + deleteDirOnShutdown(tmpDir); + + assertFalse(callPackageRemoved(venvDir, Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Collections.emptyList(), Collections.emptyList())); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1=="), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("==pkg1"), Arrays.asList("==pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1==1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + + assertTrue(callPackageRemoved(venvDir, Collections.emptyList(), Arrays.asList("pkg"), Arrays.asList("pkg==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1=="), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("==pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1", "pkg2==1"), Arrays.asList("pkg1==1", "pkg2==1"))); + assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + } + + private static boolean callPackageRemoved(Path venvDir, List packages, List contents, List installed) + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Method m = VFSUtils.class.getDeclaredMethod("removedFromPluginPackages", Path.class, List.class, List.class, List.class); + m.setAccessible(true); + return (boolean) m.invoke(VFSUtils.class, venvDir, packages, contents, installed); + } + private interface ExceptionCall { void call() throws Exception; } @@ -749,7 +813,9 @@ private static void checkVenvContentsFile(Path contents, String graalPyVersion, assertEquals(graalPyVersion, lines.get(0)); lines.remove(0); assertEquals(packages.length, lines.size()); - assertTrue(lines.containsAll(Arrays.asList(packages))); + if (!lines.containsAll(Arrays.asList(packages))) { + fail(String.format("expected %s to contain all from %s", lines, Arrays.asList(packages))); + } } } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index a321535f10..1606179b89 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -48,7 +48,8 @@ MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-gradle-plugin configuration" WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-gradle-plugin configuration have no exact version declared" -PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-gradle-plugin configuration are either missing or have a different version" +PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-gradle-plugin configuration are either missing in requirements file or have a different version" +VENV_UPTODATE = "Virtual environment is up to date with requirements file, skipping install" def append(file, txt): with open(file, "a") as f: @@ -250,7 +251,7 @@ def check_freeze_requirements(self, community): cmd = gradlew_cmd + ["build", "run"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("Python packages up to date, skipping install", out) + util.check_ouput(VENV_UPTODATE, out) util.check_ouput("hello java", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py index 1fee24f38c..03e164bef5 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py @@ -340,8 +340,8 @@ def hello(): out, result = run_cmd(command, cwd=work_dir) self.assertTrue(result == 0, f"Execution failed with code {result}\n command: {command}\n stdout: {out}") - self.assertTrue("Uninstalling ujson" in out, f"Expected text:\nUninstalling ujson") - self.assertFalse("Successfully installed termcolor" in out, f"Did not expect text:\nSuccessfully installed termcolor") + self.assertFalse("ujson" in out, f"Did not expect text:\n ujson") + self.assertTrue("Successfully installed termcolor" in out, f"Did not expect text:\nSuccessfully installed termcolor") self.assertTrue("hello java" in out, f"Expected text:\nhello java\nbut in stdout was:\n{out}") # add ujson in additional PIP comment diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index 123c82b8e8..b2c8fd7ed9 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -50,7 +50,8 @@ MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-maven-plugin configuration" WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-maven-plugin configuration have no exact version declared" -PACKAGES_INCONSISTENT_ERROR = "some packages from graalpy-maven-plugin configuration are either missing or have a different version" +PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version" +VENV_UPTODATE = "Virtual environment is up to date with requirements file, skipping install" class MavenPluginTest(util.BuildToolTestBase): @@ -249,7 +250,7 @@ def test_freeze_requirements(self): cmd = mvnw_cmd + ["package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("Python packages up to date, skipping install", out) + util.check_ouput(VENV_UPTODATE, out) util.check_ouput("hello java", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java index 3f00552ed5..706638d97f 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java @@ -69,7 +69,7 @@ private void manageVenv() throws MojoExecutionException { MavenDelegateLog log = new MavenDelegateLog(getLog()); Path requirements = getRequirementsFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_LIST_CHANGED_ERROR, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_LIST_CHANGED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 4890055d9f..c6e872cf88 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -281,19 +281,24 @@ public static void createVenv(Path venvDirectory, List packagesArgs, Lau } public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, - String inconsistentPackagesError, String wrongPackageVersionFormatError, String missingRequirementsFileWarning, String packagesListChangedError, + String inconsistentPackagesError, String wrongPackageVersionFormatError, String packagesListChangedError, String missingRequirementsFileWarning, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); Objects.requireNonNull(launcher); Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); + if (requirementsFile != null) { + Objects.requireNonNull(inconsistentPackagesError); + Objects.requireNonNull(wrongPackageVersionFormatError); + Objects.requireNonNull(packagesListChangedError); + } logVenvArgs(venvDirectory, packages, requirementsFile, launcher, graalPyVersion, log); List pluginPackages = trim(packages); List requirementsPackages = requirementsFile != null && Files.exists(requirementsFile) ? readPackagesFromFile(requirementsFile) : null; - if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, wrongPackageVersionFormatError, log)) { + if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, wrongPackageVersionFormatError, packagesListChangedError, log)) { return; } @@ -301,7 +306,6 @@ public static void createVenv(Path venvDirectory, List packages, Path re boolean installed; if (requirementsPackages != null) { - checkPluginPackagesChanged(venvContents, pluginPackages, requirementsFile, packagesListChangedError, log); installed = install(venvDirectory, requirementsFile, requirementsPackages, log); } else { installed = install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); @@ -312,19 +316,65 @@ public static void createVenv(Path venvDirectory, List packages, Path re } /** - * checks if plugin packages are still the same as the packages previously used to generate the - * requirements file + * checks if package was removed since the last install */ - private static void checkPluginPackagesChanged(VenvContents venvContents, List pluginPackages, Path requirementsFile, String packagesListChangedError, BuildToolLog log) + private static void checkIfRemovedFromPluginPackages(Path venvDirectory, VenvContents venvContents, List pluginPackages, Path requirementsFile, String packagesListChangedError, + BuildToolLog log) throws IOException { - if (packagesListChangedError != null && venvContents.packages != null && - venvContents.packages.size() != pluginPackages.size() && venvContents.packages.containsAll(pluginPackages)) { + if (venvContents == null) { + return; + } + if (packagesListChangedError != null && removedFromPluginPackages(venvDirectory, venvContents, pluginPackages)) { extendedError(log, String.format(packagesListChangedError, requirementsFile, String.join(", ", pluginPackages.stream().sorted().toList()), String.join(", ", venvContents.packages.stream().sorted().toList()))); throw new IOException("packages from plugin configuration changed"); } } + private static boolean removedFromPluginPackages(Path venvDirectory, VenvContents venvContents, List pluginPackages) throws IOException { + if (venvContents == null || venvContents.packages == null) { + return false; + } + List installedPackages = InstalledPackages.fromVenv(venvDirectory).packages; + return removedFromPluginPackages(venvDirectory, pluginPackages, venvContents.packages, installedPackages); + } + + private static boolean removedFromPluginPackages(Path venvDirectory, List pluginPackages, List contentsPackages, List installedPackages) { + for (String contentsPackage : contentsPackages) { + if (!pluginPackages.contains(contentsPackage)) { + // there is a previously installed package missing in the current plugin packages + // list + if (!contentsPackage.contains("==")) { + // it has no version specified, so lets check if it isn't just requested with a + // version + String pkgAndVersion = getByName(contentsPackage, pluginPackages); + if (pkgAndVersion != null) { + // yes, a version was added to a package + if (installedPackages.contains(pkgAndVersion)) { + // and it happened to be already installed with the same version + continue; + } + } + } + return true; + } + } + return false; + } + + private static String getByName(String name, List packages) { + for (String p : packages) { + int idx = p.indexOf("=="); + if (idx > -1) { + String n = p.split("==")[0]; + if (n.equals(name)) { + return p; + } + } + } + return null; + } + public static void freezePackages(Path venvDirectory, List packages, Path requirementsFile, String requirementsHeader, String wrongPackageVersionFormatError, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { checkVersionFormat(packages, wrongPackageVersionFormatError, log); @@ -355,13 +405,26 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path } private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String inconsistentPackagesError, - String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { + String wrongPackageVersionFormatError, String packagesListChangedError, BuildToolLog log) throws IOException { + VenvContents contents = null; + if (Files.exists(venvDirectory)) { + // get contents from prev install if such already present + contents = VenvContents.fromVenv(venvDirectory); + } + if (requirementsPackages != null) { checkVersionFormat(pluginPackages, wrongPackageVersionFormatError, log); checkPluginPackagesInRequirementsFile(pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, log); + checkIfRemovedFromPluginPackages(venvDirectory, contents, pluginPackages, requirementsFile, packagesListChangedError, log); logPackages(requirementsPackages, requirementsFile, log); return needVenv(venvDirectory, requirementsPackages, log); } else { + if (removedFromPluginPackages(venvDirectory, contents, pluginPackages)) { + // a package was removed, and we do not know if it did not leave behind any + // transitive dependencies - rather create whole venv again to avoid it growing + info(log, "A package with unknown dependencies was removed since last install, setting up a clean venv"); + delete(venvDirectory); + } logPackages(pluginPackages, null, log); return needVenv(venvDirectory, pluginPackages, log); } @@ -409,15 +472,15 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion delete(venvDirectory); } else if (!graalPyVersion.equals(contents.graalPyVersion)) { contents = null; - info(log, "Stale GraalPy venv, updating to %s", graalPyVersion); + info(log, "Stale GraalPy virtual environment, updating to %s", graalPyVersion); delete(venvDirectory); } } if (!Files.exists(venvDirectory)) { - info(log, "Creating GraalPy %s venv", graalPyVersion); - runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); - runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); + info(log, "Creating GraalPy %s virtual environment", graalPyVersion); + runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); + runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } if (contents == null) { diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 0d694b26ab..9b3eed33e1 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -71,7 +71,7 @@ public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { VFSUtils.createVenv(venvDirectory, getPackages().get(), getRequirementsPath(), - INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_LIST_CHANGED_ERROR, + INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_LIST_CHANGED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); From f45327d9f571e3944534fcffafbfbcff12d39dac Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Feb 2025 15:28:37 +0100 Subject: [PATCH 066/512] minor logging changes in VFSUtils --- .../src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index c6e872cf88..c42e63cd6b 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -478,7 +478,7 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion } if (!Files.exists(venvDirectory)) { - info(log, "Creating GraalPy %s virtual environment", graalPyVersion); + info(log, "Creating GraalPy %s venv", graalPyVersion); runLauncher(launcherPath.toString(), log, "-m", "venv", venvDirectory.toString(), "--without-pip"); runVenvBin(venvDirectory, "graalpy", log, "-I", "-m", "ensurepip"); } @@ -565,7 +565,7 @@ private static void checkVersionFormat(List packages, String wrongPackag StringBuilder sb = new StringBuilder(); for (String pkg : packages) { if (!checkValidPackageVersion(pkg)) { - sb.append(!sb.isEmpty() ? ", " : "").append("'").append(pkg).append("'"); + sb.append(!sb.isEmpty() ? ", " : "").append(pkg); } } if (!sb.isEmpty()) { From 28ae177b682c9814e2f4fd938a65c90f5a526cf9 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Feb 2025 15:28:56 +0100 Subject: [PATCH 067/512] merged some tests in VFSUtilsTests --- .../embedding/vfs/test/VFSUtilsTest.java | 292 +++++++----------- .../python/embedding/tools/vfs/VFSUtils.java | 2 +- 2 files changed, 118 insertions(+), 176 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 8c82bfba6c..362dcfbd24 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -70,7 +70,7 @@ public class VFSUtilsTest { private static final String PACKAGE_WAS_REMOVED = "A package with unknown dependencies was removed since last install, setting up a clean venv"; private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; private static final String INCONSISTENT_PKGS_ERROR = "requirements %s inconsistent with packages %s"; - private static final String PACKAGES_CHANGED_ERROR = "packages changed requirements file %s, current packages %s, previous packages %s"; + private static final String PACKAGES_CHANGED_ERROR = "packages changed in requirements file %s, current packages %s, previous packages %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; @@ -164,8 +164,10 @@ private static boolean isVerbose() { } /** - * tests scenarios when packages are declared only in plugin config, and requirement file logic - * is available, even though no used + * tests scenarios without requirements file logic available, but not used + * + * - packages declared only in plugin config - requirement file path is provided, but does not + * exist */ @Test public void withPackagesOnlyFromPluginConfig() throws IOException { @@ -233,22 +235,12 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { assertFalse(log.getOutput().contains("tiny-tiny")); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); - - // change version, assert that new venv created and packages installed - log.clearOutput(); - createVenv(venvDir, "0.2", log, requirements, "hello-world"); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains(STALE_VENV)); - assertTrue(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains("hello-world")); - assertFalse(log.getOutput().contains("tiny-tiny")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.2", "hello-world"); } /** * tests scenarios without requirements file logic - e.g. when called from jbang + * + * - packages declared only in plugin config - and requirement file path is not provided */ @Test public void withoutRequirementsFile() throws IOException { @@ -287,45 +279,6 @@ public void withoutRequirementsFile() throws IOException { checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); log.clearOutput(); - - // new graalPy version - createVenv(venvDir, "0.2", log, "hello-world==0.1"); - checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains(STALE_VENV)); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.2", "hello-world==0.1"); - log.clearOutput(); - } - - @Test - public void emptyRequirements() throws IOException { - TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("emptyRequirements"); - Path venvDir = tmpDir.resolve("venv"); - deleteDirOnShutdown(tmpDir); - - Path requirements = tmpDir.resolve("requirements.txt"); - - Files.createFile(requirements); - - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); - assertFalse(log.getOutput().contains("pip install")); - log.clearOutput(); - - createVenv(venvDir, "0.1", log, requirements); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - log.clearOutput(); - - createVenv(venvDir, "0.2", log, requirements); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - log.clearOutput(); } /** @@ -387,15 +340,6 @@ public void onlyRequirementsFile() throws IOException { checkVenvContentsFile(contents, "0.1"); log.clearOutput(); - // new graalpy version - createVenv(venvDir, "0.2", log, requirements); - checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains(STALE_VENV)); - assertTrue(log.getOutput().contains("pip install -r")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); - checkVenvContentsFile(contents, "0.2"); - log.clearOutput(); - // check that freeze rewrites an existing requirements file writeRequirementsFile(requirements); // no packages freeze(venvDir, requirements, log, "hello-world==0.1", "tiny-tiny==0.1"); @@ -403,69 +347,48 @@ public void onlyRequirementsFile() throws IOException { log.clearOutput(); } - private static void freeze(Path venvDir, Path requirements, TestLog log, String... packages) throws IOException { - VFSUtils.freezePackages(venvDir, Arrays.asList(packages), requirements, REQUIREMENTS_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); - } - - private static void writeRequirementsFile(Path requirements, String... packages) throws IOException { - List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); - lines.addAll(Arrays.asList(packages)); - Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - } - + /** + * requirement file exists but is empty + */ @Test - public void missingRequirementsWarning() throws IOException { + public void emptyRequirements() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("missingRequirementsWarning"); + Path tmpDir = Files.createTempDirectory("emptyRequirements"); Path venvDir = tmpDir.resolve("venv"); - Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); Path requirements = tmpDir.resolve("requirements.txt"); - // install request, it pulls in transitive pkgs and - // we get the missing requirements file warning - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.3"); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), true); - checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); - checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); - assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); - log.clearOutput(); + Files.createFile(requirements); - // freeze requirements - freeze(venvDir, requirements, log, "requests==2.32.3"); - checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); - checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "hello-world"))); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); - // install again - no more warning - delete(venvDir); - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.3"); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), true); - checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi"); - checkVenvContentsFile(contents, "0.1", "requests==2.32.3"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + createVenv(venvDir, "0.1", log, requirements); + assertFalse(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), false); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); - // 1.) first freeze requests which pulls in transitive deps - freeze(venvDir, requirements, log, "requests==2.32.3", "hello-world==0.2"); + createVenv(venvDir, "0.2", log, requirements); + assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - checkRequirementsFile(requirements, "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi", "hello-world==0.2"); - checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.3", "charset-normalizer", "idna", "urllib3", "certifi", "hello-world==0.2"); - checkVenvContentsFile(contents, "0.1", "requests==2.32.3", "hello-world==0.2"); - log.clearOutput(); - // 2.) then freeze without it - its transitive deps have to be gone as well - freeze(venvDir, requirements, log, "hello-world==0.2"); - checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains(PACKAGE_WAS_REMOVED)); - checkRequirementsFile(requirements, "hello-world==0.2"); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); + assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); + } + private static void freeze(Path venvDir, Path requirements, TestLog log, String... packages) throws IOException { + VFSUtils.freezePackages(venvDir, Arrays.asList(packages), requirements, REQUIREMENTS_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); + } + + private static void writeRequirementsFile(Path requirements, String... packages) throws IOException { + List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); + lines.addAll(Arrays.asList(packages)); + Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } @Test @@ -478,151 +401,171 @@ public void installAndFreeze() throws IOException { Path requirements = tmpDir.resolve("requirements.txt"); - // install package from plugin config - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2"); + // install request from plugin config, it pulls in transitive pkgs and + // we get the missing requirements file warning + createVenv(venvDir, "0.1", log, requirements, "requests"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests"); + assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements without version - fails - checkException(IOException.class, () -> freeze(venvDir, requirements, log, "hello-world")); + checkException(IOException.class, () -> freeze(venvDir, requirements, log, "requests")); assertFalse(Files.exists(requirements)); - assertFalse(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "hello-world"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); // freeze requirements with version - ok - freeze(venvDir, requirements, log, "hello-world==0.2"); - checkRequirementsFile(requirements, "hello-world==0.2"); + freeze(venvDir, requirements, log, "requests==2.32.2"); + checkRequirementsFile(requirements, "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // reinstall without exact version declared - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests")); checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'hello-world'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); assertFalse(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); + assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + + // reinstall again - no more warning + delete(venvDir); + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2"); + assertTrue(Files.exists(venvDir)); + checkVenvCreate(log.getOutput(), true); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); - // reinstall with exact version declared - ok + // reinstall with lower version - ok Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1"); - // we changed hello-world from 01. to 0.2, we do not know if the prev version did not leave + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1"); + // we changed version from 2.32.2 to 2.32.1, we do not know if the prev version did not + // leave // any transitive deps, so the venv is deleted and created again checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); + assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // freeze requirements - freeze(venvDir, requirements, log, "hello-world==0.1"); - checkRequirementsFile(requirements, "hello-world==0.1"); + freeze(venvDir, requirements, log, "requests==2.32.1"); + checkRequirementsFile(requirements, "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // add tiny-tiny - fails because inconsistent with requirements file assert Files.exists(requirements); - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2")); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "tiny-tiny==0.2"))); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // delete requirements and try again tiny-tiny - now ok Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertTrue(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); - // freeze requirements - hello-world, tiny-tiny - freeze(venvDir, requirements, log, "hello-world==0.1", "tiny-tiny==0.2"); - checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); + assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + log.clearOutput(); + // freeze requirements + freeze(venvDir, requirements, log, "requests==2.32.1", "tiny-tiny==0.2"); + checkRequirementsFile(requirements, "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // install again - OK - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.1", "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); - // update hello-world version - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2")); + // update in declared packages requests version back to 2.32.2 - fails + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "hello-world==0.2"))); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.1", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny==0.2"); + assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "requests==2.32.2"))); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // delete requirements and try again new hello-world version - now ok Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); - // we changed hello-world from 01. to 0.2, we do not know if the prev version did not leave + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2"); + // we changed version from 2.32.2 to 2.32.1, we do not know if the prev version did not + // leave // any transitive deps, so the venv is deleted and created again checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.2", "tiny-tiny==0.2"); + assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); - // freeze requirements with new hello-world - freeze(venvDir, requirements, log, "hello-world==0.2", "tiny-tiny==0.2"); - checkRequirementsFile(requirements, "hello-world==0.2", "tiny-tiny==0.2"); + // freeze requirements with new requests version + freeze(venvDir, requirements, log, "requests==2.32.2", "tiny-tiny==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkRequirementsFile(requirements, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // install again - OK - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2", "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2", "tiny-tiny==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2", "tiny-tiny==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkRequirementsFile(requirements, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkVenvContentsFile(contents, "0.1", "requests==2.32.2", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); - // remove tiny-tiny from packages list - fails because it is still in requirements - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2")); + // remove requests from packages list - fails because it is still in requirements + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, requirements, "hello-world==0.2", "hello-world==0.2, tiny-tiny==0.2"))); + assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, requirements, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); log.clearOutput(); - // freeze requirements with new hello-world - freeze(venvDir, requirements, log, "hello-world==0.2"); + // freeze requirements only with tiny-tiny + freeze(venvDir, requirements, log, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), true); - checkRequirementsFile(requirements, "hello-world==0.2"); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); - checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); + checkRequirementsFile(requirements, "tiny-tiny==0.2"); + // requests transitive deps are gone as well + checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); // try again - createVenv(venvDir, "0.1", log, requirements, "hello-world==0.2"); + createVenv(venvDir, "0.1", log, requirements, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); assertTrue(log.getOutput().contains("Virtual environment is up to date with requirements file")); log.clearOutput(); // reinstall with new graalpy version - createVenv(venvDir, "0.2", log, requirements, "hello-world==0.2"); + createVenv(venvDir, "0.2", log, requirements, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains(STALE_VENV)); assertTrue(log.getOutput().contains("pip install -r")); // requirements file is used - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world==0.2"); - checkVenvContentsFile(contents, "0.2", "hello-world==0.2"); + checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny==0.2"); + checkVenvContentsFile(contents, "0.2", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); log.clearOutput(); } @@ -630,7 +573,6 @@ public void installAndFreeze() throws IOException { @Test public void invalidVersionFormatTest() throws NoSuchMethodException { TestLog log = new TestLog(); - checkWrongPkgVersionFormat("", log); checkWrongPkgVersionFormat("==2.2", log); checkWrongPkgVersionFormat("==", log); checkWrongPkgVersionFormat("somepkg==", log); @@ -647,7 +589,7 @@ private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws N Method m = VFSUtils.class.getDeclaredMethod("checkVersionFormat", List.class, String.class, BuildToolLog.class); m.setAccessible(true); checkException(IOException.class, () -> m.invoke(VFSUtils.class, Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "'" + pkg + "'"))); + assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, pkg))); log.clearOutput(); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index c42e63cd6b..e64b63dd0e 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -509,7 +509,7 @@ private static boolean install(Path venvDirectory, List newPackages, Ven if (needsUpdate) { List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); if (missingRequirementsFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingRequirementsWarning")) { - if (installedPackages.size() != newPackages.size()) { + if (installedPackages.size() > newPackages.size()) { missingRequirementsWarning(log, missingRequirementsFileWarning); } } From 16430c1a65e21dea087386e3c8243d1833f4eaea Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Feb 2025 20:28:40 +0100 Subject: [PATCH 068/512] renamed ManageResourcesMojo to InstallPackagesMojo --- .../{ManageResourcesMojo.java => InstallPackagesMojo.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/{ManageResourcesMojo.java => InstallPackagesMojo.java} (93%) diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java similarity index 93% rename from graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java rename to graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java index 706638d97f..4f6eb2bcc1 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/ManageResourcesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java @@ -52,7 +52,7 @@ @Mojo(name = "process-graalpy-resources", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class ManageResourcesMojo extends AbstractGraalPyMojo { +public class InstallPackagesMojo extends AbstractGraalPyMojo { public void execute() throws MojoExecutionException { preExec(true); @@ -69,7 +69,7 @@ private void manageVenv() throws MojoExecutionException { MavenDelegateLog log = new MavenDelegateLog(getLog()); Path requirements = getRequirementsFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_LIST_CHANGED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, requirements, NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGE_REMOVED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } From b33f0fd1cc4cfd6be719e55a676b6a50e3b996aa Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Feb 2025 20:29:33 +0100 Subject: [PATCH 069/512] minor variable name refactoring --- .../embedding/test/EmbeddingTestUtils.java | 7 +- .../embedding/vfs/test/VFSUtilsTest.java | 65 +++++++++---------- .../maven/plugin/AbstractGraalPyMojo.java | 10 +-- .../python/embedding/tools/vfs/VFSUtils.java | 39 +++++------ .../python/tasks/AbstractPackagesTask.java | 12 ++-- .../python/tasks/InstallPackagesTask.java | 3 +- 6 files changed, 67 insertions(+), 69 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index a887428d2d..71960422f8 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -63,16 +63,15 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog } public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, - String inconsistentPackagesError, String wrongPackageVersionError, String missingRequirementsFileWarning, String packagesListChangedError, - String... packages) - throws IOException { + String newPackageOrVersionError, String wrongPackageVersionError, String missingRequirementsFileWarning, String packageRemovedError, + String... packages) throws IOException { try { info(log, "<<<<<< create test venv %s <<<<<<", venvDir); Launcher launcher = createLauncher(venvDir); if (requirements != null) { VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, - inconsistentPackagesError, wrongPackageVersionError, packagesListChangedError, missingRequirementsFileWarning, + newPackageOrVersionError, wrongPackageVersionError, packageRemovedError, missingRequirementsFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 362dcfbd24..98a5669477 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -67,10 +67,10 @@ public class VFSUtilsTest { - private static final String PACKAGE_WAS_REMOVED = "A package with unknown dependencies was removed since last install, setting up a clean venv"; + private static final String PACKAGE_WAS_REMOVED = "A package with transitive dependencies was removed since last install, setting up a clean venv"; private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; - private static final String INCONSISTENT_PKGS_ERROR = "requirements %s inconsistent with packages %s"; - private static final String PACKAGES_CHANGED_ERROR = "packages changed in requirements file %s, current packages %s, previous packages %s"; + private static final String NEW_PACKAGE_OR_VERSION_ERROR = "requirements %s inconsistent with packages %s"; + private static final String PACKAGE_REMOVED_ERROR = "packages changed in requirements file %s, current packages %s, previous packages %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; @@ -467,7 +467,7 @@ public void installAndFreeze() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "tiny-tiny==0.2"))); + assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "tiny-tiny==0.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); @@ -502,7 +502,7 @@ public void installAndFreeze() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "requests==2.32.2"))); + assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "requests==2.32.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); @@ -541,7 +541,7 @@ public void installAndFreeze() throws IOException { checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, requirements, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); + assertTrue(log.getOutput().contains(String.format(PACKAGE_REMOVED_ERROR, requirements, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); log.clearOutput(); // freeze requirements only with tiny-tiny freeze(venvDir, requirements, log, "tiny-tiny==0.2"); @@ -605,14 +605,14 @@ public void packageConsistency() throws Exception { callPackageConsistencyCheck(log, Collections.emptyList(), requirements); checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.emptyList(), requirements, "pkg1==1")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg1==1"))); + assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg1==1"))); log.clearOutput(); final List requirementsList = Arrays.asList("pkg1==1.0.0"); Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, requirements, "pkg2==1")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg2==1"))); + assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg2==1"))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList, requirements, "pkg1==1.0"); log.clearOutput(); @@ -623,7 +623,7 @@ public void packageConsistency() throws Exception { Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg2==2")); - assertTrue(log.getOutput().contains(String.format(INCONSISTENT_PKGS_ERROR, requirements, "pkg2==2"))); + assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg2==2"))); log.clearOutput(); callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg1==1.0"); log.clearOutput(); @@ -635,44 +635,43 @@ private static void callPackageConsistencyCheck(TestLog log, List requir throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method m = VFSUtils.class.getDeclaredMethod("checkPluginPackagesInRequirementsFile", List.class, List.class, Path.class, String.class, BuildToolLog.class); m.setAccessible(true); - m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, INCONSISTENT_PKGS_ERROR, log); + m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, NEW_PACKAGE_OR_VERSION_ERROR, log); } @Test public void packageRemoved() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException { Path tmpDir = Files.createTempDirectory("packageRemoved"); - Path venvDir = tmpDir.resolve("venv"); deleteDirOnShutdown(tmpDir); - assertFalse(callPackageRemoved(venvDir, Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Collections.emptyList(), Collections.emptyList())); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + assertFalse(callPackageRemoved(Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); + assertFalse(callPackageRemoved(Arrays.asList("pkg1"), Collections.emptyList(), Collections.emptyList())); + assertFalse(callPackageRemoved(Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1=="), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("==pkg1"), Arrays.asList("==pkg1"), Arrays.asList("pkg1==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1==1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertFalse(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("pkg1=="), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("==pkg1"), Arrays.asList("==pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("pkg1==1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertFalse(callPackageRemoved(Arrays.asList("pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Collections.emptyList(), Arrays.asList("pkg"), Arrays.asList("pkg==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + assertTrue(callPackageRemoved(Collections.emptyList(), Arrays.asList("pkg"), Arrays.asList("pkg==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg2"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1"), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1=="), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("==pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1"), Arrays.asList("pkg1=="), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1=="), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(Arrays.asList("==pkg1"), Arrays.asList("pkg1"), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1"), Arrays.asList("pkg1==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1", "pkg2==1"), Arrays.asList("pkg1==1", "pkg2==1"))); - assertTrue(callPackageRemoved(venvDir, Arrays.asList("pkg1==2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1"), Arrays.asList("pkg1==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1==2"), Arrays.asList("pkg1==1", "pkg2==1"), Arrays.asList("pkg1==1", "pkg2==1"))); + assertTrue(callPackageRemoved(Arrays.asList("pkg1==2"), Arrays.asList("pkg1", "pkg2"), Arrays.asList("pkg1==1", "pkg2==1"))); } - private static boolean callPackageRemoved(Path venvDir, List packages, List contents, List installed) + private static boolean callPackageRemoved(List packages, List contents, List installed) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method m = VFSUtils.class.getDeclaredMethod("removedFromPluginPackages", Path.class, List.class, List.class, List.class); + Method m = VFSUtils.class.getDeclaredMethod("removedFromPluginPackages", List.class, List.class, List.class); m.setAccessible(true); - return (boolean) m.invoke(VFSUtils.class, venvDir, packages, contents, installed); + return (boolean) m.invoke(VFSUtils.class, packages, contents, installed); } private interface ExceptionCall { @@ -744,7 +743,7 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, } private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path requirements, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, INCONSISTENT_PKGS_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGES_CHANGED_ERROR, + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGE_REMOVED_ERROR, packages); } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index eeb9c92116..066c4a6766 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -75,10 +75,10 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { protected static final String REQUIREMENTS_FILE_HEADER = """ Generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + WARNING: Any manual changes are done at your own risk and will be overwritten when the goal is executed. + This file contains a list of all required Python packages with their specific versions, based on the packages defined in the plugin configuration and their dependencies. - - WARNING: Any manual changes are done at your own risk. """; @@ -95,14 +95,14 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { When using the graalpy-maven-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. """; - protected static final String INCONSISTENT_PACKAGES_ERROR = """ + protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ Install of python packages is based on requirements file %s, - but some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version: %s. + but some packages in graalpy-maven-plugin configuration are removed since previously used to generate the requirements file. The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. """; - protected static final String PACKAGES_LIST_CHANGED_ERROR = """ + protected static final String PACKAGE_REMOVED_ERROR = """ Install of python packages is based on requirements file %s, but some packages in graalpy-maven-plugin configuration are different then previously used to generate the requirements file. diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index e64b63dd0e..a526019dff 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -281,7 +281,7 @@ public static void createVenv(Path venvDirectory, List packagesArgs, Lau } public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, - String inconsistentPackagesError, String wrongPackageVersionFormatError, String packagesListChangedError, String missingRequirementsFileWarning, + String newPackageOrVersionError, String wrongPackageVersionFormatError, String packagesListChangedError, String missingRequirementsFileWarning, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); @@ -289,7 +289,7 @@ public static void createVenv(Path venvDirectory, List packages, Path re Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); if (requirementsFile != null) { - Objects.requireNonNull(inconsistentPackagesError); + Objects.requireNonNull(newPackageOrVersionError); Objects.requireNonNull(wrongPackageVersionFormatError); Objects.requireNonNull(packagesListChangedError); } @@ -298,7 +298,7 @@ public static void createVenv(Path venvDirectory, List packages, Path re List pluginPackages = trim(packages); List requirementsPackages = requirementsFile != null && Files.exists(requirementsFile) ? readPackagesFromFile(requirementsFile) : null; - if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, wrongPackageVersionFormatError, packagesListChangedError, log)) { + if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, newPackageOrVersionError, wrongPackageVersionFormatError, packagesListChangedError, log)) { return; } @@ -336,17 +336,17 @@ private static boolean removedFromPluginPackages(Path venvDirectory, VenvContent return false; } List installedPackages = InstalledPackages.fromVenv(venvDirectory).packages; - return removedFromPluginPackages(venvDirectory, pluginPackages, venvContents.packages, installedPackages); + return removedFromPluginPackages(pluginPackages, venvContents.packages, installedPackages); } - private static boolean removedFromPluginPackages(Path venvDirectory, List pluginPackages, List contentsPackages, List installedPackages) { + private static boolean removedFromPluginPackages(List pluginPackages, List contentsPackages, List installedPackages) { for (String contentsPackage : contentsPackages) { if (!pluginPackages.contains(contentsPackage)) { - // there is a previously installed package missing in the current plugin packages - // list + // a previously installed package is missing + // in the current plugin packages list if (!contentsPackage.contains("==")) { - // it has no version specified, so lets check if it isn't just requested with a - // version + // it has no version specified, + // lets check if it isn't just requested with a different version String pkgAndVersion = getByName(contentsPackage, pluginPackages); if (pkgAndVersion != null) { // yes, a version was added to a package @@ -404,7 +404,7 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path } } - private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String inconsistentPackagesError, + private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String newPackageOrVersionError, String wrongPackageVersionFormatError, String packagesListChangedError, BuildToolLog log) throws IOException { VenvContents contents = null; if (Files.exists(venvDirectory)) { @@ -414,7 +414,7 @@ private static boolean checkPackages(Path venvDirectory, List pluginPack if (requirementsPackages != null) { checkVersionFormat(pluginPackages, wrongPackageVersionFormatError, log); - checkPluginPackagesInRequirementsFile(pluginPackages, requirementsPackages, requirementsFile, inconsistentPackagesError, log); + checkPluginPackagesInRequirementsFile(pluginPackages, requirementsPackages, requirementsFile, newPackageOrVersionError, log); checkIfRemovedFromPluginPackages(venvDirectory, contents, pluginPackages, requirementsFile, packagesListChangedError, log); logPackages(requirementsPackages, requirementsFile, log); return needVenv(venvDirectory, requirementsPackages, log); @@ -594,19 +594,20 @@ private static void wrongPackageVersionError(BuildToolLog log, String wrongPacka /** * check that there are no plugin packages missing in requirements file */ - private static void checkPluginPackagesInRequirementsFile(List packages, List requiredPackages, Path requirementsFile, String inconsistentPackagesError, BuildToolLog log) + private static void checkPluginPackagesInRequirementsFile(List pluginPackages, List requirementsPackages, Path requirementsFile, String newPackageOrVersionError, BuildToolLog log) throws IOException { - if (packages.isEmpty()) { + if (pluginPackages.isEmpty()) { return; } - Map requiredPackagesMap = requiredPackages.stream().filter(p -> p.contains("==")).map(p -> p.split("==")).collect(Collectors.toMap(parts -> parts[0], parts -> parts[1])); + Map requirementsPackagesMap = requirementsPackages.stream().filter(p -> p.contains("==")).map(p -> p.split("==")).collect( + Collectors.toMap(parts -> parts[0], parts -> parts[1])); List inconsistent = new ArrayList<>(); - for (String pkg : packages) { + for (String pkg : pluginPackages) { String[] s = pkg.split("=="); String pName = s[0]; String pVersion = s[1]; - String rVersion = requiredPackagesMap.get(pName); + String rVersion = requirementsPackagesMap.get(pName); if (rVersion != null && rVersion.startsWith(pVersion)) { continue; } @@ -614,12 +615,12 @@ private static void checkPluginPackagesInRequirementsFile(List packages, } if (!inconsistent.isEmpty()) { - inconsistentPackagesError(log, inconsistentPackagesError, requirementsFile, String.join(", ", inconsistent)); + newPackageOrVersionError(log, newPackageOrVersionError, requirementsFile, String.join(", ", inconsistent)); } } - private static void inconsistentPackagesError(BuildToolLog log, String inconsistentPackagesError, Object... args) throws IOException { - extendedError(log, String.format(inconsistentPackagesError, args) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); + private static void newPackageOrVersionError(BuildToolLog log, String newPackageOrVersionError, Object... args) throws IOException { + extendedError(log, String.format(newPackageOrVersionError, args) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); throw new IOException("inconsistent packages"); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 65f08c926a..ab8bc272ea 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -82,10 +82,10 @@ public abstract class AbstractPackagesTask extends DefaultTask { protected static final String REQUIREMENTS_FILE_HEADER = """ This file was generated by gradle task 'graalpyFreezeInstalledPackages'. - This file contains a list of all required Python packages with their specific versions, - based on the packages defined in the plugin configuration and their dependencies. + WARNING: Any manual changes are done at your own risk and will be overwritten when the task is executed. - WARNING: Any manual changes are done at your own risk. + This file contains a list of all required Python packages with their specific versions, + based on the packages defined in the plugin configuration and their dependencies. """; @@ -102,16 +102,16 @@ public abstract class AbstractPackagesTask extends DefaultTask { When using the graalpy-gradle-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. """; - protected static final String INCONSISTENT_PACKAGES_ERROR = """ + protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ Install of python packages is based on requirements file %s, but some packages in graalpy-gradle-plugin configuration are either missing in requirements file or have a different version: %s. The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. """; - protected static final String PACKAGES_LIST_CHANGED_ERROR = """ + protected static final String PACKAGE_REMOVED_ERROR = """ Install of python packages is based on requirements file %s, - but some packages in graalpy-gradle-plugin configuration are different then previously used to generate the requirements file. + but some packages in graalpy-gradle-plugin configuration were removed since previously used to generate the requirements file. Packages currently declared in graalpy-gradle-plugin configuration: %s Packages which were used to generate the requirements file: %s diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 9b3eed33e1..6d282a56b0 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -45,7 +45,6 @@ import org.gradle.api.tasks.*; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; import org.graalvm.python.embedding.tools.vfs.VFSUtils; @@ -71,7 +70,7 @@ public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { VFSUtils.createVenv(venvDirectory, getPackages().get(), getRequirementsPath(), - INCONSISTENT_PACKAGES_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_LIST_CHANGED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, + NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGE_REMOVED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); From 6f80ec1912a78e0b782883be83c5ad8237c71d1c Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Feb 2025 18:19:43 +0100 Subject: [PATCH 070/512] added gate for VFSUtils test --- ci.jsonnet | 2 +- mx.graalpython/mx_graalpython.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ci.jsonnet b/ci.jsonnet index 0afcce4291..5480f56ead 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "ac2b03008a765064fba41da97cbcd096f6d19809" } +{ "overlay": "9682e88c454813f57f9104b481421538895239b5" } diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index e52c7987ad..e2eb6563b0 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -415,10 +415,6 @@ def __str__(self): TestConfig("multi-cext", vm_args + ['org.graalvm.python.embedding.cext.test'] + args + (["--use-graalvm"] if has_compiler else []), True), ) - configs.append( - TestConfig("vfsutil", vm_args + ['org.graalvm.python.embedding.vfs.test'] + args + (["--use-graalvm"] if has_compiler else []), True), - ) - if '--regex' not in args: async_regex = ['--regex', r'com\.oracle\.graal\.python\.test\.integration\.advanced\.AsyncActionThreadingTest'] configs.append(TestConfig("async", vm_args + ['-Dpython.AutomaticAsyncActions=false', 'com.oracle.graal.python.test', 'org.graalvm.python.embedding.test'] + async_regex + args, True, False)) @@ -496,6 +492,7 @@ class GraalPythonTags(object): unittest_gradle_plugin_long_run = 'python-unittest-gradle-plugin-long-run' unittest_maven_plugin = 'python-unittest-maven-plugin' unittest_maven_plugin_long_run = 'python-unittest-maven-plugin-long-run' + junit_vfsutils = 'python-junit-vfsutils' tagged = 'python-tagged-unittest' svmunit = 'python-svm-unittest' svmunit_sandboxed = 'python-svm-unittest-sandboxed' @@ -1213,7 +1210,7 @@ def graalpython_gate_runner(args, tasks): "--verbose", "--no-leak-tests", "--regex", - r'((graal\.python\.test\.integration)|(graal\.python\.test\.(builtin|interop|util))|(org\.graalvm\.python\.embedding\.(test|test\.integration))|(org\.graalvm\.python\.embedding\.vfs\.test))' + r'((graal\.python\.test\.integration)|(graal\.python\.test\.(builtin|interop|util))|(org\.graalvm\.python\.embedding\.(test|test\.integration)))' ], report=True ) @@ -1393,7 +1390,7 @@ def graalpython_gate_runner(args, tasks): parallel=3, ) - with Task('GraalPython maven plugin long runnning tests', tasks, tags=[GraalPythonTags.unittest_maven_plugin_long_run]) as task: + with Task('GraalPython maven plugin long running tests', tasks, tags=[GraalPythonTags.unittest_maven_plugin_long_run]) as task: if task: standalone_home, env = setup_maven_plugin_tests() env['ENABLE_MAVEN_PLUGIN_LONG_RUNNING_UNITTESTS'] = 'true' @@ -1408,6 +1405,12 @@ def graalpython_gate_runner(args, tasks): parallel=3, ) + with Task('GraalPython VFSUtils long running tests', tasks, tags=[GraalPythonTags.junit_vfsutils]) as task: + if task: + args =['--verbose'] + vm_args = ['-Dpolyglot.engine.WarnInterpreterOnly=false'] + mx_unittest.unittest(vm_args + ['org.graalvm.python.embedding.vfs.test'] + args + ["--use-graalvm"]) + with Task('GraalPython Python tests', tasks, tags=[GraalPythonTags.tagged]) as task: if task: # don't fail this task if we're running with the jacoco agent, we know that some tests don't pass with it enabled From 7c9cdd2b49e2f01388dd76210aa376bc467bddb1 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 12 Feb 2025 17:04:23 +0100 Subject: [PATCH 071/512] minor logging changes in VFSUtils --- .../maven/plugin/AbstractGraalPyMojo.java | 18 +++++++++++++++--- .../python/embedding/tools/vfs/VFSUtils.java | 19 +++++++++++-------- .../python/tasks/AbstractPackagesTask.java | 18 +++++++++++++++--- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index 066c4a6766..04b23c4061 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -87,19 +87,28 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { Additional python dependencies were installed besides the packages declared in graalpy-maven-plugin configuration. It is highly recommended to freeze python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ Some python packages in graalpy-maven-plugin configuration have no exact version declared: %s When using the graalpy-maven-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ Install of python packages is based on requirements file %s, - but some packages in graalpy-maven-plugin configuration are removed since previously used to generate the requirements file. + but some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version: %s. - The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String PACKAGE_REMOVED_ERROR = """ @@ -109,7 +118,10 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { Packages currently declared in graalpy-maven-plugin configuration: %s Packages which were used to generate the requirements file: %s - The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; @Parameter(defaultValue = "${project}", required = true, readonly = true) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index a526019dff..b1974e4762 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -90,8 +90,6 @@ public final class VFSUtils { private static final String GRAALPY_MAIN_CLASS = "com.oracle.graal.python.shell.GraalPythonMain"; - private static final String FOR_MORE_INFO_REFERENCE_MSG = "For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools"; - public static void writeNativeImageConfig(Path metaInfRoot, String pluginId) throws IOException { writeNativeImageConfig(metaInfRoot, pluginId, VFS_ROOT); } @@ -422,7 +420,7 @@ private static boolean checkPackages(Path venvDirectory, List pluginPack if (removedFromPluginPackages(venvDirectory, contents, pluginPackages)) { // a package was removed, and we do not know if it did not leave behind any // transitive dependencies - rather create whole venv again to avoid it growing - info(log, "A package with unknown dependencies was removed since last install, setting up a clean venv"); + info(log, "A package with transitive dependencies was removed since last install, setting up a clean venv"); delete(venvDirectory); } logPackages(pluginPackages, null, log); @@ -445,9 +443,14 @@ private static boolean needVenv(Path venvDirectory, List packages, Build private static void logPackages(List packages, Path requirementsFile, BuildToolLog log) { if (requirementsFile != null) { - info(log, "There is %s python package(s) in requirements file: %s", packages.size(), requirementsFile); + info(log, "Got %s python package(s) in requirements file: %s", packages.size(), requirementsFile); } else { - info(log, "There is %s python package(s) in GraalPy plugin configuration", packages.size()); + info(log, "Got %s python package(s) in GraalPy plugin configuration", packages.size()); + } + if (log.isDebugEnabled()) { + for (String pkg : packages) { + log.debug(" " + pkg); + } } } @@ -520,7 +523,7 @@ private static boolean install(Path venvDirectory, List newPackages, Ven private static void missingRequirementsWarning(BuildToolLog log, String missingRequirementsFileWarning) { if (log.isWarningEnabled()) { - String txt = missingRequirementsFileWarning + "\n" + FOR_MORE_INFO_REFERENCE_MSG + "\n"; + String txt = missingRequirementsFileWarning + "\n"; for (String t : txt.split("\n")) { log.warning(t); } @@ -587,7 +590,7 @@ private static boolean checkValidPackageVersion(String pkg) { } private static void wrongPackageVersionError(BuildToolLog log, String wrongPackageVersionFormatError, String pkgs) throws IOException { - extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); + extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n"); throw new IOException("invalid package format: " + pkgs); } @@ -620,7 +623,7 @@ private static void checkPluginPackagesInRequirementsFile(List pluginPac } private static void newPackageOrVersionError(BuildToolLog log, String newPackageOrVersionError, Object... args) throws IOException { - extendedError(log, String.format(newPackageOrVersionError, args) + "\n" + FOR_MORE_INFO_REFERENCE_MSG); + extendedError(log, String.format(newPackageOrVersionError, args) + "\n"); throw new IOException("inconsistent packages"); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index ab8bc272ea..56eb8c5410 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -94,19 +94,28 @@ public abstract class AbstractPackagesTask extends DefaultTask { WARNING: Additional python dependencies were installed besides the packages declared in graalpy-gradle-plugin configuration. WARNING: It is highly recommended to freeze python dependencies by running the gradle task 'graalpyFreezeInstalledPackages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ Some python packages in graalpy-gradle-plugin configuration have no exact version declared: %s - When using the graalpy-gradle-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + When using the graalpy-gradle-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ Install of python packages is based on requirements file %s, - but some packages in graalpy-gradle-plugin configuration are either missing in requirements file or have a different version: %s. + but some packages in graalpy-gradle-plugin configuration are either missing in the requirements file or have a different version: %s. The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; protected static final String PACKAGE_REMOVED_ERROR = """ @@ -116,7 +125,10 @@ public abstract class AbstractPackagesTask extends DefaultTask { Packages currently declared in graalpy-gradle-plugin configuration: %s Packages which were used to generate the requirements file: %s - The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; /** @see #getOutput() */ From aa80f49db8f0d8211357445841036360ec1f1238 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 12 Feb 2025 17:05:01 +0100 Subject: [PATCH 072/512] added docs for freeze packages in gradle and maven plugins --- docs/user/Embedding-Build-Tools.md | 77 ++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/docs/user/Embedding-Build-Tools.md b/docs/user/Embedding-Build-Tools.md index 3b845cabc1..ef2f6d8460 100644 --- a/docs/user/Embedding-Build-Tools.md +++ b/docs/user/Embedding-Build-Tools.md @@ -79,7 +79,35 @@ Any manual change will be overridden by the plugin during the build. The _src_ subdirectory is left to be manually populated by the user with custom Python scripts or modules. -## GraalPy Maven Plugin Configuration +## Python Dependency Management +To manage third-party Python packages, a [Python virtual environment](https://docs.python.org/3.11/tutorial/venv.html) is used behind the scenes. +Whether deployed in a virtual filesystem or an external directory, its contents are solely managed by the plugin based on the Python packages +specified in the plugin configuration or a Python requirements file. + +If a requirements file is provided, it is used exclusively for downloading and installing Python packages. +If the file does not exist, the package list from the plugin configuration is used. +In the case where both a requirements file exists and packages are specified in the plugin configuration, +the packages in the configuration must be an exact subset of those listed in the requirements file. + +### Freezing Dependencies +When installing packages, additional dependencies may be pulled into the virtual environment. Since Python does not +enforce exact versioning of dependencies, this can lead to issues if a third-party package or one of its transitive dependencies +is suddenly updated to a newer version, causing unexpected behavior. + +In simpler scenarios, where only a few packages are needed, it may be sufficient to specify each package and +its exact version in the plugin configuration. However, this approach is not always practical, and manually managing +the entire dependency tree can quickly become cumbersome. + +For these cases, we **highly recommend freezing** all Python dependencies whenever there is a change in the required packages for the project. +As a result a requirements file will be created listing all required Python packages with their specific versions, based on the packages defined +in the plugin configuration and their dependencies. Subsequent GraalPy plugin executions will then use this file exclusively to install all packages +with a guaranteed version. + +For information on the specific Maven or Gradle freeze commands, please refer to the plugin descriptions below in this document. + +## GraalPy Maven Plugin + +### Maven Plugin Configuration Add the plugin configuration in the `configuration` block of `graalpy-maven-plugin` in the _pom.xml_ file: ```xml @@ -104,7 +132,16 @@ The Python packages and their versions are specified as if used with `pip`: ...
    ``` - +- The **requirementsFile** element can specify the path to a Python requirements file which has to follow +the python [requirements file format](https://pip.pypa.io/en/stable/reference/requirements-file-format/). +Default value is `${basedir}/requirements.txt`. + ```xml + + ${basedir}/python-requirements.txt + ... + + ``` + - The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path). Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java. ```xml @@ -119,9 +156,21 @@ Remember to use the appropriate `GraalPyResources` API to create the Context. Th ... ``` + +### Freezing Installed Packages +To freeze the current state of the installed packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages`. +```bash +$ mvn org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages +``` +*Note that the action will override the existing requirements file, no matter if it was previously generated by the plugin or created manually.* -## GraalPy Gradle Plugin Configuration +For more information on managing Python packages and working with a requirements file, please refer to the descriptions of +the `requirementsFile` and `packages` fields in the [plugin configuration](#maven-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) section +above in this document. +## GraalPy Gradle Plugin + +### Gradle Plugin Configuration The plugin must be added to the plugins section in the _build.gradle_ file. The **version** property defines which version of GraalPy to use. ``` @@ -146,6 +195,16 @@ The plugin can be configured in the `graalPy` block: } ``` +- The **requirementsFile** element can specify the path to a Python requirements file which has to follow + the python [requirements file format](https://pip.pypa.io/en/stable/reference/requirements-file-format/). + Default value is `$rootDir/requirements.txt`. + ``` + graalPy { + requirementsFile = file("$rootDir/python-requirements.txt") + ... + } + ``` + - The **resourceDirectory** element can specify the relative [Java resource path](#java-resource-path). Remember to use `VirtualFileSystem$Builder#resourceDirectory` when configuring the `VirtualFileSystem` in Java. ``` @@ -168,8 +227,18 @@ dependency `org.graalvm.python:python` to the community build: `org.graalvm.pyth ... } ``` +### Freezing Installed Packages +To freeze the current state of the installed packages, execute the GraalPy plugin task `graalpyFreezeInstalledPackages`. +```bash +$ gradle graalpyFreezeInstalledPackages +``` +*Note that the action will override the existing requirements file, no matter if it was previously generated by the plugin or created manually.* + +For more information on managing Python packages and working with a requirements file, please refer to the descriptions of +the `requirementsFile` and `packages` fields in the [plugin configuration](#gradle-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) sections +in this document. -### Related Documentation +## Related Documentation * [Embedding Graal languages in Java](https://www.graalvm.org/reference-manual/embed-languages/) * [Permissions for Python Embeddings](Embedding-Permissions.md) From af926f3d886d7b1272ecc9cc0a4b9b5082bae18f Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 14 Feb 2025 13:30:25 +0100 Subject: [PATCH 073/512] - replaced requirements.txt with gradle.lock and changed format - merged errors when plugin packages changed into one generic --- .../embedding/test/EmbeddingTestUtils.java | 10 +- .../embedding/vfs/test/VFSUtilsTest.java | 424 ++++++++---------- .../tests/standalone/test_gradle_plugin.py | 78 ++-- .../src/tests/standalone/test_maven_plugin.py | 54 +-- .../maven/plugin/AbstractGraalPyMojo.java | 49 +- .../maven/plugin/InstallPackagesMojo.java | 4 +- ...ackagesMojo.java => LockPackagesMojo.java} | 12 +- .../python/embedding/tools/vfs/VFSUtils.java | 290 +++++++----- .../graalvm/python/GraalPyGradlePlugin.java | 14 +- .../graalvm/python/dsl/GraalPyExtension.java | 8 +- .../python/tasks/AbstractPackagesTask.java | 46 +- .../python/tasks/InstallPackagesTask.java | 4 +- ...ackagesTask.java => LockPackagesTask.java} | 12 +- 13 files changed, 502 insertions(+), 503 deletions(-) rename graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/{FreezeInstalledPackagesMojo.java => LockPackagesMojo.java} (88%) rename graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/{FreezeInstalledPackagesTask.java => LockPackagesTask.java} (83%) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index 71960422f8..c49d1a6419 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -62,16 +62,16 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog createVenv(venvDir, graalPyVersion, log, null, null, null, null, null, packages); } - public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path requirements, - String newPackageOrVersionError, String wrongPackageVersionError, String missingRequirementsFileWarning, String packageRemovedError, + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile, + String lockFileHeader, String wrongPackageVersionError, String missingLockFileWarning, String packageRemovedError, String... packages) throws IOException { try { info(log, "<<<<<< create test venv %s <<<<<<", venvDir); Launcher launcher = createLauncher(venvDir); - if (requirements != null) { - VFSUtils.createVenv(venvDir, Arrays.asList(packages), requirements, - newPackageOrVersionError, wrongPackageVersionError, packageRemovedError, missingRequirementsFileWarning, + if (lockFile != null) { + VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile, + lockFileHeader, wrongPackageVersionError, packageRemovedError, missingLockFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 98a5669477..6ab2667038 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -47,6 +47,7 @@ import org.junit.Test; import java.io.IOException; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.file.Files; @@ -67,12 +68,27 @@ public class VFSUtilsTest { + private static final String GRAALPY_VERSION_PREFIX; + private static final String INPUT_PACKAGES_PREFIX; + + static { + try { + Field f = VFSUtils.class.getDeclaredField("GRAALPY_VERSION_PREFIX"); + f.setAccessible(true); + GRAALPY_VERSION_PREFIX = (String) f.get(VFSUtils.class); + f = VFSUtils.class.getDeclaredField("INPUT_PACKAGES_PREFIX"); + f.setAccessible(true); + INPUT_PACKAGES_PREFIX = (String) f.get(VFSUtils.class); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + private static final String PACKAGE_WAS_REMOVED = "A package with transitive dependencies was removed since last install, setting up a clean venv"; - private static final String REQUIREMENTS_HEADER = "generated by graalpy tests\nwith a two line header"; - private static final String NEW_PACKAGE_OR_VERSION_ERROR = "requirements %s inconsistent with packages %s"; - private static final String PACKAGE_REMOVED_ERROR = "packages changed in requirements file %s, current packages %s, previous packages %s"; + private static final String LOCK_FILE_HEADER = "generated by graalpy tests\nwith a two line header"; + private static final String PACKAGES_CHANGED_ERROR = "packages changed in lock file %s, current packages %s, previous packages %s"; private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; - private static final String MISSING_REQUIREMENTS_FILE_WARNING = "missing requirements file"; + private static final String MISSING_LOCK_FILE_WARNING = "missing lock file"; private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; private static final class TestLog implements BuildToolLog { @@ -164,10 +180,9 @@ private static boolean isVerbose() { } /** - * tests scenarios without requirements file logic available, but not used + * tests scenarios without lock file logic available, but not used * - * - packages declared only in plugin config - requirement file path is provided, but does not - * exist + * - packages declared only in plugin config - lock file path is provided, but does not exist */ @Test public void withPackagesOnlyFromPluginConfig() throws IOException { @@ -176,15 +191,15 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { Path venvDir = tmpDir.resolve("venv"); deleteDirOnShutdown(tmpDir); - // test with a not existing requirements path - // the maven and gradle plugins always send the default requirements path, no matter if the + // test with a not existing lock file path + // the maven and gradle plugins always send the default lock file path, no matter if the // file exists or not - Path requirements = tmpDir.resolve("requirements.txt"); + Path lockFile = tmpDir.resolve("lockFile.txt"); Path contents = venvDir.resolve("contents"); - // no packages, requirements file does not exist - does nothing + // no packages, lock file file does not exist - does nothing log.clearOutput(); - createVenv(venvDir, "0.1", log, requirements); + createVenv(venvDir, "0.1", log, lockFile); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); @@ -193,7 +208,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { // install packages log.clearOutput(); - createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); + createVenv(venvDir, "0.1", log, lockFile, "hello-world", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); @@ -202,7 +217,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { // install packages again, assert that venv wasn't created and packages weren't installed log.clearOutput(); - createVenv(venvDir, "0.1", log, requirements, "hello-world", "tiny-tiny"); + createVenv(venvDir, "0.1", log, lockFile, "hello-world", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); @@ -214,7 +229,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { // remove tiny-tiny, assert that venv was deleted and created anew as we don't know if there // were any transitive deps left log.clearOutput(); - createVenv(venvDir, "0.1", log, requirements, "hello-world"); + createVenv(venvDir, "0.1", log, lockFile, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains(PACKAGE_WAS_REMOVED)); @@ -227,7 +242,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { // install only hello-world again, assert that venv wasn't created and // packages weren't installed log.clearOutput(); - createVenv(venvDir, "0.1", log, requirements, "hello-world"); + createVenv(venvDir, "0.1", log, lockFile, "hello-world"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); @@ -238,14 +253,14 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { } /** - * tests scenarios without requirements file logic - e.g. when called from jbang + * tests scenarios without lock file logic - e.g. when called from jbang * - * - packages declared only in plugin config - and requirement file path is not provided + * - packages declared only in plugin config - and lock file path is not provided */ @Test - public void withoutRequirementsFile() throws IOException { + public void withoutLockFile() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("withoutRequirementsFile"); + Path tmpDir = Files.createTempDirectory("withoutLockFile"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); @@ -259,7 +274,7 @@ public void withoutRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, "hello-world==0.1"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); log.clearOutput(); @@ -267,7 +282,7 @@ public void withoutRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, "hello-world==0.1", "tiny-tiny"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1", "tiny-tiny"); log.clearOutput(); @@ -275,177 +290,146 @@ public void withoutRequirementsFile() throws IOException { createVenv(venvDir, "0.1", log, "hello-world==0.1"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world==0.1"); log.clearOutput(); } - /** - * python packages managed only by requirements file - */ @Test - public void onlyRequirementsFile() throws IOException { + public void lockFile() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("onlyRequirementsFile"); + Path tmpDir = Files.createTempDirectory("emptyLockFile"); Path venvDir = tmpDir.resolve("venv"); - Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); - Path requirements = tmpDir.resolve("requirements.txt"); + Path lockFile = tmpDir.resolve("graalpy.lock"); - writeRequirementsFile(requirements); - createVenv(venvDir, "0.1", log, requirements); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - assertFalse(Files.exists(venvDir.resolve("installed.txt"))); - log.clearOutput(); + Files.createFile(lockFile); - writeRequirementsFile(requirements, "hello-world"); - createVenv(venvDir, "0.1", log, requirements); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), true); - assertTrue(log.getOutput().contains("pip install -r")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1"); - log.clearOutput(); + createWithLockFile(venvDir, lockFile, log); - writeRequirementsFile(requirements, "tiny-tiny"); - createVenv(venvDir, "0.1", log, requirements); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains("pip install -r")); - assertTrue(log.getOutput().contains("pip uninstall")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny"); - checkVenvContentsFile(contents, "0.1"); - log.clearOutput(); + List validLockFileHeader = createLockFileHeader("0.1"); - writeRequirementsFile(requirements, "tiny-tiny", "hello-world"); - createVenv(venvDir, "0.1", log, requirements); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains("pip install -r")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); - checkVenvContentsFile(contents, "0.1"); - log.clearOutput(); - - writeRequirementsFile(requirements, "tiny-tiny==0.1", "hello-world"); - createVenv(venvDir, "0.1", log, requirements); - assertTrue(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains("pip install -r")); - assertTrue(log.getOutput().contains("pip uninstall")); - checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny==0.1"); - checkVenvContentsFile(contents, "0.1"); - log.clearOutput(); + List lockFileList; + int headerLineCount = LOCK_FILE_HEADER.split("\n").length; + // bogus line in header comment + for (int i = 0; i < headerLineCount - 1; i++) { + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(i, "test"); + createWithLockFile(venvDir, lockFile, log, lockFileList); + } - // check that freeze rewrites an existing requirements file - writeRequirementsFile(requirements); // no packages - freeze(venvDir, requirements, log, "hello-world==0.1", "tiny-tiny==0.1"); - checkRequirementsFile(requirements, "hello-world==0.1", "tiny-tiny==0.1"); - log.clearOutput(); + // bogus graalPyVersion line + int graalpVersionLineIdx = headerLineCount; + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(graalpVersionLineIdx, "test"); + createWithLockFile(venvDir, lockFile, log, lockFileList); + + // empty graalPyVersion line + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(graalpVersionLineIdx, GRAALPY_VERSION_PREFIX); + createWithLockFile(venvDir, lockFile, log, lockFileList); + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(graalpVersionLineIdx, GRAALPY_VERSION_PREFIX + " "); + createWithLockFile(venvDir, lockFile, log, lockFileList); + + // bogus input packages line + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(3, "test"); + createWithLockFile(venvDir, lockFile, log, lockFileList); + + // empty input packages line + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(3, INPUT_PACKAGES_PREFIX); + createWithLockFile(venvDir, lockFile, log, lockFileList); + lockFileList = new ArrayList<>(validLockFileHeader); + lockFileList.set(3, INPUT_PACKAGES_PREFIX + " "); + createWithLockFile(venvDir, lockFile, log, lockFileList); } - /** - * requirement file exists but is empty - */ - @Test - public void emptyRequirements() throws IOException { - TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("emptyRequirements"); - Path venvDir = tmpDir.resolve("venv"); - deleteDirOnShutdown(tmpDir); - - Path requirements = tmpDir.resolve("requirements.txt"); - - Files.createFile(requirements); - - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "hello-world")); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "hello-world"))); - assertFalse(log.getOutput().contains("pip install")); - log.clearOutput(); - - createVenv(venvDir, "0.1", log, requirements); - assertFalse(Files.exists(venvDir)); - checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - log.clearOutput(); + private static void createWithLockFile(Path venvDir, Path lockFile, TestLog log, List lines) throws IOException { + createWithLockFile(venvDir, lockFile, log, lines.toArray(new String[lines.size()])); + } - createVenv(venvDir, "0.2", log, requirements); + private static void createWithLockFile(Path venvDir, Path lockFile, TestLog log, String... lines) throws IOException { + Files.write(lockFile, new ArrayList<>(Arrays.asList(lines)), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile), "invalid lock file format"); assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); log.clearOutput(); } - private static void freeze(Path venvDir, Path requirements, TestLog log, String... packages) throws IOException { - VFSUtils.freezePackages(venvDir, Arrays.asList(packages), requirements, REQUIREMENTS_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); + private static void lock(Path venvDir, Path lockFile, TestLog log, String... packages) throws IOException { + VFSUtils.lockPackages(venvDir, Arrays.asList(packages), lockFile, LOCK_FILE_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); } - private static void writeRequirementsFile(Path requirements, String... packages) throws IOException { - List lines = new ArrayList<>(Arrays.asList("# " + String.join("\n# ", REQUIREMENTS_HEADER.split("\n")))); - lines.addAll(Arrays.asList(packages)); - Files.write(requirements, lines, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + private static List createLockFileHeader(String graalPyVersion, String... packages) { + List lines = new ArrayList<>(); + for (String s : LOCK_FILE_HEADER.split("\n")) { + lines.add("# " + s); + } + lines.add(GRAALPY_VERSION_PREFIX + graalPyVersion); + lines.add(INPUT_PACKAGES_PREFIX + String.join(",", packages)); + return lines; } @Test - public void installAndFreeze() throws IOException { + public void installAndLock() throws IOException { TestLog log = new TestLog(); - Path tmpDir = Files.createTempDirectory("installAndFreeze"); + Path tmpDir = Files.createTempDirectory("installAndLock"); Path venvDir = tmpDir.resolve("venv"); Path contents = venvDir.resolve("contents"); deleteDirOnShutdown(tmpDir); - Path requirements = tmpDir.resolve("requirements.txt"); + Path lockFile = tmpDir.resolve("graalpy.lock"); - // install request from plugin config, it pulls in transitive pkgs and - // we get the missing requirements file warning - createVenv(venvDir, "0.1", log, requirements, "requests"); + // install request from plugin config, it pulls in transitive pkgs, and + // we get the missing lock file warning + createVenv(venvDir, "0.1", log, lockFile, "requests"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests"); - assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // freeze requirements without version - fails - checkException(IOException.class, () -> freeze(venvDir, requirements, log, "requests")); - assertFalse(Files.exists(requirements)); + // lock without version - fails + checkException(IOException.class, () -> lock(venvDir, lockFile, log, "requests")); + assertFalse(Files.exists(lockFile)); assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); - // freeze requirements with version - ok - freeze(venvDir, requirements, log, "requests==2.32.2"); - checkRequirementsFile(requirements, "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); + // lock with version - ok + lock(venvDir, lockFile, log, "requests==2.32.2"); + checkLockFile(lockFile, new String[]{"requests==2.32.2"}, "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // reinstall without exact version declared - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests")); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests")); checkVenvCreate(log.getOutput(), false); assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // reinstall again - no more warning delete(venvDir); - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2"); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // reinstall with lower version - ok - Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1"); + Files.delete(lockFile); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1"); // we changed version from 2.32.2 to 2.32.1, we do not know if the prev version did not // leave // any transitive deps, so the venv is deleted and created again @@ -453,64 +437,64 @@ public void installAndFreeze() throws IOException { assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); - assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // freeze requirements - freeze(venvDir, requirements, log, "requests==2.32.1"); - checkRequirementsFile(requirements, "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); + // lock + lock(venvDir, lockFile, log, "requests==2.32.1"); + checkLockFile(lockFile, new String[]{"requests==2.32.1"}, "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // add tiny-tiny - fails because inconsistent with requirements file - assert Files.exists(requirements); - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2")); + // add tiny-tiny - fails because inconsistent with lock file + assert Files.exists(lockFile); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "tiny-tiny==0.2"))); + assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "requests==2.32.1, tiny-tiny==0.2", "requests==2.32.1"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // delete requirements and try again tiny-tiny - now ok - Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2"); + // delete lock and try again tiny-tiny - now ok + Files.delete(lockFile); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); - assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // freeze requirements - freeze(venvDir, requirements, log, "requests==2.32.1", "tiny-tiny==0.2"); - checkRequirementsFile(requirements, "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + // lock + lock(venvDir, lockFile, log, "requests==2.32.1", "tiny-tiny==0.2"); + checkLockFile(lockFile, new String[]{"requests==2.32.1", "tiny-tiny==0.2"}, "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // install again - OK - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.1", "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // update in declared packages requests version back to 2.32.2 - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2")); + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "requests==2.32.2"))); + assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "requests==2.32.2, tiny-tiny==0.2", "requests==2.32.1, tiny-tiny==0.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // delete requirements and try again new hello-world version - now ok - Files.delete(requirements); - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2"); + // delete lock and try again new hello-world version - now ok + Files.delete(lockFile); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2", "tiny-tiny==0.2"); // we changed version from 2.32.2 to 2.32.1, we do not know if the prev version did not // leave // any transitive deps, so the venv is deleted and created again @@ -518,55 +502,55 @@ public void installAndFreeze() throws IOException { assertTrue(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2", "tiny-tiny==0.2"); - assertTrue(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // freeze requirements with new requests version - freeze(venvDir, requirements, log, "requests==2.32.2", "tiny-tiny==0.2"); + // lock with new requests version + lock(venvDir, lockFile, log, "requests==2.32.2", "tiny-tiny==0.2"); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); - checkRequirementsFile(requirements, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + checkLockFile(lockFile, new String[]{"requests==2.32.2", "tiny-tiny==0.2"}, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // install again - OK - createVenv(venvDir, "0.1", log, requirements, "requests==2.32.2", "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2", "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); - checkRequirementsFile(requirements, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); + checkLockFile(lockFile, new String[]{"requests==2.32.2", "tiny-tiny==0.2"}, "requests==2.32.2", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // remove requests from packages list - fails because it is still in requirements - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, requirements, "tiny-tiny==0.2")); + // remove requests from packages list - fails because it is still in lock + checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGE_REMOVED_ERROR, requirements, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); + assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); log.clearOutput(); - // freeze requirements only with tiny-tiny - freeze(venvDir, requirements, log, "tiny-tiny==0.2"); + // lock only with tiny-tiny + lock(venvDir, lockFile, log, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), true); - checkRequirementsFile(requirements, "tiny-tiny==0.2"); + checkLockFile(lockFile, new String[]{"tiny-tiny==0.2"}, "tiny-tiny==0.2"); // requests transitive deps are gone as well checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.1", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); // try again - createVenv(venvDir, "0.1", log, requirements, "tiny-tiny==0.2"); + createVenv(venvDir, "0.1", log, lockFile, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains("Virtual environment is up to date with requirements file")); + assertTrue(log.getOutput().contains("Virtual environment is up to date with lock file")); log.clearOutput(); // reinstall with new graalpy version - createVenv(venvDir, "0.2", log, requirements, "tiny-tiny==0.2"); + createVenv(venvDir, "0.2", log, lockFile, "tiny-tiny==0.2"); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains(STALE_VENV)); - assertTrue(log.getOutput().contains("pip install -r")); // requirements file is used + assertTrue(log.getOutput().contains("pip install -r")); // lock file is used checkInstalledPackages(venvDir.resolve("installed.txt"), "tiny-tiny==0.2"); checkVenvContentsFile(contents, "0.2", "tiny-tiny==0.2"); - assertFalse(log.getOutput().contains(MISSING_REQUIREMENTS_FILE_WARNING)); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); } @@ -593,51 +577,6 @@ private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws N log.clearOutput(); } - @Test - public void packageConsistency() throws Exception { - TestLog log = new TestLog(); - - Path tmpDir = Files.createTempDirectory("packageConsistency"); - deleteDirOnShutdown(tmpDir); - Path requirements = tmpDir.resolve("requirements.txt"); - Files.createFile(requirements); - - callPackageConsistencyCheck(log, Collections.emptyList(), requirements); - - checkException(IOException.class, () -> callPackageConsistencyCheck(log, Collections.emptyList(), requirements, "pkg1==1")); - assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg1==1"))); - log.clearOutput(); - - final List requirementsList = Arrays.asList("pkg1==1.0.0"); - Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - - checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList, requirements, "pkg2==1")); - assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg2==1"))); - log.clearOutput(); - callPackageConsistencyCheck(log, requirementsList, requirements, "pkg1==1.0"); - log.clearOutput(); - callPackageConsistencyCheck(log, requirementsList, requirements, "pkg1==1.0.0"); - log.clearOutput(); - - final List requirementsList2 = Arrays.asList("pkg1==1.0.0", "pkg2==1.0.0"); - Files.write(requirements, requirementsList, StandardOpenOption.TRUNCATE_EXISTING); - - checkException(IOException.class, () -> callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg2==2")); - assertTrue(log.getOutput().contains(String.format(NEW_PACKAGE_OR_VERSION_ERROR, requirements, "pkg2==2"))); - log.clearOutput(); - callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg1==1.0"); - log.clearOutput(); - callPackageConsistencyCheck(log, requirementsList2, requirements, "pkg1==1.0", "pkg2==1.0.0"); - log.clearOutput(); - } - - private static void callPackageConsistencyCheck(TestLog log, List requirementsList, Path requirements, String... packages) - throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method m = VFSUtils.class.getDeclaredMethod("checkPluginPackagesInRequirementsFile", List.class, List.class, Path.class, String.class, BuildToolLog.class); - m.setAccessible(true); - m.invoke(VFSUtils.class, Arrays.asList(packages), requirementsList, requirements, NEW_PACKAGE_OR_VERSION_ERROR, log); - } - @Test public void packageRemoved() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException { Path tmpDir = Files.createTempDirectory("packageRemoved"); @@ -679,6 +618,10 @@ private interface ExceptionCall { } private static void checkException(Class cls, ExceptionCall c) { + checkException(cls, c, null); + } + + private static void checkException(Class cls, ExceptionCall c, String msg) { try { c.call(); } catch (Exception e) { @@ -687,6 +630,9 @@ private static void checkException(Class cls, ExceptionCall c) { } else { assertEquals(cls, e.getClass()); } + if (msg != null) { + assertEquals(msg, e.getMessage()); + } } } @@ -700,26 +646,23 @@ private static void checkVenvCreate(String output, boolean b) { } } - private static void checkInstalledPackages(Path requirements, String... packages) throws IOException { - checkPackages(requirements, null, packages); - } - - private static void checkRequirementsFile(Path requirements, String... packages) throws IOException { - checkPackages(requirements, REQUIREMENTS_HEADER, packages); + private static void checkInstalledPackages(Path instaledFile, String... packages) throws IOException { + assertTrue(Files.exists(instaledFile)); + checkPackages(instaledFile, Files.readAllLines(instaledFile), packages); } - private static void checkPackages(Path file, String header, String... packages) throws IOException { - assertTrue(Files.exists(file)); - List lines = Files.readAllLines(file); - - if (header != null) { - String[] h = header.split("\n"); - assertTrue(lines.size() >= h.length); - for (int i = 0; i < h.length; i++) { - assertEquals("# " + h[i], lines.get(i)); - } + private static void checkLockFile(Path lockFile, String[] inputPackages, String... installedPackages) throws IOException { + assertTrue(Files.exists(lockFile)); + List lines = Files.readAllLines(lockFile); + List header = createLockFileHeader("0.1", inputPackages); + assertTrue(lines.size() >= header.size()); + for (int i = 0; i < header.size(); i++) { + assertEquals(header.get(i), lines.get(i)); } + checkPackages(lockFile, lines, installedPackages); + } + private static void checkPackages(Path file, List lines, String... packages) throws IOException { lines = lines.stream().filter(line -> !line.trim().startsWith("#") && !line.trim().isEmpty()).toList(); assertEquals(packages.length, lines.size()); for (String pkg : packages) { @@ -742,8 +685,8 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, packages); } - private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path requirements, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, requirements, NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PKG_VERSION_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, PACKAGE_REMOVED_ERROR, + private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path lockFile, String... packages) throws IOException { + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, LOCK_FILE_HEADER, WRONG_PKG_VERSION_ERROR, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR, packages); } @@ -758,5 +701,4 @@ private static void checkVenvContentsFile(Path contents, String graalPyVersion, fail(String.format("expected %s to contain all from %s", lines, Arrays.asList(packages))); } } - } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index 1606179b89..0a15c3b3ff 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -48,8 +48,8 @@ MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-gradle-plugin configuration" WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-gradle-plugin configuration have no exact version declared" -PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-gradle-plugin configuration are either missing in requirements file or have a different version" -VENV_UPTODATE = "Virtual environment is up to date with requirements file, skipping install" +PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file" +VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install" def append(file, txt): with open(file, "a") as f: @@ -97,7 +97,7 @@ def native_image_with_bogus_include(self): def native_image_with_exlude_email(self): pass - def freeze_requirements_config(self, community, pkgs, requirements): + def lock_packages_config(self, community, pkgs, lock_file): pass def generate_app(self, target_dir): @@ -190,17 +190,17 @@ def check_gradle_generated_app(self, community): self.check_filelist(target_dir2, log) @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") - def check_freeze_requirements(self, community): + def check_lock_packages(self, community): with util.TemporaryTestDirectory() as tmpdir: - target_dir = os.path.join(str(tmpdir), "freeze_requirements" + self.target_dir_name_sufix()) + target_dir = os.path.join(str(tmpdir), "lock_packages" + self.target_dir_name_sufix()) self.generate_app(target_dir) build_file = os.path.join(target_dir, self.build_file_name) gradlew_cmd = util.get_gradle_wrapper(target_dir, self.env) # start with requests package without version - append(build_file, self.freeze_requirements_config(pkgs=["requests"], requirements="test-requirements.txt", community=True)) + append(build_file, self.lock_packages_config(pkgs=["requests"], lock_file="test-graalpy.lock", community=True)) # build cmd = gradlew_cmd + ["build"] @@ -208,46 +208,46 @@ def check_freeze_requirements(self, community): util.check_ouput("pip install", out) util.check_ouput("BUILD SUCCESS", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # freeze - fails due to no version - cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + # lock - fails due to no version + cmd = gradlew_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) - assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # freeze with correct version + # lock with correct version log = Logger() self.copy_build_files(target_dir) - append(build_file, self.freeze_requirements_config(pkgs=["requests==2.32.3"], requirements="test-requirements.txt", community=True)) - cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + append(build_file, self.lock_packages_config(pkgs=["requests==2.32.3"], lock_file="test-graalpy.lock", community=True)) + cmd = gradlew_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # add termcolor and build - fails as it is not part of requirements + # add termcolor and build - fails as it is not part of lock file log = Logger() self.copy_build_files(target_dir) - append(build_file, self.freeze_requirements_config(pkgs=["requests==2.32.3", "termcolor==2.2"], requirements="test-requirements.txt", community=True)) + append(build_file, self.lock_packages_config(pkgs=["requests==2.32.3", "termcolor==2.2"], lock_file="test-graalpy.lock", community=True)) cmd = gradlew_cmd + ["build"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput(PACKAGES_INCONSISTENT_ERROR, out) + util.check_ouput(PACKAGES_CHANGED_ERROR, out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # freeze with termcolor + # lock with termcolor log = Logger() - cmd = gradlew_cmd + ["graalpyFreezeInstalledPackages"] + cmd = gradlew_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # rebuild with requirements and exec + # rebuild with lock and exec cmd = gradlew_cmd + ["build", "run"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) @@ -255,19 +255,19 @@ def check_freeze_requirements(self, community): util.check_ouput("hello java", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - # run with no packages, only requirements file + # run with no packages, only lock file self.copy_build_files(target_dir) append(build_file, self.empty_packages()) - # stop using requirementsFile field and test with default value {project_root}/requirements.txt - shutil.move(os.path.join(target_dir, "test-requirements.txt"), os.path.join(target_dir, "requirements.txt")) + # stop using lock file field and test with default value {project_root}/graalpy.lock + shutil.move(os.path.join(target_dir, "test-graalpy.lock"), os.path.join(target_dir, "graalpy.lock")) # should be able to import requests if installed util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "org", "example", "GraalPy.java"), "import hello", "import requests; import hello") - # clean and rebuild with requirements and exec + # clean and rebuild with lock and exec cmd = gradlew_cmd + ["clean", "build", "run"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) @@ -426,11 +426,11 @@ def check_gradle_empty_packages(self): util.check_ouput("BUILD SUCCESS", out) assert return_code == 0, out - cmd = gradle_cmd + ["graalpyFreezeInstalledPackages"] + cmd = gradle_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("In order to run the graalpyFreezeInstalledPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration.", out) - assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + util.check_ouput("In order to run the graalpyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration.", out) + assert not os.path.exists(os.path.join(target_dir, "graalpy.lock")) def check_gradle_python_resources_dir_deprecation(self): @@ -575,8 +575,8 @@ def test_gradle_generated_app(self): self.check_gradle_generated_app(community=True) @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") - def test_gradle_freeze_requirements(self): - self.check_freeze_requirements(community=True) + def test_gradle_lock_packages(self): + self.check_lock_packages(community=True) @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") def test_gradle_generated_app_external_resources(self): @@ -634,13 +634,13 @@ def packages_termcolor(self, community): }} """) - def freeze_requirements_config(self, community, pkgs, requirements=None): - requirements_file = f"requirementsFile = file(\"{requirements}\")" if requirements else "" + def lock_packages_config(self, community, pkgs, lock=None): + lock_file = f"graalPyLockFile = file(\"{lock}\")" if lock else "" packages = "packages = [\"" + "\",\"".join(pkgs) + "\"]" return textwrap.dedent(f""" graalPy {{ {packages} - {requirements_file} + {lock_file} {_community_as_property(community)} }} """) @@ -760,8 +760,8 @@ def test_gradle_generated_app(self): self.check_gradle_generated_app(community=True) @unittest.skipUnless(util.is_gradle_plugin_test_enabled, "ENABLE_GRADLE_PLUGIN_UNITTESTS is not true") - def test_gradle_freeze_requirements(self): - self.check_freeze_requirements(community=True) + def test_gradle_lock_packages(self): + self.check_lock_packages(community=True) @unittest.skipUnless(util.is_gradle_plugin_long_running_test_enabled, "ENABLE_GRADLE_PLUGIN_LONG_RUNNING_UNITTESTS is not true") def test_gradle_generated_app_external_resources(self): @@ -810,15 +810,15 @@ def copy_build_files(self, target_dir): def empty_plugin(self, community): return f"graalPy {{ {_community_as_property(community) } }}" - def freeze_requirements_config(self, community, pkgs, requirements=None): - requirements_file = f"requirementsFile = file(\"{requirements}\")" if requirements else "" + def lock_packages_config(self, community, pkgs, lock=None): + lock_file = f"graalPyLockFile = file(\"{lock}\")" if lock else "" packages = "" for p in pkgs: packages += f" packages.add(\"{p}\")\n" return textwrap.dedent(f""" graalPy {{ {packages} - {requirements_file} + {lock_file} {_community_as_property(community)} }} """) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index b2c8fd7ed9..ae4b9793a7 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -50,8 +50,8 @@ MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-maven-plugin configuration" WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-maven-plugin configuration have no exact version declared" -PACKAGES_INCONSISTENT_ERROR = "some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version" -VENV_UPTODATE = "Virtual environment is up to date with requirements file, skipping install" +PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file" +VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install" class MavenPluginTest(util.BuildToolTestBase): @@ -187,10 +187,10 @@ def test_generated_app_utils_pkg(self): self.check_generated_app(use_default_vfs_path=True, use_utils_pkg=True) @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") - def test_freeze_requirements(self): + def test_lock_file(self): with util.TemporaryTestDirectory() as tmpdir: - target_name = "test_freeze_requirements" + target_name = "test_lock_file" target_dir = os.path.join(str(tmpdir), target_name) self.generate_app(tmpdir, target_dir, target_name) @@ -205,48 +205,48 @@ def test_freeze_requirements(self): util.replace_in_file(os.path.join(target_dir, "pom.xml"), "termcolor==2.2", "requests") # build - cmd = mvnw_cmd + ["package", "-DrequirementsFile=test-requirements.txt"] + cmd = mvnw_cmd + ["package", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("pip install", out) util.check_ouput("BUILD SUCCESS", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) # freeze - fails due to no version - cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:lock-packages", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) - assert not os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) # freeze with correct version util.replace_in_file(os.path.join(target_dir, "pom.xml"), "requests", "requests==2.32.3") - cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages", "-DrequirementsFile=test-requirements.txt"] + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:lock-packages", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # add termcolor and build - fails as it is not part of requirements + # add termcolor and build - fails as it is not part of ock file util.replace_in_file(os.path.join(target_dir, "pom.xml"), "
    ", "termcolor==2.2\n") - cmd = mvnw_cmd + ["package", "-DrequirementsFile=test-requirements.txt"] + cmd = mvnw_cmd + ["package", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput(PACKAGES_INCONSISTENT_ERROR, out) + util.check_ouput(PACKAGES_CHANGED_ERROR, out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) # freeze with termcolor - # stop using requirementsFile system property but test also with field in pom.xml - util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "\ntest-requirements.txt") - cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages"] + # stop using lock file system property but test also with field in pom.xml + util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "\ntest-graalpy.lock") + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:lock-packages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=True) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - assert os.path.exists(os.path.join(target_dir, "test-requirements.txt")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # rebuild with requirements and exec + # rebuild with lock file and exec cmd = mvnw_cmd + ["package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) @@ -254,7 +254,7 @@ def test_freeze_requirements(self): util.check_ouput("hello java", out) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - # disable packages config in pom - run with no packages, only requirements file + # disable packages config in pom - run with no packages, only lock file util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "") @@ -263,7 +263,7 @@ def test_freeze_requirements(self): "import hello", "import requests; import hello") - # clean and rebuild with requirements and exec + # clean and rebuild with lock and exec cmd = mvnw_cmd + ["clean", "package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) @@ -438,11 +438,11 @@ def test_empty_packages(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) - cmd = mvnw_cmd + ["-X", "org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages"] + cmd = mvnw_cmd + ["-X", "org.graalvm.python:graalpy-maven-plugin:lock-packages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) - assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + util.check_ouput("In order to run the lock-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) + assert not os.path.exists(os.path.join(target_dir, "graalpy.lock")) util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", " ") @@ -450,11 +450,11 @@ def test_empty_packages(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out) - cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages"] + cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:lock-packages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) - assert not os.path.exists(os.path.join(target_dir, "requirements.txt")) + util.check_ouput("In order to run the lock-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration", out) + assert not os.path.exists(os.path.join(target_dir, "graalpy.lock")) @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") def test_python_resources_dir_deprecation(self): diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index 04b23c4061..d40685b0be 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -72,21 +72,22 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { private static final String PYTHON_ARTIFACT_ID = "python"; private static final String GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID = "graalpy-maven-plugin"; - protected static final String REQUIREMENTS_FILE_HEADER = """ - Generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. - + protected static final String LOCK_FILE_HEADER = """ + This file was generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. + WARNING: Any manual changes are done at your own risk and will be overwritten when the goal is executed. - + + This file is meant to be tracked in a version control system. + This file contains a list of all required Python packages with their specific versions, based on the packages defined in the plugin configuration and their dependencies. - """; - protected static final String MISSING_REQUIREMENTS_FILE_WARNING = """ + protected static final String MISSING_LOCK_FILE_WARNING = """ Additional python dependencies were installed besides the packages declared in graalpy-maven-plugin configuration. - It is highly recommended to freeze python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + It is highly recommended to lock python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management @@ -95,30 +96,20 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ Some python packages in graalpy-maven-plugin configuration have no exact version declared: %s - When using the graalpy-maven-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + When using the graalpy-maven-plugin together with a lock file, it is necessary to declare python packages in format [package_name]==[version]. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management """; - protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ - Install of python packages is based on requirements file %s, - but some packages in graalpy-maven-plugin configuration are either missing in requirements file or have a different version: %s. - - The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String PACKAGE_REMOVED_ERROR = """ - Install of python packages is based on requirements file %s, - but some packages in graalpy-maven-plugin configuration are different then previously used to generate the requirements file. + protected static final String PACKAGES_CHANGED_ERROR = """ + Install of python packages is based on lock file %s, + but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file. Packages currently declared in graalpy-maven-plugin configuration: %s - Packages which were used to generate the requirements file: %s + Packages which were used to generate the lock file: %s - The requirements file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages'. + The lock file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management @@ -136,8 +127,8 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { @Parameter(property = "resourceDirectory") String resourceDirectory; - @Parameter(property = "requirementsFile", defaultValue = "requirements.txt") - String requirementsFile; + @Parameter(property = "graalPyLockFile", defaultValue = "graalpy.lock") + String graalPyLockFile; @Parameter List packages; @@ -181,7 +172,7 @@ protected void preExec(boolean checkFields) throws MojoExecutionException { pythonResourcesDirectory = normalizeEmpty(pythonResourcesDirectory); externalDirectory = normalizeEmpty(externalDirectory); resourceDirectory = normalizeEmpty(resourceDirectory); - requirementsFile = normalizeEmpty(requirementsFile); + graalPyLockFile = normalizeEmpty(graalPyLockFile); packages = packages != null ? packages.stream().filter(p -> p != null && !p.trim().isEmpty()).toList() : Collections.EMPTY_LIST; if(pythonResourcesDirectory != null) { @@ -287,12 +278,12 @@ public Set computeClassPath() throws IOException { return launcherArg; } - protected Path getRequirementsFile() { - Path rfp = Path.of(requirementsFile); + protected Path getLockFile() { + Path rfp = Path.of(graalPyLockFile); if(rfp.isAbsolute()) { return rfp; } else { - return project.getBasedir().toPath().resolve(requirementsFile); + return project.getBasedir().toPath().resolve(graalPyLockFile); } } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java index 4f6eb2bcc1..95ebe99763 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java @@ -67,9 +67,9 @@ public void execute() throws MojoExecutionException { private void manageVenv() throws MojoExecutionException { Path venvDirectory = getVenvDirectory(); MavenDelegateLog log = new MavenDelegateLog(getLog()); - Path requirements = getRequirementsFile(); + Path requirements = getLockFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGE_REMOVED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, requirements, LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java similarity index 88% rename from graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java rename to graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java index d1bc06d21b..1c91436792 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/FreezeInstalledPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java @@ -45,17 +45,15 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; -import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -@Mojo(name = "freeze-installed-packages", +@Mojo(name = "lock-packages", requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class FreezeInstalledPackagesMojo extends AbstractGraalPyMojo { +public class LockPackagesMojo extends AbstractGraalPyMojo { public void execute() throws MojoExecutionException { preExec(false); @@ -70,10 +68,10 @@ public void execute() throws MojoExecutionException { protected void manageVenv() throws MojoExecutionException { Path venvDirectory = getVenvDirectory(); MavenDelegateLog log = new MavenDelegateLog(getLog()); - Path requirements = getRequirementsFile(); + Path requirements = getLockFile(); try { - VFSUtils.freezePackages(venvDirectory, packages, requirements, REQUIREMENTS_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.lockPackages(venvDirectory, packages, requirements, LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } @@ -82,7 +80,7 @@ protected void manageVenv() throws MojoExecutionException { private void checkEmptyPackages() throws MojoExecutionException { if((packages == null || packages.isEmpty())) { getLog().error(""); - getLog().error("In order to run the freeze-installed-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration."); + getLog().error("In order to run the lock-packages goal there have to be python packages declared in the graalpy-maven-plugin configuration."); getLog().error(""); getLog().error("NOTE that the section has to be declared for the whole graalpy-maven-plugin"); getLog().error("and not specifically for the process-graalpy-resources execution goal."); diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index b1974e4762..9b477cb6dc 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -50,17 +50,17 @@ import java.nio.file.StandardOpenOption; import java.nio.file.attribute.PosixFilePermission; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; +import java.util.NoSuchElementException; import java.util.Objects; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; -import java.util.stream.Collectors; import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.exec.BuildToolLog.CollectOutputLog; @@ -274,61 +274,170 @@ void write(List pkgs) throws IOException { } } + private static final String GRAALPY_VERSION_PREFIX = "# graalpy-version: "; + private static final String INPUT_PACKAGES_PREFIX = "# input-packages: "; + private static final String INPUT_PACKAGES_DELIMITER = ","; + + private static class LockFile { + + final Path path; + final List packages; + final List inputPackages; + + private LockFile(Path path, List inputPackages, List packages) { + this.path = path; + this.packages = packages; + this.inputPackages = inputPackages; + } + + static LockFile fromFile(Path file, String lockFileHeader, BuildToolLog log) throws IOException { + List packages = new ArrayList<>(); + List inputPackages = null; + if (Files.isReadable(file)) { + List lines = Files.readAllLines(file); + if (lines.isEmpty()) { + throw wrongFormat(file, lines, log); + } + // parse version first, we don't care about it for now, but with future versions the + // file format might change, and we will need to know to parse differently + parseVersion(lines, file, log); + + // parseVersion removed the version line + // what is expected to be left is: + // 1.) a multiline header comment + // 2.) input packages in 1 line (starting with comment #) + // 3.) locked packages, 1 line each (as input for pip install) + // see also LockFile.write() + Iterator it = lines.iterator(); + Iterator headerIterator = Arrays.asList(lockFileHeader.split("\n")).iterator(); + try { + // 1.) header + while (headerIterator.hasNext()) { + if (!("# " + headerIterator.next()).equals(it.next())) { + throw wrongFormat(file, lines, log); + } + } + // 2.) input packages + String line = it.next(); + if (!line.startsWith(INPUT_PACKAGES_PREFIX)) { + throw wrongFormat(file, lines, log); + } + String pkgs = line.substring(INPUT_PACKAGES_PREFIX.length()).trim(); + if (pkgs.isEmpty()) { + throw wrongFormat(file, lines, log); + } + inputPackages = Arrays.asList(pkgs.split(INPUT_PACKAGES_DELIMITER)); + } catch (NoSuchElementException e) { + throw wrongFormat(file, lines, log); + } + // 3.) locked packages + while (it.hasNext()) { + packages.add(it.next()); + } + } else { + throw new IOException("can't read lock file"); + } + return new LockFile(file, inputPackages, packages); + } + + private static String parseVersion(List lines, Path file, BuildToolLog log) throws IOException { + Iterator it = lines.iterator(); + while (it.hasNext()) { + String line = it.next(); + if (line.startsWith(GRAALPY_VERSION_PREFIX)) { + String graalPyVersion = line.substring(GRAALPY_VERSION_PREFIX.length()).trim(); + if (graalPyVersion.isEmpty()) { + throw wrongFormat(file, lines, log); + } + it.remove(); + return graalPyVersion; + } + } + throw wrongFormat(file, lines, log); + } + + private static IOException wrongFormat(Path file, List lines, BuildToolLog log) throws IOException { + if (log.isDebugEnabled()) { + log.debug("wrong format of lock file " + file); + for (String l : lines) { + log.debug(l); + } + log.debug(""); + } + return new IOException("invalid lock file format"); + } + + private static void write(Path venvDirectory, Path lockFile, String lockFileHeader, List inputPackages, String graalPyVersion, BuildToolLog log) throws IOException { + Objects.requireNonNull(venvDirectory); + Objects.requireNonNull(lockFile); + Objects.requireNonNull(lockFileHeader); + Objects.requireNonNull(log); + + assert Files.exists(venvDirectory); + + InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); + List header = getHeaderList(lockFileHeader); + header.add(GRAALPY_VERSION_PREFIX + graalPyVersion); + header.add(INPUT_PACKAGES_PREFIX + String.join(INPUT_PACKAGES_DELIMITER, inputPackages)); + Files.write(lockFile, header, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); + Files.write(lockFile, installedPackages.packages, StandardOpenOption.APPEND); + + lifecycle(log, "Created GraalPy lock file: %s", lockFile); + logDebug(log, installedPackages.packages, null); + } + + private static List getHeaderList(String lockFileHeader) { + List list = new ArrayList<>(); + String[] lines = lockFileHeader.split("\n"); + for (String l : lines) { + list.add("# " + l); + } + return list; + } + } + public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { createVenv(venvDirectory, packagesArgs, null, null, null, null, null, launcherArgs, graalPyVersion, log); } - public static void createVenv(Path venvDirectory, List packages, Path requirementsFile, - String newPackageOrVersionError, String wrongPackageVersionFormatError, String packagesListChangedError, String missingRequirementsFileWarning, + public static void createVenv(Path venvDirectory, List packages, Path lockFilePath, + String lockFileHeader, String wrongPackageVersionFormatError, String packagesChangedError, String missingLockFileWarning, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); Objects.requireNonNull(launcher); Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); - if (requirementsFile != null) { - Objects.requireNonNull(newPackageOrVersionError); + if (lockFilePath != null) { Objects.requireNonNull(wrongPackageVersionFormatError); - Objects.requireNonNull(packagesListChangedError); + Objects.requireNonNull(packagesChangedError); } - logVenvArgs(venvDirectory, packages, requirementsFile, launcher, graalPyVersion, log); + logVenvArgs(venvDirectory, packages, lockFilePath, launcher, graalPyVersion, log); List pluginPackages = trim(packages); - List requirementsPackages = requirementsFile != null && Files.exists(requirementsFile) ? readPackagesFromFile(requirementsFile) : null; - if (!checkPackages(venvDirectory, pluginPackages, requirementsPackages, requirementsFile, newPackageOrVersionError, wrongPackageVersionFormatError, packagesListChangedError, log)) { + LockFile lockFile = null; + if (lockFilePath != null && Files.exists(lockFilePath)) { + lockFile = LockFile.fromFile(lockFilePath, lockFileHeader, log); + } + + if (!checkPackages(venvDirectory, pluginPackages, lockFile, wrongPackageVersionFormatError, packagesChangedError, log)) { return; } VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, launcher, log); boolean installed; - if (requirementsPackages != null) { - installed = install(venvDirectory, requirementsFile, requirementsPackages, log); + if (lockFile != null) { + installed = install(venvDirectory, lockFile, log); } else { - installed = install(venvDirectory, pluginPackages, venvContents, missingRequirementsFileWarning, log); + installed = install(venvDirectory, pluginPackages, venvContents, missingLockFileWarning, log); } if (installed) { venvContents.write(pluginPackages); } } - /** - * checks if package was removed since the last install - */ - private static void checkIfRemovedFromPluginPackages(Path venvDirectory, VenvContents venvContents, List pluginPackages, Path requirementsFile, String packagesListChangedError, - BuildToolLog log) - throws IOException { - if (venvContents == null) { - return; - } - if (packagesListChangedError != null && removedFromPluginPackages(venvDirectory, venvContents, pluginPackages)) { - extendedError(log, String.format(packagesListChangedError, requirementsFile, - String.join(", ", pluginPackages.stream().sorted().toList()), String.join(", ", venvContents.packages.stream().sorted().toList()))); - throw new IOException("packages from plugin configuration changed"); - } - } - private static boolean removedFromPluginPackages(Path venvDirectory, VenvContents venvContents, List pluginPackages) throws IOException { if (venvContents == null || venvContents.packages == null) { return false; @@ -343,8 +452,8 @@ private static boolean removedFromPluginPackages(List pluginPackages, Li // a previously installed package is missing // in the current plugin packages list if (!contentsPackage.contains("==")) { - // it has no version specified, - // lets check if it isn't just requested with a different version + // it had previously no version specified, + // check if it is requested with the same version as installed String pkgAndVersion = getByName(contentsPackage, pluginPackages); if (pkgAndVersion != null) { // yes, a version was added to a package @@ -373,21 +482,29 @@ private static String getByName(String name, List packages) { return null; } - public static void freezePackages(Path venvDirectory, List packages, Path requirementsFile, String requirementsHeader, String wrongPackageVersionFormatError, Launcher launcher, + public static void lockPackages(Path venvDirectory, List packages, Path lockFile, String lockFileHeader, String wrongPackageVersionFormatError, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { + Objects.requireNonNull(venvDirectory); + Objects.requireNonNull(packages); + Objects.requireNonNull(lockFile); + Objects.requireNonNull(lockFileHeader); + Objects.requireNonNull(wrongPackageVersionFormatError); + Objects.requireNonNull(graalPyVersion); + Objects.requireNonNull(log); + checkVersionFormat(packages, wrongPackageVersionFormatError, log); createVenv(venvDirectory, packages, launcher, graalPyVersion, log); if (Files.exists(venvDirectory)) { - createRequirementsFile(venvDirectory, requirementsFile, requirementsHeader, log); + LockFile.write(venvDirectory, lockFile, lockFileHeader, packages, graalPyVersion, log); } else { // how comes? - warning(log, "did not generate new python requirements file due to missing python virtual environment"); + warning(log, "did not generate new python lock file due to missing python virtual environment"); } } - private static void logVenvArgs(Path venvDirectory, List packages, Path requirementsFile, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) + private static void logVenvArgs(Path venvDirectory, List packages, Path lockFile, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { if (log.isDebugEnabled()) { // avoid computing classpath if not necessary @@ -396,13 +513,13 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path log.debug(" graalPyVersion: " + graalPyVersion); log.debug(" venvDirectory: " + venvDirectory); log.debug(" packages: " + packages); - log.debug(" requirements file: " + requirementsFile); + log.debug(" lock file: " + lockFile); log.debug(" launcher: " + launcherArgs.launcherPath); log.debug(" launcher classpath: " + lcp); } } - private static boolean checkPackages(Path venvDirectory, List pluginPackages, List requirementsPackages, Path requirementsFile, String newPackageOrVersionError, + private static boolean checkPackages(Path venvDirectory, List pluginPackages, LockFile lockFile, String wrongPackageVersionFormatError, String packagesListChangedError, BuildToolLog log) throws IOException { VenvContents contents = null; if (Files.exists(venvDirectory)) { @@ -410,12 +527,11 @@ private static boolean checkPackages(Path venvDirectory, List pluginPack contents = VenvContents.fromVenv(venvDirectory); } - if (requirementsPackages != null) { + if (lockFile != null) { checkVersionFormat(pluginPackages, wrongPackageVersionFormatError, log); - checkPluginPackagesInRequirementsFile(pluginPackages, requirementsPackages, requirementsFile, newPackageOrVersionError, log); - checkIfRemovedFromPluginPackages(venvDirectory, contents, pluginPackages, requirementsFile, packagesListChangedError, log); - logPackages(requirementsPackages, requirementsFile, log); - return needVenv(venvDirectory, requirementsPackages, log); + checkPluginPackagesInLockFile(pluginPackages, lockFile, packagesListChangedError, log); + logPackages(lockFile.packages, lockFile.path, log); + return needVenv(venvDirectory, lockFile.packages, log); } else { if (removedFromPluginPackages(venvDirectory, contents, pluginPackages)) { // a package was removed, and we do not know if it did not leave behind any @@ -434,16 +550,16 @@ private static boolean needVenv(Path venvDirectory, List packages, Build info(log, "No packages to install, deleting venv"); delete(venvDirectory); } else { - debug(log, "VFSUtils skipping venv create - no package or requirements file provided"); + debug(log, "VFSUtils skipping venv create - no package or lock file provided"); } return false; } return true; } - private static void logPackages(List packages, Path requirementsFile, BuildToolLog log) { - if (requirementsFile != null) { - info(log, "Got %s python package(s) in requirements file: %s", packages.size(), requirementsFile); + private static void logPackages(List packages, Path lockFile, BuildToolLog log) { + if (lockFile != null) { + info(log, "Got %s python package(s) in lock file: %s", packages.size(), lockFile); } else { info(log, "Got %s python package(s) in GraalPy plugin configuration", packages.size()); } @@ -493,27 +609,27 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion return contents; } - private static boolean install(Path venvDirectory, Path requirementsFile, List requiredPkgs, BuildToolLog log) throws IOException { + private static boolean install(Path venvDirectory, LockFile lockFile, BuildToolLog log) throws IOException { InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); - if (installedPackages.packages.size() != requiredPkgs.size() || deleteUnwantedPackages(venvDirectory, requiredPkgs, installedPackages.packages, log)) { - runPip(venvDirectory, "install", log, "-r", requirementsFile.toString()); + if (installedPackages.packages.size() != lockFile.packages.size() || deleteUnwantedPackages(venvDirectory, lockFile.packages, installedPackages.packages, log)) { + runPip(venvDirectory, "install", log, "-r", lockFile.path.toString()); installedPackages.freeze(log); return true; } else { - info(log, "Virtual environment is up to date with requirements file, skipping install"); + info(log, "Virtual environment is up to date with lock file, skipping install"); } return false; } - private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, String missingRequirementsFileWarning, BuildToolLog log) throws IOException { + private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, String missingLockFileWarning, BuildToolLog log) throws IOException { boolean needsUpdate = false; needsUpdate |= deleteUnwantedPackages(venvDirectory, newPackages, venvContents.packages, log); needsUpdate |= installWantedPackages(venvDirectory, newPackages, venvContents.packages, log); if (needsUpdate) { List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); - if (missingRequirementsFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingRequirementsWarning")) { + if (missingLockFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingLockFileWarning")) { if (installedPackages.size() > newPackages.size()) { - missingRequirementsWarning(log, missingRequirementsFileWarning); + missingLockFileWarning(log, missingLockFileWarning); } } return true; @@ -521,42 +637,15 @@ private static boolean install(Path venvDirectory, List newPackages, Ven return false; } - private static void missingRequirementsWarning(BuildToolLog log, String missingRequirementsFileWarning) { + private static void missingLockFileWarning(BuildToolLog log, String missingLockFileWarning) { if (log.isWarningEnabled()) { - String txt = missingRequirementsFileWarning + "\n"; + String txt = missingLockFileWarning + "\n"; for (String t : txt.split("\n")) { log.warning(t); } } } - private static void createRequirementsFile(Path venvDirectory, Path requirementsFile, String requirementsFileHeader, BuildToolLog log) throws IOException { - Objects.requireNonNull(venvDirectory); - Objects.requireNonNull(requirementsFile); - Objects.requireNonNull(requirementsFileHeader); - Objects.requireNonNull(log); - - assert Files.exists(venvDirectory); - - InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory); - List header = getHeaderList(requirementsFileHeader); - Files.write(requirementsFile, header, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); - Files.write(requirementsFile, installedPackages.packages, StandardOpenOption.APPEND); - - lifecycle(log, "Created python requirements file: %s", requirementsFile); - logDebug(log, installedPackages.packages, null); - } - - private static List getHeaderList(String requirementsFileHeader) { - List list = new ArrayList<>(); - String[] lines = requirementsFileHeader.split("\n"); - for (String l : lines) { - list.add("# " + l); - } - list.add(""); - return list; - } - /** * check that packages are declared with a specific version - package_name==version */ @@ -595,38 +684,25 @@ private static void wrongPackageVersionError(BuildToolLog log, String wrongPacka } /** - * check that there are no plugin packages missing in requirements file + * check that there are no plugin packages missing in lock file */ - private static void checkPluginPackagesInRequirementsFile(List pluginPackages, List requirementsPackages, Path requirementsFile, String newPackageOrVersionError, BuildToolLog log) + private static void checkPluginPackagesInLockFile(List pluginPackages, LockFile lockFile, String packagesChangedError, BuildToolLog log) throws IOException { - if (pluginPackages.isEmpty()) { - return; - } + checkPluginPackagesInLockFile(pluginPackages, lockFile.inputPackages, lockFile.path, packagesChangedError, log); + } - Map requirementsPackagesMap = requirementsPackages.stream().filter(p -> p.contains("==")).map(p -> p.split("==")).collect( - Collectors.toMap(parts -> parts[0], parts -> parts[1])); - List inconsistent = new ArrayList<>(); - for (String pkg : pluginPackages) { - String[] s = pkg.split("=="); - String pName = s[0]; - String pVersion = s[1]; - String rVersion = requirementsPackagesMap.get(pName); - if (rVersion != null && rVersion.startsWith(pVersion)) { - continue; - } - inconsistent.add(pkg); - } + /** + * Accessed from VFSUtilsTest + */ + private static void checkPluginPackagesInLockFile(List pluginPackages, List lockFilePackages, Path lockFilePath, String packagesChangedError, BuildToolLog log) + throws IOException { - if (!inconsistent.isEmpty()) { - newPackageOrVersionError(log, newPackageOrVersionError, requirementsFile, String.join(", ", inconsistent)); + if (pluginPackages.size() != lockFilePackages.size() || !pluginPackages.containsAll(lockFilePackages)) { + extendedError(log, String.format(packagesChangedError, lockFilePath, String.join(", ", pluginPackages), String.join(", ", lockFilePackages)) + "\n"); + throw new IOException("inconsistent packages"); } } - private static void newPackageOrVersionError(BuildToolLog log, String newPackageOrVersionError, Object... args) throws IOException { - extendedError(log, String.format(newPackageOrVersionError, args) + "\n"); - throw new IOException("inconsistent packages"); - } - private static void checkVenvLauncher(Path venvDirectory, Path launcherPath, BuildToolLog log) throws IOException { if (!Files.exists(launcherPath)) { throw new IOException(String.format("Launcher file does not exist '%s'", launcherPath)); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java index 965d391415..ab92c94d36 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java @@ -42,7 +42,7 @@ import org.graalvm.python.dsl.GraalPyExtension; import org.graalvm.python.tasks.AbstractPackagesTask; -import org.graalvm.python.tasks.FreezeInstalledPackagesTask; +import org.graalvm.python.tasks.LockPackagesTask; import org.graalvm.python.tasks.MetaInfTask; import org.graalvm.python.tasks.InstallPackagesTask; import org.graalvm.python.tasks.VFSFilesListTask; @@ -90,10 +90,10 @@ public abstract class GraalPyGradlePlugin implements Plugin { private static final String DEFAULT_FILESLIST_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "fileslist"; private static final String GRAALPY_META_INF_DIRECTORY = "generated" + File.separator + "graalpy" + File.separator + "META-INF"; private static final String GRAALPY_INSTALL_PACKAGES_TASK = "graalPyInstallPackages"; - private static final String GRAALPY_FREEZE_DEPENDENCIES_TASK = "graalPyFreezeInstalledPackages"; + private static final String GRAALPY_LOCK_PACKAGES_TASK = "graalPyLockPackages"; private static final String GRAALPY_META_INF_TASK_TASK = "graalPyMetaInf"; private static final String GRAALPY_VFS_FILESLIST_TASK = "graalPyVFSFilesList"; - private static final String PYTHON_REQUIREMENTS_FILE = "requirements.txt"; + private static final String GRAALPY_LOCK_FILE = "graalpy.lock"; GraalPyExtension extension; Project project; @@ -116,7 +116,7 @@ public void apply(Project project) { var mainSourceSet = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); mainSourceSet.getResources().srcDir(installPackagesTask); - registerFreezeInstalledPackagesTask(project, launcherClasspath, extension); + registerLockPackagesTask(project, launcherClasspath, extension); addDependencies(); @@ -208,8 +208,8 @@ private TaskProvider registerInstallPackagesTask(Project pr }); } - private TaskProvider registerFreezeInstalledPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) { - return project.getTasks().register(GRAALPY_FREEZE_DEPENDENCIES_TASK, FreezeInstalledPackagesTask.class, t -> { + private TaskProvider registerLockPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) { + return project.getTasks().register(GRAALPY_LOCK_PACKAGES_TASK, LockPackagesTask.class, t -> { registerPackagesTask(project, launcherClasspath, extension, t); // TODO probably not necessary // t.getOutputs().upToDateWhen(tt -> false); @@ -231,7 +231,7 @@ private void registerPackagesTask(Project project, Configuration launcherClasspa t.getIncludeVfsRoot().convention(externalDirectory.map(d -> false).orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true))); t.getResourceDirectory().set(extension.getResourceDirectory()); - t.getRequirementsFile().convention(extension.getRequirementsFile().orElse(projectDirectory.file(PYTHON_REQUIREMENTS_FILE))); + t.getGraalPyLockFile().convention(extension.getGraalPyLockFile().orElse(projectDirectory.file(GRAALPY_LOCK_FILE))); t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java index 477e34cc85..df51d7e99f 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/dsl/GraalPyExtension.java @@ -77,14 +77,14 @@ public interface GraalPyExtension { Property getResourceDirectory(); /** - * A python requirements file. + * GraalPy lock file. * * If present then used as exclusive input when installing python packages * for GraalPy usage instead of {@link #getPackages()}. * * @see #getPackages() */ - RegularFileProperty getRequirementsFile(); + RegularFileProperty getGraalPyLockFile(); /** * Experimental property. Allows overriding the default Polyglot and GraalPy version. @@ -96,9 +96,9 @@ public interface GraalPyExtension { /** * Determines third party python packages to be installed for GraalPy usage in case - * no python requirements file is provided by {@link #getRequirementsFile()}. + * no GraalPy lock file is provided by {@link #getGraalPyLockFile()}. * - * @see #getRequirementsFile() + * @see #getGraalPyLockFile() */ SetProperty getPackages(); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 56eb8c5410..66b78036f8 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -79,21 +79,23 @@ @CacheableTask public abstract class AbstractPackagesTask extends DefaultTask { - protected static final String REQUIREMENTS_FILE_HEADER = """ - This file was generated by gradle task 'graalpyFreezeInstalledPackages'. + protected static final String LOCK_FILE_HEADER = """ + This file was generated by gradle task 'graalpyLockPackages'. WARNING: Any manual changes are done at your own risk and will be overwritten when the task is executed. - + + This file is meant to be tracked in a version control system. + This file contains a list of all required Python packages with their specific versions, - based on the packages defined in the plugin configuration and their dependencies. - + based on the packages defined in the plugin configuration and their dependencies. + """; - protected static final String MISSING_REQUIREMENTS_FILE_WARNING = """ + protected static final String MISSING_LOCK_FILE_WARNING = """ WARNING: Additional python dependencies were installed besides the packages declared in graalpy-gradle-plugin configuration. - WARNING: It is highly recommended to freeze python dependencies by running the gradle task 'graalpyFreezeInstalledPackages'. + WARNING: It is highly recommended to lock python dependencies by running the gradle task 'graalpyLockPackages'. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management @@ -102,30 +104,20 @@ public abstract class AbstractPackagesTask extends DefaultTask { protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ Some python packages in graalpy-gradle-plugin configuration have no exact version declared: %s - When using the graalpy-gradle-plugin together with a python requirements file, it is necessary to declare python packages in format [package_name]==[version]. + When using the graalpy-gradle-plugin together with graalpy.lock file, it is necessary to declare python packages in format [package_name]==[version]. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management """; - protected static final String NEW_PACKAGE_OR_VERSION_ERROR = """ - Install of python packages is based on requirements file %s, - but some packages in graalpy-gradle-plugin configuration are either missing in the requirements file or have a different version: %s. - - The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String PACKAGE_REMOVED_ERROR = """ - Install of python packages is based on requirements file %s, - but some packages in graalpy-gradle-plugin configuration were removed since previously used to generate the requirements file. + protected static final String PACKAGES_CHANGED_ERROR = """ + Install of python packages is based on lock file %s, + but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file. Packages currently declared in graalpy-gradle-plugin configuration: %s - Packages which were used to generate the requirements file: %s + Packages which were used to generate the lock file: %s - The requirements file has to be refreshed by running the gradle task 'graalpyFreezeInstalledPackages'. + The lock file has to be refreshed by running the gradle task 'graalpyLockPackages'. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management @@ -165,7 +157,7 @@ public abstract class AbstractPackagesTask extends DefaultTask { @InputFiles @Optional @PathSensitive(PathSensitivity.RELATIVE) - public abstract RegularFileProperty getRequirementsFile(); + public abstract RegularFileProperty getGraalPyLockFile(); /** * Desired polyglot runtime and GraalPy version. @@ -212,12 +204,12 @@ protected Path getVenvDirectory() { } @Internal - protected Path getRequirementsPath() { - Path rfp = getRequirementsFile().get().getAsFile().toPath(); + protected Path getLockFilePath() { + Path rfp = getGraalPyLockFile().get().getAsFile().toPath(); if(rfp.isAbsolute()) { return rfp; } else { - return getProject().file(getRequirementsFile().get()).toPath(); + return getProject().file(getGraalPyLockFile().get()).toPath(); } } } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index 6d282a56b0..df11ce6c31 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -69,8 +69,8 @@ public abstract class InstallPackagesTask extends AbstractPackagesTask { public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { - VFSUtils.createVenv(venvDirectory, getPackages().get(), getRequirementsPath(), - NEW_PACKAGE_OR_VERSION_ERROR, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGE_REMOVED_ERROR, MISSING_REQUIREMENTS_FILE_WARNING, + VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), + LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java similarity index 83% rename from graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java rename to graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java index 9d89ba6ea1..53e70d9fb0 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/FreezeInstalledPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java @@ -51,24 +51,24 @@ import org.graalvm.python.embedding.tools.vfs.VFSUtils; /** - * Creates a python requirements file from all user packages installed in the python virtual environment. + * Creates a GraalPy lock file from packages declared in plugin configuration. * * If there is no virtual environment preset then it is first created and packages are installed the same way * as in scope of {@link InstallPackagesTask}. */ @CacheableTask -public abstract class FreezeInstalledPackagesTask extends AbstractPackagesTask { +public abstract class LockPackagesTask extends AbstractPackagesTask { @TaskAction public void exec() throws GradleException { checkEmptyPackages(); Path venvDirectory = getVenvDirectory(); try { - VFSUtils.freezePackages(getVenvDirectory(), getPackages().get(), getRequirementsPath(), - REQUIREMENTS_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, + VFSUtils.lockPackages(getVenvDirectory(), getPackages().get(), getLockFilePath(), + LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { - throw new GradleException(String.format("failed to freeze packages in python virtual environment %s", venvDirectory), e); + throw new GradleException(String.format("failed to lock packages in python virtual environment %s", venvDirectory), e); } } @@ -76,7 +76,7 @@ private void checkEmptyPackages() throws GradleException { List packages = getPackages().get(); if((packages == null || packages.isEmpty())) { getLog().error(""); - getLog().error("In order to run the graalpyFreezeInstalledPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration."); + getLog().error("In order to run the graalpyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration."); getLog().error(""); getLog().error("For more information, please refer to https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md"); getLog().error(""); From 09c9f0c145e438fc7341b3e684053fda967a9ddc Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Fri, 14 Feb 2025 15:34:57 +0100 Subject: [PATCH 074/512] - warn about missing lock file every time when installed packages != plugin packages - removed package version check --- docs/user/Embedding-Build-Tools.md | 77 ++++++------ .../embedding/test/EmbeddingTestUtils.java | 6 +- .../embedding/vfs/test/VFSUtilsTest.java | 57 +++------ .../tests/standalone/test_gradle_plugin.py | 41 +++---- .../src/tests/standalone/test_maven_plugin.py | 35 +++--- .../maven/plugin/AbstractGraalPyMojo.java | 16 +-- .../maven/plugin/InstallPackagesMojo.java | 2 +- .../python/maven/plugin/LockPackagesMojo.java | 2 +- .../python/embedding/tools/vfs/VFSUtils.java | 113 ++++++------------ .../python/tasks/AbstractPackagesTask.java | 22 ++-- .../python/tasks/InstallPackagesTask.java | 4 +- .../python/tasks/LockPackagesTask.java | 4 +- 12 files changed, 144 insertions(+), 235 deletions(-) diff --git a/docs/user/Embedding-Build-Tools.md b/docs/user/Embedding-Build-Tools.md index ef2f6d8460..c5fc0a8283 100644 --- a/docs/user/Embedding-Build-Tools.md +++ b/docs/user/Embedding-Build-Tools.md @@ -79,31 +79,32 @@ Any manual change will be overridden by the plugin during the build. The _src_ subdirectory is left to be manually populated by the user with custom Python scripts or modules. -## Python Dependency Management To manage third-party Python packages, a [Python virtual environment](https://docs.python.org/3.11/tutorial/venv.html) is used behind the scenes. -Whether deployed in a virtual filesystem or an external directory, its contents are solely managed by the plugin based on the Python packages -specified in the plugin configuration or a Python requirements file. +Whether deployed in a virtual filesystem or an external directory, its contents are managed by the plugin based on the Python packages +specified in the plugin configuration. + +## Python Dependency Management +The list of third-party Python packages to be downloaded and installed can be specified in the particular plugin`s configuration. Unfortunately, +Python does not enforce strict versioning of dependencies, which can result in problems if a third-party package or one of its transitive +dependencies is unexpectedly updated to a newer version, leading to unforeseen behavior. -If a requirements file is provided, it is used exclusively for downloading and installing Python packages. -If the file does not exist, the package list from the plugin configuration is used. -In the case where both a requirements file exists and packages are specified in the plugin configuration, -the packages in the configuration must be an exact subset of those listed in the requirements file. +It is regarded as good practice to always specify a Python package with its exact version. In simpler scenarios, where only a few packages +are required, specifying the exact version of each package in the plugin configuration, +along with their transitive dependencies, might be sufficient. However, this method is often impractical, +as manually managing the entire dependency tree can quickly become overwhelming. -### Freezing Dependencies -When installing packages, additional dependencies may be pulled into the virtual environment. Since Python does not -enforce exact versioning of dependencies, this can lead to issues if a third-party package or one of its transitive dependencies -is suddenly updated to a newer version, causing unexpected behavior. +### Locking Dependencies -In simpler scenarios, where only a few packages are needed, it may be sufficient to specify each package and -its exact version in the plugin configuration. However, this approach is not always practical, and manually managing -the entire dependency tree can quickly become cumbersome. +For these cases, we **highly recommend locking** all Python dependencies whenever there is a change +in the list of required packages for a project. The GraalPy plugins provide an action to do so, +and as a result, a GraalPy lock file will be created, listing all required Python packages with their specific versions +based on the packages defined in the plugin configuration and their dependencies. Subsequent GraalPy plugin executions +will then use this file exclusively to install all packages with guaranteed versions. -For these cases, we **highly recommend freezing** all Python dependencies whenever there is a change in the required packages for the project. -As a result a requirements file will be created listing all required Python packages with their specific versions, based on the packages defined -in the plugin configuration and their dependencies. Subsequent GraalPy plugin executions will then use this file exclusively to install all packages -with a guaranteed version. +The default location of the lock file is in the project root, and since it serves as input for generating resources, +it should be stored alongside other project files in a version control system. -For information on the specific Maven or Gradle freeze commands, please refer to the plugin descriptions below in this document. +For information on the specific Maven or Gradle lock packages actions, please refer to the plugin descriptions below in this document. ## GraalPy Maven Plugin @@ -132,12 +133,11 @@ The Python packages and their versions are specified as if used with `pip`: ... ``` -- The **requirementsFile** element can specify the path to a Python requirements file which has to follow -the python [requirements file format](https://pip.pypa.io/en/stable/reference/requirements-file-format/). -Default value is `${basedir}/requirements.txt`. +- The **graalPyLockFile** element can specify an alternative path to a GraalPy lock file. +Default value is `${basedir}/graalpy.lock`. ```xml - ${basedir}/python-requirements.txt + ${basedir}/graalpy.lock ... ``` @@ -157,15 +157,15 @@ Remember to use the appropriate `GraalPyResources` API to create the Context. Th ``` -### Freezing Installed Packages -To freeze the current state of the installed packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages`. +### Locking Python Packages +To lock the current state of the installed packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:lock-packages`. ```bash -$ mvn org.graalvm.python:graalpy-maven-plugin:freeze-installed-packages +$ mvn org.graalvm.python:graalpy-maven-plugin:lock-packages ``` -*Note that the action will override the existing requirements file, no matter if it was previously generated by the plugin or created manually.* +*Note that the action will override the existing lock file.* -For more information on managing Python packages and working with a requirements file, please refer to the descriptions of -the `requirementsFile` and `packages` fields in the [plugin configuration](#maven-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) section +For more information on managing Python packages, please refer to the descriptions of +the `graalPyLockFile` and `packages` fields in the [plugin configuration](#maven-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) section above in this document. ## GraalPy Gradle Plugin @@ -195,12 +195,11 @@ The plugin can be configured in the `graalPy` block: } ``` -- The **requirementsFile** element can specify the path to a Python requirements file which has to follow - the python [requirements file format](https://pip.pypa.io/en/stable/reference/requirements-file-format/). - Default value is `$rootDir/requirements.txt`. +- The **graalPyLockFile** element can specify an alternative path to a GraalPy lock file. + Default value is `$rootDir/graalpy.lock`. ``` graalPy { - requirementsFile = file("$rootDir/python-requirements.txt") + graalPyLockFile = file("$rootDir/graalpy.lock") ... } ``` @@ -227,15 +226,15 @@ dependency `org.graalvm.python:python` to the community build: `org.graalvm.pyth ... } ``` -### Freezing Installed Packages -To freeze the current state of the installed packages, execute the GraalPy plugin task `graalpyFreezeInstalledPackages`. +### Locking Python Packages +To lock the current state of declared packages, execute the GraalPy plugin task `graalPyLockPackages`. ```bash -$ gradle graalpyFreezeInstalledPackages +$ gradle graalPyLockPackages ``` -*Note that the action will override the existing requirements file, no matter if it was previously generated by the plugin or created manually.* +*Note that the action will override the existing lock file.* -For more information on managing Python packages and working with a requirements file, please refer to the descriptions of -the `requirementsFile` and `packages` fields in the [plugin configuration](#gradle-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) sections +For more information on managing Python packages, please refer to the descriptions of +the `graalPyLockFile` and `packages` fields in the [plugin configuration](#gradle-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) sections in this document. ## Related Documentation diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index c49d1a6419..8e412c72eb 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -59,11 +59,11 @@ private EmbeddingTestUtils() { } public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException { - createVenv(venvDir, graalPyVersion, log, null, null, null, null, null, packages); + createVenv(venvDir, graalPyVersion, log, null, null, null, null, packages); } public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile, - String lockFileHeader, String wrongPackageVersionError, String missingLockFileWarning, String packageRemovedError, + String lockFileHeader, String missingLockFileWarning, String packageRemovedError, String... packages) throws IOException { try { info(log, "<<<<<< create test venv %s <<<<<<", venvDir); @@ -71,7 +71,7 @@ public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog Launcher launcher = createLauncher(venvDir); if (lockFile != null) { VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile, - lockFileHeader, wrongPackageVersionError, packageRemovedError, missingLockFileWarning, + lockFileHeader, packageRemovedError, missingLockFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 6ab2667038..b54afc4c0c 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -87,7 +87,6 @@ public class VFSUtilsTest { private static final String PACKAGE_WAS_REMOVED = "A package with transitive dependencies was removed since last install, setting up a clean venv"; private static final String LOCK_FILE_HEADER = "generated by graalpy tests\nwith a two line header"; private static final String PACKAGES_CHANGED_ERROR = "packages changed in lock file %s, current packages %s, previous packages %s"; - private static final String WRONG_PKG_VERSION_ERROR = "wrong package version %s"; private static final String MISSING_LOCK_FILE_WARNING = "missing lock file"; private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; @@ -212,10 +211,12 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), true); assertTrue(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); - // install packages again, assert that venv wasn't created and packages weren't installed + // install packages again, assert that venv wasn't created again and packages weren't + // installed log.clearOutput(); createVenv(venvDir, "0.1", log, lockFile, "hello-world", "tiny-tiny"); assertTrue(Files.exists(venvDir)); @@ -223,6 +224,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { assertFalse(log.getOutput().contains("pip install")); assertFalse(log.getOutput().contains("hello-world")); assertFalse(log.getOutput().contains("tiny-tiny")); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world", "tiny-tiny"); checkVenvContentsFile(contents, "0.1", "hello-world", "tiny-tiny"); @@ -236,20 +238,22 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { assertTrue(log.getOutput().contains("pip install")); assertTrue(log.getOutput().contains("hello-world")); assertFalse(log.getOutput().contains("tiny-tiny")); + assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); checkVenvContentsFile(contents, "0.1", "hello-world"); // install only hello-world again, assert that venv wasn't created and // packages weren't installed log.clearOutput(); - createVenv(venvDir, "0.1", log, lockFile, "hello-world"); + createVenv(venvDir, "0.1", log, lockFile, "hello-world==0.2"); assertTrue(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); - assertFalse(log.getOutput().contains("pip install")); - assertFalse(log.getOutput().contains("hello-world")); - assertFalse(log.getOutput().contains("tiny-tiny")); + assertTrue(log.getOutput().contains("pip install")); + assertTrue(log.getOutput().contains("pip uninstall")); + assertTrue(log.getOutput().contains("hello-world")); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); checkInstalledPackages(venvDir.resolve("installed.txt"), "hello-world"); - checkVenvContentsFile(contents, "0.1", "hello-world"); + checkVenvContentsFile(contents, "0.1", "hello-world==0.2"); } /** @@ -269,6 +273,7 @@ public void withoutLockFile() throws IOException { assertFalse(Files.exists(venvDir)); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); + assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); createVenv(venvDir, "0.1", log, "hello-world==0.1"); @@ -362,7 +367,7 @@ private static void createWithLockFile(Path venvDir, Path lockFile, TestLog log, } private static void lock(Path venvDir, Path lockFile, TestLog log, String... packages) throws IOException { - VFSUtils.lockPackages(venvDir, Arrays.asList(packages), lockFile, LOCK_FILE_HEADER, WRONG_PKG_VERSION_ERROR, createLauncher(venvDir), "0.1", log); + VFSUtils.lockPackages(venvDir, Arrays.asList(packages), lockFile, LOCK_FILE_HEADER, createLauncher(venvDir), "0.1", log); } private static List createLockFileHeader(String graalPyVersion, String... packages) { @@ -395,12 +400,12 @@ public void installAndLock() throws IOException { assertTrue(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); log.clearOutput(); - // lock without version - fails - checkException(IOException.class, () -> lock(venvDir, lockFile, log, "requests")); - assertFalse(Files.exists(lockFile)); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); + // lock without version + lock(venvDir, lockFile, log, "requests"); + assertTrue(Files.exists(lockFile)); assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); - // lock with version - ok + // lock with version + Files.delete(lockFile); lock(venvDir, lockFile, log, "requests==2.32.2"); checkLockFile(lockFile, new String[]{"requests==2.32.2"}, "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); @@ -410,7 +415,6 @@ public void installAndLock() throws IOException { // reinstall without exact version declared - fails checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests")); checkVenvCreate(log.getOutput(), false); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, "requests"))); assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.2"); @@ -554,29 +558,6 @@ public void installAndLock() throws IOException { log.clearOutput(); } - @Test - public void invalidVersionFormatTest() throws NoSuchMethodException { - TestLog log = new TestLog(); - checkWrongPkgVersionFormat("==2.2", log); - checkWrongPkgVersionFormat("==", log); - checkWrongPkgVersionFormat("somepkg==", log); - - checkWrongPkgVersionFormat("somepkg", log); - checkWrongPkgVersionFormat("somepkg==2.*", log); - checkWrongPkgVersionFormat("==*", log); - for (String v : new String[]{"", "<=", ">=", "~="}) { - checkWrongPkgVersionFormat("somepkg" + v + "2.2.0", log); - } - } - - private static void checkWrongPkgVersionFormat(String pkg, TestLog log) throws NoSuchMethodException { - Method m = VFSUtils.class.getDeclaredMethod("checkVersionFormat", List.class, String.class, BuildToolLog.class); - m.setAccessible(true); - checkException(IOException.class, () -> m.invoke(VFSUtils.class, Arrays.asList(pkg), WRONG_PKG_VERSION_ERROR, log)); - assertTrue(log.getOutput().contains(String.format(WRONG_PKG_VERSION_ERROR, pkg))); - log.clearOutput(); - } - @Test public void packageRemoved() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException { Path tmpDir = Files.createTempDirectory("packageRemoved"); @@ -686,7 +667,7 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, } private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path lockFile, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, LOCK_FILE_HEADER, WRONG_PKG_VERSION_ERROR, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR, + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, LOCK_FILE_HEADER, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR, packages); } diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index 0a15c3b3ff..81369cfc27 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -46,8 +46,7 @@ from tests.standalone import util from tests.standalone.util import TemporaryTestDirectory, Logger -MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-gradle-plugin configuration" -WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-gradle-plugin configuration have no exact version declared" +MISSING_FILE_WARNING = "The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration" PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file" VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install" @@ -207,16 +206,16 @@ def check_lock_packages(self, community): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("pip install", out) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=True) assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # lock - fails due to no version + # lock without version cmd = gradlew_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("BUILD SUCCESS", out, contains=False) + util.check_ouput("BUILD SUCCESS", out, contains=True) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) - assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + os.remove(os.path.join(target_dir, "test-graalpy.lock")) # lock with correct version log = Logger() @@ -247,6 +246,11 @@ def check_lock_packages(self, community): util.check_ouput(MISSING_FILE_WARNING, out, contains=False) assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + # should be able to import requests if installed + util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "org", "example", "GraalPy.java"), + "import hello", + "import requests; import hello") + # rebuild with lock and exec cmd = gradlew_cmd + ["build", "run"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) @@ -262,17 +266,10 @@ def check_lock_packages(self, community): # stop using lock file field and test with default value {project_root}/graalpy.lock shutil.move(os.path.join(target_dir, "test-graalpy.lock"), os.path.join(target_dir, "graalpy.lock")) - # should be able to import requests if installed - util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "org", "example", "GraalPy.java"), - "import hello", - "import requests; import hello") - - # clean and rebuild with lock and exec + # clean and rebuild fails cmd = gradlew_cmd + ["clean", "build", "run"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("pip install", out) - util.check_ouput("hello java", out) + util.check_ouput("BUILD SUCCESS", out, contains=False) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) def check_gradle_generated_app_external_resources(self): @@ -634,13 +631,13 @@ def packages_termcolor(self, community): }} """) - def lock_packages_config(self, community, pkgs, lock=None): - lock_file = f"graalPyLockFile = file(\"{lock}\")" if lock else "" + def lock_packages_config(self, community, pkgs, lock_file=None): + lf = f"graalPyLockFile = file(\"{lock_file}\")" if lock_file else "" packages = "packages = [\"" + "\",\"".join(pkgs) + "\"]" return textwrap.dedent(f""" graalPy {{ {packages} - {lock_file} + {lf} {_community_as_property(community)} }} """) @@ -810,15 +807,15 @@ def copy_build_files(self, target_dir): def empty_plugin(self, community): return f"graalPy {{ {_community_as_property(community) } }}" - def lock_packages_config(self, community, pkgs, lock=None): - lock_file = f"graalPyLockFile = file(\"{lock}\")" if lock else "" + def lock_packages_config(self, community, pkgs, lock_file=None): + lf = f"graalPyLockFile = file(\"{lock_file}\")" if lock_file else "" packages = "" for p in pkgs: packages += f" packages.add(\"{p}\")\n" return textwrap.dedent(f""" graalPy {{ {packages} - {lock_file} + {lf} {_community_as_property(community)} }} """) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py index ae4b9793a7..2d23d3433a 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py @@ -48,8 +48,7 @@ from tests.standalone import util from tests.standalone.util import TemporaryTestDirectory, Logger -MISSING_FILE_WARNING = "Some python dependencies were installed in addition to packages declared in graalpy-maven-plugin configuration" -WRONG_PACKAGE_VERSION_FORMAT = "Some python packages in graalpy-maven-plugin configuration have no exact version declared" +MISSING_FILE_WARNING = "The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration." PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file" VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install" @@ -209,16 +208,16 @@ def test_lock_file(self): out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("pip install", out) util.check_ouput("BUILD SUCCESS", out) - util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + util.check_ouput(MISSING_FILE_WARNING, out, contains=True) assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # freeze - fails due to no version + # freeze without version cmd = mvnw_cmd + ["org.graalvm.python:graalpy-maven-plugin:lock-packages", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput(MISSING_FILE_WARNING, out, contains=False) - util.check_ouput(WRONG_PACKAGE_VERSION_FORMAT, out) - assert not os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + util.check_ouput("BUILD SUCCESS", out, contains=True) + util.check_ouput(MISSING_FILE_WARNING, out, contains=False) + assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + os.remove(os.path.join(target_dir, "test-graalpy.lock")) # freeze with correct version util.replace_in_file(os.path.join(target_dir, "pom.xml"), "requests", "requests==2.32.3") @@ -228,7 +227,7 @@ def test_lock_file(self): util.check_ouput(MISSING_FILE_WARNING, out, contains=False) assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) - # add termcolor and build - fails as it is not part of ock file + # add termcolor and build - fails as it is not part of lock file util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "termcolor==2.2\n") cmd = mvnw_cmd + ["package", "-DgraalPyLockFile=test-graalpy.lock"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) @@ -246,6 +245,11 @@ def test_lock_file(self): util.check_ouput(MISSING_FILE_WARNING, out, contains=False) assert os.path.exists(os.path.join(target_dir, "test-graalpy.lock")) + # should be able to import requests if installed + util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "it", "pkg", "GraalPy.java"), + "import hello", + "import requests; import hello") + # rebuild with lock file and exec cmd = mvnw_cmd + ["package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) @@ -258,17 +262,10 @@ def test_lock_file(self): util.replace_in_file(os.path.join(target_dir, "pom.xml"), "", "") - # should be able to import requests if installed - util.replace_in_file(os.path.join(target_dir, "src", "main", "java", "it", "pkg", "GraalPy.java"), - "import hello", - "import requests; import hello") - - # clean and rebuild with lock and exec - cmd = mvnw_cmd + ["clean", "package", "exec:java", "-Dexec.mainClass=it.pkg.GraalPy"] + # clean and rebuild fails + cmd = mvnw_cmd + ["clean", "package"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) - util.check_ouput("BUILD SUCCESS", out) - util.check_ouput("pip install", out) - util.check_ouput("hello java", out) + util.check_ouput("BUILD SUCCESS", out, contains=False) util.check_ouput(MISSING_FILE_WARNING, out, contains=False) @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true") diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index d40685b0be..3d2566ced1 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -85,20 +85,12 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { protected static final String MISSING_LOCK_FILE_WARNING = """ - Additional python dependencies were installed besides the packages declared in graalpy-maven-plugin configuration. + The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. + This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. - It is highly recommended to lock python dependencies by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. + In such cases, it is strongly recommended to lock the Python dependencies by executing the Maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ - Some python packages in graalpy-maven-plugin configuration have no exact version declared: %s - - When using the graalpy-maven-plugin together with a lock file, it is necessary to declare python packages in format [package_name]==[version]. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management """; diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java index 95ebe99763..d7dfe7c5bb 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java @@ -69,7 +69,7 @@ private void manageVenv() throws MojoExecutionException { MavenDelegateLog log = new MavenDelegateLog(getLog()); Path requirements = getLockFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, requirements, LOCK_FILE_HEADER, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java index 1c91436792..52458551de 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java @@ -71,7 +71,7 @@ protected void manageVenv() throws MojoExecutionException { Path requirements = getLockFile(); try { - VFSUtils.lockPackages(venvDirectory, packages, requirements, LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.lockPackages(venvDirectory, packages, requirements, LOCK_FILE_HEADER, createLauncher(), getGraalPyVersion(project), log); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 9b477cb6dc..8d17a30ef5 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -356,7 +356,7 @@ private static String parseVersion(List lines, Path file, BuildToolLog l throw wrongFormat(file, lines, log); } - private static IOException wrongFormat(Path file, List lines, BuildToolLog log) throws IOException { + private static IOException wrongFormat(Path file, List lines, BuildToolLog log) { if (log.isDebugEnabled()) { log.debug("wrong format of lock file " + file); for (String l : lines) { @@ -397,11 +397,11 @@ private static List getHeaderList(String lockFileHeader) { } public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { - createVenv(venvDirectory, packagesArgs, null, null, null, null, null, launcherArgs, graalPyVersion, log); + createVenv(venvDirectory, packagesArgs, null, null, null, null, launcherArgs, graalPyVersion, log); } public static void createVenv(Path venvDirectory, List packages, Path lockFilePath, - String lockFileHeader, String wrongPackageVersionFormatError, String packagesChangedError, String missingLockFileWarning, + String lockFileHeader, String packagesChangedError, String missingLockFileWarning, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); @@ -409,7 +409,6 @@ public static void createVenv(Path venvDirectory, List packages, Path lo Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); if (lockFilePath != null) { - Objects.requireNonNull(wrongPackageVersionFormatError); Objects.requireNonNull(packagesChangedError); } @@ -421,7 +420,7 @@ public static void createVenv(Path venvDirectory, List packages, Path lo lockFile = LockFile.fromFile(lockFilePath, lockFileHeader, log); } - if (!checkPackages(venvDirectory, pluginPackages, lockFile, wrongPackageVersionFormatError, packagesChangedError, log)) { + if (!checkPackages(venvDirectory, pluginPackages, lockFile, packagesChangedError, log)) { return; } @@ -431,19 +430,25 @@ public static void createVenv(Path venvDirectory, List packages, Path lo if (lockFile != null) { installed = install(venvDirectory, lockFile, log); } else { - installed = install(venvDirectory, pluginPackages, venvContents, missingLockFileWarning, log); + installed = install(venvDirectory, pluginPackages, venvContents, log); + missingLockFileWarning(venvDirectory, pluginPackages, missingLockFileWarning, log); } if (installed) { venvContents.write(pluginPackages); } } - private static boolean removedFromPluginPackages(Path venvDirectory, VenvContents venvContents, List pluginPackages) throws IOException { - if (venvContents == null || venvContents.packages == null) { - return false; + private static boolean removedFromPluginPackages(Path venvDirectory, List pluginPackages) throws IOException { + if (Files.exists(venvDirectory)) { + // comapre with contents from prev install if such already present + VenvContents contents = VenvContents.fromVenv(venvDirectory); + if (contents == null || contents.packages == null) { + return false; + } + List installedPackages = InstalledPackages.fromVenv(venvDirectory).packages; + return removedFromPluginPackages(pluginPackages, contents.packages, installedPackages); } - List installedPackages = InstalledPackages.fromVenv(venvDirectory).packages; - return removedFromPluginPackages(pluginPackages, venvContents.packages, installedPackages); + return false; } private static boolean removedFromPluginPackages(List pluginPackages, List contentsPackages, List installedPackages) { @@ -482,18 +487,15 @@ private static String getByName(String name, List packages) { return null; } - public static void lockPackages(Path venvDirectory, List packages, Path lockFile, String lockFileHeader, String wrongPackageVersionFormatError, Launcher launcher, + public static void lockPackages(Path venvDirectory, List packages, Path lockFile, String lockFileHeader, Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); Objects.requireNonNull(lockFile); Objects.requireNonNull(lockFileHeader); - Objects.requireNonNull(wrongPackageVersionFormatError); Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); - checkVersionFormat(packages, wrongPackageVersionFormatError, log); - createVenv(venvDirectory, packages, launcher, graalPyVersion, log); if (Files.exists(venvDirectory)) { @@ -519,21 +521,13 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path } } - private static boolean checkPackages(Path venvDirectory, List pluginPackages, LockFile lockFile, - String wrongPackageVersionFormatError, String packagesListChangedError, BuildToolLog log) throws IOException { - VenvContents contents = null; - if (Files.exists(venvDirectory)) { - // get contents from prev install if such already present - contents = VenvContents.fromVenv(venvDirectory); - } - + private static boolean checkPackages(Path venvDirectory, List pluginPackages, LockFile lockFile, String packagesListChangedError, BuildToolLog log) throws IOException { if (lockFile != null) { - checkVersionFormat(pluginPackages, wrongPackageVersionFormatError, log); checkPluginPackagesInLockFile(pluginPackages, lockFile, packagesListChangedError, log); logPackages(lockFile.packages, lockFile.path, log); return needVenv(venvDirectory, lockFile.packages, log); } else { - if (removedFromPluginPackages(venvDirectory, contents, pluginPackages)) { + if (removedFromPluginPackages(venvDirectory, pluginPackages)) { // a package was removed, and we do not know if it did not leave behind any // transitive dependencies - rather create whole venv again to avoid it growing info(log, "A package with transitive dependencies was removed since last install, setting up a clean venv"); @@ -621,66 +615,25 @@ private static boolean install(Path venvDirectory, LockFile lockFile, BuildToolL return false; } - private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, String missingLockFileWarning, BuildToolLog log) throws IOException { + private static boolean install(Path venvDirectory, List newPackages, VenvContents venvContents, BuildToolLog log) throws IOException { boolean needsUpdate = false; needsUpdate |= deleteUnwantedPackages(venvDirectory, newPackages, venvContents.packages, log); needsUpdate |= installWantedPackages(venvDirectory, newPackages, venvContents.packages, log); - if (needsUpdate) { - List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); - if (missingLockFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingLockFileWarning")) { - if (installedPackages.size() > newPackages.size()) { - missingLockFileWarning(log, missingLockFileWarning); - } - } - return true; - } - return false; - } - - private static void missingLockFileWarning(BuildToolLog log, String missingLockFileWarning) { - if (log.isWarningEnabled()) { - String txt = missingLockFileWarning + "\n"; - for (String t : txt.split("\n")) { - log.warning(t); - } - } - } - - /** - * check that packages are declared with a specific version - package_name==version - */ - private static void checkVersionFormat(List packages, String wrongPackageVersionFormatError, BuildToolLog log) throws IOException { - Objects.requireNonNull(packages); - Objects.requireNonNull(wrongPackageVersionFormatError); - Objects.requireNonNull(log); - - StringBuilder sb = new StringBuilder(); - for (String pkg : packages) { - if (!checkValidPackageVersion(pkg)) { - sb.append(!sb.isEmpty() ? ", " : "").append(pkg); - } - } - if (!sb.isEmpty()) { - wrongPackageVersionError(log, wrongPackageVersionFormatError, sb.toString()); - } + return needsUpdate; } - private static boolean checkValidPackageVersion(String pkg) { - int idx = pkg.indexOf("=="); - if (idx <= 0) { - return false; - } else { - String version = pkg.substring(idx + 2).trim(); - if (version.isEmpty() || version.contains("*")) { - return false; + private static void missingLockFileWarning(Path venvDirectory, List newPackages, String missingLockFileWarning, BuildToolLog log) throws IOException { + List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log); + if (missingLockFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingLockFileWarning")) { + if (!newPackages.containsAll(installedPackages)) { + if (log.isWarningEnabled()) { + String txt = missingLockFileWarning + "\n"; + for (String t : txt.split("\n")) { + log.warning(t); + } + } } } - return true; - } - - private static void wrongPackageVersionError(BuildToolLog log, String wrongPackageVersionFormatError, String pkgs) throws IOException { - extendedError(log, String.format(wrongPackageVersionFormatError, pkgs) + "\n"); - throw new IOException("invalid package format: " + pkgs); } /** @@ -698,7 +651,9 @@ private static void checkPluginPackagesInLockFile(List pluginPackages, L throws IOException { if (pluginPackages.size() != lockFilePackages.size() || !pluginPackages.containsAll(lockFilePackages)) { - extendedError(log, String.format(packagesChangedError, lockFilePath, String.join(", ", pluginPackages), String.join(", ", lockFilePackages)) + "\n"); + String pluginPkgsString = pluginPackages.isEmpty() ? "None" : String.join(", ", pluginPackages); + String lockFilePkgsString = lockFilePackages.isEmpty() ? "None" : String.join(", ", lockFilePackages); + extendedError(log, String.format(packagesChangedError, lockFilePath, pluginPkgsString, lockFilePkgsString) + "\n"); throw new IOException("inconsistent packages"); } } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 66b78036f8..d9e09c035a 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -80,7 +80,7 @@ public abstract class AbstractPackagesTask extends DefaultTask { protected static final String LOCK_FILE_HEADER = """ - This file was generated by gradle task 'graalpyLockPackages'. + This file was generated by gradle task 'graalPyLockPackages'. WARNING: Any manual changes are done at your own risk and will be overwritten when the task is executed. @@ -93,21 +93,13 @@ public abstract class AbstractPackagesTask extends DefaultTask { protected static final String MISSING_LOCK_FILE_WARNING = """ - WARNING: Additional python dependencies were installed besides the packages declared in graalpy-gradle-plugin configuration. - - WARNING: It is highly recommended to lock python dependencies by running the gradle task 'graalpyLockPackages'. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String WRONG_PACKAGE_VERSION_FORMAT_ERROR = """ - Some python packages in graalpy-gradle-plugin configuration have no exact version declared: %s + WARNING: The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. + WARNING: This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. + + WARNING: In such cases, it is strongly recommended to lock the Python dependencies by executing the Gradle task 'graalPyLockPackages'. - When using the graalpy-gradle-plugin together with graalpy.lock file, it is necessary to declare python packages in format [package_name]==[version]. + For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - """; protected static final String PACKAGES_CHANGED_ERROR = """ @@ -117,7 +109,7 @@ public abstract class AbstractPackagesTask extends DefaultTask { Packages currently declared in graalpy-gradle-plugin configuration: %s Packages which were used to generate the lock file: %s - The lock file has to be refreshed by running the gradle task 'graalpyLockPackages'. + The lock file has to be refreshed by running the gradle task 'graalPyLockPackages'. For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index df11ce6c31..a91a65dfbf 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -69,9 +69,7 @@ public abstract class InstallPackagesTask extends AbstractPackagesTask { public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { - VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), - LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, - createLauncher(), getPolyglotVersion().get(), getLog()); + VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), LOCK_FILE_HEADER, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java index 53e70d9fb0..6f90e6d114 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java @@ -64,9 +64,7 @@ public void exec() throws GradleException { Path venvDirectory = getVenvDirectory(); try { - VFSUtils.lockPackages(getVenvDirectory(), getPackages().get(), getLockFilePath(), - LOCK_FILE_HEADER, WRONG_PACKAGE_VERSION_FORMAT_ERROR, - createLauncher(), getPolyglotVersion().get(), getLog()); + VFSUtils.lockPackages(getVenvDirectory(), getPackages().get(), getLockFilePath(), LOCK_FILE_HEADER, createLauncher(), getPolyglotVersion().get(), getLog()); } catch (IOException e) { throw new GradleException(String.format("failed to lock packages in python virtual environment %s", venvDirectory), e); } From 96df78a68bc71137d060a2c8b26a05986a16584d Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 13 Feb 2025 11:49:41 +0100 Subject: [PATCH 075/512] Add env files for building GraalPy standalones in various configurations * These env files only build the GraalPy standalone and nothing else. --- mx.graalpython/env_files.md | 11 +++++++++++ mx.graalpython/jvm | 5 +++++ mx.graalpython/jvm-ce | 5 +++++ mx.graalpython/jvm-ce-libgraal | 6 ++++++ mx.graalpython/jvm-ee | 7 +++++++ mx.graalpython/jvm-ee-libgraal | 6 ++++++ mx.graalpython/native-ce | 7 +++++++ mx.graalpython/native-ee | 7 +++++++ mx.graalpython/native-ee-aux | 9 +++++++++ 9 files changed, 63 insertions(+) create mode 100644 mx.graalpython/env_files.md create mode 100644 mx.graalpython/jvm create mode 100644 mx.graalpython/jvm-ce create mode 100644 mx.graalpython/jvm-ce-libgraal create mode 100644 mx.graalpython/jvm-ee create mode 100644 mx.graalpython/jvm-ee-libgraal create mode 100644 mx.graalpython/native-ce create mode 100644 mx.graalpython/native-ee create mode 100644 mx.graalpython/native-ee-aux diff --git a/mx.graalpython/env_files.md b/mx.graalpython/env_files.md new file mode 100644 index 0000000000..7bb92f7f2f --- /dev/null +++ b/mx.graalpython/env_files.md @@ -0,0 +1,11 @@ +Here is how the various env files relate to each other: +* `jvm` + * `jvm-ce`: + GraalVM Community Compiler + * `jvm-ce-libgraal`: + libgraal + * `native-ce`: + libpythonvm + `Truffle Macro` + * `jvm-ee`: + Oracle GraalVM Compiler + `Truffle enterprise` + license + `LLVM Runtime Native Enterprise` + * `jvm-ee-libgraal`: + libgraal + * `native-ee`: + libpythonvm + `Truffle Macro Enterprise` + Native Image G1 + * `native-ee-aux`: + `AuxiliaryEngineCache`, - Native Image G1 (currently incompatible) + +They all build the GraalPy standalone and nothing else to optimize build time. diff --git a/mx.graalpython/jvm b/mx.graalpython/jvm new file mode 100644 index 0000000000..3d55e5dbcb --- /dev/null +++ b/mx.graalpython/jvm @@ -0,0 +1,5 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools +COMPONENTS=GraalVM Python,suite:tools +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/jvm-ce b/mx.graalpython/jvm-ce new file mode 100644 index 0000000000..e3c380c1fb --- /dev/null +++ b/mx.graalpython/jvm-ce @@ -0,0 +1,5 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/compiler +COMPONENTS=GraalVM Python,suite:tools,GraalVM compiler +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/jvm-ce-libgraal b/mx.graalpython/jvm-ce-libgraal new file mode 100644 index 0000000000..e2deb64728 --- /dev/null +++ b/mx.graalpython/jvm-ce-libgraal @@ -0,0 +1,6 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/compiler,/substratevm +COMPONENTS=GraalVM Python,suite:tools,GraalVM compiler,SubstrateVM,LibGraal +NATIVE_IMAGES=lib:jvmcicompiler +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/jvm-ee b/mx.graalpython/jvm-ee new file mode 100644 index 0000000000..9df146cf1d --- /dev/null +++ b/mx.graalpython/jvm-ee @@ -0,0 +1,7 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/graalpython-enterprise,/graal-enterprise,/vm-enterprise,/sulong-managed,/substratevm-enterprise +COMPONENTS=GraalVM Python,suite:tools,GraalVM enterprise compiler,Truffle enterprise,GraalVM enterprise license files,LLVM Runtime Native Enterprise,SubstrateVM Enterprise +NATIVE_IMAGES=false +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES +# NOTE: SVM EE is added as a workaround to tell the JVM standalone to be EE diff --git a/mx.graalpython/jvm-ee-libgraal b/mx.graalpython/jvm-ee-libgraal new file mode 100644 index 0000000000..e2f229fa59 --- /dev/null +++ b/mx.graalpython/jvm-ee-libgraal @@ -0,0 +1,6 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/graalpython-enterprise,/graal-enterprise,/vm-enterprise,/sulong-managed,/substratevm-enterprise +COMPONENTS=GraalVM Python,suite:tools,GraalVM enterprise compiler,Truffle enterprise,GraalVM enterprise license files,LLVM Runtime Native Enterprise,SubstrateVM Enterprise,LibGraal Enterprise +NATIVE_IMAGES=lib:jvmcicompiler +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/native-ce b/mx.graalpython/native-ce new file mode 100644 index 0000000000..2b4fadfbe7 --- /dev/null +++ b/mx.graalpython/native-ce @@ -0,0 +1,7 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/compiler,/substratevm +COMPONENTS=GraalVM Python,suite:tools,GraalVM compiler,SubstrateVM,Truffle Macro +NATIVE_IMAGES=lib:pythonvm +GENERATE_DEBUGINFO=false +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/native-ee b/mx.graalpython/native-ee new file mode 100644 index 0000000000..8d243ebfc5 --- /dev/null +++ b/mx.graalpython/native-ee @@ -0,0 +1,7 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/graalpython-enterprise,/graal-enterprise,/vm-enterprise,/sulong-managed,/substratevm-enterprise +COMPONENTS=GraalVM Python,suite:tools,GraalVM enterprise compiler,Truffle enterprise,GraalVM enterprise license files,LLVM Runtime Native Enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise +NATIVE_IMAGES=lib:pythonvm +GENERATE_DEBUGINFO=false +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES diff --git a/mx.graalpython/native-ee-aux b/mx.graalpython/native-ee-aux new file mode 100644 index 0000000000..206eae6abb --- /dev/null +++ b/mx.graalpython/native-ee-aux @@ -0,0 +1,9 @@ +GRAALVM_SKIP_ARCHIVE=true +DYNAMIC_IMPORTS=/tools,/graalpython-enterprise,/graal-enterprise,/vm-enterprise,/sulong-managed,/substratevm-enterprise +COMPONENTS=GraalVM Python,suite:tools,GraalVM enterprise compiler,Truffle enterprise,GraalVM enterprise license files,LLVM Runtime Native Enterprise,SubstrateVM Enterprise,Truffle Macro Enterprise +NATIVE_IMAGES=lib:pythonvm +EXTRA_IMAGE_BUILDER_ARGUMENTS=pythonvm:-H:+AuxiliaryEngineCache pythonvm:-H:ReservedAuxiliaryImageBytes=1073741824 +GENERATE_DEBUGINFO=false +NATIVE_IMAGE_AUXILIARY_ENGINE_CACHE=true +INSTALLABLES=GraalVM Python +BUILD_TARGETS=GRAALVM_STANDALONES From 6979f9c72d5efecdaca54eb818c6a21fda1e5924 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 11 Feb 2025 17:28:44 +0100 Subject: [PATCH 076/512] Use Env#isPreInitialization() instead of ImageInfo.inImageBuildtimeCode() * Necessary to be correct during the pre-initialization of --engine.CacheStore. --- .../graal/python/shell/GraalPythonMain.java | 4 +- .../oracle/graal/python/PythonLanguage.java | 10 +- .../graal/python/builtins/Python3Core.java | 28 +- .../modules/GraalPythonModuleBuiltins.java | 16 +- .../builtins/modules/ImpModuleBuiltins.java | 8 +- .../builtins/modules/SSLModuleBuiltins.java | 10 +- .../modules/SignalModuleBuiltins.java | 9 +- .../builtins/modules/SysModuleBuiltins.java | 4 +- .../builtins/modules/TimeModuleBuiltins.java | 7 +- .../objects/cext/capi/CApiContext.java | 6 +- .../cext/hpy/jni/GraalHPyJNIContext.java | 6 +- .../objects/tuple/StructSequence.java | 11 +- .../graal/python/runtime/AsyncHandler.java | 10 +- .../python/runtime/EmulatedPosixSupport.java | 5 +- .../graal/python/runtime/NFIPosixSupport.java | 4 +- ...xSupport.java => PreInitPosixSupport.java} | 299 +++++++++--------- .../graal/python/runtime/PythonContext.java | 57 ++-- .../oracle/graal/python/util/PythonUtils.java | 5 +- .../standalone/resources/Py2BinLauncher.java | 2 +- .../3/importlib/_bootstrap_external.py | 2 +- .../python/embedding/GraalPyResources.java | 2 +- 21 files changed, 249 insertions(+), 256 deletions(-) rename graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/{ImageBuildtimePosixSupport.java => PreInitPosixSupport.java} (88%) diff --git a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java index 68ba6b5ccc..3b52e31e7d 100644 --- a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java +++ b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java @@ -411,7 +411,7 @@ protected List preprocessArguments(List givenArgs, Map exec_list = new ArrayList<>(); sb.append(System.getProperty("java.home")).append(File.separator).append("bin").append(File.separator).append("java"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index 89417ea024..305f8f3268 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -53,7 +53,6 @@ import java.util.logging.Level; import org.graalvm.home.Version; -import org.graalvm.nativeimage.ImageInfo; import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionKey; import org.graalvm.options.OptionValues; @@ -385,8 +384,8 @@ public StructSequence.DescriptorCallTargets getOrCreateStructSequenceCallTargets return factory.apply(descriptor); } if (descriptor instanceof BuiltinTypeDescriptor builtinDescriptor) { - // There must be finite set of objects initialized at build time, no need for a weak map - assert !ImageInfo.inImageCode() || builtinDescriptor.wasInitializedAtBuildTime(); + // There must be finite set of objects initialized in static final fields, no need for a + // weak map return structSequenceBuiltinTargets.computeIfAbsent(builtinDescriptor, factory); } return getOrCreateStructSeqNonBuiltinTargets(descriptor, factory); @@ -498,6 +497,7 @@ protected boolean patchContext(PythonContext context, Env newEnv) { Python3Core.writeInfo("Cannot use preinitialized context."); return false; } + context.resetPerfCounter(); context.initializeHomeAndPrefixPaths(newEnv, getLanguageHome()); Python3Core.writeInfo("Using preinitialized context."); context.patch(newEnv); @@ -989,7 +989,7 @@ public static Source newSource(PythonContext ctxt, TruffleFile src, String name) } private static Source newSource(PythonContext context, SourceBuilder srcBuilder) throws IOException { - if (getPythonOS() == PLATFORM_WIN32 && ImageInfo.inImageBuildtimeCode()) { + if (getPythonOS() == PLATFORM_WIN32 && context.getEnv().isPreInitialization()) { // canonicalization on windows means something else than on linux and causes issues // with paths srcBuilder.canonicalizePath(false); @@ -1218,7 +1218,7 @@ protected void exitContext(PythonContext context, ExitMode exitMode, int exitCod if (context.getCApiContext() != null) { context.getCApiContext().exitCApiContext(); } - if (!PythonImageBuildOptions.WITHOUT_PLATFORM_ACCESS && !ImageInfo.inImageBuildtimeCode()) { + if (!PythonImageBuildOptions.WITHOUT_PLATFORM_ACCESS && !context.getEnv().isPreInitialization()) { // Reset signal handlers back to what they were PythonModule signalModule = context.lookupBuiltinModule(T__SIGNAL); if (signalModule != null) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index e488973ee4..26cb2a8a1e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -393,8 +393,10 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleFile; +import com.oracle.truffle.api.TruffleLanguage; import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLogger; +import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.object.Shape; import com.oracle.truffle.api.source.Source; @@ -470,7 +472,7 @@ private static void filterBuiltins(List builtins) { builtins.removeAll(toRemove); } - private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed, boolean socketIOAllowed) { + private static PythonBuiltins[] initializeBuiltins(TruffleLanguage.Env env) { List builtins = new ArrayList<>(Arrays.asList(new BuiltinConstructors(), new AbcModuleBuiltins(), new BuiltinFunctions(), @@ -647,9 +649,9 @@ private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed, new JSONModuleBuiltins(), new SREModuleBuiltins(), new AstModuleBuiltins(), - PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !socketIOAllowed) ? null : new SelectModuleBuiltins(), - PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !socketIOAllowed) ? null : new SocketModuleBuiltins(), - PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !socketIOAllowed) ? null : new SocketBuiltins(), + PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !env.isSocketIOAllowed()) ? null : new SelectModuleBuiltins(), + PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !env.isSocketIOAllowed()) ? null : new SocketModuleBuiltins(), + PythonImageBuildOptions.WITHOUT_NATIVE_POSIX && (PythonImageBuildOptions.WITHOUT_JAVA_INET || !env.isSocketIOAllowed()) ? null : new SocketBuiltins(), PythonImageBuildOptions.WITHOUT_PLATFORM_ACCESS ? null : new SignalModuleBuiltins(), new TracebackBuiltins(), new GcModuleBuiltins(), @@ -803,7 +805,7 @@ private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed, builtins.add(new LsprofModuleBuiltins()); builtins.add(LsprofModuleBuiltins.newProfilerBuiltins()); } - if (!PythonImageBuildOptions.WITHOUT_COMPRESSION_LIBRARIES && (nativeAccessAllowed || ImageInfo.inImageBuildtimeCode())) { + if (!PythonImageBuildOptions.WITHOUT_COMPRESSION_LIBRARIES && (env.isNativeAccessAllowed() || env.isPreInitialization())) { builtins.add(new BZ2CompressorBuiltins()); builtins.add(new BZ2DecompressorBuiltins()); builtins.add(new BZ2ModuleBuiltins()); @@ -844,15 +846,15 @@ private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed, private final PythonLanguage language; - public Python3Core(PythonLanguage language, boolean isNativeSupportAllowed, boolean socketIOAllowed) { + public Python3Core(PythonLanguage language, TruffleLanguage.Env env) { this.language = language; - this.builtins = initializeBuiltins(isNativeSupportAllowed, socketIOAllowed); + this.builtins = initializeBuiltins(env); this.coreFiles = initializeCoreFiles(); } @CompilerDirectives.ValueType public static class SysModuleState { - private int recursionLimit = ImageInfo.inImageCode() ? NATIVE_REC_LIM : REC_LIM; + private int recursionLimit = TruffleOptions.AOT ? NATIVE_REC_LIM : REC_LIM; private int checkInterval = 100; private double switchInterval = 0.005; @@ -1040,10 +1042,10 @@ private void initializePython3Core(TruffleString coreHome) { /** * Run post-initialization code that needs a fully working Python environment. This will be run * eagerly when the context is initialized on the JVM or a new context is created on SVM, but is - * omitted when the native image is generated. + * omitted when creating a pre-initialized context. */ - public final void postInitialize() { - if (!ImageInfo.inImageBuildtimeCode() || ImageInfo.inImageRuntimeCode()) { + public final void postInitialize(Env env) { + if (!env.isPreInitialization()) { initialized = false; for (PythonBuiltins builtin : builtins) { @@ -1060,9 +1062,9 @@ public final void postInitialize() { * fallback to another _bz2 implementation (e.g. LLVM or maybe some Java lib). This * needs to be done here and cannot be done in 'initializeBuiltins' because then we * would never include the intrinsified _bz2 module in the native image since native - * access is never allowed during native image build time. + * access is never allowed during context pre-initialization. */ - if (!PythonImageBuildOptions.WITHOUT_COMPRESSION_LIBRARIES && ImageInfo.inImageCode() && !getContext().isNativeAccessAllowed()) { + if (!PythonImageBuildOptions.WITHOUT_COMPRESSION_LIBRARIES && TruffleOptions.AOT && !getContext().isNativeAccessAllowed()) { removeBuiltinModule(BuiltinNames.T_BZ2); } 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 882a36875c..50ad988ae7 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 @@ -83,8 +83,6 @@ import java.util.List; import java.util.logging.Level; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; @@ -179,6 +177,7 @@ import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.TruffleLanguage.Env; import com.oracle.truffle.api.TruffleLogger; +import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -222,7 +221,7 @@ protected List> getNodeFa @Override public void initialize(Python3Core core) { super.initialize(core); - addBuiltinConstant("is_native", ImageInfo.inImageCode()); + addBuiltinConstant("is_native", TruffleOptions.AOT); PythonContext ctx = core.getContext(); TruffleString encodingOpt = ctx.getLanguage().getEngineOption(PythonOptions.StandardStreamEncoding); TruffleString standardStreamEncoding = null; @@ -257,11 +256,10 @@ public void postInitialize(Python3Core core) { PythonContext context = core.getContext(); PythonModule mod = core.lookupBuiltinModule(T___GRAALPYTHON__); PythonLanguage language = context.getLanguage(); - if (!ImageInfo.inImageBuildtimeCode()) { + if (!context.getEnv().isPreInitialization()) { mod.setAttribute(tsLiteral("home"), context.getLanguageHome()); } - mod.setAttribute(tsLiteral("in_image_buildtime"), ImageInfo.inImageBuildtimeCode()); - mod.setAttribute(tsLiteral("in_image"), ImageInfo.inImageCode()); + mod.setAttribute(tsLiteral("in_preinitialization"), context.getEnv().isPreInitialization()); TruffleString coreHome = context.getCoreHome(); TruffleString stdlibHome = context.getStdlibHome(); TruffleString capiHome = context.getCAPIHome(); @@ -324,8 +322,8 @@ PNone run() { * other paths through pymain_run_python are handled in GraalPythonMain and the path * prepending is done in PythonLanguage in those other cases */ - assert !ImageInfo.inImageBuildtimeCode(); PythonContext context = getContext(); + assert !context.getEnv().isPreInitialization(); TruffleString inputFilePath = context.getOption(PythonOptions.InputFilePath); PythonModule sysModule = context.getSysModule(); boolean needsMainImporter = !inputFilePath.isEmpty() && getImporter(sysModule, inputFilePath); @@ -864,11 +862,11 @@ static Object doIt(Object value, @Bind("this") Node inliningTarget, @CachedLibrary(limit = "3") InteropLibrary lib, @Cached PRaiseNode raiseNode) { - if (ImageInfo.inImageBuildtimeCode()) { + if (getContext(inliningTarget).getEnv().isPreInitialization()) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw new UnsupportedOperationException(ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM.toJavaStringUncached()); } - if (ImageInfo.inImageRuntimeCode()) { + if (TruffleOptions.AOT) { CompilerDirectives.transferToInterpreterAndInvalidate(); throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java index 7337778755..6beb7a7aae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java @@ -61,8 +61,6 @@ import java.util.List; import java.util.concurrent.locks.ReentrantLock; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; @@ -458,13 +456,13 @@ public abstract static class ExecBuiltin extends PythonBuiltinNode { @Specialization @TruffleBoundary public Object exec(PythonModule pythonModule) { - final Python3Core core = getContext(); - if (!ImageInfo.inImageBuildtimeCode()) { + final PythonContext context = getContext(); + if (!context.getEnv().isPreInitialization()) { final PythonBuiltins builtins = pythonModule.getBuiltins(); assert builtins != null; // this is a builtin, therefore its builtins must have been // set at this point if (!builtins.isInitialized()) { - doPostInit(core, builtins); + doPostInit(context, builtins); builtins.setInitialized(true); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java index 3b500ccdac..c72e2d4d63 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SSLModuleBuiltins.java @@ -67,8 +67,8 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; +import com.oracle.graal.python.runtime.PythonContext; import org.bouncycastle.util.encoders.DecoderException; -import org.graalvm.nativeimage.ImageInfo; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; @@ -163,10 +163,10 @@ protected List> getNodeFa return SSLModuleBuiltinsFactory.getFactories(); } - private static synchronized void loadDefaults() { - if (ImageInfo.inImageBuildtimeCode()) { + private static synchronized void loadDefaults(PythonContext pythonContext) { + if (pythonContext.getEnv().isPreInitialization()) { // The values are dependent on system properties, don't bake them into the image - throw new AssertionError("SSL module initialized at build time"); + throw new AssertionError("SSL module initialized during pre-initialization"); } try { SSLContext context = SSLContext.getInstance("TLS"); @@ -218,7 +218,7 @@ private static boolean tryProtocolAvailability(SSLContext context, SSLProtocol p @Override public void postInitialize(Python3Core core) { super.postInitialize(core); - loadDefaults(); + loadDefaults(core.getContext()); PythonModule module = core.lookupBuiltinModule(T__SSL); module.setAttribute(tsLiteral("OPENSSL_VERSION_NUMBER"), 0); PTuple versionInfo = PFactory.createTuple(core.getLanguage(), new int[]{0, 0, 0, 0, 0}); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java index 2520389596..47853da8ef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java @@ -57,8 +57,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; @@ -164,7 +162,8 @@ public void postInitialize(Python3Core core) { } } - if (PosixSupportLibrary.getUncached().getBackend(core.getContext().getPosixSupport()).equalsUncached(T_JAVA, TS_ENCODING)) { + var context = core.getContext(); + if (PosixSupportLibrary.getUncached().getBackend(context.getPosixSupport()).equalsUncached(T_JAVA, TS_ENCODING)) { for (EmulatedSignal signal : EmulatedSignal.values()) { if (signalModule.getAttribute(signal.name) == PNone.NO_VALUE) { moduleData.signals.put(signal.name(), signal.number); @@ -173,7 +172,7 @@ public void postInitialize(Python3Core core) { } } - core.getContext().registerAsyncAction(() -> { + context.registerAsyncAction(() -> { SignalTriggerAction poll = moduleData.signalQueue.poll(); if (PythonOptions.AUTOMATIC_ASYNC_ACTIONS) { try { @@ -188,7 +187,7 @@ public void postInitialize(Python3Core core) { return poll; }); - if (!ImageInfo.inImageBuildtimeCode() && core.getContext().getOption(PythonOptions.InstallSignalHandlers)) { + if (!context.getEnv().isPreInitialization() && context.getOption(PythonOptions.InstallSignalHandlers)) { Object defaultSigintHandler = signalModule.getAttribute(T_DEFAULT_INT_HANDLER); assert defaultSigintHandler != PNone.NO_VALUE; SignalNode.signal(null, new Signal("INT").getNumber(), defaultSigintHandler, moduleData); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java index e05902b286..2689c74313 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java @@ -140,8 +140,6 @@ import java.util.List; import java.util.Set; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; @@ -647,7 +645,7 @@ public void postInitialize0(Python3Core core) { TruffleString stdlibHome = context.getStdlibHome(); TruffleString capiHome = context.getCAPIHome(); - if (!ImageInfo.inImageBuildtimeCode()) { + if (!context.getEnv().isPreInitialization()) { TruffleString executable = context.getOption(PythonOptions.Executable); TruffleString baseExecutable = context.getOption(PythonOptions.BaseExecutable); sys.setAttribute(tsLiteral("executable"), executable); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java index 18dcd246ea..a458b06c1c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java @@ -49,8 +49,6 @@ import java.util.List; import java.util.TimeZone; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.builtins.Builtin; @@ -96,6 +94,7 @@ import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.TruffleOptions; import com.oracle.truffle.api.TruffleSafepoint; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -476,7 +475,7 @@ abstract static class ThreadTimeNode extends PythonBuiltinNode { @Specialization @TruffleBoundary Object getProcesTime() { - return !ImageInfo.inImageCode() ? (ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime()) / 1000_000_000.0 : 0; + return !TruffleOptions.AOT ? (ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime()) / 1000_000_000.0 : 0; } } @@ -486,7 +485,7 @@ abstract static class ThreadTimeNsNode extends PythonBuiltinNode { @Specialization @TruffleBoundary Object getProcesNsTime() { - return !ImageInfo.inImageCode() ? ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() : 0; + return !TruffleOptions.AOT ? ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime() : 0; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java index 93fc71e8ca..11f7f4ae05 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java @@ -70,7 +70,6 @@ import java.util.logging.Level; import org.graalvm.collections.Pair; -import org.graalvm.nativeimage.ImageInfo; import org.graalvm.shadowed.com.ibm.icu.impl.Punycode; import org.graalvm.shadowed.com.ibm.icu.text.StringPrepParseException; @@ -363,8 +362,7 @@ public CApiContext(PythonContext context, Object llvmLibrary, NativeLibraryLocat if (!CApiContext.nativeSymbolCacheSingleContextUsed && context.getLanguage().isSingleContext()) { assert CApiContext.nativeSymbolCacheSingleContext == null; - // we cannot be in built-time code because this is using pre-initialized contexts - assert !ImageInfo.inImageBuildtimeCode(); + assert !context.getEnv().isPreInitialization(); // this is the first context accessing the static symbol cache CApiContext.nativeSymbolCacheSingleContext = this.nativeSymbolCache; @@ -851,7 +849,7 @@ public long getCurrentRSS() { @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH") // context.get() is never null here void runBackgroundGCTask(PythonContext context) { CompilerAsserts.neverPartOfCompilation(); - if (ImageInfo.inImageBuildtimeCode() // + if (context.getEnv().isPreInitialization() // || context.getOption(PythonOptions.NoAsyncActions) // || !PythonOptions.AUTOMATIC_ASYNC_ACTIONS // || !context.getOption(PythonOptions.BackgroundGCTask)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java index 7289ec2e46..39d0935434 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java @@ -62,8 +62,6 @@ import java.util.List; import java.util.Objects; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -435,8 +433,8 @@ protected void initNativeFastPaths() { } @SuppressWarnings("restricted") - public static void loadJNIBackend() { - if (!(ImageInfo.inImageBuildtimeCode() || jniBackendLoaded)) { + public void loadJNIBackend() { + if (!getContext().getEnv().isPreInitialization() && !jniBackendLoaded) { String pythonJNIPath; pythonJNIPath = getJNILibrary(); try { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java index 473aff97db..55c54bcb44 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java @@ -60,8 +60,6 @@ import java.util.Arrays; import java.util.Objects; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.Python3Core; @@ -214,11 +212,12 @@ public int hashCode() { /** * Very similar to {@code PyStructSequence_Desc} but already specific to a built-in type. Used - * for built-in structseq objects. + * for built-in structseq objects. All BuiltinTypeDescriptor instances should be kept in + * {@code static final} fields to ensure there is a finite number of them, see + * {@link PythonLanguage#getOrCreateStructSequenceCallTargets(Descriptor, Function)}. */ public static final class BuiltinTypeDescriptor extends Descriptor { public final PythonBuiltinClassType type; - private final boolean initializedInBuildTime = ImageInfo.inImageBuildtimeCode(); public BuiltinTypeDescriptor(PythonBuiltinClassType type, String docString, int inSequence, String[] fieldNames, String[] fieldDocStrings, boolean allowInstances) { super(docString == null ? null : toTruffleStringUncached(docString), inSequence, toTruffleStringArrayUncached(fieldNames), toTruffleStringArrayUncached(fieldDocStrings), allowInstances); @@ -249,10 +248,6 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(super.hashCode(), type); } - - public boolean wasInitializedAtBuildTime() { - return initializedInBuildTime; - } } public record DescriptorCallTargets(RootCallTarget reprBuiltin, RootCallTarget reduceBuiltin, RootCallTarget newBuiltin) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java index d714ad6cf6..f26a0c25cd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -46,6 +46,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; +import java.util.Objects; import java.util.Queue; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedDeque; @@ -54,8 +55,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.function.Signature; @@ -316,10 +315,11 @@ public boolean setsUpCalleeContext() { * regular intervals to run on a separate thread, or if it will be polled. The caller needs to * ensure that the AsyncAction passed into this method does not block in the latter case. */ - @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH") // context.get() is never null here + @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH") // incorrect warning void registerAction(Supplier actionSupplier) { CompilerAsserts.neverPartOfCompilation(); - if (ImageInfo.inImageBuildtimeCode() || context.get().getOption(PythonOptions.NoAsyncActions)) { + var context = Objects.requireNonNull(this.context.get()); + if (context.getEnv().isPreInitialization() || context.getOption(PythonOptions.NoAsyncActions)) { return; } if (PythonOptions.AUTOMATIC_ASYNC_ACTIONS) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java index 5a8afb7fe1..8c3af9a7bd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/EmulatedPosixSupport.java @@ -210,6 +210,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; +import com.oracle.truffle.api.TruffleOptions; import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.ProcessProperties; import org.graalvm.polyglot.io.ProcessHandler.Redirect; @@ -361,7 +362,7 @@ static UnsupportedPosixFeatureException createUnsupportedFeature(String message) @Override public void setEnv(Env env) { super.setEnv(env); - if (!ImageInfo.inImageBuildtimeCode()) { + if (!env.isPreInitialization()) { environ.putAll(env.getEnvironment()); } } @@ -2109,7 +2110,7 @@ public RusageResult getrusage(int who) throws PosixException { double ru_stime = 0; // time in system mode (float) long ru_maxrss; - if (!ImageInfo.inImageCode()) { + if (!TruffleOptions.AOT) { // once GR-44559 is fixed we can enable this branch on NI java.lang.management.ThreadMXBean threadMXBean = java.lang.management.ManagementFactory.getThreadMXBean(); if (PosixConstants.RUSAGE_THREAD.defined && diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java index 4abb27fdc0..a247e976ed 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java @@ -89,8 +89,6 @@ import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.logging.Level; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonOS; @@ -476,7 +474,7 @@ long getConstant(NFIPosixConstants constant) { @Override public void setEnv(Env env) { - if (ImageInfo.inImageBuildtimeCode()) { + if (env.isPreInitialization()) { return; } // Java NIO (and TruffleFile) do not expect/support changing native working directory since diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ImageBuildtimePosixSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PreInitPosixSupport.java similarity index 88% rename from graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ImageBuildtimePosixSupport.java rename to graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PreInitPosixSupport.java index 078a154f4f..38033c0230 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ImageBuildtimePosixSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PreInitPosixSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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,8 +45,6 @@ import java.util.HashSet; import java.util.IdentityHashMap; -import org.graalvm.nativeimage.ImageInfo; - import com.oracle.graal.python.runtime.PosixSupportLibrary.AcceptResult; import com.oracle.graal.python.runtime.PosixSupportLibrary.AddrInfoCursor; import com.oracle.graal.python.runtime.PosixSupportLibrary.Buffer; @@ -72,14 +70,16 @@ import com.oracle.truffle.api.strings.TruffleString; @ExportLibrary(PosixSupportLibrary.class) -public class ImageBuildtimePosixSupport extends PosixSupport { +public class PreInitPosixSupport extends PosixSupport { protected final PosixSupport nativePosixSupport; private PosixSupport emulatedPosixSupport; private HashSet emulatedFds; private IdentityHashMap emulatedDirStreams; + private boolean inPreInitialization; - public ImageBuildtimePosixSupport(PosixSupport nativePosixSupport, PosixSupport emulatedPosixSupport) { + public PreInitPosixSupport(Env env, PosixSupport nativePosixSupport, PosixSupport emulatedPosixSupport) { + this.inPreInitialization = env.isPreInitialization(); this.nativePosixSupport = nativePosixSupport; this.emulatedPosixSupport = emulatedPosixSupport; if (emulatedPosixSupport != null) { @@ -90,12 +90,13 @@ public ImageBuildtimePosixSupport(PosixSupport nativePosixSupport, PosixSupport @Override public void setEnv(Env env) { - assert !ImageInfo.inImageBuildtimeCode(); + assert !env.isPreInitialization(); + this.inPreInitialization = env.isPreInitialization(); nativePosixSupport.setEnv(env); } public void checkLeakingResources() { - assert ImageInfo.inImageBuildtimeCode(); + assert inPreInitialization; if (!emulatedFds.isEmpty()) { throw shouldNotReachHere("Emulated fds leaked into the image"); } @@ -107,9 +108,9 @@ public void checkLeakingResources() { emulatedDirStreams = null; } - private static void checkNotInImageBuildtime() { - if (ImageInfo.inImageBuildtimeCode()) { - throw shouldNotReachHere("Posix call not expected during image buildtime"); + private void checkNotInPreInitialization() { + if (inPreInitialization) { + throw shouldNotReachHere("Posix call not expected during pre-initialization"); } } @@ -151,34 +152,34 @@ private Object removeDirStream(Object dirStream) { @ExportMessage final TruffleString getBackend(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getBackend(nativePosixSupport); } @ExportMessage final TruffleString strerror(int errorCode, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.strerror(nativePosixSupport, errorCode); } @ExportMessage final long getpid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpid(nativePosixSupport); } @ExportMessage final int umask(int mask, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.umask(nativePosixSupport, mask); } @ExportMessage final int openat(int dirFd, Object pathname, int flags, int mode, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return addFd(PosixSupportLibrary.getUncached().openat(emulatedPosixSupport, dirFd, pathname, flags, mode)); } return nativeLib.openat(nativePosixSupport, dirFd, pathname, flags, mode); @@ -187,7 +188,7 @@ final int openat(int dirFd, Object pathname, int flags, int mode, @ExportMessage final int close(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().close(emulatedPosixSupport, removeFd(fd)); } return nativeLib.close(nativePosixSupport, fd); @@ -196,7 +197,7 @@ final int close(int fd, @ExportMessage final Buffer read(int fd, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().read(emulatedPosixSupport, fd, length); } return nativeLib.read(nativePosixSupport, fd, length); @@ -205,35 +206,35 @@ final Buffer read(int fd, long length, @ExportMessage final long write(int fd, Buffer data, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.write(nativePosixSupport, fd, data); } @ExportMessage final int dup(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.dup(nativePosixSupport, fd); } @ExportMessage final int dup2(int fd, int fd2, boolean inheritable, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.dup2(nativePosixSupport, fd, fd2, inheritable); } @ExportMessage final boolean getInheritable(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getInheritable(nativePosixSupport, fd); } @ExportMessage final void setInheritable(int fd, boolean inheritable, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { PosixSupportLibrary.getUncached().setInheritable(emulatedPosixSupport, fd, inheritable); return; } @@ -242,21 +243,21 @@ final void setInheritable(int fd, boolean inheritable, @ExportMessage final int[] pipe(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.pipe(nativePosixSupport); } @ExportMessage final SelectResult select(int[] readfds, int[] writefds, int[] errorfds, Timeval timeout, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.select(nativePosixSupport, readfds, writefds, errorfds, timeout); } @ExportMessage final long lseek(int fd, long offset, int how, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().lseek(emulatedPosixSupport, fd, offset, how); } return nativeLib.lseek(nativePosixSupport, fd, offset, how); @@ -265,63 +266,63 @@ final long lseek(int fd, long offset, int how, @ExportMessage final void ftruncate(int fd, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.ftruncate(nativePosixSupport, fd, length); } @ExportMessage final void truncate(Object path, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.truncate(nativePosixSupport, path, length); } @ExportMessage final void fsync(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fsync(nativePosixSupport, fd); } @ExportMessage final void flock(int fd, int operation, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.flock(nativePosixSupport, fd, operation); } @ExportMessage final void fcntlLock(int fd, boolean blocking, int lockType, int whence, long start, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fcntlLock(nativePosixSupport, fd, blocking, lockType, whence, start, length); } @ExportMessage final boolean getBlocking(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getBlocking(nativePosixSupport, fd); } @ExportMessage final void setBlocking(int fd, boolean blocking, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.setBlocking(nativePosixSupport, fd, blocking); } @ExportMessage final int[] getTerminalSize(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getTerminalSize(nativePosixSupport, fd); } @ExportMessage final long[] fstatat(int dirFd, Object pathname, boolean followSymlinks, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().fstatat(emulatedPosixSupport, dirFd, pathname, followSymlinks); } return nativeLib.fstatat(nativePosixSupport, dirFd, pathname, followSymlinks); @@ -330,7 +331,7 @@ final long[] fstatat(int dirFd, Object pathname, boolean followSymlinks, @ExportMessage final long[] fstat(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().fstat(emulatedPosixSupport, fd); } return nativeLib.fstat(nativePosixSupport, fd); @@ -339,7 +340,7 @@ final long[] fstat(int fd, @ExportMessage final long[] statvfs(Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().statvfs(emulatedPosixSupport, path); } return nativeLib.statvfs(nativePosixSupport, path); @@ -348,7 +349,7 @@ final long[] statvfs(Object path, @ExportMessage final long[] fstatvfs(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().fstatvfs(emulatedPosixSupport, fd); } return nativeLib.fstatvfs(nativePosixSupport, fd); @@ -356,69 +357,69 @@ final long[] fstatvfs(int fd, @ExportMessage final Object[] uname(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.uname(nativePosixSupport); } @ExportMessage final void unlinkat(int dirFd, Object pathname, boolean rmdir, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.unlinkat(nativePosixSupport, dirFd, pathname, rmdir); } @ExportMessage final void linkat(int oldFdDir, Object oldPath, int newFdDir, Object newPath, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.linkat(nativePosixSupport, oldFdDir, oldPath, newFdDir, newPath, flags); } @ExportMessage final void symlinkat(Object target, int linkpathDirFd, Object linkpath, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.symlinkat(nativePosixSupport, target, linkpathDirFd, linkpath); } @ExportMessage final void mkdirat(int dirFd, Object pathname, int mode, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.mkdirat(nativePosixSupport, dirFd, pathname, mode); } @ExportMessage final Object getcwd(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getcwd(nativePosixSupport); } @ExportMessage final void chdir(Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.chdir(nativePosixSupport, path); } @ExportMessage final void fchdir(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fchdir(nativePosixSupport, fd); } @ExportMessage final boolean isatty(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.isatty(nativePosixSupport, fd); } @ExportMessage final Object opendir(Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return addDirStream(PosixSupportLibrary.getUncached().opendir(emulatedPosixSupport, path)); } return nativeLib.opendir(nativePosixSupport, path); @@ -427,14 +428,14 @@ final Object opendir(Object path, @ExportMessage final Object fdopendir(int fd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.fdopendir(nativePosixSupport, fd); } @ExportMessage final void closedir(Object dirStream, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { PosixSupportLibrary.getUncached().closedir(emulatedPosixSupport, removeDirStream(dirStream)); return; } @@ -444,7 +445,7 @@ final void closedir(Object dirStream, @ExportMessage final Object readdir(Object dirStream, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().readdir(emulatedPosixSupport, dirStream); } return nativeLib.readdir(nativePosixSupport, dirStream); @@ -453,7 +454,7 @@ final Object readdir(Object dirStream, @ExportMessage final void rewinddir(Object dirStream, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { PosixSupportLibrary.getUncached().rewinddir(emulatedPosixSupport, dirStream); } nativeLib.rewinddir(nativePosixSupport, dirStream); @@ -462,7 +463,7 @@ final void rewinddir(Object dirStream, @ExportMessage final Object dirEntryGetName(Object dirEntry, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().dirEntryGetName(emulatedPosixSupport, dirEntry); } return nativeLib.dirEntryGetName(nativePosixSupport, dirEntry); @@ -471,292 +472,292 @@ final Object dirEntryGetName(Object dirEntry, @ExportMessage final Object dirEntryGetPath(Object dirEntry, Object scandirPath, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.dirEntryGetPath(nativePosixSupport, dirEntry, scandirPath); } @ExportMessage final long dirEntryGetInode(Object dirEntry, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.dirEntryGetInode(nativePosixSupport, dirEntry); } @ExportMessage final int dirEntryGetType(Object dirEntry, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.dirEntryGetType(nativePosixSupport, dirEntry); } @ExportMessage final void utimensat(int dirFd, Object pathname, long[] timespec, boolean followSymlinks, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.utimensat(nativePosixSupport, dirFd, pathname, timespec, followSymlinks); } @ExportMessage final void futimens(int fd, long[] timespec, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.futimens(nativePosixSupport, fd, timespec); } @ExportMessage final void futimes(int fd, Timeval[] timeval, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.futimes(nativePosixSupport, fd, timeval); } @ExportMessage final void lutimes(Object filename, Timeval[] timeval, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.lutimes(nativePosixSupport, filename, timeval); } @ExportMessage final void utimes(Object filename, Timeval[] timeval, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.utimes(nativePosixSupport, filename, timeval); } @ExportMessage final void renameat(int oldDirFd, Object oldPath, int newDirFd, Object newPath, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.renameat(nativePosixSupport, oldDirFd, oldPath, newDirFd, newPath); } @ExportMessage final boolean faccessat(int dirFd, Object path, int mode, boolean effectiveIds, boolean followSymlinks, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.faccessat(nativePosixSupport, dirFd, path, mode, effectiveIds, followSymlinks); } @ExportMessage final void fchmodat(int dirFd, Object path, int mode, boolean followSymlinks, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fchmodat(nativePosixSupport, dirFd, path, mode, followSymlinks); } @ExportMessage final void fchmod(int fd, int mode, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fchmod(nativePosixSupport, fd, mode); } @ExportMessage final void fchownat(int dirFd, Object path, long owner, long group, boolean followSymlinks, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fchownat(nativePosixSupport, dirFd, path, owner, group, followSymlinks); } @ExportMessage final void fchown(int fd, long owner, long group, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.fchown(nativePosixSupport, fd, owner, group); } @ExportMessage final Object readlinkat(int dirFd, Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.readlinkat(nativePosixSupport, dirFd, path); } @ExportMessage final void kill(long pid, int signal, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.kill(nativePosixSupport, pid, signal); } @ExportMessage final void killpg(long pgid, int signal, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.killpg(nativePosixSupport, pgid, signal); } @ExportMessage final long[] waitpid(long pid, int options, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.waitpid(nativePosixSupport, pid, options); } @ExportMessage final void abort(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.abort(nativePosixSupport); } @ExportMessage final boolean wcoredump(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wcoredump(nativePosixSupport, status); } @ExportMessage final boolean wifcontinued(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wifcontinued(nativePosixSupport, status); } @ExportMessage final boolean wifstopped(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wifstopped(nativePosixSupport, status); } @ExportMessage final boolean wifsignaled(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wifsignaled(nativePosixSupport, status); } @ExportMessage final boolean wifexited(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wifexited(nativePosixSupport, status); } @ExportMessage final int wexitstatus(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wexitstatus(nativePosixSupport, status); } @ExportMessage final int wtermsig(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wtermsig(nativePosixSupport, status); } @ExportMessage final int wstopsig(int status, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.wstopsig(nativePosixSupport, status); } @ExportMessage final long getuid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getuid(nativePosixSupport); } @ExportMessage final long geteuid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.geteuid(nativePosixSupport); } @ExportMessage final long getgid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getgid(nativePosixSupport); } @ExportMessage final long getegid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getegid(nativePosixSupport); } @ExportMessage final long getppid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getppid(nativePosixSupport); } @ExportMessage final long getpgid(long pid, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpgid(nativePosixSupport, pid); } @ExportMessage final void setpgid(long pid, long pgid, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.setpgid(nativePosixSupport, pid, pgid); } @ExportMessage final long getpgrp(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpgrp(nativePosixSupport); } @ExportMessage final long getsid(long pid, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getsid(nativePosixSupport, pid); } @ExportMessage final long setsid( @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.setsid(nativePosixSupport); } @ExportMessage final long[] getgroups( @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getgroups(nativePosixSupport); } @ExportMessage final RusageResult getrusage(int who, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getrusage(nativePosixSupport, who); } @ExportMessage final OpenPtyResult openpty(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.openpty(nativePosixSupport); } @ExportMessage final TruffleString ctermid(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.ctermid(nativePosixSupport); } @ExportMessage final void setenv(Object name, Object value, boolean overwrite, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.setenv(nativePosixSupport, name, value, overwrite); } @ExportMessage final void unsetenv(Object name, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.unsetenv(nativePosixSupport, name); } @@ -764,7 +765,7 @@ final void unsetenv(Object name, final int forkExec(Object[] executables, Object[] args, Object cwd, Object[] env, int stdinReadFd, int stdinWriteFd, int stdoutReadFd, int stdoutWriteFd, int stderrReadFd, int stderrWriteFd, int errPipeReadFd, int errPipeWriteFd, boolean closeFds, boolean restoreSignals, boolean callSetsid, int[] fdsToKeep, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.forkExec(nativePosixSupport, executables, args, cwd, env, stdinReadFd, stdinWriteFd, stdoutReadFd, stdoutWriteFd, stderrReadFd, stderrWriteFd, errPipeReadFd, errPipeWriteFd, closeFds, restoreSignals, callSetsid, fdsToKeep); } @@ -772,63 +773,63 @@ final int forkExec(Object[] executables, Object[] args, Object cwd, Object[] env @ExportMessage final void execv(Object pathname, Object[] args, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.execv(nativePosixSupport, pathname, args); } @ExportMessage final int system(Object command, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.system(nativePosixSupport, command); } @ExportMessage final Object mmap(long length, int prot, int flags, int fd, long offset, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.mmap(nativePosixSupport, length, prot, flags, fd, offset); } @ExportMessage final byte mmapReadByte(Object mmap, long index, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.mmapReadByte(nativePosixSupport, mmap, index); } @ExportMessage final void mmapWriteByte(Object mmap, long index, byte value, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.mmapWriteByte(nativePosixSupport, mmap, index, value); } @ExportMessage final int mmapReadBytes(Object mmap, long index, byte[] bytes, int length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.mmapReadBytes(nativePosixSupport, mmap, index, bytes, length); } @ExportMessage final void mmapWriteBytes(Object mmap, long index, byte[] bytes, int length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.mmapWriteBytes(nativePosixSupport, mmap, index, bytes, length); } @ExportMessage final void mmapFlush(Object mmap, long offset, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.mmapFlush(nativePosixSupport, mmap, offset, length); } @ExportMessage final void mmapUnmap(Object mmap, long length, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.mmapUnmap(nativePosixSupport, mmap, length); } @@ -836,21 +837,21 @@ final void mmapUnmap(Object mmap, long length, @SuppressWarnings("static-method") final long mmapGetPointer(Object mmap, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.mmapGetPointer(nativePosixSupport, mmap); } @ExportMessage public PwdResult getpwuid(long uid, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpwuid(nativePosixSupport, uid); } @ExportMessage public PwdResult getpwnam(Object name, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpwnam(nativePosixSupport, name); } @@ -861,265 +862,265 @@ public boolean hasGetpwentries(@CachedLibrary("this.nativePosixSupport") PosixSu @ExportMessage public PwdResult[] getpwentries(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpwentries(nativePosixSupport); } @ExportMessage final int ioctlBytes(int fd, long request, byte[] arg, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.ioctlBytes(nativePosixSupport, fd, request, arg); } @ExportMessage final int ioctlInt(int fd, long request, int arg, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.ioctlInt(nativePosixSupport, fd, request, arg); } @ExportMessage final int socket(int domain, int type, int protocol, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.socket(nativePosixSupport, domain, type, protocol); } @ExportMessage final AcceptResult accept(int sockfd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.accept(nativePosixSupport, sockfd); } @ExportMessage final void bind(int sockfd, UniversalSockAddr addr, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.bind(nativePosixSupport, sockfd, addr); } @ExportMessage final void connect(int sockfd, UniversalSockAddr addr, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.connect(nativePosixSupport, sockfd, addr); } @ExportMessage final void listen(int sockfd, int backlog, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.listen(nativePosixSupport, sockfd, backlog); } @ExportMessage final UniversalSockAddr getpeername(int sockfd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getpeername(nativePosixSupport, sockfd); } @ExportMessage final UniversalSockAddr getsockname(int sockfd, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getsockname(nativePosixSupport, sockfd); } @ExportMessage final int send(int sockfd, byte[] buf, int offset, int len, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.send(nativePosixSupport, sockfd, buf, offset, len, flags); } @ExportMessage final int sendto(int sockfd, byte[] buf, int offset, int len, int flags, UniversalSockAddr destAddr, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.sendto(nativePosixSupport, sockfd, buf, offset, len, flags, destAddr); } @ExportMessage final int recv(int sockfd, byte[] buf, int offset, int len, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.recv(nativePosixSupport, sockfd, buf, offset, len, flags); } @ExportMessage final RecvfromResult recvfrom(int sockfd, byte[] buf, int offset, int len, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.recvfrom(nativePosixSupport, sockfd, buf, offset, len, flags); } @ExportMessage final void shutdown(int sockfd, int how, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.shutdown(nativePosixSupport, sockfd, how); } @ExportMessage final int getsockopt(int sockfd, int level, int optname, byte[] optval, int optlen, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getsockopt(nativePosixSupport, sockfd, level, optname, optval, optlen); } @ExportMessage final void setsockopt(int sockfd, int level, int optname, byte[] optval, int optlen, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); nativeLib.setsockopt(nativePosixSupport, sockfd, level, optname, optval, optlen); } @ExportMessage final int inet_addr(Object src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.inet_addr(nativePosixSupport, src); } @ExportMessage final int inet_aton(Object src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws InvalidAddressException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.inet_aton(nativePosixSupport, src); } @ExportMessage final Object inet_ntoa(int address, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.inet_ntoa(nativePosixSupport, address); } @ExportMessage final byte[] inet_pton(int family, Object src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException, InvalidAddressException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.inet_pton(nativePosixSupport, family, src); } @ExportMessage final Object inet_ntop(int family, byte[] src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.inet_ntop(nativePosixSupport, family, src); } @ExportMessage final Object gethostname(@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.gethostname(nativePosixSupport); } @ExportMessage final Object[] getnameinfo(UniversalSockAddr addr, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws GetAddrInfoException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getnameinfo(nativePosixSupport, addr, flags); } @ExportMessage final AddrInfoCursor getaddrinfo(Object node, Object service, int family, int sockType, int protocol, int flags, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws GetAddrInfoException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.getaddrinfo(nativePosixSupport, node, service, family, sockType, protocol, flags); } @ExportMessage final TruffleString crypt(TruffleString word, TruffleString salt, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.crypt(nativePosixSupport, word, salt); } @ExportMessage final long semOpen(Object name, int openFlags, int mode, int value, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return lib.semOpen(nativePosixSupport, name, openFlags, mode, value); } @ExportMessage final void semClose(long handle, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); lib.semClose(nativePosixSupport, handle); } @ExportMessage final void semUnlink(Object name, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); lib.semUnlink(nativePosixSupport, name); } @ExportMessage final int semGetValue(long handle, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return lib.semGetValue(nativePosixSupport, handle); } @ExportMessage final void semPost(long handle, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); lib.semPost(nativePosixSupport, handle); } @ExportMessage final void semWait(long handle, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); lib.semWait(nativePosixSupport, handle); } @ExportMessage final boolean semTryWait(long handle, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return lib.semTryWait(nativePosixSupport, handle); } @ExportMessage final boolean semTimedWait(long handle, long deadlineNs, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary lib) throws PosixException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return lib.semTimedWait(nativePosixSupport, handle, deadlineNs); } @ExportMessage final UniversalSockAddr createUniversalSockAddrInet4(Inet4SockAddr src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.createUniversalSockAddrInet4(nativePosixSupport, src); } @ExportMessage final UniversalSockAddr createUniversalSockAddrInet6(Inet6SockAddr src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.createUniversalSockAddrInet6(nativePosixSupport, src); } @ExportMessage final UniversalSockAddr createUniversalSockAddrUnix(UnixSockAddr src, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws InvalidUnixSocketPathException { - checkNotInImageBuildtime(); + checkNotInPreInitialization(); return nativeLib.createUniversalSockAddrUnix(nativePosixSupport, src); } @ExportMessage final Object createPathFromString(TruffleString path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().createPathFromString(emulatedPosixSupport, path); } return nativeLib.createPathFromString(nativePosixSupport, path); @@ -1128,7 +1129,7 @@ final Object createPathFromString(TruffleString path, @ExportMessage final Object createPathFromBytes(byte[] path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().createPathFromBytes(emulatedPosixSupport, path); } return nativeLib.createPathFromBytes(nativePosixSupport, path); @@ -1137,7 +1138,7 @@ final Object createPathFromBytes(byte[] path, @ExportMessage final TruffleString getPathAsString(Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().getPathAsString(emulatedPosixSupport, path); } return nativeLib.getPathAsString(nativePosixSupport, path); @@ -1146,7 +1147,7 @@ final TruffleString getPathAsString(Object path, @ExportMessage final Buffer getPathAsBytes(Object path, @CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) { - if (ImageInfo.inImageBuildtimeCode()) { + if (inPreInitialization) { return PosixSupportLibrary.getUncached().getPathAsBytes(emulatedPosixSupport, path); } return nativeLib.getPathAsBytes(nativePosixSupport, path); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java index 4047597076..1dd0d641aa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java @@ -100,7 +100,7 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; -import org.graalvm.nativeimage.ImageInfo; +import com.oracle.truffle.api.TruffleOptions; import org.graalvm.options.OptionKey; import com.oracle.graal.python.PythonLanguage; @@ -845,7 +845,7 @@ public Thread getOwner() { private final ConcurrentHashMap deserializationId = new ConcurrentHashMap<>(); - private final long perfCounterStart = ImageInfo.inImageBuildtimeCode() ? 0 : System.nanoTime(); + @CompilationFinal private long perfCounterStart = System.nanoTime(); public static final String CHILD_CONTEXT_DATA = "childContextData"; @CompilationFinal private List childContextFDs; @@ -1252,7 +1252,7 @@ public void putChildContextData(long id, ChildContextData data) { } public PythonContext(PythonLanguage language, TruffleLanguage.Env env) { - super(language, env.isNativeAccessAllowed(), env.isSocketIOAllowed()); + super(language, env); this.env = env; this.allocationReporter = env.lookup(AllocationReporter.class); this.childContextData = (ChildContextData) env.getConfig().get(CHILD_CONTEXT_DATA); @@ -1512,7 +1512,7 @@ public long getPerfCounterStart() { * Get a SecureRandom instance using a non-blocking source. */ public SecureRandom getSecureRandom() { - assert !ImageInfo.inImageBuildtimeCode(); + assert !env.isPreInitialization(); if (secureRandom == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); try { @@ -1533,7 +1533,7 @@ public SecureRandom getSecureRandom() { } public byte[] getHashSecret() { - assert !ImageInfo.inImageBuildtimeCode(); + assert !env.isPreInitialization(); return hashSecret; } @@ -1564,20 +1564,24 @@ public void initialize() { initializePosixSupport(); initialize(this); setupRuntimeInformation(false); - postInitialize(); - if (!ImageInfo.inImageBuildtimeCode()) { + postInitialize(env); + if (!env.isPreInitialization()) { importSiteIfForced(); - } else if (posixSupport instanceof ImageBuildtimePosixSupport) { - ((ImageBuildtimePosixSupport) posixSupport).checkLeakingResources(); + } else if (posixSupport instanceof PreInitPosixSupport) { + ((PreInitPosixSupport) posixSupport).checkLeakingResources(); } } finally { - if (ImageInfo.inImageBuildtimeCode()) { + if (env.isPreInitialization()) { mainThread = null; } releaseGil(); } } + public void resetPerfCounter() { + perfCounterStart = System.nanoTime(); + } + public void patch(Env newEnv) { try { acquireGil(); @@ -1588,7 +1592,7 @@ public void patch(Env newEnv) { mainThread = new WeakReference<>(Thread.currentThread()); setEnv(newEnv); setupRuntimeInformation(true); - postInitialize(); + postInitialize(newEnv); importSiteIfForced(); } finally { releaseGil(); @@ -1708,7 +1712,7 @@ private void initializeLocale() { } private void setupRuntimeInformation(boolean isPatching) { - if (!ImageInfo.inImageBuildtimeCode()) { + if (!env.isPreInitialization()) { initializeHashSecret(); } initializeLocale(); @@ -1725,11 +1729,11 @@ private void setupRuntimeInformation(boolean isPatching) { SetDictNode.executeUncached(mainModule, PFactory.createDictFixedStorage(getLanguage(), mainModule)); getSysModules().setItem(T___MAIN__, mainModule); - if (ImageInfo.inImageBuildtimeCode()) { + if (env.isPreInitialization()) { // Patch any pre-loaded packages' paths if we're running // pre-initialization patchPackagePaths(getStdlibHome(), T_STD_LIB_PLACEHOLDER); - } else if (isPatching && ImageInfo.inImageRuntimeCode()) { + } else if (isPatching) { // Patch any pre-loaded packages' paths to the new stdlib home if // we're patching a pre-initialized context patchPackagePaths(T_STD_LIB_PLACEHOLDER, getStdlibHome()); @@ -1740,7 +1744,7 @@ private void setupRuntimeInformation(boolean isPatching) { } private void initializeHashSecret() { - assert !ImageInfo.inImageBuildtimeCode(); + assert !env.isPreInitialization(); Optional hashSeed = getOption(PythonOptions.HashSeed); if (hashSeed.isPresent()) { int hashSeedValue = hashSeed.get(); @@ -1785,13 +1789,17 @@ private void initializePosixSupport() { } result = new EmulatedPosixSupport(this); } else if (eqNode.execute(T_NATIVE, option, TS_ENCODING) || eqNode.execute(T_LLVM_LANGUAGE, option, TS_ENCODING)) { - if (ImageInfo.inImageBuildtimeCode()) { + if (env.isPreInitialization()) { EmulatedPosixSupport emulatedPosixSupport = new EmulatedPosixSupport(this); NFIPosixSupport nativePosixSupport = new NFIPosixSupport(this, option); - result = new ImageBuildtimePosixSupport(nativePosixSupport, emulatedPosixSupport); - } else if (ImageInfo.inImageRuntimeCode()) { + result = new PreInitPosixSupport(env, nativePosixSupport, emulatedPosixSupport); + } else if (TruffleOptions.AOT) { + // We always use a PreInitPosixSupport on SVM to keep the type of the posixSupport + // field consistent for both pre-initialized and not-pre-initialized contexts so + // that host inlining and PE see only one type, and also to avoid polymorphism when + // calling library methods. NFIPosixSupport nativePosixSupport = new NFIPosixSupport(this, option); - result = new ImageBuildtimePosixSupport(nativePosixSupport, null); + result = new PreInitPosixSupport(env, nativePosixSupport, null); } else { if (!getOption(PythonOptions.RunViaLauncher)) { writeWarning("Native Posix backend is not fully supported when embedding. For example, standard I/O always uses file " + @@ -1812,8 +1820,9 @@ private void initializePosixSupport() { private TruffleString langHome, sysPrefix, basePrefix, coreHome, capiHome, jniHome, stdLibHome; public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { - if (ImageInfo.inImageBuildtimeCode()) { - // at buildtime we do not need these paths to be valid, since all boot files are frozen + if (env.isPreInitialization()) { + // during pre-initialization we do not need these paths to be valid, since all boot + // files are frozen basePrefix = sysPrefix = langHome = coreHome = stdLibHome = capiHome = jniHome = T_DOT; return; } @@ -2512,8 +2521,8 @@ public TruffleFile getPublicTruffleFileRelaxed(TruffleString path, TruffleString TruffleFile f = env.getInternalTruffleFile(path.toJavaStringUncached()); // 'isDirectory' does deliberately not follow symlinks because otherwise this could allow to // escape the language home directory. - // Also, during image build time, we allow full internal access. - if (ImageInfo.inImageBuildtimeCode() || isPyFileInLanguageHome(f) && (f.isDirectory(LinkOption.NOFOLLOW_LINKS) || hasAllowedSuffix(path, allowedSuffixes))) { + // Also, during pre-initialization, we allow full internal access. + if (env.isPreInitialization() || isPyFileInLanguageHome(f) && (f.isDirectory(LinkOption.NOFOLLOW_LINKS) || hasAllowedSuffix(path, allowedSuffixes))) { return f; } else { return env.getPublicTruffleFile(path.toJavaStringUncached()); @@ -2540,7 +2549,7 @@ private static boolean hasAllowedSuffix(TruffleString path, TruffleString[] allo */ @TruffleBoundary public boolean isPyFileInLanguageHome(TruffleFile path) { - assert !ImageInfo.inImageBuildtimeCode() : "language home won't be available during image build time"; + assert !env.isPreInitialization() : "language home won't be available during pre-initialization"; // The language home may be 'null' if an embedder uses Python. In this case, IO must just be // allowed. if (langHome != null) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java index d47f9bf51f..2745fdc551 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java @@ -64,7 +64,6 @@ import javax.management.ObjectName; import javax.management.ReflectionException; -import org.graalvm.nativeimage.ImageInfo; import org.graalvm.nativeimage.VMRuntime; import org.graalvm.polyglot.io.ByteSequence; @@ -513,7 +512,7 @@ public static boolean isDivisible(int number, int twoExponent) { private static final ObjectName OBJECT_NAME; static { - if (ImageInfo.inImageCode()) { + if (TruffleOptions.AOT) { OBJECT_NAME = null; SERVER = null; } else { @@ -546,7 +545,7 @@ public static void forceFullGC() { @TruffleBoundary public static void dumpHeap(String path) { - if (ImageInfo.inImageCode()) { + if (TruffleOptions.AOT) { try { VMRuntime.dumpHeap(path, true); } catch (UnsupportedOperationException | IOException e) { diff --git a/graalpython/lib-graalpython/modules/standalone/resources/Py2BinLauncher.java b/graalpython/lib-graalpython/modules/standalone/resources/Py2BinLauncher.java index 7c54344081..793c62f453 100644 --- a/graalpython/lib-graalpython/modules/standalone/resources/Py2BinLauncher.java +++ b/graalpython/lib-graalpython/modules/standalone/resources/Py2BinLauncher.java @@ -67,7 +67,7 @@ public static void main(String[] args) throws IOException { .allowAllAccess(true) .arguments("python", Stream.concat(Stream.of(getProgramName()), Stream.of(args)).toArray(String[]::new)) .option("python.RunViaLauncher", "true"); - if(ImageInfo.inImageRuntimeCode()) { + if (ImageInfo.inImageRuntimeCode()) { builder.option("engine.WarnInterpreterOnly", "false"); } try (var context = builder.build()) { diff --git a/graalpython/lib-python/3/importlib/_bootstrap_external.py b/graalpython/lib-python/3/importlib/_bootstrap_external.py index 7a7c5cdd03..41044bd189 100644 --- a/graalpython/lib-python/3/importlib/_bootstrap_external.py +++ b/graalpython/lib-python/3/importlib/_bootstrap_external.py @@ -454,7 +454,7 @@ def cache_from_source(path, debug_override=None, *, optimization=None): If sys.implementation.cache_tag is None then NotImplementedError is raised. """ - if __graalpython__.in_image_buildtime: + if __graalpython__.in_preinitialization: return if debug_override is not None: _warnings.warn('the debug_override parameter is deprecated; use ' diff --git a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java index fa26d06389..eda2b568a4 100644 --- a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java +++ b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java @@ -411,7 +411,7 @@ private static Context.Builder createContextBuilder() { /** * Determines a native executable path if running in {@link ImageInfo#inImageRuntimeCode()}. *

    - * Example creating a GraalPy context precofigured with an external resource directory + * Example creating a GraalPy context preconfigured with an external resource directory * located next to a native image executable. * *

    
    From bbf6ab710b3b74e9db28caea1b396241829a59f0 Mon Sep 17 00:00:00 2001
    From: Benoit Daloze 
    Date: Fri, 21 Feb 2025 17:24:27 +0100
    Subject: [PATCH 077/512] Remove the unused ServiceLoader for PythonBuiltins
    
    ---
     ...racle.graal.python.builtins.PythonBuiltins |  1 -
     .../test/advanced/CustomBuiltinsTest.java     | 52 ---------------
     .../python/test/advanced/CustomModule.java    | 65 -------------------
     .../graal/python/builtins/CoreFunctions.java  |  6 +-
     .../graal/python/builtins/Python3Core.java    | 26 +-------
     mx.graalpython/suite.py                       |  3 -
     6 files changed, 4 insertions(+), 149 deletions(-)
     delete mode 100644 graalpython/com.oracle.graal.python.test/src/META-INF/services/com.oracle.graal.python.builtins.PythonBuiltins
     delete mode 100644 graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomBuiltinsTest.java
     delete mode 100644 graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomModule.java
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/META-INF/services/com.oracle.graal.python.builtins.PythonBuiltins b/graalpython/com.oracle.graal.python.test/src/META-INF/services/com.oracle.graal.python.builtins.PythonBuiltins
    deleted file mode 100644
    index 32134f782e..0000000000
    --- a/graalpython/com.oracle.graal.python.test/src/META-INF/services/com.oracle.graal.python.builtins.PythonBuiltins
    +++ /dev/null
    @@ -1 +0,0 @@
    -com.oracle.graal.python.test.advanced.CustomModule
    diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomBuiltinsTest.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomBuiltinsTest.java
    deleted file mode 100644
    index c6970a1416..0000000000
    --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomBuiltinsTest.java
    +++ /dev/null
    @@ -1,52 +0,0 @@
    -/*
    - * Copyright (c) 2018, 2023, 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.test.advanced;
    -
    -import org.junit.Test;
    -
    -import com.oracle.graal.python.test.PythonTests;
    -
    -public class CustomBuiltinsTest extends PythonTests {
    -    @Test
    -    public void testCustomBuiltinModule() {
    -        assertPrints("success\n", "import CustomModule; print(CustomModule.success)");
    -    }
    -}
    diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomModule.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomModule.java
    deleted file mode 100644
    index cc0aaa6ad0..0000000000
    --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advanced/CustomModule.java
    +++ /dev/null
    @@ -1,65 +0,0 @@
    -/*
    - * Copyright (c) 2018, 2023, 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.test.advanced;
    -
    -import java.util.ArrayList;
    -import java.util.List;
    -
    -import com.oracle.graal.python.builtins.CoreFunctions;
    -import com.oracle.graal.python.builtins.Python3Core;
    -import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    -import com.oracle.truffle.api.dsl.NodeFactory;
    -
    -@CoreFunctions(defineModule = "CustomModule")
    -public class CustomModule extends PythonBuiltins {
    -
    -    @Override
    -    protected List> getNodeFactories() {
    -        return new ArrayList<>();
    -    }
    -
    -    @Override
    -    public void initialize(Python3Core core) {
    -        super.initialize(core);
    -        this.addBuiltinConstant("success", "success");
    -    }
    -}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/CoreFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/CoreFunctions.java
    index fedb82582b..9e9bf4955b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/CoreFunctions.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/CoreFunctions.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2017, 2021, Oracle and/or its affiliates.
    + * Copyright (c) 2017, 2025, Oracle and/or its affiliates.
      * Copyright (c) 2013, Regents of the University of California
      *
      * All rights reserved.
    @@ -40,11 +40,7 @@
          */
         PythonOS os() default PythonOS.PLATFORM_ANY;
     
    -    String publicName() default "";
    -
         PythonBuiltinClassType[] extendClasses() default {};
     
    -    String pythonFile() default "";
    -
         boolean isEager() default false;
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java
    index 26cb2a8a1e..d659f2cdab 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java
    @@ -56,11 +56,8 @@
     import java.util.List;
     import java.util.Map;
     import java.util.Map.Entry;
    -import java.util.ServiceLoader;
     import java.util.logging.Level;
     
    -import org.graalvm.nativeimage.ImageInfo;
    -
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.builtins.modules.AbcModuleBuiltins;
     import com.oracle.graal.python.builtins.modules.ArrayModuleBuiltins;
    @@ -419,28 +416,15 @@ public abstract class Python3Core {
     
         private static TruffleString[] initializeCoreFiles() {
             // Order matters!
    -        List coreFiles = new ArrayList<>(Arrays.asList(
    +        return new TruffleString[]{
                             toTruffleStringUncached("__graalpython__"),
                             toTruffleStringUncached("_weakref"),
                             toTruffleStringUncached("unicodedata"),
                             toTruffleStringUncached("_sre"),
                             toTruffleStringUncached("_sysconfig"),
                             toTruffleStringUncached("java"),
    -                        toTruffleStringUncached("pip_hook")));
    -        // add service loader defined python file extensions
    -        if (!ImageInfo.inImageRuntimeCode()) {
    -            ServiceLoader providers = ServiceLoader.load(PythonBuiltins.class, Python3Core.class.getClassLoader());
    -            PythonOS currentOs = PythonOS.getPythonOS();
    -            for (PythonBuiltins builtin : providers) {
    -                CoreFunctions annotation = builtin.getClass().getAnnotation(CoreFunctions.class);
    -                if (!annotation.pythonFile().isEmpty() &&
    -                                (annotation.os() == PythonOS.PLATFORM_ANY || annotation.os() == currentOs)) {
    -                    coreFiles.add(toTruffleStringUncached(annotation.pythonFile()));
    -                }
    -            }
    -        }
    -        coreFiles.removeAll(Arrays.asList(new TruffleString[]{null}));
    -        return coreFiles.toArray(new TruffleString[coreFiles.size()]);
    +                        toTruffleStringUncached("pip_hook")
    +        };
         }
     
         private final PythonBuiltins[] builtins;
    @@ -810,10 +794,6 @@ private static PythonBuiltins[] initializeBuiltins(TruffleLanguage.Env env) {
                 builtins.add(new BZ2DecompressorBuiltins());
                 builtins.add(new BZ2ModuleBuiltins());
             }
    -        ServiceLoader providers = ServiceLoader.load(PythonBuiltins.class, Python3Core.class.getClassLoader());
    -        for (PythonBuiltins builtin : providers) {
    -            builtins.add(builtin);
    -        }
             filterBuiltins(builtins);
             return builtins.toArray(new PythonBuiltins[builtins.size()]);
         }
    diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py
    index ebdc42a3e9..00e0a78f2d 100644
    --- a/mx.graalpython/suite.py
    +++ b/mx.graalpython/suite.py
    @@ -1147,9 +1147,6 @@
                     "exports": [
                         "com.oracle.graal.python.* to org.graalvm.py.enterprise",
                     ],
    -                "uses": [
    -                    "com.oracle.graal.python.builtins.PythonBuiltins",
    -                ],
                 },
                 "useModulePath": True,
                 "dependencies": [
    
    From 17c532eb57806748d665331b8cd5b7106a5cd59b Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 24 Feb 2025 08:54:17 +0100
    Subject: [PATCH 078/512] Remove CallArithmeticRootNode
    
    ---
     .../expression/CallArithmeticRootNode.java    | 91 -------------------
     1 file changed, 91 deletions(-)
     delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CallArithmeticRootNode.java
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CallArithmeticRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CallArithmeticRootNode.java
    deleted file mode 100644
    index 3fc2045168..0000000000
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/CallArithmeticRootNode.java
    +++ /dev/null
    @@ -1,91 +0,0 @@
    -/*
    - * Copyright (c) 2020, 2023, 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.expression;
    -
    -import com.oracle.graal.python.nodes.PRootNode;
    -import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext;
    -import com.oracle.truffle.api.CompilerDirectives;
    -import com.oracle.truffle.api.TruffleLanguage;
    -import com.oracle.truffle.api.frame.VirtualFrame;
    -
    -/**
    - * A simple base class for root nodes that call an arithmetic operation.
    - */
    -abstract class CallArithmeticRootNode extends PRootNode {
    -
    -    @Child private CalleeContext calleeContext;
    -
    -    protected CallArithmeticRootNode(TruffleLanguage language) {
    -        super(language);
    -    }
    -
    -    @Override
    -    public boolean isInternal() {
    -        return true;
    -    }
    -
    -    @Override
    -    public boolean isPythonInternal() {
    -        return true;
    -    }
    -
    -    @Override
    -    public Object execute(VirtualFrame frame) {
    -        if (calleeContext == null) {
    -            CompilerDirectives.transferToInterpreterAndInvalidate();
    -            calleeContext = insert(CalleeContext.create());
    -        }
    -
    -        calleeContext.enter(frame);
    -        try {
    -            return doCall(frame);
    -        } finally {
    -            calleeContext.exit(frame, this);
    -        }
    -    }
    -
    -    protected abstract Object doCall(VirtualFrame frame);
    -
    -    @Override
    -    public boolean setsUpCalleeContext() {
    -        return true;
    -    }
    -}
    
    From b9a634cc1531d15b1456254c7abf0e5972e15a4d Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 14 Feb 2025 19:53:53 +0100
    Subject: [PATCH 079/512] do not enforce correct lock file header when parsing
    
    ---
     .../embedding/test/EmbeddingTestUtils.java    | 11 ++-
     .../embedding/vfs/test/VFSUtilsTest.java      | 19 ++----
     .../maven/plugin/InstallPackagesMojo.java     |  2 +-
     .../python/embedding/tools/vfs/VFSUtils.java  | 68 ++++++++-----------
     .../python/tasks/InstallPackagesTask.java     |  2 +-
     5 files changed, 40 insertions(+), 62 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java
    index 8e412c72eb..e426b9fca7 100644
    --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java
    +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java
    @@ -59,20 +59,17 @@ private EmbeddingTestUtils() {
         }
     
         public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException {
    -        createVenv(venvDir, graalPyVersion, log, null, null, null, null, packages);
    +        createVenv(venvDir, graalPyVersion, log, null, null, null, packages);
         }
     
    -    public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile,
    -                    String lockFileHeader, String missingLockFileWarning, String packageRemovedError,
    -                    String... packages) throws IOException {
    +    public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile, String missingLockFileWarning, String packageRemovedError, String... packages)
    +                    throws IOException {
             try {
                 info(log, "<<<<<< create test venv %s <<<<<<", venvDir);
     
                 Launcher launcher = createLauncher(venvDir);
                 if (lockFile != null) {
    -                VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile,
    -                                lockFileHeader, packageRemovedError, missingLockFileWarning,
    -                                launcher, graalPyVersion, log);
    +                VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile, packageRemovedError, missingLockFileWarning, launcher, graalPyVersion, log);
                 } else {
                     VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log);
                 }
    diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java
    index b54afc4c0c..68dca21ea0 100644
    --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java
    +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java
    @@ -314,16 +314,10 @@ public void lockFile() throws IOException {
     
             createWithLockFile(venvDir, lockFile, log);
     
    -        List validLockFileHeader = createLockFileHeader("0.1");
    +        List validLockFileHeader = createLockFileHeader("0.1", "pkg");
     
             List lockFileList;
             int headerLineCount = LOCK_FILE_HEADER.split("\n").length;
    -        // bogus line in header comment
    -        for (int i = 0; i < headerLineCount - 1; i++) {
    -            lockFileList = new ArrayList<>(validLockFileHeader);
    -            lockFileList.set(i, "test");
    -            createWithLockFile(venvDir, lockFile, log, lockFileList);
    -        }
     
             // bogus graalPyVersion line
             int graalpVersionLineIdx = headerLineCount;
    @@ -359,7 +353,7 @@ private static void createWithLockFile(Path venvDir, Path lockFile, TestLog log,
     
         private static void createWithLockFile(Path venvDir, Path lockFile, TestLog log, String... lines) throws IOException {
             Files.write(lockFile, new ArrayList<>(Arrays.asList(lines)), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
    -        checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile), "invalid lock file format");
    +        checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile), "Cannot read the lock file from ");
             assertFalse(Files.exists(venvDir));
             checkVenvCreate(log.getOutput(), false);
             assertFalse(log.getOutput().contains("pip install"));
    @@ -612,7 +606,7 @@ private static void checkException(Class cls, ExceptionCall c, String msg) {
                     assertEquals(cls, e.getClass());
                 }
                 if (msg != null) {
    -                assertEquals(msg, e.getMessage());
    +                assertTrue(e.getMessage().contains(msg));
                 }
             }
         }
    @@ -643,8 +637,8 @@ private static void checkLockFile(Path lockFile, String[] inputPackages, String.
             checkPackages(lockFile, lines, installedPackages);
         }
     
    -    private static void checkPackages(Path file, List lines, String... packages) throws IOException {
    -        lines = lines.stream().filter(line -> !line.trim().startsWith("#") && !line.trim().isEmpty()).toList();
    +    private static void checkPackages(Path file, List linesArg, String... packages) {
    +        List lines = linesArg.stream().filter(line -> !line.trim().startsWith("#") && !line.trim().isEmpty()).toList();
             assertEquals(packages.length, lines.size());
             for (String pkg : packages) {
                 boolean found = false;
    @@ -667,8 +661,7 @@ private static void createVenv(Path venvDir, String graalPyVersion, TestLog log,
         }
     
         private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path lockFile, String... packages) throws IOException {
    -        EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, LOCK_FILE_HEADER, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR,
    -                        packages);
    +        EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR, packages);
         }
     
         private static void checkVenvContentsFile(Path contents, String graalPyVersion, String... packages) throws IOException {
    diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java
    index d7dfe7c5bb..ce9bfe09ec 100644
    --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java
    +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java
    @@ -69,7 +69,7 @@ private void manageVenv() throws MojoExecutionException {
             MavenDelegateLog log = new MavenDelegateLog(getLog());
             Path requirements = getLockFile();
             try {
    -            VFSUtils.createVenv(venvDirectory, packages, requirements, LOCK_FILE_HEADER, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log);
    +            VFSUtils.createVenv(venvDirectory, packages, requirements, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log);
             } catch (IOException e) {
                 throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e);
             }
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    index 8d17a30ef5..e2f9b75544 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    @@ -290,7 +290,7 @@ private LockFile(Path path, List inputPackages, List packages) {
                 this.inputPackages = inputPackages;
             }
     
    -        static LockFile fromFile(Path file, String lockFileHeader, BuildToolLog log) throws IOException {
    +        static LockFile fromFile(Path file, BuildToolLog log) throws IOException {
                 List packages = new ArrayList<>();
                 List inputPackages = null;
                 if (Files.isReadable(file)) {
    @@ -298,26 +298,31 @@ static LockFile fromFile(Path file, String lockFileHeader, BuildToolLog log) thr
                     if (lines.isEmpty()) {
                         throw wrongFormat(file, lines, log);
                     }
    -                // parse version first, we don't care about it for now, but with future versions the
    -                // file format might change, and we will need to know to parse differently
    -                parseVersion(lines, file, log);
    -
    -                // parseVersion removed the version line
    -                // what is expected to be left is:
    +                // format:
                     // 1.) a multiline header comment
    -                // 2.) input packages in 1 line (starting with comment #)
    -                // 3.) locked packages, 1 line each (as input for pip install)
    +                // 2.) graalpy version - 1 line (starting with comment #)
    +                // 2.) input packages - 1 line (starting with comment #)
    +                // 3.) locked packages - 1 line each (as input for pip install)
                     // see also LockFile.write()
                     Iterator it = lines.iterator();
    -                Iterator headerIterator = Arrays.asList(lockFileHeader.split("\n")).iterator();
                     try {
    -                    // 1.) header
    -                    while (headerIterator.hasNext()) {
    -                        if (!("# " + headerIterator.next()).equals(it.next())) {
    -                            throw wrongFormat(file, lines, log);
    +                    // graalpy version, we don't care about it for now, but with future versions the
    +                    // file format might change, and we will need to know to parse differently
    +                    String graalPyVersion = null;
    +                    while (it.hasNext()) {
    +                        String line = it.next();
    +                        if (line.startsWith(GRAALPY_VERSION_PREFIX)) {
    +                            graalPyVersion = line.substring(GRAALPY_VERSION_PREFIX.length()).trim();
    +                            if (graalPyVersion.isEmpty()) {
    +                                throw wrongFormat(file, lines, log);
    +                            }
    +                            break;
                             }
                         }
    -                    // 2.) input packages
    +                    if (graalPyVersion == null) {
    +                        throw wrongFormat(file, lines, log);
    +                    }
    +                    // input packages
                         String line = it.next();
                         if (!line.startsWith(INPUT_PACKAGES_PREFIX)) {
                             throw wrongFormat(file, lines, log);
    @@ -327,35 +332,19 @@ static LockFile fromFile(Path file, String lockFileHeader, BuildToolLog log) thr
                             throw wrongFormat(file, lines, log);
                         }
                         inputPackages = Arrays.asList(pkgs.split(INPUT_PACKAGES_DELIMITER));
    +                    // locked packages
    +                    while (it.hasNext()) {
    +                        packages.add(it.next());
    +                    }
                     } catch (NoSuchElementException e) {
                         throw wrongFormat(file, lines, log);
                     }
    -                // 3.) locked packages
    -                while (it.hasNext()) {
    -                    packages.add(it.next());
    -                }
                 } else {
                     throw new IOException("can't read lock file");
                 }
                 return new LockFile(file, inputPackages, packages);
             }
     
    -        private static String parseVersion(List lines, Path file, BuildToolLog log) throws IOException {
    -            Iterator it = lines.iterator();
    -            while (it.hasNext()) {
    -                String line = it.next();
    -                if (line.startsWith(GRAALPY_VERSION_PREFIX)) {
    -                    String graalPyVersion = line.substring(GRAALPY_VERSION_PREFIX.length()).trim();
    -                    if (graalPyVersion.isEmpty()) {
    -                        throw wrongFormat(file, lines, log);
    -                    }
    -                    it.remove();
    -                    return graalPyVersion;
    -                }
    -            }
    -            throw wrongFormat(file, lines, log);
    -        }
    -
             private static IOException wrongFormat(Path file, List lines, BuildToolLog log) {
                 if (log.isDebugEnabled()) {
                     log.debug("wrong format of lock file " + file);
    @@ -397,12 +386,11 @@ private static List getHeaderList(String lockFileHeader) {
         }
     
         public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException {
    -        createVenv(venvDirectory, packagesArgs, null, null, null, null, launcherArgs, graalPyVersion, log);
    +        createVenv(venvDirectory, packagesArgs, null, null, null, launcherArgs, graalPyVersion, log);
         }
     
    -    public static void createVenv(Path venvDirectory, List packages, Path lockFilePath,
    -                    String lockFileHeader, String packagesChangedError, String missingLockFileWarning,
    -                    Launcher launcher, String graalPyVersion, BuildToolLog log) throws IOException {
    +    public static void createVenv(Path venvDirectory, List packages, Path lockFilePath, String packagesChangedError, String missingLockFileWarning, Launcher launcher, String graalPyVersion,
    +                    BuildToolLog log) throws IOException {
             Objects.requireNonNull(venvDirectory);
             Objects.requireNonNull(packages);
             Objects.requireNonNull(launcher);
    @@ -417,7 +405,7 @@ public static void createVenv(Path venvDirectory, List packages, Path lo
             List pluginPackages = trim(packages);
             LockFile lockFile = null;
             if (lockFilePath != null && Files.exists(lockFilePath)) {
    -            lockFile = LockFile.fromFile(lockFilePath, lockFileHeader, log);
    +            lockFile = LockFile.fromFile(lockFilePath, log);
             }
     
             if (!checkPackages(venvDirectory, pluginPackages, lockFile, packagesChangedError, log)) {
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    index a91a65dfbf..3b4e9abc02 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    @@ -69,7 +69,7 @@ public abstract class InstallPackagesTask extends AbstractPackagesTask {
         public void exec() throws GradleException {
             Path venvDirectory = getVenvDirectory();
             try {
    -            VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), LOCK_FILE_HEADER, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(),  getPolyglotVersion().get(), getLog());
    +            VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(),  getPolyglotVersion().get(), getLog());
             } catch (IOException e) {
                 throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e);
             }
    
    From f6ec26ec4b5452f6960a99480061615486bcf373 Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 14:25:58 +0100
    Subject: [PATCH 080/512] changed LockPackagesTask to @UntrackedTask
    
    ---
     .../org/graalvm/python/tasks/AbstractPackagesTask.java | 10 ++++++++--
     .../org/graalvm/python/tasks/LockPackagesTask.java     |  4 ++--
     2 files changed, 10 insertions(+), 4 deletions(-)
    
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    index d9e09c035a..d05772089a 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    @@ -50,7 +50,14 @@
     import org.gradle.api.file.RegularFileProperty;
     import org.gradle.api.provider.ListProperty;
     import org.gradle.api.provider.Property;
    -import org.gradle.api.tasks.*;
    +import org.gradle.api.tasks.Classpath;
    +import org.gradle.api.tasks.Input;
    +import org.gradle.api.tasks.InputFiles;
    +import org.gradle.api.tasks.Internal;
    +import org.gradle.api.tasks.Optional;
    +import org.gradle.api.tasks.OutputDirectory;
    +import org.gradle.api.tasks.PathSensitive;
    +import org.gradle.api.tasks.PathSensitivity;
     import org.jetbrains.annotations.NotNull;
     
     import java.io.File;
    @@ -76,7 +83,6 @@
      * 
      *
      */
    -@CacheableTask
     public abstract class AbstractPackagesTask extends DefaultTask {
     
         protected static final String LOCK_FILE_HEADER = """
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    index 6f90e6d114..62a9763db4 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    @@ -41,7 +41,7 @@
     package org.graalvm.python.tasks;
     
     import org.gradle.api.GradleException;
    -import org.gradle.api.tasks.CacheableTask;
    +import org.gradle.api.tasks.UntrackedTask;
     import org.gradle.api.tasks.TaskAction;
     
     import java.io.IOException;
    @@ -56,7 +56,7 @@
      * If there is no virtual environment preset then it is first created and packages are installed the same way
      * as in scope of {@link InstallPackagesTask}.
      */
    -@CacheableTask
    +@UntrackedTask(because="manually triggered, should always run")
     public abstract class LockPackagesTask extends AbstractPackagesTask {
         @TaskAction
         public void exec() throws GradleException {
    
    From aa6638376a277217b7d038a47249946593d8287b Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 15:09:43 +0100
    Subject: [PATCH 081/512] minor refactoring around installed packages freeze
    
    ---
     .../python/embedding/tools/vfs/VFSUtils.java  | 21 ++++++++-----------
     1 file changed, 9 insertions(+), 12 deletions(-)
    
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    index e2f9b75544..7c7961cbf8 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    @@ -414,15 +414,19 @@ public static void createVenv(Path venvDirectory, List packages, Path lo
     
             VenvContents venvContents = ensureVenv(venvDirectory, graalPyVersion, launcher, log);
     
    +        InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory);
             boolean installed;
             if (lockFile != null) {
    -            installed = install(venvDirectory, lockFile, log);
    +            installed = install(venvDirectory, installedPackages, lockFile, log);
             } else {
                 installed = install(venvDirectory, pluginPackages, venvContents, log);
    -            missingLockFileWarning(venvDirectory, pluginPackages, missingLockFileWarning, log);
             }
             if (installed) {
                 venvContents.write(pluginPackages);
    +            installedPackages.freeze(log);
    +        }
    +        if (lockFile == null) {
    +            missingLockFileWarning(venvDirectory, pluginPackages, missingLockFileWarning, log);
             }
         }
     
    @@ -591,11 +595,9 @@ private static VenvContents ensureVenv(Path venvDirectory, String graalPyVersion
             return contents;
         }
     
    -    private static boolean install(Path venvDirectory, LockFile lockFile, BuildToolLog log) throws IOException {
    -        InstalledPackages installedPackages = InstalledPackages.fromVenv(venvDirectory);
    +    private static boolean install(Path venvDirectory, InstalledPackages installedPackages, LockFile lockFile, BuildToolLog log) throws IOException {
             if (installedPackages.packages.size() != lockFile.packages.size() || deleteUnwantedPackages(venvDirectory, lockFile.packages, installedPackages.packages, log)) {
                 runPip(venvDirectory, "install", log, "-r", lockFile.path.toString());
    -            installedPackages.freeze(log);
                 return true;
             } else {
                 info(log, "Virtual environment is up to date with lock file, skipping install");
    @@ -611,9 +613,8 @@ private static boolean install(Path venvDirectory, List newPackages, Ven
         }
     
         private static void missingLockFileWarning(Path venvDirectory, List newPackages, String missingLockFileWarning, BuildToolLog log) throws IOException {
    -        List installedPackages = InstalledPackages.fromVenv(venvDirectory).freeze(log);
             if (missingLockFileWarning != null && !Boolean.getBoolean("graalpy.vfs.skipMissingLockFileWarning")) {
    -            if (!newPackages.containsAll(installedPackages)) {
    +            if (!newPackages.containsAll(InstalledPackages.fromVenv(venvDirectory).packages)) {
                     if (log.isWarningEnabled()) {
                         String txt = missingLockFileWarning + "\n";
                         for (String t : txt.split("\n")) {
    @@ -809,9 +810,7 @@ private static List trim(List l) {
         }
     
         private static void warning(BuildToolLog log, String txt) {
    -        if (log.isWarningEnabled()) {
    -            log.warning(txt);
    -        }
    +        log.warning(txt);
         }
     
         private static void extendedError(BuildToolLog log, String txt) {
    @@ -837,9 +836,7 @@ private static void lifecycle(BuildToolLog log, String txt, Object... args) {
         }
     
         private static void debug(BuildToolLog log, String txt) {
    -        if (log.isDebugEnabled()) {
                 log.debug(txt);
    -        }
         }
     
         private static void logDebug(BuildToolLog log, List l, String msg, Object... args) {
    
    From e9a951bb1444ebcc2cfc27b6f32f58cfa9399634 Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 16:00:22 +0100
    Subject: [PATCH 082/512] improved error handling
    
    ---
     .../maven/plugin/AbstractGraalPyMojo.java     | 52 +++++------
     .../python/embedding/tools/vfs/VFSUtils.java  | 93 ++++++++++---------
     2 files changed, 70 insertions(+), 75 deletions(-)
    
    diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    index 3d2566ced1..dfd8753ed9 100644
    --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    @@ -160,7 +160,7 @@ protected void listGraalPyResources() throws MojoExecutionException {
             }
         }
     
    -    protected void preExec(boolean checkFields) throws MojoExecutionException {
    +    protected void preExec(boolean enableWarnings) throws MojoExecutionException {
             pythonResourcesDirectory = normalizeEmpty(pythonResourcesDirectory);
             externalDirectory = normalizeEmpty(externalDirectory);
             resourceDirectory = normalizeEmpty(resourceDirectory);
    @@ -168,47 +168,41 @@ protected void preExec(boolean checkFields) throws MojoExecutionException {
             packages = packages != null ? packages.stream().filter(p -> p != null && !p.trim().isEmpty()).toList() : Collections.EMPTY_LIST;
     
             if(pythonResourcesDirectory != null) {
    -            if(checkFields) {
    -                if (externalDirectory != null) {
    -                    throw new MojoExecutionException(
    -                            "Cannot use  and  at the same time. " +
    -                                    "New option  is a replacement for deprecated . " +
    -                                    "If you want to deploy the virtual environment into physical filesystem, use . " +
    -                                    "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." +
    -                                    "If you want to bundle the virtual filesystem in Java resources, use . " +
    -                                    "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ");
    -                }
    -                getLog().warn("Option  is deprecated and will be removed. Use  instead.");
    +            if (externalDirectory != null) {
    +                throw new MojoExecutionException(
    +                        "Cannot use  and  at the same time. " +
    +                                "New option  is a replacement for deprecated . " +
    +                                "If you want to deploy the virtual environment into physical filesystem, use . " +
    +                                "The deployment of the external directory alongside the application is not handled by the GraalPy Maven plugin in such case." +
    +                                "If you want to bundle the virtual filesystem in Java resources, use . " +
    +                                "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ");
                 }
    +            getLog().warn("Option  is deprecated and will be removed. Use  instead.");
                 externalDirectory = pythonResourcesDirectory;
             }
     
             if (resourceDirectory != null) {
    -            if(checkFields) {
    -                if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) {
    -                    throw new MojoExecutionException(
    -                            "Value of  should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'");
    -                }
    +            if (resourceDirectory.startsWith("/") || resourceDirectory.endsWith("/")) {
    +                throw new MojoExecutionException(
    +                        "Value of  should be relative resources path, i.e., without the leading '/', and it also must not end with trailing '/'");
                 }
             }
     
             if (resourceDirectory == null) {
    -            if(checkFields) {
    -                if (externalDirectory == null) {
    -                    getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " +
    -                            "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " +
    -                            "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " +
    -                            "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." +
    -                            "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ",
    -                            VFS_ROOT,
    -                            Path.of(VFS_ROOT, "src"),
    -                            Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId())));
    -                }
    +            if (enableWarnings && externalDirectory == null) {
    +                getLog().info(String.format("Virtual filesystem is deployed to default resources directory '%s'. " +
    +                        "This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem. " +
    +                        "Consider adding GRAALPY-VFS/${project.groupId}/${project.artifactId} to your pom.xml, " +
    +                        "moving any existing sources from '%s' to '%s', and using VirtualFileSystem$Builder#resourceDirectory." +
    +                        "For more details, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools. ",
    +                        VFS_ROOT,
    +                        Path.of(VFS_ROOT, "src"),
    +                        Path.of("GRAALPY-VFS", project.getGroupId(), project.getArtifactId())));
                 }
                 resourceDirectory = VFS_ROOT;
             }
     
    -        if(checkFields && pythonHome != null) {
    +        if(enableWarnings && pythonHome != null) {
                 getLog().warn("The GraalPy plugin  configuration setting was deprecated and has no effect anymore.\n" +
                     "For execution in jvm mode, the python language home is always available.\n" +
                     "When building a native executable using GraalVM Native Image, then the full python language home is by default embedded into the native executable.\n" +
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    index 7c7961cbf8..60cb28d473 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    @@ -293,54 +293,55 @@ private LockFile(Path path, List inputPackages, List packages) {
             static LockFile fromFile(Path file, BuildToolLog log) throws IOException {
                 List packages = new ArrayList<>();
                 List inputPackages = null;
    -            if (Files.isReadable(file)) {
    -                List lines = Files.readAllLines(file);
    -                if (lines.isEmpty()) {
    -                    throw wrongFormat(file, lines, log);
    -                }
    -                // format:
    -                // 1.) a multiline header comment
    -                // 2.) graalpy version - 1 line (starting with comment #)
    -                // 2.) input packages - 1 line (starting with comment #)
    -                // 3.) locked packages - 1 line each (as input for pip install)
    -                // see also LockFile.write()
    -                Iterator it = lines.iterator();
    -                try {
    -                    // graalpy version, we don't care about it for now, but with future versions the
    -                    // file format might change, and we will need to know to parse differently
    -                    String graalPyVersion = null;
    -                    while (it.hasNext()) {
    -                        String line = it.next();
    -                        if (line.startsWith(GRAALPY_VERSION_PREFIX)) {
    -                            graalPyVersion = line.substring(GRAALPY_VERSION_PREFIX.length()).trim();
    -                            if (graalPyVersion.isEmpty()) {
    -                                throw wrongFormat(file, lines, log);
    -                            }
    -                            break;
    -                        }
    -                    }
    -                    if (graalPyVersion == null) {
    -                        throw wrongFormat(file, lines, log);
    -                    }
    -                    // input packages
    +            List lines;
    +            try {
    +                lines = Files.readAllLines(file);
    +            } catch (IOException e) {
    +                throw new IOException(String.format("Cannot read the lock file from '%s'", file), e);
    +            }
    +            if (lines.isEmpty()) {
    +                throw wrongFormat(file, lines, log);
    +            }
    +            // format:
    +            // 1.) a multiline header comment
    +            // 2.) graalpy version - 1 line (starting with comment #)
    +            // 2.) input packages - 1 line (starting with comment #)
    +            // 3.) locked packages - 1 line each (as input for pip install)
    +            // see also LockFile.write()
    +            Iterator it = lines.iterator();
    +            try {
    +                // graalpy version, we don't care about it for now, but with future versions the
    +                // file format might change, and we will need to know to parse differently
    +                String graalPyVersion = null;
    +                while (it.hasNext()) {
                         String line = it.next();
    -                    if (!line.startsWith(INPUT_PACKAGES_PREFIX)) {
    -                        throw wrongFormat(file, lines, log);
    -                    }
    -                    String pkgs = line.substring(INPUT_PACKAGES_PREFIX.length()).trim();
    -                    if (pkgs.isEmpty()) {
    -                        throw wrongFormat(file, lines, log);
    -                    }
    -                    inputPackages = Arrays.asList(pkgs.split(INPUT_PACKAGES_DELIMITER));
    -                    // locked packages
    -                    while (it.hasNext()) {
    -                        packages.add(it.next());
    +                    if (line.startsWith(GRAALPY_VERSION_PREFIX)) {
    +                        graalPyVersion = line.substring(GRAALPY_VERSION_PREFIX.length()).trim();
    +                        if (graalPyVersion.isEmpty()) {
    +                            throw wrongFormat(file, lines, log);
    +                        }
    +                        break;
                         }
    -                } catch (NoSuchElementException e) {
    +                }
    +                if (graalPyVersion == null) {
                         throw wrongFormat(file, lines, log);
                     }
    -            } else {
    -                throw new IOException("can't read lock file");
    +                // input packages
    +                String line = it.next();
    +                if (!line.startsWith(INPUT_PACKAGES_PREFIX)) {
    +                    throw wrongFormat(file, lines, log);
    +                }
    +                String pkgs = line.substring(INPUT_PACKAGES_PREFIX.length()).trim();
    +                if (pkgs.isEmpty()) {
    +                    throw wrongFormat(file, lines, log);
    +                }
    +                inputPackages = Arrays.asList(pkgs.split(INPUT_PACKAGES_DELIMITER));
    +                // locked packages
    +                while (it.hasNext()) {
    +                    packages.add(it.next());
    +                }
    +            } catch (NoSuchElementException e) {
    +                throw wrongFormat(file, lines, log);
                 }
                 return new LockFile(file, inputPackages, packages);
             }
    @@ -353,7 +354,7 @@ private static IOException wrongFormat(Path file, List lines, BuildToolL
                     }
                     log.debug("");
                 }
    -            return new IOException("invalid lock file format");
    +            return new IOException(String.format("Cannot read the lock file from '%s'\n(turn on debug log level to see the contents)", file));
             }
     
             private static void write(Path venvDirectory, Path lockFile, String lockFileHeader, List inputPackages, String graalPyVersion, BuildToolLog log) throws IOException {
    @@ -836,7 +837,7 @@ private static void lifecycle(BuildToolLog log, String txt, Object... args) {
         }
     
         private static void debug(BuildToolLog log, String txt) {
    -            log.debug(txt);
    +        log.debug(txt);
         }
     
         private static void logDebug(BuildToolLog log, List l, String msg, Object... args) {
    
    From 72a71def237bb0b24f05705329ebfeaea2c0a6dc Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 16:00:30 +0100
    Subject: [PATCH 083/512] javadoc in BuildToolLog
    
    ---
     .../org/graalvm/python/embedding/tools/exec/BuildToolLog.java | 4 ++++
     1 file changed, 4 insertions(+)
    
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java
    index c58e2bb412..2a4db4798b 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/BuildToolLog.java
    @@ -44,6 +44,10 @@
     import java.util.ArrayList;
     import java.util.List;
     
    +/**
    + * Build tool verbosity: maven - debug, info, warning, error gradle - debug, info, lifecycle,
    + * warning, error
    + */
     public interface BuildToolLog {
         void subProcessOut(String out);
     
    
    From cd29dbe6663fb95f24ccb1b187094b3eb3250b32 Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 16:02:35 +0100
    Subject: [PATCH 084/512] improved wording in PACKAGES_CHANGED_ERROR
    
    ---
     .../src/tests/standalone/test_maven_plugin.py                   | 2 +-
     .../org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java    | 2 +-
     .../java/org/graalvm/python/tasks/AbstractPackagesTask.java     | 2 +-
     3 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    index 2d23d3433a..633fc9b553 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    @@ -49,7 +49,7 @@
     from tests.standalone.util import TemporaryTestDirectory, Logger
     
     MISSING_FILE_WARNING = "The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration."
    -PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file"
    +PACKAGES_CHANGED_ERROR = "but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file"
     VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install"
     
     class MavenPluginTest(util.BuildToolTestBase):
    diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    index dfd8753ed9..810c183489 100644
    --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java
    @@ -96,7 +96,7 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo {
     
         protected static final String PACKAGES_CHANGED_ERROR = """
             Install of python packages is based on lock file %s,
    -        but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file.
    +        but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file.
             
             Packages currently declared in graalpy-maven-plugin configuration: %s
             Packages which were used to generate the lock file: %s
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    index d05772089a..6216ee7b89 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    @@ -110,7 +110,7 @@ public abstract class AbstractPackagesTask extends DefaultTask {
     
         protected static final String PACKAGES_CHANGED_ERROR = """
             Install of python packages is based on lock file %s,
    -        but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file.
    +        but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file.
             
             Packages currently declared in graalpy-gradle-plugin configuration: %s
             Packages which were used to generate the lock file: %s
    
    From ee19b0c3c2ab68f27c7cbdc3b88b578f0fd6f3f6 Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 16:03:19 +0100
    Subject: [PATCH 085/512] optionally switch off info log level in
     test_gradle_plugin
    
    ---
     .../src/tests/standalone/test_gradle_plugin.py             | 7 +++++--
     .../src/tests/standalone/util.py                           | 7 +++++--
     2 files changed, 10 insertions(+), 4 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py
    index 81369cfc27..61fcc7c578 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py
    @@ -47,7 +47,7 @@
     from tests.standalone.util import TemporaryTestDirectory, Logger
     
     MISSING_FILE_WARNING = "The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration"
    -PACKAGES_CHANGED_ERROR = "but packages in graalpy-maven-plugin configuration are different then previously used to generate the lock file"
    +PACKAGES_CHANGED_ERROR = "packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file"
     VENV_UPTODATE = "Virtual environment is up to date with lock file, skipping install"
     
     def append(file, txt):
    @@ -133,10 +133,11 @@ def check_gradle_generated_app(self, community):
                 build_file = os.path.join(target_dir, self.build_file_name)
                 append(build_file, self.packages_termcolor(community))
     
    -            gradlew_cmd = util.get_gradle_wrapper(target_dir, self.env)
                 log = Logger()
     
                 # build
    +            gradlew_cmd = util.get_gradle_wrapper(target_dir, self.env, verbose=False)
    +
                 cmd = gradlew_cmd + ["build"]
                 out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, logger=log)
                 util.check_ouput("BUILD SUCCESS", out, logger=log)
    @@ -144,6 +145,8 @@ def check_gradle_generated_app(self, community):
                 util.check_ouput("This can cause conflicts if used with other Java libraries that also deploy GraalPy virtual filesystem", out, logger=log)
                 self.check_filelist(target_dir, log)
     
    +            gradlew_cmd = util.get_gradle_wrapper(target_dir, self.env)
    +
                 cmd = gradlew_cmd + ["nativeCompile"]
                 out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir, logger=log)
                 util.check_ouput("BUILD SUCCESS", out, logger=log)
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py
    index 33a77dc7cd..4fb6f4867c 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py
    @@ -227,12 +227,15 @@ def get_mvn_wrapper(project_dir, env):
         check_ouput(MAVEN_VERSION, out)
         return mvn_cmd
     
    -def get_gradle_wrapper(project_dir, env):
    +def get_gradle_wrapper(project_dir, env, verbose=True):
         gradle_cmd = [os.path.abspath(os.path.join(project_dir, "gradlew" if 'win32' != sys.platform else "gradlew.bat"))]
         cmd = gradle_cmd + ["--version"]
         out, return_code = run_cmd(cmd, env, cwd=project_dir)
         check_ouput(GRADLE_VERSION, out)
    -    return gradle_cmd + ["-i"]
    +    if verbose:
    +        return gradle_cmd + ["-i"]
    +    else:
    +        return gradle_cmd
     
     def get_gp():
         if "PYTHON_STANDALONE_HOME" not in os.environ:
    
    From e12f6ddf241ab1f14f47bbc7a92454c252938d2a Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Fri, 21 Feb 2025 16:09:17 +0100
    Subject: [PATCH 086/512] minor wording fix in Embedding-Build-Tools.md
    
    ---
     docs/user/Embedding-Build-Tools.md | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/docs/user/Embedding-Build-Tools.md b/docs/user/Embedding-Build-Tools.md
    index c5fc0a8283..5f7c8790d4 100644
    --- a/docs/user/Embedding-Build-Tools.md
    +++ b/docs/user/Embedding-Build-Tools.md
    @@ -84,7 +84,7 @@ Whether deployed in a virtual filesystem or an external directory, its contents
     specified in the plugin configuration.
     
     ## Python Dependency Management
    -The list of third-party Python packages to be downloaded and installed can be specified in the particular plugin`s configuration. Unfortunately,
    +The list of third-party Python packages to be downloaded and installed can be specified in Maven or Gradle plugin configuration. Unfortunately,
     Python does not enforce strict versioning of dependencies, which can result in problems if a third-party package or one of its transitive
     dependencies is unexpectedly updated to a newer version, leading to unforeseen behavior.
     
    @@ -158,7 +158,7 @@ Remember to use the appropriate `GraalPyResources` API to create the Context. Th
       ```
       
     ### Locking Python Packages
    -To lock the current state of the installed packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:lock-packages`. 
    +To lock the dependency tree of the specified Python packages, execute the GraalPy plugin goal `org.graalvm.python:graalpy-maven-plugin:lock-packages`. 
     ```bash
     $ mvn org.graalvm.python:graalpy-maven-plugin:lock-packages
     ```
    @@ -227,7 +227,7 @@ dependency `org.graalvm.python:python` to the community build: `org.graalvm.pyth
       }
       ```
     ### Locking Python Packages
    -To lock the current state of declared packages, execute the GraalPy plugin task `graalPyLockPackages`.
    +To lock the dependency tree of the specified Python packages, execute the GraalPy plugin task `graalPyLockPackages`.
     ```bash
     $ gradle graalPyLockPackages
     ```
    
    From 00a3fb6dd9e870bfedb90dd8844157385aa96bdd Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 24 Feb 2025 10:55:22 +0100
    Subject: [PATCH 087/512] Add sq_contains slot
    
    ---
     .../oracle/graal/python/annotations/Slot.java |   2 +
     .../graal/python/processor/SlotsMapping.java  |   2 +
     .../src/tests/cpyext/test_tp_slots.py         |   5 +-
     .../builtins/objects/array/ArrayBuiltins.java |   6 +-
     .../objects/bytes/BytesCommonBuiltins.java    |   6 +-
     .../objects/cext/capi/PyProcsWrapper.java     |  42 +++
     .../objects/contextvars/ContextBuiltins.java  |   6 +-
     .../builtins/objects/deque/DequeBuiltins.java |   6 +-
     .../builtins/objects/dict/DictBuiltins.java   |   6 +-
     .../objects/dict/DictViewBuiltins.java        |   6 +-
     .../builtins/objects/list/ListBuiltins.java   |   6 +-
     .../mappingproxy/MappingproxyBuiltins.java    |  14 +-
     .../builtins/objects/range/RangeBuiltins.java |   6 +-
     .../builtins/objects/set/BaseSetBuiltins.java |   6 +-
     .../builtins/objects/str/StringBuiltins.java  |   6 +-
     .../builtins/objects/tuple/TupleBuiltins.java |   7 +-
     .../python/builtins/objects/type/TpSlots.java |  14 +
     .../objects/type/slots/TpSlotSqContains.java  | 148 +++++++++++
     .../python/lib/PySequenceContainsNode.java    |  50 ++--
     .../graal/python/nodes/bytecode/InNode.java   |  67 +++++
     .../nodes/bytecode/PBytecodeRootNode.java     |   3 +-
     .../python/nodes/expression/ContainsNode.java | 248 ------------------
     22 files changed, 336 insertions(+), 326 deletions(-)
     create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
     create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/InNode.java
     delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ContainsNode.java
    
    diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    index 20e7d98081..834ac45af4 100644
    --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    @@ -177,6 +177,8 @@ enum SlotKind {
             sq_inplace_concat("__iadd__"),
             /** seq *= seq */
             sq_inplace_repeat("__imul__"),
    +        /** item in seq **/
    +        sq_contains("__contains__"),
             /** mapping length */
             mp_length("__len__"),
             /** mapping subscript, e.g. o[key], o[i:j] */
    diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    index 7f4296fcbf..73af396a11 100644
    --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    @@ -67,6 +67,7 @@ static String getSlotBaseClass(Slot s) {
                 case sq_length, mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix(s.isComplex());
                 case sq_item, sq_repeat, sq_inplace_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin";
                 case sq_ass_item -> "TpSlotSqAssItem.TpSlotSqAssItemBuiltin";
    +            case sq_contains -> "TpSlotSqContains.TpSlotSqContainsBuiltin";
                 case mp_subscript -> "TpSlotBinaryFunc.TpSlotMpSubscript";
                 case mp_ass_subscript -> "TpSlotMpAssSubscript.TpSlotMpAssSubscriptBuiltin";
                 case tp_getattro -> "TpSlotGetAttr.TpSlotGetAttrBuiltin";
    @@ -95,6 +96,7 @@ static String getSlotNodeBaseClass(Slot s) {
                 case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode";
                 case sq_ass_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode";
                 case sq_repeat, sq_inplace_repeat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode";
    +            case sq_contains -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode";
                 case mp_subscript -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode";
                 case mp_ass_subscript -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode";
                 case tp_getattro -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode";
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    index 294a870f26..7abbedb073 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    @@ -1336,9 +1336,8 @@ def __contains__(self, item):
         for obj in [NativeSqSlotProxy([1]), NativeSqSlotProxy(PureSlotProxy([1]))]:
             assert len(obj) == 1
             assert bool(obj)
    -        # TODO fix on graalpy
    -        # assert 1 in obj
    -        # assert 2 not in obj
    +        assert 1 in obj
    +        assert 2 not in obj
     
             assert obj[0] == 1
             assert_raises(IndexError, operator.getitem, obj, 1)
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    index 789313778e..97c8212abb 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    @@ -40,7 +40,6 @@
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ARRAY;
     import static com.oracle.graal.python.nodes.ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DICT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    @@ -92,6 +91,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
    @@ -487,9 +487,9 @@ static Object cmp(VirtualFrame frame, Object left, Object right,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    abstract static class ContainsNode extends SqContainsBuiltinNode {
             @Specialization
             static boolean contains(VirtualFrame frame, PArray self, Object value,
                             @Bind("this") Node inliningTarget,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    index 73c05dea87..b2f0965ab3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.METHOD_REQUIRES_A_BYTES_OBJECT_GOT_P;
     import static com.oracle.graal.python.nodes.ErrorMessages.SEP_MUST_BE_ASCII;
     import static com.oracle.graal.python.nodes.ErrorMessages.SEP_MUST_BE_LENGTH_1;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETNEWARGS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    @@ -105,6 +104,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyNumberIndexNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -415,9 +415,9 @@ public static int len(Object self,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    abstract static class ContainsNode extends SqContainsBuiltinNode {
     
             @Specialization
             boolean contains(VirtualFrame frame, Object self, Object other,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    index 826b572f0f..9e4d53560a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    @@ -70,6 +70,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.CallManagedSlotSetAttrNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.CallSlotSizeArgFun;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.CallSlotSqAssItemNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.CallSlotSqContainsNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.CallSlotUnaryNode;
     import com.oracle.graal.python.lib.PyObjectHashNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -548,6 +549,47 @@ public TpSlotWrapper cloneWith(TpSlotManaged slot) {
             }
         }
     
    +    @ExportLibrary(InteropLibrary.class)
    +    public static final class SqContainsWrapper extends TpSlotWrapper {
    +        public SqContainsWrapper(TpSlotManaged delegate) {
    +            super(delegate);
    +        }
    +
    +        @ExportMessage
    +        Object execute(Object[] arguments,
    +                        @Bind("$node") Node inliningTarget,
    +                        @Cached CallSlotSqContainsNode callSlotNode,
    +                        @Cached NativeToPythonNode toJavaNode,
    +                        @Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
    +                        @Exclusive @Cached GilNode gil) {
    +            boolean mustRelease = gil.acquire();
    +            CApiTiming.enter();
    +            try {
    +                try {
    +                    return callSlotNode.execute(null, inliningTarget, getSlot(), toJavaNode.execute(arguments[0]), toJavaNode.execute(arguments[1]));
    +                } catch (Throwable t) {
    +                    throw checkThrowableBeforeNative(t, "SqContainsWrapper", getDelegate());
    +                }
    +            } catch (PException e) {
    +                transformExceptionToNativeNode.execute(inliningTarget, e);
    +                return -1;
    +            } finally {
    +                CApiTiming.exit(timing);
    +                gil.release(mustRelease);
    +            }
    +        }
    +
    +        @Override
    +        protected String getSignature() {
    +            return "(POINTER,POINTER):SINT32";
    +        }
    +
    +        @Override
    +        public TpSlotWrapper cloneWith(TpSlotManaged slot) {
    +            return new SqContainsWrapper(slot);
    +        }
    +    }
    +
         @ExportLibrary(InteropLibrary.class)
         public static final class ObjobjargWrapper extends TpSlotWrapper {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    index 9fa115934f..47e8407cf0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.contextvars;
     
     import static com.oracle.graal.python.nodes.PGuards.isNoValue;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     
     import java.util.List;
    @@ -58,6 +57,7 @@
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -192,9 +192,9 @@ Object doGetDefault(PContextVarsContext self, Object key, Object def,
     
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class Contains extends PythonBuiltinNode {
    +    public abstract static class Contains extends SqContainsBuiltinNode {
             @Specialization
             boolean doIn(PContextVarsContext self, Object key,
                             @Bind("this") Node inliningTarget,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    index 51048cba13..510afcc2f2 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    @@ -52,7 +52,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.DEQUE_MUTATED_DURING_REMOVE;
     import static com.oracle.graal.python.nodes.ErrorMessages.DEQUE_REMOVE_X_NOT_IN_DEQUE;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___COPY__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
    @@ -100,6 +99,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -792,9 +792,9 @@ PDeque doGeneric(PDeque self, int n) {
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class DequeContainsNode extends PythonBinaryBuiltinNode {
    +    public abstract static class DequeContainsNode extends SqContainsBuiltinNode {
     
             @Specialization
             @TruffleBoundary
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    index dea70bcd88..f043553da8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    @@ -30,7 +30,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_KEYS;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_VALUES;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    @@ -74,6 +73,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyDictCheckNode;
     import com.oracle.graal.python.lib.PyDictSetDefault;
    @@ -430,9 +430,9 @@ static Object doGeneric(VirtualFrame frame, Object self, Object other,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    public abstract static class ContainsNode extends SqContainsBuiltinNode {
     
             @Specialization
             static boolean run(VirtualFrame frame, Object self, Object key,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    index f605099833..116d28e343 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.dict;
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_ISDISJOINT;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    @@ -83,6 +82,7 @@
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    @@ -197,9 +197,9 @@ static Object getReversedItemsViewIter(PDictItemsView self,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    public abstract static class ContainsNode extends SqContainsBuiltinNode {
             @SuppressWarnings("unused")
             @Specialization(guards = "len.execute(inliningTarget, self.getWrappedStorage()) == 0", limit = "1")
             static boolean containsEmpty(PDictView self, Object key,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    index a29702df43..50bfc2b7f9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    @@ -29,7 +29,6 @@
     import static com.oracle.graal.python.nodes.BuiltinNames.J_EXTEND;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_SORT;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    @@ -87,6 +86,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyListCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -1011,9 +1011,9 @@ static Object doOther(VirtualFrame frame, Object left, Object right,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    abstract static class ContainsNode extends SqContainsBuiltinNode {
             @Specialization
             boolean contains(VirtualFrame frame, Object self, Object other,
                             @Bind("this") Node inliningTarget,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    index 6d7c857758..9849b061fb 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    @@ -32,7 +32,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_KEYS;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_VALUES;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    @@ -61,6 +60,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.MpSubscriptBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.PyNumberOrNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.lib.PyObjectGetItem;
    @@ -69,6 +69,7 @@
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
     import com.oracle.graal.python.lib.PyObjectStrAsObjectNode;
    +import com.oracle.graal.python.lib.PySequenceContainsNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -184,13 +185,14 @@ Object getItem(VirtualFrame frame, PMappingproxy self, Object key,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class ContainsNode extends PythonBuiltinNode {
    +    public abstract static class ContainsNode extends SqContainsBuiltinNode {
             @Specialization
    -        Object run(VirtualFrame frame, PMappingproxy self, Object key,
    -                        @Cached com.oracle.graal.python.nodes.expression.ContainsNode containsNode) {
    -            return containsNode.execute(frame, key, self.getMapping());
    +        boolean run(VirtualFrame frame, PMappingproxy self, Object key,
    +                        @Bind Node inliningTarget,
    +                        @Cached PySequenceContainsNode containsNode) {
    +            return containsNode.execute(frame, inliningTarget, self.getMapping(), key);
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    index 3e678b5c7a..87e2159a4e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    @@ -30,7 +30,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.builtins.objects.common.IndexNodes.checkBounds;
     import static com.oracle.graal.python.nodes.ErrorMessages.RANGE_OUT_OF_BOUNDS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    @@ -71,6 +70,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyLongCheckExactNode;
    @@ -628,11 +628,11 @@ public static GetItemNode getUncached() {
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
         @ImportStatic(PGuards.class)
         @TypeSystemReference(PythonIntegerTypes.class)
    -    abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    abstract static class ContainsNode extends SqContainsBuiltinNode {
             private static final BigInteger MINUS_ONE = BigInteger.ONE.negate();
     
             public abstract boolean execute(VirtualFrame frame, PRange self, Object value);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    index efdb549f23..41db9626db 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.set;
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    @@ -88,6 +87,7 @@
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectGetStateNode;
    @@ -262,9 +262,9 @@ static PNotImplemented doGeneric(Object self, Object other) {
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    protected abstract static class BaseContainsNode extends PythonBinaryBuiltinNode {
    +    protected abstract static class BaseContainsNode extends SqContainsBuiltinNode {
     
             @Specialization
             static boolean contains(VirtualFrame frame, PBaseSet self, Object key,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    index 91aa28c98c..e59806c794 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    @@ -37,7 +37,6 @@
     import static com.oracle.graal.python.nodes.BuiltinNames.T_STARTSWITH;
     import static com.oracle.graal.python.nodes.ErrorMessages.FILL_CHAR_MUST_BE_UNICODE_CHAR_NOT_P;
     import static com.oracle.graal.python.nodes.ErrorMessages.S_ENCODER_RETURNED_P_INSTEAD_OF_BYTES;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___FORMAT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETNEWARGS__;
    @@ -131,6 +130,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
    @@ -423,9 +423,9 @@ static Object doGeneric(Node inliningTarget, Object self, Object other, IntPredi
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    public abstract static class ContainsNode extends SqContainsBuiltinNode {
             public abstract boolean executeBool(Object self, Object left);
     
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    index 7a0bb1eb5b..6563c5ab48 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    @@ -26,7 +26,6 @@
     package com.oracle.graal.python.builtins.objects.tuple;
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETNEWARGS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
    @@ -75,6 +74,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyObjectHashNode;
     import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode;
    @@ -488,9 +488,9 @@ static Object doTuple(VirtualFrame frame, Object left, int repeats,
             }
         }
     
    -    @Builtin(name = J___CONTAINS__, minNumOfPositionalArgs = 2)
    +    @Slot(value = SlotKind.sq_contains, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class ContainsNode extends PythonBinaryBuiltinNode {
    +    abstract static class ContainsNode extends SqContainsBuiltinNode {
             @Specialization
             boolean contains(VirtualFrame frame, Object self, Object other,
                             @Bind("this") Node inliningTarget,
    @@ -498,7 +498,6 @@ boolean contains(VirtualFrame frame, Object self, Object other,
                             @Cached SequenceStorageNodes.ContainsNode containsNode) {
                 return containsNode.execute(frame, inliningTarget, getTupleStorage.execute(inliningTarget, self), other);
             }
    -
         }
     
         @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    index b5901965ba..b07754fb17 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    @@ -44,6 +44,7 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ADD__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BOOL__;
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELATTR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELETE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELITEM__;
    @@ -132,6 +133,7 @@
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbPowerWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.ObjobjargWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SetattrWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SqContainsWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SsizeargfuncSlotWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.SsizeobjargprocWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.TpSlotWrapper;
    @@ -175,6 +177,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.TpSlotSqAssItemBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.TpSlotSqAssItemPython;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.TpSlotSqContainsBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.TpSlotUnaryFuncBuiltin;
     import com.oracle.graal.python.nodes.PGuards;
     import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
    @@ -298,6 +301,7 @@ public record TpSlots(TpSlot nb_bool, //
                     TpSlot sq_repeat, //
                     TpSlot sq_inplace_concat, //
                     TpSlot sq_inplace_repeat, //
    +                TpSlot sq_contains, //
                     TpSlot mp_length, //
                     TpSlot mp_subscript, //
                     TpSlot mp_ass_subscript, //
    @@ -744,6 +748,14 @@ public enum TpSlotMeta {
                             CFields.PySequenceMethods__sq_inplace_repeat,
                             PExternalFunctionWrapper.SSIZE_ARG,
                             SsizeargfuncSlotWrapper::new),
    +        SQ_CONTAINS(
    +                        TpSlots::sq_contains,
    +                        TpSlotPythonSingle.class,
    +                        TpSlotSqContainsBuiltin.class,
    +                        TpSlotGroup.AS_SEQUENCE,
    +                        CFields.PySequenceMethods__sq_contains,
    +                        PExternalFunctionWrapper.OBJOBJPROC,
    +                        SqContainsWrapper::new),
             MP_LENGTH(
                             TpSlots::mp_length,
                             TpSlotPythonSingle.class,
    @@ -1078,6 +1090,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl
                             TpSlotDef.withoutHPy(T___DELITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.DELITEM));
             addSlotDef(s, TpSlotMeta.SQ_INPLACE_CONCAT, TpSlotDef.withNoFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC));
             addSlotDef(s, TpSlotMeta.SQ_INPLACE_REPEAT, TpSlotDef.withNoFunction(T___IMUL__, PExternalFunctionWrapper.SSIZE_ARG, HPySlotWrapper.INDEXARGFUNC));
    +        addSlotDef(s, TpSlotMeta.SQ_CONTAINS, TpSlotDef.withSimpleFunction(T___CONTAINS__, PExternalFunctionWrapper.OBJOBJPROC));
     
             SLOTDEFS = s;
             SPECIAL2SLOT = new HashMap<>(SLOTDEFS.size() * 2);
    @@ -1699,6 +1712,7 @@ public TpSlots build() {
                                 get(TpSlotMeta.SQ_REPEAT), //
                                 get(TpSlotMeta.SQ_INPLACE_CONCAT), //
                                 get(TpSlotMeta.SQ_INPLACE_REPEAT), //
    +                            get(TpSlotMeta.SQ_CONTAINS), //
                                 get(TpSlotMeta.MP_LENGTH), //
                                 get(TpSlotMeta.MP_SUBSCRIPT), //
                                 get(TpSlotMeta.MP_ASS_SUBSCRIPT), //
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
    new file mode 100644
    index 0000000000..b681257b97
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
    @@ -0,0 +1,148 @@
    +/*
    + * Copyright (c) 2025, 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.builtins.objects.type.slots;
    +
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__;
    +
    +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.CheckInquiryResultNode;
    +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode;
    +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming;
    +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode;
    +import com.oracle.graal.python.builtins.objects.function.PArguments;
    +import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.BinaryPythonSlotDispatcherNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotBinaryFuncBuiltin;
    +import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    +import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    +import com.oracle.graal.python.runtime.ExecutionContext.CallContext;
    +import com.oracle.graal.python.runtime.PythonContext;
    +import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode;
    +import com.oracle.graal.python.runtime.PythonContext.PythonThreadState;
    +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
    +import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateCached;
    +import com.oracle.truffle.api.dsl.GenerateInline;
    +import com.oracle.truffle.api.dsl.GenerateUncached;
    +import com.oracle.truffle.api.dsl.NodeFactory;
    +import com.oracle.truffle.api.dsl.Specialization;
    +import com.oracle.truffle.api.frame.VirtualFrame;
    +import com.oracle.truffle.api.nodes.IndirectCallNode;
    +import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedConditionProfile;
    +
    +public final class TpSlotSqContains {
    +    private TpSlotSqContains() {
    +    }
    +
    +    public abstract static class TpSlotSqContainsBuiltin extends TpSlotBinaryFuncBuiltin {
    +
    +        protected TpSlotSqContainsBuiltin(NodeFactory nodeFactory) {
    +            super(nodeFactory, PExternalFunctionWrapper.OBJOBJPROC, J___CONTAINS__);
    +        }
    +
    +        final SqContainsBuiltinNode createOpSlotNode() {
    +            return createNode();
    +        }
    +    }
    +
    +    @GenerateInline(value = false, inherit = true)
    +    public abstract static class SqContainsBuiltinNode extends PythonBinaryBuiltinNode {
    +        public abstract boolean executeBoolean(VirtualFrame frame, Object obj, Object value);
    +
    +        @Override
    +        public final Object execute(VirtualFrame frame, Object obj, Object value) {
    +            return executeBoolean(frame, obj, value);
    +        }
    +    }
    +
    +    @GenerateInline
    +    @GenerateCached(false)
    +    @GenerateUncached
    +    public abstract static class CallSlotSqContainsNode extends Node {
    +        private static final CApiTiming C_API_TIMING = CApiTiming.create(true, "sq_contains");
    +
    +        public abstract boolean execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object self, Object arg);
    +
    +        @Specialization(guards = "cachedSlot == slot", limit = "3")
    +        static boolean callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") TpSlotSqContainsBuiltin slot, Object self, Object arg,
    +                        @SuppressWarnings("unused") @Cached("slot") TpSlotSqContainsBuiltin cachedSlot,
    +                        @Cached("cachedSlot.createOpSlotNode()") SqContainsBuiltinNode slotNode) {
    +            return slotNode.executeBoolean(frame, self, arg);
    +        }
    +
    +        @Specialization
    +        static boolean callPython(VirtualFrame frame, Node inliningTarget, TpSlotPythonSingle slot, Object self, Object arg,
    +                        @Cached BinaryPythonSlotDispatcherNode dispatcherNode,
    +                        @Cached PyObjectIsTrueNode isTrueNode) {
    +            Object result = dispatcherNode.execute(frame, inliningTarget, slot.getCallable(), slot.getType(), self, arg);
    +            return isTrueNode.execute(frame, result);
    +        }
    +
    +        @Specialization
    +        static boolean callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, Object self, Object arg,
    +                        @Cached GetThreadStateNode getThreadStateNode,
    +                        @Cached(inline = false) PythonToNativeNode selfToNativeNode,
    +                        @Cached(inline = false) PythonToNativeNode argToNativeNode,
    +                        @Cached ExternalFunctionInvokeNode externalInvokeNode,
    +                        @Cached(inline = false) CheckInquiryResultNode checkResultNode) {
    +            PythonContext ctx = PythonContext.get(inliningTarget);
    +            PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx);
    +            Object result = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___CONTAINS__, slot.callable,
    +                            selfToNativeNode.execute(self), argToNativeNode.execute(arg));
    +            return checkResultNode.executeBool(state, T___CONTAINS__, result);
    +        }
    +
    +        @Specialization(replaces = "callCachedBuiltin")
    +        @InliningCutoff
    +        static boolean callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotBinaryFuncBuiltin slot, Object self, Object arg,
    +                        @Cached(inline = false) CallContext callContext,
    +                        @Cached InlinedConditionProfile isNullFrameProfile,
    +                        @Cached(inline = false) IndirectCallNode indirectCallNode) {
    +            Object[] arguments = PArguments.create(2);
    +            PArguments.setArgument(arguments, 0, self);
    +            PArguments.setArgument(arguments, 1, arg);
    +            return (boolean) BuiltinDispatchers.callGenericBuiltin(frame, inliningTarget, slot.callTargetIndex, arguments, callContext, isNullFrameProfile, indirectCallNode);
    +        }
    +    }
    +}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceContainsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceContainsNode.java
    index 0fa4539e05..7fd3e1120a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceContainsNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceContainsNode.java
    @@ -40,24 +40,20 @@
      */
     package com.oracle.graal.python.lib;
     
    -import com.oracle.graal.python.builtins.objects.PNone;
    -import com.oracle.graal.python.builtins.objects.PNotImplemented;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.CallSlotSqContainsNode;
     import com.oracle.graal.python.lib.PySequenceIterSearchNode.LazyPySequenceIterSeachNode;
    -import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.GenerateCached;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
    -import com.oracle.truffle.api.dsl.ImportStatic;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.Frame;
    +import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedConditionProfile;
     
     /**
      * Equivalent of CPython's {@code PySequence_Contains}.
    @@ -65,33 +61,21 @@
     @GenerateUncached
     @GenerateInline
     @GenerateCached(false)
    -@ImportStatic(SpecialMethodSlot.class)
    -public abstract class PySequenceContainsNode extends PNodeWithContext {
    -    public abstract boolean execute(Frame frame, Node inlining, Object container, Object key);
    +public abstract class PySequenceContainsNode extends Node {
    +    public abstract boolean execute(Frame frame, Node inliningTarget, Object container, Object key);
     
         @Specialization
    -    static boolean contains(Frame frame, Node inliningTarget, Object container, Object key,
    -                    @Cached GetClassNode getReceiverClass,
    -                    @Cached(parameters = "Contains", inline = false) LookupSpecialMethodSlotNode lookupContains,
    -                    @Cached IsBuiltinObjectProfile noContainsProfile,
    -                    @Cached(inline = false) CallBinaryMethodNode callContains,
    -                    @Cached LazyPySequenceIterSeachNode iterSearch,
    -                    @Cached PyObjectIsTrueNode isTrue) {
    -        Object type = getReceiverClass.execute(inliningTarget, container);
    -        Object contains = PNone.NO_VALUE;
    -        try {
    -            contains = lookupContains.execute(frame, type, container);
    -        } catch (PException e) {
    -            e.expectAttributeError(inliningTarget, noContainsProfile);
    -        }
    -        Object result = PNotImplemented.NOT_IMPLEMENTED;
    -        if (!(contains instanceof PNone)) {
    -            result = callContains.executeObject(frame, contains, container, key);
    -        }
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            return iterSearch.get(inliningTarget).executeCached(frame, container, key, PySequenceIterSearchNode.PY_ITERSEARCH_CONTAINS) == 1;
    +    static boolean contains(VirtualFrame frame, Node inliningTarget, Object container, Object key,
    +                    @Cached GetClassNode getClassNode,
    +                    @Cached GetCachedTpSlotsNode getSlots,
    +                    @Cached InlinedConditionProfile hasContains,
    +                    @Cached CallSlotSqContainsNode callSlot,
    +                    @Cached LazyPySequenceIterSeachNode iterSearch) {
    +        TpSlots slots = getSlots.execute(inliningTarget, getClassNode.execute(inliningTarget, container));
    +        if (hasContains.profile(inliningTarget, slots.sq_contains() != null)) {
    +            return callSlot.execute(frame, inliningTarget, slots.sq_contains(), container, key);
             } else {
    -            return isTrue.execute(frame, result);
    +            return iterSearch.get(inliningTarget).executeCached(frame, container, key, PySequenceIterSearchNode.PY_ITERSEARCH_CONTAINS) == 1;
             }
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/InNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/InNode.java
    new file mode 100644
    index 0000000000..2d928803f2
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/InNode.java
    @@ -0,0 +1,67 @@
    +/*
    + * Copyright (c) 2025, 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.bytecode;
    +
    +import com.oracle.graal.python.lib.PySequenceContainsNode;
    +import com.oracle.graal.python.nodes.expression.BinaryOpNode;
    +import com.oracle.truffle.api.dsl.Bind;
    +import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateInline;
    +import com.oracle.truffle.api.dsl.NeverDefault;
    +import com.oracle.truffle.api.dsl.Specialization;
    +import com.oracle.truffle.api.frame.VirtualFrame;
    +import com.oracle.truffle.api.nodes.Node;
    +
    +@GenerateInline(false)
    +abstract class InNode extends BinaryOpNode {
    +
    +    @Specialization
    +    Object contains(VirtualFrame frame, Object item, Object container,
    +                    @Bind Node inliningTarget,
    +                    @Cached PySequenceContainsNode containsNode) {
    +        return containsNode.execute(frame, inliningTarget, container, item);
    +    }
    +
    +    @NeverDefault
    +    public static InNode create() {
    +        return InNodeGen.create();
    +    }
    +}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    index d1fda4b40f..d48ed611de 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    @@ -194,7 +194,6 @@
     import com.oracle.graal.python.nodes.exception.ExceptMatchNodeGen;
     import com.oracle.graal.python.nodes.expression.BinaryComparisonNode;
     import com.oracle.graal.python.nodes.expression.BinaryOp;
    -import com.oracle.graal.python.nodes.expression.ContainsNode;
     import com.oracle.graal.python.nodes.expression.UnaryOpNode;
     import com.oracle.graal.python.nodes.frame.DeleteGlobalNode;
     import com.oracle.graal.python.nodes.frame.DeleteGlobalNodeGen;
    @@ -502,7 +501,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
                 case BinaryOpsConstants.IS:
                     return IsNode.create();
                 case BinaryOpsConstants.IN:
    -                return ContainsNode.create();
    +                return InNode.create();
                 default:
                     throw CompilerDirectives.shouldNotReachHere();
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ContainsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ContainsNode.java
    deleted file mode 100644
    index e8f75d827e..0000000000
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ContainsNode.java
    +++ /dev/null
    @@ -1,248 +0,0 @@
    -/*
    - * Copyright (c) 2019, 2025, 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.expression;
    -
    -import com.oracle.graal.python.builtins.objects.PNotImplemented;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    -import com.oracle.graal.python.lib.GetNextNode;
    -import com.oracle.graal.python.lib.PyObjectGetIter;
    -import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    -import com.oracle.graal.python.lib.PyObjectRichCompareBool;
    -import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.runtime.exception.PException;
    -import com.oracle.truffle.api.dsl.Bind;
    -import com.oracle.truffle.api.dsl.Cached;
    -import com.oracle.truffle.api.dsl.Cached.Shared;
    -import com.oracle.truffle.api.dsl.GenerateInline;
    -import com.oracle.truffle.api.dsl.NeverDefault;
    -import com.oracle.truffle.api.dsl.Specialization;
    -import com.oracle.truffle.api.frame.VirtualFrame;
    -import com.oracle.truffle.api.nodes.Node;
    -import com.oracle.truffle.api.nodes.UnexpectedResultException;
    -
    -@GenerateInline(false)
    -public abstract class ContainsNode extends BinaryOpNode {
    -    @NeverDefault
    -    public static ContainsNode create() {
    -        return ContainsNodeGen.create();
    -    }
    -
    -    @NeverDefault
    -    public static LookupAndCallBinaryNode createCallNode() {
    -        return LookupAndCallBinaryNode.create(SpecialMethodSlot.Contains);
    -    }
    -
    -    @Specialization(rewriteOn = UnexpectedResultException.class)
    -    public static boolean doBoolean(VirtualFrame frame, boolean item, Object iter,
    -                    @Bind("this") Node inliningTarget,
    -                    @Shared @Cached PyObjectIsTrueNode castBool,
    -                    @Shared("callNode") @Cached("createCallNode()") LookupAndCallBinaryNode callNode,
    -                    @Shared("errorProfile") @Cached IsBuiltinObjectProfile errorProfile,
    -                    @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                    @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                    @Shared("nextNode") @Cached GetNextNode nextNode) throws UnexpectedResultException {
    -        Object result = callNode.executeObject(frame, iter, item);
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            Object iterator = getIter.execute(frame, inliningTarget, iter);
    -            return sequenceContains(frame, iterator, item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        return castBool.execute(frame, result);
    -    }
    -
    -    @Specialization(rewriteOn = UnexpectedResultException.class)
    -    public static boolean doInt(VirtualFrame frame, int item, Object iter,
    -                    @Bind("this") Node inliningTarget,
    -                    @Shared @Cached PyObjectIsTrueNode castBool,
    -                    @Shared("callNode") @Cached("createCallNode()") LookupAndCallBinaryNode callNode,
    -                    @Shared("errorProfile") @Cached IsBuiltinObjectProfile errorProfile,
    -                    @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                    @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                    @Shared("nextNode") @Cached GetNextNode nextNode) throws UnexpectedResultException {
    -        Object result = callNode.executeObject(frame, iter, item);
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            return sequenceContains(frame, getIter.execute(frame, inliningTarget, iter), item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        return castBool.execute(frame, result);
    -    }
    -
    -    @Specialization(rewriteOn = UnexpectedResultException.class)
    -    public static boolean doLong(VirtualFrame frame, long item, Object iter,
    -                    @Bind("this") Node inliningTarget,
    -                    @Shared @Cached PyObjectIsTrueNode castBool,
    -                    @Shared("callNode") @Cached("createCallNode()") LookupAndCallBinaryNode callNode,
    -                    @Shared("errorProfile") @Cached IsBuiltinObjectProfile errorProfile,
    -                    @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                    @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                    @Shared("nextNode") @Cached GetNextNode nextNode) throws UnexpectedResultException {
    -        Object result = callNode.executeObject(frame, iter, item);
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            return sequenceContains(frame, getIter.execute(frame, inliningTarget, iter), item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        return castBool.execute(frame, result);
    -    }
    -
    -    @Specialization(rewriteOn = UnexpectedResultException.class)
    -    public static boolean doDouble(VirtualFrame frame, double item, Object iter,
    -                    @Bind("this") Node inliningTarget,
    -                    @Shared @Cached PyObjectIsTrueNode castBool,
    -                    @Shared("callNode") @Cached("createCallNode()") LookupAndCallBinaryNode callNode,
    -                    @Shared("errorProfile") @Cached IsBuiltinObjectProfile errorProfile,
    -                    @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                    @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                    @Shared("nextNode") @Cached GetNextNode nextNode) throws UnexpectedResultException {
    -        Object result = callNode.executeObject(frame, iter, item);
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            return sequenceContains(frame, getIter.execute(frame, inliningTarget, iter), item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        return castBool.execute(frame, result);
    -    }
    -
    -    @Specialization
    -    public static boolean doGeneric(VirtualFrame frame, Object item, Object iter,
    -                    @Bind("this") Node inliningTarget,
    -                    @Shared @Cached PyObjectIsTrueNode castBool,
    -                    @Shared("callNode") @Cached("createCallNode()") LookupAndCallBinaryNode callNode,
    -                    @Shared("errorProfile") @Cached IsBuiltinObjectProfile errorProfile,
    -                    @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                    @Shared("eqNode") @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                    @Shared("nextNode") @Cached GetNextNode nextNode) {
    -        Object result = callNode.executeObject(frame, iter, item);
    -        if (result == PNotImplemented.NOT_IMPLEMENTED) {
    -            return sequenceContainsObject(frame, getIter.execute(frame, inliningTarget, iter), item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        return castBool.execute(frame, result);
    -    }
    -
    -    private static void handleUnexpectedResult(VirtualFrame frame, Object iterator, Object item, UnexpectedResultException e, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -        // If we got an unexpected (non-primitive) result from the iterator, we need to compare it
    -        // and continue iterating with "next" through the generic case. However, we also want the
    -        // specialization to go away, so we wrap the boolean result in a new
    -        // UnexpectedResultException. This will cause the DSL to disable the specialization with the
    -        // primitive value and return the result we got, without iterating again.
    -        Object result = e.getResult();
    -        if (eqNode.compare(frame, inliningTarget, result, item)) {
    -            result = true;
    -        } else {
    -            result = sequenceContainsObject(frame, iterator, item, eqNode, nextNode, inliningTarget, errorProfile);
    -        }
    -        throw new UnexpectedResultException(result);
    -    }
    -
    -    private static boolean sequenceContains(VirtualFrame frame, Object iterator, boolean item, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -        while (true) {
    -            try {
    -                if (nextNode.executeBoolean(frame, iterator) == item) {
    -                    return true;
    -                }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile);
    -                return false;
    -            } catch (UnexpectedResultException e) {
    -                handleUnexpectedResult(frame, iterator, item, e, eqNode, nextNode, inliningTarget, errorProfile);
    -            }
    -        }
    -    }
    -
    -    private static boolean sequenceContains(VirtualFrame frame, Object iterator, int item, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -        while (true) {
    -            try {
    -                if (nextNode.executeInt(frame, iterator) == item) {
    -                    return true;
    -                }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile);
    -                return false;
    -            } catch (UnexpectedResultException e) {
    -                handleUnexpectedResult(frame, iterator, item, e, eqNode, nextNode, inliningTarget, errorProfile);
    -            }
    -        }
    -    }
    -
    -    private static boolean sequenceContains(VirtualFrame frame, Object iterator, long item, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -        while (true) {
    -            try {
    -                if (nextNode.executeLong(frame, iterator) == item) {
    -                    return true;
    -                }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile);
    -                return false;
    -            } catch (UnexpectedResultException e) {
    -                handleUnexpectedResult(frame, iterator, item, e, eqNode, nextNode, inliningTarget, errorProfile);
    -            }
    -        }
    -    }
    -
    -    private static boolean sequenceContains(VirtualFrame frame, Object iterator, double item, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -        while (true) {
    -            try {
    -                if (nextNode.executeDouble(frame, iterator) == item) {
    -                    return true;
    -                }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile);
    -                return false;
    -            } catch (UnexpectedResultException e) {
    -                handleUnexpectedResult(frame, iterator, item, e, eqNode, nextNode, inliningTarget, errorProfile);
    -            }
    -        }
    -    }
    -
    -    private static boolean sequenceContainsObject(VirtualFrame frame, Object iterator, Object item, PyObjectRichCompareBool.EqNode eqNode, GetNextNode nextNode,
    -                    Node inliningTarget, IsBuiltinObjectProfile errorProfile) {
    -        while (true) {
    -            try {
    -                if (eqNode.compare(frame, inliningTarget, nextNode.execute(frame, iterator), item)) {
    -                    return true;
    -                }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile);
    -                return false;
    -            }
    -        }
    -    }
    -}
    
    From 9cde923992423bb5e5283fa1112fd2a033833ecd Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 24 Feb 2025 15:57:13 +0100
    Subject: [PATCH 088/512] Fix error handling of sequence contains
    
    ---
     .../builtins/objects/type/slots/TpSlotSqContains.java  | 10 +++++++++-
     .../graal/python/lib/PySequenceIterSearchNode.java     |  2 +-
     .../com/oracle/graal/python/nodes/ErrorMessages.java   |  1 +
     3 files changed, 11 insertions(+), 2 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
    index b681257b97..fab02db996 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSqContains.java
    @@ -43,6 +43,8 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__;
     
    +import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    +import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.CheckInquiryResultNode;
     import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode;
     import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
    @@ -54,6 +56,8 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.TpSlotBinaryFuncBuiltin;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    +import com.oracle.graal.python.nodes.ErrorMessages;
    +import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.runtime.ExecutionContext.CallContext;
     import com.oracle.graal.python.runtime.PythonContext;
    @@ -114,7 +118,11 @@ static boolean callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused")
             @Specialization
             static boolean callPython(VirtualFrame frame, Node inliningTarget, TpSlotPythonSingle slot, Object self, Object arg,
                             @Cached BinaryPythonSlotDispatcherNode dispatcherNode,
    -                        @Cached PyObjectIsTrueNode isTrueNode) {
    +                        @Cached PyObjectIsTrueNode isTrueNode,
    +                        @Cached PRaiseNode raiseNode) {
    +            if (slot.getCallable() == PNone.NONE) {
    +                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_CONTAINER, self);
    +            }
                 Object result = dispatcherNode.execute(frame, inliningTarget, slot.getCallable(), slot.getType(), self, arg);
                 return isTrueNode.execute(frame, result);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    index b95177f102..9c28f84a7f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    @@ -104,7 +104,7 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key
                 iterator = getIter.execute(frame, inliningTarget, container);
             } catch (PException e) {
                 e.expectTypeError(inliningTarget, noIterProfile);
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.IS_NOT_A_CONTAINER, container);
    +            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARGUMENT_OF_TYPE_P_IS_NOT_ITERABLE, container);
             }
             Object next = PNone.NO_VALUE;
             try {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java
    index 3dc120280a..d1ad95d035 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java
    @@ -582,6 +582,7 @@ public abstract class ErrorMessages {
         public static final TruffleString OBJ_ISNT_MAPPING = tsLiteral("'%p' object is not a mapping");
         public static final TruffleString OBJ_ISNT_REVERSIBLE = tsLiteral("'%p' object is not reversible");
         public static final TruffleString OBJ_NOT_ITERABLE = tsLiteral("'%p' object is not iterable");
    +    public static final TruffleString ARGUMENT_OF_TYPE_P_IS_NOT_ITERABLE = tsLiteral("argument of type '%p' is not iterable");
         public static final TruffleString OBJ_NOT_SUBSCRIPTABLE = tsLiteral("'%p' object is not subscriptable");
         public static final TruffleString TYPE_NOT_SUBSCRIPTABLE = tsLiteral("type '%N' is not subscriptable");
         public static final TruffleString OBJ_OR_KLASS_ARGS_IS_NOT_HOST_OBJ = tsLiteral("the object '%p' or klass '%p' arguments is not a host object");
    
    From 7ef052a14fca206762b6ae4852e4bd7eafaa7f47 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 18 Feb 2025 10:42:58 +0100
    Subject: [PATCH 089/512] [GR-62558] Avoid calling PyObject_Dump on freed
     objects
    
    ---
     graalpython/com.oracle.graal.python.cext/src/object.c  |  5 +----
     .../modules/cext/PythonCextObjectBuiltins.java         | 10 ++++++++++
     .../builtins/objects/cext/capi/CApiFunction.java       |  1 -
     .../objects/cext/capi/transitions/ArgDescriptor.java   |  1 +
     .../objects/cext/capi/transitions/CApiTransitions.java |  2 +-
     5 files changed, 13 insertions(+), 6 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.cext/src/object.c b/graalpython/com.oracle.graal.python.cext/src/object.c
    index eb22c9e94d..2a920dbd41 100644
    --- a/graalpython/com.oracle.graal.python.cext/src/object.c
    +++ b/graalpython/com.oracle.graal.python.cext/src/object.c
    @@ -2394,7 +2394,6 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
         fprintf(stderr, "\n");
         fflush(stderr);
     
    -#if 0 // GraalPy change
         if (_PyObject_IsFreed(obj)) {
             /* It seems like the object memory has been freed:
                don't access it to prevent a segmentation fault. */
    @@ -2402,6 +2401,7 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
             fflush(stderr);
         }
         else {
    +#if 0 // GraalPy change
             /* Display the traceback where the object has been allocated.
                Do it before dumping repr(obj), since repr() is more likely
                to crash than dumping the traceback. */
    @@ -2418,14 +2418,11 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
     #endif // GraalPy change
             /* This might succeed or fail, but we're about to abort, so at least
                try to provide any extra info we can: */
    -        if (obj) // GraalPy change, guard call to _PyObject_Dump
             _PyObject_Dump(obj);
     
    -#if 0 // GraalPy change
             fprintf(stderr, "\n");
             fflush(stderr);
         }
    -#endif // GraalPy change
     
         Py_FatalError("_PyObject_AssertFailed");
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java
    index 06f7b89603..ac890864cd 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java
    @@ -49,6 +49,7 @@
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Pointer;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObject;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectConstPtr;
    +import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectRawPointer;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectTransfer;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyObjectWrapper;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PyThreadState;
    @@ -599,6 +600,15 @@ static PNone set(PSequence obj, long size,
             }
         }
     
    +    @CApiBuiltin(ret = Int, args = {PyObjectRawPointer}, call = Direct)
    +    abstract static class _PyObject_IsFreed extends CApiUnaryBuiltinNode {
    +        @Specialization
    +        int doGeneric(Object pointer,
    +                        @Cached ToPythonWrapperNode toPythonWrapperNode) {
    +            return toPythonWrapperNode.executeWrapper(pointer, false) == null ? 1 : 0;
    +        }
    +    }
    +
         @CApiBuiltin(ret = Void, args = {PyObjectWrapper}, call = Direct)
         abstract static class _PyObject_Dump extends CApiUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java
    index d71eb1b0f9..707446c4c1 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java
    @@ -1119,7 +1119,6 @@ public final class CApiFunction {
         @CApiBuiltin(name = "_PyObject_GetState", ret = PyObject, args = {PyObject}, call = NotImplemented)
         @CApiBuiltin(name = "_PyObject_HasLen", ret = Int, args = {PyObject}, call = NotImplemented)
         @CApiBuiltin(name = "_PyObject_IsAbstract", ret = Int, args = {PyObject}, call = NotImplemented)
    -    @CApiBuiltin(name = "_PyObject_IsFreed", ret = Int, args = {PyObject}, call = NotImplemented)
         @CApiBuiltin(name = "_PyObject_LookupSpecialId", ret = PyObject, args = {PyObject, PY_IDENTIFIER}, call = NotImplemented)
         @CApiBuiltin(name = "_PyObject_RealIsInstance", ret = Int, args = {PyObject, PyObject}, call = NotImplemented)
         @CApiBuiltin(name = "_PyObject_RealIsSubclass", ret = Int, args = {PyObject, PyObject}, call = NotImplemented)
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    index f64ce20174..ff02b92524 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    @@ -145,6 +145,7 @@ public enum ArgDescriptor {
         PyMethodObject(ArgBehavior.PyObject, "PyMethodObject*"),
         PyInstanceMethodObject(ArgBehavior.PyObject, "PyInstanceMethodObject*"),
         PyObjectTransfer(ArgBehavior.PyObject, "PyObject*", true),
    +    PyObjectRawPointer(ArgBehavior.Pointer, "PyObject*"),
         Pointer(ArgBehavior.Pointer, "void*"),
         Py_ssize_t(ArgBehavior.Int64, "Py_ssize_t"),
         Py_hash_t(ArgBehavior.Int64, "Py_hash_t"),
    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 3d811fd88d..dd291e4348 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
    @@ -1895,7 +1895,7 @@ static PythonNativeWrapper doGeneric(Node inliningTarget, long pointer, boolean
                     IdReference lookup = nativeLookupGet(nativeContext, pointer);
                     if (isNativeProfile.profile(inliningTarget, lookup != null)) {
                         Object ref = lookup.get();
    -                    if (ref == null) {
    +                    if (strict && ref == null) {
                             CompilerDirectives.transferToInterpreterAndInvalidate();
                             throw CompilerDirectives.shouldNotReachHere("reference was collected: " + Long.toHexString(pointer));
                         }
    
    From 20f59830ebd5974fb3863a88979dd3eba37bd66c Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 18 Feb 2025 14:27:37 +0100
    Subject: [PATCH 090/512] Print a backtrace on assertion failure in C API
    
    ---
     .../com.oracle.graal.python.cext/src/object.c   | 17 +++++++++++++++++
     1 file changed, 17 insertions(+)
    
    diff --git a/graalpython/com.oracle.graal.python.cext/src/object.c b/graalpython/com.oracle.graal.python.cext/src/object.c
    index 2a920dbd41..d1a6a7642e 100644
    --- a/graalpython/com.oracle.graal.python.cext/src/object.c
    +++ b/graalpython/com.oracle.graal.python.cext/src/object.c
    @@ -2369,6 +2369,15 @@ _PyTrash_cond(PyObject *op, destructor dealloc)
         return Py_TYPE(op)->tp_dealloc == dealloc;
     }
     
    +// Begin GraalPy change
    +#if ((__linux__ && __GNU_LIBRARY__) || __APPLE__)
    +#include 
    +static void bt() {
    +    void* stack[8];
    +    backtrace_symbols_fd(stack, backtrace(stack, 8), stderr);
    +}
    +#endif
    +// End GraalPy change
     
     void _Py_NO_RETURN
     _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
    @@ -2394,6 +2403,14 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
         fprintf(stderr, "\n");
         fflush(stderr);
     
    +    // Begin GraalPy change
    +#if ((__linux__ && __GNU_LIBRARY__) || __APPLE__)
    +    fprintf(stderr, "Native backtrace:\n");
    +    bt();
    +    fflush(stderr);
    +#endif
    +    // End GraalPy change
    +
         if (_PyObject_IsFreed(obj)) {
             /* It seems like the object memory has been freed:
                don't access it to prevent a segmentation fault. */
    
    From 8402c60c26a513570eeab653e76af7cd519aec6b Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Wed, 19 Feb 2025 09:16:58 +0100
    Subject: [PATCH 091/512] Fix name of __signature__ constant
    
    ---
     .../builtins/objects/function/BuiltinFunctionBuiltins.java    | 4 ++--
     .../objects/method/BuiltinFunctionOrMethodBuiltins.java       | 4 ++--
     .../com/oracle/graal/python/nodes/SpecialAttributeNames.java  | 2 +-
     3 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java
    index 80081e8bea..8aa39bc6d5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinFunctionBuiltins.java
    @@ -31,7 +31,7 @@
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___NAME__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___QUALNAME__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___SIGNATURE__;
    -import static com.oracle.graal.python.nodes.SpecialAttributeNames.T__SIGNATURE__;
    +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___SIGNATURE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___OBJCLASS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode.T_DOLLAR_DECL_TYPE;
    @@ -148,7 +148,7 @@ public abstract static class SignatureNode extends PythonUnaryBuiltinNode {
             static Object doIt(PBuiltinFunction fun,
                             @Bind("this") Node inliningTarget) {
                 if (fun.getSignature().isHidden()) {
    -                throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__);
    +                throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T___SIGNATURE__);
                 }
                 return createInspectSignature(fun.getSignature(), false);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java
    index 5aef32c3ca..25b01edc31 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java
    @@ -42,7 +42,7 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.AttributeError;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___SIGNATURE__;
    -import static com.oracle.graal.python.nodes.SpecialAttributeNames.T__SIGNATURE__;
    +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___SIGNATURE__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     
    @@ -152,7 +152,7 @@ public Object doIt(Object fun,
                             @Bind("this") Node inliningTarget) {
                 Signature signature = GetSignatureNode.executeUncached(fun);
                 if (signature.isHidden()) {
    -                throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T__SIGNATURE__);
    +                throw PRaiseNode.raiseStatic(inliningTarget, AttributeError, ErrorMessages.HAS_NO_ATTR, fun, T___SIGNATURE__);
                 }
                 return BuiltinFunctionBuiltins.SignatureNode.createInspectSignature(signature, true);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    index 9b53e57fc4..8e8def054e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    @@ -120,7 +120,7 @@ public abstract class SpecialAttributeNames {
         public static final TruffleString T___TEXT_SIGNATURE__ = tsLiteral(J___TEXT_SIGNATURE__);
     
         public static final String J___SIGNATURE__ = "__signature__";
    -    public static final TruffleString T__SIGNATURE__ = tsLiteral(J___SIGNATURE__);
    +    public static final TruffleString T___SIGNATURE__ = tsLiteral(J___SIGNATURE__);
     
         public static final String J___TRACEBACK__ = "__traceback__";
         public static final TruffleString T___TRACEBACK__ = tsLiteral(J___TRACEBACK__);
    
    From 6d6fb9eff1a76ea87e56a5cf73974222a91705e5 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Wed, 19 Feb 2025 09:28:08 +0100
    Subject: [PATCH 092/512] Expose __name__ on foreign executables
    
    ---
     .../foreign/ForeignExecutableBuiltins.java    | 32 +++++++++++++++++--
     1 file changed, 29 insertions(+), 3 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    index 5b7b7ecc96..fa9c5ec381 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    @@ -26,6 +26,8 @@
     
     package com.oracle.graal.python.builtins.objects.foreign;
     
    +import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___NAME__;
    +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__;
     
     import java.util.List;
    @@ -39,12 +41,12 @@
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
    +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode;
     import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext;
     import com.oracle.graal.python.runtime.GilNode;
     import com.oracle.graal.python.runtime.IndirectCallData;
     import com.oracle.graal.python.runtime.PythonContext;
    -import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -54,6 +56,7 @@
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.interop.ArityException;
     import com.oracle.truffle.api.interop.InteropLibrary;
    +import com.oracle.truffle.api.interop.UnknownIdentifierException;
     import com.oracle.truffle.api.interop.UnsupportedMessageException;
     import com.oracle.truffle.api.interop.UnsupportedTypeException;
     import com.oracle.truffle.api.library.CachedLibrary;
    @@ -66,12 +69,35 @@ protected List> getNodeFa
             return ForeignExecutableBuiltinsFactory.getFactories();
         }
     
    +    @Builtin(name = J___NAME__, minNumOfPositionalArgs = 1, isGetter = true)
    +    @GenerateNodeFactory
    +    public abstract static class NameNode extends PythonUnaryBuiltinNode {
    +        @Specialization
    +        static Object getName(Object self,
    +                        @Bind("this") Node inliningTarget,
    +                        @Cached PRaiseNode raiseNode,
    +                        @Cached PForeignToPTypeNode toPythonNode,
    +                        @CachedLibrary(limit = "2") InteropLibrary lib) {
    +            try {
    +                if (lib.isMemberReadable(self, J___NAME__)) {
    +                    return toPythonNode.executeConvert(lib.readMember(self, J___NAME__));
    +                } else if (lib.hasExecutableName(self)) {
    +                    return toPythonNode.executeConvert(lib.getExecutableName(self));
    +                } else {
    +                    throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, self, T___NAME__);
    +                }
    +            } catch (UnsupportedMessageException | UnknownIdentifierException e) {
    +                throw CompilerDirectives.shouldNotReachHere(e);
    +            }
    +        }
    +    }
    +
         @Builtin(name = J___CALL__, minNumOfPositionalArgs = 1, takesVarArgs = true)
         @GenerateNodeFactory
         public abstract static class CallNode extends PythonBuiltinNode {
             @Specialization
             static Object doInteropCall(VirtualFrame frame, Object callee, Object[] arguments,
    -                        @SuppressWarnings("unused") @Bind("this") Node inliningTarget,
    +                        @Bind("this") Node inliningTarget,
                             @Cached("createFor(this)") IndirectCallData indirectCallData,
                             @CachedLibrary(limit = "4") InteropLibrary lib,
                             @Cached PForeignToPTypeNode toPTypeNode,
    @@ -89,7 +115,7 @@ static Object doInteropCall(VirtualFrame frame, Object callee, Object[] argument
                         IndirectCallContext.exit(frame, language, context, state);
                     }
                 } catch (ArityException | UnsupportedTypeException e) {
    -                throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ);
    +                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.INVALID_INSTANTIATION_OF_FOREIGN_OBJ);
                 } catch (UnsupportedMessageException e) {
                     throw CompilerDirectives.shouldNotReachHere(e);
                 }
    
    From 15a25211df13fc91b708703348f091798e32d68b Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Wed, 19 Feb 2025 14:59:26 +0100
    Subject: [PATCH 093/512] Explicitly forward the __doc__ property to the
     foreign side, otherwise the foreign type's __doc__ takes precendence
    
    ---
     .../foreign/ForeignExecutableBuiltins.java    | 23 +++++++++++++++++++
     1 file changed, 23 insertions(+)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    index fa9c5ec381..cc32d4b035 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignExecutableBuiltins.java
    @@ -26,6 +26,7 @@
     
     package com.oracle.graal.python.builtins.objects.foreign;
     
    +import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___DOC__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___NAME__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__;
    @@ -37,6 +38,7 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    +import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -92,6 +94,27 @@ static Object getName(Object self,
             }
         }
     
    +    @Builtin(name = J___DOC__, minNumOfPositionalArgs = 1, isGetter = true)
    +    @GenerateNodeFactory
    +    public abstract static class DocNode extends PythonUnaryBuiltinNode {
    +        @Specialization
    +        static Object getName(Object self,
    +                        @Bind("this") Node inliningTarget,
    +                        @Cached PRaiseNode raiseNode,
    +                        @Cached PForeignToPTypeNode toPythonNode,
    +                        @CachedLibrary(limit = "2") InteropLibrary lib) {
    +            if (lib.isMemberReadable(self, J___DOC__)) {
    +                try {
    +                    return toPythonNode.executeConvert(lib.readMember(self, J___DOC__));
    +                } catch (UnsupportedMessageException | UnknownIdentifierException e) {
    +                    throw CompilerDirectives.shouldNotReachHere(e);
    +                }
    +            } else {
    +                return PNone.NONE;
    +            }
    +        }
    +    }
    +
         @Builtin(name = J___CALL__, minNumOfPositionalArgs = 1, takesVarArgs = true)
         @GenerateNodeFactory
         public abstract static class CallNode extends PythonBuiltinNode {
    
    From 1d9054ce5415add8495fa39095d788d655e34c26 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Wed, 19 Feb 2025 09:28:29 +0100
    Subject: [PATCH 094/512] Treat foreign executables as builtins which allows
     them to have `__text_signature__`
    
    ---
     CHANGELOG.md                                  |  1 +
     .../integration/interop/JavaInteropTest.java  | 40 +++++++++++++++++++
     graalpython/lib-python/3/inspect.py           |  3 ++
     3 files changed, 44 insertions(+)
    
    diff --git a/CHANGELOG.md b/CHANGELOG.md
    index a892ba0b0d..24c16bad89 100644
    --- a/CHANGELOG.md
    +++ b/CHANGELOG.md
    @@ -5,6 +5,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
     
     ## Version 25.0.0
     * `dir(foreign_object)` now returns both foreign methods and Python methods (it used to return only foreign methods).
    +* Support `__name__`, `__doc__`, `__text_signature__` fields on foreign executables to serve as their proper counterparts on the Python side. This is useful to, for example, use Java functional interfaces in lieu of Python functions for things like LangChain's `@tool` annotation that want to inspect the underlying function.
     
     ## Version 24.2.0
     * Updated developer metadata of Maven artifacts.
    diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    index 68a56f6086..3b4a812c56 100644
    --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    @@ -839,6 +839,46 @@ class Bar(Foo):
                 assertEquals(object.getMetaSimpleName(), "object");
                 assertFalse(object.hasMetaParents());
             }
    +
    +        public static class MyFunction implements java.util.function.Function {
    +            public String __text_signature__ = "(string) -> str";
    +
    +            @Override
    +            public String apply(String s) {
    +                return s;
    +            }
    +        }
    +
    +        public static class MyFunctionWithCustomName implements java.util.function.Function {
    +            public String __text_signature__ = "(string) -> str";
    +            public String __name__ = "myfunc";
    +
    +            @Override
    +            public String apply(String s) {
    +                return s;
    +            }
    +        }
    +
    +        public static class MyFunctionWithIncorrectSignature implements java.util.function.Function {
    +            public String __text_signature__ = "[I;java.lang.String;";
    +
    +            @Override
    +            public String apply(String s) {
    +                return s;
    +            }
    +        }
    +
    +        @Test
    +        public void javaExecutablesAsPythonFunctions() throws IOException {
    +            Value inspectSignature = context.eval("python", "import inspect; inspect.signature");
    +            assertEquals("", inspectSignature.execute(new MyFunction()).toString());
    +
    +            Value signature = context.eval("python", "lambda f: f.__text_signature__");
    +            assertEquals(new MyFunctionWithIncorrectSignature().__text_signature__, signature.execute(new MyFunctionWithIncorrectSignature()).asString());
    +
    +            Value name = context.eval("python", "lambda f: f.__name__");
    +            assertEquals(new MyFunctionWithCustomName().__name__, name.execute(new MyFunctionWithCustomName()).asString());
    +        }
         }
     
         @RunWith(Parameterized.class)
    diff --git a/graalpython/lib-python/3/inspect.py b/graalpython/lib-python/3/inspect.py
    index 655b04b0ee..c7533f3b34 100644
    --- a/graalpython/lib-python/3/inspect.py
    +++ b/graalpython/lib-python/3/inspect.py
    @@ -2069,6 +2069,9 @@ def _signature_is_builtin(obj):
         return (isbuiltin(obj) or
                 ismethoddescriptor(obj) or
                 isinstance(obj, _NonUserDefinedCallables) or
    +            # Truffle change: treat foreign executables as builtin
    +            (isinstance(obj, __graalpython__.ForeignType) and callable(obj)) or
    +            # End Truffle change
                 # Can't test 'isinstance(type)' here, as it would
                 # also be True for regular python classes
                 obj in (type, object))
    
    From e0322839080a74141270a3f877cb28ad89897198 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 25 Feb 2025 10:35:26 +0100
    Subject: [PATCH 095/512] [GR-62557] Add patch for jq to recythonize the C
     code.
    
    ---
     .../lib-graalpython/patches/jq-1.8.0.patch    | 59 +++++++++++++++++++
     .../lib-graalpython/patches/metadata.toml     |  9 +++
     2 files changed, 68 insertions(+)
     create mode 100644 graalpython/lib-graalpython/patches/jq-1.8.0.patch
    
    diff --git a/graalpython/lib-graalpython/patches/jq-1.8.0.patch b/graalpython/lib-graalpython/patches/jq-1.8.0.patch
    new file mode 100644
    index 0000000000..c62c51759a
    --- /dev/null
    +++ b/graalpython/lib-graalpython/patches/jq-1.8.0.patch
    @@ -0,0 +1,59 @@
    +--- a/pyproject.toml
    ++++ b/pyproject.toml
    +@@ -2,13 +2,10 @@
    + requires = [
    +     "setuptools>=43",
    +     "wheel",
    ++    "Cython==3.0.10",
    + ]
    + build-backend = "setuptools.build_meta"
    + 
    + [tool.cibuildwheel]
    +-before-build = [
    +-    "pip install cython==3.0.10",
    +-    "cython {project}/jq.pyx",
    +-]
    + test-requires = "-r test-requirements.txt"
    + test-command = "pytest {project}/tests"
    +diff --git a/setup.py b/setup.py
    +index 0b97097..54ed7b3 100644
    +--- a/setup.py
    ++++ b/setup.py
    +@@ -94,15 +94,27 @@ else:
    +         os.path.join(jq_lib_dir, "modules/oniguruma/src/.libs/libonig.a"),
    +     ]
    + 
    ++
    ++try:
    ++    # Follow recommendation from https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
    ++    from Cython.Build import cythonize
    ++except ImportError:
    ++    cythonize = lambda o: o
    ++    ext = ".c"
    ++else:
    ++    ext = ".pyx"
    ++
    ++
    + jq_extension = Extension(
    +     "jq",
    +-    sources=["jq.c"],
    ++    sources=[_path_in_dir(f"jq{ext}")],
    +     define_macros=[("MS_WIN64" , 1)] if os.name == "nt" and sys.maxsize > 2**32  else None, # https://github.com/cython/cython/issues/2670
    +     include_dirs=[os.path.join(jq_lib_dir, "src")],
    +     extra_link_args=["-lm"] + (["-Wl,-Bstatic", "-lpthread", "-lshlwapi", "-static-libgcc"] if os.name == 'nt' else []) + link_args_deps,
    +     extra_objects=extra_objects,
    + )
    + 
    ++
    + setup(
    +     name='jq',
    +     version='1.8.0',
    +@@ -112,7 +124,7 @@ setup(
    +     url='https://github.com/mwilliamson/jq.py',
    +     python_requires='>=3.6',
    +     license='BSD 2-Clause',
    +-    ext_modules = [jq_extension],
    ++    ext_modules = cythonize([jq_extension]),
    +     cmdclass={"build_ext": jq_build_ext},
    +     classifiers=[
    +         'Development Status :: 5 - Production/Stable',
    diff --git a/graalpython/lib-graalpython/patches/metadata.toml b/graalpython/lib-graalpython/patches/metadata.toml
    index 7356d3a129..1f3a11255e 100644
    --- a/graalpython/lib-graalpython/patches/metadata.toml
    +++ b/graalpython/lib-graalpython/patches/metadata.toml
    @@ -200,6 +200,15 @@ version = '<=1.3.2'
     patch = 'joblib-1.3.2.patch'
     license = 'BSD-3-Clause'
     
    +[[jq.rules]]
    +version = '==1.8.0'
    +patch = 'jq-1.8.0.patch'
    +license = 'BSD-2-Clause'
    +
    +[[jq.add-sources]]
    +version = '1.8.0'
    +url = 'https://github.com/mwilliamson/jq.py/archive/refs/tags/1.8.0.tar.gz'
    +
     [[jupyter_server.rules]]
     patch = 'jupyter_server.patch'
     license = 'BSD-3-Clause'
    
    From 800c7f0e3a418bc0b39acff63555b40e9f9d2b0a Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 25 Feb 2025 15:03:47 +0100
    Subject: [PATCH 096/512] Add pandas 2.2.3 patch
    
    ---
     .../lib-graalpython/patches/metadata.toml     |  6 +++
     .../patches/pandas-2.2.3.patch                | 52 +++++++++++++++++++
     2 files changed, 58 insertions(+)
     create mode 100644 graalpython/lib-graalpython/patches/pandas-2.2.3.patch
    
    diff --git a/graalpython/lib-graalpython/patches/metadata.toml b/graalpython/lib-graalpython/patches/metadata.toml
    index 1f3a11255e..55e95f5619 100644
    --- a/graalpython/lib-graalpython/patches/metadata.toml
    +++ b/graalpython/lib-graalpython/patches/metadata.toml
    @@ -367,6 +367,12 @@ patch = 'pandas-2.2.2.patch'
     license = 'BSD-3-Clause'
     dist-type = 'sdist'
     
    +[[pandas.rules]]
    +version = '== 2.2.3'
    +patch = 'pandas-2.2.3.patch'
    +license = 'BSD-3-Clause'
    +dist-type = 'sdist'
    +
     [[pandas.rules]]
     version = '== 2.0.3'
     patch = 'pandas-2.0.3.patch'
    diff --git a/graalpython/lib-graalpython/patches/pandas-2.2.3.patch b/graalpython/lib-graalpython/patches/pandas-2.2.3.patch
    new file mode 100644
    index 0000000000..1312dfbb7d
    --- /dev/null
    +++ b/graalpython/lib-graalpython/patches/pandas-2.2.3.patch
    @@ -0,0 +1,52 @@
    +diff --git a/pandas/_libs/include/pandas/vendored/klib/khash_python.h b/pandas/_libs/include/pandas/vendored/klib/khash_python.h
    +index 5a933b4..f579fc6 100644
    +--- a/pandas/_libs/include/pandas/vendored/klib/khash_python.h
    ++++ b/pandas/_libs/include/pandas/vendored/klib/khash_python.h
    +@@ -173,13 +173,15 @@ static inline int floatobject_cmp(PyFloatObject *a, PyFloatObject *b) {
    + // PyObject_RichCompareBool for complexobjects has a different behavior
    + // needs to be replaced
    + static inline int complexobject_cmp(PyComplexObject *a, PyComplexObject *b) {
    +-  return (Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
    +-          Py_IS_NAN(a->cval.imag) && Py_IS_NAN(b->cval.imag)) ||
    +-         (Py_IS_NAN(a->cval.real) && Py_IS_NAN(b->cval.real) &&
    +-          a->cval.imag == b->cval.imag) ||
    +-         (a->cval.real == b->cval.real && Py_IS_NAN(a->cval.imag) &&
    +-          Py_IS_NAN(b->cval.imag)) ||
    +-         (a->cval.real == b->cval.real && a->cval.imag == b->cval.imag);
    ++  Py_complex a_cval = PyComplex_AsCComplex((PyObject*)a);
    ++  Py_complex b_cval = PyComplex_AsCComplex((PyObject*)b);
    ++  return (Py_IS_NAN(a_cval.real) && Py_IS_NAN(b_cval.real) &&
    ++          Py_IS_NAN(a_cval.imag) && Py_IS_NAN(b_cval.imag)) ||
    ++         (Py_IS_NAN(a_cval.real) && Py_IS_NAN(b_cval.real) &&
    ++          a_cval.imag == b_cval.imag) ||
    ++         (a_cval.real == b_cval.real && Py_IS_NAN(a_cval.imag) &&
    ++          Py_IS_NAN(b_cval.imag)) ||
    ++         (a_cval.real == b_cval.real && a_cval.imag == b_cval.imag);
    + }
    + 
    + static inline int pyobject_cmp(PyObject *a, PyObject *b);
    +@@ -250,8 +252,9 @@ static inline Py_hash_t floatobject_hash(PyFloatObject *key) {
    + 
    + // replaces _Py_HashDouble with _Pandas_HashDouble
    + static inline Py_hash_t complexobject_hash(PyComplexObject *key) {
    +-  Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(key->cval.real);
    +-  Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(key->cval.imag);
    ++  Py_complex cval = PyComplex_AsCComplex((PyObject*)key);
    ++  Py_uhash_t realhash = (Py_uhash_t)_Pandas_HashDouble(cval.real);
    ++  Py_uhash_t imaghash = (Py_uhash_t)_Pandas_HashDouble(cval.imag);
    +   if (realhash == (Py_uhash_t)-1 || imaghash == (Py_uhash_t)-1) {
    +     return -1;
    +   }
    +diff --git a/pyproject.toml b/pyproject.toml
    +index db9f055..c191232 100644
    +--- a/pyproject.toml
    ++++ b/pyproject.toml
    +@@ -5,7 +5,7 @@ requires = [
    +     "meson-python==0.13.1",
    +     "meson==1.2.1",
    +     "wheel",
    +-    "Cython~=3.0.5",  # Note: sync with setup.py, environment.yml and asv.conf.json
    ++    "Cython==3.0.10",  # Note: sync with setup.py, environment.yml and asv.conf.json
    +     # Force numpy higher than 2.0, so that built wheels are compatible
    +     # with both numpy 1 and 2
    +     "numpy>=2.0",
    
    From 4af8cfdfd9e8267fb47d311e4663ee1768cd2554 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 25 Feb 2025 15:52:10 +0100
    Subject: [PATCH 097/512] Fix style checks
    
    ---
     .../python/test/integration/interop/JavaInteropTest.java      | 4 ++--
     .../builtins/objects/cext/capi/transitions/ArgDescriptor.java | 2 +-
     .../src/com/oracle/graal/python/nodes/BuiltinNames.java       | 2 +-
     .../com/oracle/graal/python/nodes/SpecialAttributeNames.java  | 2 +-
     .../src/com/oracle/graal/python/nodes/SpecialMethodNames.java | 2 +-
     5 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    index 3b4a812c56..d78d531adb 100644
    --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/interop/JavaInteropTest.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2017, 2025, 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
    @@ -869,7 +869,7 @@ public String apply(String s) {
             }
     
             @Test
    -        public void javaExecutablesAsPythonFunctions() throws IOException {
    +        public void javaExecutablesAsPythonFunctions() {
                 Value inspectSignature = context.eval("python", "import inspect; inspect.signature");
                 assertEquals("", inspectSignature.execute(new MyFunction()).toString());
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    index ff02b92524..7a69c5c57e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2022, 2025, 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
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/BuiltinNames.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/BuiltinNames.java
    index 2f69d1e336..57d3cbb19d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/BuiltinNames.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/BuiltinNames.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2025, 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
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    index 8e8def054e..c3c378ce98 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialAttributeNames.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2025, 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
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialMethodNames.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialMethodNames.java
    index 33a6a74639..14f7819dfd 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialMethodNames.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/SpecialMethodNames.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2025, 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
    
    From 2d5adad3921a9b281168967769c9a765620425d9 Mon Sep 17 00:00:00 2001
    From: stepan 
    Date: Thu, 27 Feb 2025 13:36:23 +0100
    Subject: [PATCH 098/512] Update imports
    
    ---
     ci.jsonnet              | 2 +-
     mx.graalpython/suite.py | 8 ++++----
     2 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/ci.jsonnet b/ci.jsonnet
    index 5480f56ead..21600f27e4 100644
    --- a/ci.jsonnet
    +++ b/ci.jsonnet
    @@ -1 +1 @@
    -{ "overlay": "9682e88c454813f57f9104b481421538895239b5" }
    +{ "overlay": "8dd41b33e90f2176621893827fb1431b82c865b3" }
    diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py
    index ebdc42a3e9..8bc1dc2ff4 100644
    --- a/mx.graalpython/suite.py
    +++ b/mx.graalpython/suite.py
    @@ -45,7 +45,7 @@
                 },
                 {
                     "name": "sdk",
    -                "version": "f3b5ff623b69e2904057365ebb934dc567e48e76",
    +                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -53,7 +53,7 @@
                 },
                 {
                     "name": "tools",
    -                "version": "f3b5ff623b69e2904057365ebb934dc567e48e76",
    +                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -61,7 +61,7 @@
                 },
                 {
                     "name": "sulong",
    -                "version": "f3b5ff623b69e2904057365ebb934dc567e48e76",
    +                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -69,7 +69,7 @@
                 },
                 {
                     "name": "regex",
    -                "version": "f3b5ff623b69e2904057365ebb934dc567e48e76",
    +                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    
    From 4583133c4ed4010e1093318a8002454dbff464f1 Mon Sep 17 00:00:00 2001
    From: stepan 
    Date: Thu, 27 Feb 2025 20:45:47 +0100
    Subject: [PATCH 099/512] Update test tags
    
    ---
     .../src/tests/unittest_tags/test_asyncio.txt  |   1 +
     .../src/tests/unittest_tags/test_capi.txt     |   2 +
     .../src/tests/unittest_tags/test_descr.txt    |   1 +
     .../src/tests/unittest_tags/test_getpass.txt  |   2 +
     .../test_multiprocessing_spawn.txt            |   1 +
     .../src/tests/unittest_tags/test_tarfile.txt  | 356 +++++++++---------
     .../src/tests/unittest_tags/test_weakref.txt  |   1 +
     7 files changed, 186 insertions(+), 178 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    index ecc93e08b7..8922fe3259 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    @@ -620,6 +620,7 @@ test.test_asyncio.test_ssl.TestSSL.test_create_server_ssl_1 @ darwin-arm64,darwi
     test.test_asyncio.test_ssl.TestSSL.test_create_server_ssl_over_ssl @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_flush_before_shutdown @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_shutdown_cleanly @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_asyncio.test_ssl.TestSSL.test_shutdown_timeout_handler_leak @ darwin-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_shutdown_timeout_handler_not_set @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_ssl_connect_accepted_socket @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_ssl_handshake_connection_lost @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    index ee94af6946..215d6591c4 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    @@ -79,6 +79,7 @@ test.test_capi.test_misc.CAPITest.test_heaptype_with_dict @ darwin-arm64,darwin-
     test.test_capi.test_misc.CAPITest.test_heaptype_with_negative_dict @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.CAPITest.test_heaptype_with_setattro @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.CAPITest.test_instancemethod @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.CAPITest.test_mapping_has_key @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.CAPITest.test_mapping_keys_values_items @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.CAPITest.test_mapping_keys_values_items_bad_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.CAPITest.test_memoryview_from_NULL_pointer @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    @@ -125,6 +126,7 @@ test.test_capi.test_misc.Test_testcapi.test_long_as_unsigned_long_long_mask @ da
     test.test_capi.test_misc.Test_testcapi.test_long_long_and_overflow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_testcapi.test_long_numbits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_testcapi.test_longlong_api @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.Test_testcapi.test_mapping_has_key_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_testcapi.test_py_is_funcs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_testcapi.test_py_is_macros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_testcapi.test_pymem_alloc0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt
    index 8f3b9670b8..308ca8ce85 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt
    @@ -34,6 +34,7 @@ test.test_descr.ClassPropertiesAndMethods.test_hash_inheritance @ darwin-arm64,d
     test.test_descr.ClassPropertiesAndMethods.test_imul_bug @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_descr.ClassPropertiesAndMethods.test_init @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_descr.ClassPropertiesAndMethods.test_ipow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_descr.ClassPropertiesAndMethods.test_ipow_exception_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_descr.ClassPropertiesAndMethods.test_ipow_returns_not_implemented @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_descr.ClassPropertiesAndMethods.test_isinst_isclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_descr.ClassPropertiesAndMethods.test_keyword_arguments @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_getpass.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_getpass.txt
    index 5f849f2bbf..582a4ea880 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_getpass.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_getpass.txt
    @@ -7,6 +7,8 @@ test.test_getpass.GetpassRawinputTest.test_trims_trailing_newline @ darwin-arm64
     test.test_getpass.GetpassRawinputTest.test_uses_stderr_as_default @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_getpass.GetpassRawinputTest.test_uses_stdin_as_default_input @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_getpass.GetpassRawinputTest.test_uses_stdin_as_different_locale @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_getpass.UnixGetpassTest.test_falls_back_to_fallback_if_termios_raises @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_getpass.UnixGetpassTest.test_falls_back_to_stdin @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_getpass.UnixGetpassTest.test_flushes_stream_after_input @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_getpass.UnixGetpassTest.test_resets_termios @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_getpass.UnixGetpassTest.test_uses_tty_directly @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    index 544fab8935..39b9d514f7 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    @@ -199,6 +199,7 @@ test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_chunks
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_no_failfast @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap_async @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_terminate @ darwin-arm64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_traceback @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_active_children @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_args_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    index 10a7620240..1e452d8705 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    @@ -253,7 +253,7 @@ test.test_tarfile.GzipWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_
     test.test_tarfile.GzipWriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.GzipWriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.GzipWriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.GzipWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.GzipWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.GzipWriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.GzipWriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.GzipWriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    @@ -261,12 +261,12 @@ test.test_tarfile.GzipWriteTest.test_tar_size @ darwin-arm64,darwin-x86_64,linux
     test.test_tarfile.HardlinkTest.test_add_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.HardlinkTest.test_add_twice @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.HardlinkTest.test_dereference_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LimitsTest.test_gnu_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LimitsTest.test_pax_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LimitsTest.test_ustar_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaAppendTest.test_append_compressed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LimitsTest.test_gnu_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LimitsTest.test_pax_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LimitsTest.test_ustar_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaAppendTest.test_append_compressed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaCreateTest.test_create @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaCreateTest.test_create_existing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaCreateTest.test_create_existing_taropen @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    @@ -274,206 +274,206 @@ test.test_tarfile.LzmaCreateTest.test_create_pathlike_name @ darwin-arm64,darwin
     test.test_tarfile.LzmaCreateTest.test_create_taropen @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaCreateTest.test_create_taropen_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaCreateTest.test_create_with_preset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaMiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaMiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaMiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaMiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaStreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaStreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaUstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaWriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaWriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaWriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaWriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.LzmaWriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.LzmaWriteTest.test_tar_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.MiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.MiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.MiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.MiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.MiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.NoneInfoTests_Misc.test_add @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.NumericOwnerTest.test_extract_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.NumericOwnerTest.test_extractall_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.NumericOwnerTest.test_keyword_only @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.PaxReadTest.test_longname_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.StreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    index 5e7ea67812..8e2191e2f0 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    @@ -53,6 +53,7 @@ test.test_weakref.ReferencesTestCase.test_set_callback_attribute @ darwin-arm64,
     test.test_weakref.ReferencesTestCase.test_sf_bug_840829 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.ReferencesTestCase.test_shared_ref_without_callback @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.ReferencesTestCase.test_trashcan_16602 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs @ win32-AMD64
     test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_cycle @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_slots @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.WeakKeyDictionaryTestCase.test_bool @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    
    From 69de2bf7f7d263b5679da7d92339cd04976a7698 Mon Sep 17 00:00:00 2001
    From: stepan 
    Date: Thu, 27 Feb 2025 13:06:58 +0100
    Subject: [PATCH 100/512] Build tools: pass
     --sun-misc-unsafe-memory-access=allow on JDK24+
    
    ---
     .../src/tests/standalone/test_maven_plugin.py |  27 ++++
     .../embedding/tools/exec/GraalPyRunner.java   |  15 ++
     .../python/embedding/tools/vfs/VFSUtils.java  | 129 ++++++++++--------
     3 files changed, 114 insertions(+), 57 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    index 633fc9b553..35130b4e8d 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_maven_plugin.py
    @@ -504,6 +504,33 @@ def test_python_resources_dir_and_external_dir_error(self):
                 util.check_ouput("Cannot use  and  at the same time", out)
     
     
    +    @unittest.skipUnless(util.is_maven_plugin_test_enabled, "ENABLE_MAVEN_PLUGIN_UNITTESTS is not true")
    +    def test_java_home_change(self):
    +        with util.TemporaryTestDirectory() as tmpdir:
    +            target_name = "check_home_warning_test"
    +            target_dir = os.path.join(str(tmpdir), target_name)
    +            self.generate_app(tmpdir, target_dir, target_name)
    +
    +            mvnw_cmd = util.get_mvn_wrapper(target_dir, self.env)
    +
    +            # build the app
    +            process_resources_cmd = mvnw_cmd + ["package"]
    +            out, return_code = util.run_cmd(process_resources_cmd, self.env, cwd=target_dir)
    +            util.check_ouput("BUILD SUCCESS", out)
    +
    +            # update the generated launcher, so that it looks like it's been generated with different Java path
    +            pyenvcfg = os.path.join(target_dir, 'target', 'pyvenv.cfg')
    +            if os.path.exists(pyenvcfg):
    +                util.replace_in_file(pyenvcfg, os.environ['JAVA_HOME'], '/bogus/java/home')
    +            else:
    +                util.replace_in_file(os.path.join(target_dir, 'target', 'graalpy.sh'), os.environ['JAVA_HOME'], '/bogus/java/home')
    +
    +            util.replace_in_file(os.path.join(target_dir, 'pom.xml'), 'termcolor==2.2', 'termcolor==2')
    +            process_resources_cmd = mvnw_cmd + ["package"]
    +            out, return_code = util.run_cmd(process_resources_cmd, self.env, cwd=target_dir)
    +            util.check_ouput("BUILD SUCCESS", out)
    +
    +
         # Creates two Java apps from given pom templates, the dependencies between them
         # must be configured in the pom template(s)
         def _prepare_multi_project(self, tmpdir, app1_pom_template_name, app2_pom_template_name):
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java
    index 3cd3bd5d74..14833396e9 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/exec/GraalPyRunner.java
    @@ -51,6 +51,7 @@
     import java.nio.file.Path;
     import java.nio.file.Paths;
     import java.util.ArrayList;
    +import java.util.Arrays;
     import java.util.List;
     import java.util.Set;
     
    @@ -60,6 +61,18 @@ public class GraalPyRunner {
         private static final String BIN_DIR = IS_WINDOWS ? "Scripts" : "bin";
         private static final String EXE_SUFFIX = IS_WINDOWS ? ".exe" : "";
     
    +    public static String[] getExtraJavaOptions() {
    +        String javaVersion = System.getProperty("java.version");
    +        try {
    +            if (Integer.parseInt(javaVersion) >= 24) {
    +                return new String[]{"--sun-misc-unsafe-memory-access=allow"};
    +            }
    +        } catch (NumberFormatException ex) {
    +            // covers also javaVersion being 'null'
    +        }
    +        return new String[0];
    +    }
    +
         public static void run(Set classpath, BuildToolLog log, String... args) throws IOException, InterruptedException {
             run(String.join(File.pathSeparator, classpath), log, args);
         }
    @@ -69,6 +82,8 @@ public static void run(String classpath, BuildToolLog log, String... args) throw
             Path java = Paths.get(System.getProperty("java.home"), "bin", "java");
             List cmd = new ArrayList<>();
             cmd.add(java.toString());
    +        cmd.add("--enable-native-access=ALL-UNNAMED");
    +        cmd.addAll(Arrays.asList(getExtraJavaOptions()));
             cmd.add("-classpath");
             cmd.add(classpath);
             cmd.add("com.oracle.graal.python.shell.GraalPythonMain");
    diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    index 60cb28d473..7eee7902ee 100644
    --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java
    @@ -690,65 +690,80 @@ private static Path ensureLauncher(Launcher launcherArgs, BuildToolLog log) thro
             }
         }
     
    -    private static void generateLaunchers(Launcher launcherArgs, BuildToolLog log) throws IOException {
    -        if (!Files.exists(launcherArgs.launcherPath)) {
    -            info(log, "Generating GraalPy launchers");
    -            createParentDirectories(launcherArgs.launcherPath);
    -            Path java = Paths.get(System.getProperty("java.home"), "bin", "java");
    -            String classpath = String.join(File.pathSeparator, launcherArgs.computeClassPath());
    -            if (!IS_WINDOWS) {
    -                var script = String.format("""
    -                                #!/usr/bin/env bash
    -                                %s --enable-native-access=ALL-UNNAMED -classpath %s %s --python.Executable="$0" "$@"
    -                                """,
    -                                java,
    -                                String.join(File.pathSeparator, classpath),
    -                                GRAALPY_MAIN_CLASS);
    -                try {
    -                    Files.writeString(launcherArgs.launcherPath, script);
    -                    var perms = Files.getPosixFilePermissions(launcherArgs.launcherPath);
    -                    perms.addAll(List.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_EXECUTE));
    -                    Files.setPosixFilePermissions(launcherArgs.launcherPath, perms);
    -                } catch (IOException e) {
    -                    throw new IOException(String.format("failed to create launcher %s", launcherArgs.launcherPath), e);
    -                }
    -            } else {
    -                // on windows, generate a venv launcher that executes our mvn target
    -                var script = String.format("""
    -                                import os, shutil, struct, venv
    -                                from pathlib import Path
    -                                vl = os.path.join(venv.__path__[0], 'scripts', 'nt', 'graalpy.exe')
    -                                tl = os.path.join(r'%s')
    -                                os.makedirs(Path(tl).parent.absolute(), exist_ok=True)
    -                                shutil.copy(vl, tl)
    -                                cmd = r'%s --enable-native-access=ALL-UNNAMED -classpath "%s" %s'
    -                                pyvenvcfg = os.path.join(os.path.dirname(tl), "pyvenv.cfg")
    -                                with open(pyvenvcfg, 'w', encoding='utf-8') as f:
    -                                    f.write('venvlauncher_command = ')
    -                                    f.write(cmd)
    -                                """,
    -                                launcherArgs.launcherPath,
    -                                java,
    -                                classpath,
    -                                GRAALPY_MAIN_CLASS);
    -                File tmp;
    -                try {
    -                    tmp = File.createTempFile("create_launcher", ".py");
    -                } catch (IOException e) {
    -                    throw new IOException("failed to create tmp launcher", e);
    -                }
    -                tmp.deleteOnExit();
    -                try (var wr = new FileWriter(tmp)) {
    -                    wr.write(script);
    -                } catch (IOException e) {
    -                    throw new IOException(String.format("failed to write tmp launcher %s", tmp), e);
    +    private static boolean checkWinLauncherJavaPath(Path venvCfg, Path java) {
    +        try {
    +            for (String line : Files.readAllLines(venvCfg)) {
    +                if (line.trim().startsWith("venvlauncher_command = " + java)) {
    +                    return true;
                     }
    +            }
    +        } catch (IOException ignore) {
    +        }
    +        return false;
    +    }
     
    -                try {
    -                    GraalPyRunner.run(classpath, log, tmp.getAbsolutePath());
    -                } catch (InterruptedException e) {
    -                    throw new IOException(String.format("failed to run Graalpy launcher"), e);
    -                }
    +    private static void generateLaunchers(Launcher launcherArgs, BuildToolLog log) throws IOException {
    +        debug(log, "Generating GraalPy launchers");
    +        createParentDirectories(launcherArgs.launcherPath);
    +        Path java = Paths.get(System.getProperty("java.home"), "bin", "java");
    +        String classpath = String.join(File.pathSeparator, launcherArgs.computeClassPath());
    +        String extraJavaOptions = String.join(" ", GraalPyRunner.getExtraJavaOptions());
    +        if (!IS_WINDOWS) {
    +            // we do not bother checking if it exists and has correct java home, since it is simple
    +            // to regenerate the launcher
    +            var script = String.format("""
    +                            #!/usr/bin/env bash
    +                            %s --enable-native-access=ALL-UNNAMED %s -classpath %s %s --python.Executable="$0" "$@"
    +                            """,
    +                            java,
    +                            extraJavaOptions,
    +                            String.join(File.pathSeparator, classpath),
    +                            GRAALPY_MAIN_CLASS);
    +            try {
    +                Files.writeString(launcherArgs.launcherPath, script);
    +                var perms = Files.getPosixFilePermissions(launcherArgs.launcherPath);
    +                perms.addAll(List.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_EXECUTE));
    +                Files.setPosixFilePermissions(launcherArgs.launcherPath, perms);
    +            } catch (IOException e) {
    +                throw new IOException(String.format("failed to create launcher %s", launcherArgs.launcherPath), e);
    +            }
    +        } else if (!Files.exists(launcherArgs.launcherPath) || !checkWinLauncherJavaPath(launcherArgs.launcherPath.getParent().resolve("pyenv.cfg"), java)) {
    +            // on windows, generate a venv launcher that executes the java command
    +            var script = String.format("""
    +                            import os, shutil, struct, venv
    +                            from pathlib import Path
    +                            vl = os.path.join(venv.__path__[0], 'scripts', 'nt', 'graalpy.exe')
    +                            tl = os.path.join(r'%s')
    +                            os.makedirs(Path(tl).parent.absolute(), exist_ok=True)
    +                            shutil.copy(vl, tl)
    +                            cmd = r'%s --enable-native-access=ALL-UNNAMED %s -classpath "%s" %s'
    +                            pyvenvcfg = os.path.join(os.path.dirname(tl), "pyvenv.cfg")
    +                            with open(pyvenvcfg, 'w', encoding='utf-8') as f:
    +                                f.write('venvlauncher_command = ')
    +                                f.write(cmd)
    +                            """,
    +                            launcherArgs.launcherPath,
    +                            java,
    +                            extraJavaOptions,
    +                            classpath,
    +                            GRAALPY_MAIN_CLASS);
    +            File tmp;
    +            try {
    +                tmp = File.createTempFile("create_launcher", ".py");
    +            } catch (IOException e) {
    +                throw new IOException("failed to create tmp launcher", e);
    +            }
    +            tmp.deleteOnExit();
    +            try (var wr = new FileWriter(tmp)) {
    +                wr.write(script);
    +            } catch (IOException e) {
    +                throw new IOException(String.format("failed to write tmp launcher %s", tmp), e);
    +            }
    +
    +            try {
    +                GraalPyRunner.run(classpath, log, tmp.getAbsolutePath());
    +            } catch (InterruptedException e) {
    +                throw new IOException("failed to run Graalpy launcher", e);
                 }
             }
         }
    
    From d78d4b7c3ae744dd8f921c5b0cc5f049983dc793 Mon Sep 17 00:00:00 2001
    From: stepan 
    Date: Fri, 28 Feb 2025 09:44:11 +0100
    Subject: [PATCH 101/512] Change the warning 'compiler does not support source
     tree parsing during annotation processing' to a note to avoid failing -Werror
     build
    
    ---
     .../graal/python/processor/CApiBuiltinsProcessor.java      | 7 ++++---
     1 file changed, 4 insertions(+), 3 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java
    index f8635ea096..ab94bf9b3f 100644
    --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java
    +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2020, 2025, 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
    @@ -70,6 +70,7 @@
     import javax.lang.model.type.TypeMirror;
     import javax.lang.model.util.AbstractAnnotationValueVisitor14;
     import javax.lang.model.util.ElementFilter;
    +import javax.tools.Diagnostic.Kind;
     import javax.tools.StandardLocation;
     
     import com.oracle.graal.python.annotations.CApiConstants;
    @@ -121,8 +122,8 @@ public synchronized void init(ProcessingEnvironment pe) {
             try {
                 this.trees = Trees.instance(pe);
             } catch (Throwable t) {
    -            // ECJ does not support this, so we skip the some processing of C API builtins
    -            pe.getMessager().printWarning("The compiler does not support source tree parsing during annotation processing. Regeneration of Python C API builtins will be incorrect.");
    +            // ECJ does not support this, so we skip the processing of C API builtins
    +            pe.getMessager().printMessage(Kind.NOTE, "The compiler does not support source tree parsing during annotation processing. Regeneration of Python C API builtins will be incorrect.");
                 this.trees = null;
             }
         }
    
    From 4e15a8a65892fd5434d3a0426d450794b659b367 Mon Sep 17 00:00:00 2001
    From: stepan 
    Date: Fri, 28 Feb 2025 10:28:10 +0100
    Subject: [PATCH 102/512] Ignore transiently failing tagged tests
    
    ---
     .../src/tests/unittest_tags/test_asyncio.txt                   | 3 ++-
     .../src/tests/unittest_tags/test_multiprocessing_spawn.txt     | 3 ++-
     .../src/tests/unittest_tags/test_weakref.txt                   | 3 ++-
     3 files changed, 6 insertions(+), 3 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    index 8922fe3259..be43c5a205 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt
    @@ -620,7 +620,8 @@ test.test_asyncio.test_ssl.TestSSL.test_create_server_ssl_1 @ darwin-arm64,darwi
     test.test_asyncio.test_ssl.TestSSL.test_create_server_ssl_over_ssl @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_flush_before_shutdown @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_shutdown_cleanly @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_asyncio.test_ssl.TestSSL.test_shutdown_timeout_handler_leak @ darwin-x86_64
    +# transiently fails
    +!test.test_asyncio.test_ssl.TestSSL.test_shutdown_timeout_handler_leak
     test.test_asyncio.test_ssl.TestSSL.test_shutdown_timeout_handler_not_set @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_ssl_connect_accepted_socket @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_asyncio.test_ssl.TestSSL.test_ssl_handshake_connection_lost @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    index 39b9d514f7..83747affb1 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_multiprocessing_spawn.txt
    @@ -199,7 +199,8 @@ test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_chunks
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_no_failfast @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap_async @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_terminate @ darwin-arm64
    +# transiently fails
    +!test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_terminate
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_traceback @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_active_children @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_args_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    index 8e2191e2f0..d550307c5b 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    @@ -53,7 +53,8 @@ test.test_weakref.ReferencesTestCase.test_set_callback_attribute @ darwin-arm64,
     test.test_weakref.ReferencesTestCase.test_sf_bug_840829 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.ReferencesTestCase.test_shared_ref_without_callback @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.ReferencesTestCase.test_trashcan_16602 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    -test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs @ win32-AMD64
    +# transiently fails
    +!test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs
     test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_cycle @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_slots @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.WeakKeyDictionaryTestCase.test_bool @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    
    From 90a522b5f3e7bfe87c8c3129548d2289a850133e Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Mon, 3 Mar 2025 11:16:12 +0100
    Subject: [PATCH 103/512] Increase timeout for shared context multithreading
     tests for coverage
    
    ---
     .../engine/SharedEngineMultithreadingTestBase.java        | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java
    index 6230ef9a34..da1e4d03f9 100644
    --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java
    +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingTestBase.java
    @@ -69,6 +69,7 @@ public class SharedEngineMultithreadingTestBase extends PythonTests {
         protected static final int RUNS_COUNT_FACTOR = Integer.getInteger("com.oracle.graal.python.test.SharedEngineMultithreadingRunCountFactor", 4);
         protected static final int THREADS_COUNT = Runtime.getRuntime().availableProcessors();
         private static final boolean LOG = false;
    +    private static final int TIMEOUT = 20;
     
         @Rule public CleanupRule cleanup = new CleanupRule();
     
    @@ -117,16 +118,15 @@ protected static void submitAndWaitAll(ExecutorService service, Task[] tasks) th
             boolean wasTimeout = false;
             for (Future future : futures) {
                 try {
    -                // Under coverage, some of these tests are almost 10x slower,
    -                // so we go with a 15min timeout
    -                future.get(15, TimeUnit.MINUTES);
    +                // Under coverage, some of these tests are very slow
    +                future.get(TIMEOUT, TimeUnit.MINUTES);
                 } catch (TimeoutException e) {
                     wasTimeout = true;
                 }
             }
             if (wasTimeout) {
                 System.err.println(Utils.getThreadDump());
    -            throw new AssertionError("One of the tasks did not finish in 2 minutes");
    +            throw new AssertionError("One of the tasks did not finish in " + TIMEOUT + " minutes");
             }
             log("All %d futures finished...", tasks.length);
         }
    
    From 64b9e6443b388bc851a08ea9b6b9d13c5565cc30 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 24 Feb 2025 15:18:16 +0100
    Subject: [PATCH 104/512] Implement tp_iter slot
    
    ---
     .../oracle/graal/python/annotations/Slot.java |   4 +-
     .../graal/python/processor/SlotsMapping.java  |   9 +-
     .../builtins/PythonBuiltinClassType.java      | 154 ++++++++++++------
     .../modules/csv/CSVReaderBuiltins.java        |   7 +-
     .../builtins/modules/io/IOBaseBuiltins.java   |   7 +-
     .../modules/json/JSONEncoderBuiltins.java     |  10 +-
     .../objects/PythonAbstractObject.java         |   8 +-
     .../builtins/objects/array/ArrayBuiltins.java |   3 +-
     .../objects/asyncio/AsyncGenSendBuiltins.java |   8 +-
     .../asyncio/AsyncGenThrowBuiltins.java        |   8 +-
     .../asyncio/CoroutineWrapperBuiltins.java     |  14 +-
     .../objects/bytes/BytesCommonBuiltins.java    |   3 +-
     .../objects/cext/capi/SlotMethodDef.java      |   3 -
     .../objects/cext/capi/ToNativeTypeNode.java   |   1 -
     .../objects/common/HashingStorage.java        |  10 +-
     .../objects/contextvars/ContextBuiltins.java  |   3 +-
     .../contextvars/ContextIteratorBuiltins.java  |   8 +-
     .../builtins/objects/deque/DequeBuiltins.java |   3 +-
     .../objects/deque/DequeIterBuiltins.java      |   7 +-
     .../builtins/objects/dict/DictBuiltins.java   |   3 +-
     .../objects/dict/DictValuesBuiltins.java      |   3 +-
     .../objects/dict/DictViewBuiltins.java        |   3 +-
     .../objects/enumerate/EnumerateBuiltins.java  |   7 +-
     .../foreign/ForeignIterableBuiltins.java      |  10 +-
     .../function/BuiltinMethodDescriptors.java    |  58 -------
     .../objects/generator/GeneratorBuiltins.java  |   8 +-
     .../objects/iterator/IteratorBuiltins.java    |   8 +-
     .../objects/iterator/PZipBuiltins.java        |   8 +-
     .../iterator/SentinelIteratorBuiltins.java    |   8 +-
     .../objects/itertools/AccumulateBuiltins.java |   8 +-
     .../objects/itertools/ChainBuiltins.java      |   8 +-
     .../itertools/CombinationsBuiltins.java       |   8 +-
     .../objects/itertools/CompressBuiltins.java   |   8 +-
     .../objects/itertools/CountBuiltins.java      |   8 +-
     .../objects/itertools/CycleBuiltins.java      |   8 +-
     .../objects/itertools/DropwhileBuiltins.java  |   8 +-
     .../itertools/FilterfalseBuiltins.java        |   8 +-
     .../objects/itertools/GroupByBuiltins.java    |   8 +-
     .../objects/itertools/GrouperBuiltins.java    |   8 +-
     .../objects/itertools/IsliceBuiltins.java     |   8 +-
     .../objects/itertools/PairwiseBuiltins.java   |   8 +-
     .../itertools/PermutationsBuiltins.java       |   8 +-
     .../objects/itertools/ProductBuiltins.java    |   8 +-
     .../objects/itertools/RepeatBuiltins.java     |   8 +-
     .../objects/itertools/StarmapBuiltins.java    |   8 +-
     .../objects/itertools/TakewhileBuiltins.java  |   8 +-
     .../objects/itertools/TeeBuiltins.java        |   8 +-
     .../objects/itertools/ZipLongestBuiltins.java |   8 +-
     .../builtins/objects/list/ListBuiltins.java   |   3 +-
     .../builtins/objects/map/MapBuiltins.java     |   8 +-
     .../mappingproxy/MappingproxyBuiltins.java    |   3 +-
     .../ordereddict/OrderedDictBuiltins.java      |   3 +-
     .../ordereddict/OrderedDictItemsBuiltins.java |   9 +-
     .../OrderedDictIteratorBuiltins.java          |   9 +-
     .../ordereddict/OrderedDictKeysBuiltins.java  |   9 +-
     .../OrderedDictValuesBuiltins.java            |   9 +-
     .../posix/ScandirIteratorBuiltins.java        |   8 +-
     .../builtins/objects/range/RangeBuiltins.java |   3 +-
     .../objects/reversed/ReversedBuiltins.java    |   8 +-
     .../builtins/objects/set/BaseSetBuiltins.java |   3 +-
     .../builtins/objects/str/StringBuiltins.java  |   3 +-
     .../struct/StructUnpackIteratorBuiltins.java  |   9 +-
     .../tokenize/TokenizerIterBuiltins.java       |   8 +-
     .../builtins/objects/tuple/TupleBuiltins.java |   3 +-
     .../objects/type/SpecialMethodSlot.java       |   7 -
     .../python/builtins/objects/type/TpSlots.java |  18 +-
     .../objects/types/GenericAliasBuiltins.java   |   3 +-
     .../objects/types/GenericTypeNodes.java       |   5 +-
     .../graal/python/lib/PyObjectGetIter.java     |  37 ++---
     .../oracle/graal/python/nodes/PGuards.java    |   8 +-
     .../keywords/ConcatDictToStorageNode.java     |  21 +--
     .../keywords/MappingToKeywordsNode.java       |   7 +-
     72 files changed, 443 insertions(+), 299 deletions(-)
     delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinMethodDescriptors.java
    
    diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    index 834ac45af4..d499f16354 100644
    --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    @@ -192,7 +192,9 @@ enum SlotKind {
             /** get object attribute */
             tp_getattro("__getattribute__, __getattr__"),
             /** set/delete object attribute */
    -        tp_setattro("__setattr__, __delattr__");
    +        tp_setattro("__setattr__, __delattr__"),
    +        /** iter(obj) */
    +        tp_iter("__iter__");
     
             SlotKind(@SuppressWarnings("unused") String specialMethods) {
             }
    diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    index 73af396a11..c84fe9e7ab 100644
    --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    @@ -52,7 +52,9 @@ private static String getSuffix(boolean isComplex) {
         static String getSlotBaseClass(Slot s) {
             return switch (s.value()) {
                 case nb_bool -> "TpSlotInquiry.TpSlotInquiryBuiltin";
    -            case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert -> "TpSlotUnaryFunc.TpSlotUnaryFuncBuiltin";
    +            case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert,
    +                            tp_iter ->
    +                "TpSlotUnaryFunc.TpSlotUnaryFuncBuiltin";
                 case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or,
                                 nb_floor_divide, nb_true_divide, nb_matrix_multiply ->
                     "TpSlotBinaryOp.TpSlotBinaryOpBuiltin";
    @@ -81,7 +83,9 @@ static String getSlotNodeBaseClass(Slot s) {
             return switch (s.value()) {
                 case tp_descr_get -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode";
                 case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode";
    -            case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert -> "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode";
    +            case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert,
    +                            tp_iter ->
    +                "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode";
                 case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or,
                                 nb_floor_divide, nb_true_divide, nb_matrix_multiply ->
                     "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode";
    @@ -175,6 +179,7 @@ public static String getExtraCtorArgs(TpSlotData slot) {
                 case sq_repeat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MUL__";
                 case sq_inplace_concat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__";
                 case sq_inplace_repeat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__";
    +            case tp_iter -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__";
                 default -> "";
             };
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    index 13c5fcb87c..ff738e807f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    @@ -113,6 +113,7 @@
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.Slot;
     import com.oracle.graal.python.builtins.modules.WeakRefModuleBuiltins;
    +import com.oracle.graal.python.builtins.modules.csv.CSVReaderBuiltins;
     import com.oracle.graal.python.builtins.modules.ctypes.CDataTypeSequenceBuiltins;
     import com.oracle.graal.python.builtins.modules.ctypes.CFieldBuiltins;
     import com.oracle.graal.python.builtins.modules.ctypes.PyCArrayBuiltins;
    @@ -122,31 +123,63 @@
     import com.oracle.graal.python.builtins.modules.ctypes.SimpleCDataBuiltins;
     import com.oracle.graal.python.builtins.modules.ctypes.StgDictBuiltins;
     import com.oracle.graal.python.builtins.modules.functools.LruCacheWrapperBuiltins;
    +import com.oracle.graal.python.builtins.modules.io.IOBaseBuiltins;
     import com.oracle.graal.python.builtins.objects.NoneBuiltins;
     import com.oracle.graal.python.builtins.objects.array.ArrayBuiltins;
    +import com.oracle.graal.python.builtins.objects.asyncio.AsyncGenSendBuiltins;
    +import com.oracle.graal.python.builtins.objects.asyncio.AsyncGenThrowBuiltins;
    +import com.oracle.graal.python.builtins.objects.asyncio.CoroutineWrapperBuiltins;
     import com.oracle.graal.python.builtins.objects.bool.BoolBuiltins;
     import com.oracle.graal.python.builtins.objects.bytes.ByteArrayBuiltins;
     import com.oracle.graal.python.builtins.objects.bytes.BytesBuiltins;
     import com.oracle.graal.python.builtins.objects.bytes.BytesCommonBuiltins;
     import com.oracle.graal.python.builtins.objects.complex.ComplexBuiltins;
     import com.oracle.graal.python.builtins.objects.contextvars.ContextBuiltins;
    +import com.oracle.graal.python.builtins.objects.contextvars.ContextIteratorBuiltins;
     import com.oracle.graal.python.builtins.objects.deque.DequeBuiltins;
    +import com.oracle.graal.python.builtins.objects.deque.DequeIterBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.DefaultDictBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.DictBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.DictValuesBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.DictViewBuiltins;
    +import com.oracle.graal.python.builtins.objects.enumerate.EnumerateBuiltins;
     import com.oracle.graal.python.builtins.objects.floats.FloatBuiltins;
     import com.oracle.graal.python.builtins.objects.foreign.ForeignBooleanBuiltins;
    +import com.oracle.graal.python.builtins.objects.foreign.ForeignIterableBuiltins;
     import com.oracle.graal.python.builtins.objects.foreign.ForeignNumberBuiltins;
     import com.oracle.graal.python.builtins.objects.foreign.ForeignObjectBuiltins;
     import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor;
     import com.oracle.graal.python.builtins.objects.function.FunctionBuiltins;
     import com.oracle.graal.python.builtins.objects.function.MethodDescriptorBuiltins;
     import com.oracle.graal.python.builtins.objects.function.WrapperDescriptorBuiltins;
    +import com.oracle.graal.python.builtins.objects.generator.GeneratorBuiltins;
     import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptorTypeBuiltins;
     import com.oracle.graal.python.builtins.objects.getsetdescriptor.MemberDescriptorBuiltins;
     import com.oracle.graal.python.builtins.objects.ints.IntBuiltins;
    +import com.oracle.graal.python.builtins.objects.iterator.IteratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.iterator.PZipBuiltins;
    +import com.oracle.graal.python.builtins.objects.iterator.SentinelIteratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.AccumulateBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.ChainBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.CombinationsBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.CompressBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.CountBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.CycleBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.DropwhileBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.FilterfalseBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.GroupByBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.GrouperBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.IsliceBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.PairwiseBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.PermutationsBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.ProductBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.RepeatBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.StarmapBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.TakewhileBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.TeeBuiltins;
    +import com.oracle.graal.python.builtins.objects.itertools.ZipLongestBuiltins;
     import com.oracle.graal.python.builtins.objects.list.ListBuiltins;
    +import com.oracle.graal.python.builtins.objects.map.MapBuiltins;
     import com.oracle.graal.python.builtins.objects.mappingproxy.MappingproxyBuiltins;
     import com.oracle.graal.python.builtins.objects.memoryview.MemoryViewBuiltins;
     import com.oracle.graal.python.builtins.objects.method.ClassmethodBuiltins;
    @@ -157,13 +190,21 @@
     import com.oracle.graal.python.builtins.objects.module.ModuleBuiltins;
     import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
     import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictBuiltins;
    +import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictItemsBuiltins;
    +import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictIteratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictKeysBuiltins;
    +import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictValuesBuiltins;
    +import com.oracle.graal.python.builtins.objects.posix.ScandirIteratorBuiltins;
     import com.oracle.graal.python.builtins.objects.property.PropertyBuiltins;
     import com.oracle.graal.python.builtins.objects.range.RangeBuiltins;
    +import com.oracle.graal.python.builtins.objects.reversed.ReversedBuiltins;
     import com.oracle.graal.python.builtins.objects.set.BaseSetBuiltins;
     import com.oracle.graal.python.builtins.objects.set.SetBuiltins;
     import com.oracle.graal.python.builtins.objects.str.StringBuiltins;
    +import com.oracle.graal.python.builtins.objects.struct.StructUnpackIteratorBuiltins;
     import com.oracle.graal.python.builtins.objects.superobject.SuperBuiltins;
     import com.oracle.graal.python.builtins.objects.thread.ThreadLocalBuiltins;
    +import com.oracle.graal.python.builtins.objects.tokenize.TokenizerIterBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.TupleGetterBuiltins;
     import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    @@ -191,8 +232,8 @@ public enum PythonBuiltinClassType implements TruffleObject {
     
         Boolean("bool", J_BUILTINS, Flags.PUBLIC_DERIVED_WODICT, BOOLEAN_M_FLAGS, BoolBuiltins.SLOTS),
         PArray("array", "array", ARRAY_M_FLAGS, ArrayBuiltins.SLOTS),
    -    PArrayIterator("arrayiterator", Flags.PRIVATE_DERIVED_WODICT),
    -    PIterator("iterator", Flags.PRIVATE_DERIVED_WODICT),
    +    PArrayIterator("arrayiterator", Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
    +    PIterator("iterator", Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
         /** See {@link com.oracle.graal.python.builtins.objects.function.PBuiltinFunction} */
         PBuiltinFunction("method_descriptor", Flags.PRIVATE_DERIVED_WODICT, MethodDescriptorBuiltins.SLOTS),
         /** See {@link com.oracle.graal.python.builtins.objects.method.PBuiltinMethod} */
    @@ -217,41 +258,41 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PDefaultDict(J_DEFAULTDICT, "_collections", "collections", Flags.PUBLIC_BASE_WODICT, DEFAULTDICT_M_FLAGS, DefaultDictBuiltins.SLOTS),
         PDeque(J_DEQUE, "_collections", Flags.PUBLIC_BASE_WODICT, DEQUE_M_FLAGS, DequeBuiltins.SLOTS),
         PTupleGetter(J_TUPLE_GETTER, "_collections", Flags.PUBLIC_BASE_WODICT, TupleGetterBuiltins.SLOTS),
    -    PDequeIter(J_DEQUE_ITER, "_collections", Flags.PUBLIC_DERIVED_WODICT),
    -    PDequeRevIter(J_DEQUE_REV_ITER, "_collections", Flags.PUBLIC_DERIVED_WODICT),
    +    PDequeIter(J_DEQUE_ITER, "_collections", Flags.PUBLIC_DERIVED_WODICT, DequeIterBuiltins.SLOTS),
    +    PDequeRevIter(J_DEQUE_REV_ITER, "_collections", Flags.PUBLIC_DERIVED_WODICT, DequeIterBuiltins.SLOTS),
         POrderedDict(J_ORDERED_DICT, "_collections", Flags.PUBLIC_BASE_WDICT, DICT_M_FLAGS, OrderedDictBuiltins.SLOTS),
    -    POrderedDictKeys("odict_keys", Flags.PRIVATE_DERIVED_WODICT, DICTKEYSVIEW_M_FLAGS),
    -    POrderedDictValues("odict_values", Flags.PRIVATE_DERIVED_WODICT, DICTVALUESVIEW_M_FLAGS),
    -    POrderedDictItems("odict_items", Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS),
    -    POrderedDictIterator("odict_iterator", Flags.PRIVATE_DERIVED_WODICT),
    +    POrderedDictKeys("odict_keys", Flags.PRIVATE_DERIVED_WODICT, DICTKEYSVIEW_M_FLAGS, OrderedDictKeysBuiltins.SLOTS),
    +    POrderedDictValues("odict_values", Flags.PRIVATE_DERIVED_WODICT, DICTVALUESVIEW_M_FLAGS, OrderedDictValuesBuiltins.SLOTS),
    +    POrderedDictItems("odict_items", Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS, OrderedDictItemsBuiltins.SLOTS),
    +    POrderedDictIterator("odict_iterator", Flags.PRIVATE_DERIVED_WODICT, OrderedDictIteratorBuiltins.SLOTS),
         PComplex("complex", J_BUILTINS, COMPLEX_M_FLAGS, ComplexBuiltins.SLOTS),
         PDict("dict", J_BUILTINS, DICT_M_FLAGS, DictBuiltins.SLOTS),
    -    PDictItemIterator(J_DICT_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    -    PDictReverseItemIterator(J_DICT_REVERSE_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    +    PDictItemIterator(J_DICT_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
    +    PDictReverseItemIterator(J_DICT_REVERSE_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
         PDictItemsView(J_DICT_ITEMS, Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS, DictViewBuiltins.SLOTS),
    -    PDictKeyIterator(J_DICT_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    -    PDictReverseKeyIterator(J_DICT_REVERSE_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    +    PDictKeyIterator(J_DICT_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
    +    PDictReverseKeyIterator(J_DICT_REVERSE_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
         PDictKeysView(J_DICT_KEYS, Flags.PRIVATE_DERIVED_WODICT, DICTKEYSVIEW_M_FLAGS, DictViewBuiltins.SLOTS),
    -    PDictValueIterator(J_DICT_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    -    PDictReverseValueIterator(J_DICT_REVERSE_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT),
    +    PDictValueIterator(J_DICT_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
    +    PDictReverseValueIterator(J_DICT_REVERSE_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS),
         PDictValuesView(J_DICT_VALUES, Flags.PRIVATE_DERIVED_WODICT, DICTVALUESVIEW_M_FLAGS, DictValuesBuiltins.SLOTS),
         PEllipsis("ellipsis", Flags.PRIVATE_DERIVED_WODICT),
    -    PEnumerate("enumerate", J_BUILTINS),
    -    PMap("map", J_BUILTINS),
    +    PEnumerate("enumerate", J_BUILTINS, EnumerateBuiltins.SLOTS),
    +    PMap("map", J_BUILTINS, MapBuiltins.SLOTS),
         PFloat("float", J_BUILTINS, FLOAT_M_FLAGS, FloatBuiltins.SLOTS),
         PFrame("frame", Flags.PRIVATE_DERIVED_WODICT),
         PFrozenSet("frozenset", J_BUILTINS, FROZENSET_M_FLAGS, BaseSetBuiltins.SLOTS),
         PFunction("function", Flags.PRIVATE_DERIVED_WDICT, FunctionBuiltins.SLOTS),
    -    PGenerator("generator", Flags.PRIVATE_DERIVED_WODICT, GENERATOR_M_FLAGS),
    +    PGenerator("generator", Flags.PRIVATE_DERIVED_WODICT, GENERATOR_M_FLAGS, GeneratorBuiltins.SLOTS),
         PCoroutine("coroutine", Flags.PRIVATE_DERIVED_WODICT, COROUTINE_M_FLAGS),
    -    PCoroutineWrapper("coroutine_wrapper", Flags.PRIVATE_DERIVED_WODICT),
    +    PCoroutineWrapper("coroutine_wrapper", Flags.PRIVATE_DERIVED_WODICT, CoroutineWrapperBuiltins.SLOTS),
         PAsyncGenerator("async_generator", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_M_FLAGS),
         PInt("int", J_BUILTINS, INT_M_FLAGS, IntBuiltins.SLOTS),
         PList("list", J_BUILTINS, LIST_M_FLAGS, ListBuiltins.SLOTS),
         PMappingproxy("mappingproxy", Flags.PRIVATE_DERIVED_WODICT, MAPPINGPROXY_M_FLAGS, MappingproxyBuiltins.SLOTS),
         PMemoryView("memoryview", J_BUILTINS, Flags.PUBLIC_DERIVED_WODICT, MEMORYVIEW_M_FLAGS, MemoryViewBuiltins.SLOTS),
    -    PAsyncGenASend("async_generator_asend", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_ASEND_M_FLAGS),
    -    PAsyncGenAThrow("async_generator_athrow", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_ATHROW_M_FLAGS),
    +    PAsyncGenASend("async_generator_asend", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_ASEND_M_FLAGS, AsyncGenSendBuiltins.SLOTS),
    +    PAsyncGenAThrow("async_generator_athrow", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_ATHROW_M_FLAGS, AsyncGenThrowBuiltins.SLOTS),
         PAsyncGenAWrappedValue("async_generator_wrapped_value", Flags.PRIVATE_DERIVED_WODICT),
         PMethod("method", Flags.PRIVATE_DERIVED_WODICT, MethodBuiltins.SLOTS),
         PMMap("mmap", "mmap", MMAP_M_FLAGS, MMapBuiltins.SLOTS),
    @@ -262,8 +303,8 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PRandom("Random", "_random"),
         PRange("range", J_BUILTINS, Flags.PUBLIC_DERIVED_WODICT, RANGE_M_FLAGS, RangeBuiltins.SLOTS),
         PReferenceType("ReferenceType", "_weakref"),
    -    PSentinelIterator("callable_iterator", Flags.PRIVATE_DERIVED_WODICT),
    -    PReverseIterator("reversed", J_BUILTINS),
    +    PSentinelIterator("callable_iterator", Flags.PRIVATE_DERIVED_WODICT, SentinelIteratorBuiltins.SLOTS),
    +    PReverseIterator("reversed", J_BUILTINS, ReversedBuiltins.SLOTS),
         PSet("set", J_BUILTINS, SET_M_FLAGS, TpSlots.merge(BaseSetBuiltins.SLOTS, SetBuiltins.SLOTS)),
         PSlice("slice", J_BUILTINS),
         PString("str", J_BUILTINS, STRING_M_FLAGS, StringBuiltins.SLOTS),
    @@ -278,7 +319,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PGenericAlias("GenericAlias", J_TYPES, Flags.PUBLIC_BASE_WODICT, GENERIC_ALIAS_M_FLAGS, GenericAliasBuiltins.SLOTS),
         PGenericAliasIterator("generic_alias_iterator", Flags.PRIVATE_DERIVED_WODICT),
         PUnionType("UnionType", J_TYPES, Flags.PUBLIC_DERIVED_WODICT, UNION_TYPE_M_FLAGS, UnionTypeBuiltins.SLOTS),
    -    PZip("zip", J_BUILTINS),
    +    PZip("zip", J_BUILTINS, PZipBuiltins.SLOTS),
         PThread("start_new_thread", J__THREAD),
         PThreadLocal("_local", J__THREAD, ThreadLocalBuiltins.SLOTS),
         PLock("LockType", J__THREAD),
    @@ -289,11 +330,11 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PStaticmethod("staticmethod", J_BUILTINS, Flags.PUBLIC_BASE_WDICT, StaticmethodBuiltins.SLOTS),
         PClassmethod("classmethod", J_BUILTINS, Flags.PUBLIC_BASE_WDICT, ClassmethodBuiltins.SLOTS),
         PInstancemethod("instancemethod", Flags.PUBLIC_BASE_WDICT, InstancemethodBuiltins.SLOTS),
    -    PScandirIterator("ScandirIterator", J_POSIX, Flags.PRIVATE_DERIVED_WODICT),
    +    PScandirIterator("ScandirIterator", J_POSIX, Flags.PRIVATE_DERIVED_WODICT, ScandirIteratorBuiltins.SLOTS),
         PDirEntry("DirEntry", J_POSIX, Flags.PUBLIC_DERIVED_WODICT),
         LsprofProfiler("Profiler", "_lsprof"),
         PStruct("Struct", J__STRUCT),
    -    PStructUnpackIterator("unpack_iterator", J__STRUCT),
    +    PStructUnpackIterator("unpack_iterator", J__STRUCT, StructUnpackIteratorBuiltins.SLOTS),
         Pickler("Pickler", "_pickle"),
         PicklerMemoProxy("PicklerMemoProxy", "_pickle"),
         UnpicklerMemoProxy("UnpicklerMemoProxy", "_pickle"),
    @@ -307,7 +348,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
         ForeignAbstractClass("ForeignAbstractClass", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT),
         ForeignExecutable("ForeignExecutable", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT),
         ForeignInstantiable("ForeignInstantiable", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT),
    -    ForeignIterable("ForeignIterable", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT),
    +    ForeignIterable("ForeignIterable", J_POLYGLOT, ForeignObject, Flags.PUBLIC_BASE_WDICT, ForeignIterableBuiltins.SLOTS),
     
         // bz2
         BZ2Compressor("BZ2Compressor", "_bz2"),
    @@ -322,10 +363,10 @@ public enum PythonBuiltinClassType implements TruffleObject {
         ZlibDecompress("Decompress", "zlib"),
     
         // io
    -    PIOBase("_IOBase", "_io", Flags.PUBLIC_BASE_WDICT),
    -    PRawIOBase("_RawIOBase", "_io"),
    -    PTextIOBase("_TextIOBase", "_io"),
    -    PBufferedIOBase("_BufferedIOBase", "_io"),
    +    PIOBase("_IOBase", "_io", Flags.PUBLIC_BASE_WDICT, IOBaseBuiltins.SLOTS),
    +    PRawIOBase("_RawIOBase", "_io", IOBaseBuiltins.SLOTS),
    +    PTextIOBase("_TextIOBase", "_io", IOBaseBuiltins.SLOTS),
    +    PBufferedIOBase("_BufferedIOBase", "_io", IOBaseBuiltins.SLOTS),
         PBufferedReader("BufferedReader", "_io", Flags.PUBLIC_BASE_WDICT),
         PBufferedWriter("BufferedWriter", "_io", Flags.PUBLIC_BASE_WDICT),
         PBufferedRWPair("BufferedRWPair", "_io", Flags.PUBLIC_BASE_WDICT),
    @@ -361,27 +402,27 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PMemoryBIO("MemoryBIO", J__SSL),
     
         // itertools
    -    PTee("_tee", "itertools", Flags.PUBLIC_DERIVED_WODICT),
    +    PTee("_tee", "itertools", Flags.PUBLIC_DERIVED_WODICT, TeeBuiltins.SLOTS),
         PTeeDataObject("_tee_dataobject", "itertools", Flags.PUBLIC_DERIVED_WODICT),
    -    PAccumulate("accumulate", "itertools"),
    -    PCombinations("combinations", "itertools"),
    -    PCombinationsWithReplacement("combinations_with_replacement", "itertools"),
    -    PCompress("compress", "itertools"),
    -    PCycle("cycle", "itertools"),
    -    PDropwhile("dropwhile", "itertools"),
    -    PFilterfalse("filterfalse", "itertools"),
    -    PGroupBy("groupby", "itertools"),
    -    PGrouper("grouper", "itertools", Flags.PUBLIC_DERIVED_WODICT),
    -    PPairwise("pairwise", "itertools"),
    -    PPermutations("permutations", "itertools"),
    -    PProduct("product", "itertools"),
    -    PRepeat("repeat", "itertools"),
    -    PChain("chain", "itertools"),
    -    PCount("count", "itertools"),
    -    PIslice("islice", "itertools"),
    -    PStarmap("starmap", "itertools"),
    -    PTakewhile("takewhile", "itertools"),
    -    PZipLongest("zip_longest", "itertools"),
    +    PAccumulate("accumulate", "itertools", AccumulateBuiltins.SLOTS),
    +    PCombinations("combinations", "itertools", CombinationsBuiltins.SLOTS),
    +    PCombinationsWithReplacement("combinations_with_replacement", "itertools", CombinationsBuiltins.SLOTS),
    +    PCompress("compress", "itertools", CompressBuiltins.SLOTS),
    +    PCycle("cycle", "itertools", CycleBuiltins.SLOTS),
    +    PDropwhile("dropwhile", "itertools", DropwhileBuiltins.SLOTS),
    +    PFilterfalse("filterfalse", "itertools", FilterfalseBuiltins.SLOTS),
    +    PGroupBy("groupby", "itertools", GroupByBuiltins.SLOTS),
    +    PGrouper("grouper", "itertools", Flags.PUBLIC_DERIVED_WODICT, GrouperBuiltins.SLOTS),
    +    PPairwise("pairwise", "itertools", PairwiseBuiltins.SLOTS),
    +    PPermutations("permutations", "itertools", PermutationsBuiltins.SLOTS),
    +    PProduct("product", "itertools", ProductBuiltins.SLOTS),
    +    PRepeat("repeat", "itertools", RepeatBuiltins.SLOTS),
    +    PChain("chain", "itertools", ChainBuiltins.SLOTS),
    +    PCount("count", "itertools", CountBuiltins.SLOTS),
    +    PIslice("islice", "itertools", IsliceBuiltins.SLOTS),
    +    PStarmap("starmap", "itertools", StarmapBuiltins.SLOTS),
    +    PTakewhile("takewhile", "itertools", TakewhileBuiltins.SLOTS),
    +    PZipLongest("zip_longest", "itertools", ZipLongestBuiltins.SLOTS),
     
         // json
         JSONScanner("Scanner", "_json", Flags.PUBLIC_BASE_WODICT),
    @@ -389,7 +430,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
     
         // csv
         CSVDialect("Dialect", "_csv", Flags.PUBLIC_BASE_WODICT),
    -    CSVReader("Reader", "_csv", Flags.PUBLIC_BASE_WODICT),
    +    CSVReader("Reader", "_csv", Flags.PUBLIC_BASE_WODICT, CSVReaderBuiltins.SLOTS),
         CSVWriter("Writer", "_csv", Flags.PUBLIC_BASE_WODICT),
     
         // codecs
    @@ -556,11 +597,11 @@ public enum PythonBuiltinClassType implements TruffleObject {
         ContextVarsContext("Context", J__CONTEXTVARS, Flags.PUBLIC_DERIVED_WODICT, CONTEXT_M_FLAGS, ContextBuiltins.SLOTS),
         ContextVar("ContextVar", J__CONTEXTVARS, Flags.PUBLIC_DERIVED_WODICT),
         // CPython uses separate keys, values, items python types for the iterators.
    -    ContextIterator("context_iterator", J__CONTEXTVARS, Flags.PUBLIC_DERIVED_WODICT),
    +    ContextIterator("context_iterator", J__CONTEXTVARS, Flags.PUBLIC_DERIVED_WODICT, ContextIteratorBuiltins.SLOTS),
     
         Capsule("PyCapsule"),
     
    -    PTokenizerIter("TokenizerIter", "_tokenize"),
    +    PTokenizerIter("TokenizerIter", "_tokenize", TokenizerIterBuiltins.SLOTS),
     
         // A marker for @Builtin that is not a class. Must always come last.
         nil("nil");
    @@ -648,6 +689,11 @@ private static class Flags {
             this(name, module, module, flags, methodsFlags, slots);
         }
     
    +    PythonBuiltinClassType(String name, String module, PythonBuiltinClassType base, Flags flags, TpSlots slots) {
    +        this(name, module, module, flags, slots);
    +        this.base = base;
    +    }
    +
         PythonBuiltinClassType(String name, String module, PythonBuiltinClassType base, Flags flags, long methodsFlags, TpSlots slots) {
             this(name, module, module, flags, methodsFlags, slots);
             this.base = base;
    @@ -815,7 +861,7 @@ public final Shape getInstanceShape(PythonLanguage lang) {
             UnicodeDecodeError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
             UnicodeTranslateError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
             OSError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
    -        PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Next, SpecialMethodSlot.Iter, SpecialMethodSlot.LengthHint};
    +        PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Next, SpecialMethodSlot.LengthHint};
     
             // These slots actually contain context independent values, but they are initialized in
             // StructSequence to artificial PBuiltinFunctions with artificial builtin node factories,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    index 8a5394ec37..90022ba88b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    @@ -51,19 +51,21 @@
     import static com.oracle.graal.python.builtins.modules.csv.CSVReader.ReaderState.START_RECORD;
     import static com.oracle.graal.python.builtins.modules.csv.QuoteStyle.QUOTE_NONE;
     import static com.oracle.graal.python.builtins.modules.csv.QuoteStyle.QUOTE_NONNUMERIC;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.modules.csv.CSVReader.ReaderState;
     import com.oracle.graal.python.builtins.objects.list.PList;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyNumberFloatNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -94,13 +96,14 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.CSVReader)
     public final class CSVReaderBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = CSVReaderBuiltinsSlotsGen.SLOTS;
     
         @Override
         protected List> getNodeFactories() {
             return CSVReaderBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterReaderNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    index c9059dccef..09d5edd993 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    @@ -77,7 +77,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_FILENO;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ENTER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EXIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T_FILENO;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.IOUnsupportedOperation;
    @@ -89,6 +88,8 @@
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.ArgumentClinic;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -97,6 +98,7 @@
     import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
     import com.oracle.graal.python.builtins.objects.bytes.PBytes;
     import com.oracle.graal.python.builtins.objects.object.PythonObject;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyErrChainExceptions;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
    @@ -140,6 +142,7 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PIOBase)
     public final class IOBaseBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = IOBaseBuiltinsSlotsGen.SLOTS;
     
         // taken from usr/include/stdio.h
         public static final int BUFSIZ = 8192;
    @@ -411,7 +414,7 @@ static boolean isatty(VirtualFrame frame, PythonObject self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    index 333cd0283a..dd6e66faee 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    @@ -45,9 +45,9 @@
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyListCheckExactNode;
    +import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyTupleCheckExactNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PGuards;
    @@ -98,8 +98,8 @@ protected List> getNodeFa
         @GenerateNodeFactory
         public abstract static class CallEncoderNode extends PythonTernaryClinicBuiltinNode {
             @Child private LookupAndCallUnaryNode callGetItems = LookupAndCallUnaryNode.create(SpecialMethodNames.T_ITEMS);
    -        @Child private LookupAndCallUnaryNode callGetDictIter = LookupAndCallUnaryNode.create(SpecialMethodSlot.Iter);
    -        @Child private LookupAndCallUnaryNode callGetListIter = LookupAndCallUnaryNode.create(SpecialMethodSlot.Iter);
    +        @Child private PyObjectGetIter callGetDictIter = PyObjectGetIter.create();
    +        @Child private PyObjectGetIter callGetListIter = PyObjectGetIter.create();
             @Child private ListSortNode sortList = ListSortNode.create();
     
             @Override
    @@ -266,7 +266,7 @@ private void appendDictSlowPath(PJSONEncoder encoder, TruffleStringBuilderUTF32
                 if (encoder.sortKeys) {
                     sortList.execute(null, items);
                 }
    -            Object iter = callGetDictIter.executeObject(null, items);
    +            Object iter = callGetDictIter.executeCached(null, items);
                 boolean first = true;
                 while (true) {
                     Object item;
    @@ -334,7 +334,7 @@ private void appendList(PJSONEncoder encoder, TruffleStringBuilderUTF32 builder,
             }
     
             private void appendListSlowPath(PJSONEncoder encoder, TruffleStringBuilderUTF32 builder, PSequence list) {
    -            Object iter = callGetListIter.executeObject(null, list);
    +            Object iter = callGetListIter.executeCached(null, list);
                 boolean first = true;
                 while (true) {
                     Object item;
    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 1cf346883a..d0febd66ee 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
    @@ -98,6 +98,8 @@
     import com.oracle.graal.python.builtins.objects.type.PythonClass;
     import com.oracle.graal.python.builtins.objects.type.PythonManagedClass;
     import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroNode;
    @@ -200,7 +202,6 @@ public abstract class PythonAbstractObject extends DynamicObject implements Truf
         private PythonAbstractObjectNativeWrapper nativeWrapper;
     
         // @ImportStatic doesn't work for this for some reason
    -    protected static final SpecialMethodSlot Iter = SpecialMethodSlot.Iter;
         protected static final SpecialMethodSlot Next = SpecialMethodSlot.Next;
     
         protected static final Shape ABSTRACT_SHAPE = Shape.newBuilder().build();
    @@ -1674,7 +1675,7 @@ public boolean hasIterator(
                         // GR-44020: make shared:
                         @Exclusive @Cached PRaiseNode raiseNode,
                         @Shared("getClass") @Cached(inline = false) GetClassNode getClassNode,
    -                    @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                    @Cached GetCachedTpSlotsNode getSlots,
                         // GR-44020: make shared:
                         @Exclusive @Cached GilNode gil) {
             boolean mustRelease = gil.acquire();
    @@ -1684,7 +1685,8 @@ public boolean hasIterator(
                 if (behavior != null) {
                     return getValue.executeBoolean(inliningTarget, behavior, method, toBooleanNode, raiseNode, this);
                 } else {
    -                return !(lookupIter.execute(getClassNode.executeCached(this)) instanceof PNone);
    +                TpSlots slots = getSlots.execute(inliningTarget, getClassNode.executeCached(this));
    +                return slots.tp_iter() != null;
                 }
             } finally {
                 gil.release(mustRelease);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    index 97c8212abb..de642089ca 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -768,7 +767,7 @@ static void setitem(PArray self, PSlice slice, Object other,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    index 52ee2d072d..70e6ec99af 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    @@ -42,17 +42,19 @@
     
     import static com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenASend.AwaitableState;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -72,6 +74,8 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PAsyncGenASend)
     public final class AsyncGenSendBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = AsyncGenSendBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return AsyncGenSendBuiltinsFactory.getFactories();
    @@ -201,7 +205,7 @@ public Object doThrow(VirtualFrame frame, PAsyncGenASend self, Object arg1, Obje
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class Iter extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    index a26f24fb45..0125a271b5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    @@ -44,17 +44,19 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.GENERATOR_IGNORED_EXIT;
     import static com.oracle.graal.python.nodes.ErrorMessages.SEND_NON_NONE_TO_UNSTARTED_GENERATOR;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -75,6 +77,8 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PAsyncGenAThrow)
     public final class AsyncGenThrowBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = AsyncGenThrowBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return AsyncGenThrowBuiltinsFactory.getFactories();
    @@ -89,7 +93,7 @@ public Object doAwait(PAsyncGenAThrow self) {
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class Iter extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    index 8e0c35222f..724c0316fa 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2022, 2025, 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
    @@ -40,14 +40,19 @@
      */
     package com.oracle.graal.python.builtins.objects.asyncio;
     
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    +
     import java.util.List;
     
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    @@ -60,12 +65,15 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PCoroutineWrapper)
     public final class CoroutineWrapperBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = CoroutineWrapperBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return CoroutineWrapperBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = "__iter__", minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    @@ -74,7 +82,7 @@ public Object getIter(PCoroutineWrapper self) {
             }
         }
     
    -    @Builtin(name = "__next__", minNumOfPositionalArgs = 1)
    +    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
         @GenerateNodeFactory
         public abstract static class NextNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    index b2f0965ab3..575a9a59cb 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesCommonBuiltins.java
    @@ -45,7 +45,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.SEP_MUST_BE_LENGTH_1;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETNEWARGS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
     import static com.oracle.graal.python.nodes.StringLiterals.T_IGNORE;
     import static com.oracle.graal.python.nodes.StringLiterals.T_REPLACE;
    @@ -427,7 +426,7 @@ boolean contains(VirtualFrame frame, Object self, Object other,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    index 2b87b1cbdf..c748c25b71 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    @@ -46,7 +46,6 @@
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_hash;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_init;
    -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_iter;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_iternext;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_repr;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_richcompare;
    @@ -57,7 +56,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__;
    @@ -78,7 +76,6 @@ public enum SlotMethodDef {
         TP_CALL(PyTypeObject__tp_call, T___CALL__, CallFunctionWrapper::new),
         TP_HASH(PyTypeObject__tp_hash, T___HASH__, HashfuncWrapper::new),
         TP_INIT(PyTypeObject__tp_init, T___INIT__, InitWrapper::new),
    -    TP_ITER(PyTypeObject__tp_iter, T___ITER__, PyProcsWrapper.UnaryFuncLegacyWrapper::new),
         TP_ITERNEXT(PyTypeObject__tp_iternext, T___NEXT__, UnaryFuncLegacyWrapper::new),
         TP_REPR(PyTypeObject__tp_repr, T___REPR__, PyProcsWrapper.UnaryFuncLegacyWrapper::new),
         TP_RICHCOMPARE(PyTypeObject__tp_richcompare, T___TRUFFLE_RICHCOMPARE__, RichcmpFunctionWrapper::new),
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    index 20bd1161a8..b894d83673 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    @@ -271,7 +271,6 @@ static void initializeType(PythonClassNativeWrapper obj, Object mem, boolean hea
             writePtrNode.write(mem, CFields.PyTypeObject__tp_is_gc, tpIsGc);
     
             writePtrNode.write(mem, CFields.PyTypeObject__tp_richcompare, lookup(clazz, SlotMethodDef.TP_RICHCOMPARE));
    -        writePtrNode.write(mem, CFields.PyTypeObject__tp_iter, lookup(clazz, SlotMethodDef.TP_ITER));
             writePtrNode.write(mem, CFields.PyTypeObject__tp_iternext, lookup(clazz, SlotMethodDef.TP_ITERNEXT));
             writePtrNode.write(mem, CFields.PyTypeObject__tp_methods, nullValue);
             writePtrNode.write(mem, CFields.PyTypeObject__tp_members, nullValue);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    index 2930148360..e1ee0ed09a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    @@ -54,6 +54,7 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceNodes.LenNode;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -61,7 +62,6 @@
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.builtins.ListNodes.FastConstructListNode;
     import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    @@ -102,20 +102,20 @@ static HashingStorage doKeywords(@SuppressWarnings("unused") PNone iterable, PKe
                 return new KeywordsStorage(kwargs);
             }
     
    -        @Specialization(guards = {"isEmpty(kwargs)", "hasBuiltinDictIter(inliningTarget, dict, getClassNode, lookupIter)"})
    +        @Specialization(guards = {"isEmpty(kwargs)", "hasBuiltinDictIter(inliningTarget, dict, getClassNode, getSlots)"})
             static HashingStorage doPDict(PDict dict, @SuppressWarnings("unused") PKeyword[] kwargs,
                             @Bind("this") Node inliningTarget,
                             @SuppressWarnings("unused") @Shared @Cached GetClassNode.GetPythonObjectClassNode getClassNode,
    -                        @SuppressWarnings("unused") @Shared @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                        @SuppressWarnings("unused") @Shared @Cached GetCachedTpSlotsNode getSlots,
                             @Shared @Cached HashingStorageCopy copyNode) {
                 return copyNode.execute(inliningTarget, dict.getDictStorage());
             }
     
    -        @Specialization(guards = {"!isEmpty(kwargs)", "hasBuiltinDictIter(inliningTarget, dict, getClassNode, lookupIter)"})
    +        @Specialization(guards = {"!isEmpty(kwargs)", "hasBuiltinDictIter(inliningTarget, dict, getClassNode, getSlots)"})
             static HashingStorage doPDictKwargs(VirtualFrame frame, PDict dict, PKeyword[] kwargs,
                             @Bind("this") Node inliningTarget,
                             @SuppressWarnings("unused") @Shared @Cached GetClassNode.GetPythonObjectClassNode getClassNode,
    -                        @SuppressWarnings("unused") @Shared @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                        @SuppressWarnings("unused") @Shared @Cached GetCachedTpSlotsNode getSlots,
                             @Shared @Cached HashingStorageCopy copyNode,
                             @Exclusive @Cached HashingStorageAddAllToOther addAllToOther) {
                 HashingStorage iterableDictStorage = dict.getDictStorage();
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    index 47e8407cf0..e27059c22d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.contextvars;
     
     import static com.oracle.graal.python.nodes.PGuards.isNoValue;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     
     import java.util.List;
     
    @@ -106,7 +105,7 @@ Object get(PContextVarsContext self, Object key,
             }
         }
     
    -    @Builtin(name = J___ITER__, declaresExplicitSelf = true, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class Iter extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    index 6b2da34c1c..c93d764a81 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    @@ -40,16 +40,18 @@
      */
     package com.oracle.graal.python.builtins.objects.contextvars;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -62,12 +64,14 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.ContextIterator)
     public final class ContextIteratorBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = ContextIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ContextIteratorBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, declaresExplicitSelf = true, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class Iter extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    index 510afcc2f2..ce0c2c7880 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    @@ -57,7 +57,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -847,7 +846,7 @@ static void setOrDel(PDeque self, int idx, Object value,
         }
     
         // deque.__iter__()
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class DequeIterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    index f0db1b3b0b..8868cf0acc 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.deque;
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -51,11 +50,14 @@
     import java.util.NoSuchElementException;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -73,6 +75,7 @@
     
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PDequeIter, PythonBuiltinClassType.PDequeRevIter})
     public final class DequeIterBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = DequeIterBuiltinsSlotsGen.SLOTS;
     
         @Override
         protected List> getNodeFactories() {
    @@ -80,7 +83,7 @@ protected List> getNodeFa
         }
     
         // _deque_iterator.__iter__()
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class DequeIterIterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    index f043553da8..f12ad143cc 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    @@ -32,7 +32,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.KeyError;
    @@ -373,7 +372,7 @@ static void run(VirtualFrame frame, Object self, Object key, @SuppressWarnings("
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java
    index 010b4831f3..ad2262067f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictValuesBuiltins.java
    @@ -25,7 +25,6 @@
      */
     package com.oracle.graal.python.builtins.objects.dict;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     
     import java.util.List;
    @@ -86,7 +85,7 @@ static int run(PDictView self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    index 116d28e343..42ccc611ef 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -149,7 +148,7 @@ static int len(PDictView self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    index 1238532ef2..11a61a0b1c 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    @@ -26,18 +26,20 @@
     package com.oracle.graal.python.builtins.objects.enumerate;
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    @@ -55,6 +57,7 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PEnumerate)
     public final class EnumerateBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = EnumerateBuiltinsSlotsGen.SLOTS;
     
         @Override
         protected List> getNodeFactories() {
    @@ -77,7 +80,7 @@ static Object doNext(VirtualFrame frame, PEnumerate self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignIterableBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignIterableBuiltins.java
    index 647eee6b2f..f7e2711f0e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignIterableBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignIterableBuiltins.java
    @@ -26,14 +26,14 @@
     
     package com.oracle.graal.python.builtins.objects.foreign;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    -
     import java.util.List;
     
    -import com.oracle.graal.python.builtins.Builtin;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode;
    @@ -55,12 +55,14 @@
      */
     @CoreFunctions(extendClasses = PythonBuiltinClassType.ForeignIterable)
     public final class ForeignIterableBuiltins extends PythonBuiltins {
    +    public static final TpSlots SLOTS = ForeignIterableBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ForeignIterableBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinMethodDescriptors.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinMethodDescriptors.java
    deleted file mode 100644
    index 7a4aafab1c..0000000000
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/BuiltinMethodDescriptors.java
    +++ /dev/null
    @@ -1,58 +0,0 @@
    -/*
    - * Copyright (c) 2021, 2024, 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.builtins.objects.function;
    -
    -import static com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.get;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
    -
    -import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    -import com.oracle.graal.python.builtins.objects.dict.DictBuiltinsFactory;
    -
    -/**
    - * Enum-like class with some useful well known descriptors. Because of initialization order issues,
    - * these constants cannot be places in {@link BuiltinMethodDescriptor} class.
    - */
    -public abstract class BuiltinMethodDescriptors {
    -    public static final BuiltinMethodDescriptor DICT_ITER = get(J___ITER__, DictBuiltinsFactory.IterNodeFactory.getInstance(), PythonBuiltinClassType.PDict);
    -
    -    private BuiltinMethodDescriptors() {
    -    }
    -}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    index 7f49e23bd3..3afa1acb15 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    @@ -31,7 +31,6 @@
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___QUALNAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
    @@ -39,6 +38,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -49,6 +50,7 @@
     import com.oracle.graal.python.builtins.objects.function.PArguments;
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.bytecode.FrameInfo;
    @@ -80,6 +82,8 @@ private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseN
             }
         }
     
    +    public static final TpSlots SLOTS = GeneratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return GeneratorBuiltinsFactory.getFactories();
    @@ -129,7 +133,7 @@ static Object setQualname(PGenerator self, Object value,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    index bb0cd3889d..b7b2503ea7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    @@ -29,7 +29,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
     import static com.oracle.graal.python.nodes.ErrorMessages.DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -41,6 +40,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -62,6 +63,7 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
    @@ -115,6 +117,8 @@ public final class IteratorBuiltins extends PythonBuiltins {
          * class.
          */
     
    +    public static final TpSlots SLOTS = IteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return IteratorBuiltinsFactory.getFactories();
    @@ -355,7 +359,7 @@ static Object doSetKey(Node inliningTarget, @SuppressWarnings("unused") PBaseSet
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    index f48f59267f..908e7e49d9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    @@ -25,7 +25,6 @@
      */
     package com.oracle.graal.python.builtins.objects.iterator;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -33,12 +32,15 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -63,6 +65,8 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PZip)
     public final class PZipBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = PZipBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return PZipBuiltinsFactory.getFactories();
    @@ -123,7 +127,7 @@ static Object doNext(VirtualFrame frame, PZip self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    index a93f9c27ef..f50b9e0937 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    @@ -26,18 +26,20 @@
     package com.oracle.graal.python.builtins.objects.iterator;
     
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -59,6 +61,8 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PSentinelIterator)
     public final class SentinelIteratorBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = SentinelIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return SentinelIteratorBuiltinsFactory.getFactories();
    @@ -94,7 +98,7 @@ static Object doIterator(VirtualFrame frame, PSentinelIterator iterator,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    index 09d6d72a16..17e2693f35 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -48,6 +47,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -56,6 +57,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyNumberAddNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -77,12 +79,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PAccumulate})
     public final class AccumulateBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = AccumulateBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return AccumulateBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    index 09c0ffd1e8..e138c4c4ce 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.ARGUMENTS_MUST_BE_ITERATORS;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -52,6 +51,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -61,6 +62,7 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyIterCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -85,12 +87,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PChain})
     public final class ChainBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = ChainBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ChainBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    index 932733c7fc..b9ff327c99 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -52,6 +51,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -59,6 +60,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -86,12 +88,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PCombinations, PythonBuiltinClassType.PCombinationsWithReplacement})
     public final class CombinationsBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = CombinationsBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return CombinationsBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    index cb3238ec69..1ab4654ba3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    @@ -40,13 +40,14 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -54,6 +55,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -71,12 +73,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PCompress})
     public final class CompressBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = CompressBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return CompressBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    index 2fe6c53551..ee6ca228af 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.itertools;
     
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
    @@ -49,12 +48,15 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyNumberAddNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
    @@ -79,12 +81,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PCount})
     public final class CountBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = CountBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return CountBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    index 6562eb0817..dd31b5b712 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.ErrorMessages.STATE_ARGUMENT_D_MUST_BE_A_S;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -54,6 +53,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -65,6 +66,7 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectLookupAttr;
    @@ -91,12 +93,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PCycle})
     public final class CycleBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = CycleBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return CycleBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    index 3609a583f3..25d718235e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -51,6 +50,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -58,6 +59,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -81,12 +83,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PDropwhile})
     public final class DropwhileBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = DropwhileBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return DropwhileBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    index b34b55e78f..116aa35971 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    @@ -40,13 +40,14 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -54,6 +55,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -74,12 +76,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PFilterfalse})
     public final class FilterfalseBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = FilterfalseBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return FilterfalseBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    index 1b5ac87fba..6b398dd6cd 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -50,6 +49,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -58,6 +59,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -80,12 +82,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PGroupBy})
     public final class GroupByBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = GroupByBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return GroupByBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    index 80a5206723..f4565d9a54 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    @@ -41,13 +41,14 @@
     package com.oracle.graal.python.builtins.objects.itertools;
     
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -55,6 +56,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.nodes.BuiltinNames;
    @@ -77,12 +79,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PGrouper})
     public final class GrouperBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = GrouperBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return GrouperBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    index 8a1d726f33..cd0e7c1015 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -52,6 +51,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -59,6 +60,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -83,12 +85,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PIslice})
     public final class IsliceBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = IsliceBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return IsliceBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    index 1f0b789210..834be21c68 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    @@ -40,18 +40,20 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -69,12 +71,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PPairwise})
     public final class PairwiseBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = PairwiseBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return PairwiseBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    index 3500aa3628..3031b3467e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -53,6 +52,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -61,6 +62,7 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -87,12 +89,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PPermutations})
     public final class PermutationsBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = PermutationsBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return PermutationsBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    index 73e109e2ae..ced590cfb9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -48,6 +47,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -55,6 +56,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyLongAsIntNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -79,12 +81,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PProduct})
     public final class ProductBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = ProductBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ProductBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    index a5e805f45f..7f971389be 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.LEN_OF_UNSIZED_OBJECT;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -53,12 +52,15 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -81,12 +83,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PRepeat})
     public final class RepeatBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = RepeatBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return RepeatBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    index d656ba290c..c4803e4945 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    @@ -40,13 +40,14 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -55,6 +56,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -72,12 +74,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PStarmap})
     public final class StarmapBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = StarmapBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return StarmapBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    index fc50ba486f..5d9255b9bf 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    @@ -40,13 +40,14 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -54,6 +55,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -73,12 +75,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PTakewhile})
     public final class TakewhileBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = TakewhileBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return TakewhileBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    index 775263a32a..2d953e9a95 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    @@ -47,7 +47,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.INTEGER_REQUIRED_GOT;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___COPY__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -57,6 +56,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -66,6 +67,7 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
    @@ -91,6 +93,8 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PTee})
     public final class TeeBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = TeeBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return TeeBuiltinsFactory.getFactories();
    @@ -131,7 +135,7 @@ static Object copy(PTee self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    index ba82bf8630..74c04c8503 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.itertools;
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
    @@ -49,6 +48,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -56,6 +57,7 @@
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    @@ -77,12 +79,14 @@
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PZipLongest})
     public final class ZipLongestBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = ZipLongestBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ZipLongestBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    index 50bfc2b7f9..f6b8808acc 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java
    @@ -33,7 +33,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -1023,7 +1022,7 @@ boolean contains(VirtualFrame frame, Object self, Object other,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    index dd43ef47c1..201ddaf0c7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    @@ -40,19 +40,21 @@
      */
     package com.oracle.graal.python.builtins.objects.map;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -70,6 +72,8 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PMap)
     public final class MapBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = MapBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return MapBuiltinsFactory.getFactories();
    @@ -98,7 +102,7 @@ Object doNext(VirtualFrame frame, PMap self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    index 9849b061fb..b570de6cb3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/mappingproxy/MappingproxyBuiltins.java
    @@ -34,7 +34,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__;
    @@ -108,7 +107,7 @@ Object doPMappingproxy(PMappingproxy self, Object mapping) {
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java
    index ca6ad00107..4e65922ced 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java
    @@ -48,7 +48,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_VALUES;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
    @@ -478,7 +477,7 @@ static Object items(POrderedDict self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java
    index d54a72325c..51eb883711 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictItemsBuiltins.java
    @@ -40,17 +40,19 @@
      */
     package com.oracle.graal.python.builtins.objects.ordereddict;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemsView;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -61,12 +63,15 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.POrderedDictItems)
     public class OrderedDictItemsBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = OrderedDictItemsBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return OrderedDictItemsBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    index cf5dc45c52..5fa9dc56e4 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    @@ -44,13 +44,14 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -58,6 +59,7 @@
     import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes;
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -76,12 +78,15 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.POrderedDictIterator)
     public class OrderedDictIteratorBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = OrderedDictIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return OrderedDictIteratorBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java
    index 0863121e61..be0eb506e2 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictKeysBuiltins.java
    @@ -40,17 +40,19 @@
      */
     package com.oracle.graal.python.builtins.objects.ordereddict;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeysView;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -61,12 +63,15 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.POrderedDictKeys)
     public class OrderedDictKeysBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = OrderedDictKeysBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return OrderedDictKeysBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java
    index 0d362211a6..8c5699fa6e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictValuesBuiltins.java
    @@ -40,17 +40,19 @@
      */
     package com.oracle.graal.python.builtins.objects.ordereddict;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValuesView;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -61,12 +63,15 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.POrderedDictValues)
     public class OrderedDictValuesBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = OrderedDictValuesBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return OrderedDictValuesBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    index 75dcd10d55..71ae05ca9f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    @@ -42,17 +42,19 @@
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ENTER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EXIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PConstructAndRaiseNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -79,6 +81,8 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PScandirIterator)
     public final class ScandirIteratorBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = ScandirIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ScandirIteratorBuiltinsFactory.getFactories();
    @@ -95,7 +99,7 @@ PNone close(PScandirIterator self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    index 87e2159a4e..de696e50f1 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    @@ -32,7 +32,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.RANGE_OUT_OF_BOUNDS;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
    @@ -242,7 +241,7 @@ boolean doPBigRange(PBigRange self) {
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    index c7fc519f6e..a4b3afc232 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    @@ -26,7 +26,6 @@
     package com.oracle.graal.python.builtins.objects.reversed;
     
     import static com.oracle.graal.python.nodes.ErrorMessages.OBJ_HAS_NO_LEN;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -37,6 +36,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -45,6 +46,7 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceNodes;
     import com.oracle.graal.python.builtins.objects.iterator.PBuiltinIterator;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
     import com.oracle.graal.python.lib.PySequenceGetItemNode;
    @@ -76,6 +78,8 @@ public final class ReversedBuiltins extends PythonBuiltins {
          * class.
          */
     
    +    public static final TpSlots SLOTS = ReversedBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return ReversedBuiltinsFactory.getFactories();
    @@ -121,7 +125,7 @@ static Object next(PStringReverseIterator self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    index 41db9626db..3bd6acfa8c 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
    @@ -190,7 +189,7 @@ public static Object repr(VirtualFrame frame, PBaseSet self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         protected abstract static class BaseIterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    index e59806c794..8aef54caa5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -2452,7 +2451,7 @@ static TruffleString doString(VirtualFrame frame, Object self, Object idx,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    index d0ab50aa91..234d02e140 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    @@ -7,7 +7,6 @@
     
     import static com.oracle.graal.python.builtins.objects.struct.StructBuiltins.unpackInternal;
     import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_CREATE_P_OBJECTS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    @@ -15,6 +14,8 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -22,6 +23,7 @@
     import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.iterator.PStructUnpackIterator;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
    @@ -39,6 +41,9 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PStructUnpackIterator)
     public class StructUnpackIteratorBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = StructUnpackIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return StructUnpackIteratorBuiltinsFactory.getFactories();
    @@ -54,7 +59,7 @@ static Object createNew(Object type, @SuppressWarnings("unused") Object[] args,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    index a1ea04b3fa..6eaf32df4e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.tokenize;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
     import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
    @@ -48,11 +47,14 @@
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -70,12 +72,14 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PTokenizerIter)
     public final class TokenizerIterBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = TokenizerIterBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return TokenizerIterBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    index 6563c5ab48..768cb79838 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java
    @@ -31,7 +31,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__;
    @@ -500,7 +499,7 @@ boolean contains(VirtualFrame frame, Object self, Object other,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         public abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization(guards = {"isIntStorage(primary)"})
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    index f46ae14faa..0a8eeb2797 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    @@ -68,7 +68,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INSTANCECHECK__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LT__;
    @@ -152,7 +151,6 @@
     public enum SpecialMethodSlot {
         Dict(T___DICT__),
     
    -    Iter(T___ITER__),
         Next(T___NEXT__),
         Await(T___AWAIT__, AM_AWAIT),
     
    @@ -752,11 +750,6 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin
                         return Dict;
                     }
                     break;
    -            case 'i' * 26 + 't':    // it
    -                if (eqNode.execute(name, T___ITER__, TS_ENCODING)) {
    -                    return Iter;
    -                }
    -                break;
                 case 'n' * 26 + 'e':    // ne
                     if (eqNode.execute(name, T___NEXT__, TS_ENCODING)) {
                         return Next;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    index b07754fb17..ad4732c983 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    @@ -69,6 +69,7 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__;
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LEN__;
    @@ -315,6 +316,7 @@ public record TpSlots(TpSlot nb_bool, //
                     TpSlot tp_setattro, //
                     TpSlot tp_setattr,
                     TpSlot combined_tp_setattro_setattr,
    +                TpSlot tp_iter, //
                     boolean has_as_number,
                     boolean has_as_sequence,
                     boolean has_as_mapping) {
    @@ -827,7 +829,15 @@ public enum TpSlotMeta {
                             TpSlotGroup.NO_GROUP,
                             CFields.PyTypeObject__tp_setattr,
                             PExternalFunctionWrapper.SETATTR,
    -                        new NativeWrapperFactory.ShouldNotReach("tp_setattr"));
    +                        new NativeWrapperFactory.ShouldNotReach("tp_setattr")),
    +        TP_ITER(
    +                        TpSlots::tp_iter,
    +                        TpSlotPythonSingle.class,
    +                        TpSlotUnaryFuncBuiltin.class,
    +                        TpSlotGroup.NO_GROUP,
    +                        CFields.PyTypeObject__tp_iter,
    +                        PExternalFunctionWrapper.UNARYFUNC,
    +                        UnaryFuncWrapper::new);
     
             public static final TpSlotMeta[] VALUES = values();
     
    @@ -1007,6 +1017,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl
             addSlotDef(s, TpSlotMeta.TP_DESCR_SET, //
                             TpSlotDef.withoutHPy(T___SET__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_SET), //
                             TpSlotDef.withoutHPy(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE));
    +        addSlotDef(s, TpSlotMeta.TP_ITER, TpSlotDef.withSimpleFunction(T___ITER__, PExternalFunctionWrapper.UNARYFUNC));
             addSlotDef(s, TpSlotMeta.NB_ADD,
                             TpSlotDef.withoutHPy(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L),
                             TpSlotDef.withoutHPy(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R));
    @@ -1726,6 +1737,7 @@ public TpSlots build() {
                                 get(TpSlotMeta.TP_SETATTRO),
                                 get(TpSlotMeta.TP_SETATTR),
                                 tp_set_attro_attr,
    +                            get(TpSlotMeta.TP_ITER), //
                                 hasGroup(TpSlotGroup.AS_NUMBER),
                                 hasGroup(TpSlotGroup.AS_SEQUENCE),
                                 hasGroup(TpSlotGroup.AS_MAPPING));
    @@ -1820,6 +1832,10 @@ public final TpSlots executeCached(Object pythonObject) {
                 return execute(this, pythonObject);
             }
     
    +        public static TpSlots executeUncached(Object pythonObject) {
    +            return GetObjectSlotsNodeGen.getUncached().execute(null, pythonObject);
    +        }
    +
             @NeverDefault
             public static GetObjectSlotsNode create() {
                 return GetObjectSlotsNodeGen.create();
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java
    index f4c492f342..45ad0e9195 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java
    @@ -59,7 +59,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___MRO_ENTRIES__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
    @@ -436,7 +435,7 @@ static Object get(PGenericAlias self,
             }
         }
     
    -    @Builtin(name = J___ITER__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iter, isComplex = true)
         @GenerateNodeFactory
         abstract static class IterNode extends PythonUnaryBuiltinNode {
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java
    index cd265a0b03..87b90d48cb 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericTypeNodes.java
    @@ -59,7 +59,7 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
     import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    @@ -73,7 +73,6 @@
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.object.IsNode;
    @@ -324,7 +323,7 @@ private static Object subsTvars(Object obj, PTuple parameters, Object[] argitems
                         // TypeVarTuple
                         if (arg instanceof PTuple tuple1) {
                             Object paramType = GetClassNode.executeUncached(param);
    -                        if (LookupCallableSlotInMRONode.getUncached(SpecialMethodSlot.Iter).execute(paramType) != PNone.NO_VALUE) {
    +                        if (GetObjectSlotsNode.executeUncached(paramType).tp_iter() != null) {
                                 listExtend(subargs, tuple1);
                             }
                         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java
    index 3c800f40a5..8f76c8c9cd 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectGetIter.java
    @@ -43,15 +43,13 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     
     import com.oracle.graal.python.PythonLanguage;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.range.PIntRange;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.CallSlotUnaryNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
     import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.dsl.Bind;
    @@ -59,10 +57,10 @@
     import com.oracle.truffle.api.dsl.GenerateCached;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
    -import com.oracle.truffle.api.dsl.ImportStatic;
     import com.oracle.truffle.api.dsl.NeverDefault;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.Frame;
    +import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
     
     /**
    @@ -71,7 +69,6 @@
     @GenerateUncached
     @GenerateCached
     @GenerateInline(inlineByDefault = true)
    -@ImportStatic(SpecialMethodSlot.class)
     public abstract class PyObjectGetIter extends Node {
         public static Object executeUncached(Object obj) {
             return PyObjectGetIterNodeGen.getUncached().execute(null, null, obj);
    @@ -91,31 +88,25 @@ static Object getIterRange(PIntRange object,
     
         @Specialization
         @InliningCutoff
    -    static Object getIter(Frame frame, Node inliningTarget, Object receiver,
    +    static Object getIter(VirtualFrame frame, Node inliningTarget, Object receiver,
                         @Cached GetClassNode getReceiverClass,
    -                    @Cached(parameters = "Iter", inline = false) LookupSpecialMethodSlotNode lookupIter,
    +                    @Cached GetCachedTpSlotsNode getSlots,
                         @Cached PySequenceCheckNode sequenceCheckNode,
    -                    @Bind PythonLanguage language,
                         @Cached PRaiseNode raise,
    -                    @Cached(inline = false) CallUnaryMethodNode callIter,
    +                    @Cached CallSlotUnaryNode callSlot,
                         @Cached PyIterCheckNode checkNode) {
             Object type = getReceiverClass.execute(inliningTarget, receiver);
    -        Object iterMethod = PNone.NO_VALUE;
    -        try {
    -            iterMethod = lookupIter.execute(frame, type, receiver);
    -        } catch (PException e) {
    -            // ignore
    -        }
    -        if (iterMethod instanceof PNone) {
    -            if (sequenceCheckNode.execute(inliningTarget, receiver)) {
    -                return PFactory.createSequenceIterator(language, receiver);
    -            }
    -        } else {
    -            Object result = callIter.executeObject(frame, iterMethod, receiver);
    +        TpSlots slots = getSlots.execute(inliningTarget, type);
    +        if (slots.tp_iter() != null) {
    +            Object result = callSlot.execute(frame, inliningTarget, slots.tp_iter(), receiver);
                 if (!checkNode.execute(inliningTarget, result)) {
                     throw raise.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NONITER, result);
                 }
                 return result;
    +        } else {
    +            if (sequenceCheckNode.execute(inliningTarget, receiver)) {
    +                return PFactory.createSequenceIterator(PythonLanguage.get(inliningTarget), receiver);
    +            }
             }
             throw raise.raise(inliningTarget, TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver);
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java
    index 77e3587a07..9728f7af4d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java
    @@ -65,6 +65,7 @@
     import com.oracle.graal.python.builtins.objects.common.HashingStorage;
     import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
     import com.oracle.graal.python.builtins.objects.complex.PComplex;
    +import com.oracle.graal.python.builtins.objects.dict.DictBuiltins;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.dict.PDictView;
     import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis;
    @@ -74,7 +75,6 @@
     import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.BinaryBuiltinDescriptor;
     import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.TernaryBuiltinDescriptor;
     import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor.UnaryBuiltinDescriptor;
    -import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptors;
     import com.oracle.graal.python.builtins.objects.function.PArguments;
     import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
     import com.oracle.graal.python.builtins.objects.function.PFunction;
    @@ -101,9 +101,9 @@
     import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
     import com.oracle.graal.python.builtins.objects.type.PythonClass;
     import com.oracle.graal.python.builtins.objects.type.PythonManagedClass;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.sequence.PSequence;
    @@ -715,7 +715,7 @@ public static boolean isNullOrZero(Object value, InteropLibrary lib) {
         }
     
         /* CPython tests that tp_iter is dict_iter */
    -    public static boolean hasBuiltinDictIter(Node inliningTarget, PDict dict, GetPythonObjectClassNode getClassNode, LookupCallableSlotInMRONode lookupIter) {
    -        return isBuiltinDict(dict) || lookupIter.execute(getClassNode.execute(inliningTarget, dict)) == BuiltinMethodDescriptors.DICT_ITER;
    +    public static boolean hasBuiltinDictIter(Node inliningTarget, PDict dict, GetPythonObjectClassNode getClassNode, GetCachedTpSlotsNode getSlots) {
    +        return isBuiltinDict(dict) || getSlots.execute(inliningTarget, getClassNode.execute(inliningTarget, dict)).tp_iter() == DictBuiltins.SLOTS.tp_iter();
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ConcatDictToStorageNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ConcatDictToStorageNode.java
    index 6fa89a74ea..e51aa1bcef 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ConcatDictToStorageNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/ConcatDictToStorageNode.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2023, 2025, 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
    @@ -49,12 +49,12 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PGuards;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.builtins.ListNodes;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
    @@ -64,6 +64,7 @@
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.Cached.Exclusive;
    +import com.oracle.truffle.api.dsl.Cached.Shared;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
     import com.oracle.truffle.api.dsl.Specialization;
    @@ -78,20 +79,20 @@
     public abstract class ConcatDictToStorageNode extends PNodeWithContext {
         public abstract HashingStorage execute(VirtualFrame frame, HashingStorage dest, Object other) throws SameDictKeyException, NonMappingException;
     
    -    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, other, getClassNode, lookupIter)", limit = "1")
    +    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, other, getClassNode, getSlots)", limit = "1")
         static HashingStorage doBuiltinDictEmptyDest(@SuppressWarnings("unused") EmptyStorage dest, PDict other,
                         @Bind("this") Node inliningTarget,
                         @SuppressWarnings("unused") @Exclusive @Cached GetPythonObjectClassNode getClassNode,
    -                    @SuppressWarnings("unused") @Cached.Shared("lookupIter") @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                    @SuppressWarnings("unused") @Shared @Cached GetCachedTpSlotsNode getSlots,
                         @Cached HashingStorageNodes.HashingStorageCopy copyNode) {
             return copyNode.execute(inliningTarget, other.getDictStorage());
         }
     
    -    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, other, getClassNode, lookupIter)", limit = "1")
    +    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, other, getClassNode, getSlots)", limit = "1")
         static HashingStorage doBuiltinDict(VirtualFrame frame, HashingStorage dest, PDict other,
                         @Bind("this") Node inliningTarget,
                         @SuppressWarnings("unused") @Exclusive @Cached GetPythonObjectClassNode getClassNode,
    -                    @SuppressWarnings("unused") @Cached.Shared("lookupIter") @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                    @SuppressWarnings("unused") @Shared @Cached GetCachedTpSlotsNode getSlots,
                         @Exclusive @Cached HashingStorageNodes.HashingStorageGetItem resultGetItem,
                         @Exclusive @Cached HashingStorageNodes.HashingStorageSetItem resultSetItem,
                         @Cached HashingStorageNodes.HashingStorageGetIterator getIterator,
    @@ -118,15 +119,15 @@ static HashingStorage doBuiltinDict(VirtualFrame frame, HashingStorage dest, PDi
         }
     
         // Not using @Fallback because of GR-43912
    -    static boolean isFallback(Node inliningTarget, Object other, GetPythonObjectClassNode getClassNode, LookupCallableSlotInMRONode lookupIter) {
    -        return !(other instanceof PDict otherDict && PGuards.hasBuiltinDictIter(inliningTarget, otherDict, getClassNode, lookupIter));
    +    static boolean isFallback(Node inliningTarget, Object other, GetPythonObjectClassNode getClassNode, GetCachedTpSlotsNode getSlots) {
    +        return !(other instanceof PDict otherDict && PGuards.hasBuiltinDictIter(inliningTarget, otherDict, getClassNode, getSlots));
         }
     
    -    @Specialization(guards = "isFallback(inliningTarget, other, getClassNode, lookupIter)", limit = "1")
    +    @Specialization(guards = "isFallback(inliningTarget, other, getClassNode, getSlots)", limit = "1")
         static HashingStorage doMapping(VirtualFrame frame, HashingStorage dest, Object other,
                         @Bind("this") Node inliningTarget,
                         @SuppressWarnings("unused") @Exclusive @Cached GetPythonObjectClassNode getClassNode,
    -                    @SuppressWarnings("unused") @Cached.Shared("lookupIter") @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
    +                    @SuppressWarnings("unused") @Shared @Cached GetCachedTpSlotsNode getSlots,
                         @Exclusive @Cached InlinedBranchProfile sameKeyProfile,
                         @Exclusive @Cached StringNodes.CastToTruffleStringCheckedNode castToStringNode,
                         @Cached PyObjectCallMethodObjArgs callKeys,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java
    index 23206eb134..8075f04481 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/MappingToKeywordsNode.java
    @@ -50,10 +50,10 @@
     import com.oracle.graal.python.builtins.objects.common.KeywordsStorage;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
     import com.oracle.graal.python.nodes.util.CannotCastException;
     import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
    @@ -81,10 +81,10 @@ public abstract class MappingToKeywordsNode extends PNodeWithContext {
     
         public abstract PKeyword[] execute(VirtualFrame frame, Node inliningTarget, Object starargs) throws SameDictKeyException, NonMappingException;
     
    -    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, starargs, getClassNode, lookupIter)", limit = "1")
    +    @Specialization(guards = "hasBuiltinDictIter(inliningTarget, starargs, getClassNode, getSlots)", limit = "1")
         public static PKeyword[] doDict(VirtualFrame frame, Node inliningTarget, PDict starargs,
                         @SuppressWarnings("unused") @Cached GetPythonObjectClassNode getClassNode,
    -                    @SuppressWarnings("unused") @Cached(parameters = "Iter", inline = false) LookupCallableSlotInMRONode lookupIter,
    +                    @SuppressWarnings("unused") @Cached GetCachedTpSlotsNode getSlots,
                         @Exclusive @Cached HashingStorageToKeywords convert) {
             return convert.execute(frame, inliningTarget, starargs.getDictStorage());
         }
    @@ -157,7 +157,6 @@ static PKeyword[] doEmptyStorage(@SuppressWarnings("unused") EmptyStorage storag
     
             @Specialization(guards = {"!isKeywordsStorage(storage)", "!isEmptyStorage(storage)"})
             static PKeyword[] doCached(VirtualFrame frame, Node inliningTarget, HashingStorage storage,
    -                        @SuppressWarnings("unused") @Cached(parameters = "Iter", inline = false) LookupCallableSlotInMRONode lookupIter,
                             @Cached(inline = false) AddKeywordNode addKeywordNode,
                             @Cached HashingStorageNodes.HashingStorageForEach forEachNode,
                             @SuppressWarnings("unused") @Cached HashingStorageLen lenNode,
    
    From 9c88eca7f610459d619e22a23f6bba35a2838a13 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 24 Feb 2025 15:31:52 +0100
    Subject: [PATCH 105/512] Add test for tp_iter and tp_iternext calls
    
    ---
     .../src/tests/cpyext/test_tp_slots.py         | 52 +++++++++++++++++++
     1 file changed, 52 insertions(+)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    index 7abbedb073..fd778a5efa 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    @@ -1456,3 +1456,55 @@ def __delitem__(self, key):
             assert get_delegate(obj) == {'a': 1}
             del obj['a']
             assert not bool(obj)
    +
    +
    +def test_tp_slot_calls():
    +    NativeSlotProxy = CPyExtType(
    +        name='TpSlotProxy',
    +        cmembers='PyObject* delegate;',
    +        code=r'''
    +            typedef TpSlotProxyObject ProxyObject;
    +            static PyObject* get_delegate(PyObject* self) {
    +                return ((ProxyObject*)self)->delegate;
    +            }
    +            static PyObject* proxy_tp_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
    +                PyObject* delegate;
    +                if (!PyArg_UnpackTuple(args, "NativeTpSlotProxy", 0, 1, &delegate))
    +                    return NULL;
    +                ProxyObject* obj = (ProxyObject*)type->tp_alloc(type, 0);
    +                if (!obj)
    +                    return NULL;
    +                obj->delegate = Py_NewRef(delegate);  // leaked
    +                return (PyObject*)obj;
    +            }
    +            static PyObject* proxy_tp_iter(PyObject* self) {
    +                PyObject* delegate = get_delegate(self);
    +                return Py_TYPE(delegate)->tp_iter(delegate);
    +            }
    +            static PyObject* proxy_tp_iternext(PyObject* self) {
    +                PyObject* delegate = get_delegate(self);
    +                return Py_TYPE(delegate)->tp_iternext(delegate);
    +            }
    +        ''',
    +        tp_new='proxy_tp_new',
    +        tp_members='{"delegate", T_OBJECT, offsetof(ProxyObject, delegate), 0, NULL}',
    +        tp_iter='proxy_tp_iter',
    +        tp_iternext='proxy_tp_iternext',
    +    )
    +
    +    class PureSlotProxy:
    +        def __init__(self, delegate):
    +            self.delegate = delegate
    +
    +        def __iter__(self):
    +            return iter(self.delegate)
    +
    +        def __next__(self):
    +            return next(self.delegate)
    +
    +    for obj in [NativeSlotProxy([1]), NativeSlotProxy(PureSlotProxy([1]))]:
    +        assert isinstance(iter(obj), type(iter([])))
    +
    +    for obj in [NativeSlotProxy(iter([1])), NativeSlotProxy(PureSlotProxy(iter([1])))]:
    +        assert next(obj) == 1
    +        assert_raises(StopIteration, next, obj)
    
    From 7faf58aafed21c22755ec61aea1a5ed975ca17c7 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Wed, 26 Feb 2025 14:29:25 +0100
    Subject: [PATCH 106/512] Add tp_iternext slot
    
    ---
     .../oracle/graal/python/annotations/Slot.java |   4 +-
     .../graal/python/processor/SlotsMapping.java  |   3 +-
     .../python/test/datatype/PRangeTests.java     |   5 +-
     .../builtins/PythonBuiltinClassType.java      |  17 +-
     .../builtins/modules/BuiltinFunctions.java    |  58 ++---
     .../builtins/modules/GcModuleBuiltins.java    |   8 +-
     .../builtins/modules/ast/Obj2SstBase.java     |   3 +-
     .../cext/PythonCextAbstractBuiltins.java      |  40 ++--
     .../modules/csv/CSVReaderBuiltins.java        |   8 +-
     .../io/BufferedReaderMixinBuiltins.java       |  18 +-
     .../builtins/modules/io/BytesIOBuiltins.java  |  15 +-
     .../builtins/modules/io/IOBaseBuiltins.java   |  11 +-
     .../builtins/modules/io/StringIOBuiltins.java |  16 +-
     .../modules/io/TextIOWrapperBuiltins.java     |  18 +-
     .../builtins/modules/pickle/PPickler.java     |  11 +-
     .../builtins/modules/pickle/PUnpickler.java   |   3 +-
     .../objects/asyncio/AsyncGenSendBuiltins.java |   6 +-
     .../asyncio/AsyncGenThrowBuiltins.java        |   6 +-
     .../asyncio/CoroutineWrapperBuiltins.java     |   7 +-
     .../objects/cext/capi/PyProcsWrapper.java     |  49 ++++
     .../objects/cext/capi/SlotMethodDef.java      |   3 -
     .../objects/cext/capi/ToNativeTypeNode.java   |   1 -
     .../objects/common/HashingStorage.java        |   4 +-
     .../objects/common/SequenceStorageNodes.java  |  28 +--
     .../contextvars/ContextIteratorBuiltins.java  |  17 +-
     .../objects/deque/DequeIterBuiltins.java      |   8 +-
     .../objects/enumerate/EnumerateBuiltins.java  |  13 +-
     .../objects/generator/GeneratorBuiltins.java  |  13 +-
     .../objects/iterator/IteratorBuiltins.java    | 112 ++++-----
     .../objects/iterator/PZipBuiltins.java        |  12 +-
     .../iterator/SentinelIteratorBuiltins.java    |  16 +-
     .../objects/itertools/AccumulateBuiltins.java |  15 +-
     .../objects/itertools/ChainBuiltins.java      |  43 ++--
     .../itertools/CombinationsBuiltins.java       |  24 +-
     .../objects/itertools/CompressBuiltins.java   |  41 +++-
     .../objects/itertools/CountBuiltins.java      |   6 +-
     .../objects/itertools/CycleBuiltins.java      |  25 +-
     .../objects/itertools/DropwhileBuiltins.java  |  34 ++-
     .../itertools/FilterfalseBuiltins.java        |  61 ++---
     .../objects/itertools/GroupByBuiltins.java    |  15 +-
     .../objects/itertools/GrouperBuiltins.java    |  15 +-
     .../objects/itertools/IsliceBuiltins.java     |  72 +++---
     .../builtins/objects/itertools/PGroupBy.java  |  13 +-
     .../objects/itertools/PTeeDataObject.java     |  11 +-
     .../objects/itertools/PairwiseBuiltins.java   |  55 +++--
     .../itertools/PermutationsBuiltins.java       |  17 +-
     .../objects/itertools/ProductBuiltins.java    |  18 +-
     .../objects/itertools/RepeatBuiltins.java     |  13 +-
     .../objects/itertools/StarmapBuiltins.java    |  16 +-
     .../objects/itertools/TakewhileBuiltins.java  |  23 +-
     .../objects/itertools/TeeBuiltins.java        |  12 +-
     .../objects/itertools/ZipLongestBuiltins.java |  49 ++--
     .../builtins/objects/map/MapBuiltins.java     |  23 +-
     .../OrderedDictIteratorBuiltins.java          |   9 +-
     .../posix/ScandirIteratorBuiltins.java        |  16 +-
     .../objects/reversed/ReversedBuiltins.java    |  23 +-
     .../struct/StructUnpackIteratorBuiltins.java  |  17 +-
     .../tokenize/TokenizerIterBuiltins.java       |   7 +-
     .../python/builtins/objects/type/TpSlots.java |  35 ++-
     .../objects/type/slots/TpSlotIterNext.java    | 221 ++++++++++++++++++
     .../types/GenericAliasIteratorBuiltins.java   |  17 +-
     .../oracle/graal/python/lib/GetNextNode.java  | 138 ++---------
     .../graal/python/lib/PyIterCheckNode.java     |  21 +-
     .../graal/python/lib/PyIterNextNode.java      |  63 ++---
     .../python/nodes/bytecode/ForIterINode.java   |  47 +---
     .../python/nodes/bytecode/ForIterONode.java   |  35 +--
     .../graal/python/nodes/bytecode/SendNode.java |  33 ++-
     67 files changed, 985 insertions(+), 831 deletions(-)
     create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotIterNext.java
    
    diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    index d499f16354..a7bee38dee 100644
    --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java
    @@ -194,7 +194,9 @@ enum SlotKind {
             /** set/delete object attribute */
             tp_setattro("__setattr__, __delattr__"),
             /** iter(obj) */
    -        tp_iter("__iter__");
    +        tp_iter("__iter__"),
    +        /** next(obj) */
    +        tp_iternext("__next__");
     
             SlotKind(@SuppressWarnings("unused") String specialMethods) {
             }
    diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    index c84fe9e7ab..c3e8797341 100644
    --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java
    @@ -76,6 +76,7 @@ static String getSlotBaseClass(Slot s) {
                 case tp_descr_get -> "TpSlotDescrGet.TpSlotDescrGetBuiltin" + getSuffix(s.isComplex());
                 case tp_descr_set -> "TpSlotDescrSet.TpSlotDescrSetBuiltin";
                 case tp_setattro -> "TpSlotSetAttr.TpSlotSetAttrBuiltin";
    +            case tp_iternext -> "TpSlotIterNext.TpSlotIterNextBuiltin";
             };
         }
     
    @@ -84,7 +85,7 @@ static String getSlotNodeBaseClass(Slot s) {
                 case tp_descr_get -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode";
                 case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode";
                 case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert,
    -                            tp_iter ->
    +                            tp_iter, tp_iternext ->
                     "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode";
                 case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or,
                                 nb_floor_divide, nb_true_divide, nb_matrix_multiply ->
    diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    index d8448fe7aa..717b38f0f4 100644
    --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    @@ -35,6 +35,7 @@
     import com.oracle.graal.python.builtins.objects.range.PRange;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    +import com.oracle.graal.python.nodes.PGuards;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -75,7 +76,7 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
     
                 while (true) {
                     try {
    -                    int item = next.executeInt(null, iter);
    +                    int item = PGuards.expectInteger(next.execute(null, iter));
                         assertEquals(index, item);
                     } catch (PException e) {
                         e.expectStopIteration(null, errorProfile);
    @@ -103,7 +104,7 @@ public void loopWithStep() throws UnexpectedResultException {
     
                 while (true) {
                     try {
    -                    int item = next.executeInt(null, iter);
    +                    int item = PGuards.expectInteger(next.execute(null, iter));
                         assertEquals(index, item);
                     } catch (PException e) {
                         e.expectStopIteration(null, errorProfile);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    index ff738e807f..15abaf44ef 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    @@ -123,7 +123,11 @@
     import com.oracle.graal.python.builtins.modules.ctypes.SimpleCDataBuiltins;
     import com.oracle.graal.python.builtins.modules.ctypes.StgDictBuiltins;
     import com.oracle.graal.python.builtins.modules.functools.LruCacheWrapperBuiltins;
    +import com.oracle.graal.python.builtins.modules.io.BufferedReaderMixinBuiltins;
    +import com.oracle.graal.python.builtins.modules.io.BytesIOBuiltins;
     import com.oracle.graal.python.builtins.modules.io.IOBaseBuiltins;
    +import com.oracle.graal.python.builtins.modules.io.StringIOBuiltins;
    +import com.oracle.graal.python.builtins.modules.io.TextIOWrapperBuiltins;
     import com.oracle.graal.python.builtins.objects.NoneBuiltins;
     import com.oracle.graal.python.builtins.objects.array.ArrayBuiltins;
     import com.oracle.graal.python.builtins.objects.asyncio.AsyncGenSendBuiltins;
    @@ -212,6 +216,7 @@
     import com.oracle.graal.python.builtins.objects.type.TpSlots.Builder;
     import com.oracle.graal.python.builtins.objects.type.TypeBuiltins;
     import com.oracle.graal.python.builtins.objects.types.GenericAliasBuiltins;
    +import com.oracle.graal.python.builtins.objects.types.GenericAliasIteratorBuiltins;
     import com.oracle.graal.python.builtins.objects.types.UnionTypeBuiltins;
     import com.oracle.graal.python.runtime.PythonContext;
     import com.oracle.truffle.api.CompilerAsserts;
    @@ -317,7 +322,7 @@ public enum PythonBuiltinClassType implements TruffleObject {
         Super("super", J_BUILTINS, SuperBuiltins.SLOTS),
         PCode("code", Flags.PRIVATE_DERIVED_WODICT),
         PGenericAlias("GenericAlias", J_TYPES, Flags.PUBLIC_BASE_WODICT, GENERIC_ALIAS_M_FLAGS, GenericAliasBuiltins.SLOTS),
    -    PGenericAliasIterator("generic_alias_iterator", Flags.PRIVATE_DERIVED_WODICT),
    +    PGenericAliasIterator("generic_alias_iterator", Flags.PRIVATE_DERIVED_WODICT, GenericAliasIteratorBuiltins.SLOTS),
         PUnionType("UnionType", J_TYPES, Flags.PUBLIC_DERIVED_WODICT, UNION_TYPE_M_FLAGS, UnionTypeBuiltins.SLOTS),
         PZip("zip", J_BUILTINS, PZipBuiltins.SLOTS),
         PThread("start_new_thread", J__THREAD),
    @@ -367,15 +372,15 @@ public enum PythonBuiltinClassType implements TruffleObject {
         PRawIOBase("_RawIOBase", "_io", IOBaseBuiltins.SLOTS),
         PTextIOBase("_TextIOBase", "_io", IOBaseBuiltins.SLOTS),
         PBufferedIOBase("_BufferedIOBase", "_io", IOBaseBuiltins.SLOTS),
    -    PBufferedReader("BufferedReader", "_io", Flags.PUBLIC_BASE_WDICT),
    +    PBufferedReader("BufferedReader", "_io", Flags.PUBLIC_BASE_WDICT, BufferedReaderMixinBuiltins.SLOTS),
         PBufferedWriter("BufferedWriter", "_io", Flags.PUBLIC_BASE_WDICT),
         PBufferedRWPair("BufferedRWPair", "_io", Flags.PUBLIC_BASE_WDICT),
    -    PBufferedRandom("BufferedRandom", "_io", Flags.PUBLIC_BASE_WDICT),
    +    PBufferedRandom("BufferedRandom", "_io", Flags.PUBLIC_BASE_WDICT, BufferedReaderMixinBuiltins.SLOTS),
         PFileIO("FileIO", "_io", Flags.PUBLIC_BASE_WDICT),
    -    PTextIOWrapper("TextIOWrapper", "_io", Flags.PUBLIC_BASE_WDICT),
    +    PTextIOWrapper("TextIOWrapper", "_io", Flags.PUBLIC_BASE_WDICT, TextIOWrapperBuiltins.SLOTS),
         PIncrementalNewlineDecoder("IncrementalNewlineDecoder", "_io", Flags.PUBLIC_BASE_WODICT),
    -    PStringIO("StringIO", "_io", Flags.PUBLIC_BASE_WDICT),
    -    PBytesIO("BytesIO", "_io", Flags.PUBLIC_BASE_WDICT),
    +    PStringIO("StringIO", "_io", Flags.PUBLIC_BASE_WDICT, StringIOBuiltins.SLOTS),
    +    PBytesIO("BytesIO", "_io", Flags.PUBLIC_BASE_WDICT, BytesIOBuiltins.SLOTS),
         PBytesIOBuf("_BytesIOBuffer", "_io", Flags.PRIVATE_BASE_WODICT),
     
         PStatResult("stat_result", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS),
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    index 721debf322..f92e29b1a6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    @@ -27,6 +27,7 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.DeprecationWarning;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
    +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SyntaxError;
     import static com.oracle.graal.python.builtins.modules.io.IONodes.T_FLUSH;
     import static com.oracle.graal.python.builtins.modules.io.IONodes.T_WRITE;
    @@ -84,7 +85,6 @@
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DICT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FORMAT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MRO_ENTRIES__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROUND__;
     import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
     import static com.oracle.graal.python.nodes.StringLiterals.T_FALSE;
    @@ -156,16 +156,21 @@
     import com.oracle.graal.python.builtins.objects.object.PythonObject;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.compiler.Compiler;
     import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyCallableCheckNode;
     import com.oracle.graal.python.lib.PyEvalGetGlobals;
     import com.oracle.graal.python.lib.PyEvalGetLocals;
    +import com.oracle.graal.python.lib.PyIterCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyMappingCheckNode;
     import com.oracle.graal.python.lib.PyNumberAbsoluteNode;
     import com.oracle.graal.python.lib.PyNumberAddNode;
    @@ -288,7 +293,6 @@
     import com.oracle.truffle.api.nodes.Node;
     import com.oracle.truffle.api.nodes.RootNode;
     import com.oracle.truffle.api.nodes.UnexpectedResultException;
    -import com.oracle.truffle.api.profiles.BranchProfile;
     import com.oracle.truffle.api.profiles.ConditionProfile;
     import com.oracle.truffle.api.profiles.InlinedBranchProfile;
     import com.oracle.truffle.api.profiles.InlinedConditionProfile;
    @@ -1724,39 +1728,41 @@ static Object min(VirtualFrame frame, Object arg1, Object[] args, Object keyword
         }
     
         // next(iterator[, default])
    -    @SuppressWarnings("unused")
         @Builtin(name = J_NEXT, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonBinaryBuiltinNode {
    +    abstract static class NextNode extends PythonBinaryBuiltinNode {
             @Specialization
    -        public Object next(VirtualFrame frame, Object iterator, Object defaultObject,
    +        static Object next(VirtualFrame frame, Object iterator, Object defaultObject,
                             @Bind("this") Node inliningTarget,
                             @Cached InlinedConditionProfile defaultIsNoValue,
    -                        @Cached("createNextCall()") LookupAndCallUnaryNode callNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile) {
    -            if (defaultIsNoValue.profile(inliningTarget, isNoValue(defaultObject))) {
    -                return callNode.executeObject(frame, iterator);
    -            } else {
    -                try {
    -                    return callNode.executeObject(frame, iterator);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
    +                        @Cached PRaiseNode raiseTypeError,
    +                        @Cached PRaiseNode raiseStopIteration,
    +                        @Cached IsBuiltinObjectProfile stopIterationProfile) {
    +            TpSlots slots = getSlots.execute(inliningTarget, iterator);
    +            if (!PyIterCheckNode.checkSlots(slots)) {
    +                throw raiseTypeError.raise(inliningTarget, TypeError, ErrorMessages.OBJ_ISNT_ITERATOR, iterator);
    +            }
    +            Object result;
    +            try {
    +                result = callIterNext.execute(frame, inliningTarget, slots.tp_iternext(), iterator);
    +            } catch (PException e) {
    +                if (defaultIsNoValue.profile(inliningTarget, defaultObject == NO_VALUE)) {
    +                    throw e;
    +                } else {
    +                    e.expectStopIteration(inliningTarget, stopIterationProfile);
                         return defaultObject;
                     }
                 }
    -        }
    -
    -        @NeverDefault
    -        protected LookupAndCallUnaryNode createNextCall() {
    -            return LookupAndCallUnaryNode.create(T___NEXT__, () -> new LookupAndCallUnaryNode.NoAttributeHandler() {
    -                private final BranchProfile errorProfile = BranchProfile.create();
    -
    -                @Override
    -                public Object execute(Object iterator) {
    -                    errorProfile.enter();
    -                    throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.OBJ_ISNT_ITERATOR, iterator);
    +            if (PyIterNextNode.isExhausted(result)) {
    +                if (defaultIsNoValue.profile(inliningTarget, defaultObject == NO_VALUE)) {
    +                    throw raiseStopIteration.raise(inliningTarget, StopIteration);
    +                } else {
    +                    return defaultObject;
                     }
    -            });
    +            }
    +            return result;
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    index d4c4585762..32f409caf6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    @@ -138,9 +138,9 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                 Object iter = getIter.execute(frame, inliningTarget, callbacks);
                 Object cb = next.execute(frame, iter);
                 TruffleString phase = null;
    -            Object info = null;
    +            Object info;
                 long res = 0;
    -            if (cb != null) {
    +            if (!PyIterNextNode.isExhausted(cb)) {
                     phase = START;
                     info = PFactory.createDict(language, new PKeyword[]{
                                     new PKeyword(GENERATION, 2),
    @@ -149,7 +149,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                     });
                     do {
                         call.executeObject(frame, cb, phase, info);
    -                } while ((cb = next.execute(frame, iter)) != null);
    +                } while (!PyIterNextNode.isExhausted(cb = next.execute(frame, iter)));
                 }
                 long freedMemory = javaCollect(inliningTarget, gil);
                 PythonContext pythonContext = PythonContext.get(inliningTarget);
    @@ -168,7 +168,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                                     new PKeyword(UNCOLLECTABLE, 0),
                     });
                     iter = getIter.execute(frame, inliningTarget, callbacks);
    -                while ((cb = next.execute(frame, iter)) != null) {
    +                while (!PyIterNextNode.isExhausted(cb = next.execute(frame, iter))) {
                         call.executeObject(frame, cb, phase, info);
                     }
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    index 9d8ca154cb..174594409d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    @@ -290,11 +290,10 @@ ConstantValue obj2ConstantValue(Object obj) {
             boolean isTuple = PyTupleCheckExactNode.executeUncached(obj);
             if (isTuple || PyFrozenSetCheckExactNode.executeUncached(obj)) {
                 Object iter = PyObjectGetIter.executeUncached(obj);
    -            GetNextNode nextNode = GetNextNode.getUncached();
                 ArrayList list = new ArrayList<>();
                 while (true) {
                     try {
    -                    list.add(obj2ConstantValue(nextNode.execute(iter)));
    +                    list.add(obj2ConstantValue(GetNextNode.executeUncached(iter)));
                     } catch (PException e) {
                         e.expectStopIteration(null, IsBuiltinObjectProfile.getUncached());
                         break;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    index c06e057308..a9cb951f78 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    @@ -66,7 +66,6 @@
     import com.oracle.graal.python.builtins.modules.BuiltinConstructors.TupleNode;
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions.BinNode;
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions.HexNode;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions.NextNode;
     import com.oracle.graal.python.builtins.modules.BuiltinFunctions.OctNode;
     import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBinaryBuiltinNode;
     import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiBuiltin;
    @@ -95,8 +94,8 @@
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.CallSlotMpAssSubscriptNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIterCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAddNode;
     import com.oracle.graal.python.lib.PyNumberAndNode;
     import com.oracle.graal.python.lib.PyNumberDivmodNode;
    @@ -886,18 +885,12 @@ static int doMapping(Object obj,
         abstract static class PyIter_Next extends CApiUnaryBuiltinNode {
             @Specialization
             Object check(Object object,
    -                        @Bind("this") Node inliningTarget,
    -                        @Cached NextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile isClassProfile) {
    -            try {
    -                return nextNode.execute(null, object, PNone.NO_VALUE);
    -            } catch (PException e) {
    -                if (isClassProfile.profileException(inliningTarget, e, PythonBuiltinClassType.StopIteration)) {
    -                    return getNativeNull();
    -                } else {
    -                    throw e;
    -                }
    +                        @Cached PyIterNextNode nextNode) {
    +            Object result = nextNode.execute(null, object);
    +            if (PyIterNextNode.isExhausted(result)) {
    +                return getNativeNull();
                 }
    +            return result;
             }
         }
     
    @@ -908,19 +901,20 @@ Object send(Object iter, Object arg,
                             @Bind("this") Node inliningTarget,
                             @Cached PyIterCheckNode pyiterCheck,
                             @Cached PyObjectCallMethodObjArgs callMethodNode,
    -                        @Cached GetNextNode getNextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached IsBuiltinObjectProfile isClassProfile) {
    -            try {
    -                if (arg instanceof PNone && pyiterCheck.execute(inliningTarget, iter)) {
    -                    return getNextNode.execute(iter);
    -                } else {
    -                    return callMethodNode.execute(null, inliningTarget, iter, T_SEND, arg);
    +            if (arg instanceof PNone && pyiterCheck.execute(inliningTarget, iter)) {
    +                Object result = nextNode.execute(null, iter);
    +                if (PyIterNextNode.isExhausted(result)) {
    +                    return getNativeNull();
                     }
    -            } catch (PException e) {
    -                if (isClassProfile.profileException(inliningTarget, e, PythonBuiltinClassType.StopIteration)) {
    +                return result;
    +            } else {
    +                try {
    +                    return callMethodNode.execute(null, inliningTarget, iter, T_SEND, arg);
    +                } catch (PException e) {
    +                    e.expectStopIteration(inliningTarget, isClassProfile);
                         return getNativeNull();
    -                } else {
    -                    throw e;
                     }
                 }
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    index 90022ba88b..65bbb4eb8b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    @@ -51,7 +51,6 @@
     import static com.oracle.graal.python.builtins.modules.csv.CSVReader.ReaderState.START_RECORD;
     import static com.oracle.graal.python.builtins.modules.csv.QuoteStyle.QUOTE_NONE;
     import static com.oracle.graal.python.builtins.modules.csv.QuoteStyle.QUOTE_NONNUMERIC;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
     
     import java.util.List;
    @@ -66,6 +65,7 @@
     import com.oracle.graal.python.builtins.modules.csv.CSVReader.ReaderState;
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyNumberFloatNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -112,9 +112,9 @@ Object iter(CSVReader self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextReaderNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextReaderNode extends TpIterNextBuiltin {
     
             private static final int EOL = -2;
             private static final int NEWLINE_CODEPOINT = '\n';
    @@ -158,7 +158,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self,
                                 break;
                             }
                         }
    -                    throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                    return iteratorExhausted();
                     }
                     self.fieldLimit = csvModuleBuiltins.fieldLimit;
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java
    index c619347623..860da8f781 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java
    @@ -62,7 +62,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.IO_S_INVALID_LENGTH;
     import static com.oracle.graal.python.nodes.ErrorMessages.IO_S_SHOULD_RETURN_BYTES;
     import static com.oracle.graal.python.nodes.ErrorMessages.MUST_BE_NON_NEG_OR_NEG_1;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.OSError;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
    @@ -73,9 +72,10 @@
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.ArgumentClinic;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
    -import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode;
     import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.EnterBufferedNode;
     import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.FlushAndRewindUnlockedNode;
    @@ -86,6 +86,8 @@
     import com.oracle.graal.python.builtins.objects.bytes.BytesUtils;
     import com.oracle.graal.python.builtins.objects.bytes.PByteArray;
     import com.oracle.graal.python.builtins.objects.bytes.PBytes;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -117,6 +119,9 @@
     
     @CoreFunctions(extendClasses = {PBufferedReader, PBufferedRandom})
     public final class BufferedReaderMixinBuiltins extends AbstractBufferedIOBuiltins {
    +
    +    public static final TpSlots SLOTS = BufferedReaderMixinBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return BufferedReaderMixinBuiltinsFactory.getFactories();
    @@ -815,21 +820,20 @@ static Object doit(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @ImportStatic(IONodes.class)
         @GenerateNodeFactory
         abstract static class NextNode extends PythonUnaryWithInitErrorBuiltinNode {
     
             @Specialization(guards = "self.isOK()")
    -        static PBytes doit(VirtualFrame frame, PBuffered self,
    +        static Object doit(VirtualFrame frame, PBuffered self,
                             @Bind("this") Node inliningTarget,
                             @Cached("create(T_READLINE)") CheckIsClosedNode checkIsClosedNode,
    -                        @Cached BufferedReadlineNode readlineNode,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached BufferedReadlineNode readlineNode) {
                 checkIsClosedNode.execute(frame, self);
                 byte[] line = readlineNode.execute(frame, inliningTarget, self, -1);
                 if (line.length == 0) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 }
                 return PFactory.createBytes(PythonLanguage.get(inliningTarget), line);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    index fab9fb561e..928146b0c8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    @@ -74,7 +74,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
    @@ -83,6 +82,8 @@
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.ArgumentClinic;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -97,6 +98,8 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetInternalObjectArrayNode;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyMemoryViewFromObject;
    @@ -133,6 +136,8 @@
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PBytesIO)
     public final class BytesIOBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = BytesIOBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return BytesIOBuiltinsFactory.getFactories();
    @@ -768,19 +773,17 @@ static Object close(PBytesIO self,
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
         abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode {
     
             @Specialization(guards = "self.hasBuf()")
             static Object doit(PBytesIO self,
    -                        @Bind("this") Node inliningTarget,
                             @Bind PythonLanguage language,
    -                        @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib) {
                 int n = scanEOL(self, -1, bufferLib);
                 if (n == 0) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 }
                 return readBytes(self, n, bufferLib, language);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    index 09d5edd993..5b0c60c616 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    @@ -77,7 +77,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J_FILENO;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ENTER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EXIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T_FILENO;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.IOUnsupportedOperation;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.OSError;
    @@ -99,6 +98,7 @@
     import com.oracle.graal.python.builtins.objects.bytes.PBytes;
     import com.oracle.graal.python.builtins.objects.object.PythonObject;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyErrChainExceptions;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
    @@ -426,18 +426,17 @@ static PythonObject iter(VirtualFrame frame, PythonObject self,
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PythonObject self,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectCallMethodObjArgs callMethod,
    -                        @Cached PyObjectSizeNode sizeNode,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached PyObjectSizeNode sizeNode) {
                 Object line = callMethod.execute(frame, inliningTarget, self, T_READLINE);
                 if (sizeNode.execute(frame, inliningTarget, line) <= 0) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 return line;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java
    index 186ec651cf..40678e37f7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/StringIOBuiltins.java
    @@ -74,7 +74,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.THIRD_ITEM_OF_STATE_SHOULD_BE_A_DICT_GOT_A_P;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
     import static com.oracle.graal.python.nodes.StringLiterals.T_NEWLINE;
    @@ -88,6 +87,8 @@
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.ArgumentClinic;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    @@ -100,6 +101,8 @@
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.str.StringNodes.StringReplaceNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyNumberIndexNode;
    @@ -136,6 +139,8 @@ public final class StringIOBuiltins extends PythonBuiltins {
     
         private static final int NIL_CODEPOINT = 0;
     
    +    public static final TpSlots SLOTS = StringIOBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return StringIOBuiltinsFactory.getFactories();
    @@ -802,7 +807,7 @@ static Object close(PStringIO self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
         abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode {
     
    @@ -816,12 +821,11 @@ static Object builtin(PStringIO self,
                             @SuppressWarnings("unused") @Exclusive @Cached IsBuiltinObjectExactProfile profile,
                             @Cached TruffleStringBuilder.ToStringNode toStringNode,
                             @Cached FindLineEndingNode findLineEndingNode,
    -                        @Cached TruffleString.SubstringNode substringNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached TruffleString.SubstringNode substringNode) {
                 self.realize();
                 TruffleString line = stringioReadline(inliningTarget, self, -1, findLineEndingNode, substringNode, toStringNode);
                 if (line.isEmpty()) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 }
                 return line;
             }
    @@ -843,7 +847,7 @@ static Object slowpath(VirtualFrame frame, PStringIO self,
                 }
                 TruffleString line = toString.execute(inliningTarget, res);
                 if (line.isEmpty()) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 }
                 return line;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java
    index a8606b2935..91bf0d9b3a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java
    @@ -118,7 +118,6 @@
     import static com.oracle.graal.python.nodes.PGuards.isNoValue;
     import static com.oracle.graal.python.nodes.PGuards.isPNone;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
     import static com.oracle.graal.python.nodes.StringLiterals.T_NEWLINE;
    @@ -131,9 +130,10 @@
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.ArgumentClinic;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
    -import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.modules.io.TextIOWrapperNodes.WriteFlushNode;
     import com.oracle.graal.python.builtins.objects.PNone;
    @@ -145,6 +145,8 @@
     import com.oracle.graal.python.builtins.objects.str.StringNodes.StringReplaceNode;
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyErrChainExceptions;
     import com.oracle.graal.python.lib.PyLongAsLongNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
    @@ -189,6 +191,8 @@
     @CoreFunctions(extendClasses = PTextIOWrapper)
     public final class TextIOWrapperBuiltins extends PythonBuiltins {
     
    +    public static final TpSlots SLOTS = TextIOWrapperBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return TextIOWrapperBuiltinsFactory.getFactories();
    @@ -1201,20 +1205,18 @@ static Object attachError(@SuppressWarnings("unused") PTextIO self, @SuppressWar
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
         abstract static class IternextNode extends ClosedCheckPythonUnaryBuiltinNode {
             @Specialization(guards = {"checkAttached(self)", "isOpen(frame, self)"})
    -        static TruffleString doit(VirtualFrame frame, PTextIO self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Cached TextIOWrapperNodes.ReadlineNode readlineNode,
    -                        @Cached PRaiseNode raiseNode) {
    +        static Object doit(VirtualFrame frame, PTextIO self,
    +                        @Cached TextIOWrapperNodes.ReadlineNode readlineNode) {
                 self.setTelling(false);
                 TruffleString line = readlineNode.execute(frame, self, -1);
                 if (line.isEmpty()) {
                     self.clearSnapshot();
                     self.setTelling(self.isSeekable());
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 }
                 return line;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java
    index c47ce7a2d1..65ab92a34c 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PPickler.java
    @@ -90,6 +90,7 @@
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.lib.PyCallableCheckNode;
     import com.oracle.graal.python.lib.PyFloatAsDoubleNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyLongAsLongNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -739,7 +740,7 @@ private void saveIteratorBatchedUnrolled(VirtualFrame frame, PPickler pickler, O
                 do {
                     // Get first item
                     final Object firstItem = getNextItem(frame, iterator);
    -                if (firstItem == null) {
    +                if (PyIterNextNode.isExhausted(firstItem)) {
                         // nothing more to add
                         break;
                     }
    @@ -747,7 +748,7 @@ private void saveIteratorBatchedUnrolled(VirtualFrame frame, PPickler pickler, O
     
                     // Try to get a second item
                     obj = getNextItem(frame, iterator);
    -                if (obj == null) {
    +                if (PyIterNextNode.isExhausted(obj)) {
                         // Only one item to write
                         saveItem.accept(firstItem);
                         write(pickler, opcodeOneItem);
    @@ -769,7 +770,7 @@ private void saveIteratorBatchedUnrolled(VirtualFrame frame, PPickler pickler, O
                         }
     
                         obj = getNextItem(frame, iterator);
    -                    if (obj == null) {
    +                    if (PyIterNextNode.isExhausted(obj)) {
                             break;
                         }
                     }
    @@ -801,7 +802,7 @@ private void saveListIteratorBatchUnrolled(VirtualFrame frame, PPickler pickler,
             private void saveIterator(VirtualFrame frame, PPickler pickler, Object iterator, byte opcode, Consumer itemConsumer) {
                 while (true) {
                     Object item = getNextItem(frame, iterator);
    -                if (item == null) {
    +                if (PyIterNextNode.isExhausted(item)) {
                         break;
                     }
                     itemConsumer.accept(item);
    @@ -1495,7 +1496,7 @@ private void batchSet(VirtualFrame frame, PPickler pickler, Object obj) {
                     write(pickler, PickleUtils.OPCODE_MARK);
                     while (true) {
                         Object item = getNextItem(frame, iterator);
    -                    if (item == null) {
    +                    if (PyIterNextNode.isExhausted(item)) {
                             break;
                         }
                         save(frame, pickler, item, 0);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java
    index f4729ecb59..69c2d97d21 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PUnpickler.java
    @@ -157,6 +157,7 @@
     import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
     import com.oracle.graal.python.builtins.objects.set.PSet;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyMemoryViewFromObject;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectLookupAttr;
    @@ -972,7 +973,7 @@ private void loadNextBuffer(VirtualFrame frame, PUnpickler self) {
                 }
     
                 Object buf = getNextItem(frame, self.buffers);
    -            if (buf == null) {
    +            if (PyIterNextNode.isExhausted(buf)) {
                     throw raise(PythonBuiltinClassType.UnpicklingError, ErrorMessages.NOT_ENOUGH_BUFFERS);
                 }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    index 70e6ec99af..f20946c495 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenSendBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.objects.asyncio.PAsyncGenASend.AwaitableState;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    @@ -55,6 +54,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -90,9 +90,9 @@ public Object doAwait(PAsyncGenASend self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class Next extends PythonUnaryBuiltinNode {
    +    public abstract static class Next extends TpIterNextBuiltin {
             @Specialization
             public Object next(VirtualFrame frame, PAsyncGenASend self,
                             @Cached Send send) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    index 0125a271b5..2c5768596a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/AsyncGenThrowBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.GENERATOR_IGNORED_EXIT;
     import static com.oracle.graal.python.nodes.ErrorMessages.SEND_NON_NONE_TO_UNSTARTED_GENERATOR;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    @@ -57,6 +56,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -102,9 +102,9 @@ public Object doIter(PAsyncGenAThrow self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class Next extends PythonUnaryBuiltinNode {
    +    public abstract static class Next extends TpIterNextBuiltin {
             @Specialization
             public Object doSend(VirtualFrame frame, PAsyncGenAThrow self,
                             @Cached Send send) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    index 724c0316fa..b08ae12088 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/CoroutineWrapperBuiltins.java
    @@ -40,8 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.asyncio;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    -
     import java.util.List;
     
     import com.oracle.graal.python.annotations.Slot;
    @@ -53,6 +51,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    @@ -82,9 +81,9 @@ public Object getIter(PCoroutineWrapper self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             public Object doNext(VirtualFrame frame, PCoroutineWrapper self,
                             @Cached CommonGeneratorBuiltins.SendNode send) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    index 9e4d53560a..3f679ad57b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyProcsWrapper.java
    @@ -63,6 +63,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet.CallSlotDescrSet;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.CallManagedSlotGetAttrNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.CallSlotNbBoolNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.CallSlotMpAssSubscriptNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotNbPower.CallSlotNbInPlacePowerNode;
    @@ -72,6 +73,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.CallSlotSqAssItemNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.CallSlotSqContainsNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.CallSlotUnaryNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectHashNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -504,6 +506,53 @@ protected String getSignature() {
             }
         }
     
    +    @ExportLibrary(InteropLibrary.class)
    +    public static final class IterNextWrapper extends TpSlotWrapper {
    +
    +        public IterNextWrapper(TpSlotManaged delegate) {
    +            super(delegate);
    +        }
    +
    +        @Override
    +        public TpSlotWrapper cloneWith(TpSlotManaged slot) {
    +            return new IterNextWrapper(slot);
    +        }
    +
    +        @ExportMessage
    +        Object execute(Object[] arguments,
    +                        @Bind("$node") Node inliningTarget,
    +                        @Cached PythonToNativeNewRefNode toNativeNode,
    +                        @Cached CallSlotTpIterNextNode callNode,
    +                        @Cached NativeToPythonNode toJavaNode,
    +                        @Cached TransformExceptionToNativeNode transformExceptionToNativeNode,
    +                        @Exclusive @Cached GilNode gil) throws ArityException {
    +            boolean mustRelease = gil.acquire();
    +            CApiTiming.enter();
    +            try {
    +                try {
    +                    Object result = callNode.execute(null, inliningTarget, getSlot(), toJavaNode.execute(arguments[0]));
    +                    if (PyIterNextNode.isExhausted(result)) {
    +                        return PythonContext.get(inliningTarget).getNativeNull();
    +                    }
    +                    return toNativeNode.execute(result);
    +                } catch (Throwable t) {
    +                    throw checkThrowableBeforeNative(t, "UnaryFuncWrapper", getDelegate());
    +                }
    +            } catch (PException e) {
    +                transformExceptionToNativeNode.execute(inliningTarget, e);
    +                return PythonContext.get(gil).getNativeNull();
    +            } finally {
    +                CApiTiming.exit(timing);
    +                gil.release(mustRelease);
    +            }
    +        }
    +
    +        @Override
    +        protected String getSignature() {
    +            return "(POINTER):POINTER";
    +        }
    +    }
    +
         @ExportLibrary(InteropLibrary.class)
         public static final class InquiryWrapper extends TpSlotWrapper {
             public InquiryWrapper(TpSlotManaged delegate) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    index c748c25b71..7c843c255d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/SlotMethodDef.java
    @@ -46,7 +46,6 @@
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_call;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_hash;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_init;
    -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_iternext;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_repr;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_richcompare;
     import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_str;
    @@ -56,7 +55,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUFFLE_RICHCOMPARE__;
    @@ -76,7 +74,6 @@ public enum SlotMethodDef {
         TP_CALL(PyTypeObject__tp_call, T___CALL__, CallFunctionWrapper::new),
         TP_HASH(PyTypeObject__tp_hash, T___HASH__, HashfuncWrapper::new),
         TP_INIT(PyTypeObject__tp_init, T___INIT__, InitWrapper::new),
    -    TP_ITERNEXT(PyTypeObject__tp_iternext, T___NEXT__, UnaryFuncLegacyWrapper::new),
         TP_REPR(PyTypeObject__tp_repr, T___REPR__, PyProcsWrapper.UnaryFuncLegacyWrapper::new),
         TP_RICHCOMPARE(PyTypeObject__tp_richcompare, T___TRUFFLE_RICHCOMPARE__, RichcmpFunctionWrapper::new),
         TP_STR(PyTypeObject__tp_str, T___STR__, UnaryFuncLegacyWrapper::new),
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    index b894d83673..2b15dcfb13 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/ToNativeTypeNode.java
    @@ -271,7 +271,6 @@ static void initializeType(PythonClassNativeWrapper obj, Object mem, boolean hea
             writePtrNode.write(mem, CFields.PyTypeObject__tp_is_gc, tpIsGc);
     
             writePtrNode.write(mem, CFields.PyTypeObject__tp_richcompare, lookup(clazz, SlotMethodDef.TP_RICHCOMPARE));
    -        writePtrNode.write(mem, CFields.PyTypeObject__tp_iternext, lookup(clazz, SlotMethodDef.TP_ITERNEXT));
             writePtrNode.write(mem, CFields.PyTypeObject__tp_methods, nullValue);
             writePtrNode.write(mem, CFields.PyTypeObject__tp_members, nullValue);
             writePtrNode.write(mem, CFields.PyTypeObject__tp_getset, nullValue);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    index e1ee0ed09a..986e44717d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    @@ -216,7 +216,7 @@ static ArrayBuilder partialMerge(VirtualFrame frame, Object mapping, O
                 Object keysIt = getIter.execute(frame, inliningTarget, keysIterable);
                 ArrayBuilder elements = new ArrayBuilder<>();
                 Object keyObj;
    -            while ((keyObj = nextNode.execute(frame, keysIt)) != null) {
    +            while (!PyIterNextNode.isExhausted(keyObj = nextNode.execute(frame, keysIt))) {
                     Object valueObj = getItemNode.execute(frame, inliningTarget, mapping, keyObj);
                     elements.add(new KeyValue(keyObj, valueObj));
                 }
    @@ -240,7 +240,7 @@ static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object it
                 Object next;
                 int len = 2;
                 try {
    -                while ((next = nextNode.execute(frame, it)) != null) {
    +                while (!PyIterNextNode.isExhausted(next = nextNode.execute(frame, it))) {
                         PSequence element = createListNode.execute(frame, inliningTarget, next);
                         assert element != null;
                         // This constructs a new list using the builtin type. So, the object cannot
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    index b432d53661..fa913c3fa8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    @@ -26,7 +26,6 @@
     package com.oracle.graal.python.builtins.objects.common;
     
     import static com.oracle.graal.python.builtins.objects.common.IndexNodes.checkBounds;
    -import static com.oracle.graal.python.builtins.objects.iterator.IteratorBuiltins.NextHelperNode.STOP_MARKER;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.IndexError;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.MemoryError;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError;
    @@ -89,6 +88,7 @@
     import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    @@ -4112,7 +4112,7 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 array = elements;
                                 try {
                                     while (true) {
    -                                    boolean value = nextNode.executeBoolean(frame, iterator);
    +                                    boolean value = PGuards.expectBoolean(nextNode.execute(frame, iterator));
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4129,7 +4129,7 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 array = elements;
                                 try {
                                     while (true) {
    -                                    int value = nextNode.executeInt(frame, iterator);
    +                                    int value = PGuards.expectInteger(nextNode.execute(frame, iterator));
                                         byte bvalue;
                                         try {
                                             bvalue = PInt.byteValueExact(value);
    @@ -4152,7 +4152,7 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 array = elements;
                                 try {
                                     while (true) {
    -                                    int value = nextNode.executeInt(frame, iterator);
    +                                    int value = PGuards.expectInteger(nextNode.execute(frame, iterator));
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4169,7 +4169,7 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 array = elements;
                                 try {
                                     while (true) {
    -                                    long value = nextNode.executeLong(frame, iterator);
    +                                    long value = PGuards.expectLong(nextNode.execute(frame, iterator));
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4186,7 +4186,7 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 array = elements;
                                 try {
                                     while (true) {
    -                                    double value = nextNode.executeDouble(frame, iterator);
    +                                    double value = PGuards.expectDouble(nextNode.execute(frame, iterator));
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4281,7 +4281,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                     int i = 0;
                     try {
                         Object value;
    -                    for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                    for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                             if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                 elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                             }
    @@ -4301,7 +4301,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                                 boolean[] elements = new boolean[size];
                                 array = elements;
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                             array = elements;
    @@ -4317,7 +4317,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                                 byte[] elements = new byte[size];
                                 array = elements;
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         byte bvalue;
                                         try {
                                             bvalue = PInt.byteValueExact(PGuards.expectInteger(value));
    @@ -4338,7 +4338,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                                 int[] elements = new int[size];
                                 array = elements;
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4353,7 +4353,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                                 long[] elements = new long[size];
                                 array = elements;
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4368,7 +4368,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                                 double[] elements = new double[size];
                                 array = elements;
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4382,7 +4382,7 @@ protected static SequenceStorage createStorageFromBuiltin(VirtualFrame frame, PB
                             case Generic: {
                                 Object[] elements = new Object[size];
                                 try {
    -                                for (; loopProfile.profile(inliningTarget, (value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER); i++) {
    +                                for (; loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))); i++) {
                                         if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
                                             elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    @@ -4413,7 +4413,7 @@ private static SequenceStorage genericFallback(VirtualFrame frame, PBuiltinItera
                 elements[i++] = result;
                 Object value;
                 try {
    -                while ((value = nextNode.execute(frame, inliningTarget, iterator, false)) != STOP_MARKER) {
    +                while (!PyIterNextNode.isExhausted(value = nextNode.execute(frame, inliningTarget, iterator))) {
                         if (i >= elements.length) {
                             elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    index c93d764a81..96bc96d334 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextIteratorBuiltins.java
    @@ -40,27 +40,22 @@
      */
     package com.oracle.graal.python.builtins.objects.contextvars;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    -
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.Slot;
     import com.oracle.graal.python.annotations.Slot.SlotKind;
    -import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.truffle.api.dsl.Bind;
    -import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.GenerateNodeFactory;
     import com.oracle.truffle.api.dsl.NodeFactory;
     import com.oracle.truffle.api.dsl.Specialization;
    -import com.oracle.truffle.api.nodes.Node;
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.ContextIterator)
     public final class ContextIteratorBuiltins extends PythonBuiltins {
    @@ -80,17 +75,15 @@ static Object iter(PContextIterator self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, declaresExplicitSelf = true, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class Next extends PythonUnaryBuiltinNode {
    +    public abstract static class Next extends TpIterNextBuiltin {
             @Specialization
             static Object next(PContextIterator self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Bind PythonLanguage language) {
                 Object next = self.next(language);
                 if (next == null) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 } else {
                     return next;
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    index 8868cf0acc..05ee6de97a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeIterBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.ConcurrentModificationException;
    @@ -58,6 +57,7 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -94,9 +94,9 @@ static PDequeIter doGeneric(PDequeIter self) {
         }
     
         // _deque_iterator.__next__()
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class DequeIterNextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class DequeIterNextNode extends TpIterNextBuiltin {
     
             public abstract Object execute(PDequeIter self);
     
    @@ -107,7 +107,7 @@ Object doGeneric(PDequeIter self) {
                     if (self.startState == self.deque.getState()) {
                         if (!self.hasNext()) {
                             assert self.lengthHint() == 0;
    -                        throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.StopIteration);
    +                        return iteratorExhausted();
                         }
                         return self.next();
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    index 11a61a0b1c..17d2f0a8dc 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    @@ -26,7 +26,6 @@
     package com.oracle.graal.python.builtins.objects.enumerate;
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -40,7 +39,8 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -64,18 +64,21 @@ protected List> getNodeFa
             return EnumerateBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
     
             @Specialization
             static Object doNext(VirtualFrame frame, PEnumerate self,
                             @Bind("this") Node inliningTarget,
                             @Bind PythonLanguage language,
                             @Cached InlinedConditionProfile bigIntIndexProfile,
    -                        @Cached GetNextNode next) {
    +                        @Cached PyIterNextNode next) {
                 Object index = self.getAndIncrementIndex(inliningTarget, language, bigIntIndexProfile);
                 Object nextValue = next.execute(frame, self.getDecoratedIterator());
    +            if (PyIterNextNode.isExhausted(nextValue)) {
    +                return iteratorExhausted();
    +            }
                 return PFactory.createTuple(language, (new Object[]{index, nextValue}));
             }
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    index 3afa1acb15..6e1c350261 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    @@ -31,7 +31,6 @@
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___QUALNAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError;
     
    @@ -51,6 +50,7 @@
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.bytecode.FrameInfo;
    @@ -143,15 +143,20 @@ static Object iter(PGenerator self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1, doc = "Implement next(self).")
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PGenerator self,
                             @Bind("this") Node inliningTarget,
                             @Cached CommonGeneratorBuiltins.ResumeGeneratorNode resumeGeneratorNode,
                             @Cached PRaiseNode raiseNode) {
    -            checkResumable(inliningTarget, self, raiseNode);
    +            if (self.isFinished()) {
    +                return iteratorExhausted();
    +            }
    +            if (self.isRunning()) {
    +                throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.GENERATOR_ALREADY_EXECUTING);
    +            }
                 return resumeGeneratorNode.execute(frame, inliningTarget, self, null);
             }
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    index b7b2503ea7..03f77bc622 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorBuiltins.java
    @@ -30,7 +30,6 @@
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
     import static com.oracle.graal.python.nodes.ErrorMessages.DESCRIPTOR_REQUIRES_S_OBJ_RECEIVED_P;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING;
    @@ -64,6 +63,7 @@
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
    @@ -124,15 +124,15 @@ protected List> getNodeFa
             return IteratorBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
     
             @Specialization
             static Object exhausted(VirtualFrame frame, Object self,
                             @Bind("this") Node inliningTarget,
                             @Cached NextHelperNode nextHelperNode) {
    -            return nextHelperNode.execute(frame, inliningTarget, self, true);
    +            return nextHelperNode.execute(frame, inliningTarget, self);
             }
         }
     
    @@ -140,118 +140,91 @@ static Object exhausted(VirtualFrame frame, Object self,
         @GenerateCached(false)
         public abstract static class NextHelperNode extends PNodeWithContext {
     
    -        public static final Object STOP_MARKER = new Object();
    +        public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object iterator);
     
    -        public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object iterator, boolean throwStopIteration);
    -
    -        private static Object stopIteration(Node inliningTarget, PBuiltinIterator self, boolean throwStopIteration, PRaiseNode raiseNode) {
    +        private static Object stopIteration(PBuiltinIterator self) {
                 self.setExhausted();
    -            if (throwStopIteration) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    -            } else {
    -                return STOP_MARKER;
    -            }
    -        }
    -
    -        private static Object stopIterationForeign(Node inliningTarget, boolean throwStopIteration, PRaiseNode raiseNode) {
    -            if (throwStopIteration) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    -            } else {
    -                return STOP_MARKER;
    -            }
    +            return TpIterNextBuiltin.iteratorExhausted();
             }
     
             @Specialization(guards = "self.isExhausted()")
    -        static Object exhausted(Node inliningTarget, @SuppressWarnings("unused") PBuiltinIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    -            if (throwStopIteration) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    -            } else {
    -                return STOP_MARKER;
    -            }
    +        static Object exhausted(@SuppressWarnings("unused") PBuiltinIterator self) {
    +            return TpIterNextBuiltin.iteratorExhausted();
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PArrayIterator self, boolean throwStopIteration,
    +        static Object next(Node inliningTarget, PArrayIterator self,
                             @Cached InlinedExactClassProfile itemTypeProfile,
    -                        @Cached ArrayNodes.GetValueNode getValueNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached ArrayNodes.GetValueNode getValueNode) {
                 PArray array = self.array;
                 if (self.getIndex() < array.getLength()) {
                     return itemTypeProfile.profile(inliningTarget, getValueNode.execute(inliningTarget, array, self.index++));
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PIntegerSequenceIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(PIntegerSequenceIterator self) {
                 if (self.getIndex() < self.sequence.length()) {
                     return self.sequence.getIntItemNormalized(self.index++);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PObjectSequenceIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(PObjectSequenceIterator self) {
                 if (self.getIndex() < self.sequence.length()) {
                     return self.sequence.getObjectItemNormalized(self.index++);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PIntRangeIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached InlinedConditionProfile profile,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(Node inliningTarget, PIntRangeIterator self,
    +                        @Exclusive @Cached InlinedConditionProfile profile) {
                 if (profile.profile(inliningTarget, self.hasNextInt())) {
                     return self.nextInt();
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PBigRangeIterator self, boolean throwStopIteration,
    -                        @Bind PythonLanguage language,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(PBigRangeIterator self,
    +                        @Bind PythonLanguage language) {
                 if (self.hasNextBigInt()) {
                     return PFactory.createInt(language, self.nextBigInt());
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PDoubleSequenceIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(PDoubleSequenceIterator self) {
                 if (self.getIndex() < self.sequence.length()) {
                     return self.sequence.getDoubleItemNormalized(self.index++);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PLongSequenceIterator self, boolean throwStopIteration,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +        static Object next(PLongSequenceIterator self) {
                 if (self.getIndex() < self.sequence.length()) {
                     return self.sequence.getLongItemNormalized(self.index++);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object next(Node inliningTarget, PStringIterator self, boolean throwStopIteration,
    +        static Object next(PStringIterator self,
                             @Cached(inline = false) TruffleString.CodePointLengthNode codePointLengthNode,
    -                        @Cached(inline = false) TruffleString.SubstringNode substringNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached(inline = false) TruffleString.SubstringNode substringNode) {
                 if (self.getIndex() < codePointLengthNode.execute(self.value, TS_ENCODING)) {
                     return substringNode.execute(self.value, self.index++, 1, TS_ENCODING, false);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = "!self.isExhausted()")
    -        static Object nextHashingStorageIter(Node inliningTarget, PHashingStorageIterator self, boolean throwStopIteration,
    +        static Object nextHashingStorageIter(Node inliningTarget, PHashingStorageIterator self,
                             @Exclusive @Cached InlinedConditionProfile sizeChanged,
                             @Cached HashingStorageLen lenNode,
                             @Cached HashingStorageIteratorNext nextNode,
    @@ -268,26 +241,24 @@ static Object nextHashingStorageIter(Node inliningTarget, PHashingStorageIterato
                     self.index++;
                     return itValueNode.execute(inliningTarget, self, storage, it);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = {"!self.isExhausted()", "self.isPSequence()"})
    -        static Object next(Node inliningTarget, PSequenceIterator self, boolean throwStopIteration,
    +        static Object next(Node inliningTarget, PSequenceIterator self,
                             @Cached SequenceNodes.GetSequenceStorageNode getStorage,
    -                        @Cached(value = "createNotNormalized()", inline = false) SequenceStorageNodes.GetItemNode getItemNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached(value = "createNotNormalized()", inline = false) SequenceStorageNodes.GetItemNode getItemNode) {
                 SequenceStorage s = getStorage.execute(inliningTarget, self.getPSequence());
                 if (self.getIndex() < s.length()) {
                     return getItemNode.execute(s, self.index++);
                 }
    -            return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +            return stopIteration(self);
             }
     
             @Specialization(guards = {"!self.isExhausted()", "!self.isPSequence()"})
    -        static Object next(VirtualFrame frame, Node inliningTarget, PSequenceIterator self, boolean throwStopIteration,
    +        static Object next(VirtualFrame frame, Node inliningTarget, PSequenceIterator self,
                             @Cached(inline = false) PySequenceGetItemNode getItem,
    -                        @Cached IsBuiltinObjectProfile profile,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached IsBuiltinObjectProfile profile) {
                 try {
                     /*
                      * This must use PySequence_GetItem and not any other get item nodes. The reason is
    @@ -299,24 +270,23 @@ static Object next(VirtualFrame frame, Node inliningTarget, PSequenceIterator se
                     return getItem.execute(frame, self.getObject(), self.index++);
                 } catch (PException e) {
                     e.expectIndexError(inliningTarget, profile);
    -                return stopIteration(inliningTarget, self, throwStopIteration, raiseNode);
    +                return stopIteration(self);
                 }
             }
     
             @Specialization(guards = {"isForeignObjectNode.execute(inliningTarget, self)", "interop.isIterator(self)"}, limit = "1")
    -        static Object foreign(Node inliningTarget, Object self, boolean throwStopIteration,
    -                        @Cached IsForeignObjectNode isForeignObjectNode,
    +        static Object foreign(@SuppressWarnings("unused") Node inliningTarget, Object self,
    +                        @SuppressWarnings("unused") @Cached IsForeignObjectNode isForeignObjectNode,
                             @CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") InteropLibrary interop,
                             @Cached(inline = false) GilNode gil,
    -                        @Cached(inline = false) PForeignToPTypeNode toPythonNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached(inline = false) PForeignToPTypeNode toPythonNode) {
                 final Object element;
     
                 gil.release(true);
                 try {
                     element = interop.getIteratorNextElement(self);
                 } catch (StopIterationException e) {
    -                return stopIterationForeign(inliningTarget, throwStopIteration, raiseNode);
    +                return TpIterNextBuiltin.iteratorExhausted();
                 } catch (UnsupportedMessageException e) {
                     throw CompilerDirectives.shouldNotReachHere("iterator claimed to be iterator but wasn't");
                 } finally {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    index 908e7e49d9..9aa0c83888 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    @@ -25,7 +25,6 @@
      */
     package com.oracle.graal.python.builtins.objects.iterator;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -41,6 +40,7 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -72,14 +72,13 @@ protected List> getNodeFa
             return PZipBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
     
             @Specialization(guards = "isEmpty(self.getIterators())")
    -        static Object doEmpty(@SuppressWarnings("unused") PZip self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration);
    +        static Object doEmpty(@SuppressWarnings("unused") PZip self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = {"!isEmpty(self.getIterators())", "!self.isStrict()"})
    @@ -121,6 +120,7 @@ static Object doNext(VirtualFrame frame, PZip self,
                         } catch (PException e2) {
                             e2.expectStopIteration(inliningTarget, classProfile);
                         }
    +                    return iteratorExhausted();
                     }
                     throw e;
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    index f50b9e0937..d298b2d557 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/SentinelIteratorBuiltins.java
    @@ -26,7 +26,6 @@
     package com.oracle.graal.python.builtins.objects.iterator;
     
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -40,9 +39,9 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
    -import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -68,18 +67,17 @@ protected List> getNodeFa
             return SentinelIteratorBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object doIterator(VirtualFrame frame, PSentinelIterator iterator,
                             @Bind("this") Node inliningTarget,
                             @Cached CallNode callNode,
                             @Cached IsBuiltinObjectProfile errorProfile,
    -                        @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached PyObjectRichCompareBool.EqNode eqNode) {
                 if (iterator.sentinelReached()) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 Object nextValue;
                 try {
    @@ -87,12 +85,12 @@ static Object doIterator(VirtualFrame frame, PSentinelIterator iterator,
                 } catch (PException e) {
                     e.expectStopIteration(inliningTarget, errorProfile);
                     iterator.markSentinelReached();
    -                throw e;
    +                return iteratorExhausted();
                 }
                 boolean iteratorDone = eqNode.compare(frame, inliningTarget, nextValue, iterator.getSentinel());
                 if (iteratorDone) {
                     iterator.markSentinelReached();
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 return nextValue;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    index 17e2693f35..e3085220e2 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -53,11 +52,12 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAddNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -95,13 +95,13 @@ static Object iter(PAccumulate self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PAccumulate self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyNumberAddNode addNode,
                             @Cached CallNode callNode,
                             @Cached InlinedBranchProfile hasInitialProfile,
    @@ -113,7 +113,10 @@ static Object next(VirtualFrame frame, PAccumulate self,
                     self.setInitial(null);
                     return self.getTotal();
                 }
    -            Object value = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +            Object value = nextNode.execute(frame, self.getIterable());
    +            if (PyIterNextNode.isExhausted(value)) {
    +                return iteratorExhausted();
    +            }
                 if (self.getTotal() == null) {
                     markerProfile.enter(inliningTarget);
                     self.setTotal(value);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    index e138c4c4ce..b0a3670940 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.ARGUMENTS_MUST_BE_ITERATORS;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -57,19 +56,19 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -103,38 +102,46 @@ static Object iter(PChain self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PChain self,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile,
    -                        @Cached InlinedBranchProfile nextExceptioProfile,
    -                        @Cached InlinedLoopConditionProfile loopProfile,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached InlinedBranchProfile nextExceptionProfile,
    +                        @Cached InlinedLoopConditionProfile loopProfile) {
                 while (loopProfile.profile(inliningTarget, self.getSource() != PNone.NONE)) {
                     if (self.getActive() == PNone.NONE) {
                         try {
    -                        Object next = nextNode.execute(frame, self.getSource(), PNone.NO_VALUE);
    +                        Object next;
    +                        try {
    +                            next = nextNode.execute(frame, self.getSource());
    +                        } catch (PException e) {
    +                            nextExceptionProfile.enter(inliningTarget);
    +                            self.setSource(PNone.NONE);
    +                            throw e;
    +                        }
    +                        if (PyIterNextNode.isExhausted(next)) {
    +                            self.setSource(PNone.NONE);
    +                            return iteratorExhausted();
    +                        }
                             Object iter = getIter.execute(frame, inliningTarget, next);
                             self.setActive(iter);
                         } catch (PException e) {
    -                        nextExceptioProfile.enter(inliningTarget);
    +                        nextExceptionProfile.enter(inliningTarget);
                             self.setSource(PNone.NONE);
                             throw e;
                         }
                     }
    -                try {
    -                    return nextNode.execute(frame, self.getActive(), PNone.NO_VALUE);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, isStopIterationProfile);
    -                    self.setActive(PNone.NONE);
    +                Object next = nextNode.execute(frame, self.getActive());
    +                if (!PyIterNextNode.isExhausted(next)) {
    +                    return next;
                     }
    +                self.setActive(PNone.NONE);
                 }
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +            return iteratorExhausted();
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    index b9ff327c99..b36ad06b2e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CombinationsBuiltins.java
    @@ -40,10 +40,8 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETSTATE__;
    @@ -61,6 +59,7 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -69,7 +68,6 @@
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.util.CannotCastException;
     import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
     import com.oracle.graal.python.util.PythonUtils;
    @@ -104,14 +102,14 @@ static Object iter(PAbstractCombinations self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @SuppressWarnings("unused")
             @Specialization(guards = "self.isStopped()")
             static Object nextStopped(PAbstractCombinations self,
                             @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, StopIteration);
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = {"!self.isStopped()", "isLastResultNull(self)"})
    @@ -134,22 +132,20 @@ static Object nextNoResult(PAbstractCombinations self,
             static Object next(PCombinations self,
                             @Bind("this") Node inliningTarget,
                             @Shared @Cached InlinedLoopConditionProfile indexLoopProfile,
    -                        @Shared @Cached InlinedLoopConditionProfile resultLoopProfile,
    -                        @Shared @Cached PRaiseNode raiseNode) {
    -            return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode);
    +                        @Shared @Cached InlinedLoopConditionProfile resultLoopProfile) {
    +            return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile);
             }
     
             @Specialization(guards = {"!self.isStopped()", "!isLastResultNull(self)"})
             static Object next(PCombinationsWithReplacement self,
                             @Bind("this") Node inliningTarget,
                             @Shared @Cached InlinedLoopConditionProfile indexLoopProfile,
    -                        @Shared @Cached InlinedLoopConditionProfile resultLoopProfile,
    -                        @Shared @Cached PRaiseNode raiseNode) {
    -            return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile, raiseNode);
    +                        @Shared @Cached InlinedLoopConditionProfile resultLoopProfile) {
    +            return nextInternal(inliningTarget, self, indexLoopProfile, resultLoopProfile);
             }
     
             private static Object nextInternal(Node inliningTarget, PAbstractCombinations self, InlinedLoopConditionProfile indexLoopProfile,
    -                        InlinedLoopConditionProfile resultLoopProfile, PRaiseNode raiseNode) throws PException {
    +                        InlinedLoopConditionProfile resultLoopProfile) {
     
                 CompilerAsserts.partialEvaluationConstant(self.getClass());
     
    @@ -166,7 +162,7 @@ private static Object nextInternal(Node inliningTarget, PAbstractCombinations se
                 // If i is negative, then the indices are all at their maximum value and we're done
                 if (i < 0) {
                     self.setStopped(true);
    -                throw raiseNode.raise(inliningTarget, StopIteration);
    +                return iteratorExhausted();
                 }
     
                 // Increment the current index which we know is not at its maximum.
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    index 1ab4654ba3..c918d837a5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CompressBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -52,10 +51,13 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -89,22 +91,37 @@ static Object iter(PCompress self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PCompress self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached GetObjectSlotsNode getDataSlots,
    +                        @Cached GetObjectSlotsNode getSelectorsSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNextData,
    +                        @Cached CallSlotTpIterNextNode callIterNextSelectors,
                             @Cached PyObjectIsTrueNode isTrue,
                             @Cached InlinedLoopConditionProfile loopConditionProfile) {
    -            Object nextSelector;
    -            Object nextItem;
    +            Object data = self.getData();
    +            Object selectors = self.getSelectors();
    +            TpSlot dataIterNext = getDataSlots.execute(inliningTarget, data).tp_iternext();
    +            TpSlot selectorsIterNext = getSelectorsSlots.execute(inliningTarget, selectors).tp_iternext();
    +            Object result = null;
                 do {
    -                nextItem = nextNode.execute(frame, self.getData(), PNone.NO_VALUE);
    -                nextSelector = nextNode.execute(frame, self.getSelectors(), PNone.NO_VALUE);
    -            } while (loopConditionProfile.profile(inliningTarget, !isTrue.execute(frame, nextSelector)));
    -            return nextItem;
    +                Object datum = callIterNextData.execute(frame, inliningTarget, dataIterNext, data);
    +                if (PyIterNextNode.isExhausted(datum)) {
    +                    result = iteratorExhausted();
    +                } else {
    +                    Object selector = callIterNextSelectors.execute(frame, inliningTarget, selectorsIterNext, selectors);
    +                    if (PyIterNextNode.isExhausted(selector)) {
    +                        result = iteratorExhausted();
    +                    } else if (isTrue.execute(frame, selector)) {
    +                        result = datum;
    +                    }
    +                }
    +            } while (loopConditionProfile.profile(inliningTarget, result == null));
    +            return result;
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    index ee6ca228af..e5cfc9c0ff 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.itertools;
     
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     
    @@ -57,6 +56,7 @@
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyNumberAddNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
    @@ -97,9 +97,9 @@ static Object iter(PCount self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PCount self,
                             @Bind("this") Node inliningTarget,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    index dd31b5b712..901eec54e7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    @@ -43,7 +43,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.ErrorMessages.STATE_ARGUMENT_D_MUST_BE_A_S;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETSTATE__;
    @@ -59,7 +58,6 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ToArrayNode;
     import com.oracle.graal.python.builtins.objects.list.PList;
    @@ -67,6 +65,8 @@
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectLookupAttr;
    @@ -109,33 +109,30 @@ static Object iter(PCycle self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PCycle self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached InlinedBranchProfile iterableProfile,
    -                        @Cached InlinedBranchProfile firstPassProfile,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached InlinedBranchProfile firstPassProfile) {
                 if (self.getIterable() != null) {
                     iterableProfile.enter(inliningTarget);
    -                try {
    -                    Object item = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +                Object item = nextNode.execute(frame, self.getIterable());
    +                if (PyIterNextNode.isExhausted(item)) {
    +                    self.setIterable(null);
    +                } else {
                         if (!self.isFirstpass()) {
                             firstPassProfile.enter(inliningTarget);
                             add(self.getSaved(), item);
                         }
                         return item;
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, isStopIterationProfile);
    -                    self.setIterable(null);
                     }
                 }
                 if (isEmpty(self.getSaved())) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 Object item = get(self.getSaved(), self.getIndex());
                 self.setIndex(self.getIndex() + 1);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    index 25d718235e..c5c6240bb5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/DropwhileBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETSTATE__;
    @@ -56,10 +55,14 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -99,27 +102,34 @@ static Object iter(PDropwhile self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PDropwhile self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached CallNode callNode,
                             @Cached PyObjectIsTrueNode isTrue,
                             @Cached InlinedBranchProfile doneDroppingProfile,
                             @Cached InlinedLoopConditionProfile loopProfile) {
    -
    -            while (loopProfile.profile(inliningTarget, !self.isDoneDropping())) {
    -                Object n = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    -                if (!isTrue.execute(frame, callNode.execute(frame, self.getPredicate(), n))) {
    +            Object iterable = self.getIterable();
    +            TpSlot iterNext = getSlots.execute(inliningTarget, iterable).tp_iternext();
    +            Object result = null;
    +            do {
    +                Object item = callIterNext.execute(frame, inliningTarget, iterNext, iterable);
    +                if (self.isDoneDropping()) {
    +                    result = item;
    +                } else if (PyIterNextNode.isExhausted(item)) {
    +                    result = iteratorExhausted();
    +                } else if (!isTrue.execute(frame, callNode.execute(frame, self.getPredicate(), item))) {
                         doneDroppingProfile.enter(inliningTarget);
                         self.setDoneDropping(true);
    -                    return n;
    +                    result = item;
                     }
    -            }
    -            return nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +            } while (loopProfile.profile(inliningTarget, result == null));
    +            return result;
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    index 116aa35971..5b9c041003 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/FilterfalseBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -52,10 +51,14 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -64,7 +67,6 @@
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    -import com.oracle.truffle.api.dsl.Cached.Shared;
     import com.oracle.truffle.api.dsl.GenerateNodeFactory;
     import com.oracle.truffle.api.dsl.NodeFactory;
     import com.oracle.truffle.api.dsl.Specialization;
    @@ -92,38 +94,37 @@ static Object iter(PFilterfalse self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    -        @Specialization(guards = "hasFunc(self)")
    +    public abstract static class NextNode extends TpIterNextBuiltin {
    +        @Specialization
             static Object next(VirtualFrame frame, PFilterfalse self,
                             @Bind("this") Node inliningTarget,
    -                        @Shared @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached CallNode callNode,
    -                        @Shared @Cached PyObjectIsTrueNode isTrue,
    -                        @Shared @Cached InlinedLoopConditionProfile loopConditionProfile) {
    -            Object n;
    -            do {
    -                n = nextNode.execute(frame, self.getSequence(), PNone.NO_VALUE);
    -            } while (loopConditionProfile.profile(inliningTarget, isTrue.execute(frame, callNode.execute(frame, self.getFunc(), n))));
    -            return n;
    -        }
    -
    -        @Specialization(guards = "!hasFunc(self)")
    -        static Object nextNoFunc(VirtualFrame frame, PFilterfalse self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Shared @Cached BuiltinFunctions.NextNode nextNode,
    -                        @Shared @Cached PyObjectIsTrueNode isTrue,
    -                        @Shared @Cached InlinedLoopConditionProfile loopConditionProfile) {
    -            Object n;
    +                        @Cached PyObjectIsTrueNode isTrue,
    +                        @Cached InlinedConditionProfile hasFuncProfile,
    +                        @Cached InlinedLoopConditionProfile loopConditionProfile) {
    +            Object sequence = self.getSequence();
    +            TpSlot iterNext = getSlots.execute(inliningTarget, sequence).tp_iternext();
    +            Object func = self.getFunc();
    +            boolean hasFunc = hasFuncProfile.profile(inliningTarget, func != null);
    +            Object result;
    +            boolean cont;
                 do {
    -                n = nextNode.execute(frame, self.getSequence(), PNone.NO_VALUE);
    -            } while (loopConditionProfile.profile(inliningTarget, isTrue.execute(frame, n)));
    -            return n;
    -        }
    -
    -        protected boolean hasFunc(PFilterfalse self) {
    -            return self.getFunc() != null;
    +                result = callIterNext.execute(frame, inliningTarget, iterNext, sequence);
    +                if (PyIterNextNode.isExhausted(result)) {
    +                    cont = false;
    +                } else {
    +                    Object good = result;
    +                    if (hasFunc) {
    +                        good = callNode.execute(frame, func, result);
    +                    }
    +                    cont = isTrue.execute(frame, good);
    +                }
    +            } while (loopConditionProfile.profile(inliningTarget, cont));
    +            return result;
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    index 6b398dd6cd..b17a68406e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GroupByBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -55,11 +54,12 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -98,13 +98,13 @@ static Object iter(PGroupBy self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PGroupBy self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached PyObjectRichCompareBool.EqNode eqNode,
                             @Cached InlinedBranchProfile eqProfile,
    @@ -113,7 +113,10 @@ static Object next(VirtualFrame frame, PGroupBy self,
                             @Bind PythonLanguage language) {
                 self.setCurrGrouper(null);
                 while (loopConditionProfile.profile(inliningTarget, doGroupByStep(frame, inliningTarget, self, eqProfile, eqNode))) {
    -                self.groupByStep(frame, inliningTarget, nextNode, callNode, hasFuncProfile);
    +                boolean cont = self.groupByStep(frame, inliningTarget, nextNode, callNode, hasFuncProfile);
    +                if (!cont) {
    +                    return iteratorExhausted();
    +                }
                 }
                 self.setTgtKey(self.getCurrKey());
                 PGrouper grouper = PFactory.createGrouper(language, self, self.getTgtKey());
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    index f4565d9a54..2834c927ad 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/GrouperBuiltins.java
    @@ -41,7 +41,6 @@
     package com.oracle.graal.python.builtins.objects.itertools;
     
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -53,10 +52,11 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.nodes.BuiltinNames;
    @@ -95,13 +95,13 @@ static Object iter(PGrouper self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PGrouper self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached PyObjectRichCompareBool.EqNode eqNode,
                             @Cached InlinedBranchProfile currGrouperProfile,
    @@ -116,7 +116,10 @@ static Object next(VirtualFrame frame, PGrouper self,
                 }
                 if (gbo.getCurrValue() == null) {
                     currValueMarkerProfile.enter(inliningTarget);
    -                gbo.groupByStep(frame, inliningTarget, nextNode, callNode, hasFuncProfile);
    +                boolean cont = gbo.groupByStep(frame, inliningTarget, nextNode, callNode, hasFuncProfile);
    +                if (!cont) {
    +                    return iteratorExhausted();
    +                }
                 }
                 if (!eqNode.compare(frame, inliningTarget, self.getTgtKey(), gbo.getCurrKey())) {
                     currValueTgtProfile.enter(inliningTarget);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    index cd0e7c1015..5ced7b259a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/IsliceBuiltins.java
    @@ -40,10 +40,8 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETSTATE__;
    @@ -57,10 +55,14 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -101,57 +103,57 @@ static Object iter(PIslice self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "isNone(self.getIterable())")
    -        static Object next(@SuppressWarnings("unused") PIslice self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, StopIteration);
    +        static Object next(@SuppressWarnings("unused") PIslice self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!isNone(self.getIterable())")
             static Object next(VirtualFrame frame, PIslice self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached InlinedLoopConditionProfile loopProfile,
                             @Cached InlinedBranchProfile nextExceptionProfile,
    -                        @Cached InlinedBranchProfile nextExceptionProfile2,
    -                        @Cached InlinedBranchProfile setNextProfile,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached InlinedBranchProfile setNextProfile) {
                 Object it = self.getIterable();
    +            TpSlot iterNext = getSlots.execute(inliningTarget, it).tp_iternext();
                 int stop = self.getStop();
                 Object item;
    -            while (loopProfile.profile(inliningTarget, self.getCnt() < self.getNext())) {
    -                try {
    -                    item = nextNode.execute(frame, it, PNone.NO_VALUE);
    -                } catch (PException e) {
    -                    nextExceptionProfile.enter(inliningTarget);
    -                    // C code uses any exception to clear the iterator
    +            try {
    +                while (loopProfile.profile(inliningTarget, self.getCnt() < self.getNext())) {
    +                    item = callIterNext.execute(frame, inliningTarget, iterNext, it);
    +                    if (PyIterNextNode.isExhausted(item)) {
    +                        self.setIterable(PNone.NONE);
    +                        return iteratorExhausted();
    +                    }
    +                    self.setCnt(self.getCnt() + 1);
    +                }
    +                if (stop != -1 && self.getCnt() >= stop) {
                         self.setIterable(PNone.NONE);
    -                    throw e;
    +                    return iteratorExhausted();
    +                }
    +                item = callIterNext.execute(frame, inliningTarget, iterNext, it);
    +                if (PyIterNextNode.isExhausted(item)) {
    +                    self.setIterable(PNone.NONE);
    +                    return iteratorExhausted();
                     }
                     self.setCnt(self.getCnt() + 1);
    -            }
    -            if (stop != -1 && self.getCnt() >= stop) {
    -                self.setIterable(PNone.NONE);
    -                throw raiseNode.raise(inliningTarget, StopIteration);
    -            }
    -            try {
    -                item = nextNode.execute(frame, it, PNone.NO_VALUE);
    +                int oldNext = self.getNext();
    +                self.setNext(self.getNext() + self.getStep());
    +                if (self.getNext() < oldNext || (stop != -1 && self.getNext() > stop)) {
    +                    setNextProfile.enter(inliningTarget);
    +                    self.setNext(stop);
    +                }
    +                return item;
                 } catch (PException e) {
    -                nextExceptionProfile2.enter(inliningTarget);
    +                nextExceptionProfile.enter(inliningTarget);
                     self.setIterable(PNone.NONE);
                     throw e;
                 }
    -            self.setCnt(self.getCnt() + 1);
    -            int oldNext = self.getNext();
    -            self.setNext(self.getNext() + self.getStep());
    -            if (self.getNext() < oldNext || (stop != -1 && self.getNext() > stop)) {
    -                setNextProfile.enter(inliningTarget);
    -                self.setNext(stop);
    -            }
    -            return item;
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    index 9ab040d504..3a3a941ab0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2021, 2025, 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
    @@ -40,9 +40,8 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    @@ -110,8 +109,11 @@ public void setCurrKey(Object currKey) {
             this.currKey = currKey;
         }
     
    -    void groupByStep(VirtualFrame frame, Node inliningTarget, BuiltinFunctions.NextNode nextNode, CallNode callNode, InlinedConditionProfile hasFuncProfile) {
    -        Object newValue = nextNode.execute(frame, it, PNone.NO_VALUE);
    +    boolean groupByStep(VirtualFrame frame, Node inliningTarget, PyIterNextNode nextNode, CallNode callNode, InlinedConditionProfile hasFuncProfile) {
    +        Object newValue = nextNode.execute(frame, it);
    +        if (PyIterNextNode.isExhausted(newValue)) {
    +            return false;
    +        }
             Object newKey;
             if (hasFuncProfile.profile(inliningTarget, keyFunc == null)) {
                 newKey = newValue;
    @@ -120,5 +122,6 @@ void groupByStep(VirtualFrame frame, Node inliningTarget, BuiltinFunctions.NextN
             }
             currValue = newValue;
             currKey = newKey;
    +        return true;
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    index cb20fc0baa..737723c0cd 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    @@ -45,9 +45,9 @@
     
     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.object.PythonBuiltinObject;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.frame.VirtualFrame;
    @@ -122,7 +122,7 @@ PTeeDataObject jumplink(PythonLanguage language) {
             return nextlink;
         }
     
    -    Object getItem(VirtualFrame frame, Node inliningTarget, int i, BuiltinFunctions.NextNode nextNode, PRaiseNode raiseNode) {
    +    Object getItem(VirtualFrame frame, Node inliningTarget, int i, PyIterNextNode nextNode, PRaiseNode raiseNode) {
             assert i < TeeDataObjectBuiltins.LINKCELLS;
             if (i < numread) {
                 return values[i];
    @@ -135,10 +135,13 @@ Object getItem(VirtualFrame frame, Node inliningTarget, int i, BuiltinFunctions.
                 running = true;
                 Object value;
                 try {
    -                value = nextNode.execute(frame, it, PNone.NO_VALUE);
    +                value = nextNode.execute(frame, it);
                 } finally {
                     running = false;
                 }
    +            if (PyIterNextNode.isExhausted(value)) {
    +                return TpIterNextBuiltin.iteratorExhausted();
    +            }
                 values[numread++] = value;
                 return value;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    index 834be21c68..93424dfbc9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    @@ -40,24 +40,19 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    -
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.Slot;
     import com.oracle.graal.python.annotations.Slot.SlotKind;
    -import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
    @@ -67,6 +62,7 @@
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedBranchProfile;
     
     @CoreFunctions(extendClasses = {PythonBuiltinClassType.PPairwise})
     public final class PairwiseBuiltins extends PythonBuiltins {
    @@ -87,37 +83,52 @@ static Object iter(PPairwise self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getIterable() != null")
             static Object next(VirtualFrame frame, PPairwise self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile,
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached InlinedBranchProfile exceptionProfile,
                             @Bind PythonLanguage language) {
                 Object item;
                 Object old = self.getOld();
    -            if (self.getOld() == null) {
    -                old = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    -                self.setOld(old);
    -            }
    +            Object iterable = self.getIterable();
                 try {
    -                item = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +                if (self.getOld() == null) {
    +                    old = nextNode.execute(frame, iterable);
    +                    if (PyIterNextNode.isExhausted(old)) {
    +                        self.setOld(null);
    +                        self.setIterable(null);
    +                        return iteratorExhausted();
    +                    }
    +                    self.setOld(old);
    +                    iterable = self.getIterable();
    +                    if (iterable == null) {
    +                        self.setOld(null);
    +                        return iteratorExhausted();
    +                    }
    +                }
    +                item = nextNode.execute(frame, iterable);
    +                if (PyIterNextNode.isExhausted(item)) {
    +                    self.setOld(null);
    +                    self.setIterable(null);
    +                    return iteratorExhausted();
    +                }
                     self.setOld(item);
    +                return PFactory.createTuple(language, new Object[]{old, item});
                 } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, isStopIterationProfile);
    -                self.setIterable(null);
    +                exceptionProfile.enter(inliningTarget);
                     self.setOld(null);
    +                self.setIterable(null);
                     throw e;
                 }
    -            return PFactory.createTuple(language, new Object[]{old, item});
             }
     
             @Specialization(guards = "self.getIterable() == null")
    -        static Object next(@SuppressWarnings("unused") PPairwise self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration);
    +        static Object next(@SuppressWarnings("unused") PPairwise self) {
    +            return iteratorExhausted();
             }
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    index 3031b3467e..66142d596a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PermutationsBuiltins.java
    @@ -40,11 +40,9 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.ErrorMessages.INVALID_ARGS;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETSTATE__;
    @@ -63,6 +61,7 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.GetItemNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -105,14 +104,13 @@ static Object iter(PPermutations self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.isStopped()")
    -        static Object next(PPermutations self,
    -                        @Bind("this") Node inliningTarget) {
    +        static Object next(PPermutations self) {
                 self.setRaisedStopIteration(true);
    -            throw PRaiseNode.raiseStatic(inliningTarget, StopIteration);
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!self.isStopped()")
    @@ -123,8 +121,7 @@ static Object next(PPermutations self,
                             @Cached InlinedLoopConditionProfile resultLoopProfile,
                             @Cached InlinedLoopConditionProfile mainLoopProfile,
                             @Cached InlinedLoopConditionProfile shiftIndicesProfile,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Bind PythonLanguage language) {
                 int r = self.getR();
     
                 int[] indices = self.getIndices();
    @@ -161,7 +158,7 @@ static Object next(PPermutations self,
     
                 self.setStopped(true);
                 if (isStartedProfile.profile(inliningTarget, self.isStarted())) {
    -                throw raiseNode.raise(inliningTarget, StopIteration);
    +                return iteratorExhausted();
                 } else {
                     self.setStarted(true);
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    index ced590cfb9..0aa630a53e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ProductBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -57,9 +56,9 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyLongAsIntNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
    -import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -97,9 +96,9 @@ static Object iter(PProduct self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
     
             @Specialization(guards = {"!self.isStopped()", "!hasLst(self)"})
             static Object next(PProduct self,
    @@ -123,8 +122,7 @@ static Object next(PProduct self,
                             @Cached InlinedBranchProfile wasStoppedProfile,
                             @Exclusive @Cached InlinedLoopConditionProfile loopProfile,
                             @Cached InlinedBranchProfile doneProfile,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Bind PythonLanguage language) {
                 Object[][] gears = self.getGears();
                 int x = gears.length - 1;
                 if (gearsProfile.profile(inliningTarget, x >= 0)) {
    @@ -144,7 +142,7 @@ static Object next(PProduct self,
     
                 if (self.isStopped()) {
                     wasStoppedProfile.enter(inliningTarget);
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
     
                 // the existing lst array can be changed in a following next call
    @@ -153,11 +151,9 @@ static Object next(PProduct self,
                 return PFactory.createTuple(language, ret);
             }
     
    -        @SuppressWarnings("unused")
             @Specialization(guards = "self.isStopped()")
    -        static Object nextStopped(PProduct self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration);
    +        static Object nextStopped(@SuppressWarnings("unused") PProduct self) {
    +            return iteratorExhausted();
             }
     
             private static void rotatePreviousGear(Node inliningTarget, PProduct self, InlinedLoopConditionProfile loopProfile, InlinedBranchProfile doneProfile) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    index 7f971389be..8f983d59c7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java
    @@ -40,12 +40,10 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.nodes.ErrorMessages.LEN_OF_UNSIZED_OBJECT;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__;
     
    @@ -61,6 +59,7 @@
     import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectReprAsObjectNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -99,20 +98,18 @@ static Object iter(PRepeat self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getCnt() > 0")
             static Object nextPos(PRepeat self) {
                 self.setCnt(self.getCnt() - 1);
                 return self.getElement();
             }
     
    -        @SuppressWarnings("unused")
             @Specialization(guards = "self.getCnt() == 0")
    -        static Object nextZero(PRepeat self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, StopIteration);
    +        static Object nextZero(@SuppressWarnings("unused") PRepeat self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "self.getCnt() < 0")
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    index c4803e4945..27e00c2253 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -52,11 +51,11 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -90,15 +89,18 @@ static Object iter(PStarmap self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object nextPos(VirtualFrame frame, PStarmap self,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached ExecutePositionalStarargsNode getArgsNode) {
    -            Object obj = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +            Object obj = nextNode.execute(frame, self.getIterable());
    +            if (PyIterNextNode.isExhausted(obj)) {
    +                return iteratorExhausted();
    +            }
                 Object[] args = getArgsNode.executeWith(frame, obj);
                 return callNode.execute(frame, self.getFun(), args, PKeyword.EMPTY_KEYWORDS);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    index 5d9255b9bf..6a89ef4e5a 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -52,12 +51,11 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    -import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.CallNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -91,21 +89,22 @@ static Object iter(PTakewhile self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PTakewhile self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached PyObjectIsTrueNode isTrue,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    -            Object value = nextNode.execute(frame, self.getIterable(), PNone.NO_VALUE);
    +                        @Bind PythonLanguage language) {
    +            Object value = nextNode.execute(frame, self.getIterable());
    +            if (PyIterNextNode.isExhausted(value)) {
    +                return iteratorExhausted();
    +            }
                 if (!isTrue.execute(frame, callNode.execute(frame, self.getPredicate(), value))) {
                     self.setIterable(PFactory.createSequenceIterator(language, PFactory.createList(language, PythonUtils.EMPTY_OBJECT_ARRAY)));
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 return value;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    index 2d953e9a95..80d2393aa7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    @@ -48,7 +48,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.IS_NOT_A;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___COPY__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___COPY__;
    @@ -62,12 +61,13 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins.LenNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
    @@ -144,14 +144,14 @@ static Object iter(PTee self) {
             }
         }
     
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @ImportStatic(TeeDataObjectBuiltins.class)
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getIndex() < LINKCELLS")
             static Object next(VirtualFrame frame, PTee self,
                             @Bind("this") Node inliningTarget,
    -                        @Shared @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Shared @Cached PRaiseNode raiseNode) {
                 Object value = self.getDataobj().getItem(frame, inliningTarget, self.getIndex(), nextNode, raiseNode);
                 self.setIndex(self.getIndex() + 1);
    @@ -161,7 +161,7 @@ static Object next(VirtualFrame frame, PTee self,
             @Specialization(guards = "self.getIndex() >= LINKCELLS")
             static Object nextNext(VirtualFrame frame, PTee self,
                             @Bind("this") Node inliningTarget,
    -                        @Shared @Cached BuiltinFunctions.NextNode nextNode,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Bind PythonLanguage language,
                             @Shared @Cached PRaiseNode raiseNode) {
                 self.setDataObj(self.getDataobj().jumplink(language));
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    index 74c04c8503..2b1c07e327 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    @@ -40,8 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.itertools;
     
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     
    @@ -54,15 +52,14 @@
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
    -import com.oracle.graal.python.builtins.modules.BuiltinFunctions;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -95,32 +92,23 @@ static Object iter(PZipLongest self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    -        @SuppressWarnings("unused")
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "zeroSize(self)")
    -        static Object nextNoFillValue(VirtualFrame frame, PZipLongest self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, StopIteration);
    +        static Object nextNoFillValue(@SuppressWarnings("unused") PZipLongest self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!zeroSize(self)")
             static Object next(VirtualFrame frame, PZipLongest self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached BuiltinFunctions.NextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached InlinedConditionProfile noItProfile,
                             @Cached InlinedConditionProfile noActiveProfile,
                             @Cached InlinedLoopConditionProfile loopProfile,
    -                        @Cached InlinedConditionProfile isNullFillProfile,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Cached InlinedConditionProfile isNullFillProfile) {
                 Object fillValue = isNullFillProfile.profile(inliningTarget, isNullFillValue(self)) ? PNone.NONE : self.getFillValue();
    -            return next(frame, inliningTarget, self, fillValue, nextNode, isStopIterationProfile, loopProfile, noItProfile, noActiveProfile, raiseNode);
    -        }
    -
    -        private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest self, Object fillValue, BuiltinFunctions.NextNode nextNode, IsBuiltinObjectProfile isStopIterationProfile,
    -                        InlinedLoopConditionProfile loopProfile, InlinedConditionProfile noItProfile, InlinedConditionProfile noActiveProfile, PRaiseNode raiseNode) {
                 Object[] result = new Object[self.getItTuple().length];
                 loopProfile.profileCounted(inliningTarget, result.length);
                 for (int i = 0; loopProfile.inject(inliningTarget, i < result.length); i++) {
    @@ -130,19 +118,18 @@ private static Object next(VirtualFrame frame, Node inliningTarget, PZipLongest
                         item = fillValue;
                     } else {
                         try {
    -                        item = nextNode.execute(frame, it, PNone.NO_VALUE);
    +                        item = nextNode.execute(frame, it);
                         } catch (PException e) {
    -                        if (isStopIterationProfile.profileException(inliningTarget, e, StopIteration)) {
    -                            self.setNumActive(self.getNumActive() - 1);
    -                            if (noActiveProfile.profile(inliningTarget, self.getNumActive() == 0)) {
    -                                throw raiseNode.raise(inliningTarget, StopIteration);
    -                            } else {
    -                                item = fillValue;
    -                                self.getItTuple()[i] = PNone.NONE;
    -                            }
    +                        self.setNumActive(0);
    +                        throw e;
    +                    }
    +                    if (PyIterNextNode.isExhausted(item)) {
    +                        self.setNumActive(self.getNumActive() - 1);
    +                        if (noActiveProfile.profile(inliningTarget, self.getNumActive() == 0)) {
    +                            return iteratorExhausted();
                             } else {
    -                            self.setNumActive(0);
    -                            throw e;
    +                            item = fillValue;
    +                            self.getItTuple()[i] = PNone.NONE;
                             }
                         }
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    index 201ddaf0c7..be59a30205 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.map;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -55,7 +54,8 @@
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
    @@ -79,24 +79,31 @@ protected List> getNodeFa
             return MapBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getIterators().length == 1")
             Object doOne(VirtualFrame frame, PMap self,
                             @Shared @Cached CallVarargsMethodNode callNode,
    -                        @Shared @Cached GetNextNode next) {
    -            return callNode.execute(frame, self.getFunction(), new Object[]{next.execute(frame, self.getIterators()[0])}, PKeyword.EMPTY_KEYWORDS);
    +                        @Shared @Cached PyIterNextNode nextNode) {
    +            Object item = nextNode.execute(frame, self.getIterators()[0]);
    +            if (PyIterNextNode.isExhausted(item)) {
    +                return iteratorExhausted();
    +            }
    +            return callNode.execute(frame, self.getFunction(), new Object[]{item}, PKeyword.EMPTY_KEYWORDS);
             }
     
             @Specialization(replaces = "doOne")
             Object doNext(VirtualFrame frame, PMap self,
                             @Shared @Cached CallVarargsMethodNode callNode,
    -                        @Shared @Cached GetNextNode next) {
    +                        @Shared @Cached PyIterNextNode nextNode) {
                 Object[] iterators = self.getIterators();
                 Object[] arguments = new Object[iterators.length];
                 for (int i = 0; i < iterators.length; i++) {
    -                arguments[i] = next.execute(frame, iterators[i]);
    +                arguments[i] = nextNode.execute(frame, iterators[i]);
    +                if (PyIterNextNode.isExhausted(arguments[i])) {
    +                    return iteratorExhausted();
    +                }
                 }
                 return callNode.execute(frame, self.getFunction(), arguments, PKeyword.EMPTY_KEYWORDS);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    index 5fa9dc56e4..ac7d2f5b21 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictIteratorBuiltins.java
    @@ -42,9 +42,7 @@
     
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.KeyError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
    @@ -60,6 +58,7 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -95,16 +94,16 @@ static Object iter(POrderedDictIterator self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, POrderedDictIterator self,
                             @Bind("this") Node inliningTarget,
                             @Cached PRaiseNode raiseNode,
                             @Cached HashingStorageNodes.HashingStorageGetItemWithHash getItem) {
                 if (self.current == null) {
    -                throw raiseNode.raise(inliningTarget, StopIteration);
    +                return iteratorExhausted();
                 }
                 if (self.size != self.dict.nodes.size()) {
                     throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.CHANGED_SIZE_DURING_ITERATION, "OrderedDict");
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    index 71ae05ca9f..08e8114fa7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/ScandirIteratorBuiltins.java
    @@ -42,7 +42,6 @@
     
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ENTER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EXIT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    @@ -55,8 +54,8 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.PConstructAndRaiseNode;
    -import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -108,25 +107,24 @@ PScandirIterator iter(PScandirIterator self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
    -        static PDirEntry next(VirtualFrame frame, PScandirIterator self,
    +        static Object next(VirtualFrame frame, PScandirIterator self,
                             @Bind("this") Node inliningTarget,
                             @CachedLibrary("getPosixSupport()") PosixSupportLibrary posixLib,
                             @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Bind PythonLanguage language) {
                 if (self.ref.isReleased()) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 PosixSupport posixSupport = PosixSupport.get(inliningTarget);
                 try {
                     Object dirEntryData = posixLib.readdir(posixSupport, self.ref.getReference());
                     if (dirEntryData == null) {
                         self.ref.rewindAndClose(posixLib, posixSupport);
    -                    throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                    return iteratorExhausted();
                     }
                     return PFactory.createDirEntry(language, dirEntryData, self.path);
                 } catch (PosixException e) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    index a4b3afc232..0d92d4f847 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/reversed/ReversedBuiltins.java
    @@ -27,7 +27,6 @@
     
     import static com.oracle.graal.python.nodes.ErrorMessages.OBJ_HAS_NO_LEN;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__;
     import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
    @@ -47,6 +46,7 @@
     import com.oracle.graal.python.builtins.objects.iterator.PBuiltinIterator;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
     import com.oracle.graal.python.lib.PySequenceGetItemNode;
    @@ -61,7 +61,6 @@
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    -import com.oracle.truffle.api.dsl.Cached.Exclusive;
     import com.oracle.truffle.api.dsl.Cached.Shared;
     import com.oracle.truffle.api.dsl.GenerateNodeFactory;
     import com.oracle.truffle.api.dsl.NodeFactory;
    @@ -85,22 +84,20 @@ protected List> getNodeFa
             return ReversedBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
     
             @Specialization(guards = "self.isExhausted()")
    -        static Object exhausted(@SuppressWarnings("unused") PBuiltinIterator self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration);
    +        static Object exhausted(@SuppressWarnings("unused") PBuiltinIterator self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!self.isExhausted()")
             static Object next(VirtualFrame frame, PSequenceReverseIterator self,
                             @Bind("this") Node inliningTarget,
                             @Cached PySequenceGetItemNode getItemNode,
    -                        @Cached IsBuiltinObjectProfile profile,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached IsBuiltinObjectProfile profile) {
                 if (self.index >= 0) {
                     try {
                         return getItemNode.execute(frame, self.getObject(), self.index--);
    @@ -109,19 +106,17 @@ static Object next(VirtualFrame frame, PSequenceReverseIterator self,
                     }
                 }
                 self.setExhausted();
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!self.isExhausted()")
             static Object next(PStringReverseIterator self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Cached TruffleString.SubstringNode substringNode,
    -                        @Exclusive @Cached PRaiseNode raiseNode) {
    +                        @Cached TruffleString.SubstringNode substringNode) {
                 if (self.index >= 0) {
                     return substringNode.execute(self.value, self.index--, 1, TS_ENCODING, false);
                 }
                 self.setExhausted();
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +            return iteratorExhausted();
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    index 234d02e140..df29e2ba24 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/struct/StructUnpackIteratorBuiltins.java
    @@ -9,7 +9,6 @@
     import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_CREATE_P_OBJECTS;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     
     import java.util.List;
     
    @@ -24,6 +23,7 @@
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.iterator.PStructUnpackIterator;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
    @@ -82,23 +82,20 @@ static int lenHint(PStructUnpackIterator self,
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    public abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.isExhausted()")
    -        static Object nextExhausted(@SuppressWarnings("unused") PStructUnpackIterator self,
    -                        @Bind("this") Node inliningTarget) {
    -            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.StopIteration);
    +        static Object nextExhausted(@SuppressWarnings("unused") PStructUnpackIterator self) {
    +            return iteratorExhausted();
             }
     
             @Specialization(guards = "!self.isExhausted()", limit = "3")
             static Object next(VirtualFrame frame, PStructUnpackIterator self,
    -                        @Bind("this") Node inliningTarget,
                             @Cached("createFor(this)") IndirectCallData indirectCallData,
                             @Cached StructNodes.UnpackValueNode unpackValueNode,
                             @CachedLibrary("self.getBuffer()") PythonBufferAccessLibrary bufferLib,
    -                        @Bind PythonLanguage language,
    -                        @Cached PRaiseNode raiseNode) {
    +                        @Bind PythonLanguage language) {
                 final PStruct struct = self.getStruct();
                 final Object buffer = self.getBuffer();
                 final int bufferLen = bufferLib.getBufferLength(buffer);
    @@ -106,7 +103,7 @@ static Object next(VirtualFrame frame, PStructUnpackIterator self,
                 if (struct == null || self.index >= bufferLen) {
                     self.setExhausted();
                     bufferLib.release(buffer, frame, indirectCallData);
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
     
                 assert self.index + struct.getSize() <= bufferLen;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    index 6eaf32df4e..1c77c23df1 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tokenize/TokenizerIterBuiltins.java
    @@ -40,7 +40,6 @@
      */
     package com.oracle.graal.python.builtins.objects.tokenize;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
     import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
     
    @@ -49,12 +48,12 @@
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.annotations.Slot;
     import com.oracle.graal.python.annotations.Slot.SlotKind;
    -import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    @@ -88,9 +87,9 @@ static PTokenizerIter iter(PTokenizerIter self) {
             }
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    abstract static class NextNode extends TpIterNextBuiltin {
             private static final TruffleString T_EOF = tsLiteral("EOF");
     
             @Specialization
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    index ad4732c983..98b2965e81 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    @@ -78,6 +78,7 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MUL__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEG__;
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__;
    @@ -129,6 +130,7 @@
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.DescrSetFunctionWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.GetAttrWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.InquiryWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.IterNextWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.LenfuncWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbInPlacePowerWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.NbPowerWrapper;
    @@ -169,6 +171,8 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.TpSlotGetAttrBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.TpSlotGetAttrPython;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.TpSlotInquiryBuiltin;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpSlotIterNextBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.TpSlotLenBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.TpSlotMpAssSubscriptBuiltin;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.TpSlotMpAssSubscriptPython;
    @@ -317,12 +321,16 @@ public record TpSlots(TpSlot nb_bool, //
                     TpSlot tp_setattr,
                     TpSlot combined_tp_setattro_setattr,
                     TpSlot tp_iter, //
    +                TpSlot tp_iternext, //
                     boolean has_as_number,
                     boolean has_as_sequence,
                     boolean has_as_mapping) {
     
         private static final TruffleLogger LOGGER = PythonLanguage.getLogger(TpSlot.class);
     
    +    // Force class initialization earlier
    +    private static final TpSlot NEXT_NOT_IMPLEMENTED = TpSlotIterNext.NEXT_NOT_IMPLEMENTED;
    +
         @FunctionalInterface
         private interface TpSlotGetter {
             TpSlot get(TpSlots slots);
    @@ -837,7 +845,15 @@ public enum TpSlotMeta {
                             TpSlotGroup.NO_GROUP,
                             CFields.PyTypeObject__tp_iter,
                             PExternalFunctionWrapper.UNARYFUNC,
    -                        UnaryFuncWrapper::new);
    +                        UnaryFuncWrapper::new),
    +        TP_ITERNEXT(
    +                        TpSlots::tp_iternext,
    +                        TpSlotPythonSingle.class,
    +                        TpSlotIterNextBuiltin.class,
    +                        TpSlotGroup.NO_GROUP,
    +                        CFields.PyTypeObject__tp_iternext,
    +                        PExternalFunctionWrapper.ITERNEXT,
    +                        IterNextWrapper::new);
     
             public static final TpSlotMeta[] VALUES = values();
     
    @@ -1018,6 +1034,7 @@ private static void addSlotDef(LinkedHashMap defs, TpSl
                             TpSlotDef.withoutHPy(T___SET__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_SET), //
                             TpSlotDef.withoutHPy(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE));
             addSlotDef(s, TpSlotMeta.TP_ITER, TpSlotDef.withSimpleFunction(T___ITER__, PExternalFunctionWrapper.UNARYFUNC));
    +        addSlotDef(s, TpSlotMeta.TP_ITERNEXT, TpSlotDef.withSimpleFunction(T___NEXT__, PExternalFunctionWrapper.ITERNEXT));
             addSlotDef(s, TpSlotMeta.NB_ADD,
                             TpSlotDef.withoutHPy(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L),
                             TpSlotDef.withoutHPy(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R));
    @@ -1371,19 +1388,18 @@ private static Builder updateSlots(PythonAbstractClass klass, Builder slots, Set
                 // dynamic lookup.
                 for (int i = 0; i < defs.length; i++) {
                     TruffleString name = defs[i].name();
    -                Object decr = lookup.execute(klass, name);
    -                genericCallables[i] = decr;
    +                Object descr = lookup.execute(klass, name);
    +                genericCallables[i] = descr;
                     genericCallablesNames[i] = name;
    -                if (decr == PNone.NO_VALUE) {
    -                    /*- TODO:
    -                    if (ptr == (void**)&type->tp_iternext) {
    -                        specific = (void *)_PyObject_NextNotImplemented;
    -                    }*/
    +                if (descr == PNone.NO_VALUE) {
    +                    if (slot == TpSlotMeta.TP_ITERNEXT) {
    +                        specific = NEXT_NOT_IMPLEMENTED;
    +                    }
                         continue;
                     }
                     // Is the value a builtin function (in CPython PyWrapperDescr_Type) that wraps a
                     // builtin or native slot?
    -                if (decr instanceof PBuiltinFunction builtin && builtin.getSlot() != null) {
    +                if (descr instanceof PBuiltinFunction builtin && builtin.getSlot() != null) {
                         /*
                          * CPython source comment: if the special method is a wrapper_descriptor with
                          * the correct name but the type has precisely one slot set for that name and
    @@ -1738,6 +1754,7 @@ public TpSlots build() {
                                 get(TpSlotMeta.TP_SETATTR),
                                 tp_set_attro_attr,
                                 get(TpSlotMeta.TP_ITER), //
    +                            get(TpSlotMeta.TP_ITERNEXT), //
                                 hasGroup(TpSlotGroup.AS_NUMBER),
                                 hasGroup(TpSlotGroup.AS_SEQUENCE),
                                 hasGroup(TpSlotGroup.AS_MAPPING));
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotIterNext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotIterNext.java
    new file mode 100644
    index 0000000000..4d8aa93d72
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotIterNext.java
    @@ -0,0 +1,221 @@
    +/*
    + * Copyright (c) 2025, 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.builtins.objects.type.slots;
    +
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
    +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
    +
    +import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
    +import com.oracle.graal.python.builtins.Python3Core;
    +import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    +import com.oracle.graal.python.builtins.objects.PNone;
    +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode;
    +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming;
    +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonTransferNode;
    +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode;
    +import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ClearCurrentExceptionNode;
    +import com.oracle.graal.python.builtins.objects.function.PArguments;
    +import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
    +import com.oracle.graal.python.builtins.objects.type.slots.NodeFactoryUtils.WrapperNodeFactory;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.CallSlotUnaryPythonNode;
    +import com.oracle.graal.python.nodes.ErrorMessages;
    +import com.oracle.graal.python.nodes.PRaiseNode;
    +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    +import com.oracle.graal.python.runtime.ExecutionContext.CallContext;
    +import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode;
    +import com.oracle.graal.python.runtime.PythonContext.PythonThreadState;
    +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
    +import com.oracle.truffle.api.RootCallTarget;
    +import com.oracle.truffle.api.dsl.Bind;
    +import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateCached;
    +import com.oracle.truffle.api.dsl.GenerateInline;
    +import com.oracle.truffle.api.dsl.GenerateNodeFactory;
    +import com.oracle.truffle.api.dsl.GenerateUncached;
    +import com.oracle.truffle.api.dsl.NodeFactory;
    +import com.oracle.truffle.api.dsl.Specialization;
    +import com.oracle.truffle.api.frame.VirtualFrame;
    +import com.oracle.truffle.api.nodes.IndirectCallNode;
    +import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedConditionProfile;
    +import com.oracle.truffle.api.strings.TruffleString;
    +
    +public final class TpSlotIterNext {
    +    private TpSlotIterNext() {
    +    }
    +
    +    /**
    +     * Marker value that {@code tp_iternext} slots can return instead of raising
    +     * {@code StopIteration} to indicate the same.
    +     */
    +    public static final Object ITERATOR_EXHAUSTED = PNone.NO_VALUE;
    +
    +    /** Equivalent of {@code _PyObject_NextNotImplemented} */
    +    public static final TpSlot NEXT_NOT_IMPLEMENTED = TpSlotIterNextSlotsGen.SLOTS.tp_iternext();
    +
    +    public abstract static class TpSlotIterNextBuiltin extends TpSlotBuiltin {
    +        final int callTargetIndex = TpSlotBuiltinCallTargetRegistry.getNextCallTargetIndex();
    +
    +        protected TpSlotIterNextBuiltin(NodeFactory nodeFactory) {
    +            super(nodeFactory);
    +        }
    +
    +        final PythonUnaryBuiltinNode createSlotNode() {
    +            return createNode();
    +        }
    +
    +        @Override
    +        public final void initialize(PythonLanguage language) {
    +            RootCallTarget callTarget = createBuiltinCallTarget(language, BuiltinSlotWrapperSignature.UNARY, getNodeFactory(), J___NEXT__);
    +            language.setBuiltinSlotCallTarget(callTargetIndex, callTarget);
    +        }
    +
    +        @Override
    +        public PBuiltinFunction createBuiltin(Python3Core core, Object type, TruffleString tsName, PExternalFunctionWrapper wrapper) {
    +            var factory = new WrapperNodeFactory<>(getNodeFactory(), TpIterNextBuiltinWrapperNode.class, TpIterNextBuiltinWrapperNode::new);
    +            return createBuiltin(core, type, tsName, BuiltinSlotWrapperSignature.UNARY, wrapper, factory);
    +        }
    +    }
    +
    +    public static final class TpIterNextBuiltinWrapperNode extends PythonUnaryBuiltinNode {
    +        @Child PythonUnaryBuiltinNode delegate;
    +
    +        public TpIterNextBuiltinWrapperNode(PythonUnaryBuiltinNode delegate) {
    +            this.delegate = delegate;
    +        }
    +
    +        @Override
    +        public Object execute(VirtualFrame frame, Object arg) {
    +            Object result = delegate.execute(frame, arg);
    +            if (result == ITERATOR_EXHAUSTED) {
    +                throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.StopIteration);
    +            }
    +            return result;
    +        }
    +    }
    +
    +    /**
    +     * Convenience base class for {@code tp_iternext} builtin implementations.
    +     * {@code PythonUnaryBuiltinNode} can be used instead if necessitated by existing inheritance
    +     * hierarchy.
    +     */
    +    @GenerateInline(value = false, inherit = true)
    +    public abstract static class TpIterNextBuiltin extends PythonUnaryBuiltinNode {
    +        /**
    +         * Return the marker value used by {@code tp_iternext} slots to indicate the iteration
    +         * should stop. A faster equivalent to raising {@code StopIteration} python exception.
    +         * Returns the same constant as
    +         */
    +        public static Object iteratorExhausted() {
    +            return ITERATOR_EXHAUSTED;
    +        }
    +    }
    +
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
    +    @GenerateNodeFactory
    +    abstract static class NextNotImplementedNode extends PythonUnaryBuiltinNode {
    +        @Specialization
    +        static Object error(Object iterable,
    +                        @Bind Node inliningTarget) {
    +            throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterable);
    +        }
    +    }
    +
    +    @GenerateInline
    +    @GenerateCached(false)
    +    @GenerateUncached
    +    public abstract static class CallSlotTpIterNextNode extends Node {
    +        private static final CApiTiming C_API_TIMING = CApiTiming.create(true, "iternext");
    +
    +        public abstract Object execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object self);
    +
    +        @Specialization(guards = "cachedSlot == slot", limit = "3")
    +        static Object callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") TpSlotIterNextBuiltin slot, Object self,
    +                        @SuppressWarnings("unused") @Cached("slot") TpSlotIterNextBuiltin cachedSlot,
    +                        @Cached("cachedSlot.createSlotNode()") PythonUnaryBuiltinNode slotNode) {
    +            return slotNode.execute(frame, self);
    +        }
    +
    +        @Specialization
    +        static Object callPython(VirtualFrame frame, TpSlotPythonSingle slot, Object self,
    +                        @Cached(inline = false) CallSlotUnaryPythonNode callSlotNode) {
    +            return callSlotNode.execute(frame, slot, self);
    +        }
    +
    +        @Specialization
    +        static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, Object self,
    +                        @Cached GetThreadStateNode getThreadStateNode,
    +                        @Cached(inline = false) PythonToNativeNode toNativeNode,
    +                        @Cached ExternalFunctionInvokeNode externalInvokeNode,
    +                        @Cached(inline = false) NativeToPythonTransferNode toPythonNode,
    +                        @Cached ClearCurrentExceptionNode clearCurrentExceptionNode) {
    +            PythonThreadState state = getThreadStateNode.execute(inliningTarget);
    +            Object nativeResult = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___NEXT__, slot.callable,
    +                            toNativeNode.execute(self));
    +            Object pythonResult = toPythonNode.execute(nativeResult);
    +            if (pythonResult == PNone.NO_VALUE) {
    +                if (state.getCurrentException() != null) {
    +                    throw clearCurrentExceptionNode.getCurrentExceptionForReraise(inliningTarget, state);
    +                } else {
    +                    return ITERATOR_EXHAUSTED;
    +                }
    +            }
    +            return pythonResult;
    +        }
    +
    +        @Specialization(replaces = "callCachedBuiltin")
    +        @InliningCutoff
    +        static Object callGenericBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotIterNextBuiltin slot, Object self,
    +                        @Cached(inline = false) CallContext callContext,
    +                        @Cached InlinedConditionProfile isNullFrameProfile,
    +                        @Cached(inline = false) IndirectCallNode indirectCallNode) {
    +            Object[] arguments = PArguments.create(1);
    +            PArguments.setArgument(arguments, 0, self);
    +            return BuiltinDispatchers.callGenericBuiltin(frame, inliningTarget, slot.callTargetIndex, arguments, callContext, isNullFrameProfile, indirectCallNode);
    +        }
    +    }
    +}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java
    index bba33da549..d637414ff1 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasIteratorBuiltins.java
    @@ -41,19 +41,21 @@
     package com.oracle.graal.python.builtins.objects.types;
     
     import static com.oracle.graal.python.nodes.BuiltinNames.T_ITER;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__;
     
     import java.util.List;
     
     import com.oracle.graal.python.PythonLanguage;
    +import com.oracle.graal.python.annotations.Slot;
    +import com.oracle.graal.python.annotations.Slot.SlotKind;
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.CoreFunctions;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
    -import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.runtime.PythonContext;
    @@ -68,21 +70,22 @@
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PGenericAliasIterator)
     public final class GenericAliasIteratorBuiltins extends PythonBuiltins {
    +
    +    public static final TpSlots SLOTS = GenericAliasIteratorBuiltinsSlotsGen.SLOTS;
    +
         @Override
         protected List> getNodeFactories() {
             return GenericAliasIteratorBuiltinsFactory.getFactories();
         }
     
    -    @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
    +    @Slot(value = SlotKind.tp_iternext, isComplex = true)
         @GenerateNodeFactory
    -    abstract static class NextNode extends PythonUnaryBuiltinNode {
    +    abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(PGenericAliasIterator self,
    -                        @Bind("this") Node inliningTarget,
    -                        @Cached PRaiseNode raiseNode,
                             @Bind PythonLanguage language) {
                 if (self.isExhausted()) {
    -                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    +                return iteratorExhausted();
                 }
                 PGenericAlias alias = self.getObj();
                 PGenericAlias starredAlias = PFactory.createGenericAlias(language, alias.getOrigin(), alias.getArgs(), true);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    index 136c62578d..8ef40996e0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    @@ -40,141 +40,45 @@
      */
     package com.oracle.graal.python.lib;
     
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
    -
    -import com.oracle.graal.python.builtins.objects.PNone;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    -import com.oracle.graal.python.nodes.ErrorMessages;
    -import com.oracle.graal.python.nodes.PGuards;
    +import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
    -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.NoAttributeHandler;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
    -import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PythonErrorType;
    -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
    +import com.oracle.truffle.api.dsl.Bind;
    +import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateUncached;
     import com.oracle.truffle.api.dsl.NeverDefault;
    +import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.Frame;
     import com.oracle.truffle.api.frame.VirtualFrame;
    -import com.oracle.truffle.api.nodes.UnexpectedResultException;
    -import com.oracle.truffle.api.profiles.BranchProfile;
    +import com.oracle.truffle.api.nodes.Node;
     
    +@GenerateUncached
     public abstract class GetNextNode extends PNodeWithContext {
         public abstract Object execute(Frame frame, Object iterator);
     
    -    public Object execute(Object iterator) {
    -        return execute(null, iterator);
    -    }
    -
    -    public abstract boolean executeBoolean(VirtualFrame frame, Object iterator) throws UnexpectedResultException;
    -
    -    public abstract int executeInt(VirtualFrame frame, Object iterator) throws UnexpectedResultException;
    -
    -    public abstract long executeLong(VirtualFrame frame, Object iterator) throws UnexpectedResultException;
    -
    -    public abstract double executeDouble(VirtualFrame frame, Object iterator) throws UnexpectedResultException;
    -
    -    private static final class GetNextCached extends GetNextNode {
    -
    -        @Child private LookupAndCallUnaryNode nextCall = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next, () -> new NoAttributeHandler() {
    -            private final BranchProfile errorProfile = BranchProfile.create();
    -
    -            @Override
    -            public Object execute(Object receiver) {
    -                errorProfile.enter();
    -                throw PRaiseNode.raiseStatic(this, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, receiver);
    -            }
    -        });
    -
    -        @Override
    -        public Object execute(Frame frame, Object iterator) {
    -            return nextCall.executeObject((VirtualFrame) frame, iterator);
    -        }
    -
    -        @Override
    -        public boolean executeBoolean(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            return PGuards.expectBoolean(nextCall.executeObject(frame, iterator));
    -        }
    -
    -        @Override
    -        public int executeInt(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            return PGuards.expectInteger(nextCall.executeObject(frame, iterator));
    -        }
    -
    -        @Override
    -        public long executeLong(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            return PGuards.expectLong(nextCall.executeObject(frame, iterator));
    -        }
    -
    -        @Override
    -        public double executeDouble(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            return PGuards.expectDouble(nextCall.executeObject(frame, iterator));
    -        }
    +    public static Object executeUncached(Object iterator) {
    +        return getUncached().execute(null, iterator);
         }
     
    -    private static final class GetNextUncached extends GetNextNode {
    -        static final GetNextUncached INSTANCE = new GetNextUncached();
    -
    -        @Override
    -        public Object execute(Frame frame, Object iterator) {
    -            return executeImpl(iterator);
    -        }
    -
    -        @SuppressWarnings("static-method")
    -        @TruffleBoundary
    -        private Object executeImpl(Object iterator) {
    -            Object nextMethod = LookupSpecialMethodSlotNode.getUncached(SpecialMethodSlot.Next).execute(null, GetClassNode.executeUncached(iterator), iterator);
    -            if (nextMethod == PNone.NO_VALUE) {
    -                throw PRaiseNode.raiseStatic(null, PythonErrorType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, iterator, T___NEXT__);
    -            }
    -            return CallUnaryMethodNode.getUncached().executeObject(nextMethod, iterator);
    -        }
    -
    -        @Override
    -        public boolean executeBoolean(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            Object value = execute(frame, iterator);
    -            if (value instanceof Boolean) {
    -                return (boolean) value;
    -            }
    -            throw new UnexpectedResultException(value);
    -        }
    -
    -        @Override
    -        public int executeInt(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            Object value = execute(frame, iterator);
    -            if (value instanceof Integer) {
    -                return (int) value;
    -            }
    -            throw new UnexpectedResultException(value);
    -        }
    -
    -        @Override
    -        public long executeLong(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            Object value = execute(frame, iterator);
    -            if (value instanceof Long) {
    -                return (long) value;
    -            }
    -            throw new UnexpectedResultException(value);
    -        }
    -
    -        @Override
    -        public double executeDouble(VirtualFrame frame, Object iterator) throws UnexpectedResultException {
    -            Object value = execute(frame, iterator);
    -            if (value instanceof Double) {
    -                return (double) value;
    -            }
    -            throw new UnexpectedResultException(value);
    +    // TODO replace this node with PyIterNext
    +    @Specialization
    +    Object next(VirtualFrame frame, Object iterator,
    +                    @Bind Node inliningTarget,
    +                    @Cached PyIterNextNode iterNextNode,
    +                    @Cached PRaiseNode raiseNode) {
    +        Object result = iterNextNode.execute(frame, iterator);
    +        if (PyIterNextNode.isExhausted(result)) {
    +            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
             }
    +        return result;
         }
     
         @NeverDefault
         public static GetNextNode create() {
    -        return new GetNextCached();
    +        return GetNextNodeGen.create();
         }
     
         public static GetNextNode getUncached() {
    -        return GetNextUncached.INSTANCE;
    +        return GetNextNodeGen.getUncached();
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterCheckNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterCheckNode.java
    index ddd93328cb..a985574977 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterCheckNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterCheckNode.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2023, 2025, 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
    @@ -40,18 +40,15 @@
      */
     package com.oracle.graal.python.lib;
     
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.iterator.PBuiltinIterator;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
    -import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.Fallback;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
    -import com.oracle.truffle.api.dsl.ImportStatic;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.nodes.Node;
     
    @@ -59,7 +56,6 @@
      * Check if the object is iterable - has {@code __next__} method. Equivalent of CPython's
      * {@code PyIter_Check}.
      */
    -@ImportStatic(SpecialMethodSlot.class)
     @GenerateInline(inlineByDefault = true)
     @GenerateUncached
     public abstract class PyIterCheckNode extends PNodeWithContext {
    @@ -81,9 +77,12 @@ static boolean doIterator(@SuppressWarnings("unused") PBuiltinIterator object) {
         @InliningCutoff
         @Fallback
         static boolean doGeneric(Node inliningTarget, Object object,
    -                    @Cached GetClassNode getClassNode,
    -                    @Cached(parameters = "Next", inline = false) LookupCallableSlotInMRONode lookupNext) {
    -        Object type = getClassNode.execute(inliningTarget, object);
    -        return !(lookupNext.execute(type) instanceof PNone);
    +                    @Cached TpSlots.GetObjectSlotsNode getSlots) {
    +        TpSlots slots = getSlots.execute(inliningTarget, object);
    +        return checkSlots(slots);
    +    }
    +
    +    public static boolean checkSlots(TpSlots slots) {
    +        return slots.tp_iternext() != null && slots.tp_iternext() != TpSlotIterNext.NEXT_NOT_IMPLEMENTED;
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    index a3f0f97ebb..49fe1a9e0f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    @@ -40,84 +40,61 @@
      */
     package com.oracle.graal.python.lib;
     
    -import com.oracle.graal.python.PythonLanguage;
    -import com.oracle.graal.python.builtins.objects.PNone;
    -import com.oracle.graal.python.builtins.objects.iterator.PBigRangeIterator;
    -import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator;
    -import com.oracle.graal.python.nodes.ErrorMessages;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
    -import com.oracle.graal.python.runtime.exception.PythonErrorType;
    -import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
    +import com.oracle.truffle.api.dsl.NeverDefault;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.Frame;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
     
     /**
    - * Obtains the next value of an iterator. When the iterator is exhausted it returns {@code null}. It
    - * never raises {@code StopIteration}.
    + * Obtains the next value of an iterator. It never raises {@code StopIteration}. Use
    + * {@link PyIterNextNode#isExhausted(Object)} on the returned value to determine if the iterator was
    + * exhausted.
      */
     @GenerateUncached
     @GenerateInline(false)
     public abstract class PyIterNextNode extends PNodeWithContext {
         public abstract Object execute(Frame frame, Object iterator);
     
    -    @Specialization
    -    Object doIntRange(PIntRangeIterator iterator) {
    -        if (iterator.hasNextInt()) {
    -            return iterator.nextInt();
    -        }
    -        iterator.setExhausted();
    -        return null;
    +    public static Object executeUncached(Object iterator) {
    +        return PyIterNextNodeGen.getUncached().execute(null, iterator);
         }
     
    -    @Specialization
    -    static Object doBigIntRange(PBigRangeIterator iterator,
    -                    @Bind("this") Node inliningTarget) {
    -        if (iterator.hasNextBigInt()) {
    -            return PFactory.createInt(PythonLanguage.get(inliningTarget), iterator.nextBigInt());
    -        }
    -        iterator.setExhausted();
    -        return null;
    +    public static boolean isExhausted(Object value) {
    +        return value == TpSlotIterNext.ITERATOR_EXHAUSTED;
         }
     
    -    // TODO list, tuple, enumerate, dict keys, dict values, dict items, string, bytes
    -
         @Specialization
         static Object doGeneric(VirtualFrame frame, Object iterator,
                         @Bind("this") Node inliningTarget,
                         @Cached GetClassNode getClassNode,
    -                    @Cached(parameters = "Next") LookupSpecialMethodSlotNode lookupNext,
    -                    @Cached CallUnaryMethodNode callNext,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile,
    -                    @Cached PRaiseNode raiseNode) {
    -        Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator);
    -        if (nextMethod == PNone.NO_VALUE) {
    -            throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator);
    -        }
    +                    @Cached GetCachedTpSlotsNode getSlots,
    +                    @Cached CallSlotTpIterNextNode callNext,
    +                    @Cached IsBuiltinObjectProfile stopIterationProfile) {
    +        TpSlots slots = getSlots.execute(inliningTarget, getClassNode.execute(inliningTarget, iterator));
    +        assert slots.tp_iternext() != null;
             try {
    -            return callNext.executeObject(frame, nextMethod, iterator);
    +            return callNext.execute(frame, inliningTarget, slots.tp_iternext(), iterator);
             } catch (PException e) {
                 e.expectStopIteration(inliningTarget, stopIterationProfile);
    -            return null;
    +            return TpSlotIterNext.ITERATOR_EXHAUSTED;
             }
         }
     
    +    @NeverDefault
         public static PyIterNextNode create() {
             return PyIterNextNodeGen.create();
         }
    -
    -    public static PyIterNextNode getUncached() {
    -        return PyIterNextNodeGen.getUncached();
    -    }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    index debb8cbcac..a515f91565 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    @@ -40,18 +40,10 @@
      */
     package com.oracle.graal.python.nodes.bytecode;
     
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator;
     import com.oracle.graal.python.compiler.QuickeningTypes;
    -import com.oracle.graal.python.nodes.ErrorMessages;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PException;
    -import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.dsl.Bind;
    @@ -64,10 +56,6 @@
     import com.oracle.truffle.api.nodes.Node;
     import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile;
     
    -/**
    - * Obtains the next value of an iterator. When the iterator is exhausted it returns {@code null}. It
    - * never raises {@code StopIteration}.
    - */
     @GenerateUncached
     @GenerateInline(false) // Used in BCI
     public abstract class ForIterINode extends PNodeWithContext {
    @@ -94,30 +82,17 @@ boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
         @Specialization
         @InliningCutoff
         static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop,
    -                    @Bind("this") Node inliningTarget,
    -                    @Cached GetClassNode getClassNode,
    -                    @Cached(parameters = "Next") LookupSpecialMethodSlotNode lookupNext,
    -                    @Cached CallUnaryMethodNode callNext,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile,
    -                    @Cached PRaiseNode raiseNode) throws QuickeningGeneralizeException {
    -        Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator);
    -        if (nextMethod == PNone.NO_VALUE) {
    -            throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator);
    -        }
    -        try {
    -            Object res = callNext.executeObject(frame, nextMethod, iterator);
    -            if (res instanceof Integer) {
    -                frame.setInt(stackTop, (int) res);
    -                return true;
    -            } else {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                // TODO other types
    -                frame.setObject(stackTop, res);
    -                throw new QuickeningGeneralizeException(QuickeningTypes.OBJECT);
    -            }
    -        } catch (PException e) {
    -            e.expectStopIteration(inliningTarget, stopIterationProfile);
    +                    @Cached PyIterNextNode nextNode) throws QuickeningGeneralizeException {
    +        Object res = nextNode.execute(frame, iterator);
    +        if (res instanceof Integer) {
    +            frame.setInt(stackTop, (int) res);
    +            return true;
    +        } else if (PyIterNextNode.isExhausted(res)) {
                 return false;
    +        } else {
    +            CompilerDirectives.transferToInterpreterAndInvalidate();
    +            frame.setObject(stackTop, res);
    +            throw new QuickeningGeneralizeException(QuickeningTypes.OBJECT);
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    index 7429b330e9..c4d1fd60a6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    @@ -40,17 +40,9 @@
      */
     package com.oracle.graal.python.nodes.bytecode;
     
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator;
    -import com.oracle.graal.python.nodes.ErrorMessages;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PException;
    -import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -62,10 +54,6 @@
     import com.oracle.truffle.api.nodes.Node;
     import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile;
     
    -/**
    - * Obtains the next value of an iterator. When the iterator is exhausted it returns {@code null}. It
    - * never raises {@code StopIteration}.
    - */
     @GenerateUncached
     @GenerateInline(false) // Used in BCI
     public abstract class ForIterONode extends PNodeWithContext {
    @@ -92,24 +80,13 @@ boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
         @Specialization
         @InliningCutoff
         static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop,
    -                    @Bind("this") Node inliningTarget,
    -                    @Cached GetClassNode getClassNode,
    -                    @Cached(parameters = "Next") LookupSpecialMethodSlotNode lookupNext,
    -                    @Cached CallUnaryMethodNode callNext,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile,
    -                    @Cached PRaiseNode raiseNode) {
    -        assert iterator != null;
    -        Object nextMethod = lookupNext.execute(frame, getClassNode.execute(inliningTarget, iterator), iterator);
    -        if (nextMethod == PNone.NO_VALUE) {
    -            throw raiseNode.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator);
    -        }
    -        try {
    -            frame.setObject(stackTop, callNext.executeObject(frame, nextMethod, iterator));
    -            return true;
    -        } catch (PException e) {
    -            e.expectStopIteration(inliningTarget, stopIterationProfile);
    +                    @Cached PyIterNextNode nextNode) {
    +        Object res = nextNode.execute(frame, iterator);
    +        if (PyIterNextNode.isExhausted(res)) {
                 return false;
             }
    +        frame.setObject(stackTop, res);
    +        return true;
         }
     
         public static ForIterONode create() {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SendNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SendNode.java
    index 96fcfa8022..2d32d16eb3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SendNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SendNode.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2022, 2025, 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
    @@ -47,8 +47,11 @@
     import com.oracle.graal.python.builtins.objects.exception.StopIterationBuiltins;
     import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins;
     import com.oracle.graal.python.builtins.objects.generator.PGenerator;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.lib.PyIterCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    @@ -61,6 +64,7 @@
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedBranchProfile;
     
     @GenerateInline(false) // used in BCI root node
     public abstract class SendNode extends PNodeWithContext {
    @@ -84,23 +88,36 @@ static boolean doGenerator(VirtualFrame virtualFrame, int stackTop, PGenerator g
             }
         }
     
    -    @Specialization(guards = "iterCheck.execute(inliningTarget, iter)", limit = "1")
    +    @Specialization(guards = "hasIterSlot(slots)", limit = "1")
         static boolean doIterator(VirtualFrame virtualFrame, int stackTop, Object iter, @SuppressWarnings("unused") PNone arg,
                         @Bind("this") Node inliningTarget,
    -                    @SuppressWarnings("unused") @Cached PyIterCheckNode iterCheck,
    -                    @Cached GetNextNode getNextNode,
    +                    @SuppressWarnings("unused") @Cached GetObjectSlotsNode getSlots,
    +                    @Bind("getSlots.execute(inliningTarget, iter)") TpSlots slots,
    +                    @Cached CallSlotTpIterNextNode callIterNext,
    +                    @Exclusive @Cached InlinedBranchProfile exhaustedNoException,
                         @Exclusive @Cached IsBuiltinObjectProfile stopIterationProfile,
                         @Exclusive @Cached StopIterationBuiltins.StopIterationValueNode getValue) {
             try {
    -            Object value = getNextNode.execute(virtualFrame, iter);
    -            virtualFrame.setObject(stackTop, value);
    -            return false;
    +            Object value = callIterNext.execute(virtualFrame, inliningTarget, slots.tp_iternext(), iter);
    +            if (PyIterNextNode.isExhausted(value)) {
    +                exhaustedNoException.enter(inliningTarget);
    +                virtualFrame.setObject(stackTop, null);
    +                virtualFrame.setObject(stackTop - 1, PNone.NONE);
    +                return true;
    +            } else {
    +                virtualFrame.setObject(stackTop, value);
    +                return false;
    +            }
             } catch (PException e) {
                 handleException(virtualFrame, e, inliningTarget, stopIterationProfile, getValue, stackTop);
                 return true;
             }
         }
     
    +    protected static boolean hasIterSlot(TpSlots slots) {
    +        return PyIterCheckNode.checkSlots(slots);
    +    }
    +
         @Fallback
         static boolean doOther(VirtualFrame virtualFrame, int stackTop, Object obj, Object arg,
                         @Bind("this") Node inliningTarget,
    
    From a0267788b1bb0587f25a14761d5d4194e8e47c9c Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Wed, 26 Feb 2025 16:25:18 +0100
    Subject: [PATCH 107/512] Inline PyIterNext node
    
    ---
     .../python/builtins/modules/GcModuleBuiltins.java   |  6 +++---
     .../modules/cext/PythonCextAbstractBuiltins.java    |  5 +++--
     .../builtins/modules/pickle/PicklerNodes.java       |  2 +-
     .../builtins/objects/common/HashingStorage.java     |  8 ++++----
     .../objects/enumerate/EnumerateBuiltins.java        |  2 +-
     .../objects/itertools/AccumulateBuiltins.java       |  2 +-
     .../builtins/objects/itertools/ChainBuiltins.java   |  4 ++--
     .../builtins/objects/itertools/CycleBuiltins.java   |  2 +-
     .../python/builtins/objects/itertools/PGroupBy.java |  2 +-
     .../builtins/objects/itertools/PTeeDataObject.java  |  2 +-
     .../objects/itertools/PairwiseBuiltins.java         |  4 ++--
     .../builtins/objects/itertools/StarmapBuiltins.java |  3 ++-
     .../objects/itertools/TakewhileBuiltins.java        |  3 ++-
     .../objects/itertools/ZipLongestBuiltins.java       |  2 +-
     .../python/builtins/objects/map/MapBuiltins.java    |  7 +++++--
     .../com/oracle/graal/python/lib/GetNextNode.java    |  2 +-
     .../com/oracle/graal/python/lib/PyIterNextNode.java | 13 ++++++++-----
     .../graal/python/nodes/bytecode/ForIterINode.java   |  3 ++-
     .../graal/python/nodes/bytecode/ForIterONode.java   |  3 ++-
     19 files changed, 43 insertions(+), 32 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    index 32f409caf6..89dfcd5fa6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GcModuleBuiltins.java
    @@ -136,7 +136,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                             @Cached CheckPrimitiveFunctionResultNode checkPrimitiveFunctionResultNode) {
                 Object callbacks = getAttr.execute(frame, inliningTarget, self, CALLBACKS);
                 Object iter = getIter.execute(frame, inliningTarget, callbacks);
    -            Object cb = next.execute(frame, iter);
    +            Object cb = next.execute(frame, inliningTarget, iter);
                 TruffleString phase = null;
                 Object info;
                 long res = 0;
    @@ -149,7 +149,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                     });
                     do {
                         call.executeObject(frame, cb, phase, info);
    -                } while (!PyIterNextNode.isExhausted(cb = next.execute(frame, iter)));
    +                } while (!PyIterNextNode.isExhausted(cb = next.execute(frame, inliningTarget, iter)));
                 }
                 long freedMemory = javaCollect(inliningTarget, gil);
                 PythonContext pythonContext = PythonContext.get(inliningTarget);
    @@ -168,7 +168,7 @@ static long collect(VirtualFrame frame, PythonModule self, @SuppressWarnings("un
                                     new PKeyword(UNCOLLECTABLE, 0),
                     });
                     iter = getIter.execute(frame, inliningTarget, callbacks);
    -                while (!PyIterNextNode.isExhausted(cb = next.execute(frame, iter))) {
    +                while (!PyIterNextNode.isExhausted(cb = next.execute(frame, inliningTarget, iter))) {
                         call.executeObject(frame, cb, phase, info);
                     }
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    index a9cb951f78..91220154e0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java
    @@ -885,8 +885,9 @@ static int doMapping(Object obj,
         abstract static class PyIter_Next extends CApiUnaryBuiltinNode {
             @Specialization
             Object check(Object object,
    +                        @Bind Node inliningTarget,
                             @Cached PyIterNextNode nextNode) {
    -            Object result = nextNode.execute(null, object);
    +            Object result = nextNode.execute(null, inliningTarget, object);
                 if (PyIterNextNode.isExhausted(result)) {
                     return getNativeNull();
                 }
    @@ -904,7 +905,7 @@ Object send(Object iter, Object arg,
                             @Cached PyIterNextNode nextNode,
                             @Cached IsBuiltinObjectProfile isClassProfile) {
                 if (arg instanceof PNone && pyiterCheck.execute(inliningTarget, iter)) {
    -                Object result = nextNode.execute(null, iter);
    +                Object result = nextNode.execute(null, inliningTarget, iter);
                     if (PyIterNextNode.isExhausted(result)) {
                         return getNativeNull();
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java
    index 7e68d843d9..8cf540180d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/pickle/PicklerNodes.java
    @@ -560,7 +560,7 @@ protected boolean isBuiltinClass(Object cls, PythonBuiltinClassType type) {
             }
     
             public Object getNextItem(VirtualFrame frame, Object iterator) {
    -            return getNextNode.execute(frame, iterator);
    +            return getNextNode.executeCached(frame, iterator);
             }
     
             public Object getItem(VirtualFrame frame, SequenceStorage storage, int i) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    index 986e44717d..c078611775 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java
    @@ -208,7 +208,7 @@ public abstract static class ObjectToArrayPairNode extends PNodeWithContext {
             static ArrayBuilder partialMerge(VirtualFrame frame, Object mapping, Object keyAttr,
                             @Bind("this") Node inliningTarget,
                             @Shared @Cached PyObjectGetIter getIter,
    -                        @Shared @Cached(neverDefault = false) PyIterNextNode nextNode,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Shared @Cached PyObjectGetItem getItemNode,
                             @Cached CallVarargsMethodNode callKeysMethod) {
                 // We don't need to pass self as the attribute object has it already.
    @@ -216,7 +216,7 @@ static ArrayBuilder partialMerge(VirtualFrame frame, Object mapping, O
                 Object keysIt = getIter.execute(frame, inliningTarget, keysIterable);
                 ArrayBuilder elements = new ArrayBuilder<>();
                 Object keyObj;
    -            while (!PyIterNextNode.isExhausted(keyObj = nextNode.execute(frame, keysIt))) {
    +            while (!PyIterNextNode.isExhausted(keyObj = nextNode.execute(frame, inliningTarget, keysIt))) {
                     Object valueObj = getItemNode.execute(frame, inliningTarget, mapping, keyObj);
                     elements.add(new KeyValue(keyObj, valueObj));
                 }
    @@ -228,7 +228,7 @@ static ArrayBuilder partialMerge(VirtualFrame frame, Object mapping, O
             static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object iterable, @SuppressWarnings("unused") PNone keyAttr,
                             @Bind("this") Node inliningTarget,
                             @Shared @Cached PyObjectGetIter getIter,
    -                        @Shared @Cached(neverDefault = false) PyIterNextNode nextNode,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Shared @Cached PyObjectGetItem getItemNode,
                             @Cached FastConstructListNode createListNode,
                             @Cached LenNode seqLenNode,
    @@ -240,7 +240,7 @@ static ArrayBuilder partialMergeFromSeq2(VirtualFrame frame, Object it
                 Object next;
                 int len = 2;
                 try {
    -                while (!PyIterNextNode.isExhausted(next = nextNode.execute(frame, it))) {
    +                while (!PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, it))) {
                         PSequence element = createListNode.execute(frame, inliningTarget, next);
                         assert element != null;
                         // This constructs a new list using the builtin type. So, the object cannot
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    index 17d2f0a8dc..afe48317ac 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    @@ -75,7 +75,7 @@ static Object doNext(VirtualFrame frame, PEnumerate self,
                             @Cached InlinedConditionProfile bigIntIndexProfile,
                             @Cached PyIterNextNode next) {
                 Object index = self.getAndIncrementIndex(inliningTarget, language, bigIntIndexProfile);
    -            Object nextValue = next.execute(frame, self.getDecoratedIterator());
    +            Object nextValue = next.execute(frame, inliningTarget, self.getDecoratedIterator());
                 if (PyIterNextNode.isExhausted(nextValue)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    index e3085220e2..394fd0a720 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    @@ -113,7 +113,7 @@ static Object next(VirtualFrame frame, PAccumulate self,
                     self.setInitial(null);
                     return self.getTotal();
                 }
    -            Object value = nextNode.execute(frame, self.getIterable());
    +            Object value = nextNode.execute(frame, inliningTarget, self.getIterable());
                 if (PyIterNextNode.isExhausted(value)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    index b0a3670940..2d50d0e211 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ChainBuiltins.java
    @@ -117,7 +117,7 @@ static Object next(VirtualFrame frame, PChain self,
                         try {
                             Object next;
                             try {
    -                            next = nextNode.execute(frame, self.getSource());
    +                            next = nextNode.execute(frame, inliningTarget, self.getSource());
                             } catch (PException e) {
                                 nextExceptionProfile.enter(inliningTarget);
                                 self.setSource(PNone.NONE);
    @@ -135,7 +135,7 @@ static Object next(VirtualFrame frame, PChain self,
                             throw e;
                         }
                     }
    -                Object next = nextNode.execute(frame, self.getActive());
    +                Object next = nextNode.execute(frame, inliningTarget, self.getActive());
                     if (!PyIterNextNode.isExhausted(next)) {
                         return next;
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    index 901eec54e7..9eadef0384 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CycleBuiltins.java
    @@ -120,7 +120,7 @@ static Object next(VirtualFrame frame, PCycle self,
                             @Cached InlinedBranchProfile firstPassProfile) {
                 if (self.getIterable() != null) {
                     iterableProfile.enter(inliningTarget);
    -                Object item = nextNode.execute(frame, self.getIterable());
    +                Object item = nextNode.execute(frame, inliningTarget, self.getIterable());
                     if (PyIterNextNode.isExhausted(item)) {
                         self.setIterable(null);
                     } else {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    index 3a3a941ab0..61e4ce1127 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PGroupBy.java
    @@ -110,7 +110,7 @@ public void setCurrKey(Object currKey) {
         }
     
         boolean groupByStep(VirtualFrame frame, Node inliningTarget, PyIterNextNode nextNode, CallNode callNode, InlinedConditionProfile hasFuncProfile) {
    -        Object newValue = nextNode.execute(frame, it);
    +        Object newValue = nextNode.execute(frame, inliningTarget, it);
             if (PyIterNextNode.isExhausted(newValue)) {
                 return false;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    index 737723c0cd..961b542bad 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    @@ -135,7 +135,7 @@ Object getItem(VirtualFrame frame, Node inliningTarget, int i, PyIterNextNode ne
                 running = true;
                 Object value;
                 try {
    -                value = nextNode.execute(frame, it);
    +                value = nextNode.execute(frame, inliningTarget, it);
                 } finally {
                     running = false;
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    index 93424dfbc9..12f0abfd31 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    @@ -97,7 +97,7 @@ static Object next(VirtualFrame frame, PPairwise self,
                 Object iterable = self.getIterable();
                 try {
                     if (self.getOld() == null) {
    -                    old = nextNode.execute(frame, iterable);
    +                    old = nextNode.execute(frame, inliningTarget, iterable);
                         if (PyIterNextNode.isExhausted(old)) {
                             self.setOld(null);
                             self.setIterable(null);
    @@ -110,7 +110,7 @@ static Object next(VirtualFrame frame, PPairwise self,
                             return iteratorExhausted();
                         }
                     }
    -                item = nextNode.execute(frame, iterable);
    +                item = nextNode.execute(frame, inliningTarget, iterable);
                     if (PyIterNextNode.isExhausted(item)) {
                         self.setOld(null);
                         self.setIterable(null);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    index 27e00c2253..0e9d094cde 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    @@ -94,10 +94,11 @@ static Object iter(PStarmap self) {
         public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object nextPos(VirtualFrame frame, PStarmap self,
    +                        @Bind Node inliningTarget,
                             @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached ExecutePositionalStarargsNode getArgsNode) {
    -            Object obj = nextNode.execute(frame, self.getIterable());
    +            Object obj = nextNode.execute(frame, inliningTarget, self.getIterable());
                 if (PyIterNextNode.isExhausted(obj)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    index 6a89ef4e5a..72a1fcf038 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    @@ -94,11 +94,12 @@ static Object iter(PTakewhile self) {
         public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PTakewhile self,
    +                        @Bind Node inliningTarget,
                             @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached PyObjectIsTrueNode isTrue,
                             @Bind PythonLanguage language) {
    -            Object value = nextNode.execute(frame, self.getIterable());
    +            Object value = nextNode.execute(frame, inliningTarget, self.getIterable());
                 if (PyIterNextNode.isExhausted(value)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    index 2b1c07e327..49a7da7158 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/ZipLongestBuiltins.java
    @@ -118,7 +118,7 @@ static Object next(VirtualFrame frame, PZipLongest self,
                         item = fillValue;
                     } else {
                         try {
    -                        item = nextNode.execute(frame, it);
    +                        item = nextNode.execute(frame, inliningTarget, it);
                         } catch (PException e) {
                             self.setNumActive(0);
                             throw e;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    index be59a30205..387893ff6f 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/map/MapBuiltins.java
    @@ -68,6 +68,7 @@
     import com.oracle.truffle.api.dsl.NodeFactory;
     import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.frame.VirtualFrame;
    +import com.oracle.truffle.api.nodes.Node;
     
     @CoreFunctions(extendClasses = PythonBuiltinClassType.PMap)
     public final class MapBuiltins extends PythonBuiltins {
    @@ -84,9 +85,10 @@ protected List> getNodeFa
         public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getIterators().length == 1")
             Object doOne(VirtualFrame frame, PMap self,
    +                        @Bind Node inliningTarget,
                             @Shared @Cached CallVarargsMethodNode callNode,
                             @Shared @Cached PyIterNextNode nextNode) {
    -            Object item = nextNode.execute(frame, self.getIterators()[0]);
    +            Object item = nextNode.execute(frame, inliningTarget, self.getIterators()[0]);
                 if (PyIterNextNode.isExhausted(item)) {
                     return iteratorExhausted();
                 }
    @@ -95,12 +97,13 @@ Object doOne(VirtualFrame frame, PMap self,
     
             @Specialization(replaces = "doOne")
             Object doNext(VirtualFrame frame, PMap self,
    +                        @Bind Node inliningTarget,
                             @Shared @Cached CallVarargsMethodNode callNode,
                             @Shared @Cached PyIterNextNode nextNode) {
                 Object[] iterators = self.getIterators();
                 Object[] arguments = new Object[iterators.length];
                 for (int i = 0; i < iterators.length; i++) {
    -                arguments[i] = nextNode.execute(frame, iterators[i]);
    +                arguments[i] = nextNode.execute(frame, inliningTarget, iterators[i]);
                     if (PyIterNextNode.isExhausted(arguments[i])) {
                         return iteratorExhausted();
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    index 8ef40996e0..8e3ae5b5ba 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    @@ -66,7 +66,7 @@ Object next(VirtualFrame frame, Object iterator,
                         @Bind Node inliningTarget,
                         @Cached PyIterNextNode iterNextNode,
                         @Cached PRaiseNode raiseNode) {
    -        Object result = iterNextNode.execute(frame, iterator);
    +        Object result = iterNextNode.execute(frame, inliningTarget, iterator);
             if (PyIterNextNode.isExhausted(result)) {
                 throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    index 49fe1a9e0f..37fb16cc97 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    @@ -64,12 +64,16 @@
      * exhausted.
      */
     @GenerateUncached
    -@GenerateInline(false)
    +@GenerateInline(inlineByDefault = true)
     public abstract class PyIterNextNode extends PNodeWithContext {
    -    public abstract Object execute(Frame frame, Object iterator);
    +    public abstract Object execute(Frame frame, Node inliningTarget, Object iterator);
    +
    +    public final Object executeCached(VirtualFrame frame, Object iterator) {
    +        return execute(frame, this, iterator);
    +    }
     
         public static Object executeUncached(Object iterator) {
    -        return PyIterNextNodeGen.getUncached().execute(null, iterator);
    +        return PyIterNextNodeGen.getUncached().execute(null, null, iterator);
         }
     
         public static boolean isExhausted(Object value) {
    @@ -77,8 +81,7 @@ public static boolean isExhausted(Object value) {
         }
     
         @Specialization
    -    static Object doGeneric(VirtualFrame frame, Object iterator,
    -                    @Bind("this") Node inliningTarget,
    +    static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object iterator,
                         @Cached GetClassNode getClassNode,
                         @Cached GetCachedTpSlotsNode getSlots,
                         @Cached CallSlotTpIterNextNode callNext,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    index a515f91565..231b46f9df 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterINode.java
    @@ -82,8 +82,9 @@ boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
         @Specialization
         @InliningCutoff
         static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop,
    +                    @Bind Node inliningTarget,
                         @Cached PyIterNextNode nextNode) throws QuickeningGeneralizeException {
    -        Object res = nextNode.execute(frame, iterator);
    +        Object res = nextNode.execute(frame, inliningTarget, iterator);
             if (res instanceof Integer) {
                 frame.setInt(stackTop, (int) res);
                 return true;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    index c4d1fd60a6..f17c1fa3b6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ForIterONode.java
    @@ -80,8 +80,9 @@ boolean doIntRange(VirtualFrame frame, PIntRangeIterator iterator, int stackTop,
         @Specialization
         @InliningCutoff
         static boolean doGeneric(VirtualFrame frame, Object iterator, int stackTop,
    +                    @Bind Node inliningTarget,
                         @Cached PyIterNextNode nextNode) {
    -        Object res = nextNode.execute(frame, iterator);
    +        Object res = nextNode.execute(frame, inliningTarget, iterator);
             if (PyIterNextNode.isExhausted(res)) {
                 return false;
             }
    
    From dabd64589c861e07c3bde8e3e5e00f0420e36fb8 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 27 Feb 2025 09:29:46 +0100
    Subject: [PATCH 108/512] Remove GetNextNode
    
    ---
     .../python/test/datatype/PRangeTests.java     |  30 +--
     .../builtins/modules/ArrayModuleBuiltins.java |  14 +-
     .../builtins/modules/BuiltinFunctions.java    |  41 ++--
     .../builtins/modules/ast/Obj2SstBase.java     |  11 +-
     .../modules/csv/CSVReaderBuiltins.java        |  18 +-
     .../modules/csv/CSVWriterBuiltins.java        |  47 ++--
     .../functools/FunctoolsModuleBuiltins.java    |  33 ++-
     .../builtins/modules/io/BytesIOBuiltins.java  |  14 +-
     .../builtins/modules/io/IOBaseBuiltins.java   |  36 ++-
     .../modules/json/JSONEncoderBuiltins.java     |  18 +-
     .../objects/PythonAbstractObject.java         |  15 +-
     .../builtins/objects/array/ArrayBuiltins.java |  13 +-
     .../builtins/objects/bytes/BytesNodes.java    |  32 ++-
     .../common/HashingCollectionNodes.java        |  16 +-
     .../objects/common/SequenceStorageNodes.java  | 205 ++++++++----------
     .../builtins/objects/deque/DequeBuiltins.java |  77 +++----
     .../builtins/objects/dict/DictBuiltins.java   |  15 +-
     .../objects/dict/DictViewBuiltins.java        |  22 +-
     .../objects/iterator/IteratorNodes.java       |  17 +-
     .../objects/iterator/PZipBuiltins.java        |  44 ++--
     .../objects/itertools/PTeeDataObject.java     |  13 +-
     .../objects/itertools/TeeBuiltins.java        |   7 +-
     .../builtins/objects/range/RangeBuiltins.java |  57 ++---
     .../builtins/objects/set/BaseSetBuiltins.java |  19 +-
     .../builtins/objects/set/SetBuiltins.java     |  14 +-
     .../python/builtins/objects/set/SetNodes.java |  14 +-
     .../builtins/objects/str/StringNodes.java     |  23 +-
     .../oracle/graal/python/lib/GetNextNode.java  |  84 -------
     .../graal/python/lib/PyIterNextNode.java      |   5 +-
     .../ExecutePositionalStarargsNode.java        |  14 +-
     .../python/nodes/bytecode/ImportStarNode.java |  17 +-
     .../python/nodes/bytecode/UnpackExNode.java   |  19 +-
     .../nodes/bytecode/UnpackSequenceNode.java    |  20 +-
     33 files changed, 382 insertions(+), 642 deletions(-)
     delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    index 717b38f0f4..49d67f1dcd 100644
    --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java
    @@ -33,11 +33,9 @@
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.builtins.objects.range.PIntRange;
     import com.oracle.graal.python.builtins.objects.range.PRange;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PGuards;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.test.PythonTests;
     import com.oracle.truffle.api.frame.VirtualFrame;
    @@ -68,20 +66,15 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
                 PythonLanguage language = PythonLanguage.get(null);
                 PRange range = PFactory.createIntRange(language, 10);
                 int index = 0;
    -            TestRoot testRoot = new TestRoot(language);
                 Object iter = PyObjectGetIter.executeUncached(range);
    -            GetNextNode next = GetNextNode.create();
    -            testRoot.doInsert(next);
    -            IsBuiltinObjectProfile errorProfile = IsBuiltinObjectProfile.getUncached();
     
                 while (true) {
    -                try {
    -                    int item = PGuards.expectInteger(next.execute(null, iter));
    -                    assertEquals(index, item);
    -                } catch (PException e) {
    -                    e.expectStopIteration(null, errorProfile);
    +                Object next = PyIterNextNode.executeUncached(iter);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
    +                int item = PGuards.expectInteger(next);
    +                assertEquals(index, item);
                     index++;
                 }
             } finally {
    @@ -96,20 +89,15 @@ public void loopWithStep() throws UnexpectedResultException {
                 PythonLanguage language = PythonLanguage.get(null);
                 PRange range = PFactory.createIntRange(language, 0, 10, 2, 5);
                 int index = 0;
    -            TestRoot testRoot = new TestRoot(language);
                 Object iter = PyObjectGetIter.executeUncached(range);
    -            GetNextNode next = GetNextNode.create();
    -            testRoot.doInsert(next);
    -            IsBuiltinObjectProfile errorProfile = IsBuiltinObjectProfile.getUncached();
     
                 while (true) {
    -                try {
    -                    int item = PGuards.expectInteger(next.execute(null, iter));
    -                    assertEquals(index, item);
    -                } catch (PException e) {
    -                    e.expectStopIteration(null, errorProfile);
    +                Object next = PyIterNextNode.executeUncached(iter);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
    +                int item = PGuards.expectInteger(next);
    +                assertEquals(index, item);
                     index += 2;
                 }
             } finally {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java
    index 7cb4676972..fe4073e1ea 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java
    @@ -61,7 +61,7 @@
     import com.oracle.graal.python.builtins.objects.range.PIntRange;
     import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToTruffleStringCheckedNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -73,9 +73,7 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinClassExactProfile;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.util.SplitArgsNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.PSequence;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
    @@ -287,8 +285,7 @@ static PArray arrayIteratorInitializer(VirtualFrame frame, Node inliningTarget,
                                 @Bind PythonLanguage language,
                                 @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape,
                                 @Exclusive @Cached ArrayNodes.PutValueNode putValueNode,
    -                            @Cached(inline = false) GetNextNode nextNode,
    -                            @Cached IsBuiltinObjectProfile errorProfile,
    +                            @Cached PyIterNextNode nextNode,
                                 @Cached ArrayNodes.SetLengthNode setLengthNode,
                                 @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode) {
                     Object iter = getIter.execute(frame, inliningTarget, initializer);
    @@ -298,11 +295,8 @@ static PArray arrayIteratorInitializer(VirtualFrame frame, Node inliningTarget,
     
                     int length = 0;
                     while (true) {
    -                    Object nextValue;
    -                    try {
    -                        nextValue = nextNode.execute(frame, iter);
    -                    } catch (PException e) {
    -                        e.expectStopIteration(inliningTarget, errorProfile);
    +                    Object nextValue = nextNode.execute(frame, inliningTarget, iter);
    +                    if (PyIterNextNode.isExhausted(nextValue)) {
                             break;
                         }
                         try {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    index f92e29b1a6..5ee5f10e62 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    @@ -165,7 +165,6 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.compiler.Compiler;
     import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyCallableCheckNode;
     import com.oracle.graal.python.lib.PyEvalGetGlobals;
     import com.oracle.graal.python.lib.PyEvalGetLocals;
    @@ -475,22 +474,21 @@ static boolean doHashColl(VirtualFrame frame, PHashingCollection object,
             static boolean doObject(VirtualFrame frame, Object object,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectIsTrueNode isTrueNode) {
                 Object iterator = getIter.execute(frame, inliningTarget, object);
                 int nbrIter = 0;
     
                 while (true) {
                     try {
    -                    Object next = nextNode.execute(frame, iterator);
    +                    Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                    if (PyIterNextNode.isExhausted(next)) {
    +                        break;
    +                    }
                         nbrIter++;
                         if (!isTrueNode.execute(frame, next)) {
                             return false;
                         }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    break;
                     } finally {
                         LoopNode.reportLoopCount(inliningTarget, nbrIter);
                     }
    @@ -528,22 +526,21 @@ static boolean doHashColl(VirtualFrame frame, PHashingCollection object,
             static boolean doObject(VirtualFrame frame, Object object,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectIsTrueNode isTrueNode) {
                 Object iterator = getIter.execute(frame, inliningTarget, object);
                 int nbrIter = 0;
     
                 while (true) {
                     try {
    -                    Object next = nextNode.execute(frame, iterator);
    +                    Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                    if (PyIterNextNode.isExhausted(next)) {
    +                        break;
    +                    }
                         nbrIter++;
                         if (isTrueNode.execute(frame, next)) {
                             return true;
                         }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    break;
                     } finally {
                         LoopNode.reportLoopCount(inliningTarget, nbrIter);
                     }
    @@ -1571,24 +1568,19 @@ public abstract static class MinMaxNode extends Node {
             static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Object arg1, @SuppressWarnings("unused") Object[] args, Object keywordArgIn, Object defaultVal, String name,
                             BinaryComparisonNode compare,
                             @Exclusive @Cached PyObjectGetIter getIter,
    -                        @Cached(inline = false) GetNextNode nextNode,
    +                        @Exclusive @Cached PyIterNextNode nextNode,
                             @Exclusive @Cached PyObjectIsTrueNode castToBooleanNode,
                             @Exclusive @Cached CallNode.Lazy keyCall,
                             @Exclusive @Cached InlinedBranchProfile seenNonBoolean,
                             @Exclusive @Cached InlinedConditionProfile keywordArgIsNone,
    -                        @Exclusive @Cached IsBuiltinObjectProfile errorProfile1,
    -                        @Exclusive @Cached IsBuiltinObjectProfile errorProfile2,
                             @Exclusive @Cached InlinedConditionProfile hasDefaultProfile,
                             @Exclusive @Cached PRaiseNode raiseNode) {
                 boolean kwArgsAreNone = keywordArgIsNone.profile(inliningTarget, PGuards.isPNone(keywordArgIn));
                 Object keywordArg = kwArgsAreNone ? null : keywordArgIn;
     
                 Object iterator = getIter.execute(frame, inliningTarget, arg1);
    -            Object currentValue;
    -            try {
    -                currentValue = nextNode.execute(frame, iterator);
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, errorProfile1);
    +            Object currentValue = nextNode.execute(frame, inliningTarget, iterator);
    +            if (PyIterNextNode.isExhausted(currentValue)) {
                     if (hasDefaultProfile.profile(inliningTarget, isNoValue(defaultVal))) {
                         throw raiseNode.raise(inliningTarget, PythonErrorType.ValueError, ErrorMessages.ARG_IS_EMPTY_SEQ, name);
                     } else {
    @@ -1599,11 +1591,8 @@ static Object minmaxSequenceWithKey(VirtualFrame frame, Node inliningTarget, Obj
                 int loopCount = 0;
                 try {
                     while (true) {
    -                    Object nextValue;
    -                    try {
    -                        nextValue = nextNode.execute(frame, iterator);
    -                    } catch (PException e) {
    -                        e.expectStopIteration(inliningTarget, errorProfile2);
    +                    Object nextValue = nextNode.execute(frame, inliningTarget, iterator);
    +                    if (PyIterNextNode.isExhausted(nextValue)) {
                             break;
                         }
                         Object nextKey = applyKeyFunction(frame, inliningTarget, keywordArg, keyCall, nextValue);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    index 174594409d..8f2d08b377 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/Obj2SstBase.java
    @@ -68,11 +68,11 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyBytesCheckExactNode;
     import com.oracle.graal.python.lib.PyComplexCheckExactNode;
     import com.oracle.graal.python.lib.PyFloatCheckExactNode;
     import com.oracle.graal.python.lib.PyFrozenSetCheckExactNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyLongAsIntNode;
     import com.oracle.graal.python.lib.PyLongCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -84,7 +84,6 @@
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.SpecialMethodNames;
     import com.oracle.graal.python.nodes.call.CallNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.util.CannotCastException;
     import com.oracle.graal.python.nodes.util.CastToJavaBooleanNode;
     import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
    @@ -292,11 +291,11 @@ ConstantValue obj2ConstantValue(Object obj) {
                 Object iter = PyObjectGetIter.executeUncached(obj);
                 ArrayList list = new ArrayList<>();
                 while (true) {
    -                try {
    -                    list.add(obj2ConstantValue(GetNextNode.executeUncached(iter)));
    -                } catch (PException e) {
    -                    e.expectStopIteration(null, IsBuiltinObjectProfile.getUncached());
    +                Object item = PyIterNextNode.executeUncached(iter);
    +                if (PyIterNextNode.isExhausted(item)) {
                         break;
    +                } else {
    +                    list.add(obj2ConstantValue(item));
                     }
                 }
                 if (isTuple) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    index 65bbb4eb8b..2cfddf6cc8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVReaderBuiltins.java
    @@ -66,19 +66,17 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberFloatNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.builtins.ListNodes.AppendNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.util.CannotCastException;
     import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
     import com.oracle.graal.python.runtime.PythonContext;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -125,15 +123,14 @@ public abstract static class NextReaderNode extends TpIterNextBuiltin {
             static Object nextPos(VirtualFrame frame, CSVReader self,
                             @Bind("this") Node inliningTarget,
                             @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode,
    -                        @Cached TruffleStringIterator.NextNode nextNode,
    +                        @Cached TruffleStringIterator.NextNode stringNextNode,
                             @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode,
                             @Cached TruffleStringBuilder.ToStringNode toStringNode,
                             @Cached PyNumberFloatNode pyNumberFloatNode,
                             @Cached AppendNode appendNode,
    -                        @Cached GetNextNode getNextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CastToTruffleStringNode castToStringNode,
                             @Cached GetClassNode getClassNode,
    -                        @Cached IsBuiltinObjectProfile isBuiltinClassProfile,
                             @Bind PythonLanguage language,
                             @Cached PRaiseNode raiseNode) {
                 PList fields = PFactory.createList(language);
    @@ -141,10 +138,8 @@ static Object nextPos(VirtualFrame frame, CSVReader self,
                 self.parseReset();
                 do {
                     Object lineObj;
    -                try {
    -                    lineObj = getNextNode.execute(frame, self.inputIter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, isBuiltinClassProfile);
    +                lineObj = nextNode.execute(frame, inliningTarget, self.inputIter);
    +                if (PyIterNextNode.isExhausted(lineObj)) {
                         self.fieldLimit = csvModuleBuiltins.fieldLimit;
                         if (!self.field.isEmpty() || self.state == IN_QUOTED_FIELD) {
                             if (self.dialect.strict) {
    @@ -153,7 +148,6 @@ static Object nextPos(VirtualFrame frame, CSVReader self,
                                 try {
                                     parseSaveField(inliningTarget, self, fields, toStringNode, pyNumberFloatNode, appendNode);
                                 } catch (AbstractTruffleException ignored) {
    -                                throw e;
                                 }
                                 break;
                             }
    @@ -172,7 +166,7 @@ static Object nextPos(VirtualFrame frame, CSVReader self,
                     self.lineNum++;
                     TruffleStringIterator tsi = createCodePointIteratorNode.execute(line, TS_ENCODING);
                     while (tsi.hasNext()) {
    -                    final int codepoint = nextNode.execute(tsi);
    +                    final int codepoint = stringNextNode.execute(tsi);
                         parseProcessCodePoint(inliningTarget, self, fields, codepoint, appendCodePointNode, toStringNode, pyNumberFloatNode, appendNode, raiseNode);
                     }
                     parseProcessCodePoint(inliningTarget, self, fields, EOL, appendCodePointNode, toStringNode, pyNumberFloatNode, appendNode, raiseNode);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java
    index 498c5edcea..45b5e34d61 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/csv/CSVWriterBuiltins.java
    @@ -51,7 +51,7 @@
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.PNone;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode;
    @@ -94,15 +94,14 @@ static Object doIt(VirtualFrame frame, CSVWriter self, Object seq,
                             @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached CallUnaryMethodNode callNode,
                             @Cached TruffleString.CreateCodePointIteratorNode createCodePointIteratorNode,
    -                        @Cached TruffleStringIterator.NextNode nextNode,
    +                        @Cached TruffleStringIterator.NextNode stringNextNode,
                             @Cached TruffleString.ByteIndexOfCodePointNode byteIndexOfCodePointNode,
                             @Cached TruffleStringBuilder.AppendCodePointNode appendCodePointNode,
                             @Cached TruffleStringBuilder.AppendStringNode appendStringNode,
                             @Cached TruffleStringBuilder.ToStringNode toStringNode,
                             @Cached PyObjectStrAsTruffleStringNode objectStrAsTruffleStringNode,
                             @Cached PyNumberCheckNode pyNumberCheckNode,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile isBuiltinClassProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PRaiseNode raiseNode) {
                 Object iter;
     
    @@ -118,26 +117,24 @@ static Object doIt(VirtualFrame frame, CSVWriter self, Object seq,
                 CSVDialect dialect = self.dialect;
                 boolean first = true;
                 while (true) {
    -                try {
    -                    Object field = getNextNode.execute(frame, iter);
    -                    /* If this is not the first field we need a field separator */
    -                    if (!first) {
    -                        appendStringNode.execute(sb, dialect.delimiter);
    -                    } else {
    -                        first = false;
    -                    }
    -                    joinField(inliningTarget, sb, dialect, field, createCodePointIteratorNode, nextNode, byteIndexOfCodePointNode, appendCodePointNode, appendStringNode, objectStrAsTruffleStringNode,
    -                                    pyNumberCheckNode, raiseNode);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, isBuiltinClassProfile);
    +                Object field = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(field)) {
                         break;
                     }
    +                /* If this is not the first field we need a field separator */
    +                if (!first) {
    +                    appendStringNode.execute(sb, dialect.delimiter);
    +                } else {
    +                    first = false;
    +                }
    +                joinField(inliningTarget, sb, dialect, field, createCodePointIteratorNode, stringNextNode, byteIndexOfCodePointNode, appendCodePointNode, appendStringNode,
    +                                objectStrAsTruffleStringNode, pyNumberCheckNode, raiseNode);
                 }
                 if (!first && sb.isEmpty()) {
                     if (dialect.quoting == QUOTE_NONE) {
                         throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.CSVError, ErrorMessages.EMPTY_FIELD_RECORD_MUST_BE_QUOTED);
                     }
    -                joinAppend(inliningTarget, sb, dialect, null, true, createCodePointIteratorNode, nextNode, byteIndexOfCodePointNode, appendCodePointNode, appendStringNode, raiseNode);
    +                joinAppend(inliningTarget, sb, dialect, null, true, createCodePointIteratorNode, stringNextNode, byteIndexOfCodePointNode, appendCodePointNode, appendStringNode, raiseNode);
                 }
                 appendStringNode.execute(sb, dialect.lineTerminator);
                 return callNode.executeObject(frame, self.write, toStringNode.execute(sb));
    @@ -259,21 +256,15 @@ public abstract static class WriteRowsNode extends PythonBinaryBuiltinNode {
             Object doIt(VirtualFrame frame, CSVWriter self, Object seq,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode getNext,
    -                        @Cached IsBuiltinObjectProfile isBuiltinClassProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached WriteRowNode writeRow) {
    -            Object iter, row;
    -
    -            iter = getIter.execute(frame, inliningTarget, seq);
    -
    +            Object iter = getIter.execute(frame, inliningTarget, seq);
                 while (true) {
    -                try {
    -                    row = getNext.execute(frame, iter);
    -                    writeRow.execute(frame, self, row);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, isBuiltinClassProfile);
    +                Object row = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(row)) {
                         break;
                     }
    +                writeRow.execute(frame, self, row);
                 }
                 return PNone.NONE;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java
    index 7c84fcadaf..0f9c12f3a8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/FunctoolsModuleBuiltins.java
    @@ -55,7 +55,7 @@
     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.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PGuards;
     import com.oracle.graal.python.nodes.PRaiseNode;
    @@ -119,7 +119,7 @@ public abstract static class ReduceNode extends PythonTernaryBuiltinNode {
             Object doReduce(VirtualFrame frame, Object function, Object sequence, Object initialIn,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CallNode callNode,
                             @Cached InlinedConditionProfile initialNoValueProfile,
                             @Cached IsBuiltinObjectProfile stopIterProfile,
    @@ -138,24 +138,21 @@ Object doReduce(VirtualFrame frame, Object function, Object sequence, Object ini
     
                 int count = 0;
                 while (true) {
    -                Object op2;
    -                try {
    -                    op2 = nextNode.execute(frame, seqIterator);
    -                    if (result == null) {
    -                        result = op2;
    -                    } else {
    -                        // Update the args tuple in-place
    -                        args[0] = result;
    -                        args[1] = op2;
    -                        result = callNode.execute(frame, function, args);
    -                    }
    -                    if (CompilerDirectives.hasNextTier()) {
    -                        count++;
    -                    }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, stopIterProfile);
    +                Object op2 = nextNode.execute(frame, inliningTarget, seqIterator);
    +                if (PyIterNextNode.isExhausted(op2)) {
                         break;
                     }
    +                if (result == null) {
    +                    result = op2;
    +                } else {
    +                    // Update the args tuple in-place
    +                    args[0] = result;
    +                    args[1] = op2;
    +                    result = callNode.execute(frame, function, args);
    +                }
    +                if (CompilerDirectives.hasNextTier()) {
    +                    count++;
    +                }
                 }
                 reportLoopCount(this, count >= 0 ? count : Integer.MAX_VALUE);
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    index 928146b0c8..86de98597b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java
    @@ -100,8 +100,8 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyMemoryViewFromObject;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -113,10 +113,8 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetOrCreateDictNode;
     import com.oracle.graal.python.runtime.IndirectCallData;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
     import com.oracle.graal.python.util.ArrayBuilder;
    @@ -476,19 +474,15 @@ abstract static class WriteLinesNode extends ClosedCheckPythonBinaryBuiltinNode
             @Specialization(guards = "self.hasBuf()")
             static Object writeLines(VirtualFrame frame, PBytesIO self, Object lines,
                             @Bind("this") Node inliningTarget,
    -                        @Cached GetNextNode getNextNode,
                             @Cached WriteNode writeNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PRaiseNode raiseNode) {
                 self.checkExports(inliningTarget, raiseNode);
                 Object iter = getIter.execute(frame, inliningTarget, lines);
                 while (true) {
    -                Object line;
    -                try {
    -                    line = getNextNode.execute(frame, iter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object line = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(line)) {
                         break;
                     }
                     writeNode.execute(frame, self, line);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    index 5b0c60c616..4344ea06c5 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/IOBaseBuiltins.java
    @@ -99,8 +99,8 @@
     import com.oracle.graal.python.builtins.objects.object.PythonObject;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyErrChainExceptions;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -118,7 +118,6 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.IsNode;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -449,18 +448,14 @@ abstract static class WriteLinesNode extends PythonBinaryBuiltinNode {
             static Object writeLines(VirtualFrame frame, PythonObject self, Object lines,
                             @Bind("this") Node inliningTarget,
                             @Cached CheckClosedHelperNode checkClosedNode,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached PyObjectCallMethodObjArgs callMethod,
    -                        @Cached PyObjectGetIter getIter) {
    +                        @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode) {
                 checkClosedNode.execute(frame, inliningTarget, self);
                 Object iter = getIter.execute(frame, inliningTarget, lines);
                 while (true) {
    -                Object line;
    -                try {
    -                    line = getNextNode.execute(frame, iter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object line = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(line)) {
                         break;
                     }
                     callMethod.execute(frame, inliningTarget, self, T_WRITE, line);
    @@ -551,28 +546,25 @@ protected ArgumentClinicProvider getArgumentClinic() {
             static Object withHint(VirtualFrame frame, Object self, int hintIn,
                             @Bind("this") Node inliningTarget,
                             @Bind PythonLanguage language,
    -                        @Cached GetNextNode next,
                             @Cached InlinedConditionProfile isNegativeHintProfile,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectSizeNode sizeNode) {
                 int hint = isNegativeHintProfile.profile(inliningTarget, hintIn <= 0) ? Integer.MAX_VALUE : hintIn;
                 int length = 0;
                 Object iterator = getIter.execute(frame, inliningTarget, self);
                 ArrayBuilder list = new ArrayBuilder<>();
                 while (true) {
    -                try {
    -                    Object line = next.execute(frame, iterator);
    -                    list.add(line);
    -                    int lineLength = sizeNode.execute(frame, inliningTarget, line);
    -                    if (lineLength > hint - length) {
    -                        break;
    -                    }
    -                    length += lineLength;
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object line = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(line)) {
    +                    break;
    +                }
    +                list.add(line);
    +                int lineLength = sizeNode.execute(frame, inliningTarget, line);
    +                if (lineLength > hint - length) {
                         break;
                     }
    +                length += lineLength;
                 }
                 return PFactory.createList(language, list.toArray(new Object[0]));
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    index dd6e66faee..65bb603aa0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/json/JSONEncoderBuiltins.java
    @@ -45,7 +45,7 @@
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyListCheckExactNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyTupleCheckExactNode;
    @@ -59,9 +59,7 @@
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.formatting.FloatFormatter;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.PSequence;
    @@ -269,11 +267,8 @@ private void appendDictSlowPath(PJSONEncoder encoder, TruffleStringBuilderUTF32
                 Object iter = callGetDictIter.executeCached(null, items);
                 boolean first = true;
                 while (true) {
    -                Object item;
    -                try {
    -                    item = GetNextNode.getUncached().execute(null, iter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(null, IsBuiltinObjectProfile.getUncached());
    +                Object item = PyIterNextNode.executeUncached(iter);
    +                if (PyIterNextNode.isExhausted(item)) {
                         break;
                     }
                     if (!(item instanceof PTuple itemTuple) || itemTuple.getSequenceStorage().length() != 2) {
    @@ -337,11 +332,8 @@ private void appendListSlowPath(PJSONEncoder encoder, TruffleStringBuilderUTF32
                 Object iter = callGetListIter.executeCached(null, list);
                 boolean first = true;
                 while (true) {
    -                Object item;
    -                try {
    -                    item = GetNextNode.getUncached().execute(null, iter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(null, IsBuiltinObjectProfile.getUncached());
    +                Object item = PyIterNextNode.executeUncached(iter);
    +                if (PyIterNextNode.isExhausted(item)) {
                         break;
                     }
                     if (!first) {
    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 d0febd66ee..e766a77ddf 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
    @@ -103,8 +103,8 @@
     import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyCallableCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyMappingCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -1758,8 +1758,7 @@ public boolean hasIteratorNextElement(
                         @Exclusive @Cached CastToJavaBooleanNode toBooleanNode,
                         // GR-44020: make shared:
                         @Exclusive @Cached PRaiseNode raiseNode,
    -                    @Cached GetNextNode getNextNode,
    -                    @Exclusive @Cached IsBuiltinObjectProfile exceptionProfile,
    +                    @Cached PyIterNextNode nextNode,
                         @Exclusive @Cached GilNode gil,
                         @CachedLibrary("this") InteropLibrary ilib,
                         // GR-44020: make shared:
    @@ -1777,14 +1776,12 @@ public boolean hasIteratorNextElement(
                         if (nextElement != null) {
                             return true;
                         }
    -                    try {
    -                        nextElement = getNextNode.execute(null, this);
    -                        writeHiddenAttrNode.execute(inliningTarget, this, HiddenAttr.NEXT_ELEMENT, nextElement);
    -                        return true;
    -                    } catch (PException e) {
    -                        e.expect(inliningTarget, PythonBuiltinClassType.StopIteration, exceptionProfile);
    +                    nextElement = nextNode.execute(null, inliningTarget, this);
    +                    if (PyIterNextNode.isExhausted(nextElement)) {
                             return false;
                         }
    +                    writeHiddenAttrNode.execute(inliningTarget, this, HiddenAttr.NEXT_ELEMENT, nextElement);
    +                    return true;
                     }
                 }
                 throw UnsupportedMessageException.create();
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    index de642089ca..7ef22d4b6d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java
    @@ -91,8 +91,8 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyNumberIndexNode;
     import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
    @@ -115,7 +115,6 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
     import com.oracle.graal.python.runtime.IndirectCallData;
    @@ -967,20 +966,16 @@ static Object extend(VirtualFrame frame, PArray self, PSequence value,
             static Object extend(VirtualFrame frame, PArray self, Object value,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode,
                             @Exclusive @Cached ArrayNodes.PutValueNode putValueNode,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Exclusive @Cached ArrayNodes.EnsureCapacityNode ensureCapacityNode,
                             @Exclusive @Cached ArrayNodes.SetLengthNode setLengthNode,
                             @Exclusive @Cached PRaiseNode raiseNode) {
                 Object iter = getIter.execute(frame, inliningTarget, value);
                 int length = self.getLength();
                 while (true) {
    -                Object nextValue;
    -                try {
    -                    nextValue = nextNode.execute(frame, iter);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object nextValue = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(nextValue)) {
                         break;
                     }
                     // The whole extend is not atomic, just individual inserts are. That's the same as
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java
    index bfeaa560dd..fce33e9802 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java
    @@ -76,10 +76,10 @@
     import com.oracle.graal.python.builtins.objects.iterator.IteratorNodes;
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.str.StringNodes;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyByteArrayCheckNode;
     import com.oracle.graal.python.lib.PyBytesCheckNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyOSFSPathNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -181,19 +181,17 @@ public abstract static class BytesJoinNode extends PNodeWithContext {
             @Specialization
             static byte[] join(VirtualFrame frame, Node inliningTarget, byte[] sep, Object iterable,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached(inline = false) GetNextNode getNextNode,
    -                        @Cached(inline = false) ToBytesNode toBytesNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile) {
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached(inline = false) ToBytesNode toBytesNode) {
                 ArrayList parts = new ArrayList<>();
                 int partsTotalSize = 0;
                 Object iterator = getIter.execute(frame, inliningTarget, iterable);
                 while (true) {
    -                try {
    -                    partsTotalSize += append(parts, toBytesNode.execute(frame, getNextNode.execute(frame, iterator)));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         return joinArrays(sep, parts, partsTotalSize);
                     }
    +                partsTotalSize += append(parts, toBytesNode.execute(frame, next));
                 }
             }
     
    @@ -776,8 +774,7 @@ public abstract static class IterableToByteNode extends Node {
             static byte[] bytearray(VirtualFrame frame, Object iterable,
                             @Bind("this") Node inliningTarget,
                             @Cached IteratorNodes.GetLength lenghtHintNode,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile stopIterationProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached CastToByteNode castToByteNode,
                             @Cached PyObjectGetIter getIter) {
                 Object it = getIter.execute(frame, inliningTarget, iterable);
    @@ -785,16 +782,15 @@ static byte[] bytearray(VirtualFrame frame, Object iterable,
                 byte[] arr = new byte[len < 16 && len > 0 ? len : 16];
                 int i = 0;
                 while (true) {
    -                try {
    -                    byte item = castToByteNode.execute(frame, getNextNode.execute(frame, it));
    -                    if (i >= arr.length) {
    -                        arr = resize(arr, arr.length * 2);
    -                    }
    -                    arr[i++] = item;
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, stopIterationProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(next)) {
                         return resize(arr, i);
                     }
    +                byte item = castToByteNode.execute(frame, next);
    +                if (i >= arr.length) {
    +                    arr = resize(arr, arr.length * 2);
    +                }
    +                arr[i++] = item;
                 }
             }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java
    index 55c4644dbe..40594e1437 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2025, 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
    @@ -54,13 +54,11 @@
     import com.oracle.graal.python.builtins.objects.dict.DictNodes;
     import com.oracle.graal.python.builtins.objects.dict.PDict;
     import com.oracle.graal.python.builtins.objects.dict.PDictView;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.PGuards;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -215,18 +213,14 @@ static HashingStorage doString(Node inliningTarget, Object strObj, Object value,
             @InliningCutoff
             static HashingStorage doIterable(VirtualFrame frame, Node inliningTarget, Object other, Object value,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached(inline = false) GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Exclusive @Cached HashingStorageSetItem setStorageItem) {
                 HashingStorage curStorage = EmptyStorage.INSTANCE;
                 Object iterator = getIter.execute(frame, inliningTarget, other);
                 Object val = value == PNone.NO_VALUE ? PNone.NONE : value;
                 while (true) {
    -                Object key;
    -                try {
    -                    key = nextNode.execute(frame, iterator);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object key = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(key)) {
                         return curStorage;
                     }
                     curStorage = setStorageItem.execute(frame, inliningTarget, curStorage, key, val);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    index fa913c3fa8..19fdc83603 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    @@ -86,7 +86,6 @@
     import com.oracle.graal.python.builtins.objects.slice.SliceNodes.ComputeIndices;
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
    @@ -1746,7 +1745,7 @@ static void multiStep(SequenceStorage self, SliceInfo sinfo, SequenceStorage val
                 } else {
                     /*- Assign slice */
                     if (wrongLength.profile(inliningTarget, needed != slicelen)) {
    -                    raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ATTEMPT_TO_ASSIGN_SEQ_OF_SIZE_TO_SLICE_OF_SIZE, needed, slicelen);
    +                    throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.ATTEMPT_TO_ASSIGN_SEQ_OF_SIZE_TO_SLICE_OF_SIZE, needed, slicelen);
                     }
                     for (int cur = start, i = 0; i < slicelen; cur += step, i++) {
                         setLeftItemNode.execute(inliningTarget, self, cur, getRightItemNode.execute(inliningTarget, data, i));
    @@ -2400,8 +2399,7 @@ SequenceStorage doWithoutStorage(VirtualFrame frame, SequenceStorage left, Objec
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
                             @Exclusive @Cached EnsureCapacityNode ensureCapacityNode,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached AppendNode appendNode) {
                 SequenceStorage currentStore = left;
                 int lenLeft = currentStore.length();
    @@ -2411,13 +2409,11 @@ SequenceStorage doWithoutStorage(VirtualFrame frame, SequenceStorage left, Objec
                 }
                 while (true) {
                     Object value;
    -                try {
    -                    value = getNextNode.execute(frame, it);
    -                    currentStore = appendNode.execute(inliningTarget, currentStore, value, genNodeProvider);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                value = nextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(value)) {
                         return currentStore;
                     }
    +                currentStore = appendNode.execute(inliningTarget, currentStore, value, genNodeProvider);
                 }
             }
     
    @@ -4097,11 +4093,11 @@ public final SequenceStorage execute(VirtualFrame frame, Object iterator) {
     
             private static final int START_SIZE = 4;
     
    -        protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int len, StorageType type, GetNextNode nextNode, IsBuiltinObjectProfile errorProfile,
    +        protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int len, StorageType type, PyIterNextNode nextNode,
                             Node inliningTarget, InlinedCountingConditionProfile growArrayProfile) {
                 final int size = len > 0 ? len : START_SIZE;
                 if (type == Uninitialized || type == Empty) {
    -                return createStorageUninitialized(frame, inliningTarget, iterator, nextNode, errorProfile, size);
    +                return createStorageUninitialized(frame, inliningTarget, iterator, nextNode, size);
                 } else {
                     int i = 0;
                     Object array = null;
    @@ -4110,107 +4106,106 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                             case Boolean: {
                                 boolean[] elements = new boolean[size];
                                 array = elements;
    -                            try {
    -                                while (true) {
    -                                    boolean value = PGuards.expectBoolean(nextNode.execute(frame, iterator));
    -                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                        array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                    }
    -                                    elements[i++] = value;
    +                            while (true) {
    +                                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(next)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
    +                                boolean value = PGuards.expectBoolean(next);
    +                                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                    array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                                }
    +                                elements[i++] = value;
                                 }
                                 return new BoolSequenceStorage(elements, i);
                             }
                             case Byte: {
                                 byte[] elements = new byte[size];
                                 array = elements;
    -                            try {
    -                                while (true) {
    -                                    int value = PGuards.expectInteger(nextNode.execute(frame, iterator));
    -                                    byte bvalue;
    -                                    try {
    -                                        bvalue = PInt.byteValueExact(value);
    -                                        if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                            array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                        }
    -                                        elements[i++] = bvalue;
    -                                    } catch (OverflowException e) {
    -                                        throw new UnexpectedResultException(value);
    +                            while (true) {
    +                                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(next)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
    +                                }
    +                                int value = PGuards.expectInteger(next);
    +                                byte bvalue;
    +                                try {
    +                                    bvalue = PInt.byteValueExact(value);
    +                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                        array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                                         }
    +                                    elements[i++] = bvalue;
    +                                } catch (OverflowException e) {
    +                                    throw new UnexpectedResultException(value);
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
                                 }
                                 return new ByteSequenceStorage(elements, i);
                             }
                             case Int: {
                                 int[] elements = new int[size];
                                 array = elements;
    -                            try {
    -                                while (true) {
    -                                    int value = PGuards.expectInteger(nextNode.execute(frame, iterator));
    -                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                        array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                    }
    -                                    elements[i++] = value;
    +                            while (true) {
    +                                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(next)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
    +                                int value = PGuards.expectInteger(next);
    +                                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                    array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                                }
    +                                elements[i++] = value;
                                 }
                                 return new IntSequenceStorage(elements, i);
                             }
                             case Long: {
                                 long[] elements = new long[size];
                                 array = elements;
    -                            try {
    -                                while (true) {
    -                                    long value = PGuards.expectLong(nextNode.execute(frame, iterator));
    -                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                        array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                    }
    -                                    elements[i++] = value;
    +                            while (true) {
    +                                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(next)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
    +                                long value = PGuards.expectLong(next);
    +                                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                    array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                                }
    +                                elements[i++] = value;
                                 }
                                 return new LongSequenceStorage(elements, i);
                             }
                             case Double: {
                                 double[] elements = new double[size];
                                 array = elements;
    -                            try {
    -                                while (true) {
    -                                    double value = PGuards.expectDouble(nextNode.execute(frame, iterator));
    -                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                        array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                    }
    -                                    elements[i++] = value;
    +                            while (true) {
    +                                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(next)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
    +                                double value = PGuards.expectDouble(next);
    +                                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                    array = elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                                }
    +                                elements[i++] = value;
                                 }
                                 return new DoubleSequenceStorage(elements, i);
                             }
                             case Generic: {
                                 Object[] elements = new Object[size];
    -                            try {
    -                                while (true) {
    -                                    Object value = nextNode.execute(frame, iterator);
    -                                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                                        elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                                    }
    -                                    elements[i++] = value;
    +                            while (true) {
    +                                Object value = nextNode.execute(frame, inliningTarget, iterator);
    +                                if (PyIterNextNode.isExhausted(value)) {
    +                                    LoopNode.reportLoopCount(this, i);
    +                                    break;
                                     }
    -                            } catch (PException e) {
    -                                LoopNode.reportLoopCount(this, i);
    -                                e.expectStopIteration(inliningTarget, errorProfile);
    +                                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                                    elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                                }
    +                                elements[i++] = value;
                                 }
                                 return new ObjectSequenceStorage(elements, i);
                             }
    @@ -4219,33 +4214,30 @@ protected SequenceStorage createStorage(VirtualFrame frame, Object iterator, int
                                 throw new RuntimeException("unexpected state");
                         }
                     } catch (UnexpectedResultException e) {
    -                    return genericFallback(frame, iterator, array, i, e.getResult(), nextNode, errorProfile, inliningTarget, growArrayProfile);
    +                    return genericFallback(frame, iterator, array, i, e.getResult(), nextNode, inliningTarget, growArrayProfile);
                     }
                 }
             }
     
    -        private SequenceStorage createStorageUninitialized(VirtualFrame frame, Node inliningTarget, Object iterator, GetNextNode nextNode, IsBuiltinObjectProfile errorProfile, int size) {
    +        private SequenceStorage createStorageUninitialized(VirtualFrame frame, Node inliningTarget, Object iterator, PyIterNextNode nextNode, int size) {
                 Object[] elements = new Object[size];
                 int i = 0;
                 while (true) {
    -                try {
    -                    Object value = nextNode.execute(frame, iterator);
    -                    if (i >= elements.length) {
    -                        // Intentionally not profiled, because "size" can be reprofiled after this
    -                        // first initialization run
    -                        elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                    }
    -                    elements[i++] = value;
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object value = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(value)) {
                         LoopNode.reportLoopCount(this, i);
    -                    break;
    +                    return SequenceStorageFactory.createStorage(PythonUtils.arrayCopyOf(elements, i));
    +                }
    +                if (i >= elements.length) {
    +                    // Intentionally not profiled, because "size" can be reprofiled after this
    +                    // first initialization run
    +                    elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
                     }
    +                elements[i++] = value;
                 }
    -            return SequenceStorageFactory.createStorage(PythonUtils.arrayCopyOf(elements, i));
             }
     
    -        private SequenceStorage genericFallback(VirtualFrame frame, Object iterator, Object array, int count, Object result, GetNextNode nextNode, IsBuiltinObjectProfile errorProfile,
    +        private SequenceStorage genericFallback(VirtualFrame frame, Object iterator, Object array, int count, Object result, PyIterNextNode nextNode,
                             Node inliningTarget, InlinedCountingConditionProfile growArrayProfile) {
                 Object[] elements = new Object[Array.getLength(array) * 2];
                 int i = 0;
    @@ -4254,19 +4246,16 @@ private SequenceStorage genericFallback(VirtualFrame frame, Object iterator, Obj
                 }
                 elements[i++] = result;
                 while (true) {
    -                try {
    -                    Object value = nextNode.execute(frame, iterator);
    -                    if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    -                        elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    -                    }
    -                    elements[i++] = value;
    -                } catch (PException e) {
    +                Object value = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(value)) {
                         LoopNode.reportLoopCount(this, i);
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    break;
    +                    return new ObjectSequenceStorage(elements, i);
                     }
    +                if (growArrayProfile.profile(inliningTarget, i >= elements.length)) {
    +                    elements = PythonUtils.arrayCopyOf(elements, elements.length * 2);
    +                }
    +                elements[i++] = value;
                 }
    -            return new ObjectSequenceStorage(elements, i);
             }
     
             /**
    @@ -4434,7 +4423,7 @@ public abstract static class CreateStorageFromIteratorNodeCached extends CreateS
                 @CompilationFinal int startSizeProfiled = START_SIZE;
     
                 public boolean isBuiltinIterator(GetClassNode getClass, Node inliningTarget, Object iterator) {
    -                return iterator instanceof PBuiltinIterator && getClass.execute(inliningTarget, (PBuiltinIterator) iterator) == PythonBuiltinClassType.PIterator;
    +                return iterator instanceof PBuiltinIterator && getClass.execute(inliningTarget, iterator) == PythonBuiltinClassType.PIterator;
                 }
     
                 public static SequenceStorage getSequenceStorage(Node inliningTarget, GetInternalIteratorSequenceStorage node, PBuiltinIterator iterator) {
    @@ -4487,11 +4476,10 @@ public SequenceStorage createBuiltinKnownLen(VirtualFrame frame, PBuiltinIterato
                 public SequenceStorage createGenericUnknownLen(VirtualFrame frame, Object iterator, @SuppressWarnings("unused") int len,
                                 @Bind("this") Node inliningTarget,
                                 @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode,
    -                            @Shared("errProfile") @Cached IsBuiltinObjectProfile errorProfile,
                                 @Shared("arrayGrowProfile") @Cached InlinedCountingConditionProfile arrayGrowProfile,
                                 @Shared @Cached GetElementType getElementType,
    -                            @Shared @Cached GetNextNode getNextNode) {
    -                SequenceStorage s = createStorage(frame, iterator, startSizeProfiled, expectedElementType, getNextNode, errorProfile, inliningTarget, arrayGrowProfile);
    +                            @Shared @Cached PyIterNextNode nextNode) {
    +                SequenceStorage s = createStorage(frame, iterator, startSizeProfiled, expectedElementType, nextNode, inliningTarget, arrayGrowProfile);
                     return profileResult(getElementType, inliningTarget, s, true);
                 }
     
    @@ -4499,11 +4487,10 @@ public SequenceStorage createGenericUnknownLen(VirtualFrame frame, Object iterat
                 public SequenceStorage createGenericKnownLen(VirtualFrame frame, Object iterator, int len,
                                 @Bind("this") Node inliningTarget,
                                 @SuppressWarnings("unused") @Shared @Cached GetClassNode getClassNode,
    -                            @Shared("errProfile") @Cached IsBuiltinObjectProfile errorProfile,
                                 @Shared("arrayGrowProfile") @Cached InlinedCountingConditionProfile arrayGrowProfile,
                                 @Shared @Cached GetElementType getElementType,
    -                            @Shared @Cached GetNextNode getNextNode) {
    -                SequenceStorage s = createStorage(frame, iterator, len, expectedElementType, getNextNode, errorProfile, inliningTarget, arrayGrowProfile);
    +                            @Shared @Cached PyIterNextNode nextNode) {
    +                SequenceStorage s = createStorage(frame, iterator, len, expectedElementType, nextNode, inliningTarget, arrayGrowProfile);
                     return profileResult(getElementType, inliningTarget, s, false);
                 }
     
    @@ -4541,7 +4528,7 @@ private static SequenceStorage executeImpl(Object iterator, int len) {
                             }
                         }
                     }
    -                return create().createStorageUninitialized(null, null, iterator, GetNextNode.getUncached(), IsBuiltinObjectProfile.getUncached(), len >= 0 ? len : START_SIZE);
    +                return create().createStorageUninitialized(null, null, iterator, PyIterNextNode.getUncached(), len >= 0 ? len : START_SIZE);
                 }
             }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    index ce0c2c7880..7b0ef096e6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java
    @@ -44,7 +44,6 @@
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.MemoryError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeError;
    -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.StopIteration;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
     import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
     import static com.oracle.graal.python.nodes.BuiltinNames.J_APPEND;
    @@ -99,7 +98,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqRepeatBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqAssItem.SqAssItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectGetStateNode;
    @@ -174,19 +173,17 @@ static PNone doIterable(VirtualFrame frame, PDeque self, Object iterable, @Suppr
                             @Bind("this") Node inliningTarget,
                             @Exclusive @Cached InlinedConditionProfile sizeZeroProfile,
                             @Exclusive @Cached PyObjectGetIter getIter,
    -                        @Exclusive @Cached GetNextNode getNextNode,
    -                        @Exclusive @Cached IsBuiltinObjectProfile isStopIterationProfile) {
    +                        @Exclusive @Cached PyIterNextNode nextNode) {
                 if (sizeZeroProfile.profile(inliningTarget, self.getSize() != 0)) {
                     self.clear();
                 }
                 Object iterator = getIter.execute(frame, inliningTarget, iterable);
                 while (true) {
    -                try {
    -                    self.append(getNextNode.execute(frame, iterator));
    -                } catch (PException e) {
    -                    e.expect(inliningTarget, PythonBuiltinClassType.StopIteration, isStopIterationProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
    +                self.append(next);
                 }
                 return PNone.NONE;
             }
    @@ -197,9 +194,8 @@ static PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object
                             @Exclusive @Cached InlinedConditionProfile sizeZeroProfile,
                             @Cached CastToJavaIntExactNode castToIntNode,
                             @Exclusive @Cached PyObjectGetIter getIter,
    -                        @Exclusive @Cached GetNextNode getNextNode,
    +                        @Exclusive @Cached PyIterNextNode nextNode,
                             @Exclusive @Cached IsBuiltinObjectProfile isTypeErrorProfile,
    -                        @Exclusive @Cached IsBuiltinObjectProfile isStopIterationProfile,
                             @Cached PRaiseNode raiseNode) {
                 if (!PGuards.isPNone(maxlenObj)) {
                     try {
    @@ -221,7 +217,7 @@ static PNone doGeneric(VirtualFrame frame, PDeque self, Object iterable, Object
                 }
     
                 if (iterable != PNone.NO_VALUE) {
    -                doIterable(frame, self, iterable, PNone.NO_VALUE, inliningTarget, sizeZeroProfile, getIter, getNextNode, isStopIterationProfile);
    +                doIterable(frame, self, iterable, PNone.NO_VALUE, inliningTarget, sizeZeroProfile, getIter, nextNode);
                 }
                 return PNone.NONE;
             }
    @@ -347,36 +343,32 @@ PNone doGeneric(VirtualFrame frame, PDeque self, Object other,
                             @Cached InlinedConditionProfile selfIsOtherProfile,
                             @Cached InlinedConditionProfile maxLenZeroProfile,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 if (selfIsOtherProfile.profile(inliningTarget, self == other)) {
                     return doSelf(self, self);
                 }
     
                 Object it = getIter.execute(frame, inliningTarget, other);
                 if (maxLenZeroProfile.profile(inliningTarget, self.getMaxLength() == 0)) {
    -                consumeIterator(frame, it, getNextNode, inliningTarget, isStopIterationProfile);
    +                consumeIterator(frame, it, nextNode, inliningTarget);
                     return PNone.NONE;
                 }
     
                 while (true) {
    -                try {
    -                    appendOperation(self, getNextNode.execute(frame, it));
    -                } catch (PException e) {
    -                    e.expect(inliningTarget, StopIteration, isStopIterationProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
    +                appendOperation(self, next);
                 }
    -            consumeIterator(frame, it, getNextNode, inliningTarget, isStopIterationProfile);
    +            consumeIterator(frame, it, nextNode, inliningTarget);
                 return PNone.NONE;
             }
     
    -        private static void consumeIterator(VirtualFrame frame, Object it, GetNextNode getNextNode, Node inliningTarget, IsBuiltinObjectProfile isStopIterationProfile) {
    +        private static void consumeIterator(VirtualFrame frame, Object it, PyIterNextNode getNextNode, Node inliningTarget) {
                 while (true) {
    -                try {
    -                    getNextNode.execute(frame, it);
    -                } catch (PException e) {
    -                    e.expect(inliningTarget, StopIteration, isStopIterationProfile);
    +                Object next = getNextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
                 }
    @@ -690,8 +682,7 @@ static PDeque doDeque(PDeque self, PDeque other) {
             static PDeque doOther(VirtualFrame frame, PDeque self, Object other,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile isStopIterationProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 if (other instanceof PDeque) {
                     return doDeque(self, (PDeque) other);
                 }
    @@ -702,12 +693,11 @@ static PDeque doOther(VirtualFrame frame, PDeque self, Object other,
                  */
                 Object iterator = getIter.execute(frame, inliningTarget, other);
                 while (true) {
    -                try {
    -                    self.append(getNextNode.execute(frame, iterator));
    -                } catch (PException e) {
    -                    e.expect(inliningTarget, PythonBuiltinClassType.StopIteration, isStopIterationProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         break;
                     }
    +                self.append(next);
                 }
                 return self;
             }
    @@ -955,24 +945,25 @@ static Object doOther(Object self, Object other, ComparisonOp op, PyObjectRichCo
             static Object doGeneric(VirtualFrame frame, Node inliningTarget, PDeque self, PDeque other, @SuppressWarnings("unused") ComparisonOp op, PyObjectRichCompareBool.ComparisonBaseNode cmpNode,
                             @Cached PyObjectGetIter getIterSelf,
                             @Cached PyObjectGetIter getIterOther,
    -                        @Cached(inline = false) GetNextNode selfItNextNode,
    -                        @Cached(inline = false) GetNextNode otherItNextNode,
    -                        @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                        @Cached IsBuiltinObjectProfile profile) {
    +                        @Cached PyIterNextNode selfItNextNode,
    +                        @Cached PyIterNextNode otherItNextNode,
    +                        @Cached PyObjectRichCompareBool.EqNode eqNode) {
                 Object ait = getIterSelf.execute(frame, inliningTarget, self);
                 Object bit = getIterOther.execute(frame, inliningTarget, other);
                 while (true) {
    -                try {
    -                    Object selfItem = selfItNextNode.execute(frame, ait);
    -                    Object otherItem = otherItNextNode.execute(frame, bit);
    -                    if (!eqNode.compare(frame, inliningTarget, selfItem, otherItem)) {
    -                        return cmpNode.compare(frame, inliningTarget, selfItem, otherItem);
    -                    }
    -                } catch (PException e) {
    -                    e.expect(inliningTarget, StopIteration, profile);
    -                    return cmpNode.compare(frame, inliningTarget, self.getSize(), other.getSize());
    +                Object selfItem = selfItNextNode.execute(frame, inliningTarget, ait);
    +                if (PyIterNextNode.isExhausted(selfItem)) {
    +                    break;
    +                }
    +                Object otherItem = otherItNextNode.execute(frame, inliningTarget, bit);
    +                if (PyIterNextNode.isExhausted(otherItem)) {
    +                    break;
    +                }
    +                if (!eqNode.compare(frame, inliningTarget, selfItem, otherItem)) {
    +                    return cmpNode.compare(frame, inliningTarget, selfItem, otherItem);
                     }
                 }
    +            return cmpNode.compare(frame, inliningTarget, self.getSize(), other.getSize());
             }
     
             static boolean isPDeque(Object object) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    index f12ad143cc..2112582a0e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictBuiltins.java
    @@ -73,9 +73,9 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotMpAssSubscript.MpAssSubscriptBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyDictCheckNode;
     import com.oracle.graal.python.lib.PyDictSetDefault;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectSetItem;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -91,8 +91,6 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
    @@ -575,19 +573,16 @@ static Object doKeys(VirtualFrame frame, Object cls, Object iterable, Object val
                             @Cached PyObjectGetIter getIter,
                             @Cached CallNode callCtor,
                             @Cached PyObjectSetItem setItem,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 Object dict = callCtor.execute(frame, cls);
                 Object val = value == PNone.NO_VALUE ? PNone.NONE : value;
                 Object it = getIter.execute(frame, inliningTarget, iterable);
                 while (true) {
    -                try {
    -                    Object key = nextNode.execute(frame, it);
    -                    setItem.execute(frame, inliningTarget, dict, key, val);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object key = nextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(key)) {
                         break;
                     }
    +                setItem.execute(frame, inliningTarget, dict, key, val);
                 }
                 return dict;
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    index 42ccc611ef..c7cac844f6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    @@ -82,7 +82,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
    @@ -92,8 +92,6 @@
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
     import com.oracle.graal.python.util.ComparisonOp;
    @@ -298,7 +296,6 @@ static boolean disjoint(VirtualFrame frame, PDictView self, Object other,
          * view comparisons dictates that we need to use iteration to compare them in the general case.
          */
         protected abstract static class ContainedInNode extends PNodeWithContext {
    -        @Child private GetNextNode next;
             @Child private LookupAndCallBinaryNode contains;
             @Child private PyObjectIsTrueNode cast;
             private final boolean checkAll;
    @@ -307,14 +304,6 @@ public ContainedInNode(boolean checkAll) {
                 this.checkAll = checkAll;
             }
     
    -        private GetNextNode getNext() {
    -            if (next == null) {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                next = insert(GetNextNode.create());
    -            }
    -            return next;
    -        }
    -
             private LookupAndCallBinaryNode getContains() {
                 if (contains == null) {
                     CompilerDirectives.transferToInterpreterAndInvalidate();
    @@ -338,18 +327,19 @@ public boolean doIt(VirtualFrame frame, Object self, Object other,
                             @Bind("this") Node inliningTarget,
                             @Cached InlinedLoopConditionProfile loopConditionProfile,
                             @Cached PyObjectGetIter getIterNode,
    -                        @Cached IsBuiltinObjectProfile stopProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 Object iterator = getIterNode.execute(frame, inliningTarget, self);
                 boolean ok = checkAll;
                 int i = 0;
                 try {
                     while (loopConditionProfile.profile(inliningTarget, checkAll && ok || !checkAll && !ok)) {
    -                    Object item = getNext().execute(frame, iterator);
    +                    Object item = nextNode.execute(frame, inliningTarget, iterator);
    +                    if (PyIterNextNode.isExhausted(item)) {
    +                        break;
    +                    }
                         ok = getCast().execute(frame, getContains().executeObject(frame, other, item));
                         i++;
                     }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, stopProfile);
                 } finally {
                     LoopNode.reportLoopCount(this, i < 0 ? Integer.MAX_VALUE : i);
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java
    index 12b75fb4d9..edcf58759d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java
    @@ -65,8 +65,8 @@
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
    @@ -367,19 +367,18 @@ public static Object[] doIt(PSequence iterable,
             @Fallback
             public static Object[] doIt(VirtualFrame frame, Object iterable,
                             @Bind("this") Node inliningTarget,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile stopIterationProfile,
    -                        @Cached PyObjectGetIter getIter) {
    +                        @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode) {
                 Object it = getIter.execute(frame, inliningTarget, iterable);
                 List result = createlist();
                 while (true) {
    -                try {
    -                    result.add(getNextNode.execute(frame, it));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, stopIterationProfile);
    -                    return result.toArray(new Object[result.size()]);
    +                Object next = nextNode.execute(frame, inliningTarget, it);
    +                if (PyIterNextNode.isExhausted(next)) {
    +                    break;
                     }
    +                result.add(next);
                 }
    +            return result.toArray(new Object[result.size()]);
             }
     
             @TruffleBoundary
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    index 9aa0c83888..01aee22ee0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    @@ -41,16 +41,14 @@
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -83,12 +81,16 @@ static Object doEmpty(@SuppressWarnings("unused") PZip self) {
     
             @Specialization(guards = {"!isEmpty(self.getIterators())", "!self.isStrict()"})
             static Object doNext(VirtualFrame frame, PZip self,
    -                        @Shared @Cached GetNextNode next,
    +                        @Bind Node inliningTarget,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Bind PythonLanguage language) {
                 Object[] iterators = self.getIterators();
                 Object[] tupleElements = new Object[iterators.length];
                 for (int i = 0; i < iterators.length; i++) {
    -                tupleElements[i] = next.execute(frame, iterators[i]);
    +                tupleElements[i] = nextNode.execute(frame, inliningTarget, iterators[i]);
    +                if (PyIterNextNode.isExhausted(tupleElements[i])) {
    +                    return iteratorExhausted();
    +                }
                 }
                 return PFactory.createTuple(language, tupleElements);
             }
    @@ -96,34 +98,28 @@ static Object doNext(VirtualFrame frame, PZip self,
             @Specialization(guards = {"!isEmpty(self.getIterators())", "self.isStrict()"})
             static Object doNext(VirtualFrame frame, PZip self,
                             @Bind("this") Node inliningTarget,
    -                        @Shared @Cached GetNextNode next,
    -                        @Cached IsBuiltinObjectProfile classProfile,
    +                        @Shared @Cached PyIterNextNode nextNode,
                             @Bind PythonLanguage language,
                             @Cached PRaiseNode raiseNode) {
                 Object[] iterators = self.getIterators();
                 Object[] tupleElements = new Object[iterators.length];
                 int i = 0;
    -            try {
    -                for (; i < iterators.length; i++) {
    -                    tupleElements[i] = next.execute(frame, iterators[i]);
    -                }
    -                return PFactory.createTuple(language, tupleElements);
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, classProfile);
    -                if (i > 0) {
    -                    throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_SHORTER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i);
    -                }
    -                for (i = 1; i < iterators.length; i++) {
    -                    try {
    -                        next.execute(frame, iterators[i]);
    -                        throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_LONGER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i);
    -                    } catch (PException e2) {
    -                        e2.expectStopIteration(inliningTarget, classProfile);
    +            for (; i < iterators.length; i++) {
    +                tupleElements[i] = nextNode.execute(frame, inliningTarget, iterators[i]);
    +                if (PyIterNextNode.isExhausted(tupleElements[i])) {
    +                    if (i > 0) {
    +                        throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_SHORTER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i);
    +                    }
    +                    for (i = 1; i < iterators.length; i++) {
    +                        Object next = nextNode.execute(frame, inliningTarget, iterators[i]);
    +                        if (!PyIterNextNode.isExhausted(next)) {
    +                            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.ZIP_ARG_D_IS_LONGER_THEN_ARG_SD, i + 1, i == 1 ? " " : "s 1-", i);
    +                        }
                         }
                         return iteratorExhausted();
                     }
    -                throw e;
                 }
    +            return PFactory.createTuple(language, tupleElements);
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    index 961b542bad..fb938b2555 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PTeeDataObject.java
    @@ -46,7 +46,6 @@
     import com.oracle.graal.python.PythonLanguage;
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
    -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -133,17 +132,15 @@ Object getItem(VirtualFrame frame, Node inliningTarget, int i, PyIterNextNode ne
                 }
     
                 running = true;
    -            Object value;
                 try {
    -                value = nextNode.execute(frame, inliningTarget, it);
    +                Object value = nextNode.execute(frame, inliningTarget, it);
    +                if (!PyIterNextNode.isExhausted(value)) {
    +                    values[numread++] = value;
    +                }
    +                return value;
                 } finally {
                     running = false;
                 }
    -            if (PyIterNextNode.isExhausted(value)) {
    -                return TpIterNextBuiltin.iteratorExhausted();
    -            }
    -            values[numread++] = value;
    -            return value;
             }
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    index 80d2393aa7..2a18ff1b45 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TeeBuiltins.java
    @@ -154,7 +154,9 @@ static Object next(VirtualFrame frame, PTee self,
                             @Shared @Cached PyIterNextNode nextNode,
                             @Shared @Cached PRaiseNode raiseNode) {
                 Object value = self.getDataobj().getItem(frame, inliningTarget, self.getIndex(), nextNode, raiseNode);
    -            self.setIndex(self.getIndex() + 1);
    +            if (!PyIterNextNode.isExhausted(value)) {
    +                self.setIndex(self.getIndex() + 1);
    +            }
                 return value;
             }
     
    @@ -165,9 +167,8 @@ static Object nextNext(VirtualFrame frame, PTee self,
                             @Bind PythonLanguage language,
                             @Shared @Cached PRaiseNode raiseNode) {
                 self.setDataObj(self.getDataobj().jumplink(language));
    -            Object value = self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode);
                 self.setIndex(1);
    -            return value;
    +            return self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode);
             }
         }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    index de696e50f1..80f53b32b4 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java
    @@ -70,8 +70,8 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyLongCheckExactNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -785,23 +785,19 @@ static boolean containsSlowNum(PBigRange self, PInt other,
             static boolean containsIterator(VirtualFrame frame, PRange self, Object elem,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @SuppressWarnings("unused") @Exclusive @Cached PyLongCheckExactNode isBuiltin) {
                 Object iter = getIter.execute(frame, inliningTarget, self);
                 while (true) {
    -                try {
    -                    Object item = nextNode.execute(frame, iter);
    -                    if (eqNode.compare(frame, inliningTarget, elem, item)) {
    -                        return true;
    -                    }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    break;
    +                Object item = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(item)) {
    +                    return false;
    +                }
    +                if (eqNode.compare(frame, inliningTarget, elem, item)) {
    +                    return true;
                     }
                 }
    -            return false;
             }
     
             @NeverDefault
    @@ -887,23 +883,20 @@ static Object doLongRange(VirtualFrame frame, PBigRange self, Object elem,
             @Specialization(guards = "!canBeInteger(elem)")
             static Object containsIterator(VirtualFrame frame, PIntRange self, Object elem,
                             @Bind("this") Node inliningTarget,
    -                        @Cached GetNextNode nextNode,
                             @Cached PyObjectGetIter getIter,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Exclusive @Cached PRaiseNode raiseNode) {
                 int idx = 0;
                 Object iter = getIter.execute(frame, inliningTarget, self);
                 while (true) {
    -                try {
    -                    Object item = nextNode.execute(frame, iter);
    -                    if (eqNode.compare(frame, inliningTarget, elem, item)) {
    -                        return idx;
    -                    }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object item = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(item)) {
                         break;
                     }
    +                if (eqNode.compare(frame, inliningTarget, elem, item)) {
    +                    return idx;
    +                }
                     if (idx == SysModuleBuiltins.MAXSIZE) {
                         throw raiseNode.raiseOverflow(inliningTarget);
                     }
    @@ -987,27 +980,23 @@ static boolean isFallback(Object value) {
             static int doGeneric(VirtualFrame frame, PRange self, Object elem,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyObjectRichCompareBool.EqNode eqNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached PRaiseNode raiseNode) {
                 int count = 0;
                 Object iter = getIter.execute(frame, inliningTarget, self);
                 while (true) {
    -                try {
    -                    Object item = nextNode.execute(frame, iter);
    -                    if (eqNode.compare(frame, inliningTarget, elem, item)) {
    -                        if (count == SysModuleBuiltins.MAXSIZE) {
    -                            throw raiseNode.raiseOverflow(inliningTarget);
    -                        }
    -                        count = count + 1;
    +                Object item = nextNode.execute(frame, inliningTarget, iter);
    +                if (PyIterNextNode.isExhausted(item)) {
    +                    return count;
    +                }
    +                if (eqNode.compare(frame, inliningTarget, elem, item)) {
    +                    if (count == SysModuleBuiltins.MAXSIZE) {
    +                        throw raiseNode.raiseOverflow(inliningTarget);
                         }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    break;
    +                    count = count + 1;
                     }
                 }
    -            return count;
             }
         }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    index 3bd6acfa8c..4dadedf20e 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java
    @@ -87,7 +87,7 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSqContains.SqContainsBuiltinNode;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.lib.PyObjectGetStateNode;
     import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode;
    @@ -97,10 +97,8 @@
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.PythonContext;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -434,20 +432,17 @@ static boolean isDisjointGeneric(VirtualFrame frame, Object self, Object other,
                             @Bind("this") Node inliningTarget,
                             @Cached HashingStorageGetItem getHashingStorageItem,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode getNextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 HashingStorage selfStorage = ((PBaseSet) self).getDictStorage();
                 Object iterator = getIter.execute(frame, inliningTarget, other);
                 while (true) {
    -                try {
    -                    Object nextValue = getNextNode.execute(frame, iterator);
    -                    if (getHashingStorageItem.hasKey(frame, inliningTarget, selfStorage, nextValue)) {
    -                        return false;
    -                    }
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object nextValue = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(nextValue)) {
                         return true;
                     }
    +                if (getHashingStorageItem.hasKey(frame, inliningTarget, selfStorage, nextValue)) {
    +                    return false;
    +                }
                 }
             }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java
    index fa4f679213..887b00ea88 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetBuiltins.java
    @@ -60,7 +60,7 @@
     import com.oracle.graal.python.builtins.objects.dict.PDictView;
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PGuards;
    @@ -70,10 +70,8 @@
     import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
     import com.oracle.graal.python.runtime.PythonOptions;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.PSequence;
    @@ -284,17 +282,13 @@ static void doIterable(VirtualFrame frame, PHashingCollection collection, Object
                             @Bind("this") Node inliningTarget,
                             @SuppressWarnings("unused") @Exclusive @Cached GetPythonObjectClassNode getClassNode,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PyIterNextNode nextNode,
                             @Exclusive @Cached HashingStorageSetItem setStorageItem) {
                 HashingStorage curStorage = collection.getDictStorage();
                 Object iterator = getIter.execute(frame, inliningTarget, other);
                 while (true) {
    -                Object key;
    -                try {
    -                    key = nextNode.execute(frame, iterator);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object key = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(key)) {
                         collection.setDictStorage(curStorage);
                         return;
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    index c5348cb4f3..cf3bc9efed 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    @@ -46,14 +46,12 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
     import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageDelItem;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -85,17 +83,15 @@ static PSet setIterable(VirtualFrame frame, Object iterable,
                             @Bind PythonLanguage language,
                             @Exclusive @Cached HashingCollectionNodes.SetItemNode setItemNode,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile) {
    +                        @Cached PyIterNextNode nextNode) {
                 PSet set = PFactory.createSet(language);
                 Object iterator = getIter.execute(frame, inliningTarget, iterable);
                 while (true) {
    -                try {
    -                    setItemNode.execute(frame, inliningTarget, set, nextNode.execute(frame, iterator), PNone.NONE);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         return set;
                     }
    +                setItemNode.execute(frame, inliningTarget, set, next, PNone.NONE);
                 }
             }
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java
    index a9e71272bf..9a976f9a85 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringNodes.java
    @@ -63,7 +63,7 @@
     import com.oracle.graal.python.builtins.objects.ints.PInt;
     import com.oracle.graal.python.builtins.objects.str.StringNodesFactory.IsInternedStringNodeGen;
     import com.oracle.graal.python.builtins.objects.str.StringNodesFactory.StringMaterializeNodeGen;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.HiddenAttr;
    @@ -348,10 +348,8 @@ static TruffleString doGeneric(VirtualFrame frame, TruffleString string, Object
                             @Bind("this") Node inliningTarget,
                             @Exclusive @Cached PRaiseNode raise,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached GetNextNode nextNode,
    -                        @Cached IsBuiltinObjectProfile errorProfile0,
    -                        @Cached IsBuiltinObjectProfile errorProfile1,
    -                        @Cached IsBuiltinObjectProfile errorProfile2,
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Exclusive @Cached CastToTruffleStringNode castToStringNode,
                             @Shared @Cached TruffleStringBuilder.AppendStringNode appendStringNode,
                             @Shared @Cached TruffleStringBuilder.ToStringNode toStringNode) {
    @@ -359,24 +357,21 @@ static TruffleString doGeneric(VirtualFrame frame, TruffleString string, Object
                 try {
                     iterator = getIter.execute(frame, inliningTarget, iterable);
                 } catch (PException e) {
    -                e.expect(inliningTarget, PythonBuiltinClassType.TypeError, errorProfile0);
    +                e.expect(inliningTarget, PythonBuiltinClassType.TypeError, errorProfile);
                     throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_ONLY_JOIN_ITERABLE);
                 }
                 try {
                     TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING);
    -                try {
    -                    appendStringNode.execute(sb, checkItem(inliningTarget, nextNode.execute(frame, iterator), 0, castToStringNode, raise));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile1);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         return T_EMPTY_STRING;
                     }
    +                appendStringNode.execute(sb, checkItem(inliningTarget, next, 0, castToStringNode, raise));
                     int i = 1;
                     while (true) {
                         Object value;
    -                    try {
    -                        value = nextNode.execute(frame, iterator);
    -                    } catch (PException e) {
    -                        e.expectStopIteration(inliningTarget, errorProfile2);
    +                    value = nextNode.execute(frame, inliningTarget, iterator);
    +                    if (PyIterNextNode.isExhausted(value)) {
                             return toStringNode.execute(sb);
                         }
                         appendStringNode.execute(sb, string);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    deleted file mode 100644
    index 8e3ae5b5ba..0000000000
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/GetNextNode.java
    +++ /dev/null
    @@ -1,84 +0,0 @@
    -/*
    - * Copyright (c) 2018, 2025, 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.lib;
    -
    -import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    -import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.truffle.api.dsl.Bind;
    -import com.oracle.truffle.api.dsl.Cached;
    -import com.oracle.truffle.api.dsl.GenerateUncached;
    -import com.oracle.truffle.api.dsl.NeverDefault;
    -import com.oracle.truffle.api.dsl.Specialization;
    -import com.oracle.truffle.api.frame.Frame;
    -import com.oracle.truffle.api.frame.VirtualFrame;
    -import com.oracle.truffle.api.nodes.Node;
    -
    -@GenerateUncached
    -public abstract class GetNextNode extends PNodeWithContext {
    -    public abstract Object execute(Frame frame, Object iterator);
    -
    -    public static Object executeUncached(Object iterator) {
    -        return getUncached().execute(null, iterator);
    -    }
    -
    -    // TODO replace this node with PyIterNext
    -    @Specialization
    -    Object next(VirtualFrame frame, Object iterator,
    -                    @Bind Node inliningTarget,
    -                    @Cached PyIterNextNode iterNextNode,
    -                    @Cached PRaiseNode raiseNode) {
    -        Object result = iterNextNode.execute(frame, inliningTarget, iterator);
    -        if (PyIterNextNode.isExhausted(result)) {
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.StopIteration);
    -        }
    -        return result;
    -    }
    -
    -    @NeverDefault
    -    public static GetNextNode create() {
    -        return GetNextNodeGen.create();
    -    }
    -
    -    public static GetNextNode getUncached() {
    -        return GetNextNodeGen.getUncached();
    -    }
    -}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    index 37fb16cc97..8ec0196713 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyIterNextNode.java
    @@ -48,7 +48,6 @@
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
    -import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.GenerateInline;
     import com.oracle.truffle.api.dsl.GenerateUncached;
    @@ -100,4 +99,8 @@ static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object iterator
         public static PyIterNextNode create() {
             return PyIterNextNodeGen.create();
         }
    +
    +    public static PyIterNextNode getUncached() {
    +        return PyIterNextNodeGen.getUncached();
    +    }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java
    index e6e59a5326..c4943184da 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java
    @@ -52,13 +52,11 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.set.PSet;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.runtime.PythonOptions;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.graal.python.util.ArrayBuilder;
     import com.oracle.truffle.api.dsl.Bind;
    @@ -127,18 +125,16 @@ static Object[] starargs(VirtualFrame frame, Object object,
                         @Bind("this") Node inliningTarget,
                         @Cached PRaiseNode raise,
                         @Cached PyObjectGetIter getIter,
    -                    @Cached GetNextNode nextNode,
    -                    @Cached IsBuiltinObjectProfile errorProfile) {
    +                    @Cached PyIterNextNode nextNode) {
             Object iterator = getIter.execute(frame, inliningTarget, object);
             if (iterator != PNone.NO_VALUE && iterator != PNone.NONE) {
                 ArrayBuilder internalStorage = new ArrayBuilder<>();
                 while (true) {
    -                try {
    -                    internalStorage.add(nextNode.execute(frame, iterator));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (PyIterNextNode.isExhausted(next)) {
                         return internalStorage.toArray(new Object[0]);
                     }
    +                internalStorage.add(next);
                 }
             }
             throw raise.raise(inliningTarget, PythonErrorType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_ITERABLE, object);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java
    index 00e1ebba9e..79bc9c0568 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/ImportStarNode.java
    @@ -35,7 +35,7 @@
     import com.oracle.graal.python.builtins.objects.function.PArguments;
     import com.oracle.graal.python.builtins.objects.mappingproxy.PMappingproxy;
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetAttr;
     import com.oracle.graal.python.lib.PyObjectGetItem;
     import com.oracle.graal.python.lib.PyObjectGetIter;
    @@ -83,15 +83,14 @@ void doImport(VirtualFrame frame, TruffleString moduleName, int level,
                         @Cached GetOrCreateDictNode getDictNode,
                         @Cached PyObjectGetAttr getAttrNode,
                         @Cached PyObjectGetIter getIterNode,
    -                    @Cached GetNextNode getNextNode,
    +                    @Cached PyIterNextNode nextNode,
                         @Cached PyObjectSizeNode sizeNode,
                         @Cached PyObjectGetItem getItemNode,
                         @Cached InlinedConditionProfile javaImport,
                         @Cached CastToTruffleStringNode castToTruffleStringNode,
                         @Cached TruffleString.CodePointLengthNode codePointLengthNode,
                         @Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
    -                    @Cached IsBuiltinObjectProfile isAttributeErrorProfile,
    -                    @Cached IsBuiltinObjectProfile isStopIterationProfile) {
    +                    @Cached IsBuiltinObjectProfile isAttributeErrorProfile) {
             Object importedModule = importModule(frame, moduleName, PArguments.getGlobals(frame), T_IMPORT_ALL, level, importNameNode);
             Object locals = PArguments.getSpecialArgument(frame);
             if (locals == null) {
    @@ -128,14 +127,12 @@ void doImport(VirtualFrame frame, TruffleString moduleName, int level,
                     assert importedModule instanceof PythonModule;
                     Object keysIterator = getIterNode.execute(frame, inliningTarget, getDictNode.execute(inliningTarget, importedModule));
                     while (true) {
    -                    try {
    -                        Object key = getNextNode.execute(frame, keysIterator);
    -                        writeAttributeToLocals(frame, inliningTarget, moduleName, (PythonModule) importedModule, locals, key, false, castToTruffleStringNode, codePointLengthNode,
    -                                        codePointAtIndexNode, getAttrNode, setItemNode, setAttrNode);
    -                    } catch (PException iterException) {
    -                        iterException.expectStopIteration(inliningTarget, isStopIterationProfile);
    +                    Object key = nextNode.execute(frame, inliningTarget, keysIterator);
    +                    if (PyIterNextNode.isExhausted(key)) {
                             break;
                         }
    +                    writeAttributeToLocals(frame, inliningTarget, moduleName, (PythonModule) importedModule, locals, key, false, castToTruffleStringNode, codePointLengthNode,
    +                                    codePointAtIndexNode, getAttrNode, setItemNode, setAttrNode);
                     }
                 }
             }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java
    index 581f455c90..f1f6582840 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackExNode.java
    @@ -47,7 +47,7 @@
     import com.oracle.graal.python.builtins.objects.common.SequenceNodes;
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
     import com.oracle.graal.python.builtins.objects.list.PList;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    @@ -105,9 +105,8 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s
         static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object collection, int countBefore, int countAfter,
                         @Bind("this") Node inliningTarget,
                         @Cached PyObjectGetIter getIter,
    -                    @Cached GetNextNode getNextNode,
    +                    @Cached PyIterNextNode nextNode,
                         @Cached IsBuiltinObjectProfile notIterableProfile,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile,
                         @Cached ListNodes.ConstructListNode constructListNode,
                         @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode,
                         @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode,
    @@ -124,7 +123,7 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll
                 e.expectTypeError(inliningTarget, notIterableProfile);
                 throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection);
             }
    -        stackTop = moveItemsToStack(frame, inliningTarget, iterator, stackTop, 0, countBefore, countBefore + countAfter, getNextNode, stopIterationProfile, raiseNode);
    +        stackTop = moveItemsToStack(frame, inliningTarget, iterator, stackTop, 0, countBefore, countBefore + countAfter, nextNode, raiseNode);
             PList starAndAfter = constructListNode.execute(frame, iterator);
             SequenceStorage storage = starAndAfter.getSequenceStorage();
             int lenAfter = storage.length();
    @@ -143,18 +142,16 @@ static int doUnpackIterable(VirtualFrame frame, int initialStackTop, Object coll
         }
     
         @ExplodeLoop
    -    private static int moveItemsToStack(VirtualFrame frame, Node inliningTarget, Object iterator, int initialStackTop, int offset, int length, int totalLength, GetNextNode getNextNode,
    -                    IsBuiltinObjectProfile stopIterationProfile, PRaiseNode raiseNode) {
    +    private static int moveItemsToStack(VirtualFrame frame, Node inliningTarget, Object iterator, int initialStackTop, int offset, int length, int totalLength, PyIterNextNode nextNode,
    +                    PRaiseNode raiseNode) {
             CompilerAsserts.partialEvaluationConstant(length);
             int stackTop = initialStackTop;
             for (int i = 0; i < length; i++) {
    -            try {
    -                Object item = getNextNode.execute(frame, iterator);
    -                frame.setObject(stackTop--, item);
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, stopIterationProfile);
    +            Object item = nextNode.execute(frame, inliningTarget, iterator);
    +            if (PyIterNextNode.isExhausted(item)) {
                     throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, totalLength, offset + i);
                 }
    +            frame.setObject(stackTop--, item);
             }
             return stackTop;
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java
    index fb9a606338..2a771208a7 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/UnpackSequenceNode.java
    @@ -45,7 +45,7 @@
     
     import com.oracle.graal.python.builtins.objects.common.SequenceNodes;
     import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
    -import com.oracle.graal.python.lib.GetNextNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectGetIter;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    @@ -103,10 +103,8 @@ static int doUnpackSequence(VirtualFrame frame, int initialStackTop, PSequence s
         static int doUnpackIterable(Frame frame, int initialStackTop, Object collection, int count,
                         @Bind("this") Node inliningTarget,
                         @Cached PyObjectGetIter getIter,
    -                    @Cached GetNextNode getNextNode,
    +                    @Cached PyIterNextNode nextNode,
                         @Cached IsBuiltinObjectProfile notIterableProfile,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile1,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile2,
                         @Shared("raise") @Cached PRaiseNode raiseNode) {
             CompilerAsserts.partialEvaluationConstant(count);
             int resultStackTop = initialStackTop + count;
    @@ -119,18 +117,14 @@ static int doUnpackIterable(Frame frame, int initialStackTop, Object collection,
                 throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection);
             }
             for (int i = 0; i < count; i++) {
    -            try {
    -                Object item = getNextNode.execute(frame, iterator);
    -                frame.setObject(stackTop--, item);
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, stopIterationProfile1);
    +            Object item = nextNode.execute(frame, inliningTarget, iterator);
    +            if (PyIterNextNode.isExhausted(item)) {
                     throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, i);
                 }
    +            frame.setObject(stackTop--, item);
             }
    -        try {
    -            getNextNode.execute(frame, iterator);
    -        } catch (PException e) {
    -            e.expectStopIteration(inliningTarget, stopIterationProfile2);
    +        Object next = nextNode.execute(frame, inliningTarget, iterator);
    +        if (PyIterNextNode.isExhausted(next)) {
                 return resultStackTop;
             }
             throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count);
    
    From 273634f5faccc508bf06fef112376b83196d7443 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 27 Feb 2025 10:25:14 +0100
    Subject: [PATCH 109/512] Pass through StopIteration where CPython would
    
    ---
     .../objects/common/SequenceStorageNodes.java  | 25 +++++++++++++------
     .../objects/enumerate/EnumerateBuiltins.java  |  8 ++++--
     .../objects/iterator/PZipBuiltins.java        | 17 +++++++++----
     .../objects/itertools/AccumulateBuiltins.java |  8 ++++--
     .../objects/itertools/PairwiseBuiltins.java   |  9 ++++---
     .../objects/itertools/StarmapBuiltins.java    |  8 ++++--
     .../objects/itertools/TakewhileBuiltins.java  |  8 ++++--
     7 files changed, 60 insertions(+), 23 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    index 19fdc83603..46474b29b9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java
    @@ -86,6 +86,9 @@
     import com.oracle.graal.python.builtins.objects.slice.SliceNodes.ComputeIndices;
     import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.lib.PyIndexCheckNode;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
    @@ -2399,22 +2402,30 @@ SequenceStorage doWithoutStorage(VirtualFrame frame, SequenceStorage left, Objec
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
                             @Exclusive @Cached EnsureCapacityNode ensureCapacityNode,
    -                        @Cached PyIterNextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
    +                        @Cached IsBuiltinObjectProfile stopIterationProfile,
                             @Cached AppendNode appendNode) {
                 SequenceStorage currentStore = left;
                 int lenLeft = currentStore.length();
                 Object it = getIter.execute(frame, inliningTarget, iterable);
    +            TpSlot iterNext = getSlots.execute(inliningTarget, it).tp_iternext();
                 if (len > 0) {
                     ensureCapacityNode.execute(inliningTarget, left, lengthResult(lenLeft, len));
                 }
    -            while (true) {
    -                Object value;
    -                value = nextNode.execute(frame, inliningTarget, it);
    -                if (PyIterNextNode.isExhausted(value)) {
    -                    return currentStore;
    +            try {
    +                while (true) {
    +                    Object value;
    +                    value = callIterNext.execute(frame, inliningTarget, iterNext, it);
    +                    if (PyIterNextNode.isExhausted(value)) {
    +                        break;
    +                    }
    +                    currentStore = appendNode.execute(inliningTarget, currentStore, value, genNodeProvider);
                     }
    -                currentStore = appendNode.execute(inliningTarget, currentStore, value, genNodeProvider);
    +            } catch (PException e) {
    +                e.expectStopIteration(inliningTarget, stopIterationProfile);
                 }
    +            return currentStore;
             }
     
             private SequenceStorage generalizeStore(SequenceStorage storage, Object value) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    index afe48317ac..737f461054 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/enumerate/EnumerateBuiltins.java
    @@ -39,6 +39,8 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -73,9 +75,11 @@ static Object doNext(VirtualFrame frame, PEnumerate self,
                             @Bind("this") Node inliningTarget,
                             @Bind PythonLanguage language,
                             @Cached InlinedConditionProfile bigIntIndexProfile,
    -                        @Cached PyIterNextNode next) {
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext) {
                 Object index = self.getAndIncrementIndex(inliningTarget, language, bigIntIndexProfile);
    -            Object nextValue = next.execute(frame, inliningTarget, self.getDecoratedIterator());
    +            Object it = self.getDecoratedIterator();
    +            Object nextValue = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, it).tp_iternext(), it);
                 if (PyIterNextNode.isExhausted(nextValue)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    index 01aee22ee0..600db14d5d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/PZipBuiltins.java
    @@ -40,6 +40,8 @@
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    @@ -52,7 +54,6 @@
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    -import com.oracle.truffle.api.dsl.Cached.Shared;
     import com.oracle.truffle.api.dsl.GenerateNodeFactory;
     import com.oracle.truffle.api.dsl.NodeFactory;
     import com.oracle.truffle.api.dsl.Specialization;
    @@ -82,12 +83,18 @@ static Object doEmpty(@SuppressWarnings("unused") PZip self) {
             @Specialization(guards = {"!isEmpty(self.getIterators())", "!self.isStrict()"})
             static Object doNext(VirtualFrame frame, PZip self,
                             @Bind Node inliningTarget,
    -                        @Shared @Cached PyIterNextNode nextNode,
    -                        @Bind PythonLanguage language) {
    +                        @Bind PythonLanguage language,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext) {
                 Object[] iterators = self.getIterators();
                 Object[] tupleElements = new Object[iterators.length];
                 for (int i = 0; i < iterators.length; i++) {
    -                tupleElements[i] = nextNode.execute(frame, inliningTarget, iterators[i]);
    +                Object it = iterators[i];
    +                /*
    +                 * Not using PyIterNext because the non-strict version should pass through existing
    +                 * StopIteration
    +                 */
    +                tupleElements[i] = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, it).tp_iternext(), it);
                     if (PyIterNextNode.isExhausted(tupleElements[i])) {
                         return iteratorExhausted();
                     }
    @@ -98,8 +105,8 @@ static Object doNext(VirtualFrame frame, PZip self,
             @Specialization(guards = {"!isEmpty(self.getIterators())", "self.isStrict()"})
             static Object doNext(VirtualFrame frame, PZip self,
                             @Bind("this") Node inliningTarget,
    -                        @Shared @Cached PyIterNextNode nextNode,
                             @Bind PythonLanguage language,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PRaiseNode raiseNode) {
                 Object[] iterators = self.getIterators();
                 Object[] tupleElements = new Object[iterators.length];
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    index 394fd0a720..46c283c7b0 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java
    @@ -56,6 +56,8 @@
     import com.oracle.graal.python.builtins.objects.list.PList;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyNumberAddNode;
    @@ -101,7 +103,8 @@ public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PAccumulate self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached PyIterNextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached PyNumberAddNode addNode,
                             @Cached CallNode callNode,
                             @Cached InlinedBranchProfile hasInitialProfile,
    @@ -113,7 +116,8 @@ static Object next(VirtualFrame frame, PAccumulate self,
                     self.setInitial(null);
                     return self.getTotal();
                 }
    -            Object value = nextNode.execute(frame, inliningTarget, self.getIterable());
    +            Object it = self.getIterable();
    +            Object value = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, it).tp_iternext(), it);
                 if (PyIterNextNode.isExhausted(value)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    index 12f0abfd31..9bbbc5c7f1 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/PairwiseBuiltins.java
    @@ -49,6 +49,8 @@
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
    @@ -89,7 +91,8 @@ public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization(guards = "self.getIterable() != null")
             static Object next(VirtualFrame frame, PPairwise self,
                             @Bind("this") Node inliningTarget,
    -                        @Cached PyIterNextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached InlinedBranchProfile exceptionProfile,
                             @Bind PythonLanguage language) {
                 Object item;
    @@ -97,7 +100,7 @@ static Object next(VirtualFrame frame, PPairwise self,
                 Object iterable = self.getIterable();
                 try {
                     if (self.getOld() == null) {
    -                    old = nextNode.execute(frame, inliningTarget, iterable);
    +                    old = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, iterable).tp_iternext(), iterable);
                         if (PyIterNextNode.isExhausted(old)) {
                             self.setOld(null);
                             self.setIterable(null);
    @@ -110,7 +113,7 @@ static Object next(VirtualFrame frame, PPairwise self,
                             return iteratorExhausted();
                         }
                     }
    -                item = nextNode.execute(frame, inliningTarget, iterable);
    +                item = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, iterable).tp_iternext(), iterable);
                     if (PyIterNextNode.isExhausted(item)) {
                         self.setOld(null);
                         self.setIterable(null);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    index 0e9d094cde..9beb731da3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/StarmapBuiltins.java
    @@ -54,6 +54,8 @@
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
    @@ -95,10 +97,12 @@ public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object nextPos(VirtualFrame frame, PStarmap self,
                             @Bind Node inliningTarget,
    -                        @Cached PyIterNextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached CallNode callNode,
                             @Cached ExecutePositionalStarargsNode getArgsNode) {
    -            Object obj = nextNode.execute(frame, inliningTarget, self.getIterable());
    +            Object it = self.getIterable();
    +            Object obj = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, it).tp_iternext(), it);
                 if (PyIterNextNode.isExhausted(obj)) {
                     return iteratorExhausted();
                 }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    index 72a1fcf038..e29472eae6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/TakewhileBuiltins.java
    @@ -53,6 +53,8 @@
     import com.oracle.graal.python.builtins.PythonBuiltins;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
    +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
    +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
    @@ -95,11 +97,13 @@ public abstract static class NextNode extends TpIterNextBuiltin {
             @Specialization
             static Object next(VirtualFrame frame, PTakewhile self,
                             @Bind Node inliningTarget,
    -                        @Cached PyIterNextNode nextNode,
    +                        @Cached GetObjectSlotsNode getSlots,
    +                        @Cached CallSlotTpIterNextNode callIterNext,
                             @Cached CallNode callNode,
                             @Cached PyObjectIsTrueNode isTrue,
                             @Bind PythonLanguage language) {
    -            Object value = nextNode.execute(frame, inliningTarget, self.getIterable());
    +            Object it = self.getIterable();
    +            Object value = callIterNext.execute(frame, inliningTarget, getSlots.execute(inliningTarget, it).tp_iternext(), it);
                 if (PyIterNextNode.isExhausted(value)) {
                     return iteratorExhausted();
                 }
    
    From 4b3a49f04e8b129d4b225adeb58ddee5c79adbde Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 27 Feb 2025 11:00:45 +0100
    Subject: [PATCH 110/512] Clean up remains of old Contains slot
    
    ---
     .../objects/dict/DictViewBuiltins.java        | 28 ++++---------------
     .../objects/type/SpecialMethodSlot.java       |  8 ------
     2 files changed, 5 insertions(+), 31 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    index c7cac844f6..14bff48850 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java
    @@ -77,7 +77,6 @@
     import com.oracle.graal.python.builtins.objects.set.PSet;
     import com.oracle.graal.python.builtins.objects.set.SetNodes;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode;
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode;
    @@ -87,15 +86,14 @@
     import com.oracle.graal.python.lib.PyObjectIsTrueNode;
     import com.oracle.graal.python.lib.PyObjectRichCompareBool;
     import com.oracle.graal.python.lib.PyObjectSizeNode;
    +import com.oracle.graal.python.lib.PySequenceContainsNode;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
     import com.oracle.graal.python.util.ComparisonOp;
    -import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.Cached.Exclusive;
    @@ -296,30 +294,12 @@ static boolean disjoint(VirtualFrame frame, PDictView self, Object other,
          * view comparisons dictates that we need to use iteration to compare them in the general case.
          */
         protected abstract static class ContainedInNode extends PNodeWithContext {
    -        @Child private LookupAndCallBinaryNode contains;
    -        @Child private PyObjectIsTrueNode cast;
             private final boolean checkAll;
     
             public ContainedInNode(boolean checkAll) {
                 this.checkAll = checkAll;
             }
     
    -        private LookupAndCallBinaryNode getContains() {
    -            if (contains == null) {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                contains = insert(LookupAndCallBinaryNode.create(SpecialMethodSlot.Contains));
    -            }
    -            return contains;
    -        }
    -
    -        private PyObjectIsTrueNode getCast() {
    -            if (cast == null) {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                cast = insert(PyObjectIsTrueNode.create());
    -            }
    -            return cast;
    -        }
    -
             public abstract boolean execute(VirtualFrame frame, Object self, Object other);
     
             @Specialization
    @@ -327,7 +307,9 @@ public boolean doIt(VirtualFrame frame, Object self, Object other,
                             @Bind("this") Node inliningTarget,
                             @Cached InlinedLoopConditionProfile loopConditionProfile,
                             @Cached PyObjectGetIter getIterNode,
    -                        @Cached PyIterNextNode nextNode) {
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached PySequenceContainsNode containsNode,
    +                        @Cached PyObjectIsTrueNode isTrueNode) {
                 Object iterator = getIterNode.execute(frame, inliningTarget, self);
                 boolean ok = checkAll;
                 int i = 0;
    @@ -337,7 +319,7 @@ public boolean doIt(VirtualFrame frame, Object self, Object other,
                         if (PyIterNextNode.isExhausted(item)) {
                             break;
                         }
    -                    ok = getCast().execute(frame, getContains().executeObject(frame, other, item));
    +                    ok = isTrueNode.execute(frame, containsNode.execute(frame, inliningTarget, other, item));
                         i++;
                     }
                 } finally {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    index 0a8eeb2797..f5a1204d42 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    @@ -45,7 +45,6 @@
     import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.AM_AWAIT;
     import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.NB_INPLACE_ADD;
     import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.NB_INPLACE_MULTIPLY;
    -import static com.oracle.graal.python.builtins.objects.type.MethodsFlags.SQ_CONTAINS;
     import static com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot.Flags.NO_BUILTIN_DESCRIPTORS;
     import static com.oracle.graal.python.nodes.HiddenAttr.METHODS_FLAGS;
     import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DICT__;
    @@ -56,7 +55,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AWAIT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BYTES__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ENTER__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EQ__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EXIT__;
    @@ -171,7 +169,6 @@ public enum SpecialMethodSlot {
         Enter(T___ENTER__),
     
         LengthHint(T___LENGTH_HINT__),
    -    Contains(T___CONTAINS__, SQ_CONTAINS),
         Hash(T___HASH__),
         Str(T___STR__),
         Repr(T___REPR__),
    @@ -797,11 +794,6 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin
                         return Le;
                     }
                     break;
    -            case 'c' * 26 + 'o':    // co
    -                if (eqNode.execute(name, T___CONTAINS__, TS_ENCODING)) {
    -                    return Contains;
    -                }
    -                break;
                 case 'h' * 26 + 'a':    // ha
                     if (eqNode.execute(name, T___HASH__, TS_ENCODING)) {
                         return Hash;
    
    From 7c6f09c83d392f963ddbe543349a8d9220e2d5fd Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 27 Feb 2025 15:50:43 +0100
    Subject: [PATCH 111/512] Refactor sum
    
    ---
     .../builtins/modules/BuiltinFunctions.java    | 255 +++++++++++-------
     .../graal/python/lib/PyNumberAddNode.java     |   5 -
     2 files changed, 159 insertions(+), 101 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    index 5ee5f10e62..d32becf29c 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    @@ -148,6 +148,9 @@
     import com.oracle.graal.python.builtins.objects.function.PFunction;
     import com.oracle.graal.python.builtins.objects.function.PKeyword;
     import com.oracle.graal.python.builtins.objects.ints.PInt;
    +import com.oracle.graal.python.builtins.objects.iterator.PDoubleSequenceIterator;
    +import com.oracle.graal.python.builtins.objects.iterator.PIntegerSequenceIterator;
    +import com.oracle.graal.python.builtins.objects.iterator.PLongSequenceIterator;
     import com.oracle.graal.python.builtins.objects.list.ListBuiltins;
     import com.oracle.graal.python.builtins.objects.list.ListBuiltins.ListSortNode;
     import com.oracle.graal.python.builtins.objects.list.PList;
    @@ -256,6 +259,7 @@
     import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage;
     import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
     import com.oracle.graal.python.util.CharsetMapping;
    +import com.oracle.graal.python.util.OverflowException;
     import com.oracle.graal.python.util.PythonUtils;
     import com.oracle.graal.python.util.Supplier;
     import com.oracle.truffle.api.CallTarget;
    @@ -2117,112 +2121,171 @@ Object ternary(VirtualFrame frame, Object x, Object y, Object z,
         @GenerateNodeFactory
         public abstract static class SumFunctionNode extends PythonBuiltinNode {
     
    -        @Child private LookupAndCallUnaryNode next = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next);
    -
    -        public static boolean isIntOrNone(Object o) {
    -            return o instanceof Integer || PGuards.isNoValue(o);
    -        }
    -
    -        @Specialization(guards = "isIntOrNone(startIn)", rewriteOn = UnexpectedResultException.class)
    -        int sumInt(VirtualFrame frame, Object arg1, Object startIn,
    -                        @Bind("this") Node inliningTarget,
    -                        @Shared @Cached InlinedConditionProfile hasStart,
    -                        @Shared @Cached PyNumberAddNode addNode,
    -                        @Shared @Cached IsBuiltinObjectProfile errorProfile,
    -                        @Shared("getIter") @Cached PyObjectGetIter getIter) throws UnexpectedResultException {
    -            int start = hasStart.profile(inliningTarget, startIn instanceof Integer) ? (Integer) startIn : 0;
    -            return sumIntInternal(frame, inliningTarget, arg1, start, addNode, getIter, errorProfile);
    -        }
    -
    -        private int sumIntInternal(VirtualFrame frame, Node inliningTarget, Object arg1, int start, PyNumberAddNode add, PyObjectGetIter getIter,
    -                        IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -            Object iterator = getIter.execute(frame, inliningTarget, arg1);
    -            int value = start;
    -            while (true) {
    -                int nextValue;
    -                try {
    -                    nextValue = PGuards.expectInteger(next.executeObject(frame, iterator));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    return value;
    -                } catch (UnexpectedResultException e) {
    -                    Object newValue = add.execute(frame, inliningTarget, value, e.getResult());
    -                    throw new UnexpectedResultException(iterateGeneric(frame, inliningTarget, iterator, newValue, add, errorProfile));
    +        @Specialization
    +        Object sum(VirtualFrame frame, Object iterable, Object start,
    +                        @Bind Node inliningTarget,
    +                        @Cached InlinedConditionProfile defaultStart,
    +                        @Cached PRaiseNode raiseNode,
    +                        @Cached PyObjectGetIter getIter,
    +                        @Cached SumIteratorNode sumIteratorNode) {
    +            if (defaultStart.profile(inliningTarget, start == NO_VALUE)) {
    +                start = 0;
    +            } else if (PGuards.isString(start)) {
    +                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_STRINGS);
    +            } else if (start instanceof PBytes) {
    +                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTES);
    +            } else if (start instanceof PByteArray) {
    +                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTEARRAY);
    +            }
    +            Object iterator = getIter.execute(frame, inliningTarget, iterable);
    +            return sumIteratorNode.execute(frame, inliningTarget, iterator, start);
    +        }
    +
    +        @GenerateInline
    +        @GenerateCached(false)
    +        abstract static class SumIteratorNode extends Node {
    +            public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object iterator, Object start);
    +
    +            @Specialization
    +            static Object sumIntIterator(VirtualFrame frame, Node inliningTarget, PIntegerSequenceIterator iterator, int start,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfileGeneric,
    +                            @Shared @Cached InlinedBranchProfile overflowProfile,
    +                            @Shared @Cached PyNumberAddNode addNode,
    +                            @Shared @Cached InlinedConditionProfile resultFitsInInt) {
    +                long longResult = start;
    +                while (loopProfilePrimitive.profile(inliningTarget, iterator.hasNext())) {
    +                    long next = iterator.next();
    +                    try {
    +                        longResult = PythonUtils.addExact(longResult, next);
    +                    } catch (OverflowException e) {
    +                        overflowProfile.enter(inliningTarget);
    +                        Object objectResult = addNode.execute(frame, inliningTarget, longResult, next);
    +                        while (loopProfileGeneric.profile(inliningTarget, iterator.hasNext())) {
    +                            objectResult = addNode.execute(frame, inliningTarget, objectResult, iterator.next());
    +                        }
    +                        return objectResult;
    +                    }
                     }
    -                try {
    -                    value = add.executeInt(frame, inliningTarget, value, nextValue);
    -                } catch (UnexpectedResultException e) {
    -                    throw new UnexpectedResultException(iterateGeneric(frame, inliningTarget, iterator, e.getResult(), add, errorProfile));
    +                return maybeInt(inliningTarget, resultFitsInInt, longResult);
    +            }
    +
    +            @Specialization
    +            static Object sumLongIterator(VirtualFrame frame, Node inliningTarget, PLongSequenceIterator iterator, int start,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfileGeneric,
    +                            @Shared @Cached InlinedBranchProfile overflowProfile,
    +                            @Shared @Cached PyNumberAddNode addNode,
    +                            @Shared @Cached InlinedConditionProfile resultFitsInInt) {
    +                long longResult = start;
    +                while (loopProfilePrimitive.profile(inliningTarget, iterator.hasNext())) {
    +                    long next = iterator.next();
    +                    try {
    +                        longResult = PythonUtils.addExact(longResult, next);
    +                    } catch (OverflowException e) {
    +                        overflowProfile.enter(inliningTarget);
    +                        Object objectResult = addNode.execute(frame, inliningTarget, longResult, next);
    +                        while (loopProfileGeneric.profile(inliningTarget, iterator.hasNext())) {
    +                            objectResult = addNode.execute(frame, inliningTarget, objectResult, iterator.next());
    +                        }
    +                        return objectResult;
    +                    }
                     }
    +                return maybeInt(inliningTarget, resultFitsInInt, longResult);
                 }
    -        }
     
    -        @Specialization(rewriteOn = UnexpectedResultException.class)
    -        double sumDoubleDouble(VirtualFrame frame, Object arg1, double start,
    -                        @Bind("this") Node inliningTarget,
    -                        @Shared @Cached PyNumberAddNode addNode,
    -                        @Shared @Cached IsBuiltinObjectProfile errorProfile,
    -                        // dummy inline profile, so it can be @Shared, to optimize generated code:
    -                        @SuppressWarnings("unused") @Shared @Cached InlinedConditionProfile hasStart,
    -                        @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                        // dummy raiseNode, so it can be @Shared, to optimize generated code:
    -                        @SuppressWarnings("unused") @Shared @Cached PRaiseNode raiseNode) throws UnexpectedResultException {
    -            return sumDoubleInternal(frame, inliningTarget, arg1, start, addNode, getIter, errorProfile);
    -        }
    -
    -        private double sumDoubleInternal(VirtualFrame frame, Node inliningTarget, Object arg1, double start, PyNumberAddNode add, PyObjectGetIter getIter,
    -                        IsBuiltinObjectProfile errorProfile) throws UnexpectedResultException {
    -            Object iterator = getIter.execute(frame, inliningTarget, arg1);
    -            double value = start;
    -            while (true) {
    -                double nextValue;
    -                try {
    -                    nextValue = PGuards.expectDouble(next.executeObject(frame, iterator));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    return value;
    -                } catch (UnexpectedResultException e) {
    -                    Object newValue = add.execute(frame, inliningTarget, value, e.getResult());
    -                    throw new UnexpectedResultException(iterateGeneric(frame, inliningTarget, iterator, newValue, add, errorProfile));
    -                }
    -                try {
    -                    value = add.executeDouble(frame, inliningTarget, value, nextValue);
    -                } catch (UnexpectedResultException e) {
    -                    throw new UnexpectedResultException(iterateGeneric(frame, inliningTarget, iterator, e.getResult(), add, errorProfile));
    +            @Specialization
    +            static Object sumDoubleIterator(Node inliningTarget, PDoubleSequenceIterator iterator, double start,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive) {
    +                double result = start;
    +                while (loopProfilePrimitive.profile(inliningTarget, iterator.hasNext())) {
    +                    result += iterator.next();
                     }
    +                return result;
                 }
    -        }
     
    -        @Specialization(replaces = {"sumInt", "sumDoubleDouble"})
    -        Object sum(VirtualFrame frame, Object arg1, Object start,
    -                        @Bind("this") Node inliningTarget,
    -                        @Shared @Cached PyNumberAddNode addNode,
    -                        @Shared @Cached IsBuiltinObjectProfile errorProfile,
    -                        @Shared("getIter") @Cached PyObjectGetIter getIter,
    -                        @Shared @Cached InlinedConditionProfile hasStart,
    -                        @Shared @Cached PRaiseNode raiseNode) {
    -            if (PGuards.isString(start)) {
    -                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_STRINGS);
    -            } else if (start instanceof PBytes) {
    -                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTES);
    -            } else if (start instanceof PByteArray) {
    -                throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANT_SUM_BYTEARRAY);
    +            @Specialization
    +            static Object sumDoubleIteratorIntStart(Node inliningTarget, PDoubleSequenceIterator iterator, int start,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive) {
    +                /*
    +                 * Need to make sure we keep start as int if the iterator was empty
    +                 */
    +                if (!iterator.hasNext()) {
    +                    return start;
    +                }
    +                return sumDoubleIterator(inliningTarget, iterator, start, loopProfilePrimitive);
    +            }
    +
    +            @Fallback
    +            static Object sumGeneric(VirtualFrame frame, Node inliningTarget, Object iterator, Object start,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive,
    +                            @Shared @Cached InlinedLoopConditionProfile loopProfileGeneric,
    +                            @Cached PyIterNextNode nextNode,
    +                            @Shared @Cached PyNumberAddNode addNode,
    +                            @Shared @Cached InlinedConditionProfile resultFitsInInt,
    +                            @Exclusive @Cached InlinedBranchProfile seenInt,
    +                            @Exclusive @Cached InlinedBranchProfile seenDouble,
    +                            @Exclusive @Cached InlinedBranchProfile seenObject) {
    +                /*
    +                 * Peel the first iteration to see what's the type.
    +                 */
    +                Object next = nextNode.execute(frame, inliningTarget, iterator);
    +                if (!PyIterNextNode.isExhausted(next)) {
    +                    Object acc = addNode.execute(frame, inliningTarget, start, next);
    +                    /*
    +                     * We try to process integers/longs/doubles as long as we can. Then we always
    +                     * fall through to the generic path. `next` and `acc` are always properly set so
    +                     * that the generic path can check if there are remaining items and resume if
    +                     * necessary.
    +                     */
    +                    if (acc instanceof Integer || acc instanceof Long) {
    +                        seenInt.enter(inliningTarget);
    +                        long longAcc = acc instanceof Integer ? (int) acc : (long) acc;
    +                        while (loopProfilePrimitive.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator)))) {
    +                            try {
    +                                if (next instanceof Integer nextInt) {
    +                                    longAcc = PythonUtils.addExact(longAcc, nextInt);
    +                                } else if (next instanceof Long nextLong) {
    +                                    longAcc = PythonUtils.addExact(longAcc, nextLong);
    +                                } else {
    +                                    break;
    +                                }
    +                            } catch (OverflowException e) {
    +                                break;
    +                            }
    +                        }
    +                        acc = maybeInt(inliningTarget, resultFitsInInt, longAcc);
    +                    } else if (acc instanceof Double doubleAcc) {
    +                        seenDouble.enter(inliningTarget);
    +                        while (loopProfilePrimitive.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator)))) {
    +                            if (next instanceof Double nextDouble) {
    +                                doubleAcc += nextDouble;
    +                            } else {
    +                                break;
    +                            }
    +                        }
    +                        acc = doubleAcc;
    +                    } else {
    +                        next = nextNode.execute(frame, inliningTarget, iterator);
    +                    }
    +                    if (!PyIterNextNode.isExhausted(next)) {
    +                        seenObject.enter(inliningTarget);
    +                        do {
    +                            acc = addNode.execute(frame, inliningTarget, acc, next);
    +                        } while (loopProfileGeneric.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator))));
    +                    }
    +                    return acc;
    +                } else {
    +                    return start;
    +                }
                 }
    -            Object iterator = getIter.execute(frame, inliningTarget, arg1);
    -            return iterateGeneric(frame, inliningTarget, iterator, hasStart.profile(inliningTarget, start != NO_VALUE) ? start : 0, addNode, errorProfile);
    -        }
     
    -        private Object iterateGeneric(VirtualFrame frame, Node inliningTarget, Object iterator, Object start, PyNumberAddNode add, IsBuiltinObjectProfile errorProfile) {
    -            Object value = start;
    -            while (true) {
    -                Object nextValue;
    -                try {
    -                    nextValue = next.executeObject(frame, iterator);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    return value;
    +            private static long maybeInt(Node inliningTarget, InlinedConditionProfile resultFitsInInt, long result) {
    +                if (resultFitsInInt.profile(inliningTarget, PInt.isIntRange(result))) {
    +                    return (int) result;
    +                } else {
    +                    return result;
                     }
    -                value = add.execute(frame, inliningTarget, value, nextValue);
                 }
             }
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java
    index d46dc198c3..71639455f3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java
    @@ -73,7 +73,6 @@
     import com.oracle.truffle.api.dsl.TypeSystemReference;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    -import com.oracle.truffle.api.nodes.UnexpectedResultException;
     import com.oracle.truffle.api.profiles.InlinedBranchProfile;
     import com.oracle.truffle.api.strings.TruffleString;
     
    @@ -141,10 +140,6 @@ public final Object executeCached(VirtualFrame frame, Object v, Object w) {
             return execute(frame, this, v, w);
         }
     
    -    public abstract int executeInt(VirtualFrame frame, Node inliningTarget, int left, int right) throws UnexpectedResultException;
    -
    -    public abstract double executeDouble(VirtualFrame frame, Node inliningTarget, double left, double right) throws UnexpectedResultException;
    -
         @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"})
         static PList doPList(Node inliningTarget, PList left, PList right,
                         @Shared @Cached SequenceStorageNodes.ConcatListOrTupleNode concatNode,
    
    From 2d07bc42c6a3b97e1bae2d1728530fab2127379c Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 27 Feb 2025 16:15:33 +0100
    Subject: [PATCH 112/512] Remove old Next slot
    
    ---
     .../builtins/PythonBuiltinClassType.java      |  2 +-
     .../builtins/modules/MathModuleBuiltins.java  | 65 ++++++---------
     .../objects/PythonAbstractObject.java         | 11 +--
     .../objects/type/SpecialMethodSlot.java       |  5 --
     .../python/lib/PySequenceIterSearchNode.java  | 83 ++++++++-----------
     5 files changed, 61 insertions(+), 105 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    index 15abaf44ef..0ed5eaa90b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java
    @@ -866,7 +866,7 @@ public final Shape getInstanceShape(PythonLanguage lang) {
             UnicodeDecodeError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
             UnicodeTranslateError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
             OSError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str};
    -        PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Next, SpecialMethodSlot.LengthHint};
    +        PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.LengthHint};
     
             // These slots actually contain context independent values, but they are initialized in
             // StructSequence to artificial PBuiltinFunctions with artificial builtin node factories,
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java
    index 33cde1d47e..8bc9c5ce10 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java
    @@ -50,8 +50,8 @@
     import com.oracle.graal.python.builtins.objects.ints.IntBuiltins;
     import com.oracle.graal.python.builtins.objects.ints.PInt;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
     import com.oracle.graal.python.lib.PyFloatAsDoubleNode;
    +import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode;
     import com.oracle.graal.python.lib.PyLongFromDoubleNode;
     import com.oracle.graal.python.lib.PyNumberAsSizeNode;
    @@ -76,12 +76,10 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryClinicBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
    -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.truffle.PythonIntegerAndFloatTypes;
     import com.oracle.graal.python.nodes.util.CastToJavaLongLossyNode;
     import com.oracle.graal.python.nodes.util.NarrowBigIntegerNode;
    -import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.graal.python.util.OverflowException;
     import com.oracle.truffle.api.CompilerDirectives;
    @@ -866,37 +864,28 @@ public abstract static class FsumNode extends PythonUnaryBuiltinNode {
             static double doIt(VirtualFrame frame, Object iterable,
                             @Bind("this") Node inliningTarget,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached("create(Next)") LookupAndCallUnaryNode callNextNode,
    +                        @Cached PyIterNextNode nextNode,
                             @Cached PyFloatAsDoubleNode asDoubleNode,
    -                        @Cached IsBuiltinObjectProfile stopProfile,
    +                        @Cached InlinedLoopConditionProfile loopProfile,
                             @Cached PRaiseNode raiseNode) {
    +            /*
    +             * This implementation is taken from CPython. The performance is not good. Should be
    +             * faster. It can be easily replace with much simpler code based on BigDecimal:
    +             *
    +             * BigDecimal result = BigDecimal.ZERO;
    +             *
    +             * in cycle just: result = result.add(BigDecimal.valueof(x); ... The current
    +             * implementation is little bit faster. The testFSum in test_math.py takes in different
    +             * implementations: CPython ~0.6s CurrentImpl: ~14.3s Using BigDecimal: ~15.1
    +             */
                 Object iterator = getIter.execute(frame, inliningTarget, iterable);
    -            return fsum(frame, iterator, callNextNode, asDoubleNode, inliningTarget, stopProfile, raiseNode);
    -        }
    -
    -        /*
    -         * This implementation is taken from CPython. The performance is not good. Should be faster.
    -         * It can be easily replace with much simpler code based on BigDecimal:
    -         *
    -         * BigDecimal result = BigDecimal.ZERO;
    -         *
    -         * in cycle just: result = result.add(BigDecimal.valueof(x); ... The current implementation
    -         * is little bit faster. The testFSum in test_math.py takes in different implementations:
    -         * CPython ~0.6s CurrentImpl: ~14.3s Using BigDecimal: ~15.1
    -         */
    -        private static double fsum(VirtualFrame frame, Object iterator, LookupAndCallUnaryNode next,
    -                        PyFloatAsDoubleNode asDoubleNode, Node inliningTarget, IsBuiltinObjectProfile stopProfile, PRaiseNode raiseNode) {
                 double x, y, t, hi, lo = 0, yr, inf_sum = 0, special_sum = 0, sum;
                 double xsave;
                 int i, j, n = 0, arayLength = 32;
                 double[] p = new double[arayLength];
    -            while (true) {
    -                try {
    -                    x = asDoubleNode.execute(frame, inliningTarget, next.executeObject(frame, iterator));
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, stopProfile);
    -                    break;
    -                }
    +            Object next;
    +            while (loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator)))) {
    +                x = asDoubleNode.execute(frame, inliningTarget, next);
                     xsave = x;
                     for (i = j = 0; j < n; j++) { /* for y in partials */
                         y = p[j];
    @@ -2467,28 +2456,22 @@ private static void raiseIfNegative(Node inliningTarget, boolean condition, PRai
         @GenerateNodeFactory
         public abstract static class ProdNode extends PythonBuiltinNode {
     
    -        @Child private LookupAndCallUnaryNode callNextNode = LookupAndCallUnaryNode.create(SpecialMethodSlot.Next);
    -
             @Specialization
             public Object doGeneric(VirtualFrame frame, Object iterable, Object startIn,
                             @Bind("this") Node inliningTarget,
    -                        @Cached IsBuiltinObjectProfile errorProfile,
                             @Cached InlinedConditionProfile startIsNoValueProfile,
                             @Cached PyObjectGetIter getIter,
    -                        @Cached PyNumberMultiplyNode multiplyNode) {
    +                        @Cached PyIterNextNode nextNode,
    +                        @Cached PyNumberMultiplyNode multiplyNode,
    +                        @Cached InlinedLoopConditionProfile loopProfile) {
                 Object start = startIsNoValueProfile.profile(inliningTarget, PGuards.isNoValue(startIn)) ? 1 : startIn;
                 Object iterator = getIter.execute(frame, inliningTarget, iterable);
    -            Object value = start;
    -            while (true) {
    -                Object nextValue;
    -                try {
    -                    nextValue = callNextNode.executeObject(frame, iterator);
    -                } catch (PException e) {
    -                    e.expectStopIteration(inliningTarget, errorProfile);
    -                    return value;
    -                }
    -                value = multiplyNode.execute(frame, inliningTarget, value, nextValue);
    +            Object acc = start;
    +            Object next;
    +            while (loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator)))) {
    +                acc = multiplyNode.execute(frame, inliningTarget, acc, next);
                 }
    +            return acc;
             }
         }
     
    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 e766a77ddf..1bb8a1bf74 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
    @@ -97,13 +97,13 @@
     import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
     import com.oracle.graal.python.builtins.objects.type.PythonClass;
     import com.oracle.graal.python.builtins.objects.type.PythonManagedClass;
    -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
     import com.oracle.graal.python.builtins.objects.type.TpSlots;
     import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes;
     import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetMroNode;
     import com.oracle.graal.python.lib.PyCallableCheckNode;
    +import com.oracle.graal.python.lib.PyIterCheckNode;
     import com.oracle.graal.python.lib.PyIterNextNode;
     import com.oracle.graal.python.lib.PyMappingCheckNode;
     import com.oracle.graal.python.lib.PyObjectGetItem;
    @@ -125,7 +125,6 @@
     import com.oracle.graal.python.nodes.argument.keywords.NonMappingException;
     import com.oracle.graal.python.nodes.argument.keywords.SameDictKeyException;
     import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
    -import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
     import com.oracle.graal.python.nodes.attributes.LookupInheritedAttributeNode;
     import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
     import com.oracle.graal.python.nodes.call.CallNode;
    @@ -201,9 +200,6 @@ public abstract class PythonAbstractObject extends DynamicObject implements Truf
         private static final int PRIVATE_PREFIX_LENGTH = T_PRIVATE_PREFIX.codePointLengthUncached(TS_ENCODING);
         private PythonAbstractObjectNativeWrapper nativeWrapper;
     
    -    // @ImportStatic doesn't work for this for some reason
    -    protected static final SpecialMethodSlot Next = SpecialMethodSlot.Next;
    -
         protected static final Shape ABSTRACT_SHAPE = Shape.newBuilder().build();
     
         private Object[] indexedSlots;
    @@ -1730,8 +1726,7 @@ public boolean isIterator(
                         @Exclusive @Cached CastToJavaBooleanNode toBooleanNode,
                         // GR-44020: make shared:
                         @Exclusive @Cached PRaiseNode raiseNode,
    -                    @Shared("getClass") @Cached(inline = false) GetClassNode getClassNode,
    -                    @Cached(parameters = "Next") LookupCallableSlotInMRONode lookupNext,
    +                    @Cached PyIterCheckNode checkNode,
                         // GR-44020: make shared:
                         @Exclusive @Cached GilNode gil) {
             boolean mustRelease = gil.acquire();
    @@ -1741,7 +1736,7 @@ public boolean isIterator(
                 if (behavior != null) {
                     return getValue.executeBoolean(inliningTarget, behavior, method, toBooleanNode, raiseNode, this);
                 } else {
    -                return lookupNext.execute(getClassNode.executeCached(this)) != PNone.NO_VALUE;
    +                return checkNode.execute(inliningTarget, this);
                 }
             } finally {
                 gil.release(mustRelease);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    index f5a1204d42..fccf72cd55 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java
    @@ -71,7 +71,6 @@
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MISSING__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__;
    -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NE__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__;
     import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REVERSED__;
    @@ -149,7 +148,6 @@
     public enum SpecialMethodSlot {
         Dict(T___DICT__),
     
    -    Next(T___NEXT__),
         Await(T___AWAIT__, AM_AWAIT),
     
         AEnter(T___AENTER__),
    @@ -748,9 +746,6 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin
                     }
                     break;
                 case 'n' * 26 + 'e':    // ne
    -                if (eqNode.execute(name, T___NEXT__, TS_ENCODING)) {
    -                    return Next;
    -                }
                     if (eqNode.execute(name, T___NEW__, TS_ENCODING)) {
                         return New;
                     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    index 9c28f84a7f..117ba591df 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PySequenceIterSearchNode.java
    @@ -41,15 +41,11 @@
     package com.oracle.graal.python.lib;
     
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
    -import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PNodeWithContext;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
    -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
     import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
    -import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -62,6 +58,7 @@
     import com.oracle.truffle.api.nodes.LoopNode;
     import com.oracle.truffle.api.nodes.Node;
     import com.oracle.truffle.api.profiles.InlinedIntValueProfile;
    +import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile;
     
     /**
      * Equivalent of CPython's {@code _PySequence_IterSearch}.
    @@ -92,12 +89,9 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key
                         @Cached PyObjectGetIter getIter,
                         @Cached IsBuiltinObjectProfile noIterProfile,
                         @Cached PRaiseNode raiseNode,
    -                    @Cached GetClassNode getIterClass,
    -                    @Cached(parameters = "Next", inline = false) LookupSpecialMethodSlotNode lookupIternext,
    -                    @Cached IsBuiltinObjectProfile noNextProfile,
    -                    @Cached(inline = false) CallUnaryMethodNode callNext,
    +                    @Cached PyIterNextNode nextNode,
    +                    @Cached InlinedLoopConditionProfile loopProfile,
                         @Cached(inline = false) PyObjectRichCompareBool.EqNode eqNode,
    -                    @Cached IsBuiltinObjectProfile stopIterationProfile,
                         @Cached InlinedIntValueProfile opProfile) {
             Object iterator;
             try {
    @@ -106,56 +100,45 @@ static int search(Frame frame, Node inliningTarget, Object container, Object key
                 e.expectTypeError(inliningTarget, noIterProfile);
                 throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARGUMENT_OF_TYPE_P_IS_NOT_ITERABLE, container);
             }
    -        Object next = PNone.NO_VALUE;
    -        try {
    -            next = lookupIternext.execute(frame, getIterClass.execute(inliningTarget, iterator), iterator);
    -        } catch (PException e) {
    -            e.expect(inliningTarget, PythonBuiltinClassType.AttributeError, noNextProfile);
    -        }
    -        if (next instanceof PNone) {
    -            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_ITERABLE, iterator);
    -        }
    +        operation = opProfile.profile(inliningTarget, operation);
             int i = 0;
             int n = 0;
             boolean wrapped = false;
    -        while (true) {
    -            try {
    -                if (eqNode.compare(frame, inliningTarget, callNext.executeObject(frame, next, iterator), key)) {
    -                    switch (opProfile.profile(inliningTarget, operation)) {
    -                        case PY_ITERSEARCH_COUNT:
    -                            n++;
    -                            break;
    -                        case PY_ITERSEARCH_INDEX:
    -                            if (CompilerDirectives.hasNextTier()) {
    -                                LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    -                            }
    -                            if (wrapped) {
    -                                throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.INDEX_EXCEEDS_INT);
    -                            } else {
    -                                return i;
    -                            }
    -                        case PY_ITERSEARCH_CONTAINS:
    -                            if (CompilerDirectives.hasNextTier()) {
    -                                LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    -                            }
    -                            return 1;
    -                    }
    +        Object next;
    +        while (loopProfile.profile(inliningTarget, !PyIterNextNode.isExhausted(next = nextNode.execute(frame, inliningTarget, iterator)))) {
    +            if (eqNode.compare(frame, inliningTarget, next, key)) {
    +                switch (operation) {
    +                    case PY_ITERSEARCH_COUNT:
    +                        n++;
    +                        break;
    +                    case PY_ITERSEARCH_INDEX:
    +                        if (CompilerDirectives.hasNextTier()) {
    +                            LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    +                        }
    +                        if (wrapped) {
    +                            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.OverflowError, ErrorMessages.INDEX_EXCEEDS_INT);
    +                        } else {
    +                            return i;
    +                        }
    +                    case PY_ITERSEARCH_CONTAINS:
    +                        if (CompilerDirectives.hasNextTier()) {
    +                            LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    +                        }
    +                        return 1;
                     }
    -            } catch (PException e) {
    -                e.expectStopIteration(inliningTarget, stopIterationProfile);
    -                if (CompilerDirectives.hasNextTier()) {
    -                    LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    -                }
    -                if (opProfile.profile(inliningTarget, operation) == PY_ITERSEARCH_INDEX) {
    -                    throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.X_NOT_IN_SEQUENCE);
    -                }
    -                return n;
                 }
    -            if (opProfile.profile(inliningTarget, operation) == PY_ITERSEARCH_INDEX && i == Integer.MAX_VALUE) {
    +            if (operation == PY_ITERSEARCH_INDEX && i == Integer.MAX_VALUE) {
                     wrapped = true;
                 }
                 i++;
             }
    +        if (CompilerDirectives.hasNextTier()) {
    +            LoopNode.reportLoopCount(inliningTarget, wrapped ? Integer.MAX_VALUE : i + 1);
    +        }
    +        if (operation == PY_ITERSEARCH_INDEX) {
    +            throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.X_NOT_IN_SEQUENCE);
    +        }
    +        return n;
         }
     
         @GenerateInline
    
    From 874064d74b3aa8eab70546e442a5452d7210a9cd Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Fri, 28 Feb 2025 10:12:33 +0100
    Subject: [PATCH 113/512] Excercise python slot wrappers more in tests
    
    ---
     .../src/tests/cpyext/test_tp_slots.py         | 194 ++++++++----------
     1 file changed, 82 insertions(+), 112 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    index fd778a5efa..99b60cc26a 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    @@ -943,6 +943,27 @@ def test_PyType_Modified_doesnt_change_slots():
         assert tester.call_PySequence_GetItem(1) == 'sq_item'
     
     
    +class DelegateSlot:
    +    def __set_name__(self, owner, name):
    +        self.name = name
    +
    +    def __get__(self, obj, objtype=None):
    +        return getattr(obj.delegate, self.name)
    +
    +
    +class DelegateInplaceSlot(DelegateSlot):
    +    def __get__(self, obj, objtype=None):
    +        method = getattr(obj.delegate, self.name, None)
    +        if method is None:
    +            method = getattr(obj.delegate, self.name.replace('__i', '__'))
    +
    +        def wrapper(*args):
    +            self.delegate = method(*args)
    +            return self
    +
    +        return wrapper
    +
    +
     def test_nb_slot_calls():
         slots = [
             ('proxy_nb_binary_slot', 'nb_add'),
    @@ -1060,92 +1081,59 @@ def test_nb_slot_calls():
             **{slot: f'proxy_{slot}' for _, slot in slots},
         )
     
    -    def _unary_op(op):
    -        def fn(a):
    -            return op(a.delegate)
    -
    -        return fn
    -
    -    def _binary_op(op):
    -        def fn(a, b):
    -            return op(a.delegate, b)
    -
    -        return fn
    -
    -    def _binary_op_r(op):
    -        def fn(a, b):
    -            return op(b, a.delegate)
    -
    -        return fn
    -
    -    def _binary_op_inplace(op):
    -        def fn(a, b):
    -            a.delegate = op(a.delegate, b)
    -            return a
    -
    -        return fn
    -
         class PureSlotProxy:
             def __init__(self, delegate):
                 self.delegate = delegate
     
    -        __add__ = _binary_op(operator.add)
    -        __radd__ = _binary_op_r(operator.add)
    -        __iadd__ = _binary_op_inplace(operator.add)
    -        __sub__ = _binary_op(operator.sub)
    -        __rsub__ = _binary_op_r(operator.sub)
    -        __isub__ = _binary_op_inplace(operator.sub)
    -        __mul__ = _binary_op(operator.mul)
    -        __rmul__ = _binary_op_r(operator.mul)
    -        __imul__ = _binary_op_inplace(operator.mul)
    -        __mod__ = _binary_op(operator.mod)
    -        __rmod__ = _binary_op_r(operator.mod)
    -        __imod__ = _binary_op_inplace(operator.mod)
    -        __floordiv__ = _binary_op(operator.floordiv)
    -        __rfloordiv__ = _binary_op_r(operator.floordiv)
    -        __ifloordiv__ = _binary_op_inplace(operator.floordiv)
    -        __truediv__ = _binary_op(operator.truediv)
    -        __rtruediv__ = _binary_op_r(operator.truediv)
    -        __itruediv__ = _binary_op_inplace(operator.truediv)
    -        __divmod__ = _binary_op(divmod)
    -        __rdivmod__ = _binary_op_r(divmod)
    -
    -        def __pow__(self, power, modulo=None):
    -            return pow(self.delegate, power, modulo)
    -
    -        def __rpow__(self, other):
    -            return other ** self.delegate
    -
    -        def __ipow__(self, other):
    -            self.delegate = self.delegate ** other
    -            return self
    -
    -        __pos__ = _unary_op(operator.pos)
    -        __neg__ = _unary_op(operator.neg)
    -        __abs__ = _unary_op(abs)
    -        __bool__ = _unary_op(bool)
    -        __invert__ = _unary_op(operator.invert)
    -        __index__ = _unary_op(operator.index)
    -        __int__ = _unary_op(int)
    -        __float__ = _unary_op(float)
    -        __lshift__ = _binary_op(operator.lshift)
    -        __rlshift__ = _binary_op_r(operator.lshift)
    -        __ilshift__ = _binary_op_inplace(operator.lshift)
    -        __rshift__ = _binary_op(operator.rshift)
    -        __rrshift__ = _binary_op_r(operator.rshift)
    -        __irshift__ = _binary_op_inplace(operator.rshift)
    -        __and__ = _binary_op(operator.and_)
    -        __rand__ = _binary_op_r(operator.and_)
    -        __iand__ = _binary_op_inplace(operator.and_)
    -        __or__ = _binary_op(operator.or_)
    -        __ror__ = _binary_op_r(operator.or_)
    -        __ior__ = _binary_op_inplace(operator.or_)
    -        __xor__ = _binary_op(operator.xor)
    -        __rxor__ = _binary_op_r(operator.xor)
    -        __ixor__ = _binary_op_inplace(operator.xor)
    -        __matmul__ = _binary_op(operator.matmul)
    -        __rmatmul__ = _binary_op_r(operator.matmul)
    -        __imatmul__ = _binary_op_inplace(operator.matmul)
    +        __add__ = DelegateSlot()
    +        __radd__ = DelegateSlot()
    +        __iadd__ = DelegateInplaceSlot()
    +        __sub__ = DelegateSlot()
    +        __rsub__ = DelegateSlot()
    +        __isub__ = DelegateInplaceSlot()
    +        __mul__ = DelegateSlot()
    +        __rmul__ = DelegateSlot()
    +        __imul__ = DelegateInplaceSlot()
    +        __mod__ = DelegateSlot()
    +        __rmod__ = DelegateSlot()
    +        __imod__ = DelegateInplaceSlot()
    +        __floordiv__ = DelegateSlot()
    +        __rfloordiv__ = DelegateSlot()
    +        __ifloordiv__ = DelegateInplaceSlot()
    +        __truediv__ = DelegateSlot()
    +        __rtruediv__ = DelegateSlot()
    +        __itruediv__ = DelegateInplaceSlot()
    +        __divmod__ = DelegateSlot()
    +        __rdivmod__ = DelegateSlot()
    +        __pow__ = DelegateSlot()
    +        __rpow__ = DelegateSlot()
    +        __ipow__ = DelegateInplaceSlot()
    +        __pos__ = DelegateSlot()
    +        __neg__ = DelegateSlot()
    +        __abs__ = DelegateSlot()
    +        __bool__ = DelegateSlot()
    +        __invert__ = DelegateSlot()
    +        __index__ = DelegateSlot()
    +        __int__ = DelegateSlot()
    +        __float__ = DelegateSlot()
    +        __lshift__ = DelegateSlot()
    +        __rlshift__ = DelegateSlot()
    +        __ilshift__ = DelegateInplaceSlot()
    +        __rshift__ = DelegateSlot()
    +        __rrshift__ = DelegateSlot()
    +        __irshift__ = DelegateInplaceSlot()
    +        __and__ = DelegateSlot()
    +        __rand__ = DelegateSlot()
    +        __iand__ = DelegateInplaceSlot()
    +        __or__ = DelegateSlot()
    +        __ror__ = DelegateSlot()
    +        __ior__ = DelegateInplaceSlot()
    +        __xor__ = DelegateSlot()
    +        __rxor__ = DelegateSlot()
    +        __ixor__ = DelegateInplaceSlot()
    +        __matmul__ = DelegateSlot()
    +        __rmatmul__ = DelegateSlot()
    +        __imatmul__ = DelegateInplaceSlot()
     
         class ObjWithMatmul:
             def __matmul__(self, other):
    @@ -1318,20 +1306,11 @@ class PureSlotProxy:
             def __init__(self, delegate):
                 self.delegate = delegate
     
    -        def __len__(self):
    -            return len(self.delegate)
    -
    -        def __getitem__(self, item):
    -            return self.delegate[item]
    -
    -        def __setitem__(self, key, value):
    -            self.delegate[key] = value
    -
    -        def __delitem__(self, key):
    -            del self.delegate[key]
    -
    -        def __contains__(self, item):
    -            return item in self.delegate
    +        __len__ = DelegateSlot()
    +        __getitem__ = DelegateSlot()
    +        __setitem__ = DelegateSlot()
    +        __delitem__ = DelegateSlot()
    +        __contains__ = DelegateSlot()
     
         for obj in [NativeSqSlotProxy([1]), NativeSqSlotProxy(PureSlotProxy([1]))]:
             assert len(obj) == 1
    @@ -1430,17 +1409,11 @@ class PureSlotProxy:
             def __init__(self, delegate):
                 self.delegate = delegate
     
    -        def __len__(self):
    -            return len(self.delegate)
    -
    -        def __getitem__(self, item):
    -            return self.delegate[item]
    -
    -        def __setitem__(self, key, value):
    -            self.delegate[key] = value
    -
    -        def __delitem__(self, key):
    -            del self.delegate[key]
    +        __len__ = DelegateSlot()
    +        __getitem__ = DelegateSlot()
    +        __setitem__ = DelegateSlot()
    +        __delitem__ = DelegateSlot()
    +        __contains__ = DelegateSlot()
     
         for obj in [NativeMpSlotProxy({'a': 1}), NativeMpSlotProxy(PureSlotProxy({'a': 1}))]:
             assert len(obj) == 1
    @@ -1496,11 +1469,8 @@ class PureSlotProxy:
             def __init__(self, delegate):
                 self.delegate = delegate
     
    -        def __iter__(self):
    -            return iter(self.delegate)
    -
    -        def __next__(self):
    -            return next(self.delegate)
    +        __iter__ = DelegateSlot()
    +        __next__ = DelegateSlot()
     
         for obj in [NativeSlotProxy([1]), NativeSlotProxy(PureSlotProxy([1]))]:
             assert isinstance(iter(obj), type(iter([])))
    
    From 45a89aeda6a2e22a28f8e3a9e40e1dbbd106925b Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Fri, 28 Feb 2025 15:27:14 +0100
    Subject: [PATCH 114/512] Add tests for erasing __next__ mid-iteration
    
    ---
     .../src/tests/cpyext/test_tp_slots.py         | 77 ++++++++++++++++++-
     1 file changed, 76 insertions(+), 1 deletion(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    index 99b60cc26a..bf16a481ae 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tp_slots.py
    @@ -36,9 +36,10 @@
     # 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.
    -import operator
    +import itertools
     import sys
     
    +import operator
     from . import CPyExtType, CPyExtHeapType, compile_module_from_string, assert_raises, compile_module_from_file
     
     
    @@ -1478,3 +1479,77 @@ def __init__(self, delegate):
         for obj in [NativeSlotProxy(iter([1])), NativeSlotProxy(PureSlotProxy(iter([1])))]:
             assert next(obj) == 1
             assert_raises(StopIteration, next, obj)
    +
    +
    +def test_tp_iternext_not_implemented():
    +    class ManagedTypeWithVanishingNext:
    +        def __next__(self):
    +            del type(self).__next__
    +            return True
    +
    +    NativeTypeWithVanishingNext = CPyExtHeapType(
    +        name='TypeWithVanishingNext',
    +        code=r'''
    +            static PyObject* tp_iternext(TypeWithVanishingNextObject* self) {
    +                if (PyObject_DelAttrString((PyObject*)Py_TYPE(self), "__next__") < 0)
    +                    return NULL;
    +                Py_RETURN_TRUE;
    +            }
    +        ''',
    +        slots=['{Py_tp_iternext, tp_iternext}'],
    +    )
    +
    +    tester = CPyExtType(
    +        'IterableTester',
    +        r'''
    +        PyObject* iter_check(PyObject* unused, PyObject* obj) {
    +            return PyBool_FromLong(PyIter_Check(obj));
    +        }
    +        PyObject* not_impl_check(PyObject* unused, PyObject* obj) {
    +            return PyBool_FromLong(Py_TYPE(obj)->tp_iternext == _PyObject_NextNotImplemented);
    +        }
    +        ''',
    +        tp_methods='''
    +        {"PyIter_Check", iter_check, METH_O | METH_STATIC, ""},
    +        {"has_not_implemented_iternext", not_impl_check, METH_O | METH_STATIC, ""}
    +        ''',
    +    )
    +
    +    for TypeWithVanishingNext in (ManagedTypeWithVanishingNext, NativeTypeWithVanishingNext):
    +
    +        class Iterable:
    +            def __iter__(self):
    +                return TypeWithVanishingNext()
    +
    +        try:
    +            # We need to use a builtin that stores the iterator inside without rechecking it
    +            i = itertools.takewhile(lambda x: x, Iterable())
    +            assert next(i) is True
    +            next(i)
    +        except TypeError as e:
    +            # We need to check the message, because it's not the one from `next`, but from _PyObject_NextNotImplemented
    +            assert str(e).endswith("is not iterable")
    +        else:
    +            assert False
    +
    +        i = TypeWithVanishingNext()
    +        try:
    +            next(i)
    +        except TypeError as e:
    +            # Different message, now from `next` directly
    +            assert str(e).endswith("is not an iterator")
    +
    +        assert not tester.PyIter_Check(i)
    +        assert tester.has_not_implemented_iternext(i)
    +
    +    NativeTypeWithNotImplementedNext = CPyExtHeapType(
    +        name='TypeWithNotImplNext',
    +        slots=['{Py_tp_iternext, _PyObject_NextNotImplemented}'],
    +    )
    +    i = NativeTypeWithNotImplementedNext()
    +    assert not tester.PyIter_Check(i)
    +    assert tester.has_not_implemented_iternext(i)
    +    try:
    +        next(i)
    +    except TypeError as e:
    +        assert str(e).endswith("is not an iterator")
    
    From 9387eb762436b7518120150f1dfe4f9b8a9a8090 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Fri, 28 Feb 2025 16:18:03 +0100
    Subject: [PATCH 115/512] Convert between _PyObject_NextNotImplemented and its
     managed version
    
    ---
     .../objects/cext/capi/NativeCAPISymbol.java   |  4 ++-
     .../python/builtins/objects/type/TpSlots.java | 12 +++++++-
     .../builtins/objects/type/slots/TpSlot.java   | 29 +++----------------
     3 files changed, 18 insertions(+), 27 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/NativeCAPISymbol.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/NativeCAPISymbol.java
    index 946f7150e2..44b78e9261 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/NativeCAPISymbol.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/NativeCAPISymbol.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2025, 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,6 +44,7 @@
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.ConstCharPtrAsTruffleString;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.INT64_T;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Int;
    +import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.IterResult;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.LONG_LONG;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.PY_SSIZE_T_PTR;
     import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor.Pointer;
    @@ -167,6 +168,7 @@ public enum NativeCAPISymbol implements NativeCExtSymbol {
         FUN_GRAALPY_GC_COLLECT("GraalPyGC_Collect", Py_ssize_t, Int),
         FUN_SUBTYPE_TRAVERSE("subtype_traverse", Int, PyObject, Pointer, Pointer),
         FUN_GRAALPYOBJECT_GC_NOTIFYOWNERSHIPTRANSFER("_GraalPyObject_GC_NotifyOwnershipTransfer", Void, PyObject),
    +    FUN_PY_OBJECT_NEXT_NOT_IMPLEMENTED("_PyObject_NextNotImplemented", IterResult, PyObject),
     
         /* PyDateTime_CAPI */
     
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    index 98b2965e81..8299730181 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    @@ -122,7 +122,9 @@
     import com.oracle.graal.python.builtins.PythonBuiltinClassType;
     import com.oracle.graal.python.builtins.objects.PNone;
     import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject;
    +import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext;
     import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.BinaryOpSlotFuncWrapper;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.BinarySlotFuncWrapper;
    @@ -1160,12 +1162,20 @@ public static TpSlots fromNative(PythonAbstractNativeObject pythonClass, PythonC
                 TpSlotWrapper existingSlotWrapper = null;
                 if (interop.isPointer(field)) {
                     try {
    -                    Object executable = ctx.getCApiContext().getClosureExecutable(interop.asPointer(field));
    +                    long fieldPointer = interop.asPointer(field);
    +                    Object executable = ctx.getCApiContext().getClosureExecutable(fieldPointer);
                         if (executable instanceof TpSlotWrapper execWrapper) {
                             existingSlotWrapper = execWrapper;
                         } else if (executable != null) {
                             // This can happen for legacy slots where the delegate would be a PFunction
                             LOGGER.fine(() -> String.format("Unexpected executable for slot pointer: %s", executable));
    +                    } else {
    +                        Object symbol = CApiContext.getNativeSymbol(null, NativeCAPISymbol.FUN_PY_OBJECT_NEXT_NOT_IMPLEMENTED);
    +                        InteropLibrary symbolLibrary = InteropLibrary.getUncached(symbol);
    +                        if (fieldPointer == symbolLibrary.asPointer(symbol)) {
    +                            builder.set(def, TpSlotIterNext.NEXT_NOT_IMPLEMENTED);
    +                            continue;
    +                        }
                         }
                     } catch (UnsupportedMessageException e) {
                         throw new IllegalStateException(e);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    index 4e38bdbc9d..2d6b1c2dbc 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    @@ -51,7 +51,9 @@
     import com.oracle.graal.python.builtins.Builtin;
     import com.oracle.graal.python.builtins.Python3Core;
     import com.oracle.graal.python.builtins.objects.PNone;
    +import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext;
     import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper;
    +import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol;
     import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.TpSlotWrapper;
     import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
     import com.oracle.graal.python.builtins.objects.type.TpSlots.TpSlotMeta;
    @@ -63,7 +65,6 @@
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.RootCallTarget;
    -import com.oracle.truffle.api.TruffleLogger;
     import com.oracle.truffle.api.dsl.Fallback;
     import com.oracle.truffle.api.dsl.GenerateCached;
     import com.oracle.truffle.api.dsl.GenerateInline;
    @@ -82,7 +83,6 @@
      * {@link com.oracle.graal.python.builtins.objects.type.TpSlots} object.
      */
     public abstract class TpSlot {
    -    private static final TruffleLogger LOGGER = PythonLanguage.getLogger(TpSlot.class);
     
         /**
          * Transforms the slot object to an interop object that can be sent to native.
    @@ -92,6 +92,8 @@ public static Object toNative(TpSlotMeta slotMeta, TpSlot slot, Object defaultVa
                 return defaultValue;
             } else if (slot instanceof TpSlotNative nativeSlot) {
                 return nativeSlot.getCallable();
    +        } else if (slot == TpSlotIterNext.NEXT_NOT_IMPLEMENTED) {
    +            return CApiContext.getNativeSymbol(null, NativeCAPISymbol.FUN_PY_OBJECT_NEXT_NOT_IMPLEMENTED);
             } else if (slot instanceof TpSlotManaged managedSlot) {
                 // This returns PyProcsWrapper, which will, in its toNative message, register the
                 // pointer in C API context, such that we can map back from a pointer that we get from C
    @@ -106,29 +108,6 @@ public static Object toNative(TpSlotMeta slotMeta, TpSlot slot, Object defaultVa
             }
         }
     
    -    /**
    -     * If the interop object represents a pointer to existing {@link TpSlot}, then returns that
    -     * slot, otherwise {@code null}.
    -     */
    -    public static TpSlot fromNative(PythonContext ctx, Object ptr, InteropLibrary interop) {
    -        if (interop.isPointer(ptr)) {
    -            try {
    -                Object delegate = ctx.getCApiContext().getClosureDelegate(interop.asPointer(ptr));
    -                if (delegate instanceof TpSlot s) {
    -                    return s;
    -                } else if (delegate != null) {
    -                    // This can happen for legacy slots where the delegate would be a PFunction
    -                    LOGGER.warning(() -> String.format("Unexpected delegate for slot pointer: %s", delegate));
    -                }
    -            } catch (UnsupportedMessageException e) {
    -                throw new IllegalStateException(e);
    -            }
    -        } else if (ptr instanceof TpSlotWrapper slotWrapper) {
    -            return slotWrapper.getSlot();
    -        }
    -        return null;
    -    }
    -
         /**
          * Checks whether the slot represents the same "slot value" in CPython compatible way: i.e.,
          * Python magic method wrappers are same slots even if they are wrapping different
    
    From 4ba12e93358ec54e76131122fb0baac7ad3d83ee Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Fri, 28 Feb 2025 16:18:19 +0100
    Subject: [PATCH 116/512] Fix propagating slot updates to native objects
    
    ---
     .../objects/type/PythonManagedClass.java      |  8 ----
     .../python/builtins/objects/type/TpSlots.java | 38 +++++++++----------
     2 files changed, 18 insertions(+), 28 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java
    index b98201849a..def3ade42b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonManagedClass.java
    @@ -247,14 +247,6 @@ public boolean canSkipOnAttributeUpdate(TruffleString key, @SuppressWarnings("un
                             !SpecialMethodSlot.canBeSpecial(key, codePointLengthNode, codePointAtIndexNode);
         }
     
    -    public final void onAttributeUpdate(Object key, Object value) {
    -        // In compilation: use a profile and call the String key overload
    -        CompilerAsserts.neverPartOfCompilation();
    -        if (key instanceof TruffleString) {
    -            onAttributeUpdate((TruffleString) key, value);
    -        }
    -    }
    -
         @TruffleBoundary
         public void onAttributeUpdate(TruffleString key, Object value) {
             methodResolutionOrder.invalidateAttributeInMROFinalAssumptions(key);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    index 8299730181..ed15a6c644 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java
    @@ -1459,27 +1459,25 @@ private static Builder updateSlots(PythonAbstractClass klass, Builder slots, Set
                     }
                 }
     
    +            TpSlot newValue = null;
                 if (specific != null && !useGeneric) {
    -                slots.set(slot, specific);
    -            } else {
    -                TpSlot newValue = null;
    -                if (generic != null) {
    -                    newValue = generic.create(genericCallables, genericCallablesNames, klass);
    -                }
    -                slots.set(slot, newValue);
    -                if (klass instanceof PythonAbstractNativeObject nativeClass) {
    -                    // Update the slots on the native side if this is a native class
    -                    toNative(nativeClass.getPtr(), slot, newValue, nativeNull);
    -                }
    -                if (klass instanceof PythonManagedClass managedClass) {
    -                    // Update the slots on the native side if this is a managed class that has a
    -                    // native mirror allocated already
    -                    PythonClassNativeWrapper classNativeWrapper = managedClass.getClassNativeWrapper();
    -                    if (classNativeWrapper != null) {
    -                        Object replacement = classNativeWrapper.getReplacementIfInitialized();
    -                        if (replacement != null) {
    -                            toNative(replacement, slot, newValue, nativeNull);
    -                        }
    +                newValue = specific;
    +            } else if (generic != null) {
    +                newValue = generic.create(genericCallables, genericCallablesNames, klass);
    +            }
    +            slots.set(slot, newValue);
    +            if (klass instanceof PythonAbstractNativeObject nativeClass) {
    +                // Update the slots on the native side if this is a native class
    +                toNative(nativeClass.getPtr(), slot, newValue, nativeNull);
    +            }
    +            if (klass instanceof PythonManagedClass managedClass) {
    +                // Update the slots on the native side if this is a managed class that has a
    +                // native mirror allocated already
    +                PythonClassNativeWrapper classNativeWrapper = managedClass.getClassNativeWrapper();
    +                if (classNativeWrapper != null) {
    +                    Object replacement = classNativeWrapper.getReplacementIfInitialized();
    +                    if (replacement != null) {
    +                        toNative(replacement, slot, newValue, nativeNull);
                         }
                     }
                 }
    
    From a68bf4af0fba83beb9212bc73e2d92c5f4ed46ea Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 3 Mar 2025 10:32:37 +0100
    Subject: [PATCH 117/512] Add dostrings to slot wrapper methods
    
    ---
     .../type/slots/SlotWrapperDocstrings.java     | 135 ++++++++++++++++++
     .../builtins/objects/type/slots/TpSlot.java   |   2 +-
     2 files changed, 136 insertions(+), 1 deletion(-)
     create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/SlotWrapperDocstrings.java
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/SlotWrapperDocstrings.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/SlotWrapperDocstrings.java
    new file mode 100644
    index 0000000000..032f1dc8c4
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/SlotWrapperDocstrings.java
    @@ -0,0 +1,135 @@
    +/*
    + * Copyright (c) 2025, 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.builtins.objects.type.slots;
    +
    +import static com.oracle.graal.python.util.PythonUtils.tsLiteral;
    +
    +import com.oracle.truffle.api.strings.TruffleString;
    +
    +public enum SlotWrapperDocstrings {
    +    __repr__("Return repr(self)."),
    +    __hash__("Return hash(self)."),
    +    __call__("Call self as a function."),
    +    __str__("Return str(self)."),
    +    __getattribute__("Return getattr(self, name)."),
    +    __setattr__("Implement setattr(self, name, value)."),
    +    __delattr__("Implement delattr(self, name)."),
    +    __lt__("Return selfvalue."),
    +    __ge__("Return self>=value."),
    +    __iter__("Implement iter(self)."),
    +    __next__("Implement next(self)."),
    +    __get__("Return an attribute of instance, which is of type owner."),
    +    __set__("Set an attribute of instance to value."),
    +    __delete__("Delete an attribute of instance."),
    +    __init__("Initialize self.  See help(type(self)) for accurate signature."),
    +    __new__("Create and return new object.  See help(type) for accurate signature."),
    +    __await__("Return an iterator to be used in await expression."),
    +    __aiter__("Return an awaitable, that resolves in asynchronous iterator."),
    +    __anext__("Return a value or raise StopAsyncIteration."),
    +    __add__("Return self+value."),
    +    __radd__("Return value+self."),
    +    __sub__("Return self-value."),
    +    __rsub__("Return value-self."),
    +    __mul__("Return self*value."),
    +    __rmul__("Return value*self."),
    +    __mod__("Return self%value."),
    +    __rmod__("Return value%self."),
    +    __divmod__("Return divmod(self, value)."),
    +    __rdivmod__("Return divmod(value, self)."),
    +    __pow__("Return pow(self, value, mod)."),
    +    __rpow__("Return pow(value, self, mod)."),
    +    __neg__("-self"),
    +    __pos__("+self"),
    +    __abs__("abs(self)"),
    +    __bool__("True if self else False"),
    +    __invert__("~self"),
    +    __lshift__("Return self<>value."),
    +    __rrshift__("Return value>>self."),
    +    __and__("Return self&value."),
    +    __rand__("Return value&self."),
    +    __xor__("Return self^value."),
    +    __rxor__("Return value^self."),
    +    __or__("Return self|value."),
    +    __ror__("Return value|self."),
    +    __int__("int(self)"),
    +    __float__("float(self)"),
    +    __iadd__("Return self+=value."),
    +    __isub__("Return self-=value."),
    +    __imul__("Return self*=value."),
    +    __imod__("Return self%=value."),
    +    __ipow__("Return self**=value."),
    +    __ilshift__("Return self<<=value."),
    +    __irshift__("Return self>>=value."),
    +    __iand__("Return self&=value."),
    +    __ixor__("Return self^=value."),
    +    __ior__("Return self|=value."),
    +    __floordiv__("Return self//value."),
    +    __rfloordiv__("Return value//self."),
    +    __truediv__("Return self/value."),
    +    __rtruediv__("Return value/self."),
    +    __ifloordiv__("Return self//=value."),
    +    __itruediv__("Return self/=value."),
    +    __index__("Return self converted to an integer, if self is suitable for use as an index into a list."),
    +    __matmul__("Return self@value."),
    +    __rmatmul__("Return value@self."),
    +    __imatmul__("Return self@=value."),
    +    __len__("Return len(self)."),
    +    __getitem__("Return self[key]."),
    +    __setitem__("Set self[key] to value."),
    +    __delitem__("Delete self[key]."),
    +    __contains__("Return key in self.");
    +
    +    public final TruffleString docstring;
    +
    +    SlotWrapperDocstrings(String docstring) {
    +        this.docstring = tsLiteral(docstring);
    +    }
    +
    +    public static TruffleString getDocstring(String name) {
    +        return valueOf(name).docstring;
    +    }
    +}
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    index 2d6b1c2dbc..6d38189aad 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java
    @@ -316,7 +316,7 @@ final PBuiltinFunction createBuiltin(Python3Core core, Object type, TruffleStrin
                 RootCallTarget callTarget = createBuiltinCallTarget(core.getLanguage(), signature, factory, name);
                 Builtin builtin = ((BuiltinFunctionRootNode) callTarget.getRootNode()).getBuiltin();
                 PBuiltinFunction function = PFactory.createWrapperDescriptor(core.getLanguage(), tsName, type, numDefaults(builtin), 0, callTarget, this, wrapper);
    -            function.setAttribute(T___DOC__, PNone.NONE);
    +            function.setAttribute(T___DOC__, SlotWrapperDocstrings.getDocstring(name));
                 return function;
             }
     
    
    From fd88bccb0401da86006026e4e8bb37c183b72fc8 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 3 Mar 2025 16:53:18 +0100
    Subject: [PATCH 118/512] Update imports
    
    ---
     ci.jsonnet              | 2 +-
     mx.graalpython/suite.py | 8 ++++----
     2 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/ci.jsonnet b/ci.jsonnet
    index 21600f27e4..cd8ecb9bf4 100644
    --- a/ci.jsonnet
    +++ b/ci.jsonnet
    @@ -1 +1 @@
    -{ "overlay": "8dd41b33e90f2176621893827fb1431b82c865b3" }
    +{ "overlay": "0edef0e6e6ab7aafc365b13e12078537e28bcb96" }
    diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py
    index 8bc1dc2ff4..b5be374d93 100644
    --- a/mx.graalpython/suite.py
    +++ b/mx.graalpython/suite.py
    @@ -45,7 +45,7 @@
                 },
                 {
                     "name": "sdk",
    -                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
    +                "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -53,7 +53,7 @@
                 },
                 {
                     "name": "tools",
    -                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
    +                "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -61,7 +61,7 @@
                 },
                 {
                     "name": "sulong",
    -                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
    +                "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    @@ -69,7 +69,7 @@
                 },
                 {
                     "name": "regex",
    -                "version": "719c89f9d6756aad165de2b98abf13a5c252be0c",
    +                "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982",
                     "subdir": True,
                     "urls": [
                         {"url": "https://github.com/oracle/graal", "kind": "git"},
    
    From d346cf94d7da15d5ba691ebe191648efb0378f84 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 3 Mar 2025 16:57:11 +0100
    Subject: [PATCH 119/512] Retag unittests
    
    ---
     .../src/tests/unittest_tags/test_capi.txt     |  6 ++
     .../src/tests/unittest_tags/test_mmap.txt     |  2 +-
     .../src/tests/unittest_tags/test_tarfile.txt  | 99 ++++++++++---------
     .../src/tests/unittest_tags/test_weakref.txt  |  2 +-
     4 files changed, 58 insertions(+), 51 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    index 215d6591c4..dfb217723f 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_capi.txt
    @@ -97,6 +97,12 @@ test.test_capi.test_misc.CAPITest.test_subprocess_fork_exec @ darwin-arm64,darwi
     test.test_capi.test_misc.CAPITest.test_sys_getobject @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     # Segfaults most of the time
     !test.test_capi.test_misc.CAPITest.test_trashcan_subclass
    +test.test_capi.test_misc.PyMemDebugTests.test_pyobject_forbidden_bytes_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.PyMemDebugTests.test_pyobject_null_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.PyMemDebugTests.test_pyobject_uninitialized_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.PyMemMallocDebugTests.test_pyobject_forbidden_bytes_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.PyMemMallocDebugTests.test_pyobject_null_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_capi.test_misc.PyMemMallocDebugTests.test_pyobject_uninitialized_is_freed @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_FrameAPI.test_frame_fback_api @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_FrameAPI.test_frame_getters @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_capi.test_misc.Test_ModuleStateAccess.test_get_module_bad_def @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_mmap.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_mmap.txt
    index 40372a8428..0338144a9e 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_mmap.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_mmap.txt
    @@ -19,5 +19,5 @@ test.test_mmap.MmapTests.test_prot_readonly @ darwin-arm64,darwin-x86_64,linux-a
     test.test_mmap.MmapTests.test_read_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_mmap.MmapTests.test_read_invalid_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_mmap.MmapTests.test_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    -test.test_mmap.MmapTests.test_tougher_find @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_mmap.MmapTests.test_tougher_find @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_mmap.MmapTests.test_write_returning_the_number_of_bytes_written @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    index 1e452d8705..be7f184483 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt
    @@ -475,81 +475,82 @@ test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_
     test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.StreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.StreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.StreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.TestExtractionFilters.test_absolute_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_bad_filter_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.TestExtractionFilters.test_chains @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.TestExtractionFilters.test_deep_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_default_filter_warns_not @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_errorlevel @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.TestExtractionFilters.test_modes @ win32-AMD64
     test.test_tarfile.TestExtractionFilters.test_parent_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_parent_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_pipe @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_sly_relative0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.TestExtractionFilters.test_sly_relative2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.TestExtractionFilters.test_stateful_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.UstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.UstarUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.UstarUnicodeTest.test_unicode_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.UstarUnicodeTest.test_unicode_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    +test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.WriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.WriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.WriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.WriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    -test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_tarfile.WriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
     test.test_tarfile.WriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    index d550307c5b..56f3526cc9 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_weakref.txt
    @@ -10,7 +10,7 @@ test.test_weakref.MappingTestCase.test_make_weak_valued_dict_misc @ darwin-arm64
     test.test_weakref.MappingTestCase.test_make_weak_valued_dict_repr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.MappingTestCase.test_threaded_weak_key_dict_copy @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.MappingTestCase.test_threaded_weak_value_dict_copy @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    -test.test_weakref.MappingTestCase.test_threaded_weak_value_dict_deepcopy @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64
    +test.test_weakref.MappingTestCase.test_threaded_weak_value_dict_deepcopy @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.MappingTestCase.test_threaded_weak_valued_consistency @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.MappingTestCase.test_threaded_weak_valued_pop @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
     test.test_weakref.MappingTestCase.test_threaded_weak_valued_setdefault @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64
    
    From e3c46277c8e531f4292a6754ee561db5a9922bc9 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Mon, 3 Mar 2025 16:44:25 +0100
    Subject: [PATCH 120/512] Add more tests for sum
    
    ---
     .../src/tests/test_sum.py                     | 38 ++++++++++++++++-
     .../builtins/modules/BuiltinFunctions.java    | 26 +++++-------
     .../modules/GraalPythonModuleBuiltins.java    | 42 ++++++++++++-------
     3 files changed, 76 insertions(+), 30 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_sum.py b/graalpython/com.oracle.graal.python.test/src/tests/test_sum.py
    index 4e71f08ae8..f46869c541 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/test_sum.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_sum.py
    @@ -1,4 +1,4 @@
    -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
    +# Copyright (c) 2018, 2025, 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
    @@ -76,3 +76,39 @@ def test_iterator():
     def test_basics():
         assert sum([[1, 2], [3, 4]], []) == [1, 2, 3, 4]
         assert_raises(TypeError, sum, [1,2,3], None)
    +
    +
    +def test_specializations():
    +    # test sumIntIterator
    +    assert sum([1, 2, 3]) == 6
    +    assert sum([1, 2, 3], 2) == 8
    +    assert sum([1, 2 ** 64, 3]) == 2 ** 64 + 4
    +    assert sum([2 ** 30, 2 ** 30]) == 2 ** 31
    +    # test sumLongIterator
    +    assert sum([2 ** 32, 2 ** 32]) == 2 ** 33
    +    assert sum([2 ** 31, -(2 ** 30)]) == 2 ** 30
    +    assert sum([2 ** 62, 2 ** 62]) == 2 ** 63
    +    # test sumDoubleIterator
    +    assert sum([1.0, 2.0, 3.1]) == 6.1
    +    assert sum([2.1], 1.0) == 3.1
    +    assert sum([2.1], 1) == 3.1
    +    assert sum([], 2.1) == 2.1
    +    l = [2.0]
    +    del l[0]  # To obtain an empty list with double storage
    +    assert sum(l, 1) == 1
    +    assert type(sum(l, 1)) is int
    +    # sumGeneric
    +    l = ["a", 1, 2]
    +    del l[0]  # To obtain a list of integers with object storage
    +    assert sum(l) == 3
    +    assert sum(l, 1) == 4
    +    l = ["a", 1.0, 2.1]
    +    del l[0]  # To obtain a list of doubles with object storage
    +    assert sum(l) == 3.1
    +    assert sum(l, 1) == 4.1
    +    assert sum([1, 2.1]) == 3.1
    +    assert sum([1, 2.1], 1) == 4.1
    +    assert sum([2.1, 1]) == 3.1
    +    assert sum([2.1, 1], 1.0) == 4.1
    +    assert sum([], 1) == 1
    +    assert type(sum([], 1)) is int
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    index d32becf29c..589a0f6b6b 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
    @@ -2119,7 +2119,7 @@ Object ternary(VirtualFrame frame, Object x, Object y, Object z,
         // sum(iterable[, start])
         @Builtin(name = J_SUM, minNumOfPositionalArgs = 1, parameterNames = {"iterable", "start"})
         @GenerateNodeFactory
    -    public abstract static class SumFunctionNode extends PythonBuiltinNode {
    +    public abstract static class SumFunctionNode extends PythonBinaryBuiltinNode {
     
             @Specialization
             Object sum(VirtualFrame frame, Object iterable, Object start,
    @@ -2143,6 +2143,7 @@ Object sum(VirtualFrame frame, Object iterable, Object start,
     
             @GenerateInline
             @GenerateCached(false)
    +        @ImportStatic(PGuards.class)
             abstract static class SumIteratorNode extends Node {
                 public abstract Object execute(VirtualFrame frame, Node inliningTarget, Object iterator, Object start);
     
    @@ -2194,26 +2195,21 @@ static Object sumLongIterator(VirtualFrame frame, Node inliningTarget, PLongSequ
                     return maybeInt(inliningTarget, resultFitsInInt, longResult);
                 }
     
    -            @Specialization
    -            static Object sumDoubleIterator(Node inliningTarget, PDoubleSequenceIterator iterator, double start,
    -                            @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive) {
    -                double result = start;
    -                while (loopProfilePrimitive.profile(inliningTarget, iterator.hasNext())) {
    -                    result += iterator.next();
    -                }
    -                return result;
    -            }
    -
    -            @Specialization
    -            static Object sumDoubleIteratorIntStart(Node inliningTarget, PDoubleSequenceIterator iterator, int start,
    +            @Specialization(guards = "isDouble(start) || isInt(start)")
    +            static Object sumDoubleIterator(Node inliningTarget, PDoubleSequenceIterator iterator, Object start,
    +                            @Cached InlinedConditionProfile startIsDouble,
                                 @Shared @Cached InlinedLoopConditionProfile loopProfilePrimitive) {
                     /*
    -                 * Need to make sure we keep start as int if the iterator was empty
    +                 * Need to make sure we keep start type if the iterator was empty
                      */
                     if (!iterator.hasNext()) {
                         return start;
                     }
    -                return sumDoubleIterator(inliningTarget, iterator, start, loopProfilePrimitive);
    +                double result = startIsDouble.profile(inliningTarget, start instanceof Double) ? (double) start : (int) start;
    +                while (loopProfilePrimitive.profile(inliningTarget, iterator.hasNext())) {
    +                    result += iterator.next();
    +                }
    +                return result;
                 }
     
                 @Fallback
    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 882a36875c..85ff00f79a 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
    @@ -127,6 +127,7 @@
     import com.oracle.graal.python.builtins.objects.module.PythonModule;
     import com.oracle.graal.python.builtins.objects.object.PythonObject;
     import com.oracle.graal.python.builtins.objects.set.PSet;
    +import com.oracle.graal.python.builtins.objects.str.PString;
     import com.oracle.graal.python.builtins.objects.str.StringUtils;
     import com.oracle.graal.python.builtins.objects.tuple.PTuple;
     import com.oracle.graal.python.builtins.objects.type.PythonClass;
    @@ -944,18 +945,6 @@ Object doIt(Object value) {
         @Builtin(name = "which", minNumOfPositionalArgs = 1)
         @GenerateNodeFactory
         abstract static class WhichNode extends PythonUnaryBuiltinNode {
    -        @Specialization
    -        @TruffleBoundary
    -        Object which(PBuiltinFunction object) {
    -            RootCallTarget callTarget = object.getCallTarget();
    -            return toTruffleStringUncached(String.format("%s(%s)", object.getClass().getName(), whichCallTarget(callTarget)));
    -        }
    -
    -        @Specialization
    -        @TruffleBoundary
    -        Object which(PBuiltinMethod object) {
    -            return toTruffleStringUncached(String.format("%s(%s)", object.getClass().getName(), whichCallTarget(object.getBuiltinFunction().getCallTarget())));
    -        }
     
             private static String whichCallTarget(RootCallTarget callTarget) {
                 RootNode rootNode = callTarget.getRootNode();
    @@ -970,8 +959,33 @@ private static String whichCallTarget(RootCallTarget callTarget) {
     
             @Specialization
             @TruffleBoundary
    -        Object which(Object object) {
    -            return toTruffleStringUncached(object.getClass().getName());
    +        // This is a builtin for debugging, so it also includes things that should never end up in
    +        // python value space
    +        static Object which(Object object) {
    +            if (object == null) {
    +                return "null";
    +            }
    +            String name = object.getClass().getName();
    +            Object detail = null;
    +            try {
    +                if (object instanceof PNone) {
    +                    detail = "NO_VALUE";
    +                } else if (object instanceof PBuiltinFunction fn) {
    +                    detail = whichCallTarget(fn.getCallTarget());
    +                } else if (object instanceof PBuiltinMethod fn) {
    +                    detail = whichCallTarget(fn.getBuiltinFunction().getCallTarget());
    +                } else if (object instanceof PSequence sequence && !(object instanceof PString)) {
    +                    detail = sequence.getSequenceStorage();
    +                } else if (object instanceof PArray array) {
    +                    detail = array.getSequenceStorage();
    +                } else if (object instanceof PythonAbstractNativeObject nativeObject) {
    +                    detail = PythonUtils.formatPointer(nativeObject.getPtr());
    +                }
    +            } catch (Throwable t) {
    +                detail = "Detail computation threw exception: " + t;
    +            }
    +            String which = detail != null ? String.format("%s(%s)", name, detail) : name;
    +            return toTruffleStringUncached(which);
             }
         }
     
    
    From 979793d66f3c0174fa9e79c4d0d6e8148dd03104 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Tue, 4 Mar 2025 14:13:43 +0100
    Subject: [PATCH 121/512] Declare slots in local variable to workaround MSVC
     bugs
    
    ---
     .../src/tests/cpyext/__init__.py                       | 10 ++++------
     1 file changed, 4 insertions(+), 6 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py
    index 27a2e407ac..5c6050f9d1 100644
    --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py
    +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py
    @@ -764,13 +764,11 @@ def CPyExtHeapType(name, bases=(object), code='', slots=None, **kwargs):
     
         {code}
     
    -    PyType_Slot slots[] = {{
    -        {slots}
    -    }};
    -
    -    PyType_Spec spec = {{ "{name}", sizeof({name}Object), 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, slots }};
    -
         static PyObject* create(PyObject* unused, PyObject* bases) {{
    +        PyType_Slot slots[] = {{
    +            {slots}
    +        }};
    +        PyType_Spec spec = {{ "{name}", sizeof({name}Object), 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, slots }};
             {ready_code}
             PyObject* type = PyType_FromSpecWithBases(&spec, bases);
             if (type == NULL)
    
    From c541c66e4490349a32a84e5168c4562c6ceb6892 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Tue, 4 Mar 2025 18:09:19 +0100
    Subject: [PATCH 122/512] Simplify CallDispatchNode
    
    ---
     .../python/builtins/objects/code/PCode.java   |  4 ++
     .../python/nodes/call/CallDispatchNode.java   | 46 ++++++-------------
     2 files changed, 19 insertions(+), 31 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    index fed0025ac1..b94f9d35b3 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    @@ -632,6 +632,10 @@ public RootCallTarget getRootCallTarget() {
             return callTarget;
         }
     
    +    public RootCallTarget getRootCallTargetOrNull() {
    +        return callTarget;
    +    }
    +
         @TruffleBoundary
         synchronized RootCallTarget initializeCallTarget() {
             assert PythonContext.get(null).ownsGil(); // otherwise this is racy
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallDispatchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallDispatchNode.java
    index 48816e085d..13f7ba7c12 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallDispatchNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallDispatchNode.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2017, 2023, Oracle and/or its affiliates.
    + * Copyright (c) 2017, 2025, Oracle and/or its affiliates.
      * Copyright (c) 2014, Regents of the University of California
      *
      * All rights reserved.
    @@ -25,15 +25,11 @@
      */
     package com.oracle.graal.python.nodes.call;
     
    -import com.oracle.graal.python.builtins.objects.code.CodeNodes.GetCodeCallTargetNode;
     import com.oracle.graal.python.builtins.objects.code.PCode;
     import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
     import com.oracle.graal.python.builtins.objects.function.PFunction;
     import com.oracle.graal.python.nodes.PNodeWithContext;
    -import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
    -import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetFunctionCodeNode;
     import com.oracle.graal.python.runtime.PythonOptions;
    -import com.oracle.truffle.api.CompilerAsserts;
     import com.oracle.truffle.api.RootCallTarget;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
    @@ -46,6 +42,7 @@
     import com.oracle.truffle.api.frame.Frame;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.profiles.InlinedBranchProfile;
     
     @ImportStatic(PythonOptions.class)
     @GenerateUncached
    @@ -101,38 +98,25 @@ protected static Object callFunctionCached(VirtualFrame frame, @SuppressWarnings
             return invoke.execute(frame, arguments);
         }
     
    -    // We only have a single context and this function changed its code before, but now it's
    -    // constant
    -    protected PCode getCode(Node inliningTarget, GetFunctionCodeNode getFunctionCodeNode, PFunction function) {
    -        return getFunctionCodeNode.execute(inliningTarget, function);
    -    }
    -
    -    @Specialization(guards = {"isSingleContext()", "callee == cachedCallee", "getCode(inliningTarget, getFunctionCodeNode, callee) == cachedCode"}, //
    -                    replaces = "callFunctionCached", limit = "getCallSiteInlineCacheMaxDepth()")
    -    protected static Object callFunctionCachedCode(VirtualFrame frame, @SuppressWarnings("unused") PFunction callee, Object[] arguments,
    -                    @SuppressWarnings("unused") @Bind("this") Node inliningTarget,
    -                    @SuppressWarnings("unused") @Cached("callee") PFunction cachedCallee,
    -                    @SuppressWarnings("unused") @Cached GetFunctionCodeNode getFunctionCodeNode,
    -                    @SuppressWarnings("unused") @Cached("getCode(inliningTarget, getFunctionCodeNode, callee)") PCode cachedCode,
    -                    @Cached("createInvokeNode(cachedCallee)") FunctionInvokeNode invoke) {
    -        return invoke.execute(frame, arguments);
    -    }
    -
    -    protected static RootCallTarget getCallTargetUncached(PFunction callee) {
    -        CompilerAsserts.neverPartOfCompilation();
    -        return GetCallTargetNode.getUncached().execute(callee);
    -    }
    -
         // We have multiple contexts, don't cache the objects so that contexts can be cleaned up
    -    @Specialization(guards = {"getCt.execute(inliningTarget, callee.getCode()) == ct"}, limit = "getCallSiteInlineCacheMaxDepth()", replaces = "callFunctionCachedCode")
    +    @Specialization(guards = {"getCallTarget(inliningTarget, code, initializeCodeProfile) == ct"}, limit = "getCallSiteInlineCacheMaxDepth()", replaces = "callFunctionCached")
         protected static Object callFunctionCachedCt(VirtualFrame frame, PFunction callee, Object[] arguments,
                         @SuppressWarnings("unused") @Bind("this") Node inliningTarget,
    -                    @SuppressWarnings("unused") @Cached("getCallTargetUncached(callee)") RootCallTarget ct,
    -                    @SuppressWarnings("unused") @Cached GetCodeCallTargetNode getCt,
    +                    @SuppressWarnings("unused") @Bind("callee.getCode()") PCode code,
    +                    @SuppressWarnings("unused") @Cached InlinedBranchProfile initializeCodeProfile,
    +                    @SuppressWarnings("unused") @Cached("code.getRootCallTarget()") RootCallTarget ct,
                         @Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
             return invoke.execute(frame, callee, callee.getGlobals(), callee.getClosure(), arguments);
         }
     
    +    protected static RootCallTarget getCallTarget(Node inliningTarget, PCode code, InlinedBranchProfile initializeCodeProfile) {
    +        if (code.getRootCallTargetOrNull() == null) {
    +            initializeCodeProfile.enter(inliningTarget);
    +            return code.getRootCallTarget();
    +        }
    +        return code.getRootCallTargetOrNull();
    +    }
    +
         @Specialization(guards = {"isSingleContext()", "callee == cachedCallee"}, limit = "getCallSiteInlineCacheMaxDepth()")
         protected static Object callBuiltinFunctionCached(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinFunction callee, Object[] arguments,
                         @SuppressWarnings("unused") @Cached("callee") PBuiltinFunction cachedCallee,
    @@ -147,7 +131,7 @@ protected static Object callBuiltinFunctionCachedCt(VirtualFrame frame, @Suppres
             return invoke.execute(frame, null, null, null, arguments);
         }
     
    -    @Specialization(replaces = {"callFunctionCached", "callFunctionCachedCode", "callFunctionCachedCt"})
    +    @Specialization(replaces = {"callFunctionCached", "callFunctionCachedCt"})
         @Megamorphic
         protected static Object callFunctionUncached(Frame frame, PFunction callee, Object[] arguments,
                         @Shared @Cached GenericInvokeNode invoke) {
    
    From 68bb77e1c02446276f3f691456de891dd2292041 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Mon, 3 Mar 2025 19:49:30 +0100
    Subject: [PATCH 123/512] Refactor CallContext to avoid potential deopt loop.
    
    ---
     .../python/runtime/ExecutionContext.java      | 228 ++++++++++--------
     1 file changed, 134 insertions(+), 94 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java
    index ed28f25b8b..2eb06dd69d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java
    @@ -52,6 +52,7 @@
     import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
     import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode.FrameSelector;
     import com.oracle.graal.python.nodes.util.ExceptionStateNodes.GetCaughtExceptionNode;
    +import com.oracle.graal.python.runtime.ExecutionContextFactory.CallContextNodeGen;
     import com.oracle.graal.python.runtime.PythonContext.PythonThreadState;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.truffle.api.CompilerAsserts;
    @@ -60,42 +61,39 @@
     import com.oracle.truffle.api.CompilerDirectives.ValueType;
     import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
     import com.oracle.truffle.api.RootCallTarget;
    +import com.oracle.truffle.api.dsl.Bind;
    +import com.oracle.truffle.api.dsl.Cached;
    +import com.oracle.truffle.api.dsl.GenerateCached;
    +import com.oracle.truffle.api.dsl.GenerateInline;
    +import com.oracle.truffle.api.dsl.GenerateUncached;
    +import com.oracle.truffle.api.dsl.ImportStatic;
     import com.oracle.truffle.api.dsl.NeverDefault;
    +import com.oracle.truffle.api.dsl.ReportPolymorphism;
    +import com.oracle.truffle.api.dsl.Specialization;
     import com.oracle.truffle.api.exception.AbstractTruffleException;
     import com.oracle.truffle.api.frame.Frame;
     import com.oracle.truffle.api.frame.FrameInstance;
     import com.oracle.truffle.api.frame.VirtualFrame;
     import com.oracle.truffle.api.nodes.Node;
    -import com.oracle.truffle.api.profiles.ConditionProfile;
    +import com.oracle.truffle.api.profiles.InlinedConditionProfile;
    +import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile;
     
     /**
      * An ExecutionContext ensures proper entry and exit for Python calls on both sides of the call, and
      * depending on whether the other side is also a Python frame.
      */
     public abstract class ExecutionContext {
    -
    -    public static final class CallContext extends Node {
    -        @CompilationFinal boolean neededCallerFrame;
    -        @CompilationFinal boolean neededExceptionState;
    -        private static final CallContext INSTANCE = new CallContext(false);
    -
    -        @Child private MaterializeFrameNode materializeNode;
    -
    -        private final boolean adoptable;
    -
    -        @CompilationFinal private ConditionProfile isPythonFrameProfile;
    -
    -        private CallContext(boolean adoptable) {
    -            this.adoptable = adoptable;
    -            this.neededExceptionState = !adoptable;
    -            this.neededCallerFrame = !adoptable;
    +    @GenerateUncached
    +    public abstract static class CallContext extends Node {
    +        public static CallContext create() {
    +            return CallContextNodeGen.create();
             }
     
             /**
              * Prepare an indirect call from a Python frame to a Python function.
              */
             public void prepareIndirectCall(VirtualFrame frame, Object[] callArguments, Node callNode) {
    -            prepareCall(frame, callArguments, callNode, true, true);
    +            executePrepareCall(frame, callArguments, callNode, true, true);
             }
     
             /**
    @@ -105,101 +103,143 @@ public void prepareCall(VirtualFrame frame, Object[] callArguments, RootCallTarg
                 // n.b.: The class cast should always be correct, since this context
                 // must only be used when calling from Python to Python
                 PRootNode calleeRootNode = (PRootNode) callTarget.getRootNode();
    -            prepareCall(frame, callArguments, callNode, calleeRootNode.needsCallerFrame(), calleeRootNode.needsExceptionState());
    +            executePrepareCall(frame, callArguments, callNode, calleeRootNode.needsCallerFrame(), calleeRootNode.needsExceptionState());
             }
     
    -        private void prepareCall(VirtualFrame frame, Object[] callArguments, Node callNode, boolean needsCallerFrame, boolean needsExceptionState) {
    -            // equivalent to PyPy's ExecutionContext.enter `frame.f_backref =
    -            // self.topframeref` we here pass the current top frame reference to
    -            // the next frame. An optimization we do is to only pass the frame
    -            // info if the caller requested it, otherwise they'll have to deopt
    -            // and walk the stack up once.
    -
    -            if (needsCallerFrame) {
    -                if (!neededCallerFrame) {
    -                    CompilerDirectives.transferToInterpreterAndInvalidate();
    -                    neededCallerFrame = true;
    -                }
    -                PFrame.Reference thisInfo;
    -
    -                if (isPythonFrame(frame, callNode)) {
    -                    thisInfo = PArguments.getCurrentFrameInfo(frame);
    +        protected abstract void executePrepareCall(VirtualFrame frame, Object[] callArguments, Node callNode, boolean needsCallerFrame, boolean needsExceptionState);
     
    -                    // We are handing the PFrame of the current frame to the caller, i.e., it does
    -                    // not 'escape' since it is still on the stack.Also, force synchronization of
    -                    // values
    -                    PFrame pyFrame = materialize(frame, callNode, false, true);
    -                    assert thisInfo.getPyFrame() == pyFrame;
    -                    assert pyFrame.getRef() == thisInfo;
    -                } else {
    -                    thisInfo = PFrame.Reference.EMPTY;
    -                }
    +        /**
    +         * Equivalent to PyPy's ExecutionContext.enter `frame.f_backref = self.topframeref` we here
    +         * pass the current top frame reference to the next frame. An optimization we do is to only
    +         * pass the frame info if the caller requested it, otherwise they'll have to deopt and walk
    +         * the stack up once.
    +         */
    +        @GenerateCached(false)
    +        @GenerateUncached
    +        @GenerateInline
    +        @ImportStatic(PArguments.class)
    +        protected abstract static class PassCallerFrameNode extends Node {
    +            protected abstract void execute(VirtualFrame frame, Node inliningTarget, Object[] callArguments, Node callNode, boolean needsCallerFrame);
    +
    +            @Specialization(guards = "!needsCallerFrame")
    +            protected static void dontPassCallerFrame(VirtualFrame frame, Node inliningTarget, Object[] callArguments, Node callNode, boolean needsCallerFrame) {
    +            }
     
    +            @Specialization(guards = {"needsCallerFrame", "isPythonFrame(frame)"})
    +            protected static void passCallerFrame(VirtualFrame frame, Node inliningTarget, Object[] callArguments, Node callNode, boolean needsCallerFrame,
    +                            @Cached(inline = false) MaterializeFrameNode materialize) {
    +                PFrame.Reference thisInfo = PArguments.getCurrentFrameInfo(frame);
    +                // We are handing the PFrame of the current frame to the caller, i.e., it does
    +                // not 'escape' since it is still on the stack.Also, force synchronization of
    +                // values
    +                PFrame pyFrame = materialize.execute(frame, callNode, false, true);
    +                assert thisInfo.getPyFrame() == pyFrame;
    +                assert pyFrame.getRef() == thisInfo;
                     thisInfo.setCallNode(callNode);
                     PArguments.setCallerFrameInfo(callArguments, thisInfo);
                 }
    -            if (needsExceptionState) {
    -                if (!neededExceptionState) {
    -                    CompilerDirectives.transferToInterpreterAndInvalidate();
    -                    neededExceptionState = true;
    -                }
    -                AbstractTruffleException curExc;
    -                if (isPythonFrame(frame, callNode)) {
    -                    curExc = PArguments.getException(frame);
    -                    if (curExc == null) {
    -                        CompilerDirectives.transferToInterpreterAndInvalidate();
    -                        AbstractTruffleException fromStackWalk = GetCaughtExceptionNode.fullStackWalk();
    -                        curExc = fromStackWalk != null ? fromStackWalk : PException.NO_EXCEPTION;
    -                        // now, set in our args, such that we won't do this again
    -                        PArguments.setException(frame, curExc);
    -                    }
    -                } else {
    -                    // If we're here, it can only be because some top-level call
    -                    // inside Python led us here
    -                    curExc = PException.NO_EXCEPTION;
    -                }
    -                PArguments.setException(callArguments, curExc);
    -            }
    -        }
     
    -        private PFrame materialize(VirtualFrame frame, Node callNode, boolean markAsEscaped, boolean forceSync) {
    -            if (adoptable) {
    -                return ensureMaterializeNode().execute(frame, callNode, markAsEscaped, forceSync);
    +            @Specialization(guards = {"needsCallerFrame", "!isPythonFrame(frame)"})
    +            protected static void passEmptyCallerFrame(VirtualFrame frame, Node inliningTarget, Object[] callArguments, Node callNode, boolean needsCallerFrame) {
    +                PArguments.setCallerFrameInfo(callArguments, PFrame.Reference.EMPTY);
                 }
    -            return MaterializeFrameNode.getUncached().execute(frame, callNode, markAsEscaped, forceSync);
             }
     
    -        private boolean isPythonFrame(VirtualFrame frame, Node callNode) {
    -            if (isPythonFrameProfile == null) {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                isPythonFrameProfile = ConditionProfile.create();
    +        @GenerateCached(false)
    +        @GenerateUncached
    +        @GenerateInline
    +        @ImportStatic(PArguments.class)
    +        protected abstract static class PassExceptionStateNode extends Node {
    +
    +            /*
    +             * This may seem a bit odd on first sight, but it's straightforward with a bit of
    +             * explanation:
    +             *
    +             * 1. Most callees won't need exception state, so that is the first specialization. We
    +             * pass the NO_EXCEPTION marker if we have it though.
    +             *
    +             * 2. If we call a callee that needs exception state, the first time around we likely do
    +             * not have it, so we do a stack walk. If this is a top level function e.g. always
    +             * called from a new Python lambda or something like that in an embedding, we will get
    +             * stuck in this specialization, but that's the best we can do and it's straight line
    +             * code with a boundary call.
    +             *
    +             * 3. If we come around again in normal Python code, we'll likely have exception state
    +             * now because the caller passed it. If this caller is the only one that needs to pass
    +             * exception state (maybe all other callers do not trigger code paths that need it) we
    +             * will never have to walk the stack again. So we *replace* the specialization that does
    +             * the stack walk with one that never does so there are just guards and no full branches
    +             * in the compiled code.
    +             *
    +             * 4. If we get into the situation again that we need to pass exception state, but do
    +             * not have it, this means we got invoked from another call site that did not pass the
    +             * exception state. We resist the tempation to be fancy here. We'll switch to putting
    +             * the stack walk in the compiled code with a profile to inject how probable the stack
    +             * walk is. We'll just have to hope the compiler does something decent with it. We also
    +             * report this as an expensive specialization using the @Megamorphic annotation, so
    +             * Truffle might be more inclined to split.
    +             *
    +             * 5. The last and least likely scenario is that this is directly a call from an
    +             * embedding, e.g. via the #execute interop message. We trivially won't have an active
    +             * exception in this case.
    +             */
    +            protected abstract void execute(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState);
    +
    +            @Specialization(guards = {"!needsExceptionState"})
    +            protected static void dontPassExceptionState(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState,
    +                            @Cached InlinedConditionProfile hasNoException) {
    +                AbstractTruffleException curExc = PArguments.getException(frame);
    +                if (hasNoException.profile(inliningTarget, curExc == PException.NO_EXCEPTION)) {
    +                    PArguments.setException(callArguments, curExc);
    +                }
                 }
    -            boolean result = isPythonFrameProfile.profile(PArguments.isPythonFrame(frame));
    -            assert result || callNode.getRootNode() instanceof TopLevelExceptionHandler : "calling from non-Python or non-top-level frame";
    -            return result;
    -        }
     
    -        private MaterializeFrameNode ensureMaterializeNode() {
    -            if (materializeNode == null) {
    -                CompilerDirectives.transferToInterpreterAndInvalidate();
    -                materializeNode = insert(MaterializeFrameNodeGen.create());
    +            @Specialization(guards = {"needsExceptionState", "isPythonFrame(frame)", "getException(frame) == null"})
    +            protected static void passExceptionStateFromStackWalk(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState) {
    +                AbstractTruffleException fromStackWalk = GetCaughtExceptionNode.fullStackWalk();
    +                if (fromStackWalk == null) {
    +                    fromStackWalk = PException.NO_EXCEPTION;
    +                }
    +                // set it also in our args, such that we won't stack walk again in later calls that
    +                // start with this frame
    +                PArguments.setException(frame, fromStackWalk);
    +                PArguments.setException(callArguments, fromStackWalk);
                 }
    -            return materializeNode;
     
    -        }
    +            @Specialization(guards = {"needsExceptionState", "isPythonFrame(frame)", "curExc != null"}, replaces = "passExceptionStateFromStackWalk")
    +            protected static void passGivenExceptionState(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState,
    +                            @Bind("getException(frame)") AbstractTruffleException curExc) {
    +                PArguments.setException(callArguments, curExc);
    +            }
     
    -        @Override
    -        public boolean isAdoptable() {
    -            return adoptable;
    -        }
    +            @ReportPolymorphism.Megamorphic
    +            @Specialization(guards = {"needsExceptionState", "isPythonFrame(frame)"}, replaces = "passGivenExceptionState")
    +            protected static void passExceptionStateFromFrameOrStack(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState,
    +                            @Cached InlinedCountingConditionProfile needsStackWalk) {
    +                AbstractTruffleException curExc = PArguments.getException(frame);
    +                if (needsStackWalk.profile(inliningTarget, curExc == null)) {
    +                    passExceptionStateFromStackWalk(frame, inliningTarget, callArguments, needsExceptionState);
    +                } else {
    +                    passGivenExceptionState(frame, inliningTarget, callArguments, needsExceptionState, curExc);
    +                }
    +            }
     
    -        @NeverDefault
    -        public static CallContext create() {
    -            return new CallContext(true);
    +            @Specialization(guards = {"needsExceptionState", "!isPythonFrame(frame)"})
    +            protected static void passNoExceptionState(VirtualFrame frame, Node inliningTarget, Object[] callArguments, boolean needsExceptionState) {
    +                // If we're here, it can only be because some top-level call
    +                // inside Python led us here
    +                PArguments.setException(callArguments, PException.NO_EXCEPTION);
    +            }
             }
     
    -        public static CallContext getUncached() {
    -            return INSTANCE;
    +        @Specialization
    +        protected static void prepareCall(VirtualFrame frame, Object[] callArguments, Node callNode, boolean needsCallerFrame, boolean needsExceptionState,
    +                        @Bind Node inliningTarget,
    +                        @Cached PassCallerFrameNode passCallerFrame,
    +                        @Cached PassExceptionStateNode passExceptionState) {
    +            assert PArguments.isPythonFrame(frame) || callNode.getRootNode() instanceof TopLevelExceptionHandler : "calling from non-Python or non-top-level frame";
    +            passCallerFrame.execute(frame, inliningTarget, callArguments, callNode, needsCallerFrame);
    +            passExceptionState.execute(frame, inliningTarget, callArguments, needsExceptionState);
             }
         }
     
    
    From 6c8088452e27c2a8d50b9f52b5b4bfaed7f7b46f Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Tue, 4 Mar 2025 10:39:40 +0100
    Subject: [PATCH 124/512] Basic running of mx python-style --fix on Windows
    
    ---
     mx.graalpython/mx_graalpython.py | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py
    index e2eb6563b0..04ca1a3e35 100644
    --- a/mx.graalpython/mx_graalpython.py
    +++ b/mx.graalpython/mx_graalpython.py
    @@ -536,7 +536,7 @@ def find_eclipse():
                                                      for f in os.listdir(pardir)]:
             if os.path.basename(f) == "eclipse" and os.path.isdir(f):
                 mx.log("Automatically choosing %s for Eclipse" % f)
    -            eclipse_exe = os.path.join(f, "eclipse")
    +            eclipse_exe = os.path.join(f, f"eclipse{'.exe' if mx.is_windows() else ''}")
                 if os.path.exists(eclipse_exe):
                     os.environ["ECLIPSE_EXE"] = eclipse_exe
                     return
    @@ -2101,6 +2101,9 @@ def python_style_checks(args):
     
     
     def python_checkcopyrights(args):
    +    if mx.is_windows():
    +        # skip, broken with crlf stuff
    +        return
         # we wan't to ignore lib-python/3, because that's just crazy
         listfilename = tempfile.mktemp()
         with open(listfilename, "w") as listfile:
    
    From 9fc72e9807bed0d7af7d6c0a6cd03abdd1541724 Mon Sep 17 00:00:00 2001
    From: Tomas Stupka 
    Date: Thu, 6 Mar 2025 15:03:42 +0100
    Subject: [PATCH 125/512] @Input-s cleanup in AbstractPackagesTask
    
    ---
     .../graalvm/python/GraalPyGradlePlugin.java   | 20 +++++++---
     .../python/tasks/AbstractPackagesTask.java    | 38 +++----------------
     .../python/tasks/InstallPackagesTask.java     |  2 +-
     .../python/tasks/LockPackagesTask.java        |  4 +-
     4 files changed, 22 insertions(+), 42 deletions(-)
    
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java
    index ab92c94d36..6cf8920df6 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/GraalPyGradlePlugin.java
    @@ -56,9 +56,11 @@
     import org.gradle.api.file.Directory;
     import org.gradle.api.file.DirectoryProperty;
     import org.gradle.api.file.ProjectLayout;
    +import org.gradle.api.file.RegularFile;
     import org.gradle.api.plugins.JavaPlugin;
     import org.gradle.api.plugins.JavaPluginExtension;
     import org.gradle.api.provider.Provider;
    +import org.gradle.api.tasks.Internal;
     import org.gradle.api.tasks.SourceSet;
     import org.gradle.api.tasks.TaskProvider;
     import org.gradle.jvm.tasks.Jar;
    @@ -74,6 +76,7 @@
     
     import static org.graalvm.python.embedding.tools.vfs.VFSUtils.GRAALPY_GROUP_ID;
     import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT;
    +import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV;
     
     public abstract class GraalPyGradlePlugin implements Plugin {
         private static final String LAUNCHER_CONFIGURATION_NAME = "pythonLauncherClasspath";
    @@ -211,8 +214,6 @@ private TaskProvider registerInstallPackagesTask(Project pr
         private TaskProvider registerLockPackagesTask(Project project, Configuration launcherClasspath, GraalPyExtension extension) {
             return project.getTasks().register(GRAALPY_LOCK_PACKAGES_TASK, LockPackagesTask.class, t -> {
                 registerPackagesTask(project, launcherClasspath, extension, t);
    -            // TODO probably not necessary
    -            // t.getOutputs().upToDateWhen(tt -> false);
             });
         }
     
    @@ -227,11 +228,18 @@ private void registerPackagesTask(Project project, Configuration launcherClasspa
             t.getPackages().set(extension.getPackages());
     
             DirectoryProperty externalDirectory = extension.getExternalDirectory();
    -        t.getOutput().convention(externalDirectory.orElse(extension.getPythonResourcesDirectory().orElse(buildDirectory.dir(DEFAULT_RESOURCES_DIRECTORY))));
    -        t.getIncludeVfsRoot().convention(externalDirectory.map(d -> false).orElse(extension.getPythonResourcesDirectory().map(d -> false).orElse(true)));
    -        t.getResourceDirectory().set(extension.getResourceDirectory());
    +        Directory output = externalDirectory.orElse(extension.getPythonResourcesDirectory().orElse(buildDirectory.dir(DEFAULT_RESOURCES_DIRECTORY))).get();
    +        t.getOutput().convention(output);
     
    -        t.getGraalPyLockFile().convention(extension.getGraalPyLockFile().orElse(projectDirectory.file(GRAALPY_LOCK_FILE)));
    +        String vfsRoot = externalDirectory.isPresent() ? "" : extension.getResourceDirectory().getOrElse(VFS_ROOT);
    +        t.getVenvDirectory().set(output.getAsFile().toPath().resolve(vfsRoot).resolve(VFS_VENV).toFile());
    +
    +        RegularFile graalPyLockFile = extension.getGraalPyLockFile().orElse(projectDirectory.file(GRAALPY_LOCK_FILE)).get();
    +        File glfFile = graalPyLockFile.getAsFile();
    +        if(!glfFile.isAbsolute()) {
    +            graalPyLockFile = projectDirectory.file(glfFile.getPath());
    +        }
    +        t.getGraalPyLockFile().set(graalPyLockFile);
     
             t.setGroup(GRAALPY_GRADLE_PLUGIN_TASK_GROUP);
         }
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    index 6216ee7b89..f761ef341c 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java
    @@ -66,8 +66,6 @@
     import java.util.stream.Collectors;
     
     import static org.graalvm.python.embedding.tools.vfs.VFSUtils.LAUNCHER_NAME;
    -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_ROOT;
    -import static org.graalvm.python.embedding.tools.vfs.VFSUtils.VFS_VENV;
     
     /**
      * This task is responsible installing the dependencies which were requested by the user.
    @@ -121,11 +119,6 @@ public abstract class AbstractPackagesTask extends DefaultTask {
                    
             """;
     
    -    /** @see #getOutput() */
    -    @Input
    -    @Optional
    -    public abstract Property getIncludeVfsRoot();
    -
         @Input
         public abstract ListProperty getPackages();
     
    @@ -143,20 +136,15 @@ public abstract class AbstractPackagesTask extends DefaultTask {
          */
         @OutputDirectory
         public abstract DirectoryProperty getOutput();
    -    
    -    /**
    -     * The directory where the VFS should be generated within Java resources, i.e., applied only when
    -     * {@link #getIncludeVfsRoot()} is set.
    -     */
    -    @Input
    -    @Optional
    -    public abstract Property getResourceDirectory();
     
         @InputFiles
         @Optional
         @PathSensitive(PathSensitivity.RELATIVE)
         public abstract RegularFileProperty getGraalPyLockFile();
     
    +    @Internal
    +    public abstract RegularFileProperty getVenvDirectory();
    +
         /**
          * Desired polyglot runtime and GraalPy version.
          */
    @@ -189,25 +177,9 @@ protected Path computeLauncherDirectory() {
             return getLauncherDirectory().get().getAsFile().toPath();
         }
     
    -    @Internal
    -    protected Path getVenvDirectory() {
    -        // XXX why not convention?
    -        // XXX skip external/resouces dir and set venv dir from task config
    -        String path = "";
    -        if (getIncludeVfsRoot().getOrElse(true)) {
    -            path = getResourceDirectory().getOrElse(VFS_ROOT);
    -        }
    -
    -        return Path.of(getOutput().get().getAsFile().toURI()).resolve(path).resolve(VFS_VENV);
    -    }
    -
         @Internal
         protected Path getLockFilePath() {
    -        Path rfp = getGraalPyLockFile().get().getAsFile().toPath();
    -        if(rfp.isAbsolute()) {
    -            return rfp;
    -        } else {
    -            return getProject().file(getGraalPyLockFile().get()).toPath();
    -        }
    +        return getGraalPyLockFile().get().getAsFile().toPath();
         }
    +
     }
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    index 3b4e9abc02..dd592e2203 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java
    @@ -67,7 +67,7 @@
     public abstract class InstallPackagesTask extends AbstractPackagesTask {
         @TaskAction
         public void exec() throws GradleException {
    -        Path venvDirectory = getVenvDirectory();
    +        Path venvDirectory = getVenvDirectory().get().getAsFile().toPath();
             try {
                 VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(),  getPolyglotVersion().get(), getLog());
             } catch (IOException e) {
    diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    index 62a9763db4..bbfcf6f60b 100644
    --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java
    @@ -62,9 +62,9 @@ public abstract class LockPackagesTask extends AbstractPackagesTask {
         public void exec() throws GradleException {
             checkEmptyPackages();
     
    -        Path venvDirectory = getVenvDirectory();
    +        Path venvDirectory = getVenvDirectory().get().getAsFile().toPath();
             try {
    -            VFSUtils.lockPackages(getVenvDirectory(), getPackages().get(), getLockFilePath(), LOCK_FILE_HEADER, createLauncher(), getPolyglotVersion().get(), getLog());
    +            VFSUtils.lockPackages(venvDirectory, getPackages().get(), getLockFilePath(), LOCK_FILE_HEADER, createLauncher(), getPolyglotVersion().get(), getLog());
             } catch (IOException e) {
                 throw new GradleException(String.format("failed to lock packages in python virtual environment %s", venvDirectory), e);
             }
    
    From 38fc8b846d29f55d3218086e6276dd14ea205e98 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Fri, 21 Feb 2025 18:48:03 +0100
    Subject: [PATCH 126/512] Add live heap benchmarks
    
    ---
     .../python/heap/allocate-objects.py           | 51 ++++++++++
     .../python/heap/import-a-lot.py               | 65 +++++++++++++
     .../python/heap/post-startup.py               | 45 +++++++++
     mx.graalpython/live_heap_tracker.py           | 75 +++++++++++++++
     mx.graalpython/mx_graalpython.py              |  8 +-
     mx.graalpython/mx_graalpython_bench_param.py  | 11 ++-
     mx.graalpython/mx_graalpython_benchmark.py    | 96 +++++++++++++++++--
     7 files changed, 339 insertions(+), 12 deletions(-)
     create mode 100644 graalpython/com.oracle.graal.python.benchmarks/python/heap/allocate-objects.py
     create mode 100644 graalpython/com.oracle.graal.python.benchmarks/python/heap/import-a-lot.py
     create mode 100644 graalpython/com.oracle.graal.python.benchmarks/python/heap/post-startup.py
     create mode 100644 mx.graalpython/live_heap_tracker.py
    
    diff --git a/graalpython/com.oracle.graal.python.benchmarks/python/heap/allocate-objects.py b/graalpython/com.oracle.graal.python.benchmarks/python/heap/allocate-objects.py
    new file mode 100644
    index 0000000000..64eb36ed03
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python.benchmarks/python/heap/allocate-objects.py
    @@ -0,0 +1,51 @@
    +# Copyright (c) 2025, 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.
    +
    +import time
    +
    +class MyObject:
    +    def __init__(self, name, value):
    +        self.name = name
    +        self.value = value
    +
    +objects = [MyObject("foo", 42) for i in range(10 ** 6)]
    +
    +# Sleep a bit to shake out weakref callbacks and get more measurement samples
    +for i in range(30):
    +    time.sleep(0.1)
    diff --git a/graalpython/com.oracle.graal.python.benchmarks/python/heap/import-a-lot.py b/graalpython/com.oracle.graal.python.benchmarks/python/heap/import-a-lot.py
    new file mode 100644
    index 0000000000..ffbde613c6
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python.benchmarks/python/heap/import-a-lot.py
    @@ -0,0 +1,65 @@
    +# Copyright (c) 2025, 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.
    +
    +# Measure the heap after importing many modules
    +import time
    +import urllib.request, urllib.parse
    +import pickle
    +import os
    +import xmlrpc
    +import json
    +import email
    +import multiprocessing
    +import re
    +import concurrent.futures
    +import collections
    +import inspect
    +import hashlib
    +import decimal
    +import fractions
    +import unittest
    +import contextlib
    +import configparser
    +import tomllib
    +import argparse
    +import subprocess
    +
    +# Sleep a bit to shake out weakref callbacks and get more measurement samples
    +for i in range(30):
    +    time.sleep(0.1)
    diff --git a/graalpython/com.oracle.graal.python.benchmarks/python/heap/post-startup.py b/graalpython/com.oracle.graal.python.benchmarks/python/heap/post-startup.py
    new file mode 100644
    index 0000000000..109dace077
    --- /dev/null
    +++ b/graalpython/com.oracle.graal.python.benchmarks/python/heap/post-startup.py
    @@ -0,0 +1,45 @@
    +# Copyright (c) 2025, 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.
    +
    +# Measure the heap after startup
    +import time
    +
    +# Sleep a bit to shake out weakref callbacks and get more measurement samples
    +for i in range(30):
    +    time.sleep(0.1)
    diff --git a/mx.graalpython/live_heap_tracker.py b/mx.graalpython/live_heap_tracker.py
    new file mode 100644
    index 0000000000..ad99b581b3
    --- /dev/null
    +++ b/mx.graalpython/live_heap_tracker.py
    @@ -0,0 +1,75 @@
    +# Copyright (c) 2025, 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.
    +
    +import sys
    +import time
    +
    +import re
    +import subprocess
    +
    +TOTAL_RE = re.compile(r'^Total +\d+ +(\d+)', re.MULTILINE)
    +
    +
    +def main():
    +    output_file = sys.argv[1]
    +    iterations = int(sys.argv[2])
    +    jmap_binary = sys.argv[3]
    +    benchmark = sys.argv[4:]
    +    with open(output_file, 'w') as f:
    +        for _ in range(iterations):
    +            proc = subprocess.Popen(benchmark)
    +            while proc.poll() is None:
    +                time.sleep(0.3)
    +                try:
    +                    jmap_output = subprocess.check_output(
    +                        [jmap_binary, '-histo:live', str(proc.pid)],
    +                        universal_newlines=True,
    +                        stderr=subprocess.DEVNULL,
    +                    )
    +                    if match := TOTAL_RE.search(jmap_output):
    +                        heap_bytes = int(match.group(1))
    +                        f.write(f'{heap_bytes}\n')
    +                except subprocess.CalledProcessError:
    +                    pass
    +            if proc.returncode != 0:
    +                sys.exit(proc.returncode)
    +
    +
    +if __name__ == '__main__':
    +    main()
    diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py
    index 04ca1a3e35..cdf83ad74b 100644
    --- a/mx.graalpython/mx_graalpython.py
    +++ b/mx.graalpython/mx_graalpython.py
    @@ -71,7 +71,8 @@
     from mx_graalpython_gradleproject import GradlePluginProject #pylint: disable=unused-import
     
     from mx_gate import Task
    -from mx_graalpython_bench_param import PATH_MESO, BENCHMARKS, WARMUP_BENCHMARKS, JAVA_DRIVER_BENCHMARKS
    +from mx_graalpython_bench_param import PATH_MESO, BENCHMARKS, WARMUP_BENCHMARKS, JAVA_DRIVER_BENCHMARKS, \
    +    HEAP_BENCHMARKS
     from mx_graalpython_benchmark import PythonBenchmarkSuite, python_vm_registry, CPythonVm, PyPyVm, JythonVm, \
         GraalPythonVm, \
         CONFIGURATION_DEFAULT, CONFIGURATION_SANDBOXED, CONFIGURATION_NATIVE, \
    @@ -82,7 +83,8 @@
         CONFIGURATION_NATIVE_INTERPRETER_MULTI, PythonJavaEmbeddingBenchmarkSuite, python_java_embedding_vm_registry, \
         GraalPythonJavaDriverVm, CONFIGURATION_JAVA_EMBEDDING_INTERPRETER_MULTI_SHARED, \
         CONFIGURATION_JAVA_EMBEDDING_INTERPRETER_MULTI, CONFIGURATION_JAVA_EMBEDDING_MULTI_SHARED, \
    -    CONFIGURATION_JAVA_EMBEDDING_MULTI, CONFIGURATION_PANAMA, PythonJMHDistMxBenchmarkSuite
    +    CONFIGURATION_JAVA_EMBEDDING_MULTI, CONFIGURATION_PANAMA, PythonJMHDistMxBenchmarkSuite, \
    +    PythonHeapBenchmarkSuite
     
     if not sys.modules.get("__main__"):
         # workaround for pdb++
    @@ -2314,6 +2316,8 @@ def _register_bench_suites(namespace):
         for py_bench_suite in PythonVmWarmupBenchmarkSuite.get_benchmark_suites(WARMUP_BENCHMARKS):
             mx_benchmark.add_bm_suite(py_bench_suite)
         mx_benchmark.add_bm_suite(PythonJMHDistMxBenchmarkSuite())
    +    for py_bench_suite in PythonHeapBenchmarkSuite.get_benchmark_suites(HEAP_BENCHMARKS):
    +        mx_benchmark.add_bm_suite(py_bench_suite)
     
     
     class CharsetFilteringPariticpant:
    diff --git a/mx.graalpython/mx_graalpython_bench_param.py b/mx.graalpython/mx_graalpython_bench_param.py
    index 2833b14bfd..d0ec69ee43 100644
    --- a/mx.graalpython/mx_graalpython_bench_param.py
    +++ b/mx.graalpython/mx_graalpython_bench_param.py
    @@ -1,4 +1,4 @@
    -# Copyright (c) 2017, 2024, Oracle and/or its affiliates.
    +# Copyright (c) 2017, 2025, Oracle and/or its affiliates.
     # Copyright (c) 2013, Regents of the University of California
     #
     # All rights reserved.
    @@ -39,6 +39,7 @@
     PATH_WARMUP = os.path.join(_BASE_PATH, 'warmup')
     PATH_INTEROP = os.path.join(_BASE_PATH, 'host_interop')
     PATH_JAVA_EMBEDDING = os.path.join(_BASE_PATH, 'java-embedding')
    +PATH_HEAP = os.path.join(_BASE_PATH, 'heap')
     
     # ----------------------------------------------------------------------------------------------------------------------
     #
    @@ -331,3 +332,11 @@ def _pickling_benchmarks(module='pickle'):
     WARMUP_BENCHMARKS = {
         "python-warmup": [PATH_WARMUP, WARMUP_BENCHMARKS],
     }
    +
    +HEAP_BENCHMARKS = {
    +    "heap": [PATH_HEAP, {
    +        "post-startup": [],
    +        "import-a-lot": [],
    +        "allocate-objects": [],
    +    }]
    +}
    diff --git a/mx.graalpython/mx_graalpython_benchmark.py b/mx.graalpython/mx_graalpython_benchmark.py
    index d6fe937cfd..28079a290d 100644
    --- a/mx.graalpython/mx_graalpython_benchmark.py
    +++ b/mx.graalpython/mx_graalpython_benchmark.py
    @@ -1,4 +1,4 @@
    -# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
    +# Copyright (c) 2018, 2025, Oracle and/or its affiliates.
     # Copyright (c) 2013, Regents of the University of California
     #
     # All rights reserved.
    @@ -23,12 +23,17 @@
     # OF THE POSSIBILITY OF SUCH DAMAGE.
     from __future__ import print_function
     
    +import statistics
    +import sys
    +
     import os
     import re
     import subprocess
     from abc import ABCMeta, abstractproperty, abstractmethod
     from contextlib import contextmanager
     from os.path import join
    +from datetime import datetime
    +from pathlib import Path
     
     import mx
     import mx_benchmark
    @@ -41,6 +46,7 @@
     #
     # ----------------------------------------------------------------------------------------------------------------------
     SUITE = mx.suite("graalpython")
    +DIR = Path(__file__).parent.resolve()
     
     # ----------------------------------------------------------------------------------------------------------------------
     #
    @@ -89,11 +95,6 @@
     # utils
     #
     # ----------------------------------------------------------------------------------------------------------------------
    -def _check_vm_args(name, args):
    -    if len(args) < 2:
    -        mx.abort("Expected at least 2 args (a single benchmark path in addition to the harness), "
    -                 "got {} instead".format(args))
    -
     
     def is_sandboxed_configuration(conf):
         return conf in (CONFIGURATION_SANDBOXED, CONFIGURATION_SANDBOXED_MULTI)
    @@ -187,7 +188,6 @@ def interpreter(self):
             return None
     
         def run(self, cwd, args):
    -        _check_vm_args(self.name(), args)
             out = mx.OutputCapture()
             stdout_capture = mx.TeeOutputCapture(out)
             ret_code = mx.run([self.interpreter] + args, out=stdout_capture, err=stdout_capture, env=self._env)
    @@ -294,7 +294,6 @@ def interpreter(self):
         def run(self, cwd, args):
             jar = mx.get_env(ENV_JYTHON_JAR)
             if jar:
    -            _check_vm_args(self.name(), args)
                 host_vm = self.host_vm()
     
                 vm_args = mx.get_runtime_jvm_args([])
    @@ -364,7 +363,6 @@ def _remove_vm_prefix(argument):
                 return argument
     
         def run(self, cwd, args):
    -        _check_vm_args(self.name(), args)
             extra_polyglot_args = self.get_extra_polyglot_args()
     
             host_vm = self.host_vm()
    @@ -1031,3 +1029,83 @@ def filter_distribution(self, dist):
             # but by overriding this method we fix that and also get the nice property
             # that one cannot accidentally run some other JMH benchmarks via this class
             return dist.name == 'GRAALPYTHON_BENCH'
    +
    +
    +class LiveHeapTracker(mx_benchmark.Tracker):
    +    def __init__(self, bmSuite):
    +        super().__init__(bmSuite)
    +        self.out_file = None
    +
    +    def map_command(self, cmd):
    +        bench_name = self.bmSuite.currently_running_benchmark() if self.bmSuite else "benchmark"
    +        if self.bmSuite:
    +            bench_name = f"{self.bmSuite.name()}-{bench_name}"
    +        ts = datetime.now().strftime("%Y%m%d-%H%M%S")
    +        jmap_command = mx.get_jdk().exe_path('jmap')
    +        self.out_file = os.path.join(os.getcwd(), f"heap_tracker_{bench_name}_{ts}.txt")
    +        iterations = 3
    +        return [sys.executable, str(DIR / 'live_heap_tracker.py'), self.out_file, str(iterations), jmap_command, *cmd]
    +
    +    def get_rules(self, bmSuiteArgs):
    +        return [self.LiveHeapRule(self, bmSuiteArgs)]
    +
    +    class LiveHeapRule(mx_benchmark.Rule):
    +        def __init__(self, tracker, bmSuiteArgs):
    +            self.tracker = tracker
    +            self.bmSuiteArgs = bmSuiteArgs
    +
    +        def parse(self, text):
    +            with open(self.tracker.out_file) as f:
    +                heap_mb = [int(line.strip()) / (1024 ** 2) for line in f if line]
    +            os.unlink(self.tracker.out_file)
    +            self.tracker.out_file = None
    +            deciles = statistics.quantiles(heap_mb, n=10)
    +            print(f"Heap size deciles (MiB): {deciles}")
    +            return [
    +                {
    +                    "benchmark": self.tracker.bmSuite.currently_running_benchmark(),
    +                    "bench-suite": self.tracker.bmSuite.benchSuiteName(self.bmSuiteArgs),
    +                    "config.vm-flags": ' '.join(self.tracker.bmSuite.vmArgs(self.bmSuiteArgs)),
    +                    "metric.name": "allocated-memory",
    +                    "metric.value": deciles[-1],
    +                    "metric.unit": "MB",
    +                    "metric.type": "numeric",
    +                    "metric.score-function": "id",
    +                    "metric.better": "lower",
    +                    "metric.iteration": 0
    +                }
    +            ]
    +
    +
    +class PythonHeapBenchmarkSuite(PythonBaseBenchmarkSuite):
    +    def __init__(self, name, bench_path, benchmarks):
    +        super().__init__(name, benchmarks)
    +        super().register_tracker('live-heap', LiveHeapTracker)
    +        self._bench_path = bench_path
    +
    +    def get_vm_registry(self):
    +        return python_vm_registry
    +
    +    def rules(self, output, benchmarks, bm_suite_args):
    +        return []  # Tracker will add a rule
    +
    +    def register_tracker(self, name, tracker_type):
    +        # We don't want any other trackers
    +        pass
    +
    +    def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
    +        benchmark = benchmarks[0]
    +        bench_path = os.path.join(self._bench_path, f'{benchmark}.py')
    +        return [*self.vmArgs(bmSuiteArgs), bench_path, *self.runArgs(bmSuiteArgs)]
    +
    +    def successPatterns(self):
    +        return []
    +
    +    def failurePatterns(self):
    +        return []
    +
    +    @classmethod
    +    def get_benchmark_suites(cls, benchmarks):
    +        assert isinstance(benchmarks, dict), "benchmarks must be a dict: {suite: [path, {bench: args, ... }], ...}"
    +        return [cls(suite_name, suite_info[0], suite_info[1])
    +                for suite_name, suite_info in benchmarks.items()]
    
    From 51f583bd8ddfa77ac7f530b71557f5cd95b273fc Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Wed, 5 Mar 2025 18:08:23 +0100
    Subject: [PATCH 127/512] Update overlay
    
    ---
     ci.jsonnet | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/ci.jsonnet b/ci.jsonnet
    index cd8ecb9bf4..ce99393b4c 100644
    --- a/ci.jsonnet
    +++ b/ci.jsonnet
    @@ -1 +1 @@
    -{ "overlay": "0edef0e6e6ab7aafc365b13e12078537e28bcb96" }
    +{ "overlay": "e7117a989914a1d1a4cf85ffc55ff81ef8a6046d" }
    
    From c9dbf6125b58e83c4e1999be4538b1ada70a3270 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 13 Feb 2025 10:32:23 +0100
    Subject: [PATCH 128/512] Avoid copying bytecode for quickening
    
    ---
     .../modules/MarshalModuleBuiltins.java        |  2 +-
     .../python/builtins/objects/code/PCode.java   |  8 +---
     .../graal/python/compiler/CodeUnit.java       | 42 +++++++++++++++----
     .../nodes/bytecode/PBytecodeRootNode.java     |  2 +-
     4 files changed, 39 insertions(+), 15 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java
    index d858f0ee50..4ade7eee38 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java
    @@ -1300,7 +1300,7 @@ private void writeCodeUnit(CodeUnit code) throws IOException {
                 writeInt(code.kwOnlyArgCount);
                 writeInt(code.positionalOnlyArgCount);
                 writeInt(code.stacksize);
    -            writeBytes(code.code);
    +            writeBytes(code.getBytecodeForSerialization());
                 writeBytes(code.srcOffsetTable);
                 writeInt(code.flags);
                 writeStringArray(code.names);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    index fed0025ac1..137d885cc6 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java
    @@ -696,12 +696,8 @@ public String toDisassembledString(boolean quickened) {
             } else if (rootNode instanceof PBytecodeGeneratorFunctionRootNode r) {
                 rootNode = r.getBytecodeRootNode();
             }
    -        if (rootNode instanceof PBytecodeRootNode) {
    -            CodeUnit code = ((PBytecodeRootNode) rootNode).getCodeUnit();
    -            if (quickened) {
    -                return code.toString(((PBytecodeRootNode) rootNode).getBytecode());
    -            }
    -            return code.toString();
    +        if (rootNode instanceof PBytecodeRootNode bytecodeRootNode) {
    +            return bytecodeRootNode.getCodeUnit().toString(quickened);
             }
             return J_EMPTY_STRING;
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java
    index 6e3a92b444..0025ae6f37 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java
    @@ -80,6 +80,7 @@ public final class CodeUnit {
     
         public final int stacksize;
     
    +    // Note this is being mutated when quickening
         @CompilationFinal(dimensions = 1) public final byte[] code;
         @CompilationFinal(dimensions = 1) public final byte[] srcOffsetTable;
         public final int flags;
    @@ -227,10 +228,10 @@ public int getTotalArgCount() {
         @SuppressWarnings("fallthrough")
         @Override
         public String toString() {
    -        return toString(code);
    +        return toString(false);
         }
     
    -    public String toString(byte[] bytecode) {
    +    public String toString(boolean quickened) {
             StringBuilder sb = new StringBuilder();
     
             HashMap lines = new HashMap<>();
    @@ -254,9 +255,13 @@ public String toString(byte[] bytecode) {
             int bci = 0;
             int oparg = 0;
             SourceMap map = getSourceMap();
    -        while (bci < bytecode.length) {
    +        while (bci < code.length) {
                 int bcBCI = bci;
    -            OpCodes opcode = OpCodes.fromOpCode(bytecode[bci++]);
    +            OpCodes opcode = OpCodes.fromOpCode(code[bci++]);
    +
    +            if (!quickened) {
    +                opcode = unquicken(opcode);
    +            }
     
                 String[] line = lines.computeIfAbsent(bcBCI, k -> new String[DISASSEMBLY_NUM_COLUMNS]);
                 line[0] = String.format("%3d:%-3d - %3d:%-3d", map.startLineMap[bcBCI], map.startColumnMap[bcBCI], map.endLineMap[bcBCI], map.endColumnMap[bcBCI]);
    @@ -269,11 +274,11 @@ public String toString(byte[] bytecode) {
                 if (!opcode.hasArg()) {
                     line[4] = "";
                 } else {
    -                oparg |= Byte.toUnsignedInt(bytecode[bci++]);
    +                oparg |= Byte.toUnsignedInt(code[bci++]);
                     if (opcode.argLength > 1) {
                         followingArgs = new byte[opcode.argLength - 1];
                         for (int i = 0; i < opcode.argLength - 1; i++) {
    -                        followingArgs[i] = bytecode[bci++];
    +                        followingArgs[i] = code[bci++];
                         }
                     }
                     line[4] = String.format("% 2d", oparg);
    @@ -460,7 +465,7 @@ public String toString(byte[] bytecode) {
                 }
             }
     
    -        for (bci = 0; bci < bytecode.length; bci++) {
    +        for (bci = 0; bci < code.length; bci++) {
                 String[] line = lines.get(bci);
                 if (line != null) {
                     line[5] = line[5] == null ? "" : String.format("(%s)", line[5]);
    @@ -767,6 +772,7 @@ private static int opCodeAt(byte[] bytecode, int bci, BytecodeAction action) {
                 bci += 2;
                 op = OpCodes.fromOpCode(bytecode[bci]);
             }
    +        op = unquicken(op);
             byte[] followingArgs = null;
             if (op.argLength > 0) {
                 oparg |= Byte.toUnsignedInt(bytecode[bci + 1]);
    @@ -788,4 +794,26 @@ public static void iterateBytecode(byte[] bytecode, BytecodeAction action) {
         public void iterateBytecode(BytecodeAction action) {
             iterateBytecode(code, action);
         }
    +
    +    public byte[] getBytecodeForSerialization() {
    +        byte[] bytecode = Arrays.copyOf(code, code.length);
    +        for (int bci = 0; bci < bytecode.length;) {
    +            OpCodes op = OpCodes.fromOpCode(bytecode[bci]);
    +            bytecode[bci] = (byte) unquicken(op).ordinal();
    +            bci += op.length();
    +        }
    +        return bytecode;
    +    }
    +
    +    private static OpCodes unquicken(OpCodes op) {
    +        if (op.quickens == null) {
    +            return op;
    +        }
    +        return switch (op.quickens) {
    +            // These are already quickened by the compiler, so keep them quickened
    +            // See CompilationUnit.emitBytecode
    +            case LOAD_BYTE, LOAD_INT, LOAD_LONG, LOAD_DOUBLE, LOAD_TRUE, LOAD_FALSE -> op;
    +            default -> op.quickens;
    +        };
    +    }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    index d48ed611de..0d79273920 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    @@ -676,7 +676,7 @@ private PBytecodeRootNode(PythonLanguage language, FrameDescriptor fd, Signature
             this.internal = source.isInternal();
             this.parserErrorCallback = parserErrorCallback;
             this.signature = sign;
    -        this.bytecode = PythonUtils.arrayCopyOf(co.code, co.code.length);
    +        this.bytecode = co.code;
             this.adoptedNodes = new Node[co.code.length];
             this.conditionProfiles = new int[co.conditionProfileCount];
             this.outputCanQuicken = co.outputCanQuicken;
    
    From 386e9cf19a9b70fa60068bc3ce0eab98f4b06564 Mon Sep 17 00:00:00 2001
    From: Michael Simacek 
    Date: Thu, 13 Feb 2025 10:32:54 +0100
    Subject: [PATCH 129/512] Initialize bytecode node array upon first execution
    
    ---
     .../nodes/bytecode/PBytecodeRootNode.java     | 67 ++++++-------------
     1 file changed, 22 insertions(+), 45 deletions(-)
    
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    index 0d79273920..9c85bdbb43 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java
    @@ -580,7 +580,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
          * When instrumentation is in use, InstrumentationSupport#bciToHelper node is used instead of
          * this array. Use getChildNodes() to get the right array.
          */
    -    @Children private final Node[] adoptedNodes;
    +    @Children private Node[] adoptedNodes;
         @Child private CalleeContext calleeContext = CalleeContext.create();
         // TODO: make some of those lazy?
         @Child private ExceptionStateNodes.GetCaughtExceptionNode getCaughtExceptionNode;
    @@ -590,7 +590,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
         @CompilationFinal private Object osrMetadata;
     
         @CompilationFinal private boolean usingCachedNodes;
    -    @CompilationFinal(dimensions = 1) private final int[] conditionProfiles;
    +    @CompilationFinal(dimensions = 1) private int[] conditionProfiles;
     
         @Child private InstrumentationRoot instrumentationRoot = InstrumentationRoot.create();
     
    @@ -677,8 +677,6 @@ private PBytecodeRootNode(PythonLanguage language, FrameDescriptor fd, Signature
             this.parserErrorCallback = parserErrorCallback;
             this.signature = sign;
             this.bytecode = co.code;
    -        this.adoptedNodes = new Node[co.code.length];
    -        this.conditionProfiles = new int[co.conditionProfileCount];
             this.outputCanQuicken = co.outputCanQuicken;
             this.variableShouldUnbox = co.variableShouldUnbox;
             this.generalizeInputsMap = co.generalizeInputsMap;
    @@ -767,7 +765,22 @@ public byte[] getBytecode() {
     
         private Node[] getChildNodes() {
             InstrumentationSupport instrumentation = instrumentationRoot.getInstrumentation();
    -        return instrumentation == null ? adoptedNodes : instrumentation.bciToHelperNode;
    +        if (instrumentation != null) {
    +            return instrumentation.bciToHelperNode;
    +        }
    +        if (adoptedNodes == null) {
    +            CompilerDirectives.transferToInterpreterAndInvalidate();
    +            Lock lock = getLock();
    +            lock.lock();
    +            try {
    +                if (adoptedNodes == null) {
    +                    adoptedNodes = new Node[bytecode.length];
    +                }
    +            } finally {
    +                lock.unlock();
    +            }
    +        }
    +        return adoptedNodes;
         }
     
         @FunctionalInterface
    @@ -776,51 +789,11 @@ private interface NodeSupplier {
             T get();
         }
     
    -    @FunctionalInterface
    -    private interface NodeFunction {
    -        T apply(A argument);
    -    }
    -
         @FunctionalInterface
         private interface IntNodeFunction {
             T apply(int argument);
         }
     
    -    @SuppressWarnings("unchecked")
    -    private  T insertChildNode(Node[] nodes, int nodeIndex, Class cachedClass, NodeFunction nodeSupplier, A argument) {
    -        Node node = nodes[nodeIndex];
    -        if (node != null && node.getClass() == cachedClass) {
    -            return CompilerDirectives.castExact(node, cachedClass);
    -        }
    -        return CompilerDirectives.castExact(doInsertChildNode(nodes, nodeIndex, nodeSupplier, argument), cachedClass);
    -    }
    -
    -    @SuppressWarnings("unchecked")
    -    private  T doInsertChildNode(Node[] nodes, int nodeIndex, NodeFunction nodeSupplier, A argument) {
    -        CompilerDirectives.transferToInterpreterAndInvalidate();
    -        Lock lock = getLock();
    -        lock.lock();
    -        try {
    -            T newNode = nodeSupplier.apply(argument);
    -            doInsertChildNode(nodes, nodeIndex, newNode);
    -            return newNode;
    -        } finally {
    -            lock.unlock();
    -        }
    -    }
    -
    -    @SuppressWarnings("unchecked")
    -    private  T insertChildNode(Node[] nodes, int nodeIndex, T uncached, Class cachedClass, NodeFunction nodeSupplier, A argument, boolean useCachedNodes) {
    -        if (!useCachedNodes) {
    -            return uncached;
    -        }
    -        Node node = nodes[nodeIndex];
    -        if (node != null && node.getClass() == cachedClass) {
    -            return CompilerDirectives.castExact(node, cachedClass);
    -        }
    -        return CompilerDirectives.castExact(doInsertChildNode(nodes, nodeIndex, nodeSupplier, argument), cachedClass);
    -    }
    -
         @SuppressWarnings("unchecked")
         private  T insertChildNodeInt(Node[] nodes, int nodeIndex, Class expectedClass, IntNodeFunction nodeSupplier, int argument) {
             Node node = nodes[nodeIndex];
    @@ -899,6 +872,10 @@ private boolean profileCondition(boolean value, byte[] localBC, int bci, boolean
             if (!useCachedNodes) {
                 return value;
             }
    +        if (conditionProfiles == null) {
    +            CompilerDirectives.transferToInterpreterAndInvalidate();
    +            conditionProfiles = new int[co.conditionProfileCount];
    +        }
             int index = Byte.toUnsignedInt(localBC[bci + 2]) | Byte.toUnsignedInt(localBC[bci + 3]) << 8;
             int t = conditionProfiles[index];
             int f = conditionProfiles[index + 1];
    
    From 7a107a7493a0e0480fc7e206ee9a00e118002015 Mon Sep 17 00:00:00 2001
    From: Tim Felgentreff 
    Date: Mon, 11 Nov 2024 09:50:33 +0100
    Subject: [PATCH 130/512] Add GraalPy site
    
    Co-authored-by: Olya Gupalo 
    Co-authored-by: Fabio Niephaus 
    Co-authored-by: Yevhen Shcheholskyy 
    ---
     .gitignore                                    |   1 +
     README.md                                     |  30 +-
     ci.jsonnet                                    |   2 +-
     docs/site/01-docs.md                          |  18 +
     docs/site/02-downloads.md                     | 396 ++++++++++
     docs/site/03-compatibility.md                 | 377 ++++++++++
     docs/site/Gemfile                             |  33 +
     docs/site/Gemfile.lock                        | 157 ++++
     docs/site/_config.yml                         |  21 +
     docs/site/_plugins/graalpy_wheels.txt         |  26 +
     docs/site/_plugins/wheel_repo_plugin.rb       |  59 ++
     .../assets/img/python/devoxx2024-cover.png    | Bin 0 -> 307360 bytes
     .../assets/img/python/jfocus2025-cover.png    | Bin 0 -> 266009 bytes
     .../assets/js/check_compatibility_helpers.js  | 280 +++++++
     docs/site/assets/logo.svg                     |   9 +
     docs/site/index.md                            | 387 ++++++++++
     .../python-module-testing-v241.csv            | 689 ++++++++++++++++++
     docs/user/Embedding-Build-Tools.md            |  35 +-
     docs/user/Embedding-Permissions.md            |   8 -
     docs/user/Interoperability.md                 |  13 +-
     docs/user/Native-Extensions.md                |  13 +-
     docs/user/Native-Images-with-Python.md        |   8 -
     docs/user/Performance.md                      |  27 +-
     docs/user/Python-Runtime.md                   |  12 +-
     docs/user/Python-Standalone-Applications.md   |  10 +-
     docs/user/Python-on-JVM.md                    |  10 +-
     docs/user/README.md                           |  42 +-
     docs/user/Tooling.md                          |  29 +-
     28 files changed, 2528 insertions(+), 164 deletions(-)
     create mode 100644 docs/site/01-docs.md
     create mode 100644 docs/site/02-downloads.md
     create mode 100644 docs/site/03-compatibility.md
     create mode 100644 docs/site/Gemfile
     create mode 100644 docs/site/Gemfile.lock
     create mode 100644 docs/site/_config.yml
     create mode 100644 docs/site/_plugins/graalpy_wheels.txt
     create mode 100644 docs/site/_plugins/wheel_repo_plugin.rb
     create mode 100644 docs/site/assets/img/python/devoxx2024-cover.png
     create mode 100644 docs/site/assets/img/python/jfocus2025-cover.png
     create mode 100644 docs/site/assets/js/check_compatibility_helpers.js
     create mode 100644 docs/site/assets/logo.svg
     create mode 100644 docs/site/index.md
     create mode 100644 docs/site/module_results/python-module-testing-v241.csv
    
    diff --git a/.gitignore b/.gitignore
    index f4da3d24c6..35689c2822 100644
    --- a/.gitignore
    +++ b/.gitignore
    @@ -70,6 +70,7 @@ Python.asdl.stamp
     *.jfr
     .DS_Store
     
    +docs/site/_site
     graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/antlr/.antlr/
     graalpython/lib-python/3/test/data
     !graalpython/lib-python/3/test/data/README
    diff --git a/README.md b/README.md
    index 2e036787f1..d61192b8be 100644
    --- a/README.md
    +++ b/README.md
    @@ -54,20 +54,20 @@ Refer to our [embedding documentation](https://www.graalvm.org/latest/reference-
       
           org.graalvm.polyglot
           polyglot
    -      24.1.1
    +      24.1.2
       
       
           org.graalvm.polyglot
           python
    -      24.1.1
    +      24.1.2
           pom
       
       ```
     
     * Gradle
       ```kotlin
    -  implementation("org.graalvm.polyglot:polyglot:24.1.1")
    -  implementation("org.graalvm.polyglot:python:24.1.1")
    +  implementation("org.graalvm.polyglot:polyglot:24.1.2")
    +  implementation("org.graalvm.polyglot:python:24.1.2")
       ```
     
     
    @@ -85,12 +85,12 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
     * Linux
     
       The easiest way to install GraalPy on Linux is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager).
    -  To install version 24.1.1 using Pyenv, run the following commands:
    +  To install version 24.1.2 using Pyenv, run the following commands:
       ```bash
    -  pyenv install graalpy-24.1.1
    +  pyenv install graalpy-24.1.2
       ```
       ```bash
    -  pyenv shell graalpy-24.1.1
    +  pyenv shell graalpy-24.1.2
       ```
       > NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
       
    @@ -102,12 +102,12 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
     * macOS
     
       The easiest way to install GraalPy on macOS is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager).
    -  To install version 24.1.1 using Pyenv, run the following commands:
    +  To install version 24.1.2 using Pyenv, run the following commands:
       ```bash
    -  pyenv install graalpy-24.1.1
    +  pyenv install graalpy-24.1.2
       ```
       ```bash
    -  pyenv shell graalpy-24.1.1
    +  pyenv shell graalpy-24.1.2
       ```
       > NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
     
    @@ -120,7 +120,7 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
           ```
           For example:
           ```bash
    -      sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.1
    +      sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.2
           ```
       3. Uncompress the file and update your `PATH` environment variable to include to the _graalpy-XX.Y.Z-macos-amd64/bin_ (or _graalpy-XX.Y.Z-macos-aarch64/bin_) directory.
     
    @@ -128,12 +128,12 @@ Thanks to our integration with GraalVM Native Image, we can deploy Python applic
     
       The Windows support of GraalPy is still experimental, so not all features and packages may be available.
       The easiest way to install GraalPy on Windows is to use [Pyenv-win](https://pyenv-win.github.io/pyenv-win/) (the Python version manager for Windows).
    -  To install version 24.1.1 using Pyenv-win, run the following commands:
    +  To install version 24.1.2 using Pyenv-win, run the following commands:
       ```cmd
    -  pyenv install graalpy-24.1.1-windows-amd64
    +  pyenv install graalpy-24.1.2-windows-amd64
       ```
       ```cmd
    -  pyenv shell graalpy-24.1.1-windows-amd64
    +  pyenv shell graalpy-24.1.2-windows-amd64
       ```
       > NOTE: There will be a delay between GraalPy release and its availability on Pyenv. Make sure to update Pyenv.
     
    @@ -179,7 +179,7 @@ To run Jython scripts, you need to use a GraalPy distribution running on the JVM
           ```
           For example:
           ```bash
    -      sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.1
    +      sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.2
           ```
       3. Uncompress the file and update your `PATH` environment variable to include to the _graalpy-jvm-XX.Y.Z-macos-amd64/bin_ (or _graalpy-jvm-XX.Y.Z-macos-aarch64/bin_) directory.
       4. Run your scripts with `graalpy --python.EmulateJython`.
    diff --git a/ci.jsonnet b/ci.jsonnet
    index ce99393b4c..cead7b9462 100644
    --- a/ci.jsonnet
    +++ b/ci.jsonnet
    @@ -1 +1 @@
    -{ "overlay": "e7117a989914a1d1a4cf85ffc55ff81ef8a6046d" }
    +{ "overlay": "49fac12d217e7ee98fbf68fea640bdc5b0f0e7c0" }
    diff --git a/docs/site/01-docs.md b/docs/site/01-docs.md
    new file mode 100644
    index 0000000000..fe5b664297
    --- /dev/null
    +++ b/docs/site/01-docs.md
    @@ -0,0 +1,18 @@
    +---
    +layout: docs
    +title: Documentation
    +permalink: docs/
    +---
    +
    +{% gfm_docs ../user/README.md %}
    +{% gfm_docs ../user/Python-Runtime.md %}
    +{% gfm_docs ../user/Performance.md %}
    +{% gfm_docs ../user/Python-on-JVM.md %}
    +{% gfm_docs ../user/Native-Images-with-Python.md %}
    +{% gfm_docs ../user/Python-Standalone-Applications.md %}
    +{% gfm_docs ../user/Interoperability.md %}
    +{% gfm_docs ../user/Embedding-Build-Tools.md %}
    +{% gfm_docs ../user/Embedding-Permissions.md %}
    +{% gfm_docs ../user/Tooling.md %}
    +
    +{% copy_assets ../user/assets %}
    diff --git a/docs/site/02-downloads.md b/docs/site/02-downloads.md
    new file mode 100644
    index 0000000000..fcf6ca3795
    --- /dev/null
    +++ b/docs/site/02-downloads.md
    @@ -0,0 +1,396 @@
    +---
    +layout: base
    +title: Downloads
    +permalink: downloads/
    +published: false
    +---
    +
    +
    +
    +
    +
    +

    Download GraalPy from Maven Central

    +
    +
    + Have a Java application? +
    +
    +You can extend it with Python code or leverage packages from the Python ecosystem. GraalPy is available on Maven Central and can be added as a dependency to your Maven or Gradle project as — see setup instructions. +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    Download Standalone Distributions of GraalPy

    +
    +
    + Do you want to test your Python application or package on GraalPy? +
    +
    + To test Python code on GraalPy, a standalone distribution is available for different platforms and in two different kinds: Native (for compact download and footprint) and JVM (for full Java interoperability). We recommend the distributions based on Oracle GraalVM for best performance and advanced features (released under the GFTC license). Distributions based on GraalVM Community Edition (released under the OSI-approved UPL license) are available on GitHub. Standalone distributions are also available via pyenv, pyenv-win, and setup-python: +
    +
    +
    +
    +
    + {%- highlight bash -%} +# Latest GraalPy release +pyenv install graalpy-{{ site.language_version }} +pyenv shell graalpy-{{ site.language_version }} + +# Latest EA build of GraalPy +pyenv install graalpy-dev +pyenv shell graalpy-dev + {%- endhighlight -%} +
    +
    +
    + pyenv and pyenv-win +
    +
    +
    +
    +
    + {%- highlight yml -%} +steps: +- uses: actions/checkout@v4 +- uses: actions/setup-python@v5 + with: + python-version: 'graalpy-{{ site.language_version }}' +- run: python my_script.py + {%- endhighlight -%} +
    + +
    +
    + +
    GraalPy on Oracle GraalVM is free to use in production and free to redistribute, at no cost, under the GraalVM Free Terms and Conditions.
    +
    +
    +
    +
    diff --git a/docs/site/03-compatibility.md b/docs/site/03-compatibility.md new file mode 100644 index 0000000000..03d5b6f8f1 --- /dev/null +++ b/docs/site/03-compatibility.md @@ -0,0 +1,377 @@ +--- +layout: base +title: Compatibility +permalink: compatibility/ +--- + + + +
    +
    +
    +
    +

    GraalPy: Package Compatibility

    +
    +
    +

    GraalPy 24.1

    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    To ensure GraalPy is compatible with common Python packages, the GraalPy team conducts + compatibility testing to verify the presence and correct functioning of + the top 500 packages on PyPI plus some more that are of special interest to us, including + libraries and frameworks such as NumPy, Pandas, and Django.
    +
    Compatibility testing ensures that + developers can leverage GraalPy's powerful capabilities in their existing applications. + It also enables developers to use GraalPy to create more efficient and productive applications in the areas of + machine learning, data analysis, and web development using their familiar Python + toolsets.
    +
    Many more Python packages than are on this list work on GraalPy. + If there is a package you are interested in that you cannot find here, chances are that it + might just work.
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    Compatible: loading...
    +
    + Currently Untested: loading...
    +
    +
    +
    Currently + Incompatible: loading...
    +
    Not + Supported: loading...
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Python Packages

    +
    + +
    +
    + + +
    + +
    +
    +
    + + + + + + + + + + + +
    Python Packages
    NameVersionTest Level %Package URL
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    +
    +
    diff --git a/docs/site/Gemfile b/docs/site/Gemfile new file mode 100644 index 0000000000..2c11ff519e --- /dev/null +++ b/docs/site/Gemfile @@ -0,0 +1,33 @@ +source "https://rubygems.org/" + +gem "jekyll", "~> 4.3.4" + +gem "graal-languages-jekyll-theme" + +group :jekyll_plugins do + gem "jekyll-relative-links" + gem "jekyll-seo-tag" +end + +# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem +# and associated library. +platforms :mingw, :x64_mingw, :mswin, :jruby do + gem "tzinfo", ">= 1", "< 3" + gem "tzinfo-data" +end + +# Performance-booster for watching directories on Windows +gem "wdm", "~> 0.1", :platforms => [:mingw, :x64_mingw, :mswin] + +# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem +# do not have a Java counterpart. +gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] + +# Clean unused resources with `bundle exec siteleaf clean resources` +group :development do + gem 'siteleaf' + gem 'pry' + gem 'html-proofer' + # Run this with: + # bundle exec htmlproofer --swap-urls '^/python/:/' ./_site/ +end diff --git a/docs/site/Gemfile.lock b/docs/site/Gemfile.lock new file mode 100644 index 0000000000..d7ae358a10 --- /dev/null +++ b/docs/site/Gemfile.lock @@ -0,0 +1,157 @@ +GEM + remote: https://rubygems.org/ + specs: + Ascii85 (2.0.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + afm (0.2.2) + async (2.23.0) + console (~> 1.29) + fiber-annotation + io-event (~> 1.9) + metrics (~> 0.12) + traces (~> 0.15) + bigdecimal (3.1.8) + coderay (1.1.3) + colorator (1.1.0) + concurrent-ruby (1.3.4) + console (1.29.3) + fiber-annotation + fiber-local (~> 1.1) + json + csv (3.3.0) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + ethon (0.16.0) + ffi (>= 1.15.0) + eventmachine (1.2.7) + ffi (1.17.0-x86_64-linux-gnu) + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.0) + forwardable-extended (2.6.0) + google-protobuf (4.28.3-x86_64-linux) + bigdecimal + rake (>= 13) + graal-languages-jekyll-theme (0.1.0) + jekyll (~> 4.3) + hashery (2.1.2) + html-proofer (5.0.10) + addressable (~> 2.3) + async (~> 2.1) + nokogiri (~> 1.13) + pdf-reader (~> 2.11) + rainbow (~> 3.0) + typhoeus (~> 1.3) + yell (~> 2.0) + zeitwerk (~> 2.5) + http_parser.rb (0.8.0) + httparty (0.22.0) + csv + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + io-event (1.9.0) + jekyll (4.3.4) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (>= 0.3.6, < 0.5) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-relative-links (0.7.0) + jekyll (>= 3.3, < 5.0) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) + jekyll-seo-tag (2.8.0) + jekyll (>= 3.8, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + json (2.10.1) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + mercenary (0.4.0) + method_source (1.1.0) + metrics (0.12.1) + mini_mime (1.1.5) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + nokogiri (1.18.3-x86_64-linux-gnu) + racc (~> 1.4) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + pdf-reader (2.14.1) + Ascii85 (>= 1.0, < 3.0, != 2.0.0) + afm (~> 0.2.1) + hashery (~> 2.0) + ruby-rc4 + ttfunk + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rexml (3.3.9) + rouge (4.5.1) + ruby-rc4 (0.1.5) + safe_yaml (1.0.5) + sass-embedded (1.81.0-x86_64-linux-gnu) + google-protobuf (~> 4.28) + siteleaf (2.3.0) + httparty (>= 0.16.0) + jekyll (>= 1.4.1) + rack + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + traces (0.15.2) + ttfunk (1.8.0) + bigdecimal (~> 3.1) + typhoeus (1.4.1) + ethon (>= 0.9.0) + unicode-display_width (2.6.0) + webrick (1.9.0) + yell (2.2.2) + zeitwerk (2.7.2) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + graal-languages-jekyll-theme + html-proofer + http_parser.rb (~> 0.6.0) + jekyll (~> 4.3.4) + jekyll-relative-links + jekyll-seo-tag + pry + siteleaf + tzinfo (>= 1, < 3) + tzinfo-data + wdm (~> 0.1) + +BUNDLED WITH + 2.5.9 diff --git a/docs/site/_config.yml b/docs/site/_config.yml new file mode 100644 index 0000000000..4353b0f045 --- /dev/null +++ b/docs/site/_config.yml @@ -0,0 +1,21 @@ +baseurl: "/python" +url: "https://graalvm.org/" +github: "oracle/graalpython" +language_version: 24.1.2 +name: GraalPy + +permalink: pretty + +plugins: + - jekyll-relative-links + - jekyll-seo-tag + - graal-languages-jekyll-theme + +theme: graal-languages-jekyll-theme + +sass: + quiet_deps: true + +exclude: + - Gemfile + - Gemfile.lock diff --git a/docs/site/_plugins/graalpy_wheels.txt b/docs/site/_plugins/graalpy_wheels.txt new file mode 100644 index 0000000000..3cd710c97d --- /dev/null +++ b/docs/site/_plugins/graalpy_wheels.txt @@ -0,0 +1,26 @@ +# This file is processed by _plugins/wheel_repo_plugin.rb +# Each line is a wheel filename. Comments and empty lines are ignored +contourpy-1.2.1-graalpy311-graalpy241_311_native-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +httptools-0.6.1-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +httptools-0.6.1-graalpy311-graalpy241_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl +httptools-0.6.1-graalpy311-graalpy241_311_native-win_amd64.whl +jiter-0.5.0-graalpy311-graalpy241_311_native-manylinux_2_28_x86_64.whl +kiwisolver-1.4.5-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +kiwisolver-1.4.5-graalpy311-graalpy241_311_native-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl +kiwisolver-1.4.5-graalpy311-graalpy241_311_native-win_amd64.whl +numpy-1.26.4-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +numpy-1.26.4-graalpy311-graalpy241_311_native-manylinux_2_28_x86_64.whl +numpy-1.26.4-graalpy311-graalpy241_311_native-win_amd64.whl +oracledb-2.2.1-graalpy311-graalpy241_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +psutil-5.9.8-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +psutil-5.9.8-graalpy311-graalpy241_311_native-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl +psutil-5.9.8-graalpy311-graalpy241_311_native-win_amd64.whl +pydantic_core-2.10.1-graalpy311-graalpy241_311_native-manylinux_2_28_x86_64.whl +ujson-5.10.0-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +ujson-5.10.0-graalpy311-graalpy241_311_native-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl +ujson-5.10.0-graalpy311-graalpy241_311_native-win_amd64.whl +uvloop-0.19.0-graalpy311-graalpy241_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +watchfiles-0.21.0-graalpy311-graalpy241_311_native-manylinux_2_28_x86_64.whl +xxhash-3.4.1-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl +xxhash-3.4.1-graalpy311-graalpy241_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +xxhash-3.4.1-graalpy311-graalpy241_311_native-win_amd64.whl diff --git a/docs/site/_plugins/wheel_repo_plugin.rb b/docs/site/_plugins/wheel_repo_plugin.rb new file mode 100644 index 0000000000..c00bb174fc --- /dev/null +++ b/docs/site/_plugins/wheel_repo_plugin.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +# Plugin that generates a Python repository index for GraalPy wheels at +# /python/wheels. The input is the graalpy_wheels.txt file next to this file. +# The wheels themselves are hosted in GDS. +module WheelRepoPlugin + TEMPLATE = <<~EOF + + + + GraalPy wheel repository + + +
    +      %{content}
    +      
    + + + EOF + + Wheel = Struct.new(:name, :filename) + + class IndexGenerator < Jekyll::Generator + safe true + + def generate(site) + index_path = File.join(__dir__, "graalpy_wheels.txt") + all_wheels = File.readlines(index_path).select do |line| + !line.empty? && !line.start_with?("#") + end.collect do |line| + if /([^-]+)-([^-]+)-.*\.whl/ =~ line + Wheel.new($1.downcase.gsub(/[-_.]+/, "-"), line.strip) + else + raise "Invalid wheel name in #{index_path}: #{line.inspect}" + end + end + wheels_by_name = all_wheels.group_by(&:name) + index_links = wheels_by_name.keys.map do |name| + "#{name}" + end + index_page = Jekyll::PageWithoutAFile.new(site, "", "/wheels", "index.html") + index_page.content = render index_links + site.pages << index_page + + wheels_by_name.each do |name, wheels| + package_links = wheels.collect do |wheel| + "#{wheel.filename}" + end + package_page = Jekyll::PageWithoutAFile.new(site, "", "/wheels/#{name}", "index.html") + package_page.content = render package_links + site.pages << package_page + end + end + + def render(links) + TEMPLATE % { content: links.join("\n") } + end + end +end diff --git a/docs/site/assets/img/python/devoxx2024-cover.png b/docs/site/assets/img/python/devoxx2024-cover.png new file mode 100644 index 0000000000000000000000000000000000000000..c3980a6d3995b26154b1546eb441361e0ddeeaba GIT binary patch literal 307360 zcmV(+K;6HIP){@cu)U`Kul}a}h*x_XdZ&In{m`4BZrCLr z=pWXfI!0}!^gX0gFP+QQ&U`j>^Is?pGkW8j-b8=!@jsxg#X@fz^GJ_9_9zW$MlZei z0u94ZKg$>sV~kxlYkNbT4{28BHFw`n`$DzNdS7Ctg>f8D&;o%L^gd?mkK8vIZ~H6N zdt}|@_gwFb^`}M)F_r#zPaF5TPLM#^_>SWqxovNMkG}u=zK?$K7ylKl*K5#+5vA=L zo~|bvVyEYxI${h{I=6NAy~3w-w8ZQPt=@nC{q(^Pevp3ppZ+xM?(R;9VG}|pua3~1 zx=Xi(`seVW^{s!poM_3~>7MKRLib*e)pAAeeeZke!o~CSOTYB5X?uH{qEr4BE_7lm z6mK~;jlQ>a-#%w9-MEPM_x9*7{DmK(U;gEPP1mnqS6U5fJINNNQx%Q#$+WWdS(;Jq7jT4?kB za>~2t6#h_7jJ17SrgVH_&aLfOQnXX<*}kk>?#8gu@6CSPV-5Vhr~bYT;^^zzFu zhYS#Gva_>8_uY4&^1!!y zDgey6jU_n8iGD$G2*TX?wDYY-%bed)~zYyj0PJ(DR_R9smU`U z92XVv9PA&^^&8h|KA&&AzqI$@*C(HRlAeG5i*&p^?f@X3Ar7JoY*3<0F-?rSZGmaR zuO{uHVfn zNFBJ1QU1GJEo07`LXc=N9~4ZQFt7Jjz(BN#oeO{%oq9QFkKYSuj_>)vWKD#ozyJHc zkAC~3AEg&xc##%$-Zq6uBSUUu*g#0rK2reh$%~8ciE__=t?K+g_0&`J{`bC*{^5WB zkCcI&WJvU-$Hwj5Qvlf7>FJF(`Z*!%et+|Z#`9$^0n;*;GgX27z2E)aI=5Tx+0DJ( zwOL${PTt2;ZiTV*pQTDucPj|o-r1^jKVbYNUUACqI&t|PZ+$D%g++Jz?b$w@4sY|T zdtMzMnDnlk&SZKp&YL~RWkcC6-IsJym{SQpKN&Z5bX_4m?dABj#FFgC|U8*_7FkxsVVZX2iZe?St%Bg)VC;GSf3~h|*lr`RXcYJtSfA4XL>=j=3 zfe(Cue&Q#7g5L6$x2R!be}A8T;TL|Me)LEGL;by!LSN2+Ay`HX03t`%>v8g(v?-v{ ze|{xb1%MwaJCD7=%xtGHlj$&fa5vqUO8jAE>t5jCiMz>-?`Wc}_HXy^CcL@f?7c*^vh_+mUK zCuKsjiKfh%=!8+E?+^okXY^@Z0mGJp78{2HXc^92!J=}9y8O8Uw%nLA89~h}6EBmw zPPAMvJ5XTYY*7JV?m@hQ%4K}7!>MaxmdLhlYJIJnBX2O6MO_P>O%AA1$21zl>lA`^ zl?^^v=!8XMLN{&BY(hD1FWmz|(s%Ff)7JJ@or_rqbT$|Y_duyME%nP?W!janGJ~Qf zZ^F<8tP3zbfByVQhOt2_o3z~Hw5d?rYykT%hI<-su=&YrfU#~lrT}+yXZv6(jnr|7 zWm&A4s)QzPdjxx(yY~g%P@)anD$(SxLKEQXe5#v^UNML^CW_f9^U)ySbS8|1T8rI~ zb=NRak6R1Yx}TmYzoU--6xyT=rj4nkwq9FxFK$)k>EQ5))*O_qZO z)Ak8978SG9PfdwsQM#-O+QIFc^*u8>cj z=LWg7v3Dy!S)1-2q78i`_gq@v-%w34IaDT{iSJ7Hdq2i|sO;Uv&6}Cm6=x*%cI;OJ zl>+-Jhefu1nMO`d;XS|Qui$>%dFkuFwd`KGUx{e4x%6pgXVfts?iQ$fc_|?TgH *

    - * + * + *

    + * When Maven or Gradle GraalPy plugin is used to build the virtual environment, it also has to + * be configured to generate the virtual environment into the same directory using the + * {@code } tag in Maven or the {@code externalDirectory} field in Gradle. + *

    + * * @param externalResourcesDirectory the root directory with GraalPy specific embedding * resources * @return a new {@link org.graalvm.polyglot.Context.Builder} instance diff --git a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java index d6ab34a421..a96a9a47e9 100644 --- a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java +++ b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java @@ -119,10 +119,17 @@ private Builder() { *

    * User scripts, data files, and other resources that should be accessible in Python should * be put into this resource directory, e.g., - * {@code src/main/resources/org.graalvm.python.vfs} for the default value of this option - * and assuming the usual layout of a Maven or Gradle project. + * {@code src/main/resources/org.graalvm.python.vfs/src} where: + *

      + *
    • assuming the usual layout of a Maven or Gradle project then the + * {@code src/main/resources/org.graalvm.python.vfs} prefix is the default value of the + * {@code resourceDirectory} option
    • + *
    • and the following {@code src} directory is the folder used by {@link GraalPyResources + * convention} for Python application files and is configured as the default search path for + * Python module files. + *
    *

    - * When Maven and Gradle GraalPy plugin is used to build the virtual environment, it should + * When Maven or Gradle GraalPy plugin is used to build the virtual environment, it should * be configured to generate the virtual environment into the same directory using the * {@code } tag in Maven or the {@code resourceDirectory} field in * Gradle. From 8b3ac06267477a91213cf5abd9dc49f00fb8a9cb Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 26 Feb 2025 13:35:33 +0100 Subject: [PATCH 145/512] added Troubleshooting.md --- docs/user/Embedding-Build-Tools.md | 25 ++++-- docs/user/Troubleshooting.md | 133 +++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 docs/user/Troubleshooting.md diff --git a/docs/user/Embedding-Build-Tools.md b/docs/user/Embedding-Build-Tools.md index 865cafa7b1..a6bc6188e5 100644 --- a/docs/user/Embedding-Build-Tools.md +++ b/docs/user/Embedding-Build-Tools.md @@ -6,7 +6,7 @@ required for embedding Python code in Java-based applications: - *Third-party Python packages* installed by the plugin during the build according to the plugin configuration. Apart from physically managing and deploying those files, it is also necessary to make them available in Python at runtime by configuring the **GraalPy Context** in your Java code accordingly. -The [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) API provides factory methods to create a Context preconfigured for accessing Python, embedding relevant resources with a **Virtual Filesystem** or from a dedicated **external directory**. +The [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) API provides factory methods to create a Context preconfigured for accessing Python, embedding relevant resources with a **Virtual Filesystem** or from a dedicated **external directory**. ## Deployment @@ -26,7 +26,7 @@ User can choose relative Java resources path that will be made accessible in Pyt by default it is `org.graalvm.python.vfs`. All resources subdirectories with this path are merged during build and mapped to a configurable Virtual Filesystem mount point at the Python side, by default `/graalpy_vfs`. For example, a Python file with the real filesystem path `${project_resources_directory}/org.graalvm.python.vfs/src/foo/bar.py` will be accessible as `/graalpy_vfs/src/foo/bar.py` in Python. -Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) +Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) factory methods to create GraalPy Context preconfigured for the use of the Virtual Filesystem: * `GraalPyResources.createContext()` * `GraalPyResources.contextBuilder()` @@ -48,18 +48,33 @@ at runtime using the `VirtualFileSystem$Builder#resourceDirectory` API. This is also the case of the default virtual filesystem location. When a resources directory is not a valid Java package name, such as the recommended "GRAALPY-VFS", the resources are not subject to the encapsulation rules and do not require additional module system configuration.* +#### Extracting files from Virtual Filesystem +Normally, Virtual Filesystem resources are loaded like java resources, but there are cases when files need to be accessed +outside the Truffle sandbox, e.g. Python C extension files which need to be accessed by the operating system loader. + +By default, files which are of type `.so`, `.dylib`, `.pyd`, `.dll`, or `.ttf`, are automatically extracted to a temporary directory +in the real filesystem when accessed for the first time and the Virtual Filesystem then delegates to those real files. + +The default extract rule can be enhanced using the `VirtualFileSystem$Builder#extractFilter` API. + +Alternatively, it is possible to extract all Python resources into a user-defined directory before creating a GraalPy +context, and then configure the context to use that directory. Please refer to the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) +methods for more details: +* `GraalPyResources.extractVirtualFileSystemResources(VirtualFileSystem vfs, Path externalResourcesDirectory)` +* `GraalPyResourcescontextBuilder(Path externalResourcesDirectory)` + ### External Directory As an alternative to Java resources with the Virtual Filesystem, it is also possible to configure the Maven or Gradle plugin to manage the contents of an external directory, which will **not be embedded** as a Java resource into the resulting application. A user is then responsible for the deployment of such directory. Python code will access the files directly from the real filesystem. -Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) factory methods to create GraalPy Context preconfigured for the use of an external directory: +Use the following [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) factory methods to create GraalPy Context preconfigured for the use of an external directory: * `GraalPyResources.createContextBuilder(Path)` ## Conventions -The factory methods in [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/utils/GraalPyResources.java) rely on the following conventions, where the `${root}` is either an external directory, or a Virtual System mount point on the Python side and Java resources directories, such as `${project_resources_directory}/org.graalvm.python.vfs`, on the real filesystem: +The factory methods in [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) rely on the following conventions, where the `${root}` is either an external directory, or a Virtual System mount point on the Python side and Java resources directories, such as `${project_resources_directory}/org.graalvm.python.vfs`, on the real filesystem: - `${root}/src`: used for Python application files. This directory will be configured as the default search path for Python module files (equivalent to `PYTHONPATH` environment variable). - `${root}/venv`: used for the Python virtual environment holding installed third-party Python packages. The Context will be configured as if it is executed from this virtual environment. Notably packages installed in this @@ -161,7 +176,7 @@ For more information on managing Python packages, please refer to the descriptio the `graalPyLockFile` and `packages` fields in the [plugin configuration](#maven-plugin-configuration), as well as the [Python Dependency Management](#python-dependency-management) section above in this document. -## GraalPy Gradle Plugin +## GraalPy Gradle Plugin ### Gradle Plugin Configuration The plugin must be added to the plugins section in the _build.gradle_ file. diff --git a/docs/user/Troubleshooting.md b/docs/user/Troubleshooting.md new file mode 100644 index 0000000000..839fceff11 --- /dev/null +++ b/docs/user/Troubleshooting.md @@ -0,0 +1,133 @@ +# GraalPy Troubleshooting + +[[TOC]] + +## GraalPy Embedding + +#### VirtualFileSystem cannot load a file +There are situations where a file cannot be loaded even though it is part of the Virtual Filesystem resources. +GraalPy tries to prevent such situations by automatically [extracting](Embedding-Build-Tools.md#extracting-files-from-virtual-filesystem) +some well known files to the real filesystem, but if you see an error like: +``` +ImportError: cannot load /graalpy_vfs/venv/lib/python3.11/site-packages/_cffi_backend.graalpy250dev09433ef706-311-native-aarch64-darwin.so: +NFIUnsatisfiedLinkError: dlopen(/graalpy_vfs/venv/lib/python3.11/site-packages/_cffi_backend.graalpy250dev09433ef706-311-native-aarch64-darwin.so, 0x0002): +``` +then the default behavior did not work as intended. + +Depending on how you [deploy Python resources](Embedding-Build-Tools.md#deployment) in your application, you can try one of the following: +- if you need to package resources within your Jar or Native Image executable: + - if the problematic file is not one of the following types: `.so`, `.dylib`, `.pyd`, `.dll`, or `.ttf`, which are extracted to + the real filesystem by default, you can simply attempt to add it to the extraction filter using: + ```java + VirtualFileSystem.Builder.extractFilter(filter); + ``` + - if the previous does not help, it is also possible to extract all Python resources into a user-defined directory before creating a GraalPy + context, and then configure the context to use that directory: + ```java + // extract the Python resources from the jar or native image into a given directory + GraalPyResources.extractVirtualFileSystemResources(VirtualFileSystem.create(), externalResourceDirectoryPath); + // create a GraalPy context configured with an external Python resource directory + Context context = GraalPyResources.contextBuilder(externalResourceDirectoryPath).build(); + ``` +- or if you're able to ship resources in a separate directory, you have to set the `externalDirectory` tag in + [Maven](Embedding-Build-Tools.md#graalpy-maven-plugin) or `externalDirectory` field in [Gradle](Embedding-Build-Tools.md#graalpy-gradle-plugin) + and also configure the GraalPy context to use that directory as well: + ```java + // create a Context configured with an external Python resource directory + Context context = GraalPyResources.contextBuilder(externalResourceDirectoryPath).build(); + ``` + Please **note**, that if switching from Virtual FileSystem to an external directory, also all **user files** from the previous + Virtual FileSystem resource root have to be moved into that directory as well. + +For more details about the Python resources in GraalPy Embedding please refer to the [Embedding Build Tools](Embedding-Build-Tools.md) documentation. + +For more details about GraalPy context and Virtual FileSystem configuration please refer to [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) and +[VirtualFileSystem](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java) javadoc. + +#### Issues with GraalPy 'java' posix backend +The Virtual FileSystem is built on the Truffle filesystem and relies on the GraalPy Java POSIX backend. +Unfortunately, certain Python packages bypass Python's I/O and directly access files through their +native extensions. If you encounter an error like: +``` +NotImplementedError: 'PyObject_AsFileDescriptor' not supported when using 'java' posix backend +``` +then you have to override the default `java` GraalPy backend option byt setting the `native` POSIX backend +and completely omit the Virtual FileSystem at runtime. + +Depending on how you [deploy Python resources](Embedding-Build-Tools.md#deployment) in your application, +you can do one of the following: + +- if you need to package Python resources within your Jar or Native Image executable, then: + ```java + // extract the Python resources from the jar or native image into a given directory + GraalPyResources.extractVirtualFileSystemResources(VirtualFileSystem.create(), externalResourceDirectoryPath); + // create a Context.Builder configured with an external python resource directory + Builder builder = GraalPyResources.contextBuilder(externalResourceDirectoryPath); + // override the python.PosixModuleBackend option with "native" + builder.option("python.PosixModuleBackend", "native"); + // create a context + Context context = builder.build(); + ``` +- or if you're able to ship Python resources in a separate directory, you have to set the `externalDirectory` tag in + [Maven](Embedding-Build-Tools.md#graalpy-maven-plugin) or `externalDirectory` field in [Gradle](Embedding-Build-Tools.md#graalpy-gradle-plugin) + and configure the GraalPy context accordingly: + ```java + // create a Context.Builder configured with an external python resource directory + Builder builder = GraalPyResources.contextBuilder(externalResourceDirectoryPath); + // override the python.PosixModuleBackend option with "native" + builder.option("python.PosixModuleBackend", "native"); + // create a context + Context context = builder.build(); + ``` + Please **note**, that if switching from Virtual FileSystem to an external directory, also all **user files** from the previous + Virtual FileSystem resource root have to be moved into that directory as well. + +For more details about the Python resources in GraalPy Embedding please refer to the [Embedding Build Tools](Embedding-Build-Tools.md) documentation. + +For more details about GraalPy context and Virtual FileSystem configuration please refer to [GraalPyResources](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java) and +[VirtualFileSystem](https://github.com/oracle/graalpython/blob/master/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/VirtualFileSystem.java) javadoc. + +### Maven and Gradle applications + +#### GraalVM JDK Compatibility +To enable runtime compilation when running GraalPy from a Maven or Gradle application, +you must use versions of GraalPy and the Polyglot API dependencies that are compatible +with the specified GraalVM JDK version. If you see errors like the following: + +``` +Your Java runtime '23.0.1+11-jvmci-b01' with compiler version '24.1.1' is incompatible with polyglot version '24.1.0'. +``` +You need to keep the versions of your GraalPy and Polyglot dependencies according to the error message, +so either upgrade the version of your JDK or your polyglot and GraalPy dependencies. + +Note, this can also apply to cases when your dependencies are transitively pulled in by another artifact, +e.g. micronaut-graalpy. + +#### The following artifacts could not be resolved: org.graalvm.python:python-language-enterprise +`python-language-enterprise` was discontinued, use `org.graalvm.polyglot:python` instead. + +#### Issues with Meson build system when installing Python packages on OSX with Maven or Gradle GraalPy plugin +Errors like the following: +``` +../meson.build:1:0: ERROR: Failed running 'cython', binary or interpreter not executable. +``` + +could be caused by the GraalPy launcher used internally by the Maven or Gradle GraalPy plugin +for installing Python packages. Currently, there is no straightforward solution. However, +a workaround is to set the Java system property graalpy.vfs.venvLauncher to a launcher from +a downloaded [GraalPy](https://github.com/oracle/graalpython/releases/) distribution with a version +matching the GraalPy Maven artifacts version. + +e.g. +``` +mvn package -Dgraalpy.vfs.venvLauncher={graalpy_directroy}/Contents/Home/bin/graalpy +``` + +#### No language and polyglot implementation was found on the module-path. +If you see an error like: +``` +java.lang.IllegalStateException: No language and polyglot implementation was found on the module-path. Make sure at last one language is added to the module-path. +``` +you are probably missing the python langauge dependency in your Maven of Gradle configuration file. +You need to add either `org.graalvm.polyglot:python` or `org.graalvm.polyglot:python-community` to your dependencies. + From d7808565094ba7494c2912dc2dd8b6227253b4a9 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 4 Mar 2025 22:34:20 +0100 Subject: [PATCH 146/512] minor fix in GraalPyResources javadoc --- docs/user/Troubleshooting.md | 8 ++++++++ .../org/graalvm/python/embedding/GraalPyResources.java | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/user/Troubleshooting.md b/docs/user/Troubleshooting.md index 839fceff11..da916dcc22 100644 --- a/docs/user/Troubleshooting.md +++ b/docs/user/Troubleshooting.md @@ -89,6 +89,14 @@ For more details about GraalPy context and Virtual FileSystem configuration plea ### Maven and Gradle applications +#### ImportError reports "unknown location" +A possible cause of an `ImportError` ending with `(unknown location)` when running a GraalPy Java Embedding project might be +that an embedded Python package was built for a different operating system. If you see an error like the following: +``` +ImportError: cannot import name 'exceptions' from 'cryptography.hazmat.bindings._rust' (unknown location) +``` +You probably need to rebuild your project on the correct operating system before running it. + #### GraalVM JDK Compatibility To enable runtime compilation when running GraalPy from a Maven or Gradle application, you must use versions of GraalPy and the Polyglot API dependencies that are compatible diff --git a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java index 0cae2e0d79..d4ecffe8d4 100644 --- a/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java +++ b/graalpython/org.graalvm.python.embedding/src/org/graalvm/python/embedding/GraalPyResources.java @@ -76,10 +76,12 @@ *

    * *

    - * In order to make this work, it is necessary for those embedded resources to have their root - * directory set to /org.graalvm.python.vfs which in python code will be mapped to - * the virtual filesystem mount point, by default /graalpy_vfs. Refer to - * {@link VirtualFileSystem.Builder} documentation for more details. + * In order to make this work, it is necessary for those embedded resources to have a common + * resource root directory. The default value is /org.graalvm.python.vfs, + * however the recommended convention is to use {@code GRAALPY-VFS/{groupId}/{artifactId}}. This + * root directory will then be in python code mapped to the virtual filesystem mount point, + * by default /graalpy_vfs. Refer to + * {@link VirtualFileSystem.Builder#resourceDirectory(String)} documentation for more details. *

    * *

    External Directory

    From c2b1ad3ca67eced9ee4ec29f33834196692c04fc Mon Sep 17 00:00:00 2001 From: Ondrej Tethal Date: Mon, 10 Mar 2025 13:50:52 +0100 Subject: [PATCH 147/512] Update imports --- ci.jsonnet | 2 +- mx.graalpython/suite.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci.jsonnet b/ci.jsonnet index cead7b9462..71c43b2cf5 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "49fac12d217e7ee98fbf68fea640bdc5b0f0e7c0" } +{ "overlay": "f5f1fdc315441dcb664bed5e190f54be0e4dc78e" } diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py index b5be374d93..df0507bee8 100644 --- a/mx.graalpython/suite.py +++ b/mx.graalpython/suite.py @@ -45,7 +45,7 @@ }, { "name": "sdk", - "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982", + "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -53,7 +53,7 @@ }, { "name": "tools", - "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982", + "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -61,7 +61,7 @@ }, { "name": "sulong", - "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982", + "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -69,7 +69,7 @@ }, { "name": "regex", - "version": "80fe02a9176546f6f2ec412a4a8f5990898e9982", + "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, From 634b4dde7d53a031199c6d7cd2b01206182d170d Mon Sep 17 00:00:00 2001 From: Ondrej Tethal Date: Mon, 10 Mar 2025 14:06:57 +0100 Subject: [PATCH 148/512] Update tags --- .../src/tests/unittest_tags/test_itertools.txt | 1 + .../src/tests/unittest_tags/test_pathlib.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt index b3ac95e1c7..7022a17f05 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt @@ -31,6 +31,7 @@ test.test_itertools.TestBasicOps.test_islice @ darwin-arm64,darwin-x86_64,linux- test.test_itertools.TestBasicOps.test_map @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_pairwise @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_pairwise_reenter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_itertools.TestBasicOps.test_pairwise_reenter2 @ darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_permutations @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_product @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_product_issue_25021 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_pathlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_pathlib.txt index e9c42657d6..6e4258d86c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_pathlib.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_pathlib.txt @@ -375,6 +375,7 @@ test.test_pathlib.WindowsPathTest.test_expanduser @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_expanduser_common @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_glob_dotdot @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_glob_long_symlink @ win32-AMD64 +test.test_pathlib.WindowsPathTest.test_glob_many_open_files @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_glob_permissions @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_is_block_device_false @ win32-AMD64 test.test_pathlib.WindowsPathTest.test_is_char_device_false @ win32-AMD64 From 7801764dff6111ce637687a20a949244f72dab11 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Mon, 10 Mar 2025 15:41:31 +0100 Subject: [PATCH 149/512] added docs/user/Troubleshooting.md to docs/site/01-docs.md --- docs/site/01-docs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/site/01-docs.md b/docs/site/01-docs.md index fe5b664297..294c748ac1 100644 --- a/docs/site/01-docs.md +++ b/docs/site/01-docs.md @@ -14,5 +14,6 @@ permalink: docs/ {% gfm_docs ../user/Embedding-Build-Tools.md %} {% gfm_docs ../user/Embedding-Permissions.md %} {% gfm_docs ../user/Tooling.md %} +{% gfm_docs ../user/Troubleshooting.md %} {% copy_assets ../user/assets %} From f3d5da93b708e327872763933a1ee039843c5e6d Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Tue, 11 Mar 2025 15:15:57 +0100 Subject: [PATCH 150/512] throw GradleException with the intended message instead of logging it --- .../org/graalvm/python/tasks/LockPackagesTask.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java index bbfcf6f60b..1017b67abe 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java @@ -73,13 +73,12 @@ public void exec() throws GradleException { private void checkEmptyPackages() throws GradleException { List packages = getPackages().get(); if((packages == null || packages.isEmpty())) { - getLog().error(""); - getLog().error("In order to run the graalpyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration."); - getLog().error(""); - getLog().error("For more information, please refer to https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md"); - getLog().error(""); - - throw new GradleException("missing python packages in plugin configuration"); + String msg = """ + In order to run the graalPyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration. + + For more information, please refer to https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md + """; + throw new GradleException(msg); } } } From 9cd0898a10cae3e2f70a4aa0c444e7cc7dee452c Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 6 Mar 2025 14:03:33 +0100 Subject: [PATCH 151/512] Special case empty storages in CreateEmptyForTypesNode --- .../objects/common/SequenceStorageNodes.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java index 46474b29b9..a9feefd4ea 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java @@ -3035,10 +3035,10 @@ static ArrayBasedSequenceStorage doIt(Node inliningTarget, SequenceStorage s, in @GenerateUncached public abstract static class CreateEmpty2Node extends SequenceStorageBaseNode { - public abstract ArrayBasedSequenceStorage execute(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap); + public abstract SequenceStorage execute(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap); @Specialization - static ArrayBasedSequenceStorage doIt(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap, + static SequenceStorage doIt(Node inliningTarget, SequenceStorage s1, SequenceStorage s2, int cap, @Cached GetElementType getElementType1, @Cached GetElementType getElementType2, @Cached CreateEmptyForTypesNode create) { @@ -3087,23 +3087,35 @@ static ObjectSequenceStorage doObject(@SuppressWarnings("unused") StorageType ty @GenerateInline @GenerateCached(false) @GenerateUncached + @ImportStatic(StorageType.class) abstract static class CreateEmptyForTypesNode extends SequenceStorageBaseNode { - public abstract ArrayBasedSequenceStorage execute(Node inliningTarget, StorageType type1, StorageType type2, int cap); + public abstract SequenceStorage execute(Node inliningTarget, StorageType type1, StorageType type2, int cap); - @Specialization(guards = "type1 == type2") - static ArrayBasedSequenceStorage doSame(Node inliningTarget, StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap, - @Cached CreateEmptyForTypeNode create) { + @Specialization(guards = {"type1 == type2 || type2 == Empty", "type1 != Empty"}) + static SequenceStorage doSameOr1Empty(Node inliningTarget, StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap, + @Shared @Cached CreateEmptyForTypeNode create) { return create.execute(inliningTarget, type1, cap); } + @Specialization(guards = {"type1 == Empty", "type2 != Empty"}) + static SequenceStorage do2Empty(Node inliningTarget, @SuppressWarnings("unused") StorageType type1, StorageType type2, int cap, + @Shared @Cached CreateEmptyForTypeNode create) { + return create.execute(inliningTarget, type2, cap); + } + + @Specialization(guards = {"type1 == Empty", "type2 == Empty", "cap == 0"}) + static SequenceStorage doBothEmpty(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, @SuppressWarnings("unused") int cap) { + return EmptySequenceStorage.INSTANCE; + } + @Specialization(guards = "generalizeToLong(type1, type2)") - static LongSequenceStorage doLong(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { + static SequenceStorage doLong(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { return new LongSequenceStorage(cap); } @Fallback - static ObjectSequenceStorage doObject(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { + static SequenceStorage doObject(@SuppressWarnings("unused") StorageType type1, @SuppressWarnings("unused") StorageType type2, int cap) { return new ObjectSequenceStorage(cap); } From c9cb1be962c0d358a32df5f9238bb47146f96949 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 12 Mar 2025 16:02:00 +0100 Subject: [PATCH 152/512] Exclude Truffle test packages from our coverage gates This reduces the length of the generated jacoco agent args commandline so we can run it --- mx.graalpython/mx_graalpython.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index cdf83ad74b..2320fde547 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -133,6 +133,20 @@ def get_boolean_env(name, default=False): WIN32 = sys.platform == "win32" BUILD_NATIVE_IMAGE_WITH_ASSERTIONS = get_boolean_env('BUILD_WITH_ASSERTIONS', CI) +mx_gate.add_jacoco_excludes([ + "com.oracle.graal.python.pegparser.sst", + "com.oracle.graal.python.pegparser.test", + "com.oracle.truffle.api.staticobject.test", + "com.oracle.truffle.regex.tregex.test", + "com.oracle.truffle.tck", + "com.oracle.truffle.tools.chromeinspector.test", + "com.oracle.truffle.tools.coverage.test", + "com.oracle.truffle.tools.dap.test", + "com.oracle.truffle.tools.profiler.test", + "org.graalvm.tools.insight.test", + "org.graalvm.tools.lsp.test", +]) + if CI and not os.environ.get("GRAALPYTEST_FAIL_FAST"): os.environ["GRAALPYTEST_FAIL_FAST"] = "true" From 57ad8d9b5492b670ddaa1b2c1d0c14ce591f32d1 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 12 Mar 2025 14:02:11 +0100 Subject: [PATCH 153/512] throw exception from VFSUtils.createVenv if packages changed --- .../cext/test/MultiContextCExtTest.java | 3 +- .../embedding/test/EmbeddingTestUtils.java | 10 +-- .../embedding/vfs/test/VFSUtilsTest.java | 25 +++---- .../tests/standalone/test_gradle_plugin.py | 2 +- .../maven/plugin/AbstractGraalPyMojo.java | 35 --------- .../maven/plugin/InstallPackagesMojo.java | 33 ++++++++- .../python/maven/plugin/LockPackagesMojo.java | 11 +++ .../python/embedding/tools/vfs/VFSUtils.java | 71 ++++++++++--------- .../python/tasks/AbstractPackagesTask.java | 38 +--------- .../python/tasks/InstallPackagesTask.java | 33 ++++++++- .../python/tasks/LockPackagesTask.java | 13 ++++ 11 files changed, 143 insertions(+), 131 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java index 1918739368..5231530e53 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java @@ -58,6 +58,7 @@ import org.graalvm.polyglot.PolyglotException; import org.graalvm.polyglot.Source; import org.graalvm.python.embedding.tools.exec.BuildToolLog; +import org.graalvm.python.embedding.tools.vfs.VFSUtils; import org.junit.Test; import static org.graalvm.python.embedding.test.EmbeddingTestUtils.deleteDirOnShutdown; @@ -165,7 +166,7 @@ public void close() { } @Test - public void testCreatingVenvForMulticontext() throws IOException { + public void testCreatingVenvForMulticontext() throws IOException, VFSUtils.PackagesChangedException { var log = new TestLog(); Path tmpdir = Files.createTempDirectory("MultiContextCExtTest"); Path venvDir = tmpdir.resolve("venv"); diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java index e426b9fca7..36819a68b0 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/test/EmbeddingTestUtils.java @@ -58,18 +58,18 @@ public final class EmbeddingTestUtils { private EmbeddingTestUtils() { } - public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException { - createVenv(venvDir, graalPyVersion, log, null, null, null, packages); + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, String... packages) throws IOException, VFSUtils.PackagesChangedException { + createVenv(venvDir, graalPyVersion, log, null, null, packages); } - public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile, String missingLockFileWarning, String packageRemovedError, String... packages) - throws IOException { + public static void createVenv(Path venvDir, String graalPyVersion, BuildToolLog log, Path lockFile, String missingLockFileWarning, String... packages) + throws IOException, VFSUtils.PackagesChangedException { try { info(log, "<<<<<< create test venv %s <<<<<<", venvDir); Launcher launcher = createLauncher(venvDir); if (lockFile != null) { - VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile, packageRemovedError, missingLockFileWarning, launcher, graalPyVersion, log); + VFSUtils.createVenv(venvDir, Arrays.asList(packages), lockFile, missingLockFileWarning, launcher, graalPyVersion, log); } else { VFSUtils.createVenv(venvDir, Arrays.asList(packages), launcher, graalPyVersion, log); } diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java index 68dca21ea0..70775c8670 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/vfs/test/VFSUtilsTest.java @@ -44,6 +44,7 @@ import org.graalvm.python.embedding.test.EmbeddingTestUtils; import org.graalvm.python.embedding.tools.exec.BuildToolLog; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.PackagesChangedException; import org.junit.Test; import java.io.IOException; @@ -86,7 +87,6 @@ public class VFSUtilsTest { private static final String PACKAGE_WAS_REMOVED = "A package with transitive dependencies was removed since last install, setting up a clean venv"; private static final String LOCK_FILE_HEADER = "generated by graalpy tests\nwith a two line header"; - private static final String PACKAGES_CHANGED_ERROR = "packages changed in lock file %s, current packages %s, previous packages %s"; private static final String MISSING_LOCK_FILE_WARNING = "missing lock file"; private static final CharSequence STALE_VENV = "Stale GraalPy virtual environment, updating to"; @@ -184,7 +184,7 @@ private static boolean isVerbose() { * - packages declared only in plugin config - lock file path is provided, but does not exist */ @Test - public void withPackagesOnlyFromPluginConfig() throws IOException { + public void withPackagesOnlyFromPluginConfig() throws IOException, PackagesChangedException { TestLog log = new TestLog(); Path tmpDir = Files.createTempDirectory("withPackagesOnlyFromPluginConfig"); Path venvDir = tmpDir.resolve("venv"); @@ -262,7 +262,7 @@ public void withPackagesOnlyFromPluginConfig() throws IOException { * - packages declared only in plugin config - and lock file path is not provided */ @Test - public void withoutLockFile() throws IOException { + public void withoutLockFile() throws IOException, PackagesChangedException { TestLog log = new TestLog(); Path tmpDir = Files.createTempDirectory("withoutLockFile"); Path venvDir = tmpDir.resolve("venv"); @@ -375,7 +375,7 @@ private static List createLockFileHeader(String graalPyVersion, String.. } @Test - public void installAndLock() throws IOException { + public void installAndLock() throws IOException, PackagesChangedException { TestLog log = new TestLog(); Path tmpDir = Files.createTempDirectory("installAndLock"); Path venvDir = tmpDir.resolve("venv"); @@ -407,7 +407,7 @@ public void installAndLock() throws IOException { log.clearOutput(); // reinstall without exact version declared - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests")); + checkException(PackagesChangedException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.2", "charset-normalizer", "idna", "urllib3", "certifi"); @@ -446,10 +446,9 @@ public void installAndLock() throws IOException { // add tiny-tiny - fails because inconsistent with lock file assert Files.exists(lockFile); - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1", "tiny-tiny==0.2")); + checkException(PackagesChangedException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.1", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "requests==2.32.1, tiny-tiny==0.2", "requests==2.32.1"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1"); assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); @@ -481,10 +480,9 @@ public void installAndLock() throws IOException { log.clearOutput(); // update in declared packages requests version back to 2.32.2 - fails - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2", "tiny-tiny==0.2")); + checkException(PackagesChangedException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "requests==2.32.2", "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "requests==2.32.2, tiny-tiny==0.2", "requests==2.32.1, tiny-tiny==0.2"))); checkInstalledPackages(venvDir.resolve("installed.txt"), "requests==2.32.1", "tiny-tiny==0.2", "charset-normalizer", "idna", "urllib3", "certifi"); checkVenvContentsFile(contents, "0.1", "requests==2.32.1", "tiny-tiny==0.2"); assertFalse(log.getOutput().contains(MISSING_LOCK_FILE_WARNING)); @@ -520,10 +518,9 @@ public void installAndLock() throws IOException { log.clearOutput(); // remove requests from packages list - fails because it is still in lock - checkException(IOException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "tiny-tiny==0.2")); + checkException(PackagesChangedException.class, () -> createVenv(venvDir, "0.1", log, lockFile, "tiny-tiny==0.2")); checkVenvCreate(log.getOutput(), false); assertFalse(log.getOutput().contains("pip install")); - assertTrue(log.getOutput().contains(String.format(PACKAGES_CHANGED_ERROR, lockFile, "tiny-tiny==0.2", "requests==2.32.2, tiny-tiny==0.2"))); log.clearOutput(); // lock only with tiny-tiny lock(venvDir, lockFile, log, "tiny-tiny==0.2"); @@ -656,12 +653,12 @@ private static void checkPackages(Path file, List linesArg, String... pa } } - private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, String... packages) throws IOException { + private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, String... packages) throws IOException, PackagesChangedException { EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, packages); } - private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path lockFile, String... packages) throws IOException { - EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, MISSING_LOCK_FILE_WARNING, PACKAGES_CHANGED_ERROR, packages); + private static void createVenv(Path venvDir, String graalPyVersion, TestLog log, Path lockFile, String... packages) throws IOException, PackagesChangedException { + EmbeddingTestUtils.createVenv(venvDir, graalPyVersion, log, lockFile, MISSING_LOCK_FILE_WARNING, packages); } private static void checkVenvContentsFile(Path contents, String graalPyVersion, String... packages) throws IOException { diff --git a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py index 61fcc7c578..be30a2d94b 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/standalone/test_gradle_plugin.py @@ -429,7 +429,7 @@ def check_gradle_empty_packages(self): cmd = gradle_cmd + ["graalpyLockPackages"] out, return_code = util.run_cmd(cmd, self.env, cwd=target_dir) util.check_ouput("BUILD SUCCESS", out, contains=False) - util.check_ouput("In order to run the graalpyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration.", out) + util.check_ouput("In order to run the graalPyLockPackages task there have to be python packages declared in the graalpy-gradle-plugin configuration.", out) assert not os.path.exists(os.path.join(target_dir, "graalpy.lock")) diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java index 810c183489..b81bf0fa00 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java @@ -72,41 +72,6 @@ public abstract class AbstractGraalPyMojo extends AbstractMojo { private static final String PYTHON_ARTIFACT_ID = "python"; private static final String GRAALPY_MAVEN_PLUGIN_ARTIFACT_ID = "graalpy-maven-plugin"; - protected static final String LOCK_FILE_HEADER = """ - This file was generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. - - WARNING: Any manual changes are done at your own risk and will be overwritten when the goal is executed. - - This file is meant to be tracked in a version control system. - - This file contains a list of all required Python packages with their specific versions, - based on the packages defined in the plugin configuration and their dependencies. - """; - - protected static final String MISSING_LOCK_FILE_WARNING = """ - - The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. - This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. - - In such cases, it is strongly recommended to lock the Python dependencies by executing the Maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. - - For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String PACKAGES_CHANGED_ERROR = """ - Install of python packages is based on lock file %s, - but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file. - - Packages currently declared in graalpy-maven-plugin configuration: %s - Packages which were used to generate the lock file: %s - - The lock file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - @Parameter(defaultValue = "${project}", required = true, readonly = true) MavenProject project; diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java index ce9bfe09ec..8f415a72c6 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java @@ -45,6 +45,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.PackagesChangedException; import java.io.IOException; import java.nio.file.Path; @@ -54,6 +55,30 @@ requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) public class InstallPackagesMojo extends AbstractGraalPyMojo { + private static final String PACKAGES_CHANGED_ERROR = """ + + Install of python packages is based on lock file %s, + but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file. + + Packages currently declared in graalpy-maven-plugin configuration: %s + Packages which were used to generate the lock file: %s + + The lock file has to be refreshed by running the maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + """; + + protected static final String MISSING_LOCK_FILE_WARNING = """ + + The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. + This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. + + In such cases, it is strongly recommended to lock the Python dependencies by executing the Maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. + + For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + + """; + public void execute() throws MojoExecutionException { preExec(true); @@ -67,9 +92,13 @@ public void execute() throws MojoExecutionException { private void manageVenv() throws MojoExecutionException { Path venvDirectory = getVenvDirectory(); MavenDelegateLog log = new MavenDelegateLog(getLog()); - Path requirements = getLockFile(); + Path lockFile = getLockFile(); try { - VFSUtils.createVenv(venvDirectory, packages, requirements, PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + VFSUtils.createVenv(venvDirectory, packages, lockFile, MISSING_LOCK_FILE_WARNING, createLauncher(), getGraalPyVersion(project), log); + } catch(PackagesChangedException pce) { + String pluginPkgsString = pce.getPluginPackages().isEmpty() ? "None" : String.join(", ", pce.getPluginPackages()); + String lockFilePkgsString = pce.getLockFilePackages().isEmpty() ? "None" : String.join(", ", pce.getLockFilePackages()); + throw new MojoExecutionException(String.format(PACKAGES_CHANGED_ERROR, lockFile, pluginPkgsString, lockFilePkgsString)); } catch (IOException e) { throw new MojoExecutionException(String.format("failed to create venv %s", venvDirectory), e); } diff --git a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java index 52458551de..c0bea2e693 100644 --- a/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java +++ b/graalpython/graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java @@ -55,6 +55,17 @@ requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) public class LockPackagesMojo extends AbstractGraalPyMojo { + protected static final String LOCK_FILE_HEADER = """ + This file was generated by maven goal 'org.graalvm.python:graalpy-maven-plugin:lock-packages'. + + WARNING: Any manual changes are done at your own risk and will be overwritten when the goal is executed. + + This file is meant to be tracked in a version control system. + + This file contains a list of all required Python packages with their specific versions, + based on the packages defined in the plugin configuration and their dependencies. + """; + public void execute() throws MojoExecutionException { preExec(false); checkEmptyPackages(); diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 60cb28d473..db7f5ebd80 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -386,20 +386,44 @@ private static List getHeaderList(String lockFileHeader) { } } + public static final class PackagesChangedException extends Exception { + private static final long serialVersionUID = 9162516912727973035L; + + private final transient List pluginPackages; + private final transient List lockFilePackages; + + private PackagesChangedException(List pluginPackages, List lockFilePackages) { + this.pluginPackages = pluginPackages; + this.lockFilePackages = lockFilePackages; + } + + public List getPluginPackages() { + return pluginPackages; + } + + public List getLockFilePackages() { + return lockFilePackages; + } + + } + public static void createVenv(Path venvDirectory, List packagesArgs, Launcher launcherArgs, String graalPyVersion, BuildToolLog log) throws IOException { - createVenv(venvDirectory, packagesArgs, null, null, null, launcherArgs, graalPyVersion, log); + try { + createVenv(venvDirectory, packagesArgs, null, null, launcherArgs, graalPyVersion, log); + } catch (PackagesChangedException e) { + // should not happen + assert false; + throw new IllegalStateException(e); + } } - public static void createVenv(Path venvDirectory, List packages, Path lockFilePath, String packagesChangedError, String missingLockFileWarning, Launcher launcher, String graalPyVersion, - BuildToolLog log) throws IOException { + public static void createVenv(Path venvDirectory, List packages, Path lockFilePath, String missingLockFileWarning, Launcher launcher, String graalPyVersion, BuildToolLog log) + throws IOException, PackagesChangedException { Objects.requireNonNull(venvDirectory); Objects.requireNonNull(packages); Objects.requireNonNull(launcher); Objects.requireNonNull(graalPyVersion); Objects.requireNonNull(log); - if (lockFilePath != null) { - Objects.requireNonNull(packagesChangedError); - } logVenvArgs(venvDirectory, packages, lockFilePath, launcher, graalPyVersion, log); @@ -409,7 +433,7 @@ public static void createVenv(Path venvDirectory, List packages, Path lo lockFile = LockFile.fromFile(lockFilePath, log); } - if (!checkPackages(venvDirectory, pluginPackages, lockFile, packagesChangedError, log)) { + if (!checkPackages(venvDirectory, pluginPackages, lockFile, log)) { return; } @@ -514,9 +538,9 @@ private static void logVenvArgs(Path venvDirectory, List packages, Path } } - private static boolean checkPackages(Path venvDirectory, List pluginPackages, LockFile lockFile, String packagesListChangedError, BuildToolLog log) throws IOException { + private static boolean checkPackages(Path venvDirectory, List pluginPackages, LockFile lockFile, BuildToolLog log) throws IOException, PackagesChangedException { if (lockFile != null) { - checkPluginPackagesInLockFile(pluginPackages, lockFile, packagesListChangedError, log); + checkPluginPackagesInLockFile(pluginPackages, lockFile); logPackages(lockFile.packages, lockFile.path, log); return needVenv(venvDirectory, lockFile.packages, log); } else { @@ -629,22 +653,9 @@ private static void missingLockFileWarning(Path venvDirectory, List newP /** * check that there are no plugin packages missing in lock file */ - private static void checkPluginPackagesInLockFile(List pluginPackages, LockFile lockFile, String packagesChangedError, BuildToolLog log) - throws IOException { - checkPluginPackagesInLockFile(pluginPackages, lockFile.inputPackages, lockFile.path, packagesChangedError, log); - } - - /** - * Accessed from VFSUtilsTest - */ - private static void checkPluginPackagesInLockFile(List pluginPackages, List lockFilePackages, Path lockFilePath, String packagesChangedError, BuildToolLog log) - throws IOException { - - if (pluginPackages.size() != lockFilePackages.size() || !pluginPackages.containsAll(lockFilePackages)) { - String pluginPkgsString = pluginPackages.isEmpty() ? "None" : String.join(", ", pluginPackages); - String lockFilePkgsString = lockFilePackages.isEmpty() ? "None" : String.join(", ", lockFilePackages); - extendedError(log, String.format(packagesChangedError, lockFilePath, pluginPkgsString, lockFilePkgsString) + "\n"); - throw new IOException("inconsistent packages"); + private static void checkPluginPackagesInLockFile(List pluginPackages, LockFile lockFile) throws PackagesChangedException { + if (pluginPackages.size() != lockFile.inputPackages.size() || !pluginPackages.containsAll(lockFile.inputPackages)) { + throw new PackagesChangedException(new ArrayList<>(pluginPackages), new ArrayList<>(lockFile.inputPackages)); } } @@ -814,16 +825,6 @@ private static void warning(BuildToolLog log, String txt) { log.warning(txt); } - private static void extendedError(BuildToolLog log, String txt) { - if (log.isErrorEnabled()) { - log.error(""); - for (String t : txt.split("\n")) { - log.error(t); - } - log.error(""); - } - } - private static void info(BuildToolLog log, String txt, Object... args) { if (log.isInfoEnabled()) { log.info(String.format(txt, args)); diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index f761ef341c..8770c5746a 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -83,42 +83,6 @@ */ public abstract class AbstractPackagesTask extends DefaultTask { - protected static final String LOCK_FILE_HEADER = """ - This file was generated by gradle task 'graalPyLockPackages'. - - WARNING: Any manual changes are done at your own risk and will be overwritten when the task is executed. - - This file is meant to be tracked in a version control system. - - This file contains a list of all required Python packages with their specific versions, - based on the packages defined in the plugin configuration and their dependencies. - - """; - - protected static final String MISSING_LOCK_FILE_WARNING = """ - - WARNING: The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. - WARNING: This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. - - WARNING: In such cases, it is strongly recommended to lock the Python dependencies by executing the Gradle task 'graalPyLockPackages'. - - For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - - protected static final String PACKAGES_CHANGED_ERROR = """ - Install of python packages is based on lock file %s, - but packages and their version constraints in graalpy-maven-plugin configuration are different then previously used to generate the lock file. - - Packages currently declared in graalpy-gradle-plugin configuration: %s - Packages which were used to generate the lock file: %s - - The lock file has to be refreshed by running the gradle task 'graalPyLockPackages'. - - For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management - - """; - @Input public abstract ListProperty getPackages(); @@ -127,7 +91,7 @@ public abstract class AbstractPackagesTask extends DefaultTask { @Classpath public abstract ConfigurableFileCollection getLauncherClasspath(); - + /** * The directory where the virtual filesystem should be generated. If {@link #getIncludeVfsRoot()} is set, * then this is the parent directory where the actual VFS directory should be created and populated with diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java index dd592e2203..21da31e2a2 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/InstallPackagesTask.java @@ -48,6 +48,7 @@ import java.nio.file.Path; import org.graalvm.python.embedding.tools.vfs.VFSUtils; +import org.graalvm.python.embedding.tools.vfs.VFSUtils.PackagesChangedException; /** * This task is responsible installing the dependencies which were requested by the user. @@ -65,11 +66,41 @@ */ @CacheableTask public abstract class InstallPackagesTask extends AbstractPackagesTask { + + private static final String PACKAGES_CHANGED_ERROR = """ + Install of python packages is based on lock file %s, + but packages and their version constraints in graalpy-gradle-plugin configuration are different then previously used to generate the lock file. + + Packages currently declared in graalpy-gradle-plugin configuration: %s + Packages which were used to generate the lock file: %s + + The lock file has to be refreshed by running the gradle task 'graalPyLockPackages'. + + For more information, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + + """; + + protected static final String MISSING_LOCK_FILE_WARNING = """ + + WARNING: The list of installed Python packages does not match the packages specified in the graalpy-maven-plugin configuration. + WARNING: This could indicate that either extra dependencies were installed or some packages were installed with a more specific versions than declared. + + WARNING: In such cases, it is strongly recommended to lock the Python dependencies by executing the Gradle task 'graalPyLockPackages'. + + For more details on managing Python dependencies, please refer to https://www.graalvm.org/latest/reference-manual/python/Embedding-Build-Tools#Python-Dependency-Management + + """; + @TaskAction public void exec() throws GradleException { Path venvDirectory = getVenvDirectory().get().getAsFile().toPath(); + Path lockFilePath = getLockFilePath(); try { - VFSUtils.createVenv(venvDirectory, getPackages().get(), getLockFilePath(), PACKAGES_CHANGED_ERROR, MISSING_LOCK_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); + VFSUtils.createVenv(venvDirectory, getPackages().get(), lockFilePath, MISSING_LOCK_FILE_WARNING, createLauncher(), getPolyglotVersion().get(), getLog()); + } catch(PackagesChangedException pce) { + String pluginPkgsString = pce.getPluginPackages().isEmpty() ? "None" : String.join(", ", pce.getPluginPackages()); + String lockFilePkgsString = pce.getLockFilePackages().isEmpty() ? "None" : String.join(", ", pce.getLockFilePackages()); + throw new GradleException(String.format(PACKAGES_CHANGED_ERROR, lockFilePath, pluginPkgsString, lockFilePkgsString)); } catch (IOException e) { throw new GradleException(String.format("failed to create python virtual environment in %s", venvDirectory), e); } diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java index 1017b67abe..064cd8a712 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/LockPackagesTask.java @@ -58,6 +58,19 @@ */ @UntrackedTask(because="manually triggered, should always run") public abstract class LockPackagesTask extends AbstractPackagesTask { + + protected static final String LOCK_FILE_HEADER = """ + This file was generated by gradle task 'graalPyLockPackages'. + + WARNING: Any manual changes are done at your own risk and will be overwritten when the task is executed. + + This file is meant to be tracked in a version control system. + + This file contains a list of all required Python packages with their specific versions, + based on the packages defined in the plugin configuration and their dependencies. + + """; + @TaskAction public void exec() throws GradleException { checkEmptyPackages(); From aa0ceccf41a9a7940c75f454bff4d47d4681b006 Mon Sep 17 00:00:00 2001 From: Tomas Stupka Date: Wed, 12 Mar 2025 14:05:13 +0100 Subject: [PATCH 154/512] minor javadoc cleanup in AbstractPackagesTask --- .../org/graalvm/python/tasks/AbstractPackagesTask.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java index 8770c5746a..de41e89b2a 100644 --- a/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java +++ b/graalpython/org.graalvm.python.gradle.plugin/src/main/java/org/graalvm/python/tasks/AbstractPackagesTask.java @@ -91,12 +91,9 @@ public abstract class AbstractPackagesTask extends DefaultTask { @Classpath public abstract ConfigurableFileCollection getLauncherClasspath(); - + /** - * The directory where the virtual filesystem should be generated. If {@link #getIncludeVfsRoot()} is set, - * then this is the parent directory where the actual VFS directory should be created and populated with - * "venv" subdirectory (this is the case when we generate the VFS to Java resources). Otherwise, this path - * is used as is. + * The directory where the virtual filesystem should be generated. */ @OutputDirectory public abstract DirectoryProperty getOutput(); From 1bd3164f7db822113bb485689f164653108a1cfb Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 13 Mar 2025 11:22:13 +0100 Subject: [PATCH 155/512] Implement tp_str and tp_repr --- .../oracle/graal/python/annotations/Slot.java | 6 +- .../graal/python/processor/SlotsMapping.java | 6 +- .../graal/python/builtins/Python3Core.java | 2 + .../builtins/PythonBuiltinClassType.java | 155 +++++++------ .../builtins/modules/BuiltinConstructors.java | 9 +- .../cext/PythonCextStructSeqBuiltins.java | 6 +- .../modules/ctypes/CArgObjectBuiltins.java | 8 +- .../modules/ctypes/CFieldBuiltins.java | 3 +- .../modules/ctypes/PyCFuncPtrBuiltins.java | 3 +- .../modules/ctypes/SimpleCDataBuiltins.java | 3 +- .../modules/functools/PartialBuiltins.java | 8 +- .../modules/hashlib/HashObjectBuiltins.java | 12 +- .../modules/io/BufferedIOMixinBuiltins.java | 9 +- .../builtins/modules/io/FileIOBuiltins.java | 16 +- .../modules/io/TextIOWrapperBuiltins.java | 13 +- .../python/builtins/objects/NoneBuiltins.java | 6 +- .../objects/NotImplementedBuiltins.java | 17 +- .../builtins/objects/array/ArrayBuiltins.java | 11 +- .../builtins/objects/bool/BoolBuiltins.java | 11 +- .../objects/bytes/ByteArrayBuiltins.java | 3 +- .../builtins/objects/bytes/BytesBuiltins.java | 3 +- .../builtins/objects/cell/CellBuiltins.java | 12 +- .../builtins/objects/code/CodeBuiltins.java | 8 +- .../objects/common/FormatNodeBase.java | 22 +- .../objects/complex/ComplexBuiltins.java | 3 +- .../builtins/objects/deque/DequeBuiltins.java | 3 +- .../objects/dict/DefaultDictBuiltins.java | 3 +- .../objects/dict/DictReprBuiltin.java | 9 +- .../objects/ellipsis/EllipsisBuiltins.java | 17 +- .../exception/BaseExceptionBuiltins.java | 11 +- .../exception/BaseExceptionGroupBuiltins.java | 9 +- .../exception/ImportErrorBuiltins.java | 8 +- .../objects/exception/KeyErrorBuiltins.java | 12 +- .../objects/exception/OsErrorBuiltins.java | 8 +- .../exception/SyntaxErrorBuiltins.java | 8 +- .../exception/UnicodeDecodeErrorBuiltins.java | 8 +- .../exception/UnicodeEncodeErrorBuiltins.java | 9 +- .../UnicodeTranslateErrorBuiltins.java | 8 +- .../objects/floats/FloatBuiltins.java | 6 +- .../foreign/ForeignBooleanBuiltins.java | 8 +- .../foreign/ForeignNumberBuiltins.java | 6 +- .../foreign/ForeignObjectBuiltins.java | 23 +- .../builtins/objects/frame/FrameBuiltins.java | 8 +- .../objects/function/FunctionBuiltins.java | 3 +- .../function/MethodDescriptorBuiltins.java | 5 +- .../function/WrapperDescriptorBuiltins.java | 5 +- .../objects/generator/CoroutineBuiltins.java | 9 +- .../objects/generator/GeneratorBuiltins.java | 3 +- .../GetSetDescriptorTypeBuiltins.java | 5 +- .../MemberDescriptorBuiltins.java | 3 +- .../builtins/objects/ints/IntBuiltins.java | 8 +- .../objects/itertools/CountBuiltins.java | 3 +- .../objects/itertools/RepeatBuiltins.java | 3 +- .../builtins/objects/list/ListBuiltins.java | 3 +- .../mappingproxy/MappingproxyBuiltins.java | 6 +- .../memoryview/MemoryViewBuiltins.java | 3 +- .../method/BuiltinClassmethodBuiltins.java | 10 +- .../BuiltinFunctionOrMethodBuiltins.java | 10 +- .../objects/method/ClassmethodBuiltins.java | 139 +----------- .../method/ClassmethodCommonBuiltins.java | 204 ++++++++++++++++++ .../method/InstancemethodBuiltins.java | 3 +- .../objects/method/MethodBuiltins.java | 3 +- .../objects/method/MethodWrapperBuiltins.java | 10 +- .../objects/method/StaticmethodBuiltins.java | 3 +- .../namespace/SimpleNamespaceBuiltins.java | 9 +- .../objects/object/ObjectBuiltins.java | 25 ++- .../ordereddict/OrderedDictBuiltins.java | 3 +- .../objects/posix/DirEntryBuiltins.java | 16 +- .../builtins/objects/range/RangeBuiltins.java | 5 +- .../referencetype/ReferenceTypeBuiltins.java | 11 +- .../builtins/objects/set/BaseSetBuiltins.java | 3 +- .../builtins/objects/slice/SliceBuiltins.java | 10 +- .../objects/socket/SocketBuiltins.java | 8 +- .../objects/ssl/SSLErrorBuiltins.java | 8 +- .../builtins/objects/str/StringBuiltins.java | 6 +- .../objects/superobject/SuperBuiltins.java | 3 +- .../builtins/objects/thread/LockBuiltins.java | 9 +- .../objects/tuple/StructSequence.java | 26 ++- .../builtins/objects/tuple/TupleBuiltins.java | 3 +- .../objects/type/SpecialMethodSlot.java | 12 -- .../python/builtins/objects/type/TpSlots.java | 26 ++- .../builtins/objects/type/TypeBuiltins.java | 3 +- .../objects/type/slots/TpSlotRepr.java | 192 +++++++++++++++++ .../objects/types/GenericAliasBuiltins.java | 3 +- .../objects/types/UnionTypeBuiltins.java | 3 +- .../python/lib/PyObjectReprAsObjectNode.java | 43 ++-- .../python/lib/PyObjectStrAsObjectNode.java | 44 ++-- 87 files changed, 901 insertions(+), 530 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodCommonBuiltins.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotRepr.java diff --git a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java index a7bee38dee..650738f722 100644 --- a/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java +++ b/graalpython/com.oracle.graal.python.annotations/src/com/oracle/graal/python/annotations/Slot.java @@ -196,7 +196,11 @@ enum SlotKind { /** iter(obj) */ tp_iter("__iter__"), /** next(obj) */ - tp_iternext("__next__"); + tp_iternext("__next__"), + /** str(obj) */ + tp_str("__str__"), + /** repr(obj) */ + tp_repr("__repr__"); SlotKind(@SuppressWarnings("unused") String specialMethods) { } diff --git a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java index c3e8797341..9a04c3a8ab 100644 --- a/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java +++ b/graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/SlotsMapping.java @@ -53,7 +53,7 @@ static String getSlotBaseClass(Slot s) { return switch (s.value()) { case nb_bool -> "TpSlotInquiry.TpSlotInquiryBuiltin"; case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert, - tp_iter -> + tp_iter, tp_str, tp_repr -> "TpSlotUnaryFunc.TpSlotUnaryFuncBuiltin"; case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> @@ -85,7 +85,7 @@ static String getSlotNodeBaseClass(Slot s) { case tp_descr_get -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode"; case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode"; case nb_index, nb_int, nb_float, nb_absolute, nb_positive, nb_negative, nb_invert, - tp_iter, tp_iternext -> + tp_iter, tp_iternext, tp_str, tp_repr -> "com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode"; case nb_add, nb_subtract, nb_multiply, nb_remainder, nb_divmod, nb_lshift, nb_rshift, nb_and, nb_xor, nb_or, nb_floor_divide, nb_true_divide, nb_matrix_multiply -> @@ -181,6 +181,8 @@ public static String getExtraCtorArgs(TpSlotData slot) { case sq_inplace_concat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IADD__"; case sq_inplace_repeat -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___IMUL__"; case tp_iter -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ITER__"; + case tp_str -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__"; + case tp_repr -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__"; default -> ""; }; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index d659f2cdab..298be8e5ad 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -312,6 +312,7 @@ import com.oracle.graal.python.builtins.objects.method.BuiltinClassmethodBuiltins; import com.oracle.graal.python.builtins.objects.method.BuiltinFunctionOrMethodBuiltins; import com.oracle.graal.python.builtins.objects.method.ClassmethodBuiltins; +import com.oracle.graal.python.builtins.objects.method.ClassmethodCommonBuiltins; import com.oracle.graal.python.builtins.objects.method.DecoratedMethodBuiltins; import com.oracle.graal.python.builtins.objects.method.InstancemethodBuiltins; import com.oracle.graal.python.builtins.objects.method.MethodBuiltins; @@ -462,6 +463,7 @@ private static PythonBuiltins[] initializeBuiltins(TruffleLanguage.Env env) { new BuiltinFunctions(), new DecoratedMethodBuiltins(), new ClassmethodBuiltins(), + new ClassmethodCommonBuiltins(), new StaticmethodBuiltins(), new InstancemethodBuiltins(), new SimpleNamespaceBuiltins(), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java index 0ed5eaa90b..9921e330c1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java @@ -114,6 +114,7 @@ import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.builtins.modules.WeakRefModuleBuiltins; import com.oracle.graal.python.builtins.modules.csv.CSVReaderBuiltins; +import com.oracle.graal.python.builtins.modules.ctypes.CArgObjectBuiltins; import com.oracle.graal.python.builtins.modules.ctypes.CDataTypeSequenceBuiltins; import com.oracle.graal.python.builtins.modules.ctypes.CFieldBuiltins; import com.oracle.graal.python.builtins.modules.ctypes.PyCArrayBuiltins; @@ -123,12 +124,17 @@ import com.oracle.graal.python.builtins.modules.ctypes.SimpleCDataBuiltins; import com.oracle.graal.python.builtins.modules.ctypes.StgDictBuiltins; import com.oracle.graal.python.builtins.modules.functools.LruCacheWrapperBuiltins; +import com.oracle.graal.python.builtins.modules.functools.PartialBuiltins; +import com.oracle.graal.python.builtins.modules.hashlib.HashObjectBuiltins; +import com.oracle.graal.python.builtins.modules.io.BufferedIOMixinBuiltins; import com.oracle.graal.python.builtins.modules.io.BufferedReaderMixinBuiltins; import com.oracle.graal.python.builtins.modules.io.BytesIOBuiltins; +import com.oracle.graal.python.builtins.modules.io.FileIOBuiltins; import com.oracle.graal.python.builtins.modules.io.IOBaseBuiltins; import com.oracle.graal.python.builtins.modules.io.StringIOBuiltins; import com.oracle.graal.python.builtins.modules.io.TextIOWrapperBuiltins; import com.oracle.graal.python.builtins.objects.NoneBuiltins; +import com.oracle.graal.python.builtins.objects.NotImplementedBuiltins; import com.oracle.graal.python.builtins.objects.array.ArrayBuiltins; import com.oracle.graal.python.builtins.objects.asyncio.AsyncGenSendBuiltins; import com.oracle.graal.python.builtins.objects.asyncio.AsyncGenThrowBuiltins; @@ -137,6 +143,8 @@ import com.oracle.graal.python.builtins.objects.bytes.ByteArrayBuiltins; import com.oracle.graal.python.builtins.objects.bytes.BytesBuiltins; import com.oracle.graal.python.builtins.objects.bytes.BytesCommonBuiltins; +import com.oracle.graal.python.builtins.objects.cell.CellBuiltins; +import com.oracle.graal.python.builtins.objects.code.CodeBuiltins; import com.oracle.graal.python.builtins.objects.complex.ComplexBuiltins; import com.oracle.graal.python.builtins.objects.contextvars.ContextBuiltins; import com.oracle.graal.python.builtins.objects.contextvars.ContextIteratorBuiltins; @@ -144,18 +152,31 @@ import com.oracle.graal.python.builtins.objects.deque.DequeIterBuiltins; import com.oracle.graal.python.builtins.objects.dict.DefaultDictBuiltins; import com.oracle.graal.python.builtins.objects.dict.DictBuiltins; +import com.oracle.graal.python.builtins.objects.dict.DictReprBuiltin; import com.oracle.graal.python.builtins.objects.dict.DictValuesBuiltins; import com.oracle.graal.python.builtins.objects.dict.DictViewBuiltins; +import com.oracle.graal.python.builtins.objects.ellipsis.EllipsisBuiltins; import com.oracle.graal.python.builtins.objects.enumerate.EnumerateBuiltins; +import com.oracle.graal.python.builtins.objects.exception.BaseExceptionBuiltins; +import com.oracle.graal.python.builtins.objects.exception.BaseExceptionGroupBuiltins; +import com.oracle.graal.python.builtins.objects.exception.ImportErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.KeyErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.OsErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.SyntaxErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.UnicodeDecodeErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.UnicodeEncodeErrorBuiltins; +import com.oracle.graal.python.builtins.objects.exception.UnicodeTranslateErrorBuiltins; import com.oracle.graal.python.builtins.objects.floats.FloatBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignBooleanBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignIterableBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignNumberBuiltins; import com.oracle.graal.python.builtins.objects.foreign.ForeignObjectBuiltins; +import com.oracle.graal.python.builtins.objects.frame.FrameBuiltins; import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor; import com.oracle.graal.python.builtins.objects.function.FunctionBuiltins; import com.oracle.graal.python.builtins.objects.function.MethodDescriptorBuiltins; import com.oracle.graal.python.builtins.objects.function.WrapperDescriptorBuiltins; +import com.oracle.graal.python.builtins.objects.generator.CoroutineBuiltins; import com.oracle.graal.python.builtins.objects.generator.GeneratorBuiltins; import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptorTypeBuiltins; import com.oracle.graal.python.builtins.objects.getsetdescriptor.MemberDescriptorBuiltins; @@ -186,29 +207,41 @@ import com.oracle.graal.python.builtins.objects.map.MapBuiltins; import com.oracle.graal.python.builtins.objects.mappingproxy.MappingproxyBuiltins; import com.oracle.graal.python.builtins.objects.memoryview.MemoryViewBuiltins; +import com.oracle.graal.python.builtins.objects.method.BuiltinClassmethodBuiltins; +import com.oracle.graal.python.builtins.objects.method.BuiltinFunctionOrMethodBuiltins; import com.oracle.graal.python.builtins.objects.method.ClassmethodBuiltins; +import com.oracle.graal.python.builtins.objects.method.ClassmethodCommonBuiltins; import com.oracle.graal.python.builtins.objects.method.InstancemethodBuiltins; import com.oracle.graal.python.builtins.objects.method.MethodBuiltins; +import com.oracle.graal.python.builtins.objects.method.MethodWrapperBuiltins; import com.oracle.graal.python.builtins.objects.method.StaticmethodBuiltins; import com.oracle.graal.python.builtins.objects.mmap.MMapBuiltins; import com.oracle.graal.python.builtins.objects.module.ModuleBuiltins; +import com.oracle.graal.python.builtins.objects.namespace.SimpleNamespaceBuiltins; import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins; import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictBuiltins; import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictItemsBuiltins; import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictIteratorBuiltins; import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictKeysBuiltins; import com.oracle.graal.python.builtins.objects.ordereddict.OrderedDictValuesBuiltins; +import com.oracle.graal.python.builtins.objects.posix.DirEntryBuiltins; import com.oracle.graal.python.builtins.objects.posix.ScandirIteratorBuiltins; import com.oracle.graal.python.builtins.objects.property.PropertyBuiltins; import com.oracle.graal.python.builtins.objects.range.RangeBuiltins; +import com.oracle.graal.python.builtins.objects.referencetype.ReferenceTypeBuiltins; import com.oracle.graal.python.builtins.objects.reversed.ReversedBuiltins; import com.oracle.graal.python.builtins.objects.set.BaseSetBuiltins; import com.oracle.graal.python.builtins.objects.set.SetBuiltins; +import com.oracle.graal.python.builtins.objects.slice.SliceBuiltins; +import com.oracle.graal.python.builtins.objects.socket.SocketBuiltins; +import com.oracle.graal.python.builtins.objects.ssl.SSLErrorBuiltins; import com.oracle.graal.python.builtins.objects.str.StringBuiltins; import com.oracle.graal.python.builtins.objects.struct.StructUnpackIteratorBuiltins; import com.oracle.graal.python.builtins.objects.superobject.SuperBuiltins; +import com.oracle.graal.python.builtins.objects.thread.LockBuiltins; import com.oracle.graal.python.builtins.objects.thread.ThreadLocalBuiltins; import com.oracle.graal.python.builtins.objects.tokenize.TokenizerIterBuiltins; +import com.oracle.graal.python.builtins.objects.tuple.StructSequence; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleGetterBuiltins; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; @@ -242,22 +275,22 @@ public enum PythonBuiltinClassType implements TruffleObject { /** See {@link com.oracle.graal.python.builtins.objects.function.PBuiltinFunction} */ PBuiltinFunction("method_descriptor", Flags.PRIVATE_DERIVED_WODICT, MethodDescriptorBuiltins.SLOTS), /** See {@link com.oracle.graal.python.builtins.objects.method.PBuiltinMethod} */ - PBuiltinFunctionOrMethod("builtin_function_or_method", Flags.PRIVATE_DERIVED_WODICT), + PBuiltinFunctionOrMethod("builtin_function_or_method", Flags.PRIVATE_DERIVED_WODICT, BuiltinFunctionOrMethodBuiltins.SLOTS), /** See {@link com.oracle.graal.python.builtins.objects.function.PBuiltinFunction} */ WrapperDescriptor(J_WRAPPER_DESCRIPTOR, Flags.PRIVATE_DERIVED_WODICT, WrapperDescriptorBuiltins.SLOTS), /** See {@link com.oracle.graal.python.builtins.objects.method.PBuiltinMethod} */ - MethodWrapper("method-wrapper", Flags.PRIVATE_DERIVED_WODICT), + MethodWrapper("method-wrapper", Flags.PRIVATE_DERIVED_WODICT, MethodWrapperBuiltins.SLOTS), /** See {@link com.oracle.graal.python.builtins.objects.method.PBuiltinMethod} */ PBuiltinMethod("builtin_method", Flags.PRIVATE_DERIVED_WODICT), - PBuiltinClassMethod("classmethod_descriptor", Flags.PRIVATE_DERIVED_WODICT, ClassmethodBuiltins.SLOTS), + PBuiltinClassMethod("classmethod_descriptor", Flags.PRIVATE_DERIVED_WODICT, TpSlots.merge(ClassmethodCommonBuiltins.SLOTS, BuiltinClassmethodBuiltins.SLOTS)), GetSetDescriptor("getset_descriptor", Flags.PRIVATE_DERIVED_WODICT, GetSetDescriptorTypeBuiltins.SLOTS), MemberDescriptor(J_MEMBER_DESCRIPTOR, Flags.PRIVATE_DERIVED_WODICT, MemberDescriptorBuiltins.SLOTS), PByteArray("bytearray", J_BUILTINS, BYTE_ARRAY_M_FLAGS, TpSlots.merge(BytesCommonBuiltins.SLOTS, ByteArrayBuiltins.SLOTS)), PBytes("bytes", J_BUILTINS, BYTES_M_FLAGS, TpSlots.merge(BytesCommonBuiltins.SLOTS, BytesBuiltins.SLOTS)), - PCell("cell", Flags.PRIVATE_DERIVED_WODICT), - PSimpleNamespace("SimpleNamespace", null, "types", Flags.PUBLIC_BASE_WDICT), + PCell("cell", Flags.PRIVATE_DERIVED_WODICT, CellBuiltins.SLOTS), + PSimpleNamespace("SimpleNamespace", null, "types", Flags.PUBLIC_BASE_WDICT, SimpleNamespaceBuiltins.SLOTS), PKeyWrapper("KeyWrapper", "_functools", "functools", Flags.PUBLIC_DERIVED_WODICT), - PPartial(J_PARTIAL, "_functools", "functools", Flags.PUBLIC_BASE_WDICT), + PPartial(J_PARTIAL, "_functools", "functools", Flags.PUBLIC_BASE_WDICT, PartialBuiltins.SLOTS), PLruListElem("_lru_list_elem", null, "functools", Flags.PUBLIC_DERIVED_WODICT), PLruCacheWrapper(J_LRU_CACHE_WRAPPER, "_functools", "functools", Flags.PUBLIC_BASE_WDICT, LruCacheWrapperBuiltins.SLOTS), PDefaultDict(J_DEFAULTDICT, "_collections", "collections", Flags.PUBLIC_BASE_WODICT, DEFAULTDICT_M_FLAGS, DefaultDictBuiltins.SLOTS), @@ -271,25 +304,25 @@ public enum PythonBuiltinClassType implements TruffleObject { POrderedDictItems("odict_items", Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS, OrderedDictItemsBuiltins.SLOTS), POrderedDictIterator("odict_iterator", Flags.PRIVATE_DERIVED_WODICT, OrderedDictIteratorBuiltins.SLOTS), PComplex("complex", J_BUILTINS, COMPLEX_M_FLAGS, ComplexBuiltins.SLOTS), - PDict("dict", J_BUILTINS, DICT_M_FLAGS, DictBuiltins.SLOTS), + PDict("dict", J_BUILTINS, DICT_M_FLAGS, TpSlots.merge(DictBuiltins.SLOTS, DictReprBuiltin.SLOTS)), PDictItemIterator(J_DICT_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), PDictReverseItemIterator(J_DICT_REVERSE_ITEMITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), - PDictItemsView(J_DICT_ITEMS, Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS, DictViewBuiltins.SLOTS), + PDictItemsView(J_DICT_ITEMS, Flags.PRIVATE_DERIVED_WODICT, DICTITEMSVIEW_M_FLAGS, TpSlots.merge(DictViewBuiltins.SLOTS, DictReprBuiltin.SLOTS)), PDictKeyIterator(J_DICT_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), PDictReverseKeyIterator(J_DICT_REVERSE_KEYITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), - PDictKeysView(J_DICT_KEYS, Flags.PRIVATE_DERIVED_WODICT, DICTKEYSVIEW_M_FLAGS, DictViewBuiltins.SLOTS), + PDictKeysView(J_DICT_KEYS, Flags.PRIVATE_DERIVED_WODICT, DICTKEYSVIEW_M_FLAGS, TpSlots.merge(DictViewBuiltins.SLOTS, DictReprBuiltin.SLOTS)), PDictValueIterator(J_DICT_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), PDictReverseValueIterator(J_DICT_REVERSE_VALUEITERATOR, Flags.PRIVATE_DERIVED_WODICT, IteratorBuiltins.SLOTS), - PDictValuesView(J_DICT_VALUES, Flags.PRIVATE_DERIVED_WODICT, DICTVALUESVIEW_M_FLAGS, DictValuesBuiltins.SLOTS), - PEllipsis("ellipsis", Flags.PRIVATE_DERIVED_WODICT), + PDictValuesView(J_DICT_VALUES, Flags.PRIVATE_DERIVED_WODICT, DICTVALUESVIEW_M_FLAGS, TpSlots.merge(DictValuesBuiltins.SLOTS, DictReprBuiltin.SLOTS)), + PEllipsis("ellipsis", Flags.PRIVATE_DERIVED_WODICT, EllipsisBuiltins.SLOTS), PEnumerate("enumerate", J_BUILTINS, EnumerateBuiltins.SLOTS), PMap("map", J_BUILTINS, MapBuiltins.SLOTS), PFloat("float", J_BUILTINS, FLOAT_M_FLAGS, FloatBuiltins.SLOTS), - PFrame("frame", Flags.PRIVATE_DERIVED_WODICT), + PFrame("frame", Flags.PRIVATE_DERIVED_WODICT, FrameBuiltins.SLOTS), PFrozenSet("frozenset", J_BUILTINS, FROZENSET_M_FLAGS, BaseSetBuiltins.SLOTS), PFunction("function", Flags.PRIVATE_DERIVED_WDICT, FunctionBuiltins.SLOTS), PGenerator("generator", Flags.PRIVATE_DERIVED_WODICT, GENERATOR_M_FLAGS, GeneratorBuiltins.SLOTS), - PCoroutine("coroutine", Flags.PRIVATE_DERIVED_WODICT, COROUTINE_M_FLAGS), + PCoroutine("coroutine", Flags.PRIVATE_DERIVED_WODICT, COROUTINE_M_FLAGS, CoroutineBuiltins.SLOTS), PCoroutineWrapper("coroutine_wrapper", Flags.PRIVATE_DERIVED_WODICT, CoroutineWrapperBuiltins.SLOTS), PAsyncGenerator("async_generator", Flags.PRIVATE_DERIVED_WODICT, ASYNC_GENERATOR_M_FLAGS), PInt("int", J_BUILTINS, INT_M_FLAGS, IntBuiltins.SLOTS), @@ -302,16 +335,16 @@ public enum PythonBuiltinClassType implements TruffleObject { PMethod("method", Flags.PRIVATE_DERIVED_WODICT, MethodBuiltins.SLOTS), PMMap("mmap", "mmap", MMAP_M_FLAGS, MMapBuiltins.SLOTS), PNone("NoneType", Flags.PRIVATE_DERIVED_WODICT, NONE_M_FLAGS, NoneBuiltins.SLOTS), - PNotImplemented("NotImplementedType", Flags.PRIVATE_DERIVED_WODICT), + PNotImplemented("NotImplementedType", Flags.PRIVATE_DERIVED_WODICT, NotImplementedBuiltins.SLOTS), PProperty(J_PROPERTY, J_BUILTINS, Flags.PUBLIC_BASE_WODICT, PropertyBuiltins.SLOTS), PSimpleQueue(J_SIMPLE_QUEUE, "_queue", Flags.PUBLIC_BASE_WODICT), PRandom("Random", "_random"), PRange("range", J_BUILTINS, Flags.PUBLIC_DERIVED_WODICT, RANGE_M_FLAGS, RangeBuiltins.SLOTS), - PReferenceType("ReferenceType", "_weakref"), + PReferenceType("ReferenceType", "_weakref", ReferenceTypeBuiltins.SLOTS), PSentinelIterator("callable_iterator", Flags.PRIVATE_DERIVED_WODICT, SentinelIteratorBuiltins.SLOTS), PReverseIterator("reversed", J_BUILTINS, ReversedBuiltins.SLOTS), PSet("set", J_BUILTINS, SET_M_FLAGS, TpSlots.merge(BaseSetBuiltins.SLOTS, SetBuiltins.SLOTS)), - PSlice("slice", J_BUILTINS), + PSlice("slice", J_BUILTINS, SliceBuiltins.SLOTS), PString("str", J_BUILTINS, STRING_M_FLAGS, StringBuiltins.SLOTS), PTraceback("traceback"), PTuple("tuple", J_BUILTINS, TUPLE_M_FLAGS, TupleBuiltins.SLOTS), @@ -320,23 +353,23 @@ public enum PythonBuiltinClassType implements TruffleObject { PythonModuleDef("moduledef", Flags.PRIVATE_DERIVED_WODICT), PythonObject("object", J_BUILTINS, ObjectBuiltins.SLOTS), Super("super", J_BUILTINS, SuperBuiltins.SLOTS), - PCode("code", Flags.PRIVATE_DERIVED_WODICT), + PCode("code", Flags.PRIVATE_DERIVED_WODICT, CodeBuiltins.SLOTS), PGenericAlias("GenericAlias", J_TYPES, Flags.PUBLIC_BASE_WODICT, GENERIC_ALIAS_M_FLAGS, GenericAliasBuiltins.SLOTS), PGenericAliasIterator("generic_alias_iterator", Flags.PRIVATE_DERIVED_WODICT, GenericAliasIteratorBuiltins.SLOTS), PUnionType("UnionType", J_TYPES, Flags.PUBLIC_DERIVED_WODICT, UNION_TYPE_M_FLAGS, UnionTypeBuiltins.SLOTS), PZip("zip", J_BUILTINS, PZipBuiltins.SLOTS), PThread("start_new_thread", J__THREAD), PThreadLocal("_local", J__THREAD, ThreadLocalBuiltins.SLOTS), - PLock("LockType", J__THREAD), - PRLock("RLock", J__THREAD), + PLock("LockType", J__THREAD, LockBuiltins.SLOTS), + PRLock("RLock", J__THREAD, LockBuiltins.SLOTS), PSemLock("SemLock", "_multiprocessing"), PGraalPySemLock("SemLock", "_multiprocessing_graalpy"), - PSocket("socket", J__SOCKET), + PSocket("socket", J__SOCKET, SocketBuiltins.SLOTS), PStaticmethod("staticmethod", J_BUILTINS, Flags.PUBLIC_BASE_WDICT, StaticmethodBuiltins.SLOTS), - PClassmethod("classmethod", J_BUILTINS, Flags.PUBLIC_BASE_WDICT, ClassmethodBuiltins.SLOTS), + PClassmethod("classmethod", J_BUILTINS, Flags.PUBLIC_BASE_WDICT, TpSlots.merge(ClassmethodCommonBuiltins.SLOTS, ClassmethodBuiltins.SLOTS)), PInstancemethod("instancemethod", Flags.PUBLIC_BASE_WDICT, InstancemethodBuiltins.SLOTS), PScandirIterator("ScandirIterator", J_POSIX, Flags.PRIVATE_DERIVED_WODICT, ScandirIteratorBuiltins.SLOTS), - PDirEntry("DirEntry", J_POSIX, Flags.PUBLIC_DERIVED_WODICT), + PDirEntry("DirEntry", J_POSIX, Flags.PUBLIC_DERIVED_WODICT, DirEntryBuiltins.SLOTS), LsprofProfiler("Profiler", "_lsprof"), PStruct("Struct", J__STRUCT), PStructUnpackIterator("unpack_iterator", J__STRUCT, StructUnpackIteratorBuiltins.SLOTS), @@ -372,11 +405,11 @@ public enum PythonBuiltinClassType implements TruffleObject { PRawIOBase("_RawIOBase", "_io", IOBaseBuiltins.SLOTS), PTextIOBase("_TextIOBase", "_io", IOBaseBuiltins.SLOTS), PBufferedIOBase("_BufferedIOBase", "_io", IOBaseBuiltins.SLOTS), - PBufferedReader("BufferedReader", "_io", Flags.PUBLIC_BASE_WDICT, BufferedReaderMixinBuiltins.SLOTS), - PBufferedWriter("BufferedWriter", "_io", Flags.PUBLIC_BASE_WDICT), + PBufferedReader("BufferedReader", "_io", Flags.PUBLIC_BASE_WDICT, TpSlots.merge(BufferedReaderMixinBuiltins.SLOTS, BufferedIOMixinBuiltins.SLOTS)), + PBufferedWriter("BufferedWriter", "_io", Flags.PUBLIC_BASE_WDICT, BufferedIOMixinBuiltins.SLOTS), PBufferedRWPair("BufferedRWPair", "_io", Flags.PUBLIC_BASE_WDICT), - PBufferedRandom("BufferedRandom", "_io", Flags.PUBLIC_BASE_WDICT, BufferedReaderMixinBuiltins.SLOTS), - PFileIO("FileIO", "_io", Flags.PUBLIC_BASE_WDICT), + PBufferedRandom("BufferedRandom", "_io", Flags.PUBLIC_BASE_WDICT, TpSlots.merge(BufferedReaderMixinBuiltins.SLOTS, BufferedIOMixinBuiltins.SLOTS)), + PFileIO("FileIO", "_io", Flags.PUBLIC_BASE_WDICT, FileIOBuiltins.SLOTS), PTextIOWrapper("TextIOWrapper", "_io", Flags.PUBLIC_BASE_WDICT, TextIOWrapperBuiltins.SLOTS), PIncrementalNewlineDecoder("IncrementalNewlineDecoder", "_io", Flags.PUBLIC_BASE_WODICT), PStringIO("StringIO", "_io", Flags.PUBLIC_BASE_WDICT, StringIOBuiltins.SLOTS), @@ -456,16 +489,16 @@ public enum PythonBuiltinClassType implements TruffleObject { Sha3Shake256Type("shake_256", "_sha3", Flags.PUBLIC_BASE_WODICT), Blake2bType("blake2b", "_blake2", Flags.PUBLIC_BASE_WODICT), Blake2sType("blake2s", "_blake2", Flags.PUBLIC_BASE_WODICT), - HashlibHash("HASH", "_hashlib", Flags.PUBLIC_BASE_WODICT), + HashlibHash("HASH", "_hashlib", Flags.PUBLIC_BASE_WODICT, HashObjectBuiltins.SLOTS), HashlibHashXof("HASHXOF", "_hashlib", Flags.PUBLIC_DERIVED_WODICT), - HashlibHmac("HMAC", "_hashlib", Flags.PUBLIC_BASE_WODICT), + HashlibHmac("HMAC", "_hashlib", Flags.PUBLIC_BASE_WODICT, HashObjectBuiltins.SLOTS), UnsupportedDigestmodError("UnsupportedDigestmodError", "_hashlib", Flags.EXCEPTION), // _ast (rest of the classes are not builtin, they are generated in AstModuleBuiltins) AST("AST", "_ast", "ast", Flags.PUBLIC_BASE_WDICT), // _ctype - CArgObject("CArgObject", Flags.PUBLIC_BASE_WODICT), + CArgObject("CArgObject", Flags.PUBLIC_BASE_WODICT, CArgObjectBuiltins.SLOTS), CThunkObject("CThunkObject", J__CTYPES, Flags.PUBLIC_BASE_WODICT), StgDict("StgDict", Flags.PRIVATE_DERIVED_WODICT, DICT_M_FLAGS, StgDictBuiltins.SLOTS), PyCStructType("PyCStructType", J__CTYPES, Flags.PUBLIC_BASE_WODICT, PYCSTRUCTTYPE_M_FLAGS, TpSlots.merge(CDataTypeSequenceBuiltins.SLOTS, PyCStructTypeBuiltins.SLOTS)), @@ -501,8 +534,8 @@ public enum PythonBuiltinClassType implements TruffleObject { // Errors and exceptions: // everything after BaseException is considered to be an exception - PBaseException("BaseException", J_BUILTINS, Flags.EXCEPTION), - PBaseExceptionGroup("BaseExceptionGroup", J_BUILTINS, Flags.EXCEPTION), + PBaseException("BaseException", J_BUILTINS, Flags.EXCEPTION, BaseExceptionBuiltins.SLOTS), + PBaseExceptionGroup("BaseExceptionGroup", J_BUILTINS, Flags.EXCEPTION, BaseExceptionGroupBuiltins.SLOTS), SystemExit("SystemExit", J_BUILTINS, Flags.EXCEPTION), KeyboardInterrupt("KeyboardInterrupt", J_BUILTINS, Flags.EXCEPTION), GeneratorExit("GeneratorExit", J_BUILTINS, Flags.EXCEPTION), @@ -517,15 +550,15 @@ public enum PythonBuiltinClassType implements TruffleObject { AttributeError("AttributeError", J_BUILTINS, Flags.EXCEPTION), BufferError("BufferError", J_BUILTINS, Flags.EXCEPTION), EOFError("EOFError", J_BUILTINS, Flags.EXCEPTION), - ImportError("ImportError", J_BUILTINS, Flags.EXCEPTION), + ImportError("ImportError", J_BUILTINS, Flags.EXCEPTION, ImportErrorBuiltins.SLOTS), ModuleNotFoundError("ModuleNotFoundError", J_BUILTINS, Flags.EXCEPTION), LookupError("LookupError", J_BUILTINS, Flags.EXCEPTION), IndexError("IndexError", J_BUILTINS, Flags.EXCEPTION), - KeyError("KeyError", J_BUILTINS, Flags.EXCEPTION), + KeyError("KeyError", J_BUILTINS, Flags.EXCEPTION, KeyErrorBuiltins.SLOTS), MemoryError("MemoryError", J_BUILTINS, Flags.EXCEPTION), NameError("NameError", J_BUILTINS, Flags.EXCEPTION), UnboundLocalError("UnboundLocalError", J_BUILTINS, Flags.EXCEPTION), - OSError("OSError", J_BUILTINS, Flags.EXCEPTION), + OSError("OSError", J_BUILTINS, Flags.EXCEPTION, OsErrorBuiltins.SLOTS), BlockingIOError("BlockingIOError", J_BUILTINS, Flags.EXCEPTION), ChildProcessError("ChildProcessError", J_BUILTINS, Flags.EXCEPTION), ConnectionError("ConnectionError", J_BUILTINS, Flags.EXCEPTION), @@ -552,7 +585,7 @@ public enum PythonBuiltinClassType implements TruffleObject { SocketHError("herror", J__SOCKET, Flags.EXCEPTION), BinasciiError("Error", "binascii", Flags.EXCEPTION), BinasciiIncomplete("Incomplete", "binascii", Flags.EXCEPTION), - SSLError("SSLError", J__SSL, Flags.EXCEPTION), + SSLError("SSLError", J__SSL, Flags.EXCEPTION, SSLErrorBuiltins.SLOTS), SSLZeroReturnError("SSLZeroReturnError", J__SSL, Flags.EXCEPTION), SSLWantReadError("SSLWantReadError", J__SSL, Flags.EXCEPTION), SSLWantWriteError("SSLWantWriteError", J__SSL, Flags.EXCEPTION), @@ -565,16 +598,16 @@ public enum PythonBuiltinClassType implements TruffleObject { ReferenceError("ReferenceError", J_BUILTINS, Flags.EXCEPTION), RuntimeError("RuntimeError", J_BUILTINS, Flags.EXCEPTION), NotImplementedError("NotImplementedError", J_BUILTINS, Flags.EXCEPTION), - SyntaxError("SyntaxError", J_BUILTINS, Flags.EXCEPTION), - IndentationError("IndentationError", J_BUILTINS, Flags.EXCEPTION), - TabError("TabError", J_BUILTINS, Flags.EXCEPTION), + SyntaxError("SyntaxError", J_BUILTINS, Flags.EXCEPTION, SyntaxErrorBuiltins.SLOTS), + IndentationError("IndentationError", J_BUILTINS, Flags.EXCEPTION, SyntaxErrorBuiltins.SLOTS), + TabError("TabError", J_BUILTINS, Flags.EXCEPTION, SyntaxErrorBuiltins.SLOTS), SystemError("SystemError", J_BUILTINS, Flags.EXCEPTION), TypeError("TypeError", J_BUILTINS, Flags.EXCEPTION), ValueError("ValueError", J_BUILTINS, Flags.EXCEPTION), UnicodeError("UnicodeError", J_BUILTINS, Flags.EXCEPTION), - UnicodeDecodeError("UnicodeDecodeError", J_BUILTINS, Flags.EXCEPTION), - UnicodeEncodeError("UnicodeEncodeError", J_BUILTINS, Flags.EXCEPTION), - UnicodeTranslateError("UnicodeTranslateError", J_BUILTINS, Flags.EXCEPTION), + UnicodeDecodeError("UnicodeDecodeError", J_BUILTINS, Flags.EXCEPTION, UnicodeDecodeErrorBuiltins.SLOTS), + UnicodeEncodeError("UnicodeEncodeError", J_BUILTINS, Flags.EXCEPTION, UnicodeEncodeErrorBuiltins.SLOTS), + UnicodeTranslateError("UnicodeTranslateError", J_BUILTINS, Flags.EXCEPTION, UnicodeTranslateErrorBuiltins.SLOTS), RecursionError("RecursionError", J_BUILTINS, Flags.EXCEPTION), IOUnsupportedOperation("UnsupportedOperation", "io", Flags.EXCEPTION), @@ -857,15 +890,8 @@ public final Shape getInstanceShape(PythonLanguage lang) { static { // fill the overridden slots - SpecialMethodSlot[] repr = new SpecialMethodSlot[]{SpecialMethodSlot.Repr}; - SpecialMethodSlot[] reprAndNew = new SpecialMethodSlot[]{SpecialMethodSlot.Repr, SpecialMethodSlot.New}; - - PythonModule.redefinedSlots = Super.redefinedSlots = repr; - SyntaxError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str}; - UnicodeEncodeError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str}; - UnicodeDecodeError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str}; - UnicodeTranslateError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str}; - OSError.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.Str}; + SpecialMethodSlot[] newSlot = new SpecialMethodSlot[]{SpecialMethodSlot.New}; + PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.LengthHint}; // These slots actually contain context independent values, but they are initialized in @@ -874,23 +900,18 @@ public final Shape getInstanceShape(PythonLanguage lang) { // to guarantee their identity across contexts. For the sake of simplicity, we just ignore // those slots for now. PStruct.type = PythonClass; - PStructRusage.redefinedSlots = reprAndNew; - PStructPasswd.redefinedSlots = reprAndNew; - PUnameResult.redefinedSlots = reprAndNew; - PUnraisableHookArgs.redefinedSlots = reprAndNew; - PIntInfo.redefinedSlots = reprAndNew; - PHashInfo.redefinedSlots = reprAndNew; - PStructTime.redefinedSlots = reprAndNew; - PProfilerEntry.redefinedSlots = reprAndNew; - PProfilerSubentry.redefinedSlots = reprAndNew; - PThreadInfo.redefinedSlots = reprAndNew; - PStatResult.redefinedSlots = repr; - PStatvfsResult.redefinedSlots = repr; - PFloatInfo.redefinedSlots = reprAndNew; - PVersionInfo.redefinedSlots = repr; - PWindowsVersion.redefinedSlots = repr; - PFlags.redefinedSlots = repr; - PTerminalSize.redefinedSlots = reprAndNew; + PStructRusage.redefinedSlots = newSlot; + PStructPasswd.redefinedSlots = newSlot; + PUnameResult.redefinedSlots = newSlot; + PUnraisableHookArgs.redefinedSlots = newSlot; + PIntInfo.redefinedSlots = newSlot; + PHashInfo.redefinedSlots = newSlot; + PStructTime.redefinedSlots = newSlot; + PProfilerEntry.redefinedSlots = newSlot; + PProfilerSubentry.redefinedSlots = newSlot; + PThreadInfo.redefinedSlots = newSlot; + PFloatInfo.redefinedSlots = newSlot; + PTerminalSize.redefinedSlots = newSlot; PythonObject.type = PythonClass; PythonObject.base = null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java index 5f86503a3b..da63a3ab3e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java @@ -188,6 +188,7 @@ import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectReprAsObjectNode; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.lib.PySequenceCheckNode; @@ -419,7 +420,7 @@ public PByteArray setEmpty(Object cls, @SuppressWarnings("unused") Object arg, This is equivalent to (real + imag*1j) where imag defaults to 0.""") @GenerateNodeFactory public abstract static class ComplexNode extends PythonTernaryBuiltinNode { - @Child private LookupAndCallUnaryNode callReprNode; + @Child private PyObjectReprAsObjectNode reprNode; @Child private LookupAndCallUnaryNode callComplexNode; @Child private WarnNode warnNode; @@ -778,11 +779,11 @@ static Object complexGeneric(Object cls, Object realObj, Object imaginaryObj, private Object convertStringToComplex(VirtualFrame frame, Node inliningTarget, String src, Object cls, Object origObj, PRaiseNode raiseNode) { String str = FloatUtils.removeUnicodeAndUnderscores(src); if (str == null) { - if (callReprNode == null) { + if (reprNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - callReprNode = insert(LookupAndCallUnaryNode.create(SpecialMethodSlot.Repr)); + reprNode = insert(PyObjectReprAsObjectNode.create()); } - Object strStr = callReprNode.executeObject(frame, origObj); + Object strStr = reprNode.executeCached(frame, origObj); if (PGuards.isString(strStr)) { throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.COULD_NOT_CONVERT_STRING_TO_COMPLEX, strStr); } else { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java index 81c957989e..eda10c8429 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java @@ -67,6 +67,7 @@ import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.StructSequence; +import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonClass; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.BuiltinNames; @@ -77,6 +78,7 @@ import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; +import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; import com.oracle.truffle.api.CompilerDirectives; @@ -97,7 +99,7 @@ abstract static class PyTruffleStructSequence_InitType2 extends CApiTernaryBuilt @Specialization @TruffleBoundary - static int doGeneric(Object klass, Object fields, int nInSequence, + static int doGeneric(PythonAbstractClass klass, Object fields, int nInSequence, @CachedLibrary(limit = "3") InteropLibrary lib, @Cached CStructAccess.ReadPointerNode readNode, @Cached FromCharPointerNode fromCharPtr) { @@ -123,7 +125,7 @@ static int doGeneric(Object klass, Object fields, int nInSequence, TruffleString[] fieldDocs = docs.toArray(TruffleString[]::new); StructSequence.Descriptor d = new StructSequence.Descriptor(null, nInSequence, fieldNames, fieldDocs); - StructSequence.initType(PythonLanguage.get(readNode), klass, d); + StructSequence.initType(PythonContext.get(readNode), klass, d); return 0; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java index 4207cd1891..d3df325b45 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java @@ -40,12 +40,13 @@ */ package com.oracle.graal.python.builtins.modules.ctypes; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -54,6 +55,7 @@ import com.oracle.graal.python.builtins.modules.ctypes.memory.Pointer; import com.oracle.graal.python.builtins.modules.ctypes.memory.PointerNodes; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.object.PFactory; @@ -73,6 +75,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.CArgObject) public final class CArgObjectBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = CArgObjectBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return CArgObjectBuiltinsFactory.getFactories(); @@ -97,7 +101,7 @@ static boolean isLiteralChar(char c) { return c < 128 && isPrintable(c) && c != '\\' && c != '\''; } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java index cc37e4ce67..0a8ccb7867 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CFieldBuiltins.java @@ -45,7 +45,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.CANT_DELETE_ATTRIBUTE; import static com.oracle.graal.python.nodes.ErrorMessages.HAS_NO_STGINFO; import static com.oracle.graal.python.nodes.ErrorMessages.NOT_A_CTYPE_INSTANCE; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; @@ -193,7 +192,7 @@ static Object doit(CFieldObject self, Object inst, @SuppressWarnings("unused") O } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java index 252f1d06f7..63d0a34a42 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/PyCFuncPtrBuiltins.java @@ -75,7 +75,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.THIS_FUNCTION_TAKES_D_ARGUMENT_S_D_GIVEN; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; import static com.oracle.graal.python.runtime.exception.PythonErrorType.AttributeError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; @@ -474,7 +473,7 @@ static Object error(@SuppressWarnings("unused") Object self, @SuppressWarnings(" } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java index 6a212a881f..0924a94047 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/SimpleCDataBuiltins.java @@ -46,7 +46,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.CANT_DELETE_ATTRIBUTE; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -229,7 +228,7 @@ static boolean Simple_bool(CDataObject self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java index 612145e5f5..56fd1ee437 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/functools/PartialBuiltins.java @@ -49,7 +49,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; import static com.oracle.graal.python.nodes.StringLiterals.T_ELLIPSIS; @@ -61,6 +60,8 @@ import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -81,6 +82,7 @@ import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.object.ObjectNodes; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyCallableCheckNode; import com.oracle.graal.python.lib.PyDictCheckExactNode; @@ -142,6 +144,8 @@ public static Object[] getNewPartialArgs(PPartial partial, Object[] args, Node i return newArgs; } + public static final TpSlots SLOTS = PartialBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return PartialBuiltinsFactory.getFactories(); @@ -478,7 +482,7 @@ static Object callWDictWKw(VirtualFrame frame, PPartial self, Object[] args, PKe } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class PartialReprNode extends PythonUnaryBuiltinNode { private static void reprArgs(VirtualFrame frame, Node inliningTarget, PPartial partial, TruffleStringBuilder sb, PyObjectReprAsTruffleStringNode reprNode, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashObjectBuiltins.java index f957622dfb..379ab1561c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/hashlib/HashObjectBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,14 +42,15 @@ import java.util.List; -import com.oracle.graal.python.builtins.Builtin; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.object.ObjectNodes.GetFullyQualifiedClassNameNode; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.truffle.api.dsl.Bind; @@ -63,12 +64,15 @@ @CoreFunctions(extendClasses = {PythonBuiltinClassType.HashlibHash, PythonBuiltinClassType.HashlibHmac}) public final class HashObjectBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = HashObjectBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return HashObjectBuiltinsFactory.getFactories(); } - @Builtin(name = SpecialMethodNames.J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java index f94807b80d..7d9617a42d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java @@ -76,13 +76,14 @@ import static com.oracle.graal.python.nodes.ErrorMessages.IO_UNINIT; import static com.oracle.graal.python.nodes.ErrorMessages.REENTRANT_CALL_INSIDE_S_REPR; import static com.oracle.graal.python.nodes.ErrorMessages.UNSUPPORTED_WHENCE; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.IOUnsupportedOperation; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import java.util.List; import com.oracle.graal.python.annotations.ArgumentClinic; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode; @@ -91,6 +92,7 @@ import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.RawTellNode; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyErrChainExceptions; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; @@ -121,6 +123,9 @@ @CoreFunctions(extendClasses = {PBufferedReader, PBufferedWriter, PBufferedRandom}) public final class BufferedIOMixinBuiltins extends AbstractBufferedIOBuiltins { + + public static final TpSlots SLOTS = BufferedIOMixinBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return BufferedIOMixinBuiltinsFactory.getFactories(); @@ -397,7 +402,7 @@ static Object doit(VirtualFrame frame, PBuffered self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java index 2fee23d480..1c064258e7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java @@ -87,7 +87,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.UNBOUNDED_READ_RETURNED_MORE_BYTES; import static com.oracle.graal.python.nodes.ErrorMessages.UNCLOSED_FILE; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_FALSE; import static com.oracle.graal.python.nodes.StringLiterals.T_TRUE; import static com.oracle.graal.python.runtime.PosixConstants.AT_FDCWD; @@ -108,6 +107,8 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -124,18 +125,19 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyErrChainExceptions; import com.oracle.graal.python.lib.PyIndexCheckNode; 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.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.lib.PyObjectSetAttr; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -144,7 +146,6 @@ import com.oracle.graal.python.nodes.function.builtins.PythonTernaryClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.AsyncHandler; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.IndirectCallData; @@ -183,6 +184,8 @@ public final class FileIOBuiltins extends PythonBuiltins { private static final int SMALLCHUNK = BUFSIZ; + public static final TpSlots SLOTS = FileIOBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return FileIOBuiltinsFactory.getFactories(); @@ -1123,7 +1126,7 @@ static Object doit(VirtualFrame frame, PFileIO self, Object v, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @@ -1138,8 +1141,7 @@ static TruffleString doit(@SuppressWarnings("unused") PFileIO self) { static TruffleString doit(VirtualFrame frame, PFileIO self, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookupName, - @Cached("create(Repr)") LookupAndCallUnaryNode repr, - @Cached CastToTruffleStringNode castToTruffleStringNode, + @Cached PyObjectReprAsTruffleStringNode repr, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, @Cached PRaiseNode raiseNode) { TruffleString mode = ModeNode.modeString(self); @@ -1152,7 +1154,7 @@ static TruffleString doit(VirtualFrame frame, PFileIO self, throw raiseNode.raise(inliningTarget, RuntimeError, REENTRANT_CALL_INSIDE_P_REPR, self); } try { - TruffleString name = castToTruffleStringNode.execute(inliningTarget, repr.executeObject(frame, nameobj)); + TruffleString name = repr.execute(frame, inliningTarget, nameobj); return simpleTruffleStringFormatNode.format("<_io.FileIO name=%s mode='%s' closefd=%s>", name, mode, closefd); } finally { PythonContext.get(inliningTarget).reprLeave(self); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java index 91bf0d9b3a..06eb48bd14 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/TextIOWrapperBuiltins.java @@ -118,7 +118,6 @@ import static com.oracle.graal.python.nodes.PGuards.isNoValue; import static com.oracle.graal.python.nodes.PGuards.isPNone; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.nodes.StringLiterals.T_NEWLINE; import static com.oracle.graal.python.runtime.exception.PythonErrorType.OSError; @@ -155,10 +154,10 @@ import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; @@ -1222,7 +1221,7 @@ static Object doit(VirtualFrame frame, PTextIO self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends InitCheckPythonUnaryBuiltinNode { @@ -1230,7 +1229,7 @@ abstract static class ReprNode extends InitCheckPythonUnaryBuiltinNode { static Object doit(VirtualFrame frame, PTextIO self, @Bind("this") Node inliningTarget, @Cached PyObjectLookupAttr lookup, - @Cached("create(Repr)") LookupAndCallUnaryNode repr, + @Cached PyObjectReprAsTruffleStringNode repr, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode, @Cached IONodes.ToTruffleStringNode toString, @Cached IsBuiltinObjectProfile isValueError, @@ -1253,11 +1252,11 @@ static Object doit(VirtualFrame frame, PTextIO self, } return simpleTruffleStringFormatNode.format("<_io.TextIOWrapper mode='%s' encoding='%s'>", toString.execute(inliningTarget, modeobj), self.getEncoding()); } - Object name = repr.executeObject(frame, nameobj); + Object name = repr.execute(frame, inliningTarget, nameobj); if (modeobj == PNone.NO_VALUE) { - return simpleTruffleStringFormatNode.format("<_io.TextIOWrapper name=%s encoding='%s'>", toString.execute(inliningTarget, name), self.getEncoding()); + return simpleTruffleStringFormatNode.format("<_io.TextIOWrapper name=%s encoding='%s'>", name, self.getEncoding()); } - return simpleTruffleStringFormatNode.format("<_io.TextIOWrapper name=%s mode='%s' encoding='%s'>", toString.execute(inliningTarget, name), toString.execute(inliningTarget, modeobj), + return simpleTruffleStringFormatNode.format("<_io.TextIOWrapper name=%s mode='%s' encoding='%s'>", name, toString.execute(inliningTarget, modeobj), self.getEncoding()); } finally { PythonContext.get(inliningTarget).reprLeave(self); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NoneBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NoneBuiltins.java index 1994e9014c..b7821582dd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NoneBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NoneBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -40,14 +40,12 @@ */ package com.oracle.graal.python.builtins.objects; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_NONE; import java.util.List; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -82,7 +80,7 @@ static boolean doNone(Object none) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NotImplementedBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NotImplementedBuiltins.java index 1386bc75c0..ef7a38515f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NotImplementedBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NotImplementedBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,16 +42,19 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T_NOT_IMPLEMENTED; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -61,14 +64,16 @@ @SuppressWarnings("unused") public final class NotImplementedBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = NotImplementedBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return NotImplementedBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class ReprNode extends PythonBuiltinNode { + abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static TruffleString doit(PNotImplemented self) { @@ -78,7 +83,7 @@ static TruffleString doit(PNotImplemented self) { @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) @GenerateNodeFactory - public abstract static class ReduceNode extends PythonBuiltinNode { + public abstract static class ReduceNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") TruffleString doit(PNotImplemented self, Object ignored) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java index 7ef22d4b6d..23d646fb44 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java @@ -47,7 +47,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE_EX__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; import static com.oracle.graal.python.nodes.StringLiterals.T_LBRACKET; import static com.oracle.graal.python.nodes.StringLiterals.T_LPAREN; @@ -100,13 +99,13 @@ import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.builtins.ListNodes; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; @@ -502,13 +501,13 @@ static boolean contains(VirtualFrame frame, PArray self, Object value, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization static TruffleString repr(VirtualFrame frame, PArray self, @Bind("this") Node inliningTarget, - @Cached("create(Repr)") LookupAndCallUnaryNode reprNode, + @Cached PyObjectReprAsTruffleStringNode repr, @Cached InlinedConditionProfile isEmptyProfile, @Cached InlinedConditionProfile isUnicodeProfile, @Cached CastToTruffleStringNode cast, @@ -526,7 +525,7 @@ static TruffleString repr(VirtualFrame frame, PArray self, if (isEmptyProfile.profile(inliningTarget, length != 0)) { if (isUnicodeProfile.profile(inliningTarget, self.getFormat() == BufferFormat.UNICODE)) { appendStringNode.execute(sb, T_COMMA_SPACE); - appendStringNode.execute(sb, cast.execute(inliningTarget, reprNode.executeObject(frame, toUnicodeNode.execute(frame, self)))); + appendStringNode.execute(sb, repr.execute(frame, inliningTarget, toUnicodeNode.execute(frame, self))); } else { appendStringNode.execute(sb, T_COMMA_SPACE); appendStringNode.execute(sb, T_LBRACKET); @@ -535,7 +534,7 @@ static TruffleString repr(VirtualFrame frame, PArray self, appendStringNode.execute(sb, T_COMMA_SPACE); } Object value = getValueNode.execute(inliningTarget, self, i); - appendStringNode.execute(sb, cast.execute(inliningTarget, reprNode.executeObject(frame, value))); + appendStringNode.execute(sb, cast.execute(inliningTarget, repr.execute(frame, inliningTarget, value))); } appendStringNode.execute(sb, T_RBRACKET); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java index 39d1418252..427cb30991 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bool/BoolBuiltins.java @@ -25,8 +25,6 @@ */ package com.oracle.graal.python.builtins.objects.bool; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_FALSE; import static com.oracle.graal.python.nodes.StringLiterals.T_TRUE; @@ -34,7 +32,6 @@ import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -43,7 +40,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.truffle.PythonIntegerTypes; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -64,10 +61,10 @@ protected List> getNodeFa return BoolBuiltinsFactory.getFactories(); } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @TypeSystemReference(PythonIntegerTypes.class) @GenerateNodeFactory - abstract static class StrNode extends PythonBuiltinNode { + abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization static TruffleString doBoolean(boolean self) { return self ? T_TRUE : T_FALSE; @@ -84,7 +81,7 @@ public static TruffleString doPInt(PInt self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class RepNode extends StrNode { } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java index bd719d0915..e6a9cb37f8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java @@ -38,7 +38,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.MemoryError; @@ -402,7 +401,7 @@ protected ArgumentClinicProvider getArgumentClinic() { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java index 1d2117c3d0..dcc120208d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java @@ -35,7 +35,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import java.util.List; @@ -153,7 +152,7 @@ private static PException raiseNonIntIndex(Node inliningTarget, PRaiseNode raise } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java index 420c927db9..a25affc05e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/CellBuiltins.java @@ -46,7 +46,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GT__; @@ -58,6 +57,8 @@ import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -66,6 +67,7 @@ import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.nodes.ErrorMessages; @@ -73,6 +75,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -90,6 +93,9 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PCell) public final class CellBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = CellBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return CellBuiltinsFactory.getFactories(); @@ -275,9 +281,9 @@ static Object notImplemented(Object self, Object other, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class ReprNode extends PythonBuiltinNode { + abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization static TruffleString repr(PCell self, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java index 6637816761..ff2d9db21d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java @@ -30,7 +30,6 @@ import static com.oracle.graal.python.annotations.ArgumentClinic.VALUE_NONE; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_NONE; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.objectArrayToTruffleStringArray; @@ -41,6 +40,8 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -51,6 +52,7 @@ import com.oracle.graal.python.builtins.objects.str.StringNodes.InternStringNode; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.compiler.SourceMap; @@ -81,6 +83,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PCode) public final class CodeBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = CodeBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return CodeBuiltinsFactory.getFactories(); @@ -345,7 +349,7 @@ Object positions(PCode self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class CodeReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/FormatNodeBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/FormatNodeBase.java index c29dde81fc..23a122ad6d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/FormatNodeBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/FormatNodeBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -40,27 +40,23 @@ */ package com.oracle.graal.python.builtins.objects.common; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; +import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; +@GenerateCached(false) public abstract class FormatNodeBase extends PythonBinaryClinicBuiltinNode { - @Override - protected ArgumentClinicProvider getArgumentClinic() { - // must be implemented here, because DSL creates a generated node for this class - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw new AbstractMethodError(); - } - // applies to all types: empty format string => use __str__ @Specialization(guards = "formatString.isEmpty()") public static Object formatEmptyString(VirtualFrame frame, Object self, @SuppressWarnings("unused") TruffleString formatString, - @Cached("create(Str)") LookupAndCallUnaryNode lookupAndCallNode) { - return lookupAndCallNode.executeObject(frame, self); + @Bind Node inliningTarget, + @Cached PyObjectStrAsObjectNode str) { + return str.execute(frame, inliningTarget, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java index 94785edf82..7c7cc8e12e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java @@ -52,7 +52,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ZeroDivisionError; @@ -726,7 +725,7 @@ static PNotImplemented doGeneric(Object left, Object right) { } @GenerateNodeFactory - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java index 7b0ef096e6..e588cbb4cd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/deque/DequeBuiltins.java @@ -60,7 +60,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.StringLiterals.T_ELLIPSIS_IN_BRACKETS; @@ -860,7 +859,7 @@ static PDequeIter doGeneric(PDeque self, } // deque.__repr__() - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class DequeReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java index 6aa6a1a045..caefb2877e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DefaultDictBuiltins.java @@ -45,7 +45,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___MISSING__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -98,7 +97,7 @@ protected List> getNodeFa return DefaultDictBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java index 2dda3e591f..356007269e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictReprBuiltin.java @@ -40,7 +40,6 @@ */ package com.oracle.graal.python.builtins.objects.dict; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_COLON_SPACE; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; @@ -54,7 +53,8 @@ import java.util.List; -import com.oracle.graal.python.builtins.Builtin; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -67,6 +67,7 @@ import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictItemsView; import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictKeysView; import com.oracle.graal.python.builtins.objects.dict.PDictView.PDictValuesView; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -95,12 +96,14 @@ @CoreFunctions(extendClasses = {PythonBuiltinClassType.PDictKeysView, PythonBuiltinClassType.PDictItemsView, PythonBuiltinClassType.PDictValuesView, PythonBuiltinClassType.PDict}) public final class DictReprBuiltin extends PythonBuiltins { + public static final TpSlots SLOTS = DictReprBuiltinSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return DictReprBuiltinFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { private static final TruffleString T_LPAREN_BRACKET = tsLiteral("(["); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ellipsis/EllipsisBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ellipsis/EllipsisBuiltins.java index 334b32744c..89a894e613 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ellipsis/EllipsisBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ellipsis/EllipsisBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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,18 +41,21 @@ package com.oracle.graal.python.builtins.objects.ellipsis; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; 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.objects.type.TpSlots; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NodeFactory; import com.oracle.truffle.api.dsl.Specialization; @@ -64,6 +67,8 @@ public final class EllipsisBuiltins extends PythonBuiltins { private static final TruffleString T_ELLIPSIS = tsLiteral("Ellipsis"); + public static final TpSlots SLOTS = EllipsisBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return EllipsisBuiltinsFactory.getFactories(); @@ -75,9 +80,9 @@ public void postInitialize(Python3Core core) { core.getBuiltins().setAttribute(T_ELLIPSIS, PEllipsis.INSTANCE); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class ReprNode extends PythonBuiltinNode { + abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization @SuppressWarnings("unused") static Object doit(PEllipsis self) { @@ -87,7 +92,7 @@ static Object doit(PEllipsis self) { @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 2) @GenerateNodeFactory - public abstract static class ReduceNode extends PythonBuiltinNode { + public abstract static class ReduceNode extends PythonBinaryBuiltinNode { @Specialization @SuppressWarnings("unused") Object doit(PEllipsis self, Object ignored) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java index cd0b6eea75..4da865d949 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java @@ -37,9 +37,7 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SETSTATE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_PARENS; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.nodes.StringLiterals.T_LPAREN; @@ -49,6 +47,8 @@ import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -68,6 +68,7 @@ import com.oracle.graal.python.builtins.objects.list.PList; import com.oracle.graal.python.builtins.objects.traceback.PTraceback; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode; import com.oracle.graal.python.lib.PyObjectGetAttr; import com.oracle.graal.python.lib.PyObjectLookupAttr; @@ -117,6 +118,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PBaseException) public final class BaseExceptionBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = BaseExceptionBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return BaseExceptionBuiltinsFactory.getFactories(); @@ -410,7 +413,7 @@ static Object reduce(VirtualFrame frame, Object self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory public abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization @@ -448,7 +451,7 @@ Object repr(VirtualFrame frame, Object self, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java index ecd281fc2f..78e25ccc7a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionGroupBuiltins.java @@ -46,7 +46,6 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T___NOTES__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___MODULE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -55,6 +54,8 @@ import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -69,6 +70,7 @@ import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.traceback.PTraceback; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyErrExceptionMatchesNode; import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; @@ -103,6 +105,9 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PBaseExceptionGroup) public class BaseExceptionGroupBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = BaseExceptionGroupBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return BaseExceptionGroupBuiltinsFactory.getFactories(); @@ -125,7 +130,7 @@ private static void createExceptionGroupType(Python3Core core) { builtins.setAttribute(T_EXCEPTION_GROUP, exceptionGroupType); } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java index bb42438e2a..7e3eca1cb0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java @@ -43,7 +43,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.S_IS_AN_INVALID_ARG_FOR_S; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_NAME; import static com.oracle.graal.python.nodes.StringLiterals.T_PATH; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -52,6 +51,8 @@ import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -63,6 +64,7 @@ import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyUnicodeCheckExactNode; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -86,6 +88,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.ImportError) public final class ImportErrorBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = ImportErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return ImportErrorBuiltinsFactory.getFactories(); @@ -230,7 +234,7 @@ static Object reduce(PBaseException self, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class ImportErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/KeyErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/KeyErrorBuiltins.java index 7ac6e20448..0075902b70 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/KeyErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/KeyErrorBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -40,16 +40,16 @@ */ package com.oracle.graal.python.builtins.objects.exception; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; - import java.util.List; -import com.oracle.graal.python.builtins.Builtin; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; @@ -65,12 +65,14 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.KeyError) public final class KeyErrorBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = KeyErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return KeyErrorBuiltinsFactory.getFactories(); } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class KeyErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java index fcef70114f..1f3e6f0ac3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java @@ -55,7 +55,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -63,6 +62,8 @@ import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.Python3Core; @@ -77,6 +78,7 @@ import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyArgCheckPositionalNode; import com.oracle.graal.python.lib.PyNumberAsSizeNode; @@ -125,6 +127,8 @@ public final class OsErrorBuiltins extends PythonBuiltins { return attrs; }; + public static final TpSlots SLOTS = OsErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return OsErrorBuiltinsFactory.getFactories(); @@ -427,7 +431,7 @@ static Object generic(PBaseException self, Object value, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class OSErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java index 509dc4c3ab..0105fe4287 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/SyntaxErrorBuiltins.java @@ -44,11 +44,12 @@ import static com.oracle.graal.python.nodes.ErrorMessages.MISSING_PARENTHESES_IN_CALL_TO_PRINT; import static com.oracle.graal.python.nodes.ErrorMessages.TUPLE_OUT_OF_BOUNDS; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -57,6 +58,7 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode; import com.oracle.graal.python.lib.PyLongCheckExactNode; import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; @@ -96,6 +98,8 @@ public final class SyntaxErrorBuiltins extends PythonBuiltins { public static final BaseExceptionAttrNode.StorageFactory SYNTAX_ERROR_ATTR_FACTORY = (args) -> new Object[SYNTAX_ERR_NUM_ATTRS]; + public static final TpSlots SLOTS = SyntaxErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return SyntaxErrorBuiltinsFactory.getFactories(); @@ -300,7 +304,7 @@ Object generic(PBaseException self, Object value, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class SyntaxErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java index 181595c89e..f9373dacc5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeDecodeErrorBuiltins.java @@ -50,13 +50,14 @@ import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsInt; import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsString; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.runtime.exception.PythonErrorType.UnicodeDecodeError; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -66,6 +67,7 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToTruffleStringCheckedNode; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectSizeNode; import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; import com.oracle.graal.python.nodes.ErrorMessages; @@ -93,6 +95,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.UnicodeDecodeError) public final class UnicodeDecodeErrorBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = UnicodeDecodeErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return UnicodeDecodeErrorBuiltinsFactory.getFactories(); @@ -124,7 +128,7 @@ static Object initNoArgs(VirtualFrame frame, PBaseException self, Object[] args, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class UnicodeEncodeErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java index 6ee7334eb3..90564a8299 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeEncodeErrorBuiltins.java @@ -50,19 +50,21 @@ import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsInt; import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsString; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.str.StringNodes.CastToTruffleStringCheckedNode; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -86,6 +88,9 @@ @CoreFunctions(extendClasses = UnicodeEncodeError) public final class UnicodeEncodeErrorBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = UnicodeEncodeErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return UnicodeEncodeErrorBuiltinsFactory.getFactories(); @@ -116,7 +121,7 @@ static Object initNoArgs(PBaseException self, Object[] args, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class UnicodeEncodeErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java index 9e0eb7cafe..7ad77db024 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/UnicodeTranslateErrorBuiltins.java @@ -48,18 +48,20 @@ import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsInt; import static com.oracle.graal.python.builtins.objects.exception.UnicodeErrorBuiltins.getArgAsString; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -80,6 +82,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.UnicodeTranslateError) public final class UnicodeTranslateErrorBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = UnicodeTranslateErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return UnicodeTranslateErrorBuiltinsFactory.getFactories(); @@ -112,7 +116,7 @@ static Object initNoArgs(PBaseException self, Object[] args, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class UnicodeTranslateErrorStrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java index 17854e35d6..42d456ca13 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java @@ -40,9 +40,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; import static com.oracle.graal.python.runtime.formatting.FormattingUtils.validateForFloat; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -203,7 +201,7 @@ void raiseDivisionByZero(boolean cond) { } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory public abstract static class StrNode extends AbstractNumericUnaryBuiltin { public static final Spec spec = new Spec(' ', '>', Spec.NONE, false, Spec.UNSPECIFIED, Spec.NONE, 0, 'r'); @@ -221,7 +219,7 @@ public static TruffleString doFormat(double d, FloatFormatter f) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends StrNode { } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignBooleanBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignBooleanBuiltins.java index dd2ec3943d..a3f22962e9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignBooleanBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignBooleanBuiltins.java @@ -26,14 +26,10 @@ package com.oracle.graal.python.builtins.objects.foreign; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; - import java.util.List; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -114,8 +110,8 @@ protected static int doIt(Object object, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java index 9cff1707f4..449b2570fa 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignNumberBuiltins.java @@ -34,9 +34,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___GT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -722,7 +720,7 @@ protected static Object doIt(Object object, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { @Child private TruffleString.SwitchEncodingNode switchEncodingNode; @@ -759,7 +757,7 @@ protected TruffleString defaultConversion(VirtualFrame frame, InteropLibrary lib } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends StrNode { @Child private ObjectNodes.DefaultObjectReprNode defaultReprNode; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java index f245425f3a..c71db8d500 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java @@ -31,8 +31,6 @@ import static com.oracle.graal.python.builtins.objects.str.StringUtils.simpleTruffleStringFormatUncached; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___DIR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import java.util.List; @@ -53,15 +51,15 @@ import com.oracle.graal.python.builtins.objects.set.PSet; import com.oracle.graal.python.builtins.objects.set.SetNodes; import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode; import com.oracle.graal.python.builtins.objects.type.TypeBuiltins; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; +import com.oracle.graal.python.lib.PyObjectReprAsObjectNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; import com.oracle.graal.python.nodes.builtins.ListNodes; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; @@ -325,7 +323,7 @@ protected Object doIt(VirtualFrame frame, Object object, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { @Child private TruffleString.SwitchEncodingNode switchEncodingNode; @@ -333,20 +331,17 @@ abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization Object str(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached(parameters = "T___REPR__") LookupAttributeInMRONode lookupAttributeInMRONode, - @Cached(parameters = "Repr") LookupAndCallUnaryNode reprNode, + @Cached GetObjectSlotsNode getSlots, + @Cached PyObjectReprAsObjectNode reprNode, @CachedLibrary(limit = "3") InteropLibrary lib, @Cached ObjectNodes.DefaultObjectReprNode defaultReprNode, @Cached InlinedBranchProfile isIterator, @Cached InlinedBranchProfile defaultCase) { // Check if __repr__ is defined before foreign, if so call that, like object.__str__ // would do - var klass = getClassNode.execute(inliningTarget, object); - var repr = lookupAttributeInMRONode.execute(klass); - var foreignObjectBuiltinsRepr = lookupAttributeInMRONode.execute(PythonBuiltinClassType.ForeignObject); - if (repr != foreignObjectBuiltinsRepr) { - return reprNode.executeObject(frame, object); + TpSlots slots = getSlots.execute(inliningTarget, object); + if (slots.tp_repr() != SLOTS.tp_repr()) { + return reprNode.execute(frame, inliningTarget, object); } if (lib.isIterator(object)) { @@ -375,7 +370,7 @@ protected TruffleString defaultConversion(VirtualFrame frame, InteropLibrary lib } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends StrNode { @Child private ObjectNodes.DefaultObjectReprNode defaultReprNode; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java index 978c84e856..e91e50c63c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java @@ -26,11 +26,12 @@ package com.oracle.graal.python.builtins.objects.frame; import static com.oracle.graal.python.builtins.objects.PythonAbstractObject.objectHashCodeAsHexString; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -45,6 +46,7 @@ import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins.DictNode; import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode; import com.oracle.graal.python.lib.PyLongCheckExactNode; import com.oracle.graal.python.nodes.ErrorMessages; @@ -80,12 +82,14 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PFrame) public final class FrameBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = FrameBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return FrameBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java index bfaf3ba982..1833d1f4b6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/FunctionBuiltins.java @@ -36,7 +36,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___QUALNAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J_TRUFFLE_SOURCE; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -115,7 +114,7 @@ static Object doFunction(PFunction self, @SuppressWarnings("unused") PNone insta } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java index cb85579bf7..99bcab4fbb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/MethodDescriptorBuiltins.java @@ -40,14 +40,11 @@ */ package com.oracle.graal.python.builtins.objects.function; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; - import java.util.List; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -111,7 +108,7 @@ static Object doBuiltinFunction(PBuiltinFunction self, Object instance, Object k } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getEnclosingType() == null") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java index ce2ee82afd..3bea117b6c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/WrapperDescriptorBuiltins.java @@ -40,14 +40,11 @@ */ package com.oracle.graal.python.builtins.objects.function; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; - import java.util.List; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; @@ -105,7 +102,7 @@ static Object doBuiltinFunction(PBuiltinFunction self, Object instance, Object k } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java index 495c3ed66f..44d5a4dc04 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CoroutineBuiltins.java @@ -41,11 +41,12 @@ package com.oracle.graal.python.builtins.objects.generator; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___AWAIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -53,6 +54,7 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.runtime.object.PFactory; @@ -68,6 +70,9 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PCoroutine) public final class CoroutineBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = CoroutineBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return CoroutineBuiltinsFactory.getFactories(); @@ -132,7 +137,7 @@ static Object await(PGenerator self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java index 6e1c350261..3d4fb14044 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java @@ -31,7 +31,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___QUALNAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import java.util.List; @@ -226,7 +225,7 @@ static boolean suspended(PGenerator self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptorTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptorTypeBuiltins.java index 0b693af60b..6b7afbcc72 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptorTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/GetSetDescriptorTypeBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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,6 @@ package com.oracle.graal.python.builtins.objects.getsetdescriptor; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___OBJCLASS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -101,7 +100,7 @@ static Object doIndexedSlotDescriptor(IndexedSlotDescriptor self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class GetSetReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java index 6771172fd3..204e64277c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/getsetdescriptor/MemberDescriptorBuiltins.java @@ -41,7 +41,6 @@ package com.oracle.graal.python.builtins.objects.getsetdescriptor; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -91,7 +90,7 @@ protected List> getNodeFa return MemberDescriptorBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class MemberDescriptorReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java index 9e811dce30..efc93e7912 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java @@ -51,9 +51,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___ROUND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUFFLE_RICHCOMPARE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUNC__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BYTES__; @@ -2803,10 +2801,10 @@ static boolean toBoolean(PythonNativeVoidPtr self, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory @TypeSystemReference(PythonIntegerTypes.class) - abstract static class StrNode extends PythonBuiltinNode { + abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization static TruffleString doL(long self, @@ -2869,7 +2867,7 @@ static TruffleString doNativeVoidPtr(VirtualFrame frame, PythonNativeVoidPtr sel } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends StrNode { } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java index e5cfc9c0ff..60067a701c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/CountBuiltins.java @@ -42,7 +42,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -110,7 +109,7 @@ static Object next(VirtualFrame frame, PCount self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory public abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java index 8f983d59c7..178ed9edfd 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/RepeatBuiltins.java @@ -45,7 +45,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LENGTH_HINT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -155,7 +154,7 @@ static Object reduce(PRepeat self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory public abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getCnt() >= 0") diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java index f6b8808acc..7352dd975c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/list/ListBuiltins.java @@ -36,7 +36,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; @@ -155,7 +154,7 @@ protected List> getNodeFactories() { return BuiltinClassmethodBuiltinsFactory.getFactories(); @@ -139,7 +143,7 @@ static Object textSignature(VirtualFrame frame, PDecoratedMethod self, } } - @Builtin(name = J___REPR__, maxNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java index 25b01edc31..c24bbecd7e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/BuiltinFunctionOrMethodBuiltins.java @@ -42,12 +42,13 @@ import static com.oracle.graal.python.builtins.PythonBuiltinClassType.AttributeError; import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___SIGNATURE__; -import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___SIGNATURE__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___SIGNATURE__; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,6 +60,7 @@ import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -82,12 +84,14 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PBuiltinFunctionOrMethod) public final class BuiltinFunctionOrMethodBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = BuiltinFunctionOrMethodBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return BuiltinFunctionOrMethodBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { static boolean isBuiltinFunction(PBuiltinMethod self) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java index 631db6babe..619ca02477 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/ClassmethodBuiltins.java @@ -40,53 +40,31 @@ */ package com.oracle.graal.python.builtins.objects.method; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; import java.util.List; -import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.Slot; import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.type.TpSlots; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode; import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NodeFactory; -import com.oracle.truffle.api.dsl.ReportPolymorphism; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleStringBuilder; -@CoreFunctions(extendClasses = {PythonBuiltinClassType.PClassmethod, PythonBuiltinClassType.PBuiltinClassMethod}) +@CoreFunctions(extendClasses = PythonBuiltinClassType.PClassmethod) public final class ClassmethodBuiltins extends PythonBuiltins { public static final TpSlots SLOTS = ClassmethodBuiltinsSlotsGen.SLOTS; @@ -96,120 +74,7 @@ protected List> getNodeFa return ClassmethodBuiltinsFactory.getFactories(); } - @Slot(SlotKind.tp_descr_get) - @ReportPolymorphism - @GenerateUncached - @GenerateNodeFactory - abstract static class GetNode extends DescrGetBuiltinNode { - /*- - TODO: (GR-53082) this is not handling following code-path added to CPython at some later point: - if (Py_TYPE(cm->cm_callable)->tp_descr_get != NULL) { - return Py_TYPE(cm->cm_callable)->tp_descr_get(cm->cm_callable, type, type); - } - - Additionally, in CPython tp_descrget is not shared between classmethod_descriptor and classmethod, - we should investigate if we can really share the implementation - */ - - // If self.getCallable() is null, let the next @Specialization handle that - @Specialization(guards = {"isSingleContext()", "isNoValue(type)", "cachedSelf == self", "cachedCallable != null"}, limit = "3") - static Object getCached(@SuppressWarnings("unused") PDecoratedMethod self, Object obj, @SuppressWarnings("unused") Object type, - @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached(value = "self", weak = true) PDecoratedMethod cachedSelf, - @SuppressWarnings("unused") @Cached(value = "self.getCallable()", weak = true) Object cachedCallable, - @Shared @Cached GetClassNode getClass, - @Shared @Cached MakeMethodNode makeMethod) { - return makeMethod.execute(inliningTarget, getClass.execute(inliningTarget, obj), cachedCallable); - } - - @Specialization(guards = "isNoValue(type)", replaces = "getCached") - static Object get(PDecoratedMethod self, Object obj, @SuppressWarnings("unused") Object type, - @Bind("this") Node inliningTarget, - @Shared @Cached GetClassNode getClass, - @Shared @Cached MakeMethodNode makeMethod, - @Shared @Cached PRaiseNode raiseNode) { - return doGet(inliningTarget, self, getClass.execute(inliningTarget, obj), makeMethod, raiseNode); - } - - // If self.getCallable() is null, let the next @Specialization handle that - @Specialization(guards = {"isSingleContext()", "!isNoValue(type)", "cachedSelf == self", "cachedCallable != null"}, limit = "3") - static Object getTypeCached(@SuppressWarnings("unused") PDecoratedMethod self, @SuppressWarnings("unused") Object obj, Object type, - @Bind("this") Node inliningTarget, - @SuppressWarnings("unused") @Cached(value = "self", weak = true) PDecoratedMethod cachedSelf, - @SuppressWarnings("unused") @Cached(value = "self.getCallable()", weak = true) Object cachedCallable, - @Shared @Cached MakeMethodNode makeMethod) { - return makeMethod.execute(inliningTarget, type, cachedCallable); - } - - @Specialization(guards = "!isNoValue(type)", replaces = "getTypeCached") - static Object getType(PDecoratedMethod self, @SuppressWarnings("unused") Object obj, Object type, - @Bind("this") Node inliningTarget, - @Shared @Cached MakeMethodNode makeMethod, - @Shared @Cached PRaiseNode raiseNode) { - return doGet(inliningTarget, self, type, makeMethod, raiseNode); - } - - private static Object doGet(Node inliningTarget, PDecoratedMethod self, Object type, MakeMethodNode makeMethod, PRaiseNode raiseNode) { - Object callable = self.getCallable(); - if (callable == null) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); - } - return makeMethod.execute(inliningTarget, type, callable); - } - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - @ImportStatic(PGuards.class) - @ReportPolymorphism - abstract static class MakeMethodNode extends PNodeWithContext { - abstract Object execute(Node inliningTarget, Object self, Object func); - - @Specialization - Object method(Object self, PFunction func, - @Bind PythonLanguage language) { - return PFactory.createMethod(language, self, func); - } - - @Specialization(guards = "!func.needsDeclaringType()") - Object methodBuiltin(Object self, PBuiltinFunction func, - @Bind PythonLanguage language) { - return PFactory.createBuiltinMethod(language, self, func); - } - - @Specialization(guards = "func.needsDeclaringType()") - Object methodBuiltinWithDeclaringType(Object self, PBuiltinFunction func, - @Bind PythonLanguage language) { - return PFactory.createBuiltinMethod(language, self, func, func.getEnclosingType()); - } - - @Specialization(guards = "!isFunction(func)") - Object generic(Object self, Object func, - @Bind PythonLanguage language) { - return PFactory.createMethod(language, self, func); - } - } - - @Builtin(name = J___CALL__, minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true) - @GenerateNodeFactory - abstract static class CallNode extends PythonVarargsBuiltinNode { - @Child private com.oracle.graal.python.nodes.call.CallNode callNode = com.oracle.graal.python.nodes.call.CallNode.create(); - - @Specialization - protected Object doIt(VirtualFrame frame, PDecoratedMethod self, Object[] arguments, PKeyword[] keywords) { - return callNode.execute(frame, self.getCallable(), arguments, keywords); - } - - @Override - public Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { - Object[] argsWithoutSelf = new Object[arguments.length - 1]; - PythonUtils.arraycopy(arguments, 1, argsWithoutSelf, 0, argsWithoutSelf.length); - return execute(frame, arguments[0], argsWithoutSelf, keywords); - } - } - - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { private static final TruffleString PREFIX = tsLiteral("> getNodeFactories() { + return ClassmethodCommonBuiltinsFactory.getFactories(); + } + + @Slot(SlotKind.tp_descr_get) + @ReportPolymorphism + @GenerateUncached + @GenerateNodeFactory + abstract static class GetNode extends DescrGetBuiltinNode { + /*- + TODO: (GR-53082) this is not handling following code-path added to CPython at some later point: + if (Py_TYPE(cm->cm_callable)->tp_descr_get != NULL) { + return Py_TYPE(cm->cm_callable)->tp_descr_get(cm->cm_callable, type, type); + } + + Additionally, in CPython tp_descrget is not shared between classmethod_descriptor and classmethod, + we should investigate if we can really share the implementation + */ + + // If self.getCallable() is null, let the next @Specialization handle that + @Specialization(guards = {"isSingleContext()", "isNoValue(type)", "cachedSelf == self", "cachedCallable != null"}, limit = "3") + static Object getCached(@SuppressWarnings("unused") PDecoratedMethod self, Object obj, @SuppressWarnings("unused") Object type, + @Bind("this") Node inliningTarget, + @SuppressWarnings("unused") @Cached(value = "self", weak = true) PDecoratedMethod cachedSelf, + @SuppressWarnings("unused") @Cached(value = "self.getCallable()", weak = true) Object cachedCallable, + @Shared @Cached GetClassNode getClass, + @Shared @Cached MakeMethodNode makeMethod) { + return makeMethod.execute(inliningTarget, getClass.execute(inliningTarget, obj), cachedCallable); + } + + @Specialization(guards = "isNoValue(type)", replaces = "getCached") + static Object get(PDecoratedMethod self, Object obj, @SuppressWarnings("unused") Object type, + @Bind("this") Node inliningTarget, + @Shared @Cached GetClassNode getClass, + @Shared @Cached MakeMethodNode makeMethod, + @Shared @Cached PRaiseNode raiseNode) { + return doGet(inliningTarget, self, getClass.execute(inliningTarget, obj), makeMethod, raiseNode); + } + + // If self.getCallable() is null, let the next @Specialization handle that + @Specialization(guards = {"isSingleContext()", "!isNoValue(type)", "cachedSelf == self", "cachedCallable != null"}, limit = "3") + static Object getTypeCached(@SuppressWarnings("unused") PDecoratedMethod self, @SuppressWarnings("unused") Object obj, Object type, + @Bind("this") Node inliningTarget, + @SuppressWarnings("unused") @Cached(value = "self", weak = true) PDecoratedMethod cachedSelf, + @SuppressWarnings("unused") @Cached(value = "self.getCallable()", weak = true) Object cachedCallable, + @Shared @Cached MakeMethodNode makeMethod) { + return makeMethod.execute(inliningTarget, type, cachedCallable); + } + + @Specialization(guards = "!isNoValue(type)", replaces = "getTypeCached") + static Object getType(PDecoratedMethod self, @SuppressWarnings("unused") Object obj, Object type, + @Bind("this") Node inliningTarget, + @Shared @Cached MakeMethodNode makeMethod, + @Shared @Cached PRaiseNode raiseNode) { + return doGet(inliningTarget, self, type, makeMethod, raiseNode); + } + + private static Object doGet(Node inliningTarget, PDecoratedMethod self, Object type, MakeMethodNode makeMethod, PRaiseNode raiseNode) { + Object callable = self.getCallable(); + if (callable == null) { + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.RuntimeError, ErrorMessages.UNINITIALIZED_S_OBJECT); + } + return makeMethod.execute(inliningTarget, type, callable); + } + } + + @GenerateInline + @GenerateCached(false) + @GenerateUncached + @ImportStatic(PGuards.class) + @ReportPolymorphism + abstract static class MakeMethodNode extends PNodeWithContext { + abstract Object execute(Node inliningTarget, Object self, Object func); + + @Specialization + Object method(Object self, PFunction func, + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); + } + + @Specialization(guards = "!func.needsDeclaringType()") + Object methodBuiltin(Object self, PBuiltinFunction func, + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, self, func); + } + + @Specialization(guards = "func.needsDeclaringType()") + Object methodBuiltinWithDeclaringType(Object self, PBuiltinFunction func, + @Bind PythonLanguage language) { + return PFactory.createBuiltinMethod(language, self, func, func.getEnclosingType()); + } + + @Specialization(guards = "!isFunction(func)") + Object generic(Object self, Object func, + @Bind PythonLanguage language) { + return PFactory.createMethod(language, self, func); + } + } + + @Builtin(name = J___CALL__, minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true) + @GenerateNodeFactory + abstract static class CallNode extends PythonVarargsBuiltinNode { + @Child private com.oracle.graal.python.nodes.call.CallNode callNode = com.oracle.graal.python.nodes.call.CallNode.create(); + + @Specialization + protected Object doIt(VirtualFrame frame, PDecoratedMethod self, Object[] arguments, PKeyword[] keywords) { + return callNode.execute(frame, self.getCallable(), arguments, keywords); + } + + @Override + public Object varArgExecute(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { + Object[] argsWithoutSelf = new Object[arguments.length - 1]; + PythonUtils.arraycopy(arguments, 1, argsWithoutSelf, 0, argsWithoutSelf.length); + return execute(frame, arguments[0], argsWithoutSelf, keywords); + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java index bd573df628..234840d547 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/InstancemethodBuiltins.java @@ -48,7 +48,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; @@ -192,7 +191,7 @@ static Object doGeneric(PDecoratedMethod self, Object obj, @SuppressWarnings("un } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java index e7fac1ff3f..9720e82f1a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodBuiltins.java @@ -34,7 +34,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___CODE__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___QUALNAME__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTRIBUTE__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; @@ -159,7 +158,7 @@ static Object getattribute(Object self, @SuppressWarnings("unused") Object key, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodWrapperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodWrapperBuiltins.java index 6150da3a0c..166463c045 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodWrapperBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/MethodWrapperBuiltins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,16 +42,18 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___OBJCLASS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.PythonBuiltins; import com.oracle.graal.python.builtins.objects.PythonAbstractObject; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; import com.oracle.graal.python.nodes.attributes.GetAttributeNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -71,6 +73,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.MethodWrapper) public final class MethodWrapperBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = MethodWrapperBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return MethodWrapperBuiltinsFactory.getFactories(); @@ -85,7 +89,7 @@ Object objclass(PBuiltinMethod self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java index c219c00123..5126b2f5b9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/method/StaticmethodBuiltins.java @@ -41,7 +41,6 @@ package com.oracle.graal.python.builtins.objects.method; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CALL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -122,7 +121,7 @@ static Object call(VirtualFrame frame, PDecoratedMethod self, Object[] args, PKe } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { private static final TruffleString PREFIX = tsLiteral("> getNodeFactories() { return SimpleNamespaceBuiltinsFactory.getFactories(); @@ -179,7 +184,7 @@ static Object reduce(PSimpleNamespace self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class SimpleNamespaceReprNode extends PythonUnaryBuiltinNode { private static final TruffleString T_RECURSE = tsLiteral("...)"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java index 0b21e0e991..ad966b0839 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java @@ -49,9 +49,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE_EX__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SIZEOF__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSHOOK__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUFFLE_RICHCOMPARE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T_UPDATE; @@ -103,10 +101,12 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.CallSlotDescrGet; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrSet; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotRepr.CallSlotReprNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.lib.PyObjectSizeNode; +import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PGuards; @@ -117,7 +117,6 @@ import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.expression.BinaryComparisonNode; import com.oracle.graal.python.nodes.expression.BinaryComparisonNodeFactory; @@ -339,17 +338,24 @@ static Object notImplemented(Object self, Object other) { } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1, doc = "Return str(self).") + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization static Object str(VirtualFrame frame, Object self, - @Cached("create(Repr)") LookupAndCallUnaryNode reprNode) { - return reprNode.executeObject(frame, self); + @Bind Node inliningTarget, + @Cached GetObjectSlotsNode getSlots, + @Cached CallSlotReprNode callSlot, + @Cached ObjectNodes.DefaultObjectReprNode defaultRepr) { + TpSlots slots = getSlots.execute(inliningTarget, self); + if (slots.tp_repr() != null) { + return callSlot.execute(frame, inliningTarget, slots.tp_repr(), self); + } + return defaultRepr.execute(frame, inliningTarget, self); } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @@ -655,8 +661,9 @@ static Object format(Object self, @SuppressWarnings("unused") TruffleString form @Specialization(guards = "formatString.isEmpty()") static Object format(VirtualFrame frame, Object self, @SuppressWarnings("unused") TruffleString formatString, - @Cached("create(Str)") LookupAndCallUnaryNode strCall) { - return strCall.executeObject(frame, self); + @Bind Node inliningTarget, + @Cached PyObjectStrAsObjectNode str) { + return str.execute(frame, inliningTarget, self); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java index 4e65922ced..f90195afc1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ordereddict/OrderedDictBuiltins.java @@ -50,7 +50,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SIZEOF__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T_ITEMS; @@ -497,7 +496,7 @@ static Object iter(POrderedDict self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java index cff17ec06d..34a7c14237 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/posix/DirEntryBuiltins.java @@ -43,7 +43,6 @@ import static com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.opaquePathToBytes; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___CLASS_GETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___FSPATH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.PosixConstants.AT_FDCWD; import static com.oracle.graal.python.runtime.PosixConstants.DT_DIR; import static com.oracle.graal.python.runtime.PosixConstants.DT_LNK; @@ -59,6 +58,8 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -70,14 +71,14 @@ import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.PosixSupport; import com.oracle.graal.python.runtime.PosixSupportLibrary; import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException; @@ -101,6 +102,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PDirEntry) public final class DirEntryBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = DirEntryBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return DirEntryBuiltinsFactory.getFactories(); @@ -128,17 +131,16 @@ static Object nameAsBytes(VirtualFrame frame, PDirEntry self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization static TruffleString repr(VirtualFrame frame, PDirEntry self, @Bind("this") Node inliningTarget, @Cached NameNode nameNode, - @Cached("create(Repr)") LookupAndCallUnaryNode reprNode, - @Cached CastToTruffleStringNode castToStringNode, + @Cached PyObjectReprAsTruffleStringNode repr, @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode) { - return simpleTruffleStringFormatNode.format("", castToStringNode.execute(inliningTarget, reprNode.executeObject(frame, nameNode.execute(frame, self)))); + return simpleTruffleStringFormatNode.format("", repr.execute(frame, inliningTarget, nameNode.execute(frame, self))); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java index 80f53b32b4..49b6104ad8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/range/RangeBuiltins.java @@ -33,7 +33,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; import java.math.BigInteger; @@ -168,9 +167,9 @@ static long hash(VirtualFrame frame, PBigRange self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class ReprNode extends PythonBuiltinNode { + abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization public static TruffleString repr(PRange self, @Bind("this") Node inliningTarget, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java index 35030b8572..2e8905977c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/referencetype/ReferenceTypeBuiltins.java @@ -49,11 +49,12 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -61,6 +62,7 @@ import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.PNotImplemented; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyObjectHashNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; @@ -90,6 +92,9 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PReferenceType) public final class ReferenceTypeBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = ReferenceTypeBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return ReferenceTypeBuiltinsFactory.getFactories(); @@ -160,9 +165,9 @@ static int hashWrong(@SuppressWarnings("unused") Object self, } // ref.__repr__ - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class RefTypeReprNode extends PythonBuiltinNode { + abstract static class RefTypeReprNode extends PythonUnaryBuiltinNode { @Specialization(guards = "self.getObject() == null") static TruffleString repr(PReferenceType self, @Shared("formatter") @Cached SimpleTruffleStringFormatNode simpleTruffleStringFormatNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java index 4dadedf20e..4ee32056e6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/BaseSetBuiltins.java @@ -47,7 +47,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; import static com.oracle.graal.python.nodes.StringLiterals.T_ELLIPSIS_IN_PARENS; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_PARENS; @@ -124,7 +123,7 @@ protected List> getNodeFa return BaseSetBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class BaseReprNode extends PythonUnaryBuiltinNode { private static void fillItems(VirtualFrame frame, Node inliningTarget, HashingStorage storage, TruffleStringBuilder sb, PyObjectReprAsTruffleStringNode repr, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java index 6e3df887c1..4d43b72da0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/slice/SliceBuiltins.java @@ -28,13 +28,14 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.exception.PythonErrorType.ValueError; import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; import java.util.List; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -45,6 +46,7 @@ import com.oracle.graal.python.builtins.objects.slice.SliceNodes.SliceCastToToBigInt; import com.oracle.graal.python.builtins.objects.slice.SliceNodes.SliceExactCastToInt; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectRichCompareBool; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; @@ -71,14 +73,16 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PSlice) public final class SliceBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = SliceBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return SliceBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory - abstract static class ReprNode extends PythonBuiltinNode { + abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization @TruffleBoundary public static TruffleString repr(PSlice self) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java index 7456dd77cf..f15e1da6ba 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/socket/SocketBuiltins.java @@ -52,7 +52,6 @@ import static com.oracle.graal.python.builtins.objects.socket.PSocket.INVALID_FD; import static com.oracle.graal.python.nodes.BuiltinNames.T__SOCKET; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.runtime.PosixConstants.SOL_SOCKET; import static com.oracle.graal.python.runtime.PosixConstants.SO_ERROR; import static com.oracle.graal.python.runtime.PosixConstants.SO_PROTOCOL; @@ -62,6 +61,8 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -74,6 +75,7 @@ import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum; import com.oracle.graal.python.builtins.objects.socket.SocketUtils.TimeoutHelper; import com.oracle.graal.python.builtins.objects.str.StringUtils.SimpleTruffleStringFormatNode; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyLongAsIntNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PConstructAndRaiseNode; @@ -119,6 +121,8 @@ @CoreFunctions(extendClasses = PythonBuiltinClassType.PSocket) public final class SocketBuiltins extends PythonBuiltins { + public static final TpSlots SLOTS = SocketBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return SocketBuiltinsFactory.getFactories(); @@ -265,7 +269,7 @@ protected ArgumentClinicProvider getArgumentClinic() { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java index e07cf6ab3e..89d8478ba6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/SSLErrorBuiltins.java @@ -44,11 +44,12 @@ import static com.oracle.graal.python.builtins.objects.exception.OsErrorBuiltins.IDX_WRITTEN; import static com.oracle.graal.python.builtins.objects.ssl.SSLErrorCode.ERROR_CERT_VERIFICATION; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; import java.util.List; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.CoreFunctions; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -59,6 +60,7 @@ import com.oracle.graal.python.builtins.objects.exception.OsErrorBuiltins; import com.oracle.graal.python.builtins.objects.exception.PBaseException; import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.lib.PyObjectStrAsObjectNode; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; @@ -87,6 +89,8 @@ public final class SSLErrorBuiltins extends PythonBuiltins { public static final BaseExceptionAttrNode.StorageFactory SSL_ERROR_ATTR_FACTORY = (args) -> new Object[SSL_ERR_NUM_ATTRS]; public static final TruffleString T_SSL_IN_BRACKETS = tsLiteral("[SSL]"); + public static final TpSlots SLOTS = SSLErrorBuiltinsSlotsGen.SLOTS; + @Override protected List> getNodeFactories() { return SSLErrorBuiltinsFactory.getFactories(); @@ -171,7 +175,7 @@ Object generic(PBaseException self, Object value, } } - @Builtin(name = J___STR__, minNumOfPositionalArgs = 1, maxNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_str, isComplex = true) @GenerateNodeFactory abstract static class StrNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java index 8aef54caa5..1c1dc5c486 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java @@ -46,8 +46,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUFFLE_RICHCOMPARE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EQ__; @@ -211,7 +209,7 @@ protected List> getNodeFactories() { return LockBuiltinsFactory.getFactories(); @@ -240,7 +245,7 @@ static boolean isLocked(PLock self) { } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprLockNode extends PythonUnaryBuiltinNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java index 55c54bcb44..165839447e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java @@ -43,7 +43,6 @@ import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; import static com.oracle.graal.python.nodes.StringLiterals.T_EQ; @@ -61,6 +60,8 @@ import java.util.Objects; import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; @@ -82,8 +83,9 @@ import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.DisabledNewNodeGen; import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.NewNodeGen; import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.ReduceNodeGen; -import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.ReprNodeGen; +import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; +import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TypeFlags; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; @@ -102,6 +104,7 @@ import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.PSequence; @@ -118,6 +121,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.GenerateNodeFactory; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; @@ -250,17 +254,20 @@ public int hashCode() { } } - public record DescriptorCallTargets(RootCallTarget reprBuiltin, RootCallTarget reduceBuiltin, RootCallTarget newBuiltin) { + public static final TpSlots SLOTS = StructSequenceSlotsGen.SLOTS; + + public record DescriptorCallTargets(RootCallTarget reduceBuiltin, RootCallTarget newBuiltin) { } @TruffleBoundary public static void initType(Python3Core core, BuiltinTypeDescriptor desc) { - initType(core.getLanguage(), core.lookupType(desc.type), desc); + initType(core.getContext(), core.lookupType(desc.type), desc); } @TruffleBoundary - public static void initType(PythonLanguage language, Object klass, Descriptor desc) { + public static void initType(PythonContext context, PythonAbstractClass klass, Descriptor desc) { assert IsSubtypeNode.getUncached().execute(klass, PythonBuiltinClassType.PTuple); + PythonLanguage language = context.getLanguage(); long flags = TypeNodes.GetTypeFlagsNode.executeUncached(klass); if ((flags & TypeFlags.IMMUTABLETYPE) != 0) { @@ -280,15 +287,17 @@ public static void initType(PythonLanguage language, Object klass, Descriptor de } DescriptorCallTargets callTargets = language.getOrCreateStructSequenceCallTargets(desc, d -> new DescriptorCallTargets( - createBuiltinCallTarget(language, desc, ReprNode.class, ReprNodeGen::create, true), createBuiltinCallTarget(language, desc, ReduceNode.class, ReduceNodeGen::create, true), desc.allowInstances ? // createBuiltinCallTarget(language, desc, NewNode.class, NewNodeGen::create, false) : // createBuiltinCallTarget(language, desc, DisabledNewNode.class, ignore -> DisabledNewNodeGen.create(), false))); - createMethod(klass, ReprNode.class, callTargets.reprBuiltin); createMethod(klass, ReduceNode.class, callTargets.reduceBuiltin); + TpSlots.Builder slots = TpSlots.GetTpSlotsNode.executeUncached(klass).copy(); + TpSlots.doSetOneSlot(klass, slots, TpSlots.TpSlotMeta.TP_REPR, SLOTS.tp_repr(), context.getNativeNull()); + TpSlots.setSlots(klass, slots.build()); + WriteAttributeToObjectNode writeAttrNode = WriteAttributeToObjectNode.getUncached(true); /* * Only set __doc__ if given. It may be 'null' e.g. in case of initializing a native class @@ -495,7 +504,8 @@ PTuple reduce(PTuple self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) + @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { @CompilationFinal(dimensions = 1) private final TruffleString[] fieldNames; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java index 768cb79838..ff39e842ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/TupleBuiltins.java @@ -34,7 +34,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___LT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUFFLE_RICHCOMPARE__; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA; import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; @@ -211,7 +210,7 @@ public int len(Object self, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory public abstract static class ReprNode extends PythonUnaryBuiltinNode { @Override diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java index fccf72cd55..e0a5388d4a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java @@ -72,11 +72,9 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MISSING__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REVERSED__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROUND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SET_NAME__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUBCLASSCHECK__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -168,8 +166,6 @@ public enum SpecialMethodSlot { LengthHint(T___LENGTH_HINT__), Hash(T___HASH__), - Str(T___STR__), - Repr(T___REPR__), // Note: __format__ does not seem to be actual slot in CPython, but it is looked up frequently Format(T___FORMAT__), Missing(T___MISSING__), @@ -794,15 +790,7 @@ public static SpecialMethodSlot findSpecialSlot(TruffleString name, TruffleStrin return Hash; } break; - case 's' * 26 + 't': // st - if (eqNode.execute(name, T___STR__, TS_ENCODING)) { - return Str; - } - break; case 'r' * 26 + 'e': // re - if (eqNode.execute(name, T___REPR__, TS_ENCODING)) { - return Repr; - } if (eqNode.execute(name, T___REVERSED__, TS_ENCODING)) { return Reversed; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index ed15a6c644..6b84bca91d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -85,6 +85,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RADD__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RAND__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RDIVMOD__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RFLOORDIV__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RLSHIFT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMATMUL__; @@ -100,6 +101,7 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETATTR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETITEM__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SET__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUB__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUEDIV__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___XOR__; @@ -324,6 +326,8 @@ public record TpSlots(TpSlot nb_bool, // TpSlot combined_tp_setattro_setattr, TpSlot tp_iter, // TpSlot tp_iternext, // + TpSlot tp_repr, // + TpSlot tp_str, // boolean has_as_number, boolean has_as_sequence, boolean has_as_mapping) { @@ -855,7 +859,23 @@ public enum TpSlotMeta { TpSlotGroup.NO_GROUP, CFields.PyTypeObject__tp_iternext, PExternalFunctionWrapper.ITERNEXT, - IterNextWrapper::new); + IterNextWrapper::new), + TP_REPR( + TpSlots::tp_repr, + TpSlotPythonSingle.class, + TpSlotUnaryFuncBuiltin.class, + TpSlotGroup.NO_GROUP, + CFields.PyTypeObject__tp_repr, + PExternalFunctionWrapper.UNARYFUNC, + UnaryFuncWrapper::new), + TP_STR( + TpSlots::tp_str, + TpSlotPythonSingle.class, + TpSlotUnaryFuncBuiltin.class, + TpSlotGroup.NO_GROUP, + CFields.PyTypeObject__tp_str, + PExternalFunctionWrapper.UNARYFUNC, + UnaryFuncWrapper::new); public static final TpSlotMeta[] VALUES = values(); @@ -1037,6 +1057,8 @@ private static void addSlotDef(LinkedHashMap defs, TpSl TpSlotDef.withoutHPy(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE)); addSlotDef(s, TpSlotMeta.TP_ITER, TpSlotDef.withSimpleFunction(T___ITER__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.TP_ITERNEXT, TpSlotDef.withSimpleFunction(T___NEXT__, PExternalFunctionWrapper.ITERNEXT)); + addSlotDef(s, TpSlotMeta.TP_STR, TpSlotDef.withSimpleFunction(T___STR__, PExternalFunctionWrapper.UNARYFUNC)); + addSlotDef(s, TpSlotMeta.TP_REPR, TpSlotDef.withSimpleFunction(T___REPR__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_ADD, TpSlotDef.withoutHPy(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), TpSlotDef.withoutHPy(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); @@ -1763,6 +1785,8 @@ public TpSlots build() { tp_set_attro_attr, get(TpSlotMeta.TP_ITER), // get(TpSlotMeta.TP_ITERNEXT), // + get(TpSlotMeta.TP_REPR), // + get(TpSlotMeta.TP_STR), // hasGroup(TpSlotGroup.AS_NUMBER), hasGroup(TpSlotGroup.AS_SEQUENCE), hasGroup(TpSlotGroup.AS_MAPPING)); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java index 46d1be5146..40b0184da7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java @@ -62,7 +62,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INIT__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___PREPARE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSCHECK__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSES__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSHOOK__; @@ -208,7 +207,7 @@ protected List> getNodeFa return TypeBuiltinsFactory.getFactories(); } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory @ImportStatic(SpecialAttributeNames.class) abstract static class ReprNode extends PythonUnaryBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotRepr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotRepr.java new file mode 100644 index 0000000000..a17eddd1d8 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotRepr.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2024, 2025, 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.builtins.objects.type.slots; + +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; + +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.ExternalFunctionInvokeNode; +import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PyObjectCheckFunctionResultNode; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonTransferNode; +import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; +import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.builtins.objects.function.PFunction; +import com.oracle.graal.python.builtins.objects.object.ObjectNodes; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.TpSlotUnaryFuncBuiltin; +import com.oracle.graal.python.nodes.PGuards; +import com.oracle.graal.python.nodes.call.BoundDescriptor; +import com.oracle.graal.python.nodes.call.CallNode; +import com.oracle.graal.python.nodes.call.FunctionInvokeNode; +import com.oracle.graal.python.nodes.call.special.MaybeBindDescriptorNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; +import com.oracle.graal.python.runtime.ExecutionContext.CallContext; +import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; +import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; +import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.IndirectCallNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.utilities.TruffleWeakReference; + +public final class TpSlotRepr { + private TpSlotRepr() { + } + + // The only difference from CallSlotUnaryNode is the fallback for failed descriptor bind + @GenerateInline + @GenerateCached(false) + @GenerateUncached + public abstract static class CallSlotReprNode extends Node { + private static final CApiTiming C_API_TIMING = CApiTiming.create(true, "repr"); + + public abstract Object execute(VirtualFrame frame, Node inliningTarget, TpSlot slot, Object self); + + @Specialization(guards = "cachedSlot == slot", limit = "3") + static Object callCachedBuiltin(VirtualFrame frame, @SuppressWarnings("unused") TpSlotUnaryFuncBuiltin slot, Object self, + @SuppressWarnings("unused") @Cached("slot") TpSlotUnaryFuncBuiltin cachedSlot, + @Cached("cachedSlot.createSlotNode()") PythonUnaryBuiltinNode slotNode) { + return slotNode.execute(frame, self); + } + + @Specialization + static Object callPython(VirtualFrame frame, TpSlotPythonSingle slot, Object self, + @Cached(inline = false) CallSlotReprPythonNode callSlotNode) { + return callSlotNode.execute(frame, slot, self); + } + + @Specialization + static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative slot, Object self, + @Cached GetThreadStateNode getThreadStateNode, + @Cached(inline = false) PythonToNativeNode toNativeNode, + @Cached ExternalFunctionInvokeNode externalInvokeNode, + @Cached(inline = false) NativeToPythonTransferNode toPythonNode, + @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { + PythonThreadState state = getThreadStateNode.execute(inliningTarget); + Object result = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___REPR__, slot.callable, + toNativeNode.execute(self)); + return checkResultNode.execute(state, T___REPR__, toPythonNode.execute(result)); + } + + @Specialization(replaces = "callCachedBuiltin") + @InliningCutoff + static Object callGenericBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotUnaryFuncBuiltin slot, Object self, + @Cached(inline = false) CallContext callContext, + @Cached InlinedConditionProfile isNullFrameProfile, + @Cached(inline = false) IndirectCallNode indirectCallNode) { + Object[] arguments = PArguments.create(1); + PArguments.setArgument(arguments, 0, self); + return BuiltinDispatchers.callGenericBuiltin(frame, inliningTarget, slot.callTargetIndex, arguments, callContext, isNullFrameProfile, indirectCallNode); + } + } + + @GenerateUncached + @GenerateInline(false) // intentionally lazy + abstract static class CallSlotReprPythonNode extends Node { + abstract Object execute(VirtualFrame frame, TpSlotPythonSingle slot, Object obj); + + @Specialization + static Object doIt(VirtualFrame frame, TpSlotPythonSingle slot, Object self, + @Bind("this") Node inliningTarget, + @Cached ReprPythonSlotDispatcherNode dispatcherNode) { + return dispatcherNode.execute(frame, inliningTarget, slot.getCallable(), slot.getType(), self); + } + } + + @GenerateUncached + @GenerateInline + @GenerateCached(false) + @ImportStatic(PGuards.class) + abstract static class ReprPythonSlotDispatcherNode extends PythonDispatchers.PythonSlotDispatcherNodeBase { + final Object execute(VirtualFrame frame, Node inliningTarget, Object callable, Object type, Object self) { + assert !(callable instanceof TruffleWeakReference); + assert !(type instanceof TruffleWeakReference); + return executeImpl(frame, inliningTarget, callable, type, self); + } + + abstract Object executeImpl(VirtualFrame frame, Node inliningTarget, Object callable, Object type, Object self); + + @Specialization(guards = {"isSingleContext()", "callee == cachedCallee", "isSimpleSignature(cachedCallee, 1)"}, // + limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "cachedCallee.getCodeStableAssumption()") + protected static Object doCachedPFunction(VirtualFrame frame, @SuppressWarnings("unused") PFunction callee, @SuppressWarnings("unused") Object type, Object self, + @SuppressWarnings("unused") @Cached("callee") PFunction cachedCallee, + @Cached("createInvokeNode(cachedCallee)") FunctionInvokeNode invoke) { + Object[] arguments = PArguments.create(1); + PArguments.setArgument(arguments, 0, self); + return invoke.execute(frame, arguments); + } + + @Specialization(replaces = "doCachedPFunction") + @InliningCutoff + static Object doGeneric(VirtualFrame frame, Node inliningTarget, Object callableObj, Object type, Object self, + @Cached MaybeBindDescriptorNode bindDescriptorNode, + @Cached(inline = false) CallNode callNode, + @Cached(inline = false) ObjectNodes.DefaultObjectReprNode defaultRepr) { + Object bound; + try { + bound = bindDescriptorNode.execute(frame, inliningTarget, callableObj, self, type); + } catch (AbstractTruffleException e) { + return defaultRepr.executeCached(frame, self); + } + Object[] arguments; + Object callable; + if (bound instanceof BoundDescriptor boundDescr) { + callable = boundDescr.descriptor; + arguments = PythonUtils.EMPTY_OBJECT_ARRAY; + } else { + callable = bound; + arguments = new Object[]{self}; + } + return callNode.execute(frame, callable, arguments); + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java index 45ad0e9195..710c729337 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/GenericAliasBuiltins.java @@ -61,7 +61,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___MRO_ENTRIES__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSCHECK__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___COPY__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DEEPCOPY__; @@ -207,7 +206,7 @@ static Object union(Object self, Object other, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { private static final TruffleString SEPARATOR = tsLiteral(", "); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java index f638494029..72a2d4f8c3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/types/UnionTypeBuiltins.java @@ -47,7 +47,6 @@ import static com.oracle.graal.python.nodes.SpecialMethodNames.J___EQ__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___HASH__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___INSTANCECHECK__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REPR__; import static com.oracle.graal.python.nodes.SpecialMethodNames.J___SUBCLASSCHECK__; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; @@ -142,7 +141,7 @@ Object union(Object self, Object other, } } - @Builtin(name = J___REPR__, minNumOfPositionalArgs = 1) + @Slot(value = SlotKind.tp_repr, isComplex = true) @GenerateNodeFactory abstract static class ReprNode extends PythonUnaryBuiltinNode { private static final TruffleString SEPARATOR = tsLiteral(" | "); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java index 640d2abfd4..961e07ca9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectReprAsObjectNode.java @@ -44,29 +44,25 @@ import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; -import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.object.ObjectNodes; import com.oracle.graal.python.builtins.objects.str.PString; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotRepr.CallSlotReprNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; -import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.strings.TruffleString; /** @@ -80,7 +76,6 @@ @GenerateUncached @GenerateCached @GenerateInline(inlineByDefault = true) -@ImportStatic(SpecialMethodSlot.class) public abstract class PyObjectReprAsObjectNode extends PNodeWithContext { public static Object executeUncached(Object object) { @@ -99,32 +94,22 @@ public final Object executeCached(Frame frame, Object object) { @Specialization static Object repr(VirtualFrame frame, Node inliningTarget, Object obj, - @Cached GetClassNode getClassNode, - @Cached(parameters = "Repr", inline = false) LookupSpecialMethodSlotNode lookupRepr, - @Cached(inline = false) CallUnaryMethodNode callRepr, + @Cached GetObjectSlotsNode getSlots, + @Cached CallSlotReprNode callSlot, @Cached(inline = false) ObjectNodes.DefaultObjectReprNode defaultRepr, - @Cached InlinedConditionProfile isString, - @Cached InlinedConditionProfile isPString, + @Cached PyUnicodeCheckNode checkNode, @Cached PRaiseNode raiseNode) { - Object type = getClassNode.execute(inliningTarget, obj); - Object reprMethod; - try { - reprMethod = lookupRepr.execute(frame, type, obj); - } catch (PException e) { + TpSlots slots = getSlots.execute(inliningTarget, obj); + if (slots.tp_repr() == null) { return defaultRepr.execute(frame, inliningTarget, obj); } - if (reprMethod != PNone.NO_VALUE) { - Object result = callRepr.executeObject(frame, reprMethod, obj); - result = assertNoJavaString(result); - if (isString.profile(inliningTarget, result instanceof TruffleString) || - isPString.profile(inliningTarget, result instanceof PString)) { - return result; - } - if (result != PNone.NO_VALUE) { - throw raiseTypeError(inliningTarget, obj, raiseNode); - } + Object result = callSlot.execute(frame, inliningTarget, slots.tp_repr(), obj); + assertNoJavaString(result); + if (checkNode.execute(inliningTarget, result)) { + return result; + } else { + throw raiseTypeError(inliningTarget, obj, raiseNode); } - return defaultRepr.execute(frame, inliningTarget, obj); } @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java index a5b7c3f35e..ddf29de641 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsObjectNode.java @@ -47,22 +47,19 @@ import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; import com.oracle.graal.python.builtins.objects.str.PString; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlotUnaryFunc.CallSlotUnaryNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; -import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateCached; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.Frame; @@ -81,7 +78,6 @@ @GenerateUncached @GenerateInline(inlineByDefault = true) @GenerateCached -@ImportStatic(SpecialMethodSlot.class) public abstract class PyObjectStrAsObjectNode extends PNodeWithContext { public final Object executeCached(Frame frame, Object object) { return execute(frame, this, object); @@ -111,25 +107,29 @@ TruffleString str(long object, @Specialization(guards = "!isTruffleString(obj)") static Object str(VirtualFrame frame, Node inliningTarget, Object obj, - @Cached GetClassNode getClassNode, - @Cached(parameters = "Str", inline = false) LookupSpecialMethodSlotNode lookupStr, - @Cached(inline = false) CallUnaryMethodNode callStr, - @Cached GetClassNode getResultClassNode, - @Cached(inline = false) IsSubtypeNode isSubtypeNode, + @Cached GetObjectSlotsNode getSlots, + @Cached CallSlotUnaryNode callSlot, + @Cached PyObjectReprAsObjectNode repr, + @Cached PyUnicodeCheckNode checkNode, @Cached PRaiseNode raiseNode) { - Object type = getClassNode.execute(inliningTarget, obj); - Object strDescr = lookupStr.execute(frame, type, obj); - // All our objects should have __str__ - assert strDescr != PNone.NO_VALUE; - Object result = callStr.executeObject(frame, strDescr, obj); - result = assertNoJavaString(result); - if (result instanceof TruffleString || isSubtypeNode.execute(getResultClassNode.execute(inliningTarget, result), PythonBuiltinClassType.PString)) { + TpSlots slots = getSlots.execute(inliningTarget, obj); + if (slots.tp_str() == null) { + return repr.execute(frame, inliningTarget, obj); + } + Object result = callSlot.execute(frame, inliningTarget, slots.tp_str(), obj); + assertNoJavaString(result); + if (checkNode.execute(inliningTarget, result)) { return result; } else { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_STRING, T___STR__, result); + throw raiseTypeError(inliningTarget, raiseNode, result); } } + @InliningCutoff + private static PException raiseTypeError(Node inliningTarget, PRaiseNode raiseNode, Object result) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.RETURNED_NON_STRING, T___STR__, result); + } + @NeverDefault public static PyObjectStrAsObjectNode create() { return PyObjectStrAsObjectNodeGen.create(); From 2fc314f1827488f8a82a4e849f2f166319dc5992 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Mar 2025 15:24:38 +0100 Subject: [PATCH 156/512] Refactor strctseq to share call targets --- .../src/structseq.c | 10 +- .../src/tests/cpyext/test_structseq.py | 12 +- .../src/tests/test_structseq.py | 5 +- .../oracle/graal/python/PythonLanguage.java | 45 --- .../graal/python/builtins/Python3Core.java | 2 + .../builtins/PythonBuiltinClassType.java | 36 +- .../builtins/modules/PosixModuleBuiltins.java | 16 +- .../builtins/objects/cext/capi/CExtNodes.java | 4 + .../objects/tuple/StructSequence.java | 360 +++--------------- .../objects/tuple/StructSequenceBuiltins.java | 342 +++++++++++++++++ .../graal/python/nodes/ErrorMessages.java | 1 + .../oracle/graal/python/nodes/HiddenAttr.java | 3 +- .../python/nodes/builtins/ListNodes.java | 7 +- 13 files changed, 435 insertions(+), 408 deletions(-) create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequenceBuiltins.java diff --git a/graalpython/com.oracle.graal.python.cext/src/structseq.c b/graalpython/com.oracle.graal.python.cext/src/structseq.c index 2858e8d7ea..b6bff24c4c 100644 --- a/graalpython/com.oracle.graal.python.cext/src/structseq.c +++ b/graalpython/com.oracle.graal.python.cext/src/structseq.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2024, Oracle and/or its affiliates. +/* Copyright (c) 2024, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2022 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -385,6 +385,7 @@ static PyMethodDef structseq_methods[] = { {"__reduce__", (PyCFunction)structseq_reduce, METH_NOARGS, NULL}, {NULL, NULL} }; +#endif // GraalPy change static Py_ssize_t count_members(PyStructSequence_Desc *desc, Py_ssize_t *n_unnamed_members) { @@ -399,6 +400,7 @@ count_members(PyStructSequence_Desc *desc, Py_ssize_t *n_unnamed_members) { return i; } +#if 0 // GraalPy change static int initialize_structseq_dict(PyStructSequence_Desc *desc, PyObject* dict, Py_ssize_t n_members, Py_ssize_t n_unnamed_members) { @@ -455,6 +457,7 @@ initialize_structseq_dict(PyStructSequence_Desc *desc, PyObject* dict, Py_DECREF(keys); return -1; } +#endif // GraalPy change static void initialize_members(PyStructSequence_Desc *desc, PyMemberDef* members, @@ -478,7 +481,6 @@ initialize_members(PyStructSequence_Desc *desc, PyMemberDef* members, } members[k].name = NULL; } -#endif // GraalPy change int @@ -518,7 +520,6 @@ _PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc, type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | tp_flags; type->tp_traverse = (traverseproc) structseq_traverse; -#if 0 // GraalPy change: initialize members in an upcall later n_members = count_members(desc, &n_unnamed_members); members = PyMem_NEW(PyMemberDef, n_members - n_unnamed_members + 1); if (members == NULL) { @@ -527,9 +528,6 @@ _PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc, } initialize_members(desc, members, n_members); type->tp_members = members; -#else // GraalPy change - type->tp_members = NULL; -#endif // GraalPy change if (PyType_Ready(type) < 0) { // GraalPy change: not initialized diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_structseq.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_structseq.py index 6f92f37932..4d65183658 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_structseq.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_structseq.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2025, 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 @@ -48,6 +48,7 @@ def test_properties(self): static PyStructSequence_Field typeinfo_fields[] = { {"element0", "The first element."}, {"element1", "The second element."}, + {"element2", "The third element."}, {NULL, NULL,} }; @@ -69,11 +70,18 @@ def test_properties(self): ) assert TestPyStructSequence.__doc__ == "Information about some custom struct type" - tester = TestPyStructSequence(("hello", "world")) + tester = TestPyStructSequence(("hello", "world"), {"element2": 1}) assert hasattr(tester, "element0") assert hasattr(tester, "element1") assert tester.element0 == "hello" assert tester.element1 == "world" + assert tester.element2 == 1 + assert len(tester) == 2 + assert tuple(tester) == ("hello", "world") + assert repr(tester) == "TestPyStructSequenceTypes.TestPyStructSequence(element0='hello', element1='world')" + assert tester.__repr__() == "TestPyStructSequenceTypes.TestPyStructSequence(element0='hello', element1='world')" + assert tester.__reduce__() == (TestPyStructSequence, (('hello', 'world'), {'element2': 1})) + assert tester.__reduce__.__qualname__ == "TestPyStructSequence.__reduce__" def test_structseq_newtype(self): TestPyStructSequenceNewType = CPyExtType("TestPyStructSequenceNewType", """ diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_structseq.py b/graalpython/com.oracle.graal.python.test/src/tests/test_structseq.py index 927b471c34..23f894e616 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_structseq.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_structseq.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2021, 2025, 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 @@ -79,7 +79,8 @@ def test_constructor_err(self): with self.assertRaisesRegex(TypeError, r'os.stat_result\(\) takes an at most \d+-sequence \(30-sequence given\)'): posix.stat_result((1,) * 30) with self.assertRaisesRegex(TypeError, r'cannot create \'sys.flags\' instances'): - type(sys.flags)() + # GraalPy change: add argument to avoid hitting the argument error first + type(sys.flags)(()) def test_no_subclass(self): with self.assertRaises(TypeError): diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index 305f8f3268..04d0687028 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -37,7 +37,6 @@ import java.io.IOException; import java.io.InputStream; import java.lang.invoke.VarHandle; -import java.lang.ref.WeakReference; import java.nio.charset.StandardCharsets; import java.nio.file.InvalidPathException; import java.util.ArrayList; @@ -71,9 +70,6 @@ import com.oracle.graal.python.builtins.objects.module.PythonModule; import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.builtins.objects.tuple.StructSequence; -import com.oracle.graal.python.builtins.objects.tuple.StructSequence.BuiltinTypeDescriptor; -import com.oracle.graal.python.builtins.objects.tuple.StructSequence.Descriptor; -import com.oracle.graal.python.builtins.objects.tuple.StructSequence.DescriptorCallTargets; import com.oracle.graal.python.builtins.objects.type.MroShape; import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; @@ -363,46 +359,6 @@ public boolean isSingleContext() { @CompilationFinal(dimensions = 1) private final RootCallTarget[] builtinSlotsCallTargets; - /** - * Weak hash map of call targets for builtin functions associated with named tuples generated at - * runtime from C extensions. We hold the cached call targets also weakly, because otherwise we - * would have a cycle from the value (call targets reference builtin nodes which wrap the - * descriptor) to the key. The key should be GC'ed when the corresponding generated named tuple - * class is GC'ed. - */ - private final WeakHashMap> structSequenceTargets = new WeakHashMap<>(); - - /** - * The same as {@link #structSequenceTargets}, but for builtin named tuples. There is a bounded - * statically known number of builtin named tuples. - */ - private final ConcurrentHashMap structSequenceBuiltinTargets = new ConcurrentHashMap<>(); - - public StructSequence.DescriptorCallTargets getOrCreateStructSequenceCallTargets(StructSequence.Descriptor descriptor, - Function factory) { - if (singleContext) { - return factory.apply(descriptor); - } - if (descriptor instanceof BuiltinTypeDescriptor builtinDescriptor) { - // There must be finite set of objects initialized in static final fields, no need for a - // weak map - return structSequenceBuiltinTargets.computeIfAbsent(builtinDescriptor, factory); - } - return getOrCreateStructSeqNonBuiltinTargets(descriptor, factory); - } - - private DescriptorCallTargets getOrCreateStructSeqNonBuiltinTargets(Descriptor descriptor, Function factory) { - synchronized (structSequenceTargets) { - WeakReference weakResult = structSequenceTargets.computeIfAbsent(descriptor, d -> new WeakReference<>(factory.apply(d))); - DescriptorCallTargets result = weakResult.get(); - if (result == null) { - result = factory.apply(descriptor); - structSequenceTargets.put(descriptor, new WeakReference<>(result)); - } - return result; - } - } - /** * We cannot initialize call targets in language ctor and the next suitable hook is context * initialization, but that is called multiple times. We use this flag to run the language @@ -482,7 +438,6 @@ protected void finalizeContext(PythonContext context) { context.finalizeContext(); super.finalizeContext(context); // trigger cleanup of stale entries in weak hash maps - structSequenceTargets.size(); indirectCallDataMap.size(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index 298be8e5ad..ab19dff91e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -356,6 +356,7 @@ import com.oracle.graal.python.builtins.objects.thread.ThreadLocalBuiltins; import com.oracle.graal.python.builtins.objects.tokenize.TokenizerIterBuiltins; import com.oracle.graal.python.builtins.objects.traceback.TracebackBuiltins; +import com.oracle.graal.python.builtins.objects.tuple.StructSequenceBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleGetterBuiltins; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; @@ -493,6 +494,7 @@ private static PythonBuiltins[] initializeBuiltins(TruffleLanguage.Env env) { new RangeBuiltins(), new SliceBuiltins(), new TupleBuiltins(), + new StructSequenceBuiltins(), new StringBuiltins(), new BaseSetBuiltins(), new SetBuiltins(), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java index 9921e330c1..001c1d61e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java @@ -241,7 +241,7 @@ import com.oracle.graal.python.builtins.objects.thread.LockBuiltins; import com.oracle.graal.python.builtins.objects.thread.ThreadLocalBuiltins; import com.oracle.graal.python.builtins.objects.tokenize.TokenizerIterBuiltins; -import com.oracle.graal.python.builtins.objects.tuple.StructSequence; +import com.oracle.graal.python.builtins.objects.tuple.StructSequenceBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleBuiltins; import com.oracle.graal.python.builtins.objects.tuple.TupleGetterBuiltins; import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; @@ -416,23 +416,23 @@ public enum PythonBuiltinClassType implements TruffleObject { PBytesIO("BytesIO", "_io", Flags.PUBLIC_BASE_WDICT, BytesIOBuiltins.SLOTS), PBytesIOBuf("_BytesIOBuffer", "_io", Flags.PRIVATE_BASE_WODICT), - PStatResult("stat_result", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PStatvfsResult("statvfs_result", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PTerminalSize("terminal_size", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PUnameResult("uname_result", J_POSIX, Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PStructTime("struct_time", "time", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PProfilerEntry("profiler_entry", "_lsprof", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PProfilerSubentry("profiler_subentry", "_lsprof", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PStructPasswd("struct_passwd", "pwd", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PStructRusage("struct_rusage", "resource", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PVersionInfo("version_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PWindowsVersion("windowsversion", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PFlags("flags", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PFloatInfo("float_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PIntInfo("int_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PHashInfo("hash_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PThreadInfo("thread_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), - PUnraisableHookArgs("UnraisableHookArgs", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS), + PStatResult("stat_result", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PStatvfsResult("statvfs_result", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PTerminalSize("terminal_size", "os", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PUnameResult("uname_result", J_POSIX, Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PStructTime("struct_time", "time", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PProfilerEntry("profiler_entry", "_lsprof", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PProfilerSubentry("profiler_subentry", "_lsprof", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PStructPasswd("struct_passwd", "pwd", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PStructRusage("struct_rusage", "resource", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PVersionInfo("version_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PWindowsVersion("windowsversion", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PFlags("flags", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PFloatInfo("float_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PIntInfo("int_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PHashInfo("hash_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PThreadInfo("thread_info", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), + PUnraisableHookArgs("UnraisableHookArgs", "sys", Flags.PUBLIC_DERIVED_WODICT, TUPLE_M_FLAGS, StructSequenceBuiltins.SLOTS), PSSLSession("SSLSession", J__SSL), PSSLContext("_SSLContext", J__SSL), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java index 0877f1c927..32e2c41b7a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java @@ -83,6 +83,7 @@ import com.oracle.graal.python.builtins.objects.posix.PScandirIterator; import com.oracle.graal.python.builtins.objects.tuple.PTuple; import com.oracle.graal.python.builtins.objects.tuple.StructSequence; +import com.oracle.graal.python.builtins.objects.tuple.StructSequenceBuiltins; import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.lib.PyLongAsIntNode; import com.oracle.graal.python.lib.PyLongAsLongAndOverflowNode; @@ -398,13 +399,12 @@ public void postInitialize(Python3Core core) { } @Builtin(name = "stat_result", minNumOfPositionalArgs = 1, parameterNames = {"$cls", "sequence", "dict"}, constructsClass = PythonBuiltinClassType.PStatResult) - @ImportStatic(PosixModuleBuiltins.class) @GenerateNodeFactory public abstract static class StatResultNode extends PythonTernaryBuiltinNode { @Specialization public static PTuple generic(VirtualFrame frame, Object cls, Object sequence, Object dict, - @Cached("create(STAT_RESULT_DESC)") StructSequence.NewNode newNode) { + @Cached StructSequenceBuiltins.NewNode newNode) { PTuple p = (PTuple) newNode.execute(frame, cls, sequence, dict); Object[] data = CompilerDirectives.castExact(p.getSequenceStorage(), ObjectSequenceStorage.class).getInternalObjectArray(); for (int i = 7; i <= 9; i++) { @@ -416,18 +416,6 @@ public static PTuple generic(VirtualFrame frame, Object cls, Object sequence, Ob } } - @Builtin(name = "statvfs_result", minNumOfPositionalArgs = 1, parameterNames = {"$cls", "sequence", "dict"}, constructsClass = PythonBuiltinClassType.PStatvfsResult) - @ImportStatic(PosixModuleBuiltins.class) - @GenerateNodeFactory - public abstract static class StatvfsResultNode extends PythonTernaryBuiltinNode { - - @Specialization - public static Object generic(VirtualFrame frame, Object cls, Object sequence, Object dict, - @Cached("create(STATVFS_RESULT_DESC)") StructSequence.NewNode newNode) { - return newNode.execute(frame, cls, sequence, dict); - } - } - @Builtin(name = "putenv", minNumOfPositionalArgs = 2, parameterNames = {"name", "value"}) @ArgumentClinic(name = "name", conversionClass = FsConverterNode.class) @ArgumentClinic(name = "value", conversionClass = FsConverterNode.class) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java index 1121c22ab5..4dbd99443f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java @@ -550,6 +550,10 @@ public final TruffleString execute(Object charPtr) { return execute(charPtr, true); } + public static TruffleString executeUncached(Object charPtr) { + return FromCharPointerNodeGen.getUncached().execute(charPtr); + } + public abstract TruffleString execute(Object charPtr, boolean copy); @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java index 165839447e..e203e0e45b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequence.java @@ -40,95 +40,50 @@ */ package com.oracle.graal.python.builtins.objects.tuple; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.NotImplementedError; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; -import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; -import static com.oracle.graal.python.nodes.StringLiterals.T_EQ; -import static com.oracle.graal.python.nodes.StringLiterals.T_LPAREN; -import static com.oracle.graal.python.nodes.StringLiterals.T_RPAREN; -import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REDUCE__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.util.PythonUtils.EMPTY_TRUFFLESTRING_ARRAY; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; import static com.oracle.graal.python.util.PythonUtils.toTruffleStringArrayUncached; import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; import static com.oracle.graal.python.util.PythonUtils.tsArray; import static com.oracle.graal.python.util.PythonUtils.tsLiteral; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Objects; import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.annotations.Slot; -import com.oracle.graal.python.annotations.Slot.SlotKind; -import com.oracle.graal.python.builtins.Builtin; import com.oracle.graal.python.builtins.Python3Core; import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItem; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; +import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetItemNode; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ToArrayNode; -import com.oracle.graal.python.builtins.objects.dict.PDict; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptor; -import com.oracle.graal.python.builtins.objects.object.ObjectNodes.GetFullyQualifiedClassNameNode; -import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.DisabledNewNodeGen; -import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.NewNodeGen; -import com.oracle.graal.python.builtins.objects.tuple.StructSequenceFactory.ReduceNodeGen; import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass; import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; -import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; import com.oracle.graal.python.builtins.objects.type.TypeFlags; import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; -import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.PRootNode; -import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; -import com.oracle.graal.python.nodes.builtins.ListNodes.FastConstructListNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; -import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.runtime.sequence.PSequence; -import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.graal.python.util.Function; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedBranchProfile; import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleStringBuilder; /** * Allows definitions of tuple-like structs with named fields (like structseq.c in CPython). @@ -170,28 +125,6 @@ public Descriptor(TruffleString docString, int inSequence, TruffleString[] field this(docString, inSequence, fieldNames, fieldDocStrings, true); } - // This shifts the names in a confusing way, but that is what CPython does: - // >>> s = os.stat('.') - // >>> s.st_atime - // 1607033732.3041613 - // >>> s - // os.stat_result(..., st_atime=1607033732, ...) - // - // note that st_atime accessed by name returns float (index 10), but in repr the same label - // is assigned to the int value at index 7 - TruffleString[] getFieldsForRepr() { - TruffleString[] fieldNamesForRepr = new TruffleString[inSequence]; - int k = 0; - for (int idx = 0; idx < fieldNames.length && k < inSequence; ++idx) { - if (fieldNames[idx] != null) { - fieldNamesForRepr[k++] = fieldNames[idx]; - } - } - // each field < inSequence must have a name - assert k == inSequence; - return fieldNamesForRepr; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -217,8 +150,7 @@ public int hashCode() { /** * Very similar to {@code PyStructSequence_Desc} but already specific to a built-in type. Used * for built-in structseq objects. All BuiltinTypeDescriptor instances should be kept in - * {@code static final} fields to ensure there is a finite number of them, see - * {@link PythonLanguage#getOrCreateStructSequenceCallTargets(Descriptor, Function)}. + * {@code static final} fields to ensure there is a finite number of them. */ public static final class BuiltinTypeDescriptor extends Descriptor { public final PythonBuiltinClassType type; @@ -254,11 +186,6 @@ public int hashCode() { } } - public static final TpSlots SLOTS = StructSequenceSlotsGen.SLOTS; - - public record DescriptorCallTargets(RootCallTarget reduceBuiltin, RootCallTarget newBuiltin) { - } - @TruffleBoundary public static void initType(Python3Core core, BuiltinTypeDescriptor desc) { initType(core.getContext(), core.lookupType(desc.type), desc); @@ -275,30 +202,41 @@ public static void initType(PythonContext context, PythonAbstractClass klass, De TypeNodes.SetTypeFlagsNode.executeUncached(klass, flags & ~TypeFlags.IMMUTABLETYPE); } + if (!desc.allowInstances) { + flags |= TypeFlags.DISALLOW_INSTANTIATION; + } + // create descriptors for accessing named fields by their names int unnamedFields = 0; + List namedFields = new ArrayList<>(desc.fieldNames.length); for (int idx = 0; idx < desc.fieldNames.length; ++idx) { - if (desc.fieldNames[idx] != null) { + TruffleString fieldName = desc.fieldNames[idx]; + if (fieldName != null) { TruffleString doc = desc.fieldDocStrings == null ? null : desc.fieldDocStrings[idx]; - createMember(language, klass, desc.fieldNames[idx], doc, idx); + createMember(language, klass, fieldName, doc, idx); + namedFields.add(fieldName); } else { unnamedFields++; } } - - DescriptorCallTargets callTargets = language.getOrCreateStructSequenceCallTargets(desc, d -> new DescriptorCallTargets( - createBuiltinCallTarget(language, desc, ReduceNode.class, ReduceNodeGen::create, true), - desc.allowInstances ? // - createBuiltinCallTarget(language, desc, NewNode.class, NewNodeGen::create, false) : // - createBuiltinCallTarget(language, desc, DisabledNewNode.class, ignore -> DisabledNewNodeGen.create(), false))); - - createMethod(klass, ReduceNode.class, callTargets.reduceBuiltin); - - TpSlots.Builder slots = TpSlots.GetTpSlotsNode.executeUncached(klass).copy(); - TpSlots.doSetOneSlot(klass, slots, TpSlots.TpSlotMeta.TP_REPR, SLOTS.tp_repr(), context.getNativeNull()); - TpSlots.setSlots(klass, slots.build()); - WriteAttributeToObjectNode writeAttrNode = WriteAttributeToObjectNode.getUncached(true); + if (klass instanceof PythonManagedClass managedClass) { + /* + * The methods and slots are already set for each PBCT, but we need to store the field + * names. + */ + HiddenAttr.WriteNode.executeUncached(managedClass, HiddenAttr.STRUCTSEQ_FIELD_NAMES, namedFields.toArray(new TruffleString[0])); + } else if (klass instanceof PythonAbstractNativeObject) { + /* + * We need to add the methods. Note that PyType_Ready already ran, so we just write the + * method wrappers. We take them from any builtin that doesn't override them and rebind + * them to the type. Field names are already populated in tp_members on the native side. + */ + PythonBuiltinClass template = context.lookupType(PythonBuiltinClassType.PFlags); + copyMethod(language, klass, T___NEW__, template); + copyMethod(language, klass, T___REPR__, template); + copyMethod(language, klass, T___REDUCE__, template); + } /* * Only set __doc__ if given. It may be 'null' e.g. in case of initializing a native class * where 'tp_doc' is set in native code already. @@ -310,20 +248,13 @@ public static void initType(PythonContext context, PythonAbstractClass klass, De writeAttrNode.execute(klass, T_N_FIELDS, desc.fieldNames.length); writeAttrNode.execute(klass, T_N_UNNAMED_FIELDS, unnamedFields); - if (ReadAttributeFromObjectNode.getUncachedForceType().execute(klass, T___NEW__) == PNone.NO_VALUE) { - Builtin builtin = NewNode.class.getAnnotation(Builtin.class); - PythonUtils.createConstructor(klass, builtin, callTargets.newBuiltin); - } - if ((flags & TypeFlags.IMMUTABLETYPE) != 0) { - // Restore flags - TypeNodes.SetTypeFlagsNode.executeUncached(klass, flags); - } + TypeNodes.SetTypeFlagsNode.executeUncached(klass, flags); } - private static RootCallTarget createBuiltinCallTarget(PythonLanguage l, Descriptor descriptor, Class nodeClass, Function nodeFactory, - boolean declaresExplicitSelf) { - Builtin builtin = nodeClass.getAnnotation(Builtin.class); - return new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory(nodeFactory.apply(descriptor)), declaresExplicitSelf).getCallTarget(); + private static void copyMethod(PythonLanguage language, PythonAbstractClass klass, TruffleString name, PythonBuiltinClass template) { + PBuiltinFunction templateMethod = (PBuiltinFunction) template.getAttribute(name); + PBuiltinFunction method = PFactory.createBuiltinFunction(language, templateMethod, klass); + WriteAttributeToObjectNode.getUncached(true).execute(klass, name, method); } private static void createMember(PythonLanguage language, Object klass, TruffleString name, TruffleString doc, int idx) { @@ -336,212 +267,6 @@ private static void createMember(PythonLanguage language, Object klass, TruffleS WriteAttributeToObjectNode.getUncached(true).execute(klass, name, callable); } - private static void createMethod(Object klass, Class nodeClass, RootCallTarget callTarget) { - Builtin builtin = nodeClass.getAnnotation(Builtin.class); - PythonUtils.createMethod(klass, builtin, callTarget, PythonBuiltinClassType.PTuple, 0); - } - - @Builtin(name = J___NEW__, minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true) - public abstract static class DisabledNewNode extends PythonVarargsBuiltinNode { - - @Override - @SuppressWarnings("unused") - public final Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords) throws VarargsBuiltinDirectInvocationNotSupported { - if (arguments.length > 0) { - return error(arguments[0], PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw VarargsBuiltinDirectInvocationNotSupported.INSTANCE; - } - - @Specialization - @SuppressWarnings("unused") - Object error(Object cls, Object[] arguments, PKeyword[] keywords) { - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, StructSequence.getTpName(cls)); - } - } - - @Builtin(name = J___NEW__, minNumOfPositionalArgs = 2, parameterNames = {"$cls", "sequence", "dict"}) - public abstract static class NewNode extends PythonTernaryBuiltinNode { - - @CompilationFinal(dimensions = 1) private final TruffleString[] fieldNames; - private final int inSequence; - - NewNode(Descriptor desc) { - this.fieldNames = desc.fieldNames; - this.inSequence = desc.inSequence; - } - - @NeverDefault - public static NewNode create(Descriptor desc) { - return NewNodeGen.create(desc); - } - - @Specialization(guards = "isNoValue(dict)") - @SuppressWarnings("truffle-static-method") - PTuple withoutDict(VirtualFrame frame, Object cls, Object sequence, @SuppressWarnings("unused") PNone dict, - @Bind("this") Node inliningTarget, - @Exclusive @Cached FastConstructListNode fastConstructListNode, - @Exclusive @Cached ToArrayNode toArrayNode, - @Exclusive @Cached IsBuiltinObjectProfile notASequenceProfile, - @Exclusive @Cached InlinedBranchProfile wrongLenProfile, - @Exclusive @Cached InlinedBranchProfile needsReallocProfile, - @Bind PythonLanguage language, - @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode raiseNode) { - Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); - Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); - for (int i = src.length; i < dst.length; ++i) { - dst[i] = PNone.NONE; - } - return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(dst, inSequence)); - } - - @Specialization - @SuppressWarnings("truffle-static-method") - PTuple withDict(VirtualFrame frame, Object cls, Object sequence, PDict dict, - @Bind("this") Node inliningTarget, - @Exclusive @Cached FastConstructListNode fastConstructListNode, - @Exclusive @Cached ToArrayNode toArrayNode, - @Exclusive @Cached IsBuiltinObjectProfile notASequenceProfile, - @Exclusive @Cached InlinedBranchProfile wrongLenProfile, - @Exclusive @Cached InlinedBranchProfile needsReallocProfile, - @Cached HashingStorageGetItem getItem, - @Bind PythonLanguage language, - @Shared @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Exclusive @Cached PRaiseNode raiseNode) { - Object[] src = sequenceToArray(frame, inliningTarget, sequence, fastConstructListNode, toArrayNode, notASequenceProfile, raiseNode); - Object[] dst = processSequence(inliningTarget, cls, src, wrongLenProfile, needsReallocProfile, raiseNode); - HashingStorage hs = dict.getDictStorage(); - for (int i = src.length; i < dst.length; ++i) { - Object o = getItem.execute(inliningTarget, hs, fieldNames[i]); - dst[i] = o == null ? PNone.NONE : o; - } - return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(dst, inSequence)); - } - - @Specialization(guards = {"!isNoValue(dict)", "!isDict(dict)"}) - @SuppressWarnings("unused") - static PTuple doDictError(VirtualFrame frame, Object cls, Object sequence, Object dict, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.TAKES_A_DICT_AS_SECOND_ARG_IF_ANY, StructSequence.getTpName(cls)); - } - - private static Object[] sequenceToArray(VirtualFrame frame, Node inliningTarget, Object sequence, FastConstructListNode fastConstructListNode, - ToArrayNode toArrayNode, IsBuiltinObjectProfile notASequenceProfile, PRaiseNode raiseNode) { - PSequence seq; - try { - seq = fastConstructListNode.execute(frame, inliningTarget, sequence); - } catch (PException e) { - e.expect(inliningTarget, TypeError, notASequenceProfile); - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CONSTRUCTOR_REQUIRES_A_SEQUENCE); - } - return toArrayNode.execute(inliningTarget, seq.getSequenceStorage()); - } - - private Object[] processSequence(Node inliningTarget, Object cls, Object[] src, InlinedBranchProfile wrongLenProfile, InlinedBranchProfile needsReallocProfile, PRaiseNode raiseNode) { - int len = src.length; - int minLen = inSequence; - int maxLen = fieldNames.length; - - if (len < minLen || len > maxLen) { - wrongLenProfile.enter(inliningTarget); - if (minLen == maxLen) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_A_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); - } - if (len < minLen) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_LEAST_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); - } else { // len > maxLen - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_MOST_D_SEQUENCE, StructSequence.getTpName(cls), maxLen, len); - } - } - - if (len != maxLen) { - needsReallocProfile.enter(inliningTarget); - Object[] dst = new Object[maxLen]; - PythonUtils.arraycopy(src, 0, dst, 0, len); - return dst; - } - return src; - } - } - - @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1) - abstract static class ReduceNode extends PythonUnaryBuiltinNode { - - @CompilationFinal(dimensions = 1) private final TruffleString[] fieldNames; - private final int inSequence; - - ReduceNode(Descriptor desc) { - this.fieldNames = desc.fieldNames; - this.inSequence = desc.inSequence; - } - - @Specialization - PTuple reduce(PTuple self, - @Bind("this") Node inliningTarget, - @Cached HashingStorageSetItem setHashingStorageItem, - @Cached GetClassNode getClass, - @Bind PythonLanguage language) { - assert self.getSequenceStorage() instanceof ObjectSequenceStorage; - Object[] data = CompilerDirectives.castExact(self.getSequenceStorage(), ObjectSequenceStorage.class).getInternalObjectArray(); - assert data.length == fieldNames.length; - PTuple seq; - PDict dict; - if (fieldNames.length == inSequence) { - seq = PFactory.createTuple(language, data); - dict = PFactory.createDict(language); - } else { - HashingStorage storage = EconomicMapStorage.create(fieldNames.length - inSequence); - for (int i = inSequence; i < fieldNames.length; ++i) { - storage = setHashingStorageItem.execute(inliningTarget, storage, fieldNames[i], data[i]); - } - seq = PFactory.createTuple(language, Arrays.copyOf(data, inSequence)); - dict = PFactory.createDict(language, storage); - } - PTuple seqDictPair = PFactory.createTuple(language, new Object[]{seq, dict}); - return PFactory.createTuple(language, new Object[]{getClass.execute(inliningTarget, self), seqDictPair}); - } - } - - @Slot(value = SlotKind.tp_repr, isComplex = true) - @GenerateNodeFactory - abstract static class ReprNode extends PythonUnaryBuiltinNode { - - @CompilationFinal(dimensions = 1) private final TruffleString[] fieldNames; - - ReprNode(Descriptor desc) { - this.fieldNames = desc.getFieldsForRepr(); - } - - @Specialization - public TruffleString repr(VirtualFrame frame, PTuple self, - @Bind("this") Node inliningTarget, - @Cached GetFullyQualifiedClassNameNode getFullyQualifiedClassNameNode, - @Cached("createNotNormalized()") GetItemNode getItemNode, - @Cached PyObjectReprAsTruffleStringNode reprNode, - @Cached TruffleStringBuilder.AppendStringNode appendStringNode, - @Cached TruffleStringBuilder.ToStringNode toStringNode) { - TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); - appendStringNode.execute(sb, getFullyQualifiedClassNameNode.execute(frame, inliningTarget, self)); - appendStringNode.execute(sb, T_LPAREN); - SequenceStorage tupleStore = self.getSequenceStorage(); - if (fieldNames.length > 0) { - appendStringNode.execute(sb, fieldNames[0]); - appendStringNode.execute(sb, T_EQ); - appendStringNode.execute(sb, reprNode.execute(frame, inliningTarget, getItemNode.execute(tupleStore, 0))); - for (int i = 1; i < fieldNames.length; i++) { - appendStringNode.execute(sb, T_COMMA_SPACE); - appendStringNode.execute(sb, fieldNames[i]); - appendStringNode.execute(sb, T_EQ); - appendStringNode.execute(sb, reprNode.execute(frame, inliningTarget, getItemNode.execute(tupleStore, i))); - } - } - appendStringNode.execute(sb, T_RPAREN); - return toStringNode.execute(sb); - } - } - private static class GetStructMemberNode extends PRootNode { public static final Signature SIGNATURE = new Signature(-1, false, -1, false, tsArray("$self"), EMPTY_TRUFFLESTRING_ARRAY); private final int fieldIdx; @@ -554,6 +279,9 @@ private static class GetStructMemberNode extends PRootNode { @Override public Object execute(VirtualFrame frame) { PTuple self = (PTuple) PArguments.getArgument(frame, 0); + if (self.getSequenceStorage() instanceof NativeSequenceStorage && fieldIdx >= self.getSequenceStorage().length()) { + throw PRaiseNode.raiseStatic(this, NotImplementedError, ErrorMessages.UNSUPPORTED_ACCESS_OF_STRUCT_SEQUENCE_NATIVE_STORAGE); + } return SequenceStorageNodes.GetItemScalarNode.executeUncached(self.getSequenceStorage(), fieldIdx); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequenceBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequenceBuiltins.java new file mode 100644 index 0000000000..2d8477aca7 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/tuple/StructSequenceBuiltins.java @@ -0,0 +1,342 @@ +/* + * Copyright (c) 2025, 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.builtins.objects.tuple; + +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___NEW__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.J___REDUCE__; +import static com.oracle.graal.python.nodes.StringLiterals.T_COMMA_SPACE; +import static com.oracle.graal.python.nodes.StringLiterals.T_EQ; +import static com.oracle.graal.python.nodes.StringLiterals.T_LPAREN; +import static com.oracle.graal.python.nodes.StringLiterals.T_RPAREN; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError; +import static com.oracle.graal.python.util.PythonUtils.EMPTY_TRUFFLESTRING_ARRAY; +import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; + +import java.util.ArrayList; +import java.util.List; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.annotations.Slot; +import com.oracle.graal.python.annotations.Slot.SlotKind; +import com.oracle.graal.python.builtins.Builtin; +import com.oracle.graal.python.builtins.CoreFunctions; +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.PythonBuiltins; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes; +import com.oracle.graal.python.builtins.objects.cext.structs.CFields; +import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; +import com.oracle.graal.python.builtins.objects.dict.PDict; +import com.oracle.graal.python.builtins.objects.object.ObjectNodes; +import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TypeFlags; +import com.oracle.graal.python.builtins.objects.type.TypeNodes; +import com.oracle.graal.python.lib.PyDictGetItem; +import com.oracle.graal.python.lib.PyDictSetItem; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.HiddenAttr; +import com.oracle.graal.python.nodes.PGuards; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; +import com.oracle.graal.python.nodes.builtins.ListNodes; +import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; +import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; +import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; +import com.oracle.graal.python.nodes.object.BuiltinClassProfiles; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.graal.python.runtime.sequence.storage.NativeSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.GenerateCached; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.GenerateNodeFactory; +import com.oracle.truffle.api.dsl.NodeFactory; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleStringBuilder; + +@CoreFunctions(extendClasses = { + PythonBuiltinClassType.PStatResult, + PythonBuiltinClassType.PStatvfsResult, + PythonBuiltinClassType.PTerminalSize, + PythonBuiltinClassType.PUnameResult, + PythonBuiltinClassType.PStructTime, + PythonBuiltinClassType.PProfilerEntry, + PythonBuiltinClassType.PProfilerSubentry, + PythonBuiltinClassType.PStructPasswd, + PythonBuiltinClassType.PStructRusage, + PythonBuiltinClassType.PVersionInfo, + PythonBuiltinClassType.PWindowsVersion, + PythonBuiltinClassType.PFlags, + PythonBuiltinClassType.PFloatInfo, + PythonBuiltinClassType.PIntInfo, + PythonBuiltinClassType.PHashInfo, + PythonBuiltinClassType.PThreadInfo, + PythonBuiltinClassType.PUnraisableHookArgs}) +public final class StructSequenceBuiltins extends PythonBuiltins { + + public static final TpSlots SLOTS = StructSequenceBuiltinsSlotsGen.SLOTS; + + @Override + protected List> getNodeFactories() { + return StructSequenceBuiltinsFactory.getFactories(); + } + + @GenerateInline + @GenerateCached(false) + abstract static class GetSizeNode extends Node { + public abstract int execute(Node inliningTarget, Object type, TruffleString key); + + @Specialization + static int doPBCT(Node inliningTarget, PythonBuiltinClassType type, TruffleString key, + @Shared @Cached("createForceType()") ReadAttributeFromObjectNode read) { + return doGeneric(PythonContext.get(inliningTarget).lookupType(type), key, read); + } + + @Fallback + static int doGeneric(Object type, TruffleString key, + @Shared @Cached("createForceType()") ReadAttributeFromObjectNode read) { + return (int) read.execute(type, key); + } + } + + @GenerateInline + @GenerateCached(false) + abstract static class GetFieldNamesNode extends Node { + public abstract TruffleString[] execute(Node inliningTarget, Object type); + + @Specialization + static TruffleString[] doPBCT(Node inliningTarget, PythonBuiltinClassType type, + @Shared @Cached HiddenAttr.ReadNode readNode) { + return doManaged(inliningTarget, PythonContext.get(inliningTarget).lookupType(type), readNode); + } + + @Specialization + static TruffleString[] doManaged(Node inliningTarget, PythonManagedClass type, + @Shared @Cached HiddenAttr.ReadNode readNode) { + return (TruffleString[]) readNode.execute(inliningTarget, type, HiddenAttr.STRUCTSEQ_FIELD_NAMES, EMPTY_TRUFFLESTRING_ARRAY); + } + + @Specialization + @TruffleBoundary + static TruffleString[] doNative(PythonAbstractNativeObject type) { + CStructAccess.ReadPointerNode read = CStructAccess.ReadPointerNode.getUncached(); + Object membersPtr = read.readFromObj(type, CFields.PyTypeObject__tp_members); + List members = new ArrayList<>(); + InteropLibrary lib = InteropLibrary.getUncached(); + if (!PGuards.isNullOrZero(membersPtr, lib)) { + for (int i = 0;; i++) { + Object memberNamePtr = read.readStructArrayElement(membersPtr, i, CFields.PyMemberDef__name); + if (PGuards.isNullOrZero(memberNamePtr, lib)) { + break; + } + TruffleString name = CExtNodes.FromCharPointerNode.executeUncached(memberNamePtr); + members.add(name); + } + } + return members.toArray(new TruffleString[0]); + } + } + + @Builtin(name = J___NEW__, minNumOfPositionalArgs = 2, parameterNames = {"$cls", "sequence", "dict"}) + @GenerateNodeFactory + public abstract static class NewNode extends PythonTernaryBuiltinNode { + + @Specialization + static PTuple withDict(VirtualFrame frame, Object cls, Object sequence, Object dict, + @Bind("this") Node inliningTarget, + @Bind PythonLanguage language, + @Cached TypeNodes.GetTypeFlagsNode getFlags, + @Cached GetSizeNode getSizeNode, + @Cached GetFieldNamesNode getFieldNamesNode, + @Cached ListNodes.FastConstructListNode fastConstructListNode, + @Cached SequenceStorageNodes.GetItemScalarNode getItem, + @Cached BuiltinClassProfiles.IsBuiltinObjectProfile notASequenceProfile, + @Cached InlinedBranchProfile wrongLenProfile, + @Cached TypeNodes.GetInstanceShape getInstanceShape, + @Cached PyDictGetItem dictGetItem, + @Cached InlinedConditionProfile hasDictProfile, + @Cached PRaiseNode raiseNode) { + // FIXME this should be checked by type.__call__ + if ((getFlags.execute(cls) & TypeFlags.DISALLOW_INSTANTIATION) != 0) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CANNOT_CREATE_INSTANCES, StructSequence.getTpName(cls)); + } + SequenceStorage seq; + try { + seq = fastConstructListNode.execute(frame, inliningTarget, sequence).getSequenceStorage(); + } catch (PException e) { + e.expect(inliningTarget, TypeError, notASequenceProfile); + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.CONSTRUCTOR_REQUIRES_A_SEQUENCE); + } + + boolean hasDict = hasDictProfile.profile(inliningTarget, dict instanceof PDict); + if (!hasDict && dict != PNone.NO_VALUE) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_A_DICT_AS_SECOND_ARG_IF_ANY, StructSequence.getTpName(cls)); + } + + int len = seq.length(); + int minLen = getSizeNode.execute(inliningTarget, cls, StructSequence.T_N_SEQUENCE_FIELDS); + int maxLen = getSizeNode.execute(inliningTarget, cls, StructSequence.T_N_FIELDS); + int unnamedFields = getSizeNode.execute(inliningTarget, cls, StructSequence.T_N_UNNAMED_FIELDS); + + if (len < minLen || len > maxLen) { + wrongLenProfile.enter(inliningTarget); + if (minLen == maxLen) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_A_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); + } + if (len < minLen) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_LEAST_D_SEQUENCE, StructSequence.getTpName(cls), minLen, len); + } else { // len > maxLen + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TAKES_AN_AT_MOST_D_SEQUENCE, StructSequence.getTpName(cls), maxLen, len); + } + } + + Object[] dst = new Object[maxLen]; + for (int i = 0; i < seq.length(); i++) { + dst[i] = getItem.execute(inliningTarget, seq, i); + } + TruffleString[] fieldNames = hasDict ? getFieldNamesNode.execute(inliningTarget, cls) : null; + for (int i = seq.length(); i < dst.length; ++i) { + if (hasDict) { + Object o = dictGetItem.execute(frame, inliningTarget, (PDict) dict, fieldNames[i - unnamedFields]); + dst[i] = o == null ? PNone.NONE : o; + } else { + dst[i] = PNone.NONE; + } + } + return PFactory.createTuple(language, cls, getInstanceShape.execute(cls), new ObjectSequenceStorage(dst, minLen)); + } + } + + @Slot(value = SlotKind.tp_repr, isComplex = true) + @GenerateNodeFactory + abstract static class ReprNode extends PythonUnaryBuiltinNode { + + @Specialization + static TruffleString repr(VirtualFrame frame, PTuple self, + @Bind("this") Node inliningTarget, + @Cached GetClassNode getClassNode, + @Cached GetFieldNamesNode getFieldNamesNode, + @Cached ObjectNodes.GetFullyQualifiedNameNode getQName, + @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Cached PyObjectReprAsTruffleStringNode reprNode, + @Cached TruffleStringBuilder.AppendStringNode appendStringNode, + @Cached TruffleStringBuilder.ToStringNode toStringNode) { + Object type = getClassNode.execute(inliningTarget, self); + TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING); + appendStringNode.execute(sb, getQName.execute(frame, type)); + appendStringNode.execute(sb, T_LPAREN); + SequenceStorage tupleStore = self.getSequenceStorage(); + int visibleSize = tupleStore.length(); + TruffleString[] fieldNames = getFieldNamesNode.execute(inliningTarget, type); + if (visibleSize > 0) { + appendStringNode.execute(sb, fieldNames[0]); + appendStringNode.execute(sb, T_EQ); + appendStringNode.execute(sb, reprNode.execute(frame, inliningTarget, getItemNode.execute(inliningTarget, tupleStore, 0))); + for (int i = 1; i < visibleSize; i++) { + appendStringNode.execute(sb, T_COMMA_SPACE); + appendStringNode.execute(sb, fieldNames[i]); + appendStringNode.execute(sb, T_EQ); + appendStringNode.execute(sb, reprNode.execute(frame, inliningTarget, getItemNode.execute(inliningTarget, tupleStore, i))); + } + } + appendStringNode.execute(sb, T_RPAREN); + return toStringNode.execute(sb); + } + } + + @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1) + @GenerateNodeFactory + abstract static class ReduceNode extends PythonUnaryBuiltinNode { + + @Specialization + static PTuple reduce(PTuple self, + @Bind("this") Node inliningTarget, + @Cached GetClassNode getClass, + @Cached GetSizeNode getSizeNode, + @Cached GetFieldNamesNode getFieldNamesNode, + @Cached SequenceStorageNodes.GetItemScalarNode getSeqItem, + @Cached SequenceStorageNodes.GetItemSliceNode getSeqSlice, + @Cached PyDictSetItem dictSetItem, + @Cached PRaiseNode raiseNode, + @Bind PythonLanguage language) { + SequenceStorage storage = self.getSequenceStorage(); + Object type = getClass.execute(inliningTarget, self); + int nFields = getSizeNode.execute(inliningTarget, type, StructSequence.T_N_FIELDS); + int nVisibleFields = storage.length(); + int nUnnamedFields = getSizeNode.execute(inliningTarget, type, StructSequence.T_N_UNNAMED_FIELDS); + PTuple tuple = PFactory.createTuple(language, getSeqSlice.execute(storage, 0, nVisibleFields, 1, nVisibleFields)); + PDict dict = PFactory.createDict(language); + if (nFields > nVisibleFields) { + if (storage instanceof NativeSequenceStorage) { + // TODO Native storage conversion wouldn't preserve the items past length + throw raiseNode.raise(inliningTarget, NotImplementedError, ErrorMessages.UNSUPPORTED_ACCESS_OF_STRUCT_SEQUENCE_NATIVE_STORAGE); + } + assert storage.getCapacity() >= nFields; + TruffleString[] fieldNames = getFieldNamesNode.execute(inliningTarget, type); + for (int i = nVisibleFields; i < nFields; i++) { + TruffleString n = fieldNames[i - nUnnamedFields]; + // We're reading past length, GetItemScalarNode doesn't do a bounds check + dictSetItem.execute(inliningTarget, dict, n, getSeqItem.execute(inliningTarget, storage, i)); + } + } + return PFactory.createTuple(language, new Object[]{type, PFactory.createTuple(language, new Object[]{tuple, dict})}); + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java index 4e0ceade6e..760e28475e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java @@ -710,6 +710,7 @@ public abstract class ErrorMessages { public static final TruffleString TAKES_A_D_SEQUENCE = tsLiteral("%s() takes a %d-sequence (%d-sequence given)"); public static final TruffleString TAKES_AN_AT_LEAST_D_SEQUENCE = tsLiteral("%s() takes an at least %d-sequence (%d-sequence given)"); public static final TruffleString TAKES_AN_AT_MOST_D_SEQUENCE = tsLiteral("%s() takes an at most %d-sequence (%d-sequence given)"); + public static final TruffleString UNSUPPORTED_ACCESS_OF_STRUCT_SEQUENCE_NATIVE_STORAGE = tsLiteral("Unsupported access of struct sequence native storage"); public static final TruffleString TAKES_D_OR_D_ARGS = tsLiteral("%s takes %d or %d arguments"); public static final TruffleString TAKES_D_POS_ARG_S_BUT_D_POS_ARG_S = tsLiteral("%s() takes %d positional argument%s but %d positional argument%s (and %d keyword-only argument%s) were given%s"); public static final TruffleString TAKES_D_POS_ARG_S_BUT_GIVEN_S = tsLiteral("%s() takes %d positional argument%s but %d %s given%s"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/HiddenAttr.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/HiddenAttr.java index 25e70a06da..4ef97fabd1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/HiddenAttr.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/HiddenAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, 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 @@ -105,6 +105,7 @@ public final class HiddenAttr { public static final HiddenAttr NATIVE_STORAGE = new HiddenAttr("native_storage"); public static final HiddenAttr NATIVE_SLOTS = new HiddenAttr("__native_slots__"); public static final HiddenAttr INSTANCESHAPE = new HiddenAttr("instanceshape"); + public static final HiddenAttr STRUCTSEQ_FIELD_NAMES = new HiddenAttr("struct_seq_field_names"); private final HiddenKey key; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java index bb5d974679..c6d5c8ec91 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java @@ -64,7 +64,6 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ArrayBasedSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.EmptySequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.ForeignSequenceStorage; @@ -240,15 +239,15 @@ public static ConstructListNode getUncached() { @GenerateCached(false) public abstract static class FastConstructListNode extends PNodeWithContext { - public abstract PSequence execute(Frame frame, Node inliningTarget, Object value); + public abstract PList execute(Frame frame, Node inliningTarget, Object value); @Specialization(guards = "isBuiltinList(value)") - protected static PSequence doPList(PSequence value) { + protected static PList doPList(PList value) { return value; } @Fallback - protected PSequence doGeneric(VirtualFrame frame, Object value, + protected PList doGeneric(VirtualFrame frame, Object value, @Cached(inline = false) ConstructListNode constructListNode) { return constructListNode.execute(frame, value); } From dad0d7b4e543804b226819354e6d1993ba40fc51 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Mar 2025 15:48:17 +0100 Subject: [PATCH 157/512] Remove PBCT.redefinesSlot --- .../builtins/PythonBuiltinClassType.java | 46 ------------------- .../objects/type/SpecialMethodSlot.java | 6 +-- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java index 001c1d61e2..b904248dab 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java @@ -680,11 +680,6 @@ private static class Flags { @CompilationFinal private PythonBuiltinClassType base; @CompilationFinal private int weaklistoffset; - /** - * @see #redefinesSlot(SpecialMethodSlot) - */ - private SpecialMethodSlot[] redefinedSlots; - /** * Lookup cache for special slots defined in {@link SpecialMethodSlot}. Use * {@link SpecialMethodSlot} to access the values. Unlike the cache in @@ -857,25 +852,6 @@ public int getWeaklistoffset() { return weaklistoffset; } - /** - * Returns {@code true} if this method slot is redefined in Python code during initialization. - * Values of such slots cannot be cached in {@link #specialMethodSlots}, because they are not - * context independent. - */ - public boolean redefinesSlot(SpecialMethodSlot slot) { - if (redefinedSlots != null) { - for (SpecialMethodSlot redefSlot : redefinedSlots) { - if (redefSlot == slot) { - return true; - } - } - } - if (base != null) { - return base.redefinesSlot(slot); - } - return false; - } - @Override public String toString() { CompilerAsserts.neverPartOfCompilation(); @@ -889,29 +865,7 @@ public final Shape getInstanceShape(PythonLanguage lang) { @CompilationFinal(dimensions = 1) public static final PythonBuiltinClassType[] VALUES = Arrays.copyOf(values(), values().length - 1); static { - // fill the overridden slots - SpecialMethodSlot[] newSlot = new SpecialMethodSlot[]{SpecialMethodSlot.New}; - - PStructUnpackIterator.redefinedSlots = new SpecialMethodSlot[]{SpecialMethodSlot.LengthHint}; - - // These slots actually contain context independent values, but they are initialized in - // StructSequence to artificial PBuiltinFunctions with artificial builtin node factories, - // which are different for each context. We'd have to turn those factories into singletons - // to guarantee their identity across contexts. For the sake of simplicity, we just ignore - // those slots for now. PStruct.type = PythonClass; - PStructRusage.redefinedSlots = newSlot; - PStructPasswd.redefinedSlots = newSlot; - PUnameResult.redefinedSlots = newSlot; - PUnraisableHookArgs.redefinedSlots = newSlot; - PIntInfo.redefinedSlots = newSlot; - PHashInfo.redefinedSlots = newSlot; - PStructTime.redefinedSlots = newSlot; - PProfilerEntry.redefinedSlots = newSlot; - PProfilerSubentry.redefinedSlots = newSlot; - PThreadInfo.redefinedSlots = newSlot; - PFloatInfo.redefinedSlots = newSlot; - PTerminalSize.redefinedSlots = newSlot; PythonObject.type = PythonClass; PythonObject.base = null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java index e0a5388d4a..edeb5d7f2d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/SpecialMethodSlot.java @@ -340,9 +340,6 @@ private static void initializeBuiltinTypeSlotsImpl(Python3Core core) { Object[] typeSlots = new Object[VALUES.length]; PythonBuiltinClass klass = core.lookupType(type); for (SpecialMethodSlot slot : VALUES) { - if (type.redefinesSlot(slot)) { - continue; - } Object value = slot.getValue(klass); if (value instanceof PBuiltinFunction && slot.allowsBuiltinDescriptors) { BuiltinMethodDescriptor info = BuiltinMethodDescriptor.get((PBuiltinFunction) value); @@ -900,8 +897,7 @@ private static boolean checkFind() { // debugging /** - * Checks that there were no builtins' slots overridden except those explicitly marked so by - * {@link PythonBuiltinClassType#redefinesSlot}. + * Checks that there were no builtins' slots overridden. */ public static boolean checkSlotOverrides(Python3Core core) { assert builtinSlotsInitialized; From 14d0ae749c7fd6611ed74fec041b7a099a23822f Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Mar 2025 16:44:33 +0100 Subject: [PATCH 158/512] Fix SVM build --- .../builtins/objects/foreign/ForeignObjectBuiltins.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java index c71db8d500..6855127a32 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/ForeignObjectBuiltins.java @@ -53,6 +53,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode; import com.oracle.graal.python.builtins.objects.type.TypeBuiltins; +import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSetAttr.SetAttrBuiltinNode; import com.oracle.graal.python.lib.PyObjectReprAsObjectNode; @@ -328,6 +329,8 @@ protected Object doIt(VirtualFrame frame, Object object, abstract static class StrNode extends PythonUnaryBuiltinNode { @Child private TruffleString.SwitchEncodingNode switchEncodingNode; + private static final TpSlot FOREIGN_REPR = SLOTS.tp_repr(); + @Specialization Object str(VirtualFrame frame, Object object, @Bind("this") Node inliningTarget, @@ -340,7 +343,7 @@ Object str(VirtualFrame frame, Object object, // Check if __repr__ is defined before foreign, if so call that, like object.__str__ // would do TpSlots slots = getSlots.execute(inliningTarget, object); - if (slots.tp_repr() != SLOTS.tp_repr()) { + if (slots.tp_repr() != FOREIGN_REPR) { return reprNode.execute(frame, inliningTarget, object); } From fb13c36086673ea025c970e9374c1d7824f25b7b Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 14 Mar 2025 18:14:27 +0100 Subject: [PATCH 159/512] Add missing module.__repr__ --- .../graal/python/builtins/Python3Core.java | 6 ------ .../builtins/objects/module/ModuleBuiltins.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index ab19dff91e..92122b3776 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -37,7 +37,6 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T___BUILTINS__; import static com.oracle.graal.python.nodes.BuiltinNames.T___IMPORT__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___PACKAGE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; import static com.oracle.graal.python.nodes.StringLiterals.J_PY_EXTENSION; import static com.oracle.graal.python.nodes.StringLiterals.T_DOT; import static com.oracle.graal.python.nodes.StringLiterals.T_GRAALPYTHON; @@ -965,11 +964,6 @@ private void initializeImportlib() { importFunc = (PFunction) __import__; importlib = bootstrap; - PythonBuiltinClass moduleType = lookupType(PythonBuiltinClassType.PythonModule); - writeNode.execute(moduleType, T___REPR__, readNode.execute(bootstrap, toTruffleStringUncached("_module_repr"))); - - SpecialMethodSlot.reinitializeSpecialMethodSlots(moduleType, getLanguage()); - // see CPython's init_importlib_external callNode.execute(null, null, bootstrap, toTruffleStringUncached("_install_external_importers")); if (!PythonImageBuildOptions.WITHOUT_COMPRESSION_LIBRARIES) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java index afb659abcf..83ed0fa5df 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/ModuleBuiltins.java @@ -77,6 +77,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotGetAttr.GetAttrBuiltinNode; import com.oracle.graal.python.lib.PyDictGetItem; +import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; import com.oracle.graal.python.lib.PyObjectIsTrueNode; import com.oracle.graal.python.lib.PyObjectLookupAttr; import com.oracle.graal.python.nodes.ErrorMessages; @@ -97,6 +98,7 @@ import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; +import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; @@ -346,4 +348,19 @@ static Object set(Object self, Object value, return PNone.NONE; } } + + @Slot(value = SlotKind.tp_repr, isComplex = true) + @GenerateNodeFactory + abstract static class ReprNode extends PythonUnaryBuiltinNode { + + public static final TruffleString T__MODULE_REPR = tsLiteral("_module_repr"); + + @Specialization + Object repr(VirtualFrame frame, Object self, + @Bind Node inliningTarget, + @Bind PythonContext context, + @Cached PyObjectCallMethodObjArgs callMethod) { + return callMethod.execute(frame, inliningTarget, context.getImportlib(), T__MODULE_REPR, self); + } + } } From f461dd3844a57d59647c19f03056d645495abed2 Mon Sep 17 00:00:00 2001 From: Mohaned Qunaibit Date: Tue, 18 Mar 2025 15:42:43 +0300 Subject: [PATCH 160/512] Update imports --- ci.jsonnet | 2 +- mx.graalpython/suite.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci.jsonnet b/ci.jsonnet index 71c43b2cf5..40703fed35 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "f5f1fdc315441dcb664bed5e190f54be0e4dc78e" } +{ "overlay": "4832d2526e48416dc03d1ecc9b56986dc00f6d57" } diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py index f433e2646e..732907a422 100644 --- a/mx.graalpython/suite.py +++ b/mx.graalpython/suite.py @@ -45,7 +45,7 @@ }, { "name": "sdk", - "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", + "version": "0465567966e7f571243e34b5d0f263ed2fcfde9f", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -53,7 +53,7 @@ }, { "name": "tools", - "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", + "version": "0465567966e7f571243e34b5d0f263ed2fcfde9f", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -61,7 +61,7 @@ }, { "name": "sulong", - "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", + "version": "0465567966e7f571243e34b5d0f263ed2fcfde9f", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -69,7 +69,7 @@ }, { "name": "regex", - "version": "47ed7d96ed1e3e96c3d474880f8213a98ac23bfa", + "version": "0465567966e7f571243e34b5d0f263ed2fcfde9f", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, From 57ba9e004b715b4ba88d2f2a3d042361b731864b Mon Sep 17 00:00:00 2001 From: Mohaned Qunaibit Date: Tue, 18 Mar 2025 16:04:38 +0300 Subject: [PATCH 161/512] Update unittests tags --- .../src/tests/unittest_tags/test_argparse.txt | 2 +- .../src/tests/unittest_tags/test_asyncio.txt | 1 + .../src/tests/unittest_tags/test_io.txt | 1 + .../tests/unittest_tags/test_itertools.txt | 2 +- .../src/tests/unittest_tags/test_os.txt | 1 + .../src/tests/unittest_tags/test_tarfile.txt | 441 +++++++++--------- 6 files changed, 225 insertions(+), 223 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt index 1b45bf37aa..0232204709 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt @@ -1,4 +1,4 @@ -test.test_argparse.StdStreamTest.test_skip_invalid_stderr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_argparse.StdStreamTest.test_skip_invalid_stderr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_argparse.StdStreamTest.test_skip_invalid_stdout @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_argparse.TestActionExtend.test_failures_many_groups_listargs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_argparse.TestActionExtend.test_failures_many_groups_sysargs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt index 8e13e546d0..be43c5a205 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncio.txt @@ -747,6 +747,7 @@ test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_devnull_ou test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_devstdin_input @ linux-aarch64,linux-x86_64 test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_empty_input @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_kill @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_kill_issue43884 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_pause_reading @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_popen_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncio.test_subprocess.SubprocessThreadedWatcherTests.test_popen_error_with_stdin_pipe @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_io.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_io.txt index ecac6a8999..eedbeab220 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_io.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_io.txt @@ -196,6 +196,7 @@ test.test_io.CMiscIOTest.test_check_encoding_warning @ darwin-arm64,darwin-x86_6 test.test_io.CMiscIOTest.test_create_fail @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_io.CMiscIOTest.test_create_writes @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stderr_deadlock @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stdout_deadlock @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_io.CMiscIOTest.test_io_after_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_io.CMiscIOTest.test_nonblock_pipe_write_bigbuf @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_io.CMiscIOTest.test_nonblock_pipe_write_smallbuf @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt index 7022a17f05..f92ed2f9e1 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_itertools.txt @@ -31,7 +31,7 @@ test.test_itertools.TestBasicOps.test_islice @ darwin-arm64,darwin-x86_64,linux- test.test_itertools.TestBasicOps.test_map @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_pairwise @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_pairwise_reenter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_itertools.TestBasicOps.test_pairwise_reenter2 @ darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_itertools.TestBasicOps.test_pairwise_reenter2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_permutations @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_product @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_itertools.TestBasicOps.test_product_issue_25021 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_os.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_os.txt index a2f4799b47..0a73dbb177 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_os.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_os.txt @@ -60,6 +60,7 @@ test.test_os.FDInheritanceTests.test_dup2 @ darwin-arm64,darwin-x86_64,linux-aar test.test_os.FDInheritanceTests.test_dup_nul @ win32-AMD64 test.test_os.FDInheritanceTests.test_dup_standard_stream @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_os.FDInheritanceTests.test_get_set_inheritable @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_os.FDInheritanceTests.test_get_set_inheritable_badf @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_os.FDInheritanceTests.test_get_set_inheritable_o_path @ linux-aarch64,linux-x86_64 test.test_os.FDInheritanceTests.test_open @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_os.FDInheritanceTests.test_openpty @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt index be7f184483..ccb59a6b7f 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt @@ -274,283 +274,282 @@ test.test_tarfile.LzmaCreateTest.test_create_pathlike_name @ darwin-arm64,darwin test.test_tarfile.LzmaCreateTest.test_create_taropen @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaCreateTest.test_create_taropen_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaCreateTest.test_create_with_preset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaStreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaStreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaUstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_tar_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.MiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.MiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.MiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.MiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.MiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NoneInfoTests_Misc.test_add @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NumericOwnerTest.test_extract_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NumericOwnerTest.test_extractall_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NumericOwnerTest.test_keyword_only @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.PaxReadTest.test_longname_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.StreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.StreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.StreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_absolute_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_bad_filter_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_chains @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_deep_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_default_filter_warns_not @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_errorlevel @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.TestExtractionFilters.test_modes @ win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_parent_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_parent_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_pipe @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_sly_relative0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_sly_relative2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_stateful_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.UstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.UstarUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.UstarUnicodeTest.test_unicode_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.UstarUnicodeTest.test_unicode_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 From 090840330ca7386e67d1fc852701fc27bba5cb42 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 18 Mar 2025 19:47:56 +0100 Subject: [PATCH 162/512] Update GraalPy website to 24.2 --- docs/site/_config.yml | 2 +- docs/user/Interoperability.md | 2 +- docs/user/Python-Runtime.md | 18 +++++++++--------- docs/user/README.md | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/site/_config.yml b/docs/site/_config.yml index 4353b0f045..645b2f75c2 100644 --- a/docs/site/_config.yml +++ b/docs/site/_config.yml @@ -1,7 +1,7 @@ baseurl: "/python" url: "https://graalvm.org/" github: "oracle/graalpython" -language_version: 24.1.2 +language_version: 24.2.0 name: GraalPy permalink: pretty diff --git a/docs/user/Interoperability.md b/docs/user/Interoperability.md index 0978ac62c4..5dec91c72b 100644 --- a/docs/user/Interoperability.md +++ b/docs/user/Interoperability.md @@ -112,7 +112,7 @@ For example, if you have already configured a Maven project with GraalPy, add th org.graalvm.polyglot js - 24.1.0 + 24.2.0 ``` diff --git a/docs/user/Python-Runtime.md b/docs/user/Python-Runtime.md index d2bc5e4155..2415adcb7f 100644 --- a/docs/user/Python-Runtime.md +++ b/docs/user/Python-Runtime.md @@ -69,12 +69,12 @@ The four GraalPy runtimes are identified as follows, using the general pattern _ ### Linux The easiest way to install GraalPy on Linux is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager). -To install version 24.1.0 using Pyenv, run the following commands: +To install version 24.2.0 using Pyenv, run the following commands: ```bash -pyenv install graalpy-24.1.0 +pyenv install graalpy-24.2.0 ``` ```bash -pyenv shell graalpy-24.1.0 +pyenv shell graalpy-24.2.0 ``` > Before running `pyenv install`, you may need to update `pyenv` to include the latest GraalPy versions. @@ -86,12 +86,12 @@ Alternatively, you can download a compressed GraalPy installation file from [Git ### macOS The easiest way to install GraalPy on macOS is to use [Pyenv](https://github.com/pyenv/pyenv) (the Python version manager). -To install version 24.1.0 using Pyenv, run the following commands: +To install version 24.2.0 using Pyenv, run the following commands: ```bash -pyenv install graalpy-24.1.0 +pyenv install graalpy-24.2.0 ``` ```bash -pyenv shell graalpy-24.1.0 +pyenv shell graalpy-24.2.0 ``` > Before running `pyenv install`, you may need to update `pyenv` to include the latest GraalPy versions. @@ -104,7 +104,7 @@ Alternatively, you can download a compressed GraalPy installation file from [Git ``` For example: ```bash - sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.1.0 + sudo xattr -r -d com.apple.quarantine ~/.pyenv/versions/graalpy-24.2.0 ``` 3. Uncompress the file and update your `PATH` environment variable to include to the _graalpy-XX.Y.Z-macos-amd64/bin_ (or _graalpy-XX.Y.Z-macos-aarch64/bin_) directory. @@ -139,7 +139,7 @@ This generates wrapper scripts and makes the implementation usable from a shell ``` For example: ```bash - graalpy -m venv ~/.virtualenvs/graalpy-24.1.0 + graalpy -m venv ~/.virtualenvs/graalpy-24.2.0 ``` 2. Activate the environment in your shell session: @@ -148,7 +148,7 @@ This generates wrapper scripts and makes the implementation usable from a shell ``` For example: ```bash - source ~/.virtualenvs/graalpy-24.1.0/bin/activate + source ~/.virtualenvs/graalpy-24.2.0/bin/activate ``` Multiple executables are available in the virtual environment, including: `python`, `python3`, and `graalpy`. diff --git a/docs/user/README.md b/docs/user/README.md index 40418571ed..43886c14b4 100644 --- a/docs/user/README.md +++ b/docs/user/README.md @@ -13,7 +13,7 @@ GraalPy can generate a Maven project that embeds Python packages into a Java app mvn archetype:generate \ -DarchetypeGroupId=org.graalvm.python \ -DarchetypeArtifactId=graalpy-archetype-polyglot-app \ - -DarchetypeVersion=24.1.0 + -DarchetypeVersion=24.2.0 ``` 2. Build a native executable using the [GraalVM Native Image "tool"](https://www.graalvm.org/latest/reference-manual/native-image/) plugin that was added for you automatically: @@ -79,8 +79,8 @@ In order to distribute the resulting application for other systems, follow these 2. Open your project configuration file, _app/build.gradle_, and modify it as follows. - Include the GraalPy support and the [GraalVM Polyglot API](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/package-summary.html) in the `dependencies` section: ```bash - implementation("org.graalvm.polyglot:polyglot:24.1.2") - implementation("org.graalvm.polyglot:python:24.1.2") + implementation("org.graalvm.polyglot:polyglot:24.2.0") + implementation("org.graalvm.polyglot:python:24.2.0") ``` 3. Finally, replace the code in the file named _App.java_ as follows for a small Python embedding: @@ -111,7 +111,7 @@ In order to distribute the resulting application for other systems, follow these 5.1. In _app/build.gradle_: - add the graalpy-gradle-plugin to the `plugins` section: ```bash - id "org.graalvm.python" version "24.1.2" + id "org.graalvm.python" version "24.2.0" ``` - configure the GraalPy Gradle plugin: @@ -175,13 +175,13 @@ GraalPy comes with a tool to obtain the required JAR files from Maven. In a POSIX shell: ```bash export GRAALPY_HOME=$(graalpy -c 'print(__graalpython__.home)') - "${GRAALPY_HOME}/libexec/graalpy-polyglot-get" -a python -o lib -v "24.1.0" + "${GRAALPY_HOME}/libexec/graalpy-polyglot-get" -a python -o lib -v "24.2.0" ``` In PowerShell: ```bash $GRAALPY_HOME = graalpy -c "print(__graalpython__.home)" - & "$GRAALPY_HOME/libexec/graalpy-polyglot-get" -a python -o lib -v "24.1.0" + & "$GRAALPY_HOME/libexec/graalpy-polyglot-get" -a python -o lib -v "24.2.0" ``` These commands download all GraalPy dependencies into the _lib_ directory. From c0c9c64b341896ddb217b84dcd7e56fd900e1a57 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 18 Mar 2025 15:12:53 +0100 Subject: [PATCH 163/512] Update wheel index for 24.2 --- docs/site/_plugins/graalpy_wheels.txt | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/site/_plugins/graalpy_wheels.txt b/docs/site/_plugins/graalpy_wheels.txt index 3cd710c97d..8136d81c2e 100644 --- a/docs/site/_plugins/graalpy_wheels.txt +++ b/docs/site/_plugins/graalpy_wheels.txt @@ -1,5 +1,6 @@ # This file is processed by _plugins/wheel_repo_plugin.rb # Each line is a wheel filename. Comments and empty lines are ignored +# GraalPy 24.1: contourpy-1.2.1-graalpy311-graalpy241_311_native-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl httptools-0.6.1-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl httptools-0.6.1-graalpy311-graalpy241_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl @@ -24,3 +25,30 @@ watchfiles-0.21.0-graalpy311-graalpy241_311_native-manylinux_2_28_x86_64.whl xxhash-3.4.1-graalpy311-graalpy241_311_native-macosx_11_0_arm64.whl xxhash-3.4.1-graalpy311-graalpy241_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl xxhash-3.4.1-graalpy311-graalpy241_311_native-win_amd64.whl + +# GraalPy 24.2 +contourpy-1.2.1-graalpy311-graalpy242_311_native-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +httptools-0.6.1-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +httptools-0.6.1-graalpy311-graalpy242_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl +httptools-0.6.1-graalpy311-graalpy242_311_native-win_amd64.whl +jiter-0.5.0-graalpy311-graalpy242_311_native-manylinux_2_28_x86_64.whl +kiwisolver-1.4.5-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +kiwisolver-1.4.5-graalpy311-graalpy242_311_native-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl +kiwisolver-1.4.5-graalpy311-graalpy242_311_native-win_amd64.whl +numpy-1.26.4-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +numpy-1.26.4-graalpy311-graalpy242_311_native-manylinux_2_28_x86_64.whl +numpy-1.26.4-graalpy311-graalpy242_311_native-win_amd64.whl +oracledb-3.0.0-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +polyleven-0.8-graalpy311-graalpy242_311_native-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl +psutil-5.9.8-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +psutil-5.9.8-graalpy311-graalpy242_311_native-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl +psutil-5.9.8-graalpy311-graalpy242_311_native-win_amd64.whl +pydantic_core-2.10.1-graalpy311-graalpy242_311_native-manylinux_2_28_x86_64.whl +ujson-5.10.0-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +ujson-5.10.0-graalpy311-graalpy242_311_native-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl +ujson-5.10.0-graalpy311-graalpy242_311_native-win_amd64.whl +uvloop-0.19.0-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +watchfiles-0.21.0-graalpy311-graalpy242_311_native-manylinux_2_28_x86_64.whl +xxhash-3.4.1-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl +xxhash-3.4.1-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl +xxhash-3.4.1-graalpy311-graalpy242_311_native-win_amd64.whl From cf7b3397d23c6d046899043cb5c56c0c9ca63d20 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 18 Mar 2025 15:25:39 +0100 Subject: [PATCH 164/512] Add module testing data for 24.2 --- docs/site/03-compatibility.md | 8 +- docs/site/_plugins/wheel_repo_plugin.rb | 2 +- .../python-module-testing-v242.csv | 615 ++++++++++++++++++ 3 files changed, 621 insertions(+), 4 deletions(-) create mode 100644 docs/site/module_results/python-module-testing-v242.csv diff --git a/docs/site/03-compatibility.md b/docs/site/03-compatibility.md index 03d5b6f8f1..8d3f1b86be 100644 --- a/docs/site/03-compatibility.md +++ b/docs/site/03-compatibility.md @@ -5,6 +5,7 @@ permalink: compatibility/ --- - - - {scripts} - - -''' - - -def save_as_html(report_name, rows, totals, missing_modules, cannot_import_modules, java_issues, current_date): - def grid(*components): - def _fmt(cmp): - if isinstance(cmp, tuple): - return '
    {}
    '.format(cmp[1], cmp[0]) - return '
    {}
    '.format(cmp) - return ''' -
    -
    - {} -
    -
    - '''.format('\n'.join([_fmt(cmp) for cmp in components])) - - def progress_bar(value, color='success'): - return ''' -
    -
    - {value:.2f}% Complete -
    -
    - '''.format(color=color, value=value) - - def fluid_div(title, div_content): - return ''' -
    -
    -
    -

    {title}

    -
    - {content} -
    -
    - '''.format(title=title, content=div_content) - - def ul(title, items): - return fluid_div(title, '
      {}
    '.format('\n'.join([ - '
  • {}
  • '.format(itm) for itm in items - ]))) - - def table(tid, tcols, trows): - _thead = ''' - -   - {columns} - - '''.format(columns='\n'.join(['{}'.format(c) for c in tcols])) - - def format_val(row, k): - value = row[k] - if k == Col.PYTHON_ERRORS: - return "(click to expand)" - elif k == Col.UNITTEST: - _class = "text-info" - elif k == Col.NUM_PASSES and value > 0: - _class = "text-success" - elif k in [Col.NUM_ERRORS, Col.NUM_FAILS] and value > 0: - _class = "text-danger" - elif k == Col.NUM_SKIPPED and value > 0: - _class = "text-warning" - elif k == Col.NUM_TESTS: - _class = "text-dark" - else: - _class = "text-danger" if value and value < 0 else "text-muted" - return '{}'.format(_class, value) - - _tbody = '\n'.join([ - '{i}{vals}'.format( - errors = html.escape(row[Col.PYTHON_ERRORS], quote=True), # put the errors data into a data attribute - cls='info' if i % 2 == 0 else '', i=i, - vals=' '.join(['{}'.format(format_val(row, k)) for k in tcols])) - for i, row in enumerate(trows)]) - - _table = ''' - - {thead}{tbody} -
    - '''.format(tid=tid, tclass='', thead=_thead, tbody=_tbody) - - return fluid_div('cPython unittests run statistics', _table) - - scripts = ''' - - - - ''' - - missing_modules_info = ul('missing modules', [ - '{} imported by {} unittests'.format(name, cnt) - for cnt, name in sorted(((cnt, name) for name, cnt in missing_modules.items()), reverse=True) - ]) - - cannot_import_modules_info = ul('modules which could not be imported', [ - '{} could not be imported by {} unittests'.format(name, cnt) - for cnt, name in sorted(((cnt, name) for name, cnt in cannot_import_modules.items()), reverse=True) - ]) - - java_issues_info = ul('Java issues', [ - '{} caused by {} unittests'.format(name, cnt) - for cnt, name in sorted(((cnt, name) for name, cnt in java_issues.items()), reverse=True) - ]) - - modules_dnf = ul('Unittests that did not finish', [ - '{}'.format(r[Col.UNITTEST]) - for r in rows if r[Col.NUM_ERRORS] == -1 - ]) - - usecase_scores = dict() - for usecase_name, usecase_modules in USE_CASE_GROUPS.items(): - score_sum = 0 - for m in usecase_modules: - for r in rows: - if ("test_" + m + ".py") == r[Col.UNITTEST]: - if r[Col.NUM_PASSES] > 0 and r[Col.NUM_TESTS] > 0: - score_sum += r[Col.NUM_PASSES] / r[Col.NUM_TESTS] - usecase_scores[usecase_name] = score_sum / len(usecase_modules) - - - use_case_stats_info = ul("Summary per Use Case", - [ grid((progress_bar(avg_score * 100, color="info"), 3), '{}'.format(usecase_name)) + - grid(", ".join(USE_CASE_GROUPS[usecase_name])) for usecase_name, avg_score in usecase_scores.items()]) - - total_stats_info = ul("Summary", [ - grid('# total unittests: {}'.format(totals[Stat.UT_TOTAL])), - grid((progress_bar(totals[Stat.UT_PERCENT_RUNS], color="info"), 3), - '# unittest which run: {}'.format(totals[Stat.UT_RUNS])), - grid((progress_bar(totals[Stat.UT_PERCENT_PASS], color="success"), 3), - '# unittest which pass: {}'.format(totals[Stat.UT_PASS])), - grid('# tests which run: {}'.format(totals[Stat.TEST_RUNS])), - grid((progress_bar(totals[Stat.TEST_PERCENT_PASS], color="info"), 3), - '# tests which pass: {}'.format(totals[Stat.TEST_PASS])), - ]) - - table_stats = table('stats', CSV_HEADER, rows) - - content = '
    '.join([use_case_stats_info, - total_stats_info, - table_stats, - missing_modules_info, - cannot_import_modules_info, - java_issues_info, - modules_dnf]) - - report = HTML_TEMPLATE.format( - title='GraalPython Unittests Stats', - bootstrap_version='3.3.7', - bootstrap_css_integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u', - bootstrap_theme_css_integrity='sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp', - bootstrap_js_integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa', - fontawesome_version='4.7.0', - jquery_version='3.2.1', - datatables_version='1.10.15', - navbar_links='', - scripts=scripts.format(table_id='stats', datatables_version='1.10.15'), - content=content, - current_date_time=current_date) - - with open(report_name, 'w') as HTML: - HTML.write(report) - -def generate_latest(output_name, html_report_path): - contents = ''' - - - - -''' - with open(output_name, 'w') as HTML: - HTML.write(contents) - -# ---------------------------------------------------------------------------------------------------------------------- -# -# main tool -# -# ---------------------------------------------------------------------------------------------------------------------- -def main(prog, args): - parser = argparse.ArgumentParser(prog=prog, - description="Run the standard python unittests.") - parser.add_argument("-v", "--verbose", help="Verbose output.", action="http://github.com/store_true") - parser.add_argument("-n", "--no_cpython", help="Do not run the tests with cpython (for comparison).", - action="http://github.com/store_true") - parser.add_argument("-l", "--limit", help="Limit the number of unittests to run.", default=None, type=int) - parser.add_argument("-t", "--tests_path", help="Unittests path.", default=PATH_UNITTESTS) - parser.add_argument("-T", "--timeout", help="Timeout per unittest run (seconds).", default=TIMEOUT, type=int) - parser.add_argument("-o", "--only_tests", help="Run only these unittests (comma sep values).", default=None) - parser.add_argument("-s", "--skip_tests", help="Run all unittests except (comma sep values)." - "the only_tets option takes precedence", default=None) - parser.add_argument("-r", "--regression_running_tests", help="Regression threshold for running tests.", type=float, - default=None) - parser.add_argument("--no_latest", help="Don't generate latest.html file.", action="http://github.com/store_true") - parser.add_argument("-g", "--gate", help="Run in gate mode (Skip cpython runs; Do not upload results; " - "Detect regressions).", action="http://github.com/store_true") - parser.add_argument("path", help="Path to store the csv output and logs to.", nargs='?', default=None) - - global flags - flags = parser.parse_args(args=args) - - current_date = strftime("%Y-%m-%d", gmtime()) - - log("[INFO] current date : {}", current_date) - log("[INFO] unittests path : {}", flags.tests_path) - if flags.path: - log("[INFO] results (save) path : {}", flags.path) - else: - log("[INFO] results will not be saved remotely") - - if flags.gate: - log("[INFO] running in gate mode") - if not flags.regression_running_tests: - log("[WARNING] --regression_running_tests not set while in gate mode. " - "Regression detection will not be performed") - - def _fmt(t): - t = t.strip() - return os.path.join(flags.tests_path, t if t.endswith(".py") else t + ".py") - - if flags.only_tests: - only_tests = set([_fmt(test) for test in flags.only_tests.split(",")]) - unittests = [t for t in get_unittests(flags.tests_path) if t in only_tests] - else: - skip_tests = set([_fmt(test) for test in flags.skip_tests.split(",")]) if flags.skip_tests else None - unittests = get_unittests(flags.tests_path, limit=flags.limit, skip_tests=skip_tests) - - # get cpython stats - if not flags.gate and not flags.no_cpython: - log(HR) - log("[INFO] get cpython stats") - cpy_results = run_unittests(unittests, 60 * 5, with_cpython=True) - cpy_stats = process_output('\n'.join(cpy_results))[-1] - # handle the timeout - timeout = flags.timeout if flags.timeout else None - else: - cpy_stats = None - # handle the timeout - timeout = flags.timeout if flags.timeout else 60 * 5 # 5 minutes if no value specified (in gate mode only) - - # get graalpython stats - log(HR) - log("[INFO] get graalpython stats") - results = run_unittests(unittests, timeout, with_cpython=False) - txt_report_path = file_name(TXT_RESULTS_NAME, current_date) - output = save_as_txt(txt_report_path, results) - - unittests, error_messages, java_exceptions, stats = process_output(output) - - csv_report_path = file_name(CSV_RESULTS_NAME, current_date) - rows, totals = save_as_csv(csv_report_path, unittests, error_messages, java_exceptions, stats, cpy_stats=cpy_stats) - - log("[INFO] totals: {!r}", totals) - - missing_modules = process_errors(unittests, error_messages, 'ModuleNotFoundError', - msg_processor=get_missing_module) - log("[MISSING MODULES] \n{}", pformat(dict(missing_modules))) - - cannot_import_modules = process_errors(unittests, error_messages, err='ImportError', - msg_processor=get_cannot_import_module) - log("[CANNOT IMPORT MODULES] \n{}", pformat(dict(cannot_import_modules))) - - java_issues = process_errors(unittests, java_exceptions) - log("[JAVA ISSUES] \n{}", pformat(dict(java_issues))) - - html_report_path = file_name(HTML_RESULTS_NAME, current_date) - if not flags.gate: - save_as_html(html_report_path, rows, totals, missing_modules, cannot_import_modules, java_issues, current_date) - - if not flags.gate and flags.path: - log("[SAVE] saving results to {} ... ", flags.path) - scp(txt_report_path, flags.path) - scp(csv_report_path, flags.path) - scp(html_report_path, flags.path) - if not flags.no_latest: - generate_latest(LATEST_HTML_NAME, html_report_path) - scp(LATEST_HTML_NAME, flags.path) - - gate_failed = False - if flags.gate and flags.regression_running_tests: - log("[REGRESSION] detecting regression, acceptance threshold = {}%".format( - flags.regression_running_tests * 100)) - csv_files = sorted(f for f in ssh_ls(flags.path) if PTRN_VALID_CSV_NAME.match(f)) - last_csv = csv_files[-1] - # log('\n'.join(csv_files)) - # read the remote csv and extract stats - log("[REGRESSION] comparing against: {}".format(last_csv)) - scp('{}/{}'.format(flags.path, last_csv), '.', destination_name=last_csv) - rows = read_csv(last_csv) - prev_totals = { - Col.NUM_TESTS: int(rows[-1][1]), - Col.NUM_FAILS: int(rows[-1][2]), - Col.NUM_ERRORS: int(rows[-1][3]), - Col.NUM_SKIPPED: int(rows[-1][4]), - Col.NUM_PASSES: int(rows[-1][5]), - } - log("[INFO] previous totals (from {}): {!r}", last_csv, prev_totals) - if float(totals[Col.NUM_TESTS]) < float(prev_totals[Col.NUM_TESTS]) * (1.0 - flags.regression_running_tests): - log("[REGRESSION] REGRESSION DETECTED, passed {} tests vs {} from {}".format( - totals[Col.NUM_TESTS], prev_totals[Col.NUM_TESTS], last_csv)) - gate_failed = True - else: - log("[REGRESSION] no regression detected") - - log("[DONE]") - if flags.gate and gate_failed: - exit(1) - - -if __name__ == "__main__": - main(sys.argv[0], sys.argv[1:]) diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index b38a7f6142..6eaab1422a 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -497,16 +497,6 @@ def nativeclean(args): mx.clean(["--dependencies", ",".join(PYTHON_NATIVE_PROJECTS + PYTHON_ARCHIVES)]) -def python3_unittests(args): - """run the cPython stdlib unittests""" - mx.run([sys.executable, "graalpython/com.oracle.graal.python.test/src/python_unittests.py", "-v"] + args) - - -def compare_unittests(args): - """compare the output of two runs of the cPython stdlib unittests""" - mx.run([sys.executable, "graalpython/com.oracle.graal.python.test/src/compare_unittests.py", "-v"] + args) - - class GraalPythonTags(object): junit = 'python-junit' junit_maven = 'python-junit-maven' @@ -3147,8 +3137,6 @@ def run_downstream_test(args): 'python-jvm': [no_return(python_jvm), ''], 'graalpy-standalone': [graalpy_standalone_wrapper, '[jvm|native] [ce|ee] [--no-build]'], 'python-gvm': [no_return(python_gvm), ''], - 'python-unittests': [python3_unittests, ''], - 'python-compare-unittests': [compare_unittests, ''], 'nativebuild': [nativebuild, ''], 'nativeclean': [nativeclean, ''], 'python-src-import': [mx_graalpython_import.import_python_sources, ''], From b72e5ad1544ff00241342aaab9e82b08c3ef89de Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 15 Apr 2025 13:46:12 +0200 Subject: [PATCH 309/512] Update unittest tags --- .../src/tests/unittest_tags/test_argparse.txt | 2 +- .../src/tests/unittest_tags/test_ctypes.txt | 1 + .../src/tests/unittest_tags/test_descr.txt | 2 + .../tests/unittest_tags/test_distutils.txt | 4 ++ .../src/tests/unittest_tags/test_lib2to3.txt | 4 +- .../src/tests/unittest_tags/test_tarfile.txt | 46 +++++++++---------- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt index 0232204709..1b45bf37aa 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_argparse.txt @@ -1,4 +1,4 @@ -test.test_argparse.StdStreamTest.test_skip_invalid_stderr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_argparse.StdStreamTest.test_skip_invalid_stderr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_argparse.StdStreamTest.test_skip_invalid_stdout @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_argparse.TestActionExtend.test_failures_many_groups_listargs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_argparse.TestActionExtend.test_failures_many_groups_sysargs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_ctypes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_ctypes.txt index 856a251ad8..d57dc4de19 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_ctypes.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_ctypes.txt @@ -218,6 +218,7 @@ ctypes.test.test_struct_fields.StructFieldsTestCase.test_1_B @ darwin-arm64,darw ctypes.test.test_struct_fields.StructFieldsTestCase.test_2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 ctypes.test.test_struct_fields.StructFieldsTestCase.test_3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 ctypes.test.test_struct_fields.StructFieldsTestCase.test_4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_6 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 ctypes.test.test_struct_fields.StructFieldsTestCase.test___get__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 ctypes.test.test_struct_fields.StructFieldsTestCase.test___set__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 ctypes.test.test_structures.PointerMemberTestCase.test @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt index 308ca8ce85..0e35caca5c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_descr.txt @@ -3,6 +3,7 @@ test.test_descr.ClassPropertiesAndMethods.test_abstractmethods @ darwin-arm64,da test.test_descr.ClassPropertiesAndMethods.test_altmro @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_assign_slice @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_attr_raise_through_property @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_descr.ClassPropertiesAndMethods.test_bad_new @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_basic_inheritance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_binary_operator_override @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_bound_method_repr @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 @@ -72,6 +73,7 @@ test.test_descr.ClassPropertiesAndMethods.test_qualname_dict @ darwin-arm64,darw test.test_descr.ClassPropertiesAndMethods.test_recursive_call @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_repr_as_str @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_repr_with_module_str_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_descr.ClassPropertiesAndMethods.test_restored_object_new @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_rich_comparisons @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_rmul @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_descr.ClassPropertiesAndMethods.test_set_and_no_get @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_distutils.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_distutils.txt index 19b1141ec4..68a6b0dc32 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_distutils.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_distutils.txt @@ -31,7 +31,9 @@ distutils.tests.test_build_clib.BuildCLibTestCase.test_get_source_files @ darwin distutils.tests.test_build_clib.BuildCLibTestCase.test_run @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 distutils.tests.test_build_ext.BuildExtTestCase.test_check_extensions_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.BuildExtTestCase.test_compiler_option @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +distutils.tests.test_build_ext.BuildExtTestCase.test_deployment_target_default @ darwin-arm64,darwin-x86_64 distutils.tests.test_build_ext.BuildExtTestCase.test_deployment_target_higher_ok @ darwin-arm64,darwin-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_deployment_target_too_low @ darwin-arm64,darwin-x86_64 distutils.tests.test_build_ext.BuildExtTestCase.test_ext_fullpath @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.BuildExtTestCase.test_finalize_options @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.BuildExtTestCase.test_get_outputs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 @@ -42,7 +44,9 @@ distutils.tests.test_build_ext.BuildExtTestCase.test_unicode_module_names @ darw distutils.tests.test_build_ext.BuildExtTestCase.test_user_site @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_check_extensions_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_compiler_option @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_deployment_target_default @ darwin-arm64,darwin-x86_64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_deployment_target_higher_ok @ darwin-arm64,darwin-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_deployment_target_too_low @ darwin-arm64,darwin-x86_64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_ext_fullpath @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_finalize_options @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_get_outputs @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_lib2to3.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_lib2to3.txt index 0e1ebd6da2..80a0d82a66 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_lib2to3.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_lib2to3.txt @@ -1,4 +1,4 @@ -lib2to3.tests.test_all_fixers.Test_all.test_all_project_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +lib2to3.tests.test_all_fixers.Test_all.test_all_project_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_fixers.Test_apply.test_1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_fixers.Test_apply.test_2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_fixers.Test_apply.test_3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 @@ -609,7 +609,7 @@ lib2to3.tests.test_pytree.TestPatterns.test_basic_patterns @ darwin-arm64,darwin lib2to3.tests.test_pytree.TestPatterns.test_generate_matches @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_pytree.TestPatterns.test_has_key_example @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_pytree.TestPatterns.test_wildcard @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -lib2to3.tests.test_refactor.TestRefactoringTool.test_bom @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_bom @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_refactor.TestRefactoringTool.test_crlf_newlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_refactor.TestRefactoringTool.test_crlf_unchanged @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 lib2to3.tests.test_refactor.TestRefactoringTool.test_detect_future_features @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt index ccb59a6b7f..ea5af7be37 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt @@ -274,31 +274,31 @@ test.test_tarfile.LzmaCreateTest.test_create_pathlike_name @ darwin-arm64,darwin test.test_tarfile.LzmaCreateTest.test_create_taropen @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaCreateTest.test_create_taropen_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaCreateTest.test_create_with_preset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaDetectReadTest.test_detect_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaListTest.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaListTest.test_list_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 From 9fbb320db44bb7c5725eea52721bca734906ec27 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 15 Apr 2025 13:47:19 +0200 Subject: [PATCH 310/512] Untag transient test --- .../src/tests/unittest_tags/test_threading.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_threading.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_threading.txt index 1367661d2c..5cffc86e04 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_threading.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_threading.txt @@ -75,7 +75,8 @@ test.test_threading.ExceptHookTests.test_custom_excepthook_fail @ darwin-arm64,d test.test_threading.ExceptHookTests.test_excepthook @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_threading.ExceptHookTests.test_original_excepthook @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_threading.ExceptHookTests.test_system_exit @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_threading.InterruptMainTests.test_can_interrupt_tight_loops @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +# Transient on Darwin (at least) +!test.test_threading.InterruptMainTests.test_can_interrupt_tight_loops @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_threading.InterruptMainTests.test_interrupt_main_noerror @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_threading.LockTests.test_acquire_contended @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_threading.LockTests.test_acquire_destroy @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 From 8fa341d44f21f832c33ce949998bbd104441dd66 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Tue, 15 Apr 2025 13:49:27 +0200 Subject: [PATCH 311/512] Update imports --- ci.jsonnet | 2 +- mx.graalpython/suite.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci.jsonnet b/ci.jsonnet index e761837205..53581b9396 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "c563188c993a41764098b4cd94e9f7ecd80e2689" } +{ "overlay": "f801d1578ef92e240ec92f380a9970c6644c2c59" } diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py index 49fed345c3..b215b66282 100644 --- a/mx.graalpython/suite.py +++ b/mx.graalpython/suite.py @@ -45,7 +45,7 @@ }, { "name": "sdk", - "version": "46e36ff52c61d4d3d973dcf3055b9891ae2f0b6e", + "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -53,7 +53,7 @@ }, { "name": "tools", - "version": "46e36ff52c61d4d3d973dcf3055b9891ae2f0b6e", + "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -61,7 +61,7 @@ }, { "name": "sulong", - "version": "46e36ff52c61d4d3d973dcf3055b9891ae2f0b6e", + "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -69,7 +69,7 @@ }, { "name": "regex", - "version": "46e36ff52c61d4d3d973dcf3055b9891ae2f0b6e", + "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, From 37cb91a751be8b8af2eb89a288f4699b8c33ece3 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Sat, 12 Apr 2025 13:58:32 +0200 Subject: [PATCH 312/512] Fix our implementation of Py_Is --- .../com.oracle.graal.python.cext/include/object.h | 4 +++- graalpython/com.oracle.graal.python.cext/src/object.c | 5 +++++ .../modules/cext/PythonCextObjectBuiltins.java | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/graalpython/com.oracle.graal.python.cext/include/object.h b/graalpython/com.oracle.graal.python.cext/include/object.h index 7d88c22cb1..a427c70040 100644 --- a/graalpython/com.oracle.graal.python.cext/include/object.h +++ b/graalpython/com.oracle.graal.python.cext/include/object.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2018, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2018, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -124,7 +124,9 @@ typedef struct { // Test if the 'x' object is the 'y' object, the same as "x is y" in Python. PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y); +#if 0 // GraalPy change #define Py_Is(x, y) ((x) == (y)) +#endif // GraalPy change PyAPI_FUNC(Py_ssize_t) PyTruffle_REFCNT(PyObject *ob); diff --git a/graalpython/com.oracle.graal.python.cext/src/object.c b/graalpython/com.oracle.graal.python.cext/src/object.c index 97d8b3f48e..691df9134c 100644 --- a/graalpython/com.oracle.graal.python.cext/src/object.c +++ b/graalpython/com.oracle.graal.python.cext/src/object.c @@ -2532,7 +2532,12 @@ Py_XNewRef(PyObject *obj) // for the stable ABI. int Py_Is(PyObject *x, PyObject *y) { +#if 0 // GraalPy change return (x == y); +#else + return (x == y) || + (points_to_py_handle_space(x) && points_to_py_handle_space(y) && GraalPyTruffle_Is(x, y)); +#endif } int Py_IsNone(PyObject *x) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java index a0079358cd..9b5757f6c4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java @@ -133,6 +133,7 @@ import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; +import com.oracle.graal.python.nodes.object.IsNode; import com.oracle.graal.python.nodes.util.CannotCastException; import com.oracle.graal.python.nodes.util.CastToJavaStringNode; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; @@ -741,4 +742,13 @@ static Object getDict(Object object, return getDict.execute(inliningTarget, object); } } + + @CApiBuiltin(ret = Int, args = {PyObject, PyObject}, call = Ignored) + abstract static class PyTruffle_Is extends CApiBinaryBuiltinNode { + @Specialization + static int isTrue(Object a, Object b, + @Cached IsNode isNode) { + return isNode.execute(a, b) ? 1 : 0; + } + } } From ede979ef46897134ef71f4ad52a1fa0e2d18fc24 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 15 Apr 2025 12:39:08 +0200 Subject: [PATCH 313/512] Add patch for ormsgpack --- .../lib-graalpython/patches/metadata.toml | 5 + .../patches/ormsgpack-1.8.0-1.9.1.patch | 364 ++++++++++++++++++ 2 files changed, 369 insertions(+) create mode 100644 graalpython/lib-graalpython/patches/ormsgpack-1.8.0-1.9.1.patch diff --git a/graalpython/lib-graalpython/patches/metadata.toml b/graalpython/lib-graalpython/patches/metadata.toml index 0e31f29d4b..4aadbe66a6 100644 --- a/graalpython/lib-graalpython/patches/metadata.toml +++ b/graalpython/lib-graalpython/patches/metadata.toml @@ -353,6 +353,11 @@ version = '== 3.10.5' patch = 'orjson-3.10.5.patch' license = 'Apache-2.0 OR MIT' +[[ormsgpack.rules]] +version = '>= 1.8.0, <= 1.9.1' +patch = 'ormsgpack-1.8.0-1.9.1.patch' +license = 'Apache-2.0 OR MIT' + [[overrides.rules]] version = '== 7.4.0' # Important: This patch esentially breaks the package, it's not upstreamable. The package relies on bytecode parsing diff --git a/graalpython/lib-graalpython/patches/ormsgpack-1.8.0-1.9.1.patch b/graalpython/lib-graalpython/patches/ormsgpack-1.8.0-1.9.1.patch new file mode 100644 index 0000000000..3a9542a058 --- /dev/null +++ b/graalpython/lib-graalpython/patches/ormsgpack-1.8.0-1.9.1.patch @@ -0,0 +1,364 @@ +diff --git a/src/deserialize/deserializer.rs b/src/deserialize/deserializer.rs +index 41cf7f1..99cd68e 100644 +--- a/src/deserialize/deserializer.rs ++++ b/src/deserialize/deserializer.rs +@@ -292,7 +292,10 @@ impl<'de> Deserializer<'de> { + marker => Err(Error::InvalidType(marker)), + }?; + let value = self.deserialize()?; ++ #[cfg(not(GraalPy))] + let pyhash = unsafe { (*key.as_ptr().cast::()).hash }; ++ #[cfg(GraalPy)] ++ let pyhash = unsafe { pyo3::ffi::PyObject_Hash(key.as_ptr()) }; + let _ = ffi!(_PyDict_SetItem_KnownHash( + dict_ptr, + key.as_ptr(), +@@ -471,7 +474,7 @@ impl<'de> Deserializer<'de> { + let ptr = ffi!(PyTuple_New(len as pyo3::ffi::Py_ssize_t)); + for i in 0..len { + let elem = self.deserialize_map_key()?; +- ffi!(PyTuple_SET_ITEM( ++ ffi!(PyTuple_SetItem( + ptr, + i as pyo3::ffi::Py_ssize_t, + elem.as_ptr() +diff --git a/src/ext.rs b/src/ext.rs +index b2573b4..9668d4f 100644 +--- a/src/ext.rs ++++ b/src/ext.rs +@@ -22,7 +22,7 @@ unsafe extern "C" fn ext_new( + ); + return null_mut(); + } +- let tag = PyTuple_GET_ITEM(args, 0); ++ let tag = PyTuple_GetItem(args, 0); + if PyLong_Check(tag) == 0 { + PyErr_SetString( + PyExc_TypeError, +@@ -30,7 +30,7 @@ unsafe extern "C" fn ext_new( + ); + return null_mut(); + } +- let data = PyTuple_GET_ITEM(args, 1); ++ let data = PyTuple_GetItem(args, 1); + if PyBytes_Check(data) == 0 { + PyErr_SetString( + PyExc_TypeError, +diff --git a/src/ffi.rs b/src/ffi.rs +index 4e5ddc3..20c9db4 100644 +--- a/src/ffi.rs ++++ b/src/ffi.rs +@@ -7,13 +7,16 @@ use std::ptr::NonNull; + #[allow(non_snake_case)] + #[inline(always)] + pub unsafe fn PyBytes_AS_STRING(op: *mut PyObject) -> *const c_char { +- &(*op.cast::()).ob_sval as *const c_char ++ #[cfg(not(any(PyPy, GraalPy, Py_LIMITED_API)))] ++ return &(*op.cast::()).ob_sval as *const c_char; ++ #[cfg(any(PyPy, GraalPy, Py_LIMITED_API))] ++ return crate::PyBytes_AsString(op); + } + + #[allow(non_snake_case)] + #[inline(always)] + pub unsafe fn PyBytes_GET_SIZE(op: *mut PyObject) -> Py_ssize_t { +- (*op.cast::()).ob_size ++ Py_SIZE(op) + } + + #[repr(C)] +@@ -63,11 +66,21 @@ pub fn pylong_is_positive(op: *mut PyObject) -> bool { + unsafe { (*(op as *mut PyLongObject)).long_value.lv_tag & SIGN_MASK == 0 } + } + +-#[cfg(not(Py_3_12))] ++#[cfg(not(any(Py_3_12, GraalPy)))] + pub fn pylong_is_positive(op: *mut PyObject) -> bool { + unsafe { (*(op as *mut PyVarObject)).ob_size > 0 } + } + ++extern "C" { ++ #[cfg(not(PyPy))] ++ pub fn _PyLong_Sign(v: *mut PyObject) -> c_int; ++} ++ ++#[cfg(GraalPy)] ++pub fn pylong_is_positive(op: *mut PyObject) -> bool { ++ unsafe { _PyLong_Sign(op) > 0 } ++} ++ + pub struct PyDictIter { + op: *mut PyObject, + pos: isize, +diff --git a/src/lib.rs b/src/lib.rs +index f10b1c4..1a9768b 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -143,7 +143,7 @@ fn raise_unpackb_exception(msg: &str) -> *mut PyObject { + let err_msg = + PyUnicode_FromStringAndSize(msg.as_ptr() as *const c_char, msg.len() as isize); + let args = PyTuple_New(1); +- PyTuple_SET_ITEM(args, 0, err_msg); ++ PyTuple_SetItem(args, 0, err_msg); + PyErr_SetObject(typeref::MsgpackDecodeError, args); + Py_DECREF(args); + }; +@@ -199,10 +199,10 @@ pub unsafe extern "C" fn unpackb( + if !kwnames.is_null() { + let tuple_size = PyTuple_GET_SIZE(kwnames); + for i in 0..tuple_size { +- let arg = PyTuple_GET_ITEM(kwnames, i as Py_ssize_t); +- if arg == typeref::EXT_HOOK { ++ let arg = PyTuple_GetItem(kwnames, i as Py_ssize_t); ++ if PyUnicode_Compare(arg, typeref::EXT_HOOK) == 0 { + ext_hook = Some(NonNull::new_unchecked(*args.offset(num_args + i))); +- } else if arg == typeref::OPTION { ++ } else if PyUnicode_Compare(arg, typeref::OPTION) == 0 { + optsptr = Some(NonNull::new_unchecked(*args.offset(num_args + i))); + } else { + return raise_unpackb_exception("unpackb() got an unexpected keyword argument"); +@@ -247,15 +247,15 @@ pub unsafe extern "C" fn packb( + if !kwnames.is_null() { + let tuple_size = PyTuple_GET_SIZE(kwnames); + for i in 0..tuple_size { +- let arg = PyTuple_GET_ITEM(kwnames, i as Py_ssize_t); +- if arg == typeref::DEFAULT { ++ let arg = PyTuple_GetItem(kwnames, i as Py_ssize_t); ++ if PyUnicode_Compare(arg, typeref::DEFAULT) == 0 { + if unlikely!(default.is_some()) { + return raise_packb_exception( + "packb() got multiple values for argument: 'default'", + ); + } + default = Some(NonNull::new_unchecked(*args.offset(num_args + i))); +- } else if arg == typeref::OPTION { ++ } else if PyUnicode_Compare(arg, typeref::OPTION) == 0 { + if unlikely!(optsptr.is_some()) { + return raise_packb_exception( + "packb() got multiple values for argument: 'option'", +diff --git a/src/serialize/datetime.rs b/src/serialize/datetime.rs +index 63212d6..5ac2b2b 100644 +--- a/src/serialize/datetime.rs ++++ b/src/serialize/datetime.rs +@@ -61,9 +61,14 @@ pub struct Time { + + impl Time { + pub fn new(ptr: *mut pyo3::ffi::PyObject, opts: Opt) -> Result { ++ #[cfg(not(GraalPy))] + if unsafe { (*(ptr as *mut pyo3::ffi::PyDateTime_Time)).hastzinfo != 0 } { + return Err(TimeError::HasTimezone); + } ++ #[cfg(GraalPy)] ++ if unsafe { pyo3::ffi::PyDateTime_TIME_GET_TZINFO(ptr) != crate::typeref::NONE } { ++ return Err(TimeError::HasTimezone); ++ } + Ok(Time { + ptr: ptr, + opts: opts, +@@ -114,23 +119,28 @@ impl std::fmt::Display for DateTimeError { + } + + fn utcoffset(ptr: *mut pyo3::ffi::PyObject) -> Result { ++ #[cfg(not(GraalPy))] + if !unsafe { (*(ptr as *mut pyo3::ffi::PyDateTime_DateTime)).hastzinfo == 1 } { + return Ok(Offset::default()); + } + + let tzinfo = ffi!(PyDateTime_DATE_GET_TZINFO(ptr)); ++ #[cfg(GraalPy)] ++ if unsafe { tzinfo == crate::typeref::NONE } { ++ return Ok(Offset::default()); ++ } + let py_offset: *mut pyo3::ffi::PyObject; + if ffi!(PyObject_HasAttr(tzinfo, CONVERT_METHOD_STR)) == 1 { + // pendulum +- py_offset = ffi!(PyObject_CallMethodNoArgs(ptr, UTCOFFSET_METHOD_STR)); ++ py_offset = unsafe { pyo3::ffi::compat::PyObject_CallMethodNoArgs(ptr, UTCOFFSET_METHOD_STR) }; + } else if ffi!(PyObject_HasAttr(tzinfo, NORMALIZE_METHOD_STR)) == 1 { + // pytz +- let normalized = ffi!(PyObject_CallMethodOneArg(tzinfo, NORMALIZE_METHOD_STR, ptr)); +- py_offset = ffi!(PyObject_CallMethodNoArgs(normalized, UTCOFFSET_METHOD_STR)); ++ let normalized = ffi!(PyObject_CallMethodObjArgs(tzinfo, NORMALIZE_METHOD_STR, ptr, std::ptr::null_mut::())); ++ py_offset = unsafe { pyo3::ffi::compat::PyObject_CallMethodNoArgs(normalized, UTCOFFSET_METHOD_STR) }; + ffi!(Py_DECREF(normalized)); + } else if ffi!(PyObject_HasAttr(tzinfo, DST_STR)) == 1 { + // dateutil/arrow, datetime.timezone.utc +- py_offset = ffi!(PyObject_CallMethodOneArg(tzinfo, UTCOFFSET_METHOD_STR, ptr)); ++ py_offset = ffi!(PyObject_CallMethodObjArgs(tzinfo, UTCOFFSET_METHOD_STR, ptr, std::ptr::null_mut::())); + } else { + return Err(DateTimeError::LibraryUnsupported); + } +@@ -193,7 +203,10 @@ impl TimeLike for DateTime { + + impl DateTimeLike for DateTime { + fn has_tz(&self) -> bool { +- unsafe { (*(self.ptr as *mut pyo3::ffi::PyDateTime_DateTime)).hastzinfo == 1 } ++ #[cfg(not(GraalPy))] ++ return unsafe { (*(self.ptr as *mut pyo3::ffi::PyDateTime_DateTime)).hastzinfo == 1 }; ++ #[cfg(GraalPy)] ++ return unsafe { pyo3::ffi::PyDateTime_TIME_GET_TZINFO(self.ptr) != crate::typeref::NONE }; + } + + fn offset(&self) -> Offset { +diff --git a/src/serialize/numpy.rs b/src/serialize/numpy.rs +index afc5cdf..4d007bd 100644 +--- a/src/serialize/numpy.rs ++++ b/src/serialize/numpy.rs +@@ -392,8 +392,8 @@ impl NumpyDatetimeUnit { + fn from_pyobject(ptr: *mut PyObject) -> Self { + let dtype = ffi!(PyObject_GetAttr(ptr, DTYPE_STR)); + let descr = ffi!(PyObject_GetAttr(dtype, DESCR_STR)); +- let el0 = ffi!(PyList_GET_ITEM(descr, 0)); +- let descr_str = ffi!(PyTuple_GET_ITEM(el0, 1)); ++ let el0 = ffi!(PyList_GetItem(descr, 0)); ++ let descr_str = ffi!(PyTuple_GetItem(el0, 1)); + let uni = crate::unicode::unicode_to_str(descr_str).unwrap(); + if uni.len() < 5 { + return Self::NaT; +diff --git a/src/serialize/serializer.rs b/src/serialize/serializer.rs +index 309e6e1..6f7dec7 100644 +--- a/src/serialize/serializer.rs ++++ b/src/serialize/serializer.rs +@@ -864,7 +864,7 @@ impl Serialize for DictTupleKey { + let len = ffi!(PyTuple_GET_SIZE(self.ptr)) as usize; + let mut seq = serializer.serialize_seq(Some(len)).unwrap(); + for i in 0..len { +- let item = ffi!(PyTuple_GET_ITEM(self.ptr, i as isize)); ++ let item = ffi!(PyTuple_GetItem(self.ptr, i as isize)); + let value = DictKey::new(item, self.opts, self.recursion + 1); + seq.serialize_element(&value)?; + } +diff --git a/src/serialize/tuple.rs b/src/serialize/tuple.rs +index fa81cb6..9b66019 100644 +--- a/src/serialize/tuple.rs ++++ b/src/serialize/tuple.rs +@@ -41,7 +41,7 @@ impl Serialize for Tuple { + let len = ffi!(PyTuple_GET_SIZE(self.ptr)) as usize; + let mut seq = serializer.serialize_seq(Some(len)).unwrap(); + for i in 0..len { +- let item = ffi!(PyTuple_GET_ITEM(self.ptr, i as isize)); ++ let item = ffi!(PyTuple_GetItem(self.ptr, i as isize)); + let value = PyObject::new( + item, + self.opts, +diff --git a/src/serialize/writer.rs b/src/serialize/writer.rs +index a790bdd..35346d9 100644 +--- a/src/serialize/writer.rs ++++ b/src/serialize/writer.rs +@@ -27,7 +27,6 @@ impl BytesWriter { + pub fn finish(&mut self) -> NonNull { + unsafe { + std::ptr::write(self.buffer_ptr(), 0); +- (*self.bytes.cast::()).ob_size = self.len as Py_ssize_t; + self.resize(self.len); + NonNull::new_unchecked(self.bytes as *mut PyObject) + } +@@ -35,10 +34,14 @@ impl BytesWriter { + + fn buffer_ptr(&self) -> *mut u8 { + unsafe { +- std::mem::transmute::<*mut [c_char; 1], *mut u8>(std::ptr::addr_of_mut!( ++ #[cfg(not(GraalPy))] ++ return std::mem::transmute::<*mut [c_char; 1], *mut u8>(std::ptr::addr_of_mut!( + (*self.bytes).ob_sval + )) +- .add(self.len) ++ .add(self.len); ++ #[cfg(GraalPy)] ++ return std::mem::transmute::<*mut i8, *mut u8>(PyBytes_AsString(self.bytes.cast::())) ++ .add(self.len); + } + } + +diff --git a/src/unicode.rs b/src/unicode.rs +index 53aca09..552fa6c 100644 +--- a/src/unicode.rs ++++ b/src/unicode.rs +@@ -6,6 +6,7 @@ use pyo3::ffi::*; + + // see unicodeobject.h for documentation + ++#[cfg(not(GraalPy))] + pub fn unicode_from_str(buf: &str) -> *mut PyObject { + if buf.is_empty() { + ffi!(Py_INCREF(EMPTY_UNICODE)); +@@ -27,6 +28,13 @@ pub fn unicode_from_str(buf: &str) -> *mut PyObject { + } + } + ++#[cfg(GraalPy)] ++pub fn unicode_from_str(buf: &str) -> *mut PyObject { ++ unsafe { ++ PyUnicode_FromStringAndSize(buf.as_ptr() as *const i8, buf.len() as isize) ++ } ++} ++ + fn pyunicode_ascii(buf: &str) -> *mut PyObject { + unsafe { + let ptr = ffi!(PyUnicode_New(buf.len() as isize, 127)); +@@ -80,6 +88,7 @@ fn pyunicode_fourbyte(buf: &str, num_chars: usize) -> *mut PyObject { + + #[inline] + pub fn hash_str(op: *mut PyObject) -> Py_hash_t { ++ #[cfg(not(GraalPy))] + unsafe { + let data_ptr: *mut c_void = if (*op.cast::()).compact() == 1 + && (*op.cast::()).ascii() == 1 +@@ -92,7 +101,11 @@ pub fn hash_str(op: *mut PyObject) -> Py_hash_t { + (*(op as *mut PyASCIIObject)).length * ((*(op as *mut PyASCIIObject)).kind()) as isize; + let hash = _Py_HashBytes(data_ptr, num_bytes); + (*op.cast::()).hash = hash; +- hash ++ return hash; ++ } ++ #[cfg(GraalPy)] ++ unsafe { ++ return PyObject_Hash(op); + } + } + +@@ -109,19 +122,24 @@ pub fn unicode_to_str_via_ffi(op: *mut PyObject) -> Option<&'static str> { + + #[inline] + pub fn unicode_to_str(op: *mut PyObject) -> Option<&'static str> { ++ #[cfg(not(GraalPy))] + unsafe { + if unlikely!((*op.cast::()).compact() == 0) { +- unicode_to_str_via_ffi(op) ++ return unicode_to_str_via_ffi(op); + } else if (*op.cast::()).ascii() == 1 { + let ptr = op.cast::().offset(1) as *const u8; + let len = (*op.cast::()).length as usize; +- Some(str_from_slice!(ptr, len)) ++ return Some(str_from_slice!(ptr, len)); + } else if (*op.cast::()).utf8_length != 0 { + let ptr = (*op.cast::()).utf8 as *const u8; + let len = (*op.cast::()).utf8_length as usize; +- Some(str_from_slice!(ptr, len)) ++ return Some(str_from_slice!(ptr, len)); + } else { +- unicode_to_str_via_ffi(op) ++ return unicode_to_str_via_ffi(op); + } + } ++ #[cfg(GraalPy)] ++ unsafe { ++ return unicode_to_str_via_ffi(op); ++ } + } +diff --git a/src/util.rs b/src/util.rs +index 2bcc32d..89faf1a 100644 +--- a/src/util.rs ++++ b/src/util.rs +@@ -8,7 +8,7 @@ macro_rules! py_is { + + macro_rules! ob_type { + ($obj:expr) => { +- unsafe { (*($obj as *mut pyo3::ffi::PyObject)).ob_type } ++ unsafe { pyo3::ffi::Py_TYPE($obj as *mut pyo3::ffi::PyObject) } + }; + } + +-- +2.43.0 + From 97fb7929488f5362d352e56fe6ba23896009f802 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 15 Apr 2025 13:07:11 +0200 Subject: [PATCH 314/512] Expose PyTuple_SET_ITEM also as API function on GraalPy --- .../include/cpython/tupleobject.h | 10 +++----- .../src/tupleobject.c | 8 ++++++- .../src/tests/cpyext/test_tuple.py | 23 ++++++++++++++++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/graalpython/com.oracle.graal.python.cext/include/cpython/tupleobject.h b/graalpython/com.oracle.graal.python.cext/include/cpython/tupleobject.h index ef3d3c3790..222dbdfd50 100644 --- a/graalpython/com.oracle.graal.python.cext/include/cpython/tupleobject.h +++ b/graalpython/com.oracle.graal.python.cext/include/cpython/tupleobject.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2020, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2020 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -39,14 +39,10 @@ PyAPI_FUNC(PyObject *) _PyTuple_GET_ITEM(PyObject *, Py_ssize_t); // GraalPy-specific PyAPI_FUNC(PyObject **) PyTruffleTuple_GetItems(PyObject *op); -/* Function *only* to be used to fill in brand new tuples */ -static inline void -PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { - PyTruffleTuple_GetItems(op)[index] = value; -} #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 +PyAPI_FUNC(void) PyTuple_SET_ITEM(PyObject*, Py_ssize_t, PyObject*); #define PyTuple_SET_ITEM(op, index, value) \ - PyTuple_SET_ITEM(_PyObject_CAST(op), index, _PyObject_CAST(value)) + do { PyTruffleTuple_GetItems(op)[index] = value; } while (0) #endif PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); diff --git a/graalpython/com.oracle.graal.python.cext/src/tupleobject.c b/graalpython/com.oracle.graal.python.cext/src/tupleobject.c index 007bab220d..e5259468b5 100644 --- a/graalpython/com.oracle.graal.python.cext/src/tupleobject.c +++ b/graalpython/com.oracle.graal.python.cext/src/tupleobject.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2018, 2024, Oracle and/or its affiliates. +/* Copyright (c) 2018, 2025, Oracle and/or its affiliates. * Copyright (C) 1996-2022 Python Software Foundation * * Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -1424,3 +1424,9 @@ _PyTuple_GET_ITEM(PyObject* a, Py_ssize_t b) { } return NULL; // an exception has happend during transtion } + +#undef PyTuple_SET_ITEM +// Export PyTuple_SET_ITEM as regular API function to use in PyO3 and others +void PyTuple_SET_ITEM(PyObject* op, Py_ssize_t index, PyObject* value) { + PyTruffleTuple_GetItems(op)[index] = value; +} diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tuple.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tuple.py index 3570a698fb..c696d5828f 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tuple.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_tuple.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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 @@ -151,14 +151,15 @@ class TestPyTuple(CPyExtTestCase): ((1, 2, 3), -1, []), ((1, 2, 3), 3, str), ), - code="""PyObject* wrap_PyTuple_SetItem(PyObject* original, Py_ssize_t index, PyObject* value) { + code=""" + PyObject* wrap_PyTuple_SetItem(PyObject* original, Py_ssize_t index, PyObject* value) { Py_ssize_t size = PyTuple_Size(original); if (size < 0) return NULL; PyObject* tuple = PyTuple_New(size); if (!tuple) return NULL; - for (int i = 0; i < size; i++) { + for (int i = 0; i < size / 2; i++) { PyObject* item = PyTuple_GetItem(original, i); if (!item) { Py_DECREF(tuple); @@ -167,6 +168,22 @@ class TestPyTuple(CPyExtTestCase): Py_INCREF(item); PyTuple_SET_ITEM(tuple, i, item); } + + #ifdef GRAALVM_PYTHON + // test that we also have it as API function on GraalPy + #undef PyTuple_SET_ITEM + #endif + + for (int i = size / 2; i < size; i++) { + PyObject* item = PyTuple_GetItem(original, i); + if (!item) { + Py_DECREF(tuple); + return NULL; + } + Py_INCREF(item); + PyTuple_SET_ITEM(tuple, i, item); + } + Py_INCREF(value); if (PyTuple_SetItem(tuple, index, value) < 0) { Py_DECREF(tuple); From 054c3eb873fae3eb133a33a085af6ee202cbb727 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Mon, 14 Apr 2025 15:50:06 +0200 Subject: [PATCH 315/512] Adjusting the delete from attribute to cover PythonBuiltinClass --- .../nodes/attributes/WriteAttributeToObjectNode.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java index 5178e2b894..8201277a96 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToObjectNode.java @@ -230,8 +230,8 @@ static boolean writeToDictClass(PythonClass klass, TruffleString key, Object val return writeToDictManagedClass(klass, dict, key, value, inliningTarget, callAttrUpdate, updateStorage, setHashingStorageItem, codePointLengthNode, codePointAtIndexNode); } - @Specialization(guards = {"dict != null", "isNoValue(value)"}) - static boolean deleteFromDict(PythonObject obj, TruffleString key, Object value, + @Specialization(guards = {"dict != null", "isNoValue(value)", "!isPythonBuiltinClass(obj)"}) + static boolean deleteFromPythonObject(PythonObject obj, TruffleString key, Object value, @Bind("this") Node inliningTarget, @SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict, @Bind("getDict.execute(obj)") PDict dict, @@ -252,6 +252,14 @@ static boolean deleteFromDict(PythonObject obj, TruffleString key, Object value, } } + @Specialization(guards = {"dict != null", "isNoValue(value)"}) + static boolean deleteFromPythonBuiltinClass(PythonBuiltinClass klass, TruffleString key, Object value, + @Bind("this") Node inliningTarget, + @SuppressWarnings("unused") @Shared("getDict") @Cached GetDictIfExistsNode getDict, + @Bind("getDict.execute(klass)") PDict dict) { + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANT_SET_ATTRIBUTE_R_OF_IMMUTABLE_TYPE_N, key, klass); + } + private static boolean writeToDictManagedClass(PythonManagedClass klass, PDict dict, TruffleString key, Object value, Node inliningTarget, InlinedBranchProfile callAttrUpdate, InlinedBranchProfile updateStorage, HashingStorageSetItem setHashingStorageItem, TruffleString.CodePointLengthNode codePointLengthNode, TruffleString.CodePointAtIndexNode codePointAtIndexNode) { From cd862a6969c8b1e05ceacac38f6463c472b7cae3 Mon Sep 17 00:00:00 2001 From: Matt D'Souza Date: Sat, 17 Aug 2024 14:09:44 -0400 Subject: [PATCH 316/512] Bytecode DSL interpreter migration --- .../python/harness.py | 3 + .../freeze_modules.py | 24 +- .../pegparser/test/LambdaInFunctionTests.java | 2 +- .../pegparser/test/YieldStatementTests.java | 2 +- .../graal/python/pegparser/scope/Scope.java | 8 +- .../pegparser/scope/ScopeEnvironment.java | 12 +- .../graal/python/shell/GraalPythonMain.java | 5 + .../integration/generator/GeneratorTests.java | 119 +- .../test/integration/grammar/AsyncTests.java | 114 + .../test/integration/grammar/ClassTests.java | 19 +- .../test/integration/grammar/TryTests.java | 47 +- .../integration/runtime/ProfileTests.java | 4 +- .../python/test/compiler/CompilerTests.java | 10 + .../python/test/debug/PythonDebugTest.java | 13 +- .../cext/test/MultiContextCExtTest.java | 7 +- .../src/runner.py | 7 +- .../src/tests/cpyext/test_abstract.py | 104 +- .../src/tests/cpyext/test_shutdown.py | 2 + .../src/tests/test_exception.py | 6 +- .../src/tests/test_frame_tests.py | 115 +- .../src/tests/test_generators.py | 5 +- .../src/tests/test_interop.py | 2 + .../src/tests/test_parser.py | 10 +- .../src/tests/test_patmat.py | 6 +- .../src/tests/test_pdb.py | 8 +- .../src/tests/test_repl.py | 4 +- .../src/tests/test_ssl_java_integration.py | 7 +- .../src/tests/test_sys_settrace.py | 4 +- .../src/tests/test_traceback.py | 11 +- .../src/tests/test_venv.py | 4 +- .../src/tests/test_yield_from.py | 4 +- .../test__locale.txt | 2 + .../unittest_tags_bytecode_dsl/test_abc.txt | 36 + .../test_abstract_numbers.txt | 3 + .../test_argparse.txt | 1706 ++++++ .../unittest_tags_bytecode_dsl/test_array.txt | 731 +++ .../unittest_tags_bytecode_dsl/test_ast.txt | 136 + .../test_asynchat.txt | 25 + .../test_asyncio.txt | 657 +++ .../test_asyncore.txt | 51 + .../test_atexit.txt | 1 + .../test_augassign.txt | 7 + .../test_base64.txt | 36 + .../test_baseexception.txt | 11 + .../unittest_tags_bytecode_dsl/test_bdb.txt | 30 + .../test_bigmem.txt | 161 + .../test_binascii.txt | 28 + .../unittest_tags_bytecode_dsl/test_binop.txt | 12 + .../test_bisect.txt | 21 + .../unittest_tags_bytecode_dsl/test_bool.txt | 30 + .../test_buffer.txt | 35 + .../unittest_tags_bytecode_dsl/test_bufio.txt | 4 + .../test_builtin.txt | 87 + .../unittest_tags_bytecode_dsl/test_bytes.txt | 269 + .../unittest_tags_bytecode_dsl/test_bz2.txt | 94 + .../test_calendar.txt | 71 + .../unittest_tags_bytecode_dsl/test_call.txt | 66 + .../unittest_tags_bytecode_dsl/test_capi.txt | 150 + .../unittest_tags_bytecode_dsl/test_cgi.txt | 23 + .../unittest_tags_bytecode_dsl/test_cgitb.txt | 6 + .../test_charmapcodec.txt | 4 + .../unittest_tags_bytecode_dsl/test_class.txt | 15 + .../unittest_tags_bytecode_dsl/test_cmath.txt | 31 + .../unittest_tags_bytecode_dsl/test_cmd.txt | 3 + .../test_cmd_line.txt | 22 + .../test_cmd_line_script.txt | 18 + .../unittest_tags_bytecode_dsl/test_code.txt | 4 + .../test_code_module.txt | 7 + .../test_codeccallbacks.txt | 18 + .../test_codecencodings_cn.txt | 19 + .../test_codecencodings_hk.txt | 2 + .../test_codecencodings_iso2022.txt | 8 + .../test_codecencodings_jp.txt | 23 + .../test_codecencodings_kr.txt | 16 + .../test_codecencodings_tw.txt | 7 + .../test_codecmaps_cn.txt | 7 + .../test_codecmaps_hk.txt | 3 + .../test_codecmaps_jp.txt | 9 + .../test_codecmaps_kr.txt | 9 + .../test_codecmaps_tw.txt | 5 + .../test_codecs.txt | 184 + .../test_codeop.txt | 6 + .../test_collections.txt | 101 + .../test_colorsys.txt | 7 + .../test_compare.txt | 16 + .../test_compile.txt | 53 + .../test_compileall.txt | 121 + .../test_complex.txt | 29 + .../test_concurrent_futures.txt | 112 + .../test_configparser.txt | 337 ++ .../test_contains.txt | 4 + .../test_context.txt | 15 + .../test_contextlib.txt | 85 + .../test_contextlib_async.txt | 21 + .../unittest_tags_bytecode_dsl/test_copy.txt | 74 + .../test_copyreg.txt | 6 + .../test_cppext.txt | 0 .../unittest_tags_bytecode_dsl/test_crypt.txt | 6 + .../unittest_tags_bytecode_dsl/test_csv.txt | 110 + .../test_ctypes.txt | 247 + .../test_dataclasses.txt | 211 + .../unittest_tags_bytecode_dsl/test_dbm.txt | 14 + .../test_dbm_dumb.txt | 24 + .../test_decimal.txt | 372 ++ .../test_decorators.txt | 16 + .../test_defaultdict.txt | 10 + .../unittest_tags_bytecode_dsl/test_deque.txt | 73 + .../unittest_tags_bytecode_dsl/test_descr.txt | 126 + .../test_descrtut.txt | 7 + .../unittest_tags_bytecode_dsl/test_dict.txt | 90 + .../test_dictcomps.txt | 9 + .../test_dictviews.txt | 15 + .../test_difflib.txt | 51 + .../test_distutils.txt | 210 + .../test_doctest.txt | 17 + .../test_doctest2.txt | 1 + .../test_docxmlrpc.txt | 9 + .../test_dynamic.txt | 11 + .../test_dynamicclassattribute.txt | 11 + .../unittest_tags_bytecode_dsl/test_email.txt | 1659 ++++++ .../test_ensurepip.txt | 30 + .../unittest_tags_bytecode_dsl/test_enum.txt | 586 +++ .../test_enumerate.txt | 78 + .../unittest_tags_bytecode_dsl/test_eof.txt | 6 + .../unittest_tags_bytecode_dsl/test_errno.txt | 3 + .../test_except_star.txt | 1 + .../test_exception_group.txt | 47 + .../test_exception_hierarchy.txt | 15 + .../test_exception_variations.txt | 16 + .../test_exceptions.txt | 54 + .../test_faulthandler.txt | 4 + .../unittest_tags_bytecode_dsl/test_fcntl.txt | 3 + .../unittest_tags_bytecode_dsl/test_file.txt | 30 + .../test_filecmp.txt | 9 + .../test_fileinput.txt | 57 + .../test_fileio.txt | 87 + .../unittest_tags_bytecode_dsl/test_float.txt | 51 + .../unittest_tags_bytecode_dsl/test_flufl.txt | 1 + .../test_fnmatch.txt | 17 + .../test_format.txt | 12 + .../test_fractions.txt | 33 + .../unittest_tags_bytecode_dsl/test_frame.txt | 5 + .../test_frozen.txt | 3 + .../test_fstring.txt | 66 + .../test_ftplib.txt | 93 + .../test_funcattrs.txt | 30 + .../test_functools.txt | 243 + .../test_future_stmt.txt | 27 + .../unittest_tags_bytecode_dsl/test_gc.txt | 4 + .../test_generator_stop.txt | 2 + .../test_generators.txt | 19 + .../test_genericalias.txt | 29 + .../test_genericclass.txt | 21 + .../test_genericpath.txt | 24 + .../test_genexps.txt | 0 .../test_getopt.txt | 8 + .../test_getpass.txt | 14 + .../test_gettext.txt | 43 + .../unittest_tags_bytecode_dsl/test_glob.txt | 14 + .../test_global.txt | 4 + .../test_grammar.txt | 67 + .../test_graphlib.txt | 15 + .../unittest_tags_bytecode_dsl/test_gzip.txt | 61 + .../unittest_tags_bytecode_dsl/test_hash.txt | 11 + .../test_hashlib.txt | 63 + .../unittest_tags_bytecode_dsl/test_heapq.txt | 25 + .../unittest_tags_bytecode_dsl/test_hmac.txt | 26 + .../unittest_tags_bytecode_dsl/test_html.txt | 2 + .../test_htmlparser.txt | 46 + .../test_http_cookiejar.txt | 77 + .../test_http_cookies.txt | 27 + .../test_httplib.txt | 111 + .../test_httpservers.txt | 74 + .../test_imaplib.txt | 87 + .../test_imghdr.txt | 11 + .../unittest_tags_bytecode_dsl/test_imp.txt | 18 + .../test_import.txt | 66 + .../test_importlib.txt | 1405 +++++ .../unittest_tags_bytecode_dsl/test_index.txt | 55 + .../test_inspect.txt | 231 + .../unittest_tags_bytecode_dsl/test_int.txt | 36 + .../test_int_literal.txt | 6 + .../unittest_tags_bytecode_dsl/test_io.txt | 523 ++ .../test_ipaddress.txt | 204 + .../test_isinstance.txt | 22 + .../unittest_tags_bytecode_dsl/test_iter.txt | 51 + .../test_iterlen.txt | 21 + .../test_itertools.txt | 114 + .../unittest_tags_bytecode_dsl/test_json.txt | 162 + .../test_keyword.txt | 11 + .../test_keywordonlyarg.txt | 11 + .../test_largefile.txt | 10 + .../test_lib2to3.txt | 660 +++ .../test_linecache.txt | 24 + .../unittest_tags_bytecode_dsl/test_list.txt | 54 + .../test_listcomps.txt | 1 + .../test_locale.txt | 59 + .../test_logging.txt | 216 + .../unittest_tags_bytecode_dsl/test_long.txt | 34 + .../test_longexp.txt | 1 + .../unittest_tags_bytecode_dsl/test_lzma.txt | 112 + .../test_mailbox.txt | 362 ++ .../test_mailcap.txt | 9 + .../test_marshal.txt | 46 + .../unittest_tags_bytecode_dsl/test_math.txt | 70 + .../test_memoryio.txt | 157 + .../test_memoryview.txt | 107 + .../test_metaclass.txt | 1 + .../test_mimetypes.txt | 20 + .../test_minidom.txt | 128 + .../unittest_tags_bytecode_dsl/test_mmap.txt | 22 + .../test_module.txt | 34 + .../test_multibytecodec.txt | 10 + .../test_multiprocessing_spawn.txt | 192 + .../test_named_expressions.txt | 65 + .../unittest_tags_bytecode_dsl/test_netrc.txt | 22 + .../test_nntplib.txt | 71 + .../test_ntpath.txt | 63 + .../test_numeric_tower.txt | 9 + .../test_opcache.txt | 26 + .../test_opcodes.txt | 8 + .../test_operator.txt | 94 + .../test_optparse.txt | 151 + .../test_ordered_dict.txt | 251 + .../unittest_tags_bytecode_dsl/test_os.txt | 192 + .../test_pathlib.txt | 312 ++ .../test_pep646_syntax.txt | 1 + .../test_pickle.txt | 730 +++ .../test_picklebuffer.txt | 8 + .../test_pickletools.txt | 132 + .../unittest_tags_bytecode_dsl/test_pipes.txt | 14 + .../unittest_tags_bytecode_dsl/test_pkg.txt | 8 + .../test_pkgutil.txt | 26 + .../test_platform.txt | 26 + .../test_plistlib.txt | 55 + .../unittest_tags_bytecode_dsl/test_popen.txt | 5 + .../test_poplib.txt | 70 + .../test_positional_only_arg.txt | 26 + .../unittest_tags_bytecode_dsl/test_posix.txt | 45 + .../test_posixpath.txt | 77 + .../unittest_tags_bytecode_dsl/test_pow.txt | 7 + .../test_pprint.txt | 43 + .../unittest_tags_bytecode_dsl/test_print.txt | 9 + .../test_profile.txt | 4 + .../test_property.txt | 21 + .../test_pstats.txt | 8 + .../unittest_tags_bytecode_dsl/test_pty.txt | 4 + .../test_pulldom.txt | 11 + .../unittest_tags_bytecode_dsl/test_pwd.txt | 3 + .../test_py_compile.txt | 32 + .../test_pyclbr.txt | 6 + .../unittest_tags_bytecode_dsl/test_pydoc.txt | 68 + .../test_pyexpat.txt | 38 + .../unittest_tags_bytecode_dsl/test_queue.txt | 52 + .../test_quopri.txt | 11 + .../unittest_tags_bytecode_dsl/test_raise.txt | 34 + .../test_random.txt | 98 + .../unittest_tags_bytecode_dsl/test_range.txt | 25 + .../unittest_tags_bytecode_dsl/test_re.txt | 143 + .../test_reprlib.txt | 20 + .../test_resource.txt | 4 + .../test_richcmp.txt | 11 + .../test_rlcompleter.txt | 7 + .../test_robotparser.txt | 63 + .../unittest_tags_bytecode_dsl/test_runpy.txt | 31 + .../unittest_tags_bytecode_dsl/test_sax.txt | 175 + .../unittest_tags_bytecode_dsl/test_sched.txt | 11 + .../unittest_tags_bytecode_dsl/test_scope.txt | 36 + .../test_script_helper.txt | 10 + .../test_secrets.txt | 11 + .../test_select.txt | 4 + .../test_selectors.txt | 34 + .../unittest_tags_bytecode_dsl/test_set.txt | 486 ++ .../test_setcomps.txt | 1 + .../test_shelve.txt | 182 + .../unittest_tags_bytecode_dsl/test_shlex.txt | 18 + .../test_shutil.txt | 122 + .../test_signal.txt | 7 + .../unittest_tags_bytecode_dsl/test_site.txt | 26 + .../unittest_tags_bytecode_dsl/test_slice.txt | 10 + .../unittest_tags_bytecode_dsl/test_smtpd.txt | 153 + .../test_smtplib.txt | 82 + .../test_sndhdr.txt | 2 + .../test_socket.txt | 218 + .../test_socketserver.txt | 20 + .../unittest_tags_bytecode_dsl/test_sort.txt | 19 + .../test_source_encoding.txt | 40 + .../test_sqlite3.txt | 416 ++ .../unittest_tags_bytecode_dsl/test_ssl.txt | 108 + .../unittest_tags_bytecode_dsl/test_stat.txt | 5 + .../test_statistics.txt | 347 ++ .../test_strftime.txt | 4 + .../test_string.txt | 38 + .../test_string_literals.txt | 17 + .../test_stringprep.txt | 1 + .../test_strptime.txt | 42 + .../test_strtod.txt | 8 + .../test_struct.txt | 30 + .../test_structseq.txt | 15 + .../test_subclassinit.txt | 17 + .../test_subprocess.txt | 170 + .../test_sundry.txt | 1 + .../unittest_tags_bytecode_dsl/test_super.txt | 18 + .../test_support.txt | 41 + .../test_syntax.txt | 27 + .../unittest_tags_bytecode_dsl/test_sys.txt | 39 + .../test_sysconfig.txt | 18 + .../test_tabnanny.txt | 19 + .../test_tarfile.txt | 552 ++ .../test_telnetlib.txt | 19 + .../test_tempfile.txt | 94 + .../test_termios.txt | 18 + .../test_textwrap.txt | 66 + .../test_thread.txt | 20 + .../test_threadedtempfile.txt | 1 + .../test_threading.txt | 158 + .../test_threading_local.txt | 15 + .../test_threadsignals.txt | 3 + .../unittest_tags_bytecode_dsl/test_time.txt | 32 + .../test_timeit.txt | 39 + .../test_timeout.txt | 12 + .../test_tokenize.txt | 95 + .../test_tomllib.txt | 13 + .../test_traceback.txt | 92 + .../test_tracemalloc.txt | 19 + .../unittest_tags_bytecode_dsl/test_tty.txt | 2 + .../unittest_tags_bytecode_dsl/test_tuple.txt | 28 + .../test_type_annotations.txt | 8 + .../test_type_comments.txt | 16 + .../test_typechecks.txt | 6 + .../unittest_tags_bytecode_dsl/test_types.txt | 99 + .../unittest_tags_bytecode_dsl/test_ucn.txt | 12 + .../unittest_tags_bytecode_dsl/test_unary.txt | 6 + .../test_unicode.txt | 112 + .../test_unicode_file_functions.txt | 30 + .../test_unicodedata.txt | 21 + .../test_unittest.txt | 457 ++ .../test_univnewlines.txt | 34 + .../test_unpack.txt | 2 + .../test_unparse.txt | 57 + .../test_urllib.txt | 101 + .../test_urllib2.txt | 68 + .../test_urllib2_localnet.txt | 21 + .../test_urllib2net.txt | 10 + .../test_urllib_response.txt | 4 + .../test_urllibnet.txt | 12 + .../test_urlparse.txt | 71 + .../test_userdict.txt | 24 + .../test_userlist.txt | 47 + .../test_userstring.txt | 55 + .../test_utf8_mode.txt | 4 + .../test_utf8source.txt | 3 + .../unittest_tags_bytecode_dsl/test_uu.txt | 2 + .../unittest_tags_bytecode_dsl/test_uuid.txt | 20 + .../unittest_tags_bytecode_dsl/test_venv.txt | 15 + .../test_warnings.txt | 113 + .../unittest_tags_bytecode_dsl/test_wave.txt | 90 + .../test_weakref.txt | 86 + .../test_weakset.txt | 36 + .../test_webbrowser.txt | 32 + .../unittest_tags_bytecode_dsl/test_with.txt | 50 + .../test_wsgiref.txt | 34 + .../test_xdrlib.txt | 6 + .../test_xml_dom_minicompat.txt | 11 + .../test_xml_etree.txt | 181 + .../test_xml_etree_c.txt | 181 + .../test_xmlrpc.txt | 92 + .../test_yield_from.txt | 32 + .../test_zipapp.txt | 31 + .../test_zipfile.txt | 280 + .../test_zipfile64.txt | 3 + .../test_zipimport.txt | 71 + .../test_zipimport_support.txt | 4 + .../unittest_tags_bytecode_dsl/test_zlib.txt | 54 + .../test_zoneinfo.txt | 184 + .../tests/unittest_tags_bytecode_dsl/todo.sh | 58 + .../oracle/graal/python/PythonLanguage.java | 50 +- .../builtins/modules/BuiltinFunctions.java | 13 +- .../modules/GraalPythonModuleBuiltins.java | 18 +- .../modules/MarshalModuleBuiltins.java | 300 +- .../modules/cext/PythonCextCodeBuiltins.java | 2 +- .../objects/asyncio/GetAwaitableNode.java | 2 + .../builtins/objects/asyncio/PAsyncGen.java | 4 +- .../builtins/objects/code/CodeBuiltins.java | 149 +- .../builtins/objects/code/CodeNodes.java | 46 +- .../python/builtins/objects/code/PCode.java | 111 +- .../python/builtins/objects/frame/PFrame.java | 44 +- .../builtins/objects/function/PArguments.java | 10 +- .../generator/CommonGeneratorBuiltins.java | 129 +- .../objects/generator/GeneratorBuiltins.java | 33 +- .../objects/generator/PGenerator.java | 195 +- .../objects/module/PythonFrozenModule.java | 11 +- .../python/builtins/objects/set/SetNodes.java | 2 + .../objects/superobject/SuperBuiltins.java | 41 +- .../objects/traceback/LazyTraceback.java | 6 +- .../MaterializeLazyTracebackNode.java | 2 +- .../objects/traceback/PTraceback.java | 15 +- .../objects/traceback/TracebackBuiltins.java | 6 +- .../python/compiler/BytecodeCodeUnit.java | 717 +++ .../graal/python/compiler/CodeUnit.java | 683 +-- .../python/compiler/CompilationScope.java | 4 +- .../python/compiler/CompilationUnit.java | 23 +- .../graal/python/compiler/Compiler.java | 87 +- .../bytecode_dsl/BaseBytecodeDSLVisitor.java | 493 ++ .../bytecode_dsl/BytecodeDSLCompiler.java | 161 + .../bytecode_dsl/RootNodeCompiler.java | 4584 +++++++++++++++++ .../graal/python/lib/PyNumberAddNode.java | 2 + .../graal/python/lib/PyNumberAndNode.java | 2 + .../python/lib/PyNumberFloorDivideNode.java | 2 + .../python/lib/PyNumberInPlaceAddNode.java | 2 + .../python/lib/PyNumberInPlaceAndNode.java | 2 + .../lib/PyNumberInPlaceFloorDivideNode.java | 2 + .../python/lib/PyNumberInPlaceLshiftNode.java | 9 +- .../PyNumberInPlaceMatrixMultiplyNode.java | 2 + .../lib/PyNumberInPlaceMultiplyNode.java | 2 + .../python/lib/PyNumberInPlaceOrNode.java | 2 + .../python/lib/PyNumberInPlacePowerNode.java | 2 + .../lib/PyNumberInPlaceRemainderNode.java | 2 + .../python/lib/PyNumberInPlaceRshiftNode.java | 2 + .../lib/PyNumberInPlaceSubtractNode.java | 2 + .../lib/PyNumberInPlaceTrueDivideNode.java | 2 + .../python/lib/PyNumberInPlaceXorNode.java | 2 + .../graal/python/lib/PyNumberInvertNode.java | 2 + .../graal/python/lib/PyNumberLshiftNode.java | 9 +- .../lib/PyNumberMatrixMultiplyNode.java | 3 +- .../python/lib/PyNumberMultiplyNode.java | 2 + .../python/lib/PyNumberNegativeNode.java | 2 + .../graal/python/lib/PyNumberOrNode.java | 2 + .../python/lib/PyNumberPositiveNode.java | 2 + .../graal/python/lib/PyNumberPowerNode.java | 2 + .../python/lib/PyNumberRemainderNode.java | 2 + .../graal/python/lib/PyNumberRshiftNode.java | 2 + .../python/lib/PyNumberSubtractNode.java | 2 + .../python/lib/PyNumberTrueDivideNode.java | 2 + .../graal/python/lib/PyNumberXorNode.java | 2 + .../python/lib/PyObjectIsNotTrueNode.java | 141 + .../graal/python/lib/PyObjectIsTrueNode.java | 3 +- .../fastpath/PyNumberLshiftFastPathsBase.java | 2 +- .../oracle/graal/python/nodes/PGuards.java | 6 + .../oracle/graal/python/nodes/PRootNode.java | 8 +- .../graal/python/nodes/StringLiterals.java | 1 + .../python/nodes/builtins/ListNodes.java | 2 + .../nodes/bytecode/BytecodeFrameInfo.java | 100 + .../python/nodes/bytecode/FrameInfo.java | 45 +- .../nodes/bytecode/GetYieldFromIterNode.java | 2 + .../nodes/bytecode/MakeFunctionNode.java | 8 +- .../graal/python/nodes/bytecode/NotNode.java | 2 + .../nodes/bytecode/PBytecodeRootNode.java | 48 +- .../python/nodes/bytecode/RaiseNode.java | 2 + .../nodes/bytecode/SetupAnnotationsNode.java | 2 + .../InstrumentationSupport.java | 6 +- .../bytecode_dsl/BytecodeDSLCodeUnit.java | 132 + .../bytecode_dsl/BytecodeDSLFrameInfo.java | 84 + ...PBytecodeDSLGeneratorFunctionRootNode.java | 134 + .../bytecode_dsl/PBytecodeDSLRootNode.java | 3431 ++++++++++++ .../graal/python/nodes/call/InvokeNode.java | 9 +- .../nodes/exception/ExceptMatchNode.java | 2 + .../nodes/frame/GetFrameLocalsNode.java | 84 +- .../nodes/frame/MaterializeFrameNode.java | 85 +- .../nodes/frame/ReadCallerFrameNode.java | 27 +- .../python/nodes/frame/ReadNameNode.java | 4 +- .../python/nodes/frame/WriteGlobalNode.java | 2 +- .../python/nodes/frame/WriteNameNode.java | 2 +- .../graal/python/nodes/object/IsNode.java | 36 +- .../python/runtime/ExecutionContext.java | 51 +- .../graal/python/runtime/PythonContext.java | 66 +- .../graal/python/runtime/PythonOptions.java | 6 + .../runtime/exception/ExceptionUtils.java | 51 +- .../python/runtime/exception/PException.java | 97 +- .../graal/python/runtime/object/PFactory.java | 23 +- .../oracle/graal/python/util/PythonUtils.java | 8 +- .../lib-python/3/test/support/__init__.py | 11 + .../lib-python/3/test/test_sys_settrace.py | 41 + mx.graalpython/mx_graalpython.py | 58 +- mx.graalpython/mx_graalpython_benchmark.py | 4 + mx.graalpython/suite.py | 2 +- 476 files changed, 39748 insertions(+), 1240 deletions(-) create mode 100644 graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/grammar/AsyncTests.java create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test__locale.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abstract_numbers.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_argparse.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_array.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ast.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asynchat.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncio.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncore.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_atexit.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_augassign.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_base64.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_baseexception.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bdb.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bigmem.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binascii.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binop.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bisect.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bool.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_buffer.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bufio.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_builtin.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bytes.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bz2.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_calendar.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_call.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_capi.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgi.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgitb.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_charmapcodec.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_class.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmath.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line_script.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code_module.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeccallbacks.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_cn.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_hk.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_iso2022.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_jp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_kr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_tw.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_cn.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_hk.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_jp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_kr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_tw.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecs.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeop.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_collections.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_colorsys.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compare.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compileall.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_complex.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_concurrent_futures.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_configparser.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contains.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_context.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib_async.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copy.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copyreg.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cppext.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_crypt.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_csv.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ctypes.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dataclasses.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm_dumb.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decimal.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decorators.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_defaultdict.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_deque.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descrtut.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dict.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictcomps.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictviews.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_difflib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_distutils.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest2.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_docxmlrpc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamic.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamicclassattribute.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_email.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ensurepip.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enum.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enumerate.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_eof.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_errno.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_except_star.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_group.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_hierarchy.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_variations.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exceptions.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_faulthandler.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fcntl.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_file.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_filecmp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileinput.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileio.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_float.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_flufl.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fnmatch.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_format.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fractions.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frame.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frozen.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fstring.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ftplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_funcattrs.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_functools.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_future_stmt.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generator_stop.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generators.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericalias.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericclass.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericpath.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genexps.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getopt.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getpass.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gettext.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_glob.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_global.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_grammar.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_graphlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gzip.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hash.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hashlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_heapq.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hmac.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_html.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_htmlparser.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookiejar.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookies.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httpservers.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imaplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imghdr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_import.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_importlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_index.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_inspect.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int_literal.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_io.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ipaddress.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_isinstance.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iter.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iterlen.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_itertools.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_json.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keyword.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keywordonlyarg.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_largefile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lib2to3.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_linecache.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_list.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_listcomps.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_locale.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_logging.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_long.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_longexp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lzma.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailbox.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailcap.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_marshal.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_math.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryio.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryview.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_metaclass.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mimetypes.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_minidom.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mmap.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_module.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multibytecodec.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multiprocessing_spawn.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_named_expressions.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_netrc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_nntplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ntpath.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_numeric_tower.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcache.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcodes.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_operator.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_optparse.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ordered_dict.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_os.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pathlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pep646_syntax.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickle.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_picklebuffer.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickletools.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pipes.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkg.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkgutil.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_platform.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_plistlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_popen.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_poplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_positional_only_arg.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posix.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posixpath.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pow.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pprint.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_print.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_profile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_property.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pstats.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pty.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pulldom.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pwd.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_py_compile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyclbr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pydoc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyexpat.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_queue.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_quopri.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_raise.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_random.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_range.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_re.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_reprlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_resource.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_richcmp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_rlcompleter.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_robotparser.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_runpy.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sax.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sched.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_scope.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_script_helper.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_secrets.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_select.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_selectors.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_set.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_setcomps.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shelve.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shlex.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shutil.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_signal.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_site.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_slice.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtpd.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtplib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sndhdr.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socket.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socketserver.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sort.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_source_encoding.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sqlite3.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ssl.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stat.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_statistics.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strftime.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string_literals.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stringprep.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strptime.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strtod.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_struct.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_structseq.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subclassinit.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subprocess.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sundry.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_super.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_support.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_syntax.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sys.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sysconfig.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tabnanny.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tarfile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_telnetlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tempfile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_termios.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_textwrap.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_thread.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadedtempfile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading_local.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadsignals.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_time.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeit.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeout.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tokenize.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tomllib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_traceback.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tracemalloc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tty.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tuple.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_annotations.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_comments.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_typechecks.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_types.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ucn.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unary.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode_file_functions.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicodedata.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unittest.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_univnewlines.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unpack.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unparse.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2_localnet.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2net.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib_response.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllibnet.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urlparse.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userdict.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userlist.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userstring.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8_mode.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8source.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uu.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uuid.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_venv.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_warnings.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wave.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakref.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakset.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_webbrowser.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_with.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wsgiref.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xdrlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_dom_minicompat.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree_c.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xmlrpc.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_yield_from.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipapp.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile64.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport_support.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zlib.txt create mode 100644 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zoneinfo.txt create mode 100755 graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/todo.sh create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/BytecodeCodeUnit.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BaseBytecodeDSLVisitor.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BytecodeDSLCompiler.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/BytecodeFrameInfo.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLCodeUnit.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLFrameInfo.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLGeneratorFunctionRootNode.java create mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java diff --git a/graalpython/com.oracle.graal.python.benchmarks/python/harness.py b/graalpython/com.oracle.graal.python.benchmarks/python/harness.py index 8d66b5e47f..15447459c2 100644 --- a/graalpython/com.oracle.graal.python.benchmarks/python/harness.py +++ b/graalpython/com.oracle.graal.python.benchmarks/python/harness.py @@ -501,6 +501,9 @@ def run_benchmark(args): else: print("### no extra module search paths specified") + if GRAALPYTHON: + print(f"### using bytecode DSL interpreter: {__graalpython__.is_bytecode_dsl_interpreter}") + BenchRunner(bench_file, bench_args=bench_args, iterations=iterations, warmup=warmup, warmup_runs=warmup_runs, startup=startup, live_results=live_results).run() diff --git a/graalpython/com.oracle.graal.python.frozen/freeze_modules.py b/graalpython/com.oracle.graal.python.frozen/freeze_modules.py index 11212e9233..f31ce5be5b 100644 --- a/graalpython/com.oracle.graal.python.frozen/freeze_modules.py +++ b/graalpython/com.oracle.graal.python.frozen/freeze_modules.py @@ -156,7 +156,7 @@ def relpath_for_posix_display(path, base): ####################################### # specs -def parse_frozen_specs(): +def parse_frozen_specs(suffix): seen = {} for section, specs in FROZEN: parsed = _parse_specs(specs, section, seen) @@ -165,7 +165,7 @@ def parse_frozen_specs(): try: source = seen[frozenid] except KeyError: - source = FrozenSource.from_id(frozenid, pyfile) + source = FrozenSource.from_id(frozenid, suffix, pyfile) seen[frozenid] = source else: assert not pyfile or pyfile == source.pyfile, item @@ -273,11 +273,11 @@ def iter_subs(): class FrozenSource(namedtuple('FrozenSource', 'id pyfile frozenfile deepfreezefile')): @classmethod - def from_id(cls, frozenid, pyfile=None): + def from_id(cls, frozenid, suffix, pyfile=None): if not pyfile: pyfile = os.path.join(STDLIB_DIR, *frozenid.split('.')) + '.py' #assert os.path.exists(pyfile), (frozenid, pyfile) - frozenfile = resolve_frozen_file(frozenid, FROZEN_MODULES_DIR) + frozenfile = resolve_frozen_file(frozenid, FROZEN_MODULES_DIR, suffix) return cls(frozenid, pyfile, frozenfile, STDLIB_DIR) @classmethod @@ -313,7 +313,7 @@ def isbootstrap(self): return self.id in BOOTSTRAP -def resolve_frozen_file(frozenid, destdir): +def resolve_frozen_file(frozenid, destdir, suffix): """Return the filename corresponding to the given frozen ID. For stdlib modules the ID will always be the full name @@ -326,7 +326,7 @@ def resolve_frozen_file(frozenid, destdir): raise ValueError(f'unsupported frozenid {frozenid!r}') # We use a consistent naming convention for all frozen modules. frozen_symbol = FrozenSource.resolve_symbol(frozenid) - frozenfile = f"Frozen{frozen_symbol}.bin" + frozenfile = f"Frozen{frozen_symbol}.{suffix}" if not destdir: return frozenfile @@ -644,11 +644,17 @@ def main(): STDLIB_DIR = os.path.abspath(parsed_args.python_lib) FROZEN_MODULES_DIR = os.path.abspath(parsed_args.binary_dir) + if __graalpython__.is_bytecode_dsl_interpreter: + suffix = "bin_dsl" + assert os.path.isdir(parsed_args.binary_dir), "Frozen modules for the DSL should be built after the manual bytecode interpreter." + else: + suffix = "bin" + shutil.rmtree(parsed_args.binary_dir, ignore_errors=True) + os.makedirs(parsed_args.binary_dir) + # create module specs - modules = list(parse_frozen_specs()) + modules = list(parse_frozen_specs(suffix)) - shutil.rmtree(parsed_args.binary_dir, ignore_errors=True) - os.makedirs(parsed_args.binary_dir) # write frozen module binary files containing the byte code and class files # used for importing the binary files for src in _iter_sources(modules): diff --git a/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/LambdaInFunctionTests.java b/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/LambdaInFunctionTests.java index 270463582c..9734ede0f0 100644 --- a/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/LambdaInFunctionTests.java +++ b/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/LambdaInFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/YieldStatementTests.java b/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/YieldStatementTests.java index 4c8f52b4bf..974894ae9d 100644 --- a/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/YieldStatementTests.java +++ b/graalpython/com.oracle.graal.python.pegparser.test/src/com/oracle/graal/python/pegparser/test/YieldStatementTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/Scope.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/Scope.java index d0c299cd24..07cde10a2f 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/Scope.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -229,11 +229,15 @@ public boolean isNested() { } public HashMap getSymbolsByType(EnumSet expectedFlags, int start) { + return getSymbolsByType(expectedFlags, EnumSet.noneOf(DefUse.class), start); + } + + public HashMap getSymbolsByType(EnumSet expectedFlags, EnumSet unexpectedFlags, int start) { int i = start; HashMap mapping = new HashMap<>(); for (String key : getSortedSymbols()) { EnumSet keyFlags = getUseOfName(key); - if (!Collections.disjoint(expectedFlags, keyFlags)) { + if (!Collections.disjoint(expectedFlags, keyFlags) && Collections.disjoint(unexpectedFlags, keyFlags)) { mapping.put(key, i++); } } diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/ScopeEnvironment.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/ScopeEnvironment.java index 2005dd65e2..bf816b5b0e 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/ScopeEnvironment.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/scope/ScopeEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -98,6 +98,7 @@ public class ScopeEnvironment { final HashMap blocks = new HashMap<>(); final ErrorCallback errorCallback; final EnumSet futureFeatures; + final HashMap parents = new HashMap<>(); public static ScopeEnvironment analyze(ModTy moduleNode, ErrorCallback errorCallback, EnumSet futureFeatures) { return new ScopeEnvironment(moduleNode, errorCallback, futureFeatures); @@ -128,6 +129,14 @@ public Scope lookupScope(SSTNode node) { return blocks.get(node); } + public Scope lookupParent(Scope scope) { + return parents.get(scope); + } + + public Scope getTopScope() { + return topScope; + } + private void analyzeBlock(Scope scope, HashSet bound, HashSet free, HashSet global) { HashSet local = new HashSet<>(); HashMap scopes = new HashMap<>(); @@ -328,6 +337,7 @@ private void enterBlock(String name, Scope.ScopeType type, SSTNode ast) { if (type == Scope.ScopeType.Annotation) { return; } + env.parents.put(scope, prev); if (prev != null) { prev.children.add(scope); } diff --git a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java index 83ffa47084..29045f263d 100644 --- a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java +++ b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java @@ -420,6 +420,11 @@ protected List preprocessArguments(List givenArgs, Map vs in traceback") def test_exceptions(): validate_repl(dedent("""\ >>> 1 / 0 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py b/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py index 32a150e911..38da878874 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_ssl_java_integration.py @@ -63,4 +63,9 @@ def test_load_default_verify_keystore(): """) env = os.environ.copy() env['JAVA_TOOL_OPTIONS'] = f"-Djavax.net.ssl.trustStore={curdir}/ssldata/signing_keystore.jks" - subprocess.run([sys.executable, '-c', src], env=env, check=True) + + args = [] + if __graalpython__.is_bytecode_dsl_interpreter: + args += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true'] + + subprocess.run([sys.executable, *args, '-c', src], env=env, check=True) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_sys_settrace.py b/graalpython/com.oracle.graal.python.test/src/tests/test_sys_settrace.py index 1216780454..dab08b66ac 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_sys_settrace.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_sys_settrace.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2025, 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 @@ -37,6 +37,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os import unittest import difflib import sys @@ -160,6 +161,7 @@ def test_case(self): return test_case +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: FrameSlotTypeException with reparsing") class TraceTests(unittest.TestCase): def trace(self, frame, event, arg): code = frame.f_code diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_traceback.py b/graalpython/com.oracle.graal.python.test/src/tests/test_traceback.py index b5c6c086f9..2bb294e41e 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_traceback.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_traceback.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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 @@ -36,8 +36,9 @@ # 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. - +import os import sys +import unittest def assert_raises(err, fn, *args, **kwargs): @@ -103,6 +104,7 @@ def test(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: correct generator tracebacks") def test_basic_traceback_generator(): def foo(): yield 1 @@ -139,6 +141,7 @@ def reraise(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: bug in comment above") def test_reraise_direct_generator(): def reraise(): try: @@ -398,6 +401,7 @@ def reraise_from_finally(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: bug in comment above") def test_finally_generator(): def test(): try: @@ -422,6 +426,7 @@ def test(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: bug in comment above") def test_reraise_from_finally_generator(): def reraise_from_finally(): try: @@ -486,6 +491,7 @@ def test(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: correct generator tracebacks") def test_generator_throw_existing(): try: raise OverflowError @@ -508,6 +514,7 @@ def test(): ) +@unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: correct generator tracebacks") def test_generator_throw_with_traceback(): try: raise NameError diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_venv.py b/graalpython/com.oracle.graal.python.test/src/tests/test_venv.py index 40dd495b05..6fed074ce1 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_venv.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_venv.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2025, 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 @@ -83,6 +83,7 @@ def test_venv_launcher(self): assert f"Hello {tmpfile}" in out, out assert f'Original "{sys.executable}"' in out, out + @unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: issue with passing Bytecode DSL flag to subprocesses") def test_create_and_use_basic_venv(self): run = None run_output = '' @@ -97,6 +98,7 @@ def test_create_and_use_basic_venv(self): if sys.platform != 'win32': assert self.env_dir in run, run + @unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: issue with passing Bytecode DSL flag to subprocesses") def test_create_and_use_venv_with_pip(self): run = None msg = '' diff --git a/graalpython/com.oracle.graal.python.test/src/tests/test_yield_from.py b/graalpython/com.oracle.graal.python.test/src/tests/test_yield_from.py index f57f6aa8c3..0b0799923b 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/test_yield_from.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/test_yield_from.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Copyright (c) 2018, 2025, Oracle and/or its affiliates. # Copyright (C) 1996-2017 Python Software Foundation # # Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 @@ -12,6 +12,7 @@ import unittest import sys +import os class TestPEP380Operation(unittest.TestCase): """ @@ -975,6 +976,7 @@ def g(): # for stack in spam(eggs(gen())): # self.assertTrue('spam' in stack and 'eggs' in stack) + @unittest.skipIf(os.environ.get('BYTECODE_DSL_INTERPRETER'), "TODO: bug in comment above") def test_custom_iterator_return(self): # See issue #15568 class MyIter: diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test__locale.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test__locale.txt new file mode 100644 index 0000000000..d7efaa61ba --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test__locale.txt @@ -0,0 +1,2 @@ +test.test__locale._LocaleTests.test_float_parsing @ linux-x86_64 +test.test__locale._LocaleTests.test_lc_numeric_localeconv @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abc.txt new file mode 100644 index 0000000000..7c0fed706c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abc.txt @@ -0,0 +1,36 @@ +test.test_abc.test_factory..TestABC.test_ABC_has___slots__ @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_ABC_helper @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_abstractclassmethod_basics @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_abstractmethod_basics @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_abstractmethod_integration @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_abstractproperty_basics @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_abstractstaticmethod_basics @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_all_new_methods_are_called @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_customdescriptors_with_abstractmethod @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_descriptors_with_abstractmethod @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_isinstance_invalidation @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_issubclass_bad_arguments @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_metaclass_abc @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_object_new_with_many_abstractmethods @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_object_new_with_one_abstractmethod @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_register_as_class_deco @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_register_non_class @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_registration_basics @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_registration_builtins @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_registration_edge_cases @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_registration_transitiveness @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_subclasshook @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_tricky_new_works @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_as_decorator @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_del @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_del_implementation @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_implementation @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_layered_implementation @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_multi_inheritance @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_new_abstractmethods @ linux-x86_64 +test.test_abc.test_factory..TestABC.test_update_non_abc @ linux-x86_64 +test.test_abc.test_factory..TestABCWithInitSubclass.test_positional_only_and_kwonlyargs_with_init_subclass @ linux-x86_64 +test.test_abc.test_factory..TestABCWithInitSubclass.test_works_with_init_subclass @ linux-x86_64 +test.test_abc.test_factory..TestLegacyAPI.test_abstractclassmethod_basics @ linux-x86_64 +test.test_abc.test_factory..TestLegacyAPI.test_abstractproperty_basics @ linux-x86_64 +test.test_abc.test_factory..TestLegacyAPI.test_abstractstaticmethod_basics @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abstract_numbers.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abstract_numbers.txt new file mode 100644 index 0000000000..5ef53c818f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_abstract_numbers.txt @@ -0,0 +1,3 @@ +test.test_abstract_numbers.TestNumbers.test_complex @ linux-x86_64 +test.test_abstract_numbers.TestNumbers.test_float @ linux-x86_64 +test.test_abstract_numbers.TestNumbers.test_int @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_argparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_argparse.txt new file mode 100644 index 0000000000..c1f78cf360 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_argparse.txt @@ -0,0 +1,1706 @@ +test.test_argparse.StdStreamTest.test_skip_invalid_stderr @ linux-x86_64 +test.test_argparse.StdStreamTest.test_skip_invalid_stdout @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestActionExtend.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestActionRegistration.test @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestActionUserDefined.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestActionsReturned.test_dest @ linux-x86_64 +test.test_argparse.TestActionsReturned.test_misc @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_1_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_1_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_1_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_1_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_1_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_2_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_2_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_2_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_2_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_2_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_3_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_3_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_3_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_3_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_3_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_None_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_None_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_None_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_None_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_None_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_oneormore_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_oneormore_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_oneormore_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_oneormore_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_oneormore_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_optional_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_optional_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_optional_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_optional_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_optional_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_parser_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_parser_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_parser_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_parser_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_parser_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_remainder_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_remainder_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_remainder_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_remainder_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_remainder_metavar_string @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length0 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length1 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length2 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length3 @ linux-x86_64 +test.test_argparse.TestAddArgumentMetavar.test_nargs_zeroormore_metavar_string @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_alias_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_alias_invocation @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_dest @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_error_alias_invocation @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_help_alternate_prefix_chars @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_help_blank @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_help_extra_prefix_chars @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_help_non_breaking_spaces @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_optional_subparsers @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_parse_args @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_parse_args_failures @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_parse_known_args @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_parser_command_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_required_subparsers_default @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_required_subparsers_no_destination_error @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_required_subparsers_via_attribute @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_required_subparsers_via_kwarg @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_subparser1_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_subparser2_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_subparser_title_help @ linux-x86_64 +test.test_argparse.TestAddSubparsers.test_wrong_argument_subparsers_no_destination_error @ linux-x86_64 +test.test_argparse.TestArgumentError.test_argument_error @ linux-x86_64 +test.test_argparse.TestArgumentTypeError.test_argument_type_error @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFile.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestArgumentsFromFileConverter.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_const @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalAction.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestBooleanOptionalActionRequired.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestConflictHandling.test_bad_type @ linux-x86_64 +test.test_argparse.TestConflictHandling.test_conflict_error @ linux-x86_64 +test.test_argparse.TestConflictHandling.test_resolve_error @ linux-x86_64 +test.test_argparse.TestConflictHandling.test_subparser_conflict @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestConstActionsMissingConstKwarg.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDefaultSuppress.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGrouping.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestDisallowLongAbbreviationAllowsShortGroupingPrefix.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestEmptyAndSpaceContainingArguments.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestEncoding.test_argparse_module_encoding @ linux-x86_64 +test.test_argparse.TestEncoding.test_test_argparse_module_encoding @ linux-x86_64 +test.test_argparse.TestExitOnError.test_exit_on_error_with_bad_args @ linux-x86_64 +test.test_argparse.TestExitOnError.test_exit_on_error_with_good_args @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeDefaults.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeMissingInitialization.test @ linux-x86_64 +test.test_argparse.TestFileTypeOpenArgs.test_open_args @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeR.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeRB.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeRepr.test_r @ linux-x86_64 +test.test_argparse.TestFileTypeRepr.test_r_1_replace @ linux-x86_64 +test.test_argparse.TestFileTypeRepr.test_r_latin @ linux-x86_64 +test.test_argparse.TestFileTypeRepr.test_w_big5_ignore @ linux-x86_64 +test.test_argparse.TestFileTypeRepr.test_wb_1 @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeW.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeWB.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeX.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestFileTypeXB.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestGetDefault.test_get_default @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpAlternatePrefixChars.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpArgumentDefaults.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionalGroups.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerOptionals.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpBiggerPositionals.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpMetavarTypeFormatter.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpNoHelpOptional.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpNone.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpNone.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpNone.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpNone.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpNone.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpNone.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpOnlyUserGroups.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpRawDescription.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpRawText.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpReformatting.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpRequiredOptional.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersOrdering.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSubparsersWithHelpOrdering.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptional.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressOptionalGroup.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressPositional.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpSuppressUsage.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpTupleMetavar.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsage.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProg.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgOptionsWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageLongProgPositionalsWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsOnlyWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsPositionalsWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageOptionalsWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsOnlyWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsagePositionalsWrap.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpUsageWithParentheses.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansion.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionNoArguments.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpVariableExpansionUsageSupplied.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpVersionAction.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpVersionActionSuppress.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingLongNames.test_print_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_format_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_format_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_print_file_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_print_help @ linux-x86_64 +test.test_argparse.TestHelpWrappingShortNames.test_print_usage @ linux-x86_64 +test.test_argparse.TestImportStar.test @ linux-x86_64 +test.test_argparse.TestImportStar.test_all_exports_everything_but_modules @ linux-x86_64 +test.test_argparse.TestIntermixedArgs.test_basic @ linux-x86_64 +test.test_argparse.TestIntermixedArgs.test_exclusive @ linux-x86_64 +test.test_argparse.TestIntermixedArgs.test_exclusive_incompatible @ linux-x86_64 +test.test_argparse.TestIntermixedArgs.test_remainder @ linux-x86_64 +test.test_argparse.TestIntermixedMessageContentError.test_missing_argument_name_in_message @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_invalid_action @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_invalid_keyword_arguments @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_invalid_option_strings @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_invalid_type @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_missing_destination @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_more_than_one_argument_actions @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_multiple_dest @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_no_argument_actions @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_no_argument_no_const_actions @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_parsers_action_missing_params @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_required_const_actions @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_required_positional @ linux-x86_64 +test.test_argparse.TestInvalidArgumentConstructors.test_user_defined_action @ linux-x86_64 +test.test_argparse.TestInvalidNargs.test_nargs_alphabetic @ linux-x86_64 +test.test_argparse.TestInvalidNargs.test_nargs_zero @ linux-x86_64 +test.test_argparse.TestMessageContentError.test_missing_argument_name_in_message @ linux-x86_64 +test.test_argparse.TestMessageContentError.test_optional_optional_not_in_message @ linux-x86_64 +test.test_argparse.TestMessageContentError.test_optional_positional_not_in_message @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressed.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveFirstSuppressedParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrors.test_empty_group @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrors.test_help @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrors.test_invalid_add_argument @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrors.test_invalid_add_argument_group @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrorsParent.test_empty_group @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrorsParent.test_help @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrorsParent.test_invalid_add_argument @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveGroupErrorsParent.test_invalid_add_argument_group @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveInGroup.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLong.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveLongParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressed.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveManySuppressedParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveNested.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveNested.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveNested.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveNested.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositional.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalAndPositionalParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixedParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixed.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveOptionalsMixedParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimple.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_failures_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_failures_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_help_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_help_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_successes_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_successes_when_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_usage_when_not_required @ linux-x86_64 +test.test_argparse.TestMutuallyExclusiveSimpleParent.test_usage_when_required @ linux-x86_64 +test.test_argparse.TestNamespace.test_constructor @ linux-x86_64 +test.test_argparse.TestNamespace.test_equality @ linux-x86_64 +test.test_argparse.TestNamespace.test_equality_returns_notimplemented @ linux-x86_64 +test.test_argparse.TestNamespaceContainsSimple.test_empty @ linux-x86_64 +test.test_argparse.TestNamespaceContainsSimple.test_non_empty @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestNargsRemainder.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestNargsZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionLike.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppend.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConst.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendConstWithDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionAppendWithDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionCount.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreConst.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreFalse.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsActionStoreTrue.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAllowLongAbbreviation.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlmostNumericAndPositionals.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixChars.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsAddedHelp.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsAlternatePrefixCharsMultipleShortArgs.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsChoices.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDest.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviation.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDisallowLongAbbreviationPrefixChars.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDash.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPartialMatch.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsDoubleDashPrefixMatch.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_alternate_help_version @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_help_version_extra_arguments @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_no_help @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_version @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_version_action @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_version_format @ linux-x86_64 +test.test_argparse.TestOptionalsHelpVersionActions.test_version_no_help @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargs3.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOneOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsOptional.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNargsZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumeric.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsNumericAndPositionals.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsRequired.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsShortLong.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDash.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashAmbiguous.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashCombined.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashLong.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDashSubsetAmbiguous.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestOptionalsSingleDoubleDash.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestParentParsers.test_conflicting_parents @ linux-x86_64 +test.test_argparse.TestParentParsers.test_conflicting_parents_mutex @ linux-x86_64 +test.test_argparse.TestParentParsers.test_groups_parents @ linux-x86_64 +test.test_argparse.TestParentParsers.test_multiple_parents @ linux-x86_64 +test.test_argparse.TestParentParsers.test_multiple_parents_mutex @ linux-x86_64 +test.test_argparse.TestParentParsers.test_parent_help @ linux-x86_64 +test.test_argparse.TestParentParsers.test_same_argument_name_parents @ linux-x86_64 +test.test_argparse.TestParentParsers.test_single_granparent_mutex @ linux-x86_64 +test.test_argparse.TestParentParsers.test_single_parent @ linux-x86_64 +test.test_argparse.TestParentParsers.test_single_parent_mutex @ linux-x86_64 +test.test_argparse.TestParentParsers.test_subparser_parents @ linux-x86_64 +test.test_argparse.TestParentParsers.test_subparser_parents_mutex @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_arguments_list @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_arguments_list_positional @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_arguments_tuple @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_arguments_tuple_positional @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_mixed @ linux-x86_64 +test.test_argparse.TestParseKnownArgs.test_optionals @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestParserDefault42.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestParserDefaultSuppress.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsActionAppend.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesInt.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsChoicesString.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsGroups.test_group_first @ linux-x86_64 +test.test_argparse.TestPositionalsGroups.test_interleaved_groups @ linux-x86_64 +test.test_argparse.TestPositionalsGroups.test_nongroup_first @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2None.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2OneOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2Optional.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargs2ZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNone1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneNone.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOneOrMore1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneOptional1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsNoneZeroOrMore1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMore1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOneOrMoreNone.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptional1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalConvertedDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalNone.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOneOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalOptional.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsOptionalZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMore1.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreDefault.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPositionalsNargsZeroOrMoreNone.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestPrefixCharacterOnlyArguments.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_no_args @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_on_parent_and_subparser @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_parents @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_same_as_add_argument @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_same_as_add_argument_group @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_subparsers @ linux-x86_64 +test.test_argparse.TestSetDefaults.test_set_defaults_with_args @ linux-x86_64 +test.test_argparse.TestShortColumns.test_format_help @ linux-x86_64 +test.test_argparse.TestShortColumns.test_format_usage @ linux-x86_64 +test.test_argparse.TestShortColumns.test_print_file_help @ linux-x86_64 +test.test_argparse.TestShortColumns.test_print_file_usage @ linux-x86_64 +test.test_argparse.TestShortColumns.test_print_help @ linux-x86_64 +test.test_argparse.TestShortColumns.test_print_usage @ linux-x86_64 +test.test_argparse.TestStrings.test_argument @ linux-x86_64 +test.test_argparse.TestStrings.test_namespace @ linux-x86_64 +test.test_argparse.TestStrings.test_namespace_kwargs_and_starkwargs_notidentifier @ linux-x86_64 +test.test_argparse.TestStrings.test_namespace_starkwargs_identifier @ linux-x86_64 +test.test_argparse.TestStrings.test_namespace_starkwargs_notidentifier @ linux-x86_64 +test.test_argparse.TestStrings.test_optional @ linux-x86_64 +test.test_argparse.TestStrings.test_parser @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeCallable.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeClassicClass.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestTypeFunctionCallOnlyOnce.test_type_function_call_only_once @ linux-x86_64 +test.test_argparse.TestTypeFunctionCalledOnDefault.test_issue_15906 @ linux-x86_64 +test.test_argparse.TestTypeFunctionCalledOnDefault.test_no_double_type_conversion_of_default @ linux-x86_64 +test.test_argparse.TestTypeFunctionCalledOnDefault.test_type_function_call_with_non_string_default @ linux-x86_64 +test.test_argparse.TestTypeFunctionCalledOnDefault.test_type_function_call_with_string_default @ linux-x86_64 +test.test_argparse.TestTypeRegistration.test @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_failures_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_many_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_many_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_no_groups_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_no_groups_sysargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_one_group_listargs @ linux-x86_64 +test.test_argparse.TestTypeUserDefined.test_successes_one_group_sysargs @ linux-x86_64 +test.test_argparse.TestWrappingMetavar.test_help_with_metavar @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_array.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_array.txt new file mode 100644 index 0000000000..ef892153ba --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_array.txt @@ -0,0 +1,731 @@ +test.test_array.ArrayReconstructorTest.test_error @ linux-x86_64 +test.test_array.ArrayReconstructorTest.test_numbers @ linux-x86_64 +test.test_array.ArrayReconstructorTest.test_unicode @ linux-x86_64 +test.test_array.ByteTest.test_add @ linux-x86_64 +test.test_array.ByteTest.test_assignment @ linux-x86_64 +test.test_array.ByteTest.test_buffer @ linux-x86_64 +test.test_array.ByteTest.test_buffer_info @ linux-x86_64 +test.test_array.ByteTest.test_bug_782369 @ linux-x86_64 +test.test_array.ByteTest.test_byteswap @ linux-x86_64 +test.test_array.ByteTest.test_cmp @ linux-x86_64 +test.test_array.ByteTest.test_constructor @ linux-x86_64 +test.test_array.ByteTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.ByteTest.test_copy @ linux-x86_64 +test.test_array.ByteTest.test_count @ linux-x86_64 +test.test_array.ByteTest.test_coveritertraverse @ linux-x86_64 +test.test_array.ByteTest.test_create_from_bytes @ linux-x86_64 +test.test_array.ByteTest.test_deepcopy @ linux-x86_64 +test.test_array.ByteTest.test_delitem @ linux-x86_64 +test.test_array.ByteTest.test_delslice @ linux-x86_64 +test.test_array.ByteTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.ByteTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.ByteTest.test_extend @ linux-x86_64 +test.test_array.ByteTest.test_extended_getslice @ linux-x86_64 +test.test_array.ByteTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.ByteTest.test_extslice @ linux-x86_64 +test.test_array.ByteTest.test_filewrite @ linux-x86_64 +test.test_array.ByteTest.test_fromarray @ linux-x86_64 +test.test_array.ByteTest.test_frombytearray @ linux-x86_64 +test.test_array.ByteTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.ByteTest.test_getitem @ linux-x86_64 +test.test_array.ByteTest.test_getslice @ linux-x86_64 +test.test_array.ByteTest.test_iadd @ linux-x86_64 +test.test_array.ByteTest.test_imul @ linux-x86_64 +test.test_array.ByteTest.test_index @ linux-x86_64 +test.test_array.ByteTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.ByteTest.test_insert @ linux-x86_64 +test.test_array.ByteTest.test_iterationcontains @ linux-x86_64 +test.test_array.ByteTest.test_iterator_pickle @ linux-x86_64 +test.test_array.ByteTest.test_len @ linux-x86_64 +test.test_array.ByteTest.test_mul @ linux-x86_64 +test.test_array.ByteTest.test_overflow @ linux-x86_64 +test.test_array.ByteTest.test_pickle @ linux-x86_64 +test.test_array.ByteTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.ByteTest.test_pop @ linux-x86_64 +test.test_array.ByteTest.test_reduce_ex @ linux-x86_64 +test.test_array.ByteTest.test_remove @ linux-x86_64 +test.test_array.ByteTest.test_repr @ linux-x86_64 +test.test_array.ByteTest.test_reverse @ linux-x86_64 +test.test_array.ByteTest.test_reverse_iterator @ linux-x86_64 +test.test_array.ByteTest.test_setitem @ linux-x86_64 +test.test_array.ByteTest.test_setslice @ linux-x86_64 +test.test_array.ByteTest.test_str @ linux-x86_64 +test.test_array.ByteTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.ByteTest.test_subclassing @ linux-x86_64 +test.test_array.ByteTest.test_tofrombytes @ linux-x86_64 +test.test_array.ByteTest.test_tofromfile @ linux-x86_64 +test.test_array.ByteTest.test_tofromlist @ linux-x86_64 +test.test_array.ByteTest.test_type_error @ linux-x86_64 +test.test_array.DoubleTest.test_add @ linux-x86_64 +test.test_array.DoubleTest.test_alloc_overflow @ linux-x86_64 +test.test_array.DoubleTest.test_assignment @ linux-x86_64 +test.test_array.DoubleTest.test_buffer @ linux-x86_64 +test.test_array.DoubleTest.test_buffer_info @ linux-x86_64 +test.test_array.DoubleTest.test_bug_782369 @ linux-x86_64 +test.test_array.DoubleTest.test_byteswap @ linux-x86_64 +test.test_array.DoubleTest.test_cmp @ linux-x86_64 +test.test_array.DoubleTest.test_constructor @ linux-x86_64 +test.test_array.DoubleTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.DoubleTest.test_copy @ linux-x86_64 +test.test_array.DoubleTest.test_count @ linux-x86_64 +test.test_array.DoubleTest.test_coveritertraverse @ linux-x86_64 +test.test_array.DoubleTest.test_create_from_bytes @ linux-x86_64 +test.test_array.DoubleTest.test_deepcopy @ linux-x86_64 +test.test_array.DoubleTest.test_delitem @ linux-x86_64 +test.test_array.DoubleTest.test_delslice @ linux-x86_64 +test.test_array.DoubleTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.DoubleTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.DoubleTest.test_extend @ linux-x86_64 +test.test_array.DoubleTest.test_extended_getslice @ linux-x86_64 +test.test_array.DoubleTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.DoubleTest.test_extslice @ linux-x86_64 +test.test_array.DoubleTest.test_filewrite @ linux-x86_64 +test.test_array.DoubleTest.test_fromarray @ linux-x86_64 +test.test_array.DoubleTest.test_frombytearray @ linux-x86_64 +test.test_array.DoubleTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.DoubleTest.test_getitem @ linux-x86_64 +test.test_array.DoubleTest.test_getslice @ linux-x86_64 +test.test_array.DoubleTest.test_iadd @ linux-x86_64 +test.test_array.DoubleTest.test_imul @ linux-x86_64 +test.test_array.DoubleTest.test_index @ linux-x86_64 +test.test_array.DoubleTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.DoubleTest.test_insert @ linux-x86_64 +test.test_array.DoubleTest.test_iterationcontains @ linux-x86_64 +test.test_array.DoubleTest.test_iterator_pickle @ linux-x86_64 +test.test_array.DoubleTest.test_len @ linux-x86_64 +test.test_array.DoubleTest.test_mul @ linux-x86_64 +test.test_array.DoubleTest.test_nan @ linux-x86_64 +test.test_array.DoubleTest.test_pickle @ linux-x86_64 +test.test_array.DoubleTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.DoubleTest.test_pop @ linux-x86_64 +test.test_array.DoubleTest.test_reduce_ex @ linux-x86_64 +test.test_array.DoubleTest.test_remove @ linux-x86_64 +test.test_array.DoubleTest.test_repr @ linux-x86_64 +test.test_array.DoubleTest.test_reverse @ linux-x86_64 +test.test_array.DoubleTest.test_reverse_iterator @ linux-x86_64 +test.test_array.DoubleTest.test_setitem @ linux-x86_64 +test.test_array.DoubleTest.test_setslice @ linux-x86_64 +test.test_array.DoubleTest.test_str @ linux-x86_64 +test.test_array.DoubleTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.DoubleTest.test_subclassing @ linux-x86_64 +test.test_array.DoubleTest.test_tofrombytes @ linux-x86_64 +test.test_array.DoubleTest.test_tofromfile @ linux-x86_64 +test.test_array.DoubleTest.test_tofromlist @ linux-x86_64 +test.test_array.FloatTest.test_add @ linux-x86_64 +test.test_array.FloatTest.test_assignment @ linux-x86_64 +test.test_array.FloatTest.test_buffer @ linux-x86_64 +test.test_array.FloatTest.test_buffer_info @ linux-x86_64 +test.test_array.FloatTest.test_bug_782369 @ linux-x86_64 +test.test_array.FloatTest.test_byteswap @ linux-x86_64 +test.test_array.FloatTest.test_cmp @ linux-x86_64 +test.test_array.FloatTest.test_constructor @ linux-x86_64 +test.test_array.FloatTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.FloatTest.test_copy @ linux-x86_64 +test.test_array.FloatTest.test_count @ linux-x86_64 +test.test_array.FloatTest.test_coveritertraverse @ linux-x86_64 +test.test_array.FloatTest.test_create_from_bytes @ linux-x86_64 +test.test_array.FloatTest.test_deepcopy @ linux-x86_64 +test.test_array.FloatTest.test_delitem @ linux-x86_64 +test.test_array.FloatTest.test_delslice @ linux-x86_64 +test.test_array.FloatTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.FloatTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.FloatTest.test_extend @ linux-x86_64 +test.test_array.FloatTest.test_extended_getslice @ linux-x86_64 +test.test_array.FloatTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.FloatTest.test_extslice @ linux-x86_64 +test.test_array.FloatTest.test_filewrite @ linux-x86_64 +test.test_array.FloatTest.test_fromarray @ linux-x86_64 +test.test_array.FloatTest.test_frombytearray @ linux-x86_64 +test.test_array.FloatTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.FloatTest.test_getitem @ linux-x86_64 +test.test_array.FloatTest.test_getslice @ linux-x86_64 +test.test_array.FloatTest.test_iadd @ linux-x86_64 +test.test_array.FloatTest.test_imul @ linux-x86_64 +test.test_array.FloatTest.test_index @ linux-x86_64 +test.test_array.FloatTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.FloatTest.test_insert @ linux-x86_64 +test.test_array.FloatTest.test_iterationcontains @ linux-x86_64 +test.test_array.FloatTest.test_iterator_pickle @ linux-x86_64 +test.test_array.FloatTest.test_len @ linux-x86_64 +test.test_array.FloatTest.test_mul @ linux-x86_64 +test.test_array.FloatTest.test_nan @ linux-x86_64 +test.test_array.FloatTest.test_pickle @ linux-x86_64 +test.test_array.FloatTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.FloatTest.test_pop @ linux-x86_64 +test.test_array.FloatTest.test_reduce_ex @ linux-x86_64 +test.test_array.FloatTest.test_remove @ linux-x86_64 +test.test_array.FloatTest.test_repr @ linux-x86_64 +test.test_array.FloatTest.test_reverse @ linux-x86_64 +test.test_array.FloatTest.test_reverse_iterator @ linux-x86_64 +test.test_array.FloatTest.test_setitem @ linux-x86_64 +test.test_array.FloatTest.test_setslice @ linux-x86_64 +test.test_array.FloatTest.test_str @ linux-x86_64 +test.test_array.FloatTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.FloatTest.test_subclassing @ linux-x86_64 +test.test_array.FloatTest.test_tofrombytes @ linux-x86_64 +test.test_array.FloatTest.test_tofromfile @ linux-x86_64 +test.test_array.FloatTest.test_tofromlist @ linux-x86_64 +test.test_array.IntTest.test_add @ linux-x86_64 +test.test_array.IntTest.test_assignment @ linux-x86_64 +test.test_array.IntTest.test_buffer @ linux-x86_64 +test.test_array.IntTest.test_buffer_info @ linux-x86_64 +test.test_array.IntTest.test_bug_782369 @ linux-x86_64 +test.test_array.IntTest.test_byteswap @ linux-x86_64 +test.test_array.IntTest.test_cmp @ linux-x86_64 +test.test_array.IntTest.test_constructor @ linux-x86_64 +test.test_array.IntTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.IntTest.test_copy @ linux-x86_64 +test.test_array.IntTest.test_count @ linux-x86_64 +test.test_array.IntTest.test_coveritertraverse @ linux-x86_64 +test.test_array.IntTest.test_create_from_bytes @ linux-x86_64 +test.test_array.IntTest.test_deepcopy @ linux-x86_64 +test.test_array.IntTest.test_delitem @ linux-x86_64 +test.test_array.IntTest.test_delslice @ linux-x86_64 +test.test_array.IntTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.IntTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.IntTest.test_extend @ linux-x86_64 +test.test_array.IntTest.test_extended_getslice @ linux-x86_64 +test.test_array.IntTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.IntTest.test_extslice @ linux-x86_64 +test.test_array.IntTest.test_filewrite @ linux-x86_64 +test.test_array.IntTest.test_fromarray @ linux-x86_64 +test.test_array.IntTest.test_frombytearray @ linux-x86_64 +test.test_array.IntTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.IntTest.test_getitem @ linux-x86_64 +test.test_array.IntTest.test_getslice @ linux-x86_64 +test.test_array.IntTest.test_iadd @ linux-x86_64 +test.test_array.IntTest.test_imul @ linux-x86_64 +test.test_array.IntTest.test_index @ linux-x86_64 +test.test_array.IntTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.IntTest.test_insert @ linux-x86_64 +test.test_array.IntTest.test_iterationcontains @ linux-x86_64 +test.test_array.IntTest.test_iterator_pickle @ linux-x86_64 +test.test_array.IntTest.test_len @ linux-x86_64 +test.test_array.IntTest.test_mul @ linux-x86_64 +test.test_array.IntTest.test_overflow @ linux-x86_64 +test.test_array.IntTest.test_pickle @ linux-x86_64 +test.test_array.IntTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.IntTest.test_pop @ linux-x86_64 +test.test_array.IntTest.test_reduce_ex @ linux-x86_64 +test.test_array.IntTest.test_remove @ linux-x86_64 +test.test_array.IntTest.test_repr @ linux-x86_64 +test.test_array.IntTest.test_reverse @ linux-x86_64 +test.test_array.IntTest.test_reverse_iterator @ linux-x86_64 +test.test_array.IntTest.test_setitem @ linux-x86_64 +test.test_array.IntTest.test_setslice @ linux-x86_64 +test.test_array.IntTest.test_str @ linux-x86_64 +test.test_array.IntTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.IntTest.test_subclassing @ linux-x86_64 +test.test_array.IntTest.test_tofrombytes @ linux-x86_64 +test.test_array.IntTest.test_tofromfile @ linux-x86_64 +test.test_array.IntTest.test_tofromlist @ linux-x86_64 +test.test_array.IntTest.test_type_error @ linux-x86_64 +test.test_array.LargeArrayTest.test_access @ linux-x86_64 +test.test_array.LargeArrayTest.test_append @ linux-x86_64 +test.test_array.LargeArrayTest.test_count @ linux-x86_64 +test.test_array.LargeArrayTest.test_example_data @ linux-x86_64 +test.test_array.LargeArrayTest.test_extend @ linux-x86_64 +test.test_array.LargeArrayTest.test_frombytes @ linux-x86_64 +test.test_array.LargeArrayTest.test_fromlist @ linux-x86_64 +test.test_array.LargeArrayTest.test_index @ linux-x86_64 +test.test_array.LargeArrayTest.test_insert @ linux-x86_64 +test.test_array.LargeArrayTest.test_pop @ linux-x86_64 +test.test_array.LargeArrayTest.test_remove @ linux-x86_64 +test.test_array.LargeArrayTest.test_reverse @ linux-x86_64 +test.test_array.LargeArrayTest.test_slice @ linux-x86_64 +test.test_array.LargeArrayTest.test_tolist @ linux-x86_64 +test.test_array.LongLongTest.test_add @ linux-x86_64 +test.test_array.LongLongTest.test_assignment @ linux-x86_64 +test.test_array.LongLongTest.test_buffer @ linux-x86_64 +test.test_array.LongLongTest.test_buffer_info @ linux-x86_64 +test.test_array.LongLongTest.test_bug_782369 @ linux-x86_64 +test.test_array.LongLongTest.test_byteswap @ linux-x86_64 +test.test_array.LongLongTest.test_cmp @ linux-x86_64 +test.test_array.LongLongTest.test_constructor @ linux-x86_64 +test.test_array.LongLongTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.LongLongTest.test_copy @ linux-x86_64 +test.test_array.LongLongTest.test_count @ linux-x86_64 +test.test_array.LongLongTest.test_coveritertraverse @ linux-x86_64 +test.test_array.LongLongTest.test_create_from_bytes @ linux-x86_64 +test.test_array.LongLongTest.test_deepcopy @ linux-x86_64 +test.test_array.LongLongTest.test_delitem @ linux-x86_64 +test.test_array.LongLongTest.test_delslice @ linux-x86_64 +test.test_array.LongLongTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.LongLongTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.LongLongTest.test_extend @ linux-x86_64 +test.test_array.LongLongTest.test_extended_getslice @ linux-x86_64 +test.test_array.LongLongTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.LongLongTest.test_extslice @ linux-x86_64 +test.test_array.LongLongTest.test_filewrite @ linux-x86_64 +test.test_array.LongLongTest.test_fromarray @ linux-x86_64 +test.test_array.LongLongTest.test_frombytearray @ linux-x86_64 +test.test_array.LongLongTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.LongLongTest.test_getitem @ linux-x86_64 +test.test_array.LongLongTest.test_getslice @ linux-x86_64 +test.test_array.LongLongTest.test_iadd @ linux-x86_64 +test.test_array.LongLongTest.test_imul @ linux-x86_64 +test.test_array.LongLongTest.test_index @ linux-x86_64 +test.test_array.LongLongTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.LongLongTest.test_insert @ linux-x86_64 +test.test_array.LongLongTest.test_iterationcontains @ linux-x86_64 +test.test_array.LongLongTest.test_iterator_pickle @ linux-x86_64 +test.test_array.LongLongTest.test_len @ linux-x86_64 +test.test_array.LongLongTest.test_mul @ linux-x86_64 +test.test_array.LongLongTest.test_overflow @ linux-x86_64 +test.test_array.LongLongTest.test_pickle @ linux-x86_64 +test.test_array.LongLongTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.LongLongTest.test_pop @ linux-x86_64 +test.test_array.LongLongTest.test_reduce_ex @ linux-x86_64 +test.test_array.LongLongTest.test_remove @ linux-x86_64 +test.test_array.LongLongTest.test_repr @ linux-x86_64 +test.test_array.LongLongTest.test_reverse @ linux-x86_64 +test.test_array.LongLongTest.test_reverse_iterator @ linux-x86_64 +test.test_array.LongLongTest.test_setitem @ linux-x86_64 +test.test_array.LongLongTest.test_setslice @ linux-x86_64 +test.test_array.LongLongTest.test_str @ linux-x86_64 +test.test_array.LongLongTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.LongLongTest.test_subclassing @ linux-x86_64 +test.test_array.LongLongTest.test_tofrombytes @ linux-x86_64 +test.test_array.LongLongTest.test_tofromfile @ linux-x86_64 +test.test_array.LongLongTest.test_tofromlist @ linux-x86_64 +test.test_array.LongLongTest.test_type_error @ linux-x86_64 +test.test_array.LongTest.test_add @ linux-x86_64 +test.test_array.LongTest.test_assignment @ linux-x86_64 +test.test_array.LongTest.test_buffer @ linux-x86_64 +test.test_array.LongTest.test_buffer_info @ linux-x86_64 +test.test_array.LongTest.test_bug_782369 @ linux-x86_64 +test.test_array.LongTest.test_byteswap @ linux-x86_64 +test.test_array.LongTest.test_cmp @ linux-x86_64 +test.test_array.LongTest.test_constructor @ linux-x86_64 +test.test_array.LongTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.LongTest.test_copy @ linux-x86_64 +test.test_array.LongTest.test_count @ linux-x86_64 +test.test_array.LongTest.test_coveritertraverse @ linux-x86_64 +test.test_array.LongTest.test_create_from_bytes @ linux-x86_64 +test.test_array.LongTest.test_deepcopy @ linux-x86_64 +test.test_array.LongTest.test_delitem @ linux-x86_64 +test.test_array.LongTest.test_delslice @ linux-x86_64 +test.test_array.LongTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.LongTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.LongTest.test_extend @ linux-x86_64 +test.test_array.LongTest.test_extended_getslice @ linux-x86_64 +test.test_array.LongTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.LongTest.test_extslice @ linux-x86_64 +test.test_array.LongTest.test_filewrite @ linux-x86_64 +test.test_array.LongTest.test_fromarray @ linux-x86_64 +test.test_array.LongTest.test_frombytearray @ linux-x86_64 +test.test_array.LongTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.LongTest.test_getitem @ linux-x86_64 +test.test_array.LongTest.test_getslice @ linux-x86_64 +test.test_array.LongTest.test_iadd @ linux-x86_64 +test.test_array.LongTest.test_imul @ linux-x86_64 +test.test_array.LongTest.test_index @ linux-x86_64 +test.test_array.LongTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.LongTest.test_insert @ linux-x86_64 +test.test_array.LongTest.test_iterationcontains @ linux-x86_64 +test.test_array.LongTest.test_iterator_pickle @ linux-x86_64 +test.test_array.LongTest.test_len @ linux-x86_64 +test.test_array.LongTest.test_mul @ linux-x86_64 +test.test_array.LongTest.test_overflow @ linux-x86_64 +test.test_array.LongTest.test_pickle @ linux-x86_64 +test.test_array.LongTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.LongTest.test_pop @ linux-x86_64 +test.test_array.LongTest.test_reduce_ex @ linux-x86_64 +test.test_array.LongTest.test_remove @ linux-x86_64 +test.test_array.LongTest.test_repr @ linux-x86_64 +test.test_array.LongTest.test_reverse @ linux-x86_64 +test.test_array.LongTest.test_reverse_iterator @ linux-x86_64 +test.test_array.LongTest.test_setitem @ linux-x86_64 +test.test_array.LongTest.test_setslice @ linux-x86_64 +test.test_array.LongTest.test_str @ linux-x86_64 +test.test_array.LongTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.LongTest.test_subclassing @ linux-x86_64 +test.test_array.LongTest.test_tofrombytes @ linux-x86_64 +test.test_array.LongTest.test_tofromfile @ linux-x86_64 +test.test_array.LongTest.test_tofromlist @ linux-x86_64 +test.test_array.LongTest.test_type_error @ linux-x86_64 +test.test_array.MiscTest.test_empty @ linux-x86_64 +test.test_array.ShortTest.test_add @ linux-x86_64 +test.test_array.ShortTest.test_assignment @ linux-x86_64 +test.test_array.ShortTest.test_buffer @ linux-x86_64 +test.test_array.ShortTest.test_buffer_info @ linux-x86_64 +test.test_array.ShortTest.test_bug_782369 @ linux-x86_64 +test.test_array.ShortTest.test_byteswap @ linux-x86_64 +test.test_array.ShortTest.test_cmp @ linux-x86_64 +test.test_array.ShortTest.test_constructor @ linux-x86_64 +test.test_array.ShortTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.ShortTest.test_copy @ linux-x86_64 +test.test_array.ShortTest.test_count @ linux-x86_64 +test.test_array.ShortTest.test_coveritertraverse @ linux-x86_64 +test.test_array.ShortTest.test_create_from_bytes @ linux-x86_64 +test.test_array.ShortTest.test_deepcopy @ linux-x86_64 +test.test_array.ShortTest.test_delitem @ linux-x86_64 +test.test_array.ShortTest.test_delslice @ linux-x86_64 +test.test_array.ShortTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.ShortTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.ShortTest.test_extend @ linux-x86_64 +test.test_array.ShortTest.test_extended_getslice @ linux-x86_64 +test.test_array.ShortTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.ShortTest.test_extslice @ linux-x86_64 +test.test_array.ShortTest.test_filewrite @ linux-x86_64 +test.test_array.ShortTest.test_fromarray @ linux-x86_64 +test.test_array.ShortTest.test_frombytearray @ linux-x86_64 +test.test_array.ShortTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.ShortTest.test_getitem @ linux-x86_64 +test.test_array.ShortTest.test_getslice @ linux-x86_64 +test.test_array.ShortTest.test_iadd @ linux-x86_64 +test.test_array.ShortTest.test_imul @ linux-x86_64 +test.test_array.ShortTest.test_index @ linux-x86_64 +test.test_array.ShortTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.ShortTest.test_insert @ linux-x86_64 +test.test_array.ShortTest.test_iterationcontains @ linux-x86_64 +test.test_array.ShortTest.test_iterator_pickle @ linux-x86_64 +test.test_array.ShortTest.test_len @ linux-x86_64 +test.test_array.ShortTest.test_mul @ linux-x86_64 +test.test_array.ShortTest.test_overflow @ linux-x86_64 +test.test_array.ShortTest.test_pickle @ linux-x86_64 +test.test_array.ShortTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.ShortTest.test_pop @ linux-x86_64 +test.test_array.ShortTest.test_reduce_ex @ linux-x86_64 +test.test_array.ShortTest.test_remove @ linux-x86_64 +test.test_array.ShortTest.test_repr @ linux-x86_64 +test.test_array.ShortTest.test_reverse @ linux-x86_64 +test.test_array.ShortTest.test_reverse_iterator @ linux-x86_64 +test.test_array.ShortTest.test_setitem @ linux-x86_64 +test.test_array.ShortTest.test_setslice @ linux-x86_64 +test.test_array.ShortTest.test_str @ linux-x86_64 +test.test_array.ShortTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.ShortTest.test_subclassing @ linux-x86_64 +test.test_array.ShortTest.test_tofrombytes @ linux-x86_64 +test.test_array.ShortTest.test_tofromfile @ linux-x86_64 +test.test_array.ShortTest.test_tofromlist @ linux-x86_64 +test.test_array.ShortTest.test_type_error @ linux-x86_64 +test.test_array.UnicodeTest.test_add @ linux-x86_64 +test.test_array.UnicodeTest.test_buffer @ linux-x86_64 +test.test_array.UnicodeTest.test_buffer_info @ linux-x86_64 +test.test_array.UnicodeTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnicodeTest.test_byteswap @ linux-x86_64 +test.test_array.UnicodeTest.test_cmp @ linux-x86_64 +test.test_array.UnicodeTest.test_constructor @ linux-x86_64 +test.test_array.UnicodeTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnicodeTest.test_copy @ linux-x86_64 +test.test_array.UnicodeTest.test_count @ linux-x86_64 +test.test_array.UnicodeTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnicodeTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnicodeTest.test_deepcopy @ linux-x86_64 +test.test_array.UnicodeTest.test_delitem @ linux-x86_64 +test.test_array.UnicodeTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnicodeTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnicodeTest.test_extend @ linux-x86_64 +test.test_array.UnicodeTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnicodeTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnicodeTest.test_filewrite @ linux-x86_64 +test.test_array.UnicodeTest.test_fromarray @ linux-x86_64 +test.test_array.UnicodeTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnicodeTest.test_getitem @ linux-x86_64 +test.test_array.UnicodeTest.test_getslice @ linux-x86_64 +test.test_array.UnicodeTest.test_iadd @ linux-x86_64 +test.test_array.UnicodeTest.test_imul @ linux-x86_64 +test.test_array.UnicodeTest.test_index @ linux-x86_64 +test.test_array.UnicodeTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnicodeTest.test_insert @ linux-x86_64 +test.test_array.UnicodeTest.test_issue17223 @ linux-x86_64 +test.test_array.UnicodeTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnicodeTest.test_len @ linux-x86_64 +test.test_array.UnicodeTest.test_mul @ linux-x86_64 +test.test_array.UnicodeTest.test_pickle @ linux-x86_64 +test.test_array.UnicodeTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnicodeTest.test_pop @ linux-x86_64 +test.test_array.UnicodeTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnicodeTest.test_remove @ linux-x86_64 +test.test_array.UnicodeTest.test_repr @ linux-x86_64 +test.test_array.UnicodeTest.test_reverse @ linux-x86_64 +test.test_array.UnicodeTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnicodeTest.test_setitem @ linux-x86_64 +test.test_array.UnicodeTest.test_setslice @ linux-x86_64 +test.test_array.UnicodeTest.test_str @ linux-x86_64 +test.test_array.UnicodeTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnicodeTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnicodeTest.test_tofromfile @ linux-x86_64 +test.test_array.UnicodeTest.test_tofromlist @ linux-x86_64 +test.test_array.UnicodeTest.test_unicode @ linux-x86_64 +test.test_array.UnsignedByteTest.test_add @ linux-x86_64 +test.test_array.UnsignedByteTest.test_assignment @ linux-x86_64 +test.test_array.UnsignedByteTest.test_buffer @ linux-x86_64 +test.test_array.UnsignedByteTest.test_buffer_info @ linux-x86_64 +test.test_array.UnsignedByteTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnsignedByteTest.test_bytes_extend @ linux-x86_64 +test.test_array.UnsignedByteTest.test_byteswap @ linux-x86_64 +test.test_array.UnsignedByteTest.test_cmp @ linux-x86_64 +test.test_array.UnsignedByteTest.test_constructor @ linux-x86_64 +test.test_array.UnsignedByteTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnsignedByteTest.test_copy @ linux-x86_64 +test.test_array.UnsignedByteTest.test_count @ linux-x86_64 +test.test_array.UnsignedByteTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnsignedByteTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnsignedByteTest.test_deepcopy @ linux-x86_64 +test.test_array.UnsignedByteTest.test_delitem @ linux-x86_64 +test.test_array.UnsignedByteTest.test_delslice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnsignedByteTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedByteTest.test_extend @ linux-x86_64 +test.test_array.UnsignedByteTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_extslice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_filewrite @ linux-x86_64 +test.test_array.UnsignedByteTest.test_fromarray @ linux-x86_64 +test.test_array.UnsignedByteTest.test_frombytearray @ linux-x86_64 +test.test_array.UnsignedByteTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnsignedByteTest.test_getitem @ linux-x86_64 +test.test_array.UnsignedByteTest.test_getslice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_iadd @ linux-x86_64 +test.test_array.UnsignedByteTest.test_imul @ linux-x86_64 +test.test_array.UnsignedByteTest.test_index @ linux-x86_64 +test.test_array.UnsignedByteTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnsignedByteTest.test_insert @ linux-x86_64 +test.test_array.UnsignedByteTest.test_iterationcontains @ linux-x86_64 +test.test_array.UnsignedByteTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnsignedByteTest.test_len @ linux-x86_64 +test.test_array.UnsignedByteTest.test_mul @ linux-x86_64 +test.test_array.UnsignedByteTest.test_overflow @ linux-x86_64 +test.test_array.UnsignedByteTest.test_pickle @ linux-x86_64 +test.test_array.UnsignedByteTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnsignedByteTest.test_pop @ linux-x86_64 +test.test_array.UnsignedByteTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnsignedByteTest.test_remove @ linux-x86_64 +test.test_array.UnsignedByteTest.test_repr @ linux-x86_64 +test.test_array.UnsignedByteTest.test_reverse @ linux-x86_64 +test.test_array.UnsignedByteTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedByteTest.test_setitem @ linux-x86_64 +test.test_array.UnsignedByteTest.test_setslice @ linux-x86_64 +test.test_array.UnsignedByteTest.test_str @ linux-x86_64 +test.test_array.UnsignedByteTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnsignedByteTest.test_subclassing @ linux-x86_64 +test.test_array.UnsignedByteTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnsignedByteTest.test_tofromfile @ linux-x86_64 +test.test_array.UnsignedByteTest.test_tofromlist @ linux-x86_64 +test.test_array.UnsignedByteTest.test_type_error @ linux-x86_64 +test.test_array.UnsignedIntTest.test_add @ linux-x86_64 +test.test_array.UnsignedIntTest.test_assignment @ linux-x86_64 +test.test_array.UnsignedIntTest.test_buffer @ linux-x86_64 +test.test_array.UnsignedIntTest.test_buffer_info @ linux-x86_64 +test.test_array.UnsignedIntTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnsignedIntTest.test_bytes_extend @ linux-x86_64 +test.test_array.UnsignedIntTest.test_byteswap @ linux-x86_64 +test.test_array.UnsignedIntTest.test_cmp @ linux-x86_64 +test.test_array.UnsignedIntTest.test_constructor @ linux-x86_64 +test.test_array.UnsignedIntTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnsignedIntTest.test_copy @ linux-x86_64 +test.test_array.UnsignedIntTest.test_count @ linux-x86_64 +test.test_array.UnsignedIntTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnsignedIntTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnsignedIntTest.test_deepcopy @ linux-x86_64 +test.test_array.UnsignedIntTest.test_delitem @ linux-x86_64 +test.test_array.UnsignedIntTest.test_delslice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnsignedIntTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedIntTest.test_extend @ linux-x86_64 +test.test_array.UnsignedIntTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_extslice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_filewrite @ linux-x86_64 +test.test_array.UnsignedIntTest.test_fromarray @ linux-x86_64 +test.test_array.UnsignedIntTest.test_frombytearray @ linux-x86_64 +test.test_array.UnsignedIntTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnsignedIntTest.test_getitem @ linux-x86_64 +test.test_array.UnsignedIntTest.test_getslice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_iadd @ linux-x86_64 +test.test_array.UnsignedIntTest.test_imul @ linux-x86_64 +test.test_array.UnsignedIntTest.test_index @ linux-x86_64 +test.test_array.UnsignedIntTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnsignedIntTest.test_insert @ linux-x86_64 +test.test_array.UnsignedIntTest.test_iterationcontains @ linux-x86_64 +test.test_array.UnsignedIntTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnsignedIntTest.test_len @ linux-x86_64 +test.test_array.UnsignedIntTest.test_mul @ linux-x86_64 +test.test_array.UnsignedIntTest.test_overflow @ linux-x86_64 +test.test_array.UnsignedIntTest.test_pickle @ linux-x86_64 +test.test_array.UnsignedIntTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnsignedIntTest.test_pop @ linux-x86_64 +test.test_array.UnsignedIntTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnsignedIntTest.test_remove @ linux-x86_64 +test.test_array.UnsignedIntTest.test_repr @ linux-x86_64 +test.test_array.UnsignedIntTest.test_reverse @ linux-x86_64 +test.test_array.UnsignedIntTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedIntTest.test_setitem @ linux-x86_64 +test.test_array.UnsignedIntTest.test_setslice @ linux-x86_64 +test.test_array.UnsignedIntTest.test_str @ linux-x86_64 +test.test_array.UnsignedIntTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnsignedIntTest.test_subclassing @ linux-x86_64 +test.test_array.UnsignedIntTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnsignedIntTest.test_tofromfile @ linux-x86_64 +test.test_array.UnsignedIntTest.test_tofromlist @ linux-x86_64 +test.test_array.UnsignedIntTest.test_type_error @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_add @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_assignment @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_buffer @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_buffer_info @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_bytes_extend @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_byteswap @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_cmp @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_constructor @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_copy @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_count @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_deepcopy @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_delitem @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_delslice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_extend @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_extslice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_filewrite @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_fromarray @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_frombytearray @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_getitem @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_getslice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_iadd @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_imul @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_index @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_insert @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_iterationcontains @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_len @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_mul @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_overflow @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_pickle @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_pop @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_remove @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_repr @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_reverse @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_setitem @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_setslice @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_str @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_subclassing @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_tofromfile @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_tofromlist @ linux-x86_64 +test.test_array.UnsignedLongLongTest.test_type_error @ linux-x86_64 +test.test_array.UnsignedLongTest.test_add @ linux-x86_64 +test.test_array.UnsignedLongTest.test_assignment @ linux-x86_64 +test.test_array.UnsignedLongTest.test_buffer @ linux-x86_64 +test.test_array.UnsignedLongTest.test_buffer_info @ linux-x86_64 +test.test_array.UnsignedLongTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnsignedLongTest.test_bytes_extend @ linux-x86_64 +test.test_array.UnsignedLongTest.test_byteswap @ linux-x86_64 +test.test_array.UnsignedLongTest.test_cmp @ linux-x86_64 +test.test_array.UnsignedLongTest.test_constructor @ linux-x86_64 +test.test_array.UnsignedLongTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnsignedLongTest.test_copy @ linux-x86_64 +test.test_array.UnsignedLongTest.test_count @ linux-x86_64 +test.test_array.UnsignedLongTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnsignedLongTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnsignedLongTest.test_deepcopy @ linux-x86_64 +test.test_array.UnsignedLongTest.test_delitem @ linux-x86_64 +test.test_array.UnsignedLongTest.test_delslice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnsignedLongTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedLongTest.test_extend @ linux-x86_64 +test.test_array.UnsignedLongTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_extslice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_filewrite @ linux-x86_64 +test.test_array.UnsignedLongTest.test_fromarray @ linux-x86_64 +test.test_array.UnsignedLongTest.test_frombytearray @ linux-x86_64 +test.test_array.UnsignedLongTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnsignedLongTest.test_getitem @ linux-x86_64 +test.test_array.UnsignedLongTest.test_getslice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_iadd @ linux-x86_64 +test.test_array.UnsignedLongTest.test_imul @ linux-x86_64 +test.test_array.UnsignedLongTest.test_index @ linux-x86_64 +test.test_array.UnsignedLongTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnsignedLongTest.test_insert @ linux-x86_64 +test.test_array.UnsignedLongTest.test_iterationcontains @ linux-x86_64 +test.test_array.UnsignedLongTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnsignedLongTest.test_len @ linux-x86_64 +test.test_array.UnsignedLongTest.test_mul @ linux-x86_64 +test.test_array.UnsignedLongTest.test_overflow @ linux-x86_64 +test.test_array.UnsignedLongTest.test_pickle @ linux-x86_64 +test.test_array.UnsignedLongTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnsignedLongTest.test_pop @ linux-x86_64 +test.test_array.UnsignedLongTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnsignedLongTest.test_remove @ linux-x86_64 +test.test_array.UnsignedLongTest.test_repr @ linux-x86_64 +test.test_array.UnsignedLongTest.test_reverse @ linux-x86_64 +test.test_array.UnsignedLongTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedLongTest.test_setitem @ linux-x86_64 +test.test_array.UnsignedLongTest.test_setslice @ linux-x86_64 +test.test_array.UnsignedLongTest.test_str @ linux-x86_64 +test.test_array.UnsignedLongTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnsignedLongTest.test_subclassing @ linux-x86_64 +test.test_array.UnsignedLongTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnsignedLongTest.test_tofromfile @ linux-x86_64 +test.test_array.UnsignedLongTest.test_tofromlist @ linux-x86_64 +test.test_array.UnsignedLongTest.test_type_error @ linux-x86_64 +test.test_array.UnsignedShortTest.test_add @ linux-x86_64 +test.test_array.UnsignedShortTest.test_assignment @ linux-x86_64 +test.test_array.UnsignedShortTest.test_buffer @ linux-x86_64 +test.test_array.UnsignedShortTest.test_buffer_info @ linux-x86_64 +test.test_array.UnsignedShortTest.test_bug_782369 @ linux-x86_64 +test.test_array.UnsignedShortTest.test_bytes_extend @ linux-x86_64 +test.test_array.UnsignedShortTest.test_byteswap @ linux-x86_64 +test.test_array.UnsignedShortTest.test_cmp @ linux-x86_64 +test.test_array.UnsignedShortTest.test_constructor @ linux-x86_64 +test.test_array.UnsignedShortTest.test_constructor_with_iterable_argument @ linux-x86_64 +test.test_array.UnsignedShortTest.test_copy @ linux-x86_64 +test.test_array.UnsignedShortTest.test_count @ linux-x86_64 +test.test_array.UnsignedShortTest.test_coveritertraverse @ linux-x86_64 +test.test_array.UnsignedShortTest.test_create_from_bytes @ linux-x86_64 +test.test_array.UnsignedShortTest.test_deepcopy @ linux-x86_64 +test.test_array.UnsignedShortTest.test_delitem @ linux-x86_64 +test.test_array.UnsignedShortTest.test_delslice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_exhausted_iterator @ linux-x86_64 +test.test_array.UnsignedShortTest.test_exhausted_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedShortTest.test_extend @ linux-x86_64 +test.test_array.UnsignedShortTest.test_extended_getslice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_extended_set_del_slice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_extslice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_filewrite @ linux-x86_64 +test.test_array.UnsignedShortTest.test_fromarray @ linux-x86_64 +test.test_array.UnsignedShortTest.test_frombytearray @ linux-x86_64 +test.test_array.UnsignedShortTest.test_fromfile_ioerror @ linux-x86_64 +test.test_array.UnsignedShortTest.test_getitem @ linux-x86_64 +test.test_array.UnsignedShortTest.test_getslice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_iadd @ linux-x86_64 +test.test_array.UnsignedShortTest.test_imul @ linux-x86_64 +test.test_array.UnsignedShortTest.test_index @ linux-x86_64 +test.test_array.UnsignedShortTest.test_initialize_with_unicode @ linux-x86_64 +test.test_array.UnsignedShortTest.test_insert @ linux-x86_64 +test.test_array.UnsignedShortTest.test_iterationcontains @ linux-x86_64 +test.test_array.UnsignedShortTest.test_iterator_pickle @ linux-x86_64 +test.test_array.UnsignedShortTest.test_len @ linux-x86_64 +test.test_array.UnsignedShortTest.test_mul @ linux-x86_64 +test.test_array.UnsignedShortTest.test_overflow @ linux-x86_64 +test.test_array.UnsignedShortTest.test_pickle @ linux-x86_64 +test.test_array.UnsignedShortTest.test_pickle_for_empty_array @ linux-x86_64 +test.test_array.UnsignedShortTest.test_pop @ linux-x86_64 +test.test_array.UnsignedShortTest.test_reduce_ex @ linux-x86_64 +test.test_array.UnsignedShortTest.test_remove @ linux-x86_64 +test.test_array.UnsignedShortTest.test_repr @ linux-x86_64 +test.test_array.UnsignedShortTest.test_reverse @ linux-x86_64 +test.test_array.UnsignedShortTest.test_reverse_iterator @ linux-x86_64 +test.test_array.UnsignedShortTest.test_setitem @ linux-x86_64 +test.test_array.UnsignedShortTest.test_setslice @ linux-x86_64 +test.test_array.UnsignedShortTest.test_str @ linux-x86_64 +test.test_array.UnsignedShortTest.test_subclass_with_kwargs @ linux-x86_64 +test.test_array.UnsignedShortTest.test_subclassing @ linux-x86_64 +test.test_array.UnsignedShortTest.test_tofrombytes @ linux-x86_64 +test.test_array.UnsignedShortTest.test_tofromfile @ linux-x86_64 +test.test_array.UnsignedShortTest.test_tofromlist @ linux-x86_64 +test.test_array.UnsignedShortTest.test_type_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ast.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ast.txt new file mode 100644 index 0000000000..0ea7b15035 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ast.txt @@ -0,0 +1,136 @@ +test.test_ast.ASTHelpers_Test.test_bad_integer @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_copy_location @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_dump @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_dump_incomplete @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_dump_indent @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_elif_stmt_start_position @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_elif_stmt_start_position_with_else @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_fix_missing_locations @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_get_docstring @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_get_docstring_none @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_increment_lineno @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_increment_lineno_on_module @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_iter_child_nodes @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_iter_fields @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_level_as_none @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval_complex @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval_malformed_dict_nodes @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval_malformed_lineno @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval_syntax_errors @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_literal_eval_trailing_ws @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_multi_line_docstring_col_offset_and_lineno_issue16806 @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_parse @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_parse_in_error @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_recursion_direct @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_recursion_indirect @ linux-x86_64 +test.test_ast.ASTHelpers_Test.test_starred_expr_end_position_within_call @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_assert @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_assign @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_attribute @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_augassign @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_boolop @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_call @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_classdef @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_compare @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_delete @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_dict @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_dictcomp @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_expr @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_for @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_funcdef @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_generatorexp @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_global @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_if @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_ifexp @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_import @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_importfrom @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_lambda @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_list @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_listcomp @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_match_validation_pattern @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_module @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_nameconstant @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_nonlocal @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_num @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_raise @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_set @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_setcomp @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_starred @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_subscript @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_try @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_try_star @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_tuple @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_unaryop @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_while @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_with @ linux-x86_64 +test.test_ast.ASTValidatorTests.test_yield @ linux-x86_64 +test.test_ast.AST_Tests.test_AST_garbage_collection @ linux-x86_64 +test.test_ast.AST_Tests.test_AST_objects @ linux-x86_64 +test.test_ast.AST_Tests.test_alias @ linux-x86_64 +test.test_ast.AST_Tests.test_arguments @ linux-x86_64 +test.test_ast.AST_Tests.test_assignment_expression_feature_version @ linux-x86_64 +test.test_ast.AST_Tests.test_ast_asdl_signature @ linux-x86_64 +test.test_ast.AST_Tests.test_ast_validation @ linux-x86_64 +test.test_ast.AST_Tests.test_base_classes @ linux-x86_64 +test.test_ast.AST_Tests.test_classattrs @ linux-x86_64 +test.test_ast.AST_Tests.test_compilation_of_ast_nodes_with_default_end_position_values @ linux-x86_64 +test.test_ast.AST_Tests.test_constant_as_name @ linux-x86_64 +test.test_ast.AST_Tests.test_debug_f_string_feature_version @ linux-x86_64 +test.test_ast.AST_Tests.test_empty_yield_from @ linux-x86_64 +test.test_ast.AST_Tests.test_field_attr_existence @ linux-x86_64 +test.test_ast.AST_Tests.test_field_attr_writable @ linux-x86_64 +test.test_ast.AST_Tests.test_from_import @ linux-x86_64 +test.test_ast.AST_Tests.test_invalid_constant @ linux-x86_64 +test.test_ast.AST_Tests.test_invalid_identifier @ linux-x86_64 +test.test_ast.AST_Tests.test_invalid_sum @ linux-x86_64 +test.test_ast.AST_Tests.test_isinstance @ linux-x86_64 +test.test_ast.AST_Tests.test_issue18374_binop_col_offset @ linux-x86_64 +test.test_ast.AST_Tests.test_issue39579_dotted_name_end_col_offset @ linux-x86_64 +test.test_ast.AST_Tests.test_module @ linux-x86_64 +test.test_ast.AST_Tests.test_no_fields @ linux-x86_64 +test.test_ast.AST_Tests.test_nodeclasses @ linux-x86_64 +test.test_ast.AST_Tests.test_non_interned_future_from_ast @ linux-x86_64 +test.test_ast.AST_Tests.test_none_checks @ linux-x86_64 +test.test_ast.AST_Tests.test_null_bytes @ linux-x86_64 +test.test_ast.AST_Tests.test_parenthesized_with_feature_version @ linux-x86_64 +test.test_ast.AST_Tests.test_pickling @ linux-x86_64 +test.test_ast.AST_Tests.test_positional_only_feature_version @ linux-x86_64 +test.test_ast.AST_Tests.test_precedence_enum @ linux-x86_64 +test.test_ast.AST_Tests.test_realtype @ linux-x86_64 +test.test_ast.AST_Tests.test_slice @ linux-x86_64 +test.test_ast.AST_Tests.test_snippets @ linux-x86_64 +test.test_ast.AST_Tests.test_subclasses @ linux-x86_64 +test.test_ast.ConstantTests.test_assign_to_constant @ linux-x86_64 +test.test_ast.ConstantTests.test_get_docstring @ linux-x86_64 +test.test_ast.ConstantTests.test_literal_eval @ linux-x86_64 +test.test_ast.ConstantTests.test_string_kind @ linux-x86_64 +test.test_ast.ConstantTests.test_validation @ linux-x86_64 +test.test_ast.ConstantTests.test_values @ linux-x86_64 +test.test_ast.EndPositionTests.test_attribute_spaces @ linux-x86_64 +test.test_ast.EndPositionTests.test_binop @ linux-x86_64 +test.test_ast.EndPositionTests.test_boolop @ linux-x86_64 +test.test_ast.EndPositionTests.test_call @ linux-x86_64 +test.test_ast.EndPositionTests.test_call_noargs @ linux-x86_64 +test.test_ast.EndPositionTests.test_class_def @ linux-x86_64 +test.test_ast.EndPositionTests.test_class_kw @ linux-x86_64 +test.test_ast.EndPositionTests.test_comprehensions @ linux-x86_64 +test.test_ast.EndPositionTests.test_continued_str @ linux-x86_64 +test.test_ast.EndPositionTests.test_displays @ linux-x86_64 +test.test_ast.EndPositionTests.test_fstring @ linux-x86_64 +test.test_ast.EndPositionTests.test_fstring_multi_line @ linux-x86_64 +test.test_ast.EndPositionTests.test_func_def @ linux-x86_64 +test.test_ast.EndPositionTests.test_import_from_multi_line @ linux-x86_64 +test.test_ast.EndPositionTests.test_lambda @ linux-x86_64 +test.test_ast.EndPositionTests.test_multi_line_str @ linux-x86_64 +test.test_ast.EndPositionTests.test_redundant_parenthesis @ linux-x86_64 +test.test_ast.EndPositionTests.test_slices @ linux-x86_64 +test.test_ast.EndPositionTests.test_source_segment_endings @ linux-x86_64 +test.test_ast.EndPositionTests.test_source_segment_missing_info @ linux-x86_64 +test.test_ast.EndPositionTests.test_source_segment_multi @ linux-x86_64 +test.test_ast.EndPositionTests.test_source_segment_tabs @ linux-x86_64 +test.test_ast.EndPositionTests.test_suites @ linux-x86_64 +test.test_ast.EndPositionTests.test_trailers_with_redundant_parenthesis @ linux-x86_64 +test.test_ast.EndPositionTests.test_tuples @ linux-x86_64 +test.test_ast.EndPositionTests.test_yield_await @ linux-x86_64 +test.test_ast.NodeVisitorTests.test_old_constant_nodes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asynchat.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asynchat.txt new file mode 100644 index 0000000000..28ec009e04 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asynchat.txt @@ -0,0 +1,25 @@ +test.test_asynchat.TestAsynchat.test_close_when_done @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_empty_line @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_line_terminator1 @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_line_terminator2 @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_line_terminator3 @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_none_terminator @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_numeric_terminator1 @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_numeric_terminator2 @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_push @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_simple_producer @ linux-x86_64 +test.test_asynchat.TestAsynchat.test_string_producer @ linux-x86_64 +test.test_asynchat.TestAsynchatMocked.test_blockingioerror @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_close_when_done @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_empty_line @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_line_terminator1 @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_line_terminator2 @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_line_terminator3 @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_none_terminator @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_numeric_terminator1 @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_numeric_terminator2 @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_push @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_simple_producer @ linux-x86_64 +test.test_asynchat.TestAsynchat_WithPoll.test_string_producer @ linux-x86_64 +test.test_asynchat.TestHelperFunctions.test_find_prefix_at_end @ linux-x86_64 +test.test_asynchat.TestNotConnected.test_disallow_negative_terminator @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncio.txt new file mode 100644 index 0000000000..e38bc5688a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncio.txt @@ -0,0 +1,657 @@ +test.test_asyncio.test_base_events.BaseEventLoopTests.test__add_callback_cancelled_handle @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test__add_callback_handle @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test__run_once @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test__run_once_cancelled_event_cleanup @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test__run_once_schedule_handle @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_call_later @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_call_later_negative_delays @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_call_soon @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_call_soon_non_callable @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_check_thread @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_close @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_create_named_task_with_custom_factory @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_create_named_task_with_default_factory @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_create_task @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_create_task_error_closes_coro @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_default_exc_handler_broken @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_default_exc_handler_callback @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_not_implemented @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_forever_keyboard_interrupt @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_forever_pre_stopped @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_once @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_until_complete_baseexception @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_until_complete_loop @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_run_until_complete_type_error @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_debug @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_default_executor @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_default_executor_error @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_exc_handler_broken @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_exc_handler_custom @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_exc_handler_invalid @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_task_factory @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_set_task_factory_invalid @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_single_selecter_event_callback_after_stopping @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_subprocess_exec_invalid_args @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_subprocess_shell_invalid_args @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopTests.test_time_and_call_at @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_accept_connection_exception @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_accept_connection_retry @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_call_coroutine @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_host_port_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_no_host_port_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_no_ssl_server_hostname_errors @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_ssl_server_hostname_errors @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_ssl_timeout_for_plain_socket @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_connection_wrong_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_addr_error @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_noaddr_nofamily @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_setblk_err @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_sock_sockopts @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_datagram_endpoint_wrong_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_server_host_port_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_server_no_host_port_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_server_ssl_timeout_for_plain_socket @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_create_server_wrong_sock @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventLoopWithSelectorTests.test_getnameinfo @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventTests.test_ipaddr_info @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventTests.test_ipaddr_info_no_inet_pton @ linux-x86_64 +test.test_asyncio.test_base_events.BaseEventTests.test_port_parameter_types @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_blocking_socket @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_negative_count @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_negative_offset @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_nonbinary_file @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_nonstream_socket @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_notint_count @ linux-x86_64 +test.test_asyncio.test_base_events.BaseLoopSockSendfileTests.test_notint_offset @ linux-x86_64 +test.test_asyncio.test_base_events.RunningLoopTests.test_running_loop_within_a_loop @ linux-x86_64 +test.test_asyncio.test_base_events.TestSelectorUtils.test_set_nodelay @ linux-x86_64 +test.test_asyncio.test_events.AbstractEventLoopTests.test_not_implemented @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_callback_with_exception @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_coroutine_like_object_debug_formatting @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_handle @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_handle_repr @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_handle_repr_debug @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_handle_source_traceback @ linux-x86_64 +test.test_asyncio.test_events.HandleTests.test_handle_weakref @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_event_loop_policy @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_get_event_loop @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_get_event_loop_after_set_none @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_get_event_loop_calls_set_event_loop @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_get_event_loop_policy @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_get_event_loop_thread @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_new_event_loop @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_set_event_loop @ linux-x86_64 +test.test_asyncio.test_events.PolicyTests.test_set_event_loop_policy @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_add_fds_after_closing @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_bidirectional_pty @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_call_later @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_call_soon_threadsafe_same_thread @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_close @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_close_running_event_loop @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_internal_fds @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_prompt_cancellation @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_reader_callback @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_remove_fds_after_closing @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_run_in_executor @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_run_in_executor_cancel @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_run_until_complete @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_write_pipe @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_write_pipe_disconnect_on_close @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_write_pty @ linux-x86_64 +test.test_asyncio.test_events.SelectEventLoopTests.test_writer_callback @ linux-x86_64 +test.test_asyncio.test_events.TestAbstractServer.test_close @ linux-x86_64 +test.test_asyncio.test_events.TestAbstractServer.test_get_loop @ linux-x86_64 +test.test_asyncio.test_events.TestAbstractServer.test_wait_closed @ linux-x86_64 +test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_new_process @ linux-x86_64 +test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_returns_running_loop @ linux-x86_64 +test.test_asyncio.test_events.TestCGetEventLoop.test_get_event_loop_returns_running_loop2 @ linux-x86_64 +test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_new_process @ linux-x86_64 +test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_returns_running_loop @ linux-x86_64 +test.test_asyncio.test_events.TestPyGetEventLoop.test_get_event_loop_returns_running_loop2 @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_hash @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_timer @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_timer_comparison @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_timer_repr @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_timer_repr_debug @ linux-x86_64 +test.test_asyncio.test_events.TimerTests.test_when @ linux-x86_64 +test.test_asyncio.test_futures.DuckTests.test_ensure_future @ linux-x86_64 +test.test_asyncio.test_futures.DuckTests.test_wrap_future @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_callbacks_invoked_on_set_exception @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_callbacks_invoked_on_set_result @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_callbacks_remove_first_and_second_callback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_callbacks_remove_first_callback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_callbacks_remove_third_callback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_remove_done_callback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_remove_done_callbacks_list_clear @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_remove_done_callbacks_list_mutation @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_schedule_callbacks_list_mutation_1 @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureDoneCallbackTests.test_schedule_callbacks_list_mutation_2 @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureInheritanceTests.test_inherit_without_calling_super_init @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_cancel @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_constructor_positional @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_constructor_use_global_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_constructor_use_running_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_constructor_without_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_copy_state @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_exception @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_exception_class @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_cancel_message_getter @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_cancel_message_setter @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_del_collect @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_iter_throw @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_repr @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_source_traceback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_future_stop_iteration_args @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_generic_alias @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_initial_state @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_isfuture @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_iter @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_log_traceback @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_result @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_set_result_unless_cancelled @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_abandoned @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_exception_result_retrieved @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_exception_retrieved @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_not_called_after_cancel @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_result_retrieved @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_tb_logger_result_unretrieved @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_uninitialized @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_cancel @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_cancel2 @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_future @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_use_global_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_use_running_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_wrap_future_without_loop @ linux-x86_64 +test.test_asyncio.test_futures.PyFutureTests.test_yield_from_twice @ linux-x86_64 +test.test_asyncio.test_locks.EventTests.test_clear @ linux-x86_64 +test.test_asyncio.test_locks.EventTests.test_repr @ linux-x86_64 +test.test_asyncio.test_locks.LockTests.test_lock @ linux-x86_64 +test.test_asyncio.test_locks.LockTests.test_lock_doesnt_accept_loop_parameter @ linux-x86_64 +test.test_asyncio.test_locks.LockTests.test_release_not_acquired @ linux-x86_64 +test.test_asyncio.test_locks.SemaphoreTests.test_initial_value_zero @ linux-x86_64 +test.test_asyncio.test_locks.SemaphoreTests.test_release_not_acquired @ linux-x86_64 +test.test_asyncio.test_locks.SemaphoreTests.test_semaphore @ linux-x86_64 +test.test_asyncio.test_locks.SemaphoreTests.test_semaphore_value @ linux-x86_64 +test.test_asyncio.test_pep492.CoroutineTests.test_iscoroutine @ linux-x86_64 +test.test_asyncio.test_pep492.CoroutineTests.test_iscoroutinefunction @ linux-x86_64 +test.test_asyncio.test_pep492.CoroutineTests.test_types_coroutine @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_close @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_close_self_pipe @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_create_server @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_create_server_cancel @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_reading @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_reading_aborted @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_reading_data @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_reading_no_data @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_writing @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_datagram_loop_writing_aborted @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_loop_self_reading @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_loop_self_reading_exception @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_loop_self_reading_fut @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_make_datagram_transport @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_make_socket_transport @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_process_events @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_stop_serving @ linux-x86_64 +test.test_asyncio.test_proactor_events.BaseProactorEventLoopTests.test_write_to_self @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test__loop_writing_closing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test__loop_writing_error_received @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test__loop_writing_error_received_connection @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test__loop_writing_exception @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_fatal_error_connected @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_buffer @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_buffer_bytearray @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_buffer_memoryview @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_bytearray @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_closing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_connected_addr @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_error_received @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_error_received_connected @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_exception @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_memoryview @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_no_data @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorDatagramTransportTests.test_sendto_str @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_abort @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_call_connection_lost @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_close @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_close_buffer @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_close_invalid_sockobj @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_close_protocol_connection_lost_once @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_close_write_fut @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_dont_pause_writing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_fatal_error @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_fatal_error_2 @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_force_close @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_force_close_idempotent @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_force_close_protocol_connection_lost_once @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_aborted @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_aborted_closing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_aborted_is_fatal @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_conn_reset_lost @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_data @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_exception @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_reading_no_data @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_writing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_writing_closing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_writing_err @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_writing_force_close @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_loop_writing_stop @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_pause_reading_connection_made @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_pause_resume_reading @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_pause_resume_writing @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_pause_writing_2write @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_pause_writing_3write @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_eof @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_eof_buffer @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_eof_buffer_write_pipe @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_eof_duplex_pipe @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_eof_write_pipe @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_more @ linux-x86_64 +test.test_asyncio.test_proactor_events.ProactorSocketTransportTests.test_write_no_data @ linux-x86_64 +test.test_asyncio.test_protocols.ProtocolsAbsTests.test_base_protocol @ linux-x86_64 +test.test_asyncio.test_protocols.ProtocolsAbsTests.test_buffered_protocol @ linux-x86_64 +test.test_asyncio.test_protocols.ProtocolsAbsTests.test_datagram_protocol @ linux-x86_64 +test.test_asyncio.test_protocols.ProtocolsAbsTests.test_protocol @ linux-x86_64 +test.test_asyncio.test_protocols.ProtocolsAbsTests.test_subprocess_protocol @ linux-x86_64 +test.test_asyncio.test_runners.RunTests.test_asyncio_run_debug @ linux-x86_64 +test.test_asyncio.test_runners.RunTests.test_asyncio_run_from_running_loop @ linux-x86_64 +test.test_asyncio.test_runners.RunTests.test_asyncio_run_only_coro @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_custom_factory @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_debug @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_double_close @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_explicit_close @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_non_debug @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_second_with_block_raises @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_set_event_loop_called_once @ linux-x86_64 +test.test_asyncio.test_runners.RunnerTests.test_signal_install_not_supported_ok @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_add_reader @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_add_reader_existing @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_add_reader_existing_writer @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_add_writer @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_add_writer_existing @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_close @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_close_no_selector @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_make_socket_transport @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_make_ssl_transport_without_ssl_error @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_process_events_read @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_process_events_read_cancelled @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_process_events_write @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_process_events_write_cancelled @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_read_from_self_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_read_from_self_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_reader @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_reader_read_write @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_reader_unknown @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_writer @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_writer_read_write @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_remove_writer_unknown @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_write_to_self_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests.test_write_to_self_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_fatal_error_connected @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_fatal_error_connected_custom_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_read_ready @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_read_ready_err @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_read_ready_oserr @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_read_ready_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_buffer @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_buffer_bytearray @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_buffer_memoryview @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_bytearray @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_closing @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_connected_addr @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_error_received @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_error_received_connected @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_memoryview @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_no_data @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_closing @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_error_received @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_error_received_connection @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_no_data @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_ready_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_str @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorDatagramTransportTests.test_sendto_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_buffer_updated_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_get_buffer_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_get_buffer_zerosized @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_proto_type_switch @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_eof_received_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_conn_reset @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_eof @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_eof_keep_open @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_err @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportBufferedProtocolTests.test_read_ready_tryagain_interrupted @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_ctor_with_waiter @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_data_received_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_pause_reading_connection_made @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_pause_resume_reading @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_eof_received_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_conn_reset @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_eof @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_eof_keep_open @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_err @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_read_ready_tryagain_interrupted @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_transport_close_remove_writer @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_buffer @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_bytearray @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_closing @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_eof @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_eof_buffer @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_memoryview @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_no_data @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_partial @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_partial_bytearray @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_partial_memoryview @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_partial_none @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_closing @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_no_data @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_partial @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_partial_none @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_ready_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_str @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorSocketTransportTests.test_write_tryagain @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test__add_reader @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_abort @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_close @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_close_write_buffer @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_connection_lost @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_fatal_error @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_fatal_error_custom_exception @ linux-x86_64 +test.test_asyncio.test_selector_events.SelectorTransportTests.test_force_close @ linux-x86_64 +test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests.test_sock_accept @ linux-x86_64 +test.test_asyncio.test_sock_lowlevel.SelectEventLoopTests.test_unix_sock_client_ops @ linux-x86_64 +test.test_asyncio.test_ssl.TestSSL.test_ssl_connect_accepted_socket @ linux-x86_64 +test.test_asyncio.test_sslproto.SelectorStartTLSTests.test_buf_feed_data @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_close_during_handshake @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_connection_lost @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_data_received_after_closing @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_eof_received_waiter @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_fatal_error_no_name_error @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_get_extra_info_on_closed_connection @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_handshake_timeout_negative @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_handshake_timeout_zero @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_set_new_app_protocol @ linux-x86_64 +test.test_asyncio.test_sslproto.SslProtoHandshakeTests.test_write_after_closing @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_IncompleteReadError_pickleable @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_LimitOverrunError_pickleable @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__ @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__data @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__eof @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__exception @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__nondefault_limit @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__transport @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test___repr__waiter @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_exception @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_feed_empty_data @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_feed_nonempty_data @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_invalid_limit @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreader_constructor_use_global_loop @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreader_constructor_use_running_loop @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreader_constructor_without_loop @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreaderprotocol_constructor_use_global_loop @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreaderprotocol_constructor_use_running_loop @ linux-x86_64 +test.test_asyncio.test_streams.StreamTests.test_streamreaderprotocol_constructor_without_loop @ linux-x86_64 +!test.test_asyncio.test_subprocess.SubprocessSafeWatcherTests.test_shell @ linux-x86_64 +test.test_asyncio.test_subprocess.SubprocessTransportTests.test_proc_exited @ linux-x86_64 +test.test_asyncio.test_subprocess.SubprocessTransportTests.test_subprocess_repr @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__enter_task @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__enter_task_failure @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__leave_task @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__leave_task_failure1 @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__leave_task_failure2 @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__register_task_1 @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__register_task_2 @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__register_task_3 @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__unregister_task @ linux-x86_64 +test.test_asyncio.test_tasks.CIntrospectionTests.test__unregister_task_not_registered @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_cancellation_broadcast @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_constructor_use_global_loop @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_constructor_use_running_loop @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_constructor_without_loop @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_duplicate_coroutines @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_exception_marking @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_issue46672 @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_one_exception @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_result_exception_success @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_return_exceptions @ linux-x86_64 +test.test_asyncio.test_tasks.CoroutineGatherTests.test_success @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_constructor_empty_sequence_use_global_loop @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_constructor_empty_sequence_use_running_loop @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_constructor_empty_sequence_without_loop @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_constructor_heterogenous_futures @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_constructor_homogenous_futures @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_one_cancellation @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_one_exception @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_result_exception_one_cancellation @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_result_exception_success @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_return_exceptions @ linux-x86_64 +test.test_asyncio.test_tasks.FutureGatherTests.test_success @ linux-x86_64 +test.test_asyncio.test_tasks.GenericTaskTests.test_future_subclass @ linux-x86_64 +test.test_asyncio.test_tasks.PyCurrentLoopTests.test_current_task_no_running_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyCurrentLoopTests.test_current_task_no_running_loop_implicit @ linux-x86_64 +test.test_asyncio.test_tasks.PyCurrentLoopTests.test_current_task_with_implicit_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__enter_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__enter_task_failure @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__leave_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__leave_task_failure1 @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__leave_task_failure2 @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__register_task_1 @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__register_task_2 @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__register_task_3 @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__unregister_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyIntrospectionTests.test__unregister_task_not_registered @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_bare_create_named_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_bare_create_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_coroutine_non_gen_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_coroutine_non_gen_function_return_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_create_task_with_async_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_create_task_with_asynclike_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_create_task_with_noncoroutine @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_current_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_ensure_future_coroutine @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_ensure_future_error_msg @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_ensure_future_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_ensure_future_neither @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_ensure_future_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_gather_shield @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_generic_alias @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_get_coro @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_iscoroutinefunction @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_log_traceback @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_other_loop_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_cancel_inner @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_cancel_outer @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_coroutine_use_global_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_coroutine_use_running_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_coroutine_without_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_effect @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_exception @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_gather @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_result @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_shield_shortcut @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_step_result_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_subclasses_ctask_cfuture @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_awaits_on_itself @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_cancel_message_getter @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_cancel_message_setter @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_cancel_waiter_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_class @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_del_collect @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_repr_name_not_str @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_repr_wait_for @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_SubclassTests.test_task_set_methods @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_bare_create_named_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_bare_create_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_coroutine_non_gen_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_coroutine_non_gen_function_return_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_create_task_with_async_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_create_task_with_asynclike_function @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_create_task_with_noncoroutine @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_current_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_ensure_future_coroutine @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_ensure_future_error_msg @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_ensure_future_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_ensure_future_neither @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_ensure_future_task @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_gather_shield @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_generic_alias @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_get_coro @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_iscoroutinefunction @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_log_traceback @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_other_loop_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_cancel_inner @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_cancel_outer @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_coroutine_use_global_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_coroutine_use_running_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_coroutine_without_loop @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_effect @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_exception @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_gather @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_result @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_shield_shortcut @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_step_result_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_awaits_on_itself @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_cancel_message_getter @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_cancel_message_setter @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_cancel_waiter_future @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_class @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_del_collect @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_repr_name_not_str @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_repr_wait_for @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_set_methods @ linux-x86_64 +test.test_asyncio.test_tasks.PyTask_PyFuture_Tests.test_task_source_traceback @ linux-x86_64 +test.test_asyncio.test_timeouts.TimeoutTests.test_timeout_not_entered @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_ctor_extra_is_none @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_dgram_not_implemented @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_flowcontrol_mixin_set_write_limits @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_get_extra_info @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_not_implemented @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_subprocess_transport_not_implemented @ linux-x86_64 +test.test_asyncio.test_transports.TransportTests.test_writelines @ linux-x86_64 +test.test_asyncio.test_unix_events.AbstractChildWatcherTests.test_not_implemented @ linux-x86_64 +test.test_asyncio.test_unix_events.BaseChildWatcherTests.test_not_implemented @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_close @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_create_watcher @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_remove_child_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_set_loop @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_set_loop_race_condition @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_child_reaped_elsewhere @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_race_condition @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_remove_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_replace_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_two_children @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_two_children_terminating_together @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_unhandled_exception @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_unknown_pid_during_registration @ linux-x86_64 +test.test_asyncio.test_unix_events.FastChildWatcherTests.test_sigchld_unknown_status @ linux-x86_64 +test.test_asyncio.test_unix_events.PolicyTests.test_child_watcher_replace_mainloop_existing @ linux-x86_64 +test.test_asyncio.test_unix_events.PolicyTests.test_get_child_watcher_after_set @ linux-x86_64 +test.test_asyncio.test_unix_events.PolicyTests.test_get_child_watcher_thread @ linux-x86_64 +test.test_asyncio.test_unix_events.PolicyTests.test_get_default_child_watcher @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_close @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_create_watcher @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_remove_child_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_set_loop @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_set_loop_race_condition @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_child_reaped_elsewhere @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_race_condition @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_remove_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_replace_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_two_children @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_two_children_terminating_together @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_unhandled_exception @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_unknown_pid_during_registration @ linux-x86_64 +test.test_asyncio.test_unix_events.SafeChildWatcherTests.test_sigchld_unknown_status @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler_coroutine_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler_install_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler_install_error2 @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler_install_error3 @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_add_signal_handler_setup_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_check_signal @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_close @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_close_on_finalizing @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_handle_signal_cancelled_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_handle_signal_no_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_remove_signal_handler @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_remove_signal_handler_2 @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_remove_signal_handler_cleanup_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_remove_signal_handler_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopSignalTests.test_remove_signal_handler_error2 @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_nopath_nosock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_nossl_serverhost @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_path_inetsock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_path_sock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_ssl_noserverhost @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_connection_ssl_timeout_with_plain_sock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_bind_error @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_existing_path_nonsock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_nopath_nosock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_path_dgram @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_path_inetsock @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_ssl_bool @ linux-x86_64 +test.test_asyncio.test_unix_events.SelectorEventLoopUnixSocketTests.test_create_unix_server_ssl_timeout_with_plain_sock @ linux-x86_64 +test.test_asyncio.test_unix_events.TestFunctional.test_add_reader_invalid_argument @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__call_connection_lost @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__call_connection_lost_with_err @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__close @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__read_ready @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__read_ready_blocked @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__read_ready_eof @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test__read_ready_error @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_close @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_close_already_closing @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_pause_reading @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_pause_reading_on_closed_pipe @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_pause_reading_on_paused_pipe @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_resume_reading @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_resume_reading_on_closed_pipe @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixReadPipeTransportTests.test_resume_reading_on_paused_pipe @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__call_connection_lost @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__call_connection_lost_with_err @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__read_ready @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready_again @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready_closing @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready_empty @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready_err @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test__write_ready_partial @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_abort @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_can_write_eof @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_close @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_close_closing @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_ctor @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_again @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_buffer @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_close @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_eof @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_eof_pending @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_err @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_no_data @ linux-x86_64 +test.test_asyncio.test_unix_events.UnixWritePipeTransportTests.test_write_partial @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncore.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncore.txt new file mode 100644 index 0000000000..8159384918 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_asyncore.txt @@ -0,0 +1,51 @@ +test.test_asyncore.DispatcherTests.test_basic @ linux-x86_64 +test.test_asyncore.DispatcherTests.test_log @ linux-x86_64 +test.test_asyncore.DispatcherTests.test_log_info @ linux-x86_64 +test.test_asyncore.DispatcherTests.test_repr @ linux-x86_64 +test.test_asyncore.DispatcherTests.test_strerror @ linux-x86_64 +test.test_asyncore.DispatcherTests.test_unhandled @ linux-x86_64 +test.test_asyncore.DispatcherWithSendTests.test_send @ linux-x86_64 +test.test_asyncore.FileWrapperTest.test_close_twice @ linux-x86_64 +test.test_asyncore.FileWrapperTest.test_dispatcher @ linux-x86_64 +test.test_asyncore.FileWrapperTest.test_recv @ linux-x86_64 +test.test_asyncore.FileWrapperTest.test_send @ linux-x86_64 +test.test_asyncore.HelperFunctionTests.test_closeall @ linux-x86_64 +test.test_asyncore.HelperFunctionTests.test_closeall_default @ linux-x86_64 +test.test_asyncore.HelperFunctionTests.test_compact_traceback @ linux-x86_64 +test.test_asyncore.HelperFunctionTests.test_readwriteexc @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_bind @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_connection_attributes @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_create_socket @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_accept @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_accepted @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_close @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_close_after_conn_broken @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_connect @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_error @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_read @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_handle_write @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_quick_connect @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv4Select.test_set_reuse_addr @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_bind @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_connection_attributes @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_create_socket @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_accept @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_accepted @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_close @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_close_after_conn_broken @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_connect @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_error @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_read @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_handle_write @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_quick_connect @ linux-x86_64 +test.test_asyncore.TestAPI_UseIPv6Select.test_set_reuse_addr @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_connection_attributes @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_create_socket @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_accept @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_accepted @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_close @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_close_after_conn_broken @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_connect @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_error @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_read @ linux-x86_64 +test.test_asyncore.TestAPI_UseUnixSocketsSelect.test_handle_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_atexit.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_atexit.txt new file mode 100644 index 0000000000..a9abb7e8ef --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_atexit.txt @@ -0,0 +1 @@ +test.test_atexit.FunctionalTest.test_shutdown @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_augassign.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_augassign.txt new file mode 100644 index 0000000000..a052d1cb02 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_augassign.txt @@ -0,0 +1,7 @@ +test.test_augassign.AugAssignTest.testBasic @ linux-x86_64 +test.test_augassign.AugAssignTest.testCustomMethods1 @ linux-x86_64 +test.test_augassign.AugAssignTest.testCustomMethods2 @ linux-x86_64 +test.test_augassign.AugAssignTest.testInDict @ linux-x86_64 +test.test_augassign.AugAssignTest.testInList @ linux-x86_64 +test.test_augassign.AugAssignTest.testSequences @ linux-x86_64 +test.test_augassign.AugAssignTest.test_with_unpacking @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_base64.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_base64.txt new file mode 100644 index 0000000000..a0f858836c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_base64.txt @@ -0,0 +1,36 @@ +test.test_base64.BaseXYTestCase.test_ErrorHeritage @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_RFC4648_test_cases @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_a85_padding @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_a85decode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_a85decode_errors @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_a85encode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b16decode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b16encode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32decode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32decode_casefold @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32decode_error @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32encode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32hexdecode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32hexdecode_error @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32hexdecode_other_types @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32hexencode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b32hexencode_other_types @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b64decode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b64decode_invalid_chars @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b64decode_padding_error @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b64encode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b85_padding @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b85decode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b85decode_errors @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_b85encode @ linux-x86_64 +test.test_base64.BaseXYTestCase.test_decode_nonascii_str @ linux-x86_64 +test.test_base64.LegacyBase64TestCase.test_decode @ linux-x86_64 +test.test_base64.LegacyBase64TestCase.test_decodebytes @ linux-x86_64 +test.test_base64.LegacyBase64TestCase.test_encode @ linux-x86_64 +test.test_base64.LegacyBase64TestCase.test_encodebytes @ linux-x86_64 +test.test_base64.TestMain.test_decode @ linux-x86_64 +test.test_base64.TestMain.test_encode_decode @ linux-x86_64 +test.test_base64.TestMain.test_encode_file @ linux-x86_64 +test.test_base64.TestMain.test_encode_from_stdin @ linux-x86_64 +test.test_base64.TestMain.test_prints_usage_with_help_flag @ linux-x86_64 +test.test_base64.TestMain.test_prints_usage_with_invalid_flag @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_baseexception.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_baseexception.txt new file mode 100644 index 0000000000..9c96347c99 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_baseexception.txt @@ -0,0 +1,11 @@ +test.test_baseexception.ExceptionClassTests.test_builtins_new_style @ linux-x86_64 +test.test_baseexception.ExceptionClassTests.test_inheritance @ linux-x86_64 +test.test_baseexception.ExceptionClassTests.test_interface_multi_arg @ linux-x86_64 +test.test_baseexception.ExceptionClassTests.test_interface_no_arg @ linux-x86_64 +test.test_baseexception.ExceptionClassTests.test_interface_single_arg @ linux-x86_64 +test.test_baseexception.ExceptionClassTests.test_setstate_refcount_no_crash @ linux-x86_64 +test.test_baseexception.UsageTests.test_catch_BaseException_instance @ linux-x86_64 +test.test_baseexception.UsageTests.test_catch_non_BaseException @ linux-x86_64 +test.test_baseexception.UsageTests.test_catch_string @ linux-x86_64 +test.test_baseexception.UsageTests.test_raise_new_style_non_exception @ linux-x86_64 +test.test_baseexception.UsageTests.test_raise_string @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bdb.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bdb.txt new file mode 100644 index 0000000000..041d0880ae --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bdb.txt @@ -0,0 +1,30 @@ +test.test_bdb.BreakpointTestCase.test_bp_after_last_statement @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_bp_condition @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_bp_exception_on_condition_evaluation @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_bp_ignore_count @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_bp_on_non_existent_module @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_clear_at_no_bp @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_clear_two_bp_on_same_line @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_disabled_temporary_bp @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_ignore_count_on_disabled_bp @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_load_bps_from_previous_Bdb_instance @ linux-x86_64 +test.test_bdb.BreakpointTestCase.test_temporary_bp @ linux-x86_64 +test.test_bdb.IssuesTestCase.test_step_at_return_with_no_trace_in_caller @ linux-x86_64 +test.test_bdb.RunTestCase.test_run_step @ linux-x86_64 +test.test_bdb.RunTestCase.test_runeval_step @ linux-x86_64 +test.test_bdb.StateTestCase.test_down @ linux-x86_64 +test.test_bdb.StateTestCase.test_next @ linux-x86_64 +test.test_bdb.StateTestCase.test_next_in_caller_frame @ linux-x86_64 +test.test_bdb.StateTestCase.test_next_on_plain_statement @ linux-x86_64 +test.test_bdb.StateTestCase.test_next_over_import @ linux-x86_64 +test.test_bdb.StateTestCase.test_return @ linux-x86_64 +test.test_bdb.StateTestCase.test_return_in_caller_frame @ linux-x86_64 +test.test_bdb.StateTestCase.test_skip @ linux-x86_64 +test.test_bdb.StateTestCase.test_skip_with_no_name_module @ linux-x86_64 +test.test_bdb.StateTestCase.test_step @ linux-x86_64 +test.test_bdb.StateTestCase.test_step_next_on_last_statement @ linux-x86_64 +test.test_bdb.StateTestCase.test_until @ linux-x86_64 +test.test_bdb.StateTestCase.test_until_in_caller_frame @ linux-x86_64 +test.test_bdb.StateTestCase.test_until_with_too_large_count @ linux-x86_64 +test.test_bdb.StateTestCase.test_up @ linux-x86_64 +test.test_bdb.TestRegressions.test_format_stack_entry_no_lineno @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bigmem.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bigmem.txt new file mode 100644 index 0000000000..d45ef8543c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bigmem.txt @@ -0,0 +1,161 @@ +test.test_bigmem.BytearrayTest.test_capitalize @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_center @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_compare @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_concat @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_contains @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_count @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_decode @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_endswith @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_expandtabs @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_find @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_index @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_isalnum @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_isalpha @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_isdigit @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_islower @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_isspace @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_istitle @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_isupper @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_join @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_ljust @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_lower @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_lstrip @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_repeat @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_replace @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_rfind @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_rindex @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_rjust @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_rstrip @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_slice_and_getitem @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_split_small @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_splitlines @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_startswith @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_strip @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_swapcase @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_title @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_translate @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_upper @ linux-x86_64 +test.test_bigmem.BytearrayTest.test_zfill @ linux-x86_64 +test.test_bigmem.BytesTest.test_capitalize @ linux-x86_64 +test.test_bigmem.BytesTest.test_center @ linux-x86_64 +test.test_bigmem.BytesTest.test_compare @ linux-x86_64 +test.test_bigmem.BytesTest.test_concat @ linux-x86_64 +test.test_bigmem.BytesTest.test_contains @ linux-x86_64 +test.test_bigmem.BytesTest.test_count @ linux-x86_64 +test.test_bigmem.BytesTest.test_decode @ linux-x86_64 +test.test_bigmem.BytesTest.test_endswith @ linux-x86_64 +test.test_bigmem.BytesTest.test_expandtabs @ linux-x86_64 +test.test_bigmem.BytesTest.test_find @ linux-x86_64 +test.test_bigmem.BytesTest.test_hash @ linux-x86_64 +test.test_bigmem.BytesTest.test_index @ linux-x86_64 +test.test_bigmem.BytesTest.test_isalnum @ linux-x86_64 +test.test_bigmem.BytesTest.test_isalpha @ linux-x86_64 +test.test_bigmem.BytesTest.test_isdigit @ linux-x86_64 +test.test_bigmem.BytesTest.test_islower @ linux-x86_64 +test.test_bigmem.BytesTest.test_isspace @ linux-x86_64 +test.test_bigmem.BytesTest.test_istitle @ linux-x86_64 +test.test_bigmem.BytesTest.test_isupper @ linux-x86_64 +test.test_bigmem.BytesTest.test_join @ linux-x86_64 +test.test_bigmem.BytesTest.test_ljust @ linux-x86_64 +test.test_bigmem.BytesTest.test_lower @ linux-x86_64 +test.test_bigmem.BytesTest.test_repeat @ linux-x86_64 +test.test_bigmem.BytesTest.test_replace @ linux-x86_64 +test.test_bigmem.BytesTest.test_rfind @ linux-x86_64 +test.test_bigmem.BytesTest.test_rindex @ linux-x86_64 +test.test_bigmem.BytesTest.test_rjust @ linux-x86_64 +test.test_bigmem.BytesTest.test_slice_and_getitem @ linux-x86_64 +test.test_bigmem.BytesTest.test_split_large @ linux-x86_64 +test.test_bigmem.BytesTest.test_split_small @ linux-x86_64 +test.test_bigmem.BytesTest.test_splitlines @ linux-x86_64 +test.test_bigmem.BytesTest.test_startswith @ linux-x86_64 +test.test_bigmem.BytesTest.test_strip @ linux-x86_64 +test.test_bigmem.BytesTest.test_swapcase @ linux-x86_64 +test.test_bigmem.BytesTest.test_title @ linux-x86_64 +test.test_bigmem.BytesTest.test_translate @ linux-x86_64 +test.test_bigmem.BytesTest.test_upper @ linux-x86_64 +test.test_bigmem.BytesTest.test_zfill @ linux-x86_64 +test.test_bigmem.DictTest.test_dict @ linux-x86_64 +test.test_bigmem.ListTest.test_append @ linux-x86_64 +test.test_bigmem.ListTest.test_compare @ linux-x86_64 +test.test_bigmem.ListTest.test_concat_large @ linux-x86_64 +test.test_bigmem.ListTest.test_concat_small @ linux-x86_64 +test.test_bigmem.ListTest.test_contains @ linux-x86_64 +test.test_bigmem.ListTest.test_count @ linux-x86_64 +test.test_bigmem.ListTest.test_extend_large @ linux-x86_64 +test.test_bigmem.ListTest.test_extend_small @ linux-x86_64 +test.test_bigmem.ListTest.test_hash @ linux-x86_64 +test.test_bigmem.ListTest.test_index @ linux-x86_64 +test.test_bigmem.ListTest.test_index_and_slice @ linux-x86_64 +test.test_bigmem.ListTest.test_inplace_concat_large @ linux-x86_64 +test.test_bigmem.ListTest.test_inplace_concat_small @ linux-x86_64 +test.test_bigmem.ListTest.test_inplace_repeat_large @ linux-x86_64 +test.test_bigmem.ListTest.test_inplace_repeat_small @ linux-x86_64 +test.test_bigmem.ListTest.test_insert @ linux-x86_64 +test.test_bigmem.ListTest.test_pop @ linux-x86_64 +test.test_bigmem.ListTest.test_remove @ linux-x86_64 +test.test_bigmem.ListTest.test_repeat_large @ linux-x86_64 +test.test_bigmem.ListTest.test_repeat_small @ linux-x86_64 +test.test_bigmem.ListTest.test_repr_large @ linux-x86_64 +test.test_bigmem.ListTest.test_repr_small @ linux-x86_64 +test.test_bigmem.ListTest.test_reverse @ linux-x86_64 +test.test_bigmem.ListTest.test_sort @ linux-x86_64 +test.test_bigmem.StrTest.test_capitalize @ linux-x86_64 +test.test_bigmem.StrTest.test_center @ linux-x86_64 +test.test_bigmem.StrTest.test_compare @ linux-x86_64 +test.test_bigmem.StrTest.test_concat @ linux-x86_64 +test.test_bigmem.StrTest.test_contains @ linux-x86_64 +test.test_bigmem.StrTest.test_count @ linux-x86_64 +test.test_bigmem.StrTest.test_encode @ linux-x86_64 +test.test_bigmem.StrTest.test_encode_ascii @ linux-x86_64 +test.test_bigmem.StrTest.test_encode_raw_unicode_escape @ linux-x86_64 +test.test_bigmem.StrTest.test_encode_utf32 @ linux-x86_64 +test.test_bigmem.StrTest.test_encode_utf7 @ linux-x86_64 +test.test_bigmem.StrTest.test_endswith @ linux-x86_64 +test.test_bigmem.StrTest.test_expandtabs @ linux-x86_64 +test.test_bigmem.StrTest.test_find @ linux-x86_64 +test.test_bigmem.StrTest.test_format @ linux-x86_64 +test.test_bigmem.StrTest.test_index @ linux-x86_64 +test.test_bigmem.StrTest.test_isalnum @ linux-x86_64 +test.test_bigmem.StrTest.test_isalpha @ linux-x86_64 +test.test_bigmem.StrTest.test_isdigit @ linux-x86_64 +test.test_bigmem.StrTest.test_islower @ linux-x86_64 +test.test_bigmem.StrTest.test_isspace @ linux-x86_64 +test.test_bigmem.StrTest.test_istitle @ linux-x86_64 +test.test_bigmem.StrTest.test_isupper @ linux-x86_64 +test.test_bigmem.StrTest.test_join @ linux-x86_64 +test.test_bigmem.StrTest.test_ljust @ linux-x86_64 +test.test_bigmem.StrTest.test_lower @ linux-x86_64 +test.test_bigmem.StrTest.test_lstrip @ linux-x86_64 +test.test_bigmem.StrTest.test_repeat @ linux-x86_64 +test.test_bigmem.StrTest.test_replace @ linux-x86_64 +test.test_bigmem.StrTest.test_repr_large @ linux-x86_64 +test.test_bigmem.StrTest.test_repr_small @ linux-x86_64 +test.test_bigmem.StrTest.test_rfind @ linux-x86_64 +test.test_bigmem.StrTest.test_rindex @ linux-x86_64 +test.test_bigmem.StrTest.test_rjust @ linux-x86_64 +test.test_bigmem.StrTest.test_rstrip @ linux-x86_64 +test.test_bigmem.StrTest.test_split_large @ linux-x86_64 +test.test_bigmem.StrTest.test_split_small @ linux-x86_64 +test.test_bigmem.StrTest.test_splitlines @ linux-x86_64 +test.test_bigmem.StrTest.test_startswith @ linux-x86_64 +test.test_bigmem.StrTest.test_strip @ linux-x86_64 +test.test_bigmem.StrTest.test_swapcase @ linux-x86_64 +test.test_bigmem.StrTest.test_title @ linux-x86_64 +test.test_bigmem.StrTest.test_translate @ linux-x86_64 +test.test_bigmem.StrTest.test_unicode_repr @ linux-x86_64 +test.test_bigmem.StrTest.test_unicode_repr_wide @ linux-x86_64 +test.test_bigmem.StrTest.test_upper @ linux-x86_64 +test.test_bigmem.StrTest.test_zfill @ linux-x86_64 +test.test_bigmem.TupleTest.test_compare @ linux-x86_64 +test.test_bigmem.TupleTest.test_concat_large @ linux-x86_64 +test.test_bigmem.TupleTest.test_concat_small @ linux-x86_64 +test.test_bigmem.TupleTest.test_contains @ linux-x86_64 +test.test_bigmem.TupleTest.test_from_2G_generator @ linux-x86_64 +test.test_bigmem.TupleTest.test_from_almost_2G_generator @ linux-x86_64 +test.test_bigmem.TupleTest.test_hash @ linux-x86_64 +test.test_bigmem.TupleTest.test_index_and_slice @ linux-x86_64 +test.test_bigmem.TupleTest.test_repeat_large @ linux-x86_64 +test.test_bigmem.TupleTest.test_repeat_large_2 @ linux-x86_64 +test.test_bigmem.TupleTest.test_repeat_small @ linux-x86_64 +test.test_bigmem.TupleTest.test_repr_large @ linux-x86_64 +test.test_bigmem.TupleTest.test_repr_small @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binascii.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binascii.txt new file mode 100644 index 0000000000..5d7c43d458 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binascii.txt @@ -0,0 +1,28 @@ +test.test_binascii.ArrayBinASCIITest.test_b2a_base64_newline @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_base64valid @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_c_contiguity @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_crc32 @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_crc_hqx @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_exceptions @ linux-x86_64 +test.test_binascii.ArrayBinASCIITest.test_hex @ linux-x86_64 +test.test_binascii.BinASCIITest.test_b2a_base64_newline @ linux-x86_64 +test.test_binascii.BinASCIITest.test_base64valid @ linux-x86_64 +test.test_binascii.BinASCIITest.test_c_contiguity @ linux-x86_64 +test.test_binascii.BinASCIITest.test_crc32 @ linux-x86_64 +test.test_binascii.BinASCIITest.test_crc_hqx @ linux-x86_64 +test.test_binascii.BinASCIITest.test_exceptions @ linux-x86_64 +test.test_binascii.BinASCIITest.test_hex @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_b2a_base64_newline @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_base64valid @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_c_contiguity @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_crc32 @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_crc_hqx @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_exceptions @ linux-x86_64 +test.test_binascii.BytearrayBinASCIITest.test_hex @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_b2a_base64_newline @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_base64valid @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_c_contiguity @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_crc32 @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_crc_hqx @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_exceptions @ linux-x86_64 +test.test_binascii.MemoryviewBinASCIITest.test_hex @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binop.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binop.txt new file mode 100644 index 0000000000..f464c4d476 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_binop.txt @@ -0,0 +1,12 @@ +test.test_binop.FallbackBlockingTests.test_fallback_ne_blocking @ linux-x86_64 +test.test_binop.FallbackBlockingTests.test_fallback_rmethod_blocking @ linux-x86_64 +test.test_binop.OperationOrderTests.test_comparison_orders @ linux-x86_64 +test.test_binop.RatTestCase.test_add @ linux-x86_64 +test.test_binop.RatTestCase.test_constructor @ linux-x86_64 +test.test_binop.RatTestCase.test_div @ linux-x86_64 +test.test_binop.RatTestCase.test_eq @ linux-x86_64 +test.test_binop.RatTestCase.test_floordiv @ linux-x86_64 +test.test_binop.RatTestCase.test_gcd @ linux-x86_64 +test.test_binop.RatTestCase.test_mul @ linux-x86_64 +test.test_binop.RatTestCase.test_sub @ linux-x86_64 +test.test_binop.RatTestCase.test_true_div @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bisect.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bisect.txt new file mode 100644 index 0000000000..f52cf5eb45 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bisect.txt @@ -0,0 +1,21 @@ +test.test_bisect.TestBisectPython.test_backcompatibility @ linux-x86_64 +test.test_bisect.TestBisectPython.test_insort @ linux-x86_64 +test.test_bisect.TestBisectPython.test_insort_keynotNone @ linux-x86_64 +test.test_bisect.TestBisectPython.test_keyword_args @ linux-x86_64 +test.test_bisect.TestBisectPython.test_large_pyrange @ linux-x86_64 +test.test_bisect.TestBisectPython.test_large_range @ linux-x86_64 +test.test_bisect.TestBisectPython.test_lookups_with_key_function @ linux-x86_64 +test.test_bisect.TestBisectPython.test_negative_lo @ linux-x86_64 +test.test_bisect.TestBisectPython.test_optionalSlicing @ linux-x86_64 +test.test_bisect.TestBisectPython.test_precomputed @ linux-x86_64 +test.test_bisect.TestBisectPython.test_random @ linux-x86_64 +test.test_bisect.TestDocExamplePython.test_colors @ linux-x86_64 +test.test_bisect.TestDocExamplePython.test_grades @ linux-x86_64 +test.test_bisect.TestErrorHandlingPython.test_arg_parsing @ linux-x86_64 +test.test_bisect.TestErrorHandlingPython.test_cmp_err @ linux-x86_64 +test.test_bisect.TestErrorHandlingPython.test_get_only @ linux-x86_64 +test.test_bisect.TestErrorHandlingPython.test_len_only @ linux-x86_64 +test.test_bisect.TestErrorHandlingPython.test_non_sequence @ linux-x86_64 +test.test_bisect.TestInsortPython.test_backcompatibility @ linux-x86_64 +test.test_bisect.TestInsortPython.test_listDerived @ linux-x86_64 +test.test_bisect.TestInsortPython.test_vsBuiltinSort @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bool.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bool.txt new file mode 100644 index 0000000000..7f82eb32fc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bool.txt @@ -0,0 +1,30 @@ +test.test_bool.BoolTest.test_blocked @ linux-x86_64 +test.test_bool.BoolTest.test_bool_called_at_least_once @ linux-x86_64 +test.test_bool.BoolTest.test_bool_new @ linux-x86_64 +test.test_bool.BoolTest.test_boolean @ linux-x86_64 +test.test_bool.BoolTest.test_callable @ linux-x86_64 +test.test_bool.BoolTest.test_complex @ linux-x86_64 +test.test_bool.BoolTest.test_contains @ linux-x86_64 +test.test_bool.BoolTest.test_convert @ linux-x86_64 +test.test_bool.BoolTest.test_convert_to_bool @ linux-x86_64 +test.test_bool.BoolTest.test_fileclosed @ linux-x86_64 +test.test_bool.BoolTest.test_float @ linux-x86_64 +test.test_bool.BoolTest.test_format @ linux-x86_64 +test.test_bool.BoolTest.test_from_bytes @ linux-x86_64 +test.test_bool.BoolTest.test_hasattr @ linux-x86_64 +test.test_bool.BoolTest.test_int @ linux-x86_64 +test.test_bool.BoolTest.test_isinstance @ linux-x86_64 +test.test_bool.BoolTest.test_issubclass @ linux-x86_64 +test.test_bool.BoolTest.test_keyword_args @ linux-x86_64 +test.test_bool.BoolTest.test_marshal @ linux-x86_64 +test.test_bool.BoolTest.test_math @ linux-x86_64 +test.test_bool.BoolTest.test_operator @ linux-x86_64 +test.test_bool.BoolTest.test_pickle @ linux-x86_64 +test.test_bool.BoolTest.test_picklevalues @ linux-x86_64 +test.test_bool.BoolTest.test_real_and_imag @ linux-x86_64 +test.test_bool.BoolTest.test_repr @ linux-x86_64 +test.test_bool.BoolTest.test_sane_len @ linux-x86_64 +test.test_bool.BoolTest.test_str @ linux-x86_64 +test.test_bool.BoolTest.test_string @ linux-x86_64 +test.test_bool.BoolTest.test_subclass @ linux-x86_64 +test.test_bool.BoolTest.test_types @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_buffer.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_buffer.txt new file mode 100644 index 0000000000..e63458e0f4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_buffer.txt @@ -0,0 +1,35 @@ +test.test_buffer.TestBufferProtocol.test_issue_7385 @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_array @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_cast @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_cast_zero_shape @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_cast_zero_strides @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_check_released @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_compare_multidim_zero_shape @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_compare_zero_shape @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_getbuffer_undefined @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_index @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_redirect @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_repr @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_sequence @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_serializing @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_memoryview_tolist @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_cmp_contig @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_fortran @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_hash @ linux-x86_64 +!test.test_buffer.TestBufferProtocol.test_ndarray_index_getitem_multidim @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_index_invalid @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_index_null_strides @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_index_scalar @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_linked_list @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_memoryview_from_buffer @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_offset @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_random_invalid @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_re_export @ linux-x86_64 +!test.test_buffer.TestBufferProtocol.test_ndarray_slice_assign_multidim @ linux-x86_64 +!test.test_buffer.TestBufferProtocol.test_ndarray_slice_multidim @ linux-x86_64 +!test.test_buffer.TestBufferProtocol.test_ndarray_slice_redundant_suboffsets @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_slice_zero_shape @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_tolist_null_strides @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_zero_shape @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_ndarray_zero_strides @ linux-x86_64 +test.test_buffer.TestBufferProtocol.test_py_buffer_to_contiguous @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bufio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bufio.txt new file mode 100644 index 0000000000..5e4e38c7ee --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bufio.txt @@ -0,0 +1,4 @@ +test.test_bufio.CBufferSizeTest.test_nullpat @ linux-x86_64 +test.test_bufio.CBufferSizeTest.test_primepat @ linux-x86_64 +test.test_bufio.PyBufferSizeTest.test_nullpat @ linux-x86_64 +test.test_bufio.PyBufferSizeTest.test_primepat @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_builtin.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_builtin.txt new file mode 100644 index 0000000000..7cbb95d21b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_builtin.txt @@ -0,0 +1,87 @@ +DocTestCase.builtins.zip @ linux-x86_64 +test.test_builtin.BuiltinTest.test_abs @ linux-x86_64 +test.test_builtin.BuiltinTest.test_all @ linux-x86_64 +test.test_builtin.BuiltinTest.test_any @ linux-x86_64 +test.test_builtin.BuiltinTest.test_ascii @ linux-x86_64 +test.test_builtin.BuiltinTest.test_bin @ linux-x86_64 +test.test_builtin.BuiltinTest.test_bug_27936 @ linux-x86_64 +test.test_builtin.BuiltinTest.test_bytearray_extend_error @ linux-x86_64 +test.test_builtin.BuiltinTest.test_bytearray_join_with_custom_iterator @ linux-x86_64 +test.test_builtin.BuiltinTest.test_bytearray_translate @ linux-x86_64 +test.test_builtin.BuiltinTest.test_callable @ linux-x86_64 +test.test_builtin.BuiltinTest.test_chr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_cmp @ linux-x86_64 +test.test_builtin.BuiltinTest.test_construct_singletons @ linux-x86_64 +test.test_builtin.BuiltinTest.test_delattr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_dir @ linux-x86_64 +test.test_builtin.BuiltinTest.test_divmod @ linux-x86_64 +test.test_builtin.BuiltinTest.test_eval @ linux-x86_64 +test.test_builtin.BuiltinTest.test_exec @ linux-x86_64 +test.test_builtin.BuiltinTest.test_exec_redirected @ linux-x86_64 +test.test_builtin.BuiltinTest.test_filter @ linux-x86_64 +test.test_builtin.BuiltinTest.test_filter_dealloc @ linux-x86_64 +test.test_builtin.BuiltinTest.test_filter_pickle @ linux-x86_64 +test.test_builtin.BuiltinTest.test_format @ linux-x86_64 +test.test_builtin.BuiltinTest.test_general_eval @ linux-x86_64 +test.test_builtin.BuiltinTest.test_getattr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_hasattr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_hash @ linux-x86_64 +test.test_builtin.BuiltinTest.test_hex @ linux-x86_64 +test.test_builtin.BuiltinTest.test_id @ linux-x86_64 +test.test_builtin.BuiltinTest.test_import @ linux-x86_64 +test.test_builtin.BuiltinTest.test_input @ linux-x86_64 +test.test_builtin.BuiltinTest.test_isinstance @ linux-x86_64 +test.test_builtin.BuiltinTest.test_issubclass @ linux-x86_64 +test.test_builtin.BuiltinTest.test_iter @ linux-x86_64 +test.test_builtin.BuiltinTest.test_len @ linux-x86_64 +test.test_builtin.BuiltinTest.test_map @ linux-x86_64 +test.test_builtin.BuiltinTest.test_map_pickle @ linux-x86_64 +test.test_builtin.BuiltinTest.test_max @ linux-x86_64 +test.test_builtin.BuiltinTest.test_min @ linux-x86_64 +test.test_builtin.BuiltinTest.test_neg @ linux-x86_64 +test.test_builtin.BuiltinTest.test_next @ linux-x86_64 +test.test_builtin.BuiltinTest.test_oct @ linux-x86_64 +test.test_builtin.BuiltinTest.test_open @ linux-x86_64 +test.test_builtin.BuiltinTest.test_open_default_encoding @ linux-x86_64 +test.test_builtin.BuiltinTest.test_open_non_inheritable @ linux-x86_64 +test.test_builtin.BuiltinTest.test_ord @ linux-x86_64 +test.test_builtin.BuiltinTest.test_pow @ linux-x86_64 +test.test_builtin.BuiltinTest.test_repr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_round @ linux-x86_64 +test.test_builtin.BuiltinTest.test_round_large @ linux-x86_64 +test.test_builtin.BuiltinTest.test_setattr @ linux-x86_64 +test.test_builtin.BuiltinTest.test_sum @ linux-x86_64 +test.test_builtin.BuiltinTest.test_type @ linux-x86_64 +test.test_builtin.BuiltinTest.test_vars @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_bad_iterable @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_pickle @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_pickle_strict @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_pickle_strict_fail @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_strict @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_strict_error_handling @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_strict_error_handling_stopiteration @ linux-x86_64 +test.test_builtin.BuiltinTest.test_zip_strict_iterators @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_breakpoint @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_breakpoint_with_args_and_keywords @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_breakpoint_with_breakpointhook_reset @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_breakpoint_with_breakpointhook_set @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_breakpoint_with_passthru_error @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_good_path_builtin @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_good_path_empty_string @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_good_path_noop_0 @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_good_path_other @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_ignored_when_hook_is_set @ linux-x86_64 +test.test_builtin.TestBreakpoint.test_envar_unimportable @ linux-x86_64 +test.test_builtin.TestSorted.test_bad_arguments @ linux-x86_64 +test.test_builtin.TestSorted.test_baddecorator @ linux-x86_64 +test.test_builtin.TestSorted.test_basic @ linux-x86_64 +test.test_builtin.TestSorted.test_inputtypes @ linux-x86_64 +test.test_builtin.TestType.test_bad_args @ linux-x86_64 +test.test_builtin.TestType.test_bad_slots @ linux-x86_64 +test.test_builtin.TestType.test_namespace_order @ linux-x86_64 +test.test_builtin.TestType.test_new_type @ linux-x86_64 +test.test_builtin.TestType.test_type_doc @ linux-x86_64 +test.test_builtin.TestType.test_type_name @ linux-x86_64 +test.test_builtin.TestType.test_type_nokwargs @ linux-x86_64 +test.test_builtin.TestType.test_type_qualname @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bytes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bytes.txt new file mode 100644 index 0000000000..ad3d40a2d2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bytes.txt @@ -0,0 +1,269 @@ +test.test_bytes.AssortedBytesTest.test_compare_bytes_to_bytearray @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_doc @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_format @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_from_bytearray @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_literal @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_repr_str @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_return_self @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_rsplit_bytearray @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_split_bytearray @ linux-x86_64 +test.test_bytes.AssortedBytesTest.test_to_str @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_additional_rsplit @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_additional_split @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_capitalize @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_center @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_count @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_expandtabs @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_find @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_find_periodic_pattern @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_find_shift_table_overflow @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_fixtype @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_index @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isalnum @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isalpha @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isascii @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isdigit @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_islower @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isspace @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_istitle @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_isupper @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_ljust @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_lower @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_removeprefix @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_removesuffix @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_replace @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_rfind @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_rindex @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_rjust @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_rsplit @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_split @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_splitlines @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_strip @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_strip_whitespace @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_swapcase @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_title @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_upper @ linux-x86_64 +test.test_bytes.ByteArrayAsStringTest.test_zfill @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_basic @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_copy @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_fromhex @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_init_override @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_join @ linux-x86_64 +test.test_bytes.ByteArraySubclassTest.test_pickle @ linux-x86_64 +test.test_bytes.ByteArraySubclassWithSlotsTest.test_basic @ linux-x86_64 +test.test_bytes.ByteArraySubclassWithSlotsTest.test_copy @ linux-x86_64 +test.test_bytes.ByteArraySubclassWithSlotsTest.test_fromhex @ linux-x86_64 +test.test_bytes.ByteArraySubclassWithSlotsTest.test_join @ linux-x86_64 +test.test_bytes.ByteArraySubclassWithSlotsTest.test_pickle @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_alloc @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_append @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_basics @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_bytearray_api @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_center @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_clear @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_compare @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_compare_to_str @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_concat @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_constructor_exceptions @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_constructor_type_errors @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_constructor_value_errors @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_contains @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_copied @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_copy @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_count @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_decode @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_del_expand @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_delitem @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_empty_sequence @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_encoding @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_endswith @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_exhausted_iterator @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_extend @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_extended_getslice @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_extended_set_del_slice @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_fifo_overrun @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_find @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_find_etc_raise_correct_error_messages @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_buffer @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_index @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_int @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_iterable @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_list @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_mutating_list @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_ssize @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_from_tuple @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_fromhex @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_getitem_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_getslice @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_hex @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_hex_separator_basics @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_hex_separator_five_bytes @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_hex_separator_six_bytes @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_iconcat @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_imod @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_index @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_init_alloc @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_insert @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_integer_arguments_out_of_byte_range @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_irepeat @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_irepeat_1char @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_iterator_length_hint @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_iterator_pickling @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_join @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_ljust @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_maketrans @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_mod @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_nohash @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_none_arguments @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_nosort @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_ord @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_partition @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_partition_bytearray_doesnt_share_nullstring @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_partition_int_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_partition_string_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_pickling @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_pop @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_regexps @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_remove @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_repeat @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_repeat_1char @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_repeat_after_setslice @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_replace @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_replace_int_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_reverse @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_reversed @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rfind @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rindex @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rjust @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rmod @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rpartition @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_rsplit_unicodewhitespace @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_setitem @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_setitem_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_setslice @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_setslice_extend @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_setslice_trap @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_split_int_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_split_string_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_split_unicodewhitespace @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_sq_item @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_startswith @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_strip_bytearray @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_strip_int_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_strip_string_error @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_translate @ linux-x86_64 +test.test_bytes.ByteArrayTest.test_xjust_int_error @ linux-x86_64 +test.test_bytes.BytearrayPEP3137Test.test_returns_new_copy @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_additional_rsplit @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_additional_split @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_capitalize @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_center @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_count @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_expandtabs @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_find @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_find_periodic_pattern @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_find_shift_table_overflow @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_fixtype @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_index @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isalnum @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isalpha @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isascii @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isdigit @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_islower @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isspace @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_istitle @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_isupper @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_ljust @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_lower @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_removeprefix @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_removesuffix @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_replace @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_rfind @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_rindex @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_rjust @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_rsplit @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_split @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_splitlines @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_strip @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_strip_whitespace @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_swapcase @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_title @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_upper @ linux-x86_64 +test.test_bytes.BytesAsStringTest.test_zfill @ linux-x86_64 +test.test_bytes.BytesSubclassTest.test_basic @ linux-x86_64 +test.test_bytes.BytesSubclassTest.test_copy @ linux-x86_64 +test.test_bytes.BytesSubclassTest.test_fromhex @ linux-x86_64 +test.test_bytes.BytesSubclassTest.test_join @ linux-x86_64 +test.test_bytes.BytesSubclassTest.test_pickle @ linux-x86_64 +test.test_bytes.BytesTest.test__bytes__ @ linux-x86_64 +test.test_bytes.BytesTest.test_basics @ linux-x86_64 +test.test_bytes.BytesTest.test_buffer_is_readonly @ linux-x86_64 +test.test_bytes.BytesTest.test_bytes_blocking @ linux-x86_64 +test.test_bytes.BytesTest.test_center @ linux-x86_64 +test.test_bytes.BytesTest.test_compare @ linux-x86_64 +test.test_bytes.BytesTest.test_compare_to_str @ linux-x86_64 +test.test_bytes.BytesTest.test_concat @ linux-x86_64 +test.test_bytes.BytesTest.test_constructor_exceptions @ linux-x86_64 +test.test_bytes.BytesTest.test_constructor_type_errors @ linux-x86_64 +test.test_bytes.BytesTest.test_constructor_value_errors @ linux-x86_64 +test.test_bytes.BytesTest.test_contains @ linux-x86_64 +test.test_bytes.BytesTest.test_copy @ linux-x86_64 +test.test_bytes.BytesTest.test_count @ linux-x86_64 +test.test_bytes.BytesTest.test_custom @ linux-x86_64 +test.test_bytes.BytesTest.test_decode @ linux-x86_64 +test.test_bytes.BytesTest.test_empty_sequence @ linux-x86_64 +test.test_bytes.BytesTest.test_encoding @ linux-x86_64 +test.test_bytes.BytesTest.test_endswith @ linux-x86_64 +test.test_bytes.BytesTest.test_extended_getslice @ linux-x86_64 +test.test_bytes.BytesTest.test_find @ linux-x86_64 +test.test_bytes.BytesTest.test_find_etc_raise_correct_error_messages @ linux-x86_64 +test.test_bytes.BytesTest.test_from_buffer @ linux-x86_64 +test.test_bytes.BytesTest.test_from_index @ linux-x86_64 +test.test_bytes.BytesTest.test_from_int @ linux-x86_64 +test.test_bytes.BytesTest.test_from_iterable @ linux-x86_64 +test.test_bytes.BytesTest.test_from_list @ linux-x86_64 +test.test_bytes.BytesTest.test_from_mutating_list @ linux-x86_64 +test.test_bytes.BytesTest.test_from_ssize @ linux-x86_64 +test.test_bytes.BytesTest.test_from_tuple @ linux-x86_64 +test.test_bytes.BytesTest.test_fromhex @ linux-x86_64 +test.test_bytes.BytesTest.test_getitem_error @ linux-x86_64 +test.test_bytes.BytesTest.test_getslice @ linux-x86_64 +test.test_bytes.BytesTest.test_hex @ linux-x86_64 +test.test_bytes.BytesTest.test_hex_separator_basics @ linux-x86_64 +test.test_bytes.BytesTest.test_hex_separator_five_bytes @ linux-x86_64 +test.test_bytes.BytesTest.test_hex_separator_six_bytes @ linux-x86_64 +test.test_bytes.BytesTest.test_imod @ linux-x86_64 +test.test_bytes.BytesTest.test_index @ linux-x86_64 +test.test_bytes.BytesTest.test_integer_arguments_out_of_byte_range @ linux-x86_64 +test.test_bytes.BytesTest.test_iterator_pickling @ linux-x86_64 +test.test_bytes.BytesTest.test_join @ linux-x86_64 +test.test_bytes.BytesTest.test_ljust @ linux-x86_64 +test.test_bytes.BytesTest.test_maketrans @ linux-x86_64 +test.test_bytes.BytesTest.test_mod @ linux-x86_64 +test.test_bytes.BytesTest.test_none_arguments @ linux-x86_64 +test.test_bytes.BytesTest.test_ord @ linux-x86_64 +test.test_bytes.BytesTest.test_partition @ linux-x86_64 +test.test_bytes.BytesTest.test_partition_int_error @ linux-x86_64 +test.test_bytes.BytesTest.test_partition_string_error @ linux-x86_64 +test.test_bytes.BytesTest.test_pickling @ linux-x86_64 +test.test_bytes.BytesTest.test_repeat @ linux-x86_64 +test.test_bytes.BytesTest.test_repeat_1char @ linux-x86_64 +test.test_bytes.BytesTest.test_replace @ linux-x86_64 +test.test_bytes.BytesTest.test_replace_int_error @ linux-x86_64 +test.test_bytes.BytesTest.test_reversed @ linux-x86_64 +test.test_bytes.BytesTest.test_rfind @ linux-x86_64 +test.test_bytes.BytesTest.test_rindex @ linux-x86_64 +test.test_bytes.BytesTest.test_rjust @ linux-x86_64 +test.test_bytes.BytesTest.test_rmod @ linux-x86_64 +test.test_bytes.BytesTest.test_rpartition @ linux-x86_64 +test.test_bytes.BytesTest.test_rsplit_unicodewhitespace @ linux-x86_64 +test.test_bytes.BytesTest.test_split_int_error @ linux-x86_64 +test.test_bytes.BytesTest.test_split_string_error @ linux-x86_64 +test.test_bytes.BytesTest.test_split_unicodewhitespace @ linux-x86_64 +test.test_bytes.BytesTest.test_sq_item @ linux-x86_64 +test.test_bytes.BytesTest.test_startswith @ linux-x86_64 +test.test_bytes.BytesTest.test_strip_bytearray @ linux-x86_64 +test.test_bytes.BytesTest.test_strip_int_error @ linux-x86_64 +test.test_bytes.BytesTest.test_strip_string_error @ linux-x86_64 +test.test_bytes.BytesTest.test_translate @ linux-x86_64 +test.test_bytes.BytesTest.test_xjust_int_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bz2.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bz2.txt new file mode 100644 index 0000000000..207a85ee3c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_bz2.txt @@ -0,0 +1,94 @@ +test.test_bz2.BZ2CompressorTest.testCompress @ linux-x86_64 +test.test_bz2.BZ2CompressorTest.testCompress4G @ linux-x86_64 +test.test_bz2.BZ2CompressorTest.testCompressChunks10 @ linux-x86_64 +test.test_bz2.BZ2CompressorTest.testCompressEmptyString @ linux-x86_64 +test.test_bz2.BZ2CompressorTest.testPickle @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testDecompress @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testDecompress4G @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testDecompressChunks10 @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testDecompressUnusedData @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testDecompressorChunksMaxsize @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testEOFError @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.testPickle @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.test_Constructor @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.test_decompressor_inputbuf_1 @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.test_decompressor_inputbuf_2 @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.test_decompressor_inputbuf_3 @ linux-x86_64 +test.test_bz2.BZ2DecompressorTest.test_failure @ linux-x86_64 +test.test_bz2.BZ2FileTest.testAppend @ linux-x86_64 +test.test_bz2.BZ2FileTest.testBadArgs @ linux-x86_64 +test.test_bz2.BZ2FileTest.testClosedIteratorDeadlock @ linux-x86_64 +test.test_bz2.BZ2FileTest.testContextProtocol @ linux-x86_64 +test.test_bz2.BZ2FileTest.testDecompressLimited @ linux-x86_64 +test.test_bz2.BZ2FileTest.testFileno @ linux-x86_64 +test.test_bz2.BZ2FileTest.testIterator @ linux-x86_64 +test.test_bz2.BZ2FileTest.testIteratorMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testMixedIterationAndReads @ linux-x86_64 +test.test_bz2.BZ2FileTest.testMultiStreamOrdering @ linux-x86_64 +test.test_bz2.BZ2FileTest.testOpenBytesFilename @ linux-x86_64 +test.test_bz2.BZ2FileTest.testOpenNonexistent @ linux-x86_64 +test.test_bz2.BZ2FileTest.testOpenPathLikeFilename @ linux-x86_64 +test.test_bz2.BZ2FileTest.testPeek @ linux-x86_64 +test.test_bz2.BZ2FileTest.testPeekBytesIO @ linux-x86_64 +test.test_bz2.BZ2FileTest.testRead @ linux-x86_64 +test.test_bz2.BZ2FileTest.testRead0 @ linux-x86_64 +test.test_bz2.BZ2FileTest.testRead100 @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadBadFile @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadBytesIO @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadChunk10 @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadChunk10MultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadInto @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadLine @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadLineMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadLines @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadLinesMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadMonkeyMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadMultiStreamTrailingJunk @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadTrailingJunk @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadable @ linux-x86_64 +test.test_bz2.BZ2FileTest.testReadlinesNoNewline @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekBackwards @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekBackwardsAcrossStreams @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekBackwardsBytesIO @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekBackwardsFromEnd @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekBackwardsFromEndAcrossStreams @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekForward @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekForwardAcrossStreams @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekForwardBytesIO @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPostEnd @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPostEndMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPostEndTwice @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPostEndTwiceMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPreStart @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekPreStartMultiStream @ linux-x86_64 +test.test_bz2.BZ2FileTest.testSeekable @ linux-x86_64 +test.test_bz2.BZ2FileTest.testThreading @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWritable @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWrite @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWriteBytesIO @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWriteChunks10 @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWriteLines @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWriteMethodsOnReadOnlyFile @ linux-x86_64 +test.test_bz2.BZ2FileTest.testWriteNonDefaultCompressLevel @ linux-x86_64 +test.test_bz2.BZ2FileTest.test_issue44439 @ linux-x86_64 +test.test_bz2.BZ2FileTest.test_read_truncated @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testCompress @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testCompressEmptyString @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompress @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressBadData @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressEmpty @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressIncomplete @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressMultiStream @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressMultiStreamTrailingJunk @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressToEmptyString @ linux-x86_64 +test.test_bz2.CompressDecompressTest.testDecompressTrailingJunk @ linux-x86_64 +test.test_bz2.OpenTest.test_bad_params @ linux-x86_64 +test.test_bz2.OpenTest.test_binary_modes @ linux-x86_64 +test.test_bz2.OpenTest.test_encoding @ linux-x86_64 +test.test_bz2.OpenTest.test_encoding_error_handler @ linux-x86_64 +test.test_bz2.OpenTest.test_fileobj @ linux-x86_64 +test.test_bz2.OpenTest.test_implicit_binary_modes @ linux-x86_64 +test.test_bz2.OpenTest.test_newline @ linux-x86_64 +test.test_bz2.OpenTest.test_text_modes @ linux-x86_64 +test.test_bz2.OpenTest.test_x_mode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_calendar.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_calendar.txt new file mode 100644 index 0000000000..2073a0d353 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_calendar.txt @@ -0,0 +1,71 @@ +test.test_calendar.CalendarTestCase.test_days @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_enumerate_weekdays @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_illegal_weekday_reported @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_isleap @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_itermonthdays @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_itermonthdays2 @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_itermonthdays3 @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_itermonthdays4 @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_iterweekdays @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_locale_calendar_formatweekday @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_locale_calendars @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_locale_html_calendar_custom_css_class_month_name @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_locale_html_calendar_custom_css_class_weekday @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_months @ linux-x86_64 +test.test_calendar.CalendarTestCase.test_setfirstweekday @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_help @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_html_output_current_year @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_html_output_year_css @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_html_output_year_encoding @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_illegal_arguments @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_encoding @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_lines @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_locale @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_months @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_spacing @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_type @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_option_width @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_output_current_year @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_output_month @ linux-x86_64 +test.test_calendar.CommandLineTestCase.test_output_year @ linux-x86_64 +test.test_calendar.LeapdaysTestCase.test_no_leapdays @ linux-x86_64 +test.test_calendar.LeapdaysTestCase.test_no_leapdays_upper_boundary @ linux-x86_64 +test.test_calendar.LeapdaysTestCase.test_no_range @ linux-x86_64 +test.test_calendar.LeapdaysTestCase.test_one_leapday_lower_boundary @ linux-x86_64 +test.test_calendar.LeapdaysTestCase.test_several_leapyears_in_range @ linux-x86_64 +test.test_calendar.MiscTestCase.test__all__ @ linux-x86_64 +test.test_calendar.MondayTestCase.test_april @ linux-x86_64 +test.test_calendar.MondayTestCase.test_december @ linux-x86_64 +test.test_calendar.MondayTestCase.test_february @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_december @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_february_leap @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_february_nonleap @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_illegal_month_reported @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_january @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_thirteenth_month @ linux-x86_64 +test.test_calendar.MonthRangeTestCase.test_zeroth_month @ linux-x86_64 +test.test_calendar.OutputTestCase.test_format @ linux-x86_64 +test.test_calendar.OutputTestCase.test_formatmonth @ linux-x86_64 +test.test_calendar.OutputTestCase.test_formatmonthname_with_year @ linux-x86_64 +test.test_calendar.OutputTestCase.test_formatmonthname_without_year @ linux-x86_64 +test.test_calendar.OutputTestCase.test_formatweekheader_long @ linux-x86_64 +test.test_calendar.OutputTestCase.test_formatweekheader_short @ linux-x86_64 +test.test_calendar.OutputTestCase.test_output @ linux-x86_64 +test.test_calendar.OutputTestCase.test_output_htmlcalendar_encoding_ascii @ linux-x86_64 +test.test_calendar.OutputTestCase.test_output_htmlcalendar_encoding_utf8 @ linux-x86_64 +test.test_calendar.OutputTestCase.test_output_textcalendar @ linux-x86_64 +test.test_calendar.OutputTestCase.test_prmonth @ linux-x86_64 +test.test_calendar.OutputTestCase.test_prweek @ linux-x86_64 +test.test_calendar.OutputTestCase.test_pryear @ linux-x86_64 +test.test_calendar.OutputTestCase.test_yeardatescalendar @ linux-x86_64 +test.test_calendar.OutputTestCase.test_yeardayscalendar @ linux-x86_64 +test.test_calendar.SundayTestCase.test_april @ linux-x86_64 +test.test_calendar.SundayTestCase.test_december @ linux-x86_64 +test.test_calendar.SundayTestCase.test_february @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_format_year @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_format_year_head @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_formatmonth @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_formatmonthname @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_formatweek @ linux-x86_64 +test.test_calendar.TestSubClassingCase.test_formatweek_head @ linux-x86_64 +test.test_calendar.TimegmTestCase.test_timegm @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_call.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_call.txt new file mode 100644 index 0000000000..f0f74964cc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_call.txt @@ -0,0 +1,66 @@ +test.test_call.FastCallTests.test_fastcall @ linux-x86_64 +test.test_call.FastCallTests.test_fastcall_clearing_dict @ linux-x86_64 +test.test_call.FastCallTests.test_vectorcall @ linux-x86_64 +test.test_call.FastCallTests.test_vectorcall_dict @ linux-x86_64 +test.test_call.FunctionCalls.test_frames_are_popped_after_failed_calls @ linux-x86_64 +test.test_call.FunctionCalls.test_kwargs_order @ linux-x86_64 +test.test_call.TestCallingConventions.test_fastcall @ linux-x86_64 +test.test_call.TestCallingConventions.test_fastcall_ext @ linux-x86_64 +test.test_call.TestCallingConventions.test_fastcall_keywords @ linux-x86_64 +test.test_call.TestCallingConventions.test_fastcall_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventions.test_noargs @ linux-x86_64 +test.test_call.TestCallingConventions.test_noargs_ext @ linux-x86_64 +test.test_call.TestCallingConventions.test_o @ linux-x86_64 +test.test_call.TestCallingConventions.test_o_ext @ linux-x86_64 +test.test_call.TestCallingConventions.test_varargs @ linux-x86_64 +test.test_call.TestCallingConventions.test_varargs_ext @ linux-x86_64 +test.test_call.TestCallingConventions.test_varargs_keywords @ linux-x86_64 +test.test_call.TestCallingConventions.test_varargs_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_fastcall @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_fastcall_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_fastcall_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_fastcall_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_noargs @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_noargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_o @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_o_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_varargs @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_varargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_varargs_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsClass.test_varargs_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_fastcall @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_fastcall_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_fastcall_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_fastcall_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_noargs @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_noargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_o @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_o_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_varargs @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_varargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_varargs_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsClassInstance.test_varargs_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_fastcall @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_fastcall_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_fastcall_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_fastcall_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_noargs @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_noargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_o @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_o_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_varargs @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_varargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_varargs_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsInstance.test_varargs_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_fastcall @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_fastcall_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_fastcall_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_fastcall_keywords_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_noargs @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_noargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_o @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_o_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_varargs @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_varargs_ext @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_varargs_keywords @ linux-x86_64 +test.test_call.TestCallingConventionsStatic.test_varargs_keywords_ext @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_capi.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_capi.txt new file mode 100644 index 0000000000..cf2abd1c77 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_capi.txt @@ -0,0 +1,150 @@ +test.test_capi.test_codecs.CAPITest.test_decodeutf8 @ linux-x86_64 +test.test_capi.test_codecs.CAPITest.test_decodeutf8stateful @ linux-x86_64 +test.test_capi.test_eval_code_ex.PyEval_EvalCodeExTests.test_simple @ linux-x86_64 +test.test_capi.test_eval_code_ex.PyEval_EvalCodeExTests.test_with_args @ linux-x86_64 +test.test_capi.test_eval_code_ex.PyEval_EvalCodeExTests.test_with_closure @ linux-x86_64 +test.test_capi.test_eval_code_ex.PyEval_EvalCodeExTests.test_with_default @ linux-x86_64 +test.test_capi.test_eval_code_ex.PyEval_EvalCodeExTests.test_with_kwarg_default @ linux-x86_64 +test.test_capi.test_getargs.Boolean_TestCase.test_p @ linux-x86_64 +test.test_capi.test_getargs.Bytes_TestCase.test_c @ linux-x86_64 +test.test_capi.test_getargs.Bytes_TestCase.test_w_star @ linux-x86_64 +test.test_capi.test_getargs.Bytes_TestCase.test_y @ linux-x86_64 +test.test_capi.test_getargs.Bytes_TestCase.test_y_hash @ linux-x86_64 +test.test_capi.test_getargs.Bytes_TestCase.test_y_star @ linux-x86_64 +test.test_capi.test_getargs.Float_TestCase.test_D @ linux-x86_64 +test.test_capi.test_getargs.Float_TestCase.test_d @ linux-x86_64 +test.test_capi.test_getargs.Float_TestCase.test_f @ linux-x86_64 +test.test_capi.test_getargs.Float_TestCase.test_f_rounding @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_invalid_keyword @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_keyword_args @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_mixed_args @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_optional_args @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_positional_args @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_required_args @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_surrogate_keyword @ linux-x86_64 +test.test_capi.test_getargs.KeywordOnly_TestCase.test_too_many_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_invalid_keyword @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_keyword_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_kwargs @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_mixed_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_optional_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_positional_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_required_args @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_surrogate_keyword @ linux-x86_64 +test.test_capi.test_getargs.Keywords_TestCase.test_too_many_args @ linux-x86_64 +test.test_capi.test_getargs.LongLong_TestCase.test_K @ linux-x86_64 +test.test_capi.test_getargs.LongLong_TestCase.test_L @ linux-x86_64 +test.test_capi.test_getargs.Object_TestCase.test_S @ linux-x86_64 +test.test_capi.test_getargs.Object_TestCase.test_Y @ linux-x86_64 +test.test_capi.test_getargs.ParseTupleAndKeywords_Test.test_bad_use @ linux-x86_64 +test.test_capi.test_getargs.ParseTupleAndKeywords_Test.test_nested_tuple @ linux-x86_64 +test.test_capi.test_getargs.ParseTupleAndKeywords_Test.test_parse_tuple_and_keywords @ linux-x86_64 +test.test_capi.test_getargs.ParseTupleAndKeywords_Test.test_positional_only @ linux-x86_64 +test.test_capi.test_getargs.PositionalOnlyAndKeywords_TestCase.test_empty_keyword @ linux-x86_64 +test.test_capi.test_getargs.PositionalOnlyAndKeywords_TestCase.test_mixed_args @ linux-x86_64 +test.test_capi.test_getargs.PositionalOnlyAndKeywords_TestCase.test_optional_args @ linux-x86_64 +test.test_capi.test_getargs.PositionalOnlyAndKeywords_TestCase.test_positional_args @ linux-x86_64 +test.test_capi.test_getargs.PositionalOnlyAndKeywords_TestCase.test_required_args @ linux-x86_64 +test.test_capi.test_getargs.Signed_TestCase.test_h @ linux-x86_64 +test.test_capi.test_getargs.Signed_TestCase.test_i @ linux-x86_64 +test.test_capi.test_getargs.Signed_TestCase.test_l @ linux-x86_64 +test.test_capi.test_getargs.Signed_TestCase.test_n @ linux-x86_64 +test.test_capi.test_getargs.SkipitemTest.test_skipitem @ linux-x86_64 +test.test_capi.test_getargs.SkipitemTest.test_skipitem_with_suffix @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_C @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_gh_99240_clear_args @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_s @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_s_hash @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_s_hash_int @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_s_star @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_z @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_z_hash @ linux-x86_64 +test.test_capi.test_getargs.String_TestCase.test_z_star @ linux-x86_64 +test.test_capi.test_getargs.Test_testcapi.test_L_code @ linux-x86_64 +test.test_capi.test_getargs.Test_testcapi.test_k_code @ linux-x86_64 +test.test_capi.test_getargs.Test_testcapi.test_s_code @ linux-x86_64 +test.test_capi.test_getargs.Tuple_TestCase.test_args @ linux-x86_64 +test.test_capi.test_getargs.Tuple_TestCase.test_tuple @ linux-x86_64 +test.test_capi.test_getargs.Unsigned_TestCase.test_B @ linux-x86_64 +test.test_capi.test_getargs.Unsigned_TestCase.test_H @ linux-x86_64 +test.test_capi.test_getargs.Unsigned_TestCase.test_I @ linux-x86_64 +test.test_capi.test_getargs.Unsigned_TestCase.test_b @ linux-x86_64 +test.test_capi.test_getargs.Unsigned_TestCase.test_k @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_c_type_with_ipow @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_c_type_with_matrix_multiplication @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_export_symbols @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_getitem_with_error @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_heaptype_with_buffer @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_heaptype_with_dict @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_heaptype_with_negative_dict @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_heaptype_with_setattro @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_instancemethod @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_mapping_has_key @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_mapping_keys_values_items @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_mapping_keys_values_items_bad_arg @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_memoryview_from_NULL_pointer @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_multiple_inheritance_ctypes_with_weakref_or_dict @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_null_type_doc @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_pynumber_tobase @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_pyobject_bytes_from_null @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_pyobject_repr_from_null @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_pyobject_str_from_null @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_return_null_without_error @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_return_result_with_error @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_sequence_del_slice @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_sequence_set_slice @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_subprocess_fork_exec @ linux-x86_64 +test.test_capi.test_misc.CAPITest.test_sys_getobject @ linux-x86_64 +test.test_capi.test_misc.Test_FrameAPI.test_frame_fback_api @ linux-x86_64 +test.test_capi.test_misc.Test_FrameAPI.test_frame_getters @ linux-x86_64 +test.test_capi.test_misc.Test_ModuleStateAccess.test_get_module_bad_def @ linux-x86_64 +test.test_capi.test_misc.Test_ModuleStateAccess.test_get_module_static_in_mro @ linux-x86_64 +test.test_capi.test_misc.Test_ModuleStateAccess.test_subclass_get_module @ linux-x86_64 +test.test_capi.test_misc.Test_ModuleStateAccess.test_subclass_get_module_with_super @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_buildvalue_issue38913 @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_config @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_datetime_capi @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_decref_doesnt_leak @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_dict_iteration @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_empty_argparse @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_from_contiguous @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_gc_control @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_get_statictype_slots @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_get_type_name @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_get_type_qualname @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_incref_decref_API @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_incref_doesnt_leak @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_lazy_hash_inheritance @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_list_api @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_and_overflow @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_api @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_as_double @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_as_size_t @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_as_unsigned_long_long_mask @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_long_and_overflow @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_long_numbits @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_longlong_api @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_mapping_has_key_string @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_py_is_funcs @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_py_is_macros @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_pymem_alloc0 @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_pythread_tss_key_state @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_set_type_size @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_sizeof_c_types @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_string_from_format @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_string_to_double @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_structseq_newtype_doesnt_leak @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_type_from_ephemeral_spec @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_unicode_compare_with_ascii @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_with_docstring @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_xdecref_doesnt_leak @ linux-x86_64 +test.test_capi.test_misc.Test_testcapi.test_xincref_doesnt_leak @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_bad_assignments @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_bool @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_byte @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_inplace_string @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_int @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_long @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_longlong @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_py_ssize_t @ linux-x86_64 +test.test_capi.test_structmembers.ReadWriteTests.test_short @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgi.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgi.txt new file mode 100644 index 0000000000..6fa6fd178b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgi.txt @@ -0,0 +1,23 @@ +test.test_cgi.CgiTests.testQSAndFormData @ linux-x86_64 +test.test_cgi.CgiTests.testQSAndFormDataFile @ linux-x86_64 +test.test_cgi.CgiTests.testQSAndUrlEncode @ linux-x86_64 +test.test_cgi.CgiTests.test_all @ linux-x86_64 +test.test_cgi.CgiTests.test_field_storage_multipart_no_content_length @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_as_context_manager @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_invalid @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_multipart @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_multipart_leading_whitespace @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_multipart_maxline @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_multipart_non_ascii @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_multipart_w3c @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_part_content_length @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_properties @ linux-x86_64 +test.test_cgi.CgiTests.test_fieldstorage_readline @ linux-x86_64 +test.test_cgi.CgiTests.test_log @ linux-x86_64 +test.test_cgi.CgiTests.test_max_num_fields @ linux-x86_64 +test.test_cgi.CgiTests.test_parse_header @ linux-x86_64 +test.test_cgi.CgiTests.test_parse_multipart @ linux-x86_64 +test.test_cgi.CgiTests.test_parse_multipart_invalid_encoding @ linux-x86_64 +test.test_cgi.CgiTests.test_parse_multipart_without_content_length @ linux-x86_64 +test.test_cgi.CgiTests.test_separator @ linux-x86_64 +test.test_cgi.CgiTests.test_strict @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgitb.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgitb.txt new file mode 100644 index 0000000000..f892768c30 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cgitb.txt @@ -0,0 +1,6 @@ +test.test_cgitb.TestCgitb.test_blanks @ linux-x86_64 +test.test_cgitb.TestCgitb.test_fonts @ linux-x86_64 +test.test_cgitb.TestCgitb.test_html @ linux-x86_64 +test.test_cgitb.TestCgitb.test_syshook_no_logdir_default_format @ linux-x86_64 +test.test_cgitb.TestCgitb.test_syshook_no_logdir_text_format @ linux-x86_64 +test.test_cgitb.TestCgitb.test_text @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_charmapcodec.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_charmapcodec.txt new file mode 100644 index 0000000000..e1157a4ea6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_charmapcodec.txt @@ -0,0 +1,4 @@ +test.test_charmapcodec.CharmapCodecTest.test_constructorx @ linux-x86_64 +test.test_charmapcodec.CharmapCodecTest.test_constructory @ linux-x86_64 +test.test_charmapcodec.CharmapCodecTest.test_encodex @ linux-x86_64 +test.test_charmapcodec.CharmapCodecTest.test_maptoundefined @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_class.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_class.txt new file mode 100644 index 0000000000..2e9f8bfd28 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_class.txt @@ -0,0 +1,15 @@ +test.test_class.ClassTests.testBadTypeReturned @ linux-x86_64 +test.test_class.ClassTests.testBinaryOps @ linux-x86_64 +test.test_class.ClassTests.testClassWithExtCall @ linux-x86_64 +test.test_class.ClassTests.testConstructorErrorMessages @ linux-x86_64 +test.test_class.ClassTests.testForExceptionsRaisedInInstanceGetattr2 @ linux-x86_64 +test.test_class.ClassTests.testGetSetAndDel @ linux-x86_64 +test.test_class.ClassTests.testHashComparisonOfMethods @ linux-x86_64 +test.test_class.ClassTests.testHashStuff @ linux-x86_64 +test.test_class.ClassTests.testInit @ linux-x86_64 +test.test_class.ClassTests.testListAndDictOps @ linux-x86_64 +test.test_class.ClassTests.testMisc @ linux-x86_64 +test.test_class.ClassTests.testSFBug532646 @ linux-x86_64 +test.test_class.ClassTests.testSetattrNonStringName @ linux-x86_64 +test.test_class.ClassTests.testSetattrWrapperNameIntern @ linux-x86_64 +test.test_class.ClassTests.testUnaryOps @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmath.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmath.txt new file mode 100644 index 0000000000..4205cc32e6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmath.txt @@ -0,0 +1,31 @@ +test.test_cmath.CMathTests.testAtanSign @ linux-x86_64 +test.test_cmath.CMathTests.testAtanhSign @ linux-x86_64 +test.test_cmath.CMathTests.testTanhSign @ linux-x86_64 +test.test_cmath.CMathTests.test_abs @ linux-x86_64 +test.test_cmath.CMathTests.test_abs_overflows @ linux-x86_64 +test.test_cmath.CMathTests.test_cmath_matches_math @ linux-x86_64 +test.test_cmath.CMathTests.test_constants @ linux-x86_64 +test.test_cmath.CMathTests.test_infinity_and_nan_constants @ linux-x86_64 +test.test_cmath.CMathTests.test_input_type @ linux-x86_64 +test.test_cmath.CMathTests.test_isfinite @ linux-x86_64 +test.test_cmath.CMathTests.test_isinf @ linux-x86_64 +test.test_cmath.CMathTests.test_isnan @ linux-x86_64 +test.test_cmath.CMathTests.test_phase @ linux-x86_64 +test.test_cmath.CMathTests.test_polar @ linux-x86_64 +test.test_cmath.CMathTests.test_rect @ linux-x86_64 +test.test_cmath.CMathTests.test_specific_values @ linux-x86_64 +test.test_cmath.CMathTests.test_user_object @ linux-x86_64 +test.test_cmath.IsCloseTests.test_asymmetry @ linux-x86_64 +test.test_cmath.IsCloseTests.test_complex_near_zero @ linux-x86_64 +test.test_cmath.IsCloseTests.test_complex_values @ linux-x86_64 +test.test_cmath.IsCloseTests.test_decimals @ linux-x86_64 +test.test_cmath.IsCloseTests.test_eight_decimal_places @ linux-x86_64 +test.test_cmath.IsCloseTests.test_fractions @ linux-x86_64 +test.test_cmath.IsCloseTests.test_identical @ linux-x86_64 +test.test_cmath.IsCloseTests.test_identical_infinite @ linux-x86_64 +test.test_cmath.IsCloseTests.test_inf_ninf_nan @ linux-x86_64 +test.test_cmath.IsCloseTests.test_integers @ linux-x86_64 +test.test_cmath.IsCloseTests.test_near_zero @ linux-x86_64 +test.test_cmath.IsCloseTests.test_negative_tolerances @ linux-x86_64 +test.test_cmath.IsCloseTests.test_reject_complex_tolerances @ linux-x86_64 +test.test_cmath.IsCloseTests.test_zero_tolerance @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd.txt new file mode 100644 index 0000000000..ee3bcdeeca --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd.txt @@ -0,0 +1,3 @@ +DocTestCase.test.test_cmd.samplecmdclass @ linux-x86_64 +test.test_cmd.TestAlternateInput.test_file_with_missing_final_nl @ linux-x86_64 +test.test_cmd.TestAlternateInput.test_input_reset_at_EOF @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line.txt new file mode 100644 index 0000000000..87863ffbb0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line.txt @@ -0,0 +1,22 @@ +test.test_cmd_line.CmdLineTest.test_builtin_input @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_closed_stdout @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_coding @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_del___main__ @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_directories @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_empty_PYTHONPATH_issue16309 @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_help_env @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_isolatedmode @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_large_PYTHONPATH @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_non_ascii @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_optimize @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_output_newline @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_run_code @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_run_module @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_run_module_bug1764407 @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_site_flag @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_stdin_readline @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_unbuffered_input @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_unbuffered_output @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_unmached_quote @ linux-x86_64 +test.test_cmd_line.CmdLineTest.test_verbose @ linux-x86_64 +test.test_cmd_line.IgnoreEnvironmentTest.test_ignore_PYTHONPATH @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line_script.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line_script.txt new file mode 100644 index 0000000000..e074744d28 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cmd_line_script.txt @@ -0,0 +1,18 @@ +test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_direct_execution @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_consistent_sys_path_for_module_execution @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_dash_m_bad_pyc @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_dash_m_error_code_is_one @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_dash_m_errors @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_dash_m_init_traceback @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_dash_m_main_traceback @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_directory_error @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_hint_when_triying_to_import_a_py_file @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_issue20500_exit_with_exception_value @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_issue20884 @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_issue8202_dash_c_file_ignored @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_nonexisting_script @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_package_error @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_package_recursion @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_pep_409_verbiage @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_script_as_dev_fd @ linux-x86_64 +test.test_cmd_line_script.CmdLineTest.test_zipfile_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code.txt new file mode 100644 index 0000000000..b5a1216d25 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code.txt @@ -0,0 +1,4 @@ +test.test_code.CodeTest.test_constructor @ linux-x86_64 +test.test_code.CodeTest.test_qualname @ linux-x86_64 +test.test_code.CodeTest.test_replace @ linux-x86_64 +test.test_code.CodeTest.test_shrinking_localsplus @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code_module.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code_module.txt new file mode 100644 index 0000000000..4be9d93892 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_code_module.txt @@ -0,0 +1,7 @@ +test.test_code_module.TestInteractiveConsole.test_banner @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_console_stderr @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_exit_msg @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_ps1 @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_ps2 @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_syntax_error @ linux-x86_64 +test.test_code_module.TestInteractiveConsole.test_sysexcepthook @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeccallbacks.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeccallbacks.txt new file mode 100644 index 0000000000..3eda050da2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeccallbacks.txt @@ -0,0 +1,18 @@ +test.test_codeccallbacks.CodecCallbackTest.test_backslashescape @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodbackslashreplaceexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodignoreexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodnamereplaceexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodreplaceexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodstrictexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodsurrogateescapeexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodsurrogatepassexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badandgoodxmlcharrefreplaceexceptions @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badlookupcall @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_badregistercall @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_bug828737 @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_charmapencode @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_fake_error_class @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_lookup @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_translatehelper @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_unknownhandler @ linux-x86_64 +test.test_codeccallbacks.CodecCallbackTest.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_cn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_cn.txt new file mode 100644 index 0000000000..27e059842b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_cn.txt @@ -0,0 +1,19 @@ +test.test_codecencodings_cn.Test_GB18030.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_cn.Test_GB18030.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GB18030.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GB18030.test_streamwriter @ linux-x86_64 +test.test_codecencodings_cn.Test_GB18030.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_errorhandle @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_streamwriter @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_cn.Test_GB2312.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_errorhandle @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_streamwriter @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_cn.Test_GBK.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_hk.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_hk.txt new file mode 100644 index 0000000000..0aceba9f63 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_hk.txt @@ -0,0 +1,2 @@ +test.test_codecencodings_hk.Test_Big5HKSCS.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_hk.Test_Big5HKSCS.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_iso2022.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_iso2022.txt new file mode 100644 index 0000000000..5b8ed6a51c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_iso2022.txt @@ -0,0 +1,8 @@ +test.test_codecencodings_iso2022.Test_ISO2022_JP.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_JP.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_JP.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_JP2.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_JP2.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_JP2.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_KR.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_iso2022.Test_ISO2022_KR.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_jp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_jp.txt new file mode 100644 index 0000000000..c84d3693cf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_jp.txt @@ -0,0 +1,23 @@ +test.test_codecencodings_jp.Test_CP932.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_errorhandle @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_streamwriter @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_jp.Test_CP932.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_streamwriter @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_jp.Test_EUC_JP_COMPAT.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_jp.Test_SJISX0213.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_jp.Test_SJISX0213.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_jp.Test_SJISX0213.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_jp.Test_SJISX0213.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_streamwriter @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_jp.Test_SJIS_COMPAT.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_kr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_kr.txt new file mode 100644 index 0000000000..382ca971e8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_kr.txt @@ -0,0 +1,16 @@ +test.test_codecencodings_kr.Test_CP949.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_errorhandle @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_streamwriter @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_kr.Test_CP949.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_kr.Test_EUCKR.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_kr.Test_EUCKR.test_xmlcharrefreplace @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_errorhandle @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_streamwriter @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_kr.Test_JOHAB.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_tw.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_tw.txt new file mode 100644 index 0000000000..7a6a5a5e84 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecencodings_tw.txt @@ -0,0 +1,7 @@ +test.test_codecencodings_tw.Test_Big5.test_chunkcoding @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_errorhandle @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_incrementaldecoder @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_incrementalencoder @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_streamwriter @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_streamwriter_reset_no_pending @ linux-x86_64 +test.test_codecencodings_tw.Test_Big5.test_xmlcharrefreplace @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_cn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_cn.txt new file mode 100644 index 0000000000..4f4a7348a3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_cn.txt @@ -0,0 +1,7 @@ +test.test_codecmaps_cn.TestGB18030Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_cn.TestGB18030Map.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_cn.TestGB2312Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_cn.TestGB2312Map.test_mapping_file @ linux-x86_64 +test.test_codecmaps_cn.TestGB2312Map.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_cn.TestGBKMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_cn.TestGBKMap.test_mapping_supplemental @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_hk.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_hk.txt new file mode 100644 index 0000000000..cf96d766b8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_hk.txt @@ -0,0 +1,3 @@ +test.test_codecmaps_hk.TestBig5HKSCSMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_hk.TestBig5HKSCSMap.test_mapping_file @ linux-x86_64 +test.test_codecmaps_hk.TestBig5HKSCSMap.test_mapping_supplemental @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_jp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_jp.txt new file mode 100644 index 0000000000..4a82aad223 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_jp.txt @@ -0,0 +1,9 @@ +test.test_codecmaps_jp.TestCP932Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_jp.TestEUCJISX0213Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_jp.TestEUCJISX0213Map.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_jp.TestEUCJPCOMPATMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_jp.TestEUCJPCOMPATMap.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_jp.TestSJISCOMPATMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_jp.TestSJISCOMPATMap.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_jp.TestSJISX0213Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_jp.TestSJISX0213Map.test_mapping_supplemental @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_kr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_kr.txt new file mode 100644 index 0000000000..b8671dd8fd --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_kr.txt @@ -0,0 +1,9 @@ +test.test_codecmaps_kr.TestCP949Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_kr.TestCP949Map.test_mapping_file @ linux-x86_64 +test.test_codecmaps_kr.TestCP949Map.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_kr.TestEUCKRMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_kr.TestEUCKRMap.test_mapping_file @ linux-x86_64 +test.test_codecmaps_kr.TestEUCKRMap.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_kr.TestJOHABMap.test_errorhandle @ linux-x86_64 +test.test_codecmaps_kr.TestJOHABMap.test_mapping_file @ linux-x86_64 +test.test_codecmaps_kr.TestJOHABMap.test_mapping_supplemental @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_tw.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_tw.txt new file mode 100644 index 0000000000..0555dea346 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecmaps_tw.txt @@ -0,0 +1,5 @@ +test.test_codecmaps_tw.TestBIG5Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_tw.TestBIG5Map.test_mapping_file @ linux-x86_64 +test.test_codecmaps_tw.TestBIG5Map.test_mapping_supplemental @ linux-x86_64 +test.test_codecmaps_tw.TestCP950Map.test_errorhandle @ linux-x86_64 +test.test_codecmaps_tw.TestCP950Map.test_mapping_supplemental @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecs.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecs.txt new file mode 100644 index 0000000000..786d2cffcf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codecs.txt @@ -0,0 +1,184 @@ +test.test_codecs.ASCIITest.test_decode @ linux-x86_64 +test.test_codecs.ASCIITest.test_decode_error @ linux-x86_64 +test.test_codecs.ASCIITest.test_encode @ linux-x86_64 +test.test_codecs.ASCIITest.test_encode_error @ linux-x86_64 +test.test_codecs.ASCIITest.test_encode_surrogateescape_error @ linux-x86_64 +test.test_codecs.BasicUnicodeTest.test_encoding_map_type_initialized @ linux-x86_64 +test.test_codecs.CharmapTest.test_decode_with_int2int_map @ linux-x86_64 +test.test_codecs.CharmapTest.test_decode_with_int2str_map @ linux-x86_64 +test.test_codecs.CharmapTest.test_decode_with_string_map @ linux-x86_64 +test.test_codecs.CodecNameNormalizationTest.test_codecs_lookup @ linux-x86_64 +test.test_codecs.CodecNameNormalizationTest.test_encodings_normalize_encoding @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_all @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_decode @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_encode @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_file_closes_if_lookup_error_raised @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_getdecoder @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_getencoder @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_getreader @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_getwriter @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_lookup @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_lookup_issue1813 @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_open @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_register @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_undefined @ linux-x86_64 +test.test_codecs.CodecsModuleTest.test_unregister @ linux-x86_64 +test.test_codecs.EncodedFileTest.test_basic @ linux-x86_64 +test.test_codecs.EscapeDecodeTest.test_empty @ linux-x86_64 +test.test_codecs.EscapeDecodeTest.test_errors @ linux-x86_64 +test.test_codecs.EscapeDecodeTest.test_raw @ linux-x86_64 +test.test_codecs.EscapeEncodeTest.test_escape_encode @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_init_override_is_not_wrapped @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_instance_attribute_is_not_wrapped @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_multiple_args_is_not_wrapped @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_new_override_is_not_wrapped @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_non_str_arg_is_not_wrapped @ linux-x86_64 +test.test_codecs.ExceptionChainingTest.test_unflagged_non_text_codec_handling @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_builtin_decode @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_builtin_decode_length_limit @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_builtin_encode @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_errors @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_incremental_decode @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_incremental_encode @ linux-x86_64 +test.test_codecs.IDNACodecTest.test_stream @ linux-x86_64 +test.test_codecs.Latin1Test.test_decode @ linux-x86_64 +test.test_codecs.Latin1Test.test_encode @ linux-x86_64 +test.test_codecs.Latin1Test.test_encode_errors @ linux-x86_64 +test.test_codecs.Latin1Test.test_encode_surrogateescape_error @ linux-x86_64 +test.test_codecs.NameprepTest.test_nameprep @ linux-x86_64 +test.test_codecs.PunycodeTest.test_decode @ linux-x86_64 +test.test_codecs.PunycodeTest.test_decode_invalid @ linux-x86_64 +test.test_codecs.PunycodeTest.test_encode @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_bug1175396 @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_empty @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_escape_encode @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_raw_encode @ linux-x86_64 +test.test_codecs.RawUnicodeEscapeTest.test_readlinequeue @ linux-x86_64 +test.test_codecs.Rot13Test.test_decode @ linux-x86_64 +test.test_codecs.Rot13Test.test_encode @ linux-x86_64 +test.test_codecs.Rot13Test.test_incremental_decode @ linux-x86_64 +test.test_codecs.Rot13Test.test_incremental_encode @ linux-x86_64 +test.test_codecs.Rot13UtilTest.test_rot13_func @ linux-x86_64 +test.test_codecs.StreamReaderTest.test_copy @ linux-x86_64 +test.test_codecs.StreamReaderTest.test_pickle @ linux-x86_64 +test.test_codecs.StreamReaderTest.test_readlines @ linux-x86_64 +test.test_codecs.StreamReaderWriterTest.test_copy @ linux-x86_64 +test.test_codecs.StreamReaderWriterTest.test_pickle @ linux-x86_64 +test.test_codecs.StreamRecoderTest.test_seeking_read @ linux-x86_64 +test.test_codecs.StreamRecoderTest.test_seeking_write @ linux-x86_64 +test.test_codecs.StreamWriterTest.test_copy @ linux-x86_64 +test.test_codecs.StreamWriterTest.test_pickle @ linux-x86_64 +test.test_codecs.SurrogateEscapeTest.test_ascii @ linux-x86_64 +test.test_codecs.SurrogateEscapeTest.test_charmap @ linux-x86_64 +test.test_codecs.SurrogateEscapeTest.test_latin1 @ linux-x86_64 +test.test_codecs.SurrogateEscapeTest.test_utf8 @ linux-x86_64 +test.test_codecs.TransformCodecTest.test_aliases @ linux-x86_64 +test.test_codecs.TransformCodecTest.test_quopri_stateless @ linux-x86_64 +test.test_codecs.TransformCodecTest.test_uu_invalid @ linux-x86_64 +test.test_codecs.UTF16BETest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF16BETest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF16BETest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF16BETest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF16BETest.test_nonbmp @ linux-x86_64 +test.test_codecs.UTF16BETest.test_partial @ linux-x86_64 +test.test_codecs.UTF16BETest.test_readline @ linux-x86_64 +test.test_codecs.UTF16BETest.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF16ExTest.test_bad_args @ linux-x86_64 +test.test_codecs.UTF16LETest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF16LETest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF16LETest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF16LETest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF16LETest.test_nonbmp @ linux-x86_64 +test.test_codecs.UTF16LETest.test_partial @ linux-x86_64 +test.test_codecs.UTF16LETest.test_readline @ linux-x86_64 +test.test_codecs.UTF16LETest.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF16Test.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF16Test.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF16Test.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF16Test.test_bug691291 @ linux-x86_64 +test.test_codecs.UTF16Test.test_errors @ linux-x86_64 +test.test_codecs.UTF16Test.test_handlers @ linux-x86_64 +test.test_codecs.UTF16Test.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF16Test.test_partial @ linux-x86_64 +test.test_codecs.UTF16Test.test_readline @ linux-x86_64 +test.test_codecs.UTF16Test.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF32BETest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF32BETest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF32BETest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF32BETest.test_errors @ linux-x86_64 +test.test_codecs.UTF32BETest.test_issue8941 @ linux-x86_64 +test.test_codecs.UTF32BETest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF32BETest.test_partial @ linux-x86_64 +test.test_codecs.UTF32BETest.test_readline @ linux-x86_64 +test.test_codecs.UTF32BETest.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF32BETest.test_simple @ linux-x86_64 +test.test_codecs.UTF32LETest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF32LETest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF32LETest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF32LETest.test_errors @ linux-x86_64 +test.test_codecs.UTF32LETest.test_issue8941 @ linux-x86_64 +test.test_codecs.UTF32LETest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF32LETest.test_partial @ linux-x86_64 +test.test_codecs.UTF32LETest.test_readline @ linux-x86_64 +test.test_codecs.UTF32LETest.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF32LETest.test_simple @ linux-x86_64 +test.test_codecs.UTF32Test.test_badbom @ linux-x86_64 +test.test_codecs.UTF32Test.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF32Test.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF32Test.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF32Test.test_errors @ linux-x86_64 +test.test_codecs.UTF32Test.test_handlers @ linux-x86_64 +test.test_codecs.UTF32Test.test_issue8941 @ linux-x86_64 +test.test_codecs.UTF32Test.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF32Test.test_partial @ linux-x86_64 +test.test_codecs.UTF32Test.test_readline @ linux-x86_64 +test.test_codecs.UTF32Test.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF7Test.test_ascii @ linux-x86_64 +test.test_codecs.UTF7Test.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF7Test.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF7Test.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF7Test.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF7Test.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_bom @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_bug1601501 @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_decode_error @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_decoder_state @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_incremental_errors @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_incremental_surrogatepass @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_partial @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_readline @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_readlinequeue @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_stream_bare @ linux-x86_64 +test.test_codecs.UTF8SigTest.test_stream_bom @ linux-x86_64 +test.test_codecs.UTF8Test.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UTF8Test.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UTF8Test.test_bug1175396 @ linux-x86_64 +test.test_codecs.UTF8Test.test_decode_error @ linux-x86_64 +test.test_codecs.UTF8Test.test_decoder_state @ linux-x86_64 +test.test_codecs.UTF8Test.test_incremental_errors @ linux-x86_64 +test.test_codecs.UTF8Test.test_incremental_surrogatepass @ linux-x86_64 +test.test_codecs.UTF8Test.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UTF8Test.test_partial @ linux-x86_64 +test.test_codecs.UTF8Test.test_readline @ linux-x86_64 +test.test_codecs.UTF8Test.test_readlinequeue @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_bug1098990_a @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_bug1098990_b @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_bug1175396 @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_empty @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_escape_encode @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_incremental_surrogatepass @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_mixed_readline_and_read @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_partial @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_raw_decode @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_raw_encode @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_readline @ linux-x86_64 +test.test_codecs.UnicodeEscapeTest.test_readlinequeue @ linux-x86_64 +test.test_codecs.WithStmtTest.test_encodedfile @ linux-x86_64 +test.test_codecs.WithStmtTest.test_streamreaderwriter @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeop.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeop.txt new file mode 100644 index 0000000000..bdcc9a323a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_codeop.txt @@ -0,0 +1,6 @@ +test.test_codeop.CodeopTests.test_filename @ linux-x86_64 +test.test_codeop.CodeopTests.test_invalid @ linux-x86_64 +test.test_codeop.CodeopTests.test_invalid_exec @ linux-x86_64 +test.test_codeop.CodeopTests.test_syntax_errors @ linux-x86_64 +test.test_codeop.CodeopTests.test_valid @ linux-x86_64 +test.test_codeop.CodeopTests.test_warning @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_collections.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_collections.txt new file mode 100644 index 0000000000..2ab93367cf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_collections.txt @@ -0,0 +1,101 @@ +DocTestCase.collections.Counter @ linux-x86_64 +DocTestCase.collections.Counter.__add__ @ linux-x86_64 +DocTestCase.collections.Counter.__and__ @ linux-x86_64 +DocTestCase.collections.Counter.__iadd__ @ linux-x86_64 +DocTestCase.collections.Counter.__iand__ @ linux-x86_64 +DocTestCase.collections.Counter.__init__ @ linux-x86_64 +DocTestCase.collections.Counter.__ior__ @ linux-x86_64 +DocTestCase.collections.Counter.__isub__ @ linux-x86_64 +DocTestCase.collections.Counter.__or__ @ linux-x86_64 +DocTestCase.collections.Counter.__sub__ @ linux-x86_64 +DocTestCase.collections.Counter.elements @ linux-x86_64 +DocTestCase.collections.Counter.most_common @ linux-x86_64 +DocTestCase.collections.Counter.subtract @ linux-x86_64 +DocTestCase.collections.Counter.update @ linux-x86_64 +DocTestCase.collections.namedtuple @ linux-x86_64 +test.test_collections.TestChainMap.test_basics @ linux-x86_64 +test.test_collections.TestChainMap.test_bool @ linux-x86_64 +test.test_collections.TestChainMap.test_constructor @ linux-x86_64 +test.test_collections.TestChainMap.test_dict_coercion @ linux-x86_64 +test.test_collections.TestChainMap.test_iter_not_calling_getitem_on_maps @ linux-x86_64 +test.test_collections.TestChainMap.test_missing @ linux-x86_64 +test.test_collections.TestChainMap.test_new_child @ linux-x86_64 +test.test_collections.TestChainMap.test_order_preservation @ linux-x86_64 +test.test_collections.TestChainMap.test_ordering @ linux-x86_64 +test.test_collections.TestChainMap.test_union_operators @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_ByteString @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Mapping @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_MutableMapping @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_MutableMapping_subclass @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_MutableSequence @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_MutableSequence_mixins @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_MutableSet @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Sequence @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Sequence_mixins @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Set @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Set_from_iterable @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_Set_interoperability_with_real_sets @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_arithmetic_Set @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_equality_Set @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_hash_Set @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_illegal_patma_flags @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_isdisjoint_Set @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_issue16373 @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_issue26915 @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_issue8750 @ linux-x86_64 +test.test_collections.TestCollectionABCs.test_issue_5647 @ linux-x86_64 +test.test_collections.TestCounter.test_basics @ linux-x86_64 +test.test_collections.TestCounter.test_conversions @ linux-x86_64 +test.test_collections.TestCounter.test_copy_subclass @ linux-x86_64 +test.test_collections.TestCounter.test_copying @ linux-x86_64 +test.test_collections.TestCounter.test_eq @ linux-x86_64 +test.test_collections.TestCounter.test_ge @ linux-x86_64 +test.test_collections.TestCounter.test_gt @ linux-x86_64 +test.test_collections.TestCounter.test_helper_function @ linux-x86_64 +test.test_collections.TestCounter.test_init @ linux-x86_64 +test.test_collections.TestCounter.test_inplace_operations @ linux-x86_64 +test.test_collections.TestCounter.test_invariant_for_the_in_operator @ linux-x86_64 +test.test_collections.TestCounter.test_le @ linux-x86_64 +test.test_collections.TestCounter.test_lt @ linux-x86_64 +test.test_collections.TestCounter.test_multiset_operations @ linux-x86_64 +test.test_collections.TestCounter.test_multiset_operations_equivalent_to_set_operations @ linux-x86_64 +test.test_collections.TestCounter.test_order_preservation @ linux-x86_64 +test.test_collections.TestCounter.test_repr_nonsortable @ linux-x86_64 +test.test_collections.TestCounter.test_subtract @ linux-x86_64 +test.test_collections.TestCounter.test_total @ linux-x86_64 +test.test_collections.TestCounter.test_unary @ linux-x86_64 +test.test_collections.TestCounter.test_update @ linux-x86_64 +test.test_collections.TestNamedTuple.test_copy @ linux-x86_64 +test.test_collections.TestNamedTuple.test_defaults @ linux-x86_64 +test.test_collections.TestNamedTuple.test_factory @ linux-x86_64 +test.test_collections.TestNamedTuple.test_factory_doc_attr @ linux-x86_64 +test.test_collections.TestNamedTuple.test_field_doc @ linux-x86_64 +test.test_collections.TestNamedTuple.test_instance @ linux-x86_64 +test.test_collections.TestNamedTuple.test_keyword_only_arguments @ linux-x86_64 +test.test_collections.TestNamedTuple.test_match_args @ linux-x86_64 +test.test_collections.TestNamedTuple.test_module_parameter @ linux-x86_64 +test.test_collections.TestNamedTuple.test_name_conflicts @ linux-x86_64 +test.test_collections.TestNamedTuple.test_name_fixer @ linux-x86_64 +test.test_collections.TestNamedTuple.test_namedtuple_subclass_issue_24931 @ linux-x86_64 +test.test_collections.TestNamedTuple.test_non_generic_subscript @ linux-x86_64 +test.test_collections.TestNamedTuple.test_odd_sizes @ linux-x86_64 +test.test_collections.TestNamedTuple.test_pickle @ linux-x86_64 +test.test_collections.TestNamedTuple.test_readonly @ linux-x86_64 +test.test_collections.TestNamedTuple.test_repr @ linux-x86_64 +test.test_collections.TestNamedTuple.test_tupleness @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Callable @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Collection @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Container @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Generator @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Hashable @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Iterable @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Iterator @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Reversible @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_Sized @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_direct_subclassing @ linux-x86_64 +test.test_collections.TestOneTrickPonyABCs.test_registration @ linux-x86_64 +test.test_collections.TestUserObjects.test_dict_copy @ linux-x86_64 +test.test_collections.TestUserObjects.test_dict_protocol @ linux-x86_64 +test.test_collections.TestUserObjects.test_list_copy @ linux-x86_64 +test.test_collections.TestUserObjects.test_list_protocol @ linux-x86_64 +test.test_collections.TestUserObjects.test_str_protocol @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_colorsys.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_colorsys.txt new file mode 100644 index 0000000000..c49849b173 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_colorsys.txt @@ -0,0 +1,7 @@ +test.test_colorsys.ColorsysTest.test_hls_nearwhite @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_hls_roundtrip @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_hls_values @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_hsv_roundtrip @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_hsv_values @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_yiq_roundtrip @ linux-x86_64 +test.test_colorsys.ColorsysTest.test_yiq_values @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compare.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compare.txt new file mode 100644 index 0000000000..c58480cadc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compare.txt @@ -0,0 +1,16 @@ +test.test_compare.ComparisonFullTest.test_bytes @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_comp_classes_different @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_comp_classes_same @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_mappings @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_numbers @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_objects @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_sequences @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_sets @ linux-x86_64 +test.test_compare.ComparisonFullTest.test_str_subclass @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_comparisons @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_id_comparisons @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_issue_1393 @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_ne_defaults_to_not_eq @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_ne_high_priority @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_ne_low_priority @ linux-x86_64 +test.test_compare.ComparisonSimpleTest.test_other_delegation @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compile.txt new file mode 100644 index 0000000000..b4ce94500b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compile.txt @@ -0,0 +1,53 @@ +test.test_compile.TestExpressionStackSize.test_and @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_and_or @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_binop @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_chained_comparison @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_func_and @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_or @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_stack_3050 @ linux-x86_64 +test.test_compile.TestExpressionStackSize.test_stack_3050_2 @ linux-x86_64 +test.test_compile.TestSourcePositions.test_multiline_assert_rewritten_as_method_call @ linux-x86_64 +test.test_compile.TestSourcePositions.test_simple_assignment @ linux-x86_64 +test.test_compile.TestSourcePositions.test_weird_attribute_position_regressions @ linux-x86_64 +test.test_compile.TestSpecifics.test_annotation_limit @ linux-x86_64 +test.test_compile.TestSpecifics.test_apply_static_swaps @ linux-x86_64 +test.test_compile.TestSpecifics.test_apply_static_swaps_2 @ linux-x86_64 +test.test_compile.TestSpecifics.test_apply_static_swaps_3 @ linux-x86_64 +test.test_compile.TestSpecifics.test_argument_handling @ linux-x86_64 +test.test_compile.TestSpecifics.test_argument_order @ linux-x86_64 +test.test_compile.TestSpecifics.test_bad_single_statement @ linux-x86_64 +test.test_compile.TestSpecifics.test_big_dict_literal @ linux-x86_64 +test.test_compile.TestSpecifics.test_compile_filename @ linux-x86_64 +test.test_compile.TestSpecifics.test_dict_evaluation_order @ linux-x86_64 +test.test_compile.TestSpecifics.test_duplicate_global_local @ linux-x86_64 +test.test_compile.TestSpecifics.test_empty @ linux-x86_64 +test.test_compile.TestSpecifics.test_encoding @ linux-x86_64 +test.test_compile.TestSpecifics.test_exec_with_general_mapping_for_locals @ linux-x86_64 +test.test_compile.TestSpecifics.test_extended_arg @ linux-x86_64 +test.test_compile.TestSpecifics.test_float_literals @ linux-x86_64 +test.test_compile.TestSpecifics.test_for_distinct_code_objects @ linux-x86_64 +test.test_compile.TestSpecifics.test_import @ linux-x86_64 +test.test_compile.TestSpecifics.test_indentation @ linux-x86_64 +test.test_compile.TestSpecifics.test_lambda_doc @ linux-x86_64 +test.test_compile.TestSpecifics.test_literals_with_leading_zeroes @ linux-x86_64 +test.test_compile.TestSpecifics.test_mangling @ linux-x86_64 +test.test_compile.TestSpecifics.test_no_ending_newline @ linux-x86_64 +test.test_compile.TestSpecifics.test_none_assignment @ linux-x86_64 +test.test_compile.TestSpecifics.test_none_keyword_arg @ linux-x86_64 +test.test_compile.TestSpecifics.test_null_terminated @ linux-x86_64 +test.test_compile.TestSpecifics.test_other_newlines @ linux-x86_64 +test.test_compile.TestSpecifics.test_path_like_objects @ linux-x86_64 +test.test_compile.TestSpecifics.test_sequence_unpacking_error @ linux-x86_64 +test.test_compile.TestSpecifics.test_single_statement @ linux-x86_64 +test.test_compile.TestSpecifics.test_stack_overflow @ linux-x86_64 +test.test_compile.TestSpecifics.test_subscripts @ linux-x86_64 +test.test_compile.TestSpecifics.test_syntax_error @ linux-x86_64 +test.test_compile.TestSpecifics.test_unary_minus @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_async_for @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_async_for_else @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_if @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_if_else @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_try_except_star_as @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_try_except_star_finally @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_try_except_star_qualified @ linux-x86_64 +test.test_compile.TestStackSizeStability.test_while_else @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compileall.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compileall.txt new file mode 100644 index 0000000000..f847d5d87c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_compileall.txt @@ -0,0 +1,121 @@ +test.test_compileall.CommandLineTestsNoSourceEpoch.test_compiles_as_much_as_possible @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_d_compile_error @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_d_runtime_error @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_force @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_hardlink @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_hardlink_bad_args @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_ignore_symlink_destination @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_include_bad_file @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_include_file_no_arg @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_include_file_with_arg @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_include_on_stdin @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_invalid_arg_produces_message @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_legacy_paths @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_multiple_dirs @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_multiple_optimization_levels @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_multiple_runs @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_no_args_compiles_path @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_no_args_respects_force_flag @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_no_args_respects_quiet_flag @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_pep3147_paths_normal @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_pyc_invalidation_mode @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_quiet @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_recursion_control @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_recursion_limit @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_regexp @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_silent @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_symlink_loop @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_workers @ linux-x86_64 +test.test_compileall.CommandLineTestsNoSourceEpoch.test_workers_available_cores @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_compiles_as_much_as_possible @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_d_compile_error @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_d_runtime_error @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_force @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_hardlink @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_hardlink_bad_args @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_ignore_symlink_destination @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_include_bad_file @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_include_file_no_arg @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_include_file_with_arg @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_include_on_stdin @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_invalid_arg_produces_message @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_legacy_paths @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_multiple_dirs @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_multiple_optimization_levels @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_multiple_runs @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_no_args_compiles_path @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_no_args_respects_force_flag @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_no_args_respects_quiet_flag @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_pep3147_paths_normal @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_pyc_invalidation_mode @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_quiet @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_recursion_control @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_recursion_limit @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_regexp @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_silent @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_symlink_loop @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_workers @ linux-x86_64 +test.test_compileall.CommandLineTestsWithSourceEpoch.test_workers_available_cores @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_dir_maxlevels @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_dir_pathlike @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_dir_pathlike_prependdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_dir_pathlike_stripdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_file_encoding_fallback @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_file_pathlike @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_file_pathlike_ddir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_file_pathlike_prependdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_file_pathlike_stripdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_files @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_missing_multiprocessing @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_one_worker @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_path @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_pool_called @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_workers_cpu_count @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_compile_workers_non_positive @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_ignore_symlink_destination @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_larger_than_32_bit_times @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_multiple_optimization_levels @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_no_pycache_in_non_package @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_optimize @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_prepend_only @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_strip_prepend_and_ddir @ linux-x86_64 +test.test_compileall.CompileallTestsWithSourceEpoch.test_year_2038_mtime_compilation @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_dir_maxlevels @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_dir_pathlike @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_dir_pathlike_prependdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_dir_pathlike_stripdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_file_encoding_fallback @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_file_pathlike @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_file_pathlike_ddir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_file_pathlike_prependdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_file_pathlike_stripdir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_files @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_missing_multiprocessing @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_one_worker @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_path @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_pool_called @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_workers_cpu_count @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_compile_workers_non_positive @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_ignore_symlink_destination @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_larger_than_32_bit_times @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_magic_number @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_mtime @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_multiple_optimization_levels @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_no_pycache_in_non_package @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_optimize @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_prepend_only @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_strip_prepend_and_ddir @ linux-x86_64 +test.test_compileall.CompileallTestsWithoutSourceEpoch.test_year_2038_mtime_compilation @ linux-x86_64 +test.test_compileall.EncodingTest.test_error @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_bad_args @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_disabled @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_duplicated_levels @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_hardlink @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_only_two_levels @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsNoSourceEpoch.test_recompilation @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_bad_args @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_disabled @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_duplicated_levels @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_hardlink @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_only_two_levels @ linux-x86_64 +test.test_compileall.HardlinkDedupTestsWithSourceEpoch.test_recompilation @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_complex.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_complex.txt new file mode 100644 index 0000000000..dd274d7f37 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_complex.txt @@ -0,0 +1,29 @@ +test.test_complex.ComplexTest.test___complex__ @ linux-x86_64 +test.test_complex.ComplexTest.test_abs @ linux-x86_64 +test.test_complex.ComplexTest.test_boolcontext @ linux-x86_64 +test.test_complex.ComplexTest.test_conjugate @ linux-x86_64 +test.test_complex.ComplexTest.test_constructor @ linux-x86_64 +test.test_complex.ComplexTest.test_constructor_special_numbers @ linux-x86_64 +test.test_complex.ComplexTest.test_divmod @ linux-x86_64 +test.test_complex.ComplexTest.test_divmod_zero_division @ linux-x86_64 +test.test_complex.ComplexTest.test_floordiv @ linux-x86_64 +test.test_complex.ComplexTest.test_floordiv_zero_division @ linux-x86_64 +test.test_complex.ComplexTest.test_format @ linux-x86_64 +test.test_complex.ComplexTest.test_getnewargs @ linux-x86_64 +test.test_complex.ComplexTest.test_hash @ linux-x86_64 +test.test_complex.ComplexTest.test_mod @ linux-x86_64 +test.test_complex.ComplexTest.test_mod_zero_division @ linux-x86_64 +test.test_complex.ComplexTest.test_neg @ linux-x86_64 +test.test_complex.ComplexTest.test_negated_imaginary_literal @ linux-x86_64 +test.test_complex.ComplexTest.test_negative_zero_repr_str @ linux-x86_64 +test.test_complex.ComplexTest.test_overflow @ linux-x86_64 +test.test_complex.ComplexTest.test_plus_minus_0j @ linux-x86_64 +test.test_complex.ComplexTest.test_pow @ linux-x86_64 +test.test_complex.ComplexTest.test_pow_with_small_integer_exponents @ linux-x86_64 +test.test_complex.ComplexTest.test_repr_roundtrip @ linux-x86_64 +test.test_complex.ComplexTest.test_repr_str @ linux-x86_64 +test.test_complex.ComplexTest.test_richcompare @ linux-x86_64 +test.test_complex.ComplexTest.test_richcompare_boundaries @ linux-x86_64 +test.test_complex.ComplexTest.test_truediv @ linux-x86_64 +test.test_complex.ComplexTest.test_truediv_zero_division @ linux-x86_64 +test.test_complex.ComplexTest.test_underscores @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_concurrent_futures.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_concurrent_futures.txt new file mode 100644 index 0000000000..01c2a5ffb9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_concurrent_futures.txt @@ -0,0 +1,112 @@ +test.test_concurrent_futures.test_as_completed.ProcessPoolForkAsCompletedTest.test_correct_timeout_exception_msg @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ProcessPoolSpawnAsCompletedTest.test_correct_timeout_exception_msg @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ProcessPoolSpawnAsCompletedTest.test_duplicate_futures @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ProcessPoolSpawnAsCompletedTest.test_no_timeout @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ProcessPoolSpawnAsCompletedTest.test_zero_timeout @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_correct_timeout_exception_msg @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_duplicate_futures @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_no_timeout @ linux-x86_64 +test.test_concurrent_futures.test_as_completed.ThreadPoolAsCompletedTest.test_zero_timeout @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_crash_at_task_unpickle @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_error_at_task_pickle @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_error_at_task_unpickle @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_error_during_func_exec_on_worker @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_error_during_result_pickle_on_worker @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_error_during_result_unpickle_in_result_handler @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_exit_at_task_unpickle @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_exit_during_func_exec_on_worker @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_exit_during_result_pickle_on_worker @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_exit_during_result_unpickle_in_result_handler @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full @ linux-x86_64 +test.test_concurrent_futures.test_deadlock.ProcessPoolSpawnExecutorDeadlockTest.test_shutdown_deadlock_pickle @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_cancel @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_cancelled @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_already_cancelled @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_already_failed @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_already_successful @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_raises @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_raises_already_succeeded @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_with_cancel @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_with_exception @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_done_callback_with_result @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_exception_with_success @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_exception_with_timeout @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_multiple_set_exception @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_multiple_set_result @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_repr @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_result_with_cancel @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_result_with_success @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_result_with_timeout @ linux-x86_64 +test.test_concurrent_futures.test_future.FutureTests.test_running @ linux-x86_64 +test.test_concurrent_futures.test_init.ProcessPoolSpawnFailingInitializerTest.test_initializer @ linux-x86_64 +test.test_concurrent_futures.test_init.ProcessPoolSpawnInitializerTest.test_initializer @ linux-x86_64 +test.test_concurrent_futures.test_init.ThreadPoolFailingInitializerTest.test_initializer @ linux-x86_64 +test.test_concurrent_futures.test_init.ThreadPoolInitializerTest.test_initializer @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolForkProcessPoolExecutorTest.test_max_tasks_per_child @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolForkProcessPoolExecutorTest.test_max_tasks_per_child_defaults_to_spawn_context @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolForkProcessPoolExecutorTest.test_max_workers_negative @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_idle_process_reuse_multiple @ linux-x86_64 +!test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_idle_process_reuse_one @ linux-x86_64 +!test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_killed_child @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_map @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_map_chunksize @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_map_exception @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_map_timeout @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_max_tasks_early_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_max_tasks_per_child @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_max_tasks_per_child_defaults_to_spawn_context @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_max_workers_negative @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_saturation @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_shutdown_race_issue12456 @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_submit @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_submit_keyword @ linux-x86_64 +test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_traceback @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolForkProcessPoolShutdownTest.test_run_after_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_cancel_futures @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_context_manager_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_hang_gh94440 @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_hang_issue12364 @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_processes_terminate @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_run_after_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_shutdown_no_wait @ linux-x86_64 +!test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_submit_after_interpreter_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_cancel_futures @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_context_manager_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_hang_gh94440 @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_hang_issue12364 @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_run_after_shutdown @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_shutdown_no_wait @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_submit_after_interpreter_shutdown @ linux-x86_64 +!test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_thread_names_assigned @ linux-x86_64 +!test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_thread_names_default @ linux-x86_64 +test.test_concurrent_futures.test_shutdown.ThreadPoolShutdownTest.test_threads_terminate @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_default_workers @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_executor_map_current_future_cancel @ linux-x86_64 +!test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_idle_thread_reuse @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_map @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_map_exception @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_map_submits_without_iteration @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_map_timeout @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_max_workers_negative @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_saturation @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_shutdown_race_issue12456 @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_submit @ linux-x86_64 +test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_submit_keyword @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_20369 @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_all_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_first_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_first_completed_some_already_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_first_exception @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_first_exception_one_already_failed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_first_exception_some_already_complete @ linux-x86_64 +test.test_concurrent_futures.test_wait.ProcessPoolSpawnWaitTest.test_timeout @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_20369 @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_all_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_first_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_first_completed_some_already_completed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_first_exception @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_first_exception_one_already_failed @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_first_exception_some_already_complete @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_pending_calls_race @ linux-x86_64 +test.test_concurrent_futures.test_wait.ThreadPoolWaitTests.test_timeout @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_configparser.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_configparser.txt new file mode 100644 index 0000000000..811985b72d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_configparser.txt @@ -0,0 +1,337 @@ +test.test_configparser.BlatantOverrideConvertersTestCase.test_converters_at_init @ linux-x86_64 +test.test_configparser.BlatantOverrideConvertersTestCase.test_inheritance @ linux-x86_64 +test.test_configparser.BlatantOverrideConvertersTestCase.test_instance_assignment @ linux-x86_64 +test.test_configparser.CompatibleTestCase.test_comment_handling @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_add_section_default @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_defaults_keyword @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_interpolation_missing_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_items @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_safe_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_set_malformatted_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCase.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_endless_loop @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_extended_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_other_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_strange_options @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseExtendedInterpolation.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseInvalidInterpolationType.test_error_on_wrong_type_for_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_add_section_default @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_defaults_keyword @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_interpolation_missing_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_items @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseLegacyInterpolation.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_empty_case @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_no_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoInterpolation.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_add_section_default @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_defaults_keyword @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_interpolation_missing_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_items @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_safe_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_set_malformatted_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNoValue.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_add_section_default @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_defaults_keyword @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_interpolation_missing_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_items @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_safe_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_set_malformatted_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDefaultSection.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_add_section_default @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_basic @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_boolean @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_clear @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_defaults_keyword @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_interpolation_missing_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_items @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_parse_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_popitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_query_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_safe_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_set_malformatted_interpolation @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_set_string_types @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_setitem @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_weird_errors @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseNonStandardDelimiters.test_write @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3 @ linux-x86_64 +test.test_configparser.ConfigParserTestCaseTrickyFile.test_unicode_failure @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_basic @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_boolean @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_clear @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_converters @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_popitem @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_setitem @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.ConvertersTestCase.test_write @ linux-x86_64 +test.test_configparser.CopyTestCase.test_basic @ linux-x86_64 +test.test_configparser.CopyTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.CopyTestCase.test_boolean @ linux-x86_64 +test.test_configparser.CopyTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.CopyTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.CopyTestCase.test_clear @ linux-x86_64 +test.test_configparser.CopyTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.CopyTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.CopyTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.CopyTestCase.test_popitem @ linux-x86_64 +test.test_configparser.CopyTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.CopyTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.CopyTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.CopyTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.CopyTestCase.test_setitem @ linux-x86_64 +test.test_configparser.CopyTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.CopyTestCase.test_write @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_duplicate_option_error @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_inconsistent_converters_state @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_interpolation_depth_error @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_interpolation_validation @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_legacyinterpolation_deprecation @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_parsing_error @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_readfp_deprecation @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_safeconfigparser_deprecation @ linux-x86_64 +test.test_configparser.CoverageOneHundredTestCase.test_sectionproxy_repr @ linux-x86_64 +test.test_configparser.ExceptionContextTestCase.test_get_basic_interpolation @ linux-x86_64 +test.test_configparser.ExceptionContextTestCase.test_get_extended_interpolation @ linux-x86_64 +test.test_configparser.ExceptionContextTestCase.test_missing_options @ linux-x86_64 +test.test_configparser.ExceptionContextTestCase.test_missing_section @ linux-x86_64 +test.test_configparser.ExceptionContextTestCase.test_remove_option @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_duplicateoptionerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_duplicatesectionerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_error @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_interpolationdeptherror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_interpolationerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_interpolationmissingoptionerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_interpolationsyntaxerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_missingsectionheadererror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_nooptionerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_nosectionerror @ linux-x86_64 +test.test_configparser.ExceptionPicklingTestCase.test_parsingerror @ linux-x86_64 +test.test_configparser.InlineCommentStrippingTestCase.test_stripping @ linux-x86_64 +test.test_configparser.Issue7005TestCase.test_none_as_value_stringified @ linux-x86_64 +test.test_configparser.Issue7005TestCase.test_none_as_value_stringified_raw @ linux-x86_64 +test.test_configparser.MiscTestCase.test__all__ @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_basic @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_boolean @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_clear @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_dominating_multiline_values @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_popitem @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_setitem @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.MultilineValuesTestCase.test_write @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_basic @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_boolean @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_clear @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_defaults_keyword @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_interpolation @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_items @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_popitem @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_setitem @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCase.test_write @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_basic @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_basic_from_dict @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_boolean @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_case_sensitivity @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_clear @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_defaults_keyword @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_interpolation @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_items @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_parse_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_popitem @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_query_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_set_string_types @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_setitem @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_weird_errors @ linux-x86_64 +test.test_configparser.RawConfigParserTestCaseNonStandardDelimiters.test_write @ linux-x86_64 +test.test_configparser.RawConfigParserTestSambaConf.test_reading @ linux-x86_64 +test.test_configparser.ReadFileTestCase.test_file @ linux-x86_64 +test.test_configparser.ReadFileTestCase.test_iterable @ linux-x86_64 +test.test_configparser.ReadFileTestCase.test_readline_generator @ linux-x86_64 +test.test_configparser.ReadFileTestCase.test_source_as_bytes @ linux-x86_64 +test.test_configparser.SortedTestCase.test_basic @ linux-x86_64 +test.test_configparser.SortedTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.SortedTestCase.test_boolean @ linux-x86_64 +test.test_configparser.SortedTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.SortedTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.SortedTestCase.test_clear @ linux-x86_64 +test.test_configparser.SortedTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.SortedTestCase.test_defaults_keyword @ linux-x86_64 +test.test_configparser.SortedTestCase.test_interpolation @ linux-x86_64 +test.test_configparser.SortedTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.SortedTestCase.test_items @ linux-x86_64 +test.test_configparser.SortedTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.SortedTestCase.test_popitem @ linux-x86_64 +test.test_configparser.SortedTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.SortedTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.SortedTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.SortedTestCase.test_set_nonstring_types @ linux-x86_64 +test.test_configparser.SortedTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.SortedTestCase.test_setitem @ linux-x86_64 +test.test_configparser.SortedTestCase.test_sorted @ linux-x86_64 +test.test_configparser.SortedTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.SortedTestCase.test_write @ linux-x86_64 +test.test_configparser.StrictTestCase.test_basic @ linux-x86_64 +test.test_configparser.StrictTestCase.test_basic_from_dict @ linux-x86_64 +test.test_configparser.StrictTestCase.test_boolean @ linux-x86_64 +test.test_configparser.StrictTestCase.test_case_sensitivity @ linux-x86_64 +test.test_configparser.StrictTestCase.test_case_sensitivity_mapping_access @ linux-x86_64 +test.test_configparser.StrictTestCase.test_clear @ linux-x86_64 +test.test_configparser.StrictTestCase.test_default_case_sensitivity @ linux-x86_64 +test.test_configparser.StrictTestCase.test_invalid_multiline_value @ linux-x86_64 +test.test_configparser.StrictTestCase.test_parse_errors @ linux-x86_64 +test.test_configparser.StrictTestCase.test_popitem @ linux-x86_64 +test.test_configparser.StrictTestCase.test_query_errors @ linux-x86_64 +test.test_configparser.StrictTestCase.test_read_returns_file_list @ linux-x86_64 +test.test_configparser.StrictTestCase.test_read_returns_file_list_with_bytestring_path @ linux-x86_64 +test.test_configparser.StrictTestCase.test_set_string_types @ linux-x86_64 +test.test_configparser.StrictTestCase.test_setitem @ linux-x86_64 +test.test_configparser.StrictTestCase.test_weird_errors @ linux-x86_64 +test.test_configparser.StrictTestCase.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contains.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contains.txt new file mode 100644 index 0000000000..9e8dfde5ae --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contains.txt @@ -0,0 +1,4 @@ +test.test_contains.TestContains.test_block_fallback @ linux-x86_64 +test.test_contains.TestContains.test_builtin_sequence_types @ linux-x86_64 +test.test_contains.TestContains.test_common_tests @ linux-x86_64 +test.test_contains.TestContains.test_nonreflexive @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_context.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_context.txt new file mode 100644 index 0000000000..cba6f09333 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_context.txt @@ -0,0 +1,15 @@ +test.test_context.ContextTest.test_context_copy_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_get_context_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_getset_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_getset_2 @ linux-x86_64 +test.test_context.ContextTest.test_context_getset_3 @ linux-x86_64 +test.test_context.ContextTest.test_context_getset_5 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_2 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_3 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_5 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_6 @ linux-x86_64 +test.test_context.ContextTest.test_context_run_7 @ linux-x86_64 +test.test_context.ContextTest.test_context_subclassing_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_threads_1 @ linux-x86_64 +test.test_context.ContextTest.test_context_typerrors_1 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib.txt new file mode 100644 index 0000000000..e80bfd6a73 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib.txt @@ -0,0 +1,85 @@ +test.test_contextlib.ClosingTestCase.test_closing @ linux-x86_64 +test.test_contextlib.ClosingTestCase.test_closing_error @ linux-x86_64 +test.test_contextlib.ClosingTestCase.test_instance_docs @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_attribs @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_do_not_unchain_non_stopiteration_exceptions @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_doc_attrib @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_except @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_except_pep479 @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_except_stopiter @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_finally @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_no_reraise @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_non_normalised @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_plain @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_traceback @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_trap_no_yield @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_trap_second_yield @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_trap_yield_after_throw @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_contextmanager_wrap_runtimeerror @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_instance_docstring_given_cm_docstring @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_keywords @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_param_errors @ linux-x86_64 +test.test_contextlib.ContextManagerTestCase.test_recursive @ linux-x86_64 +test.test_contextlib.FileContextTestCase.testWithOpen @ linux-x86_64 +test.test_contextlib.LockContextTestCase.testWithBoundedSemaphore @ linux-x86_64 +test.test_contextlib.LockContextTestCase.testWithCondition @ linux-x86_64 +test.test_contextlib.LockContextTestCase.testWithLock @ linux-x86_64 +test.test_contextlib.LockContextTestCase.testWithRLock @ linux-x86_64 +test.test_contextlib.LockContextTestCase.testWithSemaphore @ linux-x86_64 +test.test_contextlib.NullcontextTestCase.test_nullcontext @ linux-x86_64 +test.test_contextlib.TestAbstractContextManager.test_enter @ linux-x86_64 +test.test_contextlib.TestAbstractContextManager.test_exit_is_abstract @ linux-x86_64 +test.test_contextlib.TestAbstractContextManager.test_structural_subclassing @ linux-x86_64 +test.test_contextlib.TestChdir.test_exception @ linux-x86_64 +test.test_contextlib.TestChdir.test_reentrant @ linux-x86_64 +test.test_contextlib.TestChdir.test_simple @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_contextdecorator @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_contextdecorator_as_mixin @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_contextdecorator_with_exception @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_contextmanager_as_decorator @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_decorating_method @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_decorator @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_decorator_with_exception @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_instance_docs @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_typo_enter @ linux-x86_64 +test.test_contextlib.TestContextDecorator.test_typo_exit @ linux-x86_64 +test.test_contextlib.TestExitStack.test_body_exception_suppress @ linux-x86_64 +test.test_contextlib.TestExitStack.test_callback @ linux-x86_64 +test.test_contextlib.TestExitStack.test_close @ linux-x86_64 +test.test_contextlib.TestExitStack.test_dont_reraise_RuntimeError @ linux-x86_64 +test.test_contextlib.TestExitStack.test_enter_context @ linux-x86_64 +test.test_contextlib.TestExitStack.test_enter_context_errors @ linux-x86_64 +test.test_contextlib.TestExitStack.test_excessive_nesting @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_exception_chaining_reference @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_exception_chaining_suppress @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_exception_non_suppressing @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_exception_traceback @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_exception_with_existing_context @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_raise @ linux-x86_64 +test.test_contextlib.TestExitStack.test_exit_suppress @ linux-x86_64 +test.test_contextlib.TestExitStack.test_instance_bypass @ linux-x86_64 +test.test_contextlib.TestExitStack.test_instance_docs @ linux-x86_64 +test.test_contextlib.TestExitStack.test_no_resources @ linux-x86_64 +test.test_contextlib.TestExitStack.test_pop_all @ linux-x86_64 +test.test_contextlib.TestExitStack.test_push @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_cm_is_reentrant @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_cm_is_reusable @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_enter_result_is_target @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_instance_docs @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_no_redirect_in_init @ linux-x86_64 +test.test_contextlib.TestRedirectStderr.test_redirect_to_string_io @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_cm_is_reentrant @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_cm_is_reusable @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_enter_result_is_target @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_instance_docs @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_no_redirect_in_init @ linux-x86_64 +test.test_contextlib.TestRedirectStdout.test_redirect_to_string_io @ linux-x86_64 +test.test_contextlib.TestSuppress.test_cm_is_reentrant @ linux-x86_64 +test.test_contextlib.TestSuppress.test_exact_exception @ linux-x86_64 +test.test_contextlib.TestSuppress.test_exception_hierarchy @ linux-x86_64 +test.test_contextlib.TestSuppress.test_instance_docs @ linux-x86_64 +test.test_contextlib.TestSuppress.test_multiple_exception_args @ linux-x86_64 +test.test_contextlib.TestSuppress.test_no_args @ linux-x86_64 +test.test_contextlib.TestSuppress.test_no_exception @ linux-x86_64 +test.test_contextlib.TestSuppress.test_no_result_from_enter @ linux-x86_64 +test.test_contextlib.TestSuppress.test_other_exception @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib_async.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib_async.txt new file mode 100644 index 0000000000..0e63035340 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_contextlib_async.txt @@ -0,0 +1,21 @@ +test.test_contextlib_async.AclosingTestCase.test_instance_docs @ linux-x86_64 +test.test_contextlib_async.AsyncContextManagerTestCase.test_contextmanager_attribs @ linux-x86_64 +test.test_contextlib_async.AsyncContextManagerTestCase.test_contextmanager_doc_attrib @ linux-x86_64 +test.test_contextlib_async.TestAbstractAsyncContextManager.test_exit_is_abstract @ linux-x86_64 +test.test_contextlib_async.TestAbstractAsyncContextManager.test_structural_subclassing @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_body_exception_suppress @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_callback @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_dont_reraise_RuntimeError @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_enter_context @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_enter_context_errors @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_excessive_nesting @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_exception_chaining_reference @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_exception_chaining_suppress @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_exception_non_suppressing @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_exception_with_existing_context @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_raise @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_exit_suppress @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_instance_bypass @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_instance_docs @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_no_resources @ linux-x86_64 +test.test_contextlib_async.TestAsyncExitStack.test_push @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copy.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copy.txt new file mode 100644 index 0000000000..13c1eac947 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copy.txt @@ -0,0 +1,74 @@ +test.test_copy.TestCopy.test_copy_atomic @ linux-x86_64 +test.test_copy.TestCopy.test_copy_basic @ linux-x86_64 +test.test_copy.TestCopy.test_copy_bytearray @ linux-x86_64 +test.test_copy.TestCopy.test_copy_cant @ linux-x86_64 +test.test_copy.TestCopy.test_copy_copy @ linux-x86_64 +test.test_copy.TestCopy.test_copy_dict @ linux-x86_64 +test.test_copy.TestCopy.test_copy_frozenset @ linux-x86_64 +test.test_copy.TestCopy.test_copy_function @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_copy @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_getinitargs @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_getnewargs @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_getnewargs_ex @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_getstate @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_getstate_setstate @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_setstate @ linux-x86_64 +test.test_copy.TestCopy.test_copy_inst_vanilla @ linux-x86_64 +test.test_copy.TestCopy.test_copy_list @ linux-x86_64 +test.test_copy.TestCopy.test_copy_list_subclass @ linux-x86_64 +test.test_copy.TestCopy.test_copy_reduce @ linux-x86_64 +test.test_copy.TestCopy.test_copy_reduce_ex @ linux-x86_64 +test.test_copy.TestCopy.test_copy_registry @ linux-x86_64 +test.test_copy.TestCopy.test_copy_set @ linux-x86_64 +test.test_copy.TestCopy.test_copy_slots @ linux-x86_64 +test.test_copy.TestCopy.test_copy_tuple @ linux-x86_64 +test.test_copy.TestCopy.test_copy_tuple_subclass @ linux-x86_64 +!test.test_copy.TestCopy.test_copy_weakkeydict @ linux-x86_64 +test.test_copy.TestCopy.test_copy_weakref @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_atomic @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_basic @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_bound_method @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_cant @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_deepcopy @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_dict @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_dict_subclass @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_dont_memo_immutable @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_empty_tuple @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_function @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_deepcopy @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_getinitargs @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_getnewargs @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_getnewargs_ex @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_getstate @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_getstate_setstate @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_setstate @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_inst_vanilla @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_issubclass @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_keepalive @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_list @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_list_subclass @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_memo @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reduce @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reduce_ex @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reflexive_dict @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reflexive_inst @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reflexive_list @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_reflexive_tuple @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_registry @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_slots @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_tuple @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_tuple_of_immutables @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_tuple_subclass @ linux-x86_64 +!test.test_copy.TestCopy.test_deepcopy_weakkeydict @ linux-x86_64 +test.test_copy.TestCopy.test_deepcopy_weakref @ linux-x86_64 +test.test_copy.TestCopy.test_exceptions @ linux-x86_64 +test.test_copy.TestCopy.test_getstate_exc @ linux-x86_64 +test.test_copy.TestCopy.test_reconstruct_nostate @ linux-x86_64 +test.test_copy.TestCopy.test_reconstruct_reflexive @ linux-x86_64 +test.test_copy.TestCopy.test_reconstruct_state @ linux-x86_64 +test.test_copy.TestCopy.test_reconstruct_state_setstate @ linux-x86_64 +test.test_copy.TestCopy.test_reconstruct_string @ linux-x86_64 +test.test_copy.TestCopy.test_reduce_4tuple @ linux-x86_64 +test.test_copy.TestCopy.test_reduce_5tuple @ linux-x86_64 +test.test_copy.TestCopy.test_reduce_6tuple @ linux-x86_64 +test.test_copy.TestCopy.test_reduce_6tuple_none @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copyreg.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copyreg.txt new file mode 100644 index 0000000000..3d90ddb1df --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_copyreg.txt @@ -0,0 +1,6 @@ +test.test_copyreg.CopyRegTestCase.test_bool @ linux-x86_64 +test.test_copyreg.CopyRegTestCase.test_class @ linux-x86_64 +test.test_copyreg.CopyRegTestCase.test_extension_registry @ linux-x86_64 +test.test_copyreg.CopyRegTestCase.test_noncallable_constructor @ linux-x86_64 +test.test_copyreg.CopyRegTestCase.test_noncallable_reduce @ linux-x86_64 +test.test_copyreg.CopyRegTestCase.test_slotnames @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cppext.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_cppext.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_crypt.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_crypt.txt new file mode 100644 index 0000000000..48e58c8afc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_crypt.txt @@ -0,0 +1,6 @@ +test.test_crypt.CryptTestCase.test_crypt @ linux-x86_64 +test.test_crypt.CryptTestCase.test_invalid_rounds @ linux-x86_64 +test.test_crypt.CryptTestCase.test_methods @ linux-x86_64 +test.test_crypt.CryptTestCase.test_salt @ linux-x86_64 +test.test_crypt.CryptTestCase.test_saltedcrypt @ linux-x86_64 +test.test_crypt.CryptTestCase.test_sha2_rounds @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_csv.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_csv.txt new file mode 100644 index 0000000000..1855d81e76 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_csv.txt @@ -0,0 +1,110 @@ +test.test_csv.KeyOrderingTest.test_ordered_dict_reader @ linux-x86_64 +test.test_csv.KeyOrderingTest.test_ordering_for_the_dict_reader_and_writer @ linux-x86_64 +test.test_csv.MiscTestCase.test__all__ @ linux-x86_64 +test.test_csv.MiscTestCase.test_subclassable @ linux-x86_64 +test.test_csv.TestArrayWrites.test_char_write @ linux-x86_64 +test.test_csv.TestArrayWrites.test_double_write @ linux-x86_64 +test.test_csv.TestArrayWrites.test_float_write @ linux-x86_64 +test.test_csv.TestArrayWrites.test_int_write @ linux-x86_64 +test.test_csv.TestDialectExcel.test_blankline @ linux-x86_64 +test.test_csv.TestDialectExcel.test_dubious_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_empty_fields @ linux-x86_64 +test.test_csv.TestDialectExcel.test_inline_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_inline_quotes @ linux-x86_64 +test.test_csv.TestDialectExcel.test_lone_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_newlines @ linux-x86_64 +test.test_csv.TestDialectExcel.test_null @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quote_and_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quote_fieldsep @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quoted @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quoted_nl @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quoted_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quoted_quotes @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quotes @ linux-x86_64 +test.test_csv.TestDialectExcel.test_quotes_and_more @ linux-x86_64 +test.test_csv.TestDialectExcel.test_simple @ linux-x86_64 +test.test_csv.TestDialectExcel.test_simple_writer @ linux-x86_64 +test.test_csv.TestDialectExcel.test_single @ linux-x86_64 +test.test_csv.TestDialectExcel.test_single_quoted_quote @ linux-x86_64 +test.test_csv.TestDialectExcel.test_single_writer @ linux-x86_64 +test.test_csv.TestDialectExcel.test_singlequoted @ linux-x86_64 +test.test_csv.TestDialectExcel.test_singlequoted_left_empty @ linux-x86_64 +test.test_csv.TestDialectExcel.test_singlequoted_right_empty @ linux-x86_64 +test.test_csv.TestDialectExcel.test_space_and_quote @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_bad_dialect @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_dialect_apply @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_incomplete_dialect @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_register_kwargs @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_register_kwargs_override @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_registry @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_registry_badargs @ linux-x86_64 +test.test_csv.TestDialectRegistry.test_space_dialect @ linux-x86_64 +test.test_csv.TestDialectUnix.test_simple_reader @ linux-x86_64 +test.test_csv.TestDialectUnix.test_simple_writer @ linux-x86_64 +test.test_csv.TestDialectValidity.test_delimiter @ linux-x86_64 +test.test_csv.TestDialectValidity.test_escapechar @ linux-x86_64 +test.test_csv.TestDialectValidity.test_invalid_chars @ linux-x86_64 +test.test_csv.TestDialectValidity.test_lineterminator @ linux-x86_64 +test.test_csv.TestDialectValidity.test_quoting @ linux-x86_64 +test.test_csv.TestDictFields.test_read_dict_fieldnames_chain @ linux-x86_64 +test.test_csv.TestDictFields.test_read_dict_fieldnames_from_file @ linux-x86_64 +test.test_csv.TestDictFields.test_read_dict_fields @ linux-x86_64 +test.test_csv.TestDictFields.test_read_dict_no_fieldnames @ linux-x86_64 +test.test_csv.TestDictFields.test_read_long @ linux-x86_64 +test.test_csv.TestDictFields.test_read_long_with_rest @ linux-x86_64 +test.test_csv.TestDictFields.test_read_long_with_rest_no_fieldnames @ linux-x86_64 +test.test_csv.TestDictFields.test_read_multi @ linux-x86_64 +test.test_csv.TestDictFields.test_read_semi_sep @ linux-x86_64 +test.test_csv.TestDictFields.test_read_short @ linux-x86_64 +test.test_csv.TestDictFields.test_read_with_blanks @ linux-x86_64 +test.test_csv.TestDictFields.test_typo_in_extrasaction_raises_error @ linux-x86_64 +test.test_csv.TestDictFields.test_write_field_not_in_field_names_ignore @ linux-x86_64 +test.test_csv.TestDictFields.test_write_field_not_in_field_names_raise @ linux-x86_64 +test.test_csv.TestDictFields.test_write_fields_not_in_fieldnames @ linux-x86_64 +test.test_csv.TestDictFields.test_write_multiple_dict_rows @ linux-x86_64 +test.test_csv.TestDictFields.test_write_no_fields @ linux-x86_64 +test.test_csv.TestDictFields.test_write_simple_dict @ linux-x86_64 +test.test_csv.TestDictFields.test_writeheader_return_value @ linux-x86_64 +test.test_csv.TestEscapedExcel.test_escape_fieldsep @ linux-x86_64 +test.test_csv.TestEscapedExcel.test_read_escape_fieldsep @ linux-x86_64 +test.test_csv.TestQuotedEscapedExcel.test_read_escape_fieldsep @ linux-x86_64 +test.test_csv.TestQuotedEscapedExcel.test_write_escape_fieldsep @ linux-x86_64 +test.test_csv.TestSniffer.test_delimiters @ linux-x86_64 +test.test_csv.TestSniffer.test_doublequote @ linux-x86_64 +test.test_csv.TestSniffer.test_guess_quote_and_delimiter @ linux-x86_64 +test.test_csv.TestSniffer.test_has_header @ linux-x86_64 +test.test_csv.TestSniffer.test_has_header_regex_special_delimiter @ linux-x86_64 +test.test_csv.TestSniffer.test_has_header_strings @ linux-x86_64 +test.test_csv.TestSniffer.test_issue43625 @ linux-x86_64 +test.test_csv.TestSniffer.test_sniff @ linux-x86_64 +test.test_csv.TestUnicode.test_unicode_read @ linux-x86_64 +test.test_csv.TestUnicode.test_unicode_write @ linux-x86_64 +test.test_csv.Test_Csv.test_read_bigfield @ linux-x86_64 +test.test_csv.Test_Csv.test_read_delimiter @ linux-x86_64 +test.test_csv.Test_Csv.test_read_eof @ linux-x86_64 +test.test_csv.Test_Csv.test_read_eol @ linux-x86_64 +test.test_csv.Test_Csv.test_read_escape @ linux-x86_64 +test.test_csv.Test_Csv.test_read_linenum @ linux-x86_64 +test.test_csv.Test_Csv.test_read_nul @ linux-x86_64 +test.test_csv.Test_Csv.test_read_oddinputs @ linux-x86_64 +test.test_csv.Test_Csv.test_read_quoting @ linux-x86_64 +test.test_csv.Test_Csv.test_read_skipinitialspace @ linux-x86_64 +test.test_csv.Test_Csv.test_reader_arg_valid @ linux-x86_64 +test.test_csv.Test_Csv.test_reader_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_reader_dialect_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_reader_kw_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_roundtrip_escaped_unquoted_newlines @ linux-x86_64 +test.test_csv.Test_Csv.test_roundtrip_quoteed_newlines @ linux-x86_64 +test.test_csv.Test_Csv.test_write_arg_valid @ linux-x86_64 +test.test_csv.Test_Csv.test_write_bigfield @ linux-x86_64 +test.test_csv.Test_Csv.test_write_escape @ linux-x86_64 +test.test_csv.Test_Csv.test_write_iterable @ linux-x86_64 +test.test_csv.Test_Csv.test_write_lineterminator @ linux-x86_64 +test.test_csv.Test_Csv.test_write_quoting @ linux-x86_64 +test.test_csv.Test_Csv.test_writer_arg_valid @ linux-x86_64 +test.test_csv.Test_Csv.test_writer_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_writer_dialect_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_writer_kw_attrs @ linux-x86_64 +test.test_csv.Test_Csv.test_writerows @ linux-x86_64 +test.test_csv.Test_Csv.test_writerows_errors @ linux-x86_64 +test.test_csv.Test_Csv.test_writerows_with_none @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ctypes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ctypes.txt new file mode 100644 index 0000000000..936392b758 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ctypes.txt @@ -0,0 +1,247 @@ +ctypes.test.test_anon.AnonTest.test_anon_nonmember @ linux-x86_64 +ctypes.test.test_anon.AnonTest.test_anon_nonseq @ linux-x86_64 +ctypes.test.test_array_in_pointer.Test.test @ linux-x86_64 +ctypes.test.test_array_in_pointer.Test.test_2 @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_bad_subclass @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_bpo36504_signed_int_overflow @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_cache @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_classcache @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_empty_element_array @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_empty_element_struct @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_from_address @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_numeric_arrays @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_simple @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_subclass @ linux-x86_64 +ctypes.test.test_arrays.ArrayTestCase.test_zero_length @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_callbacks_2 @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_longlong_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_pointers @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_recursive_as_param @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_shorts @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamPropertyWrapperTestCase.test_wchar_parm @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_callbacks_2 @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_longlong_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_pointers @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_recursive_as_param @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_shorts @ linux-x86_64 +ctypes.test.test_as_parameter.AsParamWrapperTestCase.test_wchar_parm @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_callbacks_2 @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_longlong_callbacks @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_pointers @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_recursive_as_param @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_shorts @ linux-x86_64 +ctypes.test.test_as_parameter.BasicWrapTestCase.test_wchar_parm @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_c_wchar @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_mixed_1 @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_mixed_2 @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_mixed_3 @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_mixed_4 @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_multi_bitfields_size @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_nonint_types @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_single_bitfield_size @ linux-x86_64 +ctypes.test.test_bitfields.BitFieldTest.test_uint32 @ linux-x86_64 +ctypes.test.test_buffers.StringBufferTestCase.test_buffer @ linux-x86_64 +ctypes.test.test_buffers.StringBufferTestCase.test_buffer_interface @ linux-x86_64 +ctypes.test.test_buffers.StringBufferTestCase.test_create_unicode_buffer_non_bmp @ linux-x86_64 +ctypes.test.test_bytes.BytesTest.test_c_char_p @ linux-x86_64 +ctypes.test.test_bytes.BytesTest.test_c_wchar @ linux-x86_64 +ctypes.test.test_bytes.BytesTest.test_c_wchar_p @ linux-x86_64 +ctypes.test.test_bytes.BytesTest.test_struct @ linux-x86_64 +ctypes.test.test_bytes.BytesTest.test_struct_W @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_double @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_float @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_int @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_longlong @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_other @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_endian_short @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_slots @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_struct_field_alignment @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_struct_fields_unsupported_byte_order @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_unaligned_native_struct_fields @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_unaligned_nonnative_struct_fields @ linux-x86_64 +ctypes.test.test_byteswap.Test.test_union_fields_unsupported_byte_order @ linux-x86_64 +ctypes.test.test_callbacks.Callbacks.test_issue12483 @ linux-x86_64 +ctypes.test.test_callbacks.Callbacks.test_unsupported_restype_1 @ linux-x86_64 +ctypes.test.test_callbacks.Callbacks.test_unsupported_restype_2 @ linux-x86_64 +ctypes.test.test_callbacks.SampleCallbacksTestCase.test_callback_register_double @ linux-x86_64 +ctypes.test.test_callbacks.SampleCallbacksTestCase.test_callback_register_int @ linux-x86_64 +ctypes.test.test_callbacks.SampleCallbacksTestCase.test_integrate @ linux-x86_64 +ctypes.test.test_callbacks.SampleCallbacksTestCase.test_issue_8959_a @ linux-x86_64 +ctypes.test.test_cast.Test.test_address2pointer @ linux-x86_64 +ctypes.test.test_cast.Test.test_array2pointer @ linux-x86_64 +ctypes.test.test_cast.Test.test_bad_type_arg @ linux-x86_64 +ctypes.test.test_cast.Test.test_char_p @ linux-x86_64 +ctypes.test.test_cast.Test.test_other @ linux-x86_64 +ctypes.test.test_cast.Test.test_p2a_objects @ linux-x86_64 +ctypes.test.test_cast.Test.test_wchar_p @ linux-x86_64 +ctypes.test.test_delattr.TestCase.test_chararray @ linux-x86_64 +ctypes.test.test_delattr.TestCase.test_simple @ linux-x86_64 +ctypes.test.test_delattr.TestCase.test_struct @ linux-x86_64 +ctypes.test.test_find.FindLibraryLinux.test_find_library_with_gcc @ linux-x86_64 +ctypes.test.test_find.FindLibraryLinux.test_find_library_with_ld @ linux-x86_64 +ctypes.test.test_find.FindLibraryLinux.test_find_on_libpath @ linux-x86_64 +ctypes.test.test_find.Test_OpenGL_libs.test_gl @ linux-x86_64 +ctypes.test.test_find.Test_OpenGL_libs.test_shell_injection @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_abstract @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_fortran_contiguous @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_from_buffer_copy @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_from_buffer_copy_with_offset @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_from_buffer_memoryview @ linux-x86_64 +ctypes.test.test_frombuffer.Test.test_from_buffer_with_offset @ linux-x86_64 +ctypes.test.test_funcptr.CFuncPtrTestCase.test_abstract @ linux-x86_64 +ctypes.test.test_funcptr.CFuncPtrTestCase.test_basic @ linux-x86_64 +ctypes.test.test_funcptr.CFuncPtrTestCase.test_dllfunctions @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_callbacks @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_callbacks_2 @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_doubleresult @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_errors @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_floatresult @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_intresult @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_longlong_callbacks @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_longlongresult @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_mro @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_pointers @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_shorts @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_stringresult @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_wchar_parm @ linux-x86_64 +ctypes.test.test_functions.FunctionTestCase.test_wchar_result @ linux-x86_64 +ctypes.test.test_init.InitTest.test_get @ linux-x86_64 +ctypes.test.test_internals.ObjectsTestCase.test_embedded_structs @ linux-x86_64 +ctypes.test.test_internals.ObjectsTestCase.test_ints @ linux-x86_64 +ctypes.test.test_internals.ObjectsTestCase.test_ptr_struct @ linux-x86_64 +ctypes.test.test_internals.ObjectsTestCase.test_simple_struct @ linux-x86_64 +ctypes.test.test_internals.ObjectsTestCase.test_xxx @ linux-x86_64 +ctypes.test.test_keeprefs.ArrayTestCase.test_cint_array @ linux-x86_64 +ctypes.test.test_keeprefs.PointerTestCase.test_p_cint @ linux-x86_64 +ctypes.test.test_keeprefs.SimpleTestCase.test_ccharp @ linux-x86_64 +ctypes.test.test_keeprefs.SimpleTestCase.test_cint @ linux-x86_64 +ctypes.test.test_keeprefs.StructureTestCase.test_ccharp_struct @ linux-x86_64 +ctypes.test.test_keeprefs.StructureTestCase.test_cint_struct @ linux-x86_64 +ctypes.test.test_keeprefs.StructureTestCase.test_struct_struct @ linux-x86_64 +ctypes.test.test_libc.LibTest.test_qsort @ linux-x86_64 +ctypes.test.test_libc.LibTest.test_sqrt @ linux-x86_64 +ctypes.test.test_loading.LoaderTest.test_find @ linux-x86_64 +ctypes.test.test_loading.LoaderTest.test_load @ linux-x86_64 +ctypes.test.test_loading.LoaderTest.test_load_version @ linux-x86_64 +ctypes.test.test_memfunctions.MemFunctionsTest.test_cast @ linux-x86_64 +ctypes.test.test_memfunctions.MemFunctionsTest.test_memmove @ linux-x86_64 +ctypes.test.test_memfunctions.MemFunctionsTest.test_memset @ linux-x86_64 +ctypes.test.test_memfunctions.MemFunctionsTest.test_wstring_at @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_bool_values @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_byref @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_char_from_address @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_default_init @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_float_from_address @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_float_overflow @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_floats @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_from_param @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_init @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_int_from_address @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_integers @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_signed_values @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_sizes @ linux-x86_64 +ctypes.test.test_numbers.NumberTestCase.test_typeerror @ linux-x86_64 +ctypes.test.test_objects.TestCase.test @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_abstract @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_array_pointers @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_byref_pointer @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_byref_pointerpointer @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_cstrings @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_cw_strings @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_int_pointers @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_subclasses @ linux-x86_64 +ctypes.test.test_parameters.SimpleTypesTestCase.test_subclasses_c_wchar_p @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_0.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_0.test_wchar @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_1.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_1.test_wchar @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_2.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_2.test_wchar @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_3.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_3.test_wchar @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_4.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_4.test_wchar @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_5.test_unpickable @ linux-x86_64 +ctypes.test.test_pickling.PickleTest_5.test_wchar @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_abstract @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_basic @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_basics @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_bug_1467852 @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_callbacks_with_pointers @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_change_pointers @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_charpp @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_from_address @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_pass_pointers @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_pointer_crash @ linux-x86_64 +ctypes.test.test_pointers.PointersTestCase.test_pointer_type_name @ linux-x86_64 +ctypes.test.test_prototypes.ArrayTest.test @ linux-x86_64 +ctypes.test.test_prototypes.CharPointersTestCase.test_POINTER_c_char_arg @ linux-x86_64 +ctypes.test.test_prototypes.CharPointersTestCase.test_c_char_p_arg @ linux-x86_64 +ctypes.test.test_prototypes.CharPointersTestCase.test_c_void_p_arg @ linux-x86_64 +ctypes.test.test_prototypes.CharPointersTestCase.test_c_void_p_arg_with_c_wchar_p @ linux-x86_64 +ctypes.test.test_prototypes.WCharPointersTestCase.test_POINTER_c_wchar_arg @ linux-x86_64 +ctypes.test.test_prototypes.WCharPointersTestCase.test_c_wchar_p_arg @ linux-x86_64 +ctypes.test.test_python_api.PythonAPITestCase.test_PyBytes_FromStringAndSize @ linux-x86_64 +!ctypes.test.test_python_api.PythonAPITestCase.test_PyOS_snprintf @ linux-x86_64 +ctypes.test.test_returnfuncptrs.ReturnFuncPtrTestCase.test_from_dll @ linux-x86_64 +ctypes.test.test_returnfuncptrs.ReturnFuncPtrTestCase.test_from_dll_refcount @ linux-x86_64 +ctypes.test.test_simplesubclasses.Test.test_compare @ linux-x86_64 +ctypes.test.test_simplesubclasses.Test.test_int_struct @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_16 @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_32 @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_64 @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_8 @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_size_t @ linux-x86_64 +ctypes.test.test_sizes.SizesTestCase.test_ssize_t @ linux-x86_64 +ctypes.test.test_slicing.SlicesTestCase.test_char_array @ linux-x86_64 +ctypes.test.test_slicing.SlicesTestCase.test_getslice_cint @ linux-x86_64 +ctypes.test.test_slicing.SlicesTestCase.test_setslice_cint @ linux-x86_64 +ctypes.test.test_stringptr.StringPtrTestCase.test__c_char_p @ linux-x86_64 +ctypes.test.test_stringptr.StringPtrTestCase.test_functions @ linux-x86_64 +ctypes.test.test_strings.StringArrayTestCase.test_c_buffer_raw @ linux-x86_64 +ctypes.test.test_strings.StringArrayTestCase.test_c_buffer_value @ linux-x86_64 +ctypes.test.test_strings.StringArrayTestCase.test_param_1 @ linux-x86_64 +ctypes.test.test_strings.StringArrayTestCase.test_param_2 @ linux-x86_64 +ctypes.test.test_strings.WStringArrayTestCase.test_nonbmp @ linux-x86_64 +ctypes.test.test_strings.WStringTestCase.test_wchar @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_1_A @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_1_B @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_2 @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_3 @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test_4 @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test___get__ @ linux-x86_64 +ctypes.test.test_struct_fields.StructFieldsTestCase.test___set__ @ linux-x86_64 +ctypes.test.test_structures.PointerMemberTestCase.test @ linux-x86_64 +ctypes.test.test_structures.PointerMemberTestCase.test_none_to_pointer_fields @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_38368 @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_abstract_class @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_conflicting_initializers @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_empty @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_fields @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_huge_field_name @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_initializers @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_invalid_field_types @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_invalid_name @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_keyword_initializers @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_methods @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_struct_alignment @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_structures_with_wchar @ linux-x86_64 +ctypes.test.test_structures.StructureTestCase.test_unions @ linux-x86_64 +ctypes.test.test_structures.TestRecursiveStructure.test_contains_itself @ linux-x86_64 +ctypes.test.test_structures.TestRecursiveStructure.test_vice_versa @ linux-x86_64 +ctypes.test.test_unaligned_structures.TestStructures.test_native @ linux-x86_64 +ctypes.test.test_unaligned_structures.TestStructures.test_swapped @ linux-x86_64 +ctypes.test.test_unicode.StringTestCase.test_buffers @ linux-x86_64 +ctypes.test.test_unicode.StringTestCase.test_embedded_null @ linux-x86_64 +ctypes.test.test_unicode.StringTestCase.test_func @ linux-x86_64 +ctypes.test.test_unicode.StringTestCase.test_wcslen @ linux-x86_64 +ctypes.test.test_unicode.UnicodeTestCase.test_embedded_null @ linux-x86_64 +ctypes.test.test_unicode.UnicodeTestCase.test_wcslen @ linux-x86_64 +ctypes.test.test_values.PythonValuesTestCase.test_undefined @ linux-x86_64 +ctypes.test.test_values.ValuesTestCase.test_undefined @ linux-x86_64 +ctypes.test.test_varsize_struct.VarSizeTest.test_array_invalid_length @ linux-x86_64 +ctypes.test.test_varsize_struct.VarSizeTest.test_zerosized_array @ linux-x86_64 +ctypes.test.test_wintypes.WinTypesTest.test_variant_bool @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dataclasses.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dataclasses.txt new file mode 100644 index 0000000000..7fe7338fcf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dataclasses.txt @@ -0,0 +1,211 @@ +test.test_dataclasses.TestAbstract.test_abc_implementation @ linux-x86_64 +test.test_dataclasses.TestAbstract.test_maintain_abc @ linux-x86_64 +test.test_dataclasses.TestCase.test_0_field_compare @ linux-x86_64 +test.test_dataclasses.TestCase.test_1_field_compare @ linux-x86_64 +test.test_dataclasses.TestCase.test_alternate_classmethod_constructor @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_attrs @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_marker @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_var @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_var_default_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_var_frozen @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_var_no_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_class_var_with_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_classvar_default_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_clean_traceback_from_fields_exception @ linux-x86_64 +test.test_dataclasses.TestCase.test_compare_subclasses @ linux-x86_64 +test.test_dataclasses.TestCase.test_dataclasses_pickleable @ linux-x86_64 +test.test_dataclasses.TestCase.test_dataclasses_qualnames @ linux-x86_64 +test.test_dataclasses.TestCase.test_default_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_default_factory_derived @ linux-x86_64 +test.test_dataclasses.TestCase.test_default_factory_not_called_if_value_given @ linux-x86_64 +test.test_dataclasses.TestCase.test_default_factory_with_no_init @ linux-x86_64 +test.test_dataclasses.TestCase.test_deliberately_mutable_defaults @ linux-x86_64 +test.test_dataclasses.TestCase.test_disallowed_mutable_defaults @ linux-x86_64 +test.test_dataclasses.TestCase.test_dont_include_other_annotations @ linux-x86_64 +test.test_dataclasses.TestCase.test_dynamic_class_creation @ linux-x86_64 +test.test_dataclasses.TestCase.test_dynamic_class_creation_using_field @ linux-x86_64 +test.test_dataclasses.TestCase.test_eq_order @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_default_default_factory_error @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_metadata_custom_mapping @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_metadata_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_metadata_mapping @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_BUILTINS_frozen @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_like_builtin @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_like_builtin_frozen @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_object @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_object_frozen @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_named_self @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_no_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_order @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_recursive_repr @ linux-x86_64 +test.test_dataclasses.TestCase.test_field_repr @ linux-x86_64 +test.test_dataclasses.TestCase.test_function_annotations @ linux-x86_64 +test.test_dataclasses.TestCase.test_generic_dataclasses @ linux-x86_64 +test.test_dataclasses.TestCase.test_generic_dynamic @ linux-x86_64 +test.test_dataclasses.TestCase.test_generic_extending @ linux-x86_64 +test.test_dataclasses.TestCase.test_hash_field_rules @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_builtin_containers @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_builtin_object_containers @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_copy_values @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_namedtuple @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_namedtuple_derived @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_namedtuple_key @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_nested @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_asdict_raises_on_classes @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_builtin_containers @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_builtin_object_containers @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_copy_values @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_namedtuple @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_nested @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_astuple_raises_on_classes @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_fields_exception @ linux-x86_64 +test.test_dataclasses.TestCase.test_helper_fields_with_class_instance @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_false_no_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_in_order @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var_default_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var_inheritance @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var_no_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var_preserve_type @ linux-x86_64 +test.test_dataclasses.TestCase.test_init_var_with_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_intermediate_non_dataclass @ linux-x86_64 +test.test_dataclasses.TestCase.test_is_dataclass @ linux-x86_64 +test.test_dataclasses.TestCase.test_is_dataclass_genericalias @ linux-x86_64 +test.test_dataclasses.TestCase.test_is_dataclass_when_getattr_always_returns @ linux-x86_64 +test.test_dataclasses.TestCase.test_items_in_dicts @ linux-x86_64 +test.test_dataclasses.TestCase.test_missing_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_missing_default_factory @ linux-x86_64 +test.test_dataclasses.TestCase.test_missing_repr @ linux-x86_64 +test.test_dataclasses.TestCase.test_named_init_params @ linux-x86_64 +test.test_dataclasses.TestCase.test_no_fields @ linux-x86_64 +test.test_dataclasses.TestCase.test_no_fields_but_member_variable @ linux-x86_64 +test.test_dataclasses.TestCase.test_no_options @ linux-x86_64 +test.test_dataclasses.TestCase.test_no_unhashable_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_not_in_compare @ linux-x86_64 +test.test_dataclasses.TestCase.test_not_in_repr @ linux-x86_64 +test.test_dataclasses.TestCase.test_not_other_dataclass @ linux-x86_64 +test.test_dataclasses.TestCase.test_not_tuple @ linux-x86_64 +test.test_dataclasses.TestCase.test_one_field_no_default @ linux-x86_64 +test.test_dataclasses.TestCase.test_overwrite_fields_in_derived_class @ linux-x86_64 +test.test_dataclasses.TestCase.test_overwrite_hash @ linux-x86_64 +test.test_dataclasses.TestCase.test_post_init @ linux-x86_64 +test.test_dataclasses.TestCase.test_post_init_classmethod @ linux-x86_64 +test.test_dataclasses.TestCase.test_post_init_not_auto_added @ linux-x86_64 +test.test_dataclasses.TestCase.test_post_init_staticmethod @ linux-x86_64 +test.test_dataclasses.TestCase.test_post_init_super @ linux-x86_64 +test.test_dataclasses.TestCase.test_recursive_annotation @ linux-x86_64 +test.test_dataclasses.TestCase.test_simple_compare @ linux-x86_64 +test.test_dataclasses.TestCase.test_two_fields_one_default @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_default_value @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_getting_field_calls_get @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_init_calls_set @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_lookup_on_class @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_lookup_on_instance @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_no_default_value @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_non_descriptor @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_set_name @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_setting_field_calls_set @ linux-x86_64 +test.test_dataclasses.TestDescriptors.test_setting_uninitialized_descriptor_field @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_list_field @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_list_field_with_default_factory @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_no_fields @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_one_field @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_one_field_with_default @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_one_field_with_default_none @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_three_fields @ linux-x86_64 +test.test_dataclasses.TestDocString.test_docstring_two_fields @ linux-x86_64 +test.test_dataclasses.TestDocString.test_existing_docstring_not_overridden @ linux-x86_64 +test.test_dataclasses.TestEq.test_no_eq @ linux-x86_64 +test.test_dataclasses.TestEq.test_overwriting_eq @ linux-x86_64 +test.test_dataclasses.TestFieldNoAnnotation.test_field_without_annotation @ linux-x86_64 +test.test_dataclasses.TestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base @ linux-x86_64 +test.test_dataclasses.TestFieldNoAnnotation.test_field_without_annotation_but_annotation_in_base_not_dataclass @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_frozen @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_frozen_hash @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit_from_normal_class @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit_frozen_from_nonfrozen @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit_nonfrozen_from_empty @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit_nonfrozen_from_empty_frozen @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_inherit_nonfrozen_from_frozen @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_non_frozen_normal_derived @ linux-x86_64 +test.test_dataclasses.TestFrozen.test_overwriting_frozen @ linux-x86_64 +test.test_dataclasses.TestHash.test_0_field_hash @ linux-x86_64 +test.test_dataclasses.TestHash.test_1_field_hash @ linux-x86_64 +test.test_dataclasses.TestHash.test_eq_only @ linux-x86_64 +test.test_dataclasses.TestHash.test_hash_no_args @ linux-x86_64 +test.test_dataclasses.TestHash.test_hash_rules @ linux-x86_64 +test.test_dataclasses.TestHash.test_unsafe_hash @ linux-x86_64 +test.test_dataclasses.TestInit.test_base_has_init @ linux-x86_64 +test.test_dataclasses.TestInit.test_inherit_from_protocol @ linux-x86_64 +test.test_dataclasses.TestInit.test_no_init @ linux-x86_64 +test.test_dataclasses.TestInit.test_overwriting_init @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_KW_ONLY @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_KW_ONLY_as_string @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_KW_ONLY_twice @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_defaults @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_field_marked_as_kwonly @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_make_dataclass @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_match_args @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_no_classvar_kwarg @ linux-x86_64 +test.test_dataclasses.TestKeywordArgs.test_post_init @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_base @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_base_dataclass @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_class_var @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_duplicate_field_names @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_funny_class_names_names @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_init_var @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_invalid_type_specification @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_keyword_field_names @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_no_mutate_namespace @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_no_types @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_non_identifier_field_names @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_other_params @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_simple @ linux-x86_64 +test.test_dataclasses.TestMakeDataclass.test_underscore_field_names @ linux-x86_64 +test.test_dataclasses.TestMatchArgs.test_bpo_43764 @ linux-x86_64 +test.test_dataclasses.TestMatchArgs.test_explicit_match_args @ linux-x86_64 +test.test_dataclasses.TestMatchArgs.test_make_dataclasses @ linux-x86_64 +test.test_dataclasses.TestMatchArgs.test_match_args @ linux-x86_64 +test.test_dataclasses.TestMatchArgs.test_match_args_argument @ linux-x86_64 +test.test_dataclasses.TestOrdering.test_functools_total_ordering @ linux-x86_64 +test.test_dataclasses.TestOrdering.test_no_order @ linux-x86_64 +test.test_dataclasses.TestOrdering.test_overwriting_order @ linux-x86_64 +test.test_dataclasses.TestReplace.test @ linux-x86_64 +test.test_dataclasses.TestReplace.test_classvar @ linux-x86_64 +test.test_dataclasses.TestReplace.test_frozen @ linux-x86_64 +test.test_dataclasses.TestReplace.test_initvar_is_specified @ linux-x86_64 +test.test_dataclasses.TestReplace.test_initvar_with_default_value @ linux-x86_64 +test.test_dataclasses.TestReplace.test_invalid_field_name @ linux-x86_64 +test.test_dataclasses.TestReplace.test_invalid_object @ linux-x86_64 +test.test_dataclasses.TestReplace.test_no_init @ linux-x86_64 +test.test_dataclasses.TestReplace.test_recursive_repr @ linux-x86_64 +test.test_dataclasses.TestReplace.test_recursive_repr_indirection @ linux-x86_64 +test.test_dataclasses.TestReplace.test_recursive_repr_indirection_two @ linux-x86_64 +test.test_dataclasses.TestReplace.test_recursive_repr_misc_attrs @ linux-x86_64 +test.test_dataclasses.TestReplace.test_recursive_repr_two_attrs @ linux-x86_64 +test.test_dataclasses.TestRepr.test_no_repr @ linux-x86_64 +test.test_dataclasses.TestRepr.test_overwriting_repr @ linux-x86_64 +test.test_dataclasses.TestRepr.test_repr @ linux-x86_64 +test.test_dataclasses.TestSlots.test_add_slots_when_slots_exists @ linux-x86_64 +test.test_dataclasses.TestSlots.test_derived_added_field @ linux-x86_64 +test.test_dataclasses.TestSlots.test_frozen_pickle @ linux-x86_64 +test.test_dataclasses.TestSlots.test_frozen_slots_pickle_custom_state @ linux-x86_64 +test.test_dataclasses.TestSlots.test_generated_slots @ linux-x86_64 +test.test_dataclasses.TestSlots.test_returns_new_class @ linux-x86_64 +test.test_dataclasses.TestSlots.test_simple @ linux-x86_64 +test.test_dataclasses.TestSlots.test_slots_with_default_factory_no_init @ linux-x86_64 +test.test_dataclasses.TestSlots.test_slots_with_default_no_init @ linux-x86_64 +test.test_dataclasses.TestSlots.test_weakref_slot_make_dataclass @ linux-x86_64 +test.test_dataclasses.TestSlots.test_weakref_slot_without_slot @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_classvar @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_classvar_module_level_import @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_initvar @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_isnt_classvar @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_isnt_initvar @ linux-x86_64 +test.test_dataclasses.TestStringAnnotations.test_text_annotations @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm.txt new file mode 100644 index 0000000000..c60e90da92 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm.txt @@ -0,0 +1,14 @@ +test.test_dbm.TestCase_dumb.test_anydbm_access @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_creation @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_creation_n_file_exists_with_invalid_contents @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_keys @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_modification @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_not_existing @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_anydbm_read @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_empty_value @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_error @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_keys @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_open_with_bytes @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_open_with_pathlib_path @ linux-x86_64 +test.test_dbm.TestCase_dumb.test_open_with_pathlib_path_bytes @ linux-x86_64 +test.test_dbm.WhichDBTestCase.test_whichdb @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm_dumb.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm_dumb.txt new file mode 100644 index 0000000000..8cb718bcaf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dbm_dumb.txt @@ -0,0 +1,24 @@ +test.test_dbm_dumb.DumbDBMTestCase.test_check_closed @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_close_twice @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_context_manager @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_create_new @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_dumbdbm_creation @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_dumbdbm_creation_mode @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_dumbdbm_keys @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_dumbdbm_modification @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_dumbdbm_read @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_eval @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_invalid_flag @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_line_endings @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_missing_data @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_missing_index @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_nonascii_filename @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_open_with_bytes_path @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_open_with_pathlib_bytes_path @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_open_with_pathlib_path @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_random @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_readonly_files @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_str_read @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_str_write_contains @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_write_contains @ linux-x86_64 +test.test_dbm_dumb.DumbDBMTestCase.test_write_write_read @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decimal.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decimal.txt new file mode 100644 index 0000000000..8a06c4ae72 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decimal.txt @@ -0,0 +1,372 @@ +DocTestCase.decimal @ linux-x86_64 +DocTestCase.decimal.Context.abs @ linux-x86_64 +DocTestCase.decimal.Context.add @ linux-x86_64 +DocTestCase.decimal.Context.canonical @ linux-x86_64 +DocTestCase.decimal.Context.compare @ linux-x86_64 +DocTestCase.decimal.Context.compare_signal @ linux-x86_64 +DocTestCase.decimal.Context.compare_total @ linux-x86_64 +DocTestCase.decimal.Context.copy_abs @ linux-x86_64 +DocTestCase.decimal.Context.copy_decimal @ linux-x86_64 +DocTestCase.decimal.Context.copy_negate @ linux-x86_64 +DocTestCase.decimal.Context.copy_sign @ linux-x86_64 +DocTestCase.decimal.Context.create_decimal_from_float @ linux-x86_64 +DocTestCase.decimal.Context.divide @ linux-x86_64 +DocTestCase.decimal.Context.divide_int @ linux-x86_64 +DocTestCase.decimal.Context.divmod @ linux-x86_64 +DocTestCase.decimal.Context.exp @ linux-x86_64 +DocTestCase.decimal.Context.fma @ linux-x86_64 +DocTestCase.decimal.Context.is_canonical @ linux-x86_64 +DocTestCase.decimal.Context.is_finite @ linux-x86_64 +DocTestCase.decimal.Context.is_infinite @ linux-x86_64 +DocTestCase.decimal.Context.is_nan @ linux-x86_64 +DocTestCase.decimal.Context.is_normal @ linux-x86_64 +DocTestCase.decimal.Context.is_qnan @ linux-x86_64 +DocTestCase.decimal.Context.is_signed @ linux-x86_64 +DocTestCase.decimal.Context.is_snan @ linux-x86_64 +DocTestCase.decimal.Context.is_subnormal @ linux-x86_64 +DocTestCase.decimal.Context.is_zero @ linux-x86_64 +DocTestCase.decimal.Context.ln @ linux-x86_64 +DocTestCase.decimal.Context.log10 @ linux-x86_64 +DocTestCase.decimal.Context.logb @ linux-x86_64 +DocTestCase.decimal.Context.logical_and @ linux-x86_64 +DocTestCase.decimal.Context.logical_invert @ linux-x86_64 +DocTestCase.decimal.Context.logical_or @ linux-x86_64 +DocTestCase.decimal.Context.logical_xor @ linux-x86_64 +DocTestCase.decimal.Context.max @ linux-x86_64 +DocTestCase.decimal.Context.max_mag @ linux-x86_64 +DocTestCase.decimal.Context.min @ linux-x86_64 +DocTestCase.decimal.Context.min_mag @ linux-x86_64 +DocTestCase.decimal.Context.minus @ linux-x86_64 +DocTestCase.decimal.Context.multiply @ linux-x86_64 +DocTestCase.decimal.Context.next_minus @ linux-x86_64 +DocTestCase.decimal.Context.next_plus @ linux-x86_64 +DocTestCase.decimal.Context.next_toward @ linux-x86_64 +DocTestCase.decimal.Context.normalize @ linux-x86_64 +DocTestCase.decimal.Context.number_class @ linux-x86_64 +DocTestCase.decimal.Context.plus @ linux-x86_64 +DocTestCase.decimal.Context.power @ linux-x86_64 +DocTestCase.decimal.Context.quantize @ linux-x86_64 +DocTestCase.decimal.Context.radix @ linux-x86_64 +DocTestCase.decimal.Context.remainder @ linux-x86_64 +DocTestCase.decimal.Context.remainder_near @ linux-x86_64 +DocTestCase.decimal.Context.rotate @ linux-x86_64 +DocTestCase.decimal.Context.same_quantum @ linux-x86_64 +DocTestCase.decimal.Context.scaleb @ linux-x86_64 +DocTestCase.decimal.Context.shift @ linux-x86_64 +DocTestCase.decimal.Context.sqrt @ linux-x86_64 +DocTestCase.decimal.Context.subtract @ linux-x86_64 +DocTestCase.decimal.Context.to_eng_string @ linux-x86_64 +DocTestCase.decimal.Context.to_integral_exact @ linux-x86_64 +DocTestCase.decimal.Context.to_integral_value @ linux-x86_64 +DocTestCase.decimal.Decimal.__new__ @ linux-x86_64 +DocTestCase.decimal.Decimal.__round__ @ linux-x86_64 +DocTestCase.decimal.Decimal.as_integer_ratio @ linux-x86_64 +DocTestCase.decimal.Decimal.from_float @ linux-x86_64 +DocTestCase.decimal.localcontext @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_addition @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_copy_sign @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_division @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_floor_div_module @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_floor_division @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_module @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_multiplication @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_nan_comparisons @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_powering @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_subtraction @ linux-x86_64 +test.test_decimal.PyArithmeticOperatorsTest.test_unary_operators @ linux-x86_64 +test.test_decimal.PyContextAPItests.test__clamp @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_abs @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_add @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_compare @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_compare_signal @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_compare_total @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_compare_total_mag @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_copy @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_copy_abs @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_copy_decimal @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_copy_negate @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_copy_sign @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_divide @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_divide_int @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_divmod @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_equality_with_other_types @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_exp @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_fma @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_finite @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_infinite @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_nan @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_normal @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_qnan @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_signed @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_snan @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_subnormal @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_is_zero @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_ln @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_log10 @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_logb @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_logical_and @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_logical_invert @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_logical_or @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_logical_xor @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_max @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_max_mag @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_min @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_min_mag @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_minus @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_multiply @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_next_minus @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_next_plus @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_next_toward @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_none_args @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_normalize @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_number_class @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_pickle @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_plus @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_power @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_quantize @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_remainder @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_remainder_near @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_rotate @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_same_quantum @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_scaleb @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_shift @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_sqrt @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_subtract @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_to_eng_string @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_to_integral_exact @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_to_integral_value @ linux-x86_64 +test.test_decimal.PyContextAPItests.test_to_sci_string @ linux-x86_64 +test.test_decimal.PyContextFlags.test_flag_comparisons @ linux-x86_64 +test.test_decimal.PyContextFlags.test_flags_irrelevant @ linux-x86_64 +test.test_decimal.PyContextFlags.test_float_comparison @ linux-x86_64 +test.test_decimal.PyContextFlags.test_float_operation @ linux-x86_64 +test.test_decimal.PyContextFlags.test_float_operation_default @ linux-x86_64 +test.test_decimal.PyContextInputValidation.test_invalid_context @ linux-x86_64 +test.test_decimal.PyContextSubclassing.test_context_subclassing @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_local_context_kwargs_does_not_overwrite_existing_argument @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_localcontext @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_localcontext_kwargs @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_localcontextarg @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_nested_with_statements @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_with_statements_gc1 @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_with_statements_gc2 @ linux-x86_64 +test.test_decimal.PyContextWithStatement.test_with_statements_gc3 @ linux-x86_64 +test.test_decimal.PyCoverage.test_adjusted @ linux-x86_64 +test.test_decimal.PyCoverage.test_canonical @ linux-x86_64 +test.test_decimal.PyCoverage.test_context_repr @ linux-x86_64 +test.test_decimal.PyCoverage.test_copy @ linux-x86_64 +test.test_decimal.PyCoverage.test_create_decimal @ linux-x86_64 +test.test_decimal.PyCoverage.test_divmod @ linux-x86_64 +test.test_decimal.PyCoverage.test_implicit_context @ linux-x86_64 +test.test_decimal.PyCoverage.test_int @ linux-x86_64 +test.test_decimal.PyCoverage.test_power @ linux-x86_64 +test.test_decimal.PyCoverage.test_quantize @ linux-x86_64 +test.test_decimal.PyCoverage.test_radix @ linux-x86_64 +test.test_decimal.PyCoverage.test_rop @ linux-x86_64 +test.test_decimal.PyCoverage.test_round @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_context_create_decimal @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_context_create_from_float @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_empty @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_Decimal @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_None @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_bool @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_float @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_int @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_list @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_string @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_explicit_from_tuples @ linux-x86_64 +test.test_decimal.PyExplicitConstructionTest.test_unicode_digits @ linux-x86_64 +test.test_decimal.PyFormatTest.test_decimal_from_float_argument_type @ linux-x86_64 +test.test_decimal.PyFormatTest.test_formatting @ linux-x86_64 +test.test_decimal.PyFormatTest.test_n_format @ linux-x86_64 +test.test_decimal.PyFormatTest.test_negative_zero_bad_format @ linux-x86_64 +test.test_decimal.PyFormatTest.test_negative_zero_format_directed_rounding @ linux-x86_64 +test.test_decimal.PyFormatTest.test_wide_char_separator_decimal_point @ linux-x86_64 +test.test_decimal.PyFunctionality.test_py_alternate_formatting @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_abs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_add @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_and @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_base @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_clamp @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_class @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_compare @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_comparetotal @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_comparetotmag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_copy @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_copyabs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_copynegate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_copysign @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddAbs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddAdd @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddAnd @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddBase @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCanonical @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddClass @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCompare @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCompareSig @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCompareTotal @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCompareTotalMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCopy @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCopyAbs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCopyNegate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddCopySign @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddDivide @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddDivideInt @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddEncode @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddFMA @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddInvert @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddLogB @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMax @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMaxMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMin @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMinMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMinus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddMultiply @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddNextMinus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddNextPlus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddNextToward @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddOr @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddPlus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddQuantize @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddReduce @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddRemainder @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddRemainderNear @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddRotate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddSameQuantum @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddScaleB @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddShift @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddSubtract @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddToIntegral @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ddXor @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_decDouble @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_decQuad @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_decSingle @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_divide @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_divideint @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqAbs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqAdd @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqAnd @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqBase @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCanonical @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqClass @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCompare @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCompareSig @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCompareTotal @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCompareTotalMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCopy @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCopyAbs @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCopyNegate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqCopySign @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqDivide @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqDivideInt @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqEncode @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqFMA @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqInvert @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqLogB @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMax @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMaxMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMin @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMinMag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMinus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqMultiply @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqNextMinus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqNextPlus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqNextToward @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqOr @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqPlus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqQuantize @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqReduce @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqRemainder @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqRemainderNear @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqRotate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqSameQuantum @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqScaleB @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqShift @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqSubtract @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqToIntegral @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dqXor @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dsBase @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_dsEncode @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_exp @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_extra @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_fma @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_inexact @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_invert @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_ln @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_log10 @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_logb @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_max @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_maxmag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_min @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_minmag @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_minus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_multiply @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_nextminus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_nextplus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_nexttoward @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_or @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_plus @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_power @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_powersqrt @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_quantize @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_randomBound32 @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_randoms @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_reduce @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_remainder @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_remainderNear @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_rescale @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_rotate @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_rounding @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_samequantum @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_scaleb @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_shift @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_squareroot @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_subtract @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_testall @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_tointegral @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_tointegralx @ linux-x86_64 +test.test_decimal.PyIBMTestCases.test_xor @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_implicit_from_Decimal @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_implicit_from_None @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_implicit_from_float @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_implicit_from_int @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_implicit_from_string @ linux-x86_64 +test.test_decimal.PyImplicitConstructionTest.test_rop @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_abc @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_complex @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_create_decimal_from_float @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_exception_hierarchy @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_from_float @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_int @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_named_parameters @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_pickle @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_quantize @ linux-x86_64 +test.test_decimal.PyPythonAPItests.test_trunc @ linux-x86_64 +test.test_decimal.PySpecialContexts.test_context_templates @ linux-x86_64 +test.test_decimal.PySpecialContexts.test_default_context @ linux-x86_64 +test.test_decimal.PyThreadingTest.test_threading @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_as_integer_ratio @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_as_nonzero @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_as_tuple @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_comparison_operators @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_conversions_from_int @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_copy_and_deepcopy_methods @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_decimal_complex_comparison @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_decimal_float_comparison @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_decimal_fraction_comparison @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_eval_round_trip @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_hash_method @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_hash_method_nan @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_implicit_context @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_min_and_max_methods @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_nan_to_float @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_none_args @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_snan_to_float @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_subclassing @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_tonum_methods @ linux-x86_64 +test.test_decimal.PyUsabilityTest.test_tostring_methods @ linux-x86_64 +test.test_decimal.PyWhitebox.test_py__round @ linux-x86_64 +test.test_decimal.PyWhitebox.test_py_decimal_id @ linux-x86_64 +test.test_decimal.PyWhitebox.test_py_exact_power @ linux-x86_64 +test.test_decimal.PyWhitebox.test_py_immutability_operations @ linux-x86_64 +test.test_decimal.PyWhitebox.test_py_rescale @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decorators.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decorators.txt new file mode 100644 index 0000000000..fe2c3b183a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_decorators.txt @@ -0,0 +1,16 @@ +test.test_decorators.TestClassDecorators.test_double @ linux-x86_64 +test.test_decorators.TestClassDecorators.test_order @ linux-x86_64 +test.test_decorators.TestClassDecorators.test_simple @ linux-x86_64 +test.test_decorators.TestDecorators.test_argforms @ linux-x86_64 +test.test_decorators.TestDecorators.test_bound_function_inside_classmethod @ linux-x86_64 +test.test_decorators.TestDecorators.test_dbcheck @ linux-x86_64 +test.test_decorators.TestDecorators.test_dotted @ linux-x86_64 +test.test_decorators.TestDecorators.test_double @ linux-x86_64 +test.test_decorators.TestDecorators.test_errors @ linux-x86_64 +test.test_decorators.TestDecorators.test_eval_order @ linux-x86_64 +test.test_decorators.TestDecorators.test_expressions @ linux-x86_64 +test.test_decorators.TestDecorators.test_memoize @ linux-x86_64 +test.test_decorators.TestDecorators.test_order @ linux-x86_64 +test.test_decorators.TestDecorators.test_single @ linux-x86_64 +test.test_decorators.TestDecorators.test_staticmethod @ linux-x86_64 +test.test_decorators.TestDecorators.test_wrapped_classmethod_inside_classmethod @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_defaultdict.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_defaultdict.txt new file mode 100644 index 0000000000..0180d51c34 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_defaultdict.txt @@ -0,0 +1,10 @@ +test.test_defaultdict.TestDefaultDict.test_basic @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_callable_arg @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_copy @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_deep_copy @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_keyerror_without_factory @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_missing @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_pickling @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_repr @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_shallow_copy @ linux-x86_64 +test.test_defaultdict.TestDefaultDict.test_union @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_deque.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_deque.txt new file mode 100644 index 0000000000..7349540e6c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_deque.txt @@ -0,0 +1,73 @@ +DocTestCase.test.test_deque.__test__.libreftest @ linux-x86_64 +test.test_deque.TestBasic.test_add @ linux-x86_64 +test.test_deque.TestBasic.test_basics @ linux-x86_64 +test.test_deque.TestBasic.test_big_queue_popleft @ linux-x86_64 +test.test_deque.TestBasic.test_big_queue_popright @ linux-x86_64 +test.test_deque.TestBasic.test_big_stack_left @ linux-x86_64 +test.test_deque.TestBasic.test_big_stack_right @ linux-x86_64 +test.test_deque.TestBasic.test_clear @ linux-x86_64 +test.test_deque.TestBasic.test_comparisons @ linux-x86_64 +test.test_deque.TestBasic.test_contains @ linux-x86_64 +test.test_deque.TestBasic.test_contains_count_stop_crashes @ linux-x86_64 +test.test_deque.TestBasic.test_copy @ linux-x86_64 +test.test_deque.TestBasic.test_copy_method @ linux-x86_64 +test.test_deque.TestBasic.test_count @ linux-x86_64 +test.test_deque.TestBasic.test_deepcopy @ linux-x86_64 +test.test_deque.TestBasic.test_delitem @ linux-x86_64 +test.test_deque.TestBasic.test_extend @ linux-x86_64 +test.test_deque.TestBasic.test_extendleft @ linux-x86_64 +test.test_deque.TestBasic.test_gc_doesnt_blowup @ linux-x86_64 +test.test_deque.TestBasic.test_getitem @ linux-x86_64 +test.test_deque.TestBasic.test_hash @ linux-x86_64 +test.test_deque.TestBasic.test_iadd @ linux-x86_64 +test.test_deque.TestBasic.test_imul @ linux-x86_64 +test.test_deque.TestBasic.test_index @ linux-x86_64 +test.test_deque.TestBasic.test_index_bug_24913 @ linux-x86_64 +test.test_deque.TestBasic.test_init @ linux-x86_64 +test.test_deque.TestBasic.test_insert @ linux-x86_64 +test.test_deque.TestBasic.test_insert_bug_26194 @ linux-x86_64 +test.test_deque.TestBasic.test_iterator_pickle @ linux-x86_64 +test.test_deque.TestBasic.test_len @ linux-x86_64 +test.test_deque.TestBasic.test_long_steadystate_queue_popleft @ linux-x86_64 +test.test_deque.TestBasic.test_long_steadystate_queue_popright @ linux-x86_64 +test.test_deque.TestBasic.test_maxlen @ linux-x86_64 +test.test_deque.TestBasic.test_maxlen_attribute @ linux-x86_64 +test.test_deque.TestBasic.test_maxlen_zero @ linux-x86_64 +test.test_deque.TestBasic.test_mul @ linux-x86_64 +test.test_deque.TestBasic.test_pickle @ linux-x86_64 +test.test_deque.TestBasic.test_pickle_recursive @ linux-x86_64 +test.test_deque.TestBasic.test_remove @ linux-x86_64 +test.test_deque.TestBasic.test_repr @ linux-x86_64 +test.test_deque.TestBasic.test_reverse @ linux-x86_64 +test.test_deque.TestBasic.test_reversed @ linux-x86_64 +test.test_deque.TestBasic.test_reversed_new @ linux-x86_64 +test.test_deque.TestBasic.test_rotate @ linux-x86_64 +test.test_deque.TestBasic.test_roundtrip_iter_init @ linux-x86_64 +test.test_deque.TestBasic.test_setitem @ linux-x86_64 +test.test_deque.TestBasic.test_underflow @ linux-x86_64 +test.test_deque.TestSequence.test_addmul @ linux-x86_64 +test.test_deque.TestSequence.test_constructors @ linux-x86_64 +test.test_deque.TestSequence.test_contains @ linux-x86_64 +test.test_deque.TestSequence.test_contains_fake @ linux-x86_64 +test.test_deque.TestSequence.test_contains_order @ linux-x86_64 +test.test_deque.TestSequence.test_count @ linux-x86_64 +test.test_deque.TestSequence.test_getitem @ linux-x86_64 +test.test_deque.TestSequence.test_getitemoverwriteiter @ linux-x86_64 +test.test_deque.TestSequence.test_getslice @ linux-x86_64 +test.test_deque.TestSequence.test_iadd @ linux-x86_64 +test.test_deque.TestSequence.test_imul @ linux-x86_64 +test.test_deque.TestSequence.test_index @ linux-x86_64 +test.test_deque.TestSequence.test_len @ linux-x86_64 +test.test_deque.TestSequence.test_minmax @ linux-x86_64 +test.test_deque.TestSequence.test_pickle @ linux-x86_64 +test.test_deque.TestSequence.test_repeat @ linux-x86_64 +test.test_deque.TestSequence.test_subscript @ linux-x86_64 +test.test_deque.TestSequence.test_truth @ linux-x86_64 +test.test_deque.TestSubclass.test_basics @ linux-x86_64 +test.test_deque.TestSubclass.test_copy_pickle @ linux-x86_64 +test.test_deque.TestSubclass.test_pickle_recursive @ linux-x86_64 +test.test_deque.TestSubclass.test_strange_subclass @ linux-x86_64 +test.test_deque.TestSubclassWithKwargs.test_subclass_with_kwargs @ linux-x86_64 +test.test_deque.TestVariousIteratorArgs.test_constructor @ linux-x86_64 +test.test_deque.TestVariousIteratorArgs.test_iter_with_altered_data @ linux-x86_64 +test.test_deque.TestVariousIteratorArgs.test_runtime_error_on_empty_deque @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descr.txt new file mode 100644 index 0000000000..e254f464db --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descr.txt @@ -0,0 +1,126 @@ +test.test_descr.AAAPTypesLongInitTest.test_pytype_long_ready @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_abstractmethods @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_altmro @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_assign_slice @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_attr_raise_through_property @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_basic_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_binary_operator_override @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_bound_method_repr @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_bpo25750 @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_buffer_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_builtin_bases @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_builtin_function_or_method @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_carloverre @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_carloverre_multi_inherit_valid @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_classic @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_classic_comparisons @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_classmethods @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_consistency_with_epg @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_copy_setstate @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_deepcopy_recursive @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_diamond_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_dict_constructors @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_dir @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_doc_descriptor @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_dynamics @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_errors @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_evil_type_name @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_ex5_from_c3_switch @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_file_fault @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_funny_new @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_getattr_hooks @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_hash_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_imul_bug @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_init @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_ipow @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_ipow_exception_text @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_ipow_returns_not_implemented @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_isinst_isclass @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_keyword_arguments @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_keywords @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_load_attr_extended_arg @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_metaclass @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_method_wrapper @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_methods @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mixing_slot_wrappers @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_module_subclasses @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_monotonicity @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mro_disagreement @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_multiple_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mutable_bases @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mutable_bases_catch_mro_conflict @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mutable_bases_with_failing_mro @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_mutable_names @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_newslots @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_no_ipow @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_not_implemented @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_object_class @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_object_class_assignment_between_heaptypes_and_nonheaptypes @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_object_new @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_object_new_and_init_with_parameters @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_overloading @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_proxy_call @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_proxy_super @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_python_dicts @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_python_lists @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_qualname @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_qualname_dict @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_recursive_call @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_repr_with_module_str_subclass @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_rich_comparisons @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_rmul @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_set_and_no_get @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_set_class @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_set_dict @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_set_doc @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slices @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slot_shadows_class_variable @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots_descriptor @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots_multiple_inheritance @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots_special @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots_special2 @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_slots_trash @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_special_method_lookup @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_special_unbound_method_types @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_specials @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_staticmethods @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_str_of_str_subclass @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_str_operations @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_str_subclass_as_dict_key @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_subclass_propagation @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_subclass_right_op @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_subclassing_does_not_duplicate_dict_descriptors @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_supers @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_type___getattribute__ @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_uninitialized_modules @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_unsubclassable_types @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_vicious_descriptor_nonsense @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_weakref_segfault @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_wrapper_segfault @ linux-x86_64 +test.test_descr.ClassPropertiesAndMethods.test_wrong_class_slot_wrapper @ linux-x86_64 +test.test_descr.DictProxyTests.test_dict_type_with_metaclass @ linux-x86_64 +test.test_descr.DictProxyTests.test_iter_items @ linux-x86_64 +test.test_descr.DictProxyTests.test_iter_keys @ linux-x86_64 +test.test_descr.DictProxyTests.test_iter_values @ linux-x86_64 +test.test_descr.DictProxyTests.test_repr @ linux-x86_64 +test.test_descr.MiscTests.test_type_lookup_mro_reference @ linux-x86_64 +test.test_descr.MroTest.test_incomplete_extend @ linux-x86_64 +test.test_descr.MroTest.test_incomplete_set_bases_on_self @ linux-x86_64 +test.test_descr.MroTest.test_incomplete_super @ linux-x86_64 +test.test_descr.MroTest.test_reent_set_bases_on_base @ linux-x86_64 +test.test_descr.MroTest.test_reent_set_bases_on_direct_base @ linux-x86_64 +test.test_descr.MroTest.test_reent_set_bases_tp_base_cycle @ linux-x86_64 +test.test_descr.MroTest.test_tp_subclasses_cycle_error_return_path @ linux-x86_64 +test.test_descr.MroTest.test_tp_subclasses_cycle_in_update_slots @ linux-x86_64 +test.test_descr.OperatorsTest.test_complexes @ linux-x86_64 +test.test_descr.OperatorsTest.test_dicts @ linux-x86_64 +test.test_descr.OperatorsTest.test_explicit_reverse_methods @ linux-x86_64 +test.test_descr.OperatorsTest.test_floats @ linux-x86_64 +test.test_descr.OperatorsTest.test_ints @ linux-x86_64 +test.test_descr.OperatorsTest.test_lists @ linux-x86_64 +test.test_descr.OperatorsTest.test_wrap_lenfunc_bad_cast @ linux-x86_64 +test.test_descr.PicklingTests.test_issue24097 @ linux-x86_64 +test.test_descr.PicklingTests.test_pickle_slots @ linux-x86_64 +test.test_descr.PicklingTests.test_reduce @ linux-x86_64 +test.test_descr.PicklingTests.test_reduce_copying @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descrtut.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descrtut.txt new file mode 100644 index 0000000000..a34b61d3d2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_descrtut.txt @@ -0,0 +1,7 @@ +DocTestCase.test.test_descrtut.__test__.tut1 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut2 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut4 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut5 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut6 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut7 @ linux-x86_64 +DocTestCase.test.test_descrtut.__test__.tut8 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dict.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dict.txt new file mode 100644 index 0000000000..5f57dca657 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dict.txt @@ -0,0 +1,90 @@ +test.test_dict.DictTest.test_bad_key @ linux-x86_64 +test.test_dict.DictTest.test_bool @ linux-x86_64 +test.test_dict.DictTest.test_clear @ linux-x86_64 +test.test_dict.DictTest.test_constructor @ linux-x86_64 +test.test_dict.DictTest.test_contains @ linux-x86_64 +test.test_dict.DictTest.test_copy @ linux-x86_64 +test.test_dict.DictTest.test_copy_fuzz @ linux-x86_64 +test.test_dict.DictTest.test_copy_maintains_tracking @ linux-x86_64 +test.test_dict.DictTest.test_copy_noncompact @ linux-x86_64 +test.test_dict.DictTest.test_dict_contain_use_after_free @ linux-x86_64 +test.test_dict.DictTest.test_dict_copy_order @ linux-x86_64 +test.test_dict.DictTest.test_dictitems_contains_use_after_free @ linux-x86_64 +test.test_dict.DictTest.test_dictview_mixed_set_operations @ linux-x86_64 +test.test_dict.DictTest.test_dictview_set_operations_on_items @ linux-x86_64 +test.test_dict.DictTest.test_dictview_set_operations_on_keys @ linux-x86_64 +test.test_dict.DictTest.test_empty_presized_dict_in_freelist @ linux-x86_64 +test.test_dict.DictTest.test_eq @ linux-x86_64 +test.test_dict.DictTest.test_equal_operator_modifying_operand @ linux-x86_64 +test.test_dict.DictTest.test_errors_in_view_containment_check @ linux-x86_64 +test.test_dict.DictTest.test_fromkeys @ linux-x86_64 +test.test_dict.DictTest.test_fromkeys_operator_modifying_dict_operand @ linux-x86_64 +test.test_dict.DictTest.test_fromkeys_operator_modifying_set_operand @ linux-x86_64 +test.test_dict.DictTest.test_get @ linux-x86_64 +test.test_dict.DictTest.test_getitem @ linux-x86_64 +test.test_dict.DictTest.test_init_use_after_free @ linux-x86_64 +test.test_dict.DictTest.test_instance_dict_getattr_str_subclass @ linux-x86_64 +test.test_dict.DictTest.test_invalid_keyword_arguments @ linux-x86_64 +test.test_dict.DictTest.test_itemiterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_items @ linux-x86_64 +test.test_dict.DictTest.test_items_symmetric_difference @ linux-x86_64 +test.test_dict.DictTest.test_iterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_keys @ linux-x86_64 +test.test_dict.DictTest.test_keys_contained @ linux-x86_64 +test.test_dict.DictTest.test_len @ linux-x86_64 +test.test_dict.DictTest.test_literal_constructor @ linux-x86_64 +test.test_dict.DictTest.test_merge_and_mutate @ linux-x86_64 +test.test_dict.DictTest.test_merge_operator @ linux-x86_64 +test.test_dict.DictTest.test_missing @ linux-x86_64 +test.test_dict.DictTest.test_mutating_iteration @ linux-x86_64 +test.test_dict.DictTest.test_mutating_lookup @ linux-x86_64 +test.test_dict.DictTest.test_object_set_item_single_instance_non_str_key @ linux-x86_64 +test.test_dict.DictTest.test_pop @ linux-x86_64 +test.test_dict.DictTest.test_popitem @ linux-x86_64 +test.test_dict.DictTest.test_reentrant_insertion @ linux-x86_64 +test.test_dict.DictTest.test_repr @ linux-x86_64 +test.test_dict.DictTest.test_resize1 @ linux-x86_64 +test.test_dict.DictTest.test_resize2 @ linux-x86_64 +test.test_dict.DictTest.test_reverse_iterator_for_empty_dict @ linux-x86_64 +test.test_dict.DictTest.test_reverse_iterator_for_shared_shared_dicts @ linux-x86_64 +test.test_dict.DictTest.test_reversed @ linux-x86_64 +test.test_dict.DictTest.test_reverseitemiterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_reverseiterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_reversevaluesiterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_setdefault @ linux-x86_64 +test.test_dict.DictTest.test_setitem_atomic_at_resize @ linux-x86_64 +test.test_dict.DictTest.test_str_nonstr @ linux-x86_64 +test.test_dict.DictTest.test_string_keys_can_track_values @ linux-x86_64 +test.test_dict.DictTest.test_tuple_keyerror @ linux-x86_64 +test.test_dict.DictTest.test_update @ linux-x86_64 +test.test_dict.DictTest.test_values @ linux-x86_64 +test.test_dict.DictTest.test_valuesiterator_pickling @ linux-x86_64 +test.test_dict.DictTest.test_views_mapping @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_bool @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_constructor @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_get @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_getitem @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_items @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_keys @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_len @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_pop @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_popitem @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_read @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_setdefault @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_update @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_values @ linux-x86_64 +test.test_dict.GeneralMappingTests.test_write @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_bool @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_constructor @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_get @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_getitem @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_items @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_keys @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_len @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_pop @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_popitem @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_read @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_setdefault @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_update @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_values @ linux-x86_64 +test.test_dict.SubclassMappingTests.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictcomps.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictcomps.txt new file mode 100644 index 0000000000..915c156532 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictcomps.txt @@ -0,0 +1,9 @@ +test.test_dictcomps.DictComprehensionTest.test_assignment_idiom_in_comprehensions @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_basics @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_evaluation_order @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_global_visibility @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_illegal_assignment @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_local_visibility @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_scope_isolation @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_scope_isolation_from_global @ linux-x86_64 +test.test_dictcomps.DictComprehensionTest.test_star_expression @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictviews.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictviews.txt new file mode 100644 index 0000000000..9ae7a102fa --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dictviews.txt @@ -0,0 +1,15 @@ +test.test_dictviews.DictSetTest.test_abc_registry @ linux-x86_64 +test.test_dictviews.DictSetTest.test_compare_error @ linux-x86_64 +test.test_dictviews.DictSetTest.test_constructors_not_callable @ linux-x86_64 +test.test_dictviews.DictSetTest.test_copy @ linux-x86_64 +test.test_dictviews.DictSetTest.test_dict_items @ linux-x86_64 +test.test_dictviews.DictSetTest.test_dict_keys @ linux-x86_64 +test.test_dictviews.DictSetTest.test_dict_mixed_keys_items @ linux-x86_64 +test.test_dictviews.DictSetTest.test_dict_repr @ linux-x86_64 +test.test_dictviews.DictSetTest.test_dict_values @ linux-x86_64 +test.test_dictviews.DictSetTest.test_items_set_operations @ linux-x86_64 +test.test_dictviews.DictSetTest.test_keys_set_operations @ linux-x86_64 +test.test_dictviews.DictSetTest.test_pickle @ linux-x86_64 +test.test_dictviews.DictSetTest.test_recursive_repr @ linux-x86_64 +test.test_dictviews.DictSetTest.test_set_operations_with_iterator @ linux-x86_64 +test.test_dictviews.DictSetTest.test_set_operations_with_noniterable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_difflib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_difflib.txt new file mode 100644 index 0000000000..6d92dc085b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_difflib.txt @@ -0,0 +1,51 @@ +DocTestCase.difflib.Differ @ linux-x86_64 +DocTestCase.difflib.Differ._fancy_replace @ linux-x86_64 +DocTestCase.difflib.Differ._qformat @ linux-x86_64 +DocTestCase.difflib.Differ.compare @ linux-x86_64 +DocTestCase.difflib.IS_CHARACTER_JUNK @ linux-x86_64 +DocTestCase.difflib.IS_LINE_JUNK @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.find_longest_match @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.get_grouped_opcodes @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.get_matching_blocks @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.get_opcodes @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.ratio @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.set_seq1 @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.set_seq2 @ linux-x86_64 +DocTestCase.difflib.SequenceMatcher.set_seqs @ linux-x86_64 +DocTestCase.difflib.context_diff @ linux-x86_64 +DocTestCase.difflib.get_close_matches @ linux-x86_64 +DocTestCase.difflib.ndiff @ linux-x86_64 +DocTestCase.difflib.restore @ linux-x86_64 +DocTestCase.difflib.unified_diff @ linux-x86_64 +test.test_difflib.TestAutojunk.test_one_insert_homogenous_sequence @ linux-x86_64 +test.test_difflib.TestBytes.test_byte_content @ linux-x86_64 +test.test_difflib.TestBytes.test_byte_filenames @ linux-x86_64 +test.test_difflib.TestBytes.test_mixed_types_content @ linux-x86_64 +test.test_difflib.TestBytes.test_mixed_types_dates @ linux-x86_64 +test.test_difflib.TestBytes.test_mixed_types_filenames @ linux-x86_64 +test.test_difflib.TestFindLongest.test_default_args @ linux-x86_64 +test.test_difflib.TestFindLongest.test_longest_match_with_popular_chars @ linux-x86_64 +test.test_difflib.TestJunkAPIs.test_is_character_junk_false @ linux-x86_64 +test.test_difflib.TestJunkAPIs.test_is_character_junk_true @ linux-x86_64 +test.test_difflib.TestJunkAPIs.test_is_line_junk_REDOS @ linux-x86_64 +test.test_difflib.TestJunkAPIs.test_is_line_junk_false @ linux-x86_64 +test.test_difflib.TestJunkAPIs.test_is_line_junk_true @ linux-x86_64 +test.test_difflib.TestOutputFormat.test_no_trailing_tab_on_empty_filedate @ linux-x86_64 +test.test_difflib.TestOutputFormat.test_range_format_context @ linux-x86_64 +test.test_difflib.TestOutputFormat.test_range_format_unified @ linux-x86_64 +test.test_difflib.TestOutputFormat.test_tab_delimiter @ linux-x86_64 +test.test_difflib.TestSFbugs.test_added_tab_hint @ linux-x86_64 +test.test_difflib.TestSFbugs.test_comparing_empty_lists @ linux-x86_64 +test.test_difflib.TestSFbugs.test_hint_indented_properly_with_tabs @ linux-x86_64 +test.test_difflib.TestSFbugs.test_matching_blocks_cache @ linux-x86_64 +test.test_difflib.TestSFbugs.test_mdiff_catch_stop_iteration @ linux-x86_64 +test.test_difflib.TestSFbugs.test_ratio_for_null_seqn @ linux-x86_64 +test.test_difflib.TestSFpatches.test_html_diff @ linux-x86_64 +test.test_difflib.TestSFpatches.test_make_file_default_charset @ linux-x86_64 +test.test_difflib.TestSFpatches.test_make_file_iso88591_charset @ linux-x86_64 +test.test_difflib.TestSFpatches.test_make_file_usascii_charset_with_nonascii_input @ linux-x86_64 +test.test_difflib.TestSFpatches.test_recursion_limit @ linux-x86_64 +test.test_difflib.TestWithAscii.test_bjunk @ linux-x86_64 +test.test_difflib.TestWithAscii.test_one_delete @ linux-x86_64 +test.test_difflib.TestWithAscii.test_one_insert @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_distutils.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_distutils.txt new file mode 100644 index 0000000000..cc19b39312 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_distutils.txt @@ -0,0 +1,210 @@ +DocTestCase.distutils.versionpredicate.VersionPredicate @ linux-x86_64 +DocTestCase.distutils.versionpredicate.split_provision @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_check_archive_formats @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_bztar @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_cwd @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_gztar @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_owner_group @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_tar @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_archive_xztar @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball_bzip2 @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball_extended @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball_gzip @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball_latin1 @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_tarball_xz @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_zipfile @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_make_zipfile_no_zlib @ linux-x86_64 +distutils.tests.test_archive_util.ArchiveUtilTestCase.test_tarfile_vs_tar @ linux-x86_64 +distutils.tests.test_bdist.BuildTestCase.test_formats @ linux-x86_64 +distutils.tests.test_bdist.BuildTestCase.test_skip_build @ linux-x86_64 +distutils.tests.test_bdist_dumb.BuildDumbTestCase.test_simple_built @ linux-x86_64 +distutils.tests.test_build.BuildTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_build_clib.BuildCLibTestCase.test_build_libraries @ linux-x86_64 +distutils.tests.test_build_clib.BuildCLibTestCase.test_check_library_dist @ linux-x86_64 +distutils.tests.test_build_clib.BuildCLibTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_build_clib.BuildCLibTestCase.test_get_source_files @ linux-x86_64 +distutils.tests.test_build_clib.BuildCLibTestCase.test_run @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_check_extensions_list @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_compiler_option @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_ext_fullpath @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_get_outputs @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_get_source_files @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_optional_extension @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_solaris_enable_shared @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_unicode_module_names @ linux-x86_64 +distutils.tests.test_build_ext.BuildExtTestCase.test_user_site @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_check_extensions_list @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_compiler_option @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_ext_fullpath @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_get_outputs @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_get_source_files @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_optional_extension @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_solaris_enable_shared @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_unicode_module_names @ linux-x86_64 +distutils.tests.test_build_ext.ParallelBuildExtTestCase.test_user_site @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_byte_compile @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_byte_compile_optimized @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_dir_in_package_data @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_dont_write_bytecode @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_empty_package_dir @ linux-x86_64 +distutils.tests.test_build_py.BuildPyTestCase.test_package_data @ linux-x86_64 +distutils.tests.test_build_scripts.BuildScriptsTestCase.test_build @ linux-x86_64 +distutils.tests.test_build_scripts.BuildScriptsTestCase.test_default_settings @ linux-x86_64 +distutils.tests.test_build_scripts.BuildScriptsTestCase.test_version_int @ linux-x86_64 +distutils.tests.test_check.CheckTestCase.test_check_all @ linux-x86_64 +distutils.tests.test_check.CheckTestCase.test_check_metadata @ linux-x86_64 +distutils.tests.test_clean.cleanTestCase.test_simple_run @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_debug_print @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_dump_options @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_ensure_dirname @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_ensure_filename @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_ensure_string @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_ensure_string_list @ linux-x86_64 +distutils.tests.test_cmd.CommandTestCase.test_make_file @ linux-x86_64 +distutils.tests.test_config.PyPIRCCommandTestCase.test_config_interpolation @ linux-x86_64 +distutils.tests.test_config.PyPIRCCommandTestCase.test_server_empty_registration @ linux-x86_64 +distutils.tests.test_config.PyPIRCCommandTestCase.test_server_registration @ linux-x86_64 +distutils.tests.test_config_cmd.ConfigTestCase.test_clean @ linux-x86_64 +distutils.tests.test_config_cmd.ConfigTestCase.test_dump_file @ linux-x86_64 +distutils.tests.test_config_cmd.ConfigTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_config_cmd.ConfigTestCase.test_search_cpp @ linux-x86_64 +distutils.tests.test_core.CoreTestCase.test_debug_mode @ linux-x86_64 +distutils.tests.test_core.CoreTestCase.test_run_setup_defines_subclass @ linux-x86_64 +distutils.tests.test_core.CoreTestCase.test_run_setup_preserves_sys_argv @ linux-x86_64 +distutils.tests.test_core.CoreTestCase.test_run_setup_provides_file @ linux-x86_64 +distutils.tests.test_core.CoreTestCase.test_run_setup_uses_current_dir @ linux-x86_64 +distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_check_config_h @ linux-x86_64 +distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_msvcr @ linux-x86_64 +distutils.tests.test_cygwinccompiler.CygwinCCompilerTestCase.test_get_versions @ linux-x86_64 +distutils.tests.test_dep_util.DepUtilTestCase.test_newer @ linux-x86_64 +distutils.tests.test_dep_util.DepUtilTestCase.test_newer_group @ linux-x86_64 +distutils.tests.test_dep_util.DepUtilTestCase.test_newer_pairwise @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_copy_tree_exception_in_listdir @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_copy_tree_skips_nfs_temp_files @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_copy_tree_verbosity @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_create_tree_verbosity @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_ensure_relative @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_mkpath_remove_tree_verbosity @ linux-x86_64 +distutils.tests.test_dir_util.DirUtilTestCase.test_mkpath_with_custom_mode @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_announce @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_command_packages_cmdline @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_command_packages_configfile @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_command_packages_unspecified @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_empty_options @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_find_config_files_disable @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_get_command_packages @ linux-x86_64 +distutils.tests.test_dist.DistributionTestCase.test_venv_install_options @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_classifier @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_classifier_invalid_type @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_custom_pydistutils @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_download_url @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_fix_help_options @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_keywords @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_keywords_invalid_type @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_long_description @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_obsoletes @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_obsoletes_illegal @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_obsoletes_to_list @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_platforms @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_platforms_invalid_types @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_provides @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_provides_illegal @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_read_metadata @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_requires @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_requires_illegal @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_requires_to_list @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_show_help @ linux-x86_64 +distutils.tests.test_dist.MetadataTestCase.test_simple_metadata @ linux-x86_64 +distutils.tests.test_extension.ExtensionTestCase.test_extension_init @ linux-x86_64 +distutils.tests.test_extension.ExtensionTestCase.test_read_setup_file @ linux-x86_64 +distutils.tests.test_file_util.FileUtilTestCase.test_copy_file_hard_link @ linux-x86_64 +distutils.tests.test_file_util.FileUtilTestCase.test_copy_file_hard_link_failure @ linux-x86_64 +distutils.tests.test_file_util.FileUtilTestCase.test_move_file_exception_unpacking_rename @ linux-x86_64 +distutils.tests.test_file_util.FileUtilTestCase.test_move_file_exception_unpacking_unlink @ linux-x86_64 +distutils.tests.test_file_util.FileUtilTestCase.test_move_file_verbosity @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_debug_print @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_exclude_pattern @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_glob_to_re @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_include_pattern @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_process_template @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_process_template_line @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_remove_duplicates @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_set_allfiles @ linux-x86_64 +distutils.tests.test_filelist.FileListTestCase.test_translate_pattern @ linux-x86_64 +distutils.tests.test_filelist.FindAllTestCase.test_basic_discovery @ linux-x86_64 +distutils.tests.test_filelist.FindAllTestCase.test_missing_symlink @ linux-x86_64 +distutils.tests.test_filelist.FindAllTestCase.test_non_local_discovery @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_debug_mode @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_handle_extra_path @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_home_installation_scheme @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_record @ linux-x86_64 +distutils.tests.test_install.InstallTestCase.test_user_site @ linux-x86_64 +distutils.tests.test_install_data.InstallDataTestCase.test_simple_run @ linux-x86_64 +distutils.tests.test_install_headers.InstallHeadersTestCase.test_simple_run @ linux-x86_64 +distutils.tests.test_install_lib.InstallLibTestCase.test_byte_compile @ linux-x86_64 +distutils.tests.test_install_lib.InstallLibTestCase.test_dont_write_bytecode @ linux-x86_64 +distutils.tests.test_install_lib.InstallLibTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_install_lib.InstallLibTestCase.test_get_inputs @ linux-x86_64 +distutils.tests.test_install_lib.InstallLibTestCase.test_get_outputs @ linux-x86_64 +distutils.tests.test_install_scripts.InstallScriptsTestCase.test_default_settings @ linux-x86_64 +distutils.tests.test_install_scripts.InstallScriptsTestCase.test_installation @ linux-x86_64 +distutils.tests.test_log.TestLog.test_non_ascii @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_check_metadata_deprecated @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_create_pypirc @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_list_classifiers @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_password_not_in_file @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_password_reset @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_registering @ linux-x86_64 +distutils.tests.test_register.RegisterTestCase.test_show_response @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_add_defaults @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_check_metadata_deprecated @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_get_file_list @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_invalid_template_unknown_command @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_invalid_template_wrong_arguments @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_make_distribution @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_manifest_comments @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_manifest_marker @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_manual_manifest @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_metadata_check_option @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_prune_file_list @ linux-x86_64 +distutils.tests.test_sdist.SDistTestCase.test_show_formats @ linux-x86_64 +distutils.tests.test_spawn.SpawnTestCase.test_find_executable @ linux-x86_64 +distutils.tests.test_spawn.SpawnTestCase.test_spawn @ linux-x86_64 +distutils.tests.test_spawn.SpawnTestCase.test_spawn_missing_exe @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_customize_compiler_before_get_config_vars @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_get_config_h_filename @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_get_config_vars @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_get_python_lib @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_parse_makefile_base @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_parse_makefile_literal_dollar @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_srcdir_independent_of_cwd @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_sysconfig_compiler_vars @ linux-x86_64 +distutils.tests.test_sysconfig.SysconfigTestCase.test_sysconfig_module @ linux-x86_64 +distutils.tests.test_text_file.TextFileTestCase.test_class @ linux-x86_64 +distutils.tests.test_unixccompiler.UnixCCompilerTestCase.test_runtime_libdir_option @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_finalize_options @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_saved_password @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_upload @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_upload_correct_cr @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_upload_fails @ linux-x86_64 +distutils.tests.test_upload.uploadTestCase.test_wrong_exception_order @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_change_root @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_check_environ @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_check_environ_getpwuid @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_convert_path @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_dont_write_bytecode @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_get_platform @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_grok_environment_error @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_rfc822_escape @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_split_quoted @ linux-x86_64 +distutils.tests.test_util.UtilTestCase.test_strtobool @ linux-x86_64 +distutils.tests.test_version.VersionTestCase.test_cmp @ linux-x86_64 +distutils.tests.test_version.VersionTestCase.test_cmp_strict @ linux-x86_64 +distutils.tests.test_version.VersionTestCase.test_prerelease @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest.txt new file mode 100644 index 0000000000..36c97d04a7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest.txt @@ -0,0 +1,17 @@ +DocTestCase.doctest.DebugRunner @ linux-x86_64 +DocTestCase.doctest.DocTestCase.debug @ linux-x86_64 +DocTestCase.doctest.DocTestRunner @ linux-x86_64 +DocTestCase.doctest._TestClass @ linux-x86_64 +DocTestCase.doctest._TestClass.__init__ @ linux-x86_64 +DocTestCase.doctest._TestClass.get @ linux-x86_64 +DocTestCase.doctest._TestClass.square @ linux-x86_64 +DocTestCase.doctest.__test__.blank lines @ linux-x86_64 +DocTestCase.doctest.__test__.bool-int equivalence @ linux-x86_64 +DocTestCase.doctest.__test__.ellipsis @ linux-x86_64 +DocTestCase.doctest.__test__.string @ linux-x86_64 +DocTestCase.doctest.__test__.whitespace normalization @ linux-x86_64 +DocTestCase.doctest._ellipsis_match @ linux-x86_64 +DocTestCase.doctest.script_from_examples @ linux-x86_64 +DocTestCase.doctest.set_unittest_reportflags @ linux-x86_64 +test.test_doctest.TestDocTestFinder.test_empty_namespace_package @ linux-x86_64 +test.test_doctest.TestDocTestFinder.test_issue35753 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest2.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest2.txt new file mode 100644 index 0000000000..cc5fc9cb5d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_doctest2.txt @@ -0,0 +1 @@ +test.test_doctest2.Test.test_testmod @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_docxmlrpc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_docxmlrpc.txt new file mode 100644 index 0000000000..8e10b69988 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_docxmlrpc.txt @@ -0,0 +1,9 @@ +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_annotations @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_autolink_dotted_methods @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_autolinking @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_get_css @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_invalid_get_response @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_lambda @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_server_title_escape @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_system_methods @ linux-x86_64 +test.test_docxmlrpc.DocXMLRPCHTTPGETServer.test_valid_get_response @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamic.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamic.txt new file mode 100644 index 0000000000..b075cbad44 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamic.txt @@ -0,0 +1,11 @@ +test.test_dynamic.RebindBuiltinsTests.test_cannot_change_globals_or_builtins_with_eval @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_cannot_change_globals_or_builtins_with_exec @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_cannot_replace_builtins_dict_between_calls @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_cannot_replace_builtins_dict_while_active @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_eval_gives_lambda_custom_globals @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_globals_shadow_builtins @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_load_global_specialization_failure_keeps_oparg @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_modify_builtins @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_modify_builtins_from_leaf_function @ linux-x86_64 +test.test_dynamic.RebindBuiltinsTests.test_modify_builtins_while_generator_active @ linux-x86_64 +test.test_dynamic.TestTracing.test_after_specialization @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamicclassattribute.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamicclassattribute.txt new file mode 100644 index 0000000000..9532001425 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_dynamicclassattribute.txt @@ -0,0 +1,11 @@ +test.test_dynamicclassattribute.PropertySubclassTests.test_docstring_copy @ linux-x86_64 +test.test_dynamicclassattribute.PropertySubclassTests.test_property_new_getter_new_docstring @ linux-x86_64 +test.test_dynamicclassattribute.PropertySubclassTests.test_property_setter_copies_getter_docstring @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_abstract_virtual @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property___isabstractmethod__descriptor @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_decorator_baseclass @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_decorator_baseclass_doc @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_decorator_doc @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_decorator_subclass @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_decorator_subclass_doc @ linux-x86_64 +test.test_dynamicclassattribute.PropertyTests.test_property_getter_doc_override @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_email.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_email.txt new file mode 100644 index 0000000000..15505206c9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_email.txt @@ -0,0 +1,1659 @@ +test.test_email.test__encoded_words.TestDecode.test_b_case_ignored @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_b_invalid_bytes_ignored_with_defect @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_b_invalid_bytes_incorrect_padding @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_b_padding_defect @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_b_undecodable_bytes_ignored_with_defect @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_non_trivial_q @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_nonnull_lang @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_q_case_ignored @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_q_escaped_bytes_preserved @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_q_nonascii @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_simple_b @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_simple_q @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_unknown_8bit_charset @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_unknown_charset @ linux-x86_64 +test.test_email.test__encoded_words.TestDecode.test_wrong_format_input_raises @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeB.test_invalid_character @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeB.test_invalid_character_and_bad_padding @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeB.test_invalid_length @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeB.test_missing_padding @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeB.test_simple @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeQ.test_no_encoded @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeQ.test_run_of_encoded @ linux-x86_64 +test.test_email.test__encoded_words.TestDecodeQ.test_spaces @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_auto_b_if_enough_unsafe @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_auto_b_if_long_unsafe @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_auto_q @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_auto_q_if_long_mostly_safe @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_auto_q_if_short_mostly_safe @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_b @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_lang @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_q @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_unknown_8bit @ linux-x86_64 +test.test_email.test__encoded_words.TestEncode.test_utf8_default @ linux-x86_64 +test.test_email.test__encoded_words.TestEncodeB.test_padding @ linux-x86_64 +test.test_email.test__encoded_words.TestEncodeB.test_simple @ linux-x86_64 +test.test_email.test__encoded_words.TestEncodeQ.test_all_safe @ linux-x86_64 +test.test_email.test__encoded_words.TestEncodeQ.test_run_of_encodables @ linux-x86_64 +test.test_email.test__encoded_words.TestEncodeQ.test_spaces @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_address_list_folding_at_commas @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_address_list_with_unicode_names @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_address_list_with_unicode_names_in_quotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_ews_combined_before_wrap @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_long_filename_attachment @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_one_ew_on_each_of_two_wrapped_lines @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_overlong_encodeable_is_wrapped @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_simple_address @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_simple_unstructured_folded @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_simple_unstructured_no_folds @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_split_at_whitespace_after_header_before_long_token @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_split_at_whitespace_before_long_token @ linux-x86_64 +test.test_email.test__header_value_parser.TestFolding.test_unstructured_with_unicode_no_folds @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test__wsp_splitter_one_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test__wsp_splitter_two_words @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test__wsp_splitter_ws_runs @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_encoded_word_inside_quotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_dot_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_multiple_domains @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_normal @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_quoted_strings_in_atom_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_with_doamin_literal @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_addr_spec_with_qouoted_string_and_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_complex @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_empty_group @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_group @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_invalid_mailbox_invalid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_CFWS @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_group_and_mailboxes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_group_empty @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_group_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_mailboxes_complex @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_mailboxes_invalid_addresses @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_mailboxes_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_list_mailboxes_two_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_quoted_local_part @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_quoted_strings_in_atom_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_rfc2047_display_name @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_address_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_empty @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_internal_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_missing_closing_angle @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_missing_closing_angle_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_no_angle_before_special_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_no_angle_raise @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_no_angle_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_obs_route @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_qs_and_domain_literal @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_qs_only_quotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_special_after_angle_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_angle_addr_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_all_atext @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_non_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_two_words_gets_first @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atext_up_to_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_atom_ends_at_noncfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_atom_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_header_ends_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_no_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_no_atom_before_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_non_printable_in_atext @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_non_printable_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_rfc2047_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_with_comments_and_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_with_multiple_comments @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_atom_with_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_empty_quotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_end_dquote_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_missing_endquotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_multiple_words @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_multiple_words_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_must_start_with_dquote @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_no_end_dquote @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_non_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_only_quotes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_bare_quoted_string_quoted_dquote @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_ends_at_non_leader @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_ends_at_non_printable @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_header_ends_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_multiple_nested_comments @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_non_printable_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_only_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_only_mixed @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_cfws_only_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_empty_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_end_paren_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_missing_end_of_nesting @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_multiple_nesting @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_multiple_words @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_multiple_words_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_must_start_with_paren @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_nested_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_nested_comment_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_no_end_paren @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_non_printable @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_qs_in_nested_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_comment_quoted_parens @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_complex1 @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_complex2 @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_ending_with_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_for_invalid_address_field @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_pharse_must_start_with_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_display_name_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_domain_literal_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_domain_literal_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_domain_literal_with_cfws_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_domain_with_cfws_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_bad_dtext_char_before_special_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_no_start_char_before_special_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_no_start_char_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_with_internal_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_literal_with_surrounding_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_no_atom_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_no_non_cfws_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_regular_domain_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_domain_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_leading_dot_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_no_atom_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_rfc2047_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_space_ends_dot_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_lone_atom_is_valid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_raises_on_leading_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_raises_on_leading_non_atext @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_raises_on_trailing_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_trailing_text_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_text_trailing_ws_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_trailing_dot_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_two_dots_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_with_comments_and_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dot_atom_with_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_all_dtext @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_close_bracket_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_non_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_open_bracket_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_two_words_gets_first @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_up_to_close_bracket_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_up_to_open_bracket_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_with_qp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_wsp_before_close_bracket_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_dtext_wsp_before_open_bracket_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_gets_first @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_gets_first_even_if_no_space @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_internal_spaces @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_invalid_cte @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_lang_default_is_blank @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_leading_internal_space @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_missing_end_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_missing_middle_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_missing_start_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_non_printable_defect @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_quopri_utf_escape_follows_cte @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_sets_extra_attributes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_encoded_word_valid_ew @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_fws_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_fws_space @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_fws_ws_run @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_cfws_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_empty @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_list_cfws_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_list_comment_only_invalid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_list_mailbox_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_list_obs_group_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_missing_final_semicol @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_mixed_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_null_addr_spec @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_one_invalid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_group_single_mailbox @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_complex_obsolete_1 @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_complex_obsolete_invalid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_double_dot_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_leading_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_leading_dot_after_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_no_part_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_quoted_strings_in_atom_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_quoted_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_quoted_with_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_simple_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_simple_quoted @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_special_instead_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_trailing_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_trailing_dot_with_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_unicode_defect @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_valid_and_invalid_qp_in_atom_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_with_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_with_quoted_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_local_part_with_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_addr_spec_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_angle_addr_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_empty_list_element @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_junk_after_valid_address @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_only_empty_elements @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_single_addr @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_two_complex @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_two_name_addr @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_two_simple_addr @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_list_unparseable_mailbox_null @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_name_addr @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_mailbox_quoted_strings_in_atom_list @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_empty @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_invalid_expected_msg_id_not_found @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_no_angle_end @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_no_angle_start @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_no_id_right_part @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_non_folding_literal_domain @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_obsolete_domain_part @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_obsolete_local @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_msg_id_valid @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_angle_addr_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_atom_name @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_atom_name_with_cfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_ends_at_special @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_name_with_cfws_and_dots @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_no_angle_after_display_name_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_no_content_before_special_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_no_content_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_qs_name @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_name_addr_with_route @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_obs_route_complex @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_obs_route_no_route_before_end_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_obs_route_no_route_before_special_raises @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_obs_route_no_route_before_special_raises2 @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_obs_route_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_phrase_complex @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_phrase_ending_with_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_phrase_obsolete @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_phrase_pharse_must_start_with_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_phrase_simple @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_all_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_close_paren_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_non_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_two_words_gets_first @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_up_to_dquote_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qcontent_wsp_before_close_paren_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_all_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_close_paren_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_following_wsp_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_non_printables @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_open_paren_mid_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_two_words_gets_first @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_up_to_close_paren_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_up_to_open_paren_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_wsp_before_close_paren_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_qp_ctext_wsp_before_open_paren_preserved @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_header_ends_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_header_ends_in_qcontent @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_internal_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_no_quoted_string @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_non_printable_in_comment @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_non_printable_in_qcontent @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_only @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_qs_ends_at_noncfws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_with_comments_and_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_with_multiple_comments @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_quoted_string_with_wsp @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_ew_with_internal_leading_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_ew_with_internal_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_ew_without_leading_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_ew_without_trailing_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_base64_character @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_base64_character_and_bad_padding @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_base64_length @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_ew @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_ew2 @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_invalid_ew_cte @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_leading_and_trailing_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_leading_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_missing_base64_padding @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_no_whitespace_between_ews @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_normal_phrase @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_normal_phrase_with_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_null @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_one_ew_trailing_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_one_valid_ew_no_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_one_valid_ew_trailing_text @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_one_word @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_phrase_with_ew_in_middle_of_text @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_phrase_with_ew_with_leading_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_phrase_with_two_ew @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_phrase_with_two_ew_extra_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_phrase_with_two_ew_trailing_ws @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_trailing_whitespace @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_two_ew_extra_ws_trailing_text @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_undecodable_bytes @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_undecodable_bytes_in_EW @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_unstructured_without_trailing_whitespace_hang_case @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_word_all_CFWS @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_word_atom_yields_atom @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_word_ends_at_dot @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_get_word_qs_yields_qs @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_invalid_content_disposition @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_invalid_content_transfer_encoding @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_parse_invalid_message_id @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_parse_message_id_with_remaining @ linux-x86_64 +test.test_email.test__header_value_parser.TestParser.test_parse_valid_message_id @ linux-x86_64 +test.test_email.test__header_value_parser.TestTokens.test_EWWhiteSpaceTerminal @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_and_missing_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_in_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_key @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_key_with_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_key_with_split_value_other_order @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_duplicate_with_broken_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_extra_dquote @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_missing_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_multiple_keys @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_simple @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_parameters.test_value_split_value @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_version.test_value_RFC_2045_2 @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_version.test_value_RFC_2045_3 @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_version.test_value_RFC_2045_4 @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_version.test_value_empty @ linux-x86_64 +test.test_email.test__header_value_parser.Test_parse_mime_version.test_value_rfc_2045_1 @ linux-x86_64 +test.test_email.test_asian_codecs.TestEmailAsianCodecs.test_japanese_codecs @ linux-x86_64 +test.test_email.test_asian_codecs.TestEmailAsianCodecs.test_payload_encoding @ linux-x86_64 +test.test_email.test_asian_codecs.TestEmailAsianCodecs.test_payload_encoding_utf8 @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_full_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_maintype_only @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_null_key @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_order_full_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_order_maintype_only @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_key_order_null_key @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_get_content_raises_if_unknown_mimetype_and_no_default @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_calls_clear_content @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_base_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_base_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_base_qualname @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_base_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_null_key @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_base_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_base_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_base_qualname @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_base_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_null_key @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_qualname @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_str_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_str_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_str_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_order_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_qualname @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_str_full_path @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_str_name @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_str_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_key_type @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_raises_if_called_on_multipart @ linux-x86_64 +test.test_email.test_contentmanager.TestContentManager.test_set_content_raises_if_unknown_type_and_no_default @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_application_octet_stream @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_image_jpeg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_message_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_message_rfc822 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_cid_receiver_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_application_octet_stream @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_image_jpeg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_message_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_message_rfc822 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_disposition_inline_receiver_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_message_non_rfc822_or_external_body_yields_bytes @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_message_rfc822_and_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_non_text @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_non_text_invalid_keyword @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_raises_on_multipart @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_invalid_keyword @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_bad_utf8_quoted_printable @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_bad_utf8_quoted_printable_ignore_errors @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_latin1 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_latin1_quoted_printable @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_utf8_base64 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_get_text_plain_utf8_base64_recoverable_bad_CTE_data @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_application_octet_stream @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_image_jpeg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_message_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_message_rfc822 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_header_receiver_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_application_octet_stream @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_image_jpeg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_message_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_message_rfc822 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_non_ascii_filename_receiver_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_application_octet_stream @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_image_jpeg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_message_external_body @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_message_rfc822 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_params_receiver_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_application_octet_stream_with_8bit_cte @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_content_bytes_cte_7bit @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_disposition_attachment @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_disposition_foo @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_disposition_inline @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_filename @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_filename_and_disposition_inline @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_from_header_objects @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_from_strings @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_with_defective_header_header_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_with_defective_string_header_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_with_invalid_duplicate_header_header_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_headers_with_invalid_duplicate_string_header_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_image_jpg @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_message @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_message_invalid_cte_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_message_with_non_ascii_and_coercion_to_7bit @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_non_ascii_filename @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_11_lines_long_line_maximal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_11_lines_long_line_minimal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_11_lines_maximal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_charset_latin_1 @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_html @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_long_line_maximal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_long_line_minimal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_maximal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_non_ascii_with_charset_ascii_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_non_ascii_with_cte_7bit_and_charset_ascii_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_non_ascii_with_cte_7bit_raises @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_plain @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_plain_long_line_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_plain_null @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_text_short_line_minimal_non_ascii_heuristics @ linux-x86_64 +test.test_email.test_contentmanager.TestRawDataManager.test_set_video_mpeg_with_binary_cte @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_bad_padding_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_first_line_is_continuation_header @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_invalid_chars_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_invalid_length_of_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_lying_multipart @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_missing_ending_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_missing_header_body_separator @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_missing_start_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_multipart_invalid_cte @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_multipart_no_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_multipart_no_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_multipart_valid_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectCapture.test_same_boundary_inner_outer @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_bad_padding_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_first_line_is_continuation_header @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_invalid_chars_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_invalid_length_of_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_lying_multipart @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_missing_ending_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_missing_header_body_separator @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_missing_start_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_multipart_invalid_cte @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_multipart_no_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_multipart_no_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_multipart_valid_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectDetection.test_same_boundary_inner_outer @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_bad_padding_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_first_line_is_continuation_header @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_invalid_chars_in_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_invalid_length_of_base64_payload @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_lying_multipart @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_missing_header_body_separator @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_missing_start_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_multipart_invalid_cte @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_multipart_no_boundary @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_multipart_no_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_multipart_valid_cte_no_defect @ linux-x86_64 +test.test_email.test_defect_handling.TestDefectRaising.test_same_boundary_inner_outer @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_8bit_in_base64_body @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_8bit_in_quopri_body @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_8bit_in_uuencode_body @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_8bit_multipart @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_bytes_feedparser @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_bytes_generator @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_bytes_generator_b_encoding_linesep @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_bytes_generator_handles_None_body @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_bytes_generator_with_unix_from @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_crlf_flatten @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_decoded_generator_emits_unicode_body @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_del_rfc2231_params_with_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_generator_b_encoding_linesep @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_generator_handles_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_8bit_header @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_all_with_8bit_headers @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_content_type_with_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_params_with_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_payload_with_8bit_cte_header @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_get_rfc2231_params_with_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_invalid_8bit_in_non_8bit_cte_uses_replace @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_items_with_8bit_headers @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_known_8bit_CTE @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_message_from_binary_file @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_print_8bit_headers @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_set_rfc2231_params_with_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_str_generator_should_not_mutate_msg_when_handling_8bit @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_string_generator_reencodes_to_quopri_when_appropriate @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_unknown_8bit_CTE @ linux-x86_64 +test.test_email.test_email.Test8BitBytesHandling.test_values_with_8bit_headers @ linux-x86_64 +test.test_email.test_email.TestBase64.test_decode @ linux-x86_64 +test.test_email.test_email.TestBase64.test_encode @ linux-x86_64 +test.test_email.test_email.TestBase64.test_header_encode @ linux-x86_64 +test.test_email.test_email.TestBase64.test_len @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_MIME_digest @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_MIME_digest_with_part_headers @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_content_type @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_dsn @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_long_header @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_message_delivery_status @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_message_external_body_idempotent @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_message_signed_idempotent @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_mixed_with_image @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_more_rfc2231_parameters @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_multipart_no_parts @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_multipart_one_part @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_multipart_report @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_nested_multipart_mixeds @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_no_start_boundary @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_parse_text_message @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_parse_untyped_message @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_parser @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_preamble_epilogue @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_rfc2231_charset @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_simple_multipart @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentCRLF.test_text_plain_in_a_multipart_digest @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_MIME_digest @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_MIME_digest_with_part_headers @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_content_type @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_dsn @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_long_header @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_message_delivery_status @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_message_external_body_idempotent @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_message_signed_idempotent @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_mixed_with_image @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_more_rfc2231_parameters @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_multipart_no_parts @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_multipart_one_part @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_multipart_report @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_nested_multipart_mixeds @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_no_start_boundary @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_parse_text_message @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_parse_untyped_message @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_parser @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_preamble_epilogue @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_rfc2231_charset @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_simple_multipart @ linux-x86_64 +test.test_email.test_email.TestBytesGeneratorIdempotentNL.test_text_plain_in_a_multipart_digest @ linux-x86_64 +test.test_email.test_email.TestCharset.test_body_encode @ linux-x86_64 +test.test_email.test_email.TestCharset.test_codec_encodeable @ linux-x86_64 +test.test_email.test_email.TestCharset.test_unicode_charset_name @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_EncodersEncode_base64 @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_default_cte @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_encode7or8bit @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_encode_empty_payload @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_qp_encode_latin1 @ linux-x86_64 +test.test_email.test_email.TestEncoders.test_qp_encode_non_latin1 @ linux-x86_64 +test.test_email.test_email.TestFeedParsers.test_empty_header_name_handled @ linux-x86_64 +test.test_email.test_email.TestFeedParsers.test_long_lines @ linux-x86_64 +test.test_email.test_email.TestFeedParsers.test_newlines @ linux-x86_64 +test.test_email.test_email.TestFromMangling.test_dont_mangle_from @ linux-x86_64 +test.test_email.test_email.TestFromMangling.test_mangle_from_in_preamble_and_epilog @ linux-x86_64 +test.test_email.test_email.TestFromMangling.test_mangled_from @ linux-x86_64 +test.test_email.test_email.TestFromMangling.test_mangled_from_with_bad_bytes @ linux-x86_64 +test.test_email.test_email.TestFromMangling.test_multipart_with_bad_bytes_in_cte @ linux-x86_64 +test.test_email.test_email.TestHeader.test_bad_8bit_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_base64_splittable @ linux-x86_64 +test.test_email.test_email.TestHeader.test_broken_base64_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_empty_header_encode @ linux-x86_64 +test.test_email.test_email.TestHeader.test_encode_preserves_leading_ws_on_value @ linux-x86_64 +test.test_email.test_email.TestHeader.test_encoded_adjacent_nonencoded @ linux-x86_64 +test.test_email.test_email.TestHeader.test_escaped_8bit_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_explicit_maxlinelen @ linux-x86_64 +test.test_email.test_email.TestHeader.test_flatten_header_with_no_value @ linux-x86_64 +test.test_email.test_email.TestHeader.test_header_ctor_default_args @ linux-x86_64 +test.test_email.test_email.TestHeader.test_header_handles_binary_unknown8bit @ linux-x86_64 +test.test_email.test_email.TestHeader.test_header_needs_no_decoding @ linux-x86_64 +test.test_email.test_email.TestHeader.test_long @ linux-x86_64 +test.test_email.test_email.TestHeader.test_make_header_handles_binary_unknown8bit @ linux-x86_64 +test.test_email.test_email.TestHeader.test_modify_returned_list_does_not_change_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_multilingual @ linux-x86_64 +test.test_email.test_email.TestHeader.test_quopri_splittable @ linux-x86_64 +test.test_email.test_email.TestHeader.test_shift_jis_charset @ linux-x86_64 +test.test_email.test_email.TestHeader.test_simple @ linux-x86_64 +test.test_email.test_email.TestHeader.test_simple_surprise @ linux-x86_64 +test.test_email.test_email.TestHeader.test_string_charset @ linux-x86_64 +test.test_email.test_email.TestHeader.test_us_ascii_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_utf8_shortest @ linux-x86_64 +test.test_email.test_email.TestHeader.test_whitespace_header @ linux-x86_64 +test.test_email.test_email.TestHeader.test_whitespace_keeper @ linux-x86_64 +test.test_email.test_email.TestHeaderRegistry.test_HeaderRegistry @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_MIME_digest @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_MIME_digest_with_part_headers @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_content_type @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_dsn @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_long_header @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_message_delivery_status @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_message_external_body_idempotent @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_message_signed_idempotent @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_mixed_with_image @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_more_rfc2231_parameters @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_multipart_no_parts @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_multipart_one_part @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_multipart_report @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_nested_multipart_mixeds @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_no_start_boundary @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_parse_text_message @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_parse_untyped_message @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_parser @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_preamble_epilogue @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_rfc2231_charset @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_simple_multipart @ linux-x86_64 +test.test_email.test_email.TestIdempotent.test_text_plain_in_a_multipart_digest @ linux-x86_64 +test.test_email.test_email.TestIterators.test_body_line_iterator @ linux-x86_64 +test.test_email.test_email.TestIterators.test_pushCR_LF @ linux-x86_64 +test.test_email.test_email.TestIterators.test_push_random @ linux-x86_64 +test.test_email.test_email.TestIterators.test_typed_subpart_iterator @ linux-x86_64 +test.test_email.test_email.TestIterators.test_typed_subpart_iterator_default_type @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_another_long_almost_unsplittable_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_another_long_multiline_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_header_encode_with_different_output_charset @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_header_splitter @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_last_split_chunk_does_not_fit @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_leading_splittable_in_the_middle_just_before_overlong_last_part @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_8bit_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_8bit_header_no_charset @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_field_name @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_encode @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_encode_with_different_output_charset @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_encode_with_tab_continuation @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_encode_with_tab_continuation_is_just_a_hint @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_with_multiple_sequential_split_chars @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_header_with_whitespace_runs @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_line_after_append @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_lines_with_different_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_nonstring @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_received_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_rfc2047_header_with_embedded_fws @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_run_with_semi_header_splitter @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_to_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_long_unbreakable_lines_with_continuation @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_multiline_with_overlong_last_part_followed_by_split_point @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_multiline_with_overlong_parts_separated_by_two_split_points @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_multiple_splittable_leading_char_followed_by_overlong_unsplittable @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_no_semis_header_splitter @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_no_split_long_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_overlong_last_part_followed_by_split_point @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_shorter_line_with_append @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_split_long_continuation @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_splittable_leading_char_followed_by_overlong_unsplittable @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_splitter_split_on_punctuation_only_if_fws @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_splitter_split_on_punctuation_only_if_fws_with_header @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_splitting_first_line_only_is_long @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_splitting_multiple_long_lines @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_string_headerinst_eq @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_trailing_splittable_on_overlong_unsplittable @ linux-x86_64 +test.test_email.test_email.TestLongHeaders.test_trailing_splittable_on_overlong_unsplittable_with_leading_splittable @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_binary_body_with_encode_7or8bit @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_binary_body_with_encode_base64 @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_binary_body_with_encode_noop @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_binary_body_with_encode_quopri @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_binary_body_with_unicode_linend_encode_noop @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_body @ linux-x86_64 +test.test_email.test_email.TestMIMEApplication.test_headers @ linux-x86_64 +test.test_email.test_email.TestMIMEAudio.test_add_header @ linux-x86_64 +test.test_email.test_email.TestMIMEAudio.test_checkSetMinor @ linux-x86_64 +test.test_email.test_email.TestMIMEAudio.test_encoding @ linux-x86_64 +test.test_email.test_email.TestMIMEAudio.test_guess_minor_type @ linux-x86_64 +test.test_email.test_email.TestMIMEImage.test_add_header @ linux-x86_64 +test.test_email.test_email.TestMIMEImage.test_checkSetMinor @ linux-x86_64 +test.test_email.test_email.TestMIMEImage.test_encoding @ linux-x86_64 +test.test_email.test_email.TestMIMEImage.test_guess_minor_type @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_bad_multipart @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_default_multipart_constructor @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_default_type @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_default_type_non_parsed @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_default_type_with_explicit_container_type @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_dsn @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_epilogue @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_generate @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_mime_attachments_in_constructor @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_multipart_custom_policy @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_multipart_default_policy @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_no_nl_preamble @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_parse_message_rfc822 @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_type_error @ linux-x86_64 +test.test_email.test_email.TestMIMEMessage.test_valid_argument @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_7bit_input @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_7bit_input_no_charset @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_charset @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_payload @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_types @ linux-x86_64 +test.test_email.test_email.TestMIMEText.test_utf8_input @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test__contains__ @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_add_header_with_name_only_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_add_header_with_no_value @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_as_bytes @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_as_bytes_policy @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_as_string @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_as_string_policy @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_ascii_add_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_ascii_add_header_with_tspecial @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_attach_when_payload_is_string @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_bad_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_binary_base64_payload @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_binary_quopri_payload @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_bogus_filename @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_broken_unicode_payload @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_byte_message_rfc822_only @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_decoded_generator @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_del_nonexistent_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_del_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_del_param_on_nonexistent_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_del_param_on_other_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_embedded_header_via_Header_rejected @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_embedded_header_via_string_rejected @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_field_containment @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_all @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_boundary @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_charsets @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_disposition @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_error @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_from_message_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_from_message_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_from_message_text_plain_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_from_message_text_plain_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_missing @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_maintype_missing_with_default_type @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_error @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_from_message_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_from_message_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_from_message_text_plain_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_from_message_text_plain_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_missing @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_subtype_missing_with_default_type @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_from_message_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_from_message_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_from_message_text_plain_explicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_from_message_text_plain_implicit @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_missing @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_content_type_missing_with_default_type @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_decoded_payload @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_filename @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_filename_with_name_parameter @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_param_funky_continuation_lines @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_param_liberal @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_param_with_quotes @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_param_with_semis_in_quotes @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_params @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_get_payload_n_raises_on_non_multipart @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_getset_charset @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_make_boundary @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_message_rfc822_only @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_missing_boundary @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_missing_filename @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_noascii_add_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_nonascii_add_header_via_triple @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_nonascii_add_header_with_tspecial @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_nonascii_as_string_without_content_type_and_cte @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_nonascii_as_string_without_cte @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_questionable_bytes_payload @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_replace_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_boundary @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_charset_from_string @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_param @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_payload_to_list @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_payload_with_8bit_data_and_charset @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_payload_with_8bit_data_and_charset_body_encoding_none @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_payload_with_charset @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_payload_with_non_ascii_and_charset_body_encoding_none @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_type @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_set_type_on_other_header @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_unicode_body_defaults_to_utf8_encoding @ linux-x86_64 +test.test_email.test_email.TestMessageAPI.test_unicode_header_defaults_to_utf8_encoding @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_BytesGenerator_linend @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_BytesGenerator_linend_with_non_ascii @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_Generator_linend @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test__all__ @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_accepts_any_charset_like_object @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_charset_richcomparisons @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_charsets_case_insensitive @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_custom_message_does_not_require_arguments @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_escape_backslashes @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_escape_dump @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_formataddr_does_not_quote_parens_in_quoted_string @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_formatdate @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_formatdate_localtime @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_formatdate_usegmt @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_get_body_encoding_with_bogus_charset @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_get_body_encoding_with_uppercase_charset @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_getaddresses @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_getaddresses_embedded_comment @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_getaddresses_header_obj @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_getaddresses_nasty @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_invalid_charset_like_object_raises_error @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_make_msgid_collisions @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_make_msgid_default_domain @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_make_msgid_domain @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_make_msgid_idstring @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_message_from_file @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_message_from_file_with_class @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_message_from_string @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_message_from_string_with_class @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_mime_classes_policy_argument @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_mktime_tz @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_multiline_from_comment @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_name_with_dot @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_noquote_dump @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parseaddr_empty @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parseaddr_multiple_domains @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parseaddr_preserves_quoted_pairs_in_addresses @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parseaddr_preserves_spaces_in_local_part @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_acceptable_to_time_functions @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_accepts_time_with_dots @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_compact @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_dot_time_delimiter @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_no_dayofweek @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_no_seconds @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_no_space_before_negative_offset @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_no_space_before_positive_offset @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_returns_None_for_invalid_strings @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_rfc_850 @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_parsedate_y2k @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_partial_falls_inside_message_delivery_status @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_quote_dump @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_quotes_unicode_names @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_unicode_address_raises_error @ linux-x86_64 +test.test_email.test_email.TestMiscellaneous.test_utils_quote_unquote @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_boundary_in_non_multipart @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_boundary_with_leading_space @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_boundary_without_trailing_newline @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_double_boundary @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_empty_multipart_idempotent @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_hierarchy @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_message_external_body @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_mimebase_custom_policy @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_mimebase_default_policy @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_nested_inner_contains_outer_boundary @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_nested_with_same_boundary @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_no_parts_in_a_multipart_with_empty_epilogue @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_no_parts_in_a_multipart_with_none_epilogue @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_one_part_in_a_multipart @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_seq_parts_in_a_multipart_with_empty_epilogue @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_seq_parts_in_a_multipart_with_empty_preamble @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_seq_parts_in_a_multipart_with_nl_epilogue @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_seq_parts_in_a_multipart_with_none_epilogue @ linux-x86_64 +test.test_email.test_email.TestMultipart.test_seq_parts_in_a_multipart_with_none_preamble @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_first_line_is_continuation_header @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_invalid_content_type @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_lying_multipart @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_missing_header_body_separator @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_missing_start_boundary @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_multipart_invalid_cte @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_multipart_no_boundary @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_multipart_no_cte_no_defect @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_multipart_valid_cte_no_defect @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_no_separating_blank_line @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_no_start_boundary @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_parse_missing_minor_type @ linux-x86_64 +test.test_email.test_email.TestNonConformant.test_same_boundary_inner_outer @ linux-x86_64 +test.test_email.test_email.TestNonMultipart.test_attach_raises_exception @ linux-x86_64 +test.test_email.test_email.TestNonMultipart.test_nonmultipart_is_not_multipart @ linux-x86_64 +test.test_email.test_email.TestParsers.test_CRLFLF_at_end_of_part @ linux-x86_64 +test.test_email.test_email.TestParsers.test_bytes_header_parser @ linux-x86_64 +test.test_email.test_email.TestParsers.test_bytes_parser_does_not_close_file @ linux-x86_64 +test.test_email.test_email.TestParsers.test_bytes_parser_on_exception_does_not_close_file @ linux-x86_64 +test.test_email.test_email.TestParsers.test_crlf_flatten @ linux-x86_64 +test.test_email.test_email.TestParsers.test_crlf_separation @ linux-x86_64 +test.test_email.test_email.TestParsers.test_header_parser @ linux-x86_64 +test.test_email.test_email.TestParsers.test_header_parser_multipart_is_valid @ linux-x86_64 +test.test_email.test_email.TestParsers.test_multipart_digest_with_extra_mime_headers @ linux-x86_64 +test.test_email.test_email.TestParsers.test_parser_does_not_close_file @ linux-x86_64 +test.test_email.test_email.TestParsers.test_parser_on_exception_does_not_close_file @ linux-x86_64 +test.test_email.test_email.TestParsers.test_rfc2822_header_syntax @ linux-x86_64 +test.test_email.test_email.TestParsers.test_rfc2822_one_character_header @ linux-x86_64 +test.test_email.test_email.TestParsers.test_rfc2822_space_not_allowed_in_header @ linux-x86_64 +test.test_email.test_email.TestParsers.test_strip_line_feed_and_carriage_return_in_headers @ linux-x86_64 +test.test_email.test_email.TestParsers.test_three_lines @ linux-x86_64 +test.test_email.test_email.TestParsers.test_whitespace_continuation @ linux-x86_64 +test.test_email.test_email.TestParsers.test_whitespace_continuation_last_header @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_body_quopri_len @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_false_quoting @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_lowercase_quoting @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_multiple_spaces @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_null_line_null_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_null_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_cr @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_crnl @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_lf @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_nl @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_one_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_one_word_eol @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_line_trailing_spaces @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_long_line @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_space @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_one_word_eol @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_quoted_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_soft_line_break @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_two_lines @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_two_lines_eol @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_two_lines_trailing_spaces @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_decode_uppercase_quoting @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_maxlinelen_too_small @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_null @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_null_lines @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_crlf @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_eol @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_eol_after_non_ascii @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_one_space @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_trailing_spaces @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_line_trailing_tab @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_long_line @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_long_string @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_space @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_very_long_line @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_word_trailing_spaces @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_one_word_trailing_tab @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_quoted_equals @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_shortest_maxlinelen @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_trailing_space_at_maxlinelen @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_trailing_space_before_maxlinelen @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_trailing_space_beyond_maxlinelen @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_two_lines_one_space @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_encode_whitespace_lines @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_decode_non_ascii @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_decode_null @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_decode_one_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_decode_re_bug_18380 @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_decode_two_lines @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_encode_alt_charset @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_encode_non_ascii @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_encode_null @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_encode_one_word @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_encode_two_lines @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_header_quopri_len @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_quopri_body_check @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_quopri_header_check @ linux-x86_64 +test.test_email.test_email.TestQuopri.test_quote_unquote_idempotent @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_multiline_header @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_B_bad_padding @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_Q_invalid_digits @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_missing_whitespace @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_multiline @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_1 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_2 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_3 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_4 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_5a @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_5b @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_6 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_rfc2047_7 @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_rfc2047_with_whitespace @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_whitespace_keeper_unicode @ linux-x86_64 +test.test_email.test_email.TestRFC2047.test_whitespace_keeper_unicode_2 @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_del_param @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_get_param @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_bad_character_in_charset @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_bad_character_in_encoding @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_bad_character_in_filename @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_bad_encoding_in_charset @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_bad_encoding_in_filename @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_encoded_then_unencoded_segments @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_get_content_charset @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_missing_tick @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_missing_tick_with_encoded_non_ascii @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_extended_values @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_language_or_charset @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_language_or_charset_in_boundary @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_language_or_charset_in_charset @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_language_or_charset_in_filename @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_no_language_or_charset_in_filename_encoded @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_parse_extra_quoting @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_parse_rfc_quoting @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_partly_encoded @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_partly_nonencoded @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_single_tick_in_filename @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_single_tick_in_filename_extended @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_tick_attack @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_tick_attack_extended @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_unencoded_then_encoded_segments @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_rfc2231_unknown_encoding @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_set_param @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_set_param_requote @ linux-x86_64 +test.test_email.test_email.TestRFC2231.test_should_not_hang_on_invalid_ew_messages @ linux-x86_64 +test.test_email.test_email.TestSigned.test_long_headers_as_string @ linux-x86_64 +test.test_email.test_email.TestSigned.test_long_headers_as_string_maxheaderlen @ linux-x86_64 +test.test_email.test_email.TestSigned.test_long_headers_flatten @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_compat32_max_line_length_does_not_fold_when_none @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_crlf_control_via_policy @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_cte_type_7bit_handles_unknown_8bit @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_cte_type_7bit_transforms_8bit_cte @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_flatten_linesep_overrides_policy @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_policy_0 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_policy_100 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_policy_20 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_policy_40 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_all_folds_0 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_all_folds_100 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_all_folds_20 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_all_folds_40 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_none_does_not_fold_0 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_none_does_not_fold_100 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_none_does_not_fold_20 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_max_line_length_with_refold_none_does_not_fold_40 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parameter_0 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parameter_100 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parameter_20 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parameter_40 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parm_overrides_policy_0 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parm_overrides_policy_100 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parm_overrides_policy_20 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_maxheaderlen_parm_overrides_policy_40 @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_rfc2231_wrapping @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_rfc2231_wrapping_switches_to_default_len_if_too_narrow @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_set_mangle_from_via_policy @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_smtp_policy @ linux-x86_64 +test.test_email.test_generator.TestBytesGenerator.test_smtputf8_policy @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_compat32_max_line_length_does_not_fold_when_none @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_crlf_control_via_policy @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_flatten_linesep_overrides_policy @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_policy_0 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_policy_100 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_policy_20 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_policy_40 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_all_folds_0 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_all_folds_100 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_all_folds_20 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_all_folds_40 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_none_does_not_fold_0 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_none_does_not_fold_100 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_none_does_not_fold_20 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_max_line_length_with_refold_none_does_not_fold_40 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parameter_0 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parameter_100 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parameter_20 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parameter_40 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parm_overrides_policy_0 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parm_overrides_policy_100 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parm_overrides_policy_20 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_maxheaderlen_parm_overrides_policy_40 @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_rfc2231_wrapping @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_rfc2231_wrapping_switches_to_default_len_if_too_narrow @ linux-x86_64 +test.test_email.test_generator.TestGenerator.test_set_mangle_from_via_policy @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_addr_spec_and_domain_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_addr_spec_and_username_and_domain_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_addr_spec_and_username_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_comparison @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_display_name_ro @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_domain_ro @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_from_addr_spec @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_from_username_domain @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_username_ro @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_address_with_no_display_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_bad_addr_sepc_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_crlf_in_constructor_args_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_display_name_blanks_not_quoted @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_display_name_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_display_name_quoting @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_domain_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_empty_group @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_empty_group_list @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_addresses_ro @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_comparison @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_display_name_ro @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_with_addresses @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_with_addresses_no_display_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_group_with_one_address_no_display_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_il8n @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_non_ascii_username_in_addr_spec_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_null_address @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_null_group @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_quoting @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_set_message_header_from_address @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_set_message_header_from_group @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_space_in_addr_spec_username_raises @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressAndGroup.test_username_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_address_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_empty @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_escaped_escapes_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_escaped_quoted_strings_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_name_and_address @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_name_with_dot @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_quoted_backslashes_in_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_quoted_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_quoted_parens_in_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_quoted_strings_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_rfc2047_atom_in_phrase_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_rfc2047_atom_in_quoted_string_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_rfc2047_atom_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_spaces_around_dots_in_local_part_removed @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_address_spaces_in_unquoted_local_part_collapsed @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_addresses_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_addresses_types @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_complex_address_list @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_address_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_empty @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_escaped_escapes_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_escaped_quoted_strings_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_name_and_address @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_name_with_dot @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_quoted_backslashes_in_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_quoted_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_quoted_parens_in_name @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_quoted_strings_in_local_part @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_rfc2047_atom_in_phrase_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_rfc2047_atom_in_quoted_string_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_rfc2047_atom_is_decoded @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_spaces_around_dots_in_local_part_removed @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_group_spaces_in_unquoted_local_part_collapsed @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_groups_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_groups_types @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_set_from_Address @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_set_from_Address_and_Group_list @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_set_from_Address_list @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_set_from_Group_list @ linux-x86_64 +test.test_email.test_headerregistry.TestAddressHeader.test_simple_address_list @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_defects_is_tuple @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_defects_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_has_name @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_name_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_str @ linux-x86_64 +test.test_email.test_headerregistry.TestBaseHeaderFeatures.test_substr @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_RFC_2183_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_RFC_2183_2 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_invalid_parameter_value_with_fws_between_ew @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_invalid_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_invalid_value_with_params @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_no_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentDisposition.test_value_parameter_value_with_fws_between_tokens @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTransferEncoding.test_value_RFC_2183_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTransferEncoding.test_value_junk_after_cte @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTransferEncoding.test_value_no_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_RFC_2045_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_RFC_2045_2 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_RFC_2045_3 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_bad_params @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_capitalized_charset @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_capitalized_charset_param_name_and_comment @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_cfws_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_charset_param @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_double_quotes_inside_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_junk_text_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_lots_of_mime_params @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_mixed_case_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_no_slash_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_no_subtype_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_non_ascii_in_params @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_non_ascii_rfc2231_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_param_value_with_tspecials @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_param_with_extra_quoted_whitespace @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_quotes_inside_rfc2231_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_bad_character_in_charset_parameter_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_encoded_charset @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_encoded_no_charset @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_encoded_no_double_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_encoded_then_unencoded_segments @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_encoded_with_double_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_folded_segments_correctly_formatted @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_no_language_or_charset @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_nonascii_in_charset_of_charset_parameter_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_partly_encoded @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_partly_encoded_2 @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_quoted_unencoded_then_encoded_segments @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_segmented_normal_values @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_single_quote_in_non_encoded_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_single_quote_in_value_with_charset_and_lang @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_single_quote_inside_double_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_unencoded_then_encoded_segments @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_unknown_charset_treated_as_ascii @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_rfc2231_utf8_in_supposedly_ascii_charset_parameter_value @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_semis_inside_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_single_quotes_inside_quotes @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_spaces_around_param_equals @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_spaces_around_semis @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_spaces_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_too_many_slashes_in_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_unknown_charset @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_unknown_content_type @ linux-x86_64 +test.test_email.test_headerregistry.TestContentTypeHeader.test_value_unquoted_param_value @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_date_header_properties @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_datetime_read_only @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_invalid_date_format @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_invalid_date_value @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_no_value_is_defect @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_parse_date @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_resent_date_header_properties @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_set_date_header_from_datetime @ linux-x86_64 +test.test_email.test_headerregistry.TestDateHeader.test_set_from_datetime @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_address_display_names @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_address_list @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_date_header @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_overlong_words_using_RFC2047 @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_short @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_single_word @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_with_commas @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_with_overlong_word @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_with_slightly_long_word @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_fold_unstructured_with_two_overlong_words @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_long_unstructured @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_message_id_header_is_not_folded @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_short_unstructured @ linux-x86_64 +test.test_email.test_headerregistry.TestFolding.test_unstructured_short_max_line_length @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_arbitrary_name_unstructured @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_dont_use_default_map @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_map_to_type @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_name_case_ignored @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_override_default_base_class @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_override_default_class @ linux-x86_64 +test.test_email.test_headerregistry.TestHeaderRegistry.test_override_default_class_only_overrides_default @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_1_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_2_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_2_x @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_RFC_2045_1 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_RFC_2045_2 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_RFC_2045_3 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_RFC_2045_4 @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_foo @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_leading_trailing_whitespace_ignored @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_missing @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_non_comment_garbage_after @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_non_comment_garbage_before @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_non_comment_garbage_inside @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_two_periods @ linux-x86_64 +test.test_email.test_headerregistry.TestMIMEVersionHeader.test_MIME_Version_whitespace @ linux-x86_64 +test.test_email.test_headerregistry.TestUnstructuredHeader.test_value_rfc2047_gb2312_base64 @ linux-x86_64 +test.test_email.test_headerregistry.TestUnstructuredHeader.test_value_rfc2047_quopri_with_regular_text @ linux-x86_64 +test.test_email.test_headerregistry.TestUnstructuredHeader.test_value_rfc2047_simple_nonascii_quopri @ linux-x86_64 +test.test_email.test_headerregistry.TestUnstructuredHeader.test_value_rfc2047_simple_quopri @ linux-x86_64 +test.test_email.test_inversion.TestInversion.test_body_base64_text @ linux-x86_64 +test.test_email.test_inversion.TestInversion.test_body_plain_text @ linux-x86_64 +test.test_email.test_inversion.TestInversion.test_body_qp_text @ linux-x86_64 +test.test_email.test_inversion.TestInversion.test_input_header_with_invalid_date @ linux-x86_64 +test.test_email.test_inversion.TestInversion.test_input_header_with_one_space_body @ linux-x86_64 +test.test_email.test_message.Test.test_error_on_setitem_if_max_count_exceeded @ linux-x86_64 +test.test_email.test_message.Test.test_rfc2043_auto_decoded_and_emailmessage_used @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_add_related_related_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_as_string_allows_maxheaderlen @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_as_string_unixform @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_as_string_uses_max_header_length_by_default @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_empty_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_content_related_with_start @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_empty_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_clear_related_with_start @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_default_content_manager_for_add_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_1 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_2 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_3 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_4 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_5 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_6 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_7 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_folding_with_utf8_encoding_8 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_empty_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_malformed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_body_related_with_start @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_content_default_cm_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_get_content_with_cm @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_is_attachment @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_empty_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachment_related_with_start @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_attachments_mutation @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_empty_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_related @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_iter_parts_related_with_start @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_related_related_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_make_with_boundary_related_related_ @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_policy_on_part_made_by_make_comes_from_message @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_set_content_adds_MIME_Version @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_set_content_default_cm_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_set_content_does_not_duplicate_MIME_Version @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_set_content_with_cm @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_str_defaults_to_policy_max_line_length @ linux-x86_64 +test.test_email.test_message.TestEmailMessage.test_str_defaults_to_utf8 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_add_related_related_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_empty_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_content_related_with_start @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_empty_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_clear_related_with_start @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_default_content_manager_for_add_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_empty_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_body_related_with_start @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_content_default_cm_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_get_content_with_cm @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_is_attachment @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_empty_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachment_related_with_start @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_attachments_mutation @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_empty_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_html_text_attachment_inline_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_html_text_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_mime_non_text @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_mixed_alternative_plain_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_mixed_related_alternative_plain_html @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_mixed_related_alternative_plain_html_wrong_order @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_mixed_text_message_rfc822 @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_non_mime_plain @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_plain_html_alternative @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_plain_html_attachment_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_plain_html_mixed @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_related @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_iter_parts_related_with_start @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_related_related_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_alternative_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_alternative_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_alternative_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_mixed_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_mixed_related_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_alternative_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_mixed_raises @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_no_content_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_none_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_plain_succeeds @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_make_with_boundary_related_related_ @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_policy_on_part_made_by_make_comes_from_message @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_set_content_default_cm_comes_from_policy @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_set_content_does_not_add_MIME_Version @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_set_content_with_cm @ linux-x86_64 +test.test_email.test_message.TestMIMEPart.test_string_payload_with_multipart_content_type @ linux-x86_64 +test.test_email.test_parser.TestBytesParser.test_custom_message_factory_on_policy @ linux-x86_64 +test.test_email.test_parser.TestBytesParser.test_factory_arg_overrides_policy @ linux-x86_64 +test.test_email.test_parser.TestBytesParser.test_only_split_on_cr_lf @ linux-x86_64 +test.test_email.test_parser.TestCustomMessage.test_custom_message_gets_policy_if_possible_from_file @ linux-x86_64 +test.test_email.test_parser.TestCustomMessage.test_custom_message_gets_policy_if_possible_from_string @ linux-x86_64 +test.test_email.test_parser.TestParser.test_custom_message_factory_on_policy @ linux-x86_64 +test.test_email.test_parser.TestParser.test_factory_arg_overrides_policy @ linux-x86_64 +test.test_email.test_parser.TestParser.test_only_split_on_cr_lf @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_deepcopy_date @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_deepcopy_from @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_deepcopy_subject @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_deepcopy_to @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_pickle_date @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_pickle_from @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_pickle_subject @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyHeader.test_pickle_to @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyMessage.test_deepcopy_created @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyMessage.test_deepcopy_parsed @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyMessage.test_pickle_created @ linux-x86_64 +test.test_email.test_pickleable.TestPickleCopyMessage.test_pickle_parsed @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_abc @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_adding_default_policies_preserves_default_factory @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_all_attributes_covered @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_clone_copies_factory @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_default_header_factory @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_defaults @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_each_Policy_gets_unique_factory @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_fold_zero_max_line_length @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_handle_defect_raises_on_strict @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_handle_defect_registers_defect @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_new_factory_overrides_default @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_non_ascii_chars_do_not_cause_inf_loop @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_overridden_register_defect_still_raises @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_overridden_register_defect_works @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_policy_addition @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_policy_is_immutable @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_register_defect @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_reject_non_policy_keyword_when_called @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_set_policy_attrs_when_cloned @ linux-x86_64 +test.test_email.test_policy.PolicyAPITests.test_short_maxlen_error @ linux-x86_64 +test.test_email.test_policy.TestConcretePolicies.test_header_store_parse_rejects_newlines @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_bytes_parser @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_from_binary_file @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_from_bytes @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_from_file @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_from_string @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_policy_propagates_to_generator @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_message_policy_used_by_as_string @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_parser @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_parser_propagates_policy_to_message @ linux-x86_64 +test.test_email.test_policy.TestPolicyPropagation.test_parser_propagates_policy_to_sub_messages @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_aware_datetime @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_naive_datetime @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_parsedate_to_datetime @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_parsedate_to_datetime_naive @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_parsedate_to_datetime_with_invalid_raises_valueerror @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_usegmt @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_usegmt_with_naive_datetime_raises @ linux-x86_64 +test.test_email.test_utils.DateTimeTests.test_usegmt_with_non_utc_datetime_raises @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_daylight_false_dst_false @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_daylight_false_dst_true @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_daylight_true_dst_false @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_daylight_true_dst_true @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_epoch_notz_daylight_false @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_epoch_notz_daylight_true @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_epoch_utc_daylight_false @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_epoch_utc_daylight_true @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_is_tz_aware_daylight_false @ linux-x86_64 +test.test_email.test_utils.LocaltimeTests.test_localtime_is_tz_aware_daylight_true @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ensurepip.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ensurepip.txt new file mode 100644 index 0000000000..4c357b2ef0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ensurepip.txt @@ -0,0 +1,30 @@ +test.test_ensurepip.TestBootstrap.test_altinstall_default_pip_conflict @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_basic_bootstrapping @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_alt_install @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_default_pip @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_regular_install @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_root @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_upgrade @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_user @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_verbosity_1 @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_verbosity_2 @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_bootstrapping_with_verbosity_3 @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_pip_config_file_disabled @ linux-x86_64 +test.test_ensurepip.TestBootstrap.test_pip_environment_variables_removed @ linux-x86_64 +test.test_ensurepip.TestBootstrappingMainFunction.test_basic_bootstrapping @ linux-x86_64 +test.test_ensurepip.TestBootstrappingMainFunction.test_bootstrap_version @ linux-x86_64 +test.test_ensurepip.TestBootstrappingMainFunction.test_bootstrapping_error_code @ linux-x86_64 +test.test_ensurepip.TestPackages.test_get_packages_no_dir @ linux-x86_64 +test.test_ensurepip.TestPackages.test_get_packages_with_dir @ linux-x86_64 +test.test_ensurepip.TestPackages.test_version @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_pip_config_file_disabled @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_pip_environment_variables_removed @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall_skipped_when_not_installed @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall_skipped_with_warning_for_wrong_version @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall_with_verbosity_1 @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall_with_verbosity_2 @ linux-x86_64 +test.test_ensurepip.TestUninstall.test_uninstall_with_verbosity_3 @ linux-x86_64 +test.test_ensurepip.TestUninstallationMainFunction.test_basic_uninstall @ linux-x86_64 +test.test_ensurepip.TestUninstallationMainFunction.test_uninstall_error_code @ linux-x86_64 +test.test_ensurepip.TestUninstallationMainFunction.test_uninstall_version @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enum.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enum.txt new file mode 100644 index 0000000000..be63ac457f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enum.txt @@ -0,0 +1,586 @@ +DocTestCase.enum.Enum @ linux-x86_64 +DocTestCase.enum._simple_enum @ linux-x86_64 +DocTestCase.enum._test_simple_enum @ linux-x86_64 +DocTestCase.enum.bin @ linux-x86_64 +test.test_enum.MiscTestCase.test__all__ @ linux-x86_64 +test.test_enum.MiscTestCase.test_doc_1 @ linux-x86_64 +test.test_enum.MiscTestCase.test_doc_2 @ linux-x86_64 +test.test_enum.MiscTestCase.test_doc_3 @ linux-x86_64 +test.test_enum.MiscTestCase.test_doc_4 @ linux-x86_64 +test.test_enum.OldTestFlag.test_aliases @ linux-x86_64 +test.test_enum.OldTestFlag.test_and @ linux-x86_64 +test.test_enum.OldTestFlag.test_auto_number @ linux-x86_64 +test.test_enum.OldTestFlag.test_auto_number_garbage @ linux-x86_64 +test.test_enum.OldTestFlag.test_bool @ linux-x86_64 +test.test_enum.OldTestFlag.test_boundary @ linux-x86_64 +test.test_enum.OldTestFlag.test_contains_er @ linux-x86_64 +test.test_enum.OldTestFlag.test_duplicate_auto @ linux-x86_64 +test.test_enum.OldTestFlag.test_init_subclass @ linux-x86_64 +test.test_enum.OldTestFlag.test_iter @ linux-x86_64 +test.test_enum.OldTestFlag.test_member_contains @ linux-x86_64 +test.test_enum.OldTestFlag.test_member_iter @ linux-x86_64 +test.test_enum.OldTestFlag.test_member_length @ linux-x86_64 +test.test_enum.OldTestFlag.test_multiple_mixin @ linux-x86_64 +test.test_enum.OldTestFlag.test_number_reset_and_order_cleanup @ linux-x86_64 +test.test_enum.OldTestFlag.test_or @ linux-x86_64 +test.test_enum.OldTestFlag.test_pickle @ linux-x86_64 +test.test_enum.OldTestFlag.test_programatic_function_from_dict @ linux-x86_64 +test.test_enum.OldTestFlag.test_programatic_function_iterable @ linux-x86_64 +test.test_enum.OldTestFlag.test_programatic_function_string @ linux-x86_64 +test.test_enum.OldTestFlag.test_programatic_function_string_list @ linux-x86_64 +test.test_enum.OldTestFlag.test_programatic_function_string_with_start @ linux-x86_64 +test.test_enum.OldTestFlag.test_unique_composite @ linux-x86_64 +test.test_enum.OldTestFlag.test_xor @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_aliases @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_and @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_bool @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_boundary @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_contains_er @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_format @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_global_enum_str @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_global_repr_conform1 @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_global_repr_keep @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_invert @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_iter @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_member_contains @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_member_iter @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_member_length @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_multiple_mixin @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_or @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_from_dict @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_from_empty_list @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_from_empty_tuple @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_iterable @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_string @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_string_list @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_programatic_function_string_with_start @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_type @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_unique_composite @ linux-x86_64 +test.test_enum.OldTestIntFlag.test_xor @ linux-x86_64 +test.test_enum.TestConvert.test_convert_complex @ linux-x86_64 +test.test_enum.TestConvert.test_convert_int @ linux-x86_64 +test.test_enum.TestConvert.test_convert_raise @ linux-x86_64 +test.test_enum.TestConvert.test_convert_repr_and_str @ linux-x86_64 +test.test_enum.TestConvert.test_convert_str @ linux-x86_64 +test.test_enum.TestConvert.test_convert_uncomparable @ linux-x86_64 +test.test_enum.TestConvert.test_convert_value_lookup_priority @ linux-x86_64 +test.test_enum.TestEmptyAndNonLatinStrings.test_empty_string @ linux-x86_64 +test.test_enum.TestEmptyAndNonLatinStrings.test_non_latin_character_string @ linux-x86_64 +test.test_enum.TestEmptyAndNonLatinStrings.test_non_latin_number_string @ linux-x86_64 +test.test_enum.TestHelpers.test_dunder @ linux-x86_64 +test.test_enum.TestHelpers.test_is_descriptor @ linux-x86_64 +test.test_enum.TestHelpers.test_is_private @ linux-x86_64 +test.test_enum.TestHelpers.test_iter_bits_lsb @ linux-x86_64 +test.test_enum.TestHelpers.test_sunder @ linux-x86_64 +test.test_enum.TestIntEnum.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestIntEnum.test_bad_new_super @ linux-x86_64 +test.test_enum.TestIntEnum.test_basics @ linux-x86_64 +test.test_enum.TestIntEnum.test_bool_is_true @ linux-x86_64 +test.test_enum.TestIntEnum.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestIntEnum.test_contains_er @ linux-x86_64 +test.test_enum.TestIntEnum.test_copy @ linux-x86_64 +test.test_enum.TestIntEnum.test_copy_member @ linux-x86_64 +test.test_enum.TestIntEnum.test_dir_on_class @ linux-x86_64 +test.test_enum.TestIntEnum.test_dir_on_item @ linux-x86_64 +test.test_enum.TestIntEnum.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestIntEnum.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestIntEnum.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestIntEnum.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestIntEnum.test_format @ linux-x86_64 +test.test_enum.TestIntEnum.test_format_specs @ linux-x86_64 +test.test_enum.TestIntEnum.test_hash @ linux-x86_64 +test.test_enum.TestIntEnum.test_inherited_repr @ linux-x86_64 +test.test_enum.TestIntEnum.test_invalid_names @ linux-x86_64 +test.test_enum.TestIntEnum.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestIntEnum.test_object_str_override @ linux-x86_64 +test.test_enum.TestIntEnum.test_overridden_format @ linux-x86_64 +test.test_enum.TestIntEnum.test_overridden_str @ linux-x86_64 +test.test_enum.TestIntEnum.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestIntEnum.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestIntEnum.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestIntEnum.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestIntEnum.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestIntEnum.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestIntEnum.test_repr @ linux-x86_64 +test.test_enum.TestIntEnum.test_repr_override @ linux-x86_64 +test.test_enum.TestIntEnum.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestIntEnum.test_str @ linux-x86_64 +test.test_enum.TestIntFlag.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestIntFlag.test_bad_new_super @ linux-x86_64 +test.test_enum.TestIntFlag.test_basics @ linux-x86_64 +test.test_enum.TestIntFlag.test_bool_is_true @ linux-x86_64 +test.test_enum.TestIntFlag.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestIntFlag.test_closed_invert_expectations @ linux-x86_64 +test.test_enum.TestIntFlag.test_contains_er @ linux-x86_64 +test.test_enum.TestIntFlag.test_copy @ linux-x86_64 +test.test_enum.TestIntFlag.test_copy_member @ linux-x86_64 +test.test_enum.TestIntFlag.test_default_missing_with_wrong_type_value @ linux-x86_64 +test.test_enum.TestIntFlag.test_dir_on_class @ linux-x86_64 +test.test_enum.TestIntFlag.test_dir_on_item @ linux-x86_64 +test.test_enum.TestIntFlag.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestIntFlag.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestIntFlag.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestIntFlag.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestIntFlag.test_format @ linux-x86_64 +test.test_enum.TestIntFlag.test_format_specs @ linux-x86_64 +test.test_enum.TestIntFlag.test_hash @ linux-x86_64 +test.test_enum.TestIntFlag.test_inherited_repr @ linux-x86_64 +test.test_enum.TestIntFlag.test_invalid_names @ linux-x86_64 +test.test_enum.TestIntFlag.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestIntFlag.test_object_str_override @ linux-x86_64 +test.test_enum.TestIntFlag.test_open_invert_expectations @ linux-x86_64 +test.test_enum.TestIntFlag.test_overridden_format @ linux-x86_64 +test.test_enum.TestIntFlag.test_overridden_str @ linux-x86_64 +test.test_enum.TestIntFlag.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestIntFlag.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestIntFlag.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestIntFlag.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestIntFlag.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestIntFlag.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestIntFlag.test_repr @ linux-x86_64 +test.test_enum.TestIntFlag.test_repr_override @ linux-x86_64 +test.test_enum.TestIntFlag.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestIntFlag.test_str @ linux-x86_64 +test.test_enum.TestInternals.test_auto_garbage_corrected_ok @ linux-x86_64 +test.test_enum.TestInternals.test_auto_garbage_ok @ linux-x86_64 +test.test_enum.TestInternals.test_auto_name @ linux-x86_64 +test.test_enum.TestInternals.test_auto_name_inherit @ linux-x86_64 +test.test_enum.TestInternals.test_auto_number @ linux-x86_64 +test.test_enum.TestInternals.test_auto_order @ linux-x86_64 +test.test_enum.TestInternals.test_auto_order_wierd @ linux-x86_64 +test.test_enum.TestInternals.test_dunder @ linux-x86_64 +test.test_enum.TestInternals.test_duplicate_auto @ linux-x86_64 +test.test_enum.TestInternals.test_is_private @ linux-x86_64 +test.test_enum.TestInternals.test_multiple_auto_on_line @ linux-x86_64 +test.test_enum.TestInternals.test_sunder @ linux-x86_64 +test.test_enum.TestMinimalDate.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMinimalDate.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMinimalDate.test_basics @ linux-x86_64 +test.test_enum.TestMinimalDate.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMinimalDate.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMinimalDate.test_contains_er @ linux-x86_64 +test.test_enum.TestMinimalDate.test_copy @ linux-x86_64 +test.test_enum.TestMinimalDate.test_copy_member @ linux-x86_64 +test.test_enum.TestMinimalDate.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMinimalDate.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMinimalDate.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMinimalDate.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMinimalDate.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMinimalDate.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMinimalDate.test_format @ linux-x86_64 +test.test_enum.TestMinimalDate.test_format_specs @ linux-x86_64 +test.test_enum.TestMinimalDate.test_hash @ linux-x86_64 +test.test_enum.TestMinimalDate.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMinimalDate.test_invalid_names @ linux-x86_64 +test.test_enum.TestMinimalDate.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMinimalDate.test_object_str_override @ linux-x86_64 +test.test_enum.TestMinimalDate.test_overridden_format @ linux-x86_64 +test.test_enum.TestMinimalDate.test_overridden_str @ linux-x86_64 +test.test_enum.TestMinimalDate.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMinimalDate.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMinimalDate.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMinimalDate.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMinimalDate.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMinimalDate.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMinimalDate.test_repr @ linux-x86_64 +test.test_enum.TestMinimalDate.test_repr_override @ linux-x86_64 +test.test_enum.TestMinimalDate.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMinimalDate.test_str @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_basics @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_contains_er @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_copy @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_copy_member @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_format @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_format_specs @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_hash @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_invalid_names @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_object_str_override @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_overridden_format @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_overridden_str @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_repr @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_repr_override @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMinimalFloat.test_str @ linux-x86_64 +test.test_enum.TestMixedDate.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMixedDate.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMixedDate.test_basics @ linux-x86_64 +test.test_enum.TestMixedDate.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMixedDate.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMixedDate.test_contains_er @ linux-x86_64 +test.test_enum.TestMixedDate.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMixedDate.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMixedDate.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMixedDate.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMixedDate.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMixedDate.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMixedDate.test_format @ linux-x86_64 +test.test_enum.TestMixedDate.test_format_specs @ linux-x86_64 +test.test_enum.TestMixedDate.test_hash @ linux-x86_64 +test.test_enum.TestMixedDate.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMixedDate.test_invalid_names @ linux-x86_64 +test.test_enum.TestMixedDate.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMixedDate.test_object_str_override @ linux-x86_64 +test.test_enum.TestMixedDate.test_overridden_format @ linux-x86_64 +test.test_enum.TestMixedDate.test_overridden_str @ linux-x86_64 +test.test_enum.TestMixedDate.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMixedDate.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMixedDate.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMixedDate.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMixedDate.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMixedDate.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMixedDate.test_repr @ linux-x86_64 +test.test_enum.TestMixedDate.test_repr_override @ linux-x86_64 +test.test_enum.TestMixedDate.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMixedDate.test_str @ linux-x86_64 +test.test_enum.TestMixedFloat.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMixedFloat.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMixedFloat.test_basics @ linux-x86_64 +test.test_enum.TestMixedFloat.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMixedFloat.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMixedFloat.test_contains_er @ linux-x86_64 +test.test_enum.TestMixedFloat.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMixedFloat.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMixedFloat.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMixedFloat.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMixedFloat.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMixedFloat.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMixedFloat.test_format @ linux-x86_64 +test.test_enum.TestMixedFloat.test_format_specs @ linux-x86_64 +test.test_enum.TestMixedFloat.test_hash @ linux-x86_64 +test.test_enum.TestMixedFloat.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMixedFloat.test_invalid_names @ linux-x86_64 +test.test_enum.TestMixedFloat.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMixedFloat.test_object_str_override @ linux-x86_64 +test.test_enum.TestMixedFloat.test_overridden_format @ linux-x86_64 +test.test_enum.TestMixedFloat.test_overridden_str @ linux-x86_64 +test.test_enum.TestMixedFloat.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMixedFloat.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMixedFloat.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMixedFloat.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMixedFloat.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMixedFloat.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMixedFloat.test_repr @ linux-x86_64 +test.test_enum.TestMixedFloat.test_repr_override @ linux-x86_64 +test.test_enum.TestMixedFloat.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMixedFloat.test_str @ linux-x86_64 +test.test_enum.TestMixedInt.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMixedInt.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMixedInt.test_basics @ linux-x86_64 +test.test_enum.TestMixedInt.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMixedInt.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMixedInt.test_contains_er @ linux-x86_64 +test.test_enum.TestMixedInt.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMixedInt.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMixedInt.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMixedInt.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMixedInt.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMixedInt.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMixedInt.test_format @ linux-x86_64 +test.test_enum.TestMixedInt.test_format_specs @ linux-x86_64 +test.test_enum.TestMixedInt.test_hash @ linux-x86_64 +test.test_enum.TestMixedInt.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMixedInt.test_invalid_names @ linux-x86_64 +test.test_enum.TestMixedInt.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMixedInt.test_object_str_override @ linux-x86_64 +test.test_enum.TestMixedInt.test_overridden_format @ linux-x86_64 +test.test_enum.TestMixedInt.test_overridden_str @ linux-x86_64 +test.test_enum.TestMixedInt.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMixedInt.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMixedInt.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMixedInt.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMixedInt.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMixedInt.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMixedInt.test_repr @ linux-x86_64 +test.test_enum.TestMixedInt.test_repr_override @ linux-x86_64 +test.test_enum.TestMixedInt.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMixedInt.test_str @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_basics @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_closed_invert_expectations @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_contains_er @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_default_missing_with_wrong_type_value @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_format @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_format_specs @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_hash @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_invalid_names @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_object_str_override @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_open_invert_expectations @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_overridden_format @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_overridden_str @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_repr @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_repr_override @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMixedIntFlag.test_str @ linux-x86_64 +test.test_enum.TestMixedStr.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestMixedStr.test_bad_new_super @ linux-x86_64 +test.test_enum.TestMixedStr.test_basics @ linux-x86_64 +test.test_enum.TestMixedStr.test_bool_is_true @ linux-x86_64 +test.test_enum.TestMixedStr.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestMixedStr.test_contains_er @ linux-x86_64 +test.test_enum.TestMixedStr.test_dir_on_class @ linux-x86_64 +test.test_enum.TestMixedStr.test_dir_on_item @ linux-x86_64 +test.test_enum.TestMixedStr.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestMixedStr.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestMixedStr.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestMixedStr.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestMixedStr.test_format @ linux-x86_64 +test.test_enum.TestMixedStr.test_format_specs @ linux-x86_64 +test.test_enum.TestMixedStr.test_hash @ linux-x86_64 +test.test_enum.TestMixedStr.test_inherited_repr @ linux-x86_64 +test.test_enum.TestMixedStr.test_invalid_names @ linux-x86_64 +test.test_enum.TestMixedStr.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestMixedStr.test_object_str_override @ linux-x86_64 +test.test_enum.TestMixedStr.test_overridden_format @ linux-x86_64 +test.test_enum.TestMixedStr.test_overridden_str @ linux-x86_64 +test.test_enum.TestMixedStr.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestMixedStr.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestMixedStr.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestMixedStr.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestMixedStr.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestMixedStr.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestMixedStr.test_repr @ linux-x86_64 +test.test_enum.TestMixedStr.test_repr_override @ linux-x86_64 +test.test_enum.TestMixedStr.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestMixedStr.test_str @ linux-x86_64 +test.test_enum.TestOrder.test_enum_has_extra_members @ linux-x86_64 +test.test_enum.TestOrder.test_enum_has_extra_members_with_aliases @ linux-x86_64 +test.test_enum.TestOrder.test_order_has_extra_members @ linux-x86_64 +test.test_enum.TestOrder.test_order_has_extra_members_with_aliases @ linux-x86_64 +test.test_enum.TestOrder.test_same_members @ linux-x86_64 +test.test_enum.TestOrder.test_same_members_with_aliases @ linux-x86_64 +test.test_enum.TestOrder.test_same_members_wrong_order @ linux-x86_64 +test.test_enum.TestPlainEnum.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestPlainEnum.test_bad_new_super @ linux-x86_64 +test.test_enum.TestPlainEnum.test_basics @ linux-x86_64 +test.test_enum.TestPlainEnum.test_bool_is_true @ linux-x86_64 +test.test_enum.TestPlainEnum.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestPlainEnum.test_contains_er @ linux-x86_64 +test.test_enum.TestPlainEnum.test_dir_on_class @ linux-x86_64 +test.test_enum.TestPlainEnum.test_dir_on_item @ linux-x86_64 +test.test_enum.TestPlainEnum.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestPlainEnum.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestPlainEnum.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestPlainEnum.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestPlainEnum.test_format @ linux-x86_64 +test.test_enum.TestPlainEnum.test_format_specs @ linux-x86_64 +test.test_enum.TestPlainEnum.test_hash @ linux-x86_64 +test.test_enum.TestPlainEnum.test_inherited_repr @ linux-x86_64 +test.test_enum.TestPlainEnum.test_invalid_names @ linux-x86_64 +test.test_enum.TestPlainEnum.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestPlainEnum.test_object_str_override @ linux-x86_64 +test.test_enum.TestPlainEnum.test_overridden_format @ linux-x86_64 +test.test_enum.TestPlainEnum.test_overridden_str @ linux-x86_64 +test.test_enum.TestPlainEnum.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestPlainEnum.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestPlainEnum.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestPlainEnum.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestPlainEnum.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestPlainEnum.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestPlainEnum.test_repr @ linux-x86_64 +test.test_enum.TestPlainEnum.test_repr_override @ linux-x86_64 +test.test_enum.TestPlainEnum.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestPlainEnum.test_str @ linux-x86_64 +test.test_enum.TestPlainFlag.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestPlainFlag.test_bad_new_super @ linux-x86_64 +test.test_enum.TestPlainFlag.test_basics @ linux-x86_64 +test.test_enum.TestPlainFlag.test_bool_is_true @ linux-x86_64 +test.test_enum.TestPlainFlag.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestPlainFlag.test_closed_invert_expectations @ linux-x86_64 +test.test_enum.TestPlainFlag.test_contains_er @ linux-x86_64 +test.test_enum.TestPlainFlag.test_default_missing_with_wrong_type_value @ linux-x86_64 +test.test_enum.TestPlainFlag.test_dir_on_class @ linux-x86_64 +test.test_enum.TestPlainFlag.test_dir_on_item @ linux-x86_64 +test.test_enum.TestPlainFlag.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestPlainFlag.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestPlainFlag.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestPlainFlag.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestPlainFlag.test_format @ linux-x86_64 +test.test_enum.TestPlainFlag.test_format_specs @ linux-x86_64 +test.test_enum.TestPlainFlag.test_hash @ linux-x86_64 +test.test_enum.TestPlainFlag.test_inherited_repr @ linux-x86_64 +test.test_enum.TestPlainFlag.test_invalid_names @ linux-x86_64 +test.test_enum.TestPlainFlag.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestPlainFlag.test_object_str_override @ linux-x86_64 +test.test_enum.TestPlainFlag.test_open_invert_expectations @ linux-x86_64 +test.test_enum.TestPlainFlag.test_overridden_format @ linux-x86_64 +test.test_enum.TestPlainFlag.test_overridden_str @ linux-x86_64 +test.test_enum.TestPlainFlag.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestPlainFlag.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestPlainFlag.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestPlainFlag.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestPlainFlag.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestPlainFlag.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestPlainFlag.test_repr @ linux-x86_64 +test.test_enum.TestPlainFlag.test_repr_override @ linux-x86_64 +test.test_enum.TestPlainFlag.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestPlainFlag.test_str @ linux-x86_64 +test.test_enum.TestSpecial.test_bool @ linux-x86_64 +test.test_enum.TestSpecial.test_comparisons @ linux-x86_64 +test.test_enum.TestSpecial.test_conflicting_types_resolved_in_new @ linux-x86_64 +test.test_enum.TestSpecial.test_custom_flag_bitwise @ linux-x86_64 +test.test_enum.TestSpecial.test_default_missing_no_chained_exception @ linux-x86_64 +test.test_enum.TestSpecial.test_duplicate_name_error @ linux-x86_64 +test.test_enum.TestSpecial.test_duplicate_values_give_unique_enum_items @ linux-x86_64 +test.test_enum.TestSpecial.test_dynamic_members_with_static_methods @ linux-x86_64 +test.test_enum.TestSpecial.test_empty_globals @ linux-x86_64 +test.test_enum.TestSpecial.test_enum_function_with_qualname @ linux-x86_64 +test.test_enum.TestSpecial.test_enum_of_generic_aliases @ linux-x86_64 +test.test_enum.TestSpecial.test_enum_of_types @ linux-x86_64 +test.test_enum.TestSpecial.test_enum_of_types_with_nonmember @ linux-x86_64 +test.test_enum.TestSpecial.test_enum_with_value_name @ linux-x86_64 +test.test_enum.TestSpecial.test_equality @ linux-x86_64 +test.test_enum.TestSpecial.test_exclude_methods @ linux-x86_64 +test.test_enum.TestSpecial.test_extending @ linux-x86_64 +test.test_enum.TestSpecial.test_extending2 @ linux-x86_64 +test.test_enum.TestSpecial.test_extending3 @ linux-x86_64 +test.test_enum.TestSpecial.test_flag_with_custom_new @ linux-x86_64 +test.test_enum.TestSpecial.test_floatenum_fromhex @ linux-x86_64 +test.test_enum.TestSpecial.test_flufl_enum @ linux-x86_64 +test.test_enum.TestSpecial.test_getattr_dunder @ linux-x86_64 +test.test_enum.TestSpecial.test_getattr_getitem @ linux-x86_64 +test.test_enum.TestSpecial.test_ignore @ linux-x86_64 +test.test_enum.TestSpecial.test_inherited_data_type @ linux-x86_64 +test.test_enum.TestSpecial.test_inherited_new_from_enhanced_enum @ linux-x86_64 +test.test_enum.TestSpecial.test_inherited_new_from_mixed_enum @ linux-x86_64 +test.test_enum.TestSpecial.test_init @ linux-x86_64 +test.test_enum.TestSpecial.test_init_exception @ linux-x86_64 +test.test_enum.TestSpecial.test_int_flags_copy @ linux-x86_64 +test.test_enum.TestSpecial.test_intenum_from_bytes @ linux-x86_64 +test.test_enum.TestSpecial.test_intenum_transitivity @ linux-x86_64 +test.test_enum.TestSpecial.test_introspection @ linux-x86_64 +test.test_enum.TestSpecial.test_iteration_order @ linux-x86_64 +test.test_enum.TestSpecial.test_member_from_member_access @ linux-x86_64 +test.test_enum.TestSpecial.test_missing_override @ linux-x86_64 +test.test_enum.TestSpecial.test_missing_value_error @ linux-x86_64 +test.test_enum.TestSpecial.test_mixed_enum_in_call_1 @ linux-x86_64 +test.test_enum.TestSpecial.test_mixed_enum_in_call_2 @ linux-x86_64 +test.test_enum.TestSpecial.test_multiple_inherited_mixin @ linux-x86_64 +test.test_enum.TestSpecial.test_multiple_mixin @ linux-x86_64 +test.test_enum.TestSpecial.test_multiple_mixin_inherited @ linux-x86_64 +test.test_enum.TestSpecial.test_multiple_mixin_mro @ linux-x86_64 +test.test_enum.TestSpecial.test_multiple_mixin_with_common_data_type @ linux-x86_64 +test.test_enum.TestSpecial.test_namedtuple_as_value @ linux-x86_64 +test.test_enum.TestSpecial.test_nested_classes_in_enum_are_members @ linux-x86_64 +test.test_enum.TestSpecial.test_nested_classes_in_enum_with_member @ linux-x86_64 +test.test_enum.TestSpecial.test_nested_classes_in_enum_with_nonmember @ linux-x86_64 +test.test_enum.TestSpecial.test_no_duplicates @ linux-x86_64 +test.test_enum.TestSpecial.test_no_such_enum_member @ linux-x86_64 +test.test_enum.TestSpecial.test_nonhash_value @ linux-x86_64 +test.test_enum.TestSpecial.test_ordered_mixin @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_by_name @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_enum @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_enum_function @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_enum_function_with_module @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_explodes @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_float @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_int @ linux-x86_64 +test.test_enum.TestSpecial.test_pickle_nested_class @ linux-x86_64 +test.test_enum.TestSpecial.test_private_variable_is_normal_attribute @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_string_list_with_start @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_string_with_start @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_type @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_type_from_subclass @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_type_from_subclass_with_start @ linux-x86_64 +test.test_enum.TestSpecial.test_programmatic_function_type_with_start @ linux-x86_64 +test.test_enum.TestSpecial.test_repr_and_str_with_no_init_mixin @ linux-x86_64 +test.test_enum.TestSpecial.test_repr_with_dataclass @ linux-x86_64 +test.test_enum.TestSpecial.test_repr_with_init_mixin @ linux-x86_64 +test.test_enum.TestSpecial.test_reserved_sunder_error @ linux-x86_64 +test.test_enum.TestSpecial.test_strenum @ linux-x86_64 +test.test_enum.TestSpecial.test_string_enum @ linux-x86_64 +test.test_enum.TestSpecial.test_subclass_duplicate_name @ linux-x86_64 +test.test_enum.TestSpecial.test_subclass_duplicate_name_dynamic @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_with_direct_pickle_support @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_with_getnewargs @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_with_getnewargs_ex @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_with_reduce @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_with_reduce_ex @ linux-x86_64 +test.test_enum.TestSpecial.test_subclasses_without_direct_pickle_support @ linux-x86_64 +test.test_enum.TestSpecial.test_subclassing @ linux-x86_64 +test.test_enum.TestSpecial.test_too_many_data_types @ linux-x86_64 +test.test_enum.TestSpecial.test_tuple_subclass @ linux-x86_64 +test.test_enum.TestSpecial.test_value_backup_assign @ linux-x86_64 +test.test_enum.TestSpecial.test_wrong_enum_in_call @ linux-x86_64 +test.test_enum.TestSpecial.test_wrong_enum_in_mixed_call @ linux-x86_64 +test.test_enum.TestSpecial.test_wrong_inheritance_order @ linux-x86_64 +test.test_enum.TestStdLib.test_inspect_classify_class_attrs @ linux-x86_64 +test.test_enum.TestStdLib.test_inspect_getmembers @ linux-x86_64 +test.test_enum.TestStdLib.test_pydoc @ linux-x86_64 +test.test_enum.TestStdLib.test_test_simple_enum @ linux-x86_64 +test.test_enum.TestStrEnum.test_attribute_deletion @ linux-x86_64 +test.test_enum.TestStrEnum.test_bad_new_super @ linux-x86_64 +test.test_enum.TestStrEnum.test_basics @ linux-x86_64 +test.test_enum.TestStrEnum.test_bool_is_true @ linux-x86_64 +test.test_enum.TestStrEnum.test_changing_member_fails @ linux-x86_64 +test.test_enum.TestStrEnum.test_contains_er @ linux-x86_64 +test.test_enum.TestStrEnum.test_copy @ linux-x86_64 +test.test_enum.TestStrEnum.test_copy_member @ linux-x86_64 +test.test_enum.TestStrEnum.test_dir_on_class @ linux-x86_64 +test.test_enum.TestStrEnum.test_dir_on_item @ linux-x86_64 +test.test_enum.TestStrEnum.test_dir_on_sub_with_behavior_including_instance_dict_on_super @ linux-x86_64 +test.test_enum.TestStrEnum.test_dir_on_sub_with_behavior_on_super @ linux-x86_64 +test.test_enum.TestStrEnum.test_dir_with_added_behavior @ linux-x86_64 +test.test_enum.TestStrEnum.test_enum_in_enum_out @ linux-x86_64 +test.test_enum.TestStrEnum.test_format @ linux-x86_64 +test.test_enum.TestStrEnum.test_format_specs @ linux-x86_64 +test.test_enum.TestStrEnum.test_hash @ linux-x86_64 +test.test_enum.TestStrEnum.test_inherited_repr @ linux-x86_64 +test.test_enum.TestStrEnum.test_invalid_names @ linux-x86_64 +test.test_enum.TestStrEnum.test_multiple_superclasses_repr @ linux-x86_64 +test.test_enum.TestStrEnum.test_object_str_override @ linux-x86_64 +test.test_enum.TestStrEnum.test_overridden_format @ linux-x86_64 +test.test_enum.TestStrEnum.test_overridden_str @ linux-x86_64 +test.test_enum.TestStrEnum.test_overridden_str_format @ linux-x86_64 +test.test_enum.TestStrEnum.test_overridden_str_format_inherited @ linux-x86_64 +test.test_enum.TestStrEnum.test_programmatic_function_from_dict @ linux-x86_64 +test.test_enum.TestStrEnum.test_programmatic_function_iterable @ linux-x86_64 +test.test_enum.TestStrEnum.test_programmatic_function_string @ linux-x86_64 +test.test_enum.TestStrEnum.test_programmatic_function_string_list @ linux-x86_64 +test.test_enum.TestStrEnum.test_repr @ linux-x86_64 +test.test_enum.TestStrEnum.test_repr_override @ linux-x86_64 +test.test_enum.TestStrEnum.test_reversed_iteration_order @ linux-x86_64 +test.test_enum.TestStrEnum.test_str @ linux-x86_64 +test.test_enum.TestUnique.test_unique_clean @ linux-x86_64 +test.test_enum.TestUnique.test_unique_dirty @ linux-x86_64 +test.test_enum.TestUnique.test_unique_with_name @ linux-x86_64 +test.test_enum.TestVerify.test_composite @ linux-x86_64 +test.test_enum.TestVerify.test_continuous @ linux-x86_64 +test.test_enum.TestVerify.test_negative_alias @ linux-x86_64 +test.test_enum.TestVerify.test_unique_clean @ linux-x86_64 +test.test_enum.TestVerify.test_unique_dirty @ linux-x86_64 +test.test_enum.TestVerify.test_unique_with_name @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enumerate.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enumerate.txt new file mode 100644 index 0000000000..ec427b036a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_enumerate.txt @@ -0,0 +1,78 @@ +test.test_enumerate.EnumerateStartTestCase.test_argumentcheck @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_basicfunction @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_exception_propagation @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_getitemseqn @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_illformediterable @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_kwargs @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_noniterable @ linux-x86_64 +test.test_enumerate.EnumerateStartTestCase.test_pickle @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_argumentcheck @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_basicfunction @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_exception_propagation @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_getitemseqn @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_illformediterable @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_kwargs @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_noniterable @ linux-x86_64 +test.test_enumerate.EnumerateTestCase.test_pickle @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_argumentcheck @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_basicfunction @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_exception_propagation @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_getitemseqn @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_illformediterable @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_kwargs @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_noniterable @ linux-x86_64 +test.test_enumerate.SubclassTestCase.test_pickle @ linux-x86_64 +test.test_enumerate.TestBig.test_argumentcheck @ linux-x86_64 +test.test_enumerate.TestBig.test_basicfunction @ linux-x86_64 +test.test_enumerate.TestBig.test_exception_propagation @ linux-x86_64 +test.test_enumerate.TestBig.test_getitemseqn @ linux-x86_64 +test.test_enumerate.TestBig.test_illformediterable @ linux-x86_64 +test.test_enumerate.TestBig.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.TestBig.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.TestBig.test_kwargs @ linux-x86_64 +test.test_enumerate.TestBig.test_noniterable @ linux-x86_64 +test.test_enumerate.TestBig.test_pickle @ linux-x86_64 +test.test_enumerate.TestEmpty.test_argumentcheck @ linux-x86_64 +test.test_enumerate.TestEmpty.test_basicfunction @ linux-x86_64 +test.test_enumerate.TestEmpty.test_exception_propagation @ linux-x86_64 +test.test_enumerate.TestEmpty.test_getitemseqn @ linux-x86_64 +test.test_enumerate.TestEmpty.test_illformediterable @ linux-x86_64 +test.test_enumerate.TestEmpty.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.TestEmpty.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.TestEmpty.test_kwargs @ linux-x86_64 +test.test_enumerate.TestEmpty.test_noniterable @ linux-x86_64 +test.test_enumerate.TestEmpty.test_pickle @ linux-x86_64 +test.test_enumerate.TestLongStart.test_argumentcheck @ linux-x86_64 +test.test_enumerate.TestLongStart.test_basicfunction @ linux-x86_64 +test.test_enumerate.TestLongStart.test_exception_propagation @ linux-x86_64 +test.test_enumerate.TestLongStart.test_getitemseqn @ linux-x86_64 +test.test_enumerate.TestLongStart.test_illformediterable @ linux-x86_64 +test.test_enumerate.TestLongStart.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.TestLongStart.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.TestLongStart.test_kwargs @ linux-x86_64 +test.test_enumerate.TestLongStart.test_noniterable @ linux-x86_64 +test.test_enumerate.TestLongStart.test_pickle @ linux-x86_64 +test.test_enumerate.TestReversed.test_args @ linux-x86_64 +test.test_enumerate.TestReversed.test_bug1229429 @ linux-x86_64 +test.test_enumerate.TestReversed.test_gc @ linux-x86_64 +test.test_enumerate.TestReversed.test_len @ linux-x86_64 +test.test_enumerate.TestReversed.test_objmethods @ linux-x86_64 +test.test_enumerate.TestReversed.test_pickle @ linux-x86_64 +test.test_enumerate.TestReversed.test_range_optimization @ linux-x86_64 +test.test_enumerate.TestReversed.test_simple @ linux-x86_64 +test.test_enumerate.TestStart.test_argumentcheck @ linux-x86_64 +test.test_enumerate.TestStart.test_basicfunction @ linux-x86_64 +test.test_enumerate.TestStart.test_exception_propagation @ linux-x86_64 +test.test_enumerate.TestStart.test_getitemseqn @ linux-x86_64 +test.test_enumerate.TestStart.test_illformediterable @ linux-x86_64 +test.test_enumerate.TestStart.test_iteratorgenerator @ linux-x86_64 +test.test_enumerate.TestStart.test_iteratorseqn @ linux-x86_64 +test.test_enumerate.TestStart.test_kwargs @ linux-x86_64 +test.test_enumerate.TestStart.test_noniterable @ linux-x86_64 +test.test_enumerate.TestStart.test_pickle @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_eof.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_eof.txt new file mode 100644 index 0000000000..926aeaddb9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_eof.txt @@ -0,0 +1,6 @@ +test.test_eof.EOFTestCase.test_EOFS @ linux-x86_64 +test.test_eof.EOFTestCase.test_EOFS_with_file @ linux-x86_64 +test.test_eof.EOFTestCase.test_EOF_single_quote @ linux-x86_64 +test.test_eof.EOFTestCase.test_eof_with_line_continuation @ linux-x86_64 +test.test_eof.EOFTestCase.test_line_continuation_EOF @ linux-x86_64 +test.test_eof.EOFTestCase.test_line_continuation_EOF_from_file_bpo2180 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_errno.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_errno.txt new file mode 100644 index 0000000000..413ccd9bf2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_errno.txt @@ -0,0 +1,3 @@ +test.test_errno.ErrnoAttributeTests.test_for_improper_attributes @ linux-x86_64 +test.test_errno.ErrnoAttributeTests.test_using_errorcode @ linux-x86_64 +test.test_errno.ErrorcodeTests.test_attributes_in_errorcode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_except_star.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_except_star.txt new file mode 100644 index 0000000000..6bec5e2be3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_except_star.txt @@ -0,0 +1 @@ +test.test_except_star.TestInvalidExceptStar.test_mixed_except_and_except_star_is_syntax_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_group.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_group.txt new file mode 100644 index 0000000000..b765dab392 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_group.txt @@ -0,0 +1,47 @@ +test.test_exception_group.BadConstructorArgs.test_bad_EG_construction__bad_excs_sequence @ linux-x86_64 +test.test_exception_group.BadConstructorArgs.test_bad_EG_construction__bad_message @ linux-x86_64 +test.test_exception_group.BadConstructorArgs.test_bad_EG_construction__nested_non_exceptions @ linux-x86_64 +test.test_exception_group.BadConstructorArgs.test_bad_EG_construction__too_many_args @ linux-x86_64 +test.test_exception_group.ExceptionGroupFields.test_basics_ExceptionGroup_fields @ linux-x86_64 +test.test_exception_group.ExceptionGroupFields.test_fields_are_readonly @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_predicate__match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_predicate__no_match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_predicate__passthrough @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_type__match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_type__no_match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSplitTests.test_basics_split_by_type__passthrough @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_predicate__match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_predicate__no_match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_predicate__passthrough @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_type__match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_type__no_match @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_by_type__passthrough @ linux-x86_64 +test.test_exception_group.ExceptionGroupSubgroupTests.test_basics_subgroup_split__bad_arg_type @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_BEG_and_E_subclass_does_not_wrap_base_exceptions @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_BEG_and_specific_subclass_can_wrap_any_nonbase_exception @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_BEG_subclass_wraps_anything @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_BEG_wraps_BaseException__creates_BEG @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_BEG_wraps_Exceptions__creates_EG @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_EG_and_specific_subclass_can_wrap_any_nonbase_exception @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_EG_subclass_does_not_wrap_base_exceptions @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_EG_subclass_wraps_non_base_exceptions @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_EG_wraps_BaseException__raises_TypeError @ linux-x86_64 +test.test_exception_group.InstanceCreation.test_EG_wraps_Exceptions__creates_EG @ linux-x86_64 +test.test_exception_group.LeafGeneratorTest.test_leaf_generator @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupBasicsTest.test_iteration_full_tracebacks @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupBasicsTest.test_nested_exception_group_tracebacks @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupBasicsTest.test_nested_group_chaining @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupBasicsTest.test_nested_group_matches_template @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSplitTest.test_split_BaseExceptionGroup @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSplitTest.test_split_by_type @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSplitTest.test_split_copies_notes @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSplitTest.test_split_does_not_copy_non_sequence_notes @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSubclassSplitTest.test_split_BaseExceptionGroup_subclass_no_derive_new_override @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSubclassSplitTest.test_split_ExceptionGroup_subclass_derive_and_new_overrides @ linux-x86_64 +test.test_exception_group.NestedExceptionGroupSubclassSplitTest.test_split_ExceptionGroup_subclass_no_derive_no_new_override @ linux-x86_64 +test.test_exception_group.StrAndReprTests.test_BaseExceptionGroup @ linux-x86_64 +test.test_exception_group.StrAndReprTests.test_ExceptionGroup @ linux-x86_64 +test.test_exception_group.StrAndReprTests.test_custom_exception @ linux-x86_64 +test.test_exception_group.TestExceptionGroupTypeHierarchy.test_exception_group_is_generic_type @ linux-x86_64 +test.test_exception_group.TestExceptionGroupTypeHierarchy.test_exception_group_types @ linux-x86_64 +test.test_exception_group.TestExceptionGroupTypeHierarchy.test_exception_is_not_generic_type @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_hierarchy.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_hierarchy.txt new file mode 100644 index 0000000000..4fb44e89eb --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_hierarchy.txt @@ -0,0 +1,15 @@ +test.test_exception_hierarchy.AttributesTest.test_blockingioerror @ linux-x86_64 +test.test_exception_hierarchy.AttributesTest.test_posix_error @ linux-x86_64 +test.test_exception_hierarchy.AttributesTest.test_windows_error @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_errno_mapping @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_init_kwdargs @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_init_new_overridden @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_init_overridden @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_init_standalone @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_new_kwdargs @ linux-x86_64 +test.test_exception_hierarchy.ExplicitSubclassingTest.test_new_overridden @ linux-x86_64 +test.test_exception_hierarchy.HierarchyTest.test_builtin_errors @ linux-x86_64 +test.test_exception_hierarchy.HierarchyTest.test_errno_mapping @ linux-x86_64 +test.test_exception_hierarchy.HierarchyTest.test_select_error @ linux-x86_64 +test.test_exception_hierarchy.HierarchyTest.test_socket_errors @ linux-x86_64 +test.test_exception_hierarchy.HierarchyTest.test_try_except @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_variations.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_variations.txt new file mode 100644 index 0000000000..49f8f650d1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exception_variations.txt @@ -0,0 +1,16 @@ +test.test_exception_variations.ExceptStarTestCases.test_try_finally_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested_else @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested_exception_in_else @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested_exception_in_except @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested_exception_in_finally_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_nested_exception_in_finally_with_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_else @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_else_finally @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_else_finally_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_else_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_finally @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_finally_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_except_no_exception @ linux-x86_64 +test.test_exception_variations.ExceptTestCases.test_try_finally_no_exception @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exceptions.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exceptions.txt new file mode 100644 index 0000000000..fa0dd83249 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_exceptions.txt @@ -0,0 +1,54 @@ +test.test_exceptions.AttributeErrorTests.test_attribute_error_with_failing_dict @ linux-x86_64 +test.test_exceptions.AttributeErrorTests.test_getattr_error_bad_suggestions_do_not_trigger_for_small_names @ linux-x86_64 +test.test_exceptions.AttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_big_dicts @ linux-x86_64 +test.test_exceptions.AttributeErrorTests.test_getattr_suggestions_do_not_trigger_for_long_attributes @ linux-x86_64 +test.test_exceptions.AttributeErrorTests.test_getattr_suggestions_for_same_name @ linux-x86_64 +test.test_exceptions.ExceptionTests.testAttributes @ linux-x86_64 +test.test_exceptions.ExceptionTests.testChainingAttrs @ linux-x86_64 +test.test_exceptions.ExceptionTests.testChainingDescriptors @ linux-x86_64 +!test.test_exceptions.ExceptionTests.testInfiniteRecursion @ linux-x86_64 +test.test_exceptions.ExceptionTests.testInvalidAttrs @ linux-x86_64 +test.test_exceptions.ExceptionTests.testInvalidTraceback @ linux-x86_64 +test.test_exceptions.ExceptionTests.testKeywordArgs @ linux-x86_64 +test.test_exceptions.ExceptionTests.testNoneClearsTracebackAttr @ linux-x86_64 +test.test_exceptions.ExceptionTests.testRaising @ linux-x86_64 +test.test_exceptions.ExceptionTests.testSyntaxErrorMessage @ linux-x86_64 +test.test_exceptions.ExceptionTests.testSyntaxErrorMissingParens @ linux-x86_64 +test.test_exceptions.ExceptionTests.testWithTraceback @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_WindowsError @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_assert_shadowing @ linux-x86_64 +!test.test_exceptions.ExceptionTests.test_badisinstance @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_context_of_exception_in_else_and_finally @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_context_of_exception_in_except_and_finally @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_context_of_exception_in_try_and_finally @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_errno_ENOTDIR @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_error_offset_continuation_characters @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_exception_cleanup_names @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_exception_cleanup_names2 @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_exception_target_in_nested_scope @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_generator_doesnt_retain_old_exc2 @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_generator_finalizing_and_exc_info @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_generator_leaking2 @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_generator_leaking3 @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_memory_error_subclasses @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_notes @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_raise_does_not_create_context_chain_cycle @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_str @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_unhandled @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_unicode_change_attributes @ linux-x86_64 +test.test_exceptions.ExceptionTests.test_unicode_errors_no_object @ linux-x86_64 +test.test_exceptions.ImportErrorTests.test_attributes @ linux-x86_64 +test.test_exceptions.ImportErrorTests.test_copy_pickle @ linux-x86_64 +test.test_exceptions.ImportErrorTests.test_non_str_argument @ linux-x86_64 +test.test_exceptions.ImportErrorTests.test_reset_attributes @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_issue45826 @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_issue45826_focused @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_name_error_bad_suggestions_do_not_trigger_for_small_names @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_name_error_suggestions_do_not_trigger_for_long_names @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_name_error_suggestions_do_not_trigger_for_too_many_locals @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_name_error_with_custom_exceptions @ linux-x86_64 +test.test_exceptions.NameErrorTests.test_unbound_local_error_doesn_not_match @ linux-x86_64 +test.test_exceptions.PEP626Tests.test_lineno_after_raise_in_with_exit @ linux-x86_64 +test.test_exceptions.PEP626Tests.test_lineno_after_raise_simple @ linux-x86_64 +test.test_exceptions.PEP626Tests.test_lineno_in_finally_normal @ linux-x86_64 +test.test_exceptions.SyntaxErrorTests.test_attributes_old_constructor @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_faulthandler.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_faulthandler.txt new file mode 100644 index 0000000000..a40d51f103 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_faulthandler.txt @@ -0,0 +1,4 @@ +test.test_faulthandler.FaultHandlerTests.test_cancel_later_without_dump_traceback_later @ linux-x86_64 +test.test_faulthandler.FaultHandlerTests.test_disable @ linux-x86_64 +test.test_faulthandler.FaultHandlerTests.test_is_enabled @ linux-x86_64 +test.test_faulthandler.FaultHandlerTests.test_sys_xoptions @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fcntl.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fcntl.txt new file mode 100644 index 0000000000..fb90c674c4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fcntl.txt @@ -0,0 +1,3 @@ +test.test_fcntl.TestFcntl.test_flock @ linux-x86_64 +test.test_fcntl.TestFcntl.test_lockf_exclusive @ linux-x86_64 +test.test_fcntl.TestFcntl.test_lockf_share @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_file.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_file.txt new file mode 100644 index 0000000000..323b57ee68 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_file.txt @@ -0,0 +1,30 @@ +test.test_file.CAutoFileTests.testAttributes @ linux-x86_64 +test.test_file.CAutoFileTests.testErrors @ linux-x86_64 +test.test_file.CAutoFileTests.testMethods @ linux-x86_64 +test.test_file.CAutoFileTests.testReadWhenWriting @ linux-x86_64 +test.test_file.CAutoFileTests.testReadinto @ linux-x86_64 +test.test_file.CAutoFileTests.testReadinto_text @ linux-x86_64 +test.test_file.CAutoFileTests.testWritelinesIntegers @ linux-x86_64 +test.test_file.CAutoFileTests.testWritelinesIntegersUserList @ linux-x86_64 +test.test_file.CAutoFileTests.testWritelinesNonString @ linux-x86_64 +test.test_file.CAutoFileTests.testWritelinesUserList @ linux-x86_64 +test.test_file.COtherFileTests.testBadModeArgument @ linux-x86_64 +test.test_file.COtherFileTests.testIteration @ linux-x86_64 +test.test_file.COtherFileTests.testModeStrings @ linux-x86_64 +test.test_file.COtherFileTests.testSetBufferSize @ linux-x86_64 +test.test_file.COtherFileTests.testTruncateOnWindows @ linux-x86_64 +test.test_file.PyAutoFileTests.testAttributes @ linux-x86_64 +test.test_file.PyAutoFileTests.testErrors @ linux-x86_64 +test.test_file.PyAutoFileTests.testMethods @ linux-x86_64 +test.test_file.PyAutoFileTests.testReadWhenWriting @ linux-x86_64 +test.test_file.PyAutoFileTests.testReadinto @ linux-x86_64 +test.test_file.PyAutoFileTests.testReadinto_text @ linux-x86_64 +test.test_file.PyAutoFileTests.testWritelinesIntegers @ linux-x86_64 +test.test_file.PyAutoFileTests.testWritelinesIntegersUserList @ linux-x86_64 +test.test_file.PyAutoFileTests.testWritelinesNonString @ linux-x86_64 +test.test_file.PyAutoFileTests.testWritelinesUserList @ linux-x86_64 +test.test_file.PyOtherFileTests.testBadModeArgument @ linux-x86_64 +test.test_file.PyOtherFileTests.testIteration @ linux-x86_64 +test.test_file.PyOtherFileTests.testModeStrings @ linux-x86_64 +test.test_file.PyOtherFileTests.testSetBufferSize @ linux-x86_64 +test.test_file.PyOtherFileTests.testTruncateOnWindows @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_filecmp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_filecmp.txt new file mode 100644 index 0000000000..627be31d25 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_filecmp.txt @@ -0,0 +1,9 @@ +test.test_filecmp.DirCompareTestCase.test_cmpfiles @ linux-x86_64 +test.test_filecmp.DirCompareTestCase.test_default_ignores @ linux-x86_64 +test.test_filecmp.DirCompareTestCase.test_dircmp @ linux-x86_64 +test.test_filecmp.DirCompareTestCase.test_dircmp_subdirs_type @ linux-x86_64 +test.test_filecmp.DirCompareTestCase.test_report_full_closure @ linux-x86_64 +test.test_filecmp.DirCompareTestCase.test_report_partial_closure @ linux-x86_64 +test.test_filecmp.FileCompareTestCase.test_cache_clear @ linux-x86_64 +test.test_filecmp.FileCompareTestCase.test_different @ linux-x86_64 +test.test_filecmp.FileCompareTestCase.test_matching @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileinput.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileinput.txt new file mode 100644 index 0000000000..d7b8216335 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileinput.txt @@ -0,0 +1,57 @@ +test.test_fileinput.BufferSizesTests.test_buffer_sizes @ linux-x86_64 +test.test_fileinput.FileInputTests.test_close_on_exception @ linux-x86_64 +test.test_fileinput.FileInputTests.test_context_manager @ linux-x86_64 +test.test_fileinput.FileInputTests.test_detached_stdin_binary_mode @ linux-x86_64 +test.test_fileinput.FileInputTests.test_empty_files_list_specified_to_constructor @ linux-x86_64 +test.test_fileinput.FileInputTests.test_file_hook_backward_compatibility @ linux-x86_64 +test.test_fileinput.FileInputTests.test_file_opening_hook @ linux-x86_64 +test.test_fileinput.FileInputTests.test_fileno @ linux-x86_64 +test.test_fileinput.FileInputTests.test_fileno_when_ValueError_raised @ linux-x86_64 +test.test_fileinput.FileInputTests.test_files_that_dont_end_with_newline @ linux-x86_64 +test.test_fileinput.FileInputTests.test_inplace_binary_write_mode @ linux-x86_64 +test.test_fileinput.FileInputTests.test_inplace_encoding_errors @ linux-x86_64 +test.test_fileinput.FileInputTests.test_invalid_opening_mode @ linux-x86_64 +test.test_fileinput.FileInputTests.test_iteration_buffering @ linux-x86_64 +test.test_fileinput.FileInputTests.test_nextfile_oserror_deleting_backup @ linux-x86_64 +test.test_fileinput.FileInputTests.test_pathlib_file @ linux-x86_64 +test.test_fileinput.FileInputTests.test_pathlib_file_inplace @ linux-x86_64 +test.test_fileinput.FileInputTests.test_readline @ linux-x86_64 +test.test_fileinput.FileInputTests.test_readline_binary_mode @ linux-x86_64 +test.test_fileinput.FileInputTests.test_readline_buffering @ linux-x86_64 +test.test_fileinput.FileInputTests.test_readline_os_chmod_raises_OSError @ linux-x86_64 +test.test_fileinput.FileInputTests.test_readline_os_fstat_raises_OSError @ linux-x86_64 +test.test_fileinput.FileInputTests.test_stdin_binary_mode @ linux-x86_64 +test.test_fileinput.FileInputTests.test_zero_byte_files @ linux-x86_64 +test.test_fileinput.MiscTest.test_all @ linux-x86_64 +test.test_fileinput.Test_fileinput_close.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_close.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_filelineno.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_filelineno.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_filename.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_filename.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_fileno.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_fileno.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_input.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_input.test_state_is_not_None_and_state_file_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_input.test_state_is_not_None_and_state_file_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_isfirstline.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_isfirstline.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_isstdin.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_isstdin.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_lineno.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_lineno.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_nextfile.test_state_is_None @ linux-x86_64 +test.test_fileinput.Test_fileinput_nextfile.test_state_is_not_None @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_binary_mode_encoding @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_blah_ext @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_bz2_ext_builtin @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_bz2_ext_fake @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_empty_string @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_gz_ext_builtin @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_gz_ext_fake @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_gz_with_encoding_fake @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_no_ext @ linux-x86_64 +test.test_fileinput.Test_hook_compressed.test_text_mode_encoding @ linux-x86_64 +test.test_fileinput.Test_hook_encoded.test @ linux-x86_64 +test.test_fileinput.Test_hook_encoded.test_errors @ linux-x86_64 +test.test_fileinput.Test_hook_encoded.test_modes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileio.txt new file mode 100644 index 0000000000..fb618fca01 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fileio.txt @@ -0,0 +1,87 @@ +test.test_fileio.CAutoFileTests.testAttributes @ linux-x86_64 +test.test_fileio.CAutoFileTests.testBlksize @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClose @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedFileno @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedIsatty @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedRead @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedReadable @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedReadall @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedReadinto @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedSeek @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedSeekable @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedTell @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedTruncate @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedWritable @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrnoOnClosedWrite @ linux-x86_64 +test.test_fileio.CAutoFileTests.testErrors @ linux-x86_64 +test.test_fileio.CAutoFileTests.testMethods @ linux-x86_64 +test.test_fileio.CAutoFileTests.testOpenDirFD @ linux-x86_64 +test.test_fileio.CAutoFileTests.testOpendir @ linux-x86_64 +test.test_fileio.CAutoFileTests.testReadintoByteArray @ linux-x86_64 +test.test_fileio.CAutoFileTests.testRepr @ linux-x86_64 +test.test_fileio.CAutoFileTests.testReprNoCloseFD @ linux-x86_64 +test.test_fileio.CAutoFileTests.testSeekTell @ linux-x86_64 +test.test_fileio.CAutoFileTests.testWritelinesError @ linux-x86_64 +test.test_fileio.CAutoFileTests.testWritelinesList @ linux-x86_64 +test.test_fileio.CAutoFileTests.testWritelinesUserList @ linux-x86_64 +test.test_fileio.CAutoFileTests.test_none_args @ linux-x86_64 +test.test_fileio.CAutoFileTests.test_reject @ linux-x86_64 +test.test_fileio.COtherFileTests.testAbles @ linux-x86_64 +test.test_fileio.COtherFileTests.testAppend @ linux-x86_64 +test.test_fileio.COtherFileTests.testBadModeArgument @ linux-x86_64 +test.test_fileio.COtherFileTests.testBytesOpen @ linux-x86_64 +test.test_fileio.COtherFileTests.testConstructorHandlesNULChars @ linux-x86_64 +test.test_fileio.COtherFileTests.testInvalidFd @ linux-x86_64 +test.test_fileio.COtherFileTests.testInvalidInit @ linux-x86_64 +test.test_fileio.COtherFileTests.testInvalidModeStrings @ linux-x86_64 +test.test_fileio.COtherFileTests.testModeStrings @ linux-x86_64 +test.test_fileio.COtherFileTests.testTruncate @ linux-x86_64 +test.test_fileio.COtherFileTests.testTruncateOnWindows @ linux-x86_64 +test.test_fileio.COtherFileTests.testUnclosedFDOnException @ linux-x86_64 +test.test_fileio.COtherFileTests.testUnicodeOpen @ linux-x86_64 +test.test_fileio.COtherFileTests.testUtf8BytesOpen @ linux-x86_64 +test.test_fileio.COtherFileTests.testWarnings @ linux-x86_64 +test.test_fileio.COtherFileTests.test_open_code @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testAttributes @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testBlksize @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClose @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedFileno @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedIsatty @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedRead @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedReadable @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedReadall @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedReadinto @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedSeek @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedSeekable @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedTell @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedTruncate @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedWritable @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrnoOnClosedWrite @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testErrors @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testMethods @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testOpenDirFD @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testOpendir @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testReadintoByteArray @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testRepr @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testReprNoCloseFD @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testSeekTell @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testWritelinesError @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testWritelinesList @ linux-x86_64 +test.test_fileio.PyAutoFileTests.testWritelinesUserList @ linux-x86_64 +test.test_fileio.PyAutoFileTests.test_none_args @ linux-x86_64 +test.test_fileio.PyAutoFileTests.test_reject @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testAbles @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testAppend @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testBadModeArgument @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testBytesOpen @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testConstructorHandlesNULChars @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testInvalidInit @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testInvalidModeStrings @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testModeStrings @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testTruncate @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testTruncateOnWindows @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testUnclosedFDOnException @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testUnicodeOpen @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testUtf8BytesOpen @ linux-x86_64 +test.test_fileio.PyOtherFileTests.testWarnings @ linux-x86_64 +test.test_fileio.PyOtherFileTests.test_open_code @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_float.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_float.txt new file mode 100644 index 0000000000..b1065333ca --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_float.txt @@ -0,0 +1,51 @@ +test.test_float.FormatFunctionsTestCase.test_getformat @ linux-x86_64 +test.test_float.FormatTestCase.test_format @ linux-x86_64 +test.test_float.FormatTestCase.test_format_testfile @ linux-x86_64 +test.test_float.FormatTestCase.test_issue35560 @ linux-x86_64 +test.test_float.FormatTestCase.test_issue5864 @ linux-x86_64 +test.test_float.GeneralFloatCases.test_error_message @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_ceil @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_containment @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_floor @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_memoryview @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_mod @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_pow @ linux-x86_64 +test.test_float.GeneralFloatCases.test_float_with_comma @ linux-x86_64 +test.test_float.GeneralFloatCases.test_floatasratio @ linux-x86_64 +test.test_float.GeneralFloatCases.test_floatconversion @ linux-x86_64 +test.test_float.GeneralFloatCases.test_hash @ linux-x86_64 +test.test_float.GeneralFloatCases.test_is_integer @ linux-x86_64 +test.test_float.GeneralFloatCases.test_keyword_args @ linux-x86_64 +test.test_float.GeneralFloatCases.test_noargs @ linux-x86_64 +test.test_float.GeneralFloatCases.test_non_numeric_input_types @ linux-x86_64 +test.test_float.GeneralFloatCases.test_underscores @ linux-x86_64 +test.test_float.HexFloatTestCase.test_ends @ linux-x86_64 +test.test_float.HexFloatTestCase.test_from_hex @ linux-x86_64 +test.test_float.HexFloatTestCase.test_invalid_inputs @ linux-x86_64 +test.test_float.HexFloatTestCase.test_roundtrip @ linux-x86_64 +test.test_float.HexFloatTestCase.test_subclass @ linux-x86_64 +test.test_float.HexFloatTestCase.test_whitespace @ linux-x86_64 +test.test_float.IEEEFormatTestCase.test_double_specials_do_unpack @ linux-x86_64 +test.test_float.IEEEFormatTestCase.test_float_specials_do_unpack @ linux-x86_64 +test.test_float.IEEEFormatTestCase.test_serialized_float_rounding @ linux-x86_64 +test.test_float.InfNanTest.test_inf_as_str @ linux-x86_64 +test.test_float.InfNanTest.test_inf_from_str @ linux-x86_64 +test.test_float.InfNanTest.test_inf_signs @ linux-x86_64 +test.test_float.InfNanTest.test_nan_as_str @ linux-x86_64 +test.test_float.InfNanTest.test_nan_from_str @ linux-x86_64 +test.test_float.InfNanTest.test_nan_signs @ linux-x86_64 +test.test_float.PackTests.test_pack @ linux-x86_64 +test.test_float.PackTests.test_roundtrip @ linux-x86_64 +test.test_float.PackTests.test_unpack @ linux-x86_64 +test.test_float.ReprTestCase.test_repr @ linux-x86_64 +test.test_float.ReprTestCase.test_short_repr @ linux-x86_64 +test.test_float.RoundTestCase.test_None_ndigits @ linux-x86_64 +test.test_float.RoundTestCase.test_format_specials @ linux-x86_64 +test.test_float.RoundTestCase.test_inf_nan @ linux-x86_64 +test.test_float.RoundTestCase.test_inf_nan_ndigits @ linux-x86_64 +test.test_float.RoundTestCase.test_large_n @ linux-x86_64 +test.test_float.RoundTestCase.test_matches_float_format @ linux-x86_64 +test.test_float.RoundTestCase.test_overflow @ linux-x86_64 +test.test_float.RoundTestCase.test_previous_round_bugs @ linux-x86_64 +test.test_float.RoundTestCase.test_small_n @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_flufl.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_flufl.txt new file mode 100644 index 0000000000..adab1d3902 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_flufl.txt @@ -0,0 +1 @@ +test.test_flufl.FLUFLTests.test_guido_as_bdfl @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fnmatch.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fnmatch.txt new file mode 100644 index 0000000000..9e89c85e12 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fnmatch.txt @@ -0,0 +1,17 @@ +test.test_fnmatch.FilterTestCase.test_case @ linux-x86_64 +test.test_fnmatch.FilterTestCase.test_filter @ linux-x86_64 +test.test_fnmatch.FilterTestCase.test_mix_bytes_str @ linux-x86_64 +test.test_fnmatch.FilterTestCase.test_sep @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_bytes @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_case @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_char_set @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_fnmatch @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_fnmatchcase @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_mix_bytes_str @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_range @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_sep @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_sep_in_char_set @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_sep_in_range @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_slow_fnmatch @ linux-x86_64 +test.test_fnmatch.FnmatchTestCase.test_warnings @ linux-x86_64 +test.test_fnmatch.TranslateTestCase.test_translate @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_format.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_format.txt new file mode 100644 index 0000000000..d90ff3ebf4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_format.txt @@ -0,0 +1,12 @@ +test.test_format.FormatTest.test_bytes_and_bytearray_format @ linux-x86_64 +test.test_format.FormatTest.test_common_format @ linux-x86_64 +test.test_format.FormatTest.test_g_format_has_no_trailing_zeros @ linux-x86_64 +test.test_format.FormatTest.test_locale @ linux-x86_64 +test.test_format.FormatTest.test_non_ascii @ linux-x86_64 +test.test_format.FormatTest.test_nul @ linux-x86_64 +test.test_format.FormatTest.test_precision @ linux-x86_64 +test.test_format.FormatTest.test_str_format @ linux-x86_64 +test.test_format.FormatTest.test_with_a_commas_and_an_underscore_in_format_specifier @ linux-x86_64 +test.test_format.FormatTest.test_with_an_underscore_and_a_comma_in_format_specifier @ linux-x86_64 +test.test_format.FormatTest.test_with_two_commas_in_format_specifier @ linux-x86_64 +test.test_format.FormatTest.test_with_two_underscore_in_format_specifier @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fractions.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fractions.txt new file mode 100644 index 0000000000..a2b7acbed6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fractions.txt @@ -0,0 +1,33 @@ +test.test_fractions.FractionTest.testApproximateCos1 @ linux-x86_64 +test.test_fractions.FractionTest.testApproximatePi @ linux-x86_64 +test.test_fractions.FractionTest.testArithmetic @ linux-x86_64 +test.test_fractions.FractionTest.testBigComplexComparisons @ linux-x86_64 +test.test_fractions.FractionTest.testBigFloatComparisons @ linux-x86_64 +test.test_fractions.FractionTest.testBoolGuarateesBoolReturn @ linux-x86_64 +test.test_fractions.FractionTest.testComparisons @ linux-x86_64 +test.test_fractions.FractionTest.testComparisonsDummyFloat @ linux-x86_64 +test.test_fractions.FractionTest.testComparisonsDummyRational @ linux-x86_64 +test.test_fractions.FractionTest.testConversions @ linux-x86_64 +test.test_fractions.FractionTest.testFromDecimal @ linux-x86_64 +test.test_fractions.FractionTest.testFromFloat @ linux-x86_64 +test.test_fractions.FractionTest.testFromString @ linux-x86_64 +test.test_fractions.FractionTest.testHash @ linux-x86_64 +test.test_fractions.FractionTest.testImmutable @ linux-x86_64 +test.test_fractions.FractionTest.testInit @ linux-x86_64 +test.test_fractions.FractionTest.testInitFromDecimal @ linux-x86_64 +test.test_fractions.FractionTest.testInitFromFloat @ linux-x86_64 +test.test_fractions.FractionTest.testIntGuaranteesIntReturn @ linux-x86_64 +test.test_fractions.FractionTest.testLargeArithmetic @ linux-x86_64 +test.test_fractions.FractionTest.testLimitDenominator @ linux-x86_64 +test.test_fractions.FractionTest.testMixedArithmetic @ linux-x86_64 +test.test_fractions.FractionTest.testMixedEqual @ linux-x86_64 +test.test_fractions.FractionTest.testMixedLess @ linux-x86_64 +test.test_fractions.FractionTest.testMixedLessEqual @ linux-x86_64 +test.test_fractions.FractionTest.testMixingWithDecimal @ linux-x86_64 +test.test_fractions.FractionTest.testRound @ linux-x86_64 +test.test_fractions.FractionTest.testStringification @ linux-x86_64 +test.test_fractions.FractionTest.testSupportsInt @ linux-x86_64 +test.test_fractions.FractionTest.test_as_integer_ratio @ linux-x86_64 +test.test_fractions.FractionTest.test_copy_deepcopy_pickle @ linux-x86_64 +test.test_fractions.FractionTest.test_int_subclass @ linux-x86_64 +test.test_fractions.FractionTest.test_slots @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frame.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frame.txt new file mode 100644 index 0000000000..ba0e568adc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frame.txt @@ -0,0 +1,5 @@ +test.test_frame.ClearTest.test_clear_does_not_clear_specials @ linux-x86_64 +test.test_frame.ClearTest.test_lineno_with_tracing @ linux-x86_64 +test.test_frame.FrameAttrsTest.test_f_lineno_del_segfault @ linux-x86_64 +test.test_frame.FrameAttrsTest.test_locals @ linux-x86_64 +test.test_frame.ReprTest.test_repr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frozen.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frozen.txt new file mode 100644 index 0000000000..9b6e502a8f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_frozen.txt @@ -0,0 +1,3 @@ +test.test_frozen.TestFrozen.test_frozen @ linux-x86_64 +test.test_frozen.TestFrozen.test_frozen_submodule_in_unfrozen_package @ linux-x86_64 +test.test_frozen.TestFrozen.test_unfrozen_submodule_in_frozen_package @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fstring.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fstring.txt new file mode 100644 index 0000000000..a47c1e7c43 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_fstring.txt @@ -0,0 +1,66 @@ +test.test_fstring.TestCase.test__format__lookup @ linux-x86_64 +test.test_fstring.TestCase.test_arguments @ linux-x86_64 +test.test_fstring.TestCase.test_assignment @ linux-x86_64 +test.test_fstring.TestCase.test_ast @ linux-x86_64 +test.test_fstring.TestCase.test_ast_compile_time_concat @ linux-x86_64 +test.test_fstring.TestCase.test_ast_line_numbers @ linux-x86_64 +test.test_fstring.TestCase.test_ast_line_numbers_duplicate_expression @ linux-x86_64 +test.test_fstring.TestCase.test_ast_line_numbers_multiple_formattedvalues @ linux-x86_64 +test.test_fstring.TestCase.test_ast_line_numbers_nested @ linux-x86_64 +test.test_fstring.TestCase.test_ast_numbers_fstring_with_formatting @ linux-x86_64 +test.test_fstring.TestCase.test_backslash_char @ linux-x86_64 +test.test_fstring.TestCase.test_backslashes_in_string_part @ linux-x86_64 +test.test_fstring.TestCase.test_call @ linux-x86_64 +test.test_fstring.TestCase.test_closure @ linux-x86_64 +test.test_fstring.TestCase.test_comments @ linux-x86_64 +test.test_fstring.TestCase.test_compile_time_concat @ linux-x86_64 +test.test_fstring.TestCase.test_compile_time_concat_errors @ linux-x86_64 +test.test_fstring.TestCase.test_conversions @ linux-x86_64 +test.test_fstring.TestCase.test_debug_conversion @ linux-x86_64 +test.test_fstring.TestCase.test_del @ linux-x86_64 +test.test_fstring.TestCase.test_dict @ linux-x86_64 +test.test_fstring.TestCase.test_docstring @ linux-x86_64 +test.test_fstring.TestCase.test_double_braces @ linux-x86_64 +test.test_fstring.TestCase.test_empty_format_specifier @ linux-x86_64 +test.test_fstring.TestCase.test_equal_equal @ linux-x86_64 +test.test_fstring.TestCase.test_errors @ linux-x86_64 +test.test_fstring.TestCase.test_expressions_with_triple_quoted_strings @ linux-x86_64 +test.test_fstring.TestCase.test_filename_in_syntaxerror @ linux-x86_64 +test.test_fstring.TestCase.test_format_specifier_expressions @ linux-x86_64 +test.test_fstring.TestCase.test_global @ linux-x86_64 +test.test_fstring.TestCase.test_if_conditional @ linux-x86_64 +test.test_fstring.TestCase.test_invalid_string_prefixes @ linux-x86_64 +test.test_fstring.TestCase.test_invalid_syntax_error_message @ linux-x86_64 +test.test_fstring.TestCase.test_lambda @ linux-x86_64 +test.test_fstring.TestCase.test_leading_trailing_spaces @ linux-x86_64 +test.test_fstring.TestCase.test_literal @ linux-x86_64 +test.test_fstring.TestCase.test_literal_eval @ linux-x86_64 +test.test_fstring.TestCase.test_locals @ linux-x86_64 +test.test_fstring.TestCase.test_loop @ linux-x86_64 +test.test_fstring.TestCase.test_many_expressions @ linux-x86_64 +test.test_fstring.TestCase.test_misformed_unicode_character_name @ linux-x86_64 +test.test_fstring.TestCase.test_mismatched_braces @ linux-x86_64 +test.test_fstring.TestCase.test_mismatched_parens @ linux-x86_64 +test.test_fstring.TestCase.test_missing_expression @ linux-x86_64 +test.test_fstring.TestCase.test_missing_format_spec @ linux-x86_64 +test.test_fstring.TestCase.test_missing_variable @ linux-x86_64 +test.test_fstring.TestCase.test_multiple_vars @ linux-x86_64 +test.test_fstring.TestCase.test_nested_fstrings @ linux-x86_64 +test.test_fstring.TestCase.test_newlines_before_syntax_error @ linux-x86_64 +test.test_fstring.TestCase.test_newlines_in_expressions @ linux-x86_64 +test.test_fstring.TestCase.test_no_backslashes_in_expression_part @ linux-x86_64 +test.test_fstring.TestCase.test_no_escapes_for_braces @ linux-x86_64 +test.test_fstring.TestCase.test_not_equal @ linux-x86_64 +test.test_fstring.TestCase.test_parens_in_expressions @ linux-x86_64 +test.test_fstring.TestCase.test_shadowed_global @ linux-x86_64 +test.test_fstring.TestCase.test_side_effect_order @ linux-x86_64 +test.test_fstring.TestCase.test_str_format_differences @ linux-x86_64 +test.test_fstring.TestCase.test_syntax_error_for_starred_expressions @ linux-x86_64 +test.test_fstring.TestCase.test_unterminated_string @ linux-x86_64 +test.test_fstring.TestCase.test_walrus @ linux-x86_64 +test.test_fstring.TestCase.test_with_a_commas_and_an_underscore_in_format_specifier @ linux-x86_64 +test.test_fstring.TestCase.test_with_an_underscore_and_a_comma_in_format_specifier @ linux-x86_64 +test.test_fstring.TestCase.test_with_two_commas_in_format_specifier @ linux-x86_64 +test.test_fstring.TestCase.test_with_two_underscore_in_format_specifier @ linux-x86_64 +test.test_fstring.TestCase.test_yield @ linux-x86_64 +test.test_fstring.TestCase.test_yield_send @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ftplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ftplib.txt new file mode 100644 index 0000000000..f96e315943 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ftplib.txt @@ -0,0 +1,93 @@ +test.test_ftplib.MiscTestCase.test__all__ @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_abort @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_acct @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_all_errors @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_cwd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_delete @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_dir @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_encoding_param @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_exceptions @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_getwelcome @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_line_too_long @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_login @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_makepasv @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_makepasv_issue43285_security_disabled @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_makepasv_issue43285_security_enabled_default @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_makeport @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_mkd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_mlsd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_nlst @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_parse257 @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_pwd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_quit @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_rename @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_retrbinary @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_retrbinary_rest @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_retrlines @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_retrlines_too_long @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_rmd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_sanitize @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_set_pasv @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_size @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_source_address @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_source_address_passive_connection @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_storbinary @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_storbinary_rest @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_storlines @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_storlines_too_long @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_voidcmd @ linux-x86_64 +test.test_ftplib.TestFTPClass.test_with_statement @ linux-x86_64 +test.test_ftplib.TestIPv6Environment.test_af @ linux-x86_64 +test.test_ftplib.TestIPv6Environment.test_makepasv @ linux-x86_64 +test.test_ftplib.TestIPv6Environment.test_makeport @ linux-x86_64 +test.test_ftplib.TestIPv6Environment.test_transfer @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_auth_issued_twice @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_ccc @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_context @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_control_connection @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_data_connection @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClass.test_login @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_abort @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_acct @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_all_errors @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_cwd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_delete @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_dir @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_encoding_param @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_exceptions @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_getwelcome @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_line_too_long @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_login @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_makepasv @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_makepasv_issue43285_security_disabled @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_makepasv_issue43285_security_enabled_default @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_makeport @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_mkd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_mlsd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_nlst @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_parse257 @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_pwd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_quit @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_rename @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_retrbinary @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_retrbinary_rest @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_retrlines @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_retrlines_too_long @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_rmd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_sanitize @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_set_pasv @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_size @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_source_address @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_source_address_passive_connection @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_storbinary @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_storbinary_rest @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_storlines @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_storlines_too_long @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_voidcmd @ linux-x86_64 +test.test_ftplib.TestTLS_FTPClassMixin.test_with_statement @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutConnect @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutDefault @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutDifferentOrder @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutDirectAccess @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutNone @ linux-x86_64 +test.test_ftplib.TestTimeouts.testTimeoutValue @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_funcattrs.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_funcattrs.txt new file mode 100644 index 0000000000..22e952bf33 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_funcattrs.txt @@ -0,0 +1,30 @@ +test.test_funcattrs.ArbitraryFunctionAttrTest.test_delete_unknown_attr @ linux-x86_64 +test.test_funcattrs.ArbitraryFunctionAttrTest.test_set_attr @ linux-x86_64 +test.test_funcattrs.ArbitraryFunctionAttrTest.test_unset_attr @ linux-x86_64 +test.test_funcattrs.BuiltinFunctionPropertiesTest.test_builtin__qualname__ @ linux-x86_64 +test.test_funcattrs.CellTest.test_comparison @ linux-x86_64 +test.test_funcattrs.FunctionDictsTest.test_delete___dict__ @ linux-x86_64 +test.test_funcattrs.FunctionDictsTest.test_func_as_dict_key @ linux-x86_64 +test.test_funcattrs.FunctionDictsTest.test_setting_dict_to_invalid @ linux-x86_64 +test.test_funcattrs.FunctionDictsTest.test_setting_dict_to_valid @ linux-x86_64 +test.test_funcattrs.FunctionDictsTest.test_unassigned_dict @ linux-x86_64 +test.test_funcattrs.FunctionDocstringTest.test_delete_docstring @ linux-x86_64 +test.test_funcattrs.FunctionDocstringTest.test_set_docstring_attr @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test___closure__ @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test___code__ @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test___globals__ @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test___name__ @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_blank_func_defaults @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_cell_new @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_copying___code__ @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_dir_includes_correct_attrs @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_duplicate_function_equality @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_empty_cell @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_func_default_args @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_module @ linux-x86_64 +test.test_funcattrs.FunctionPropertiesTest.test_set_cell @ linux-x86_64 +test.test_funcattrs.InstancemethodAttrTest.test___class__ @ linux-x86_64 +test.test_funcattrs.InstancemethodAttrTest.test___func__ @ linux-x86_64 +test.test_funcattrs.InstancemethodAttrTest.test___func___non_method @ linux-x86_64 +test.test_funcattrs.InstancemethodAttrTest.test___self__ @ linux-x86_64 +test.test_funcattrs.StaticMethodAttrsTest.test_func_attribute @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_functools.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_functools.txt new file mode 100644 index 0000000000..0f23b8017c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_functools.txt @@ -0,0 +1,243 @@ +test.test_functools.TestCachedProperty.test_access_from_class @ linux-x86_64 +test.test_functools.TestCachedProperty.test_cached @ linux-x86_64 +test.test_functools.TestCachedProperty.test_cached_attribute_name_differs_from_func_name @ linux-x86_64 +test.test_functools.TestCachedProperty.test_doc @ linux-x86_64 +test.test_functools.TestCachedProperty.test_immutable_dict @ linux-x86_64 +test.test_functools.TestCachedProperty.test_object_with_slots @ linux-x86_64 +test.test_functools.TestCachedProperty.test_reuse_different_names @ linux-x86_64 +test.test_functools.TestCachedProperty.test_reuse_same_name @ linux-x86_64 +test.test_functools.TestCachedProperty.test_set_name_not_called @ linux-x86_64 +test.test_functools.TestCachedProperty.test_threaded @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_bad_cmp @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_cmp_to_key @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_cmp_to_key_arguments @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_hash @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_obj_field @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_sort_int @ linux-x86_64 +test.test_functools.TestCmpToKeyC.test_sort_int_str @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_bad_cmp @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_cmp_to_key @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_cmp_to_key_arguments @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_hash @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_obj_field @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_sort_int @ linux-x86_64 +test.test_functools.TestCmpToKeyPy.test_sort_int_str @ linux-x86_64 +test.test_functools.TestLRUC.test_copy @ linux-x86_64 +test.test_functools.TestLRUC.test_deepcopy @ linux-x86_64 +test.test_functools.TestLRUC.test_kwargs_order @ linux-x86_64 +test.test_functools.TestLRUC.test_lru @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_bug_35780 @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_bug_36650 @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_decoration @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_parameters @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_threaded @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_threaded2 @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_threaded3 @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_cache_typed_is_not_recursive @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_hash_only_once @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_method @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_no_args @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_reentrancy_with_len @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_star_arg_handling @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_type_error @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_exceptions @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_keyword_args @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_keyword_args_maxsize_none @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_maxsize_negative @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_maxsize_none @ linux-x86_64 +test.test_functools.TestLRUC.test_lru_with_types @ linux-x86_64 +test.test_functools.TestLRUC.test_need_for_rlock @ linux-x86_64 +test.test_functools.TestLRUC.test_pickle @ linux-x86_64 +test.test_functools.TestLRUPy.test_copy @ linux-x86_64 +test.test_functools.TestLRUPy.test_deepcopy @ linux-x86_64 +test.test_functools.TestLRUPy.test_kwargs_order @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_bug_35780 @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_bug_36650 @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_decoration @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_parameters @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_threaded @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_threaded2 @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_threaded3 @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_cache_typed_is_not_recursive @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_hash_only_once @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_method @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_no_args @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_reentrancy_with_len @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_star_arg_handling @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_type_error @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_exceptions @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_keyword_args @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_keyword_args_maxsize_none @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_maxsize_negative @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_maxsize_none @ linux-x86_64 +test.test_functools.TestLRUPy.test_lru_with_types @ linux-x86_64 +test.test_functools.TestLRUPy.test_need_for_rlock @ linux-x86_64 +test.test_functools.TestLRUPy.test_pickle @ linux-x86_64 +test.test_functools.TestPartialC.test_arg_combinations @ linux-x86_64 +test.test_functools.TestPartialC.test_argument_checking @ linux-x86_64 +test.test_functools.TestPartialC.test_attributes @ linux-x86_64 +test.test_functools.TestPartialC.test_attributes_unwritable @ linux-x86_64 +test.test_functools.TestPartialC.test_basic_examples @ linux-x86_64 +test.test_functools.TestPartialC.test_copy @ linux-x86_64 +test.test_functools.TestPartialC.test_deepcopy @ linux-x86_64 +test.test_functools.TestPartialC.test_error_propagation @ linux-x86_64 +test.test_functools.TestPartialC.test_keystr_replaces_value @ linux-x86_64 +test.test_functools.TestPartialC.test_keyword @ linux-x86_64 +test.test_functools.TestPartialC.test_kw_combinations @ linux-x86_64 +test.test_functools.TestPartialC.test_kwargs_copy @ linux-x86_64 +test.test_functools.TestPartialC.test_manually_adding_non_string_keyword @ linux-x86_64 +test.test_functools.TestPartialC.test_nested_optimization @ linux-x86_64 +test.test_functools.TestPartialC.test_nested_partial_with_attribute @ linux-x86_64 +test.test_functools.TestPartialC.test_no_side_effects @ linux-x86_64 +test.test_functools.TestPartialC.test_pickle @ linux-x86_64 +test.test_functools.TestPartialC.test_positional @ linux-x86_64 +test.test_functools.TestPartialC.test_protection_of_callers_dict_argument @ linux-x86_64 +!test.test_functools.TestPartialC.test_recursive_pickle @ linux-x86_64 +test.test_functools.TestPartialC.test_recursive_repr @ linux-x86_64 +test.test_functools.TestPartialC.test_repr @ linux-x86_64 +test.test_functools.TestPartialC.test_setstate @ linux-x86_64 +test.test_functools.TestPartialC.test_setstate_errors @ linux-x86_64 +test.test_functools.TestPartialC.test_setstate_refcount @ linux-x86_64 +test.test_functools.TestPartialC.test_setstate_subclasses @ linux-x86_64 +test.test_functools.TestPartialC.test_with_bound_and_unbound_methods @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_arg_combinations @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_argument_checking @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_attributes @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_attributes_unwritable @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_basic_examples @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_copy @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_deepcopy @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_error_propagation @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_keystr_replaces_value @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_keyword @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_kw_combinations @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_kwargs_copy @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_manually_adding_non_string_keyword @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_nested_partial_with_attribute @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_no_side_effects @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_pickle @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_positional @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_protection_of_callers_dict_argument @ linux-x86_64 +!test.test_functools.TestPartialCSubclass.test_recursive_pickle @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_recursive_repr @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_repr @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_setstate @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_setstate_errors @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_setstate_refcount @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_setstate_subclasses @ linux-x86_64 +test.test_functools.TestPartialCSubclass.test_with_bound_and_unbound_methods @ linux-x86_64 +test.test_functools.TestPartialMethod.test_abstract @ linux-x86_64 +test.test_functools.TestPartialMethod.test_arg_combinations @ linux-x86_64 +test.test_functools.TestPartialMethod.test_bound_method_introspection @ linux-x86_64 +test.test_functools.TestPartialMethod.test_descriptors @ linux-x86_64 +test.test_functools.TestPartialMethod.test_invalid_args @ linux-x86_64 +test.test_functools.TestPartialMethod.test_nested @ linux-x86_64 +test.test_functools.TestPartialMethod.test_over_partial @ linux-x86_64 +test.test_functools.TestPartialMethod.test_overriding_keywords @ linux-x86_64 +test.test_functools.TestPartialMethod.test_positional_only @ linux-x86_64 +test.test_functools.TestPartialMethod.test_repr @ linux-x86_64 +test.test_functools.TestPartialMethod.test_unbound_method_retrieval @ linux-x86_64 +test.test_functools.TestPartialPy.test_arg_combinations @ linux-x86_64 +test.test_functools.TestPartialPy.test_argument_checking @ linux-x86_64 +test.test_functools.TestPartialPy.test_attributes @ linux-x86_64 +test.test_functools.TestPartialPy.test_basic_examples @ linux-x86_64 +test.test_functools.TestPartialPy.test_copy @ linux-x86_64 +test.test_functools.TestPartialPy.test_deepcopy @ linux-x86_64 +test.test_functools.TestPartialPy.test_error_propagation @ linux-x86_64 +test.test_functools.TestPartialPy.test_keyword @ linux-x86_64 +test.test_functools.TestPartialPy.test_kw_combinations @ linux-x86_64 +test.test_functools.TestPartialPy.test_kwargs_copy @ linux-x86_64 +test.test_functools.TestPartialPy.test_nested_optimization @ linux-x86_64 +test.test_functools.TestPartialPy.test_nested_partial_with_attribute @ linux-x86_64 +test.test_functools.TestPartialPy.test_no_side_effects @ linux-x86_64 +test.test_functools.TestPartialPy.test_pickle @ linux-x86_64 +test.test_functools.TestPartialPy.test_positional @ linux-x86_64 +test.test_functools.TestPartialPy.test_protection_of_callers_dict_argument @ linux-x86_64 +!test.test_functools.TestPartialPy.test_recursive_pickle @ linux-x86_64 +test.test_functools.TestPartialPy.test_recursive_repr @ linux-x86_64 +test.test_functools.TestPartialPy.test_repr @ linux-x86_64 +test.test_functools.TestPartialPy.test_setstate @ linux-x86_64 +test.test_functools.TestPartialPy.test_setstate_errors @ linux-x86_64 +test.test_functools.TestPartialPy.test_setstate_refcount @ linux-x86_64 +test.test_functools.TestPartialPy.test_setstate_subclasses @ linux-x86_64 +test.test_functools.TestPartialPy.test_with_bound_and_unbound_methods @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_arg_combinations @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_argument_checking @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_attributes @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_basic_examples @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_copy @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_deepcopy @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_error_propagation @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_keyword @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_kw_combinations @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_kwargs_copy @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_nested_optimization @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_nested_partial_with_attribute @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_no_side_effects @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_pickle @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_positional @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_protection_of_callers_dict_argument @ linux-x86_64 +!test.test_functools.TestPartialPySubclass.test_recursive_pickle @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_recursive_repr @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_repr @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_setstate @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_setstate_errors @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_setstate_refcount @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_setstate_subclasses @ linux-x86_64 +test.test_functools.TestPartialPySubclass.test_with_bound_and_unbound_methods @ linux-x86_64 +test.test_functools.TestReduceC.test_iterator_usage @ linux-x86_64 +test.test_functools.TestReduceC.test_reduce @ linux-x86_64 +test.test_functools.TestReducePy.test_iterator_usage @ linux-x86_64 +test.test_functools.TestReducePy.test_reduce @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_abstractmethod_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_annotations @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_c3_abc @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_cache_invalidation @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_callable_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_classmethod_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_classmethod_type_ann_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_compose_mro @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_double_wrapped_methods @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_false_meta @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_invalid_positional_argument @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_invalid_registrations @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_method_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_method_wrapping_attributes @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_mro @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_mro_conflicts @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_register_abc @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_register_decorator @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_register_genericalias @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_register_genericalias_annotation @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_register_genericalias_decorator @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_simple_overloads @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_staticmethod_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_staticmethod_type_ann_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_type_ann_register @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_union @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_union_None @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_union_conflict @ linux-x86_64 +test.test_functools.TestSingleDispatch.test_wrapping_attributes @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_no_operations_defined @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_notimplemented @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_pickle @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_for_metaclasses_issue_44605 @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_ge @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_gt @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_le @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_lt @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_total_ordering_no_overwrite @ linux-x86_64 +test.test_functools.TestTotalOrdering.test_type_error_when_not_implemented @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_builtin_update @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_default_update @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_default_update_doc @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_missing_attributes @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_no_update @ linux-x86_64 +test.test_functools.TestUpdateWrapper.test_selective_update @ linux-x86_64 +test.test_functools.TestWraps.test_builtin_update @ linux-x86_64 +test.test_functools.TestWraps.test_default_update @ linux-x86_64 +test.test_functools.TestWraps.test_default_update_doc @ linux-x86_64 +test.test_functools.TestWraps.test_missing_attributes @ linux-x86_64 +test.test_functools.TestWraps.test_no_update @ linux-x86_64 +test.test_functools.TestWraps.test_selective_update @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_future_stmt.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_future_stmt.txt new file mode 100644 index 0000000000..882a010086 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_future_stmt.txt @@ -0,0 +1,27 @@ +test.test_future_stmt.test_future.AnnotationsFutureTestCase.test_annotation_with_complex_target @ linux-x86_64 +test.test_future_stmt.test_future.AnnotationsFutureTestCase.test_annotations_forbidden @ linux-x86_64 +test.test_future_stmt.test_future.AnnotationsFutureTestCase.test_annotations_symbol_table_pass @ linux-x86_64 +test.test_future_stmt.test_future.AnnotationsFutureTestCase.test_get_type_hints_on_func_with_variadic_arg @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture10 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture3 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture4 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture5 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture6 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture8 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_badfuture9 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_ensure_flags_dont_clash @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_future1 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_future2 @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_future_multiple_features @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_future_multiple_imports @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_future_single_import @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_parserhack @ linux-x86_64 +test.test_future_stmt.test_future.FutureTest.test_unicode_literals_exec @ linux-x86_64 +test.test_future_stmt.test_future_flags.FutureTest.test_attributes @ linux-x86_64 +test.test_future_stmt.test_future_flags.FutureTest.test_names @ linux-x86_64 +test.test_future_stmt.test_future_multiple_features.TestMultipleFeatures.test_print_function @ linux-x86_64 +test.test_future_stmt.test_future_multiple_features.TestMultipleFeatures.test_unicode_literals @ linux-x86_64 +test.test_future_stmt.test_future_multiple_imports.Tests.test_unicode_literals @ linux-x86_64 +test.test_future_stmt.test_future_single_import.TestFuture.test_floor_div_operator @ linux-x86_64 +test.test_future_stmt.test_future_single_import.TestFuture.test_nested_scopes @ linux-x86_64 +test.test_future_stmt.test_future_single_import.TestFuture.test_true_div_as_default @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gc.txt new file mode 100644 index 0000000000..060f29052b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gc.txt @@ -0,0 +1,4 @@ +test.test_gc.GCTests.test_bug21435 @ linux-x86_64 +test.test_gc.GCTests.test_trash_weakref_clear @ linux-x86_64 +test.test_gc.GCTests.test_trashcan @ linux-x86_64 +test.test_gc.PythonFinalizationTests.test_ast_fini @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generator_stop.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generator_stop.txt new file mode 100644 index 0000000000..15823559d7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generator_stop.txt @@ -0,0 +1,2 @@ +test.test_generator_stop.TestPEP479.test_stopiteration_wrapping @ linux-x86_64 +test.test_generator_stop.TestPEP479.test_stopiteration_wrapping_context @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generators.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generators.txt new file mode 100644 index 0000000000..9b87a9580c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generators.txt @@ -0,0 +1,19 @@ +DocTestCase.test.test_generators.__test__.conjoin @ linux-x86_64 +DocTestCase.test.test_generators.__test__.coroutine @ linux-x86_64 +DocTestCase.test.test_generators.__test__.fun @ linux-x86_64 +DocTestCase.test.test_generators.__test__.pep @ linux-x86_64 +DocTestCase.test.test_generators.__test__.refleaks @ linux-x86_64 +DocTestCase.test.test_generators.__test__.syntax @ linux-x86_64 +DocTestCase.test.test_generators.__test__.tut @ linux-x86_64 +DocTestCase.test.test_generators.__test__.weakref @ linux-x86_64 +test.test_generators.ExceptionTest.test_except_throw_bad_exception @ linux-x86_64 +test.test_generators.ExceptionTest.test_return_stopiteration @ linux-x86_64 +test.test_generators.ExceptionTest.test_return_tuple @ linux-x86_64 +test.test_generators.ExceptionTest.test_stopiteration_error @ linux-x86_64 +test.test_generators.ExceptionTest.test_tutorial_stopiteration @ linux-x86_64 +test.test_generators.GeneratorStackTraceTest.test_send_with_yield_from @ linux-x86_64 +test.test_generators.GeneratorStackTraceTest.test_throw_with_yield_from @ linux-x86_64 +test.test_generators.GeneratorTest.test_copy @ linux-x86_64 +test.test_generators.GeneratorTest.test_pickle @ linux-x86_64 +test.test_generators.GeneratorTest.test_send_non_none_to_new_gen @ linux-x86_64 +test.test_generators.GeneratorThrowTest.test_throw_after_none_exc_type @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericalias.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericalias.txt new file mode 100644 index 0000000000..597b9f718e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericalias.txt @@ -0,0 +1,29 @@ +test.test_genericalias.BaseTest.test_calling_next_twice_raises_stopiteration @ linux-x86_64 +test.test_genericalias.BaseTest.test_class_methods @ linux-x86_64 +test.test_genericalias.BaseTest.test_copy @ linux-x86_64 +test.test_genericalias.BaseTest.test_del_iter @ linux-x86_64 +test.test_genericalias.BaseTest.test_dir @ linux-x86_64 +test.test_genericalias.BaseTest.test_equality @ linux-x86_64 +test.test_genericalias.BaseTest.test_exposed_type @ linux-x86_64 +test.test_genericalias.BaseTest.test_generic_subclass @ linux-x86_64 +test.test_genericalias.BaseTest.test_instantiate @ linux-x86_64 +test.test_genericalias.BaseTest.test_isinstance @ linux-x86_64 +test.test_genericalias.BaseTest.test_issubclass @ linux-x86_64 +test.test_genericalias.BaseTest.test_iter_creates_starred_tuple @ linux-x86_64 +test.test_genericalias.BaseTest.test_no_chaining @ linux-x86_64 +test.test_genericalias.BaseTest.test_no_kwargs @ linux-x86_64 +test.test_genericalias.BaseTest.test_parameter_chaining @ linux-x86_64 +test.test_genericalias.BaseTest.test_parameters @ linux-x86_64 +test.test_genericalias.BaseTest.test_pickle @ linux-x86_64 +test.test_genericalias.BaseTest.test_repr @ linux-x86_64 +test.test_genericalias.BaseTest.test_subclassing @ linux-x86_64 +test.test_genericalias.BaseTest.test_subclassing_types_genericalias @ linux-x86_64 +test.test_genericalias.BaseTest.test_type_generic @ linux-x86_64 +test.test_genericalias.BaseTest.test_type_subclass_generic @ linux-x86_64 +test.test_genericalias.BaseTest.test_unbound_methods @ linux-x86_64 +test.test_genericalias.BaseTest.test_union @ linux-x86_64 +test.test_genericalias.BaseTest.test_union_generic @ linux-x86_64 +test.test_genericalias.BaseTest.test_unpack @ linux-x86_64 +test.test_genericalias.BaseTest.test_unsubscriptable @ linux-x86_64 +test.test_genericalias.TypeIterationTests.test_cannot_iterate @ linux-x86_64 +test.test_genericalias.TypeIterationTests.test_is_not_instance_of_iterable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericclass.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericclass.txt new file mode 100644 index 0000000000..dbcbd8dee2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericclass.txt @@ -0,0 +1,21 @@ +test.test_genericclass.TestClassGetitem.test_class_getitem @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_classmethod @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_errors @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_errors_2 @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_format @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_inheritance @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_inheritance_2 @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_metaclass @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_metaclass_first @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_patched @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_with_builtins @ linux-x86_64 +test.test_genericclass.TestClassGetitem.test_class_getitem_with_metaclass @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_errors @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_errors_2 @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_metaclass @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_none @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_signature @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_type_call @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_with_builtins @ linux-x86_64 +test.test_genericclass.TestMROEntry.test_mro_entry_with_builtins_2 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericpath.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericpath.txt new file mode 100644 index 0000000000..123bc7545c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genericpath.txt @@ -0,0 +1,24 @@ +test.test_genericpath.PathLikeTests.test_path_commonprefix @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_exists @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_getctime @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_getmtime @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_getsize @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_isdir @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_isfile @ linux-x86_64 +test.test_genericpath.PathLikeTests.test_path_samefile @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_commonprefix @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_exists @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_exists_fd @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_filetime @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_getsize @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_invalid_paths @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_isdir @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_isfile @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_no_argument @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samefile @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samefile_on_link @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samefile_on_symlink @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_sameopenfile @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samestat @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samestat_on_link @ linux-x86_64 +test.test_genericpath.TestGenericTest.test_samestat_on_symlink @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genexps.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_genexps.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getopt.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getopt.txt new file mode 100644 index 0000000000..8cd52c58d6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getopt.txt @@ -0,0 +1,8 @@ +DocTestCase.test.test_getopt.test_libref_examples @ linux-x86_64 +test.test_getopt.GetoptTests.test_do_longs @ linux-x86_64 +test.test_getopt.GetoptTests.test_do_shorts @ linux-x86_64 +test.test_getopt.GetoptTests.test_getopt @ linux-x86_64 +test.test_getopt.GetoptTests.test_gnu_getopt @ linux-x86_64 +test.test_getopt.GetoptTests.test_issue4629 @ linux-x86_64 +test.test_getopt.GetoptTests.test_long_has_args @ linux-x86_64 +test.test_getopt.GetoptTests.test_short_has_arg @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getpass.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getpass.txt new file mode 100644 index 0000000000..581d65f3a0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_getpass.txt @@ -0,0 +1,14 @@ +test.test_getpass.GetpassGetuserTest.test_username_falls_back_to_pwd @ linux-x86_64 +test.test_getpass.GetpassGetuserTest.test_username_priorities_of_env_values @ linux-x86_64 +test.test_getpass.GetpassGetuserTest.test_username_takes_username_from_env @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_flushes_stream_after_prompt @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_raises_on_empty_input @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_trims_trailing_newline @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_uses_stderr_as_default @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_uses_stdin_as_default_input @ linux-x86_64 +test.test_getpass.GetpassRawinputTest.test_uses_stdin_as_different_locale @ linux-x86_64 +test.test_getpass.UnixGetpassTest.test_falls_back_to_fallback_if_termios_raises @ linux-x86_64 +test.test_getpass.UnixGetpassTest.test_falls_back_to_stdin @ linux-x86_64 +test.test_getpass.UnixGetpassTest.test_flushes_stream_after_input @ linux-x86_64 +test.test_getpass.UnixGetpassTest.test_resets_termios @ linux-x86_64 +test.test_getpass.UnixGetpassTest.test_uses_tty_directly @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gettext.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gettext.txt new file mode 100644 index 0000000000..34862ff8fe --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gettext.txt @@ -0,0 +1,43 @@ +test.test_gettext.GNUTranslationParsingTest.test_ignore_comments_in_headers_issue36239 @ linux-x86_64 +test.test_gettext.GNUTranslationParsingTest.test_plural_form_error_issue17898 @ linux-x86_64 +test.test_gettext.GNUTranslationsClassPluralFormsTestCase.test_plural_context_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsClassPluralFormsTestCase.test_plural_context_forms_null_translations @ linux-x86_64 +test.test_gettext.GNUTranslationsClassPluralFormsTestCase.test_plural_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsClassPluralFormsTestCase.test_plural_forms_null_translations @ linux-x86_64 +test.test_gettext.GNUTranslationsClassPluralFormsTestCase.test_plural_wrong_context_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsPluralFormsTestCase.test_plural_context_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsPluralFormsTestCase.test_plural_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsPluralFormsTestCase.test_plural_wrong_context_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsWithDomainPluralFormsTestCase.test_plural_context_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsWithDomainPluralFormsTestCase.test_plural_context_forms_wrong_domain @ linux-x86_64 +test.test_gettext.GNUTranslationsWithDomainPluralFormsTestCase.test_plural_forms @ linux-x86_64 +test.test_gettext.GNUTranslationsWithDomainPluralFormsTestCase.test_plural_forms_wrong_domain @ linux-x86_64 +test.test_gettext.GNUTranslationsWithDomainPluralFormsTestCase.test_plural_wrong_context_forms @ linux-x86_64 +test.test_gettext.GettextCacheTestCase.test_cache @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_double_quotes @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_multiline_strings @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_some_translations @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_some_translations_with_context @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_the_alternative_interface @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_triple_double_quotes @ linux-x86_64 +test.test_gettext.GettextTestCase1.test_triple_single_quotes @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_bad_major_version @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_bad_minor_version @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_bindtextdomain @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_double_quotes @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_multiline_strings @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_some_translations @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_some_translations_with_context @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_some_translations_with_context_and_domain @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_textdomain @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_triple_double_quotes @ linux-x86_64 +test.test_gettext.GettextTestCase2.test_triple_single_quotes @ linux-x86_64 +test.test_gettext.MiscTestCase.test__all__ @ linux-x86_64 +test.test_gettext.UnicodeTranslationsPluralTest.test_unicode_context_msgid @ linux-x86_64 +test.test_gettext.UnicodeTranslationsPluralTest.test_unicode_msgid @ linux-x86_64 +test.test_gettext.UnicodeTranslationsPluralTest.test_unicode_msgstr @ linux-x86_64 +test.test_gettext.UnicodeTranslationsPluralTest.test_unicode_msgstr_with_context @ linux-x86_64 +test.test_gettext.UnicodeTranslationsTest.test_unicode_context_msgstr @ linux-x86_64 +test.test_gettext.UnicodeTranslationsTest.test_unicode_msgid @ linux-x86_64 +test.test_gettext.UnicodeTranslationsTest.test_unicode_msgstr @ linux-x86_64 +test.test_gettext.WeirdMetadataTest.test_weird_metadata @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_glob.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_glob.txt new file mode 100644 index 0000000000..25bb39a632 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_glob.txt @@ -0,0 +1,14 @@ +test.test_glob.GlobTests.test_escape @ linux-x86_64 +test.test_glob.GlobTests.test_glob_broken_symlinks @ linux-x86_64 +test.test_glob.GlobTests.test_glob_bytes_directory_with_trailing_slash @ linux-x86_64 +test.test_glob.GlobTests.test_glob_directory_names @ linux-x86_64 +test.test_glob.GlobTests.test_glob_directory_with_trailing_slash @ linux-x86_64 +test.test_glob.GlobTests.test_glob_empty_pattern @ linux-x86_64 +test.test_glob.GlobTests.test_glob_literal @ linux-x86_64 +test.test_glob.GlobTests.test_glob_many_open_files @ linux-x86_64 +test.test_glob.GlobTests.test_glob_nested_directory @ linux-x86_64 +test.test_glob.GlobTests.test_glob_one_directory @ linux-x86_64 +test.test_glob.GlobTests.test_glob_symlinks @ linux-x86_64 +test.test_glob.GlobTests.test_hidden_glob @ linux-x86_64 +test.test_glob.GlobTests.test_recursive_glob @ linux-x86_64 +!test.test_glob.SymlinkLoopGlobTests.test_selflink @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_global.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_global.txt new file mode 100644 index 0000000000..2238dcc5f3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_global.txt @@ -0,0 +1,4 @@ +test.test_global.GlobalTests.test1 @ linux-x86_64 +test.test_global.GlobalTests.test2 @ linux-x86_64 +test.test_global.GlobalTests.test3 @ linux-x86_64 +test.test_global.GlobalTests.test4 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_grammar.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_grammar.txt new file mode 100644 index 0000000000..92ca68e163 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_grammar.txt @@ -0,0 +1,67 @@ +test.test_grammar.GrammarTests.test_additive_ops @ linux-x86_64 +test.test_grammar.GrammarTests.test_annotations_inheritance @ linux-x86_64 +test.test_grammar.GrammarTests.test_assert @ linux-x86_64 +test.test_grammar.GrammarTests.test_assert_failures @ linux-x86_64 +test.test_grammar.GrammarTests.test_async_await @ linux-x86_64 +test.test_grammar.GrammarTests.test_atoms @ linux-x86_64 +test.test_grammar.GrammarTests.test_binary_mask_ops @ linux-x86_64 +test.test_grammar.GrammarTests.test_break_continue_loop @ linux-x86_64 +test.test_grammar.GrammarTests.test_break_in_finally @ linux-x86_64 +test.test_grammar.GrammarTests.test_break_in_finally_after_return @ linux-x86_64 +test.test_grammar.GrammarTests.test_break_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_classdef @ linux-x86_64 +test.test_grammar.GrammarTests.test_comparison @ linux-x86_64 +test.test_grammar.GrammarTests.test_comparison_is_literal @ linux-x86_64 +test.test_grammar.GrammarTests.test_comprehension_specials @ linux-x86_64 +test.test_grammar.GrammarTests.test_continue_in_finally @ linux-x86_64 +test.test_grammar.GrammarTests.test_continue_in_finally_after_return @ linux-x86_64 +test.test_grammar.GrammarTests.test_continue_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_del_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_dictcomps @ linux-x86_64 +test.test_grammar.GrammarTests.test_eval_input @ linux-x86_64 +test.test_grammar.GrammarTests.test_expr_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_for @ linux-x86_64 +test.test_grammar.GrammarTests.test_former_statements_refer_to_builtins @ linux-x86_64 +test.test_grammar.GrammarTests.test_funcdef @ linux-x86_64 +test.test_grammar.GrammarTests.test_genexps @ linux-x86_64 +test.test_grammar.GrammarTests.test_global @ linux-x86_64 +test.test_grammar.GrammarTests.test_if @ linux-x86_64 +test.test_grammar.GrammarTests.test_if_else_expr @ linux-x86_64 +test.test_grammar.GrammarTests.test_import @ linux-x86_64 +test.test_grammar.GrammarTests.test_lambdef @ linux-x86_64 +test.test_grammar.GrammarTests.test_listcomps @ linux-x86_64 +test.test_grammar.GrammarTests.test_matrix_mul @ linux-x86_64 +test.test_grammar.GrammarTests.test_multiplicative_ops @ linux-x86_64 +test.test_grammar.GrammarTests.test_nonlocal @ linux-x86_64 +test.test_grammar.GrammarTests.test_paren_evaluation @ linux-x86_64 +test.test_grammar.GrammarTests.test_pass_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_raise @ linux-x86_64 +test.test_grammar.GrammarTests.test_return @ linux-x86_64 +test.test_grammar.GrammarTests.test_return_in_finally @ linux-x86_64 +test.test_grammar.GrammarTests.test_selectors @ linux-x86_64 +test.test_grammar.GrammarTests.test_shift_ops @ linux-x86_64 +test.test_grammar.GrammarTests.test_simple_stmt @ linux-x86_64 +test.test_grammar.GrammarTests.test_suite @ linux-x86_64 +test.test_grammar.GrammarTests.test_test @ linux-x86_64 +test.test_grammar.GrammarTests.test_try @ linux-x86_64 +test.test_grammar.GrammarTests.test_unary_ops @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_basic_semantics @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_basics @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_in_module @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_module_semantics @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_rhs @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_simple_exec @ linux-x86_64 +test.test_grammar.GrammarTests.test_var_annot_syntax_errors @ linux-x86_64 +test.test_grammar.GrammarTests.test_while @ linux-x86_64 +test.test_grammar.GrammarTests.test_with_statement @ linux-x86_64 +test.test_grammar.TokenTests.test_backslash @ linux-x86_64 +test.test_grammar.TokenTests.test_bad_numerical_literals @ linux-x86_64 +test.test_grammar.TokenTests.test_ellipsis @ linux-x86_64 +test.test_grammar.TokenTests.test_end_of_numerical_literals @ linux-x86_64 +test.test_grammar.TokenTests.test_eof_error @ linux-x86_64 +test.test_grammar.TokenTests.test_float_exponent_tokenization @ linux-x86_64 +test.test_grammar.TokenTests.test_floats @ linux-x86_64 +test.test_grammar.TokenTests.test_long_integers @ linux-x86_64 +test.test_grammar.TokenTests.test_plain_integers @ linux-x86_64 +test.test_grammar.TokenTests.test_string_literals @ linux-x86_64 +test.test_grammar.TokenTests.test_underscore_literals @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_graphlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_graphlib.txt new file mode 100644 index 0000000000..54dd30a3ef --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_graphlib.txt @@ -0,0 +1,15 @@ +test.test_graphlib.TestTopologicalSort.test_add_dependencies_for_same_node_incrementally @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_calls_before_prepare @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_cycle @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_done @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_empty @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_graph_with_iterables @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_invalid_nodes_in_done @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_is_active @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_no_dependencies @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_not_hashable_nodes @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_order_of_insertion_does_not_matter_between_groups @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_prepare_multiple_times @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_simple_cases @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_static_order_does_not_change_with_the_hash_seed @ linux-x86_64 +test.test_graphlib.TestTopologicalSort.test_the_node_multiple_times @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gzip.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gzip.txt new file mode 100644 index 0000000000..e77957a1c2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_gzip.txt @@ -0,0 +1,61 @@ +test.test_gzip.TestCommandLine.test_compress_fast_best_are_exclusive @ linux-x86_64 +test.test_gzip.TestCommandLine.test_compress_infile_outfile @ linux-x86_64 +test.test_gzip.TestCommandLine.test_compress_infile_outfile_default @ linux-x86_64 +test.test_gzip.TestCommandLine.test_decompress_cannot_have_flags_compression @ linux-x86_64 +test.test_gzip.TestCommandLine.test_decompress_infile_outfile @ linux-x86_64 +test.test_gzip.TestCommandLine.test_decompress_infile_outfile_error @ linux-x86_64 +test.test_gzip.TestGzip.test_1647484 @ linux-x86_64 +test.test_gzip.TestGzip.test_append @ linux-x86_64 +test.test_gzip.TestGzip.test_bad_gzip_file @ linux-x86_64 +test.test_gzip.TestGzip.test_buffered_reader @ linux-x86_64 +test.test_gzip.TestGzip.test_compress @ linux-x86_64 +test.test_gzip.TestGzip.test_compress_correct_level @ linux-x86_64 +test.test_gzip.TestGzip.test_compress_mtime @ linux-x86_64 +test.test_gzip.TestGzip.test_compresslevel_metadata @ linux-x86_64 +test.test_gzip.TestGzip.test_decompress @ linux-x86_64 +test.test_gzip.TestGzip.test_decompress_limited @ linux-x86_64 +test.test_gzip.TestGzip.test_decompress_missing_trailer @ linux-x86_64 +test.test_gzip.TestGzip.test_decompress_truncated_trailer @ linux-x86_64 +test.test_gzip.TestGzip.test_exclusive_write @ linux-x86_64 +test.test_gzip.TestGzip.test_fileobj_from_fdopen @ linux-x86_64 +test.test_gzip.TestGzip.test_fileobj_mode @ linux-x86_64 +test.test_gzip.TestGzip.test_gzip_BadGzipFile_exception @ linux-x86_64 +test.test_gzip.TestGzip.test_io_on_closed_object @ linux-x86_64 +test.test_gzip.TestGzip.test_issue44439 @ linux-x86_64 +test.test_gzip.TestGzip.test_many_append @ linux-x86_64 +test.test_gzip.TestGzip.test_metadata @ linux-x86_64 +test.test_gzip.TestGzip.test_metadata_ascii_name @ linux-x86_64 +test.test_gzip.TestGzip.test_mode @ linux-x86_64 +test.test_gzip.TestGzip.test_mtime @ linux-x86_64 +test.test_gzip.TestGzip.test_non_seekable_file @ linux-x86_64 +test.test_gzip.TestGzip.test_paddedfile_getattr @ linux-x86_64 +test.test_gzip.TestGzip.test_peek @ linux-x86_64 +test.test_gzip.TestGzip.test_prepend_error @ linux-x86_64 +test.test_gzip.TestGzip.test_read @ linux-x86_64 +test.test_gzip.TestGzip.test_read1 @ linux-x86_64 +test.test_gzip.TestGzip.test_read_large @ linux-x86_64 +test.test_gzip.TestGzip.test_read_truncated @ linux-x86_64 +test.test_gzip.TestGzip.test_read_with_extra @ linux-x86_64 +test.test_gzip.TestGzip.test_readline @ linux-x86_64 +test.test_gzip.TestGzip.test_readlines @ linux-x86_64 +test.test_gzip.TestGzip.test_seek_read @ linux-x86_64 +test.test_gzip.TestGzip.test_seek_whence @ linux-x86_64 +test.test_gzip.TestGzip.test_seek_write @ linux-x86_64 +test.test_gzip.TestGzip.test_textio_readlines @ linux-x86_64 +test.test_gzip.TestGzip.test_with_open @ linux-x86_64 +test.test_gzip.TestGzip.test_write @ linux-x86_64 +test.test_gzip.TestGzip.test_write_array @ linux-x86_64 +test.test_gzip.TestGzip.test_write_bytearray @ linux-x86_64 +test.test_gzip.TestGzip.test_write_incompatible_type @ linux-x86_64 +test.test_gzip.TestGzip.test_write_memoryview @ linux-x86_64 +test.test_gzip.TestGzip.test_write_read_with_pathlike_file @ linux-x86_64 +test.test_gzip.TestGzip.test_zero_padded_file @ linux-x86_64 +test.test_gzip.TestOpen.test_bad_params @ linux-x86_64 +test.test_gzip.TestOpen.test_binary_modes @ linux-x86_64 +test.test_gzip.TestOpen.test_encoding @ linux-x86_64 +test.test_gzip.TestOpen.test_encoding_error_handler @ linux-x86_64 +test.test_gzip.TestOpen.test_fileobj @ linux-x86_64 +test.test_gzip.TestOpen.test_implicit_binary_modes @ linux-x86_64 +test.test_gzip.TestOpen.test_newline @ linux-x86_64 +test.test_gzip.TestOpen.test_pathlike_file @ linux-x86_64 +test.test_gzip.TestOpen.test_text_modes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hash.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hash.txt new file mode 100644 index 0000000000..fc1493c22c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hash.txt @@ -0,0 +1,11 @@ +test.test_hash.HashBuiltinsTestCase.test_hashes @ linux-x86_64 +test.test_hash.HashDistributionTestCase.test_hash_distribution @ linux-x86_64 +test.test_hash.HashEqualityTestCase.test_coerced_floats @ linux-x86_64 +test.test_hash.HashEqualityTestCase.test_coerced_integers @ linux-x86_64 +test.test_hash.HashEqualityTestCase.test_numeric_literals @ linux-x86_64 +test.test_hash.HashEqualityTestCase.test_unaligned_buffers @ linux-x86_64 +test.test_hash.HashInheritanceTestCase.test_default_hash @ linux-x86_64 +test.test_hash.HashInheritanceTestCase.test_error_hash @ linux-x86_64 +test.test_hash.HashInheritanceTestCase.test_fixed_hash @ linux-x86_64 +test.test_hash.HashInheritanceTestCase.test_hashable @ linux-x86_64 +test.test_hash.HashInheritanceTestCase.test_not_hashable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hashlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hashlib.txt new file mode 100644 index 0000000000..e8465ffd8b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hashlib.txt @@ -0,0 +1,63 @@ +test.test_hashlib.HashLibTestCase.test_algorithms_available @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_algorithms_guaranteed @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_blocksize_name @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_blocksize_name_blake2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_blocksize_name_sha3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_blake2b_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_blake2b_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_blake2s_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_blake2s_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_md5_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_md5_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_md5_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha1_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha1_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha1_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha1_3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha224_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha224_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha224_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha224_3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha256_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha256_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha256_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha256_3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha384_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha384_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha384_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha384_3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_224_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_224_vector @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_256_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_256_vector @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_384_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_384_vector @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_512_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha3_512_vector @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha512_0 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha512_1 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha512_2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_case_sha512_3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_digest_length_overflow @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_extra_sha3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_get_builtin_constructor @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_get_fips_mode @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_gil @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_hash_array @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_hash_disallow_instantiation @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_hexdigest @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_large_update @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_name_attribute @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_new_upper_to_lower @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_no_unicode @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_no_unicode_blake2 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_no_unicode_sha3 @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_readonly_types @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_threaded_hashing @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_unknown_hash @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_usedforsecurity_false @ linux-x86_64 +test.test_hashlib.HashLibTestCase.test_usedforsecurity_true @ linux-x86_64 +test.test_hashlib.KDFTests.test_file_digest @ linux-x86_64 +test.test_hashlib.KDFTests.test_normalized_name @ linux-x86_64 +test.test_hashlib.KDFTests.test_pbkdf2_hmac_c @ linux-x86_64 +test.test_hashlib.KDFTests.test_pbkdf2_hmac_py @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_heapq.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_heapq.txt new file mode 100644 index 0000000000..3f3973edf0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_heapq.txt @@ -0,0 +1,25 @@ +DocTestCase.merge @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_arg_parsing @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_cmp_err @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_comparison_operator_modifiying_heap @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_comparison_operator_modifiying_heap_two_heaps @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_heappop_mutating_heap @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_heappush_mutating_heap @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_iterable_args @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_len_only @ linux-x86_64 +test.test_heapq.TestErrorHandlingPython.test_non_sequence @ linux-x86_64 +test.test_heapq.TestHeapPython.test_comparison_operator @ linux-x86_64 +test.test_heapq.TestHeapPython.test_empty_merges @ linux-x86_64 +test.test_heapq.TestHeapPython.test_heapify @ linux-x86_64 +test.test_heapq.TestHeapPython.test_heappop_max @ linux-x86_64 +test.test_heapq.TestHeapPython.test_heappushpop @ linux-x86_64 +test.test_heapq.TestHeapPython.test_heapsort @ linux-x86_64 +test.test_heapq.TestHeapPython.test_merge @ linux-x86_64 +test.test_heapq.TestHeapPython.test_merge_stability @ linux-x86_64 +test.test_heapq.TestHeapPython.test_naive_nbest @ linux-x86_64 +test.test_heapq.TestHeapPython.test_nbest @ linux-x86_64 +test.test_heapq.TestHeapPython.test_nbest_with_pushpop @ linux-x86_64 +test.test_heapq.TestHeapPython.test_nlargest @ linux-x86_64 +test.test_heapq.TestHeapPython.test_nsmallest @ linux-x86_64 +test.test_heapq.TestHeapPython.test_push_pop @ linux-x86_64 +test.test_heapq.TestModules.test_py_functions @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hmac.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hmac.txt new file mode 100644 index 0000000000..b08a530204 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_hmac.txt @@ -0,0 +1,26 @@ +test.test_hmac.CompareDigestTestCase.test_hmac_compare_digest @ linux-x86_64 +test.test_hmac.CompareDigestTestCase.test_openssl_compare_digest @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_dot_new_with_str_key @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_internal_types @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_normal @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_with_bytearray @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_with_memoryview_msg @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_with_sha256_module @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_with_str_key @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_withmodule @ linux-x86_64 +test.test_hmac.ConstructorTestCase.test_withtext @ linux-x86_64 +test.test_hmac.CopyTestCase.test_attributes_old @ linux-x86_64 +test.test_hmac.CopyTestCase.test_equality @ linux-x86_64 +test.test_hmac.CopyTestCase.test_equality_new @ linux-x86_64 +test.test_hmac.CopyTestCase.test_realcopy_hmac @ linux-x86_64 +test.test_hmac.CopyTestCase.test_realcopy_old @ linux-x86_64 +test.test_hmac.SanityTestCase.test_exercise_all_methods @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_legacy_block_size_warnings @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_md5_vectors @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_sha224_rfc4231 @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_sha256_rfc4231 @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_sha384_rfc4231 @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_sha512_rfc4231 @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_sha_vectors @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_with_digestmod_no_default @ linux-x86_64 +test.test_hmac.TestVectorsTestCase.test_with_fallback @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_html.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_html.txt new file mode 100644 index 0000000000..965d834712 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_html.txt @@ -0,0 +1,2 @@ +test.test_html.HtmlTests.test_escape @ linux-x86_64 +test.test_html.HtmlTests.test_unescape @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_htmlparser.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_htmlparser.txt new file mode 100644 index 0000000000..ce4295f5bb --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_htmlparser.txt @@ -0,0 +1,46 @@ +test.test_htmlparser.AttributesTestCase.test_adjacent_attributes @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_entity_replacement @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_funky_names @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_funky_names2 @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_nonascii @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_syntax @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_attr_values @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_comma_between_attributes @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_end_tag_in_attribute_value @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_entities_in_attribute_value @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_entityrefs_in_attributes @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_javascript_attribute_value @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_malformed_adjacent_attributes @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_malformed_attributes @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_missing_attribute_value @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_weird_chars_in_unquoted_attribute_values @ linux-x86_64 +test.test_htmlparser.AttributesTestCase.test_with_unquoted_attributes @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_EOF_in_charref @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_bad_nesting @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_bare_ampersands @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_bare_pointy_brackets @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_broken_comments @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_broken_condcoms @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_broken_invalid_end_tag @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_buffer_artefacts @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_cdata_content @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_cdata_with_closing_tags @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_comments @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_condcoms @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_convert_charrefs @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_convert_charrefs_dropped_text @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_correct_detection_of_start_tags @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_declaration_junk_chars @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_get_starttag_text @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_illegal_declarations @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_invalid_end_tags @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_malformatted_charref @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_processing_instruction_only @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_simple_html @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_slashes_in_starttag @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_startendtag @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_starttag_end_boundary @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_starttag_junk_chars @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_tolerant_parsing @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_unclosed_entityref @ linux-x86_64 +test.test_htmlparser.HTMLParserTestCase.test_valid_doctypes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookiejar.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookiejar.txt new file mode 100644 index 0000000000..7a783ce34a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookiejar.txt @@ -0,0 +1,77 @@ +test.test_http_cookiejar.CookieTests.test_Cookie_iterator @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_bad_cookie_header @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_custom_secure_protocols @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_default_path @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_default_path_with_query @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_domain_allow @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_domain_block @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_domain_match @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_domain_mirror @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_domain_return_ok @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_escape_path @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_evil_local_domain @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_evil_local_domain_2 @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_evil_nonlocal_domain @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_expires @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_is_HDN @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_localhost_domain @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_localhost_domain_contents @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_localhost_domain_contents_2 @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_missing_final_slash @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_missing_value @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_no_return_comment @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_ns_parser @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_ns_parser_special_names @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_parse_ns_headers @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_path_mirror @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_path_prefix_match @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_port_mirror @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_quote_cookie_value @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_reach @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_request_host @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_request_path @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_request_port @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_rfc2109_handling @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_secure @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_secure_block @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_strict_domain @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_two_component_domain_ns @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_two_component_domain_rfc2965 @ linux-x86_64 +test.test_http_cookiejar.CookieTests.test_wrong_domain @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_http2time @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_http2time_formats @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_http2time_garbage @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_http2time_redos_regression_actually_completes @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_iso2time @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_iso2time_formats @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_iso2time_garbage @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_iso2time_performance_regression @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_time2isoz @ linux-x86_64 +test.test_http_cookiejar.DateTimeTests.test_time2netscape @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_bad_magic @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_constructor_with_none @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_constructor_with_other_types @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_constructor_with_path_like @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_constructor_with_str @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_cookie_files_are_truncated @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_lwp_filepermissions @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_lwp_valueless_cookie @ linux-x86_64 +test.test_http_cookiejar.FileCookieJarTests.test_mozilla_filepermissions @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_join_header_words @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_parse_ns_headers @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_parse_ns_headers_special_names @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_parse_ns_headers_version @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_roundtrip @ linux-x86_64 +test.test_http_cookiejar.HeaderTests.test_split_header_words @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_empty_path @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_ietf_example_1 @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_ietf_example_2 @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_intranet_domains_2965 @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_intranet_domains_ns @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_mozilla @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_netscape_example_1 @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_netscape_example_2 @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_netscape_misc @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_rejection @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_session_cookies @ linux-x86_64 +test.test_http_cookiejar.LWPCookieTests.test_url_encoding @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookies.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookies.txt new file mode 100644 index 0000000000..8ae953096f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_http_cookies.txt @@ -0,0 +1,27 @@ +DocTestCase.http.cookies @ linux-x86_64 +test.test_http_cookies.CookieTests.test_basic @ linux-x86_64 +test.test_http_cookies.CookieTests.test_comment_quoting @ linux-x86_64 +test.test_http_cookies.CookieTests.test_extended_encode @ linux-x86_64 +test.test_http_cookies.CookieTests.test_extra_spaces @ linux-x86_64 +test.test_http_cookies.CookieTests.test_illegal_chars @ linux-x86_64 +test.test_http_cookies.CookieTests.test_invalid_cookies @ linux-x86_64 +test.test_http_cookies.CookieTests.test_load @ linux-x86_64 +test.test_http_cookies.CookieTests.test_pickle @ linux-x86_64 +test.test_http_cookies.CookieTests.test_quoted_meta @ linux-x86_64 +test.test_http_cookies.CookieTests.test_samesite_attrs @ linux-x86_64 +test.test_http_cookies.CookieTests.test_secure_httponly_false_if_not_present @ linux-x86_64 +test.test_http_cookies.CookieTests.test_secure_httponly_true_if_have_value @ linux-x86_64 +test.test_http_cookies.CookieTests.test_secure_httponly_true_if_present @ linux-x86_64 +test.test_http_cookies.CookieTests.test_set_secure_httponly_attrs @ linux-x86_64 +test.test_http_cookies.CookieTests.test_special_attrs @ linux-x86_64 +test.test_http_cookies.MorselTests.test_copy @ linux-x86_64 +test.test_http_cookies.MorselTests.test_defaults @ linux-x86_64 +test.test_http_cookies.MorselTests.test_eq @ linux-x86_64 +test.test_http_cookies.MorselTests.test_pickle @ linux-x86_64 +test.test_http_cookies.MorselTests.test_repr @ linux-x86_64 +test.test_http_cookies.MorselTests.test_reserved_keys @ linux-x86_64 +test.test_http_cookies.MorselTests.test_set_properties @ linux-x86_64 +test.test_http_cookies.MorselTests.test_setdefault @ linux-x86_64 +test.test_http_cookies.MorselTests.test_setitem @ linux-x86_64 +test.test_http_cookies.MorselTests.test_setter @ linux-x86_64 +test.test_http_cookies.MorselTests.test_update @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httplib.txt new file mode 100644 index 0000000000..85b1040c95 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httplib.txt @@ -0,0 +1,111 @@ +test.test_httplib.BasicTest.test_bad_status_repr @ linux-x86_64 +test.test_httplib.BasicTest.test_blocksize_request @ linux-x86_64 +test.test_httplib.BasicTest.test_blocksize_send @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked_extension @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked_head @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked_missing_end @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked_sync @ linux-x86_64 +test.test_httplib.BasicTest.test_chunked_trailers @ linux-x86_64 +test.test_httplib.BasicTest.test_content_length_sync @ linux-x86_64 +test.test_httplib.BasicTest.test_dir_with_added_behavior_on_status @ linux-x86_64 +test.test_httplib.BasicTest.test_early_eof @ linux-x86_64 +test.test_httplib.BasicTest.test_epipe @ linux-x86_64 +test.test_httplib.BasicTest.test_error_leak @ linux-x86_64 +test.test_httplib.BasicTest.test_host_port @ linux-x86_64 +test.test_httplib.BasicTest.test_incomplete_read @ linux-x86_64 +test.test_httplib.BasicTest.test_mixed_reads @ linux-x86_64 +test.test_httplib.BasicTest.test_negative_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_overflowing_chunked_line @ linux-x86_64 +test.test_httplib.BasicTest.test_overflowing_header_limit_after_100 @ linux-x86_64 +test.test_httplib.BasicTest.test_overflowing_header_line @ linux-x86_64 +test.test_httplib.BasicTest.test_overflowing_status_line @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_readintos @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_readintos_incomplete_body @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_readintos_no_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_readintos_past_end @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_reads @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_reads_incomplete_body @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_reads_no_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_partial_reads_past_end @ linux-x86_64 +test.test_httplib.BasicTest.test_putrequest_override_domain_validation @ linux-x86_64 +test.test_httplib.BasicTest.test_putrequest_override_encoding @ linux-x86_64 +test.test_httplib.BasicTest.test_putrequest_override_host_validation @ linux-x86_64 +test.test_httplib.BasicTest.test_read1_bound_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_read1_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_read_head @ linux-x86_64 +test.test_httplib.BasicTest.test_readinto_chunked @ linux-x86_64 +test.test_httplib.BasicTest.test_readinto_chunked_head @ linux-x86_64 +test.test_httplib.BasicTest.test_readinto_head @ linux-x86_64 +test.test_httplib.BasicTest.test_readline_bound_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_readlines_content_length @ linux-x86_64 +test.test_httplib.BasicTest.test_response_fileno @ linux-x86_64 +test.test_httplib.BasicTest.test_response_headers @ linux-x86_64 +test.test_httplib.BasicTest.test_send @ linux-x86_64 +test.test_httplib.BasicTest.test_send_file @ linux-x86_64 +test.test_httplib.BasicTest.test_send_iter @ linux-x86_64 +test.test_httplib.BasicTest.test_send_type_error @ linux-x86_64 +test.test_httplib.BasicTest.test_send_updating_file @ linux-x86_64 +test.test_httplib.BasicTest.test_simple_httpstatus @ linux-x86_64 +test.test_httplib.BasicTest.test_status_lines @ linux-x86_64 +test.test_httplib.BasicTest.test_too_many_headers @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_peek @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_peek_0 @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_read1 @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_read1_0 @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_read1_bounded @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_read1_unbounded @ linux-x86_64 +test.test_httplib.ExtendedReadTest.test_readline @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_peek @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_peek_0 @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_read1 @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_read1_0 @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_read1_bounded @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_read1_unbounded @ linux-x86_64 +test.test_httplib.ExtendedReadTestChunked.test_readline @ linux-x86_64 +test.test_httplib.HTTPResponseTest.test_getting_header @ linux-x86_64 +test.test_httplib.HTTPResponseTest.test_getting_header_defaultint @ linux-x86_64 +test.test_httplib.HTTPResponseTest.test_getting_nonexistent_header_with_iterable_default @ linux-x86_64 +test.test_httplib.HTTPResponseTest.test_getting_nonexistent_header_with_string_default @ linux-x86_64 +test.test_httplib.HTTPResponseTest.test_getting_nonexistent_header_without_default @ linux-x86_64 +test.test_httplib.HTTPSTest.test_attributes @ linux-x86_64 +test.test_httplib.HTTPSTest.test_host_port @ linux-x86_64 +test.test_httplib.HTTPSTest.test_local_bad_hostname @ linux-x86_64 +test.test_httplib.HTTPSTest.test_local_good_hostname @ linux-x86_64 +test.test_httplib.HTTPSTest.test_local_unknown_cert @ linux-x86_64 +test.test_httplib.HeaderTests.test_auto_headers @ linux-x86_64 +test.test_httplib.HeaderTests.test_content_length_0 @ linux-x86_64 +test.test_httplib.HeaderTests.test_headers_debuglevel @ linux-x86_64 +test.test_httplib.HeaderTests.test_invalid_headers @ linux-x86_64 +test.test_httplib.HeaderTests.test_ipv6host_header @ linux-x86_64 +test.test_httplib.HeaderTests.test_malformed_headers_coped_with @ linux-x86_64 +test.test_httplib.HeaderTests.test_parse_all_octets @ linux-x86_64 +test.test_httplib.HeaderTests.test_putheader @ linux-x86_64 +test.test_httplib.HttpMethodTests.test_invalid_method_names @ linux-x86_64 +test.test_httplib.OfflineTest.test_all @ linux-x86_64 +test.test_httplib.OfflineTest.test_client_constants @ linux-x86_64 +test.test_httplib.OfflineTest.test_responses @ linux-x86_64 +test.test_httplib.PersistenceTest.test_100_close @ linux-x86_64 +test.test_httplib.PersistenceTest.test_disconnected @ linux-x86_64 +test.test_httplib.PersistenceTest.test_reuse_reconnect @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_ascii_body @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_binary_file_body @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_bytes_body @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_latin1_body @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_list_body @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_manual_content_length @ linux-x86_64 +test.test_httplib.RequestBodyTest.test_text_file_body @ linux-x86_64 +test.test_httplib.SourceAddressTest.testHTTPConnectionSourceAddress @ linux-x86_64 +test.test_httplib.SourceAddressTest.testHTTPSConnectionSourceAddress @ linux-x86_64 +test.test_httplib.TimeoutTest.testTimeoutAttribute @ linux-x86_64 +test.test_httplib.TransferEncodingTest.test_empty_body @ linux-x86_64 +test.test_httplib.TransferEncodingTest.test_endheaders_chunked @ linux-x86_64 +test.test_httplib.TransferEncodingTest.test_explicit_headers @ linux-x86_64 +test.test_httplib.TransferEncodingTest.test_request @ linux-x86_64 +test.test_httplib.TunnelTests.test_connect_put_request @ linux-x86_64 +test.test_httplib.TunnelTests.test_connect_with_tunnel @ linux-x86_64 +test.test_httplib.TunnelTests.test_disallow_set_tunnel_after_connect @ linux-x86_64 +test.test_httplib.TunnelTests.test_set_tunnel_host_port_headers @ linux-x86_64 +test.test_httplib.TunnelTests.test_tunnel_connect_single_send_connection_setup @ linux-x86_64 +test.test_httplib.TunnelTests.test_tunnel_debuglog @ linux-x86_64 +test.test_httplib.TunnelTests.test_tunnel_leak @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httpservers.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httpservers.txt new file mode 100644 index 0000000000..291d42ff2a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_httpservers.txt @@ -0,0 +1,74 @@ +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_close_connection @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_date_time_string @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_extra_space @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_error @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_header @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_response_only @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_header_length @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_header_unbuffered_when_continue @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_html_escape_on_error @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_http_0_9 @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_http_1_0 @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_http_1_1 @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_request_length @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_too_many_headers @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_unprintable_not_logged @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_with_continue_1_0 @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_with_continue_1_1 @ linux-x86_64 +test.test_httpservers.BaseHTTPRequestHandlerTestCase.test_with_continue_rejected @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_command @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_error_content_length @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_handler @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_head_via_send_error @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_header_close @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_header_keep_alive @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_internal_key_error @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_latin1_header @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_major_version_number_too_long @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_minor_version_number_too_long @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_request_line_trimming @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_return_custom_status @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_return_explain_error @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_return_header_keep_alive @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_send_blank @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_send_error @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_bogus @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_digits @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_invalid @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_none @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_none_get @ linux-x86_64 +test.test_httpservers.BaseHTTPServerTestCase.test_version_signs_and_underscores @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_accept @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_authorization @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_cgi_path_in_sub_directories @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_headers_and_content @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_invaliduri @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_issue19435 @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_nested_cgi_path_issue21323 @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_no_leading_slash @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_os_environ_is_not_altered @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_post @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_query_with_continuous_slashes @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_query_with_multiple_question_mark @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_url_collapse_path @ linux-x86_64 +test.test_httpservers.CGIHTTPServerTestCase.test_urlquote_decoding_in_cgi_check @ linux-x86_64 +test.test_httpservers.MiscTestCase.test_all @ linux-x86_64 +test.test_httpservers.RequestHandlerLoggingTestCase.test_err @ linux-x86_64 +test.test_httpservers.ScriptTestCase.test_server_test_ipv4 @ linux-x86_64 +test.test_httpservers.ScriptTestCase.test_server_test_ipv6 @ linux-x86_64 +test.test_httpservers.ScriptTestCase.test_server_test_localhost @ linux-x86_64 +test.test_httpservers.ScriptTestCase.test_server_test_unspec @ linux-x86_64 +test.test_httpservers.SimpleHTTPRequestHandlerTestCase.test_query_arguments @ linux-x86_64 +test.test_httpservers.SimpleHTTPRequestHandlerTestCase.test_start_with_double_slash @ linux-x86_64 +test.test_httpservers.SimpleHTTPRequestHandlerTestCase.test_windows_colon @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_browser_cache @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_browser_cache_file_changed @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_browser_cache_with_If_None_Match_header @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_get @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_get_dir_redirect_location_domain_injection_bug @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_head @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_html_escape_filename @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_invalid_requests @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_last_modified @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_path_without_leading_slash @ linux-x86_64 +test.test_httpservers.SimpleHTTPServerTestCase.test_undecodable_parameter @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imaplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imaplib.txt new file mode 100644 index 0000000000..93471d4ee8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imaplib.txt @@ -0,0 +1,87 @@ +test.test_imaplib.NewIMAPSSLTests.test_EOF_without_complete_welcome_message @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_aborted_authentication @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_bad_auth_name @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_enable_UTF8_True_append @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_enable_UTF8_raises_error_if_not_supported @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_enable_raises_error_if_no_capability @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_enable_raises_error_if_not_AUTH @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_imaplib_timeout_functionality_test @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_invalid_authentication @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_line_termination @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_linetoolong @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_login @ linux-x86_64 +!test.test_imaplib.NewIMAPSSLTests.test_login_cram_md5_bytes @ linux-x86_64 +!test.test_imaplib.NewIMAPSSLTests.test_login_cram_md5_plain_text @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_logout @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_lsub @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_search_disallows_charset_in_utf8_mode @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_simple_with_statement @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_ssl_verified @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_unselect @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_valid_authentication_bytes @ linux-x86_64 +!test.test_imaplib.NewIMAPSSLTests.test_valid_authentication_plain_text @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_with_statement @ linux-x86_64 +test.test_imaplib.NewIMAPSSLTests.test_with_statement_logout @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_EOF_without_complete_welcome_message @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_aborted_authentication @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_bad_auth_name @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_enable_UTF8_True_append @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_enable_UTF8_raises_error_if_not_supported @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_enable_raises_error_if_no_capability @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_enable_raises_error_if_not_AUTH @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_imaplib_timeout_functionality_test @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_invalid_authentication @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_line_termination @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_linetoolong @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_login @ linux-x86_64 +!test.test_imaplib.NewIMAPTests.test_login_cram_md5_bytes @ linux-x86_64 +!test.test_imaplib.NewIMAPTests.test_login_cram_md5_plain_text @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_logout @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_lsub @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_search_disallows_charset_in_utf8_mode @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_simple_with_statement @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_unselect @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_valid_authentication_bytes @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_valid_authentication_plain_text @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_with_statement @ linux-x86_64 +test.test_imaplib.NewIMAPTests.test_with_statement_logout @ linux-x86_64 +test.test_imaplib.TestImaplib.test_Internaldate2tuple @ linux-x86_64 +test.test_imaplib.TestImaplib.test_Internaldate2tuple_issue10941 @ linux-x86_64 +test.test_imaplib.TestImaplib.test_imap4_host_default_value @ linux-x86_64 +test.test_imaplib.TestImaplib.test_that_Time2Internaldate_returns_a_result @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_aborted_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_bad_auth_name @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_bracket_flags @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_connect @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_enable_UTF8_True_append @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_enable_UTF8_raises_error_if_not_supported @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_enable_raises_error_if_no_capability @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_enable_raises_error_if_not_AUTH @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_invalid_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_issue5949 @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_line_termination @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_linetoolong @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_login_cram_md5 @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_search_disallows_charset_in_utf8_mode @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_simple_with_statement @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_valid_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_with_statement @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTests.test_with_statement_logout @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_aborted_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_bad_auth_name @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_bracket_flags @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_connect @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_enable_UTF8_True_append @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_enable_UTF8_raises_error_if_not_supported @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_enable_raises_error_if_no_capability @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_enable_raises_error_if_not_AUTH @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_invalid_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_issue5949 @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_line_termination @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_linetoolong @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_login_cram_md5 @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_search_disallows_charset_in_utf8_mode @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_simple_with_statement @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_valid_authentication @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_with_statement @ linux-x86_64 +test.test_imaplib.ThreadedNetworkedTestsSSL.test_with_statement_logout @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imghdr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imghdr.txt new file mode 100644 index 0000000000..97068cb373 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imghdr.txt @@ -0,0 +1,11 @@ +test.test_imghdr.TestImghdr.test_bad_args @ linux-x86_64 +test.test_imghdr.TestImghdr.test_closed_file @ linux-x86_64 +test.test_imghdr.TestImghdr.test_data @ linux-x86_64 +test.test_imghdr.TestImghdr.test_file_pos @ linux-x86_64 +test.test_imghdr.TestImghdr.test_invalid_headers @ linux-x86_64 +test.test_imghdr.TestImghdr.test_missing_file @ linux-x86_64 +test.test_imghdr.TestImghdr.test_output_stream @ linux-x86_64 +test.test_imghdr.TestImghdr.test_pathlike_filename @ linux-x86_64 +test.test_imghdr.TestImghdr.test_register_test @ linux-x86_64 +test.test_imghdr.TestImghdr.test_string_data @ linux-x86_64 +test.test_imghdr.TestImghdr.test_unseekable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imp.txt new file mode 100644 index 0000000000..49e7590894 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_imp.txt @@ -0,0 +1,18 @@ +test.test_imp.ImportTests.test_bug7732 @ linux-x86_64 +test.test_imp.ImportTests.test_find_and_load_checked_pyc @ linux-x86_64 +test.test_imp.ImportTests.test_find_module_encoding @ linux-x86_64 +test.test_imp.ImportTests.test_import_encoded_module @ linux-x86_64 +test.test_imp.ImportTests.test_issue1267 @ linux-x86_64 +test.test_imp.ImportTests.test_issue3594 @ linux-x86_64 +test.test_imp.ImportTests.test_issue5604 @ linux-x86_64 +test.test_imp.ImportTests.test_issue9319 @ linux-x86_64 +test.test_imp.ImportTests.test_issue_35321 @ linux-x86_64 +test.test_imp.ImportTests.test_load_source @ linux-x86_64 +test.test_imp.ImportTests.test_multiple_calls_to_get_data @ linux-x86_64 +test.test_imp.ImportTests.test_pyc_invalidation_mode_from_cmdline @ linux-x86_64 +test.test_imp.PEP3147Tests.test_cache_from_source @ linux-x86_64 +test.test_imp.PEP3147Tests.test_source_from_cache @ linux-x86_64 +test.test_imp.ReloadTests.test_builtin @ linux-x86_64 +test.test_imp.ReloadTests.test_extension @ linux-x86_64 +test.test_imp.ReloadTests.test_source @ linux-x86_64 +test.test_imp.ReloadTests.test_with_deleted_parent @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_import.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_import.txt new file mode 100644 index 0000000000..66ccc2507c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_import.txt @@ -0,0 +1,66 @@ +test.test_import.CircularImportTests.test_binding @ linux-x86_64 +test.test_import.CircularImportTests.test_circular_from_import @ linux-x86_64 +test.test_import.CircularImportTests.test_crossreference1 @ linux-x86_64 +test.test_import.CircularImportTests.test_crossreference2 @ linux-x86_64 +test.test_import.CircularImportTests.test_direct @ linux-x86_64 +test.test_import.CircularImportTests.test_indirect @ linux-x86_64 +test.test_import.CircularImportTests.test_rebinding @ linux-x86_64 +test.test_import.CircularImportTests.test_subpackage @ linux-x86_64 +test.test_import.CircularImportTests.test_unwritable_module @ linux-x86_64 +test.test_import.FilePermissionTests.test_cached_mode_issue_2051 @ linux-x86_64 +test.test_import.FilePermissionTests.test_cached_readonly @ linux-x86_64 +test.test_import.FilePermissionTests.test_creation_mode @ linux-x86_64 +test.test_import.FilePermissionTests.test_pyc_always_writable @ linux-x86_64 +test.test_import.ImportTests.test_bogus_fromlist @ linux-x86_64 +test.test_import.ImportTests.test_case_sensitivity @ linux-x86_64 +!test.test_import.ImportTests.test_concurrency @ linux-x86_64 +test.test_import.ImportTests.test_double_const @ linux-x86_64 +test.test_import.ImportTests.test_failing_import_sticks @ linux-x86_64 +test.test_import.ImportTests.test_failing_reload @ linux-x86_64 +test.test_import.ImportTests.test_file_to_source @ linux-x86_64 +test.test_import.ImportTests.test_from_import_AttributeError @ linux-x86_64 +test.test_import.ImportTests.test_from_import_message_for_existing_module @ linux-x86_64 +test.test_import.ImportTests.test_from_import_message_for_nonexistent_module @ linux-x86_64 +test.test_import.ImportTests.test_from_import_missing_attr_has_name @ linux-x86_64 +test.test_import.ImportTests.test_from_import_missing_attr_has_name_and_path @ linux-x86_64 +test.test_import.ImportTests.test_from_import_missing_attr_path_is_canonical @ linux-x86_64 +test.test_import.ImportTests.test_from_import_missing_attr_raises_ImportError @ linux-x86_64 +test.test_import.ImportTests.test_from_import_missing_module_raises_ModuleNotFoundError @ linux-x86_64 +test.test_import.ImportTests.test_from_import_star_invalid_type @ linux-x86_64 +test.test_import.ImportTests.test_import @ linux-x86_64 +test.test_import.ImportTests.test_import_by_filename @ linux-x86_64 +test.test_import.ImportTests.test_import_in_del_does_not_crash @ linux-x86_64 +test.test_import.ImportTests.test_import_name_binding @ linux-x86_64 +test.test_import.ImportTests.test_import_raises_ModuleNotFoundError @ linux-x86_64 +test.test_import.ImportTests.test_issue31286 @ linux-x86_64 +test.test_import.ImportTests.test_module_with_large_stack @ linux-x86_64 +test.test_import.ImportTests.test_timestamp_overflow @ linux-x86_64 +test.test_import.ImportTracebackTests.test_broken_from @ linux-x86_64 +test.test_import.ImportTracebackTests.test_broken_parent @ linux-x86_64 +test.test_import.ImportTracebackTests.test_broken_parent_from @ linux-x86_64 +test.test_import.ImportTracebackTests.test_broken_submodule @ linux-x86_64 +test.test_import.ImportTracebackTests.test_exec_failure @ linux-x86_64 +test.test_import.ImportTracebackTests.test_exec_failure_nested @ linux-x86_64 +test.test_import.ImportTracebackTests.test_nonexistent_module @ linux-x86_64 +test.test_import.ImportTracebackTests.test_nonexistent_module_nested @ linux-x86_64 +test.test_import.ImportTracebackTests.test_syntax_error @ linux-x86_64 +test.test_import.OverridingImportBuiltinTests.test_override_builtin @ linux-x86_64 +test.test_import.PathsTests.test_trailing_slash @ linux-x86_64 +test.test_import.PycRewritingTests.test_basics @ linux-x86_64 +test.test_import.PycRewritingTests.test_module_without_source @ linux-x86_64 +test.test_import.PycacheTests.test___cached__ @ linux-x86_64 +test.test_import.PycacheTests.test___cached___legacy_pyc @ linux-x86_64 +test.test_import.PycacheTests.test_import_pyc_path @ linux-x86_64 +test.test_import.PycacheTests.test_missing_source @ linux-x86_64 +test.test_import.PycacheTests.test_missing_source_legacy @ linux-x86_64 +test.test_import.PycacheTests.test_package___cached__ @ linux-x86_64 +test.test_import.PycacheTests.test_package___cached___from_pyc @ linux-x86_64 +test.test_import.PycacheTests.test_recompute_pyc_same_second @ linux-x86_64 +test.test_import.PycacheTests.test_unwritable_directory @ linux-x86_64 +test.test_import.RelativeImportTests.test_absolute_import_without_future @ linux-x86_64 +test.test_import.RelativeImportTests.test_import_from_non_package @ linux-x86_64 +test.test_import.RelativeImportTests.test_import_from_unloaded_package @ linux-x86_64 +test.test_import.RelativeImportTests.test_issue3221 @ linux-x86_64 +test.test_import.RelativeImportTests.test_parentless_import_shadowed_by_global @ linux-x86_64 +test.test_import.RelativeImportTests.test_relimport_star @ linux-x86_64 +test.test_import.TestSymbolicallyLinkedPackage.test_symlinked_dir_importable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_importlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_importlib.txt new file mode 100644 index 0000000000..f26069aba6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_importlib.txt @@ -0,0 +1,1405 @@ +test.test_importlib.builtin.test_finder.Frozen_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.builtin.test_finder.Frozen_FindSpecTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_finder.Frozen_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.builtin.test_finder.Frozen_FinderTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_finder.Source_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.builtin.test_finder.Source_FindSpecTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_finder.Source_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.builtin.test_finder.Source_FinderTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_InspectLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_InspectLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_InspectLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_InspectLoaderTests.test_not_builtin @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_LoaderTests.test_already_imported @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.builtin.test_loader.Frozen_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_InspectLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_InspectLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_InspectLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_InspectLoaderTests.test_not_builtin @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_LoaderTests.test_already_imported @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.builtin.test_loader.Source_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.extension.test_finder.Frozen_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.extension.test_finder.Frozen_FinderTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_finder.Source_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.extension.test_finder.Source_FinderTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_equality @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_inequality @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_load_module_API @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_bad_modules @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_functionality @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_short_name @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_submodule @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_load_twice @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonascii @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonmodule @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_nonmodule_with_methods @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_null_slots @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_reload @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_try_registration @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_unloadable @ linux-x86_64 +test.test_importlib.extension.test_loader.Frozen_MultiPhaseExtensionModuleTests.test_unloadable_nonascii @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_equality @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_inequality @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_load_module_API @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_bad_modules @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_functionality @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_short_name @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_submodule @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_load_twice @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_module @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonascii @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonmodule @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_nonmodule_with_methods @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_null_slots @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_reload @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_try_registration @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_unloadable @ linux-x86_64 +test.test_importlib.extension.test_loader.Source_MultiPhaseExtensionModuleTests.test_unloadable_nonascii @ linux-x86_64 +test.test_importlib.extension.test_path_hook.Frozen_PathHookTests.test_success @ linux-x86_64 +test.test_importlib.extension.test_path_hook.Source_PathHookTests.test_success @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_not_using_frozen @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_path_ignored @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FindSpecTests.test_target_ignored @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FinderTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FinderTests.test_module_in_package @ linux-x86_64 +test.test_importlib.frozen.test_finder.Frozen_FinderTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_not_using_frozen @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_path_ignored @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FindSpecTests.test_target_ignored @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FinderTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FinderTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FinderTests.test_module_in_package @ linux-x86_64 +test.test_importlib.frozen.test_finder.Source_FinderTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_lacking_parent @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_module_repr @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_module_repr_indirect @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_ExecModuleTests.test_unloadable @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_InspectLoaderTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_InspectLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_InspectLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_InspectLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_lacking_parent @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_module_repr @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Frozen_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_lacking_parent @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_module_repr @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_module_repr_indirect @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_ExecModuleTests.test_unloadable @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_InspectLoaderTests.test_failure @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_InspectLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_InspectLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_InspectLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_lacking_parent @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_module @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_module_repr @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_module_reuse @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_package @ linux-x86_64 +test.test_importlib.frozen.test_loader.Source_LoaderTests.test_unloadable @ linux-x86_64 +test.test_importlib.import_.test___loader__.Frozen_LoaderAttributeTests.test___loader___is_None @ linux-x86_64 +test.test_importlib.import_.test___loader__.Frozen_LoaderAttributeTests.test___loader___missing @ linux-x86_64 +test.test_importlib.import_.test___loader__.Frozen_SpecLoaderAttributeTests.test___loader__ @ linux-x86_64 +test.test_importlib.import_.test___loader__.Source_LoaderAttributeTests.test___loader___is_None @ linux-x86_64 +test.test_importlib.import_.test___loader__.Source_LoaderAttributeTests.test___loader___missing @ linux-x86_64 +test.test_importlib.import_.test___loader__.Source_SpecLoaderAttributeTests.test___loader__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_None_as___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_bad__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_bunk__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_spec_fallback @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_using___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_warn_when_package_and_spec_disagree @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP302.test_warn_when_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_None_as___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_bad__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_bunk__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_spec_fallback @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_using___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_warn_when_package_and_spec_disagree @ linux-x86_64 +test.test_importlib.import_.test___package__.Frozen_Using__package__PEP451.test_warn_when_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP302.test_package @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP302.test_submodule @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP302.test_top_level @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP451.test_package @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP451.test_submodule @ linux-x86_64 +test.test_importlib.import_.test___package__.Setting__package__PEP451.test_top_level @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_None_as___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_bad__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_bunk__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_spec_fallback @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_using___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_warn_when_package_and_spec_disagree @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP302.test_warn_when_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_None_as___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_bad__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_bunk__package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_spec_fallback @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_using___name__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_using___package__ @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_warn_when_package_and_spec_disagree @ linux-x86_64 +test.test_importlib.import_.test___package__.Source_Using__package__PEP451.test_warn_when_using___name__ @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_blocked_fromlist @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_fromlist_load_error_propagates @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_name_requires_rparition @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_negative_level @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_nonexistent_fromlist_entry @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_OldAPITests.test_raises_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_blocked_fromlist @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_fromlist_load_error_propagates @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_name_requires_rparition @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_negative_level @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_nonexistent_fromlist_entry @ linux-x86_64 +test.test_importlib.import_.test_api.Frozen_SpecAPITests.test_raises_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_blocked_fromlist @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_fromlist_load_error_propagates @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_name_requires_rparition @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_negative_level @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_nonexistent_fromlist_entry @ linux-x86_64 +test.test_importlib.import_.test_api.Source_OldAPITests.test_raises_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_blocked_fromlist @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_fromlist_load_error_propagates @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_name_requires_rparition @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_negative_level @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_nonexistent_fromlist_entry @ linux-x86_64 +test.test_importlib.import_.test_api.Source_SpecAPITests.test_raises_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_caching.Frozen_UseCache.test_None_in_cache @ linux-x86_64 +test.test_importlib.import_.test_caching.Frozen_UseCache.test_using_cache @ linux-x86_64 +test.test_importlib.import_.test_caching.ImportlibUseCache.test_None_in_cache @ linux-x86_64 +test.test_importlib.import_.test_caching.ImportlibUseCache.test_using_cache @ linux-x86_64 +test.test_importlib.import_.test_caching.ImportlibUseCache.test_using_cache_after_loader @ linux-x86_64 +test.test_importlib.import_.test_caching.ImportlibUseCache.test_using_cache_for_assigning_to_attribute @ linux-x86_64 +test.test_importlib.import_.test_caching.ImportlibUseCache.test_using_cache_for_fromlist @ linux-x86_64 +test.test_importlib.import_.test_caching.Source_UseCache.test_None_in_cache @ linux-x86_64 +test.test_importlib.import_.test_caching.Source_UseCache.test_using_cache @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_empty_string @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_fromlist_as_tuple @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_invalid_type @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_invalid_type_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_module_from_package @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_module_from_package_triggers_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_nonexistent_from_package @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_nonexistent_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_nonexistent_object @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_object @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_star_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_star_with_others @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_HandlingFromlist.test_using_star @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_ReturnValue.test_return_from_from_import @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Frozen_ReturnValue.test_return_from_import @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_empty_string @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_fromlist_as_tuple @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_invalid_type @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_invalid_type_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_module_from_package @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_module_from_package_triggers_ModuleNotFoundError @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_nonexistent_from_package @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_nonexistent_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_nonexistent_object @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_object @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_star_in_all @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_star_with_others @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_HandlingFromlist.test_using_star @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_ReturnValue.test_return_from_from_import @ linux-x86_64 +test.test_importlib.import_.test_fromlist.Source_ReturnValue.test_return_from_import @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallSignaturePEP302.test_no_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallSignaturePEP302.test_with_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallSignaturePEP451.test_no_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallSignaturePEP451.test_with_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallingOrder.test_continuing @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallingOrder.test_empty @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Frozen_CallingOrder.test_first_called @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallSignaturePEP302.test_no_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallSignaturePEP302.test_with_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallSignaturePEP451.test_no_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallSignaturePEP451.test_with_path @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallingOrder.test_continuing @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallingOrder.test_empty @ linux-x86_64 +test.test_importlib.import_.test_meta_path.Source_CallingOrder.test_first_called @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_bad_parent @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_import_parent @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_module_not_package @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_module_not_package_but_side_effects @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_raising_parent_after_double_relative_importing_child @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_raising_parent_after_importing_child @ linux-x86_64 +test.test_importlib.import_.test_packages.Frozen_ParentModuleTests.test_raising_parent_after_relative_importing_child @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_bad_parent @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_import_parent @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_module_not_package @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_module_not_package_but_side_effects @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_raising_parent_after_double_relative_importing_child @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_raising_parent_after_importing_child @ linux-x86_64 +test.test_importlib.import_.test_packages.Source_ParentModuleTests.test_raising_parent_after_relative_importing_child @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_None_on_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_deleted_cwd @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_empty_list @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_empty_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_failure @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_finder_with_find_loader @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_finder_with_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_finder_with_find_spec @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_invalidate_caches_clear_out_None @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_invalidate_caches_clear_out_relative_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_invalidate_caches_finders @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_path_importer_cache_empty_string @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindModuleTests.test_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_None_on_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_deleted_cwd @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_empty_list @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_empty_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_finder_with_find_loader @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_finder_with_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_finder_with_find_spec @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_invalidate_caches_clear_out_None @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_invalidate_caches_clear_out_relative_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_invalidate_caches_finders @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_path_importer_cache_empty_string @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_FindSpecTests.test_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_PathEntryFinderTests.test_finder_with_failing_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Frozen_PathEntryFinderTests.test_finder_with_failing_find_spec @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_None_on_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_deleted_cwd @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_empty_list @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_empty_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_failure @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_finder_with_find_loader @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_finder_with_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_finder_with_find_spec @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_invalidate_caches_clear_out_None @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_invalidate_caches_clear_out_relative_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_invalidate_caches_finders @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_path_importer_cache_empty_string @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindModuleTests.test_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_None_on_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_deleted_cwd @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_empty_list @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_empty_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_failure @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_finder_with_find_loader @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_finder_with_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_finder_with_find_spec @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_invalidate_caches_clear_out_None @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_invalidate_caches_clear_out_relative_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_invalidate_caches_finders @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_path_hooks @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_path_importer_cache_empty_string @ linux-x86_64 +test.test_importlib.import_.test_path.Source_FindSpecTests.test_sys_path @ linux-x86_64 +test.test_importlib.import_.test_path.Source_PathEntryFinderTests.test_finder_with_failing_find_module @ linux-x86_64 +test.test_importlib.import_.test_path.Source_PathEntryFinderTests.test_finder_with_failing_find_spec @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_attr_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_deep_import @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_empty_name_w_level_0 @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_import_from_different_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_import_relative_import_no_fromlist @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_module_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_module_to_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_package_to_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_package_to_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_relative_import_no_globals @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_relative_import_no_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_relative_import_no_package_exists_absolute @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_too_high_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Frozen_RelativeImports.test_too_high_from_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_attr_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_deep_import @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_empty_name_w_level_0 @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_import_from_different_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_import_relative_import_no_fromlist @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_module_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_module_to_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_package_to_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_package_to_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_relative_import_no_globals @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_relative_import_no_package @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_relative_import_no_package_exists_absolute @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_too_high_from_module @ linux-x86_64 +test.test_importlib.import_.test_relative_imports.Source_RelativeImports.test_too_high_from_package @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_bad_syntax @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_equality @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_file_from_empty_string_dir @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_get_filename_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_inequality @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_lacking_parent @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_load_module_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_module @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_module_reuse @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_overridden_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_overridden_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_package @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_state_after_failure @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_timestamp_overflow @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SimpleTest.test_unloadable @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_bad_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_old_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP302.test_read_only_bytecode @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_bad_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_old_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourceLoaderBadBytecodeTestPEP451.test_read_only_bytecode @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP302.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Frozen_SourcelessLoaderBadBytecodeTestPEP451.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_bad_syntax @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_equality @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_file_from_empty_string_dir @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_get_filename_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_inequality @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_lacking_parent @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_load_module_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_module @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_module_reuse @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_overridden_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_overridden_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_package @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_state_after_failure @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_timestamp_overflow @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.SourceDateEpoch_SimpleTest.test_unloadable @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_bad_syntax @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_equality @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_file_from_empty_string_dir @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_get_filename_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_inequality @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_lacking_parent @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_load_module_API @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_module @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_module_reuse @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_overridden_checked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_overridden_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_package @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_state_after_failure @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_timestamp_overflow @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_unchecked_hash_based_pyc @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SimpleTest.test_unloadable @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_bad_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_old_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP302.test_read_only_bytecode @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_bad_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_old_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourceLoaderBadBytecodeTestPEP451.test_read_only_bytecode @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP302.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_bad_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_empty_file @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_magic_only @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_no_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_non_code_marshal @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_partial_flags @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_partial_hash @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_partial_magic @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_partial_size @ linux-x86_64 +test.test_importlib.source.test_file_loader.Source_SourcelessLoaderBadBytecodeTestPEP451.test_partial_timestamp @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP302.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP420.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Frozen_FinderTestsPEP451.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP302.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP420.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_dir_removal_handling @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_empty_string_for_dir @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_failure @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_ignore_file @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_invalidate_caches @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_module @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_module_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_no_read_directory @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_package_in_package @ linux-x86_64 +test.test_importlib.source.test_finder.Source_FinderTestsPEP451.test_package_over_module @ linux-x86_64 +test.test_importlib.source.test_path_hook.Frozen_PathHookTest.test_empty_string @ linux-x86_64 +test.test_importlib.source.test_path_hook.Frozen_PathHookTest.test_empty_string_legacy @ linux-x86_64 +test.test_importlib.source.test_path_hook.Frozen_PathHookTest.test_success @ linux-x86_64 +test.test_importlib.source.test_path_hook.Frozen_PathHookTest.test_success_legacy @ linux-x86_64 +test.test_importlib.source.test_path_hook.Source_PathHookTest.test_empty_string @ linux-x86_64 +test.test_importlib.source.test_path_hook.Source_PathHookTest.test_empty_string_legacy @ linux-x86_64 +test.test_importlib.source.test_path_hook.Source_PathHookTest.test_success @ linux-x86_64 +test.test_importlib.source.test_path_hook.Source_PathHookTest.test_success_legacy @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_bom @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_bom_and_utf_8 @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_bom_conflict @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_default_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_encoding_on_first_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_encoding_on_second_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP302.test_non_obvious_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_bom @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_bom_and_utf_8 @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_bom_conflict @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_default_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_encoding_on_first_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_encoding_on_second_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_EncodingTestPEP451.test_non_obvious_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP302.test_cr @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP302.test_crlf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP302.test_lf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP451.test_cr @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP451.test_crlf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Frozen_LineEndingTestPEP451.test_lf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_bom @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_bom_and_utf_8 @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_bom_conflict @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_default_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_encoding_on_first_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_encoding_on_second_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP302.test_non_obvious_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_bom @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_bom_and_utf_8 @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_bom_conflict @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_default_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_encoding_on_first_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_encoding_on_second_line @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_EncodingTestPEP451.test_non_obvious_encoding @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP302.test_cr @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP302.test_crlf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP302.test_lf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP451.test_cr @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP451.test_crlf @ linux-x86_64 +test.test_importlib.source.test_source_encoding.Source_LineEndingTestPEP451.test_lf @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoaderGetCodeTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoaderGetCodeTests.test_get_code_no_path @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoaderGetCodeTests.test_get_code_source_is_None @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ExecutionLoaderGetCodeTests.test_get_code_source_not_found @ linux-x86_64 +test.test_importlib.test_abc.Frozen_FileLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_FileLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderDefaultsTests.test_get_source @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderDefaultsTests.test_is_package @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderGetCodeTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderGetCodeTests.test_get_code_source_is_None @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderGetCodeTests.test_get_code_source_not_found @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderLoadModuleTests.test_get_code_ImportError @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderLoadModuleTests.test_get_code_None @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderLoadModuleTests.test_module_returned @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderSourceToCodeTests.test_source_to_code_bytes @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderSourceToCodeTests.test_source_to_code_no_path @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderSourceToCodeTests.test_source_to_code_path @ linux-x86_64 +test.test_importlib.test_abc.Frozen_InspectLoaderSourceToCodeTests.test_source_to_code_source @ linux-x86_64 +test.test_importlib.test_abc.Frozen_LoaderDefaultsTests.test_create_module @ linux-x86_64 +test.test_importlib.test_abc.Frozen_LoaderDefaultsTests.test_load_module @ linux-x86_64 +test.test_importlib.test_abc.Frozen_LoaderDefaultsTests.test_module_repr @ linux-x86_64 +test.test_importlib.test_abc.Frozen_LoaderLoadModuleTests.test_fresh @ linux-x86_64 +test.test_importlib.test_abc.Frozen_LoaderLoadModuleTests.test_reload @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinder.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinder.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderDefaultsTests.test_find_module @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderDefaultsTests.test_invalidate_caches @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderFindModuleTests.test_find_module @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderFindModuleTests.test_find_spec_with_explicit_target @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderFindModuleTests.test_no_spec @ linux-x86_64 +test.test_importlib.test_abc.Frozen_MetaPathFinderFindModuleTests.test_spec @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinder.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinder.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinderDefaultsTests.test_find_loader @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinderDefaultsTests.test_invalidate_caches @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinderFindLoaderTests.test_no_spec @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinderFindLoaderTests.test_spec_with_loader @ linux-x86_64 +test.test_importlib.test_abc.Frozen_PathEntryFinderFindLoaderTests.test_spec_with_portions @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceLoaderDefaultsTests.test_get_data @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceReaderDefaultsTests.test_contents @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceReaderDefaultsTests.test_is_resource @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceReaderDefaultsTests.test_open_resource @ linux-x86_64 +test.test_importlib.test_abc.Frozen_ResourceReaderDefaultsTests.test_resource_path @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_code_bad_magic @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_code_bad_timestamp @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_code_with_everything @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_dont_write_bytecode @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_no_bytecode @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_no_set_data @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderBytecodeTests.test_set_data_raises_exceptions @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderGetSourceTests.test_decoded_source @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderGetSourceTests.test_default_encoding @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceLoaderGetSourceTests.test_universal_newlines @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_get_source_encoding @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_load_module @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_package_settings @ linux-x86_64 +test.test_importlib.test_abc.Frozen_SourceOnlyLoaderTests.test_source_to_code @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoaderGetCodeTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoaderGetCodeTests.test_get_code_no_path @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoaderGetCodeTests.test_get_code_source_is_None @ linux-x86_64 +test.test_importlib.test_abc.Source_ExecutionLoaderGetCodeTests.test_get_code_source_not_found @ linux-x86_64 +test.test_importlib.test_abc.Source_FileLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_FileLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderDefaultsTests.test_get_source @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderDefaultsTests.test_is_package @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderGetCodeTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderGetCodeTests.test_get_code_source_is_None @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderGetCodeTests.test_get_code_source_not_found @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderLoadModuleTests.test_get_code_ImportError @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderLoadModuleTests.test_get_code_None @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderLoadModuleTests.test_module_returned @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderSourceToCodeTests.test_source_to_code_bytes @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderSourceToCodeTests.test_source_to_code_no_path @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderSourceToCodeTests.test_source_to_code_path @ linux-x86_64 +test.test_importlib.test_abc.Source_InspectLoaderSourceToCodeTests.test_source_to_code_source @ linux-x86_64 +test.test_importlib.test_abc.Source_LoaderDefaultsTests.test_create_module @ linux-x86_64 +test.test_importlib.test_abc.Source_LoaderDefaultsTests.test_load_module @ linux-x86_64 +test.test_importlib.test_abc.Source_LoaderDefaultsTests.test_module_repr @ linux-x86_64 +test.test_importlib.test_abc.Source_LoaderLoadModuleTests.test_fresh @ linux-x86_64 +test.test_importlib.test_abc.Source_LoaderLoadModuleTests.test_reload @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinder.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinder.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderDefaultsTests.test_find_module @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderDefaultsTests.test_invalidate_caches @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderFindModuleTests.test_find_module @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderFindModuleTests.test_find_spec_with_explicit_target @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderFindModuleTests.test_no_spec @ linux-x86_64 +test.test_importlib.test_abc.Source_MetaPathFinderFindModuleTests.test_spec @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinder.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinder.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinderDefaultsTests.test_find_loader @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinderDefaultsTests.test_invalidate_caches @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinderFindLoaderTests.test_no_spec @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinderFindLoaderTests.test_spec_with_loader @ linux-x86_64 +test.test_importlib.test_abc.Source_PathEntryFinderFindLoaderTests.test_spec_with_portions @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceLoaderDefaultsTests.test_get_data @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceReaderDefaultsTests.test_contents @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceReaderDefaultsTests.test_is_resource @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceReaderDefaultsTests.test_open_resource @ linux-x86_64 +test.test_importlib.test_abc.Source_ResourceReaderDefaultsTests.test_resource_path @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoader.test_subclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoader.test_superclasses @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_code_bad_magic @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_code_bad_timestamp @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_code_with_everything @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_dont_write_bytecode @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_no_bytecode @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_no_set_data @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderBytecodeTests.test_set_data_raises_exceptions @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderGetSourceTests.test_decoded_source @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderGetSourceTests.test_default_encoding @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceLoaderGetSourceTests.test_universal_newlines @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_get_code @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_get_source @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_get_source_encoding @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_is_package @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_load_module @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_package_settings @ linux-x86_64 +test.test_importlib.test_abc.Source_SourceOnlyLoaderTests.test_source_to_code @ linux-x86_64 +test.test_importlib.test_api.FrozenImportlibTests.test_no_frozen_importlib @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_nothing @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_success @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_success_path @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP302Tests.test_sys_modules_loader_is_not_set @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_nothing @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_success @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_success_path @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_api.Frozen_FindLoaderPEP451Tests.test_sys_modules_loader_is_not_set @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_absolute_import_with_package @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_absolute_package_import @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_deep_relative_package_import @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_loaded_once @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_module_import @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_relative_import_wo_package @ linux-x86_64 +test.test_importlib.test_api.Frozen_ImportModuleTests.test_shallow_relative_package_import @ linux-x86_64 +test.test_importlib.test_api.Frozen_InvalidateCacheTests.test_method_called @ linux-x86_64 +test.test_importlib.test_api.Frozen_InvalidateCacheTests.test_method_lacking @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_module_missing_spec @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_module_replaced @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_loader_replaced @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_location_changed @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_missing_loader @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_modules @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_namespace_changed @ linux-x86_64 +test.test_importlib.test_api.Frozen_ReloadTests.test_reload_submodule @ linux-x86_64 +test.test_importlib.test_api.Frozen_StartupTests.test_everyone_has___loader__ @ linux-x86_64 +test.test_importlib.test_api.Frozen_StartupTests.test_everyone_has___spec__ @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_nothing @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_success @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_success_path @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP302Tests.test_sys_modules_loader_is_not_set @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_nothing @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_success @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_success_path @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_api.Source_FindLoaderPEP451Tests.test_sys_modules_loader_is_not_set @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_absolute_import_with_package @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_absolute_package_import @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_deep_relative_package_import @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_loaded_once @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_module_import @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_relative_import_wo_package @ linux-x86_64 +test.test_importlib.test_api.Source_ImportModuleTests.test_shallow_relative_package_import @ linux-x86_64 +test.test_importlib.test_api.Source_InvalidateCacheTests.test_method_called @ linux-x86_64 +test.test_importlib.test_api.Source_InvalidateCacheTests.test_method_lacking @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_module_missing_spec @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_module_replaced @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_loader_replaced @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_location_changed @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_missing_loader @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_modules @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_namespace_changed @ linux-x86_64 +test.test_importlib.test_api.Source_ReloadTests.test_reload_submodule @ linux-x86_64 +test.test_importlib.test_api.Source_StartupTests.test_everyone_has___loader__ @ linux-x86_64 +test.test_importlib.test_api.Source_StartupTests.test_everyone_has___spec__ @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesNoReaderTests.test_spec_path_joinpath @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_child_path_is @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_child_path_iter @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_child_path_name @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_child_path_open @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_open_invalid_mode @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_orphan_path_invalid @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_orphan_path_is @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_orphan_path_iter @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_orphan_path_name @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_orphan_path_open @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_spec_path_is @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_spec_path_iter @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_spec_path_name @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_spec_path_open @ linux-x86_64 +test.test_importlib.test_compatibilty_files.CompatibilityFilesTests.test_wrap_spec @ linux-x86_64 +test.test_importlib.test_contents.ContentsDiskTests.test_contents @ linux-x86_64 +test.test_importlib.test_contents.ContentsNamespaceTests.test_contents @ linux-x86_64 +test.test_importlib.test_contents.ContentsZipTests.test_contents @ linux-x86_64 +test.test_importlib.test_files.OpenDiskTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_files.OpenDiskTests.test_read_text @ linux-x86_64 +test.test_importlib.test_files.OpenDiskTests.test_traversable @ linux-x86_64 +test.test_importlib.test_files.OpenNamespaceTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_files.OpenNamespaceTests.test_read_text @ linux-x86_64 +test.test_importlib.test_files.OpenNamespaceTests.test_traversable @ linux-x86_64 +test.test_importlib.test_files.OpenZipTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_files.OpenZipTests.test_read_text @ linux-x86_64 +test.test_importlib.test_files.OpenZipTests.test_traversable @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderFactoryTests.test_init @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderFactoryTests.test_validation @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_attr_unchanged @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_delete_eventual_attr @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_delete_preexisting_attr @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_e2e @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_init @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_module_already_in_sys @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_module_substitution_error @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_mutated_attr @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_mutated_preexisting_attr @ linux-x86_64 +test.test_importlib.test_lazy.LazyLoaderTests.test_new_attr @ linux-x86_64 +test.test_importlib.test_locks.Frozen_DeadlockAvoidanceTests.test_deadlock @ linux-x86_64 +test.test_importlib.test_locks.Frozen_DeadlockAvoidanceTests.test_no_deadlock @ linux-x86_64 +test.test_importlib.test_locks.Frozen_LifetimeTests.test_lock_lifetime @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_acquire_contended @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_acquire_destroy @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_acquire_release @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_constructor @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_different_thread @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_reacquire @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_release_unacquired @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_thread_leak @ linux-x86_64 +test.test_importlib.test_locks.Frozen_ModuleLockAsRLockTests.test_weakref_exists @ linux-x86_64 +test.test_importlib.test_locks.Source_DeadlockAvoidanceTests.test_deadlock @ linux-x86_64 +test.test_importlib.test_locks.Source_DeadlockAvoidanceTests.test_no_deadlock @ linux-x86_64 +!test.test_importlib.test_locks.Source_LifetimeTests.test_all_locks @ linux-x86_64 +test.test_importlib.test_locks.Source_LifetimeTests.test_lock_lifetime @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_acquire_contended @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_acquire_destroy @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_acquire_release @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_constructor @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_different_thread @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_reacquire @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_release_unacquired @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_thread_leak @ linux-x86_64 +test.test_importlib.test_locks.Source_ModuleLockAsRLockTests.test_weakref_exists @ linux-x86_64 +test.test_importlib.test_main.BasicTests.test_for_name_does_not_exist @ linux-x86_64 +test.test_importlib.test_main.BasicTests.test_invalid_inputs_to_from_name @ linux-x86_64 +test.test_importlib.test_main.BasicTests.test_new_style_classes @ linux-x86_64 +test.test_importlib.test_main.BasicTests.test_package_not_found_mentions_metadata @ linux-x86_64 +test.test_importlib.test_main.BasicTests.test_retrieves_version_of_self @ linux-x86_64 +test.test_importlib.test_main.DirectoryTest.test_egg @ linux-x86_64 +test.test_importlib.test_main.DirectoryTest.test_egg_info @ linux-x86_64 +test.test_importlib.test_main.DiscoveryTests.test_invalid_usage @ linux-x86_64 +test.test_importlib.test_main.DiscoveryTests.test_package_discovery @ linux-x86_64 +test.test_importlib.test_main.FileSystem.test_unicode_dir_on_sys_path @ linux-x86_64 +test.test_importlib.test_main.ImportTests.test_entrypoint_with_colon_in_name @ linux-x86_64 +test.test_importlib.test_main.ImportTests.test_import_nonexistent_module @ linux-x86_64 +test.test_importlib.test_main.ImportTests.test_resolve @ linux-x86_64 +test.test_importlib.test_main.ImportTests.test_resolve_without_attr @ linux-x86_64 +test.test_importlib.test_main.MissingSysPath.test_discovery @ linux-x86_64 +test.test_importlib.test_main.NameNormalizationTests.test_dashes_in_dist_name_found_as_underscores @ linux-x86_64 +test.test_importlib.test_main.NameNormalizationTests.test_dist_name_found_as_any_case @ linux-x86_64 +test.test_importlib.test_main.NameNormalizationTests.test_unique_distributions @ linux-x86_64 +test.test_importlib.test_main.NonASCIITests.test_metadata_loads @ linux-x86_64 +test.test_importlib.test_main.NonASCIITests.test_metadata_loads_egg_info @ linux-x86_64 +test.test_importlib.test_main.PackagesDistributionsPrebuiltTest.test_packages_distributions_example @ linux-x86_64 +test.test_importlib.test_main.PackagesDistributionsPrebuiltTest.test_packages_distributions_example2 @ linux-x86_64 +test.test_importlib.test_main.PackagesDistributionsTest.test_packages_distributions_neither_toplevel_nor_files @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_attr @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_entry_point_pickleable @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_hashable @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_immutable @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_json_dump @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_module @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_positional_args @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_repr @ linux-x86_64 +test.test_importlib.test_main.TestEntryPoints.test_sortable @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_as_json @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_as_json_egg_info @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_as_json_odd_case @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_allows_no_attributes @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_by_index @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_dict_construction @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_distribution @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_groups_get @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_groups_getitem @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_missing_group @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_missing_name @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_entry_points_unique_packages_normalized @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_file_hash_repr @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_files_dist_info @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_files_egg_info @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_for_name_does_not_exist @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_for_top_level @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_metadata_for_this_package @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_more_complex_deps_requires_text @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_name_normalization @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_prefix_not_matched @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_read_text @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_requires_dist_info @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_requires_egg_info @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_requires_egg_info_empty @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_requires_egg_info_file @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_retrieves_version_of_distinfo_pkg @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_retrieves_version_of_self @ linux-x86_64 +test.test_importlib.test_metadata_api.APITests.test_version_egg_info_file @ linux-x86_64 +test.test_importlib.test_metadata_api.InvalidateCache.test_invalidate_cache @ linux-x86_64 +test.test_importlib.test_metadata_api.LegacyDots.test_name_normalization @ linux-x86_64 +test.test_importlib.test_metadata_api.LegacyDots.test_name_normalization_versionless_egg_info @ linux-x86_64 +test.test_importlib.test_metadata_api.OffSysPathTests.test_distribution_at_pathlib @ linux-x86_64 +test.test_importlib.test_metadata_api.OffSysPathTests.test_distribution_at_str @ linux-x86_64 +test.test_importlib.test_metadata_api.OffSysPathTests.test_find_distributions_specified_path @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.CombinedNamespacePackages.test_imports @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.DynamicPathCalculation.test_project3_fails @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.DynamicPathCalculation.test_project3_succeeds @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.DynamicPathNamespacePackage.test_dynamic_path @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.LegacySupport.test_non_namespace_package_takes_precedence @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.LoaderTests.test_loader_abc @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.LoaderTests.test_namespace_loader_consistency @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.LoaderTests.test_namespace_origin_consistency @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.LoaderTests.test_path_indexable @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ModuleAndNamespacePackageInSameDir.test_module_before_namespace_package @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ReloadTests.test_cant_import_other @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ReloadTests.test_dynamic_path @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ReloadTests.test_simple_package @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedNamespacePackages.test_imports @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedNamespacePackagesCreatedWhileRunning.test_invalidate_caches @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedNestedZipNamespacePackages.test_imports @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedOverlappingNamespacePackages.test_first_path_wins @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedOverlappingNamespacePackages.test_first_path_wins_again @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedOverlappingNamespacePackages.test_first_path_wins_importing_second_first @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SeparatedZipNamespacePackages.test_imports @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleNamespacePackage.test_cant_import_other @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleNamespacePackage.test_module_repr @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleNamespacePackage.test_simple_package @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleNestedZipNamespacePackage.test_cant_import_other @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleNestedZipNamespacePackage.test_simple_package @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleZipNamespacePackage.test_cant_import_other @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.SingleZipNamespacePackage.test_simple_package @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ZipWithMissingDirectory.test_missing_directory @ linux-x86_64 +test.test_importlib.test_namespace_pkgs.ZipWithMissingDirectory.test_present_directory @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_extant_path @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_importing_module_as_side_effect @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_missing_path @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_non_package_by_name @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_non_package_by_package @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_package_name @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_package_object @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_pathlib_path @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_string_path @ linux-x86_64 +test.test_importlib.test_open.CommonBinaryTests.test_useless_loader @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_extant_path @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_importing_module_as_side_effect @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_missing_path @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_non_package_by_name @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_non_package_by_package @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_package_name @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_package_object @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_pathlib_path @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_string_path @ linux-x86_64 +test.test_importlib.test_open.CommonTextTests.test_useless_loader @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_binary @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_binary_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_text_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_text_default_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_text_given_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenDiskNamespaceTests.test_open_text_with_errors @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_binary @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_binary_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_text_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_text_default_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_text_given_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenDiskTests.test_open_text_with_errors @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_binary @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_binary_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_text_FileNotFoundError @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_text_default_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_text_given_encoding @ linux-x86_64 +test.test_importlib.test_open.OpenZipTests.test_open_text_with_errors @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_extant_path @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_importing_module_as_side_effect @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_missing_path @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_non_package_by_name @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_non_package_by_package @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_package_name @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_package_object @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_pathlib_path @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_string_path @ linux-x86_64 +test.test_importlib.test_path.CommonTests.test_useless_loader @ linux-x86_64 +test.test_importlib.test_path.PathDiskTests.test_natural_path @ linux-x86_64 +test.test_importlib.test_path.PathDiskTests.test_reading @ linux-x86_64 +test.test_importlib.test_path.PathMemoryTests.test_reading @ linux-x86_64 +test.test_importlib.test_path.PathZipTests.test_reading @ linux-x86_64 +test.test_importlib.test_path.PathZipTests.test_remove_in_context_manager @ linux-x86_64 +test.test_importlib.test_pkg_import.TestImport.test_package_import__semantics @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_extant_path @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_importing_module_as_side_effect @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_missing_path @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_non_package_by_name @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_non_package_by_package @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_package_name @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_package_object @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_pathlib_path @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_string_path @ linux-x86_64 +test.test_importlib.test_read.CommonBinaryTests.test_useless_loader @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_extant_path @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_importing_module_as_side_effect @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_missing_path @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_non_package_by_name @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_non_package_by_package @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_package_name @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_package_object @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_pathlib_path @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_string_path @ linux-x86_64 +test.test_importlib.test_read.CommonTextTests.test_useless_loader @ linux-x86_64 +test.test_importlib.test_read.ReadDiskTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_read.ReadDiskTests.test_read_text_default_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadDiskTests.test_read_text_given_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadDiskTests.test_read_text_with_errors @ linux-x86_64 +test.test_importlib.test_read.ReadNamespaceTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_read.ReadNamespaceTests.test_read_text_default_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadNamespaceTests.test_read_text_given_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadNamespaceTests.test_read_text_with_errors @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_bytes @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_submodule_resource @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_submodule_resource_by_name @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_text_default_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_text_given_encoding @ linux-x86_64 +test.test_importlib.test_read.ReadZipTests.test_read_text_with_errors @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_init_file @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_init_no_paths @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_is_dir @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_is_file @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_iterdir @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_iterdir_duplicate @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_join_path @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_name @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_open_file @ linux-x86_64 +test.test_importlib.test_reader.MultiplexedPathTest.test_repr @ linux-x86_64 +test.test_importlib.test_reader.NamespaceReaderTest.test_files @ linux-x86_64 +test.test_importlib.test_reader.NamespaceReaderTest.test_init_error @ linux-x86_64 +test.test_importlib.test_reader.NamespaceReaderTest.test_resource_path @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_entered_path_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_is_file_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_is_file_failure_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_iterdir_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_read_binary_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.DeletingZipsTest.test_read_text_does_not_keep_open @ linux-x86_64 +test.test_importlib.test_resource.ResourceCornerCaseTests.test_package_has_no_reader_fallback @ linux-x86_64 +test.test_importlib.test_resource.ResourceDiskTests.test_is_dir @ linux-x86_64 +test.test_importlib.test_resource.ResourceDiskTests.test_is_file_exists @ linux-x86_64 +test.test_importlib.test_resource.ResourceDiskTests.test_is_file_missing @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromNamespaceTest01.test_is_submodule_resource @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromNamespaceTest01.test_read_submodule_resource_by_name @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromNamespaceTest01.test_submodule_contents @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromNamespaceTest01.test_submodule_contents_by_name @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromZipsTest01.test_is_submodule_resource @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromZipsTest01.test_read_submodule_resource_by_name @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromZipsTest01.test_submodule_contents @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromZipsTest01.test_submodule_contents_by_name @ linux-x86_64 +test.test_importlib.test_resource.ResourceFromZipsTest02.test_unrelated_contents @ linux-x86_64 +test.test_importlib.test_resource.ResourceLoaderTests.test_is_dir @ linux-x86_64 +test.test_importlib.test_resource.ResourceLoaderTests.test_is_file @ linux-x86_64 +test.test_importlib.test_resource.ResourceLoaderTests.test_resource_contents @ linux-x86_64 +test.test_importlib.test_resource.ResourceLoaderTests.test_resource_missing @ linux-x86_64 +test.test_importlib.test_resource.ResourceZipTests.test_is_dir @ linux-x86_64 +test.test_importlib.test_resource.ResourceZipTests.test_is_file_exists @ linux-x86_64 +test.test_importlib.test_resource.ResourceZipTests.test_is_file_missing @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_default @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_default_bad_suffix @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_default_without_location @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_loader_no_location @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_loader_no_location_bad_get_filename @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_loader_no_location_no_get_filename @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_path_like_arg @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_relative_path @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_default @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_default_bad_is_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_default_no_is_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_default_not_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_empty @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_none @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_file_location_smsl_not_empty @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_default @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_default_with_bad_is_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_default_with_file_loader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_false @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_false_with_fileloader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_true @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_true_with_fileloader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_with_loader_false @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_is_package_with_loader_true @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_origin @ linux-x86_64 +test.test_importlib.test_spec.Frozen_FactoryTests.test_spec_from_loader_origin_and_is_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___loader___module_repr @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___loader___module_repr_bad @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___spec__ @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___spec___location @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___spec___no_origin @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module___spec___no_origin_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module_no_file @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module_no_file_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module_no_name @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleReprTests.test_module_with_file @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_exec @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_failed @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_failed_removed @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_legacy @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_legacy_attributes @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_legacy_attributes_immutable @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_load_replaced @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_reload @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_reload_extra_attributes @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_reload_init_module_attrs @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_reload_legacy @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecMethodsTests.test_reload_modified @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_no_origin @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_set @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_source @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_source_missing_cache_tag @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_source_unknown_suffix @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_sourceless @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_cached_with_origin_not_location @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_default @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_default_is_package_false @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_default_is_package_true @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_default_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_equality @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_equality_location @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_has_location_setter @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_inequality @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_inequality_incomplete @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_package @ linux-x86_64 +test.test_importlib.test_spec.Frozen_ModuleSpecTests.test_package_is_package @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_default @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_default_bad_suffix @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_default_without_location @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_loader_no_location @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_loader_no_location_bad_get_filename @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_loader_no_location_no_get_filename @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_path_like_arg @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_relative_path @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_default @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_default_bad_is_package @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_default_no_is_package @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_default_not_package @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_empty @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_none @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_file_location_smsl_not_empty @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_default @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_default_with_bad_is_package @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_default_with_file_loader @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_false @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_false_with_fileloader @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_true @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_true_with_fileloader @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_with_loader_false @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_is_package_with_loader_true @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_origin @ linux-x86_64 +test.test_importlib.test_spec.Source_FactoryTests.test_spec_from_loader_origin_and_is_package @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___loader___module_repr @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___loader___module_repr_bad @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___spec__ @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___spec___location @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___spec___no_origin @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module___spec___no_origin_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module_no_file @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module_no_file_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module_no_name @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleReprTests.test_module_with_file @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_exec @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_failed @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_failed_removed @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_legacy @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_legacy_attributes @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_legacy_attributes_immutable @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_load_replaced @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_reload @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_reload_extra_attributes @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_reload_init_module_attrs @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_reload_legacy @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecMethodsTests.test_reload_modified @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_no_origin @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_set @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_source @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_source_missing_cache_tag @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_source_unknown_suffix @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_sourceless @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_cached_with_origin_not_location @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_default @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_default_is_package_false @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_default_is_package_true @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_default_no_loader @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_equality @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_equality_location @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_has_location_setter @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_inequality @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_inequality_incomplete @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_package @ linux-x86_64 +test.test_importlib.test_spec.Source_ModuleSpecTests.test_package_is_package @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_circular_imports @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_concurrent_futures_circular_import @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_import_hangers @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_multiprocessing_pool_circular_import @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_parallel_meta_path @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_parallel_module_init @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_parallel_path_hooks @ linux-x86_64 +test.test_importlib.test_threaded_import.ThreadedImportTests.test_side_effect_import @ linux-x86_64 +test.test_importlib.test_util.Frozen_DecodeSourceBytesTests.test_specified_encoding @ linux-x86_64 +test.test_importlib.test_util.Frozen_DecodeSourceBytesTests.test_universal_newlines @ linux-x86_64 +test.test_importlib.test_util.Frozen_DecodeSourceBytesTests.test_ut8_default @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_find_relative_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_find_relative_module_missing_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_find_submodule @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_find_submodule_in_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_find_submodule_parent_already_imported @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_nothing @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_success @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_sys_modules_spec_is_None @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_sys_modules_spec_is_not_set @ linux-x86_64 +test.test_importlib.test_util.Frozen_FindSpecTests.test_sys_modules_without___loader__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_MagicNumberTests.test_incorporates_rn @ linux-x86_64 +test.test_importlib.test_util.Frozen_MagicNumberTests.test_length @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_attributes_set @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_decorator_attrs @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_false_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_new_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_new_module_failure @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_reload @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_reload_failure @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleForLoaderTests.test_warning @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___cached__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___file__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___loader__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___name__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___package__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___path__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test___spec__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test_create_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test_create_module_returns_None @ linux-x86_64 +test.test_importlib.test_util.Frozen_ModuleFromSpecTests.test_no_create_module @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_cwd @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_debug_override @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_debug_override_optimization_both_set @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_no_cache_tag @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_no_dot @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_optimization_None @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_optimization_empty_string @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_optimization_set @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_override @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_path_like_arg @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_respects_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_cache_from_source_respects_pycache_prefix_relative @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_bad_path @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_inside_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_missing_optimization @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_no__pycache__ @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_no_cache_tag @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_no_slash @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_not_opt @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_optimized_bytecode @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_outside_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_path_like_arg @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_too_few_dots @ linux-x86_64 +test.test_importlib.test_util.Frozen_PEP3147Tests.test_source_from_cache_too_many_dots @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_absolute @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_absolute_within_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_escape @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_in_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_no_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_ResolveNameTests.test_other_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetLoaderTests.test_attribute_is_None @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetLoaderTests.test_no_attribute @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetLoaderTests.test_not_reset @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_decorator_attrs @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_leaving_alone @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_package @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_setting_if_missing @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_submodule @ linux-x86_64 +test.test_importlib.test_util.Frozen_SetPackageTests.test_top_level @ linux-x86_64 +test.test_importlib.test_util.Source_DecodeSourceBytesTests.test_specified_encoding @ linux-x86_64 +test.test_importlib.test_util.Source_DecodeSourceBytesTests.test_universal_newlines @ linux-x86_64 +test.test_importlib.test_util.Source_DecodeSourceBytesTests.test_ut8_default @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_find_relative_module @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_find_relative_module_missing_package @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_find_submodule @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_find_submodule_in_module @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_find_submodule_parent_already_imported @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_nothing @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_success @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_sys_modules @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_sys_modules_loader_is_None @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_sys_modules_spec_is_None @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_sys_modules_spec_is_not_set @ linux-x86_64 +test.test_importlib.test_util.Source_FindSpecTests.test_sys_modules_without___loader__ @ linux-x86_64 +test.test_importlib.test_util.Source_MagicNumberTests.test_incorporates_rn @ linux-x86_64 +test.test_importlib.test_util.Source_MagicNumberTests.test_length @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_attributes_set @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_decorator_attrs @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_false_module @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_new_module @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_new_module_failure @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_reload @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_reload_failure @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleForLoaderTests.test_warning @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___cached__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___file__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___loader__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___name__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___package__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___path__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test___spec__ @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test_create_module @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test_create_module_returns_None @ linux-x86_64 +test.test_importlib.test_util.Source_ModuleFromSpecTests.test_no_create_module @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_cwd @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_debug_override @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_debug_override_optimization_both_set @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_no_cache_tag @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_no_dot @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_optimization_None @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_optimization_empty_string @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_optimization_set @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_override @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_path_like_arg @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_respects_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_cache_from_source_respects_pycache_prefix_relative @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_bad_path @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_inside_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_missing_optimization @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_no__pycache__ @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_no_cache_tag @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_no_slash @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_not_opt @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_optimized_bytecode @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_outside_pycache_prefix @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_path_like_arg @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_too_few_dots @ linux-x86_64 +test.test_importlib.test_util.Source_PEP3147Tests.test_source_from_cache_too_many_dots @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_absolute @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_absolute_within_package @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_escape @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_in_package @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_no_package @ linux-x86_64 +test.test_importlib.test_util.Source_ResolveNameTests.test_other_package @ linux-x86_64 +test.test_importlib.test_util.Source_SetLoaderTests.test_attribute_is_None @ linux-x86_64 +test.test_importlib.test_util.Source_SetLoaderTests.test_no_attribute @ linux-x86_64 +test.test_importlib.test_util.Source_SetLoaderTests.test_not_reset @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_decorator_attrs @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_leaving_alone @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_package @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_setting_if_missing @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_submodule @ linux-x86_64 +test.test_importlib.test_util.Source_SetPackageTests.test_top_level @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_case_insensitive @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_files @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_missing_metadata @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_normalized_name @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_one_distribution @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_zip_entry_points @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_zip_version @ linux-x86_64 +test.test_importlib.test_zip.TestEgg.test_zip_version_does_not_match @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_case_insensitive @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_files @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_missing_metadata @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_one_distribution @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_zip_entry_points @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_zip_version @ linux-x86_64 +test.test_importlib.test_zip.TestZip.test_zip_version_does_not_match @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_index.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_index.txt new file mode 100644 index 0000000000..b12815a266 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_index.txt @@ -0,0 +1,55 @@ +test.test_index.BaseTestCase.test_basic @ linux-x86_64 +test.test_index.BaseTestCase.test_error @ linux-x86_64 +test.test_index.BaseTestCase.test_index_returns_int_subclass @ linux-x86_64 +test.test_index.BaseTestCase.test_int_subclass_with_index @ linux-x86_64 +test.test_index.BaseTestCase.test_slice @ linux-x86_64 +test.test_index.BaseTestCase.test_subclasses @ linux-x86_64 +test.test_index.BaseTestCase.test_wrappers @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_error @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_index @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_repeat @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_slice @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_subclasses @ linux-x86_64 +test.test_index.ByteArrayTestCase.test_wrappers @ linux-x86_64 +test.test_index.BytesTestCase.test_error @ linux-x86_64 +test.test_index.BytesTestCase.test_index @ linux-x86_64 +test.test_index.BytesTestCase.test_repeat @ linux-x86_64 +test.test_index.BytesTestCase.test_slice @ linux-x86_64 +test.test_index.BytesTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.BytesTestCase.test_subclasses @ linux-x86_64 +test.test_index.BytesTestCase.test_wrappers @ linux-x86_64 +test.test_index.ListTestCase.test_error @ linux-x86_64 +test.test_index.ListTestCase.test_index @ linux-x86_64 +test.test_index.ListTestCase.test_inplace_repeat @ linux-x86_64 +test.test_index.ListTestCase.test_repeat @ linux-x86_64 +test.test_index.ListTestCase.test_setdelitem @ linux-x86_64 +test.test_index.ListTestCase.test_slice @ linux-x86_64 +test.test_index.ListTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.ListTestCase.test_subclasses @ linux-x86_64 +test.test_index.ListTestCase.test_wrappers @ linux-x86_64 +test.test_index.NewSeqTestCase.test_error @ linux-x86_64 +test.test_index.NewSeqTestCase.test_index @ linux-x86_64 +test.test_index.NewSeqTestCase.test_repeat @ linux-x86_64 +test.test_index.NewSeqTestCase.test_slice @ linux-x86_64 +test.test_index.NewSeqTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.NewSeqTestCase.test_subclasses @ linux-x86_64 +test.test_index.NewSeqTestCase.test_wrappers @ linux-x86_64 +test.test_index.OverflowTestCase.test_getitem @ linux-x86_64 +test.test_index.OverflowTestCase.test_large_longs @ linux-x86_64 +test.test_index.OverflowTestCase.test_sequence_repeat @ linux-x86_64 +test.test_index.RangeTestCase.test_range @ linux-x86_64 +test.test_index.StringTestCase.test_error @ linux-x86_64 +test.test_index.StringTestCase.test_index @ linux-x86_64 +test.test_index.StringTestCase.test_repeat @ linux-x86_64 +test.test_index.StringTestCase.test_slice @ linux-x86_64 +test.test_index.StringTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.StringTestCase.test_subclasses @ linux-x86_64 +test.test_index.StringTestCase.test_wrappers @ linux-x86_64 +test.test_index.TupleTestCase.test_error @ linux-x86_64 +test.test_index.TupleTestCase.test_index @ linux-x86_64 +test.test_index.TupleTestCase.test_repeat @ linux-x86_64 +test.test_index.TupleTestCase.test_slice @ linux-x86_64 +test.test_index.TupleTestCase.test_slice_bug7532 @ linux-x86_64 +test.test_index.TupleTestCase.test_subclasses @ linux-x86_64 +test.test_index.TupleTestCase.test_wrappers @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_inspect.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_inspect.txt new file mode 100644 index 0000000000..9828c57e4a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_inspect.txt @@ -0,0 +1,231 @@ +test.test_inspect.test_inspect.IsTestBase.test__all__ @ linux-x86_64 +test.test_inspect.test_inspect.TestBlockComments.test_class_async_method @ linux-x86_64 +test.test_inspect.test_inspect.TestBlockComments.test_class_method @ linux-x86_64 +test.test_inspect.test_inspect.TestBlockComments.test_toplevel_class @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_apply_defaults @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_arguments_type @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_equality @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_pickle @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_repr @ linux-x86_64 +test.test_inspect.test_inspect.TestBoundArguments.test_signature_bound_arguments_unhashable @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_class_decorator @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_class_definition_in_multiline_comment @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_class_definition_in_multiline_string_definition @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_class_inside_conditional @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_findsource_code_in_linecache @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_findsource_with_out_of_bounds_lineno @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_findsource_without_filename @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_getsource_on_method @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_method_in_dynamic_class @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_multiline_sig @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_multiple_children_classes @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_class @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_class_definition @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_class_definition_indented_string @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_class_definition_inside_async_function @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_class_definition_inside_function @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_nested_func @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_one_liner_dedent_non_name @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_one_liner_followed_by_non_name @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_with_comment @ linux-x86_64 +test.test_inspect.test_inspect.TestBuggyCases.test_with_comment_instead_of_docstring @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_argspec_api_ignores_wrapped @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_DynamicClassAttribute @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_VirtualAttribute @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_VirtualAttribute_multi_classes @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_builtin_types @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_class_attrs_with_buggy_dir @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_metaclass_class_attribute @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_newstyle @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_classify_overrides_bool @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_get_annotations_with_stock_annotations @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_get_annotations_with_stringized_annotations @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getfullargspec @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getfullargspec_definition_order_preserved_on_kwonly @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getfullargspec_signature_annos @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getfullargspec_signature_attr @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getmembers_VirtualAttribute @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getmembers_descriptors @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getmembers_method @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getmembers_static @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_getmembers_with_buggy_dir @ linux-x86_64 +test.test_inspect.test_inspect.TestClassesAndFunctions.test_newstyle_mro @ linux-x86_64 +test.test_inspect.test_inspect.TestDecorators.test_replacing_decorator @ linux-x86_64 +test.test_inspect.test_inspect.TestFormatAnnotation.test_typing_replacement @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_builtins_as_dict @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_builtins_as_module @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_builtins_fallback @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_generator_closure @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_getclosurevars_empty @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_getclosurevars_error @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_method_closure @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_name_resolution @ linux-x86_64 +test.test_inspect.test_inspect.TestGetClosureVars.test_nonlocal_vars @ linux-x86_64 +test.test_inspect.test_inspect.TestGetCoroutineState.test_closed_after_immediate_exception @ linux-x86_64 +test.test_inspect.test_inspect.TestGetCoroutineState.test_easy_debugging @ linux-x86_64 +test.test_inspect.test_inspect.TestGetGeneratorState.test_closed_after_exhaustion @ linux-x86_64 +test.test_inspect.test_inspect.TestGetGeneratorState.test_closed_after_immediate_exception @ linux-x86_64 +test.test_inspect.test_inspect.TestGetGeneratorState.test_easy_debugging @ linux-x86_64 +test.test_inspect.test_inspect.TestGetGeneratorState.test_running @ linux-x86_64 +test.test_inspect.test_inspect.TestGetGeneratorState.test_suspended @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_basic @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_classAttribute @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_classVirtualAttribute @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_class_as_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_custom___getattr__ @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_custom___getattribute__ @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_custom_object_dict @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_descriptor @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_descriptor_raises_AttributeError @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_dict_as_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_inherited @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_inherited_classattribute @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_inherited_slots @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_instance_attr @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_metaclass @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_metaclass_dict_as_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_metaclass_with_descriptor @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_metaclass_with_metaclass_with_dict_as_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_module @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_mro_as_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_no_dict_no_slots @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_no_dict_no_slots_instance_member @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_property @ linux-x86_64 +test.test_inspect.test_inspect.TestGetattrStatic.test_slots @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsFunctions.test_multiple_features @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsFunctions.test_plain @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsFunctions.test_varargs @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsFunctions.test_varkw @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsFunctions.test_varkw_only @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsMethods.test_multiple_features @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsMethods.test_plain @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsMethods.test_varargs @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsMethods.test_varkw @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsMethods.test_varkw_only @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsUnboundMethods.test_multiple_features @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsUnboundMethods.test_plain @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsUnboundMethods.test_varargs @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsUnboundMethods.test_varkw @ linux-x86_64 +test.test_inspect.test_inspect.TestGetcallargsUnboundMethods.test_varkw_only @ linux-x86_64 +test.test_inspect.test_inspect.TestGetsourceInteractive.test_getclasses_interactive @ linux-x86_64 +test.test_inspect.test_inspect.TestGettingSourceOfToplevelFrames.test_range_toplevel_frame @ linux-x86_64 +test.test_inspect.test_inspect.TestGettingSourceOfToplevelFrames.test_range_traceback_toplevel_frame @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test__all__ @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test_abuse_done @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test_frame @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test_previous_frame @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test_stack @ linux-x86_64 +test.test_inspect.test_inspect.TestInterpreterStack.test_trace @ linux-x86_64 +test.test_inspect.test_inspect.TestIsDataDescriptor.test_custom_descriptors @ linux-x86_64 +test.test_inspect.test_inspect.TestIsDataDescriptor.test_functions @ linux-x86_64 +test.test_inspect.test_inspect.TestIsDataDescriptor.test_property @ linux-x86_64 +test.test_inspect.test_inspect.TestIsDataDescriptor.test_slot @ linux-x86_64 +test.test_inspect.test_inspect.TestMain.test_builtins @ linux-x86_64 +test.test_inspect.test_inspect.TestMain.test_custom_getattr @ linux-x86_64 +test.test_inspect.test_inspect.TestMain.test_only_source @ linux-x86_64 +test.test_inspect.test_inspect.TestMain.test_qualname_source @ linux-x86_64 +test.test_inspect.test_inspect.TestNoEOL.test_class @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_anonymous @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_lambda_in_list @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_manyargs @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_oneline_lambda @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_onelinefunc @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_threeline_lambda @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_twoline_indented_lambda @ linux-x86_64 +test.test_inspect.test_inspect.TestOneliners.test_twolinefunc @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_equality @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_hashable @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_immutability @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_kinds @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_object @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_positional_only @ linux-x86_64 +test.test_inspect.test_inspect.TestParameterObject.test_signature_parameter_replace @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test__all__ @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test_get_slot_members @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test_isabstract @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test_isabstract_during_init_subclass @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test_isclass @ linux-x86_64 +test.test_inspect.test_inspect.TestPredicates.test_isroutine @ linux-x86_64 +test.test_inspect.test_inspect.TestReload.test_getsource_reload @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_cleandoc @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_finddoc @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getclasses @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getcomments @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getdoc_inherited @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfile @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfile_broken_repr @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfile_builtin_class @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfile_builtin_function_or_method @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfile_builtin_module @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getframeinfo_get_first_line @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getfunctions @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getmodule @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getmodule_file_not_found @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getmodule_recursion @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getsource @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getsource_on_code_object @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_getsourcefile @ linux-x86_64 +test.test_inspect.test_inspect.TestRetrievingSourceCode.test_proceed_with_fake_filename @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_args_and_kwargs @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_args_and_varargs @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_arguments @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_empty @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_just_args @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_just_kwargs @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_kwonly @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_positional_only @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_posonly_kwargs @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_var @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_vararg_name @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_varargs_order @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureBind.test_signature_bind_with_self_arg @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureDefinitions.test_python_function_override_signature @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signater_parameters_is_ordered @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_annotations_with_local_namespaces @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_definition_order_preserved_on_kwonly @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_equality @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_eval_str @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_from_callable_builtin_obj @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_from_callable_class @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_from_callable_python_obj @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_from_functionlike_object @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_functionlike_class @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_hashable @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_immutability @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_none_annotation @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_object @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_object_pickle @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_callable_objects @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_class @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_classmethod @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_complex_args @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_decorated @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_derived_classes @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_fake_partialmethod @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_generic_subclass @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_lambdas @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_mangled_parameters @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_method @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_mocks @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_noarg @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_non_function @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_noncallable_mocks @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_partial @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_partialmethod @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_staticmethod @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_subclass @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_wargs @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_on_wkwonly @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_replace_anno @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_replaced @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_str @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_str_positional_only @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_without_self @ linux-x86_64 +test.test_inspect.test_inspect.TestSignatureObject.test_signature_wrapped_bound_method @ linux-x86_64 +test.test_inspect.test_inspect.TestSignaturePrivateHelpers.test_signature_strip_non_python_syntax @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_cycle @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_recursion_limit @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_stop @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_unhashable @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_unwrap_one @ linux-x86_64 +test.test_inspect.test_inspect.TestUnwrap.test_unwrap_several @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int.txt new file mode 100644 index 0000000000..a7c86661c0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int.txt @@ -0,0 +1,36 @@ +!test.test_int.IntStrDigitLimitsTests.test_denial_of_service_prevented_int_to_str @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_denial_of_service_prevented_str_to_int @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_disabled_limit @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_int_from_other_bases @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_max_str_digits @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_max_str_digits_edge_cases @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_power_of_two_bases_unlimited @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_sign_not_counted @ linux-x86_64 +test.test_int.IntStrDigitLimitsTests.test_underscores_ignored @ linux-x86_64 +!test.test_int.IntSubclassStrDigitLimitsTests.test_denial_of_service_prevented_int_to_str @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_denial_of_service_prevented_str_to_int @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_disabled_limit @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_int_from_other_bases @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_max_str_digits @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_max_str_digits_edge_cases @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_power_of_two_bases_unlimited @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_sign_not_counted @ linux-x86_64 +test.test_int.IntSubclassStrDigitLimitsTests.test_underscores_ignored @ linux-x86_64 +test.test_int.IntTestCases.test_basic @ linux-x86_64 +test.test_int.IntTestCases.test_error_message @ linux-x86_64 +test.test_int.IntTestCases.test_int_base_bad_types @ linux-x86_64 +test.test_int.IntTestCases.test_int_base_indexable @ linux-x86_64 +test.test_int.IntTestCases.test_int_base_limits @ linux-x86_64 +test.test_int.IntTestCases.test_int_memoryview @ linux-x86_64 +test.test_int.IntTestCases.test_int_returns_int_subclass @ linux-x86_64 +test.test_int.IntTestCases.test_int_subclass_with_index @ linux-x86_64 +test.test_int.IntTestCases.test_int_subclass_with_int @ linux-x86_64 +test.test_int.IntTestCases.test_intconversion @ linux-x86_64 +test.test_int.IntTestCases.test_invalid_signs @ linux-x86_64 +test.test_int.IntTestCases.test_issue31619 @ linux-x86_64 +test.test_int.IntTestCases.test_keyword_args @ linux-x86_64 +test.test_int.IntTestCases.test_no_args @ linux-x86_64 +test.test_int.IntTestCases.test_non_numeric_input_types @ linux-x86_64 +test.test_int.IntTestCases.test_string_float @ linux-x86_64 +test.test_int.IntTestCases.test_underscores @ linux-x86_64 +test.test_int.IntTestCases.test_unicode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int_literal.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int_literal.txt new file mode 100644 index 0000000000..6228e00732 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_int_literal.txt @@ -0,0 +1,6 @@ +test.test_int_literal.TestHexOctBin.test_bin_baseline @ linux-x86_64 +test.test_int_literal.TestHexOctBin.test_bin_unsigned @ linux-x86_64 +test.test_int_literal.TestHexOctBin.test_hex_baseline @ linux-x86_64 +test.test_int_literal.TestHexOctBin.test_hex_unsigned @ linux-x86_64 +test.test_int_literal.TestHexOctBin.test_oct_baseline @ linux-x86_64 +test.test_int_literal.TestHexOctBin.test_oct_unsigned @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_io.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_io.txt new file mode 100644 index 0000000000..fba4892118 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_io.txt @@ -0,0 +1,523 @@ +test.test_io.CBufferedRWPairTest.test_close_and_closed @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_constructor @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_constructor_max_buffer_size_removal @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_constructor_with_not_readable @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_constructor_with_not_writeable @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_detach @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_isatty @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_peek @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_read @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_read1 @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_readable @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_reader_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_reader_writer_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_readinto @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_readlines @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_seekable @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_uninitialized @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_weakref_clearing @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_write @ linux-x86_64 +test.test_io.CBufferedRWPairTest.test_writeable @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_args_error @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_buffering @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_constructor @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_context_manager @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_detach @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_detach_flush @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_fileno @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush_and_peek @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush_and_read @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush_and_readinto @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush_and_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_interleaved_read_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_interleaved_readline_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_invalid_args @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_max_buffer_size_removal @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_misbehaved_io @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_multi_close @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_no_extraneous_read @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read1 @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read1_arbitrary @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read_all @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read_and_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read_non_blocking @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read_on_closed @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_read_past_eof @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readinto @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readinto1 @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readinto1_array @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readinto_array @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readlines @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_readonly_attributes @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_repr @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_seek_and_tell @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_slow_close_from_thread @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_threads @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_truncate @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_truncate_after_read_or_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_truncate_after_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_uninitialized @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_after_readahead @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_and_rewind @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_error_on_close @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_non_blocking @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_overflow @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_write_rewind_write @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writelines @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writelines_error @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writelines_userlist @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_flushes @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_peek @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_read1s @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_readintos @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_reads @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_seeks @ linux-x86_64 +test.test_io.CBufferedRandomTest.test_writes_and_truncates @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_args_error @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_bad_readinto_type @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_bad_readinto_value @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_buffering @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_constructor @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_context_manager @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_detach @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_fileno @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_initialization @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_invalid_args @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_misbehaved_io @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_misbehaved_io_read @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_multi_close @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_no_extraneous_read @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read1 @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read1_arbitrary @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read_all @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read_non_blocking @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read_on_closed @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_read_past_eof @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readinto @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readinto1 @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readinto1_array @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readinto_array @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readlines @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_readonly_attributes @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_repr @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_threads @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_truncate_on_read_only @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_uninitialized @ linux-x86_64 +test.test_io.CBufferedReaderTest.test_unseekable @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_args_error @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_constructor @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_context_manager @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_detach @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_detach_flush @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_fileno @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_flush @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_initialization @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_invalid_args @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_max_buffer_size_removal @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_misbehaved_io @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_multi_close @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_readonly_attributes @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_repr @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_slow_close_from_thread @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_threads @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_truncate @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_truncate_after_write @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_uninitialized @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_unseekable @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_write @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_write_and_rewind @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_write_error_on_close @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_write_non_blocking @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_write_overflow @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writelines @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writelines_error @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writelines_userlist @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writes @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writes_and_flushes @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writes_and_seeks @ linux-x86_64 +test.test_io.CBufferedWriterTest.test_writes_and_truncates @ linux-x86_64 +test.test_io.CIOTest.test_BufferedIOBase_readinto @ linux-x86_64 +test.test_io.CIOTest.test_RawIOBase_read @ linux-x86_64 +test.test_io.CIOTest.test_RawIOBase_readall @ linux-x86_64 +test.test_io.CIOTest.test_append_mode_tell @ linux-x86_64 +test.test_io.CIOTest.test_array_writes @ linux-x86_64 +test.test_io.CIOTest.test_bad_opener_negative_1 @ linux-x86_64 +test.test_io.CIOTest.test_bad_opener_other_negative @ linux-x86_64 +test.test_io.CIOTest.test_buffered_file_io @ linux-x86_64 +test.test_io.CIOTest.test_buffered_readinto_mixin @ linux-x86_64 +test.test_io.CIOTest.test_close_assert @ linux-x86_64 +test.test_io.CIOTest.test_close_flushes @ linux-x86_64 +test.test_io.CIOTest.test_closefd @ linux-x86_64 +test.test_io.CIOTest.test_closefd_attr @ linux-x86_64 +test.test_io.CIOTest.test_fileio_closefd @ linux-x86_64 +test.test_io.CIOTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.CIOTest.test_fspath_support @ linux-x86_64 +test.test_io.CIOTest.test_invalid_newline @ linux-x86_64 +test.test_io.CIOTest.test_invalid_operations @ linux-x86_64 +test.test_io.CIOTest.test_large_file_ops @ linux-x86_64 +test.test_io.CIOTest.test_multi_close @ linux-x86_64 +test.test_io.CIOTest.test_next_nonsizeable @ linux-x86_64 +test.test_io.CIOTest.test_no_closefd_with_filename @ linux-x86_64 +test.test_io.CIOTest.test_nonbuffered_textio @ linux-x86_64 +test.test_io.CIOTest.test_open_handles_NUL_chars @ linux-x86_64 +test.test_io.CIOTest.test_opener @ linux-x86_64 +test.test_io.CIOTest.test_opener_invalid_fd @ linux-x86_64 +test.test_io.CIOTest.test_optional_abilities @ linux-x86_64 +test.test_io.CIOTest.test_raw_bytes_io @ linux-x86_64 +test.test_io.CIOTest.test_raw_file_io @ linux-x86_64 +test.test_io.CIOTest.test_read_closed @ linux-x86_64 +test.test_io.CIOTest.test_readline @ linux-x86_64 +test.test_io.CIOTest.test_readline_nonsizeable @ linux-x86_64 +test.test_io.CIOTest.test_types_have_dict @ linux-x86_64 +test.test_io.CIOTest.test_with_open @ linux-x86_64 +test.test_io.CIncrementalNewlineDecoderTest.test_newline_bytes @ linux-x86_64 +test.test_io.CIncrementalNewlineDecoderTest.test_newline_decoder @ linux-x86_64 +test.test_io.CIncrementalNewlineDecoderTest.test_translate @ linux-x86_64 +test.test_io.CMiscIOTest.test___all__ @ linux-x86_64 +test.test_io.CMiscIOTest.test_abc_inheritance @ linux-x86_64 +test.test_io.CMiscIOTest.test_abc_inheritance_official @ linux-x86_64 +test.test_io.CMiscIOTest.test_abcs @ linux-x86_64 +test.test_io.CMiscIOTest.test_attributes @ linux-x86_64 +test.test_io.CMiscIOTest.test_check_encoding_warning @ linux-x86_64 +test.test_io.CMiscIOTest.test_create_fail @ linux-x86_64 +test.test_io.CMiscIOTest.test_create_writes @ linux-x86_64 +test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stderr_deadlock @ linux-x86_64 +test.test_io.CMiscIOTest.test_daemon_threads_shutdown_stdout_deadlock @ linux-x86_64 +test.test_io.CMiscIOTest.test_io_after_close @ linux-x86_64 +test.test_io.CMiscIOTest.test_nonblock_pipe_write_bigbuf @ linux-x86_64 +test.test_io.CMiscIOTest.test_nonblock_pipe_write_smallbuf @ linux-x86_64 +test.test_io.CMiscIOTest.test_open_allargs @ linux-x86_64 +test.test_io.CMiscIOTest.test_open_pipe_with_append @ linux-x86_64 +test.test_io.CMiscIOTest.test_pickling @ linux-x86_64 +test.test_io.CMiscIOTest.test_readinto_buffer_overflow @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_basic_io @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_bufio_write_through @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_close_error_on_close @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_constructor @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_default_encoding @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_del__CHUNK_SIZE_SystemError @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_detach @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_encoding @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_encoding_errors_reading @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_encoding_errors_writing @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_error_through_destructor @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_errors_property @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_illegal_decoder @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_illegal_encoder @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_initialization @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_internal_buffer_size @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue1395_1 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue1395_2 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue1395_3 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue1395_4 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue1395_5 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue2282 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue22849 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_issue25862 @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_line_buffering @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_multi_close @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_multibyte_seek_and_tell @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_newlines @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_newlines_input @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_newlines_output @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_non_text_encoding_codecs_are_rejected @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_rawio @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_rawio_write_through @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_read_by_chunk @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_read_byteslike @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_read_nonbytes @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_read_one_by_one @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_readlines @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_readonly_attributes @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_defaults @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_encoding_read @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_line_buffering @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_newline @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_write @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_write_fromascii @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_write_non_seekable @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_reconfigure_write_through @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_repr @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_seek_and_tell @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_seeking @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_seeking_too @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_telling @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_threads_write @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_uninitialized @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_unreadable @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_unseekable @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_writelines @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_writelines_error @ linux-x86_64 +test.test_io.CTextIOWrapperTest.test_writelines_userlist @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_close_and_closed @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_constructor @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_constructor_max_buffer_size_removal @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_constructor_with_not_readable @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_constructor_with_not_writeable @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_detach @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_isatty @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_peek @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_read @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_read1 @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_readable @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_reader_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_reader_writer_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_readinto @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_readlines @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_seekable @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_uninitialized @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_weakref_clearing @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_write @ linux-x86_64 +test.test_io.PyBufferedRWPairTest.test_writeable @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_buffering @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_constructor @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_context_manager @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_detach @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_detach_flush @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_fileno @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush_and_peek @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush_and_read @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush_and_readinto @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush_and_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_interleaved_read_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_interleaved_readline_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_invalid_args @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_max_buffer_size_removal @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_misbehaved_io @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_multi_close @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_no_extraneous_read @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read1 @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read1_arbitrary @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read_all @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read_and_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read_non_blocking @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read_on_closed @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_read_past_eof @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readinto @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readinto1 @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readinto1_array @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readinto_array @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readlines @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_readonly_attributes @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_repr @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_seek_and_tell @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_slow_close_from_thread @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_threads @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_truncate @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_truncate_after_read_or_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_truncate_after_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_uninitialized @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_after_readahead @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_and_rewind @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_error_on_close @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_non_blocking @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_overflow @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_write_rewind_write @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writelines @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writelines_error @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writelines_userlist @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_flushes @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_peek @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_read1s @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_readintos @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_reads @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_seeks @ linux-x86_64 +test.test_io.PyBufferedRandomTest.test_writes_and_truncates @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_buffering @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_constructor @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_context_manager @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_detach @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_fileno @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_invalid_args @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_misbehaved_io @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_multi_close @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_no_extraneous_read @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read1 @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read1_arbitrary @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read_all @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read_non_blocking @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read_on_closed @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_read_past_eof @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readinto @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readinto1 @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readinto1_array @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readinto_array @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readlines @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_readonly_attributes @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_repr @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_threads @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_truncate_on_read_only @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_uninitialized @ linux-x86_64 +test.test_io.PyBufferedReaderTest.test_unseekable @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_constructor @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_context_manager @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_detach @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_detach_flush @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_fileno @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_flush @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_invalid_args @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_max_buffer_size_removal @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_misbehaved_io @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_multi_close @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_readonly_attributes @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_repr @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_slow_close_from_thread @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_threads @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_truncate @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_truncate_after_write @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_uninitialized @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_unseekable @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_write @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_write_and_rewind @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_write_error_on_close @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_write_non_blocking @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_write_overflow @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writelines @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writelines_error @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writelines_userlist @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writes @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writes_and_flushes @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writes_and_seeks @ linux-x86_64 +test.test_io.PyBufferedWriterTest.test_writes_and_truncates @ linux-x86_64 +test.test_io.PyIOTest.test_BufferedIOBase_readinto @ linux-x86_64 +test.test_io.PyIOTest.test_RawIOBase_read @ linux-x86_64 +test.test_io.PyIOTest.test_RawIOBase_readall @ linux-x86_64 +test.test_io.PyIOTest.test_append_mode_tell @ linux-x86_64 +test.test_io.PyIOTest.test_array_writes @ linux-x86_64 +test.test_io.PyIOTest.test_bad_opener_negative_1 @ linux-x86_64 +test.test_io.PyIOTest.test_bad_opener_other_negative @ linux-x86_64 +test.test_io.PyIOTest.test_buffered_file_io @ linux-x86_64 +test.test_io.PyIOTest.test_buffered_readinto_mixin @ linux-x86_64 +test.test_io.PyIOTest.test_close_assert @ linux-x86_64 +test.test_io.PyIOTest.test_close_flushes @ linux-x86_64 +test.test_io.PyIOTest.test_closefd @ linux-x86_64 +test.test_io.PyIOTest.test_closefd_attr @ linux-x86_64 +test.test_io.PyIOTest.test_fileio_closefd @ linux-x86_64 +test.test_io.PyIOTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.PyIOTest.test_fspath_support @ linux-x86_64 +test.test_io.PyIOTest.test_invalid_newline @ linux-x86_64 +test.test_io.PyIOTest.test_invalid_operations @ linux-x86_64 +test.test_io.PyIOTest.test_large_file_ops @ linux-x86_64 +test.test_io.PyIOTest.test_multi_close @ linux-x86_64 +test.test_io.PyIOTest.test_next_nonsizeable @ linux-x86_64 +test.test_io.PyIOTest.test_no_closefd_with_filename @ linux-x86_64 +test.test_io.PyIOTest.test_nonbuffered_textio @ linux-x86_64 +test.test_io.PyIOTest.test_open_handles_NUL_chars @ linux-x86_64 +test.test_io.PyIOTest.test_opener @ linux-x86_64 +test.test_io.PyIOTest.test_opener_invalid_fd @ linux-x86_64 +test.test_io.PyIOTest.test_optional_abilities @ linux-x86_64 +test.test_io.PyIOTest.test_raw_bytes_io @ linux-x86_64 +test.test_io.PyIOTest.test_raw_file_io @ linux-x86_64 +test.test_io.PyIOTest.test_read_closed @ linux-x86_64 +test.test_io.PyIOTest.test_readline @ linux-x86_64 +test.test_io.PyIOTest.test_readline_nonsizeable @ linux-x86_64 +test.test_io.PyIOTest.test_types_have_dict @ linux-x86_64 +test.test_io.PyIOTest.test_with_open @ linux-x86_64 +test.test_io.PyIncrementalNewlineDecoderTest.test_newline_bytes @ linux-x86_64 +test.test_io.PyIncrementalNewlineDecoderTest.test_newline_decoder @ linux-x86_64 +test.test_io.PyIncrementalNewlineDecoderTest.test_translate @ linux-x86_64 +test.test_io.PyMiscIOTest.test___all__ @ linux-x86_64 +test.test_io.PyMiscIOTest.test_abc_inheritance @ linux-x86_64 +test.test_io.PyMiscIOTest.test_abc_inheritance_official @ linux-x86_64 +test.test_io.PyMiscIOTest.test_abcs @ linux-x86_64 +test.test_io.PyMiscIOTest.test_attributes @ linux-x86_64 +test.test_io.PyMiscIOTest.test_check_encoding_warning @ linux-x86_64 +test.test_io.PyMiscIOTest.test_create_fail @ linux-x86_64 +test.test_io.PyMiscIOTest.test_create_writes @ linux-x86_64 +test.test_io.PyMiscIOTest.test_io_after_close @ linux-x86_64 +test.test_io.PyMiscIOTest.test_nonblock_pipe_write_bigbuf @ linux-x86_64 +test.test_io.PyMiscIOTest.test_nonblock_pipe_write_smallbuf @ linux-x86_64 +test.test_io.PyMiscIOTest.test_open_allargs @ linux-x86_64 +test.test_io.PyMiscIOTest.test_open_pipe_with_append @ linux-x86_64 +test.test_io.PyMiscIOTest.test_pickling @ linux-x86_64 +test.test_io.PyMiscIOTest.test_removed_u_mode @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_basic_io @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_bufio_write_through @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_close_error_on_close @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_constructor @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_default_encoding @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_detach @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_encoding @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_encoding_errors_reading @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_encoding_errors_writing @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_error_through_destructor @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_errors_property @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_flush_error_on_close @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_illegal_decoder @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_illegal_encoder @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue1395_1 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue1395_2 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue1395_3 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue1395_4 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue1395_5 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue2282 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue22849 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_issue25862 @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_line_buffering @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_multi_close @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_multibyte_seek_and_tell @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_newlines @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_newlines_input @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_newlines_output @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_non_text_encoding_codecs_are_rejected @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_nonnormalized_close_error_on_close @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_rawio @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_rawio_write_through @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_read_by_chunk @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_read_byteslike @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_read_nonbytes @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_read_one_by_one @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_readlines @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_readonly_attributes @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_defaults @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_encoding_read @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_errors @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_line_buffering @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_newline @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_write @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_write_fromascii @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_write_non_seekable @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_reconfigure_write_through @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_repr @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_seek_and_tell @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_seeking @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_seeking_too @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_telling @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_threads_write @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_uninitialized @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_unreadable @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_unseekable @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_writelines @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_writelines_error @ linux-x86_64 +test.test_io.PyTextIOWrapperTest.test_writelines_userlist @ linux-x86_64 +test.test_io.StatefulIncrementalDecoderTest.test_decoder @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ipaddress.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ipaddress.txt new file mode 100644 index 0000000000..57e91a4198 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ipaddress.txt @@ -0,0 +1,204 @@ +test.test_ipaddress.AddressTestCase_v4.test_bad_address_split @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_empty_address @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_empty_octet @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_format @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_int @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_invalid_characters @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_network_passed_as_address @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_octet_length @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_octet_limit @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_packed @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_pickle @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v4.test_weakref @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_leading_colon @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_not_enough_parts @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_repeated_double_colon @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_too_many_colons @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_too_many_parts @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_too_many_parts_with_double_colon @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_address_split_v6_trailing_colon @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_bad_v4_part_in @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_blank_scope_id @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_copy @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_empty_address @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_format @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_int @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_invalid_characters @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_invalid_scope_id_with_percent @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_network_passed_as_address @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_packed @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_part_length @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_pickle @ linux-x86_64 +test.test_ipaddress.AddressTestCase_v6.test_weakref @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_containment @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_foreign_type_equality @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_foreign_type_ordering @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_incompatible_versions @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_mixed_type_equality @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_mixed_type_key @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_mixed_type_ordering @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_same_type_equality @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_same_type_ordering @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_scoped_ipv6_equality @ linux-x86_64 +test.test_ipaddress.ComparisonTests.test_v4_with_v6_scoped_equality @ linux-x86_64 +test.test_ipaddress.FactoryFunctionErrors.test_ip_address @ linux-x86_64 +test.test_ipaddress.FactoryFunctionErrors.test_ip_interface @ linux-x86_64 +test.test_ipaddress.FactoryFunctionErrors.test_ip_network @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_address_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_empty_address @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_int @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_netmask_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_netmask_in_tuple_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_no_mask @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_packed @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_pickle @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_split_netmask @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v4.test_valid_netmask @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_address_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_blank_scope_id @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_empty_address @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_int @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_invalid_scope_id_with_percent @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_netmask_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_netmask_in_tuple_errors @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_no_mask @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_packed @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_pickle @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_split_netmask @ linux-x86_64 +test.test_ipaddress.InterfaceTestCase_v6.test_valid_netmask @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testAddrExclude @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testAddressComparison @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testAddressIntMath @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testCollapsing @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testCompressIPv6Address @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testContains @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testCopyConstructor @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testEmbeddedIpv4 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testEqual @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testExplodeShortHandIpStr @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testFancySubnetting @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testForceVersion @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetBroadcast @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetIp @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetNetmask @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetNetwork @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetNum_Addresses @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetPrefixlen @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetScopeId @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSubnetForSingle128 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSubnetForSingle32 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSubnets @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSubnets3 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSupernet @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSupernet3 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetSupernet4 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testGetitem @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testHash @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testHosts @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPBases @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPVersion @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv4Net @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv4NetworkHelpers @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv4Tuple @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv6AddressTooLarge @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv6NetworkHelpers @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIPv6Tuple @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIntRepresentation @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testInterfaceComparison @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testInternals @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testInvalidIntToBytes @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIpFromInt @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIpFromPacked @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIpType @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIpv4Mapped @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testIpv4MappedPrivateCheck @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testMaxPrefixLength @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testNetworkComparison @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testNetworkElementCaching @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testNotEqual @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testNth @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testOverlaps @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testPacked @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testPrivateNetworks @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testRepr @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testReservedIpv4 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testReservedIpv6 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testReversePointer @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSlash0Constructor @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSlash128Constructor @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSlash32Constructor @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testStrictNetworks @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSubnet2 @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSubnetFailsForLargeCidrDiff @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSubnetFailsForNegativeCidrDiff @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSummarizing @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testSupernetFailsForLargeCidrDiff @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testTeredo @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testV4HashIsNotConstant @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testV6HashIsNotConstant @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testWithStar @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testZeroNetmask @ linux-x86_64 +test.test_ipaddress.IpaddrUnitTest.testsixtofour @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_address_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_empty_address @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_int @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_netmask_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_netmask_in_tuple_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_no_mask @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_packed @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_pickle @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_split_netmask @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_subnet_of @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_subnet_of_mixed_types @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_supernet_of @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v4.test_valid_netmask @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_address_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_bad_packed_length @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_blank_scope_id @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_empty_address @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_floats_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_int @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_invalid_scope_id_with_percent @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_large_ints_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_leading_zeros @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_negative_ints_rejected @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_netmask_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_netmask_in_tuple_errors @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_no_mask @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_not_an_index_issue15559 @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_packed @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_pickle @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_split_netmask @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_subnet_of @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_supernet_of @ linux-x86_64 +test.test_ipaddress.NetworkTestCase_v6.test_valid_netmask @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_isinstance.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_isinstance.txt new file mode 100644 index 0000000000..25d29c2028 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_isinstance.txt @@ -0,0 +1,22 @@ +test.test_isinstance.TestIsInstanceExceptions.test_bases_raises_other_than_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsInstanceExceptions.test_class_has_no_bases @ linux-x86_64 +test.test_isinstance.TestIsInstanceExceptions.test_dont_mask_non_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsInstanceExceptions.test_isinstance_dont_mask_non_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsInstanceExceptions.test_mask_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_infinite_cycle_in_bases @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_infinite_recursion_in_bases @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_infinitely_many_bases @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_isinstance_abstract @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_isinstance_normal @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_isinstance_recursion_limit @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_isinstance_with_or_union @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_issubclass_refcount_handling @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_subclass_abstract @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_subclass_normal @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_subclass_recursion_limit @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_subclass_tuple @ linux-x86_64 +test.test_isinstance.TestIsInstanceIsSubclass.test_subclass_with_union @ linux-x86_64 +test.test_isinstance.TestIsSubclassExceptions.test_dont_mask_non_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsSubclassExceptions.test_dont_mask_non_attribute_error_in_cls_arg @ linux-x86_64 +test.test_isinstance.TestIsSubclassExceptions.test_mask_attribute_error @ linux-x86_64 +test.test_isinstance.TestIsSubclassExceptions.test_mask_attribute_error_in_cls_arg @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iter.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iter.txt new file mode 100644 index 0000000000..f613726e1b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iter.txt @@ -0,0 +1,51 @@ +test.test_iter.TestCase.test_3720 @ linux-x86_64 +test.test_iter.TestCase.test_builtin_filter @ linux-x86_64 +test.test_iter.TestCase.test_builtin_list @ linux-x86_64 +test.test_iter.TestCase.test_builtin_map @ linux-x86_64 +test.test_iter.TestCase.test_builtin_max_min @ linux-x86_64 +test.test_iter.TestCase.test_builtin_tuple @ linux-x86_64 +test.test_iter.TestCase.test_builtin_zip @ linux-x86_64 +test.test_iter.TestCase.test_countOf @ linux-x86_64 +test.test_iter.TestCase.test_error_iter @ linux-x86_64 +test.test_iter.TestCase.test_exception_function @ linux-x86_64 +test.test_iter.TestCase.test_exception_sequence @ linux-x86_64 +test.test_iter.TestCase.test_extending_list_with_iterator_does_not_segfault @ linux-x86_64 +test.test_iter.TestCase.test_in_and_not_in @ linux-x86_64 +test.test_iter.TestCase.test_indexOf @ linux-x86_64 +test.test_iter.TestCase.test_iter_basic @ linux-x86_64 +test.test_iter.TestCase.test_iter_big_range @ linux-x86_64 +test.test_iter.TestCase.test_iter_callable @ linux-x86_64 +test.test_iter.TestCase.test_iter_class_for @ linux-x86_64 +test.test_iter.TestCase.test_iter_class_iter @ linux-x86_64 +test.test_iter.TestCase.test_iter_dict @ linux-x86_64 +test.test_iter.TestCase.test_iter_empty @ linux-x86_64 +test.test_iter.TestCase.test_iter_file @ linux-x86_64 +test.test_iter.TestCase.test_iter_for_loop @ linux-x86_64 +test.test_iter.TestCase.test_iter_function @ linux-x86_64 +test.test_iter.TestCase.test_iter_function_stop @ linux-x86_64 +test.test_iter.TestCase.test_iter_idempotency @ linux-x86_64 +test.test_iter.TestCase.test_iter_independence @ linux-x86_64 +test.test_iter.TestCase.test_iter_neg_setstate @ linux-x86_64 +test.test_iter.TestCase.test_iter_range @ linux-x86_64 +test.test_iter.TestCase.test_iter_string @ linux-x86_64 +test.test_iter.TestCase.test_iter_tuple @ linux-x86_64 +test.test_iter.TestCase.test_mutating_seq_class_exhausted_iter @ linux-x86_64 +test.test_iter.TestCase.test_mutating_seq_class_iter_pickle @ linux-x86_64 +test.test_iter.TestCase.test_nested_comprehensions_for @ linux-x86_64 +test.test_iter.TestCase.test_nested_comprehensions_iter @ linux-x86_64 +test.test_iter.TestCase.test_new_style_iter_class @ linux-x86_64 +test.test_iter.TestCase.test_seq_class_for @ linux-x86_64 +test.test_iter.TestCase.test_seq_class_iter @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_callable @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_dict @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_enumerate @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_list @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_range @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_sequence @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_string @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_tuple @ linux-x86_64 +test.test_iter.TestCase.test_sinkstate_yield @ linux-x86_64 +test.test_iter.TestCase.test_stop_sequence @ linux-x86_64 +test.test_iter.TestCase.test_unicode_join_endcase @ linux-x86_64 +test.test_iter.TestCase.test_unpack_iter @ linux-x86_64 +test.test_iter.TestCase.test_writelines @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iterlen.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iterlen.txt new file mode 100644 index 0000000000..42c583084e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_iterlen.txt @@ -0,0 +1,21 @@ +test.test_iterlen.TestDeque.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestDeque.test_invariant @ linux-x86_64 +test.test_iterlen.TestDequeReversed.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestDequeReversed.test_invariant @ linux-x86_64 +test.test_iterlen.TestDictItems.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestDictItems.test_invariant @ linux-x86_64 +test.test_iterlen.TestDictKeys.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestDictKeys.test_invariant @ linux-x86_64 +test.test_iterlen.TestDictValues.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestDictValues.test_invariant @ linux-x86_64 +test.test_iterlen.TestLengthHintExceptions.test_invalid_hint @ linux-x86_64 +test.test_iterlen.TestLengthHintExceptions.test_issue1242657 @ linux-x86_64 +test.test_iterlen.TestList.test_invariant @ linux-x86_64 +test.test_iterlen.TestListReversed.test_invariant @ linux-x86_64 +test.test_iterlen.TestListReversed.test_mutation @ linux-x86_64 +test.test_iterlen.TestRepeat.test_invariant @ linux-x86_64 +test.test_iterlen.TestSet.test_immutable_during_iteration @ linux-x86_64 +test.test_iterlen.TestSet.test_invariant @ linux-x86_64 +test.test_iterlen.TestTuple.test_invariant @ linux-x86_64 +test.test_iterlen.TestXrange.test_invariant @ linux-x86_64 +test.test_iterlen.TestXrangeCustomReversed.test_invariant @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_itertools.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_itertools.txt new file mode 100644 index 0000000000..1788425219 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_itertools.txt @@ -0,0 +1,114 @@ +test.test_itertools.LengthTransparency.test_repeat @ linux-x86_64 +test.test_itertools.LengthTransparency.test_repeat_with_negative_times @ linux-x86_64 +test.test_itertools.RegressionTests.test_issue30347_1 @ linux-x86_64 +test.test_itertools.RegressionTests.test_issue30347_2 @ linux-x86_64 +test.test_itertools.RegressionTests.test_long_chain_of_empty_iterables @ linux-x86_64 +test.test_itertools.RegressionTests.test_sf_793826 @ linux-x86_64 +test.test_itertools.RegressionTests.test_sf_950057 @ linux-x86_64 +test.test_itertools.SubclassWithKwargsTest.test_keywords_in_subclass @ linux-x86_64 +test.test_itertools.TestBasicOps.test_StopIteration @ linux-x86_64 +test.test_itertools.TestBasicOps.test_accumulate @ linux-x86_64 +test.test_itertools.TestBasicOps.test_bug_7244 @ linux-x86_64 +test.test_itertools.TestBasicOps.test_chain @ linux-x86_64 +test.test_itertools.TestBasicOps.test_chain_from_iterable @ linux-x86_64 +test.test_itertools.TestBasicOps.test_chain_reducible @ linux-x86_64 +test.test_itertools.TestBasicOps.test_chain_setstate @ linux-x86_64 +test.test_itertools.TestBasicOps.test_combinations @ linux-x86_64 +test.test_itertools.TestBasicOps.test_combinations_with_replacement @ linux-x86_64 +test.test_itertools.TestBasicOps.test_combinatorics @ linux-x86_64 +test.test_itertools.TestBasicOps.test_compress @ linux-x86_64 +test.test_itertools.TestBasicOps.test_count @ linux-x86_64 +test.test_itertools.TestBasicOps.test_count_with_stride @ linux-x86_64 +test.test_itertools.TestBasicOps.test_cycle @ linux-x86_64 +test.test_itertools.TestBasicOps.test_cycle_copy_pickle @ linux-x86_64 +test.test_itertools.TestBasicOps.test_cycle_setstate @ linux-x86_64 +test.test_itertools.TestBasicOps.test_cycle_unpickle_compat @ linux-x86_64 +test.test_itertools.TestBasicOps.test_dropwhile @ linux-x86_64 +test.test_itertools.TestBasicOps.test_filter @ linux-x86_64 +test.test_itertools.TestBasicOps.test_filterfalse @ linux-x86_64 +test.test_itertools.TestBasicOps.test_groupby @ linux-x86_64 +test.test_itertools.TestBasicOps.test_islice @ linux-x86_64 +test.test_itertools.TestBasicOps.test_map @ linux-x86_64 +test.test_itertools.TestBasicOps.test_pairwise @ linux-x86_64 +test.test_itertools.TestBasicOps.test_pairwise_reenter @ linux-x86_64 +test.test_itertools.TestBasicOps.test_pairwise_reenter2 @ linux-x86_64 +test.test_itertools.TestBasicOps.test_permutations @ linux-x86_64 +test.test_itertools.TestBasicOps.test_product @ linux-x86_64 +test.test_itertools.TestBasicOps.test_product_issue_25021 @ linux-x86_64 +test.test_itertools.TestBasicOps.test_product_pickling @ linux-x86_64 +test.test_itertools.TestBasicOps.test_repeat @ linux-x86_64 +test.test_itertools.TestBasicOps.test_repeat_with_negative_times @ linux-x86_64 +test.test_itertools.TestBasicOps.test_starmap @ linux-x86_64 +test.test_itertools.TestBasicOps.test_takewhile @ linux-x86_64 +test.test_itertools.TestBasicOps.test_tee @ linux-x86_64 +test.test_itertools.TestBasicOps.test_tee_concurrent @ linux-x86_64 +test.test_itertools.TestBasicOps.test_tee_del_backward @ linux-x86_64 +test.test_itertools.TestBasicOps.test_tee_reenter @ linux-x86_64 +test.test_itertools.TestBasicOps.test_zip @ linux-x86_64 +test.test_itertools.TestBasicOps.test_zip_longest_bad_iterable @ linux-x86_64 +test.test_itertools.TestBasicOps.test_zip_longest_pickling @ linux-x86_64 +test.test_itertools.TestBasicOps.test_ziplongest @ linux-x86_64 +test.test_itertools.TestExamples.test_accumulate @ linux-x86_64 +test.test_itertools.TestExamples.test_accumulate_reducible @ linux-x86_64 +test.test_itertools.TestExamples.test_accumulate_reducible_none @ linux-x86_64 +test.test_itertools.TestExamples.test_chain @ linux-x86_64 +test.test_itertools.TestExamples.test_chain_from_iterable @ linux-x86_64 +test.test_itertools.TestExamples.test_combinations @ linux-x86_64 +test.test_itertools.TestExamples.test_combinations_with_replacement @ linux-x86_64 +test.test_itertools.TestExamples.test_compress @ linux-x86_64 +test.test_itertools.TestExamples.test_count @ linux-x86_64 +test.test_itertools.TestExamples.test_cycle @ linux-x86_64 +test.test_itertools.TestExamples.test_dropwhile @ linux-x86_64 +test.test_itertools.TestExamples.test_filter @ linux-x86_64 +test.test_itertools.TestExamples.test_filterfalse @ linux-x86_64 +test.test_itertools.TestExamples.test_groupby @ linux-x86_64 +test.test_itertools.TestExamples.test_islice @ linux-x86_64 +test.test_itertools.TestExamples.test_map @ linux-x86_64 +test.test_itertools.TestExamples.test_permutations @ linux-x86_64 +test.test_itertools.TestExamples.test_product @ linux-x86_64 +test.test_itertools.TestExamples.test_repeat @ linux-x86_64 +test.test_itertools.TestExamples.test_stapmap @ linux-x86_64 +test.test_itertools.TestExamples.test_takewhile @ linux-x86_64 +test.test_itertools.TestExamples.test_zip @ linux-x86_64 +test.test_itertools.TestExamples.test_zip_longest @ linux-x86_64 +test.test_itertools.TestGC.test_accumulate @ linux-x86_64 +test.test_itertools.TestGC.test_chain @ linux-x86_64 +test.test_itertools.TestGC.test_chain_from_iterable @ linux-x86_64 +test.test_itertools.TestGC.test_combinations @ linux-x86_64 +test.test_itertools.TestGC.test_combinations_with_replacement @ linux-x86_64 +test.test_itertools.TestGC.test_compress @ linux-x86_64 +test.test_itertools.TestGC.test_count @ linux-x86_64 +test.test_itertools.TestGC.test_cycle @ linux-x86_64 +test.test_itertools.TestGC.test_dropwhile @ linux-x86_64 +test.test_itertools.TestGC.test_filter @ linux-x86_64 +test.test_itertools.TestGC.test_filterfalse @ linux-x86_64 +test.test_itertools.TestGC.test_groupby @ linux-x86_64 +test.test_itertools.TestGC.test_islice @ linux-x86_64 +test.test_itertools.TestGC.test_issue2246 @ linux-x86_64 +test.test_itertools.TestGC.test_map @ linux-x86_64 +test.test_itertools.TestGC.test_pairwise @ linux-x86_64 +test.test_itertools.TestGC.test_permutations @ linux-x86_64 +test.test_itertools.TestGC.test_product @ linux-x86_64 +test.test_itertools.TestGC.test_repeat @ linux-x86_64 +test.test_itertools.TestGC.test_starmap @ linux-x86_64 +test.test_itertools.TestGC.test_takewhile @ linux-x86_64 +test.test_itertools.TestGC.test_zip @ linux-x86_64 +test.test_itertools.TestGC.test_zip_longest @ linux-x86_64 +test.test_itertools.TestPurePythonRoughEquivalents.test_islice_recipe @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_accumulate @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_chain @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_compress @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_cycle @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_dropwhile @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_filter @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_filterfalse @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_groupby @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_islice @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_map @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_pairwise @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_product @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_starmap @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_takewhile @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_tee @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_zip @ linux-x86_64 +test.test_itertools.TestVariousIteratorArgs.test_ziplongest @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_json.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_json.txt new file mode 100644 index 0000000000..253411101d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_json.txt @@ -0,0 +1,162 @@ +DocTestCase.json @ linux-x86_64 +DocTestCase.json.encoder.JSONEncoder.encode @ linux-x86_64 +test.test_json.TestCTest.test_cjson @ linux-x86_64 +test.test_json.TestPyTest.test_pyjson @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_decimal @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_decoder_optimizations @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_empty_objects @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_extra_data @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_float @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_invalid_escape @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_invalid_input_type @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_keys_reuse @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_limit_int @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_negative_index @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_object_pairs_hook @ linux-x86_64 +test.test_json.test_decode.TestCDecode.test_string_with_utf8_bom @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_decimal @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_decoder_optimizations @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_empty_objects @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_extra_data @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_float @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_invalid_escape @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_invalid_input_type @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_keys_reuse @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_limit_int @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_negative_index @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_object_pairs_hook @ linux-x86_64 +test.test_json.test_decode.TestPyDecode.test_string_with_utf8_bom @ linux-x86_64 +test.test_json.test_default.TestCDefault.test_default @ linux-x86_64 +test.test_json.test_default.TestCDefault.test_ordereddict @ linux-x86_64 +test.test_json.test_default.TestPyDefault.test_default @ linux-x86_64 +test.test_json.test_default.TestPyDefault.test_ordereddict @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_dump @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_dump_skipkeys @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_dumps @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_encode_evil_dict @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_encode_mutated @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_encode_truefalse @ linux-x86_64 +test.test_json.test_dump.TestCDump.test_large_list @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_dump @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_dump_skipkeys @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_dumps @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_encode_evil_dict @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_encode_mutated @ linux-x86_64 +test.test_json.test_dump.TestPyDump.test_encode_truefalse @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestCEncodeBasestringAscii.test_encode_basestring_ascii @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestCEncodeBasestringAscii.test_ordered_dict @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestCEncodeBasestringAscii.test_sorted_dict @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestPyEncodeBasestringAscii.test_encode_basestring_ascii @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestPyEncodeBasestringAscii.test_ordered_dict @ linux-x86_64 +test.test_json.test_encode_basestring_ascii.TestPyEncodeBasestringAscii.test_sorted_dict @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_dict_keys @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_dict_values @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_floats @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_ints @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_list @ linux-x86_64 +test.test_json.test_enum.TestCEnum.test_weird_floats @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_dict_keys @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_dict_values @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_floats @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_ints @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_list @ linux-x86_64 +test.test_json.test_enum.TestPyEnum.test_weird_floats @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_extra_data @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_failures @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_linecol @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_non_string_keys_dict @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_not_serializable @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_truncated_input @ linux-x86_64 +test.test_json.test_fail.TestCFail.test_unexpected_data @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_extra_data @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_failures @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_linecol @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_not_serializable @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_truncated_input @ linux-x86_64 +test.test_json.test_fail.TestPyFail.test_unexpected_data @ linux-x86_64 +test.test_json.test_float.TestCFloat.test_allow_nan @ linux-x86_64 +test.test_json.test_float.TestCFloat.test_floats @ linux-x86_64 +test.test_json.test_float.TestCFloat.test_ints @ linux-x86_64 +test.test_json.test_float.TestCFloat.test_out_of_range @ linux-x86_64 +test.test_json.test_float.TestPyFloat.test_allow_nan @ linux-x86_64 +test.test_json.test_float.TestPyFloat.test_floats @ linux-x86_64 +test.test_json.test_float.TestPyFloat.test_ints @ linux-x86_64 +test.test_json.test_float.TestPyFloat.test_out_of_range @ linux-x86_64 +test.test_json.test_indent.TestCIndent.test_indent @ linux-x86_64 +test.test_json.test_indent.TestCIndent.test_indent0 @ linux-x86_64 +test.test_json.test_indent.TestPyIndent.test_indent @ linux-x86_64 +test.test_json.test_indent.TestPyIndent.test_indent0 @ linux-x86_64 +test.test_json.test_pass1.TestCPass1.test_parse @ linux-x86_64 +test.test_json.test_pass1.TestPyPass1.test_parse @ linux-x86_64 +test.test_json.test_pass2.TestCPass2.test_parse @ linux-x86_64 +test.test_json.test_pass2.TestPyPass2.test_parse @ linux-x86_64 +test.test_json.test_pass3.TestCPass3.test_parse @ linux-x86_64 +test.test_json.test_pass3.TestPyPass3.test_parse @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_defaultrecursion @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_dictrecursion @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_endless_recursion @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_highly_nested_objects_decoding @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_highly_nested_objects_encoding @ linux-x86_64 +test.test_json.test_recursion.TestCRecursion.test_listrecursion @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_defaultrecursion @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_dictrecursion @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_endless_recursion @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_highly_nested_objects_decoding @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_highly_nested_objects_encoding @ linux-x86_64 +test.test_json.test_recursion.TestPyRecursion.test_listrecursion @ linux-x86_64 +test.test_json.test_scanstring.TestCScanstring.test_bad_escapes @ linux-x86_64 +test.test_json.test_scanstring.TestCScanstring.test_overflow @ linux-x86_64 +test.test_json.test_scanstring.TestPyScanstring.test_bad_escapes @ linux-x86_64 +test.test_json.test_scanstring.TestPyScanstring.test_overflow @ linux-x86_64 +test.test_json.test_scanstring.TestPyScanstring.test_scanstring @ linux-x86_64 +test.test_json.test_scanstring.TestPyScanstring.test_surrogates @ linux-x86_64 +test.test_json.test_separators.TestCSeparators.test_illegal_separators @ linux-x86_64 +test.test_json.test_separators.TestCSeparators.test_separators @ linux-x86_64 +test.test_json.test_separators.TestPySeparators.test_illegal_separators @ linux-x86_64 +test.test_json.test_separators.TestPySeparators.test_separators @ linux-x86_64 +test.test_json.test_speedups.TestDecode.test_bad_bool_args @ linux-x86_64 +test.test_json.test_speedups.TestDecode.test_make_scanner @ linux-x86_64 +test.test_json.test_speedups.TestEncode.test_bad_bool_args @ linux-x86_64 +test.test_json.test_speedups.TestEncode.test_bad_markers_argument_to_encoder @ linux-x86_64 +test.test_json.test_speedups.TestEncode.test_bad_str_encoder @ linux-x86_64 +test.test_json.test_speedups.TestEncode.test_make_encoder @ linux-x86_64 +test.test_json.test_speedups.TestEncode.test_unsortable_keys @ linux-x86_64 +test.test_json.test_speedups.TestSpeedups.test_encode_basestring_ascii @ linux-x86_64 +test.test_json.test_speedups.TestSpeedups.test_scanstring @ linux-x86_64 +test.test_json.test_tool.TestTool.test_broken_pipe_error @ linux-x86_64 +test.test_json.test_tool.TestTool.test_compact @ linux-x86_64 +test.test_json.test_tool.TestTool.test_ensure_ascii_default @ linux-x86_64 +test.test_json.test_tool.TestTool.test_help_flag @ linux-x86_64 +test.test_json.test_tool.TestTool.test_indent @ linux-x86_64 +test.test_json.test_tool.TestTool.test_infile_outfile @ linux-x86_64 +test.test_json.test_tool.TestTool.test_infile_stdout @ linux-x86_64 +test.test_json.test_tool.TestTool.test_jsonlines @ linux-x86_64 +test.test_json.test_tool.TestTool.test_no_ensure_ascii_flag @ linux-x86_64 +test.test_json.test_tool.TestTool.test_no_indent @ linux-x86_64 +test.test_json.test_tool.TestTool.test_non_ascii_infile @ linux-x86_64 +test.test_json.test_tool.TestTool.test_sort_keys_flag @ linux-x86_64 +test.test_json.test_tool.TestTool.test_stdin_stdout @ linux-x86_64 +test.test_json.test_tool.TestTool.test_tab @ linux-x86_64 +test.test_json.test_tool.TestTool.test_writing_in_place @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_big_unicode_decode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_big_unicode_encode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_bytes_decode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_bytes_encode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_encoding3 @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_encoding4 @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_encoding5 @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_encoding6 @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_object_pairs_hook_with_unicode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_unicode_decode @ linux-x86_64 +test.test_json.test_unicode.TestCUnicode.test_unicode_preservation @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_big_unicode_decode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_big_unicode_encode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_bytes_decode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_bytes_encode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_encoding3 @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_encoding4 @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_encoding5 @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_encoding6 @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_object_pairs_hook_with_unicode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_unicode_decode @ linux-x86_64 +test.test_json.test_unicode.TestPyUnicode.test_unicode_preservation @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keyword.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keyword.txt new file mode 100644 index 0000000000..3fe1b825db --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keyword.txt @@ -0,0 +1,11 @@ +test.test_keyword.Test_iskeyword.test_all_keywords_fail_to_be_used_as_names @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_all_soft_keywords_can_be_used_as_names @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_async_and_await_are_keywords @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_changing_the_kwlist_does_not_affect_iskeyword @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_changing_the_softkwlist_does_not_affect_issoftkeyword @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_keywords_are_sorted @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_match_and_case_are_soft_keywords @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_none_value_is_not_a_keyword @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_softkeywords_are_sorted @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_true_is_a_keyword @ linux-x86_64 +test.test_keyword.Test_iskeyword.test_uppercase_true_is_not_a_keyword @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keywordonlyarg.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keywordonlyarg.txt new file mode 100644 index 0000000000..159e8d8ca3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_keywordonlyarg.txt @@ -0,0 +1,11 @@ +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testFunctionCall @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testKwDefaults @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testRaiseErrorFuncallWithUnexpectedKeywordArgument @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testSyntaxErrorForFunctionCall @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testSyntaxErrorForFunctionDefinition @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testSyntaxForManyArguments @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.testTooManyPositionalErrorMessage @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.test_default_evaluation_order @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.test_issue13343 @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.test_kwonly_methods @ linux-x86_64 +test.test_keywordonlyarg.KeywordOnlyArgTestCase.test_mangling @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_largefile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_largefile.txt new file mode 100644 index 0000000000..81ba48509d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_largefile.txt @@ -0,0 +1,10 @@ +test.test_largefile.CLargeFileTest.test_lseek @ linux-x86_64 +test.test_largefile.CLargeFileTest.test_osstat @ linux-x86_64 +test.test_largefile.CLargeFileTest.test_seek_read @ linux-x86_64 +test.test_largefile.CLargeFileTest.test_seekable @ linux-x86_64 +test.test_largefile.CLargeFileTest.test_truncate @ linux-x86_64 +test.test_largefile.PyLargeFileTest.test_lseek @ linux-x86_64 +test.test_largefile.PyLargeFileTest.test_osstat @ linux-x86_64 +test.test_largefile.PyLargeFileTest.test_seek_read @ linux-x86_64 +test.test_largefile.PyLargeFileTest.test_seekable @ linux-x86_64 +test.test_largefile.PyLargeFileTest.test_truncate @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lib2to3.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lib2to3.txt new file mode 100644 index 0000000000..97122e8d46 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lib2to3.txt @@ -0,0 +1,660 @@ +lib2to3.tests.test_fixers.Test_apply.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_call @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_complex_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_complex_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_complex_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_dotted_name @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_extreme @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_space_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_space_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_subscript @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_6b @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_7 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_8 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_unchanged_9 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_apply.test_weird_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_asserts.test_deprecated_names @ linux-x86_64 +lib2to3.tests.test_fixers.Test_asserts.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_asserts.test_variants @ linux-x86_64 +lib2to3.tests.test_fixers.Test_basestring.test_basestring @ linux-x86_64 +lib2to3.tests.test_fixers.Test_buffer.test_buffer @ linux-x86_64 +lib2to3.tests.test_fixers.Test_buffer.test_slicing @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_01 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_02 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_03 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_04 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_05 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_06 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_07 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_08 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_09 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_10 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_11 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_12 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_13 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_14 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_15 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_16 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_17 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_18 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_19 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_20 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_21 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_22 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_23 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_24 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_25 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_26 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_27 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_28 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_29 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_30 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_31 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_32 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_trailing_comment @ linux-x86_64 +lib2to3.tests.test_fixers.Test_dict.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_bare_except @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_bare_except_and_else_finally @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_list_unpack @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_multi_class @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_multi_fixed_excepts_before_bare_except @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_one_line_suites @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_simple_no_space_before_target @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_tuple_unpack @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_unchanged_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_weird_target_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_weird_target_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_except.test_weird_target_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_complex_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_complex_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_unchanged_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_unchanged_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_with_globals @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exec.test_with_globals_locals @ linux-x86_64 +lib2to3.tests.test_fixers.Test_execfile.test_conversion @ linux-x86_64 +lib2to3.tests.test_fixers.Test_execfile.test_spacing @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_complex_expression @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_in_a_function @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_names_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_no_sys_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_exitfunc.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_filter.test_filter_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_filter.test_filter_nochange @ linux-x86_64 +lib2to3.tests.test_fixers.Test_filter.test_filter_trailers @ linux-x86_64 +lib2to3.tests.test_fixers.Test_filter.test_future_builtins @ linux-x86_64 +lib2to3.tests.test_fixers.Test_filter.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_funcattrs.test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_funcattrs.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_future.test_future @ linux-x86_64 +lib2to3.tests.test_fixers.Test_future.test_run_order @ linux-x86_64 +lib2to3.tests.test_fixers.Test_getcwdu.test_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_getcwdu.test_comment @ linux-x86_64 +lib2to3.tests.test_fixers.Test_getcwdu.test_indentation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_getcwdu.test_multilation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_getcwdu.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_10 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_11 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_7 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_8 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_has_key.test_9 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_eq_expression @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_eq_reverse @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_eq_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_expression @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_not_expression @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_not_reverse @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_not_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_reverse @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_is_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_ne_expression @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_ne_reverse @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_ne_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_sort_list_call @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_sort_simple_expr @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_sort_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_type_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_while @ linux-x86_64 +lib2to3.tests.test_fixers.Test_idioms.test_while_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_already_relative_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_comments_and_indent @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_dotted_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_dotted_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_dotted_import_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_files_checked @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_import_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_import_from_package @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_in_package @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_local_and_absolute @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_not_in_package @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_prefix @ linux-x86_64 +lib2to3.tests.test_fixers.Test_import.test_with_absolute_import_enabled @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_import_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_import_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_import_module @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_import_module_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_import_module_usage @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_multiple_imports @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_multiple_imports_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports.test_star @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_import_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_import_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_import_module @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_import_module_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_import_module_usage @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports2.test_star @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_after_local_imports_refactoring @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_import_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_import_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_import_module @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_import_module_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_import_module_usage @ linux-x86_64 +lib2to3.tests.test_fixers.Test_imports_fixer_order.test_star @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_idempotency @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_input.test_trailing_comment @ linux-x86_64 +lib2to3.tests.test_fixers.Test_intern.test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_intern.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_intern.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_isinstance.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_isinstance.test_remove_multiple_items @ linux-x86_64 +lib2to3.tests.test_fixers.Test_isinstance.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_0 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_qualified @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_run_order @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_space_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools.test_space_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_ifilter_and_zip_longest @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_import_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_import_star @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_none @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_reduced @ linux-x86_64 +lib2to3.tests.test_fixers.Test_itertools_imports.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_long.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_long.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_long.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_long.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_long.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_None_with_multiple_arguments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_future_builtins @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_map_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_map_nochange @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_map_trailers @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_map.test_trailing_comment @ linux-x86_64 +lib2to3.tests.test_fixers.Test_metaclass.test_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_metaclass.test_meta @ linux-x86_64 +lib2to3.tests.test_fixers.Test_metaclass.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_methodattrs.test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_methodattrs.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_ne.test_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_ne.test_chained @ linux-x86_64 +lib2to3.tests.test_fixers.Test_ne.test_no_spaces @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_assign_to_next @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_assign_to_next_in_list @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_assign_to_next_in_tuple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_builtin_assign @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_builtin_assign_in_list @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_builtin_assign_in_tuple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_method_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_method_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_method_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_method_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_method_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_noncall_access_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_noncall_access_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_noncall_access_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_prefix_preservation_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_assign_list_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_assign_list_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_assign_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_assign_tuple_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_assign_tuple_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_for_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_for_tuple_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_for_tuple_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_funcdef_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_funcdef_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_global_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_global_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_from_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_from_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_from_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_next.test_shadowing_import_from_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_nonzero.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_nonzero.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_nonzero.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_nonzero.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_nonzero.test_unchanged_func @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_comments_and_spacing @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_long_hex @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_long_int_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_long_int_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_octal_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_complex_bare @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_complex_float @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_complex_int @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_exp @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_float @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_hex @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_int @ linux-x86_64 +lib2to3.tests.test_fixers.Test_numliterals.test_unchanged_octal @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_isCallable @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_operator_irepeat @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_operator_isMappingType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_operator_isNumberType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_operator_isSequenceType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_operator_repeat @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_bare_sequenceIncludes @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_irepeat @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_isCallable @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_isMappingType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_isNumberType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_isSequenceType @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_repeat @ linux-x86_64 +lib2to3.tests.test_fixers.Test_operator.test_operator_sequenceIncludes @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_0 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_unchanged_0 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_unchanged_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_paren.test_unchanged_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_idempotency @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_idempotency_print_as_function @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_no_trailing_comma @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_spaces_before_file @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_trailing_comma_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_trailing_comma_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_trailing_comma_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_tuple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_vargs_without_trailing_comma @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_with_future_print_function @ linux-x86_64 +lib2to3.tests.test_fixers.Test_print.test_with_trailing_comma @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_None_value @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_string_exc @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_string_exc_val @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_string_exc_val_tb @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tb_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tuple_detection @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tuple_exc_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tuple_exc_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_tuple_value @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raise.test_with_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_8 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_raw_input.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reduce.test_bug_7253 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reduce.test_call_with_lambda @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reduce.test_simple_call @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reduce.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reload.test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reload.test_comment @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reload.test_space @ linux-x86_64 +lib2to3.tests.test_fixers.Test_reload.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_renames.test_import_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_renames.test_import_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_renames.test_import_module_usage @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_complex @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_nested @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_nested_tuples @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_simple_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_simple_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_repr.test_tuple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_set_literal.test_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_set_literal.test_comments @ linux-x86_64 +lib2to3.tests.test_fixers.Test_set_literal.test_listcomps @ linux-x86_64 +lib2to3.tests.test_fixers.Test_set_literal.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_set_literal.test_whitespace @ linux-x86_64 +lib2to3.tests.test_fixers.Test_standarderror.test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_0 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_sys_exc.test_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_4 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_5 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_6 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_7 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_tb_8 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_untouched_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_untouched_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_untouched_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_warn_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_warn_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_throw.test_warn_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_docstring @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_keywords @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_nested @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_nested_multi_use @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_no_change @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_one_tuple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_parens_single_arg @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_simple @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_simple_multi_use @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_lambda_simple_reverse @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_multi_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_multi_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_semicolon @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_unchanged_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_unchanged_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_unchanged_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_tuple_params.test_varargs @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_bytes_literal_escape_u @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_native_literal_escape_u @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_native_unicode_literal_escape_u @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unichr @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unicode_call @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unicode_literal_1 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unicode_literal_2 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unicode_literal_3 @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_unicode_literal_escape_u @ linux-x86_64 +lib2to3.tests.test_fixers.Test_unicode.test_whitespace @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_import_from @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_import_from_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_import_module @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_import_module_as @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_import_module_usage @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_indented @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_single_import @ linux-x86_64 +lib2to3.tests.test_fixers.Test_urllib.test_star @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_in_consuming_context @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_in_contains_test @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_prefix_preservation @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_range_in_for @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_single_arg @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_three_args @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_two_args @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_wrap_in_list @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange.test_xrange_in_for @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xrange_with_reduce.test_double_transform @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xreadlines.test_attr_ref @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xreadlines.test_call @ linux-x86_64 +lib2to3.tests.test_fixers.Test_xreadlines.test_unchanged @ linux-x86_64 +lib2to3.tests.test_fixers.Test_zip.test_future_builtins @ linux-x86_64 +lib2to3.tests.test_fixers.Test_zip.test_zip_basic @ linux-x86_64 +lib2to3.tests.test_fixers.Test_zip.test_zip_nochange @ linux-x86_64 +lib2to3.tests.test_fixers.Test_zip.test_zip_trailers @ linux-x86_64 +lib2to3.tests.test_parser.TestAsyncAwait.test_async_for @ linux-x86_64 +lib2to3.tests.test_parser.TestAsyncAwait.test_async_generator @ linux-x86_64 +lib2to3.tests.test_parser.TestAsyncAwait.test_async_var @ linux-x86_64 +lib2to3.tests.test_parser.TestAsyncAwait.test_async_with @ linux-x86_64 +lib2to3.tests.test_parser.TestAsyncAwait.test_await_expr @ linux-x86_64 +lib2to3.tests.test_parser.TestClassDef.test_new_syntax @ linux-x86_64 +lib2to3.tests.test_parser.TestDriver.test_formfeed @ linux-x86_64 +lib2to3.tests.test_parser.TestExcept.test_new @ linux-x86_64 +lib2to3.tests.test_parser.TestExcept.test_old @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_10 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_11 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_12 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_13 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_14 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_15 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_16 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_17 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_18 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_19 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_20 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_21 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_5 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_6 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_7 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_8 @ linux-x86_64 +lib2to3.tests.test_parser.TestFunctionAnnotations.test_9 @ linux-x86_64 +lib2to3.tests.test_parser.TestIdentifier.test_non_ascii_identifiers @ linux-x86_64 +lib2to3.tests.test_parser.TestLiterals.test_multiline_bytes_literals @ linux-x86_64 +lib2to3.tests.test_parser.TestLiterals.test_multiline_bytes_tripquote_literals @ linux-x86_64 +lib2to3.tests.test_parser.TestLiterals.test_multiline_str_literals @ linux-x86_64 +lib2to3.tests.test_parser.TestMatrixMultiplication.test_matrix_multiplication_operator @ linux-x86_64 +lib2to3.tests.test_parser.TestNamedAssignments.test_named_assignment_generator @ linux-x86_64 +lib2to3.tests.test_parser.TestNamedAssignments.test_named_assignment_if @ linux-x86_64 +lib2to3.tests.test_parser.TestNamedAssignments.test_named_assignment_listcomp @ linux-x86_64 +lib2to3.tests.test_parser.TestNamedAssignments.test_named_assignment_while @ linux-x86_64 +lib2to3.tests.test_parser.TestNumericLiterals.test_new_binary_notation @ linux-x86_64 +lib2to3.tests.test_parser.TestNumericLiterals.test_new_octal_notation @ linux-x86_64 +lib2to3.tests.test_parser.TestParserIdempotency.test_all_project_files @ linux-x86_64 +lib2to3.tests.test_parser.TestParserIdempotency.test_extended_unpacking @ linux-x86_64 +lib2to3.tests.test_parser.TestPgen2Caching.test_load_grammar_from_pickle @ linux-x86_64 +!lib2to3.tests.test_parser.TestPgen2Caching.test_load_grammar_from_subprocess @ linux-x86_64 +lib2to3.tests.test_parser.TestPgen2Caching.test_load_grammar_from_txt_file @ linux-x86_64 +lib2to3.tests.test_parser.TestPgen2Caching.test_load_packaged_grammar @ linux-x86_64 +lib2to3.tests.test_parser.TestPickleableException.test_ParseError @ linux-x86_64 +lib2to3.tests.test_parser.TestPositionalOnlyArgs.test_all_markers @ linux-x86_64 +lib2to3.tests.test_parser.TestPositionalOnlyArgs.test_all_with_args_and_kwargs @ linux-x86_64 +lib2to3.tests.test_parser.TestPositionalOnlyArgs.test_lambda_soup @ linux-x86_64 +lib2to3.tests.test_parser.TestPositionalOnlyArgs.test_one_pos_only_arg @ linux-x86_64 +lib2to3.tests.test_parser.TestPositionalOnlyArgs.test_only_positional_or_keyword @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_2x_style_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_2x_style_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_2x_style_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_2x_style_invalid_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_3x_style @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_3x_style_invalid_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_3x_style_invalid_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_3x_style_invalid_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestRaiseChanges.test_3x_style_invalid_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestSetLiteral.test_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestSetLiteral.test_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestSetLiteral.test_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestSetLiteral.test_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestStringLiterals.test_lit @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_argument_unpacking_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_argument_unpacking_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_argument_unpacking_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_complex_double_star_expression @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_complex_star_expression @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_dict_display_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_dict_display_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_double_star_dict_literal @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_double_star_dict_literal_after_keywords @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_double_star_expression @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_list_display @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_mid_positional_star @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_set_display @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_star_expression @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_5 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_6 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_7 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_8 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_9 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_5 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_6 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_7 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_8 @ linux-x86_64 +lib2to3.tests.test_parser.TestUnpackingGeneralizations.test_trailing_commas_lambda_9 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_1 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_2 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_3 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_4 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_5 @ linux-x86_64 +lib2to3.tests.test_parser.TestVarAnnotations.test_6 @ linux-x86_64 +lib2to3.tests.test_parser.TestYieldFrom.test_yield_from @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_changed @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_depth @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_get_suffix @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_instantiate_base @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_constructor_prefix @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_equality @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_next_sibling @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_prefix @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_prev_sibling @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_repr @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_str @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaf_str_numeric_value @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_leaves @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_append_child @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_constructor_prefix @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_equality @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_insert_child @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_next_sibling @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_prefix @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_prev_sibling @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_recursive_equality @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_repr @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_set_child @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_node_str @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_post_order @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_pre_order @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_remove @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_remove_parentless @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_replace @ linux-x86_64 +lib2to3.tests.test_pytree.TestNodes.test_replace_with_list @ linux-x86_64 +lib2to3.tests.test_pytree.TestPatterns.test_basic_patterns @ linux-x86_64 +lib2to3.tests.test_pytree.TestPatterns.test_generate_matches @ linux-x86_64 +lib2to3.tests.test_pytree.TestPatterns.test_has_key_example @ linux-x86_64 +lib2to3.tests.test_pytree.TestPatterns.test_wildcard @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_detect_future_features @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_exec_function_option @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_explicit @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_fixer_loading @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_fixer_loading_helpers @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_get_headnode_dict @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_naughty_fixers @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_print_function_option @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_dir @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_docstring @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_file @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_file_write_unchanged_file @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_stdin @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_refactor_string @ linux-x86_64 +lib2to3.tests.test_refactor.TestRefactoringTool.test_write_unchanged_files_option @ linux-x86_64 +lib2to3.tests.test_util.Test_Attr.test @ linux-x86_64 +lib2to3.tests.test_util.Test_Attr.test_returns @ linux-x86_64 +lib2to3.tests.test_util.Test_Call.test @ linux-x86_64 +lib2to3.tests.test_util.Test_Name.test @ linux-x86_64 +lib2to3.tests.test_util.Test_does_tree_import.test_in_function @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_class_def @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_for @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_for_nested @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_from_import @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_from_import_as @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_from_import_as_with_package @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_from_import_with_package @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_function_def @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_if @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_if_nested @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_import_as @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_import_as_with_package @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_invalid_assignments @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_list_assignment @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_simple_assignment @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_simple_import @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_simple_import_with_package @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_try_except @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_try_except_finally @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_try_except_finally_nested @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_try_except_nested @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_tuple_assignment @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_while @ linux-x86_64 +lib2to3.tests.test_util.Test_find_binding.test_while_nested @ linux-x86_64 +lib2to3.tests.test_util.Test_find_indentation.test_nothing @ linux-x86_64 +lib2to3.tests.test_util.Test_find_indentation.test_simple @ linux-x86_64 +lib2to3.tests.test_util.Test_is_list.test_invalid @ linux-x86_64 +lib2to3.tests.test_util.Test_is_list.test_valid @ linux-x86_64 +lib2to3.tests.test_util.Test_is_tuple.test_invalid @ linux-x86_64 +lib2to3.tests.test_util.Test_is_tuple.test_valid @ linux-x86_64 +lib2to3.tests.test_util.Test_touch_import.test_after_docstring @ linux-x86_64 +lib2to3.tests.test_util.Test_touch_import.test_after_imports @ linux-x86_64 +lib2to3.tests.test_util.Test_touch_import.test_beginning @ linux-x86_64 +lib2to3.tests.test_util.Test_touch_import.test_from_import @ linux-x86_64 +lib2to3.tests.test_util.Test_touch_import.test_name_import @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_linecache.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_linecache.txt new file mode 100644 index 0000000000..36349d56b2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_linecache.txt @@ -0,0 +1,24 @@ +test.test_linecache.BadUnicode_NoDeclaration.test_getline @ linux-x86_64 +test.test_linecache.BadUnicode_NoDeclaration.test_getlines @ linux-x86_64 +test.test_linecache.BadUnicode_WithDeclaration.test_getline @ linux-x86_64 +test.test_linecache.BadUnicode_WithDeclaration.test_getlines @ linux-x86_64 +test.test_linecache.EmptyFile.test_getline @ linux-x86_64 +test.test_linecache.EmptyFile.test_getlines @ linux-x86_64 +test.test_linecache.GoodUnicode.test_getline @ linux-x86_64 +test.test_linecache.GoodUnicode.test_getlines @ linux-x86_64 +test.test_linecache.LineCacheInvalidationTests.test_checkcache_for_deleted_file @ linux-x86_64 +test.test_linecache.LineCacheInvalidationTests.test_checkcache_for_modified_file @ linux-x86_64 +test.test_linecache.LineCacheInvalidationTests.test_checkcache_with_no_parameter @ linux-x86_64 +test.test_linecache.LineCacheTests.test_checkcache @ linux-x86_64 +test.test_linecache.LineCacheTests.test_clearcache @ linux-x86_64 +test.test_linecache.LineCacheTests.test_getline @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_already_cached @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_bad_filename @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_check @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_no_globals @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_provide_after_failed_lookup @ linux-x86_64 +test.test_linecache.LineCacheTests.test_lazycache_smoke @ linux-x86_64 +test.test_linecache.LineCacheTests.test_memoryerror @ linux-x86_64 +test.test_linecache.LineCacheTests.test_no_ending_newline @ linux-x86_64 +test.test_linecache.SingleEmptyLine.test_getline @ linux-x86_64 +test.test_linecache.SingleEmptyLine.test_getlines @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_list.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_list.txt new file mode 100644 index 0000000000..8cf804c93f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_list.txt @@ -0,0 +1,54 @@ +test.test_list.ListTest.test_addmul @ linux-x86_64 +test.test_list.ListTest.test_append @ linux-x86_64 +test.test_list.ListTest.test_basic @ linux-x86_64 +test.test_list.ListTest.test_clear @ linux-x86_64 +test.test_list.ListTest.test_constructor_exception_handling @ linux-x86_64 +test.test_list.ListTest.test_constructors @ linux-x86_64 +test.test_list.ListTest.test_contains @ linux-x86_64 +test.test_list.ListTest.test_contains_fake @ linux-x86_64 +test.test_list.ListTest.test_contains_order @ linux-x86_64 +test.test_list.ListTest.test_copy @ linux-x86_64 +test.test_list.ListTest.test_count @ linux-x86_64 +test.test_list.ListTest.test_count_index_remove_crashes @ linux-x86_64 +test.test_list.ListTest.test_delitem @ linux-x86_64 +test.test_list.ListTest.test_delslice @ linux-x86_64 +test.test_list.ListTest.test_equal_operator_modifying_operand @ linux-x86_64 +test.test_list.ListTest.test_exhausted_iterator @ linux-x86_64 +test.test_list.ListTest.test_extend @ linux-x86_64 +test.test_list.ListTest.test_extendedslicing @ linux-x86_64 +test.test_list.ListTest.test_getitem @ linux-x86_64 +test.test_list.ListTest.test_getitem_error @ linux-x86_64 +test.test_list.ListTest.test_getitemoverwriteiter @ linux-x86_64 +test.test_list.ListTest.test_getslice @ linux-x86_64 +test.test_list.ListTest.test_iadd @ linux-x86_64 +test.test_list.ListTest.test_identity @ linux-x86_64 +test.test_list.ListTest.test_imul @ linux-x86_64 +test.test_list.ListTest.test_index @ linux-x86_64 +test.test_list.ListTest.test_init @ linux-x86_64 +test.test_list.ListTest.test_insert @ linux-x86_64 +test.test_list.ListTest.test_iterator_pickle @ linux-x86_64 +test.test_list.ListTest.test_keyword_args @ linux-x86_64 +test.test_list.ListTest.test_len @ linux-x86_64 +test.test_list.ListTest.test_list_resize_overflow @ linux-x86_64 +test.test_list.ListTest.test_minmax @ linux-x86_64 +test.test_list.ListTest.test_no_comdat_folding @ linux-x86_64 +test.test_list.ListTest.test_overflow @ linux-x86_64 +test.test_list.ListTest.test_pickle @ linux-x86_64 +test.test_list.ListTest.test_pop @ linux-x86_64 +test.test_list.ListTest.test_remove @ linux-x86_64 +test.test_list.ListTest.test_repeat @ linux-x86_64 +test.test_list.ListTest.test_repr @ linux-x86_64 +!test.test_list.ListTest.test_repr_deep @ linux-x86_64 +test.test_list.ListTest.test_repr_large @ linux-x86_64 +test.test_list.ListTest.test_reverse @ linux-x86_64 +test.test_list.ListTest.test_reversed @ linux-x86_64 +test.test_list.ListTest.test_reversed_pickle @ linux-x86_64 +test.test_list.ListTest.test_set_subscript @ linux-x86_64 +test.test_list.ListTest.test_setitem @ linux-x86_64 +test.test_list.ListTest.test_setitem_error @ linux-x86_64 +test.test_list.ListTest.test_setslice @ linux-x86_64 +test.test_list.ListTest.test_slice @ linux-x86_64 +test.test_list.ListTest.test_sort @ linux-x86_64 +test.test_list.ListTest.test_step_overflow @ linux-x86_64 +test.test_list.ListTest.test_subscript @ linux-x86_64 +test.test_list.ListTest.test_truth @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_listcomps.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_listcomps.txt new file mode 100644 index 0000000000..bcd126d9d0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_listcomps.txt @@ -0,0 +1 @@ +DocTestCase.test.test_listcomps.__test__.doctests @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_locale.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_locale.txt new file mode 100644 index 0000000000..6b7019e95f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_locale.txt @@ -0,0 +1,59 @@ +test.test_locale.NormalizeTest.test_c @ linux-x86_64 +test.test_locale.NormalizeTest.test_devanagari_modifier @ linux-x86_64 +test.test_locale.NormalizeTest.test_empty @ linux-x86_64 +test.test_locale.NormalizeTest.test_english @ linux-x86_64 +test.test_locale.NormalizeTest.test_euc_encoding @ linux-x86_64 +test.test_locale.NormalizeTest.test_euro_modifier @ linux-x86_64 +test.test_locale.NormalizeTest.test_hyphenated_encoding @ linux-x86_64 +test.test_locale.NormalizeTest.test_japanese @ linux-x86_64 +test.test_locale.NormalizeTest.test_latin_modifier @ linux-x86_64 +test.test_locale.NormalizeTest.test_locale_alias @ linux-x86_64 +test.test_locale.NormalizeTest.test_valencia_modifier @ linux-x86_64 +test.test_locale.TestCDelocalizeTest.test_atof @ linux-x86_64 +test.test_locale.TestCDelocalizeTest.test_atoi @ linux-x86_64 +test.test_locale.TestCDelocalizeTest.test_delocalize @ linux-x86_64 +test.test_locale.TestCLocalize.test_localize @ linux-x86_64 +test.test_locale.TestCNumberFormatting.test_grouping @ linux-x86_64 +test.test_locale.TestCNumberFormatting.test_grouping_and_padding @ linux-x86_64 +test.test_locale.TestEnUSDelocalize.test_atof @ linux-x86_64 +test.test_locale.TestEnUSDelocalize.test_atoi @ linux-x86_64 +test.test_locale.TestEnUSDelocalize.test_delocalize @ linux-x86_64 +test.test_locale.TestEnUSLocalize.test_localize @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_complex_formatting @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_currency @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_format_deprecation @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_grouping @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_grouping_and_padding @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_integer_grouping @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_integer_grouping_and_padding @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_padding @ linux-x86_64 +test.test_locale.TestEnUSNumberFormatting.test_simple @ linux-x86_64 +test.test_locale.TestFormatPatternArg.test_onlyOnePattern @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_currency @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_decimal_point @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_grouping @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_grouping_and_padding @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_integer_grouping @ linux-x86_64 +test.test_locale.TestFrFRNumberFormatting.test_integer_grouping_and_padding @ linux-x86_64 +test.test_locale.TestLocaleFormatString.test_mapping @ linux-x86_64 +test.test_locale.TestLocaleFormatString.test_percent_escape @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_defaults_UTF8 @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_getencoding @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_getpreferredencoding @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_getsetlocale_issue1813 @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_invalid_iterable_in_localetuple @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_invalid_locale_format_in_localetuple @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_setlocale_category @ linux-x86_64 +test.test_locale.TestMiscellaneous.test_strcoll_3303 @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_complex_formatting @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_format_deprecation @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_grouping @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_grouping_and_padding @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_integer_grouping @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_integer_grouping_and_padding @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_padding @ linux-x86_64 +test.test_locale.TestNumberFormatting.test_simple @ linux-x86_64 +test.test_locale.TestfrFRDelocalizeTest.test_atof @ linux-x86_64 +test.test_locale.TestfrFRDelocalizeTest.test_atoi @ linux-x86_64 +test.test_locale.TestfrFRDelocalizeTest.test_delocalize @ linux-x86_64 +test.test_locale.TestfrFRLocalize.test_localize @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_logging.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_logging.txt new file mode 100644 index 0000000000..351d580133 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_logging.txt @@ -0,0 +1,216 @@ +test.test_logging.BasicConfigTest.test_critical @ linux-x86_64 +test.test_logging.BasicConfigTest.test_datefmt @ linux-x86_64 +test.test_logging.BasicConfigTest.test_debug @ linux-x86_64 +test.test_logging.BasicConfigTest.test_encoding @ linux-x86_64 +test.test_logging.BasicConfigTest.test_encoding_errors @ linux-x86_64 +test.test_logging.BasicConfigTest.test_encoding_errors_default @ linux-x86_64 +test.test_logging.BasicConfigTest.test_encoding_errors_none @ linux-x86_64 +test.test_logging.BasicConfigTest.test_error @ linux-x86_64 +test.test_logging.BasicConfigTest.test_filemode @ linux-x86_64 +test.test_logging.BasicConfigTest.test_filename @ linux-x86_64 +test.test_logging.BasicConfigTest.test_force @ linux-x86_64 +test.test_logging.BasicConfigTest.test_format @ linux-x86_64 +test.test_logging.BasicConfigTest.test_handlers @ linux-x86_64 +test.test_logging.BasicConfigTest.test_incompatible @ linux-x86_64 +test.test_logging.BasicConfigTest.test_info @ linux-x86_64 +test.test_logging.BasicConfigTest.test_level @ linux-x86_64 +test.test_logging.BasicConfigTest.test_log @ linux-x86_64 +test.test_logging.BasicConfigTest.test_no_kwargs @ linux-x86_64 +test.test_logging.BasicConfigTest.test_stream @ linux-x86_64 +test.test_logging.BasicConfigTest.test_strformatstyle @ linux-x86_64 +test.test_logging.BasicConfigTest.test_stringtemplatestyle @ linux-x86_64 +test.test_logging.BasicConfigTest.test_style @ linux-x86_64 +test.test_logging.BasicConfigTest.test_warning @ linux-x86_64 +test.test_logging.BasicFilterTest.test_callable_filter @ linux-x86_64 +test.test_logging.BasicFilterTest.test_empty_filter @ linux-x86_64 +test.test_logging.BasicFilterTest.test_filter @ linux-x86_64 +test.test_logging.BufferingFormatterTest.test_custom @ linux-x86_64 +test.test_logging.BufferingFormatterTest.test_default @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_flat @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_issue27935 @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_nested_explicit @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_nested_inherited @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_nested_with_virtual_parent @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_regression_22386 @ linux-x86_64 +test.test_logging.BuiltinLevelsTest.test_regression_29220 @ linux-x86_64 +test.test_logging.ChildLoggerTest.test_child_loggers @ linux-x86_64 +test.test_logging.ConfigDictTest.test_90195 @ linux-x86_64 +test.test_logging.ConfigDictTest.test_baseconfig @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config0_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config11_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config12_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config13_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config14_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config15_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config17_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config1_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config2_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config2a_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config2b_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config3_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config4_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config4a_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config5_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config6_failure @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config7_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_10_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_8_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_8a_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_9_ok @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_callable_filter_works @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_filter_method_works @ linux-x86_64 +test.test_logging.ConfigDictTest.test_config_filter_works @ linux-x86_64 +test.test_logging.ConfigDictTest.test_custom_formatter_class_with_validate @ linux-x86_64 +test.test_logging.ConfigDictTest.test_custom_formatter_class_with_validate2 @ linux-x86_64 +test.test_logging.ConfigDictTest.test_custom_formatter_class_with_validate2_with_wrong_fmt @ linux-x86_64 +test.test_logging.ConfigDictTest.test_custom_formatter_class_with_validate3 @ linux-x86_64 +test.test_logging.ConfigDictTest.test_custom_formatter_function_with_validate @ linux-x86_64 +test.test_logging.ConfigDictTest.test_invalid_type_raises @ linux-x86_64 +!test.test_logging.ConfigDictTest.test_listen_config_10_ok @ linux-x86_64 +!test.test_logging.ConfigDictTest.test_listen_config_1_ok @ linux-x86_64 +!test.test_logging.ConfigDictTest.test_listen_verify @ linux-x86_64 +test.test_logging.ConfigDictTest.test_namedtuple @ linux-x86_64 +test.test_logging.ConfigDictTest.test_out_of_order @ linux-x86_64 +test.test_logging.ConfigDictTest.test_out_of_order_with_dollar_style @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config0_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config0_using_cp_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config1_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config2_failure @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config3_failure @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config4_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config5_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config6_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config7_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config8_ok @ linux-x86_64 +test.test_logging.ConfigFileTest.test_config_set_handler_names @ linux-x86_64 +test.test_logging.ConfigFileTest.test_defaults_do_no_interpolation @ linux-x86_64 +test.test_logging.ConfigFileTest.test_exception_if_confg_file_is_empty @ linux-x86_64 +test.test_logging.ConfigFileTest.test_exception_if_confg_file_is_invalid @ linux-x86_64 +test.test_logging.ConfigFileTest.test_exception_if_config_file_does_not_exist @ linux-x86_64 +test.test_logging.ConfigFileTest.test_logger_disabling @ linux-x86_64 +test.test_logging.CustomLevelsAndFiltersTest.test_handler_filter @ linux-x86_64 +test.test_logging.CustomLevelsAndFiltersTest.test_logger_filter @ linux-x86_64 +test.test_logging.CustomLevelsAndFiltersTest.test_specific_filters @ linux-x86_64 +test.test_logging.DatagramHandlerTest.test_output @ linux-x86_64 +test.test_logging.EncodingTest.test_encoding_cyrillic_unicode @ linux-x86_64 +test.test_logging.EncodingTest.test_encoding_plain_file @ linux-x86_64 +test.test_logging.ExceptionTest.test_formatting @ linux-x86_64 +test.test_logging.FileHandlerTest.test_delay @ linux-x86_64 +test.test_logging.FileHandlerTest.test_emit_after_closing_in_write_mode @ linux-x86_64 +test.test_logging.FormatterTest.test_braces @ linux-x86_64 +test.test_logging.FormatterTest.test_default_msec_format_none @ linux-x86_64 +test.test_logging.FormatterTest.test_defaults_parameter @ linux-x86_64 +test.test_logging.FormatterTest.test_dollars @ linux-x86_64 +test.test_logging.FormatterTest.test_format_validate @ linux-x86_64 +test.test_logging.FormatterTest.test_invalid_style @ linux-x86_64 +test.test_logging.FormatterTest.test_issue_89047 @ linux-x86_64 +test.test_logging.FormatterTest.test_percent @ linux-x86_64 +test.test_logging.FormatterTest.test_time @ linux-x86_64 +test.test_logging.HTTPHandlerTest.test_output @ linux-x86_64 +test.test_logging.HandlerTest.test_builtin_handlers @ linux-x86_64 +test.test_logging.HandlerTest.test_name @ linux-x86_64 +test.test_logging.HandlerTest.test_path_objects @ linux-x86_64 +test.test_logging.HandlerTest.test_race @ linux-x86_64 +test.test_logging.IPv6SysLogHandlerTest.test_output @ linux-x86_64 +test.test_logging.IPv6SysLogHandlerTest.test_udp_reconnection @ linux-x86_64 +test.test_logging.LastResortTest.test_last_resort @ linux-x86_64 +test.test_logging.LogRecordFactoryTest.test_logrecord_class @ linux-x86_64 +test.test_logging.LogRecordTest.test_dict_arg @ linux-x86_64 +test.test_logging.LogRecordTest.test_multiprocessing @ linux-x86_64 +test.test_logging.LogRecordTest.test_optional @ linux-x86_64 +test.test_logging.LogRecordTest.test_str_rep @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_critical @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_exception @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_exception_excinfo @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_has_handlers @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_is_enabled_for @ linux-x86_64 +test.test_logging.LoggerAdapterTest.test_nested @ linux-x86_64 +test.test_logging.LoggerTest.test_caching @ linux-x86_64 +test.test_logging.LoggerTest.test_exception @ linux-x86_64 +test.test_logging.LoggerTest.test_find_caller_with_stack_info @ linux-x86_64 +test.test_logging.LoggerTest.test_find_caller_with_stacklevel @ linux-x86_64 +test.test_logging.LoggerTest.test_has_handlers @ linux-x86_64 +test.test_logging.LoggerTest.test_has_handlers_no_propagate @ linux-x86_64 +test.test_logging.LoggerTest.test_invalid_names @ linux-x86_64 +test.test_logging.LoggerTest.test_is_enabled_for @ linux-x86_64 +test.test_logging.LoggerTest.test_is_enabled_for_disabled_logger @ linux-x86_64 +test.test_logging.LoggerTest.test_log_invalid_level_no_raise @ linux-x86_64 +test.test_logging.LoggerTest.test_log_invalid_level_with_raise @ linux-x86_64 +test.test_logging.LoggerTest.test_make_record_with_extra_no_overwrite @ linux-x86_64 +test.test_logging.LoggerTest.test_make_record_with_extra_overwrite @ linux-x86_64 +test.test_logging.LoggerTest.test_pickling @ linux-x86_64 +test.test_logging.LoggerTest.test_root_logger_aliases @ linux-x86_64 +test.test_logging.LoggerTest.test_set_invalid_level @ linux-x86_64 +test.test_logging.ManagerTest.test_manager_loggerclass @ linux-x86_64 +test.test_logging.ManagerTest.test_set_log_record_factory @ linux-x86_64 +test.test_logging.MemoryHandlerTest.test_flush @ linux-x86_64 +test.test_logging.MemoryHandlerTest.test_flush_on_close @ linux-x86_64 +test.test_logging.MemoryHandlerTest.test_race_between_set_target_and_flush @ linux-x86_64 +test.test_logging.MemoryTest.test_persistent_loggers @ linux-x86_64 +test.test_logging.MiscTestCase.test__all__ @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_critical @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_debug @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_disable @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_error @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_get_level_names_mapping @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_info @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_log @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_recursion_error @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_set_logger_class @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_subclass_logger_cache @ linux-x86_64 +test.test_logging.ModuleLevelMiscTest.test_warning @ linux-x86_64 +test.test_logging.QueueHandlerTest.test_formatting @ linux-x86_64 +test.test_logging.QueueHandlerTest.test_queue_handler @ linux-x86_64 +test.test_logging.QueueHandlerTest.test_queue_listener @ linux-x86_64 +test.test_logging.QueueHandlerTest.test_queue_listener_with_StreamHandler @ linux-x86_64 +test.test_logging.QueueHandlerTest.test_queue_listener_with_multiple_handlers @ linux-x86_64 +test.test_logging.QueueListenerTest.test_calls_task_done_after_stop @ linux-x86_64 +test.test_logging.QueueListenerTest.test_handle_called_with_mp_queue @ linux-x86_64 +test.test_logging.QueueListenerTest.test_handle_called_with_queue_queue @ linux-x86_64 +test.test_logging.QueueListenerTest.test_no_messages_in_queue_after_stop @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_file_created @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_namer_rotator_inheritance @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_rollover_filenames @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_rotator @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_should_not_rollover @ linux-x86_64 +test.test_logging.RotatingFileHandlerTest.test_should_rollover @ linux-x86_64 +test.test_logging.SMTPHandlerTest.test_basic @ linux-x86_64 +test.test_logging.ShutdownTest.test_no_failure @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_ioerror_in_acquire @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_ioerror_in_close @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_ioerror_in_flush @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_acquire_with_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_acquire_without_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_close_with_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_close_without_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_flush_with_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_other_error_in_flush_without_raise @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_valueerror_in_acquire @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_valueerror_in_close @ linux-x86_64 +test.test_logging.ShutdownTest.test_with_valueerror_in_flush @ linux-x86_64 +test.test_logging.SocketHandlerTest.test_noserver @ linux-x86_64 +test.test_logging.SocketHandlerTest.test_output @ linux-x86_64 +test.test_logging.StreamHandlerTest.test_can_represent_stream_with_int_name @ linux-x86_64 +test.test_logging.StreamHandlerTest.test_error_handling @ linux-x86_64 +test.test_logging.StreamHandlerTest.test_stream_setting @ linux-x86_64 +test.test_logging.SysLogHandlerTest.test_output @ linux-x86_64 +test.test_logging.SysLogHandlerTest.test_udp_reconnection @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_files_to_delete @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_D @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_H @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_M @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_MIDNIGHT @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_S @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_W0 @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_daily_attime @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_compute_rollover_weekly_attime @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_invalid @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_rollover @ linux-x86_64 +test.test_logging.TimedRotatingFileHandlerTest.test_should_not_rollover @ linux-x86_64 +test.test_logging.UnixDatagramHandlerTest.test_output @ linux-x86_64 +test.test_logging.UnixSocketHandlerTest.test_noserver @ linux-x86_64 +test.test_logging.UnixSocketHandlerTest.test_output @ linux-x86_64 +test.test_logging.UnixSysLogHandlerTest.test_output @ linux-x86_64 +test.test_logging.UnixSysLogHandlerTest.test_udp_reconnection @ linux-x86_64 +test.test_logging.WarningsTest.test_warnings @ linux-x86_64 +test.test_logging.WarningsTest.test_warnings_no_handlers @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_long.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_long.txt new file mode 100644 index 0000000000..0f67c14d7a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_long.txt @@ -0,0 +1,34 @@ +test.test_long.LongTest.test__format__ @ linux-x86_64 +test.test_long.LongTest.test_access_to_nonexistent_digit_0 @ linux-x86_64 +test.test_long.LongTest.test_as_integer_ratio @ linux-x86_64 +test.test_long.LongTest.test_big_lshift @ linux-x86_64 +test.test_long.LongTest.test_big_rshift @ linux-x86_64 +test.test_long.LongTest.test_bit_count @ linux-x86_64 +test.test_long.LongTest.test_bit_length @ linux-x86_64 +test.test_long.LongTest.test_bitop_identities @ linux-x86_64 +test.test_long.LongTest.test_conversion @ linux-x86_64 +test.test_long.LongTest.test_division @ linux-x86_64 +test.test_long.LongTest.test_float_conversion @ linux-x86_64 +test.test_long.LongTest.test_float_overflow @ linux-x86_64 +test.test_long.LongTest.test_floordiv @ linux-x86_64 +test.test_long.LongTest.test_format @ linux-x86_64 +test.test_long.LongTest.test_from_bytes @ linux-x86_64 +test.test_long.LongTest.test_huge_rshift @ linux-x86_64 +test.test_long.LongTest.test_karatsuba @ linux-x86_64 +test.test_long.LongTest.test_logs @ linux-x86_64 +test.test_long.LongTest.test_long @ linux-x86_64 +test.test_long.LongTest.test_lshift_of_zero @ linux-x86_64 +test.test_long.LongTest.test_medium_lshift @ linux-x86_64 +test.test_long.LongTest.test_medium_rshift @ linux-x86_64 +test.test_long.LongTest.test_mixed_compares @ linux-x86_64 +test.test_long.LongTest.test_mod_division @ linux-x86_64 +test.test_long.LongTest.test_nan_inf @ linux-x86_64 +test.test_long.LongTest.test_negative_shift_count @ linux-x86_64 +test.test_long.LongTest.test_round @ linux-x86_64 +test.test_long.LongTest.test_shift_bool @ linux-x86_64 +test.test_long.LongTest.test_small_ints @ linux-x86_64 +test.test_long.LongTest.test_small_lshift @ linux-x86_64 +test.test_long.LongTest.test_small_rshift @ linux-x86_64 +test.test_long.LongTest.test_square @ linux-x86_64 +test.test_long.LongTest.test_to_bytes @ linux-x86_64 +test.test_long.LongTest.test_true_division @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_longexp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_longexp.txt new file mode 100644 index 0000000000..c5c0fdea81 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_longexp.txt @@ -0,0 +1 @@ +test.test_longexp.LongExpText.test_longexp @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lzma.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lzma.txt new file mode 100644 index 0000000000..00c3f5d4f1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_lzma.txt @@ -0,0 +1,112 @@ +test.test_lzma.CompressDecompressFunctionTestCase.test_bad_args @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_bad_input @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_good_input @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_incomplete_input @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_memlimit @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_multistream @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_multistream_trailing_junk @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_decompress_trailing_junk @ linux-x86_64 +test.test_lzma.CompressDecompressFunctionTestCase.test_roundtrip @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_bad_filter_spec @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_compressor_bigmem @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_after_eof @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_alone @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_auto @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_bad_input @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_bigmem @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_bug_28275 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_chunks @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_chunks_empty @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_chunks_maxsize @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_inputbuf_1 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_inputbuf_2 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_inputbuf_3 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_memlimit @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_multistream @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_raw_1 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_raw_2 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_raw_3 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_raw_4 @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_unused_data @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_decompressor_xz @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_alone @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_chunks @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_empty_chunks @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_raw @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_raw_empty @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_roundtrip_xz @ linux-x86_64 +test.test_lzma.CompressorDecompressorTestCase.test_simple_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_close @ linux-x86_64 +test.test_lzma.FileTestCase.test_closed @ linux-x86_64 +test.test_lzma.FileTestCase.test_decompress_limited @ linux-x86_64 +test.test_lzma.FileTestCase.test_fileno @ linux-x86_64 +test.test_lzma.FileTestCase.test_init @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_bad_check @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_bad_filter_spec @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_bad_mode @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_bad_preset @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_mode @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_with_PathLike_filename @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_with_filename @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_with_preset_and_filters @ linux-x86_64 +test.test_lzma.FileTestCase.test_init_with_x_mode @ linux-x86_64 +test.test_lzma.FileTestCase.test_issue21872 @ linux-x86_64 +test.test_lzma.FileTestCase.test_issue44439 @ linux-x86_64 +test.test_lzma.FileTestCase.test_iterator @ linux-x86_64 +test.test_lzma.FileTestCase.test_peek @ linux-x86_64 +test.test_lzma.FileTestCase.test_peek_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_read @ linux-x86_64 +test.test_lzma.FileTestCase.test_read1 @ linux-x86_64 +test.test_lzma.FileTestCase.test_read1_0 @ linux-x86_64 +test.test_lzma.FileTestCase.test_read1_10 @ linux-x86_64 +test.test_lzma.FileTestCase.test_read1_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_read1_multistream @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_0 @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_10 @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_bad_data @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_from_file @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_incomplete @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_multistream @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_multistream_buffer_size_aligned @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_multistream_trailing_junk @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_trailing_junk @ linux-x86_64 +test.test_lzma.FileTestCase.test_read_truncated @ linux-x86_64 +test.test_lzma.FileTestCase.test_readable @ linux-x86_64 +test.test_lzma.FileTestCase.test_readline @ linux-x86_64 +test.test_lzma.FileTestCase.test_readlines @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_backward @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_backward_across_streams @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_backward_relative_to_end @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_forward @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_forward_across_streams @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_forward_relative_to_current @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_forward_relative_to_end @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_past_end @ linux-x86_64 +test.test_lzma.FileTestCase.test_seek_past_start @ linux-x86_64 +test.test_lzma.FileTestCase.test_seekable @ linux-x86_64 +test.test_lzma.FileTestCase.test_tell @ linux-x86_64 +test.test_lzma.FileTestCase.test_tell_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_writable @ linux-x86_64 +test.test_lzma.FileTestCase.test_write @ linux-x86_64 +test.test_lzma.FileTestCase.test_write_10 @ linux-x86_64 +test.test_lzma.FileTestCase.test_write_append @ linux-x86_64 +test.test_lzma.FileTestCase.test_write_append_to_file @ linux-x86_64 +test.test_lzma.FileTestCase.test_write_bad_args @ linux-x86_64 +test.test_lzma.FileTestCase.test_write_to_file @ linux-x86_64 +test.test_lzma.FileTestCase.test_writelines @ linux-x86_64 +test.test_lzma.MiscellaneousTestCase.test__decode_filter_properties @ linux-x86_64 +test.test_lzma.MiscellaneousTestCase.test__encode_filter_properties @ linux-x86_64 +test.test_lzma.MiscellaneousTestCase.test_filter_properties_roundtrip @ linux-x86_64 +test.test_lzma.MiscellaneousTestCase.test_is_check_supported @ linux-x86_64 +test.test_lzma.OpenTestCase.test_bad_params @ linux-x86_64 +test.test_lzma.OpenTestCase.test_binary_modes @ linux-x86_64 +test.test_lzma.OpenTestCase.test_encoding @ linux-x86_64 +test.test_lzma.OpenTestCase.test_encoding_error_handler @ linux-x86_64 +test.test_lzma.OpenTestCase.test_filename @ linux-x86_64 +test.test_lzma.OpenTestCase.test_format_and_filters @ linux-x86_64 +test.test_lzma.OpenTestCase.test_newline @ linux-x86_64 +test.test_lzma.OpenTestCase.test_text_modes @ linux-x86_64 +test.test_lzma.OpenTestCase.test_with_pathlike_filename @ linux-x86_64 +test.test_lzma.OpenTestCase.test_x_mode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailbox.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailbox.txt new file mode 100644 index 0000000000..ea9aa189f9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailbox.txt @@ -0,0 +1,362 @@ +test.test_mailbox.MaildirTestCase.test_empty_maildir @ linux-x86_64 +test.test_mailbox.MaildirTestCase.test_nonempty_maildir_both @ linux-x86_64 +test.test_mailbox.MaildirTestCase.test_nonempty_maildir_cur @ linux-x86_64 +test.test_mailbox.MaildirTestCase.test_nonempty_maildir_new @ linux-x86_64 +test.test_mailbox.MiscTestCase.test__all__ @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_8bit_body @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_StringIO_warns @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_binary_file @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_binary_nonascii_file @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_doesnt_rewrite @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_invalid_8bit_bytes_header @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_nonascii_StringIO_raises @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_nonascii_string_header_raises @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_text_file_warns @ linux-x86_64 +test.test_mailbox.TestBabyl.test_add_that_raises_leaves_mailbox_empty @ linux-x86_64 +test.test_mailbox.TestBabyl.test_clear @ linux-x86_64 +test.test_mailbox.TestBabyl.test_close @ linux-x86_64 +test.test_mailbox.TestBabyl.test_contains @ linux-x86_64 +test.test_mailbox.TestBabyl.test_delitem @ linux-x86_64 +test.test_mailbox.TestBabyl.test_discard @ linux-x86_64 +test.test_mailbox.TestBabyl.test_dump_message @ linux-x86_64 +test.test_mailbox.TestBabyl.test_flush @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get_bytes @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get_file @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get_file_can_be_closed_twice @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get_message @ linux-x86_64 +test.test_mailbox.TestBabyl.test_get_string @ linux-x86_64 +test.test_mailbox.TestBabyl.test_getitem @ linux-x86_64 +test.test_mailbox.TestBabyl.test_invalid_nonascii_header_as_string @ linux-x86_64 +test.test_mailbox.TestBabyl.test_items @ linux-x86_64 +test.test_mailbox.TestBabyl.test_iter @ linux-x86_64 +test.test_mailbox.TestBabyl.test_iteritems @ linux-x86_64 +test.test_mailbox.TestBabyl.test_iterkeys @ linux-x86_64 +test.test_mailbox.TestBabyl.test_itervalues @ linux-x86_64 +test.test_mailbox.TestBabyl.test_keys @ linux-x86_64 +test.test_mailbox.TestBabyl.test_labels @ linux-x86_64 +test.test_mailbox.TestBabyl.test_len @ linux-x86_64 +test.test_mailbox.TestBabyl.test_lock_unlock @ linux-x86_64 +test.test_mailbox.TestBabyl.test_permissions_after_flush @ linux-x86_64 +test.test_mailbox.TestBabyl.test_pop @ linux-x86_64 +test.test_mailbox.TestBabyl.test_popitem @ linux-x86_64 +test.test_mailbox.TestBabyl.test_popitem_and_flush_twice @ linux-x86_64 +test.test_mailbox.TestBabyl.test_remove @ linux-x86_64 +test.test_mailbox.TestBabyl.test_set_item @ linux-x86_64 +test.test_mailbox.TestBabyl.test_update @ linux-x86_64 +test.test_mailbox.TestBabyl.test_values @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_labels @ linux-x86_64 +test.test_mailbox.TestBabylMessage.test_visible @ linux-x86_64 +test.test_mailbox.TestFakeMailBox.test_closing_fd @ linux-x86_64 +test.test_mailbox.TestMH.test_add @ linux-x86_64 +test.test_mailbox.TestMH.test_add_8bit_body @ linux-x86_64 +test.test_mailbox.TestMH.test_add_StringIO_warns @ linux-x86_64 +test.test_mailbox.TestMH.test_add_and_remove_folders @ linux-x86_64 +test.test_mailbox.TestMH.test_add_binary_file @ linux-x86_64 +test.test_mailbox.TestMH.test_add_binary_nonascii_file @ linux-x86_64 +test.test_mailbox.TestMH.test_add_invalid_8bit_bytes_header @ linux-x86_64 +test.test_mailbox.TestMH.test_add_nonascii_StringIO_raises @ linux-x86_64 +test.test_mailbox.TestMH.test_add_nonascii_string_header_raises @ linux-x86_64 +test.test_mailbox.TestMH.test_add_text_file_warns @ linux-x86_64 +test.test_mailbox.TestMH.test_add_that_raises_leaves_mailbox_empty @ linux-x86_64 +test.test_mailbox.TestMH.test_clear @ linux-x86_64 +test.test_mailbox.TestMH.test_close @ linux-x86_64 +test.test_mailbox.TestMH.test_contains @ linux-x86_64 +test.test_mailbox.TestMH.test_delitem @ linux-x86_64 +test.test_mailbox.TestMH.test_discard @ linux-x86_64 +test.test_mailbox.TestMH.test_dump_message @ linux-x86_64 +test.test_mailbox.TestMH.test_flush @ linux-x86_64 +test.test_mailbox.TestMH.test_get @ linux-x86_64 +test.test_mailbox.TestMH.test_get_bytes @ linux-x86_64 +test.test_mailbox.TestMH.test_get_file @ linux-x86_64 +test.test_mailbox.TestMH.test_get_file_can_be_closed_twice @ linux-x86_64 +test.test_mailbox.TestMH.test_get_folder @ linux-x86_64 +test.test_mailbox.TestMH.test_get_message @ linux-x86_64 +test.test_mailbox.TestMH.test_get_string @ linux-x86_64 +test.test_mailbox.TestMH.test_getitem @ linux-x86_64 +test.test_mailbox.TestMH.test_invalid_nonascii_header_as_string @ linux-x86_64 +test.test_mailbox.TestMH.test_issue2625 @ linux-x86_64 +test.test_mailbox.TestMH.test_issue7627 @ linux-x86_64 +test.test_mailbox.TestMH.test_items @ linux-x86_64 +test.test_mailbox.TestMH.test_iter @ linux-x86_64 +test.test_mailbox.TestMH.test_iteritems @ linux-x86_64 +test.test_mailbox.TestMH.test_iterkeys @ linux-x86_64 +test.test_mailbox.TestMH.test_itervalues @ linux-x86_64 +test.test_mailbox.TestMH.test_keys @ linux-x86_64 +test.test_mailbox.TestMH.test_len @ linux-x86_64 +test.test_mailbox.TestMH.test_list_folders @ linux-x86_64 +test.test_mailbox.TestMH.test_lock_unlock @ linux-x86_64 +test.test_mailbox.TestMH.test_pack @ linux-x86_64 +test.test_mailbox.TestMH.test_pop @ linux-x86_64 +test.test_mailbox.TestMH.test_popitem @ linux-x86_64 +test.test_mailbox.TestMH.test_popitem_and_flush_twice @ linux-x86_64 +test.test_mailbox.TestMH.test_remove @ linux-x86_64 +test.test_mailbox.TestMH.test_sequences @ linux-x86_64 +test.test_mailbox.TestMH.test_set_item @ linux-x86_64 +test.test_mailbox.TestMH.test_update @ linux-x86_64 +test.test_mailbox.TestMH.test_values @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestMHMessage.test_sequences @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_8bit_body @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_StringIO_warns @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_and_close @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_binary_file @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_binary_nonascii_file @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_doesnt_rewrite @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_from_bytes @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_from_string @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_invalid_8bit_bytes_header @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_mbox_or_mmdf_message @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_nonascii_StringIO_raises @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_nonascii_string_header_raises @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_text_file_warns @ linux-x86_64 +test.test_mailbox.TestMMDF.test_add_that_raises_leaves_mailbox_empty @ linux-x86_64 +test.test_mailbox.TestMMDF.test_clear @ linux-x86_64 +test.test_mailbox.TestMMDF.test_close @ linux-x86_64 +test.test_mailbox.TestMMDF.test_contains @ linux-x86_64 +test.test_mailbox.TestMMDF.test_delitem @ linux-x86_64 +test.test_mailbox.TestMMDF.test_discard @ linux-x86_64 +test.test_mailbox.TestMMDF.test_dump_message @ linux-x86_64 +test.test_mailbox.TestMMDF.test_flush @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_bytes @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_bytes_from @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_file @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_file_can_be_closed_twice @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_message @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_string @ linux-x86_64 +test.test_mailbox.TestMMDF.test_get_string_from @ linux-x86_64 +test.test_mailbox.TestMMDF.test_getitem @ linux-x86_64 +test.test_mailbox.TestMMDF.test_invalid_nonascii_header_as_string @ linux-x86_64 +test.test_mailbox.TestMMDF.test_items @ linux-x86_64 +test.test_mailbox.TestMMDF.test_iter @ linux-x86_64 +test.test_mailbox.TestMMDF.test_iteritems @ linux-x86_64 +test.test_mailbox.TestMMDF.test_iterkeys @ linux-x86_64 +test.test_mailbox.TestMMDF.test_itervalues @ linux-x86_64 +test.test_mailbox.TestMMDF.test_keys @ linux-x86_64 +test.test_mailbox.TestMMDF.test_len @ linux-x86_64 +test.test_mailbox.TestMMDF.test_lock_unlock @ linux-x86_64 +test.test_mailbox.TestMMDF.test_open_close_open @ linux-x86_64 +test.test_mailbox.TestMMDF.test_permissions_after_flush @ linux-x86_64 +test.test_mailbox.TestMMDF.test_pop @ linux-x86_64 +test.test_mailbox.TestMMDF.test_popitem @ linux-x86_64 +test.test_mailbox.TestMMDF.test_popitem_and_flush_twice @ linux-x86_64 +test.test_mailbox.TestMMDF.test_relock @ linux-x86_64 +test.test_mailbox.TestMMDF.test_remove @ linux-x86_64 +test.test_mailbox.TestMMDF.test_set_item @ linux-x86_64 +test.test_mailbox.TestMMDF.test_update @ linux-x86_64 +test.test_mailbox.TestMMDF.test_values @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_flags @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_from @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestMMDFMessage.test_initialize_with_unixfrom @ linux-x86_64 +test.test_mailbox.TestMailboxSuperclass.test_notimplemented @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_8bit_body @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_MM @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_StringIO_warns @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_and_remove_folders @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_binary_file @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_binary_nonascii_file @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_invalid_8bit_bytes_header @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_nonascii_StringIO_raises @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_nonascii_string_header_raises @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_text_file_warns @ linux-x86_64 +test.test_mailbox.TestMaildir.test_add_that_raises_leaves_mailbox_empty @ linux-x86_64 +test.test_mailbox.TestMaildir.test_clean @ linux-x86_64 +test.test_mailbox.TestMaildir.test_clear @ linux-x86_64 +test.test_mailbox.TestMaildir.test_close @ linux-x86_64 +test.test_mailbox.TestMaildir.test_consistent_factory @ linux-x86_64 +test.test_mailbox.TestMaildir.test_contains @ linux-x86_64 +test.test_mailbox.TestMaildir.test_create_tmp @ linux-x86_64 +test.test_mailbox.TestMaildir.test_delitem @ linux-x86_64 +test.test_mailbox.TestMaildir.test_directory_in_folder @ linux-x86_64 +test.test_mailbox.TestMaildir.test_discard @ linux-x86_64 +test.test_mailbox.TestMaildir.test_dump_message @ linux-x86_64 +test.test_mailbox.TestMaildir.test_file_permissions @ linux-x86_64 +test.test_mailbox.TestMaildir.test_flush @ linux-x86_64 +test.test_mailbox.TestMaildir.test_folder @ linux-x86_64 +test.test_mailbox.TestMaildir.test_folder_file_perms @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_MM @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_bytes @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_file @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_file_can_be_closed_twice @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_folder @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_message @ linux-x86_64 +test.test_mailbox.TestMaildir.test_get_string @ linux-x86_64 +test.test_mailbox.TestMaildir.test_getitem @ linux-x86_64 +test.test_mailbox.TestMaildir.test_initialize_existing @ linux-x86_64 +test.test_mailbox.TestMaildir.test_initialize_new @ linux-x86_64 +test.test_mailbox.TestMaildir.test_invalid_nonascii_header_as_string @ linux-x86_64 +test.test_mailbox.TestMaildir.test_items @ linux-x86_64 +test.test_mailbox.TestMaildir.test_iter @ linux-x86_64 +test.test_mailbox.TestMaildir.test_iteritems @ linux-x86_64 +test.test_mailbox.TestMaildir.test_iterkeys @ linux-x86_64 +test.test_mailbox.TestMaildir.test_itervalues @ linux-x86_64 +test.test_mailbox.TestMaildir.test_keys @ linux-x86_64 +test.test_mailbox.TestMaildir.test_len @ linux-x86_64 +test.test_mailbox.TestMaildir.test_list_folders @ linux-x86_64 +test.test_mailbox.TestMaildir.test_lock_unlock @ linux-x86_64 +test.test_mailbox.TestMaildir.test_lookup @ linux-x86_64 +test.test_mailbox.TestMaildir.test_pop @ linux-x86_64 +test.test_mailbox.TestMaildir.test_popitem @ linux-x86_64 +test.test_mailbox.TestMaildir.test_popitem_and_flush_twice @ linux-x86_64 +test.test_mailbox.TestMaildir.test_refresh @ linux-x86_64 +test.test_mailbox.TestMaildir.test_refresh_after_safety_period @ linux-x86_64 +test.test_mailbox.TestMaildir.test_remove @ linux-x86_64 +test.test_mailbox.TestMaildir.test_reread @ linux-x86_64 +test.test_mailbox.TestMaildir.test_set_MM @ linux-x86_64 +test.test_mailbox.TestMaildir.test_set_item @ linux-x86_64 +test.test_mailbox.TestMaildir.test_update @ linux-x86_64 +test.test_mailbox.TestMaildir.test_values @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_date @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_flags @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_info @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_info_and_flags @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestMaildirMessage.test_subdir @ linux-x86_64 +test.test_mailbox.TestMbox.test_add @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_8bit_body @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_StringIO_warns @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_and_close @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_binary_file @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_binary_nonascii_file @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_doesnt_rewrite @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_from_bytes @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_from_string @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_invalid_8bit_bytes_header @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_mbox_or_mmdf_message @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_nonascii_StringIO_raises @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_nonascii_string_header_raises @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_text_file_warns @ linux-x86_64 +test.test_mailbox.TestMbox.test_add_that_raises_leaves_mailbox_empty @ linux-x86_64 +test.test_mailbox.TestMbox.test_clear @ linux-x86_64 +test.test_mailbox.TestMbox.test_close @ linux-x86_64 +test.test_mailbox.TestMbox.test_contains @ linux-x86_64 +test.test_mailbox.TestMbox.test_delitem @ linux-x86_64 +test.test_mailbox.TestMbox.test_discard @ linux-x86_64 +test.test_mailbox.TestMbox.test_dump_message @ linux-x86_64 +test.test_mailbox.TestMbox.test_file_perms @ linux-x86_64 +test.test_mailbox.TestMbox.test_flush @ linux-x86_64 +test.test_mailbox.TestMbox.test_get @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_bytes @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_bytes_from @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_file @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_file_can_be_closed_twice @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_message @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_string @ linux-x86_64 +test.test_mailbox.TestMbox.test_get_string_from @ linux-x86_64 +test.test_mailbox.TestMbox.test_getitem @ linux-x86_64 +test.test_mailbox.TestMbox.test_invalid_nonascii_header_as_string @ linux-x86_64 +test.test_mailbox.TestMbox.test_items @ linux-x86_64 +test.test_mailbox.TestMbox.test_iter @ linux-x86_64 +test.test_mailbox.TestMbox.test_iteritems @ linux-x86_64 +test.test_mailbox.TestMbox.test_iterkeys @ linux-x86_64 +test.test_mailbox.TestMbox.test_itervalues @ linux-x86_64 +test.test_mailbox.TestMbox.test_keys @ linux-x86_64 +test.test_mailbox.TestMbox.test_len @ linux-x86_64 +test.test_mailbox.TestMbox.test_lock_unlock @ linux-x86_64 +test.test_mailbox.TestMbox.test_message_separator @ linux-x86_64 +test.test_mailbox.TestMbox.test_open_close_open @ linux-x86_64 +test.test_mailbox.TestMbox.test_permissions_after_flush @ linux-x86_64 +test.test_mailbox.TestMbox.test_pop @ linux-x86_64 +test.test_mailbox.TestMbox.test_popitem @ linux-x86_64 +test.test_mailbox.TestMbox.test_popitem_and_flush_twice @ linux-x86_64 +test.test_mailbox.TestMbox.test_relock @ linux-x86_64 +test.test_mailbox.TestMbox.test_remove @ linux-x86_64 +test.test_mailbox.TestMbox.test_set_item @ linux-x86_64 +test.test_mailbox.TestMbox.test_terminating_newline @ linux-x86_64 +test.test_mailbox.TestMbox.test_update @ linux-x86_64 +test.test_mailbox.TestMbox.test_values @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_flags @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_from @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestMboxMessage.test_initialize_with_unixfrom @ linux-x86_64 +test.test_mailbox.TestMessage.test_all_eMM_attributes_exist @ linux-x86_64 +test.test_mailbox.TestMessage.test_become_message @ linux-x86_64 +test.test_mailbox.TestMessage.test_explain_to @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_incorrectly @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_with_binary_file @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_with_eMM @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_with_file @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_with_nothing @ linux-x86_64 +test.test_mailbox.TestMessage.test_initialize_with_string @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_babyl_to_babyl @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_babyl_to_maildir @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_babyl_to_mboxmmdf @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_babyl_to_mh @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_maildir_to_babyl @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_maildir_to_maildir @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_maildir_to_mboxmmdf @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_maildir_to_mh @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mboxmmdf_to_babyl @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mboxmmdf_to_maildir @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mboxmmdf_to_mboxmmdf @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mboxmmdf_to_mh @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mh_to_babyl @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mh_to_maildir @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mh_to_mboxmmdf @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_mh_to_mh @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_plain_to_x @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_type_specific_attributes_removed_on_conversion @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_x_from_bytes @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_x_to_invalid @ linux-x86_64 +test.test_mailbox.TestMessageConversion.test_x_to_plain @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_close @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_initialize @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_iteration @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_read @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_readline @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_readlines @ linux-x86_64 +test.test_mailbox.TestPartialFile.test_seek_and_tell @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_close @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_initialize @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_iteration @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_read @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_readline @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_readlines @ linux-x86_64 +test.test_mailbox.TestProxyFile.test_seek_and_tell @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailcap.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailcap.txt new file mode 100644 index 0000000000..dde8262ec9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mailcap.txt @@ -0,0 +1,9 @@ +test.test_mailcap.FindmatchTest.test_findmatch @ linux-x86_64 +test.test_mailcap.FindmatchTest.test_test @ linux-x86_64 +test.test_mailcap.FindmatchTest.test_unsafe_mailcap_input @ linux-x86_64 +test.test_mailcap.GetcapsTest.test_mock_getcaps @ linux-x86_64 +test.test_mailcap.GetcapsTest.test_system_mailcap @ linux-x86_64 +test.test_mailcap.HelperFunctionTest.test_listmailcapfiles @ linux-x86_64 +test.test_mailcap.HelperFunctionTest.test_lookup @ linux-x86_64 +test.test_mailcap.HelperFunctionTest.test_readmailcapfile @ linux-x86_64 +test.test_mailcap.HelperFunctionTest.test_subst @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_marshal.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_marshal.txt new file mode 100644 index 0000000000..109e56ef41 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_marshal.txt @@ -0,0 +1,46 @@ +test.test_marshal.BufferTestCase.test_array @ linux-x86_64 +test.test_marshal.BufferTestCase.test_bytearray @ linux-x86_64 +test.test_marshal.BufferTestCase.test_memoryview @ linux-x86_64 +test.test_marshal.BugsTestCase.test_bad_reader @ linux-x86_64 +test.test_marshal.BugsTestCase.test_bug_5888452 @ linux-x86_64 +test.test_marshal.BugsTestCase.test_deterministic_sets @ linux-x86_64 +test.test_marshal.BugsTestCase.test_eof @ linux-x86_64 +test.test_marshal.BugsTestCase.test_exact_type_match @ linux-x86_64 +test.test_marshal.BugsTestCase.test_fuzz @ linux-x86_64 +test.test_marshal.BugsTestCase.test_large_marshal @ linux-x86_64 +test.test_marshal.BugsTestCase.test_loads_recursion @ linux-x86_64 +test.test_marshal.BugsTestCase.test_loads_reject_unicode_strings @ linux-x86_64 +test.test_marshal.BugsTestCase.test_multiple_dumps_and_loads @ linux-x86_64 +test.test_marshal.BugsTestCase.test_patch_873224 @ linux-x86_64 +test.test_marshal.BugsTestCase.test_recursion_limit @ linux-x86_64 +test.test_marshal.BugsTestCase.test_version_argument @ linux-x86_64 +test.test_marshal.CodeTestCase.test_different_filenames @ linux-x86_64 +test.test_marshal.CodeTestCase.test_many_codeobjects @ linux-x86_64 +test.test_marshal.CompatibilityTestCase.test0To3 @ linux-x86_64 +test.test_marshal.CompatibilityTestCase.test1To3 @ linux-x86_64 +test.test_marshal.CompatibilityTestCase.test2To3 @ linux-x86_64 +test.test_marshal.CompatibilityTestCase.test3To3 @ linux-x86_64 +test.test_marshal.ContainerTestCase.test_dict @ linux-x86_64 +test.test_marshal.ContainerTestCase.test_list @ linux-x86_64 +test.test_marshal.ContainerTestCase.test_sets @ linux-x86_64 +test.test_marshal.ContainerTestCase.test_tuple @ linux-x86_64 +test.test_marshal.ExceptionTestCase.test_exceptions @ linux-x86_64 +test.test_marshal.FloatTestCase.test_floats @ linux-x86_64 +test.test_marshal.InstancingTestCase.testBytes @ linux-x86_64 +test.test_marshal.InstancingTestCase.testDict @ linux-x86_64 +test.test_marshal.InstancingTestCase.testFloat @ linux-x86_64 +test.test_marshal.InstancingTestCase.testFrozenSet @ linux-x86_64 +test.test_marshal.InstancingTestCase.testInt @ linux-x86_64 +test.test_marshal.InstancingTestCase.testList @ linux-x86_64 +test.test_marshal.InstancingTestCase.testRecursion @ linux-x86_64 +test.test_marshal.InstancingTestCase.testSet @ linux-x86_64 +test.test_marshal.InstancingTestCase.testStr @ linux-x86_64 +test.test_marshal.InstancingTestCase.testTuple @ linux-x86_64 +test.test_marshal.IntTestCase.test_bool @ linux-x86_64 +test.test_marshal.IntTestCase.test_int64 @ linux-x86_64 +test.test_marshal.IntTestCase.test_ints @ linux-x86_64 +test.test_marshal.InterningTestCase.testIntern @ linux-x86_64 +test.test_marshal.InterningTestCase.testNoIntern @ linux-x86_64 +test.test_marshal.StringTestCase.test_bytes @ linux-x86_64 +test.test_marshal.StringTestCase.test_string @ linux-x86_64 +test.test_marshal.StringTestCase.test_unicode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_math.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_math.txt new file mode 100644 index 0000000000..d1a42e7a68 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_math.txt @@ -0,0 +1,70 @@ +DocFileCase.ieee754_txt @ linux-x86_64 +test.test_math.IsCloseTests.test_asymmetry @ linux-x86_64 +test.test_math.IsCloseTests.test_decimals @ linux-x86_64 +test.test_math.IsCloseTests.test_eight_decimal_places @ linux-x86_64 +test.test_math.IsCloseTests.test_fractions @ linux-x86_64 +test.test_math.IsCloseTests.test_identical @ linux-x86_64 +test.test_math.IsCloseTests.test_identical_infinite @ linux-x86_64 +test.test_math.IsCloseTests.test_inf_ninf_nan @ linux-x86_64 +test.test_math.IsCloseTests.test_integers @ linux-x86_64 +test.test_math.IsCloseTests.test_near_zero @ linux-x86_64 +test.test_math.IsCloseTests.test_negative_tolerances @ linux-x86_64 +test.test_math.IsCloseTests.test_zero_tolerance @ linux-x86_64 +test.test_math.MathTests.testAcos @ linux-x86_64 +test.test_math.MathTests.testAcosh @ linux-x86_64 +test.test_math.MathTests.testAsin @ linux-x86_64 +test.test_math.MathTests.testAsinh @ linux-x86_64 +test.test_math.MathTests.testAtan @ linux-x86_64 +test.test_math.MathTests.testAtan2 @ linux-x86_64 +test.test_math.MathTests.testAtanh @ linux-x86_64 +test.test_math.MathTests.testCeil @ linux-x86_64 +test.test_math.MathTests.testComb @ linux-x86_64 +test.test_math.MathTests.testConstants @ linux-x86_64 +test.test_math.MathTests.testCopysign @ linux-x86_64 +test.test_math.MathTests.testCos @ linux-x86_64 +test.test_math.MathTests.testCosh @ linux-x86_64 +test.test_math.MathTests.testDegrees @ linux-x86_64 +test.test_math.MathTests.testDist @ linux-x86_64 +test.test_math.MathTests.testExp @ linux-x86_64 +test.test_math.MathTests.testFabs @ linux-x86_64 +test.test_math.MathTests.testFactorial @ linux-x86_64 +test.test_math.MathTests.testFactorialNonIntegers @ linux-x86_64 +test.test_math.MathTests.testFloor @ linux-x86_64 +test.test_math.MathTests.testFmod @ linux-x86_64 +test.test_math.MathTests.testFrexp @ linux-x86_64 +test.test_math.MathTests.testFsum @ linux-x86_64 +test.test_math.MathTests.testGcd @ linux-x86_64 +test.test_math.MathTests.testHypot @ linux-x86_64 +test.test_math.MathTests.testIsfinite @ linux-x86_64 +test.test_math.MathTests.testIsinf @ linux-x86_64 +test.test_math.MathTests.testIsnan @ linux-x86_64 +test.test_math.MathTests.testIsqrt @ linux-x86_64 +test.test_math.MathTests.testLdexp @ linux-x86_64 +test.test_math.MathTests.testLog @ linux-x86_64 +test.test_math.MathTests.testLog10 @ linux-x86_64 +test.test_math.MathTests.testLog1p @ linux-x86_64 +test.test_math.MathTests.testLog2 @ linux-x86_64 +test.test_math.MathTests.testLog2Exact @ linux-x86_64 +test.test_math.MathTests.testModf @ linux-x86_64 +test.test_math.MathTests.testPerm @ linux-x86_64 +test.test_math.MathTests.testPow @ linux-x86_64 +test.test_math.MathTests.testRadians @ linux-x86_64 +test.test_math.MathTests.testRemainder @ linux-x86_64 +test.test_math.MathTests.testSin @ linux-x86_64 +test.test_math.MathTests.testSinh @ linux-x86_64 +test.test_math.MathTests.testSqrt @ linux-x86_64 +test.test_math.MathTests.testTan @ linux-x86_64 +test.test_math.MathTests.testTanh @ linux-x86_64 +test.test_math.MathTests.testTanhSign @ linux-x86_64 +test.test_math.MathTests.test_inf_constant @ linux-x86_64 +test.test_math.MathTests.test_input_exceptions @ linux-x86_64 +test.test_math.MathTests.test_issue39871 @ linux-x86_64 +test.test_math.MathTests.test_lcm @ linux-x86_64 +test.test_math.MathTests.test_math_dist_leak @ linux-x86_64 +test.test_math.MathTests.test_mtestfile @ linux-x86_64 +test.test_math.MathTests.test_nan_constant @ linux-x86_64 +test.test_math.MathTests.test_nextafter @ linux-x86_64 +test.test_math.MathTests.test_prod @ linux-x86_64 +test.test_math.MathTests.test_testfile @ linux-x86_64 +test.test_math.MathTests.test_trunc @ linux-x86_64 +test.test_math.MathTests.test_ulp @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryio.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryio.txt new file mode 100644 index 0000000000..dc8498f942 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryio.txt @@ -0,0 +1,157 @@ +test.test_memoryio.CBytesIOTest.testInit @ linux-x86_64 +test.test_memoryio.CBytesIOTest.testRead @ linux-x86_64 +test.test_memoryio.CBytesIOTest.testReadNoArgs @ linux-x86_64 +test.test_memoryio.CBytesIOTest.testSeek @ linux-x86_64 +test.test_memoryio.CBytesIOTest.testTell @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_bytes_array @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_detach @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_flags @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_flush @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_getstate @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_getvalue @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_init @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_instance_dict_leak @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_issue5449 @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_iterator @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_overseek @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_pickling @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_read @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_read1 @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_readinto @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_readline @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_readlines @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_seek @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_setstate @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_subclassing @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_tell @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_truncate @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_unicode @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_write @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_writelines @ linux-x86_64 +test.test_memoryio.CBytesIOTest.test_writelines_error @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_issue5265 @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_argument @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_cr @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_crlf @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_default @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_empty @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_lf @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newline_none @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_newlines_property @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.CStringIOPickleTest.test_textio_properties @ linux-x86_64 +test.test_memoryio.CStringIOTest.testInit @ linux-x86_64 +test.test_memoryio.CStringIOTest.testRead @ linux-x86_64 +test.test_memoryio.CStringIOTest.testReadNoArgs @ linux-x86_64 +test.test_memoryio.CStringIOTest.testSeek @ linux-x86_64 +test.test_memoryio.CStringIOTest.testTell @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_detach @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_flags @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_flush @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_getstate @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_getvalue @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_init @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_instance_dict_leak @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_issue5265 @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_iterator @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_argument @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_cr @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_crlf @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_default @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_empty @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_lf @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newline_none @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_newlines_property @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_overseek @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_pickling @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_read @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_readline @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_readlines @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_seek @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_setstate @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_subclassing @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_tell @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_textio_properties @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_truncate @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_widechar @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_write @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_writelines @ linux-x86_64 +test.test_memoryio.CStringIOTest.test_writelines_error @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.testInit @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.testRead @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.testReadNoArgs @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.testSeek @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.testTell @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_bytes_array @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_detach @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_flags @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_flush @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_getvalue @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_init @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_instance_dict_leak @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_issue5449 @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_iterator @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_overseek @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_pickling @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_read @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_read1 @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_readinto @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_readline @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_readlines @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_seek @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_subclassing @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_tell @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_truncate @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_unicode @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_write @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_writelines @ linux-x86_64 +test.test_memoryio.PyBytesIOTest.test_writelines_error @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_issue5265 @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_argument @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_cr @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_crlf @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_default @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_empty @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_lf @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newline_none @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_newlines_property @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.PyStringIOPickleTest.test_textio_properties @ linux-x86_64 +test.test_memoryio.PyStringIOTest.testInit @ linux-x86_64 +test.test_memoryio.PyStringIOTest.testRead @ linux-x86_64 +test.test_memoryio.PyStringIOTest.testReadNoArgs @ linux-x86_64 +test.test_memoryio.PyStringIOTest.testSeek @ linux-x86_64 +test.test_memoryio.PyStringIOTest.testTell @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_detach @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_flags @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_flush @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_getvalue @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_init @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_instance_dict_leak @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_issue5265 @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_iterator @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_argument @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_cr @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_crlf @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_default @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_empty @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_lf @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newline_none @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_newlines_property @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_overseek @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_pickling @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_read @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_readline @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_readlines @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_relative_seek @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_seek @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_subclassing @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_tell @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_textio_properties @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_truncate @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_write @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_writelines @ linux-x86_64 +test.test_memoryio.PyStringIOTest.test_writelines_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryview.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryview.txt new file mode 100644 index 0000000000..70524bce56 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_memoryview.txt @@ -0,0 +1,107 @@ +test.test_memoryview.ArrayMemorySliceSliceTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_compare @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_delitem @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_getitem @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_iter @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_release @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_reversed @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_tobytes @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceSliceTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_compare @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_delitem @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_getitem @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_iter @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_release @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_reversed @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_tobytes @ linux-x86_64 +test.test_memoryview.ArrayMemorySliceTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_array_assign @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_compare @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_delitem @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_getitem @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_iter @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_release @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_reversed @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_tobytes @ linux-x86_64 +test.test_memoryview.ArrayMemoryviewTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_attributes_readonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_compare @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_delitem @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_getbuffer @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_getitem @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_hash @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_iter @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_release @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_reversed @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_setitem_readonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_tobytes @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_tolist @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceSliceTest.test_writable_readonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_attributes_readonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_compare @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_delitem @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_getbuffer @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_getitem @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_hash @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_iter @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_release @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_reversed @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_setitem_readonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_tobytes @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_tolist @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.BytesMemorySliceTest.test_writable_readonly @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_attributes_readonly @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_attributes_writable @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_compare @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_constructor @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_contextmanager @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_delitem @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_getbuf_fail @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_getbuffer @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_getitem @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_hash @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_hash_writable @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_issue22668 @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_iter @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_release @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_reversed @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_setitem_readonly @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_setitem_writable @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_tobytes @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_tolist @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_toreadonly @ linux-x86_64 +test.test_memoryview.BytesMemoryviewTest.test_writable_readonly @ linux-x86_64 +test.test_memoryview.OtherTest.test_copy @ linux-x86_64 +test.test_memoryview.OtherTest.test_memoryview_hex @ linux-x86_64 +test.test_memoryview.OtherTest.test_pickle @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_metaclass.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_metaclass.txt new file mode 100644 index 0000000000..2b9509c9f5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_metaclass.txt @@ -0,0 +1 @@ +DocTestCase.test.test_metaclass.__test__.doctests @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mimetypes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mimetypes.txt new file mode 100644 index 0000000000..e71077bf05 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mimetypes.txt @@ -0,0 +1,20 @@ +test.test_mimetypes.MimeTypesTestCase.test_case_sensitivity @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_data_urls @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_default_data @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_encoding @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_file_parsing @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_filename_with_url_delimiters @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_guess_all_types @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_guess_known_extensions @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_init_reinitializes @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_init_stability @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_keywords_args_api @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_non_standard_types @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_path_like_ob @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_preferred_extension @ linux-x86_64 +test.test_mimetypes.MimeTypesTestCase.test_read_mime_types @ linux-x86_64 +test.test_mimetypes.MimetypesCliTestCase.test_guess_extension @ linux-x86_64 +test.test_mimetypes.MimetypesCliTestCase.test_guess_type @ linux-x86_64 +test.test_mimetypes.MimetypesCliTestCase.test_help_option @ linux-x86_64 +test.test_mimetypes.MimetypesCliTestCase.test_invalid_option @ linux-x86_64 +test.test_mimetypes.MiscTestCase.test__all__ @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_minidom.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_minidom.txt new file mode 100644 index 0000000000..e05f7b0085 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_minidom.txt @@ -0,0 +1,128 @@ +test.test_minidom.MinidomTest.testAAA @ linux-x86_64 +test.test_minidom.MinidomTest.testAAB @ linux-x86_64 +test.test_minidom.MinidomTest.testAddAttr @ linux-x86_64 +test.test_minidom.MinidomTest.testAltNewline @ linux-x86_64 +test.test_minidom.MinidomTest.testAppendChild @ linux-x86_64 +test.test_minidom.MinidomTest.testAppendChildFragment @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListItem @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListItemNS @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListItems @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListKeys @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListKeysNS @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListLength @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrListValues @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrList__getitem__ @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrList__setitem__ @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrModeSetsNonOptionalAttrs @ linux-x86_64 +test.test_minidom.MinidomTest.testAttrModeSetsParamsAsAttrs @ linux-x86_64 +test.test_minidom.MinidomTest.testAttributeRepr @ linux-x86_64 +test.test_minidom.MinidomTest.testBug0777884 @ linux-x86_64 +test.test_minidom.MinidomTest.testBug1433694 @ linux-x86_64 +test.test_minidom.MinidomTest.testChangeAttr @ linux-x86_64 +test.test_minidom.MinidomTest.testChildNodes @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneAttributeDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneAttributeShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentTypeDeepNotOk @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentTypeDeepOk @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentTypeShallowNotOk @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneDocumentTypeShallowOk @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneElementDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneElementShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testCloneNodeEntity @ linux-x86_64 +test.test_minidom.MinidomTest.testClonePIDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testClonePIShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testComment @ linux-x86_64 +test.test_minidom.MinidomTest.testContext @ linux-x86_64 +test.test_minidom.MinidomTest.testCreateAttributeNS @ linux-x86_64 +test.test_minidom.MinidomTest.testCreateElementNS @ linux-x86_64 +test.test_minidom.MinidomTest.testDeepcopiedDocument @ linux-x86_64 +test.test_minidom.MinidomTest.testDeleteAttr @ linux-x86_64 +test.test_minidom.MinidomTest.testDocRemoveChild @ linux-x86_64 +test.test_minidom.MinidomTest.testDocumentAsyncAttr @ linux-x86_64 +test.test_minidom.MinidomTest.testDocumentElement @ linux-x86_64 +test.test_minidom.MinidomTest.testElement @ linux-x86_64 +test.test_minidom.MinidomTest.testElementReprAndStr @ linux-x86_64 +test.test_minidom.MinidomTest.testElementReprAndStrUnicode @ linux-x86_64 +test.test_minidom.MinidomTest.testElementReprAndStrUnicodeNS @ linux-x86_64 +test.test_minidom.MinidomTest.testEmptyXMLNSValue @ linux-x86_64 +test.test_minidom.MinidomTest.testExceptionOnSpacesInXMLNSValue @ linux-x86_64 +test.test_minidom.MinidomTest.testFirstChild @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttrLength @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttrList @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttrValues @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttribute @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttributeNS @ linux-x86_64 +test.test_minidom.MinidomTest.testGetAttributeNode @ linux-x86_64 +test.test_minidom.MinidomTest.testGetElementsByTagName @ linux-x86_64 +test.test_minidom.MinidomTest.testGetElementsByTagNameNS @ linux-x86_64 +test.test_minidom.MinidomTest.testGetEmptyNodeListFromElementsByTagNameNS @ linux-x86_64 +test.test_minidom.MinidomTest.testHasAttribute @ linux-x86_64 +test.test_minidom.MinidomTest.testHasChildNodes @ linux-x86_64 +test.test_minidom.MinidomTest.testImportDocumentDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testImportDocumentShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testImportDocumentTypeDeep @ linux-x86_64 +test.test_minidom.MinidomTest.testImportDocumentTypeShallow @ linux-x86_64 +test.test_minidom.MinidomTest.testInsertBefore @ linux-x86_64 +test.test_minidom.MinidomTest.testInsertBeforeFragment @ linux-x86_64 +test.test_minidom.MinidomTest.testLegalChildren @ linux-x86_64 +test.test_minidom.MinidomTest.testNamedNodeMapSetItem @ linux-x86_64 +test.test_minidom.MinidomTest.testNodeListItem @ linux-x86_64 +test.test_minidom.MinidomTest.testNonZero @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalize @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeCombineAndNextSibling @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeDeleteAndCombine @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeDeleteWithNextSibling @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeDeleteWithPrevSibling @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeDeleteWithTwoNonTextSiblings @ linux-x86_64 +test.test_minidom.MinidomTest.testNormalizeRecursion @ linux-x86_64 +test.test_minidom.MinidomTest.testParents @ linux-x86_64 +test.test_minidom.MinidomTest.testParse @ linux-x86_64 +test.test_minidom.MinidomTest.testParseAttributeNamespaces @ linux-x86_64 +test.test_minidom.MinidomTest.testParseAttributes @ linux-x86_64 +test.test_minidom.MinidomTest.testParseElement @ linux-x86_64 +test.test_minidom.MinidomTest.testParseElementNamespaces @ linux-x86_64 +test.test_minidom.MinidomTest.testParseFromBinaryFile @ linux-x86_64 +test.test_minidom.MinidomTest.testParseFromTextFile @ linux-x86_64 +test.test_minidom.MinidomTest.testParseProcessingInstructions @ linux-x86_64 +test.test_minidom.MinidomTest.testParseString @ linux-x86_64 +test.test_minidom.MinidomTest.testPatch1094164 @ linux-x86_64 +test.test_minidom.MinidomTest.testPickledDocument @ linux-x86_64 +test.test_minidom.MinidomTest.testProcessingInstruction @ linux-x86_64 +test.test_minidom.MinidomTest.testProcessingInstructionNameError @ linux-x86_64 +test.test_minidom.MinidomTest.testProcessingInstructionRepr @ linux-x86_64 +test.test_minidom.MinidomTest.testRemoveAttr @ linux-x86_64 +test.test_minidom.MinidomTest.testRemoveAttrNS @ linux-x86_64 +test.test_minidom.MinidomTest.testRemoveAttributeNode @ linux-x86_64 +test.test_minidom.MinidomTest.testRemoveNamedItem @ linux-x86_64 +test.test_minidom.MinidomTest.testRemoveNamedItemNS @ linux-x86_64 +test.test_minidom.MinidomTest.testRenameAttribute @ linux-x86_64 +test.test_minidom.MinidomTest.testRenameElement @ linux-x86_64 +test.test_minidom.MinidomTest.testRenameOther @ linux-x86_64 +test.test_minidom.MinidomTest.testReplaceChildFragment @ linux-x86_64 +test.test_minidom.MinidomTest.testReplaceWholeText @ linux-x86_64 +test.test_minidom.MinidomTest.testSchemaType @ linux-x86_64 +test.test_minidom.MinidomTest.testSerializeCommentNodeWithDoubleHyphen @ linux-x86_64 +test.test_minidom.MinidomTest.testSetAttrValueandNodeValue @ linux-x86_64 +test.test_minidom.MinidomTest.testSetIdAttribute @ linux-x86_64 +test.test_minidom.MinidomTest.testSetIdAttributeNS @ linux-x86_64 +test.test_minidom.MinidomTest.testSetIdAttributeNode @ linux-x86_64 +test.test_minidom.MinidomTest.testSiblings @ linux-x86_64 +test.test_minidom.MinidomTest.testStandalone @ linux-x86_64 +test.test_minidom.MinidomTest.testTextNodeRepr @ linux-x86_64 +test.test_minidom.MinidomTest.testTextRepr @ linux-x86_64 +test.test_minidom.MinidomTest.testTooManyDocumentElements @ linux-x86_64 +test.test_minidom.MinidomTest.testUnlink @ linux-x86_64 +test.test_minidom.MinidomTest.testUserData @ linux-x86_64 +test.test_minidom.MinidomTest.testWholeText @ linux-x86_64 +test.test_minidom.MinidomTest.testWriteText @ linux-x86_64 +test.test_minidom.MinidomTest.testWriteXML @ linux-x86_64 +test.test_minidom.MinidomTest.test_cdata_parsing @ linux-x86_64 +test.test_minidom.MinidomTest.test_minidom_attribute_order @ linux-x86_64 +test.test_minidom.MinidomTest.test_toprettyxml_preserves_content_of_text_node @ linux-x86_64 +test.test_minidom.MinidomTest.test_toprettyxml_with_adjacent_text_nodes @ linux-x86_64 +test.test_minidom.MinidomTest.test_toprettyxml_with_attributes_ordered @ linux-x86_64 +test.test_minidom.MinidomTest.test_toprettyxml_with_cdata @ linux-x86_64 +test.test_minidom.MinidomTest.test_toprettyxml_with_text_nodes @ linux-x86_64 +test.test_minidom.MinidomTest.test_toxml_with_attributes_ordered @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mmap.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mmap.txt new file mode 100644 index 0000000000..f941254fe9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_mmap.txt @@ -0,0 +1,22 @@ +test.test_mmap.LargeMmapTests.test_large_offset @ linux-x86_64 +test.test_mmap.MmapTests.test_anonymous @ linux-x86_64 +test.test_mmap.MmapTests.test_bad_file_desc @ linux-x86_64 +test.test_mmap.MmapTests.test_basic @ linux-x86_64 +test.test_mmap.MmapTests.test_concat_repeat_exception @ linux-x86_64 +test.test_mmap.MmapTests.test_context_manager @ linux-x86_64 +test.test_mmap.MmapTests.test_context_manager_exception @ linux-x86_64 +test.test_mmap.MmapTests.test_double_close @ linux-x86_64 +test.test_mmap.MmapTests.test_empty_file @ linux-x86_64 +test.test_mmap.MmapTests.test_entire_file @ linux-x86_64 +test.test_mmap.MmapTests.test_extended_set_del_slice @ linux-x86_64 +test.test_mmap.MmapTests.test_find_does_not_access_beyond_buffer @ linux-x86_64 +test.test_mmap.MmapTests.test_find_end @ linux-x86_64 +test.test_mmap.MmapTests.test_length_0_large_offset @ linux-x86_64 +test.test_mmap.MmapTests.test_length_0_offset @ linux-x86_64 +test.test_mmap.MmapTests.test_offset @ linux-x86_64 +test.test_mmap.MmapTests.test_prot_readonly @ linux-x86_64 +test.test_mmap.MmapTests.test_read_all @ linux-x86_64 +test.test_mmap.MmapTests.test_read_invalid_arg @ linux-x86_64 +test.test_mmap.MmapTests.test_subclass @ linux-x86_64 +test.test_mmap.MmapTests.test_tougher_find @ linux-x86_64 +test.test_mmap.MmapTests.test_write_returning_the_number_of_bytes_written @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_module.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_module.txt new file mode 100644 index 0000000000..284e45ea81 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_module.txt @@ -0,0 +1,34 @@ +test.test_module.ModuleTests.test_annotations_are_created_correctly @ linux-x86_64 +test.test_module.ModuleTests.test_annotations_getset_raises @ linux-x86_64 +test.test_module.ModuleTests.test_ascii_docstring @ linux-x86_64 +test.test_module.ModuleTests.test_descriptor_errors_propagate @ linux-x86_64 +test.test_module.ModuleTests.test_dont_clear_dict @ linux-x86_64 +test.test_module.ModuleTests.test_lazy_create_annotations @ linux-x86_64 +test.test_module.ModuleTests.test_missing_getattr @ linux-x86_64 +test.test_module.ModuleTests.test_module_dir @ linux-x86_64 +test.test_module.ModuleTests.test_module_dir_errors @ linux-x86_64 +test.test_module.ModuleTests.test_module_getattr @ linux-x86_64 +test.test_module.ModuleTests.test_module_getattr_errors @ linux-x86_64 +test.test_module.ModuleTests.test_module_getattr_tricky @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_builtin @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_minimal @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_source @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_bare_loader @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_bare_loader_and_filename @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_bare_loader_but_no_name @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_filename_only @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_full_loader @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_full_loader_and_filename @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_full_loader_but_no_name @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_loader_as_None @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_name @ linux-x86_64 +test.test_module.ModuleTests.test_module_repr_with_name_and_filename @ linux-x86_64 +test.test_module.ModuleTests.test_no_docstring @ linux-x86_64 +test.test_module.ModuleTests.test_reinit @ linux-x86_64 +test.test_module.ModuleTests.test_repeated_attribute_pops @ linux-x86_64 +test.test_module.ModuleTests.test_setting_annotations @ linux-x86_64 +test.test_module.ModuleTests.test_subclass_with_slots @ linux-x86_64 +test.test_module.ModuleTests.test_unicode_docstring @ linux-x86_64 +test.test_module.ModuleTests.test_uninitialized @ linux-x86_64 +test.test_module.ModuleTests.test_uninitialized_missing_getattr @ linux-x86_64 +test.test_module.ModuleTests.test_weakref @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multibytecodec.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multibytecodec.txt new file mode 100644 index 0000000000..ae4b98b3c1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multibytecodec.txt @@ -0,0 +1,10 @@ +test.test_multibytecodec.TestStateful.test_encode @ linux-x86_64 +test.test_multibytecodec.Test_ISO2022.test_bug1572832 @ linux-x86_64 +test.test_multibytecodec.Test_IncrementalDecoder.test_dbcs @ linux-x86_64 +test.test_multibytecodec.Test_IncrementalDecoder.test_dbcs_keep_buffer @ linux-x86_64 +test.test_multibytecodec.Test_IncrementalEncoder.test_issue5640 @ linux-x86_64 +test.test_multibytecodec.Test_IncrementalEncoder.test_stateless @ linux-x86_64 +test.test_multibytecodec.Test_MultibyteCodec.test_codingspec @ linux-x86_64 +test.test_multibytecodec.Test_StreamWriter.test_gb18030 @ linux-x86_64 +test.test_multibytecodec.Test_StreamWriter.test_streamwriter_strwrite @ linux-x86_64 +test.test_multibytecodec.Test_StreamWriter.test_utf_8 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multiprocessing_spawn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multiprocessing_spawn.txt new file mode 100644 index 0000000000..cc75ee9221 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_multiprocessing_spawn.txt @@ -0,0 +1,192 @@ +test.test_multiprocessing_spawn.test_misc.MiscTestCase.test__all__ @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.MiscTestCase.test_spawn_sys_executable_none_allows_import @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.OtherTest.test_answer_challenge_auth_failure @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.OtherTest.test_deliver_challenge_auth_failure @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.SemLockTests.test_semlock_subclass @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestForkAwareThreadLock.test_lock @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestIgnoreEINTR.test_ignore @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestIgnoreEINTR.test_ignore_listener @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestInternalDecorators.test_only_run_in_spawn_testsuite @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestInvalidFamily.test_invalid_family @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestInvalidHandle.test_invalid_handles @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestNamedResource.test_global_named_resource_spawn @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestNoForkBomb.test_noforkbomb @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestPoolNotLeakOnFailure.test_release_unused_processes @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_resource_tracker @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_resource_tracker_reused @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestResourceTracker.test_too_long_name_resource @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSimpleQueue.test_close @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSimpleQueue.test_empty @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestStartMethod.test_get_all @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestStartMethod.test_nested_startmethod @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestStdinBadfiledescriptor.test_flushing @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestStdinBadfiledescriptor.test_pool_in_process @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestStdinBadfiledescriptor.test_queue_in_process @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_array @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_barrier @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_bounded_semaphore @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_condition @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_dict @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_event @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_joinable_queue @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_list @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_namespace @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_pool @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_queue @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_rlock @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_semaphore @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestSyncManagerTypes.test_value @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestTimeouts.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_neg_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_wait @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_wait_slow @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_wait_socket @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_wait_socket_slow @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc.TestWait.test_wait_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_misc._TestImportStar.test_import @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestArray.test_array @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestArray.test_array_from_size @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestArray.test_getobj_getlock_obj @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestArray.test_rawarray @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestCondition.test_notify @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestCondition.test_notify_all @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestCondition.test_notify_n @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestCondition.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestConnection.test_connection @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestConnection.test_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestConnection.test_duplex_false @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestConnection.test_sendbytes @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestConnection.test_spawn_close @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestEvent.test_event @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestEvent.test_repr @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListener.test_abstract_socket @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListener.test_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListener.test_multiple_bind @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListenerClient.test_issue14725 @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListenerClient.test_issue16955 @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestListenerClient.test_listener_client @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestLock.test_lock @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestLock.test_lock_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestLock.test_rlock @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestLogging.test_enable_logging @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestLogging.test_level @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestManagerRestart.test_rapid_restart @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoll.test_boundaries @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoll.test_dont_merge @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoll.test_empty_string @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoll.test_strings @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPollEintr.test_poll_eintr @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_apply @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_async_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_empty_iterable @ linux-x86_64 +!test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_enter @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_imap @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_imap_handle_iterable_exception @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_imap_unordered @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_imap_unordered_handle_iterable_exception @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_make_pool @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map_async_callbacks @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map_chunksize @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map_handle_iterable_exception @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_map_no_failfast @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_starmap @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_starmap_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_terminate @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_traceback @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPool.test_wrapped_exception @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerErrors.test_async_error_callback @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerErrors.test_unpickleable_result @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerLifetime.test_pool_maxtasksperchild_invalid @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerLifetime.test_pool_worker_lifetime @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerLifetime.test_pool_worker_lifetime_early_close @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestPoolWorkerLifetime.test_worker_finalization_via_atexit_handler_of_multiprocessing @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_active_children @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_args_argument @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_child_fd_inflation @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_cpu_count @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_current @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_daemon_argument @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_error_on_stdio_flush_1 @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_error_on_stdio_flush_2 @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_kill @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_parent_process @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_parent_process_attributes @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_process @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_recursion @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_sentinel @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_set_executable @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_terminate @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestProcess.test_wait_for_threads @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_closed_queue_put_get_exceptions @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_fork @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_get @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_no_import_lock_contention @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_put @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_qsize @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_queue_feeder_donot_stop_onexc @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_queue_feeder_on_queue_feeder_error @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_task_done @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestQueue.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestSemaphore.test_bounded_semaphore @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestSemaphore.test_semaphore @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestSemaphore.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestSubclassingProcess.test_stderr_flush @ linux-x86_64 +test.test_multiprocessing_spawn.test_processes.WithProcessesTestSubclassingProcess.test_subclassing @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestCondition.test_notify @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestCondition.test_notify_all @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestCondition.test_notify_n @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestCondition.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestConnection.test_connection @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestConnection.test_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestConnection.test_duplex_false @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestConnection.test_spawn_close @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestEvent.test_event @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestEvent.test_repr @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestListenerClient.test_issue14725 @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestListenerClient.test_issue16955 @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestListenerClient.test_listener_client @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestLock.test_lock_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestLock.test_rlock @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestManagerRestart.test_rapid_restart @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPoll.test_boundaries @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPoll.test_dont_merge @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPoll.test_empty_string @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPoll.test_strings @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_apply @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_async_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_context @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_empty_iterable @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_enter @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_imap @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_imap_unordered @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_make_pool @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_async_callbacks @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_chunksize @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_map_no_failfast @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_starmap_async @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestPool.test_traceback @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_active_children @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_args_argument @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_cpu_count @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_error_on_stdio_flush_1 @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_error_on_stdio_flush_2 @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_process @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestProcess.test_recursion @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_closed_queue_put_get_exceptions @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_fork @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_get @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_no_import_lock_contention @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_put @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_qsize @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_task_done @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestQueue.test_timeout @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestSemaphore.test_bounded_semaphore @ linux-x86_64 +test.test_multiprocessing_spawn.test_threads.WithThreadsTestSemaphore.test_semaphore @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_named_expressions.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_named_expressions.txt new file mode 100644 index 0000000000..eaec897c19 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_named_expressions.txt @@ -0,0 +1,65 @@ +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_01 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_02 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_03 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_04 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_05 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_06 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_07 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_08 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_09 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_10 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_11 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_12 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_13 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_14 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_15 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_16 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_17 @ linux-x86_64 +test.test_named_expressions.NamedExpressionAssignmentTest.test_named_expression_assignment_18 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_01 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_02 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_03 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_04 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_06 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_07 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_08 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_09 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_10 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_11 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_12 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_13 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_14 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_15 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_16 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_17 @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_in_class_body @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_list_comprehension_iterable_expression @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_rebinding_list_comprehension_inner_loop @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_rebinding_set_comprehension_inner_loop @ linux-x86_64 +test.test_named_expressions.NamedExpressionInvalidTest.test_named_expression_invalid_set_comprehension_iterable_expression @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_global_scope @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_global_scope_no_global_keyword @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_nonlocal_scope @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_nonlocal_scope_no_nonlocal_keyword @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_01 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_02 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_03 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_04 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_05 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_06 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_07 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_08 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_09 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_10 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_11 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_17 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_18 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_19 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_20 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_21 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_22 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_23 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_24 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_25 @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_scope_in_genexp @ linux-x86_64 +test.test_named_expressions.NamedExpressionScopeTest.test_named_expression_variable_reuse_in_comprehensions @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_netrc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_netrc.txt new file mode 100644 index 0000000000..145cb4c1f5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_netrc.txt @@ -0,0 +1,22 @@ +test.test_netrc.NetrcTestCase.test_comment_after_machine_line @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_after_machine_line_hash_only @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_after_machine_line_no_space @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_at_end_of_machine_line @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_at_end_of_machine_line_no_space @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_at_end_of_machine_line_pass_has_hash @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_before_machine_line @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_before_machine_line_hash_only @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_comment_before_machine_line_no_space @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_invalid_tokens @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_macros @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_optional_tokens @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_security @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_escape @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_internal_hash @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_leading_hash @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_non_ascii @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_quotes @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_trailing_hash @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_token_value_whitespace @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_toplevel_non_ordered_tokens @ linux-x86_64 +test.test_netrc.NetrcTestCase.test_toplevel_tokens @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_nntplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_nntplib.txt new file mode 100644 index 0000000000..139268cb91 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_nntplib.txt @@ -0,0 +1,71 @@ +test.test_nntplib.CapsAfterLoginNNTPv2Tests.test_caps_only_after_login @ linux-x86_64 +test.test_nntplib.LocalServerTests.test_starttls @ linux-x86_64 +test.test_nntplib.MiscTests.test_decode_header @ linux-x86_64 +test.test_nntplib.MiscTests.test_parse_datetime @ linux-x86_64 +test.test_nntplib.MiscTests.test_parse_overview @ linux-x86_64 +test.test_nntplib.MiscTests.test_parse_overview_fmt @ linux-x86_64 +test.test_nntplib.MiscTests.test_ssl_support @ linux-x86_64 +test.test_nntplib.MiscTests.test_unparse_datetime @ linux-x86_64 +test.test_nntplib.MiscTests.test_unparse_datetime_legacy @ linux-x86_64 +test.test_nntplib.MockSocketTests.test_bad_capabilities @ linux-x86_64 +test.test_nntplib.MockSocketTests.test_bad_welcome @ linux-x86_64 +test.test_nntplib.MockSocketTests.test_login_aborted @ linux-x86_64 +test.test_nntplib.MockSocketTests.test_service_permanently_unavailable @ linux-x86_64 +test.test_nntplib.MockSocketTests.test_service_temporarily_unavailable @ linux-x86_64 +test.test_nntplib.MockSslTests.test_bad_capabilities @ linux-x86_64 +test.test_nntplib.MockSslTests.test_bad_welcome @ linux-x86_64 +test.test_nntplib.MockSslTests.test_login_aborted @ linux-x86_64 +test.test_nntplib.MockSslTests.test_service_permanently_unavailable @ linux-x86_64 +test.test_nntplib.MockSslTests.test_service_temporarily_unavailable @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_article @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_article_file @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_authinfo @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_body @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_body_file @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_caps @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_date @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_description @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_descriptions @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_group @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_head @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_head_file @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_help @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_ihave @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_last @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_list @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_newnews @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_next @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_over @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_post @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_quit @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_stat @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_too_long_lines @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_welcome @ linux-x86_64 +test.test_nntplib.NNTPv1Tests.test_xover @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_article @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_article_file @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_authinfo @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_body @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_body_file @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_caps @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_date @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_description @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_descriptions @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_group @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_head @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_head_file @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_help @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_ihave @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_last @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_list @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_newnews @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_next @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_over @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_post @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_quit @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_stat @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_too_long_lines @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_welcome @ linux-x86_64 +test.test_nntplib.NNTPv2Tests.test_xover @ linux-x86_64 +test.test_nntplib.PublicAPITests.test_module_all_attribute @ linux-x86_64 +test.test_nntplib.SendReaderNNTPv2Tests.test_we_are_in_reader_mode_after_connect @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ntpath.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ntpath.txt new file mode 100644 index 0000000000..edcc20c1fe --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ntpath.txt @@ -0,0 +1,63 @@ +test.test_ntpath.NtCommonTest.test_abspath @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_abspath_issue3426 @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_commonprefix @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_exists @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_exists_fd @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_expandvars @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_expandvars_nonascii @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_filetime @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_getsize @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_import @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_isdir @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_isfile @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_join_errors @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_no_argument @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_nonascii_abspath @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_normcase @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_normpath_issue106242 @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_normpath_issue5827 @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_realpath @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_relpath_errors @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samefile @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samefile_on_link @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samefile_on_symlink @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_sameopenfile @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samestat @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samestat_on_link @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_samestat_on_symlink @ linux-x86_64 +test.test_ntpath.NtCommonTest.test_splitdrive @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_abspath @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_basename @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_commonpath @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_dirname @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_expanduser @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_expandvars @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_isabs @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_isdir @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_islink @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_ismount @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_join @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_lexists @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_normcase @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_normpath @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_realpath @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_relpath @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_split @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_splitdrive @ linux-x86_64 +test.test_ntpath.PathLikeTests.test_path_splitext @ linux-x86_64 +test.test_ntpath.TestNtpath.test_commonpath @ linux-x86_64 +test.test_ntpath.TestNtpath.test_commonprefix @ linux-x86_64 +test.test_ntpath.TestNtpath.test_expanduser @ linux-x86_64 +test.test_ntpath.TestNtpath.test_expandvars @ linux-x86_64 +test.test_ntpath.TestNtpath.test_expandvars_nonascii @ linux-x86_64 +test.test_ntpath.TestNtpath.test_isabs @ linux-x86_64 +test.test_ntpath.TestNtpath.test_ismount @ linux-x86_64 +test.test_ntpath.TestNtpath.test_join @ linux-x86_64 +test.test_ntpath.TestNtpath.test_normpath @ linux-x86_64 +test.test_ntpath.TestNtpath.test_realpath_curdir @ linux-x86_64 +test.test_ntpath.TestNtpath.test_realpath_pardir @ linux-x86_64 +test.test_ntpath.TestNtpath.test_relpath @ linux-x86_64 +test.test_ntpath.TestNtpath.test_sameopenfile @ linux-x86_64 +test.test_ntpath.TestNtpath.test_split @ linux-x86_64 +test.test_ntpath.TestNtpath.test_splitdrive @ linux-x86_64 +test.test_ntpath.TestNtpath.test_splitext @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_numeric_tower.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_numeric_tower.txt new file mode 100644 index 0000000000..895b05aa22 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_numeric_tower.txt @@ -0,0 +1,9 @@ +test.test_numeric_tower.ComparisonTest.test_complex @ linux-x86_64 +test.test_numeric_tower.ComparisonTest.test_mixed_comparisons @ linux-x86_64 +test.test_numeric_tower.HashTest.test_binary_floats @ linux-x86_64 +test.test_numeric_tower.HashTest.test_bools @ linux-x86_64 +test.test_numeric_tower.HashTest.test_complex @ linux-x86_64 +test.test_numeric_tower.HashTest.test_decimals @ linux-x86_64 +test.test_numeric_tower.HashTest.test_fractions @ linux-x86_64 +test.test_numeric_tower.HashTest.test_hash_normalization @ linux-x86_64 +test.test_numeric_tower.HashTest.test_integers @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcache.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcache.txt new file mode 100644 index 0000000000..c97e6aa2c1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcache.txt @@ -0,0 +1,26 @@ +test.test_opcache.TestCallCache.test_too_many_defaults_0 @ linux-x86_64 +test.test_opcache.TestCallCache.test_too_many_defaults_1 @ linux-x86_64 +test.test_opcache.TestCallCache.test_too_many_defaults_2 @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_descriptor_added_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_load_borrowed_slot_should_not_crash @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_load_shadowing_slot_should_raise_type_error @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_del_descriptor_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_descriptor_added_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_descriptor_shadows_class_attribute @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_getattribute @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_set_descriptor_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_metaclass_swap @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_store_borrowed_slot_should_not_crash @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_store_shadowing_slot_should_raise_type_error @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_type_descriptor_shadows_attribute_getset @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_type_descriptor_shadows_attribute_member @ linux-x86_64 +test.test_opcache.TestLoadAttrCache.test_type_descriptor_shadows_attribute_method @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_descriptor_added_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_del_descriptor_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_descriptor_added_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_descriptor_shadows_class_attribute @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_getattribute @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_set_descriptor_after_optimization @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_metaclass_swap @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_type_descriptor_shadows_attribute_member @ linux-x86_64 +test.test_opcache.TestLoadMethodCache.test_type_descriptor_shadows_attribute_method @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcodes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcodes.txt new file mode 100644 index 0000000000..e3a607ffe1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_opcodes.txt @@ -0,0 +1,8 @@ +test.test_opcodes.OpcodeTest.test_compare_function_objects @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_default_annotations_exist @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_do_not_recreate_annotations @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_modulo_of_string_subclasses @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_raise_class_exceptions @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_setup_annotations_line @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_try_inside_for_loop @ linux-x86_64 +test.test_opcodes.OpcodeTest.test_use_existing_annotations @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_operator.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_operator.txt new file mode 100644 index 0000000000..b5b42cfeac --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_operator.txt @@ -0,0 +1,94 @@ +test.test_operator.CCOperatorPickleTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.CCOperatorPickleTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.CCOperatorPickleTestCase.test_methodcaller @ linux-x86_64 +test.test_operator.COperatorTestCase.test___all__ @ linux-x86_64 +test.test_operator.COperatorTestCase.test_abs @ linux-x86_64 +test.test_operator.COperatorTestCase.test_add @ linux-x86_64 +test.test_operator.COperatorTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.COperatorTestCase.test_bitwise_and @ linux-x86_64 +test.test_operator.COperatorTestCase.test_bitwise_or @ linux-x86_64 +test.test_operator.COperatorTestCase.test_bitwise_xor @ linux-x86_64 +test.test_operator.COperatorTestCase.test_call @ linux-x86_64 +test.test_operator.COperatorTestCase.test_concat @ linux-x86_64 +test.test_operator.COperatorTestCase.test_contains @ linux-x86_64 +test.test_operator.COperatorTestCase.test_countOf @ linux-x86_64 +test.test_operator.COperatorTestCase.test_delitem @ linux-x86_64 +test.test_operator.COperatorTestCase.test_dunder_is_original @ linux-x86_64 +test.test_operator.COperatorTestCase.test_eq @ linux-x86_64 +test.test_operator.COperatorTestCase.test_floordiv @ linux-x86_64 +test.test_operator.COperatorTestCase.test_ge @ linux-x86_64 +test.test_operator.COperatorTestCase.test_getitem @ linux-x86_64 +test.test_operator.COperatorTestCase.test_gt @ linux-x86_64 +test.test_operator.COperatorTestCase.test_indexOf @ linux-x86_64 +test.test_operator.COperatorTestCase.test_inplace @ linux-x86_64 +test.test_operator.COperatorTestCase.test_invert @ linux-x86_64 +test.test_operator.COperatorTestCase.test_is @ linux-x86_64 +test.test_operator.COperatorTestCase.test_is_not @ linux-x86_64 +test.test_operator.COperatorTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.COperatorTestCase.test_le @ linux-x86_64 +test.test_operator.COperatorTestCase.test_length_hint @ linux-x86_64 +test.test_operator.COperatorTestCase.test_lshift @ linux-x86_64 +test.test_operator.COperatorTestCase.test_lt @ linux-x86_64 +test.test_operator.COperatorTestCase.test_matmul @ linux-x86_64 +test.test_operator.COperatorTestCase.test_methodcaller @ linux-x86_64 +test.test_operator.COperatorTestCase.test_mod @ linux-x86_64 +test.test_operator.COperatorTestCase.test_mul @ linux-x86_64 +test.test_operator.COperatorTestCase.test_ne @ linux-x86_64 +test.test_operator.COperatorTestCase.test_neg @ linux-x86_64 +test.test_operator.COperatorTestCase.test_pos @ linux-x86_64 +test.test_operator.COperatorTestCase.test_pow @ linux-x86_64 +test.test_operator.COperatorTestCase.test_rshift @ linux-x86_64 +test.test_operator.COperatorTestCase.test_setitem @ linux-x86_64 +test.test_operator.COperatorTestCase.test_sub @ linux-x86_64 +test.test_operator.COperatorTestCase.test_truediv @ linux-x86_64 +test.test_operator.COperatorTestCase.test_truth @ linux-x86_64 +test.test_operator.CPyOperatorPickleTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.CPyOperatorPickleTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.CPyOperatorPickleTestCase.test_methodcaller @ linux-x86_64 +test.test_operator.PyCOperatorPickleTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.PyCOperatorPickleTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.PyCOperatorPickleTestCase.test_methodcaller @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test___all__ @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_abs @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_add @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_bitwise_and @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_bitwise_or @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_bitwise_xor @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_call @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_concat @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_contains @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_countOf @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_delitem @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_dunder_is_original @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_eq @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_floordiv @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_ge @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_getitem @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_gt @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_indexOf @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_inplace @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_invert @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_is @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_is_not @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_le @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_length_hint @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_lshift @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_lt @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_matmul @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_methodcaller @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_mod @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_mul @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_ne @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_neg @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_pos @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_pow @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_rshift @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_setitem @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_sub @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_truediv @ linux-x86_64 +test.test_operator.PyOperatorTestCase.test_truth @ linux-x86_64 +test.test_operator.PyPyOperatorPickleTestCase.test_attrgetter @ linux-x86_64 +test.test_operator.PyPyOperatorPickleTestCase.test_itemgetter @ linux-x86_64 +test.test_operator.PyPyOperatorPickleTestCase.test_methodcaller @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_optparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_optparse.txt new file mode 100644 index 0000000000..0185a04eca --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_optparse.txt @@ -0,0 +1,151 @@ +test.test_optparse.MiscTestCase.test__all__ @ linux-x86_64 +test.test_optparse.TestBool.test_bool_default @ linux-x86_64 +test.test_optparse.TestBool.test_bool_false @ linux-x86_64 +test.test_optparse.TestBool.test_bool_flicker_on_and_off @ linux-x86_64 +test.test_optparse.TestBool.test_bool_true @ linux-x86_64 +test.test_optparse.TestCallback.test_callback @ linux-x86_64 +test.test_optparse.TestCallback.test_callback_help @ linux-x86_64 +test.test_optparse.TestCallbackCheckAbbrev.test_abbrev_callback_expansion @ linux-x86_64 +test.test_optparse.TestCallbackExtraArgs.test_callback_extra_args @ linux-x86_64 +test.test_optparse.TestCallbackManyArgs.test_many_args @ linux-x86_64 +test.test_optparse.TestCallbackMeddleArgs.test_callback_meddle_args @ linux-x86_64 +test.test_optparse.TestCallbackMeddleArgs.test_callback_meddle_args_separator @ linux-x86_64 +test.test_optparse.TestCallbackVarArgs.test_consume_separator_stop_at_option @ linux-x86_64 +test.test_optparse.TestCallbackVarArgs.test_positional_arg_and_variable_args @ linux-x86_64 +test.test_optparse.TestCallbackVarArgs.test_stop_at_invalid_option @ linux-x86_64 +test.test_optparse.TestCallbackVarArgs.test_stop_at_option @ linux-x86_64 +test.test_optparse.TestCallbackVarArgs.test_variable_args @ linux-x86_64 +test.test_optparse.TestChoice.test_add_choice_option @ linux-x86_64 +test.test_optparse.TestChoice.test_invalid_choice @ linux-x86_64 +test.test_optparse.TestChoice.test_valid_choice @ linux-x86_64 +test.test_optparse.TestConflict.test_conflict_error @ linux-x86_64 +test.test_optparse.TestConflict.test_conflict_error_group @ linux-x86_64 +test.test_optparse.TestConflict.test_no_such_conflict_handler @ linux-x86_64 +test.test_optparse.TestConflictOverride.test_conflict_override_args @ linux-x86_64 +test.test_optparse.TestConflictOverride.test_conflict_override_help @ linux-x86_64 +test.test_optparse.TestConflictOverride.test_conflict_override_opts @ linux-x86_64 +test.test_optparse.TestConflictResolve.test_conflict_resolve @ linux-x86_64 +test.test_optparse.TestConflictResolve.test_conflict_resolve_help @ linux-x86_64 +test.test_optparse.TestConflictResolve.test_conflict_resolve_long_opt @ linux-x86_64 +test.test_optparse.TestConflictResolve.test_conflict_resolve_long_opts @ linux-x86_64 +test.test_optparse.TestConflictResolve.test_conflict_resolve_short_opt @ linux-x86_64 +test.test_optparse.TestConflictingDefaults.test_conflict_default @ linux-x86_64 +test.test_optparse.TestConflictingDefaults.test_conflict_default_none @ linux-x86_64 +test.test_optparse.TestCount.test_count_interspersed_args @ linux-x86_64 +test.test_optparse.TestCount.test_count_no_interspersed_args @ linux-x86_64 +test.test_optparse.TestCount.test_count_no_such_option @ linux-x86_64 +test.test_optparse.TestCount.test_count_one @ linux-x86_64 +test.test_optparse.TestCount.test_count_option_no_value @ linux-x86_64 +test.test_optparse.TestCount.test_count_override_amount @ linux-x86_64 +test.test_optparse.TestCount.test_count_override_quiet @ linux-x86_64 +test.test_optparse.TestCount.test_count_overriding @ linux-x86_64 +test.test_optparse.TestCount.test_count_overriding_default @ linux-x86_64 +test.test_optparse.TestCount.test_count_three @ linux-x86_64 +test.test_optparse.TestCount.test_count_three_apart @ linux-x86_64 +test.test_optparse.TestCount.test_count_with_default @ linux-x86_64 +test.test_optparse.TestCount.test_empty @ linux-x86_64 +test.test_optparse.TestDefaultValues.test_basic_defaults @ linux-x86_64 +test.test_optparse.TestDefaultValues.test_mixed_defaults_post @ linux-x86_64 +test.test_optparse.TestDefaultValues.test_mixed_defaults_pre @ linux-x86_64 +test.test_optparse.TestDefaultValues.test_process_default @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_alt_expand @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_default_none_1 @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_default_none_2 @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_float_default @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_no_default @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_no_expand @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_option_default @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_parser_default_1 @ linux-x86_64 +test.test_optparse.TestExpandDefaults.test_parser_default_2 @ linux-x86_64 +test.test_optparse.TestExtendAddActions.test_extend_add_action @ linux-x86_64 +test.test_optparse.TestExtendAddActions.test_extend_add_action_normal @ linux-x86_64 +test.test_optparse.TestExtendAddTypes.test_filetype_noexist @ linux-x86_64 +test.test_optparse.TestExtendAddTypes.test_filetype_notfile @ linux-x86_64 +test.test_optparse.TestExtendAddTypes.test_filetype_ok @ linux-x86_64 +test.test_optparse.TestHelp.test_help @ linux-x86_64 +test.test_optparse.TestHelp.test_help_description_groups @ linux-x86_64 +test.test_optparse.TestHelp.test_help_long_opts_first @ linux-x86_64 +test.test_optparse.TestHelp.test_help_old_usage @ linux-x86_64 +test.test_optparse.TestHelp.test_help_title_formatter @ linux-x86_64 +test.test_optparse.TestHelp.test_help_unicode @ linux-x86_64 +test.test_optparse.TestHelp.test_help_unicode_description @ linux-x86_64 +test.test_optparse.TestHelp.test_wrap_columns @ linux-x86_64 +test.test_optparse.TestMatchAbbrev.test_match_abbrev @ linux-x86_64 +test.test_optparse.TestMatchAbbrev.test_match_abbrev_error @ linux-x86_64 +test.test_optparse.TestMultipleArgs.test_nargs_invalid_float_value @ linux-x86_64 +test.test_optparse.TestMultipleArgs.test_nargs_long_opt @ linux-x86_64 +test.test_optparse.TestMultipleArgs.test_nargs_required_values @ linux-x86_64 +test.test_optparse.TestMultipleArgs.test_nargs_with_positional_args @ linux-x86_64 +test.test_optparse.TestMultipleArgsAppend.test_nargs_append @ linux-x86_64 +test.test_optparse.TestMultipleArgsAppend.test_nargs_append_const @ linux-x86_64 +test.test_optparse.TestMultipleArgsAppend.test_nargs_append_required_values @ linux-x86_64 +test.test_optparse.TestMultipleArgsAppend.test_nargs_append_simple @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_action_invalid @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_attr_invalid @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_bad_choices_list @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_callback_args_no_tuple @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_callback_kwargs_no_dict @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_callback_not_callable @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_callback_args_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_callback_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_callback_kwargs_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_choices_for_type @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_choices_list @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_const_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_nargs_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_single_dash @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_no_type_for_action @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_opt_string_empty @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_opt_string_long_invalid @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_opt_string_short_invalid @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_opt_string_too_short @ linux-x86_64 +test.test_optparse.TestOptionChecks.test_type_invalid @ linux-x86_64 +test.test_optparse.TestOptionGroup.test_add_group_invalid_arguments @ linux-x86_64 +test.test_optparse.TestOptionGroup.test_add_group_no_group @ linux-x86_64 +test.test_optparse.TestOptionGroup.test_add_group_wrong_parser @ linux-x86_64 +test.test_optparse.TestOptionGroup.test_group_manipulate @ linux-x86_64 +test.test_optparse.TestOptionGroup.test_option_group_create_instance @ linux-x86_64 +test.test_optparse.TestOptionParser.test_add_option_invalid_arguments @ linux-x86_64 +test.test_optparse.TestOptionParser.test_add_option_no_Option @ linux-x86_64 +test.test_optparse.TestOptionParser.test_get_option @ linux-x86_64 +test.test_optparse.TestOptionParser.test_get_option_equals @ linux-x86_64 +test.test_optparse.TestOptionParser.test_has_option @ linux-x86_64 +test.test_optparse.TestOptionParser.test_remove_long_opt @ linux-x86_64 +test.test_optparse.TestOptionParser.test_remove_nonexistent @ linux-x86_64 +test.test_optparse.TestOptionParser.test_remove_short_opt @ linux-x86_64 +test.test_optparse.TestOptionValues.test_basics @ linux-x86_64 +test.test_optparse.TestParseNumber.test_numeric_options @ linux-x86_64 +test.test_optparse.TestParseNumber.test_parse_num_fail @ linux-x86_64 +test.test_optparse.TestParseNumber.test_parse_num_ok @ linux-x86_64 +test.test_optparse.TestProgName.test_custom_progname @ linux-x86_64 +test.test_optparse.TestProgName.test_default_progname @ linux-x86_64 +test.test_optparse.TestStandard.test_abbrev_long_option @ linux-x86_64 +test.test_optparse.TestStandard.test_ambiguous_option @ linux-x86_64 +test.test_optparse.TestStandard.test_combined_single_invalid_option @ linux-x86_64 +test.test_optparse.TestStandard.test_defaults @ linux-x86_64 +test.test_optparse.TestStandard.test_empty @ linux-x86_64 +test.test_optparse.TestStandard.test_hyphen_becomes_positional_arg @ linux-x86_64 +test.test_optparse.TestStandard.test_invalid_integer @ linux-x86_64 +test.test_optparse.TestStandard.test_long_invalid_integer @ linux-x86_64 +test.test_optparse.TestStandard.test_long_option_append @ linux-x86_64 +test.test_optparse.TestStandard.test_long_option_argument_joined @ linux-x86_64 +test.test_optparse.TestStandard.test_long_option_argument_split @ linux-x86_64 +test.test_optparse.TestStandard.test_long_option_short_option @ linux-x86_64 +test.test_optparse.TestStandard.test_no_append_versus_append @ linux-x86_64 +test.test_optparse.TestStandard.test_no_such_option @ linux-x86_64 +test.test_optparse.TestStandard.test_option_argument_joined @ linux-x86_64 +test.test_optparse.TestStandard.test_option_argument_joined_integer @ linux-x86_64 +test.test_optparse.TestStandard.test_option_argument_split @ linux-x86_64 +test.test_optparse.TestStandard.test_option_argument_split_negative_integer @ linux-x86_64 +test.test_optparse.TestStandard.test_option_consumes_optionlike_string @ linux-x86_64 +test.test_optparse.TestStandard.test_required_value @ linux-x86_64 +test.test_optparse.TestStandard.test_short_and_long_option_split @ linux-x86_64 +test.test_optparse.TestStandard.test_short_option_consumes_separator @ linux-x86_64 +test.test_optparse.TestStandard.test_short_option_joined_and_separator @ linux-x86_64 +test.test_optparse.TestStandard.test_short_option_split_long_option_append @ linux-x86_64 +test.test_optparse.TestStandard.test_short_option_split_one_positional_arg @ linux-x86_64 +test.test_optparse.TestStandard.test_shortopt_empty_longopt_append @ linux-x86_64 +test.test_optparse.TestTypeAliases.test_str_aliases_string @ linux-x86_64 +test.test_optparse.TestTypeAliases.test_type_object @ linux-x86_64 +test.test_optparse.TestVersion.test_no_version @ linux-x86_64 +test.test_optparse.TestVersion.test_version @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ordered_dict.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ordered_dict.txt new file mode 100644 index 0000000000..fb2dbeaf46 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ordered_dict.txt @@ -0,0 +1,251 @@ +test.test_ordered_dict.CPythonBuiltinDictTests.test_abc @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_clear @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_delitem @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_delitem_hash_collision @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_detect_deletion_during_iteration @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_highly_nested @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_init @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_override_update @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_reinsert @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_setitem @ linux-x86_64 +test.test_ordered_dict.CPythonBuiltinDictTests.test_update @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_bool @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_constructor @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_get @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_getitem @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_items @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_keys @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_len @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_pop @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_read @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_update @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_values @ linux-x86_64 +test.test_ordered_dict.CPythonGeneralMappingTests.test_write @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_468 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_abc @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_clear @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_copying @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_delitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_delitem_hash_collision @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_detect_deletion_during_iteration @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_delitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_pop @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_setitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_dict_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_equality @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_fromkeys @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_highly_nested @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_init @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_init_calls @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_issue24348 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_issue24667 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_iterators @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_iterators_empty @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_iterators_pickling @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_merge_operator @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_move_to_end @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_move_to_end_issue25406 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_overridden_init @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_override_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_pickle_recursive @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_pop @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_popitem_last @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_reduce_not_too_fat @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_reinsert @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_repr @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_repr_recursive @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_repr_recursive_values @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_setitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_sizeof @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_sorted_iterators @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_views @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictSubclassTests.test_yaml_linkage @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_468 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_abc @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_clear @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_copying @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_delitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_delitem_hash_collision @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_detect_deletion_during_iteration @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_delitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_pop @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_setitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_dict_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_equality @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_fromkeys @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_highly_nested @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_init @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_init_calls @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_issue24348 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_issue24667 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_iterators @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_iterators_empty @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_iterators_pickling @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_merge_operator @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_move_to_end @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_move_to_end_issue25406 @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_overridden_init @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_override_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_pickle_recursive @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_pop @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_popitem_last @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_reduce_not_too_fat @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_reinsert @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_repr @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_repr_recursive @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_repr_recursive_values @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_setitem @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_sizeof @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_sorted_iterators @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_update @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_views @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictTests.test_yaml_linkage @ linux-x86_64 +test.test_ordered_dict.CPythonOrderedDictWithSlotsCopyingTests.test_copying @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_bool @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_constructor @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_get @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_getitem @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_items @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_keys @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_len @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_pop @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_read @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_update @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_values @ linux-x86_64 +test.test_ordered_dict.CPythonSubclassMappingTests.test_write @ linux-x86_64 +test.test_ordered_dict.CSimpleLRUCacheTests.test_add_after_full @ linux-x86_64 +test.test_ordered_dict.CSimpleLRUCacheTests.test_change_order_on_get @ linux-x86_64 +test.test_ordered_dict.CSimpleLRUCacheTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_bool @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_constructor @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_get @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_getitem @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_items @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_keys @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_len @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_read @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_update @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_values @ linux-x86_64 +test.test_ordered_dict.PurePythonGeneralMappingTests.test_write @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_468 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_abc @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_clear @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_copying @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_delitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_delitem_hash_collision @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_detect_deletion_during_iteration @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_delitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_setitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_dict_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_equality @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_fromkeys @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_highly_nested @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_init @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_init_calls @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_issue24348 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_issue24667 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_iterators @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_iterators_empty @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_merge_operator @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_move_to_end @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_move_to_end_issue25406 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_overridden_init @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_override_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_pickle_recursive @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_popitem_last @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_reduce_not_too_fat @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_reinsert @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_repr @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_repr_recursive @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_repr_recursive_values @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_setitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_sizeof @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_sorted_iterators @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_views @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictSubclassTests.test_yaml_linkage @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_468 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_abc @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_clear @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_copying @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_delitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_delitem_hash_collision @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_detect_deletion_during_iteration @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_delitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_setitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_dict_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_equality @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_fromkeys @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_highly_nested @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_init @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_init_calls @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_issue24348 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_issue24667 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_iterators @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_iterators_empty @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_merge_operator @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_move_to_end @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_move_to_end_issue25406 @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_overridden_init @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_override_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_pickle_recursive @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_popitem_last @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_reduce_not_too_fat @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_reinsert @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_repr @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_repr_recursive @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_repr_recursive_values @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_setitem @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_sizeof @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_sorted_iterators @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_update @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_views @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictTests.test_yaml_linkage @ linux-x86_64 +test.test_ordered_dict.PurePythonOrderedDictWithSlotsCopyingTests.test_copying @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_bool @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_constructor @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_get @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_getitem @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_items @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_keys @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_len @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_pop @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_popitem @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_read @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_setdefault @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_update @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_values @ linux-x86_64 +test.test_ordered_dict.PurePythonSubclassMappingTests.test_write @ linux-x86_64 +test.test_ordered_dict.PySimpleLRUCacheTests.test_add_after_full @ linux-x86_64 +test.test_ordered_dict.PySimpleLRUCacheTests.test_change_order_on_get @ linux-x86_64 +test.test_ordered_dict.PySimpleLRUCacheTests.test_pop @ linux-x86_64 +test.test_ordered_dict.PySimpleLRUCacheTests.test_popitem @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_os.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_os.txt new file mode 100644 index 0000000000..fd0f9b3ced --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_os.txt @@ -0,0 +1,192 @@ +test.test_os.BlockingTests.test_blocking @ linux-x86_64 +test.test_os.BytesFwalkTests.test_compare_to_walk @ linux-x86_64 +test.test_os.BytesFwalkTests.test_dir_fd @ linux-x86_64 +test.test_os.BytesFwalkTests.test_fd_leak @ linux-x86_64 +test.test_os.BytesFwalkTests.test_file_like_path @ linux-x86_64 +test.test_os.BytesFwalkTests.test_walk_bad_dir @ linux-x86_64 +test.test_os.BytesFwalkTests.test_walk_bottom_up @ linux-x86_64 +test.test_os.BytesFwalkTests.test_walk_prune @ linux-x86_64 +test.test_os.BytesFwalkTests.test_walk_symlink @ linux-x86_64 +test.test_os.BytesFwalkTests.test_walk_topdown @ linux-x86_64 +test.test_os.BytesFwalkTests.test_yields_correct_dir_fd @ linux-x86_64 +test.test_os.BytesWalkTests.test_file_like_path @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_bad_dir @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_bottom_up @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_many_open_files @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_prune @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_symlink @ linux-x86_64 +test.test_os.BytesWalkTests.test_walk_topdown @ linux-x86_64 +test.test_os.CPUCountTests.test_cpu_count @ linux-x86_64 +test.test_os.ChownFileTests.test_chown_uid_gid_arguments_must_be_index @ linux-x86_64 +test.test_os.ChownFileTests.test_chown_without_permission @ linux-x86_64 +test.test_os.DevNullTests.test_devnull @ linux-x86_64 +test.test_os.EnvironTests.test___repr__ @ linux-x86_64 +test.test_os.EnvironTests.test_bool @ linux-x86_64 +test.test_os.EnvironTests.test_constructor @ linux-x86_64 +test.test_os.EnvironTests.test_environb @ linux-x86_64 +test.test_os.EnvironTests.test_get @ linux-x86_64 +test.test_os.EnvironTests.test_get_exec_path @ linux-x86_64 +test.test_os.EnvironTests.test_getitem @ linux-x86_64 +test.test_os.EnvironTests.test_ior_operator @ linux-x86_64 +test.test_os.EnvironTests.test_ior_operator_invalid_dicts @ linux-x86_64 +test.test_os.EnvironTests.test_ior_operator_key_value_iterable @ linux-x86_64 +test.test_os.EnvironTests.test_items @ linux-x86_64 +test.test_os.EnvironTests.test_iter_error_when_changing_os_environ @ linux-x86_64 +test.test_os.EnvironTests.test_iter_error_when_changing_os_environ_items @ linux-x86_64 +test.test_os.EnvironTests.test_iter_error_when_changing_os_environ_values @ linux-x86_64 +test.test_os.EnvironTests.test_key_type @ linux-x86_64 +test.test_os.EnvironTests.test_keys @ linux-x86_64 +test.test_os.EnvironTests.test_keyvalue_types @ linux-x86_64 +test.test_os.EnvironTests.test_len @ linux-x86_64 +test.test_os.EnvironTests.test_or_operator @ linux-x86_64 +test.test_os.EnvironTests.test_os_popen_iter @ linux-x86_64 +test.test_os.EnvironTests.test_pop @ linux-x86_64 +test.test_os.EnvironTests.test_popitem @ linux-x86_64 +test.test_os.EnvironTests.test_putenv_unsetenv @ linux-x86_64 +test.test_os.EnvironTests.test_putenv_unsetenv_error @ linux-x86_64 +test.test_os.EnvironTests.test_read @ linux-x86_64 +test.test_os.EnvironTests.test_ror_operator @ linux-x86_64 +test.test_os.EnvironTests.test_setdefault @ linux-x86_64 +test.test_os.EnvironTests.test_update @ linux-x86_64 +test.test_os.EnvironTests.test_update2 @ linux-x86_64 +test.test_os.EnvironTests.test_values @ linux-x86_64 +test.test_os.EnvironTests.test_write @ linux-x86_64 +test.test_os.ExecTests.test_execv_with_bad_arglist @ linux-x86_64 +test.test_os.ExecTests.test_execvpe_with_bad_program @ linux-x86_64 +test.test_os.ExportsTests.test_os_all @ linux-x86_64 +test.test_os.FDInheritanceTests.test_dup @ linux-x86_64 +test.test_os.FDInheritanceTests.test_dup2 @ linux-x86_64 +test.test_os.FDInheritanceTests.test_dup_standard_stream @ linux-x86_64 +test.test_os.FDInheritanceTests.test_get_set_inheritable @ linux-x86_64 +test.test_os.FDInheritanceTests.test_get_set_inheritable_badf @ linux-x86_64 +test.test_os.FDInheritanceTests.test_get_set_inheritable_o_path @ linux-x86_64 +test.test_os.FDInheritanceTests.test_open @ linux-x86_64 +test.test_os.FDInheritanceTests.test_openpty @ linux-x86_64 +test.test_os.FDInheritanceTests.test_pipe @ linux-x86_64 +test.test_os.FSEncodingTests.test_identity @ linux-x86_64 +test.test_os.FSEncodingTests.test_nop @ linux-x86_64 +test.test_os.FileTests.test_access @ linux-x86_64 +test.test_os.FileTests.test_fdopen @ linux-x86_64 +test.test_os.FileTests.test_open_keywords @ linux-x86_64 +test.test_os.FileTests.test_read @ linux-x86_64 +test.test_os.FileTests.test_replace @ linux-x86_64 +test.test_os.FileTests.test_symlink_keywords @ linux-x86_64 +test.test_os.FileTests.test_write @ linux-x86_64 +test.test_os.FwalkTests.test_compare_to_walk @ linux-x86_64 +test.test_os.FwalkTests.test_dir_fd @ linux-x86_64 +test.test_os.FwalkTests.test_fd_leak @ linux-x86_64 +test.test_os.FwalkTests.test_file_like_path @ linux-x86_64 +test.test_os.FwalkTests.test_walk_bad_dir @ linux-x86_64 +test.test_os.FwalkTests.test_walk_bottom_up @ linux-x86_64 +test.test_os.FwalkTests.test_walk_prune @ linux-x86_64 +test.test_os.FwalkTests.test_walk_symlink @ linux-x86_64 +test.test_os.FwalkTests.test_walk_topdown @ linux-x86_64 +test.test_os.FwalkTests.test_yields_correct_dir_fd @ linux-x86_64 +test.test_os.LinkTests.test_link @ linux-x86_64 +test.test_os.LinkTests.test_link_bytes @ linux-x86_64 +test.test_os.LinkTests.test_unicode_name @ linux-x86_64 +test.test_os.MakedirTests.test_exist_ok_existing_directory @ linux-x86_64 +test.test_os.MakedirTests.test_exist_ok_existing_regular_file @ linux-x86_64 +test.test_os.MakedirTests.test_exist_ok_s_isgid_directory @ linux-x86_64 +test.test_os.MakedirTests.test_makedir @ linux-x86_64 +test.test_os.MakedirTests.test_mode @ linux-x86_64 +test.test_os.MiscTests.test_getcwd @ linux-x86_64 +test.test_os.MiscTests.test_getcwd_long_path @ linux-x86_64 +test.test_os.MiscTests.test_getcwdb @ linux-x86_64 +test.test_os.NonLocalSymlinkTests.test_directory_link_nonlocal @ linux-x86_64 +test.test_os.OSErrorTests.test_oserror_filename @ linux-x86_64 +test.test_os.PathTConverterTests.test_path_t_converter @ linux-x86_64 +test.test_os.PathTConverterTests.test_path_t_converter_and_custom_class @ linux-x86_64 +test.test_os.PidTests.test_getppid @ linux-x86_64 +test.test_os.ReadlinkTests.test_bytes @ linux-x86_64 +test.test_os.ReadlinkTests.test_missing_link @ linux-x86_64 +test.test_os.ReadlinkTests.test_not_symlink @ linux-x86_64 +test.test_os.ReadlinkTests.test_pathlike @ linux-x86_64 +test.test_os.ReadlinkTests.test_pathlike_bytes @ linux-x86_64 +test.test_os.RemoveDirsTests.test_remove_all @ linux-x86_64 +test.test_os.RemoveDirsTests.test_remove_nothing @ linux-x86_64 +test.test_os.RemoveDirsTests.test_remove_partial @ linux-x86_64 +test.test_os.StatAttributeTests.test_stat_attributes @ linux-x86_64 +test.test_os.StatAttributeTests.test_stat_attributes_bytes @ linux-x86_64 +test.test_os.StatAttributeTests.test_stat_result_pickle @ linux-x86_64 +test.test_os.StatAttributeTests.test_statvfs_attributes @ linux-x86_64 +test.test_os.StatAttributeTests.test_statvfs_result_pickle @ linux-x86_64 +test.test_os.TestDirEntry.test_uninstantiable @ linux-x86_64 +test.test_os.TestDirEntry.test_unpickable @ linux-x86_64 +test.test_os.TestInvalidFD.test_blocking @ linux-x86_64 +test.test_os.TestInvalidFD.test_dup @ linux-x86_64 +test.test_os.TestInvalidFD.test_dup2 @ linux-x86_64 +test.test_os.TestInvalidFD.test_fchdir @ linux-x86_64 +test.test_os.TestInvalidFD.test_fchmod @ linux-x86_64 +test.test_os.TestInvalidFD.test_fchown @ linux-x86_64 +test.test_os.TestInvalidFD.test_fdatasync @ linux-x86_64 +test.test_os.TestInvalidFD.test_fdopen @ linux-x86_64 +test.test_os.TestInvalidFD.test_fstat @ linux-x86_64 +test.test_os.TestInvalidFD.test_fstatvfs @ linux-x86_64 +test.test_os.TestInvalidFD.test_fsync @ linux-x86_64 +test.test_os.TestInvalidFD.test_ftruncate @ linux-x86_64 +test.test_os.TestInvalidFD.test_inheritable @ linux-x86_64 +test.test_os.TestInvalidFD.test_isatty @ linux-x86_64 +test.test_os.TestInvalidFD.test_lseek @ linux-x86_64 +test.test_os.TestInvalidFD.test_read @ linux-x86_64 +test.test_os.TestInvalidFD.test_tcgetpgrp @ linux-x86_64 +test.test_os.TestInvalidFD.test_ttyname @ linux-x86_64 +test.test_os.TestInvalidFD.test_write @ linux-x86_64 +test.test_os.TestPEP519.test_argument_required @ linux-x86_64 +test.test_os.TestPEP519.test_bad_pathlike @ linux-x86_64 +test.test_os.TestPEP519.test_fsencode_fsdecode @ linux-x86_64 +test.test_os.TestPEP519.test_garbage_in_exception_out @ linux-x86_64 +test.test_os.TestPEP519.test_pathlike @ linux-x86_64 +test.test_os.TestPEP519.test_pathlike_class_getitem @ linux-x86_64 +test.test_os.TestPEP519.test_pathlike_subclasshook @ linux-x86_64 +test.test_os.TestPEP519.test_return_bytes @ linux-x86_64 +test.test_os.TestPEP519.test_return_string @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_argument_required @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_bad_pathlike @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_fsencode_fsdecode @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_garbage_in_exception_out @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_pathlike @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_pathlike_class_getitem @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_pathlike_subclasshook @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_return_bytes @ linux-x86_64 +test.test_os.TestPEP519PurePython.test_return_string @ linux-x86_64 +test.test_os.TestScandir.test_attributes @ linux-x86_64 +test.test_os.TestScandir.test_bad_path_type @ linux-x86_64 +test.test_os.TestScandir.test_broken_symlink @ linux-x86_64 +test.test_os.TestScandir.test_bytes @ linux-x86_64 +test.test_os.TestScandir.test_bytes_like @ linux-x86_64 +test.test_os.TestScandir.test_close @ linux-x86_64 +test.test_os.TestScandir.test_consume_iterator_twice @ linux-x86_64 +test.test_os.TestScandir.test_context_manager @ linux-x86_64 +test.test_os.TestScandir.test_context_manager_close @ linux-x86_64 +test.test_os.TestScandir.test_context_manager_exception @ linux-x86_64 +test.test_os.TestScandir.test_current_directory @ linux-x86_64 +test.test_os.TestScandir.test_empty_path @ linux-x86_64 +test.test_os.TestScandir.test_fd @ linux-x86_64 +test.test_os.TestScandir.test_fspath_protocol @ linux-x86_64 +test.test_os.TestScandir.test_fspath_protocol_bytes @ linux-x86_64 +test.test_os.TestScandir.test_removed_dir @ linux-x86_64 +test.test_os.TestScandir.test_removed_file @ linux-x86_64 +test.test_os.TestScandir.test_repr @ linux-x86_64 +test.test_os.TestScandir.test_uninstantiable @ linux-x86_64 +test.test_os.TestScandir.test_unpickable @ linux-x86_64 +test.test_os.URandomTests.test_urandom_length @ linux-x86_64 +test.test_os.URandomTests.test_urandom_subprocess @ linux-x86_64 +test.test_os.URandomTests.test_urandom_value @ linux-x86_64 +test.test_os.UtimeTests.test_utime @ linux-x86_64 +test.test_os.UtimeTests.test_utime_by_indexed @ linux-x86_64 +test.test_os.UtimeTests.test_utime_by_times @ linux-x86_64 +test.test_os.UtimeTests.test_utime_current @ linux-x86_64 +test.test_os.UtimeTests.test_utime_current_old @ linux-x86_64 +test.test_os.UtimeTests.test_utime_dir_fd @ linux-x86_64 +test.test_os.UtimeTests.test_utime_directory @ linux-x86_64 +test.test_os.UtimeTests.test_utime_fd @ linux-x86_64 +test.test_os.UtimeTests.test_utime_invalid_arguments @ linux-x86_64 +test.test_os.UtimeTests.test_utime_nofollow_symlinks @ linux-x86_64 +test.test_os.WalkTests.test_file_like_path @ linux-x86_64 +test.test_os.WalkTests.test_walk_bad_dir @ linux-x86_64 +test.test_os.WalkTests.test_walk_bottom_up @ linux-x86_64 +test.test_os.WalkTests.test_walk_many_open_files @ linux-x86_64 +test.test_os.WalkTests.test_walk_prune @ linux-x86_64 +test.test_os.WalkTests.test_walk_symlink @ linux-x86_64 +test.test_os.WalkTests.test_walk_topdown @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pathlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pathlib.txt new file mode 100644 index 0000000000..ccf1fdebe2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pathlib.txt @@ -0,0 +1,312 @@ +test.test_pathlib.CompatiblePathTest.test_rtruediv @ linux-x86_64 +test.test_pathlib.CompatiblePathTest.test_truediv @ linux-x86_64 +test.test_pathlib.NTFlavourTest.test_parse_parts @ linux-x86_64 +test.test_pathlib.NTFlavourTest.test_parse_parts_common @ linux-x86_64 +test.test_pathlib.NTFlavourTest.test_splitroot @ linux-x86_64 +test.test_pathlib.PathTest.test_absolute_common @ linux-x86_64 +test.test_pathlib.PathTest.test_chmod @ linux-x86_64 +test.test_pathlib.PathTest.test_chmod_follow_symlinks_true @ linux-x86_64 +test.test_pathlib.PathTest.test_complex_symlinks_absolute @ linux-x86_64 +test.test_pathlib.PathTest.test_complex_symlinks_relative @ linux-x86_64 +test.test_pathlib.PathTest.test_complex_symlinks_relative_dot_dot @ linux-x86_64 +test.test_pathlib.PathTest.test_concrete_class @ linux-x86_64 +test.test_pathlib.PathTest.test_cwd @ linux-x86_64 +test.test_pathlib.PathTest.test_empty_path @ linux-x86_64 +test.test_pathlib.PathTest.test_exists @ linux-x86_64 +test.test_pathlib.PathTest.test_expanduser_common @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_common @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_dotdot @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_empty_pattern @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_long_symlink @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_many_open_files @ linux-x86_64 +test.test_pathlib.PathTest.test_glob_permissions @ linux-x86_64 +test.test_pathlib.PathTest.test_hardlink_to @ linux-x86_64 +test.test_pathlib.PathTest.test_is_block_device_false @ linux-x86_64 +test.test_pathlib.PathTest.test_is_char_device_false @ linux-x86_64 +test.test_pathlib.PathTest.test_is_char_device_true @ linux-x86_64 +test.test_pathlib.PathTest.test_is_dir @ linux-x86_64 +test.test_pathlib.PathTest.test_is_fifo_false @ linux-x86_64 +test.test_pathlib.PathTest.test_is_file @ linux-x86_64 +test.test_pathlib.PathTest.test_is_mount @ linux-x86_64 +test.test_pathlib.PathTest.test_is_socket_false @ linux-x86_64 +test.test_pathlib.PathTest.test_is_socket_true @ linux-x86_64 +test.test_pathlib.PathTest.test_is_symlink @ linux-x86_64 +test.test_pathlib.PathTest.test_iterdir @ linux-x86_64 +test.test_pathlib.PathTest.test_iterdir_nodir @ linux-x86_64 +test.test_pathlib.PathTest.test_iterdir_symlink @ linux-x86_64 +test.test_pathlib.PathTest.test_link_to @ linux-x86_64 +test.test_pathlib.PathTest.test_lstat @ linux-x86_64 +test.test_pathlib.PathTest.test_lstat_nosymlink @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_concurrent_parent_creation @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_exist_ok @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_exist_ok_root @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_exist_ok_with_parent @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_no_parents_file @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_parents @ linux-x86_64 +test.test_pathlib.PathTest.test_mkdir_with_child_file @ linux-x86_64 +test.test_pathlib.PathTest.test_open_common @ linux-x86_64 +test.test_pathlib.PathTest.test_parts_interning @ linux-x86_64 +test.test_pathlib.PathTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PathTest.test_read_write_bytes @ linux-x86_64 +test.test_pathlib.PathTest.test_read_write_text @ linux-x86_64 +test.test_pathlib.PathTest.test_readlink @ linux-x86_64 +test.test_pathlib.PathTest.test_rename @ linux-x86_64 +test.test_pathlib.PathTest.test_replace @ linux-x86_64 +test.test_pathlib.PathTest.test_resolve_common @ linux-x86_64 +test.test_pathlib.PathTest.test_resolve_dot @ linux-x86_64 +test.test_pathlib.PathTest.test_resolve_nonexist_relative_issue38671 @ linux-x86_64 +test.test_pathlib.PathTest.test_rglob_common @ linux-x86_64 +test.test_pathlib.PathTest.test_rglob_symlink_loop @ linux-x86_64 +test.test_pathlib.PathTest.test_rmdir @ linux-x86_64 +test.test_pathlib.PathTest.test_samefile @ linux-x86_64 +test.test_pathlib.PathTest.test_stat @ linux-x86_64 +test.test_pathlib.PathTest.test_stat_no_follow_symlinks @ linux-x86_64 +test.test_pathlib.PathTest.test_stat_no_follow_symlinks_nosymlink @ linux-x86_64 +test.test_pathlib.PathTest.test_symlink_to @ linux-x86_64 +test.test_pathlib.PathTest.test_touch_common @ linux-x86_64 +test.test_pathlib.PathTest.test_touch_nochange @ linux-x86_64 +test.test_pathlib.PathTest.test_unlink @ linux-x86_64 +test.test_pathlib.PathTest.test_unlink_missing_ok @ linux-x86_64 +test.test_pathlib.PathTest.test_unsupported_flavour @ linux-x86_64 +test.test_pathlib.PathTest.test_with @ linux-x86_64 +test.test_pathlib.PathTest.test_write_text_with_newlines @ linux-x86_64 +test.test_pathlib.PosixFlavourTest.test_parse_parts @ linux-x86_64 +test.test_pathlib.PosixFlavourTest.test_parse_parts_common @ linux-x86_64 +test.test_pathlib.PosixFlavourTest.test_splitroot @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_anchor_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_as_bytes_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_as_posix_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_as_uri @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_as_uri_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_as_uri_non_ascii @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_constructor_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_div @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_div_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_drive_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_eq @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_eq_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_equivalences @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_fspath_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_is_absolute @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_is_relative_to_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_is_reserved @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_join @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_join_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_match @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_match_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_name_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_ordering_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_parent_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_parents_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_parts_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_relative_to_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_repr_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_root @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_root_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_stem_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_str_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_str_subclass_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_suffix_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_suffixes_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_with_name_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_with_stem_common @ linux-x86_64 +test.test_pathlib.PosixPathAsPureTest.test_with_suffix_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_absolute @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_absolute_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_chmod @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_chmod_follow_symlinks_true @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_complex_symlinks_absolute @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_complex_symlinks_relative @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_complex_symlinks_relative_dot_dot @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_cwd @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_empty_path @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_exists @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_expanduser_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob_dotdot @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob_long_symlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob_many_open_files @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_glob_permissions @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_hardlink_to @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_block_device_false @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_char_device_false @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_char_device_true @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_dir @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_fifo_false @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_file @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_mount @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_socket_false @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_socket_true @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_is_symlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_iterdir @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_iterdir_nodir @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_iterdir_symlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_link_to @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_lstat @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_lstat_nosymlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_concurrent_parent_creation @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_exist_ok @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_exist_ok_root @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_exist_ok_with_parent @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_no_parents_file @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_parents @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_mkdir_with_child_file @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_open_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_open_mode @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_parts_interning @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_read_write_bytes @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_read_write_text @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_readlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_rename @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_replace @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_resolve_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_resolve_dot @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_resolve_loop @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_resolve_nonexist_relative_issue38671 @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_resolve_root @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_rglob @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_rglob_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_rglob_symlink_loop @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_rmdir @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_samefile @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_stat @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_stat_no_follow_symlinks @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_stat_no_follow_symlinks_nosymlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_symlink_to @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_touch_common @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_touch_mode @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_touch_nochange @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_unlink @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_unlink_missing_ok @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_with @ linux-x86_64 +test.test_pathlib.PosixPathTest.test_write_text_with_newlines @ linux-x86_64 +test.test_pathlib.PurePathTest.test_anchor_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_as_bytes_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_as_posix_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_as_uri_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_concrete_class @ linux-x86_64 +test.test_pathlib.PurePathTest.test_constructor_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_different_flavours_unequal @ linux-x86_64 +test.test_pathlib.PurePathTest.test_different_flavours_unordered @ linux-x86_64 +test.test_pathlib.PurePathTest.test_div_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_drive_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_eq_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_equivalences @ linux-x86_64 +test.test_pathlib.PurePathTest.test_fspath_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_is_relative_to_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_join_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_match_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_name_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_ordering_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_parent_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_parents_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_parts_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_relative_to_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_repr_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_root_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_stem_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_str_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_str_subclass_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_suffix_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_suffixes_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_with_name_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_with_stem_common @ linux-x86_64 +test.test_pathlib.PurePathTest.test_with_suffix_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_anchor_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_as_bytes_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_as_posix_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_as_uri @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_as_uri_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_as_uri_non_ascii @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_constructor_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_div @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_div_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_drive_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_eq @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_eq_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_equivalences @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_fspath_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_is_absolute @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_is_relative_to_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_is_reserved @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_join @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_join_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_match @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_match_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_name_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_ordering_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_parent_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_parents_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_parts_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_relative_to_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_repr_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_root @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_root_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_stem_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_str_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_str_subclass_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_suffix_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_suffixes_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_with_name_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_with_stem_common @ linux-x86_64 +test.test_pathlib.PurePosixPathTest.test_with_suffix_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_anchor @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_anchor_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_as_bytes_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_as_posix_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_as_uri @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_as_uri_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_constructor_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_div @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_div_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_drive @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_drive_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_eq @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_eq_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_equivalences @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_fspath_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_is_absolute @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_is_relative_to @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_is_relative_to_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_is_reserved @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_join @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_join_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_match_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_name @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_name_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_ordering_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parent @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parent_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parents @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parents_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parts @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_parts_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_pickling_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_relative_to @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_relative_to_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_repr_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_root @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_root_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_stem @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_stem_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_str @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_str_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_str_subclass @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_str_subclass_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_suffix @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_suffix_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_suffixes @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_suffixes_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_name @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_name_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_stem @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_stem_common @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_suffix @ linux-x86_64 +test.test_pathlib.PureWindowsPathTest.test_with_suffix_common @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pep646_syntax.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pep646_syntax.txt new file mode 100644 index 0000000000..ea3b529610 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pep646_syntax.txt @@ -0,0 +1 @@ +DocTestCase.test.test_pep646_syntax.__test__.doctests @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickle.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickle.txt new file mode 100644 index 0000000000..0b4c0b405c --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickle.txt @@ -0,0 +1,730 @@ +test.test_pickle.CChainDispatchTableTests.test_class_dispatch_table @ linux-x86_64 +test.test_pickle.CChainDispatchTableTests.test_default_dispatch_table @ linux-x86_64 +test.test_pickle.CChainDispatchTableTests.test_instance_dispatch_table @ linux-x86_64 +test.test_pickle.CDispatchTableTests.test_class_dispatch_table @ linux-x86_64 +test.test_pickle.CDispatchTableTests.test_default_dispatch_table @ linux-x86_64 +test.test_pickle.CDispatchTableTests.test_instance_dispatch_table @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_appends_on_non_lists @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_buffer_callback_error @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_buffers_error @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_builtin_exceptions @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_builtin_functions @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_builtin_types @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_bytearray @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_bytes @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_c_methods @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_compat_pickle @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_complex_newobj @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_complex_newobj_ex @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_dict_chunking @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_dynamic_class @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_ellipsis @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_evil_pickler_mutating_collection @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_float @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_float_format @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_framed_write_sizes_with_delayed_writer @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_framing_large_objects @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_framing_many_objects @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_getinitargs @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_global_ext1 @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_global_ext2 @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_global_ext4 @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_in_band_buffers @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_ints @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_large_pickles @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_list_chunking @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_local_lookup_error @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_long @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_long1 @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_long4 @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_many_puts_and_gets @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_metaclass @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_misc @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_nested_names @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_generic @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_list @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_list_slots @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_not_class @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_overridden_new @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_proxies @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_newobj_tuple @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_notimplemented @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_oob_buffers @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_optional_frames @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_pickle_to_2x @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_picklebuffer_error @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_proto @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_py_methods @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_like @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_inst_state @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_list @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_list_like @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_list_subclass @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_multi @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_nested_names @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_set @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_calls_base @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_ex_called @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_roundtrip_equality @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_set_chunking @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_short_tuples @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_simple_newobj @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_singleton_types @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_singletons @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_structseq @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_unicode @ linux-x86_64 +test.test_pickle.CDumpPickle_LoadPickle.test_unicode_high_plane @ linux-x86_64 +test.test_pickle.CIdPersPicklerTests.test_protocol0_is_ascii_only @ linux-x86_64 +test.test_pickle.CIdPersPicklerTests.test_return_correct_type @ linux-x86_64 +test.test_pickle.CPersPicklerTests.test_persistence @ linux-x86_64 +test.test_pickle.CPickleTests.test_bad_init @ linux-x86_64 +test.test_pickle.CPickleTests.test_callapi @ linux-x86_64 +test.test_pickle.CPickleTests.test_dump_closed_file @ linux-x86_64 +test.test_pickle.CPickleTests.test_dump_load_oob_buffers @ linux-x86_64 +test.test_pickle.CPickleTests.test_dump_text_file @ linux-x86_64 +test.test_pickle.CPickleTests.test_dumps_loads_oob_buffers @ linux-x86_64 +test.test_pickle.CPickleTests.test_highest_protocol @ linux-x86_64 +test.test_pickle.CPickleTests.test_incomplete_input @ linux-x86_64 +test.test_pickle.CPickleTests.test_load_closed_file @ linux-x86_64 +test.test_pickle.CPickleTests.test_load_from_and_dump_to_file @ linux-x86_64 +test.test_pickle.CPickleTests.test_pickler_bad_file @ linux-x86_64 +test.test_pickle.CPickleTests.test_unpickler_bad_file @ linux-x86_64 +test.test_pickle.CPicklerHookTests.test_pickler_hook @ linux-x86_64 +test.test_pickle.CPicklerTests.test_appends_on_non_lists @ linux-x86_64 +test.test_pickle.CPicklerTests.test_buffer_callback_error @ linux-x86_64 +test.test_pickle.CPicklerTests.test_buffers_error @ linux-x86_64 +test.test_pickle.CPicklerTests.test_builtin_exceptions @ linux-x86_64 +test.test_pickle.CPicklerTests.test_builtin_functions @ linux-x86_64 +test.test_pickle.CPicklerTests.test_builtin_types @ linux-x86_64 +test.test_pickle.CPicklerTests.test_bytearray @ linux-x86_64 +test.test_pickle.CPicklerTests.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickle.CPicklerTests.test_bytes @ linux-x86_64 +test.test_pickle.CPicklerTests.test_c_methods @ linux-x86_64 +test.test_pickle.CPicklerTests.test_compat_pickle @ linux-x86_64 +test.test_pickle.CPicklerTests.test_complex_newobj @ linux-x86_64 +test.test_pickle.CPicklerTests.test_complex_newobj_ex @ linux-x86_64 +test.test_pickle.CPicklerTests.test_dict_chunking @ linux-x86_64 +test.test_pickle.CPicklerTests.test_dynamic_class @ linux-x86_64 +test.test_pickle.CPicklerTests.test_ellipsis @ linux-x86_64 +test.test_pickle.CPicklerTests.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickle.CPicklerTests.test_evil_pickler_mutating_collection @ linux-x86_64 +test.test_pickle.CPicklerTests.test_float @ linux-x86_64 +test.test_pickle.CPicklerTests.test_float_format @ linux-x86_64 +test.test_pickle.CPicklerTests.test_framed_write_sizes_with_delayed_writer @ linux-x86_64 +test.test_pickle.CPicklerTests.test_framing_large_objects @ linux-x86_64 +test.test_pickle.CPicklerTests.test_framing_many_objects @ linux-x86_64 +test.test_pickle.CPicklerTests.test_getinitargs @ linux-x86_64 +test.test_pickle.CPicklerTests.test_global_ext1 @ linux-x86_64 +test.test_pickle.CPicklerTests.test_global_ext2 @ linux-x86_64 +test.test_pickle.CPicklerTests.test_global_ext4 @ linux-x86_64 +test.test_pickle.CPicklerTests.test_in_band_buffers @ linux-x86_64 +test.test_pickle.CPicklerTests.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickle.CPicklerTests.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickle.CPicklerTests.test_ints @ linux-x86_64 +test.test_pickle.CPicklerTests.test_large_pickles @ linux-x86_64 +test.test_pickle.CPicklerTests.test_list_chunking @ linux-x86_64 +test.test_pickle.CPicklerTests.test_local_lookup_error @ linux-x86_64 +test.test_pickle.CPicklerTests.test_long @ linux-x86_64 +test.test_pickle.CPicklerTests.test_long1 @ linux-x86_64 +test.test_pickle.CPicklerTests.test_long4 @ linux-x86_64 +test.test_pickle.CPicklerTests.test_many_puts_and_gets @ linux-x86_64 +test.test_pickle.CPicklerTests.test_metaclass @ linux-x86_64 +test.test_pickle.CPicklerTests.test_misc @ linux-x86_64 +test.test_pickle.CPicklerTests.test_nested_names @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_generic @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_list @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_list_slots @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_not_class @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_overridden_new @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_proxies @ linux-x86_64 +test.test_pickle.CPicklerTests.test_newobj_tuple @ linux-x86_64 +test.test_pickle.CPicklerTests.test_notimplemented @ linux-x86_64 +test.test_pickle.CPicklerTests.test_oob_buffers @ linux-x86_64 +test.test_pickle.CPicklerTests.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickle.CPicklerTests.test_optional_frames @ linux-x86_64 +test.test_pickle.CPicklerTests.test_pickle_to_2x @ linux-x86_64 +test.test_pickle.CPicklerTests.test_picklebuffer_error @ linux-x86_64 +test.test_pickle.CPicklerTests.test_proto @ linux-x86_64 +test.test_pickle.CPicklerTests.test_py_methods @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_like @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_inst_state @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_list @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_list_like @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_list_subclass @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_multi @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_nested_names @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_set @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickle.CPicklerTests.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_calls_base @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_ex_called @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickle.CPicklerTests.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickle.CPicklerTests.test_roundtrip_equality @ linux-x86_64 +test.test_pickle.CPicklerTests.test_set_chunking @ linux-x86_64 +test.test_pickle.CPicklerTests.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickle.CPicklerTests.test_short_tuples @ linux-x86_64 +test.test_pickle.CPicklerTests.test_simple_newobj @ linux-x86_64 +test.test_pickle.CPicklerTests.test_singleton_types @ linux-x86_64 +test.test_pickle.CPicklerTests.test_singletons @ linux-x86_64 +test.test_pickle.CPicklerTests.test_structseq @ linux-x86_64 +test.test_pickle.CPicklerTests.test_unicode @ linux-x86_64 +test.test_pickle.CPicklerTests.test_unicode_high_plane @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_clear_pickler_memo @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_issue18339 @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_multiple_unpicklings_minimal @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_multiple_unpicklings_seekable @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_multiple_unpicklings_unseekable @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_priming_pickler_memo @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_priming_unpickler_memo @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_reusing_unpickler_objects @ linux-x86_64 +test.test_pickle.CPicklerUnpicklerObjectTests.test_unpickling_buffering_readline @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bad_mark @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bad_newobj @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bad_newobj_ex @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bad_reduce @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bad_stack @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_badly_escaped_string @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_badly_quoted_string @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_binbytes @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_binbytes8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_binget @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_binunicode8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_bytearray8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_compat_unpickle @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_constants @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_correctly_quoted_string @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_dup @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_empty_bytestring @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_frame_readline @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_get @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_large_32b_binbytes8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_large_32b_binunicode8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_large_32b_bytearray8 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_classic_instance @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_from_data0 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_from_data1 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_from_data2 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_from_data3 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_from_data4 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_long_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_load_python2_unicode_as_str @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_long_binget @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_maxint64 @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_misc_get @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_negative_32b_binbytes @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_negative_32b_binput @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_negative_32b_binunicode @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_negative_put @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_short_binbytes @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_short_binunicode @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_truncated_data @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_unpickle_from_2x @ linux-x86_64 +test.test_pickle.CUnpicklerTests.test_unpickle_module_race @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_exceptions @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_import @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_import_mapping @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_multiprocessing_exceptions @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_name_mapping @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_reverse_import_mapping @ linux-x86_64 +test.test_pickle.CompatPickleTests.test_reverse_name_mapping @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_appends_on_non_lists @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_buffer_callback_error @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_buffers_error @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_builtin_exceptions @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_builtin_functions @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_builtin_types @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_bytearray @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_bytes @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_c_methods @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_compat_pickle @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_complex_newobj @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_complex_newobj_ex @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_dict_chunking @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_dynamic_class @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_ellipsis @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_evil_pickler_mutating_collection @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_float @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_float_format @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_framed_write_sizes_with_delayed_writer @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_framing_large_objects @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_framing_many_objects @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_getinitargs @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_global_ext1 @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_global_ext2 @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_global_ext4 @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_in_band_buffers @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_ints @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_large_pickles @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_list_chunking @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_local_lookup_error @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_long @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_long1 @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_long4 @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_many_puts_and_gets @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_metaclass @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_misc @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_nested_names @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_generic @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_list @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_list_slots @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_not_class @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_overridden_new @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_proxies @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_newobj_tuple @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_notimplemented @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_oob_buffers @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_optional_frames @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_pickle_to_2x @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_picklebuffer_error @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_proto @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_py_methods @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_like @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_inst_state @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_list @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_list_like @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_list_subclass @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_multi @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_nested_names @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_set @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_calls_base @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_ex_called @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_roundtrip_equality @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_set_chunking @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_short_tuples @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_simple_newobj @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_singleton_types @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_singletons @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_structseq @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_unicode @ linux-x86_64 +test.test_pickle.DumpPickle_CLoadPickle.test_unicode_high_plane @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_appends_on_non_lists @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bad_mark @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bad_newobj @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bad_newobj_ex @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bad_reduce @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bad_stack @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_badly_escaped_string @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_badly_quoted_string @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_binbytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_binbytes8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_binget @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_binunicode8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_buffer_callback_error @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_buffers_error @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_builtin_exceptions @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_builtin_functions @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_builtin_types @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bytearray @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bytearray8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_bytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_c_methods @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_compat_pickle @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_compat_unpickle @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_complex_newobj @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_complex_newobj_ex @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_constants @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_correctly_quoted_string @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_dict_chunking @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_dup @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_dynamic_class @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_ellipsis @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_empty_bytestring @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_float @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_float_format @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_frame_readline @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_framing_large_objects @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_framing_many_objects @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_get @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_getinitargs @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_global_ext1 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_global_ext2 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_global_ext4 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_in_band_buffers @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_ints @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_large_32b_binbytes8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_large_32b_binunicode8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_large_32b_bytearray8 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_large_pickles @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_list_chunking @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_classic_instance @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_from_data0 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_from_data1 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_from_data2 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_from_data3 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_from_data4 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_long_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_load_python2_unicode_as_str @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_local_lookup_error @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_long @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_long1 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_long4 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_long_binget @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_many_puts_and_gets @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_maxint64 @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_metaclass @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_misc @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_misc_get @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_negative_32b_binbytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_negative_32b_binput @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_negative_32b_binunicode @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_negative_put @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_nested_names @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_generic @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_list @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_list_slots @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_not_class @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_overridden_new @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_proxies @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_newobj_tuple @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_notimplemented @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_oob_buffers @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_optional_frames @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_pickle_to_2x @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_picklebuffer_error @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_proto @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_py_methods @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_like @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_inst_state @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_list @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_list_like @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_list_subclass @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_multi @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_nested_names @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_set @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_calls_base @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_ex_called @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_roundtrip_equality @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_set_chunking @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_short_binbytes @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_short_binunicode @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_short_tuples @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_simple_newobj @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_singleton_types @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_singletons @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_structseq @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_truncated_data @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_unicode @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_unicode_high_plane @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_unpickle_from_2x @ linux-x86_64 +test.test_pickle.InMemoryPickleTests.test_unpickle_module_race @ linux-x86_64 +test.test_pickle.PyChainDispatchTableTests.test_class_dispatch_table @ linux-x86_64 +test.test_pickle.PyChainDispatchTableTests.test_default_dispatch_table @ linux-x86_64 +test.test_pickle.PyChainDispatchTableTests.test_instance_dispatch_table @ linux-x86_64 +test.test_pickle.PyDispatchTableTests.test_class_dispatch_table @ linux-x86_64 +test.test_pickle.PyDispatchTableTests.test_default_dispatch_table @ linux-x86_64 +test.test_pickle.PyDispatchTableTests.test_instance_dispatch_table @ linux-x86_64 +test.test_pickle.PyIdPersPicklerTests.test_protocol0_is_ascii_only @ linux-x86_64 +test.test_pickle.PyIdPersPicklerTests.test_return_correct_type @ linux-x86_64 +test.test_pickle.PyPersPicklerTests.test_persistence @ linux-x86_64 +test.test_pickle.PyPickleTests.test_bad_init @ linux-x86_64 +test.test_pickle.PyPickleTests.test_callapi @ linux-x86_64 +test.test_pickle.PyPickleTests.test_dump_closed_file @ linux-x86_64 +test.test_pickle.PyPickleTests.test_dump_load_oob_buffers @ linux-x86_64 +test.test_pickle.PyPickleTests.test_dump_text_file @ linux-x86_64 +test.test_pickle.PyPickleTests.test_dumps_loads_oob_buffers @ linux-x86_64 +test.test_pickle.PyPickleTests.test_highest_protocol @ linux-x86_64 +test.test_pickle.PyPickleTests.test_incomplete_input @ linux-x86_64 +test.test_pickle.PyPickleTests.test_load_closed_file @ linux-x86_64 +test.test_pickle.PyPickleTests.test_load_from_and_dump_to_file @ linux-x86_64 +test.test_pickle.PyPickleTests.test_pickler_bad_file @ linux-x86_64 +test.test_pickle.PyPickleTests.test_unpickler_bad_file @ linux-x86_64 +test.test_pickle.PyPicklerHookTests.test_pickler_hook @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_appends_on_non_lists @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_buffer_callback_error @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_buffers_error @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_builtin_exceptions @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_builtin_functions @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_builtin_types @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_bytearray @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_bytes @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_c_methods @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_compat_pickle @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_complex_newobj @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_complex_newobj_ex @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_dict_chunking @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_dynamic_class @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_ellipsis @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_evil_pickler_mutating_collection @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_float @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_float_format @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_framed_write_sizes_with_delayed_writer @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_framing_large_objects @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_framing_many_objects @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_getinitargs @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_global_ext1 @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_global_ext2 @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_global_ext4 @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_in_band_buffers @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_ints @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_large_pickles @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_list_chunking @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_local_lookup_error @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_long @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_long1 @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_long4 @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_many_puts_and_gets @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_metaclass @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_misc @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_nested_names @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_generic @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_list @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_list_slots @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_not_class @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_overridden_new @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_proxies @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_newobj_tuple @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_notimplemented @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_oob_buffers @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_optional_frames @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_pickle_to_2x @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_picklebuffer_error @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_proto @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_py_methods @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_like @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_inst_state @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_list @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_list_like @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_list_subclass @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_multi @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_nested_names @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_set @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_calls_base @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_ex_called @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_roundtrip_equality @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_set_chunking @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_short_tuples @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_simple_newobj @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_singleton_types @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_singletons @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_structseq @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_unicode @ linux-x86_64 +test.test_pickle.PyPicklerTests.test_unicode_high_plane @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_clear_pickler_memo @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_multiple_unpicklings_minimal @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_multiple_unpicklings_seekable @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_multiple_unpicklings_unseekable @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_priming_pickler_memo @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_priming_unpickler_memo @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_reusing_unpickler_objects @ linux-x86_64 +test.test_pickle.PyPicklerUnpicklerObjectTests.test_unpickling_buffering_readline @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bad_mark @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bad_newobj @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bad_newobj_ex @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bad_reduce @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bad_stack @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_badly_escaped_string @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_badly_quoted_string @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_binbytes @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_binbytes8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_binget @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_binunicode8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_bytearray8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_compat_unpickle @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_constants @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_correctly_quoted_string @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_dup @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_empty_bytestring @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_frame_readline @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_get @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_large_32b_binbytes8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_large_32b_binunicode8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_large_32b_bytearray8 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_classic_instance @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_from_data0 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_from_data1 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_from_data2 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_from_data3 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_from_data4 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_long_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_python2_str_as_bytes @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_load_python2_unicode_as_str @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_long_binget @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_maxint64 @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_misc_get @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_negative_32b_binbytes @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_negative_32b_binput @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_negative_32b_binunicode @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_negative_put @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_short_binbytes @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_short_binunicode @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_truncated_data @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_unpickle_from_2x @ linux-x86_64 +test.test_pickle.PyUnpicklerTests.test_unpickle_module_race @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_picklebuffer.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_picklebuffer.txt new file mode 100644 index 0000000000..138f7838a6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_picklebuffer.txt @@ -0,0 +1,8 @@ +test.test_picklebuffer.PickleBufferTest.test_basics @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_constructor_failure @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_ndarray_2d @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_raw @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_raw_ndarray @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_raw_non_contiguous @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_raw_released @ linux-x86_64 +test.test_picklebuffer.PickleBufferTest.test_release @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickletools.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickletools.txt new file mode 100644 index 0000000000..0ee57402fc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pickletools.txt @@ -0,0 +1,132 @@ +DocTestCase.pickletools.__test__.disassembler_memo_test @ linux-x86_64 +DocTestCase.pickletools.__test__.disassembler_test @ linux-x86_64 +DocTestCase.pickletools.read_bytearray8 @ linux-x86_64 +DocTestCase.pickletools.read_bytes1 @ linux-x86_64 +DocTestCase.pickletools.read_bytes4 @ linux-x86_64 +DocTestCase.pickletools.read_bytes8 @ linux-x86_64 +DocTestCase.pickletools.read_decimalnl_long @ linux-x86_64 +DocTestCase.pickletools.read_decimalnl_short @ linux-x86_64 +DocTestCase.pickletools.read_float8 @ linux-x86_64 +DocTestCase.pickletools.read_floatnl @ linux-x86_64 +DocTestCase.pickletools.read_int4 @ linux-x86_64 +DocTestCase.pickletools.read_long1 @ linux-x86_64 +DocTestCase.pickletools.read_long4 @ linux-x86_64 +DocTestCase.pickletools.read_string1 @ linux-x86_64 +DocTestCase.pickletools.read_string4 @ linux-x86_64 +DocTestCase.pickletools.read_stringnl @ linux-x86_64 +DocTestCase.pickletools.read_stringnl_noescape_pair @ linux-x86_64 +DocTestCase.pickletools.read_uint1 @ linux-x86_64 +DocTestCase.pickletools.read_uint2 @ linux-x86_64 +DocTestCase.pickletools.read_uint4 @ linux-x86_64 +DocTestCase.pickletools.read_uint8 @ linux-x86_64 +DocTestCase.pickletools.read_unicodestring1 @ linux-x86_64 +DocTestCase.pickletools.read_unicodestring4 @ linux-x86_64 +DocTestCase.pickletools.read_unicodestring8 @ linux-x86_64 +DocTestCase.pickletools.read_unicodestringnl @ linux-x86_64 +test.test_pickletools.MiscTestCase.test__all__ @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_appends_on_non_lists @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_buffer_callback_error @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_buffers_error @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_builtin_exceptions @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_builtin_functions @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_builtin_types @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_bytearray @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_bytearray_memoization_bug @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_bytes @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_c_methods @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_compat_pickle @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_complex_newobj @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_complex_newobj_ex @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_dict_chunking @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_dynamic_class @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_ellipsis @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_evil_class_mutating_dict @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_float @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_float_format @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_framing_large_objects @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_framing_many_objects @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_getinitargs @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_global_ext1 @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_global_ext2 @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_global_ext4 @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_in_band_buffers @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_inband_accept_default_buffers_argument @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_int_pickling_efficiency @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_ints @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_large_pickles @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_list_chunking @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_local_lookup_error @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_long @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_long1 @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_long4 @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_many_puts_and_gets @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_metaclass @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_misc @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_nested_names @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_generic @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_list @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_list_slots @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_not_class @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_overridden_new @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_proxies @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_newobj_tuple @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_notimplemented @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_oob_buffers @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_oob_buffers_writable_to_readonly @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_optimize_binput_and_memoize @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_optimize_long_binget @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_optional_frames @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_picklebuffer_error @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_proto @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_py_methods @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_like @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_like_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_subclass @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_subclass_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_dict_subclass_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_frozenset_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_frozenset_subclass_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_inst_state @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_list @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_list_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_list_like @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_list_subclass @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_list_subclass_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_multi @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_nested_names @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_set @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_set_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_set_subclass_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict_like @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict_like_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict_subclass @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_dict_subclass_key @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_inst_state @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_list @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_list_like @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_and_list_subclass @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_recursive_tuple_subclass_and_inst @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_bad_iterator @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_calls_base @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_ex_called @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_ex_calls_base @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_ex_overrides_reduce @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_reduce_overrides_default_reduce_ex @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_roundtrip_equality @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_set_chunking @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_setitems_on_non_dicts @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_short_tuples @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_simple_newobj @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_singleton_types @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_singletons @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_structseq @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_unicode @ linux-x86_64 +test.test_pickletools.OptimizedPickleTests.test_unicode_high_plane @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pipes.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pipes.txt new file mode 100644 index 0000000000..6638e169e7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pipes.txt @@ -0,0 +1,14 @@ +test.test_pipes.SimplePipeTests.testBadAppendOptions @ linux-x86_64 +test.test_pipes.SimplePipeTests.testBadOpenMode @ linux-x86_64 +test.test_pipes.SimplePipeTests.testBadPrependOptions @ linux-x86_64 +test.test_pipes.SimplePipeTests.testClone @ linux-x86_64 +test.test_pipes.SimplePipeTests.testEmptyPipeline1 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testEmptyPipeline2 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testEmptyPipeline3 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testReadOpenSink @ linux-x86_64 +test.test_pipes.SimplePipeTests.testRepr @ linux-x86_64 +test.test_pipes.SimplePipeTests.testSetDebug @ linux-x86_64 +test.test_pipes.SimplePipeTests.testSimplePipe1 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testSimplePipe2 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testSimplePipe3 @ linux-x86_64 +test.test_pipes.SimplePipeTests.testWriteOpenSource @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkg.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkg.txt new file mode 100644 index 0000000000..4c1c41b630 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkg.txt @@ -0,0 +1,8 @@ +test.test_pkg.TestPkg.test_1 @ linux-x86_64 +test.test_pkg.TestPkg.test_2 @ linux-x86_64 +test.test_pkg.TestPkg.test_3 @ linux-x86_64 +test.test_pkg.TestPkg.test_4 @ linux-x86_64 +test.test_pkg.TestPkg.test_5 @ linux-x86_64 +test.test_pkg.TestPkg.test_6 @ linux-x86_64 +test.test_pkg.TestPkg.test_7 @ linux-x86_64 +test.test_pkg.TestPkg.test_8 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkgutil.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkgutil.txt new file mode 100644 index 0000000000..fc27e3d142 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pkgutil.txt @@ -0,0 +1,26 @@ +test.test_pkgutil.ExtendPathTests.test_iter_importers @ linux-x86_64 +test.test_pkgutil.ExtendPathTests.test_mixed_namespace @ linux-x86_64 +test.test_pkgutil.ExtendPathTests.test_simple @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_find_loader_avoids_emulation @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_find_loader_missing_module @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_importer_avoids_emulation @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_loader_None_in_sys_modules @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_loader_avoids_emulation @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_loader_handles_missing_loader_attribute @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_loader_handles_missing_spec_attribute @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_get_loader_handles_spec_attribute_none @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_importer_deprecated @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_issue44061 @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_iter_importers_avoids_emulation @ linux-x86_64 +test.test_pkgutil.ImportlibMigrationTests.test_loader_deprecated @ linux-x86_64 +test.test_pkgutil.NestedNamespacePackageTest.test_nested @ linux-x86_64 +test.test_pkgutil.PkgutilPEP302Tests.test_alreadyloaded @ linux-x86_64 +test.test_pkgutil.PkgutilPEP302Tests.test_getdata_pep302 @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_getdata_filesys @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_getdata_zipfile @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_issue44061_iter_modules @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_name_resolution @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_unreadable_dir_on_syspath @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_walk_packages_raises_on_string_or_bytes_input @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_walkpackages_filesys @ linux-x86_64 +test.test_pkgutil.PkgutilTests.test_walkpackages_zipfile @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_platform.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_platform.txt new file mode 100644 index 0000000000..d4ee9d3799 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_platform.txt @@ -0,0 +1,26 @@ +test.test_platform.PlatformTest.test_architecture @ linux-x86_64 +test.test_platform.PlatformTest.test_freedesktop_os_release @ linux-x86_64 +test.test_platform.PlatformTest.test_java_ver @ linux-x86_64 +test.test_platform.PlatformTest.test_libc_ver @ linux-x86_64 +test.test_platform.PlatformTest.test_mac_ver @ linux-x86_64 +test.test_platform.PlatformTest.test_machine @ linux-x86_64 +test.test_platform.PlatformTest.test_macos @ linux-x86_64 +test.test_platform.PlatformTest.test_node @ linux-x86_64 +test.test_platform.PlatformTest.test_parse_os_release @ linux-x86_64 +test.test_platform.PlatformTest.test_platform @ linux-x86_64 +test.test_platform.PlatformTest.test_processor @ linux-x86_64 +test.test_platform.PlatformTest.test_release @ linux-x86_64 +test.test_platform.PlatformTest.test_sys_version @ linux-x86_64 +test.test_platform.PlatformTest.test_system @ linux-x86_64 +test.test_platform.PlatformTest.test_system_alias @ linux-x86_64 +test.test_platform.PlatformTest.test_uname @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_asdict @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_cast_to_tuple @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_copy @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_fields @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_pickle @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_processor @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_replace @ linux-x86_64 +test.test_platform.PlatformTest.test_uname_slices @ linux-x86_64 +test.test_platform.PlatformTest.test_version @ linux-x86_64 +test.test_platform.PlatformTest.test_win32_ver @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_plistlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_plistlib.txt new file mode 100644 index 0000000000..566246ccb4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_plistlib.txt @@ -0,0 +1,55 @@ +test.test_plistlib.MiscTestCase.test__all__ @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_cycles @ linux-x86_64 +!test.test_plistlib.TestBinaryPlistlib.test_deep_nesting @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_dump_duplicates @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_identity @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_invalid_binary @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_large_timestamp @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_load_int @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_load_singletons @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_nonstandard_refs_size @ linux-x86_64 +test.test_plistlib.TestBinaryPlistlib.test_unsupported @ linux-x86_64 +test.test_plistlib.TestKeyedArchive.test_keyed_archive_data @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_appleformatting @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_appleformattingfromliteral @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_bytearray @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_bytes @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_bytesio @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_controlcharacters @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_create @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_dict_members @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_dump_invalid_format @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_indentation_array @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_indentation_dict @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_indentation_dict_mix @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_int @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_integer_notations @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invalid_type @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invalid_uid @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invalidarray @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invaliddict @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invalidinteger @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_invalidreal @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_io @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_keys_no_string @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_keysort @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_keysort_bytesio @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_list_members @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_load_invalid_file @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_lone_surrogates @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_modified_uid_huge @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_modified_uid_negative @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_non_bmp_characters @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_nondictroot @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_skipkeys @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_tuple_members @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_copy @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_data @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_eq @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_hash @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_index @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_pickle @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_uid_repr @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_xml_encodings @ linux-x86_64 +test.test_plistlib.TestPlistlib.test_xml_plist_with_entity_decl @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_popen.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_popen.txt new file mode 100644 index 0000000000..fde6cabdb8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_popen.txt @@ -0,0 +1,5 @@ +test.test_popen.PopenTest.test_contextmanager @ linux-x86_64 +test.test_popen.PopenTest.test_iterating @ linux-x86_64 +test.test_popen.PopenTest.test_keywords @ linux-x86_64 +test.test_popen.PopenTest.test_popen @ linux-x86_64 +test.test_popen.PopenTest.test_return_code @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_poplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_poplib.txt new file mode 100644 index 0000000000..732806d516 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_poplib.txt @@ -0,0 +1,70 @@ +test.test_poplib.TestPOP3Class.test_apop_REDOS @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_apop_normal @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_capa @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_dele @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_exceptions @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_getwelcome @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_list @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_noop @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_pass_ @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_quit @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_retr @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_rpop @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_stat @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_stls @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_stls_capa @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_too_long_lines @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_top @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_uidl @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_user @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_utf8 @ linux-x86_64 +test.test_poplib.TestPOP3Class.test_utf8_raises_if_unsupported @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test__all__ @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_apop_REDOS @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_apop_normal @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_capa @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_context @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_dele @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_exceptions @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_getwelcome @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_list @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_noop @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_pass_ @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_quit @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_retr @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_rpop @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_stat @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_stls @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_stls_capa @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_stls_context @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_too_long_lines @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_top @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_uidl @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_user @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_utf8 @ linux-x86_64 +test.test_poplib.TestPOP3_SSLClass.test_utf8_raises_if_unsupported @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_apop_REDOS @ linux-x86_64 +!test.test_poplib.TestPOP3_TLSClass.test_apop_normal @ linux-x86_64 +!test.test_poplib.TestPOP3_TLSClass.test_capa @ linux-x86_64 +!test.test_poplib.TestPOP3_TLSClass.test_dele @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_exceptions @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_getwelcome @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_list @ linux-x86_64 +!test.test_poplib.TestPOP3_TLSClass.test_noop @ linux-x86_64 +!test.test_poplib.TestPOP3_TLSClass.test_pass_ @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_quit @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_retr @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_rpop @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_stat @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_stls @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_stls_capa @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_stls_context @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_too_long_lines @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_top @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_uidl @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_user @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_utf8 @ linux-x86_64 +test.test_poplib.TestPOP3_TLSClass.test_utf8_raises_if_unsupported @ linux-x86_64 +test.test_poplib.TestTimeouts.testTimeoutDefault @ linux-x86_64 +test.test_poplib.TestTimeouts.testTimeoutNone @ linux-x86_64 +test.test_poplib.TestTimeouts.testTimeoutValue @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_positional_only_arg.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_positional_only_arg.txt new file mode 100644 index 0000000000..842ab43eaa --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_positional_only_arg.txt @@ -0,0 +1,26 @@ +test.test_positional_only_arg.PositionalOnlyTestCase.test_annotations_in_closures @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_change_default_pos_only @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_closures @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_generator @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_invalid_syntax_errors @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_invalid_syntax_errors_async @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_invalid_syntax_lambda @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_lambdas @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_mangling @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_module_function @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_no_standard_args_usage @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_optional_positional_only_args @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_pos_only_call_via_unpacking @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_pos_only_definition @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_positional_only_and_arg_invalid_calls @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_positional_only_and_kwonlyargs_invalid_calls @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_positional_only_and_optional_arg_invalid_calls @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_positional_only_invalid_calls @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_positional_only_with_optional_invalid_calls @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_posonly_methods @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_same_keyword_as_positional_with_kwargs @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_serialization @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_super @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_syntax_for_many_positional_only @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_too_many_arguments @ linux-x86_64 +test.test_positional_only_arg.PositionalOnlyTestCase.test_use_positional_as_keyword @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posix.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posix.txt new file mode 100644 index 0000000000..9c175e9b1e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posix.txt @@ -0,0 +1,45 @@ +test.test_posix.PosixTester.testNoArgFunctions @ linux-x86_64 +test.test_posix.PosixTester.test_access @ linux-x86_64 +test.test_posix.PosixTester.test_chdir @ linux-x86_64 +test.test_posix.PosixTester.test_chown @ linux-x86_64 +test.test_posix.PosixTester.test_dup @ linux-x86_64 +test.test_posix.PosixTester.test_dup2 @ linux-x86_64 +test.test_posix.PosixTester.test_environ @ linux-x86_64 +test.test_posix.PosixTester.test_fchown @ linux-x86_64 +test.test_posix.PosixTester.test_fs_holes @ linux-x86_64 +test.test_posix.PosixTester.test_fstat @ linux-x86_64 +test.test_posix.PosixTester.test_fstatvfs @ linux-x86_64 +test.test_posix.PosixTester.test_ftruncate @ linux-x86_64 +test.test_posix.PosixTester.test_getcwd_long_pathnames @ linux-x86_64 +test.test_posix.PosixTester.test_getgroups @ linux-x86_64 +test.test_posix.PosixTester.test_lchown @ linux-x86_64 +test.test_posix.PosixTester.test_listdir @ linux-x86_64 +test.test_posix.PosixTester.test_listdir_bytes @ linux-x86_64 +test.test_posix.PosixTester.test_listdir_bytes_like @ linux-x86_64 +test.test_posix.PosixTester.test_listdir_default @ linux-x86_64 +test.test_posix.PosixTester.test_listdir_fd @ linux-x86_64 +test.test_posix.PosixTester.test_oscloexec @ linux-x86_64 +test.test_posix.PosixTester.test_path_error2 @ linux-x86_64 +test.test_posix.PosixTester.test_path_with_null_byte @ linux-x86_64 +test.test_posix.PosixTester.test_path_with_null_character @ linux-x86_64 +test.test_posix.PosixTester.test_pipe @ linux-x86_64 +test.test_posix.PosixTester.test_putenv @ linux-x86_64 +test.test_posix.PosixTester.test_rtld_constants @ linux-x86_64 +test.test_posix.PosixTester.test_stat @ linux-x86_64 +test.test_posix.PosixTester.test_statvfs @ linux-x86_64 +test.test_posix.PosixTester.test_strerror @ linux-x86_64 +test.test_posix.PosixTester.test_truncate @ linux-x86_64 +test.test_posix.PosixTester.test_umask @ linux-x86_64 +test.test_posix.PosixTester.test_utime @ linux-x86_64 +test.test_posix.PosixTester.test_utime_nofollow_symlinks @ linux-x86_64 +test.test_posix.PosixTester.test_utime_with_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_access_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_chmod_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_mkdir_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_open_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_readlink_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_rename_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_stat_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_symlink_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_unlink_dir_fd @ linux-x86_64 +test.test_posix.TestPosixDirFd.test_utime_dir_fd @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posixpath.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posixpath.txt new file mode 100644 index 0000000000..5b60611c71 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_posixpath.txt @@ -0,0 +1,77 @@ +test.test_posixpath.PathLikeTests.test_path_abspath @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_basename @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_commonpath @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_dirname @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_expanduser @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_expandvars @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_isabs @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_islink @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_ismount @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_join @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_lexists @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_normcase @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_normpath @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_realpath @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_relpath @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_split @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_splitdrive @ linux-x86_64 +test.test_posixpath.PathLikeTests.test_path_splitext @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_abspath @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_abspath_issue3426 @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_commonprefix @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_exists @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_exists_fd @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_expandvars @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_expandvars_nonascii @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_filetime @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_getsize @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_import @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_isdir @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_isfile @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_join_errors @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_no_argument @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_nonascii_abspath @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_normcase @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_normpath_issue106242 @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_normpath_issue5827 @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_realpath @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_relpath_errors @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samefile @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samefile_on_link @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samefile_on_symlink @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_sameopenfile @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samestat @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samestat_on_link @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_samestat_on_symlink @ linux-x86_64 +test.test_posixpath.PosixCommonTest.test_splitdrive @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_basename @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_commonpath @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_dirname @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_expanduser @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_expanduser_home_envvar @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_expanduser_pwd @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_isabs @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_islink @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_ismount @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_ismount_different_device @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_ismount_directory_not_readable @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_ismount_non_existent @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_ismount_symlinks @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_join @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_normpath @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_basic @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_curdir @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_deep_recursion @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_pardir @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_relative @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_repeated_indirect_symlinks @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_resolve_before_normalizing @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_resolve_first @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_resolve_parents @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_strict @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_symlink_loops @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_realpath_symlink_loops_strict @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_relpath @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_relpath_bytes @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_split @ linux-x86_64 +test.test_posixpath.PosixPathTest.test_splitext @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pow.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pow.txt new file mode 100644 index 0000000000..e94e243600 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pow.txt @@ -0,0 +1,7 @@ +test.test_pow.PowTest.test_big_exp @ linux-x86_64 +test.test_pow.PowTest.test_bug643260 @ linux-x86_64 +test.test_pow.PowTest.test_bug705231 @ linux-x86_64 +test.test_pow.PowTest.test_negative_exponent @ linux-x86_64 +test.test_pow.PowTest.test_other @ linux-x86_64 +test.test_pow.PowTest.test_powfloat @ linux-x86_64 +test.test_pow.PowTest.test_powint @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pprint.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pprint.txt new file mode 100644 index 0000000000..aa094ccf63 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pprint.txt @@ -0,0 +1,43 @@ +test.test_pprint.QueryTestCase.test_basic @ linux-x86_64 +test.test_pprint.QueryTestCase.test_basic_line_wrap @ linux-x86_64 +test.test_pprint.QueryTestCase.test_bytearray_wrap @ linux-x86_64 +test.test_pprint.QueryTestCase.test_bytes_wrap @ linux-x86_64 +test.test_pprint.QueryTestCase.test_chainmap @ linux-x86_64 +test.test_pprint.QueryTestCase.test_compact @ linux-x86_64 +test.test_pprint.QueryTestCase.test_compact_width @ linux-x86_64 +test.test_pprint.QueryTestCase.test_container_repr_override_called @ linux-x86_64 +test.test_pprint.QueryTestCase.test_counter @ linux-x86_64 +test.test_pprint.QueryTestCase.test_cyclic_dataclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_dataclass_no_repr @ linux-x86_64 +test.test_pprint.QueryTestCase.test_dataclass_with_repr @ linux-x86_64 +test.test_pprint.QueryTestCase.test_default_dict @ linux-x86_64 +test.test_pprint.QueryTestCase.test_depth @ linux-x86_64 +test.test_pprint.QueryTestCase.test_deque @ linux-x86_64 +test.test_pprint.QueryTestCase.test_empty_dataclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_empty_simple_namespace @ linux-x86_64 +test.test_pprint.QueryTestCase.test_init @ linux-x86_64 +test.test_pprint.QueryTestCase.test_integer @ linux-x86_64 +test.test_pprint.QueryTestCase.test_knotted @ linux-x86_64 +test.test_pprint.QueryTestCase.test_larger_dataclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_mapping_proxy @ linux-x86_64 +test.test_pprint.QueryTestCase.test_nested_indentations @ linux-x86_64 +test.test_pprint.QueryTestCase.test_ordered_dict @ linux-x86_64 +test.test_pprint.QueryTestCase.test_recursive_dataclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_same_as_repr @ linux-x86_64 +test.test_pprint.QueryTestCase.test_set_reprs @ linux-x86_64 +test.test_pprint.QueryTestCase.test_simple_namespace @ linux-x86_64 +test.test_pprint.QueryTestCase.test_simple_namespace_subclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_small_dataclass @ linux-x86_64 +test.test_pprint.QueryTestCase.test_small_simple_namespace @ linux-x86_64 +test.test_pprint.QueryTestCase.test_sort_dict @ linux-x86_64 +test.test_pprint.QueryTestCase.test_sort_orderable_and_unorderable_values @ linux-x86_64 +test.test_pprint.QueryTestCase.test_sort_unorderable_values @ linux-x86_64 +test.test_pprint.QueryTestCase.test_sorted_dict @ linux-x86_64 +test.test_pprint.QueryTestCase.test_stdout_is_None @ linux-x86_64 +test.test_pprint.QueryTestCase.test_str_wrap @ linux-x86_64 +test.test_pprint.QueryTestCase.test_subclassing @ linux-x86_64 +test.test_pprint.QueryTestCase.test_unreadable @ linux-x86_64 +test.test_pprint.QueryTestCase.test_user_dict @ linux-x86_64 +test.test_pprint.QueryTestCase.test_user_list @ linux-x86_64 +test.test_pprint.QueryTestCase.test_user_string @ linux-x86_64 +test.test_pprint.QueryTestCase.test_width @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_print.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_print.txt new file mode 100644 index 0000000000..2b1cdf08a9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_print.txt @@ -0,0 +1,9 @@ +test.test_print.TestPrint.test_print @ linux-x86_64 +test.test_print.TestPrint.test_print_flush @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_normal_string @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_string_in_loop_on_same_line @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_string_with_excessive_whitespace @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_string_with_leading_whitespace @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_string_with_semicolon @ linux-x86_64 +test.test_print.TestPy2MigrationHint.test_string_with_soft_space @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_profile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_profile.txt new file mode 100644 index 0000000000..8e9d7009ce --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_profile.txt @@ -0,0 +1,4 @@ +test.test_profile.ProfileTest.test_output_file_when_changing_directory @ linux-x86_64 +test.test_profile.ProfileTest.test_run @ linux-x86_64 +test.test_profile.ProfileTest.test_run_profile_as_module @ linux-x86_64 +test.test_profile.ProfileTest.test_runctx @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_property.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_property.txt new file mode 100644 index 0000000000..3ac5d5740a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_property.txt @@ -0,0 +1,21 @@ +test.test_property.PropertySubclassTests.test_docstring_copy @ linux-x86_64 +test.test_property.PropertySubclassTests.test_property_new_getter_new_docstring @ linux-x86_64 +test.test_property.PropertySubclassTests.test_property_setter_copies_getter_docstring @ linux-x86_64 +test.test_property.PropertySubclassTests.test_slots_docstring_copy_exception @ linux-x86_64 +test.test_property.PropertyTests.test_property___isabstractmethod__descriptor @ linux-x86_64 +test.test_property.PropertyTests.test_property_builtin_doc_writable @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_baseclass @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_baseclass_doc @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_doc @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_doc_writable @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_subclass @ linux-x86_64 +test.test_property.PropertyTests.test_property_decorator_subclass_doc @ linux-x86_64 +test.test_property.PropertyTests.test_property_getter_doc_override @ linux-x86_64 +test.test_property.PropertyTests.test_property_set_name_incorrect_args @ linux-x86_64 +test.test_property.PropertyTests.test_property_setname_on_property_subclass @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeNoName.test_del_property @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeNoName.test_get_property @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeNoName.test_set_property @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeWithName.test_del_property @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeWithName.test_get_property @ linux-x86_64 +test.test_property.PropertyUnreachableAttributeWithName.test_set_property @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pstats.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pstats.txt new file mode 100644 index 0000000000..c27c49eb23 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pstats.txt @@ -0,0 +1,8 @@ +test.test_pstats.AddCallersTestCase.test_combine_results @ linux-x86_64 +test.test_pstats.StatsTestCase.test_SortKey_enum @ linux-x86_64 +test.test_pstats.StatsTestCase.test_add @ linux-x86_64 +test.test_pstats.StatsTestCase.test_sort_starts_mix @ linux-x86_64 +test.test_pstats.StatsTestCase.test_sort_stats_enum @ linux-x86_64 +test.test_pstats.StatsTestCase.test_sort_stats_int @ linux-x86_64 +test.test_pstats.StatsTestCase.test_sort_stats_partial @ linux-x86_64 +test.test_pstats.StatsTestCase.test_sort_stats_string @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pty.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pty.txt new file mode 100644 index 0000000000..e69c02a69e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pty.txt @@ -0,0 +1,4 @@ +test.test_pty.PtyTest.test_master_read @ linux-x86_64 +test.test_pty.PtyTest.test_openpty @ linux-x86_64 +test.test_pty.SmallPtyTests.test__copy_to_each @ linux-x86_64 +test.test_pty.SmallPtyTests.test__restore_tty_mode_normal_return @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pulldom.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pulldom.txt new file mode 100644 index 0000000000..ebcfcbe615 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pulldom.txt @@ -0,0 +1,11 @@ +test.test_pulldom.PullDOMTestCase.test_comment @ linux-x86_64 +test.test_pulldom.PullDOMTestCase.test_end_document @ linux-x86_64 +test.test_pulldom.PullDOMTestCase.test_expandItem @ linux-x86_64 +test.test_pulldom.PullDOMTestCase.test_external_ges_default @ linux-x86_64 +test.test_pulldom.PullDOMTestCase.test_parse @ linux-x86_64 +test.test_pulldom.PullDOMTestCase.test_parse_semantics @ linux-x86_64 +test.test_pulldom.SAX2DOMTestCase.testSAX2DOM @ linux-x86_64 +test.test_pulldom.SAX2DOMTestCase.test_basic @ linux-x86_64 +test.test_pulldom.ThoroughTestCase.test_sax2dom_fail @ linux-x86_64 +test.test_pulldom.ThoroughTestCase.test_thorough_parse @ linux-x86_64 +test.test_pulldom.ThoroughTestCase.test_thorough_sax2dom @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pwd.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pwd.txt new file mode 100644 index 0000000000..2350c4121e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pwd.txt @@ -0,0 +1,3 @@ +test.test_pwd.PwdTest.test_errors @ linux-x86_64 +test.test_pwd.PwdTest.test_values @ linux-x86_64 +test.test_pwd.PwdTest.test_values_extended @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_py_compile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_py_compile.txt new file mode 100644 index 0000000000..c1ca96f9c9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_py_compile.txt @@ -0,0 +1,32 @@ +test.test_py_compile.PyCompileCLITestCase.test_bad_syntax @ linux-x86_64 +test.test_py_compile.PyCompileCLITestCase.test_bad_syntax_with_quiet @ linux-x86_64 +test.test_py_compile.PyCompileCLITestCase.test_file_not_exists @ linux-x86_64 +test.test_py_compile.PyCompileCLITestCase.test_file_not_exists_with_quiet @ linux-x86_64 +test.test_py_compile.PyCompileCLITestCase.test_stdin @ linux-x86_64 +test.test_py_compile.PyCompileCLITestCase.test_with_files @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_absolute_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_bad_coding @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_cache_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_cwd @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_do_not_overwrite_nonregular_files @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_do_not_overwrite_symlinks @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_double_dot_no_clobber @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_exceptions_propagate @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_invalidation_mode @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_optimization_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_quiet @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_relative_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithSourceEpoch.test_source_date_epoch @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_absolute_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_bad_coding @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_cache_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_cwd @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_do_not_overwrite_nonregular_files @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_do_not_overwrite_symlinks @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_double_dot_no_clobber @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_exceptions_propagate @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_invalidation_mode @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_optimization_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_quiet @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_relative_path @ linux-x86_64 +test.test_py_compile.PyCompileTestsWithoutSourceEpoch.test_source_date_epoch @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyclbr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyclbr.txt new file mode 100644 index 0000000000..6ea16c12bb --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyclbr.txt @@ -0,0 +1,6 @@ +test.test_pyclbr.PyclbrTest.test_decorators @ linux-x86_64 +test.test_pyclbr.PyclbrTest.test_easy @ linux-x86_64 +test.test_pyclbr.PyclbrTest.test_nested @ linux-x86_64 +test.test_pyclbr.PyclbrTest.test_others @ linux-x86_64 +test.test_pyclbr.ReadmoduleTests.test_dotted_name_not_a_package @ linux-x86_64 +test.test_pyclbr.ReadmoduleTests.test_module_has_no_spec @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pydoc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pydoc.txt new file mode 100644 index 0000000000..a19b686d77 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pydoc.txt @@ -0,0 +1,68 @@ +test.test_pydoc.PydocDocTest.test__future__imports @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_allmethods @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_builtin_no_child @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_builtin_on_metaclasses @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_builtin_with_child @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_builtin_with_grandchild @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_builtin_with_more_than_four_children @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_fail_help_cli @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_fail_help_output_redirect @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_getpager_with_stdin_none @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_input_strip @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_is_package_when_is_package @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_is_package_when_not_package @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_issue8225 @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_mixed_case_module_names_are_lower_cased @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_namedtuple_fields @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_namedtuple_public_underscore @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_non_str_name @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_not_ascii @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_not_here @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_splitdoc_with_description @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_stripid @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_synopsis @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_synopsis_sourceless @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_synopsis_sourceless_empty_doc @ linux-x86_64 +test.test_pydoc.PydocDocTest.test_text_enum_member_with_value_zero @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_apropos_empty_doc @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_apropos_with_bad_package @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_apropos_with_unreadable_dir @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_badimport @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_importfile @ linux-x86_64 +test.test_pydoc.PydocImportTest.test_url_search_package_error @ linux-x86_64 +test.test_pydoc.PydocServerTest.test_server @ linux-x86_64 +test.test_pydoc.PydocUrlHandlerTest.test_content_type_err @ linux-x86_64 +test.test_pydoc.PydocUrlHandlerTest.test_url_requests @ linux-x86_64 +test.test_pydoc.PydocWithMetaClasses.test_buggy_dir @ linux-x86_64 +test.test_pydoc.PydocWithMetaClasses.test_resolve_false @ linux-x86_64 +test.test_pydoc.PydocWithMetaClasses.test_virtualClassAttributeWithOneMeta @ linux-x86_64 +test.test_pydoc.PydocWithMetaClasses.test_virtualClassAttributeWithTwoMeta @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_async_annotation @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_async_generator_annotation @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_bound_builtin_method @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_bound_python_method @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_builtin @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_class @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_custom_data_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_custom_non_data_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_dict_attr_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_field_order_for_named_tuples @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_generic_alias @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_getset_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_html_for_https_links @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_member_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_module @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_namedtuple_field_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_property @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_slot_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_special_form @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_staticmethod @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_structseq_member_descriptor @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_typing_pydoc @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_unbound_builtin_method @ linux-x86_64 +test.test_pydoc.TestDescriptions.test_unbound_python_method @ linux-x86_64 +test.test_pydoc.TestHelper.test_keywords @ linux-x86_64 +test.test_pydoc.TestInternalUtilities.test_sys_path_adjustment_adds_missing_curdir @ linux-x86_64 +test.test_pydoc.TestInternalUtilities.test_sys_path_adjustment_protects_pydoc_dir @ linux-x86_64 +test.test_pydoc.TestInternalUtilities.test_sys_path_adjustment_removes_argv0_dir @ linux-x86_64 +test.test_pydoc.TestInternalUtilities.test_sys_path_adjustment_when_curdir_already_included @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyexpat.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyexpat.txt new file mode 100644 index 0000000000..b7296c43ce --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_pyexpat.txt @@ -0,0 +1,38 @@ +test.test_pyexpat.BufferTextTest.test1 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test2 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test3 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test4 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test5 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test6 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test7 @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test_buffering_enabled @ linux-x86_64 +test.test_pyexpat.BufferTextTest.test_default_to_disabled @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_1000_bytes @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_1025_bytes @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_change_size_1 @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_change_size_2 @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_disabling_buffer @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_unchanged_size @ linux-x86_64 +test.test_pyexpat.ChardataBufferTest.test_wrong_size @ linux-x86_64 +test.test_pyexpat.ErrorMessageTest.test_codes @ linux-x86_64 +test.test_pyexpat.ErrorMessageTest.test_expaterror @ linux-x86_64 +test.test_pyexpat.ForeignDTDTests.test_ignore_use_foreign_dtd @ linux-x86_64 +test.test_pyexpat.ForeignDTDTests.test_use_foreign_dtd @ linux-x86_64 +test.test_pyexpat.InterningTest.test @ linux-x86_64 +test.test_pyexpat.InterningTest.test_issue9402 @ linux-x86_64 +test.test_pyexpat.MalformedInputTest.test1 @ linux-x86_64 +test.test_pyexpat.MalformedInputTest.test2 @ linux-x86_64 +test.test_pyexpat.NamespaceSeparatorTest.test_illegal @ linux-x86_64 +test.test_pyexpat.NamespaceSeparatorTest.test_legal @ linux-x86_64 +test.test_pyexpat.NamespaceSeparatorTest.test_zero_length @ linux-x86_64 +test.test_pyexpat.ParseTest.test_parse_again @ linux-x86_64 +test.test_pyexpat.ParseTest.test_parse_bytes @ linux-x86_64 +test.test_pyexpat.ParseTest.test_parse_file @ linux-x86_64 +test.test_pyexpat.ParseTest.test_parse_str @ linux-x86_64 +test.test_pyexpat.PositionTest.test @ linux-x86_64 +test.test_pyexpat.SetAttributeTest.test_buffer_text @ linux-x86_64 +test.test_pyexpat.SetAttributeTest.test_invalid_attributes @ linux-x86_64 +test.test_pyexpat.SetAttributeTest.test_namespace_prefixes @ linux-x86_64 +test.test_pyexpat.SetAttributeTest.test_ordered_attributes @ linux-x86_64 +test.test_pyexpat.SetAttributeTest.test_specified_attributes @ linux-x86_64 +test.test_pyexpat.sf1296433Test.test_parse_only_xml_data @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_queue.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_queue.txt new file mode 100644 index 0000000000..0c1c8fcfb2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_queue.txt @@ -0,0 +1,52 @@ +test.test_queue.CFailingQueueTest.test_failing_queue @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_basic @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_nowait @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.CLifoQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_basic @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_nowait @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.CPriorityQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.CQueueTest.test_basic @ linux-x86_64 +test.test_queue.CQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.CQueueTest.test_nowait @ linux-x86_64 +test.test_queue.CQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.CQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.CQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_basic @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_is_default @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_many_threads @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_many_threads_nonblock @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_many_threads_timeout @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_order @ linux-x86_64 +test.test_queue.CSimpleQueueTest.test_reentrancy @ linux-x86_64 +test.test_queue.PyFailingQueueTest.test_failing_queue @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_basic @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_nowait @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.PyLifoQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_basic @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_nowait @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.PyPriorityQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.PyQueueTest.test_basic @ linux-x86_64 +test.test_queue.PyQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.PyQueueTest.test_nowait @ linux-x86_64 +test.test_queue.PyQueueTest.test_queue_join @ linux-x86_64 +test.test_queue.PyQueueTest.test_queue_task_done @ linux-x86_64 +test.test_queue.PyQueueTest.test_shrinking_queue @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_basic @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_many_threads @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_many_threads_nonblock @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_many_threads_timeout @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_negative_timeout_raises_exception @ linux-x86_64 +test.test_queue.PySimpleQueueTest.test_order @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_quopri.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_quopri.txt new file mode 100644 index 0000000000..6333652793 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_quopri.txt @@ -0,0 +1,11 @@ +test.test_quopri.QuopriTestCase.test_decode @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_decode_header @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_decodestring @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_decodestring_double_equals @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_embedded_ws @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_encode @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_encode_header @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_encodestring @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_idempotent_string @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_scriptdecode @ linux-x86_64 +test.test_quopri.QuopriTestCase.test_scriptencode @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_raise.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_raise.txt new file mode 100644 index 0000000000..7fee0280cd --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_raise.txt @@ -0,0 +1,34 @@ +test.test_raise.TestCause.testCauseSyntax @ linux-x86_64 +test.test_raise.TestCause.test_class_cause @ linux-x86_64 +test.test_raise.TestCause.test_erroneous_cause @ linux-x86_64 +test.test_raise.TestCause.test_instance_cause @ linux-x86_64 +test.test_raise.TestCause.test_invalid_cause @ linux-x86_64 +test.test_raise.TestContext.test_3118 @ linux-x86_64 +test.test_raise.TestContext.test_c_exception_context @ linux-x86_64 +test.test_raise.TestContext.test_c_exception_raise @ linux-x86_64 +test.test_raise.TestContext.test_class_context_class_raise @ linux-x86_64 +test.test_raise.TestContext.test_class_context_instance_raise @ linux-x86_64 +test.test_raise.TestContext.test_context_manager @ linux-x86_64 +test.test_raise.TestContext.test_cycle_broken @ linux-x86_64 +test.test_raise.TestContext.test_instance_context_instance_raise @ linux-x86_64 +test.test_raise.TestContext.test_noraise_finally @ linux-x86_64 +test.test_raise.TestContext.test_not_last @ linux-x86_64 +test.test_raise.TestContext.test_raise_finally @ linux-x86_64 +test.test_raise.TestContext.test_reraise_cycle_broken @ linux-x86_64 +test.test_raise.TestRaise.test_assert_with_tuple_arg @ linux-x86_64 +test.test_raise.TestRaise.test_erroneous_exception @ linux-x86_64 +test.test_raise.TestRaise.test_except_reraise @ linux-x86_64 +test.test_raise.TestRaise.test_finally_reraise @ linux-x86_64 +test.test_raise.TestRaise.test_invalid_reraise @ linux-x86_64 +test.test_raise.TestRaise.test_nested_reraise @ linux-x86_64 +test.test_raise.TestRaise.test_new_returns_invalid_instance @ linux-x86_64 +test.test_raise.TestRaise.test_raise_from_None @ linux-x86_64 +test.test_raise.TestRaise.test_reraise @ linux-x86_64 +test.test_raise.TestRaise.test_with_reraise1 @ linux-x86_64 +test.test_raise.TestRaise.test_with_reraise2 @ linux-x86_64 +test.test_raise.TestRemovedFunctionality.test_strings @ linux-x86_64 +test.test_raise.TestRemovedFunctionality.test_tuples @ linux-x86_64 +test.test_raise.TestTraceback.test_accepts_traceback @ linux-x86_64 +test.test_raise.TestTraceback.test_sets_traceback @ linux-x86_64 +test.test_raise.TestTracebackType.test_attrs @ linux-x86_64 +test.test_raise.TestTracebackType.test_constructor @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_random.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_random.txt new file mode 100644 index 0000000000..80ca585573 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_random.txt @@ -0,0 +1,98 @@ +test.test_random.MersenneTwister_TestBasicOps.test_53_bits_per_float @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_autoseed @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bigrand @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bigrand_ranges @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bug_1727780 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bug_27706 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bug_31478 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bug_31482 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_bug_9025 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choice @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choice_with_numpy @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices_algorithms @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices_infinite_total @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices_negative_total @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices_subnormal @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_choices_with_all_zero_weights @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_gauss @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_getrandbits @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_guaranteed_stable @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_long_seed @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_mu_sigma_default_args @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_pickling @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randbelow_logic @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randbelow_without_getrandbits @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randbytes @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randbytes_getrandbits @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randrange_bug_1590891 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_randrange_uses_getrandbits @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_rangelimits @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_referenceImplementation @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_counts_equivalence @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_distribution @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_inputs @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_on_dicts @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_on_seqsets @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_on_sets @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_sample_with_counts @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_saverestore @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_seed_no_mutate_bug_44018 @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_seed_when_randomness_source_not_found @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_seedargs @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_setstate_first_arg @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_setstate_middle_arg @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_shuffle @ linux-x86_64 +test.test_random.MersenneTwister_TestBasicOps.test_strong_reference_implementation @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_53_bits_per_float @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_autoseed @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_bigrand @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_bigrand_ranges @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_bug_1727780 @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_bug_9025 @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choice @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choice_with_numpy @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choices @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choices_infinite_total @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choices_negative_total @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choices_subnormal @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_choices_with_all_zero_weights @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_gauss @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_getrandbits @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_mu_sigma_default_args @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_pickling @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randbelow_logic @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randbytes @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randrange_argument_handling @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randrange_errors @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randrange_nonunit_step @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_randrange_step @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_rangelimits @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_distribution @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_inputs @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_on_dicts @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_on_seqsets @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_on_sets @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_sample_with_counts @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_saverestore @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_seed_no_mutate_bug_44018 @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_seed_when_randomness_source_not_found @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_seedargs @ linux-x86_64 +test.test_random.SystemRandom_TestBasicOps.test_shuffle @ linux-x86_64 +test.test_random.TestDistributions.test_avg_std @ linux-x86_64 +test.test_random.TestDistributions.test_betavariate_return_zero @ linux-x86_64 +test.test_random.TestDistributions.test_constant @ linux-x86_64 +test.test_random.TestDistributions.test_gammavariate_alpha_between_zero_and_one @ linux-x86_64 +test.test_random.TestDistributions.test_gammavariate_alpha_equal_one @ linux-x86_64 +test.test_random.TestDistributions.test_gammavariate_alpha_equal_one_equals_expovariate @ linux-x86_64 +test.test_random.TestDistributions.test_gammavariate_alpha_greater_one @ linux-x86_64 +test.test_random.TestDistributions.test_gammavariate_errors @ linux-x86_64 +test.test_random.TestDistributions.test_von_mises_large_kappa @ linux-x86_64 +test.test_random.TestDistributions.test_von_mises_range @ linux-x86_64 +test.test_random.TestDistributions.test_zeroinputs @ linux-x86_64 +test.test_random.TestModule.testMagicConstants @ linux-x86_64 +test.test_random.TestModule.test__all__ @ linux-x86_64 +test.test_random.TestRandomSubclassing.test_random_subclass_with_kwargs @ linux-x86_64 +test.test_random.TestRandomSubclassing.test_subclasses_overriding_methods @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_range.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_range.txt new file mode 100644 index 0000000000..349ae580da --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_range.txt @@ -0,0 +1,25 @@ +test.test_range.RangeTest.test_attributes @ linux-x86_64 +test.test_range.RangeTest.test_comparison @ linux-x86_64 +test.test_range.RangeTest.test_contains @ linux-x86_64 +test.test_range.RangeTest.test_count @ linux-x86_64 +test.test_range.RangeTest.test_empty @ linux-x86_64 +test.test_range.RangeTest.test_exhausted_iterator_pickling @ linux-x86_64 +test.test_range.RangeTest.test_index @ linux-x86_64 +test.test_range.RangeTest.test_invalid_invocation @ linux-x86_64 +test.test_range.RangeTest.test_issue11845 @ linux-x86_64 +test.test_range.RangeTest.test_iterator_pickling @ linux-x86_64 +test.test_range.RangeTest.test_iterator_pickling_overflowing_index @ linux-x86_64 +test.test_range.RangeTest.test_large_exhausted_iterator_pickling @ linux-x86_64 +test.test_range.RangeTest.test_large_operands @ linux-x86_64 +test.test_range.RangeTest.test_large_range @ linux-x86_64 +test.test_range.RangeTest.test_odd_bug @ linux-x86_64 +test.test_range.RangeTest.test_pickling @ linux-x86_64 +test.test_range.RangeTest.test_range @ linux-x86_64 +test.test_range.RangeTest.test_range_iterators @ linux-x86_64 +test.test_range.RangeTest.test_range_iterators_invocation @ linux-x86_64 +test.test_range.RangeTest.test_repr @ linux-x86_64 +test.test_range.RangeTest.test_reverse_iteration @ linux-x86_64 +test.test_range.RangeTest.test_slice @ linux-x86_64 +test.test_range.RangeTest.test_strided_limits @ linux-x86_64 +test.test_range.RangeTest.test_types @ linux-x86_64 +test.test_range.RangeTest.test_user_index_method @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_re.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_re.txt new file mode 100644 index 0000000000..d670732bf2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_re.txt @@ -0,0 +1,143 @@ +test.test_re.ExternalTests.test_re_benchmarks @ linux-x86_64 +test.test_re.ExternalTests.test_re_tests @ linux-x86_64 +test.test_re.ImplementationTest.test_overlap_table @ linux-x86_64 +test.test_re.ImplementationTest.test_signedness @ linux-x86_64 +test.test_re.PatternReprTests.test_bytes @ linux-x86_64 +test.test_re.PatternReprTests.test_flags_repr @ linux-x86_64 +test.test_re.PatternReprTests.test_inline_flags @ linux-x86_64 +test.test_re.PatternReprTests.test_locale @ linux-x86_64 +test.test_re.PatternReprTests.test_long_pattern @ linux-x86_64 +test.test_re.PatternReprTests.test_multiple_flags @ linux-x86_64 +test.test_re.PatternReprTests.test_quotes @ linux-x86_64 +test.test_re.PatternReprTests.test_single_flag @ linux-x86_64 +test.test_re.PatternReprTests.test_unicode_flag @ linux-x86_64 +test.test_re.PatternReprTests.test_unknown_flags @ linux-x86_64 +test.test_re.PatternReprTests.test_without_flags @ linux-x86_64 +test.test_re.ReTests.test_ASSERT_NOT_mark_bug @ linux-x86_64 +test.test_re.ReTests.test_MARK_PUSH_macro_bug @ linux-x86_64 +test.test_re.ReTests.test_MIN_REPEAT_ONE_mark_bug @ linux-x86_64 +test.test_re.ReTests.test_MIN_UNTIL_mark_bug @ linux-x86_64 +test.test_re.ReTests.test_REPEAT_ONE_mark_bug @ linux-x86_64 +test.test_re.ReTests.test_anyall @ linux-x86_64 +test.test_re.ReTests.test_ascii_and_unicode_flag @ linux-x86_64 +test.test_re.ReTests.test_atomic_grouping @ linux-x86_64 +test.test_re.ReTests.test_backref_group_name_in_exception @ linux-x86_64 +test.test_re.ReTests.test_basic_re_sub @ linux-x86_64 +test.test_re.ReTests.test_big_codesize @ linux-x86_64 +test.test_re.ReTests.test_bigcharset @ linux-x86_64 +test.test_re.ReTests.test_branching @ linux-x86_64 +test.test_re.ReTests.test_bug_113254 @ linux-x86_64 +test.test_re.ReTests.test_bug_114660 @ linux-x86_64 +test.test_re.ReTests.test_bug_117612 @ linux-x86_64 +test.test_re.ReTests.test_bug_1661 @ linux-x86_64 +test.test_re.ReTests.test_bug_16688 @ linux-x86_64 +test.test_re.ReTests.test_bug_20998 @ linux-x86_64 +test.test_re.ReTests.test_bug_2537 @ linux-x86_64 +test.test_re.ReTests.test_bug_29444 @ linux-x86_64 +test.test_re.ReTests.test_bug_34294 @ linux-x86_64 +test.test_re.ReTests.test_bug_3629 @ linux-x86_64 +test.test_re.ReTests.test_bug_418626 @ linux-x86_64 +test.test_re.ReTests.test_bug_448951 @ linux-x86_64 +test.test_re.ReTests.test_bug_449000 @ linux-x86_64 +test.test_re.ReTests.test_bug_449964 @ linux-x86_64 +test.test_re.ReTests.test_bug_527371 @ linux-x86_64 +test.test_re.ReTests.test_bug_581080 @ linux-x86_64 +test.test_re.ReTests.test_bug_612074 @ linux-x86_64 +test.test_re.ReTests.test_bug_6509 @ linux-x86_64 +test.test_re.ReTests.test_bug_6561 @ linux-x86_64 +test.test_re.ReTests.test_bug_725106 @ linux-x86_64 +test.test_re.ReTests.test_bug_725149 @ linux-x86_64 +test.test_re.ReTests.test_bug_764548 @ linux-x86_64 +test.test_re.ReTests.test_bug_817234 @ linux-x86_64 +test.test_re.ReTests.test_bug_926075 @ linux-x86_64 +test.test_re.ReTests.test_bug_931848 @ linux-x86_64 +test.test_re.ReTests.test_bug_gh106052 @ linux-x86_64 +test.test_re.ReTests.test_bug_gh91616 @ linux-x86_64 +test.test_re.ReTests.test_bytes_str_mixing @ linux-x86_64 +test.test_re.ReTests.test_category @ linux-x86_64 +test.test_re.ReTests.test_character_set_errors @ linux-x86_64 +test.test_re.ReTests.test_comments @ linux-x86_64 +test.test_re.ReTests.test_compile @ linux-x86_64 +test.test_re.ReTests.test_constants @ linux-x86_64 +test.test_re.ReTests.test_copying @ linux-x86_64 +test.test_re.ReTests.test_dollar_matches_twice @ linux-x86_64 +test.test_re.ReTests.test_empty_array @ linux-x86_64 +test.test_re.ReTests.test_enum @ linux-x86_64 +test.test_re.ReTests.test_error @ linux-x86_64 +test.test_re.ReTests.test_expand @ linux-x86_64 +test.test_re.ReTests.test_findall_atomic_grouping @ linux-x86_64 +test.test_re.ReTests.test_findall_possessive_quantifiers @ linux-x86_64 +test.test_re.ReTests.test_finditer @ linux-x86_64 +test.test_re.ReTests.test_flags @ linux-x86_64 +test.test_re.ReTests.test_fullmatch_atomic_grouping @ linux-x86_64 +test.test_re.ReTests.test_fullmatch_possessive_quantifiers @ linux-x86_64 +test.test_re.ReTests.test_getattr @ linux-x86_64 +test.test_re.ReTests.test_group @ linux-x86_64 +test.test_re.ReTests.test_group_name_in_exception @ linux-x86_64 +test.test_re.ReTests.test_groupdict @ linux-x86_64 +test.test_re.ReTests.test_ignore_case @ linux-x86_64 +test.test_re.ReTests.test_ignore_case_range @ linux-x86_64 +test.test_re.ReTests.test_ignore_case_set @ linux-x86_64 +test.test_re.ReTests.test_ignore_spaces @ linux-x86_64 +test.test_re.ReTests.test_inline_flags @ linux-x86_64 +test.test_re.ReTests.test_issue17998 @ linux-x86_64 +test.test_re.ReTests.test_keyword_parameters @ linux-x86_64 +test.test_re.ReTests.test_large_search @ linux-x86_64 +test.test_re.ReTests.test_large_subn @ linux-x86_64 +test.test_re.ReTests.test_locale_flag @ linux-x86_64 +test.test_re.ReTests.test_lookahead @ linux-x86_64 +test.test_re.ReTests.test_lookbehind @ linux-x86_64 +test.test_re.ReTests.test_match_getitem @ linux-x86_64 +test.test_re.ReTests.test_match_repr @ linux-x86_64 +test.test_re.ReTests.test_misc_errors @ linux-x86_64 +test.test_re.ReTests.test_multiple_repeat @ linux-x86_64 +test.test_re.ReTests.test_named_unicode_escapes @ linux-x86_64 +test.test_re.ReTests.test_not_literal @ linux-x86_64 +test.test_re.ReTests.test_nothing_to_repeat @ linux-x86_64 +test.test_re.ReTests.test_other_escapes @ linux-x86_64 +test.test_re.ReTests.test_pattern_compare @ linux-x86_64 +test.test_re.ReTests.test_pattern_compare_bytes @ linux-x86_64 +test.test_re.ReTests.test_pickling @ linux-x86_64 +test.test_re.ReTests.test_possessive_quantifiers @ linux-x86_64 +test.test_re.ReTests.test_possible_set_operations @ linux-x86_64 +test.test_re.ReTests.test_qualified_re_split @ linux-x86_64 +test.test_re.ReTests.test_qualified_re_sub @ linux-x86_64 +test.test_re.ReTests.test_re_escape @ linux-x86_64 +test.test_re.ReTests.test_re_escape_bytes @ linux-x86_64 +test.test_re.ReTests.test_re_escape_non_ascii @ linux-x86_64 +test.test_re.ReTests.test_re_escape_non_ascii_bytes @ linux-x86_64 +test.test_re.ReTests.test_re_findall @ linux-x86_64 +test.test_re.ReTests.test_re_fullmatch @ linux-x86_64 +test.test_re.ReTests.test_re_groupref @ linux-x86_64 +test.test_re.ReTests.test_re_groupref_exists @ linux-x86_64 +test.test_re.ReTests.test_re_groupref_exists_errors @ linux-x86_64 +test.test_re.ReTests.test_re_groupref_exists_validation_bug @ linux-x86_64 +test.test_re.ReTests.test_re_groupref_overflow @ linux-x86_64 +test.test_re.ReTests.test_re_match @ linux-x86_64 +test.test_re.ReTests.test_re_split @ linux-x86_64 +test.test_re.ReTests.test_re_subn @ linux-x86_64 +test.test_re.ReTests.test_regression_gh94675 @ linux-x86_64 +test.test_re.ReTests.test_repeat_minmax @ linux-x86_64 +test.test_re.ReTests.test_repeat_minmax_overflow @ linux-x86_64 +test.test_re.ReTests.test_scanner @ linux-x86_64 +test.test_re.ReTests.test_scoped_flags @ linux-x86_64 +test.test_re.ReTests.test_search_anchor_at_beginning @ linux-x86_64 +test.test_re.ReTests.test_search_coverage @ linux-x86_64 +test.test_re.ReTests.test_search_dot_unicode @ linux-x86_64 +test.test_re.ReTests.test_search_star_plus @ linux-x86_64 +test.test_re.ReTests.test_special_escapes @ linux-x86_64 +test.test_re.ReTests.test_sre_byte_class_literals @ linux-x86_64 +test.test_re.ReTests.test_sre_byte_literals @ linux-x86_64 +test.test_re.ReTests.test_sre_character_class_literals @ linux-x86_64 +test.test_re.ReTests.test_sre_character_literals @ linux-x86_64 +test.test_re.ReTests.test_stack_overflow @ linux-x86_64 +test.test_re.ReTests.test_string_boundaries @ linux-x86_64 +test.test_re.ReTests.test_sub_template_numeric_escape @ linux-x86_64 +test.test_re.ReTests.test_symbolic_groups @ linux-x86_64 +test.test_re.ReTests.test_symbolic_groups_errors @ linux-x86_64 +test.test_re.ReTests.test_symbolic_refs @ linux-x86_64 +test.test_re.ReTests.test_symbolic_refs_errors @ linux-x86_64 +test.test_re.ReTests.test_template_function_and_flag_is_deprecated @ linux-x86_64 +test.test_re.ReTests.test_unlimited_zero_width_repeat @ linux-x86_64 +test.test_re.ReTests.test_weakref @ linux-x86_64 +test.test_re.ReTests.test_zerowidth @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_reprlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_reprlib.txt new file mode 100644 index 0000000000..4904ac5122 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_reprlib.txt @@ -0,0 +1,20 @@ +test.test_reprlib.LongReprTest.test_class @ linux-x86_64 +test.test_reprlib.LongReprTest.test_instance @ linux-x86_64 +test.test_reprlib.LongReprTest.test_method @ linux-x86_64 +test.test_reprlib.LongReprTest.test_module @ linux-x86_64 +test.test_reprlib.LongReprTest.test_type @ linux-x86_64 +test.test_reprlib.ReprTests.test_builtin_function @ linux-x86_64 +test.test_reprlib.ReprTests.test_cell @ linux-x86_64 +test.test_reprlib.ReprTests.test_container @ linux-x86_64 +test.test_reprlib.ReprTests.test_descriptors @ linux-x86_64 +test.test_reprlib.ReprTests.test_frozenset @ linux-x86_64 +test.test_reprlib.ReprTests.test_instance @ linux-x86_64 +test.test_reprlib.ReprTests.test_nesting @ linux-x86_64 +test.test_reprlib.ReprTests.test_numbers @ linux-x86_64 +test.test_reprlib.ReprTests.test_range @ linux-x86_64 +test.test_reprlib.ReprTests.test_set_literal @ linux-x86_64 +test.test_reprlib.ReprTests.test_string @ linux-x86_64 +test.test_reprlib.ReprTests.test_tuple @ linux-x86_64 +test.test_reprlib.ReprTests.test_unsortable @ linux-x86_64 +test.test_reprlib.TestRecursiveRepr.test_assigned_attributes @ linux-x86_64 +test.test_reprlib.TestRecursiveRepr.test_recursive_repr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_resource.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_resource.txt new file mode 100644 index 0000000000..3e0d697fed --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_resource.txt @@ -0,0 +1,4 @@ +test.test_resource.ResourceTest.test_freebsd_contants @ linux-x86_64 +test.test_resource.ResourceTest.test_getrusage @ linux-x86_64 +test.test_resource.ResourceTest.test_linux_constants @ linux-x86_64 +test.test_resource.ResourceTest.test_pagesize @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_richcmp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_richcmp.txt new file mode 100644 index 0000000000..49ac537d10 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_richcmp.txt @@ -0,0 +1,11 @@ +test.test_richcmp.DictTest.test_dicts @ linux-x86_64 +test.test_richcmp.ListTest.test_badentry @ linux-x86_64 +test.test_richcmp.ListTest.test_coverage @ linux-x86_64 +test.test_richcmp.ListTest.test_goodentry @ linux-x86_64 +test.test_richcmp.MiscTest.test_exception_message @ linux-x86_64 +test.test_richcmp.MiscTest.test_misbehavin @ linux-x86_64 +test.test_richcmp.MiscTest.test_not @ linux-x86_64 +test.test_richcmp.MiscTest.test_recursion @ linux-x86_64 +test.test_richcmp.NumberTest.test_basic @ linux-x86_64 +test.test_richcmp.NumberTest.test_values @ linux-x86_64 +test.test_richcmp.VectorTest.test_mixed @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_rlcompleter.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_rlcompleter.txt new file mode 100644 index 0000000000..2302309974 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_rlcompleter.txt @@ -0,0 +1,7 @@ +test.test_rlcompleter.TestRlcompleter.test_complete @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_duplicate_globals @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_excessive_getattr @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_global_matches @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_namespace @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_property_method_not_called @ linux-x86_64 +test.test_rlcompleter.TestRlcompleter.test_uncreated_attr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_robotparser.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_robotparser.txt new file mode 100644 index 0000000000..a4258f35d0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_robotparser.txt @@ -0,0 +1,63 @@ +test.test_robotparser.AnotherInvalidRequestRateTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.AnotherInvalidRequestRateTest.test_good_urls @ linux-x86_64 +test.test_robotparser.AnotherInvalidRequestRateTest.test_site_maps @ linux-x86_64 +test.test_robotparser.CrawlDelayAndCustomAgentTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.CrawlDelayAndCustomAgentTest.test_good_urls @ linux-x86_64 +test.test_robotparser.CrawlDelayAndCustomAgentTest.test_site_maps @ linux-x86_64 +test.test_robotparser.CrawlDelayAndRequestRateTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.CrawlDelayAndRequestRateTest.test_good_urls @ linux-x86_64 +test.test_robotparser.CrawlDelayAndRequestRateTest.test_request_rate @ linux-x86_64 +test.test_robotparser.CrawlDelayAndRequestRateTest.test_site_maps @ linux-x86_64 +test.test_robotparser.DefaultEntryTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.DefaultEntryTest.test_good_urls @ linux-x86_64 +test.test_robotparser.DefaultEntryTest.test_request_rate @ linux-x86_64 +test.test_robotparser.DefaultEntryTest.test_site_maps @ linux-x86_64 +test.test_robotparser.DifferentAgentTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.DifferentAgentTest.test_good_urls @ linux-x86_64 +test.test_robotparser.DifferentAgentTest.test_request_rate @ linux-x86_64 +test.test_robotparser.DifferentAgentTest.test_site_maps @ linux-x86_64 +test.test_robotparser.DisallowQueryStringTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.DisallowQueryStringTest.test_good_urls @ linux-x86_64 +test.test_robotparser.DisallowQueryStringTest.test_site_maps @ linux-x86_64 +test.test_robotparser.EmptyFileTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.EmptyFileTest.test_good_urls @ linux-x86_64 +test.test_robotparser.EmptyFileTest.test_request_rate @ linux-x86_64 +test.test_robotparser.EmptyFileTest.test_site_maps @ linux-x86_64 +test.test_robotparser.EmptyQueryStringTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.EmptyQueryStringTest.test_good_urls @ linux-x86_64 +test.test_robotparser.EmptyQueryStringTest.test_site_maps @ linux-x86_64 +test.test_robotparser.GoogleURLOrderingTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.GoogleURLOrderingTest.test_good_urls @ linux-x86_64 +test.test_robotparser.GoogleURLOrderingTest.test_site_maps @ linux-x86_64 +test.test_robotparser.InvalidCrawlDelayTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.InvalidCrawlDelayTest.test_good_urls @ linux-x86_64 +test.test_robotparser.InvalidCrawlDelayTest.test_site_maps @ linux-x86_64 +test.test_robotparser.InvalidRequestRateTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.InvalidRequestRateTest.test_good_urls @ linux-x86_64 +test.test_robotparser.InvalidRequestRateTest.test_site_maps @ linux-x86_64 +test.test_robotparser.NetworkTestCase.test_basic @ linux-x86_64 +test.test_robotparser.NetworkTestCase.test_can_fetch @ linux-x86_64 +test.test_robotparser.NetworkTestCase.test_read_404 @ linux-x86_64 +test.test_robotparser.PasswordProtectedSiteTestCase.testPasswordProtectedSite @ linux-x86_64 +test.test_robotparser.RejectAllRobotsTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.RejectAllRobotsTest.test_good_urls @ linux-x86_64 +test.test_robotparser.RejectAllRobotsTest.test_site_maps @ linux-x86_64 +test.test_robotparser.SitemapTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.SitemapTest.test_good_urls @ linux-x86_64 +test.test_robotparser.SitemapTest.test_site_maps @ linux-x86_64 +test.test_robotparser.StringFormattingTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.StringFormattingTest.test_good_urls @ linux-x86_64 +test.test_robotparser.StringFormattingTest.test_site_maps @ linux-x86_64 +test.test_robotparser.StringFormattingTest.test_string_formatting @ linux-x86_64 +test.test_robotparser.UseFirstUserAgentWildcardTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.UseFirstUserAgentWildcardTest.test_good_urls @ linux-x86_64 +test.test_robotparser.UseFirstUserAgentWildcardTest.test_site_maps @ linux-x86_64 +test.test_robotparser.UserAgentGoogleMobileTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.UserAgentGoogleMobileTest.test_good_urls @ linux-x86_64 +test.test_robotparser.UserAgentGoogleMobileTest.test_site_maps @ linux-x86_64 +test.test_robotparser.UserAgentOrderingTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.UserAgentOrderingTest.test_good_urls @ linux-x86_64 +test.test_robotparser.UserAgentOrderingTest.test_site_maps @ linux-x86_64 +test.test_robotparser.UserAgentWildcardTest.test_bad_urls @ linux-x86_64 +test.test_robotparser.UserAgentWildcardTest.test_good_urls @ linux-x86_64 +test.test_robotparser.UserAgentWildcardTest.test_site_maps @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_runpy.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_runpy.txt new file mode 100644 index 0000000000..c349484e35 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_runpy.txt @@ -0,0 +1,31 @@ +test.test_runpy.ExecutionLayerTestCase.test_run_code @ linux-x86_64 +test.test_runpy.ExecutionLayerTestCase.test_run_module_code @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_explicit_relative_import @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_invalid_names @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_library_module @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_main_relative_import @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_package_imported_no_warning @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_pkgutil_walk_packages @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_module @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_module_alter_sys @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_module_in_namespace_package @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_name @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_namespace_package @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_namespace_package_in_namespace_package @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_package @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_package_alter_sys @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_package_in_namespace_package @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_run_package_init_exceptions @ linux-x86_64 +test.test_runpy.RunModuleTestCase.test_submodule_imported_warning @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_basic_script @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_basic_script_no_suffix @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_basic_script_with_path_object @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_directory @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_directory_compiled @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_directory_error @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_encoding @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_main_recursion_error @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_script_compiled @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_zipfile @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_zipfile_compiled @ linux-x86_64 +test.test_runpy.RunPathTestCase.test_zipfile_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sax.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sax.txt new file mode 100644 index 0000000000..771246e9aa --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sax.txt @@ -0,0 +1,175 @@ +test.test_sax.BytesXmlgenTest.test_1463026_1 @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_1463026_1_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_1463026_2 @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_1463026_2_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_1463026_3 @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_1463026_3_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_5027_1 @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_5027_2 @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_no_close_file @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_attr_escape @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_basic @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_basic_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_content @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_content_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_content_escape @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_fragment @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_ignorable @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_ignorable_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_ns @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_ns_empty @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_pi @ linux-x86_64 +test.test_sax.BytesXmlgenTest.test_xmlgen_unencodable @ linux-x86_64 +test.test_sax.CDATAHandlerTest.test_handlers @ linux-x86_64 +test.test_sax.ErrorReportingTest.test_expat_incomplete @ linux-x86_64 +test.test_sax.ErrorReportingTest.test_expat_inpsource_location @ linux-x86_64 +test.test_sax.ErrorReportingTest.test_sax_parse_exception_str @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_attrs_empty @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_attrs_wattr @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_binary_file @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_binary_file_bytes_name @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_binary_file_int_name @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_binary_file_nonascii @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_dtdhandler @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_entityresolver_default @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_entityresolver_enabled @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_external_dtd_default @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_external_dtd_enabled @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_incremental @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_incremental_reset @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_inpsource_byte_stream @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_inpsource_character_stream @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_inpsource_filename @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_inpsource_sysid @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_inpsource_sysid_nonascii @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_locator_noinfo @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_locator_withinfo @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_locator_withinfo_nonascii @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_nsattrs_empty @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_nsattrs_wattr @ linux-x86_64 +test.test_sax.ExpatReaderTest.test_expat_text_file @ linux-x86_64 +test.test_sax.LexicalHandlerTest.test_handlers @ linux-x86_64 +test.test_sax.MakeParserTest.test_make_parser2 @ linux-x86_64 +test.test_sax.MakeParserTest.test_make_parser3 @ linux-x86_64 +test.test_sax.MakeParserTest.test_make_parser4 @ linux-x86_64 +test.test_sax.MakeParserTest.test_make_parser5 @ linux-x86_64 +test.test_sax.ParseTest.test_parseString_text @ linux-x86_64 +test.test_sax.ParseTest.test_parse_close_source @ linux-x86_64 +test.test_sax.ParseTest.test_parse_path_object @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_binary_file @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_byte_stream @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_character_stream @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_path_objects @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_string @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_system_id @ linux-x86_64 +test.test_sax.PrepareInputSourceTest.test_text_file @ linux-x86_64 +test.test_sax.SaxutilsTest.test_double_quoteattr @ linux-x86_64 +test.test_sax.SaxutilsTest.test_escape_all @ linux-x86_64 +test.test_sax.SaxutilsTest.test_escape_basic @ linux-x86_64 +test.test_sax.SaxutilsTest.test_escape_extra @ linux-x86_64 +test.test_sax.SaxutilsTest.test_make_parser @ linux-x86_64 +test.test_sax.SaxutilsTest.test_quoteattr_basic @ linux-x86_64 +test.test_sax.SaxutilsTest.test_single_double_quoteattr @ linux-x86_64 +test.test_sax.SaxutilsTest.test_single_quoteattr @ linux-x86_64 +test.test_sax.SaxutilsTest.test_unescape_all @ linux-x86_64 +test.test_sax.SaxutilsTest.test_unescape_amp_extra @ linux-x86_64 +test.test_sax.SaxutilsTest.test_unescape_basic @ linux-x86_64 +test.test_sax.SaxutilsTest.test_unescape_extra @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_1 @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_1_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_2 @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_2_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_3 @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_1463026_3_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_5027_1 @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_5027_2 @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_no_close_file @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_attr_escape @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_basic @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_basic_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_content @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_content_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_content_escape @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_encoding @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_encoding_bytes @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_fragment @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_ignorable @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_ignorable_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_ns @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_ns_empty @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_pi @ linux-x86_64 +test.test_sax.StreamReaderWriterXmlgenTest.test_xmlgen_unencodable @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_1 @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_1_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_2 @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_2_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_3 @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_1463026_3_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_5027_1 @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_5027_2 @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_no_close_file @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_attr_escape @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_basic @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_basic_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_content @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_content_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_content_escape @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_encoding @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_encoding_bytes @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_fragment @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_ignorable @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_ignorable_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_ns @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_ns_empty @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_pi @ linux-x86_64 +test.test_sax.StreamWriterXmlgenTest.test_xmlgen_unencodable @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_1 @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_1_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_2 @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_2_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_3 @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_1463026_3_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_5027_1 @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_5027_2 @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_no_close_file @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_attr_escape @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_basic @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_basic_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_content @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_content_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_content_escape @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_encoding @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_encoding_bytes @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_fragment @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_ignorable @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_ignorable_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_ns @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_ns_empty @ linux-x86_64 +test.test_sax.StringXmlgenTest.test_xmlgen_pi @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_1 @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_1_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_2 @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_2_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_3 @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_1463026_3_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_5027_1 @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_5027_2 @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_no_close_file @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_attr_escape @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_basic @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_basic_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_content @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_content_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_content_escape @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_fragment @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_ignorable @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_ignorable_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_ns @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_ns_empty @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_pi @ linux-x86_64 +test.test_sax.WriterXmlgenTest.test_xmlgen_unencodable @ linux-x86_64 +test.test_sax.XMLFilterBaseTest.test_filter_basic @ linux-x86_64 +test.test_sax.XmlReaderTest.test_attrs_empty @ linux-x86_64 +test.test_sax.XmlReaderTest.test_attrs_wattr @ linux-x86_64 +test.test_sax.XmlReaderTest.test_nsattrs_empty @ linux-x86_64 +test.test_sax.XmlReaderTest.test_nsattrs_wattr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sched.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sched.txt new file mode 100644 index 0000000000..f448880c0e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sched.txt @@ -0,0 +1,11 @@ +test.test_sched.TestCase.test_args_kwargs @ linux-x86_64 +test.test_sched.TestCase.test_cancel @ linux-x86_64 +test.test_sched.TestCase.test_cancel_concurrent @ linux-x86_64 +test.test_sched.TestCase.test_cancel_correct_event @ linux-x86_64 +test.test_sched.TestCase.test_empty @ linux-x86_64 +test.test_sched.TestCase.test_enter @ linux-x86_64 +test.test_sched.TestCase.test_enter_concurrent @ linux-x86_64 +test.test_sched.TestCase.test_enterabs @ linux-x86_64 +test.test_sched.TestCase.test_priority @ linux-x86_64 +test.test_sched.TestCase.test_queue @ linux-x86_64 +test.test_sched.TestCase.test_run_non_blocking @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_scope.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_scope.txt new file mode 100644 index 0000000000..bade6f95c8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_scope.txt @@ -0,0 +1,36 @@ +test.test_scope.ScopeTests.testBoundAndFree @ linux-x86_64 +test.test_scope.ScopeTests.testCellIsArgAndEscapes @ linux-x86_64 +test.test_scope.ScopeTests.testCellIsKwonlyArg @ linux-x86_64 +test.test_scope.ScopeTests.testCellIsLocalAndEscapes @ linux-x86_64 +test.test_scope.ScopeTests.testClassAndGlobal @ linux-x86_64 +test.test_scope.ScopeTests.testClassNamespaceOverridesClosure @ linux-x86_64 +test.test_scope.ScopeTests.testComplexDefinitions @ linux-x86_64 +test.test_scope.ScopeTests.testEvalExecFreeVars @ linux-x86_64 +test.test_scope.ScopeTests.testEvalFreeVars @ linux-x86_64 +test.test_scope.ScopeTests.testExtraNesting @ linux-x86_64 +test.test_scope.ScopeTests.testFreeVarInMethod @ linux-x86_64 +test.test_scope.ScopeTests.testFreeingCell @ linux-x86_64 +test.test_scope.ScopeTests.testGlobalInParallelNestedFunctions @ linux-x86_64 +test.test_scope.ScopeTests.testLambdas @ linux-x86_64 +test.test_scope.ScopeTests.testListCompLocalVars @ linux-x86_64 +test.test_scope.ScopeTests.testLocalsClass @ linux-x86_64 +test.test_scope.ScopeTests.testLocalsFunction @ linux-x86_64 +test.test_scope.ScopeTests.testMixedFreevarsAndCellvars @ linux-x86_64 +test.test_scope.ScopeTests.testNearestEnclosingScope @ linux-x86_64 +test.test_scope.ScopeTests.testNestedNonLocal @ linux-x86_64 +test.test_scope.ScopeTests.testNestingGlobalNoFree @ linux-x86_64 +test.test_scope.ScopeTests.testNestingPlusFreeRefToGlobal @ linux-x86_64 +test.test_scope.ScopeTests.testNestingThroughClass @ linux-x86_64 +test.test_scope.ScopeTests.testNonLocalClass @ linux-x86_64 +test.test_scope.ScopeTests.testNonLocalFunction @ linux-x86_64 +test.test_scope.ScopeTests.testNonLocalGenerator @ linux-x86_64 +test.test_scope.ScopeTests.testNonLocalMethod @ linux-x86_64 +test.test_scope.ScopeTests.testRecursion @ linux-x86_64 +test.test_scope.ScopeTests.testScopeOfGlobalStmt @ linux-x86_64 +test.test_scope.ScopeTests.testSimpleAndRebinding @ linux-x86_64 +test.test_scope.ScopeTests.testSimpleNesting @ linux-x86_64 +test.test_scope.ScopeTests.testTopIsNotSignificant @ linux-x86_64 +test.test_scope.ScopeTests.testUnboundLocal @ linux-x86_64 +test.test_scope.ScopeTests.testUnboundLocal_AfterDel @ linux-x86_64 +test.test_scope.ScopeTests.testUnboundLocal_AugAssign @ linux-x86_64 +test.test_scope.ScopeTests.testUnoptimizedNamespaces @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_script_helper.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_script_helper.txt new file mode 100644 index 0000000000..31af69e0f5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_script_helper.txt @@ -0,0 +1,10 @@ +test.test_script_helper.TestScriptHelper.test_assert_python_failure @ linux-x86_64 +test.test_script_helper.TestScriptHelper.test_assert_python_failure_raises @ linux-x86_64 +test.test_script_helper.TestScriptHelper.test_assert_python_isolated_when_env_not_required @ linux-x86_64 +test.test_script_helper.TestScriptHelper.test_assert_python_not_isolated_when_env_is_required @ linux-x86_64 +test.test_script_helper.TestScriptHelper.test_assert_python_ok @ linux-x86_64 +test.test_script_helper.TestScriptHelper.test_assert_python_ok_raises @ linux-x86_64 +test.test_script_helper.TestScriptHelperEnvironment.test_interpreter_requires_environment_details @ linux-x86_64 +test.test_script_helper.TestScriptHelperEnvironment.test_interpreter_requires_environment_false @ linux-x86_64 +test.test_script_helper.TestScriptHelperEnvironment.test_interpreter_requires_environment_true @ linux-x86_64 +test.test_script_helper.TestScriptHelperEnvironment.test_interpreter_requires_environment_with_pythonhome @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_secrets.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_secrets.txt new file mode 100644 index 0000000000..b10c80f1b9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_secrets.txt @@ -0,0 +1,11 @@ +test.test_secrets.Compare_Digest_Tests.test_bad_types @ linux-x86_64 +test.test_secrets.Compare_Digest_Tests.test_bool @ linux-x86_64 +test.test_secrets.Compare_Digest_Tests.test_equal @ linux-x86_64 +test.test_secrets.Compare_Digest_Tests.test_unequal @ linux-x86_64 +test.test_secrets.Random_Tests.test_choice @ linux-x86_64 +test.test_secrets.Random_Tests.test_randbelow @ linux-x86_64 +test.test_secrets.Random_Tests.test_randbits @ linux-x86_64 +test.test_secrets.Token_Tests.test_token_bytes @ linux-x86_64 +test.test_secrets.Token_Tests.test_token_defaults @ linux-x86_64 +test.test_secrets.Token_Tests.test_token_hex @ linux-x86_64 +test.test_secrets.Token_Tests.test_token_urlsafe @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_select.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_select.txt new file mode 100644 index 0000000000..878072b3cb --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_select.txt @@ -0,0 +1,4 @@ +test.test_select.SelectTestCase.test_errno @ linux-x86_64 +test.test_select.SelectTestCase.test_error_conditions @ linux-x86_64 +test.test_select.SelectTestCase.test_returned_list_identity @ linux-x86_64 +test.test_select.SelectTestCase.test_select_mutated @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_selectors.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_selectors.txt new file mode 100644 index 0000000000..52f57b21e0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_selectors.txt @@ -0,0 +1,34 @@ +test.test_selectors.DefaultSelectorTestCase.test_close @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_context_manager @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_empty_select @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_fileno @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_get_key @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_get_map @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_modify @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_register @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_select @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_select_interrupt_noraise @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_select_read_write @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_selector @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_timeout @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_unregister @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_unregister_after_fd_close @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_unregister_after_fd_close_and_reuse @ linux-x86_64 +test.test_selectors.DefaultSelectorTestCase.test_unregister_after_socket_close @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_close @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_context_manager @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_empty_select @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_fileno @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_get_key @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_get_map @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_modify @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_register @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_select @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_select_interrupt_noraise @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_select_read_write @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_selector @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_timeout @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_unregister @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_unregister_after_fd_close @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_unregister_after_fd_close_and_reuse @ linux-x86_64 +test.test_selectors.SelectSelectorTestCase.test_unregister_after_socket_close @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_set.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_set.txt new file mode 100644 index 0000000000..94d682776b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_set.txt @@ -0,0 +1,486 @@ +test.test_set.TestBasicOpsBytes.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_length @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsBytes.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_length @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsEmpty.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_length @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsMixedStringBytes.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_in @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_length @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_not_in @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsSingleton.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsString.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsString.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsString.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsString.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsString.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsString.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsString.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsString.test_length @ linux-x86_64 +test.test_set.TestBasicOpsString.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsString.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsString.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsString.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_length @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsTriple.test_union_empty @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_copy @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_difference @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_difference_rev @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_intersection @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_empty_union @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_equivalent_equality @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_in @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_intersection_empty @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_isdisjoint_empty @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_issue_37219 @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_iteration @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_length @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_not_in @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_pickling @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_repr @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_difference @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_equality @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_intersection @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_isdisjoint @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_symmetric_difference @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_self_union @ linux-x86_64 +test.test_set.TestBasicOpsTuple.test_union_empty @ linux-x86_64 +test.test_set.TestBinaryOps.test_eq @ linux-x86_64 +test.test_set.TestBinaryOps.test_intersection_non_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_intersection_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_intersection_subset @ linux-x86_64 +test.test_set.TestBinaryOps.test_intersection_superset @ linux-x86_64 +test.test_set.TestBinaryOps.test_isdisjoint_non_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_isdisjoint_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_isdisjoint_subset @ linux-x86_64 +test.test_set.TestBinaryOps.test_isdisjoint_superset @ linux-x86_64 +test.test_set.TestBinaryOps.test_sym_difference_non_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_sym_difference_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_sym_difference_subset @ linux-x86_64 +test.test_set.TestBinaryOps.test_sym_difference_superset @ linux-x86_64 +test.test_set.TestBinaryOps.test_union_non_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_union_overlap @ linux-x86_64 +test.test_set.TestBinaryOps.test_union_subset @ linux-x86_64 +test.test_set.TestBinaryOps.test_union_superset @ linux-x86_64 +test.test_set.TestCopyingEmpty.test_copy @ linux-x86_64 +test.test_set.TestCopyingEmpty.test_deep_copy @ linux-x86_64 +test.test_set.TestCopyingNested.test_copy @ linux-x86_64 +test.test_set.TestCopyingNested.test_deep_copy @ linux-x86_64 +test.test_set.TestCopyingSingleton.test_copy @ linux-x86_64 +test.test_set.TestCopyingSingleton.test_deep_copy @ linux-x86_64 +test.test_set.TestCopyingTriple.test_copy @ linux-x86_64 +test.test_set.TestCopyingTriple.test_deep_copy @ linux-x86_64 +test.test_set.TestCopyingTuple.test_copy @ linux-x86_64 +test.test_set.TestCopyingTuple.test_deep_copy @ linux-x86_64 +test.test_set.TestExceptionPropagation.test_changingSizeWhileIterating @ linux-x86_64 +test.test_set.TestExceptionPropagation.test_instanceWithException @ linux-x86_64 +test.test_set.TestExceptionPropagation.test_instancesWithoutException @ linux-x86_64 +test.test_set.TestFrozenSet.test_and @ linux-x86_64 +test.test_set.TestFrozenSet.test_badcmp @ linux-x86_64 +test.test_set.TestFrozenSet.test_constructor_identity @ linux-x86_64 +test.test_set.TestFrozenSet.test_contains @ linux-x86_64 +test.test_set.TestFrozenSet.test_copy @ linux-x86_64 +test.test_set.TestFrozenSet.test_cyclical_repr @ linux-x86_64 +test.test_set.TestFrozenSet.test_deepcopy @ linux-x86_64 +test.test_set.TestFrozenSet.test_difference @ linux-x86_64 +test.test_set.TestFrozenSet.test_do_not_rehash_dict_keys @ linux-x86_64 +test.test_set.TestFrozenSet.test_equality @ linux-x86_64 +test.test_set.TestFrozenSet.test_frozen_as_dictkey @ linux-x86_64 +test.test_set.TestFrozenSet.test_gc @ linux-x86_64 +test.test_set.TestFrozenSet.test_hash @ linux-x86_64 +test.test_set.TestFrozenSet.test_hash_caching @ linux-x86_64 +test.test_set.TestFrozenSet.test_hash_effectiveness @ linux-x86_64 +test.test_set.TestFrozenSet.test_init @ linux-x86_64 +test.test_set.TestFrozenSet.test_intersection @ linux-x86_64 +test.test_set.TestFrozenSet.test_isdisjoint @ linux-x86_64 +test.test_set.TestFrozenSet.test_iterator_pickling @ linux-x86_64 +test.test_set.TestFrozenSet.test_len @ linux-x86_64 +test.test_set.TestFrozenSet.test_new_or_init @ linux-x86_64 +test.test_set.TestFrozenSet.test_or @ linux-x86_64 +test.test_set.TestFrozenSet.test_pickling @ linux-x86_64 +test.test_set.TestFrozenSet.test_setOfFrozensets @ linux-x86_64 +test.test_set.TestFrozenSet.test_sub @ linux-x86_64 +test.test_set.TestFrozenSet.test_sub_and_super @ linux-x86_64 +test.test_set.TestFrozenSet.test_subclass_with_custom_hash @ linux-x86_64 +test.test_set.TestFrozenSet.test_symmetric_difference @ linux-x86_64 +test.test_set.TestFrozenSet.test_union @ linux-x86_64 +test.test_set.TestFrozenSet.test_uniquification @ linux-x86_64 +test.test_set.TestFrozenSet.test_xor @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_and @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_badcmp @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_constructor_identity @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_contains @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_copy @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_cyclical_repr @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_deepcopy @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_difference @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_do_not_rehash_dict_keys @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_equality @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_frozen_as_dictkey @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_gc @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_hash @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_hash_caching @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_hash_effectiveness @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_init @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_intersection @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_isdisjoint @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_iterator_pickling @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_len @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_nested_empty_constructor @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_new_or_init @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_or @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_pickling @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_setOfFrozensets @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_singleton_empty_frozenset @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_sub @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_sub_and_super @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_subclass_with_custom_hash @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_symmetric_difference @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_union @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_uniquification @ linux-x86_64 +test.test_set.TestFrozenSetSubclass.test_xor @ linux-x86_64 +test.test_set.TestFrozenSetSubclassWithSlots.test_pickling @ linux-x86_64 +test.test_set.TestGraphs.test_cube @ linux-x86_64 +test.test_set.TestGraphs.test_cuboctahedron @ linux-x86_64 +test.test_set.TestIdentities.test_binopsVsSubsets @ linux-x86_64 +test.test_set.TestIdentities.test_commutativity @ linux-x86_64 +test.test_set.TestIdentities.test_exclusion @ linux-x86_64 +test.test_set.TestIdentities.test_summations @ linux-x86_64 +test.test_set.TestMutate.test_add_absent @ linux-x86_64 +test.test_set.TestMutate.test_add_present @ linux-x86_64 +test.test_set.TestMutate.test_add_until_full @ linux-x86_64 +test.test_set.TestMutate.test_clear @ linux-x86_64 +test.test_set.TestMutate.test_discard_absent @ linux-x86_64 +test.test_set.TestMutate.test_discard_present @ linux-x86_64 +test.test_set.TestMutate.test_pop @ linux-x86_64 +test.test_set.TestMutate.test_remove_absent @ linux-x86_64 +test.test_set.TestMutate.test_remove_present @ linux-x86_64 +test.test_set.TestMutate.test_remove_until_empty @ linux-x86_64 +test.test_set.TestMutate.test_update_empty_tuple @ linux-x86_64 +test.test_set.TestMutate.test_update_unit_tuple_non_overlap @ linux-x86_64 +test.test_set.TestMutate.test_update_unit_tuple_overlap @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_union @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_update @ linux-x86_64 +test.test_set.TestOnlySetsDict.test_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_union @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_update @ linux-x86_64 +test.test_set.TestOnlySetsGenerator.test_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_union @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_update @ linux-x86_64 +test.test_set.TestOnlySetsNumeric.test_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_union @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_update @ linux-x86_64 +test.test_set.TestOnlySetsOperator.test_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsString.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsString.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsString.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsString.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsString.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsString.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsString.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsString.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsString.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsString.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsString.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsString.test_union @ linux-x86_64 +test.test_set.TestOnlySetsString.test_update @ linux-x86_64 +test.test_set.TestOnlySetsString.test_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_difference @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_eq_ne @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_ge_gt_le_lt @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_intersection @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_intersection_update @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_intersection_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_sym_difference @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_sym_difference_update @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_sym_difference_update_operator @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_union @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_update @ linux-x86_64 +test.test_set.TestOnlySetsTuple.test_update_operator @ linux-x86_64 +test.test_set.TestSet.test_add @ linux-x86_64 +test.test_set.TestSet.test_and @ linux-x86_64 +test.test_set.TestSet.test_badcmp @ linux-x86_64 +test.test_set.TestSet.test_clear @ linux-x86_64 +test.test_set.TestSet.test_constructor_identity @ linux-x86_64 +test.test_set.TestSet.test_contains @ linux-x86_64 +test.test_set.TestSet.test_copy @ linux-x86_64 +test.test_set.TestSet.test_cyclical_repr @ linux-x86_64 +test.test_set.TestSet.test_deepcopy @ linux-x86_64 +test.test_set.TestSet.test_difference @ linux-x86_64 +test.test_set.TestSet.test_difference_update @ linux-x86_64 +test.test_set.TestSet.test_discard @ linux-x86_64 +test.test_set.TestSet.test_do_not_rehash_dict_keys @ linux-x86_64 +test.test_set.TestSet.test_equality @ linux-x86_64 +test.test_set.TestSet.test_gc @ linux-x86_64 +test.test_set.TestSet.test_hash @ linux-x86_64 +test.test_set.TestSet.test_iand @ linux-x86_64 +test.test_set.TestSet.test_init @ linux-x86_64 +test.test_set.TestSet.test_inplace_on_self @ linux-x86_64 +test.test_set.TestSet.test_intersection @ linux-x86_64 +test.test_set.TestSet.test_intersection_update @ linux-x86_64 +test.test_set.TestSet.test_ior @ linux-x86_64 +test.test_set.TestSet.test_isdisjoint @ linux-x86_64 +test.test_set.TestSet.test_isub @ linux-x86_64 +test.test_set.TestSet.test_iterator_pickling @ linux-x86_64 +test.test_set.TestSet.test_ixor @ linux-x86_64 +test.test_set.TestSet.test_len @ linux-x86_64 +test.test_set.TestSet.test_new_or_init @ linux-x86_64 +test.test_set.TestSet.test_or @ linux-x86_64 +test.test_set.TestSet.test_pickling @ linux-x86_64 +test.test_set.TestSet.test_pop @ linux-x86_64 +test.test_set.TestSet.test_remove @ linux-x86_64 +test.test_set.TestSet.test_remove_keyerror_set @ linux-x86_64 +test.test_set.TestSet.test_remove_keyerror_unpacking @ linux-x86_64 +test.test_set.TestSet.test_rich_compare @ linux-x86_64 +test.test_set.TestSet.test_setOfFrozensets @ linux-x86_64 +test.test_set.TestSet.test_set_literal @ linux-x86_64 +test.test_set.TestSet.test_set_literal_evaluation_order @ linux-x86_64 +test.test_set.TestSet.test_set_literal_insertion_order @ linux-x86_64 +test.test_set.TestSet.test_sub @ linux-x86_64 +test.test_set.TestSet.test_sub_and_super @ linux-x86_64 +test.test_set.TestSet.test_subclass_with_custom_hash @ linux-x86_64 +test.test_set.TestSet.test_symmetric_difference @ linux-x86_64 +test.test_set.TestSet.test_symmetric_difference_update @ linux-x86_64 +test.test_set.TestSet.test_union @ linux-x86_64 +test.test_set.TestSet.test_uniquification @ linux-x86_64 +test.test_set.TestSet.test_update @ linux-x86_64 +test.test_set.TestSet.test_xor @ linux-x86_64 +test.test_set.TestSetOfSets.test_constructor @ linux-x86_64 +test.test_set.TestSetSubclass.test_add @ linux-x86_64 +test.test_set.TestSetSubclass.test_and @ linux-x86_64 +test.test_set.TestSetSubclass.test_badcmp @ linux-x86_64 +test.test_set.TestSetSubclass.test_clear @ linux-x86_64 +test.test_set.TestSetSubclass.test_constructor_identity @ linux-x86_64 +test.test_set.TestSetSubclass.test_contains @ linux-x86_64 +test.test_set.TestSetSubclass.test_copy @ linux-x86_64 +test.test_set.TestSetSubclass.test_cyclical_repr @ linux-x86_64 +test.test_set.TestSetSubclass.test_deepcopy @ linux-x86_64 +test.test_set.TestSetSubclass.test_difference @ linux-x86_64 +test.test_set.TestSetSubclass.test_difference_update @ linux-x86_64 +test.test_set.TestSetSubclass.test_discard @ linux-x86_64 +test.test_set.TestSetSubclass.test_do_not_rehash_dict_keys @ linux-x86_64 +test.test_set.TestSetSubclass.test_equality @ linux-x86_64 +test.test_set.TestSetSubclass.test_gc @ linux-x86_64 +test.test_set.TestSetSubclass.test_hash @ linux-x86_64 +test.test_set.TestSetSubclass.test_iand @ linux-x86_64 +test.test_set.TestSetSubclass.test_init @ linux-x86_64 +test.test_set.TestSetSubclass.test_inplace_on_self @ linux-x86_64 +test.test_set.TestSetSubclass.test_intersection @ linux-x86_64 +test.test_set.TestSetSubclass.test_intersection_update @ linux-x86_64 +test.test_set.TestSetSubclass.test_ior @ linux-x86_64 +test.test_set.TestSetSubclass.test_isdisjoint @ linux-x86_64 +test.test_set.TestSetSubclass.test_isub @ linux-x86_64 +test.test_set.TestSetSubclass.test_iterator_pickling @ linux-x86_64 +test.test_set.TestSetSubclass.test_ixor @ linux-x86_64 +test.test_set.TestSetSubclass.test_keywords_in_subclass @ linux-x86_64 +test.test_set.TestSetSubclass.test_len @ linux-x86_64 +test.test_set.TestSetSubclass.test_new_or_init @ linux-x86_64 +test.test_set.TestSetSubclass.test_or @ linux-x86_64 +test.test_set.TestSetSubclass.test_pickling @ linux-x86_64 +test.test_set.TestSetSubclass.test_pop @ linux-x86_64 +test.test_set.TestSetSubclass.test_remove @ linux-x86_64 +test.test_set.TestSetSubclass.test_remove_keyerror_set @ linux-x86_64 +test.test_set.TestSetSubclass.test_remove_keyerror_unpacking @ linux-x86_64 +test.test_set.TestSetSubclass.test_rich_compare @ linux-x86_64 +test.test_set.TestSetSubclass.test_setOfFrozensets @ linux-x86_64 +test.test_set.TestSetSubclass.test_set_literal @ linux-x86_64 +test.test_set.TestSetSubclass.test_set_literal_evaluation_order @ linux-x86_64 +test.test_set.TestSetSubclass.test_set_literal_insertion_order @ linux-x86_64 +test.test_set.TestSetSubclass.test_sub @ linux-x86_64 +test.test_set.TestSetSubclass.test_sub_and_super @ linux-x86_64 +test.test_set.TestSetSubclass.test_subclass_with_custom_hash @ linux-x86_64 +test.test_set.TestSetSubclass.test_symmetric_difference @ linux-x86_64 +test.test_set.TestSetSubclass.test_symmetric_difference_update @ linux-x86_64 +test.test_set.TestSetSubclass.test_union @ linux-x86_64 +test.test_set.TestSetSubclass.test_uniquification @ linux-x86_64 +test.test_set.TestSetSubclass.test_update @ linux-x86_64 +test.test_set.TestSetSubclass.test_xor @ linux-x86_64 +test.test_set.TestSetSubclassWithSlots.test_pickling @ linux-x86_64 +test.test_set.TestSubsetEmptyNonEmpty.test_issubset @ linux-x86_64 +test.test_set.TestSubsetEqualEmpty.test_issubset @ linux-x86_64 +test.test_set.TestSubsetEqualNonEmpty.test_issubset @ linux-x86_64 +test.test_set.TestSubsetNonOverlap.test_issubset @ linux-x86_64 +test.test_set.TestSubsetPartial.test_issubset @ linux-x86_64 +test.test_set.TestUpdateOps.test_difference_method_call @ linux-x86_64 +test.test_set.TestUpdateOps.test_difference_non_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_difference_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_difference_subset @ linux-x86_64 +test.test_set.TestUpdateOps.test_difference_superset @ linux-x86_64 +test.test_set.TestUpdateOps.test_intersection_method_call @ linux-x86_64 +test.test_set.TestUpdateOps.test_intersection_non_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_intersection_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_intersection_subset @ linux-x86_64 +test.test_set.TestUpdateOps.test_intersection_superset @ linux-x86_64 +test.test_set.TestUpdateOps.test_sym_difference_method_call @ linux-x86_64 +test.test_set.TestUpdateOps.test_sym_difference_non_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_sym_difference_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_sym_difference_subset @ linux-x86_64 +test.test_set.TestUpdateOps.test_sym_difference_superset @ linux-x86_64 +test.test_set.TestUpdateOps.test_union_method_call @ linux-x86_64 +test.test_set.TestUpdateOps.test_union_non_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_union_overlap @ linux-x86_64 +test.test_set.TestUpdateOps.test_union_subset @ linux-x86_64 +test.test_set.TestUpdateOps.test_union_superset @ linux-x86_64 +test.test_set.TestVariousIteratorArgs.test_constructor @ linux-x86_64 +test.test_set.TestVariousIteratorArgs.test_inline_methods @ linux-x86_64 +test.test_set.TestVariousIteratorArgs.test_inplace_methods @ linux-x86_64 +test.test_set.TestWeirdBugs.test_8420_set_merge @ linux-x86_64 +test.test_set.TestWeirdBugs.test_iter_and_mutate @ linux-x86_64 +test.test_set.TestWeirdBugs.test_merge_and_mutate @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_setcomps.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_setcomps.txt new file mode 100644 index 0000000000..f8ef442fba --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_setcomps.txt @@ -0,0 +1 @@ +DocTestCase.test.test_setcomps.__test__.doctests @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shelve.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shelve.txt new file mode 100644 index 0000000000..78ac459080 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shelve.txt @@ -0,0 +1,182 @@ +test.test_shelve.TestCase.test_ascii_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_binary_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_bytes_path_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_close @ linux-x86_64 +test.test_shelve.TestCase.test_default_protocol @ linux-x86_64 +test.test_shelve.TestCase.test_in_memory_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_keyencoding @ linux-x86_64 +test.test_shelve.TestCase.test_mutable_entry @ linux-x86_64 +test.test_shelve.TestCase.test_open_template @ linux-x86_64 +test.test_shelve.TestCase.test_pathlib_bytes_path_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_pathlib_path_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_proto2_file_shelf @ linux-x86_64 +test.test_shelve.TestCase.test_with @ linux-x86_64 +test.test_shelve.TestCase.test_writeback_also_writes_immediately @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto0File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto0MemShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto1File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto1MemShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto2File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto2MemShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto3File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto3MemShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto4File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto4MemShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto5File_dumbShelve.test_write @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_bool @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_constructor @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_get @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_getitem @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_items @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_keys @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_len @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_pop @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_popitem @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_read @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_setdefault @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_update @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_values @ linux-x86_64 +test.test_shelve.TestProto5MemShelve.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shlex.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shlex.txt new file mode 100644 index 0000000000..764d525fd5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shlex.txt @@ -0,0 +1,18 @@ +test.test_shlex.ShlexTest.testCompat @ linux-x86_64 +test.test_shlex.ShlexTest.testEmptyStringHandling @ linux-x86_64 +test.test_shlex.ShlexTest.testJoin @ linux-x86_64 +test.test_shlex.ShlexTest.testJoinRoundtrip @ linux-x86_64 +test.test_shlex.ShlexTest.testPunctuationCharsReadOnly @ linux-x86_64 +test.test_shlex.ShlexTest.testPunctuationInWordChars @ linux-x86_64 +test.test_shlex.ShlexTest.testPunctuationWithPosix @ linux-x86_64 +test.test_shlex.ShlexTest.testPunctuationWithWhitespaceSplit @ linux-x86_64 +test.test_shlex.ShlexTest.testQuote @ linux-x86_64 +test.test_shlex.ShlexTest.testSplitNoneDeprecation @ linux-x86_64 +test.test_shlex.ShlexTest.testSplitPosix @ linux-x86_64 +test.test_shlex.ShlexTest.testSyntaxSplitAmpersandAndPipe @ linux-x86_64 +test.test_shlex.ShlexTest.testSyntaxSplitCustom @ linux-x86_64 +test.test_shlex.ShlexTest.testSyntaxSplitParen @ linux-x86_64 +test.test_shlex.ShlexTest.testSyntaxSplitRedirect @ linux-x86_64 +test.test_shlex.ShlexTest.testSyntaxSplitSemicolon @ linux-x86_64 +test.test_shlex.ShlexTest.testTokenTypes @ linux-x86_64 +test.test_shlex.ShlexTest.testUnicodeHandling @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shutil.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shutil.txt new file mode 100644 index 0000000000..a3f4758b9d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_shutil.txt @@ -0,0 +1,122 @@ +test.test_shutil.PublicAPITests.test_module_all_attribute @ linux-x86_64 +test.test_shutil.TestArchives.test_make_archive @ linux-x86_64 +test.test_shutil.TestArchives.test_make_archive_cwd @ linux-x86_64 +test.test_shutil.TestArchives.test_make_archive_owner_group @ linux-x86_64 +test.test_shutil.TestArchives.test_make_tarball @ linux-x86_64 +test.test_shutil.TestArchives.test_make_tarfile_in_curdir @ linux-x86_64 +test.test_shutil.TestArchives.test_make_tarfile_rootdir_nodir @ linux-x86_64 +test.test_shutil.TestArchives.test_make_zipfile @ linux-x86_64 +test.test_shutil.TestArchives.test_make_zipfile_in_curdir @ linux-x86_64 +test.test_shutil.TestArchives.test_make_zipfile_rootdir_nodir @ linux-x86_64 +test.test_shutil.TestArchives.test_register_archive_format @ linux-x86_64 +test.test_shutil.TestArchives.test_tarfile_vs_tar @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_archive_bztar @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_archive_gztar @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_archive_tar @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_archive_xztar @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_archive_zip @ linux-x86_64 +test.test_shutil.TestArchives.test_unpack_registry @ linux-x86_64 +test.test_shutil.TestArchives.test_unzip_zipfile @ linux-x86_64 +test.test_shutil.TestArchives.test_zipfile_vs_zip @ linux-x86_64 +test.test_shutil.TestCopy.test_copy @ linux-x86_64 +test.test_shutil.TestCopy.test_copy2 @ linux-x86_64 +test.test_shutil.TestCopy.test_copy2_dir @ linux-x86_64 +test.test_shutil.TestCopy.test_copy2_symlinks @ linux-x86_64 +test.test_shutil.TestCopy.test_copy_dir @ linux-x86_64 +test.test_shutil.TestCopy.test_copy_return_value @ linux-x86_64 +test.test_shutil.TestCopy.test_copy_symlinks @ linux-x86_64 +test.test_shutil.TestCopy.test_copyfile_copy_dir @ linux-x86_64 +test.test_shutil.TestCopy.test_copyfile_nonexistent_dir @ linux-x86_64 +test.test_shutil.TestCopy.test_copyfile_return_value @ linux-x86_64 +test.test_shutil.TestCopy.test_copyfile_same_file @ linux-x86_64 +test.test_shutil.TestCopy.test_copyfile_symlinks @ linux-x86_64 +test.test_shutil.TestCopy.test_copymode_follow_symlinks @ linux-x86_64 +test.test_shutil.TestCopy.test_copymode_symlink_to_symlink_wo_lchmod @ linux-x86_64 +test.test_shutil.TestCopy.test_copystat_symlinks @ linux-x86_64 +test.test_shutil.TestCopy.test_dont_copy_file_onto_link_to_itself @ linux-x86_64 +test.test_shutil.TestCopy.test_dont_copy_file_onto_symlink_to_itself @ linux-x86_64 +test.test_shutil.TestCopyFile.test_w_dest_close_fails @ linux-x86_64 +test.test_shutil.TestCopyFile.test_w_dest_open_fails @ linux-x86_64 +test.test_shutil.TestCopyFile.test_w_source_close_fails @ linux-x86_64 +test.test_shutil.TestCopyFile.test_w_source_open_fails @ linux-x86_64 +test.test_shutil.TestCopyFileObj.test_content @ linux-x86_64 +test.test_shutil.TestCopyFileObj.test_file_not_closed @ linux-x86_64 +test.test_shutil.TestCopyFileObj.test_file_offset @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_arg_types_of_ignore @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_custom_copy_function @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_dangling_symlinks @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_dirs_exist_ok @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_retains_permissions @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_return_value @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_simple @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_special_func @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_subdirectory @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_symlink_dir @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_symlinks @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_winerror @ linux-x86_64 +test.test_shutil.TestCopyTree.test_copytree_with_exclude @ linux-x86_64 +test.test_shutil.TestGetTerminalSize.test_bad_environ @ linux-x86_64 +test.test_shutil.TestGetTerminalSize.test_does_not_crash @ linux-x86_64 +test.test_shutil.TestGetTerminalSize.test_fallback @ linux-x86_64 +test.test_shutil.TestGetTerminalSize.test_os_environ_first @ linux-x86_64 +test.test_shutil.TestMisc.test_disk_usage @ linux-x86_64 +test.test_shutil.TestMove.test_destinsrc_false_negative @ linux-x86_64 +test.test_shutil.TestMove.test_destinsrc_false_positive @ linux-x86_64 +test.test_shutil.TestMove.test_dont_move_dir_in_itself @ linux-x86_64 +test.test_shutil.TestMove.test_existing_file_inside_dest_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_as_rename_return_value @ linux-x86_64 +test.test_shutil.TestMove.test_move_dangling_symlink @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_caseinsensitive @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_other_fs @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_sep_to_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_special_function @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_symlink @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_to_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_dir_to_dir_other_fs @ linux-x86_64 +test.test_shutil.TestMove.test_move_file @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_other_fs @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_special_function @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_symlink @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_symlink_to_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_to_dir @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_to_dir_other_fs @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_to_dir_pathlike_dst @ linux-x86_64 +test.test_shutil.TestMove.test_move_file_to_dir_pathlike_src @ linux-x86_64 +test.test_shutil.TestMove.test_move_return_value @ linux-x86_64 +test.test_shutil.TestRmTree.test_on_error @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_does_not_choke_on_failing_lstat @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_dont_delete_file @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_errors @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_fails_on_symlink @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_on_symlink @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_uses_safe_fd_version_if_available @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_with_dir_fd @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_works_on_bytes @ linux-x86_64 +test.test_shutil.TestRmTree.test_rmtree_works_on_symlinks @ linux-x86_64 +test.test_shutil.TestWhich.test_absolute_cmd @ linux-x86_64 +test.test_shutil.TestWhich.test_basic @ linux-x86_64 +test.test_shutil.TestWhich.test_cwd @ linux-x86_64 +test.test_shutil.TestWhich.test_empty_path @ linux-x86_64 +test.test_shutil.TestWhich.test_empty_path_no_PATH @ linux-x86_64 +test.test_shutil.TestWhich.test_environ_path @ linux-x86_64 +test.test_shutil.TestWhich.test_environ_path_cwd @ linux-x86_64 +test.test_shutil.TestWhich.test_environ_path_empty @ linux-x86_64 +test.test_shutil.TestWhich.test_environ_path_missing @ linux-x86_64 +test.test_shutil.TestWhich.test_non_matching_mode @ linux-x86_64 +test.test_shutil.TestWhich.test_nonexistent_file @ linux-x86_64 +test.test_shutil.TestWhich.test_relative_cmd @ linux-x86_64 +test.test_shutil.TestWhich.test_relative_path @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_absolute_cmd @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_basic @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_cwd @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_empty_path @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_empty_path_no_PATH @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_environ_path @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_environ_path_cwd @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_environ_path_empty @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_environ_path_missing @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_non_matching_mode @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_nonexistent_file @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_relative_cmd @ linux-x86_64 +test.test_shutil.TestWhichBytes.test_relative_path @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_signal.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_signal.txt new file mode 100644 index 0000000000..1325360e70 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_signal.txt @@ -0,0 +1,7 @@ +test.test_signal.GenericTests.test_enums @ linux-x86_64 +test.test_signal.GenericTests.test_functions_module_attr @ linux-x86_64 +test.test_signal.ItimerTest.test_setitimer_tiny @ linux-x86_64 +test.test_signal.PosixTests.test_getsignal @ linux-x86_64 +test.test_signal.PosixTests.test_setting_signal_handler_to_none_raises_error @ linux-x86_64 +test.test_signal.PosixTests.test_valid_signals @ linux-x86_64 +test.test_signal.SiginterruptTest.test_siginterrupt_off @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_site.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_site.txt new file mode 100644 index 0000000000..6439b71adf --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_site.txt @@ -0,0 +1,26 @@ +test.test_site.HelperFunctionsTests.test__getuserbase @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addpackage @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addpackage_empty_lines @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addpackage_import_bad_exec @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addpackage_import_bad_pth_file @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addpackage_import_bad_syntax @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_addsitedir @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_get_path @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_getsitepackages @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_getuserbase @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_getusersitepackages @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_init_pathinfo @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_makepath @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_no_home_directory @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_s_option @ linux-x86_64 +test.test_site.HelperFunctionsTests.test_trace @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_abs_paths_cached_None @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_license_exists_at_url @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_no_duplicate_paths @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_setting_copyright @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_setting_help @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_setting_quit @ linux-x86_64 +test.test_site.ImportSideEffectTests.test_sitecustomize_executed @ linux-x86_64 +test.test_site.StartupImportTests.test_startup_interactivehook @ linux-x86_64 +test.test_site.StartupImportTests.test_startup_interactivehook_isolated @ linux-x86_64 +test.test_site.StartupImportTests.test_startup_interactivehook_isolated_explicit @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_slice.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_slice.txt new file mode 100644 index 0000000000..1fa0f1150d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_slice.txt @@ -0,0 +1,10 @@ +test.test_slice.SliceTest.test_cmp @ linux-x86_64 +test.test_slice.SliceTest.test_constructor @ linux-x86_64 +test.test_slice.SliceTest.test_copy @ linux-x86_64 +test.test_slice.SliceTest.test_deepcopy @ linux-x86_64 +test.test_slice.SliceTest.test_hash @ linux-x86_64 +test.test_slice.SliceTest.test_indices @ linux-x86_64 +test.test_slice.SliceTest.test_members @ linux-x86_64 +test.test_slice.SliceTest.test_pickle @ linux-x86_64 +test.test_slice.SliceTest.test_repr @ linux-x86_64 +test.test_slice.SliceTest.test_setslice_without_getslice @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtpd.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtpd.txt new file mode 100644 index 0000000000..ca22feab86 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtpd.txt @@ -0,0 +1,153 @@ +test.test_smtpd.DebuggingServerTest.test_process_SMTPUTF8_message_with_enable_SMTPUTF8_true @ linux-x86_64 +test.test_smtpd.DebuggingServerTest.test_process_message_with_decode_data_false @ linux-x86_64 +test.test_smtpd.DebuggingServerTest.test_process_message_with_decode_data_true @ linux-x86_64 +test.test_smtpd.DebuggingServerTest.test_process_message_with_enable_SMTPUTF8_true @ linux-x86_64 +test.test_smtpd.MiscTestCase.test__all__ @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_DATA_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_EHLO_HELO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_EHLO_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_EHLO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_EXPN_not_implemented @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_EHLO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_NOOP @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_QUIT @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_RSET @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELO_parameter_rejected_when_extensions_not_enabled @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELP @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELP_command @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_HELP_command_unknown @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_RCPT_unknown_parameters @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_allows_space_after_colon @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_chevrons @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_command_limit_extended_with_SIZE @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_command_rejects_SMTPUTF8_by_default @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_empty_chevrons @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_invalid_size_parameter @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_missing_address @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_quoted_localpart @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_quoted_localpart_no_angles @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_quoted_localpart_with_size @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_quoted_localpart_with_size_no_angles @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_size_parameter @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_size_parameter_larger_than_default_data_size_limit @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_syntax_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_MAIL_syntax_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_NOOP @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_NOOP_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_QUIT @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_QUIT_arg_ignored @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_RCPT_lowercase_to_OK @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_RCPT_syntax_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_RCPT_syntax_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_RSET @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_RSET_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_VRFY @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_VRFY_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_attribute_deprecations @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_bad_state @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_broken_connect @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_command_too_long @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_data_dialog @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_data_longer_than_default_data_size_limit @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_data_transparency_section_4_5_2 @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_decode_data_and_enable_SMTPUTF8_raises @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_extended_MAIL_allows_space_after_colon @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_manual_status @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_missing_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_multiple_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_need_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_need_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_nested_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_no_HELO_DATA @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_no_HELO_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_no_HELO_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_server_accept @ linux-x86_64 +test.test_smtpd.SMTPDChannelIPv6Test.test_unknown_command @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_DATA_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_EHLO_HELO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_EHLO_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_EHLO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_EXPN_not_implemented @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_EHLO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_NOOP @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_QUIT @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_RSET @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_duplicate @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELO_parameter_rejected_when_extensions_not_enabled @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELP @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELP_command @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_HELP_command_unknown @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_RCPT_unknown_parameters @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_allows_space_after_colon @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_chevrons @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_command_limit_extended_with_SIZE @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_command_rejects_SMTPUTF8_by_default @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_empty_chevrons @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_invalid_size_parameter @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_missing_address @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_quoted_localpart @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_quoted_localpart_no_angles @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_quoted_localpart_with_size @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_quoted_localpart_with_size_no_angles @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_size_parameter @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_size_parameter_larger_than_default_data_size_limit @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_syntax_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_MAIL_syntax_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_NOOP @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_NOOP_bad_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_QUIT @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_QUIT_arg_ignored @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_RCPT_lowercase_to_OK @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_RCPT_syntax_EHLO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_RCPT_syntax_HELO @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_RSET @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_RSET_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_VRFY @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_VRFY_syntax @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_attribute_deprecations @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_bad_state @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_broken_connect @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_command_too_long @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_data_dialog @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_data_longer_than_default_data_size_limit @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_data_transparency_section_4_5_2 @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_decode_data_and_enable_SMTPUTF8_raises @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_extended_MAIL_allows_space_after_colon @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_manual_status @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_missing_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_multiple_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_need_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_need_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_nested_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_no_HELO_DATA @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_no_HELO_MAIL @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_no_HELO_RCPT @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_server_accept @ linux-x86_64 +test.test_smtpd.SMTPDChannelTest.test_unknown_command @ linux-x86_64 +test.test_smtpd.SMTPDChannelTestWithEnableSMTPUTF8True.test_MAIL_command_accepts_SMTPUTF8_when_announced @ linux-x86_64 +test.test_smtpd.SMTPDChannelTestWithEnableSMTPUTF8True.test_MAIL_command_limit_extended_with_SIZE_and_SMTPUTF8 @ linux-x86_64 +test.test_smtpd.SMTPDChannelTestWithEnableSMTPUTF8True.test_multiple_emails_with_extended_command_length @ linux-x86_64 +test.test_smtpd.SMTPDChannelTestWithEnableSMTPUTF8True.test_process_smtputf8_message @ linux-x86_64 +test.test_smtpd.SMTPDChannelTestWithEnableSMTPUTF8True.test_utf8_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDataSizeLimitTest.test_data_limit_dialog @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDataSizeLimitTest.test_data_limit_dialog_too_much_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDecodeDataFalse.test_ascii_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDecodeDataFalse.test_utf8_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDecodeDataTrue.test_ascii_data @ linux-x86_64 +test.test_smtpd.SMTPDChannelWithDecodeDataTrue.test_utf8_data @ linux-x86_64 +test.test_smtpd.SMTPDServerTest.test_decode_data_and_enable_SMTPUTF8_raises @ linux-x86_64 +test.test_smtpd.SMTPDServerTest.test_process_message_unimplemented @ linux-x86_64 +test.test_smtpd.TestFamilyDetection.test_socket_uses_IPv4 @ linux-x86_64 +test.test_smtpd.TestFamilyDetection.test_socket_uses_IPv6 @ linux-x86_64 +test.test_smtpd.TestMailOptionParsing.test_with_decode_data_false @ linux-x86_64 +test.test_smtpd.TestMailOptionParsing.test_with_decode_data_true @ linux-x86_64 +test.test_smtpd.TestMailOptionParsing.test_with_enable_smtputf8_true @ linux-x86_64 +test.test_smtpd.TestRcptOptionParsing.test_nothing_accepted @ linux-x86_64 +test.test_smtpd.TestRcptOptionParsing.test_params_rejected @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtplib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtplib.txt new file mode 100644 index 0000000000..c5e3f75ed9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_smtplib.txt @@ -0,0 +1,82 @@ +test.test_smtplib.BadHELOServerTests.testFailingHELO @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testBasic @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testELHO @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testEXPNNotImplemented @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testHELP @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testNOOP @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testRSET @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSecondHELO @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSend @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendBinary @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessage @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageMultipleResentRaises @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageResent @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageWithAddresses @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageWithMultipleFrom @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageWithSomeAddresses @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendMessageWithSpecifiedAddresses @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendNeedingDotQuote @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSendNullSender @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testSourceAddress @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.testVRFY @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.test_issue43124_escape_localhostname @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.test_issue43124_escape_options @ linux-x86_64 +test.test_smtplib.DebuggingServerTests.test_issue43124_putcmd_escapes_newline @ linux-x86_64 +test.test_smtplib.DefaultArgumentsTests.testSendMessage @ linux-x86_64 +test.test_smtplib.DefaultArgumentsTests.testSendMessageWithMailOptions @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testBasic1 @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testBasic2 @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testLocalHostName @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testQuoteData @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testSourceAddress @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testTimeoutDefault @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testTimeoutNone @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testTimeoutValue @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testTimeoutZero @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.testUnixDomainSocketTimeoutDefault @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.test_debuglevel @ linux-x86_64 +test.test_smtplib.LMTPGeneralTests.test_debuglevel_2 @ linux-x86_64 +test.test_smtplib.NonConnectingTests.testNonnumericPort @ linux-x86_64 +test.test_smtplib.NonConnectingTests.testNotConnected @ linux-x86_64 +test.test_smtplib.NonConnectingTests.testSockAttributeExists @ linux-x86_64 +test.test_smtplib.SMTPAUTHInitialResponseSimTests.testAUTH_PLAIN_initial_response_auth @ linux-x86_64 +test.test_smtplib.SMTPAUTHInitialResponseSimTests.testAUTH_PLAIN_initial_response_login @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testBasic1 @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testBasic2 @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testLocalHostName @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testQuoteData @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testSourceAddress @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testTimeoutDefault @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testTimeoutNone @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testTimeoutValue @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.testTimeoutZero @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.test_debuglevel @ linux-x86_64 +test.test_smtplib.SMTPGeneralTests.test_debuglevel_2 @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_BUGGY @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_CRAM_MD5 @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_LOGIN @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_LOGIN_initial_response_notok @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_LOGIN_initial_response_ok @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_PLAIN @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testAUTH_multiple @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testBasic @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testEHLO @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testEXPN @ linux-x86_64 +test.test_smtplib.SMTPSimTests.testVRFY @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_421_from_data_cmd @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_421_from_mail_cmd @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_421_from_rcpt_cmd @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test__rest_from_mail_cmd @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_auth_function @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_name_field_not_included_in_envelop_addresses @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_quit_resets_greeting @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_send_message_error_on_non_ascii_addrs_if_no_smtputf8 @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_send_unicode_without_SMTPUTF8 @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_smtputf8_NotSupportedError_if_no_server_support @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_with_statement @ linux-x86_64 +test.test_smtplib.SMTPSimTests.test_with_statement_QUIT_failure @ linux-x86_64 +test.test_smtplib.SMTPUTF8SimTests.test_send_message_uses_smtputf8_if_addrs_non_ascii @ linux-x86_64 +test.test_smtplib.SMTPUTF8SimTests.test_send_unicode_with_SMTPUTF8_via_low_level_API @ linux-x86_64 +test.test_smtplib.SMTPUTF8SimTests.test_send_unicode_with_SMTPUTF8_via_sendmail @ linux-x86_64 +test.test_smtplib.SMTPUTF8SimTests.test_test_server_supports_extensions @ linux-x86_64 +test.test_smtplib.TooLongLineTests.testLineTooLong @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sndhdr.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sndhdr.txt new file mode 100644 index 0000000000..aa65b146aa --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sndhdr.txt @@ -0,0 +1,2 @@ +test.test_sndhdr.TestFormats.test_data @ linux-x86_64 +test.test_sndhdr.TestFormats.test_pickleable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socket.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socket.txt new file mode 100644 index 0000000000..b01c6cac08 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socket.txt @@ -0,0 +1,218 @@ +test.test_socket.BasicSocketPairTest.testDefaults @ linux-x86_64 +test.test_socket.BasicSocketPairTest.testRecv @ linux-x86_64 +test.test_socket.BasicSocketPairTest.testSend @ linux-x86_64 +test.test_socket.BasicTCPTest.testDetach @ linux-x86_64 +test.test_socket.BasicTCPTest.testDup @ linux-x86_64 +test.test_socket.BasicTCPTest.testFromFd @ linux-x86_64 +test.test_socket.BasicTCPTest.testOverFlowRecv @ linux-x86_64 +test.test_socket.BasicTCPTest.testOverFlowRecvFrom @ linux-x86_64 +test.test_socket.BasicTCPTest.testRecv @ linux-x86_64 +test.test_socket.BasicTCPTest.testRecvFrom @ linux-x86_64 +test.test_socket.BasicTCPTest.testSendAll @ linux-x86_64 +test.test_socket.BasicTCPTest.testShutdown @ linux-x86_64 +test.test_socket.BasicTCPTest2.testDetach @ linux-x86_64 +test.test_socket.BasicTCPTest2.testDup @ linux-x86_64 +test.test_socket.BasicTCPTest2.testFromFd @ linux-x86_64 +test.test_socket.BasicTCPTest2.testOverFlowRecv @ linux-x86_64 +test.test_socket.BasicTCPTest2.testOverFlowRecvFrom @ linux-x86_64 +test.test_socket.BasicTCPTest2.testRecv @ linux-x86_64 +test.test_socket.BasicTCPTest2.testRecvFrom @ linux-x86_64 +test.test_socket.BasicTCPTest2.testSendAll @ linux-x86_64 +test.test_socket.BasicTCPTest2.testShutdown @ linux-x86_64 +test.test_socket.BasicUDPTest.testRecvFrom @ linux-x86_64 +test.test_socket.BasicUDPTest.testRecvFromNegative @ linux-x86_64 +test.test_socket.BasicUDPTest.testSendtoAndRecv @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvFromIntoArray @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvFromIntoBytearray @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvFromIntoEmptyBuffer @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvFromIntoMemoryview @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvFromIntoSmallBuffer @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvIntoArray @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvIntoBytearray @ linux-x86_64 +test.test_socket.BufferIOTest.testRecvIntoMemoryview @ linux-x86_64 +test.test_socket.ContextManagersTest.testCreateConnectionBase @ linux-x86_64 +test.test_socket.ContextManagersTest.testCreateConnectionClose @ linux-x86_64 +test.test_socket.CreateServerFunctionalTest.test_dual_stack_client_v4 @ linux-x86_64 +test.test_socket.CreateServerFunctionalTest.test_dual_stack_client_v6 @ linux-x86_64 +test.test_socket.CreateServerFunctionalTest.test_tcp4 @ linux-x86_64 +test.test_socket.CreateServerFunctionalTest.test_tcp6 @ linux-x86_64 +test.test_socket.CreateServerTest.test_address @ linux-x86_64 +test.test_socket.CreateServerTest.test_dualstack_ipv6_family @ linux-x86_64 +test.test_socket.CreateServerTest.test_family_and_type @ linux-x86_64 +test.test_socket.CreateServerTest.test_ipv6_only_default @ linux-x86_64 +test.test_socket.CreateServerTest.test_reuse_port @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.FileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.GeneralModuleTests.testCloseException @ linux-x86_64 +test.test_socket.GeneralModuleTests.testCrucialConstants @ linux-x86_64 +test.test_socket.GeneralModuleTests.testCrucialIpProtoConstants @ linux-x86_64 +test.test_socket.GeneralModuleTests.testDefaultTimeout @ linux-x86_64 +test.test_socket.GeneralModuleTests.testGetServBy @ linux-x86_64 +test.test_socket.GeneralModuleTests.testGetSockOpt @ linux-x86_64 +test.test_socket.GeneralModuleTests.testHostnameRes @ linux-x86_64 +test.test_socket.GeneralModuleTests.testIPv4_inet_aton_fourbytes @ linux-x86_64 +test.test_socket.GeneralModuleTests.testIPv4toString @ linux-x86_64 +test.test_socket.GeneralModuleTests.testIPv6toString @ linux-x86_64 +test.test_socket.GeneralModuleTests.testInterpreterCrash @ linux-x86_64 +test.test_socket.GeneralModuleTests.testNewAttributes @ linux-x86_64 +test.test_socket.GeneralModuleTests.testNtoH @ linux-x86_64 +test.test_socket.GeneralModuleTests.testRefCountGetNameInfo @ linux-x86_64 +test.test_socket.GeneralModuleTests.testSendAfterClose @ linux-x86_64 +test.test_socket.GeneralModuleTests.testSendtoErrors @ linux-x86_64 +test.test_socket.GeneralModuleTests.testSetSockOpt @ linux-x86_64 +test.test_socket.GeneralModuleTests.testSockName @ linux-x86_64 +test.test_socket.GeneralModuleTests.testSocketError @ linux-x86_64 +test.test_socket.GeneralModuleTests.testStringToIPv4 @ linux-x86_64 +test.test_socket.GeneralModuleTests.testStringToIPv6 @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_SocketType_is_socketobject @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_addressfamily_enum @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_addressinfo_enum @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_csocket_repr @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_flowinfo @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_getaddrinfo_ipv6_basic @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_getfqdn_filter_localhost @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_getnameinfo @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_getsockaddrarg @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_host_resolution @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_host_resolution_bad_address @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_idna @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_listen_backlog @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_makefile_invalid_mode @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_makefile_mode @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_msgflag_enum @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_name_closed_socketio @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_pickle @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_repr @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_close @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_consistent_sock_type @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_rejects_float @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_rejects_invalid_socket @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_rejects_negative @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_rejects_other_types @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_requires_socket_fd @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_fileno_requires_valid_fd @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socket_methods @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_socketkind_enum @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_str_for_enums @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_unknown_socket_family_repr @ linux-x86_64 +test.test_socket.GeneralModuleTests.test_unusable_closed_socketio @ linux-x86_64 +test.test_socket.InheritanceTest.test_default_inheritable @ linux-x86_64 +test.test_socket.InheritanceTest.test_dup @ linux-x86_64 +test.test_socket.InheritanceTest.test_set_inheritable @ linux-x86_64 +test.test_socket.InheritanceTest.test_socketpair @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.LineBufferedFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testFamily @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testSourceAddress @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testTimeoutDefault @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testTimeoutNone @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testTimeoutValueNamed @ linux-x86_64 +test.test_socket.NetworkConnectionAttributesTest.testTimeoutValueNonamed @ linux-x86_64 +test.test_socket.NetworkConnectionBehaviourTest.testInsideTimeout @ linux-x86_64 +test.test_socket.NetworkConnectionBehaviourTest.testOutsideTimeout @ linux-x86_64 +test.test_socket.NetworkConnectionNoServer.test_connect @ linux-x86_64 +test.test_socket.NetworkConnectionNoServer.test_create_connection @ linux-x86_64 +test.test_socket.NetworkConnectionNoServer.test_create_connection_all_errors @ linux-x86_64 +test.test_socket.NetworkConnectionNoServer.test_create_connection_timeout @ linux-x86_64 +test.test_socket.NonBlockingTCPTests.testAccept @ linux-x86_64 +test.test_socket.NonBlockingTCPTests.testInheritFlagsBlocking @ linux-x86_64 +test.test_socket.NonBlockingTCPTests.testInheritFlagsTimeout @ linux-x86_64 +test.test_socket.NonBlockingTCPTests.testRecv @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testCount @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testCountSmall @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testCountWithOffset @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testEmptyFileSend @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testNonBlocking @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testNonRegularFile @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testOffset @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testRegularFile @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testWithTimeout @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.testWithTimeoutTriggeredSend @ linux-x86_64 +test.test_socket.SendfileUsingSendTest.test_errors @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.SmallBufferedFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.TCPCloserTest.testClose @ linux-x86_64 +test.test_socket.TCPTimeoutTest.testTCPTimeout @ linux-x86_64 +test.test_socket.TCPTimeoutTest.testTimeoutZero @ linux-x86_64 +test.test_socket.TestExceptions.testExceptionTree @ linux-x86_64 +test.test_socket.TestExceptions.test_setblocking_invalidfd @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testAutobind @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testBytearrayName @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testLinuxAbstractNamespace @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testMaxName @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testNameOverflow @ linux-x86_64 +test.test_socket.TestLinuxAbstractNamespace.testStrName @ linux-x86_64 +test.test_socket.TestUnixDomain.testBytesAddr @ linux-x86_64 +test.test_socket.TestUnixDomain.testStrAddr @ linux-x86_64 +test.test_socket.TestUnixDomain.testUnbound @ linux-x86_64 +test.test_socket.UDPTimeoutTest.testTimeoutZero @ linux-x86_64 +test.test_socket.UDPTimeoutTest.testUDPTimeout @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testMakefileClose @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testSmallReadNonBlocking @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testUnbufferedReadline @ linux-x86_64 +test.test_socket.UnbufferedFileObjectClassTestCase.testWriteNonBlocking @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.UnicodeReadFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.UnicodeReadWriteFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testAttributes @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testCloseAfterMakefile @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testClosedAttr @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testFullRead @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testMakefileAfterMakefileClose @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testReadAfterTimeout @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testReadline @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testRealClose @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testSmallRead @ linux-x86_64 +test.test_socket.UnicodeWriteFileObjectClassTestCase.testUnbufferedRead @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socketserver.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socketserver.txt new file mode 100644 index 0000000000..2b11afc3a0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_socketserver.txt @@ -0,0 +1,20 @@ +test.test_socketserver.ErrorHandlerTest.test_sync_handled @ linux-x86_64 +test.test_socketserver.ErrorHandlerTest.test_sync_not_handled @ linux-x86_64 +test.test_socketserver.ErrorHandlerTest.test_threading_handled @ linux-x86_64 +test.test_socketserver.ErrorHandlerTest.test_threading_not_handled @ linux-x86_64 +test.test_socketserver.MiscTestCase.test_all @ linux-x86_64 +test.test_socketserver.MiscTestCase.test_shutdown_request_called_if_verify_request_false @ linux-x86_64 +test.test_socketserver.MiscTestCase.test_threads_reaped @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_TCPServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_ThreadingTCPServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_ThreadingUDPServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_ThreadingUnixDatagramServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_ThreadingUnixStreamServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_UDPServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_UnixDatagramServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_UnixStreamServer @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_close_immediately @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_context_manager @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_shutdown @ linux-x86_64 +test.test_socketserver.SocketServerTest.test_tcpserver_bind_leak @ linux-x86_64 +test.test_socketserver.SocketWriterTest.test_basics @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sort.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sort.txt new file mode 100644 index 0000000000..dc83bf1315 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sort.txt @@ -0,0 +1,19 @@ +test.test_sort.TestBase.testStressfully @ linux-x86_64 +test.test_sort.TestBugs.test_bug453523 @ linux-x86_64 +test.test_sort.TestBugs.test_undetected_mutation @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_baddecorator @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_decorated @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_key_with_exception @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_key_with_mutation @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_reverse @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_reverse_stability @ linux-x86_64 +test.test_sort.TestDecorateSortUndecorate.test_stability @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_none_in_tuples @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_not_all_tuples @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_safe_object_compare @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_unsafe_float_compare @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_unsafe_latin_compare @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_unsafe_long_compare @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_unsafe_object_compare @ linux-x86_64 +test.test_sort.TestOptimizedCompares.test_unsafe_tuple_compare @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_source_encoding.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_source_encoding.txt new file mode 100644 index 0000000000..767bad5431 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_source_encoding.txt @@ -0,0 +1,40 @@ +test.test_source_encoding.BytesSourceEncodingTest.test_crcrcrlf @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_crcrcrlf2 @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_crcrlf @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_crlf @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_default_coding @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_double_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_double_coding_same_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_first_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_first_non_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_second_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_second_non_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_third_coding_line @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_utf8_bom @ linux-x86_64 +test.test_source_encoding.BytesSourceEncodingTest.test_utf8_bom_and_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_crcrcrlf @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_crcrcrlf2 @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_crcrlf @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_crlf @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_default_coding @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_double_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_double_coding_same_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_first_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_first_non_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_second_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_second_non_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_third_coding_line @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_utf8_bom @ linux-x86_64 +test.test_source_encoding.FileSourceEncodingTest.test_utf8_bom_and_utf8_coding_line @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_20731 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_bad_coding @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_bad_coding2 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_compilestring @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_error_message @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_exec_valid_coding @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_file_parse @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_issue2301 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_issue3297 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_issue4626 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_issue7820 @ linux-x86_64 +test.test_source_encoding.MiscSourceEncodingTest.test_pep263 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sqlite3.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sqlite3.txt new file mode 100644 index 0000000000..4f1f57421d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sqlite3.txt @@ -0,0 +1,416 @@ +test.test_sqlite3.test_backup.BackupTests.test_bad_source_closed_connection @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_bad_target @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_bad_target_closed_connection @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_bad_target_filename @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_bad_target_in_transaction @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_bad_target_same_connection @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_database_source_name @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_failing_progress @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_keyword_only_args @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_modifying_progress @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_non_callable_progress @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_progress @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_progress_all_pages_at_once_1 @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_progress_all_pages_at_once_2 @ linux-x86_64 +test.test_sqlite3.test_backup.BackupTests.test_simple @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_32bit_rowid @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_closed @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_closed_db_read @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_context_manager @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_context_manager_reraise_exceptions @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_empty_slice @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_item @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_item_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_slice @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_slice_negative_index @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_get_slice_with_skip @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_is_a_blob @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_length @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_mapping_invalid_index_type @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_open_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_read @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_read_advance_offset @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_read_at_offset @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_read_error_row_changed @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_read_oversized @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_seek_and_tell @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_seek_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_sequence_not_supported @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_empty_slice @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_item @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_item_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_item_negative_index @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_item_with_offset @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_slice @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_slice_buffer_object @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_slice_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_set_slice_with_skip @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write_advance_offset @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write_at_offset @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write_error_length @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write_error_readonly @ linux-x86_64 +test.test_sqlite3.test_dbapi.BlobTests.test_blob_write_error_row_changed @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_call @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_con_commit @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_con_cursor @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_con_rollback @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_create_aggregate @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_create_function @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_cur_execute @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_set_authorizer @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedConTests.test_closed_set_progress_callback @ linux-x86_64 +test.test_sqlite3.test_dbapi.ClosedCurTests.test_closed @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_close @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_commit @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_commit_after_no_changes @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_bad_limit_category @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_bad_reinit @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_exceptions @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_init_bad_isolation_level @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_init_good_isolation_levels @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_connection_limits @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_cursor @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_drop_unused_refs @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_exceptions @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_failed_open @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_in_transaction @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_in_transaction_ro @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_interrupt @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_interrupt_on_closed_db @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_rollback @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_rollback_after_no_changes @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConnectionTests.test_use_after_close @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_binary @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_date @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_date_from_ticks @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_time @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_time_from_ticks @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_timestamp @ linux-x86_64 +test.test_sqlite3.test_dbapi.ConstructorTests.test_timestamp_from_ticks @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_array_size @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_close @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_column_count @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_cursor_connection @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_cursor_wrong_class @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_arg_float @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_arg_int @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_arg_string @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_arg_string_with_zero_byte @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_dict_mapping @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_dict_mapping_mapping @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_dict_mapping_no_args @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_dict_mapping_too_little_args @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_dict_mapping_unnamed @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_illegal_sql @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_many_iterator @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_many_not_iterable @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_many_select @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_many_sequence @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_many_wrong_sql_arg @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_multiple_statements @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_no_args @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_non_iterable @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_param_list @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_param_sequence @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_param_sequence_bad_len @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_too_many_params @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_with_appended_comments @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_wrong_no_of_args1 @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_wrong_no_of_args2 @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_wrong_no_of_args3 @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_execute_wrong_sql_arg @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetch_iter @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetchall @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetchmany @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetchmany_kw_arg @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetchone @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_fetchone_no_statement @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_last_row_id_insert_o_r @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_last_row_id_on_ignore @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_last_row_id_on_replace @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_execute @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_executemany @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_prefixed_with_comment @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_select @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_update_returning @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_rowcount_vaccuum @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_same_query_in_multiple_cursors @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_setinputsizes @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_setoutputsize @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_setoutputsize_no_column @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_total_changes @ linux-x86_64 +test.test_sqlite3.test_dbapi.CursorTests.test_wrong_cursor_callable @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_connection_execute @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_connection_executemany @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_connection_executescript @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_cursor_executescript_as_bytes @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_cursor_executescript_too_large_script @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_cursor_executescript_tx_control @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_cursor_executescript_with_null_characters @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_cursor_executescript_with_surrogates @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_script_error_normal @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_script_string_sql @ linux-x86_64 +test.test_sqlite3.test_dbapi.ExtensionTests.test_script_syntax_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_api_level @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_complete_statement @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_data_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_database_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_disallow_instantiation @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_error_code_on_exception @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_extended_error_code_on_exception @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_integrity_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_interface_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_internal_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_module_constants @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_not_supported_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_operational_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_param_style @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_programming_error @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_shared_cache_deprecated @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_thread_safety @ linux-x86_64 +test.test_sqlite3.test_dbapi.ModuleTests.test_warning @ linux-x86_64 +test.test_sqlite3.test_dbapi.MultiprocessTests.test_ctx_mgr_rollback_if_commit_failed @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_database_keyword @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_factory_database_arg @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_undecodable_uri @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_unquoted_uri @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_uri @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_uri_readonly @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_with_path_like_object @ linux-x86_64 +test.test_sqlite3.test_dbapi.OpenTests.test_open_with_undecodable_path @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_abort_raises_with_explicit_transactions @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_abort_raises_without_transactions @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_fail @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_ignore @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_replace @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_rollback_with_explicit_transaction @ linux-x86_64 +test.test_sqlite3.test_dbapi.SqliteOnConflictTests.test_on_conflict_rollback_without_transaction @ linux-x86_64 +test.test_sqlite3.test_dbapi.ThreadTests.test_check_connection_thread @ linux-x86_64 +test.test_sqlite3.test_dbapi.ThreadTests.test_check_cursor_thread @ linux-x86_64 +test.test_sqlite3.test_dbapi.ThreadTests.test_dont_check_same_thread @ linux-x86_64 +test.test_sqlite3.test_dbapi.UninitialisedConnectionTests.test_uninit_operations @ linux-x86_64 +test.test_sqlite3.test_dump.DumpTests.test_dump_autoincrement @ linux-x86_64 +test.test_sqlite3.test_dump.DumpTests.test_table_dump @ linux-x86_64 +test.test_sqlite3.test_dump.DumpTests.test_unorderable_row @ linux-x86_64 +test.test_sqlite3.test_factory.ConnectionFactoryTests.test_connection_factories @ linux-x86_64 +test.test_sqlite3.test_factory.ConnectionFactoryTests.test_connection_factory_as_positional_arg @ linux-x86_64 +test.test_sqlite3.test_factory.ConnectionFactoryTests.test_connection_factory_relayed_call @ linux-x86_64 +test.test_sqlite3.test_factory.CursorFactoryTests.test_invalid_factory @ linux-x86_64 +test.test_sqlite3.test_factory.CursorFactoryTests.test_is_instance @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_custom_factory @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_fake_cursor_class @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_as_dict @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_as_sequence @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_as_tuple @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_hash_cmp @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_index @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_index_unicode @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_iter @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_keys @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTests.test_sqlite_row_slice @ linux-x86_64 +test.test_sqlite3.test_factory.RowFactoryTestsBackwardsCompat.test_is_produced_by_factory @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTests.test_custom @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTests.test_optimized_unicode @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTests.test_string @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTests.test_unicode @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTestsWithEmbeddedZeroBytes.test_bytearray @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTestsWithEmbeddedZeroBytes.test_bytes @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTestsWithEmbeddedZeroBytes.test_custom @ linux-x86_64 +test.test_sqlite3.test_factory.TextFactoryTestsWithEmbeddedZeroBytes.test_string @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_collation_is_used @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_collation_register_twice @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_collation_returns_large_integer @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_create_collation_bad_upper @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_create_collation_not_ascii @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_create_collation_not_callable @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_create_collation_not_string @ linux-x86_64 +test.test_sqlite3.test_hooks.CollationTests.test_deregister_collation @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_cancel_operation @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_clear_handler @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_error_in_progress_handler @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_error_in_progress_handler_result @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_opcode_count @ linux-x86_64 +test.test_sqlite3.test_hooks.ProgressTests.test_progress_handler_used @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_clear_trace_callback @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_trace_bad_handler @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_trace_callback_content @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_trace_callback_used @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_trace_too_much_expanded_sql @ linux-x86_64 +test.test_sqlite3.test_hooks.TraceCallbackTests.test_unicode_content @ linux-x86_64 +test.test_sqlite3.test_regression.RecursiveUseOfCursors.test_recursive_cursor_close @ linux-x86_64 +test.test_sqlite3.test_regression.RecursiveUseOfCursors.test_recursive_cursor_init @ linux-x86_64 +test.test_sqlite3.test_regression.RecursiveUseOfCursors.test_recursive_cursor_iter @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_auto_commit @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_bind_mutating_list @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_bpo31770 @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_bpo37347 @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_collation @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_column_name_with_spaces @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_commit_cursor_reset @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_connection_call @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_connection_constructor_call_check @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_convert_timestamp_microsecond_padding @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_cursor_constructor_call_check @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_custom_cursor_object_crash_gh_99886 @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_del_isolation_level_segfault @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_empty_statement @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_executescript_step_through_select @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_invalid_isolation_level_type @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_large_sql @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_null_character @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_on_conflict_rollback @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_pragma_autocommit @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_pragma_schema_version @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_pragma_user_version @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_recursive_cursor_use @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_register_adapter @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_return_empty_bytestring @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_set_isolation_level @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_statement_finalization_on_close_db @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_statement_reset @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_str_subclass @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_surrogates @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_type_map_usage @ linux-x86_64 +test.test_sqlite3.test_regression.RegressionTests.test_workaround_for_buggy_sqlite_transfer_bindings @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_begin @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_default @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_deferred @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_exclusive @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_immediate @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelFromInit.test_isolation_level_none @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_begin @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_default @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_deferrred @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_exclusive @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_immediate @ linux-x86_64 +test.test_sqlite3.test_transactions.IsolationLevelPostInit.test_isolation_level_none @ linux-x86_64 +test.test_sqlite3.test_transactions.RollbackTests.test_no_duplicate_rows_after_rollback_close_cursor @ linux-x86_64 +test.test_sqlite3.test_transactions.RollbackTests.test_no_duplicate_rows_after_rollback_del_cursor @ linux-x86_64 +test.test_sqlite3.test_transactions.RollbackTests.test_no_duplicate_rows_after_rollback_new_query @ linux-x86_64 +test.test_sqlite3.test_transactions.SpecialCommandTests.test_drop_table @ linux-x86_64 +test.test_sqlite3.test_transactions.SpecialCommandTests.test_pragma @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_delete_starts_transaction @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_dml_does_not_auto_commit_before @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_insert_starts_transaction @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_locking @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_multiple_cursors_and_iternext @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_raise_timeout @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_replace_starts_transaction @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_rollback_cursor_consistency @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_toggle_auto_commit @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionTests.test_update_starts_transaction @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionalDDL.test_ddl_does_not_autostart_transaction @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionalDDL.test_immediate_transactional_ddl @ linux-x86_64 +test.test_sqlite3.test_transactions.TransactionalDDL.test_transactional_ddl @ linux-x86_64 +test.test_sqlite3.test_types.BinaryConverterTests.test_binary_input_for_converter @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_case_in_converter_name @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_col_name @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_cursor_description_insert @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_cursor_description_no_row @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_decl_type_not_used @ linux-x86_64 +test.test_sqlite3.test_types.ColNamesTests.test_none @ linux-x86_64 +test.test_sqlite3.test_types.CommonTableExpressionTests.test_cursor_description_cte @ linux-x86_64 +test.test_sqlite3.test_types.CommonTableExpressionTests.test_cursor_description_cte_multiple_columns @ linux-x86_64 +test.test_sqlite3.test_types.CommonTableExpressionTests.test_cursor_description_cte_simple @ linux-x86_64 +test.test_sqlite3.test_types.DateTimeTests.test_date_time_sub_seconds @ linux-x86_64 +test.test_sqlite3.test_types.DateTimeTests.test_date_time_sub_seconds_floating_point @ linux-x86_64 +test.test_sqlite3.test_types.DateTimeTests.test_sql_timestamp @ linux-x86_64 +test.test_sqlite3.test_types.DateTimeTests.test_sqlite_date @ linux-x86_64 +test.test_sqlite3.test_types.DateTimeTests.test_sqlite_timestamp @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_blob @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_bool @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_convert_zero_sized_blob @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_error_in_conform @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_float @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_foo @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_large_int @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_number1 @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_number2 @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_small_int @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_string @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_unicode @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_unsupported_dict @ linux-x86_64 +test.test_sqlite3.test_types.DeclTypesTests.test_unsupported_seq @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_adapt @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_adapt_alt @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_caster_is_used @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_custom_proto @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_defect_proto @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_defect_self_adapt @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_missing_adapter @ linux-x86_64 +test.test_sqlite3.test_types.ObjectAdaptationTests.test_missing_protocol @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_blob @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_float @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_large_int @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_small_int @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_string @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_string_with_null_character @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_string_with_surrogates @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_too_large_int @ linux-x86_64 +test.test_sqlite3.test_types.SqliteTypeTests.test_unicode_execute @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_aggr_sum @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_param_blob @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_param_float @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_param_int @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_param_none @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_param_str @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_check_params_int @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_error_on_create @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_exception_in_finalize @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_exception_in_init @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_exception_in_step @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_no_finalize @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_no_match @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_no_step @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AggregateTests.test_aggr_text @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerIllegalTypeTests.test_clear_authorizer @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerIllegalTypeTests.test_column_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerIllegalTypeTests.test_table_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerLargeIntegerTests.test_clear_authorizer @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerLargeIntegerTests.test_column_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerLargeIntegerTests.test_table_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerRaiseExceptionTests.test_clear_authorizer @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerRaiseExceptionTests.test_column_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerRaiseExceptionTests.test_table_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerTests.test_clear_authorizer @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerTests.test_column_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.AuthorizerTests.test_table_access @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_any_arguments @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_empty_blob @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_deterministic @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_deterministic_keyword_only @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_error_on_create @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_exception @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_memory_error @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_non_deterministic @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_overflow_error @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_params @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_ref_count @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_blob @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_float @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_illegal_value @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_int @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_long_long @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_nan @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_null @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_text @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_text_with_null_char @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_too_large_int @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_return_unicode @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_func_too_many_args @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_function_destructor_via_gc @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_nan_float @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_non_contiguous_blob @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_return_non_contiguous_blob @ linux-x86_64 +test.test_sqlite3.test_userfunctions.FunctionTests.test_too_large_int @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_clear_function @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_error_on_create @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_error_value_return @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_exception_in_finalize @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_exception_in_method @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_missing_finalize @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_missing_method @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_redefine_function @ linux-x86_64 +test.test_sqlite3.test_userfunctions.WindowFunctionTests.test_win_sum_int @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ssl.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ssl.txt new file mode 100644 index 0000000000..2260f5510b --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ssl.txt @@ -0,0 +1,108 @@ +test.test_ssl.BasicSocketTests.test_DER_to_PEM @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_cert_time_to_seconds @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_connect_ex_error @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_empty_cert @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_errors_sslwrap @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_get_default_verify_paths @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_malformed_cert @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_malformed_key @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_parse_cert @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_parse_cert_CVE_2019_5010 @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_private_init @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_purpose_enum @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_read_write_zero @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_server_side @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_str_for_enums @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_timeout @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_unknown_channel_binding @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_unsupported_dtls @ linux-x86_64 +test.test_ssl.BasicSocketTests.test_wrapped_unconnected @ linux-x86_64 +test.test_ssl.ContextTests.test__create_stdlib_context @ linux-x86_64 +test.test_ssl.ContextTests.test_cert_store_stats @ linux-x86_64 +test.test_ssl.ContextTests.test_check_hostname @ linux-x86_64 +test.test_ssl.ContextTests.test_ciphers @ linux-x86_64 +test.test_ssl.ContextTests.test_constructor @ linux-x86_64 +test.test_ssl.ContextTests.test_context_client_server @ linux-x86_64 +test.test_ssl.ContextTests.test_context_custom_class @ linux-x86_64 +test.test_ssl.ContextTests.test_create_default_context @ linux-x86_64 +test.test_ssl.ContextTests.test_get_ca_certs @ linux-x86_64 +test.test_ssl.ContextTests.test_get_ciphers @ linux-x86_64 +test.test_ssl.ContextTests.test_hostname_checks_common_name @ linux-x86_64 +test.test_ssl.ContextTests.test_load_cert_chain @ linux-x86_64 +test.test_ssl.ContextTests.test_load_default_certs @ linux-x86_64 +test.test_ssl.ContextTests.test_load_default_certs_env @ linux-x86_64 +test.test_ssl.ContextTests.test_load_verify_cadata @ linux-x86_64 +test.test_ssl.ContextTests.test_load_verify_locations @ linux-x86_64 +test.test_ssl.ContextTests.test_min_max_version @ linux-x86_64 +test.test_ssl.ContextTests.test_options @ linux-x86_64 +test.test_ssl.ContextTests.test_set_default_verify_paths @ linux-x86_64 +test.test_ssl.ContextTests.test_verify_mode_protocol @ linux-x86_64 +test.test_ssl.MemoryBIOTests.test_buffer_types @ linux-x86_64 +test.test_ssl.MemoryBIOTests.test_eof @ linux-x86_64 +test.test_ssl.MemoryBIOTests.test_error_types @ linux-x86_64 +test.test_ssl.MemoryBIOTests.test_pending @ linux-x86_64 +test.test_ssl.MemoryBIOTests.test_read_write @ linux-x86_64 +test.test_ssl.SSLErrorTests.test_bad_server_hostname @ linux-x86_64 +test.test_ssl.SSLErrorTests.test_str @ linux-x86_64 +test.test_ssl.SSLErrorTests.test_subclass @ linux-x86_64 +test.test_ssl.SSLObjectTests.test_private_init @ linux-x86_64 +test.test_ssl.SSLObjectTests.test_unwrap @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_bio_handshake @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_bio_read_write_data @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_ciphers @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_connect_cadata @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_connect_capath @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_connect_ex @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_connect_fail @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_connect_with_context_fail @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_get_server_certificate @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_get_server_certificate_fail @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_makefile_close @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_non_blocking_connect_ex @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_non_blocking_handshake @ linux-x86_64 +test.test_ssl.SimpleBackgroundTests.test_transport_eof @ linux-x86_64 +test.test_ssl.TestEnumerations.test_alertdescription @ linux-x86_64 +test.test_ssl.TestEnumerations.test_options @ linux-x86_64 +test.test_ssl.TestEnumerations.test_sslerrornumber @ linux-x86_64 +test.test_ssl.TestEnumerations.test_sslmethod @ linux-x86_64 +test.test_ssl.TestEnumerations.test_tlsalerttype @ linux-x86_64 +test.test_ssl.TestEnumerations.test_tlscontenttype @ linux-x86_64 +test.test_ssl.TestEnumerations.test_tlsmessagetype @ linux-x86_64 +test.test_ssl.TestEnumerations.test_tlsversion @ linux-x86_64 +test.test_ssl.TestEnumerations.test_verifyflags @ linux-x86_64 +test.test_ssl.TestEnumerations.test_verifymode @ linux-x86_64 +test.test_ssl.TestPreHandshakeClose.test_https_client_non_tls_response_ignored @ linux-x86_64 +test.test_ssl.TestPreHandshakeClose.test_preauth_data_to_tls_client @ linux-x86_64 +test.test_ssl.TestPreHandshakeClose.test_preauth_data_to_tls_server @ linux-x86_64 +test.test_ssl.ThreadedTests.test_asyncore_server @ linux-x86_64 +test.test_ssl.ThreadedTests.test_check_hostname @ linux-x86_64 +test.test_ssl.ThreadedTests.test_check_hostname_idn @ linux-x86_64 +test.test_ssl.ThreadedTests.test_compression @ linux-x86_64 +test.test_ssl.ThreadedTests.test_compression_disabled @ linux-x86_64 +test.test_ssl.ThreadedTests.test_crl_check @ linux-x86_64 +test.test_ssl.ThreadedTests.test_default_ecdh_curve @ linux-x86_64 +test.test_ssl.ThreadedTests.test_do_handshake_enotconn @ linux-x86_64 +test.test_ssl.ThreadedTests.test_dual_rsa_ecc @ linux-x86_64 +test.test_ssl.ThreadedTests.test_ecc_cert @ linux-x86_64 +test.test_ssl.ThreadedTests.test_getpeercert @ linux-x86_64 +test.test_ssl.ThreadedTests.test_getpeercert_enotconn @ linux-x86_64 +test.test_ssl.ThreadedTests.test_handshake_timeout @ linux-x86_64 +test.test_ssl.ThreadedTests.test_nonblocking_send @ linux-x86_64 +test.test_ssl.ThreadedTests.test_npn_protocols @ linux-x86_64 +test.test_ssl.ThreadedTests.test_read_write_after_close_raises_valuerror @ linux-x86_64 +test.test_ssl.ThreadedTests.test_recv_into_buffer_protocol_len @ linux-x86_64 +test.test_ssl.ThreadedTests.test_recv_send @ linux-x86_64 +test.test_ssl.ThreadedTests.test_recv_zero @ linux-x86_64 +test.test_ssl.ThreadedTests.test_rude_shutdown @ linux-x86_64 +test.test_ssl.ThreadedTests.test_selected_alpn_protocol @ linux-x86_64 +test.test_ssl.ThreadedTests.test_selected_alpn_protocol_if_server_uses_alpn @ linux-x86_64 +test.test_ssl.ThreadedTests.test_sendfile @ linux-x86_64 +test.test_ssl.ThreadedTests.test_server_accept @ linux-x86_64 +test.test_ssl.ThreadedTests.test_shared_ciphers @ linux-x86_64 +test.test_ssl.ThreadedTests.test_socketserver @ linux-x86_64 +test.test_ssl.ThreadedTests.test_ssl_cert_verify_error @ linux-x86_64 +test.test_ssl.ThreadedTests.test_starttls @ linux-x86_64 +test.test_ssl.ThreadedTests.test_tls1_3 @ linux-x86_64 +test.test_ssl.ThreadedTests.test_version_basic @ linux-x86_64 +test.test_ssl.ThreadedTests.test_wrong_cert_tls12 @ linux-x86_64 +test.test_ssl.ThreadedTests.test_wrong_cert_tls13 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stat.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stat.txt new file mode 100644 index 0000000000..99820f262d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stat.txt @@ -0,0 +1,5 @@ +test.test_stat.TestFilemodePyStat.test_devices @ linux-x86_64 +test.test_stat.TestFilemodePyStat.test_directory @ linux-x86_64 +test.test_stat.TestFilemodePyStat.test_link @ linux-x86_64 +test.test_stat.TestFilemodePyStat.test_mode @ linux-x86_64 +test.test_stat.TestFilemodePyStat.test_module_attributes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_statistics.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_statistics.txt new file mode 100644 index 0000000000..e7c8591ed5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_statistics.txt @@ -0,0 +1,347 @@ +DocTestCase.test.test_statistics.NumericTestCase.assertApproxEqual @ linux-x86_64 +DocTestCase.test.test_statistics._DoNothing @ linux-x86_64 +DocTestCase.test.test_statistics._calc_errors @ linux-x86_64 +DocTestCase.test.test_statistics._nan_equal @ linux-x86_64 +DocTestCase.test.test_statistics.approx_equal @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_absolute @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_absolute_decimals @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_both @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_decimals @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_floats @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_fractions @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_ints @ linux-x86_64 +test.test_statistics.ApproxEqualExactTest.test_exactly_equal_relative @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_absolute_decimals @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_absolute_floats @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_absolute_fractions @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_absolute_ints @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_both1 @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_both2 @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_both3 @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_both4 @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_relative_decimals @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_relative_floats @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_relative_fractions @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_approx_equal_relative_ints @ linux-x86_64 +test.test_statistics.ApproxEqualInexactTest.test_cross_zero @ linux-x86_64 +test.test_statistics.ApproxEqualSpecialsTest.test_decimal_zeroes @ linux-x86_64 +test.test_statistics.ApproxEqualSpecialsTest.test_float_zeroes @ linux-x86_64 +test.test_statistics.ApproxEqualSpecialsTest.test_inf @ linux-x86_64 +test.test_statistics.ApproxEqualSpecialsTest.test_nan @ linux-x86_64 +test.test_statistics.ApproxEqualSymmetryTest.test_relative_symmetry @ linux-x86_64 +test.test_statistics.ApproxEqualSymmetryTest.test_symmetry @ linux-x86_64 +test.test_statistics.ApproxEqualUnequalTest.test_exactly_unequal_decimals @ linux-x86_64 +test.test_statistics.ApproxEqualUnequalTest.test_exactly_unequal_floats @ linux-x86_64 +test.test_statistics.ApproxEqualUnequalTest.test_exactly_unequal_fractions @ linux-x86_64 +test.test_statistics.ApproxEqualUnequalTest.test_exactly_unequal_ints @ linux-x86_64 +test.test_statistics.CoerceTest.test_bool @ linux-x86_64 +test.test_statistics.CoerceTest.test_decimal @ linux-x86_64 +test.test_statistics.CoerceTest.test_float @ linux-x86_64 +test.test_statistics.CoerceTest.test_fraction @ linux-x86_64 +test.test_statistics.CoerceTest.test_incompatible_types @ linux-x86_64 +test.test_statistics.CoerceTest.test_int @ linux-x86_64 +test.test_statistics.CoerceTest.test_non_numeric_types @ linux-x86_64 +test.test_statistics.ConvertTest.test_decimal @ linux-x86_64 +test.test_statistics.ConvertTest.test_float @ linux-x86_64 +test.test_statistics.ConvertTest.test_fraction @ linux-x86_64 +test.test_statistics.ConvertTest.test_inf @ linux-x86_64 +test.test_statistics.ConvertTest.test_int @ linux-x86_64 +test.test_statistics.ConvertTest.test_invalid_input_type @ linux-x86_64 +test.test_statistics.ConvertTest.test_nan @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_infinity @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_nan @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_negative_exponent @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_positive_exponent @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_regression_20536 @ linux-x86_64 +test.test_statistics.DecimalToRatioTest.test_sign @ linux-x86_64 +test.test_statistics.DocTests.test_doc_tests @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_decimal @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_decimal_nan @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_float @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_float_nan @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_fraction @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_inf @ linux-x86_64 +test.test_statistics.ExactRatioTest.test_int @ linux-x86_64 +test.test_statistics.FailNegTest.test_error_msg @ linux-x86_64 +test.test_statistics.FailNegTest.test_negatives_raise @ linux-x86_64 +test.test_statistics.FailNegTest.test_pass_through @ linux-x86_64 +test.test_statistics.GlobalsTest.test_check_all @ linux-x86_64 +test.test_statistics.GlobalsTest.test_meta @ linux-x86_64 +test.test_statistics.IsFiniteTest.test_finite @ linux-x86_64 +test.test_statistics.IsFiniteTest.test_infinity @ linux-x86_64 +test.test_statistics.IsFiniteTest.test_nan @ linux-x86_64 +test.test_statistics.StatisticsErrorTest.test_has_exception @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_decimal_basiccontext_mismatched_infs_to_nan @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_decimal_extendedcontext_mismatched_infs_to_nan @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_decimal_inf @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_decimal_snan_raises @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_float_inf @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_float_mismatched_infs @ linux-x86_64 +test.test_statistics.SumSpecialValues.test_nan @ linux-x86_64 +test.test_statistics.SumTortureTest.test_torture @ linux-x86_64 +test.test_statistics.TestApproxEqualErrors.test_bad_rel @ linux-x86_64 +test.test_statistics.TestApproxEqualErrors.test_bad_tol @ linux-x86_64 +test.test_statistics.TestBivariateStatistics.test_small_sample_error @ linux-x86_64 +test.test_statistics.TestBivariateStatistics.test_unequal_size_error @ linux-x86_64 +test.test_statistics.TestCorrelationAndCovariance.test_different_scales @ linux-x86_64 +test.test_statistics.TestCorrelationAndCovariance.test_results @ linux-x86_64 +test.test_statistics.TestFMean.test_basics @ linux-x86_64 +test.test_statistics.TestFMean.test_error_cases @ linux-x86_64 +test.test_statistics.TestFMean.test_special_values @ linux-x86_64 +test.test_statistics.TestFMean.test_weights @ linux-x86_64 +test.test_statistics.TestGeometricMean.test_basics @ linux-x86_64 +test.test_statistics.TestGeometricMean.test_big_and_small @ linux-x86_64 +test.test_statistics.TestGeometricMean.test_mixed_int_and_float @ linux-x86_64 +test.test_statistics.TestGeometricMean.test_special_values @ linux-x86_64 +test.test_statistics.TestGeometricMean.test_various_input_types @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_decimals_exact @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_doubled_data @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_empty_data @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_floats_exact @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_fractions @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_inf @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_ints @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_invalid_type_error @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_multiply_data_points @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_nan @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_negative_error @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_no_args @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_range_data @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_single_value @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_singleton_lists @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_types_conserved @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_with_weights @ linux-x86_64 +test.test_statistics.TestHarmonicMean.test_zero @ linux-x86_64 +test.test_statistics.TestLinearRegression.test_constant_input_error @ linux-x86_64 +test.test_statistics.TestLinearRegression.test_proportional @ linux-x86_64 +test.test_statistics.TestLinearRegression.test_results @ linux-x86_64 +test.test_statistics.TestMean.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMean.test_big_data @ linux-x86_64 +test.test_statistics.TestMean.test_decimals @ linux-x86_64 +test.test_statistics.TestMean.test_doubled_data @ linux-x86_64 +test.test_statistics.TestMean.test_empty_data @ linux-x86_64 +test.test_statistics.TestMean.test_floats @ linux-x86_64 +test.test_statistics.TestMean.test_fractions @ linux-x86_64 +test.test_statistics.TestMean.test_inf @ linux-x86_64 +test.test_statistics.TestMean.test_ints @ linux-x86_64 +test.test_statistics.TestMean.test_mismatched_infs @ linux-x86_64 +test.test_statistics.TestMean.test_nan @ linux-x86_64 +test.test_statistics.TestMean.test_no_args @ linux-x86_64 +test.test_statistics.TestMean.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMean.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMean.test_range_data @ linux-x86_64 +test.test_statistics.TestMean.test_regression_20561 @ linux-x86_64 +test.test_statistics.TestMean.test_regression_25177 @ linux-x86_64 +test.test_statistics.TestMean.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMean.test_single_value @ linux-x86_64 +test.test_statistics.TestMean.test_torture_pep @ linux-x86_64 +test.test_statistics.TestMean.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMean.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMean.test_types_conserved @ linux-x86_64 +test.test_statistics.TestMedian.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMedian.test_empty_data @ linux-x86_64 +test.test_statistics.TestMedian.test_even_decimals @ linux-x86_64 +test.test_statistics.TestMedian.test_even_fractions @ linux-x86_64 +test.test_statistics.TestMedian.test_even_ints @ linux-x86_64 +test.test_statistics.TestMedian.test_no_args @ linux-x86_64 +test.test_statistics.TestMedian.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMedian.test_odd_decimals @ linux-x86_64 +test.test_statistics.TestMedian.test_odd_fractions @ linux-x86_64 +test.test_statistics.TestMedian.test_odd_ints @ linux-x86_64 +test.test_statistics.TestMedian.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMedian.test_range_data @ linux-x86_64 +test.test_statistics.TestMedian.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMedian.test_single_value @ linux-x86_64 +test.test_statistics.TestMedian.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMedian.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMedianDataType.test_types_conserved @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_data_type_error @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_empty_data @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_even_decimals @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_even_fractions @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_even_ints @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_even_number_repeated @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_interval @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_no_args @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_odd_decimals @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_odd_fractions @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_odd_ints @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_odd_number_repeated @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_range_data @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_single_value @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMedianGrouped.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_empty_data @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_even_decimals @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_even_fractions @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_even_ints @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_no_args @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_odd_decimals @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_odd_fractions @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_odd_ints @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_range_data @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_single_value @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMedianHigh.test_types_conserved @ linux-x86_64 +test.test_statistics.TestMedianLow.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMedianLow.test_empty_data @ linux-x86_64 +test.test_statistics.TestMedianLow.test_even_decimals @ linux-x86_64 +test.test_statistics.TestMedianLow.test_even_fractions @ linux-x86_64 +test.test_statistics.TestMedianLow.test_even_ints @ linux-x86_64 +test.test_statistics.TestMedianLow.test_no_args @ linux-x86_64 +test.test_statistics.TestMedianLow.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMedianLow.test_odd_decimals @ linux-x86_64 +test.test_statistics.TestMedianLow.test_odd_fractions @ linux-x86_64 +test.test_statistics.TestMedianLow.test_odd_ints @ linux-x86_64 +test.test_statistics.TestMedianLow.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMedianLow.test_range_data @ linux-x86_64 +test.test_statistics.TestMedianLow.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMedianLow.test_single_value @ linux-x86_64 +test.test_statistics.TestMedianLow.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMedianLow.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMedianLow.test_types_conserved @ linux-x86_64 +test.test_statistics.TestMode.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestMode.test_bimodal_data @ linux-x86_64 +test.test_statistics.TestMode.test_counter_data @ linux-x86_64 +test.test_statistics.TestMode.test_discrete_data @ linux-x86_64 +test.test_statistics.TestMode.test_empty_data @ linux-x86_64 +test.test_statistics.TestMode.test_no_args @ linux-x86_64 +test.test_statistics.TestMode.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestMode.test_nominal_data @ linux-x86_64 +test.test_statistics.TestMode.test_none_data @ linux-x86_64 +test.test_statistics.TestMode.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestMode.test_range_data @ linux-x86_64 +test.test_statistics.TestMode.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestMode.test_single_value @ linux-x86_64 +test.test_statistics.TestMode.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestMode.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestMode.test_types_conserved @ linux-x86_64 +test.test_statistics.TestMode.test_unique_data @ linux-x86_64 +test.test_statistics.TestModules.test_py_functions @ linux-x86_64 +test.test_statistics.TestMultiMode.test_basics @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_alternative_constructor @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_cdf @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_copy @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_equality @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_hashability @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_instantiation_and_attributes @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_inv_cdf @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_pdf @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_pickle @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_properties @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_quantiles @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_repr @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_same_type_addition_and_subtraction @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_sample_generation @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_slots @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_translation_and_scaling @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_unary_operations @ linux-x86_64 +test.test_statistics.TestNormalDistPython.test_zscore @ linux-x86_64 +test.test_statistics.TestNumericTestCase.test_error_msg_numeric @ linux-x86_64 +test.test_statistics.TestNumericTestCase.test_error_msg_sequence @ linux-x86_64 +test.test_statistics.TestNumericTestCase.test_numerictestcase_is_testcase @ linux-x86_64 +test.test_statistics.TestPStdev.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestPStdev.test_center_not_at_mean @ linux-x86_64 +test.test_statistics.TestPStdev.test_compare_to_variance @ linux-x86_64 +test.test_statistics.TestPStdev.test_domain_error_regression @ linux-x86_64 +test.test_statistics.TestPStdev.test_empty_data @ linux-x86_64 +test.test_statistics.TestPStdev.test_iter_list_same @ linux-x86_64 +test.test_statistics.TestPStdev.test_no_args @ linux-x86_64 +test.test_statistics.TestPStdev.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestPStdev.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestPStdev.test_range_data @ linux-x86_64 +test.test_statistics.TestPStdev.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestPStdev.test_shift_data @ linux-x86_64 +test.test_statistics.TestPStdev.test_shift_data_exact @ linux-x86_64 +test.test_statistics.TestPStdev.test_single_value @ linux-x86_64 +test.test_statistics.TestPStdev.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestPStdev.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestPVariance.test_accuracy_bug_20499 @ linux-x86_64 +test.test_statistics.TestPVariance.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestPVariance.test_decimals @ linux-x86_64 +test.test_statistics.TestPVariance.test_domain_error_regression @ linux-x86_64 +test.test_statistics.TestPVariance.test_empty_data @ linux-x86_64 +test.test_statistics.TestPVariance.test_exact_uniform @ linux-x86_64 +test.test_statistics.TestPVariance.test_fractions @ linux-x86_64 +test.test_statistics.TestPVariance.test_ints @ linux-x86_64 +test.test_statistics.TestPVariance.test_iter_list_same @ linux-x86_64 +test.test_statistics.TestPVariance.test_no_args @ linux-x86_64 +test.test_statistics.TestPVariance.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestPVariance.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestPVariance.test_range_data @ linux-x86_64 +test.test_statistics.TestPVariance.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestPVariance.test_shift_data @ linux-x86_64 +test.test_statistics.TestPVariance.test_shift_data_exact @ linux-x86_64 +test.test_statistics.TestPVariance.test_single_value @ linux-x86_64 +test.test_statistics.TestPVariance.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestPVariance.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestPVariance.test_types_conserved @ linux-x86_64 +test.test_statistics.TestQuantiles.test_equal_inputs @ linux-x86_64 +test.test_statistics.TestQuantiles.test_equal_sized_groups @ linux-x86_64 +test.test_statistics.TestQuantiles.test_error_cases @ linux-x86_64 +test.test_statistics.TestQuantiles.test_specific_cases @ linux-x86_64 +test.test_statistics.TestQuantiles.test_specific_cases_inclusive @ linux-x86_64 +test.test_statistics.TestSign.testZeroes @ linux-x86_64 +test.test_statistics.TestSqrtHelpers.test_decimal_sqrt_of_frac @ linux-x86_64 +test.test_statistics.TestSqrtHelpers.test_float_sqrt_of_frac @ linux-x86_64 +test.test_statistics.TestSqrtHelpers.test_integer_sqrt_of_frac_rto @ linux-x86_64 +test.test_statistics.TestStdev.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestStdev.test_center_not_at_mean @ linux-x86_64 +test.test_statistics.TestStdev.test_compare_to_variance @ linux-x86_64 +test.test_statistics.TestStdev.test_domain_error_regression @ linux-x86_64 +test.test_statistics.TestStdev.test_empty_data @ linux-x86_64 +test.test_statistics.TestStdev.test_iter_list_same @ linux-x86_64 +test.test_statistics.TestStdev.test_no_args @ linux-x86_64 +test.test_statistics.TestStdev.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestStdev.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestStdev.test_range_data @ linux-x86_64 +test.test_statistics.TestStdev.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestStdev.test_shift_data @ linux-x86_64 +test.test_statistics.TestStdev.test_shift_data_exact @ linux-x86_64 +test.test_statistics.TestStdev.test_single_value @ linux-x86_64 +test.test_statistics.TestStdev.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestStdev.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestSum.test_bytes_fail @ linux-x86_64 +test.test_statistics.TestSum.test_compare_with_math_fsum @ linux-x86_64 +test.test_statistics.TestSum.test_decimals @ linux-x86_64 +test.test_statistics.TestSum.test_empty_data @ linux-x86_64 +test.test_statistics.TestSum.test_floats @ linux-x86_64 +test.test_statistics.TestSum.test_fractions @ linux-x86_64 +test.test_statistics.TestSum.test_ints @ linux-x86_64 +test.test_statistics.TestSum.test_mixed_sum @ linux-x86_64 +test.test_statistics.TestSum.test_strings_fail @ linux-x86_64 +test.test_statistics.TestVariance.test_accuracy_bug_20499 @ linux-x86_64 +test.test_statistics.TestVariance.test_bad_arg_types @ linux-x86_64 +test.test_statistics.TestVariance.test_center_not_at_mean @ linux-x86_64 +test.test_statistics.TestVariance.test_decimals @ linux-x86_64 +test.test_statistics.TestVariance.test_domain_error_regression @ linux-x86_64 +test.test_statistics.TestVariance.test_empty_data @ linux-x86_64 +test.test_statistics.TestVariance.test_fractions @ linux-x86_64 +test.test_statistics.TestVariance.test_ints @ linux-x86_64 +test.test_statistics.TestVariance.test_iter_list_same @ linux-x86_64 +test.test_statistics.TestVariance.test_no_args @ linux-x86_64 +test.test_statistics.TestVariance.test_no_inplace_modifications @ linux-x86_64 +test.test_statistics.TestVariance.test_order_doesnt_matter @ linux-x86_64 +test.test_statistics.TestVariance.test_range_data @ linux-x86_64 +test.test_statistics.TestVariance.test_repeated_single_value @ linux-x86_64 +test.test_statistics.TestVariance.test_shift_data @ linux-x86_64 +test.test_statistics.TestVariance.test_shift_data_exact @ linux-x86_64 +test.test_statistics.TestVariance.test_single_value @ linux-x86_64 +test.test_statistics.TestVariance.test_type_of_data_collection @ linux-x86_64 +test.test_statistics.TestVariance.test_type_of_data_element @ linux-x86_64 +test.test_statistics.TestVariance.test_types_conserved @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strftime.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strftime.txt new file mode 100644 index 0000000000..74ab95bcf9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strftime.txt @@ -0,0 +1,4 @@ +test.test_strftime.StrftimeTest.test_strftime @ linux-x86_64 +test.test_strftime.Y1900Tests.test_y_1900 @ linux-x86_64 +test.test_strftime.Y1900Tests.test_y_after_1900 @ linux-x86_64 +test.test_strftime.Y1900Tests.test_y_before_1900 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string.txt new file mode 100644 index 0000000000..9c816c61b8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string.txt @@ -0,0 +1,38 @@ +test.test_string.ModuleTest.test_attrs @ linux-x86_64 +test.test_string.ModuleTest.test_auto_numbering @ linux-x86_64 +test.test_string.ModuleTest.test_basic_formatter @ linux-x86_64 +test.test_string.ModuleTest.test_capwords @ linux-x86_64 +test.test_string.ModuleTest.test_check_unused_args @ linux-x86_64 +test.test_string.ModuleTest.test_conversion_specifiers @ linux-x86_64 +test.test_string.ModuleTest.test_format_keyword_arguments @ linux-x86_64 +test.test_string.ModuleTest.test_index_lookup @ linux-x86_64 +test.test_string.ModuleTest.test_name_lookup @ linux-x86_64 +test.test_string.ModuleTest.test_override_convert_field @ linux-x86_64 +test.test_string.ModuleTest.test_override_format_field @ linux-x86_64 +test.test_string.ModuleTest.test_override_get_value @ linux-x86_64 +test.test_string.ModuleTest.test_override_parse @ linux-x86_64 +test.test_string.ModuleTest.test_vformat_recursion_limit @ linux-x86_64 +test.test_string.TestTemplate.test_SafeTemplate @ linux-x86_64 +test.test_string.TestTemplate.test_braced_override @ linux-x86_64 +test.test_string.TestTemplate.test_braced_override_safe @ linux-x86_64 +test.test_string.TestTemplate.test_delimiter_override @ linux-x86_64 +test.test_string.TestTemplate.test_escapes @ linux-x86_64 +test.test_string.TestTemplate.test_flags_override @ linux-x86_64 +test.test_string.TestTemplate.test_get_identifiers @ linux-x86_64 +test.test_string.TestTemplate.test_idpattern_override @ linux-x86_64 +test.test_string.TestTemplate.test_idpattern_override_inside_outside @ linux-x86_64 +test.test_string.TestTemplate.test_idpattern_override_inside_outside_invalid_unbraced @ linux-x86_64 +test.test_string.TestTemplate.test_invalid_placeholders @ linux-x86_64 +test.test_string.TestTemplate.test_invalid_with_no_lines @ linux-x86_64 +test.test_string.TestTemplate.test_is_valid @ linux-x86_64 +test.test_string.TestTemplate.test_keyword_arguments @ linux-x86_64 +test.test_string.TestTemplate.test_keyword_arguments_safe @ linux-x86_64 +test.test_string.TestTemplate.test_pattern_override @ linux-x86_64 +test.test_string.TestTemplate.test_percents @ linux-x86_64 +test.test_string.TestTemplate.test_regular_templates @ linux-x86_64 +test.test_string.TestTemplate.test_regular_templates_with_braces @ linux-x86_64 +test.test_string.TestTemplate.test_regular_templates_with_non_letters @ linux-x86_64 +test.test_string.TestTemplate.test_regular_templates_with_upper_case @ linux-x86_64 +test.test_string.TestTemplate.test_stringification @ linux-x86_64 +test.test_string.TestTemplate.test_tupleargs @ linux-x86_64 +test.test_string.TestTemplate.test_unicode_values @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string_literals.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string_literals.txt new file mode 100644 index 0000000000..b32b52c380 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_string_literals.txt @@ -0,0 +1,17 @@ +test.test_string_literals.TestLiterals.test_eval_bytes_incomplete @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_bytes_invalid_escape @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_bytes_normal @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_bytes_raw @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_str_incomplete @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_str_invalid_escape @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_str_normal @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_str_raw @ linux-x86_64 +test.test_string_literals.TestLiterals.test_eval_str_u @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_iso_8859_1 @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_latin9 @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_latin_1 @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_utf8 @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_utf_8 @ linux-x86_64 +test.test_string_literals.TestLiterals.test_file_utf_8_error @ linux-x86_64 +test.test_string_literals.TestLiterals.test_template @ linux-x86_64 +test.test_string_literals.TestLiterals.test_uppercase_prefixes @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stringprep.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stringprep.txt new file mode 100644 index 0000000000..e2f25ed430 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_stringprep.txt @@ -0,0 +1 @@ +test.test_stringprep.StringprepTests.test @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strptime.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strptime.txt new file mode 100644 index 0000000000..19cadf94f5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strptime.txt @@ -0,0 +1,42 @@ +test.test_strptime.CacheTests.test_TimeRE_recreation_locale @ linux-x86_64 +test.test_strptime.CacheTests.test_new_localetime @ linux-x86_64 +test.test_strptime.CacheTests.test_regex_cleanup @ linux-x86_64 +test.test_strptime.CacheTests.test_time_re_recreation @ linux-x86_64 +test.test_strptime.CalculationTests.test_week_0 @ linux-x86_64 +test.test_strptime.JulianTests.test_all_julian_days @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_am_pm @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_date_time @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_lang @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_month @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_timezone @ linux-x86_64 +test.test_strptime.LocaleTime_Tests.test_weekday @ linux-x86_64 +test.test_strptime.Strptime12AMPMTests.test_twelve_noon_midnight @ linux-x86_64 +test.test_strptime.StrptimeTests.test_ValueError @ linux-x86_64 +test.test_strptime.StrptimeTests.test_bad_offset @ linux-x86_64 +test.test_strptime.StrptimeTests.test_caseinsensitive @ linux-x86_64 +test.test_strptime.StrptimeTests.test_date @ linux-x86_64 +test.test_strptime.StrptimeTests.test_date_time @ linux-x86_64 +test.test_strptime.StrptimeTests.test_day @ linux-x86_64 +test.test_strptime.StrptimeTests.test_defaults @ linux-x86_64 +test.test_strptime.StrptimeTests.test_escaping @ linux-x86_64 +test.test_strptime.StrptimeTests.test_feb29_on_leap_year_without_year @ linux-x86_64 +test.test_strptime.StrptimeTests.test_fraction @ linux-x86_64 +test.test_strptime.StrptimeTests.test_hour @ linux-x86_64 +test.test_strptime.StrptimeTests.test_julian @ linux-x86_64 +test.test_strptime.StrptimeTests.test_mar1_comes_after_feb29_even_when_omitting_the_year @ linux-x86_64 +test.test_strptime.StrptimeTests.test_minute @ linux-x86_64 +test.test_strptime.StrptimeTests.test_month @ linux-x86_64 +test.test_strptime.StrptimeTests.test_offset @ linux-x86_64 +test.test_strptime.StrptimeTests.test_percent @ linux-x86_64 +test.test_strptime.StrptimeTests.test_second @ linux-x86_64 +test.test_strptime.StrptimeTests.test_strptime_exception_context @ linux-x86_64 +test.test_strptime.StrptimeTests.test_time @ linux-x86_64 +test.test_strptime.StrptimeTests.test_unconverteddata @ linux-x86_64 +test.test_strptime.StrptimeTests.test_year @ linux-x86_64 +test.test_strptime.TimeRETests.test_blankpattern @ linux-x86_64 +test.test_strptime.TimeRETests.test_locale_data_w_regex_metacharacters @ linux-x86_64 +test.test_strptime.TimeRETests.test_matching_with_escapes @ linux-x86_64 +test.test_strptime.TimeRETests.test_pattern @ linux-x86_64 +test.test_strptime.TimeRETests.test_pattern_escaping @ linux-x86_64 +test.test_strptime.TimeRETests.test_whitespace_substitution @ linux-x86_64 +test.test_strptime.getlang_Tests.test_basic @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strtod.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strtod.txt new file mode 100644 index 0000000000..a2fa1b0d6a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_strtod.txt @@ -0,0 +1,8 @@ +test.test_strtod.StrtodTests.test_bigcomp @ linux-x86_64 +test.test_strtod.StrtodTests.test_boundaries @ linux-x86_64 +test.test_strtod.StrtodTests.test_halfway_cases @ linux-x86_64 +test.test_strtod.StrtodTests.test_large_exponents @ linux-x86_64 +test.test_strtod.StrtodTests.test_parsing @ linux-x86_64 +test.test_strtod.StrtodTests.test_particular @ linux-x86_64 +test.test_strtod.StrtodTests.test_short_halfway_cases @ linux-x86_64 +test.test_strtod.StrtodTests.test_underflow_boundary @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_struct.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_struct.txt new file mode 100644 index 0000000000..5f8800bf43 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_struct.txt @@ -0,0 +1,30 @@ +test.test_struct.StructTest.test_1530559 @ linux-x86_64 +test.test_struct.StructTest.test_705836 @ linux-x86_64 +test.test_struct.StructTest.test_Struct_reinitialization @ linux-x86_64 +test.test_struct.StructTest.test_bool @ linux-x86_64 +test.test_struct.StructTest.test_boundary_error_message @ linux-x86_64 +test.test_struct.StructTest.test_boundary_error_message_with_large_offset @ linux-x86_64 +test.test_struct.StructTest.test_boundary_error_message_with_negative_offset @ linux-x86_64 +test.test_struct.StructTest.test_calcsize @ linux-x86_64 +test.test_struct.StructTest.test_consistence @ linux-x86_64 +test.test_struct.StructTest.test_format_attr @ linux-x86_64 +test.test_struct.StructTest.test_integers @ linux-x86_64 +test.test_struct.StructTest.test_isbigendian @ linux-x86_64 +test.test_struct.StructTest.test_issue29802 @ linux-x86_64 +test.test_struct.StructTest.test_issue35714 @ linux-x86_64 +test.test_struct.StructTest.test_nN_code @ linux-x86_64 +test.test_struct.StructTest.test_new_features @ linux-x86_64 +test.test_struct.StructTest.test_p_code @ linux-x86_64 +test.test_struct.StructTest.test_pack_into @ linux-x86_64 +test.test_struct.StructTest.test_pack_into_fn @ linux-x86_64 +test.test_struct.StructTest.test_trailing_counter @ linux-x86_64 +test.test_struct.StructTest.test_transitiveness @ linux-x86_64 +test.test_struct.StructTest.test_unpack_from @ linux-x86_64 +test.test_struct.StructTest.test_unpack_with_buffer @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_arbitrary_buffer @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_construct @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_half_float @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_iterate @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_length_hint @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_module_func @ linux-x86_64 +test.test_struct.UnpackIteratorTest.test_uninstantiable @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_structseq.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_structseq.txt new file mode 100644 index 0000000000..4476e422b9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_structseq.txt @@ -0,0 +1,15 @@ +test.test_structseq.StructSeqTest.test_cmp @ linux-x86_64 +test.test_structseq.StructSeqTest.test_concat @ linux-x86_64 +test.test_structseq.StructSeqTest.test_constructor @ linux-x86_64 +test.test_structseq.StructSeqTest.test_contains @ linux-x86_64 +test.test_structseq.StructSeqTest.test_copying @ linux-x86_64 +test.test_structseq.StructSeqTest.test_copying_with_unnamed_fields @ linux-x86_64 +test.test_structseq.StructSeqTest.test_eviltuple @ linux-x86_64 +test.test_structseq.StructSeqTest.test_extended_getslice @ linux-x86_64 +test.test_structseq.StructSeqTest.test_fields @ linux-x86_64 +test.test_structseq.StructSeqTest.test_hash @ linux-x86_64 +test.test_structseq.StructSeqTest.test_pickling @ linux-x86_64 +test.test_structseq.StructSeqTest.test_pickling_with_unnamed_fields @ linux-x86_64 +test.test_structseq.StructSeqTest.test_repeat @ linux-x86_64 +test.test_structseq.StructSeqTest.test_repr @ linux-x86_64 +test.test_structseq.StructSeqTest.test_tuple @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subclassinit.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subclassinit.txt new file mode 100644 index 0000000000..1e3a8fc825 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subclassinit.txt @@ -0,0 +1,17 @@ +test.test_subclassinit.Test.test_errors @ linux-x86_64 +test.test_subclassinit.Test.test_errors_changed_pep487 @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_diamond @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_dict @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_error @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_kwargs @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_skipped @ linux-x86_64 +test.test_subclassinit.Test.test_init_subclass_wrong @ linux-x86_64 +test.test_subclassinit.Test.test_set_name @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_error @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_init_subclass @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_lookup @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_metaclass @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_modifying_dict @ linux-x86_64 +test.test_subclassinit.Test.test_set_name_wrong @ linux-x86_64 +test.test_subclassinit.Test.test_type @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subprocess.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subprocess.txt new file mode 100644 index 0000000000..747e33cd93 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_subprocess.txt @@ -0,0 +1,170 @@ +test.test_subprocess.ContextManagerTests.test_broken_pipe_cleanup @ linux-x86_64 +test.test_subprocess.ContextManagerTests.test_communicate_stdin @ linux-x86_64 +test.test_subprocess.ContextManagerTests.test_invalid_args @ linux-x86_64 +test.test_subprocess.ContextManagerTests.test_pipe @ linux-x86_64 +test.test_subprocess.ContextManagerTests.test_returncode @ linux-x86_64 +test.test_subprocess.MiscTests.test__all__ @ linux-x86_64 +test.test_subprocess.MiscTests.test_call_keyboardinterrupt_no_kill @ linux-x86_64 +test.test_subprocess.MiscTests.test_context_manager_keyboardinterrupt_no_kill @ linux-x86_64 +test.test_subprocess.MiscTests.test_getoutput @ linux-x86_64 +test.test_subprocess.MiscTests.test_run_keyboardinterrupt_no_kill @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_CalledProcessError_str_non_zero @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_CalledProcessError_str_signal @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_CalledProcessError_str_unknown_signal @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_args_string @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_bytes_program @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_call_string @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fd_0 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fd_1 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fd_2 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fds_0_1 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fds_0_1_2 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fds_0_2 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_close_fds_1_2 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_close @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_close_with_timeout @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_flush @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_write @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_communicate_repeated_call_after_stdout_close @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_exception_bad_args_0 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_exception_bad_executable @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_exception_cwd @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_exception_errpipe_bad_data @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_exception_errpipe_normal @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_extra_groups_error @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_group_error @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_invalid_args @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_kill @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_kill_dead @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_remapping_std_fds @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_select_unbuffered @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_send_signal @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_send_signal_dead @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_send_signal_race @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_send_signal_race2 @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_shell_sequence @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_shell_string @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_small_errpipe_write_fd @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_specific_shell @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_start_new_session @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_stderr_stdin_are_single_inout_fd @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_stdout_stderr_are_single_inout_fd @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_stdout_stdin_are_single_inout_fd @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_stopped @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_swap_fds @ linux-x86_64 +!test.test_subprocess.POSIXProcessTestCase.test_swap_std_fds_with_one_closed @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_terminate_dead @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_user_error @ linux-x86_64 +test.test_subprocess.POSIXProcessTestCase.test_wait_when_sigchild_ignored @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_bufsize_equal_one_binary_mode @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_bufsize_equal_one_text_mode @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_bufsize_is_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_bytes_executable @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_bytes_executable_replaces_shell @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_call_kwargs @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_call_seq @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_call_timeout @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_call_nonzero @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_call_zero @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_input_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_input_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_input_none_encoding_errors @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_input_none_text @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_input_none_universal_newlines @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_nonzero @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_stderr @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_stdin_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_stdin_with_input_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_check_output_stdout_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_class_getitems @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_eintr @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_epipe @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_epipe_only_stdin @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_errors @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_pipe_buf @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_pipe_fd_leak @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_returns @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_stderr @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_stdin @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_stdout @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_timeout @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_communicate_timeout_large_output @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd_with_absolute_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd_with_bytes @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd_with_pathlike @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd_with_relative_arg @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_cwd_with_relative_executable @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_double_close_on_error @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_empty_env @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_env @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_executable @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_executable_replaces_shell @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_executable_takes_precedence @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_executable_with_cwd @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_executable_without_cwd @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_failed_child_execute_fd_leak @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_file_not_found_includes_filename @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_file_not_found_with_bad_cwd @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_handles_closed_on_exception @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_invalid_args @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_invalid_bufsize @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_invalid_cmd @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_invalid_env @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_io_buffered_by_default @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_io_unbuffered_works @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_issue8780 @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_leaking_fds_on_error @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_list2cmdline @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_pathlike_executable @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_pathlike_executable_replaces_shell @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_poll @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_repr @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_devnull @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_filedes @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_fileobj @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_pipe @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stderr_redirect_with_no_stdout_redirect @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdin_devnull @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdin_filedes @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdin_fileobj @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdin_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdin_pipe @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_devnull @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_filedes @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_filedes_of_stdout @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_fileobj @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_pipe @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_stderr_file @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_stdout_stderr_pipe @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_threadsafe_wait @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_and_text @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_communicate @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_communicate_encodings @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_communicate_input_none @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_communicate_stdin @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_universal_newlines_communicate_stdin_stdout_stderr @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_wait @ linux-x86_64 +test.test_subprocess.ProcessTestCase.test_writes_before_communicate @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_capture_output @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_capture_stderr @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_capture_stdout @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_check @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_check_output_input_arg @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_check_output_stdin_arg @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_check_output_stdin_with_input_arg @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_check_zero @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_encoding_warning @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_returncode @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_run_kwargs @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_run_with_bytes_path_and_arguments @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_run_with_pathlike_path @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_run_with_pathlike_path_and_arguments @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_run_with_shell_timeout_and_capture_output @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_stderr_with_capture_output_arg @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_stdout_with_capture_output_arg @ linux-x86_64 +test.test_subprocess.RunFuncTestCase.test_timeout @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sundry.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sundry.txt new file mode 100644 index 0000000000..c4f66e6af7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sundry.txt @@ -0,0 +1 @@ +test.test_sundry.TestUntestedModules.test_untested_modules_can_be_imported @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_super.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_super.txt new file mode 100644 index 0000000000..7934a15c8a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_super.txt @@ -0,0 +1,18 @@ +test.test_super.TestSuper.test___class___classmethod @ linux-x86_64 +test.test_super.TestSuper.test___class___delayed @ linux-x86_64 +test.test_super.TestSuper.test___class___instancemethod @ linux-x86_64 +test.test_super.TestSuper.test___class___new @ linux-x86_64 +test.test_super.TestSuper.test___class___staticmethod @ linux-x86_64 +test.test_super.TestSuper.test___classcell___expected_behaviour @ linux-x86_64 +test.test_super.TestSuper.test___classcell___overwrite @ linux-x86_64 +test.test_super.TestSuper.test_basics_working @ linux-x86_64 +test.test_super.TestSuper.test_cell_as_self @ linux-x86_64 +test.test_super.TestSuper.test_class_getattr_working @ linux-x86_64 +test.test_super.TestSuper.test_class_methods_still_working @ linux-x86_64 +test.test_super.TestSuper.test_obscure_super_errors @ linux-x86_64 +test.test_super.TestSuper.test_subclass_no_override_working @ linux-x86_64 +test.test_super.TestSuper.test_super_in_class_methods_working @ linux-x86_64 +test.test_super.TestSuper.test_super_init_leaks @ linux-x86_64 +test.test_super.TestSuper.test_super_with_closure @ linux-x86_64 +test.test_super.TestSuper.test_unbound_method_transfer_working @ linux-x86_64 +test.test_super.TestSuper.test_various___class___pathologies @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_support.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_support.txt new file mode 100644 index 0000000000..b8d3805bb1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_support.txt @@ -0,0 +1,41 @@ +test.test_support.TestSupport.test_CleanImport @ linux-x86_64 +test.test_support.TestSupport.test_DirsOnSysPath @ linux-x86_64 +test.test_support.TestSupport.test_HOST @ linux-x86_64 +test.test_support.TestSupport.test_bind_port @ linux-x86_64 +test.test_support.TestSupport.test_captured_stderr @ linux-x86_64 +test.test_support.TestSupport.test_captured_stdin @ linux-x86_64 +test.test_support.TestSupport.test_captured_stdout @ linux-x86_64 +test.test_support.TestSupport.test_change_cwd @ linux-x86_64 +test.test_support.TestSupport.test_change_cwd__chdir_warning @ linux-x86_64 +test.test_support.TestSupport.test_change_cwd__non_existent_dir @ linux-x86_64 +test.test_support.TestSupport.test_change_cwd__non_existent_dir__quiet_true @ linux-x86_64 +test.test_support.TestSupport.test_check__all__ @ linux-x86_64 +test.test_support.TestSupport.test_check_syntax_error @ linux-x86_64 +test.test_support.TestSupport.test_detect_api_mismatch @ linux-x86_64 +test.test_support.TestSupport.test_detect_api_mismatch__ignore @ linux-x86_64 +test.test_support.TestSupport.test_fd_count @ linux-x86_64 +test.test_support.TestSupport.test_find_unused_port @ linux-x86_64 +test.test_support.TestSupport.test_forget @ linux-x86_64 +test.test_support.TestSupport.test_gc_collect @ linux-x86_64 +test.test_support.TestSupport.test_get_attribute @ linux-x86_64 +test.test_support.TestSupport.test_has_strftime_extensions @ linux-x86_64 +test.test_support.TestSupport.test_ignored_deprecations_are_silent @ linux-x86_64 +test.test_support.TestSupport.test_import_fresh_module @ linux-x86_64 +test.test_support.TestSupport.test_import_module @ linux-x86_64 +test.test_support.TestSupport.test_make_bad_fd @ linux-x86_64 +test.test_support.TestSupport.test_parse_memlimit @ linux-x86_64 +test.test_support.TestSupport.test_print_warning @ linux-x86_64 +test.test_support.TestSupport.test_python_is_optimized @ linux-x86_64 +test.test_support.TestSupport.test_rmtree @ linux-x86_64 +test.test_support.TestSupport.test_set_memlimit @ linux-x86_64 +test.test_support.TestSupport.test_sortdict @ linux-x86_64 +test.test_support.TestSupport.test_swap_attr @ linux-x86_64 +test.test_support.TestSupport.test_swap_item @ linux-x86_64 +test.test_support.TestSupport.test_temp_cwd @ linux-x86_64 +test.test_support.TestSupport.test_temp_cwd__name_none @ linux-x86_64 +test.test_support.TestSupport.test_temp_dir @ linux-x86_64 +test.test_support.TestSupport.test_temp_dir__existing_dir__quiet_default @ linux-x86_64 +test.test_support.TestSupport.test_temp_dir__existing_dir__quiet_true @ linux-x86_64 +test.test_support.TestSupport.test_temp_dir__path_none @ linux-x86_64 +test.test_support.TestSupport.test_unlink @ linux-x86_64 +test.test_support.TestSupport.test_unload @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_syntax.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_syntax.txt new file mode 100644 index 0000000000..9daf680aec --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_syntax.txt @@ -0,0 +1,27 @@ +DocTestCase.test.test_syntax @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_assign_call @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_assign_del @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_bad_outdent @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_barry_as_flufl_with_syntax_errors @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_break_outside_loop @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_case_call_does_not_raise_syntax_error @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_continuation_bad_indentation @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_continue_outside_loop @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_curly_brace_after_primary_raises_immediately @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_empty_line_after_linecont @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_error_string_literal @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_except_star_then_except @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_except_then_except_star @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_expression_with_assignment @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_generator_in_function_call @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_global_param_err_first @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_invalid_line_continuation_left_recursive @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_kwargs_last @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_kwargs_last2 @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_kwargs_last3 @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_match_call_does_not_raise_syntax_error @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_no_indent @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_nonlocal_param_err_first @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_return_outside_function @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_unexpected_indent @ linux-x86_64 +test.test_syntax.SyntaxTestCase.test_yield_outside_function @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sys.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sys.txt new file mode 100644 index 0000000000..46b062ae4d --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sys.txt @@ -0,0 +1,39 @@ +test.test_sys.ActiveExceptionTests.test_exc_info_no_exception @ linux-x86_64 +test.test_sys.ActiveExceptionTests.test_exc_info_with_exception_instance @ linux-x86_64 +test.test_sys.ActiveExceptionTests.test_exc_info_with_exception_type @ linux-x86_64 +test.test_sys.ActiveExceptionTests.test_sys_exception_no_exception @ linux-x86_64 +test.test_sys.ActiveExceptionTests.test_sys_exception_with_exception_instance @ linux-x86_64 +test.test_sys.ActiveExceptionTests.test_sys_exception_with_exception_type @ linux-x86_64 +test.test_sys.DisplayHookTest.test_custom_displayhook @ linux-x86_64 +test.test_sys.DisplayHookTest.test_lost_displayhook @ linux-x86_64 +test.test_sys.DisplayHookTest.test_original_displayhook @ linux-x86_64 +test.test_sys.ExceptHookTest.test_excepthook @ linux-x86_64 +test.test_sys.ExceptHookTest.test_excepthook_bytes_filename @ linux-x86_64 +test.test_sys.ExceptHookTest.test_original_excepthook @ linux-x86_64 +test.test_sys.SysModuleTest.test_43581 @ linux-x86_64 +test.test_sys.SysModuleTest.test_attributes @ linux-x86_64 +test.test_sys.SysModuleTest.test_c_locale_surrogateescape @ linux-x86_64 +test.test_sys.SysModuleTest.test_dlopenflags @ linux-x86_64 +test.test_sys.SysModuleTest.test_executable @ linux-x86_64 +test.test_sys.SysModuleTest.test_exit @ linux-x86_64 +test.test_sys.SysModuleTest.test_getdefaultencoding @ linux-x86_64 +test.test_sys.SysModuleTest.test_getfilesystemencoding @ linux-x86_64 +test.test_sys.SysModuleTest.test_getframe @ linux-x86_64 +test.test_sys.SysModuleTest.test_getrecursionlimit @ linux-x86_64 +test.test_sys.SysModuleTest.test_implementation @ linux-x86_64 +test.test_sys.SysModuleTest.test_intern @ linux-x86_64 +test.test_sys.SysModuleTest.test_ioencoding @ linux-x86_64 +test.test_sys.SysModuleTest.test_module_names @ linux-x86_64 +test.test_sys.SysModuleTest.test_no_duplicates_in_meta_path @ linux-x86_64 +test.test_sys.SysModuleTest.test_orig_argv @ linux-x86_64 +test.test_sys.SysModuleTest.test_posix_locale_surrogateescape @ linux-x86_64 +test.test_sys.SysModuleTest.test_recursionlimit_recovery @ linux-x86_64 +test.test_sys.SysModuleTest.test_setrecursionlimit @ linux-x86_64 +test.test_sys.SysModuleTest.test_stdlib_dir @ linux-x86_64 +test.test_sys.SysModuleTest.test_switchinterval @ linux-x86_64 +test.test_sys.SysModuleTest.test_sys_flags @ linux-x86_64 +test.test_sys.SysModuleTest.test_sys_flags_no_instantiation @ linux-x86_64 +test.test_sys.SysModuleTest.test_sys_ignores_cleaning_up_user_data @ linux-x86_64 +test.test_sys.SysModuleTest.test_sys_tracebacklimit @ linux-x86_64 +test.test_sys.SysModuleTest.test_sys_version_info_no_instantiation @ linux-x86_64 +test.test_sys.SysModuleTest.test_thread_info @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sysconfig.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sysconfig.txt new file mode 100644 index 0000000000..620a3a68d6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_sysconfig.txt @@ -0,0 +1,18 @@ +test.test_sysconfig.MakefileTests.test_parse_makefile @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_EXT_SUFFIX_in_vars @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_config_h_filename @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_config_vars @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_default_scheme @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_path @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_path_names @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_paths @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_platform @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_preferred_schemes @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_get_scheme_names @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_ldshared_value @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_main @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_nt_venv_scheme @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_posix_venv_scheme @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_srcdir_independent_of_cwd @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_user_similar @ linux-x86_64 +test.test_sysconfig.TestSysConfig.test_venv_scheme @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tabnanny.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tabnanny.txt new file mode 100644 index 0000000000..3612533e2f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tabnanny.txt @@ -0,0 +1,19 @@ +test.test_tabnanny.TestCheck.test_correct_directory @ linux-x86_64 +test.test_tabnanny.TestCheck.test_correct_directory_verbose @ linux-x86_64 +test.test_tabnanny.TestCheck.test_correct_file @ linux-x86_64 +test.test_tabnanny.TestCheck.test_errored_directory @ linux-x86_64 +test.test_tabnanny.TestCheck.test_when_nannynag_error @ linux-x86_64 +test.test_tabnanny.TestCheck.test_when_nannynag_error_verbose @ linux-x86_64 +test.test_tabnanny.TestCheck.test_when_no_file @ linux-x86_64 +test.test_tabnanny.TestCheck.test_when_tokenize_tokenerror @ linux-x86_64 +test.test_tabnanny.TestCheck.test_when_wrong_indented @ linux-x86_64 +test.test_tabnanny.TestCommandLine.test_double_verbose_mode @ linux-x86_64 +test.test_tabnanny.TestCommandLine.test_quiet_flag @ linux-x86_64 +test.test_tabnanny.TestCommandLine.test_verbose_mode @ linux-x86_64 +test.test_tabnanny.TestCommandLine.test_with_error_free_file @ linux-x86_64 +test.test_tabnanny.TestCommandLine.test_with_errored_file @ linux-x86_64 +test.test_tabnanny.TestErrPrint.test_errprint @ linux-x86_64 +test.test_tabnanny.TestFormatWitnesses.test_format_witnesses @ linux-x86_64 +test.test_tabnanny.TestNannyNag.test_all_methods @ linux-x86_64 +test.test_tabnanny.TestProcessTokens.test_with_correct_code @ linux-x86_64 +test.test_tabnanny.TestProcessTokens.test_with_errored_codes_samples @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tarfile.txt new file mode 100644 index 0000000000..e903613266 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tarfile.txt @@ -0,0 +1,552 @@ +test.test_tarfile.AppendTest.test_empty @ linux-x86_64 +test.test_tarfile.AppendTest.test_empty_fileobj @ linux-x86_64 +test.test_tarfile.AppendTest.test_existing @ linux-x86_64 +test.test_tarfile.AppendTest.test_fileobj @ linux-x86_64 +test.test_tarfile.AppendTest.test_incomplete @ linux-x86_64 +test.test_tarfile.AppendTest.test_invalid @ linux-x86_64 +test.test_tarfile.AppendTest.test_non_existing @ linux-x86_64 +test.test_tarfile.AppendTest.test_null @ linux-x86_64 +test.test_tarfile.AppendTest.test_premature_eof @ linux-x86_64 +test.test_tarfile.AppendTest.test_trailing_garbage @ linux-x86_64 +test.test_tarfile.Bz2AppendTest.test_append_compressed @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_existing @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_existing_taropen @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_taropen @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_taropen_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_create_with_compresslevel @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.Bz2CreateTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.Bz2DetectReadTest.test_detect_file @ linux-x86_64 +test.test_tarfile.Bz2DetectReadTest.test_detect_fileobj @ linux-x86_64 +test.test_tarfile.Bz2DetectReadTest.test_detect_stream_bz2 @ linux-x86_64 +test.test_tarfile.Bz2ListTest.test_list @ linux-x86_64 +test.test_tarfile.Bz2ListTest.test_list_members @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_check_members @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_empty_name_attribute @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_extract_directory @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_extract_hardlink @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_extract_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_extractall @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_extractall_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_fail_comp @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_fileobj_with_offset @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_find_members @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_illegal_mode_arg @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_init_close_fobj @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_int_name_attribute @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_next_on_empty_tarfile @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_no_name_attribute @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_parallel_iteration @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_v7_dirtype @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_xstar_type @ linux-x86_64 +test.test_tarfile.Bz2MiscReadTest.test_zlib_error_does_not_leak @ linux-x86_64 +test.test_tarfile.Bz2PartialReadTest.test_partial_input @ linux-x86_64 +test.test_tarfile.Bz2PartialReadTest.test_partial_input_bz2 @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_compare_members @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_provoke_stream_error @ linux-x86_64 +test.test_tarfile.Bz2StreamReadTest.test_read_through @ linux-x86_64 +test.test_tarfile.Bz2StreamWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.Bz2StreamWriteTest.test_file_mode @ linux-x86_64 +test.test_tarfile.Bz2StreamWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.Bz2StreamWriteTest.test_stream_padding @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_add_dir_getmember @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_iter @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_link1 @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_link2 @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_readlines @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_seek @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_symlink1 @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_symlink2 @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_fileobj_text @ linux-x86_64 +test.test_tarfile.Bz2UstarReadTest.test_issue14160 @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_100_char_name @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_abs_pathnames @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_add_self @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_cwd @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_directory_size @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_extractall_symlinks @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_file_size @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_filter @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_gettarinfo_pathlike_name @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_link_size @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_open_nonwritable_fileobj @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_ordered_recursion @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_pathnames @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_symlink_size @ linux-x86_64 +test.test_tarfile.Bz2WriteTest.test_tar_size @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_bad_use @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_create_command @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_create_command_compressed @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_create_command_dot_started_filename @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_create_command_dotless_filename @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_create_command_verbose @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_extract_command @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_extract_command_different_directory @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_extract_command_filter @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_extract_command_invalid_file @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_extract_command_verbose @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_list_command @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_list_command_invalid_file @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_list_command_verbose @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_test_command @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_test_command_invalid_file @ linux-x86_64 +test.test_tarfile.CommandLineTest.test_test_command_verbose @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_basic @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_closed @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_eof @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_exception @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_fileobj @ linux-x86_64 +test.test_tarfile.ContextManagerTest.test_no_eof @ linux-x86_64 +test.test_tarfile.CreateTest.test_create @ linux-x86_64 +test.test_tarfile.CreateTest.test_create_existing @ linux-x86_64 +test.test_tarfile.CreateTest.test_create_existing_taropen @ linux-x86_64 +test.test_tarfile.CreateTest.test_create_pathlike_name @ linux-x86_64 +test.test_tarfile.CreateTest.test_create_taropen @ linux-x86_64 +test.test_tarfile.CreateTest.test_create_taropen_pathlike_name @ linux-x86_64 +test.test_tarfile.CreateTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.CreateTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_create @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_create_existing @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_create_pathlike_name @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_create_taropen_pathlike_name @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.CreateWithXModeTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.DetectReadTest.test_detect_file @ linux-x86_64 +test.test_tarfile.DetectReadTest.test_detect_fileobj @ linux-x86_64 +test.test_tarfile.DeviceHeaderTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.DeviceHeaderTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.DeviceHeaderTest.test_headers_written_only_for_device_files @ linux-x86_64 +test.test_tarfile.GNUReadTest.test_header_offset @ linux-x86_64 +test.test_tarfile.GNUReadTest.test_longname_directory @ linux-x86_64 +test.test_tarfile.GNUReadTest.test_read_longlink @ linux-x86_64 +test.test_tarfile.GNUReadTest.test_read_longname @ linux-x86_64 +test.test_tarfile.GNUReadTest.test_truncated_longname @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_bad_pax_header @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_iso8859_1_filename @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_uname_unicode @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_unicode_argument @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_unicode_filename_error @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_utf7_filename @ linux-x86_64 +test.test_tarfile.GNUUnicodeTest.test_utf8_filename @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longlink_1023 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longlink_1024 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longlink_1025 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longname_1023 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longname_1024 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longname_1025 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longnamelink_1023 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longnamelink_1024 @ linux-x86_64 +test.test_tarfile.GNUWriteTest.test_longnamelink_1025 @ linux-x86_64 +test.test_tarfile.GzipAppendTest.test_append_compressed @ linux-x86_64 +test.test_tarfile.GzipBrokenHeaderCorrectException.runTest @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_existing @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_existing_taropen @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_taropen @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_taropen_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_create_with_compresslevel @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.GzipCreateTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.GzipDetectReadTest.test_detect_file @ linux-x86_64 +test.test_tarfile.GzipDetectReadTest.test_detect_fileobj @ linux-x86_64 +test.test_tarfile.GzipListTest.test_list @ linux-x86_64 +test.test_tarfile.GzipListTest.test_list_members @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_bytes_name_attribute @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_check_members @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_empty_name_attribute @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_extract_directory @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_extract_hardlink @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_extract_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_extractall @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_extractall_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_fail_comp @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_fileobj_with_offset @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_find_members @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_illegal_mode_arg @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_init_close_fobj @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_int_name_attribute @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_next_on_empty_tarfile @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_no_name_argument @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_no_name_attribute @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_parallel_iteration @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_v7_dirtype @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_xstar_type @ linux-x86_64 +test.test_tarfile.GzipMiscReadTest.test_zlib_error_does_not_leak @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_compare_members @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_provoke_stream_error @ linux-x86_64 +test.test_tarfile.GzipStreamReadTest.test_read_through @ linux-x86_64 +test.test_tarfile.GzipStreamWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.GzipStreamWriteTest.test_file_mode @ linux-x86_64 +test.test_tarfile.GzipStreamWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.GzipStreamWriteTest.test_source_directory_not_leaked @ linux-x86_64 +test.test_tarfile.GzipStreamWriteTest.test_stream_padding @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_add_dir_getmember @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_iter @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_link1 @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_link2 @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_readlines @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_seek @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_symlink1 @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_symlink2 @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_fileobj_text @ linux-x86_64 +test.test_tarfile.GzipUstarReadTest.test_issue14160 @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_100_char_name @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_abs_pathnames @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_add_self @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_cwd @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_directory_size @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_extractall_symlinks @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_file_size @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_filter @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_gettarinfo_pathlike_name @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_link_size @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_open_nonwritable_fileobj @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_ordered_recursion @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_pathnames @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_symlink_size @ linux-x86_64 +test.test_tarfile.GzipWriteTest.test_tar_size @ linux-x86_64 +test.test_tarfile.HardlinkTest.test_add_hardlink @ linux-x86_64 +test.test_tarfile.HardlinkTest.test_add_twice @ linux-x86_64 +test.test_tarfile.HardlinkTest.test_dereference_hardlink @ linux-x86_64 +test.test_tarfile.LimitsTest.test_gnu_limits @ linux-x86_64 +test.test_tarfile.LimitsTest.test_pax_limits @ linux-x86_64 +test.test_tarfile.LimitsTest.test_ustar_limits @ linux-x86_64 +test.test_tarfile.ListTest.test_list @ linux-x86_64 +test.test_tarfile.ListTest.test_list_members @ linux-x86_64 +test.test_tarfile.LzmaAppendTest.test_append_compressed @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_existing @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_existing_taropen @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_taropen @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_taropen_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_create_with_preset @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.LzmaCreateTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.LzmaDetectReadTest.test_detect_file @ linux-x86_64 +test.test_tarfile.LzmaDetectReadTest.test_detect_fileobj @ linux-x86_64 +test.test_tarfile.LzmaListTest.test_list @ linux-x86_64 +test.test_tarfile.LzmaListTest.test_list_members @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_check_members @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_empty_name_attribute @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extract_directory @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extract_hardlink @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extract_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extractall @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_extractall_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_fail_comp @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_fileobj_with_offset @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_find_members @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_illegal_mode_arg @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_init_close_fobj @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_int_name_attribute @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_next_on_empty_tarfile @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_compare_members @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_read_through @ linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_file_mode @ linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_add_dir_getmember @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_100_char_name @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_abs_pathnames @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_add_self @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_cwd @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_directory_size @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_extractall_symlinks @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_file_size @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_filter @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_gettarinfo_pathlike_name @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_link_size @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_ordered_recursion @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_pathnames @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_symlink_size @ linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_tar_size @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_blktype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_chrtype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_conttype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_dirtype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_fifotype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_lnktype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_regtype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_sparse @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_symtype @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_umlauts @ linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_ustar_longname @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_check_members @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_empty_name_attribute @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_extract_directory @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_extract_hardlink @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_extractall @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_find_members @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_init_close_fobj @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_int_name_attribute @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_next_on_empty_tarfile @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_no_name_argument @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_no_name_attribute @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_parallel_iteration @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_pathlike_name @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_v7_dirtype @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_xstar_type @ linux-x86_64 +test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ linux-x86_64 +test.test_tarfile.MiscTest.test__all__ @ linux-x86_64 +test.test_tarfile.MiscTest.test_char_fields @ linux-x86_64 +test.test_tarfile.MiscTest.test_number_field_limits @ linux-x86_64 +test.test_tarfile.MiscTest.test_read_number_fields @ linux-x86_64 +test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ linux-x86_64 +test.test_tarfile.MiscTest.test_write_number_fields @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ linux-x86_64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ linux-x86_64 +test.test_tarfile.NoneInfoTests_Misc.test_add @ linux-x86_64 +test.test_tarfile.NoneInfoTests_Misc.test_list @ linux-x86_64 +test.test_tarfile.NumericOwnerTest.test_extract_with_numeric_owner @ linux-x86_64 +test.test_tarfile.NumericOwnerTest.test_extractall_with_numeric_owner @ linux-x86_64 +test.test_tarfile.NumericOwnerTest.test_keyword_only @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_binary_header @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_header_offset @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_longname_directory @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_pax_global_headers @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_pax_number_fields @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_read_longlink @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_read_longname @ linux-x86_64 +test.test_tarfile.PaxReadTest.test_truncated_longname @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_create_pax_header @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1023 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1024 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longlink_1025 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1023 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1024 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longname_1025 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_pax_extended_header @ linux-x86_64 +test.test_tarfile.PaxWriteTest.test_pax_global_header @ linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_all @ linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_deep @ linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_internal @ linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_name @ linux-x86_64 +test.test_tarfile.ReplaceTests.test_replace_shallow @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_compare_members @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_empty_tarfile @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_ignore_zeros @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_length_zero_header @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_null_tarfile @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_premature_end_of_archive @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_provoke_stream_error @ linux-x86_64 +test.test_tarfile.StreamReadTest.test_read_through @ linux-x86_64 +test.test_tarfile.StreamWriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.StreamWriteTest.test_file_mode @ linux-x86_64 +test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.StreamWriteTest.test_stream_padding @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_absolute @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_absolute_symlink @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_bad_filter_name @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_benign_file @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_chains @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_custom_filter @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_data_filter @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_deep_symlink @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_default_filter_warns_not @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_errorlevel @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_parent_symlink @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_parent_symlink2 @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_pipe @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_sly_relative0 @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_sly_relative2 @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_special_files @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_stateful_filter @ linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_tar_filter @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_add_dir_getmember @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_iter @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_link1 @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_link2 @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_readlines @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_seek @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_text @ linux-x86_64 +test.test_tarfile.UstarReadTest.test_issue14160 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_uname_unicode @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_link1 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_link2 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ linux-x86_64 +test.test_tarfile.WriteTest.test_100_char_name @ linux-x86_64 +test.test_tarfile.WriteTest.test_abs_pathnames @ linux-x86_64 +test.test_tarfile.WriteTest.test_add_self @ linux-x86_64 +test.test_tarfile.WriteTest.test_cwd @ linux-x86_64 +test.test_tarfile.WriteTest.test_directory_size @ linux-x86_64 +test.test_tarfile.WriteTest.test_eof_marker @ linux-x86_64 +test.test_tarfile.WriteTest.test_extractall_symlinks @ linux-x86_64 +test.test_tarfile.WriteTest.test_file_size @ linux-x86_64 +test.test_tarfile.WriteTest.test_fileobj_no_close @ linux-x86_64 +test.test_tarfile.WriteTest.test_filter @ linux-x86_64 +test.test_tarfile.WriteTest.test_gettarinfo_pathlike_name @ linux-x86_64 +test.test_tarfile.WriteTest.test_link_size @ linux-x86_64 +test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ linux-x86_64 +test.test_tarfile.WriteTest.test_ordered_recursion @ linux-x86_64 +test.test_tarfile.WriteTest.test_pathnames @ linux-x86_64 +test.test_tarfile.WriteTest.test_symlink_size @ linux-x86_64 +test.test_tarfile.WriteTest.test_tar_size @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_telnetlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_telnetlib.txt new file mode 100644 index 0000000000..64870de1a7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_telnetlib.txt @@ -0,0 +1,19 @@ +test.test_telnetlib.ExpectTests.test_expect @ linux-x86_64 +test.test_telnetlib.GeneralTests.testBasic @ linux-x86_64 +test.test_telnetlib.GeneralTests.testContextManager @ linux-x86_64 +test.test_telnetlib.GeneralTests.testGetters @ linux-x86_64 +test.test_telnetlib.GeneralTests.testTimeoutDefault @ linux-x86_64 +test.test_telnetlib.GeneralTests.testTimeoutNone @ linux-x86_64 +test.test_telnetlib.GeneralTests.testTimeoutOpen @ linux-x86_64 +test.test_telnetlib.GeneralTests.testTimeoutValue @ linux-x86_64 +test.test_telnetlib.OptionTests.test_IAC_commands @ linux-x86_64 +test.test_telnetlib.OptionTests.test_SB_commands @ linux-x86_64 +test.test_telnetlib.OptionTests.test_debug_accepts_str_port @ linux-x86_64 +test.test_telnetlib.OptionTests.test_debuglevel_reads @ linux-x86_64 +test.test_telnetlib.OptionTests.test_debuglevel_write @ linux-x86_64 +test.test_telnetlib.ReadTests.test_read_all @ linux-x86_64 +test.test_telnetlib.ReadTests.test_read_eager @ linux-x86_64 +test.test_telnetlib.ReadTests.test_read_lazy @ linux-x86_64 +test.test_telnetlib.ReadTests.test_read_some @ linux-x86_64 +test.test_telnetlib.ReadTests.test_read_until @ linux-x86_64 +test.test_telnetlib.WriteTests.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tempfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tempfile.txt new file mode 100644 index 0000000000..76c664093e --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tempfile.txt @@ -0,0 +1,94 @@ +test.test_tempfile.TestCandidateTempdirList.test_nonempty_list @ linux-x86_64 +test.test_tempfile.TestCandidateTempdirList.test_wanted_dirs @ linux-x86_64 +test.test_tempfile.TestExports.test_exports @ linux-x86_64 +test.test_tempfile.TestGetCandidateNames.test_retval @ linux-x86_64 +test.test_tempfile.TestGetCandidateNames.test_same_thing @ linux-x86_64 +test.test_tempfile.TestGetDefaultTempdir.test_no_files_left_behind @ linux-x86_64 +test.test_tempfile.TestGetTempDir.test_case_sensitive @ linux-x86_64 +test.test_tempfile.TestGetTempDir.test_directory_exists @ linux-x86_64 +test.test_tempfile.TestGetTempDir.test_directory_writable @ linux-x86_64 +test.test_tempfile.TestGetTempDir.test_same_thing @ linux-x86_64 +test.test_tempfile.TestGetTempPrefix.test_sane_template @ linux-x86_64 +test.test_tempfile.TestGetTempPrefix.test_usable_template @ linux-x86_64 +test.test_tempfile.TestLowLevelInternals.test_infer_return_type_multiples @ linux-x86_64 +test.test_tempfile.TestLowLevelInternals.test_infer_return_type_multiples_and_none @ linux-x86_64 +test.test_tempfile.TestLowLevelInternals.test_infer_return_type_pathlib @ linux-x86_64 +test.test_tempfile.TestLowLevelInternals.test_infer_return_type_pathlike @ linux-x86_64 +test.test_tempfile.TestLowLevelInternals.test_infer_return_type_singles @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_basic @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_basic_many @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_basic_with_bytes_names @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_choose_directory @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_collision_with_existing_directory @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_collision_with_existing_file @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_for_tempdir_is_bytes_issue40701_api_warts @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_mode @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_non_directory @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_nonexisting_directory @ linux-x86_64 +test.test_tempfile.TestMkdtemp.test_read_only_directory @ linux-x86_64 +test.test_tempfile.TestMkstemp.test_basic @ linux-x86_64 +test.test_tempfile.TestMkstemp.test_basic_with_bytes_names @ linux-x86_64 +test.test_tempfile.TestMkstemp.test_choose_directory @ linux-x86_64 +test.test_tempfile.TestMkstemp.test_for_tempdir_is_bytes_issue40701_api_warts @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_basic @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_basic_many @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_basic_with_bytes_names @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_collision_with_existing_directory @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_collision_with_existing_file @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_file_mode @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_non_directory @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_nonexisting_directory @ linux-x86_64 +test.test_tempfile.TestMkstempInner.test_read_only_directory @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_bad_encoding @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_bad_mode @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_basic @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_context_manager @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_creates_named @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_del_on_close @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_dis_del_on_close @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_iter @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_method_lookup @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_multiple_close @ linux-x86_64 +test.test_tempfile.TestNamedTemporaryFile.test_unexpected_error @ linux-x86_64 +test.test_tempfile.TestRandomNameSequence.test_get_eight_char_str @ linux-x86_64 +test.test_tempfile.TestRandomNameSequence.test_many @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_basic @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_bound_methods @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_class_getitem @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_context_manager_after_rollover @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_context_manager_before_rollover @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_context_manager_during_rollover @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_del_on_close @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_del_rolled_file @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_del_unrolled_file @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_fileno @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_iobase_interface @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_is_iobase @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_multiple_close_after_rollover @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_multiple_close_before_rollover @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_properties @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_rewrite_small @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_sparse @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_text_mode @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_text_newline_and_encoding @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_truncate_with_size_parameter @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_write_sequential @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_writelines @ linux-x86_64 +test.test_tempfile.TestSpooledTemporaryFile.test_writelines_sequential @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_cleanup_with_symlink_to_a_directory @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_context_manager @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_del_on_shutdown @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_del_on_shutdown_ignore_errors @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_exit_on_shutdown @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_explicit_cleanup @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_explict_cleanup_ignore_errors @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_mkdtemp_failure @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_modes @ linux-x86_64 +test.test_tempfile.TestTemporaryDirectory.test_multiple_close @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_bad_encoding @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_bad_mode @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_basic @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_has_no_name @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_mode_and_encoding @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_multiple_close @ linux-x86_64 +test.test_tempfile.TestTemporaryFile.test_unexpected_error @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_termios.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_termios.txt new file mode 100644 index 0000000000..7735e458a0 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_termios.txt @@ -0,0 +1,18 @@ +test.test_termios.TestFunctions.test_tcdrain @ linux-x86_64 +test.test_termios.TestFunctions.test_tcdrain_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcflow @ linux-x86_64 +test.test_termios.TestFunctions.test_tcflow_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcflush @ linux-x86_64 +test.test_termios.TestFunctions.test_tcflush_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcgetattr @ linux-x86_64 +test.test_termios.TestFunctions.test_tcgetattr_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcgetwinsize @ linux-x86_64 +test.test_termios.TestFunctions.test_tcgetwinsize_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsendbreak @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsendbreak_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsetattr @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsetattr_errors @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsetwinsize @ linux-x86_64 +test.test_termios.TestFunctions.test_tcsetwinsize_errors @ linux-x86_64 +test.test_termios.TestModule.test_constants @ linux-x86_64 +test.test_termios.TestModule.test_exception @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_textwrap.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_textwrap.txt new file mode 100644 index 0000000000..32ee862849 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_textwrap.txt @@ -0,0 +1,66 @@ +test.test_textwrap.DedentTestCase.test_dedent_declining @ linux-x86_64 +test.test_textwrap.DedentTestCase.test_dedent_even @ linux-x86_64 +test.test_textwrap.DedentTestCase.test_dedent_nomargin @ linux-x86_64 +test.test_textwrap.DedentTestCase.test_dedent_preserve_internal_tabs @ linux-x86_64 +test.test_textwrap.DedentTestCase.test_dedent_preserve_margin_tabs @ linux-x86_64 +test.test_textwrap.DedentTestCase.test_dedent_uneven @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_all_lines @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_default @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_empty_lines @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_explicit_default @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_no_lines @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_nomargin_all_lines @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_nomargin_default @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_indent_nomargin_explicit_default @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_roundtrip_mixed @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_roundtrip_spaces @ linux-x86_64 +test.test_textwrap.IndentTestCase.test_roundtrip_tabs @ linux-x86_64 +test.test_textwrap.IndentTestCases.test_fill @ linux-x86_64 +test.test_textwrap.IndentTestCases.test_initial_indent @ linux-x86_64 +test.test_textwrap.IndentTestCases.test_subsequent_indent @ linux-x86_64 +test.test_textwrap.LongWordTestCase.test_break_long @ linux-x86_64 +test.test_textwrap.LongWordTestCase.test_max_lines_long @ linux-x86_64 +test.test_textwrap.LongWordTestCase.test_nobreak_long @ linux-x86_64 +test.test_textwrap.LongWordWithHyphensTestCase.test_break_long_words_not_on_hyphen @ linux-x86_64 +test.test_textwrap.LongWordWithHyphensTestCase.test_break_long_words_on_hyphen @ linux-x86_64 +test.test_textwrap.LongWordWithHyphensTestCase.test_break_on_hyphen_but_not_long_words @ linux-x86_64 +test.test_textwrap.LongWordWithHyphensTestCase.test_do_not_break_long_words_or_on_hyphens @ linux-x86_64 +test.test_textwrap.MaxLinesTestCase.test_placeholder @ linux-x86_64 +test.test_textwrap.MaxLinesTestCase.test_placeholder_backtrack @ linux-x86_64 +test.test_textwrap.MaxLinesTestCase.test_simple @ linux-x86_64 +test.test_textwrap.MaxLinesTestCase.test_spaces @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_empty_string @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_first_word_too_long_but_placeholder_fits @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_placeholder @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_simple @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_whitespace @ linux-x86_64 +test.test_textwrap.ShortenTestCase.test_width_too_small_for_placeholder @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_bad_width @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_break_on_hyphens @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_false @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_false_whitespace_only @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_false_whitespace_only_with_indent @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_leading_whitespace @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_whitespace_indent @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_whitespace_line @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_whitespace_only @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_drop_whitespace_whitespace_only_with_indent @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_em_dash @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_empty_string @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_empty_string_with_initial_indent @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_fix_sentence_endings @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_funky_hyphens @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_funky_parens @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_hyphenated @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_hyphenated_numbers @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_narrow_non_breaking_space @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_no_split_at_umlaut @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_non_breaking_space @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_punct_hyphens @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_simple @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_split @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_umlaut_followed_by_dash @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_unix_options @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_whitespace @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_wrap_short @ linux-x86_64 +test.test_textwrap.WrapTestCase.test_wrap_short_1line @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_thread.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_thread.txt new file mode 100644 index 0000000000..b74b8246e5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_thread.txt @@ -0,0 +1,20 @@ +test.test_thread.BarrierTest.test_barrier @ linux-x86_64 +test.test_thread.LockTests.test_acquire_contended @ linux-x86_64 +test.test_thread.LockTests.test_acquire_destroy @ linux-x86_64 +test.test_thread.LockTests.test_acquire_release @ linux-x86_64 +test.test_thread.LockTests.test_constructor @ linux-x86_64 +test.test_thread.LockTests.test_different_thread @ linux-x86_64 +test.test_thread.LockTests.test_locked_repr @ linux-x86_64 +test.test_thread.LockTests.test_reacquire @ linux-x86_64 +test.test_thread.LockTests.test_repr @ linux-x86_64 +test.test_thread.LockTests.test_state_after_timeout @ linux-x86_64 +test.test_thread.LockTests.test_thread_leak @ linux-x86_64 +test.test_thread.LockTests.test_timeout @ linux-x86_64 +test.test_thread.LockTests.test_try_acquire @ linux-x86_64 +test.test_thread.LockTests.test_try_acquire_contended @ linux-x86_64 +test.test_thread.LockTests.test_weakref_exists @ linux-x86_64 +test.test_thread.LockTests.test_with @ linux-x86_64 +test.test_thread.ThreadRunningTests.test__count @ linux-x86_64 +test.test_thread.ThreadRunningTests.test_nt_and_posix_stack_size @ linux-x86_64 +test.test_thread.ThreadRunningTests.test_stack_size @ linux-x86_64 +test.test_thread.ThreadRunningTests.test_starting_threads @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadedtempfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadedtempfile.txt new file mode 100644 index 0000000000..5b419df28f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadedtempfile.txt @@ -0,0 +1 @@ +test.test_threadedtempfile.ThreadedTempFileTest.test_main @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading.txt new file mode 100644 index 0000000000..d5be4bb77f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading.txt @@ -0,0 +1,158 @@ +test.test_threading.AtexitTests.test_atexit_called_once @ linux-x86_64 +test.test_threading.AtexitTests.test_atexit_output @ linux-x86_64 +test.test_threading.BarrierTests.test_abort @ linux-x86_64 +test.test_threading.BarrierTests.test_abort_and_reset @ linux-x86_64 +test.test_threading.BarrierTests.test_action @ linux-x86_64 +test.test_threading.BarrierTests.test_barrier @ linux-x86_64 +test.test_threading.BarrierTests.test_barrier_10 @ linux-x86_64 +test.test_threading.BarrierTests.test_default_timeout @ linux-x86_64 +test.test_threading.BarrierTests.test_repr @ linux-x86_64 +test.test_threading.BarrierTests.test_reset @ linux-x86_64 +test.test_threading.BarrierTests.test_single_thread @ linux-x86_64 +test.test_threading.BarrierTests.test_timeout @ linux-x86_64 +test.test_threading.BarrierTests.test_wait_return @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_acquire @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_acquire_contended @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_acquire_timeout @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_constructor @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_default_value @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_multirelease @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_release_unacquired @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_repr @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_try_acquire @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.BoundedSemaphoreTests.test_with @ linux-x86_64 +test.test_threading.CRLockTests.test__is_owned @ linux-x86_64 +test.test_threading.CRLockTests.test_acquire_contended @ linux-x86_64 +test.test_threading.CRLockTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.CRLockTests.test_acquire_release @ linux-x86_64 +test.test_threading.CRLockTests.test_constructor @ linux-x86_64 +test.test_threading.CRLockTests.test_different_thread @ linux-x86_64 +test.test_threading.CRLockTests.test_locked_repr @ linux-x86_64 +test.test_threading.CRLockTests.test_reacquire @ linux-x86_64 +test.test_threading.CRLockTests.test_recursion_count @ linux-x86_64 +test.test_threading.CRLockTests.test_release_save_unacquired @ linux-x86_64 +test.test_threading.CRLockTests.test_release_unacquired @ linux-x86_64 +test.test_threading.CRLockTests.test_repr @ linux-x86_64 +test.test_threading.CRLockTests.test_thread_leak @ linux-x86_64 +test.test_threading.CRLockTests.test_timeout @ linux-x86_64 +test.test_threading.CRLockTests.test_try_acquire @ linux-x86_64 +test.test_threading.CRLockTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.CRLockTests.test_weakref_exists @ linux-x86_64 +test.test_threading.CRLockTests.test_with @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test__is_owned @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_acquire_contended @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_acquire_release @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_constructor @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_different_thread @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_locked_repr @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_reacquire @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_release_save_unacquired @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_release_unacquired @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_repr @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_thread_leak @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_timeout @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_try_acquire @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_weakref_exists @ linux-x86_64 +test.test_threading.ConditionAsRLockTests.test_with @ linux-x86_64 +test.test_threading.ConditionTests.test_acquire @ linux-x86_64 +test.test_threading.ConditionTests.test_notify @ linux-x86_64 +test.test_threading.ConditionTests.test_timeout @ linux-x86_64 +test.test_threading.ConditionTests.test_unacquired_notify @ linux-x86_64 +test.test_threading.ConditionTests.test_unacquired_wait @ linux-x86_64 +test.test_threading.ConditionTests.test_waitfor @ linux-x86_64 +test.test_threading.ConditionTests.test_waitfor_timeout @ linux-x86_64 +test.test_threading.EventTests.test_is_set @ linux-x86_64 +test.test_threading.EventTests.test_notify @ linux-x86_64 +test.test_threading.EventTests.test_repr @ linux-x86_64 +test.test_threading.EventTests.test_set_and_clear @ linux-x86_64 +test.test_threading.EventTests.test_timeout @ linux-x86_64 +test.test_threading.ExceptHookTests.test_custom_excepthook @ linux-x86_64 +test.test_threading.ExceptHookTests.test_custom_excepthook_fail @ linux-x86_64 +test.test_threading.ExceptHookTests.test_excepthook @ linux-x86_64 +test.test_threading.ExceptHookTests.test_original_excepthook @ linux-x86_64 +test.test_threading.ExceptHookTests.test_system_exit @ linux-x86_64 +test.test_threading.InterruptMainTests.test_interrupt_main_noerror @ linux-x86_64 +test.test_threading.LockTests.test_acquire_contended @ linux-x86_64 +test.test_threading.LockTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.LockTests.test_acquire_release @ linux-x86_64 +test.test_threading.LockTests.test_constructor @ linux-x86_64 +test.test_threading.LockTests.test_different_thread @ linux-x86_64 +test.test_threading.LockTests.test_locked_repr @ linux-x86_64 +test.test_threading.LockTests.test_reacquire @ linux-x86_64 +test.test_threading.LockTests.test_repr @ linux-x86_64 +test.test_threading.LockTests.test_state_after_timeout @ linux-x86_64 +test.test_threading.LockTests.test_thread_leak @ linux-x86_64 +test.test_threading.LockTests.test_timeout @ linux-x86_64 +test.test_threading.LockTests.test_try_acquire @ linux-x86_64 +test.test_threading.LockTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.LockTests.test_weakref_exists @ linux-x86_64 +test.test_threading.LockTests.test_with @ linux-x86_64 +test.test_threading.MiscTestCase.test__all__ @ linux-x86_64 +test.test_threading.PyRLockTests.test__is_owned @ linux-x86_64 +test.test_threading.PyRLockTests.test_acquire_contended @ linux-x86_64 +test.test_threading.PyRLockTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.PyRLockTests.test_acquire_release @ linux-x86_64 +test.test_threading.PyRLockTests.test_constructor @ linux-x86_64 +test.test_threading.PyRLockTests.test_different_thread @ linux-x86_64 +test.test_threading.PyRLockTests.test_locked_repr @ linux-x86_64 +test.test_threading.PyRLockTests.test_reacquire @ linux-x86_64 +test.test_threading.PyRLockTests.test_recursion_count @ linux-x86_64 +test.test_threading.PyRLockTests.test_release_save_unacquired @ linux-x86_64 +test.test_threading.PyRLockTests.test_release_unacquired @ linux-x86_64 +test.test_threading.PyRLockTests.test_repr @ linux-x86_64 +test.test_threading.PyRLockTests.test_thread_leak @ linux-x86_64 +test.test_threading.PyRLockTests.test_timeout @ linux-x86_64 +test.test_threading.PyRLockTests.test_try_acquire @ linux-x86_64 +test.test_threading.PyRLockTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.PyRLockTests.test_weakref_exists @ linux-x86_64 +test.test_threading.PyRLockTests.test_with @ linux-x86_64 +test.test_threading.SemaphoreTests.test_acquire @ linux-x86_64 +test.test_threading.SemaphoreTests.test_acquire_contended @ linux-x86_64 +test.test_threading.SemaphoreTests.test_acquire_destroy @ linux-x86_64 +test.test_threading.SemaphoreTests.test_acquire_timeout @ linux-x86_64 +test.test_threading.SemaphoreTests.test_constructor @ linux-x86_64 +test.test_threading.SemaphoreTests.test_default_value @ linux-x86_64 +test.test_threading.SemaphoreTests.test_multirelease @ linux-x86_64 +test.test_threading.SemaphoreTests.test_release_unacquired @ linux-x86_64 +test.test_threading.SemaphoreTests.test_repr @ linux-x86_64 +test.test_threading.SemaphoreTests.test_try_acquire @ linux-x86_64 +test.test_threading.SemaphoreTests.test_try_acquire_contended @ linux-x86_64 +test.test_threading.SemaphoreTests.test_with @ linux-x86_64 +!test.test_threading.ThreadJoinOnShutdown.test_4_daemon_threads @ linux-x86_64 +test.test_threading.ThreadTests.test_BoundedSemaphore_limit @ linux-x86_64 +test.test_threading.ThreadTests.test_args_argument @ linux-x86_64 +test.test_threading.ThreadTests.test_boolean_target @ linux-x86_64 +test.test_threading.ThreadTests.test_daemon_param @ linux-x86_64 +test.test_threading.ThreadTests.test_enumerate_after_join @ linux-x86_64 +!test.test_threading.ThreadTests.test_finalization_shutdown @ linux-x86_64 +!test.test_threading.ThreadTests.test_finalize_with_trace @ linux-x86_64 +test.test_threading.ThreadTests.test_foreign_thread @ linux-x86_64 +test.test_threading.ThreadTests.test_getprofile @ linux-x86_64 +test.test_threading.ThreadTests.test_gettrace @ linux-x86_64 +test.test_threading.ThreadTests.test_ident_of_no_threading_threads @ linux-x86_64 +!test.test_threading.ThreadTests.test_import_from_another_thread @ linux-x86_64 +!test.test_threading.ThreadTests.test_join_nondaemon_on_shutdown @ linux-x86_64 +test.test_threading.ThreadTests.test_leak_without_join @ linux-x86_64 +test.test_threading.ThreadTests.test_limbo_cleanup @ linux-x86_64 +test.test_threading.ThreadTests.test_main_thread @ linux-x86_64 +test.test_threading.ThreadTests.test_old_threading_api @ linux-x86_64 +test.test_threading.ThreadTests.test_repr_daemon @ linux-x86_64 +test.test_threading.ThreadTests.test_repr_stopped @ linux-x86_64 +test.test_threading.ThreadTests.test_tstate_lock @ linux-x86_64 +test.test_threading.ThreadTests.test_various_ops @ linux-x86_64 +test.test_threading.ThreadTests.test_various_ops_large_stack @ linux-x86_64 +test.test_threading.ThreadTests.test_various_ops_small_stack @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_bare_raise_in_brand_new_thread @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_daemonize_active_thread @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_joining_current_thread @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_joining_inactive_thread @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_multithread_modify_file_noerror @ linux-x86_64 +!test.test_threading.ThreadingExceptionTests.test_print_exception @ linux-x86_64 +!test.test_threading.ThreadingExceptionTests.test_print_exception_stderr_is_none_1 @ linux-x86_64 +!test.test_threading.ThreadingExceptionTests.test_print_exception_stderr_is_none_2 @ linux-x86_64 +test.test_threading.ThreadingExceptionTests.test_start_thread_again @ linux-x86_64 +test.test_threading.TimerTests.test_init_immutable_default_args @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading_local.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading_local.txt new file mode 100644 index 0000000000..401bc5f565 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threading_local.txt @@ -0,0 +1,15 @@ +!DocTestCase._threading_local @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_arguments @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_derived @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_derived_cycle_dealloc @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_dict_attribute @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_dict_attribute_subclass @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_threading_local @ linux-x86_64 +test.test_threading_local.PyThreadingLocalTest.test_threading_local_subclass @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_arguments @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_derived @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_derived_cycle_dealloc @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_dict_attribute @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_dict_attribute_subclass @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_threading_local @ linux-x86_64 +test.test_threading_local.ThreadLocalTest.test_threading_local_subclass @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadsignals.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadsignals.txt new file mode 100644 index 0000000000..f00fb4dab4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_threadsignals.txt @@ -0,0 +1,3 @@ +test.test_threadsignals.ThreadSignals.test_lock_acquire_retries_on_intr @ linux-x86_64 +test.test_threadsignals.ThreadSignals.test_rlock_acquire_retries_on_intr @ linux-x86_64 +test.test_threadsignals.ThreadSignals.test_signals @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_time.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_time.txt new file mode 100644 index 0000000000..0f81dc29a6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_time.txt @@ -0,0 +1,32 @@ +test.test_time.TestAsctime4dyear.test_large_year @ linux-x86_64 +test.test_time.TestAsctime4dyear.test_negative @ linux-x86_64 +test.test_time.TestAsctime4dyear.test_year @ linux-x86_64 +test.test_time.TestLocale.test_bug_3061 @ linux-x86_64 +test.test_time.TestPytime.test_localtime_timezone @ linux-x86_64 +test.test_time.TestPytime.test_short_times @ linux-x86_64 +test.test_time.TestStrftime4dyear.test_large_year @ linux-x86_64 +test.test_time.TestStrftime4dyear.test_negative @ linux-x86_64 +test.test_time.TestStrftime4dyear.test_year @ linux-x86_64 +test.test_time.TimeTestCase.test_asctime @ linux-x86_64 +test.test_time.TimeTestCase.test_asctime_bounding_check @ linux-x86_64 +test.test_time.TimeTestCase.test_conversions @ linux-x86_64 +test.test_time.TimeTestCase.test_ctime @ linux-x86_64 +test.test_time.TimeTestCase.test_ctime_without_arg @ linux-x86_64 +test.test_time.TimeTestCase.test_data_attributes @ linux-x86_64 +test.test_time.TimeTestCase.test_default_values_for_zero @ linux-x86_64 +test.test_time.TimeTestCase.test_epoch @ linux-x86_64 +test.test_time.TimeTestCase.test_get_clock_info @ linux-x86_64 +test.test_time.TimeTestCase.test_insane_timestamps @ linux-x86_64 +test.test_time.TimeTestCase.test_mktime @ linux-x86_64 +test.test_time.TimeTestCase.test_monotonic @ linux-x86_64 +test.test_time.TimeTestCase.test_perf_counter @ linux-x86_64 +test.test_time.TimeTestCase.test_process_time @ linux-x86_64 +test.test_time.TimeTestCase.test_sleep @ linux-x86_64 +test.test_time.TimeTestCase.test_strftime @ linux-x86_64 +test.test_time.TimeTestCase.test_strftime_bounding_check @ linux-x86_64 +test.test_time.TimeTestCase.test_strftime_format_check @ linux-x86_64 +test.test_time.TimeTestCase.test_strptime_bytes @ linux-x86_64 +test.test_time.TimeTestCase.test_strptime_exception_context @ linux-x86_64 +test.test_time.TimeTestCase.test_thread_time @ linux-x86_64 +test.test_time.TimeTestCase.test_time @ linux-x86_64 +test.test_time.TimeTestCase.test_time_ns_type @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeit.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeit.txt new file mode 100644 index 0000000000..c878cc9509 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeit.txt @@ -0,0 +1,39 @@ +test.test_timeit.TestTimeit.test_autorange @ linux-x86_64 +test.test_timeit.TestTimeit.test_autorange_second @ linux-x86_64 +test.test_timeit.TestTimeit.test_autorange_with_callback @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_bad_switch @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_exception @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_exception_fixed_reps @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_fixed_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_fixed_reps @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_help @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_microseconds @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_milliseconds @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_multiple_setups @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_negative_reps @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_seconds @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_setup @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_verbose @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_very_verbose @ linux-x86_64 +test.test_timeit.TestTimeit.test_main_with_time_unit @ linux-x86_64 +test.test_timeit.TestTimeit.test_print_exc @ linux-x86_64 +test.test_timeit.TestTimeit.test_reindent_empty @ linux-x86_64 +test.test_timeit.TestTimeit.test_reindent_multi @ linux-x86_64 +test.test_timeit.TestTimeit.test_reindent_multi_empty @ linux-x86_64 +test.test_timeit.TestTimeit.test_reindent_single @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_callable_setup @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_callable_stmt @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_callable_stmt_and_setup @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_few_reps_and_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_function_zero_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_function_zero_reps @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_zero_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_repeat_zero_reps @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_callable_setup @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_callable_stmt @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_callable_stmt_and_setup @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_few_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_function_zero_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_globals_args @ linux-x86_64 +test.test_timeit.TestTimeit.test_timeit_zero_iters @ linux-x86_64 +test.test_timeit.TestTimeit.test_timer_empty_stmt @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeout.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeout.txt new file mode 100644 index 0000000000..5807452fbc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_timeout.txt @@ -0,0 +1,12 @@ +test.test_timeout.CreationTestCase.testBlockingThenTimeout @ linux-x86_64 +test.test_timeout.CreationTestCase.testFloatReturnValue @ linux-x86_64 +test.test_timeout.CreationTestCase.testObjectCreation @ linux-x86_64 +test.test_timeout.CreationTestCase.testRangeCheck @ linux-x86_64 +test.test_timeout.CreationTestCase.testReturnType @ linux-x86_64 +test.test_timeout.CreationTestCase.testTimeoutThenBlocking @ linux-x86_64 +test.test_timeout.CreationTestCase.testTypeCheck @ linux-x86_64 +test.test_timeout.TCPTimeoutTestCase.testAcceptTimeout @ linux-x86_64 +test.test_timeout.TCPTimeoutTestCase.testSend @ linux-x86_64 +test.test_timeout.TCPTimeoutTestCase.testSendall @ linux-x86_64 +test.test_timeout.TCPTimeoutTestCase.testSendto @ linux-x86_64 +test.test_timeout.UDPTimeoutTestCase.testRecvfromTimeout @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tokenize.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tokenize.txt new file mode 100644 index 0000000000..2049643a32 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tokenize.txt @@ -0,0 +1,95 @@ +test.test_tokenize.CTokenizeTest.test_additive @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_async @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_comparison @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_continuation_lines_indentation @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_float @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_function @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_int @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_invalid_syntax @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_max_indent @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_method @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_multiplicative @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_selector @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_string @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_tabs @ linux-x86_64 +test.test_tokenize.CTokenizeTest.test_unary @ linux-x86_64 +test.test_tokenize.CTokenizerBufferTests.test_newline_at_the_end_of_buffer @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_additive @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_async @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_basic @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_comparison @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_float @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_function @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_implicit_newline @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_int @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_long @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_method @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_multiplicative @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_non_ascii_identifiers @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_selector @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_shift @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_string @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_tabs @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_unary @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_underscore_literals @ linux-x86_64 +test.test_tokenize.GenerateTokensTest.test_unicode @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_bom_no_cookie @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_cookie_first_line_no_bom @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_cookie_second_line_commented_first_line @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_cookie_second_line_empty_first_line @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_cookie_second_line_no_bom @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_cookie_second_line_noncommented_first_line @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_false_encoding @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_filename_in_exception @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_latin1_normalization @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_matched_bom_and_cookie_first_line @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_matched_bom_and_cookie_second_line @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_mismatched_bom_and_cookie_first_line_raises_syntaxerror @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_mismatched_bom_and_cookie_second_line_raises_syntaxerror @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_no_bom_no_encoding_cookie @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_open @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_open_error @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_short_files @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_syntaxerror_latin1 @ linux-x86_64 +test.test_tokenize.TestDetectEncoding.test_utf8_normalization @ linux-x86_64 +test.test_tokenize.TestMisc.test_decistmt @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_backslash_continuation @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_continuation @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_indentation_semantics_retained @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_random_files @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_roundtrip @ linux-x86_64 +test.test_tokenize.TestRoundtrip.test_string_concatenation @ linux-x86_64 +test.test_tokenize.TestTokenize.test_comment_at_the_end_of_the_source_without_newline @ linux-x86_64 +test.test_tokenize.TestTokenize.test_exact_type @ linux-x86_64 +test.test_tokenize.TestTokenize.test_oneline_defs @ linux-x86_64 +test.test_tokenize.TestTokenize.test_pathological_trailing_whitespace @ linux-x86_64 +test.test_tokenize.TestTokenize.test_tokenize @ linux-x86_64 +test.test_tokenize.TestTokenizerAdheresToPep0263.test_bad_coding_cookie @ linux-x86_64 +test.test_tokenize.TestTokenizerAdheresToPep0263.test_latin1_coding_cookie_and_utf8_bom @ linux-x86_64 +test.test_tokenize.TestTokenizerAdheresToPep0263.test_no_coding_cookie_and_utf8_bom @ linux-x86_64 +test.test_tokenize.TestTokenizerAdheresToPep0263.test_utf8_coding_cookie_and_no_utf8_bom @ linux-x86_64 +test.test_tokenize.TestTokenizerAdheresToPep0263.test_utf8_coding_cookie_and_utf8_bom @ linux-x86_64 +test.test_tokenize.Test_Tokenize.test__tokenize_decodes_with_specified_encoding @ linux-x86_64 +test.test_tokenize.Test_Tokenize.test__tokenize_does_not_decode_with_encoding_none @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_additive @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_async @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_basic @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_comparison @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_float @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_function @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_implicit_newline @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_int @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_long @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_method @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_multiplicative @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_non_ascii_identifiers @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_selector @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_shift @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_string @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_tabs @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_unary @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_underscore_literals @ linux-x86_64 +test.test_tokenize.TokenizeTest.test_unicode @ linux-x86_64 +test.test_tokenize.UntokenizeTest.test_backslash_continuation @ linux-x86_64 +test.test_tokenize.UntokenizeTest.test_bad_input_order @ linux-x86_64 +test.test_tokenize.UntokenizeTest.test_iter_compat @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tomllib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tomllib.txt new file mode 100644 index 0000000000..5c1232c654 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tomllib.txt @@ -0,0 +1,13 @@ +test.test_tomllib.test_data.TestData.test_invalid @ linux-x86_64 +test.test_tomllib.test_data.TestData.test_valid @ linux-x86_64 +test.test_tomllib.test_error.TestError.test_invalid_char_quotes @ linux-x86_64 +test.test_tomllib.test_error.TestError.test_invalid_parse_float @ linux-x86_64 +test.test_tomllib.test_error.TestError.test_line_and_col @ linux-x86_64 +test.test_tomllib.test_error.TestError.test_missing_value @ linux-x86_64 +test.test_tomllib.test_error.TestError.test_module_name @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_deepcopy @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_incorrect_load @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_inline_array_recursion_limit @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_inline_table_recursion_limit @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_load @ linux-x86_64 +test.test_tomllib.test_misc.TestMiscellaneous.test_parse_float @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_traceback.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_traceback.txt new file mode 100644 index 0000000000..40ad824561 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_traceback.txt @@ -0,0 +1,92 @@ +test.test_traceback.LimitTests.test_extract_stack @ linux-x86_64 +test.test_traceback.LimitTests.test_extract_tb @ linux-x86_64 +test.test_traceback.LimitTests.test_format_exception @ linux-x86_64 +test.test_traceback.MiscTest.test_all @ linux-x86_64 +test.test_traceback.MiscTracebackCases.test_extract_stack @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_cause @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_cause_and_context @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_cause_recursive @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_context @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_context_suppression @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_bad__str__ @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_basic @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_cause @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_context_with_context @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_depth_limit @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_nested @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_width_limit @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_with_multiple_notes @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_group_with_notes @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_modulename @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_modulename_not_unicode @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_qualname @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_with_invalid_notes @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_with_multiple_notes @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_exception_with_note @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_message_none @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_simple @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_syntax_error_no_lineno @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_syntax_error_offset_at_eol @ linux-x86_64 +test.test_traceback.PyExcReportingTests.test_syntax_error_various_offsets @ linux-x86_64 +test.test_traceback.TestFrame.test_explicit_line @ linux-x86_64 +test.test_traceback.TestFrame.test_len @ linux-x86_64 +test.test_traceback.TestFrame.test_no_line @ linux-x86_64 +test.test_traceback.TestStack.test_custom_format_frame @ linux-x86_64 +test.test_traceback.TestStack.test_dropping_frames @ linux-x86_64 +test.test_traceback.TestStack.test_extract_stack @ linux-x86_64 +test.test_traceback.TestStack.test_extract_stack_limit @ linux-x86_64 +test.test_traceback.TestStack.test_format_locals @ linux-x86_64 +test.test_traceback.TestStack.test_format_smoke @ linux-x86_64 +test.test_traceback.TestStack.test_from_list @ linux-x86_64 +test.test_traceback.TestStack.test_from_list_edited_stack @ linux-x86_64 +test.test_traceback.TestStack.test_locals @ linux-x86_64 +test.test_traceback.TestStack.test_no_locals @ linux-x86_64 +test.test_traceback.TestStack.test_walk_stack @ linux-x86_64 +test.test_traceback.TestStack.test_walk_tb @ linux-x86_64 +test.test_traceback.TestTracebackException.test_cause @ linux-x86_64 +test.test_traceback.TestTracebackException.test_compact_no_cause @ linux-x86_64 +test.test_traceback.TestTracebackException.test_compact_with_cause @ linux-x86_64 +test.test_traceback.TestTracebackException.test_comparison_basic @ linux-x86_64 +test.test_traceback.TestTracebackException.test_comparison_equivalent_exceptions_are_equal @ linux-x86_64 +test.test_traceback.TestTracebackException.test_comparison_params_variations @ linux-x86_64 +test.test_traceback.TestTracebackException.test_context @ linux-x86_64 +test.test_traceback.TestTracebackException.test_from_exception @ linux-x86_64 +test.test_traceback.TestTracebackException.test_limit @ linux-x86_64 +test.test_traceback.TestTracebackException.test_locals @ linux-x86_64 +test.test_traceback.TestTracebackException.test_long_context_chain @ linux-x86_64 +test.test_traceback.TestTracebackException.test_no_locals @ linux-x86_64 +test.test_traceback.TestTracebackException.test_no_refs_to_exception_and_traceback_objects @ linux-x86_64 +test.test_traceback.TestTracebackException.test_smoke @ linux-x86_64 +test.test_traceback.TestTracebackException.test_traceback_header @ linux-x86_64 +test.test_traceback.TestTracebackException.test_unhashable @ linux-x86_64 +test.test_traceback.TestTracebackException_ExceptionGroups.test_comparison @ linux-x86_64 +test.test_traceback.TestTracebackException_ExceptionGroups.test_exception_group_construction @ linux-x86_64 +test.test_traceback.TestTracebackException_ExceptionGroups.test_exception_group_format_exception_only @ linux-x86_64 +test.test_traceback.TestTracebackException_ExceptionGroups.test_max_group_depth @ linux-x86_64 +test.test_traceback.TestTracebackException_ExceptionGroups.test_max_group_width @ linux-x86_64 +test.test_traceback.TracebackCases.test_base_exception @ linux-x86_64 +test.test_traceback.TracebackCases.test_caret @ linux-x86_64 +test.test_traceback.TracebackCases.test_encoded_file @ linux-x86_64 +test.test_traceback.TracebackCases.test_exception_is_None @ linux-x86_64 +test.test_traceback.TracebackCases.test_format_exception_exc @ linux-x86_64 +test.test_traceback.TracebackCases.test_format_exception_only_bad__str__ @ linux-x86_64 +test.test_traceback.TracebackCases.test_format_exception_only_exc @ linux-x86_64 +test.test_traceback.TracebackCases.test_no_caret_with_no_debug_ranges_flag @ linux-x86_64 +test.test_traceback.TracebackCases.test_nocaret @ linux-x86_64 +test.test_traceback.TracebackCases.test_print_exception @ linux-x86_64 +test.test_traceback.TracebackCases.test_print_exception_exc @ linux-x86_64 +test.test_traceback.TracebackCases.test_recursion_error_during_traceback @ linux-x86_64 +test.test_traceback.TracebackCases.test_signatures @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_basic_caret @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_byte_offset_multiline @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_caret_exception_group @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_caret_in_type_annotation @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_caret_multiline_expression @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_caret_multiline_expression_bin_op @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_traceback_specialization_with_syntax_error @ linux-x86_64 +test.test_traceback.TracebackErrorLocationCaretTests.test_traceback_very_long_line @ linux-x86_64 +test.test_traceback.TracebackFormatTests.test_exception_group_deep_recursion_traceback @ linux-x86_64 +test.test_traceback.TracebackFormatTests.test_format_stack @ linux-x86_64 +test.test_traceback.TracebackFormatTests.test_print_exception_bad_type_python @ linux-x86_64 +test.test_traceback.TracebackFormatTests.test_print_stack @ linux-x86_64 +test.test_traceback.TracebackFormatTests.test_stack_format @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tracemalloc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tracemalloc.txt new file mode 100644 index 0000000000..d8a82207d5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tracemalloc.txt @@ -0,0 +1,19 @@ +test.test_tracemalloc.TestCommandLine.test_pymem_alloc0 @ linux-x86_64 +test.test_tracemalloc.TestFilters.test_filter_attributes @ linux-x86_64 +test.test_tracemalloc.TestFilters.test_filter_match @ linux-x86_64 +test.test_tracemalloc.TestFilters.test_filter_match_filename @ linux-x86_64 +test.test_tracemalloc.TestFilters.test_filter_match_filename_joker @ linux-x86_64 +test.test_tracemalloc.TestFilters.test_filter_match_trace @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_filter_traces @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_filter_traces_domain @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_filter_traces_domain_filter @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_format_traceback @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_slices @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_snapshot_group_by_cumulative @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_snapshot_group_by_file @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_snapshot_group_by_line @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_snapshot_group_by_traceback @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_statistic_diff_format @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_statistic_format @ linux-x86_64 +test.test_tracemalloc.TestSnapshot.test_trace_format @ linux-x86_64 +test.test_tracemalloc.TestTraceback.test_repr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tty.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tty.txt new file mode 100644 index 0000000000..b0bda1f877 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tty.txt @@ -0,0 +1,2 @@ +test.test_tty.TestTty.test_setcbreak @ linux-x86_64 +test.test_tty.TestTty.test_setraw @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tuple.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tuple.txt new file mode 100644 index 0000000000..01e26e0d6f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_tuple.txt @@ -0,0 +1,28 @@ +test.test_tuple.TupleTest.test_addmul @ linux-x86_64 +test.test_tuple.TupleTest.test_constructors @ linux-x86_64 +test.test_tuple.TupleTest.test_contains @ linux-x86_64 +test.test_tuple.TupleTest.test_contains_fake @ linux-x86_64 +test.test_tuple.TupleTest.test_contains_order @ linux-x86_64 +test.test_tuple.TupleTest.test_count @ linux-x86_64 +test.test_tuple.TupleTest.test_getitem @ linux-x86_64 +test.test_tuple.TupleTest.test_getitem_error @ linux-x86_64 +test.test_tuple.TupleTest.test_getitemoverwriteiter @ linux-x86_64 +test.test_tuple.TupleTest.test_getslice @ linux-x86_64 +test.test_tuple.TupleTest.test_hash_optional @ linux-x86_64 +test.test_tuple.TupleTest.test_iadd @ linux-x86_64 +test.test_tuple.TupleTest.test_imul @ linux-x86_64 +test.test_tuple.TupleTest.test_index @ linux-x86_64 +test.test_tuple.TupleTest.test_iterator_pickle @ linux-x86_64 +test.test_tuple.TupleTest.test_keyword_args @ linux-x86_64 +test.test_tuple.TupleTest.test_len @ linux-x86_64 +test.test_tuple.TupleTest.test_lexicographic_ordering @ linux-x86_64 +test.test_tuple.TupleTest.test_minmax @ linux-x86_64 +test.test_tuple.TupleTest.test_no_comdat_folding @ linux-x86_64 +test.test_tuple.TupleTest.test_pickle @ linux-x86_64 +test.test_tuple.TupleTest.test_repeat @ linux-x86_64 +test.test_tuple.TupleTest.test_repr @ linux-x86_64 +test.test_tuple.TupleTest.test_repr_large @ linux-x86_64 +test.test_tuple.TupleTest.test_reversed_pickle @ linux-x86_64 +test.test_tuple.TupleTest.test_subscript @ linux-x86_64 +test.test_tuple.TupleTest.test_truth @ linux-x86_64 +test.test_tuple.TupleTest.test_tupleresizebug @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_annotations.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_annotations.txt new file mode 100644 index 0000000000..1f01fe5fb3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_annotations.txt @@ -0,0 +1,8 @@ +test.test_type_annotations.TestSetupAnnotations.test_blocks @ linux-x86_64 +test.test_type_annotations.TestSetupAnnotations.test_top_level @ linux-x86_64 +test.test_type_annotations.TestSetupAnnotations.test_try @ linux-x86_64 +test.test_type_annotations.TypeAnnotationTests.test_annotations_are_created_correctly @ linux-x86_64 +test.test_type_annotations.TypeAnnotationTests.test_annotations_getset_raises @ linux-x86_64 +test.test_type_annotations.TypeAnnotationTests.test_descriptor_still_works @ linux-x86_64 +test.test_type_annotations.TypeAnnotationTests.test_lazy_create_annotations @ linux-x86_64 +test.test_type_annotations.TypeAnnotationTests.test_setting_annotations @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_comments.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_comments.txt new file mode 100644 index 0000000000..2ee79ee6b2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_type_comments.txt @@ -0,0 +1,16 @@ +test.test_type_comments.TypeCommentTests.test_asynccomp @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_asyncdef @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_asyncvar @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_forstmt @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_fstring @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_func_type_input @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_funcdef @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_ignores @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_inappropriate_type_comments @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_longargs @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_matmul @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_nonasciidef @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_redundantdef @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_underscorednumber @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_vardecl @ linux-x86_64 +test.test_type_comments.TypeCommentTests.test_withstmt @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_typechecks.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_typechecks.txt new file mode 100644 index 0000000000..1fec90ebed --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_typechecks.txt @@ -0,0 +1,6 @@ +test.test_typechecks.TypeChecksTest.testIsInstanceActual @ linux-x86_64 +test.test_typechecks.TypeChecksTest.testIsInstanceBuiltin @ linux-x86_64 +test.test_typechecks.TypeChecksTest.testIsSubclassActual @ linux-x86_64 +test.test_typechecks.TypeChecksTest.testIsSubclassBuiltin @ linux-x86_64 +test.test_typechecks.TypeChecksTest.testIsSubclassInternal @ linux-x86_64 +test.test_typechecks.TypeChecksTest.testSubclassBehavior @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_types.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_types.txt new file mode 100644 index 0000000000..5b14241ccc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_types.txt @@ -0,0 +1,99 @@ +test.test_types.ClassCreationTests.test_bad___prepare__ @ linux-x86_64 +test.test_types.ClassCreationTests.test_metaclass_derivation @ linux-x86_64 +test.test_types.ClassCreationTests.test_metaclass_new_error @ linux-x86_64 +test.test_types.ClassCreationTests.test_metaclass_override_callable @ linux-x86_64 +test.test_types.ClassCreationTests.test_metaclass_override_function @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_basics @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_defaults @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_exec_body @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_meta @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_meta_with_base @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_metaclass_keywords @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_subclass @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry_error @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry_genericalias @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry_multiple @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry_multiple_2 @ linux-x86_64 +test.test_types.ClassCreationTests.test_new_class_with_mro_entry_none @ linux-x86_64 +test.test_types.ClassCreationTests.test_prepare_class @ linux-x86_64 +test.test_types.ClassCreationTests.test_resolve_bases @ linux-x86_64 +test.test_types.ClassCreationTests.test_resolve_bases_with_mro_entry @ linux-x86_64 +test.test_types.CoroutineTests.test_duck_coro @ linux-x86_64 +test.test_types.CoroutineTests.test_duck_corogen @ linux-x86_64 +test.test_types.CoroutineTests.test_non_gen_values @ linux-x86_64 +test.test_types.CoroutineTests.test_wrapper_object @ linux-x86_64 +test.test_types.CoroutineTests.test_wrong_args @ linux-x86_64 +test.test_types.MappingProxyTests.test_chainmap @ linux-x86_64 +test.test_types.MappingProxyTests.test_constructor @ linux-x86_64 +test.test_types.MappingProxyTests.test_contains @ linux-x86_64 +test.test_types.MappingProxyTests.test_copy @ linux-x86_64 +test.test_types.MappingProxyTests.test_customdict @ linux-x86_64 +test.test_types.MappingProxyTests.test_get @ linux-x86_64 +test.test_types.MappingProxyTests.test_iterators @ linux-x86_64 +test.test_types.MappingProxyTests.test_len @ linux-x86_64 +test.test_types.MappingProxyTests.test_methods @ linux-x86_64 +test.test_types.MappingProxyTests.test_missing @ linux-x86_64 +test.test_types.MappingProxyTests.test_reversed @ linux-x86_64 +test.test_types.MappingProxyTests.test_union @ linux-x86_64 +test.test_types.MappingProxyTests.test_views @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_as_dict @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_attrdel @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_attrget @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_attrset @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_constructor @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_equal @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_fake_namespace_compare @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_nested @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_pickle @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_recursive @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_subclass @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_unbound @ linux-x86_64 +test.test_types.SimpleNamespaceTests.test_underlying_dict @ linux-x86_64 +test.test_types.TypesTests.test_boolean_ops @ linux-x86_64 +test.test_types.TypesTests.test_comparisons @ linux-x86_64 +test.test_types.TypesTests.test_ellipsis_type @ linux-x86_64 +test.test_types.TypesTests.test_float__format__ @ linux-x86_64 +test.test_types.TypesTests.test_float__format__locale @ linux-x86_64 +test.test_types.TypesTests.test_float_constructor @ linux-x86_64 +test.test_types.TypesTests.test_float_to_string @ linux-x86_64 +test.test_types.TypesTests.test_floats @ linux-x86_64 +test.test_types.TypesTests.test_format_spec_errors @ linux-x86_64 +test.test_types.TypesTests.test_int__format__ @ linux-x86_64 +test.test_types.TypesTests.test_int__format__locale @ linux-x86_64 +test.test_types.TypesTests.test_method_wrapper_types @ linux-x86_64 +test.test_types.TypesTests.test_none_type @ linux-x86_64 +test.test_types.TypesTests.test_normal_integers @ linux-x86_64 +test.test_types.TypesTests.test_notimplemented_type @ linux-x86_64 +test.test_types.TypesTests.test_numeric_types @ linux-x86_64 +test.test_types.TypesTests.test_slot_wrapper_types @ linux-x86_64 +test.test_types.TypesTests.test_strings @ linux-x86_64 +test.test_types.TypesTests.test_traceback_and_frame_types @ linux-x86_64 +test.test_types.TypesTests.test_truth_values @ linux-x86_64 +test.test_types.TypesTests.test_type_function @ linux-x86_64 +test.test_types.TypesTests.test_zero_division @ linux-x86_64 +test.test_types.UnionTests.test_bad_instancecheck @ linux-x86_64 +test.test_types.UnionTests.test_bad_subclasscheck @ linux-x86_64 +test.test_types.UnionTests.test_hash @ linux-x86_64 +test.test_types.UnionTests.test_instancecheck_and_subclasscheck @ linux-x86_64 +test.test_types.UnionTests.test_instancecheck_and_subclasscheck_order @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_Alias @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_IO @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_Literal @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_NamedTuple @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_NewType @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_Protocol @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_SpecialForm @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_TypeVar @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_TypedDict @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_bad_module @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_forward @ linux-x86_64 +test.test_types.UnionTests.test_or_type_operator_with_genericalias @ linux-x86_64 +test.test_types.UnionTests.test_or_type_repr @ linux-x86_64 +test.test_types.UnionTests.test_or_types_operator @ linux-x86_64 +test.test_types.UnionTests.test_union_args @ linux-x86_64 +test.test_types.UnionTests.test_union_copy @ linux-x86_64 +test.test_types.UnionTests.test_union_parameter_chaining @ linux-x86_64 +test.test_types.UnionTests.test_union_parameter_substitution @ linux-x86_64 +test.test_types.UnionTests.test_union_parameter_substitution_errors @ linux-x86_64 +test.test_types.UnionTests.test_union_pickle @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ucn.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ucn.txt new file mode 100644 index 0000000000..8c47d62fd2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_ucn.txt @@ -0,0 +1,12 @@ +test.test_ucn.UnicodeNamesTest.test_aliases @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_aliases_names_in_pua_range @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_ascii_letters @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_cjk_unified_ideographs @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_errors @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_general @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_hangul_syllables @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_misc_symbols @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_named_sequences_full @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_named_sequences_names_in_pua_range @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_named_sequences_sample @ linux-x86_64 +test.test_ucn.UnicodeNamesTest.test_strict_error_handling @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unary.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unary.txt new file mode 100644 index 0000000000..2be7122090 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unary.txt @@ -0,0 +1,6 @@ +test.test_unary.UnaryOpTestCase.test_bad_types @ linux-x86_64 +test.test_unary.UnaryOpTestCase.test_invert @ linux-x86_64 +test.test_unary.UnaryOpTestCase.test_negation_of_exponentiation @ linux-x86_64 +test.test_unary.UnaryOpTestCase.test_negative @ linux-x86_64 +test.test_unary.UnaryOpTestCase.test_no_overflow @ linux-x86_64 +test.test_unary.UnaryOpTestCase.test_positive @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode.txt new file mode 100644 index 0000000000..d1f2972e75 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode.txt @@ -0,0 +1,112 @@ +test.test_unicode.StringModuleTest.test_formatter_field_name_split @ linux-x86_64 +test.test_unicode.StringModuleTest.test_formatter_parser @ linux-x86_64 +test.test_unicode.StringModuleTest.test_str_subclass_attr @ linux-x86_64 +test.test_unicode.UnicodeTest.test___contains__ @ linux-x86_64 +test.test_unicode.UnicodeTest.test_additional_rsplit @ linux-x86_64 +test.test_unicode.UnicodeTest.test_additional_split @ linux-x86_64 +test.test_unicode.UnicodeTest.test_ascii @ linux-x86_64 +test.test_unicode.UnicodeTest.test_bug1001011 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_bytes_comparison @ linux-x86_64 +test.test_unicode.UnicodeTest.test_capitalize @ linux-x86_64 +test.test_unicode.UnicodeTest.test_casefold @ linux-x86_64 +test.test_unicode.UnicodeTest.test_center @ linux-x86_64 +test.test_unicode.UnicodeTest.test_codecs @ linux-x86_64 +test.test_unicode.UnicodeTest.test_codecs_errors @ linux-x86_64 +test.test_unicode.UnicodeTest.test_codecs_idna @ linux-x86_64 +test.test_unicode.UnicodeTest.test_codecs_utf7 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_codecs_utf8 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_compare @ linux-x86_64 +test.test_unicode.UnicodeTest.test_comparison @ linux-x86_64 +test.test_unicode.UnicodeTest.test_concatenation @ linux-x86_64 +test.test_unicode.UnicodeTest.test_constructor @ linux-x86_64 +test.test_unicode.UnicodeTest.test_constructor_defaults @ linux-x86_64 +test.test_unicode.UnicodeTest.test_constructor_keyword_args @ linux-x86_64 +test.test_unicode.UnicodeTest.test_contains @ linux-x86_64 +test.test_unicode.UnicodeTest.test_conversion @ linux-x86_64 +test.test_unicode.UnicodeTest.test_count @ linux-x86_64 +test.test_unicode.UnicodeTest.test_endswith @ linux-x86_64 +test.test_unicode.UnicodeTest.test_exhausted_iterator @ linux-x86_64 +test.test_unicode.UnicodeTest.test_expandtabs @ linux-x86_64 +test.test_unicode.UnicodeTest.test_extended_getslice @ linux-x86_64 +test.test_unicode.UnicodeTest.test_find @ linux-x86_64 +test.test_unicode.UnicodeTest.test_find_etc_raise_correct_error_messages @ linux-x86_64 +test.test_unicode.UnicodeTest.test_find_periodic_pattern @ linux-x86_64 +test.test_unicode.UnicodeTest.test_find_shift_table_overflow @ linux-x86_64 +test.test_unicode.UnicodeTest.test_fixtype @ linux-x86_64 +test.test_unicode.UnicodeTest.test_floatformatting @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_auto_numbering @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_float @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_huge_item_number @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_huge_precision @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_huge_width @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_map @ linux-x86_64 +test.test_unicode.UnicodeTest.test_format_subclass @ linux-x86_64 +test.test_unicode.UnicodeTest.test_formatting @ linux-x86_64 +test.test_unicode.UnicodeTest.test_formatting_huge_precision @ linux-x86_64 +test.test_unicode.UnicodeTest.test_formatting_huge_width @ linux-x86_64 +test.test_unicode.UnicodeTest.test_formatting_with_enum @ linux-x86_64 +test.test_unicode.UnicodeTest.test_getnewargs @ linux-x86_64 +test.test_unicode.UnicodeTest.test_hash @ linux-x86_64 +test.test_unicode.UnicodeTest.test_index @ linux-x86_64 +test.test_unicode.UnicodeTest.test_inplace_rewrites @ linux-x86_64 +test.test_unicode.UnicodeTest.test_invalid_cb_for_2bytes_seq @ linux-x86_64 +test.test_unicode.UnicodeTest.test_invalid_cb_for_4bytes_seq @ linux-x86_64 +test.test_unicode.UnicodeTest.test_invalid_start_byte @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isalnum @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isalpha @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isascii @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isdecimal @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isdigit @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isidentifier @ linux-x86_64 +test.test_unicode.UnicodeTest.test_islower @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isnumeric @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isprintable @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isspace @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isspace_invariant @ linux-x86_64 +test.test_unicode.UnicodeTest.test_issue18183 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_issue28598_strsubclass_rhs @ linux-x86_64 +test.test_unicode.UnicodeTest.test_issue8271 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_istitle @ linux-x86_64 +test.test_unicode.UnicodeTest.test_isupper @ linux-x86_64 +test.test_unicode.UnicodeTest.test_iteration @ linux-x86_64 +test.test_unicode.UnicodeTest.test_iterators @ linux-x86_64 +test.test_unicode.UnicodeTest.test_iterators_invocation @ linux-x86_64 +test.test_unicode.UnicodeTest.test_join @ linux-x86_64 +test.test_unicode.UnicodeTest.test_literals @ linux-x86_64 +test.test_unicode.UnicodeTest.test_ljust @ linux-x86_64 +test.test_unicode.UnicodeTest.test_lower @ linux-x86_64 +test.test_unicode.UnicodeTest.test_maketrans_translate @ linux-x86_64 +test.test_unicode.UnicodeTest.test_mul @ linux-x86_64 +test.test_unicode.UnicodeTest.test_none_arguments @ linux-x86_64 +test.test_unicode.UnicodeTest.test_partition @ linux-x86_64 +test.test_unicode.UnicodeTest.test_pickle_iterator @ linux-x86_64 +test.test_unicode.UnicodeTest.test_removeprefix @ linux-x86_64 +test.test_unicode.UnicodeTest.test_removesuffix @ linux-x86_64 +test.test_unicode.UnicodeTest.test_repeat_id_preserving @ linux-x86_64 +test.test_unicode.UnicodeTest.test_replace @ linux-x86_64 +test.test_unicode.UnicodeTest.test_repr @ linux-x86_64 +test.test_unicode.UnicodeTest.test_rfind @ linux-x86_64 +test.test_unicode.UnicodeTest.test_rindex @ linux-x86_64 +test.test_unicode.UnicodeTest.test_rjust @ linux-x86_64 +test.test_unicode.UnicodeTest.test_rpartition @ linux-x86_64 +test.test_unicode.UnicodeTest.test_rsplit @ linux-x86_64 +test.test_unicode.UnicodeTest.test_slice @ linux-x86_64 +test.test_unicode.UnicodeTest.test_split @ linux-x86_64 +test.test_unicode.UnicodeTest.test_splitlines @ linux-x86_64 +test.test_unicode.UnicodeTest.test_startswith @ linux-x86_64 +test.test_unicode.UnicodeTest.test_startswith_endswith_errors @ linux-x86_64 +test.test_unicode.UnicodeTest.test_strip @ linux-x86_64 +test.test_unicode.UnicodeTest.test_strip_whitespace @ linux-x86_64 +test.test_unicode.UnicodeTest.test_subclass_add @ linux-x86_64 +test.test_unicode.UnicodeTest.test_subscript @ linux-x86_64 +test.test_unicode.UnicodeTest.test_surrogates @ linux-x86_64 +test.test_unicode.UnicodeTest.test_swapcase @ linux-x86_64 +test.test_unicode.UnicodeTest.test_title @ linux-x86_64 +test.test_unicode.UnicodeTest.test_ucs4 @ linux-x86_64 +test.test_unicode.UnicodeTest.test_unexpected_end_of_data @ linux-x86_64 +test.test_unicode.UnicodeTest.test_unicode_repr @ linux-x86_64 +test.test_unicode.UnicodeTest.test_upper @ linux-x86_64 +test.test_unicode.UnicodeTest.test_utf8_decode_invalid_sequences @ linux-x86_64 +test.test_unicode.UnicodeTest.test_utf8_decode_valid_sequences @ linux-x86_64 +test.test_unicode.UnicodeTest.test_zfill @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode_file_functions.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode_file_functions.txt new file mode 100644 index 0000000000..9054e05080 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicode_file_functions.txt @@ -0,0 +1,30 @@ +test.test_unicode_file_functions.UnicodeFileTests.test_directory @ linux-x86_64 +test.test_unicode_file_functions.UnicodeFileTests.test_failures @ linux-x86_64 +test.test_unicode_file_functions.UnicodeFileTests.test_listdir @ linux-x86_64 +test.test_unicode_file_functions.UnicodeFileTests.test_normalize @ linux-x86_64 +test.test_unicode_file_functions.UnicodeFileTests.test_open @ linux-x86_64 +test.test_unicode_file_functions.UnicodeFileTests.test_rename @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_directory @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_failures @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_listdir @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_normalize @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_open @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFCFileTests.test_rename @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_directory @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_failures @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_listdir @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_normalize @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_open @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFDFileTests.test_rename @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_directory @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_failures @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_listdir @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_normalize @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_open @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKCFileTests.test_rename @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_directory @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_failures @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_listdir @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_normalize @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_open @ linux-x86_64 +test.test_unicode_file_functions.UnicodeNFKDFileTests.test_rename @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicodedata.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicodedata.txt new file mode 100644 index 0000000000..80b5d020d5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unicodedata.txt @@ -0,0 +1,21 @@ +test.test_unicodedata.NormalizationTest.test_bug_834676 @ linux-x86_64 +test.test_unicodedata.NormalizationTest.test_edge_cases @ linux-x86_64 +test.test_unicodedata.NormalizationTest.test_normalization @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_category @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_combining @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_decimal @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_decomposition @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_digit @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_east_asian_width @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_east_asian_width_9_0_changes @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_issue10254 @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_issue29456 @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_mirrored @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_numeric @ linux-x86_64 +test.test_unicodedata.UnicodeFunctionsTest.test_pr29 @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_bug_1704793 @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_bug_4971 @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_bug_5828 @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_decimal_numeric_consistent @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_digit_numeric_consistent @ linux-x86_64 +test.test_unicodedata.UnicodeMiscTest.test_ucd_510 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unittest.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unittest.txt new file mode 100644 index 0000000000..4f945bbf80 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unittest.txt @@ -0,0 +1,457 @@ +unittest.test.test_assertions.TestLongMessage.testAlmostEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertDictContainsSubset @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertDictEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertFalse @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertGreater @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertGreaterEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertIn @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertIs @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertIsNone @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertIsNot @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertIsNotNone @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertLess @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertLessEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertMultiLineEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertNotIn @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertNotRegex @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertRaises @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertRaisesRegex @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertRegex @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertSequenceEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertSetEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertTrue @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertWarns @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testAssertWarnsRegex @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testDefault @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testNotAlmostEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.testNotEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.test_baseAssertEqual @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.test_formatMessage_unicode_error @ linux-x86_64 +unittest.test.test_assertions.TestLongMessage.test_formatMsg @ linux-x86_64 +unittest.test.test_assertions.Test_Assertions.testAssertNotRegex @ linux-x86_64 +unittest.test.test_assertions.Test_Assertions.test_AlmostEqual @ linux-x86_64 +unittest.test.test_assertions.Test_Assertions.test_AmostEqualWithDelta @ linux-x86_64 +unittest.test.test_assertions.Test_Assertions.test_assertRaises @ linux-x86_64 +!unittest.test.test_assertions.Test_Assertions.test_assertRaises_frames_survival @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_base_exception_from_async_method @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_cleanups_interleave_order @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_exception_in_setup @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_exception_in_tear_clean_up @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_exception_in_tear_down @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_exception_in_test @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_full_cycle @ linux-x86_64 +unittest.test.test_async_case.TestAsyncCase.test_setup_get_event_loop @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAddTypeEqualityFunc @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertCountEqual @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertDictContainsSubset @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertDictEqualTruncates @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertEqual @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertEqualSingleLine @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertEqual_diffThreshold @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertEqual_shorten @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertIn @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertIs @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertIsInstance @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertIsNone @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertIsNot @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsDefaults @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsFailureLevelTooHigh @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsFailureLevelTooHigh_FilterInRootLogger @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsFailureMismatchingLogger @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsFailureNoLogs @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsPerLevel @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsPerLogger @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsTwoMatchingMessages @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertLogsUnexpectedException @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertMultiLineEqual @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertMultiLineEqualTruncates @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsDefault @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsFailureFoundLogs @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsFailurePerLevel @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsFailurePerLogger @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsPerLevel @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsPerLogger @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsUnexpectedException @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNoLogsYieldsNone @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNotIsInstance @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertNotRaisesRegex @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesCallable @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesContext @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesExcValue @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesNoExceptionType @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesRefcount @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesRegex @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesRegexInvalidRegex @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesRegexMismatch @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRaisesRegexNoExceptionType @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertRegex @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertSequenceEqualMaxDiff @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertSetEqual @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsCallable @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsContext @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsModifySysModules @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsNoExceptionType @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsRegexCallable @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsRegexContext @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsRegexInvalidRegex @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testAssertWarnsRegexNoExceptionType @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testDeepcopy @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testDeprecatedMethodNames @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testEquality @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testEqualityBytesWarning @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testInequality @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testKeyboardInterrupt @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testPickle @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testShortDescriptionWhitespaceTrimming @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testShortDescriptionWithMultiLineDocstring @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testShortDescriptionWithOneLineDocstring @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testShortDescriptionWithoutDocstring @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testSkippingEverywhere @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testSystemExit @ linux-x86_64 +unittest.test.test_case.Test_TestCase.testTruncateMessage @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_call__invoking_an_instance_delegates_to_run @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_countTestCases @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_defaultTestResult @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_deprecation_of_return_val_from_test @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_eq @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_failureException__default @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_failureException__subclassing__explicit_raise @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_failureException__subclassing__implicit_raise @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_hash @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_id @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_init__no_test_name @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_init__test_name__invalid @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_init__test_name__valid @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_ne @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run__returns_given_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run__uses_defaultTestResult @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_setUp @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_setUp_default_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_tearDown @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_tearDown_default_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_test @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__error_in_test_default_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__failure_in_test @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__failure_in_test_default_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__subtests @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__subtests_failfast @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__subtests_legacy @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__subtests_success @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order__subtests_success_legacy @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_run_call_order_default_result @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_setUp @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_subtests_debug @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_subtests_failfast @ linux-x86_64 +unittest.test.test_case.Test_TestCase.test_tearDown @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_discover_by_default @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_discover_by_default_with_options @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_do_discovery_calls_loader @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_do_discovery_too_many_arguments @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_do_discovery_uses_default_loader @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_command_line_handling_parseArgs @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_detect_module_clash @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover_start_dir_is_package_calls_package_load_tests @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover_with_init_module_that_raises_SkipTest_on_import @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover_with_init_modules_that_fail_to_import @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover_with_module_that_raises_SkipTest_on_import @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discover_with_modules_that_fail_to_import @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discovery_failed_discovery @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discovery_from_dotted_path @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_discovery_from_dotted_path_builtin_modules @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_find_tests @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_find_tests_customize_via_package_pattern @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_find_tests_default_calls_package_load_tests @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_find_tests_socket @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_find_tests_with_package @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_get_name_from_path @ linux-x86_64 +unittest.test.test_discovery.TestDiscovery.test_module_symlink_ok @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_countTestCases @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_id @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_run_call_order__error_in_setUp @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_run_call_order__error_in_tearDown @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_run_call_order__error_in_test @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_run_call_order__failure_in_test @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_shortDescription__no_docstring @ linux-x86_64 +unittest.test.test_functiontestcase.Test_FunctionTestCase.test_shortDescription__singleline_docstring @ linux-x86_64 +unittest.test.test_loader.TestObsoleteFunctions.test_findTestCases @ linux-x86_64 +unittest.test.test_loader.TestObsoleteFunctions.test_getTestCaseNames @ linux-x86_64 +unittest.test.test_loader.TestObsoleteFunctions.test_makeSuite @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test___init__ @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames__inheritance @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames__no_tests @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames__not_a_TestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames__testNamePatterns @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_getTestCaseNames__testNamePatterns__attribute_access_regression @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__TestCase_subclass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__TestCase_subclass_internals @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__faulty_load_tests @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__load_tests @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__no_TestCase_instances @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__no_TestCase_tests @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__not_a_module @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__pattern @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__too_many_positional_args @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__use_load_tests_deprecated_keyword @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__use_load_tests_deprecated_positional @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromModule__use_load_tests_other_bad_keyword @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__callable__TestCase_instance @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__callable__TestCase_instance_ProperSuiteClass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__callable__TestSuite @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__callable__wrong_type @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__empty_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__function_with_different_name_than_method @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__malformed_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__module_not_loaded @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_TestCase_subclass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_TestSuite @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_bad_object @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_empty_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_malformed_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_not_a_module @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_testmethod @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_testmethod_ProperSuiteClass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__relative_unknown_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__unknown_attr_name_on_module @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__unknown_attr_name_on_package @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromName__unknown_module_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__callable__TestCase_instance @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__callable__TestSuite @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__callable__call_staticmethod @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__callable__wrong_type @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__empty_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__empty_name_list @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__malformed_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__module_not_loaded @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_TestCase_subclass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_TestSuite @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_bad_object @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_empty_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_empty_name_list @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_malformed_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_not_a_module @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__relative_testmethod @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__unknown_attr_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__unknown_module_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__unknown_name_relative_1 @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromNames__unknown_name_relative_2 @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase__TestSuite_subclass @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase__default_method_name @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase__from_FunctionTestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase__from_TestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_loadTestsFromTestCase__no_matches @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_partial_functions @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__None @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__default_value @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__getTestCaseNames @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__loadTestsFromModule @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__loadTestsFromName @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__loadTestsFromNames @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_sortTestMethodsUsing__loadTestsFromTestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_suiteClass__default_value @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_suiteClass__loadTestsFromModule @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_suiteClass__loadTestsFromName @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_suiteClass__loadTestsFromNames @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_suiteClass__loadTestsFromTestCase @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_testMethodPrefix__default_value @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_testMethodPrefix__loadTestsFromModule @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_testMethodPrefix__loadTestsFromName @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_testMethodPrefix__loadTestsFromNames @ linux-x86_64 +unittest.test.test_loader.Test_TestLoader.test_testMethodPrefix__loadTestsFromTestCase @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testBufferCatchFailfast @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testCatchBreakInstallsHandler @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsAbsolutePathsThatCanBeConverted @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsAbsolutePathsThatCannotBeConverted @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsFileNames @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsFilePaths @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsNonExistentFiles @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testParseArgsSelectedTestNames @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testRunTestsOldRunnerClass @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testRunTestsRunnerClass @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testRunTestsRunnerInstance @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testSelectedTestNamesFunctionalTest @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testVerbosity @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.testWarning @ linux-x86_64 +unittest.test.test_program.TestCommandLineArgs.test_locals @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.testNoExit @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_Exit @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_ExitAsDefault @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_NonExit @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_defaultTest_with_iterable @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_defaultTest_with_string @ linux-x86_64 +unittest.test.test_program.Test_TestProgram.test_discovery_from_dotted_path @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferDoClassCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferDoCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferDoModuleCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferOutputAddErrorOrFailure @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferOutputOff @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferOutputStartTestAddSuccess @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetUp @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetUpModule @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetUpModule_DoModuleCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetUp_DoCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetupClass @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferSetupClass_DoClassCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDown @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDownClass @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDownClass_DoClassCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDownModule @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDownModule_DoModuleCleanups @ linux-x86_64 +unittest.test.test_result.TestOutputBuffering.testBufferTearDown_DoCleanups @ linux-x86_64 +unittest.test.test_result.Test_OldTestResult.testOldResultWithRunner @ linux-x86_64 +unittest.test.test_result.Test_OldTestResult.testOldTestResult @ linux-x86_64 +unittest.test.test_result.Test_OldTestResult.testOldTestResultClass @ linux-x86_64 +unittest.test.test_result.Test_OldTestResult.testOldTestTesultSetup @ linux-x86_64 +unittest.test.test_result.Test_TestResult.testFailFast @ linux-x86_64 +unittest.test.test_result.Test_TestResult.testFailFastSetByRunner @ linux-x86_64 +unittest.test.test_result.Test_TestResult.testStackFrameTrimming @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addError @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addError_locals @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addFailure @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addFailure_filter_traceback_frames @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addFailure_filter_traceback_frames_chained_exception_cycle @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addFailure_filter_traceback_frames_chained_exception_self_loop @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addFailure_filter_traceback_frames_context @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addSubTest @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_addSuccess @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_init @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_startTest @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_startTestRun_stopTestRun @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_stop @ linux-x86_64 +unittest.test.test_result.Test_TestResult.test_stopTest @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testDotsOutput @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testDotsOutputSubTestMixed @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testDotsOutputSubTestSuccess @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testDotsOutputTearDownFail @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetDescriptionWithMultiLineDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetDescriptionWithOneLineDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetDescriptionWithoutDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetDuplicatedNestedSubTestDescriptionWithoutDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetNestedSubTestDescriptionWithoutDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetSubTestDescriptionForFalsyValues @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetSubTestDescriptionWithMultiLineDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetSubTestDescriptionWithOneLineDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstring @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testGetSubTestDescriptionWithoutDocstringAndParams @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testLongOutput @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testLongOutputSubTestMixed @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testLongOutputSubTestSuccess @ linux-x86_64 +unittest.test.test_result.Test_TextTestResult.testLongOutputTearDownFail @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_addClassCleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_debug_executes_classCleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_debug_executes_classCleanUp_when_teardown_exception @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_doClassCleanups_with_errors_addClassCleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_enterClassContext @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_enterClassContext_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_run_class_cleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_run_class_cleanUp_without_tearDownClass @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_run_nested_test @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_run_with_errors_addClassCleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_with_errors_addCleanUp @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_with_errors_in_addClassCleanup_and_setUps @ linux-x86_64 +unittest.test.test_runner.TestClassCleanup.test_with_errors_in_tearDownClass @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.testCleanUp @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.testCleanUpWithErrors @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.testCleanupInRun @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.testTestCaseDebugExecutesCleanups @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.test_enterContext @ linux-x86_64 +unittest.test.test_runner.TestCleanUp.test_enterContext_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_addClassCleanup_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_addCleanup_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_addModuleCleanup_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_add_and_do_ModuleCleanup @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_debug_module_cleanUp_when_teardown_exception @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_debug_module_executes_cleanUp @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_doModuleCleanup_with_errors_in_addModuleCleanup @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_enterModuleContext @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_enterModuleContext_arg_errors @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_module_cleanUp_with_multiple_classes @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_run_module_cleanUp @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_run_module_cleanUp_when_teardown_exception @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_run_module_cleanUp_without_teardown @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_run_multiple_module_cleanUp @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_with_errors_in_addClassCleanup @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_with_errors_in_addCleanup @ linux-x86_64 +unittest.test.test_runner.TestModuleCleanUp.test_with_errors_in_addModuleCleanup_and_setUps @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.testBufferAndFailfast @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.testRunnerRegistersResult @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.testSpecifiedStreamUsed @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.testStdErrLookedUpAtInstantiationTime @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_init @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_locals @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_multiple_inheritance @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_pickle_unpickle @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_resultclass @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_startTestRun_stopTestRun_called @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_warnings @ linux-x86_64 +unittest.test.test_runner.Test_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_class_not_setup_or_torndown_when_skipped @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_class_not_torndown_when_setup_fails @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_error_in_setup_module @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_error_in_setupclass @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_error_in_teardown_class @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_error_in_teardown_module @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_setup_class @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_setup_module @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_setup_teardown_order_with_pathological_suite @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_skiptest_in_setupclass @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_skiptest_in_setupmodule @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_suite_debug_executes_setups_and_teardowns @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_suite_debug_propagates_exceptions @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_teardown_class @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_teardown_class_two_classes @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_teardown_module @ linux-x86_64 +unittest.test.test_setups.TestSetups.test_testcase_with_missing_module @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_debug_skipping @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_debug_skipping_class @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_debug_skipping_subtests @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_decorated_skip @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure_and_fail_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure_and_skip_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure_subtests @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure_with_wrapped_class @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_expected_failure_with_wrapped_subclass @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_failure_and_skip_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_class @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_doesnt_run_setup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_in_setup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_non_unittest_class @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skip_without_reason @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skipping @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skipping_and_fail_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skipping_decorators @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_skipping_subtests @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_unexpected_success @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_unexpected_success_and_fail_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_unexpected_success_and_skip_in_cleanup @ linux-x86_64 +unittest.test.test_skipping.Test_TestSkipping.test_unexpected_success_subtests @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTest__TestCase @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTest__TestSuite @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTest__casesuiteclass @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTest__noncallable @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTest__noniterable @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTests @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_addTests__string @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_basetestsuite @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_countTestCases_nested @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_countTestCases_simple @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_countTestCases_zero_nested @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_countTestCases_zero_simple @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_eq @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_function_in_suite @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_init__TestSuite_instances_in_tests @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_init__empty_tests @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_init__tests_from_any_iterable @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_init__tests_optional @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_iter @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_ne @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_overriding_call @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_remove_test_at_index @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_remove_test_at_index_not_indexable @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_run @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_run__empty_suite @ linux-x86_64 +unittest.test.test_suite.Test_TestSuite.test_run__requires_result @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_univnewlines.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_univnewlines.txt new file mode 100644 index 0000000000..bc9f469ab4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_univnewlines.txt @@ -0,0 +1,34 @@ +test.test_univnewlines.CTestCRLFNewlines.test_read @ linux-x86_64 +test.test_univnewlines.CTestCRLFNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.CTestCRLFNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.CTestCRLFNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.CTestCRLFNewlines.test_tell @ linux-x86_64 +test.test_univnewlines.CTestCRNewlines.test_read @ linux-x86_64 +test.test_univnewlines.CTestCRNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.CTestCRNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.CTestCRNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.CTestLFNewlines.test_read @ linux-x86_64 +test.test_univnewlines.CTestLFNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.CTestLFNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.CTestLFNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.CTestMixedNewlines.test_read @ linux-x86_64 +test.test_univnewlines.CTestMixedNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.CTestMixedNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.CTestMixedNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.PyTestCRLFNewlines.test_read @ linux-x86_64 +test.test_univnewlines.PyTestCRLFNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.PyTestCRLFNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.PyTestCRLFNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.PyTestCRLFNewlines.test_tell @ linux-x86_64 +test.test_univnewlines.PyTestCRNewlines.test_read @ linux-x86_64 +test.test_univnewlines.PyTestCRNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.PyTestCRNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.PyTestCRNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.PyTestLFNewlines.test_read @ linux-x86_64 +test.test_univnewlines.PyTestLFNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.PyTestLFNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.PyTestLFNewlines.test_seek @ linux-x86_64 +test.test_univnewlines.PyTestMixedNewlines.test_read @ linux-x86_64 +test.test_univnewlines.PyTestMixedNewlines.test_readline @ linux-x86_64 +test.test_univnewlines.PyTestMixedNewlines.test_readlines @ linux-x86_64 +test.test_univnewlines.PyTestMixedNewlines.test_seek @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unpack.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unpack.txt new file mode 100644 index 0000000000..9c5a305397 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unpack.txt @@ -0,0 +1,2 @@ +DocTestCase.test.test_unpack.__test__.doctests @ linux-x86_64 +test.test_unpack.TestCornerCases.test_extended_oparg_not_ignored @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unparse.txt new file mode 100644 index 0000000000..56c60efd09 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_unparse.txt @@ -0,0 +1,57 @@ +test.test_unparse.CosmeticTestCase.test_class_bases_and_keywords @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_docstrings @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_docstrings_negative_cases @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_fstrings @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_lambda_parameters @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_multiquote_joined_string @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_simple_expressions_parens @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_slices @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_star_expr_assign_target @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_star_expr_assign_target_multiple @ linux-x86_64 +test.test_unparse.CosmeticTestCase.test_unary_op_factor @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_annotations @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_bytes @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_chained_comparisons @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_class_decorators @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_class_definition @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_del_statement @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_dict_comprehension @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_dict_unpacking_in_dict @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_docstrings @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_elifs @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_empty_set @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_for_else @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_fstrings @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_fstrings_complicated @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_fstrings_special_chars @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_function_arguments @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_function_type @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_huge_float @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_imaginary_literals @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_import_from_level_none @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_integer_parens @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_invalid_fstring_backslash @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_invalid_fstring_value @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_invalid_raise @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_invalid_yield_from @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_lambda_parentheses @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_min_int @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_nan @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_nonlocal @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_raise_from @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_relative_import @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_set_comprehension @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_set_literal @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_shifts @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_slices @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_starred_assignment @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_strings @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_try_except_finally @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_try_except_star_finally @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_type_comments @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_type_ignore @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_unary_parens @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_while_else @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_with_as @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_with_simple @ linux-x86_64 +test.test_unparse.UnparseTestCase.test_with_two_items @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib.txt new file mode 100644 index 0000000000..4cc01df8a8 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib.txt @@ -0,0 +1,101 @@ +test.test_urllib.PathName2URLTests.test_converting_drive_letter @ linux-x86_64 +test.test_urllib.PathName2URLTests.test_converting_when_no_drive_letter @ linux-x86_64 +test.test_urllib.PathName2URLTests.test_long_drive_letter @ linux-x86_64 +test.test_urllib.PathName2URLTests.test_roundtrip_pathname2url @ linux-x86_64 +test.test_urllib.PathName2URLTests.test_simple_compare @ linux-x86_64 +test.test_urllib.Pathname_Tests.test_basic @ linux-x86_64 +test.test_urllib.Pathname_Tests.test_quoting @ linux-x86_64 +test.test_urllib.ProxyTests.test_getproxies_environment_keep_no_proxies @ linux-x86_64 +test.test_urllib.ProxyTests.test_proxy_bypass_environment_always_match @ linux-x86_64 +test.test_urllib.ProxyTests.test_proxy_bypass_environment_host_match @ linux-x86_64 +test.test_urllib.ProxyTests.test_proxy_bypass_environment_newline @ linux-x86_64 +test.test_urllib.ProxyTests.test_proxy_cgi_ignore @ linux-x86_64 +test.test_urllib.ProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercase @ linux-x86_64 +test.test_urllib.QuotingTests.test_default_quoting @ linux-x86_64 +test.test_urllib.QuotingTests.test_default_safe @ linux-x86_64 +test.test_urllib.QuotingTests.test_never_quote @ linux-x86_64 +test.test_urllib.QuotingTests.test_quote_bytes @ linux-x86_64 +test.test_urllib.QuotingTests.test_quote_plus_with_unicode @ linux-x86_64 +test.test_urllib.QuotingTests.test_quote_with_unicode @ linux-x86_64 +test.test_urllib.QuotingTests.test_quoting_plus @ linux-x86_64 +test.test_urllib.QuotingTests.test_quoting_space @ linux-x86_64 +test.test_urllib.QuotingTests.test_safe @ linux-x86_64 +test.test_urllib.RequestTests.test_default_values @ linux-x86_64 +test.test_urllib.RequestTests.test_with_method_arg @ linux-x86_64 +test.test_urllib.URL2PathNameTests.test_converting_drive_letter @ linux-x86_64 +test.test_urllib.URL2PathNameTests.test_converting_when_no_drive_letter @ linux-x86_64 +test.test_urllib.URL2PathNameTests.test_non_ascii_drive_letter @ linux-x86_64 +test.test_urllib.URL2PathNameTests.test_roundtrip_url2pathname @ linux-x86_64 +test.test_urllib.URL2PathNameTests.test_simple_compare @ linux-x86_64 +test.test_urllib.URLopener_Tests.test_local_file_open @ linux-x86_64 +test.test_urllib.URLopener_Tests.test_quoted_open @ linux-x86_64 +test.test_urllib.URLopener_Tests.test_urlopener_retrieve_file @ linux-x86_64 +test.test_urllib.URLopener_Tests.test_urlopener_retrieve_remote @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquote_to_bytes @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquote_with_unicode @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting_badpercent @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting_mixed_case @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting_parts @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting_plus @ linux-x86_64 +test.test_urllib.UnquotingTests.test_unquoting_with_bytes_input @ linux-x86_64 +test.test_urllib.Utility_Tests.test_thishost @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_doseq @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_empty_sequence @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_nonstring_seq_values @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_nonstring_values @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_quoting @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_urlencode_bytes @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_urlencode_encoding @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_urlencode_encoding_doseq @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_urlencode_encoding_safe_parameter @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_using_mapping @ linux-x86_64 +test.test_urllib.urlencode_Tests.test_using_sequence @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_geturl @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_info @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_interface @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_invalid_base64_data @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_missing_comma @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_read_image @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_read_text @ linux-x86_64 +test.test_urllib.urlopen_DataTests.test_read_text_base64 @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_close @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_fileno @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_getcode @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_geturl @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_headers @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_info @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_interface @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_iter @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_read @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_readline @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_readlines @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_relativelocalfile @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_status @ linux-x86_64 +test.test_urllib.urlopen_FileTests.test_url @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_URLopener_deprecation @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_cafile_and_context @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_empty_socket @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_file_notexists @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_ftp_cache_pruning @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_invalid_redirect @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_missing_localfile @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_read_0_9 @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_read_1_0 @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_read_1_1 @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_read_bogus @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_redirect_limit_independent @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_url_fragment @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_url_path_with_control_char_rejected @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_url_path_with_newline_header_injection_rejected @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_userpass_inurl @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_userpass_inurl_w_spaces @ linux-x86_64 +test.test_urllib.urlopen_HttpTests.test_willclose @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_basic @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_copy @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_reporthook @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_reporthook_0_bytes @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_reporthook_5_bytes @ linux-x86_64 +test.test_urllib.urlretrieve_FileTests.test_reporthook_8193_bytes @ linux-x86_64 +test.test_urllib.urlretrieve_HttpTests.test_short_content_raises_ContentTooShortError @ linux-x86_64 +test.test_urllib.urlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthook @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2.txt new file mode 100644 index 0000000000..6588b112f7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2.txt @@ -0,0 +1,68 @@ +test.test_urllib2.HandlerTests.test_basic_and_digest_auth_handlers @ linux-x86_64 +test.test_urllib2.HandlerTests.test_basic_auth @ linux-x86_64 +test.test_urllib2.HandlerTests.test_basic_prior_auth_auto_send @ linux-x86_64 +test.test_urllib2.HandlerTests.test_basic_prior_auth_send_after_first_success @ linux-x86_64 +test.test_urllib2.HandlerTests.test_cookie_redirect @ linux-x86_64 +test.test_urllib2.HandlerTests.test_cookies @ linux-x86_64 +test.test_urllib2.HandlerTests.test_errors @ linux-x86_64 +test.test_urllib2.HandlerTests.test_file @ linux-x86_64 +test.test_urllib2.HandlerTests.test_fixpath_in_weirdurls @ linux-x86_64 +test.test_urllib2.HandlerTests.test_ftp @ linux-x86_64 +test.test_urllib2.HandlerTests.test_full_url_deleter @ linux-x86_64 +test.test_urllib2.HandlerTests.test_full_url_setter @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_array @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_empty_seq @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_file @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_fileobj @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_iterable @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_body_pipe @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_closed @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_doubleslash @ linux-x86_64 +test.test_urllib2.HandlerTests.test_http_handler_debuglevel @ linux-x86_64 +test.test_urllib2.HandlerTests.test_invalid_closed @ linux-x86_64 +test.test_urllib2.HandlerTests.test_invalid_redirect @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy_basic_auth @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy_https @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy_https_proxy_authorization @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy_no_proxy @ linux-x86_64 +test.test_urllib2.HandlerTests.test_proxy_no_proxy_all @ linux-x86_64 +test.test_urllib2.HandlerTests.test_redirect @ linux-x86_64 +test.test_urllib2.HandlerTests.test_redirect_fragment @ linux-x86_64 +test.test_urllib2.HandlerTests.test_relative_redirect @ linux-x86_64 +test.test_urllib2.HandlerTests.test_unsupported_auth_basic_handler @ linux-x86_64 +test.test_urllib2.HandlerTests.test_unsupported_auth_digest_handler @ linux-x86_64 +test.test_urllib2.MiscTests.test_HTTPError_interface @ linux-x86_64 +test.test_urllib2.MiscTests.test_build_opener @ linux-x86_64 +test.test_urllib2.MiscTests.test_gh_98778 @ linux-x86_64 +test.test_urllib2.MiscTests.test_parse_proxy @ linux-x86_64 +test.test_urllib2.MiscTests.test_unsupported_algorithm @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_add_non_handler @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_badly_named_methods @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_handled @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_handler_order @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_http_error @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_processors @ linux-x86_64 +test.test_urllib2.OpenerDirectorTests.test_raise @ linux-x86_64 +test.test_urllib2.RequestHdrsTests.test_password_manager @ linux-x86_64 +test.test_urllib2.RequestHdrsTests.test_password_manager_default_port @ linux-x86_64 +test.test_urllib2.RequestHdrsTests.test_request_headers_dict @ linux-x86_64 +test.test_urllib2.RequestHdrsTests.test_request_headers_methods @ linux-x86_64 +test.test_urllib2.RequestTests.test_data @ linux-x86_64 +test.test_urllib2.RequestTests.test_deleting_data_should_remove_content_length @ linux-x86_64 +test.test_urllib2.RequestTests.test_get_full_url @ linux-x86_64 +test.test_urllib2.RequestTests.test_get_host @ linux-x86_64 +test.test_urllib2.RequestTests.test_get_host_unquote @ linux-x86_64 +test.test_urllib2.RequestTests.test_get_type @ linux-x86_64 +test.test_urllib2.RequestTests.test_method @ linux-x86_64 +test.test_urllib2.RequestTests.test_proxy @ linux-x86_64 +test.test_urllib2.RequestTests.test_selector @ linux-x86_64 +test.test_urllib2.RequestTests.test_setting_data_should_remove_content_length @ linux-x86_64 +test.test_urllib2.RequestTests.test_url_fragment @ linux-x86_64 +test.test_urllib2.RequestTests.test_url_fullurl_get_full_url @ linux-x86_64 +test.test_urllib2.RequestTests.test_wrapped_url @ linux-x86_64 +test.test_urllib2.TrivialTests.test_URLError_reasonstr @ linux-x86_64 +test.test_urllib2.TrivialTests.test___all__ @ linux-x86_64 +test.test_urllib2.TrivialTests.test_parse_http_list @ linux-x86_64 +test.test_urllib2.TrivialTests.test_trivial @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2_localnet.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2_localnet.txt new file mode 100644 index 0000000000..aeedfebbd1 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2_localnet.txt @@ -0,0 +1,21 @@ +test.test_urllib2_localnet.BasicAuthTests.test_basic_auth_httperror @ linux-x86_64 +test.test_urllib2_localnet.ProxyAuthTests.test_proxy_qop_auth_int_works_or_throws_urlerror @ linux-x86_64 +test.test_urllib2_localnet.ProxyAuthTests.test_proxy_qop_auth_works @ linux-x86_64 +test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_bad_password_raises_httperror @ linux-x86_64 +test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_no_password_raises_httperror @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_200 @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_200_with_parameters @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_404 @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_basic @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_chunked @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_geturl @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_https @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_https_with_cadefault @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_https_with_cafile @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_info @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_issue16464 @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_iteration @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_line_iteration @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_redirection @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_sending_headers @ linux-x86_64 +test.test_urllib2_localnet.TestUrlopen.test_sending_headers_camel @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2net.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2net.txt new file mode 100644 index 0000000000..111928a3a2 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib2net.txt @@ -0,0 +1,10 @@ +test.test_urllib2net.CloseSocketTest.test_close @ linux-x86_64 +test.test_urllib2net.OtherNetworkTests.test_custom_headers @ linux-x86_64 +test.test_urllib2net.OtherNetworkTests.test_file @ linux-x86_64 +!test.test_urllib2net.OtherNetworkTests.test_ftp @ linux-x86_64 +test.test_urllib2net.OtherNetworkTests.test_redirect_url_withfrag @ linux-x86_64 +test.test_urllib2net.OtherNetworkTests.test_urlwithfrag @ linux-x86_64 +test.test_urllib2net.TimeoutTest.test_http_basic @ linux-x86_64 +test.test_urllib2net.TimeoutTest.test_http_default_timeout @ linux-x86_64 +test.test_urllib2net.TimeoutTest.test_http_no_timeout @ linux-x86_64 +test.test_urllib2net.TimeoutTest.test_http_timeout @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib_response.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib_response.txt new file mode 100644 index 0000000000..56c0d090df --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllib_response.txt @@ -0,0 +1,4 @@ +test.test_urllib_response.TestResponse.test_addclosehook @ linux-x86_64 +test.test_urllib_response.TestResponse.test_addinfo @ linux-x86_64 +test.test_urllib_response.TestResponse.test_addinfourl @ linux-x86_64 +test.test_urllib_response.TestResponse.test_with @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllibnet.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllibnet.txt new file mode 100644 index 0000000000..88801ca7ee --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urllibnet.txt @@ -0,0 +1,12 @@ +test.test_urllibnet.URLTimeoutTest.testURLread @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_bad_address @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_basic @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_getcode @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_geturl @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_info @ linux-x86_64 +test.test_urllibnet.urlopenNetworkTests.test_readlines @ linux-x86_64 +test.test_urllibnet.urlretrieveNetworkTests.test_basic @ linux-x86_64 +test.test_urllibnet.urlretrieveNetworkTests.test_data_header @ linux-x86_64 +test.test_urllibnet.urlretrieveNetworkTests.test_header @ linux-x86_64 +test.test_urllibnet.urlretrieveNetworkTests.test_reporthook @ linux-x86_64 +test.test_urllibnet.urlretrieveNetworkTests.test_specified_path @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urlparse.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urlparse.txt new file mode 100644 index 0000000000..82ef9813da --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_urlparse.txt @@ -0,0 +1,71 @@ +test.test_urlparse.DeprecationTest.test_Quoter_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitattr_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splithost_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitnport_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitpasswd_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitport_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitquery_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splittag_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splittype_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splituser_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_splitvalue_deprecation @ linux-x86_64 +test.test_urlparse.DeprecationTest.test_to_bytes_deprecation @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_Quoter_repr @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_RFC1808 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_RFC2368 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_RFC2396 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_RFC2732 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_RFC3986 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_all @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_anyscheme @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_attributes_bad_port @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_attributes_bad_scheme @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_attributes_without_netloc @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_clear_cache_for_code_coverage @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_default_scheme @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_http_roundtrips @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_invalid_bracketed_hosts @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_issue14072 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_mixed_types_rejected @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_noslash @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_fragments @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_qs_encoding @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_qs_separator @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_qsl_encoding @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_qsl_max_num_fields @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_parse_qsl_separator @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_port_casting_failure_message @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_portseparator @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_qs @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_qsl @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_quote_errors @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_quote_from_bytes @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_result_pairs @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_roundtrips @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_splitting_bracketed_hosts @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_telurl_params @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_unparse_parse @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_unquote_to_bytes @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urldefrag @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlencode_quote_via @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlencode_sequences @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urljoins @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urllib_parse_getattr_failure @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlsplit_attributes @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlsplit_remove_unsafe_bytes @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlsplit_scoped_IPv6 @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_urlsplit_strip_url @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_usingsys @ linux-x86_64 +test.test_urlparse.UrlParseTestCase.test_withoutscheme @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitattr @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splithost @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitnport @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitpasswd @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitport @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitquery @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splittag @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splittype @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splituser @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_splitvalue @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_to_bytes @ linux-x86_64 +test.test_urlparse.Utility_Tests.test_unwrap @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userdict.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userdict.txt new file mode 100644 index 0000000000..d5f657be62 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userdict.txt @@ -0,0 +1,24 @@ +test.test_userdict.UserDictTest.test_all @ linux-x86_64 +test.test_userdict.UserDictTest.test_bool @ linux-x86_64 +test.test_userdict.UserDictTest.test_clear @ linux-x86_64 +test.test_userdict.UserDictTest.test_constructor @ linux-x86_64 +test.test_userdict.UserDictTest.test_contains @ linux-x86_64 +test.test_userdict.UserDictTest.test_copy @ linux-x86_64 +test.test_userdict.UserDictTest.test_eq @ linux-x86_64 +test.test_userdict.UserDictTest.test_fromkeys @ linux-x86_64 +test.test_userdict.UserDictTest.test_get @ linux-x86_64 +test.test_userdict.UserDictTest.test_getitem @ linux-x86_64 +test.test_userdict.UserDictTest.test_init @ linux-x86_64 +test.test_userdict.UserDictTest.test_items @ linux-x86_64 +test.test_userdict.UserDictTest.test_keys @ linux-x86_64 +test.test_userdict.UserDictTest.test_len @ linux-x86_64 +test.test_userdict.UserDictTest.test_missing @ linux-x86_64 +test.test_userdict.UserDictTest.test_mutatingiteration @ linux-x86_64 +test.test_userdict.UserDictTest.test_pop @ linux-x86_64 +test.test_userdict.UserDictTest.test_popitem @ linux-x86_64 +test.test_userdict.UserDictTest.test_read @ linux-x86_64 +test.test_userdict.UserDictTest.test_repr @ linux-x86_64 +test.test_userdict.UserDictTest.test_setdefault @ linux-x86_64 +test.test_userdict.UserDictTest.test_update @ linux-x86_64 +test.test_userdict.UserDictTest.test_values @ linux-x86_64 +test.test_userdict.UserDictTest.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userlist.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userlist.txt new file mode 100644 index 0000000000..7e870e2ce7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userlist.txt @@ -0,0 +1,47 @@ +test.test_userlist.UserListTest.test_add_specials @ linux-x86_64 +test.test_userlist.UserListTest.test_addmul @ linux-x86_64 +test.test_userlist.UserListTest.test_append @ linux-x86_64 +test.test_userlist.UserListTest.test_clear @ linux-x86_64 +test.test_userlist.UserListTest.test_constructor_exception_handling @ linux-x86_64 +test.test_userlist.UserListTest.test_constructors @ linux-x86_64 +test.test_userlist.UserListTest.test_contains @ linux-x86_64 +test.test_userlist.UserListTest.test_contains_fake @ linux-x86_64 +test.test_userlist.UserListTest.test_contains_order @ linux-x86_64 +test.test_userlist.UserListTest.test_copy @ linux-x86_64 +test.test_userlist.UserListTest.test_count @ linux-x86_64 +test.test_userlist.UserListTest.test_delitem @ linux-x86_64 +test.test_userlist.UserListTest.test_delslice @ linux-x86_64 +test.test_userlist.UserListTest.test_exhausted_iterator @ linux-x86_64 +test.test_userlist.UserListTest.test_extend @ linux-x86_64 +test.test_userlist.UserListTest.test_extendedslicing @ linux-x86_64 +test.test_userlist.UserListTest.test_getitem @ linux-x86_64 +test.test_userlist.UserListTest.test_getitem_error @ linux-x86_64 +test.test_userlist.UserListTest.test_getitemoverwriteiter @ linux-x86_64 +test.test_userlist.UserListTest.test_getslice @ linux-x86_64 +test.test_userlist.UserListTest.test_iadd @ linux-x86_64 +test.test_userlist.UserListTest.test_imul @ linux-x86_64 +test.test_userlist.UserListTest.test_index @ linux-x86_64 +test.test_userlist.UserListTest.test_init @ linux-x86_64 +test.test_userlist.UserListTest.test_insert @ linux-x86_64 +test.test_userlist.UserListTest.test_len @ linux-x86_64 +test.test_userlist.UserListTest.test_minmax @ linux-x86_64 +test.test_userlist.UserListTest.test_mixedadd @ linux-x86_64 +test.test_userlist.UserListTest.test_mixedcmp @ linux-x86_64 +test.test_userlist.UserListTest.test_pickle @ linux-x86_64 +test.test_userlist.UserListTest.test_pop @ linux-x86_64 +test.test_userlist.UserListTest.test_radd_specials @ linux-x86_64 +test.test_userlist.UserListTest.test_remove @ linux-x86_64 +test.test_userlist.UserListTest.test_repeat @ linux-x86_64 +test.test_userlist.UserListTest.test_repr @ linux-x86_64 +test.test_userlist.UserListTest.test_reverse @ linux-x86_64 +test.test_userlist.UserListTest.test_reversed @ linux-x86_64 +test.test_userlist.UserListTest.test_set_subscript @ linux-x86_64 +test.test_userlist.UserListTest.test_setitem @ linux-x86_64 +test.test_userlist.UserListTest.test_setitem_error @ linux-x86_64 +test.test_userlist.UserListTest.test_setslice @ linux-x86_64 +test.test_userlist.UserListTest.test_slice @ linux-x86_64 +test.test_userlist.UserListTest.test_slice_type @ linux-x86_64 +test.test_userlist.UserListTest.test_sort @ linux-x86_64 +test.test_userlist.UserListTest.test_subscript @ linux-x86_64 +test.test_userlist.UserListTest.test_truth @ linux-x86_64 +test.test_userlist.UserListTest.test_userlist_copy @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userstring.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userstring.txt new file mode 100644 index 0000000000..0defdf79c7 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_userstring.txt @@ -0,0 +1,55 @@ +test.test_userstring.UserStringTest.test___contains__ @ linux-x86_64 +test.test_userstring.UserStringTest.test_additional_rsplit @ linux-x86_64 +test.test_userstring.UserStringTest.test_additional_split @ linux-x86_64 +test.test_userstring.UserStringTest.test_capitalize @ linux-x86_64 +test.test_userstring.UserStringTest.test_center @ linux-x86_64 +test.test_userstring.UserStringTest.test_count @ linux-x86_64 +test.test_userstring.UserStringTest.test_encode_default_args @ linux-x86_64 +test.test_userstring.UserStringTest.test_encode_explicit_none_args @ linux-x86_64 +test.test_userstring.UserStringTest.test_endswith @ linux-x86_64 +test.test_userstring.UserStringTest.test_expandtabs @ linux-x86_64 +test.test_userstring.UserStringTest.test_extended_getslice @ linux-x86_64 +test.test_userstring.UserStringTest.test_find @ linux-x86_64 +test.test_userstring.UserStringTest.test_find_etc_raise_correct_error_messages @ linux-x86_64 +test.test_userstring.UserStringTest.test_find_periodic_pattern @ linux-x86_64 +test.test_userstring.UserStringTest.test_find_shift_table_overflow @ linux-x86_64 +test.test_userstring.UserStringTest.test_fixtype @ linux-x86_64 +test.test_userstring.UserStringTest.test_floatformatting @ linux-x86_64 +test.test_userstring.UserStringTest.test_formatting @ linux-x86_64 +test.test_userstring.UserStringTest.test_hash @ linux-x86_64 +test.test_userstring.UserStringTest.test_index @ linux-x86_64 +test.test_userstring.UserStringTest.test_inplace_rewrites @ linux-x86_64 +test.test_userstring.UserStringTest.test_isalnum @ linux-x86_64 +test.test_userstring.UserStringTest.test_isalpha @ linux-x86_64 +test.test_userstring.UserStringTest.test_isascii @ linux-x86_64 +test.test_userstring.UserStringTest.test_isdigit @ linux-x86_64 +test.test_userstring.UserStringTest.test_islower @ linux-x86_64 +test.test_userstring.UserStringTest.test_isspace @ linux-x86_64 +test.test_userstring.UserStringTest.test_istitle @ linux-x86_64 +test.test_userstring.UserStringTest.test_isupper @ linux-x86_64 +test.test_userstring.UserStringTest.test_join @ linux-x86_64 +test.test_userstring.UserStringTest.test_ljust @ linux-x86_64 +test.test_userstring.UserStringTest.test_lower @ linux-x86_64 +test.test_userstring.UserStringTest.test_mul @ linux-x86_64 +test.test_userstring.UserStringTest.test_none_arguments @ linux-x86_64 +test.test_userstring.UserStringTest.test_partition @ linux-x86_64 +test.test_userstring.UserStringTest.test_removeprefix @ linux-x86_64 +test.test_userstring.UserStringTest.test_removesuffix @ linux-x86_64 +test.test_userstring.UserStringTest.test_replace @ linux-x86_64 +test.test_userstring.UserStringTest.test_rfind @ linux-x86_64 +test.test_userstring.UserStringTest.test_rindex @ linux-x86_64 +test.test_userstring.UserStringTest.test_rjust @ linux-x86_64 +test.test_userstring.UserStringTest.test_rmod @ linux-x86_64 +test.test_userstring.UserStringTest.test_rpartition @ linux-x86_64 +test.test_userstring.UserStringTest.test_rsplit @ linux-x86_64 +test.test_userstring.UserStringTest.test_slice @ linux-x86_64 +test.test_userstring.UserStringTest.test_split @ linux-x86_64 +test.test_userstring.UserStringTest.test_splitlines @ linux-x86_64 +test.test_userstring.UserStringTest.test_startswith @ linux-x86_64 +test.test_userstring.UserStringTest.test_strip @ linux-x86_64 +test.test_userstring.UserStringTest.test_strip_whitespace @ linux-x86_64 +test.test_userstring.UserStringTest.test_subscript @ linux-x86_64 +test.test_userstring.UserStringTest.test_swapcase @ linux-x86_64 +test.test_userstring.UserStringTest.test_title @ linux-x86_64 +test.test_userstring.UserStringTest.test_upper @ linux-x86_64 +test.test_userstring.UserStringTest.test_zfill @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8_mode.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8_mode.txt new file mode 100644 index 0000000000..ca970c16fc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8_mode.txt @@ -0,0 +1,4 @@ +test.test_utf8_mode.UTF8ModeTests.test_filesystemencoding @ linux-x86_64 +test.test_utf8_mode.UTF8ModeTests.test_io @ linux-x86_64 +test.test_utf8_mode.UTF8ModeTests.test_io_encoding @ linux-x86_64 +test.test_utf8_mode.UTF8ModeTests.test_pyio_encoding @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8source.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8source.txt new file mode 100644 index 0000000000..2dc3b5803f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_utf8source.txt @@ -0,0 +1,3 @@ +test.test_utf8source.BuiltinCompileTests.test_latin1 @ linux-x86_64 +test.test_utf8source.PEP3120Test.test_badsyntax @ linux-x86_64 +test.test_utf8source.PEP3120Test.test_pep3120 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uu.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uu.txt new file mode 100644 index 0000000000..5fc858b1b3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uu.txt @@ -0,0 +1,2 @@ +test.test_uu.UUTest.test_missingbegin @ linux-x86_64 +test.test_uu.UUTest.test_no_directory_traversal @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uuid.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uuid.txt new file mode 100644 index 0000000000..7d2d6e6cff --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_uuid.txt @@ -0,0 +1,20 @@ +test.test_uuid.TestInternalsWithoutExtModule.test_find_mac_near_keyword @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_find_under_heading @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_find_under_heading_ipv6 @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_ip_getnode @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_parse_mac @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_parse_mac_aix @ linux-x86_64 +test.test_uuid.TestInternalsWithoutExtModule.test_random_getnode @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_UUID @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_exceptions @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_getnode @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_pickle_roundtrip @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_safe_uuid_enum @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_unpickle_previous_python_versions @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid1 @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid1_eui64 @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid1_time @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid3 @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid4 @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid5 @ linux-x86_64 +test.test_uuid.TestUUIDWithoutExtModule.test_uuid_weakref @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_venv.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_venv.txt new file mode 100644 index 0000000000..04358f1fcc --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_venv.txt @@ -0,0 +1,15 @@ +test.test_venv.BasicTest.test_deactivate_with_strict_bash_opts @ linux-x86_64 +test.test_venv.BasicTest.test_executable @ linux-x86_64 +test.test_venv.BasicTest.test_executable_symlinks @ linux-x86_64 +test.test_venv.BasicTest.test_isolation @ linux-x86_64 +test.test_venv.BasicTest.test_overwrite_existing @ linux-x86_64 +test.test_venv.BasicTest.test_pathsep_error @ linux-x86_64 +test.test_venv.BasicTest.test_prefixes @ linux-x86_64 +test.test_venv.BasicTest.test_prompt @ linux-x86_64 +test.test_venv.BasicTest.test_symlinking @ linux-x86_64 +test.test_venv.BasicTest.test_unoverwritable_fails @ linux-x86_64 +test.test_venv.BasicTest.test_upgrade @ linux-x86_64 +test.test_venv.BasicTest.test_upgrade_dependencies @ linux-x86_64 +test.test_venv.EnsurePipTest.test_devnull @ linux-x86_64 +test.test_venv.EnsurePipTest.test_explicit_no_pip @ linux-x86_64 +test.test_venv.EnsurePipTest.test_no_pip_by_default @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_warnings.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_warnings.txt new file mode 100644 index 0000000000..dabb10b455 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_warnings.txt @@ -0,0 +1,113 @@ +test.test_warnings.BootstrapTest.test_issue_8766 @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_catch_warnings_defaults @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_catch_warnings_recording @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_catch_warnings_reentry_guard @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_catch_warnings_restore @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_check_warnings @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_record_override_showwarning_before @ linux-x86_64 +test.test_warnings.CCatchWarningTests.test_record_override_showwarning_inside @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_comma_separated_warnings @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_conflicting_envvar_and_command_line @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_default_filter_configuration @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_envvar_and_command_line @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_nonascii @ linux-x86_64 +test.test_warnings.CEnvironmentVariableTests.test_single_warning @ linux-x86_64 +test.test_warnings.CFilterTests.test_always @ linux-x86_64 +test.test_warnings.CFilterTests.test_always_after_default @ linux-x86_64 +test.test_warnings.CFilterTests.test_append_duplicate @ linux-x86_64 +test.test_warnings.CFilterTests.test_catchwarnings_with_simplefilter_error @ linux-x86_64 +test.test_warnings.CFilterTests.test_catchwarnings_with_simplefilter_ignore @ linux-x86_64 +test.test_warnings.CFilterTests.test_default @ linux-x86_64 +test.test_warnings.CFilterTests.test_error @ linux-x86_64 +test.test_warnings.CFilterTests.test_error_after_default @ linux-x86_64 +test.test_warnings.CFilterTests.test_filterwarnings @ linux-x86_64 +test.test_warnings.CFilterTests.test_filterwarnings_duplicate_filters @ linux-x86_64 +test.test_warnings.CFilterTests.test_ignore @ linux-x86_64 +test.test_warnings.CFilterTests.test_ignore_after_default @ linux-x86_64 +test.test_warnings.CFilterTests.test_inheritance @ linux-x86_64 +test.test_warnings.CFilterTests.test_message_matching @ linux-x86_64 +test.test_warnings.CFilterTests.test_module @ linux-x86_64 +test.test_warnings.CFilterTests.test_module_globals @ linux-x86_64 +test.test_warnings.CFilterTests.test_mutate_filter_list @ linux-x86_64 +test.test_warnings.CFilterTests.test_once @ linux-x86_64 +test.test_warnings.CFilterTests.test_ordering @ linux-x86_64 +test.test_warnings.CFilterTests.test_simplefilter_duplicate_filters @ linux-x86_64 +test.test_warnings.CPublicAPITests.test_module_all_attribute @ linux-x86_64 +test.test_warnings.CWCmdLineTests.test_import_from_module @ linux-x86_64 +test.test_warnings.CWCmdLineTests.test_improper_input @ linux-x86_64 +test.test_warnings.CWarnTests.test_accelerated @ linux-x86_64 +test.test_warnings.CWarnTests.test_bad_str @ linux-x86_64 +test.test_warnings.CWarnTests.test_exec_filename @ linux-x86_64 +test.test_warnings.CWarnTests.test_filename @ linux-x86_64 +test.test_warnings.CWarnTests.test_message @ linux-x86_64 +test.test_warnings.CWarnTests.test_stacklevel @ linux-x86_64 +test.test_warnings.CWarnTests.test_warn_explicit_non_ascii_filename @ linux-x86_64 +test.test_warnings.CWarnTests.test_warn_explicit_type_errors @ linux-x86_64 +test.test_warnings.CWarnTests.test_warn_nonstandard_types @ linux-x86_64 +test.test_warnings.CWarnTests.test_warning_classes @ linux-x86_64 +test.test_warnings.CWarningsDisplayTests.test_formatwarning @ linux-x86_64 +test.test_warnings.CWarningsDisplayTests.test_formatwarning_override @ linux-x86_64 +test.test_warnings.CWarningsDisplayTests.test_showwarning @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_catch_warnings_defaults @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_catch_warnings_recording @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_catch_warnings_reentry_guard @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_catch_warnings_restore @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_check_warnings @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_record_override_showwarning_before @ linux-x86_64 +test.test_warnings.PyCatchWarningTests.test_record_override_showwarning_inside @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_comma_separated_warnings @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_conflicting_envvar_and_command_line @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_default_filter_configuration @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_envvar_and_command_line @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_nonascii @ linux-x86_64 +test.test_warnings.PyEnvironmentVariableTests.test_single_warning @ linux-x86_64 +test.test_warnings.PyFilterTests.test_always @ linux-x86_64 +test.test_warnings.PyFilterTests.test_always_after_default @ linux-x86_64 +test.test_warnings.PyFilterTests.test_append_duplicate @ linux-x86_64 +test.test_warnings.PyFilterTests.test_catchwarnings_with_simplefilter_error @ linux-x86_64 +test.test_warnings.PyFilterTests.test_catchwarnings_with_simplefilter_ignore @ linux-x86_64 +test.test_warnings.PyFilterTests.test_default @ linux-x86_64 +test.test_warnings.PyFilterTests.test_error @ linux-x86_64 +test.test_warnings.PyFilterTests.test_error_after_default @ linux-x86_64 +test.test_warnings.PyFilterTests.test_filterwarnings @ linux-x86_64 +test.test_warnings.PyFilterTests.test_filterwarnings_duplicate_filters @ linux-x86_64 +test.test_warnings.PyFilterTests.test_ignore @ linux-x86_64 +test.test_warnings.PyFilterTests.test_ignore_after_default @ linux-x86_64 +test.test_warnings.PyFilterTests.test_inheritance @ linux-x86_64 +test.test_warnings.PyFilterTests.test_message_matching @ linux-x86_64 +test.test_warnings.PyFilterTests.test_module @ linux-x86_64 +test.test_warnings.PyFilterTests.test_module_globals @ linux-x86_64 +test.test_warnings.PyFilterTests.test_mutate_filter_list @ linux-x86_64 +test.test_warnings.PyFilterTests.test_once @ linux-x86_64 +test.test_warnings.PyFilterTests.test_ordering @ linux-x86_64 +test.test_warnings.PyFilterTests.test_simplefilter_duplicate_filters @ linux-x86_64 +test.test_warnings.PyPublicAPITests.test_module_all_attribute @ linux-x86_64 +test.test_warnings.PyWCmdLineTests.test_import_from_module @ linux-x86_64 +test.test_warnings.PyWCmdLineTests.test_improper_input @ linux-x86_64 +test.test_warnings.PyWCmdLineTests.test_improper_option @ linux-x86_64 +test.test_warnings.PyWCmdLineTests.test_warnings_bootstrap @ linux-x86_64 +test.test_warnings.PyWarnTests.test_bad_str @ linux-x86_64 +test.test_warnings.PyWarnTests.test_exec_filename @ linux-x86_64 +test.test_warnings.PyWarnTests.test_filename @ linux-x86_64 +test.test_warnings.PyWarnTests.test_message @ linux-x86_64 +test.test_warnings.PyWarnTests.test_pure_python @ linux-x86_64 +test.test_warnings.PyWarnTests.test_stacklevel @ linux-x86_64 +test.test_warnings.PyWarnTests.test_warn_explicit_non_ascii_filename @ linux-x86_64 +test.test_warnings.PyWarnTests.test_warn_explicit_type_errors @ linux-x86_64 +test.test_warnings.PyWarnTests.test_warn_nonstandard_types @ linux-x86_64 +test.test_warnings.PyWarnTests.test_warning_classes @ linux-x86_64 +test.test_warnings.PyWarningsDisplayTests.test_formatwarning @ linux-x86_64 +test.test_warnings.PyWarningsDisplayTests.test_formatwarning_override @ linux-x86_64 +test.test_warnings.PyWarningsDisplayTests.test_showwarning @ linux-x86_64 +test.test_warnings._DeprecatedTest.test_RuntimeError @ linux-x86_64 +test.test_warnings._DeprecatedTest.test_warning @ linux-x86_64 +test.test_warnings._WarningsTests.test_default_action @ linux-x86_64 +test.test_warnings._WarningsTests.test_filename_none @ linux-x86_64 +test.test_warnings._WarningsTests.test_filter @ linux-x86_64 +test.test_warnings._WarningsTests.test_issue31285 @ linux-x86_64 +test.test_warnings._WarningsTests.test_onceregistry @ linux-x86_64 +test.test_warnings._WarningsTests.test_show_warning_output @ linux-x86_64 +test.test_warnings._WarningsTests.test_showwarning_missing @ linux-x86_64 +test.test_warnings._WarningsTests.test_showwarning_not_callable @ linux-x86_64 +test.test_warnings._WarningsTests.test_showwarnmsg_missing @ linux-x86_64 +test.test_warnings._WarningsTests.test_stderr_none @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wave.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wave.txt new file mode 100644 index 0000000000..2d35c10018 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wave.txt @@ -0,0 +1,90 @@ +test.test_wave.MiscTestCase.test__all__ @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_no_chunks @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_no_data_chunk @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_no_fmt_chunk @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_no_fmt_no_data_chunk @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_no_riff_chunk @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_not_wave @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_wrong_form @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_wrong_number_of_channels @ linux-x86_64 +test.test_wave.WaveLowLevelTest.test_read_wrong_sample_width @ linux-x86_64 +test.test_wave.WavePCM16Test.test_close @ linux-x86_64 +test.test_wave.WavePCM16Test.test_context_manager_with_filename @ linux-x86_64 +test.test_wave.WavePCM16Test.test_context_manager_with_open_file @ linux-x86_64 +test.test_wave.WavePCM16Test.test_copy @ linux-x86_64 +test.test_wave.WavePCM16Test.test_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_multiple_writes @ linux-x86_64 +test.test_wave.WavePCM16Test.test_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_read @ linux-x86_64 +test.test_wave.WavePCM16Test.test_read_not_from_start @ linux-x86_64 +test.test_wave.WavePCM16Test.test_read_params @ linux-x86_64 +test.test_wave.WavePCM16Test.test_unseekable_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_unseekable_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_unseekable_read @ linux-x86_64 +test.test_wave.WavePCM16Test.test_unseekable_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write_array @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write_bytearray @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write_context_manager_calls_close @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write_memoryview @ linux-x86_64 +test.test_wave.WavePCM16Test.test_write_params @ linux-x86_64 +test.test_wave.WavePCM24Test.test_close @ linux-x86_64 +test.test_wave.WavePCM24Test.test_context_manager_with_filename @ linux-x86_64 +test.test_wave.WavePCM24Test.test_context_manager_with_open_file @ linux-x86_64 +test.test_wave.WavePCM24Test.test_copy @ linux-x86_64 +test.test_wave.WavePCM24Test.test_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_multiple_writes @ linux-x86_64 +test.test_wave.WavePCM24Test.test_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_read @ linux-x86_64 +test.test_wave.WavePCM24Test.test_read_not_from_start @ linux-x86_64 +test.test_wave.WavePCM24Test.test_read_params @ linux-x86_64 +test.test_wave.WavePCM24Test.test_unseekable_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_unseekable_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_unseekable_read @ linux-x86_64 +test.test_wave.WavePCM24Test.test_unseekable_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write_array @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write_bytearray @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write_context_manager_calls_close @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write_memoryview @ linux-x86_64 +test.test_wave.WavePCM24Test.test_write_params @ linux-x86_64 +test.test_wave.WavePCM32Test.test_close @ linux-x86_64 +test.test_wave.WavePCM32Test.test_context_manager_with_filename @ linux-x86_64 +test.test_wave.WavePCM32Test.test_context_manager_with_open_file @ linux-x86_64 +test.test_wave.WavePCM32Test.test_copy @ linux-x86_64 +test.test_wave.WavePCM32Test.test_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_multiple_writes @ linux-x86_64 +test.test_wave.WavePCM32Test.test_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_read @ linux-x86_64 +test.test_wave.WavePCM32Test.test_read_not_from_start @ linux-x86_64 +test.test_wave.WavePCM32Test.test_read_params @ linux-x86_64 +test.test_wave.WavePCM32Test.test_unseekable_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_unseekable_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_unseekable_read @ linux-x86_64 +test.test_wave.WavePCM32Test.test_unseekable_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write_array @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write_bytearray @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write_context_manager_calls_close @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write_memoryview @ linux-x86_64 +test.test_wave.WavePCM32Test.test_write_params @ linux-x86_64 +test.test_wave.WavePCM8Test.test_close @ linux-x86_64 +test.test_wave.WavePCM8Test.test_context_manager_with_filename @ linux-x86_64 +test.test_wave.WavePCM8Test.test_context_manager_with_open_file @ linux-x86_64 +test.test_wave.WavePCM8Test.test_copy @ linux-x86_64 +test.test_wave.WavePCM8Test.test_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_multiple_writes @ linux-x86_64 +test.test_wave.WavePCM8Test.test_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_read @ linux-x86_64 +test.test_wave.WavePCM8Test.test_read_not_from_start @ linux-x86_64 +test.test_wave.WavePCM8Test.test_read_params @ linux-x86_64 +test.test_wave.WavePCM8Test.test_unseekable_incompleted_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_unseekable_overflowed_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_unseekable_read @ linux-x86_64 +test.test_wave.WavePCM8Test.test_unseekable_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write_array @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write_bytearray @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write_context_manager_calls_close @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write_memoryview @ linux-x86_64 +test.test_wave.WavePCM8Test.test_write_params @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakref.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakref.txt new file mode 100644 index 0000000000..03fc77d16a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakref.txt @@ -0,0 +1,86 @@ +DocTestCase.test.test_weakref.__test__.libreftest @ linux-x86_64 +test.test_weakref.FinalizeTestCase.test_arg_errors @ linux-x86_64 +test.test_weakref.FinalizeTestCase.test_finalize @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_keyed_dict_from_dict @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_keyed_dict_from_weak_keyed_dict @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_keyed_dict_repr @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_valued_dict_from_dict @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_valued_dict_from_weak_valued_dict @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_valued_dict_misc @ linux-x86_64 +test.test_weakref.MappingTestCase.test_make_weak_valued_dict_repr @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_key_dict_copy @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_value_dict_copy @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_value_dict_deepcopy @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_valued_consistency @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_valued_pop @ linux-x86_64 +test.test_weakref.MappingTestCase.test_threaded_weak_valued_setdefault @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_keyed_delitem @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_keyed_dict_popitem @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_keyed_dict_setdefault @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_keyed_dict_update @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_keyed_iters @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_valued_delitem @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_valued_dict_popitem @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_valued_dict_setdefault @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_valued_dict_update @ linux-x86_64 +test.test_weakref.MappingTestCase.test_weak_valued_iters @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_basic_callback @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_basic_proxy @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_basic_ref @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_callback_different_classes @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_callback_gcs @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_callback_in_cycle @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_callback_reachable_one_way @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_callbacks_protected @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_constructor_kwargs @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_hashing @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_init @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_multiple_callbacks @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_multiple_selfref_callbacks @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_newstyle_number_ops @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_ordering @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_bool @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_deletion @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_div @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_index @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_iter @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_next @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_reversed @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_proxy_unicode @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_ref_created_during_del @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_set_callback_attribute @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_sf_bug_840829 @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_shared_ref_without_callback @ linux-x86_64 +test.test_weakref.ReferencesTestCase.test_trashcan_16602 @ linux-x86_64 +test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_cycle @ linux-x86_64 +test.test_weakref.SubclassableWeakrefTestCase.test_subclass_refs_with_slots @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_bool @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_constructor @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_get @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_getitem @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_items @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_keys @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_len @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_pop @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_popitem @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_read @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_setdefault @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_update @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_values @ linux-x86_64 +test.test_weakref.WeakKeyDictionaryTestCase.test_write @ linux-x86_64 +test.test_weakref.WeakMethodTestCase.test_alive @ linux-x86_64 +test.test_weakref.WeakMethodTestCase.test_equality @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_bool @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_constructor @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_get @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_getitem @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_items @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_keys @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_len @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_pop @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_popitem @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_read @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_setdefault @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_update @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_values @ linux-x86_64 +test.test_weakref.WeakValueDictionaryTestCase.test_write @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakset.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakset.txt new file mode 100644 index 0000000000..99e3e83139 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_weakset.txt @@ -0,0 +1,36 @@ +test.test_weakset.TestWeakSet.test_abc @ linux-x86_64 +test.test_weakset.TestWeakSet.test_and @ linux-x86_64 +test.test_weakset.TestWeakSet.test_clear @ linux-x86_64 +test.test_weakset.TestWeakSet.test_constructor_identity @ linux-x86_64 +test.test_weakset.TestWeakSet.test_copy @ linux-x86_64 +test.test_weakset.TestWeakSet.test_copying @ linux-x86_64 +test.test_weakset.TestWeakSet.test_difference @ linux-x86_64 +test.test_weakset.TestWeakSet.test_difference_update @ linux-x86_64 +test.test_weakset.TestWeakSet.test_discard @ linux-x86_64 +test.test_weakset.TestWeakSet.test_eq @ linux-x86_64 +test.test_weakset.TestWeakSet.test_gc @ linux-x86_64 +test.test_weakset.TestWeakSet.test_gt @ linux-x86_64 +test.test_weakset.TestWeakSet.test_hash @ linux-x86_64 +test.test_weakset.TestWeakSet.test_iand @ linux-x86_64 +test.test_weakset.TestWeakSet.test_init @ linux-x86_64 +test.test_weakset.TestWeakSet.test_inplace_on_self @ linux-x86_64 +test.test_weakset.TestWeakSet.test_intersection_update @ linux-x86_64 +test.test_weakset.TestWeakSet.test_ior @ linux-x86_64 +test.test_weakset.TestWeakSet.test_isdisjoint @ linux-x86_64 +test.test_weakset.TestWeakSet.test_isub @ linux-x86_64 +test.test_weakset.TestWeakSet.test_ixor @ linux-x86_64 +test.test_weakset.TestWeakSet.test_lt @ linux-x86_64 +test.test_weakset.TestWeakSet.test_methods @ linux-x86_64 +test.test_weakset.TestWeakSet.test_ne @ linux-x86_64 +test.test_weakset.TestWeakSet.test_new_or_init @ linux-x86_64 +test.test_weakset.TestWeakSet.test_or @ linux-x86_64 +test.test_weakset.TestWeakSet.test_pop @ linux-x86_64 +test.test_weakset.TestWeakSet.test_remove @ linux-x86_64 +test.test_weakset.TestWeakSet.test_repr @ linux-x86_64 +test.test_weakset.TestWeakSet.test_sub @ linux-x86_64 +test.test_weakset.TestWeakSet.test_sub_and_super @ linux-x86_64 +test.test_weakset.TestWeakSet.test_subclass_with_custom_hash @ linux-x86_64 +test.test_weakset.TestWeakSet.test_symmetric_difference_update @ linux-x86_64 +test.test_weakset.TestWeakSet.test_update @ linux-x86_64 +test.test_weakset.TestWeakSet.test_update_set @ linux-x86_64 +test.test_weakset.TestWeakSet.test_xor @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_webbrowser.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_webbrowser.txt new file mode 100644 index 0000000000..9ce63b4ec5 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_webbrowser.txt @@ -0,0 +1,32 @@ +test.test_webbrowser.BackgroundBrowserCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.BrowserRegistrationTest.test_register @ linux-x86_64 +test.test_webbrowser.BrowserRegistrationTest.test_register_default @ linux-x86_64 +test.test_webbrowser.BrowserRegistrationTest.test_register_preferred @ linux-x86_64 +test.test_webbrowser.ChromeCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.ChromeCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.ChromeCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.ChromeCommandTest.test_open_with_autoraise_false @ linux-x86_64 +test.test_webbrowser.ELinksCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.ELinksCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.ELinksCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.ELinksCommandTest.test_open_with_autoraise_false @ linux-x86_64 +test.test_webbrowser.GaleonCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.GaleonCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.GaleonCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.GaleonCommandTest.test_open_with_autoraise_false @ linux-x86_64 +test.test_webbrowser.GenericBrowserCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.ImportTest.test_get @ linux-x86_64 +test.test_webbrowser.ImportTest.test_register @ linux-x86_64 +test.test_webbrowser.ImportTest.test_synthesize @ linux-x86_64 +test.test_webbrowser.MozillaCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.MozillaCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.MozillaCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.MozillaCommandTest.test_open_with_autoraise_false @ linux-x86_64 +test.test_webbrowser.NetscapeCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.NetscapeCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.NetscapeCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.NetscapeCommandTest.test_open_with_autoraise_false @ linux-x86_64 +test.test_webbrowser.OperaCommandTest.test_open @ linux-x86_64 +test.test_webbrowser.OperaCommandTest.test_open_new @ linux-x86_64 +test.test_webbrowser.OperaCommandTest.test_open_new_tab @ linux-x86_64 +test.test_webbrowser.OperaCommandTest.test_open_with_autoraise_false @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_with.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_with.txt new file mode 100644 index 0000000000..ddd297e7b9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_with.txt @@ -0,0 +1,50 @@ +test.test_with.AssignmentTargetTestCase.testMultipleComplexTargets @ linux-x86_64 +test.test_with.AssignmentTargetTestCase.testSingleComplexTarget @ linux-x86_64 +test.test_with.AssignmentTargetTestCase.testWithExtendedTargets @ linux-x86_64 +test.test_with.ExceptionalTestCase.testErrorsInBool @ linux-x86_64 +test.test_with.ExceptionalTestCase.testExceptionNormalized @ linux-x86_64 +test.test_with.ExceptionalTestCase.testMultipleResourcesInSingleStatement @ linux-x86_64 +test.test_with.ExceptionalTestCase.testNestedExceptionAfterInnerStatement @ linux-x86_64 +test.test_with.ExceptionalTestCase.testNestedExceptionBeforeInnerStatement @ linux-x86_64 +test.test_with.ExceptionalTestCase.testNestedSingleStatements @ linux-x86_64 +test.test_with.ExceptionalTestCase.testRaisedGeneratorExit1 @ linux-x86_64 +test.test_with.ExceptionalTestCase.testRaisedGeneratorExit2 @ linux-x86_64 +test.test_with.ExceptionalTestCase.testRaisedStopIteration1 @ linux-x86_64 +test.test_with.ExceptionalTestCase.testRaisedStopIteration2 @ linux-x86_64 +test.test_with.ExceptionalTestCase.testRaisedStopIteration3 @ linux-x86_64 +test.test_with.ExceptionalTestCase.testSingleResource @ linux-x86_64 +test.test_with.ExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException @ linux-x86_64 +test.test_with.ExitSwallowsExceptionTestCase.testExitTrueSwallowsException @ linux-x86_64 +test.test_with.FailureTestCase.testAssignmentToNoneError @ linux-x86_64 +test.test_with.FailureTestCase.testAssignmentToTupleContainingNoneError @ linux-x86_64 +test.test_with.FailureTestCase.testAssignmentToTupleOnlyContainingNoneError @ linux-x86_64 +test.test_with.FailureTestCase.testEnterAttributeError1 @ linux-x86_64 +test.test_with.FailureTestCase.testEnterAttributeError2 @ linux-x86_64 +test.test_with.FailureTestCase.testEnterThrows @ linux-x86_64 +test.test_with.FailureTestCase.testExitAttributeError @ linux-x86_64 +test.test_with.FailureTestCase.testExitThrows @ linux-x86_64 +test.test_with.FailureTestCase.testNameError @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testMultipleArgBound @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testMultipleArgUnbound @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testSingleArgBoundToNonTuple @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedList @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testSingleArgInlineGeneratorSyntax @ linux-x86_64 +test.test_with.NestedNonexceptionalTestCase.testSingleArgUnbound @ linux-x86_64 +test.test_with.NestedWith.testEnterReturnsTuple @ linux-x86_64 +test.test_with.NestedWith.testExceptionInEnter @ linux-x86_64 +test.test_with.NestedWith.testExceptionInExit @ linux-x86_64 +test.test_with.NestedWith.testExceptionInExprList @ linux-x86_64 +test.test_with.NestedWith.testNoExceptions @ linux-x86_64 +test.test_with.NonLocalFlowControlTestCase.testWithBreak @ linux-x86_64 +test.test_with.NonLocalFlowControlTestCase.testWithContinue @ linux-x86_64 +test.test_with.NonLocalFlowControlTestCase.testWithRaise @ linux-x86_64 +test.test_with.NonLocalFlowControlTestCase.testWithReturn @ linux-x86_64 +test.test_with.NonLocalFlowControlTestCase.testWithYield @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testBoundGenerator @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testInlineGeneratorBoundSyntax @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariable @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testInlineGeneratorBoundToExistingVariable @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testInlineGeneratorSyntax @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testNestedSingleStatements @ linux-x86_64 +test.test_with.NonexceptionalTestCase.testUnboundGenerator @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wsgiref.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wsgiref.txt new file mode 100644 index 0000000000..cc046fd695 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_wsgiref.txt @@ -0,0 +1,34 @@ +test.test_wsgiref.HandlerTests.testAbstractMethods @ linux-x86_64 +test.test_wsgiref.HandlerTests.testBasicErrorOutput @ linux-x86_64 +test.test_wsgiref.HandlerTests.testBytesData @ linux-x86_64 +test.test_wsgiref.HandlerTests.testCGIEnviron @ linux-x86_64 +test.test_wsgiref.HandlerTests.testClientConnectionTerminations @ linux-x86_64 +test.test_wsgiref.HandlerTests.testCloseOnError @ linux-x86_64 +test.test_wsgiref.HandlerTests.testContentLength @ linux-x86_64 +test.test_wsgiref.HandlerTests.testDontResetInternalStateOnException @ linux-x86_64 +test.test_wsgiref.HandlerTests.testEnviron @ linux-x86_64 +test.test_wsgiref.HandlerTests.testErrorAfterOutput @ linux-x86_64 +test.test_wsgiref.HandlerTests.testHeaderFormats @ linux-x86_64 +test.test_wsgiref.HandlerTests.testPartialWrite @ linux-x86_64 +test.test_wsgiref.HandlerTests.testScheme @ linux-x86_64 +test.test_wsgiref.HeaderTests.testExtras @ linux-x86_64 +test.test_wsgiref.HeaderTests.testMappingInterface @ linux-x86_64 +test.test_wsgiref.HeaderTests.testRequireList @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_bytes_validation @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_cp1252_url @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_environ @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_plain_hello @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_request_length @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_simple_validation_error @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_status_validation_errors @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_validated_hello @ linux-x86_64 +test.test_wsgiref.IntegrationTests.test_wsgi_input @ linux-x86_64 +test.test_wsgiref.UtilityTests.testAppURIs @ linux-x86_64 +test.test_wsgiref.UtilityTests.testCrossDefaults @ linux-x86_64 +test.test_wsgiref.UtilityTests.testDefaults @ linux-x86_64 +test.test_wsgiref.UtilityTests.testFileWrapper @ linux-x86_64 +test.test_wsgiref.UtilityTests.testGuessScheme @ linux-x86_64 +test.test_wsgiref.UtilityTests.testHopByHop @ linux-x86_64 +test.test_wsgiref.UtilityTests.testNormalizedShifts @ linux-x86_64 +test.test_wsgiref.UtilityTests.testReqURIs @ linux-x86_64 +test.test_wsgiref.UtilityTests.testSimpleShifts @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xdrlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xdrlib.txt new file mode 100644 index 0000000000..5d7a2df0a3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xdrlib.txt @@ -0,0 +1,6 @@ +test.test_xdrlib.ConversionErrorTest.test_double @ linux-x86_64 +test.test_xdrlib.ConversionErrorTest.test_float @ linux-x86_64 +test.test_xdrlib.ConversionErrorTest.test_pack_int @ linux-x86_64 +test.test_xdrlib.ConversionErrorTest.test_pack_uint @ linux-x86_64 +test.test_xdrlib.ConversionErrorTest.test_uhyper @ linux-x86_64 +test.test_xdrlib.XDRTest.test_xdr @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_dom_minicompat.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_dom_minicompat.txt new file mode 100644 index 0000000000..efaf1164e3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_dom_minicompat.txt @@ -0,0 +1,11 @@ +test.test_xml_dom_minicompat.EmptyNodeListTestCase.test_emptynodelist___add__ @ linux-x86_64 +test.test_xml_dom_minicompat.EmptyNodeListTestCase.test_emptynodelist___radd__ @ linux-x86_64 +test.test_xml_dom_minicompat.EmptyNodeListTestCase.test_emptynodelist_item @ linux-x86_64 +test.test_xml_dom_minicompat.EmptyNodeListTestCase.test_emptynodelist_length @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist___add__ @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist___radd__ @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist_copy @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist_deepcopy @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist_item @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist_length @ linux-x86_64 +test.test_xml_dom_minicompat.NodeListTestCase.test_nodelist_pickle_roundtrip @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree.txt new file mode 100644 index 0000000000..7a77c4bd33 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree.txt @@ -0,0 +1,181 @@ +test.test_xml_etree.BadElementPathTest.test_find_with_error @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_find_with_mutating @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findall_with_error @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findall_with_mutating @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findtext_with_error @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findtext_with_falsey_text_attribute @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findtext_with_mutating @ linux-x86_64 +test.test_xml_etree.BadElementPathTest.test_findtext_with_none_text_attribute @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_ass_subscr @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_element_get_tail @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_element_get_text @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_extend_mutable_list @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_extend_mutable_list2 @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_recursive_repr @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_remove_with_mutating @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_subscr @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_treebuilder_end @ linux-x86_64 +test.test_xml_etree.BadElementTest.test_treebuilder_start @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test___copy__ @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test___deepcopy__ @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test___init__ @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_augmentation_type_errors @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_copy @ linux-x86_64 +!test.test_xml_etree.BasicElementTest.test_cyclic_gc @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_get_keyword_args @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_pickle @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_pickle_issue18997 @ linux-x86_64 +test.test_xml_etree.BasicElementTest.test_weakref @ linux-x86_64 +test.test_xml_etree.BugsTest.test_39495_treebuilder_start @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_1534630 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200708_close @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200708_newline @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200709_default_namespace @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200709_element_comment @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200709_element_insert @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200709_iter_comment @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_200709_register_namespace @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit21 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit25 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit28 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit39 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit54 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit55 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit60 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit62 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkit63 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_bug_xmltoolkitX1 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_expat224_utf8_bug @ linux-x86_64 +test.test_xml_etree.BugsTest.test_expat224_utf8_bug_file @ linux-x86_64 +test.test_xml_etree.BugsTest.test_issue10777 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_issue6233 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_issue6565 @ linux-x86_64 +test.test_xml_etree.BugsTest.test_lost_tail @ linux-x86_64 +test.test_xml_etree.BugsTest.test_lost_text @ linux-x86_64 +test.test_xml_etree.C14NTest.test_c14n_exclusion @ linux-x86_64 +test.test_xml_etree.C14NTest.test_simple_roundtrip @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_bad_find @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_find_simple @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_find_through_ElementTree @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_find_xpath @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_findall @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_findall_different_nsmaps @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_findall_wildcard @ linux-x86_64 +test.test_xml_etree.ElementFindTest.test_test_find_with_ns @ linux-x86_64 +test.test_xml_etree.ElementIterTest.test_basic @ linux-x86_64 +test.test_xml_etree.ElementIterTest.test_copy @ linux-x86_64 +test.test_xml_etree.ElementIterTest.test_corners @ linux-x86_64 +test.test_xml_etree.ElementIterTest.test_iter_by_tag @ linux-x86_64 +test.test_xml_etree.ElementIterTest.test_pickle @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_delslice @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_getslice_negative_steps @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_getslice_range @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_getslice_single_index @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_getslice_steps @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_setslice_range @ linux-x86_64 +test.test_xml_etree.ElementSlicingTest.test_setslice_single_index @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_attlist_default @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_attrib @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_cdata @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_children @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_copy @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_custom_builder @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_custom_builder_only_end_ns @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_doctype_public @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_dump_attribute_order @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_entity @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_file_init @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_html_empty_elems_serialization @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_indent @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_indent_level @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_indent_space @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_indent_space_caching @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_initialize_parser_without_target @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_interface @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_issue18347 @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_iterparse @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_makeelement @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_methods @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_namespace @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_parsefile @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_parseliteral @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_path_cache @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_processinginstruction @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_qname @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_set_attribute @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_default_namespace @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_default_namespace_different_namespace @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_default_namespace_original_no_namespace @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_no_xml_declaration @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_xml_declaration @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_xml_declaration_cases @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostring_xml_declaration_unicode_encoding @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostringlist_default_namespace @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tostringlist_xml_declaration @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_tree_write_attribute_order @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_writefile @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_writestring @ linux-x86_64 +test.test_xml_etree.ElementTreeTest.test_xpath_tokenizer @ linux-x86_64 +test.test_xml_etree.ElementTreeTypeTest.test_Element_subclass_constructor @ linux-x86_64 +test.test_xml_etree.ElementTreeTypeTest.test_Element_subclass_find @ linux-x86_64 +test.test_xml_etree.ElementTreeTypeTest.test_Element_subclass_new_method @ linux-x86_64 +test.test_xml_etree.ElementTreeTypeTest.test_Element_subclass_trivial @ linux-x86_64 +test.test_xml_etree.ElementTreeTypeTest.test_istype @ linux-x86_64 +test.test_xml_etree.IOTest.test_read_from_bytesio @ linux-x86_64 +test.test_xml_etree.IOTest.test_read_from_stringio @ linux-x86_64 +test.test_xml_etree.IOTest.test_read_from_user_binary_reader @ linux-x86_64 +test.test_xml_etree.IOTest.test_read_from_user_text_reader @ linux-x86_64 +test.test_xml_etree.IOTest.test_short_empty_elements @ linux-x86_64 +test.test_xml_etree.IOTest.test_tostringlist_invariant @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_binary_file @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_binary_file_with_encoding @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_bytesio @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_filename @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_filename_as_unicode @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_filename_with_encoding @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_stringio @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_text_file @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_user_binary_writer @ linux-x86_64 +test.test_xml_etree.IOTest.test_write_to_user_text_writer @ linux-x86_64 +test.test_xml_etree.KeywordArgsTest.test_issue14818 @ linux-x86_64 +test.test_xml_etree.ModuleTest.test_all @ linux-x86_64 +test.test_xml_etree.ModuleTest.test_sanity @ linux-x86_64 +test.test_xml_etree.NamespaceParseTest.test_find_with_namespace @ linux-x86_64 +test.test_xml_etree.NoAcceleratorTest.test_correct_import_pyET @ linux-x86_64 +test.test_xml_etree.ParseErrorTest.test_error_code @ linux-x86_64 +test.test_xml_etree.ParseErrorTest.test_error_position @ linux-x86_64 +test.test_xml_etree.ParseErrorTest.test_subclass @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_builder_lookup_errors @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_doctype @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_dummy_builder @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_element_factory @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_element_factory_pure_python_subclass @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_element_factory_subclass @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_late_tail @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_late_tail_mix_pi_comments @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_subclass @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_subclass_comment_pi @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_treebuilder_comment @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_treebuilder_elementfactory_none @ linux-x86_64 +test.test_xml_etree.TreeBuilderTest.test_treebuilder_pi @ linux-x86_64 +test.test_xml_etree.XIncludeTest.test_xinclude @ linux-x86_64 +test.test_xml_etree.XIncludeTest.test_xinclude_default @ linux-x86_64 +test.test_xml_etree.XIncludeTest.test_xinclude_failures @ linux-x86_64 +test.test_xml_etree.XIncludeTest.test_xinclude_repeated @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_constructor_args @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_doctype_warning @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_inherited_doctype @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_parse_string @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_subclass @ linux-x86_64 +test.test_xml_etree.XMLParserTest.test_subclass_doctype @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_events @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_events_comment @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_events_pi @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_events_sequence @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_feed_while_iterating @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_ns_events @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_ns_events_start @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_ns_events_start_end @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_simple_xml @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_simple_xml_with_ns @ linux-x86_64 +test.test_xml_etree.XMLPullParserTest.test_unknown_event @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree_c.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree_c.txt new file mode 100644 index 0000000000..4bfbf45fa6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xml_etree_c.txt @@ -0,0 +1,181 @@ +test.test_xml_etree_c.BadElementPathTest.test_find_with_error @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_find_with_mutating @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findall_with_error @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findall_with_mutating @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findtext_with_error @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findtext_with_falsey_text_attribute @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findtext_with_mutating @ linux-x86_64 +test.test_xml_etree_c.BadElementPathTest.test_findtext_with_none_text_attribute @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_ass_subscr @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_element_get_tail @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_element_get_text @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_extend_mutable_list @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_extend_mutable_list2 @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_recursive_repr @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_remove_with_mutating @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_subscr @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_treebuilder_end @ linux-x86_64 +test.test_xml_etree_c.BadElementTest.test_treebuilder_start @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test___copy__ @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test___deepcopy__ @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test___init__ @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_augmentation_type_errors @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_copy @ linux-x86_64 +!test.test_xml_etree_c.BasicElementTest.test_cyclic_gc @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_get_keyword_args @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_pickle @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_pickle_issue18997 @ linux-x86_64 +test.test_xml_etree_c.BasicElementTest.test_weakref @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_39495_treebuilder_start @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_1534630 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200708_close @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200708_newline @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200709_default_namespace @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200709_element_comment @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200709_element_insert @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200709_iter_comment @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_200709_register_namespace @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit21 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit25 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit28 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit39 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit54 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit55 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit60 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit62 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkit63 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_bug_xmltoolkitX1 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_expat224_utf8_bug @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_expat224_utf8_bug_file @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_issue10777 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_issue6233 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_issue6565 @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_lost_tail @ linux-x86_64 +test.test_xml_etree_c.BugsTest.test_lost_text @ linux-x86_64 +test.test_xml_etree_c.C14NTest.test_c14n_exclusion @ linux-x86_64 +test.test_xml_etree_c.C14NTest.test_simple_roundtrip @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_bad_find @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_find_simple @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_find_through_ElementTree @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_find_xpath @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_findall @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_findall_different_nsmaps @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_findall_wildcard @ linux-x86_64 +test.test_xml_etree_c.ElementFindTest.test_test_find_with_ns @ linux-x86_64 +test.test_xml_etree_c.ElementIterTest.test_basic @ linux-x86_64 +test.test_xml_etree_c.ElementIterTest.test_copy @ linux-x86_64 +test.test_xml_etree_c.ElementIterTest.test_corners @ linux-x86_64 +test.test_xml_etree_c.ElementIterTest.test_iter_by_tag @ linux-x86_64 +test.test_xml_etree_c.ElementIterTest.test_pickle @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_delslice @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_getslice_negative_steps @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_getslice_range @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_getslice_single_index @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_getslice_steps @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_setslice_range @ linux-x86_64 +test.test_xml_etree_c.ElementSlicingTest.test_setslice_single_index @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_attlist_default @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_attrib @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_cdata @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_children @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_copy @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_custom_builder @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_custom_builder_only_end_ns @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_doctype_public @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_dump_attribute_order @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_entity @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_file_init @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_html_empty_elems_serialization @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_indent @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_indent_level @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_indent_space @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_indent_space_caching @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_initialize_parser_without_target @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_interface @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_issue18347 @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_iterparse @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_makeelement @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_methods @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_namespace @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_parsefile @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_parseliteral @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_path_cache @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_processinginstruction @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_qname @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_set_attribute @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_default_namespace @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_default_namespace_different_namespace @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_default_namespace_original_no_namespace @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_no_xml_declaration @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_xml_declaration @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_xml_declaration_cases @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostring_xml_declaration_unicode_encoding @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostringlist_default_namespace @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tostringlist_xml_declaration @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_tree_write_attribute_order @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_writefile @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_writestring @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTest.test_xpath_tokenizer @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTypeTest.test_Element_subclass_constructor @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTypeTest.test_Element_subclass_find @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTypeTest.test_Element_subclass_new_method @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTypeTest.test_Element_subclass_trivial @ linux-x86_64 +test.test_xml_etree_c.ElementTreeTypeTest.test_istype @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_read_from_bytesio @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_read_from_stringio @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_read_from_user_binary_reader @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_read_from_user_text_reader @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_short_empty_elements @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_tostringlist_invariant @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_binary_file @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_binary_file_with_encoding @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_bytesio @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_filename @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_filename_as_unicode @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_filename_with_encoding @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_stringio @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_text_file @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_user_binary_writer @ linux-x86_64 +test.test_xml_etree_c.IOTest.test_write_to_user_text_writer @ linux-x86_64 +test.test_xml_etree_c.KeywordArgsTest.test_issue14818 @ linux-x86_64 +test.test_xml_etree_c.ModuleTest.test_all @ linux-x86_64 +test.test_xml_etree_c.ModuleTest.test_sanity @ linux-x86_64 +test.test_xml_etree_c.NamespaceParseTest.test_find_with_namespace @ linux-x86_64 +test.test_xml_etree_c.NoAcceleratorTest.test_correct_import_pyET @ linux-x86_64 +test.test_xml_etree_c.ParseErrorTest.test_error_code @ linux-x86_64 +test.test_xml_etree_c.ParseErrorTest.test_error_position @ linux-x86_64 +test.test_xml_etree_c.ParseErrorTest.test_subclass @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_builder_lookup_errors @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_doctype @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_dummy_builder @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_element_factory @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_element_factory_pure_python_subclass @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_element_factory_subclass @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_late_tail @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_late_tail_mix_pi_comments @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_subclass @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_subclass_comment_pi @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_treebuilder_comment @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_treebuilder_elementfactory_none @ linux-x86_64 +test.test_xml_etree_c.TreeBuilderTest.test_treebuilder_pi @ linux-x86_64 +test.test_xml_etree_c.XIncludeTest.test_xinclude @ linux-x86_64 +test.test_xml_etree_c.XIncludeTest.test_xinclude_default @ linux-x86_64 +test.test_xml_etree_c.XIncludeTest.test_xinclude_failures @ linux-x86_64 +test.test_xml_etree_c.XIncludeTest.test_xinclude_repeated @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_constructor_args @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_doctype_warning @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_inherited_doctype @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_parse_string @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_subclass @ linux-x86_64 +test.test_xml_etree_c.XMLParserTest.test_subclass_doctype @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_events @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_events_comment @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_events_pi @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_events_sequence @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_feed_while_iterating @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_ns_events @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_ns_events_start @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_ns_events_start_end @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_simple_xml @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_simple_xml_with_ns @ linux-x86_64 +test.test_xml_etree_c.XMLPullParserTest.test_unknown_event @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xmlrpc.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xmlrpc.txt new file mode 100644 index 0000000000..f9b3ea5fa4 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_xmlrpc.txt @@ -0,0 +1,92 @@ +test.test_xmlrpc.BinaryTestCase.test_decode @ linux-x86_64 +test.test_xmlrpc.BinaryTestCase.test_default @ linux-x86_64 +test.test_xmlrpc.BinaryTestCase.test_string @ linux-x86_64 +test.test_xmlrpc.CGIHandlerTestCase.test_cgi_get @ linux-x86_64 +test.test_xmlrpc.CGIHandlerTestCase.test_cgi_xmlrpc_response @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_comparison @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_datetime_datetime @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_decode @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_default @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_repr @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_time @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_time_struct @ linux-x86_64 +test.test_xmlrpc.DateTimeTestCase.test_time_tuple @ linux-x86_64 +test.test_xmlrpc.FailingServerTestCase.test_basic @ linux-x86_64 +test.test_xmlrpc.FailingServerTestCase.test_fail_no_info @ linux-x86_64 +test.test_xmlrpc.FailingServerTestCase.test_fail_with_info @ linux-x86_64 +test.test_xmlrpc.FaultTestCase.test_dotted_attribute @ linux-x86_64 +test.test_xmlrpc.FaultTestCase.test_dump_fault @ linux-x86_64 +test.test_xmlrpc.FaultTestCase.test_repr @ linux-x86_64 +test.test_xmlrpc.GzipServerTestCase.test_bad_gzip_request @ linux-x86_64 +test.test_xmlrpc.GzipServerTestCase.test_gzip_request @ linux-x86_64 +test.test_xmlrpc.GzipServerTestCase.test_gzip_response @ linux-x86_64 +test.test_xmlrpc.GzipUtilTestCase.test_gzip_decode_limit @ linux-x86_64 +test.test_xmlrpc.HeadersServerTestCase.test_header @ linux-x86_64 +test.test_xmlrpc.HeadersServerTestCase.test_header_empty @ linux-x86_64 +test.test_xmlrpc.HeadersServerTestCase.test_header_items @ linux-x86_64 +test.test_xmlrpc.HeadersServerTestCase.test_header_many @ linux-x86_64 +test.test_xmlrpc.HelperTestCase.test_escape @ linux-x86_64 +test.test_xmlrpc.KeepaliveServerTestCase1.test_two @ linux-x86_64 +test.test_xmlrpc.KeepaliveServerTestCase2.test_close @ linux-x86_64 +test.test_xmlrpc.KeepaliveServerTestCase2.test_transport @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_empty_path @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_empty_path_fragment @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_empty_path_query @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_invalid_path @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path1 @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path2 @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path3 @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path_fragment @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path_query @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_path_query_fragment @ linux-x86_64 +test.test_xmlrpc.MultiPathServerTestCase.test_root_path @ linux-x86_64 +test.test_xmlrpc.ServerProxyTestCase.test_close @ linux-x86_64 +test.test_xmlrpc.ServerProxyTestCase.test_transport @ linux-x86_64 +test.test_xmlrpc.SimpleServerEncodingTestCase.test_server_encoding @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_404 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_allow_dotted_names_true @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_client_encoding @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_context_manager @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_context_manager_method_error @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_dotted_attribute @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_introspection1 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_introspection2 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_introspection3 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_introspection4 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_multicall @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_non_existing_multicall @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_nonascii @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_nonascii_methodname @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_partial_post @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_simple1 @ linux-x86_64 +test.test_xmlrpc.SimpleServerTestCase.test_unicode_host @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_call_dispatch_func @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_call_instance_func @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_call_registered_func @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_cannot_locate_func @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_instance_has_no_func @ linux-x86_64 +test.test_xmlrpc.SimpleXMLRPCDispatcherTestCase.test_registered_func_is_none @ linux-x86_64 +test.test_xmlrpc.UseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flag @ linux-x86_64 +test.test_xmlrpc.UseBuiltinTypesTestCase.test_use_builtin_types @ linux-x86_64 +test.test_xmlrpc.UseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flag @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_bug_1164912 @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_datetime_before_1900 @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_bad_dict @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_bare_datetime @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_big_int @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_big_long @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_bytes @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_double @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_encoding @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_load @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_none @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_recursive_dict @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_dump_recursive_seq @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_get_host_info @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_keepalive_disconnect @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_limit_int @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_load_extension_types @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_load_standard_types @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_loads_unsupported @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_newstyle_class @ linux-x86_64 +test.test_xmlrpc.XMLRPCTestCase.test_ssl_presence @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_yield_from.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_yield_from.txt new file mode 100644 index 0000000000..fd317e5e31 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_yield_from.txt @@ -0,0 +1,32 @@ +test.test_yield_from.TestPEP380Operation.test_attempted_yield_from_loop @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_attempting_to_send_to_non_generator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_broken_getattr_handling @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_catching_exception_from_subgen_and_returning @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_close_with_cleared_frame @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_conversion_of_sendNone_to_next @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegating_close @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegating_generators_claim_to_be_running @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegating_throw @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegating_throw_to_non_generator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegation_of_close_to_non_generator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegation_of_initial_next_to_subgenerator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegation_of_next_call_to_subgenerator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegation_of_next_to_non_generator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegation_of_send @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_delegator_is_visible_to_debugger @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_exception_in_initial_next_call @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_exception_value_crash @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_generator_return_value @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_handing_exception_while_delegating_close @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_handling_exception_while_delegating_send @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_next_and_return_with_value @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_raising_exception_in_delegated_next_call @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_raising_exception_in_initial_next_call @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_returning_value_from_delegated_throw @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_send_and_return_with_value @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_send_tuple_with_custom_generator @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_raises @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_throwing_GeneratorExit_into_subgen_that_returns @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_throwing_GeneratorExit_into_subgenerator_that_yields @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_value_attribute_of_StopIteration_exception @ linux-x86_64 +test.test_yield_from.TestPEP380Operation.test_yield_from_empty @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipapp.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipapp.txt new file mode 100644 index 0000000000..457627136f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipapp.txt @@ -0,0 +1,31 @@ +test.test_zipapp.ZipAppCmdlineTest.test_cmdline_copy @ linux-x86_64 +test.test_zipapp.ZipAppCmdlineTest.test_cmdline_copy_change_main @ linux-x86_64 +test.test_zipapp.ZipAppCmdlineTest.test_cmdline_copy_inplace @ linux-x86_64 +test.test_zipapp.ZipAppCmdlineTest.test_cmdline_create @ linux-x86_64 +test.test_zipapp.ZipAppCmdlineTest.test_info_command @ linux-x86_64 +test.test_zipapp.ZipAppCmdlineTest.test_info_error @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_content_of_copied_archive @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_default_target @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_filter_exclude_dir @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_with_compression @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_with_filter @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_with_pathlib @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_create_archive_with_subdirs @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_custom_interpreter @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_default_no_shebang @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_main_and_main_py @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_main_only_written_once @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_main_validation @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_main_written @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_modify_shebang @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_no_main @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_no_shebang_is_not_executable @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_pack_to_fileobj @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_read_from_fileobj @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_read_from_pathobj @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_read_missing_shebang @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_read_shebang @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_remove_shebang @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_shebang_is_executable @ linux-x86_64 +test.test_zipapp.ZipAppTest.test_write_shebang_to_fileobj @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile.txt new file mode 100644 index 0000000000..0b07ed155f --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile.txt @@ -0,0 +1,280 @@ +test.test_zipfile.Bzip2BadCrcTests.test_read_with_bad_crc @ linux-x86_64 +test.test_zipfile.Bzip2BadCrcTests.test_testzip_with_bad_crc @ linux-x86_64 +test.test_zipfile.Bzip2TestZip64InSmallFiles.test_basic @ linux-x86_64 +test.test_zipfile.Bzip2TestZip64InSmallFiles.test_too_many_files @ linux-x86_64 +test.test_zipfile.Bzip2TestZip64InSmallFiles.test_too_many_files_append @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithRandomBinaryFiles.test_open @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithRandomBinaryFiles.test_random_open @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithRandomBinaryFiles.test_read @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_basic @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_compresslevel_basic @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_iterlines @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_low_compression @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_open @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_open_with_pathlike @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_per_file_compresslevel @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_random_open @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_read1 @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_read1_10 @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_read_return_size @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_readline @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_readline_read @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_readlines @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_repr @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_truncated_zipfile @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_writestr_compression @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_writestr_compresslevel @ linux-x86_64 +test.test_zipfile.Bzip2TestsWithSourceFile.test_writing_errors @ linux-x86_64 +test.test_zipfile.Bzip2WriterTests.test_close_after_close @ linux-x86_64 +test.test_zipfile.Bzip2WriterTests.test_issue44439 @ linux-x86_64 +test.test_zipfile.Bzip2WriterTests.test_write_after_close @ linux-x86_64 +test.test_zipfile.CommandLineTest.test_bad_use @ linux-x86_64 +test.test_zipfile.CommandLineTest.test_create_command @ linux-x86_64 +test.test_zipfile.CommandLineTest.test_extract_command @ linux-x86_64 +test.test_zipfile.CommandLineTest.test_list_command @ linux-x86_64 +test.test_zipfile.CommandLineTest.test_test_command @ linux-x86_64 +test.test_zipfile.DecryptionTests.test_bad_password @ linux-x86_64 +test.test_zipfile.DecryptionTests.test_good_password @ linux-x86_64 +test.test_zipfile.DecryptionTests.test_no_password @ linux-x86_64 +test.test_zipfile.DecryptionTests.test_seek_tell @ linux-x86_64 +test.test_zipfile.DecryptionTests.test_unicode_password @ linux-x86_64 +test.test_zipfile.DeflateBadCrcTests.test_read_with_bad_crc @ linux-x86_64 +test.test_zipfile.DeflateBadCrcTests.test_testzip_with_bad_crc @ linux-x86_64 +test.test_zipfile.DeflateTestZip64InSmallFiles.test_basic @ linux-x86_64 +test.test_zipfile.DeflateTestZip64InSmallFiles.test_too_many_files @ linux-x86_64 +test.test_zipfile.DeflateTestZip64InSmallFiles.test_too_many_files_append @ linux-x86_64 +test.test_zipfile.DeflateTestsWithRandomBinaryFiles.test_open @ linux-x86_64 +test.test_zipfile.DeflateTestsWithRandomBinaryFiles.test_random_open @ linux-x86_64 +test.test_zipfile.DeflateTestsWithRandomBinaryFiles.test_read @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_basic @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_compresslevel_basic @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_iterlines @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_low_compression @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_open @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_open_with_pathlike @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_per_file_compression @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_per_file_compresslevel @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_random_open @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_read1 @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_read1_10 @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_read_return_size @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_readline @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_readline_read @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_readlines @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_repr @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_truncated_zipfile @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_writestr_compression @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_writestr_compresslevel @ linux-x86_64 +test.test_zipfile.DeflateTestsWithSourceFile.test_writing_errors @ linux-x86_64 +test.test_zipfile.DeflateWriterTests.test_close_after_close @ linux-x86_64 +test.test_zipfile.DeflateWriterTests.test_issue44439 @ linux-x86_64 +test.test_zipfile.DeflateWriterTests.test_write_after_close @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_cli_with_metadata_encoding @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_cli_with_metadata_encoding_extract @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_read_after_append @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_read_with_incorrect_metadata_encoding @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_read_with_metadata_encoding @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_read_with_unsuitable_metadata_encoding @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_read_without_metadata_encoding @ linux-x86_64 +test.test_zipfile.EncodedMetadataTests.test_write_with_metadata_encoding @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_all @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_all_with_target @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_all_with_target_pathlike @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_hackers_arcnames_common_cases @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_hackers_arcnames_posix_only @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_with_target @ linux-x86_64 +test.test_zipfile.ExtractTests.test_extract_with_target_pathlike @ linux-x86_64 +test.test_zipfile.ExtractTests.test_sanitize_windows_name @ linux-x86_64 +test.test_zipfile.LzmaBadCrcTests.test_read_with_bad_crc @ linux-x86_64 +test.test_zipfile.LzmaBadCrcTests.test_testzip_with_bad_crc @ linux-x86_64 +test.test_zipfile.LzmaTestZip64InSmallFiles.test_basic @ linux-x86_64 +test.test_zipfile.LzmaTestZip64InSmallFiles.test_too_many_files @ linux-x86_64 +test.test_zipfile.LzmaTestZip64InSmallFiles.test_too_many_files_append @ linux-x86_64 +test.test_zipfile.LzmaTestsWithRandomBinaryFiles.test_open @ linux-x86_64 +test.test_zipfile.LzmaTestsWithRandomBinaryFiles.test_random_open @ linux-x86_64 +test.test_zipfile.LzmaTestsWithRandomBinaryFiles.test_read @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_basic @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_compresslevel_basic @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_iterlines @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_low_compression @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_open @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_open_with_pathlike @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_per_file_compresslevel @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_random_open @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_read1 @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_read1_10 @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_read_return_size @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_readline @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_readline_read @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_readlines @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_repr @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_truncated_zipfile @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_writestr_compression @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_writestr_compresslevel @ linux-x86_64 +test.test_zipfile.LzmaTestsWithSourceFile.test_writing_errors @ linux-x86_64 +test.test_zipfile.LzmaWriterTests.test_close_after_close @ linux-x86_64 +test.test_zipfile.LzmaWriterTests.test_issue44439 @ linux-x86_64 +test.test_zipfile.LzmaWriterTests.test_write_after_close @ linux-x86_64 +test.test_zipfile.OtherTests.test_bad_compression_mode @ linux-x86_64 +test.test_zipfile.OtherTests.test_bad_constructor_mode @ linux-x86_64 +test.test_zipfile.OtherTests.test_bad_open_mode @ linux-x86_64 +test.test_zipfile.OtherTests.test_change_comment_in_empty_archive @ linux-x86_64 +test.test_zipfile.OtherTests.test_change_comment_in_nonempty_archive @ linux-x86_64 +test.test_zipfile.OtherTests.test_close @ linux-x86_64 +test.test_zipfile.OtherTests.test_close_erroneous_file @ linux-x86_64 +test.test_zipfile.OtherTests.test_close_on_exception @ linux-x86_64 +test.test_zipfile.OtherTests.test_closed_zip_raises_ValueError @ linux-x86_64 +test.test_zipfile.OtherTests.test_comments @ linux-x86_64 +test.test_zipfile.OtherTests.test_create_empty_zipinfo_default_attributes @ linux-x86_64 +test.test_zipfile.OtherTests.test_create_empty_zipinfo_repr @ linux-x86_64 +test.test_zipfile.OtherTests.test_create_non_existent_file_for_append @ linux-x86_64 +test.test_zipfile.OtherTests.test_create_zipinfo_before_1980 @ linux-x86_64 +test.test_zipfile.OtherTests.test_damaged_zipfile @ linux-x86_64 +test.test_zipfile.OtherTests.test_decompress_without_3rd_party_library @ linux-x86_64 +test.test_zipfile.OtherTests.test_empty_file_raises_BadZipFile @ linux-x86_64 +test.test_zipfile.OtherTests.test_empty_zipfile @ linux-x86_64 +test.test_zipfile.OtherTests.test_exclusive_create_zip_file @ linux-x86_64 +test.test_zipfile.OtherTests.test_is_zip_erroneous_file @ linux-x86_64 +test.test_zipfile.OtherTests.test_is_zip_valid_file @ linux-x86_64 +test.test_zipfile.OtherTests.test_negative_central_directory_offset_raises_BadZipFile @ linux-x86_64 +test.test_zipfile.OtherTests.test_non_existent_file_raises_OSError @ linux-x86_64 +test.test_zipfile.OtherTests.test_null_byte_in_filename @ linux-x86_64 +test.test_zipfile.OtherTests.test_open_conflicting_handles @ linux-x86_64 +test.test_zipfile.OtherTests.test_open_empty_file @ linux-x86_64 +test.test_zipfile.OtherTests.test_open_non_existent_item @ linux-x86_64 +test.test_zipfile.OtherTests.test_open_via_zip_info @ linux-x86_64 +test.test_zipfile.OtherTests.test_read0 @ linux-x86_64 +test.test_zipfile.OtherTests.test_read_after_write_unicode_filenames @ linux-x86_64 +test.test_zipfile.OtherTests.test_read_unicode_filenames @ linux-x86_64 +test.test_zipfile.OtherTests.test_seek_tell @ linux-x86_64 +test.test_zipfile.OtherTests.test_struct_sizes @ linux-x86_64 +test.test_zipfile.OtherTests.test_unicode_comment @ linux-x86_64 +test.test_zipfile.OtherTests.test_unsupported_compression @ linux-x86_64 +test.test_zipfile.OtherTests.test_unsupported_version @ linux-x86_64 +test.test_zipfile.OtherTests.test_write_unicode_filenames @ linux-x86_64 +test.test_zipfile.OtherTests.test_writestr_extended_local_header_issue1202 @ linux-x86_64 +test.test_zipfile.OtherTests.test_zipfile_with_short_extra_field @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_non_pyfile @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_pathlike @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_pyfile @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_pyfile_bad_syntax @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_python_directory @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_python_directory_filtered @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_python_package @ linux-x86_64 +test.test_zipfile.PyZipFileTests.test_write_with_optimization @ linux-x86_64 +test.test_zipfile.StoredBadCrcTests.test_read_with_bad_crc @ linux-x86_64 +test.test_zipfile.StoredBadCrcTests.test_testzip_with_bad_crc @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_absolute_arcnames @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_append @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_bad_zip64_extra @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_basic @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_force_zip64 @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_generated_valid_zip64_extra @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_large_file_exception @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_too_many_files @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_too_many_files_append @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_unseekable_zip_known_filesize @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_unseekable_zip_unknown_filesize @ linux-x86_64 +test.test_zipfile.StoredTestZip64InSmallFiles.test_zip64_required_not_allowed_fail @ linux-x86_64 +test.test_zipfile.StoredTestsWithRandomBinaryFiles.test_open @ linux-x86_64 +test.test_zipfile.StoredTestsWithRandomBinaryFiles.test_random_open @ linux-x86_64 +test.test_zipfile.StoredTestsWithRandomBinaryFiles.test_read @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_absolute_arcnames @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_add_file_before_1980 @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_append_to_concatenated_zip_file @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_append_to_non_zip_file @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_append_to_zip_file @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_basic @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_compresslevel_basic @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_ignores_newline_at_end @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_ignores_stuff_appended_past_comments @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_io_on_closed_zipextfile @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_iterlines @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_open @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_open_with_pathlike @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_per_file_compresslevel @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_random_open @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_read1 @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_read1_10 @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_read_concatenated_zip_file @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_read_return_size @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_readline @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_readline_read @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_readlines @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_repr @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_truncated_zipfile @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_write_default_name @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_write_to_readonly @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_writestr_compression @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_writestr_compresslevel @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_writestr_permissions @ linux-x86_64 +test.test_zipfile.StoredTestsWithSourceFile.test_writing_errors @ linux-x86_64 +test.test_zipfile.StoredWriterTests.test_close_after_close @ linux-x86_64 +test.test_zipfile.StoredWriterTests.test_issue44439 @ linux-x86_64 +test.test_zipfile.StoredWriterTests.test_write_after_close @ linux-x86_64 +test.test_zipfile.StripExtraTests.test_multiples @ linux-x86_64 +test.test_zipfile.StripExtraTests.test_no_data @ linux-x86_64 +test.test_zipfile.StripExtraTests.test_too_short @ linux-x86_64 +test.test_zipfile.StripExtraTests.test_with_data @ linux-x86_64 +test.test_zipfile.TestExecutablePrependedZip.test_read_zip64_with_exe_prepended @ linux-x86_64 +test.test_zipfile.TestExecutablePrependedZip.test_read_zip_with_exe_prepended @ linux-x86_64 +test.test_zipfile.TestPath.test_dir_parent @ linux-x86_64 +test.test_zipfile.TestPath.test_encoding_warnings @ linux-x86_64 +test.test_zipfile.TestPath.test_extract_orig_with_implied_dirs @ linux-x86_64 +test.test_zipfile.TestPath.test_filename @ linux-x86_64 +test.test_zipfile.TestPath.test_implied_dirs_performance @ linux-x86_64 +test.test_zipfile.TestPath.test_inheritance @ linux-x86_64 +test.test_zipfile.TestPath.test_is_file_missing @ linux-x86_64 +test.test_zipfile.TestPath.test_iterdir_and_types @ linux-x86_64 +test.test_zipfile.TestPath.test_iterdir_on_file @ linux-x86_64 +test.test_zipfile.TestPath.test_joinpath @ linux-x86_64 +test.test_zipfile.TestPath.test_joinpath_constant_time @ linux-x86_64 +test.test_zipfile.TestPath.test_joinpath_multiple @ linux-x86_64 +test.test_zipfile.TestPath.test_missing_dir_parent @ linux-x86_64 +test.test_zipfile.TestPath.test_mutability @ linux-x86_64 +test.test_zipfile.TestPath.test_open @ linux-x86_64 +test.test_zipfile.TestPath.test_open_binary_invalid_args @ linux-x86_64 +test.test_zipfile.TestPath.test_open_encoding_errors @ linux-x86_64 +test.test_zipfile.TestPath.test_open_encoding_utf16 @ linux-x86_64 +test.test_zipfile.TestPath.test_open_extant_directory @ linux-x86_64 +test.test_zipfile.TestPath.test_open_missing_directory @ linux-x86_64 +test.test_zipfile.TestPath.test_open_write @ linux-x86_64 +test.test_zipfile.TestPath.test_parent @ linux-x86_64 +test.test_zipfile.TestPath.test_pathlike_construction @ linux-x86_64 +test.test_zipfile.TestPath.test_read @ linux-x86_64 +test.test_zipfile.TestPath.test_read_does_not_close @ linux-x86_64 +test.test_zipfile.TestPath.test_root_name @ linux-x86_64 +test.test_zipfile.TestPath.test_root_parent @ linux-x86_64 +test.test_zipfile.TestPath.test_root_unnamed @ linux-x86_64 +test.test_zipfile.TestPath.test_stem @ linux-x86_64 +test.test_zipfile.TestPath.test_subclass @ linux-x86_64 +test.test_zipfile.TestPath.test_subdir_is_dir @ linux-x86_64 +test.test_zipfile.TestPath.test_suffix @ linux-x86_64 +test.test_zipfile.TestPath.test_suffix_no_filename @ linux-x86_64 +test.test_zipfile.TestPath.test_suffixes @ linux-x86_64 +test.test_zipfile.TestPath.test_traverse_pathlike @ linux-x86_64 +test.test_zipfile.TestPath.test_traverse_simplediv @ linux-x86_64 +test.test_zipfile.TestPath.test_traverse_truediv @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_bug_6050 @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_create_directory_with_write @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_extract_dir @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_mkdir @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_write_dir @ linux-x86_64 +test.test_zipfile.TestWithDirectory.test_writestr_dir @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_different_file @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_interleaved @ linux-x86_64 +!test.test_zipfile.TestsWithMultipleOpens.test_many_opens @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_read_after_close @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_read_after_write @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_same_file @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_write_after_read @ linux-x86_64 +test.test_zipfile.TestsWithMultipleOpens.test_write_while_reading @ linux-x86_64 +test.test_zipfile.UnseekableTests.test_open_write @ linux-x86_64 +test.test_zipfile.UnseekableTests.test_write @ linux-x86_64 +test.test_zipfile.UnseekableTests.test_writestr @ linux-x86_64 +test.test_zipfile.ZipInfoTests.test_from_dir @ linux-x86_64 +test.test_zipfile.ZipInfoTests.test_from_file @ linux-x86_64 +test.test_zipfile.ZipInfoTests.test_from_file_bytes @ linux-x86_64 +test.test_zipfile.ZipInfoTests.test_from_file_fileno @ linux-x86_64 +test.test_zipfile.ZipInfoTests.test_from_file_pathlike @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile64.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile64.txt new file mode 100644 index 0000000000..d72ab1bdab --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipfile64.txt @@ -0,0 +1,3 @@ +test.test_zipfile64.OtherTests.testMoreThan64kFiles @ linux-x86_64 +test.test_zipfile64.OtherTests.testMoreThan64kFilesAppend @ linux-x86_64 +test.test_zipfile64.TestsWithSourceFile.testDeflated @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport.txt new file mode 100644 index 0000000000..7e6f56ffc9 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport.txt @@ -0,0 +1,71 @@ +test.test_zipimport.BadFileZipImportTestCase.testBadArgs @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testEmptyFile @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testEmptyFilename @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testFileUnreadable @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testFilenameTooLong @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testNoFile @ linux-x86_64 +test.test_zipimport.BadFileZipImportTestCase.testNotZipFile @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.test2038MTime @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBadMTime @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBadMagic @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBadMagic2 @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBeginningCruftAndComment @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBoth @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testBytesPath @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testComment @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testDefaultOptimizationLevel @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testDoctestFile @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testDoctestSuite @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testEmptyPy @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testGetCompiledSource @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testGetData @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testGetSource @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testImport_WithStuff @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testImporterAttr @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testInvalidateCaches @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testLargestPossibleComment @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testMixedNamespacePackage @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testNamespacePackage @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testPackage @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testPy @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testPyc @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testSubNamespacePackage @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testSubPackage @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testTraceback @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testUncheckedHashBasedPyc @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testUnencodable @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testZipImporterMethods @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.testZipImporterMethodsInSubDirectory @ linux-x86_64 +test.test_zipimport.CompressedZipImportTestCase.test_checked_hash_based_change_pyc @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.test2038MTime @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBadMTime @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBadMagic @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBadMagic2 @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBeginningCruftAndComment @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBoth @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testBytesPath @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testComment @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testDefaultOptimizationLevel @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testDoctestFile @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testDoctestSuite @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testEmptyPy @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testGetCompiledSource @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testGetData @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testGetSource @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testImport_WithStuff @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testImporterAttr @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testInvalidateCaches @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testLargestPossibleComment @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testMixedNamespacePackage @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testNamespacePackage @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testPackage @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testPy @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testPyc @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testSubNamespacePackage @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testSubPackage @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testTraceback @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testUncheckedHashBasedPyc @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testUnencodable @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testZipImporterMethods @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.testZipImporterMethodsInSubDirectory @ linux-x86_64 +test.test_zipimport.UncompressedZipImportTestCase.test_checked_hash_based_change_pyc @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport_support.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport_support.txt new file mode 100644 index 0000000000..64b946c89a --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zipimport_support.txt @@ -0,0 +1,4 @@ +test.test_zipimport_support.ZipSupportTests.test_doctest_issue4197 @ linux-x86_64 +test.test_zipimport_support.ZipSupportTests.test_doctest_main_issue4197 @ linux-x86_64 +test.test_zipimport_support.ZipSupportTests.test_inspect_getsource_issue4223 @ linux-x86_64 +test.test_zipimport_support.ZipSupportTests.test_pdb_issue4201 @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zlib.txt new file mode 100644 index 0000000000..b3e3f2bba6 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zlib.txt @@ -0,0 +1,54 @@ +test.test_zlib.ChecksumTestCase.test_adler32empty @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_adler32start @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_crc32_adler32_unsigned @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_crc32empty @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_crc32start @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_penguins @ linux-x86_64 +test.test_zlib.ChecksumTestCase.test_same_as_binascii_crc32 @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_badcompresscopy @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_baddecompresscopy @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_big_compress_buffer @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_big_decompress_buffer @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_clear_unconsumed_tail @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_compresscopy @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_compressincremental @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_compressoptions @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompimax @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompinc @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompincflush @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompress_eof @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompress_eof_incomplete_stream @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompress_incomplete_stream @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompress_raw_with_dictionary @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompress_unused_data @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompresscopy @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompressmaxlen @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_decompressmaxlenflush @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_dictionary @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_dictionary_streaming @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_empty_flush @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_flush_custom_length @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_flush_large_length @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_flush_with_freed_input @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_flushes @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_keywords @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_maxlen_custom @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_maxlen_large @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_maxlenmisc @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_odd_flush @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_pair @ linux-x86_64 +test.test_zlib.CompressObjectTestCase.test_wbits @ linux-x86_64 +test.test_zlib.CompressTestCase.test_big_compress_buffer @ linux-x86_64 +test.test_zlib.CompressTestCase.test_big_decompress_buffer @ linux-x86_64 +test.test_zlib.CompressTestCase.test_custom_bufsize @ linux-x86_64 +test.test_zlib.CompressTestCase.test_incomplete_stream @ linux-x86_64 +test.test_zlib.CompressTestCase.test_keywords @ linux-x86_64 +test.test_zlib.CompressTestCase.test_large_bufsize @ linux-x86_64 +test.test_zlib.CompressTestCase.test_speech @ linux-x86_64 +test.test_zlib.CompressTestCase.test_speech128 @ linux-x86_64 +test.test_zlib.ExceptionTestCase.test_badargs @ linux-x86_64 +test.test_zlib.ExceptionTestCase.test_badcompressobj @ linux-x86_64 +test.test_zlib.ExceptionTestCase.test_baddecompressobj @ linux-x86_64 +test.test_zlib.ExceptionTestCase.test_badlevel @ linux-x86_64 +test.test_zlib.ExceptionTestCase.test_decompressobj_badflush @ linux-x86_64 +test.test_zlib.VersionTestCase.test_library_version @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zoneinfo.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zoneinfo.txt new file mode 100644 index 0000000000..cb2fcfcfaa --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_zoneinfo.txt @@ -0,0 +1,184 @@ +test.test_zoneinfo.test_zoneinfo.CCallingConventionTest.test_clear_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CCallingConventionTest.test_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTZStrTest.test_extreme_tzstr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTZStrTest.test_invalid_tzstr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTZStrTest.test_tzstr_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTZStrTest.test_tzstr_localized @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_available_timezones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_available_timezones_weirdzone @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_dir_contains_all @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_dir_unique @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_exclude_posixrules @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_folder_exclusions @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTestModule.test_getattr_error @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_env_variable @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_env_variable_relative_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_reset_tzpath_kwarg @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_reset_tzpath_relative_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_tzpath_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CTzPathTest.test_tzpath_type_error @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_empty_zone @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_fixed_offset_phantom_transition @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_no_tz_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_one_transition @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_one_zone_dst @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_tz_before_only @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CWeirdZoneTest.test_zone_very_large_timestamp @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_cache_reset_tzpath @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_clear_cache_explicit_none @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_clear_cache_one_key @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_clear_cache_two_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_ephemeral_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_no_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoCacheTest.test_strong_refs @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_fold_mutate @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoDatetimeSubclassTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoPickleTest.test_cache_hit @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoPickleTest.test_cache_miss @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoPickleTest.test_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoPickleTest.test_no_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoPickleTest.test_pickle_after_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_subclass_own_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoSubclassTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_fold_mutate @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CZoneInfoV1Test.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CallingConventionTest.test_clear_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.CallingConventionTest.test_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TZStrTest.test_extreme_tzstr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TZStrTest.test_invalid_tzstr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TZStrTest.test_tzstr_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TZStrTest.test_tzstr_localized @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_available_timezones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_available_timezones_weirdzone @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_dir_contains_all @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_dir_unique @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_exclude_posixrules @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_folder_exclusions @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TestModule.test_getattr_error @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_env_variable @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_env_variable_relative_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_reset_tzpath_kwarg @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_reset_tzpath_relative_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_tzpath_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.TzPathTest.test_tzpath_type_error @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_empty_zone @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_fixed_offset_phantom_transition @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_no_tz_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_one_transition @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_one_zone_dst @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_tz_before_only @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.WeirdZoneTest.test_zone_very_large_timestamp @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_cache_reset_tzpath @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_clear_cache_explicit_none @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_clear_cache_one_key @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_clear_cache_two_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_ephemeral_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_no_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoCacheTest.test_strong_refs @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoDatetimeSubclassTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoPickleTest.test_cache_hit @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoPickleTest.test_cache_miss @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoPickleTest.test_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoPickleTest.test_no_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoPickleTest.test_pickle_after_from_file @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_subclass_own_cache @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoSubclassTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoTest.test_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_bad_keys @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_bad_keys_paths @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_bad_zones @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_folds_and_gaps @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_folds_from_utc @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_fromutc_errors @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_key_attribute @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_repr @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_str @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_time_fixed_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_time_variable_offset @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_unambiguous @ linux-x86_64 +test.test_zoneinfo.test_zoneinfo.ZoneInfoV1Test.test_utc @ linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/todo.sh b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/todo.sh new file mode 100755 index 0000000000..264b146ad3 --- /dev/null +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/todo.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (c) 2025, 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. + +# Lists all the amd64-linux tags that are in the baseline tagged files +# and not here, i.e., the TODO list for Bytecode DSL interpreter + +parent_dir=$(dirname "$(readlink -f "$0")") +parent2_dir=$(dirname "$parent_dir") +baseline_dir="$parent2_dir/unittest_tags/" + +for path in $(ls $parent_dir/*.txt); do + f=$(basename "$path") + comm -3 <(grep 'linux-x86_64' $baseline_dir/$f | egrep -v '^(#|!)' | sed 's/@.*//' | sort) <(egrep -v '^(#|!)' $f | sed 's/@.*//' | sort) +done + +for path in $(ls $baseline_dir/*.txt); do + f=$(basename "$path") + if [ ! -f "$parent_dir/$f" ]; then + echo "COMPLETE SUITE: $f" + fi +done diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java index a3a7b84406..03b283009f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java @@ -75,12 +75,16 @@ import com.oracle.graal.python.builtins.objects.type.PythonManagedClass; import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.compiler.CompilationUnit; import com.oracle.graal.python.compiler.Compiler; import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback; +import com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompiler; +import com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompiler.BytecodeDSLCompilerResult; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.call.GenericInvokeNode; import com.oracle.graal.python.nodes.exception.TopLevelExceptionHandler; @@ -587,7 +591,18 @@ protected CallTarget parse(ParsingRequest request) { if (internal && !source.isInternal()) { source = Source.newBuilder(source).internal(true).build(); } - PBytecodeRootNode rootNode = PBytecodeRootNode.create(this, code, source); + RootNode rootNode = null; + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (source.hasBytes()) { + // Force a character-based source so that source sections work as expected. + source = Source.newBuilder(source).content(Source.CONTENT_NONE).build(); + } + rootNode = ((BytecodeDSLCodeUnit) code).createRootNode(context, source); + } else { + rootNode = PBytecodeRootNode.create(this, (BytecodeCodeUnit) code, source); + } + return PythonUtils.getOrCreateCallTarget(rootNode); } @@ -632,7 +647,7 @@ public RootCallTarget parse(PythonContext context, Source source, InputType type Parser parser = Compiler.createParser(source.getCharacters().toString(), errorCb, type, interactiveTerminal); ModTy mod = (ModTy) parser.parse(); assert mod != null; - return compileForBytecodeInterpreter(context, mod, source, topLevel, optimize, argumentNames, errorCb, futureFeatures); + return compileModule(context, mod, source, topLevel, optimize, argumentNames, errorCb, futureFeatures); } catch (PException e) { if (topLevel) { PythonUtils.getOrCreateCallTarget(new TopLevelExceptionHandler(this, e)).call(); @@ -642,20 +657,19 @@ public RootCallTarget parse(PythonContext context, Source source, InputType type } @TruffleBoundary - public RootCallTarget compileForBytecodeInterpreter(PythonContext context, ModTy mod, Source source, boolean topLevel, int optimize, List argumentNames, + public RootCallTarget compileModule(PythonContext context, ModTy modIn, Source source, boolean topLevel, int optimize, List argumentNames, RaisePythonExceptionErrorCallback errorCallback, int flags) { - return compileForBytecodeInterpreter(context, mod, source, topLevel, optimize, argumentNames, errorCallback, FutureFeature.fromFlags(flags)); + return compileModule(context, modIn, source, topLevel, optimize, argumentNames, errorCallback, FutureFeature.fromFlags(flags)); } @TruffleBoundary - public RootCallTarget compileForBytecodeInterpreter(PythonContext context, ModTy modIn, Source source, boolean topLevel, int optimize, List argumentNames, + public RootCallTarget compileModule(PythonContext context, ModTy modIn, Source source, boolean topLevel, int optimize, List argumentNames, RaisePythonExceptionErrorCallback errorCallback, EnumSet futureFeatures) { RaisePythonExceptionErrorCallback errorCb = errorCallback; if (errorCb == null) { errorCb = new RaisePythonExceptionErrorCallback(source, PythonOptions.isPExceptionWithJavaStacktrace(this)); } try { - Compiler compiler = new Compiler(errorCb); boolean hasArguments = argumentNames != null && !argumentNames.isEmpty(); final ModTy mod; if (hasArguments) { @@ -663,9 +677,14 @@ public RootCallTarget compileForBytecodeInterpreter(PythonContext context, ModTy } else { mod = modIn; } - CompilationUnit cu = compiler.compile(mod, EnumSet.noneOf(Compiler.Flags.class), optimize, futureFeatures); - CodeUnit co = cu.assemble(); - RootNode rootNode = PBytecodeRootNode.create(this, co, source, errorCb); + + RootNode rootNode; + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + rootNode = compileForBytecodeDSLInterpreter(context, mod, source, optimize, errorCb, futureFeatures); + } else { + rootNode = compileForBytecodeInterpreter(mod, source, optimize, errorCb, futureFeatures); + } + if (topLevel) { GilNode gil = GilNode.getUncached(); boolean wasAcquired = gil.acquire(context, rootNode); @@ -690,6 +709,19 @@ public RootCallTarget compileForBytecodeInterpreter(PythonContext context, ModTy } } + private RootNode compileForBytecodeInterpreter(ModTy mod, Source source, int optimize, RaisePythonExceptionErrorCallback errorCallback, EnumSet futureFeatures) { + Compiler compiler = new Compiler(errorCallback); + CompilationUnit cu = compiler.compile(mod, EnumSet.noneOf(Compiler.Flags.class), optimize, futureFeatures); + BytecodeCodeUnit co = cu.assemble(); + return PBytecodeRootNode.create(this, co, source, errorCallback); + } + + private RootNode compileForBytecodeDSLInterpreter(PythonContext context, ModTy mod, Source source, int optimize, + RaisePythonExceptionErrorCallback errorCallback, EnumSet futureFeatures) { + BytecodeDSLCompilerResult result = BytecodeDSLCompiler.compile(this, context, mod, source, optimize, errorCallback, futureFeatures); + return result.rootNode(); + } + private static ModTy transformASTForExecutionWithArguments(List argumentNames, ModTy mod) { NodeFactory nodeFactory = new NodeFactory(); ArgTy[] astArgArray = new ArgTy[argumentNames.size()]; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java index 3bd453bf7b..a1d2a2fe4a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java @@ -219,6 +219,7 @@ import com.oracle.graal.python.nodes.builtins.ListNodes.ConstructListNode; import com.oracle.graal.python.nodes.bytecode.GetAIterNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.call.CallDispatchNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.call.GenericInvokeNode; @@ -274,6 +275,7 @@ import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.TruffleLanguage.Env; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.debug.Debugger; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -1153,7 +1155,7 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri if (AstModuleBuiltins.isAst(context, wSource)) { ModTy mod = AstModuleBuiltins.obj2sst(inliningTarget, context, wSource, getParserInputType(mode, flags)); Source source = PythonUtils.createFakeSource(filename); - RootCallTarget rootCallTarget = context.getLanguage(inliningTarget).compileForBytecodeInterpreter(context, mod, source, false, optimize, null, null, flags); + RootCallTarget rootCallTarget = context.getLanguage(inliningTarget).compileModule(context, mod, source, false, optimize, null, null, flags); return wrapRootCallTarget(rootCallTarget); } TruffleString source = sourceAsString(frame, inliningTarget, wSource, filename, interopLib, acquireLib, bufferLib, handleDecodingErrorNode, asStrNode, switchEncodingNode, @@ -1164,8 +1166,12 @@ Object generic(VirtualFrame frame, Object wSource, Object wFilename, TruffleStri private static PCode wrapRootCallTarget(RootCallTarget rootCallTarget) { RootNode rootNode = rootCallTarget.getRootNode(); - if (rootNode instanceof PBytecodeRootNode) { - ((PBytecodeRootNode) rootNode).triggerDeferredDeprecationWarnings(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLRootNode bytecodeDSLRootNode) { + bytecodeDSLRootNode.triggerDeferredDeprecationWarnings(); + } + } else if (rootNode instanceof PBytecodeRootNode bytecodeRootNode) { + bytecodeRootNode.triggerDeferredDeprecationWarnings(); } return PFactory.createCode(PythonLanguage.get(null), rootCallTarget); } @@ -1926,6 +1932,7 @@ static Object repr(VirtualFrame frame, Object obj, // format(object, [format_spec]) @Builtin(name = J_FORMAT, minNumOfPositionalArgs = 1, parameterNames = {"object", "format_spec"}) @GenerateNodeFactory + @OperationProxy.Proxyable @ImportStatic(PGuards.class) public abstract static class FormatNode extends PythonBinaryBuiltinNode { 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 3c642d4a09..97a4d50576 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 @@ -143,6 +143,7 @@ import com.oracle.graal.python.nodes.arrow.ArrowSchema; import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.classes.IsSubtypeNode; import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; @@ -224,6 +225,7 @@ protected List> getNodeFa public void initialize(Python3Core core) { super.initialize(core); addBuiltinConstant("is_native", TruffleOptions.AOT); + addBuiltinConstant("is_bytecode_dsl_interpreter", PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER); PythonContext ctx = core.getContext(); TruffleString encodingOpt = ctx.getLanguage().getEngineOption(PythonOptions.StandardStreamEncoding); TruffleString standardStreamEncoding = null; @@ -559,8 +561,12 @@ public Object doIt(VirtualFrame frame, PFunction func, @TruffleBoundary public synchronized PFunction convertToBuiltin(PFunction func) { RootNode rootNode = CodeNodes.GetCodeRootNode.executeUncached(func.getCode()); - if (rootNode instanceof PBytecodeRootNode) { - ((PBytecodeRootNode) rootNode).setPythonInternal(true); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLRootNode r) { + r.setPythonInternal(true); + } + } else if (rootNode instanceof PBytecodeRootNode r) { + r.setPythonInternal(true); } func.setBuiltin(true); return func; @@ -575,8 +581,12 @@ public Object doIt(PFunction func, @Bind("this") Node inliningTarget, @Cached CodeNodes.GetCodeRootNode getRootNode) { RootNode rootNode = getRootNode.execute(inliningTarget, func.getCode()); - if (rootNode instanceof PBytecodeRootNode) { - ((PBytecodeRootNode) rootNode).setPythonInternal(true); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLRootNode r) { + r.setPythonInternal(true); + } + } else if (rootNode instanceof PBytecodeRootNode r) { + r.setPythonInternal(true); } return func; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java index 05159ee07e..646f9e5f82 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java @@ -35,6 +35,11 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; @@ -43,6 +48,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.function.Supplier; import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.annotations.ArgumentClinic; @@ -74,13 +80,16 @@ import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.GetInternalObjectArrayNode; import com.oracle.graal.python.builtins.objects.complex.PComplex; import com.oracle.graal.python.builtins.objects.dict.PDict; +import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis; import com.oracle.graal.python.builtins.objects.floats.PFloat; +import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.ints.PInt; import com.oracle.graal.python.builtins.objects.set.PBaseSet; import com.oracle.graal.python.builtins.objects.str.PString; import com.oracle.graal.python.builtins.objects.str.StringNodes; import com.oracle.graal.python.builtins.objects.str.StringNodes.IsInternedStringNode; import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.compiler.Compiler; import com.oracle.graal.python.lib.PyComplexCheckExactNode; @@ -96,6 +105,9 @@ import com.oracle.graal.python.lib.PyUnicodeCheckExactNode; import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen; import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.PythonBuiltinNode; @@ -106,6 +118,7 @@ import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; @@ -113,6 +126,11 @@ import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.bytecode.BytecodeConfig; +import com.oracle.truffle.api.bytecode.BytecodeRootNodes; +import com.oracle.truffle.api.bytecode.serialization.BytecodeDeserializer; +import com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer; +import com.oracle.truffle.api.bytecode.serialization.SerializationUtils; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateNodeFactory; @@ -123,13 +141,14 @@ import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.memory.ByteArraySupport; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.InternalByteArray; import com.oracle.truffle.api.strings.TruffleString; import com.oracle.truffle.api.strings.TruffleString.Encoding; @CoreFunctions(defineModule = "marshal") public final class MarshalModuleBuiltins extends PythonBuiltins { - static final int CURRENT_VERSION = 4; + static final int CURRENT_VERSION = 5; @Override protected List> getNodeFactories() { @@ -302,6 +321,10 @@ static final class Marshal { private static final char TYPE_GRAALPYTHON_CODE_UNIT = 'U'; private static final char TYPE_BIG_INTEGER = 'B'; private static final char TYPE_ARRAY = ']'; + // These are constants that show up in the Bytecode DSL interpreter. + private static final char TYPE_GRAALPYTHON_DSL_CODE_UNIT = 'D'; + private static final char TYPE_DSL_SOURCE = '$'; + private static final char TYPE_DSL_EMPTY_KEYWORDS = 'k'; private static final char ARRAY_TYPE_OBJECT = 'o'; private static final char ARRAY_TYPE_INT = 'i'; @@ -353,7 +376,7 @@ public final Throwable fillInStackTrace() { static byte[] dump(PythonContext context, Object value, int version) throws IOException, MarshalError { Marshal outMarshal = new Marshal(context, version, context.getTrue(), context.getFalse()); outMarshal.writeObject(value); - return outMarshal.out.toByteArray(); + return outMarshal.outData.toByteArray(); } @TruffleBoundary @@ -425,8 +448,9 @@ public int read(byte[] b, int off, int len) { private final PythonContext context; final HashMap refMap; final ArrayList refList; - final ByteArrayOutputStream out; - final InputStream in; + final ByteArrayOutputStream outData; + final DataOutput out; + final DataInput in; final int version; final PInt pyTrue; final PInt pyFalse; @@ -434,36 +458,54 @@ public int read(byte[] b, int off, int len) { final ByteArraySupport baSupport = ByteArraySupport.littleEndian(); byte[] buffer = new byte[Long.BYTES]; int depth = 0; + /* + * A DSL node needs access to its Source during deserialization, but we do not wish to + * actually encode it in the serialized representation. Instead, we supply a Source to the + * Marshal object and return it when the source is needed. + */ + Source source = null; Marshal(PythonContext context, int version, PInt pyTrue, PInt pyFalse) { this.context = context; this.version = version; this.pyTrue = pyTrue; this.pyFalse = pyFalse; - this.out = new ByteArrayOutputStream(); + this.outData = new ByteArrayOutputStream(); + this.out = new DataOutputStream(outData); this.refMap = new HashMap<>(); this.in = null; this.refList = null; } - Marshal(PythonContext context, byte[] in, int length) { + Marshal(PythonContext context, int version, PInt pyTrue, PInt pyFalse, DataOutput out) { this.context = context; - this.in = new ByteArrayInputStream(in, 0, length); - this.refList = new ArrayList<>(); - this.version = -1; - this.pyTrue = null; - this.pyFalse = null; - this.out = null; - this.refMap = null; + this.version = version; + this.pyTrue = pyTrue; + this.pyFalse = pyFalse; + this.outData = null; + this.out = out; + this.refMap = new HashMap<>(); + this.in = null; + this.refList = null; + } + + Marshal(PythonContext context, byte[] in, int length) { + this(context, new DataInputStream(new ByteArrayInputStream(in, 0, length)), null); } Marshal(PythonContext context, Object in) { + this(context, new DataInputStream(new FileLikeInputStream(in)), null); + } + + Marshal(PythonContext context, DataInput in, Source source) { this.context = context; - this.in = new FileLikeInputStream(in); + this.in = in; + this.source = source; this.refList = new ArrayList<>(); this.version = -1; this.pyTrue = null; this.pyFalse = null; + this.outData = null; this.out = null; this.refMap = null; } @@ -473,18 +515,31 @@ private PythonLanguage getLanguage() { } private void writeByte(int v) { - out.write(v); + try { + out.write(v); + } catch (IOException e) { + // The underlying output streams we use should not throw IOExceptions. + throw CompilerDirectives.shouldNotReachHere(); + } } - private int readByte() { - int nextByte; + private void writeBytes(byte[] b, int off, int len) { try { - nextByte = in.read(); + out.write(b, off, len); } catch (IOException e) { + // The underlying output streams we use should not throw IOExceptions. throw CompilerDirectives.shouldNotReachHere(); } - if (nextByte < 0) { + } + + private int readByte() { + int nextByte; + try { + nextByte = in.readUnsignedByte(); + } catch (EOFException e) { throw new MarshalError(PythonBuiltinClassType.EOFError, ErrorMessages.BAD_MARSHAL_DATA_EOF); + } catch (IOException e) { + throw CompilerDirectives.shouldNotReachHere(); } return nextByte; } @@ -528,15 +583,13 @@ private byte[] readNBytes(int sz, byte[] output) { if (sz == 0) { return output; } - int read; try { - read = in.read(output, 0, sz); + in.readFully(output, 0, sz); + } catch (EOFException e) { + throw new MarshalError(PythonBuiltinClassType.EOFError, ErrorMessages.BAD_MARSHAL_DATA_EOF); } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(); } - if (read < sz) { - throw new MarshalError(PythonBuiltinClassType.EOFError, ErrorMessages.BAD_MARSHAL_DATA_EOF); - } return output; } @@ -547,13 +600,13 @@ private byte[] readBytes() { private void writeInt(int v) { for (int i = 0; i < Integer.SIZE; i += Byte.SIZE) { - out.write((v >> i) & 0xff); + writeByte((v >> i) & 0xff); } } private void writeShort(short v) { for (int i = 0; i < Short.SIZE; i += Byte.SIZE) { - out.write((v >> i) & 0xff); + writeByte((v >> i) & 0xff); } } @@ -567,7 +620,7 @@ private short readShort() { private void writeLong(long v) { for (int i = 0; i < Long.SIZE; i += Byte.SIZE) { - out.write((int) ((v >>> i) & 0xff)); + writeByte((int) ((v >>> i) & 0xff)); } } @@ -593,7 +646,7 @@ private void writeBigInteger(BigInteger v) { } for (int digit : digits) { for (int i = 0; i < Short.SIZE; i += Byte.SIZE) { - out.write((digit >> i) & 0xff); + writeByte((digit >> i) & 0xff); } } } @@ -688,7 +741,7 @@ private void writeObject(Object v) throws IOException { writeByte(TYPE_NOVALUE); } else if (IsSameTypeNode.executeUncached(v, PythonBuiltinClassType.StopIteration)) { writeByte(TYPE_STOPITER); - } else if (IsSameTypeNode.executeUncached(v, PythonBuiltinClassType.PEllipsis)) { + } else if (v == PEllipsis.INSTANCE) { writeByte(TYPE_ELLIPSIS); } else if (v == Boolean.TRUE || v == pyTrue) { writeByte(TYPE_TRUE); @@ -837,6 +890,9 @@ private void writeComplexObject(Object v, int flag) { writeByte(TYPE_ARRAY | flag); writeByte(ARRAY_TYPE_STRING); writeStringArray((TruffleString[]) v); + } else if (v instanceof PKeyword[]) { + assert v == PKeyword.EMPTY_KEYWORDS; + writeByte(TYPE_DSL_EMPTY_KEYWORDS); } else if (v instanceof Object[]) { writeByte(TYPE_ARRAY | flag); writeByte(ARRAY_TYPE_OBJECT); @@ -856,8 +912,16 @@ private void writeComplexObject(Object v, int flag) { } writeBytes(lnotab); } else if (v instanceof CodeUnit) { - writeByte(TYPE_GRAALPYTHON_CODE_UNIT | flag); - writeCodeUnit((CodeUnit) v); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + writeByte(TYPE_GRAALPYTHON_DSL_CODE_UNIT | flag); + writeBytecodeDSLCodeUnit((BytecodeDSLCodeUnit) v); + } else { + writeByte(TYPE_GRAALPYTHON_CODE_UNIT | flag); + writeBytecodeCodeUnit((BytecodeCodeUnit) v); + } + } else if (v instanceof Source s) { + writeByte(TYPE_DSL_SOURCE | flag); + setSource(s); } else { PythonBufferAcquireLibrary acquireLib = PythonBufferAcquireLibrary.getFactory().getUncached(v); if (acquireLib.hasBuffer(v)) { @@ -978,7 +1042,7 @@ private Object readObject(int type, AddRefAndReturn addRef) throws NumberFormatE case TYPE_STOPITER: return PythonBuiltinClassType.StopIteration; case TYPE_ELLIPSIS: - return PythonBuiltinClassType.PEllipsis; + return PEllipsis.INSTANCE; case TYPE_FALSE: return false; case TYPE_TRUE: @@ -1070,10 +1134,15 @@ private Object readObject(int type, AddRefAndReturn addRef) throws NumberFormatE case TYPE_GRAALPYTHON_CODE: return addRef.run(readCode()); case TYPE_GRAALPYTHON_CODE_UNIT: - return addRef.run(readCodeUnit()); - case TYPE_ARRAY: { + return addRef.run(readBytecodeCodeUnit()); + case TYPE_GRAALPYTHON_DSL_CODE_UNIT: + return addRef.run(readBytecodeDSLCodeUnit()); + case TYPE_DSL_SOURCE: + return getSource(); + case TYPE_DSL_EMPTY_KEYWORDS: + return PKeyword.EMPTY_KEYWORDS; + case TYPE_ARRAY: return addRef.run(readJavaArray()); - } default: throw new MarshalError(ValueError, ErrorMessages.BAD_MARSHAL_DATA); } @@ -1093,7 +1162,7 @@ private void writeString(TruffleString v) { } InternalByteArray ba = v.switchEncodingUncached(encoding).getInternalByteArrayUncached(encoding); writeSize(ba.getLength()); - out.write(ba.getArray(), ba.getOffset(), ba.getLength()); + writeBytes(ba.getArray(), ba.getOffset(), ba.getLength()); } private TruffleString readString() { @@ -1226,6 +1295,24 @@ private Object[] readObjectArray() { return a; } + private void setSource(Source s) { + if (source == null) { + source = s; + } else if (source != s) { + throw CompilerDirectives.shouldNotReachHere("attempted to serialize with multiple Source objects"); + } + } + + private Source getSource() { + if (source != null) { + return source; + } else { + // This should never happen when deserializing a bytecode DSL code unit, but could + // happen if the user tries to deserialize arbitrary bytes. + throw new MarshalError(ValueError, ErrorMessages.BAD_MARSHAL_DATA); + } + } + private void writeSparseTable(int[][] table) { writeInt(table.length); for (int i = 0; i < table.length; i++) { @@ -1250,6 +1337,21 @@ private int[][] readSparseTable() { } private CodeUnit readCodeUnit() { + int codeUnitType = readByte(); + return switch (codeUnitType) { + case TYPE_GRAALPYTHON_CODE_UNIT -> readBytecodeCodeUnit(); + case TYPE_GRAALPYTHON_DSL_CODE_UNIT -> readBytecodeDSLCodeUnit(); + default -> throw CompilerDirectives.shouldNotReachHere(); + }; + } + + private BytecodeCodeUnit readBytecodeCodeUnit() { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + throw new MarshalError(ValueError, + PythonUtils.tsLiteral( + "Attempted to deserialize a code object from the manual bytecode interpreter, but the DSL interpreter is enabled. Consider clearing or setting a different pycache folder.")); + } + int fileVersion = readByte(); if (fileVersion != Compiler.BYTECODE_VERSION) { throw new MarshalError(ValueError, ErrorMessages.BYTECODE_VERSION_MISMATCH, Compiler.BYTECODE_VERSION, fileVersion); @@ -1283,13 +1385,57 @@ private CodeUnit readCodeUnit() { byte[] variableShouldUnbox = readBytes(); int[][] generalizeInputsMap = readSparseTable(); int[][] generalizeVarsMap = readSparseTable(); - return new CodeUnit(name, qualname, argCount, kwOnlyArgCount, positionalOnlyArgCount, stacksize, code, srcOffsetTable, - flags, names, varnames, cellvars, freevars, cell2arg, constants, primitiveConstants, exceptionHandlerRanges, conditionProfileCount, - startLine, startColumn, endLine, endColumn, + return new BytecodeCodeUnit(name, qualname, argCount, kwOnlyArgCount, positionalOnlyArgCount, flags, names, varnames, + cellvars, freevars, cell2arg, constants, startLine, startColumn, endLine, endColumn, code, srcOffsetTable, + primitiveConstants, exceptionHandlerRanges, stacksize, conditionProfileCount, outputCanQuicken, variableShouldUnbox, generalizeInputsMap, generalizeVarsMap); } + private BytecodeDSLCodeUnit readBytecodeDSLCodeUnit() { + if (!PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + throw new MarshalError(ValueError, + PythonUtils.tsLiteral( + "Attempted to deserialize a code object from the Bytecode DSL interpreter, but the manual interpreter is enabled. Consider clearing or setting a different pycache folder.")); + } + + byte[] serialized = readBytes(); + TruffleString name = readString(); + TruffleString qualname = readString(); + int argCount = readInt(); + int kwOnlyArgCount = readInt(); + int positionalOnlyArgCount = readInt(); + int flags = readInt(); + TruffleString[] names = readStringArray(); + TruffleString[] varnames = readStringArray(); + TruffleString[] cellvars = readStringArray(); + TruffleString[] freevars = readStringArray(); + int[] cell2arg = readIntArray(); + if (cell2arg.length == 0) { + cell2arg = null; + } + Object[] constants = readObjectArray(); + int startLine = readInt(); + int startColumn = readInt(); + int endLine = readInt(); + int endColumn = readInt(); + int classcellIndex = readInt(); + int selfIndex = readInt(); + + return new BytecodeDSLCodeUnit(name, qualname, argCount, kwOnlyArgCount, positionalOnlyArgCount, flags, names, varnames, cellvars, freevars, cell2arg, constants, + startLine, startColumn, endLine, endColumn, classcellIndex, selfIndex, serialized, null); + } + private void writeCodeUnit(CodeUnit code) throws IOException { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + writeByte(TYPE_GRAALPYTHON_DSL_CODE_UNIT); + writeBytecodeDSLCodeUnit((BytecodeDSLCodeUnit) code); + } else { + writeByte(TYPE_GRAALPYTHON_CODE_UNIT); + writeBytecodeCodeUnit((BytecodeCodeUnit) code); + } + } + + private void writeBytecodeCodeUnit(BytecodeCodeUnit code) throws IOException { writeByte(Compiler.BYTECODE_VERSION); writeString(code.name); writeString(code.qualname); @@ -1323,6 +1469,34 @@ private void writeCodeUnit(CodeUnit code) throws IOException { writeSparseTable(code.generalizeVarsMap); } + @SuppressWarnings("unchecked") + private void writeBytecodeDSLCodeUnit(BytecodeDSLCodeUnit code) throws IOException { + byte[] serialized = code.getSerialized(context); + writeBytes(serialized); + writeString(code.name); + writeString(code.qualname); + writeInt(code.argCount); + writeInt(code.kwOnlyArgCount); + writeInt(code.positionalOnlyArgCount); + writeInt(code.flags); + writeStringArray(code.names); + writeStringArray(code.varnames); + writeStringArray(code.cellvars); + writeStringArray(code.freevars); + if (code.cell2arg != null) { + writeIntArray(code.cell2arg); + } else { + writeIntArray(PythonUtils.EMPTY_INT_ARRAY); + } + writeObjectArray(code.constants); + writeInt(code.startLine); + writeInt(code.startColumn); + writeInt(code.endLine); + writeInt(code.endColumn); + writeInt(code.classcellIndex); + writeInt(code.selfIndex); + } + private PCode readCode() { TruffleString fileName = readString(); int flags = readInt(); @@ -1330,7 +1504,7 @@ private PCode readCode() { int codeLen = readSize(); byte[] codeString = new byte[codeLen + Long.BYTES]; try { - in.read(codeString, 0, codeLen); + in.readFully(codeString, 0, codeLen); } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(); } @@ -1349,7 +1523,7 @@ public static byte[] serializeCodeUnit(Node node, PythonContext context, CodeUni try { Marshal marshal = new Marshal(context, CURRENT_VERSION, null, null); marshal.writeCodeUnit(code); - return marshal.out.toByteArray(); + return marshal.outData.toByteArray(); } catch (IOException e) { throw CompilerDirectives.shouldNotReachHere(e); } catch (Marshal.MarshalError me) { @@ -1368,4 +1542,48 @@ public static CodeUnit deserializeCodeUnit(Node node, PythonContext context, byt throw PRaiseNode.raiseStatic(node, ValueError, ErrorMessages.BAD_MARSHAL_DATA_S, e.getMessage()); } } + + public static BytecodeRootNodes deserializeBytecodeNodes(PythonContext context, Source source, byte[] serialized) { + try { + Supplier supplier = () -> SerializationUtils.createDataInput(ByteBuffer.wrap(serialized)); + return PBytecodeDSLRootNodeGen.deserialize(context.getLanguage(), BytecodeConfig.WITH_SOURCE, supplier, new MarshalModuleBuiltins.PBytecodeDSLDeserializer(context, source)); + } catch (IOException e) { + throw CompilerDirectives.shouldNotReachHere("Deserialization error."); + } + } + + public static class PBytecodeDSLSerializer implements BytecodeSerializer { + private final PythonContext pythonContext; + + public PBytecodeDSLSerializer(PythonContext context) { + this.pythonContext = context; + } + + public void serialize(SerializerContext context, DataOutput buffer, Object object) throws IOException { + /* + * NB: Since the deserializer uses a fresh Marshal instance for each object (see below) + * we must also do the same here. Otherwise, the encoding may be different (e.g., a + * reference for an already-emitted object). + */ + new Marshal(pythonContext, CURRENT_VERSION, pythonContext.getTrue(), pythonContext.getFalse(), buffer).writeObject(object); + } + } + + public static class PBytecodeDSLDeserializer implements BytecodeDeserializer { + private final PythonContext pythonContext; + final Source source; + + public PBytecodeDSLDeserializer(PythonContext context, Source source) { + this.pythonContext = context; + this.source = source; + } + + public Object deserialize(DeserializerContext context, DataInput buffer) throws IOException { + /* + * NB: Since a DSL node may reparse multiple times, we cannot reuse a common Marshal + * object across calls (each call may take a different buffer). + */ + return new Marshal(pythonContext, buffer, source).readObject(); + } + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCodeBuiltins.java index 4c53354244..cd67388846 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextCodeBuiltins.java @@ -117,7 +117,7 @@ static int addr2line(PCode code, int lasti) { if (lasti < 0) { return code.co_firstlineno(); } - return code.bciToLine(code.lastiToBci(lasti)); + return code.lastiToLine(lasti); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java index e9f55c5a12..ddd7993c76 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/GetAwaitableNode.java @@ -49,6 +49,7 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -60,6 +61,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateUncached +@OperationProxy.Proxyable @SuppressWarnings("truffle-inlining") public abstract class GetAwaitableNode extends Node { public abstract Object execute(VirtualFrame frame, Object arg); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/PAsyncGen.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/PAsyncGen.java index bfeca4b659..b10e377209 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/PAsyncGen.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/asyncio/PAsyncGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, 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 @@ -58,7 +58,7 @@ public static PAsyncGen create(PythonLanguage lang, TruffleString name, TruffleS } private PAsyncGen(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { - super(lang, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PAsyncGenerator, false); + super(lang, name, qualname, arguments, PythonBuiltinClassType.PAsyncGenerator, false, new BytecodeState(rootNode, callTargets)); } public boolean isClosed() { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java index 46483e89b9..b426a403b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java @@ -58,6 +58,7 @@ import com.oracle.graal.python.builtins.objects.type.TpSlots; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotHashFun.HashBuiltinNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotRichCompare.RichCmpBuiltinNode; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.compiler.SourceMap; @@ -67,15 +68,20 @@ import com.oracle.graal.python.nodes.ErrorMessages; import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.runtime.IndirectCallData; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.bytecode.BytecodeNode; +import com.oracle.truffle.api.bytecode.Instruction; +import com.oracle.truffle.api.bytecode.SourceInformationTree; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -85,6 +91,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; @CoreFunctions(extendClasses = PythonBuiltinClassType.PCode) @@ -371,26 +378,107 @@ static Object lines(PCode self) { PTuple tuple; CodeUnit co = self.getCodeUnit(); if (co != null) { - SourceMap map = co.getSourceMap(); - List lines = new ArrayList<>(); - if (map != null && map.startLineMap.length > 0) { - IteratorData data = new IteratorData(); - data.line = map.startLineMap[0]; - co.iterateBytecode((int bci, OpCodes op, int oparg, byte[] followingArgs) -> { - int nextStart = bci + op.length(); - if (map.startLineMap[bci] != data.line || nextStart == co.code.length) { - lines.add(PFactory.createTuple(language, new int[]{data.start, nextStart, data.line})); - data.line = map.startLineMap[bci]; - data.start = nextStart; - } - }); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) self.getRootNodeForExtraction(); + List lines = computeLinesForBytecodeDSLInterpreter(rootNode); + tuple = PFactory.createTuple(language, lines.toArray()); + } else { + BytecodeCodeUnit bytecodeCo = (BytecodeCodeUnit) co; + SourceMap map = bytecodeCo.getSourceMap(); + List lines = new ArrayList<>(); + if (map != null && map.startLineMap.length > 0) { + IteratorData data = new IteratorData(); + data.line = map.startLineMap[0]; + bytecodeCo.iterateBytecode((int bci, OpCodes op, int oparg, byte[] followingArgs) -> { + int nextStart = bci + op.length(); + if (map.startLineMap[bci] != data.line || nextStart == bytecodeCo.code.length) { + lines.add(PFactory.createTuple(language, new int[]{data.start, nextStart, data.line})); + data.line = map.startLineMap[bci]; + data.start = nextStart; + } + }); + } + tuple = PFactory.createTuple(language, lines.toArray()); } - tuple = PFactory.createTuple(language, lines.toArray()); } else { tuple = PFactory.createEmptyTuple(language); } return PyObjectGetIter.executeUncached(tuple); } + + private static List computeLinesForBytecodeDSLInterpreter(PBytecodeDSLRootNode root) { + BytecodeNode bytecodeNode = root.getBytecodeNode(); + List triples = new ArrayList<>(); + SourceInformationTree sourceInformationTree = bytecodeNode.getSourceInformationTree(); + assert sourceInformationTree.getSourceSection() != null; + traverseSourceInformationTree(sourceInformationTree, triples); + return convertTripleBcisToInstructionIndices(bytecodeNode, root.getLanguage(), triples); + } + + /** + * This function traverses the source information tree recursively to compute a list of + * consecutive bytecode ranges with their corresponding line numbers. + *

    + * Each node in the tree covers a bytecode range. Each child covers some sub-range. The + * bytecodes covered by a particular node are the bytecodes within its range that are *not* + * covered by the node's children. + *

    + * For example, consider a node covering [0, 20] with children covering [4, 9] and [15, 18]. + * The node itself covers the ranges [0, 4], [9, 15], and [18, 20]. These ranges are + * assigned the line number of the node. + */ + private static void traverseSourceInformationTree(SourceInformationTree tree, List triples) { + int startIndex = tree.getStartBytecodeIndex(); + int startLine = tree.getSourceSection().getStartLine(); + for (SourceInformationTree child : tree.getChildren()) { + if (startIndex < child.getStartBytecodeIndex()) { + // range before child.start is uncovered + triples.add(new int[]{startIndex, child.getStartBytecodeIndex(), startLine}); + } + // recursively handle [child.start, child.end] + traverseSourceInformationTree(child, triples); + startIndex = child.getEndBytecodeIndex(); + } + + if (startIndex < tree.getEndBytecodeIndex()) { + // range after last_child.end is uncovered + triples.add(new int[]{startIndex, tree.getEndBytecodeIndex(), startLine}); + } + } + + /** + * The bci ranges in the triples are not stable and can change when the bytecode is + * instrumented. We create new triples with stable instruction indices by walking the + * instructions. + */ + private static List convertTripleBcisToInstructionIndices(BytecodeNode bytecodeNode, PythonLanguage language, List triples) { + List result = new ArrayList<>(triples.size()); + int tripleIndex = 0; + int[] triple = triples.get(0); + assert triple[0] == 0 : "the first bytecode range should start from 0"; + + int startInstructionIndex = 0; + int instructionIndex = 0; + for (Instruction instruction : bytecodeNode.getInstructions()) { + if (instruction.getBytecodeIndex() == triple[1] /* end bci */) { + result.add(PFactory.createTuple(language, new int[]{startInstructionIndex, instructionIndex, triple[2]})); + startInstructionIndex = instructionIndex; + triple = triples.get(++tripleIndex); + assert triple[0] == instruction.getBytecodeIndex() : "bytecode ranges should be consecutive"; + } + + if (!instruction.isInstrumentation()) { + // Emulate CPython's fixed 2-word instructions. + instructionIndex += 2; + } + } + + result.add(PFactory.createTuple(language, new int[]{startInstructionIndex, instructionIndex, triple[2]})); + assert tripleIndex == triples.size() : "every bytecode range should have been converted to an instruction range"; + + return result; + } + } @Builtin(name = "co_positions", minNumOfPositionalArgs = 1) @@ -404,13 +492,34 @@ Object positions(PCode self) { PTuple tuple; CodeUnit co = self.getCodeUnit(); if (co != null) { - SourceMap map = co.getSourceMap(); List lines = new ArrayList<>(); - if (map != null && map.startLineMap.length > 0) { - byte[] bytecode = co.code; - for (int i = 0; i < bytecode.length;) { - lines.add(PFactory.createTuple(language, new int[]{map.startLineMap[i], map.endLineMap[i], map.startColumnMap[i], map.endColumnMap[i]})); - i += OpCodes.fromOpCode(bytecode[i]).length(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) self.getRootNodeForExtraction(); + for (Instruction instruction : rootNode.getBytecodeNode().getInstructions()) { + if (instruction.isInstrumentation()) { + // Skip instrumented instructions. The co_positions array should agree + // with the logical instruction index. + continue; + } + SourceSection section = rootNode.getSourceSectionForLocation(instruction.getLocation()); + lines.add(PFactory.createTuple(language, new int[]{ + section.getStartLine(), + section.getEndLine(), + // 1-based inclusive to 0-based inclusive + section.getStartColumn() - 1, + // 1-based inclusive to 0-based exclusive (-1 + 1 = 0) + section.getEndColumn() + })); + } + } else { + BytecodeCodeUnit bytecodeCo = (BytecodeCodeUnit) co; + SourceMap map = bytecodeCo.getSourceMap(); + if (map != null && map.startLineMap.length > 0) { + byte[] bytecode = bytecodeCo.code; + for (int i = 0; i < bytecode.length;) { + lines.add(PFactory.createTuple(language, new int[]{map.startLineMap[i], map.endLineMap[i], map.startColumnMap[i], map.endColumnMap[i]})); + i += OpCodes.fromOpCode(bytecode[i]).length(); + } } } tuple = PFactory.createTuple(language, lines.toArray()); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java index 99d2c79252..19edfa3bc2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeNodes.java @@ -50,15 +50,20 @@ import com.oracle.graal.python.builtins.objects.code.CodeNodesFactory.GetCodeRootNodeGen; import com.oracle.graal.python.builtins.objects.function.PFunction; import com.oracle.graal.python.builtins.objects.function.Signature; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorFunctionRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLGeneratorFunctionRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.util.BadOPCodeNode; import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; import com.oracle.graal.python.runtime.IndirectCallData; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.graal.python.util.Supplier; @@ -142,7 +147,7 @@ private static PCode createCode(PythonLanguage language, PythonContext context, parameterNames, kwOnlyNames); } else { - ct = create().deserializeForBytecodeInterpreter(context, codedata, cellvars, freevars); + ct = create().deserializeForBytecodeInterpreter(language, context, codedata, cellvars, freevars); signature = ((PRootNode) ct.getRootNode()).getSignature(); } if (filename != null) { @@ -152,20 +157,31 @@ private static PCode createCode(PythonLanguage language, PythonContext context, } @SuppressWarnings("static-method") - private RootCallTarget deserializeForBytecodeInterpreter(PythonContext context, byte[] data, TruffleString[] cellvars, TruffleString[] freevars) { - CodeUnit code = MarshalModuleBuiltins.deserializeCodeUnit(null, context, data); - if (cellvars != null && !Arrays.equals(code.cellvars, cellvars) || freevars != null && !Arrays.equals(code.freevars, freevars)) { - code = new CodeUnit(code.name, code.qualname, code.argCount, code.kwOnlyArgCount, code.positionalOnlyArgCount, code.stacksize, code.code, - code.srcOffsetTable, code.flags, code.names, code.varnames, - cellvars != null ? cellvars : code.cellvars, freevars != null ? freevars : code.freevars, - code.cell2arg, code.constants, code.primitiveConstants, code.exceptionHandlerRanges, code.conditionProfileCount, - code.startLine, code.startColumn, code.endLine, code.endColumn, - code.outputCanQuicken, code.variableShouldUnbox, - code.generalizeInputsMap, code.generalizeVarsMap); - } - RootNode rootNode = PBytecodeRootNode.create(context.getLanguage(), code, PythonUtils.createFakeSource()); - if (code.isGeneratorOrCoroutine()) { - rootNode = new PBytecodeGeneratorFunctionRootNode(context.getLanguage(), rootNode.getFrameDescriptor(), (PBytecodeRootNode) rootNode, code.name); + private RootCallTarget deserializeForBytecodeInterpreter(PythonLanguage language, PythonContext context, byte[] data, TruffleString[] cellvars, TruffleString[] freevars) { + CodeUnit codeUnit = MarshalModuleBuiltins.deserializeCodeUnit(null, context, data); + RootNode rootNode = null; + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeDSLCodeUnit code = (BytecodeDSLCodeUnit) codeUnit; + rootNode = code.createRootNode(context, PythonUtils.createFakeSource()); + if (code.isGeneratorOrCoroutine()) { + rootNode = new PBytecodeDSLGeneratorFunctionRootNode(language, rootNode.getFrameDescriptor(), (PBytecodeDSLRootNode) rootNode, code.name); + } + } else { + BytecodeCodeUnit code = (BytecodeCodeUnit) codeUnit; + if (cellvars != null && !Arrays.equals(code.cellvars, cellvars) || freevars != null && !Arrays.equals(code.freevars, freevars)) { + code = new BytecodeCodeUnit(code.name, code.qualname, code.argCount, code.kwOnlyArgCount, code.positionalOnlyArgCount, code.flags, code.names, + code.varnames, cellvars != null ? cellvars : code.cellvars, freevars != null ? freevars : code.freevars, code.cell2arg, + code.constants, code.startLine, + code.startColumn, code.endLine, code.endColumn, code.code, code.srcOffsetTable, + code.primitiveConstants, code.exceptionHandlerRanges, code.stacksize, code.conditionProfileCount, + code.outputCanQuicken, code.variableShouldUnbox, + code.generalizeInputsMap, code.generalizeVarsMap); + } + rootNode = PBytecodeRootNode.create(context.getLanguage(), code, PythonUtils.createFakeSource()); + if (code.isGeneratorOrCoroutine()) { + rootNode = new PBytecodeGeneratorFunctionRootNode(context.getLanguage(), rootNode.getFrameDescriptor(), (PBytecodeRootNode) rootNode, code.name); + } } return PythonUtils.getOrCreateCallTarget(rootNode); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java index 1ff9e9d77f..c7c0fe56da 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/PCode.java @@ -59,15 +59,20 @@ import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorFunctionRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLGeneratorFunctionRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.object.IsForeignObjectNode; import com.oracle.graal.python.runtime.GilNode; import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; @@ -80,6 +85,8 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.bytecode.BytecodeNode; +import com.oracle.truffle.api.bytecode.ContinuationRootNode; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.interop.InteropLibrary; @@ -169,12 +176,18 @@ public PCode(Object cls, Shape instanceShape, Supplier callTargetSup this.filename = filename; } - public PCode(Object cls, Shape instanceShape, RootCallTarget callTarget, Signature signature, CodeUnit codeUnit) { + public PCode(Object cls, Shape instanceShape, RootCallTarget callTarget, Signature signature, BytecodeCodeUnit codeUnit) { this(cls, instanceShape, callTarget, signature, codeUnit.varnames.length, -1, -1, null, null, null, null, null, null, codeUnit.name, codeUnit.qualname, -1, codeUnit.srcOffsetTable); } + public PCode(Object cls, Shape instanceShape, RootCallTarget callTarget, Signature signature, BytecodeDSLCodeUnit codeUnit) { + this(cls, instanceShape, callTarget, signature, codeUnit.varnames.length, -1, -1, null, null, + null, null, null, null, + codeUnit.name, codeUnit.qualname, -1, null); + } + public PCode(Object cls, Shape instanceShape, RootCallTarget callTarget, Signature signature, int nlocals, int stacksize, int flags, Object[] constants, TruffleString[] names, TruffleString[] varnames, TruffleString[] freevars, TruffleString[] cellvars, @@ -266,13 +279,14 @@ private static String getSourceSectionFileName(SourceSection src) { @TruffleBoundary private static int extractFirstLineno(RootNode rootNode) { RootNode funcRootNode = rootNodeForExtraction(rootNode); - if (funcRootNode instanceof PBytecodeRootNode) { - CodeUnit co = ((PBytecodeRootNode) funcRootNode).getCodeUnit(); + CodeUnit co = getCodeUnit(funcRootNode); + if (co != null) { if ((co.flags & CO_GRAALPYHON_MODULE) != 0) { return 1; } return co.startLine; } + SourceSection sourceSection = funcRootNode.getSourceSection(); if (sourceSection != null) { return sourceSection.getStartLine(); @@ -288,10 +302,15 @@ private static TruffleString extractName(RootNode rootNode) { @TruffleBoundary private static int extractStackSize(RootNode rootNode) { RootNode funcRootNode = rootNodeForExtraction(rootNode); - if (funcRootNode instanceof PBytecodeRootNode) { - CodeUnit code = ((PBytecodeRootNode) funcRootNode).getCodeUnit(); + if (funcRootNode instanceof PBytecodeRootNode bytecodeRootNode) { + BytecodeCodeUnit code = bytecodeRootNode.getCodeUnit(); return code.stacksize + code.varnames.length + code.cellvars.length + code.freevars.length; } + /** + * NB: This fallback case includes PBytecodeDSLRootNode. The Bytecode DSL stack does not + * mirror a CPython stack (it's an operand stack for its own instruction set), so the frame + * size is our best estimate. + */ return funcRootNode.getFrameDescriptor().getNumberOfSlots(); } @@ -307,8 +326,18 @@ private static TruffleString[] extractVarnames(RootNode node) { @TruffleBoundary private static Object[] extractConstants(RootNode node) { RootNode rootNode = rootNodeForExtraction(node); - if (rootNode instanceof PBytecodeRootNode) { - CodeUnit co = ((PBytecodeRootNode) rootNode).getCodeUnit(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLRootNode bytecodeDSLRootNode) { + BytecodeDSLCodeUnit co = bytecodeDSLRootNode.getCodeUnit(); + List constants = new ArrayList<>(); + for (int i = 0; i < co.constants.length; i++) { + Object constant = convertConstantToPythonSpace(rootNode, co.constants[i]); + constants.add(constant); + } + return constants.toArray(new Object[0]); + } + } else if (rootNode instanceof PBytecodeRootNode bytecodeRootNode) { + BytecodeCodeUnit co = bytecodeRootNode.getCodeUnit(); Set bytecodeConstants = new HashSet<>(); for (int bci = 0; bci < co.code.length;) { OpCodes op = OpCodes.fromOpCode(co.code[bci]); @@ -355,11 +384,20 @@ private static TruffleString[] extractNames(RootNode node) { } private static RootNode rootNodeForExtraction(RootNode rootNode) { - if (rootNode instanceof PBytecodeGeneratorFunctionRootNode) { - return ((PBytecodeGeneratorFunctionRootNode) rootNode).getBytecodeRootNode(); - } - if (rootNode instanceof PBytecodeGeneratorRootNode) { - return ((PBytecodeGeneratorRootNode) rootNode).getBytecodeRootNode(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLGeneratorFunctionRootNode generatorFunctionRootNode) { + return generatorFunctionRootNode.getBytecodeRootNode(); + } + if (rootNode instanceof ContinuationRootNode generatorRootNode) { + return (RootNode) generatorRootNode.getSourceRootNode(); + } + } else { + if (rootNode instanceof PBytecodeGeneratorFunctionRootNode generatorFunctionRootNode) { + return generatorFunctionRootNode.getBytecodeRootNode(); + } + if (rootNode instanceof PBytecodeGeneratorRootNode generatorRootNode) { + return generatorRootNode.getBytecodeRootNode(); + } } return rootNode; } @@ -376,8 +414,12 @@ private static int extractFlags(RootNode node) { private static CodeUnit getCodeUnit(RootNode node) { RootNode rootNode = rootNodeForExtraction(node); - if (rootNode instanceof PBytecodeRootNode) { - return ((PBytecodeRootNode) rootNode).getCodeUnit(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (rootNode instanceof PBytecodeDSLRootNode bytecodeDSLRootNode) { + return bytecodeDSLRootNode.getCodeUnit(); + } + } else if (rootNode instanceof PBytecodeRootNode bytecodeRootNode) { + return bytecodeRootNode.getCodeUnit(); } return null; } @@ -386,6 +428,10 @@ RootNode getRootNode() { return getRootCallTarget().getRootNode(); } + RootNode getRootNodeForExtraction() { + return rootNodeForExtraction(getRootNode()); + } + public TruffleString[] getFreeVars() { if (freevars == null) { freevars = extractFreeVars(getRootNode()); @@ -433,23 +479,19 @@ public int getFirstLineNo() { } @TruffleBoundary - public int bciToLine(int bci) { + public int lastiToLine(int lasti) { RootNode funcRootNode = rootNodeForExtraction(getRootNode()); - if (funcRootNode instanceof PBytecodeRootNode bytecodeRootNode) { - return bytecodeRootNode.bciToLine(bci); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (funcRootNode instanceof PBytecodeDSLRootNode bytecodeDSLRootNode) { + BytecodeNode bytecodeNode = bytecodeDSLRootNode.getBytecodeNode(); + return bytecodeDSLRootNode.bciToLine(PBytecodeDSLRootNode.lastiToBci(lasti, bytecodeNode), bytecodeNode); + } + } else if (funcRootNode instanceof PBytecodeRootNode bytecodeRootNode) { + return bytecodeRootNode.bciToLine(bytecodeRootNode.lastiToBci(lasti)); } return -1; } - @TruffleBoundary - public int lastiToBci(int lasti) { - RootNode funcRootNode = rootNodeForExtraction(getRootNode()); - if (funcRootNode instanceof PBytecodeRootNode bytecodeRootNode) { - return bytecodeRootNode.lastiToBci(lasti); - } - return lasti; - } - public TruffleString getName() { if (name == null) { name = extractName(getRootNode()); @@ -528,9 +570,16 @@ public Object[] getConstants() { @TruffleBoundary private static Object convertConstantToPythonSpace(RootNode rootNode, Object o) { PythonLanguage language = PythonLanguage.get(null); - if (o instanceof CodeUnit code) { - PBytecodeRootNode bytecodeRootNode = PBytecodeRootNode.create(language, code, getSourceSection(rootNode).getSource()); - return PFactory.createCode(language, bytecodeRootNode.getCallTarget(), bytecodeRootNode.getSignature(), code); + if (o instanceof CodeUnit) { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeDSLCodeUnit code = (BytecodeDSLCodeUnit) o; + PBytecodeDSLRootNode root = code.createRootNode(PythonContext.get(rootNode), getSourceSection(rootNode).getSource()); + return PFactory.createCode(language, root.getCallTarget(), root.getSignature(), code); + } else { + BytecodeCodeUnit code = (BytecodeCodeUnit) o; + PBytecodeRootNode bytecodeRootNode = PBytecodeRootNode.create(language, code, getSourceSection(rootNode).getSource()); + return PFactory.createCode(language, bytecodeRootNode.getCallTarget(), bytecodeRootNode.getSignature(), code); + } } else if (o instanceof BigInteger) { return PFactory.createInt(language, (BigInteger) o); } else if (o instanceof int[]) { @@ -695,6 +744,10 @@ public String toString() { @TruffleBoundary public String toDisassembledString(boolean quickened) { RootNode rootNode = getRootCallTarget().getRootNode(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER && rootNode instanceof PBytecodeDSLRootNode dslRoot) { + return dslRoot.dump(); + } + if (rootNode instanceof PBytecodeGeneratorRootNode r) { rootNode = r.getBytecodeRootNode(); } else if (rootNode instanceof PBytecodeGeneratorFunctionRootNode r) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java index cc236bb633..a98bea7397 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -50,22 +50,27 @@ import com.oracle.graal.python.builtins.objects.object.PythonObject; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.frame.GetFrameLocalsNode; import com.oracle.graal.python.nodes.frame.MaterializeFrameNode; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.nodes.Node; public final class PFrame extends PythonBuiltinObject { + private static final int UNINITIALIZED_LINE = -2; + private Object[] arguments; private final MaterializedFrame locals; private Object localsDict; private final Reference virtualFrameInfo; private Node location; private RootCallTarget callTarget; - private int line = -2; + private int line = UNINITIALIZED_LINE; private int bci = -1; /* @@ -187,7 +192,7 @@ public PFrame(PythonLanguage lang, @SuppressWarnings("unused") Object threadStat this.virtualFrameInfo = curFrameInfo; curFrameInfo.setPyFrame(this); this.location = GetCodeRootNode.executeUncached(code); - this.line = this.location == null ? code.getFirstLineNo() : -2; + this.line = this.location == null ? code.getFirstLineNo() : UNINITIALIZED_LINE; this.arguments = frameArgs; this.locals = null; this.localsDict = localsDict; @@ -254,11 +259,16 @@ public boolean didJump() { @TruffleBoundary public int getLine() { - if (line == -2) { + if (line == UNINITIALIZED_LINE) { if (location == null) { line = -1; - } else if (location instanceof PBytecodeRootNode) { - return ((PBytecodeRootNode) location).bciToLine(bci); + } else if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (location instanceof BytecodeNode bytecodeNode) { + PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) bytecodeNode.getRootNode(); + return rootNode.bciToLine(bci, bytecodeNode); + } + } else if (location instanceof PBytecodeRootNode bytecodeRootNode) { + return bytecodeRootNode.bciToLine(bci); } } return line; @@ -304,6 +314,10 @@ public Node getLocation() { return location; } + public BytecodeNode getBytecodeNode() { + return (location instanceof BytecodeNode bytecodeNode) ? bytecodeNode : null; + } + public int getBci() { return bci; } @@ -313,15 +327,21 @@ public void setBci(int bci) { } public int getLasti() { - return bciToLasti(bci); + return bciToLasti(bci, location); } @TruffleBoundary - public int bciToLasti(int bci) { - if (location instanceof PBytecodeRootNode bytecodeRootNode) { - return bytecodeRootNode.bciToLasti(bci); - } else if (location instanceof PBytecodeGeneratorRootNode generatorRootNode) { - return generatorRootNode.getBytecodeRootNode().bciToLasti(bci); + public static int bciToLasti(int bci, Node location) { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (bci >= 0 && location instanceof BytecodeNode bytecodeNode) { + return PBytecodeDSLRootNode.bciToLasti(bci, bytecodeNode); + } + } else { + if (location instanceof PBytecodeRootNode bytecodeRootNode) { + return bytecodeRootNode.bciToLasti(bci); + } else if (location instanceof PBytecodeGeneratorRootNode generatorRootNode) { + return generatorRootNode.getBytecodeRootNode().bciToLasti(bci); + } } return -1; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java index 25baa2d572..febb49e675 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2013, Regents of the University of California * * All rights reserved. @@ -28,6 +28,8 @@ import com.oracle.graal.python.builtins.objects.cell.PCell; import com.oracle.graal.python.builtins.objects.frame.PFrame; import com.oracle.graal.python.builtins.objects.object.PythonObject; +import com.oracle.graal.python.runtime.PythonOptions; +import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.exception.AbstractTruffleException; @@ -217,6 +219,11 @@ public static Object getExceptionUnchecked(Object[] arguments) { return arguments[INDEX_CURRENT_EXCEPTION]; } + public static boolean hasException(Object[] arguments) { + Object exception = getExceptionUnchecked(arguments); + return exception != null && exception != PException.NO_EXCEPTION; + } + public static void setException(Frame frame, AbstractTruffleException exc) { setException(frame.getArguments(), exc); } @@ -280,6 +287,7 @@ public static int getUserArgumentLength(Object[] arguments) { } public static MaterializedFrame getGeneratorFrame(Object[] arguments) { + assert !PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; return (MaterializedFrame) arguments[INDEX_GENERATOR_FRAME]; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java index 7ca7c4de46..5ed7079c51 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/CommonGeneratorBuiltins.java @@ -83,6 +83,8 @@ import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.bytecode.ContinuationResult; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -107,7 +109,7 @@ public final class CommonGeneratorBuiltins extends PythonBuiltins { * is invoked using {@code next(g)} outside of any {@code except} handler but the generator * requests the exception state, then the exception state will be written into the arguments. If * we now use the same arguments array every time, the next invocation would think that there is - * not excepion but in fact, the a subsequent call ot {@code next} may have a different + * not an exception but in fact, a subsequent call to {@code next} may have a different * exception state. * *
    @@ -158,7 +160,7 @@ private static void checkResumable(Node inliningTarget, PGenerator self, PRaiseN
         abstract static class ResumeGeneratorNode extends Node {
             public abstract Object execute(VirtualFrame frame, Node inliningTarget, PGenerator self, Object sendValue);
     
    -        @Specialization(guards = "sameCallTarget(self.getCurrentCallTarget(), call.getCallTarget())", limit = "getCallSiteInlineCacheMaxDepth()")
    +        @Specialization(guards = {"!isBytecodeDSLInterpreter()", "sameCallTarget(self.getCurrentCallTarget(), call.getCallTarget())"}, limit = "getCallSiteInlineCacheMaxDepth()")
             static Object cached(VirtualFrame frame, Node inliningTarget, PGenerator self, Object sendValue,
                             @Cached(value = "createDirectCall(self.getCurrentCallTarget())", inline = false) CallTargetInvokeNode call,
                             @Exclusive @Cached InlinedBranchProfile returnProfile,
    @@ -176,14 +178,69 @@ static Object cached(VirtualFrame frame, Node inliningTarget, PGenerator self, O
                     throw handleException(self, inliningTarget, errorProfile, raiseNode, e);
                 } catch (GeneratorReturnException e) {
                     returnProfile.enter(inliningTarget);
    -                throw handleReturn(inliningTarget, self, e);
    +                throw handleReturn(inliningTarget, self, e.value);
                 } finally {
                     self.setRunning(false);
                 }
                 return handleResult(inliningTarget, self, result);
             }
     
    -        @Specialization(replaces = "cached")
    +        @Specialization(guards = {"isBytecodeDSLInterpreter()", "sameCallTarget(currentCallTarget, call.getCallTarget())"}, limit = "getCallSiteInlineCacheMaxDepth()")
    +        static Object cachedBytecodeDSL(VirtualFrame frame, Node inliningTarget, PGenerator self, Object sendValue,
    +                        @Bind("self.getCurrentCallTarget()") @SuppressWarnings("unused") RootCallTarget currentCallTarget,
    +                        @Cached(value = "createDirectCall(currentCallTarget)", inline = false) CallTargetInvokeNode call,
    +                        @Cached("self.getContinuation() == null") boolean firstCall,
    +                        @Exclusive @Cached InlinedBranchProfile returnProfile,
    +                        @Exclusive @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Exclusive @Cached PRaiseNode raiseNode) {
    +            self.setRunning(true);
    +            Object generatorResult;
    +            try {
    +                ContinuationResult continuation = self.getContinuation();
    +                Object[] arguments;
    +                // TODO: GR-62196, Bytecode DSL does not have the same shape of arguments array for
    +                // continuation calls:
    +
    +                // 1) in the manual interpreter, we always pass an array of the same length (with
    +                // slots defined in PArguments), this argument array is used for callee context
    +                // enter/exit in PBytecodeGeneratorRootNode as opposed to the original arguments
    +                // array taken from the PGenerator object. Moreover, this array is a copy of
    +                // PGenerator arguments, and the comment above prepareArguments seems to indicate
    +                // that we indeed need a fresh copy, because we do not want to share the state
    +                // stored in the arguments between invocations
    +
    +                // 2) Bytecode DSL doesn't do callee context enter/exit for individual calls,
    +                // but for the whole coroutine
    +
    +                // 3) when walking the stack, e.g., in MaterializeFrameNode, we must take care of
    +                // this additional arguments shape and unwrap the materialized frame from the
    +                // continuation frame to access its arguments array that will have the desired
    +                // "PArguments shape", however this will be a shared arguments array, so it is a
    +                // question if this unwrapping would be correct, see 1).
    +
    +                if (firstCall) {
    +                    // First invocation: call the regular root node.
    +                    arguments = prepareArguments(self);
    +                } else {
    +                    // Subsequent invocations: call a continuation root node.
    +                    arguments = new Object[]{continuation.getFrame(), sendValue};
    +                }
    +                generatorResult = call.execute(frame, null, null, null, arguments);
    +            } catch (PException e) {
    +                throw handleException(self, inliningTarget, errorProfile, raiseNode, e);
    +            } finally {
    +                self.setRunning(false);
    +            }
    +            if (generatorResult instanceof ContinuationResult continuation) {
    +                return handleResult(inliningTarget, self, continuation);
    +            } else {
    +                returnProfile.enter(inliningTarget);
    +                throw handleReturn(inliningTarget, self, generatorResult);
    +            }
    +
    +        }
    +
    +        @Specialization(replaces = "cached", guards = "!isBytecodeDSLInterpreter()")
             @Megamorphic
             static Object generic(VirtualFrame frame, Node inliningTarget, PGenerator self, Object sendValue,
                             @Cached InlinedConditionProfile hasFrameProfile,
    @@ -207,13 +264,53 @@ static Object generic(VirtualFrame frame, Node inliningTarget, PGenerator self,
                     throw handleException(self, inliningTarget, errorProfile, raiseNode, e);
                 } catch (GeneratorReturnException e) {
                     returnProfile.enter(inliningTarget);
    -                throw handleReturn(inliningTarget, self, e);
    +                throw handleReturn(inliningTarget, self, e.value);
                 } finally {
                     self.setRunning(false);
                 }
                 return handleResult(inliningTarget, self, result);
             }
     
    +        @Specialization(replaces = "cachedBytecodeDSL", guards = "isBytecodeDSLInterpreter()")
    +        @Megamorphic
    +        static Object genericBytecodeDSL(VirtualFrame frame, Node inliningTarget, PGenerator self, Object sendValue,
    +                        @Cached InlinedConditionProfile hasFrameProfile,
    +                        @Cached(inline = false) GenericInvokeNode call,
    +                        @Cached InlinedConditionProfile firstInvocationProfile,
    +                        @Cached InlinedBranchProfile returnProfile,
    +                        @Cached IsBuiltinObjectProfile errorProfile,
    +                        @Cached PRaiseNode raiseNode) {
    +            self.setRunning(true);
    +            Object generatorResult;
    +            try {
    +                ContinuationResult continuation = self.getContinuation();
    +                Object[] arguments;
    +                if (firstInvocationProfile.profile(inliningTarget, continuation == null)) {
    +                    // First invocation: call the regular root node.
    +                    arguments = prepareArguments(self);
    +                } else {
    +                    // Subsequent invocations: call a continuation root node.
    +                    arguments = new Object[]{continuation.getFrame(), sendValue};
    +                }
    +
    +                if (hasFrameProfile.profile(inliningTarget, frame != null)) {
    +                    generatorResult = call.execute(frame, self.getCurrentCallTarget(), arguments);
    +                } else {
    +                    generatorResult = call.execute(self.getCurrentCallTarget(), arguments);
    +                }
    +            } catch (PException e) {
    +                throw handleException(self, inliningTarget, errorProfile, raiseNode, e);
    +            } finally {
    +                self.setRunning(false);
    +            }
    +            if (generatorResult instanceof ContinuationResult continuation) {
    +                return handleResult(inliningTarget, self, continuation);
    +            } else {
    +                returnProfile.enter(inliningTarget);
    +                throw handleReturn(inliningTarget, self, generatorResult);
    +            }
    +        }
    +
             private static PException handleException(PGenerator self, Node inliningTarget, IsBuiltinObjectProfile profile, PRaiseNode raiseNode, PException e) {
                 self.markAsFinished();
                 if (self.isAsyncGen()) {
    @@ -228,18 +325,17 @@ private static PException handleException(PGenerator self, Node inliningTarget,
                 throw raiseNode.raiseWithCause(inliningTarget, RuntimeError, e, ErrorMessages.GENERATOR_RAISED_STOPITER);
             }
     
    -        private static Object handleResult(Node node, PGenerator self, GeneratorYieldResult result) {
    -            self.handleResult(PythonLanguage.get(node), result);
    -            return result.yieldValue;
    +        private static Object handleResult(Node node, PGenerator self, Object result) {
    +            return self.handleResult(PythonLanguage.get(node), result);
             }
     
    -        private static PException handleReturn(Node inliningTarget, PGenerator self, GeneratorReturnException e) {
    +        private static PException handleReturn(Node inliningTarget, PGenerator self, Object returnValue) {
                 self.markAsFinished();
                 if (self.isAsyncGen()) {
                     throw PRaiseNode.raiseStatic(inliningTarget, StopAsyncIteration);
                 }
    -            if (e.value != PNone.NONE) {
    -                throw PRaiseNode.raiseStatic(inliningTarget, StopIteration, new Object[]{e.value});
    +            if (returnValue != PNone.NONE) {
    +                throw PRaiseNode.raiseStatic(inliningTarget, StopIteration, new Object[]{returnValue});
                 } else {
                     throw TpIterNextBuiltin.iteratorExhausted();
                 }
    @@ -329,15 +425,20 @@ static Object sendThrow(VirtualFrame frame, PGenerator self, Object typ, Object
                     // its frame to the traceback manually.
                     self.markAsFinished();
                     Node location = self.getCurrentCallTarget().getRootNode();
    -                MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(self.getArguments());
    +                MaterializedFrame generatorFrame;
    +                if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +                    generatorFrame = Truffle.getRuntime().createMaterializedFrame(PArguments.create(), self.getRootNode().getFrameDescriptor());
    +                } else {
    +                    generatorFrame = PArguments.getGeneratorFrame(self.getArguments());
    +                }
                     PFrame pFrame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY);
                     FrameInfo info = (FrameInfo) generatorFrame.getFrameDescriptor().getInfo();
    -                pFrame.setLine(info.getRootNode().getFirstLineno());
    +                pFrame.setLine(info.getFirstLineNumber());
                     Object existingTracebackObj = getTracebackNode.execute(inliningTarget, instance);
                     PTraceback newTraceback = PFactory.createTraceback(language, pFrame, pFrame.getLine(),
                                     (existingTracebackObj instanceof PTraceback existingTraceback) ? existingTraceback : null);
                     setTracebackNode.execute(inliningTarget, instance, newTraceback);
    -                throw PException.fromObject(instance, location, PythonOptions.isPExceptionWithJavaStacktrace(language));
    +                throw PException.fromObject(instance, inliningTarget, PythonOptions.isPExceptionWithJavaStacktrace(language));
                 }
             }
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    index 46421b5b25..01342aa0c9 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java
    @@ -52,12 +52,16 @@
     import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.TpIterNextBuiltin;
     import com.oracle.graal.python.nodes.ErrorMessages;
     import com.oracle.graal.python.nodes.PRaiseNode;
    -import com.oracle.graal.python.nodes.bytecode.FrameInfo;
    +import com.oracle.graal.python.nodes.bytecode.BytecodeFrameInfo;
    +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLFrameInfo;
     import com.oracle.graal.python.nodes.frame.MaterializeFrameNode;
     import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
    +import com.oracle.graal.python.runtime.PythonOptions;
     import com.oracle.graal.python.runtime.object.PFactory;
    +import com.oracle.truffle.api.bytecode.BytecodeLocation;
    +import com.oracle.truffle.api.bytecode.ContinuationResult;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.GenerateNodeFactory;
    @@ -194,14 +198,25 @@ static Object getFrame(PGenerator self) {
                 if (self.isFinished()) {
                     return PNone.NONE;
                 } else {
    -                MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(self.getArguments());
    -                Node location = ((FrameInfo) generatorFrame.getFrameDescriptor().getInfo()).getRootNode();
    -                PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(location, generatorFrame, PFrame.Reference.EMPTY);
    -                FrameInfo info = (FrameInfo) generatorFrame.getFrameDescriptor().getInfo();
    -                int bci = self.getBci();
    -                frame.setBci(bci);
    -                frame.setLine(info.getRootNode().bciToLine(bci));
    -                return frame;
    +                if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +                    ContinuationResult continuation = self.getContinuation();
    +                    BytecodeLocation location = continuation.getBytecodeLocation();
    +                    MaterializedFrame generatorFrame = continuation.getFrame();
    +                    BytecodeDSLFrameInfo info = (BytecodeDSLFrameInfo) generatorFrame.getFrameDescriptor().getInfo();
    +                    PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(location.getBytecodeNode(), generatorFrame, PFrame.Reference.EMPTY);
    +                    int bci = location.getBytecodeIndex();
    +                    frame.setBci(bci);
    +                    frame.setLine(info.getRootNode().bciToLine(bci, location.getBytecodeNode()));
    +                    return frame;
    +                } else {
    +                    MaterializedFrame generatorFrame = PArguments.getGeneratorFrame(self.getArguments());
    +                    BytecodeFrameInfo info = (BytecodeFrameInfo) generatorFrame.getFrameDescriptor().getInfo();
    +                    PFrame frame = MaterializeFrameNode.materializeGeneratorFrame(info.getRootNode(), generatorFrame, PFrame.Reference.EMPTY);
    +                    int bci = self.getBci();
    +                    frame.setBci(bci);
    +                    frame.setLine(info.getRootNode().bciToLine(bci));
    +                    return frame;
    +                }
                 }
             }
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java
    index 89df69e533..7f7888b099 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java
    @@ -31,15 +31,21 @@
     import com.oracle.graal.python.builtins.objects.code.PCode;
     import com.oracle.graal.python.builtins.objects.function.PArguments;
     import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
    +import com.oracle.graal.python.nodes.bytecode.BytecodeFrameInfo;
     import com.oracle.graal.python.nodes.bytecode.FrameInfo;
     import com.oracle.graal.python.nodes.bytecode.GeneratorYieldResult;
     import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorRootNode;
     import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode;
    +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLFrameInfo;
    +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode;
    +import com.oracle.graal.python.runtime.PythonOptions;
     import com.oracle.graal.python.runtime.object.PFactory;
     import com.oracle.truffle.api.CompilerDirectives;
     import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
    +import com.oracle.truffle.api.bytecode.ContinuationResult;
     import com.oracle.truffle.api.RootCallTarget;
     import com.oracle.truffle.api.nodes.Node;
    +import com.oracle.truffle.api.nodes.RootNode;
     import com.oracle.truffle.api.profiles.InlinedConditionProfile;
     import com.oracle.truffle.api.strings.TruffleString;
     
    @@ -47,32 +53,94 @@ public class PGenerator extends PythonBuiltinObject {
     
         private TruffleString name;
         private TruffleString qualname;
    -    /**
    -     * Call targets with copies of the generator's AST. Each call target corresponds to one possible
    -     * entry point into the generator: the first call, and continuation for each yield. Each AST can
    -     * then specialize towards which nodes are executed when starting from that particular entry
    -     * point. When yielding, the next index to the next call target to continue from is updated via
    -     * {@link #handleResult}.
    -     */
    -    @CompilationFinal(dimensions = 1) protected final RootCallTarget[] callTargets;
    -    protected final Object[] arguments;
    -    private boolean finished;
    -    private PCode code;
    -    private int currentCallTarget;
    -    private final PBytecodeRootNode bytecodeRootNode;
         private final FrameInfo frameInfo;
    +
    +    private boolean finished;
         // running means it is currently on the stack, not just started
         private boolean running;
         private final boolean isCoroutine;
         private final boolean isAsyncGen;
     
    +    private PCode code;
    +    protected final Object[] arguments;
    +
    +    // TODO (GR-38700): remove BytecodeState after migrated to the Bytecode DSL interpreter.
    +    protected static class BytecodeState {
    +        private final PBytecodeRootNode rootNode;
    +
    +        /**
    +         * Call targets with copies of the generator's AST. Each call target corresponds to one
    +         * possible entry point into the generator: the first call, and continuation for each yield.
    +         * Each AST can then specialize towards which nodes are executed when starting from that
    +         * particular entry point. When yielding, the next index to the next call target to continue
    +         * from is updated via {@link #handleResult}.
    +         */
    +        @CompilationFinal(dimensions = 1) private final RootCallTarget[] callTargets;
    +        private int currentCallTarget;
    +
    +        public BytecodeState(PBytecodeRootNode rootNode, RootCallTarget[] callTargets) {
    +            this.rootNode = rootNode;
    +            this.callTargets = callTargets;
    +            this.currentCallTarget = 0;
    +        }
    +
    +        public RootCallTarget getCurrentCallTarget() {
    +            return callTargets[currentCallTarget];
    +        }
    +
    +        public PBytecodeGeneratorRootNode getCurrentRootNode() {
    +            return (PBytecodeGeneratorRootNode) getCurrentCallTarget().getRootNode();
    +        }
    +
    +        public Object handleResult(PythonLanguage language, GeneratorYieldResult result) {
    +            currentCallTarget = result.resumeBci;
    +            if (callTargets[currentCallTarget] == null) {
    +                CompilerDirectives.transferToInterpreterAndInvalidate();
    +                PBytecodeGeneratorRootNode generatorRootNode = new PBytecodeGeneratorRootNode(language, rootNode, result.resumeBci, result.resumeStackTop);
    +                callTargets[currentCallTarget] = generatorRootNode.getCallTarget();
    +            }
    +            return result.yieldValue;
    +        }
    +    }
    +
    +    private static class BytecodeDSLState {
    +        private final PBytecodeDSLRootNode rootNode;
    +        private ContinuationResult yieldResult;
    +
    +        public BytecodeDSLState(PBytecodeDSLRootNode rootNode) {
    +            this.rootNode = rootNode;
    +            this.yieldResult = null;
    +        }
    +
    +        public Object handleResult(ContinuationResult result) {
    +            yieldResult = result;
    +            return result.getResult();
    +        }
    +    }
    +
    +    // This is either BytecodeState or BytecodeDSLState.
    +    private final Object state;
    +
    +    private BytecodeState getBytecodeState() {
    +        return (BytecodeState) state;
    +    }
    +
    +    private BytecodeDSLState getBytecodeDSLState() {
    +        return (BytecodeDSLState) state;
    +    }
    +
         // An explicit isIterableCoroutine argument is needed for iterable coroutines (generally created
         // via types.coroutine)
         public static PGenerator create(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments,
                         PythonBuiltinClassType cls, boolean isIterableCoroutine) {
             // note: also done in PAsyncGen.create
             rootNode.createGeneratorFrame(arguments);
    -        return new PGenerator(lang, name, qualname, rootNode, callTargets, arguments, cls, isIterableCoroutine);
    +        return new PGenerator(lang, name, qualname, arguments, cls, isIterableCoroutine, new BytecodeState(rootNode, callTargets));
    +    }
    +
    +    public static PGenerator create(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeDSLRootNode rootNode, Object[] arguments,
    +                    PythonBuiltinClassType cls, boolean isIterableCoroutine) {
    +        return new PGenerator(lang, name, qualname, arguments, cls, isIterableCoroutine, new BytecodeDSLState(rootNode));
         }
     
         public static PGenerator create(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments,
    @@ -80,61 +148,79 @@ public static PGenerator create(PythonLanguage lang, TruffleString name, Truffle
             return create(lang, name, qualname, rootNode, callTargets, arguments, cls, false);
         }
     
    -    protected PGenerator(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments, PythonBuiltinClassType cls,
    -                    boolean isIterableCoroutine) {
    +    public static PGenerator create(PythonLanguage lang, TruffleString name, TruffleString qualname, PBytecodeDSLRootNode rootNode, Object[] arguments,
    +                    PythonBuiltinClassType cls) {
    +        return create(lang, name, qualname, rootNode, arguments, cls, false);
    +    }
    +
    +    protected PGenerator(PythonLanguage lang, TruffleString name, TruffleString qualname, Object[] arguments, PythonBuiltinClassType cls, boolean isIterableCoroutine, Object state) {
             super(cls, cls.getInstanceShape(lang));
             this.name = name;
             this.qualname = qualname;
    -        this.callTargets = callTargets;
    -        this.currentCallTarget = 0;
             this.arguments = arguments;
             this.finished = false;
    -        this.bytecodeRootNode = rootNode;
    -        this.frameInfo = (FrameInfo) rootNode.getFrameDescriptor().getInfo();
             this.isCoroutine = isIterableCoroutine || cls == PythonBuiltinClassType.PCoroutine;
             this.isAsyncGen = cls == PythonBuiltinClassType.PAsyncGenerator;
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            BytecodeDSLState bytecodeDSLState = (BytecodeDSLState) state;
    +            this.state = state;
    +            this.frameInfo = (BytecodeDSLFrameInfo) bytecodeDSLState.rootNode.getFrameDescriptor().getInfo();
    +        } else {
    +            BytecodeState bytecodeState = (BytecodeState) state;
    +            this.state = state;
    +            this.frameInfo = (BytecodeFrameInfo) bytecodeState.rootNode.getFrameDescriptor().getInfo();
    +        }
         }
     
    -    public final void handleResult(PythonLanguage language, GeneratorYieldResult result) {
    -        currentCallTarget = result.resumeBci;
    -        if (callTargets[currentCallTarget] == null) {
    -            CompilerDirectives.transferToInterpreterAndInvalidate();
    -            PBytecodeGeneratorRootNode rootNode = new PBytecodeGeneratorRootNode(language, bytecodeRootNode, result.resumeBci, result.resumeStackTop);
    -            callTargets[currentCallTarget] = rootNode.getCallTarget();
    +    public RootNode getRootNode() {
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            return getBytecodeDSLState().rootNode;
    +        } else {
    +            return getBytecodeState().rootNode;
             }
         }
     
         /**
    -     * Returns the call target that should be used the next time the generator is called. Each time
    -     * a generator call target returns through a yield, the generator should be updated with the
    -     * next yield index to use via {@link #handleResult}
    +     * Returns the call target that should be used the next time the generator is called.
          */
    -    public final RootCallTarget getCurrentCallTarget() {
    -        return callTargets[currentCallTarget];
    +    public RootCallTarget getCurrentCallTarget() {
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            BytecodeDSLState bytecodeDSLState = getBytecodeDSLState();
    +            if (bytecodeDSLState.yieldResult == null) {
    +                return bytecodeDSLState.rootNode.getCallTarget();
    +            }
    +            return bytecodeDSLState.yieldResult.getContinuationCallTarget();
    +        } else {
    +            return getBytecodeState().getCurrentCallTarget();
    +        }
         }
     
    -    public final Object getYieldFrom() {
    -        if (running || finished) {
    +    public Object getYieldFrom() {
    +        if (isRunning() || isFinished()) {
                 return null;
             }
    -        return frameInfo.getYieldFrom(PArguments.getGeneratorFrame(arguments), getBci(), getCurrentRootNode().getResumeStackTop());
    -    }
     
    -    private PBytecodeGeneratorRootNode getCurrentRootNode() {
    -        return (PBytecodeGeneratorRootNode) getCurrentCallTarget().getRootNode();
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            throw new UnsupportedOperationException("not implemented"); // TODO: GR-64250
    +        } else {
    +            return frameInfo.getYieldFrom(PArguments.getGeneratorFrame(arguments), getBci(), getBytecodeState().getCurrentRootNode().getResumeStackTop());
    +        }
    +
         }
     
    -    public final boolean isStarted() {
    -        return currentCallTarget != 0 && !running;
    +    public boolean isStarted() {
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            return getBytecodeDSLState().yieldResult != null && !isRunning();
    +        } else {
    +            return getBytecodeState().currentCallTarget != 0 && !isRunning();
    +        }
         }
     
    -    public final int getBci() {
    -        if (!isStarted()) {
    -            return -1;
    -        } else if (finished) {
    -            return bytecodeRootNode.getCodeUnit().code.length;
    +    public Object handleResult(PythonLanguage language, Object result) {
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            return getBytecodeDSLState().handleResult((ContinuationResult) result);
             } else {
    -            return getCurrentRootNode().getResumeBci();
    +            return getBytecodeState().handleResult(language, (GeneratorYieldResult) result);
             }
         }
     
    @@ -157,8 +243,7 @@ public final String toString() {
     
         public final PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCodeProfile) {
             if (hasCodeProfile.profile(inliningTarget, code == null)) {
    -            RootCallTarget callTarget;
    -            callTarget = bytecodeRootNode.getCallTarget();
    +            RootCallTarget callTarget = getRootNode().getCallTarget();
                 code = PFactory.createCode(PythonLanguage.get(inliningTarget), callTarget);
             }
             return code;
    @@ -196,4 +281,20 @@ public final boolean isCoroutine() {
         public final boolean isAsyncGen() {
             return isAsyncGen;
         }
    +
    +    public int getBci() {
    +        assert !PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER;
    +        if (!isStarted()) {
    +            return -1;
    +        } else if (isFinished()) {
    +            return getBytecodeState().rootNode.getCodeUnit().code.length;
    +        } else {
    +            return getBytecodeState().getCurrentRootNode().getResumeBci();
    +        }
    +    }
    +
    +    public ContinuationResult getContinuation() {
    +        assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER;
    +        return getBytecodeDSLState().yieldResult;
    +    }
     }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonFrozenModule.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonFrozenModule.java
    index fe76a33414..b20fc5df77 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonFrozenModule.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/module/PythonFrozenModule.java
    @@ -47,6 +47,7 @@
     import java.io.IOException;
     import java.io.InputStream;
     
    +import com.oracle.graal.python.runtime.PythonOptions;
     import com.oracle.truffle.api.strings.TruffleString;
     
     public final class PythonFrozenModule {
    @@ -56,7 +57,7 @@ public final class PythonFrozenModule {
     
         private static byte[] getByteCode(String symbol) {
             try {
    -            InputStream resourceAsStream = PythonFrozenModule.class.getResourceAsStream("Frozen" + symbol + ".bin");
    +            InputStream resourceAsStream = PythonFrozenModule.class.getResourceAsStream("Frozen" + symbol + "." + getSuffix());
                 if (resourceAsStream != null) {
                     return resourceAsStream.readAllBytes();
                 }
    @@ -66,6 +67,14 @@ private static byte[] getByteCode(String symbol) {
             return null;
         }
     
    +    private static String getSuffix() {
    +        if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +            return "bin_dsl";
    +        } else {
    +            return "bin";
    +        }
    +    }
    +
         public PythonFrozenModule(String symbol, String originalName, boolean isPackage) {
             this(toTruffleStringUncached(originalName), getByteCode(symbol), isPackage);
         }
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    index 0ad74fb3a3..137c1d2b66 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/set/SetNodes.java
    @@ -54,6 +54,7 @@
     import com.oracle.graal.python.nodes.PRaiseNode;
     import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
     import com.oracle.graal.python.runtime.object.PFactory;
    +import com.oracle.truffle.api.bytecode.OperationProxy;
     import com.oracle.truffle.api.dsl.Bind;
     import com.oracle.truffle.api.dsl.Cached;
     import com.oracle.truffle.api.dsl.Cached.Exclusive;
    @@ -115,6 +116,7 @@ public static ConstructSetNode getUncached() {
         }
     
         @GenerateUncached
    +    @OperationProxy.Proxyable
         @SuppressWarnings("truffle-inlining")       // footprint reduction 92 -> 73
         public abstract static class AddNode extends PNodeWithContext {
             public abstract void execute(Frame frame, PSet self, Object o);
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java
    index 75f0390810..f707576c6d 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/superobject/SuperBuiltins.java
    @@ -90,6 +90,7 @@
     import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
     import com.oracle.graal.python.nodes.bytecode.FrameInfo;
     import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode;
    +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode;
     import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
     import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
     import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode.FrameSelector;
    @@ -100,6 +101,7 @@
     import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
     import com.oracle.graal.python.nodes.object.GetClassNode;
     import com.oracle.graal.python.nodes.object.IsForeignObjectNode;
    +import com.oracle.graal.python.runtime.PythonOptions;
     import com.oracle.graal.python.runtime.exception.PException;
     import com.oracle.graal.python.runtime.exception.PythonErrorType;
     import com.oracle.graal.python.runtime.object.PFactory;
    @@ -275,12 +277,17 @@ PNone initInPlace(VirtualFrame frame, SuperObject self, @SuppressWarnings("unuse
                             @Bind("this") Node inliningTarget,
                             @Shared @Cached PRaiseNode raiseNode,
                             @Shared @Cached CellBuiltins.GetRefNode getRefNode) {
    -            PBytecodeRootNode rootNode = (PBytecodeRootNode) getRootNode();
    -            Frame localFrame = frame;
    -            if (rootNode.getCodeUnit().isGeneratorOrCoroutine()) {
    -                localFrame = PArguments.getGeneratorFrame(frame);
    +            if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +                PBytecodeDSLRootNode rootNode = (PBytecodeDSLRootNode) getRootNode();
    +                return initFromLocalFrame(frame, inliningTarget, self, rootNode, frame, getRefNode, raiseNode);
    +            } else {
    +                PBytecodeRootNode rootNode = (PBytecodeRootNode) getRootNode();
    +                Frame localFrame = frame;
    +                if (rootNode.getCodeUnit().isGeneratorOrCoroutine()) {
    +                    localFrame = PArguments.getGeneratorFrame(frame);
    +                }
    +                return initFromLocalFrame(frame, inliningTarget, self, rootNode, localFrame, getRefNode, raiseNode);
                 }
    -            return initFromLocalFrame(frame, inliningTarget, self, rootNode, localFrame, getRefNode, raiseNode);
             }
     
             /**
    @@ -301,7 +308,11 @@ PNone init(VirtualFrame frame, SuperObject self, @SuppressWarnings("unused") PNo
                     throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_NO_CLASS);
                 }
                 FrameInfo frameInfo = (FrameInfo) locals.getFrameDescriptor().getInfo();
    -            return initFromLocalFrame(frame, inliningTarget, self, frameInfo.getRootNode(), locals, getRefNode, raiseNode);
    +            if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) {
    +                return initFromLocalFrame(frame, inliningTarget, self, (PBytecodeDSLRootNode) frameInfo.getRootNode(), locals, getRefNode, raiseNode);
    +            } else {
    +                return initFromLocalFrame(frame, inliningTarget, self, (PBytecodeRootNode) frameInfo.getRootNode(), locals, getRefNode, raiseNode);
    +            }
             }
     
             private PNone initFromLocalFrame(VirtualFrame frame, Node inliningTarget, SuperObject self, PBytecodeRootNode rootNode, Frame localFrame, CellBuiltins.GetRefNode getRefNode,
    @@ -322,6 +333,24 @@ private PNone initFromLocalFrame(VirtualFrame frame, Node inliningTarget, SuperO
                 return init(frame, self, cls, obj, inliningTarget, raiseNode);
             }
     
    +        private PNone initFromLocalFrame(VirtualFrame frame, Node inliningTarget, SuperObject self, PBytecodeDSLRootNode rootNode, Frame localFrame, CellBuiltins.GetRefNode getRefNode,
    +                        PRaiseNode raiseNode) {
    +            PCell classCell = rootNode.readClassCell(localFrame);
    +            if (classCell == null) {
    +                throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_NO_CLASS);
    +            }
    +            Object cls = getRefNode.execute(inliningTarget, classCell);
    +            if (cls == null) {
    +                // the cell is empty
    +                throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.SUPER_EMPTY_CLASS);
    +            }
    +            Object obj = rootNode.readSelf(localFrame);
    +            if (obj == null) {
    +                throw raiseNode.raise(inliningTarget, RuntimeError, ErrorMessages.NO_ARGS, "super()");
    +            }
    +            return init(frame, self, cls, obj, inliningTarget, raiseNode);
    +        }
    +
             @SuppressWarnings("unused")
             @Fallback
             PNone initFallback(Object self, Object cls, Object obj) {
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/LazyTraceback.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/LazyTraceback.java
    index a63b7d14b6..8de472f4bb 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/LazyTraceback.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/LazyTraceback.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2020, 2025, 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
    @@ -154,8 +154,8 @@ public static boolean elementWantedForTraceback(TruffleStackTraceElement element
             if (frame != null) {
                 // only include frames of non-builtin python functions
                 Object info = frame.getFrameDescriptor().getInfo();
    -            if (info instanceof FrameInfo) {
    -                return ((FrameInfo) info).getRootNode().frameIsVisibleToPython();
    +            if (info instanceof FrameInfo frameInfo) {
    +                return frameInfo.includeInTraceback();
                 }
             }
             return false;
    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java
    index eed52a94df..a08af605d8 100644
    --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java
    +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/MaterializeLazyTracebackNode.java
    @@ -72,7 +72,7 @@
      * frames that the exception has passed through during the unwinding plus the frame where it was
      * caught. It doesn't include the frames above it (to the top). Secondly, the traceback is never
      * frozen. The traceback accumulates more frames when the exception gets reraised. To correct the
    - * mismatch between Truffle and Python eception handling, we need to wrap {@link PException}s in
    + * mismatch between Truffle and Python exception handling, we need to wrap {@link PException}s in
      * {@link LazyTraceback} objects when caught and adhere to particular rules of exception handling
      * mentioned below.
      * 

    diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/PTraceback.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/PTraceback.java index 3d04a261ab..21011830be 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/PTraceback.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/PTraceback.java @@ -46,7 +46,10 @@ import com.oracle.graal.python.builtins.PythonBuiltinClassType; import com.oracle.graal.python.builtins.objects.frame.PFrame; import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.bytecode.BytecodeNode; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.strings.TruffleString; public final class PTraceback extends PythonBuiltinObject { @@ -56,6 +59,7 @@ public final class PTraceback extends PythonBuiltinObject { private PFrame.Reference frameInfo; private int lineno = UNKNOWN_LINE_NUMBER; private int bci = -1; + private BytecodeNode bytecodeNode = null; private int lasti = -1; private PTraceback next; private LazyTraceback lazyTraceback; @@ -107,13 +111,20 @@ public int getLineno() { public int getLasti(PFrame pFrame) { if (lasti == -1 && bci >= 0) { - lasti = pFrame.bciToLasti(bci); + Node location; + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + location = bytecodeNode; + } else { + location = pFrame.getLocation(); + } + lasti = PFrame.bciToLasti(bci, location); } return lasti; } - public void setBci(int bci) { + public void setLocation(int bci, BytecodeNode bytecodeNode) { this.bci = bci; + this.bytecodeNode = bytecodeNode; // nullable this.lasti = -1; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java index 4819bc14fb..6d1275e6e4 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/traceback/TracebackBuiltins.java @@ -193,14 +193,14 @@ static void doMaterialize(Node inliningTarget, PTraceback tb, if (LazyTraceback.elementWantedForTraceback(element)) { PFrame pFrame = materializeFrame(element, materializeFrameNode); next = PFactory.createTraceback(PythonLanguage.get(null), pFrame, pFrame.getLine(), next); - next.setBci(pFrame.getBci()); + next.setLocation(pFrame.getBci(), pFrame.getBytecodeNode()); pyIndex++; } } } if (lazyTraceback.catchingFrameWantedForTraceback()) { - tb.setBci(pException.getCatchBci()); - tb.setLineno(pException.getCatchRootNode().bciToLine(pException.getCatchBci())); + tb.setLocation(pException.getCatchBci(), pException.getBytecodeNode()); + tb.setLineno(pException.getCatchLine()); tb.setNext(next); } else { assert next != null; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/BytecodeCodeUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/BytecodeCodeUnit.java new file mode 100644 index 0000000000..76f7d7a8fc --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/BytecodeCodeUnit.java @@ -0,0 +1,717 @@ +/* + * Copyright (c) 2021, 2025, 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.compiler; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; + +import com.oracle.graal.python.builtins.PythonBuiltinClassType; +import com.oracle.graal.python.builtins.objects.bytes.BytesUtils; +import com.oracle.graal.python.builtins.objects.code.PCode; +import com.oracle.graal.python.builtins.objects.str.StringNodes; +import com.oracle.graal.python.compiler.OpCodes.CollectionBits; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.strings.TruffleString; + +public final class BytecodeCodeUnit extends CodeUnit { + private static final int DISASSEMBLY_NUM_COLUMNS = 8; + + // Note this is being mutated when quickening + @CompilationFinal(dimensions = 1) public final byte[] code; + @CompilationFinal(dimensions = 1) public final byte[] srcOffsetTable; + @CompilationFinal(dimensions = 1) public final long[] primitiveConstants; + @CompilationFinal(dimensions = 1) public final int[] exceptionHandlerRanges; + public final int stacksize; + public final int conditionProfileCount; + + /* Quickening data. See docs in PBytecodeRootNode */ + @CompilationFinal(dimensions = 1) public final byte[] outputCanQuicken; + @CompilationFinal(dimensions = 1) public final byte[] variableShouldUnbox; + @CompilationFinal(dimensions = 1) public final int[][] generalizeInputsMap; + @CompilationFinal(dimensions = 1) public final int[][] generalizeVarsMap; + + /* Lazily initialized source map */ + @CompilationFinal SourceMap sourceMap; + + public BytecodeCodeUnit(TruffleString name, TruffleString qualname, + int argCount, int kwOnlyArgCount, int positionalOnlyArgCount, int flags, + TruffleString[] names, TruffleString[] varnames, TruffleString[] cellvars, + TruffleString[] freevars, int[] cell2arg, Object[] constants, int startLine, int startColumn, + int endLine, int endColumn, + byte[] code, byte[] linetable, + long[] primitiveConstants, int[] exceptionHandlerRanges, int stacksize, int conditionProfileCount, + byte[] outputCanQuicken, byte[] variableShouldUnbox, int[][] generalizeInputsMap, int[][] generalizeVarsMap) { + super(name, qualname, argCount, kwOnlyArgCount, positionalOnlyArgCount, flags, names, varnames, cellvars, freevars, cell2arg, constants, startLine, startColumn, endLine, endColumn); + this.code = code; + this.srcOffsetTable = linetable; + this.primitiveConstants = primitiveConstants; + this.exceptionHandlerRanges = exceptionHandlerRanges; + this.stacksize = stacksize; + this.conditionProfileCount = conditionProfileCount; + this.outputCanQuicken = outputCanQuicken; + this.variableShouldUnbox = variableShouldUnbox; + this.generalizeInputsMap = generalizeInputsMap; + this.generalizeVarsMap = generalizeVarsMap; + } + + public SourceMap getSourceMap() { + if (sourceMap == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + sourceMap = new SourceMap(code, srcOffsetTable, startLine, startColumn); + } + return sourceMap; + } + + public int bciToLine(int bci) { + if (bci < 0 || bci >= code.length) { + return -1; + } + return getSourceMap().startLineMap[bci]; + } + + public int bciToColumn(int bci) { + if (bci < 0 || bci >= code.length) { + return -1; + } + return getSourceMap().startColumnMap[bci]; + } + + @Override + public String toString() { + return toString(false); + } + + public String toString(boolean quickened) { + StringBuilder sb = new StringBuilder(); + + HashMap lines = new HashMap<>(); + + sb.append("Disassembly of ").append(qualname).append(":\n"); + + List flagNames = new ArrayList<>(); + if (isGenerator()) { + flagNames.add("CO_GENERATOR"); + } + if (isCoroutine()) { + flagNames.add("CO_COROUTINE"); + } + if (isAsyncGenerator()) { + flagNames.add("CO_ASYNC_GENERATOR"); + } + if (!flagNames.isEmpty()) { + sb.append("Flags: ").append(String.join(" | ", flagNames)).append("\n"); + } + + int bci = 0; + int oparg = 0; + SourceMap map = getSourceMap(); + while (bci < code.length) { + int bcBCI = bci; + OpCodes opcode = OpCodes.fromOpCode(code[bci++]); + + if (!quickened) { + opcode = unquicken(opcode); + } + + String[] line = lines.computeIfAbsent(bcBCI, k -> new String[DISASSEMBLY_NUM_COLUMNS]); + line[0] = String.format("%3d:%-3d - %3d:%-3d", map.startLineMap[bcBCI], map.startColumnMap[bcBCI], map.endLineMap[bcBCI], map.endColumnMap[bcBCI]); + if (line[1] == null) { + line[1] = ""; + } + line[2] = String.valueOf(bcBCI); + line[3] = opcode.toString(); + byte[] followingArgs = PythonUtils.EMPTY_BYTE_ARRAY; + if (!opcode.hasArg()) { + line[4] = ""; + } else { + oparg |= Byte.toUnsignedInt(code[bci++]); + if (opcode.argLength > 1) { + followingArgs = new byte[opcode.argLength - 1]; + for (int i = 0; i < opcode.argLength - 1; i++) { + followingArgs[i] = code[bci++]; + } + } + line[4] = String.format("% 2d", oparg); + } + + while (true) { + switch (opcode) { + case EXTENDED_ARG: + line[4] = ""; + break; + case LOAD_BYTE: + line[4] = String.format("% 2d", (byte) oparg); + break; + case LOAD_CONST: + case LOAD_BIGINT: + case LOAD_STRING: + case LOAD_BYTES: + case LOAD_CONST_COLLECTION: + case MAKE_KEYWORD: { + Object constant = constants[oparg]; + if (constant instanceof CodeUnit) { + line[5] = ((CodeUnit) constant).qualname.toJavaStringUncached(); + } else { + if (constant instanceof TruffleString) { + line[5] = StringNodes.StringReprNode.getUncached().execute((TruffleString) constant).toJavaStringUncached(); + } else if (constant instanceof byte[]) { + byte[] bytes = (byte[]) constant; + line[5] = BytesUtils.bytesRepr(bytes, bytes.length); + } else if (constant instanceof int[]) { + line[5] = Arrays.toString((int[]) constant); + } else if (constant instanceof long[]) { + line[5] = Arrays.toString((long[]) constant); + } else if (constant instanceof boolean[]) { + line[5] = Arrays.toString((boolean[]) constant); + } else if (constant instanceof double[]) { + line[5] = Arrays.toString((double[]) constant); + } else if (constant instanceof Object[]) { + line[5] = Arrays.toString((Object[]) constant); + } else { + line[5] = Objects.toString(constant); + } + } + if (opcode == OpCodes.LOAD_CONST_COLLECTION) { + line[5] += " type " + collectionTypeToString(followingArgs[0]) + " into " + collectionKindToString(followingArgs[0]); + } + break; + } + case MAKE_FUNCTION: { + line[4] = String.format("% 2d", followingArgs[0]); + CodeUnit codeUnit = (CodeUnit) constants[oparg]; + line[5] = line[5] = codeUnit.qualname.toJavaStringUncached(); + break; + } + case LOAD_INT: + case LOAD_LONG: + line[5] = Objects.toString(primitiveConstants[oparg]); + break; + case LOAD_DOUBLE: + line[5] = Objects.toString(Double.longBitsToDouble(primitiveConstants[oparg])); + break; + case LOAD_COMPLEX: { + double[] num = (double[]) constants[oparg]; + if (num[0] == 0.0) { + line[5] = String.format("%gj", num[1]); + } else { + line[5] = String.format("%g%+gj", num[0], num[1]); + } + break; + } + case LOAD_CLOSURE: + case LOAD_DEREF: + case STORE_DEREF: + case DELETE_DEREF: + if (oparg >= cellvars.length) { + line[5] = freevars[oparg - cellvars.length].toJavaStringUncached(); + } else { + line[5] = cellvars[oparg].toJavaStringUncached(); + } + break; + case LOAD_FAST: + case STORE_FAST: + case DELETE_FAST: + line[5] = varnames[oparg].toJavaStringUncached(); + break; + case LOAD_NAME: + case LOAD_METHOD: + case STORE_NAME: + case DELETE_NAME: + case IMPORT_NAME: + case IMPORT_FROM: + case LOAD_GLOBAL: + case STORE_GLOBAL: + case DELETE_GLOBAL: + case LOAD_ATTR: + case STORE_ATTR: + case DELETE_ATTR: + line[5] = names[oparg].toJavaStringUncached(); + break; + case FORMAT_VALUE: { + int type = oparg & FormatOptions.FVC_MASK; + switch (type) { + case FormatOptions.FVC_STR: + line[5] = "STR"; + break; + case FormatOptions.FVC_REPR: + line[5] = "REPR"; + break; + case FormatOptions.FVC_ASCII: + line[5] = "ASCII"; + break; + case FormatOptions.FVC_NONE: + line[5] = "NONE"; + break; + } + if ((oparg & FormatOptions.FVS_MASK) == FormatOptions.FVS_HAVE_SPEC) { + line[5] += " + SPEC"; + } + break; + } + case CALL_METHOD: { + line[4] = String.format("% 2d", oparg); + break; + } + case UNARY_OP: + line[5] = UnaryOps.values()[oparg].toString(); + break; + case BINARY_OP: + line[5] = BinaryOps.values()[oparg].toString(); + break; + case COLLECTION_FROM_STACK: + case COLLECTION_ADD_STACK: + case COLLECTION_FROM_COLLECTION: + case COLLECTION_ADD_COLLECTION: + case ADD_TO_COLLECTION: + line[4] = String.format("% 2d", CollectionBits.elementCount(oparg)); + line[5] = collectionKindToString(oparg); + break; + case UNPACK_EX: + line[5] = String.format("%d, %d", oparg, Byte.toUnsignedInt(followingArgs[0])); + break; + case JUMP_BACKWARD: + lines.computeIfAbsent(bcBCI - oparg, k -> new String[DISASSEMBLY_NUM_COLUMNS])[1] = ">>"; + line[5] = String.format("to %d", bcBCI - oparg); + break; + case FOR_ITER: + case JUMP_FORWARD: + case POP_AND_JUMP_IF_FALSE: + case POP_AND_JUMP_IF_TRUE: + case JUMP_IF_FALSE_OR_POP: + case JUMP_IF_TRUE_OR_POP: + case MATCH_EXC_OR_JUMP: + case SEND: + case THROW: + lines.computeIfAbsent(bcBCI + oparg, k -> new String[DISASSEMBLY_NUM_COLUMNS])[1] = ">>"; + line[5] = String.format("to %d", bcBCI + oparg); + break; + default: + if (opcode.quickens != null) { + opcode = opcode.quickens; + continue; + } + } + if (opcode == OpCodes.EXTENDED_ARG) { + oparg <<= 8; + } else { + oparg = 0; + } + break; + } + } + + for (int i = 0; i < exceptionHandlerRanges.length; i += 4) { + int start = exceptionHandlerRanges[i]; + int stop = exceptionHandlerRanges[i + 1]; + int handler = exceptionHandlerRanges[i + 2]; + int stackAtHandler = exceptionHandlerRanges[i + 3]; + String[] line = lines.get(handler); + assert line != null; + String handlerStr = String.format("exc handler %d - %d; stack: %d", start, stop, stackAtHandler); + if (line[6] == null) { + line[6] = handlerStr; + } else { + line[6] += " | " + handlerStr; + } + } + + for (bci = 0; bci < code.length; bci++) { + String[] line = lines.get(bci); + if (line != null) { + line[5] = line[5] == null ? "" : String.format("(%s)", line[5]); + line[6] = line[6] == null ? "" : String.format("(%s)", line[6]); + line[7] = ""; + if (outputCanQuicken != null && (outputCanQuicken[bci] != 0 || generalizeInputsMap[bci] != null)) { + StringBuilder quickenSb = new StringBuilder(); + if (outputCanQuicken[bci] != 0) { + quickenSb.append("can quicken"); + } + if (generalizeInputsMap[bci] != null) { + if (quickenSb.length() > 0) { + quickenSb.append(", "); + } + quickenSb.append("generalizes: "); + for (int i = 0; i < generalizeInputsMap[bci].length; i++) { + if (i > 0) { + quickenSb.append(", "); + } + quickenSb.append(generalizeInputsMap[bci][i]); + } + } + line[7] = quickenSb.toString(); + } + String formatted = String.format("%-8s %2s %4s %-32s %-3s %-32s %s %s", (Object[]) line); + sb.append(formatted.stripTrailing()); + sb.append('\n'); + } + } + + for (Object c : constants) { + if (c instanceof CodeUnit) { + sb.append('\n'); + sb.append(c); + } + } + + return sb.toString(); + } + + private static String collectionKindToString(int oparg) { + switch (CollectionBits.collectionKind(oparg)) { + case CollectionBits.KIND_LIST: + return "list"; + case CollectionBits.KIND_TUPLE: + return "tuple"; + case CollectionBits.KIND_SET: + return "set"; + case CollectionBits.KIND_DICT: + return "dict"; + case CollectionBits.KIND_KWORDS: + return "PKeyword[]"; + case CollectionBits.KIND_OBJECT: + return "Object[]"; + } + throw new IllegalStateException("Unknown kind"); + } + + private static String collectionTypeToString(int oparg) { + switch (CollectionBits.elementType(oparg)) { + case CollectionBits.ELEMENT_BOOLEAN: + return "boolean"; + case CollectionBits.ELEMENT_INT: + return "int"; + case CollectionBits.ELEMENT_LONG: + return "long"; + case CollectionBits.ELEMENT_DOUBLE: + return "double"; + case CollectionBits.ELEMENT_OBJECT: + return "Object"; + } + throw new IllegalStateException("Unknown type"); + } + + public static final int LINE_TO_BCI_LINE_AFTER_CODEBLOCK = -1; + public static final int LINE_TO_BCI_LINE_BEFORE_CODEBLOCK = -2; + + // -1 for line after the code block, -2 for line before the code block, line number otherwise + public int lineToBci(int line) { + if (startLine == line) { + return 0; + } + if ((flags & PCode.CO_GRAALPYHON_MODULE) != 0 && line < startLine) { + // allow jump to the first line of a file, even if it is a comment + return 0; + } + int[] map = getSourceMap().startLineMap; + int bestBci = LINE_TO_BCI_LINE_AFTER_CODEBLOCK; + int lineDiff = Integer.MAX_VALUE; + boolean afterFirst = false; + for (int bci = 0; bci < map.length; ++bci) { + if (map[bci] >= line) { + int lineDiff2 = map[bci] - line; + // the first bci found is the start of the line + if (lineDiff2 < lineDiff) { + bestBci = bci; + lineDiff = lineDiff2; + } + } + if (map[bci] > 0 && map[bci] <= line) { + // the line is actually within the codeblock. + afterFirst = true; + } + } + // bestBci being -1 means the line is outside the code block + return afterFirst ? bestBci : LINE_TO_BCI_LINE_BEFORE_CODEBLOCK; + } + + public enum StackItem { + With("the body of a with statement"), + Iterable("the body of a for loop"), + Except("an 'except' block as there's no exception"), + Object("Incompatible stack"); + + public final String error; + + StackItem(String error) { + this.error = error; + } + + ArrayList push(ArrayList v) { + ArrayList ret = v == null ? new ArrayList<>() : new ArrayList<>(v); + ret.add(this); + return ret; + } + } + + private void setNextStack(ArrayDeque todo, List> stacks, int target, ArrayList value) { + ArrayList blocksAtTarget = stacks.get(target); + if (blocksAtTarget == null) { + stacks.set(target, value); + todo.addLast(target); + } else { + assert value.equals(blocksAtTarget) : "found conflicting stacks depending on code path: " + this.name + "\t at " + target; + } + } + + private static ArrayList popStack(ArrayList blocks) { + assert blocks != null : "Pop from null stack"; + assert blocks.size() >= 1 : "Pop from empty stack"; + return new ArrayList<>(blocks.subList(0, blocks.size() - 1)); + } + + // returns null if the jump is fine + public String checkJump(Node node, List> stackElems, int from, int to) { + ArrayList blkFrom = stackElems.get(from); + if (blkFrom == null) { + // this should not happen + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, bciToLine(from)); + } + ArrayList blkTo = stackElems.get(to); + if (blkTo == null) { + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, bciToLine(from)); + } + if (blkTo.size() > blkFrom.size()) { + return blkTo.get(blkTo.size() - 1).error; + } + for (int i = blkTo.size() - 1; i >= 0; --i) { + if (blkTo.get(i) != blkFrom.get(i)) { + return blkTo.get(i).error; + } + } + return null; + } + + public List> computeStackElems() { + List> blocks = new ArrayList<>(Collections.nCopies(code.length + 1, null)); + blocks.set(0, new ArrayList<>()); + ArrayDeque todo = new ArrayDeque<>(); + todo.addFirst(0); + while (!todo.isEmpty()) { + int firstBci = todo.removeLast(); + assert blocks.get(firstBci) != null : "Reached block without determining its stack state"; + opCodeAt(code, firstBci, (bci, op, oparg, followingArgs) -> { + // firstBci can be different from bci if EXTEND_ARG is used + // the stack is kept both at firstBci and bci + ArrayList next = blocks.get(firstBci); + if (firstBci != bci) { + blocks.set(bci, next); + } + for (int j = 0; j < exceptionHandlerRanges.length; j += 4) { + int start = exceptionHandlerRanges[j]; + int handler = exceptionHandlerRanges[j + 2]; + int stack = exceptionHandlerRanges[j + 3]; + if (start == bci) { + ArrayList handlerStack = StackItem.Except.push(new ArrayList<>(blocks.get(bci).subList(0, stack))); + // an exception handler is like a jump + // the except block is added in the lines below + setNextStack(todo, blocks, handler, handlerStack); + } + } + switch (op) { + case GET_ITER: + case GET_AITER: + next = StackItem.Iterable.push(popStack(blocks.get(bci))); + setNextStack(todo, blocks, bci + 1, next); + break; + case FOR_ITER: + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), StackItem.Object.push(next)); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, true), popStack(next)); + break; + case PUSH_EXC_INFO: + next = StackItem.Except.push(StackItem.Object.push(popStack(blocks.get(bci)))); + setNextStack(todo, blocks, bci + 1, next); + break; + case MATCH_EXC_OR_JUMP: + next = popStack(next); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, true), next); + break; + case SETUP_WITH: + case SETUP_AWITH: + next = StackItem.Object.push(StackItem.With.push(blocks.get(bci))); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + break; + case GET_AEXIT_CORO: + next = StackItem.Object.push(StackItem.Except.push(popStack(popStack(popStack(blocks.get(bci)))))); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + break; + case DUP_TOP: + next = next.get(next.size() - 1).push(next); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + break; + case ROT_TWO: { + StackItem top = next.get(next.size() - 1); + StackItem belowTop = next.get(next.size() - 2); + next = belowTop.push(top.push(popStack(popStack(next)))); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + break; + } + case ROT_THREE: { + StackItem top = next.get(next.size() - 1); + StackItem second = next.get(next.size() - 2); + StackItem third = next.get(next.size() - 3); + next = second.push(third.push(top.push(top.push(popStack(popStack(popStack(next))))))); + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); + break; + } + case LOAD_NONE: + opCodeAt(code, op.getNextBci(bci, oparg, false), (ignored, nextOp, ignored2, ignored3) -> { + // Usually, when compiling bytecode around exception handlers, the code + // is generated twice, once for the path with no exception, and + // once for the path with the exception. However, when generating code + // for a with statement exit, the code is generated as follows (and in a + // similar manner for async with). + // ... + // LOAD_NONE + // EXIT_WITH (exception handler starts here) + // ... + // This means that setting the stack at EXIT_WITH to have Object on top, + // as LOAD_NONE usually would, would cause a conflict with the exception + // handler starting at that position, which has the stack top be an + // Exception. + if (nextOp != OpCodes.GET_AEXIT_CORO && nextOp != OpCodes.EXIT_WITH) { + setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), StackItem.Object.push(blocks.get(bci))); + } + }); + break; + + default: { + int nextWJump = op.getNextBci(bci, oparg, true); + int nextWOJump = op.getNextBci(bci, oparg, false); + int stackLostWJump = op.getNumberOfConsumedStackItems(oparg, followingArgs, true); + int stackLostWOJump = op.getNumberOfConsumedStackItems(oparg, followingArgs, false); + int stackGainWJump = op.getNumberOfProducedStackItems(oparg, followingArgs, true); + int stackGainWOJump = op.getNumberOfProducedStackItems(oparg, followingArgs, false); + handleGeneralOp(blocks, todo, bci, nextWJump, stackLostWJump, stackGainWJump); + if (nextWJump != nextWOJump) { + handleGeneralOp(blocks, todo, bci, nextWOJump, stackLostWOJump, stackGainWOJump); + } + break; + } + } + }); + } + return blocks; + } + + private void handleGeneralOp(List> blocks, ArrayDeque todo, int bci, int next, int stackLost, int stackGain) { + if (next >= 0) { + ArrayList blocksHere = new ArrayList<>(blocks.get(bci)); + for (int k = 0; k < stackLost; ++k) { + blocksHere.remove(blocksHere.size() - 1); + } + for (int k = 0; k < stackGain; ++k) { + blocksHere.add(StackItem.Object); + } + setNextStack(todo, blocks, next, blocksHere); + } + } + + @FunctionalInterface + public interface BytecodeAction { + void run(int bci, OpCodes op, int oparg, byte[] followingArgs); + } + + // returns the following bci + private static int opCodeAt(byte[] bytecode, int bci, BytecodeAction action) { + int oparg = 0; + OpCodes op = OpCodes.fromOpCode(bytecode[bci]); + while (op == OpCodes.EXTENDED_ARG) { + oparg |= Byte.toUnsignedInt(bytecode[bci + 1]); + oparg <<= 8; + bci += 2; + op = OpCodes.fromOpCode(bytecode[bci]); + } + op = unquicken(op); + byte[] followingArgs = null; + if (op.argLength > 0) { + oparg |= Byte.toUnsignedInt(bytecode[bci + 1]); + if (op.argLength > 1) { + followingArgs = new byte[op.argLength - 1]; + System.arraycopy(bytecode, bci + 2, followingArgs, 0, followingArgs.length); + } + } + action.run(bci, op, oparg, followingArgs); + return bci + op.length(); + } + + public static void iterateBytecode(byte[] bytecode, BytecodeAction action) { + for (int bci = 0; bci < bytecode.length;) { + bci = opCodeAt(bytecode, bci, action); + } + } + + public void iterateBytecode(BytecodeAction action) { + iterateBytecode(code, action); + } + + public byte[] getBytecodeForSerialization() { + byte[] bytecode = Arrays.copyOf(code, code.length); + for (int bci = 0; bci < bytecode.length;) { + OpCodes op = OpCodes.fromOpCode(bytecode[bci]); + bytecode[bci] = (byte) unquicken(op).ordinal(); + bci += op.length(); + } + return bytecode; + } + + private static OpCodes unquicken(OpCodes op) { + if (op.quickens == null) { + return op; + } + return switch (op.quickens) { + // These are already quickened by the compiler, so keep them quickened + // See CompilationUnit.emitBytecode + case LOAD_BYTE, LOAD_INT, LOAD_LONG, LOAD_DOUBLE, LOAD_TRUE, LOAD_FALSE -> op; + default -> op.quickens; + }; + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java index 0025ae6f37..a1b795320b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CodeUnit.java @@ -40,25 +40,11 @@ */ package com.oracle.graal.python.compiler; -import java.util.ArrayDeque; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.bytes.BytesUtils; import com.oracle.graal.python.builtins.objects.code.PCode; -import com.oracle.graal.python.builtins.objects.str.StringNodes; -import com.oracle.graal.python.compiler.OpCodes.CollectionBits; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.strings.TruffleString; @@ -68,9 +54,7 @@ * bytecode and all the related data, like constants or exception handler ranges. It doesn't contain * the filename to make it easier to keep in native images. */ -public final class CodeUnit { - private static final int DISASSEMBLY_NUM_COLUMNS = 8; - +public abstract class CodeUnit { public final TruffleString name; public final TruffleString qualname; @@ -78,11 +62,6 @@ public final class CodeUnit { public final int kwOnlyArgCount; public final int positionalOnlyArgCount; - public final int stacksize; - - // Note this is being mutated when quickening - @CompilationFinal(dimensions = 1) public final byte[] code; - @CompilationFinal(dimensions = 1) public final byte[] srcOffsetTable; public final int flags; @CompilationFinal(dimensions = 1) public final TruffleString[] names; @@ -93,42 +72,22 @@ public final class CodeUnit { @CompilationFinal(dimensions = 1) public final int[] arg2cell; @CompilationFinal(dimensions = 1) public final Object[] constants; - @CompilationFinal(dimensions = 1) public final long[] primitiveConstants; - - @CompilationFinal(dimensions = 1) public final int[] exceptionHandlerRanges; - - public final int conditionProfileCount; public final int startLine; public final int startColumn; public final int endLine; public final int endColumn; - /* Lazily initialized source map */ - @CompilationFinal SourceMap sourceMap; - - /* Quickening data. See docs in PBytecodeRootNode */ - @CompilationFinal(dimensions = 1) public final byte[] outputCanQuicken; - @CompilationFinal(dimensions = 1) public final byte[] variableShouldUnbox; - @CompilationFinal(dimensions = 1) public final int[][] generalizeInputsMap; - @CompilationFinal(dimensions = 1) public final int[][] generalizeVarsMap; - public CodeUnit(TruffleString name, TruffleString qualname, - int argCount, int kwOnlyArgCount, int positionalOnlyArgCount, int stacksize, - byte[] code, byte[] linetable, int flags, - TruffleString[] names, TruffleString[] varnames, TruffleString[] cellvars, TruffleString[] freevars, int[] cell2arg, - Object[] constants, long[] primitiveConstants, - int[] exceptionHandlerRanges, int conditionProfileCount, - int startLine, int startColumn, int endLine, int endColumn, - byte[] outputCanQuicken, byte[] variableShouldUnbox, int[][] generalizeInputsMap, int[][] generalizeVarsMap) { + int argCount, int kwOnlyArgCount, int positionalOnlyArgCount, int flags, + TruffleString[] names, TruffleString[] varnames, TruffleString[] cellvars, + TruffleString[] freevars, int[] cell2arg, Object[] constants, int startLine, int startColumn, + int endLine, int endColumn) { this.name = name; this.qualname = qualname != null ? qualname : name; this.argCount = argCount; this.kwOnlyArgCount = kwOnlyArgCount; this.positionalOnlyArgCount = positionalOnlyArgCount; - this.stacksize = stacksize; - this.code = code; - this.srcOffsetTable = linetable; this.flags = flags; this.names = names; this.varnames = varnames; @@ -147,39 +106,11 @@ public CodeUnit(TruffleString name, TruffleString qualname, } this.arg2cell = arg2cellValue; this.constants = constants; - this.primitiveConstants = primitiveConstants; - this.exceptionHandlerRanges = exceptionHandlerRanges; - this.conditionProfileCount = conditionProfileCount; + this.startLine = startLine; this.startColumn = startColumn; this.endLine = endLine; this.endColumn = endColumn; - this.outputCanQuicken = outputCanQuicken; - this.variableShouldUnbox = variableShouldUnbox; - this.generalizeInputsMap = generalizeInputsMap; - this.generalizeVarsMap = generalizeVarsMap; - } - - public SourceMap getSourceMap() { - if (sourceMap == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - sourceMap = new SourceMap(code, srcOffsetTable, startLine, startColumn); - } - return sourceMap; - } - - public int bciToLine(int bci) { - if (bci < 0 || bci >= code.length) { - return -1; - } - return getSourceMap().startLineMap[bci]; - } - - public int bciToColumn(int bci) { - if (bci < 0 || bci >= code.length) { - return -1; - } - return getSourceMap().startColumnMap[bci]; } public SourceSection getSourceSection(Source source) { @@ -225,595 +156,15 @@ public int getTotalArgCount() { return count; } - @SuppressWarnings("fallthrough") - @Override - public String toString() { - return toString(false); - } - - public String toString(boolean quickened) { - StringBuilder sb = new StringBuilder(); - - HashMap lines = new HashMap<>(); - - sb.append("Disassembly of ").append(qualname).append(":\n"); - - List flagNames = new ArrayList<>(); - if (isGenerator()) { - flagNames.add("CO_GENERATOR"); - } - if (isCoroutine()) { - flagNames.add("CO_COROUTINE"); - } - if (isAsyncGenerator()) { - flagNames.add("CO_ASYNC_GENERATOR"); - } - if (!flagNames.isEmpty()) { - sb.append("Flags: ").append(String.join(" | ", flagNames)).append("\n"); - } - - int bci = 0; - int oparg = 0; - SourceMap map = getSourceMap(); - while (bci < code.length) { - int bcBCI = bci; - OpCodes opcode = OpCodes.fromOpCode(code[bci++]); - - if (!quickened) { - opcode = unquicken(opcode); - } - - String[] line = lines.computeIfAbsent(bcBCI, k -> new String[DISASSEMBLY_NUM_COLUMNS]); - line[0] = String.format("%3d:%-3d - %3d:%-3d", map.startLineMap[bcBCI], map.startColumnMap[bcBCI], map.endLineMap[bcBCI], map.endColumnMap[bcBCI]); - if (line[1] == null) { - line[1] = ""; - } - line[2] = String.valueOf(bcBCI); - line[3] = opcode.toString(); - byte[] followingArgs = PythonUtils.EMPTY_BYTE_ARRAY; - if (!opcode.hasArg()) { - line[4] = ""; - } else { - oparg |= Byte.toUnsignedInt(code[bci++]); - if (opcode.argLength > 1) { - followingArgs = new byte[opcode.argLength - 1]; - for (int i = 0; i < opcode.argLength - 1; i++) { - followingArgs[i] = code[bci++]; - } - } - line[4] = String.format("% 2d", oparg); - } - - while (true) { - switch (opcode) { - case EXTENDED_ARG: - line[4] = ""; - break; - case LOAD_BYTE: - line[4] = String.format("% 2d", (byte) oparg); - break; - case LOAD_CONST: - case LOAD_BIGINT: - case LOAD_STRING: - case LOAD_BYTES: - case LOAD_CONST_COLLECTION: - case MAKE_KEYWORD: { - Object constant = constants[oparg]; - if (constant instanceof CodeUnit) { - line[5] = ((CodeUnit) constant).qualname.toJavaStringUncached(); - } else { - if (constant instanceof TruffleString) { - line[5] = StringNodes.StringReprNode.getUncached().execute((TruffleString) constant).toJavaStringUncached(); - } else if (constant instanceof byte[]) { - byte[] bytes = (byte[]) constant; - line[5] = BytesUtils.bytesRepr(bytes, bytes.length); - } else if (constant instanceof int[]) { - line[5] = Arrays.toString((int[]) constant); - } else if (constant instanceof long[]) { - line[5] = Arrays.toString((long[]) constant); - } else if (constant instanceof boolean[]) { - line[5] = Arrays.toString((boolean[]) constant); - } else if (constant instanceof double[]) { - line[5] = Arrays.toString((double[]) constant); - } else if (constant instanceof Object[]) { - line[5] = Arrays.toString((Object[]) constant); - } else { - line[5] = Objects.toString(constant); - } - } - if (opcode == OpCodes.LOAD_CONST_COLLECTION) { - line[5] += " type " + collectionTypeToString(followingArgs[0]) + " into " + collectionKindToString(followingArgs[0]); - } - break; - } - case MAKE_FUNCTION: { - line[4] = String.format("% 2d", followingArgs[0]); - CodeUnit codeUnit = (CodeUnit) constants[oparg]; - line[5] = line[5] = codeUnit.qualname.toJavaStringUncached(); - break; - } - case LOAD_INT: - case LOAD_LONG: - line[5] = Objects.toString(primitiveConstants[oparg]); - break; - case LOAD_DOUBLE: - line[5] = Objects.toString(Double.longBitsToDouble(primitiveConstants[oparg])); - break; - case LOAD_COMPLEX: { - double[] num = (double[]) constants[oparg]; - if (num[0] == 0.0) { - line[5] = String.format("%gj", num[1]); - } else { - line[5] = String.format("%g%+gj", num[0], num[1]); - } - break; - } - case LOAD_CLOSURE: - case LOAD_DEREF: - case STORE_DEREF: - case DELETE_DEREF: - if (oparg >= cellvars.length) { - line[5] = freevars[oparg - cellvars.length].toJavaStringUncached(); - } else { - line[5] = cellvars[oparg].toJavaStringUncached(); - } - break; - case LOAD_FAST: - case STORE_FAST: - case DELETE_FAST: - line[5] = varnames[oparg].toJavaStringUncached(); - break; - case LOAD_NAME: - case LOAD_METHOD: - case STORE_NAME: - case DELETE_NAME: - case IMPORT_NAME: - case IMPORT_FROM: - case LOAD_GLOBAL: - case STORE_GLOBAL: - case DELETE_GLOBAL: - case LOAD_ATTR: - case STORE_ATTR: - case DELETE_ATTR: - line[5] = names[oparg].toJavaStringUncached(); - break; - case FORMAT_VALUE: { - int type = oparg & FormatOptions.FVC_MASK; - switch (type) { - case FormatOptions.FVC_STR: - line[5] = "STR"; - break; - case FormatOptions.FVC_REPR: - line[5] = "REPR"; - break; - case FormatOptions.FVC_ASCII: - line[5] = "ASCII"; - break; - case FormatOptions.FVC_NONE: - line[5] = "NONE"; - break; - } - if ((oparg & FormatOptions.FVS_MASK) == FormatOptions.FVS_HAVE_SPEC) { - line[5] += " + SPEC"; - } - break; - } - case CALL_METHOD: { - line[4] = String.format("% 2d", oparg); - break; - } - case UNARY_OP: - line[5] = UnaryOps.values()[oparg].toString(); - break; - case BINARY_OP: - line[5] = BinaryOps.values()[oparg].toString(); - break; - case COLLECTION_FROM_STACK: - case COLLECTION_ADD_STACK: - case COLLECTION_FROM_COLLECTION: - case COLLECTION_ADD_COLLECTION: - case ADD_TO_COLLECTION: - line[4] = String.format("% 2d", CollectionBits.elementCount(oparg)); - line[5] = collectionKindToString(oparg); - break; - case UNPACK_EX: - line[5] = String.format("%d, %d", oparg, Byte.toUnsignedInt(followingArgs[0])); - break; - case JUMP_BACKWARD: - lines.computeIfAbsent(bcBCI - oparg, k -> new String[DISASSEMBLY_NUM_COLUMNS])[1] = ">>"; - line[5] = String.format("to %d", bcBCI - oparg); - break; - case FOR_ITER: - case JUMP_FORWARD: - case POP_AND_JUMP_IF_FALSE: - case POP_AND_JUMP_IF_TRUE: - case JUMP_IF_FALSE_OR_POP: - case JUMP_IF_TRUE_OR_POP: - case MATCH_EXC_OR_JUMP: - case SEND: - case THROW: - lines.computeIfAbsent(bcBCI + oparg, k -> new String[DISASSEMBLY_NUM_COLUMNS])[1] = ">>"; - line[5] = String.format("to %d", bcBCI + oparg); - break; - default: - if (opcode.quickens != null) { - opcode = opcode.quickens; - continue; - } - } - if (opcode == OpCodes.EXTENDED_ARG) { - oparg <<= 8; - } else { - oparg = 0; - } - break; - } - } - - for (int i = 0; i < exceptionHandlerRanges.length; i += 4) { - int start = exceptionHandlerRanges[i]; - int stop = exceptionHandlerRanges[i + 1]; - int handler = exceptionHandlerRanges[i + 2]; - int stackAtHandler = exceptionHandlerRanges[i + 3]; - String[] line = lines.get(handler); - assert line != null; - String handlerStr = String.format("exc handler %d - %d; stack: %d", start, stop, stackAtHandler); - if (line[6] == null) { - line[6] = handlerStr; - } else { - line[6] += " | " + handlerStr; - } - } - - for (bci = 0; bci < code.length; bci++) { - String[] line = lines.get(bci); - if (line != null) { - line[5] = line[5] == null ? "" : String.format("(%s)", line[5]); - line[6] = line[6] == null ? "" : String.format("(%s)", line[6]); - line[7] = ""; - if (outputCanQuicken != null && (outputCanQuicken[bci] != 0 || generalizeInputsMap[bci] != null)) { - StringBuilder quickenSb = new StringBuilder(); - if (outputCanQuicken[bci] != 0) { - quickenSb.append("can quicken"); - } - if (generalizeInputsMap[bci] != null) { - if (quickenSb.length() > 0) { - quickenSb.append(", "); - } - quickenSb.append("generalizes: "); - for (int i = 0; i < generalizeInputsMap[bci].length; i++) { - if (i > 0) { - quickenSb.append(", "); - } - quickenSb.append(generalizeInputsMap[bci][i]); - } - } - line[7] = quickenSb.toString(); - } - String formatted = String.format("%-8s %2s %4s %-32s %-3s %-32s %s %s", (Object[]) line); - sb.append(formatted.stripTrailing()); - sb.append('\n'); - } - } - - for (Object c : constants) { - if (c instanceof CodeUnit) { - sb.append('\n'); - sb.append(c); - } - } - - return sb.toString(); - } - - private static String collectionKindToString(int oparg) { - switch (CollectionBits.collectionKind(oparg)) { - case CollectionBits.KIND_LIST: - return "list"; - case CollectionBits.KIND_TUPLE: - return "tuple"; - case CollectionBits.KIND_SET: - return "set"; - case CollectionBits.KIND_DICT: - return "dict"; - case CollectionBits.KIND_KWORDS: - return "PKeyword[]"; - case CollectionBits.KIND_OBJECT: - return "Object[]"; - } - throw new IllegalStateException("Unknown kind"); - } - - private static String collectionTypeToString(int oparg) { - switch (CollectionBits.elementType(oparg)) { - case CollectionBits.ELEMENT_BOOLEAN: - return "boolean"; - case CollectionBits.ELEMENT_INT: - return "int"; - case CollectionBits.ELEMENT_LONG: - return "long"; - case CollectionBits.ELEMENT_DOUBLE: - return "double"; - case CollectionBits.ELEMENT_OBJECT: - return "Object"; - } - throw new IllegalStateException("Unknown type"); - } - - public static final int LINE_TO_BCI_LINE_AFTER_CODEBLOCK = -1; - public static final int LINE_TO_BCI_LINE_BEFORE_CODEBLOCK = -2; - - // -1 for line after the code block, -2 for line before the code block, line number otherwise - public int lineToBci(int line) { - if (startLine == line) { - return 0; - } - if ((flags & PCode.CO_GRAALPYHON_MODULE) != 0 && line < startLine) { - // allow jump to the first line of a file, even if it is a comment - return 0; - } - int[] map = getSourceMap().startLineMap; - int bestBci = LINE_TO_BCI_LINE_AFTER_CODEBLOCK; - int lineDiff = Integer.MAX_VALUE; - boolean afterFirst = false; - for (int bci = 0; bci < map.length; ++bci) { - if (map[bci] >= line) { - int lineDiff2 = map[bci] - line; - // the first bci found is the start of the line - if (lineDiff2 < lineDiff) { - bestBci = bci; - lineDiff = lineDiff2; - } - } - if (map[bci] > 0 && map[bci] <= line) { - // the line is actually within the codeblock. - afterFirst = true; - } - } - // bestBci being -1 means the line is outside the code block - return afterFirst ? bestBci : LINE_TO_BCI_LINE_BEFORE_CODEBLOCK; - } - - public enum StackItem { - With("the body of a with statement"), - Iterable("the body of a for loop"), - Except("an 'except' block as there's no exception"), - Object("Incompatible stack"); - - public final String error; - - StackItem(String error) { - this.error = error; - } - - ArrayList push(ArrayList v) { - ArrayList ret = v == null ? new ArrayList<>() : new ArrayList<>(v); - ret.add(this); - return ret; - } - } - - private void setNextStack(ArrayDeque todo, List> stacks, int target, ArrayList value) { - ArrayList blocksAtTarget = stacks.get(target); - if (blocksAtTarget == null) { - stacks.set(target, value); - todo.addLast(target); - } else { - assert value.equals(blocksAtTarget) : "found conflicting stacks depending on code path: " + this.name + "\t at " + target; - } - } - - private static ArrayList popStack(ArrayList blocks) { - assert blocks != null : "Pop from null stack"; - assert blocks.size() >= 1 : "Pop from empty stack"; - return new ArrayList<>(blocks.subList(0, blocks.size() - 1)); - } - - // returns null if the jump is fine - public String checkJump(Node node, List> stackElems, int from, int to) { - ArrayList blkFrom = stackElems.get(from); - if (blkFrom == null) { - // this should not happen - throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, bciToLine(from)); - } - ArrayList blkTo = stackElems.get(to); - if (blkTo == null) { - throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, bciToLine(from)); - } - if (blkTo.size() > blkFrom.size()) { - return blkTo.get(blkTo.size() - 1).error; - } - for (int i = blkTo.size() - 1; i >= 0; --i) { - if (blkTo.get(i) != blkFrom.get(i)) { - return blkTo.get(i).error; - } - } - return null; - } - - public List> computeStackElems() { - List> blocks = new ArrayList<>(Collections.nCopies(code.length + 1, null)); - blocks.set(0, new ArrayList<>()); - ArrayDeque todo = new ArrayDeque<>(); - todo.addFirst(0); - while (!todo.isEmpty()) { - int firstBci = todo.removeLast(); - assert blocks.get(firstBci) != null : "Reached block without determining its stack state"; - opCodeAt(code, firstBci, (bci, op, oparg, followingArgs) -> { - // firstBci can be different from bci if EXTEND_ARG is used - // the stack is kept both at firstBci and bci - ArrayList next = blocks.get(firstBci); - if (firstBci != bci) { - blocks.set(bci, next); - } - for (int j = 0; j < exceptionHandlerRanges.length; j += 4) { - int start = exceptionHandlerRanges[j]; - int handler = exceptionHandlerRanges[j + 2]; - int stack = exceptionHandlerRanges[j + 3]; - if (start == bci) { - ArrayList handlerStack = StackItem.Except.push(new ArrayList<>(blocks.get(bci).subList(0, stack))); - // an exception handler is like a jump - // the except block is added in the lines below - setNextStack(todo, blocks, handler, handlerStack); - } - } - switch (op) { - case GET_ITER: - case GET_AITER: - next = StackItem.Iterable.push(popStack(blocks.get(bci))); - setNextStack(todo, blocks, bci + 1, next); - break; - case FOR_ITER: - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), StackItem.Object.push(next)); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, true), popStack(next)); - break; - case PUSH_EXC_INFO: - next = StackItem.Except.push(StackItem.Object.push(popStack(blocks.get(bci)))); - setNextStack(todo, blocks, bci + 1, next); - break; - case MATCH_EXC_OR_JUMP: - next = popStack(next); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, true), next); - break; - case SETUP_WITH: - case SETUP_AWITH: - next = StackItem.Object.push(StackItem.With.push(blocks.get(bci))); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - break; - case GET_AEXIT_CORO: - next = StackItem.Object.push(StackItem.Except.push(popStack(popStack(popStack(blocks.get(bci)))))); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - break; - case DUP_TOP: - next = next.get(next.size() - 1).push(next); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - break; - case ROT_TWO: { - StackItem top = next.get(next.size() - 1); - StackItem belowTop = next.get(next.size() - 2); - next = belowTop.push(top.push(popStack(popStack(next)))); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - break; - } - case ROT_THREE: { - StackItem top = next.get(next.size() - 1); - StackItem second = next.get(next.size() - 2); - StackItem third = next.get(next.size() - 3); - next = second.push(third.push(top.push(top.push(popStack(popStack(popStack(next))))))); - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), next); - break; - } - case LOAD_NONE: - opCodeAt(code, op.getNextBci(bci, oparg, false), (ignored, nextOp, ignored2, ignored3) -> { - // Usually, when compiling bytecode around exception handlers, the code - // is generated twice, once for the path with no exception, and - // once for the path with the exception. However, when generating code - // for a with statement exit, the code is generated as follows (and in a - // similar manner for async with). - // ... - // LOAD_NONE - // EXIT_WITH (exception handler starts here) - // ... - // This means that setting the stack at EXIT_WITH to have Object on top, - // as LOAD_NONE usually would, would cause a conflict with the exception - // handler starting at that position, which has the stack top be an - // Exception. - if (nextOp != OpCodes.GET_AEXIT_CORO && nextOp != OpCodes.EXIT_WITH) { - setNextStack(todo, blocks, op.getNextBci(bci, oparg, false), StackItem.Object.push(blocks.get(bci))); - } - }); - break; - - default: { - int nextWJump = op.getNextBci(bci, oparg, true); - int nextWOJump = op.getNextBci(bci, oparg, false); - int stackLostWJump = op.getNumberOfConsumedStackItems(oparg, followingArgs, true); - int stackLostWOJump = op.getNumberOfConsumedStackItems(oparg, followingArgs, false); - int stackGainWJump = op.getNumberOfProducedStackItems(oparg, followingArgs, true); - int stackGainWOJump = op.getNumberOfProducedStackItems(oparg, followingArgs, false); - handleGeneralOp(blocks, todo, bci, nextWJump, stackLostWJump, stackGainWJump); - if (nextWJump != nextWOJump) { - handleGeneralOp(blocks, todo, bci, nextWOJump, stackLostWOJump, stackGainWOJump); - } - break; - } - } - }); - } - return blocks; - } - - private void handleGeneralOp(List> blocks, ArrayDeque todo, int bci, int next, int stackLost, int stackGain) { - if (next >= 0) { - ArrayList blocksHere = new ArrayList<>(blocks.get(bci)); - for (int k = 0; k < stackLost; ++k) { - blocksHere.remove(blocksHere.size() - 1); - } - for (int k = 0; k < stackGain; ++k) { - blocksHere.add(StackItem.Object); - } - setNextStack(todo, blocks, next, blocksHere); - } - } - - @FunctionalInterface - public interface BytecodeAction { - void run(int bci, OpCodes op, int oparg, byte[] followingArgs); - } - - // returns the following bci - private static int opCodeAt(byte[] bytecode, int bci, BytecodeAction action) { - int oparg = 0; - OpCodes op = OpCodes.fromOpCode(bytecode[bci]); - while (op == OpCodes.EXTENDED_ARG) { - oparg |= Byte.toUnsignedInt(bytecode[bci + 1]); - oparg <<= 8; - bci += 2; - op = OpCodes.fromOpCode(bytecode[bci]); - } - op = unquicken(op); - byte[] followingArgs = null; - if (op.argLength > 0) { - oparg |= Byte.toUnsignedInt(bytecode[bci + 1]); - if (op.argLength > 1) { - followingArgs = new byte[op.argLength - 1]; - System.arraycopy(bytecode, bci + 2, followingArgs, 0, followingArgs.length); - } - } - action.run(bci, op, oparg, followingArgs); - return bci + op.length(); - } - - public static void iterateBytecode(byte[] bytecode, BytecodeAction action) { - for (int bci = 0; bci < bytecode.length;) { - bci = opCodeAt(bytecode, bci, action); - } - } - - public void iterateBytecode(BytecodeAction action) { - iterateBytecode(code, action); - } - - public byte[] getBytecodeForSerialization() { - byte[] bytecode = Arrays.copyOf(code, code.length); - for (int bci = 0; bci < bytecode.length;) { - OpCodes op = OpCodes.fromOpCode(bytecode[bci]); - bytecode[bci] = (byte) unquicken(op).ordinal(); - bci += op.length(); - } - return bytecode; - } - - private static OpCodes unquicken(OpCodes op) { - if (op.quickens == null) { - return op; - } - return switch (op.quickens) { - // These are already quickened by the compiler, so keep them quickened - // See CompilationUnit.emitBytecode - case LOAD_BYTE, LOAD_INT, LOAD_LONG, LOAD_DOUBLE, LOAD_TRUE, LOAD_FALSE -> op; - default -> op.quickens; - }; + public final Signature computeSignature() { + int posArgCount = argCount + positionalOnlyArgCount; + TruffleString[] parameterNames = Arrays.copyOf(varnames, posArgCount); + TruffleString[] kwOnlyNames = Arrays.copyOfRange(varnames, posArgCount, posArgCount + kwOnlyArgCount); + int varArgsIndex = takesVarArgs() ? posArgCount : -1; + return new Signature(positionalOnlyArgCount, + takesVarKeywordArgs(), + varArgsIndex, + parameterNames, + kwOnlyNames); } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationScope.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationScope.java index dee34b0461..148cc15f37 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationScope.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationScope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -40,7 +40,7 @@ */ package com.oracle.graal.python.compiler; -enum CompilationScope { +public enum CompilationScope { Module, Class, Function, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationUnit.java index 1bb92cce55..6f4d2cc4cf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationUnit.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/CompilationUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, 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 @@ -183,7 +183,7 @@ private void addImplicitReturn() { } } - public CodeUnit assemble() { + public BytecodeCodeUnit assemble() { addImplicitReturn(); calculateJumpInstructionArguments(); @@ -321,19 +321,20 @@ public CodeUnit assemble() { } } } - return new CodeUnit(toTruffleStringUncached(name), toTruffleStringUncached(qualName), - argCount, kwOnlyArgCount, positionalOnlyArgCount, maxStackSize, - buf.toByteArray(), sourceMapBuilder.build(), flags, - orderedKeys(names, new TruffleString[0], PythonUtils::toTruffleStringUncached), - orderedKeys(varnames, new TruffleString[0], PythonUtils::toTruffleStringUncached), + return new BytecodeCodeUnit(toTruffleStringUncached(name), toTruffleStringUncached(qualName), + argCount, kwOnlyArgCount, positionalOnlyArgCount, flags, + orderedKeys(names, new TruffleString[0], PythonUtils::toTruffleStringUncached), orderedKeys(varnames, new TruffleString[0], PythonUtils::toTruffleStringUncached), orderedKeys(cellvars, new TruffleString[0], PythonUtils::toTruffleStringUncached), orderedKeys(freevars, new TruffleString[0], cellvars.size(), PythonUtils::toTruffleStringUncached), cell2arg, orderedKeys(constants, new Object[0]), - orderedLong(primitiveConstants), - exceptionHandlerRanges, - conditionProfileCount, - startLocation.startLine, startLocation.startColumn, startLocation.endLine, startLocation.endColumn, + startLocation.startLine, + startLocation.startColumn, + startLocation.endLine, + startLocation.endColumn, + buf.toByteArray(), + sourceMapBuilder.build(), + orderedLong(primitiveConstants), exceptionHandlerRanges, maxStackSize, conditionProfileCount, finishedCanQuickenOutput, shouldUnboxVariable, finishedGeneralizeInputsMap, finishedGeneralizeVarsMap); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java index 4d63d53442..f7aaaf07df 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/Compiler.java @@ -237,9 +237,9 @@ public Compiler(ErrorCallback errorCallback) { public CompilationUnit compile(ModTy mod, EnumSet flags, int optimizationLevel, EnumSet futureFeatures) { this.flags = flags; if (mod instanceof ModTy.Module) { - parseFuture(((ModTy.Module) mod).body); + futureLineno = parseFuture(((ModTy.Module) mod).body, futureFeatures, errorCallback); } else if (mod instanceof ModTy.Interactive) { - parseFuture(((ModTy.Interactive) mod).body); + futureLineno = parseFuture(((ModTy.Interactive) mod).body, futureFeatures, errorCallback); } this.futureFeatures.addAll(futureFeatures); this.env = ScopeEnvironment.analyze(mod, errorCallback, this.futureFeatures); @@ -251,21 +251,23 @@ public CompilationUnit compile(ModTy mod, EnumSet flags, int optimization return topUnit; } - private void parseFuture(StmtTy[] modBody) { + public static int parseFuture(StmtTy[] modBody, EnumSet futureFeatures, ErrorCallback errorCallback) { + int lastFutureLine = -1; if (modBody == null || modBody.length == 0) { - return; + return lastFutureLine; } boolean done = false; int prevLine = 0; int i = 0; - if (getDocstring(modBody) != null) { + if (findDocstring(modBody) != null) { i++; } + for (; i < modBody.length; i++) { StmtTy s = modBody[i]; int line = s.getSourceRange().startLine; if (done && line > prevLine) { - return; + return lastFutureLine; } prevLine = line; if (s instanceof StmtTy.ImportFrom) { @@ -274,8 +276,8 @@ private void parseFuture(StmtTy[] modBody) { if (done) { errorCallback.onError(ErrorType.Syntax, s.getSourceRange(), "from __future__ imports must occur at the beginning of the file"); } - parseFutureFeatures(importFrom, futureFeatures); - futureLineno = line; + parseFutureFeatures(importFrom, futureFeatures, errorCallback); + lastFutureLine = line; } else { done = true; } @@ -283,9 +285,10 @@ private void parseFuture(StmtTy[] modBody) { done = true; } } + return lastFutureLine; } - private void parseFutureFeatures(StmtTy.ImportFrom node, EnumSet features) { + private static void parseFutureFeatures(StmtTy.ImportFrom node, EnumSet features, ErrorCallback errorCallback) { for (AliasTy alias : node.names) { if (alias.name != null) { switch (alias.name) { @@ -445,7 +448,7 @@ private void exitScope() { } } - private void checkForbiddenName(String id, ExprContextTy context) { + protected final void checkForbiddenName(String id, ExprContextTy context) { if (context == ExprContextTy.Store) { if (id.equals("__debug__")) { errorCallback.onError(ErrorType.Syntax, unit.currentLocation, "cannot assign to __debug__"); @@ -657,10 +660,7 @@ private static int addObject(HashMap dict, T o) { return v; } - private TruffleString getDocstring(StmtTy[] body) { - if (optimizationLevel >= 2) { - return null; - } + private static TruffleString findDocstring(StmtTy[] body) { if (body != null && body.length > 0) { StmtTy stmt = body[0]; if (stmt instanceof StmtTy.Expr) { @@ -676,6 +676,13 @@ private TruffleString getDocstring(StmtTy[] body) { return null; } + private TruffleString getDocstring(StmtTy[] body) { + if (optimizationLevel >= 2) { + return null; + } + return findDocstring(body); + } + private SourceRange setLocation(SourceRange location) { SourceRange savedLocation = unit.currentLocation; unit.currentLocation = location; @@ -842,6 +849,19 @@ public boolean isEmpty() { } } + /** + * After these bytecodes are executed, there will a Python collection on the stack containing + * all the arguments. + *

    + * We push individual arguments to the stack and when we reach certain size threshold, we emit + * instruction to collect N stack items (N is immediate operand) to the collection, which will + * now be on TOS. Next time this happens we emit instruction that adds the stack items to the + * collection. This way we accumulate the arguments into the collection and also never overflow + * certain stack size. + *

    + * When we encounter starred argument: we accumulate what we have on stack to the collection and + * then add the values in the starred arg to it. + */ private void collectIntoArray(ExprTy[] nodes, int bits, int alreadyOnStack) { Collector collector = new Collector(bits, alreadyOnStack); if (nodes != null) { @@ -886,7 +906,7 @@ private void collectIntoDict(ExprTy[] keys, ExprTy[] values) { collector.finishCollection(); } - private void validateKeywords(KeywordTy[] keywords) { + protected final void validateKeywords(KeywordTy[] keywords) { for (int i = 0; i < keywords.length; i++) { if (keywords[i].arg != null) { checkForbiddenName(keywords[i].arg, ExprContextTy.Store); @@ -1546,7 +1566,7 @@ public Void visit(ExprTy.List node) { case Store: return unpackInto(node.elements); case Load: - boolean emittedConstant = tryCollectConstantCollection(node.elements, CollectionBits.KIND_LIST); + boolean emittedConstant = tryLoadConstantCollection(node.elements, CollectionBits.KIND_LIST); if (emittedConstant) { return null; } @@ -1829,7 +1849,7 @@ public Void visit(ExprTy.Tuple node) { } } } - boolean emittedConstant = tryCollectConstantCollection(node.elements, CollectionBits.KIND_TUPLE); + boolean emittedConstant = tryLoadConstantCollection(node.elements, CollectionBits.KIND_TUPLE); if (emittedConstant) { return null; } @@ -1849,13 +1869,33 @@ public Void visit(ExprTy.Tuple node) { } } - private boolean tryCollectConstantCollection(ExprTy[] elements, int collectionKind) { + private boolean tryLoadConstantCollection(ExprTy[] elements, int collectionKind) { + ConstantCollection constantCollection = tryCollectConstantCollection(elements); + if (constantCollection == null) { + return false; + } + + addOp(LOAD_CONST_COLLECTION, addObject(unit.constants, constantCollection.collection), new byte[]{(byte) (constantCollection.elementType | collectionKind)}); + return true; + } + + public static final class ConstantCollection { + public final Object collection; + public final int elementType; + + ConstantCollection(Object collection, int elementType) { + this.collection = collection; + this.elementType = elementType; + } + } + + public static ConstantCollection tryCollectConstantCollection(ExprTy[] elements) { /* * We try to store the whole tuple as a Java array constant when all the elements are * constant and context-independent. */ if (elements == null || elements.length == 0) { - return false; + return null; } int constantType = -1; @@ -1885,10 +1925,10 @@ private boolean tryCollectConstantCollection(ExprTy[] elements, int collectionKi constantType = determineConstantType(constantType, CollectionBits.ELEMENT_OBJECT); constants.add(PNone.NONE); } else { - return false; + return null; } } else { - return false; + return null; } } Object newConstant = null; @@ -1929,11 +1969,10 @@ private boolean tryCollectConstantCollection(ExprTy[] elements, int collectionKi break; } } - addOp(LOAD_CONST_COLLECTION, addObject(unit.constants, newConstant), new byte[]{(byte) (constantType | collectionKind)}); - return true; + return new ConstantCollection(newConstant, constantType); } - int determineConstantType(int existing, int type) { + private static int determineConstantType(int existing, int type) { if (existing == -1 || existing == type) { return type; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BaseBytecodeDSLVisitor.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BaseBytecodeDSLVisitor.java new file mode 100644 index 0000000000..d0910aee08 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BaseBytecodeDSLVisitor.java @@ -0,0 +1,493 @@ +/* + * Copyright (c) 2023, 2025, 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.compiler.bytecode_dsl; + +import com.oracle.graal.python.pegparser.sst.AliasTy; +import com.oracle.graal.python.pegparser.sst.ArgTy; +import com.oracle.graal.python.pegparser.sst.ArgumentsTy; +import com.oracle.graal.python.pegparser.sst.ComprehensionTy; +import com.oracle.graal.python.pegparser.sst.ExceptHandlerTy; +import com.oracle.graal.python.pegparser.sst.ExprTy; +import com.oracle.graal.python.pegparser.sst.KeywordTy; +import com.oracle.graal.python.pegparser.sst.MatchCaseTy; +import com.oracle.graal.python.pegparser.sst.ModTy; +import com.oracle.graal.python.pegparser.sst.PatternTy; +import com.oracle.graal.python.pegparser.sst.SSTNode; +import com.oracle.graal.python.pegparser.sst.SSTreeVisitor; +import com.oracle.graal.python.pegparser.sst.StmtTy; +import com.oracle.graal.python.pegparser.sst.TypeIgnoreTy.TypeIgnore; +import com.oracle.graal.python.pegparser.sst.WithItemTy; + +/** + * This interface provides default implementations of all {@code SSTreeVisitor} methods, which makes + * it easier to incrementally add support to the Bytecode DSL compiler. Once the compiler is stable, + * this interface should be removed. + */ +public interface BaseBytecodeDSLVisitor extends SSTreeVisitor { + + default T defaultValue(SSTNode node) { + throw new UnsupportedOperationException(getClass().getSimpleName() + ": " + node.getClass().getSimpleName()); + } + + default void visitNode(SSTNode node) { + if (node != null) { + node.accept(this); + } + } + + default T visit(AliasTy node) { + return defaultValue(node); + } + + default T visit(ArgTy node) { + return defaultValue(node); + } + + default T visit(ArgumentsTy node) { + visitSequence(node.defaults); + visitSequence(node.kwDefaults); + return defaultValue(node); + } + + default T visit(ComprehensionTy node) { + visitNode(node.iter); + visitSequence(node.ifs); + visitNode(node.target); + return defaultValue(node); + } + + default T visit(ExprTy.Attribute node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.Await node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.BinOp node) { + visitNode(node.left); + visitNode(node.right); + return defaultValue(node); + } + + default T visit(ExprTy.BoolOp node) { + visitSequence(node.values); + return defaultValue(node); + } + + default T visit(ExprTy.Call node) { + visitNode(node.func); + visitSequence(node.args); + visitSequence(node.keywords); + return defaultValue(node); + } + + default T visit(ExprTy.Compare node) { + visitNode(node.left); + visitSequence(node.comparators); + return defaultValue(node); + } + + default T visit(ExprTy.Constant node) { + return defaultValue(node); + } + + default T visit(ExprTy.Dict node) { + visitSequence(node.keys); + visitSequence(node.values); + return defaultValue(node); + } + + default T visit(ExprTy.DictComp node) { + visitSequence(node.generators); + visitNode(node.key); + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.FormattedValue node) { + visitNode(node.formatSpec); + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.GeneratorExp node) { + visitNode(node.element); + visitSequence(node.generators); + return defaultValue(node); + } + + default T visit(ExprTy.IfExp node) { + visitNode(node.test); + visitNode(node.body); + visitNode(node.orElse); + return defaultValue(node); + } + + default T visit(ExprTy.JoinedStr node) { + visitSequence(node.values); + return defaultValue(node); + } + + default T visit(ExprTy.Lambda node) { + visitNode(node.body); + return defaultValue(node); + } + + default T visit(ExprTy.List node) { + visitSequence(node.elements); + return defaultValue(node); + } + + default T visit(ExprTy.ListComp node) { + visitSequence(node.generators); + visitNode(node.element); + return defaultValue(node); + } + + default T visit(ExprTy.Name node) { + return defaultValue(node); + } + + default T visit(ExprTy.NamedExpr node) { + visitNode(node.target); + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.Set node) { + visitSequence(node.elements); + return defaultValue(node); + } + + default T visit(ExprTy.SetComp node) { + visitSequence(node.generators); + visitNode(node.element); + return defaultValue(node); + } + + default T visit(ExprTy.Slice node) { + visitNode(node.lower); + visitNode(node.upper); + visitNode(node.step); + return defaultValue(node); + } + + default T visit(ExprTy.Starred node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.Subscript node) { + visitNode(node.value); + visitNode(node.slice); + return defaultValue(node); + } + + default T visit(ExprTy.Tuple node) { + visitSequence(node.elements); + return defaultValue(node); + } + + default T visit(ExprTy.UnaryOp node) { + visitNode(node.operand); + return defaultValue(node); + } + + default T visit(ExprTy.Yield node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ExprTy.YieldFrom node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(KeywordTy node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(ModTy.Expression node) { + visitNode(node.body); + return defaultValue(node); + } + + default T visit(ModTy.FunctionType node) { + visitNode(node.returns); + return defaultValue(node); + } + + default T visit(ModTy.Interactive node) { + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(ModTy.Module node) { + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.AnnAssign node) { + visitNode(node.target); + visitNode(node.annotation); + visitNode(node.value); + return defaultValue(node); + } + + default T visit(StmtTy.Assert node) { + visitNode(node.test); + visitNode(node.msg); + return defaultValue(node); + } + + default T visit(StmtTy.Assign node) { + visitNode(node.value); + visitSequence(node.targets); + return defaultValue(node); + } + + default T visit(StmtTy.AsyncFor node) { + visitNode(node.target); + visitNode(node.iter); + visitSequence(node.body); + visitSequence(node.orElse); + return defaultValue(node); + } + + default T visit(StmtTy.AsyncFunctionDef node) { + visitSequence(node.decoratorList); + visitNode(node.args); + visitNode(node.returns); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.AsyncWith node) { + visitSequence(node.items); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.AugAssign node) { + visitNode(node.target); + visitNode(node.value); + return defaultValue(node); + } + + default T visit(StmtTy.ClassDef node) { + visitSequence(node.decoratorList); + visitSequence(node.bases); + visitSequence(node.keywords); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.Delete node) { + visitSequence(node.targets); + return defaultValue(node); + } + + default T visit(StmtTy.Expr node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(StmtTy.For node) { + visitNode(node.iter); + visitNode(node.target); + visitSequence(node.body); + visitSequence(node.orElse); + return defaultValue(node); + } + + default T visit(StmtTy.FunctionDef node) { + visitSequence(node.decoratorList); + visitNode(node.args); + visitNode(node.returns); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.Global node) { + return defaultValue(node); + } + + default T visit(StmtTy.If node) { + visitNode(node.test); + visitSequence(node.body); + visitSequence(node.orElse); + return defaultValue(node); + } + + default T visit(StmtTy.Import node) { + return defaultValue(node); + } + + default T visit(StmtTy.ImportFrom node) { + return defaultValue(node); + } + + default T visit(StmtTy.Match node) { + visitNode(node.subject); + visitSequence(node.cases); + return defaultValue(node); + } + + default T visit(MatchCaseTy node) { + visitNode(node.pattern); + visitNode(node.guard); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(PatternTy.MatchAs node) { + visitNode(node.pattern); + return defaultValue(node); + } + + default T visit(PatternTy.MatchClass node) { + visitSequence(node.patterns); + visitSequence(node.kwdPatterns); + visitNode(node.cls); + return defaultValue(node); + } + + default T visit(PatternTy.MatchMapping node) { + visitSequence(node.keys); + visitSequence(node.patterns); + return defaultValue(node); + } + + default T visit(PatternTy.MatchOr node) { + visitSequence(node.patterns); + return defaultValue(node); + } + + default T visit(PatternTy.MatchSequence node) { + visitSequence(node.patterns); + return defaultValue(node); + } + + default T visit(PatternTy.MatchSingleton node) { + return defaultValue(node); + } + + default T visit(PatternTy.MatchStar node) { + return defaultValue(node); + } + + default T visit(PatternTy.MatchValue node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(StmtTy.Nonlocal node) { + return defaultValue(node); + } + + default T visit(StmtTy.Raise node) { + visitNode(node.exc); + visitNode(node.cause); + return defaultValue(node); + } + + default T visit(StmtTy.Return node) { + visitNode(node.value); + return defaultValue(node); + } + + default T visit(StmtTy.Try node) { + visitSequence(node.body); + visitSequence(node.orElse); + visitSequence(node.finalBody); + visitSequence(node.handlers); + return defaultValue(node); + } + + default T visit(StmtTy.TryStar node) { + return defaultValue(node); + } + + default T visit(ExceptHandlerTy.ExceptHandler node) { + visitNode(node.type); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(StmtTy.While node) { + visitNode(node.test); + visitSequence(node.body); + visitSequence(node.orElse); + return defaultValue(node); + } + + default T visit(StmtTy.With node) { + visitSequence(node.items); + visitSequence(node.body); + return defaultValue(node); + } + + default T visit(WithItemTy node) { + visitNode(node.contextExpr); + visitNode(node.optionalVars); + return defaultValue(node); + } + + default T visit(StmtTy.Break node) { + return defaultValue(node); + } + + default T visit(StmtTy.Continue node) { + return defaultValue(node); + } + + default T visit(StmtTy.Pass node) { + return defaultValue(node); + } + + default T visit(TypeIgnore node) { + return defaultValue(node); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BytecodeDSLCompiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BytecodeDSLCompiler.java new file mode 100644 index 0000000000..11e21db32b --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/BytecodeDSLCompiler.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025, 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.compiler.bytecode_dsl; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.compiler.Compiler; +import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; +import com.oracle.graal.python.pegparser.FutureFeature; +import com.oracle.graal.python.pegparser.scope.Scope; +import com.oracle.graal.python.pegparser.scope.ScopeEnvironment; +import com.oracle.graal.python.pegparser.sst.ModTy; +import com.oracle.graal.python.pegparser.sst.StmtTy; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.truffle.api.source.Source; + +public class BytecodeDSLCompiler { + + public static final record BytecodeDSLCompilerResult(PBytecodeDSLRootNode rootNode, BytecodeDSLCodeUnit codeUnit) { + } + + public static BytecodeDSLCompilerResult compile(PythonLanguage language, PythonContext context, ModTy mod, Source source, int optimize, RaisePythonExceptionErrorCallback errorCallback, + EnumSet futureFeatures) { + /** + * Parse __future__ annotations before the analysis step. The analysis does extra validation + * when __future__.annotations is imported. + */ + int futureLineNumber = parseFuture(mod, futureFeatures, errorCallback); + ScopeEnvironment scopeEnvironment = ScopeEnvironment.analyze(mod, errorCallback, futureFeatures); + BytecodeDSLCompilerContext ctx = new BytecodeDSLCompilerContext(language, context, mod, source, optimize, futureFeatures, futureLineNumber, errorCallback, scopeEnvironment); + RootNodeCompiler compiler = new RootNodeCompiler(ctx, mod, futureFeatures); + return compiler.compile(); + } + + private static int parseFuture(ModTy mod, EnumSet futureFeatures, RaisePythonExceptionErrorCallback errorCallback) { + StmtTy[] stmts = null; + if (mod instanceof ModTy.Module module) { + stmts = module.body; + } else if (mod instanceof ModTy.Interactive interactive) { + stmts = interactive.body; + } else { + return -1; + } + return Compiler.parseFuture(stmts, futureFeatures, errorCallback); + } + + public static class BytecodeDSLCompilerContext { + + public final PythonLanguage language; + public final PythonContext pythonContext; + public final ModTy mod; + public final Source source; + public final int optimizationLevel; + public final EnumSet futureFeatures; + public final int futureLineNumber; + public final RaisePythonExceptionErrorCallback errorCallback; + public final ScopeEnvironment scopeEnvironment; + public final Map qualifiedNames; + + public BytecodeDSLCompilerContext(PythonLanguage language, PythonContext context, ModTy mod, Source source, int optimizationLevel, + EnumSet futureFeatures, int futureLineNumber, RaisePythonExceptionErrorCallback errorCallback, ScopeEnvironment scopeEnvironment) { + this.language = language; + this.pythonContext = context; + this.mod = mod; + this.source = source; + this.optimizationLevel = optimizationLevel; + this.futureFeatures = futureFeatures; + this.futureLineNumber = futureLineNumber; + this.errorCallback = errorCallback; + this.scopeEnvironment = scopeEnvironment; + this.qualifiedNames = new HashMap<>(); + } + + String mangle(Scope scope, String name) { + return ScopeEnvironment.mangle(getClassName(scope), name); + } + + String getClassName(Scope s) { + Scope cur = s; + while (cur != null) { + if (cur.isClass()) { + return cur.getName(); + } + cur = scopeEnvironment.lookupParent(cur); + } + return null; + } + + String getQualifiedName(Scope scope) { + if (qualifiedNames.containsKey(scope)) { + return qualifiedNames.get(scope); + } else { + String qualifiedName = computeQualifiedName(scope); + qualifiedNames.put(scope, qualifiedName); + return qualifiedName; + } + } + + private String computeQualifiedName(Scope scope) { + String qualifiedName = scope.getName(); + Scope parentScope = scopeEnvironment.lookupParent(scope); + if (parentScope != null && parentScope != scopeEnvironment.getTopScope()) { + if (!((scope.isFunction() || scope.isClass()) && parentScope.getUseOfName(mangle(scope, scope.getName())).contains(Scope.DefUse.GlobalExplicit))) { + // Qualify the name, unless it's a function/class and the parent declared the + // name as a global (in which case the function/class doesn't belong to the + // parent). + if (parentScope.isFunction()) { + qualifiedName = getQualifiedName(parentScope) + ".." + scope.getName(); + } else { + qualifiedName = getQualifiedName(parentScope) + "." + scope.getName(); + } + } + } + + return qualifiedName; + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java new file mode 100644 index 0000000000..b36f6c1f22 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java @@ -0,0 +1,4584 @@ +/* + * Copyright (c) 2024, 2025, 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.compiler.bytecode_dsl; + +import static com.oracle.graal.python.compiler.CompilationScope.Class; +import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___CLASS__; +import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Function; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.code.PCode; +import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis; +import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.type.TypeFlags; +import com.oracle.graal.python.compiler.CompilationScope; +import com.oracle.graal.python.compiler.Compiler; +import com.oracle.graal.python.compiler.Compiler.ConstantCollection; +import com.oracle.graal.python.compiler.OpCodes.CollectionBits; +import com.oracle.graal.python.compiler.Unparser; +import com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompiler.BytecodeDSLCompilerContext; +import com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompiler.BytecodeDSLCompilerResult; +import com.oracle.graal.python.nodes.StringLiterals; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen.Builder; +import com.oracle.graal.python.pegparser.ErrorCallback.ErrorType; +import com.oracle.graal.python.pegparser.ErrorCallback.WarningType; +import com.oracle.graal.python.pegparser.FutureFeature; +import com.oracle.graal.python.pegparser.scope.Scope; +import com.oracle.graal.python.pegparser.scope.Scope.DefUse; +import com.oracle.graal.python.pegparser.sst.AliasTy; +import com.oracle.graal.python.pegparser.sst.ArgTy; +import com.oracle.graal.python.pegparser.sst.ArgumentsTy; +import com.oracle.graal.python.pegparser.sst.BoolOpTy; +import com.oracle.graal.python.pegparser.sst.CmpOpTy; +import com.oracle.graal.python.pegparser.sst.ComprehensionTy; +import com.oracle.graal.python.pegparser.sst.ConstantValue; +import com.oracle.graal.python.pegparser.sst.ConstantValue.Kind; +import com.oracle.graal.python.pegparser.sst.ExceptHandlerTy; +import com.oracle.graal.python.pegparser.sst.ExprContextTy; +import com.oracle.graal.python.pegparser.sst.ExprTy; +import com.oracle.graal.python.pegparser.sst.ExprTy.Constant; +import com.oracle.graal.python.pegparser.sst.ExprTy.DictComp; +import com.oracle.graal.python.pegparser.sst.ExprTy.GeneratorExp; +import com.oracle.graal.python.pegparser.sst.ExprTy.Lambda; +import com.oracle.graal.python.pegparser.sst.ExprTy.ListComp; +import com.oracle.graal.python.pegparser.sst.ExprTy.SetComp; +import com.oracle.graal.python.pegparser.sst.KeywordTy; +import com.oracle.graal.python.pegparser.sst.MatchCaseTy; +import com.oracle.graal.python.pegparser.sst.ModTy; +import com.oracle.graal.python.pegparser.sst.OperatorTy; +import com.oracle.graal.python.pegparser.sst.PatternTy; +import com.oracle.graal.python.pegparser.sst.SSTNode; +import com.oracle.graal.python.pegparser.sst.StmtTy; +import com.oracle.graal.python.pegparser.sst.StmtTy.AsyncFunctionDef; +import com.oracle.graal.python.pegparser.sst.UnaryOpTy; +import com.oracle.graal.python.pegparser.sst.WithItemTy; +import com.oracle.graal.python.pegparser.tokenizer.SourceRange; +import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.bytecode.BytecodeConfig; +import com.oracle.truffle.api.bytecode.BytecodeLabel; +import com.oracle.truffle.api.bytecode.BytecodeLocal; +import com.oracle.truffle.api.bytecode.BytecodeParser; +import com.oracle.truffle.api.bytecode.BytecodeRootNodes; +import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag; +import com.oracle.truffle.api.strings.TruffleString; + +/** + * Compiles a top-level AST (modules, functions, classes, etc.) to a root node. Produces a + * {@link BytecodeDSLCompilerResult}. Every instance is associated with corresponding + * {@link SSTNode} that represents the compiled top level AST. + *

    + * The class implements SST visitor, so that it can have a separate handler for each top-level AST + * node type, the handler (one of the {@code visit} methods) then creates a lambda of type + * {@link BytecodeParser}, which captures the node being compiled and the instance of + * {@link RootNodeCompiler}, and it uses the {@link RootNodeCompiler} to do the parsing itself. The + * {@link BytecodeParser} instance is passed to Truffle API + * {@link PBytecodeDSLRootNodeGen#create(PythonLanguage, BytecodeConfig, BytecodeParser)} to trigger + * the parsing. Truffle keeps the lambda, and it may invoke it again when it needs to perform the + * parsing of the given node again. + *

    + * The parsing must happen within the {@link BytecodeParser} lambda invocation. + *

    + * This visitor also captures compilation unit state, such as the map of local variables, and serves + * the same purpose as the {@code compiler_unit} struct in the CPython compiler. Instead of explicit + * stack of compiler units, we use implicitly Java stack and new instances of + * {@link RootNodeCompiler}. + *

    + * For the parsing of the body of the top level AST element, this visitor delegates to the + * {@link StatementCompiler}, which does all the heavy lifting. + */ +public final class RootNodeCompiler implements BaseBytecodeDSLVisitor { + /** + * Because a {@link RootNodeCompiler} instance gets reused on reparse, it should be idempotent. + * Consequently, most of its fields are final and immutable/not mutated after construction. For + * some tables updated during parsing (e.g., the constants map), we ensure these updates are + * idempotent. Any remaining fields must be {@link #reset()} at the beginning of the parse. + */ + // Immutable + private final BytecodeDSLCompilerContext ctx; + private final SSTNode startNode; + private final Scope scope; + private final CompilationScope scopeType; + private final boolean isInteractive; + private final EnumSet futureFeatures; + + // Immutable after construction + private final HashMap varnames; + private final HashMap cellvars; + private final HashMap freevars; + private final int[] cell2arg; + private final String selfCellName; + + // Updated idempotently: the keys are filled during first parsing, on subsequent parsings the + // values will be just overridden, but no new keys should be added. + private final Map locals = new HashMap<>(); + private final Map cellLocals = new HashMap<>(); + private final Map freeLocals = new HashMap<>(); + private final HashMap constants = new HashMap<>(); + private final HashMap names = new HashMap<>(); + + // Mutable (must be reset) + private SourceRange currentLocation; + + public RootNodeCompiler(BytecodeDSLCompilerContext ctx, SSTNode rootNode, EnumSet futureFeatures) { + this.ctx = ctx; + this.startNode = rootNode; + this.scope = ctx.scopeEnvironment.lookupScope(rootNode); + this.scopeType = getScopeType(scope, rootNode); + this.isInteractive = rootNode instanceof ModTy.Interactive; + this.futureFeatures = futureFeatures; + + this.varnames = new HashMap<>(); + if (scope.isFunction()) { + /* + * scope.getVarnames only returns parameters. We use the scope to collect the rest of + * the regular variables. + */ + for (int i = 0; i < scope.getVarnames().size(); i++) { + varnames.put(scope.getVarnames().get(i), i); + } + varnames.putAll(scope.getSymbolsByType(EnumSet.of(DefUse.Local), EnumSet.of(DefUse.DefParam, DefUse.Cell, DefUse.Free), varnames.size())); + } + + this.cellvars = scope.getSymbolsByType(EnumSet.of(Scope.DefUse.Cell), 0); + if (scope.needsClassClosure()) { + assert scopeType == Class; + assert cellvars.isEmpty(); + cellvars.put("__class__", 0); + } + + this.freevars = scope.getSymbolsByType(EnumSet.of(Scope.DefUse.Free, Scope.DefUse.DefFreeClass), 0); + + int[] cell2argValue = new int[cellvars.size()]; + boolean hasArgCell = false; + Arrays.fill(cell2argValue, -1); + String selfCellNameValue = null; + for (String cellvar : cellvars.keySet()) { + if (varnames.containsKey(cellvar)) { + int argIndex = varnames.get(cellvar); + cell2argValue[cellvars.get(cellvar)] = argIndex; + hasArgCell = true; + if (argIndex == 0) { + assert selfCellNameValue == null; + selfCellNameValue = cellvar; + } + } + } + this.cell2arg = hasArgCell ? cell2argValue : null; + this.selfCellName = selfCellNameValue; + } + + private static CompilationScope getScopeType(Scope scope, SSTNode rootNode) { + if (scope.isModule()) { + return CompilationScope.Module; + } else if (scope.isClass()) { + return CompilationScope.Class; + } else if (scope.isFunction()) { + if (rootNode instanceof Lambda) { + return CompilationScope.Lambda; + } else if (rootNode instanceof AsyncFunctionDef) { + return CompilationScope.AsyncFunction; + } else if (rootNode instanceof DictComp || rootNode instanceof ListComp || rootNode instanceof SetComp || rootNode instanceof GeneratorExp) { + return CompilationScope.Comprehension; + } else { + return CompilationScope.Function; + } + } else { + throw new IllegalStateException("Unexpected scope: " + scope); + } + } + + private static U[] orderedKeys(HashMap map, U[] base, Function converter) { + U[] result = Arrays.copyOf(base, map.size()); + for (Map.Entry e : map.entrySet()) { + result[e.getValue()] = converter.apply(e.getKey()); + } + return result; + } + + private static T[] orderedKeys(HashMap map, T[] base) { + return orderedKeys(map, base, x -> x); + } + + private Object addConstant(Object c) { + Integer v = constants.get(c); + if (v == null) { + v = constants.size(); + constants.put(c, v); + } + return c; + } + + private static TruffleString[] orderedTruffleStringArray(HashMap map) { + return orderedKeys(map, new TruffleString[0], PythonUtils::toTruffleStringUncached); + } + + private BytecodeDSLCompilerResult compileRootNode(String name, ArgumentInfo argumentInfo, SourceRange sourceRange, BytecodeParser parser) { + BytecodeRootNodes nodes = PBytecodeDSLRootNodeGen.create(ctx.language, BytecodeConfig.WITH_SOURCE, parser); + List nodeList = nodes.getNodes(); + assert nodeList.size() == 1; + PBytecodeDSLRootNode rootNode = nodeList.get(0); + + int flags = PCode.CO_OPTIMIZED | PCode.CO_NEWLOCALS; + flags |= argumentInfo.takesVarArgs ? PCode.CO_VARARGS : 0; + flags |= argumentInfo.takesVarKeywordArgs ? PCode.CO_VARKEYWORDS : 0; + if (scope.isNested()) { + flags |= PCode.CO_NESTED; + } + if (scope.isModule()) { + flags |= PCode.CO_GRAALPYHON_MODULE; + } + if (scope.isGenerator() && scope.isCoroutine()) { + flags |= PCode.CO_ASYNC_GENERATOR; + } else if (scope.isGenerator()) { + flags |= PCode.CO_GENERATOR; + } else if (scope.isCoroutine()) { + flags |= PCode.CO_COROUTINE; + } + for (FutureFeature flag : futureFeatures) { + flags |= flag.flagValue; + } + + int classcellIndex = -1; + if (freeLocals.containsKey(J___CLASS__)) { + classcellIndex = freeLocals.get(J___CLASS__).getLocalOffset(); + } + + int selfIndex = -1; + if (argumentInfo.nonEmpty()) { + selfIndex = 0; + if (selfCellName != null) { + selfIndex = cellLocals.get(selfCellName).getLocalOffset(); + } + } + + BytecodeDSLCodeUnit codeUnit = new BytecodeDSLCodeUnit(toTruffleStringUncached(name), toTruffleStringUncached(ctx.getQualifiedName(scope)), + argumentInfo.argCount, argumentInfo.kwOnlyArgCount, argumentInfo.positionalOnlyArgCount, + flags, orderedTruffleStringArray(names), + orderedTruffleStringArray(varnames), + orderedTruffleStringArray(cellvars), + orderedTruffleStringArray(freevars), + cell2arg, + orderedKeys(constants, new Object[0]), + sourceRange.startLine, + sourceRange.startColumn, + sourceRange.endLine, + sourceRange.endColumn, + classcellIndex, + selfIndex, + null, + nodes); + rootNode.setMetadata(codeUnit, ctx.errorCallback); + return new BytecodeDSLCompilerResult(rootNode, codeUnit); + } + + private static class ArgumentInfo { + static final ArgumentInfo NO_ARGS = new ArgumentInfo(0, 0, 0, false, false); + + final int argCount; + final int positionalOnlyArgCount; + final int kwOnlyArgCount; + final boolean takesVarArgs; + final boolean takesVarKeywordArgs; + + ArgumentInfo(int argCount, int positionalOnlyArgCount, int kwOnlyArgCount, boolean takesVarArgs, boolean takesVarKeywordArgs) { + this.argCount = argCount; + this.positionalOnlyArgCount = positionalOnlyArgCount; + this.kwOnlyArgCount = kwOnlyArgCount; + this.takesVarArgs = takesVarArgs; + this.takesVarKeywordArgs = takesVarKeywordArgs; + } + + static ArgumentInfo fromArguments(ArgumentsTy args) { + int argc, pargc, kwargc; + boolean splat, kwSplat; + if (args == null) { + argc = pargc = kwargc = 0; + splat = kwSplat = false; + } else { + argc = args.args == null ? 0 : args.args.length; + pargc = args.posOnlyArgs == null ? 0 : args.posOnlyArgs.length; + kwargc = args.kwOnlyArgs == null ? 0 : args.kwOnlyArgs.length; + splat = args.varArg != null; + kwSplat = args.kwArg != null; + } + return new ArgumentInfo(argc, pargc, kwargc, splat, kwSplat); + } + + private boolean nonEmpty() { + return argCount + positionalOnlyArgCount + kwOnlyArgCount > 0 || takesVarArgs || takesVarKeywordArgs; + } + } + + private void checkForbiddenName(String id, NameOperation context) { + checkForbiddenName(id, context, currentLocation); + } + + private void checkForbiddenName(String id, NameOperation context, SourceRange location) { + if (context == NameOperation.BeginWrite) { + if (id.equals("__debug__")) { + ctx.errorCallback.onError(ErrorType.Syntax, location, "cannot assign to __debug__"); + } + } + if (context == NameOperation.Delete) { + if (id.equals("__debug__")) { + ctx.errorCallback.onError(ErrorType.Syntax, location, "cannot delete __debug__"); + } + } + } + + private void checkForbiddenArgs(ArgumentsTy args, SourceRange location) { + if (args != null) { + if (args.posOnlyArgs != null) { + for (ArgTy arg : args.posOnlyArgs) { + checkForbiddenName(arg.arg, NameOperation.BeginWrite, location); + } + } + if (args.args != null) { + for (ArgTy arg : args.args) { + checkForbiddenName(arg.arg, NameOperation.BeginWrite, location); + } + } + if (args.kwOnlyArgs != null) { + for (ArgTy arg : args.kwOnlyArgs) { + checkForbiddenName(arg.arg, NameOperation.BeginWrite, location); + } + } + if (args.varArg != null) { + checkForbiddenName(args.varArg.arg, NameOperation.BeginWrite, location); + } + if (args.kwArg != null) { + checkForbiddenName(args.kwArg.arg, NameOperation.BeginWrite, location); + } + } + } + + private boolean containsAnnotations(StmtTy[] stmts) { + if (stmts == null) { + return false; + } + for (StmtTy stmt : stmts) { + if (containsAnnotations(stmt)) { + return true; + } + } + return false; + } + + private boolean containsAnnotations(StmtTy stmt) { + if (stmt instanceof StmtTy.AnnAssign) { + return true; + } else if (stmt instanceof StmtTy.For) { + return containsAnnotations(((StmtTy.For) stmt).body) || containsAnnotations(((StmtTy.For) stmt).orElse); + } else if (stmt instanceof StmtTy.While) { + return containsAnnotations(((StmtTy.While) stmt).body) || containsAnnotations(((StmtTy.While) stmt).orElse); + } else if (stmt instanceof StmtTy.If) { + return containsAnnotations(((StmtTy.If) stmt).body) || containsAnnotations(((StmtTy.If) stmt).orElse); + } else if (stmt instanceof StmtTy.With) { + return containsAnnotations(((StmtTy.With) stmt).body); + } else if (stmt instanceof StmtTy.Try) { + StmtTy.Try tryStmt = (StmtTy.Try) stmt; + if (tryStmt.handlers != null) { + for (ExceptHandlerTy h : tryStmt.handlers) { + if (containsAnnotations(((ExceptHandlerTy.ExceptHandler) h).body)) { + return true; + } + } + } + return containsAnnotations(tryStmt.body) || containsAnnotations(tryStmt.finalBody) || containsAnnotations(tryStmt.orElse); + } + return false; + } + + private static final class ParamAnnotation { + final TruffleString name; + final ExprTy annotation; + + ParamAnnotation(TruffleString name, ExprTy annotation) { + this.name = name; + this.annotation = annotation; + } + } + + private List collectParamAnnotations(ArgumentsTy args, ExprTy returns) { + List result = new ArrayList<>(); + if (args != null) { + visitParamAnnotations(result, args.args); + visitParamAnnotations(result, args.posOnlyArgs); + if (args.varArg != null) { + visitParamAnnotation(result, args.varArg.arg, args.varArg.annotation); + } + visitParamAnnotations(result, args.kwOnlyArgs); + if (args.kwArg != null) { + visitParamAnnotation(result, args.kwArg.arg, args.kwArg.annotation); + } + } + visitParamAnnotation(result, "return", returns); + return result; + } + + private void visitParamAnnotations(List result, ArgTy[] args) { + for (int i = 0; i < args.length; i++) { + visitParamAnnotation(result, args[i].arg, args[i].annotation); + } + } + + private void visitParamAnnotation(List result, String name, ExprTy annotation) { + if (annotation != null) { + String mangled = mangle(name); + result.add(new ParamAnnotation(toTruffleStringUncached(mangled), annotation)); + } + } + + public BytecodeDSLCompilerResult compile() { + return startNode.accept(this); + } + + public void reset() { + this.currentLocation = null; + } + + // -------------- helpers -------------- + + void beginRootNode(SSTNode node, ArgumentsTy args, Builder b) { + reset(); + b.beginSource(ctx.source); + beginRootSourceSection(node, b); + + b.beginRoot(); + + checkForbiddenArgs(args, node.getSourceRange()); + setUpFrame(args, b); + + b.emitTraceOrProfileCall(); + } + + void endRootNode(Builder b) { + b.endRoot(); + endRootSourceSection(b); + b.endSource(); + } + + /** + * Opens a new SourceSection operation. Emits TraceLine and starts a new Tag(Statement) if this + * location has a different line from the previous location. + *

    + * Returns whether this call opened a new Tag(Statement). The result should be passed to the + * corresponding {@link #endSourceSection} call to ensure the Tag is closed. + */ + boolean beginSourceSection(SSTNode node, Builder b) { + SourceRange sourceRange = node.getSourceRange(); + SourceRange oldSourceRange = this.currentLocation; + this.currentLocation = sourceRange; + + if (ctx.source.hasCharacters()) { + int startOffset = getStartOffset(sourceRange); + int endOffset = getEndOffset(sourceRange); + int length = endOffset - startOffset; + if (length == 0) { + startOffset = 0; + } + b.beginSourceSection(startOffset, length); + + if (oldSourceRange == null || oldSourceRange.startLine != sourceRange.startLine) { + b.beginTag(StatementTag.class); + b.beginBlock(); + b.emitTraceLine(sourceRange.startLine); + return true; + } + } + return false; + } + + /** + * Same as {@link #beginSourceSection(SSTNode, Builder)}, but does not emit tags or trace events + * (since the root has not been started yet). Avoids setting {@link #currentLocation} so that + * {{@link #beginSourceSection(SSTNode, Builder)} will emit a TraceLine for a statement on the + * first line. + */ + void beginRootSourceSection(SSTNode node, Builder b) { + SourceRange sourceRange = node.getSourceRange(); + + if (ctx.source.hasCharacters()) { + int startOffset = getStartOffset(sourceRange); + int endOffset = getEndOffset(sourceRange); + int length = endOffset - startOffset; + if (length == 0) { + startOffset = 0; + } + b.beginSourceSection(startOffset, length); + } + } + + void endSourceSection(Builder b, boolean closeTag) { + if (ctx.source.hasCharacters()) { + if (closeTag) { + b.endBlock(); + b.endTag(StatementTag.class); + } + b.endSourceSection(); + } + } + + void endRootSourceSection(Builder b) { + if (ctx.source.hasCharacters()) { + b.endSourceSection(); + } + } + + int getStartOffset(SourceRange sourceRange) { + return ctx.source.getLineStartOffset(sourceRange.startLine) + sourceRange.startColumn; + } + + int getEndOffset(SourceRange sourceRange) { + return ctx.source.getLineStartOffset(sourceRange.endLine) + sourceRange.endColumn; + } + + void beginReturn(Builder b) { + b.beginReturn(); + b.beginTraceOrProfileReturn(); + } + + void endReturn(Builder b) { + b.endTraceOrProfileReturn(); + b.endReturn(); + } + + // --------------------- visitor --------------------------- + + @Override + public BytecodeDSLCompilerResult visit(ModTy.Module node) { + return compileRootNode("", ArgumentInfo.NO_ARGS, node.getSourceRange(), b -> { + beginRootNode(node, null, b); + visitModuleBody(node.body, b); + endRootNode(b); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ModTy.Expression node) { + return compileRootNode("", ArgumentInfo.NO_ARGS, node.getSourceRange(), b -> { + beginRootNode(node, null, b); + beginReturn(b); + new StatementCompiler(b).visitNode(node.body); + endReturn(b); + endRootNode(b); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ModTy.Interactive node) { + return compileRootNode("", ArgumentInfo.NO_ARGS, node.getSourceRange(), b -> { + beginRootNode(node, null, b); + visitModuleBody(node.body, b); + endRootNode(b); + }); + } + + private void visitModuleBody(StmtTy[] body, Builder b) { + if (body != null) { + if (containsAnnotations(body)) { + b.emitSetupAnnotations(); + } + + StatementCompiler statementCompiler = new StatementCompiler(b); + if (isInteractive) { + for (int i = 0; i < body.length; i++) { + StmtTy bodyNode = body[i]; + if (i == body.length - 1) { + bodyNode.accept(statementCompiler); + + // For interactive code, always return None. + beginReturn(b); + b.emitLoadConstant(PNone.NONE); + endReturn(b); + } else { + bodyNode.accept(statementCompiler); + } + } + } else { + int i = 0; + TruffleString docstring = getDocstring(body); + if (docstring != null) { + /* + * Skip over the docstring so it does not get evaluated (and registered as a + * constant) for higher optimization levels. We manually add it as a constant + * for lower levels. + */ + i++; + if (ctx.optimizationLevel < 2) { + beginStoreLocal("__doc__", b); + emitPythonConstant(docstring, b); + endStoreLocal("__doc__", b); + } + } + if (i == body.length) { + // Special case: module body just consists of a docstring. + beginReturn(b); + b.emitLoadConstant(PNone.NONE); + endReturn(b); + return; + } + + for (; i < body.length; i++) { + StmtTy bodyNode = body[i]; + if (i == body.length - 1) { + if (bodyNode instanceof StmtTy.Expr expr) { + // Return the value of the last statement for interop eval. + beginReturn(b); + expr.value.accept(statementCompiler); + endReturn(b); + } else { + bodyNode.accept(statementCompiler); + beginReturn(b); + b.emitLoadConstant(PNone.NONE); + endReturn(b); + } + } else { + bodyNode.accept(statementCompiler); + } + } + } + } else { + beginReturn(b); + b.emitLoadConstant(PNone.NONE); + endReturn(b); + } + } + + private static TruffleString getDocstring(StmtTy[] body) { + if (body != null && body.length > 0) { + StmtTy stmt = body[0]; + if (stmt instanceof StmtTy.Expr expr // + && expr.value instanceof ExprTy.Constant constant // + && constant.value.kind == ConstantValue.Kind.RAW) { + return constant.value.getRaw(TruffleString.class); + } + } + return null; + } + + @Override + public BytecodeDSLCompilerResult visit(StmtTy.FunctionDef node) { + return compileRootNode(node.name, ArgumentInfo.fromArguments(node.args), node.getSourceRange(), + b -> emitFunctionDef(node, node.args, node.body, b, getDocstring(node.body), false)); + } + + @Override + public BytecodeDSLCompilerResult visit(StmtTy.AsyncFunctionDef node) { + return compileRootNode(node.name, ArgumentInfo.fromArguments(node.args), node.getSourceRange(), + b -> emitFunctionDef(node, node.args, node.body, b, getDocstring(node.body), false)); + } + + @Override + public BytecodeDSLCompilerResult visit(ExprTy.Lambda node) { + return compileRootNode("", ArgumentInfo.fromArguments(node.args), node.getSourceRange(), + b -> emitFunctionDef(node, node.args, new SSTNode[]{node.body}, b, null, !scope.isGenerator())); + } + + private void emitFunctionDef(SSTNode node, ArgumentsTy args, SSTNode[] body, Builder b, Object docstring, boolean isRegularLambda) { + beginRootNode(node, args, b); + + int i = 0; + if (docstring != null) { + i++; + if (ctx.optimizationLevel < 2) { + addConstant(docstring); + } else { + addConstant(PNone.NONE); + } + } else { + addConstant(PNone.NONE); + } + + StatementCompiler statementCompiler = new StatementCompiler(b); + + if (isRegularLambda) { + assert i == 0; + assert body[0] instanceof ExprTy; + beginReturn(b); + body[0].accept(statementCompiler); + endReturn(b); + } else { + for (; i < body.length; i++) { + body[i].accept(statementCompiler); + } + beginReturn(b); + emitPythonConstant(PNone.NONE, b); + endReturn(b); + } + + endRootNode(b); + } + + @Override + public BytecodeDSLCompilerResult visit(StmtTy.ClassDef node) { + return compileRootNode(node.name, ArgumentInfo.NO_ARGS, node.getSourceRange(), b -> { + beginRootNode(node, null, b); + + beginStoreLocal("__module__", b); + emitReadLocal("__name__", b); + endStoreLocal("__module__", b); + + beginStoreLocal("__qualname__", b); + emitPythonConstant(toTruffleStringUncached(ctx.getQualifiedName(scope)), b); + endStoreLocal("__qualname__", b); + + if (containsAnnotations(node.body)) { + b.emitSetupAnnotations(); + } + + int i = 0; + TruffleString docstring = getDocstring(node.body); + if (docstring != null) { + i++; + if (ctx.optimizationLevel < 2) { + beginStoreLocal("__doc__", b); + emitPythonConstant(docstring, b); + endStoreLocal("__doc__", b); + } + } + + StatementCompiler statementCompiler = new StatementCompiler(b); + for (; i < node.body.length; i++) { + node.body[i].accept(statementCompiler); + } + + if (scope.needsClassClosure()) { + beginStoreLocal("__classcell__", b); + b.emitLoadLocal(cellLocals.get("__class__")); + endStoreLocal("__classcell__", b); + + beginReturn(b); + b.emitLoadLocal(cellLocals.get("__class__")); + endReturn(b); + } else { + beginReturn(b); + b.emitLoadConstant(PNone.NONE); + endReturn(b); + } + + endRootNode(b); + }); + } + + private boolean beginComprehension(ComprehensionTy comp, int index, Builder b) { + boolean newStatement = beginSourceSection(comp, b); + + BytecodeLocal localIter = b.createLocal(); + BytecodeLocal localValue = b.createLocal(); + StatementCompiler statementCompiler = new StatementCompiler(b); + + b.beginStoreLocal(localIter); + b.beginGetIter(); + if (index == 0) { + b.emitLoadArgument(PArguments.USER_ARGUMENTS_OFFSET); + } else { + comp.iter.accept(statementCompiler); + } + b.endGetIter(); + b.endStoreLocal(); + + b.beginWhile(); + + b.beginBlock(); + b.emitTraceLineAtLoopHeader(currentLocation.startLine); + b.beginForIterate(localValue); + b.emitLoadLocal(localIter); + b.endForIterate(); + b.endBlock(); + + b.beginBlock(); + + comp.target.accept(statementCompiler.new StoreVisitor(() -> b.emitLoadLocal(localValue))); + + if (comp.ifs != null) { + for (int i = 0; i < comp.ifs.length; i++) { + b.beginIfThen(); + statementCompiler.visitCondition(comp.ifs[i]); + b.beginBlock(); + } + } + + return newStatement; + } + + private void endComprehension(ComprehensionTy comp, Builder b, boolean newStatement) { + if (comp.ifs != null) { + for (int i = 0; i < len(comp.ifs); i++) { + b.endBlock(); + b.endIfThen(); + } + } + + b.endBlock(); + b.endWhile(); + + endSourceSection(b, newStatement); + } + + private BytecodeDSLCompilerResult buildComprehensionCodeUnit(SSTNode node, ComprehensionTy[] generators, String name, + Consumer emptyCollectionProducer, + BiConsumer accumulateProducer) { + return compileRootNode(name, new ArgumentInfo(1, 0, 0, false, false), node.getSourceRange(), b -> { + beginRootNode(node, null, b); + + StatementCompiler statementCompiler = new StatementCompiler(b); + boolean isGenerator = emptyCollectionProducer == null; + BytecodeLocal collectionLocal = null; + if (!isGenerator) { + collectionLocal = b.createLocal(); + b.beginStoreLocal(collectionLocal); + emptyCollectionProducer.accept(statementCompiler); + b.endStoreLocal(); + } + + boolean[] newStatement = new boolean[generators.length]; + for (int i = 0; i < generators.length; i++) { + newStatement[i] = beginComprehension(generators[i], i, b); + } + accumulateProducer.accept(statementCompiler, collectionLocal); + for (int i = generators.length - 1; i >= 0; i--) { + endComprehension(generators[i], b, newStatement[i]); + } + + beginReturn(b); + if (isGenerator) { + b.emitLoadConstant(PNone.NONE); + } else { + b.emitLoadLocal(collectionLocal); + } + endReturn(b); + + endRootNode(b); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ExprTy.ListComp node) { + return buildComprehensionCodeUnit(node, node.generators, "", + (statementCompiler) -> { + statementCompiler.b.beginMakeList(); + statementCompiler.b.emitLoadConstant(PythonUtils.EMPTY_OBJECT_ARRAY); + statementCompiler.b.endMakeList(); + }, + (statementCompiler, collection) -> { + statementCompiler.b.beginListAppend(); + statementCompiler.b.emitLoadLocal(collection); + node.element.accept(statementCompiler); + statementCompiler.b.endListAppend(); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ExprTy.DictComp node) { + return buildComprehensionCodeUnit(node, node.generators, "", + (statementCompiler) -> { + statementCompiler.b.beginMakeDict(0); + statementCompiler.b.endMakeDict(); + }, + (statementCompiler, collection) -> { + statementCompiler.b.beginSetDictItem(); + statementCompiler.b.emitLoadLocal(collection); + node.key.accept(statementCompiler); + node.value.accept(statementCompiler); + statementCompiler.b.endSetDictItem(); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ExprTy.SetComp node) { + return buildComprehensionCodeUnit(node, node.generators, "", + (statementCompiler) -> { + statementCompiler.b.beginMakeSet(); + statementCompiler.b.emitLoadConstant(PythonUtils.EMPTY_OBJECT_ARRAY); + statementCompiler.b.endMakeSet(); + }, + (statementCompiler, collection) -> { + statementCompiler.b.beginSetAdd(); + statementCompiler.b.emitLoadLocal(collection); + node.element.accept(statementCompiler); + statementCompiler.b.endSetAdd(); + }); + } + + @Override + public BytecodeDSLCompilerResult visit(ExprTy.GeneratorExp node) { + return buildComprehensionCodeUnit(node, node.generators, "", + null, + (statementCompiler, collection) -> emitYield((statementCompiler_) -> node.element.accept(statementCompiler_), statementCompiler)); + } + + enum NameOperation { + Read, + BeginWrite, + EndWrite, + Delete + } + + private String mangle(String name) { + return ctx.mangle(scope, name); + } + + private void emitNotImplemented(String what, Builder b) { + b.beginRaiseNotImplementedError(); + emitPythonConstant(toTruffleStringUncached(what), b); + b.endRaiseNotImplementedError(); + } + + /** + * Use this method for values that should show up in co_consts. + */ + private void emitPythonConstant(Object constant, Builder b) { + b.emitLoadConstant(addConstant(constant)); + } + + /** + * This helper encapsulates all of the logic needed to yield and resume. Yields should not be + * emitted directly. + */ + private static void emitYield(Consumer yieldValueProducer, StatementCompiler statementCompiler) { + statementCompiler.b.beginResumeYield(); + statementCompiler.b.beginYield(); + statementCompiler.b.beginPreYield(); + yieldValueProducer.accept(statementCompiler); + statementCompiler.b.endPreYield(); + statementCompiler.b.endYield(); + statementCompiler.b.endResumeYield(); + } + + private void emitNameCellOperation(String mangled, NameOperation op, Builder b) { + int index; + BytecodeLocal local; + if (freevars.containsKey(mangled)) { + index = freevars.get(mangled) + cellvars.size(); + local = freeLocals.get(mangled); + } else { + index = cellvars.get(mangled); + local = cellLocals.get(mangled); + } + + switch (op) { + case Read: + if (scope.isClass()) { + b.beginClassLoadCell(index); + b.emitLoadLocal(local); + b.endClassLoadCell(); + } else { + b.beginLoadCell(index); + b.emitLoadLocal(local); + b.endLoadCell(); + } + break; + case Delete: + b.beginClearCell(index); + b.emitLoadLocal(local); + b.endClearCell(); + break; + case BeginWrite: + b.beginStoreCell(); + b.emitLoadLocal(local); + break; + case EndWrite: + b.endStoreCell(); + break; + default: + throw new UnsupportedOperationException("unknown value: " + op); + } + } + + private void emitNameFastOperation(String mangled, NameOperation op, Builder b) { + BytecodeLocal local = locals.get(mangled); + switch (op) { + case Read: + b.emitCheckAndLoadLocal(local, varnames.get(mangled)); + break; + case Delete: + b.emitDeleteLocal(local, varnames.get(mangled)); + break; + case BeginWrite: + if (local == null) { + throw new NullPointerException("local " + mangled + " not defined"); + } + b.beginStoreLocal(local); + break; + case EndWrite: + b.endStoreLocal(); + break; + default: + throw new UnsupportedOperationException("unknown value: " + op); + } + } + + private void emitNameGlobalOperation(String name, NameOperation op, Builder b) { + assert locals.get(name) == null; + names.putIfAbsent(name, names.size()); + TruffleString tsName = toTruffleStringUncached(name); + switch (op) { + case Read: + b.emitReadGlobal(tsName); + break; + case Delete: + b.emitDeleteGlobal(tsName); + break; + case BeginWrite: + b.beginWriteGlobal(tsName); + break; + case EndWrite: + b.endWriteGlobal(); + break; + default: + throw new UnsupportedOperationException("unknown value: " + op); + } + } + + private void emitNameSlowOperation(String name, NameOperation op, Builder b) { + assert locals.get(name) == null; + names.putIfAbsent(name, names.size()); + TruffleString tsName = toTruffleStringUncached(name); + switch (op) { + case Read: + b.emitReadName(tsName); + break; + case Delete: + b.emitDeleteName(tsName); + break; + case BeginWrite: + b.beginWriteName(tsName); + break; + case EndWrite: + b.endWriteName(); + break; + default: + throw new UnsupportedOperationException("unknown value: " + op); + } + } + + private void emitNameOperation(String name, NameOperation op, Builder b) { + checkForbiddenName(name, op); + + String mangled = mangle(name); + EnumSet uses = scope.getUseOfName(mangled); + + if (uses != null) { + if (uses.contains(DefUse.Free)) { + assert freevars.containsKey(mangled) : String.format("scope analysis did not mark %s as a free variable", mangled); + emitNameCellOperation(mangled, op, b); + return; + } else if (uses.contains(DefUse.Cell)) { + assert cellvars.containsKey(mangled) : String.format("scope analysis did not mark %s as a cell variable", mangled); + emitNameCellOperation(mangled, op, b); + return; + } else if (uses.contains(DefUse.Local)) { + if (scope.isFunction()) { + assert varnames.containsKey(mangled) : String.format("scope analysis did not mark %s as a regular variable", mangled); + emitNameFastOperation(mangled, op, b); + return; + } + } else if (uses.contains(DefUse.GlobalImplicit)) { + if (scope.isFunction()) { + emitNameGlobalOperation(mangled, op, b); + return; + } + } else if (uses.contains(DefUse.GlobalExplicit)) { + emitNameGlobalOperation(mangled, op, b); + return; + } + } + emitNameSlowOperation(mangled, op, b); + } + + private void emitReadLocal(String name, Builder b) { + emitNameOperation(name, NameOperation.Read, b); + } + + private void emitDelLocal(String name, Builder b) { + emitNameOperation(name, NameOperation.Delete, b); + } + + private void beginStoreLocal(String name, Builder b) { + emitNameOperation(name, NameOperation.BeginWrite, b); + } + + private void endStoreLocal(String name, Builder b) { + emitNameOperation(name, NameOperation.EndWrite, b); + } + + private BytecodeLocal getLocal(String name) { + return locals.get(mangle(name)); + } + + public void setUpFrame(ArgumentsTy args, Builder b) { + /** + * This method does two things: + * + * 1. It allocates a contiguous region in the frame for Python variables. Some nodes in the + * GraalPy AST expect locals to be allocated contiguously starting at index 0. The resultant + * frame has the following layout: + * + * [var1, var2, ..., cell1, cell2, ..., free1, free2, ..., temp1, temp2, ..., stack] + * + * The temp variables are allocated elsewhere during compilation (e.g., to store an + * intermediate computation) and the stack space is automatically reserved by the DSL. + * + * 2. It emits code to copy arguments, initialize cells, and copy free variables. + */ + + // 1. Allocate space in the frame. + if (scope.isFunction()) { + String[] regularVariables = orderedKeys(varnames, new String[0]); + for (int i = 0; i < regularVariables.length; i++) { + locals.put(regularVariables[i], b.createLocal()); + } + } + + String[] cellVariables = orderedKeys(cellvars, new String[0]); + BytecodeLocal[] cellVariableLocals = new BytecodeLocal[cellVariables.length]; + for (int i = 0; i < cellVariables.length; i++) { + BytecodeLocal local = b.createLocal(); + cellLocals.put(cellVariables[i], local); + cellVariableLocals[i] = local; + } + + String[] freeVariables = orderedKeys(freevars, new String[0]); + BytecodeLocal[] freeVariableLocals = new BytecodeLocal[freeVariables.length]; + for (int i = 0; i < freeVariables.length; i++) { + BytecodeLocal local = b.createLocal(); + freeLocals.put(freeVariables[i], local); + freeVariableLocals[i] = local; + } + + // 2. Copy arguments, initialize cells, and copy free variables. + copyArguments(args, b); + + if (cellVariableLocals.length > 0) { + List toClear = new ArrayList<>(); + + b.beginStoreRange(cellVariableLocals); + b.beginCollectToObjectArray(); + for (int i = 0; i < cellVariableLocals.length; i++) { + b.beginCreateCell(); + if (scope.getUseOfName(cellVariables[i]).contains(DefUse.DefParam)) { + /* + * To simplify the argument copying performed above, we copy cell params into + * regular locals just like all other arguments. Then, here we move the value + * into a cell and clear the regular local. + */ + BytecodeLocal param = getLocal(cellVariables[i]); + b.emitLoadLocal(param); + toClear.add(param); + } else { + b.emitLoadNull(); + } + b.endCreateCell(); + } + b.endCollectToObjectArray(); + b.endStoreRange(); + + for (BytecodeLocal local : toClear) { + b.emitClearLocal(local); + } + } + + if (freeVariableLocals.length > 0) { + b.beginStoreRange(freeVariableLocals); + b.emitLoadClosure(); + b.endStoreRange(); + } + } + + private void copyArguments(ArgumentsTy args, Builder b) { + if (args == null) { + return; + } + + int argIdx = PArguments.USER_ARGUMENTS_OFFSET; + if (args.posOnlyArgs != null) { + for (int i = 0; i < args.posOnlyArgs.length; i++) { + BytecodeLocal local = getLocal(args.posOnlyArgs[i].arg); + assert local != null; + b.beginStoreLocal(local); + b.emitLoadArgument(argIdx++); + b.endStoreLocal(); + } + } + + if (args.args != null) { + for (int i = 0; i < args.args.length; i++) { + BytecodeLocal local = getLocal(args.args[i].arg); + assert local != null; + b.beginStoreLocal(local); + b.emitLoadArgument(argIdx++); + b.endStoreLocal(); + } + } + + if (args.kwOnlyArgs != null) { + for (int i = 0; i < args.kwOnlyArgs.length; i++) { + BytecodeLocal local = getLocal(args.kwOnlyArgs[i].arg); + assert local != null; + b.beginStoreLocal(local); + b.emitLoadArgument(argIdx++); + b.endStoreLocal(); + } + } + + if (args.varArg != null) { + BytecodeLocal local = getLocal(args.varArg.arg); + assert local != null; + b.beginStoreLocal(local); + b.emitLoadVariableArguments(); + b.endStoreLocal(); + } + + if (args.kwArg != null) { + BytecodeLocal local = getLocal(args.kwArg.arg); + assert local != null; + b.beginStoreLocal(local); + b.emitLoadKeywordArguments(); + b.endStoreLocal(); + } + } + + private static int len(T[] arr) { + return arr == null ? 0 : arr.length; + } + + /* ---------------- StatementCompiler -------------------- */ + + public class StatementCompiler implements BaseBytecodeDSLVisitor { + private final Builder b; + + private BytecodeLabel breakLabel; + private BytecodeLabel continueLabel; + + public StatementCompiler(Builder b) { + this.b = b; + } + + // --------------------- visitor --------------------------- + + @Override + public Void visit(AliasTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(ArgTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(ArgumentsTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(ComprehensionTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(ExprTy.Attribute node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginGetAttribute(toTruffleStringUncached(mangle(node.attr))); + node.value.accept(this); + b.endGetAttribute(); + + endSourceSection(b, newStatement); + + return null; + } + + @Override + public Void visit(ExprTy.Await node) { + // TODO if !IS_TOP_LEVEL_AWAIT + // TODO handle await in comprehension correctly (currently, it is always allowed) + if (!scope.isFunction()) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'await' outside function"); + } + if (scopeType != CompilationScope.AsyncFunction && scopeType != CompilationScope.Comprehension) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'await' outside async function"); + } + boolean newStatement = beginSourceSection(node, b); + emitAwait(() -> node.value.accept(this)); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.BinOp node) { + boolean newStatement = beginSourceSection(node, b); + switch (node.op) { + case Add: + b.beginPyNumberAdd(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberAdd(); + break; + case BitAnd: + b.beginPyNumberAnd(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberAnd(); + break; + case BitOr: + b.beginPyNumberOr(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberOr(); + break; + case BitXor: + b.beginPyNumberXor(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberXor(); + break; + case Div: + b.beginPyNumberTrueDivide(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberTrueDivide(); + break; + case FloorDiv: + b.beginPyNumberFloorDivide(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberFloorDivide(); + break; + case LShift: + b.beginPyNumberLshift(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberLshift(); + break; + case MatMult: + b.beginPyNumberMatrixMultiply(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberMatrixMultiply(); + break; + case Mod: + b.beginPyNumberRemainder(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberRemainder(); + break; + case Mult: + b.beginPyNumberMultiply(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberMultiply(); + break; + case Pow: + b.beginPow(); + node.left.accept(this); + node.right.accept(this); + b.endPow(); + break; + case RShift: + b.beginPyNumberRshift(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberRshift(); + break; + case Sub: + b.beginPyNumberSubtract(); + node.left.accept(this); + node.right.accept(this); + b.endPyNumberSubtract(); + break; + default: + throw new UnsupportedOperationException("" + node.getClass()); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.BoolOp node) { + boolean newStatement = beginSourceSection(node, b); + + if (node.op == BoolOpTy.And) { + b.beginBoolAnd(); + } else { + b.beginBoolOr(); + } + + visitSequence(node.values); + + if (node.op == BoolOpTy.And) { + b.endBoolAnd(); + } else { + b.endBoolOr(); + } + + endSourceSection(b, newStatement); + return null; + } + + private static boolean anyIsStarred(SSTNode[] nodes) { + for (int i = 0; i < nodes.length; i++) { + if (nodes[i] instanceof ExprTy.Starred) { + return true; + } + } + + return false; + } + + protected final void validateKeywords(KeywordTy[] keywords) { + for (int i = 0; i < keywords.length; i++) { + if (keywords[i].arg != null) { + checkForbiddenName(keywords[i].arg, NameOperation.BeginWrite); + for (int j = i + 1; j < keywords.length; j++) { + if (keywords[i].arg.equals(keywords[j].arg)) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "keyword argument repeated: " + keywords[i].arg); + } + } + } + } + } + + private static boolean isAttributeLoad(ExprTy node) { + return node instanceof ExprTy.Attribute && ((ExprTy.Attribute) node).context == ExprContextTy.Load; + } + + private static final int NUM_ARGS_MAX_FIXED = 4; + + private void emitCall(ExprTy func, ExprTy[] args, KeywordTy[] keywords) { + validateKeywords(keywords); + + boolean isMethodCall = isAttributeLoad(func) && keywords.length == 0; + int numArgs = len(args) + (isMethodCall ? 1 : 0); + boolean useVariadic = anyIsStarred(args) || len(keywords) > 0 || numArgs > NUM_ARGS_MAX_FIXED; + + // @formatter:off + if (useVariadic) { + b.beginCallVarargsMethod(); + } else { + switch (numArgs) { + case 0: b.beginCallNilaryMethod(); break; + case 1: b.beginCallUnaryMethod(); break; + case 2: b.beginCallBinaryMethod(); break; + case 3: b.beginCallTernaryMethod(); break; + case 4: b.beginCallQuaternaryMethod(); break; + } + } + + // @formatter:on + + if (isMethodCall) { + // The receiver is needed for method lookup and for the first argument. + BytecodeLocal receiver = b.createLocal(); + + if (useVariadic) { + BytecodeLocal function = b.createLocal(); + b.beginBlock(); + b.beginStoreLocal(function); + emitGetMethod(func, receiver); + b.endStoreLocal(); + b.emitLoadLocal(function); + b.endBlock(); + + emitUnstar(() -> b.emitLoadLocal(receiver), args); + emitKeywords(keywords, function); + } else { + assert len(keywords) == 0; + + emitGetMethod(func, receiver); + b.emitLoadLocal(receiver); + visitSequence(args); + } + + } else { + if (useVariadic) { + BytecodeLocal function = b.createLocal(); + + b.beginBlock(); + b.beginStoreLocal(function); + func.accept(this); + b.endStoreLocal(); + b.emitLoadLocal(function); + b.endBlock(); + + emitUnstar(args); + emitKeywords(keywords, function); + } else { + assert len(keywords) == 0; + + func.accept(this); + visitSequence(args); + } + } + + // @formatter:off + if (useVariadic) { + b.endCallVarargsMethod(); + } else { + switch (numArgs) { + case 0: b.endCallNilaryMethod(); break; + case 1: b.endCallUnaryMethod(); break; + case 2: b.endCallBinaryMethod(); break; + case 3: b.endCallTernaryMethod(); break; + case 4: b.endCallQuaternaryMethod(); break; + } + } + // @formatter:on + } + + private void emitGetMethod(ExprTy func, BytecodeLocal receiver) { + assert isAttributeLoad(func); + ExprTy.Attribute attrAccess = (ExprTy.Attribute) func; + b.beginBlock(); + b.beginStoreLocal(receiver); + attrAccess.value.accept(this); + b.endStoreLocal(); + + String mangled = mangle(attrAccess.attr); + b.beginGetMethod(toTruffleStringUncached(mangled)); + b.emitLoadLocal(receiver); + b.endGetMethod(); + b.endBlock(); + } + + @Override + public Void visit(ExprTy.Call node) { + boolean newStatement = beginSourceSection(node, b); + emitCall(node.func, node.args, node.keywords); + endSourceSection(b, newStatement); + return null; + } + + private void beginComparison(CmpOpTy op) { + switch (op) { + case Eq: + b.beginEq(); + break; + case NotEq: + b.beginNe(); + break; + case Lt: + b.beginLt(); + break; + case LtE: + b.beginLe(); + break; + case Gt: + b.beginGt(); + break; + case GtE: + b.beginGe(); + break; + case Is: + b.beginIs(); + break; + case IsNot: + b.beginNot(); + b.beginIs(); + break; + case In: + b.beginContains(); + break; + case NotIn: + b.beginNot(); + b.beginContains(); + break; + default: + throw new UnsupportedOperationException("" + op); + } + } + + private void endComparison(CmpOpTy op) { + switch (op) { + case Eq: + b.endEq(); + break; + case NotEq: + b.endNe(); + break; + case Lt: + b.endLt(); + break; + case LtE: + b.endLe(); + break; + case Gt: + b.endGt(); + break; + case GtE: + b.endGe(); + break; + case Is: + b.endIs(); + break; + case IsNot: + b.endIs(); + b.endNot(); + break; + case In: + b.endContains(); + break; + case NotIn: + b.endContains(); + b.endNot(); + break; + default: + throw new UnsupportedOperationException("" + op); + } + } + + @Override + public Void visit(ExprTy.Compare node) { + boolean newStatement = beginSourceSection(node, b); + checkCompare(node); + + boolean multipleComparisons = node.comparators.length > 1; + + if (multipleComparisons) { + b.beginBoolAnd(); + } + + BytecodeLocal tmp = b.createLocal(); + + for (int i = 0; i < node.comparators.length; i++) { + beginComparison(node.ops[i]); + + if (i == 0) { + node.left.accept(this); + } else { + b.emitLoadLocal(tmp); + } + + if (i != node.comparators.length - 1) { + b.beginTeeLocal(tmp); + } + node.comparators[i].accept(this); + if (i != node.comparators.length - 1) { + b.endTeeLocal(); + } + + endComparison(node.ops[i]); + } + + if (multipleComparisons) { + b.endBoolAnd(); + } + + endSourceSection(b, newStatement); + return null; + } + + private void warn(SSTNode node, String message, Object... arguments) { + ctx.errorCallback.onWarning(WarningType.Syntax, node.getSourceRange(), message, arguments); + } + + private void checkCompare(ExprTy node) { + if (!(node instanceof ExprTy.Compare compare)) { + return; + } + boolean left = checkIsArg(compare.left); + int n = compare.ops == null ? 0 : compare.ops.length; + for (int i = 0; i < n; ++i) { + CmpOpTy op = compare.ops[i]; + boolean right = checkIsArg(compare.comparators[i]); + if (op == CmpOpTy.Is || op == CmpOpTy.IsNot) { + if (!right || !left) { + warn(compare, op == CmpOpTy.Is ? "\"is\" with a literal. Did you mean \"==\"?" : "\"is not\" with a literal. Did you mean \"!=\"?"); + } + } + left = right; + } + } + + private static boolean checkIsArg(ExprTy e) { + if (e instanceof ExprTy.Constant) { + ConstantValue.Kind kind = ((Constant) e).value.kind; + return kind == Kind.NONE || kind == Kind.BOOLEAN || kind == Kind.ELLIPSIS; + } + return true; + } + + private void createConstant(ConstantValue value) { + switch (value.kind) { + case NONE: + b.emitLoadConstant(PNone.NONE); + break; + case ELLIPSIS: + b.emitLoadConstant(PEllipsis.INSTANCE); + break; + case BOOLEAN: + emitPythonConstant(value.getBoolean(), b); + break; + case LONG: + emitPythonConstant(getConstantNumber(value.getLong()), b); + break; + case DOUBLE: + emitPythonConstant(value.getDouble(), b); + break; + case COMPLEX: { + double[] complex = value.getComplex(); + addConstant(complex); + b.emitLoadComplex(complex[0], complex[1]); + break; + } + case BIGINTEGER: + addConstant(value.getBigInteger()); + b.emitLoadBigInt(value.getBigInteger()); + break; + case RAW: + emitPythonConstant(value.getRaw(TruffleString.class), b); + break; + case BYTES: + addConstant(value.getBytes()); + b.emitLoadBytes(value.getBytes()); + break; + case TUPLE: + b.beginMakeTuple(); + b.beginCollectToObjectArray(); + for (ConstantValue cv : value.getTupleElements()) { + createConstant(cv); + } + b.endCollectToObjectArray(); + b.endMakeTuple(); + break; + case FROZENSET: + b.beginMakeFrozenSet(value.getFrozensetElements().length); + for (ConstantValue cv : value.getFrozensetElements()) { + createConstant(cv); + } + b.endMakeFrozenSet(); + break; + + default: + throw new UnsupportedOperationException("not supported: " + value.kind); + } + } + + /** + * Some AST nodes have type guards expecting ints rather than long. When the actual constant + * fits into something smaller, convert it accordingly. + */ + private Object getConstantNumber(long value) { + if (value == (int) value) { + return (int) value; + } else { + return value; + } + } + + @Override + public Void visit(ExprTy.Constant node) { + boolean newStatement = beginSourceSection(node, b); + createConstant(node.value); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Dict node) { + boolean newStatement = beginSourceSection(node, b); + + if (len(node.keys) == 0) { + b.beginMakeDict(0); + b.endMakeDict(); + } else { + b.beginMakeDict(node.keys.length); + for (int i = 0; i < node.keys.length; i++) { + if (node.keys[i] == null) { + b.emitLoadConstant(PNone.NO_VALUE); + } else { + node.keys[i].accept(this); + } + node.values[i].accept(this); + } + b.endMakeDict(); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.DictComp node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginCallUnaryMethod(); + emitMakeFunction(node, "", COMPREHENSION_ARGS, null); + node.generators[0].iter.accept(this); + b.endCallUnaryMethod(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.FormattedValue node) { + boolean newStatement = beginSourceSection(node, b); + b.beginFormat(); + + // @formatter:off + switch (node.conversion) { + case 's': b.beginFormatStr(); break; + case 'r': b.beginFormatRepr(); break; + case 'a': b.beginFormatAscii(); break; + case -1: break; + default: throw new UnsupportedOperationException("unknown conversion: " + node.conversion); + } + // @formatter:on + + node.value.accept(this); + + // @formatter:off + switch (node.conversion) { + case 's': b.endFormatStr(); break; + case 'r': b.endFormatRepr(); break; + case 'a': b.endFormatAscii(); break; + case -1: break; + default: throw new UnsupportedOperationException("unknown conversion: " + node.conversion); + } + // @formatter:on + + if (node.formatSpec != null) { + node.formatSpec.accept(this); + } else { + b.emitLoadConstant(StringLiterals.T_EMPTY_STRING); + } + + b.endFormat(); + endSourceSection(b, newStatement); + + return null; + } + + @Override + public Void visit(ExprTy.GeneratorExp node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginCallUnaryMethod(); + emitMakeFunction(node, "", COMPREHENSION_ARGS, null); + node.generators[0].iter.accept(this); + b.endCallUnaryMethod(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.IfExp node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginConditional(); + visitCondition(node.test); + node.body.accept(this); + node.orElse.accept(this); + b.endConditional(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.JoinedStr node) { + boolean newStatement = beginSourceSection(node, b); + + if (node.values.length == 1) { + node.values[0].accept(this); + } else { + b.beginBuildString(node.values.length); + visitSequence(node.values); + b.endBuildString(); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Lambda node) { + boolean newStatement = beginSourceSection(node, b); + emitMakeFunction(node, "", node.args, null); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.List node) { + boolean newStatement = beginSourceSection(node, b); + + ConstantCollection constantCollection = Compiler.tryCollectConstantCollection(node.elements); + if (constantCollection != null) { + emitConstantList(constantCollection); + } else { + b.beginMakeList(); + emitUnstar(node.elements); + b.endMakeList(); + } + + endSourceSection(b, newStatement); + return null; + } + + private static final String COMPREHENSION_ARGUMENT_NAME = ".0"; + private static final ArgumentsTy COMPREHENSION_ARGS = new ArgumentsTy(new ArgTy[]{new ArgTy(COMPREHENSION_ARGUMENT_NAME, null, null, null)}, null, null, null, null, null, null, null); + + @Override + public Void visit(ExprTy.ListComp node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginCallUnaryMethod(); + emitMakeFunction(node, "", COMPREHENSION_ARGS, null); + node.generators[0].iter.accept(this); + b.endCallUnaryMethod(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Name node) { + boolean newStatement = beginSourceSection(node, b); + emitReadLocal(node.id, b); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.NamedExpr node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + + // save expr result to "tmp" + BytecodeLocal tmp = b.createLocal(); + b.beginStoreLocal(tmp); + node.value.accept(this); + b.endStoreLocal(); + + node.target.accept(new StoreVisitor(() -> { + b.emitLoadLocal(tmp); + })); + + b.emitLoadLocal(tmp); + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + private void emitConstantList(ConstantCollection constantCollection) { + addConstant(constantCollection.collection); + switch (constantCollection.elementType) { + case CollectionBits.ELEMENT_INT: + b.emitMakeConstantIntList((int[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_LONG: + b.emitMakeConstantLongList((long[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_BOOLEAN: + b.emitMakeConstantBooleanList((boolean[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_DOUBLE: + b.emitMakeConstantDoubleList((double[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_OBJECT: + b.emitMakeConstantObjectList((Object[]) constantCollection.collection); + break; + default: + throw CompilerDirectives.shouldNotReachHere(); + } + } + + private void emitConstantTuple(ConstantCollection constantCollection) { + addConstant(constantCollection.collection); + switch (constantCollection.elementType) { + case CollectionBits.ELEMENT_INT: + b.emitMakeConstantIntTuple((int[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_LONG: + b.emitMakeConstantLongTuple((long[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_BOOLEAN: + b.emitMakeConstantBooleanTuple((boolean[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_DOUBLE: + b.emitMakeConstantDoubleTuple((double[]) constantCollection.collection); + break; + case CollectionBits.ELEMENT_OBJECT: + b.emitMakeConstantObjectTuple((Object[]) constantCollection.collection); + break; + default: + throw CompilerDirectives.shouldNotReachHere(); + } + } + + /** + * Converts a sequence of expressions of which some may be starred into just an Object[]. + * + * @param args the sequence of expressions + */ + private void emitUnstar(ExprTy[] args) { + emitUnstar(null, args); + } + + /** + * Same as above, but takes an optional Runnable to produce elements at the beginning of the + * sequence. + * + * @param initialElementsProducer a runnable to produce the first element(s) of the + * sequence. + * @param args the sequence of expressions to unstar + */ + private void emitUnstar(Runnable initialElementsProducer, ExprTy[] args) { + if (len(args) == 0 && initialElementsProducer == null) { + b.emitLoadConstant(PythonUtils.EMPTY_OBJECT_ARRAY); + } else if (anyIsStarred(args)) { + /** + * We emit one or more arrays and concatenate them using Unstar. Each array + * corresponds to a contiguous sequence of arguments or the result of unpacking a + * single starred argument. + * + * For example, for the argument list a, b, *c, d, e, *f, g we would emit: + * + * @formatter:off + * Unstar( + * CollectToObjectArray(a, b), + * UnpackStarred(c), + * CollectToObjectArray(d, e), + * UnpackStarred(f), + * CollectToObjectArray(g) + * ) + * @formatter:on + */ + b.beginUnstar(); + boolean inVariadic = false; + int numOperands = 0; + + if (initialElementsProducer != null) { + b.beginCollectToObjectArray(); + initialElementsProducer.run(); + inVariadic = true; + } + + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof ExprTy.Starred) { + if (inVariadic) { + b.endCollectToObjectArray(); + inVariadic = false; + numOperands++; + } + + b.beginUnpackStarred(); + ((ExprTy.Starred) args[i]).value.accept(this); + b.endUnpackStarred(); + numOperands++; + } else { + if (!inVariadic) { + b.beginCollectToObjectArray(); + inVariadic = true; + } + + args[i].accept(this); + } + } + + if (inVariadic) { + b.endCollectToObjectArray(); + numOperands++; + } + + b.endUnstar(numOperands); + } else { + b.beginCollectToObjectArray(); + if (initialElementsProducer != null) { + initialElementsProducer.run(); + } + visitSequence(args); + b.endCollectToObjectArray(); + } + } + + @Override + public Void visit(ExprTy.Set node) { + boolean newStatement = beginSourceSection(node, b); + b.beginMakeSet(); + if (len(node.elements) == 0) { + b.emitLoadConstant(PythonUtils.EMPTY_OBJECT_ARRAY); + } else { + emitUnstar(node.elements); + } + b.endMakeSet(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.SetComp node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginCallUnaryMethod(); + emitMakeFunction(node, "", COMPREHENSION_ARGS, null); + node.generators[0].iter.accept(this); + b.endCallUnaryMethod(); + + endSourceSection(b, newStatement); + return null; + } + + private void visitNoneable(ExprTy node) { + if (node == null) { + b.emitLoadConstant(PNone.NONE); + } else { + node.accept(this); + } + } + + @Override + public Void visit(ExprTy.Slice node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginMakeSlice(); + + visitNoneable(node.lower); + visitNoneable(node.upper); + visitNoneable(node.step); + + b.endMakeSlice(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Starred node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(ExprTy.Subscript node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBinarySubscript(); + node.value.accept(this); + node.slice.accept(this); + b.endBinarySubscript(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Tuple node) { + boolean newStatement = beginSourceSection(node, b); + + ConstantCollection constantCollection = Compiler.tryCollectConstantCollection(node.elements); + if (constantCollection != null) { + emitConstantTuple(constantCollection); + } else { + b.beginMakeTuple(); + emitUnstar(node.elements); + b.endMakeTuple(); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.UnaryOp node) { + // Basic constant folding for unary negation + if (node.op == UnaryOpTy.USub && node.operand instanceof ExprTy.Constant c) { + if (c.value.kind == ConstantValue.Kind.BIGINTEGER || c.value.kind == ConstantValue.Kind.DOUBLE || c.value.kind == ConstantValue.Kind.LONG || + c.value.kind == ConstantValue.Kind.COMPLEX) { + ConstantValue cv = c.value.negate(); + boolean newStatement = beginSourceSection(node, b); + visit(new ExprTy.Constant(cv, null, c.getSourceRange())); + endSourceSection(b, newStatement); + return null; + } + } + boolean newStatement = beginSourceSection(node, b); + switch (node.op) { + case UAdd: + b.beginPyNumberPositive(); + node.operand.accept(this); + b.endPyNumberPositive(); + break; + case Invert: + b.beginPyNumberInvert(); + node.operand.accept(this); + b.endPyNumberInvert(); + break; + case USub: + b.beginPyNumberNegative(); + node.operand.accept(this); + b.endPyNumberNegative(); + break; + case Not: + b.beginNot(); + node.operand.accept(this); + b.endNot(); + break; + default: + throw new UnsupportedOperationException("" + node.getClass()); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Yield node) { + if (!scope.isFunction()) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'yield' outside function"); + } + boolean newStatement = beginSourceSection(node, b); + emitYield((statementCompiler) -> { + if (node.value != null) { + node.value.accept(this); + } else { + statementCompiler.b.emitLoadConstant(PNone.NONE); + } + }, this); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.YieldFrom node) { + if (!scope.isFunction()) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'yield' outside function"); + } + if (scopeType == CompilationScope.AsyncFunction) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'yield from' inside async function"); + } + boolean newStatement = beginSourceSection(node, b); + emitYieldFrom(() -> { + b.beginGetYieldFromIter(); + node.value.accept(this); + b.endGetYieldFromIter(); + }); + endSourceSection(b, newStatement); + return null; + } + + public void emitYieldFrom(Runnable generatorOrCoroutineProducer) { + /** + * @formatter:off + * generator = + * returnValue = None + * sentValue = None + * + * # Step 1: prime the generator + * try: + * yieldValue = generator.send(sentValue) + * except StopIteration as e: + * returnValue = e.value + * goto end + * + * while True: + * # Step 2: yield yieldValue to the caller + * try: + * sentValue = yield yieldValue + * except Exception as e: + * # throw/close generator + * if generator returned a value: + * goto end + * else: + * continue (generator yielded a value) + * + * # Step 3: send sentValue into the generator + * try: + * yieldValue = generator.send(sentValue) + * except StopIteration as e: + * returnValue = e.value + * goto end + * + * end: + * # Step 4: return returnValue + * returnValue (result) + * @formatter:on + */ + b.beginBlock(); + + BytecodeLocal generator = b.createLocal(); + BytecodeLocal returnValue = b.createLocal(); + BytecodeLocal sentValue = b.createLocal(); + BytecodeLocal yieldValue = b.createLocal(); + BytecodeLabel end = b.createLabel(); + + b.beginStoreLocal(generator); + generatorOrCoroutineProducer.run(); + b.endStoreLocal(); + + b.beginStoreLocal(returnValue); + b.emitLoadConstant(PNone.NONE); + b.endStoreLocal(); + + b.beginStoreLocal(sentValue); + b.emitLoadConstant(PNone.NONE); + b.endStoreLocal(); + + // Step 1: prime the generator + emitSend(generator, sentValue, yieldValue, returnValue, end); + + b.beginWhile(); + b.emitLoadConstant(true); + + b.beginBlock(); + BytecodeLabel loopEnd = b.createLabel(); + // Step 2: yield yieldValue to the caller + b.beginTryCatch(); + + // try clause: yield + b.beginStoreLocal(sentValue); + emitYield((statementCompiler) -> statementCompiler.b.emitLoadLocal(yieldValue), this); + b.endStoreLocal(); + + // catch clause: handle throw/close exceptions. + b.beginIfThenElse(); + b.beginYieldFromThrow(yieldValue, returnValue); + b.emitLoadLocal(generator); + b.emitLoadException(); + b.endYieldFromThrow(); + + // StopIteration was raised; go to the end. + b.emitBranch(end); + + // The generator yielded a value; go to top of the loop. + b.emitBranch(loopEnd); + + b.endIfThenElse(); + + b.endTryCatch(); + + // Step 3: send sentValue into the generator + emitSend(generator, sentValue, yieldValue, returnValue, end); + + b.emitLabel(loopEnd); + b.endBlock(); + b.endWhile(); + + // Step 4: return returnValue + b.emitLabel(end); + b.emitLoadLocal(returnValue); + + b.endBlock(); + } + + private void emitSend(BytecodeLocal generator, BytecodeLocal sentValue, BytecodeLocal yieldValue, BytecodeLocal returnValue, BytecodeLabel end) { + b.beginIfThen(); + // When the generator raises StopIteration, send evaluates to true; branch to the end. + b.beginYieldFromSend(yieldValue, returnValue); + b.emitLoadLocal(generator); + b.emitLoadLocal(sentValue); + b.endYieldFromSend(); + + b.emitBranch(end); + + b.endIfThen(); + } + + private void emitAwait(Runnable producer) { + emitYieldFrom(() -> { + b.beginGetAwaitable(); + producer.run(); + b.endGetAwaitable(); + }); + } + + @Override + public Void visit(KeywordTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(StmtTy.AnnAssign node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + if (node.value != null) { + // Emit the assignment if there's an RHS. + emitAssignment(new ExprTy[]{node.target}, node.value); + } + if (node.target instanceof ExprTy.Name) { + String name = ((ExprTy.Name) node.target).id; + checkForbiddenName(name, NameOperation.BeginWrite); + /* If we have a simple name in a module or class, store annotation. */ + if (node.isSimple && + (scopeType == CompilationScope.Module || scopeType == CompilationScope.Class)) { + b.beginSetDictItem(); + emitNameOperation("__annotations__", NameOperation.Read, b); + + String mangled = mangle(name); + emitPythonConstant(toTruffleStringUncached(mangled), b); + + if (futureFeatures.contains(FutureFeature.ANNOTATIONS)) { + emitPythonConstant(Unparser.unparse(node.annotation), b); + } else { + node.annotation.accept(this); + } + + b.endSetDictItem(); + } + } else if (node.target instanceof ExprTy.Attribute) { + if (node.value == null) { + ExprTy.Attribute attr = (ExprTy.Attribute) node.target; + checkForbiddenName(attr.attr, NameOperation.BeginWrite); + if (attr.value != null) { + checkAnnExpr(attr.value); + } + } + } else if (node.target instanceof ExprTy.Subscript) { + if (node.value == null) { + ExprTy.Subscript subscript = (ExprTy.Subscript) node.target; + if (subscript.value != null) { + checkAnnExpr(subscript.value); + } + checkAnnSubscr(subscript.slice); + } + } else { + ctx.errorCallback.onError(ErrorType.Syntax, node.getSourceRange(), "invalid node type for annotated assignment"); + } + if (!node.isSimple) { + /* + * Annotations of complex targets does not produce anything under annotations + * future. Annotations are only evaluated in a module or class. + */ + if (!futureFeatures.contains(FutureFeature.ANNOTATIONS) && (scopeType == CompilationScope.Module || scopeType == CompilationScope.Class)) { + checkAnnExpr(node.annotation); + } + } + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + private void checkAnnExpr(ExprTy expr) { + expr.accept(this); + } + + private void checkAnnSubscr(ExprTy expr) { + if (expr instanceof ExprTy.Slice) { + ExprTy.Slice slice = (ExprTy.Slice) expr; + if (slice.lower != null) { + checkAnnExpr(slice.lower); + } + if (slice.upper != null) { + checkAnnExpr(slice.upper); + } + if (slice.step != null) { + checkAnnExpr(slice.step); + } + } else if (expr instanceof ExprTy.Tuple) { + ExprTy.Tuple tuple = (ExprTy.Tuple) expr; + for (int i = 0; i < tuple.elements.length; i++) { + checkAnnSubscr(tuple.elements[i]); + } + } else { + checkAnnExpr(expr); + } + } + + @Override + public Void visit(StmtTy.Assert node) { + if (ctx.optimizationLevel <= 0) { + boolean newStatement = beginSourceSection(node, b); + b.beginIfThen(); + + b.beginNot(); + node.test.accept(this); + b.endNot(); + + b.beginAssertFailed(); + if (node.msg == null) { + b.emitLoadConstant(PNone.NO_VALUE); + } else { + node.msg.accept(this); + } + b.endAssertFailed(); + + b.endIfThen(); + endSourceSection(b, newStatement); + } + return null; + } + + // --------------------- assign ------------------------ + + /** + * Generates code to store the value produced by {@link #generateValue} into the visited + * expression. + */ + public class StoreVisitor implements BaseBytecodeDSLVisitor { + private final Builder b = StatementCompiler.this.b; + private final Runnable generateValue; + + StoreVisitor(Runnable generateValue) { + this.generateValue = generateValue; + } + + @Override + public Void visit(ExprTy.Name node) { + boolean newStatement = beginSourceSection(node, b); + beginStoreLocal(node.id, b); + generateValue.run(); + endStoreLocal(node.id, b); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Attribute node) { + boolean newStatement = beginSourceSection(node, b); + checkForbiddenName(node.attr, NameOperation.BeginWrite); + b.beginSetAttribute(toTruffleStringUncached(mangle(node.attr))); + generateValue.run(); + node.value.accept(StatementCompiler.this); + b.endSetAttribute(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Subscript node) { + boolean newStatement = beginSourceSection(node, b); + b.beginSetItem(); + generateValue.run(); + node.value.accept(StatementCompiler.this); + node.slice.accept(StatementCompiler.this); + b.endSetItem(); + endSourceSection(b, newStatement); + return null; + } + + /** + * This method unpacks the rhs (a sequence/iterable) to the elements on the lhs + * (specified by {@code nodes}. + */ + private void visitIterableAssign(ExprTy[] nodes) { + b.beginBlock(); + + /** + * The rhs should be fully evaluated and unpacked into the expected number of + * elements before storing values into the lhs (e.g., if an lhs element is f().attr, + * but computing or unpacking rhs throws, f() is not computed). Thus, the unpacking + * step stores the unpacked values into intermediate variables, and then those + * variables are copied into the lhs elements afterward. + */ + BytecodeLocal[] targets = new BytecodeLocal[nodes.length]; + for (int i = 0; i < targets.length; i++) { + targets[i] = b.createLocal(); + } + + int indexOfStarred = -1; + for (int i = 0; i < nodes.length; i++) { + if (nodes[i] instanceof ExprTy.Starred) { + indexOfStarred = i; + break; + } + } + + if (indexOfStarred == -1) { + b.beginUnpackToLocals(targets); + } else { + b.beginUnpackStarredToLocals(indexOfStarred, targets); + } + + generateValue.run(); + + if (indexOfStarred == -1) { + b.endUnpackToLocals(); + } else { + b.endUnpackStarredToLocals(); + } + + for (int i = 0; i < nodes.length; i++) { + final int index = i; + + ExprTy target = nodes[i]; + if (nodes[i] instanceof ExprTy.Starred) { + target = ((ExprTy.Starred) target).value; + } + + target.accept(new StoreVisitor(() -> { + b.emitLoadLocal(targets[index]); + })); + } + + b.endBlock(); + } + + @Override + public Void visit(ExprTy.Tuple node) { + boolean newStatement = beginSourceSection(node, b); + visitIterableAssign(node.elements); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.List node) { + boolean newStatement = beginSourceSection(node, b); + visitIterableAssign(node.elements); + endSourceSection(b, newStatement); + return null; + } + } + + private class AugStoreVisitor implements BaseBytecodeDSLVisitor { + private final Builder b = StatementCompiler.this.b; + private final ExprTy value; + private final OperatorTy op; + + AugStoreVisitor(OperatorTy op, ExprTy value) { + this.op = op; + this.value = value; + } + + private void beginAugAssign() { + switch (op) { + case Add -> b.beginPyNumberInPlaceAdd(); + case Sub -> b.beginPyNumberInPlaceSubtract(); + case Mult -> b.beginPyNumberInPlaceMultiply(); + case FloorDiv -> b.beginPyNumberInPlaceFloorDivide(); + case BitAnd -> b.beginPyNumberInPlaceAnd(); + case BitOr -> b.beginPyNumberInPlaceOr(); + case BitXor -> b.beginPyNumberInPlaceXor(); + case RShift -> b.beginPyNumberInPlaceRshift(); + case LShift -> b.beginPyNumberInPlaceLshift(); + case Div -> b.beginPyNumberInPlaceTrueDivide(); + case Mod -> b.beginPyNumberInPlaceRemainder(); + case MatMult -> b.beginPyNumberInPlaceMatrixMultiply(); + case Pow -> b.beginInPlacePow(); + default -> throw new UnsupportedOperationException("aug ass: " + op); + } + } + + private void endAugAssign() { + switch (op) { + case Add -> b.endPyNumberInPlaceAdd(); + case Sub -> b.endPyNumberInPlaceSubtract(); + case Mult -> b.endPyNumberInPlaceMultiply(); + case FloorDiv -> b.endPyNumberInPlaceFloorDivide(); + case BitAnd -> b.endPyNumberInPlaceAnd(); + case BitOr -> b.endPyNumberInPlaceOr(); + case BitXor -> b.endPyNumberInPlaceXor(); + case RShift -> b.endPyNumberInPlaceRshift(); + case LShift -> b.endPyNumberInPlaceLshift(); + case Div -> b.endPyNumberInPlaceTrueDivide(); + case Mod -> b.endPyNumberInPlaceRemainder(); + case MatMult -> b.endPyNumberInPlaceMatrixMultiply(); + case Pow -> b.endInPlacePow(); + default -> throw new UnsupportedOperationException("aug ass: " + op); + } + } + + @Override + public Void visit(ExprTy.Name node) { + boolean newStatement = beginSourceSection(node, b); + + beginStoreLocal(node.id, b); + beginAugAssign(); + emitReadLocal(node.id, b); + value.accept(StatementCompiler.this); + endAugAssign(); + endStoreLocal(node.id, b); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Attribute node) { + boolean newStatement = beginSourceSection(node, b); + checkForbiddenName(node.attr, NameOperation.BeginWrite); + b.beginBlock(); + // { + BytecodeLocal target = b.createLocal(); + + b.beginStoreLocal(target); + node.value.accept(StatementCompiler.this); + b.endStoreLocal(); + + TruffleString attrName = toTruffleStringUncached(mangle(node.attr)); + b.beginSetAttribute(attrName); + beginAugAssign(); + + b.beginGetAttribute(attrName); + b.emitLoadLocal(target); + b.endGetAttribute(); + + value.accept(StatementCompiler.this); + + endAugAssign(); + + b.emitLoadLocal(target); + b.endSetAttribute(); + // } + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Subscript node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + // { + BytecodeLocal target = b.createLocal(); + BytecodeLocal slice = b.createLocal(); + + b.beginStoreLocal(target); + node.value.accept(StatementCompiler.this); + b.endStoreLocal(); + + b.beginStoreLocal(slice); + node.slice.accept(StatementCompiler.this); + b.endStoreLocal(); + + b.beginSetItem(); + beginAugAssign(); + + b.beginBinarySubscript(); + b.emitLoadLocal(target); + b.emitLoadLocal(slice); + b.endBinarySubscript(); + + value.accept(StatementCompiler.this); + + endAugAssign(); + + b.emitLoadLocal(target); + b.emitLoadLocal(slice); + b.endSetItem(); + // } + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + } + + @Override + public Void visit(StmtTy.Assign node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + emitAssignment(node.targets, node.value); + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + private void emitAssignment(ExprTy[] targets, ExprTy value) { + if (targets.length == 1) { + targets[0].accept(new StoreVisitor(() -> { + value.accept(this); + })); + } else { + BytecodeLocal tmp = b.createLocal(); + b.beginStoreLocal(tmp); + value.accept(this); + b.endStoreLocal(); + + for (ExprTy target : targets) { + target.accept(new StoreVisitor(() -> { + b.emitLoadLocal(tmp); + })); + } + } + } + + @Override + public Void visit(StmtTy.AsyncFor node) { + emitNotImplemented("async for", b); + return null; + } + + @Override + public Void visit(StmtTy.AsyncWith node) { + if (!scope.isFunction()) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'async with' outside function"); + } + if (scopeType != CompilationScope.AsyncFunction && scopeType != CompilationScope.Comprehension) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'async with' outside async function"); + } + boolean newStatement = beginSourceSection(node, b); + visitWithRecurse(node.items, 0, node.body, true); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.AugAssign node) { + boolean newStatement = beginSourceSection(node, b); + node.target.accept(new AugStoreVisitor(node.op, node.value)); + endSourceSection(b, newStatement); + return null; + } + + private abstract static sealed class KeywordGroup permits NamedKeywords, SplatKeywords { + } + + private static final class NamedKeywords extends KeywordGroup { + final ArrayList names; + final ArrayList values; + + NamedKeywords(ArrayList names, ArrayList values) { + this.names = names; + this.values = values; + } + } + + private static final class SplatKeywords extends KeywordGroup { + final ExprTy expr; + + SplatKeywords(ExprTy expr) { + this.expr = expr; + } + } + + private void emitKeywords(KeywordTy[] kws, BytecodeLocal function) { + if (len(kws) == 0) { + b.emitLoadConstant(PKeyword.EMPTY_KEYWORDS); + } else { + KeywordGroup[] groups = partitionKeywords(kws); + // The nodes that validate keyword arguments operate on PDicts, so we convert into + // a list of PKeywords after validation. + b.beginMappingToKeywords(); + emitKeywordsRecursive(groups, groups.length - 1, function); + b.endMappingToKeywords(); + } + } + + private KeywordGroup[] partitionKeywords(KeywordTy[] kws) { + ArrayList groups = new ArrayList<>(); + + int i = 0; + while (i < kws.length) { + if (kws[i].arg == null) { + // splat + groups.add(new SplatKeywords(kws[i].value)); + i++; + } else { + // named keyword + ArrayList kwNames = new ArrayList<>(); + ArrayList kwValues = new ArrayList<>(); + while (i < kws.length && kws[i].arg != null) { + kwNames.add(toTruffleStringUncached(kws[i].arg)); + kwValues.add(kws[i].value); + i++; + } + groups.add(new NamedKeywords(kwNames, kwValues)); + } + } + + return groups.toArray(KeywordGroup[]::new); + } + + private void emitKeywordsRecursive(KeywordGroup[] groups, int i, BytecodeLocal function) { + /* + * Keyword groups should be merged left-to-right. For example, for groups [A, B, C] we + * should emit KwArgsMerge(KwArgsMerge(A, B), C). + */ + if (i == 0) { + emitKeywordGroup(groups[i], true, function); + } else { + b.beginKwargsMerge(function); + emitKeywordsRecursive(groups, i - 1, function); + emitKeywordGroup(groups[i], false, function); + b.endKwargsMerge(); + } + } + + private void emitKeywordGroup(KeywordGroup group, boolean copy, BytecodeLocal function) { + if (group instanceof NamedKeywords namedKeywords) { + b.beginMakeDict(namedKeywords.names.size()); + for (int i = 0; i < namedKeywords.names.size(); i++) { + emitPythonConstant(namedKeywords.names.get(i), b); + namedKeywords.values.get(i).accept(this); + } + b.endMakeDict(); + } else { + SplatKeywords splatKeywords = (SplatKeywords) group; + + if (copy) { + b.beginKwargsMerge(function); + b.beginMakeDict(0); + b.endMakeDict(); + splatKeywords.expr.accept(this); + b.endKwargsMerge(); + } else { + splatKeywords.expr.accept(this); + } + } + } + + @Override + public Void visit(StmtTy.ClassDef node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + BytecodeLocal buildClassFunction = b.createLocal(); + + // compute __build_class__ (we need it in multiple places, so store it) + b.beginStoreLocal(buildClassFunction); + b.emitBuildClass(); + b.endStoreLocal(); + + // ClassName = __build_class__(, "ClassName", bases, keywords) + beginStoreLocal(node.name, b); + + int numDeco = len(node.decoratorList); + for (int i = 0; i < numDeco; i++) { + b.beginCallUnaryMethod(); + node.decoratorList[i].accept(this); + } + + b.beginCallVarargsMethod(); + + b.emitLoadLocal(buildClassFunction); + + // positional args + emitUnstar(() -> { + emitMakeFunction(node, node.name, null, null); + emitPythonConstant(toTruffleStringUncached(node.name), b); + }, node.bases); + + // keyword args + validateKeywords(node.keywords); + emitKeywords(node.keywords, buildClassFunction); + + b.endCallVarargsMethod(); + + for (int i = 0; i < numDeco; i++) { + b.endCallUnaryMethod(); + } + + endStoreLocal(node.name, b); + + b.endBlock(); + endSourceSection(b, newStatement); + + return null; + } + + private class DeleteVisitor implements BaseBytecodeDSLVisitor { + + @Override + public Void visit(ExprTy.Subscript node) { + boolean newStatement = beginSourceSection(node, b); + + b.beginDeleteItem(); + node.value.accept(StatementCompiler.this); + node.slice.accept(StatementCompiler.this); + b.endDeleteItem(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Attribute node) { + boolean newStatement = beginSourceSection(node, b); + checkForbiddenName(node.attr, NameOperation.BeginWrite); + b.beginDeleteAttribute(toTruffleStringUncached(node.attr)); + node.value.accept(StatementCompiler.this); + b.endDeleteAttribute(); + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Name node) { + boolean newStatement = beginSourceSection(node, b); + emitNameOperation(node.id, NameOperation.Delete, b); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.Tuple node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + visitSequence(node.elements); + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(ExprTy.List node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + visitSequence(node.elements); + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + } + + @Override + public Void visit(StmtTy.Delete node) { + new DeleteVisitor().visitSequence(node.targets); + return null; + } + + @Override + public Void visit(StmtTy.Expr node) { + boolean newStatement = beginSourceSection(node, b); + if (isInteractive) { + b.beginPrintExpr(); + node.value.accept(this); + b.endPrintExpr(); + } else { + node.value.accept(this); + } + endSourceSection(b, newStatement); + + return null; + } + + @Override + public Void visit(StmtTy.For node) { + // @formatter:off + // iter = GetIter(<>); value; + // while (ForIterate(iter, &value)) { + // store value + // <> + // continueLabel: + // } + // < + // breakLabel: + // @formatter:on + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + + BytecodeLocal iter = b.createLocal(); + + b.beginStoreLocal(iter); + b.beginGetIter(); + node.iter.accept(this); + b.endGetIter(); + b.endStoreLocal(); + + BytecodeLabel oldBreakLabel = breakLabel; + BytecodeLabel oldContinueLabel = continueLabel; + + BytecodeLabel currentBreakLabel = b.createLabel(); + breakLabel = currentBreakLabel; + + b.beginWhile(); + BytecodeLocal value = b.createLocal(); + + // condition + b.beginBlock(); + b.emitTraceLineAtLoopHeader(currentLocation.startLine); + b.beginForIterate(value); + b.emitLoadLocal(iter); + b.endForIterate(); + b.endBlock(); + + // body + b.beginBlock(); + continueLabel = b.createLabel(); + node.target.accept(new StoreVisitor(() -> { + b.emitLoadLocal(value); + })); + + visitSequence(node.body); + b.emitLabel(continueLabel); + b.endBlock(); + + b.endWhile(); + + breakLabel = oldBreakLabel; + continueLabel = oldContinueLabel; + visitSequence(node.orElse); + b.emitLabel(currentBreakLabel); + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.FunctionDef node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + + beginStoreLocal(node.name, b); + + int numDeco = len(node.decoratorList); + for (int i = 0; i < numDeco; i++) { + b.beginCallUnaryMethod(); + node.decoratorList[i].accept(this); + } + + List annotations = collectParamAnnotations(node.args, node.returns); + emitMakeFunction(node, node.name, node.args, annotations); + + for (int i = 0; i < numDeco; i++) { + b.endCallUnaryMethod(); + } + + endStoreLocal(node.name, b); + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.AsyncFunctionDef node) { + boolean newStatement = beginSourceSection(node, b); + beginStoreLocal(node.name, b); + + int numDeco = len(node.decoratorList); + for (int i = 0; i < numDeco; i++) { + b.beginCallUnaryMethod(); + node.decoratorList[i].accept(this); + } + + List annotations = collectParamAnnotations(node.args, node.returns); + emitMakeFunction(node, node.name, node.args, annotations); + + for (int i = 0; i < numDeco; i++) { + b.endCallUnaryMethod(); + } + + endStoreLocal(node.name, b); + endSourceSection(b, newStatement); + return null; + } + + private void emitParamAnnotation(ParamAnnotation paramAnnotation) { + emitPythonConstant(paramAnnotation.name, b); + + if (futureFeatures.contains(FutureFeature.ANNOTATIONS)) { + emitPythonConstant(Unparser.unparse(paramAnnotation.annotation), b); + } else { + if (paramAnnotation.annotation instanceof ExprTy.Starred starred) { + // *args: *Ts (where Ts is a TypeVarTuple). + // Do [annotation_value] = [*Ts]. + b.beginBlock(); + BytecodeLocal local = b.createLocal(); + b.beginUnpackToLocals(new BytecodeLocal[]{local}); + starred.value.accept(this); + b.endUnpackToLocals(); + b.emitLoadLocal(local); + b.endBlock(); + } else { + paramAnnotation.annotation.accept(this); + } + } + } + + private void emitMakeFunction(SSTNode node, String name, ArgumentsTy args, List annotations) { + BytecodeDSLCompilerResult compilerResult = compileNode(node); + BytecodeDSLCodeUnit codeUnit = compilerResult.codeUnit(); + + TruffleString functionName = toTruffleStringUncached(name); + Scope targetScope = ctx.scopeEnvironment.lookupScope(node); + TruffleString qualifiedName = toTruffleStringUncached(ctx.getQualifiedName(targetScope)); + + // Register these in the Python constants list. + addConstant(qualifiedName); + addConstant(codeUnit); + + b.beginMakeFunction(functionName, qualifiedName, codeUnit); + + if (args == null || len(args.defaults) == 0) { + b.emitLoadConstant(PythonUtils.EMPTY_OBJECT_ARRAY); + } else { + b.beginCollectToObjectArray(); + for (int i = 0; i < args.defaults.length; i++) { + args.defaults[i].accept(this); + } + b.endCollectToObjectArray(); + } + + boolean hasKeywords = false; + if (args != null && len(args.kwDefaults) != 0) { + // We only emit keywords with default values. Check if any exist. + for (int i = 0; i < args.kwDefaults.length; i++) { + if (args.kwDefaults[i] != null) { + hasKeywords = true; + break; + } + } + } + + if (!hasKeywords) { + b.emitLoadConstant(PKeyword.EMPTY_KEYWORDS); + } else { + ArgTy[] kwOnlyArgs = args.kwOnlyArgs; + + List keys = new ArrayList<>(); + b.beginMakeKeywords(); + for (int i = 0; i < args.kwDefaults.length; i++) { + // Only emit keywords with default values. + if (args.kwDefaults[i] != null) { + keys.add(toTruffleStringUncached(mangle(kwOnlyArgs[i].arg))); + args.kwDefaults[i].accept(this); + } + } + b.endMakeKeywords(keys.toArray(new TruffleString[0])); + } + + if (codeUnit.freevars.length == 0) { + b.emitLoadNull(); + } else { + b.beginMakeCellArray(); + for (int i = 0; i < codeUnit.freevars.length; i++) { + String fv = codeUnit.freevars[i].toJavaStringUncached(); + BytecodeLocal local; + if (scopeType == CompilationScope.Class && "__class__".equals(fv) || scope.getUseOfName(fv).contains(Scope.DefUse.Cell)) { + local = cellLocals.get(fv); + } else { + local = freeLocals.get(fv); + } + b.emitLoadLocal(local); + } + b.endMakeCellArray(); + } + + // __annotations__ + if (annotations != null && annotations.size() > 0) { + b.beginMakeDict(annotations.size()); + for (ParamAnnotation annotation : annotations) { + emitParamAnnotation(annotation); + } + b.endMakeDict(); + } else { + b.emitLoadNull(); + } + + b.endMakeFunction(); + } + + private BytecodeDSLCompilerResult compileNode(SSTNode node) { + return (new RootNodeCompiler(ctx, node, futureFeatures)).compile(); + } + + @Override + public Void visit(StmtTy.Global node) { + return null; + } + + private void visitStatements(StmtTy[] stmts) { + b.beginBlock(); + if (stmts != null) { + for (StmtTy stmt : stmts) { + stmt.accept(this); + } + } + b.endBlock(); + } + + @Override + public Void visit(StmtTy.If node) { + boolean newStatement = beginSourceSection(node, b); + if (node.orElse == null || node.orElse.length == 0) { + b.beginIfThen(); + visitCondition(node.test); + visitStatements(node.body); + b.endIfThen(); + } else { + b.beginIfThenElse(); + visitCondition(node.test); + visitStatements(node.body); + visitStatements(node.orElse); + b.endIfThenElse(); + } + + endSourceSection(b, newStatement); + return null; + } + + private boolean producesBoolean(ExprTy node) { + // NB: Binary and/or operations evaluate to their operands, which are not necessarily + // booleans. + return node instanceof ExprTy.UnaryOp unOp && unOp.op == UnaryOpTy.Not || + node instanceof ExprTy.Constant c && c.value.kind == Kind.BOOLEAN; + } + + private void visitCondition(ExprTy node) { + boolean mayNeedCoercion = !producesBoolean(node); + if (mayNeedCoercion) { + b.beginYes(); + } + + node.accept(this); + + if (mayNeedCoercion) { + b.endYes(); + } + } + + @Override + public Void visit(StmtTy.Import node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + + for (AliasTy name : node.names) { + addConstant(PythonUtils.EMPTY_TRUFFLESTRING_ARRAY); + if (name.asName == null) { + // import a.b.c + // --> a = (Import "a.b.c" [] 0) + // import a + // --> a = (Import "a" [] 0) + String resName = name.name.contains(".") + ? name.name.substring(0, name.name.indexOf('.')) + : name.name; + + beginStoreLocal(resName, b); + b.emitImport(toTruffleStringUncached(name.name), PythonUtils.EMPTY_TRUFFLESTRING_ARRAY, 0); + endStoreLocal(resName, b); + } else { + // import a.b.c as x + // --> x = (ImportFrom (ImportFrom (Import "a.b.c" [] 0) "b") "c") + // import a as x + // --> x = (Import "a" [] 0) + String[] parts = name.name.split("\\."); + + beginStoreLocal(name.asName, b); + + for (int i = parts.length - 1; i >= 0; i--) { + if (i != 0) { + b.beginImportFrom(toTruffleStringUncached(parts[i])); + } else { + b.emitImport(toTruffleStringUncached(name.name), PythonUtils.EMPTY_TRUFFLESTRING_ARRAY, 0); + } + } + + for (int i = 1; i < parts.length; i++) { + b.endImportFrom(); + } + + endStoreLocal(name.asName, b); + } + } + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.ImportFrom node) { + boolean newStatement = beginSourceSection(node, b); + if (node.getSourceRange().startLine > ctx.futureLineNumber && "__future__".equals(node.module)) { + ctx.errorCallback.onError(ErrorType.Syntax, node.getSourceRange(), "from __future__ imports must occur at the beginning of the file"); + } + + TruffleString tsModuleName = toTruffleStringUncached(node.module == null ? "" : node.module); + + if (node.names[0].name.equals("*")) { + b.emitImportStar(tsModuleName, node.level); + } else { + b.beginBlock(); + + BytecodeLocal module = b.createLocal(); + + TruffleString[] fromList = new TruffleString[node.names.length]; + for (int i = 0; i < fromList.length; i++) { + fromList[i] = toTruffleStringUncached(node.names[i].name); + } + + b.beginStoreLocal(module); + b.emitImport(tsModuleName, fromList, node.level); + b.endStoreLocal(); + + TruffleString[] importedNames = new TruffleString[node.names.length]; + for (int i = 0; i < node.names.length; i++) { + AliasTy alias = node.names[i]; + String asName = alias.asName == null ? alias.name : alias.asName; + beginStoreLocal(asName, b); + + TruffleString name = toTruffleStringUncached(alias.name); + importedNames[i] = name; + b.beginImportFrom(name); + b.emitLoadLocal(module); + b.endImportFrom(); + + endStoreLocal(asName, b); + } + addConstant(importedNames); + + b.endBlock(); + } + + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.Match node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + // Compute and store the subject in a local. + BytecodeLocal subject = b.createLocal(); + b.beginStoreLocal(subject); + node.subject.accept(this); + b.endStoreLocal(); + + visitMatchCaseRecursively(node.cases, 0, new PatternContext(subject)); + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + private final class PatternContext { + private final Map bindVariables = new HashMap<>(); + private final BytecodeLocal subject; + private boolean allowIrrefutable = false; + + PatternContext(BytecodeLocal subject) { + this.subject = subject; + } + + public void copySubjectToTemporary(String name) { + BytecodeLocal temporary = allocateBindVariable(name); + b.beginStoreLocal(temporary); + b.emitLoadLocal(subject); + b.endStoreLocal(); + } + + private BytecodeLocal allocateBindVariable(String name) { + checkForbiddenName(name, NameOperation.BeginWrite); + if (bindVariables.containsKey(name)) { + duplicateStoreError(name); + } + BytecodeLocal result = b.createLocal(); + bindVariables.put(name, result); + return result; + } + + private void duplicateStoreError(String name) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "multiple assignments to name '%s' in pattern", name); + } + + } + + private void visitMatchCaseRecursively(MatchCaseTy[] cases, int index, PatternContext pc) { + /** + * Cases are chained as a sequence of if-then-else clauses, as in: + * + * @formatter:off + * IfThenElse( + * , + * , + * IfThenElse( + * , + * , + * ... + * ) + * ) + * @formatter:on + */ + MatchCaseTy c = cases[index]; + boolean newStatement = beginSourceSection(c, b); + + if (index != cases.length - 1) { + b.beginIfThenElse(); + + // A case that isn't last can be irrefutable only if it is guarded. + pc.allowIrrefutable = c.guard != null; + + emitPatternCondition(c, pc); + visitStatements(c.body); + visitMatchCaseRecursively(cases, index + 1, pc); + b.endIfThenElse(); + } else { + /** + * For the last pattern: if it's an unguarded wildcard _, just emit the body. + * Otherwise, emit an IfThen (no else). + */ + if (wildcardCheck(c.pattern) && c.guard == null) { + visitStatements(c.body); + } else { + b.beginIfThen(); + + // The last case can be irrefutable. + pc.allowIrrefutable = true; + + emitPatternCondition(c, pc); + visitStatements(c.body); + b.endIfThen(); + } + } + + endSourceSection(b, newStatement); + } + + private void emitPatternCondition(MatchCaseTy currentCase, PatternContext pc) { + PatternTy pattern = currentCase.pattern; + ExprTy guard = currentCase.guard; + + /** + * We evaluate conditions using a sequence of boolean computations chained with + * short-circuiting ANDs. If a condition fails at any point, we abort and continue with + * the next pattern. + * + * Patterns can bind variables, but a variable is only bound if the full pattern + * matches. We accumulate the bound values into temporary variables and copy them all + * over only if the pattern matches. For example: + * + * @formatter:off + * IfThenElse( + * And( + * , + * Block( + * + * ... + * , + * true // continue unconditionally + * ), + * + * ), + * , + * ... + * ) + * @formatter:on + */ + b.beginPrimitiveBoolAnd(); + + visitPattern(pattern, pc); + + if (!pc.bindVariables.isEmpty()) { + b.beginBlock(); + + for (Map.Entry entry : pc.bindVariables.entrySet()) { + beginStoreLocal(entry.getKey(), b); + b.emitLoadLocal(entry.getValue()); + endStoreLocal(entry.getKey(), b); + } + + b.emitLoadConstant(true); + b.endBlock(); + } + if (guard != null) { + guard.accept(this); + } + b.endPrimitiveBoolAnd(); + } + + /** + * Generates code to test a {@code pattern} against the value stored in {@code subject}. + * + * Invariants: + *

      + *
    • The code for each pattern produces a boolean value. + *
    • When the pattern has a variable binding, the code will use the {@code pc} to allocate + * a new temporary variable to store the value of the binding. If the pattern match + * succeeds, only then will we copy the temporaries into Python-level variables. + *
    • The {@code pc.subject} variable always contains the value to match against a pattern. + * When performing structural recursion on a value, the original value will be overwritten + * unless saved in a new local. + *
    + */ + private void visitPattern(PatternTy pattern, PatternContext pc) { + boolean newStatement = beginSourceSection(pattern, b); + if (pattern instanceof PatternTy.MatchAs matchAs) { + doVisitPattern(matchAs, pc); + } else if (pattern instanceof PatternTy.MatchClass matchClass) { + doVisitPattern(matchClass); + } else if (pattern instanceof PatternTy.MatchMapping matchMapping) { + doVisitPattern(matchMapping); + } else if (pattern instanceof PatternTy.MatchOr matchOr) { + doVisitPattern(matchOr, pc); + } else if (pattern instanceof PatternTy.MatchSequence matchSequence) { + doVisitPattern(matchSequence, pc); + } else if (pattern instanceof PatternTy.MatchSingleton matchSingleton) { + doVisitPattern(matchSingleton, pc); + } else if (pattern instanceof PatternTy.MatchStar matchStar) { + doVisitPattern(matchStar, pc); + } else if (pattern instanceof PatternTy.MatchValue matchValue) { + doVisitPattern(matchValue, pc); + } else { + throw CompilerDirectives.shouldNotReachHere(); + } + endSourceSection(b, newStatement); + } + + // In a subpattern, irrefutable patterns are OK. + private void visitSubpattern(PatternTy pattern, PatternContext pc) { + boolean allowIrrefutable = pc.allowIrrefutable; + pc.allowIrrefutable = true; + visitPattern(pattern, pc); + pc.allowIrrefutable = allowIrrefutable; + } + + private void doVisitPattern(PatternTy.MatchAs node, PatternContext pc) { + b.beginBlock(); + if (node.name != null) { + pc.copySubjectToTemporary(node.name); + } + + if (node.pattern == null) { + // If there's no pattern (e.g., _), it trivially matches. Ensure this is permitted. + if (!pc.allowIrrefutable) { + if (node.name != null) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "name capture '%s' makes remaining patterns unreachable", node.name); + } + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "wildcard makes remaining patterns unreachable"); + } + b.emitLoadConstant(true); + } else { + assert node.name != null : "name should only be null for the empty wildcard pattern '_'"; + visitPattern(node.pattern, pc); + } + + b.endBlock(); + } + + private void emitPatternNotImplemented(String kind) { + b.beginBlock(); + emitNotImplemented(kind + " pattern matching", b); + // we need a value producing operation + b.emitLoadConstant(false); + b.endBlock(); + } + + private void doVisitPattern(PatternTy.MatchClass node) { + emitPatternNotImplemented("class"); + } + + private void doVisitPattern(PatternTy.MatchMapping node) { + emitPatternNotImplemented("mapping"); + } + + private void doVisitPattern(PatternTy.MatchOr node, PatternContext pc) { + if (node.patterns.length > 2) { + emitPatternNotImplemented("OR with more than 2 elements"); + } + b.beginBoolOr(); + visitPattern(node.patterns[0], pc); + visitPattern(node.patterns[1], pc); + b.endBoolOr(); + } + + private void patternHelperSequenceUnpack(PatternTy[] patterns, PatternContext pc) { + int n = len(patterns); + + b.beginBlock(); + // We need to remember the unpacked array, since subject will be overwritten in + // recursive calls. + BytecodeLocal unpacked = b.createLocal(); + b.beginStoreLocal(unpacked); + patternUnpackHelper(patterns, pc); + b.endStoreLocal(); + + for (int i = 0; i < n; i++) { + b.beginStoreLocal(pc.subject); + b.beginArrayIndex(i); + b.emitLoadLocal(unpacked); + b.endArrayIndex(); + b.endStoreLocal(); + + visitSubpattern(patterns[i], pc); + } + b.endBlock(); + } + + private void patternUnpackHelper(PatternTy[] patterns, PatternContext pc) { + int n = len(patterns); + + boolean seenStar = false; + for (int i = 0; i < n; i++) { + PatternTy pattern = patterns[i]; + if (pattern instanceof PatternTy.MatchStar) { + if (seenStar) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "multiple starred expressions in sequence pattern"); + } + seenStar = true; + int countAfter = n - i - 1; + if (countAfter != (byte) countAfter) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "too many expressions in star-unpacking sequence pattern"); + } + // If there's a star pattern, emit UnpackEx. + b.beginUnpackEx(i, countAfter); + b.emitLoadLocal(pc.subject); + b.endUnpackEx(); + // Continue in the loop to ensure there are no additional starred patterns. + } + } + // If there were no star patterns, emit UnpackSequence. + if (!seenStar) { + b.beginUnpackSequence(n); + b.emitLoadLocal(pc.subject); + b.endUnpackSequence(); + } + } + + /** + * Like patternHelperSequenceUnpack, but uses subscripting, which is (likely) more efficient + * for patterns with a starred wildcard like [first, *_], [first, *_, last], [*_, last], + * etc. + */ + private void patternHelperSequenceSubscr(PatternTy[] patterns, int star, PatternContext pc) { + int n = len(patterns); + + b.beginBlock(); + // We need to remember the sequence, since subject will be overwritten in recursive + // calls. + BytecodeLocal sequence = b.createLocal(); + b.beginStoreLocal(sequence); + b.emitLoadLocal(pc.subject); + b.endStoreLocal(); + + for (int i = 0; i < n; i++) { + PatternTy pattern = patterns[i]; + if (wildcardCheck(pattern)) { + // nothing to check + continue; + } else if (i == star) { + // nothing to check + assert wildcardStarCheck(pattern); + continue; + } + + b.beginStoreLocal(pc.subject); + b.beginBinarySubscript(); + b.emitLoadLocal(sequence); + if (i < star) { + b.emitLoadConstant(i); + } else { + // The subject may not support negative indexing! Compute a + // nonnegative index: + b.beginPyNumberSubtract(); + + b.beginGetLen(); + b.emitLoadLocal(sequence); + b.endGetLen(); + + b.emitLoadConstant(n - i); + + b.endPyNumberSubtract(); + } + b.endBinarySubscript(); + b.endStoreLocal(); + + visitSubpattern(pattern, pc); + } + b.endBlock(); + } + + private void doVisitPattern(PatternTy.MatchSequence node, PatternContext pc) { + int size = len(node.patterns); + int star = -1; + boolean onlyWildcard = true; + boolean starWildcard = false; + + // Find a starred name, if it exists. There may be at most one: + for (int i = 0; i < size; i++) { + PatternTy pattern = node.patterns[i]; + if (pattern instanceof PatternTy.MatchStar) { + if (star >= 0) { + ctx.errorCallback.onError(ErrorType.Syntax, node.getSourceRange(), "multiple starred names in sequence pattern"); + } + starWildcard = wildcardStarCheck(pattern); + onlyWildcard &= starWildcard; + star = i; + continue; + } + onlyWildcard &= wildcardCheck(pattern); + } + + b.beginPrimitiveBoolAnd(); + + b.beginCheckTypeFlags(TypeFlags.SEQUENCE); + b.emitLoadLocal(pc.subject); + b.endCheckTypeFlags(); + + if (star < 0) { + // No star: len(subject) == size + b.beginEq(); + b.beginGetLen(); + b.emitLoadLocal(pc.subject); + b.endGetLen(); + b.emitLoadConstant(size); + b.endEq(); + } else if (size > 1) { + // Star: len(subject) >= size - 1 + b.beginGe(); + b.beginGetLen(); + b.emitLoadLocal(pc.subject); + b.endGetLen(); + b.emitLoadConstant(size - 1); + b.endGe(); + } + + if (onlyWildcard) { + /** + * For patterns like: [] / [_] / [_, _] / [*_] / [_, *_] / [_, _, *_] / etc., there + * is nothing more to check. + */ + } else if (starWildcard) { + /** + * For sequences with a *_ pattern, it is (likely) more efficient to extract the + * bound elements with subscripting rather than iterating the entire collection. + */ + patternHelperSequenceSubscr(node.patterns, star, pc); + } else { + /** + * Otherwise, unpack the sequence element-by-element. If there's a named * pattern, + * collect the rest into it. + */ + patternHelperSequenceUnpack(node.patterns, pc); + } + + b.endPrimitiveBoolAnd(); + } + + private void doVisitPattern(PatternTy.MatchSingleton node, PatternContext pc) { + b.beginIs(); + b.emitLoadLocal(pc.subject); + + switch (node.value.kind) { + case BOOLEAN: + b.emitLoadConstant(node.value.getBoolean()); + break; + case NONE: + b.emitLoadConstant(PNone.NONE); + break; + default: + throw new IllegalStateException("wrong MatchSingleton value kind " + node.value.kind); + } + b.endIs(); + } + + private void doVisitPattern(PatternTy.MatchStar node, PatternContext pc) { + if (node.name != null) { + b.beginBlock(); + pc.copySubjectToTemporary(node.name); + b.emitLoadConstant(true); + b.endBlock(); + } + /** + * If there's no name, no need to emit anything. A MatchStar can only appear as a + * subpattern of a mapping/sequence pattern, at which point in code generation we will + * be in the middle of a short-circuiting AND (that already has at least one operand) + */ + } + + private void doVisitPattern(PatternTy.MatchValue node, PatternContext pc) { + b.beginEq(); + b.emitLoadLocal(pc.subject); + + if (node.value instanceof ExprTy.UnaryOp || node.value instanceof ExprTy.BinOp) { + createConstant(foldConstantOp(node.value)); + } else if (node.value instanceof ExprTy.Constant || node.value instanceof ExprTy.Attribute) { + node.value.accept(this); + } else { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "patterns may only match literals and attribute lookups"); + } + b.endEq(); + } + + private static boolean wildcardCheck(PatternTy pattern) { + return pattern instanceof PatternTy.MatchAs && ((PatternTy.MatchAs) pattern).name == null; + } + + private static boolean wildcardStarCheck(PatternTy pattern) { + return pattern instanceof PatternTy.MatchStar && ((PatternTy.MatchStar) pattern).name == null; + } + + /** + * handles only particular cases when a constant comes either as a unary or binary op + */ + private ConstantValue foldConstantOp(ExprTy value) { + if (value instanceof ExprTy.UnaryOp unaryOp) { + return foldUnaryOpConstant(unaryOp); + } else if (value instanceof ExprTy.BinOp binOp) { + return foldBinOpComplexConstant(binOp); + } + throw new IllegalStateException("should not reach here"); + } + + /** + * handles only unary sub and a numeric constant + */ + private ConstantValue foldUnaryOpConstant(ExprTy.UnaryOp unaryOp) { + assert unaryOp.op == UnaryOpTy.USub; + assert unaryOp.operand instanceof ExprTy.Constant : unaryOp.operand; + ExprTy.Constant c = (ExprTy.Constant) unaryOp.operand; + ConstantValue ret = c.value.negate(); + assert ret != null; + return ret; + } + + /** + * handles only complex which comes as a BinOp + */ + private ConstantValue foldBinOpComplexConstant(ExprTy.BinOp binOp) { + assert (binOp.left instanceof ExprTy.UnaryOp || binOp.left instanceof ExprTy.Constant) && binOp.right instanceof ExprTy.Constant : binOp.left + " " + binOp.right; + assert binOp.op == OperatorTy.Sub || binOp.op == OperatorTy.Add; + ConstantValue left; + if (binOp.left instanceof ExprTy.UnaryOp) { + left = foldUnaryOpConstant((ExprTy.UnaryOp) binOp.left); + } else { + left = ((ExprTy.Constant) binOp.left).value; + } + ExprTy.Constant right = (ExprTy.Constant) binOp.right; + switch (binOp.op) { + case Add: + return left.addComplex(right.value); + case Sub: + return left.subComplex(right.value); + default: + throw new IllegalStateException("wrong constant BinOp operator " + binOp.op); + } + } + + @Override + public Void visit(MatchCaseTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchAs node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchClass node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchMapping node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchOr node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchSequence node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchSingleton node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchStar node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(PatternTy.MatchValue node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(StmtTy.Nonlocal node) { + return null; + } + + @Override + public Void visit(StmtTy.Raise node) { + boolean newStatement = beginSourceSection(node, b); + b.beginRaise(); + + if (node.exc != null) { + node.exc.accept(this); + } else { + b.emitLoadConstant(PNone.NO_VALUE); + } + + if (node.cause != null) { + node.cause.accept(this); + } else { + b.emitLoadConstant(PNone.NO_VALUE); + } + + b.endRaise(); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.Return node) { + boolean newStatement = beginSourceSection(node, b); + if (!scope.isFunction()) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'return' outside function"); + } + beginReturn(b); + if (node.value != null) { + node.value.accept(this); + } else { + b.emitLoadConstant(PNone.NONE); + } + endReturn(b); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.Try node) { + boolean newStatement = beginSourceSection(node, b); + if (node.finalBody != null && node.finalBody.length != 0) { + /** + * In Python, an uncaught exception becomes the "current" exception inside a finally + * block. The finally body can itself throw, in which case it replaces the exception + * being thrown. For such a scenario, we have to be careful to restore the "current" + * exception using a try-finally. + * + * In pseudocode, the implementation looks like: + * @formatter:off + * try { + * try_catch_else + * } catch uncaught_ex { + * save current exception + * set the current exception to uncaught_ex + * markCaught(uncaught_ex) + * try { + * finally_body + * } catch handler_ex { + * restore current exception + * markCaught(handler_ex) + * reraise handler_ex + * } otherwise { + * restore current exception + * } + * reraise uncaught_ex + * } otherwise { + * finally_body + * } + */ + b.beginTryCatchOtherwise(() -> { + b.beginBlock(); // finally + visitSequence(node.finalBody); + b.endBlock(); + }); + + emitTryExceptElse(node); // try + + b.beginBlock(); // catch + BytecodeLocal savedException = b.createLocal(); + emitSaveCurrentException(savedException); + emitSetCurrentException(); + // Mark this location for the stack trace. + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); + b.endMarkExceptionAsCaught(); + + b.beginTryCatchOtherwise(() -> emitRestoreCurrentException(savedException)); + b.beginBlock(); // try + visitSequence(node.finalBody); + b.endBlock(); // try + + b.beginBlock(); // catch + emitRestoreCurrentException(savedException); + + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); + b.endMarkExceptionAsCaught(); + + b.beginReraise(); + b.emitLoadException(); + b.endReraise(); + b.endBlock(); // catch + b.endTryCatchOtherwise(); + + b.beginReraise(); + b.emitLoadException(); + b.endReraise(); + b.endBlock(); // catch + b.endTryCatchOtherwise(); + // @formatter:on + } else { + emitTryExceptElse(node); + } + + endSourceSection(b, newStatement); + return null; + } + + /** + * Emit the "try-except-else" part of a Try node. The "finally" part, if it exists, should + * be handled by the caller of this method. + */ + private void emitTryExceptElse(StmtTy.Try node) { + if (node.handlers != null && node.handlers.length != 0) { + /** + * There are two orthogonal issues that complicate Python try-except clauses. + * + * First, when in an exception handler, the "current" exception (accessible via, e.g., + * sys.exc_info) gets set to the caught exception. After leaving the handler, this + * "current" exception must be restored to the one previously stored. Since except + * clauses can themselves raise exceptions, the restoring process must happen inside + * a finally block. + * + * Second, when an exception is bound to an identifier (e.g., except BaseException as + * ex), the identifier must be deleted after leaving the except clause. Again, since + * the except clause may raise an exception, the deletion must happen inside a finally + * block. Since the bound name is different in each clause, this block is specific to + * each handler. + * + * @formatter:off + * try { + * try_body + * # fall through to else_body + * } catch ex { + * save current exception + * set current exception to ex + * markCaught(ex) + * try { + * if (handler_1_matches(ex)) { + * assign ex to handler_1_name + * try { + * handler_1_body + * } catch handler_1_ex { + * unbind handler_1_name + * // Freeze the bci before it gets rethrown. + * markCaught(handler_ex) + * throw handler_1_ex + * } otherwise { + * unbind handler_1_name + * } + * goto afterElse + * } + * ... // more handlers + * + * // case 1: bare except + * bare_except_body + * goto afterElse + * } catch handler_ex { + * // A handler raised or no handler was found. Restore exception state and reraise. + * restore current exception + * markCaught(handler_ex) // (no-op if handler_ex is the original exception) + * reraise handler_ex + * } otherwise { + * // Exception handled. Restore the exception state. + * restore current exception + * } + * // case 2: no bare except (we only reach this point if no handler matched/threw) + * reraise ex + * } + * else_body + * afterElse: + */ + b.beginBlock(); // outermost block + + BytecodeLocal savedException = b.createLocal(); + BytecodeLabel afterElse = b.createLabel(); + + b.beginTryCatch(); + + b.beginBlock(); // try + visitSequence(node.body); + b.endBlock(); // try + + b.beginBlock(); // catch + emitSaveCurrentException(savedException); + emitSetCurrentException(); + // Mark this location for the stack trace. + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); // ex + b.endMarkExceptionAsCaught(); + + b.beginTryCatchOtherwise(() -> emitRestoreCurrentException(savedException)); + b.beginBlock(); // try + SourceRange bareExceptRange = null; + for (ExceptHandlerTy h : node.handlers) { + boolean newStatement = beginSourceSection(h, b); + if (bareExceptRange != null) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "default 'except:' must be last"); + } + + ExceptHandlerTy.ExceptHandler handler = (ExceptHandlerTy.ExceptHandler) h; + if (handler.type != null) { + b.beginIfThen(); + b.beginExceptMatch(); + b.emitLoadException(); // ex + handler.type.accept(this); + b.endExceptMatch(); + } else { + bareExceptRange = handler.getSourceRange(); + } + + b.beginBlock(); // handler body + + if (handler.name != null) { + // Assign exception to handler name. + beginStoreLocal(handler.name, b); + b.beginUnwrapException(); + b.emitLoadException(); // ex + b.endUnwrapException(); + endStoreLocal(handler.name, b); + + b.beginTryCatchOtherwise(() -> emitUnbindHandlerVariable(handler)); + b.beginBlock(); // try + visitSequence(handler.body); + b.endBlock(); // try + + b.beginBlock(); // catch + emitUnbindHandlerVariable(handler); + + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); // handler_i_ex + b.endMarkExceptionAsCaught(); + + b.beginThrow(); + b.emitLoadException(); // handler_i_ex + b.endThrow(); + b.endBlock(); // catch + b.endTryCatchOtherwise(); + } else { // bare except + b.beginBlock(); + visitSequence(handler.body); + b.endBlock(); + } + + b.emitBranch(afterElse); + + b.endBlock(); // handler body + + if (handler.type != null) { + b.endIfThen(); + } + + endSourceSection(b, newStatement); + } + b.endBlock(); // try + + b.beginBlock(); // catch + emitRestoreCurrentException(savedException); + + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); // handler_ex + b.endMarkExceptionAsCaught(); + + b.beginReraise(); + b.emitLoadException(); // handler_ex + b.endReraise(); + b.endBlock(); // catch + b.endTryCatchOtherwise(); + + /** + * Each handler branches to afterElse. If we reach this point and there was not a + * bare exception, none of the handlers matched, and we should reraise. + * Optimization: If there's a bare except clause, control will never fall through + * and we can omit the rethrow. + */ + if (bareExceptRange == null) { + b.beginReraise(); + b.emitLoadException(); // ex + b.endReraise(); + } + + b.endBlock(); // catch + + b.endTryCatch(); + + if (node.orElse != null) { + visitSequence(node.orElse); + } + b.emitLabel(afterElse); + + b.endBlock(); // outermost block + // @formatter:on + } else { + // Optimization: If there's no except clauses, there's no point in generating a + // TryCatch with a catch that just rethrows the caught exception. + b.beginBlock(); + visitSequence(node.body); + b.endBlock(); + } + } + + private void emitSaveCurrentException(BytecodeLocal savedException) { + b.beginStoreLocal(savedException); + b.emitGetCurrentException(); + b.endStoreLocal(); + } + + private void emitSetCurrentException() { + b.beginSetCurrentException(); + b.emitLoadException(); + b.endSetCurrentException(); + } + + private void emitRestoreCurrentException(BytecodeLocal savedException) { + b.beginSetCurrentException(); + b.emitLoadLocal(savedException); + b.endSetCurrentException(); + } + + private void emitUnbindHandlerVariable(ExceptHandlerTy.ExceptHandler handler) { + b.beginBlock(); + // Store None to the variable just in case the handler deleted it. + beginStoreLocal(handler.name, b); + b.emitLoadConstant(PNone.NONE); + endStoreLocal(handler.name, b); + emitDelLocal(handler.name, b); + b.endBlock(); + } + + @Override + public Void visit(StmtTy.TryStar node) { + emitNotImplemented("try star", b); + return null; + } + + @Override + public Void visit(ExceptHandlerTy.ExceptHandler node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(StmtTy.While node) { + boolean newStatement = beginSourceSection(node, b); + b.beginBlock(); + + BytecodeLabel oldBreakLabel = breakLabel; + BytecodeLabel oldContinueLabel = continueLabel; + + BytecodeLabel currentBreakLabel = b.createLabel(); + breakLabel = currentBreakLabel; + + b.beginWhile(); + + b.beginBlock(); + b.emitTraceLineAtLoopHeader(currentLocation.startLine); + visitCondition(node.test); + b.endBlock(); + + b.beginBlock(); + continueLabel = b.createLabel(); + visitStatements(node.body); + b.emitLabel(continueLabel); + b.endBlock(); + + b.endWhile(); + + breakLabel = oldBreakLabel; + continueLabel = oldContinueLabel; + visitStatements(node.orElse); + b.emitLabel(currentBreakLabel); + + b.endBlock(); + endSourceSection(b, newStatement); + return null; + } + + private void visitWithRecurse(WithItemTy[] items, int index, StmtTy[] body, boolean async) { + /** + * For a with-statement like + * + * with foo as x: + * bar + * + * we generate code that performs (roughly) + * + * @formatter:off + * contextManager = foo + * resolve __enter__ and __exit__ + * value = __enter__() + * try { + * x = value + * bar + * } catch ex { + * if not __exit__(...): + * raise + * } otherwise { + * call __exit__(None, None, None) + * } + * @formatter:on + * + * When there are multiple context managers, they are recursively generated (where "bar" + * is). Once we have entered all of the context managers, we emit the body. + */ + WithItemTy item = items[index]; + boolean newStatement = beginSourceSection(item, b); + b.beginBlock(); + + BytecodeLocal contextManager = b.createLocal(); + b.beginStoreLocal(contextManager); + item.contextExpr.accept(this); + b.endStoreLocal(); + + BytecodeLocal exit = b.createLocal(); + BytecodeLocal value = b.createLocal(); + if (async) { + // call __aenter__ + b.beginAsyncContextManagerEnter(exit, value); + b.emitLoadLocal(contextManager); + b.endAsyncContextManagerEnter(); + // await the result + emitAwait(() -> b.emitLoadLocal(value)); + } else { + // call __enter__ + b.beginContextManagerEnter(exit, value); + b.emitLoadLocal(contextManager); + b.endContextManagerEnter(); + } + + Runnable finallyHandler; + if (async) { + finallyHandler = () -> emitAwait(() -> { + b.beginAsyncContextManagerCallExit(); + b.emitLoadConstant(PNone.NONE); + b.emitLoadLocal(exit); + b.emitLoadLocal(contextManager); + b.endAsyncContextManagerCallExit(); + }); + } else { + finallyHandler = () -> { + // call __exit__ + b.beginContextManagerExit(); + b.emitLoadConstant(PNone.NONE); + b.emitLoadLocal(exit); + b.emitLoadLocal(contextManager); + b.endContextManagerExit(); + }; + } + b.beginTryCatchOtherwise(finallyHandler); + b.beginBlock(); // try + if (item.optionalVars != null) { + item.optionalVars.accept(new StoreVisitor(() -> b.emitLoadLocal(value))); + } + if (index < items.length - 1) { + visitWithRecurse(items, index + 1, body, async); + } else { + visitSequence(body); + } + b.endBlock(); // try + + b.beginBlock(); // catch + + // Mark this location for the stack trace. + b.beginMarkExceptionAsCaught(); + b.emitLoadException(); + b.endMarkExceptionAsCaught(); + + // exceptional exit + if (async) { + // call, await, and handle result of __aexit__ + b.beginAsyncContextManagerExit(); + b.emitLoadException(); + emitAwait(() -> { + b.beginAsyncContextManagerCallExit(); + b.emitLoadException(); + b.emitLoadLocal(exit); + b.emitLoadLocal(contextManager); + b.endAsyncContextManagerCallExit(); + }); + b.endAsyncContextManagerExit(); + } else { + // call __exit__ + b.beginContextManagerExit(); + b.emitLoadException(); + b.emitLoadLocal(exit); + b.emitLoadLocal(contextManager); + b.endContextManagerExit(); + } + b.endBlock(); // catch + + b.endTryCatchOtherwise(); + b.endBlock(); + endSourceSection(b, newStatement); + } + + @Override + public Void visit(StmtTy.With node) { + boolean newStatement = beginSourceSection(node, b); + visitWithRecurse(node.items, 0, node.body, false); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(WithItemTy node) { + throw new UnsupportedOperationException("" + node.getClass()); + } + + @Override + public Void visit(StmtTy.Break aThis) { + boolean newStatement = beginSourceSection(aThis, b); + if (breakLabel == null) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'break' outside loop"); + } + b.emitBranch(breakLabel); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.Continue aThis) { + boolean newStatement = beginSourceSection(aThis, b); + if (continueLabel == null) { + ctx.errorCallback.onError(ErrorType.Syntax, currentLocation, "'continue' not properly in loop"); + } + b.emitBranch(continueLabel); + endSourceSection(b, newStatement); + return null; + } + + @Override + public Void visit(StmtTy.Pass aThis) { + return null; + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java index 1d32ff3298..efeb878f58 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAddNode.java @@ -57,6 +57,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -73,6 +74,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberAddNode extends PyNumberAddFastPathsBase { @Specialization(guards = {"isBuiltinList(left)", "isBuiltinList(right)"}) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java index b93c72006b..0ad79e2a87 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberAndNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberAndFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberAndNode extends PyNumberAndFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java index f1cbeb22ef..710904e665 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloorDivideNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberFloorDivideFastPathsBase; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -53,6 +54,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberFloorDivideNode extends PyNumberFloorDivideFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java index c53cea1277..c700c6ef4d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAddNode.java @@ -52,6 +52,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -65,6 +66,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceAddNode extends PyNumberAddFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java index 08bd3d37a4..25f56faf46 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceAndNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberAndFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceAndNode extends PyNumberAndFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java index b443ee3c49..b0eb213ec5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceFloorDivideNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberFloorDivideFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceFloorDivideNode extends PyNumberFloorDivideFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java index 6e31d2f863..9ede290b1f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceLshiftNode.java @@ -41,7 +41,8 @@ package com.oracle.graal.python.lib; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; -import com.oracle.graal.python.lib.fastpath.PyNumberLshiftFastPathsBase; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -51,10 +52,12 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +// TODO: should inherit from PyNumberLshiftFastPathsBase, blocked by GR-64005 @GenerateInline(false) @GenerateUncached -public abstract class PyNumberInPlaceLshiftNode extends PyNumberLshiftFastPathsBase { - @Specialization(replaces = {"doII", "doLL"}) +@OperationProxy.Proxyable +public abstract class PyNumberInPlaceLshiftNode extends BinaryOpNode { + @Specialization // (replaces = {"doII", "doLL"}) public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, @Cached CallBinaryIOpNode callBinaryOpNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java index 3f65419a60..76f26e8e4b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMatrixMultiplyNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -53,6 +54,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceMatrixMultiplyNode extends BinaryOpNode { @Specialization public static Object doIt(VirtualFrame frame, Object v, Object w, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java index c9591a2714..aa0b005f2c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceMultiplyNode.java @@ -51,6 +51,7 @@ import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -64,6 +65,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceMultiplyNode extends PyNumberMultiplyFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java index 0b400b106f..28edd9a3d5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceOrNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberOrFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceOrNode extends PyNumberOrFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java index f175c4f8a5..def6460240 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlacePowerNode.java @@ -48,6 +48,7 @@ import com.oracle.graal.python.nodes.expression.BinaryOpNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -59,6 +60,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlacePowerNode extends BinaryOpNode { public abstract Object execute(VirtualFrame frame, Object v, Object w, Object z); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java index 38183412e8..19c3df7d0e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRemainderNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberRemainderFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceRemainderNode extends PyNumberRemainderFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java index 525187f1ae..3e961b7892 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceRshiftNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberRshiftFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceRshiftNode extends PyNumberRshiftFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java index 029896fab9..c8e642dba0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceSubtractNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberSubtractFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceSubtractNode extends PyNumberSubtractFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java index a46f7f8686..423ea1a51b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceTrueDivideNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberTrueDivideFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceTrueDivideNode extends PyNumberTrueDivideFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java index 649c2306a6..c2665ccf1c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInPlaceXorNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.InplaceSlot; import com.oracle.graal.python.lib.fastpath.PyNumberXorFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberInPlaceXorNode extends PyNumberXorFastPathsBase { @Fallback @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java index a920f76837..fd35b6dddb 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberInvertNode.java @@ -49,6 +49,7 @@ import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -61,6 +62,7 @@ @GenerateUncached @GenerateInline(false) +@OperationProxy.Proxyable public abstract class PyNumberInvertNode extends UnaryOpNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java index 1b4c280b14..df9e53e00f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberLshiftNode.java @@ -41,7 +41,8 @@ package com.oracle.graal.python.lib; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; -import com.oracle.graal.python.lib.fastpath.PyNumberLshiftFastPathsBase; +import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -51,11 +52,13 @@ import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +// TODO: should inherit from PyNumberLshiftFastPathsBase, blocked by GR-64005 @GenerateInline(false) @GenerateUncached -public abstract class PyNumberLshiftNode extends PyNumberLshiftFastPathsBase { +@OperationProxy.Proxyable +public abstract class PyNumberLshiftNode extends BinaryOpNode { - @Specialization(replaces = {"doII", "doLL"}) + @Specialization // (replaces = {"doII", "doLL"}) public static Object doIt(VirtualFrame frame, Object v, Object w, @Bind Node inliningTarget, @Cached CallBinaryOpNode callBinaryOpNode) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java index a702b99071..bdc6dbfbe7 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMatrixMultiplyNode.java @@ -42,6 +42,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.nodes.expression.BinaryOpNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -52,7 +53,7 @@ import com.oracle.truffle.api.nodes.Node; @GenerateInline(false) - +@OperationProxy.Proxyable @GenerateUncached public abstract class PyNumberMatrixMultiplyNode extends BinaryOpNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java index a3d006cfa3..a7d60a4e5f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberMultiplyNode.java @@ -49,6 +49,7 @@ import com.oracle.graal.python.lib.fastpath.PyNumberMultiplyFastPathsBase; import com.oracle.graal.python.nodes.PRaiseNode; import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -62,6 +63,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberMultiplyNode extends PyNumberMultiplyFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java index cca2839be7..399fe6c422 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberNegativeNode.java @@ -49,6 +49,7 @@ import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -61,6 +62,7 @@ @GenerateUncached @GenerateInline(false) +@OperationProxy.Proxyable public abstract class PyNumberNegativeNode extends UnaryOpNode { public static final int INT_MIN_VALUE = Integer.MIN_VALUE; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java index 5509caa8ce..a91292e253 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberOrNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberOrFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberOrNode extends PyNumberOrFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java index 833297afea..6689a5b541 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPositiveNode.java @@ -49,6 +49,7 @@ import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -61,6 +62,7 @@ @GenerateUncached @GenerateInline(false) +@OperationProxy.Proxyable public abstract class PyNumberPositiveNode extends UnaryOpNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java index 6fcb9381e2..2b7d4848b3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberPowerNode.java @@ -51,6 +51,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -62,6 +63,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberPowerNode extends BinaryOpNode { public abstract Object execute(VirtualFrame frame, Object v, Object w, Object z); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java index cb47c66661..88dee651ef 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRemainderNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberRemainderFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberRemainderNode extends PyNumberRemainderFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java index 4d68329099..9ede62d455 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberRshiftNode.java @@ -56,6 +56,7 @@ import com.oracle.graal.python.runtime.exception.PException; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -67,6 +68,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberRshiftNode extends PyNumberRshiftFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java index f7a9a92404..ee8db9dad3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberSubtractNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberSubtractFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberSubtractNode extends PyNumberSubtractFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java index 71e03afe02..b63c97a07c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberTrueDivideNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberTrueDivideFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberTrueDivideNode extends PyNumberTrueDivideFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java index a2cea4db58..e58dd7d03d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberXorNode.java @@ -43,6 +43,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.ReversibleSlot; import com.oracle.graal.python.lib.fastpath.PyNumberXorFastPathsBase; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -54,6 +55,7 @@ @GenerateInline(false) @GenerateUncached +@OperationProxy.Proxyable public abstract class PyNumberXorNode extends PyNumberXorFastPathsBase { @Fallback diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java new file mode 100644 index 0000000000..27c7af8a60 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsNotTrueNode.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2021, 2025, 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.lib; + +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; +import com.oracle.graal.python.builtins.objects.dict.PDict; +import com.oracle.graal.python.builtins.objects.list.PList; +import com.oracle.graal.python.builtins.objects.set.PBaseSet; +import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.lib.PyObjectIsTrueNode.PyObjectIsTrueNodeGeneric; +import com.oracle.graal.python.nodes.PNodeWithContext; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.GenerateInline; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.frame.Frame; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.strings.TruffleString; + +/** + * Equivalent of a negation of CPython's {@code PyObject_IsTrue}. This class exists only so that we + * can have quickening fast-paths for this operation. The fast-paths should be synchronized with + * {@link PyObjectIsNotTrueNode}. + */ +@GenerateInline(false) +@OperationProxy.Proxyable +public abstract class PyObjectIsNotTrueNode extends PNodeWithContext { + public abstract boolean execute(Frame frame, Object object); + + @Specialization + public static boolean doBoolean(boolean object) { + return !object; + } + + @Specialization + public static boolean doNone(@SuppressWarnings("unused") PNone object) { + return true; + } + + @Specialization + public static boolean doInt(int object) { + return object == 0; + } + + @Specialization + public static boolean doLong(long object) { + return object == 0; + } + + @Specialization + public static boolean doDouble(double object) { + return object == 0.0; + } + + @Specialization + public static boolean doString(TruffleString object) { + return object.isEmpty(); + } + + @Specialization(guards = "isBuiltinList(object)") + public static boolean doList(PList object) { + return object.getSequenceStorage().length() == 0; + } + + @Specialization(guards = "isBuiltinTuple(object)") + public static boolean doTuple(PTuple object) { + return object.getSequenceStorage().length() == 0; + } + + @Specialization(guards = "isBuiltinDict(object)") + public static boolean doDict(PDict object, + @Bind Node inliningTarget, + @Exclusive @Cached HashingStorageLen lenNode) { + return lenNode.execute(inliningTarget, object.getDictStorage()) == 0; + } + + @Specialization(guards = "isBuiltinAnySet(object)") + @InliningCutoff + public static boolean doSet(PBaseSet object, + @Bind Node inliningTarget, + @Exclusive @Cached HashingStorageLen lenNode) { + return lenNode.execute(inliningTarget, object.getDictStorage()) == 0; + } + + @Specialization(guards = {"!isBoolean(object)", "!isPNone(object)", "!isInt(object)", "!isLong(object)", "!isDouble(object)", "!isTruffleString(object)"}, // + replaces = {"doList", "doTuple", "doDict", "doSet"}) + @InliningCutoff + public static boolean doOthers(VirtualFrame frame, Object object, + @Cached(inline = false) PyObjectIsTrueNodeGeneric internalNode) { + return !internalNode.execute(frame, object); + } + + @NeverDefault + public static PyObjectIsNotTrueNode create() { + return PyObjectIsNotTrueNodeGen.create(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java index 8cd53b7697..c4170433d0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectIsTrueNode.java @@ -53,6 +53,7 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -76,7 +77,7 @@ @GenerateUncached @GenerateInline(false) @GenerateCached - +@OperationProxy.Proxyable public abstract class PyObjectIsTrueNode extends PNodeWithContext { public abstract boolean execute(Frame frame, Object object); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberLshiftFastPathsBase.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberLshiftFastPathsBase.java index 048f9354db..3662fe3a00 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberLshiftFastPathsBase.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/fastpath/PyNumberLshiftFastPathsBase.java @@ -47,7 +47,7 @@ /** * Helper class with shared fast-paths. Must be public so that it is accessible by the Bytecode DSL - * generated code. + * generated code. TODO: unused due to GR-64005 */ @GenerateCached(false) public abstract class PyNumberLshiftFastPathsBase extends BinaryOpNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java index 9728f7af4d..30d9f320f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java @@ -105,6 +105,7 @@ import com.oracle.graal.python.builtins.objects.type.TypeNodes; import com.oracle.graal.python.lib.PyIndexCheckNode; import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.sequence.PSequence; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; @@ -718,4 +719,9 @@ public static boolean isNullOrZero(Object value, InteropLibrary lib) { public static boolean hasBuiltinDictIter(Node inliningTarget, PDict dict, GetPythonObjectClassNode getClassNode, GetCachedTpSlotsNode getSlots) { return isBuiltinDict(dict) || getSlots.execute(inliningTarget, getClassNode.execute(inliningTarget, dict)).tp_iter() == DictBuiltins.SLOTS.tp_iter(); } + + @Idempotent + public static boolean isBytecodeDSLInterpreter() { + return PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRootNode.java index 1f56957fff..46b56a408e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRootNode.java @@ -61,19 +61,19 @@ public abstract class PRootNode extends RootNode { private final ConditionProfile frameEscaped = ConditionProfile.create(); - @CompilationFinal private Assumption dontNeedCallerFrame = createCallerFrameAssumption(); + @CompilationFinal private transient Assumption dontNeedCallerFrame = createCallerFrameAssumption(); /** * Flag indicating if some child node of this root node (or a callee) eventually needs the * exception state. Hence, the caller of this root node should provide the exception state in * the arguments. */ - @CompilationFinal private Assumption dontNeedExceptionState = createExceptionStateAssumption(); + @CompilationFinal private transient Assumption dontNeedExceptionState = createExceptionStateAssumption(); - private int nodeCount = -1; + private transient int nodeCount = -1; // contains the code of this root node in marshaled/serialized form - private byte[] code; + private transient byte[] code; protected PRootNode(TruffleLanguage language) { super(language); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java index 96dd482536..40fb5ff99b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java @@ -147,6 +147,7 @@ public abstract class StringLiterals { public static final TruffleString T_EXEC = tsLiteral("exec"); public static final TruffleString T_EVAL = tsLiteral("eval"); public static final TruffleString T_FUNC_TYPE = tsLiteral("func_type"); + public static final TruffleString T_SUPER = tsLiteral("super"); public static final String J_OB_REFCNT = "ob_refcnt"; public static final String J_DEBUG = "debug"; public static final String J_TRACE = "trace"; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java index 33996ad97e..9bdcccd688 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java @@ -72,6 +72,7 @@ import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -267,6 +268,7 @@ protected PList doGeneric(VirtualFrame frame, Object value, */ @GenerateUncached @GenerateInline(false) // footprint reduction 36 -> 17 + @OperationProxy.Proxyable public abstract static class AppendNode extends PNodeWithContext { private static final BranchProfile[] DISABLED = new BranchProfile[]{BranchProfile.getUncached()}; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/BytecodeFrameInfo.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/BytecodeFrameInfo.java new file mode 100644 index 0000000000..5d0761210e --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/BytecodeFrameInfo.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025, 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.bytecode; + +import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.OpCodesConstants; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.frame.Frame; + +public class BytecodeFrameInfo implements FrameInfo { + @CompilationFinal PBytecodeRootNode rootNode; + + void setRootNode(PBytecodeRootNode rootNode) { + this.rootNode = rootNode; + } + + @Override + public PBytecodeRootNode getRootNode() { + return rootNode; + } + + public int getBci(Frame frame) { + if (frame.isInt(rootNode.bcioffset)) { + return frame.getInt(rootNode.bcioffset); + } else { + return -1; + } + } + + public int getLineForBci(int bci) { + return rootNode.bciToLine(bci); + } + + public int getLine(Frame frame) { + return getLineForBci(getBci(frame)); + } + + @Override + public int getFirstLineNumber() { + return rootNode.getFirstLineno(); + } + + @Override + public Object getYieldFrom(Frame generatorFrame, int bci, int stackTop) { + /* Match the `yield from` bytecode pattern and get the object from stack */ + if (bci > 3 && bci < rootNode.bytecode.length && rootNode.bytecode[bci - 3] == OpCodesConstants.SEND && rootNode.bytecode[bci - 1] == OpCodesConstants.YIELD_VALUE && + rootNode.bytecode[bci] == OpCodesConstants.RESUME_YIELD) { + return generatorFrame.getObject(stackTop); + } + return null; + } + + @Override + public CodeUnit getCodeUnit() { + return rootNode.getCodeUnit(); + } + + @Override + public boolean includeInTraceback() { + return rootNode.frameIsVisibleToPython(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/FrameInfo.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/FrameInfo.java index 97a4d69844..3fbc8a948f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/FrameInfo.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/FrameInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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,8 +41,7 @@ package com.oracle.graal.python.nodes.bytecode; import com.oracle.graal.python.compiler.CodeUnit; -import com.oracle.graal.python.compiler.OpCodesConstants; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.graal.python.nodes.PRootNode; import com.oracle.truffle.api.dsl.Idempotent; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; @@ -53,38 +52,30 @@ * returned by {@link FrameDescriptor#getInfo()} if and only if the frame is coming from the * bytecode interpreter. */ -public final class FrameInfo { - @CompilationFinal PBytecodeRootNode rootNode; +public interface FrameInfo { - public PBytecodeRootNode getRootNode() { - return rootNode; - } + public PRootNode getRootNode(); - public int getBci(Frame frame) { - if (frame.isInt(rootNode.bcioffset)) { - return frame.getInt(rootNode.bcioffset); - } else { - return -1; - } - } + public int getFirstLineNumber(); - public Object getYieldFrom(Frame generatorFrame, int bci, int stackTop) { - /* Match the `yield from` bytecode pattern and get the object from stack */ - if (bci > 3 && bci < rootNode.bytecode.length && rootNode.bytecode[bci - 3] == OpCodesConstants.SEND && rootNode.bytecode[bci - 1] == OpCodesConstants.YIELD_VALUE && - rootNode.bytecode[bci] == OpCodesConstants.RESUME_YIELD) { - return generatorFrame.getObject(stackTop); - } - return null; - } + public Object getYieldFrom(Frame generatorFrame, int bci, int stackTop); + + public boolean includeInTraceback(); + + public CodeUnit getCodeUnit(); @Idempotent - public int getVariableCount() { - CodeUnit code = rootNode.getCodeUnit(); + public default int getVariableCount() { + CodeUnit code = getCodeUnit(); return code.varnames.length + code.cellvars.length + code.freevars.length; } - public TruffleString getVariableName(int slot) { - CodeUnit code = rootNode.getCodeUnit(); + public default int getRegularVariableCount() { + return getCodeUnit().varnames.length; + } + + public default TruffleString getVariableName(int slot) { + CodeUnit code = getCodeUnit(); if (slot < code.varnames.length) { return code.varnames[slot]; } else if (slot < code.varnames.length + code.cellvars.length) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetYieldFromIterNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetYieldFromIterNode.java index 3a43fe1d1c..c746d74f2e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetYieldFromIterNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/GetYieldFromIterNode.java @@ -44,6 +44,7 @@ import com.oracle.graal.python.builtins.objects.generator.PGenerator; import com.oracle.graal.python.lib.PyObjectGetIter; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectExactProfile; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.GenerateInline; @@ -54,6 +55,7 @@ @GenerateUncached @GenerateInline(false) // used in BCI root node +@OperationProxy.Proxyable public abstract class GetYieldFromIterNode extends Node { public abstract Object execute(VirtualFrame frame, Object receiver); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java index 637625706c..e076c27bce 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/MakeFunctionNode.java @@ -49,7 +49,7 @@ import com.oracle.graal.python.builtins.objects.function.PKeyword; import com.oracle.graal.python.builtins.objects.function.Signature; import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.nodes.PNodeWithContext; import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; @@ -67,7 +67,7 @@ public abstract class MakeFunctionNode extends PNodeWithContext { private final RootCallTarget callTarget; - private final CodeUnit code; + private final BytecodeCodeUnit code; private final Signature signature; @CompilationFinal private PCode cachedCode; @@ -76,7 +76,7 @@ public abstract class MakeFunctionNode extends PNodeWithContext { public abstract int execute(VirtualFrame frame, Object globals, int initialStackTop, int flags); - public MakeFunctionNode(RootCallTarget callTarget, CodeUnit code, Signature signature) { + public MakeFunctionNode(RootCallTarget callTarget, BytecodeCodeUnit code, Signature signature) { this.callTarget = callTarget; this.code = code; this.signature = signature; @@ -145,7 +145,7 @@ int makeFunction(VirtualFrame frame, Object globals, int initialStackTop, int fl return stackTop; } - public static MakeFunctionNode create(PythonLanguage language, CodeUnit code, Source source) { + public static MakeFunctionNode create(PythonLanguage language, BytecodeCodeUnit code, Source source) { RootCallTarget callTarget; PBytecodeRootNode bytecodeRootNode = PBytecodeRootNode.create(language, code, source); if (code.isGeneratorOrCoroutine()) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java index 0da78402b5..83a68bac42 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/NotNode.java @@ -50,6 +50,7 @@ import com.oracle.graal.python.lib.PyObjectIsTrueNode.PyObjectIsTrueNodeGeneric; import com.oracle.graal.python.nodes.expression.UnaryOpNode; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -66,6 +67,7 @@ * {@link PyObjectIsTrueNode}. */ @GenerateInline(false) +@OperationProxy.Proxyable public abstract class NotNode extends UnaryOpNode { @Specialization diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java index 34b7d0dca8..9fba60116b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/PBytecodeRootNode.java @@ -52,7 +52,6 @@ import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; import java.math.BigInteger; -import java.util.Arrays; import java.util.Collections; import java.util.Set; import java.util.concurrent.locks.Lock; @@ -101,7 +100,7 @@ import com.oracle.graal.python.builtins.objects.slice.SliceNodes.CreateSliceNode; import com.oracle.graal.python.builtins.objects.slice.SliceNodesFactory.CreateSliceNodeGen; import com.oracle.graal.python.compiler.BinaryOpsConstants; -import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.FormatOptions; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.compiler.OpCodes.CollectionBits; @@ -524,7 +523,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod final int selfIndex; final int classcellIndex; - private final CodeUnit co; + private final BytecodeCodeUnit co; private final Source source; private SourceSection sourceSection; // For deferred deprecation warnings @@ -595,7 +594,7 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod @Child private InstrumentationRoot instrumentationRoot = InstrumentationRoot.create(); - private static FrameDescriptor makeFrameDescriptor(CodeUnit co, FrameInfo info) { + private static FrameDescriptor makeFrameDescriptor(BytecodeCodeUnit co, FrameInfo info) { int capacity = co.varnames.length + co.cellvars.length + co.freevars.length + co.stacksize + 1; FrameDescriptor.Builder newBuilder = FrameDescriptor.newBuilder(capacity); newBuilder.info(info); @@ -633,39 +632,27 @@ private static FrameDescriptor makeFrameDescriptor(CodeUnit co, FrameInfo info) return newBuilder.build(); } - private static Signature makeSignature(CodeUnit co) { - int posArgCount = co.argCount + co.positionalOnlyArgCount; - TruffleString[] parameterNames = Arrays.copyOf(co.varnames, posArgCount); - TruffleString[] kwOnlyNames = Arrays.copyOfRange(co.varnames, posArgCount, posArgCount + co.kwOnlyArgCount); - int varArgsIndex = co.takesVarArgs() ? posArgCount : -1; - return new Signature(co.positionalOnlyArgCount, - co.takesVarKeywordArgs(), - varArgsIndex, - parameterNames, - kwOnlyNames); - } - @TruffleBoundary - public static PBytecodeRootNode create(PythonLanguage language, CodeUnit co, Source source) { + public static PBytecodeRootNode create(PythonLanguage language, BytecodeCodeUnit co, Source source) { return create(language, co, source, null); } @TruffleBoundary - public static PBytecodeRootNode create(PythonLanguage language, CodeUnit co, Source source, RaisePythonExceptionErrorCallback parserErrorCallback) { - FrameInfo frameInfo = new FrameInfo(); + public static PBytecodeRootNode create(PythonLanguage language, BytecodeCodeUnit co, Source source, RaisePythonExceptionErrorCallback parserErrorCallback) { + BytecodeFrameInfo frameInfo = new BytecodeFrameInfo(); FrameDescriptor fd = makeFrameDescriptor(co, frameInfo); - PBytecodeRootNode rootNode = new PBytecodeRootNode(language, fd, makeSignature(co), co, source, parserErrorCallback); + PBytecodeRootNode rootNode = new PBytecodeRootNode(language, fd, co.computeSignature(), co, source, parserErrorCallback); PythonContext context = PythonContext.get(rootNode); if (context != null && context.getOption(PythonOptions.EagerlyMaterializeInstrumentationNodes)) { rootNode.adoptChildren(); rootNode.instrumentationRoot.materializeInstrumentableNodes(Collections.singleton(StandardTags.StatementTag.class)); } - frameInfo.rootNode = rootNode; + frameInfo.setRootNode(rootNode); return rootNode; } @TruffleBoundary - private PBytecodeRootNode(PythonLanguage language, FrameDescriptor fd, Signature sign, CodeUnit co, Source source, RaisePythonExceptionErrorCallback parserErrorCallback) { + private PBytecodeRootNode(PythonLanguage language, FrameDescriptor fd, Signature sign, BytecodeCodeUnit co, Source source, RaisePythonExceptionErrorCallback parserErrorCallback) { super(language, fd); assert source != null; this.celloffset = co.varnames.length; @@ -751,7 +738,7 @@ public void setPythonInternal(boolean pythonInternal) { this.pythonInternal = pythonInternal; } - public CodeUnit getCodeUnit() { + public BytecodeCodeUnit getCodeUnit() { return co; } @@ -1073,7 +1060,6 @@ public Object execute(VirtualFrame virtualFrame) { if (!co.isGeneratorOrCoroutine()) { copyArgsAndCells(virtualFrame, virtualFrame.getArguments()); } - return executeFromBci(virtualFrame, virtualFrame, this, 0, getInitialStackTop()); } finally { calleeContext.exit(virtualFrame, this); @@ -2599,7 +2585,7 @@ private void bytecodeSetupAnnotations(VirtualFrame virtualFrame, boolean useCach @BytecodeInterpreterSwitch private int bytecodeMakeFunction(VirtualFrame virtualFrame, Object globals, int stackTop, Node[] localNodes, int beginBci, int flags, Object localConsts) { - CodeUnit codeUnit = (CodeUnit) localConsts; + BytecodeCodeUnit codeUnit = (BytecodeCodeUnit) localConsts; MakeFunctionNode makeFunctionNode = insertMakeFunctionNode(localNodes, beginBci, codeUnit); return makeFunctionNode.execute(virtualFrame, globals, stackTop, flags); } @@ -2772,15 +2758,15 @@ private Object notifyEnter(VirtualFrame virtualFrame, InstrumentationSupport ins return null; } - private MakeFunctionNode insertMakeFunctionNode(Node[] localNodes, int beginBci, CodeUnit codeUnit) { + private MakeFunctionNode insertMakeFunctionNode(Node[] localNodes, int beginBci, BytecodeCodeUnit codeUnit) { return insertChildNode(localNodes, beginBci, MakeFunctionNodeGen.class, () -> MakeFunctionNode.create(getLanguage(PythonLanguage.class), codeUnit, source)); } public void materializeContainedFunctionsForInstrumentation(Set> materializedTags) { usingCachedNodes = true; - CodeUnit.iterateBytecode(bytecode, (bci, op, oparg, followingArgs) -> { + BytecodeCodeUnit.iterateBytecode(bytecode, (bci, op, oparg, followingArgs) -> { if (op == OpCodes.MAKE_FUNCTION) { - CodeUnit codeUnit = (CodeUnit) consts[oparg]; + BytecodeCodeUnit codeUnit = (BytecodeCodeUnit) consts[oparg]; MakeFunctionNode makeFunctionNode = insertMakeFunctionNode(getChildNodes(), bci, codeUnit); RootNode rootNode = makeFunctionNode.getCallTarget().getRootNode(); if (rootNode instanceof PBytecodeGeneratorFunctionRootNode) { @@ -2948,10 +2934,10 @@ private int traceLine(VirtualFrame virtualFrame, MutableLoopData mutableData, by if (pyFrame.didJump()) { int newBci = lineToBci(pyFrame.getJumpDestLine()); mutableData.setPastBci(bci); - if (newBci == CodeUnit.LINE_TO_BCI_LINE_AFTER_CODEBLOCK) { + if (newBci == BytecodeCodeUnit.LINE_TO_BCI_LINE_AFTER_CODEBLOCK) { // line after the code block throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.LINE_D_COMES_AFTER_THE_CURRENT_CODE_BLOCK, pyFrame.getLine()); - } else if (newBci == CodeUnit.LINE_TO_BCI_LINE_BEFORE_CODEBLOCK) { + } else if (newBci == BytecodeCodeUnit.LINE_TO_BCI_LINE_BEFORE_CODEBLOCK) { // line before the code block throw PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.LINE_D_COMES_BEFORE_THE_CURRENT_CODE_BLOCK, pyFrame.getJumpDestLine()); } else { @@ -3157,7 +3143,7 @@ private void syncLocalsBackToFrame(VirtualFrame virtualFrame, PFrame pyFrame) { if (co.isGeneratorOrCoroutine()) { localFrame = PArguments.getGeneratorFrame(virtualFrame); } - GetFrameLocalsNode.syncLocalsBackToFrame(co, pyFrame, localFrame); + GetFrameLocalsNode.syncLocalsBackToFrame(co, this, pyFrame, localFrame); } private void profileCEvent(VirtualFrame virtualFrame, Object callable, PythonContext.ProfileEvent event, MutableLoopData mutableData, byte tracingOrProfilingEnabled) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java index 12066f8483..14cd3802a9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/RaiseNode.java @@ -51,6 +51,7 @@ import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.GenerateInline; import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.frame.VirtualFrame; @@ -245,6 +246,7 @@ private static PException raiseNoException(Node inliningTarget, PRaiseNode raise throw raise.raise(inliningTarget, TypeError, ErrorMessages.EXCEPTIONS_MUST_DERIVE_FROM_BASE_EX); } + @NeverDefault public static RaiseNode create() { return RaiseNodeGen.create(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java index 2fe1eb0988..af6bb2069b 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/SetupAnnotationsNode.java @@ -59,6 +59,7 @@ import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.exception.PException; import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Fallback; @@ -76,6 +77,7 @@ @GenerateUncached @ImportStatic(PArguments.class) @GenerateInline(false) // used in BCI root node +@OperationProxy.Proxyable public abstract class SetupAnnotationsNode extends PNodeWithContext { public abstract void execute(Frame frame); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationSupport.java index ca1734135a..28c0807e52 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode/instrumentation/InstrumentationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, 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 @@ -40,7 +40,7 @@ */ package com.oracle.graal.python.nodes.bytecode.instrumentation; -import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.compiler.OpCodes; import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; @@ -62,7 +62,7 @@ * @see InstrumentationRoot */ public final class InstrumentationSupport extends Node { - final CodeUnit code; + final BytecodeCodeUnit code; @Children InstrumentedBytecodeStatement[] statements; /* * When instrumentation is active, this array is used instead of PBytecodeRootNode#adoptedNodes diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLCodeUnit.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLCodeUnit.java new file mode 100644 index 0000000000..b6e089e5e0 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLCodeUnit.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2025, 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.bytecode_dsl; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import com.oracle.graal.python.builtins.modules.MarshalModuleBuiltins; +import com.oracle.graal.python.builtins.modules.MarshalModuleBuiltins.PBytecodeDSLSerializer; +import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.bytecode.BytecodeRootNodes; +import com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; + +public final class BytecodeDSLCodeUnit extends CodeUnit { + /* + * A {@link BytecodeDSLCodeUnit} is a context-independent representation of a root node. It + * contains the bytes produced from Bytecode DSL serialization. + * + * Since it is expensive to serialize every root node, we perform serialization lazily using the + * {@link BytecodeNodes} produced during parsing. + * + * When this code unit is directly instantiated via unmarshaling, there is no {@link + * BytecodeNodes}; instead, we store the serialized bytes directly. + */ + private volatile byte[] serialized; + private final BytecodeRootNodes nodes; + public final int classcellIndex; + public final int selfIndex; + + public BytecodeDSLCodeUnit(TruffleString name, TruffleString qualname, int argCount, int kwOnlyArgCount, int positionalOnlyArgCount, int flags, TruffleString[] names, TruffleString[] varnames, + TruffleString[] cellvars, TruffleString[] freevars, int[] cell2arg, Object[] constants, int startLine, int startColumn, int endLine, int endColumn, + int classcellIndex, int selfIndex, byte[] serialized, BytecodeRootNodes nodes) { + super(name, qualname, argCount, kwOnlyArgCount, positionalOnlyArgCount, flags, names, varnames, cellvars, freevars, cell2arg, constants, startLine, startColumn, endLine, endColumn); + // Only one of these fields should be set. The other gets computed dynamically. + assert serialized == null ^ nodes == null; + this.serialized = serialized; + this.nodes = nodes; + this.classcellIndex = classcellIndex; + this.selfIndex = selfIndex; + } + + @TruffleBoundary + public PBytecodeDSLRootNode createRootNode(PythonContext context, Source source) { + byte[] toDeserialize = getSerialized(context); + BytecodeRootNodes deserialized = MarshalModuleBuiltins.deserializeBytecodeNodes(context, source, toDeserialize); + assert deserialized.count() == 1; + PBytecodeDSLRootNode result = deserialized.getNode(0); + result.setMetadata(this, null); + return result; + } + + public byte[] getSerialized(PythonContext context) { + CompilerAsserts.neverPartOfCompilation(); + byte[] result = serialized; + if (result == null) { + synchronized (this) { + result = serialized; + if (result == null) { + result = serialized = computeSerialized(context); + } + } + } + return result; + } + + @SuppressWarnings("unchecked") + @TruffleBoundary + private byte[] computeSerialized(PythonContext context) { + try { + BytecodeSerializer serializer = new PBytecodeDSLSerializer(context); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + nodes.serialize(new DataOutputStream(bytes), serializer); + return bytes.toByteArray(); + } catch (IOException e) { + throw CompilerDirectives.shouldNotReachHere(e); + } + } + + public TruffleString getDocstring() { + // The first constant in the code unit is the docstring (if available) or PNone. + if (constants.length > 0 && constants[0] instanceof TruffleString docstring) { + return docstring; + } + return null; + } + +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLFrameInfo.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLFrameInfo.java new file mode 100644 index 0000000000..1ef3e7a87e --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/BytecodeDSLFrameInfo.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025, 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.bytecode_dsl; + +import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.nodes.bytecode.FrameInfo; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.frame.Frame; + +public class BytecodeDSLFrameInfo implements FrameInfo { + @CompilationFinal PBytecodeDSLRootNode rootNode; + + /** + * The root node cannot be created without a frame descriptor, which cannot be created without + * the frame info, so we have to set the root node after the frame info is constructed. + */ + void setRootNode(PBytecodeDSLRootNode rootNode) { + this.rootNode = rootNode; + } + + @Override + public PBytecodeDSLRootNode getRootNode() { + return rootNode; + } + + @Override + public int getFirstLineNumber() { + return rootNode.getFirstLineno(); + } + + @Override + public Object getYieldFrom(Frame generatorFrame, int bci, int stackTop) { + // TODO implement + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public CodeUnit getCodeUnit() { + return rootNode.getCodeUnit(); + } + + @Override + public boolean includeInTraceback() { + return !rootNode.isInternal(); + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLGeneratorFunctionRootNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLGeneratorFunctionRootNode.java new file mode 100644 index 0000000000..1d3840e2d2 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLGeneratorFunctionRootNode.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2025, 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.bytecode_dsl; + +import com.oracle.graal.python.PythonLanguage; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.builtins.objects.function.PFunction; +import com.oracle.graal.python.builtins.objects.function.Signature; +import com.oracle.graal.python.nodes.PRootNode; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; + +public final class PBytecodeDSLGeneratorFunctionRootNode extends PRootNode { + private final PBytecodeDSLRootNode rootNode; + private final TruffleString originalName; + private final ConditionProfile isIterableCoroutine = ConditionProfile.create(); + + public PBytecodeDSLGeneratorFunctionRootNode(PythonLanguage language, FrameDescriptor frameDescriptor, PBytecodeDSLRootNode rootNode, TruffleString originalName) { + super(language, frameDescriptor); + CompilerAsserts.neverPartOfCompilation(); + this.rootNode = rootNode; + this.originalName = originalName; + } + + @Override + public Object execute(VirtualFrame frame) { + Object[] arguments = frame.getArguments(); + + // This is passed from InvokeNode node + PFunction generatorFunction = PArguments.getGeneratorFunction(arguments); + assert generatorFunction != null; + if (rootNode.getCodeUnit().isGenerator()) { + // if CO_ITERABLE_COROUTINE was explicitly set (likely by types.coroutine), we have to + // pass the information to the generator + // .gi_code.co_flags will still be wrong, but at least await will work correctly + if (isIterableCoroutine.profile((generatorFunction.getCode().getFlags() & 0x100) != 0)) { + return PFactory.createIterableCoroutine(rootNode.getLanguage(), generatorFunction.getName(), generatorFunction.getQualname(), rootNode, arguments); + } else { + return PFactory.createGenerator(rootNode.getLanguage(), generatorFunction.getName(), generatorFunction.getQualname(), rootNode, arguments); + } + } else if (rootNode.getCodeUnit().isCoroutine()) { + return PFactory.createCoroutine(rootNode.getLanguage(), generatorFunction.getName(), generatorFunction.getQualname(), rootNode, arguments); + } else if (rootNode.getCodeUnit().isAsyncGenerator()) { + /* + * TODO: Support async generators. + * + * We need to produce something instead of failing here because async generators are + * instantiated in frozen module code. + */ + return PNone.NONE; + } + throw CompilerDirectives.shouldNotReachHere("Unknown generator/coroutine type"); + } + + @Override + public String getName() { + return originalName.toJavaStringUncached(); + } + + @Override + public String toString() { + CompilerAsserts.neverPartOfCompilation(); + return ""; + } + + @Override + public Signature getSignature() { + return rootNode.getSignature(); + } + + @Override + public boolean isPythonInternal() { + return rootNode.isPythonInternal(); + } + + @Override + public SourceSection getSourceSection() { + return rootNode.getSourceSection(); + } + + @Override + protected byte[] extractCode() { + return rootNode.extractCode(); + } + + public PBytecodeDSLRootNode getBytecodeRootNode() { + return rootNode; + } +} 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 new file mode 100644 index 0000000000..4a6aa90f19 --- /dev/null +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/bytecode_dsl/PBytecodeDSLRootNode.java @@ -0,0 +1,3431 @@ +/* + * Copyright (c) 2024, 2025, 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.bytecode_dsl; + +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.AttributeError; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.GeneratorExit; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___ANNOTATIONS__; +import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AENTER__; +import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AEXIT__; +import static com.oracle.graal.python.runtime.exception.PythonErrorType.AssertionError; +import static com.oracle.graal.python.util.PythonUtils.tsLiteral; + +import java.math.BigInteger; +import java.util.Iterator; + +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.MarshalModuleBuiltins; +import com.oracle.graal.python.builtins.objects.PNone; +import com.oracle.graal.python.builtins.objects.asyncio.GetAwaitableNode; +import com.oracle.graal.python.builtins.objects.cell.PCell; +import com.oracle.graal.python.builtins.objects.code.PCode; +import com.oracle.graal.python.builtins.objects.common.EmptyStorage; +import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes; +import com.oracle.graal.python.builtins.objects.common.HashingStorage; +import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; +import com.oracle.graal.python.builtins.objects.common.SequenceNodes; +import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; +import com.oracle.graal.python.builtins.objects.dict.DictNodes; +import com.oracle.graal.python.builtins.objects.dict.PDict; +import com.oracle.graal.python.builtins.objects.exception.ChainExceptionsNode; +import com.oracle.graal.python.builtins.objects.exception.ExceptionNodes; +import com.oracle.graal.python.builtins.objects.exception.PBaseException; +import com.oracle.graal.python.builtins.objects.exception.StopIterationBuiltins; +import com.oracle.graal.python.builtins.objects.frame.PFrame; +import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.builtins.objects.function.PFunction; +import com.oracle.graal.python.builtins.objects.function.PKeyword; +import com.oracle.graal.python.builtins.objects.function.Signature; +import com.oracle.graal.python.builtins.objects.generator.CommonGeneratorBuiltins; +import com.oracle.graal.python.builtins.objects.generator.PGenerator; +import com.oracle.graal.python.builtins.objects.iterator.PDoubleSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PIntRangeIterator; +import com.oracle.graal.python.builtins.objects.iterator.PIntegerIterator; +import com.oracle.graal.python.builtins.objects.iterator.PIntegerSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PLongSequenceIterator; +import com.oracle.graal.python.builtins.objects.iterator.PObjectSequenceIterator; +import com.oracle.graal.python.builtins.objects.list.PList; +import com.oracle.graal.python.builtins.objects.set.PFrozenSet; +import com.oracle.graal.python.builtins.objects.set.PSet; +import com.oracle.graal.python.builtins.objects.set.SetNodes; +import com.oracle.graal.python.builtins.objects.tuple.PTuple; +import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; +import com.oracle.graal.python.builtins.objects.type.TpSlots; +import com.oracle.graal.python.builtins.objects.type.TpSlots.GetObjectSlotsNode; +import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback; +import com.oracle.graal.python.lib.IteratorExhausted; +import com.oracle.graal.python.lib.PyIterCheckNode; +import com.oracle.graal.python.lib.PyIterNextNode; +import com.oracle.graal.python.lib.PyNumberAddNode; +import com.oracle.graal.python.lib.PyNumberAndNode; +import com.oracle.graal.python.lib.PyNumberFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; +import com.oracle.graal.python.lib.PyNumberInPlaceAndNode; +import com.oracle.graal.python.lib.PyNumberInPlaceFloorDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceLshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceMultiplyNode; +import com.oracle.graal.python.lib.PyNumberInPlaceOrNode; +import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRemainderNode; +import com.oracle.graal.python.lib.PyNumberInPlaceRshiftNode; +import com.oracle.graal.python.lib.PyNumberInPlaceSubtractNode; +import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; +import com.oracle.graal.python.lib.PyNumberInvertNode; +import com.oracle.graal.python.lib.PyNumberLshiftNode; +import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; +import com.oracle.graal.python.lib.PyNumberMultiplyNode; +import com.oracle.graal.python.lib.PyNumberNegativeNode; +import com.oracle.graal.python.lib.PyNumberOrNode; +import com.oracle.graal.python.lib.PyNumberPositiveNode; +import com.oracle.graal.python.lib.PyNumberPowerNode; +import com.oracle.graal.python.lib.PyNumberRemainderNode; +import com.oracle.graal.python.lib.PyNumberRshiftNode; +import com.oracle.graal.python.lib.PyNumberSubtractNode; +import com.oracle.graal.python.lib.PyNumberTrueDivideNode; +import com.oracle.graal.python.lib.PyNumberXorNode; +import com.oracle.graal.python.lib.PyObjectAsciiNode; +import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; +import com.oracle.graal.python.lib.PyObjectDelItem; +import com.oracle.graal.python.lib.PyObjectFunctionStr; +import com.oracle.graal.python.lib.PyObjectGetItem; +import com.oracle.graal.python.lib.PyObjectGetIter; +import com.oracle.graal.python.lib.PyObjectGetMethod; +import com.oracle.graal.python.lib.PyObjectIsNotTrueNode; +import com.oracle.graal.python.lib.PyObjectIsTrueNode; +import com.oracle.graal.python.lib.PyObjectLookupAttr; +import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; +import com.oracle.graal.python.lib.PyObjectRichCompare.GenericRichCompare; +import com.oracle.graal.python.lib.PyObjectSetAttr; +import com.oracle.graal.python.lib.PyObjectSetAttrO; +import com.oracle.graal.python.lib.PyObjectSetItem; +import com.oracle.graal.python.lib.PyObjectSizeNode; +import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; +import com.oracle.graal.python.lib.PySequenceContainsNode; +import com.oracle.graal.python.lib.RichCmpOp; +import com.oracle.graal.python.nodes.BuiltinNames; +import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.PGuards; +import com.oracle.graal.python.nodes.PRaiseNode; +import com.oracle.graal.python.nodes.PRootNode; +import com.oracle.graal.python.nodes.WriteUnraisableNode; +import com.oracle.graal.python.nodes.argument.keywords.ConcatDictToStorageNode; +import com.oracle.graal.python.nodes.argument.keywords.ExpandKeywordStarargsNode; +import com.oracle.graal.python.nodes.argument.keywords.NonMappingException; +import com.oracle.graal.python.nodes.argument.keywords.SameDictKeyException; +import com.oracle.graal.python.nodes.attributes.GetAttributeNode.GetFixedAttributeNode; +import com.oracle.graal.python.nodes.builtins.ListNodes; +import com.oracle.graal.python.nodes.bytecode.GetSendValueNode; +import com.oracle.graal.python.nodes.bytecode.GetTPFlagsNode; +import com.oracle.graal.python.nodes.bytecode.GetYieldFromIterNode; +import com.oracle.graal.python.nodes.bytecode.ImportFromNode; +import com.oracle.graal.python.nodes.bytecode.ImportNode; +import com.oracle.graal.python.nodes.bytecode.ImportStarNode; +import com.oracle.graal.python.nodes.bytecode.PrintExprNode; +import com.oracle.graal.python.nodes.bytecode.RaiseNode; +import com.oracle.graal.python.nodes.bytecode.SetupAnnotationsNode; +import com.oracle.graal.python.nodes.call.CallNode; +import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode; +import com.oracle.graal.python.nodes.call.special.CallQuaternaryMethodNode; +import com.oracle.graal.python.nodes.call.special.CallTernaryMethodNode; +import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; +import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode; +import com.oracle.graal.python.nodes.exception.ExceptMatchNode; +import com.oracle.graal.python.nodes.frame.DeleteGlobalNode; +import com.oracle.graal.python.nodes.frame.GetFrameLocalsNode; +import com.oracle.graal.python.nodes.frame.MaterializeFrameNode; +import com.oracle.graal.python.nodes.frame.ReadFromLocalsNode; +import com.oracle.graal.python.nodes.frame.ReadGlobalOrBuiltinNode; +import com.oracle.graal.python.nodes.frame.ReadNameNode; +import com.oracle.graal.python.nodes.frame.WriteGlobalNode; +import com.oracle.graal.python.nodes.frame.WriteNameNode; +import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; +import com.oracle.graal.python.nodes.object.GetClassNode; +import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; +import com.oracle.graal.python.nodes.object.IsNode; +import com.oracle.graal.python.nodes.util.ExceptionStateNodes; +import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; +import com.oracle.graal.python.runtime.PythonContext; +import com.oracle.graal.python.runtime.PythonContext.ProfileEvent; +import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; +import com.oracle.graal.python.runtime.PythonContext.TraceEvent; +import com.oracle.graal.python.runtime.PythonOptions; +import com.oracle.graal.python.runtime.exception.ExceptionUtils; +import com.oracle.graal.python.runtime.exception.PException; +import com.oracle.graal.python.runtime.exception.PythonErrorType; +import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.graal.python.runtime.sequence.PSequence; +import com.oracle.graal.python.runtime.sequence.storage.BoolSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; +import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; +import com.oracle.graal.python.util.ArrayBuilder; +import com.oracle.graal.python.util.PythonUtils; +import com.oracle.truffle.api.Assumption; +import com.oracle.truffle.api.CompilerAsserts; +import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.BytecodeConfig; +import com.oracle.truffle.api.bytecode.BytecodeLocation; +import com.oracle.truffle.api.bytecode.BytecodeNode; +import com.oracle.truffle.api.bytecode.BytecodeRootNode; +import com.oracle.truffle.api.bytecode.ConstantOperand; +import com.oracle.truffle.api.bytecode.EpilogExceptional; +import com.oracle.truffle.api.bytecode.EpilogReturn; +import com.oracle.truffle.api.bytecode.GenerateBytecode; +import com.oracle.truffle.api.bytecode.Instruction; +import com.oracle.truffle.api.bytecode.Instrumentation; +import com.oracle.truffle.api.bytecode.LocalAccessor; +import com.oracle.truffle.api.bytecode.LocalRangeAccessor; +import com.oracle.truffle.api.bytecode.Operation; +import com.oracle.truffle.api.bytecode.OperationProxy; +import com.oracle.truffle.api.bytecode.Prolog; +import com.oracle.truffle.api.bytecode.ShortCircuitOperation; +import com.oracle.truffle.api.bytecode.ShortCircuitOperation.Operator; +import com.oracle.truffle.api.bytecode.Variadic; +import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.dsl.Cached.Exclusive; +import com.oracle.truffle.api.dsl.Cached.Shared; +import com.oracle.truffle.api.dsl.Fallback; +import com.oracle.truffle.api.dsl.Idempotent; +import com.oracle.truffle.api.dsl.ImportStatic; +import com.oracle.truffle.api.dsl.NeverDefault; +import com.oracle.truffle.api.dsl.NonIdempotent; +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.frame.Frame; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.library.CachedLibrary; +import com.oracle.truffle.api.nodes.EncapsulatingNodeReference; +import com.oracle.truffle.api.nodes.ExplodeLoop; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.UnexpectedResultException; +import com.oracle.truffle.api.object.DynamicObjectLibrary; +import com.oracle.truffle.api.profiles.InlinedBranchProfile; +import com.oracle.truffle.api.profiles.InlinedConditionProfile; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.api.strings.TruffleString; +import com.oracle.truffle.api.strings.TruffleStringBuilder; + +@GenerateBytecode(// + languageClass = PythonLanguage.class, // + enableBlockScoping = false, // + enableYield = true, // + enableSerialization = true, // + enableTagInstrumentation = true, // + boxingEliminationTypes = {int.class}, // + storeBytecodeIndexInFrame = true // +) +@OperationProxy(PyNumberSubtractNode.class) +@OperationProxy(PyNumberTrueDivideNode.class) +@OperationProxy(PyNumberFloorDivideNode.class) +@OperationProxy(PyNumberRemainderNode.class) +@OperationProxy(PyNumberLshiftNode.class) +@OperationProxy(PyNumberRshiftNode.class) +@OperationProxy(PyNumberAndNode.class) +@OperationProxy(PyNumberOrNode.class) +@OperationProxy(PyNumberXorNode.class) +@OperationProxy(PyNumberMatrixMultiplyNode.class) +@OperationProxy(PyNumberMultiplyNode.class) +@OperationProxy(PyNumberAddNode.class) +@OperationProxy(PyNumberPositiveNode.class) +@OperationProxy(PyNumberNegativeNode.class) +@OperationProxy(PyNumberInvertNode.class) +@OperationProxy(PyNumberInPlaceAddNode.class) +@OperationProxy(PyNumberInPlaceSubtractNode.class) +@OperationProxy(PyNumberInPlaceMultiplyNode.class) +@OperationProxy(PyNumberInPlaceTrueDivideNode.class) +@OperationProxy(PyNumberInPlaceFloorDivideNode.class) +@OperationProxy(PyNumberInPlaceRemainderNode.class) +@OperationProxy(PyNumberInPlaceMatrixMultiplyNode.class) +@OperationProxy(PyNumberInPlaceAndNode.class) +@OperationProxy(PyNumberInPlaceOrNode.class) +@OperationProxy(PyNumberInPlaceXorNode.class) +@OperationProxy(PyNumberInPlaceLshiftNode.class) +@OperationProxy(PyNumberInPlaceRshiftNode.class) +@OperationProxy(IsNode.class) +@OperationProxy(FormatNode.class) +@OperationProxy(ExceptMatchNode.class) +@OperationProxy(GetYieldFromIterNode.class) +@OperationProxy(GetAwaitableNode.class) +@OperationProxy(SetupAnnotationsNode.class) +@OperationProxy(value = PyObjectIsTrueNode.class, name = "Yes") +@OperationProxy(value = PyObjectIsNotTrueNode.class, name = "Not") +@OperationProxy(value = ListNodes.AppendNode.class, name = "ListAppend") +@OperationProxy(value = SetNodes.AddNode.class, name = "SetAdd") +@ShortCircuitOperation(name = "BoolAnd", booleanConverter = PyObjectIsTrueNode.class, operator = Operator.AND_RETURN_VALUE) +@ShortCircuitOperation(name = "BoolOr", booleanConverter = PyObjectIsTrueNode.class, operator = Operator.OR_RETURN_VALUE) +@ShortCircuitOperation(name = "PrimitiveBoolAnd", operator = Operator.AND_RETURN_VALUE) +@SuppressWarnings("unused") +public abstract class PBytecodeDSLRootNode extends PRootNode implements BytecodeRootNode { + public static final int EXPLODE_LOOP_THRESHOLD = 30; + private static final BytecodeConfig TRACE_AND_PROFILE_CONFIG = PBytecodeDSLRootNodeGen.newConfigBuilder().// + addInstrumentation(TraceOrProfileCall.class).// + addInstrumentation(TraceLine.class).// + addInstrumentation(TraceLineAtLoopHeader.class).// + addInstrumentation(TraceOrProfileReturn.class).// + addInstrumentation(TraceException.class).// + build(); + + @Child private transient CalleeContext calleeContext = CalleeContext.create(); + @Child private transient ExceptionStateNodes.GetCaughtExceptionNode getCaughtExceptionNode; + @Child private transient MaterializeFrameNode traceMaterializeFrameNode = null; + @Child private transient ChainExceptionsNode chainExceptionsNode; + + // These fields are effectively final, but can only be set after construction. + @CompilationFinal protected transient BytecodeDSLCodeUnit co; + @CompilationFinal protected transient Signature signature; + @CompilationFinal protected transient int selfIndex; + @CompilationFinal protected transient int classcellIndex; + + private transient boolean pythonInternal; + @CompilationFinal private transient boolean internal; + + // For deferred deprecation warnings + @CompilationFinal private transient RaisePythonExceptionErrorCallback parserErrorCallback; + + @SuppressWarnings("this-escape") + protected PBytecodeDSLRootNode(PythonLanguage language, FrameDescriptor.Builder frameDescriptorBuilder) { + super(language, frameDescriptorBuilder.info(new BytecodeDSLFrameInfo()).build()); + ((BytecodeDSLFrameInfo) getFrameDescriptor().getInfo()).setRootNode(this); + } + + public final PythonLanguage getLanguage() { + return getLanguage(PythonLanguage.class); + } + + public void setMetadata(BytecodeDSLCodeUnit co, RaisePythonExceptionErrorCallback parserErrorCallback) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + this.co = co; + this.signature = co.computeSignature(); + this.classcellIndex = co.classcellIndex; + this.selfIndex = co.selfIndex; + this.internal = getSource().isInternal(); + this.parserErrorCallback = parserErrorCallback; + } + + @Override + public final boolean isInternal() { + return internal; + } + + @Override + public final boolean isPythonInternal() { + return pythonInternal; + } + + public final void setPythonInternal(boolean pythonInternal) { + this.pythonInternal = pythonInternal; + } + + public final void triggerDeferredDeprecationWarnings() { + if (parserErrorCallback != null) { + parserErrorCallback.triggerDeprecationWarnings(); + } + } + + @Override + public String toString() { + return ""; + } + + @Prolog + public static final class EnterCalleeContext { + @Specialization + public static void doEnter(VirtualFrame frame, + @Bind PBytecodeDSLRootNode root) { + root.calleeContext.enter(frame); + + if (root.needsTraceAndProfileInstrumentation()) { + root.ensureTraceAndProfileEnabled(); + root.getThreadState().pushInstrumentationData(root); + } + } + } + + @EpilogReturn + public static final class EpilogForReturn { + @Specialization + public static Object doExit(VirtualFrame frame, Object returnValue, + @Bind PBytecodeDSLRootNode root, + @Bind Node location) { + if (root.needsTraceAndProfileInstrumentation()) { + root.getThreadState().popInstrumentationData(root); + } + + root.calleeContext.exit(frame, root, location); + return returnValue; + } + } + + @EpilogExceptional + public static final class EpilogForException { + @Specialization + public static void doExit(VirtualFrame frame, AbstractTruffleException ate, + @Bind PBytecodeDSLRootNode root, + @Bind Node location) { + if (ate instanceof PException pe) { + pe.notifyAddedTracebackFrame(!root.isInternal()); + } + + if (root.needsTraceAndProfileInstrumentation()) { + root.traceOrProfileReturn(frame, location, null); + root.getThreadState().popInstrumentationData(root); + } + + root.calleeContext.exit(frame, root, location); + } + } + + /* + * Data for tracing, profiling and instrumentation + */ + public static final class InstrumentationData { + private final InstrumentationData previous; + private final PBytecodeDSLRootNode rootNode; + private int pastLine; + + public InstrumentationData(PBytecodeDSLRootNode rootNode, InstrumentationData previous) { + this.previous = previous; + this.rootNode = rootNode; + this.pastLine = -1; + } + + public InstrumentationData getPrevious() { + return previous; + } + + public PBytecodeDSLRootNode getRootNode() { + return rootNode; + } + + int getPastLine() { + return pastLine; + } + + void setPastLine(int pastLine) { + this.pastLine = pastLine; + } + + void clearPastLine() { + this.pastLine = -1; + } + } + + @NonIdempotent + public final boolean needsTraceAndProfileInstrumentation() { + // We need instrumentation only if the assumption is invalid and the root node is visible. + return !getLanguage().noTracingOrProfilingAssumption.isValid() && !isInternal(); + } + + @NonIdempotent + public final PythonThreadState getThreadState() { + return PythonContext.get(this).getThreadState(getLanguage()); + } + + /** + * Reparses with instrumentations for settrace and setprofile enabled. + */ + public final void ensureTraceAndProfileEnabled() { + assert !isInternal(); + getRootNodes().update(TRACE_AND_PROFILE_CONFIG); + } + + private PFrame ensurePyFrame(VirtualFrame frame, Node location) { + if (traceMaterializeFrameNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + traceMaterializeFrameNode = insert(MaterializeFrameNode.create()); + } + return traceMaterializeFrameNode.execute(frame, location, true, true); + } + + private void syncLocalsBackToFrame(VirtualFrame frame, PFrame pyFrame) { + GetFrameLocalsNode.syncLocalsBackToFrame(co, this, pyFrame, frame); + } + + /** + * When tracing/profiling is enabled, we emit a lot of extra operations. Reduce compiled code + * size by putting the calls behind a boundary (the uncached invoke will eventually perform an + * indirect call anyway). + */ + @TruffleBoundary + private static Object doInvokeProfileOrTraceFunction(Object fun, PFrame pyFrame, TruffleString eventName, Object arg) { + return CallTernaryMethodNode.getUncached().execute(null, fun, pyFrame, eventName, arg == null ? PNone.NONE : arg); + } + + @InliningCutoff + private void invokeProfileFunction(VirtualFrame virtualFrame, Node location, Object profileFun, + PythonContext.PythonThreadState threadState, PythonContext.ProfileEvent event, Object arg) { + if (threadState.isProfiling()) { + return; + } + threadState.profilingStart(); + PFrame pyFrame = ensurePyFrame(virtualFrame, location); + EncapsulatingNodeReference encapsulating = EncapsulatingNodeReference.getCurrent(); + Node oldEncapsulatingNode = encapsulating.set(location); + try { + // Force locals dict sync, so that we can sync them back later + GetFrameLocalsNode.executeUncached(pyFrame); + Object result = doInvokeProfileOrTraceFunction(profileFun, pyFrame, event.name, arg); + syncLocalsBackToFrame(virtualFrame, pyFrame); + Object realResult = result == PNone.NONE ? null : result; + pyFrame.setLocalTraceFun(realResult); + } catch (Throwable e) { + threadState.setProfileFun(null, getLanguage()); + throw e; + } finally { + threadState.profilingStop(); + encapsulating.set(oldEncapsulatingNode); + } + } + + @InliningCutoff + private void invokeTraceFunction(VirtualFrame virtualFrame, Node location, Object traceFun, PythonContext.PythonThreadState threadState, + PythonContext.TraceEvent event, Object arg, int line) { + if (threadState.isTracing()) { + return; + } + assert event != PythonContext.TraceEvent.DISABLED; + threadState.tracingStart(event); + PFrame pyFrame = ensurePyFrame(virtualFrame, location); + /** + * Call events use the thread-local trace function, which returns a "local" trace function + * to use for other trace events. + */ + boolean useLocalFn = event != TraceEvent.CALL; + Object traceFn = useLocalFn ? pyFrame.getLocalTraceFun() : traceFun; + if (traceFn == null) { + threadState.tracingStop(); + return; + } + Object nonNullArg = arg == null ? PNone.NONE : arg; + + EncapsulatingNodeReference encapsulating = EncapsulatingNodeReference.getCurrent(); + Node oldEncapsulatingNode = encapsulating.set(location); + try { + /** + * The PFrame syncs to the line of the current bci. Sometimes this location is + * inaccurate and needs to be overridden (e.g., when tracing an implicit return at the + * end of a function, we need to trace the line of the last statement executed). + */ + if (line != -1) { + pyFrame.setLineLock(line); + } + + // Force locals dict sync, so that we can sync them back later + GetFrameLocalsNode.executeUncached(pyFrame); + Object result = doInvokeProfileOrTraceFunction(traceFn, pyFrame, event.pythonName, nonNullArg); + syncLocalsBackToFrame(virtualFrame, pyFrame); + // https://github.com/python/cpython/issues/104232 + if (useLocalFn) { + Object realResult = result == PNone.NONE ? traceFn : result; + pyFrame.setLocalTraceFun(realResult); + } else if (result != PNone.NONE) { + pyFrame.setLocalTraceFun(result); + } else { + pyFrame.setLocalTraceFun(null); + } + } catch (Throwable e) { + threadState.setTraceFun(null, getLanguage()); + throw e; + } finally { + if (line != -1) { + pyFrame.lineUnlock(); + } + threadState.tracingStop(); + encapsulating.set(oldEncapsulatingNode); + } + } + + private void traceOrProfileCall(VirtualFrame frame, Node location, BytecodeNode bytecode, int bci) { + PythonThreadState threadState = getThreadState(); + Object traceFun = threadState.getTraceFun(); + if (traceFun != null) { + int line = bciToLine(bci, bytecode); + invokeTraceFunction(frame, location, traceFun, threadState, TraceEvent.CALL, null, line); + } + Object profileFun = threadState.getProfileFun(); + if (profileFun != null) { + invokeProfileFunction(frame, location, profileFun, threadState, ProfileEvent.CALL, null); + } + } + + @InliningCutoff + private void traceLine(VirtualFrame frame, Node location, int line) { + PythonThreadState threadState = getThreadState(); + InstrumentationData instrumentationData = threadState.getInstrumentationData(this); + + // TODO: this should never happen by nature of how we emit TraceLine, but sometimes does. + // needs investigation. + if (line == instrumentationData.getPastLine()) { + return; + } + instrumentationData.setPastLine(line); + + PFrame pyFrame = ensurePyFrame(frame, location); + if (pyFrame.getTraceLine()) { + Object traceFun = threadState.getTraceFun(); + if (traceFun != null) { + invokeTraceFunction(frame, location, traceFun, threadState, TraceEvent.LINE, null, line); + } + } + } + + @InliningCutoff + private void traceLineAtLoopHeader(VirtualFrame frame, Node location, int line) { + PythonThreadState threadState = getThreadState(); + InstrumentationData instrumentationData = threadState.getInstrumentationData(this); + int pastLine = instrumentationData.getPastLine(); + + /** + * A loop should always be traced once, even if it is not entered. We also need to trace the + * loop header on each iteration. To accomplish this, we emit a TraceLine at the top of each + * loop (before loop initialization) and a TraceLineAtLoopHeader before the loop condition + * evaluates. To avoid tracing twice on the first iteration, we need to check our line + * against pastLine. + */ + if (line != pastLine) { + Object traceFun = threadState.getTraceFun(); + if (traceFun != null) { + invokeTraceFunction(frame, location, traceFun, threadState, TraceEvent.LINE, null, line); + } + } + /** + * If the loop is all on one line, we need to trace on each iteration (even though the line + * hasn't changed). Clear pastLine so the line comparison above succeeds. + */ + instrumentationData.clearPastLine(); + } + + private void traceOrProfileReturn(VirtualFrame frame, Node location, Object value) { + PythonThreadState threadState = getThreadState(); + Object traceFun = threadState.getTraceFun(); + if (traceFun != null) { + invokeTraceFunction(frame, location, traceFun, threadState, TraceEvent.RETURN, value, threadState.getInstrumentationData(this).getPastLine()); + } + Object profileFun = threadState.getProfileFun(); + if (profileFun != null) { + invokeProfileFunction(frame, location, profileFun, threadState, ProfileEvent.RETURN, value); + } + } + + @InliningCutoff + private PException traceException(VirtualFrame frame, BytecodeNode bytecode, int bci, PException pe) { + PException result = pe; + + PythonThreadState threadState = getThreadState(); + // We should only trace the exception if tracing is enabled. + if (threadState.getTraceFun() != null) { + PFrame pyFrame = ensurePyFrame(frame, bytecode); + // We use the local function for tracing exceptions. + if (pyFrame.getLocalTraceFun() != null) { + pe.markAsCaught(frame, this); + Object peForPython = pe.getEscapedException(); + Object peType = GetClassNode.executeUncached(peForPython); + Object traceback = ExceptionNodes.GetTracebackNode.executeUncached(peForPython); + try { + invokeTraceFunction(frame, bytecode, null, threadState, TraceEvent.EXCEPTION, + PFactory.createTuple(getLanguage(), new Object[]{peType, peForPython, traceback}), + bciToLine(bci, bytecode)); + } catch (PException newPe) { + // If the trace function raises, handle its exception instead. + result = newPe; + // Below, we get the exception for reraise in order to hide the original + // raising site that's being traced (i.e., hiding the original cause). + } + // The exception was reified already. Return a new exception that looks like this + // catch didn't happen. + result = result.getExceptionForReraise(!isInternal()); + result.setCatchLocation(bci, bytecode); + } + } + return result; + } + + @Instrumentation + public static final class TraceOrProfileCall { + @Specialization + public static void perform(VirtualFrame frame, + @Bind Node location, + @Bind PBytecodeDSLRootNode root, + @Bind BytecodeNode bytecode, + @Bind("$bytecodeIndex") int bci) { + root.traceOrProfileCall(frame, location, bytecode, bci); + } + } + + @Instrumentation + @ConstantOperand(type = int.class) + public static final class TraceLine { + @Specialization + public static void perform(VirtualFrame frame, + int line, + @Bind Node location, + @Bind PBytecodeDSLRootNode root) { + root.traceLine(frame, location, line); + } + } + + @Instrumentation + @ConstantOperand(type = int.class) + public static final class TraceLineAtLoopHeader { + @Specialization + public static void perform(VirtualFrame frame, + int line, + @Bind Node location, + @Bind PBytecodeDSLRootNode root) { + root.traceLineAtLoopHeader(frame, location, line); + } + } + + @Instrumentation + public static final class TraceOrProfileReturn { + @Specialization + public static Object perform(VirtualFrame frame, Object value, + @Bind Node location, + @Bind PBytecodeDSLRootNode root) { + root.traceOrProfileReturn(frame, location, value); + return value; + } + } + + @Instrumentation + public static final class TraceException { + @Specialization + public static void perform() { + throw new UnsupportedOperationException("trace exception not implemented"); + } + } + + @Override + public Throwable interceptInternalException(Throwable throwable, VirtualFrame frame, BytecodeNode bytecodeNode, int bci) { + PythonLanguage language = getLanguage(); + if (language.getEngineOption(PythonOptions.CatchAllExceptions) && (throwable instanceof Exception || throwable instanceof AssertionError)) { + return ExceptionUtils.wrapJavaException(throwable, this, PFactory.createBaseException(language, SystemError, ErrorMessages.M, new Object[]{throwable})); + } + PException wrapped = ExceptionUtils.wrapJavaExceptionIfApplicable(this, throwable); + return wrapped != null ? wrapped : throwable; + } + + @Override + public AbstractTruffleException interceptTruffleException(AbstractTruffleException ex, VirtualFrame frame, BytecodeNode bytecodeNode, int bci) { + if (ex instanceof PException pe) { + pe.setCatchLocation(bci, bytecodeNode); + + if (needsTraceAndProfileInstrumentation() && !getThreadState().isTracing()) { + pe = traceException(frame, bytecodeNode, bci, pe); + } + + // Fill in the __context__, if available. + if (getCaughtExceptionNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + getCaughtExceptionNode = insert(ExceptionStateNodes.GetCaughtExceptionNode.create()); + } + AbstractTruffleException context = getCaughtExceptionNode.execute(frame); + if (context instanceof PException pe2) { + if (chainExceptionsNode == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + chainExceptionsNode = insert(ChainExceptionsNode.create()); + } + chainExceptionsNode.execute(pe, pe2); + } + return pe; + } + + return ex; + } + + // TODO: ContinuationRootNodeImpl does not provide this, nor it is PRootNode, do we need to + // handle it in ReadCallerFrame#getFrame, and other places that iterate frames and/or check if a + // root node is PRootNode? + @Override + public boolean setsUpCalleeContext() { + return true; + } + + @Override + public String getName() { + if (co == null) { + // getName can be called by validation code before the code unit has been set. + return null; + } + return co.name.toJavaStringUncached(); + } + + @Override + public Signature getSignature() { + return signature; + } + + public BytecodeDSLCodeUnit getCodeUnit() { + return co; + } + + public int getFirstLineno() { + return co.startLine; + } + + protected Source getSource() { + SourceSection section = getSourceSection(); + if (section == null) { + return PythonUtils.createFakeSource(); + } + return section.getSource(); + } + + @TruffleBoundary + public int bciToLine(int bci, BytecodeNode bytecodeNode) { + return getSourceSectionForLocation(bci, bytecodeNode).getStartLine(); + } + + @TruffleBoundary + public SourceSection getSourceSectionForLocation(BytecodeLocation location) { + SourceSection sourceSection = null; + if (location != null) { + sourceSection = location.getSourceLocation(); + } + + if (sourceSection == null) { + /** + * If we don't have a source section, fall back on the root node's source section. This + * can happen, for example, when throwing into an unstarted generator, where we don't + * have an actual location (and the first line of the root node is expected). + */ + sourceSection = getSourceSection(); + } + + return sourceSection; + } + + @TruffleBoundary + public SourceSection getSourceSectionForLocation(int bci, BytecodeNode bytecodeNode) { + BytecodeLocation location = null; + if (bytecodeNode != null) { + location = bytecodeNode.getBytecodeLocation(bci); + } + return getSourceSectionForLocation(location); + } + + public static int bciToLasti(int bci, BytecodeNode bytecodeNode) { + if (bci <= 0) { + return bci; + } + int number = 0; + for (Instruction instruction : bytecodeNode.getInstructions()) { + if (instruction.isInstrumentation()) { + continue; + } + if (instruction.getBytecodeIndex() >= bci) { + return number; + } + // Emulate CPython's fixed 2-word instructions. + number += 2; + } + return -1; + } + + public static int lastiToBci(int lasti, BytecodeNode bytecodeNode) { + if (lasti < 0) { + return 0; + } + Iterator iter = bytecodeNode.getInstructions().iterator(); + assert iter.hasNext(); + + int nexti = 0; + Instruction result; + do { + result = iter.next(); + if (result.isInstrumentation()) { + continue; + } + nexti += 2; + } while (nexti <= lasti && iter.hasNext()); + return result.getBytecodeIndex(); + } + + @Override + protected byte[] extractCode() { + return MarshalModuleBuiltins.serializeCodeUnit(this, PythonContext.get(this), co); + } + + private static Object checkUnboundCell(PCell cell, int index, PBytecodeDSLRootNode rootNode, Node inliningTarget, PRaiseNode raiseNode) { + Object result = cell.getRef(); + if (result == null) { + CompilerDirectives.transferToInterpreterAndInvalidate(); + CodeUnit codeUnit = rootNode.getCodeUnit(); + if (index < codeUnit.cellvars.length) { + TruffleString localName = codeUnit.cellvars[index]; + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, localName); + } else { + TruffleString localName = codeUnit.freevars[index - codeUnit.cellvars.length]; + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.NameError, ErrorMessages.UNBOUNDFREEVAR, localName); + } + } + return result; + } + + public PCell readClassCell(Frame frame) { + if (classcellIndex < 0) { + return null; + } + return (PCell) getBytecodeNode().getLocalValue(0, frame, classcellIndex); + } + + public Object readSelf(Frame frame) { + if (selfIndex < 0) { + return null; + } else if (selfIndex == 0) { + return getBytecodeNode().getLocalValue(0, frame, 0); + } else { + PCell selfCell = (PCell) getBytecodeNode().getLocalValue(0, frame, selfIndex); + return selfCell.getRef(); + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class ArrayIndex { + @Specialization + public static Object doObject(int i, Object[] array) { + return array[i]; + } + } + + @Operation + public static final class UnwrapException { + @Specialization + public static Object doPException(PException ex) { + return ex.getEscapedException(); + } + + @Fallback + public static Object doOther(Object ex) { + // Let interop exceptions be + assert ex instanceof AbstractTruffleException; + return ex; + } + } + + /** + * Some operations take a single Object[] operand (e.g., {@link MakeTuple}). To pass a + * fixed-length sequence of elements to these operands (e.g., to instantiate a constant tuple) + * we need to first collect the values into an Object[]. + */ + @Operation + public static final class CollectToObjectArray { + @Specialization + public static Object[] perform(@Variadic Object[] values) { + return values; + } + } + + @Operation + public static final class Contains { + @Specialization + static Object contains(VirtualFrame frame, Object item, Object container, + @Bind Node inliningTarget, + @Cached PySequenceContainsNode containsNode) { + return containsNode.execute(frame, inliningTarget, container, item); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class WriteName { + @Specialization + public static void perform(VirtualFrame frame, TruffleString name, Object value, + @Cached WriteNameNode writeNode) { + writeNode.execute(frame, name, value); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class ReadName { + @Specialization + public static Object perform(VirtualFrame frame, TruffleString name, + @Cached ReadNameNode readNode) { + return readNode.execute(frame, name); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class DeleteName { + @Specialization(guards = "hasLocals(frame)") + public static void performLocals(VirtualFrame frame, TruffleString name, + @Bind Node inliningTarget, + @Cached PyObjectDelItem deleteNode) { + deleteNode.execute(frame, inliningTarget, PArguments.getSpecialArgument(frame), name); + } + + @Specialization(guards = "!hasLocals(frame)") + public static void performGlobals(VirtualFrame frame, TruffleString name, + @Cached DeleteGlobalNode deleteNode) { + deleteNode.executeWithGlobals(frame, PArguments.getGlobals(frame), name); + } + + public static boolean hasLocals(VirtualFrame frame) { + return PArguments.getSpecialArgument(frame) != null; + } + } + + @Operation + public static final class LoadVariableArguments { + @Specialization + public static Object perform(VirtualFrame frame, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createTuple(rootNode.getLanguage(), PArguments.getVariableArguments(frame)); + } + } + + @Operation + public static final class LoadKeywordArguments { + @Specialization + public static Object perform(VirtualFrame frame, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createDict(rootNode.getLanguage(), PArguments.getKeywordArguments(frame)); + } + } + + @Operation + @ConstantOperand(type = double.class) + @ConstantOperand(type = double.class) + public static final class LoadComplex { + @Specialization + public static Object perform(double real, double imag, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createComplex(rootNode.getLanguage(), real, imag); + } + } + + @Operation + @ConstantOperand(type = BigInteger.class) + public static final class LoadBigInt { + @Specialization + public static Object perform(BigInteger bigInt, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createInt(rootNode.getLanguage(), bigInt); + } + } + + @Operation + @ConstantOperand(type = byte[].class, dimensions = 0) + public static final class LoadBytes { + @Specialization + public static Object perform(byte[] bytes, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createBytes(rootNode.getLanguage(), bytes); + } + } + + @Operation + public static final class GetIter { + @Specialization + public static Object perform(VirtualFrame frame, Object receiver, + @Bind Node inliningTarget, + @Cached PyObjectGetIter getIterNode) { + return getIterNode.execute(frame, inliningTarget, receiver); + } + } + + @Operation + public static final class FormatStr { + @Specialization + public static TruffleString perform(VirtualFrame frame, Object object, + @Bind Node inliningTarget, + @Cached PyObjectStrAsTruffleStringNode asTruffleStringNode) { + return asTruffleStringNode.execute(frame, inliningTarget, object); + } + } + + @Operation + public static final class FormatRepr { + @Specialization + public static TruffleString perform(VirtualFrame frame, Object object, + @Bind Node inliningTarget, + @Cached PyObjectReprAsTruffleStringNode asTruffleStringNode) { + return asTruffleStringNode.execute(frame, inliningTarget, object); + } + } + + @Operation + public static final class FormatAscii { + @Specialization + public static TruffleString perform(VirtualFrame frame, Object object, + @Bind Node inliningTarget, + @Cached PyObjectAsciiNode asTruffleStringNode) { + return asTruffleStringNode.execute(frame, inliningTarget, object); + } + } + + @Operation + public static final class PrintExpr { + @Specialization + public static void perform(VirtualFrame frame, Object object, + @Cached PrintExprNode printExprNode) { + printExprNode.execute(frame, object); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class, name = "name") + @ConstantOperand(type = TruffleString.class, name = "qualifiedName") + @ConstantOperand(type = BytecodeDSLCodeUnit.class) + public static final class MakeFunction { + @Specialization(guards = {"isSingleContext(rootNode)", "!codeUnit.isGeneratorOrCoroutine()"}) + public static Object functionSingleContext(VirtualFrame frame, + TruffleString name, + TruffleString qualifiedName, + BytecodeDSLCodeUnit codeUnit, + Object[] defaults, + Object[] kwDefaultsObject, + Object closure, + Object annotations, + @Bind PBytecodeDSLRootNode rootNode, + @Cached(value = "createFunctionRootNode(rootNode, codeUnit)", adopt = false) PBytecodeDSLRootNode functionRootNode, + @Cached("createCode(rootNode, codeUnit, functionRootNode)") PCode cachedCode, + @Shared @CachedLibrary(limit = "1") DynamicObjectLibrary dylib) { + return createFunction(frame, name, qualifiedName, codeUnit.getDocstring(), cachedCode, defaults, kwDefaultsObject, closure, annotations, rootNode, dylib); + } + + @Specialization(replaces = "functionSingleContext", guards = "!codeUnit.isGeneratorOrCoroutine()") + public static Object functionMultiContext(VirtualFrame frame, + TruffleString name, + TruffleString qualifiedName, + BytecodeDSLCodeUnit codeUnit, + Object[] defaults, + Object[] kwDefaultsObject, + Object closure, + Object annotations, + @Bind PBytecodeDSLRootNode rootNode, + @Cached(value = "createFunctionRootNode(rootNode, codeUnit)", adopt = false) PBytecodeDSLRootNode functionRootNode, + @Shared @CachedLibrary(limit = "1") DynamicObjectLibrary dylib) { + PCode code = createCode(rootNode, codeUnit, functionRootNode); + return createFunction(frame, name, qualifiedName, codeUnit.getDocstring(), code, defaults, kwDefaultsObject, closure, annotations, rootNode, dylib); + } + + @Specialization(guards = {"isSingleContext(rootNode)", "codeUnit.isGeneratorOrCoroutine()"}) + public static Object generatorOrCoroutineSingleContext(VirtualFrame frame, + TruffleString name, + TruffleString qualifiedName, + BytecodeDSLCodeUnit codeUnit, + Object[] defaults, + Object[] kwDefaultsObject, + Object closure, + Object annotations, + @Bind PBytecodeDSLRootNode rootNode, + @Cached(value = "createFunctionRootNode(rootNode, codeUnit)", adopt = false) PBytecodeDSLRootNode functionRootNode, + @Cached(value = "createGeneratorRootNode(rootNode, functionRootNode, codeUnit)", adopt = false) PBytecodeDSLGeneratorFunctionRootNode generatorRootNode, + @Cached("createCode(rootNode, codeUnit, generatorRootNode)") PCode cachedCode, + @Shared @CachedLibrary(limit = "1") DynamicObjectLibrary dylib) { + return createFunction(frame, name, qualifiedName, codeUnit.getDocstring(), cachedCode, defaults, kwDefaultsObject, closure, annotations, rootNode, dylib); + } + + @Specialization(replaces = "generatorOrCoroutineSingleContext", guards = "codeUnit.isGeneratorOrCoroutine()") + public static Object generatorOrCoroutineMultiContext(VirtualFrame frame, + TruffleString name, + TruffleString qualifiedName, + BytecodeDSLCodeUnit codeUnit, + Object[] defaults, + Object[] kwDefaultsObject, + Object closure, + Object annotations, + @Bind PBytecodeDSLRootNode rootNode, + @Cached(value = "createFunctionRootNode(rootNode, codeUnit)", adopt = false) PBytecodeDSLRootNode functionRootNode, + @Cached(value = "createGeneratorRootNode(rootNode, functionRootNode, codeUnit)", adopt = false) PBytecodeDSLGeneratorFunctionRootNode generatorRootNode, + @Shared @CachedLibrary(limit = "1") DynamicObjectLibrary dylib) { + PCode code = createCode(rootNode, codeUnit, generatorRootNode); + return createFunction(frame, name, qualifiedName, codeUnit.getDocstring(), code, defaults, kwDefaultsObject, closure, annotations, rootNode, dylib); + } + + @Idempotent + protected static boolean isSingleContext(Node node) { + return PythonLanguage.get(node).isSingleContext(); + } + + @NeverDefault + protected static PBytecodeDSLRootNode createFunctionRootNode(PBytecodeDSLRootNode outerRootNode, BytecodeDSLCodeUnit codeUnit) { + return codeUnit.createRootNode(PythonContext.get(outerRootNode), outerRootNode.getSource()); + } + + @NeverDefault + protected static PBytecodeDSLGeneratorFunctionRootNode createGeneratorRootNode(PBytecodeDSLRootNode outerRootNode, PBytecodeDSLRootNode functionRootNode, + BytecodeDSLCodeUnit codeUnit) { + return new PBytecodeDSLGeneratorFunctionRootNode(PythonLanguage.get(outerRootNode), functionRootNode.getFrameDescriptor(), functionRootNode, codeUnit.name); + } + + @NeverDefault + protected static PCode createCode(PBytecodeDSLRootNode outerRootNode, BytecodeDSLCodeUnit codeUnit, PRootNode rootNode) { + return PFactory.createCode( + PythonLanguage.get(outerRootNode), + rootNode.getCallTarget(), + rootNode.getSignature(), + codeUnit); + } + + protected static PFunction createFunction(VirtualFrame frame, + TruffleString name, TruffleString qualifiedName, TruffleString doc, + PCode code, Object[] defaults, + Object[] kwDefaultsObject, Object closure, Object annotations, + PBytecodeDSLRootNode node, + DynamicObjectLibrary dylib) { + PKeyword[] kwDefaults = new PKeyword[kwDefaultsObject.length]; + // Note: kwDefaultsObject should be a result of operation MakeKeywords, which produces + // PKeyword[] + System.arraycopy(kwDefaultsObject, 0, kwDefaults, 0, kwDefaults.length); + PFunction function = PFactory.createFunction(PythonLanguage.get(node), name, qualifiedName, code, PArguments.getGlobals(frame), defaults, kwDefaults, (PCell[]) closure); + + if (annotations != null) { + dylib.put(function, T___ANNOTATIONS__, annotations); + } + if (doc != null) { + dylib.put(function, T___DOC__, doc); + } + + return function; + } + } + + @Operation + public static final class Pow { + @Specialization + public static Object doIt(VirtualFrame frame, Object left, Object right, + @Cached PyNumberPowerNode powNode) { + return powNode.execute(frame, left, right); + } + } + + @Operation + public static final class InPlacePow { + @Specialization + public static Object doIt(VirtualFrame frame, Object left, Object right, + @Cached PyNumberInPlacePowerNode ipowNode) { + return ipowNode.execute(frame, left, right); + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + public static final class ForIterate { + + @Specialization + public static boolean doIntegerSequence(VirtualFrame frame, LocalAccessor output, PIntegerSequenceIterator iterator, + @Bind BytecodeNode bytecode) { + return doInteger(frame, output, iterator, bytecode); + } + + @Specialization + public static boolean doIntRange(VirtualFrame frame, LocalAccessor output, PIntRangeIterator iterator, + @Bind BytecodeNode bytecode) { + return doInteger(frame, output, iterator, bytecode); + } + + private static boolean doInteger(VirtualFrame frame, LocalAccessor output, + PIntegerIterator iterator, BytecodeNode bytecode) { + if (!iterator.hasNext()) { + iterator.setExhausted(); + return false; + } + output.setInt(bytecode, frame, iterator.next()); + return true; + } + + @Specialization + public static boolean doObjectIterator(VirtualFrame frame, LocalAccessor output, PObjectSequenceIterator iterator, + @Bind BytecodeNode bytecode) { + if (!iterator.hasNext()) { + iterator.setExhausted(); + output.setObject(bytecode, frame, null); + return false; + } + Object value = iterator.next(); + output.setObject(bytecode, frame, value); + return value != null; + } + + @Specialization + public static boolean doLongIterator(VirtualFrame frame, LocalAccessor output, PLongSequenceIterator iterator, + @Bind BytecodeNode bytecode) { + if (!iterator.hasNext()) { + iterator.setExhausted(); + return false; + } + output.setLong(bytecode, frame, iterator.next()); + return true; + } + + @Specialization + public static boolean doDoubleIterator(VirtualFrame frame, LocalAccessor output, PDoubleSequenceIterator iterator, + @Bind BytecodeNode bytecode) { + if (!iterator.hasNext()) { + iterator.setExhausted(); + return false; + } + output.setDouble(bytecode, frame, iterator.next()); + return true; + } + + @Specialization + @InliningCutoff + public static boolean doIterator(VirtualFrame frame, LocalAccessor output, Object object, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached PyIterNextNode next, + @Cached IsBuiltinObjectProfile errorProfile) { + try { + Object value = next.execute(frame, inliningTarget, object); + output.setObject(bytecode, frame, value); + return true; + } catch (IteratorExhausted e) { + output.setObject(bytecode, frame, null); + return false; + } + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class GetMethod { + @Specialization + public static Object doIt(VirtualFrame frame, + TruffleString name, Object obj, + @Bind Node inliningTarget, + @Cached PyObjectGetMethod getMethod) { + return getMethod.execute(frame, inliningTarget, obj, name); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class GetAttribute { + @Specialization + @InliningCutoff + public static Object doIt(VirtualFrame frame, + TruffleString name, + Object obj, + @Cached("create(name)") GetFixedAttributeNode getAttributeNode) { + return getAttributeNode.execute(frame, obj); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class SetAttribute { + @Specialization + @InliningCutoff + public static void doIt(VirtualFrame frame, + TruffleString key, + Object value, + Object object, + @Bind Node inliningTarget, + @Cached PyObjectSetAttr setAttrNode) { + setAttrNode.execute(frame, inliningTarget, object, key, value); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class DeleteAttribute { + @Specialization + @InliningCutoff + public static void doObject(VirtualFrame frame, + TruffleString key, + Object object, + @Bind Node inliningTarget, + @Cached PyObjectSetAttrO setAttrO) { + setAttrO.execute(frame, inliningTarget, object, key, PNone.NO_VALUE); + + } + } + + @Operation + @ImportStatic(SpecialMethodSlot.class) + public static final class DeleteItem { + @Specialization + public static void doWithFrame(VirtualFrame frame, Object primary, Object index, + @Bind Node inliningTarget, + @Cached PyObjectDelItem delItemNode) { + delItemNode.execute(frame, inliningTarget, primary, index); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class ReadGlobal { + @Specialization + public static Object perform(VirtualFrame frame, TruffleString name, + @Cached ReadGlobalOrBuiltinNode readNode) { + return readNode.execute(frame, name); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class WriteGlobal { + @Specialization + public static void perform(VirtualFrame frame, TruffleString name, Object value, + @Cached WriteGlobalNode writeNode) { + writeNode.executeObject(frame, name, value); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class DeleteGlobal { + @Specialization + public static void perform(VirtualFrame frame, TruffleString name, + @Cached DeleteGlobalNode deleteNode) { + deleteNode.executeWithGlobals(frame, PArguments.getGlobals(frame), name); + } + } + + @Operation + public static final class BuildClass { + + public static final TruffleString NAME = BuiltinNames.T___BUILD_CLASS__; + + @Specialization + @InliningCutoff + public static Object perform(VirtualFrame frame, + @Cached ReadGlobalOrBuiltinNode readNode) { + return readNode.execute(frame, NAME); + } + } + + @Operation + public static final class MakeList { + @Specialization + public static PList perform(Object[] elements, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createList(rootNode.getLanguage(), elements); + } + } + + @Operation + @ImportStatic({PBytecodeDSLRootNode.class}) + public static final class MakeSet { + @Specialization(guards = {"elements.length == length", "length <= EXPLODE_LOOP_THRESHOLD"}, limit = "1") + @ExplodeLoop + public static PSet doExploded(VirtualFrame frame, Object[] elements, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node node, + @Cached(value = "elements.length") int length, + @Shared @Cached SetNodes.AddNode addNode, + @Shared @Cached HashingCollectionNodes.SetItemNode setItemNode) { + PSet set = PFactory.createSet(rootNode.getLanguage()); + for (int i = 0; i < length; i++) { + SetNodes.AddNode.add(frame, set, elements[i], addNode, setItemNode); + } + return set; + } + + @Specialization(replaces = "doExploded") + public static PSet performRegular(VirtualFrame frame, Object[] elements, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node node, + @Shared @Cached SetNodes.AddNode addNode, + @Shared @Cached HashingCollectionNodes.SetItemNode setItemNode) { + PSet set = PFactory.createSet(rootNode.getLanguage()); + for (int i = 0; i < elements.length; i++) { + SetNodes.AddNode.add(frame, set, elements[i], addNode, setItemNode); + } + return set; + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class MakeFrozenSet { + @Specialization + public static PFrozenSet perform(VirtualFrame frame, + int length, + @Variadic Object[] elements, + @Cached HashingStorageSetItem hashingStorageLibrary, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget) { + HashingStorage setStorage; + if (length <= EXPLODE_LOOP_THRESHOLD) { + setStorage = doExploded(frame, inliningTarget, elements, length, hashingStorageLibrary); + } else { + setStorage = doRegular(frame, inliningTarget, elements, length, hashingStorageLibrary); + } + return PFactory.createFrozenSet(rootNode.getLanguage(), setStorage); + } + + @ExplodeLoop + private static HashingStorage doExploded(VirtualFrame frame, Node inliningTarget, Object[] elements, int length, HashingStorageSetItem hashingStorageLibrary) { + CompilerAsserts.partialEvaluationConstant(length); + HashingStorage setStorage = EmptyStorage.INSTANCE; + for (int i = 0; i < length; ++i) { + Object o = elements[i]; + setStorage = hashingStorageLibrary.execute(frame, inliningTarget, setStorage, o, PNone.NONE); + } + return setStorage; + } + + private static HashingStorage doRegular(VirtualFrame frame, Node inliningTarget, Object[] elements, int length, HashingStorageSetItem hashingStorageLibrary) { + HashingStorage setStorage = EmptyStorage.INSTANCE; + for (int i = 0; i < length; ++i) { + Object o = elements[i]; + setStorage = hashingStorageLibrary.execute(frame, inliningTarget, setStorage, o, PNone.NONE); + } + return setStorage; + } + + } + + @Operation + public static final class MakeTuple { + @Specialization + public static Object perform(Object[] elements, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createTuple(rootNode.getLanguage(), elements); + } + } + + @Operation + @ConstantOperand(type = int[].class, dimensions = 0) + public static final class MakeConstantIntList { + @Specialization + public static PList perform(int[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new IntSequenceStorage(PythonUtils.arrayCopyOf(array, array.length)); + return PFactory.createList(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = long[].class, dimensions = 0) + public static final class MakeConstantLongList { + @Specialization + public static PList perform(long[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new LongSequenceStorage(PythonUtils.arrayCopyOf(array, array.length)); + return PFactory.createList(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = boolean[].class, dimensions = 0) + public static final class MakeConstantBooleanList { + @Specialization + public static PList perform(boolean[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new BoolSequenceStorage(PythonUtils.arrayCopyOf(array, array.length)); + return PFactory.createList(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = double[].class, dimensions = 0) + public static final class MakeConstantDoubleList { + @Specialization + public static PList perform(double[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new DoubleSequenceStorage(PythonUtils.arrayCopyOf(array, array.length)); + return PFactory.createList(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = Object[].class, dimensions = 0) + public static final class MakeConstantObjectList { + @Specialization + public static PList perform(Object[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new ObjectSequenceStorage(PythonUtils.arrayCopyOf(array, array.length)); + return PFactory.createList(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = int[].class, dimensions = 0) + public static final class MakeConstantIntTuple { + @Specialization + public static PTuple perform(int[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new IntSequenceStorage(array); + return PFactory.createTuple(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = long[].class, dimensions = 0) + public static final class MakeConstantLongTuple { + @Specialization + public static PTuple perform(long[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new LongSequenceStorage(array); + return PFactory.createTuple(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = boolean[].class, dimensions = 0) + public static final class MakeConstantBooleanTuple { + @Specialization + public static PTuple perform(boolean[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new BoolSequenceStorage(array); + return PFactory.createTuple(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = double[].class, dimensions = 0) + public static final class MakeConstantDoubleTuple { + @Specialization + public static PTuple perform(double[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new DoubleSequenceStorage(array); + return PFactory.createTuple(rootNode.getLanguage(), storage); + } + } + + @Operation + @ConstantOperand(type = Object[].class, dimensions = 0) + public static final class MakeConstantObjectTuple { + @Specialization + public static PTuple perform(Object[] array, + @Bind PBytecodeDSLRootNode rootNode) { + SequenceStorage storage = new ObjectSequenceStorage(array); + return PFactory.createTuple(rootNode.getLanguage(), storage); + } + } + + @Operation + public static final class MakeSlice { + + @Specialization + public static Object doIII(int start, int end, int step, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createIntSlice(rootNode.getLanguage(), start, end, step); + } + + @Specialization + public static Object doNIN(PNone start, int end, PNone step, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createIntSlice(rootNode.getLanguage(), 0, end, 1, true, true); + } + + @Specialization + public static Object doIIN(int start, int end, PNone step, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createIntSlice(rootNode.getLanguage(), start, end, 1, false, true); + } + + @Specialization + public static Object doNII(PNone start, int end, int step, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createIntSlice(rootNode.getLanguage(), 0, end, step, true, false); + } + + @Specialization + @InliningCutoff + public static Object doGeneric(Object start, Object end, Object step, + @Bind PBytecodeDSLRootNode rootNode) { + return PFactory.createObjectSlice(rootNode.getLanguage(), start, end, step); + } + } + + @Operation + @ConstantOperand(type = TruffleString[].class, dimensions = 0, specifyAtEnd = true) + public static final class MakeKeywords { + @Specialization + public static PKeyword[] perform(@Variadic Object[] values, TruffleString[] keys) { + if (keys.length <= EXPLODE_LOOP_THRESHOLD) { + return doExploded(keys, values); + } else { + return doRegular(keys, values); + } + } + + @ExplodeLoop + private static PKeyword[] doExploded(TruffleString[] keys, Object[] values) { + CompilerAsserts.partialEvaluationConstant(keys.length); + PKeyword[] result = new PKeyword[keys.length]; + for (int i = 0; i < keys.length; i++) { + result[i] = new PKeyword(keys[i], values[i]); + } + return result; + } + + private static PKeyword[] doRegular(TruffleString[] keys, Object[] values) { + PKeyword[] result = new PKeyword[keys.length]; + for (int i = 0; i < keys.length; i++) { + result[i] = new PKeyword(keys[i], values[i]); + } + return result; + } + } + + @Operation + public static final class MappingToKeywords { + @Specialization + public static PKeyword[] perform(Object sourceCollection, + @Bind Node inliningTarget, + @Cached ExpandKeywordStarargsNode expandKeywordStarargsNode, + @Cached PRaiseNode raise) { + return expandKeywordStarargsNode.execute(inliningTarget, sourceCollection); + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class MakeDict { + // TODO: GR-64247, split to empty dict and non-empty dict created directly from preallocated + // hashmap + // storage + @Specialization + @ExplodeLoop + public static PDict empty(VirtualFrame frame, + int entries, + @Variadic Object[] keysAndValues, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget, + @Cached HashingCollectionNodes.SetItemNode setItemNode, + @Cached DictNodes.UpdateNode updateNode) { + if (keysAndValues.length != entries * 2) { + throw CompilerDirectives.shouldNotReachHere(); + } + PDict dict = PFactory.createDict(rootNode.getLanguage()); + for (int i = 0; i < entries; i++) { + Object key = keysAndValues[i * 2]; + Object value = keysAndValues[i * 2 + 1]; + // Each entry represents either a k: v pair or a **splats. splats have no key. + if (key == PNone.NO_VALUE) { + updateNode.execute(frame, dict, value); + } else { + setItemNode.execute(frame, inliningTarget, dict, key, value); + } + } + return dict; + } + } + + @Operation + public static final class SetDictItem { + @Specialization + public static void perform(VirtualFrame frame, PDict item, Object key, Object value, + @Bind Node inliningTarget, + @Cached HashingStorageSetItem setItem) { + item.setDictStorage(setItem.execute(frame, inliningTarget, item.getDictStorage(), key, value)); + } + } + + public static final class LiteralBoolean { + @Specialization + public static boolean doBoolean(boolean value) { + return value; + } + } + + @Operation + public static final class SetItem { + @Specialization + public static void doIt(VirtualFrame frame, Object value, Object primary, Object slice, + @Bind Node inliningTarget, + @Shared @Cached PyObjectSetItem setItemNode) { + setItemNode.execute(frame, inliningTarget, primary, slice, value); + } + } + + @Operation + @ConstantOperand(type = LocalRangeAccessor.class) + @ImportStatic({PGuards.class}) + public static final class UnpackToLocals { + @Specialization(guards = "isBuiltinSequence(sequence)") + @ExplodeLoop + public static void doUnpackSequence(VirtualFrame localFrame, LocalRangeAccessor results, PSequence sequence, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, + @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Shared @Cached PRaiseNode raiseNode) { + SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, sequence); + int len = storage.length(); + + int count = results.getLength(); + CompilerAsserts.partialEvaluationConstant(count); + + if (len == count) { + for (int i = 0; i < count; i++) { + results.setObject(bytecode, localFrame, i, getItemNode.execute(inliningTarget, storage, i)); + } + } else { + if (len < count) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, len); + } else { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + } + } + } + + @Specialization + @ExplodeLoop + @InliningCutoff + public static void doUnpackIterable(VirtualFrame virtualFrame, LocalRangeAccessor results, Object collection, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached PyObjectGetIter getIter, + @Cached PyIterNextNode getNextNode, + @Cached IsBuiltinObjectProfile notIterableProfile, + @Shared @Cached PRaiseNode raiseNode) { + int count = results.getLength(); + CompilerAsserts.partialEvaluationConstant(count); + + Object iterator; + try { + iterator = getIter.execute(virtualFrame, inliningTarget, collection); + } catch (PException e) { + e.expectTypeError(inliningTarget, notIterableProfile); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + } + for (int i = 0; i < count; i++) { + try { + Object value = getNextNode.execute(virtualFrame, inliningTarget, iterator); + results.setObject(bytecode, virtualFrame, i, value); + } catch (IteratorExhausted e) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, i); + } + } + try { + Object value = getNextNode.execute(virtualFrame, inliningTarget, iterator); + } catch (IteratorExhausted e) { + return; + } + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + } + } + + @Operation + @ConstantOperand(type = int.class) + @ConstantOperand(type = LocalRangeAccessor.class) + @ImportStatic({PGuards.class}) + @SuppressWarnings("truffle-interpreted-performance") + public static final class UnpackStarredToLocals { + @Specialization(guards = "isBuiltinSequence(sequence)") + public static void doUnpackSequence(VirtualFrame localFrame, + int starIndex, + LocalRangeAccessor results, + PSequence sequence, + @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, + @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Shared @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecode, + @Bind Node inliningTarget, + @Shared @Cached PRaiseNode raiseNode) { + int resultsLength = results.getLength(); + int countBefore = starIndex; + int countAfter = resultsLength - starIndex - 1; + + SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, sequence); + int len = storage.length(); + + int starLen = len - resultsLength + 1; + if (starLen < 0) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, len); + } + + copyToLocalsFromSequence(storage, 0, 0, countBefore, results, localFrame, inliningTarget, bytecode, getItemNode); + PList starList = PFactory.createList(rootNode.getLanguage(), getItemSliceNode.execute(storage, countBefore, countBefore + starLen, 1, starLen)); + results.setObject(bytecode, localFrame, starIndex, starList); + copyToLocalsFromSequence(storage, starIndex + 1, len - countAfter, countAfter, results, localFrame, inliningTarget, bytecode, getItemNode); + } + + @Specialization + @InliningCutoff + public static void doUnpackIterable(VirtualFrame frame, + int starIndex, + LocalRangeAccessor results, + Object collection, + @Cached PyObjectGetIter getIter, + @Cached PyIterNextNode getNextNode, + @Cached IsBuiltinObjectProfile notIterableProfile, + @Cached ListNodes.ConstructListNode constructListNode, + @Shared @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Shared @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecode, + @Bind Node inliningTarget, + @Shared @Cached PRaiseNode raiseNode) { + int resultsLength = results.getLength(); + int countBefore = starIndex; + int countAfter = resultsLength - starIndex - 1; + + Object iterator; + try { + iterator = getIter.execute(frame, inliningTarget, collection); + } catch (PException e) { + e.expectTypeError(inliningTarget, notIterableProfile); + throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + } + + copyToLocalsFromIterator(frame, inliningTarget, iterator, countBefore, results, bytecode, countBefore + countAfter, getNextNode, raiseNode); + + PList starAndAfter = constructListNode.execute(frame, iterator); + SequenceStorage storage = starAndAfter.getSequenceStorage(); + int lenAfter = storage.length(); + if (lenAfter < countAfter) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, countBefore + lenAfter); + } + if (countAfter == 0) { + results.setObject(bytecode, frame, starIndex, starAndAfter); + } else { + int starLen = lenAfter - countAfter; + PList starList = PFactory.createList(rootNode.getLanguage(), getItemSliceNode.execute(storage, 0, starLen, 1, starLen)); + results.setObject(bytecode, frame, starIndex, starList); + + copyToLocalsFromSequence(storage, starIndex + 1, starLen, countAfter, results, frame, inliningTarget, bytecode, getItemNode); + } + } + + @ExplodeLoop + private static void copyToLocalsFromIterator(VirtualFrame frame, Node inliningTarget, Object iterator, int length, LocalRangeAccessor results, + BytecodeNode bytecode, int requiredLength, + PyIterNextNode getNextNode, PRaiseNode raiseNode) { + CompilerAsserts.partialEvaluationConstant(length); + for (int i = 0; i < length; i++) { + try { + Object item = getNextNode.execute(frame, inliningTarget, iterator); + results.setObject(bytecode, frame, i, item); + } catch (IteratorExhausted e) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, requiredLength, i); + } + } + } + + @ExplodeLoop + private static void copyToLocalsFromSequence(SequenceStorage storage, int runOffset, int offset, int length, LocalRangeAccessor run, + VirtualFrame localFrame, Node inliningTarget, BytecodeNode bytecode, SequenceStorageNodes.GetItemScalarNode getItemNode) { + CompilerAsserts.partialEvaluationConstant(length); + for (int i = 0; i < length; i++) { + run.setObject(bytecode, localFrame, runOffset + i, getItemNode.execute(inliningTarget, storage, offset + i)); + } + } + } + + private static RuntimeException notSupported(Object left, Object right, Node nodeForRaise, TruffleString operator) { + throw PRaiseNode.raiseStatic(nodeForRaise, PythonErrorType.TypeError, ErrorMessages.NOT_SUPPORTED_BETWEEN_INSTANCES, operator, left, right); + } + + @Operation + public static final class Le { + @Specialization + public static boolean cmp(int left, int right) { + return left <= right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left <= right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left <= right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left <= right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left <= right; + } + + @Specialization + public static boolean cmp(int left, double right) { + return left <= right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left <= right; + } + + @Specialization + @InliningCutoff + public static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_LE); + } + } + + @Operation + public static final class Lt { + @Specialization + public static boolean cmp(int left, int right) { + return left < right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left < right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left < right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left < right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left < right; + } + + @Specialization + public static boolean cmp(int left, double right) { + return left < right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left < right; + } + + @Specialization + @InliningCutoff + public static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_LT); + } + } + + @Operation + public static final class Ge { + @Specialization + public static boolean cmp(int left, int right) { + return left >= right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left >= right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left >= right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left >= right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left >= right; + } + + @Specialization + public static boolean cmp(int left, double right) { + return left >= right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left >= right; + } + + @Specialization + @InliningCutoff + public static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_GE); + } + } + + @Operation + public static final class Gt { + @Specialization + public static boolean cmp(int left, int right) { + return left > right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left > right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left > right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left > right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left > right; + } + + @Specialization + public static boolean cmp(int left, double right) { + return left > right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left > right; + } + + @Specialization + @InliningCutoff + public static final Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_GT); + } + } + + @Operation + public static final class Eq { + @Specialization + public static boolean cmp(int left, int right) { + return left == right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left == right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left == right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left == right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left == right; + } + + @Specialization + public static boolean cmp(TruffleString left, TruffleString right, + @Cached TruffleString.EqualNode equalNode) { + return equalNode.execute(left, right, PythonUtils.TS_ENCODING); + } + + @Specialization + public static boolean cmp(int left, double right) { + return left == right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left == right; + } + + @Specialization + @InliningCutoff + public static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_EQ); + } + } + + @Operation + public static final class Ne { + @Specialization + public static boolean cmp(int left, int right) { + return left != right; + } + + @Specialization + public static boolean cmp(long left, long right) { + return left != right; + } + + @Specialization + public static boolean cmp(char left, char right) { + return left != right; + } + + @Specialization + public static boolean cmp(byte left, byte right) { + return left != right; + } + + @Specialization + public static boolean cmp(double left, double right) { + return left != right; + } + + @Specialization + public static boolean cmp(TruffleString left, TruffleString right, + @Cached TruffleString.EqualNode equalNode) { + return !equalNode.execute(left, right, PythonUtils.TS_ENCODING); + } + + @Specialization + public static boolean cmp(int left, double right) { + return left != right; + } + + @Specialization + public static boolean cmp(double left, int right) { + return left != right; + } + + @Specialization + @InliningCutoff + public static Object doGeneric(VirtualFrame frame, Object left, Object right, + @Cached GenericRichCompare richCompareNode) { + return richCompareNode.execute(frame, left, right, RichCmpOp.Py_NE); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + @ConstantOperand(type = TruffleString[].class, dimensions = 0) + @ConstantOperand(type = int.class) + public static final class Import { + @Specialization + @InliningCutoff + public static Object doImport(VirtualFrame frame, TruffleString name, TruffleString[] fromList, int level, + @Cached ImportNode node) { + return node.execute(frame, name, PArguments.getGlobals(frame), fromList, level); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + public static final class ImportFrom { + @Specialization + @InliningCutoff + public static Object doImport(VirtualFrame frame, TruffleString name, Object module, + @Cached ImportFromNode node) { + return node.execute(frame, module, name); + } + } + + @Operation + @ConstantOperand(type = TruffleString.class) + @ConstantOperand(type = int.class) + public static final class ImportStar { + @Specialization + @InliningCutoff + public static void doImport(VirtualFrame frame, TruffleString name, int level, + @Cached("create(name, level)") ImportStarNode node) { + node.execute(frame, name, level); + } + + @NeverDefault + static ImportStarNode create(TruffleString name, int level) { + return ImportStarNode.create(); + } + } + + @Operation + public static final class Raise { + @Specialization + public static void perform(VirtualFrame frame, Object typeOrExceptionObject, Object cause, + @Bind PBytecodeDSLRootNode root, + @Cached RaiseNode raiseNode) { + raiseNode.execute(frame, typeOrExceptionObject, cause, !root.isInternal()); + } + } + + @Operation + public static final class Reraise { + @Specialization + public static void doPException(PException ex, + @Bind PBytecodeDSLRootNode root) { + throw ex.getExceptionForReraise(!root.isInternal()); + } + + @Specialization + public static void doAbstractTruffleException(AbstractTruffleException ex) { + throw ex; + } + } + + /** + * Throw is used internally for our try-catch-finally implementation when we need to throw an + * exception and catch it elsewhere. We don't need to do any of the work done by RaiseNode. + */ + @Operation + public static final class Throw { + @Specialization + public static void doAbstractTruffleException(AbstractTruffleException ex) { + throw ex; + } + } + + @Operation + public static final class GetCurrentException { + @Specialization + public static AbstractTruffleException doPException(VirtualFrame frame) { + return PArguments.getException(frame); + } + } + + @Operation + public static final class SetCurrentException { + @Specialization + @InliningCutoff + public static void doPException(VirtualFrame frame, AbstractTruffleException ex) { + PArguments.setException(frame, ex); + } + } + + @Operation + public static final class MarkExceptionAsCaught { + @Specialization + @InliningCutoff + public static void doPException(VirtualFrame frame, PException ex, + @Bind PBytecodeDSLRootNode rootNode) { + ex.markAsCaught(frame, rootNode); + } + + @Fallback + @InliningCutoff + public static void doNothing(@SuppressWarnings("unused") Object ex) { + } + } + + @Operation + public static final class AssertFailed { + @Specialization + public static void doAssertFailed(VirtualFrame frame, Object assertionMessage, + @Bind PBytecodeDSLRootNode rooNode) { + if (assertionMessage == PNone.NO_VALUE) { + throw PRaiseNode.raiseStatic(rooNode, AssertionError); + } else { + throw PRaiseNode.raiseStatic(rooNode, AssertionError, new Object[]{assertionMessage}); + } + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class LoadCell { + @Specialization + public static Object doLoadCell(int index, PCell cell, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget, + @Cached PRaiseNode raiseNode) { + return checkUnboundCell(cell, index, rootNode, inliningTarget, raiseNode); + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class ClassLoadCell { + @Specialization + public static Object doLoadCell(VirtualFrame frame, int index, PCell cell, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget, + @Cached ReadFromLocalsNode readLocalsNode, + @Cached PRaiseNode raiseNode) { + CodeUnit co = rootNode.getCodeUnit(); + TruffleString name = co.freevars[index - co.cellvars.length]; + Object locals = PArguments.getSpecialArgument(frame); + Object value = readLocalsNode.execute(frame, inliningTarget, locals, name); + if (value != PNone.NO_VALUE) { + return value; + } else { + return checkUnboundCell(cell, index, rootNode, inliningTarget, raiseNode); + } + } + } + + @Operation + public static final class StoreCell { + @Specialization + public static void doStoreCell(PCell cell, Object value) { + cell.setRef(value); + } + } + + @Operation + public static final class CreateCell { + @Specialization + public static PCell doCreateCell(Object value) { + PCell cell = new PCell(Assumption.create()); + cell.setRef(value); + return cell; + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class ClearCell { + @Specialization + public static void doClearCell(int index, PCell cell, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget, + @Cached PRaiseNode raiseNode) { + checkUnboundCell(cell, index, rootNode, inliningTarget, raiseNode); + cell.clearRef(); + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + public static final class ClearLocal { + @Specialization + public static void doClearLocal(VirtualFrame frame, LocalAccessor localAccessor, + @Bind BytecodeNode bytecode) { + localAccessor.setObject(bytecode, frame, null); + } + } + + @Operation + public static final class LoadClosure { + @Specialization + public static PCell[] doLoadClosure(VirtualFrame frame) { + return PArguments.getClosure(frame); + } + } + + @Operation + @ConstantOperand(type = LocalRangeAccessor.class) + public static final class StoreRange { + @Specialization + @ExplodeLoop + public static void perform(VirtualFrame frame, LocalRangeAccessor locals, Object[] values, + @Bind BytecodeNode bytecode) { + CompilerAsserts.partialEvaluationConstant(locals.getLength()); + assert values.length == locals.getLength(); + for (int i = 0; i < locals.getLength(); i++) { + locals.setObject(bytecode, frame, i, values[i]); + } + } + } + + @Operation + public static final class MakeCellArray { + @Specialization + public static PCell[] doMakeCellArray(@Variadic Object[] cells) { + return PCell.toCellArray(cells); + } + } + + /** + * Flattens an array of arrays. Used for splatting Starred expressions. + */ + @Operation + @ConstantOperand(type = int.class, specifyAtEnd = true) + public static final class Unstar { + @Specialization + public static Object[] perform(@Variadic Object[] values, + int length) { + if (length <= EXPLODE_LOOP_THRESHOLD) { + return doExploded(values, length); + } else { + return doRegular(values, length); + } + } + + @ExplodeLoop + private static Object[] doExploded(Object[] values, int length) { + CompilerAsserts.partialEvaluationConstant(length); + int totalLength = 0; + for (int i = 0; i < length; i++) { + totalLength += ((Object[]) values[i]).length; + } + Object[] result = new Object[totalLength]; + int idx = 0; + for (int i = 0; i < length; i++) { + int nl = ((Object[]) values[i]).length; + System.arraycopy(values[i], 0, result, idx, nl); + idx += nl; + } + return result; + } + + private static Object[] doRegular(Object[] values, int length) { + int totalLength = 0; + for (int i = 0; i < length; i++) { + totalLength += ((Object[]) values[i]).length; + } + Object[] result = new Object[totalLength]; + int idx = 0; + for (int i = 0; i < length; i++) { + int nl = ((Object[]) values[i]).length; + System.arraycopy(values[i], 0, result, idx, nl); + idx += nl; + } + return result; + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + public static final class KwargsMerge { + @Specialization + public static PDict doMerge(VirtualFrame frame, + LocalAccessor callee, + PDict dict, + Object toMerge, + @Bind PBytecodeDSLRootNode rootNode, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecodeNode, + @Cached ConcatDictToStorageNode concatNode, + @Cached PRaiseNode raise) { + try { + HashingStorage resultStorage = concatNode.execute(frame, dict.getDictStorage(), toMerge); + dict.setDictStorage(resultStorage); + } catch (SameDictKeyException e) { + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.S_GOT_MULTIPLE_VALUES_FOR_KEYWORD_ARG, + PyObjectFunctionStr.execute(callee.getObject(bytecodeNode, frame)), + e.getKey()); + } catch (NonMappingException e) { + throw raise.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ARG_AFTER_MUST_BE_MAPPING, PyObjectFunctionStr.execute(callee.getObject(bytecodeNode, frame)), + toMerge); + } + return dict; + } + } + + @Operation + @ImportStatic({PGuards.class}) + public static final class UnpackStarred { + public static boolean isListOrTuple(PSequence obj, Node inliningTarget, InlinedConditionProfile isListProfile) { + return isListProfile.profile(inliningTarget, PGuards.isBuiltinList(obj)) || PGuards.isBuiltinTuple(obj); + } + + @Specialization(guards = "isListOrTuple(seq, inliningTarget, isListProfile)", limit = "1") + static Object[] fromListOrTuple(PSequence seq, + @Bind Node inliningTarget, + @SuppressWarnings("unused") @Cached InlinedConditionProfile isListProfile, + @Exclusive @Cached SequenceStorageNodes.ToArrayNode toArrayNode) { + return toArrayNode.execute(inliningTarget, seq.getSequenceStorage()); + } + + @Specialization(guards = "isNoValue(none)") + static Object[] none(@SuppressWarnings("unused") PNone none) { + return PythonUtils.EMPTY_OBJECT_ARRAY; + } + + @Fallback + @InliningCutoff + public static Object[] doUnpackIterable(VirtualFrame virtualFrame, Object collection, + @Bind Node inliningTarget, + @Cached PyObjectGetIter getIter, + @Cached PyIterNextNode getNextNode, + @Cached IsBuiltinObjectProfile notIterableProfile, + @Shared @Cached PRaiseNode raiseNode) { + + Object iterator; + try { + iterator = getIter.execute(virtualFrame, inliningTarget, collection); + } catch (PException e) { + e.expectTypeError(inliningTarget, notIterableProfile); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + } + ArrayBuilder result = new ArrayBuilder<>(); + while (true) { + try { + Object item = getNextNode.execute(virtualFrame, inliningTarget, iterator); + result.add(item); + } catch (IteratorExhausted e) { + return result.toArray(new Object[0]); + } + } + } + } + + @Operation + @ConstantOperand(type = int.class) + @ImportStatic({PGuards.class}) + public static final class UnpackSequence { + @Specialization(guards = "isBuiltinSequence(sequence)") + @ExplodeLoop + public static Object[] doUnpackSequence(VirtualFrame localFrame, + int count, + PSequence sequence, + @Bind Node inliningTarget, + @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, + @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Shared @Cached PRaiseNode raiseNode) { + SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, sequence); + int len = storage.length(); + if (len == count) { + Object[] result = new Object[len]; + for (int i = 0; i < count; i++) { + result[i] = getItemNode.execute(inliningTarget, storage, i); + } + return result; + } else { + if (len < count) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, len); + } else { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + } + } + } + + @Specialization + @ExplodeLoop + @InliningCutoff + public static Object[] doUnpackIterable(VirtualFrame virtualFrame, + int count, + Object collection, + @Bind Node inliningTarget, + @Cached PyObjectGetIter getIter, + @Cached PyIterNextNode getNextNode, + @Cached IsBuiltinObjectProfile notIterableProfile, + @Shared @Cached PRaiseNode raiseNode) { + Object iterator; + try { + iterator = getIter.execute(virtualFrame, inliningTarget, collection); + } catch (PException e) { + e.expectTypeError(inliningTarget, notIterableProfile); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + } + + Object[] result = new Object[count]; + for (int i = 0; i < count; i++) { + try { + Object value = getNextNode.execute(virtualFrame, inliningTarget, iterator); + result[i] = value; + } catch (IteratorExhausted e) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK, count, i); + } + } + try { + Object value = getNextNode.execute(virtualFrame, inliningTarget, iterator); + } catch (IteratorExhausted e) { + return result; + } + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TOO_MANY_VALUES_TO_UNPACK, count); + } + } + + @Operation + @ConstantOperand(type = int.class) + @ConstantOperand(type = int.class) + @ImportStatic({PGuards.class}) + public static final class UnpackEx { + @Specialization(guards = "isBuiltinSequence(sequence)") + public static Object[] doUnpackSequence(VirtualFrame localFrame, + int countBefore, + int countAfter, + PSequence sequence, + @Bind Node inliningTarget, + @SuppressWarnings("unused") @Cached GetPythonObjectClassNode getClassNode, + @Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode, + @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, + @Exclusive @Cached PRaiseNode raiseNode) { + SequenceStorage storage = getSequenceStorageNode.execute(inliningTarget, sequence); + int len = storage.length(); + int starLen = len - countBefore - countAfter; + if (starLen < 0) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, len); + } + + Object[] result = new Object[countBefore + 1 + countAfter]; + copyItemsToArray(inliningTarget, storage, 0, result, 0, countBefore, getItemNode); + result[countBefore] = PFactory.createList(PythonLanguage.get(inliningTarget), getItemSliceNode.execute(storage, countBefore, countBefore + starLen, 1, starLen)); + copyItemsToArray(inliningTarget, storage, len - countAfter, result, countBefore + 1, countAfter, getItemNode); + return result; + } + + @Specialization + @InliningCutoff + public static Object[] doUnpackIterable(VirtualFrame virtualFrame, + int countBefore, + int countAfter, + Object collection, + @Bind Node inliningTarget, + @Cached PyObjectGetIter getIter, + @Cached PyIterNextNode getNextNode, + @Cached IsBuiltinObjectProfile notIterableProfile, + @Cached ListNodes.ConstructListNode constructListNode, + @Exclusive @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, + @Exclusive @Cached SequenceStorageNodes.GetItemSliceNode getItemSliceNode, + @Exclusive @Cached PRaiseNode raiseNode) { + Object iterator; + try { + iterator = getIter.execute(virtualFrame, inliningTarget, collection); + } catch (PException e) { + e.expectTypeError(inliningTarget, notIterableProfile); + throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CANNOT_UNPACK_NON_ITERABLE, collection); + } + + Object[] result = new Object[countBefore + 1 + countAfter]; + copyItemsToArray(virtualFrame, inliningTarget, iterator, result, 0, countBefore, countBefore + countAfter, getNextNode, raiseNode); + PList starAndAfter = constructListNode.execute(virtualFrame, iterator); + SequenceStorage storage = starAndAfter.getSequenceStorage(); + int lenAfter = storage.length(); + if (lenAfter < countAfter) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, countBefore + countAfter, countBefore + lenAfter); + } + if (countAfter == 0) { + result[countBefore] = starAndAfter; + } else { + int starLen = lenAfter - countAfter; + PList starList = PFactory.createList(PythonLanguage.get(inliningTarget), getItemSliceNode.execute(storage, 0, starLen, 1, starLen)); + result[countBefore] = starList; + copyItemsToArray(inliningTarget, storage, starLen, result, countBefore + 1, countAfter, getItemNode); + } + return result; + } + + @ExplodeLoop + private static void copyItemsToArray(VirtualFrame frame, Node inliningTarget, Object iterator, Object[] destination, int destinationOffset, int length, int totalLength, + PyIterNextNode getNextNode, PRaiseNode raiseNode) { + CompilerAsserts.partialEvaluationConstant(destinationOffset); + CompilerAsserts.partialEvaluationConstant(length); + CompilerAsserts.partialEvaluationConstant(totalLength); + for (int i = 0; i < length; i++) { + try { + Object value = getNextNode.execute(frame, inliningTarget, iterator); + destination[destinationOffset + i] = value; + } catch (IteratorExhausted e) { + throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NOT_ENOUGH_VALUES_TO_UNPACK_EX, totalLength, destinationOffset + i); + } + } + } + + @ExplodeLoop + private static void copyItemsToArray(Node inliningTarget, SequenceStorage source, int sourceOffset, Object[] destination, int destinationOffset, int length, + SequenceStorageNodes.GetItemScalarNode getItemNode) { + CompilerAsserts.partialEvaluationConstant(sourceOffset); + CompilerAsserts.partialEvaluationConstant(destinationOffset); + CompilerAsserts.partialEvaluationConstant(length); + for (int i = 0; i < length; i++) { + destination[destinationOffset + i] = getItemNode.execute(inliningTarget, source, sourceOffset + i); + } + } + } + + @Operation + public static final class CallNilaryMethod { + @Specialization + @InliningCutoff + public static Object doCall(VirtualFrame frame, Object callable, + @Cached CallNode node) { + return node.execute(frame, callable, PythonUtils.EMPTY_OBJECT_ARRAY, PKeyword.EMPTY_KEYWORDS); + } + } + + @Operation + public static final class CallUnaryMethod { + @Specialization + @InliningCutoff + public static Object doCall(VirtualFrame frame, Object callable, Object arg0, + @Cached CallUnaryMethodNode node) { + return node.executeObject(frame, callable, arg0); + } + } + + @Operation + public static final class CallBinaryMethod { + @Specialization + @InliningCutoff + public static Object doObject(VirtualFrame frame, Object callable, Object arg0, Object arg1, + @Cached CallBinaryMethodNode node) { + return node.executeObject(frame, callable, arg0, arg1); + } + } + + @Operation + public static final class CallTernaryMethod { + @Specialization + @InliningCutoff + public static Object doCall(VirtualFrame frame, Object callable, Object arg0, Object arg1, Object arg2, + @Cached CallTernaryMethodNode node) { + return node.execute(frame, callable, arg0, arg1, arg2); + } + } + + @Operation + public static final class CallQuaternaryMethod { + @Specialization + @InliningCutoff + public static Object doCall(VirtualFrame frame, Object callable, Object arg0, Object arg1, Object arg2, Object arg3, + @Cached CallQuaternaryMethodNode node) { + return node.execute(frame, callable, arg0, arg1, arg2, arg3); + } + } + + @Operation + public static final class CallVarargsMethod { + @Specialization + @InliningCutoff + public static Object doCall(VirtualFrame frame, Object callable, Object[] args, PKeyword[] keywords, + @Cached CallNode node) { + return node.execute(frame, callable, args, keywords); + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = LocalAccessor.class) + @ImportStatic({SpecialMethodSlot.class}) + public static final class ContextManagerEnter { + @Specialization + @InliningCutoff + public static void doEnter(VirtualFrame frame, + LocalAccessor exitSetter, + LocalAccessor resultSetter, + Object contextManager, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached GetClassNode getClass, + @Cached(parameters = "Enter") LookupSpecialMethodSlotNode lookupEnter, + @Cached(parameters = "Exit") LookupSpecialMethodSlotNode lookupExit, + @Cached CallUnaryMethodNode callEnter, + @Cached PRaiseNode raiseNode) { + Object type = getClass.execute(inliningTarget, contextManager); + Object enter = lookupEnter.execute(frame, type, contextManager); + if (enter == PNone.NO_VALUE) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL, type); + } + Object exit = lookupExit.execute(frame, type, contextManager); + if (exit == PNone.NO_VALUE) { + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.N_OBJECT_DOES_NOT_SUPPORT_CONTEXT_MANAGER_PROTOCOL_EXIT, type); + } + Object result = callEnter.executeObject(frame, enter, contextManager); + exitSetter.setObject(bytecode, frame, exit); + resultSetter.setObject(bytecode, frame, result); + } + } + + @Operation + public static final class ContextManagerExit { + @Specialization + public static void doRegular(VirtualFrame frame, PNone none, Object exit, Object contextManager, + @Shared @Cached CallQuaternaryMethodNode callExit) { + callExit.execute(frame, exit, contextManager, PNone.NONE, PNone.NONE, PNone.NONE); + } + + @Specialization + @InliningCutoff + public static void doExceptional(VirtualFrame frame, + Object exception, Object exit, Object contextManager, + @Bind Node inliningTarget, + @Bind PBytecodeDSLRootNode rootNode, + @Shared @Cached CallQuaternaryMethodNode callExit, + @Cached GetClassNode getClass, + @Cached ExceptionNodes.GetTracebackNode getTraceback, + @Cached PyObjectIsTrueNode isTrue) { + AbstractTruffleException savedExcState = PArguments.getException(frame); + try { + Object pythonException = exception; + if (exception instanceof PException pException) { + PArguments.setException(frame, pException); + pythonException = pException.getEscapedException(); + } + Object excType = getClass.execute(inliningTarget, pythonException); + Object excTraceback = getTraceback.execute(inliningTarget, pythonException); + Object result = callExit.execute(frame, exit, contextManager, excType, pythonException, excTraceback); + if (!isTrue.execute(frame, result)) { + if (exception instanceof PException pException) { + throw pException.getExceptionForReraise(!rootNode.isInternal()); + } else if (exception instanceof AbstractTruffleException ate) { + throw ate; + } else { + throw CompilerDirectives.shouldNotReachHere("Exception not on stack"); + } + } + } finally { + PArguments.setException(frame, savedExcState); + } + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = LocalAccessor.class) + @ImportStatic({SpecialMethodSlot.class}) + public static final class AsyncContextManagerEnter { + @Specialization + @InliningCutoff + public static void doEnter(VirtualFrame frame, + LocalAccessor exitSetter, + LocalAccessor resultSetter, + Object contextManager, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached GetClassNode getClass, + @Cached(parameters = "AEnter") LookupSpecialMethodSlotNode lookupEnter, + @Cached(parameters = "AExit") LookupSpecialMethodSlotNode lookupExit, + @Cached CallUnaryMethodNode callEnter, + @Cached PRaiseNode raiseNode) { + Object type = getClass.execute(inliningTarget, contextManager); + Object enter = lookupEnter.execute(frame, type, contextManager); + if (enter == PNone.NO_VALUE) { + throw raiseNode.raise(inliningTarget, AttributeError, new Object[]{T___AENTER__}); + } + Object exit = lookupExit.execute(frame, type, contextManager); + if (exit == PNone.NO_VALUE) { + throw raiseNode.raise(inliningTarget, AttributeError, new Object[]{T___AEXIT__}); + } + Object result = callEnter.executeObject(frame, enter, contextManager); + exitSetter.setObject(bytecode, frame, exit); + resultSetter.setObject(bytecode, frame, result); + } + } + + @Operation + public static final class AsyncContextManagerCallExit { + @Specialization + public static Object doRegular(VirtualFrame frame, + PNone none, Object exit, Object contextManager, + @Shared @Cached CallQuaternaryMethodNode callExit) { + return callExit.execute(frame, exit, contextManager, PNone.NONE, PNone.NONE, PNone.NONE); + } + + @Specialization + @InliningCutoff + public static Object doExceptional(VirtualFrame frame, + Object exception, Object exit, Object contextManager, + @Bind Node inliningTarget, + @Bind PBytecodeDSLRootNode rootNode, + @Shared @Cached CallQuaternaryMethodNode callExit, + @Cached GetClassNode getClass, + @Cached ExceptionNodes.GetTracebackNode getTraceback, + @Cached PyObjectIsTrueNode isTrue) { + AbstractTruffleException savedExcState = PArguments.getException(frame); + try { + Object pythonException = exception; + if (exception instanceof PException) { + PArguments.setException(frame, (PException) exception); + pythonException = ((PException) exception).getEscapedException(); + } + Object excType = getClass.execute(inliningTarget, pythonException); + Object excTraceback = getTraceback.execute(inliningTarget, pythonException); + return callExit.execute(frame, exit, contextManager, excType, pythonException, excTraceback); + } finally { + PArguments.setException(frame, savedExcState); + } + } + } + + @Operation + public static final class AsyncContextManagerExit { + /** + * NB: There is nothing to do after awaiting __exit__(None, None, None), so this operation + * is only emitted for the case where the context manager exits due to an exception. + */ + @Specialization + @InliningCutoff + public static void doExceptional(VirtualFrame frame, + Object exception, Object result, + @Bind Node inliningTarget, + @Bind PBytecodeDSLRootNode rootNode, + @Cached CallQuaternaryMethodNode callExit, + @Cached GetClassNode getClass, + @Cached ExceptionNodes.GetTracebackNode getTraceback, + @Cached PyObjectIsTrueNode isTrue) { + if (!isTrue.execute(frame, result)) { + if (exception instanceof PException) { + throw ((PException) exception).getExceptionForReraise(!rootNode.isInternal()); + } else if (exception instanceof AbstractTruffleException) { + throw (AbstractTruffleException) exception; + } else { + throw CompilerDirectives.shouldNotReachHere("Exception not on stack"); + } + } + } + } + + @Operation + @ConstantOperand(type = int.class) + public static final class BuildString { + @Specialization + public static Object perform( + int length, + @Variadic Object[] strings, + @Cached TruffleStringBuilder.AppendStringNode appendNode, + @Cached TruffleStringBuilder.ToStringNode toString) { + TruffleStringBuilder tsb = TruffleStringBuilder.create(PythonUtils.TS_ENCODING); + if (length <= EXPLODE_LOOP_THRESHOLD) { + doExploded(strings, length, appendNode, tsb); + } else { + doRegular(strings, length, appendNode, tsb); + } + return toString.execute(tsb); + } + + @ExplodeLoop + private static void doExploded(Object[] strings, int length, TruffleStringBuilder.AppendStringNode appendNode, TruffleStringBuilder tsb) { + CompilerAsserts.partialEvaluationConstant(length); + for (int i = 0; i < length; i++) { + appendNode.execute(tsb, (TruffleString) strings[i]); + } + } + + private static void doRegular(Object[] strings, int length, TruffleStringBuilder.AppendStringNode appendNode, TruffleStringBuilder tsb) { + for (int i = 0; i < length; i++) { + appendNode.execute(tsb, (TruffleString) strings[i]); + } + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + public static final class TeeLocal { + @Specialization + public static int doInt(VirtualFrame frame, LocalAccessor local, int value, + @Bind BytecodeNode bytecode) { + local.setInt(bytecode, frame, value); + return value; + } + + @Specialization + public static double doDouble(VirtualFrame frame, LocalAccessor local, double value, + @Bind BytecodeNode bytecode) { + local.setDouble(bytecode, frame, value); + return value; + } + + @Specialization + public static long doLong(VirtualFrame frame, LocalAccessor local, long value, + @Bind BytecodeNode bytecode) { + local.setLong(bytecode, frame, value); + return value; + } + + @Specialization(replaces = {"doInt", "doDouble", "doLong"}) + public static Object doObject(VirtualFrame frame, LocalAccessor local, Object value, + @Bind BytecodeNode bytecode) { + local.setObject(bytecode, frame, value); + return value; + } + } + + @Operation + public static final class GetLen { + @Specialization + public static int doObject(VirtualFrame frame, Object value, + @Bind Node inliningTarget, + @Cached PyObjectSizeNode sizeNode) { + return sizeNode.execute(frame, inliningTarget, value); + } + } + + @Operation + @ConstantOperand(type = long.class) + public static final class CheckTypeFlags { + @Specialization + public static boolean doObject(long typeFlags, Object value, + @Cached GetTPFlagsNode getTPFlagsNode) { + return (getTPFlagsNode.execute(value) & typeFlags) != 0; + } + } + + @Operation + @ImportStatic(PGuards.class) + public static final class BinarySubscript { + // TODO: GR-64248, the result is not BE'd because of the UnexpectedResultException. maybe we + // should explicitly check for an int storage type? + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "isBuiltinList(list)") + public static int doIntList(PList list, int index, + @Shared @Cached("createForList()") SequenceStorageNodes.GetItemNode getListItemNode) throws UnexpectedResultException { + return getListItemNode.executeInt(list.getSequenceStorage(), index); + } + + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "isBuiltinList(list)") + public static double doDoubleList(PList list, int index, + @Shared @Cached("createForList()") SequenceStorageNodes.GetItemNode getListItemNode) throws UnexpectedResultException { + return getListItemNode.executeDouble(list.getSequenceStorage(), index); + } + + @Specialization(replaces = {"doIntList", "doDoubleList"}, guards = "isBuiltinList(list)") + public static Object doObjectList(PList list, int index, + @Shared @Cached("createForList()") SequenceStorageNodes.GetItemNode getListItemNode) { + return getListItemNode.execute(list.getSequenceStorage(), index); + } + + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "isBuiltinTuple(tuple)") + public static int doIntTuple(PTuple tuple, int index, + @Shared @Cached("createForTuple()") SequenceStorageNodes.GetItemNode getTupleItemNode) throws UnexpectedResultException { + return getTupleItemNode.executeInt(tuple.getSequenceStorage(), index); + + } + + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "isBuiltinTuple(tuple)") + public static double doDoubleTuple(PTuple tuple, int index, + @Shared @Cached("createForTuple()") SequenceStorageNodes.GetItemNode getTupleItemNode) throws UnexpectedResultException { + return getTupleItemNode.executeDouble(tuple.getSequenceStorage(), index); + } + + @Specialization(replaces = {"doIntTuple", "doDoubleTuple"}, guards = "isBuiltinTuple(tuple)") + public static Object doObjectTuple(PTuple tuple, int index, + @Shared @Cached("createForTuple()") SequenceStorageNodes.GetItemNode getTupleItemNode) { + return getTupleItemNode.execute(tuple.getSequenceStorage(), index); + } + + @Fallback + public static Object doOther(VirtualFrame frame, Object receiver, Object key, + @Bind("this") Node inliningTarget, + @Cached GetObjectSlotsNode getSlotsNode, + @Cached PyObjectGetItem.PyObjectGetItemGeneric getItemNode) { + TpSlots slots = getSlotsNode.execute(inliningTarget, receiver); + return getItemNode.execute(frame, inliningTarget, receiver, slots, key); + } + } + + /** + * Performs some clean-up steps before suspending execution. + */ + @Operation + public static final class PreYield { + @Specialization + public static Object doObject(VirtualFrame frame, Object value, + @Bind Node location, + @Bind PBytecodeDSLRootNode root) { + if (root.needsTraceAndProfileInstrumentation()) { + root.traceOrProfileReturn(frame, location, value); + root.getThreadState().popInstrumentationData(root); + } + return value; + } + } + + /** + * Resumes execution after yield. + */ + @Operation + public static final class ResumeYield { + @Specialization + public static Object doObject(VirtualFrame frame, Object sendValue, + @Bind Node location, + @Bind PBytecodeDSLRootNode root, + @Bind BytecodeNode bytecode, + @Bind("$bytecodeIndex") int bci, + @Cached GetSendValueNode getSendValue) { + if (root.needsTraceAndProfileInstrumentation()) { + // We may not have reparsed the root with instrumentation yet. + root.ensureTraceAndProfileEnabled(); + root.getThreadState().pushInstrumentationData(root); + root.traceOrProfileCall(frame, location, bytecode, bci); + } + + return getSendValue.execute(sendValue); + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = LocalAccessor.class) + @SuppressWarnings("truffle-interpreted-performance") + public static final class YieldFromSend { + private static final TruffleString T_SEND = tsLiteral("send"); + + @Specialization + static boolean doGenerator(VirtualFrame virtualFrame, + LocalAccessor yieldedValue, + LocalAccessor returnedValue, + PGenerator generator, + Object arg, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached CommonGeneratorBuiltins.SendNode sendNode, + @Shared @Cached IsBuiltinObjectProfile stopIterationProfile, + @Shared @Cached StopIterationBuiltins.StopIterationValueNode getValue) { + try { + Object value = sendNode.execute(virtualFrame, generator, arg); + yieldedValue.setObject(bytecode, virtualFrame, value); + return false; + } catch (PException e) { + handleException(virtualFrame, e, inliningTarget, bytecode, stopIterationProfile, getValue, returnedValue); + return true; + } + } + + @Specialization(guards = "iterCheck.execute(inliningTarget, iter)", limit = "1") + static boolean doIterator(VirtualFrame virtualFrame, + LocalAccessor yieldedValue, + LocalAccessor returnedValue, + Object iter, + @SuppressWarnings("unused") PNone arg, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @SuppressWarnings("unused") @Cached PyIterCheckNode iterCheck, + @Cached PyIterNextNode getNextNode, + @Shared @Cached IsBuiltinObjectProfile stopIterationProfile, + @Shared @Cached StopIterationBuiltins.StopIterationValueNode getValue) { + try { + Object value = getNextNode.execute(virtualFrame, inliningTarget, iter); + yieldedValue.setObject(bytecode, virtualFrame, value); + return false; + } catch (IteratorExhausted e) { + returnedValue.setObject(bytecode, virtualFrame, PNone.NONE); + return true; + } + } + + @Fallback + static boolean doOther(VirtualFrame virtualFrame, + LocalAccessor yieldedValue, + LocalAccessor returnedValue, + Object obj, + Object arg, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Bind("$bytecodeIndex") int bci, + @Cached PyObjectCallMethodObjArgs callMethodNode, + @Shared @Cached IsBuiltinObjectProfile stopIterationProfile, + @Shared @Cached StopIterationBuiltins.StopIterationValueNode getValue) { + try { + Object value = callMethodNode.execute(virtualFrame, inliningTarget, obj, T_SEND, arg); + yieldedValue.setObject(bytecode, virtualFrame, value); + return false; + } catch (PException e) { + handleException(virtualFrame, e, inliningTarget, bytecode, stopIterationProfile, getValue, returnedValue); + return true; + } + } + + private static void handleException(VirtualFrame frame, PException e, Node inliningTarget, BytecodeNode bytecode, + IsBuiltinObjectProfile stopIterationProfile, + StopIterationBuiltins.StopIterationValueNode getValue, + LocalAccessor returnedValue) { + e.expectStopIteration(inliningTarget, stopIterationProfile); + returnedValue.setObject(bytecode, frame, getValue.execute((PBaseException) e.getUnreifiedException())); + } + + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = LocalAccessor.class) + @SuppressWarnings("truffle-interpreted-performance") + public static final class YieldFromThrow { + + private static final TruffleString T_CLOSE = tsLiteral("close"); + private static final TruffleString T_THROW = tsLiteral("throw"); + + @Specialization + static boolean doGenerator(VirtualFrame frame, + LocalAccessor yieldedValue, + LocalAccessor returnedValue, + PGenerator generator, + PException exception, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached CommonGeneratorBuiltins.ThrowNode throwNode, + @Cached CommonGeneratorBuiltins.CloseNode closeNode, + @Shared @Cached IsBuiltinObjectProfile profileExit, + @Shared @Cached IsBuiltinObjectProfile stopIterationProfile, + @Shared @Cached StopIterationBuiltins.StopIterationValueNode getValue) { + if (profileExit.profileException(inliningTarget, exception, GeneratorExit)) { + closeNode.execute(frame, generator); + throw exception; + } else { + try { + Object value = throwNode.execute(frame, generator, exception.getEscapedException(), PNone.NO_VALUE, PNone.NO_VALUE); + yieldedValue.setObject(bytecode, frame, value); + return false; + } catch (PException e) { + handleException(frame, e, inliningTarget, bytecode, stopIterationProfile, getValue, returnedValue); + return true; + } + } + } + + @Fallback + static boolean doOther(VirtualFrame frame, + LocalAccessor yieldedValue, + LocalAccessor returnedValue, + Object obj, + Object exception, + @Bind Node inliningTarget, + @Bind BytecodeNode bytecode, + @Cached PyObjectLookupAttr lookupThrow, + @Cached PyObjectLookupAttr lookupClose, + @Cached CallNode callThrow, + @Cached CallNode callClose, + @Cached WriteUnraisableNode writeUnraisableNode, + @Shared @Cached IsBuiltinObjectProfile profileExit, + @Shared @Cached IsBuiltinObjectProfile stopIterationProfile, + @Shared @Cached StopIterationBuiltins.StopIterationValueNode getValue) { + PException pException = (PException) exception; + if (profileExit.profileException(inliningTarget, pException, GeneratorExit)) { + Object close = PNone.NO_VALUE; + try { + close = lookupClose.execute(frame, inliningTarget, obj, T_CLOSE); + } catch (PException e) { + writeUnraisableNode.execute(frame, e.getEscapedException(), null, obj); + } + if (close != PNone.NO_VALUE) { + callClose.execute(frame, close); + } + throw pException; + } else { + Object throwMethod = lookupThrow.execute(frame, inliningTarget, obj, T_THROW); + if (throwMethod == PNone.NO_VALUE) { + throw pException; + } + try { + Object value = callThrow.execute(frame, throwMethod, pException.getEscapedException()); + yieldedValue.setObject(bytecode, frame, value); + return false; + } catch (PException e) { + handleException(frame, e, inliningTarget, bytecode, stopIterationProfile, getValue, returnedValue); + return true; + } + } + } + + private static void handleException(VirtualFrame frame, PException e, Node inliningTarget, BytecodeNode bytecode, + IsBuiltinObjectProfile stopIterationProfile, StopIterationBuiltins.StopIterationValueNode getValue, + LocalAccessor returnedValue) { + e.expectStopIteration(inliningTarget, stopIterationProfile); + returnedValue.setObject(bytecode, frame, getValue.execute((PBaseException) e.getUnreifiedException())); + } + } + + /** + * Loads a user-defined local variable. Unlike a built-in LoadLocal, this operation raises an + * unbound local error if the local has not been set. + *

    + * This operation makes use of Truffle's boxing overloads. When an operation tries to quicken + * this one for boxing elimination, the correct overload will be selected. + */ + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = int.class) + public static final class CheckAndLoadLocal { + @Specialization(rewriteOn = UnexpectedResultException.class) + public static int doInt(VirtualFrame frame, LocalAccessor accessor, int index, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecodeNode, + @Bind Node inliningTarget, + @Shared @Cached InlinedBranchProfile localUnboundProfile) throws UnexpectedResultException { + if (accessor.isCleared(bytecodeNode, frame)) { + localUnboundProfile.enter(inliningTarget); + throw raiseUnbound(rootNode, inliningTarget, index); + } + return accessor.getInt(bytecodeNode, frame); + } + + @Specialization(rewriteOn = UnexpectedResultException.class) + public static boolean doBoolean(VirtualFrame frame, LocalAccessor accessor, int index, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecodeNode, + @Bind Node inliningTarget, + @Shared @Cached InlinedBranchProfile localUnboundProfile) throws UnexpectedResultException { + if (accessor.isCleared(bytecodeNode, frame)) { + localUnboundProfile.enter(inliningTarget); + throw raiseUnbound(rootNode, inliningTarget, index); + } + return accessor.getBoolean(bytecodeNode, frame); + } + + @Specialization(replaces = {"doInt", "doBoolean"}) + public static Object doObject(VirtualFrame frame, LocalAccessor accessor, int index, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecodeNode, + @Bind Node inliningTarget, + @Cached InlinedBranchProfile localUnboundProfile) { + if (accessor.isCleared(bytecodeNode, frame)) { + localUnboundProfile.enter(inliningTarget); + throw raiseUnbound(rootNode, inliningTarget, index); + } + return accessor.getObject(bytecodeNode, frame); + } + } + + @Operation + @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = int.class) + public static final class DeleteLocal { + @Specialization + public static void doObject(VirtualFrame frame, LocalAccessor accessor, int index, + @Bind PBytecodeDSLRootNode rootNode, + @Bind BytecodeNode bytecodeNode, + @Bind Node inliningTarget, + @Cached InlinedBranchProfile localUnboundProfile) { + if (accessor.isCleared(bytecodeNode, frame)) { + localUnboundProfile.enter(inliningTarget); + throw raiseUnbound(rootNode, inliningTarget, index); + } + accessor.clear(bytecodeNode, frame); + } + } + + @TruffleBoundary + private static PException raiseUnbound(PBytecodeDSLRootNode rootNode, Node inliningTarget, int index) { + TruffleString localName = rootNode.getCodeUnit().varnames[index]; + throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, localName); + } + + @Operation + public static final class RaiseNotImplementedError { + @Specialization + public static void doRaise(VirtualFrame frame, TruffleString name, + @Bind Node node) { + throw PRaiseNode.raiseStatic(node, PythonBuiltinClassType.NotImplementedError, name); + + } + } +} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/InvokeNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/InvokeNode.java index 68fbf82cfe..e2c016be6a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/InvokeNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/InvokeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. * Copyright (c) 2014, Regents of the University of California * * All rights reserved. @@ -32,6 +32,7 @@ import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorFunctionRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLGeneratorFunctionRootNode; import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerAsserts; @@ -66,12 +67,16 @@ protected static RootCallTarget getCallTarget(Object callee) { protected static void optionallySetGeneratorFunction(Node inliningTarget, Object[] arguments, CallTarget callTarget, InlinedConditionProfile isGeneratorFunctionProfile, PFunction callee) { RootNode rootNode = ((RootCallTarget) callTarget).getRootNode(); - if (isGeneratorFunctionProfile.profile(inliningTarget, rootNode instanceof PBytecodeGeneratorFunctionRootNode)) { + if (isGeneratorFunctionProfile.profile(inliningTarget, isGeneratorFunction(rootNode))) { assert callee != null : "generator function callee not passed to invoke node"; PArguments.setGeneratorFunction(arguments, callee); } } + private static boolean isGeneratorFunction(RootNode rootNode) { + return rootNode instanceof PBytecodeGeneratorFunctionRootNode || rootNode instanceof PBytecodeDSLGeneratorFunctionRootNode; + } + protected static boolean isBuiltin(Object callee) { return callee instanceof PBuiltinFunction || callee instanceof PBuiltinMethod; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java index 3c71e78374..84e845f7bf 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/ExceptMatchNode.java @@ -51,6 +51,7 @@ import com.oracle.graal.python.runtime.exception.PythonErrorType; import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; import com.oracle.truffle.api.CompilerDirectives; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -68,6 +69,7 @@ @ImportStatic(PGuards.class) @GenerateUncached +@OperationProxy.Proxyable @SuppressWarnings("truffle-inlining") // footprint reduction 44 -> 25 public abstract class ExceptMatchNode extends Node { public abstract boolean executeMatch(Frame frame, Object exception, Object clause); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java index 75e1129b3c..27cded0b2a 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/GetFrameLocalsNode.java @@ -49,8 +49,13 @@ import com.oracle.graal.python.builtins.objects.frame.PFrame; import com.oracle.graal.python.compiler.CodeUnit; import com.oracle.graal.python.lib.PyDictGetItem; +import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.bytecode.FrameInfo; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLFrameInfo; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -124,10 +129,19 @@ void doCachedFd(MaterializedFrame locals, PDict dict, @Bind("info.getVariableCount()") int count, @Shared("setItem") @Cached HashingStorageSetItem setItem, @Shared("delItem") @Cached HashingStorageDelItem delItem) { - CodeUnit co = info.getRootNode().getCodeUnit(); - int regularVarCount = co.varnames.length; - for (int i = 0; i < count; i++) { - copyItem(inliningTarget, locals, info, dict, setItem, delItem, i, i >= regularVarCount); + int regularVarCount = info.getRegularVariableCount(); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo) info; + PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode(); + Object[] localsArray = rootNode.getBytecodeNode().getLocalValues(0, locals); + for (int i = 0; i < count; i++) { + copyItem(inliningTarget, localsArray[i], info, dict, setItem, delItem, i, i >= regularVarCount); + } + } else { + for (int i = 0; i < count; i++) { + copyItem(inliningTarget, locals.getValue(i), info, dict, setItem, delItem, i, i >= regularVarCount); + } } } @@ -138,16 +152,25 @@ void doGeneric(MaterializedFrame locals, PDict dict, @Shared("delItem") @Cached HashingStorageDelItem delItem) { FrameInfo info = getInfo(locals.getFrameDescriptor()); int count = info.getVariableCount(); - CodeUnit co = info.getRootNode().getCodeUnit(); - int regularVarCount = co.varnames.length; - for (int i = 0; i < count; i++) { - copyItem(inliningTarget, locals, info, dict, setItem, delItem, i, i >= regularVarCount); + int regularVarCount = info.getRegularVariableCount(); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeDSLFrameInfo bytecodeDSLFrameInfo = (BytecodeDSLFrameInfo) info; + PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode(); + Object[] localsArray = rootNode.getBytecodeNode().getLocalValues(0, locals); + for (int i = 0; i < count; i++) { + copyItem(inliningTarget, localsArray[i], info, dict, setItem, delItem, i, i >= regularVarCount); + } + } else { + for (int i = 0; i < count; i++) { + copyItem(inliningTarget, locals.getValue(i), info, dict, setItem, delItem, i, i >= regularVarCount); + } } } - private static void copyItem(Node inliningTarget, MaterializedFrame locals, FrameInfo info, PDict dict, HashingStorageSetItem setItem, HashingStorageDelItem delItem, int i, boolean deref) { + private static void copyItem(Node inliningTarget, Object localValue, FrameInfo info, PDict dict, HashingStorageSetItem setItem, HashingStorageDelItem delItem, int i, boolean deref) { TruffleString name = info.getVariableName(i); - Object value = locals.getValue(i); + Object value = localValue; if (deref && value != null) { value = ((PCell) value).getRef(); } @@ -168,24 +191,39 @@ protected static FrameInfo getInfo(FrameDescriptor fd) { /** * Equivalent of CPython's {@code PyFrame_LocalsToFast} */ - public static void syncLocalsBackToFrame(CodeUnit co, PFrame pyFrame, Frame localFrame) { + public static void syncLocalsBackToFrame(CodeUnit co, PRootNode root, PFrame pyFrame, Frame localFrame) { if (!pyFrame.hasCustomLocals()) { PDict localsDict = (PDict) pyFrame.getLocalsDict(); - copyLocalsArray(localFrame, localsDict, co.varnames, 0, false); - copyLocalsArray(localFrame, localsDict, co.cellvars, co.varnames.length, true); - copyLocalsArray(localFrame, localsDict, co.freevars, co.varnames.length + co.cellvars.length, true); + copyLocalsArray(localFrame, root, localsDict, co.varnames, 0, false); + copyLocalsArray(localFrame, root, localsDict, co.cellvars, co.varnames.length, true); + copyLocalsArray(localFrame, root, localsDict, co.freevars, co.varnames.length + co.cellvars.length, true); } } - private static void copyLocalsArray(Frame localFrame, PDict localsDict, TruffleString[] namesArray, int offset, boolean deref) { - for (int i = 0; i < namesArray.length; i++) { - TruffleString varname = namesArray[i]; - Object value = PyDictGetItem.executeUncached(localsDict, varname); - if (deref) { - PCell cell = (PCell) localFrame.getObject(offset + i); - cell.setRef(value); - } else { - localFrame.setObject(offset + i, value); + private static void copyLocalsArray(Frame localFrame, PRootNode root, PDict localsDict, TruffleString[] namesArray, int offset, boolean deref) { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + PBytecodeDSLRootNode bytecodeDSLRootNode = (PBytecodeDSLRootNode) root; + BytecodeNode bytecodeNode = bytecodeDSLRootNode.getBytecodeNode(); + for (int i = 0; i < namesArray.length; i++) { + TruffleString varname = namesArray[i]; + Object value = PyDictGetItem.executeUncached(localsDict, varname); + if (deref) { + PCell cell = (PCell) bytecodeNode.getLocalValue(0, localFrame, offset + i); + cell.setRef(value); + } else { + bytecodeNode.setLocalValue(0, localFrame, offset + i, value); + } + } + } else { + for (int i = 0; i < namesArray.length; i++) { + TruffleString varname = namesArray[i]; + Object value = PyDictGetItem.executeUncached(localsDict, varname); + if (deref) { + PCell cell = (PCell) localFrame.getObject(offset + i); + cell.setRef(value); + } else { + localFrame.setObject(offset + i, value); + } } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java index 4fb26a1501..396ecf6644 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java @@ -43,10 +43,15 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.frame.PFrame; import com.oracle.graal.python.builtins.objects.function.PArguments; +import com.oracle.graal.python.nodes.bytecode.BytecodeFrameInfo; import com.oracle.graal.python.nodes.bytecode.FrameInfo; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLFrameInfo; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.graal.python.util.PythonUtils; import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Shared; @@ -112,7 +117,7 @@ static PFrame freshPFrameCachedFD(Node location, boolean markAsEscaped, boolean @Shared("syncValuesNode") @Cached SyncFrameValuesNode syncValuesNode) { MaterializedFrame locals = createLocalsFrame(cachedFD); PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); - return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, syncValuesNode); + return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, location, syncValuesNode); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "!hasGeneratorFrame(frameToMaterialize)", "!hasCustomLocals(frameToMaterialize)"}, replaces = "freshPFrameCachedFD") @@ -121,7 +126,7 @@ static PFrame freshPFrame(Node location, boolean markAsEscaped, boolean forceSyn @Shared("syncValuesNode") @Cached SyncFrameValuesNode syncValuesNode) { MaterializedFrame locals = createLocalsFrame(frameToMaterialize.getFrameDescriptor()); PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, locals); - return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, syncValuesNode); + return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, forceSync, location, syncValuesNode); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "!hasGeneratorFrame(frameToMaterialize)", "hasCustomLocals(frameToMaterialize)"}) @@ -130,7 +135,7 @@ static PFrame freshPFrameCusstomLocals(Node location, boolean markAsEscaped, @Su @Bind PythonLanguage language) { PFrame escapedFrame = PFactory.createPFrame(language, PArguments.getCurrentFrameInfo(frameToMaterialize), location, null); escapedFrame.setLocalsDict(PArguments.getSpecialArgument(frameToMaterialize)); - return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, null); + return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, location, null); } @Specialization(guards = {"getPFrame(frameToMaterialize) == null", "hasGeneratorFrame(frameToMaterialize)"}) @@ -139,7 +144,7 @@ static PFrame freshPFrameForGenerator(Node location, @SuppressWarnings("unused") PFrame.Reference frameRef = PArguments.getCurrentFrameInfo(frameToMaterialize); PFrame escapedFrame = materializeGeneratorFrame(location, generatorFrame, frameRef); frameRef.setPyFrame(escapedFrame); - return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, null); + return doEscapeFrame(frameToMaterialize, escapedFrame, markAsEscaped, false, location, null); } @Specialization(guards = "getPFrame(frameToMaterialize) != null") @@ -154,7 +159,7 @@ static PFrame alreadyEscapedFrame(@SuppressWarnings("unused") Node location, boo if (markAsEscaped) { pyFrame.getRef().markAsEscaped(); } - processBytecodeFrame(frameToMaterialize, pyFrame); + processBytecodeFrame(frameToMaterialize, pyFrame, location); return pyFrame; } @@ -168,16 +173,34 @@ public static PFrame materializeGeneratorFrame(Node location, MaterializedFrame return escapedFrame; } - private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFrame) { - FrameInfo info = (FrameInfo) frameToMaterialize.getFrameDescriptor().getInfo(); - if (info != null) { - pyFrame.setBci(info.getBci(frameToMaterialize)); - pyFrame.setLocation(info.getRootNode()); + private static void processBytecodeFrame(Frame frameToMaterialize, PFrame pyFrame, Node location) { + Object info = frameToMaterialize.getFrameDescriptor().getInfo(); + if (info == null) { + return; + } + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeNode bytecodeNode = BytecodeNode.get(location); + if (bytecodeNode == null) { + /** + * Sometimes we don't have a precise location (see + * {@link ReadCallerFrameNode#getFrame}). Set bci to -1 to mark the location as + * unknown. + */ + pyFrame.setBci(-1); + pyFrame.setLocation(location); + } else { + pyFrame.setBci(bytecodeNode.getBytecodeIndex(frameToMaterialize)); + pyFrame.setLocation(bytecodeNode); + } + } else { + BytecodeFrameInfo bytecodeFrameInfo = (BytecodeFrameInfo) info; + pyFrame.setBci(bytecodeFrameInfo.getBci(frameToMaterialize)); + pyFrame.setLocation(bytecodeFrameInfo.getRootNode()); } } private static PFrame doEscapeFrame(Frame frameToMaterialize, PFrame escapedFrame, boolean markAsEscaped, boolean forceSync, - SyncFrameValuesNode syncValuesNode) { + Node location, SyncFrameValuesNode syncValuesNode) { PFrame.Reference topFrameRef = PArguments.getCurrentFrameInfo(frameToMaterialize); topFrameRef.setPyFrame(escapedFrame); @@ -189,12 +212,13 @@ private static PFrame doEscapeFrame(Frame frameToMaterialize, PFrame escapedFram if (markAsEscaped) { topFrameRef.markAsEscaped(); } - processBytecodeFrame(frameToMaterialize, escapedFrame); + processBytecodeFrame(frameToMaterialize, escapedFrame, location); return escapedFrame; } protected static boolean hasGeneratorFrame(Frame frame) { - return PArguments.getGeneratorFrame(frame) != null; + return !PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER && + PArguments.getGeneratorFrame(frame) != null; } protected static boolean hasCustomLocals(Frame frame) { @@ -216,7 +240,8 @@ public abstract static class SyncFrameValuesNode extends Node { public abstract void execute(PFrame pyFrame, Frame frameToSync); - @Specialization(guards = {"!pyFrame.hasCustomLocals()", "frameToSync.getFrameDescriptor() == cachedFd", + @Specialization(guards = {"!pyFrame.hasCustomLocals()", + "frameToSync.getFrameDescriptor() == cachedFd", "variableSlotCount(cachedFd) < 32"}, limit = "1") @ExplodeLoop static void doSyncExploded(PFrame pyFrame, Frame frameToSync, @@ -224,17 +249,37 @@ static void doSyncExploded(PFrame pyFrame, Frame frameToSync, MaterializedFrame target = pyFrame.getLocals(); assert cachedFd == target.getFrameDescriptor(); int slotCount = variableSlotCount(cachedFd); - for (int slot = 0; slot < slotCount; slot++) { - PythonUtils.copyFrameSlot(frameToSync, target, slot); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + FrameInfo info = (FrameInfo) cachedFd.getInfo(); + if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) { + PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode(); + rootNode.getBytecodeNode().copyLocalValues(0, frameToSync, target, 0, slotCount); + } + } else { + for (int i = 0; i < slotCount; i++) { + PythonUtils.copyFrameSlot(frameToSync, target, i); + } } } @Specialization(guards = "!pyFrame.hasCustomLocals()", replaces = "doSyncExploded") - static void doSyncLoop(PFrame pyFrame, Frame frameToSync) { + @ExplodeLoop + static void doSync(PFrame pyFrame, Frame frameToSync) { MaterializedFrame target = pyFrame.getLocals(); - int slotCount = variableSlotCount(frameToSync.getFrameDescriptor()); - for (int slot = 0; slot < slotCount; slot++) { - PythonUtils.copyFrameSlot(frameToSync, target, slot); + FrameDescriptor fd = target.getFrameDescriptor(); + int slotCount = variableSlotCount(fd); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + FrameInfo info = (FrameInfo) fd.getInfo(); + if (info instanceof BytecodeDSLFrameInfo bytecodeDSLFrameInfo) { + PBytecodeDSLRootNode rootNode = bytecodeDSLFrameInfo.getRootNode(); + rootNode.getBytecodeNode().copyLocalValues(0, frameToSync, target, 0, slotCount); + } + } else { + for (int i = 0; i < slotCount; i++) { + PythonUtils.copyFrameSlot(frameToSync, target, i); + } } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadCallerFrameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadCallerFrameNode.java index cb377ffbd2..a70e54a0e2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadCallerFrameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadCallerFrameNode.java @@ -53,6 +53,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.bytecode.ContinuationRootNode; import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameInstance; @@ -308,14 +309,13 @@ private static Frame getFrame(Node requestingNode, PFrame.Reference startFrame, * */ public Frame visitFrame(FrameInstance frameInstance) { - RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); - RootNode rootNode = target.getRootNode(); + RootNode rootNode = getRootNode(frameInstance); Node callNode = frameInstance.getCallNode(); boolean didMark = IndirectCallData.setEncapsulatingNeedsToPassCallerFrame(callNode != null ? callNode : requestingNode); if (outputFrame[0] == null && rootNode instanceof PRootNode pRootNode && pRootNode.setsUpCalleeContext()) { pRootNode.setNeedsCallerFrame(); if (i < 0 && startFrame != null) { - Frame roFrame = frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY); + Frame roFrame = getFrame(frameInstance, FrameInstance.FrameAccess.READ_ONLY); if (PArguments.getCurrentFrameInfo(roFrame) == startFrame) { i = 0; } @@ -324,7 +324,7 @@ public Frame visitFrame(FrameInstance frameInstance) { // a Python frame in CPython. if (!selector.skip(pRootNode)) { if (i == level || startFrame == null) { - Frame frame = frameInstance.getFrame(frameAccess); + Frame frame = getFrame(frameInstance, frameAccess); assert PArguments.isPythonFrame(frame); PFrame.Reference info = PArguments.getCurrentFrameInfo(frame); // avoid overriding the location if we don't know it @@ -355,6 +355,25 @@ public Frame visitFrame(FrameInstance frameInstance) { return outputFrame[0]; } + private static RootNode getRootNode(FrameInstance frameInstance) { + RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); + RootNode rootNode = target.getRootNode(); + if (rootNode instanceof ContinuationRootNode continuationRoot) { + return (RootNode) continuationRoot.getSourceRootNode(); + } + return rootNode; + } + + private static Frame getFrame(FrameInstance frameInstance, FrameInstance.FrameAccess frameAccess) { + Frame frame = frameInstance.getFrame(frameAccess); + + RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); + if (target.getRootNode() instanceof ContinuationRootNode) { + return (Frame) frame.getArguments()[0]; + } + return frame; + } + private MaterializeFrameNode ensureMaterializeNode() { if (materializeNode == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadNameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadNameNode.java index 2914a0f998..2ca8e9aba3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadNameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadNameNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -53,6 +53,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; import com.oracle.truffle.api.dsl.GenerateUncached; +import com.oracle.truffle.api.dsl.NeverDefault; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; @@ -68,6 +69,7 @@ public final Object execute(VirtualFrame frame, TruffleString attributeId) { public abstract Object executeImpl(VirtualFrame frame, TruffleString attributeId); + @NeverDefault public static ReadNameNode create() { return ReadNameNodeGen.create(); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteGlobalNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteGlobalNode.java index ade2eadf09..59694b6a9d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteGlobalNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteGlobalNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteNameNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteNameNode.java index cadc06ea8e..d4d6641546 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteNameNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/WriteNameNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java index 9474f4a8d9..80ed581381 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsNode.java @@ -54,6 +54,8 @@ import com.oracle.graal.python.nodes.PGuards; import com.oracle.graal.python.nodes.bytecode.PBytecodeGeneratorFunctionRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLGeneratorFunctionRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.expression.BinaryOp; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsAnyBuiltinObjectProfile; import com.oracle.graal.python.runtime.PythonContext; @@ -61,6 +63,7 @@ import com.oracle.graal.python.util.OverflowException; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -79,6 +82,7 @@ @ImportStatic(PythonOptions.class) @GenerateUncached +@OperationProxy.Proxyable @SuppressWarnings("truffle-inlining") // footprint reduction 44 -> 26 public abstract class IsNode extends Node implements BinaryOp { @@ -234,14 +238,28 @@ public static boolean doCode(PCode left, PCode right, if (leftCt != null && rightCt != null) { RootNode leftRootNode = leftCt.getRootNode(); RootNode rightRootNode = rightCt.getRootNode(); - if (leftRootNode instanceof PBytecodeGeneratorFunctionRootNode) { - leftRootNode = ((PBytecodeGeneratorFunctionRootNode) leftRootNode).getBytecodeRootNode(); - } - if (rightRootNode instanceof PBytecodeGeneratorFunctionRootNode) { - rightRootNode = ((PBytecodeGeneratorFunctionRootNode) rightRootNode).getBytecodeRootNode(); - } - if (leftRootNode instanceof PBytecodeRootNode && rightRootNode instanceof PBytecodeRootNode) { - return ((PBytecodeRootNode) leftRootNode).getCodeUnit() == ((PBytecodeRootNode) rightRootNode).getCodeUnit(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + if (leftRootNode instanceof PBytecodeDSLGeneratorFunctionRootNode l) { + leftRootNode = l.getBytecodeRootNode(); + } + if (rightRootNode instanceof PBytecodeDSLGeneratorFunctionRootNode r) { + rightRootNode = r.getBytecodeRootNode(); + } + + if (leftRootNode instanceof PBytecodeDSLRootNode l && rightRootNode instanceof PBytecodeDSLRootNode r) { + return l.getCodeUnit() == r.getCodeUnit(); + } + } else { + if (leftRootNode instanceof PBytecodeGeneratorFunctionRootNode l) { + leftRootNode = l.getBytecodeRootNode(); + } + if (rightRootNode instanceof PBytecodeGeneratorFunctionRootNode r) { + rightRootNode = r.getBytecodeRootNode(); + } + + if (leftRootNode instanceof PBytecodeRootNode l && rightRootNode instanceof PBytecodeRootNode r) { + return l.getCodeUnit() == r.getCodeUnit(); + } } return leftRootNode == rightRootNode; } else { @@ -251,7 +269,7 @@ public static boolean doCode(PCode left, PCode right, return true; } - static boolean someIsNone(Object left, Object right) { + public static boolean someIsNone(Object left, Object right) { return PGuards.isPNone(left) || PGuards.isPNone(right); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java index 2eb06dd69d..73b5e047d3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java @@ -60,6 +60,7 @@ import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.ValueType; import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; +import com.oracle.truffle.api.bytecode.ContinuationRootNode; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; @@ -73,8 +74,10 @@ import com.oracle.truffle.api.exception.AbstractTruffleException; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameInstance; +import com.oracle.truffle.api.frame.MaterializedFrame; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.profiles.InlinedConditionProfile; import com.oracle.truffle.api.profiles.InlinedCountingConditionProfile; @@ -93,17 +96,45 @@ public static CallContext create() { * Prepare an indirect call from a Python frame to a Python function. */ public void prepareIndirectCall(VirtualFrame frame, Object[] callArguments, Node callNode) { - executePrepareCall(frame, callArguments, callNode, true, true); + executePrepareCall(frame, getActualCallArguments(callArguments), callNode, true, true); + } + + private static Object[] getActualCallArguments(Object[] callArguments) { + /** + * Bytecode DSL note: When resuming a generator/coroutine, the call target is a + * ContinuationRoot with a different calling convention from regular PRootNodes. The + * first argument is a materialized frame containing the arguments used for argument + * reads. + */ + if (callArguments.length == 2 && callArguments[0] instanceof MaterializedFrame materialized) { + return materialized.getArguments(); + } + return callArguments; } /** * Prepare a call from a Python frame to a Python function. */ public void prepareCall(VirtualFrame frame, Object[] callArguments, RootCallTarget callTarget, Node callNode) { - // n.b.: The class cast should always be correct, since this context - // must only be used when calling from Python to Python - PRootNode calleeRootNode = (PRootNode) callTarget.getRootNode(); - executePrepareCall(frame, callArguments, callNode, calleeRootNode.needsCallerFrame(), calleeRootNode.needsExceptionState()); + RootNode rootNode = callTarget.getRootNode(); + + PRootNode calleeRootNode; + Object[] actualCallArguments; + boolean needsExceptionState; + if (rootNode instanceof ContinuationRootNode continuationRoot) { + calleeRootNode = (PRootNode) continuationRoot.getSourceRootNode(); + assert callArguments.length == 2; + actualCallArguments = ((MaterializedFrame) callArguments[0]).getArguments(); + // Local exception state takes precedence over any exception in the caller's context + needsExceptionState = calleeRootNode.needsExceptionState() && !PArguments.hasException(actualCallArguments); + } else { + // n.b.: The class cast should always be correct, since this context + // must only be used when calling from Python to Python + calleeRootNode = (PRootNode) rootNode; + actualCallArguments = callArguments; + needsExceptionState = calleeRootNode.needsExceptionState(); + } + executePrepareCall(frame, actualCallArguments, callNode, calleeRootNode.needsCallerFrame(), needsExceptionState); } protected abstract void executePrepareCall(VirtualFrame frame, Object[] callArguments, Node callNode, boolean needsCallerFrame, boolean needsExceptionState); @@ -266,6 +297,10 @@ public void enter(VirtualFrame frame) { } public void exit(VirtualFrame frame, PRootNode node) { + exit(frame, node, node); + } + + public void exit(VirtualFrame frame, PRootNode node, Node location) { /* * equivalent to PyPy's ExecutionContext.leave. Note that got_exception in * their code is handled automatically by the Truffle lazy exceptions, so here we only @@ -274,12 +309,12 @@ public void exit(VirtualFrame frame, PRootNode node) { PFrame.Reference info = PArguments.getCurrentFrameInfo(frame); CompilerAsserts.partialEvaluationConstant(node); if (node.getFrameEscapedProfile().profile(info.isEscaped())) { - exitEscaped(frame, node, info); + exitEscaped(frame, node, location, info); } } @InliningCutoff - private void exitEscaped(VirtualFrame frame, PRootNode node, Reference info) { + private void exitEscaped(VirtualFrame frame, PRootNode node, Node location, Reference info) { if (!everEscaped) { CompilerDirectives.transferToInterpreterAndInvalidate(); everEscaped = true; @@ -307,7 +342,7 @@ private void exitEscaped(VirtualFrame frame, PRootNode node, Reference info) { } // force the frame so that it can be accessed later - ensureMaterializeNode().execute(frame, node, false, true); + ensureMaterializeNode().execute(frame, location, false, true); // if this frame escaped we must ensure that also f_back does callerInfo.markAsEscaped(); info.setBackref(callerInfo); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java index 5e04d5698e..d2ddcc3dc0 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java @@ -157,6 +157,7 @@ import com.oracle.graal.python.nodes.SpecialMethodNames; import com.oracle.graal.python.nodes.WriteUnraisableNode; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.object.SetDictNode; import com.oracle.graal.python.nodes.statement.AbstractImportNode; @@ -187,6 +188,7 @@ import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.ThreadLocalAction; +import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.TruffleContext; import com.oracle.truffle.api.TruffleContext.Builder; import com.oracle.truffle.api.TruffleFile; @@ -386,6 +388,13 @@ public static final class PythonThreadState { */ Object asyncgenFirstIter; + /* + * Instrumentation data (Bytecode DSL interpreter only). For the manual bytecode + * interpreter, this data is stored in a local state variable, but the DSL interpreter must + * use a thread local. + */ + PBytecodeDSLRootNode.InstrumentationData instrumentationData; + /* * Counter for C-level recursion depth used for Py_(Enter/Leave)RecursiveCall. */ @@ -566,13 +575,48 @@ public void dispose(PythonContext context, boolean canRunGuestCode) { } } + private static void invalidateNoTracingOrProfilingAssumption(PythonLanguage language) { + if (language.noTracingOrProfilingAssumption.isValid()) { + language.noTracingOrProfilingAssumption.invalidate(); + + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + enableTracingOrProfilingForActiveRootNodes(); + } + } + } + + @TruffleBoundary + private static void enableTracingOrProfilingForActiveRootNodes() { + final List rootNodes = new ArrayList<>(); + + // Ensure tracing + profiling are enabled for each method on the stack. + Truffle.getRuntime().iterateFrames((frameInstance) -> { + if (frameInstance.getCallTarget() instanceof RootCallTarget c && c.getRootNode() instanceof PBytecodeDSLRootNode r) { + if (r.needsTraceAndProfileInstrumentation()) { + r.ensureTraceAndProfileEnabled(); + } + rootNodes.add(r); + } + return null; + }); + + /** + * Normally, a root node will push + pop the instrumentation data in its prolog/epilog. + * Since these nodes are on stack, we need to push them manually, starting from the + * deepest stack frame. + */ + for (PBytecodeDSLRootNode rootNode : rootNodes.reversed()) { + rootNode.getThreadState().pushInstrumentationData(rootNode); + } + } + public Object getTraceFun() { return traceFun; } public void setTraceFun(Object traceFun, PythonLanguage language) { if (this.traceFun != traceFun) { - language.noTracingOrProfilingAssumption.invalidate(); + invalidateNoTracingOrProfilingAssumption(language); this.traceFun = traceFun; } } @@ -601,7 +645,7 @@ public void setTracingWhat(TraceEvent tracingWhat) { public void setProfileFun(Object profileFun, PythonLanguage language) { if (this.profileFun != profileFun) { - language.noTracingOrProfilingAssumption.invalidate(); + invalidateNoTracingOrProfilingAssumption(language); this.profileFun = profileFun; } } @@ -623,6 +667,24 @@ public void profilingStop() { this.profiling = false; } + public PBytecodeDSLRootNode.InstrumentationData getInstrumentationData(PBytecodeDSLRootNode rootNode) { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + assert instrumentationData != null && instrumentationData.getRootNode() == rootNode; + return instrumentationData; + } + + public void pushInstrumentationData(PBytecodeDSLRootNode rootNode) { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + instrumentationData = new PBytecodeDSLRootNode.InstrumentationData(rootNode, instrumentationData); + } + + public void popInstrumentationData(PBytecodeDSLRootNode rootNode) { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + assert instrumentationData != null; + assert instrumentationData.getRootNode() == rootNode : instrumentationData.getRootNode(); + instrumentationData = instrumentationData.getPrevious(); + } + public Object getAsyncgenFirstIter() { return asyncgenFirstIter; } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java index aad42772ea..01225837a6 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java @@ -83,6 +83,12 @@ public final class PythonOptions { */ public static final boolean AUTOMATIC_ASYNC_ACTIONS = !"false".equalsIgnoreCase(System.getProperty("python.AutomaticAsyncActions")); + /** + * Whether to use the experimental Bytecode DSL interpreter instead of the manually-written + * bytecode interpreter. + */ + public static final boolean ENABLE_BYTECODE_DSL_INTERPRETER = Boolean.getBoolean("python.EnableBytecodeDSLInterpreter"); + public enum HPyBackendMode { NFI, JNI, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java index a6a043aedf..bd758f8681 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/ExceptionUtils.java @@ -46,6 +46,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -60,6 +61,7 @@ import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode; import com.oracle.graal.python.nodes.BuiltinNames; import com.oracle.graal.python.nodes.ErrorMessages; +import com.oracle.graal.python.nodes.bytecode.BytecodeFrameInfo; import com.oracle.graal.python.nodes.bytecode.FrameInfo; import com.oracle.graal.python.nodes.call.CallNode; import com.oracle.graal.python.nodes.exception.TopLevelExceptionHandler; @@ -67,6 +69,7 @@ import com.oracle.graal.python.nodes.object.GetClassNode; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.object.PFactory; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; @@ -75,8 +78,8 @@ import com.oracle.truffle.api.TruffleStackTrace; import com.oracle.truffle.api.TruffleStackTraceElement; import com.oracle.truffle.api.exception.AbstractTruffleException; +import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.frame.Frame; -import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameInstance; import com.oracle.truffle.api.frame.FrameInstanceVisitor; import com.oracle.truffle.api.interop.InteropLibrary; @@ -93,6 +96,18 @@ private ExceptionUtils() { @TruffleBoundary public static void printPythonLikeStackTrace() { CompilerAsserts.neverPartOfCompilation("printPythonLikeStackTrace is a debug method"); + printStack(new PrintWriter(System.err, true), getStackTraceElements()); + } + + @TruffleBoundary + public static String getPythonLikeStackTrace() { + CompilerAsserts.neverPartOfCompilation("getPythonLikeStackTrace is a debug method"); + var sw = new StringWriter(); + printStack(new PrintWriter(sw, true), getStackTraceElements()); + return sw.toString(); + } + + private static ArrayList getStackTraceElements() { final ArrayList stack = new ArrayList<>(); Truffle.getRuntime().iterateFrames((FrameInstanceVisitor) frameInstance -> { RootCallTarget target = (RootCallTarget) frameInstance.getCallTarget(); @@ -101,24 +116,34 @@ public static void printPythonLikeStackTrace() { if (location == null) { location = rootNode; } - int lineno = getLineno(frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY)); + int lineno = getLineno(frameInstance.getFrame(FrameInstance.FrameAccess.READ_ONLY), location, frameInstance); appendStackLine(stack, location, rootNode, true, lineno); return null; }); - printStack(new PrintWriter(System.err, true), stack); + return stack; } - private static int getLineno(Frame frame) { - int lineno = -1; - if (frame != null) { - FrameDescriptor fd = frame.getFrameDescriptor(); - if (fd.getInfo() instanceof FrameInfo) { - FrameInfo frameInfo = (FrameInfo) fd.getInfo(); - int bci = frameInfo.getBci(frame); - lineno = frameInfo.getRootNode().bciToLine(bci); + private static int getLineno(Frame frame, Node location, FrameInstance frameInstance) { + if (frame != null && frame.getFrameDescriptor().getInfo() instanceof FrameInfo frameInfo) { + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + BytecodeNode bytecodeNode = null; + if (frameInstance != null) { + bytecodeNode = BytecodeNode.get(frameInstance); + } else { + // NB: This fails for the top stack frame, which has no BytecodeNode. + bytecodeNode = BytecodeNode.get(location); + } + + if (bytecodeNode != null) { + int bci = bytecodeNode.getBytecodeIndex(frame); + return bytecodeNode.getBytecodeLocation(bci).getSourceLocation().getStartLine(); + } + } else { + return ((BytecodeFrameInfo) frameInfo).getLine(frame); } } - return lineno; + return -1; + } @TruffleBoundary @@ -152,7 +177,7 @@ public static void printPythonLikeStackTrace(PrintWriter p, Throwable e) { for (TruffleStackTraceElement frame : stackTrace) { Node location = frame.getLocation(); RootNode rootNode = frame.getTarget().getRootNode(); - int lineno = getLineno(frame.getFrame()); + int lineno = getLineno(frame.getFrame(), location, null); appendStackLine(stack, location, rootNode, false, lineno); } printStack(p, stack); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java index 167f060bef..f98835d141 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/exception/PException.java @@ -50,11 +50,15 @@ import com.oracle.graal.python.builtins.objects.traceback.MaterializeLazyTracebackNode; import com.oracle.graal.python.builtins.objects.traceback.PTraceback; import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode; +import com.oracle.graal.python.nodes.PRootNode; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; import com.oracle.graal.python.runtime.GilNode; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import com.oracle.truffle.api.bytecode.BytecodeNode; import com.oracle.truffle.api.dsl.Bind; import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached.Exclusive; @@ -78,6 +82,7 @@ * object must be created for each throw. */ @ExportLibrary(value = InteropLibrary.class, delegateTo = "pythonException") +@SuppressWarnings({"serial"}) public final class PException extends AbstractTruffleException { private static final long serialVersionUID = -6437116280384996361L; @@ -87,7 +92,12 @@ public final class PException extends AbstractTruffleException { private String message = null; final transient Object pythonException; private transient PFrame.Reference frameInfo; - private transient PBytecodeRootNode catchRootNode; + + // This node is a manual bytecode or Bytecode DSL root node. + private transient PRootNode rootNode; + // This node is present when using the Bytecode DSL. + private transient BytecodeNode bytecodeNode; + private int catchBci; private boolean reified = false; private boolean skipFirstTracebackFrame; @@ -179,17 +189,35 @@ public void skipFirstTracebackFrame() { } public boolean catchingFrameWantedForTraceback() { - return tracebackFrameCount >= 0 && catchRootNode != null && catchRootNode.frameIsVisibleToPython(); - } - - public PBytecodeRootNode getCatchRootNode() { - return catchRootNode; + if (tracebackFrameCount < 0 || rootNode == null) { + return false; + } + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + return !((PBytecodeDSLRootNode) rootNode).isInternal(); + } else { + return ((PBytecodeRootNode) rootNode).frameIsVisibleToPython(); + } } public int getCatchBci() { return catchBci; } + public BytecodeNode getBytecodeNode() { + return bytecodeNode; + } + + public int getCatchLine() { + if (rootNode == null) { + return -1; + } + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + return ((PBytecodeDSLRootNode) rootNode).bciToLine(catchBci, bytecodeNode); + } else { + return ((PBytecodeRootNode) rootNode).bciToLine(catchBci); + } + } + /** * Return the associated {@link PBaseException}. This method doesn't ensure traceback * consistency and should be avoided unless you can guarantee that the exception will not escape @@ -243,12 +271,67 @@ public void expect(Node inliningTarget, PythonBuiltinClassType error, IsBuiltinO } } + /** + * Set the catching frame reference for a manual bytecode node. + */ public void setCatchingFrameReference(Frame frame, PBytecodeRootNode catchLocation, int catchBci) { this.frameInfo = PArguments.getCurrentFrameInfo(frame); - this.catchRootNode = catchLocation; + this.rootNode = catchLocation; this.catchBci = catchBci; } + /** + * Sets the catching frame information for a Bytecode DSL node. + * + * NB: The manual bytecode interpreter sets all of the catching frame info in one step after it + * finds a handler for the bci. This is possible because it has control over the handler + * dispatch logic. + * + * The Bytecode DSL interpreter's generated code automatically dispatches to a handler. We can + * set the frame info inside the handler code, but the bci of the raising instruction is lost at + * that point. + * + * We thus set the catch information in two steps: + *

      + *
    1. First, we use a hook in the DSL to set the catch location every time an exception is + * thrown from the bytecode loop ({@link #setCatchLocation}).
    2. + *
    3. Then, we mark the exception as "caught" when we reach a handler + * ({@link #markAsCaught(Frame, PBytecodeDSLRootNode)}. Once it's "caught", the catch location + * is frozen.
    4. + *
    + * + * (It is necessary to freeze the location after calling + * {@link #markAsCaught(Frame, PBytecodeDSLRootNode)} because Python-level try-except-finally + * blocks are implemented with multiple DSL-level throws; these throws will trigger subsequent + * {@link #setCatchLocation} calls that would overwrite the location.) + * + * Since the catch location is set unconditionally, it could refer to a location that had no + * handler (i.e., the location is invalid). Code should not use the location unless the other + * frame info (e.g., the {@link #rootNode}) has been set, which indicates that a handler was + * found and that the catch location actually refers to a guarded instruction. + */ + public void setCatchLocation(int catchBci, BytecodeNode bytecodeNode) { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + // Overwrite the catchBci as long as no handler has been found yet. + if (!isCaught()) { + this.catchBci = catchBci; + this.bytecodeNode = bytecodeNode; + } + } + + public void markAsCaught(Frame frame, PBytecodeDSLRootNode catchLocation) { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + if (!isCaught()) { + this.frameInfo = PArguments.getCurrentFrameInfo(frame); + this.rootNode = catchLocation; + } + } + + private boolean isCaught() { + assert PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER; + return rootNode != null; + } + public void markEscaped() { markFrameEscaped(); if (!(pythonException instanceof PBaseException)) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java index 4b245c8909..1c96a3d94f 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/object/PFactory.java @@ -228,8 +228,10 @@ import com.oracle.graal.python.builtins.objects.types.PGenericAlias; import com.oracle.graal.python.builtins.objects.types.PGenericAliasIterator; import com.oracle.graal.python.builtins.objects.types.PUnionType; -import com.oracle.graal.python.compiler.CodeUnit; +import com.oracle.graal.python.compiler.BytecodeCodeUnit; import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; +import com.oracle.graal.python.nodes.bytecode_dsl.BytecodeDSLCodeUnit; +import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; import com.oracle.graal.python.runtime.NFIZlibSupport; import com.oracle.graal.python.runtime.PythonContext; import com.oracle.graal.python.runtime.sequence.storage.ByteSequenceStorage; @@ -833,15 +835,28 @@ public static PGenerator createGenerator(PythonLanguage language, TruffleString return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator)); } + public static PGenerator createGenerator(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeDSLRootNode rootNode, Object[] arguments) { + return trace(language, PGenerator.create(language, name, qualname, rootNode, arguments, PythonBuiltinClassType.PGenerator)); + } + public static PGenerator createIterableCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PGenerator, true)); } + public static PGenerator createIterableCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeDSLRootNode rootNode, + Object[] arguments) { + return trace(language, PGenerator.create(language, name, qualname, rootNode, arguments, PythonBuiltinClassType.PGenerator, true)); + } + public static PGenerator createCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeRootNode rootNode, RootCallTarget[] callTargets, Object[] arguments) { return trace(language, PGenerator.create(language, name, qualname, rootNode, callTargets, arguments, PythonBuiltinClassType.PCoroutine)); } + public static PGenerator createCoroutine(PythonLanguage language, TruffleString name, TruffleString qualname, PBytecodeDSLRootNode rootNode, Object[] arguments) { + return trace(language, PGenerator.create(language, name, qualname, rootNode, arguments, PythonBuiltinClassType.PCoroutine)); + } + public static PCoroutineWrapper createCoroutineWrapper(PythonLanguage language, PGenerator generator) { return trace(language, new PCoroutineWrapper(language, generator)); } @@ -1103,7 +1118,11 @@ public static PCode createCode(PythonLanguage language, RootCallTarget ct, int f return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), ct, flags, firstlineno, linetable, filename)); } - public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, CodeUnit codeUnit) { + public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, BytecodeCodeUnit codeUnit) { + return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, codeUnit)); + } + + public static PCode createCode(PythonLanguage language, RootCallTarget callTarget, Signature signature, BytecodeDSLCodeUnit codeUnit) { return trace(language, new PCode(PythonBuiltinClassType.PCode, PythonBuiltinClassType.PCode.getInstanceShape(language), callTarget, signature, codeUnit)); } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java index b584cc7ff3..90b9798b8e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/util/PythonUtils.java @@ -80,6 +80,7 @@ import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; import com.oracle.graal.python.pegparser.scope.ScopeEnvironment; import com.oracle.graal.python.pegparser.sst.ConstantValue; +import com.oracle.graal.python.runtime.PythonOptions; import com.oracle.graal.python.runtime.object.PFactory; import com.oracle.truffle.api.CallTarget; import com.oracle.truffle.api.CompilerAsserts; @@ -754,7 +755,12 @@ public static Source createFakeSource() { @TruffleBoundary public static Source createFakeSource(TruffleString name) { - return Source.newBuilder(PythonLanguage.ID, EMPTY_BYTE_SEQUENCE, name.toJavaStringUncached()).build(); + if (PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER) { + // The DSL interpreter requires character-based sources. + return Source.newBuilder(PythonLanguage.ID, "", name.toJavaStringUncached()).content(Source.CONTENT_NONE).build(); + } else { + return Source.newBuilder(PythonLanguage.ID, EMPTY_BYTE_SEQUENCE, name.toJavaStringUncached()).build(); + } } public static Object[] prependArgument(Object primary, Object[] arguments) { diff --git a/graalpython/lib-python/3/test/support/__init__.py b/graalpython/lib-python/3/test/support/__init__.py index 630166deeb..9a133593fe 100644 --- a/graalpython/lib-python/3/test/support/__init__.py +++ b/graalpython/lib-python/3/test/support/__init__.py @@ -1057,6 +1057,17 @@ def impl_detail(msg=None, **guards): msg = msg.format(' or '.join(guardnames)) return unittest.skip(msg) +def bytecode_dsl_excluded(test): + """ + Decorator for tests that don't apply to the Bytecode DSL interpreter. + """ + try: + if sys.implementation.name == 'graalpy' and __graalpython__.is_bytecode_dsl_interpreter: + return unittest.skip("Not supported by the Bytecode DSL interpreter") + except NameError: + pass + return test + def _parse_guards(guards): # Returns a tuple ({platform_name: run_me}, default_value) if not guards: diff --git a/graalpython/lib-python/3/test/test_sys_settrace.py b/graalpython/lib-python/3/test/test_sys_settrace.py index e97e122534..5c4f83b679 100644 --- a/graalpython/lib-python/3/test/test_sys_settrace.py +++ b/graalpython/lib-python/3/test/test_sys_settrace.py @@ -1,3 +1,42 @@ +# Copyright (c) 2025, 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. + # Testing the line trace facility. from test import support @@ -1869,6 +1908,8 @@ def no_jump_without_trace_function(): raise AssertionError("Trace-function-less jump failed to fail") +# GraalPy Bytecode DSL: for the time being, arbitrary jumps are not supported by Truffle Bytecode DSL +@support.bytecode_dsl_excluded class JumpTestCase(unittest.TestCase): def setUp(self): self.addCleanup(sys.settrace, sys.gettrace()) diff --git a/mx.graalpython/mx_graalpython.py b/mx.graalpython/mx_graalpython.py index 6eaab1422a..ae8489d397 100644 --- a/mx.graalpython/mx_graalpython.py +++ b/mx.graalpython/mx_graalpython.py @@ -132,6 +132,7 @@ def get_boolean_env(name, default=False): CI = get_boolean_env("CI") WIN32 = sys.platform == "win32" BUILD_NATIVE_IMAGE_WITH_ASSERTIONS = get_boolean_env('BUILD_WITH_ASSERTIONS', CI) +BYTECODE_DSL_INTERPRETER = get_boolean_env('BYTECODE_DSL_INTERPRETER', False) mx_gate.add_jacoco_excludes([ "com.oracle.graal.python.pegparser.sst", @@ -429,6 +430,9 @@ def __str__(self): vm_args = ['-Dpolyglot.engine.WarnInterpreterOnly=false'] + if BYTECODE_DSL_INTERPRETER: + vm_args.append("-Dpython.EnableBytecodeDSLInterpreter=true") + # Note: we must use filters instead of --regex so that mx correctly processes the unit test configs, # but it is OK to apply --regex on top of the filters graalpy_tests = ['com.oracle.graal.python.test', 'com.oracle.graal.python.pegparser.test', 'org.graalvm.python.embedding.test'] @@ -618,6 +622,15 @@ def graalpy_standalone_home(standalone_type, enterprise=False, dev=False, build= import_ee_status = mx.run([launcher, "-c", "import sys; assert 'Oracle GraalVM' in sys.version"], nonZeroIsFatal=False, out=out, err=out) if enterprise != (import_ee_status == 0): mx.abort(f"GRAALPY_HOME is not compatible with requested distribution kind ({import_ee_status=}, {enterprise=}, {out=}).") + + out = mx.OutputCapture() + mx.run([launcher, "-c", "print(__graalpython__.is_bytecode_dsl_interpreter)"], nonZeroIsFatal=False, out=out, err=out) + is_bytecode_dsl_interpreter = out.data.strip() == "True" + if is_bytecode_dsl_interpreter != BYTECODE_DSL_INTERPRETER: + requested = "Bytecode DSL" if BYTECODE_DSL_INTERPRETER else "Manual" + actual = "Bytecode DSL" if is_bytecode_dsl_interpreter else "Manual" + mx.abort(f"GRAALPY_HOME is not compatible with requested interpreter kind ({requested=}, {actual=})") + return python_home env_file = 'ce-python' @@ -646,8 +659,12 @@ def graalpy_standalone_home(standalone_type, enterprise=False, dev=False, build= if mx_gate.get_jacoco_agent_args() or (build and not DISABLE_REBUILD): dep_type = 'JAVA' if standalone_type == 'jvm' else 'NATIVE' + mx_build_args = mx_args + if BYTECODE_DSL_INTERPRETER: + mx_build_args = mx_args + ["--extra-image-builder-argument=-Dpython.EnableBytecodeDSLInterpreter=true"] + # Example of a string we're building here: PYTHON_JAVA_STANDALONE_SVM_SVMEE_JAVA21 - mx.run_mx(mx_args + ["build", "--dep", f"PYTHON_{dep_type}_STANDALONE{svm_component}_JAVA{jdk_version.parts[0]}"]) + mx.run_mx(mx_build_args + ["build", "--dep", f"PYTHON_{dep_type}_STANDALONE{svm_component}_JAVA{jdk_version.parts[0]}"]) out = mx.OutputCapture() # note: 'quiet=True' is important otherwise if the outer MX runs verbose, @@ -913,6 +930,9 @@ def graalpytest(args): gp_args = ["--vm.ea", "--vm.esa", "--experimental-options=true", "--python.EnableDebuggingBuiltins"] mx.log(f"Executable seems to be GraalPy, prepending arguments: {gp_args}") python_args += gp_args + if is_graalpy and BYTECODE_DSL_INTERPRETER: + python_args.insert(0, "--vm.Dpython.EnableBytecodeDSLInterpreter=true") + runner_args.append(f'--subprocess-args={shlex.join(python_args)}') cmd_args = [*python_args, _python_test_runner(), 'run', *runner_args] delete_bad_env_keys(env) @@ -921,7 +941,12 @@ def graalpytest(args): pythonpath += [p for p in env.get('PYTHONPATH', '').split(os.pathsep) if p] env['PYTHONPATH'] = os.pathsep.join(pythonpath) if python_binary: - return mx.run([python_binary, *cmd_args], nonZeroIsFatal=True, env=env) + try: + result = mx.run([python_binary, *cmd_args], nonZeroIsFatal=True, env=env) + print(f"back from mx.run, returning {result}") + return result + except BaseException as e: + print(f"Exception raised: {e}") else: return full_python(cmd_args, env=env) @@ -985,6 +1010,9 @@ def run_python_unittests(python_binary, args=None, paths=None, exclude=None, env if mx.primary_suite() != SUITE: env.setdefault("GRAALPYTEST_ALLOW_NO_JAVA_ASSERTIONS", "true") + if BYTECODE_DSL_INTERPRETER: + args += ['--vm.Dpython.EnableBytecodeDSLInterpreter=true'] + # just to be able to verify, print C ext mode (also works for CPython) mx.run( [ @@ -2203,6 +2231,9 @@ def _python_checkpatchfiles(): 'LLVM.org toolchain': ('lib/llvm-toolchain', []), } +def bytecode_dsl_build_args(): + return ['-Dpython.EnableBytecodeDSLInterpreter=true'] if BYTECODE_DSL_INTERPRETER else [] + mx_sdk.register_graalvm_component(mx_sdk.GraalVmLanguage( suite=SUITE, name='GraalVM Python', @@ -2255,7 +2286,7 @@ def _python_checkpatchfiles(): '-H:-CopyLanguageResources', '-Dpolyglot.python.PosixModuleBackend=native', '-Dpolyglot.python.Sha3ModuleBackend=native', - ], + ] + bytecode_dsl_build_args(), language='python', default_vm_args=[ '--vm.Xss16777216', # request 16M of stack @@ -2703,9 +2734,26 @@ def getBuildEnv(self, replaceVar=mx_subst.path_substitutions): return ret +class GraalpythonFrozenModuleBuildTask(GraalpythonBuildTask): + def build(self): + # We freeze modules twice: once for the manual Bytecode interpreter and once for the DSL interpreter. + args = [mx_subst.path_substitutions.substitute(a, dependency=self) for a in self.subject.args] + return self.run(args, "manual bytecode") or self.run(args, "dsl", extra_vm_args=["-Dpython.EnableBytecodeDSLInterpreter=true"]) + + def run(self, args, interpreter_kind, extra_vm_args=None): + mx.log(f"Building frozen modules for {interpreter_kind} interpreter.") + return super().run(args, extra_vm_args=extra_vm_args) + + +class GraalpythonFrozenProject(GraalpythonProject): + def getBuildTask(self, args): + return GraalpythonFrozenModuleBuildTask(args, self) + + orig_clean = mx.command_function("clean") def python_clean(args): - orig_clean(args) + if '--just-pyc' not in args: + orig_clean(args) if not args: count = 0 for path in os.walk(SUITE.dir): @@ -3143,7 +3191,7 @@ def run_downstream_test(args): 'python-coverage': [python_coverage, ''], 'punittest': [punittest, ''], 'graalpytest': [graalpytest, '[-h] [--python PYTHON] [TESTS]'], - 'clean': [python_clean, ''], + 'clean': [python_clean, '[--just-pyc]'], 'python-update-hpy-import': [update_hpy_import_cmd, '[--no-pull] PATH_TO_HPY'], 'bisect-benchmark': [mx_graalpython_bisect.bisect_benchmark, ''], 'python-leak-test': [run_leak_launcher, ''], diff --git a/mx.graalpython/mx_graalpython_benchmark.py b/mx.graalpython/mx_graalpython_benchmark.py index ab1f3a697b..b44512a960 100644 --- a/mx.graalpython/mx_graalpython_benchmark.py +++ b/mx.graalpython/mx_graalpython_benchmark.py @@ -37,6 +37,7 @@ import mx import mx_benchmark +import mx_graalpython from mx_benchmark import StdOutRule, java_vm_registry, Vm, GuestVm, VmBenchmarkSuite, AveragingBenchmarkMixin from mx_graalpython_bench_param import HARNESS_PATH @@ -365,6 +366,9 @@ def _remove_vm_prefix(argument): def run(self, cwd, args): extra_polyglot_args = self.get_extra_polyglot_args() + if mx_graalpython.BYTECODE_DSL_INTERPRETER: + args.insert(0, "--vm.Dpython.EnableBytecodeDSLInterpreter=true") + host_vm = self.host_vm() if hasattr(host_vm, 'run_lang'): # this is a full GraalVM build return self.run_in_graalvm(cwd, args, extra_polyglot_args, host_vm) diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py index b215b66282..46d9605f16 100644 --- a/mx.graalpython/suite.py +++ b/mx.graalpython/suite.py @@ -376,7 +376,7 @@ "com.oracle.graal.python.frozen": { "subDir": "graalpython", "vpath": True, - "type": "GraalpythonProject", + "type": "GraalpythonFrozenProject", "args": [ "/freeze_modules.py", "--python-lib", From 9e0b08e68a5c3b1e316328e5947e6f12789f4d38 Mon Sep 17 00:00:00 2001 From: stepan Date: Wed, 16 Apr 2025 21:31:50 +0200 Subject: [PATCH 317/512] Update CI overlays --- ci.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci.jsonnet b/ci.jsonnet index 53581b9396..f04feb0c23 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "f801d1578ef92e240ec92f380a9970c6644c2c59" } +{ "overlay": "d8b8c70664f28d8d94d5b7d2ca0d0bdce5ec435f" } From 99b4114b5e69d51e8d4f84bff3da5a1cfff253a1 Mon Sep 17 00:00:00 2001 From: Ondrej Tethal Date: Tue, 22 Apr 2025 08:52:54 +0200 Subject: [PATCH 318/512] Update imports --- ci.jsonnet | 2 +- mx.graalpython/suite.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci.jsonnet b/ci.jsonnet index f04feb0c23..39cd744f59 100644 --- a/ci.jsonnet +++ b/ci.jsonnet @@ -1 +1 @@ -{ "overlay": "d8b8c70664f28d8d94d5b7d2ca0d0bdce5ec435f" } +{ "overlay": "a242e9622be463c91c2cc034a1f2c1811316bc18" } diff --git a/mx.graalpython/suite.py b/mx.graalpython/suite.py index 46d9605f16..aadbc21538 100644 --- a/mx.graalpython/suite.py +++ b/mx.graalpython/suite.py @@ -45,7 +45,7 @@ }, { "name": "sdk", - "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", + "version": "f696872837cbc96dff74e9916888e42f1be3a5df", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -53,7 +53,7 @@ }, { "name": "tools", - "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", + "version": "f696872837cbc96dff74e9916888e42f1be3a5df", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -61,7 +61,7 @@ }, { "name": "sulong", - "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", + "version": "f696872837cbc96dff74e9916888e42f1be3a5df", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, @@ -69,7 +69,7 @@ }, { "name": "regex", - "version": "fa6ba04036e6f905683dd52282793d239ef5b7a3", + "version": "f696872837cbc96dff74e9916888e42f1be3a5df", "subdir": True, "urls": [ {"url": "https://github.com/oracle/graal", "kind": "git"}, From bb11d8e3531df3668376b2c753efb3a90a094254 Mon Sep 17 00:00:00 2001 From: Ondrej Tethal Date: Tue, 22 Apr 2025 09:12:47 +0200 Subject: [PATCH 319/512] Update tags --- .../src/tests/unittest_tags/test_asyncgen.txt | 4 +- .../src/tests/unittest_tags/test_hashlib.txt | 8 +- .../src/tests/unittest_tags/test_tarfile.txt | 395 +++++++++--------- 3 files changed, 204 insertions(+), 203 deletions(-) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncgen.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncgen.txt index c7fa20e46c..e808fd4886 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncgen.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_asyncgen.txt @@ -1,8 +1,8 @@ test.test_asyncgen.AsyncGenAsyncioTest.test_aiter_bad_args @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncgen.AsyncGenAsyncioTest.test_aiter_idempotent @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncgen.AsyncGenAsyncioTest.test_anext_bad_args @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_asyncgen.AsyncGenAsyncioTest.test_anext_return_generator @ linux-x86_64 -test.test_asyncgen.AsyncGenAsyncioTest.test_anext_return_iterator @ linux-x86_64 +test.test_asyncgen.AsyncGenAsyncioTest.test_anext_return_generator @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_asyncgen.AsyncGenAsyncioTest.test_anext_return_iterator @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_aclose_after_exhaustion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_aclose_compatible_with_get_stack @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_asyncgen.AsyncGenAsyncioTest.test_async_gen_aclose_twice_with_different_coros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_hashlib.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_hashlib.txt index a22ac8b386..b00dd856f5 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_hashlib.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_hashlib.txt @@ -27,13 +27,13 @@ test.test_hashlib.HashLibTestCase.test_case_sha384_1 @ darwin-arm64,darwin-x86_6 test.test_hashlib.HashLibTestCase.test_case_sha384_2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha384_3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha3_224_0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_hashlib.HashLibTestCase.test_case_sha3_224_vector @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_hashlib.HashLibTestCase.test_case_sha3_224_vector @ darwin-arm64,darwin-x86_64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha3_256_0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_hashlib.HashLibTestCase.test_case_sha3_256_vector @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_hashlib.HashLibTestCase.test_case_sha3_256_vector @ darwin-arm64,darwin-x86_64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha3_384_0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_hashlib.HashLibTestCase.test_case_sha3_384_vector @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_hashlib.HashLibTestCase.test_case_sha3_384_vector @ darwin-arm64,darwin-x86_64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha3_512_0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 -test.test_hashlib.HashLibTestCase.test_case_sha3_512_vector @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_hashlib.HashLibTestCase.test_case_sha3_512_vector @ darwin-arm64,darwin-x86_64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha512_0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha512_1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_hashlib.HashLibTestCase.test_case_sha512_2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 diff --git a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt index ea5af7be37..be7f184483 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt +++ b/graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_tarfile.txt @@ -300,256 +300,257 @@ test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64 test.test_tarfile.LzmaMiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaMiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaMiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaMiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaStreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaStreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaStreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaStreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaUstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaUstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.LzmaWriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaWriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaWriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaWriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaWriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.LzmaWriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.LzmaWriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.LzmaWriteTest.test_tar_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MemberReadTest.test_find_blktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_chrtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_conttype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_dirtype_with_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_fifotype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_gnusparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_00 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_01 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_gnusparse_10 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_lnktype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_pax_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_regtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_regtype_oldv7 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_sparse @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_symtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_umlauts @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MemberReadTest.test_find_ustar_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_bytes_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_check_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_empty_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.MiscReadTest.test_extract_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_extract_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_extract_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.MiscReadTest.test_extractall @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_extractall_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_fileobj_with_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_find_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.MiscReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_illegal_mode_arg @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_init_close_fobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_int_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.MiscReadTest.test_next_on_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_no_name_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_no_name_attribute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_parallel_iteration @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.MiscReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.MiscReadTest.test_v7_dirtype @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_xstar_type @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscReadTest.test_zlib_error_does_not_leak @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test__all__ @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test_char_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test_number_field_limits @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test_read_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test_useful_error_message_when_modules_missing @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.MiscTest.test_write_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Data.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Default.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_FullyTrusted.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_gname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_mtime @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_ownership @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.NoneInfoExtractTests_Tar.test_extractall_none_uname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.NoneInfoTests_Misc.test_add @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.NoneInfoTests_Misc.test_list @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.NumericOwnerTest.test_extract_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NumericOwnerTest.test_extractall_with_numeric_owner @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.NumericOwnerTest.test_keyword_only @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PAXUnicodeTest.test_binary_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PAXUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_header_offset @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.PaxReadTest.test_longname_directory @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.PaxReadTest.test_pax_global_headers @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_pax_number_fields @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_read_longlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_read_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxReadTest.test_truncated_longname @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_create_pax_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longlink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longlink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longlink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longname_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longname_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longname_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1023 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1024 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_longnamelink_1025 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_pax_extended_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.PaxWriteTest.test_pax_global_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.ReplaceTests.test_replace_all @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.ReplaceTests.test_replace_deep @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.ReplaceTests.test_replace_internal @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.ReplaceTests.test_replace_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.ReplaceTests.test_replace_shallow @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_compare_members @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_empty_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.StreamReadTest.test_ignore_zeros @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_is_tarfile_erroneous @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_is_tarfile_keeps_position @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_is_tarfile_valid @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_length_zero_header @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_non_existent_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_null_tarfile @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.StreamReadTest.test_premature_end_of_archive @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamReadTest.test_provoke_stream_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamReadTest.test_read_through @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamWriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.StreamWriteTest.test_file_mode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.StreamWriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.StreamWriteTest.test_stream_padding @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_absolute @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_absolute_hardlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.TestExtractionFilters.test_absolute_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_bad_filter_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_benign_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.TestExtractionFilters.test_chains @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_class @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_instance @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_on_subclass @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_change_default_filter_to_string @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_custom_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_data_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.TestExtractionFilters.test_deep_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_default_filter_warns_not @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_errorlevel @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_fully_trusted_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.TestExtractionFilters.test_modes @ win32-AMD64 test.test_tarfile.TestExtractionFilters.test_parent_symlink @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_parent_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_pipe @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_sly_relative0 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.TestExtractionFilters.test_sly_relative2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_special_files @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.TestExtractionFilters.test_stateful_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.TestExtractionFilters.test_tar_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.UstarReadTest.test_add_dir_getmember @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarReadTest.test_fileobj_iter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_readlines @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_regular_file @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_seek @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_symlink2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_fileobj_text @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarReadTest.test_issue14160 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_iso8859_1_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.UstarUnicodeTest.test_uname_unicode @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_argument @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_filename_error @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.UstarUnicodeTest.test_unicode_link1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.UstarUnicodeTest.test_unicode_link2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname3 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_longname4 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name1 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_unicode_name2 @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_utf7_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.UstarUnicodeTest.test_utf8_filename @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 +test.test_tarfile.WriteTest.test_100_char_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.WriteTest.test_abs_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.WriteTest.test_add_self @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.WriteTest.test_cwd @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_directory_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.WriteTest.test_eof_marker @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.WriteTest.test_extractall_symlinks @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_file_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.WriteTest.test_fileobj_no_close @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.WriteTest.test_filter @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_gettarinfo_pathlike_name @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_link_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 -test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 +test.test_tarfile.WriteTest.test_open_nonwritable_fileobj @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64,win32-AMD64 test.test_tarfile.WriteTest.test_ordered_recursion @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_pathnames @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 test.test_tarfile.WriteTest.test_symlink_size @ darwin-arm64,darwin-x86_64,linux-aarch64,linux-x86_64 From 3dc183f6542d8df9807cd3b839c9bc704d1e198a Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Tue, 22 Apr 2025 12:41:57 +0200 Subject: [PATCH 320/512] Add default excludes for generating filelists.txt --- .../python/embedding/tools/vfs/VFSUtils.java | 134 ++++++++++++++++-- 1 file changed, 123 insertions(+), 11 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index e11640c217..69486ea3cd 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -44,6 +44,8 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -70,6 +72,104 @@ public final class VFSUtils { + /** + * Patterns which should be excluded by default, like .gitignore or SCM files + *
      + *
    • Misc: **/*~, **/#*#, **/.#*, **/%*%, + * **/._*
    • + *
    • CVS: **/CVS, **/CVS/**, **/.cvsignore
    • + *
    • RCS: **/RCS, **/RCS/**
    • + *
    • SCCS: **/SCCS, **/SCCS/**
    • + *
    • VSSercer: **/vssver.scc
    • + *
    • MKS: **/project.pj
    • + *
    • SVN: **/.svn, **/.svn/**
    • + *
    • GNU: **/.arch-ids, **/.arch-ids/**
    • + *
    • Bazaar: **/.bzr, **/.bzr/**
    • + *
    • SurroundSCM: **/.MySCMServerInfo
    • + *
    • Mac: **/.DS_Store
    • + *
    • Serena Dimension: **/.metadata, **/.metadata/**
    • + *
    • Mercurial: **/.hg, **/.hg/**
    • + *
    • Git: **/.git, **/.git/**, **/.gitignore
    • + *
    • Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, + * **/ChangeSet/**
    • + *
    • Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, + * **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail + *
    + * + */ + private static final String[] DEFAULT_EXCLUDES = { + // Miscellaneous typical temporary files + "**/*~", + "**/#*#", + "**/.#*", + "**/%*%", + "**/._*", + + // CVS + "**/CVS", + "**/CVS/**", + "**/.cvsignore", + + // RCS + "**/RCS", + "**/RCS/**", + + // SCCS + "**/SCCS", + "**/SCCS/**", + + // Visual SourceSafe + "**/vssver.scc", + + // MKS + "**/project.pj", + + // Subversion + "**/.svn", + "**/.svn/**", + + // Arch + "**/.arch-ids", + "**/.arch-ids/**", + + // Bazaar + "**/.bzr", + "**/.bzr/**", + + // SurroundSCM + "**/.MySCMServerInfo", + + // Mac + "**/.DS_Store", + + // Serena Dimensions Version 10 + "**/.metadata", + "**/.metadata/**", + + // Mercurial + "**/.hg", + "**/.hg/**", + + // git + "**/.git", + "**/.git/**", + "**/.gitignore", + + // BitKeeper + "**/BitKeeper", + "**/BitKeeper/**", + "**/ChangeSet", + "**/ChangeSet/**", + + // darcs + "**/_darcs", + "**/_darcs/**", + "**/.darcsrepo", + "**/.darcsrepo/**", + "**/-darcs-backup*", + "**/.darcs-temp-mail" + }; + public static final String VFS_ROOT = "org.graalvm.python.vfs"; public static final String VFS_VENV = "venv"; public static final String VFS_FILESLIST = "fileslist.txt"; @@ -153,23 +253,35 @@ public static void generateVFSFilesList(Path resourcesRoot, Path vfs, Set { - String entry = null; - if (Files.isDirectory(p)) { - String dirPath = makeDirPath(p.toAbsolutePath()); - entry = dirPath.substring(rootEndIdx); - } else if (Files.isRegularFile(p)) { - entry = p.toAbsolutePath().toString().substring(rootEndIdx); - } - if (entry != null) { - entry = normalizeResourcePath(entry); - if (!ret.add(entry) && duplicateHandler != null) { - duplicateHandler.accept(entry); + if (!shouldPathBeExcluded(p)) { + String entry = null; + if (Files.isDirectory(p)) { + String dirPath = makeDirPath(p.toAbsolutePath()); + entry = dirPath.substring(rootEndIdx); + } else if (Files.isRegularFile(p)) { + entry = p.toAbsolutePath().toString().substring(rootEndIdx); + } + if (entry != null) { + entry = normalizeResourcePath(entry); + if (!ret.add(entry) && duplicateHandler != null) { + duplicateHandler.accept(entry); + } } } }); } } + private static boolean shouldPathBeExcluded(Path path) { + for (String glob : DEFAULT_EXCLUDES) { + var matcher = FileSystems.getDefault().getPathMatcher("glob:" + glob); + if (matcher.matches(path)) { + return true; + } + } + return false; + } + private static String makeDirPath(Path p) { String ret = p.toString(); if (!ret.endsWith(File.separator)) { From 99469b5a5d283c00754bba850ca00299923e0d34 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Tue, 22 Apr 2025 15:04:00 +0200 Subject: [PATCH 321/512] Adding source of the exclude list --- .../org/graalvm/python/embedding/tools/vfs/VFSUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java index 69486ea3cd..90538ff66d 100644 --- a/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java +++ b/graalpython/org.graalvm.python.embedding.tools/src/org/graalvm/python/embedding/tools/vfs/VFSUtils.java @@ -44,7 +44,6 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -73,7 +72,7 @@ public final class VFSUtils { /** - * Patterns which should be excluded by default, like .gitignore or SCM files + * Patterns which should be excluded by default, like .gitignore or SCM files. *
      *
    • Misc: **/*~, **/#*#, **/.#*, **/%*%, * **/._*
    • @@ -96,6 +95,9 @@ public final class VFSUtils { * **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail *
    * + * + * The list is a copy of the one used in tools like the Maven JAR Plugin. @see DEFAULTEXCLUDES */ private static final String[] DEFAULT_EXCLUDES = { // Miscellaneous typical temporary files From fc30f2c9f325abc46cc94cc6c872f545719c251d Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Thu, 17 Apr 2025 20:12:23 +0200 Subject: [PATCH 322/512] Sulong, and thanks for all the fish --- CHANGELOG.md | 1 + docs/contributor/DEV_TASKS.md | 31 +- docs/user/Native-Images-with-Python.md | 1 - .../CEXT-WINDOWS-README.md | 1 - .../CMakeLists.txt | 12 +- .../com.oracle.graal.python.cext/src/capi.c | 9 +- .../CMakeLists.txt | 143 - .../include/hpy.h | 339 -- .../include/hpy/autogen_hpyfunc_declare.h | 111 - .../include/hpy/autogen_hpyslot.h | 159 - .../include/hpy/cpy_types.h | 73 - .../include/hpy/cpython/autogen_api_impl.h | 605 --- .../include/hpy/cpython/autogen_ctx.h | 122 - .../hpy/cpython/autogen_hpyfunc_trampolines.h | 227 - .../include/hpy/cpython/hpyfunc_trampolines.h | 148 - .../include/hpy/cpython/misc.h | 594 --- .../include/hpy/forbid_python_h/Python.h | 30 - .../include/hpy/hpydef.h | 485 --- .../include/hpy/hpyexports.h | 37 - .../include/hpy/hpyfunc.h | 149 - .../include/hpy/hpymodule.h | 182 - .../include/hpy/hpytype.h | 311 -- .../include/hpy/inline_helpers.h | 561 --- .../include/hpy/macros.h | 94 - .../include/hpy/runtime/argparse.h | 50 - .../include/hpy/runtime/buildvalue.h | 33 - .../include/hpy/runtime/ctx_funcs.h | 146 - .../include/hpy/runtime/ctx_module.h | 49 - .../include/hpy/runtime/ctx_type.h | 40 - .../include/hpy/runtime/format.h | 42 - .../include/hpy/runtime/helpers.h | 39 - .../include/hpy/runtime/structseq.h | 132 - .../include/hpy/universal/autogen_ctx.h | 335 -- .../universal/autogen_hpyfunc_trampolines.h | 440 -- .../hpy/universal/autogen_trampolines.h | 1158 ----- .../hpy/universal/hpyfunc_trampolines.h | 201 - .../include/hpy/universal/misc_trampolines.h | 121 - .../include/hpy/version.h | 27 - .../src/autogen_c_access.h | 191 - .../src/hpy.c | 1357 ------ .../src/hpynative.h | 71 - .../src/hpytest/__init__.py | 23 - .../src/hpytest/check_py27_compat.py | 113 - .../src/hpytest/conftest.py | 152 - .../src/hpytest/debug/test_builder_invalid.py | 174 - .../src/hpytest/debug/test_charptr.py | 341 -- .../src/hpytest/debug/test_context_reuse.py | 128 - .../src/hpytest/debug/test_handles_invalid.py | 250 -- .../src/hpytest/debug/test_handles_leak.py | 322 -- .../src/hpytest/debug/test_misc.py | 199 - .../src/hpytest/hpy_devel/test_abitag.py | 48 - .../src/hpytest/hpy_devel/test_distutils.py | 386 -- .../src/hpytest/support.py | 651 --- .../src/hpytest/test_00_basic.py | 585 --- .../src/hpytest/test_argparse.py | 702 ---- .../src/hpytest/test_call.py | 353 -- .../src/hpytest/test_capsule.py | 491 --- .../src/hpytest/test_capsule_legacy.py | 109 - .../src/hpytest/test_contextvar.py | 75 - .../src/hpytest/test_cpy_compat.py | 239 -- .../src/hpytest/test_eval.py | 110 - .../src/hpytest/test_helpers.py | 167 - .../src/hpytest/test_hpybuildvalue.py | 257 -- .../src/hpytest/test_hpybytes.py | 154 - .../src/hpytest/test_hpydict.py | 144 - .../src/hpytest/test_hpyerr.py | 732 ---- .../src/hpytest/test_hpyfield.py | 464 --- .../src/hpytest/test_hpyglobal.py | 123 - .../src/hpytest/test_hpyimport.py | 47 - .../src/hpytest/test_hpylist.py | 100 - .../src/hpytest/test_hpylong.py | 463 -- .../src/hpytest/test_hpymodule.py | 306 -- .../src/hpytest/test_hpyslice.py | 133 - .../src/hpytest/test_hpystructseq.py | 148 - .../src/hpytest/test_hpytuple.py | 104 - .../src/hpytest/test_hpytype.py | 1711 -------- .../src/hpytest/test_hpytype_legacy.py | 372 -- .../src/hpytest/test_hpyunicode.py | 998 ----- .../src/hpytest/test_importing.py | 78 - .../src/hpytest/test_legacy_forbidden.py | 102 - .../src/hpytest/test_number.py | 270 -- .../src/hpytest/test_object.py | 838 ---- .../src/hpytest/test_slots.py | 835 ---- .../src/hpytest/test_slots_legacy.py | 289 -- .../src/hpytest/test_support.py | 73 - .../src/hpytest/test_tracker.py | 143 - .../src/hpytest/trace/test_trace.py | 153 - .../src/autogen_ctx_call_jni.c | 647 --- .../src/autogen_ctx_init_jni.h | 75 - .../src/autogen_wrappers_jni.c | 2282 ---------- .../src/ctx_builder.c | 172 - .../src/ctx_call_jni.c | 111 - .../src/ctx_tracker.c | 171 - .../src/debug/_debugmod.c | 456 -- .../src/debug/autogen_debug_ctx_init.h | 483 --- .../src/debug/autogen_debug_wrappers.c | 1794 -------- .../src/debug/debug_ctx.c | 619 --- .../src/debug/debug_ctx_not_cpython.c | 40 - .../src/debug/debug_ctx_tracker.c | 92 - .../src/debug/debug_handles.c | 322 -- .../src/debug/debug_internal.h | 383 -- .../src/debug/dhqueue.c | 145 - .../src/debug/hpy_debug.h | 81 - .../src/debug/include/hpy_debug.h | 81 - .../src/debug/memprotect.c | 118 - .../src/debug/stacktrace.c | 118 - .../com.oracle.graal.python.jni/src/hpy_jni.c | 539 --- .../com.oracle.graal.python.jni/src/hpy_jni.h | 194 - .../com.oracle.graal.python.jni/src/hpy_log.h | 54 - .../src/hpy_native_cache.h | 100 - .../src/hpy_native_fast_paths.c | 599 --- .../src/hpy_native_fast_paths.h | 94 - .../src/trace/_tracemod.c | 275 -- .../src/trace/autogen_trace_ctx_init.h | 500 --- .../src/trace/autogen_trace_func_table.c | 320 -- .../src/trace/autogen_trace_wrappers.c | 2335 ----------- .../src/trace/hpy_trace.h | 66 - .../src/trace/include/hpy_trace.h | 66 - .../src/trace/trace_ctx.c | 148 - .../src/trace/trace_internal.h | 96 - .../graal/python/shell/GraalPythonMain.java | 21 +- .../advanced/MultiContextTest.java | 19 +- .../integration/advanced/NativeExtTest.java | 13 +- .../integration/advanced/ShutdownTest.java | 10 +- ...aredEngineMultithreadingBenchmarkTest.java | 2 +- .../builtin/objects/cext/CExtContextTest.java | 4 +- .../python/test/nodes/MemMoveNodeTests.java | 2 +- .../cext/test/MultiContextCExtTest.java | 2 +- .../src/tests/cpyext/__init__.py | 1 - .../src/tests/cpyext/test_bool.py | 2 +- .../src/tests/cpyext/test_float.py | 4 +- .../src/tests/cpyext/test_functions.py | 2 +- .../src/tests/cpyext/test_gc.py | 6 +- .../python-language/native-image.properties | 2 +- .../com/oracle/graal/python/JNIFeature.java | 254 -- .../graal/python/builtins/Python3Core.java | 8 - .../modules/GraalHPyDebugModuleBuiltins.java | 148 - .../modules/GraalHPyTraceModuleBuiltins.java | 103 - .../GraalHPyUniversalModuleBuiltins.java | 260 -- .../modules/GraalPythonModuleBuiltins.java | 128 - .../modules/cext/PythonCextBuiltins.java | 6 +- .../modules/ctypes/CtypesModuleBuiltins.java | 58 +- .../objects/cext/capi/CApiContext.java | 199 +- .../objects/cext/capi/CApiFunction.java | 2 +- .../objects/cext/common/CExtCommonNodes.java | 3 +- .../objects/cext/common/CExtContext.java | 33 +- .../objects/cext/hpy/GraalHPyBoxing.java | 121 - .../objects/cext/hpy/GraalHPyBuffer.java | 251 -- .../objects/cext/hpy/GraalHPyCAccess.java | 726 ---- .../objects/cext/hpy/GraalHPyCField.java | 126 - .../objects/cext/hpy/GraalHPyContext.java | 1217 ------ .../cext/hpy/GraalHPyContextFunctions.java | 3712 ----------------- .../objects/cext/hpy/GraalHPyData.java | 111 - .../objects/cext/hpy/GraalHPyDef.java | 546 --- .../objects/cext/hpy/GraalHPyHandle.java | 284 -- .../objects/cext/hpy/GraalHPyLegacyDef.java | 271 -- .../cext/hpy/GraalHPyMemberAccessNodes.java | 660 --- .../objects/cext/hpy/GraalHPyNativeCache.java | 96 - .../cext/hpy/GraalHPyNativeContext.java | 338 -- .../cext/hpy/GraalHPyNativeSymbol.java | 114 - .../objects/cext/hpy/GraalHPyNodes.java | 3180 -------------- .../cext/hpy/GraalHPyObjectBuiltins.java | 303 -- .../objects/cext/hpy/GraalHPySourceKind.java | 75 - .../objects/cext/hpy/GraalHPyTracker.java | 88 - .../objects/cext/hpy/HPyContextMember.java | 387 -- .../objects/cext/hpy/HPyContextSignature.java | 47 - .../cext/hpy/HPyContextSignatureType.java | 127 - .../cext/hpy/HPyExternalFunctionNodes.java | 1847 -------- .../builtins/objects/cext/hpy/HPyMode.java | 76 - .../objects/cext/hpy/HPyTypeExtra.java | 61 - .../objects/cext/hpy/PythonHPyObject.java | 54 - .../GraalHPyJNICallHelperFunctionNode.java | 76 - .../cext/hpy/jni/GraalHPyJNIContext.java | 3010 ------------- .../hpy/jni/GraalHPyJNIConvertArgNode.java | 180 - .../hpy/jni/GraalHPyJNIFunctionPointer.java | 516 --- .../cext/hpy/jni/GraalHPyJNINodes.java | 848 ---- .../cext/hpy/jni/GraalHPyJNITrampolines.java | 351 -- .../cext/hpy/llvm/GraalHPyInitObject.java | 109 - .../GraalHPyLLVMCallHelperFunctionNode.java | 69 - .../cext/hpy/llvm/GraalHPyLLVMContext.java | 1357 ------ .../cext/hpy/llvm/GraalHPyLLVMNodes.java | 914 ---- .../cext/hpy/llvm/HPyArrayWrappers.java | 337 -- .../hpy/llvm/NativeSpaceArrayWrapper.java | 118 - .../common/HashingCollectionNodes.java | 2 +- .../builtins/objects/object/PythonObject.java | 10 - .../builtins/objects/type/PythonClass.java | 59 - .../python/builtins/objects/type/TpSlots.java | 198 +- .../builtins/objects/type/TypeNodes.java | 29 +- .../objects/type/slots/HPyDispatchers.java | 90 - .../builtins/objects/type/slots/TpSlot.java | 19 +- .../objects/type/slots/TpSlotBinaryFunc.java | 19 - .../objects/type/slots/TpSlotBinaryOp.java | 18 - .../objects/type/slots/TpSlotLen.java | 38 - .../objects/type/slots/TpSlotSizeArgFun.java | 18 - .../graal/python/nodes/ErrorMessages.java | 54 - .../oracle/graal/python/nodes/PGuards.java | 10 - .../graal/python/nodes/StringLiterals.java | 2 - .../graal/python/runtime/NFIPosixSupport.java | 3 +- .../python/runtime/NativeBufferContext.java | 4 +- .../graal/python/runtime/PythonContext.java | 89 +- .../runtime/PythonImageBuildOptions.java | 4 - .../graal/python/runtime/PythonOptions.java | 35 - .../graal/python/runtime/object/PFactory.java | 9 - graalpython/lib-graalpython/_sysconfig.py | 11 +- .../modules/hpy.egg-info/PKG-INFO | 9 - .../modules/hpy.egg-info/SOURCES.txt | 18 - .../modules/hpy.egg-info/dependency_links.txt | 0 .../modules/hpy.egg-info/entry_points.txt | 3 - .../modules/hpy.egg-info/top_level.txt | 1 - .../lib-graalpython/modules/hpy/__init__.py | 39 - .../modules/hpy/debug/__init__.py | 34 - .../modules/hpy/debug/leakdetector.py | 66 - .../modules/hpy/debug/pytest.py | 54 - .../modules/hpy/devel/__init__.py | 496 --- .../modules/hpy/devel/abitag.py | 89 - .../modules/hpy/devel/src/runtime/argparse.c | 843 ---- .../hpy/devel/src/runtime/buildvalue.c | 471 --- .../modules/hpy/devel/src/runtime/ctx_bytes.c | 49 - .../modules/hpy/devel/src/runtime/ctx_call.c | 143 - .../hpy/devel/src/runtime/ctx_capsule.c | 105 - .../hpy/devel/src/runtime/ctx_contextvar.c | 40 - .../modules/hpy/devel/src/runtime/ctx_err.c | 37 - .../modules/hpy/devel/src/runtime/ctx_eval.c | 47 - .../hpy/devel/src/runtime/ctx_listbuilder.c | 86 - .../modules/hpy/devel/src/runtime/ctx_long.c | 143 - .../hpy/devel/src/runtime/ctx_module.c | 176 - .../hpy/devel/src/runtime/ctx_object.c | 117 - .../hpy/devel/src/runtime/ctx_tracker.c | 183 - .../modules/hpy/devel/src/runtime/ctx_tuple.c | 46 - .../hpy/devel/src/runtime/ctx_tuplebuilder.c | 93 - .../modules/hpy/devel/src/runtime/ctx_type.c | 1648 -------- .../modules/hpy/devel/src/runtime/format.c | 761 ---- .../modules/hpy/devel/src/runtime/helpers.c | 189 - .../modules/hpy/devel/src/runtime/structseq.c | 295 -- .../modules/hpy/devel/version.py | 26 - .../modules/hpy/trace/__init__.py | 29 - .../lib-graalpython/modules/hpy/universal.py | 65 - .../modules/standalone/__main__.py | 1 - .../lib-python/3/distutils/ccompiler.py | 2 +- graalpython/lib-python/3/venv/__init__.py | 48 - mx.graalpython/copyrights/overrides | 116 - .../org.eclipse.jdt.core.prefs | 2 +- mx.graalpython/graalpython-svm-standalone | 4 +- mx.graalpython/mx_graalpython.py | 357 +- mx.graalpython/mx_graalpython_benchmark.py | 5 - mx.graalpython/suite.py | 205 +- mx.graalpython/test_json_parsing_data.py | 2 +- scripts/gate_python_quickstyle.sh | 42 - scripts/gate_python_style.sh | 42 - scripts/gate_python_test.sh | 44 - scripts/hpy_autogen_graalpy.py | 1280 ------ 251 files changed, 255 insertions(+), 70100 deletions(-) delete mode 100644 graalpython/com.oracle.graal.python.cext/CEXT-WINDOWS-README.md delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyfunc_declare.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyslot.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpy_types.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_api_impl.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_ctx.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_hpyfunc_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/hpyfunc_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/misc.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/forbid_python_h/Python.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpydef.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyexports.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyfunc.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpymodule.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpytype.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/inline_helpers.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/macros.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/argparse.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/buildvalue.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_funcs.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_module.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_type.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/format.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/helpers.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/structseq.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_ctx.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_hpyfunc_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/hpyfunc_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/misc_trampolines.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/version.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/src/autogen_c_access.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/src/hpy.c delete mode 100644 graalpython/com.oracle.graal.python.hpy.llvm/src/hpynative.h delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/__init__.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/check_py27_compat.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/conftest.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_builder_invalid.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_charptr.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_context_reuse.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_invalid.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_leak.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_misc.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_abitag.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_distutils.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/support.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_00_basic.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_argparse.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_call.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule_legacy.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_contextvar.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_cpy_compat.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_eval.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_helpers.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybuildvalue.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybytes.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpydict.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyerr.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyfield.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyglobal.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyimport.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylist.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylong.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpymodule.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyslice.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpystructseq.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytuple.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype_legacy.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyunicode.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_importing.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_legacy_forbidden.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_number.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_object.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots_legacy.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_support.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_tracker.py delete mode 100644 graalpython/com.oracle.graal.python.hpy.test/src/hpytest/trace/test_trace.py delete mode 100644 graalpython/com.oracle.graal.python.jni/src/autogen_ctx_call_jni.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/autogen_ctx_init_jni.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/autogen_wrappers_jni.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/ctx_builder.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/ctx_call_jni.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/ctx_tracker.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/_debugmod.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_ctx_init.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_wrappers.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_not_cpython.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_tracker.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/debug_handles.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/debug_internal.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/dhqueue.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/hpy_debug.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/include/hpy_debug.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/memprotect.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/debug/stacktrace.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_jni.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_jni.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_log.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_native_cache.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/_tracemod.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_ctx_init.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_func_table.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_wrappers.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/hpy_trace.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/include/hpy_trace.h delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/trace_ctx.c delete mode 100644 graalpython/com.oracle.graal.python.jni/src/trace/trace_internal.h delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/JNIFeature.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyTraceModuleBuiltins.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBoxing.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBuffer.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCAccess.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCField.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyData.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyDef.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyHandle.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyLegacyDef.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeCache.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeSymbol.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPySourceKind.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyTracker.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextMember.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignature.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignatureType.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyMode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyTypeExtra.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/PythonHPyObject.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNICallHelperFunctionNode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIConvertArgNode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIFunctionPointer.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNINodes.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNITrampolines.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyInitObject.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMCallHelperFunctionNode.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMContext.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/HPyArrayWrappers.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/NativeSpaceArrayWrapper.java delete mode 100644 graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/HPyDispatchers.java delete mode 100644 graalpython/lib-graalpython/modules/hpy.egg-info/PKG-INFO delete mode 100644 graalpython/lib-graalpython/modules/hpy.egg-info/SOURCES.txt delete mode 100644 graalpython/lib-graalpython/modules/hpy.egg-info/dependency_links.txt delete mode 100644 graalpython/lib-graalpython/modules/hpy.egg-info/entry_points.txt delete mode 100644 graalpython/lib-graalpython/modules/hpy.egg-info/top_level.txt delete mode 100644 graalpython/lib-graalpython/modules/hpy/__init__.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/debug/__init__.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/debug/leakdetector.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/debug/pytest.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/__init__.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/abitag.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/argparse.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/buildvalue.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_bytes.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_call.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_capsule.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_contextvar.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_err.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_eval.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_listbuilder.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_long.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_module.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_object.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_tracker.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_tuple.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_tuplebuilder.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/ctx_type.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/format.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/helpers.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/src/runtime/structseq.c delete mode 100644 graalpython/lib-graalpython/modules/hpy/devel/version.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/trace/__init__.py delete mode 100644 graalpython/lib-graalpython/modules/hpy/universal.py delete mode 100755 scripts/gate_python_quickstyle.sh delete mode 100755 scripts/gate_python_style.sh delete mode 100755 scripts/gate_python_test.sh delete mode 100644 scripts/hpy_autogen_graalpy.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e23439de..4df2027adc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ language runtime. The main focus is on user-observable behavior of the engine. * `GRAALPY_VERSION_NUM` C macro now inlcudes the release level and serial number at the end to conform to the `hexversion` format. This shouldn't break any existing comparisons. * `dir(foreign_object)` now returns both foreign methods and Python methods (it used to return only foreign methods). * Support `__name__`, `__doc__`, `__text_signature__` fields on foreign executables to serve as their proper counterparts on the Python side. This is useful to, for example, use Java functional interfaces in lieu of Python functions for things like LangChain's `@tool` annotation that want to inspect the underlying function. +* Remove support for running C extensions as LLVM bitcode. This also removes the related options `python.UseSystemToolchain` and `python.NativeModules`. ## Version 24.2.0 * Updated developer metadata of Maven artifacts. diff --git a/docs/contributor/DEV_TASKS.md b/docs/contributor/DEV_TASKS.md index f71fbf7b53..821ba046ed 100644 --- a/docs/contributor/DEV_TASKS.md +++ b/docs/contributor/DEV_TASKS.md @@ -3,7 +3,7 @@ ### Updating dependencies We can use the following command to update our CI jsonnet as well as all -dependencies (truffle, sulong, ...) in one go: +dependencies (truffle, ...) in one go: mx python-update-import @@ -26,35 +26,6 @@ It prints a fairly long help. Note that you'll need to make sure you also pushed your `python-import` branch after doing the update, so that any conflicts you resolved don't have to be resolved again by the next person. -### Updating hpy - -Follow these steps to update HPy. - - - 1. Merge updated hpy sources. To do so, clone hpy somewhere next to - graalpython. Then run the following command on a new branch of graalpython: - - mx python-update-hpy-import --pull /path/to/clone/of/hpy - - Follow the instructions. - 2. We need to fix compilation. We patch the hpy sources, and the merge may - have introduced new API or types, and for these we need to apply - patches. At the time of this writing, we redefine hpy types conditionally - on `#ifdef GRAALVM_PYTHON_LLVM` (grep for this to find some - examples). Also, we use macros to convert between the structured hpy types - and plain pointers for our native interface, see the uses of the `WRAP` and - `UNWRAP` macros. - 3. Once compilation is working, we try to run the tests and go on fixing - them. If new API was added, `GraalHPyContext` needs to be adapted with the - new signatures and/or types. This may include: - - - Updating the HPyContextMember enum - - Updating the HPyContextSignatureType enum - - Adding `GraalHPyContextFunction` implementations for the new APIs - - Updating the `createMembers` method to assign the appropriate - implementations to the context members - - Updating hpy.c to assign new context members to their native locations - ### Updating patch branch GraalPy's `pip` has an ability to download newer versions of patches from our GitHub so that we can update patches outside of the release cycle. There should diff --git a/docs/user/Native-Images-with-Python.md b/docs/user/Native-Images-with-Python.md index 1551b22fcd..1c16f43f66 100644 --- a/docs/user/Native-Images-with-Python.md +++ b/docs/user/Native-Images-with-Python.md @@ -54,7 +54,6 @@ These are: This uses an `ExecutorService` with a thread pool. If you want to disallow such extra threads or avoid pulling in `ExecutorService` and related classes, then set this property to `false` and retrieve the `PollPythonAsyncActions` object from the context's polyglot bindings. This object is executable and can be used to trigger Python asynchronous actions at the locations you desire. -* `python.WithoutJNI=true` - This option removes any code that uses JNI. As a consequence, you cannot use the HPy JNI backend and maybe other parts that rely on JNI. ### Removing Pre-initialized Python Heap diff --git a/graalpython/com.oracle.graal.python.cext/CEXT-WINDOWS-README.md b/graalpython/com.oracle.graal.python.cext/CEXT-WINDOWS-README.md deleted file mode 100644 index 26fb62009f..0000000000 --- a/graalpython/com.oracle.graal.python.cext/CEXT-WINDOWS-README.md +++ /dev/null @@ -1 +0,0 @@ -C extensions on Windows not supported yet diff --git a/graalpython/com.oracle.graal.python.cext/CMakeLists.txt b/graalpython/com.oracle.graal.python.cext/CMakeLists.txt index 6359abef77..bbc34177ce 100644 --- a/graalpython/com.oracle.graal.python.cext/CMakeLists.txt +++ b/graalpython/com.oracle.graal.python.cext/CMakeLists.txt @@ -41,13 +41,9 @@ if(MSVC) message(FATAL_ERROR "C API cannot be built with MSVC") endif() -if(WIN32) - require_var(GRAALVM_LLVM_LIB_DIR) -endif() require_var(GRAALPY_PARENT_DIR) require_var(CAPI_INC_DIR) require_var(PYCONFIG_INCLUDE_DIR) -require_var(TRUFFLE_H_INC) require_var(TRUFFLE_NFI_H_INC) require_var(GRAALPY_EXT) @@ -61,7 +57,7 @@ set(TARGET_LIBPYTHON "python-native") # common variables and compile/link options (for all build targets) ###################################################################### -set(CFLAGS_WARNINGS -Wall -Werror,-Wunknown-warning-option -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable +set(CFLAGS_WARNINGS -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-const-variable -Wno-tautological-constant-out-of-range-compare # fileutils.c: wchar_t > MAX_UNICODE is always false on Windows -Wno-unused-but-set-variable # sqlite.c: BOOL bRc -Wno-ignored-pragmas # sre.c: #pragma optimize("agtw", on) @@ -75,11 +71,8 @@ add_compile_options(-ffile-prefix-map=${GRAALPY_PARENT_DIR}=.) # preprocessor defines for all platforms add_compile_definitions( NDEBUG - GRAALVM_PYTHON_LLVM ) -add_compile_definitions(GRAALVM_PYTHON_LLVM_NATIVE) - if(WIN32) add_compile_definitions( @@ -155,7 +148,6 @@ include_directories( "${SRC_DIR}/include" "${CAPI_INC_DIR}" "${PYCONFIG_INCLUDE_DIR}" - "${TRUFFLE_H_INC}" "${TRUFFLE_NFI_H_INC}" ) @@ -261,9 +253,7 @@ target_compile_definitions(${TARGET_LIBPYTHON} PRIVATE Py_BUILD_CORE Py_BUILD_CO target_compile_options(${TARGET_LIBPYTHON} PRIVATE ${CFLAGS_WARNINGS}) if(WIN32) - target_link_directories(${TARGET_LIBPYTHON} PRIVATE ${GRAALVM_LLVM_LIB_DIR}) target_compile_options(${TARGET_LIBPYTHON} PRIVATE "-fmsc-version=1920") - target_link_libraries(${TARGET_LIBPYTHON} sulong-native graalvm-llvm) else() # Link to math library; required for functions like 'hypot' or similar target_link_libraries(${TARGET_LIBPYTHON} m) diff --git a/graalpython/com.oracle.graal.python.cext/src/capi.c b/graalpython/com.oracle.graal.python.cext/src/capi.c index 1334179769..7031219e48 100644 --- a/graalpython/com.oracle.graal.python.cext/src/capi.c +++ b/graalpython/com.oracle.graal.python.cext/src/capi.c @@ -518,7 +518,7 @@ PyAPI_FUNC(size_t) PyTruffle_GetCurrentRSS() { // Linux FILE* fp = NULL; if ((fp = fopen( "/proc/self/statm", "r" )) != NULL) { - if (fscanf(fp, "%*s%ld", (long) &rss)) { + if (fscanf(fp, "%*s%ld", (long *) &rss)) { rss *= (uint64_t) sysconf( _SC_PAGESIZE); } fclose(fp); @@ -660,12 +660,7 @@ PyAPI_FUNC(int) WriteStringMember(void* object, Py_ssize_t offset, char* value) PyAPI_FUNC(int) WriteStringInPlaceMember(void* object, Py_ssize_t offset, char* value) { char *addr = (char*) (((char*) object) + offset); - size_t n; -// if (polyglot_has_array_elements(value)) { -// n = polyglot_get_array_size(value); -// } else { - n = strlen(value); -// } + size_t n = strlen(value); memcpy(addr, value, n); return 0; } diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt b/graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt deleted file mode 100644 index 86b908fb4e..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -# -# Copyright (c) 2023, 2024, Oracle and/or its affiliates. -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are -# permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this list of -# conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# 3. Neither the name of the copyright holder nor the names of its contributors may be used to -# endorse or promote products derived from this software without specific prior written -# permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -cmake_minimum_required(VERSION 3.22) -project(com.oracle.graal.python.hpy.llvm) - -function(require_var var) - if (NOT DEFINED ${var}) - message(FATAL_ERROR "${var} needs to be set") - endif() -endfunction() - -# default to CMake's source dir if not explicitly provided -if(NOT DEFINED SRC_DIR) - set(SRC_DIR "${CMAKE_SOURCE_DIR}") -endif() - -set(TARGET_LIB "hpy-native") - -# don't install into the system but into the MX project's output dir -set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}) - -require_var(GRAALPY_PARENT_DIR) -require_var(GRAALVM_HPY_INCLUDE_DIR) -require_var(GRAALVM_PYTHON_INCLUDE_DIR) -require_var(PYCONFIG_INCLUDE_DIR) -require_var(TRUFFLE_H_INC) - -set(HPY_SRC "${SRC_DIR}/src") -set(HPY_INC "${SRC_DIR}/include") - -# using glob patterns is not recommended: https://cmake.org/cmake/help/latest/command/file.html#glob -set(SRC_FILES ${HPY_SRC}/hpy.c - ${HPY_SRC}/hpynative.h -) - -set(HPY_HEADERS ${HPY_INC}/hpy/autogen_hpyslot.h - ${HPY_INC}/hpy/version.h - ${HPY_INC}/hpy/hpytype.h - ${HPY_INC}/hpy/universal/hpyfunc_trampolines.h - ${HPY_INC}/hpy/universal/autogen_trampolines.h - ${HPY_INC}/hpy/universal/misc_trampolines.h - ${HPY_INC}/hpy/universal/autogen_ctx.h - ${HPY_INC}/hpy/universal/autogen_hpyfunc_trampolines.h - ${HPY_INC}/hpy/hpydef.h - ${HPY_INC}/hpy/runtime/argparse.h - ${HPY_INC}/hpy/runtime/ctx_type.h - ${HPY_INC}/hpy/runtime/buildvalue.h - ${HPY_INC}/hpy/runtime/ctx_funcs.h - ${HPY_INC}/hpy/runtime/structseq.h - ${HPY_INC}/hpy/runtime/helpers.h - ${HPY_INC}/hpy/inline_helpers.h - ${HPY_INC}/hpy/cpython/hpyfunc_trampolines.h - ${HPY_INC}/hpy/cpython/misc.h - ${HPY_INC}/hpy/cpython/autogen_api_impl.h - ${HPY_INC}/hpy/cpython/autogen_hpyfunc_trampolines.h - ${HPY_INC}/hpy/macros.h - ${HPY_INC}/hpy/hpymodule.h - ${HPY_INC}/hpy/autogen_hpyfunc_declare.h - ${HPY_INC}/hpy/cpy_types.h - ${HPY_INC}/hpy/hpyfunc.h - ${HPY_INC}/hpy.h -) - -add_library(${TARGET_LIB} SHARED) - -target_sources(${TARGET_LIB} PRIVATE ${SRC_FILES} ${HPY_HEADERS}) -target_include_directories(${TARGET_LIB} PRIVATE - "${GRAALVM_HPY_INCLUDE_DIR}" - "${GRAALVM_PYTHON_INCLUDE_DIR}" - "${PYCONFIG_INCLUDE_DIR}" - "${TRUFFLE_H_INC}" -) - -target_compile_definitions(${TARGET_LIB} PRIVATE - HPY_ABI_HYBRID - NDEBUG - GRAALVM_PYTHON_LLVM - Py_BUILD_CORE -) - -if(WIN32) - require_var(GRAALVM_LLVM_LIB_DIR) - target_link_directories(${TARGET_LIB} PRIVATE ${GRAALVM_LLVM_LIB_DIR}) - target_link_libraries(${TARGET_LIB} PRIVATE graalvm-llvm) - # Following defines are for 'Python.h'. Since HPy includes it, we need them. - target_compile_definitions(${TARGET_LIB} PRIVATE - MS_WINDOWS - Py_ENABLE_SHARED - HAVE_DECLSPEC_DLL - ) -endif() - -if(MSVC) - target_compile_options(${TARGET_LIB} PRIVATE /O2 /WX) -else() - if(NOT WIN32) - target_compile_options(${TARGET_LIB} PRIVATE - -Werror - ) - endif() - target_compile_options(${TARGET_LIB} PRIVATE - -ffile-prefix-map=${GRAALPY_PARENT_DIR}=. - -Wno-int-to-pointer-cast - -Wno-int-conversion - -Wno-void-pointer-to-int-cast - -Wno-incompatible-pointer-types-discards-qualifiers - -Wno-pointer-type-mismatch - -Wno-braced-scalar-init - -Wno-deprecated-declarations - ) -endif() - -if(APPLE) - target_link_options(${TARGET_LIB} PRIVATE -undefined dynamic_lookup) -endif() - -install(TARGETS ${TARGET_LIB} DESTINATION bin) diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy.h deleted file mode 100644 index 46afd8ee05..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy.h +++ /dev/null @@ -1,339 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPy_H -#define HPy_H -#ifdef __cplusplus -extern "C" { -#endif - -/* ~~~~~~~~~~~~~~~~ HPy ABI version ~~~~~~~~~~~~~~~ */ -// NOTE: these must be kept on sync with the equivalent variables in hpy/devel/abitag.py -/** - * The ABI version. - * - * Minor version N+1 is binary compatible to minor version N. Major versions - * are not binary compatible (note: HPy can run several binary incompatible - * versions in one process). - */ -#define HPY_ABI_VERSION 0 -#define HPY_ABI_VERSION_MINOR 0 -#define HPY_ABI_TAG "hpy0" - - -/* ~~~~~~~~~~~~~~~~ HPy ABI macros ~~~~~~~~~~~~~~~~ */ - -/* The following macros are used to determine which kind of module we want to - compile. The build system must set one of these (e.g. by using `gcc - -D...`). This is the approach used by the setuptools support provided by - hpy.devel: - - - HPY_ABI_CPYTHON - - HPY_ABI_UNIVERSAL - - HPY_ABI_HYBRID - - In addition we also define HPY_ABI which is a string literal containing a - string representation of it. -*/ - -#if defined(HPY_ABI_CPYTHON) -# if defined(HPY_ABI_HYBRID) -# error "Conflicting macros are defined: HPY_ABI_CPYTHON and HPY_ABI_HYBRID" -# endif -# if defined(HPY_ABI_UNIVERSAL) -# error "Conflicting macros are defined: HPY_ABI_CPYTHON and HPY_ABI_UNIVERSAL" -# endif -# define HPY_ABI "cpython" - -#elif defined(HPY_ABI_HYBRID) -# if defined(HPY_ABI_UNIVERSAL) -# error "Conflicting macros are defined: HPY_ABI_HYBRID and HPY_ABI_UNIVERSAL" -# endif -# define HPY_ABI "hybrid" - -#elif defined(HPY_ABI_UNIVERSAL) -# define HPY_ABI "universal" - -#else -# error "Cannot determine the desired HPy ABI: you must set one of HPY_ABI_CPYTHON, HPY_ABI_UNIVERSAL or HPY_ABI_HYBRID" -#endif - - -#if defined(HPY_ABI_CPYTHON) || defined(HPY_ABI_HYBRID) -# define PY_SSIZE_T_CLEAN -# include -#endif - -#include -#include -#include - -/* ~~~~~~~~~~~~~~~~ useful macros ~~~~~~~~~~~~~~~~ */ - -#ifdef __GNUC__ -# define _HPy_HIDDEN __attribute__((visibility("hidden"))) -# define _HPy_UNUSED __attribute__((unused)) -#else -# define _HPy_HIDDEN -# define _HPy_UNUSED -#endif /* __GNUC__ */ -#define _HPy_UNUSED_ARG(x) (__HPy_UNUSED_TAGGED ## x) _HPy_UNUSED - -#if defined(__clang__) || \ - (defined(__GNUC__) && \ - ((__GNUC__ >= 3) || \ - (__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))) -# define _HPy_NO_RETURN __attribute__((__noreturn__)) -#elif defined(_MSC_VER) -# define _HPy_NO_RETURN __declspec(noreturn) -#else -# define _HPy_NO_RETURN -#endif - - -// clang and gcc supports __has_attribute, MSVC doesn't. This should be enough -// to be able to use it portably -#ifdef __has_attribute -# define _HPY_compiler_has_attribute(x) __has_attribute(x) -#else -# define _HPY_compiler_has_attribute(x) 0 -#endif - -#ifdef HPY_ABI_UNIVERSAL -# if _HPY_compiler_has_attribute(error) - // gcc, clang>=14 -# define _HPY_LEGACY __attribute__((error("Cannot use legacy functions when targeting the HPy Universal ABI"))) -# else - // we don't have any diagnostic feature, too bad -# define _HPY_LEGACY -# endif -#else - // in non-universal modes, we don't attach any attribute -# define _HPY_LEGACY -#endif - -#if defined(_MSC_VER) && defined(__cplusplus) // MSVC C4576 -# define _hconv(h) {h} -# define _hfconv(h) {h} -# define _htsconv(h) {h} -# define _hgconv(h) {h} -#else -# define _hconv(h) ((HPy){h}) -# define _hfconv(h) ((HPyField){h}) -# define _htsconv(h) ((HPyThreadState){h}) -# define _hgconv(h) ((HPyGlobal){h}) -#endif -/* ~~~~~~~~~~~~~~~~ HPyAPI declaration ~~~~~~~~~~~~~~~~ */ - -/* We have three different kind of API functions: */ - -/** - * Public API functions which are exposed to the user, e.g. - * ``HPy_Add`` or ``HPyType_FromSpec``. Generally speaking they are - * thin shims dispatching to the actual implementation: - * - * * In CPython-ABI mode they directly call the corresponding Py* or - * ``HPyAPI_IMPL`` equivalent, e.g. ``PyObject_Add`` or - * ``ctx_Type_FromSpec``. - * - * * In Universal-ABI mode, they always resolve to an indirect call - * through ``HPyContext *``, i.e. ``ctx->ctx_Add(...)``, which on CPython - * dispaches to ``ctx_Add``. - */ -#define HPyAPI_FUNC _HPy_UNUSED static inline - -/** An alias for ``HPyAPI_FUNC`` so we can handle it properly in the docs. */ -#define HPyAPI_INLINE_HELPER HPyAPI_FUNC - -/** - * CPython implementations for ``HPyAPI_FUNC`` - * functions. Generally speaking, they are put in ctx_*.c files and they are - * prefixed by ctx\_. - * - * Some of these functions are needed by the CPython ABI mode, and by - * CPython's implementation of hpy.universal: these can be found in - * hpy/devel/src/runtime/ctx_*.c, e.g. ``ctx_Type_FromSpec`` and - * ``ctx_Tuple_FromArray``. - * - * Some other are used ONLY by ``hpy.universal`` and can be found in - * hpy/universal/src/ctx_*.c. - */ -#define HPyAPI_IMPL _HPy_HIDDEN - -/** - * These functions are part of the public API but **not** of - * the ABI. They are helpers which are meant to be compiled togeher with every - * extension. E.g. ``HPyArg_Parse`` and ``HPyHelpers_AddType``. - */ -#define HPyAPI_HELPER _HPy_HIDDEN - - -/* ~~~~~~~~~~~~~~~~ Definition of the type HPy ~~~~~~~~~~~~~~~~ */ - -/* HPy handles are fully opaque: depending on the implementation, the _i can - be either an integer or a pointer. A few examples: - - * in CPython ABI mode, ._i is a PyObject* - - * in Universal ABI mode, the meaning of ._i depends on the implementation: - - - CPython (i.e., the code in hpy/universal/src/): ._i is the bitwise - invert of a PyObject* - - - PyPy: ._i is an index into a list - - - GraalPy: ._i is a tagged value, either an index into a list, - or an immediate integer or double value - - - Debug mode: _i is a pointer to a DebugHandle, which contains a - another HPy among other stuff - */ -#ifndef GRAALVM_PYTHON_LLVM -typedef struct _HPy_s { intptr_t _i; } HPy; -typedef struct { intptr_t _i; } HPyField; -typedef struct { intptr_t _i; } HPyGlobal; -typedef struct { intptr_t _lst; } HPyListBuilder; -typedef struct { intptr_t _tup; } HPyTupleBuilder; -typedef struct { intptr_t _i; } HPyTracker; -typedef struct { intptr_t _i; } HPyThreadState; -#else -typedef struct _HPy_s { void* _i; } HPy; -typedef struct { void* _i; } HPyField; -typedef struct { void* _i; } HPyGlobal; -typedef struct { void* _lst; } HPyListBuilder; -typedef struct { void* _tup; } HPyTupleBuilder; -typedef struct { void* _i; } HPyTracker; -typedef struct { void* _i; } HPyThreadState; -#endif - - -/* A null handle is officially defined as a handle whose _i is 0. This is true - in all ABI modes. */ -#ifndef GRAALVM_PYTHON_LLVM -#define HPy_NULL _hconv(0) -#define HPy_IsNull(h) ((h)._i == 0) -#else -#define HPy_NULL _hconv(NULL) -#define HPy_IsNull(h) ((h)._i == NULL) -#endif - -#define HPyListBuilder_IsNull(h) ((h)._lst == 0) -#define HPyTupleBuilder_IsNull(h) ((h)._tup == 0) - -#define HPyField_NULL _hfconv(0) -#define HPyField_IsNull(f) ((f)._i == 0) - -/* Convenience functions to cast between HPy and void*. We need to decide - whether these are part of the official API or not, and maybe introduce a - better naming convention. For now, they are needed for ujson. */ -#ifndef GRAALVM_PYTHON_LLVM -static inline HPy HPy_FromVoidP(void *p) { return _hconv((intptr_t)p); } -static inline void* HPy_AsVoidP(HPy h) { return (void*)h._i; } -#else -static inline HPy HPy_FromVoidP(void *p) { return _hconv(p); } -static inline void* HPy_AsVoidP(HPy h) { return h._i; } -#endif - - -/* ~~~~~~~~~~~~~~~~ Definition of other types ~~~~~~~~~~~~~~~~ */ - -typedef struct _HPyContext_s HPyContext; - -/** An enumeration of the different kinds of source code strings. */ -typedef enum { - /** Parse isolated expressions (e.g. ``a + b``). */ - HPy_SourceKind_Expr = 0, - - /** - * Parse sequences of statements as read from a file or other source. This - * is the symbol to use when compiling arbitrarily long Python source code. - */ - HPy_SourceKind_File = 1, - - /** - * Parse a single statement. This is the mode used for the interactive - * interpreter loop. - */ - HPy_SourceKind_Single = 2, -} HPy_SourceKind; - -#ifdef HPY_ABI_CPYTHON - typedef Py_ssize_t HPy_ssize_t; - typedef Py_hash_t HPy_hash_t; - typedef Py_UCS4 HPy_UCS4; - -# define HPY_SSIZE_T_MAX PY_SSIZE_T_MAX -# define HPY_SSIZE_T_MIN PY_SSIZE_T_MIN - -#else - typedef intptr_t HPy_ssize_t; - typedef intptr_t HPy_hash_t; - typedef uint32_t HPy_UCS4; - -# define HPY_SSIZE_T_MAX INTPTR_MAX -# define HPY_SSIZE_T_MIN (-HPY_SSIZE_T_MAX-1) - - /* HPyCapsule field keys */ - typedef enum { - HPyCapsule_key_Pointer = 0, - HPyCapsule_key_Name = 1, - HPyCapsule_key_Context = 2, - HPyCapsule_key_Destructor = 3, - } _HPyCapsule_key; -#endif - - -/* ~~~~~~~~~~~~~~~~ Additional #includes ~~~~~~~~~~~~~~~~ */ - -#include "hpy/cpy_types.h" -#include "hpy/hpyexports.h" -#include "hpy/macros.h" -#include "hpy/hpyfunc.h" -#include "hpy/hpydef.h" -#include "hpy/hpytype.h" -#include "hpy/hpymodule.h" -#include "hpy/runtime/argparse.h" -#include "hpy/runtime/buildvalue.h" -#include "hpy/runtime/format.h" -#include "hpy/runtime/helpers.h" -#include "hpy/runtime/structseq.h" - -#ifdef HPY_ABI_CPYTHON -# include "hpy/cpython/autogen_ctx.h" -# include "hpy/runtime/ctx_funcs.h" -# include "hpy/runtime/ctx_type.h" -# include "hpy/cpython/misc.h" -# include "hpy/cpython/autogen_api_impl.h" -#else -# include "hpy/universal/autogen_ctx.h" -# include "hpy/universal/autogen_trampolines.h" -# include "hpy/universal/misc_trampolines.h" -#endif - -#include "hpy/inline_helpers.h" - -#ifdef __cplusplus -} -#endif -#endif /* HPy_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyfunc_declare.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyfunc_declare.h deleted file mode 100644 index ab9ac55e5e..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyfunc_declare.h +++ /dev/null @@ -1,111 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_hpyfunc_declare_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#define _HPyFunc_DECLARE_HPyFunc_NOARGS(SYM) static HPy SYM(HPyContext *ctx, HPy self) -#define _HPyFunc_DECLARE_HPyFunc_O(SYM) static HPy SYM(HPyContext *ctx, HPy self, HPy arg) -#define _HPyFunc_DECLARE_HPyFunc_VARARGS(SYM) static HPy SYM(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) -#define _HPyFunc_DECLARE_HPyFunc_KEYWORDS(SYM) static HPy SYM(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames) -#define _HPyFunc_DECLARE_HPyFunc_UNARYFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_BINARYFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_TERNARYFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_INQUIRY(SYM) static int SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_LENFUNC(SYM) static HPy_ssize_t SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_SSIZEARGFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy_ssize_t) -#define _HPyFunc_DECLARE_HPyFunc_SSIZESSIZEARGFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t) -#define _HPyFunc_DECLARE_HPyFunc_SSIZEOBJARGPROC(SYM) static int SYM(HPyContext *ctx, HPy, HPy_ssize_t, HPy) -#define _HPyFunc_DECLARE_HPyFunc_SSIZESSIZEOBJARGPROC(SYM) static int SYM(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t, HPy) -#define _HPyFunc_DECLARE_HPyFunc_OBJOBJARGPROC(SYM) static int SYM(HPyContext *ctx, HPy, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_FREEFUNC(SYM) static void SYM(HPyContext *ctx, void *) -#define _HPyFunc_DECLARE_HPyFunc_GETATTRFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, char *) -#define _HPyFunc_DECLARE_HPyFunc_GETATTROFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_SETATTRFUNC(SYM) static int SYM(HPyContext *ctx, HPy, char *, HPy) -#define _HPyFunc_DECLARE_HPyFunc_SETATTROFUNC(SYM) static int SYM(HPyContext *ctx, HPy, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_REPRFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_HASHFUNC(SYM) static HPy_hash_t SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_RICHCMPFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp) -#define _HPyFunc_DECLARE_HPyFunc_GETITERFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_ITERNEXTFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_DESCRGETFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_DESCRSETFUNC(SYM) static int SYM(HPyContext *ctx, HPy, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_INITPROC(SYM) static int SYM(HPyContext *ctx, HPy self, const HPy *args, HPy_ssize_t nargs, HPy kw) -#define _HPyFunc_DECLARE_HPyFunc_NEWFUNC(SYM) static HPy SYM(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) -#define _HPyFunc_DECLARE_HPyFunc_GETTER(SYM) static HPy SYM(HPyContext *ctx, HPy, void *) -#define _HPyFunc_DECLARE_HPyFunc_SETTER(SYM) static int SYM(HPyContext *ctx, HPy, HPy, void *) -#define _HPyFunc_DECLARE_HPyFunc_OBJOBJPROC(SYM) static int SYM(HPyContext *ctx, HPy, HPy) -#define _HPyFunc_DECLARE_HPyFunc_GETBUFFERPROC(SYM) static int SYM(HPyContext *ctx, HPy, HPy_buffer *, int) -#define _HPyFunc_DECLARE_HPyFunc_RELEASEBUFFERPROC(SYM) static void SYM(HPyContext *ctx, HPy, HPy_buffer *) -#define _HPyFunc_DECLARE_HPyFunc_TRAVERSEPROC(SYM) static int SYM(void *object, HPyFunc_visitproc visit, void *arg) -#define _HPyFunc_DECLARE_HPyFunc_DESTRUCTOR(SYM) static void SYM(HPyContext *ctx, HPy) -#define _HPyFunc_DECLARE_HPyFunc_DESTROYFUNC(SYM) static void SYM(void *) -#define _HPyFunc_DECLARE_HPyFunc_MOD_CREATE(SYM) static HPy SYM(HPyContext *ctx, HPy) - -typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self); -typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg); -typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs); -typedef HPy (*HPyFunc_keywords)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames); -typedef HPy (*HPyFunc_unaryfunc)(HPyContext *ctx, HPy); -typedef HPy (*HPyFunc_binaryfunc)(HPyContext *ctx, HPy, HPy); -typedef HPy (*HPyFunc_ternaryfunc)(HPyContext *ctx, HPy, HPy, HPy); -typedef int (*HPyFunc_inquiry)(HPyContext *ctx, HPy); -typedef HPy_ssize_t (*HPyFunc_lenfunc)(HPyContext *ctx, HPy); -typedef HPy (*HPyFunc_ssizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t); -typedef HPy (*HPyFunc_ssizessizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t); -typedef int (*HPyFunc_ssizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy); -typedef int (*HPyFunc_ssizessizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t, HPy); -typedef int (*HPyFunc_objobjargproc)(HPyContext *ctx, HPy, HPy, HPy); -typedef void (*HPyFunc_freefunc)(HPyContext *ctx, void *); -typedef HPy (*HPyFunc_getattrfunc)(HPyContext *ctx, HPy, char *); -typedef HPy (*HPyFunc_getattrofunc)(HPyContext *ctx, HPy, HPy); -typedef int (*HPyFunc_setattrfunc)(HPyContext *ctx, HPy, char *, HPy); -typedef int (*HPyFunc_setattrofunc)(HPyContext *ctx, HPy, HPy, HPy); -typedef HPy (*HPyFunc_reprfunc)(HPyContext *ctx, HPy); -typedef HPy_hash_t (*HPyFunc_hashfunc)(HPyContext *ctx, HPy); -typedef HPy (*HPyFunc_richcmpfunc)(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp); -typedef HPy (*HPyFunc_getiterfunc)(HPyContext *ctx, HPy); -typedef HPy (*HPyFunc_iternextfunc)(HPyContext *ctx, HPy); -typedef HPy (*HPyFunc_descrgetfunc)(HPyContext *ctx, HPy, HPy, HPy); -typedef int (*HPyFunc_descrsetfunc)(HPyContext *ctx, HPy, HPy, HPy); -typedef int (*HPyFunc_initproc)(HPyContext *ctx, HPy self, const HPy *args, HPy_ssize_t nargs, HPy kw); -typedef HPy (*HPyFunc_newfunc)(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw); -typedef HPy (*HPyFunc_getter)(HPyContext *ctx, HPy, void *); -typedef int (*HPyFunc_setter)(HPyContext *ctx, HPy, HPy, void *); -typedef int (*HPyFunc_objobjproc)(HPyContext *ctx, HPy, HPy); -typedef int (*HPyFunc_getbufferproc)(HPyContext *ctx, HPy, HPy_buffer *, int); -typedef void (*HPyFunc_releasebufferproc)(HPyContext *ctx, HPy, HPy_buffer *); -typedef int (*HPyFunc_traverseproc)(void *object, HPyFunc_visitproc visit, void *arg); -typedef void (*HPyFunc_destructor)(HPyContext *ctx, HPy); -typedef void (*HPyFunc_destroyfunc)(void *); -typedef HPy (*HPyFunc_mod_create)(HPyContext *ctx, HPy); diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyslot.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyslot.h deleted file mode 100644 index 6d04c4f27a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/autogen_hpyslot.h +++ /dev/null @@ -1,159 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.hpyslot.autogen_hpyslot_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -typedef enum { - HPy_bf_getbuffer = 1, - HPy_bf_releasebuffer = 2, - HPy_mp_ass_subscript = 3, - HPy_mp_length = 4, - HPy_mp_subscript = 5, - HPy_nb_absolute = 6, - HPy_nb_add = 7, - HPy_nb_and = 8, - HPy_nb_bool = 9, - HPy_nb_divmod = 10, - HPy_nb_float = 11, - HPy_nb_floor_divide = 12, - HPy_nb_index = 13, - HPy_nb_inplace_add = 14, - HPy_nb_inplace_and = 15, - HPy_nb_inplace_floor_divide = 16, - HPy_nb_inplace_lshift = 17, - HPy_nb_inplace_multiply = 18, - HPy_nb_inplace_or = 19, - HPy_nb_inplace_power = 20, - HPy_nb_inplace_remainder = 21, - HPy_nb_inplace_rshift = 22, - HPy_nb_inplace_subtract = 23, - HPy_nb_inplace_true_divide = 24, - HPy_nb_inplace_xor = 25, - HPy_nb_int = 26, - HPy_nb_invert = 27, - HPy_nb_lshift = 28, - HPy_nb_multiply = 29, - HPy_nb_negative = 30, - HPy_nb_or = 31, - HPy_nb_positive = 32, - HPy_nb_power = 33, - HPy_nb_remainder = 34, - HPy_nb_rshift = 35, - HPy_nb_subtract = 36, - HPy_nb_true_divide = 37, - HPy_nb_xor = 38, - HPy_sq_ass_item = 39, - HPy_sq_concat = 40, - HPy_sq_contains = 41, - HPy_sq_inplace_concat = 42, - HPy_sq_inplace_repeat = 43, - HPy_sq_item = 44, - HPy_sq_length = 45, - HPy_sq_repeat = 46, - HPy_tp_call = 50, - HPy_tp_hash = 59, - HPy_tp_init = 60, - HPy_tp_new = 65, - HPy_tp_repr = 66, - HPy_tp_richcompare = 67, - HPy_tp_str = 70, - HPy_tp_traverse = 71, - HPy_nb_matrix_multiply = 75, - HPy_nb_inplace_matrix_multiply = 76, - HPy_tp_finalize = 80, - HPy_tp_destroy = 1000, - HPy_mod_create = 2000, - HPy_mod_exec = 2001, -} HPySlot_Slot; - -#define _HPySlot_SIG__HPy_bf_getbuffer HPyFunc_GETBUFFERPROC -#define _HPySlot_SIG__HPy_bf_releasebuffer HPyFunc_RELEASEBUFFERPROC -#define _HPySlot_SIG__HPy_mp_ass_subscript HPyFunc_OBJOBJARGPROC -#define _HPySlot_SIG__HPy_mp_length HPyFunc_LENFUNC -#define _HPySlot_SIG__HPy_mp_subscript HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_absolute HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_add HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_and HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_bool HPyFunc_INQUIRY -#define _HPySlot_SIG__HPy_nb_divmod HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_float HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_floor_divide HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_index HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_add HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_and HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_floor_divide HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_lshift HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_multiply HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_or HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_power HPyFunc_TERNARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_remainder HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_rshift HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_subtract HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_true_divide HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_xor HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_int HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_invert HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_lshift HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_multiply HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_negative HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_or HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_positive HPyFunc_UNARYFUNC -#define _HPySlot_SIG__HPy_nb_power HPyFunc_TERNARYFUNC -#define _HPySlot_SIG__HPy_nb_remainder HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_rshift HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_subtract HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_true_divide HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_xor HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_sq_ass_item HPyFunc_SSIZEOBJARGPROC -#define _HPySlot_SIG__HPy_sq_concat HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_sq_contains HPyFunc_OBJOBJPROC -#define _HPySlot_SIG__HPy_sq_inplace_concat HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_sq_inplace_repeat HPyFunc_SSIZEARGFUNC -#define _HPySlot_SIG__HPy_sq_item HPyFunc_SSIZEARGFUNC -#define _HPySlot_SIG__HPy_sq_length HPyFunc_LENFUNC -#define _HPySlot_SIG__HPy_sq_repeat HPyFunc_SSIZEARGFUNC -#define _HPySlot_SIG__HPy_tp_call HPyFunc_KEYWORDS -#define _HPySlot_SIG__HPy_tp_hash HPyFunc_HASHFUNC -#define _HPySlot_SIG__HPy_tp_init HPyFunc_INITPROC -#define _HPySlot_SIG__HPy_tp_new HPyFunc_NEWFUNC -#define _HPySlot_SIG__HPy_tp_repr HPyFunc_REPRFUNC -#define _HPySlot_SIG__HPy_tp_richcompare HPyFunc_RICHCMPFUNC -#define _HPySlot_SIG__HPy_tp_str HPyFunc_REPRFUNC -#define _HPySlot_SIG__HPy_tp_traverse HPyFunc_TRAVERSEPROC -#define _HPySlot_SIG__HPy_nb_matrix_multiply HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_nb_inplace_matrix_multiply HPyFunc_BINARYFUNC -#define _HPySlot_SIG__HPy_tp_finalize HPyFunc_DESTRUCTOR -#define _HPySlot_SIG__HPy_tp_destroy HPyFunc_DESTROYFUNC -#define _HPySlot_SIG__HPy_mod_create HPyFunc_MOD_CREATE -#define _HPySlot_SIG__HPy_mod_exec HPyFunc_INQUIRY diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpy_types.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpy_types.h deleted file mode 100644 index fd2efc7ad8..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpy_types.h +++ /dev/null @@ -1,73 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_CPY_TYPES_H -#define HPY_UNIVERSAL_CPY_TYPES_H - -/* ~~~~~~~~~~~~~~~~ CPython legacy types ~~~~~~~~~~~~~~~~ */ - -/* These are the types which are needed to implement legacy features such as - .legacy_slots, .legacy_methods, HPy_FromPyObject, HPy_AsPyObject, etc. - - In cpython and hybrid ABI mode we can #include Python.h and use the "real" - types. - - In universal ABI mode, legacy features cannot be used, but we still need - the corresponding C types to use in the HPy declarations. Note that we use - only forward declarations, meaning that it will actually be impossible to - instantiate any of these struct. -*/ - -#ifdef HPY_ABI_UNIVERSAL - -typedef struct FORBIDDEN_cpy_PyObject cpy_PyObject; -typedef struct FORBIDDEN_PyMethodDef cpy_PyMethodDef; -typedef struct FORBIDDEN_PyModuleDef cpy_PyModuleDef; -typedef struct FORBIDDEN_bufferinfo cpy_Py_buffer; - -// declare the following API functions as _HPY_LEGACY, which triggers an -// #error if they are used -HPyAPI_FUNC _HPY_LEGACY cpy_PyObject *HPy_AsPyObject(HPyContext *ctx, HPy h); -HPyAPI_FUNC _HPY_LEGACY HPy HPy_FromPyObject(HPyContext *ctx, cpy_PyObject *obj); - -#else - -// Python.h has already been included by the main hpy.h -typedef PyObject cpy_PyObject; -typedef PyMethodDef cpy_PyMethodDef; -typedef PyModuleDef cpy_PyModuleDef; -typedef Py_buffer cpy_Py_buffer; - -#endif /* HPY_ABI_UNIVERSAL */ - - -typedef cpy_PyObject *(*cpy_PyCFunction)(cpy_PyObject *, cpy_PyObject *const *, HPy_ssize_t); -typedef int (*cpy_visitproc)(cpy_PyObject *, void *); -typedef cpy_PyObject *(*cpy_getter)(cpy_PyObject *, void *); -typedef int (*cpy_setter)(cpy_PyObject *, cpy_PyObject *, void *); -typedef void (*cpy_PyCapsule_Destructor)(cpy_PyObject *); -typedef cpy_PyObject *(*cpy_vectorcallfunc)(cpy_PyObject *callable, cpy_PyObject *const *args, - size_t nargsf, cpy_PyObject *kwnames); - -#endif /* HPY_UNIVERSAL_CPY_TYPES_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_api_impl.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_api_impl.h deleted file mode 100644 index 9016982e7a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_api_impl.h +++ /dev/null @@ -1,605 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.trampolines.cpython_autogen_api_impl_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -HPyAPI_FUNC HPy HPyLong_FromSize_t(HPyContext *ctx, size_t value) -{ - return _py2h(PyLong_FromSize_t(value)); -} - -HPyAPI_FUNC HPy HPyLong_FromSsize_t(HPyContext *ctx, HPy_ssize_t value) -{ - return _py2h(PyLong_FromSsize_t(value)); -} - -HPyAPI_FUNC size_t HPyLong_AsSize_t(HPyContext *ctx, HPy h) -{ - return PyLong_AsSize_t(_h2py(h)); -} - -HPyAPI_FUNC HPy_ssize_t HPyLong_AsSsize_t(HPyContext *ctx, HPy h) -{ - return PyLong_AsSsize_t(_h2py(h)); -} - -HPyAPI_FUNC void *HPyLong_AsVoidPtr(HPyContext *ctx, HPy h) -{ - return PyLong_AsVoidPtr(_h2py(h)); -} - -HPyAPI_FUNC double HPyLong_AsDouble(HPyContext *ctx, HPy h) -{ - return PyLong_AsDouble(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyFloat_FromDouble(HPyContext *ctx, double v) -{ - return _py2h(PyFloat_FromDouble(v)); -} - -HPyAPI_FUNC double HPyFloat_AsDouble(HPyContext *ctx, HPy h) -{ - return PyFloat_AsDouble(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyBool_FromBool(HPyContext *ctx, bool v) -{ - return _py2h(PyBool_FromLong(v)); -} - -HPyAPI_FUNC HPy_ssize_t HPy_Length(HPyContext *ctx, HPy h) -{ - return PyObject_Length(_h2py(h)); -} - -HPyAPI_FUNC int HPyNumber_Check(HPyContext *ctx, HPy h) -{ - return PyNumber_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy HPy_Add(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Add(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Subtract(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Subtract(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Multiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Multiply(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_MatrixMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_MatrixMultiply(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_FloorDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_FloorDivide(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_TrueDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_TrueDivide(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Remainder(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Remainder(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Divmod(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Divmod(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Power(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return _py2h(PyNumber_Power(_h2py(h1), _h2py(h2), _h2py(h3))); -} - -HPyAPI_FUNC HPy HPy_Negative(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Negative(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Positive(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Positive(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Absolute(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Absolute(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Invert(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Invert(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Lshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Lshift(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Rshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Rshift(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_And(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_And(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Xor(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Xor(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Or(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_Or(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_Index(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Index(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Long(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Long(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_Float(HPyContext *ctx, HPy h1) -{ - return _py2h(PyNumber_Float(_h2py(h1))); -} - -HPyAPI_FUNC HPy HPy_InPlaceAdd(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceAdd(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceSubtract(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceSubtract(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceMultiply(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceMatrixMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceMatrixMultiply(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceFloorDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceFloorDivide(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceTrueDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceTrueDivide(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceRemainder(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceRemainder(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlacePower(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return _py2h(PyNumber_InPlacePower(_h2py(h1), _h2py(h2), _h2py(h3))); -} - -HPyAPI_FUNC HPy HPy_InPlaceLshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceLshift(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceRshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceRshift(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceAnd(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceAnd(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceXor(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceXor(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC HPy HPy_InPlaceOr(HPyContext *ctx, HPy h1, HPy h2) -{ - return _py2h(PyNumber_InPlaceOr(_h2py(h1), _h2py(h2))); -} - -HPyAPI_FUNC int HPyCallable_Check(HPyContext *ctx, HPy h) -{ - return PyCallable_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyErr_SetString(HPyContext *ctx, HPy h_type, const char *utf8_message) -{ - PyErr_SetString(_h2py(h_type), utf8_message); - return HPy_NULL; -} - -HPyAPI_FUNC HPy HPyErr_SetObject(HPyContext *ctx, HPy h_type, HPy h_value) -{ - PyErr_SetObject(_h2py(h_type), _h2py(h_value)); - return HPy_NULL; -} - -HPyAPI_FUNC HPy HPyErr_SetFromErrnoWithFilename(HPyContext *ctx, HPy h_type, const char *filename_fsencoded) -{ - return _py2h(PyErr_SetFromErrnoWithFilename(_h2py(h_type), filename_fsencoded)); -} - -HPyAPI_FUNC HPy HPyErr_SetFromErrnoWithFilenameObjects(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2) -{ - PyErr_SetFromErrnoWithFilenameObjects(_h2py(h_type), _h2py(filename1), _h2py(filename2)); - return HPy_NULL; -} - -HPyAPI_FUNC int HPyErr_ExceptionMatches(HPyContext *ctx, HPy exc) -{ - return PyErr_ExceptionMatches(_h2py(exc)); -} - -HPyAPI_FUNC HPy HPyErr_NoMemory(HPyContext *ctx) -{ - PyErr_NoMemory(); - return HPy_NULL; -} - -HPyAPI_FUNC void HPyErr_Clear(HPyContext *ctx) -{ - PyErr_Clear(); -} - -HPyAPI_FUNC HPy HPyErr_NewException(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict) -{ - return _py2h(PyErr_NewException(utf8_name, _h2py(base), _h2py(dict))); -} - -HPyAPI_FUNC HPy HPyErr_NewExceptionWithDoc(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict) -{ - return _py2h(PyErr_NewExceptionWithDoc(utf8_name, utf8_doc, _h2py(base), _h2py(dict))); -} - -HPyAPI_FUNC int HPyErr_WarnEx(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level) -{ - return PyErr_WarnEx(_h2py(category), utf8_message, stack_level); -} - -HPyAPI_FUNC void HPyErr_WriteUnraisable(HPyContext *ctx, HPy obj) -{ - PyErr_WriteUnraisable(_h2py(obj)); -} - -HPyAPI_FUNC int HPy_IsTrue(HPyContext *ctx, HPy h) -{ - return PyObject_IsTrue(_h2py(h)); -} - -HPyAPI_FUNC HPy HPy_GetAttr(HPyContext *ctx, HPy obj, HPy name) -{ - return _py2h(PyObject_GetAttr(_h2py(obj), _h2py(name))); -} - -HPyAPI_FUNC HPy HPy_GetAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return _py2h(PyObject_GetAttrString(_h2py(obj), utf8_name)); -} - -HPyAPI_FUNC int HPy_HasAttr(HPyContext *ctx, HPy obj, HPy name) -{ - return PyObject_HasAttr(_h2py(obj), _h2py(name)); -} - -HPyAPI_FUNC int HPy_HasAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return PyObject_HasAttrString(_h2py(obj), utf8_name); -} - -HPyAPI_FUNC int HPy_SetAttr(HPyContext *ctx, HPy obj, HPy name, HPy value) -{ - return PyObject_SetAttr(_h2py(obj), _h2py(name), _h2py(value)); -} - -HPyAPI_FUNC int HPy_SetAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name, HPy value) -{ - return PyObject_SetAttrString(_h2py(obj), utf8_name, _h2py(value)); -} - -HPyAPI_FUNC HPy HPy_GetItem(HPyContext *ctx, HPy obj, HPy key) -{ - return _py2h(PyObject_GetItem(_h2py(obj), _h2py(key))); -} - -HPyAPI_FUNC int HPy_Contains(HPyContext *ctx, HPy container, HPy key) -{ - return PySequence_Contains(_h2py(container), _h2py(key)); -} - -HPyAPI_FUNC int HPy_SetItem(HPyContext *ctx, HPy obj, HPy key, HPy value) -{ - return PyObject_SetItem(_h2py(obj), _h2py(key), _h2py(value)); -} - -HPyAPI_FUNC int HPy_DelItem(HPyContext *ctx, HPy obj, HPy key) -{ - return PyObject_DelItem(_h2py(obj), _h2py(key)); -} - -HPyAPI_FUNC HPy HPy_Type(HPyContext *ctx, HPy obj) -{ - return _py2h(PyObject_Type(_h2py(obj))); -} - -HPyAPI_FUNC HPy HPy_Repr(HPyContext *ctx, HPy obj) -{ - return _py2h(PyObject_Repr(_h2py(obj))); -} - -HPyAPI_FUNC HPy HPy_Str(HPyContext *ctx, HPy obj) -{ - return _py2h(PyObject_Str(_h2py(obj))); -} - -HPyAPI_FUNC HPy HPy_ASCII(HPyContext *ctx, HPy obj) -{ - return _py2h(PyObject_ASCII(_h2py(obj))); -} - -HPyAPI_FUNC HPy HPy_Bytes(HPyContext *ctx, HPy obj) -{ - return _py2h(PyObject_Bytes(_h2py(obj))); -} - -HPyAPI_FUNC HPy HPy_RichCompare(HPyContext *ctx, HPy v, HPy w, int op) -{ - return _py2h(PyObject_RichCompare(_h2py(v), _h2py(w), op)); -} - -HPyAPI_FUNC int HPy_RichCompareBool(HPyContext *ctx, HPy v, HPy w, int op) -{ - return PyObject_RichCompareBool(_h2py(v), _h2py(w), op); -} - -HPyAPI_FUNC HPy_hash_t HPy_Hash(HPyContext *ctx, HPy obj) -{ - return PyObject_Hash(_h2py(obj)); -} - -HPyAPI_FUNC int HPyBytes_Check(HPyContext *ctx, HPy h) -{ - return PyBytes_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy_ssize_t HPyBytes_Size(HPyContext *ctx, HPy h) -{ - return PyBytes_Size(_h2py(h)); -} - -HPyAPI_FUNC HPy_ssize_t HPyBytes_GET_SIZE(HPyContext *ctx, HPy h) -{ - return PyBytes_GET_SIZE(_h2py(h)); -} - -HPyAPI_FUNC const char *HPyBytes_AsString(HPyContext *ctx, HPy h) -{ - return PyBytes_AsString(_h2py(h)); -} - -HPyAPI_FUNC const char *HPyBytes_AS_STRING(HPyContext *ctx, HPy h) -{ - return PyBytes_AS_STRING(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyBytes_FromString(HPyContext *ctx, const char *bytes) -{ - return _py2h(PyBytes_FromString(bytes)); -} - -HPyAPI_FUNC HPy HPyUnicode_FromString(HPyContext *ctx, const char *utf8) -{ - return _py2h(PyUnicode_FromString(utf8)); -} - -HPyAPI_FUNC int HPyUnicode_Check(HPyContext *ctx, HPy h) -{ - return PyUnicode_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyUnicode_AsASCIIString(HPyContext *ctx, HPy h) -{ - return _py2h(PyUnicode_AsASCIIString(_h2py(h))); -} - -HPyAPI_FUNC HPy HPyUnicode_AsLatin1String(HPyContext *ctx, HPy h) -{ - return _py2h(PyUnicode_AsLatin1String(_h2py(h))); -} - -HPyAPI_FUNC HPy HPyUnicode_AsUTF8String(HPyContext *ctx, HPy h) -{ - return _py2h(PyUnicode_AsUTF8String(_h2py(h))); -} - -HPyAPI_FUNC const char *HPyUnicode_AsUTF8AndSize(HPyContext *ctx, HPy h, HPy_ssize_t *size) -{ - return PyUnicode_AsUTF8AndSize(_h2py(h), size); -} - -HPyAPI_FUNC HPy HPyUnicode_FromWideChar(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size) -{ - return _py2h(PyUnicode_FromWideChar(w, size)); -} - -HPyAPI_FUNC HPy HPyUnicode_DecodeFSDefault(HPyContext *ctx, const char *v) -{ - return _py2h(PyUnicode_DecodeFSDefault(v)); -} - -HPyAPI_FUNC HPy HPyUnicode_DecodeFSDefaultAndSize(HPyContext *ctx, const char *v, HPy_ssize_t size) -{ - return _py2h(PyUnicode_DecodeFSDefaultAndSize(v, size)); -} - -HPyAPI_FUNC HPy HPyUnicode_EncodeFSDefault(HPyContext *ctx, HPy h) -{ - return _py2h(PyUnicode_EncodeFSDefault(_h2py(h))); -} - -HPyAPI_FUNC HPy_UCS4 HPyUnicode_ReadChar(HPyContext *ctx, HPy h, HPy_ssize_t index) -{ - return PyUnicode_ReadChar(_h2py(h), index); -} - -HPyAPI_FUNC HPy HPyUnicode_DecodeASCII(HPyContext *ctx, const char *ascii, HPy_ssize_t size, const char *errors) -{ - return _py2h(PyUnicode_DecodeASCII(ascii, size, errors)); -} - -HPyAPI_FUNC HPy HPyUnicode_DecodeLatin1(HPyContext *ctx, const char *latin1, HPy_ssize_t size, const char *errors) -{ - return _py2h(PyUnicode_DecodeLatin1(latin1, size, errors)); -} - -HPyAPI_FUNC HPy HPyUnicode_FromEncodedObject(HPyContext *ctx, HPy obj, const char *encoding, const char *errors) -{ - return _py2h(PyUnicode_FromEncodedObject(_h2py(obj), encoding, errors)); -} - -HPyAPI_FUNC HPy HPyUnicode_Substring(HPyContext *ctx, HPy str, HPy_ssize_t start, HPy_ssize_t end) -{ - return _py2h(PyUnicode_Substring(_h2py(str), start, end)); -} - -HPyAPI_FUNC int HPyList_Check(HPyContext *ctx, HPy h) -{ - return PyList_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyList_New(HPyContext *ctx, HPy_ssize_t len) -{ - return _py2h(PyList_New(len)); -} - -HPyAPI_FUNC int HPyList_Append(HPyContext *ctx, HPy h_list, HPy h_item) -{ - return PyList_Append(_h2py(h_list), _h2py(h_item)); -} - -HPyAPI_FUNC int HPyDict_Check(HPyContext *ctx, HPy h) -{ - return PyDict_Check(_h2py(h)); -} - -HPyAPI_FUNC HPy HPyDict_New(HPyContext *ctx) -{ - return _py2h(PyDict_New()); -} - -HPyAPI_FUNC HPy HPyDict_Keys(HPyContext *ctx, HPy h) -{ - return _py2h(PyDict_Keys(_h2py(h))); -} - -HPyAPI_FUNC HPy HPyDict_Copy(HPyContext *ctx, HPy h) -{ - return _py2h(PyDict_Copy(_h2py(h))); -} - -HPyAPI_FUNC int HPyTuple_Check(HPyContext *ctx, HPy h) -{ - return PyTuple_Check(_h2py(h)); -} - -HPyAPI_FUNC int HPySlice_Unpack(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) -{ - return PySlice_Unpack(_h2py(slice), start, stop, step); -} - -HPyAPI_FUNC HPy HPyImport_ImportModule(HPyContext *ctx, const char *utf8_name) -{ - return _py2h(PyImport_ImportModule(utf8_name)); -} - -HPyAPI_FUNC int HPyCapsule_IsValid(HPyContext *ctx, HPy capsule, const char *utf8_name) -{ - return PyCapsule_IsValid(_h2py(capsule), utf8_name); -} - -HPyAPI_FUNC void HPy_ReenterPythonExecution(HPyContext *ctx, HPyThreadState state) -{ - PyEval_RestoreThread(_h2threads(state)); -} - -HPyAPI_FUNC HPyThreadState HPy_LeavePythonExecution(HPyContext *ctx) -{ - return _threads2h(PyEval_SaveThread()); -} - -HPyAPI_FUNC HPy HPy_EvalCode(HPyContext *ctx, HPy code, HPy globals, HPy locals) -{ - return _py2h(PyEval_EvalCode(_h2py(code), _h2py(globals), _h2py(locals))); -} - -HPyAPI_FUNC HPy HPyContextVar_New(HPyContext *ctx, const char *name, HPy default_value) -{ - return _py2h(PyContextVar_New(name, _h2py(default_value))); -} - -HPyAPI_FUNC HPy HPyContextVar_Set(HPyContext *ctx, HPy context_var, HPy value) -{ - return _py2h(PyContextVar_Set(_h2py(context_var), _h2py(value))); -} - diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_ctx.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_ctx.h deleted file mode 100644 index a8d028f081..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_ctx.h +++ /dev/null @@ -1,122 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.ctx.cpython_autogen_ctx_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -struct _HPyContext_s { - const char *name; - int abi_version; - HPy h_None; - HPy h_True; - HPy h_False; - HPy h_NotImplemented; - HPy h_Ellipsis; - HPy h_BaseException; - HPy h_Exception; - HPy h_StopAsyncIteration; - HPy h_StopIteration; - HPy h_GeneratorExit; - HPy h_ArithmeticError; - HPy h_LookupError; - HPy h_AssertionError; - HPy h_AttributeError; - HPy h_BufferError; - HPy h_EOFError; - HPy h_FloatingPointError; - HPy h_OSError; - HPy h_ImportError; - HPy h_ModuleNotFoundError; - HPy h_IndexError; - HPy h_KeyError; - HPy h_KeyboardInterrupt; - HPy h_MemoryError; - HPy h_NameError; - HPy h_OverflowError; - HPy h_RuntimeError; - HPy h_RecursionError; - HPy h_NotImplementedError; - HPy h_SyntaxError; - HPy h_IndentationError; - HPy h_TabError; - HPy h_ReferenceError; - HPy h_SystemError; - HPy h_SystemExit; - HPy h_TypeError; - HPy h_UnboundLocalError; - HPy h_UnicodeError; - HPy h_UnicodeEncodeError; - HPy h_UnicodeDecodeError; - HPy h_UnicodeTranslateError; - HPy h_ValueError; - HPy h_ZeroDivisionError; - HPy h_BlockingIOError; - HPy h_BrokenPipeError; - HPy h_ChildProcessError; - HPy h_ConnectionError; - HPy h_ConnectionAbortedError; - HPy h_ConnectionRefusedError; - HPy h_ConnectionResetError; - HPy h_FileExistsError; - HPy h_FileNotFoundError; - HPy h_InterruptedError; - HPy h_IsADirectoryError; - HPy h_NotADirectoryError; - HPy h_PermissionError; - HPy h_ProcessLookupError; - HPy h_TimeoutError; - HPy h_Warning; - HPy h_UserWarning; - HPy h_DeprecationWarning; - HPy h_PendingDeprecationWarning; - HPy h_SyntaxWarning; - HPy h_RuntimeWarning; - HPy h_FutureWarning; - HPy h_ImportWarning; - HPy h_UnicodeWarning; - HPy h_BytesWarning; - HPy h_ResourceWarning; - HPy h_BaseObjectType; - HPy h_TypeType; - HPy h_BoolType; - HPy h_LongType; - HPy h_FloatType; - HPy h_UnicodeType; - HPy h_TupleType; - HPy h_ListType; - HPy h_ComplexType; - HPy h_BytesType; - HPy h_MemoryViewType; - HPy h_CapsuleType; - HPy h_SliceType; - HPy h_Builtins; -}; diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_hpyfunc_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_hpyfunc_trampolines.h deleted file mode 100644 index df91efee3a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/autogen_hpyfunc_trampolines.h +++ /dev/null @@ -1,227 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_cpython_hpyfunc_trampoline_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -typedef HPy (*_HPyCFunction_NOARGS)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_NOARGS(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *self) \ - { \ - _HPyCFunction_NOARGS func = (_HPyCFunction_NOARGS)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(self))); \ - } -typedef HPy (*_HPyCFunction_O)(HPyContext *, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_O(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *self, cpy_PyObject *arg) \ - { \ - _HPyCFunction_O func = (_HPyCFunction_O)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(self), _py2h(arg))); \ - } -typedef HPy (*_HPyCFunction_UNARYFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_UNARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_UNARYFUNC func = (_HPyCFunction_UNARYFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy (*_HPyCFunction_BINARYFUNC)(HPyContext *, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_BINARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyCFunction_BINARYFUNC func = (_HPyCFunction_BINARYFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), _py2h(arg1))); \ - } -typedef HPy (*_HPyCFunction_TERNARYFUNC)(HPyContext *, HPy, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_TERNARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_TERNARYFUNC func = (_HPyCFunction_TERNARYFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), _py2h(arg2))); \ - } -typedef int (*_HPyCFunction_INQUIRY)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_INQUIRY(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_INQUIRY func = (_HPyCFunction_INQUIRY)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy_ssize_t (*_HPyCFunction_LENFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_LENFUNC(SYM, IMPL) \ - static HPy_ssize_t SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_LENFUNC func = (_HPyCFunction_LENFUNC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy (*_HPyCFunction_SSIZEARGFUNC)(HPyContext *, HPy, HPy_ssize_t); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZEARGFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, HPy_ssize_t arg1) \ - { \ - _HPyCFunction_SSIZEARGFUNC func = (_HPyCFunction_SSIZEARGFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), (arg1))); \ - } -typedef HPy (*_HPyCFunction_SSIZESSIZEARGFUNC)(HPyContext *, HPy, HPy_ssize_t, HPy_ssize_t); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZESSIZEARGFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, HPy_ssize_t arg2) \ - { \ - _HPyCFunction_SSIZESSIZEARGFUNC func = (_HPyCFunction_SSIZESSIZEARGFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), (arg1), (arg2))); \ - } -typedef int (*_HPyCFunction_SSIZEOBJARGPROC)(HPyContext *, HPy, HPy_ssize_t, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZEOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_SSIZEOBJARGPROC func = (_HPyCFunction_SSIZEOBJARGPROC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), (arg1), _py2h(arg2))); \ - } -typedef int (*_HPyCFunction_SSIZESSIZEOBJARGPROC)(HPyContext *, HPy, HPy_ssize_t, HPy_ssize_t, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZESSIZEOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, HPy_ssize_t arg2, cpy_PyObject *arg3) \ - { \ - _HPyCFunction_SSIZESSIZEOBJARGPROC func = (_HPyCFunction_SSIZESSIZEOBJARGPROC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), (arg1), (arg2), _py2h(arg3))); \ - } -typedef int (*_HPyCFunction_OBJOBJARGPROC)(HPyContext *, HPy, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_OBJOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_OBJOBJARGPROC func = (_HPyCFunction_OBJOBJARGPROC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), _py2h(arg2))); \ - } -typedef void (*_HPyCFunction_FREEFUNC)(HPyContext *, void *); -#define _HPyFunc_TRAMPOLINE_HPyFunc_FREEFUNC(SYM, IMPL) \ - static void SYM(void *arg0) \ - { \ - _HPyCFunction_FREEFUNC func = (_HPyCFunction_FREEFUNC)IMPL; \ - func(_HPyGetContext(), (arg0)); \ - return; \ - } -typedef HPy (*_HPyCFunction_GETATTRFUNC)(HPyContext *, HPy, char *); -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETATTRFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, char *arg1) \ - { \ - _HPyCFunction_GETATTRFUNC func = (_HPyCFunction_GETATTRFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), (arg1))); \ - } -typedef HPy (*_HPyCFunction_GETATTROFUNC)(HPyContext *, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETATTROFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyCFunction_GETATTROFUNC func = (_HPyCFunction_GETATTROFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), _py2h(arg1))); \ - } -typedef int (*_HPyCFunction_SETATTRFUNC)(HPyContext *, HPy, char *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETATTRFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, char *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_SETATTRFUNC func = (_HPyCFunction_SETATTRFUNC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), (arg1), _py2h(arg2))); \ - } -typedef int (*_HPyCFunction_SETATTROFUNC)(HPyContext *, HPy, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETATTROFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_SETATTROFUNC func = (_HPyCFunction_SETATTROFUNC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), _py2h(arg2))); \ - } -typedef HPy (*_HPyCFunction_REPRFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_REPRFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_REPRFUNC func = (_HPyCFunction_REPRFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy_hash_t (*_HPyCFunction_HASHFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_HASHFUNC(SYM, IMPL) \ - static HPy_hash_t SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_HASHFUNC func = (_HPyCFunction_HASHFUNC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy (*_HPyCFunction_GETITERFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETITERFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_GETITERFUNC func = (_HPyCFunction_GETITERFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy (*_HPyCFunction_ITERNEXTFUNC)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_ITERNEXTFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_ITERNEXTFUNC func = (_HPyCFunction_ITERNEXTFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0))); \ - } -typedef HPy (*_HPyCFunction_DESCRGETFUNC)(HPyContext *, HPy, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESCRGETFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_DESCRGETFUNC func = (_HPyCFunction_DESCRGETFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), _py2h(arg2))); \ - } -typedef int (*_HPyCFunction_DESCRSETFUNC)(HPyContext *, HPy, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESCRSETFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyCFunction_DESCRSETFUNC func = (_HPyCFunction_DESCRSETFUNC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), _py2h(arg2))); \ - } -typedef HPy (*_HPyCFunction_GETTER)(HPyContext *, HPy, void *); -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETTER(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, void *arg1) \ - { \ - _HPyCFunction_GETTER func = (_HPyCFunction_GETTER)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(arg0), (arg1))); \ - } -typedef int (*_HPyCFunction_SETTER)(HPyContext *, HPy, HPy, void *); -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETTER(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, void *arg2) \ - { \ - _HPyCFunction_SETTER func = (_HPyCFunction_SETTER)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), _py2h(arg1), (arg2))); \ - } -typedef int (*_HPyCFunction_OBJOBJPROC)(HPyContext *, HPy, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_OBJOBJPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyCFunction_OBJOBJPROC func = (_HPyCFunction_OBJOBJPROC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), _py2h(arg1))); \ - } -typedef void (*_HPyCFunction_DESTRUCTOR)(HPyContext *, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESTRUCTOR(SYM, IMPL) \ - static void SYM(cpy_PyObject *arg0) \ - { \ - _HPyCFunction_DESTRUCTOR func = (_HPyCFunction_DESTRUCTOR)IMPL; \ - func(_HPyGetContext(), _py2h(arg0)); \ - return; \ - } diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/hpyfunc_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/hpyfunc_trampolines.h deleted file mode 100644 index d026df297c..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/hpyfunc_trampolines.h +++ /dev/null @@ -1,148 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H -#define HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H - -/* This is a GraalPy-specific accessor function for a tuple object's items - array. There is no public header for that symbol, so we define it ad-hoc. */ -extern PyObject** (*GraalPy_get_PyTupleObject_ob_item)(PyTupleObject*); - -typedef HPy (*_HPyCFunction_VARARGS)(HPyContext*, HPy, const HPy *, size_t); -#define _HPyFunc_TRAMPOLINE_HPyFunc_VARARGS(SYM, IMPL) \ - static PyObject* \ - SYM(PyObject *self, PyObject *const *args, Py_ssize_t nargs) \ - { \ - _HPyCFunction_VARARGS func = (_HPyCFunction_VARARGS)IMPL; \ - return _h2py(func(_HPyGetContext(), \ - _py2h(self), _arr_py2h(args), nargs)); \ - } - -typedef HPy (*_HPyCFunction_KEYWORDS)(HPyContext*, HPy, const HPy *, size_t, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_KEYWORDS(SYM, IMPL) \ - static PyObject * \ - SYM(PyObject *self, PyObject *const *args, size_t nargsf, \ - PyObject *kwnames) \ - { \ - _HPyCFunction_KEYWORDS func = (_HPyCFunction_KEYWORDS)IMPL; \ - /* We also use HPyFunc_KEYWORDS for HPy_tp_call which is */ \ - /* called via vectorcall and so nargsf may have the flag set */ \ - return _h2py(func(_HPyGetContext(), _py2h(self), _arr_py2h(args), \ - PyVectorcall_NARGS(nargsf), _py2h(kwnames))); \ - } - -typedef int (*_HPyCFunction_INITPROC)(HPyContext*, HPy, const HPy *, HPy_ssize_t, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_INITPROC(SYM, IMPL) \ - static int \ - SYM(PyObject *self, PyObject *args, PyObject *kw) \ - { \ - /* get the tuple elements as an array of "PyObject *", which */ \ - /* is equivalent to an array of "HPy" with enough casting... */ \ - PyObject *const *items = GraalPy_get_PyTupleObject_ob_item((PyTupleObject *)args); \ - Py_ssize_t nargs = PyTuple_GET_SIZE(args); \ - _HPyCFunction_INITPROC func = (_HPyCFunction_INITPROC)IMPL; \ - return func(_HPyGetContext(), _py2h(self), \ - _arr_py2h(items), nargs, _py2h(kw)); \ - } - -typedef HPy (*_HPyCFunction_NEWFUNC)(HPyContext*, HPy, const HPy *, HPy_ssize_t, HPy); -#define _HPyFunc_TRAMPOLINE_HPyFunc_NEWFUNC(SYM, IMPL) \ - static PyObject * \ - SYM(PyObject *self, PyObject *args, PyObject *kw) \ - { \ - /* get the tuple elements as an array of "PyObject *", which */ \ - /* is equivalent to an array of "HPy" with enough casting... */ \ - PyObject *const *items = GraalPy_get_PyTupleObject_ob_item((PyTupleObject *)args); \ - Py_ssize_t nargs = PyTuple_GET_SIZE(args); \ - _HPyCFunction_NEWFUNC func = (_HPyCFunction_NEWFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(self), \ - _arr_py2h(items), nargs, _py2h(kw))); \ - } - -/* special case: the HPy_tp_destroy slot doesn't map to any CPython slot. - Instead, it is called from our own tp_dealloc: see also - hpytype_dealloc(). */ -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESTROYFUNC(SYM, IMPL) \ - static void SYM(void) { abort(); } - -/* this needs to be written manually because HPy has a different type for - "op": HPy_RichCmpOp instead of int */ -typedef HPy (*_HPyCFunction_RICHCMPFUNC)(HPyContext *, HPy, HPy, int); -#define _HPyFunc_TRAMPOLINE_HPyFunc_RICHCMPFUNC(SYM, IMPL) \ - static cpy_PyObject * \ - SYM(PyObject *self, PyObject *obj, int op) \ - { \ - _HPyCFunction_RICHCMPFUNC func = (_HPyCFunction_RICHCMPFUNC)IMPL; \ - return _h2py(func(_HPyGetContext(), _py2h(self), _py2h(obj), op)); \ - } - -/* With the cpython ABI, Py_buffer and HPy_buffer are ABI-compatible. - * Even though casting between them is technically undefined behavior, it - * should always work. That way, we avoid a costly allocation and copy. */ -typedef int (*_HPyCFunction_GETBUFFERPROC)(HPyContext *, HPy, HPy_buffer *, int); -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETBUFFERPROC(SYM, IMPL) \ - static int SYM(PyObject *arg0, Py_buffer *arg1, int arg2) \ - { \ - _HPyCFunction_GETBUFFERPROC func = (_HPyCFunction_GETBUFFERPROC)IMPL; \ - return (func(_HPyGetContext(), _py2h(arg0), (HPy_buffer*)arg1, arg2)); \ - } - -typedef int (*_HPyCFunction_RELEASEBUFFERPROC)(HPyContext *, HPy, HPy_buffer *); -#define _HPyFunc_TRAMPOLINE_HPyFunc_RELEASEBUFFERPROC(SYM, IMPL) \ - static void SYM(PyObject *arg0, Py_buffer *arg1) \ - { \ - _HPyCFunction_RELEASEBUFFERPROC func = (_HPyCFunction_RELEASEBUFFERPROC)IMPL; \ - func(_HPyGetContext(), _py2h(arg0), (HPy_buffer*)arg1); \ - return; \ - } - - -#define _HPyFunc_TRAMPOLINE_HPyFunc_TRAVERSEPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *self, cpy_visitproc visit, void *arg) \ - { \ - return call_traverseproc_from_trampoline((HPyFunc_traverseproc)IMPL, self, \ - visit, arg); \ - } - -#define HPyCapsule_DESTRUCTOR_TRAMPOLINE(SYM, IMPL) \ - static void SYM(PyObject *capsule) \ - { \ - const char *name = PyCapsule_GetName(capsule); \ - IMPL(name, PyCapsule_GetPointer(capsule, name), \ - PyCapsule_GetContext(capsule)); \ - } - -extern void -_HPyModule_CheckCreateSlotResult(cpy_PyObject **result); - -#define _HPyFunc_TRAMPOLINE_HPyFunc_MOD_CREATE(SYM, IMPL) \ - static cpy_PyObject* SYM(cpy_PyObject *spec, cpy_PyModuleDef *def) \ - { \ - (void) def; /* avoid 'unused' warning */ \ - cpy_PyObject* result = _h2py(IMPL(_HPyGetContext(), _py2h(spec))); \ - _HPyModule_CheckCreateSlotResult(&result); \ - return result; \ - } - -#endif // HPY_CPYTHON_HPYFUNC_TRAMPOLINES_H diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/misc.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/misc.h deleted file mode 100644 index 64009cfa97..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/cpython/misc.h +++ /dev/null @@ -1,594 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_CPYTHON_MISC_H -#define HPY_CPYTHON_MISC_H - -#include -#include "hpy.h" -#include "hpy/runtime/ctx_funcs.h" - -static inline PyObject* _h2py(HPy h) { - return (PyObject*) h._i; -} - -static inline HPy _py2h(PyObject *o) { -#ifdef GRAALVM_PYTHON_LLVM - return _hconv((void*)o); -#else - return _hconv((intptr_t)o); -#endif -} - -static inline HPyThreadState _threads2h(PyThreadState *s) { -#ifdef GRAALVM_PYTHON_LLVM - return _htsconv((void*)s); -#else - return _htsconv((intptr_t)s); -#endif -} - -static inline PyThreadState* _h2threads(HPyThreadState h) { - return (PyThreadState*) h._i; -} - -static inline HPyField _py2hf(PyObject *obj) -{ - HPy h = _py2h(obj); - return _hfconv( ._i = h._i ); -} - -static inline PyObject * _hf2py(HPyField hf) -{ - HPy h = { ._i = hf._i }; - return _h2py(h); -} - -static inline HPyGlobal _py2hg(PyObject *obj) -{ - HPy h = _py2h(obj); - return _hgconv(._i = h._i); -} - -static inline PyObject * _hg2py(HPyGlobal hf) -{ - HPy h = { ._i = hf._i }; - return _h2py(h); -} - -static inline const HPy *_arr_py2h(PyObject *const *py_arr) { - assert(sizeof(HPy) == sizeof(PyObject *)); - return (const HPy *)py_arr; -} - -/* XXX! should be defined only once, not once for every .c! */ -static struct _HPyContext_s _global_ctx; - -HPyAPI_FUNC HPyContext * _HPyGetContext(void) { - HPyContext *ctx = &_global_ctx; - if (!ctx->name) { - ctx->name = "HPy CPython ABI"; - ctx->abi_version = HPY_ABI_VERSION; - /* Constants */ - ctx->h_None = _py2h(Py_None); - ctx->h_True = _py2h(Py_True); - ctx->h_False = _py2h(Py_False); - ctx->h_NotImplemented = _py2h(Py_NotImplemented); - ctx->h_Ellipsis = _py2h(Py_Ellipsis); - /* Exceptions */ - ctx->h_BaseException = _py2h(PyExc_BaseException); - ctx->h_Exception = _py2h(PyExc_Exception); - ctx->h_StopAsyncIteration = _py2h(PyExc_StopAsyncIteration); - ctx->h_StopIteration = _py2h(PyExc_StopIteration); - ctx->h_GeneratorExit = _py2h(PyExc_GeneratorExit); - ctx->h_ArithmeticError = _py2h(PyExc_ArithmeticError); - ctx->h_LookupError = _py2h(PyExc_LookupError); - ctx->h_AssertionError = _py2h(PyExc_AssertionError); - ctx->h_AttributeError = _py2h(PyExc_AttributeError); - ctx->h_BufferError = _py2h(PyExc_BufferError); - ctx->h_EOFError = _py2h(PyExc_EOFError); - ctx->h_FloatingPointError = _py2h(PyExc_FloatingPointError); - ctx->h_OSError = _py2h(PyExc_OSError); - ctx->h_ImportError = _py2h(PyExc_ImportError); - ctx->h_ModuleNotFoundError = _py2h(PyExc_ModuleNotFoundError); - ctx->h_IndexError = _py2h(PyExc_IndexError); - ctx->h_KeyError = _py2h(PyExc_KeyError); - ctx->h_KeyboardInterrupt = _py2h(PyExc_KeyboardInterrupt); - ctx->h_MemoryError = _py2h(PyExc_MemoryError); - ctx->h_NameError = _py2h(PyExc_NameError); - ctx->h_OverflowError = _py2h(PyExc_OverflowError); - ctx->h_RuntimeError = _py2h(PyExc_RuntimeError); - ctx->h_RecursionError = _py2h(PyExc_RecursionError); - ctx->h_NotImplementedError = _py2h(PyExc_NotImplementedError); - ctx->h_SyntaxError = _py2h(PyExc_SyntaxError); - ctx->h_IndentationError = _py2h(PyExc_IndentationError); - ctx->h_TabError = _py2h(PyExc_TabError); - ctx->h_ReferenceError = _py2h(PyExc_ReferenceError); - ctx->h_SystemError = _py2h(PyExc_SystemError); - ctx->h_SystemExit = _py2h(PyExc_SystemExit); - ctx->h_TypeError = _py2h(PyExc_TypeError); - ctx->h_UnboundLocalError = _py2h(PyExc_UnboundLocalError); - ctx->h_UnicodeError = _py2h(PyExc_UnicodeError); - ctx->h_UnicodeEncodeError = _py2h(PyExc_UnicodeEncodeError); - ctx->h_UnicodeDecodeError = _py2h(PyExc_UnicodeDecodeError); - ctx->h_UnicodeTranslateError = _py2h(PyExc_UnicodeTranslateError); - ctx->h_ValueError = _py2h(PyExc_ValueError); - ctx->h_ZeroDivisionError = _py2h(PyExc_ZeroDivisionError); - ctx->h_BlockingIOError = _py2h(PyExc_BlockingIOError); - ctx->h_BrokenPipeError = _py2h(PyExc_BrokenPipeError); - ctx->h_ChildProcessError = _py2h(PyExc_ChildProcessError); - ctx->h_ConnectionError = _py2h(PyExc_ConnectionError); - ctx->h_ConnectionAbortedError = _py2h(PyExc_ConnectionAbortedError); - ctx->h_ConnectionRefusedError = _py2h(PyExc_ConnectionRefusedError); - ctx->h_ConnectionResetError = _py2h(PyExc_ConnectionResetError); - ctx->h_FileExistsError = _py2h(PyExc_FileExistsError); - ctx->h_FileNotFoundError = _py2h(PyExc_FileNotFoundError); - ctx->h_InterruptedError = _py2h(PyExc_InterruptedError); - ctx->h_IsADirectoryError = _py2h(PyExc_IsADirectoryError); - ctx->h_NotADirectoryError = _py2h(PyExc_NotADirectoryError); - ctx->h_PermissionError = _py2h(PyExc_PermissionError); - ctx->h_ProcessLookupError = _py2h(PyExc_ProcessLookupError); - ctx->h_TimeoutError = _py2h(PyExc_TimeoutError); - /* Warnings */ - ctx->h_Warning = _py2h(PyExc_Warning); - ctx->h_UserWarning = _py2h(PyExc_UserWarning); - ctx->h_DeprecationWarning = _py2h(PyExc_DeprecationWarning); - ctx->h_PendingDeprecationWarning = _py2h(PyExc_PendingDeprecationWarning); - ctx->h_SyntaxWarning = _py2h(PyExc_SyntaxWarning); - ctx->h_RuntimeWarning = _py2h(PyExc_RuntimeWarning); - ctx->h_FutureWarning = _py2h(PyExc_FutureWarning); - ctx->h_ImportWarning = _py2h(PyExc_ImportWarning); - ctx->h_UnicodeWarning = _py2h(PyExc_UnicodeWarning); - ctx->h_BytesWarning = _py2h(PyExc_BytesWarning); - ctx->h_ResourceWarning = _py2h(PyExc_ResourceWarning); - /* Types */ - ctx->h_BaseObjectType = _py2h((PyObject *)&PyBaseObject_Type); - ctx->h_TypeType = _py2h((PyObject *)&PyType_Type); - ctx->h_BoolType = _py2h((PyObject *)&PyBool_Type); - ctx->h_LongType = _py2h((PyObject *)&PyLong_Type); - ctx->h_FloatType = _py2h((PyObject *)&PyFloat_Type); - ctx->h_UnicodeType = _py2h((PyObject *)&PyUnicode_Type); - ctx->h_TupleType = _py2h((PyObject *)&PyTuple_Type); - ctx->h_ListType = _py2h((PyObject *)&PyList_Type); - ctx->h_ComplexType = _py2h((PyObject *)&PyComplex_Type); - ctx->h_BytesType = _py2h((PyObject *)&PyBytes_Type); - ctx->h_MemoryViewType = _py2h((PyObject *)&PyMemoryView_Type); - ctx->h_CapsuleType = _py2h((PyObject *)&PyCapsule_Type); - ctx->h_SliceType = _py2h((PyObject *)&PySlice_Type); - /* Reflection */ - ctx->h_Builtins = _py2h(PyEval_GetBuiltins()); - } - return ctx; -} - -HPyAPI_FUNC HPy HPy_Dup(HPyContext *ctx, HPy handle) -{ - Py_XINCREF(_h2py(handle)); - return handle; -} - -HPyAPI_FUNC void HPy_Close(HPyContext *ctx, HPy handle) -{ - Py_XDECREF(_h2py(handle)); -} - -HPyAPI_FUNC void HPyField_Store(HPyContext *ctx, HPy target_obj, - HPyField *target_field, HPy h) -{ - PyObject *obj = _h2py(h); - PyObject *target_py_obj = _hf2py(*target_field); - Py_XINCREF(obj); - *target_field = _py2hf(obj); - Py_XDECREF(target_py_obj); -} - -HPyAPI_FUNC HPy HPyField_Load(HPyContext *ctx, HPy source_obj, HPyField source_field) -{ - PyObject *obj = _hf2py(source_field); - Py_INCREF(obj); - return _py2h(obj); -} - -HPyAPI_FUNC void HPyGlobal_Store(HPyContext *ctx, HPyGlobal *global, HPy h) -{ - PyObject *obj = _h2py(h); - Py_XDECREF(_hg2py(*global)); - Py_XINCREF(obj); - *global = _py2hg(obj); -} - -HPyAPI_FUNC HPy HPyGlobal_Load(HPyContext *ctx, HPyGlobal global) -{ - PyObject *obj = _hg2py(global); - Py_INCREF(obj); - return _py2h(obj); -} - -HPyAPI_FUNC HPy HPy_FromPyObject(HPyContext *ctx, PyObject *obj) -{ - Py_XINCREF(obj); - return _py2h(obj); -} - -HPyAPI_FUNC PyObject * HPy_AsPyObject(HPyContext *ctx, HPy h) -{ - PyObject *result = _h2py(h); - Py_XINCREF(result); - return result; -} - -HPyAPI_FUNC HPy HPyModule_Create(HPyContext *ctx, HPyModuleDef *mdef) -{ - return ctx_Module_Create(ctx, mdef); -} - -HPyAPI_FUNC HPy HPyType_FromSpec(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params) -{ - return ctx_Type_FromSpec(ctx, spec, params); -} - -HPyAPI_FUNC HPy _HPy_New(HPyContext *ctx, HPy h, void **data) -{ - return ctx_New(ctx, h, data); -} - -HPyAPI_FUNC _HPy_NO_RETURN void HPy_FatalError(HPyContext *ctx, const char *message) -{ - Py_FatalError(message); -} - -HPyAPI_FUNC HPy HPyType_GenericNew(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) -{ - return ctx_Type_GenericNew(ctx, type, args, nargs, kw); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Object(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Object(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Legacy(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Legacy(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Type(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Type(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Long(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Long(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Float(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Float(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Unicode(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Unicode(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_Tuple(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_Tuple(ctx, h); -} - -HPyAPI_FUNC void* _HPy_AsStruct_List(HPyContext *ctx, HPy h) -{ - return ctx_AsStruct_List(ctx, h); -} - -HPyAPI_FUNC HPy HPy_CallTupleDict(HPyContext *ctx, HPy callable, HPy args, HPy kw) -{ - return ctx_CallTupleDict(ctx, callable, args, kw); -} - -#if PY_VERSION_HEX < 0x03090000 -# define PyObject_Vectorcall _PyObject_Vectorcall -#endif - -HPyAPI_FUNC HPy HPy_Call(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) -{ - assert(sizeof(HPy) == sizeof(PyObject *)); - return _py2h(PyObject_Vectorcall(_h2py(callable), (PyObject *const *)args, nargs, _h2py(kwnames))); -} - -#if PY_VERSION_HEX < 0x03090000 -# undef PyObject_Vectorcall -#endif - -HPyAPI_FUNC HPy HPy_CallMethod(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames) -{ -#if PY_VERSION_HEX >= 0x03090000 - assert(sizeof(HPy) == sizeof(PyObject *)); - return _py2h(PyObject_VectorcallMethod(_h2py(name), (PyObject *const *)args, nargs, _h2py(kwnames))); -#else - return ctx_CallMethod(ctx, name, args, nargs, kwnames); -#endif -} - -HPyAPI_FUNC void _HPy_Dump(HPyContext *ctx, HPy h) -{ - ctx_Dump(ctx, h); -} - -HPyAPI_FUNC int HPy_TypeCheck(HPyContext *ctx, HPy h_obj, HPy h_type) -{ - return ctx_TypeCheck(ctx, h_obj, h_type); -} - -HPyAPI_FUNC int HPy_Is(HPyContext *ctx, HPy h_obj, HPy h_other) -{ - return ctx_Is(ctx, h_obj, h_other); -} - -HPyAPI_FUNC HPyListBuilder HPyListBuilder_New(HPyContext *ctx, HPy_ssize_t initial_size) -{ - return ctx_ListBuilder_New(ctx, initial_size); -} - -HPyAPI_FUNC void HPyListBuilder_Set(HPyContext *ctx, HPyListBuilder builder, - HPy_ssize_t index, HPy h_item) -{ - ctx_ListBuilder_Set(ctx, builder, index, h_item); -} - -HPyAPI_FUNC HPy HPyListBuilder_Build(HPyContext *ctx, HPyListBuilder builder) -{ - return ctx_ListBuilder_Build(ctx, builder); -} - -HPyAPI_FUNC void HPyListBuilder_Cancel(HPyContext *ctx, HPyListBuilder builder) -{ - ctx_ListBuilder_Cancel(ctx, builder); -} - -HPyAPI_FUNC HPyTupleBuilder HPyTupleBuilder_New(HPyContext *ctx, HPy_ssize_t initial_size) -{ - return ctx_TupleBuilder_New(ctx, initial_size); -} - -HPyAPI_FUNC void HPyTupleBuilder_Set(HPyContext *ctx, HPyTupleBuilder builder, - HPy_ssize_t index, HPy h_item) -{ - ctx_TupleBuilder_Set(ctx, builder, index, h_item); -} - -HPyAPI_FUNC HPy HPyTupleBuilder_Build(HPyContext *ctx, HPyTupleBuilder builder) -{ - return ctx_TupleBuilder_Build(ctx, builder); -} - -HPyAPI_FUNC void HPyTupleBuilder_Cancel(HPyContext *ctx, HPyTupleBuilder builder) -{ - ctx_TupleBuilder_Cancel(ctx, builder); -} - -HPyAPI_FUNC HPy HPyTuple_FromArray(HPyContext *ctx, HPy items[], HPy_ssize_t n) -{ - return ctx_Tuple_FromArray(ctx, items, n); -} - -HPyAPI_FUNC HPyTracker HPyTracker_New(HPyContext *ctx, HPy_ssize_t size) -{ - return ctx_Tracker_New(ctx, size); -} - -HPyAPI_FUNC int HPyTracker_Add(HPyContext *ctx, HPyTracker ht, HPy h) -{ - return ctx_Tracker_Add(ctx, ht, h); -} - -HPyAPI_FUNC void HPyTracker_ForgetAll(HPyContext *ctx, HPyTracker ht) -{ - ctx_Tracker_ForgetAll(ctx, ht); -} - -HPyAPI_FUNC void HPyTracker_Close(HPyContext *ctx, HPyTracker ht) -{ - ctx_Tracker_Close(ctx, ht); -} - -HPyAPI_FUNC HPy HPy_GetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx) { - return ctx_GetItem_i(ctx, obj, idx); -} - -HPyAPI_FUNC HPy HPy_GetItem_s(HPyContext *ctx, HPy obj, const char *key) { - return ctx_GetItem_s(ctx, obj, key); -} - -HPyAPI_FUNC int HPy_SetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value) { - return ctx_SetItem_i(ctx, obj, idx, value); -} - -HPyAPI_FUNC int HPy_SetItem_s(HPyContext *ctx, HPy obj, const char *key, HPy value) { - return ctx_SetItem_s(ctx, obj, key, value); -} - -HPyAPI_FUNC int HPy_DelItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx) { - return ctx_DelItem_i(ctx, obj, idx); -} - -HPyAPI_FUNC int HPy_DelItem_s(HPyContext *ctx, HPy obj, const char *key) { - return ctx_DelItem_s(ctx, obj, key); -} - -HPyAPI_FUNC HPy HPyBytes_FromStringAndSize(HPyContext *ctx, const char *v, HPy_ssize_t len) { - return ctx_Bytes_FromStringAndSize(ctx, v, len); -} - -HPyAPI_FUNC int HPyErr_Occurred(HPyContext *ctx) { - return ctx_Err_Occurred(ctx); -} - -HPyAPI_FUNC HPy HPyCapsule_New(HPyContext *ctx, void *pointer, const char *name, HPyCapsule_Destructor *destructor) -{ - return ctx_Capsule_New(ctx, pointer, name, destructor); -} - -HPyAPI_FUNC void * HPyCapsule_GetPointer(HPyContext *ctx, HPy capsule, const char *name) -{ - return PyCapsule_GetPointer(_h2py(capsule), name); -} - -HPyAPI_FUNC const char * HPyCapsule_GetName(HPyContext *ctx, HPy capsule) -{ - return PyCapsule_GetName(_h2py(capsule)); -} - -HPyAPI_FUNC void * HPyCapsule_GetContext(HPyContext *ctx, HPy capsule) -{ - return PyCapsule_GetContext(_h2py(capsule)); -} - -HPyAPI_FUNC int HPyCapsule_SetPointer(HPyContext *ctx, HPy capsule, void *pointer) -{ - return PyCapsule_SetPointer(_h2py(capsule), pointer); -} - -HPyAPI_FUNC int HPyCapsule_SetName(HPyContext *ctx, HPy capsule, const char *name) -{ - return PyCapsule_SetName(_h2py(capsule), name); -} - -HPyAPI_FUNC int HPyCapsule_SetContext(HPyContext *ctx, HPy capsule, void *context) -{ - return PyCapsule_SetContext(_h2py(capsule), context); -} - -HPyAPI_FUNC int HPyCapsule_SetDestructor(HPyContext *ctx, HPy capsule, HPyCapsule_Destructor *destructor) -{ - return ctx_Capsule_SetDestructor(ctx, capsule, destructor); -} - -// just for better readability -#define SIZEOF_INT32 4 -#define SIZEOF_INT64 8 - -HPyAPI_FUNC HPy HPyLong_FromInt32_t(HPyContext *ctx, int32_t value) { -#if SIZEOF_LONG >= SIZEOF_INT32 - return _py2h(PyLong_FromLong((long)value)); -#else - return ctx_Long_FromInt32_t ( ctx, value ); -#endif -} - -HPyAPI_FUNC HPy HPyLong_FromUInt32_t(HPyContext *ctx, uint32_t value) { -#if SIZEOF_LONG >= SIZEOF_INT32 - return _py2h(PyLong_FromUnsignedLong((unsigned long)value)); -#else - return ctx_Long_FromUInt32_t ( ctx, value ); -#endif -} - -HPyAPI_FUNC HPy HPyLong_FromInt64_t(HPyContext *ctx, int64_t v) { -#if SIZEOF_LONG_LONG >= SIZEOF_INT64 - return _py2h(PyLong_FromLongLong((long long)v)); -#else - return ctx_Long_FromInt64_t ( ctx, v ); -#endif -} - -HPyAPI_FUNC HPy HPyLong_FromUInt64_t(HPyContext *ctx, uint64_t v) { -#if SIZEOF_LONG_LONG >= SIZEOF_INT64 - return _py2h(PyLong_FromUnsignedLongLong((unsigned long long)v)); -#else - return ctx_Long_FromUInt64_t ( ctx, v ); -#endif -} - -HPyAPI_FUNC int32_t HPyLong_AsInt32_t(HPyContext *ctx, HPy h) { -#if SIZEOF_LONG == SIZEOF_INT32 - return (int32_t) PyLong_AsLong(_h2py(h)); -#else - return ctx_Long_AsInt32_t ( ctx, h ); -#endif -} - -HPyAPI_FUNC uint32_t HPyLong_AsUInt32_t(HPyContext *ctx, HPy h) { -#if SIZEOF_LONG == SIZEOF_INT32 - return (uint32_t) PyLong_AsUnsignedLong(_h2py(h)); -#else - return ctx_Long_AsUInt32_t ( ctx, h ); -#endif -} - -HPyAPI_FUNC uint32_t HPyLong_AsUInt32_tMask(HPyContext *ctx, HPy h) { - return (uint32_t) PyLong_AsUnsignedLongMask(_h2py(h)); -} - -HPyAPI_FUNC int64_t HPyLong_AsInt64_t(HPyContext *ctx, HPy h) { -#if SIZEOF_LONG_LONG == SIZEOF_INT64 - return (int64_t) PyLong_AsLongLong(_h2py(h)); -#else - return ctx_Long_AsInt64_t ( ctx, h ); -#endif -} - -HPyAPI_FUNC uint64_t HPyLong_AsUInt64_t(HPyContext *ctx, HPy h) { -#if SIZEOF_LONG_LONG == SIZEOF_INT64 - return (uint64_t) PyLong_AsUnsignedLongLong(_h2py(h)); -#else - return ctx_Long_AsUInt64_t ( ctx, h ); -#endif -} - -HPyAPI_FUNC uint64_t HPyLong_AsUInt64_tMask(HPyContext *ctx, HPy h) { - return (uint64_t) PyLong_AsUnsignedLongLongMask(_h2py(h)); -} - -#undef SIZEOF_INT32 -#undef SIZEOF_INT64 - -HPyAPI_FUNC HPy HPy_Compile_s(HPyContext *ctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind) { - return ctx_Compile_s(ctx, utf8_source, utf8_filename, kind); -} - -HPyAPI_FUNC int32_t -HPyContextVar_Get(HPyContext *ctx, HPy context_var, HPy default_value, HPy *result) { - return ctx_ContextVar_Get(ctx, context_var, default_value, result); -} - -HPyAPI_FUNC const char * -HPyType_GetName(HPyContext *ctx, HPy type) -{ - return ctx_Type_GetName(ctx, type); -} - -HPyAPI_FUNC int HPyType_IsSubtype(HPyContext *ctx, HPy sub, HPy type) -{ - return PyType_IsSubtype((PyTypeObject *)_h2py(sub), - (PyTypeObject *)_h2py(type)); -} - -HPyAPI_FUNC int HPy_SetCallFunction(HPyContext *ctx, HPy h, HPyCallFunction *func) -{ - return ctx_SetCallFunction(ctx, h, func); -} - -#endif /* !HPY_CPYTHON_MISC_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/forbid_python_h/Python.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/forbid_python_h/Python.h deleted file mode 100644 index f71e69c6d2..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/forbid_python_h/Python.h +++ /dev/null @@ -1,30 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -// sanity check -#ifndef HPY_ABI_UNIVERSAL -# error "Internal HPy error, something is wrong with your build system. The directory hpy/forbid_python_h has been added to the include_dirs but the target ABI does not seems to be 'universal'" -#endif - -#error "It is forbidden to #include when targeting the HPy Universal ABI" diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpydef.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpydef.h deleted file mode 100644 index 6fce75b944..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpydef.h +++ /dev/null @@ -1,485 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_HPYDEF_H -#define HPY_UNIVERSAL_HPYDEF_H -#ifdef __cplusplus -extern "C" { -#endif - -#include /* to make sure "offsetof" is available for our users */ - -#include "hpy/hpyfunc.h" -#include "hpy/autogen_hpyslot.h" -#include "hpy/cpy_types.h" - -typedef void* (*HPyCFunction)(); -typedef void (*HPyFunc_Capsule_Destructor)(const char *name, void *pointer, void *context); - -/** - * C structure to define an HPy slot. - * - * It is perfectly fine to fill this structure manually. However, the - * recommended and easier way is to use macro :c:macro:`HPyDef_SLOT`. - */ -typedef struct { - /** - * The slot to fill. - */ - HPySlot_Slot slot; - - /** Function pointer to the slot's implementation */ - HPyCFunction impl; - - /** - * Function pointer to the CPython trampoline function which is used by - * CPython to call the actual HPy function ``impl``. - */ - cpy_PyCFunction cpy_trampoline; -} HPySlot; - -/** - * C structure to define an HPy method. - * - * It is perfectly fine to fill this structure manually. However, the - * recommended and easier way is to use macro :c:macro:`HPyDef_METH`. - */ -typedef struct { - /** The name of Python attribute (UTF-8 encoded) */ - const char *name; - - /** Function pointer of the C function implementation */ - HPyCFunction impl; - - /** - * Function pointer to the CPython trampoline function which is used by - * CPython to call the actual HPy function ``impl``. - */ - cpy_PyCFunction cpy_trampoline; - - /** Indicates the C function's expected signature */ - HPyFunc_Signature signature; - - /** Docstring of the method (UTF-8 encoded; may be ``NULL``) */ - const char *doc; - -} HPyMeth; - -/** - * Describes the type (and therefore also the size) of an HPy member. - */ -typedef enum { - HPyMember_SHORT = 0, - HPyMember_INT = 1, - HPyMember_LONG = 2, - HPyMember_FLOAT = 3, - HPyMember_DOUBLE = 4, - HPyMember_STRING = 5, - HPyMember_OBJECT = 6, - HPyMember_CHAR = 7, /* 1-character string */ - HPyMember_BYTE = 8, /* 8-bit signed int */ - /* unsigned variants: */ - HPyMember_UBYTE = 9, - HPyMember_USHORT = 10, - HPyMember_UINT = 11, - HPyMember_ULONG = 12, - - /* Added by Jack: strings contained in the structure */ - HPyMember_STRING_INPLACE = 13, - - /* Added by Lillo: bools contained in the structure (assumed char) */ - HPyMember_BOOL = 14, - HPyMember_OBJECT_EX = 16, /* Like T_OBJECT, but raises AttributeError - when the value is NULL, instead of - converting to None. */ - HPyMember_LONGLONG = 17, - HPyMember_ULONGLONG = 18, - - HPyMember_HPYSSIZET = 19, /* HPy_ssize_t */ - HPyMember_NONE = 20, /* Value is always None */ - -} HPyMember_FieldType; - -/** - * C structure to define an HPy member. - * - * It is perfectly fine to fill this structure manually. However, the - * recommended and easier way is to use macro :c:macro:`HPyDef_MEMBER`. - */ -typedef struct { - /** The name of Python attribute (UTF-8 encoded) */ - const char *name; - - /** The type of the HPy member (see enum ``HPyMember_FieldType``). */ - HPyMember_FieldType type; - - /** - * The location (byte offset) of the member. Usually computed with - * ``offsetof(type, field)``. - */ - HPy_ssize_t offset; - - /** Flag indicating if the member is read-only */ - int readonly; - - /** Docstring of the member (UTF-8 encoded; may be ``NULL``) */ - const char *doc; -} HPyMember; - -/** - * C structure to define an HPy get/set descriptor. - * - * It is perfectly fine to fill this structure manually. However, the - * recommended and easier way is to use macros :c:macro:`HPyDef_GET` (to create - * a get descriptor only), :c:macro:`HPyDef_SET` (to create a set descriptor - * only), or :c:macro:`HPyDef_GETSET` (to create both). - */ -typedef struct { - /** The name of Python attribute (UTF-8 encoded) */ - const char *name; - - /** Function pointer of the C getter function (may be ``NULL``) */ - HPyCFunction getter_impl; - - /** Function pointer of the C setter function (may be ``NULL``) */ - HPyCFunction setter_impl; - - /** - * Function pointer to the CPython trampoline function for the getter (may - * be ``NULL`` if (and only if) ``getter_impl == NULL``) - */ - cpy_getter getter_cpy_trampoline; - - /** - * Function pointer to the CPython trampoline function for the setter (may - * be ``NULL`` if (and only if) ``setter_impl == NULL``) - */ - cpy_setter setter_cpy_trampoline; - - /** Docstring of the get/set descriptor (UTF-8 encoded; may be ``NULL``) */ - const char *doc; - - /** - * A value that will be passed to the ``getter_impl``/``setter_impl`` - * functions. - */ - void *closure; - -} HPyGetSet; - -/** - * Enum to identify an HPy definition's kind. - */ -typedef enum { - HPyDef_Kind_Slot = 1, - HPyDef_Kind_Meth = 2, - HPyDef_Kind_Member = 3, - HPyDef_Kind_GetSet = 4, -} HPyDef_Kind; - -/** - * Generic structure of an HPy definition. - * - * This struct can be used to define a slot, method, member, or get/set - * descriptor. For details, see embedded structures :c:struct:`HPySlot`, - * :c:struct:`HPyMeth`, :c:struct:`HPyMember`, or :c:struct:`HPyGetSet`. - */ -typedef struct { - /** - * The kind of this definition. - * The value of this field determines which one of the embedded members - * ``slot``, ``meth``, ``member``, or ``getset`` is used. Since those are - * combined in a union, only one can be used at a time. - */ - HPyDef_Kind kind; - - union { - HPySlot slot; - HPyMeth meth; - HPyMember member; - HPyGetSet getset; - }; -} HPyDef; - -typedef struct { - cpy_PyCapsule_Destructor cpy_trampoline; - HPyFunc_Capsule_Destructor impl; -} HPyCapsule_Destructor; - -typedef struct { - cpy_vectorcallfunc cpy_trampoline; - HPyFunc_keywords impl; -} HPyCallFunction; - -// macros to automatically define HPyDefs of various kinds - -/* ~~~ HPySlot_SIG ~~~ - - Macro-magic to automatically determine the HPyFunc_Signature from a - symbolic slot name such as HPy_tp_repr, HPy_nb_add, etc. - */ - -#define HPySlot_SIG(SLOT) _HPySlot_SIG__##SLOT -// Macros such as _HPySlot_SIG__HPy_tp_add &co. are defined in autogen_hpyslot.h - - - -/* ~~~ HPyDef_SLOT ~~~ - - This is the official version of HPyDef_SLOT, which automatically determines - the SIG from the SLOT. The anonymous enum is needed to get a nice - compile-time error in case we pass a SLOT which does not exist, see the - more detailed explanation in the comments around HPyFunc_DECLARE in - hpyfunc.h -*/ -#define HPyDef_SLOT_IMPL(SYM, IMPL, SLOT) \ - enum { SYM##_slot = SLOT }; \ - _HPyDef_SLOT(SYM, IMPL, SLOT, HPySlot_SIG(SLOT)) - -/** - * A convenience macro and recommended way to create a definition for an HPy - * slot. - * - * The macro generates a C global variable and an appropriate CPython - * trampoline function. It will fill an :c:struct:`HPyDef` structure appropriately - * and store it in the global variable. - * - * This macro expects a C function ``SYM_impl`` that will be used as the - * implementing slot function. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param SLOT: The HPy slot identifier. - */ -#define HPyDef_SLOT(SYM, SLOT) \ - HPyDef_SLOT_IMPL(SYM, SYM##_impl, SLOT) - -// this is the actual implementation, after we determined the SIG -#define _HPyDef_SLOT(SYM, IMPL, SLOT, SIG) \ - HPyFunc_DECLARE(IMPL, SIG); \ - HPyFunc_TRAMPOLINE(SYM##_trampoline, IMPL, SIG); \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_Slot, \ - .slot = { \ - .slot = SLOT, \ - .impl = (HPyCFunction)IMPL, \ - .cpy_trampoline = (cpy_PyCFunction)SYM##_trampoline \ - } \ - }; - - -#define HPyDef_METH_IMPL(SYM, NAME, IMPL, SIG, ...) \ - HPyFunc_DECLARE(IMPL, SIG); \ - HPyFunc_TRAMPOLINE(SYM##_trampoline, IMPL, SIG) \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_Meth, \ - .meth = { \ - .name = NAME, \ - .impl = (HPyCFunction)IMPL, \ - .cpy_trampoline = (cpy_PyCFunction)SYM##_trampoline, \ - .signature = SIG, \ - __VA_ARGS__ \ - } \ - }; - -/** - * A convenience macro and recommended way to create a definition for an HPy - * method. - * - * The macro generates a C global variable and an appropriate CPython - * trampoline function. It will fill an :c:struct:`HPyDef` structure appropriately - * and store it in the global variable. - * - * This macro expects a C function ``SYM_impl`` that will be used as the - * implementing C function. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param NAME: The Python attribute name (UTF-8 encoded). - * :param SIG: The implementation's C signature (see - * :c:enum:`HPyFunc_Signature`). - */ -#define HPyDef_METH(SYM, NAME, SIG, ...) \ - HPyDef_METH_IMPL(SYM, NAME, SYM##_impl, SIG, __VA_ARGS__) - -/** - * A convenience macro and recommended way to create a definition for an HPy - * member. - * - * The macro generates a C global variable. It will fill an :c:struct:`HPyDef` - * structure appropriately and store it in the global variable. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param NAME: The Python attribute name (UTF-8 encoded). - * :param TYPE: The implementation's C signature (see - * :c:enum:`HPyFunc_Signature`). - * :param OFFSET: The Python attribute name (UTF-8 encoded). - * :param .readonly: Optional flag indicating if the member is read-only. - * :param .doc: Optional docstring (UTF-8 encoded). - */ -#define HPyDef_MEMBER(SYM, NAME, TYPE, OFFSET, ...) \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_Member, \ - .member = { \ - .name = NAME, \ - .type = TYPE, \ - .offset = OFFSET, \ - __VA_ARGS__ \ - } \ - }; - -#define HPyDef_GET_IMPL(SYM, NAME, GETIMPL, ...) \ - HPyFunc_DECLARE(GETIMPL, HPyFunc_GETTER); \ - HPyFunc_TRAMPOLINE(SYM##_get_trampoline, GETIMPL, HPyFunc_GETTER); \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_GetSet, \ - .getset = { \ - .name = NAME, \ - .getter_impl = (HPyCFunction)GETIMPL, \ - .getter_cpy_trampoline = (cpy_getter)SYM##_get_trampoline, \ - __VA_ARGS__ \ - } \ - }; - -/** - * A convenience macro and recommended way to create a definition for an HPy - * get descriptor. - * - * The macro generates a C global variable. It will fill an :c:struct:`HPyDef` - * structure appropriately and store it in the global variable. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param NAME: The Python attribute name (UTF-8 encoded). - * :param .doc: Optional docstring (UTF-8 encoded). - * :param .closure: Optional pointer, providing additional data for the getter. - */ -#define HPyDef_GET(SYM, NAME, ...) \ - HPyDef_GET_IMPL(SYM, NAME, SYM##_get, __VA_ARGS__) - -#define HPyDef_SET_IMPL(SYM, NAME, SETIMPL, ...) \ - HPyFunc_DECLARE(SETIMPL, HPyFunc_SETTER); \ - HPyFunc_TRAMPOLINE(SYM##_set_trampoline, SETIMPL, HPyFunc_SETTER); \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_GetSet, \ - .getset = { \ - .name = NAME, \ - .setter_impl = (HPyCFunction)SETIMPL, \ - .setter_cpy_trampoline = (cpy_setter)SYM##_set_trampoline, \ - __VA_ARGS__ \ - } \ - }; - -/** - * A convenience macro and recommended way to create a definition for an HPy - * set descriptor. - * - * The macro generates a C global variable. It will fill an :c:struct:`HPyDef` - * structure appropriately and store it in the global variable. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param NAME: The Python attribute name (UTF-8 encoded). - * :param .doc: Optional docstring (UTF-8 encoded). - * :param .closure: Optional pointer, providing additional data for the setter. - */ -#define HPyDef_SET(SYM, NAME, ...) \ - HPyDef_SET_IMPL(SYM, NAME, SYM##_set, __VA_ARGS__) - -#define HPyDef_GETSET_IMPL(SYM, NAME, GETIMPL, SETIMPL, ...) \ - HPyFunc_DECLARE(GETIMPL, HPyFunc_GETTER); \ - HPyFunc_TRAMPOLINE(SYM##_get_trampoline, GETIMPL, HPyFunc_GETTER); \ - HPyFunc_DECLARE(SETIMPL, HPyFunc_SETTER); \ - HPyFunc_TRAMPOLINE(SYM##_set_trampoline, SETIMPL, HPyFunc_SETTER); \ - HPyDef SYM = { \ - .kind = HPyDef_Kind_GetSet, \ - .getset = { \ - .name = NAME, \ - .getter_impl = (HPyCFunction)GETIMPL, \ - .setter_impl = (HPyCFunction)SETIMPL, \ - .getter_cpy_trampoline = (cpy_getter)SYM##_get_trampoline, \ - .setter_cpy_trampoline = (cpy_setter)SYM##_set_trampoline, \ - __VA_ARGS__ \ - } \ - }; - -/** - * A convenience macro and recommended way to create a definition for an HPy - * get/set descriptor. - * - * The macro generates a C global variable. It will fill an :c:struct:`HPyDef` - * structure appropriately and store it in the global variable. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated HPy definition. The variable is defined - * as ``static``. - * :param NAME: The Python attribute name (UTF-8 encoded). - * :param .doc: Optional docstring (UTF-8 encoded). - * :param .closure: Optional pointer, providing additional data for the getter - * and setter. - */ -#define HPyDef_GETSET(SYM, NAME, ...) \ - HPyDef_GETSET_IMPL(SYM, NAME, SYM##_get, SYM##_set, __VA_ARGS__) - -#define HPyCapsule_DESTRUCTOR(SYM) \ - static void SYM##_impl(const char *name, void *pointer, void *context); \ - HPyCapsule_DESTRUCTOR_TRAMPOLINE(SYM##_trampoline, SYM##_impl); \ - static HPyCapsule_Destructor SYM = { \ - .cpy_trampoline = SYM##_trampoline, \ - .impl = SYM##_impl \ - }; - -/** - * A convenience macro and the recommended way to create a call function - * definition. - * - * The macro generates a C global variable with name ``SYM``. It will fill an - * :c:struct:`HPyCallFunction` structure appropriately and store it in the - * global variable. - * - * This macro expects a C function ``SYM_impl`` that will be used as the - * implementing C function. - * - * :param SYM: A C symbol name of the resulting global variable that will - * contain the generated call function definition. The variable is - * defined as ``static``. - */ -#define HPyDef_CALL_FUNCTION(SYM) \ - HPyFunc_DECLARE(SYM##_impl, HPyFunc_KEYWORDS); \ - HPyFunc_TRAMPOLINE(SYM##_trampoline, SYM##_impl, HPyFunc_KEYWORDS); \ - static HPyCallFunction SYM = { \ - .cpy_trampoline = SYM##_trampoline, \ - .impl = SYM##_impl \ - }; - -#ifdef __cplusplus -} -#endif -#endif /* HPY_UNIVERSAL_HPYDEF_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyexports.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyexports.h deleted file mode 100644 index f627b7d361..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyexports.h +++ /dev/null @@ -1,37 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPy_EXPORTS_H -#define HPy_EXPORTS_H - -// Copied from Python's exports.h -#ifndef HPy_EXPORTED_SYMBOL - #if defined(_WIN32) || defined(__CYGWIN__) - #define HPy_EXPORTED_SYMBOL __declspec(dllexport) - #else - #define HPy_EXPORTED_SYMBOL __attribute__ ((visibility ("default"))) - #endif -#endif - -#endif /* HPy_EXPORTS_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyfunc.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyfunc.h deleted file mode 100644 index a11db14e7f..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpyfunc.h +++ /dev/null @@ -1,149 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_HPYFUNC_H -#define HPY_UNIVERSAL_HPYFUNC_H - -typedef enum { - HPyFunc_VARARGS = 1, // METH_FASTCALL - HPyFunc_KEYWORDS = 2, // METH_FASTCALL | METH_KEYWORDS - HPyFunc_NOARGS = 3, // METH_NOARGS - HPyFunc_O = 4, // METH_O - - HPyFunc_DESTROYFUNC, - - HPyFunc_GETBUFFERPROC, - HPyFunc_RELEASEBUFFERPROC, - HPyFunc_UNARYFUNC, - HPyFunc_BINARYFUNC, - HPyFunc_TERNARYFUNC, - HPyFunc_INQUIRY, - HPyFunc_LENFUNC, - HPyFunc_SSIZEARGFUNC, - HPyFunc_SSIZESSIZEARGFUNC, - HPyFunc_SSIZEOBJARGPROC, - HPyFunc_SSIZESSIZEOBJARGPROC, - HPyFunc_OBJOBJARGPROC, - HPyFunc_FREEFUNC, - HPyFunc_GETATTRFUNC, - HPyFunc_GETATTROFUNC, - HPyFunc_SETATTRFUNC, - HPyFunc_SETATTROFUNC, - HPyFunc_REPRFUNC, - HPyFunc_HASHFUNC, - HPyFunc_RICHCMPFUNC, - HPyFunc_GETITERFUNC, - HPyFunc_ITERNEXTFUNC, - HPyFunc_DESCRGETFUNC, - HPyFunc_DESCRSETFUNC, - HPyFunc_INITPROC, - HPyFunc_NEWFUNC, - HPyFunc_GETTER, - HPyFunc_SETTER, - HPyFunc_OBJOBJPROC, - HPyFunc_TRAVERSEPROC, - HPyFunc_DESTRUCTOR, - HPyFunc_CAPSULE_DESTRUCTOR, - HPyFunc_VECTORCALLFUNC, - - HPyFunc_MOD_CREATE, - -} HPyFunc_Signature; - -/* The typedefs corresponding to the various HPyFunc_Signature members - are produced inside autogen_hpyfunc_declare.h. */ - - -/* ~~~ HPyFunc_DECLARE ~~~ - - Emit a forward declaration for a function SYM having a signature SIG, where - SIG is one of HPyFunc_Signature members. - - Strictly speaking, the anonymous enum is not needed, since it just defines - a constant like Foo_sig which is never used anyway. However, since we try - to use "SIG" in the enum definition, we get a very nice error message in - case we use a SIG value which does not exists. If we didn't use this - trick, we would get a VERY obscure error message, since gcc would see a - function call to something like _HPyFunc_DECLARE_HPyFunc_XXX. -*/ -#define HPyFunc_DECLARE(SYM, SIG) \ - enum { SYM##_sig = SIG }; \ - _HPyFunc_DECLARE_##SIG(SYM) - - -/* ~~~ HPyFunc_TRAMPOLINE ~~~ - - Emit a CPython-compatible trampoline which calls IMPL, where IMPL has the - signature SIG. See above for why we need the anonymous enum. The actual - implementation of trampolines are in hpyfunc_trampolines.h, which is - different for the CPython and Universal cases -*/ -#define HPyFunc_TRAMPOLINE(SYM, IMPL, SIG) \ - enum { SYM##_sig = SIG }; \ - _HPyFunc_TRAMPOLINE_##SIG(SYM, IMPL) - -typedef struct { - void *buf; - HPy obj; /* owned reference */ - HPy_ssize_t len; - HPy_ssize_t itemsize; - int readonly; - int ndim; - char *format; - HPy_ssize_t *shape; - HPy_ssize_t *strides; - HPy_ssize_t *suboffsets; - void *internal; -} HPy_buffer; - -typedef int (*HPyFunc_visitproc)(HPyField *, void *); - -/* COPIED AND ADAPTED FROM CPython. - * Utility macro to help write tp_traverse functions - * To use this macro, the tp_traverse function must name its arguments - * "visit" and "arg". This is intended to keep tp_traverse functions - * looking as much alike as possible. - */ -#define HPy_VISIT(hpyfield) \ - do { \ - if (!HPyField_IsNull(*hpyfield)) { \ - int vret = visit(hpyfield, arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) - - - -#include "autogen_hpyfunc_declare.h" - -#ifdef HPY_ABI_CPYTHON -# include "cpython/hpyfunc_trampolines.h" -# include "cpython/autogen_hpyfunc_trampolines.h" -#else -# include "universal/hpyfunc_trampolines.h" -# include "universal/autogen_hpyfunc_trampolines.h" -#endif // HPY_ABI_CPYTHON - -#endif /* HPY_UNIVERSAL_HPYFUNC_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpymodule.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpymodule.h deleted file mode 100644 index 4badb12cfa..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpymodule.h +++ /dev/null @@ -1,182 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_HPYMODULE_H -#define HPY_UNIVERSAL_HPYMODULE_H - -/* If 'HPY_EMBEDDED_MODULES' is defined, this means that there will be several - embedded HPy modules (and so, several 'HPy_MODINIT' usages) in the same - binary. In this case, some restrictions apply: (1) all of the module's - methods/member/slots/... must be defined in the same file, and (2) the - embedder *MUST* declare the module to be "embeddable" by using macro - 'HPY_MOD_EMBEDDABLE(modname)'. */ -#ifdef HPY_EMBEDDED_MODULES -#define _HPy_CTX_MODIFIER static -#define HPY_MOD_EMBEDDABLE(modname) \ - _HPy_CTX_MODIFIER HPyContext *_ctx_for_trampolines; -#else -#define _HPy_CTX_MODIFIER _HPy_HIDDEN -/** - * Declares a module to be *embeddable* which means that it and its members can - * be compiled/linked into a binary together with other embeddable HPy modules. - * - * You may declare a module to be *embeddable* if all of its member definitions - * are in the same file. - */ -#define HPY_MOD_EMBEDDABLE(modname) -// this is defined by HPy_MODINIT -extern HPyContext *_ctx_for_trampolines; -#endif - - -/** - * Definition of a Python module. Pointer to this struct is returned from - * the HPy initialization function ``HPyInit_{extname}`` and the Python - * interpreter creates a Python module from it. HPy supports only the - * multi-phase module initialization approach (PEP 451). - * - * There is no HPy API to create a Python module manually, i.e., equivalent - * of ``PyModule_Create`` or ``PyModule_FromDefAndSpec``, for the time being, - * but may be added if a use-case arises. - * - * Note: unlike Python/C API, HPy module definition does not specify module - * name. The name if always taken from the ModuleSpec, which is also the case - * in multi-phase module initialization on Python/C API. - */ -typedef struct { - /** Docstring of the type (UTF-8 encoded; may be ``NULL``) */ - const char* doc; - - /** - * The size (in bytes) of the module state structure. If set to zero, - * then the module will not get allocated and assigned any HPy module state. - * Negative size, unlike in Python/C API, does not have any specific meaning - * and will produce a runtime error. - */ - HPy_ssize_t size; - - /** - * ``NULL``-terminated list of legacy module-level methods. - * In order to enable incremental migration - * from C API to HPy, it is possible to still add *legacy* method - * definitions. Those methods have a C API signature which means that they - * still receive ``PyObject *`` and similar arguments. If legacy methods - * are defined, you cannot create a *universal binary* (i.e. a binary that - * will run on all Python engines). - */ - cpy_PyMethodDef *legacy_methods; - - /** - * Pointer to a ``NULL``-terminated array of pointers to HPy defines (i.e. - * ``HPyDef *``). Note, that some kinds of HPy definitions don't make sense - * for a module. In particular, anything else than methods. - */ - HPyDef **defines; - - /** - * Pointer to a ``NULL``-terminated array of pointers to - * :c:struct:`HPyGlobal` variables. For details, see :doc:`hpy-global`. - */ - HPyGlobal **globals; -} HPyModuleDef; - - -#if defined(__cplusplus) -# define HPy_EXPORTED_FUNC extern "C" HPy_EXPORTED_SYMBOL -#else /* __cplusplus */ -# define HPy_EXPORTED_FUNC HPy_EXPORTED_SYMBOL -#endif /* __cplusplus */ - -#ifdef HPY_ABI_CPYTHON - -// helpers provided by HPy runtime: -#include "hpy/runtime/ctx_module.h" - -// module initialization in the CPython case -#define HPy_MODINIT(ext_name, mod_def) \ - PyMODINIT_FUNC \ - PyInit_##ext_name(void) \ - { \ - return _HPyModuleDef_AsPyInit(&mod_def); \ - } - -#else // HPY_ABI_CPYTHON - -// module initialization in the universal and hybrid case - -/** - * Convenience macro for generating the module initialization code. This will - * generate three functions that are used by to verify an initialize the module - * when loading: - * - * ``get_required_hpy_major_version_`` - * The HPy major version this module was built with. - * - * ``get_required_hpy_minor_version_`` - * The HPy minor version this module was built with. - * - * ``HPyModuleDef* HPyInit_`` - * The init function that will be called by the interpreter. This function - * does not have an access to HPyContext and thus cannot call any HPy APIs. - * The purpose of this function is to return a pointer to a HPyModuleDef - * structure that will serve as a specification of the module that should be - * created by the interpreter. HPy supports only multi-phase module - * initialization (PEP 451). Any module initialization code can be added - * to the HPy_mod_exec slot of the module if needed. - * - * Example: - * - * .. code-block:: c - * - * HPy_MODINIT(myextension_shared_library_filename, my_hpy_module_def) - */ -#define HPy_MODINIT(ext_name, mod_def) \ - HPy_EXPORTED_FUNC uint32_t \ - get_required_hpy_major_version_##ext_name() \ - { \ - return HPY_ABI_VERSION; \ - } \ - HPy_EXPORTED_FUNC uint32_t \ - get_required_hpy_minor_version_##ext_name() \ - { \ - return HPY_ABI_VERSION_MINOR; \ - } \ - _HPy_CTX_MODIFIER HPyContext *_ctx_for_trampolines; \ - HPy_EXPORTED_FUNC void \ - HPyInitGlobalContext_##ext_name(HPyContext *ctx) \ - { \ - _ctx_for_trampolines = ctx; \ - } \ - HPy_EXPORTED_FUNC HPyModuleDef* \ - HPyInit_##ext_name() \ - { \ - return &mod_def; \ - } - -// Implementation note: the global HPyContext is used by the CPython -// trampolines generated by the HPyDef_XXX macros - -#endif // HPY_ABI_CPYTHON - -#endif // HPY_UNIVERSAL_HPYMODULE_H diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpytype.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpytype.h deleted file mode 100644 index 38a0a301a7..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/hpytype.h +++ /dev/null @@ -1,311 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_HPYTYPE_H -#define HPY_UNIVERSAL_HPYTYPE_H - -#include -#ifdef __GNUC__ -#define HPyAPI_UNUSED __attribute__((unused)) static inline -#else -#define HPyAPI_UNUSED static inline -#endif /* __GNUC__ */ - -// NOTE: HPyType_BuiltinShape_Object == 0, which means it's the default -// if it's not specified in HPyType_spec -typedef enum { - /** - * A type whose struct starts with ``PyObject_HEAD`` or equivalent is a - * legacy type. A legacy type must set - * ``.builtin_shape = HPyType_BuiltinShape_Legacy`` in its - * :c:struct:`HPyType_Spec`. - * - * A type is a non-legacy type, also called HPy pure type, if its struct does - * not include ``PyObject_HEAD``. Using pure types should be preferred. - * Legacy types are available to allow gradual porting of existing CPython - * extensions. - * - * A type with ``.legacy_slots != NULL`` - * (see :c:member:`HPyType_Spec.legacy_slots`) is required to have - * ``HPyType_BuiltinShape_Legacy`` and to include ``PyObject_HEAD`` at the - * start of its struct. It would be easy to relax this requirement on - * CPython (where the ``PyObject_HEAD`` fields are always present) but a - * large burden on other implementations (e.g. PyPy, GraalPy) where a - * struct starting with ``PyObject_HEAD`` might not exist. - * - * Types created via the old Python C API are automatically legacy types. - */ - HPyType_BuiltinShape_Legacy = -1, - - /** The type inherits from built-in type ``object`` (default). */ - HPyType_BuiltinShape_Object = 0, - - /** - * The type inherits from built-in type ``type``. This can be used to - * create metaclasses. If using this shape, you need to specify base class - * ``ctx->h_TypeType``. - */ - HPyType_BuiltinShape_Type = 1, - - /** - * The type inherits from built-in type ``int`` (aka. long object). If using - * this shape, you need to specify base class ``ctx->h_LongType``. - */ - HPyType_BuiltinShape_Long = 2, - - /** - * The type inherits from built-in type ``float``. If using this shape, you - * need to specify base class ``ctx->h_FloatType``. - */ - HPyType_BuiltinShape_Float = 3, - - /** - * The type inherits from built-in type ``str`` (aka. unicode object). If - * using this shape, you need to specify base class ``ctx->h_UnicodeType``. - */ - HPyType_BuiltinShape_Unicode = 4, - - /** - * The type inherits from built-in type ``tuple``. If using this shape, you - * need to specify base class ``ctx->h_TupleType``. - */ - HPyType_BuiltinShape_Tuple = 5, - - /** - * The type inherits from built-in type ``list``. If using this shape, you - * need to specify base class ``ctx->h_ListType``. - */ - HPyType_BuiltinShape_List = 6, -} HPyType_BuiltinShape; - -typedef struct { - cpy_vectorcallfunc cpy_trampoline; - HPyCallFunction impl; -} HPyType_Vectorcall; - -typedef struct { - /** The Python name of type (UTF-8 encoded) */ - const char* name; - - /** - * The size in bytes of the types associated native structure. Usually, you - * define some C structure, e.g., ``typedef struct { int a; } MyObject;``, - * and then this field is set to ``sizeof(MyObject)``. - */ - int basicsize; - - /** The size of embedded elements (currently not supported). */ - int itemsize; - - /** - * Type flags (see :c:macro:`HPy_TPFLAGS_DEFAULT`, - * :c:macro:`HPy_TPFLAGS_BASETYPE`, :c:macro:`HPy_TPFLAGS_HAVE_GC`, and - * others if available). - */ - unsigned long flags; - - /** - * The internal *shape* of the type. - * - * The shape gives the necessary hint to compute the offset to the data - * pointer of the object's underlying struct that should be returned when - * calling ``MyObject_AsStruct``. - * - * **ATTENTION**: - * It is also necessary to specify the right base class in - * the type's specification parameters (see :c:struct:`HPyType_SpecParam`). - * - * Assuming that the type's C structure is called ``MyObject``, this field - * should be initialized with ``.builtin_shape = SHAPE(MyObject)``. Note: - * This requires that you use :c:macro:`HPyType_HELPERS` or - * :c:macro:`HPyType_LEGACY_HELPERS`. - * - * Some more explanation: It would be possible to reduce this information - * to a Boolean that specifies if the type is a *legacy* type or not. - * Everything else could be determined by looking at the base classes. - * However, with this information it is possible to do the data pointer - * computation statically and thus is performance critical. - * - * Types that do not define a struct of their own, should set the value of - * ``.builtin_shape`` to the same value as the type they inherit from. If - * they inherit from a built-in type, they must set the corresponding - * ``.builtin_shape``. - */ - HPyType_BuiltinShape builtin_shape; - - /** - * Pointer to a ``NULL``-terminated array of legacy (i.e. ``PyType_Slot``) - * slots. - * - * A type with ``.legacy_slots != NULL`` is required to have - * ``HPyType_BuiltinShape_Legacy`` and to include ``PyObject_HEAD`` at the - * start of its struct. It would be easy to relax this requirement on - * CPython (where the ``PyObject_HEAD`` fields are always present) but a - * large burden on other implementations (e.g. PyPy, GraalPy) where a - * struct starting with ``PyObject_HEAD`` might not exist. - */ - void *legacy_slots; - - /** - * Pointer to a ``NULL``-terminated array of pointers to HPy defines (i.e. - * ``HPyDef *``). - */ - HPyDef **defines; - - /** Docstring of the type (UTF-8 encoded; may be ``NULL``) */ - const char* doc; -} HPyType_Spec; - -typedef enum { - /** - * Specify a base class. This parameter may be repeated but cannot be used - * together with - * :c:enumerator:`HPyType_SpecParam_Kind.HPyType_SpecParam_BasesTuple`. - */ - HPyType_SpecParam_Base = 1, - - /** - * Specify a tuple of base classes. Cannot be used together with - * :c:enumerator:`HPyType_SpecParam_Kind.HPyType_SpecParam_Base` - */ - HPyType_SpecParam_BasesTuple = 2, - - /** Specify a meta class for the type. */ - HPyType_SpecParam_Metaclass = 3, - - //HPyType_SpecParam_Module = 4, -} HPyType_SpecParam_Kind; - -typedef struct { - /** The kind of the type spec param. */ - HPyType_SpecParam_Kind kind; - - /** The value of the type spec param (an HPy handle). */ - HPy object; -} HPyType_SpecParam; - -/* All types are dynamically allocated */ -#define _Py_TPFLAGS_HEAPTYPE (1UL << 9) -#define _Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) - -/** Default type flags for HPy types. */ -#define HPy_TPFLAGS_DEFAULT (_Py_TPFLAGS_HEAPTYPE | _Py_TPFLAGS_HAVE_VERSION_TAG) - -/** Set if the type implements the vectorcall protocol (PEP 590) */ -#define HPy_TPFLAGS_HAVE_VECTORCALL (1UL << 11) - -/** Set if the type allows subclassing */ -#define HPy_TPFLAGS_BASETYPE (1UL << 10) - -/** Set if the type allows subclassing */ -#define HPy_TPFLAGS_BASETYPE (1UL << 10) - -/** If set, the object will be tracked by CPython's GC. Probably irrelevant for - GC-based alternative implementations. */ -#define HPy_TPFLAGS_HAVE_GC (1UL << 14) - -/** Convenience macro which is equivalent to: - ``HPyType_HELPERS(TYPE, HPyType_BuiltinShape_Legacy)`` */ -#define HPyType_LEGACY_HELPERS(TYPE) \ - HPyType_HELPERS(TYPE, HPyType_BuiltinShape_Legacy) - -#define _HPyType_HELPER_TYPE(TYPE, ...) TYPE * -#define _HPyType_HELPER_FNAME(TYPE, ...) TYPE##_AsStruct -#define _HPyType_HELPER_DEFINE_SHAPE(TYPE, SHAPE, ...) \ - enum { TYPE##_SHAPE = (int)SHAPE } -#define _HPyType_HELPER_AS_STRUCT(TYPE, SHAPE, ...) SHAPE##_AsStruct -// helper macro make MSVC's preprocessor work with our variadic macros -#define _HPyType_HELPER_X(X) X - -/** - A macro for creating (static inline) helper functions for custom types. - - Two versions of the helper exist. One for legacy types and one for pure - HPy types. - - Example for a pure HPy custom type: - - ``HPyType_HELPERS(PointObject)`` - - It is also possible to inherit from some built-in types. The list of - available built-in base types is given in enum `HPyTupe_BuiltinShape`. - In case you want to inherit from one of those, it is necessary to specify - the base built-in type in the `HPyType_HELPERS` macro. Here is an example - for a pure HPy custom type inheriting from a built-in type 'tuple': - - ``HPyType_HELPERS(PointObject, HPyType_BuiltinShape_Tuple)`` - - This would generate the following: - - * ``PointObject * PointObject_AsStruct(HPyContext *ctx, HPy h)``: a static - inline function that uses HPy_AsStruct to return the PointObject struct - associated with a given handle. The behaviour is undefined if `h` - is associated with an object that is not an instance of PointObject. - However, debug mode will catch an incorrect usage. - - * ``SHAPE(PointObject)``: a macro that is meant to be used as static - initializer in the corresponding HPyType_Spec. It is recommended to write - ``.builtin_shape = SHAPE(PointObject)`` such that you don't have to - remember to update the spec when the helpers used changes. - - Example for a legacy custom type: - - ``HPyType_LEGACY_HELPERS(PointObject)`` - - This would generate the same functions and constants as above, except: - - * ``_HPy_AsStruct_Legacy`` is used instead of ``_HPy_AsStruct_Object``. - - * ``SHAPE(PointObject)`` would be ``HPyType_BuiltinShape_Legacy``. - - :param STRUCT: The C structure of the HPy type. - :param SHAPE: Optional. The built-in shape of the type. This defaults to - :c:enumerator:`HPyType_BuiltinShape_Object`. Possible values - are all enumerators of :c:enum:`HPyType_BuiltinShape`. -*/ -#define HPyType_HELPERS(...) \ - \ -_HPyType_HELPER_X( \ - _HPyType_HELPER_DEFINE_SHAPE(__VA_ARGS__, HPyType_BuiltinShape_Object)); \ - \ -HPyAPI_UNUSED _HPyType_HELPER_X(_HPyType_HELPER_TYPE(__VA_ARGS__)) \ -_HPyType_HELPER_X(_HPyType_HELPER_FNAME(__VA_ARGS__))(HPyContext *ctx, HPy h) \ -{ \ - return (_HPyType_HELPER_X(_HPyType_HELPER_TYPE(__VA_ARGS__))) \ - _HPyType_HELPER_X(_HPyType_HELPER_AS_STRUCT(__VA_ARGS__, \ - HPyType_BuiltinShape_Object))(ctx, h); \ -} - -#define SHAPE(TYPE) ((HPyType_BuiltinShape)TYPE##_SHAPE) - -#define HPyType_BuiltinShape_Legacy_AsStruct _HPy_AsStruct_Legacy -#define HPyType_BuiltinShape_Object_AsStruct _HPy_AsStruct_Object -#define HPyType_BuiltinShape_Type_AsStruct _HPy_AsStruct_Type -#define HPyType_BuiltinShape_Long_AsStruct _HPy_AsStruct_Long -#define HPyType_BuiltinShape_Float_AsStruct _HPy_AsStruct_Float -#define HPyType_BuiltinShape_Unicode_AsStruct _HPy_AsStruct_Unicode -#define HPyType_BuiltinShape_Tuple_AsStruct _HPy_AsStruct_Tuple -#define HPyType_BuiltinShape_List_AsStruct _HPy_AsStruct_List - -#endif /* HPY_UNIVERSAL_HPYTYPE_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/inline_helpers.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/inline_helpers.h deleted file mode 100644 index c362616bb9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/inline_helpers.h +++ /dev/null @@ -1,561 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_INLINE_HELPERS_H -#define HPY_INLINE_HELPERS_H - -#if defined(_MSC_VER) -# include /* for alloca() */ -#endif - -#include - -/** - * Same as :c:func:`HPyErr_SetFromErrnoWithFilenameObjects` but passes - * ``HPy_NULL`` to the optional arguments. - * - * :param ctx: - * The execution context. - * :param h_type: - * The exception type to raise. - * - * :return: - * always returns ``HPy_NULL`` - */ -HPyAPI_INLINE_HELPER HPy -HPyErr_SetFromErrno(HPyContext *ctx, HPy h_type) -{ - return HPyErr_SetFromErrnoWithFilenameObjects(ctx, h_type, HPy_NULL, HPy_NULL); -} - -/** - * Same as :c:func:`HPyErr_SetFromErrnoWithFilenameObjects` but passes - * ``HPy_NULL`` to the last (optional) argument. - * - * :param ctx: - * The execution context. - * :param h_type: - * The exception type to raise. - * :param filename: - * a filename; may be ``HPy_NULL`` - * - * :return: - * always returns ``HPy_NULL`` - */ -HPyAPI_INLINE_HELPER HPy -HPyErr_SetFromErrnoWithFilenameObject(HPyContext *ctx, HPy h_type, HPy filename) -{ - return HPyErr_SetFromErrnoWithFilenameObjects(ctx, h_type, filename, HPy_NULL); -} - -/** - * Create a tuple from arguments. - * - * A convenience function that will allocate a temporary array of ``HPy`` - * elements and use :c:func:`HPyTuple_FromArray` to create a tuple. - * - * :param ctx: - * The execution context. - * :param n: - * The number of elements to pack into a tuple. - * :param ...: - * Variable number of ``HPy`` arguments. - * - * :return: - * A new tuple with ``n`` elements or ``HPy_NULL`` in case of an error - * occurred. - */ -HPyAPI_INLINE_HELPER HPy -HPyTuple_Pack(HPyContext *ctx, HPy_ssize_t n, ...) -{ - va_list vargs; - HPy_ssize_t i; - - if (n == 0) { - return HPyTuple_FromArray(ctx, (HPy*)NULL, n); - } - HPy *array = (HPy *)alloca(n * sizeof(HPy)); - va_start(vargs, n); - if (array == NULL) { - va_end(vargs); - return HPy_NULL; - } - for (i = 0; i < n; i++) { - array[i] = va_arg(vargs, HPy); - } - va_end(vargs); - return HPyTuple_FromArray(ctx, array, n); -} - -/** - * Delete an attribute. - * - * This is the equivalent of the Python statement ``del o.attr_name``. - * - * :param ctx: - * The execution context. - * :param obj: - * The object with the attribute. - * :param name: - * The name (an unicode object) of the attribute. - * - * :return: - * ``0`` on success; ``-1`` in case of an error. - */ -HPyAPI_INLINE_HELPER int -HPy_DelAttr(HPyContext *ctx, HPy obj, HPy name) -{ - return HPy_SetAttr(ctx, obj, name, HPy_NULL); -} - -/** - * Delete an attribute. - * - * This is the equivalent of the Python statement ``del o.attr_name``. - * - * :param ctx: - * The execution context. - * :param obj: - * The object with the attribute. - * :param utf8_name: - * The name (an UTF-8 encoded C string) of the attribute. - * - * :return: - * ``0`` on success; ``-1`` in case of an error. - */ -HPyAPI_INLINE_HELPER int -HPy_DelAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return HPy_SetAttr_s(ctx, obj, utf8_name, HPy_NULL); -} - -/** - * Create a Python long object from a C ``long`` value. - * - * :param ctx: - * The execution context. - * :param l: - * A C long value. - * - * :return: - * A Python long object with the value of ``l`` or ``HPy_NULL`` on failure. - */ -HPyAPI_INLINE_HELPER HPy -HPyLong_FromLong(HPyContext *ctx, long l) -{ - if (sizeof(long) <= sizeof(int32_t)) - return HPyLong_FromInt32_t(ctx, (int32_t)l); - assert(sizeof(long) <= sizeof(int64_t)); - return HPyLong_FromInt64_t(ctx, (int64_t)l); -} - -/** - * Create a Python long object from a C ``unsigned long`` value. - * - * :param ctx: - * The execution context. - * :param l: - * A C ``unsigned long`` value. - * - * :return: - * A Python long object with the value of ``l`` or ``HPy_NULL`` on failure. - */ -HPyAPI_INLINE_HELPER HPy -HPyLong_FromUnsignedLong(HPyContext *ctx, unsigned long l) -{ - if (sizeof(unsigned long) <= sizeof(uint32_t)) - return HPyLong_FromUInt32_t(ctx, (uint32_t)l); - assert(sizeof(unsigned long) <= sizeof(uint64_t)); - return HPyLong_FromUInt64_t(ctx, (uint64_t)l); -} - -/** - * Create a Python long object from a C ``long long`` value. - * - * :param ctx: - * The execution context. - * :param l: - * A C ``long long`` value. - * - * :return: - * A Python long object with the value of ``l`` or ``HPy_NULL`` on failure. - */ -HPyAPI_INLINE_HELPER HPy -HPyLong_FromLongLong(HPyContext *ctx, long long l) -{ - assert(sizeof(long long) <= sizeof(int64_t)); - return HPyLong_FromInt64_t(ctx, (int64_t)l); -} - -/** - * Create a Python long object from a C ``unsigned long long`` value. - * - * :param ctx: - * The execution context. - * :param l: - * A C ``unsigned long long`` value. - * - * :return: - * A Python long object with the value of ``l`` or ``HPy_NULL`` on failure. - */ -HPyAPI_INLINE_HELPER HPy -HPyLong_FromUnsignedLongLong(HPyContext *ctx, unsigned long long l) -{ - assert(sizeof(unsigned long long) <= sizeof(uint64_t)); - return HPyLong_FromUInt64_t(ctx, (uint64_t)l); -} - -/** - * Return a C ``long`` representation of the given Python long object. If the - * object is not an instance of Python long, the object's ``__index__`` method - * (if present) will be used to convert it to a Python long object. - * - * This function will raise an ``OverflowError`` if the value of the object is - * out of range for a C ``long``. - * - * This function will raise a ``TypeError`` if: - * - * * The object is neither an instance of Python long nor it provides an - * ``__index__`` method. - * * If the ``__index__`` method does not return an instance of Python long. - * - * :param ctx: - * The execution context. - * :param h: - * Either an instance of Python long or an object that provides an - * ``__index__`` method (which returns a Python long). - * - * :return: - * A C ``long`` value. Errors will be indicated with return value ``-1``. - * In this case, use :c:func:`HPyErr_Occurred` to disambiguate. - */ -HPyAPI_INLINE_HELPER long -HPyLong_AsLong(HPyContext *ctx, HPy h) -{ - if (sizeof(long) <= sizeof(int32_t)) - return (long) HPyLong_AsInt32_t(ctx, h); - else if (sizeof(long) <= sizeof(int64_t)) - return (long) HPyLong_AsInt64_t(ctx, h); -} - -/** - * Return a C ``unsigned long`` representation of the given Python long object. - * - * This function will raise a ``TypeError`` if the object is not an instance of - * Python long and it will raise an ``OverflowError`` if the object's value is - * negative or out of range for a C ``unsigned long``. - * - * :param ctx: - * The execution context. - * :param h: - * The object to convert to C ``unsigned long`` (must be an instance of - * Python long). - * - * :return: - * A C ``unsigned long`` value. Errors will be indicated with return value - * ``(unsigned long)-1``. In this case, use :c:func:`HPyErr_Occurred` to - * disambiguate. - */ -HPyAPI_INLINE_HELPER unsigned long -HPyLong_AsUnsignedLong(HPyContext *ctx, HPy h) -{ - if (sizeof(unsigned long) <= sizeof(uint32_t)) - return (unsigned long) HPyLong_AsUInt32_t(ctx, h); - else if (sizeof(unsigned long) <= sizeof(uint64_t)) - return (unsigned long) HPyLong_AsUInt64_t(ctx, h); -} - -/** - * Return a C ``unsigned long`` representation of the given Python long object. If the - * object is not an instance of Python long, the object's ``__index__`` method - * (if present) will be used to convert it to a Python long object. - * - * If the object's value is out of range for an ``unsigned long``, return the - * reduction of that value modulo ``ULONG_MAX + 1``. Therefore, this function - * will **NOT** raise an ``OverflowError`` if the value of the object is out of - * range for a C ``unsigned long``. - * - * :param ctx: - * The execution context. - * :param h: - * Either an instance of Python long or an object that provides an - * ``__index__`` method (which returns a Python long). - * - * :return: - * A C ``unsigned long`` value. Errors will be indicated with return value - * ``(unsigned long)-1``. In this case, use :c:func:`HPyErr_Occurred` to - * disambiguate. - */ -HPyAPI_INLINE_HELPER unsigned long -HPyLong_AsUnsignedLongMask(HPyContext *ctx, HPy h) -{ - if (sizeof(unsigned long) <= sizeof(uint32_t)) - return (unsigned long) HPyLong_AsUInt32_tMask(ctx, h); - else if (sizeof(unsigned long) <= sizeof(uint64_t)) - return (unsigned long) HPyLong_AsUInt64_tMask(ctx, h); -} - -/** - * Return a C ``long long`` representation of the given Python long object. If - * the object is not an instance of Python long, the object's ``__index__`` - * method (if present) will be used to convert it to a Python long object. - * - * This function will raise an ``OverflowError`` if the value of the object is - * out of range for a C ``long long``. - * - * This function will raise a ``TypeError`` if: - * - * * The object is neither an instance of Python long nor it provides an - * ``__index__`` method. - * * If the ``__index__`` method does not return an instance of Python long. - * - * :param ctx: - * The execution context. - * :param h: - * Either an instance of Python long or an object that provides an - * ``__index__`` method (which returns a Python long). - * - * :return: - * A C ``long long`` value. Errors will be indicated with return value - * ``-1``. In this case, use :c:func:`HPyErr_Occurred` to disambiguate. - */ -HPyAPI_INLINE_HELPER long long -HPyLong_AsLongLong(HPyContext *ctx, HPy h) -{ - assert(sizeof(long long) <= sizeof(int64_t)); - return (long long) HPyLong_AsInt64_t(ctx, h); -} - -/** - * Return a C ``unsigned long long`` representation of the given Python long - * object. - * - * This function will raise a ``TypeError`` if the object is not an instance of - * Python long and it will raise an ``OverflowError`` if the object's value is - * negative or out of range for a C ``unsigned long``. - * - * :param ctx: - * The execution context. - * :param h: - * The object to convert to C ``unsigned long long`` (must be an instance of - * Python long). - * - * :return: - * A C ``unsigned long long`` value. Errors will be indicated with return - * value ``(unsigned long long)-1``. In this case, use - * :c:func:`HPyErr_Occurred` to disambiguate. - */ -HPyAPI_INLINE_HELPER unsigned long long -HPyLong_AsUnsignedLongLong(HPyContext *ctx, HPy h) -{ - assert(sizeof(unsigned long long) <= sizeof(uint64_t)); - return (unsigned long long) HPyLong_AsUInt64_t(ctx, h); -} - -/** - * Return a C ``unsigned long long`` representation of the given Python long - * object. If the object is not an instance of Python long, the object's - * ``__index__`` method (if present) will be used to convert it to a Python long - * object. - * - * If the object's value is out of range for an ``unsigned long long``, return - * the reduction of that value modulo ``ULLONG_MAX + 1``. Therefore, this - * function will **NOT** raise an ``OverflowError`` if the value of the object - * is out of range for a C ``unsigned long long``. - * - * :param ctx: - * The execution context. - * :param h: - * Either an instance of Python long or an object that provides an - * ``__index__`` method (which returns a Python long). - * - * :return: - * A C ``unsigned long`` value. Errors will be indicated with return value - * ``(unsigned long long)-1``. In this case, use :c:func:`HPyErr_Occurred` - * to disambiguate. - */ -HPyAPI_INLINE_HELPER unsigned long long -HPyLong_AsUnsignedLongLongMask(HPyContext *ctx, HPy h) -{ - assert(sizeof(unsigned long long) <= sizeof(uint64_t)); - return (unsigned long long) HPyLong_AsUInt64_tMask(ctx, h); -} - -/** - * Returns Python ``True`` or ``False`` depending on the truth value of ``v``. - * - * :param ctx: - * The execution context. - * :param v: - * A C ``long`` value. - * - * :return: - * Python ``True`` if ``v != 0``; Python ``False`` otherwise. - */ -HPyAPI_INLINE_HELPER HPy -HPyBool_FromLong(HPyContext *ctx, long v) -{ - return HPyBool_FromBool(ctx, (v ? true : false)); -} - -/** - * Adjust start/end slice indices assuming a sequence of the specified length. - * - * Out of bounds indices are clipped in a manner consistent with the handling of - * normal slices. This function cannot fail and does not call interpreter - * routines. - * - * :param ctx: - * The execution context. - * :param length: - * The length of the sequence that should be assumed for adjusting the - * indices. - * :param start: - * Pointer to the start value (must not be ``NULL``). - * :param stop: - * Pointer to the stop value (must not be ``NULL``). - * :param step: - * The step value of the slice (must not be ``0``) - * - * :return: - * Return the length of the slice. Always successful. Doesn’t call Python code. - */ -HPyAPI_INLINE_HELPER HPy_ssize_t -HPySlice_AdjustIndices(HPyContext *_HPy_UNUSED_ARG(ctx), HPy_ssize_t length, - HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t step) -{ - /* Taken from CPython: Written by Jim Hugunin and Chris Chase. */ - /* this is harder to get right than you might think */ - assert(step != 0); - assert(step >= -HPY_SSIZE_T_MAX); - - if (*start < 0) { - *start += length; - if (*start < 0) { - *start = (step < 0) ? -1 : 0; - } - } - else if (*start >= length) { - *start = (step < 0) ? length - 1 : length; - } - - if (*stop < 0) { - *stop += length; - if (*stop < 0) { - *stop = (step < 0) ? -1 : 0; - } - } - else if (*stop >= length) { - *stop = (step < 0) ? length - 1 : length; - } - - if (step < 0) { - if (*stop < *start) { - return (*start - *stop - 1) / (-step) + 1; - } - } - else { - if (*start < *stop) { - return (*stop - *start - 1) / step + 1; - } - } - return 0; -} - -/** - * Call a method of a Python object. - * - * This is a convenience function for calling a method. It uses - * :c:func:`HPy_GetAttr_s` and :c:func:`HPy_CallTupleDict` to perform the method - * call. - * - * :param ctx: - * The execution context. - * :param utf8_name: - * The name (UTF-8 encoded C string) of the method. Must not be ``NULL``. - * :param receiver: - * A handle to the receiver of the call (i.e. the ``self``). Must not be - * ``HPy_NULL``. - * :param args: - * A handle to a tuple containing the positional arguments (must not be - * ``HPy_NULL`` but can, of course, be empty). - * :param kw: - * A handle to a Python dictionary containing the keyword arguments (may be - * ``HPy_NULL``). - * - * :returns: - * The result of the call on success, or ``HPy_NULL`` in case of an error. - */ -HPyAPI_INLINE_HELPER HPy -HPy_CallMethodTupleDict_s(HPyContext *ctx, const char *utf8_name, HPy receiver, HPy args, HPy kw) -{ - HPy method = HPy_GetAttr_s(ctx, receiver, utf8_name); - if (HPy_IsNull(method)) { - return HPy_NULL; - } - - HPy result = HPy_CallTupleDict(ctx, method, args, kw); - HPy_Close(ctx, method); - return result; -} - -/** - * Call a method of a Python object. - * - * This is a convenience function for calling a method. It uses - * :c:func:`HPy_GetAttr` and :c:func:`HPy_CallTupleDict` to perform the method - * call. - * - * :param ctx: - * The execution context. - * :param name: - * A handle to the name (a Unicode object) of the method. Must not be - * ``HPy_NULL``. - * :param receiver: - * A handle to the receiver of the call (i.e. the ``self``). Must not be - * ``HPy_NULL``. - * :param args: - * A handle to a tuple containing the positional arguments (must not be - * ``HPy_NULL`` but can, of course, be empty). - * :param kw: - * A handle to a Python dictionary containing the keyword arguments (may be - * ``HPy_NULL``). - * - * :returns: - * The result of the call on success, or ``HPy_NULL`` in case of an error. - */ -HPyAPI_INLINE_HELPER HPy -HPy_CallMethodTupleDict(HPyContext *ctx, HPy name, HPy receiver, HPy args, HPy kw) -{ - HPy method = HPy_GetAttr(ctx, receiver, name); - if (HPy_IsNull(method)) { - return HPy_NULL; - } - - HPy result = HPy_CallTupleDict(ctx, method, args, kw); - HPy_Close(ctx, method); - return result; -} - -#endif //HPY_INLINE_HELPERS_H diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/macros.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/macros.h deleted file mode 100644 index fc1df4e60b..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/macros.h +++ /dev/null @@ -1,94 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/* We define HPy_New as a macro around _HPy_New to suppress a - warning. Usually, we expected it to be called this way: - - PointObject *p; - HPy h = HPy_New(ctx, cls, &p); - - If we call _HPy_New directly, we get a warning because we are implicitly - casting a PointObject** into a void**. The following macro explicitly - casts the third argument to a void**. -*/ - -#define HPy_New(ctx, cls, data) (_HPy_New( \ - (ctx), \ - (cls), \ - ((void**)data) \ - )) - -/* Rich comparison opcodes */ -typedef enum { - HPy_LT = 0, - HPy_LE = 1, - HPy_EQ = 2, - HPy_NE = 3, - HPy_GT = 4, - HPy_GE = 5, -} HPy_RichCmpOp; - -// this needs to be a macro because val1 and val2 can be of arbitrary types -#define HPy_RETURN_RICHCOMPARE(ctx, val1, val2, op) \ - do { \ - bool result; \ - switch (op) { \ - case HPy_EQ: result = ((val1) == (val2)); break; \ - case HPy_NE: result = ((val1) != (val2)); break; \ - case HPy_LT: result = ((val1) < (val2)); break; \ - case HPy_GT: result = ((val1) > (val2)); break; \ - case HPy_LE: result = ((val1) <= (val2)); break; \ - case HPy_GE: result = ((val1) >= (val2)); break; \ - default: \ - HPy_FatalError(ctx, "Invalid value for HPy_RichCmpOp"); \ - } \ - if (result) \ - return HPy_Dup(ctx, ctx->h_True); \ - return HPy_Dup(ctx, ctx->h_False); \ - } while (0) - - -#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT - #define _HPy_PARSE_PID "i" - #define HPyLong_FromPid HPyLong_FromLong - #define HPyLong_AsPid HPyLong_AsLong -#elif SIZEOF_PID_T == SIZEOF_LONG - #define _HPy_PARSE_PID "l" - #define HPyLong_FromPid HPyLong_FromLong - #define HPyLong_AsPid HPyLong_AsLong -#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG - #define _HPy_PARSE_PID "L" - #define HPyLong_FromPid HPyLong_FromLongLong - #define HPyLong_AsPid HPyLong_AsLongLong -#else -#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" -#endif /* SIZEOF_PID_T */ - -#define HPy_BEGIN_LEAVE_PYTHON(context) { \ - HPyThreadState _token; \ - _token = HPy_LeavePythonExecution(context); - -#define HPy_END_LEAVE_PYTHON(context) \ - HPy_ReenterPythonExecution(context, _token); \ - } diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/argparse.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/argparse.h deleted file mode 100644 index 927d87db96..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/argparse.h +++ /dev/null @@ -1,50 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_ARGPARSE_H -#define HPY_COMMON_RUNTIME_ARGPARSE_H -#ifdef __cplusplus -extern "C" { -#endif - -#include "hpy.h" - -HPyAPI_HELPER int -HPyArg_Parse(HPyContext *ctx, HPyTracker *ht, const HPy *args, - size_t nargs, const char *fmt, ...); - -HPyAPI_HELPER int -HPyArg_ParseKeywords(HPyContext *ctx, HPyTracker *ht, const HPy *args, - size_t nargs, HPy kwnames, const char *fmt, - const char *keywords[], ...); - -HPyAPI_HELPER int -HPyArg_ParseKeywordsDict(HPyContext *ctx, HPyTracker *ht, const HPy *args, - HPy_ssize_t nargs, HPy kw, const char *fmt, - const char *keywords[], ...); - -#ifdef __cplusplus -} -#endif -#endif /* HPY_COMMON_RUNTIME_ARGPARSE_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/buildvalue.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/buildvalue.h deleted file mode 100644 index 78fda36b64..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/buildvalue.h +++ /dev/null @@ -1,33 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_BUILDVALUE_H -#define HPY_COMMON_RUNTIME_BUILDVALUE_H - -#include "hpy.h" - -HPyAPI_HELPER HPy -HPy_BuildValue(HPyContext *ctx, const char *fmt, ...); - -#endif /* HPY_COMMON_RUNTIME_BUILDVALUE_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_funcs.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_funcs.h deleted file mode 100644 index 6653c2c4a9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_funcs.h +++ /dev/null @@ -1,146 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_RUNTIME_CTX_FUNCS_H -#define HPY_RUNTIME_CTX_FUNCS_H - -// This file contains the prototypes for all the functions defined in -// hpy/devel/src/runtime/ctx_*.c - -#include "hpy.h" - -// ctx_bytes.c -_HPy_HIDDEN HPy ctx_Bytes_FromStringAndSize(HPyContext *ctx, const char *v, - HPy_ssize_t len); - -// ctx_call.c -_HPy_HIDDEN HPy ctx_CallTupleDict(HPyContext *ctx, HPy callable, HPy args, HPy kw); -_HPy_HIDDEN HPy ctx_Call(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames); -_HPy_HIDDEN HPy ctx_CallMethod(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames); - -// ctx_err.c -_HPy_HIDDEN int ctx_Err_Occurred(HPyContext *ctx); - -// ctx_listbuilder.c -_HPy_HIDDEN HPyListBuilder ctx_ListBuilder_New(HPyContext *ctx, - HPy_ssize_t size); -_HPy_HIDDEN void ctx_ListBuilder_Set(HPyContext *ctx, HPyListBuilder builder, - HPy_ssize_t index, HPy h_item); -_HPy_HIDDEN HPy ctx_ListBuilder_Build(HPyContext *ctx, HPyListBuilder builder); -_HPy_HIDDEN void ctx_ListBuilder_Cancel(HPyContext *ctx, HPyListBuilder builder); - -// ctx_module.c -_HPy_HIDDEN HPy ctx_Module_Create(HPyContext *ctx, HPyModuleDef *hpydef); - -// ctx_object.c -_HPy_HIDDEN void ctx_Dump(HPyContext *ctx, HPy h); -_HPy_HIDDEN int ctx_TypeCheck(HPyContext *ctx, HPy h_obj, HPy h_type); -_HPy_HIDDEN int ctx_Is(HPyContext *ctx, HPy h_obj, HPy h_other); -_HPy_HIDDEN HPy ctx_GetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -_HPy_HIDDEN HPy ctx_GetItem_s(HPyContext *ctx, HPy obj, const char *key); -_HPy_HIDDEN int ctx_SetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value); -_HPy_HIDDEN int ctx_SetItem_s(HPyContext *ctx, HPy obj, const char *key, HPy value); -_HPy_HIDDEN int ctx_DelItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -_HPy_HIDDEN int ctx_DelItem_s(HPyContext *ctx, HPy obj, const char *key); - -// ctx_tracker.c -_HPy_HIDDEN HPyTracker ctx_Tracker_New(HPyContext *ctx, HPy_ssize_t size); -_HPy_HIDDEN int ctx_Tracker_Add(HPyContext *ctx, HPyTracker ht, HPy h); -_HPy_HIDDEN void ctx_Tracker_ForgetAll(HPyContext *ctx, HPyTracker ht); -_HPy_HIDDEN void ctx_Tracker_Close(HPyContext *ctx, HPyTracker ht); - -// ctx_tuplebuilder.c -_HPy_HIDDEN HPyTupleBuilder ctx_TupleBuilder_New(HPyContext *ctx, - HPy_ssize_t size); -_HPy_HIDDEN void ctx_TupleBuilder_Set(HPyContext *ctx, HPyTupleBuilder builder, - HPy_ssize_t index, HPy h_item); -_HPy_HIDDEN HPy ctx_TupleBuilder_Build(HPyContext *ctx, HPyTupleBuilder builder); -_HPy_HIDDEN void ctx_TupleBuilder_Cancel(HPyContext *ctx, - HPyTupleBuilder builder); - -// ctx_tuple.c -_HPy_HIDDEN HPy ctx_Tuple_FromArray(HPyContext *ctx, HPy items[], HPy_ssize_t n); - -// ctx_capsule.c -_HPy_HIDDEN HPy ctx_Capsule_New(HPyContext *ctx, - void *pointer, - const char *name, - HPyCapsule_Destructor *destructor); -_HPy_HIDDEN int ctx_Capsule_SetDestructor(HPyContext *ctx, - HPy h_capsule, - HPyCapsule_Destructor *destructor); - -#ifndef HPY_ABI_CPYTHON -_HPy_HIDDEN void* ctx_Capsule_Get(HPyContext *ctx, - HPy capsule, - _HPyCapsule_key key, - const char *name); -_HPy_HIDDEN int ctx_Capsule_Set(HPyContext *ctx, - HPy capsule, - _HPyCapsule_key key, - void *value); -#endif - -// ctx_type.c -_HPy_HIDDEN void* ctx_AsStruct_Object(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Legacy(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Type(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Long(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Float(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Unicode(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Tuple(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_List(HPyContext *ctx, HPy h); -_HPy_HIDDEN void* ctx_AsStruct_Slow(HPyContext *ctx, HPy h); -_HPy_HIDDEN HPy ctx_Type_FromSpec(HPyContext *ctx, HPyType_Spec *hpyspec, - HPyType_SpecParam *params); -_HPy_HIDDEN HPy ctx_New(HPyContext *ctx, HPy h_type, void **data); -_HPy_HIDDEN HPy ctx_Type_GenericNew(HPyContext *ctx, HPy h_type, - const HPy *args, HPy_ssize_t nargs, HPy kw); -_HPy_HIDDEN HPyType_BuiltinShape ctx_Type_GetBuiltinShape(HPyContext *ctx, - HPy h_type); -_HPy_HIDDEN const char *ctx_Type_GetName(HPyContext *ctx, HPy type); -_HPy_HIDDEN int ctx_SetCallFunction(HPyContext *ctx, HPy h, - HPyCallFunction *func); - - -// ctx_long.c -_HPy_HIDDEN HPy ctx_Long_FromInt32_t(HPyContext *ctx, int32_t value); -_HPy_HIDDEN HPy ctx_Long_FromUInt32_t(HPyContext *ctx, uint32_t value); -_HPy_HIDDEN HPy ctx_Long_FromInt64_t(HPyContext *ctx, int64_t v); -_HPy_HIDDEN HPy ctx_Long_FromUInt64_t(HPyContext *ctx, uint64_t v); -_HPy_HIDDEN int32_t ctx_Long_AsInt32_t(HPyContext *ctx, HPy h); -_HPy_HIDDEN uint32_t ctx_Long_AsUInt32_t(HPyContext *ctx, HPy h); -_HPy_HIDDEN uint32_t ctx_Long_AsUInt32_tMask(HPyContext *ctx, HPy h); -_HPy_HIDDEN int64_t ctx_Long_AsInt64_t(HPyContext *ctx, HPy h); -_HPy_HIDDEN uint64_t ctx_Long_AsUInt64_t(HPyContext *ctx, HPy h); -_HPy_HIDDEN uint64_t ctx_Long_AsUInt64_tMask(HPyContext *ctx, HPy h); - -// ctx_eval.c -_HPy_HIDDEN HPy ctx_Compile_s(HPyContext *ctx, const char *utf8_source, - const char *utf8_filename, HPy_SourceKind kind); - -// ctx_contextvar.c -_HPy_HIDDEN int32_t ctx_ContextVar_Get(HPyContext *ctx, HPy context_var, - HPy default_value, HPy *result); -#endif /* HPY_RUNTIME_CTX_FUNCS_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_module.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_module.h deleted file mode 100644 index 079e772b0f..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_module.h +++ /dev/null @@ -1,49 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_CTX_MODULE_H -#define HPY_COMMON_RUNTIME_CTX_MODULE_H - -#include -#include "hpy.h" - -// Helper functions for CPython implementation (both CPython ABI and -// HPy universal module impl for CPython) - -/** Converts HPy module definition to CPython module definition for multiphase - * initialization */ -_HPy_HIDDEN PyModuleDef* -_HPyModuleDef_CreatePyModuleDef(HPyModuleDef *hpydef); - -/** Converts HPy module definition to PyObject that wraps CPython module - * definition for multiphase initialization */ -_HPy_HIDDEN PyObject* -_HPyModuleDef_AsPyInit(HPyModuleDef *hpydef); - -/** Implements the extra HPy specific validation that should be applied to the - * result of the HPy_mod_create slot. */ -_HPy_HIDDEN void -_HPyModule_CheckCreateSlotResult(PyObject **result); - -#endif //HPY_COMMON_RUNTIME_CTX_MODULE_H diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_type.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_type.h deleted file mode 100644 index 90d7e08c08..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/ctx_type.h +++ /dev/null @@ -1,40 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_CTX_TYPE_H -#define HPY_COMMON_RUNTIME_CTX_TYPE_H - -#include -#include "hpy.h" -#include "hpy/hpytype.h" - -_HPy_HIDDEN PyMethodDef *create_method_defs(HPyDef *hpydefs[], - PyMethodDef *legacy_methods); - -_HPy_HIDDEN int call_traverseproc_from_trampoline(HPyFunc_traverseproc tp_traverse, - PyObject *self, - cpy_visitproc cpy_visit, - void *cpy_arg); - -#endif /* HPY_COMMON_RUNTIME_CTX_TYPE_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/format.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/format.h deleted file mode 100644 index b04b5d12b9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/format.h +++ /dev/null @@ -1,42 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/** - * String formatting helpers. These functions are not part of HPy ABI. The implementation will be linked into HPy extensions. - */ -#ifndef HPY_COMMON_RUNTIME_FORMAT_H -#define HPY_COMMON_RUNTIME_FORMAT_H - -#include "hpy.h" - -HPyAPI_HELPER HPy -HPyUnicode_FromFormat(HPyContext *ctx, const char *fmt, ...); - -HPyAPI_HELPER HPy -HPyUnicode_FromFormatV(HPyContext *ctx, const char *format, va_list vargs); - -HPyAPI_HELPER HPy -HPyErr_Format(HPyContext *ctx, HPy h_type, const char *fmt, ...); - -#endif /* HPY_COMMON_RUNTIME_FORMAT_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/helpers.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/helpers.h deleted file mode 100644 index 7cfd833a40..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/helpers.h +++ /dev/null @@ -1,39 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_HELPERS_H -#define HPY_COMMON_RUNTIME_HELPERS_H - -#include "hpy.h" -#include "hpy/hpytype.h" - -HPyAPI_HELPER int -HPyHelpers_AddType(HPyContext *ctx, HPy obj, const char *name, - HPyType_Spec *hpyspec, HPyType_SpecParam *params); - -HPyAPI_HELPER int -HPyHelpers_PackArgsAndKeywords(HPyContext *ctx, const HPy *args, size_t nargs, - HPy kwnames, HPy *out_args_tuple, HPy *out_kwd); - -#endif /* HPY_COMMON_RUNTIME_HELPERS_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/structseq.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/structseq.h deleted file mode 100644 index f8af3a79d3..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/runtime/structseq.h +++ /dev/null @@ -1,132 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_COMMON_RUNTIME_STRUCTSEQ_H -#define HPY_COMMON_RUNTIME_STRUCTSEQ_H - -#include "hpy.h" - -/* - * Struct sequences are subclasses of tuple, so we provide a simplified API to - * create them here. This maps closely to the CPython limited API for creating - * struct sequences. However, in universal mode we use the - * collections.namedtuple type to implement this, which behaves a bit - * differently w.r.t. hidden elements. Thus, the n_in_sequence field available - * in CPython's PyStructSequence_Desc is not available. Also, we use a builder - * API like for tuples and lists so that the struct sequence is guaranteed not - * to be written after it is created. - */ - -/** - * Describes a field of a struct sequence. - */ -typedef struct { - /** - * Name (UTF-8 encoded) for the field or ``NULL`` to end the list of named - * fields. Set the name to :c:var:`HPyStructSequence_UnnamedField` to leave - * it unnamed. - */ - const char *name; - - /** - * Docstring of the field (UTF-8 encoded); may be ``NULL``. - */ - const char *doc; -} HPyStructSequence_Field; - -/** - * Contains the meta information of a struct sequence type to create. - * Struct sequences are subclasses of tuple. The index in the :c:member:`fields` - * array of the descriptor determines which field of the struct sequence is - * described. - */ -typedef struct { - /** - * Name of the struct sequence type (UTF-8 encoded; must not be ``NULL``). - */ - const char *name; - - /** Docstring of the type (UTF-8 encoded); may be ``NULL``. */ - const char *doc; - - /** - * Pointer to ``NULL``-terminated array with field names of the new type - * (must not be ``NULL``). - */ - HPyStructSequence_Field *fields; -} HPyStructSequence_Desc; - -/** - * A marker that can be used as struct sequence field name to indicate that a - * field should be anonymous (i.e. cannot be accessed by a name but only by - * numeric index). - */ -extern const char * const HPyStructSequence_UnnamedField; - -/** - * Create a new struct sequence type from a descriptor. Instances of the - * resulting type can be created with :c:func:`HPyStructSequence_New`. - * - * :param ctx: - * The execution context. - * :param desc: - * The descriptor of the struct sequence type to create (must not be - * ``NULL``): - * - * :returns: - * A handle to the new struct sequence type or ``HPy_NULL`` in case of - * errors. - */ -HPyAPI_HELPER HPy -HPyStructSequence_NewType(HPyContext *ctx, HPyStructSequence_Desc *desc); - -/** - * Creates a new instance of ``type`` initializing it with the given arguments. - * - * Since struct sequences are immutable objects, they need to be initialized at - * instantiation. This function will create a fresh instance of the provided - * struct sequence type. The type must have been created with - * :c:func:`HPyStructSequence_NewType`. - * - * :param ctx: - * The execution context. - * :param type: - * A struct sequence type (must not be ``HPy_NULL``). If the passed object - * is not a type, the behavior is undefined. If the given type is not - * appropriate, a ``TypeError`` will be raised. - * :param nargs: - * The number of arguments in ``args``. If this argument is not exactly the - * number of fields of the struct sequence, a ``TypeError`` will be raised. - * :param args: - * An array of HPy handles to Python objects to be used for initializing - * the struct sequence. If ``nargs > 0`` then this argument must not be - * ``NULL``. - * - * :returns: - * A new instance of ``type`` or ``HPy_NULL`` if an error occurred. - */ -HPyAPI_HELPER HPy -HPyStructSequence_New(HPyContext *ctx, HPy type, HPy_ssize_t nargs, HPy *args); - -#endif /* HPY_COMMON_RUNTIME_STRUCTSEQ_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_ctx.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_ctx.h deleted file mode 100644 index ef205ad4bd..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_ctx.h +++ /dev/null @@ -1,335 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.ctx.autogen_ctx_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -typedef HPy* _HPyPtr; -typedef const HPy* _ConstHPyPtr; -typedef HPyField* _HPyFieldPtr; -typedef HPy _HPyConst; -typedef HPyGlobal* _HPyGlobalPtr; - -#ifdef GRAALVM_PYTHON_LLVM -#define HPy void* -#define HPyListBuilder void* -#define HPyTupleBuilder void* -#define HPyTracker void* -#define HPyField void* -#define HPyThreadState void* -#define HPyGlobal void* -#define _HPyCapsule_key int32_t -#define HPy_SourceKind int32_t -#endif - - -struct _HPyContext_s { - const char *name; // used just to make debugging and testing easier - void *_private; // used by implementations to store custom data - int abi_version; - _HPyConst h_None; - _HPyConst h_True; - _HPyConst h_False; - _HPyConst h_NotImplemented; - _HPyConst h_Ellipsis; - _HPyConst h_BaseException; - _HPyConst h_Exception; - _HPyConst h_StopAsyncIteration; - _HPyConst h_StopIteration; - _HPyConst h_GeneratorExit; - _HPyConst h_ArithmeticError; - _HPyConst h_LookupError; - _HPyConst h_AssertionError; - _HPyConst h_AttributeError; - _HPyConst h_BufferError; - _HPyConst h_EOFError; - _HPyConst h_FloatingPointError; - _HPyConst h_OSError; - _HPyConst h_ImportError; - _HPyConst h_ModuleNotFoundError; - _HPyConst h_IndexError; - _HPyConst h_KeyError; - _HPyConst h_KeyboardInterrupt; - _HPyConst h_MemoryError; - _HPyConst h_NameError; - _HPyConst h_OverflowError; - _HPyConst h_RuntimeError; - _HPyConst h_RecursionError; - _HPyConst h_NotImplementedError; - _HPyConst h_SyntaxError; - _HPyConst h_IndentationError; - _HPyConst h_TabError; - _HPyConst h_ReferenceError; - _HPyConst h_SystemError; - _HPyConst h_SystemExit; - _HPyConst h_TypeError; - _HPyConst h_UnboundLocalError; - _HPyConst h_UnicodeError; - _HPyConst h_UnicodeEncodeError; - _HPyConst h_UnicodeDecodeError; - _HPyConst h_UnicodeTranslateError; - _HPyConst h_ValueError; - _HPyConst h_ZeroDivisionError; - _HPyConst h_BlockingIOError; - _HPyConst h_BrokenPipeError; - _HPyConst h_ChildProcessError; - _HPyConst h_ConnectionError; - _HPyConst h_ConnectionAbortedError; - _HPyConst h_ConnectionRefusedError; - _HPyConst h_ConnectionResetError; - _HPyConst h_FileExistsError; - _HPyConst h_FileNotFoundError; - _HPyConst h_InterruptedError; - _HPyConst h_IsADirectoryError; - _HPyConst h_NotADirectoryError; - _HPyConst h_PermissionError; - _HPyConst h_ProcessLookupError; - _HPyConst h_TimeoutError; - _HPyConst h_Warning; - _HPyConst h_UserWarning; - _HPyConst h_DeprecationWarning; - _HPyConst h_PendingDeprecationWarning; - _HPyConst h_SyntaxWarning; - _HPyConst h_RuntimeWarning; - _HPyConst h_FutureWarning; - _HPyConst h_ImportWarning; - _HPyConst h_UnicodeWarning; - _HPyConst h_BytesWarning; - _HPyConst h_ResourceWarning; - _HPyConst h_BaseObjectType; - _HPyConst h_TypeType; - _HPyConst h_BoolType; - _HPyConst h_LongType; - _HPyConst h_FloatType; - _HPyConst h_UnicodeType; - _HPyConst h_TupleType; - _HPyConst h_ListType; - HPy (*ctx_Dup)(HPyContext *ctx, HPy h); - void (*ctx_Close)(HPyContext *ctx, HPy h); - HPy (*ctx_Long_FromInt32_t)(HPyContext *ctx, int32_t value); - HPy (*ctx_Long_FromUInt32_t)(HPyContext *ctx, uint32_t value); - HPy (*ctx_Long_FromInt64_t)(HPyContext *ctx, int64_t v); - HPy (*ctx_Long_FromUInt64_t)(HPyContext *ctx, uint64_t v); - HPy (*ctx_Long_FromSize_t)(HPyContext *ctx, size_t value); - HPy (*ctx_Long_FromSsize_t)(HPyContext *ctx, HPy_ssize_t value); - int32_t (*ctx_Long_AsInt32_t)(HPyContext *ctx, HPy h); - uint32_t (*ctx_Long_AsUInt32_t)(HPyContext *ctx, HPy h); - uint32_t (*ctx_Long_AsUInt32_tMask)(HPyContext *ctx, HPy h); - int64_t (*ctx_Long_AsInt64_t)(HPyContext *ctx, HPy h); - uint64_t (*ctx_Long_AsUInt64_t)(HPyContext *ctx, HPy h); - uint64_t (*ctx_Long_AsUInt64_tMask)(HPyContext *ctx, HPy h); - size_t (*ctx_Long_AsSize_t)(HPyContext *ctx, HPy h); - HPy_ssize_t (*ctx_Long_AsSsize_t)(HPyContext *ctx, HPy h); - void *(*ctx_Long_AsVoidPtr)(HPyContext *ctx, HPy h); - double (*ctx_Long_AsDouble)(HPyContext *ctx, HPy h); - HPy (*ctx_Float_FromDouble)(HPyContext *ctx, double v); - double (*ctx_Float_AsDouble)(HPyContext *ctx, HPy h); - HPy (*ctx_Bool_FromBool)(HPyContext *ctx, bool v); - HPy_ssize_t (*ctx_Length)(HPyContext *ctx, HPy h); - int (*ctx_Number_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_Add)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Subtract)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Multiply)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_MatrixMultiply)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_FloorDivide)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_TrueDivide)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Remainder)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Divmod)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Power)(HPyContext *ctx, HPy h1, HPy h2, HPy h3); - HPy (*ctx_Negative)(HPyContext *ctx, HPy h1); - HPy (*ctx_Positive)(HPyContext *ctx, HPy h1); - HPy (*ctx_Absolute)(HPyContext *ctx, HPy h1); - HPy (*ctx_Invert)(HPyContext *ctx, HPy h1); - HPy (*ctx_Lshift)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Rshift)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_And)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Xor)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Or)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_Index)(HPyContext *ctx, HPy h1); - HPy (*ctx_Long)(HPyContext *ctx, HPy h1); - HPy (*ctx_Float)(HPyContext *ctx, HPy h1); - HPy (*ctx_InPlaceAdd)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceSubtract)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceMultiply)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceMatrixMultiply)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceFloorDivide)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceTrueDivide)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceRemainder)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlacePower)(HPyContext *ctx, HPy h1, HPy h2, HPy h3); - HPy (*ctx_InPlaceLshift)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceRshift)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceAnd)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceXor)(HPyContext *ctx, HPy h1, HPy h2); - HPy (*ctx_InPlaceOr)(HPyContext *ctx, HPy h1, HPy h2); - int (*ctx_Callable_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_CallTupleDict)(HPyContext *ctx, HPy callable, HPy args, HPy kw); - void (*ctx_FatalError)(HPyContext *ctx, const char *message); - void (*ctx_Err_SetString)(HPyContext *ctx, HPy h_type, const char *utf8_message); - void (*ctx_Err_SetObject)(HPyContext *ctx, HPy h_type, HPy h_value); - HPy (*ctx_Err_SetFromErrnoWithFilename)(HPyContext *ctx, HPy h_type, const char *filename_fsencoded); - void (*ctx_Err_SetFromErrnoWithFilenameObjects)(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2); - int (*ctx_Err_Occurred)(HPyContext *ctx); - int (*ctx_Err_ExceptionMatches)(HPyContext *ctx, HPy exc); - void (*ctx_Err_NoMemory)(HPyContext *ctx); - void (*ctx_Err_Clear)(HPyContext *ctx); - HPy (*ctx_Err_NewException)(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict); - HPy (*ctx_Err_NewExceptionWithDoc)(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict); - int (*ctx_Err_WarnEx)(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level); - void (*ctx_Err_WriteUnraisable)(HPyContext *ctx, HPy obj); - int (*ctx_IsTrue)(HPyContext *ctx, HPy h); - HPy (*ctx_Type_FromSpec)(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params); - HPy (*ctx_Type_GenericNew)(HPyContext *ctx, HPy type, _ConstHPyPtr args, HPy_ssize_t nargs, HPy kw); - HPy (*ctx_GetAttr)(HPyContext *ctx, HPy obj, HPy name); - HPy (*ctx_GetAttr_s)(HPyContext *ctx, HPy obj, const char *utf8_name); - int (*ctx_HasAttr)(HPyContext *ctx, HPy obj, HPy name); - int (*ctx_HasAttr_s)(HPyContext *ctx, HPy obj, const char *utf8_name); - int (*ctx_SetAttr)(HPyContext *ctx, HPy obj, HPy name, HPy value); - int (*ctx_SetAttr_s)(HPyContext *ctx, HPy obj, const char *utf8_name, HPy value); - HPy (*ctx_GetItem)(HPyContext *ctx, HPy obj, HPy key); - HPy (*ctx_GetItem_i)(HPyContext *ctx, HPy obj, HPy_ssize_t idx); - HPy (*ctx_GetItem_s)(HPyContext *ctx, HPy obj, const char *utf8_key); - int (*ctx_Contains)(HPyContext *ctx, HPy container, HPy key); - int (*ctx_SetItem)(HPyContext *ctx, HPy obj, HPy key, HPy value); - int (*ctx_SetItem_i)(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value); - int (*ctx_SetItem_s)(HPyContext *ctx, HPy obj, const char *utf8_key, HPy value); - HPy (*ctx_Type)(HPyContext *ctx, HPy obj); - int (*ctx_TypeCheck)(HPyContext *ctx, HPy obj, HPy type); - int (*ctx_Is)(HPyContext *ctx, HPy obj, HPy other); - void *(*ctx_AsStruct_Object)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Legacy)(HPyContext *ctx, HPy h); - HPy (*ctx_New)(HPyContext *ctx, HPy h_type, void **data); - HPy (*ctx_Repr)(HPyContext *ctx, HPy obj); - HPy (*ctx_Str)(HPyContext *ctx, HPy obj); - HPy (*ctx_ASCII)(HPyContext *ctx, HPy obj); - HPy (*ctx_Bytes)(HPyContext *ctx, HPy obj); - HPy (*ctx_RichCompare)(HPyContext *ctx, HPy v, HPy w, int op); - int (*ctx_RichCompareBool)(HPyContext *ctx, HPy v, HPy w, int op); - HPy_hash_t (*ctx_Hash)(HPyContext *ctx, HPy obj); - int (*ctx_Bytes_Check)(HPyContext *ctx, HPy h); - HPy_ssize_t (*ctx_Bytes_Size)(HPyContext *ctx, HPy h); - HPy_ssize_t (*ctx_Bytes_GET_SIZE)(HPyContext *ctx, HPy h); - const char *(*ctx_Bytes_AsString)(HPyContext *ctx, HPy h); - const char *(*ctx_Bytes_AS_STRING)(HPyContext *ctx, HPy h); - HPy (*ctx_Bytes_FromString)(HPyContext *ctx, const char *bytes); - HPy (*ctx_Bytes_FromStringAndSize)(HPyContext *ctx, const char *bytes, HPy_ssize_t len); - HPy (*ctx_Unicode_FromString)(HPyContext *ctx, const char *utf8); - int (*ctx_Unicode_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_Unicode_AsASCIIString)(HPyContext *ctx, HPy h); - HPy (*ctx_Unicode_AsLatin1String)(HPyContext *ctx, HPy h); - HPy (*ctx_Unicode_AsUTF8String)(HPyContext *ctx, HPy h); - const char *(*ctx_Unicode_AsUTF8AndSize)(HPyContext *ctx, HPy h, HPy_ssize_t *size); - HPy (*ctx_Unicode_FromWideChar)(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size); - HPy (*ctx_Unicode_DecodeFSDefault)(HPyContext *ctx, const char *v); - HPy (*ctx_Unicode_DecodeFSDefaultAndSize)(HPyContext *ctx, const char *v, HPy_ssize_t size); - HPy (*ctx_Unicode_EncodeFSDefault)(HPyContext *ctx, HPy h); - HPy_UCS4 (*ctx_Unicode_ReadChar)(HPyContext *ctx, HPy h, HPy_ssize_t index); - HPy (*ctx_Unicode_DecodeASCII)(HPyContext *ctx, const char *ascii, HPy_ssize_t size, const char *errors); - HPy (*ctx_Unicode_DecodeLatin1)(HPyContext *ctx, const char *latin1, HPy_ssize_t size, const char *errors); - int (*ctx_List_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_List_New)(HPyContext *ctx, HPy_ssize_t len); - int (*ctx_List_Append)(HPyContext *ctx, HPy h_list, HPy h_item); - int (*ctx_Dict_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_Dict_New)(HPyContext *ctx); - int (*ctx_Tuple_Check)(HPyContext *ctx, HPy h); - HPy (*ctx_Tuple_FromArray)(HPyContext *ctx, _HPyPtr items, HPy_ssize_t n); - HPy (*ctx_Import_ImportModule)(HPyContext *ctx, const char *utf8_name); - HPy (*ctx_FromPyObject)(HPyContext *ctx, cpy_PyObject *obj); - cpy_PyObject *(*ctx_AsPyObject)(HPyContext *ctx, HPy h); - void (*ctx_CallRealFunctionFromTrampoline)(HPyContext *ctx, HPyFunc_Signature sig, HPyCFunction func, void *args); - HPyListBuilder (*ctx_ListBuilder_New)(HPyContext *ctx, HPy_ssize_t size); - void (*ctx_ListBuilder_Set)(HPyContext *ctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item); - HPy (*ctx_ListBuilder_Build)(HPyContext *ctx, HPyListBuilder builder); - void (*ctx_ListBuilder_Cancel)(HPyContext *ctx, HPyListBuilder builder); - HPyTupleBuilder (*ctx_TupleBuilder_New)(HPyContext *ctx, HPy_ssize_t size); - void (*ctx_TupleBuilder_Set)(HPyContext *ctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item); - HPy (*ctx_TupleBuilder_Build)(HPyContext *ctx, HPyTupleBuilder builder); - void (*ctx_TupleBuilder_Cancel)(HPyContext *ctx, HPyTupleBuilder builder); - HPyTracker (*ctx_Tracker_New)(HPyContext *ctx, HPy_ssize_t size); - int (*ctx_Tracker_Add)(HPyContext *ctx, HPyTracker ht, HPy h); - void (*ctx_Tracker_ForgetAll)(HPyContext *ctx, HPyTracker ht); - void (*ctx_Tracker_Close)(HPyContext *ctx, HPyTracker ht); - void (*ctx_Field_Store)(HPyContext *ctx, HPy target_object, _HPyFieldPtr target_field, HPy h); - HPy (*ctx_Field_Load)(HPyContext *ctx, HPy source_object, HPyField source_field); - void (*ctx_ReenterPythonExecution)(HPyContext *ctx, HPyThreadState state); - HPyThreadState (*ctx_LeavePythonExecution)(HPyContext *ctx); - void (*ctx_Global_Store)(HPyContext *ctx, _HPyGlobalPtr global, HPy h); - HPy (*ctx_Global_Load)(HPyContext *ctx, HPyGlobal global); - void (*ctx_Dump)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Type)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Long)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Float)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Unicode)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_Tuple)(HPyContext *ctx, HPy h); - void *(*ctx_AsStruct_List)(HPyContext *ctx, HPy h); - HPyType_BuiltinShape (*ctx_Type_GetBuiltinShape)(HPyContext *ctx, HPy h_type); - int (*ctx_DelItem)(HPyContext *ctx, HPy obj, HPy key); - int (*ctx_DelItem_i)(HPyContext *ctx, HPy obj, HPy_ssize_t idx); - int (*ctx_DelItem_s)(HPyContext *ctx, HPy obj, const char *utf8_key); - _HPyConst h_ComplexType; - _HPyConst h_BytesType; - _HPyConst h_MemoryViewType; - _HPyConst h_CapsuleType; - _HPyConst h_SliceType; - _HPyConst h_Builtins; - HPy (*ctx_Capsule_New)(HPyContext *ctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor); - void *(*ctx_Capsule_Get)(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name); - int (*ctx_Capsule_IsValid)(HPyContext *ctx, HPy capsule, const char *utf8_name); - int (*ctx_Capsule_Set)(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value); - HPy (*ctx_Compile_s)(HPyContext *ctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind); - HPy (*ctx_EvalCode)(HPyContext *ctx, HPy code, HPy globals, HPy locals); - HPy (*ctx_ContextVar_New)(HPyContext *ctx, const char *name, HPy default_value); - int32_t (*ctx_ContextVar_Get)(HPyContext *ctx, HPy context_var, HPy default_value, _HPyPtr result); - HPy (*ctx_ContextVar_Set)(HPyContext *ctx, HPy context_var, HPy value); - const char *(*ctx_Type_GetName)(HPyContext *ctx, HPy type); - int (*ctx_Type_IsSubtype)(HPyContext *ctx, HPy sub, HPy type); - HPy (*ctx_Unicode_FromEncodedObject)(HPyContext *ctx, HPy obj, const char *encoding, const char *errors); - HPy (*ctx_Unicode_Substring)(HPyContext *ctx, HPy str, HPy_ssize_t start, HPy_ssize_t end); - HPy (*ctx_Dict_Keys)(HPyContext *ctx, HPy h); - HPy (*ctx_Dict_Copy)(HPyContext *ctx, HPy h); - int (*ctx_Slice_Unpack)(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step); - int (*ctx_SetCallFunction)(HPyContext *ctx, HPy h, HPyCallFunction *func); - HPy (*ctx_Call)(HPyContext *ctx, HPy callable, _ConstHPyPtr args, size_t nargs, HPy kwnames); - HPy (*ctx_CallMethod)(HPyContext *ctx, HPy name, _ConstHPyPtr args, size_t nargs, HPy kwnames); -}; - -#ifdef GRAALVM_PYTHON_LLVM -#undef HPy -#undef HPyListBuilder -#undef HPyTupleBuilder -#undef HPyTracker -#undef HPyField -#undef HPyThreadState -#undef HPyGlobal -#undef _HPyCapsule_key -#undef HPy_SourceKind -#endif diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_hpyfunc_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_hpyfunc_trampolines.h deleted file mode 100644 index d873b50f2a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_hpyfunc_trampolines.h +++ /dev/null @@ -1,440 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.hpyfunc.autogen_hpyfunc_trampoline_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -typedef struct { - cpy_PyObject *self; - cpy_PyObject * result; -} _HPyFunc_args_NOARGS; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_NOARGS(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *self) \ - { \ - _HPyFunc_args_NOARGS a = { self }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_NOARGS, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *self; - cpy_PyObject *arg; - cpy_PyObject * result; -} _HPyFunc_args_O; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_O(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *self, cpy_PyObject *arg) \ - { \ - _HPyFunc_args_O a = { self, arg }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_O, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject * result; -} _HPyFunc_args_UNARYFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_UNARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_UNARYFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_UNARYFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject * result; -} _HPyFunc_args_BINARYFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_BINARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyFunc_args_BINARYFUNC a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_BINARYFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject *arg2; - cpy_PyObject * result; -} _HPyFunc_args_TERNARYFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_TERNARYFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_TERNARYFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_TERNARYFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - int result; -} _HPyFunc_args_INQUIRY; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_INQUIRY(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_INQUIRY a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_INQUIRY, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_ssize_t result; -} _HPyFunc_args_LENFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_LENFUNC(SYM, IMPL) \ - static HPy_ssize_t SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_LENFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_LENFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_ssize_t arg1; - cpy_PyObject * result; -} _HPyFunc_args_SSIZEARGFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZEARGFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, HPy_ssize_t arg1) \ - { \ - _HPyFunc_args_SSIZEARGFUNC a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SSIZEARGFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_ssize_t arg1; - HPy_ssize_t arg2; - cpy_PyObject * result; -} _HPyFunc_args_SSIZESSIZEARGFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZESSIZEARGFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, HPy_ssize_t arg2) \ - { \ - _HPyFunc_args_SSIZESSIZEARGFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SSIZESSIZEARGFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_ssize_t arg1; - cpy_PyObject *arg2; - int result; -} _HPyFunc_args_SSIZEOBJARGPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZEOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_SSIZEOBJARGPROC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SSIZEOBJARGPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_ssize_t arg1; - HPy_ssize_t arg2; - cpy_PyObject *arg3; - int result; -} _HPyFunc_args_SSIZESSIZEOBJARGPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SSIZESSIZEOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, HPy_ssize_t arg1, HPy_ssize_t arg2, cpy_PyObject *arg3) \ - { \ - _HPyFunc_args_SSIZESSIZEOBJARGPROC a = { arg0, arg1, arg2, arg3 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SSIZESSIZEOBJARGPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject *arg2; - int result; -} _HPyFunc_args_OBJOBJARGPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_OBJOBJARGPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_OBJOBJARGPROC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_OBJOBJARGPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - void *arg0; -} _HPyFunc_args_FREEFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_FREEFUNC(SYM, IMPL) \ - static void SYM(void *arg0) \ - { \ - _HPyFunc_args_FREEFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_FREEFUNC, (HPyCFunction)IMPL, &a); \ - return; \ - } - -typedef struct { - cpy_PyObject *arg0; - char *arg1; - cpy_PyObject * result; -} _HPyFunc_args_GETATTRFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETATTRFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, char *arg1) \ - { \ - _HPyFunc_args_GETATTRFUNC a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_GETATTRFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject * result; -} _HPyFunc_args_GETATTROFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETATTROFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyFunc_args_GETATTROFUNC a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_GETATTROFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - char *arg1; - cpy_PyObject *arg2; - int result; -} _HPyFunc_args_SETATTRFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETATTRFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, char *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_SETATTRFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SETATTRFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject *arg2; - int result; -} _HPyFunc_args_SETATTROFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETATTROFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_SETATTROFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SETATTROFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject * result; -} _HPyFunc_args_REPRFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_REPRFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_REPRFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_REPRFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - HPy_hash_t result; -} _HPyFunc_args_HASHFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_HASHFUNC(SYM, IMPL) \ - static HPy_hash_t SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_HASHFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_HASHFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject * result; -} _HPyFunc_args_GETITERFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETITERFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_GETITERFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_GETITERFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject * result; -} _HPyFunc_args_ITERNEXTFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_ITERNEXTFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_ITERNEXTFUNC a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_ITERNEXTFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject *arg2; - cpy_PyObject * result; -} _HPyFunc_args_DESCRGETFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESCRGETFUNC(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_DESCRGETFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_DESCRGETFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - cpy_PyObject *arg2; - int result; -} _HPyFunc_args_DESCRSETFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESCRSETFUNC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, cpy_PyObject *arg2) \ - { \ - _HPyFunc_args_DESCRSETFUNC a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_DESCRSETFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - void *arg1; - cpy_PyObject * result; -} _HPyFunc_args_GETTER; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETTER(SYM, IMPL) \ - static cpy_PyObject *SYM(cpy_PyObject *arg0, void *arg1) \ - { \ - _HPyFunc_args_GETTER a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_GETTER, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - void *arg2; - int result; -} _HPyFunc_args_SETTER; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_SETTER(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1, void *arg2) \ - { \ - _HPyFunc_args_SETTER a = { arg0, arg1, arg2 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_SETTER, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - int result; -} _HPyFunc_args_OBJOBJPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_OBJOBJPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *arg0, cpy_PyObject *arg1) \ - { \ - _HPyFunc_args_OBJOBJPROC a = { arg0, arg1 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_OBJOBJPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *arg0; -} _HPyFunc_args_DESTRUCTOR; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESTRUCTOR(SYM, IMPL) \ - static void SYM(cpy_PyObject *arg0) \ - { \ - _HPyFunc_args_DESTRUCTOR a = { arg0 }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_DESTRUCTOR, (HPyCFunction)IMPL, &a); \ - return; \ - } - diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_trampolines.h deleted file mode 100644 index 186fd8386b..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/autogen_trampolines.h +++ /dev/null @@ -1,1158 +0,0 @@ -/* - * Copyright (c) 2023, 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.graalpy.autogen_llvm_trampolines_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#ifdef GRAALVM_PYTHON_LLVM -#define UNWRAP(_h) ((_h)._i) -#define WRAP(_ptr) ((HPy){(_ptr)}) -#define UNWRAP_TUPLE_BUILDER(_h) ((_h)._tup) -#define WRAP_TUPLE_BUILDER(_ptr) ((HPyTupleBuilder){(_ptr)}) -#define UNWRAP_LIST_BUILDER(_h) ((_h)._lst) -#define WRAP_LIST_BUILDER(_ptr) ((HPyListBuilder){(_ptr)}) -#define UNWRAP_TRACKER(_h) ((_h)._i) -#define WRAP_TRACKER(_ptr) ((HPyTracker){(_ptr)}) -#define UNWRAP_THREADSTATE(_ts) ((_ts)._i) -#define WRAP_THREADSTATE(_ptr) ((HPyThreadState){(_ptr)}) -#define UNWRAP_FIELD(_h) ((_h)._i) -#define WRAP_FIELD(_ptr) ((HPyField){(_ptr)}) -#define UNWRAP_GLOBAL(_h) ((_h)._i) -#define WRAP_GLOBAL(_ptr) ((HPyGlobal){(_ptr)}) -#define UNWRAP_SOURCE_KIND(_h) ((int)(_h)) -#else -#define UNWRAP(_h) _h -#define WRAP(_ptr) _ptr -#define UNWRAP_TUPLE_BUILDER(_h) _h -#define WRAP_TUPLE_BUILDER(_ptr) _ptr -#define UNWRAP_LIST_BUILDER(_h) _h -#define WRAP_LIST_BUILDER(_ptr) _ptr -#define UNWRAP_TRACKER(_h) _h -#define WRAP_TRACKER(_ptr) _ptr -#define UNWRAP_THREADSTATE(_ts) _ts -#define WRAP_THREADSTATE(_data) _data -#define UNWRAP_FIELD(_h) _h -#define WRAP_FIELD(_ptr) _ptr -#define UNWRAP_GLOBAL(_h) _h -#define WRAP_GLOBAL(_ptr) _ptr -#define UNWRAP_SOURCE_KIND(_h) _h -#endif -HPyAPI_FUNC -HPy HPy_Dup(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Dup((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -void HPy_Close(HPyContext *ctx, HPy h) -{ - ctx->ctx_Close((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyLong_FromInt32_t(HPyContext *ctx, int32_t value) -{ - return WRAP(ctx->ctx_Long_FromInt32_t((ctx), (value))); -} - -HPyAPI_FUNC -HPy HPyLong_FromUInt32_t(HPyContext *ctx, uint32_t value) -{ - return WRAP(ctx->ctx_Long_FromUInt32_t((ctx), (value))); -} - -HPyAPI_FUNC -HPy HPyLong_FromInt64_t(HPyContext *ctx, int64_t v) -{ - return WRAP(ctx->ctx_Long_FromInt64_t((ctx), (v))); -} - -HPyAPI_FUNC -HPy HPyLong_FromUInt64_t(HPyContext *ctx, uint64_t v) -{ - return WRAP(ctx->ctx_Long_FromUInt64_t((ctx), (v))); -} - -HPyAPI_FUNC -HPy HPyLong_FromSize_t(HPyContext *ctx, size_t value) -{ - return WRAP(ctx->ctx_Long_FromSize_t((ctx), (value))); -} - -HPyAPI_FUNC -HPy HPyLong_FromSsize_t(HPyContext *ctx, HPy_ssize_t value) -{ - return WRAP(ctx->ctx_Long_FromSsize_t((ctx), (value))); -} - -HPyAPI_FUNC -int32_t HPyLong_AsInt32_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsInt32_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -uint32_t HPyLong_AsUInt32_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsUInt32_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -uint32_t HPyLong_AsUInt32_tMask(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsUInt32_tMask((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -int64_t HPyLong_AsInt64_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsInt64_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -uint64_t HPyLong_AsUInt64_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsUInt64_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -uint64_t HPyLong_AsUInt64_tMask(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsUInt64_tMask((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -size_t HPyLong_AsSize_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsSize_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy_ssize_t HPyLong_AsSsize_t(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsSsize_t((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *HPyLong_AsVoidPtr(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsVoidPtr((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -double HPyLong_AsDouble(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Long_AsDouble((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyFloat_FromDouble(HPyContext *ctx, double v) -{ - return WRAP(ctx->ctx_Float_FromDouble((ctx), (v))); -} - -HPyAPI_FUNC -double HPyFloat_AsDouble(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Float_AsDouble((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyBool_FromBool(HPyContext *ctx, bool v) -{ - return WRAP(ctx->ctx_Bool_FromBool((ctx), (v))); -} - -HPyAPI_FUNC -HPy_ssize_t HPy_Length(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Length((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -int HPyNumber_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Number_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPy_Add(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Add((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Subtract(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Subtract((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Multiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Multiply((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_MatrixMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_MatrixMultiply((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_FloorDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_FloorDivide((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_TrueDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_TrueDivide((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Remainder(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Remainder((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Divmod(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Divmod((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Power(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return WRAP(ctx->ctx_Power((ctx), UNWRAP(h1), UNWRAP(h2), UNWRAP(h3))); -} - -HPyAPI_FUNC -HPy HPy_Negative(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Negative((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Positive(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Positive((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Absolute(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Absolute((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Invert(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Invert((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Lshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Lshift((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Rshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Rshift((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_And(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_And((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Xor(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Xor((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Or(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_Or((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_Index(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Index((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Long(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Long((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_Float(HPyContext *ctx, HPy h1) -{ - return WRAP(ctx->ctx_Float((ctx), UNWRAP(h1))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceAdd(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceAdd((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceSubtract(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceSubtract((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceMultiply((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceMatrixMultiply(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceMatrixMultiply((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceFloorDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceFloorDivide((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceTrueDivide(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceTrueDivide((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceRemainder(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceRemainder((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlacePower(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return WRAP(ctx->ctx_InPlacePower((ctx), UNWRAP(h1), UNWRAP(h2), UNWRAP(h3))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceLshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceLshift((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceRshift(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceRshift((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceAnd(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceAnd((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceXor(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceXor((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -HPy HPy_InPlaceOr(HPyContext *ctx, HPy h1, HPy h2) -{ - return WRAP(ctx->ctx_InPlaceOr((ctx), UNWRAP(h1), UNWRAP(h2))); -} - -HPyAPI_FUNC -int HPyCallable_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Callable_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPy_CallTupleDict(HPyContext *ctx, HPy callable, HPy args, HPy kw) -{ - return WRAP(ctx->ctx_CallTupleDict((ctx), UNWRAP(callable), UNWRAP(args), UNWRAP(kw))); -} - -HPyAPI_FUNC -HPy HPy_Call(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) -{ - return WRAP(ctx->ctx_Call((ctx), UNWRAP(callable), (args), (nargs), UNWRAP(kwnames))); -} - -HPyAPI_FUNC -HPy HPy_CallMethod(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames) -{ - return WRAP(ctx->ctx_CallMethod((ctx), UNWRAP(name), (args), (nargs), UNWRAP(kwnames))); -} - -HPyAPI_FUNC -HPy HPyErr_SetString(HPyContext *ctx, HPy h_type, const char *utf8_message) -{ - ctx->ctx_Err_SetString((ctx), UNWRAP(h_type), (utf8_message)); -return HPy_NULL; -} - -HPyAPI_FUNC -HPy HPyErr_SetObject(HPyContext *ctx, HPy h_type, HPy h_value) -{ - ctx->ctx_Err_SetObject((ctx), UNWRAP(h_type), UNWRAP(h_value)); -return HPy_NULL; -} - -HPyAPI_FUNC -HPy HPyErr_SetFromErrnoWithFilename(HPyContext *ctx, HPy h_type, const char *filename_fsencoded) -{ - return WRAP(ctx->ctx_Err_SetFromErrnoWithFilename((ctx), UNWRAP(h_type), (filename_fsencoded))); -} - -HPyAPI_FUNC -HPy HPyErr_SetFromErrnoWithFilenameObjects(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2) -{ - ctx->ctx_Err_SetFromErrnoWithFilenameObjects((ctx), UNWRAP(h_type), UNWRAP(filename1), UNWRAP(filename2)); -return HPy_NULL; -} - -HPyAPI_FUNC -int HPyErr_Occurred(HPyContext *ctx) -{ - return ctx->ctx_Err_Occurred((ctx)); -} - -HPyAPI_FUNC -int HPyErr_ExceptionMatches(HPyContext *ctx, HPy exc) -{ - return ctx->ctx_Err_ExceptionMatches((ctx), UNWRAP(exc)); -} - -HPyAPI_FUNC -HPy HPyErr_NoMemory(HPyContext *ctx) -{ - ctx->ctx_Err_NoMemory((ctx)); -return HPy_NULL; -} - -HPyAPI_FUNC -void HPyErr_Clear(HPyContext *ctx) -{ - ctx->ctx_Err_Clear((ctx)); -} - -HPyAPI_FUNC -HPy HPyErr_NewException(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict) -{ - return WRAP(ctx->ctx_Err_NewException((ctx), (utf8_name), UNWRAP(base), UNWRAP(dict))); -} - -HPyAPI_FUNC -HPy HPyErr_NewExceptionWithDoc(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict) -{ - return WRAP(ctx->ctx_Err_NewExceptionWithDoc((ctx), (utf8_name), (utf8_doc), UNWRAP(base), UNWRAP(dict))); -} - -HPyAPI_FUNC -int HPyErr_WarnEx(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level) -{ - return ctx->ctx_Err_WarnEx((ctx), UNWRAP(category), (utf8_message), (stack_level)); -} - -HPyAPI_FUNC -void HPyErr_WriteUnraisable(HPyContext *ctx, HPy obj) -{ - ctx->ctx_Err_WriteUnraisable((ctx), UNWRAP(obj)); -} - -HPyAPI_FUNC -int HPy_IsTrue(HPyContext *ctx, HPy h) -{ - return ctx->ctx_IsTrue((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyType_FromSpec(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params) -{ - return WRAP(ctx->ctx_Type_FromSpec((ctx), (spec), (params))); -} - -HPyAPI_FUNC -HPy HPyType_GenericNew(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) -{ - return WRAP(ctx->ctx_Type_GenericNew((ctx), UNWRAP(type), (args), (nargs), UNWRAP(kw))); -} - -HPyAPI_FUNC -HPy HPy_GetAttr(HPyContext *ctx, HPy obj, HPy name) -{ - return WRAP(ctx->ctx_GetAttr((ctx), UNWRAP(obj), UNWRAP(name))); -} - -HPyAPI_FUNC -HPy HPy_GetAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return WRAP(ctx->ctx_GetAttr_s((ctx), UNWRAP(obj), (utf8_name))); -} - -HPyAPI_FUNC -int HPy_HasAttr(HPyContext *ctx, HPy obj, HPy name) -{ - return ctx->ctx_HasAttr((ctx), UNWRAP(obj), UNWRAP(name)); -} - -HPyAPI_FUNC -int HPy_HasAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return ctx->ctx_HasAttr_s((ctx), UNWRAP(obj), (utf8_name)); -} - -HPyAPI_FUNC -int HPy_SetAttr(HPyContext *ctx, HPy obj, HPy name, HPy value) -{ - return ctx->ctx_SetAttr((ctx), UNWRAP(obj), UNWRAP(name), UNWRAP(value)); -} - -HPyAPI_FUNC -int HPy_SetAttr_s(HPyContext *ctx, HPy obj, const char *utf8_name, HPy value) -{ - return ctx->ctx_SetAttr_s((ctx), UNWRAP(obj), (utf8_name), UNWRAP(value)); -} - -HPyAPI_FUNC -HPy HPy_GetItem(HPyContext *ctx, HPy obj, HPy key) -{ - return WRAP(ctx->ctx_GetItem((ctx), UNWRAP(obj), UNWRAP(key))); -} - -HPyAPI_FUNC -HPy HPy_GetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx) -{ - return WRAP(ctx->ctx_GetItem_i((ctx), UNWRAP(obj), (idx))); -} - -HPyAPI_FUNC -HPy HPy_GetItem_s(HPyContext *ctx, HPy obj, const char *utf8_key) -{ - return WRAP(ctx->ctx_GetItem_s((ctx), UNWRAP(obj), (utf8_key))); -} - -HPyAPI_FUNC -int HPy_Contains(HPyContext *ctx, HPy container, HPy key) -{ - return ctx->ctx_Contains((ctx), UNWRAP(container), UNWRAP(key)); -} - -HPyAPI_FUNC -int HPy_SetItem(HPyContext *ctx, HPy obj, HPy key, HPy value) -{ - return ctx->ctx_SetItem((ctx), UNWRAP(obj), UNWRAP(key), UNWRAP(value)); -} - -HPyAPI_FUNC -int HPy_SetItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value) -{ - return ctx->ctx_SetItem_i((ctx), UNWRAP(obj), (idx), UNWRAP(value)); -} - -HPyAPI_FUNC -int HPy_SetItem_s(HPyContext *ctx, HPy obj, const char *utf8_key, HPy value) -{ - return ctx->ctx_SetItem_s((ctx), UNWRAP(obj), (utf8_key), UNWRAP(value)); -} - -HPyAPI_FUNC -int HPy_DelItem(HPyContext *ctx, HPy obj, HPy key) -{ - return ctx->ctx_DelItem((ctx), UNWRAP(obj), UNWRAP(key)); -} - -HPyAPI_FUNC -int HPy_DelItem_i(HPyContext *ctx, HPy obj, HPy_ssize_t idx) -{ - return ctx->ctx_DelItem_i((ctx), UNWRAP(obj), (idx)); -} - -HPyAPI_FUNC -int HPy_DelItem_s(HPyContext *ctx, HPy obj, const char *utf8_key) -{ - return ctx->ctx_DelItem_s((ctx), UNWRAP(obj), (utf8_key)); -} - -HPyAPI_FUNC -HPy HPy_Type(HPyContext *ctx, HPy obj) -{ - return WRAP(ctx->ctx_Type((ctx), UNWRAP(obj))); -} - -HPyAPI_FUNC -int HPy_TypeCheck(HPyContext *ctx, HPy obj, HPy type) -{ - return ctx->ctx_TypeCheck((ctx), UNWRAP(obj), UNWRAP(type)); -} - -HPyAPI_FUNC -const char *HPyType_GetName(HPyContext *ctx, HPy type) -{ - return ctx->ctx_Type_GetName((ctx), UNWRAP(type)); -} - -HPyAPI_FUNC -int HPyType_IsSubtype(HPyContext *ctx, HPy sub, HPy type) -{ - return ctx->ctx_Type_IsSubtype((ctx), UNWRAP(sub), UNWRAP(type)); -} - -HPyAPI_FUNC -int HPy_Is(HPyContext *ctx, HPy obj, HPy other) -{ - return ctx->ctx_Is((ctx), UNWRAP(obj), UNWRAP(other)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Object(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Object((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Legacy(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Legacy((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Type(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Type((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Long(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Long((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Float(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Float((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Unicode(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Unicode((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_Tuple(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_Tuple((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void *_HPy_AsStruct_List(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsStruct_List((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPyType_BuiltinShape _HPyType_GetBuiltinShape(HPyContext *ctx, HPy h_type) -{ - return ctx->ctx_Type_GetBuiltinShape((ctx), UNWRAP(h_type)); -} - -HPyAPI_FUNC -HPy HPy_Repr(HPyContext *ctx, HPy obj) -{ - return WRAP(ctx->ctx_Repr((ctx), UNWRAP(obj))); -} - -HPyAPI_FUNC -HPy HPy_Str(HPyContext *ctx, HPy obj) -{ - return WRAP(ctx->ctx_Str((ctx), UNWRAP(obj))); -} - -HPyAPI_FUNC -HPy HPy_ASCII(HPyContext *ctx, HPy obj) -{ - return WRAP(ctx->ctx_ASCII((ctx), UNWRAP(obj))); -} - -HPyAPI_FUNC -HPy HPy_Bytes(HPyContext *ctx, HPy obj) -{ - return WRAP(ctx->ctx_Bytes((ctx), UNWRAP(obj))); -} - -HPyAPI_FUNC -HPy HPy_RichCompare(HPyContext *ctx, HPy v, HPy w, int op) -{ - return WRAP(ctx->ctx_RichCompare((ctx), UNWRAP(v), UNWRAP(w), (op))); -} - -HPyAPI_FUNC -int HPy_RichCompareBool(HPyContext *ctx, HPy v, HPy w, int op) -{ - return ctx->ctx_RichCompareBool((ctx), UNWRAP(v), UNWRAP(w), (op)); -} - -HPyAPI_FUNC -HPy_hash_t HPy_Hash(HPyContext *ctx, HPy obj) -{ - return ctx->ctx_Hash((ctx), UNWRAP(obj)); -} - -HPyAPI_FUNC -int HPyBytes_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Bytes_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy_ssize_t HPyBytes_Size(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Bytes_Size((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy_ssize_t HPyBytes_GET_SIZE(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Bytes_GET_SIZE((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -const char *HPyBytes_AsString(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Bytes_AsString((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -const char *HPyBytes_AS_STRING(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Bytes_AS_STRING((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyBytes_FromString(HPyContext *ctx, const char *bytes) -{ - return WRAP(ctx->ctx_Bytes_FromString((ctx), (bytes))); -} - -HPyAPI_FUNC -HPy HPyBytes_FromStringAndSize(HPyContext *ctx, const char *bytes, HPy_ssize_t len) -{ - return WRAP(ctx->ctx_Bytes_FromStringAndSize((ctx), (bytes), (len))); -} - -HPyAPI_FUNC -HPy HPyUnicode_FromString(HPyContext *ctx, const char *utf8) -{ - return WRAP(ctx->ctx_Unicode_FromString((ctx), (utf8))); -} - -HPyAPI_FUNC -int HPyUnicode_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Unicode_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyUnicode_AsASCIIString(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Unicode_AsASCIIString((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -HPy HPyUnicode_AsLatin1String(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Unicode_AsLatin1String((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -HPy HPyUnicode_AsUTF8String(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Unicode_AsUTF8String((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -const char *HPyUnicode_AsUTF8AndSize(HPyContext *ctx, HPy h, HPy_ssize_t *size) -{ - return ctx->ctx_Unicode_AsUTF8AndSize((ctx), UNWRAP(h), (size)); -} - -HPyAPI_FUNC -HPy HPyUnicode_FromWideChar(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size) -{ - return WRAP(ctx->ctx_Unicode_FromWideChar((ctx), (w), (size))); -} - -HPyAPI_FUNC -HPy HPyUnicode_DecodeFSDefault(HPyContext *ctx, const char *v) -{ - return WRAP(ctx->ctx_Unicode_DecodeFSDefault((ctx), (v))); -} - -HPyAPI_FUNC -HPy HPyUnicode_DecodeFSDefaultAndSize(HPyContext *ctx, const char *v, HPy_ssize_t size) -{ - return WRAP(ctx->ctx_Unicode_DecodeFSDefaultAndSize((ctx), (v), (size))); -} - -HPyAPI_FUNC -HPy HPyUnicode_EncodeFSDefault(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Unicode_EncodeFSDefault((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -HPy_UCS4 HPyUnicode_ReadChar(HPyContext *ctx, HPy h, HPy_ssize_t index) -{ - return ctx->ctx_Unicode_ReadChar((ctx), UNWRAP(h), (index)); -} - -HPyAPI_FUNC -HPy HPyUnicode_DecodeASCII(HPyContext *ctx, const char *ascii, HPy_ssize_t size, const char *errors) -{ - return WRAP(ctx->ctx_Unicode_DecodeASCII((ctx), (ascii), (size), (errors))); -} - -HPyAPI_FUNC -HPy HPyUnicode_DecodeLatin1(HPyContext *ctx, const char *latin1, HPy_ssize_t size, const char *errors) -{ - return WRAP(ctx->ctx_Unicode_DecodeLatin1((ctx), (latin1), (size), (errors))); -} - -HPyAPI_FUNC -HPy HPyUnicode_FromEncodedObject(HPyContext *ctx, HPy obj, const char *encoding, const char *errors) -{ - return WRAP(ctx->ctx_Unicode_FromEncodedObject((ctx), UNWRAP(obj), (encoding), (errors))); -} - -HPyAPI_FUNC -HPy HPyUnicode_Substring(HPyContext *ctx, HPy str, HPy_ssize_t start, HPy_ssize_t end) -{ - return WRAP(ctx->ctx_Unicode_Substring((ctx), UNWRAP(str), (start), (end))); -} - -HPyAPI_FUNC -int HPyList_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_List_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyList_New(HPyContext *ctx, HPy_ssize_t len) -{ - return WRAP(ctx->ctx_List_New((ctx), (len))); -} - -HPyAPI_FUNC -int HPyList_Append(HPyContext *ctx, HPy h_list, HPy h_item) -{ - return ctx->ctx_List_Append((ctx), UNWRAP(h_list), UNWRAP(h_item)); -} - -HPyAPI_FUNC -int HPyDict_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Dict_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyDict_New(HPyContext *ctx) -{ - return WRAP(ctx->ctx_Dict_New((ctx))); -} - -HPyAPI_FUNC -HPy HPyDict_Keys(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Dict_Keys((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -HPy HPyDict_Copy(HPyContext *ctx, HPy h) -{ - return WRAP(ctx->ctx_Dict_Copy((ctx), UNWRAP(h))); -} - -HPyAPI_FUNC -int HPyTuple_Check(HPyContext *ctx, HPy h) -{ - return ctx->ctx_Tuple_Check((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyTuple_FromArray(HPyContext *ctx, HPy items[], HPy_ssize_t n) -{ - return WRAP(ctx->ctx_Tuple_FromArray((ctx), (items), (n))); -} - -HPyAPI_FUNC -int HPySlice_Unpack(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) -{ - return ctx->ctx_Slice_Unpack((ctx), UNWRAP(slice), (start), (stop), (step)); -} - -HPyAPI_FUNC -HPy HPyImport_ImportModule(HPyContext *ctx, const char *utf8_name) -{ - return WRAP(ctx->ctx_Import_ImportModule((ctx), (utf8_name))); -} - -HPyAPI_FUNC -HPy HPyCapsule_New(HPyContext *ctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor) -{ - return WRAP(ctx->ctx_Capsule_New((ctx), (pointer), (utf8_name), (destructor))); -} - -HPyAPI_FUNC -void *HPyCapsule_Get(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name) -{ - return ctx->ctx_Capsule_Get((ctx), UNWRAP(capsule), (key), (utf8_name)); -} - -HPyAPI_FUNC -int HPyCapsule_IsValid(HPyContext *ctx, HPy capsule, const char *utf8_name) -{ - return ctx->ctx_Capsule_IsValid((ctx), UNWRAP(capsule), (utf8_name)); -} - -HPyAPI_FUNC -int HPyCapsule_Set(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value) -{ - return ctx->ctx_Capsule_Set((ctx), UNWRAP(capsule), (key), (value)); -} - -HPyAPI_FUNC -HPy HPy_FromPyObject(HPyContext *ctx, cpy_PyObject *obj) -{ - return WRAP(ctx->ctx_FromPyObject((ctx), (obj))); -} - -HPyAPI_FUNC -cpy_PyObject *HPy_AsPyObject(HPyContext *ctx, HPy h) -{ - return ctx->ctx_AsPyObject((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -void _HPy_CallRealFunctionFromTrampoline(HPyContext *ctx, HPyFunc_Signature sig, HPyCFunction func, void *args) -{ - ctx->ctx_CallRealFunctionFromTrampoline((ctx), (sig), (func), (args)); -} - -HPyAPI_FUNC -HPyListBuilder HPyListBuilder_New(HPyContext *ctx, HPy_ssize_t size) -{ - return WRAP_LIST_BUILDER(ctx->ctx_ListBuilder_New((ctx), (size))); -} - -HPyAPI_FUNC -void HPyListBuilder_Set(HPyContext *ctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item) -{ - ctx->ctx_ListBuilder_Set((ctx), UNWRAP_LIST_BUILDER(builder), (index), UNWRAP(h_item)); -} - -HPyAPI_FUNC -HPy HPyListBuilder_Build(HPyContext *ctx, HPyListBuilder builder) -{ - return WRAP(ctx->ctx_ListBuilder_Build((ctx), UNWRAP_LIST_BUILDER(builder))); -} - -HPyAPI_FUNC -void HPyListBuilder_Cancel(HPyContext *ctx, HPyListBuilder builder) -{ - ctx->ctx_ListBuilder_Cancel((ctx), UNWRAP_LIST_BUILDER(builder)); -} - -HPyAPI_FUNC -HPyTupleBuilder HPyTupleBuilder_New(HPyContext *ctx, HPy_ssize_t size) -{ - return WRAP_TUPLE_BUILDER(ctx->ctx_TupleBuilder_New((ctx), (size))); -} - -HPyAPI_FUNC -void HPyTupleBuilder_Set(HPyContext *ctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item) -{ - ctx->ctx_TupleBuilder_Set((ctx), UNWRAP_TUPLE_BUILDER(builder), (index), UNWRAP(h_item)); -} - -HPyAPI_FUNC -HPy HPyTupleBuilder_Build(HPyContext *ctx, HPyTupleBuilder builder) -{ - return WRAP(ctx->ctx_TupleBuilder_Build((ctx), UNWRAP_TUPLE_BUILDER(builder))); -} - -HPyAPI_FUNC -void HPyTupleBuilder_Cancel(HPyContext *ctx, HPyTupleBuilder builder) -{ - ctx->ctx_TupleBuilder_Cancel((ctx), UNWRAP_TUPLE_BUILDER(builder)); -} - -HPyAPI_FUNC -HPyTracker HPyTracker_New(HPyContext *ctx, HPy_ssize_t size) -{ - return WRAP_TRACKER(ctx->ctx_Tracker_New((ctx), (size))); -} - -HPyAPI_FUNC -int HPyTracker_Add(HPyContext *ctx, HPyTracker ht, HPy h) -{ - return ctx->ctx_Tracker_Add((ctx), UNWRAP_TRACKER(ht), UNWRAP(h)); -} - -HPyAPI_FUNC -void HPyTracker_ForgetAll(HPyContext *ctx, HPyTracker ht) -{ - ctx->ctx_Tracker_ForgetAll((ctx), UNWRAP_TRACKER(ht)); -} - -HPyAPI_FUNC -void HPyTracker_Close(HPyContext *ctx, HPyTracker ht) -{ - ctx->ctx_Tracker_Close((ctx), UNWRAP_TRACKER(ht)); -} - -HPyAPI_FUNC -void HPyField_Store(HPyContext *ctx, HPy target_object, HPyField *target_field, HPy h) -{ - ctx->ctx_Field_Store((ctx), UNWRAP(target_object), (target_field), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyField_Load(HPyContext *ctx, HPy source_object, HPyField source_field) -{ - return WRAP(ctx->ctx_Field_Load((ctx), UNWRAP(source_object), UNWRAP_FIELD(source_field))); -} - -HPyAPI_FUNC -void HPy_ReenterPythonExecution(HPyContext *ctx, HPyThreadState state) -{ - ctx->ctx_ReenterPythonExecution((ctx), UNWRAP_THREADSTATE(state)); -} - -HPyAPI_FUNC -HPyThreadState HPy_LeavePythonExecution(HPyContext *ctx) -{ - return WRAP_THREADSTATE(ctx->ctx_LeavePythonExecution((ctx))); -} - -HPyAPI_FUNC -void HPyGlobal_Store(HPyContext *ctx, HPyGlobal *global, HPy h) -{ - ctx->ctx_Global_Store((ctx), (global), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPyGlobal_Load(HPyContext *ctx, HPyGlobal global) -{ - return WRAP(ctx->ctx_Global_Load((ctx), UNWRAP_GLOBAL(global))); -} - -HPyAPI_FUNC -void _HPy_Dump(HPyContext *ctx, HPy h) -{ - ctx->ctx_Dump((ctx), UNWRAP(h)); -} - -HPyAPI_FUNC -HPy HPy_Compile_s(HPyContext *ctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind) -{ - return WRAP(ctx->ctx_Compile_s((ctx), (utf8_source), (utf8_filename), UNWRAP_SOURCE_KIND(kind))); -} - -HPyAPI_FUNC -HPy HPy_EvalCode(HPyContext *ctx, HPy code, HPy globals, HPy locals) -{ - return WRAP(ctx->ctx_EvalCode((ctx), UNWRAP(code), UNWRAP(globals), UNWRAP(locals))); -} - -HPyAPI_FUNC -HPy HPyContextVar_New(HPyContext *ctx, const char *name, HPy default_value) -{ - return WRAP(ctx->ctx_ContextVar_New((ctx), (name), UNWRAP(default_value))); -} - -HPyAPI_FUNC -int32_t HPyContextVar_Get(HPyContext *ctx, HPy context_var, HPy default_value, HPy *result) -{ - return ctx->ctx_ContextVar_Get((ctx), UNWRAP(context_var), UNWRAP(default_value), (result)); -} - -HPyAPI_FUNC -HPy HPyContextVar_Set(HPyContext *ctx, HPy context_var, HPy value) -{ - return WRAP(ctx->ctx_ContextVar_Set((ctx), UNWRAP(context_var), UNWRAP(value))); -} - -HPyAPI_FUNC -int HPy_SetCallFunction(HPyContext *ctx, HPy h, HPyCallFunction *func) -{ - return ctx->ctx_SetCallFunction((ctx), UNWRAP(h), (func)); -} - diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/hpyfunc_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/hpyfunc_trampolines.h deleted file mode 100644 index f06419b5d8..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/hpyfunc_trampolines.h +++ /dev/null @@ -1,201 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_UNIVERSAL_HPYFUNC_TRAMPOLINES_H -#define HPY_UNIVERSAL_HPYFUNC_TRAMPOLINES_H - -/* This file should be autogenerated */ - -typedef struct { - cpy_PyObject *self; - cpy_PyObject *const *args; - HPy_ssize_t nargs; - cpy_PyObject *result; -} _HPyFunc_args_VARARGS; - -typedef struct { - cpy_PyObject *self; - cpy_PyObject *const *args; - /* We also use HPyFunc_KEYWORDS for HPy_tp_call which will be called as - vectorcall function from CPython. Therefore, 'nargsf' may also have bit - 'PY_VECTORCALL_ARGUMENTS_OFFSET' set. */ - size_t nargsf; - cpy_PyObject *kwnames; - cpy_PyObject *result; -} _HPyFunc_args_KEYWORDS; - -typedef struct { - cpy_PyObject *self; - cpy_PyObject *args; - cpy_PyObject *kw; - int result; -} _HPyFunc_args_INITPROC; - -typedef struct { - cpy_PyObject *self; - cpy_PyObject *args; - cpy_PyObject *kw; - cpy_PyObject *result; -} _HPyFunc_args_NEWFUNC; - -typedef struct { - cpy_PyObject *arg0; - cpy_PyObject *arg1; - HPy_RichCmpOp arg2; - cpy_PyObject * result; -} _HPyFunc_args_RICHCMPFUNC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_VARARGS(SYM, IMPL) \ - static cpy_PyObject * \ - SYM(cpy_PyObject *self, cpy_PyObject *const *args, HPy_ssize_t nargs) \ - { \ - _HPyFunc_args_VARARGS a = { self, args, nargs }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_VARARGS, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -#define _HPyFunc_TRAMPOLINE_HPyFunc_KEYWORDS(SYM, IMPL) \ - static cpy_PyObject * \ - SYM(cpy_PyObject *self, cpy_PyObject *const *args, size_t nargs, \ - cpy_PyObject *kwnames) \ - { \ - _HPyFunc_args_KEYWORDS a = { self, args, nargs, kwnames }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_KEYWORDS, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -#define _HPyFunc_TRAMPOLINE_HPyFunc_INITPROC(SYM, IMPL) \ - static int \ - SYM(cpy_PyObject *self, cpy_PyObject *args, cpy_PyObject *kw) \ - { \ - _HPyFunc_args_INITPROC a = { self, args, kw }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_INITPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -#define _HPyFunc_TRAMPOLINE_HPyFunc_NEWFUNC(SYM, IMPL) \ - static cpy_PyObject * \ - SYM(cpy_PyObject *self, cpy_PyObject *args, cpy_PyObject *kw) \ - { \ - _HPyFunc_args_NEWFUNC a = { self, args, kw }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_NEWFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -/* special case: the HPy_tp_destroy slot doesn't map to any CPython slot. - Instead, it is called from our own tp_dealloc: see also - hpytype_dealloc(). */ -#define _HPyFunc_TRAMPOLINE_HPyFunc_DESTROYFUNC(SYM, IMPL) \ - static void SYM(void) { abort(); } - - -/* this needs to be written manually because HPy has a different type for - "op": HPy_RichCmpOp instead of int */ -#define _HPyFunc_TRAMPOLINE_HPyFunc_RICHCMPFUNC(SYM, IMPL) \ - static cpy_PyObject * \ - SYM(cpy_PyObject *self, cpy_PyObject *obj, int op) \ - { \ - _HPyFunc_args_RICHCMPFUNC a = { self, obj, (HPy_RichCmpOp)op }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_RICHCMPFUNC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *self; - cpy_Py_buffer *view; - int flags; - int result; -} _HPyFunc_args_GETBUFFERPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_GETBUFFERPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *self, cpy_Py_buffer *view, int flags) \ - { \ - _HPyFunc_args_GETBUFFERPROC a = {self, view, flags}; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_GETBUFFERPROC, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -typedef struct { - cpy_PyObject *self; - cpy_Py_buffer *view; -} _HPyFunc_args_RELEASEBUFFERPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_RELEASEBUFFERPROC(SYM, IMPL) \ - static void SYM(cpy_PyObject *self, cpy_Py_buffer *view) \ - { \ - _HPyFunc_args_RELEASEBUFFERPROC a = {self, view}; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_RELEASEBUFFERPROC, \ - (HPyCFunction)IMPL, &a); \ - return; \ - } - - -typedef struct { - cpy_PyObject *self; - cpy_visitproc visit; - void *arg; - int result; -} _HPyFunc_args_TRAVERSEPROC; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_TRAVERSEPROC(SYM, IMPL) \ - static int SYM(cpy_PyObject *self, cpy_visitproc visit, void *arg) \ - { \ - _HPyFunc_args_TRAVERSEPROC a = { self, visit, arg }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_TRAVERSEPROC, \ - (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - -#define HPyCapsule_DESTRUCTOR_TRAMPOLINE(SYM, IMPL) \ - static void SYM(cpy_PyObject *capsule) \ - { \ - _HPy_CallRealFunctionFromTrampoline(_ctx_for_trampolines, \ - HPyFunc_CAPSULE_DESTRUCTOR, (HPyCFunction)IMPL, capsule); \ - } - -typedef struct { - cpy_PyObject *spec; - cpy_PyObject *result; -} _HPyFunc_args_MOD_CREATE; - -#define _HPyFunc_TRAMPOLINE_HPyFunc_MOD_CREATE(SYM, IMPL) \ - static cpy_PyObject* SYM(cpy_PyObject *spec, cpy_PyModuleDef *def) \ - { \ - (void) def; /* avoid 'unused' warning */ \ - _HPyFunc_args_UNARYFUNC a = { spec }; \ - _HPy_CallRealFunctionFromTrampoline( \ - _ctx_for_trampolines, HPyFunc_MOD_CREATE, (HPyCFunction)IMPL, &a); \ - return a.result; \ - } - - -#endif // HPY_UNIVERSAL_HPYFUNC_TRAMPOLINES_H diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/misc_trampolines.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/misc_trampolines.h deleted file mode 100644 index 159e3d01a1..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/universal/misc_trampolines.h +++ /dev/null @@ -1,121 +0,0 @@ -/* MIT License - * - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_MISC_TRAMPOLINES_H -#define HPY_MISC_TRAMPOLINES_H - -#ifdef GRAALVM_PYTHON_LLVM -#define UNWRAP(_h) ((_h)._i) -#define WRAP(_ptr) ((HPy){(_ptr)}) -#else -#define UNWRAP(_h) _h -#define WRAP(_ptr) _ptr -#endif - -static inline HPy _HPy_New(HPyContext *ctx, HPy h_type, void **data) { - /* Performance hack: the autogenerated version of this trampoline would - simply forward data to ctx_New. - - Suppose you call HPy_New this way: - PointObject *point; - HPy h = HPy_New(ctx, cls, &point); - - If you pass "data" to ctx->New, the C compiler must assume that anybody - could write a different value at any time into this local variable - because a pointer to it escaped. With this hack, it's no longer the - case: what escaped is the address of data_result instead and that local - variable disappears since this function is likely inlined. - - See https://github.com/pyhandle/hpy/pull/22#pullrequestreview-413365845 - */ - void *data_result; - HPy h = WRAP(ctx->ctx_New(ctx, UNWRAP(h_type), &data_result)); - *data = data_result; - return h; -} - -static inline _HPy_NO_RETURN void -HPy_FatalError(HPyContext *ctx, const char *message) { - ctx->ctx_FatalError(ctx, message); - /* note: the following abort() is unreachable, but needed because the - _HPy_NO_RETURN doesn't seem to be sufficient. I think that what - occurs is that this function is inlined, after which gcc forgets - that it couldn't return. Having abort() inlined fixes that. */ - abort(); -} - -static inline void * -HPyCapsule_GetPointer(HPyContext *ctx, HPy capsule, const char *name) -{ - return ctx->ctx_Capsule_Get( - ctx, UNWRAP(capsule), HPyCapsule_key_Pointer, name); -} - -static inline const char * -HPyCapsule_GetName(HPyContext *ctx, HPy capsule) -{ - return (const char *) ctx->ctx_Capsule_Get( - ctx, UNWRAP(capsule), HPyCapsule_key_Name, NULL); -} - -static inline void * -HPyCapsule_GetContext(HPyContext *ctx, HPy capsule) -{ - return ctx->ctx_Capsule_Get( - ctx, UNWRAP(capsule), HPyCapsule_key_Context, NULL); -} - -static inline int -HPyCapsule_SetPointer(HPyContext *ctx, HPy capsule, void *pointer) -{ - return ctx->ctx_Capsule_Set( - ctx, UNWRAP(capsule), HPyCapsule_key_Pointer, pointer); -} - -static inline int -HPyCapsule_SetName(HPyContext *ctx, HPy capsule, const char *name) -{ - return ctx->ctx_Capsule_Set( - ctx, UNWRAP(capsule), HPyCapsule_key_Name, (void *) name); -} - -static inline int -HPyCapsule_SetContext(HPyContext *ctx, HPy capsule, void *context) -{ - return ctx->ctx_Capsule_Set( - ctx, UNWRAP(capsule), HPyCapsule_key_Context, context); -} - -static inline int -HPyCapsule_SetDestructor(HPyContext *ctx, HPy capsule, - HPyCapsule_Destructor *destructor) -{ - return ctx->ctx_Capsule_Set( - ctx, UNWRAP(capsule), HPyCapsule_key_Destructor, (void *) destructor); -} - -#undef UNWRAP -#undef WRAP - -#endif /* HPY_MISC_TRAMPOLINES_H */ diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/version.h b/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/version.h deleted file mode 100644 index eb57b14570..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/include/hpy/version.h +++ /dev/null @@ -1,27 +0,0 @@ -/* MIT License - * - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -// automatically generated by setup.py:get_scm_config() -#define HPY_VERSION "0.9.0" -#define HPY_GIT_REVISION "f6114734" diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/src/autogen_c_access.h b/graalpython/com.oracle.graal.python.hpy.llvm/src/autogen_c_access.h deleted file mode 100644 index f345a3209b..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/src/autogen_c_access.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.graalpy.autogen_c_access - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#ifndef _AUTOGEN_C_ACCESS_H -#define _AUTOGEN_C_ACCESS_H -#include - -#include "Python.h" -#include "structmember.h" - -static int fill_c_type_sizes(int32_t *ctype_sizes) -{ - ctype_sizes[0] = (int32_t) sizeof(HPyContext*); - ctype_sizes[1] = (int32_t) 0; - ctype_sizes[2] = (int32_t) sizeof(void*); - ctype_sizes[3] = (int32_t) sizeof(void**); - ctype_sizes[4] = (int32_t) sizeof(bool); - ctype_sizes[5] = (int32_t) sizeof(int); - ctype_sizes[6] = (int32_t) sizeof(unsigned int); - ctype_sizes[7] = (int32_t) sizeof(long); - ctype_sizes[8] = (int32_t) sizeof(unsigned long); - ctype_sizes[9] = (int32_t) sizeof(int8_t); - ctype_sizes[10] = (int32_t) sizeof(uint8_t); - ctype_sizes[11] = (int32_t) sizeof(int16_t); - ctype_sizes[12] = (int32_t) sizeof(uint16_t); - ctype_sizes[13] = (int32_t) sizeof(int32_t); - ctype_sizes[14] = (int32_t) sizeof(uint32_t); - ctype_sizes[15] = (int32_t) sizeof(float); - ctype_sizes[16] = (int32_t) sizeof(double); - ctype_sizes[17] = (int32_t) sizeof(int64_t); - ctype_sizes[18] = (int32_t) sizeof(uint64_t); - ctype_sizes[19] = (int32_t) sizeof(HPy); - ctype_sizes[20] = (int32_t) sizeof(HPy*); - ctype_sizes[21] = (int32_t) sizeof(const HPy*); - ctype_sizes[22] = (int32_t) sizeof(wchar_t*); - ctype_sizes[23] = (int32_t) sizeof(const wchar_t*); - ctype_sizes[24] = (int32_t) sizeof(char*); - ctype_sizes[25] = (int32_t) sizeof(const char*); - ctype_sizes[26] = (int32_t) sizeof(void*); - ctype_sizes[27] = (int32_t) sizeof(void**); - ctype_sizes[28] = (int32_t) sizeof(HPyTracker); - ctype_sizes[29] = (int32_t) sizeof(size_t); - ctype_sizes[30] = (int32_t) sizeof(HPy_ssize_t); - ctype_sizes[31] = (int32_t) sizeof(HPy_ssize_t*); - ctype_sizes[32] = (int32_t) sizeof(HPy_hash_t); - ctype_sizes[33] = (int32_t) sizeof(HPy_UCS4); - ctype_sizes[34] = (int32_t) sizeof(HPyTupleBuilder); - ctype_sizes[35] = (int32_t) sizeof(HPyListBuilder); - ctype_sizes[36] = (int32_t) sizeof(cpy_PyObject*); - ctype_sizes[37] = (int32_t) sizeof(cpy_PyMethodDef*); - ctype_sizes[38] = (int32_t) sizeof(HPyModuleDef*); - ctype_sizes[39] = (int32_t) sizeof(HPyType_Spec*); - ctype_sizes[40] = (int32_t) sizeof(HPyType_SpecParam); - ctype_sizes[41] = (int32_t) sizeof(HPyType_SpecParam*); - ctype_sizes[42] = (int32_t) sizeof(HPyDef*); - ctype_sizes[43] = (int32_t) sizeof(HPyThreadState); - ctype_sizes[44] = (int32_t) sizeof(HPyField); - ctype_sizes[45] = (int32_t) sizeof(HPyField*); - ctype_sizes[46] = (int32_t) sizeof(HPyGlobal); - ctype_sizes[47] = (int32_t) sizeof(HPyGlobal*); - ctype_sizes[48] = (int32_t) sizeof(HPyCapsule_Destructor*); - ctype_sizes[49] = (int32_t) sizeof(_HPyCapsule_key); - ctype_sizes[50] = (int32_t) sizeof(HPyType_BuiltinShape); - ctype_sizes[51] = (int32_t) sizeof(HPy_SourceKind); - ctype_sizes[52] = (int32_t) sizeof(HPyCallFunction*); - ctype_sizes[53] = (int32_t) sizeof(PyType_Slot); - ctype_sizes[54] = (int32_t) sizeof(PyType_Slot*); - ctype_sizes[55] = (int32_t) sizeof(HPyFunc_Signature); - ctype_sizes[56] = (int32_t) sizeof(HPyMember_FieldType); - ctype_sizes[57] = (int32_t) sizeof(HPySlot_Slot); - ctype_sizes[58] = (int32_t) sizeof(PyMemberDef); - ctype_sizes[59] = (int32_t) sizeof(HPy_buffer); - ctype_sizes[60] = (int32_t) sizeof(PyGetSetDef); - return 0; -}; - -static int fill_c_field_offsets(int32_t *cfield_offsets) -{ - cfield_offsets[0] = (int32_t) offsetof(HPyType_SpecParam, kind); - cfield_offsets[1] = (int32_t) offsetof(HPyType_SpecParam, object); - cfield_offsets[2] = (int32_t) offsetof(HPyType_Spec, name); - cfield_offsets[3] = (int32_t) offsetof(HPyType_Spec, basicsize); - cfield_offsets[4] = (int32_t) offsetof(HPyType_Spec, itemsize); - cfield_offsets[5] = (int32_t) offsetof(HPyType_Spec, flags); - cfield_offsets[6] = (int32_t) offsetof(HPyType_Spec, builtin_shape); - cfield_offsets[7] = (int32_t) offsetof(HPyType_Spec, legacy_slots); - cfield_offsets[8] = (int32_t) offsetof(HPyType_Spec, defines); - cfield_offsets[9] = (int32_t) offsetof(HPyType_Spec, doc); - cfield_offsets[10] = (int32_t) offsetof(HPyDef, kind); - cfield_offsets[11] = (int32_t) offsetof(HPyDef, meth.name); - cfield_offsets[12] = (int32_t) offsetof(HPyDef, meth.impl); - cfield_offsets[13] = (int32_t) offsetof(HPyDef, meth.signature); - cfield_offsets[14] = (int32_t) offsetof(HPyDef, meth.doc); - cfield_offsets[15] = (int32_t) offsetof(HPyDef, member.name); - cfield_offsets[16] = (int32_t) offsetof(HPyDef, member.type); - cfield_offsets[17] = (int32_t) offsetof(HPyDef, member.offset); - cfield_offsets[18] = (int32_t) offsetof(HPyDef, member.readonly); - cfield_offsets[19] = (int32_t) offsetof(HPyDef, member.doc); - cfield_offsets[20] = (int32_t) offsetof(HPyDef, getset.name); - cfield_offsets[21] = (int32_t) offsetof(HPyDef, getset.getter_impl); - cfield_offsets[22] = (int32_t) offsetof(HPyDef, getset.setter_impl); - cfield_offsets[23] = (int32_t) offsetof(HPyDef, getset.doc); - cfield_offsets[24] = (int32_t) offsetof(HPyDef, getset.closure); - cfield_offsets[25] = (int32_t) offsetof(HPyDef, slot.slot); - cfield_offsets[26] = (int32_t) offsetof(HPyDef, slot.impl); - cfield_offsets[27] = (int32_t) offsetof(PyType_Slot, slot); - cfield_offsets[28] = (int32_t) offsetof(PyType_Slot, pfunc); - cfield_offsets[29] = (int32_t) offsetof(HPyCapsule_Destructor, cpy_trampoline); - cfield_offsets[30] = (int32_t) offsetof(HPyCapsule_Destructor, impl); - cfield_offsets[31] = (int32_t) offsetof(HPyCallFunction, impl); - cfield_offsets[32] = (int32_t) offsetof(HPyModuleDef, doc); - cfield_offsets[33] = (int32_t) offsetof(HPyModuleDef, size); - cfield_offsets[34] = (int32_t) offsetof(HPyModuleDef, legacy_methods); - cfield_offsets[35] = (int32_t) offsetof(HPyModuleDef, defines); - cfield_offsets[36] = (int32_t) offsetof(HPyModuleDef, globals); - cfield_offsets[37] = (int32_t) offsetof(PyGetSetDef, name); - cfield_offsets[38] = (int32_t) offsetof(PyGetSetDef, get); - cfield_offsets[39] = (int32_t) offsetof(PyGetSetDef, set); - cfield_offsets[40] = (int32_t) offsetof(PyGetSetDef, doc); - cfield_offsets[41] = (int32_t) offsetof(PyGetSetDef, closure); - cfield_offsets[42] = (int32_t) offsetof(PyMemberDef, name); - cfield_offsets[43] = (int32_t) offsetof(PyMemberDef, type); - cfield_offsets[44] = (int32_t) offsetof(PyMemberDef, offset); - cfield_offsets[45] = (int32_t) offsetof(PyMemberDef, flags); - cfield_offsets[46] = (int32_t) offsetof(PyMemberDef, doc); - cfield_offsets[47] = (int32_t) offsetof(HPy_buffer, buf); - cfield_offsets[48] = (int32_t) offsetof(HPy_buffer, obj); - cfield_offsets[49] = (int32_t) offsetof(HPy_buffer, len); - cfield_offsets[50] = (int32_t) offsetof(HPy_buffer, itemsize); - cfield_offsets[51] = (int32_t) offsetof(HPy_buffer, readonly); - cfield_offsets[52] = (int32_t) offsetof(HPy_buffer, ndim); - cfield_offsets[53] = (int32_t) offsetof(HPy_buffer, format); - cfield_offsets[54] = (int32_t) offsetof(HPy_buffer, shape); - cfield_offsets[55] = (int32_t) offsetof(HPy_buffer, strides); - cfield_offsets[56] = (int32_t) offsetof(HPy_buffer, suboffsets); - cfield_offsets[57] = (int32_t) offsetof(HPy_buffer, internal); - return 0; -}; - -#endif - diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/src/hpy.c b/graalpython/com.oracle.graal.python.hpy.llvm/src/hpy.c deleted file mode 100644 index 6e2e4e92e0..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/src/hpy.c +++ /dev/null @@ -1,1357 +0,0 @@ -/* - * Copyright (c) 2019, 2023, 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. - */ -#include "hpy.h" -#include "structmember.h" -#include -#include - -#include -#include -#include - -#include "autogen_c_access.h" - - -#define SRC_CS "utf-8" -#define UNWRAP(_h) ((_h)._i) -#define WRAP(_ptr) ((HPy){(_ptr)}) - -/* References to the managed HPy contexts (Java objects). */ -static HPyContext *g_universal_ctx; - -typedef HPyDef* HPyDefPtr; -typedef PyMemberDef cpy_PyMemberDef; -typedef PyGetSetDef cpy_PyGetSetDef; -typedef PyType_Slot cpy_PyTypeSlot; -typedef void* VoidPtr; - -POLYGLOT_DECLARE_TYPE(VoidPtr); -POLYGLOT_DECLARE_TYPE(HPy) -POLYGLOT_DECLARE_TYPE(HPyContext) -POLYGLOT_DECLARE_TYPE(int8_t) - -int Py_EXPORTED_SYMBOL graal_hpy_init(HPyContext *context, void *initObject, int32_t *c_type_sizes, int32_t *c_field_offsets) { - // save context in global for NFI upcalls - g_universal_ctx = context; - - // register the native type of HPy - polyglot_invoke(initObject, "setHPyContextNativeType", polyglot_HPyContext_typeid()); - polyglot_invoke(initObject, "setHPyNativeType", polyglot_HPy_typeid()); - polyglot_invoke(initObject, "setHPyArrayNativeType", polyglot_array_typeid(polyglot_HPy_typeid(), 0)); - - if (fill_c_type_sizes(c_type_sizes)) { - return 1; - } - if (fill_c_field_offsets(c_field_offsets)) { - return 1; - } - - return 0; -} - -void *graal_hpy_get_element_ptr(void *base, int64_t offset) { - return base + offset; -} - -void* graal_hpy_calloc(size_t count, size_t eltsize) { - return calloc(count, eltsize); -} - -void graal_hpy_free(void *ptr) { - free(ptr); -} - -void* graal_hpy_get_field_i(HPyField *hf) { - return hf->_i; -} - -void graal_hpy_set_field_i(HPyField *hf, void* i) { - hf->_i = i; -} - -void* graal_hpy_get_global_i(HPyGlobal *hg) { - return hg->_i; -} - -void graal_hpy_set_global_i(HPyGlobal *hg, void* i) { - hg->_i = i; -} - -void* graal_hpy_from_string(const char *ptr) { - return polyglot_from_string(ptr, SRC_CS); -} - -int graal_hpy_get_errno() { - return errno; -} - -char *graal_hpy_get_strerror(int i) { - if (i != 0) { - return strerror(i); - } - return "Error"; -} - -uint64_t graal_hpy_strlen(const char *ptr) { - return strlen(ptr); -} - -void* graal_hpy_from_HPy_array(void *arr, uint64_t len) { - /* - * We attach type 'VoidPtr arr[len]' instead of 'HPy arr[len]' because that - * saves the additional read of member '_i' if we would use - */ - return polyglot_from_VoidPtr_array(arr, len); -} - -void* graal_hpy_from_i8_array(void *arr, uint64_t len) { - return polyglot_from_i8_array(arr, len); -} - -/* - * Casts a 'wchar_t*' array to an 'int8_t*' array and also associates the proper length. - * The length is determined using 'wcslen' if 'len == -1'. - */ -int8_t* graal_hpy_i8_from_wchar_array(wchar_t *arr, uint64_t len) { - if (len == -1) { - len = (uint64_t) (wcslen(arr) * sizeof(wchar_t)); - } - return polyglot_from_i8_array((int8_t *) arr, len); -} - -/* - * Transforms a Java handle array to native. - * TODO(fa): This currently uses a workaround because Sulong does not fully - * support passing structs via interop. Therefore, we pretend to have 'void *' - * array and convert to handle using 'HPy_FromVoidP'. - */ -void* graal_hpy_array_to_native(VoidPtr *source, uint64_t len) { - uint64_t i; - HPy *dest = (HPy *)malloc(len*sizeof(HPy)); - for (i=0; i < len; i++) { - dest[i] = HPy_FromVoidP(source[i]); - } - return polyglot_from_HPy_array(dest, len); -} - -HPy_buffer* graal_hpy_buffer_to_native(void* buf, HPy obj, HPy_ssize_t len, HPy_ssize_t item_size, int readonly, int ndim, - int64_t format_ptr, int64_t shape_ptr, int64_t strides_ptr, int64_t suboffsets_ptr, void *internal) { - HPy_buffer *hpy_buffer = (HPy_buffer *) malloc(sizeof(HPy_buffer)); - hpy_buffer->buf = buf; - hpy_buffer->obj = obj; - hpy_buffer->len = len; - hpy_buffer->itemsize = item_size; - hpy_buffer->readonly = readonly; - hpy_buffer->ndim = ndim; - hpy_buffer->format = (char *)format_ptr; - hpy_buffer->shape = (HPy_ssize_t *)shape_ptr; - hpy_buffer->strides = (HPy_ssize_t *)strides_ptr; - hpy_buffer->suboffsets = (HPy_ssize_t *)suboffsets_ptr; - hpy_buffer->internal = internal; - return hpy_buffer; -} - -#define PRIMITIVE_ARRAY_TO_NATIVE(__jtype__, __ctype__, __polyglot_type__, __element_cast__) \ - void* graal_hpy_##__jtype__##_array_to_native(const void* jarray, int64_t len) { \ - int64_t i; \ - int64_t size = len + 1; \ - __ctype__* carr = (__ctype__*) malloc(size * sizeof(__ctype__)); \ - carr[len] = (__ctype__)0; \ - for (i=0; i < len; i++) { \ - carr[i] = __element_cast__(polyglot_get_array_element(jarray, i)); \ - } \ - return polyglot_from_##__polyglot_type__##_array(carr, len); \ - } \ - -PRIMITIVE_ARRAY_TO_NATIVE(byte, int8_t, i8, polyglot_as_i8); -PRIMITIVE_ARRAY_TO_NATIVE(int, int32_t, i32, polyglot_as_i32); -PRIMITIVE_ARRAY_TO_NATIVE(long, int64_t, i64, polyglot_as_i64); -PRIMITIVE_ARRAY_TO_NATIVE(double, double, double, polyglot_as_double); -PRIMITIVE_ARRAY_TO_NATIVE(pointer, VoidPtr, VoidPtr, (VoidPtr)); - -/*****************************************************************************/ -/* getter for reading native members */ -/*****************************************************************************/ - -#define ReadMember(object, offset, T) ((T*)(((char*)object) + offset))[0] - -bool graal_hpy_read_bool(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, bool); -} - -uint8_t graal_hpy_read_ui8(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, uint8_t); -} - -int8_t graal_hpy_read_i8(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, int8_t); -} - -int16_t graal_hpy_read_i16(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, int16_t); -} - -uint16_t graal_hpy_read_ui16(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, uint16_t); -} - -int32_t graal_hpy_read_i32(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, int32_t); -} - -uint32_t graal_hpy_read_ui32(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, uint32_t); -} - -int64_t graal_hpy_read_i64(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, int64_t); -} - -uint64_t graal_hpy_read_ui64(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, uint64_t); -} - -int graal_hpy_read_i(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, int); -} - -unsigned int graal_hpy_read_ui(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, unsigned int); -} - -long graal_hpy_read_l(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, long); -} - -unsigned long graal_hpy_read_ul(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, unsigned long); -} - -double graal_hpy_read_f(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, float); -} - -double graal_hpy_read_d(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, double); -} - -void* graal_hpy_read_ptr(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, void*); -} - -void* graal_hpy_read_HPy(void* object, HPy_ssize_t offset) { - return UNWRAP_FIELD(ReadMember(object, offset, HPy)); -} - -void* graal_hpy_read_HPyField(void* object, HPy_ssize_t offset) { - return UNWRAP_FIELD(ReadMember(object, offset, HPyField)); -} - -HPy_ssize_t graal_hpy_read_HPy_ssize_t(void* object, HPy_ssize_t offset) { - return ReadMember(object, offset, HPy_ssize_t); -} - -#undef ReadMember - -/*****************************************************************************/ -/* setter for writing native members */ -/*****************************************************************************/ - -#define WriteMember(object, offset, value, T) *(T*)(((char*)object) + offset) = (value) - -void graal_hpy_write_bool(void* object, HPy_ssize_t offset, bool value) { - WriteMember(object, offset, value, bool); -} - -void graal_hpy_write_i8(void* object, HPy_ssize_t offset, int8_t value) { - WriteMember(object, offset, value, int8_t); -} - -void graal_hpy_write_ui8(void* object, HPy_ssize_t offset, uint8_t value) { - WriteMember(object, offset, value, uint8_t); -} - -void graal_hpy_write_i16(void* object, HPy_ssize_t offset, int16_t value) { - WriteMember(object, offset, value, int16_t); -} - -void graal_hpy_write_ui16(void* object, HPy_ssize_t offset, uint16_t value) { - WriteMember(object, offset, value, uint16_t); -} - -void graal_hpy_write_i32(void* object, HPy_ssize_t offset, int32_t value) { - WriteMember(object, offset, value, int32_t); -} - -void graal_hpy_write_ui32(void* object, HPy_ssize_t offset, uint32_t value) { - WriteMember(object, offset, value, uint32_t); -} - -void graal_hpy_write_i64(void* object, HPy_ssize_t offset, int64_t value) { - WriteMember(object, offset, value, int64_t); -} - -void graal_hpy_write_ui64(void* object, HPy_ssize_t offset, uint64_t value) { - WriteMember(object, offset, value, uint64_t); -} - -void graal_hpy_write_i(void* object, HPy_ssize_t offset, int value) { - WriteMember(object, offset, (value), int); -} - -void graal_hpy_write_l(void* object, HPy_ssize_t offset, long value) { - WriteMember(object, offset, (value), long); -} - -void graal_hpy_write_f(void* object, HPy_ssize_t offset, float value) { - WriteMember(object, offset, (value), float); -} - -void graal_hpy_write_d(void* object, HPy_ssize_t offset, double value) { - WriteMember(object, offset, (value), double); -} - -void graal_hpy_write_HPy(void* object, HPy_ssize_t offset, void* value) { - WriteMember(object, offset, WRAP(value), HPy); -} - -void graal_hpy_write_HPyField(void* object, HPy_ssize_t offset, void* value) { - WriteMember(object, offset, WRAP_FIELD(value), HPyField); -} - -void graal_hpy_write_ui(void* object, HPy_ssize_t offset, unsigned int value) { - WriteMember(object, offset, value, unsigned int); -} - -void graal_hpy_write_ul(void* object, HPy_ssize_t offset, unsigned long value) { - WriteMember(object, offset, value, unsigned long); -} - -void graal_hpy_write_HPy_ssize_t(void* object, HPy_ssize_t offset, HPy_ssize_t value) { - WriteMember(object, offset, value, HPy_ssize_t); -} - -void graal_hpy_write_ptr(void* object, HPy_ssize_t offset, void* value) { - WriteMember(object, offset, value, void*); -} - -#undef WriteMember - -typedef void (*destroyfunc)(void*); -/* to be used from Java code only */ -int graal_hpy_bulk_free(uint64_t ptrArray[], int64_t len) -{ - int64_t i; - uint64_t obj; - destroyfunc func; - - for (i = 0; i < len; i += 2) { - obj = ptrArray[i]; - func = (destroyfunc) ptrArray[i + 1]; - if (obj) { - if (func != NULL) { - func((void*) obj); - } - free((void*) obj); - } - } - return 0; -} - -/*****************************************************************************/ -/* HPy context helper functions */ -/*****************************************************************************/ - - -#define HPyAPI_STORAGE _HPy_HIDDEN -#define _HPy_IMPL_NAME(name) ctx_##name -#define _HPy_IMPL_NAME_NOPREFIX(name) ctx_##name -#define _py2h(_x) HPy_NULL -#define _h2py(_x) NULL - -typedef HPy* _HPyPtr; -typedef HPyField* _HPyFieldPtr; -typedef HPy _HPyConst; -typedef HPyGlobal* _HPyGlobalPtr; - -#define HPy void* -#define HPyListBuilder void* -#define HPyTupleBuilder void* -#define HPyTracker void* -#define HPyField void* -#define HPyThreadState void* -#define HPyGlobal void* -#define _HPyCapsule_key int32_t - -#define SELECT_CTX(__ctx__) (g_universal_ctx) - -#define UPCALL_HPY(__name__, __ctx__, ...) polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__) -#define UPCALL_HPY0(__name__, __ctx__) polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__)) -#define UPCALL_CHARPTR(__name__, __ctx__, ...) ((char*)polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__)) -#define UPCALL_VOID(__name__, __ctx__, ...) (void)polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__) -#define UPCALL_VOID0(__name__, __ctx__) ((void)polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__))) -#define UPCALL_DOUBLE(__name__, __ctx__, ...) polyglot_as_double(polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__)) -#define UPCALL_I64(__name__, __ctx__, ...) polyglot_as_i64(polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__)) -#define UPCALL_I32(__name__, __ctx__, ...) polyglot_as_i32(polyglot_invoke(SELECT_CTX(__ctx__), #__name__, (__ctx__), __VA_ARGS__)) - - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Module_Create)(HPyContext *ctx, HPyModuleDef *hpydef) -{ - return UPCALL_HPY(ctx_Module_Create, ctx, hpydef); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dup)(HPyContext *ctx, HPy h) -{ - return UPCALL_HPY(ctx_Dup, ctx, h); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Close)(HPyContext *ctx, HPy h) -{ - UPCALL_VOID(ctx_Close, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromLong)(HPyContext *ctx, long v) -{ - return UPCALL_HPY(ctx_Long_FromLong, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromUnsignedLong)(HPyContext *ctx, unsigned long v) -{ - return UPCALL_HPY(ctx_Long_FromUnsignedLong, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromLongLong)(HPyContext *ctx, long long v) -{ - return UPCALL_HPY(ctx_Long_FromLongLong, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromUnsignedLongLong)(HPyContext *ctx, unsigned long long v) -{ - return UPCALL_HPY(ctx_Long_FromUnsignedLongLong, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromSize_t)(HPyContext *ctx, size_t v) -{ - return UPCALL_HPY(ctx_Long_FromSize_t, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Long_FromSsize_t)(HPyContext *ctx, HPy_ssize_t v) -{ - return UPCALL_HPY(ctx_Long_FromSsize_t, ctx, v); -} - -HPyAPI_STORAGE long _HPy_IMPL_NAME(Long_AsLong)(HPyContext *ctx, HPy h) -{ - return (long) UPCALL_I64(ctx_Long_AsLong, ctx, h); -} - -HPyAPI_STORAGE unsigned long _HPy_IMPL_NAME(Long_AsUnsignedLong)(HPyContext *ctx, HPy h) -{ - return (unsigned long) UPCALL_I64(ctx_Long_AsUnsignedLong, ctx, h); -} - -HPyAPI_STORAGE unsigned long _HPy_IMPL_NAME(Long_AsUnsignedLongMask)(HPyContext *ctx, HPy h) -{ - return (unsigned long) UPCALL_I64(ctx_Long_AsUnsignedLongMask, ctx, h); -} - -HPyAPI_STORAGE long long _HPy_IMPL_NAME(Long_AsLongLong)(HPyContext *ctx, HPy h) -{ - return (long long) UPCALL_I64(ctx_Long_AsLongLong, ctx, h); -} - -HPyAPI_STORAGE unsigned long long _HPy_IMPL_NAME(Long_AsUnsignedLongLong)(HPyContext *ctx, HPy h) -{ - return (unsigned long long) UPCALL_I64(ctx_Long_AsUnsignedLongLong, ctx, h); -} - -HPyAPI_STORAGE unsigned long long _HPy_IMPL_NAME(Long_AsUnsignedLongLongMask)(HPyContext *ctx, HPy h) -{ - return (unsigned long long) UPCALL_I64(ctx_Long_AsUnsignedLongLongMask, ctx, h); -} - -HPyAPI_STORAGE size_t _HPy_IMPL_NAME(Long_AsSize_t)(HPyContext *ctx, HPy h) -{ - return (size_t) UPCALL_I64(ctx_Long_AsSize_t, ctx, h); -} - -HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME(Long_AsSsize_t)(HPyContext *ctx, HPy h) -{ - return (HPy_ssize_t) UPCALL_I64(ctx_Long_AsSsize_t, ctx, h); -} - -HPyAPI_STORAGE void* _HPy_IMPL_NAME(Long_AsVoidPtr)(HPyContext *ctx, HPy h) { - return (void *) UPCALL_I64(ctx_Long_AsVoidPtr, ctx, h); -} - -HPyAPI_STORAGE double _HPy_IMPL_NAME(Long_AsDouble)(HPyContext *ctx, HPy h) { - return UPCALL_DOUBLE(ctx_Long_AsDouble, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Float_FromDouble)(HPyContext *ctx, double v) -{ - return UPCALL_HPY(ctx_Float_FromDouble, ctx, v); -} - -HPyAPI_STORAGE double _HPy_IMPL_NAME(Float_AsDouble)(HPyContext *ctx, HPy h) -{ - return UPCALL_DOUBLE(ctx_Float_AsDouble, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bool_FromLong)(HPyContext *ctx, long v) -{ - return UPCALL_HPY(ctx_Bool_FromLong, ctx, v); -} - -HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME_NOPREFIX(Length)(HPyContext *ctx, HPy h) -{ - return (HPy_ssize_t) UPCALL_I64(ctx_Length, ctx, h); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Number_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Number_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Add)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Add, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Subtract)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Subtract, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Multiply)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Multiply, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(MatrixMultiply)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_MatrixMultiply, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(FloorDivide)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_FloorDivide, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(TrueDivide)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_TrueDivide, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Remainder)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Remainder, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Divmod)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Divmod, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Power)(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return UPCALL_HPY(ctx_Power, ctx, h1, h2, h3); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Negative)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Negative, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Positive)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Positive, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Absolute)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Absolute, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Invert)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Invert, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Lshift)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Lshift, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Rshift)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Rshift, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(And)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_And, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Xor)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Xor, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Or)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_Or, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Index)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Index, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Long)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Long, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Float)(HPyContext *ctx, HPy h1) -{ - return UPCALL_HPY(ctx_Float, ctx, h1); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceAdd)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceAdd, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceSubtract)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceSubtract, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceMultiply)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceMultiply, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceMatrixMultiply)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceMatrixMultiply, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceFloorDivide)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceFloorDivide, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceTrueDivide)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceTrueDivide, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceRemainder)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceRemainder, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlacePower)(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return UPCALL_HPY(ctx_InPlacePower, ctx, h1, h2, h3); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceLshift)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceLshift, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceRshift)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceRshift, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceAnd)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceAnd, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceXor)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceXor, ctx, h1, h2); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(InPlaceOr)(HPyContext *ctx, HPy h1, HPy h2) -{ - return UPCALL_HPY(ctx_InPlaceOr, ctx, h1, h2); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Callable_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Callable_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(CallTupleDict)(HPyContext *ctx, HPy callable, HPy args, HPy kw) -{ - return UPCALL_HPY(ctx_CallTupleDict, ctx, callable, args, kw); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetString)(HPyContext *ctx, HPy h_type, const char *message) -{ - UPCALL_VOID(ctx_Err_SetString, ctx, h_type, message); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetObject)(HPyContext *ctx, HPy h_type, HPy h_value) -{ - UPCALL_VOID(ctx_Err_SetObject, ctx, h_type, h_value); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Err_SetFromErrnoWithFilename)(HPyContext *ctx, HPy h_type, const char *filename_fsencoded) { - return UPCALL_HPY(ctx_Err_SetFromErrnoWithFilename, ctx, h_type, filename_fsencoded); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_SetFromErrnoWithFilenameObjects)(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2) { - UPCALL_VOID(ctx_Err_SetFromErrnoWithFilenameObjects, ctx, h_type, filename1, filename2); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Err_Occurred)(HPyContext *ctx) -{ - return (int) polyglot_as_i32(UPCALL_HPY0(ctx_Err_Occurred, ctx)); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Err_ExceptionMatches)(HPyContext *ctx, HPy exc) { - return (int) UPCALL_I32(ctx_Err_ExceptionMatches, ctx, exc); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_NoMemory)(HPyContext *ctx) -{ - UPCALL_VOID0(ctx_Err_NoMemory, ctx); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_Clear)(HPyContext *ctx) -{ - UPCALL_VOID0(ctx_Err_Clear, ctx); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Err_NewException)(HPyContext *ctx, const char *name, HPy base, HPy dict) { - return UPCALL_HPY(ctx_Err_NewException, ctx, name, base, dict); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Err_NewExceptionWithDoc)(HPyContext *ctx, const char *name, const char *doc, HPy base, HPy dict) { - return UPCALL_HPY(ctx_Err_NewExceptionWithDoc, ctx, name, doc, base, dict); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Err_WarnEx)(HPyContext *ctx, HPy category, const char *message, HPy_ssize_t stack_level) { - return (int) UPCALL_I32(ctx_Err_WarnEx, ctx, category, message, stack_level); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Err_WriteUnraisable)(HPyContext *ctx, HPy obj) { - UPCALL_VOID(ctx_Err_WriteUnraisable, ctx, obj); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(FatalError)(HPyContext *ctx, const char *msg) { - UPCALL_VOID(ctx_FatalError, ctx, msg); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(IsTrue)(HPyContext *ctx, HPy h) -{ - return UPCALL_HPY(ctx_IsTrue, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Type_FromSpec)(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params) -{ - return UPCALL_HPY(ctx_Type_FromSpec, ctx, spec, params); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Type_GenericNew)(HPyContext *ctx, HPy type, _HPyPtr args, HPy_ssize_t nargs, HPy kw) -{ - return UPCALL_HPY(ctx_Type_GenericNew, ctx, type, args, nargs, kw); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(GetAttr)(HPyContext *ctx, HPy obj, HPy name) -{ - return UPCALL_HPY(ctx_GetAttr, ctx, obj, name); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(GetAttr_s)(HPyContext *ctx, HPy obj, const char *name) -{ - return UPCALL_HPY(ctx_GetAttr_s, ctx, obj, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(HasAttr)(HPyContext *ctx, HPy obj, HPy name) -{ - return (int) UPCALL_I32(ctx_HasAttr, ctx, obj, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(HasAttr_s)(HPyContext *ctx, HPy obj, const char *name) -{ - return (int) UPCALL_I32(ctx_HasAttr_s, ctx, obj, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetAttr)(HPyContext *ctx, HPy obj, HPy name, HPy value) -{ - return (int) UPCALL_I32(ctx_SetAttr, ctx, obj, name, value); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetAttr_s)(HPyContext *ctx, HPy obj, const char *name, HPy value) -{ - return (int) UPCALL_I32(ctx_SetAttr_s, ctx, obj, name, value); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(GetItem)(HPyContext *ctx, HPy obj, HPy key) -{ - return UPCALL_HPY(ctx_GetItem, ctx, obj, key); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(GetItem_i)(HPyContext *ctx, HPy obj, HPy_ssize_t idx) -{ - return UPCALL_HPY(ctx_GetItem_i, ctx, obj, idx); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(GetItem_s)(HPyContext *ctx, HPy obj, const char *key) -{ - return UPCALL_HPY(ctx_GetItem_s, ctx, obj, key); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(Contains)(HPyContext *ctx, HPy container, HPy key) { - return (int) UPCALL_I32(ctx_Contains, ctx, container, key); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetItem)(HPyContext *ctx, HPy obj, HPy key, HPy value) -{ - return UPCALL_HPY(ctx_SetItem, ctx, obj, key, value); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetItem_i)(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value) -{ - return UPCALL_HPY(ctx_SetItem_i, ctx, obj, idx, value); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(SetItem_s)(HPyContext *ctx, HPy obj, const char *key, HPy value) -{ - return UPCALL_HPY(ctx_SetItem_s, ctx, obj, key, value); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Type)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_Type, ctx, obj); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(TypeCheck)(HPyContext *ctx, HPy obj, HPy type) -{ - return (int) UPCALL_I32(ctx_TypeCheck, ctx, obj, type); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(TypeCheck_g)(HPyContext *ctx, HPy obj, HPyGlobal type) -{ - return (int) UPCALL_I32(ctx_TypeCheck_g, ctx, obj, type); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(Is)(HPyContext *ctx, HPy obj, HPy other) -{ - return (int) UPCALL_I32(ctx_Is, ctx, obj, other); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(Is_g)(HPyContext *ctx, HPy obj, HPyGlobal other) -{ - return (int) UPCALL_I32(ctx_Is_g, ctx, obj, other); -} - -HPyAPI_STORAGE void *_HPy_IMPL_NAME_NOPREFIX(AsStruct)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_AsStruct, ctx, obj); -} - -HPyAPI_STORAGE void *_HPy_IMPL_NAME_NOPREFIX(AsStructLegacy)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_AsStructLegacy, ctx, obj); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(New)(HPyContext *ctx, HPy h_type, void **data) -{ - return UPCALL_HPY(ctx_New, ctx, h_type, data); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Repr)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_Repr, ctx, obj); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Str)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_Str, ctx, obj); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(ASCII)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_ASCII, ctx, obj); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(Bytes)(HPyContext *ctx, HPy obj) -{ - return UPCALL_HPY(ctx_Bytes, ctx, obj); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(RichCompare)(HPyContext *ctx, HPy v, HPy w, int op) -{ - return UPCALL_HPY(ctx_RichCompare, ctx, v, w, op); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME_NOPREFIX(RichCompareBool)(HPyContext *ctx, HPy v, HPy w, int op) -{ - return (int) UPCALL_I32(ctx_RichCompareBool, ctx, v, w, op); -} - -HPyAPI_STORAGE HPy_hash_t _HPy_IMPL_NAME_NOPREFIX(Hash)(HPyContext *ctx, HPy obj) -{ - return (HPy_hash_t) UPCALL_I64(ctx_Hash, ctx, obj); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Bytes_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Bytes_Check, ctx, h); -} - -HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME(Bytes_Size)(HPyContext *ctx, HPy h) -{ - return (HPy_ssize_t) UPCALL_I64(ctx_Bytes_Size, ctx, h); -} - -HPyAPI_STORAGE HPy_ssize_t _HPy_IMPL_NAME(Bytes_GET_SIZE)(HPyContext *ctx, HPy h) -{ - return (HPy_ssize_t) UPCALL_I64(ctx_Bytes_GET_SIZE, ctx, h); -} - -HPyAPI_STORAGE char *_HPy_IMPL_NAME(Bytes_AsString)(HPyContext *ctx, HPy h) -{ - return UPCALL_CHARPTR(ctx_Bytes_AsString, ctx, h); -} - -HPyAPI_STORAGE char *_HPy_IMPL_NAME(Bytes_AS_STRING)(HPyContext *ctx, HPy h) -{ - return UPCALL_CHARPTR(ctx_Bytes_AS_STRING, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bytes_FromString)(HPyContext *ctx, const char *v) -{ - return UPCALL_HPY(ctx_Bytes_FromString, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Bytes_FromStringAndSize)(HPyContext *ctx, const char *v, HPy_ssize_t len) -{ - return UPCALL_HPY(ctx_Bytes_FromStringAndSize, ctx, v, len); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_FromString)(HPyContext *ctx, const char *utf8) -{ - return UPCALL_HPY(ctx_Unicode_FromString, ctx, utf8); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Unicode_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Unicode_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_AsASCIIString)(HPyContext *ctx, HPy h) { - return UPCALL_HPY(ctx_Unicode_AsASCIIString, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_AsLatin1String)(HPyContext *ctx, HPy h) { - return UPCALL_HPY(ctx_Unicode_AsLatin1String, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_AsUTF8String)(HPyContext *ctx, HPy h) -{ - return UPCALL_HPY(ctx_Unicode_AsUTF8String, ctx, h); -} - -HPyAPI_STORAGE const char *_HPy_IMPL_NAME(Unicode_AsUTF8AndSize)(HPyContext *ctx, HPy h, HPy_ssize_t *size) { - return UPCALL_CHARPTR(ctx_Unicode_AsUTF8AndSize, ctx, h, size); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_FromWideChar)(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size) -{ - return UPCALL_HPY(ctx_Unicode_FromWideChar, ctx, w, size); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_DecodeFSDefault)(HPyContext *ctx, const char *v) -{ - return UPCALL_HPY(ctx_Unicode_DecodeFSDefault, ctx, v); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_DecodeFSDefaultAndSize)(HPyContext *ctx, const char *v, HPy_ssize_t size) { - return UPCALL_HPY(ctx_Unicode_DecodeFSDefaultAndSize, ctx, v, size); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_EncodeFSDefault)(HPyContext *ctx, HPy h) { - return UPCALL_HPY(ctx_Unicode_EncodeFSDefault, ctx, h); -} - -HPyAPI_STORAGE uint32_t _HPy_IMPL_NAME(Unicode_ReadChar)(HPyContext *ctx, HPy h, HPy_ssize_t index) { - return (uint32_t) UPCALL_I32(ctx_Unicode_ReadChar, ctx, h, index); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_DecodeLatin1)(HPyContext *ctx, const char *s, HPy_ssize_t size, const char *errors) { - return UPCALL_HPY(ctx_Unicode_DecodeLatin1, ctx, s, size, errors ); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_DecodeASCII)(HPyContext *ctx, const char *s, HPy_ssize_t size, const char *errors) { - return UPCALL_HPY(ctx_Unicode_DecodeASCII, ctx, s, size, errors ); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(List_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_List_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(List_New)(HPyContext *ctx, HPy_ssize_t len) -{ - return UPCALL_HPY(ctx_List_New, ctx, len); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(List_Append)(HPyContext *ctx, HPy h_list, HPy h_item) -{ - return (int) UPCALL_I32(ctx_List_Append, ctx, h_list, h_item); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Dict_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Dict_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_New)(HPyContext *ctx) -{ - return UPCALL_HPY0(ctx_Dict_New, ctx); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Tuple_Check)(HPyContext *ctx, HPy h) -{ - return (int) UPCALL_I32(ctx_Tuple_Check, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Tuple_FromArray)(HPyContext *ctx, _HPyPtr items, HPy_ssize_t n) -{ - return UPCALL_HPY(ctx_Tuple_FromArray, ctx, items, n); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Import_ImportModule)(HPyContext *ctx, const char *name) -{ - return UPCALL_HPY(ctx_Import_ImportModule, ctx, name); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME_NOPREFIX(FromPyObject)(HPyContext *ctx, cpy_PyObject *obj) -{ - /* Although, this operation is not supported for in ABI compatibility mode, we still - need to implement the callback properly because it might still be a valid path - in other modes. */ - return UPCALL_HPY(ctx_FromPyObject, ctx, obj); -} - -HPyAPI_STORAGE cpy_PyObject *_HPy_IMPL_NAME_NOPREFIX(AsPyObject)(HPyContext *ctx, HPy h) -{ - return (cpy_PyObject *) UPCALL_CHARPTR(ctx_AsPyObject, ctx, h); -} - -HPyAPI_STORAGE HPyListBuilder _HPy_IMPL_NAME(ListBuilder_New)(HPyContext *ctx, HPy_ssize_t initial_size) { - return UPCALL_HPY(ctx_ListBuilder_New, ctx, initial_size); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(ListBuilder_Set)(HPyContext *ctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item) { - UPCALL_VOID(ctx_ListBuilder_Set, ctx, builder, index, h_item); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(ListBuilder_Build)(HPyContext *ctx, HPyListBuilder builder) { - return UPCALL_HPY(ctx_ListBuilder_Build, ctx, builder); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(ListBuilder_Cancel)(HPyContext *ctx, HPyListBuilder builder) { - UPCALL_VOID(ctx_ListBuilder_Cancel, ctx, builder); -} - -HPyAPI_STORAGE HPyTupleBuilder _HPy_IMPL_NAME(TupleBuilder_New)(HPyContext *ctx, HPy_ssize_t initial_size) { - return UPCALL_HPY(ctx_TupleBuilder_New, ctx, initial_size); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(TupleBuilder_Set)(HPyContext *ctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item) { - UPCALL_VOID(ctx_TupleBuilder_Set, ctx, builder, index, h_item); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(TupleBuilder_Build)(HPyContext *ctx, HPyTupleBuilder builder) { - return UPCALL_HPY(ctx_TupleBuilder_Build, ctx, builder); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(TupleBuilder_Cancel)(HPyContext *ctx, HPyTupleBuilder builder) { - UPCALL_VOID(ctx_TupleBuilder_Cancel, ctx, builder); -} - -HPyAPI_STORAGE HPyTracker _HPy_IMPL_NAME(Tracker_New)(HPyContext *ctx, HPy_ssize_t size) { - return UPCALL_HPY(ctx_Tracker_New, ctx, size); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Tracker_Add)(HPyContext *ctx, HPyTracker ht, HPy h) { - return (int) UPCALL_I32(ctx_Tracker_Add, ctx, ht, h); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Tracker_ForgetAll)(HPyContext *ctx, HPyTracker ht) { - UPCALL_VOID(ctx_Tracker_ForgetAll, ctx, ht); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Tracker_Close)(HPyContext *ctx, HPyTracker ht) { - UPCALL_VOID(ctx_Tracker_Close, ctx, ht); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Field_Store)(HPyContext *ctx, HPy target_object, _HPyFieldPtr target_field, HPy h) { - UPCALL_VOID(ctx_Field_Store, ctx, target_object, target_field, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Field_Load)(HPyContext *ctx, HPy source_object, HPyField source_field) { - return UPCALL_HPY(ctx_Field_Load, ctx, source_object, source_field); -} - -HPyAPI_STORAGE HPyThreadState _HPy_IMPL_NAME(LeavePythonExecution)(HPyContext *ctx) { - return UPCALL_HPY0(ctx_LeavePythonExecution, ctx); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(ReenterPythonExecution)(HPyContext *ctx, HPyThreadState state) { - UPCALL_VOID(ctx_ReenterPythonExecution, ctx, state); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Global_Store)(HPyContext *ctx, _HPyGlobalPtr global, HPy h) { - UPCALL_VOID(ctx_Global_Store, ctx, global, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Global_Load)(HPyContext *ctx, HPyGlobal global) { - return UPCALL_HPY(ctx_Global_Load, ctx, global); -} - -HPyAPI_STORAGE void _HPy_IMPL_NAME(Dump)(HPyContext *ctx, HPy h) { - UPCALL_VOID(ctx_Dump, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(MaybeGetAttr_s)(HPyContext *ctx, HPy obj, const char *name) { - return UPCALL_HPY(ctx_MaybeGetAttr_s, ctx, obj, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(SetType)(HPyContext *ctx, HPy obj, HPy type) { - return (int) UPCALL_I32(ctx_SetType, ctx, obj, type); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Type_IsSubtype)(HPyContext *ctx, HPy sub, HPy type) { - return (int) UPCALL_I32(ctx_Type_IsSubtype, ctx, sub, type); -} - -HPyAPI_STORAGE const char* _HPy_IMPL_NAME(Type_GetName)(HPyContext *ctx, HPy type) { - return UPCALL_CHARPTR(ctx_Type_GetName, ctx, type); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_FromEncodedObject)(HPyContext *ctx, HPy obj, const char *encoding, const char *errors) { - return UPCALL_HPY(ctx_Unicode_FromEncodedObject, ctx, obj, encoding, errors); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_InternFromString)(HPyContext *ctx, const char *str) { - return UPCALL_HPY(ctx_Unicode_InternFromString, ctx, str); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Unicode_Substring)(HPyContext *ctx, HPy obj, HPy_ssize_t start, HPy_ssize_t end) { - return UPCALL_HPY(ctx_Unicode_Substring, ctx, obj, start, end); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_Keys)(HPyContext *ctx, HPy h) { - return UPCALL_HPY(ctx_Dict_Keys, ctx, h); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Dict_GetItem)(HPyContext *ctx, HPy op, HPy key) { - return UPCALL_HPY(ctx_Dict_GetItem, ctx, op, key); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(ContextVar_New)(HPyContext *ctx, const char *name, HPy default_value) { - return UPCALL_HPY(ctx_ContextVar_New, ctx, name, default_value); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(ContextVar_Get)(HPyContext *ctx, HPy context_var, HPy default_value, _HPyPtr result) { - return (int) UPCALL_I32(ctx_ContextVar_Get, ctx, context_var, default_value, result); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(ContextVar_Set)(HPyContext *ctx, HPy context_var, HPy value) { - return UPCALL_HPY(ctx_ContextVar_Set, ctx, context_var, value); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(Capsule_New)(HPyContext *ctx, void *pointer, const char *name, HPyCapsule_Destructor destructor) { - return UPCALL_HPY(ctx_Capsule_New, ctx, pointer, name, destructor); -} - -HPyAPI_STORAGE void *_HPy_IMPL_NAME(Capsule_Get)(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *name) { - return UPCALL_HPY(ctx_Capsule_Get, ctx, capsule, (int32_t)key, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Capsule_IsValid)(HPyContext *ctx, HPy capsule, const char *name) { - return (int) UPCALL_I32(ctx_Capsule_IsValid, ctx, capsule, name); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Capsule_Set)(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value) { - return (int) UPCALL_I32(ctx_Capsule_Set, ctx, capsule, (int32_t)key, value); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Type_CheckSlot)(HPyContext *ctx, HPy type, HPyDef *expected) { - return (int) UPCALL_I32(ctx_Type_CheckSlot, ctx, type, expected); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Sequence_Check)(HPyContext *ctx, HPy obj) { - return (int) UPCALL_I32(ctx_Sequence_Check, ctx, obj); -} - -HPyAPI_STORAGE int _HPy_IMPL_NAME(Slice_Unpack)(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) { - return (int) UPCALL_I32(ctx_Slice_Unpack, ctx, slice, start, stop, step); -} - -HPyAPI_STORAGE HPy _HPy_IMPL_NAME(SeqIter_New)(HPyContext *ctx, HPy seq) { - return UPCALL_HPY(ctx_SeqIter_New, ctx, seq); -} - -#undef HPy -#undef HPyListBuilder -#undef HPyTupleBuilder -#undef HPyTracker -#undef HPyField -#undef HPyThreadState -#undef HPyGlobal -#undef _HPyCapsule_key - -#undef _HPy_IMPL_NAME_NOPREFIX -#undef _HPy_IMPL_NAME - -#include "hpynative.h" - -/* Allocate a native HPy context structure and fill it. */ -HPyContext *graal_hpy_context_to_native(HPyContext *managed_context) { - GraalHPyContext *full_native_context = (GraalHPyContext *) malloc(sizeof(GraalHPyContext)); - - HPyContext *native_context = graal_native_context_get_hpy_context(full_native_context); - -#define COPY(__member) native_context->__member = managed_context->__member - COPY(name); - COPY(abi_version); - COPY(h_None); - COPY(h_True); - COPY(h_False); - COPY(h_NotImplemented); - COPY(h_Ellipsis); - COPY(h_BaseException); - COPY(h_Exception); - COPY(h_StopAsyncIteration); - COPY(h_StopIteration); - COPY(h_GeneratorExit); - COPY(h_ArithmeticError); - COPY(h_LookupError); - COPY(h_AssertionError); - COPY(h_AttributeError); - COPY(h_BufferError); - COPY(h_EOFError); - COPY(h_FloatingPointError); - COPY(h_OSError); - COPY(h_ImportError); - COPY(h_ModuleNotFoundError); - COPY(h_IndexError); - COPY(h_KeyError); - COPY(h_KeyboardInterrupt); - COPY(h_MemoryError); - COPY(h_NameError); - COPY(h_OverflowError); - COPY(h_RuntimeError); - COPY(h_RecursionError); - COPY(h_NotImplementedError); - COPY(h_SyntaxError); - COPY(h_IndentationError); - COPY(h_TabError); - COPY(h_ReferenceError); - COPY(h_SystemError); - COPY(h_SystemExit); - COPY(h_TypeError); - COPY(h_UnboundLocalError); - COPY(h_UnicodeError); - COPY(h_UnicodeEncodeError); - COPY(h_UnicodeDecodeError); - COPY(h_UnicodeTranslateError); - COPY(h_ValueError); - COPY(h_ZeroDivisionError); - COPY(h_BlockingIOError); - COPY(h_BrokenPipeError); - COPY(h_ChildProcessError); - COPY(h_ConnectionError); - COPY(h_ConnectionAbortedError); - COPY(h_ConnectionRefusedError); - COPY(h_ConnectionResetError); - COPY(h_FileExistsError); - COPY(h_FileNotFoundError); - COPY(h_InterruptedError); - COPY(h_IsADirectoryError); - COPY(h_NotADirectoryError); - COPY(h_PermissionError); - COPY(h_ProcessLookupError); - COPY(h_TimeoutError); - COPY(h_Warning); - COPY(h_UserWarning); - COPY(h_DeprecationWarning); - COPY(h_PendingDeprecationWarning); - COPY(h_SyntaxWarning); - COPY(h_RuntimeWarning); - COPY(h_FutureWarning); - COPY(h_ImportWarning); - COPY(h_UnicodeWarning); - COPY(h_BytesWarning); - COPY(h_ResourceWarning); - COPY(h_BaseObjectType); - COPY(h_TypeType); - COPY(h_BoolType); - COPY(h_LongType); - COPY(h_FloatType); - COPY(h_UnicodeType); - COPY(h_TupleType); - COPY(h_ListType); - COPY(h_ComplexType); - COPY(h_BytesType); - COPY(h_MemoryViewType); - COPY(h_CapsuleType); - COPY(h_SliceType); -#undef COPY - - return native_context; -} - -#undef WRAP -#undef UNWRAP diff --git a/graalpython/com.oracle.graal.python.hpy.llvm/src/hpynative.h b/graalpython/com.oracle.graal.python.hpy.llvm/src/hpynative.h deleted file mode 100644 index decae94d0c..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.llvm/src/hpynative.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021, 2023, 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. - */ - -#ifndef HPY_HPYNATIVE_H_ -#define HPY_HPYNATIVE_H_ - -#include - -#include "hpy.h" - -typedef struct { - void *jni_backend; - void *jni_context; - - /* embed HPy context */ - HPyContext hpy_context; -} GraalHPyContext; - -#if defined(_MSC_VER) && !defined(__clang__) -#define MUST_INLINE static inline -#else -#define MUST_INLINE __attribute__((always_inline)) static inline -#endif - -MUST_INLINE HPyContext *graal_native_context_get_hpy_context(GraalHPyContext *native_context) { - return &(native_context->hpy_context); -} - -MUST_INLINE GraalHPyContext *graal_hpy_context_get_native_context(HPyContext *hpy_context) { - return (GraalHPyContext *)(((char *)hpy_context) - offsetof(GraalHPyContext, hpy_context)); -} - -#endif /* HPY_HPYNATIVE_H_ */ diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/__init__.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/__init__.py deleted file mode 100644 index f8907d5ea7..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/check_py27_compat.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/check_py27_compat.py deleted file mode 100644 index 3c15890655..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/check_py27_compat.py +++ /dev/null @@ -1,113 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -Some of the files in this repo are used also by PyPy tests, which run on -python2.7. - -This script tries to import all of them: it does not check any behavior, just -that they are importable and thus are not using any py3-specific syntax. - -This script assumes that pathlib and pytest are installed (because the modules -try to import them). -""" - -from __future__ import print_function -import sys -import traceback -import py - -ROOT = py.path.local(__file__).join('..', '..') -TEST_DIRS = [ROOT / 'test', ROOT / 'test' / 'debug'] - -# PyPy does NOT import these files using py2 -PY3_ONLY = ['test_support.py', - 'test_handles_invalid.py', - 'test_handles_leak.py', - 'test_builder_invalid.py'] - -def try_import(name): - try: - if isinstance(name, py.path.local): - print('Trying to import %s... ' % ROOT.bestrelpath(name), end='') - name.pyimport() - else: - print('Trying to import %s... ' % name, end='') - __import__(name) - except: - print('ERROR!') - print() - traceback.print_exc(file=sys.stdout) - print() - return False - else: - print('OK') - return True - -def try_import_hpy_devel(): - """ - To import hpy.devel we need to create an empty hpy/__init__.py, because - python2.7 does not support namespace packages. - - Return the number of failed imports. - """ - failed = 0 - init_py = ROOT.join('hpy', '__init__.py') - assert init_py.check(exists=False) - try: - init_py.write('') # create an empty __init__.py - if not try_import('hpy.devel'): - failed += 1 - finally: - init_py.remove() - return failed - -def try_import_tests(dirs): - failed = 0 - for d in dirs: - for t in d.listdir('test_*.py'): - if t.basename in PY3_ONLY: - continue - if not try_import(t): - failed += 1 - return failed - - -def main(): - if sys.version_info[:2] != (2, 7): - print('ERROR: this script should be run on top of python 2.7') - sys.exit(1) - - sys.path.insert(0, str(ROOT)) - failed = 0 - failed += try_import_hpy_devel() - failed += try_import_tests(TEST_DIRS) - print() - if failed == 0: - print('Everything ok!') - else: - print('%d failed imports :(' % failed) - sys.exit(1) - -if __name__ == '__main__': - main() diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/conftest.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/conftest.py deleted file mode 100644 index 916169e287..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/conftest.py +++ /dev/null @@ -1,152 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import os -import sys -import pytest -from .support import ExtensionCompiler, DefaultExtensionTemplate,\ - PythonSubprocessRunner, HPyDebugCapture, make_hpy_abi_fixture -from hpy.debug.leakdetector import LeakDetector -from pathlib import Path - -IS_VALGRIND_RUN = False -def pytest_addoption(parser): - parser.addoption( - "--compiler-v", action="http://github.com/store_true", - help="Print to stdout the commands used to invoke the compiler") - parser.addoption( - "--subprocess-v", action="http://github.com/store_true", - help="Print to stdout the stdout and stderr of Python subprocesses " - "executed via run_python_subprocess") - parser.addoption( - "--dump-dir", - help="Enables dump mode and specifies where to write generated test " - "sources. This will then only generate the sources and skip " - "evaluation of the tests.") - parser.addoption( - '--reuse-venv', action="http://github.com/store_true", - help="Development only: reuse the venv for test_distutils.py instead of " - "creating a new one for every test") - - -@pytest.hookimpl(trylast=True) -def pytest_configure(config): - global IS_VALGRIND_RUN - IS_VALGRIND_RUN = config.pluginmanager.hasplugin('valgrind_checker') - config.addinivalue_line( - "markers", "syncgc: Mark tests that rely on a synchronous GC." - ) - config.addinivalue_line( - "markers", "tp_traverse: Mark tests that rely tp_traverse being called." - ) - - -def pytest_runtest_setup(item): - if (sys.implementation.name in ["graalpy", "pypy"] and - "syncgc" in [mark.name for mark in item.iter_markers()]): - pytest.skip(f"cannot run syncgc test on {sys.implementation.name}") - if (sys.implementation.name in ["graalpy"] and - "tp_traverse" in [mark.name for mark in item.iter_markers()]): - pytest.skip(f"{sys.implementation.name} does not call tp_traverse") - - -# this is the default set of hpy_abi for all the tests. Individual files and -# classes can override it. -SELECTED_ABI_MODE = os.environ.get("TEST_HPY_ABI", None) -if SELECTED_ABI_MODE: - hpy_abi = make_hpy_abi_fixture([SELECTED_ABI_MODE]) -else: - hpy_abi = make_hpy_abi_fixture('default') - - -@pytest.fixture(scope='session') -def hpy_devel(request): - from hpy.devel import HPyDevel - return HPyDevel() - -@pytest.fixture -def leakdetector(hpy_abi): - """ - Automatically detect leaks when the hpy_abi == 'debug' - """ - if 'debug' in hpy_abi: - with LeakDetector() as ld: - yield ld - else: - yield None - -@pytest.fixture -def ExtensionTemplate(): - return DefaultExtensionTemplate - -@pytest.fixture -def compiler(request, tmpdir, hpy_devel, hpy_abi, ExtensionTemplate): - compiler_verbose = request.config.getoption('--compiler-v') - dump_dir = request.config.getoption('--dump-dir') - if dump_dir: - # Test-specific dump dir in format: dump_dir/[mod_][cls_]func - qname_parts = [] - if request.module: - qname_parts.append(request.module.__name__) - if request.cls: - qname_parts.append(request.cls.__name__) - qname_parts.append(request.function.__name__) - test_dump_dir = "_".join(qname_parts).replace(".", "_") - dump_dir = Path(dump_dir).joinpath(test_dump_dir) - dump_dir.mkdir(parents=True, exist_ok=True) - return ExtensionCompiler(tmpdir, hpy_devel, hpy_abi, - compiler_verbose=compiler_verbose, - dump_dir=dump_dir, - ExtensionTemplate=ExtensionTemplate) - - -@pytest.fixture() -def skip_cpython_abi(hpy_abi): - # skip all tests in this class for CPython ABI mode - if hpy_abi == 'cpython': - pytest.skip() - - -@pytest.fixture(scope="session") -def fatal_exit_code(request): - import sys - return { - "linux": -6, # SIGABRT - # See https://bugs.python.org/issue36116#msg336782 -- the - # return code from abort on Windows 8+ is a stack buffer overrun. - # :| - "win32": 0xC0000409, # STATUS_STACK_BUFFER_OVERRUN - }.get(sys.platform, -6) - - -@pytest.fixture -def python_subprocess(request, hpy_abi): - verbose = request.config.getoption('--subprocess-v') - yield PythonSubprocessRunner(verbose, hpy_abi) - - -@pytest.fixture() -def hpy_debug_capture(request, hpy_abi): - assert hpy_abi == 'debug' - with HPyDebugCapture() as reporter: - yield reporter diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_builder_invalid.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_builder_invalid.py deleted file mode 100644 index 132a24cc64..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_builder_invalid.py +++ /dev/null @@ -1,174 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from hpy.debug.leakdetector import LeakDetector -from hpytest.support import HPyTest - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -@pytest.fixture -def hpy_abi(): - with LeakDetector(): - yield "debug" - - -def test_correct_usage(compiler, hpy_debug_capture): - # Basic sanity check that valid code does not trigger any error reports - mod = compiler.make_module(""" - HPyDef_METH(build, "build", HPyFunc_VARARGS) - static HPy build_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyTupleBuilder tbuilder = HPyTupleBuilder_New(ctx, nargs); - HPyListBuilder lbuilder = HPyListBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) { - HPyTupleBuilder_Set(ctx, tbuilder, i, args[i]); - HPyListBuilder_Set(ctx, lbuilder, i, args[i]); - } - HPy t = HPyTupleBuilder_Build(ctx, tbuilder); - HPy l = HPyListBuilder_Build(ctx, lbuilder); - HPy h_result = HPyTuple_Pack(ctx, 2, t, l); - HPy_Close(ctx, t); - HPy_Close(ctx, l); - return h_result; - } - - HPyDef_METH(cancel, "cancel", HPyFunc_VARARGS) - static HPy cancel_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyTupleBuilder tbuilder = HPyTupleBuilder_New(ctx, nargs); - HPyListBuilder lbuilder = HPyListBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) { - HPyTupleBuilder_Set(ctx, tbuilder, i, args[i]); - HPyListBuilder_Set(ctx, lbuilder, i, args[i]); - } - HPyTupleBuilder_Cancel(ctx, tbuilder); - HPyListBuilder_Cancel(ctx, lbuilder); - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(build) - @EXPORT(cancel) - @INIT - """) - assert mod.build('hello', 42, None) == (('hello', 42, None), ['hello', 42, None]) - assert mod.cancel('hello', 42, None) is None - assert hpy_debug_capture.invalid_builders_count == 0 - - -def test_build_twice(compiler, hpy_debug_capture): - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyTupleBuilder_Set(ctx, builder, i, args[i]); - HPy h_result = HPyTupleBuilder_Build(ctx, builder); - HPy_Close(ctx, h_result); - return HPyTupleBuilder_Build(ctx, builder); - } - HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyListBuilder_Set(ctx, builder, i, args[i]); - HPy h_result = HPyListBuilder_Build(ctx, builder); - HPy_Close(ctx, h_result); - return HPyListBuilder_Build(ctx, builder); - } - @EXPORT(f) - @EXPORT(g) - @INIT - """) - with pytest.raises(MemoryError): - mod.f('hello', 42, None) - assert hpy_debug_capture.invalid_builders_count == 1 - with pytest.raises(MemoryError): - mod.g('hello', 42, None) - assert hpy_debug_capture.invalid_builders_count == 2 - - -def test_build_after_cancel(compiler, hpy_debug_capture): - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyTupleBuilder_Set(ctx, builder, i, args[i]); - HPyTupleBuilder_Cancel(ctx, builder); - return HPyTupleBuilder_Build(ctx, builder); - } - HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyListBuilder_Set(ctx, builder, i, args[i]); - HPyListBuilder_Cancel(ctx, builder); - return HPyListBuilder_Build(ctx, builder); - } - @EXPORT(f) - @EXPORT(g) - @INIT - """) - with pytest.raises(MemoryError): - mod.f('hello', 42, None) - assert hpy_debug_capture.invalid_builders_count == 1 - with pytest.raises(MemoryError): - mod.g('hello', 42, None) - assert hpy_debug_capture.invalid_builders_count == 2 - - -def test_build_cancel_after_build(compiler, hpy_debug_capture): - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyTupleBuilder_Set(ctx, builder, i, args[i]); - HPy h_result = HPyTupleBuilder_Build(ctx, builder); - HPyTupleBuilder_Cancel(ctx, builder); - HPy_Close(ctx, h_result); - return HPy_Dup(ctx, ctx->h_None); - } - HPyDef_METH(g, "g", HPyFunc_VARARGS) - static HPy g_impl(HPyContext *ctx, HPy h_self, const HPy *args, size_t nargs) - { - HPyListBuilder builder = HPyListBuilder_New(ctx, nargs); - for (size_t i=0; i < nargs; i++) - HPyListBuilder_Set(ctx, builder, i, args[i]); - HPy h_result = HPyListBuilder_Build(ctx, builder); - HPyListBuilder_Cancel(ctx, builder); - HPy_Close(ctx, h_result); - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @EXPORT(g) - @INIT - """) - mod.f('hello', 42, None) - mod.g('hello', 42, None) - assert hpy_debug_capture.invalid_builders_count == 2 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_charptr.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_charptr.py deleted file mode 100644 index 4544ee92f9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_charptr.py +++ /dev/null @@ -1,341 +0,0 @@ -# Copyright (c) 2022, 2024, 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. - -import os -import pytest -from hpytest.support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION, HPyTest - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -# Tests detection of usage of char pointers associated with invalid already -# closed handles. For now, the debug mode does not provide any hook for this -# error, so we have to run the tests from subprocess and check the return code. - -@pytest.fixture -def hpy_abi(): - from hpy.debug import LeakDetector - with LeakDetector(): - yield "debug" - - -@pytest.mark.xfail -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_charptr_use_after_implicit_arg_handle_close(compiler, python_subprocess): - mod = compiler.compile_module(""" - const char *keep; - - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) - { - if (n != 2) { - HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); - return HPy_NULL; - } - long mode = HPyLong_AsLong(ctx, args[1]); - if (mode == -1) - return HPy_NULL; - - HPy_ssize_t size; - if (mode == 0) { - keep = HPyUnicode_AsUTF8AndSize(ctx, args[0], &size); - } else if (mode == 1) { - keep = HPyBytes_AsString(ctx, args[0]); - } else if (mode == 2) { - keep = HPyBytes_AS_STRING(ctx, args[0]); - } else { - HPyErr_SetString(ctx, ctx->h_ValueError, "invalid mode"); - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(g, "g", HPyFunc_NOARGS) - static HPy g_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, keep); - } - - @EXPORT(f) - @EXPORT(g) - @INIT - """) - content = "'use after close me!'" - bcontent = 'b' + content - for mode, msg in enumerate((content, bcontent, bcontent)): - if SUPPORTS_MEM_PROTECTION and False: - code = "mod.f({}, {}); mod.g()".format(msg, mode) - else: - code = "mod.f({0}, {1}); assert mod.g() == str({0})".format(msg, mode) - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert result.stdout == b"" - if SUPPORTS_MEM_PROTECTION: - assert result.stderr == b"" - else: - # The garbage we override the data with will cause this error - assert b"UnicodeDecodeError" in result.stderr - - -@pytest.mark.xfail -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_charptr_use_after_handle_close(compiler, python_subprocess): - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) - { - if (n != 2) { - HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); - return HPy_NULL; - } - long mode = HPyLong_AsLong(ctx, args[1]); - if (mode == -1) - return HPy_NULL; - - HPy arg_dup = HPy_Dup(ctx, args[0]); - HPy_ssize_t size; - const char *keep; - if (mode == 0) { - keep = HPyUnicode_AsUTF8AndSize(ctx, arg_dup, &size); - } else if (mode == 1) { - keep = HPyBytes_AsString(ctx, arg_dup); - } else if (mode == 2) { - keep = HPyBytes_AS_STRING(ctx, arg_dup); - } else { - HPyErr_SetString(ctx, ctx->h_ValueError, "invalid mode"); - return HPy_NULL; - } - HPy_Close(ctx, arg_dup); - return HPyUnicode_FromString(ctx, keep); - } - - @EXPORT(f) - @INIT - """) - content = "'use after close me!'" - bcontent = "b" + content - for mode, msg in enumerate((content, bcontent, bcontent)): - if SUPPORTS_MEM_PROTECTION: - code = "mod.f({}, {})".format(msg, mode) - else: - code = "assert mod.f({0}, {1}) == str({0})".format(msg, mode) - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert result.stdout == b"" - if SUPPORTS_MEM_PROTECTION: - assert result.stderr == b"" - else: - # The garbage we override the data with will cause this error - assert b"UnicodeDecodeError" in result.stderr - - -@pytest.mark.xfail -@pytest.mark.skipif(not SUPPORTS_MEM_PROTECTION, reason= - "Could be implemented by checking the contents on close.") -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_charptr_write_ptr(compiler, python_subprocess): - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t n) - { - if (n != 2) { - HPyErr_SetString(ctx, ctx->h_ValueError, "expected exactly two arguments"); - return HPy_NULL; - } - long mode = HPyLong_AsLong(ctx, args[1]); - if (mode == -1) - return HPy_NULL; - - HPy_ssize_t size; - char *data; - if (mode == 0) { - data = (char *)HPyUnicode_AsUTF8AndSize(ctx, args[0], &size); - } else if (mode == 1) { - data = (char *)HPyBytes_AsString(ctx, args[0]); - } else if (mode == 2) { - data = (char *)HPyBytes_AS_STRING(ctx, args[0]); - } else { - HPyErr_SetString(ctx, ctx->h_ValueError, "invalid mode"); - return HPy_NULL; - } - // write to read-only memory - data[0] = 'a'; - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @INIT - """) - content = "'try writing me!'" - bcontent = "b" + content - for mode, msg in enumerate((content, bcontent, bcontent)): - result = python_subprocess.run(mod, "mod.f({}, {});".format(msg, mode)) - assert result.returncode != 0 - assert result.stdout == b"" - assert result.stderr == b"" - - -def test_charptr_correct_usage(compiler): - mod = compiler.make_module(""" - #include - #include - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy arg_dup = HPy_Dup(ctx, arg); - HPy_ssize_t size; - const char *keep = HPyUnicode_AsUTF8AndSize(ctx, arg_dup, &size); - char *copy = (char*) malloc(size + 1); - memcpy(copy, keep, size + 1); - HPy_Close(ctx, arg_dup); - HPy result = HPyUnicode_FromString(ctx, copy); - free(copy); - return result; - } - - @EXPORT(f) - @INIT - """) - assert mod.f('I wont be leaked!') == 'I wont be leaked!'; - - -@pytest.mark.xfail -def test_charptr_limit_stress_test(compiler): - from hpy.universal import _debug - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t size; - HPyUnicode_AsUTF8AndSize(ctx, arg, &size); - if (size == 0) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - // Dummy function just to force handle creation, but should not create - // any raw data attached to those handles - HPyDef_METH(g, "g", HPyFunc_O) - static HPy g_impl(HPyContext *ctx, HPy self, HPy arg) - { - int len = HPyLong_AsLong(ctx, arg); - for (int i = 0; i < len; ++i) { - HPy h = HPyLong_FromLong(ctx, i); - HPy_Close(ctx, h); - } - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @EXPORT(g) - @INIT - """) - - def get_raw_data_sizes(handles): - return list(map(lambda h: h.raw_data_size, handles)) - - def clear_raw_data_in_closed_handles(): - closed_size = len(_debug.get_closed_handles()) - old_limit = _debug.get_closed_handles_queue_max_size() - try: - # make sure that the closed_handles queue is considered full: this - # will force the reuse of existing closed handles. - _debug.set_closed_handles_queue_max_size(closed_size) - # Dummy call to force the reuse of the existing closed handles - # -2 because 'self' and the 'arg' should already reuse 2 handles - mod.g(closed_size - 2) - finally: - _debug.set_closed_handles_queue_max_size(old_limit) - return closed_size - - old_raw_data_max_size = _debug.get_protected_raw_data_max_size() - old_closed_handles_max_size = _debug.get_closed_handles_queue_max_size() - _debug.set_protected_raw_data_max_size(100) - try: - # Reset the state as much as possible: - closed_size = clear_raw_data_in_closed_handles() - # Make enough room for the handles created by this test - _debug.set_closed_handles_queue_max_size(closed_size + 100) - # Sanity check: no raw data is now held by closed handles - initial = get_raw_data_sizes(_debug.get_closed_handles()) - assert all(map(lambda x: x == -1, initial)) - - # Large string that shouldn't be retained at all - gen = _debug.new_generation() - mod.f('abc' * 50) - closed1 = get_raw_data_sizes(_debug.get_closed_handles(gen)) - assert closed1 == [-1, -1, -1] # -1 for 'self' and the return value - - # Two small strings, should be kept, one large that should not fit in - gen = _debug.new_generation() - mod.f('a' * 31) - mod.f('b' * 32) - mod.f('c' * 50) - closed2 = get_raw_data_sizes(_debug.get_closed_handles(gen)) - # -1 for 'self'/return value for each call, and the long string - # note: C strings' size is +1 for the terminating '\0' - assert sorted(closed2) == [-1] * 7 + [32, 33] - - # Another small string should still fit - gen = _debug.new_generation() - mod.f('a' * 13) - closed3 = get_raw_data_sizes(_debug.get_closed_handles(gen)) - # 'self'/return, and the expected small string - assert sorted(closed3) == [-1, -1, 14] - - # But another small-ish string not anymore - gen = _debug.new_generation() - mod.f('a' * 27) - closed4 = get_raw_data_sizes(_debug.get_closed_handles(gen)) - # 'self'/return, and the string whose raw data didn't fit in - assert sorted(closed4) == [-1, -1, -1] - - # Check that raw data of closed handles is freed when the handle - # is reused - closed_size = clear_raw_data_in_closed_handles() - - # None of the closed handles should now have any raw data attached - all_closed = _debug.get_closed_handles() - assert len(all_closed) == closed_size # Sanity check - for h in all_closed: - assert h.raw_data_size == -1 - finally: - _debug.set_protected_raw_data_max_size(old_raw_data_max_size) - _debug.set_closed_handles_queue_max_size(old_closed_handles_max_size) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_context_reuse.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_context_reuse.py deleted file mode 100644 index d6b6881adc..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_context_reuse.py +++ /dev/null @@ -1,128 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from hpytest.support import HPyTest - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -@pytest.fixture -def hpy_abi(): - return "debug" - - -def test_reuse_context_from_global_variable(compiler, python_subprocess): - mod = compiler.compile_module(""" - #include - - HPyContext *keep; - - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - // We wrongly save the context to a global variable - keep = ctx; - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(g, "g", HPyFunc_NOARGS) - static HPy g_impl(HPyContext *ctx, HPy self) - { - HPy t = HPy_Dup(ctx, ctx->h_True); - // just checking if the correct context works - if (!HPy_TypeCheck(ctx, t, ctx->h_BoolType)) { - // if the correct context gives us bogus result, - // this will make the test fail - HPy_Close(ctx, t); - return HPy_Dup(ctx, ctx->h_None); - } - HPy_Close(ctx, t); - fprintf(stdout, "Heavy Marmelade\\n"); - fflush(stdout); - // Here we wrongly use "keep" instead of "ctx" - return HPy_Dup(keep, ctx->h_None); - } - - HPyDef_METH(bounce, "bounce", HPyFunc_O) - static HPy bounce_impl(HPyContext *ctx, HPy self, HPy trampoline) - { - fprintf(stdout, "Bouncing...\\n"); - fflush(stdout); - return HPy_CallTupleDict(ctx, trampoline, HPy_NULL, HPy_NULL); - } - - HPyDef_METH(keep_and_bounce, "keep_and_bounce", HPyFunc_O) - static HPy keep_and_bounce_impl(HPyContext *ctx, HPy self, HPy trampoline) - { - fprintf(stdout, "Bouncing differently...\\n"); - fflush(stdout); - keep = ctx; - return HPy_CallTupleDict(ctx, trampoline, HPy_NULL, HPy_NULL); - } - - @EXPORT(f) - @EXPORT(g) - @EXPORT(bounce) - @EXPORT(keep_and_bounce) - @INIT - """) - - code = "mod.f(); mod.g()" - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert b"Error: Wrong HPy Context!" in result.stderr - assert result.stdout == b"Heavy Marmelade\n" - - code = "mod.f(); mod.bounce(lambda: mod.g())" - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert b"Error: Wrong HPy Context!" in result.stderr - assert result.stdout == b"Bouncing...\nHeavy Marmelade\n" - - # checks the situation when the context cache runs out, - # and we start reusing cached contexts - code = "mod.f(); bounce_cnt = {};\n" \ - "def trampoline():\n" \ - " global bounce_cnt\n" \ - " bounce_cnt -= 1\n" \ - " return mod.bounce(trampoline) if bounce_cnt > 0 else mod.g()\n" \ - "mod.bounce(trampoline)" - - # With the reference HPy debug context implementation if we happen to run - # the usage of 'keep' on the same recycled context as when we saved 'keep', - # then ctx == keep, and it will not fail. - # To keep the test implementation agnostic, we just stress test it with - # different numbers and check that it either crashes with the right error - # or it does not crash and gives the correct result. - HPY_DEBUG_CTX_CACHE_SIZE = 16 - for size in range(HPY_DEBUG_CTX_CACHE_SIZE-1, HPY_DEBUG_CTX_CACHE_SIZE+2): - result = python_subprocess.run(mod, code.format(size)) - assert result.stdout == (b"Bouncing...\n" * size) + b"Heavy Marmelade\n" - if result.returncode != 0: - assert b"Error: Wrong HPy Context!" in result.stderr - - code = 'mod.keep_and_bounce(lambda: mod.g())' - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert b"Error: Wrong HPy Context!" in result.stderr - assert result.stdout == b"Bouncing differently...\n" + b"Heavy Marmelade\n" diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_invalid.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_invalid.py deleted file mode 100644 index b05ac61bf9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_invalid.py +++ /dev/null @@ -1,250 +0,0 @@ -# Copyright (c) 2022, 2023, 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. - -import pytest -from hpy.debug.leakdetector import LeakDetector -from hpytest.support import SUPPORTS_SYS_EXECUTABLE, IS_PYTHON_DEBUG_BUILD, GRAALPYTHON, HPyTest -from hpytest.conftest import IS_VALGRIND_RUN - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -@pytest.fixture -def hpy_abi(): - with LeakDetector(): - yield "debug" - - -def test_no_invalid_handle(compiler, hpy_debug_capture): - # Basic sanity check that valid code does not trigger any error reports - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy x = HPyLong_FromLong(ctx, 42); - HPy y = HPyLong_FromLong(ctx, 2); - HPy arg_dup = HPy_Dup(ctx, arg); - HPy_Close(ctx, y); - HPy b = HPy_Dup(ctx, x); - HPy_Close(ctx, x); - HPy_Close(ctx, arg_dup); - return b; - } - - @EXPORT(f) - @INIT - """) - assert mod.f("hello") == 42 - assert mod.f("world") == 42 - assert hpy_debug_capture.invalid_handles_count == 0 - - -def test_cant_use_closed_handle(compiler, hpy_debug_capture): - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O, .doc="double close") - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h = HPy_Dup(ctx, arg); - HPy_Close(ctx, h); - HPy_Close(ctx, h); // double close - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(g, "g", HPyFunc_O, .doc="use after close") - static HPy g_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h = HPy_Dup(ctx, arg); - HPy_Close(ctx, h); - return HPy_Repr(ctx, h); - } - - HPyDef_METH(h, "h", HPyFunc_O, .doc="closing argument") - static HPy h_impl(HPyContext *ctx, HPy self, HPy arg) - { - // Argument is implicitly closed by the caller - HPy_Close(ctx, arg); - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(f_noargs, "f_noargs", HPyFunc_NOARGS, .doc="returns arg w/o dupping it") - static HPy f_noargs_impl(HPyContext *ctx, HPy self) - { - // should be: return HPy_Dup(ctx, self); - return self; - } - - HPyDef_METH(f0, "f0", HPyFunc_O, .doc="returns arg w/o dupping it") - static HPy f0_impl(HPyContext *ctx, HPy self, HPy arg) - { - // should be: return HPy_Dup(ctx, arg); - return arg; - } - - HPyDef_METH(f_varargs, "f_varargs", HPyFunc_VARARGS, .doc="returns arg w/o dupping it") - static HPy f_varargs_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - // should be: return HPy_Dup(ctx, args[0]); - return args[0]; - } - - @EXPORT(f) - @EXPORT(g) - @EXPORT(f0) - @EXPORT(f_noargs) - @EXPORT(f_varargs) - @EXPORT(h) - @INIT - """) - mod.f('foo') # double close - assert hpy_debug_capture.invalid_handles_count == 1 - mod.g('bar') # use-after-close - assert hpy_debug_capture.invalid_handles_count == 2 - if not IS_PYTHON_DEBUG_BUILD and not IS_VALGRIND_RUN: - # CPython debug build can also catch these errors, so we cannot trigger - # them when running on debug builds - mod.f0('foo') - assert hpy_debug_capture.invalid_handles_count == 3 - mod.f_noargs() - assert hpy_debug_capture.invalid_handles_count == 4 - mod.f_varargs('foo', 'bar') - assert hpy_debug_capture.invalid_handles_count == 5 - if not GRAALPYTHON: - # GraalPython does not support this test because of the strict - # separation between universal adn debug context. The debug context - # still correctly detects the invalid handle access but later, the - # runtime will still try to close the argument handle and there is - # no means to propagate that information to the handle owner. - # Hence, an assertion will fail. - mod.h('baz') - assert hpy_debug_capture.invalid_handles_count == 6 - - -@pytest.mark.xfail(reason="graalpython does not prevent reuse of leaked handles for other handles and thus cannot always catch this") -def test_keeping_and_reusing_argument_handle(compiler, hpy_debug_capture): - mod = compiler.make_module(""" - HPy keep; - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - keep = arg; - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(g, "g", HPyFunc_NOARGS) - static HPy g_impl(HPyContext *ctx, HPy self) - { - HPy_ssize_t len = HPy_Length(ctx, keep); - return HPyLong_FromSsize_t(ctx, len); - } - - @EXPORT(f) - @EXPORT(g) - @INIT - """) - s = "hello leaks!" - mod.f(s) - assert hpy_debug_capture.invalid_handles_count == 0 - assert mod.g() == len(s) - assert hpy_debug_capture.invalid_handles_count == 1 - - -def test_return_ctx_constant_without_dup(compiler, python_subprocess, fatal_exit_code): - # Since this puts the context->h_None into an inconsistent state, we run - # this test in a subprocess and check fatal error instead - if not SUPPORTS_SYS_EXECUTABLE: - pytest.skip("no sys.executable") - - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return ctx->h_None; - } - - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f();") - assert result.returncode == fatal_exit_code - assert b"Invalid usage of already closed handle" in result.stderr - - -def test_close_ctx_constant(compiler, python_subprocess, fatal_exit_code): - # Since this puts the context->h_True into an inconsistent state, we run - # this test in a subprocess and check fatal error instead - if not SUPPORTS_SYS_EXECUTABLE: - pytest.skip("no sys.executable") - - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPy_Close(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f();") - assert result.returncode == fatal_exit_code - assert b"Invalid usage of already closed handle" in result.stderr - - -@pytest.mark.xfail(reason="set_handle_stack_trace_limit not implemented yet") -def test_invalid_handle_crashes_python_if_no_hook(compiler, python_subprocess, fatal_exit_code): - if not SUPPORTS_SYS_EXECUTABLE: - pytest.skip("no sys.executable") - - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_O, .doc="double close") - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h = HPy_Dup(ctx, arg); - HPy_Close(ctx, h); - HPy_Close(ctx, h); // double close - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f(42);") - assert result.returncode == fatal_exit_code - assert b"Invalid usage of already closed handle" in result.stderr diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_leak.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_leak.py deleted file mode 100644 index d485532803..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_handles_leak.py +++ /dev/null @@ -1,322 +0,0 @@ -# Copyright (c) 2022, 2023, 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. - -import pytest -from hpy.debug import set_handle_stack_trace_limit, disable_handle_stack_traces -from hpytest.support import HPyTest - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -@pytest.fixture -def hpy_abi(): - return "debug" - - -class AllocationTraceEnabler: - def __enter__(self): - set_handle_stack_trace_limit(32) - - def __exit__(self, exc_type, exc_val, exc_tb): - disable_handle_stack_traces() - - -@pytest.fixture(params=["with stacktrace", "no stacktrace"]) -def with_alloc_trace(request): - if request.param == "with stacktrace": - with AllocationTraceEnabler(): - yield - else: - yield - - -def make_leak_module(compiler): - # for convenience - return compiler.make_module(""" - HPyDef_METH(leak, "leak", HPyFunc_O) - static HPy leak_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_Dup(ctx, arg); // leak! - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(leak) - @INIT - """) - - -def test_debug_ctx_name(compiler): - # this is very similar to the one in test_00_basic, but: - # 1. by doing the same here, we ensure that we are actually using - # the debug ctx in these tests - # 2. in pypy we run HPyTest with only hpy_abi==universal, so this - # tests something which is NOT tested by test_00_basic - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, ctx->name); - } - - @EXPORT(f) - @INIT - """) - ctx_name = mod.f() - assert ctx_name.startswith('HPy Debug Mode ABI') - -def test_get_open_handles(compiler): - from hpy.universal import _debug - mod = make_leak_module(compiler) - gen1 = _debug.new_generation() - mod.leak('hello') - mod.leak('world') - gen2 = _debug.new_generation() - mod.leak('a younger leak') - leaks1 = _debug.get_open_handles(gen1) - leaks2 = _debug.get_open_handles(gen2) - leaks1 = [dh.obj for dh in leaks1] - leaks2 = [dh.obj for dh in leaks2] - assert leaks1 == ['hello', 'world', 'a younger leak'] - assert leaks2 == ['a younger leak'] - -def test_leak_from_method(compiler): - from hpy.universal import _debug - mod = compiler.make_module(""" - HPyDef_METH(Dummy_leak, "leak", HPyFunc_O) - static HPy Dummy_leak_impl(HPyContext *ctx, HPy self, HPy arg) { - HPy_Dup(ctx, arg); // leak! - return HPy_Dup(ctx, ctx->h_None); - } - static HPyDef *Dummy_defines[] = { - &Dummy_leak, - NULL - }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .defines = Dummy_defines, - }; - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - gen = _debug.new_generation() - obj = mod.Dummy() - obj.leak("a") - leaks = [dh.obj for dh in _debug.get_open_handles(gen)] - assert leaks == ["a"] - -def test_DebugHandle_id(compiler, with_alloc_trace): - from hpy.universal import _debug - mod = make_leak_module(compiler) - gen = _debug.new_generation() - mod.leak('a') - mod.leak('b') - a1, b1 = _debug.get_open_handles(gen) - a2, b2 = _debug.get_open_handles(gen) - assert a1.obj == a2.obj == 'a' - assert b1.obj == b2.obj == 'b' - # - assert a1 is not a2 - assert b1 is not b2 - # - assert a1.id == a2.id - assert b1.id == b2.id - assert a1.id != b1.id - -def test_DebugHandle_compare(compiler): - import pytest - from hpy.universal import _debug - mod = make_leak_module(compiler) - gen = _debug.new_generation() - mod.leak('a') - mod.leak('a') - a2, a1 = _debug.get_open_handles(gen) - assert a1 != a2 # same underlying object, but different DebugHandle - # - a2_new, a1_new = _debug.get_open_handles(gen) - assert a1 is not a1_new # different objects... - assert a2 is not a2_new - assert a1 == a1_new # ...but same DebugHandle - assert a2 == a2_new - # - with pytest.raises(TypeError): - a1 < a2 - with pytest.raises(TypeError): - a1 <= a2 - with pytest.raises(TypeError): - a1 > a2 - with pytest.raises(TypeError): - a1 >= a2 - - assert not a1 == 'hello' - assert a1 != 'hello' - with pytest.raises(TypeError): - a1 < 'hello' - -def test_DebugHandle_repr(compiler, with_alloc_trace): - from hpy.universal import _debug - mod = make_leak_module(compiler) - gen = _debug.new_generation() - mod.leak('hello') - h_hello, = _debug.get_open_handles(gen) - assert repr(h_hello).startswith("" % h_hello.id) - -def test_LeakDetector(compiler): - import pytest - from hpy.debug import LeakDetector, HPyLeakError - mod = make_leak_module(compiler) - ld = LeakDetector() - ld.start() - mod.leak('hello') - with pytest.raises(HPyLeakError) as exc: - ld.stop() - assert str(exc.value).startswith('1 unclosed handle:') - # - with pytest.raises(HPyLeakError) as exc: - with LeakDetector(): - mod.leak('foo') - mod.leak('bar') - mod.leak('baz') - msg = str(exc.value) - assert msg.startswith('3 unclosed handles:') - assert 'foo' in msg - assert 'bar' in msg - assert 'baz' in msg - assert 'hello' not in msg - assert 'world' not in msg - -def test_closed_handles(compiler, with_alloc_trace): - from hpy.universal import _debug - mod = make_leak_module(compiler) - gen = _debug.new_generation() - mod.leak('hello') - h_hello, = _debug.get_open_handles(gen) - assert not h_hello.is_closed - h_hello._force_close() - assert h_hello.is_closed - assert _debug.get_open_handles(gen) == [] - assert h_hello in _debug.get_closed_handles() - assert repr(h_hello).startswith("" % h_hello.id) - -def test_closed_handles_queue_max_size(compiler): - from hpy.universal import _debug - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - old_size = _debug.get_closed_handles_queue_max_size() - try: - # by calling "f" we open and close 3 handles: 1 for self, 1 for arg - # and 1 for the result. So, every call to f() increases the size of - # closed_handles() by 3 - n1 = len(_debug.get_closed_handles()) - _debug.set_closed_handles_queue_max_size(n1+7) - assert _debug.get_closed_handles_queue_max_size() == n1+7 - # - mod.f('aaa') - n2 = len(_debug.get_closed_handles()) - assert n2 == n1+3 - # - mod.f('bbb') - n3 = len(_debug.get_closed_handles()) - assert n3 == n2+3 - # with the next call we reach the maximum size of the queue - mod.f('ccc') - n4 = len(_debug.get_closed_handles()) - assert n4 == n1+7 - # - # same as before - mod.f('ddd') - n5 = len(_debug.get_closed_handles()) - assert n5 == n1+7 - finally: - _debug.set_closed_handles_queue_max_size(old_size) - -def test_reuse_closed_handles(compiler): - from hpy.universal import _debug - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Dup(ctx, ctx->h_None); - } - HPyDef_METH(leak, "leak", HPyFunc_O) - static HPy leak_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_Dup(ctx, arg); // leak! - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @EXPORT(leak) - @INIT - """) - - old_size = _debug.get_closed_handles_queue_max_size() - try: - gen = _debug.new_generation() - # call f twice to open/closes a bunch of handles - mod.f('hello') - mod.f('world') - # - # make sure that the closed_handles queue is considered full: this - # will force the reuse of existing closed handles - _debug.set_closed_handles_queue_max_size(1) - # during the call to leak, we create handles for: - # 1. self - # 2. arg - # 3. HPy_Dup(arg) (leaking) - # 4. result - # So the leaked handle will be 3rd in the old closed_handles queue - closed_handles = _debug.get_closed_handles() - mod.leak('foo') - assert not closed_handles[2].is_closed - assert closed_handles[2].obj == 'foo' - - closed_handles = _debug.get_closed_handles() - mod.leak('bar') - assert not closed_handles[2].is_closed - assert closed_handles[2].obj == 'bar' - - leaks = _debug.get_open_handles(gen) - for h in leaks: - h._force_close() - finally: - _debug.set_closed_handles_queue_max_size(old_size) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_misc.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_misc.py deleted file mode 100644 index f6d7672625..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/debug/test_misc.py +++ /dev/null @@ -1,199 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from hpytest.support import SUPPORTS_SYS_EXECUTABLE, SUPPORTS_MEM_PROTECTION, HPyTest - -pytestmark = pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") - -@pytest.fixture -def hpy_abi(): - return "debug" - - -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_use_invalid_as_struct(compiler, python_subprocess): - mod = compiler.compile_module(""" - typedef struct { - int value; - } DummyObject; - HPyType_HELPERS(DummyObject, HPyType_BuiltinShape_Object) - - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .basicsize = sizeof(DummyObject), - .builtin_shape = HPyType_BuiltinShape_Type - }; - - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - DummyObject *data = DummyObject_AsStruct(ctx, arg); - return HPyLong_FromLong(ctx, data->value); - } - - @EXPORT_TYPE("Dummy", Dummy_spec) - @EXPORT(f) - @INIT - """) - code = "assert mod.f(mod.Dummy()) == 0" - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert "Invalid usage of _HPy_AsStruct_Object" in result.stderr.decode("utf-8") - - -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_typecheck(compiler, python_subprocess): - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); - return HPy_NULL; - } - int res = HPy_TypeCheck(ctx, args[0], args[1]); - return HPyBool_FromLong(ctx, res); - } - @EXPORT(f) - @INIT - """) - code = "assert mod.f(mod.f('hello', 2)) == 0" - result = python_subprocess.run(mod, code) - assert result.returncode != 0 - assert "HPy_TypeCheck arg 2 must be a type" in result.stderr.decode("utf-8") - - -@pytest.mark.skipif(not SUPPORTS_MEM_PROTECTION, reason= - "Could be implemented by checking the contents on close.") -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -@pytest.mark.skipif(not HPyTest.supports_debug_mode(), reason="debug mode not supported") -def test_type_getname(compiler, python_subprocess): - mod = compiler.compile_module(""" - #define MODE_READ_ONLY 0 - #define MODE_USE_AFTER_FREE 1 - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy type; - int mode; - const char *name; - char *buffer; - - // parse arguments - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); - return HPy_NULL; - } - mode = HPyLong_AsLong(ctx, args[0]); - if (mode < 0) { - HPyErr_Clear(ctx); - HPyErr_SetString(ctx, ctx->h_ValueError, "invalid test mode"); - return HPy_NULL; - } - type = mode == 1 ? HPy_Dup(ctx, args[1]) : args[1]; - - name = HPyType_GetName(ctx, type); - if (name == NULL) - return HPy_NULL; - - switch (mode) { - case MODE_READ_ONLY: - // write to read-only memory - buffer = (char *)name; - buffer[0] = 'h'; - break; - case MODE_USE_AFTER_FREE: - // will cause use after handle was closed - HPy_Close(ctx, type); - break; - } - return HPyUnicode_FromString(ctx, name); - } - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f(0, 'hello')") - assert result.returncode != 0 - assert "HPyType_GetName arg must be a type" in result.stderr.decode("utf-8") - - result = python_subprocess.run(mod, "mod.f(0, str)") - assert result.returncode != 0 - - result = python_subprocess.run(mod, "mod.f(1, str)") - assert result.returncode != 0 - - -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_type_issubtype(compiler, python_subprocess): - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); - return HPy_NULL; - } - return HPyLong_FromLong(ctx, HPyType_IsSubtype(ctx, args[0], args[1])); - } - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f(bool, 'hello')") - assert result.returncode != 0 - assert "HPyType_IsSubtype arg 2 must be a type" in result.stderr.decode("utf-8") - - result = python_subprocess.run(mod, "mod.f('hello', str)") - assert result.returncode != 0 - assert "HPyType_IsSubtype arg 1 must be a type" in result.stderr.decode("utf-8") - - -@pytest.mark.skipif(not SUPPORTS_SYS_EXECUTABLE, reason="needs subprocess") -def test_unicode_substring(compiler, python_subprocess): - mod = compiler.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy_ssize_t start, end; - if (nargs != 3) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 3 arguments"); - return HPy_NULL; - } - - start = HPyLong_AsSsize_t(ctx, args[1]); - if (start == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - - end = HPyLong_AsSsize_t(ctx, args[2]); - if (end == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - - return HPyUnicode_Substring(ctx, args[0], start, end); - } - @EXPORT(f) - @INIT - """) - result = python_subprocess.run(mod, "mod.f(b'hello', 2, 3)") - assert result.returncode != 0 - assert "HPyUnicode_Substring arg 1 must be a Unicode object" in result.stderr.decode("utf-8") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_abitag.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_abitag.py deleted file mode 100644 index 1daedcbcfe..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_abitag.py +++ /dev/null @@ -1,48 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from hpy.devel.abitag import parse_ext_suffix, get_hpy_ext_suffix, HPY_ABI_TAG - -def test_parse_ext_suffix_ext(): - _, ext = parse_ext_suffix('.cpython-310-x86_64-linux-gnu.so') - assert ext == 'so' - -def test_parse_ext_suffix_abi_tag(): - def abi_tag(suffix): - tag, ext = parse_ext_suffix(suffix) - return tag - - assert abi_tag('.cpython-38-x86_64-linux-gnu.so') == 'cp38' - assert abi_tag('.cpython-38d-x86_64-linux-gnu.so') == 'cp38d' - assert abi_tag('.cpython-310-x86_64-linux-gnu.so') == 'cp310' - assert abi_tag('.cpython-310d-x86_64-linux-gnu.so') == 'cp310d' - assert abi_tag('.cpython-310-darwin.so') == 'cp310' - assert abi_tag('.cp310-win_amd64.pyd') == 'cp310' - assert abi_tag('.pypy38-pp73-x86_64-linux-gnu.so') == 'pypy38-pp73' - assert abi_tag('.graalpy-38-native-x86_64-darwin.dylib') == 'graalpy-38-native' - -def test_get_hpy_ext_suffix(): - get = get_hpy_ext_suffix - hpy0 = HPY_ABI_TAG - assert get('universal', '.cpython-38-x86_64-linux-gnu.so') == f'.{hpy0}.so' - assert get('hybrid', '.cpython-38-x86_64-linux-gnu.so') == f'.{hpy0}-cp38.so' diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_distutils.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_distutils.py deleted file mode 100644 index 3d87a7d977..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/hpy_devel/test_distutils.py +++ /dev/null @@ -1,386 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -Test the hpy+distutils integration. Most of the relevant code is in -hpy/devel/__init__.py. - -Note that this is a different kind of test than the majority of the other -files in this directory, which all inherit from HPyTest and test the API -itself. -""" - -import sys -import os -import textwrap -import subprocess -import shutil -import venv -import py -import pytest - -from hpytest.support import atomic_run, HPY_ROOT - -pytestmark = pytest.mark.skip("not supported on GraalPy because of legacy distutils") - -# ====== IMPORTANT DEVELOPMENT TIP ===== -# You can use py.test --reuse-venv to speed up local testing. -# -# The env is created once in /tmp/venv-for-hpytest and reused among tests and -# sessions. If you want to recreate it, simply rm -r /tmp/venv-for-hpytest - -def print_CalledProcessError(p): - """ - Print all information about a CalledProcessError - """ - print('========== subprocess failed ==========') - print('command:', ' '.join(p.cmd)) - print('argv: ', p.cmd) - print('return code:', p.returncode) - print() - print('---------- ----------') - print(p.stdout.decode('latin-1')) - print('---------- ---------') - print() - print('---------- ----------') - print(p.stderr.decode('latin-1')) - print('---------- ---------') - -@pytest.fixture(scope='session') -def venv_template(request, tmpdir_factory): - if request.config.option.reuse_venv: - d = py.path.local('/tmp/venv-for-hpytest') - if d.check(dir=True): - # if it exists, we assume it's correct. If you want to recreate, - # just manually delete /tmp/venv-for-hpytest - return d - else: - d = tmpdir_factory.mktemp('venv') - - venv.create(d, with_pip=True) - - # remove the scripts: they contains a shebang and it will fail subtly - # after we clone the template. Yes, we could try to fix the shebangs, but - # it's just easier to use e.g. python -m pip - attach_python_to_venv(d) - for script in d.bin.listdir(): - if script.basename.startswith('python'): - continue - script.remove() - # - try: - atomic_run( - [str(d.python), '-m', 'pip', 'install', '-U', 'pip', 'wheel', 'setuptools'], - check=True, - capture_output=True, - ) - atomic_run( - [str(d.python), '-m', 'pip', 'install', str(HPY_ROOT)], - check=True, - capture_output=True, - ) - except subprocess.CalledProcessError as cpe: - print_CalledProcessError(cpe) - raise - return d - -def attach_python_to_venv(d): - if os.name == 'nt': - d.bin = d.join('Scripts') - else: - d.bin = d.join('bin') - d.python = d.bin.join('python') - - -@pytest.mark.usefixtures('initargs') -class TestDistutils: - - @pytest.fixture() - def initargs(self, pytestconfig, tmpdir, venv_template): - self.tmpdir = tmpdir - # create a fresh venv by copying the template - self.venv = tmpdir.join('venv') - shutil.copytree(venv_template, self.venv) - attach_python_to_venv(self.venv) - # create the files for our test project - self.hpy_test_project = tmpdir.join('hpy_test_project').ensure(dir=True) - self.gen_project() - self.hpy_test_project.chdir() - - @pytest.fixture(params=['cpython', 'hybrid', 'universal']) - def hpy_abi(self, request): - return request.param - - def python(self, *args, capture=False): - """ - Run python inside the venv; if capture==True, return stdout - """ - cmd = [str(self.venv.python)] + list(args) - print('[RUN]', ' '.join(cmd)) - if capture: - proc = atomic_run(cmd, capture_output=True) - out = proc.stdout.decode('latin-1').strip() - else: - proc = atomic_run(cmd) - out = None - proc.check_returncode() - return out - - - def writefile(self, fname, content): - """ - Write a file inside hpy_test_project - """ - f = self.hpy_test_project.join(fname) - content = textwrap.dedent(content) - f.write(content) - - def gen_project(self): - """ - Generate the files needed to build the project, except setup.py - """ - self.writefile('cpymod.c', """ - // the simplest possible Python/C module - #include - static PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "cpymod", - "cpymod docstring" - }; - - PyMODINIT_FUNC - PyInit_cpymod(void) - { - return PyModule_Create(&moduledef); - } - """) - - self.writefile('hpymod.c', """ - // the simplest possible HPy module - #include - static HPyModuleDef moduledef = { - .doc = "hpymod with HPy ABI: " HPY_ABI, - }; - - HPy_MODINIT(hpymod, moduledef) - """) - - self.writefile('hpymod_legacy.c', """ - // the simplest possible HPy+legacy module - #include - #include - - static PyObject *f(PyObject *self, PyObject *args) - { - return PyLong_FromLong(1234); - } - static PyMethodDef my_legacy_methods[] = { - {"f", (PyCFunction)f, METH_NOARGS}, - {NULL} - }; - - static HPyModuleDef moduledef = { - .doc = "hpymod_legacy with HPy ABI: " HPY_ABI, - .legacy_methods = my_legacy_methods, - }; - - HPy_MODINIT(hpymod_legacy, moduledef) - """) - - def gen_setup_py(self, src): - preamble = textwrap.dedent(""" - from setuptools import setup, Extension - cpymod = Extension("cpymod", ["cpymod.c"]) - hpymod = Extension("hpymod", ["hpymod.c"]) - hpymod_legacy = Extension("hpymod_legacy", ["hpymod_legacy.c"]) - """) - src = preamble + textwrap.dedent(src) - f = self.hpy_test_project.join('setup.py') - f.write(src) - - def get_docstring(self, modname): - cmd = f'import {modname}; print({modname}.__doc__)' - return self.python('-c', cmd, capture=True) - - def test_cpymod_setup_install(self): - # CPython-only project, no hpy at all. This is a baseline to check - # that everything works even without hpy. - self.gen_setup_py(""" - setup(name = "hpy_test_project", - ext_modules = [cpymod], - ) - """) - self.python('setup.py', 'install') - doc = self.get_docstring('cpymod') - assert doc == 'cpymod docstring' - - def test_cpymod_with_empty_hpy_ext_modules_setup_install(self): - # if we have hpy_ext_modules=[] we trigger the hpy.devel monkey - # patch. This checks that we don't ext_modules still works after that. - self.gen_setup_py(""" - setup(name = "hpy_test_project", - ext_modules = [cpymod], - hpy_ext_modules = [] - ) - """) - self.python('setup.py', 'install') - doc = self.get_docstring('cpymod') - assert doc == 'cpymod docstring' - - def test_hpymod_py_stub(self): - # check that that we generated the .py stub for universal - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - ) - """) - self.python('setup.py', '--hpy-abi=universal', 'build') - build = self.hpy_test_project.join('build') - lib = build.listdir('lib*')[0] - hpymod_py = lib.join('hpymod.py') - assert hpymod_py.check(exists=True) - assert 'This file is automatically generated by hpy' in hpymod_py.read() - - def test_hpymod_build_platlib(self): - # check that if we have only hpy_ext_modules, the distribution is - # detected as "platform-specific" and not "platform-neutral". In - # particular, we want the end result to be in - # e.g. build/lib.linux-x86_64-3.8 and NOT in build/lib. - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - ) - """) - self.python('setup.py', 'build') - build = self.hpy_test_project.join('build') - libs = build.listdir('lib*') - assert len(libs) == 1 - libdir = libs[0] - # this is something like lib.linux-x86_64-cpython-38 - assert libdir.basename != 'lib' - - def test_hpymod_build_ext_inplace(self, hpy_abi): - # check that we can install hpy modules with setup.py build_ext -i - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - ) - """) - self.python('setup.py', f'--hpy-abi={hpy_abi}', 'build_ext', '--inplace') - doc = self.get_docstring('hpymod') - assert doc == f'hpymod with HPy ABI: {hpy_abi}' - - def test_hpymod_setup_install(self, hpy_abi): - # check that we can install hpy modules with setup.py install - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - ) - """) - self.python('setup.py', f'--hpy-abi={hpy_abi}', 'install') - doc = self.get_docstring('hpymod') - assert doc == f'hpymod with HPy ABI: {hpy_abi}' - - def test_hpymod_wheel(self, hpy_abi): - # check that we can build and install wheels - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - ) - """) - self.python('setup.py', f'--hpy-abi={hpy_abi}', 'bdist_wheel') - dist = self.hpy_test_project.join('dist') - whl = dist.listdir('*.whl')[0] - self.python('-m', 'pip', 'install', str(whl)) - doc = self.get_docstring('hpymod') - assert doc == f'hpymod with HPy ABI: {hpy_abi}' - - def test_dont_mix_cpython_and_universal_abis(self): - """ - See issue #322 - """ - # make sure that the build dirs for cpython and universal ABIs are - # distinct - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - install_requires = [], - ) - """) - self.python('setup.py', 'install') - # in the build/ dir, we should have 2 directories: temp and lib - build = self.hpy_test_project.join('build') - temps = build.listdir('temp*') - libs = build.listdir('lib*') - assert len(temps) == 1 - assert len(libs) == 1 - # - doc = self.get_docstring('hpymod') - assert doc == 'hpymod with HPy ABI: cpython' - - # now recompile with universal *without* cleaning the build - self.python('setup.py', '--hpy-abi=universal', 'install') - # in the build/ dir, we should have 4 directories: 2 temp*, and 2 lib* - build = self.hpy_test_project.join('build') - temps = build.listdir('temp*') - libs = build.listdir('lib*') - assert len(temps) == 2 - assert len(libs) == 2 - # - doc = self.get_docstring('hpymod') - assert doc == 'hpymod with HPy ABI: universal' - - def test_hpymod_legacy(self, hpy_abi): - if hpy_abi == 'universal': - pytest.skip('only for cpython and hybrid ABIs') - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod_legacy], - install_requires = [], - ) - """) - self.python('setup.py', 'install') - src = 'import hpymod_legacy; print(hpymod_legacy.f())' - out = self.python('-c', src, capture=True) - assert out == '1234' - - def test_hpymod_legacy_fails_with_universal(self): - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod_legacy], - install_requires = [], - ) - """) - with pytest.raises(subprocess.CalledProcessError) as exc: - self.python('setup.py', '--hpy-abi=universal', 'install', capture=True) - expected_msg = ("It is forbidden to #include when " - "targeting the HPy Universal ABI") - - # gcc/clang prints the #error on stderr, MSVC prints it on - # stdout. Here we check that the error is printed "somewhere", we - # don't care exactly where. - out = exc.value.stdout + b'\n' + exc.value.stderr - out = out.decode('latin-1') - if expected_msg not in out: - print_CalledProcessError(exc.value) - assert expected_msg in out diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/support.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/support.py deleted file mode 100644 index 7711a08c31..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/support.py +++ /dev/null @@ -1,651 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2024, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import os, sys -from filelock import FileLock -import pytest -from pathlib import Path -import re -import subprocess -import textwrap -import distutils - -PY2 = sys.version_info[0] == 2 -GRAALPYTHON = sys.implementation.name == 'graalpy' -DARWIN_NATIVE = sys.platform == 'darwin' - -HPY_ROOT = Path(__file__).parent.parent -LOCK = FileLock(HPY_ROOT / ".hpy.lock") - -# True if `sys.executable` is set to a value that allows a Python equivalent to -# the current Python to be launched via, e.g., `python_subprocess.run(...)`. -# By default is `True` if sys.executable is set to a true value. -SUPPORTS_SYS_EXECUTABLE = bool(getattr(sys, "executable", None)) -# True if we are running on the CPython debug build -IS_PYTHON_DEBUG_BUILD = hasattr(sys, 'gettotalrefcount') - -# pytest marker to run tests only on linux -ONLY_LINUX = pytest.mark.skipif(sys.platform!='linux', reason='linux only') - -SUPPORTS_MEM_PROTECTION = '_HPY_DEBUG_FORCE_DEFAULT_MEM_PROTECT' not in os.environ - -def reindent(s, indent): - s = textwrap.dedent(s) - return ''.join(' '*indent + line if line.strip() else line - for line in s.splitlines(True)) - -def atomic_run(*args, **kwargs): - with LOCK: - return subprocess.run(*args, **kwargs) - - -def make_hpy_abi_fixture(ABIs, class_fixture=False): - """ - Make an hpy_abi fixture. - - conftest.py defines a default hpy_abi for all tests, but individual files - and classes can override the set of ABIs they want to use. The indented - usage is the following: - - # at the top of a file - hpy_abi = make_hpy_abi_fixture(['universal', 'debug']) - - # in a class - class TestFoo(HPyTest): - hpy_abi = make_hpy_abi_fixture('with hybrid', class_fixture=True) - """ - if ABIs == 'default': - ABIs = ['cpython', 'universal', 'debug'] - elif ABIs == 'with hybrid': - ABIs = ['cpython', 'hybrid', 'hybrid+debug'] - elif isinstance(ABIs, list): - pass - else: - raise ValueError("ABIs must be 'default', 'with hybrid' " - "or a list of strings. Got: %s" % ABIs) - - # GraalPy only supports the debug mode if running native - if not GRAALPYTHON: - if 'debug' in ABIs: - ABIs.remove('debug') - elif 'hybrid+debug' in ABIs: - ABIs.remove('hybrid+debug') - - if class_fixture: - @pytest.fixture(params=ABIs) - def hpy_abi(self, request): - abi = request.param - yield abi - else: - @pytest.fixture(params=ABIs) - def hpy_abi(request): - abi = request.param - yield abi - - return hpy_abi - - -class DefaultExtensionTemplate(object): - - INIT_TEMPLATE = textwrap.dedent( - """ - static HPyDef *moduledefs[] = { - %(defines)s - NULL - }; - %(globals_defs)s - static HPyModuleDef moduledef = { - .doc = "some test for hpy", - .size = 0, - .legacy_methods = %(legacy_methods)s, - .defines = moduledefs, - %(globals_field)s - }; - - HPy_MODINIT(%(name)s, moduledef) - """) - - INIT_TEMPLATE_WITH_TYPES_INIT = textwrap.dedent( - """ - HPyDef_SLOT(generated_init, HPy_mod_exec) - static int generated_init_impl(HPyContext *ctx, HPy m) - { - // Shouldn't really happen, but jut to silence the unused label warning - if (HPy_IsNull(m)) - goto MODINIT_ERROR; - - %(init_types)s - return 0; - - MODINIT_ERROR: - return -1; - } - """ + INIT_TEMPLATE) - - r_marker = re.compile(r"^\s*@([A-Za-z_]+)(\(.*\))?$") - - def __init__(self, src, name): - self.src = textwrap.dedent(src) - self.name = name - self.defines_table = None - self.legacy_methods = 'NULL' - self.type_table = None - self.globals_table = None - - def expand(self): - self.defines_table = [] - self.globals_table = [] - self.type_table = [] - self.output = ['#include '] - for line in self.src.split('\n'): - match = self.r_marker.match(line) - if match: - name, args = self.parse_marker(match) - meth = getattr(self, name) - out = meth(*args) - if out is not None: - out = textwrap.dedent(out) - self.output.append(out) - else: - self.output.append(line) - return '\n'.join(self.output) - - def parse_marker(self, match): - name = match.group(1) - args = match.group(2) - if args is None: - args = () - else: - assert args[0] == '(' - assert args[-1] == ')' - args = args[1:-1].split(',') - args = [x.strip() for x in args] - return name, args - - def INIT(self): - NL_INDENT = '\n ' - if self.type_table: - init_types = '\n'.join(self.type_table) - else: - init_types = '' - - globals_defs = '' - globals_field = '' - if self.globals_table: - globals_defs = \ - textwrap.dedent(''' - static HPyGlobal *module_globals[] = { - %s - NULL - };''') % NL_INDENT.join(self.globals_table) - globals_field = '.globals = module_globals' - - template = self.INIT_TEMPLATE - if init_types: - template = self.INIT_TEMPLATE_WITH_TYPES_INIT - self.EXPORT('generated_init') - exp = template % { - 'legacy_methods': self.legacy_methods, - 'defines': NL_INDENT.join(self.defines_table), - 'init_types': init_types, - 'name': self.name, - 'globals_defs': globals_defs, - 'globals_field': globals_field} - self.output.append(exp) - # make sure that we don't fill the tables any more - self.defines_table = None - self.type_table = None - - def EXPORT(self, meth): - self.defines_table.append('&%s,' % meth) - - def EXPORT_GLOBAL(self, var): - self.globals_table.append('&%s,' % var) - - def EXPORT_LEGACY(self, pymethoddef): - self.legacy_methods = pymethoddef - - def EXPORT_TYPE(self, name, spec): - src = """ - if (!HPyHelpers_AddType(ctx, m, {name}, &{spec}, NULL)) {{ - goto MODINIT_ERROR; - }} - """ - src = reindent(src, 4) - self.type_table.append(src.format( - name=name, - spec=spec)) - - def EXTRA_INIT_FUNC(self, func): - src = """ - {func}(ctx, m); - if (HPyErr_Occurred(ctx)) - goto MODINIT_ERROR; - """ - src = reindent(src, 4) - self.type_table.append(src.format(func=func)) - - def HPy_MODINIT(self, mod): - return "HPy_MODINIT({}, {})".format(self.name, mod) - - -class Spec(object): - def __init__(self, name, origin): - self.name = name - self.origin = origin - - -class HPyModule(object): - def __init__(self, name, so_file): - self.name = name - self.so_filename = so_file - - -class ExtensionCompiler: - def __init__(self, tmpdir, hpy_devel, hpy_abi, compiler_verbose=False, - dump_dir=None, - ExtensionTemplate=DefaultExtensionTemplate, - extra_include_dirs=None): - """ - hpy_devel is an instance of HPyDevel which specifies where to find - include/, runtime/src, etc. Usually it will point to hpy/devel/, but - alternate implementations can point to their own place (e.g. pypy puts - it into pypy/module/_hpy_universal/_vendored) - - extra_include_dirs is a list of include dirs which is put BEFORE all - others. By default it is empty, but it is used e.g. by PyPy to make - sure that #include picks its own version, instead of the - system-wide one. - """ - self.tmpdir = tmpdir - self.dump_dir = dump_dir - self.hpy_devel = hpy_devel - self.hpy_abi = hpy_abi - self.compiler_verbose = compiler_verbose - self.ExtensionTemplate = ExtensionTemplate - self.extra_include_dirs = extra_include_dirs - self._sysconfig_universal = None - - def _expand(self, ExtensionTemplate, name, template): - source = ExtensionTemplate(template, name).expand() - filename = self.tmpdir.join(name + '.c') - dump_file = self.dump_dir.joinpath(name + '.c') if self.dump_dir else None - if PY2: - # this code is used also by pypy tests, which run on python2. In - # this case, we need to write as binary, because source is - # "bytes". If we don't and source contains a non-ascii char, we - # get an UnicodeDecodeError - if dump_file: - dump_file.write_text(source) - filename.write(source, mode='wb') - else: - if dump_file: - dump_file.write_text(source) - filename.write(source) - return name + '.c' - - def _fixup_template(self, ExtensionTemplate): - return self.ExtensionTemplate if ExtensionTemplate is None else ExtensionTemplate - - def compile_module(self, main_src, ExtensionTemplate=None, name='mytest', extra_sources=()): - """ - Create and compile a HPy module from the template - """ - ExtensionTemplate = self._fixup_template(ExtensionTemplate) - from distutils.core import Extension - filename = self._expand(ExtensionTemplate, name, main_src) - sources = [str(filename)] - for i, src in enumerate(extra_sources): - extra_filename = self._expand(ExtensionTemplate, 'extmod_%d' % i, src) - sources.append(extra_filename) - # - if self.dump_dir: - pytest.skip("dumping test sources only") - if sys.platform == 'win32': - # not strictly true, could be mingw - compile_args = [ - '/Od', - '/WX', # turn warnings into errors (all, for now) - # '/Wall', # this is too aggressive, makes windows itself fail - '/Zi', - '-D_CRT_SECURE_NO_WARNINGS', # something about _snprintf and _snprintf_s - '/FS', # Since the tests run in parallel - ] - link_args = [ - '/DEBUG', - '/LTCG', - ] - else: - compile_args = [ - '-g', # TRUFFLE CHANGE: we removed '-O0' for mem2reg opt - '-Wno-gnu-variable-sized-type-not-at-end', - '-Wfatal-errors', # stop after one error (unrelated to warnings) - '-Werror', # turn warnings into errors (all, for now) - ] - link_args = [ - '-g', - ] - # - ext = Extension( - name, - sources=sources, - include_dirs=self.extra_include_dirs, - extra_compile_args=compile_args, - extra_link_args=link_args) - - hpy_abi = self.hpy_abi - if hpy_abi == 'debug' or hpy_abi == 'trace': - # there is no compile-time difference between universal and debug - # extensions. The only difference happens at load time - hpy_abi = 'universal' - elif hpy_abi in ('hybrid+debug', 'hybrid+trace'): - hpy_abi = 'hybrid' - so_filename = c_compile(str(self.tmpdir), ext, - hpy_devel=self.hpy_devel, - hpy_abi=hpy_abi, - compiler_verbose=self.compiler_verbose) - return HPyModule(name, so_filename) - - def make_module(self, main_src, ExtensionTemplate=None, name='mytest', - extra_sources=()): - """ - Compile & load a module. This is NOT a proper import: e.g. - the module is not put into sys.modules. - - We don't want to unnecessarily modify the global state inside tests: - if you are writing a test which needs a proper import, you should not - use make_module but explicitly use compile_module and import it - manually as required by your test. - """ - ExtensionTemplate = self._fixup_template(ExtensionTemplate) - module = self.compile_module( - main_src, ExtensionTemplate, name, extra_sources) - so_filename = module.so_filename - from hpy.universal import MODE_UNIVERSAL, MODE_DEBUG, MODE_TRACE - if self.hpy_abi in ('universal', 'hybrid'): - return self.load_universal_module(name, so_filename, mode=MODE_UNIVERSAL) - elif self.hpy_abi in ('debug', 'hybrid+debug'): - return self.load_universal_module(name, so_filename, mode=MODE_DEBUG) - elif self.hpy_abi in ('trace', 'hybrid+trace'): - return self.load_universal_module(name, so_filename, mode=MODE_TRACE) - elif self.hpy_abi == 'cpython': - return self.load_cpython_module(name, so_filename) - else: - assert False - - def load_universal_module(self, name, so_filename, mode): - assert self.hpy_abi in ('universal', 'hybrid', 'debug', 'hybrid+debug', - 'trace', 'hybrid+trace') - import sys - import hpy.universal - import importlib.util - assert name not in sys.modules - spec = importlib.util.spec_from_file_location(name, so_filename) - mod = hpy.universal.load(name, so_filename, spec, mode=mode) - mod.__file__ = so_filename - mod.__spec__ = spec - return mod - - def load_cpython_module(self, name, so_filename): - assert self.hpy_abi == 'cpython' - # we've got a normal CPython module compiled with the CPython API/ABI, - # let's load it normally. It is important to do the imports only here, - # because this file will be imported also by PyPy tests which runs on - # Python2 - import importlib.util - import sys - assert name not in sys.modules - spec = importlib.util.spec_from_file_location(name, so_filename) - try: - # module_from_spec adds the module to sys.modules - module = importlib.util.module_from_spec(spec) - finally: - if name in sys.modules: - del sys.modules[name] - spec.loader.exec_module(module) - return module - - -class PythonSubprocessRunner: - def __init__(self, verbose, hpy_abi): - self.verbose = verbose - self.hpy_abi = hpy_abi - - def run(self, mod, code): - """ Starts new subprocess that loads given module as 'mod' using the - correct ABI mode and then executes given code snippet. Use - "--subprocess-v" to enable logging from this. - """ - env = os.environ.copy() - pythonpath = [os.path.dirname(mod.so_filename)] - if 'PYTHONPATH' in env: - pythonpath.append(env['PYTHONPATH']) - env["PYTHONPATH"] = os.pathsep.join(pythonpath) - if self.hpy_abi in ['universal', 'debug']: - # HPy module - load_module = "import sys;" + \ - "import hpy.universal;" + \ - "import importlib.util;" + \ - "spec = importlib.util.spec_from_file_location('{name}', '{so_filename}');" + \ - "mod = hpy.universal.load('{name}', '{so_filename}', spec, debug={debug});" - escaped_filename = mod.so_filename.replace("\\", "\\\\") # Needed for Windows paths - load_module = load_module.format(name=mod.name, so_filename=escaped_filename, - debug=self.hpy_abi == 'debug') - else: - # CPython module - assert self.hpy_abi == 'cpython' - load_module = "import {} as mod;".format(mod.name) - if self.verbose: - print("\n---\nExecuting in subprocess: {}".format(load_module + code)) - result = atomic_run([sys.executable, "-c", load_module + code], env=env, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - if self.verbose: - print("stdout/stderr:") - try: - out = result.stdout.decode('latin-1') - err = result.stderr.decode('latin-1') - print("----\n{out}--\n{err}-----".format(out=out, err=err)) - except UnicodeDecodeError: - print("Warning: stdout or stderr could not be decoded with 'latin-1' encoding") - return result - - -@pytest.mark.usefixtures('initargs') -class HPyTest: - ExtensionTemplate = DefaultExtensionTemplate - - @pytest.fixture() - def initargs(self, compiler, leakdetector, capfd): - self.compiler = compiler - self.leakdetector = leakdetector - self.capfd = capfd - - def make_module(self, main_src, name='mytest', extra_sources=()): - ExtensionTemplate = self.ExtensionTemplate - return self.compiler.make_module(main_src, ExtensionTemplate, name, - extra_sources) - - def compile_module(self, main_src, name='mytest', extra_sources=()): - ExtensionTemplate = self.ExtensionTemplate - return self.compiler.compile_module(main_src, ExtensionTemplate, name, - extra_sources) - - def expect_make_error(self, main_src, error): - with pytest.raises(distutils.errors.CompileError): - self.make_module(main_src) - # - # capfd.readouterr() "eats" the output, but we want to still see it in - # case of failure. Just print it again - cap = self.capfd.readouterr() - sys.stdout.write(cap.out) - sys.stderr.write(cap.err) - # - # gcc prints compiler errors to stderr, but MSVC seems to print them - # to stdout. Let's just check both - if error in cap.out or error in cap.err: - # the error was found, we are good - return - raise Exception("The following error message was not found in the compiler " - "output:\n " + error) - - - def supports_refcounts(self): - """ Returns True if the underlying Python implementation supports - reference counts. - - By default, returns True on CPython and False on other - implementations. - """ - return sys.implementation.name == "cpython" - - def supports_ordinary_make_module_imports(self): - """ Returns True if `.make_module(...)` loads modules using a - standard Python import mechanism (e.g. `importlib.import_module`). - - By default, returns True because the base implementation of - `.make_module(...)` uses an ordinary import. Sub-classes that - override `.make_module(...)` may also want to override this - method. - """ - return True - - @staticmethod - def supports_debug_mode(): - """ Returns True if the underlying Python implementation supports - the debug mode. - """ - from hpy.universal import _debug - try: - return _debug.get_open_handles() is not None - except: - return False - - @staticmethod - def supports_trace_mode(): - """ Returns True if the underlying Python implementation supports - the trace mode. - """ - from hpy.universal import _trace - try: - return _trace.get_call_counts() is not None - except: - return False - - -class HPyDebugCapture: - """ - Context manager that sets HPy debug invalid handle hook and remembers the - number of invalid handles reported. Once closed, sets the invalid handle - hook back to None. - """ - def __init__(self): - self.invalid_handles_count = 0 - self.invalid_builders_count = 0 - - def _capture_report(self): - self.invalid_handles_count += 1 - - def _capture_builder_report(self): - self.invalid_builders_count += 1 - - def __enter__(self): - from hpy.universal import _debug - _debug.set_on_invalid_handle(self._capture_report) - _debug.set_on_invalid_builder_handle(self._capture_builder_report) - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - from hpy.universal import _debug - _debug.set_on_invalid_handle(None) - _debug.set_on_invalid_builder_handle(None) - - -# the few functions below are copied and adapted from cffi/ffiplatform.py - -def c_compile(tmpdir, ext, hpy_devel, hpy_abi, compiler_verbose=0, debug=None): - """Compile a C extension module using distutils.""" - saved_environ = os.environ.copy() - try: - outputfilename = _build(tmpdir, ext, hpy_devel, hpy_abi, compiler_verbose, debug) - outputfilename = os.path.abspath(outputfilename) - finally: - # workaround for a distutils bugs where some env vars can - # become longer and longer every time it is used - for key, value in saved_environ.items(): - if os.environ.get(key) != value: - os.environ[key] = value - return outputfilename - - -def _build(tmpdir, ext, hpy_devel, hpy_abi, compiler_verbose=0, debug=None): - # XXX compact but horrible :-( - from distutils.core import Distribution - import distutils.errors - import distutils.log - # - dist = Distribution() - dist.parse_config_files() - if debug is None: - debug = sys.flags.debug - options_build_ext = dist.get_option_dict('build_ext') - options_build_ext['debug'] = ('ffiplatform', debug) - options_build_ext['force'] = ('ffiplatform', True) - options_build_ext['build_lib'] = ('ffiplatform', tmpdir) - options_build_ext['build_temp'] = ('ffiplatform', tmpdir) - options_build_py = dist.get_option_dict('build_py') - options_build_py['build_lib'] = ('ffiplatform', tmpdir) - - # this is the equivalent of passing --hpy-abi from setup.py's command line - dist.hpy_abi = hpy_abi - # For testing, we want to use static libs to avoid repeated compilation - # of the same sources which slows down testing. - dist.hpy_use_static_libs = False - dist.hpy_ext_modules = [ext] - # We need to explicitly specify which Python modules we expect because some - # test cases create several distributions in the same temp directory. - dist.py_modules = [ext.name] - hpy_devel.fix_distribution(dist) - - old_level = distutils.log.set_threshold(0) or 0 - old_dir = os.getcwd() - try: - os.chdir(tmpdir) - distutils.log.set_verbosity(compiler_verbose) - dist.run_command('build_ext') - cmd_obj = dist.get_command_obj('build_ext') - outputs = cmd_obj.get_outputs() - sonames = [x for x in outputs if - not x.endswith(".py") and not x.endswith(".pyc")] - assert len(sonames) == 1, 'build_ext is not supposed to return multiple DLLs' - soname = sonames[0] - finally: - os.chdir(old_dir) - distutils.log.set_threshold(old_level) - - return soname - - -# For situations when one wants to have "support.py" on the call stack. -# For example, for asserting that it is in a stack trace. -def trampoline(fun, *args, **kwargs): - fun(*args, **kwargs) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_00_basic.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_00_basic.py deleted file mode 100644 index f3ac32a6b4..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_00_basic.py +++ /dev/null @@ -1,585 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest -from hpy.devel.abitag import HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR -import shutil - - -class TestBasic(HPyTest): - - def test_get_version(self): - if self.compiler.hpy_abi != 'universal': - return - import hpy.universal - version, gitrev = hpy.universal.get_version() - # it's a bit hard to test the CONTENT of these values. Let's just - # check that they are strings... - assert isinstance(version, str) - assert isinstance(gitrev, str) - - def test_empty_module(self): - import sys - mod = self.make_module(""" - @INIT - """) - assert type(mod) is type(sys) - - def test_abi_version_check(self): - if self.compiler.hpy_abi != 'universal': - return - try: - self.make_module(""" - // hack: we redefine the version - #undef HPY_ABI_VERSION - #define HPY_ABI_VERSION 999 - @INIT - """) - except RuntimeError as ex: - assert str(ex) == "HPy extension module 'mytest' requires unsupported " \ - "version of the HPy runtime. Requested version: 999.0. " \ - "Current HPy version: {}.{}.".format(HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR) - else: - assert False, "Expected exception" - - def test_abi_tag_check(self): - if self.compiler.hpy_abi != 'universal': - return - - from hpy.universal import MODE_UNIVERSAL - def assert_load_raises(filename, message): - try: - self.compiler.load_universal_module('mytest', filename, mode=MODE_UNIVERSAL) - except RuntimeError as ex: - assert str(ex) == message - else: - assert False, "Expected exception" - - module = self.compile_module("@INIT") - filename = module.so_filename - hpy_tag = ".hpy{}".format(HPY_ABI_VERSION) - - filename_wrong_tag = filename.replace(hpy_tag, ".hpy999") - shutil.move(filename, filename_wrong_tag) - assert_load_raises(filename_wrong_tag, - "HPy extension module 'mytest' at path '{}': mismatch " - "between the HPy ABI tag encoded in the filename and " - "the major version requested by the HPy extension itself. " - "Major version tag parsed from filename: 999. " - "Requested version: {}.{}.".format(filename_wrong_tag, HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR)) - - filename_no_tag = filename.replace(hpy_tag, "") - shutil.move(filename_wrong_tag, filename_no_tag) - assert_load_raises(filename_no_tag, - "HPy extension module 'mytest' at path '{}': " - "could not find HPy ABI tag encoded in the filename. " - "The extension claims to be compiled with HPy ABI version: " - "{}.{}.".format(filename_no_tag, HPY_ABI_VERSION, HPY_ABI_VERSION_MINOR)) - - def test_different_name(self): - mod = self.make_module(""" - @INIT - """, name="foo") - assert mod.__name__ == "foo" - - def test_noop_function(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS, .doc="hello world") - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @INIT - """) - assert mod.f() is None - assert mod.f.__doc__ == 'hello world' - - def test_self_is_module(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPy_Dup(ctx, self); - } - @EXPORT(f) - @INIT - """) - assert mod.f() is mod - - def test_identity_function(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Dup(ctx, arg); - } - @EXPORT(f) - @INIT - """) - x = object() - assert mod.f(x) is x - - def test_float_asdouble(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - double a = HPyFloat_AsDouble(ctx, arg); - return HPyFloat_FromDouble(ctx, a * 2.); - } - @EXPORT(f) - @INIT - """) - assert mod.f(1.) == 2. - - def test_wrong_number_of_arguments(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f_noargs, "f_noargs", HPyFunc_NOARGS) - static HPy f_noargs_impl(HPyContext *ctx, HPy self) - { - return HPy_Dup(ctx, ctx->h_None); - } - HPyDef_METH(f_o, "f_o", HPyFunc_O) - static HPy f_o_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f_noargs) - @EXPORT(f_o) - @INIT - """) - with pytest.raises(TypeError): - mod.f_noargs(1) - with pytest.raises(TypeError): - mod.f_o() - with pytest.raises(TypeError): - mod.f_o(1, 2) - - def test_close(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy one = HPyLong_FromLong(ctx, 1); - if (HPy_IsNull(one)) - return HPy_NULL; - HPy res = HPy_Add(ctx, arg, one); - HPy_Close(ctx, one); - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f(41.5) == 42.5 - - def test_bool(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int cond = HPyLong_AsLong(ctx, arg) > 5; - return HPy_Dup(ctx, cond ? ctx->h_True : ctx->h_False); - } - @EXPORT(f) - @INIT - """) - assert mod.f(4) is False - assert mod.f(6) is True - - def test_exception(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - long x = HPyLong_AsLong(ctx, arg); - if (x < 5) { - return HPyLong_FromLong(ctx, -x); - } - else { - HPyErr_SetString(ctx, ctx->h_ValueError, "hello world"); - return HPy_NULL; - } - } - @EXPORT(f) - @INIT - """) - assert mod.f(-10) == 10 - with pytest.raises(ValueError) as exc: - mod.f(20) - assert str(exc.value) == 'hello world' - - def test_varargs(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - long a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) - return HPy_NULL; - return HPyLong_FromLong(ctx, 10*a + b); - } - @EXPORT(f) - @INIT - """) - assert mod.f(4, 5) == 45 - - def test_builtin_handles(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - long i = HPyLong_AsLong(ctx, arg); - HPy h; - switch(i) { - case 1: h = ctx->h_None; break; - case 2: h = ctx->h_False; break; - case 3: h = ctx->h_True; break; - case 4: h = ctx->h_ValueError; break; - case 5: h = ctx->h_TypeError; break; - case 6: h = ctx->h_IndexError; break; - case 7: h = ctx->h_SystemError; break; - case 8: h = ctx->h_BaseObjectType; break; - case 9: h = ctx->h_TypeType; break; - case 10: h = ctx->h_BoolType; break; - case 11: h = ctx->h_LongType; break; - case 12: h = ctx->h_FloatType; break; - case 13: h = ctx->h_UnicodeType; break; - case 14: h = ctx->h_TupleType; break; - case 15: h = ctx->h_ListType; break; - case 16: h = ctx->h_NotImplemented; break; - case 17: h = ctx->h_Ellipsis; break; - case 18: h = ctx->h_ComplexType; break; - case 19: h = ctx->h_BytesType; break; - case 20: h = ctx->h_MemoryViewType; break; - case 21: h = ctx->h_SliceType; break; - case 22: h = ctx->h_Builtins; break; - case 2048: h = ctx->h_CapsuleType; break; - default: - HPyErr_SetString(ctx, ctx->h_ValueError, "invalid choice"); - return HPy_NULL; - } - return HPy_Dup(ctx, h); - } - @EXPORT(f) - @INIT - """) - import builtins - - builtin_objs = ( - '', None, False, True, ValueError, TypeError, IndexError, - SystemError, object, type, bool, int, float, str, tuple, list, - NotImplemented, Ellipsis, complex, bytes, memoryview, slice, - builtins.__dict__ - ) - for i, obj in enumerate(builtin_objs): - if i == 0: - continue - assert mod.f(i) is obj - - # we cannot be sure if 'datetime_CAPI' is available - import datetime - if hasattr(datetime, "datetime_CAPI"): - assert mod.f(2048) is type(datetime.datetime_CAPI) - - def test_extern_def(self): - import pytest - main = """ - extern HPyDef f; - extern HPyDef g; - extern HPyDef h; - extern HPyDef i; - - @EXPORT(f) - @EXPORT(g) - @EXPORT(h) - @EXPORT(i) - @INIT - """ - extra = """ - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 12345); - } - HPyDef_METH(g, "g", HPyFunc_O) - static HPy g_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Dup(ctx, arg); - } - HPyDef_METH(h, "h", HPyFunc_VARARGS) - static HPy h_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - long a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &a, &b)) - return HPy_NULL; - return HPyLong_FromLong(ctx, 10*a + b); - } - HPyDef_METH(i, "i", HPyFunc_KEYWORDS) - static HPy i_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, - HPy kwnames) - { - long a, b; - static const char *kwlist[] = { "a", "b", NULL }; - if (!HPyArg_ParseKeywords(ctx, NULL, args, nargs, kwnames, "ll", kwlist, &a, &b)) - return HPy_NULL; - return HPyLong_FromLong(ctx, 10*a + b); - } - """ - mod = self.make_module(main, extra_sources=[extra]) - assert mod.f() == 12345 - assert mod.g(42) == 42 - assert mod.h(5, 6) == 56 - assert mod.i(4, 3) == 43 - assert mod.i(a=2, b=5) == 25 - with pytest.raises(TypeError): - mod.h("not an integer", "not an integer either") - - def test_Float_FromDouble(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyFloat_FromDouble(ctx, 123.45); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 123.45 - - def test_unsupported_signature(self): - import pytest - with pytest.raises(ValueError) as exc: - self.make_module(""" - HPyDef f = { - .kind = HPyDef_Kind_Meth, - .meth = { - .name = "f", - .signature = (HPyFunc_Signature)1234, - } - }; - @EXPORT(f) - @INIT - """) - assert str(exc.value) == 'Unsupported HPyMeth signature' - - def test_repr_str_ascii_bytes(self): - mod = self.make_module(""" - HPyDef_METH(f1, "f1", HPyFunc_O) - static HPy f1_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Repr(ctx, arg); - } - HPyDef_METH(f2, "f2", HPyFunc_O) - static HPy f2_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Str(ctx, arg); - } - HPyDef_METH(f3, "f3", HPyFunc_O) - static HPy f3_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_ASCII(ctx, arg); - } - HPyDef_METH(f4, "f4", HPyFunc_O) - static HPy f4_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Bytes(ctx, arg); - } - @EXPORT(f1) - @EXPORT(f2) - @EXPORT(f3) - @EXPORT(f4) - @INIT - """) - assert mod.f1("\u1234") == "'\u1234'" - assert mod.f2(42) == "42" - assert mod.f3("\u1234") == "'\\u1234'" - assert mod.f4(bytearray(b"foo")) == b"foo" - - def test_is_true(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int cond = HPy_IsTrue(ctx, arg); - return HPy_Dup(ctx, cond ? ctx->h_True : ctx->h_False); - } - @EXPORT(f) - @INIT - """) - assert mod.f("1234") is True - assert mod.f("") is False - - def test_richcompare(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy arg2 = HPyLong_FromLong(ctx, 100); - HPy result = HPy_RichCompare(ctx, arg, arg2, HPy_GT); - HPy_Close(ctx, arg2); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f(100) is False - assert mod.f(150) is True - - def test_richcomparebool(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy arg2 = HPyLong_FromLong(ctx, 100); - int result = HPy_RichCompareBool(ctx, arg, arg2, HPy_GE); - HPy_Close(ctx, arg2); - return HPyLong_FromLong(ctx, -result); - } - @EXPORT(f) - @INIT - """) - assert mod.f(50) == 0 - assert mod.f(100) == -1 - - def test_hash(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_hash_t hash = HPy_Hash(ctx, arg); - return HPyLong_FromSsize_t(ctx, hash); - } - @EXPORT(f) - @INIT - """) - x = object() - assert mod.f(x) == hash(x) - - def test_ctx_name(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, ctx->name); - } - - @EXPORT(f) - @INIT - """) - ctx_name = mod.f() - hpy_abi = self.compiler.hpy_abi - if hpy_abi == 'cpython': - assert ctx_name == 'HPy CPython ABI' - elif hpy_abi == 'universal': - # this can be "HPy Universal ABI (CPython backend)" or - # "... (PyPy backend)", etc. - assert ctx_name.startswith('HPy Universal ABI') - elif hpy_abi == 'debug': - assert ctx_name.startswith('HPy Debug Mode ABI') - elif hpy_abi == 'trace': - assert ctx_name.startswith('HPy Trace Mode ABI') - else: - assert False, 'unexpected hpy_abi: %s' % hpy_abi - - def test_abi_version(self): - """ - Check that all the various ABI version info that we have around match. - """ - from hpy.devel import abitag - mod = self.make_module( - """ - HPyDef_METH(get_ABI_VERSION, "get_ABI_VERSION", HPyFunc_NOARGS) - static HPy get_ABI_VERSION_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, HPY_ABI_VERSION); - } - - HPyDef_METH(get_ABI_TAG, "get_ABI_TAG", HPyFunc_NOARGS) - static HPy get_ABI_TAG_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, HPY_ABI_TAG); - } - - HPyDef_METH(get_ctx_version, "get_ctx_version", HPyFunc_NOARGS) - static HPy get_ctx_version_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, ctx->abi_version); - } - - @EXPORT(get_ABI_VERSION) - @EXPORT(get_ABI_TAG) - @EXPORT(get_ctx_version) - @INIT - """) - c_HPY_ABI_VERSION = mod.get_ABI_VERSION() - c_HPY_ABI_TAG = mod.get_ABI_TAG() - ctx_version = mod.get_ctx_version() - assert c_HPY_ABI_VERSION == ctx_version == abitag.HPY_ABI_VERSION - assert c_HPY_ABI_TAG == abitag.HPY_ABI_TAG - - def test_FromVoidP_AsVoidP(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - void *p = HPy_AsVoidP(arg); - HPy h = HPy_FromVoidP(p); - return HPy_Dup(ctx, h); - } - @EXPORT(f) - @INIT - """) - assert mod.f(42) == 42 - - def test_leave_python(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t data_len; - const char* data = HPyUnicode_AsUTF8AndSize(ctx, arg, &data_len); - HPy_ssize_t acount = 0; - HPy_BEGIN_LEAVE_PYTHON(ctx); - for (HPy_ssize_t i = 0; i < data_len; ++i) { - if (data[i] == 'a') - acount++; - } - HPy_END_LEAVE_PYTHON(ctx); - return HPyLong_FromSize_t(ctx, acount); - } - @EXPORT(f) - @INIT - """) - assert mod.f("abraka") == 3 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_argparse.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_argparse.py deleted file mode 100644 index d6f985457a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_argparse.py +++ /dev/null @@ -1,702 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -import pytest -from .support import HPyTest - - -class TestParseItem(HPyTest): - - def unsigned_long_bits(self): - """ Return the number of bits in an unsigned long. """ - # XXX: Copied from test_hpylong.py - import struct - unsigned_long_bytes = len(struct.pack('l', 0)) - return 8 * unsigned_long_bytes - - - def make_parse_item(self, fmt, type, hpy_converter): - mod = self.make_module(""" - #ifndef _MSC_VER - __attribute__((unused)) - #endif - static inline - HPy char_to_hpybytes(HPyContext *ctx, char a) {{ - return HPyBytes_FromStringAndSize(ctx, &a, 1); - }} - - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - {{ - {type} a; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "{fmt}", &a)) - return HPy_NULL; - return {hpy_converter}(ctx, a); - }} - @EXPORT(f) - @INIT - """.format(fmt=fmt, type=type, hpy_converter=hpy_converter)) - return mod - - def test_b(self): - import pytest - mod = self.make_parse_item("b", "char", "char_to_hpybytes") - assert mod.f(0) == b"\x00" - assert mod.f(1) == b"\x01" - assert mod.f(255) == b"\xff" - with pytest.raises(OverflowError) as err: - mod.f(256) - assert str(err.value) == ( - "function unsigned byte integer is greater than maximum" - ) - with pytest.raises(OverflowError) as err: - mod.f(-1) - assert str(err.value) == ( - "function unsigned byte integer is less than minimum" - ) - - def test_s(self): - import pytest - mod = self.make_parse_item("s", "const char*", "HPyUnicode_FromString") - assert mod.f("hello HPy") == "hello HPy" - with pytest.raises(ValueError) as err: - mod.f(b"hello\0HPy".decode('utf-8')) - assert str(err.value) == ( - "function embedded null character" - ) - with pytest.raises(TypeError) as err: - mod.f(b"hello HPy") - assert str(err.value) == ( - "function a str is required" - ) - - def test_B(self): - mod = self.make_parse_item("B", "char", "char_to_hpybytes") - assert mod.f(0) == b"\x00" - assert mod.f(1) == b"\x01" - assert mod.f(2**8 - 1) == b"\xff" - assert mod.f(2**8) == b"\x00" - assert mod.f(-1) == b"\xff" - - def test_h(self): - import pytest - mod = self.make_parse_item("h", "short", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**15 - 1) == 2**15 - 1 - assert mod.f(-2**15) == -2**15 - with pytest.raises(OverflowError) as err: - mod.f(2**15) - assert str(err.value) == ( - "function signed short integer is greater than maximum" - ) - with pytest.raises(OverflowError) as err: - mod.f(-2**15 - 1) - assert str(err.value) == ( - "function signed short integer is less than minimum" - ) - - def test_H_short(self): - mod = self.make_parse_item("H", "short", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**15 - 1) == 2**15 - 1 - assert mod.f(-2**15) == -2**15 - assert mod.f(2**16 - 1) == -1 - assert mod.f(-2**16 + 1) == 1 - assert mod.f(2**16) == 0 - assert mod.f(-2**16) == 0 - - def test_H_unsigned_short(self): - mod = self.make_parse_item( - "H", "unsigned short", "HPyLong_FromUnsignedLong" - ) - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == 2**16 - 1 - assert mod.f(2**16 - 1) == 2**16 - 1 - assert mod.f(-2**16 + 1) == 1 - assert mod.f(2**16) == 0 - assert mod.f(-2**16) == 0 - - def test_i(self): - import pytest - mod = self.make_parse_item("i", "int", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**31 - 1) == 2**31 - 1 - assert mod.f(-2**31) == -2**31 - with pytest.raises(OverflowError) as err: - mod.f(2**31) - assert str(err.value) in ( - "function signed integer is greater than maximum", - "Python int too large to convert to C long", # where sizeof(long) == 4 - ) - with pytest.raises(OverflowError) as err: - mod.f(-2**31 - 1) - assert str(err.value) in ( - "function signed integer is less than minimum", - "Python int too large to convert to C long", # where sizeof(long) == 4 - ) - - def test_I_signed(self): - mod = self.make_parse_item("I", "int", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**31 - 1) == 2**31 - 1 - assert mod.f(-2**31) == -2**31 - assert mod.f(2**32 - 1) == -1 - assert mod.f(-2**32 + 1) == 1 - assert mod.f(2**32) == 0 - assert mod.f(-2**32) == 0 - - def test_I_unsigned(self): - mod = self.make_parse_item( - "I", "unsigned int", "HPyLong_FromUnsignedLong" - ) - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == 2**32 - 1 - assert mod.f(2**32 - 1) == 2**32 - 1 - assert mod.f(-2**32 + 1) == 1 - assert mod.f(2**32) == 0 - assert mod.f(-2**32) == 0 - - def test_l(self): - import pytest - LONG_BITS = self.unsigned_long_bits() - 1 - mod = self.make_parse_item("l", "long", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**LONG_BITS - 1) == 2**LONG_BITS - 1 - assert mod.f(-2**LONG_BITS) == -2**LONG_BITS - with pytest.raises(OverflowError): - mod.f(2**LONG_BITS) - with pytest.raises(OverflowError): - mod.f(-2**LONG_BITS - 1) - - def test_k_signed(self): - LONG_BITS = self.unsigned_long_bits() - 1 - mod = self.make_parse_item("k", "long", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**LONG_BITS - 1) == 2**LONG_BITS - 1 - assert mod.f(-2**LONG_BITS) == -2**LONG_BITS - assert mod.f(2**(LONG_BITS + 1) - 1) == -1 - assert mod.f(-2**(LONG_BITS + 1) + 1) == 1 - assert mod.f(2**(LONG_BITS + 1)) == 0 - assert mod.f(-2**(LONG_BITS + 1)) == 0 - - def test_k_unsigned(self): - ULONG_BITS = self.unsigned_long_bits() - mod = self.make_parse_item( - "k", "unsigned long", "HPyLong_FromUnsignedLong" - ) - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == 2**ULONG_BITS - 1 - assert mod.f(2**ULONG_BITS - 1) == 2**ULONG_BITS - 1 - assert mod.f(-2**ULONG_BITS + 1) == 1 - assert mod.f(2**ULONG_BITS) == 0 - assert mod.f(-2**ULONG_BITS) == 0 - - def test_L(self): - import pytest - mod = self.make_parse_item("L", "long long", "HPyLong_FromLongLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**63 - 1) == 2**63 - 1 - assert mod.f(-2**63) == -2**63 - with pytest.raises(OverflowError): - mod.f(2**63) - with pytest.raises(OverflowError): - mod.f(-2**63 - 1) - - def test_K_signed(self): - mod = self.make_parse_item("K", "long long", "HPyLong_FromLongLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**63 - 1) == 2**63 - 1 - assert mod.f(-2**63) == -2**63 - assert mod.f(2**64 - 1) == -1 - assert mod.f(-2**64 + 1) == 1 - assert mod.f(2**64) == 0 - assert mod.f(-2**64) == 0 - - def test_K_unsigned(self): - mod = self.make_parse_item( - "K", "unsigned long long", "HPyLong_FromUnsignedLongLong" - ) - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == 2**64 - 1 - assert mod.f(2**64 - 1) == 2**64 - 1 - assert mod.f(-2**64 + 1) == 1 - assert mod.f(2**64) == 0 - assert mod.f(-2**64) == 0 - - def test_n(self): - import pytest - mod = self.make_parse_item("n", "HPy_ssize_t", "HPyLong_FromSsize_t") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == -1 - assert mod.f(2**63 - 1) == 2**63 - 1 - assert mod.f(-2**63) == -2**63 - with pytest.raises(OverflowError): - mod.f(2**63) - with pytest.raises(OverflowError): - mod.f(-2**63 - 1) - - def test_f(self): - import pytest - mod = self.make_parse_item("f", "float", "HPyFloat_FromDouble") - assert mod.f(1.) == 1. - assert mod.f(-2) == -2. - with pytest.raises(TypeError): - mod.f("x") - - def test_d(self): - import pytest - mod = self.make_parse_item("d", "double", "HPyFloat_FromDouble") - assert mod.f(1.) == 1. - assert mod.f(-2) == -2. - with pytest.raises(TypeError): - mod.f("x") - - def test_O(self): - mod = self.make_parse_item("O", "HPy", "HPy_Dup") - assert mod.f("a") == "a" - assert mod.f(5) == 5 - - def test_p(self): - mod = self.make_parse_item("p", "int", "HPyLong_FromLong") - assert mod.f(0) == 0 - assert mod.f(1) == 1 - assert mod.f(-1) == 1 - assert mod.f(False) == 0 - assert mod.f(True) == 1 - assert mod.f([]) == 0 - assert mod.f([0]) == 1 - assert mod.f("") == 0 - assert mod.f("0") == 1 - - -class TestArgParse(HPyTest): - def make_two_arg_add(self, fmt="OO"): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - {{ - HPy a; - HPy b = HPy_NULL; - HPy res; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "{fmt}", &a, &b)) - return HPy_NULL; - if (HPy_IsNull(b)) {{ - b = HPyLong_FromLong(ctx, 5); - }} else {{ - b = HPy_Dup(ctx, b); - }} - res = HPy_Add(ctx, a, b); - HPy_Close(ctx, b); - return res; - }} - @EXPORT(f) - @INIT - """.format(fmt=fmt)) - return mod - - def test_many_int_arguments(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - long a, b, c, d, e; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "lllll", - &a, &b, &c, &d, &e)) - return HPy_NULL; - return HPyLong_FromLong(ctx, - 10000*a + 1000*b + 100*c + 10*d + e); - } - @EXPORT(f) - @INIT - """) - assert mod.f(4, 5, 6, 7, 8) == 45678 - - def test_many_handle_arguments(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - return HPy_Add(ctx, a, b); - } - @EXPORT(f) - @INIT - """) - assert mod.f("a", "b") == "ab" - - def test_supplying_hpy_tracker(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b, result; - HPyTracker ht; - if (!HPyArg_Parse(ctx, &ht, args, nargs, "OO", &a, &b)) - return HPy_NULL; - result = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f("a", "b") == "ab" - - def test_unsupported_fmt(self): - import pytest - mod = self.make_two_arg_add(fmt="ZZ:two_add") - with pytest.raises(SystemError) as exc: - mod.f("a") - assert str(exc.value) == "two_add() unknown arg format code" - - def test_too_few_args(self): - import pytest - mod = self.make_two_arg_add("OO:two_add") - with pytest.raises(TypeError) as exc: - mod.f() - assert str(exc.value) == "two_add() required positional argument missing" - - def test_too_many_args(self): - import pytest - mod = self.make_two_arg_add("OO:two_add") - with pytest.raises(TypeError) as exc: - mod.f(1, 2, 3) - assert str(exc.value) == "two_add() mismatched args (too many arguments for fmt)" - - def test_optional_args(self): - mod = self.make_two_arg_add(fmt="O|O") - assert mod.f(1) == 6 - assert mod.f(3, 4) == 7 - - def test_keyword_only_args_fails(self): - import pytest - mod = self.make_two_arg_add(fmt="O$O:two_add") - with pytest.raises(SystemError) as exc: - mod.f(1, 2) - assert str(exc.value) == "two_add() unknown arg format code" - - def test_error_default_message(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "function required positional argument missing" - - def test_error_with_function_name(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO:my_func") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "my_func() required positional argument missing" - - def test_error_with_overridden_message(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO;my-error-message") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "my-error-message" - - -class TestArgParseKeywords(HPyTest): - def make_two_arg_add(self, fmt="O+O+"): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - {{ - HPy a, b, result; - HPyTracker ht; - static const char *kwlist[] = {{ "a", "b", NULL }}; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, - "{fmt}", kwlist, &a, &b)) {{ - return HPy_NULL; - }} - result = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return result; - }} - @EXPORT(f) - @INIT - """.format(fmt=fmt)) - return mod - - def test_handle_two_arguments(self): - mod = self.make_two_arg_add("OO") - assert mod.f("x", b="y") == "xy" - - def test_handle_reordered_arguments(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy a, b, result; - HPyTracker ht; - static const char *kwlist[] = { "a", "b", NULL }; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, "OO", - kwlist, &a, &b)) { - return HPy_NULL; - } - result = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f(b="y", a="x") == "xy" - - def test_handle_optional_arguments(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy a; - HPy b = HPy_NULL; - HPyTracker ht; - HPy res; - static const char *kwlist[] = { "a", "b", NULL }; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, "O|O", - kwlist, &a, &b)) { - return HPy_NULL; - } - if (HPy_IsNull(b)) { - b = HPyLong_FromLong(ctx, 5); - HPyTracker_Add(ctx, ht, b); - } - res = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f(a=3, b=2) == 5 - assert mod.f(3, 2) == 5 - assert mod.f(a=3) == 8 - assert mod.f(3) == 8 - - def test_unsupported_fmt(self): - import pytest - mod = self.make_two_arg_add(fmt="ZZ:two_add") - with pytest.raises(SystemError) as exc: - mod.f("a") - assert str(exc.value) == "two_add() unknown arg format code" - - def test_missing_required_argument(self): - import pytest - mod = self.make_two_arg_add(fmt="OO:add_two") - with pytest.raises(TypeError) as exc: - mod.f(1) - assert str(exc.value) == "add_two() no value for required argument" - - def test_mismatched_args_too_few_keywords(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO:add_two") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "add_two() mismatched args (too few keywords for fmt)" - - def test_mismatched_args_too_many_keywords(self): - import pytest - mod = self.make_two_arg_add(fmt="O:add_two") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "add_two() mismatched args (too many keywords for fmt)" - - def test_blank_keyword_argument_exception(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - long a, b, c; - static const char *kwlist[] = { "", "b", "", NULL }; - if (!HPyArg_ParseKeywords(ctx, NULL, args, nargs, kwnames, - "lll", kwlist, &a, &b, &c)) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - with pytest.raises(SystemError) as exc: - mod.f() - assert str(exc.value) == "function empty keyword parameter name" - - def test_positional_only_argument(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy a; - HPy b = HPy_NULL; - HPyTracker ht; - HPy res; - static const char *kwlist[] = { "", "b", NULL }; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, - "O|O", kwlist, &a, &b)) { - return HPy_NULL; - } - if (HPy_IsNull(b)) { - b = HPyLong_FromLong(ctx, 5); - HPyTracker_Add(ctx, ht, b); - } - res = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f(1, b=2) == 3 - assert mod.f(1, 2) == 3 - assert mod.f(1) == 6 - with pytest.raises(TypeError) as exc: - mod.f(a=1, b=2) - assert str(exc.value) == "function no value for required argument" - - def test_keyword_only_argument(self): - import pytest - mod = self.make_two_arg_add(fmt="O$O") - assert mod.f(1, b=2) == 3 - assert mod.f(a=1, b=2) == 3 - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == ( - "function keyword only argument passed as positional argument") - - def test_error_default_message(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "function mismatched args (too few keywords for fmt)" - - def test_error_with_function_name(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO:my_func") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "my_func() mismatched args (too few keywords for fmt)" - - def test_error_with_overridden_message(self): - import pytest - mod = self.make_two_arg_add(fmt="OOO;my-error-message") - with pytest.raises(TypeError) as exc: - mod.f(1, 2) - assert str(exc.value) == "my-error-message" - - def test_keywords_dict(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_KEYWORDS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy args_tuple, kwdict; - HPy a, b = HPy_NULL, res; - HPyTracker ht; - HPy_ssize_t n_args_tuple, i; - HPy *args_arr; - int status; - static const char *kwlist[] = { "a", "b", NULL }; - - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_SystemError, - "expected exactly two args"); - return HPy_NULL; - } - args_tuple = args[0]; - kwdict = args[1]; - n_args_tuple = HPy_Length(ctx, args_tuple); - args_arr = (HPy *)malloc(n_args_tuple * sizeof(HPy)); - for (i=0; i < n_args_tuple; i++) - args_arr[i] = HPy_GetItem_i(ctx, args_tuple, i); - - status = HPyArg_ParseKeywordsDict(ctx, &ht, args_arr, - n_args_tuple, kwdict, "O|O", kwlist, &a, &b); - - for (i=0; i < n_args_tuple; i++) - HPy_Close(ctx, args_arr[i]); - free(args_arr); - if (!status) { - return HPy_NULL; - } - if (HPy_IsNull(b)) { - b = HPyLong_FromLong(ctx, 5); - HPyTracker_Add(ctx, ht, b); - } - res = HPy_Add(ctx, a, b); - HPyTracker_Close(ctx, ht); - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f(tuple(), dict(a=3, b=2)) == 5 - assert mod.f((3, 2), {}) == 5 - assert mod.f(tuple(), dict(a=3)) == 8 - assert mod.f((3,), {}) == 8 - with pytest.raises(TypeError): - mod.f(tuple(), {}) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_call.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_call.py deleted file mode 100644 index 64468160ef..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_call.py +++ /dev/null @@ -1,353 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - - -class TestCall(HPyTest): - def argument_combinations(self, **items): - """ Returns all possible ways of expressing the given items as - arguments to a function. - """ - items = list(items.items()) - for i in range(len(items) + 1): - args = tuple(item[1] for item in items[:i]) - kw = dict(items[i:]) - yield {"args": args, "kw": kw} - if not args: - yield {"kw": kw} - if not kw: - yield {"args": args} - if not args and not kw: - yield {} - - def argument_combinations_tuple(self, **items): - """ Same as 'argument_combinations' but returns a tuple where - the first element is the argument tuple and the second is - a dict that may contain the keywords dict. - """ - items = list(items.items()) - for i in range(len(items) + 1): - args = tuple(item[1] for item in items[:i]) - kw = dict(items[i:]) - yield args, kw - if not args: - yield tuple(), kw - if not kw: - yield args, {} - if not args and not kw: - yield tuple(), {} - - def test_hpy_calltupledict(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(call, "call", HPyFunc_KEYWORDS) - static HPy call_impl(HPyContext *ctx, HPy self, const HPy *args, - size_t nargs, HPy kwnames) - { - - HPy f, result; - HPy f_args = HPy_NULL; - HPy f_kw = HPy_NULL; - HPyTracker ht; - static const char *kwlist[] = { "f", "args", "kw", NULL }; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, - "O|OO", kwlist, &f, &f_args, &f_kw)) { - return HPy_NULL; - } - result = HPy_CallTupleDict(ctx, f, f_args, f_kw); - HPyTracker_Close(ctx, ht); - return result; - } - @EXPORT(call) - @INIT - """) - - def f(a, b): - return a + b - - def g(): - return "this is g" - - # test passing arguments with handles of the correct type -- - # i.e. args is a tuple or a null handle, kw is a dict or a null handle. - for d in self.argument_combinations(a=1, b=2): - assert mod.call(f, **d) == 3 - for d in self.argument_combinations(a=1): - with pytest.raises(TypeError): - mod.call(f, **d) - for d in self.argument_combinations(): - with pytest.raises(TypeError): - mod.call(f, **d) - for d in self.argument_combinations(): - assert mod.call(g, **d) == "this is g" - for d in self.argument_combinations(object=2): - assert mod.call(str, **d) == "2" - for d in self.argument_combinations(): - with pytest.raises(TypeError): - mod.call("not callable", **d) - for d in self.argument_combinations(unknown=2): - with pytest.raises(TypeError): - mod.call("not callable", **d) - - # test passing handles of the incorrect type as arguments - with pytest.raises(TypeError): - mod.call(f, args=[1, 2]) - with pytest.raises(TypeError): - mod.call(f, args="string") - with pytest.raises(TypeError): - mod.call(f, args=1) - with pytest.raises(TypeError): - mod.call(f, args=None) - with pytest.raises(TypeError): - mod.call(f, kw=[1, 2]) - with pytest.raises(TypeError): - mod.call(f, kw="string") - with pytest.raises(TypeError): - mod.call(f, kw=1) - with pytest.raises(TypeError): - mod.call(f, kw=None) - - def test_hpy_callmethodtupledict(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(call, "call", HPyFunc_KEYWORDS) - static HPy call_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy result, result_0, result_1; - HPy receiver = HPy_NULL; - HPy h_name = HPy_NULL; - HPy m_args = HPy_NULL; - const char *s_name = ""; - HPyTracker ht; - static const char *kwlist[] = { "receiver", "name", "args", NULL }; - if (!HPyArg_ParseKeywords(ctx, &ht, args, nargs, kwnames, "OO|O", - kwlist, &receiver, &h_name, &m_args)) { - return HPy_NULL; - } - s_name = HPyUnicode_AsUTF8AndSize(ctx, h_name, NULL); - if (s_name == NULL) { - HPyTracker_Close(ctx, ht); - return HPy_NULL; - } - - result_0 = HPy_CallMethodTupleDict(ctx, h_name, receiver, m_args, HPy_NULL); - if (HPy_IsNull(result_0)) { - HPyTracker_Close(ctx, ht); - return HPy_NULL; - } - - result_1 = HPy_CallMethodTupleDict_s(ctx, s_name, receiver, m_args, HPy_NULL); - if (HPy_IsNull(result_1)) { - HPyTracker_Close(ctx, ht); - HPy_Close(ctx, result_0); - return HPy_NULL; - } - - HPyTracker_Close(ctx, ht); - result = HPyTuple_Pack(ctx, 2, result_0, result_1); - HPy_Close(ctx, result_0); - HPy_Close(ctx, result_1); - return result; - } - @EXPORT(call) - @INIT - """) - - test_args = ( - # (receiver, method, args_tuple) - dict(receiver={"hello": 1, "world": 2}, name="keys", args=tuple()), - dict(receiver="Hello, World", name="find", args=("Wo", )), - ) - - for kw in test_args: - res = getattr(kw["receiver"], kw["name"])(*kw["args"]) - assert mod.call(**kw) == (res, res) - - with pytest.raises(AttributeError): - mod.call(receiver=dict(), name="asdf", args=tuple()) - - with pytest.raises(TypeError): - mod.call(receiver="Hello, World", name="find") - - with pytest.raises(TypeError): - mod.call(receiver="Hello, World", name="find", args=("1", ) * 100) - - def test_hpy_call(self): - import pytest - mod = self.make_module(""" - #define SELF 1 - - HPyDef_METH(call, "call", HPyFunc_KEYWORDS) - static HPy call_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - if (nargs < SELF) { - HPyErr_SetString(ctx, ctx->h_TypeError, "HPy_Call requires a receiver"); - return HPy_NULL; - } - return HPy_Call(ctx, args[0], args + SELF, nargs - SELF, kwnames); - } - @EXPORT(call) - @INIT - """) - - def foo(): - raise ValueError - - def listify(*args): - return args - - def f(a, b): - return a + b - - def g(): - return "this is g" - - class KwDict(dict): - def __getitem__(self, key): - return "key=" + str(key); - - test_args = ( - # (receiver, args_tuple, kwd) - (dict, (dict(a=0, b=1), ), {}), - (dict, tuple(), dict(a=0, b=1)), - ) - for receiver, args_tuple, kwd in test_args: - assert mod.call(receiver, *args_tuple, **kwd) == receiver(*args_tuple, **kwd) - - # NULL dict for keywords - mod.call(dict) - - # dict subclass for keywords - # TODO(fa): GR-47126 - # kwdict = KwDict(x=11, y=12, z=13) - # assert mod.call(dict, **kwdict) == dict(kwdict) - - with pytest.raises(ValueError): - mod.call(foo) - with pytest.raises(TypeError): - mod.call() - - # large amount of args - r = range(1000) - assert mod.call(listify, *r) == listify(*r) - - # test passing arguments with handles of the correct type -- - # i.e. args is a tuple or a null handle, kw is a dict or a null handle. - for args, kwd in self.argument_combinations_tuple(a=1, b=2): - assert mod.call(f, *args, **kwd) == 3 - for args, kwd in self.argument_combinations_tuple(a=1): - with pytest.raises(TypeError): - mod.call(f, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(): - with pytest.raises(TypeError): - mod.call(f, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(): - assert mod.call(g, *args, **kwd) == "this is g" - for args, kwd in self.argument_combinations_tuple(object=2): - assert mod.call(str, *args, **kwd) == "2" - for args, kwd in self.argument_combinations_tuple(): - with pytest.raises(TypeError): - mod.call("not callable", *args, **kwd) - for args, kwd in self.argument_combinations_tuple(unknown=2): - with pytest.raises(TypeError): - mod.call("not callable", *args, **kwd) - - def test_hpy_callmethod(self): - import pytest - mod = self.make_module(""" - #define NAME 1 - - HPyDef_METH(call, "call", HPyFunc_KEYWORDS) - static HPy call_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs, HPy kwnames) - { - if (nargs < NAME) { - HPyErr_SetString(ctx, ctx->h_TypeError, "HPy_CallMethod requires a receiver and a method name"); - return HPy_NULL; - } - // 'args[0]' is the name - return HPy_CallMethod(ctx, args[0], args + NAME, nargs - NAME, kwnames); - } - @EXPORT(call) - @INIT - """) - - class Dummy: - not_callable = 123 - - def f(self, a, b): - return a + b - - def g(self): - return 'this is g' - - test_obj = Dummy() - - # test passing arguments with handles of the correct type -- - # i.e. args is a tuple or a null handle, kw is a dict or a null handle. - for args, kwd in self.argument_combinations_tuple(a=1, b=2): - assert mod.call('f', test_obj, *args, **kwd) == 3 - for args, kwd in self.argument_combinations_tuple(a=1): - with pytest.raises(TypeError): - mod.call('f', test_obj, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(a=1, b=2, c=3): - with pytest.raises(TypeError): - mod.call('f', test_obj, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(): - with pytest.raises(TypeError): - mod.call('f', test_obj, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(): - assert mod.call('g', test_obj, *args, **kwd) == 'this is g' - for args, kwd in self.argument_combinations_tuple(): - with pytest.raises(TypeError): - mod.call('not_callable', test_obj, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(unknown=2): - with pytest.raises(TypeError): - mod.call('not_callable', test_obj, *args, **kwd) - for args, kwd in self.argument_combinations_tuple(): - with pytest.raises(AttributeError): - mod.call('embedded null byte', test_obj, *args, **kwd) - - def test_hpycallable_check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyCallable_Check(ctx, arg)) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - - def f(): - return "this is f" - - assert mod.f(f) is True - assert mod.f(str) is True - assert mod.f("a") is False - assert mod.f(3) is False diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule.py deleted file mode 100644 index 3f0b7b683a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule.py +++ /dev/null @@ -1,491 +0,0 @@ -# MIT License -# -# Copyright (c) 2022, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: these tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -import pytest -from .support import HPyTest, DefaultExtensionTemplate - -class CapsuleTemplate(DefaultExtensionTemplate): - - def DEFINE_strdup(self): - return """ - #include - - static char *strdup0(const char *s) - { - size_t n = strlen(s) + 1; - char *copy = (char *) malloc(n * sizeof(char)); - if (copy == NULL) { - return NULL; - } - strncpy(copy, s, n); - return copy; - } - """ - - def DEFINE_SomeObject(self): - return """ - #include - - typedef struct { - int value; - char message[]; - } SomeObject; - - static SomeObject *create_payload(int value, char *message) - { - size_t n_message = strlen(message) + 1; - SomeObject *pointer = (SomeObject *) - malloc(sizeof(SomeObject) + n_message * sizeof(char)); - if (pointer == NULL) { - return NULL; - } - pointer->value = value; - strncpy(pointer->message, message, n_message); - return pointer; - } - """ - - def DEFINE_Capsule_New(self, destructor="NULL"): - return """ - #include - - static const char *_capsule_name = "some_capsule"; - - #define CAPSULE_NAME _capsule_name - - HPyDef_METH(Capsule_New, "capsule_new", HPyFunc_VARARGS) - static HPy Capsule_New_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy res; - int value; - char *message; - void *ptr; - - if (nargs > 0) - { - if (!HPyArg_Parse(ctx, NULL, args, nargs, "is", &value, &message)) { - return HPy_NULL; - } - ptr = (void *) create_payload(value, message); - if (ptr == NULL) { - HPyErr_SetString(ctx, ctx->h_MemoryError, "out of memory"); - return HPy_NULL; - } - res = HPyCapsule_New(ctx, ptr, CAPSULE_NAME, %s); - if (HPy_IsNull(res)) { - free(ptr); - } - return res; - } - /* just for error case testing */ - return HPyCapsule_New(ctx, NULL, CAPSULE_NAME, NULL); - } - """ % destructor - - def DEFINE_Payload_Free(self): - return """ - #include - - HPyDef_METH(Payload_Free, "payload_free", HPyFunc_O) - static HPy Payload_Free_impl(HPyContext *ctx, HPy self, HPy arg) - { - const char *name = HPyCapsule_GetName(ctx, arg); - if (name == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - - void *pointer = HPyCapsule_GetPointer(ctx, arg, name); - if (pointer == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - free(pointer); - - void *context = HPyCapsule_GetContext(ctx, arg); - if (context == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - free(context); - - return HPy_Dup(ctx, ctx->h_None); - } - """ - - def DEFINE_Capsule_GetName(self): - return """ - HPyDef_METH(Capsule_GetName, "capsule_getname", HPyFunc_O) - static HPy Capsule_GetName_impl(HPyContext *ctx, HPy self, HPy arg) - { - const char *name = HPyCapsule_GetName(ctx, arg); - if (name == NULL) { - return HPy_NULL; - } - return HPyUnicode_FromString(ctx, name); - } - """ - - def DEFINE_Capsule_GetPointer(self): - return """ - static HPy payload_as_tuple(HPyContext *ctx, SomeObject *pointer) - { - HPy value = HPyLong_FromLong(ctx, pointer->value); - HPy message = HPyUnicode_FromString(ctx, pointer->message); - HPy result = HPyTuple_Pack(ctx, 2, value, message); - HPy_Close(ctx, value); - HPy_Close(ctx, message); - return result; - } - - HPyDef_METH(Capsule_GetPointer, "capsule_getpointer", HPyFunc_O) - static HPy Capsule_GetPointer_impl(HPyContext *ctx, HPy self, HPy arg) - { - SomeObject *pointer = (SomeObject *) HPyCapsule_GetPointer(ctx, arg, CAPSULE_NAME); - if (pointer == NULL) { - return HPy_NULL; - } - return payload_as_tuple(ctx, pointer); - } - """ - -class TestHPyCapsule(HPyTest): - - ExtensionTemplate = CapsuleTemplate - - def test_capsule_new(self): - mod = self.make_module(""" - @DEFINE_SomeObject - @DEFINE_Capsule_New - @DEFINE_Capsule_GetName - @DEFINE_Payload_Free - - @EXPORT(Capsule_New) - @EXPORT(Capsule_GetName) - @EXPORT(Payload_Free) - - @INIT - """) - p = mod.capsule_new(789, "Hello, World!") - try: - assert mod.capsule_getname(p) == "some_capsule" - finally: - # manually free the payload to avoid a memleak - mod.payload_free(p) - with pytest.raises(ValueError): - mod.capsule_new() - - @pytest.mark.skip - def test_capsule_getter_and_setter(self): - mod = self.make_module(""" - #include - - @DEFINE_strdup - @DEFINE_SomeObject - @DEFINE_Capsule_New - @DEFINE_Capsule_GetPointer - @DEFINE_Capsule_GetName - @DEFINE_Payload_Free - - HPyDef_METH(Capsule_SetPointer, "capsule_setpointer", HPyFunc_VARARGS) - static HPy Capsule_SetPointer_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy capsule; - int value; - char *message; - int non_null_pointer; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "Oisi", - &capsule, &value, &message, &non_null_pointer)) { - return HPy_NULL; - } - - /* avoid memleak; get and later free previous pointer */ - void *old_ptr= HPyCapsule_GetPointer(ctx, capsule, CAPSULE_NAME); - if (old_ptr == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - - SomeObject *pointer = NULL; - if (non_null_pointer) { - pointer = create_payload(value, message); - if (pointer == NULL) { - HPyErr_SetString(ctx, ctx->h_MemoryError, "out of memory"); - return HPy_NULL; - } - } - - if (HPyCapsule_SetPointer(ctx, capsule, (void *) pointer) < 0) { - if (non_null_pointer) { - free(pointer); - } - return HPy_NULL; - } - free(old_ptr); - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(Capsule_GetContext, "capsule_getcontext", HPyFunc_O) - static HPy Capsule_GetContext_impl(HPyContext *ctx, HPy self, HPy arg) - { - SomeObject *context = (SomeObject *) HPyCapsule_GetContext(ctx, arg); - if (context == NULL) { - return HPyErr_Occurred(ctx) ? HPy_NULL : HPy_Dup(ctx, ctx->h_None); - } - return payload_as_tuple(ctx, context); - } - - HPyDef_METH(Capsule_SetContext, "capsule_setcontext", HPyFunc_VARARGS) - static HPy Capsule_SetContext_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy capsule; - int value; - char *message; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "Ois", &capsule, &value, &message)) { - return HPy_NULL; - } - - /* avoid memleak; get and free previous context */ - void *old_context = HPyCapsule_GetContext(ctx, capsule); - if (old_context == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - free(old_context); - - SomeObject *context = create_payload(value, message); - if (context == NULL) { - HPyErr_SetString(ctx, ctx->h_MemoryError, "out of memory"); - return HPy_NULL; - } - if (HPyCapsule_SetContext(ctx, capsule, (void *) context) < 0) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(Capsule_SetName, "capsule_setname", HPyFunc_VARARGS) - static HPy Capsule_SetName_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy capsule; - const char *name; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "Os", &capsule, &name)) { - return HPy_NULL; - } - - /* avoid memleak; get and free previous context */ - const char *old_name = HPyCapsule_GetName(ctx, capsule); - if (old_name == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - if (old_name != CAPSULE_NAME) { - free((void *) old_name); - } - - char *name_copy = strdup0(name); - if (name_copy == NULL) { - HPyErr_SetString(ctx, ctx->h_MemoryError, "out of memory"); - return HPy_NULL; - } - - if (HPyCapsule_SetName(ctx, capsule, (const char *) name_copy) < 0) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - static HPyCapsule_Destructor invalid_dtor = { NULL, NULL }; - - HPyDef_METH(Capsule_SetDestructor, "capsule_set_destructor", HPyFunc_VARARGS) - static HPy Capsule_SetDestructor_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy capsule; - HPy null_dtor; - HPyCapsule_Destructor *dtor; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &capsule, &null_dtor)) { - return HPy_NULL; - } - - if (HPy_IsTrue(ctx, null_dtor)) { - dtor = NULL; - } else { - dtor = &invalid_dtor; - } - - if (HPyCapsule_SetDestructor(ctx, capsule, dtor) < 0) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(Capsule_free_name, "capsule_freename", HPyFunc_O) - static HPy Capsule_free_name_impl(HPyContext *ctx, HPy self, HPy arg) - { - /* avoid memleak; get and free previous context */ - const char *old_name = HPyCapsule_GetName(ctx, arg); - if (old_name == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - if (old_name != CAPSULE_NAME) { - free((void *) old_name); - } - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(Capsule_New) - @EXPORT(Capsule_GetPointer) - @EXPORT(Capsule_SetPointer) - @EXPORT(Capsule_GetContext) - @EXPORT(Capsule_SetContext) - @EXPORT(Capsule_GetName) - @EXPORT(Capsule_SetName) - @EXPORT(Capsule_SetDestructor) - @EXPORT(Capsule_free_name) - @EXPORT(Payload_Free) - - @INIT - """) - p = mod.capsule_new(789, "Hello, World!") - try: - assert mod.capsule_getpointer(p) == (789, "Hello, World!") - assert mod.capsule_setpointer(p, 456, "lorem ipsum", True) is None - assert mod.capsule_getpointer(p) == (456, "lorem ipsum") - - assert mod.capsule_getcontext(p) == None - assert mod.capsule_setcontext(p, 123, "hello") is None - assert mod.capsule_getcontext(p) == (123, "hello") - - assert mod.capsule_getname(p) == "some_capsule" - assert mod.capsule_setname(p, "foo") is None - assert mod.capsule_getname(p) == "foo" - - assert mod.capsule_set_destructor(p, True) is None - - not_a_capsule = "hello" - with pytest.raises(ValueError): - mod.capsule_getpointer(not_a_capsule) - with pytest.raises(ValueError): - mod.capsule_setpointer(not_a_capsule, 0, "", True) - with pytest.raises(ValueError): - mod.capsule_setpointer(p, 456, "lorem ipsum", False) - with pytest.raises(ValueError): - mod.capsule_getcontext(not_a_capsule) - with pytest.raises(ValueError): - mod.capsule_setcontext(not_a_capsule, 0, "") - with pytest.raises(ValueError): - mod.capsule_getname(not_a_capsule) - with pytest.raises(ValueError): - mod.capsule_setname(not_a_capsule, "") - with pytest.raises(ValueError): - mod.capsule_set_destructor(not_a_capsule, True) - with pytest.raises(ValueError): - mod.capsule_set_destructor(p, False) - finally: - # manually free the payload to avoid a memleak - mod.payload_free(p) - mod.capsule_freename(p) - - def test_capsule_isvalid(self): - mod = self.make_module(""" - @DEFINE_SomeObject - @DEFINE_Capsule_New - @DEFINE_Capsule_GetName - @DEFINE_Payload_Free - - HPyDef_METH(Capsule_isvalid, "capsule_isvalid", HPyFunc_VARARGS) - static HPy Capsule_isvalid_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy capsule; - const char *name; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "Os", &capsule, &name)) { - return HPy_NULL; - } - return HPyBool_FromLong(ctx, HPyCapsule_IsValid(ctx, capsule, name)); - } - - @EXPORT(Capsule_New) - @EXPORT(Capsule_GetName) - @EXPORT(Capsule_isvalid) - @EXPORT(Payload_Free) - - @INIT - """) - p = mod.capsule_new(789, "Hello, World!") - name = mod.capsule_getname(p) - try: - assert mod.capsule_isvalid(p, name) - assert not mod.capsule_isvalid(p, "asdf") - assert not mod.capsule_isvalid("asdf", name) - finally: - # manually free the payload to avoid a memleak since the - # capsule doesn't have a destructor - mod.payload_free(p) - - @pytest.mark.syncgc - def test_capsule_new_with_destructor(self): - mod = self.make_module(""" - static int pointer_freed = 0; - - HPyCapsule_DESTRUCTOR(mydtor) - static void mydtor_impl(const char *name, void *pointer, void *context) - { - free(pointer); - pointer_freed = 1; - } - - @DEFINE_SomeObject - @DEFINE_Capsule_New(&mydtor) - @DEFINE_Capsule_GetName - @DEFINE_Payload_Free - - HPyDef_METH(Pointer_freed, "pointer_freed", HPyFunc_NOARGS) - static HPy Pointer_freed_impl(HPyContext *ctx, HPy self) - { - return HPyBool_FromLong(ctx, pointer_freed); - } - - @EXPORT(Capsule_New) - @EXPORT(Capsule_GetName) - @EXPORT(Pointer_freed) - - @INIT - """) - p = mod.capsule_new(789, "Hello, World!") - assert mod.capsule_getname(p) == "some_capsule" - del p - assert mod.pointer_freed() - - def test_capsule_new_with_invalid_destructor(self): - mod = self.make_module(""" - static HPyCapsule_Destructor mydtor = { NULL, NULL }; - - @DEFINE_SomeObject - @DEFINE_Capsule_New(&mydtor) - @EXPORT(Capsule_New) - @INIT - """) - with pytest.raises(ValueError): - mod.capsule_new(789, "Hello, World!") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule_legacy.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule_legacy.py deleted file mode 100644 index 364baa3f13..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_capsule_legacy.py +++ /dev/null @@ -1,109 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from .support import HPyTest, make_hpy_abi_fixture -from .test_capsule import CapsuleTemplate - -hpy_abi = make_hpy_abi_fixture('with hybrid') - -class TestHPyCapsuleLegacy(HPyTest): - - ExtensionTemplate = CapsuleTemplate - - def test_legacy_capsule_compat(self): - import pytest - mod = self.make_module(""" - @DEFINE_strdup - - #include - #include - - static int dummy = 123; - - static void legacy_destructor(PyObject *capsule) - { - /* We need to use C lib 'free' because the string was - created with 'strdup0'. */ - free((void *) PyCapsule_GetName(capsule)); - } - - HPyDef_METH(Create_pycapsule, "create_pycapsule", HPyFunc_O) - static HPy Create_pycapsule_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t n; - const char *name = HPyUnicode_AsUTF8AndSize(ctx, arg, &n); - char *name_copy = strdup0(name); - if (name_copy == NULL) { - HPyErr_SetString(ctx, ctx->h_MemoryError, "out of memory"); - return HPy_NULL; - } - PyObject *legacy_caps = PyCapsule_New(&dummy, (const char *) name_copy, - legacy_destructor); - HPy res = HPy_FromPyObject(ctx, legacy_caps); - Py_DECREF(legacy_caps); - return res; - } - - HPyDef_METH(Capsule_get, "get", HPyFunc_O) - static HPy Capsule_get_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy res = HPy_NULL; - HPy h_value = HPy_NULL; - int *ptr = NULL; - - const char *name = HPyCapsule_GetName(ctx, arg); - if (name == NULL && HPyErr_Occurred(ctx)) { - return HPy_NULL; - } - HPy h_name = HPyUnicode_FromString(ctx, name); - if (HPy_IsNull(h_name)) { - goto finish; - } - - ptr = (int *) HPyCapsule_GetPointer(ctx, arg, name); - if (ptr == NULL && HPyErr_Occurred(ctx)) { - goto finish; - } - - h_value = HPyLong_FromLong(ctx, *ptr); - if (HPy_IsNull(h_value)) { - goto finish; - } - - res = HPyTuple_Pack(ctx, 2, h_name, h_value); - - finish: - HPy_Close(ctx, h_name); - HPy_Close(ctx, h_value); - return res; - } - - @EXPORT(Create_pycapsule) - @EXPORT(Capsule_get) - - @INIT - """) - name = "legacy_capsule" - p = mod.create_pycapsule(name) - assert mod.get(p) == (name, 123) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_contextvar.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_contextvar.py deleted file mode 100644 index 88558b7ee3..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_contextvar.py +++ /dev/null @@ -1,75 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestHPyContextVar(HPyTest): - - def test_basics(self): - mod = self.make_module(""" - HPyDef_METH(new_ctxv, "new_ctxv", HPyFunc_NOARGS) - static HPy new_ctxv_impl(HPyContext *ctx, HPy self) - { - return HPyContextVar_New(ctx, "test_contextvar", HPy_NULL); - } - - HPyDef_METH(set_ctxv, "set_ctxv", HPyFunc_VARARGS) - static HPy set_ctxv_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy obj, val; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &obj, &val)) - return HPy_NULL; - return HPyContextVar_Set(ctx, obj, val); - } - HPyDef_METH(get_ctxv, "get_ctxv", HPyFunc_VARARGS) - static HPy get_ctxv_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy obj, def=HPy_NULL, val; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "O|O", &obj, &def)) - return HPy_NULL; - if (HPyContextVar_Get(ctx, obj, def, &val) < 0) { - return HPy_NULL; - } - return val; - } - - - @EXPORT(new_ctxv) - @EXPORT(get_ctxv) - @EXPORT(set_ctxv) - @INIT - """) - var = mod.new_ctxv() - tok = mod.set_ctxv(var, 4) - assert tok.var is var - four = mod.get_ctxv(var) - assert four == 4 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_cpy_compat.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_cpy_compat.py deleted file mode 100644 index 3c1142a4a3..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_cpy_compat.py +++ /dev/null @@ -1,239 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest, make_hpy_abi_fixture - -class TestCPythonCompatibility(HPyTest): - - hpy_abi = make_hpy_abi_fixture('with hybrid', class_fixture=True) - - # One note about the supports_refcounts() in the tests below: on - # CPython, handles are actually implemented as INCREF/DECREF, so we can - # check e.g. after an HPy_Dup the refcnt is += 1. However, on PyPy they - # are implemented in a completely different way which is unrelated to the - # refcnt (this is the whole point of HPy, after all :)). So in many of the - # following tests, checking the actual result of the function doesn't - # really make sens on PyPy. We still run the functions to ensure they do - # not crash, though. - - def test_abi(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, HPY_ABI); - } - @EXPORT(f) - @INIT - """) - hpy_abi = mod.f() - expected = self.compiler.hpy_abi - if expected in ('hybrid+debug', 'hybrid+trace'): - expected = 'hybrid' - assert hpy_abi == expected - - def test_frompyobject(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - PyObject *o = PyList_New(0); - Py_ssize_t initial_refcount = Py_REFCNT(o); - HPy h = HPy_FromPyObject(ctx, o); - Py_ssize_t final_refcount = Py_REFCNT(o); - - PyList_Append(o, PyLong_FromLong(1234)); - PyList_Append(o, PyLong_FromSsize_t(final_refcount - - initial_refcount)); - Py_DECREF(o); - return h; - } - @EXPORT(f) - @INIT - """) - x = mod.f() - assert x[0] == 1234 - assert len(x) == 2 - if self.supports_refcounts(): - assert x == [1234, +1] - - def test_frompyobject_null(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPy h = HPy_FromPyObject(ctx, NULL); - if (HPy_IsNull(h)) { - return HPy_Dup(ctx, ctx->h_True); - } - else { - return HPy_Dup(ctx, ctx->h_False); - } - } - @EXPORT(f) - @INIT - """) - assert mod.f() - - def test_aspyobject(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - PyObject *o = HPy_AsPyObject(ctx, arg); - long val = PyLong_AsLong(o); - Py_DecRef(o); - return HPyLong_FromLong(ctx, val*2); - } - @EXPORT(f) - @INIT - """) - assert mod.f(21) == 42 - - def test_aspyobject_null(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - PyObject *o = HPy_AsPyObject(ctx, HPy_NULL); - if (o == NULL) { - return HPy_Dup(ctx, ctx->h_True); - } - else { - return HPy_Dup(ctx, ctx->h_False); - } - } - @EXPORT(f) - @INIT - """) - assert mod.f() - - def test_aspyobject_custom_class(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - PyObject *o = HPy_AsPyObject(ctx, arg); - PyObject *o_res = PyObject_CallMethod(o, "foo", ""); - HPy h_res = HPy_FromPyObject(ctx, o_res); - Py_DecRef(o); - Py_DecRef(o_res); - return h_res; - } - @EXPORT(f) - @INIT - """) - class MyClass: - def foo(self): - return 1234 - obj = MyClass() - assert mod.f(obj) == 1234 - - def test_hpy_close(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - PyObject *o = PyList_New(0); - - HPy h = HPy_FromPyObject(ctx, o); - Py_ssize_t initial_refcount = Py_REFCNT(o); - HPy_Close(ctx, h); - Py_ssize_t final_refcount = Py_REFCNT(o); - - Py_DECREF(o); - return HPyLong_FromLong(ctx, (long)(final_refcount - - initial_refcount)); - } - @EXPORT(f) - @INIT - """) - x = mod.f() - if self.supports_refcounts(): - assert x == -1 - - def test_hpy_dup(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - PyObject *o = PyList_New(0); - - HPy h = HPy_FromPyObject(ctx, o); - Py_ssize_t initial_refcount = Py_REFCNT(o); - HPy h2 = HPy_Dup(ctx, h); - Py_ssize_t final_refcount = Py_REFCNT(o); - - HPy_Close(ctx, h); - HPy_Close(ctx, h2); - Py_DECREF(o); - return HPyLong_FromLong(ctx, (long)(final_refcount - - initial_refcount)); - } - @EXPORT(f) - @INIT - """) - x = mod.f() - if self.supports_refcounts(): - assert x == +1 - - def test_many_handles(self): - mod = self.make_module(""" - #include - #define NUM_HANDLES 10000 - - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - PyObject *o = PyList_New(0); - Py_ssize_t final_refcount; - - Py_ssize_t result = -42; - HPy handles[NUM_HANDLES]; - int i; - Py_ssize_t initial_refcount = Py_REFCNT(o); - for (i = 0; i < NUM_HANDLES; i++) - handles[i] = HPy_FromPyObject(ctx, o); - for (i = 0; i < NUM_HANDLES; i++) - if (HPy_IsNull(handles[i])) - goto error; - for (i = 0; i < NUM_HANDLES; i++) - HPy_Close(ctx, handles[i]); - final_refcount = Py_REFCNT(o); - result = final_refcount - initial_refcount; - - error: - return HPyLong_FromLong(ctx, (long)result); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 0 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_eval.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_eval.py deleted file mode 100644 index d019012245..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_eval.py +++ /dev/null @@ -1,110 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from textwrap import dedent -from .support import HPyTest - -class TestEval(HPyTest): - def test_compile(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - const char *source, *filename; - HPy_SourceKind src_kind; - int src_kind_i; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ssi", &source, &filename, &src_kind_i)) - return HPy_NULL; - - switch (src_kind_i) - { - case 0: src_kind = HPy_SourceKind_Expr; break; - case 1: src_kind = HPy_SourceKind_File; break; - case 2: src_kind = HPy_SourceKind_Single; break; - default: - // just pass through for testing - src_kind = (HPy_SourceKind) src_kind_i; - } - return HPy_Compile_s(ctx, source, filename, src_kind); - } - @EXPORT(f) - @INIT - """) - c0 = mod.f("1 + 2", "hello0.py", 0) - assert c0 - assert c0.co_filename == "hello0.py" - assert eval(c0) == 3 - - c1 = mod.f(dedent(""" - a = 1 - b = 2 - def add(x, y): - return x + y - res = add(a, b) - """), "hello1.py", 1) - globals1 = dict() - locals1 = dict() - assert eval(c1, globals1, locals1) is None - assert "add" in locals1, "was: %r" % locals1 - assert locals1["a"] == 1 - assert locals1["b"] == 2 - assert locals1["res"] == 3 - - c2 = mod.f("x = 1 + 2", "hello2.py", 2) - locals2 = dict() - assert eval(c2, dict(), locals2) is None - assert locals2["x"] == 3 - - with pytest.raises(SyntaxError): - mod.f("1 +.", "hello1.c", 0) - - with pytest.raises(SystemError): - mod.f("1+2", "hello.c", 777) - - def test_eval_code(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 3) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 3 args"); - return HPy_NULL; - } - return HPy_EvalCode(ctx, args[0], args[1], args[2]); - } - @EXPORT(f) - @INIT - """) - c0 = compile("a + b", "hello.py", "eval") - assert mod.f(c0, dict(), dict(a=2, b=3)) == 5 - - locals1 = dict(a=10, b=20) - c1 = compile("x = a + b", "hello.py", "exec") - assert mod.f(c1, dict(), locals1) is None - assert locals1['x'] == 30 - - c0 = compile("raise ValueError", "hello.py", "exec") - with pytest.raises(ValueError): - mod.f(c0, dict(__builtins__=__builtins__), dict()) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_helpers.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_helpers.py deleted file mode 100644 index 5fa41a8524..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_helpers.py +++ /dev/null @@ -1,167 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestHPyModuleAddType(HPyTest): - def test_with_spec_only(self): - mod = self.make_module(""" - static HPyType_Spec dummy_spec = { - .name = "mytest.Dummy", - }; - - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - if (!HPyHelpers_AddType(ctx, self, "Dummy", &dummy_spec, NULL)) - { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @INIT - """) - assert not hasattr(mod, "Dummy") - mod.f() - assert isinstance(mod.Dummy, type) - assert mod.Dummy.__name__ == "Dummy" - assert isinstance(mod.Dummy(), mod.Dummy) - - def test_with_spec_and_params(self): - mod = self.make_module(""" - static HPyType_Spec dummy_spec = { - .name = "mytest.Dummy", - }; - - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPyType_SpecParam param[] = { - { HPyType_SpecParam_Base, ctx->h_LongType }, - { (HPyType_SpecParam_Kind)0 } - }; - if (!HPyHelpers_AddType(ctx, self, "Dummy", &dummy_spec, param)) - { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(f) - @INIT - """) - assert not hasattr(mod, "Dummy") - mod.f() - assert isinstance(mod.Dummy, type) - assert mod.Dummy.__name__ == "Dummy" - assert isinstance(mod.Dummy(), mod.Dummy) - assert isinstance(mod.Dummy(), int) - assert mod.Dummy() == 0 - assert mod.Dummy(3) == 3 - - def test_pack_args_and_keywords(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(pack, "pack", HPyFunc_KEYWORDS) - static HPy pack_impl(HPyContext *ctx, HPy self, const HPy *args, - size_t nargs, HPy kwnames) - { - HPy out[] = { HPy_NULL, HPy_NULL }; - HPy result; - if (!HPyHelpers_PackArgsAndKeywords(ctx, args, nargs, kwnames, - &out[0], &out[1])) { - return HPy_NULL; - } - for (int i=0; i < 2; i++) { - if (HPy_IsNull(out[i])) { - out[i] = HPy_Dup(ctx, ctx->h_None); - } - } - result = HPyTuple_FromArray(ctx, out, 2); - for (int i=0; i < 2; i++) { - HPy_Close(ctx, out[i]); - } - return result; - } - - HPyDef_METH(pack_error, "pack_error", HPyFunc_O) - static HPy pack_error_impl(HPyContext *ctx, HPy self, HPy arg) - { - int success; - HPy t = HPy_NULL; - HPy d = HPy_NULL; - const HPy args[] = { ctx->h_None, ctx->h_True, ctx->h_False }; - size_t nargs = sizeof(args); - uint64_t mode = HPyLong_AsUInt64_t(ctx, arg); - switch (mode) { - case 0: - success = HPyHelpers_PackArgsAndKeywords(ctx, args, nargs, - HPy_NULL, NULL, &d); - break; - case 1: - success = HPyHelpers_PackArgsAndKeywords(ctx, args, nargs, - HPy_NULL, &t, NULL); - break; - case 2: - success = HPyHelpers_PackArgsAndKeywords(ctx, args, nargs, - HPy_NULL, NULL, NULL); - break; - case 3: - success = HPyHelpers_PackArgsAndKeywords(ctx, args, nargs, - ctx->h_None, &t, &d); - break; - default: - success = 0; - HPyErr_SetString(ctx, ctx->h_ValueError, - "unknown test mode"); - break; - } - if (success) - return HPy_Dup(ctx, ctx->h_None); - return HPy_NULL; - } - - @EXPORT(pack) - @EXPORT(pack_error) - @INIT - """) - assert mod.pack() == (None, None) - assert mod.pack(1, '2', b'3') == ((1, '2', b'3'), None) - assert mod.pack(1, '2', b'3', a='b', c='d') == ((1, '2', b'3'), dict(a='b', c='d')) - assert mod.pack(a='b', c='d') == (None, dict(a='b', c='d')) - for mode in range(3): - with pytest.raises(SystemError): - mod.pack_error(mode) - with pytest.raises(TypeError): - mod.pack_error(3) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybuildvalue.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybuildvalue.py deleted file mode 100644 index dc6e468c5a..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybuildvalue.py +++ /dev/null @@ -1,257 +0,0 @@ -# Copyright (c) 2022, 2024, 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. -import pytest -from .support import HPyTest - - -class TestBuildValue(HPyTest): - - def make_tests_module(self, test_cases): - # Creates a module with function "f", that takes index of a test case - # to execute. Argument test_cases should be a tuple with first item - # being C code of the test case. - # Generates, e.g.: case 0: return HPy_BuildValue(...); - test_cases_c_code = ["case {}: {}; break;".format(i, case[0]) for i, case in enumerate(test_cases)] - return self.make_module(""" - #include - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - {{ - switch (HPyLong_AsLong(ctx, arg)) {{ - {test_cases} - default: - HPyErr_SetString(ctx, ctx->h_ValueError, "Wrong test case number"); - return HPy_NULL; - }} - }} - - @EXPORT(f) - @INIT - """.format(test_cases='\n'.join(test_cases_c_code))) - - def test_formats(self): - test_cases = [ - ('return HPy_BuildValue(ctx, "");', None), - ('return HPy_BuildValue(ctx, "i", 42);', 42), - ('return HPy_BuildValue(ctx, "i", 0);', 0), - ('return HPy_BuildValue(ctx, "i", -1);', -1), - ('return HPy_BuildValue(ctx, "I", 33);', 33), - ('return HPy_BuildValue(ctx, "k", 1);', 1), - ('return HPy_BuildValue(ctx, "K", 6543);', 6543), - ('return HPy_BuildValue(ctx, "n", 9876);', 9876), - ('return HPy_BuildValue(ctx, "l", 345L);', 345), - ('return HPy_BuildValue(ctx, "l", -876L);', -876), - ('return HPy_BuildValue(ctx, "L", 545LL);', 545), - ('return HPy_BuildValue(ctx, "L", -344LL);', -344), - ('return HPy_BuildValue(ctx, "f", 0.25f);', 0.25), - ('return HPy_BuildValue(ctx, "d", 0.25);', 0.25), - ('return HPy_BuildValue(ctx, "ii", -1, 1);', (-1, 1)), - ('return HPy_BuildValue(ctx, "(i)", -1);', (-1,)), - ('return HPy_BuildValue(ctx, "(i,i)", -1, 1);', (-1, 1)), - ('return HPy_BuildValue(ctx, "(ii)", -1, 1);', (-1, 1)), - ('return HPy_BuildValue(ctx, "s", "test string");', 'test string'), - ('return HPy_BuildValue(ctx, "[ii]", 4, 2);', [4, 2]), - ('return HPy_BuildValue(ctx, "[i,i]", 4, 2);', [4, 2]), - ('return HPy_BuildValue(ctx, "[is]", 4, "2");', [4, '2']), - ('return HPy_BuildValue(ctx, "[]");', []), - ('return HPy_BuildValue(ctx, "[(is)((f)[kk])i]", 4, "str", 0.25, 4, 2, 14267);', - [(4, 'str'), ((0.25,), [4, 2]), 14267]), - ('return HPy_BuildValue(ctx, "{s:i, s:f}", "A", 4, "B", 0.25);', - {'A':4, "B":0.25}), - ('return HPy_BuildValue(ctx, "{s:(i,i), s:f}", "A", 4, 4, "B", 0.25);', - {'A':(4, 4), "B":0.25}), - ('return HPy_BuildValue(ctx, "[{s:(i,i), s:f},i]", "A", 4, 4, "B", 0.25, 42);', - [{'A':(4, 4), "B":0.25}, 42]), - ('return HPy_BuildValue(ctx, "({s:(i,i), s:f},[i])", "A", 4, 4, "B", 0.25, 42);', - ({'A':(4, 4), "B":0.25}, [42])), - ] - mod = self.make_tests_module(test_cases) - for i, (code, expected) in enumerate(test_cases): - actual = mod.f(i) - assert actual == expected, code - - def test_bad_formats(self): - test_cases = [ - ('return HPy_BuildValue(ctx, "(q)", 42);', - "bad format char 'q' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "(i", 42);', - "unmatched '(' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "[i", 42);', - "unmatched '[' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "([(i)k", 42);', - "unmatched '(' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "(i]", 42);', - "unmatched '(' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "[i)", 42);', - "unmatched '[' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "N", 42);', - "HPy_BuildValue does not support the 'N' formatting unit."), - ('return HPy_BuildValue(ctx, "{i:i", "foo", 42);', - "unmatched '{' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "{i:i,,}", "foo", 42);', - "unexpected ',' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "{i:ii,}", "foo", 42, 42);', - "missing ',' in the format string passed to HPy_BuildValue"), - ('return HPy_BuildValue(ctx, "{i}", 42);', - "missing ':' in the format string passed to HPy_BuildValue"), - ] - import pytest - mod = self.make_tests_module(test_cases) - for i, (code, expected_error) in enumerate(test_cases): - with pytest.raises(SystemError) as e: - mod.f(i) - assert expected_error in str(e.value), code - - def test_O_and_aliases(self): - mod = self.make_module(""" - HPyDef_METH(fo, "fo", HPyFunc_O) - static HPy fo_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_BuildValue(ctx, "O", arg); - } - - HPyDef_METH(fs, "fs", HPyFunc_O) - static HPy fs_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_BuildValue(ctx, "S", arg); - } - - @EXPORT(fo) - @EXPORT(fs) - @INIT - """) - - class Dummy: - pass - obj = Dummy() - assert mod.fo(obj) == obj - assert mod.fs(obj) == obj - - def test_O_with_new_object(self): - # HPy_BuildValue does not steal the reference to the object passed as 'O', - # the caller still needs to close it, otherwise -> handle leak - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy o = HPyLong_FromLong(ctx, 42); - HPy result; - if (HPyLong_AsLong(ctx, arg)) { - result = HPy_BuildValue(ctx, "O", o); - } else { - result = HPy_BuildValue(ctx, "(dO)", 0.25, o); - } - HPy_Close(ctx, o); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f(0) == (0.25, 42) - assert mod.f(1) == 42 - - def test_O_with_null(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(no_msg, "no_msg", HPyFunc_O) - static HPy no_msg_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyLong_AsLong(ctx, arg)) { - return HPy_BuildValue(ctx, "O", HPy_NULL); - } else { - return HPy_BuildValue(ctx, "(iO)", 42, HPy_NULL); - } - } - - HPyDef_METH(with_msg, "with_msg", HPyFunc_O) - static HPy with_msg_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPyErr_SetString(ctx, ctx->h_ValueError, "Some err msg that will be asserted"); - return no_msg_impl(ctx, self, arg); - } - - @EXPORT(with_msg) - @EXPORT(no_msg) - @INIT - """) - for i in [0, 1]: - with pytest.raises(ValueError) as e: - mod.with_msg(i) - assert "Some err msg that will be asserted" in str(e.value) - for i in [0, 1]: - with pytest.raises(SystemError) as e: - mod.no_msg(i) - assert 'HPy_NULL object passed to HPy_BuildValue' in str(e.value) - - - def test_OO_pars_with_new_objects(self): - mod = self.make_module(""" - #include - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy o1 = HPyLong_FromLong(ctx, 1); - HPy o2 = HPyLong_FromLong(ctx, 2); - HPy result = HPy_BuildValue(ctx, "(OO)", o1, o2); - HPy_Close(ctx, o1); - HPy_Close(ctx, o2); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f(None) == (1, 2) - - def test_num_limits(self): - test_cases = [ - ('return HPy_BuildValue(ctx, "(ii)", INT_MIN, INT_MAX);',), - ('return HPy_BuildValue(ctx, "(ll)", LONG_MIN, LONG_MAX);',), - ('return HPy_BuildValue(ctx, "(LL)", LLONG_MIN, LLONG_MAX);',), - ('return HPy_BuildValue(ctx, "(iI)", -1, UINT_MAX);',), - ('return HPy_BuildValue(ctx, "(ik)", -1, ULONG_MAX);',), - ('return HPy_BuildValue(ctx, "(iK)", -1, ULLONG_MAX);',), - ('return HPy_BuildValue(ctx, "(nn)", HPY_SSIZE_T_MIN, HPY_SSIZE_T_MAX);',), - ] - mod = self.make_tests_module(test_cases) - for i, (test,) in enumerate(test_cases): - result = mod.f(i) - assert result[0] < 0, test - assert result[1] > 0, test diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybytes.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybytes.py deleted file mode 100644 index 3068d26c81..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpybytes.py +++ /dev/null @@ -1,154 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - -class TestBytes(HPyTest): - - def test_Check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyBytes_Check(ctx, arg)) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - class MyBytes(bytes): - pass - - assert mod.f(b'hello') is True - assert mod.f('hello') is False - assert mod.f(MyBytes(b'hello')) is True - - def test_Size(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t a = HPyBytes_Size(ctx, arg); - HPy_ssize_t b = HPyBytes_GET_SIZE(ctx, arg); - return HPyLong_FromLongLong(ctx, 10 * a + b); - } - @EXPORT(f) - @INIT - """) - assert mod.f(b'hello') == 55 - - def test_AsString(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - long res = 0; - HPy_ssize_t n = HPyBytes_Size(ctx, arg); - const char *buf = HPyBytes_AsString(ctx, arg); - for(int i=0; ih_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - class MyDict(dict): - pass - - assert mod.f({}) is True - assert mod.f([]) is False - assert mod.f(MyDict()) is True - - def test_New(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyDict_New(ctx); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == {} - - def test_set_item(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy dict = HPyDict_New(ctx); - if (HPy_IsNull(dict)) - return HPy_NULL; - HPy val = HPyLong_FromLong(ctx, 1234); - if (HPy_SetItem(ctx, dict, arg, val) == -1) - return HPy_NULL; - HPy_Close(ctx, val); - return dict; - } - @EXPORT(f) - @INIT - """) - assert mod.f('hello') == {'hello': 1234} - - def test_get_item(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy key = HPyUnicode_FromString(ctx, "hello"); - if (HPy_IsNull(key)) - return HPy_NULL; - HPy val = HPy_GetItem(ctx, arg, key); - HPy_Close(ctx, key); - if (HPy_IsNull(val)) { - HPyErr_Clear(ctx); - return HPy_Dup(ctx, ctx->h_None); - } - return val; - } - @EXPORT(f) - @INIT - """) - assert mod.f({'hello': 1}) == 1 - assert mod.f({}) is None - - def test_keys(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h_dict = HPy_Is(ctx, arg, ctx->h_None) ? HPy_NULL : arg; - return HPyDict_Keys(ctx, h_dict); - } - @EXPORT(f) - @INIT - """) - - class SubDict(dict): - def keys(self): - return [1, 2, 3] - assert mod.f({}) == [] - assert mod.f({'hello': 1}) == ['hello'] - assert mod.f(SubDict(hello=1)) == ['hello'] - with pytest.raises(SystemError): - mod.f(None) - with pytest.raises(SystemError): - mod.f(42) - - def test_copy(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h_dict = HPy_Is(ctx, arg, ctx->h_None) ? HPy_NULL : arg; - return HPyDict_Copy(ctx, h_dict); - } - @EXPORT(f) - @INIT - """) - dicts = ({}, {'hello': 1}) - for d in dicts: - d_copy = mod.f(d) - assert d_copy == d - assert d_copy is not d - with pytest.raises(SystemError): - mod.f(None) - with pytest.raises(SystemError): - mod.f(42) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyerr.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyerr.py deleted file mode 100644 index d036216569..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyerr.py +++ /dev/null @@ -1,732 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from .support import HPyTest, SUPPORTS_SYS_EXECUTABLE, trampoline - - -class TestErr(HPyTest): - - def test_NoMemory(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyErr_NoMemory(ctx); - } - @EXPORT(f) - @INIT - """) - with pytest.raises(MemoryError): - mod.f() - - def test_FatalError(self, python_subprocess, fatal_exit_code): - mod = self.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPy_FatalError(ctx, "boom!"); - // note: no 'return' statement. This also tests that - // the call above is known to never return---otherwise, - // we get a warning from the missing 'return' and it is - // turned into an error. - } - @EXPORT(f) - @INIT - """) - if not SUPPORTS_SYS_EXECUTABLE: - # if sys.executable is not available (e.g. inside pypy app-level) - # tests, then skip the rest of this test - return - # subprocess is not importable in pypy app-level tests - result = python_subprocess.run(mod, "mod.f()") - assert result.returncode == fatal_exit_code - assert result.stdout == b"" - # In Python 3.9, the Py_FatalError() function was replaced with a macro - # which automatically prepends the name of the current function, so - # we have to allow for that difference here: - stderr_msg = result.stderr.splitlines()[0] - assert stderr_msg.startswith(b"Fatal Python error: ") - assert stderr_msg.endswith(b": boom!") - - def test_HPyErr_Occurred(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPyLong_AsLong(ctx, arg); - if (HPyErr_Occurred(ctx)) { - return HPyErr_SetString(ctx, ctx->h_ValueError, "hello world"); - } - return HPyLong_FromLong(ctx, -1002); - } - @EXPORT(f) - @INIT - """) - assert mod.f(-10) == -1002 - with pytest.raises(ValueError) as exc: - mod.f("not an integer") - assert str(exc.value) == 'hello world' - - def test_HPyErr_Cleared(self): - import sys - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPyErr_SetString(ctx, ctx->h_ValueError, "hello world"); - HPyErr_Clear(ctx); - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - assert mod.f() is None - assert sys.exc_info() == (None, None, None) - - def test_HPyErr_SetString(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyErr_SetString(ctx, ctx->h_ValueError, "error message"); - } - - HPyDef_METH(g, "g", HPyFunc_NOARGS) - static HPy g_impl(HPyContext *ctx, HPy self) - { - HPyErr_SetString(ctx, ctx->h_ValueError, "error message"); - return HPy_NULL; - } - - @EXPORT(g) - @EXPORT(f) - @INIT - """) - with pytest.raises(ValueError) as err: - mod.f() - assert str(err.value) == "error message" - - with pytest.raises(ValueError) as err: - mod.g() - assert str(err.value) == "error message" - - def test_HPyErr_SetObject(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyErr_SetObject(ctx, ctx->h_ValueError, arg); - } - @EXPORT(f) - @INIT - """) - with pytest.raises(ValueError) as err: - mod.f(ValueError("error message")) - assert str(err.value) == "error message" - - def test_HPyErr_SetFromErrno(self): - import pytest - import errno - mod = self.make_module(""" - #include - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy type) - {{ - errno = {errno}; - return HPyErr_SetFromErrno(ctx, type); - }} - @EXPORT(f) - @INIT - """.format(errno = errno.EINVAL)) - for type in [OSError, TimeoutError]: - with pytest.raises(type) as err: - mod.f(type) - - assert err.value.errno == errno.EINVAL - - def test_HPyErr_SetFromErrnoWithFilenameObjects(self): - import pytest - import errno - mod = self.make_module(""" - #include - - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - {{ - HPy type, file1, file2; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &type, &file1, &file2)) - return HPy_NULL; - - errno = {errno}; - if (HPy_Is(ctx, file2, ctx->h_None)) {{ - return HPyErr_SetFromErrnoWithFilenameObject(ctx, type, file1); - }} else {{ - return HPyErr_SetFromErrnoWithFilenameObjects(ctx, type, file1, file2); - }} - }} - @EXPORT(f) - @INIT - """.format(errno = errno.EINVAL)) - file1 = "some/file/name/to/be/asserted" - with pytest.raises(OSError) as err: - mod.f(OSError, file1, None) - assert err.value.errno == errno.EINVAL - assert err.value.filename == file1 - - file2 = "some/different/file/name/to/be/asserted" - with pytest.raises(OSError) as err: - mod.f(OSError, file1, file2) - assert err.value.errno == errno.EINVAL - assert err.value.filename == file1 - assert err.value.filename2 == file2 - - def test_HPyErr_SetFromErrnoWithFilename(self): - import pytest - import errno - mod = self.make_module(""" - #include - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy type) - {{ - errno = {errno}; - return HPyErr_SetFromErrnoWithFilename(ctx, type, "Some message that will be asserted"); - }} - @EXPORT(f) - @INIT - """.format(errno = errno.EINVAL)) - with pytest.raises(OSError) as err: - mod.f(OSError) - - assert err.value.errno == errno.EINVAL - assert "Some message that will be asserted" in str(err.value) - - def test_h_exceptions(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h_dict, h_err; - h_dict = HPyDict_New(ctx); - HPy_SetItem_s(ctx, h_dict, "BaseException", ctx->h_BaseException); - HPy_SetItem_s(ctx, h_dict, "Exception", ctx->h_Exception); - HPy_SetItem_s(ctx, h_dict, "StopAsyncIteration", ctx->h_StopAsyncIteration); - HPy_SetItem_s(ctx, h_dict, "StopIteration", ctx->h_StopIteration); - HPy_SetItem_s(ctx, h_dict, "GeneratorExit", ctx->h_GeneratorExit); - HPy_SetItem_s(ctx, h_dict, "ArithmeticError", ctx->h_ArithmeticError); - HPy_SetItem_s(ctx, h_dict, "LookupError", ctx->h_LookupError); - HPy_SetItem_s(ctx, h_dict, "AssertionError", ctx->h_AssertionError); - HPy_SetItem_s(ctx, h_dict, "AttributeError", ctx->h_AttributeError); - HPy_SetItem_s(ctx, h_dict, "BufferError", ctx->h_BufferError); - HPy_SetItem_s(ctx, h_dict, "EOFError", ctx->h_EOFError); - HPy_SetItem_s(ctx, h_dict, "FloatingPointError", ctx->h_FloatingPointError); - HPy_SetItem_s(ctx, h_dict, "OSError", ctx->h_OSError); - HPy_SetItem_s(ctx, h_dict, "ImportError", ctx->h_ImportError); - HPy_SetItem_s(ctx, h_dict, "ModuleNotFoundError", ctx->h_ModuleNotFoundError); - HPy_SetItem_s(ctx, h_dict, "IndexError", ctx->h_IndexError); - HPy_SetItem_s(ctx, h_dict, "KeyError", ctx->h_KeyError); - HPy_SetItem_s(ctx, h_dict, "KeyboardInterrupt", ctx->h_KeyboardInterrupt); - HPy_SetItem_s(ctx, h_dict, "MemoryError", ctx->h_MemoryError); - HPy_SetItem_s(ctx, h_dict, "NameError", ctx->h_NameError); - HPy_SetItem_s(ctx, h_dict, "OverflowError", ctx->h_OverflowError); - HPy_SetItem_s(ctx, h_dict, "RuntimeError", ctx->h_RuntimeError); - HPy_SetItem_s(ctx, h_dict, "RecursionError", ctx->h_RecursionError); - HPy_SetItem_s(ctx, h_dict, "NotImplementedError", ctx->h_NotImplementedError); - HPy_SetItem_s(ctx, h_dict, "SyntaxError", ctx->h_SyntaxError); - HPy_SetItem_s(ctx, h_dict, "IndentationError", ctx->h_IndentationError); - HPy_SetItem_s(ctx, h_dict, "TabError", ctx->h_TabError); - HPy_SetItem_s(ctx, h_dict, "ReferenceError", ctx->h_ReferenceError); - HPy_SetItem_s(ctx, h_dict, "SystemError", ctx->h_SystemError); - HPy_SetItem_s(ctx, h_dict, "SystemExit", ctx->h_SystemExit); - HPy_SetItem_s(ctx, h_dict, "TypeError", ctx->h_TypeError); - HPy_SetItem_s(ctx, h_dict, "UnboundLocalError", ctx->h_UnboundLocalError); - HPy_SetItem_s(ctx, h_dict, "ValueError", ctx->h_ValueError); - HPy_SetItem_s(ctx, h_dict, "ZeroDivisionError", ctx->h_ZeroDivisionError); - HPy_SetItem_s(ctx, h_dict, "BlockingIOError", ctx->h_BlockingIOError); - HPy_SetItem_s(ctx, h_dict, "BrokenPipeError", ctx->h_BrokenPipeError); - HPy_SetItem_s(ctx, h_dict, "ChildProcessError", ctx->h_ChildProcessError); - HPy_SetItem_s(ctx, h_dict, "ConnectionError", ctx->h_ConnectionError); - HPy_SetItem_s(ctx, h_dict, "ConnectionAbortedError", ctx->h_ConnectionAbortedError); - HPy_SetItem_s(ctx, h_dict, "ConnectionRefusedError", ctx->h_ConnectionRefusedError); - HPy_SetItem_s(ctx, h_dict, "ConnectionResetError", ctx->h_ConnectionResetError); - HPy_SetItem_s(ctx, h_dict, "FileExistsError", ctx->h_FileExistsError); - HPy_SetItem_s(ctx, h_dict, "FileNotFoundError", ctx->h_FileNotFoundError); - HPy_SetItem_s(ctx, h_dict, "InterruptedError", ctx->h_InterruptedError); - HPy_SetItem_s(ctx, h_dict, "IsADirectoryError", ctx->h_IsADirectoryError); - HPy_SetItem_s(ctx, h_dict, "NotADirectoryError", ctx->h_NotADirectoryError); - HPy_SetItem_s(ctx, h_dict, "PermissionError", ctx->h_PermissionError); - HPy_SetItem_s(ctx, h_dict, "ProcessLookupError", ctx->h_ProcessLookupError); - HPy_SetItem_s(ctx, h_dict, "TimeoutError", ctx->h_TimeoutError); - h_err = HPy_GetItem(ctx, h_dict, arg); - if (HPy_IsNull(h_err)) { - HPy_FatalError(ctx, "missing exception type"); - } - HPyErr_SetString(ctx, h_err, "error message"); - HPy_Close(ctx, h_dict); - HPy_Close(ctx, h_err); - return HPy_NULL; - } - @EXPORT(f) - @INIT - """) - - def check_exception(cls): - with pytest.raises(cls): - mod.f(cls.__name__) - - check_exception(BaseException) - check_exception(Exception) - check_exception(StopAsyncIteration) - check_exception(StopIteration) - check_exception(GeneratorExit) - check_exception(ArithmeticError) - check_exception(LookupError) - check_exception(AssertionError) - check_exception(AttributeError) - check_exception(BufferError) - check_exception(EOFError) - check_exception(FloatingPointError) - check_exception(OSError) - check_exception(ImportError) - check_exception(ModuleNotFoundError) - check_exception(IndexError) - check_exception(KeyError) - check_exception(KeyboardInterrupt) - check_exception(MemoryError) - check_exception(NameError) - check_exception(OverflowError) - check_exception(RuntimeError) - check_exception(RecursionError) - check_exception(NotImplementedError) - check_exception(SyntaxError) - check_exception(IndentationError) - check_exception(TabError) - check_exception(ReferenceError) - check_exception(SystemError) - check_exception(SystemExit) - check_exception(TypeError) - check_exception(UnboundLocalError) - check_exception(ValueError) - check_exception(ZeroDivisionError) - check_exception(BlockingIOError) - check_exception(BrokenPipeError) - check_exception(ChildProcessError) - check_exception(ConnectionError) - check_exception(ConnectionAbortedError) - check_exception(ConnectionRefusedError) - check_exception(ConnectionResetError) - check_exception(FileExistsError) - check_exception(FileNotFoundError) - check_exception(InterruptedError) - check_exception(IsADirectoryError) - check_exception(NotADirectoryError) - check_exception(PermissionError) - check_exception(ProcessLookupError) - check_exception(TimeoutError) - # EnvironmentError and IOError are not explicitly defined by HPy - # but they work because they are actually OSError. - check_exception(EnvironmentError) - check_exception(IOError) - - def test_h_unicode_exceptions(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy h_key, h_args, h_kw; - HPy h_dict, h_err, h_err_value; - - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &h_key, &h_args, &h_kw)) - return HPy_NULL; - - h_dict = HPyDict_New(ctx); - if (HPy_IsNull(h_dict)) { - return HPy_NULL; - } - HPy_SetItem_s(ctx, h_dict, "UnicodeError", ctx->h_UnicodeError); - HPy_SetItem_s(ctx, h_dict, "UnicodeEncodeError", ctx->h_UnicodeEncodeError); - HPy_SetItem_s(ctx, h_dict, "UnicodeDecodeError", ctx->h_UnicodeDecodeError); - HPy_SetItem_s(ctx, h_dict, "UnicodeTranslateError", ctx->h_UnicodeTranslateError); - - h_err = HPy_GetItem(ctx, h_dict, h_key); - if (HPy_IsNull(h_err)) { - HPy_Close(ctx, h_dict); - return HPy_NULL; - } - h_err_value = HPy_CallTupleDict(ctx, h_err, h_args, h_kw); - if (HPy_IsNull(h_err_value)) { - HPy_Close(ctx, h_dict); - HPy_Close(ctx, h_err); - return HPy_NULL; - } - - HPyErr_SetObject(ctx, h_err, h_err_value); - HPy_Close(ctx, h_dict); - HPy_Close(ctx, h_err); - HPy_Close(ctx, h_err_value); - return HPy_NULL; - } - @EXPORT(f) - @INIT - """) - - def check_exception(cls, *args, **kw): - with pytest.raises(cls): - mod.f(cls.__name__, args, kw) - - check_exception(UnicodeError) - check_exception( - UnicodeEncodeError, "utf-8", "object", 0, 2, "reason" - ) - check_exception( - UnicodeDecodeError, "utf-8", b"object", 0, 2, "reason" - ) - check_exception(UnicodeTranslateError, "object", 0, 2, "reason") - - def test_h_warnings(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy h_dict, h_err; - h_dict = HPyDict_New(ctx); - HPy_SetItem_s(ctx, h_dict, "Warning", ctx->h_Warning); - HPy_SetItem_s(ctx, h_dict, "UserWarning", ctx->h_UserWarning); - HPy_SetItem_s(ctx, h_dict, "DeprecationWarning", ctx->h_DeprecationWarning); - HPy_SetItem_s(ctx, h_dict, "PendingDeprecationWarning", ctx->h_PendingDeprecationWarning); - HPy_SetItem_s(ctx, h_dict, "SyntaxWarning", ctx->h_SyntaxWarning); - HPy_SetItem_s(ctx, h_dict, "RuntimeWarning", ctx->h_RuntimeWarning); - HPy_SetItem_s(ctx, h_dict, "FutureWarning", ctx->h_FutureWarning); - HPy_SetItem_s(ctx, h_dict, "ImportWarning", ctx->h_ImportWarning); - HPy_SetItem_s(ctx, h_dict, "UnicodeWarning", ctx->h_UnicodeWarning); - HPy_SetItem_s(ctx, h_dict, "BytesWarning", ctx->h_BytesWarning); - HPy_SetItem_s(ctx, h_dict, "ResourceWarning", ctx->h_ResourceWarning); - h_err = HPy_GetItem(ctx, h_dict, arg); - if (HPy_IsNull(h_err)) { - HPy_FatalError(ctx, "missing exception type"); - } - HPyErr_SetString(ctx, h_err, "error message"); - HPy_Close(ctx, h_dict); - HPy_Close(ctx, h_err); - return HPy_NULL; - } - @EXPORT(f) - @INIT - """) - - def check_warning(cls): - with pytest.raises(cls): - mod.f(cls.__name__) - - check_warning(Warning) - check_warning(UserWarning) - check_warning(DeprecationWarning) - check_warning(PendingDeprecationWarning) - check_warning(SyntaxWarning) - check_warning(RuntimeWarning) - check_warning(FutureWarning) - check_warning(ImportWarning) - check_warning(UnicodeWarning) - check_warning(BytesWarning) - check_warning(ResourceWarning) - - def test_HPyErr_WarnEx(self): - import warnings - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - switch (HPyLong_AsLong(ctx, arg)) { - case 0: - HPyErr_WarnEx(ctx, ctx->h_RuntimeWarning, "warn qzp", 1); - break; - case 1: - HPyErr_WarnEx(ctx, ctx->h_FutureWarning, "warn rtq", 2); - break; - case 2: - HPyErr_WarnEx(ctx, HPy_NULL, "warn null", 1); - break; - } - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - - # NOTE: trampoline is defined in support.py - def check_warning(arg, category, message, file): - with warnings.catch_warnings(record=True) as warnings_list: - trampoline(mod.f, arg) - assert len(warnings_list) == 1, str(category) - w = warnings_list[-1] - assert issubclass(w.category, category), str(category) - assert str(w.message) == message, str(category) - assert w.filename.endswith(file), str(category) - - check_warning(0, RuntimeWarning, "warn qzp", "support.py") - check_warning(1, FutureWarning, "warn rtq", "test_hpyerr.py") - check_warning(2, Warning, "warn null", "support.py") - - - def test_errorval_returned_by_api_functions_hpy(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy a = HPy_NULL; - HPy b = HPy_NULL; - HPy res; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - res = HPy_TrueDivide(ctx, a, b); - - // the point of the test is to check that in case of error - // HPy_Div returns HPy_NULL - if (HPy_IsNull(res)) { - HPyErr_Clear(ctx); - return HPyLong_FromLong(ctx, -42); - } - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f(21, 3) == 7 - assert mod.f(21, 0) == -42 - - def test_errorval_returned_by_api_functions_int(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t length = HPy_Length(ctx, arg); - if (length == -1) { - HPyErr_Clear(ctx); - return HPyLong_FromLong(ctx, -42); - } - return HPyLong_FromLong(ctx, (long) length); - } - @EXPORT(f) - @INIT - """) - assert mod.f([100, 200, 300]) == 3 - assert mod.f(None) == -42 - - def test_HPyErr_NewException(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - // MSVC doesn't allow "static HPy h_FooErr = HPy_NULL" - // so we do an initialization dance instead. - static int foo_error_initialized = 0; - static HPy h_FooError; - HPy arg; - HPy h_base = HPy_NULL; - HPy h_dict = HPy_NULL; - HPy h_doc = HPy_NULL; - - if (!foo_error_initialized) { - foo_error_initialized = 1; - h_FooError = HPy_NULL; - } - - if (!HPyArg_Parse(ctx, NULL, args, nargs, "O|OOO", &arg, &h_base, &h_dict, &h_doc)) { - return HPy_NULL; - } - - if (!HPy_IsTrue(ctx, arg)) { - // cleanup and close the FooError which we created earlier - if (!HPy_IsNull(h_FooError)) - HPy_Close(ctx, h_FooError); - return HPy_Dup(ctx, ctx->h_None); - } - - if(HPy_Is(ctx, h_base, ctx->h_None)) { - h_base = HPy_NULL; - } - - if(HPy_Is(ctx, h_dict, ctx->h_None)) { - h_dict = HPy_NULL; - } - - if(HPy_Is(ctx, h_doc, ctx->h_None)) { - h_FooError = HPyErr_NewException(ctx, "mytest.FooError", h_base, h_dict); - } else { - // we use bytes because ATM we don't have HPyUnicode_AsUTF8 or similar - h_FooError = HPyErr_NewExceptionWithDoc(ctx, "mytest.FooError", - HPyBytes_AsString(ctx, h_doc), h_base, h_dict); - } - - if (HPy_IsNull(h_FooError)) - return HPy_NULL; - HPyErr_SetString(ctx, h_FooError, "hello"); - return HPy_NULL; - } - @EXPORT(f) - @INIT - """) - - def check(base, dict_, doc): - with pytest.raises(Exception) as exc: - mod.f(True, base, dict_, doc) - assert issubclass(exc.type, RuntimeError if base else Exception) - assert exc.type.__name__ == 'FooError', exc.value - assert exc.type.__module__ == 'mytest' - if doc is None: - assert exc.type.__doc__ is None - else: - assert exc.type.__doc__ == doc.decode("utf-8") - - if dict_: - assert exc.type.__dict__["test"] == "pass" - mod.f(False, None, None, None) # cleanup - - check(base=None, dict_=None, doc=None) - check(base=None, dict_=None, doc=b'mytest') - check(base=None, dict_={"test": "pass"}, doc=None) - check(base=None, dict_={"test": "pass"}, doc=b'mytest') - check(base=RuntimeError, dict_=None, doc=None) - check(base=RuntimeError, dict_=None, doc=b'mytest') - check(base=RuntimeError, dict_={"test": "pass"}, doc=None) - check(base=RuntimeError, dict_={"test": "pass"}, doc=b'mytest') - - def test_exception_matches(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPyTracker ht; - HPy fun, fun_args; - HPy expected_exc_type; - HPy tmp; - HPy result; - - if (!HPyArg_Parse(ctx, &ht, args, nargs, "OOO", &fun, &fun_args, &expected_exc_type)) { - return HPy_NULL; - } - - tmp = HPy_CallTupleDict(ctx, fun, fun_args, HPy_NULL); - if (HPy_IsNull(tmp)) { - if (HPyErr_ExceptionMatches(ctx, expected_exc_type)) { - HPyErr_Clear(ctx); - result = HPy_Dup(ctx, ctx->h_True); - } else { - // propagate the unexpected exception to the caller - result = HPy_NULL; - } - } else { - HPy_Close(ctx, tmp); - result = HPy_Dup(ctx, ctx->h_False); - } - - HPyTracker_Close(ctx, ht); - return result; - } - @EXPORT(f) - @INIT - """) - - class DummyException(Exception): - pass - - def raise_exception(e): - raise e - - def do_not_raise_exception(*args): - return None - - exc_types = (StopAsyncIteration, StopIteration, GeneratorExit, ArithmeticError, LookupError, AssertionError, - AttributeError, BufferError, EOFError, FloatingPointError, OSError, ImportError, ModuleNotFoundError, IndexError, - KeyError, KeyboardInterrupt, MemoryError, NameError, OverflowError, RuntimeError, RecursionError, NotImplementedError, - SyntaxError, IndentationError, TabError, ReferenceError, SystemError, SystemExit, TypeError, UnboundLocalError, - ValueError, ZeroDivisionError, BlockingIOError, BrokenPipeError, ChildProcessError, ConnectionError, ConnectionAbortedError, - ConnectionRefusedError, ConnectionResetError, FileExistsError, FileNotFoundError, InterruptedError, IsADirectoryError, - NotADirectoryError, PermissionError, ProcessLookupError, TimeoutError) - - # just a sanity check of the extension function - assert not mod.f(do_not_raise_exception, tuple(), DummyException) - - # test with "leaf" exception - assert mod.f(raise_exception, (DummyException, ), DummyException) - with pytest.raises(DummyException): - mod.f(raise_exception, (DummyException, ), StopIteration) - - # test exception subclass - for exc_type in exc_types: - assert mod.f(raise_exception, (exc_type, ), BaseException) - assert mod.f(raise_exception, (DummyException, ), BaseException) - - # match whole tuple - for exc_type in exc_types: - res = mod.f(raise_exception, (exc_type, ), exc_types) - with pytest.raises(DummyException): - mod.f(raise_exception, (DummyException, ), exc_types) - - def test_HPyErr_WriteUnraisable(self, python_subprocess): - mod = self.compile_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPyErr_SetString(ctx, ctx->h_ValueError, "error message"); - HPyErr_WriteUnraisable(ctx, HPy_NULL); - return HPyBool_FromLong(ctx, HPyErr_Occurred(ctx)); - } - @EXPORT(f) - @INIT - """) - if not SUPPORTS_SYS_EXECUTABLE: - # if sys.executable is not available (e.g. inside pypy app-level) - # tests, then skip the rest of this test - return - # subprocess is not importable in pypy app-level tests - result = python_subprocess.run(mod, "mod.f()") - assert result.returncode == 0 - - - def test_HPyErr_Format(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyErr_Format(ctx, ctx->h_ValueError, "Formatted '%S' and %d", arg, 42); - } - @EXPORT(f) - @INIT - """) - with pytest.raises(ValueError, match="Formatted 'error message' and 42"): - mod.f("error message") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyfield.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyfield.py deleted file mode 100644 index 82a9997637..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyfield.py +++ /dev/null @@ -1,464 +0,0 @@ -# Copyright (c) 2022, 2023, 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. - -""" -NOTE: these tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -import pytest -from .support import HPyTest, DefaultExtensionTemplate - -class PairTemplate(DefaultExtensionTemplate): - - def DEFINE_PairObject(self): - return """ - typedef struct { - HPyField a; - HPyField b; - } PairObject; - - HPyType_HELPERS(PairObject); - """ - - def DEFINE_Pair_new(self): - return """ - HPyDef_SLOT(Pair_new, HPy_tp_new) - static HPy Pair_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - HPy a; - HPy b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - PairObject *pair; - HPy h_obj = HPy_New(ctx, cls, &pair); - HPyField_Store(ctx, h_obj, &pair->a, a); - HPyField_Store(ctx, h_obj, &pair->b, b); - return h_obj; - } - """ - - def DEFINE_Pair_traverse(self): - return """ - HPyDef_SLOT(Pair_traverse, HPy_tp_traverse) - static int Pair_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg) - { - PairObject *p = (PairObject *)self; - HPy_VISIT(&p->a); - HPy_VISIT(&p->b); - return 0; - } - """ - - def DEFINE_Pair_set_a(self): - return """ - HPyDef_METH(Pair_set_a, "set_a", HPyFunc_O) - static HPy Pair_set_a_impl(HPyContext *ctx, HPy self, HPy arg) - { - PairObject *pair = PairObject_AsStruct(ctx, self); - HPyField_Store(ctx, self, &pair->a, arg); - return HPy_Dup(ctx, ctx->h_None); - } - """ - - def DEFINE_Pair_get_ab(self): - return """ - HPyDef_METH(Pair_get_a, "get_a", HPyFunc_NOARGS) - static HPy Pair_get_a_impl(HPyContext *ctx, HPy self) - { - PairObject *pair = PairObject_AsStruct(ctx, self); - if (HPy_IsNull(pair->a)) - return HPyUnicode_FromString(ctx, ""); - return HPyField_Load(ctx, self, pair->a); - } - - HPyDef_METH(Pair_get_b, "get_b", HPyFunc_NOARGS) - static HPy Pair_get_b_impl(HPyContext *ctx, HPy self) - { - PairObject *pair = PairObject_AsStruct(ctx, self); - if (HPy_IsNull(pair->b)) - return HPyUnicode_FromString(ctx, ""); - return HPyField_Load(ctx, self, pair->b); - } - """ - - pair_type_flags = 'HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_HAVE_GC' - def PAIR_TYPE_FLAGS(self, flags): - self.pair_type_flags = flags - - def EXPORT_PAIR_TYPE(self, *defines): - defines += ('NULL',) - defines = ', '.join(defines) - self.EXPORT_TYPE('"Pair"', "Pair_spec") - return """ - static HPyDef *Pair_defines[] = { %s }; - static HPyType_Spec Pair_spec = { - .name = "mytest.Pair", - .basicsize = sizeof(PairObject), - .flags = %s, - .defines = Pair_defines - }; - """ % (defines, self.pair_type_flags) - -class TestHPyField(HPyTest): - - ExtensionTemplate = PairTemplate - - def test_gc_track(self): - if not self.supports_refcounts(): - import pytest - pytest.skip("CPython only") - import sys - # Test that we correctly call PyObject_GC_Track on CPython. The - # easiest way is to check whether the object is in - # gc.get_objects(). - import gc - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse) - @INIT - """) - p = mod.Pair("hello", "world") - assert gc.is_tracked(p) - - def test_gc_track_no_gc_flag(self): - if not self.supports_refcounts(): - import pytest - pytest.skip("CPython only") - # Same code as test_gc_track, but without HPy_TPFLAGS_HAVE_GC. On - # CPython, the object is NOT tracked. - import gc - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - - @PAIR_TYPE_FLAGS(HPy_TPFLAGS_DEFAULT) - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse) - @INIT - """) - p = mod.Pair("hello", "world") - assert not gc.is_tracked(p) - - @pytest.mark.tp_traverse - def test_tp_traverse(self): - import sys - import gc - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse) - @INIT - """) - p = mod.Pair("hello", "world") - referents = gc.get_referents(p) - referents.sort() - assert referents == ['hello', 'world'] - - def test_tp_traverse_sanity_check(self): - import pytest - with pytest.raises(ValueError): - self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - - // here we are defining a type with HPy_TPFLAGS_HAVE_GC but - // without providing a tp_traverse - @EXPORT_PAIR_TYPE(&Pair_new) - @INIT - """) - - def test_store_load(self): - import sys - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_get_ab - @DEFINE_Pair_traverse - - @PAIR_TYPE_FLAGS(HPy_TPFLAGS_DEFAULT) - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse, &Pair_get_a, &Pair_get_b) - @INIT - """) - p = mod.Pair("hello", "world") - assert p.get_a() == 'hello' - assert p.get_b() == 'world' - # - # check the refcnt - if self.supports_refcounts(): - a = object() - a_refcnt = sys.getrefcount(a) - p2 = mod.Pair(a, None) - assert sys.getrefcount(a) == a_refcnt + 1 - assert p2.get_a() is a - assert sys.getrefcount(a) == a_refcnt + 1 - - def test_store_overwrite(self): - import sys - mod = self.make_module(""" - #include - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_get_ab - @DEFINE_Pair_traverse - @DEFINE_Pair_set_a - - HPyDef_METH(Pair_clear_a, "clear_a", HPyFunc_NOARGS) - static HPy Pair_clear_a_impl(HPyContext *ctx, HPy self) - { - PairObject *pair = PairObject_AsStruct(ctx, self); - HPyField_Store(ctx, self, &pair->a, HPy_NULL); - return HPy_Dup(ctx, ctx->h_None); - } - - @PAIR_TYPE_FLAGS(HPy_TPFLAGS_DEFAULT) - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse, &Pair_get_a, &Pair_get_b, &Pair_set_a, &Pair_clear_a) - @INIT - """) - p = mod.Pair("hello", "world") - assert p.get_a() == 'hello' - assert p.get_b() == 'world' - p.set_a('foo') - assert p.get_a() == 'foo' - p.clear_a() - assert p.get_a() == '' - p.set_a('bar') - assert p.get_a() == 'bar' - # - # check the refcnt - if self.supports_refcounts(): - a = object() - a_refcnt = sys.getrefcount(a) - p2 = mod.Pair(a, None) - assert sys.getrefcount(a) == a_refcnt + 1 - assert p2.get_a() is a - p2.set_a('foo') - assert sys.getrefcount(a) == a_refcnt - p2.set_a(a) - assert sys.getrefcount(a) == a_refcnt + 1 - p2.clear_a() - assert sys.getrefcount(a) == a_refcnt - p2.clear_a() - assert sys.getrefcount(a) == a_refcnt - - def test_automatic_tp_dealloc(self): - import sys - if not self.supports_refcounts(): - import pytest - pytest.skip("CPython only") - - import sys - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse) - @INIT - """) - a = object() - b = object() - p = mod.Pair(a, b) - a_cnt = sys.getrefcount(a) - b_cnt = sys.getrefcount(b) - del p - assert sys.getrefcount(a) == a_cnt - 1 - assert sys.getrefcount(b) == b_cnt - 1 - - @pytest.mark.syncgc - def test_automatic_tp_clear(self): - if not self.supports_refcounts(): - import pytest - pytest.skip("CPython only") - import sys - - import gc - mod = self.make_module(""" - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - @DEFINE_Pair_set_a - - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse, &Pair_set_a) - @INIT - """) - def count_pairs(): - return len([obj for obj in gc.get_objects() if type(obj) is mod.Pair]) - assert count_pairs() == 0 - p1 = mod.Pair(None, 'hello') - p2 = mod.Pair(None, 'world') - p1.set_a(p2) - p2.set_a(p1) - assert count_pairs() == 2 - # - try: - gc.disable() - del p1 - del p2 - assert count_pairs() == 2 - finally: - gc.enable() - # - gc.collect() - assert count_pairs() == 0 - - @pytest.mark.syncgc - def test_tp_finalize(self): - # Tests the contract of tp_finalize: what it should see - # if called from within HPyField_Store - mod = self.make_module(""" - #include - - @DEFINE_PairObject - @DEFINE_Pair_new - @DEFINE_Pair_traverse - @DEFINE_Pair_set_a - - static bool saw_expected_finalize_call; - static bool unexpected_finalize_call; - static bool test_finished; - - // During the test we check our assumptions with an assert to play - // nicely with pytest, but if the finalizer gets called after the - // test has finished, we have no choice but to abort to signal - // the error - static void on_unexpected_finalize_call() { - if (test_finished) - abort(); - else - unexpected_finalize_call = true; - } - - HPyDef_SLOT(Pair_finalize, HPy_tp_finalize) - static void Pair_finalize_impl(HPyContext *ctx, HPy to_be_finalized) - { - PairObject *pair = PairObject_AsStruct(ctx, to_be_finalized); - - // Check that we were called on the right object: 'to_be_finalized' - HPy to_be_finalized_b = HPyField_Load(ctx, to_be_finalized, pair->b); - if (!HPy_Is(ctx, to_be_finalized_b, ctx->h_True)) { - HPy_Close(ctx, to_be_finalized_b); - // This is OK to happen after the test was finished - unexpected_finalize_call = true; - return; - } - HPy_Close(ctx, to_be_finalized_b); - - // Check that we were not called twice - if (saw_expected_finalize_call) { - printf("tp_finalize called twice for 'to_be_finalized'\\\n"); - on_unexpected_finalize_call(); - return; - } - - HPy owner = HPy_NULL, owner_a = HPy_NULL, owner_b = HPy_NULL; - owner = HPyField_Load(ctx, to_be_finalized, pair->a); - PairObject *owner_pair = PairObject_AsStruct(ctx, owner); - - // Check that 'to_be_finalized'->a really points to 'owner' - owner_b = HPyField_Load(ctx, owner, owner_pair->b); - if (!HPy_Is(ctx, owner_b, ctx->h_False)) { - printf("to_be_finalized'->a != 'owner'\\\n"); - on_unexpected_finalize_call(); - goto owner_cleanup; - } - - // Whatever we see in owner->a must not be 'to_be_finalized' - // For CPython it should be NULL, because Pair_finalize should - // be called immediately when the field is swapped to new value - if (HPyField_IsNull(owner_pair->a)) { - saw_expected_finalize_call = true; - goto owner_cleanup; - } - - // For GC based implementations, it can be already the 42 if - // Pair_finalize gets called later - owner_a = HPyField_Load(ctx, owner, owner_pair->a); - if (HPyLong_AsLong(ctx, owner_a) == 42) { - saw_expected_finalize_call = true; - goto owner_cleanup; - } - - HPyErr_Clear(ctx); // if the field was not a long at all - printf("unexpected value of the field: %p\\\n", (void*) owner_a._i); - on_unexpected_finalize_call(); - owner_cleanup: - HPy_Close(ctx, owner); - HPy_Close(ctx, owner_a); - HPy_Close(ctx, owner_b); - } - - HPyDef_METH(check_finalize_calls, "check_finalize_calls", HPyFunc_NOARGS) - static HPy check_finalize_calls_impl(HPyContext *ctx, HPy self) - { - test_finished = true; - if (!unexpected_finalize_call && saw_expected_finalize_call) - return HPy_Dup(ctx, ctx->h_True); - else - return HPy_Dup(ctx, ctx->h_False); - } - - @EXPORT(check_finalize_calls) - @EXPORT_PAIR_TYPE(&Pair_new, &Pair_traverse, &Pair_finalize, &Pair_set_a) - @INIT - """) - to_be_finalized = mod.Pair(None, True) - owner = mod.Pair(to_be_finalized, False) - to_be_finalized.set_a(owner) - del to_be_finalized - # Now 'to_be_finalized' is referenced only by 'owner'. - # By setting the field to the new value, the object originally pointed - # by 'to_be_finalized' becomes garbage. In CPython, this should - # immediately trigger tp_finalize, in other impls it may also - # trigger tp_finalize at that point or any later point. - # In any case, tp_finalize should not see the original value of the - # field anymore. - owner.set_a(42) - from gc import collect - collect() - assert mod.check_finalize_calls() diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyglobal.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyglobal.py deleted file mode 100644 index b5d43ee628..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyglobal.py +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright (c) 2022, 2023, 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestHPyGlobal(HPyTest): - - def test_basics(self): - mod = self.make_module(""" - HPyGlobal myglobal; - - HPyDef_METH(setg, "setg", HPyFunc_O) - static HPy setg_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPyGlobal_Store(ctx, &myglobal, arg); - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(getg, "getg", HPyFunc_NOARGS) - static HPy getg_impl(HPyContext *ctx, HPy self) - { - return HPyGlobal_Load(ctx, myglobal); - } - - @EXPORT(setg) - @EXPORT(getg) - @EXPORT_GLOBAL(myglobal) - @INIT - """) - obj = {'hello': 'world'} - assert mod.setg(obj) is None - assert mod.getg() is obj - - def test_twoglobals(self): - mod = self.make_module(""" - HPyGlobal myglobal1; - HPyGlobal myglobal2; - - HPyDef_METH(setg1, "setg1", HPyFunc_O) - static HPy setg1_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPyGlobal_Store(ctx, &myglobal1, arg); - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(setg2, "setg2", HPyFunc_O) - static HPy setg2_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPyGlobal_Store(ctx, &myglobal2, arg); - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(getg1, "getg1", HPyFunc_NOARGS) - static HPy getg1_impl(HPyContext *ctx, HPy self) - { - return HPyGlobal_Load(ctx, myglobal1); - } - - HPyDef_METH(getg2, "getg2", HPyFunc_NOARGS) - static HPy getg2_impl(HPyContext *ctx, HPy self) - { - return HPyGlobal_Load(ctx, myglobal2); - } - - @EXPORT(setg1) - @EXPORT(setg2) - @EXPORT(getg1) - @EXPORT(getg2) - @EXPORT_GLOBAL(myglobal1) - @EXPORT_GLOBAL(myglobal2) - @INIT - """) - obj1 = {'hello': 'world'} - obj2 = {'foo': 'bar'} - assert mod.setg1(obj1) is None - assert mod.setg2(obj2) is None - assert mod.getg1() is obj1 - assert mod.getg2() is obj2 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyimport.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyimport.py deleted file mode 100644 index bf9b2edb55..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyimport.py +++ /dev/null @@ -1,47 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2024, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - -class TestImport(HPyTest): - - def test_ImportModule(self): - import pytest - import sys - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy h_name) - { - // we use bytes because ATM we don't have HPyUnicode_AsUTF8 or similar - const char *name = HPyBytes_AsString(ctx, h_name); - if (name == NULL) - return HPy_NULL; - return HPyImport_ImportModule(ctx, name); - } - @EXPORT(f) - @INIT - """) - sys2 = mod.f(b'sys') - assert sys is sys2 - with pytest.raises(ImportError): - mod.f(b'This is the name of a module which does not exist, hopefully') diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylist.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylist.py deleted file mode 100644 index 1c3eaa1d96..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylist.py +++ /dev/null @@ -1,100 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - -class TestList(HPyTest): - - def test_Check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyList_Check(ctx, arg)) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - class MyList(list): - pass - - assert mod.f([]) is True - assert mod.f('hello') is False - assert mod.f(MyList()) is True - - def test_New(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyList_New(ctx, 0); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == [] - - def test_Append(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy list = HPyList_New(ctx, 0); - if (HPy_IsNull(list)) - return HPy_NULL; - if (HPyList_Append(ctx, list, arg) == -1) - return HPy_NULL; - if (HPyList_Append(ctx, list, arg) == -1) - return HPy_NULL; - return list; - } - @EXPORT(f) - @INIT - """) - assert mod.f(42) == [42, 42] - - def test_ListBuilder(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy h_self, HPy h_arg) - { - HPyListBuilder builder = HPyListBuilder_New(ctx, 3); - HPyListBuilder_Set(ctx, builder, 0, h_arg); - HPyListBuilder_Set(ctx, builder, 1, ctx->h_True); - HPy h_num = HPyLong_FromLong(ctx, -42); - if (HPy_IsNull(h_num)) - { - HPyListBuilder_Cancel(ctx, builder); - return HPy_NULL; - } - HPyListBuilder_Set(ctx, builder, 2, h_num); - HPy_Close(ctx, h_num); - HPy h_list = HPyListBuilder_Build(ctx, builder); - return h_list; - } - @EXPORT(f) - @INIT - """) - assert mod.f("xy") == ["xy", True, -42] diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylong.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylong.py deleted file mode 100644 index 6a63d23428..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpylong.py +++ /dev/null @@ -1,463 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest, DefaultExtensionTemplate - -class HPyLongTemplate(DefaultExtensionTemplate): - def DEFINE_Long_From(self, type, api_suffix, val): - self.EXPORT("from_{type}_{val}".format(type=type, val=val)) - return """ - HPyDef_METH(from_{type}_{val}, "from_{type}_{val}", HPyFunc_NOARGS) - static HPy from_{type}_{val}_impl(HPyContext *ctx, HPy self) - {{ - {type} a = {val}; - return HPyLong_From{api_suffix}(ctx, a); - }} - """.format(type=type, val=val, api_suffix=api_suffix) - - def DEFINE_Long_As(self, type, api_suffix, from_suffix=None): - self.EXPORT("as_{api_suffix}".format(api_suffix=api_suffix)) - if not from_suffix: - from_suffix = api_suffix - return """ - HPyDef_METH(as_{api_suffix}, "as_{api_suffix}", HPyFunc_O) - static HPy as_{api_suffix}_impl(HPyContext *ctx, HPy self, HPy arg) - {{ - {type} a = HPyLong_As{api_suffix}(ctx, arg); - if (a == (({type})-1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_From{from_suffix}(ctx, a * 2); - }} - """.format(type=type, api_suffix=api_suffix, from_suffix=from_suffix) - -class TestLong(HPyTest): - - ExtensionTemplate = HPyLongTemplate - - def unsigned_long_bits(self): - """ Return the number of bits in an unsigned long. """ - import struct - unsigned_long_bytes = len(struct.pack('l', 0)) - return 8 * unsigned_long_bytes - - def magic_int(self, v): - """ Return an instance of a class that implements __int__ - and returns value v. - """ - class MagicInt(object): - def __int__(self): - return v - return MagicInt() - - def magic_index(self, v): - """ Return an instance of a class that implements __index__ - and returns value v. - """ - class MagicIndex(object): - def __index__(self): - return v - return MagicIndex() - - def python_supports_magic_index(self): - """ Return True if the Python version is 3.8 or later and thus - should support calling __index__ in the various HPyLong_As... - methods. - """ - import sys - vi = sys.version_info - return (vi.major > 3 or (vi.major == 3 and vi.minor >= 8)) - - def python_supports_magic_int(self): - """ Return True if the Python version is 3.9 or earlier and thus - should support calling __int__ on non-int based types in some - HPyLong_As... methods. - """ - import sys - vi = sys.version_info - assert vi.major >= 3 - return (vi.major == 3 and vi.minor <= 9) - - def test_Long_FromFixedWidth(self): - mod = self.make_module(""" - @DEFINE_Long_From(int32_t, Int32_t, INT32_MAX) - @DEFINE_Long_From(int32_t, Int32_t, INT32_MIN) - @DEFINE_Long_From(uint32_t, UInt32_t, UINT32_MAX) - @DEFINE_Long_From(int64_t, Int64_t, INT64_MAX) - @DEFINE_Long_From(int64_t, Int64_t, INT64_MIN) - @DEFINE_Long_From(uint64_t, UInt64_t, UINT64_MAX) - @INIT - """) - assert mod.from_int32_t_INT32_MAX() == 2147483647 - assert mod.from_int32_t_INT32_MIN() == -2147483648 - assert mod.from_uint32_t_UINT32_MAX() == 4294967295 - assert mod.from_int64_t_INT64_MAX() == 9223372036854775807 - assert mod.from_int64_t_INT64_MIN() == -9223372036854775808 - assert mod.from_uint64_t_UINT64_MAX() == 18446744073709551615 - - def test_Long_FromLong(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - long a = 500; - return HPyLong_FromLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 500 - - def test_Long_AsFixedWidth(self): - import pytest - mod = self.make_module(""" - @DEFINE_Long_As(int32_t, Int32_t) - @DEFINE_Long_As(uint32_t, UInt32_t) - @DEFINE_Long_As(uint32_t, UInt32_tMask, UInt32_t) - @DEFINE_Long_As(int64_t, Int64_t) - @DEFINE_Long_As(uint64_t, UInt64_t) - @DEFINE_Long_As(uint64_t, UInt64_tMask, UInt64_t) - @INIT - """) - - assert mod.as_Int32_t(45) == 90 - assert mod.as_Int32_t(-45) == -90 - # doubling INT32_MAX is like a left-shift and will result in a negative value - assert mod.as_Int32_t(2147483647) < 0 - with pytest.raises(TypeError): - mod.as_Int32_t("this is not a number") - if self.python_supports_magic_int(): - assert mod.as_Int32_t(self.magic_int(2)) == 4 - if self.python_supports_magic_index(): - assert mod.as_Int32_t(self.magic_index(2)) == 4 - - assert mod.as_UInt32_t(45) == 90 - with pytest.raises(OverflowError): - mod.as_UInt32_t(-45) - assert mod.as_UInt32_t(2147483647) == 4294967294 - - assert mod.as_UInt32_tMask(0xffffffffffffffff) == 0xfffffffe - - assert mod.as_Int64_t(45) == 90 - assert mod.as_Int64_t(-45) == -90 - # doubling INT32_MAX is like a left-shift and will result in a negative value - assert mod.as_Int64_t(2147483647) == 4294967294 - assert mod.as_Int64_t(9223372036854775807) < 0 - with pytest.raises(TypeError): - mod.as_Int64_t("this is not a number") - - assert mod.as_UInt64_t(45) == 90 - with pytest.raises(OverflowError): - mod.as_UInt64_t(-45) - assert mod.as_UInt64_t(9223372036854775807) == 18446744073709551614 - - assert mod.as_UInt64_tMask(0xffffffffffffffffff) == 0xfffffffffffffffe - - def test_Long_AsLong(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - long a = HPyLong_AsLong(ctx, arg); - if (a == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromLong(ctx, a * 2); - } - @EXPORT(f) - @INIT - """) - assert mod.f(45) == 90 - with pytest.raises(TypeError): - mod.f("this is not a number") - if self.python_supports_magic_int(): - assert mod.f(self.magic_int(2)) == 4 - if self.python_supports_magic_index(): - assert mod.f(self.magic_index(2)) == 4 - - def test_Long_FromUnsignedLong(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - unsigned long a = 500; - return HPyLong_FromUnsignedLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 500 - - def test_Long_AsUnsignedLong(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - unsigned long a = HPyLong_AsUnsignedLong(ctx, arg); - if ((a == (unsigned long) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromUnsignedLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(45) == 45 - with pytest.raises(OverflowError): - mod.f(-91) - with pytest.raises(TypeError): - mod.f("this is not a number") - with pytest.raises(TypeError): - mod.f(self.magic_int(2)) - with pytest.raises(TypeError): - mod.f(self.magic_index(2)) - - def test_Long_AsUnsignedLongMask(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - unsigned long a = HPyLong_AsUnsignedLongMask(ctx, arg); - if ((a == (unsigned long) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromUnsignedLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(45) == 45 - assert mod.f(-1) == 2**self.unsigned_long_bits() - 1 - with pytest.raises(TypeError): - mod.f("this is not a number") - if self.python_supports_magic_int(): - assert mod.f(self.magic_int(2)) == 2 - if self.python_supports_magic_index(): - assert mod.f(self.magic_index(2)) == 2 - - def test_Long_FromLongLong(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - // take a value which doesn't fit in 32 bit - long long val = 2147483648; - return HPyLong_FromLongLong(ctx, val); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 2147483648 - - def test_Long_AsLongLong(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - long long a = HPyLong_AsLongLong(ctx, arg); - if ((a == (long long) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromLongLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(2147483648) == 2147483648 - assert mod.f(-2147483648) == -2147483648 - with pytest.raises(TypeError): - mod.f("this is not a number") - if self.python_supports_magic_int(): - assert mod.f(self.magic_int(2)) == 2 - if self.python_supports_magic_index(): - assert mod.f(self.magic_index(2)) == 2 - - def test_Long_FromUnsignedLongLong(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - // take a value which doesn't fit in unsigned 32 bit - unsigned long long val = 4294967296; - return HPyLong_FromUnsignedLongLong(ctx, val); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 4294967296 - - def test_Long_AsUnsignedLongLong(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - unsigned long long a = HPyLong_AsUnsignedLongLong(ctx, arg); - if ((a == (unsigned long long) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromUnsignedLongLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(4294967296) == 4294967296 - with pytest.raises(OverflowError): - mod.f(-4294967296) - with pytest.raises(TypeError): - mod.f("this is not a number") - with pytest.raises(TypeError): - mod.f(self.magic_int(2)) - with pytest.raises(TypeError): - mod.f(self.magic_index(2)) - - def test_Long_AsUnsignedLongLongMask(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - unsigned long long a = HPyLong_AsUnsignedLongLongMask(ctx, arg); - if ((a == (unsigned long long) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromUnsignedLongLong(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(45) == 45 - assert mod.f(-1) == 2**64 - 1 - with pytest.raises(TypeError): - mod.f("this is not a number") - if self.python_supports_magic_int(): - assert mod.f(self.magic_int(2)) == 2 - if self.python_supports_magic_index(): - assert mod.f(self.magic_index(2)) == 2 - - def test_Long_FromSize_t(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - // take a value which doesn't fit in 32 bit - size_t a = 2147483648; - return HPyLong_FromSize_t(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == 2147483648 - - def test_Long_AsSize_t(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - size_t a = HPyLong_AsSize_t(ctx, arg); - if ((a == (size_t) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromSize_t(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(2147483648) == 2147483648 - with pytest.raises(OverflowError): - mod.f(-2147483648) - with pytest.raises(TypeError): - mod.f("this is not a number") - with pytest.raises(TypeError): - mod.f(self.magic_int(2)) - with pytest.raises(TypeError): - mod.f(self.magic_index(2)) - - def test_Long_FromSsize_t(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - HPy_ssize_t a = -42; - return HPyLong_FromSsize_t(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == -42 - - def test_Long_AsSsize_t(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t a = HPyLong_AsSsize_t(ctx, arg); - if ((a == (HPy_ssize_t) -1) && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyLong_FromSsize_t(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(41) == 41 - assert mod.f(-41) == -41 - with pytest.raises(TypeError): - mod.f("this is not a number") - with pytest.raises(TypeError): - mod.f(self.magic_int(2)) - with pytest.raises(TypeError): - mod.f(self.magic_index(2)) - - def test_Long_AsVoidPtr(self): - mod = self.make_module(""" - HPyDef_METH(f, "is_null", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy val) - { - void* ptr = HPyLong_AsVoidPtr(ctx, val); - if (!ptr) { - return HPy_Dup(ctx, ctx->h_True); - } else { - return HPy_Dup(ctx, ctx->h_False); - } - } - @EXPORT(f) - @INIT - """) - assert mod.is_null(0) == True - assert mod.is_null(10) == False - - def test_Long_AsDouble(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - double a = HPyLong_AsDouble(ctx, arg); - if (a == -1.0 && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyFloat_FromDouble(ctx, a); - } - @EXPORT(f) - @INIT - """) - assert mod.f(45) == 45.0 - with pytest.raises(TypeError): - mod.f("this is not a number") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpymodule.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpymodule.py deleted file mode 100644 index db44fdd9cf..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpymodule.py +++ /dev/null @@ -1,306 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import types -import pytest -from .support import HPyTest - -class TestModule(HPyTest): - def test_HPyModule_simple(self): - """ - The simplest fully declarative module creation. - """ - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 42); - } - - static HPyDef *moduledefs[] = { &f, NULL }; - static HPyModuleDef moduledef = { - .doc = "Some doc", - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - assert mod.__name__ == mod.__spec__.name - assert mod.__doc__ == "Some doc" - assert mod.f() == 42 - - def test_HPyModule_custom_exec(self): - """ - Module that defines several exec slots. HPy specifies that the slots - will be executed in declaration order. Exec slots can add new types, - and other objects into the module. They can also initialize other - objects. The exec slots will be called on every new instance of the - module, for example, when it is imported in several subinterpreters. - """ - mod = self.make_module(""" - HPyDef_SLOT(exec1, HPy_mod_exec) - static int exec1_impl(HPyContext *ctx, HPy mod) - { - HPy list = HPyList_New(ctx, 0); - if (HPy_IsNull(list)) - return -1; - HPy_SetAttr_s(ctx, mod, "data", list); - HPy_Close(ctx, list); - return 0; - } - - HPyDef_SLOT(exec2, HPy_mod_exec) - static int exec2_impl(HPyContext *ctx, HPy mod) - { - HPy list = HPy_GetAttr_s(ctx, mod, "data"); - if (HPy_IsNull(list)) - return -1; - if (HPy_Length(ctx, list) != 0) { - HPyErr_SetString(ctx, ctx->h_RuntimeError, "Unexpected: len(list) != 0"); - return -1; - } - HPy item = HPyLong_FromLong(ctx, 42); - HPyList_Append(ctx, list, item); - HPy_Close(ctx, item); - HPy_Close(ctx, list); - return 0; - } - - static HPyDef *moduledefs[] = { - &exec1, - &exec2, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = "Some doc", - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - assert mod.data == [42] - - def test_HPyModule_custom_create_returns_non_module(self): - """ - Module that defines create slot that returns non module object. This - is, for the time being, the only supported way to implement the module - 'create' slot. HPy intentionally does not expose direct API to create - a module object. Module objects are created for the extension by the - runtime and the extension can only populate that module object in the - init slots. - """ - mod = self.make_module(""" - HPyDef_SLOT(create, HPy_mod_create) - static HPy create_impl(HPyContext *ctx, HPy spec) - { - HPy result = HPy_NULL, dict = HPy_NULL, ns_type = HPy_NULL; - - HPy types = HPyImport_ImportModule(ctx, "types"); - if (HPy_IsNull(types)) - return HPy_NULL; - - ns_type = HPy_GetAttr_s(ctx, types, "SimpleNamespace"); - if (HPy_IsNull(types)) - goto cleanup; - dict = HPyDict_New(ctx); - HPy_SetItem_s(ctx, dict, "spec", spec); - result = HPy_CallTupleDict(ctx, ns_type, HPy_NULL, dict); - if (HPy_IsNull(result)) - goto cleanup; - - cleanup: - HPy_Close(ctx, dict); - HPy_Close(ctx, types); - HPy_Close(ctx, ns_type); - return result; - } - - static HPyDef *moduledefs[] = { - &create, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = NULL, - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - assert isinstance(mod, types.SimpleNamespace) - assert mod.spec is mod.__spec__ - - def test_HPyModule_error_when_create_returns_module(self): - """ - The HPy_mod_create slot cannot return a builtin module object. - HPy does not expose any API to create builtin module objects and, until - there are any actual use-cases, the purpose of the 'create' slot is to - create non-builtin-module objects. - """ - expected_message = "HPy_mod_create slot returned a builtin module " \ - "object. This is currently not supported." - with pytest.raises(SystemError, match=expected_message): - self.make_module(""" - HPyDef_SLOT(create, HPy_mod_create) - static HPy create_impl(HPyContext *ctx, HPy spec) - { - return HPyImport_ImportModule(ctx, "types"); - } - - static HPyDef *moduledefs[] = { - &create, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = NULL, - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - - def test_HPyModule_create_raises(self): - with pytest.raises(RuntimeError, match="Test error"): - self.make_module(""" - HPyDef_SLOT(create, HPy_mod_create) - static HPy create_impl(HPyContext *ctx, HPy spec) - { - HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); - return HPy_NULL; - } - - static HPyDef *moduledefs[] = { - &create, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = NULL, - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - - def test_HPyModule_create_and_nondefault_values(self): - expected_message = r'^HPyModuleDef defines a HPy_mod_create slot.*' - with pytest.raises(SystemError, match=expected_message): - self.make_module(""" - HPyDef_SLOT(create, HPy_mod_create) - static HPy create_impl(HPyContext *ctx, HPy spec) - { - HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); - return HPy_NULL; - } - - static HPyDef *moduledefs[] = { - &create, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = "Some doc - this is non-default", - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - - def test_HPyModule_create_and_exec_slots(self): - expected_message = r'^HPyModuleDef defines a HPy_mod_create slot.*' - with pytest.raises(SystemError, match=expected_message): - self.make_module(""" - HPyDef_SLOT(create, HPy_mod_create) - static HPy create_impl(HPyContext *ctx, HPy spec) - { - HPyErr_SetString(ctx, ctx->h_RuntimeError, "Test error"); - return HPy_NULL; - } - - HPyDef_SLOT(exec, HPy_mod_exec) - static int exec_impl(HPyContext *ctx, HPy mod) - { - return 0; - } - - static HPyDef *moduledefs[] = { - &create, - &exec, - NULL - }; - - static HPyModuleDef moduledef = { - .doc = NULL, - .size = 0, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) - - def test_HPyModule_negative_size(self): - """ - The simplest fully declarative module creation. - """ - expected_message = "HPy does not permit HPyModuleDef.size < 0" - with pytest.raises(SystemError, match=expected_message): - self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 42); - } - - static HPyDef *moduledefs[] = { &f, NULL }; - static HPyModuleDef moduledef = { - .doc = "Some doc", - .size = -1, - .legacy_methods = NULL, - .defines = moduledefs, - .globals = NULL, - }; - - @HPy_MODINIT(moduledef) - """) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyslice.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyslice.py deleted file mode 100644 index bda7743fdc..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyslice.py +++ /dev/null @@ -1,133 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - -class TestSlice(HPyTest): - - def test_unpack(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(sizeof_ssize_t, "sizeof_ssize_t", HPyFunc_NOARGS) - static HPy sizeof_ssize_t_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, sizeof(HPy_ssize_t)); - } - - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t start, stop, step; - HPy h_start, h_stop, h_step; - if (HPySlice_Unpack(ctx, arg, &start, &stop, &step)) - return HPy_NULL; - - h_start = HPyLong_FromSsize_t(ctx, start); - h_stop = HPyLong_FromSsize_t(ctx, stop); - h_step = HPyLong_FromSsize_t(ctx, step); - HPy result = HPyTuple_Pack(ctx, 3, h_start, h_stop, h_step); - HPy_Close(ctx, h_start); - HPy_Close(ctx, h_stop); - HPy_Close(ctx, h_step); - return result; - } - @EXPORT(f) - @EXPORT(sizeof_ssize_t) - @INIT - """) - - ssize_t_max = (1 << (mod.sizeof_ssize_t() * 8 - 1)) - 1 - ssize_t_min = -(1 << (mod.sizeof_ssize_t() * 8 - 1)) - assert mod.f(slice(2, 20, 2)) == (2, 20, 2) - assert mod.f(slice(4, 20)) == (4, 20, 1) - assert mod.f(slice(5, (1 << 129))) == (5, ssize_t_max, 1) - assert mod.f(slice(13, -27, -1)) == (13, -27, -1) - assert mod.f(slice(ssize_t_min - 1000, ssize_t_max + 1000, 1)) == (ssize_t_min, ssize_t_max, 1) - assert mod.f(slice(ssize_t_max, 0, -ssize_t_max-1000)) == (ssize_t_max, 0, -ssize_t_max) - assert mod.f(slice(None, 10, 1)) == (0, 10, 1) - assert mod.f(slice(None, 10, -1)) == (ssize_t_max, 10, -1) - assert mod.f(slice(None, None, -1)) == (ssize_t_max, ssize_t_min, -1) - assert mod.f(slice(None, None, None)) == (0, ssize_t_max, 1) - assert mod.f(slice(13, None, None)) == (13, ssize_t_max, 1) - assert mod.f(slice(13, None, -1)) == (13, ssize_t_min, -1) - with pytest.raises(ValueError): - mod.f(slice(1, 10, 0)) - with pytest.raises(TypeError): - mod.f(slice(1, 10, "1")) - with pytest.raises(TypeError): - mod.f(slice(1, "10", 1)) - with pytest.raises(TypeError): - mod.f(slice("0", 10, 1)) - - def test_adjust_indices(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy_ssize_t length, start, stop, step; - - if (nargs != 4) { - HPyErr_SetString(ctx, ctx->h_TypeError, - "expected exactly 4 arguments"); - return HPy_NULL; - } - - if (HPyArg_Parse(ctx, NULL, args, nargs, "nnnn", - &length, &start, &stop, &step) < 0) { - return HPy_NULL; - } - length = HPySlice_AdjustIndices(ctx, length, &start, &stop, step); - return HPy_BuildValue(ctx, "nnnn", length, start, stop, step); - } - @EXPORT(f) - @INIT - """) - - # For the following tests, assume we work on a list: - # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - assert mod.f(10, 0, 10, 1) == (10, 0, 10, 1) - assert mod.f(10, 0, -1, 1) == (9, 0, 9, 1) - assert mod.f(10, -10, -1, 1) == (9, 0, 9, 1) - assert mod.f(10, 15, 20, 1) == (0, 10, 10, 1) - # start at index 9 and to go index 1 (inclusive; since 0 is exclusive) - assert mod.f(10, 9, 0, -1) == (9, 9, 0, -1) - assert mod.f(10, -1, -10, -1) == (9, 9, 0, -1) - assert mod.f(10, 5, 5, -1) == (0, 5, 5, -1) - - # same as above but with step 2 - assert mod.f(10, 0, 10, 2) == (5, 0, 10, 2) - assert mod.f(10, 0, -1, 2) == (5, 0, 9, 2) - assert mod.f(10, -10, -1, 2) == (5, 0, 9, 2) - assert mod.f(10, 15, 20, 2) == (0, 10, 10, 2) - assert mod.f(10, 9, 0, -2) == (5, 9, 0, -2) - assert mod.f(10, -1, -10, -2) == (5, 9, 0, -2) - assert mod.f(10, 5, 5, -2) == (0, 5, 5, -2) - - # same as above but with step 3 - assert mod.f(10, 0, 10, 3) == (4, 0, 10, 3) - assert mod.f(10, 0, -1, 3) == (3, 0, 9, 3) - assert mod.f(10, -10, -1, 3) == (3, 0, 9, 3) - assert mod.f(10, 15, 20, 3) == (0, 10, 10, 3) - assert mod.f(10, 9, 0, -3) == (3, 9, 0, -3) - assert mod.f(10, -1, -10, -3) == (3, 9, 0, -3) - assert mod.f(10, 5, 5, -3) == (0, 5, 5, -3) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpystructseq.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpystructseq.py deleted file mode 100644 index 11c6386a55..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpystructseq.py +++ /dev/null @@ -1,148 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestHPyStructSequence(HPyTest): - def test_structseq(self, hpy_abi): - import pytest - if hpy_abi == "cpython": - pytest.skip("structseq not supported on GraalPy") - mod = self.make_module(""" - static HPyStructSequence_Field structseq_fields[] = { - { "field0", "doc0" }, - { "field1", NULL }, - { NULL, NULL }, - { NULL, NULL }, - }; - - static HPyStructSequence_Field structseq_empty_fields[] = { - { NULL, NULL }, - }; - - static HPyStructSequence_Desc withfields_desc = { - .name = "mytest.WithFields", - .doc = "some doc", - .fields = structseq_fields - }; - - static HPyStructSequence_Desc nofields_desc = { - .name = "mytest.NoFields", - .fields = structseq_empty_fields - }; - - #define N 3 - - HPyDef_METH(build, "build", HPyFunc_O) - static HPy build_impl(HPyContext *ctx, HPy self, HPy type) - { - int i; - HPy elements[N]; - elements[0] = HPyLong_FromLong(ctx, 1); - elements[1] = HPyFloat_FromDouble(ctx, 2.0); - elements[2] = HPyUnicode_FromString(ctx, "3"); - HPy structseq = HPyStructSequence_New(ctx, type, N, elements); - for (i = 0; i < N; i++) - HPy_Close(ctx, elements[i]); - if (HPy_IsNull(structseq)) - return HPy_NULL; - return structseq; - } - - static void make_types(HPyContext *ctx, HPy module) - { - // cannot be done in the static initializer - structseq_fields[2].name = HPyStructSequence_UnnamedField; - - HPy h_withfields_type = HPyStructSequence_NewType(ctx, &withfields_desc); - if (HPy_IsNull(h_withfields_type)) - return; - HPy_SetAttr_s(ctx, module, "WithFields", h_withfields_type); - HPy_Close(ctx, h_withfields_type); - - HPy h_nofields_type = HPyStructSequence_NewType(ctx, &nofields_desc); - if (HPy_IsNull(h_nofields_type)) { - return; - } - HPy_SetAttr_s(ctx, module, "NoFields", h_nofields_type); - HPy_Close(ctx, h_nofields_type); - } - - @EXPORT(build) - @EXTRA_INIT_FUNC(make_types) - @INIT - """) - assert mod.WithFields.__name__ == "WithFields" - assert mod.WithFields.__doc__ == "some doc" - assert mod.WithFields.__module__ == "mytest" - assert mod.NoFields.__name__ == "NoFields" - # In Python 3.8 or earlier, we cannot pass a NULL pointer as docstring, - # so we pass the empty string. Therefore, we are testing for None or - # empty docstring. - assert not mod.NoFields.__doc__ - assert mod.NoFields.__module__ == "mytest" - - assert mod.WithFields.n_fields == 3 - assert mod.NoFields.n_fields == 0 - - s0 = mod.build(mod.WithFields) - assert s0.field0 == 1, s0.field0 - assert s0.field1 == 2.0, s0.field1 - assert s0[2] == "3", s0[2] - - with pytest.raises(TypeError): - mod.build(mod.NoFields) - - with pytest.raises(TypeError): - mod.build(str) - - - def test_invalid_descriptor(self): - import pytest - mod = self.make_module(""" - static HPyStructSequence_Field sentinel = { NULL, NULL }; - - static HPyStructSequence_Desc nofields_desc = { - .fields = &sentinel - }; - - HPyDef_METH(build, "build", HPyFunc_NOARGS) - static HPy build_impl(HPyContext *ctx, HPy self) - { - return HPyStructSequence_NewType(ctx, &nofields_desc); - } - - @EXPORT(build) - @INIT - """) - with pytest.raises(SystemError): - mod.build() diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytuple.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytuple.py deleted file mode 100644 index 90c366822b..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytuple.py +++ /dev/null @@ -1,104 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - -class TestTuple(HPyTest): - - def test_Check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyTuple_Check(ctx, arg)) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - class MyTuple(tuple): - pass - - assert mod.f(()) is True - assert mod.f([]) is False - assert mod.f(MyTuple()) is True - - def test_FromArray(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy x = HPyLong_FromLong(ctx, 42); - if (HPy_IsNull(x)) - return HPy_NULL; - HPy items[] = {self, arg, x}; - HPy res = HPyTuple_FromArray(ctx, items, 3); - HPy_Close(ctx, x); - return res; - } - @EXPORT(f) - @INIT - """) - assert mod.f('hello') == (mod, 'hello', 42) - - def test_Pack(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy x = HPyLong_FromLong(ctx, 42); - if (HPy_IsNull(x)) - return HPy_NULL; - HPy result = HPyTuple_Pack(ctx, 3, self, arg, x); - HPy_Close(ctx, x); - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f('hello') == (mod, 'hello', 42) - - def test_TupleBuilder(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy h_self, HPy h_arg) - { - HPyTupleBuilder builder = HPyTupleBuilder_New(ctx, 3); - HPyTupleBuilder_Set(ctx, builder, 0, h_arg); - HPyTupleBuilder_Set(ctx, builder, 1, ctx->h_True); - HPy h_num = HPyLong_FromLong(ctx, -42); - if (HPy_IsNull(h_num)) - { - HPyTupleBuilder_Cancel(ctx, builder); - return HPy_NULL; - } - HPyTupleBuilder_Set(ctx, builder, 2, h_num); - HPy_Close(ctx, h_num); - HPy h_tuple = HPyTupleBuilder_Build(ctx, builder); - return h_tuple; - } - @EXPORT(f) - @INIT - """) - assert mod.f("xy") == ("xy", True, -42) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype.py deleted file mode 100644 index c19148106f..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype.py +++ /dev/null @@ -1,1711 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: these tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest, DefaultExtensionTemplate -import pytest - - -class PointTemplate(DefaultExtensionTemplate): - """ - ExtensionTemplate with extra markers which helps to define again and again - a simple Point type. Note that every test can use a different combination - of markers, to test different features. - """ - - _CURRENT_STRUCT = None - - _STRUCT_BEGIN_FORMAT = """ - typedef struct {{ - """ - - _STRUCT_END_FORMAT = """ - }} {struct_name}; - {type_helpers} - """ - - _METACLASS_STRUCT_BEGIN_FORMAT = """ - typedef struct {{ - """ - - _METACLASS_STRUCT_END_FORMAT = """ - }} {struct_name}; - HPyType_HELPERS({struct_name}, HPyType_BuiltinShape_Type) - """ - - def TYPE_STRUCT_BEGIN(self, struct_name): - assert self._CURRENT_STRUCT is None - self._CURRENT_STRUCT = struct_name - return self._STRUCT_BEGIN_FORMAT.format(struct_name=struct_name) - - def TYPE_STRUCT_END(self, builtin_shape=None): - assert self._CURRENT_STRUCT is not None - struct_name = self._CURRENT_STRUCT - self._CURRENT_STRUCT = None - if builtin_shape: - type_helpers = "HPyType_HELPERS({struct_name}, {builtin_shape})"\ - .format(struct_name=struct_name, builtin_shape=builtin_shape) - else: - type_helpers = "HPyType_HELPERS({struct_name})"\ - .format(struct_name=struct_name) - return self._STRUCT_END_FORMAT.format(struct_name=struct_name, - type_helpers=type_helpers) - - def DEFAULT_SHAPE(self): - return "/* default object shape */" - - def DEFINE_PointObject(self, builtin_shape=None): - type_begin = self.TYPE_STRUCT_BEGIN("PointObject") - type_end = self.TYPE_STRUCT_END(builtin_shape=builtin_shape) - return """ - {type_begin} - long x; - long y; - {type_end} - """.format(type_begin=type_begin, type_end=type_end) - - def DEFINE_Point_new(self): - return """ - HPyDef_SLOT(Point_new, HPy_tp_new) - static HPy Point_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - long x, y; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &x, &y)) - return HPy_NULL; - PointObject *point; - HPy h_point = HPy_New(ctx, cls, &point); - if (HPy_IsNull(h_point)) - return HPy_NULL; - point->x = x; - point->y = y; - return h_point; - } - """ - - def DEFINE_Point_xy(self): - return """ - HPyDef_MEMBER(Point_x, "x", HPyMember_LONG, offsetof(PointObject, x)) - HPyDef_MEMBER(Point_y, "y", HPyMember_LONG, offsetof(PointObject, y)) - """ - - def DEFINE_Point_call(self): - return """ - HPyDef_SLOT(Point_call, HPy_tp_call) - static HPy - Point_call_impl(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) - { - long x, sum = 0; - for (size_t i = 0; i < nargs; i++) { - x = HPyLong_AsLong(ctx, args[i]); - if (x == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - sum += x; - } - if (!HPy_IsNull(kwnames)) { - x = 1; - HPy_ssize_t n = HPy_Length(ctx, kwnames); - HPy h_factor_str = HPyUnicode_FromString(ctx, "factor"); - HPy kwname; - for (HPy_ssize_t i=0; i < n; i++) { - kwname = HPy_GetItem_i(ctx, kwnames, i); - if (HPy_IsNull(kwname)) { - HPy_Close(ctx, h_factor_str); - return HPy_NULL; - } - if (HPy_RichCompareBool(ctx, h_factor_str, kwname, HPy_EQ)) { - x = HPyLong_AsLong(ctx, args[nargs + i]); - if (x == -1 && HPyErr_Occurred(ctx)) { - HPy_Close(ctx, kwname); - HPy_Close(ctx, h_factor_str); - return HPy_NULL; - } - HPy_Close(ctx, kwname); - break; - } - HPy_Close(ctx, kwname); - } - HPy_Close(ctx, h_factor_str); - } - PointObject *data = PointObject_AsStruct(ctx, callable); - sum += data->x + data->y; - return HPyLong_FromLong(ctx, sum * x); - } - """ - - def EXPORT_POINT_TYPE(self, *defines): - defines += ('NULL',) - defines = ', '.join(defines) - self.EXPORT_TYPE('"Point"', "Point_spec") - return """ - static HPyDef *Point_defines[] = { %s }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = SHAPE(PointObject), - .defines = Point_defines - }; - """ % defines - - - def METACLASS_STRUCT_BEGIN(self, struct_name): - assert self._CURRENT_STRUCT is None - self._CURRENT_STRUCT = struct_name - return self._METACLASS_STRUCT_BEGIN_FORMAT.format(struct_name=struct_name) - - def METACLASS_STRUCT_END(self): - assert self._CURRENT_STRUCT is not None - struct_name = self._CURRENT_STRUCT - self._CURRENT_STRUCT = None - return self._METACLASS_STRUCT_END_FORMAT.format(struct_name=struct_name) - - def DEFINE_DummyMeta_struct(self): - type_begin = self.METACLASS_STRUCT_BEGIN("DummyMeta") - type_end = self.METACLASS_STRUCT_END() - return """ - {type_begin} - int meta_magic; - int meta_member; - char some_more[64]; - {type_end} - """.format(type_begin=type_begin, type_end=type_end) - - def DEFINE_DummyMeta(self): - struct = self.DEFINE_DummyMeta_struct() - return """ - {struct} - - static HPyType_Spec DummyMeta_spec = {{ - .name = "mytest.DummyMeta", - .basicsize = sizeof(DummyMeta), - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - .builtin_shape = SHAPE(DummyMeta), - }}; - - static HPy make_DummyMeta(HPyContext *ctx) - {{ - HPyType_SpecParam param[] = {{ - {{ HPyType_SpecParam_Base, ctx->h_TypeType }}, - {{ (HPyType_SpecParam_Kind)0 }} - }}; - return HPyType_FromSpec(ctx, &DummyMeta_spec, param); - }} - """.format(struct=struct) - - def EXPORT_DummyMeta(self): - self.EXTRA_INIT_FUNC("register_DummyMeta") - return """ - static void register_DummyMeta(HPyContext *ctx, HPy module) - { - HPy h_DummyMeta = make_DummyMeta(ctx); - if (HPy_IsNull(h_DummyMeta)) - return; - HPy_SetAttr_s(ctx, module, "DummyMeta", h_DummyMeta); - HPy_Close(ctx, h_DummyMeta); - } - """ - - def DEFINE_Dummy_struct(self): - type_begin = self.TYPE_STRUCT_BEGIN("Dummy") - type_end = self.TYPE_STRUCT_END() - return """ - {type_begin} - int member; - {type_end} - """.format(type_begin=type_begin, type_end=type_end) - - def DEFINE_Dummy(self): - struct = self.DEFINE_Dummy_struct() - return """ - {struct} - - HPyDef_MEMBER(member, "member", HPyMember_INT, offsetof(Dummy, member)) - - static HPyDef *Dummy_defines[] = {{ - &member, - NULL - }}; - - static HPyType_Spec Dummy_spec = {{ - .name = "mytest.Dummy", - .basicsize = sizeof(Dummy), - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - .builtin_shape = SHAPE(Dummy), - .defines = Dummy_defines, - }}; - """.format(struct=struct) - - def DEFINE_meta_data_accessors(self): - return """ - HPyDef_METH(set_meta_data, "set_meta_data", HPyFunc_O) - static HPy set_meta_data_impl(HPyContext *ctx, HPy self, HPy arg) - { - DummyMeta *data = DummyMeta_AsStruct(ctx, arg); - data->meta_magic = 42; - data->meta_member = 11; - for (size_t i = 0; i < 64; ++i) - data->some_more[i] = (char) i; - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(get_meta_data, "get_meta_data", HPyFunc_O) - static HPy get_meta_data_impl(HPyContext *ctx, HPy self, HPy arg) - { - DummyMeta *data = DummyMeta_AsStruct(ctx, arg); - for (size_t i = 0; i < 64; ++i) { - if (data->some_more[i] != (char) i) { - HPyErr_SetString(ctx, ctx->h_RuntimeError, "some_more got mangled"); - return HPy_NULL; - } - } - return HPyLong_FromLong(ctx, data->meta_magic + data->meta_member); - } - - HPyDef_METH(set_member, "set_member", HPyFunc_O) - static HPy set_member_impl(HPyContext *ctx, HPy self, HPy arg) - { - Dummy *data = Dummy_AsStruct(ctx, arg); - data->member = 123614; - return HPy_Dup(ctx, ctx->h_None); - } - """ - - -class TestType(HPyTest): - - ExtensionTemplate = PointTemplate - - def test_simple_type(self): - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - assert isinstance(mod.Dummy, type) - assert mod.Dummy.__name__ == 'Dummy' - assert mod.Dummy.__module__ == 'mytest' - assert isinstance(mod.Dummy(), mod.Dummy) - - class Sub(mod.Dummy): - pass - assert isinstance(Sub(), mod.Dummy) - - def test_doc_string(self): - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - .doc = "A succinct description.", - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - assert mod.Dummy.__doc__ == "A succinct description." - - def test_HPyDef_SLOT_IMPL(self): - mod = self.make_module(""" - HPyDef_SLOT_IMPL(Dummy_repr, Dummy_repr_impl, HPy_tp_repr); - static HPy Dummy_repr_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, ""); - } - - HPyDef_SLOT_IMPL(Dummy_abs, Dummy_abs_impl, HPy_nb_absolute); - static HPy Dummy_abs_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - static HPyDef *Dummy_defines[] = { - &Dummy_repr, - &Dummy_abs, - NULL - }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - @DEFAULT_SHAPE - .defines = Dummy_defines, - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - d = mod.Dummy() - assert repr(d) == '' - assert abs(d) == 1234 - - def test_HPyDef_SLOT(self): - mod = self.make_module(""" - HPyDef_SLOT(Dummy_repr, HPy_tp_repr); - static HPy Dummy_repr_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, ""); - } - - HPyDef_SLOT(Dummy_abs, HPy_nb_absolute); - static HPy Dummy_abs_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - static HPyDef *Dummy_defines[] = { - &Dummy_repr, - &Dummy_abs, - NULL - }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .defines = Dummy_defines, - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - d = mod.Dummy() - assert repr(d) == '' - assert abs(d) == 1234 - - def test_HPyDef_METH_IMPL(self): - import pytest - mod = self.make_module(""" - HPyDef_METH_IMPL(Dummy_foo, "foo", Dummy_foo_impl, HPyFunc_O, .doc="hello") - static HPy Dummy_foo_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Add(ctx, arg, arg); - } - - HPyDef_METH_IMPL(Dummy_bar, "bar", Dummy_bar_impl, HPyFunc_NOARGS) - static HPy Dummy_bar_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - HPyDef_METH_IMPL(Dummy_identity, "identity", Dummy_identity_impl, HPyFunc_NOARGS) - static HPy Dummy_identity_impl(HPyContext *ctx, HPy self) - { - return HPy_Dup(ctx, self); - } - - static HPyDef *dummy_type_defines[] = { - &Dummy_foo, - &Dummy_bar, - &Dummy_identity, - NULL - }; - - static HPyType_Spec dummy_type_spec = { - .name = "mytest.Dummy", - .defines = dummy_type_defines, - }; - - @EXPORT_TYPE("Dummy", dummy_type_spec) - @INIT - """) - d = mod.Dummy() - assert d.foo.__doc__ == 'hello' - assert d.bar.__doc__ is None - assert d.foo(21) == 42 - assert d.bar() == 1234 - assert d.identity() is d - with pytest.raises(TypeError): - mod.Dummy.identity() - class A: pass - with pytest.raises(TypeError): - mod.Dummy.identity(A()) - - def test_HPyDef_METH(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(Dummy_foo, "foo", HPyFunc_O, .doc="hello") - static HPy Dummy_foo_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Add(ctx, arg, arg); - } - - HPyDef_METH(Dummy_bar, "bar", HPyFunc_NOARGS) - static HPy Dummy_bar_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - HPyDef_METH(Dummy_identity, "identity", HPyFunc_NOARGS) - static HPy Dummy_identity_impl(HPyContext *ctx, HPy self) - { - return HPy_Dup(ctx, self); - } - - static HPyDef *dummy_type_defines[] = { - &Dummy_foo, - &Dummy_bar, - &Dummy_identity, - NULL - }; - - static HPyType_Spec dummy_type_spec = { - .name = "mytest.Dummy", - @DEFAULT_SHAPE - .defines = dummy_type_defines, - }; - - @EXPORT_TYPE("Dummy", dummy_type_spec) - @INIT - """) - d = mod.Dummy() - assert d.foo.__doc__ == 'hello' - assert d.bar.__doc__ is None - assert d.foo(21) == 42 - assert d.bar() == 1234 - assert d.identity() is d - with pytest.raises(TypeError): - mod.Dummy.identity() - class A: pass - with pytest.raises(TypeError): - mod.Dummy.identity(A()) - - def test_HPy_New(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_METH(Point_foo, "foo", HPyFunc_NOARGS) - static HPy Point_foo_impl(HPyContext *ctx, HPy self) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return HPyLong_FromLong(ctx, point->x*10 + point->y); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_foo) - @INIT - """) - p1 = mod.Point(7, 3) - assert p1.foo() == 73 - p2 = mod.Point(4, 2) - assert p2.foo() == 42 - - def test_HPy_New_initialize_to_zero(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_xy - - HPyDef_METH(newPoint, "newPoint", HPyFunc_NOARGS) - static HPy newPoint_impl(HPyContext *ctx, HPy self) - { - HPy h_pointClass = HPy_GetAttr_s(ctx, self, "Point"); - if (HPy_IsNull(h_pointClass)) - return HPy_NULL; - - PointObject *point; - HPy h_point = HPy_New(ctx, h_pointClass, &point); - HPy_Close(ctx, h_pointClass); - return h_point; - } - - @EXPORT(newPoint) - @EXPORT_POINT_TYPE(&Point_x, &Point_y) - @INIT - """) - # this is suboptimal: if we don't initialized the memory after - # allocation, it might be 0 anyway. Try to allocate several Points to - # increase the chances that the test don't pass by chance - for i in range(10): - p = mod.newPoint() - assert p.x == 0 - assert p.y == 0 - - def test_refcount(self): - import pytest - import sys - if not self.supports_refcounts(): - pytest.skip() - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @EXPORT_POINT_TYPE(&Point_new) - @INIT - """) - tp = mod.Point - init_refcount = sys.getrefcount(tp) - p = tp(1, 2) - assert sys.getrefcount(tp) == init_refcount + 1 - p = None - assert sys.getrefcount(tp) == init_refcount - - def test_HPyDef_Member_basic(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_xy - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y) - @INIT - """) - p = mod.Point(7, 3) - assert p.x == 7 - assert p.y == 3 - p.x = 123 - p.y = 456 - assert p.x == 123 - assert p.y == 456 - - def test_HPyDef_Member_integers(self): - import pytest - BIGNUM = 2**200 - for kind, c_type in [ - ('SHORT', 'short'), - ('INT', 'int'), - ('LONG', 'long'), - ('USHORT', 'unsigned short'), - ('UINT', 'unsigned int'), - ('ULONG', 'unsigned long'), - ('BYTE', 'char'), - ('UBYTE', 'unsigned char'), - ('LONGLONG', 'long long'), - ('ULONGLONG', 'unsigned long long'), - ('HPYSSIZET', 'HPy_ssize_t'), - ]: - mod = self.make_module(""" - @TYPE_STRUCT_BEGIN(FooObject) - %(c_type)s member; - @TYPE_STRUCT_END - - HPyDef_SLOT(Foo_new, HPy_tp_new) - static HPy Foo_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - FooObject *foo; - HPy h_obj = HPy_New(ctx, cls, &foo); - if (HPy_IsNull(h_obj)) - return HPy_NULL; - foo->member = 42; - return h_obj; - } - - HPyDef_MEMBER(Foo_member, "member", HPyMember_%(kind)s, offsetof(FooObject, member)) - - static HPyDef *Foo_defines[] = { - &Foo_new, - &Foo_member, - NULL - }; - - static HPyType_Spec Foo_spec = { - .name = "test_%(kind)s.Foo", - .basicsize = sizeof(FooObject), - .builtin_shape = SHAPE(FooObject), - .defines = Foo_defines - }; - - @EXPORT_TYPE("Foo", Foo_spec) - @INIT - """ % {'c_type': c_type, 'kind': kind}, name='test_%s' % (kind,)) - foo = mod.Foo() - assert foo.member == 42 - foo.member = 43 - assert foo.member == 43 - with pytest.raises(OverflowError): - foo.member = BIGNUM - with pytest.raises(TypeError): - foo.member = None - with pytest.raises(TypeError): - del foo.member - - def test_HPyDef_Member_readonly_integers(self): - import pytest - for kind, c_type in [ - ('SHORT', 'short'), - ('INT', 'int'), - ('LONG', 'long'), - ('USHORT', 'unsigned short'), - ('UINT', 'unsigned int'), - ('ULONG', 'unsigned long'), - ('BYTE', 'char'), - ('UBYTE', 'unsigned char'), - ('LONGLONG', 'long long'), - ('ULONGLONG', 'unsigned long long'), - ('HPYSSIZET', 'HPy_ssize_t'), - ]: - mod = self.make_module(""" - @TYPE_STRUCT_BEGIN(FooObject) - %(c_type)s member; - @TYPE_STRUCT_END - - HPyDef_SLOT(Foo_new, HPy_tp_new) - static HPy Foo_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - FooObject *foo; - HPy h_obj = HPy_New(ctx, cls, &foo); - if (HPy_IsNull(h_obj)) - return HPy_NULL; - foo->member = 42; - return h_obj; - } - - HPyDef_MEMBER(Foo_member, "member", HPyMember_%(kind)s, offsetof(FooObject, member), .readonly=1) - - static HPyDef *Foo_defines[] = { - &Foo_new, - &Foo_member, - NULL - }; - - static HPyType_Spec Foo_spec = { - .name = "test_%(kind)s.Foo", - .basicsize = sizeof(FooObject), - .builtin_shape = SHAPE(FooObject), - .defines = Foo_defines - }; - - @EXPORT_TYPE("Foo", Foo_spec) - @INIT - """ % {'c_type': c_type, 'kind': kind}, name='test_%s' % (kind,)) - foo = mod.Foo() - assert foo.member == 42 - with pytest.raises(AttributeError): - foo.member = 43 - assert foo.member == 42 - with pytest.raises(AttributeError): - del foo.member - assert foo.member == 42 - - def test_HPyDef_Member_others(self): - import pytest - mod = self.make_module(""" - #include - @TYPE_STRUCT_BEGIN(FooObject) - float FLOAT_member; - double DOUBLE_member; - const char* STRING_member; - const char *STRING_null_member; - char CHAR_member; - char ISTRING_member[6]; - char BOOL_member; - HPyField OBJECT_member; - HPyField OBJECT_NULL_member; - HPyField OBJECT_EX_member; - @TYPE_STRUCT_END - - HPyDef_SLOT(Foo_new, HPy_tp_new) - static HPy Foo_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - FooObject *foo; - HPy h_obj = HPy_New(ctx, cls, &foo); - if (HPy_IsNull(h_obj)) - return HPy_NULL; - foo->FLOAT_member = 1.; - foo->DOUBLE_member = 1.; - const char * s = "Hello"; - foo->STRING_member = s; - foo->STRING_null_member = NULL; - foo->CHAR_member = 'A'; - strncpy(foo->ISTRING_member, "Hello", 6); - foo->BOOL_member = 0; - HPyField_Store(ctx, h_obj, &foo->OBJECT_member, ctx->h_NotImplemented); - foo->OBJECT_NULL_member = HPyField_NULL; - foo->OBJECT_EX_member = HPyField_NULL; - return h_obj; - } - - HPyDef_MEMBER(Foo_FLOAT_member, "FLOAT_member", HPyMember_FLOAT, offsetof(FooObject, FLOAT_member)) - HPyDef_MEMBER(Foo_DOUBLE_member, "DOUBLE_member", HPyMember_DOUBLE, offsetof(FooObject, DOUBLE_member)) - HPyDef_MEMBER(Foo_STRING_member, "STRING_member", HPyMember_STRING, offsetof(FooObject, STRING_member)) - HPyDef_MEMBER(Foo_STRING_null_member, "STRING_null_member", HPyMember_STRING, offsetof(FooObject, STRING_null_member)) - HPyDef_MEMBER(Foo_CHAR_member, "CHAR_member", HPyMember_CHAR, offsetof(FooObject, CHAR_member)) - HPyDef_MEMBER(Foo_ISTRING_member, "ISTRING_member", HPyMember_STRING_INPLACE, offsetof(FooObject, ISTRING_member)) - HPyDef_MEMBER(Foo_BOOL_member, "BOOL_member", HPyMember_BOOL, offsetof(FooObject, BOOL_member)) - HPyDef_MEMBER(Foo_OBJECT_member, "OBJECT_member", HPyMember_OBJECT, offsetof(FooObject, OBJECT_member)) - HPyDef_MEMBER(Foo_OBJECT_NULL_member, "OBJECT_NULL_member", HPyMember_OBJECT, offsetof(FooObject, OBJECT_NULL_member)) - HPyDef_MEMBER(Foo_OBJECT_EX_member, "OBJECT_EX_member", HPyMember_OBJECT_EX, offsetof(FooObject, OBJECT_EX_member)) - HPyDef_MEMBER(Foo_NONE_member, "NONE_member", HPyMember_NONE, offsetof(FooObject, FLOAT_member)) - - HPyDef_SLOT(Foo_traverse, HPy_tp_traverse) - static int Foo_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg) - { - FooObject *p = (FooObject *)self; - HPy_VISIT(&p->OBJECT_member); - HPy_VISIT(&p->OBJECT_NULL_member); - HPy_VISIT(&p->OBJECT_EX_member); - return 0; - } - - static HPyDef *Foo_defines[] = { - &Foo_new, - &Foo_FLOAT_member, - &Foo_DOUBLE_member, - &Foo_STRING_member, - &Foo_STRING_null_member, - &Foo_CHAR_member, - &Foo_ISTRING_member, - &Foo_BOOL_member, - &Foo_OBJECT_member, - &Foo_OBJECT_NULL_member, - &Foo_OBJECT_EX_member, - &Foo_NONE_member, - &Foo_traverse, - NULL - }; - - static HPyType_Spec Foo_spec = { - .name = "mytest.Foo", - .basicsize = sizeof(FooObject), - .builtin_shape = SHAPE(FooObject), - .defines = Foo_defines - }; - - @EXPORT_TYPE("Foo", Foo_spec) - @INIT - """) - foo = mod.Foo() - assert foo.FLOAT_member == 1. - foo.FLOAT_member = 0.1 - assert foo.FLOAT_member != 0.1 - assert abs(foo.FLOAT_member - 0.1) < 1e-8 - with pytest.raises(TypeError): - del foo.FLOAT_member - - assert foo.DOUBLE_member == 1. - foo.DOUBLE_member = 0.1 - assert foo.DOUBLE_member == 0.1 # exactly - with pytest.raises(TypeError): - del foo.DOUBLE_member - - assert foo.STRING_member == "Hello" - assert foo.STRING_null_member is None - with pytest.raises(TypeError): - foo.STRING_member = "world" - with pytest.raises(TypeError): - del foo.STRING_member - - assert foo.CHAR_member == 'A' - foo.CHAR_member = 'B' - assert foo.CHAR_member == 'B' - with pytest.raises(TypeError): - foo.CHAR_member = 'ABC' - with pytest.raises(TypeError): - del foo.CHAR_member - - assert foo.ISTRING_member == "Hello" - with pytest.raises(TypeError): - foo.ISTRING_member = "world" - with pytest.raises(TypeError): - del foo.ISTRING_member - - assert foo.BOOL_member is False - foo.BOOL_member = True - assert foo.BOOL_member is True - with pytest.raises(TypeError): - foo.BOOL_member = 1 - with pytest.raises(TypeError): - del foo.BOOL_member - - assert foo.OBJECT_member is NotImplemented - foo.OBJECT_member = 1 - assert foo.OBJECT_member == 1 - - assert foo.OBJECT_NULL_member is None - foo.OBJECT_NULL_member = 1 - assert foo.OBJECT_NULL_member == 1 - del foo.OBJECT_NULL_member - assert foo.OBJECT_NULL_member is None - - with pytest.raises(AttributeError): - foo.OBJECT_EX_member - foo.OBJECT_EX_member = 1 - assert foo.OBJECT_EX_member == 1 - del foo.OBJECT_EX_member - with pytest.raises(AttributeError): - foo.OBJECT_EX_member - - assert foo.NONE_member is None - with pytest.raises((SystemError, TypeError)): # CPython quirk/bug - foo.NONE_member = None - with pytest.raises(TypeError): - del foo.NONE_member - - def test_HPyDef_Member_readonly_others(self): - import pytest - mod = self.make_module(""" - #include - @TYPE_STRUCT_BEGIN(FooObject) - float FLOAT_member; - double DOUBLE_member; - const char* STRING_member; - char CHAR_member; - char ISTRING_member[6]; - char BOOL_member; - HPyField OBJECT_member; - @TYPE_STRUCT_END - - HPyDef_SLOT(Foo_new, HPy_tp_new) - static HPy Foo_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - FooObject *foo; - HPy h_obj = HPy_New(ctx, cls, &foo); - if (HPy_IsNull(h_obj)) - return HPy_NULL; - foo->FLOAT_member = 1.; - foo->DOUBLE_member = 1.; - const char * s = "Hello"; - foo->STRING_member = s; - foo->CHAR_member = 'A'; - strncpy(foo->ISTRING_member, "Hello", 6); - foo->BOOL_member = 0; - foo->OBJECT_member = HPyField_NULL; - return h_obj; - } - - HPyDef_MEMBER(Foo_FLOAT_member, "FLOAT_member", HPyMember_FLOAT, offsetof(FooObject, FLOAT_member), .readonly=1) - HPyDef_MEMBER(Foo_DOUBLE_member, "DOUBLE_member", HPyMember_DOUBLE, offsetof(FooObject, DOUBLE_member), .readonly=1) - HPyDef_MEMBER(Foo_STRING_member, "STRING_member", HPyMember_STRING, offsetof(FooObject, STRING_member), .readonly=1) - HPyDef_MEMBER(Foo_CHAR_member, "CHAR_member", HPyMember_CHAR, offsetof(FooObject, CHAR_member), .readonly=1) - HPyDef_MEMBER(Foo_ISTRING_member, "ISTRING_member", HPyMember_STRING_INPLACE, offsetof(FooObject, ISTRING_member), .readonly=1) - HPyDef_MEMBER(Foo_BOOL_member, "BOOL_member", HPyMember_BOOL, offsetof(FooObject, BOOL_member), .readonly=1) - HPyDef_MEMBER(Foo_OBJECT_member, "OBJECT_member", HPyMember_OBJECT, offsetof(FooObject, OBJECT_member), .readonly=1) - HPyDef_MEMBER(Foo_NONE_member, "NONE_member", HPyMember_NONE, offsetof(FooObject, FLOAT_member), .readonly=1) - - HPyDef_SLOT(Foo_traverse, HPy_tp_traverse) - static int Foo_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg) - { - FooObject *p = (FooObject *)self; - HPy_VISIT(&p->OBJECT_member); - return 0; - } - - static HPyDef *Foo_defines[] = { - &Foo_new, - &Foo_FLOAT_member, - &Foo_DOUBLE_member, - &Foo_STRING_member, - &Foo_CHAR_member, - &Foo_ISTRING_member, - &Foo_BOOL_member, - &Foo_OBJECT_member, - &Foo_NONE_member, - &Foo_traverse, - NULL - }; - - static HPyType_Spec Foo_spec = { - .name = "mytest.Foo", - .basicsize = sizeof(FooObject), - .builtin_shape = SHAPE(FooObject), - .defines = Foo_defines - }; - - @EXPORT_TYPE("Foo", Foo_spec) - @INIT - """) - foo = mod.Foo() - assert foo.FLOAT_member == 1. - with pytest.raises(AttributeError): - foo.FLOAT_member = 0.1 - assert foo.DOUBLE_member == 1. - with pytest.raises(AttributeError): - foo.DOUBLE_member = 0.1 - - assert foo.STRING_member == "Hello" - with pytest.raises(AttributeError): - foo.STRING_member = "world" - with pytest.raises(AttributeError): - del foo.STRING_member - - assert foo.CHAR_member == 'A' - with pytest.raises(AttributeError): - foo.CHAR_member = 'B' - with pytest.raises(AttributeError): - foo.CHAR_member = 'ABC' - with pytest.raises(AttributeError): - del foo.CHAR_member - - assert foo.ISTRING_member == "Hello" - with pytest.raises(AttributeError): - foo.ISTRING_member = "world" - with pytest.raises(AttributeError): - del foo.ISTRING_member - - assert foo.BOOL_member is False - with pytest.raises(AttributeError): - foo.BOOL_member = True - with pytest.raises(AttributeError): - foo.BOOL_member = 1 - with pytest.raises(AttributeError): - del foo.BOOL_member - - assert foo.OBJECT_member is None - with pytest.raises(AttributeError): - foo.OBJECT_member = 1 - with pytest.raises(AttributeError): - del foo.OBJECT_member - - assert foo.NONE_member is None - with pytest.raises(AttributeError): - foo.NONE_member = None - with pytest.raises(AttributeError): - del foo.NONE_member - - def test_call(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_call - - HPyDef_SLOT(Dummy_call, HPy_tp_call) - static HPy - Dummy_call_impl(HPyContext *ctx, HPy callable, const HPy *args, - size_t nargs, HPy kwnames) - { - return HPyUnicode_FromString(ctx, "hello"); - } - - @EXPORT_POINT_TYPE(&Point_call) - @INIT - """) - p = mod.Point() - assert p(3, 4, 5, factor=2) == 24 - - def test_call_with_tp_new(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_call - @EXPORT_POINT_TYPE(&Point_new, &Point_call) - @INIT - """) - p = mod.Point(1, 2) - assert p(3, 4, 5, factor=2) == 30 - - def test_call_set(self): - import pytest - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_call - - HPyDef_CALL_FUNCTION(Point_special_call) - static HPy - Point_special_call_impl(HPyContext *ctx, HPy callable, - const HPy *args, size_t nargs, HPy kwnames) - { - HPy tmp = Point_call_impl(ctx, callable, args, nargs, kwnames); - HPy res = HPy_Negative(ctx, tmp); - HPy_Close(ctx, tmp); - return res; - } - - HPyDef_SLOT(Point_new, HPy_tp_new) - static HPy Point_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - long x, y; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &x, &y)) - return HPy_NULL; - PointObject *point; - HPy h_point = HPy_New(ctx, cls, &point); - if (HPy_IsNull(h_point)) - return HPy_NULL; - if (x < 0 && HPy_SetCallFunction(ctx, h_point, &Point_special_call) < 0) { - HPy_Close(ctx, h_point); - return HPy_NULL; - } - point->x = x; - point->y = y; - return h_point; - } - - HPyDef_METH(call_set, "call_set", HPyFunc_O) - static HPy call_set_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPy_SetCallFunction(ctx, arg, &Point_special_call) < 0) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_call) - @EXPORT(call_set) - @INIT - """) - - # this uses 'Point_call' - p0 = mod.Point(1, 2) - assert p0(3, 4, 5, factor=2) == 30 - - # the negative 'x' will cause that 'Point_special_call' is used - p1 = mod.Point(-1, 2) - assert p1(3, 4, 5, factor=2) == -26 - - # error case: setting call function on object that does not implement - # the HPy call protocol - with pytest.raises(TypeError): - mod.call_set(object()) - - def test_call_invalid_specs(self): - import pytest - mod = self.make_module(""" - HPyDef_SLOT(Dummy_call, HPy_tp_call) - static HPy - Dummy_call_impl(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) - { - return HPyUnicode_FromString(ctx, "hello"); - } - - HPyDef_MEMBER(Dummy_vcall_offset, "__vectorcalloffset__", HPyMember_HPYSSIZET, 4*sizeof(void*), .readonly=1) - - static HPyDef *Dummy_defines[] = { &Dummy_call, NULL }; - static HPyDef *Dummy_vcall_defines[] = { &Dummy_call, &Dummy_vcall_offset, NULL }; - - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = sizeof(intptr_t), - .flags = HPy_TPFLAGS_DEFAULT, - @DEFAULT_SHAPE - .defines = Dummy_defines, - }; - - static HPyType_Spec Dummy_vcall_spec = { - .name = "mytest.DummyVCall", - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_HAVE_VECTORCALL, - @DEFAULT_SHAPE - .defines = Dummy_vcall_defines, - }; - - HPyDef_METH(create_var_type, "create_var_type", HPyFunc_NOARGS) - static HPy create_var_type_impl(HPyContext *ctx, HPy self) - { - if (!HPyHelpers_AddType(ctx, self, "Dummy", &Dummy_spec, NULL)) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - HPyDef_METH(create_vcall, "create_call_and_vectorcalloffset_type", HPyFunc_NOARGS) - static HPy create_vcall_impl(HPyContext *ctx, HPy self) - { - if (!HPyHelpers_AddType(ctx, self, "DummyVCall", &Dummy_vcall_spec, NULL)) { - return HPy_NULL; - } - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT(create_var_type) - @EXPORT(create_vcall) - @INIT - """) - with pytest.raises(TypeError): - mod.create_var_type() - with pytest.raises(TypeError): - mod.create_call_and_vectorcalloffset_type() - - @pytest.mark.skip("not yet implemented") - def test_call_explicit_offset(self): - mod = self.make_module(""" - @TYPE_STRUCT_BEGIN(FooObject) - void *a; - HPyCallFunction call_func; - void *b; - @TYPE_STRUCT_END - - HPyDef_MEMBER(Foo_vcall_offset, "__vectorcalloffset__", HPyMember_HPYSSIZET, offsetof(FooObject, call_func), .readonly=1) - - HPyDef_CALL_FUNCTION(Foo_manual_call_func) - static HPy - Foo_manual_call_func_impl(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) - { - return HPyUnicode_FromString(ctx, "hello manually initialized call function"); - } - - HPyDef_SLOT(Foo_new, HPy_tp_new) - static HPy Foo_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - FooObject *data; - HPy h_obj = HPy_New(ctx, cls, &data); - if (HPy_IsNull(h_obj)) - return HPy_NULL; - data->call_func = Foo_manual_call_func; - return h_obj; - } - - static HPyDef *Foo_defines[] = { - &Foo_vcall_offset, - &Foo_new, - NULL - }; - - static HPyType_Spec Foo_spec = { - .name = "mytest.Foo", - .basicsize = sizeof(FooObject), - .itemsize = sizeof(intptr_t), - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_HAVE_VECTORCALL, - @DEFAULT_SHAPE - .defines = Foo_defines, - }; - - @EXPORT_TYPE("Foo", Foo_spec) - @INIT - """) - foo = mod.Foo() - assert foo() == 'hello manually initialized call function' - - def test_HPyType_GenericNew(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_xy - - HPyDef_SLOT_IMPL(Point_new, HPyType_GenericNew, HPy_tp_new) - - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y) - @INIT - """) - p = mod.Point() - assert p.x == 0 - assert p.y == 0 - - def test_HPyDef_GET(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_GET(Point_z, "z") - static HPy Point_z_get(HPyContext *ctx, HPy self, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return HPyLong_FromLong(ctx, point->x*10 + point->y); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.z == 73 - - def test_HPyDef_GETSET(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_GETSET(Point_z, "z", .closure=(void *)1000) - static HPy Point_z_get(HPyContext *ctx, HPy self, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return HPyLong_FromLong(ctx, point->x*10 + point->y + (long)(HPy_ssize_t)closure); - } - static int Point_z_set(HPyContext *ctx, HPy self, HPy value, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - long current = point->x*10 + point->y + (long)(HPy_ssize_t)closure; - long target = HPyLong_AsLong(ctx, value); // assume no exception - point->y += target - current; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.z == 1073 - p.z = 1075 - assert p.z == 1075 - - def test_HPyDef_SET(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_xy - - HPyDef_SET(Point_z, "z", .closure=(void *)1000) - static int Point_z_set(HPyContext *ctx, HPy self, HPy value, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - long current = point->x*10 + point->y + (long)(HPy_ssize_t)closure; - long target = HPyLong_AsLong(ctx, value); // assume no exception - point->y += target - current; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.y == 3 - p.z = 1075 - assert p.y == 5 - - def test_HPyDef_GET_IMPL(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_GET_IMPL(Point_z, "z", Point_z_get) - static HPy Point_z_get(HPyContext *ctx, HPy self, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return HPyLong_FromLong(ctx, point->x*10 + point->y); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.z == 73 - - def test_HPyDef_GETSET_IMPL(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_GETSET_IMPL(Point_z, "z", Point_z_get, Point_z_set, .closure=(void *)1000) - static HPy Point_z_get(HPyContext *ctx, HPy self, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return HPyLong_FromLong(ctx, point->x*10 + point->y + (long)(HPy_ssize_t)closure); - } - static int Point_z_set(HPyContext *ctx, HPy self, HPy value, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - long current = point->x*10 + point->y + (long)(HPy_ssize_t)closure; - long target = HPyLong_AsLong(ctx, value); // assume no exception - point->y += target - current; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.z == 1073 - p.z = 1075 - assert p.z == 1075 - - def test_HPyDef_SET_IMPL(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_xy - - HPyDef_SET_IMPL(Point_z, "z", Point_z_set, .closure=(void *)1000) - static int Point_z_set(HPyContext *ctx, HPy self, HPy value, void *closure) - { - PointObject *point = PointObject_AsStruct(ctx, self); - long current = point->x*10 + point->y + (long)(HPy_ssize_t)closure; - long target = HPyLong_AsLong(ctx, value); // assume no exception - point->y += target - current; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y, &Point_z) - @INIT - """) - p = mod.Point(7, 3) - assert p.y == 3 - p.z = 1075 - assert p.y == 5 - - def test_specparam_base(self): - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - }; - - static void make_Dummy(HPyContext *ctx, HPy module) - { - HPyType_SpecParam param[] = { - { HPyType_SpecParam_Base, ctx->h_LongType }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_Dummy = HPyType_FromSpec(ctx, &Dummy_spec, param); - if (HPy_IsNull(h_Dummy)) - return; - HPy_SetAttr_s(ctx, module, "Dummy", h_Dummy); - HPy_Close(ctx, h_Dummy); - } - @EXTRA_INIT_FUNC(make_Dummy) - @INIT - """) - assert isinstance(mod.Dummy, type) - assert mod.Dummy.__name__ == 'Dummy' - assert mod.Dummy.__module__ == 'mytest' - assert issubclass(mod.Dummy, int) - assert isinstance(mod.Dummy(), mod.Dummy) - assert mod.Dummy() == 0 - assert mod.Dummy(42) == 42 - - class Sub(mod.Dummy): - pass - assert isinstance(Sub(), mod.Dummy) - - def test_specparam_basestuple(self): - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - }; - - static void make_Dummy(HPyContext *ctx, HPy module) - { - HPy h_bases = HPyTuple_Pack(ctx, 1, ctx->h_LongType); - if (HPy_IsNull(h_bases)) - return; - HPyType_SpecParam param[] = { - { HPyType_SpecParam_BasesTuple, h_bases }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_Dummy = HPyType_FromSpec(ctx, &Dummy_spec, param); - HPy_Close(ctx, h_bases); - if (HPy_IsNull(h_Dummy)) - return; - HPy_SetAttr_s(ctx, module, "Dummy", h_Dummy); - HPy_Close(ctx, h_Dummy); - } - @EXTRA_INIT_FUNC(make_Dummy) - @INIT - """) - assert isinstance(mod.Dummy, type) - assert mod.Dummy.__name__ == 'Dummy' - assert mod.Dummy.__module__ == 'mytest' - assert issubclass(mod.Dummy, int) - assert isinstance(mod.Dummy(), mod.Dummy) - assert mod.Dummy() == 0 - assert mod.Dummy(42) == 42 - - class Sub(mod.Dummy): - pass - assert isinstance(Sub(), mod.Dummy) - - def test_specparam_multiple_metaclass_fails(self): - import pytest - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - }; - - HPyDef_METH(make_dummy, "make_dummy", HPyFunc_NOARGS) - static HPy make_dummy_impl(HPyContext *ctx, HPy module) - { - HPyType_SpecParam param[] = { - { HPyType_SpecParam_Metaclass, ctx->h_TypeType }, - { HPyType_SpecParam_Metaclass, ctx->h_LongType }, - { (HPyType_SpecParam_Kind)0 } - }; - return HPyType_FromSpec(ctx, &Dummy_spec, param); - } - @EXPORT(make_dummy) - @INIT - """) - - with pytest.raises(ValueError): - mod.make_dummy() - - def test_metaclass(self): - import pytest - mod = self.make_module(""" - #include - - @DEFINE_DummyMeta - @DEFINE_Dummy - @DEFINE_meta_data_accessors - - HPyDef_METH(create_type, "create_type", HPyFunc_VARARGS) - static HPy create_type_impl(HPyContext *ctx, HPy module, - const HPy *args, size_t nargs) - { - HPy metaclass; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "sO", - &Dummy_spec.name, &metaclass)) - return HPy_NULL; - - HPyType_SpecParam specparam[] = { - { HPyType_SpecParam_Metaclass, metaclass }, - { (HPyType_SpecParam_Kind)0 } - }; - - const char *bare_name = strrchr(Dummy_spec.name, '.'); - if (bare_name == NULL) - bare_name = Dummy_spec.name; - else - bare_name++; - - if (!HPyHelpers_AddType(ctx, module, bare_name, - &Dummy_spec, specparam)) - return HPy_NULL; - - return HPy_Dup(ctx, ctx->h_None); - } - - @EXPORT_DummyMeta - @EXPORT(set_meta_data) - @EXPORT(get_meta_data) - @EXPORT(set_member) - @EXPORT(create_type) - @INIT - """) - - assert type(mod.DummyMeta) is type - mod.create_type("mytest.Dummy", mod.DummyMeta) - assert mod.DummyMeta is type(mod.Dummy), "type(mod.Dummy) == %r" % (type(mod.Dummy), ) - assert isinstance(mod.Dummy, type) - assert mod.set_meta_data(mod.Dummy) is None - assert mod.get_meta_data(mod.Dummy) == 42 + 11 - - d = mod.Dummy() - mod.set_member(d) - assert d.member == 123614 - - # metaclasses must inherit from 'type' - with pytest.raises(TypeError): - mod.create_type("mytest.DummyFail0", "hello") - - class WithCustomNew: - def __new__(self): - print("hello") - - # types with custom 'tp_new' cannot be used as metaclass - with pytest.raises(TypeError): - mod.create_type("mytest.DummyFail1", WithCustomNew) - - # type 'int' also has a custom new - with pytest.raises(TypeError): - mod.create_type("mytest.DummyIntMeta", int) - - def test_get_name(self, hpy_abi): - import pytest - if "debug" in hpy_abi: - pytest.skip("unsupported on GraalPy") - import array - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .itemsize = 0, - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - }; - - HPyDef_METH(get_name, "get_name", HPyFunc_O) - static HPy get_name_impl(HPyContext *ctx, HPy self, HPy arg) - { - const char *name = HPyType_GetName(ctx, arg); - if (name == NULL) - return HPy_NULL; - return HPyUnicode_FromString(ctx, name); - } - - @EXPORT_TYPE("Dummy", Dummy_spec) - @EXPORT(get_name) - @INIT - """) - assert mod.Dummy.__name__ == "Dummy" - assert mod.get_name(mod.Dummy) == "Dummy" - assert mod.get_name(str) == "str" - assert mod.get_name(array.array) == "array" - - def test_issubtype(self): - mod = self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - @DEFAULT_SHAPE - }; - - static HPyType_Spec Single_spec = { - .name = "mytest.Single", - @DEFAULT_SHAPE - }; - - static HPyType_Spec Dual_spec = { - .name = "mytest.Dual", - @DEFAULT_SHAPE - }; - - static void make_types(HPyContext *ctx, HPy module) - { - HPy h_dummy = HPyType_FromSpec(ctx, &Dummy_spec, NULL); - HPy_SetAttr_s(ctx, module, "Dummy", h_dummy); - HPyType_SpecParam single_param[] = { - { HPyType_SpecParam_Base, ctx->h_LongType }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_single = HPyType_FromSpec(ctx, &Single_spec, single_param); - if (HPy_IsNull(h_single)) - return; - HPy_SetAttr_s(ctx, module, "Single", h_single); - HPy_Close(ctx, h_single); - - HPyType_SpecParam dual_param[] = { - { HPyType_SpecParam_Base, ctx->h_LongType }, - { HPyType_SpecParam_Base, h_dummy }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_dual = HPyType_FromSpec(ctx, &Dual_spec, dual_param); - HPy_Close(ctx, h_dummy); - if (HPy_IsNull(h_dual)) - return; - HPy_SetAttr_s(ctx, module, "Dual", h_dual); - HPy_Close(ctx, h_dual); - } - - HPyDef_METH(issubtype, "issubtype", HPyFunc_VARARGS) - static HPy issubtype_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 2 arguments"); - return HPy_NULL; - } - int res = HPyType_IsSubtype(ctx, args[0], args[1]); - return HPyLong_FromLong(ctx, res); - } - - @EXPORT(issubtype) - @EXTRA_INIT_FUNC(make_types) - @INIT - """) - - class EveryMeta(type): - def __subclasscheck__(self, subclass): - return subclass is not None - Every = EveryMeta('Every', (), {}) - assert mod.issubtype(mod.Single, int) - assert mod.issubtype(mod.Dual, int) - assert mod.issubtype(mod.Dual, mod.Dummy) - assert not mod.issubtype(mod.Single, mod.Dummy) - assert not mod.issubtype(mod.Single, mod.Dual) - assert not mod.issubtype(mod.Dual, mod.Single) - assert issubclass(mod.Single, Every) - assert issubclass(mod.Dual, Every) - assert not mod.issubtype(mod.Single, Every) - assert not mod.issubtype(mod.Dual, Every) - - -class TestPureHPyType(HPyTest): - - ExtensionTemplate = PointTemplate - - def test_builtin_shape(self, hpy_abi): - import pytest - if hpy_abi == 'cpython': - pytest.skip('native int subclasses are not supported on GraalPy') - mod = self.make_module(""" - @DEFINE_PointObject(HPyType_BuiltinShape_Long) - @DEFINE_Point_xy - - static HPyDef *Point_defines[] = { - &Point_x, - &Point_y, - NULL - }; - - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = SHAPE(PointObject), - .defines = Point_defines - }; - - static void make_Point(HPyContext *ctx, HPy module) - { - HPyType_SpecParam param[] = { - { HPyType_SpecParam_Base, ctx->h_LongType }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_Point = HPyType_FromSpec(ctx, &Point_spec, param); - if (HPy_IsNull(h_Point)) - return; - HPy_SetAttr_s(ctx, module, "Point", h_Point); - HPy_Close(ctx, h_Point); - } - @EXTRA_INIT_FUNC(make_Point) - @INIT - """) - assert isinstance(mod.Point, type) - assert mod.Point.__name__ == 'Point' - assert mod.Point.__module__ == 'mytest' - assert issubclass(mod.Point, int) - assert isinstance(mod.Point(), mod.Point) - p0 = mod.Point() - assert p0 == 0 - assert p0.x == 0 - assert p0.y == 0 - - p42 = mod.Point(42) - p42.x = 123 - p42.y = 456 - assert p42 == 42 - assert p42.x == 123 - assert p42.y == 456 - - def test_invalid_shape(self): - import pytest - with pytest.raises(ValueError): - self.make_module(""" - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .builtin_shape = (HPyType_BuiltinShape)123 - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - - def test_call_zero_basicsize(self): - mod = self.make_module(""" - HPyDef_SLOT(Dummy_call, HPy_tp_call) - static HPy - Dummy_call_impl(HPyContext *ctx, HPy callable, const HPy *args, - size_t nargs, HPy kwnames) - { - return HPyUnicode_FromString(ctx, "hello"); - } - - static HPyDef *Dummy_defines[] = { &Dummy_call, NULL }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - @DEFAULT_SHAPE - .defines = Dummy_defines, - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - # type 'Dummy' has basicsize == 0; this test ensures that installation - # of the hidden call function field is done correctly - q = mod.Dummy() - assert q() == 'hello' diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype_legacy.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype_legacy.py deleted file mode 100644 index b9bbe75b09..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpytype_legacy.py +++ /dev/null @@ -1,372 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" HPyType tests on legacy types. """ - -import pytest -from .support import HPyTest, make_hpy_abi_fixture -from .test_hpytype import PointTemplate, TestType as _TestType - -hpy_abi = make_hpy_abi_fixture('with hybrid') - -class LegacyPointTemplate(PointTemplate): - """ - Override PointTemplate to instead define a legacy point type that - still provides access to PyObject_HEAD. - """ - - _STRUCT_BEGIN_FORMAT = """ - #include - typedef struct {{ - PyObject_HEAD - """ - - _STRUCT_END_FORMAT = """ - }} {struct_name}; - HPyType_LEGACY_HELPERS({struct_name}) - """ - - _METACLASS_STRUCT_BEGIN_FORMAT = """ - #include - typedef struct {{ - PyHeapTypeObject super; - """ - - _METACLASS_STRUCT_END_FORMAT = _STRUCT_END_FORMAT - - def DEFAULT_SHAPE(self): - return ".builtin_shape = HPyType_BuiltinShape_Legacy," - - -class TestLegacyType(_TestType): - - ExtensionTemplate = LegacyPointTemplate - - @pytest.mark.syncgc - def test_legacy_dealloc(self): - mod = self.make_module(""" - static long dealloc_counter = 0; - - HPyDef_METH(get_counter, "get_counter", HPyFunc_NOARGS) - static HPy get_counter_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, dealloc_counter); - } - - @DEFINE_PointObject - @DEFINE_Point_new - static void Point_dealloc(PyObject *self) - { - dealloc_counter++; - Py_TYPE(self)->tp_free(self); - } - - static HPyDef *Point_defines[] = {&Point_new, NULL}; - static PyType_Slot Point_slots[] = { - {Py_tp_dealloc, (void*)Point_dealloc}, - {0, NULL}, - }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = SHAPE(PointObject), - .legacy_slots = Point_slots, - .defines = Point_defines, - }; - - @EXPORT(get_counter) - @EXPORT_TYPE("Point", Point_spec) - @INIT - """) - assert mod.get_counter() == 0 - p = mod.Point(0, 0) - del p - import gc; gc.collect() - assert mod.get_counter() == 1 - - @pytest.mark.syncgc - def test_legacy_dealloc_and_HPy_tp_traverse(self): - import pytest - mod_src = """ - @DEFINE_PointObject - @DEFINE_Point_new - HPyDef_SLOT(Point_traverse, HPy_tp_traverse) - static int Point_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg) - { - return 0; - } - static void Point_dealloc(PyObject *self) - { - return; - } - - static HPyDef *Point_defines[] = {&Point_new, &Point_traverse, NULL}; - static PyType_Slot Point_slots[] = { - {Py_tp_dealloc, (void*)Point_dealloc}, - {0, NULL}, - }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = SHAPE(PointObject), - .legacy_slots = Point_slots, - .defines = Point_defines, - }; - @EXPORT_TYPE("Point", Point_spec) - @INIT - """ - with pytest.raises(TypeError) as err: - mod = self.make_module(mod_src) - assert "legacy tp_dealloc" in str(err.value) - - @pytest.mark.syncgc - def test_legacy_dealloc_and_HPy_tp_destroy(self): - import pytest - mod_src = """ - @DEFINE_PointObject - @DEFINE_Point_new - HPyDef_SLOT(Point_destroy, HPy_tp_destroy) - static void Point_destroy_impl(void *obj) - { - return; - } - static void Point_dealloc(PyObject *self) - { - return; - } - - static HPyDef *Point_defines[] = {&Point_new, &Point_destroy, NULL}; - static PyType_Slot Point_slots[] = { - {Py_tp_dealloc, (void*)Point_dealloc}, - {0, NULL}, - }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = SHAPE(PointObject), - .legacy_slots = Point_slots, - .defines = Point_defines, - }; - @EXPORT_TYPE("Point", Point_spec) - @INIT - """ - with pytest.raises(TypeError) as err: - mod = self.make_module(mod_src) - assert "legacy tp_dealloc" in str(err.value) - - def test_metaclass_as_legacy_static_type(self): - mod = self.make_module(""" - #include - #include - - @DEFINE_DummyMeta_struct - - /* This module is compiled as a shared library and some compilers - don't allow addresses of Python objects defined in other - libraries to be used in static initializers here. The - DEFERRED_ADDRESS macro is just used for documentation and we - need to set the actual value before we call PyType_Ready. */ - #define DEFERRED_ADDRESS(x) NULL - - static PyTypeObject DummyMetaType = { - PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) - .tp_name = "mytest.DummyMeta", - .tp_basicsize = sizeof(DummyMeta), - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_base = DEFERRED_ADDRESS(&PyType_Type), - }; - - @DEFINE_Dummy_struct - - static PyMemberDef members[] = { - {"member", T_INT, offsetof(Dummy, member), 0, NULL}, - {NULL, 0, 0, 0, NULL}, - }; - - static PyType_Slot DummySlots[] = { - {Py_tp_members, members}, - {0, NULL}, - }; - - static HPyType_Spec Dummy_legacy_spec = { - .name = "mytest.Dummy", - .basicsize = sizeof(Dummy), - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - .builtin_shape = HPyType_BuiltinShape_Legacy, - .legacy_slots = DummySlots, - }; - - void setup_types(HPyContext *ctx, HPy module) { - HPy h_DummyMeta; - DummyMetaType.ob_base.ob_base.ob_type = &PyType_Type; - DummyMetaType.tp_base = &PyType_Type; - if (PyType_Ready(&DummyMetaType)) - return; - h_DummyMeta = HPy_FromPyObject(ctx, (PyObject*) &DummyMetaType); - - HPyType_SpecParam param[] = { - { HPyType_SpecParam_Metaclass, h_DummyMeta }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_Dummy = HPyType_FromSpec(ctx, &Dummy_legacy_spec, param); - if (!HPy_IsNull(h_Dummy)) { - HPy_SetAttr_s(ctx, module, "Dummy", h_Dummy); - HPy_SetAttr_s(ctx, module, "DummyMeta", h_DummyMeta); - } - - HPy_Close(ctx, h_Dummy); - HPy_Close(ctx, h_DummyMeta); - } - - @DEFINE_meta_data_accessors - - @EXPORT(set_meta_data) - @EXPORT(get_meta_data) - @EXPORT(set_member) - @EXTRA_INIT_FUNC(setup_types) - @INIT - """) - - assert isinstance(mod.Dummy, type) - assert mod.DummyMeta is type(mod.Dummy) - assert mod.set_meta_data(mod.Dummy) is None - assert mod.get_meta_data(mod.Dummy) == 42 + 11 - - d = mod.Dummy() - mod.set_member(d) - assert d.member == 123614 - - def test_call_zero_basicsize(self): - import pytest - # type 'Dummy' has basicsize == 0; we cannot use the HPy call protocol - # with legacy types that inherit their struct since we then don't know - # how to safely allocate the hidden field - with pytest.raises(TypeError): - self.make_module(""" - HPyDef_SLOT(Dummy_call, HPy_tp_call) - static HPy - Dummy_call_impl(HPyContext *ctx, HPy callable, const HPy *args, - size_t nargs, HPy kwnames) - { - return HPyUnicode_FromString(ctx, "hello"); - } - - static HPyDef *Dummy_defines[] = { &Dummy_call, NULL }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - @DEFAULT_SHAPE - .defines = Dummy_defines, - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - -class TestCustomLegacyFeatures(HPyTest): - - def test_legacy_methods(self): - mod = self.make_module(""" - #include - - static PyObject *f(PyObject *self, PyObject *args) - { - return PyLong_FromLong(1234); - } - static PyObject *g(PyObject *self, PyObject *arg) - { - long x = PyLong_AsLong(arg); - return PyLong_FromLong(x * 2); - } - static PyObject *h(PyObject *self, PyObject *args) - { - long a, b, c; - if (!PyArg_ParseTuple(args, "lll", &a, &b, &c)) - return NULL; - return PyLong_FromLong(100*a + 10*b + c); - } - static PyObject *k(PyObject *self, PyObject *args, PyObject *kwargs) - { - static const char *kwlist[] = { "a", "b", "c", NULL }; - long a, b, c; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "lll", (char **)kwlist, &a, &b, &c)) - return NULL; - return PyLong_FromLong(100*a + 10*b + c); - } - - static PyMethodDef my_legacy_methods[] = { - {"f", (PyCFunction)f, METH_NOARGS}, - {"g", (PyCFunction)g, METH_O}, - {"h", (PyCFunction)h, METH_VARARGS}, - {"k", (PyCFunction)k, METH_VARARGS | METH_KEYWORDS}, - {NULL} - }; - - @EXPORT_LEGACY(my_legacy_methods) - @INIT - """) - assert mod.f() == 1234 - assert mod.g(45) == 90 - assert mod.h(4, 5, 6) == 456 - assert mod.k(c=6, b=5, a=4) == 456 - - def test_legacy_inherits_from_pure_raises(self): - import pytest - mod_src = """ - static HPyType_Spec PureType_spec = { - .name = "mytest.PureType", - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_BASETYPE, - }; - - static HPyType_Spec LegacyType_spec = { - .name = "mytest.LegacyType", - .builtin_shape = HPyType_BuiltinShape_Legacy, - }; - - static void make_Types(HPyContext *ctx, HPy module) - { - HPy h_PureType = HPyType_FromSpec(ctx, &PureType_spec, NULL); - if (HPy_IsNull(h_PureType)) { - return; - } - - HPyType_SpecParam LegacyType_param[] = { - { HPyType_SpecParam_Base, h_PureType }, - { (HPyType_SpecParam_Kind)0 } - }; - HPy h_LegacyType = HPyType_FromSpec( - ctx, &LegacyType_spec, LegacyType_param); - if (HPy_IsNull(h_LegacyType)) { - HPy_Close(ctx, h_PureType); - return; - } - HPy_Close(ctx, h_LegacyType); - HPy_Close(ctx, h_PureType); - } - @EXTRA_INIT_FUNC(make_Types) - @INIT - """ - with pytest.raises(TypeError) as err: - self.make_module(mod_src) - assert str(err.value) == ( - "A legacy type should not inherit its memory layout from a" - " pure type") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyunicode.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyunicode.py deleted file mode 100644 index c29b9b3d12..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_hpyunicode.py +++ /dev/null @@ -1,998 +0,0 @@ -# -*- encoding: utf-8 -*- -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import itertools -import re -import sys - -import pytest - -from .support import HPyTest - -class TestUnicode(HPyTest): - - def test_Check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (HPyUnicode_Check(ctx, arg)) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - class MyUnicode(str): - pass - - assert mod.f('hello') is True - assert mod.f(b'hello') is False - assert mod.f(MyUnicode('hello')) is True - - def test_FromString(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromString(ctx, "foobar"); - } - @EXPORT(f) - @INIT - """) - assert mod.f() == "foobar" - - def test_FromWideChar(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - const wchar_t buf[] = { 'h', 'e', 'l', 'l', 0xf2, ' ', - 'w', 'o', 'r', 'l', 'd', 0 }; - long n = HPyLong_AsLong(ctx, arg); - return HPyUnicode_FromWideChar(ctx, buf, n); - } - @EXPORT(f) - @INIT - """) - assert mod.f(-1) == "hellò world" - assert mod.f(11) == "hellò world" - assert mod.f(5) == "hellò" - - - def test_AsUTF8String(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_AsUTF8String(ctx, arg); - } - @EXPORT(f) - @INIT - """) - s = 'hellò' - b = mod.f(s) - assert type(b) is bytes - assert b == s.encode('utf-8') - - def test_AsASCIIString(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_AsASCIIString(ctx, arg); - } - @EXPORT(f) - @INIT - """) - s = 'world' - b = mod.f(s) - assert type(b) is bytes - assert b == s.encode('ascii') - - def test_AsLatin1String(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_AsLatin1String(ctx, arg); - } - @EXPORT(f) - @INIT - """) - s = "Müller" - b = mod.f(s) - assert type(b) is bytes - assert b == s.encode('latin1') - - def test_AsUTF8AndSize(self): - mod = self.make_module(""" - #include - - static HPy as_utf8_and_size(HPyContext *ctx, HPy arg, HPy_ssize_t *size) - { - HPy_ssize_t n; - const char* buf = HPyUnicode_AsUTF8AndSize(ctx, arg, size); - long res = 0; - - if (size) - n = *size; - else - n = strlen(buf); - - for(int i=0; i length - ("%5d", " 123", '(int)123'), - ("%5i", " 123", '(int)123'), - ("%5u", " 123", '(unsigned int)123'), - ("%5ld", " 123", '(long)123'), - ("%5li", " 123", '(long)123'), - ("%5lu", " 123", '(unsigned long)123'), - ("%5lld", " 123", '(long long)123'), - ("%5lli", " 123", '(long long)123'), - ("%5llu", " 123",'(unsigned long long)123'), - ("%5zd", " 123", '(HPy_ssize_t)123'), - ("%5zi", " 123", '(HPy_ssize_t)123'), - ("%5zu", " 123", '(size_t)123'), - ("%5x", " 7b", '(int)123'), - - ("%5d", " -123", '(int)-123'), - ("%5i", " -123", '(int)-123'), - ("%5ld", " -123", '(long)-123'), - ("%5li", " -123", '(long)-123'), - ("%5lld", " -123", '(long long)-123'), - ("%5lli", " -123", '(long long)-123'), - ("%5zd", " -123", '(HPy_ssize_t)-123'), - ("%5zi", " -123", '(HPy_ssize_t)-123'), - ("%9x", " ffffff85", '(int)-123'), - - # Integers: width > length, 0-flag - ("%05d", "00123", '(int)123'), - ("%05i", "00123", '(int)123'), - ("%05u", "00123", '(unsigned int)123'), - ("%05ld", "00123", '(long)123'), - ("%05li", "00123", '(long)123'), - ("%05lu", "00123", '(unsigned long)123'), - ("%05lld", "00123", '(long long)123'), - ("%05lli", "00123", '(long long)123'), - ("%05llu", "00123",'(unsigned long long)123'), - ("%05zd", "00123", '(HPy_ssize_t)123'), - ("%05zi", "00123", '(HPy_ssize_t)123'), - ("%05zu", "00123", '(size_t)123'), - ("%05x", "0007b", '(int)123'), - - ("%05d", "-0123", '(int)-123'), - ("%05i", "-0123", '(int)-123'), - ("%05ld", "-0123", '(long)-123'), - ("%05li", "-0123", '(long)-123'), - ("%05lld", "-0123", '(long long)-123'), - ("%05lli", "-0123", '(long long)-123'), - ("%05zd", "-0123", '(HPy_ssize_t)-123'), - ("%05zi", "-0123", '(HPy_ssize_t)-123'), - ("%09x", "0ffffff85", '(int)-123'), - - # Integers: precision < length - ("%.1d", "123", '(int)123'), - ("%.1i", "123", '(int)123'), - ("%.1u", "123", '(unsigned int)123'), - ("%.1ld", "123", '(long)123'), - ("%.1li", "123", '(long)123'), - ("%.1lu", "123", '(unsigned long)123'), - ("%.1lld", "123", '(long long)123'), - ("%.1lli", "123", '(long long)123'), - ("%.1llu", "123",'(unsigned long long)123'), - ("%.1zd", "123", '(HPy_ssize_t)123'), - ("%.1zi", "123", '(HPy_ssize_t)123'), - ("%.1zu", "123", '(size_t)123'), - ("%.1x", "7b", '(int)123'), - - ("%.1d", "-123", '(int)-123'), - ("%.1i", "-123", '(int)-123'), - ("%.1ld", "-123", '(long)-123'), - ("%.1li", "-123", '(long)-123'), - ("%.1lld", "-123", '(long long)-123'), - ("%.1lli", "-123", '(long long)-123'), - ("%.1zd", "-123", '(HPy_ssize_t)-123'), - ("%.1zi", "-123", '(HPy_ssize_t)-123'), - ("%.1x", "ffffff85", '(int)-123'), - - # Integers: precision > length - ("%.5d", "00123", '(int)123'), - ("%.5i", "00123", '(int)123'), - ("%.5u", "00123", '(unsigned int)123'), - ("%.5ld", "00123", '(long)123'), - ("%.5li", "00123", '(long)123'), - ("%.5lu", "00123", '(unsigned long)123'), - ("%.5lld", "00123", '(long long)123'), - ("%.5lli", "00123", '(long long)123'), - ("%.5llu", "00123",'(unsigned long long)123'), - ("%.5zd", "00123", '(HPy_ssize_t)123'), - ("%.5zi", "00123", '(HPy_ssize_t)123'), - ("%.5zu", "00123", '(size_t)123'), - ("%.5x", "0007b", '(int)123'), - - ("%.5d", "-00123", '(int)-123'), - ("%.5i", "-00123", '(int)-123'), - ("%.5ld", "-00123", '(long)-123'), - ("%.5li", "-00123", '(long)-123'), - ("%.5lld", "-00123", '(long long)-123'), - ("%.5lli", "-00123", '(long long)-123'), - ("%.5zd", "-00123", '(HPy_ssize_t)-123'), - ("%.5zi", "-00123", '(HPy_ssize_t)-123'), - ("%.9x", "0ffffff85", '(int)-123'), - - # Integers: width > precision > length - ("%7.5d", " 00123", '(int)123'), - ("%7.5i", " 00123", '(int)123'), - ("%7.5u", " 00123", '(unsigned int)123'), - ("%7.5ld", " 00123", '(long)123'), - ("%7.5li", " 00123", '(long)123'), - ("%7.5lu", " 00123", '(unsigned long)123'), - ("%7.5lld", " 00123", '(long long)123'), - ("%7.5lli", " 00123", '(long long)123'), - ("%7.5llu", " 00123",'(unsigned long long)123'), - ("%7.5zd", " 00123", '(HPy_ssize_t)123'), - ("%7.5zi", " 00123", '(HPy_ssize_t)123'), - ("%7.5zu", " 00123", '(size_t)123'), - ("%7.5x", " 0007b", '(int)123'), - - ("%7.5d", " -00123", '(int)-123'), - ("%7.5i", " -00123", '(int)-123'), - ("%7.5ld", " -00123", '(long)-123'), - ("%7.5li", " -00123", '(long)-123'), - ("%7.5lld", " -00123", '(long long)-123'), - ("%7.5lli", " -00123", '(long long)-123'), - ("%7.5zd", " -00123", '(HPy_ssize_t)-123'), - ("%7.5zi", " -00123", '(HPy_ssize_t)-123'), - ("%10.9x", " 0ffffff85", '(int)-123'), - - # Integers: width > precision > length, 0-flag - ("%07.5d", "0000123", '(int)123'), - ("%07.5i", "0000123", '(int)123'), - ("%07.5u", "0000123", '(unsigned int)123'), - ("%07.5ld", "0000123", '(long)123'), - ("%07.5li", "0000123", '(long)123'), - ("%07.5lu", "0000123", '(unsigned long)123'), - ("%07.5lld", "0000123", '(long long)123'), - ("%07.5lli", "0000123", '(long long)123'), - ("%07.5llu", "0000123",'(unsigned long long)123'), - ("%07.5zd", "0000123", '(HPy_ssize_t)123'), - ("%07.5zi", "0000123", '(HPy_ssize_t)123'), - ("%07.5zu", "0000123", '(size_t)123'), - ("%07.5x", "000007b", '(int)123'), - - ("%07.5d", "-000123", '(int)-123'), - ("%07.5i", "-000123", '(int)-123'), - ("%07.5ld", "-000123", '(long)-123'), - ("%07.5li", "-000123", '(long)-123'), - ("%07.5lld", "-000123", '(long long)-123'), - ("%07.5lli", "-000123", '(long long)-123'), - ("%07.5zd", "-000123", '(HPy_ssize_t)-123'), - ("%07.5zi", "-000123", '(HPy_ssize_t)-123'), - ("%010.9x","00ffffff85", '(int)-123'), - - # Integers: precision > width > length - ("%5.7d", "0000123", '(int)123'), - ("%5.7i", "0000123", '(int)123'), - ("%5.7u", "0000123", '(unsigned int)123'), - ("%5.7ld", "0000123", '(long)123'), - ("%5.7li", "0000123", '(long)123'), - ("%5.7lu", "0000123", '(unsigned long)123'), - ("%5.7lld", "0000123", '(long long)123'), - ("%5.7lli", "0000123", '(long long)123'), - ("%5.7llu", "0000123",'(unsigned long long)123'), - ("%5.7zd", "0000123", '(HPy_ssize_t)123'), - ("%5.7zi", "0000123", '(HPy_ssize_t)123'), - ("%5.7zu", "0000123", '(size_t)123'), - ("%5.7x", "000007b", '(int)123'), - - ("%5.7d", "-0000123", '(int)-123'), - ("%5.7i", "-0000123", '(int)-123'), - ("%5.7ld", "-0000123", '(long)-123'), - ("%5.7li", "-0000123", '(long)-123'), - ("%5.7lld", "-0000123", '(long long)-123'), - ("%5.7lli", "-0000123", '(long long)-123'), - ("%5.7zd", "-0000123", '(HPy_ssize_t)-123'), - ("%5.7zi", "-0000123", '(HPy_ssize_t)-123'), - ("%9.10x", "00ffffff85", '(int)-123'), - - # Integers: precision > width > length, 0-flag - ("%05.7d", "0000123", '(int)123'), - ("%05.7i", "0000123", '(int)123'), - ("%05.7u", "0000123", '(unsigned int)123'), - ("%05.7ld", "0000123", '(long)123'), - ("%05.7li", "0000123", '(long)123'), - ("%05.7lu", "0000123", '(unsigned long)123'), - ("%05.7lld", "0000123", '(long long)123'), - ("%05.7lli", "0000123", '(long long)123'), - ("%05.7llu", "0000123",'(unsigned long long)123'), - ("%05.7zd", "0000123", '(HPy_ssize_t)123'), - ("%05.7zi", "0000123", '(HPy_ssize_t)123'), - ("%05.7zu", "0000123", '(size_t)123'), - ("%05.7x", "000007b", '(int)123'), - - ("%05.7d", "-0000123", '(int)-123'), - ("%05.7i", "-0000123", '(int)-123'), - ("%05.7ld", "-0000123", '(long)-123'), - ("%05.7li", "-0000123", '(long)-123'), - ("%05.7lld", "-0000123", '(long long)-123'), - ("%05.7lli", "-0000123", '(long long)-123'), - ("%05.7zd", "-0000123", '(HPy_ssize_t)-123'), - ("%05.7zi", "-0000123", '(HPy_ssize_t)-123'), - ("%09.10x","00ffffff85", '(int)-123'), - - # Integers: precision = 0, arg = 0 (empty string in C) - ("%.0d", "0", '(int)0'), - ("%.0i", "0", '(int)0'), - ("%.0u", "0", '(unsigned int)0'), - ("%.0ld", "0", '(long)0'), - ("%.0li", "0", '(long)0'), - ("%.0lu", "0", '(unsigned long)0'), - ("%.0lld", "0", '(long long)0'), - ("%.0lli", "0", '(long long)0'), - ("%.0llu", "0", '(unsigned long long)0'), - ("%.0zd", "0", '(HPy_ssize_t)0'), - ("%.0zi", "0", '(HPy_ssize_t)0'), - ("%.0zu", "0", '(size_t)0'), - ("%.0x", "0", '(int)0'), - - # Strings - ("%s", "None", ' "None"'), - ("%U", "None", 'unicode'), - ("%A", "None", 'ctx->h_None'), - ("%S", "None", 'ctx->h_None'), - ("%R", "None", 'ctx->h_None'), - ("%V", "None", 'unicode, "ignored"'), - ("%V", "None", ' NULL, "None"'), - - # Strings: width < length - ("%1s", "None", ' "None"'), - ("%1U", "None", 'unicode'), - ("%1A", "None", 'ctx->h_None'), - ("%1S", "None", 'ctx->h_None'), - ("%1R", "None", 'ctx->h_None'), - ("%1V", "None", 'unicode, "ignored"'), - ("%1V", "None", ' NULL, "None"'), - - # Strings: width > length - ("%5s", " None", ' "None"'), - ("%5U", " None", 'unicode'), - ("%5A", " None", 'ctx->h_None'), - ("%5S", " None", 'ctx->h_None'), - ("%5R", " None", 'ctx->h_None'), - ("%5V", " None", 'unicode, "ignored"'), - ("%5V", " None", ' NULL, "None"'), - - # Strings: precision < length - ("%.1s", "N", ' "None"'), - ("%.1U", "N", 'unicode'), - ("%.1A", "N", 'ctx->h_None'), - ("%.1S", "N", 'ctx->h_None'), - ("%.1R", "N", 'ctx->h_None'), - ("%.1V", "N", 'unicode, "ignored"'), - ("%.1V", "N", ' NULL, "None"'), - - # Strings: precision > length - ("%.5s", "None", ' "None"'), - ("%.5U", "None", 'unicode'), - ("%.5A", "None", 'ctx->h_None'), - ("%.5S", "None", 'ctx->h_None'), - ("%.5R", "None", 'ctx->h_None'), - ("%.5V", "None", 'unicode, "ignored"'), - ("%.5V", "None", ' NULL, "None"'), - - # Strings: precision < length, width > length - ("%5.1s", " N", ' "None"'), - ("%5.1U", " N", 'unicode'), - ("%5.1A", " N", 'ctx->h_None'), - ("%5.1S", " N", 'ctx->h_None'), - ("%5.1R", " N", 'ctx->h_None'), - ("%5.1V", " N", 'unicode, "ignored"'), - ("%5.1V", " N", ' NULL, "None"'), - - # Strings: width < length, precision > length - ("%1.5s", "None", ' "None"'), - ("%1.5U", "None", 'unicode'), - ("%1.5A", "None", 'ctx->h_None'), - ("%1.5S", "None", 'ctx->h_None'), - ("%1.5R", "None", 'ctx->h_None'), - ("%1.5V", "None", 'unicode, "ignored"'), - ("%1.5V", "None", ' NULL, "None"'), - - # Additional HPy tests: - ("%c", (OverflowError, re.escape("character argument not in range(0x110000)")), "0x10ffff + 2"), - - ("check if %5d %s %6.3d is %5S or %6.3S", - "check if 42 == -042 is True or Fal", - '42, "==", -42, ctx->h_True, ctx->h_False') - ] - - cpython_incompatible_cases = [ - ( "%s", (SystemError, "null c string passed as value for formatting unit '%s'"), "NULL"), - - ( '%4p', (SystemError, "formatting unit '%p' does not support width nor precision"), "0"), - ( '%04p', (SystemError, "formatting unit '%p' does not support 0-padding"), "0"), - ( '%.4p', (SystemError, "formatting unit '%p' does not support width nor precision"), "0"), - ( '%8.4p', (SystemError, "formatting unit '%p' does not support width nor precision"), "0"), - ('%08.4p', (SystemError, "formatting unit '%p' does not support 0-padding"), "0"), - - ( '%4c', (SystemError, "formatting unit '%c' does not support width nor precision"), "0"), - ( '%04c', (SystemError, "formatting unit '%c' does not support 0-padding"), "0"), - ( '%.4c', (SystemError, "formatting unit '%c' does not support width nor precision"), "0"), - ( '%8.4c', (SystemError, "formatting unit '%c' does not support width nor precision"), "0"), - ('%08.4c', (SystemError, "formatting unit '%c' does not support 0-padding"), "0"), - - ("%U", (SystemError, ".*HPy_NULL passed.*"), "HPy_NULL"), - ("%S", (SystemError, ".*HPy_NULL passed.*"), "HPy_NULL"), - ("%R", (SystemError, ".*HPy_NULL passed.*"), "HPy_NULL"), - ("%A", (SystemError, ".*HPy_NULL passed.*"), "HPy_NULL"), - - ("%0s", (SystemError, "formatting unit '%s' does not support 0-padding"), "0"), - ("%0p", (SystemError, "formatting unit '%p' does not support 0-padding"), "0"), - ("%0U", (SystemError, "formatting unit '%U' does not support 0-padding"), "0"), - ("%0V", (SystemError, "formatting unit '%V' does not support 0-padding"), "0"), - ("%0S", (SystemError, "formatting unit '%S' does not support 0-padding"), "0"), - ("%0R", (SystemError, "formatting unit '%R' does not support 0-padding"), "0"), - ("%0A", (SystemError, "formatting unit '%A' does not support 0-padding"), "0"), - ] - - cases += cpython_incompatible_cases - cpython_incompatible_cases = set(cpython_incompatible_cases) - - # Generate a unique name for each test that is also valid C identifier - names = ['a' + str(i) for i in range(0, len(cases))] - cases = {name:case for (name, case) in itertools.zip_longest(names, cases)} - - # --- - # Generate the test code from the cases: - def makefun(name, fmt, arg): - cpy_arg = arg.replace("ctx->h_None", "Py_None").replace("HPy_ssize_t", "Py_ssize_t") - return """ - HPyDef_METH({name}, "{name}", HPyFunc_NOARGS) - static HPy {name}_impl(HPyContext *ctx, HPy self) - {{ - HPy unicode = HPyUnicode_FromString(ctx, "None"); - if (HPy_IsNull(unicode)) return HPy_NULL; - HPy result = HPyUnicode_FromFormat(ctx, "{fmt}", {arg}); - HPy_Close(ctx, unicode); - return result; - }} - - #ifdef CPM_WITH_CPYTHON - HPyDef_METH({name}_cpython, "{name}_cpython", HPyFunc_NOARGS) - static HPy {name}_cpython_impl(HPyContext *ctx, HPy self) - {{ - PyObject *unicode = PyUnicode_FromString("None"); - PyObject *py = PyUnicode_FromFormat("{fmt}", {cpy_arg}); - HPy hpy = HPy_NULL; - if (py != NULL) {{ - hpy = HPy_FromPyObject(ctx, py); - Py_DECREF(py); - }} - Py_DECREF(unicode); - return hpy; - }} - #endif - """.format(name=name, fmt=fmt, arg=arg, cpy_arg=cpy_arg) - - # Change False->True to also check comparison with CPython. - # Works only for 3.12 or higher, lower versions have bugs that are - # fixed in HPy - compare_with_cpython = False and \ - hpy_abi == 'cpython' and \ - sys.implementation.name == 'cpython' and \ - sys.implementation.version.major >= 3 and \ - sys.implementation.version.minor >= 12 - - # Create functions for each case using the "makefun" template, export them - lines = ['#define CPM_WITH_CPYTHON'] if compare_with_cpython else [] - lines += [makefun(name, fmt, arg) for (name, (fmt, _, arg)) in cases.items()] - lines += ["@EXPORT({})".format(name) for name in cases.keys()] - if compare_with_cpython: - lines += ["@EXPORT({}_cpython)".format(name) for name in cases.keys()] - lines += ["@INIT"] - - mod = self.make_module("\n".join(lines)) - - def check_cpython_raises_any(name): - try: - getattr(mod, name + "_cpython")() - return False - except: - return True - - for (name, case) in cases.items(): - (_, expected, _) = case - if isinstance(expected, tuple): - (expected_type, expected_message) = expected - with pytest.raises(expected_type, match=expected_message): - getattr(mod, name)() - if compare_with_cpython and case not in cpython_incompatible_cases: - check_cpython_raises_any(name) - continue - - assert getattr(mod, name)() == expected, name + ":" + repr(case) - if compare_with_cpython and case not in cpython_incompatible_cases: - assert getattr(mod, name)() == getattr(mod, name + "_cpython")(), \ - "CPython check: " + name + ":" + repr(case) - - def test_FromFormat_Ptr(self): - # '%p' is platform dependent to some extent, so we need to use regex - mod = self.make_module(""" - HPyDef_METH(p, "p", HPyFunc_NOARGS) - static HPy p_impl(HPyContext *ctx, HPy self) - { - return HPyUnicode_FromFormat(ctx, "prefix-%p-suffix", (void*) 0xbeef); - } - - @EXPORT(p) - @INIT - """) - assert re.match(r'prefix-0x[0]{,60}[bB][eE][eE][fF]-suffix', mod.p()) - - def test_FromFormat_PyObjs(self): - mod = self.make_module(""" - HPyDef_METH(S, "S", HPyFunc_O) - static HPy S_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_FromFormat(ctx, "prefix-%S-suffix", arg); - } - - HPyDef_METH(R, "R", HPyFunc_O) - static HPy R_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_FromFormat(ctx, "prefix-%R-suffix", arg); - } - - HPyDef_METH(A, "A", HPyFunc_O) - static HPy A_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_FromFormat(ctx, "prefix-%A-suffix", arg); - } - - @EXPORT(S) - @EXPORT(R) - @EXPORT(A) - @INIT - """) - - class MyObj: - def __str__(self): - return "MyObj.__str__" - - def __repr__(self): - return "MyObj.__repr__ü" - - assert mod.S('ABC') == 'prefix-ABC-suffix' - assert mod.S(42) == 'prefix-42-suffix' - assert mod.S(MyObj()) == 'prefix-MyObj.__str__-suffix' - - assert mod.R('ABC') == "prefix-'ABC'-suffix" - assert mod.R(42) == 'prefix-42-suffix' - assert mod.R(MyObj()) == 'prefix-MyObj.__repr__ü-suffix' - - assert mod.A('ABC') == "prefix-'ABC'-suffix" - assert mod.A(42) == 'prefix-42-suffix' - assert mod.A(MyObj()) == 'prefix-MyObj.__repr__\\xfc-suffix' - - def test_FromFormat_NoAsciiEncodedFmt(self): - mod = self.make_module(""" - HPyDef_METH(no_ascii_fmt, "no_ascii_fmt", HPyFunc_O) - static HPy no_ascii_fmt_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t s; - const char *fmt = HPyUnicode_AsUTF8AndSize(ctx, arg, &s); - return HPyUnicode_FromFormat(ctx, fmt); - } - - @EXPORT(no_ascii_fmt) - @INIT - """) - - with pytest.raises(ValueError, match="expected an ASCII-encoded format string, got a non-ASCII byte: 0xc3"): - mod.no_ascii_fmt("format ü") - - def test_FromFormat_Unicode(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPyUnicode_FromFormat(ctx, "%10.5S", arg); - } - - @EXPORT(f) - @INIT - """) - assert mod.f("€urΘpe") == " €urΘp" - - def test_FromFormat_LongFormat(self): - chunk_size = 1000 - chunks_count = 5 - total_c_size = (chunk_size + 1) * chunks_count + 1 - args = ','.join([str(i) for i in range(1, chunks_count+1)]) - mod = self.make_module(""" - #include - - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - {{ - const size_t chunk_size = {chunk_size} + 1; // for the '%d' - const size_t total_size = {total_size}; - char fmt[{total_size}]; - memset(fmt, 'a', total_size); - fmt[total_size - 1] = '\\0'; - for (size_t i = 0; i < {chunks_count}; i++) {{ - fmt[i * chunk_size] = '%'; - fmt[(i * chunk_size)+1] = 'd'; - }} - return HPyUnicode_FromFormat(ctx, fmt, {args}); - }} - - @EXPORT(f) - @INIT - """.format(chunk_size=chunk_size, chunks_count=chunks_count, total_size=total_c_size, args=args)) - assert mod.f() == ''.join([str(i) + ("a" * (chunk_size - 1)) for i in range(1,chunks_count+1)]) - - def test_FromFormat_Limits(self): - import sys - mod = self.make_module(""" - #include - - HPyDef_METH(width, "width", HPyFunc_NOARGS) - static HPy width_impl(HPyContext *ctx, HPy self) - {{ - char fmt[512]; - sprintf(fmt, "%%%llud", ((unsigned long long) HPY_SSIZE_T_MAX) + 1ull); - return HPyUnicode_FromFormat(ctx, fmt, 42); - }} - - HPyDef_METH(precision, "precision", HPyFunc_NOARGS) - static HPy precision_impl(HPyContext *ctx, HPy self) - {{ - char fmt[512]; - sprintf(fmt, "%%.%llud", ((unsigned long long) HPY_SSIZE_T_MAX) + 1ull); - return HPyUnicode_FromFormat(ctx, fmt, 42); - }} - - HPyDef_METH(memory_err_width, "memory_err_width", HPyFunc_NOARGS) - static HPy memory_err_width_impl(HPyContext *ctx, HPy self) - {{ - return HPyUnicode_FromFormat(ctx, "%{max_size}d", 42); - }} - - HPyDef_METH(memory_err_precision, "memory_err_precision", HPyFunc_NOARGS) - static HPy memory_err_precision_impl(HPyContext *ctx, HPy self) - {{ - return HPyUnicode_FromFormat(ctx, "%.{max_size}d", 42); - }} - - @EXPORT(width) - @EXPORT(precision) - @INIT - """.format(max_size = str(sys.maxsize + 1))) - with pytest.raises(ValueError) as exc: - mod.width() - assert str(exc.value) == "width too big" - with pytest.raises(ValueError) as exc: - mod.precision() - assert str(exc.value) == "precision too big" - - def test_FromEncodedObject(self): - import pytest - mod = self.make_module(""" - static const char *as_string(HPyContext *ctx, HPy h) - { - const char *res = HPyUnicode_AsUTF8AndSize(ctx, h, NULL); - if (res == NULL) - HPyErr_Clear(ctx); - return res; - } - - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy h_obj; - const char *encoding, *errors; - if (nargs != 3) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 3 arguments"); - return HPy_NULL; - } - h_obj = HPy_Is(ctx, args[0], ctx->h_None) ? HPy_NULL : args[0]; - encoding = as_string(ctx, args[1]); - errors = as_string(ctx, args[2]); - return HPyUnicode_FromEncodedObject(ctx, h_obj, encoding, errors); - } - @EXPORT(f) - @INIT - """) - # "hellö" as UTF-8 encoded bytes - utf8_bytes = b"hell\xc3\xb6" - # "hellö" as UTF-16 encoded bytes - utf16_bytes = b'\xff\xfeh\x00e\x00l\x00l\x00\xf6\x00' - ascii_codepoints = bytes(range(1, 128)) - - # note: None (if passed to arguments 'encoding' or 'errors') will be - # translated to a NULL pointer - - for errors in (None, "strict", "ignore", "replace"): - assert mod.f(b"hello", "ascii", errors) == "hello" - assert mod.f(utf8_bytes, "utf8", errors) == "hellö" - assert mod.f(utf16_bytes, "utf16", errors) == "hellö" - assert len(mod.f(ascii_codepoints, "ascii", errors)) == 127 - assert len(mod.f(ascii_codepoints, "utf8", errors)) == 127 - - # None will be translated to NULL and then defaults to UTF-8 encoding - for encoding in (None, "utf8"): - assert mod.f(utf8_bytes, encoding, None) == "hellö" - - with pytest.raises(UnicodeDecodeError): - mod.f(utf16_bytes, encoding, None) - - assert mod.f(utf16_bytes, encoding, "replace") == '��h\x00e\x00l\x00l\x00�\x00' - assert mod.f(utf16_bytes, encoding, "ignore") == 'h\x00e\x00l\x00l\x00\x00' - - # test unknown encoding - with pytest.raises(LookupError): - mod.f(b"hello", "qwertyasdf13", None) - - with pytest.raises(SystemError): - mod.f(None, None, None) - with pytest.raises(TypeError): - mod.f("hello", None, None) - with pytest.raises(TypeError): - mod.f(123, None, None) - - def test_Substring(self): - import pytest - import string - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy_ssize_t start, end; - if (nargs != 3) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly 3 arguments"); - return HPy_NULL; - } - - start = HPyLong_AsSsize_t(ctx, args[1]); - if (start == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - - end = HPyLong_AsSsize_t(ctx, args[2]); - if (end == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - - return HPyUnicode_Substring(ctx, args[0], start, end); - } - @EXPORT(f) - @INIT - """) - # start == end - assert mod.f("hello", 0, 0) == "" - assert mod.f("hello", 4, 4) == "" - assert mod.f("hello", 5, 0) == "" - # start < end - assert mod.f("hello", 0, 5) == "hello" - assert mod.f("hello", 0, 100) == "hello" - assert mod.f('hello', 0, 1) == 'h' - assert mod.f("hello", 0, 2) == "he" - assert mod.f("hello", 2, 5) == "llo" - assert mod.f("hello", 2, 4) == "ll" - assert mod.f("hello", 100, 105) == "" - # start > end - assert mod.f("hello", 2000, 1000) == "" - assert mod.f("hello", 2, 1) == "" - - with pytest.raises(IndexError): - mod.f("hello", -2, 5) - with pytest.raises(IndexError): - mod.f("hello", 2, -1) - - # The following block is a variation of CPython's - # 'string_tests.py: test_extended_getslice'. This compares substrings - # with list slicing. - s = string.ascii_letters + string.digits - n = len(s) - indices = (0, 1, 3, 41, 1000, n-1, n-2, n-37) - for start in indices: - for stop in indices: - L = list(s)[start:stop] - assert mod.f(s, start, stop) == "".join(L) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_importing.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_importing.py deleted file mode 100644 index 0085dac5a8..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_importing.py +++ /dev/null @@ -1,78 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from .support import HPyTest -from hpy.devel.abitag import get_hpy_ext_suffix - -@pytest.fixture(params=['cpython', 'universal', 'hybrid'] + (['debug'] if HPyTest.supports_debug_mode() else [])) -def hpy_abi(request): - abi = request.param - yield abi - - -class TestImporting(HPyTest): - - def full_import(self, name, mod_filename): - import importlib - import sys - import os - if name in sys.modules: - raise ValueError( - "Test module {!r} already present in sys.modules".format(name)) - importlib.invalidate_caches() - mod_dir = os.path.dirname(mod_filename) - sys.path.insert(0, mod_dir) - try: - module = importlib.import_module(name) - assert sys.modules[name] is module - finally: - # assert that the module import didn't change the sys.path entry - # that was added above, then remove the entry. - assert sys.path[0] == mod_dir - del sys.path[0] - if name in sys.modules: - del sys.modules[name] - return module - - def test_importing_attributes(self, hpy_abi, tmpdir): - import pytest - if not self.supports_ordinary_make_module_imports(): - pytest.skip() - mod = self.make_module(""" - @INIT - """, name='mytest') - mod = self.full_import(mod.__name__, mod.__file__) - assert mod.__name__ == 'mytest' - assert mod.__package__ == '' - assert mod.__doc__ == 'some test for hpy' - assert mod.__loader__.name == 'mytest' - assert mod.__spec__.loader is mod.__loader__ - assert mod.__spec__.name == 'mytest' - assert mod.__file__ - - if hpy_abi == 'debug': - hpy_abi = 'universal' - ext_suffix = get_hpy_ext_suffix(hpy_abi) - assert repr(mod) == ''.format( - repr(str(tmpdir.join('mytest' + ext_suffix)))) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_legacy_forbidden.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_legacy_forbidden.py deleted file mode 100644 index 5ff6f91976..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_legacy_forbidden.py +++ /dev/null @@ -1,102 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - - -""" -In this file we check that if we use legacy features in universal mode, we -get the expected compile time errors -""" - -import sys -import pytest -from .support import HPyTest, make_hpy_abi_fixture, ONLY_LINUX - -# this is not strictly correct, we should check whether the actual compiler -# is GCC. But for the CI and most cases, it's enough to assume that if we are -# on linux we are using GCC. -# -# We need this because some of the nice compilation errors (such as the ones -# causes by _HPY_LEGACY) are triggered only by gcc. Would be nice to have them -# also for other compilers -ONLY_GCC = ONLY_LINUX - -pytestmark = pytest.mark.skip("capfd not working properly on GraalPy") - -class TestLegacyForbidden(HPyTest): - - hpy_abi = make_hpy_abi_fixture(['universal'], class_fixture=True) - - LEGACY_ERROR = "Cannot use legacy functions when targeting the HPy Universal ABI" - - def test_expect_make_error(self): - src = """ - #error "this is a compile time error" - """ - self.expect_make_error(src, "this is a compile time error") - - @pytest.mark.skip("different include dir order on GraalPy") - def test_Python_h_forbidden(self, capfd): - src = """ - #include - @INIT - """ - self.expect_make_error(src, - "It is forbidden to #include " - "when targeting the HPy Universal ABI") - - @ONLY_GCC - def test_HPy_AsPyObject(self, capfd): - # NOTE: in this test we don't include Python.h. We want to test that - # we get a nice compile-time error by just calling HPy_AsPyObject. - # that's why we use "cpy_PyObject" (which is available because defined - # by hpy.h) - src = """ - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - cpy_PyObject *pyobj = HPy_AsPyObject(ctx, self); - (void)pyobj; // silence the warning about unused variable - return HPy_NULL; - } - @EXPORT(f) - @INIT - """ - self.expect_make_error(src, self.LEGACY_ERROR) - - @ONLY_GCC - def test_HPy_FromPyObject(self, capfd): - # NOTE: in this test we don't include Python.h. We want to test that - # we get a nice compile-time error by just calling HPy_AsPyObject. - # that's why we use "cpy_PyObject" (which is available because defined - # by hpy.h) - src = """ - HPyDef_METH(f, "f", HPyFunc_NOARGS) - static HPy f_impl(HPyContext *ctx, HPy self) - { - cpy_PyObject *pyobj = NULL; - return HPy_FromPyObject(ctx, pyobj); - } - @EXPORT(f) - @INIT - """ - self.expect_make_error(src, self.LEGACY_ERROR) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_number.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_number.py deleted file mode 100644 index 347bd6d675..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_number.py +++ /dev/null @@ -1,270 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest - - -class TestNumber(HPyTest): - - def test_bool_from_bool_and_long(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(from_bool, "from_bool", HPyFunc_O) - static HPy from_bool_impl(HPyContext *ctx, HPy self, HPy arg) - { - int32_t x = HPyLong_AsInt32_t(ctx, arg); - if (x == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - if (x != 0 && x != 1) { - HPyErr_SetString(ctx, ctx->h_ValueError, - "value must be 0 or 1"); - return HPy_NULL; - } - return HPyBool_FromBool(ctx, (x ? true : false)); - } - - HPyDef_METH(from_long, "from_long", HPyFunc_O) - static HPy from_long_impl(HPyContext *ctx, HPy self, HPy arg) - { - long x = HPyLong_AsLong(ctx, arg); - if (x == -1 && HPyErr_Occurred(ctx)) - return HPy_NULL; - return HPyBool_FromLong(ctx, x); - } - @EXPORT(from_bool) - @EXPORT(from_long) - @INIT - """) - assert mod.from_bool(0) is False - assert mod.from_bool(1) is True - with pytest.raises(ValueError): - mod.from_bool(2) - assert mod.from_long(0) is False - assert mod.from_long(42) is True - - def test_unary(self): - import pytest - import operator - ops = ( - ('Negative', operator.neg), - ('Positive', operator.pos), - ('Absolute', abs), - ('Invert', operator.invert), - ('Index', operator.index), - ('Long', int), - ('Float', float), - ) - template = """ - HPyDef_METH(f_{c_name}, "f_{c_name}", HPyFunc_O) - static HPy f_{c_name}_impl(HPyContext *ctx, HPy self, HPy arg) - {{ - return HPy_{c_name}(ctx, arg); - }} - @EXPORT(f_{c_name}) - """ - code = [] - for c_name, _ in ops: - code.append(template.format(c_name=c_name)) - code.append('@INIT') - mod = self.make_module('\n'.join(code), name='unary_ops') - for c_name, op in ops: - c_op = getattr(mod, 'f_%s' % c_name) - assert c_op(-5) == op(-5) - assert c_op(6) == op(6) - try: - res = op(4.75) - except Exception as e: - with pytest.raises(e.__class__): - c_op(4.75) - else: - assert c_op(4.75) == res - - def test_binary(self): - import operator - ops = ( - ('Add', operator.add), - ('Subtract', operator.sub), - ('Multiply', operator.mul), - ('FloorDivide', operator.floordiv), - ('TrueDivide', operator.truediv), - ('Remainder', operator.mod), - ('Divmod', divmod), - ('Lshift', operator.lshift), - ('Rshift', operator.rshift), - ('And', operator.and_), - ('Xor', operator.xor), - ('Or', operator.or_), - ) - template = """ - HPyDef_METH(f_{c_name}, "f_{c_name}", HPyFunc_VARARGS) - static HPy f_{c_name}_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - {{ - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - return HPy_{c_name}(ctx, a, b); - }} - @EXPORT(f_{c_name}) - """ - code = [] - for c_name, _ in ops: - code.append(template.format(c_name=c_name)) - code.append('@INIT') - mod = self.make_module('\n'.join(code), name='binary_ops') - for c_name, op in ops: - c_op = getattr(mod, 'f_%s' % c_name) - assert c_op(5, 4) == op(5, 4) - assert c_op(6, 3) == op(6, 3) - - def test_power(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b, c; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &a, &b, &c)) - return HPy_NULL; - return HPy_Power(ctx, a, b, c); - } - @EXPORT(f) - @INIT - """) - assert mod.f(4, 5, None) == 4 ** 5 - assert mod.f(4, 5, 7) == pow(4, 5, 7) - - def test_matmul(self): - class Mat: - def __matmul__(self, other): - return ('matmul', self, other) - m1 = Mat() - m2 = Mat() - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - return HPy_MatrixMultiply(ctx, a, b); - } - @EXPORT(f) - @INIT - """) - assert mod.f(m1, m2) == m1.__matmul__(m2) - - def test_inplace_binary(self): - import operator - for c_name, py_name in [ - ('Add', '__iadd__'), - ('Subtract', '__isub__'), - ('Multiply', '__imul__'), - ('FloorDivide', '__ifloordiv__'), - ('TrueDivide', '__itruediv__'), - ('Remainder', '__imod__'), - ('Lshift', '__ilshift__'), - ('Rshift', '__irshift__'), - ('And', '__iand__'), - ('Xor', '__ixor__'), - ('Or', '__ior__'), - ]: - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - return HPy_InPlace%s(ctx, a, b); - } - @EXPORT(f) - @INIT - """ % (c_name,), name='number_'+c_name) - class A: - def mymethod(self, b): - return (py_name, b) - setattr(A, py_name, A.mymethod) - assert mod.f(A(), 12.34) == A().mymethod(12.34) - - def test_inplace_power(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b, c; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OOO", &a, &b, &c)) - return HPy_NULL; - return HPy_InPlacePower(ctx, a, b, c); - } - @EXPORT(f) - @INIT - """) - class A: - def __ipow__(self, b): - return ('ipow', b) - # the behavior of PyNumber_InPlacePower is weird: if __ipow__ is - # defined, the 3rd arg is always ignored, even if the doc say the - # opposite - assert mod.f(A(), 5, None) == A().__ipow__(5) - assert mod.f(A(), 7, 'hello') == A().__ipow__(7) - assert mod.f(4, 5, 7) == pow(4, 5, 7) - - def test_inplace_matmul(self): - class Mat: - def __imatmul__(self, other): - return ('imatmul', self, other) - m1 = Mat() - m2 = Mat() - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - return HPy_InPlaceMatrixMultiply(ctx, a, b); - } - @EXPORT(f) - @INIT - """) - assert mod.f(m1, m2) == m1.__imatmul__(m2) - - def test_number_check(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int cond = HPyNumber_Check(ctx, arg); - return HPyLong_FromLong(ctx, cond); - } - @EXPORT(f) - @INIT - """) - assert mod.f("foo") == 0 - assert mod.f(42) == 1 - assert mod.f(42.1) == 1 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_object.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_object.py deleted file mode 100644 index 8a5bbfc291..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_object.py +++ /dev/null @@ -1,838 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestObject(HPyTest): - def test_getattr(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy name, result; - name = HPyUnicode_FromString(ctx, "foo"); - if (HPy_IsNull(name)) - return HPy_NULL; - result = HPy_GetAttr(ctx, arg, name); - HPy_Close(ctx, name); - if (HPy_IsNull(result)) - return HPy_NULL; - return result; - } - @EXPORT(f) - @INIT - """) - - class Attrs: - def __init__(self, **kw): - for k, v in kw.items(): - setattr(self, k, v) - - class ClassAttr: - foo = 10 - - class PropAttr: - @property - def foo(self): - return 11 - - assert mod.f(Attrs(foo=5)) == 5 - with pytest.raises(AttributeError): - mod.f(Attrs()) - with pytest.raises(AttributeError): - mod.f(42) - assert mod.f(ClassAttr) == 10 - assert mod.f(ClassAttr()) == 10 - assert mod.f(PropAttr()) == 11 - - def test_getattr_s(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy result; - result = HPy_GetAttr_s(ctx, arg, "foo"); - if (HPy_IsNull(result)) - return HPy_NULL; - return result; - } - @EXPORT(f) - @INIT - """) - - class Attrs: - def __init__(self, **kw): - for k, v in kw.items(): - setattr(self, k, v) - - class ClassAttr: - foo = 10 - - class PropAttr: - @property - def foo(self): - return 11 - - assert mod.f(Attrs(foo=5)) == 5 - with pytest.raises(AttributeError): - mod.f(Attrs()) - with pytest.raises(AttributeError): - mod.f(42) - assert mod.f(ClassAttr) == 10 - assert mod.f(ClassAttr()) == 10 - assert mod.f(PropAttr()) == 11 - - def test_hasattr(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy name; - int result; - name = HPyUnicode_FromString(ctx, "foo"); - if (HPy_IsNull(name)) - return HPy_NULL; - result = HPy_HasAttr(ctx, arg, name); - HPy_Close(ctx, name); - if (result == -1) - return HPy_NULL; - if (result) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - - class Attrs: - def __init__(self, **kw): - for k, v in kw.items(): - setattr(self, k, v) - - class ClassAttr: - foo = 10 - - class PropAttr: - @property - def foo(self): - return 11 - - class PropAttrRaising: - @property - def foo(self): - raise RuntimeError - - - assert mod.f(Attrs(foo=5)) is True - assert mod.f(Attrs()) is False - assert mod.f(42) is False - assert mod.f(ClassAttr) is True - assert mod.f(ClassAttr()) is True - assert mod.f(PropAttr()) is True - assert mod.f(PropAttrRaising()) is False - - - def test_hasattr_s(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_HasAttr_s(ctx, arg, "foo"); - if (result == -1) - return HPy_NULL; - if (result) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - @EXPORT(f) - @INIT - """) - - class Attrs: - def __init__(self, **kw): - for k, v in kw.items(): - setattr(self, k, v) - - class ClassAttr: - foo = 10 - - class PropAttr: - @property - def foo(self): - return 11 - - class PropAttrRaising: - @property - def foo(self): - raise RuntimeError - - assert mod.f(Attrs(foo=5)) is True - assert mod.f(Attrs()) is False - assert mod.f(42) is False - assert mod.f(ClassAttr) is True - assert mod.f(ClassAttr()) is True - assert mod.f(PropAttr()) is True - assert mod.f(PropAttrRaising()) is False - - def test_setattr(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy name; - int result; - name = HPyUnicode_FromString(ctx, "foo"); - if (HPy_IsNull(name)) - return HPy_NULL; - result = HPy_SetAttr(ctx, arg, name, ctx->h_True); - HPy_Close(ctx, name); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - - class Attrs: - pass - - class ClassAttr: - pass - - class ReadOnlyPropAttr: - @property - def foo(self): - return 11 - - class WritablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - a = Attrs() - mod.f(a) - assert a.foo is True - - mod.f(ClassAttr) - assert ClassAttr.foo is True - assert ClassAttr().foo is True - - with pytest.raises(AttributeError): - mod.f(object()) - - with pytest.raises(AttributeError): - mod.f(ReadOnlyPropAttr()) - - b = WritablePropAttr() - mod.f(b) - assert b.foo is True - - def test_setattr_s(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_SetAttr_s(ctx, arg, "foo", ctx->h_True); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - - class Attrs: - pass - - class ClassAttr: - pass - - class ReadOnlyPropAttr: - @property - def foo(self): - return 11 - - class WritablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - a = Attrs() - mod.f(a) - assert a.foo is True - - mod.f(ClassAttr) - assert ClassAttr.foo is True - assert ClassAttr().foo is True - - with pytest.raises(AttributeError): - mod.f(object()) - - with pytest.raises(AttributeError): - mod.f(ReadOnlyPropAttr()) - - b = WritablePropAttr() - mod.f(b) - assert b.foo is True - - def test_delattr(self, hpy_abi): - import pytest - if hpy_abi == "cpython": - pytest.skip("delattr not supported on GraalPy") - mod = self.make_module(""" - HPyDef_METH(del_foo, "del_foo", HPyFunc_O) - static HPy del_foo_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy name; - int result; - name = HPyUnicode_FromString(ctx, "foo"); - if (HPy_IsNull(name)) - return HPy_NULL; - result = HPy_DelAttr(ctx, arg, name); - HPy_Close(ctx, name); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(del_foo) - @INIT - """) - - class Attrs: - pass - - class ClassAttr: - pass - - class WritablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - class DeletablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - @foo.deleter - def foo(self): - del self._foo - - def set_foo(obj): - obj.foo = True - - a = Attrs() - set_foo(a) - assert a.foo is True - mod.del_foo(a) - with pytest.raises(AttributeError): - a.foo - - set_foo(ClassAttr) - assert ClassAttr.foo is True - assert ClassAttr().foo is True - mod.del_foo(ClassAttr) - with pytest.raises(AttributeError): - ClassAttr.foo - with pytest.raises(AttributeError): - ClassAttr().foo - - b = WritablePropAttr() - set_foo(b) - assert b.foo is True - with pytest.raises(AttributeError): - # does not provide a delete function, so it fails - mod.del_foo(b) - - c = DeletablePropAttr() - set_foo(c) - assert c.foo is True - mod.del_foo(c) - with pytest.raises(AttributeError): - c.foo - - def test_delattr_s(self, hpy_abi): - import pytest - if hpy_abi == "cpython": - pytest.skip("delattr not supported on GraalPy") - mod = self.make_module(""" - HPyDef_METH(del_foo, "del_foo", HPyFunc_O) - static HPy del_foo_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_DelAttr_s(ctx, arg, "foo"); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(del_foo) - @INIT - """) - - class Attrs: - pass - - class ClassAttr: - pass - - class WritablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - class DeletablePropAttr: - @property - def foo(self): - return self._foo - - @foo.setter - def foo(self, value): - self._foo = value - - @foo.deleter - def foo(self): - del self._foo - - def set_foo(obj): - obj.foo = True - - a = Attrs() - set_foo(a) - assert a.foo is True - mod.del_foo(a) - with pytest.raises(AttributeError): - a.foo - - set_foo(ClassAttr) - assert ClassAttr.foo is True - assert ClassAttr().foo is True - mod.del_foo(ClassAttr) - with pytest.raises(AttributeError): - ClassAttr.foo - with pytest.raises(AttributeError): - ClassAttr().foo - - b = WritablePropAttr() - set_foo(b) - assert b.foo is True - with pytest.raises(AttributeError): - # does not provide a delete function, so it fails - mod.del_foo(b) - - c = DeletablePropAttr() - set_foo(c) - assert c.foo is True - mod.del_foo(c) - with pytest.raises(AttributeError): - c.foo - - def test_getitem(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy key, result; - key = HPyLong_FromLong(ctx, 3); - if (HPy_IsNull(key)) - return HPy_NULL; - result = HPy_GetItem(ctx, arg, key); - HPy_Close(ctx, key); - if (HPy_IsNull(result)) - return HPy_NULL; - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f({3: "hello"}) == "hello" - with pytest.raises(KeyError) as exc: - mod.f({1: "bad"}) - assert exc.value.args == (3,) - - assert mod.f([0, 1, 2, "hello"]) == "hello" - with pytest.raises(IndexError): - mod.f([]) - - def test_getitem_i(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy result; - result = HPy_GetItem_i(ctx, arg, 3); - if (HPy_IsNull(result)) - return HPy_NULL; - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f({3: "hello"}) == "hello" - with pytest.raises(KeyError) as exc: - mod.f({1: "bad"}) - assert exc.value.args == (3,) - - assert mod.f([0, 1, 2, "hello"]) == "hello" - with pytest.raises(IndexError): - mod.f([]) - - def test_getitem_s(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy result; - result = HPy_GetItem_s(ctx, arg, "limes"); - if (HPy_IsNull(result)) - return HPy_NULL; - return result; - } - @EXPORT(f) - @INIT - """) - assert mod.f({"limes": "hello"}) == "hello" - with pytest.raises(KeyError) as exc: - mod.f({"oranges": "bad"}) - assert exc.value.args == ("limes",) - - with pytest.raises(TypeError): - mod.f([]) - - def test_setitem(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy key; - int result; - key = HPyLong_FromLong(ctx, 3); - if (HPy_IsNull(key)) - return HPy_NULL; - result = HPy_SetItem(ctx, arg, key, ctx->h_True); - HPy_Close(ctx, key); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - @EXPORT(f) - @INIT - """) - assert mod.f({}) == {3: True} - assert mod.f({"a": 1}) == {"a": 1, 3: True} - assert mod.f({3: False}) == {3: True} - - assert mod.f([0, 1, 2, False]) == [0, 1, 2, True] - with pytest.raises(IndexError): - mod.f([]) - - def test_setitem_i(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_SetItem_i(ctx, arg, 3, ctx->h_True); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - @EXPORT(f) - @INIT - """) - assert mod.f({}) == {3: True} - assert mod.f({"a": 1}) == {"a": 1, 3: True} - assert mod.f({3: False}) == {3: True} - - assert mod.f([0, 1, 2, False]) == [0, 1, 2, True] - with pytest.raises(IndexError): - mod.f([]) - - def test_setitem_s(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_SetItem_s(ctx, arg, "limes", ctx->h_True); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - @EXPORT(f) - @INIT - """) - assert mod.f({}) == {"limes": True} - assert mod.f({"a": 1}) == {"a": 1, "limes": True} - assert mod.f({"limes": False}) == {"limes": True} - - with pytest.raises(TypeError): - mod.f([]) - - def test_delitem(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(delitem3, "delitem3", HPyFunc_O) - static HPy delitem3_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy key; - int result; - key = HPyLong_FromLong(ctx, 3); - if (HPy_IsNull(key)) - return HPy_NULL; - result = HPy_DelItem(ctx, arg, key); - HPy_Close(ctx, key); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - - HPyDef_METH(delitem_i3, "delitem_i3", HPyFunc_O) - static HPy delitem_i3_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_DelItem_i(ctx, arg, 3); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - - HPyDef_METH(delitem_s3, "delitem_s3", HPyFunc_O) - static HPy delitem_s3_impl(HPyContext *ctx, HPy self, HPy arg) - { - int result; - result = HPy_DelItem_s(ctx, arg, "3"); - if (result < 0) - return HPy_NULL; - return HPy_Dup(ctx, arg); - } - - @EXPORT(delitem3) - @EXPORT(delitem_i3) - @EXPORT(delitem_s3) - @INIT - """) - # HPy_DelItem - assert mod.delitem3({3: False, 4: True}) == {4: True} - with pytest.raises(KeyError): - mod.delitem3({}) - with pytest.raises(TypeError): - mod.delitem3((1, 2, 3, 4)) - assert mod.delitem3([0, 1, 2, False]) == [0, 1, 2] - with pytest.raises(IndexError): - mod.delitem3([]) - - # HPy_DelItem_i - assert mod.delitem_i3({3: False, 4: True}) == {4: True} - with pytest.raises(KeyError): - mod.delitem_i3({}) - with pytest.raises(TypeError): - mod.delitem_i3((1, 2, 3, 4)) - assert mod.delitem_i3([0, 1, 2, False]) == [0, 1, 2] - with pytest.raises(IndexError): - mod.delitem_i3([]) - - # HPy_DelItem_s - assert mod.delitem_s3({'3': False, '4': True}) == {'4': True} - with pytest.raises(KeyError): - mod.delitem_s3({}) - with pytest.raises(TypeError): - mod.delitem_s3((1, 2, 3, 4)) - with pytest.raises(TypeError): - mod.delitem_s3([1, 2, 3, 4]) - - def test_length(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - HPy_ssize_t result; - result = HPy_Length(ctx, arg); - if (result < 0) - return HPy_NULL; - return HPyLong_FromSsize_t(ctx, result); - } - @EXPORT(f) - @INIT - """) - assert mod.f([5,6,7,8]) == 4 - assert mod.f({"a": 1}) == 1 - - def test_contains(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - int result = HPy_Contains(ctx, args[0], args[1]); - if (result == -1) { - return HPy_NULL; - } - return HPyLong_FromLong(ctx, result); - } - @EXPORT(f) - @INIT - """) - - class WithContains: - def __contains__(self, item): - return item == 42 - - class WithIter: - def __iter__(self): - return [1, 2, 3].__iter__() - - class WithGetitem: - def __getitem__(self, item): - if item > 3: - raise IndexError() - else: - return item - - class Dummy: - pass - - assert mod.f([5, 6, 42, 7, 8], 42) - assert not mod.f([5, 6, 42, 7, 8], 4) - - assert mod.f(WithContains(), 42) - assert not mod.f(WithContains(), 1) - - assert mod.f(WithIter(), 2) - assert not mod.f(WithIter(), 33) - - assert mod.f(WithGetitem(), 2) - assert not mod.f(WithGetitem(), 33) - - import pytest - with pytest.raises(TypeError): - mod.f(Dummy(), 42) - - def test_dump(self): - # _HPy_Dump is supposed to be used e.g. inside a gdb session: it - # prints various about the given handle to stdout, and it's - # implementation-specific. As such, it's hard to write a meaningful - # test: let's just call it an check it doesn't crash. - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - _HPy_Dump(ctx, arg); - return HPy_Dup(ctx, ctx->h_None); - } - @EXPORT(f) - @INIT - """) - mod.f('hello') - - def test_type(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - return HPy_Type(ctx, arg); - } - @EXPORT(f) - @INIT - """) - assert mod.f('hello') is str - assert mod.f(42) is int - - def test_typecheck(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy a, b; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &a, &b)) - return HPy_NULL; - int res = HPy_TypeCheck(ctx, a, b); - return HPyBool_FromLong(ctx, res); - } - @EXPORT(f) - @INIT - """) - class MyStr(str): - pass - assert mod.f('hello', str) - assert not mod.f('hello', int) - assert mod.f(MyStr('hello'), str) - - def test_is(self): - mod = self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - HPy obj, other; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "OO", &obj, &other)) - return HPy_NULL; - int res = HPy_Is(ctx, obj, other); - return HPyBool_FromLong(ctx, res); - } - @EXPORT(f) - @INIT - """) - assert mod.f(None, None) - a = object() - assert mod.f(a, a) - assert not mod.f(a, None) diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots.py deleted file mode 100644 index 84b79a6ce4..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots.py +++ /dev/null @@ -1,835 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2024, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -from .support import HPyTest -from .test_hpytype import PointTemplate -import pytest - - -class TestSlots(HPyTest): - - ExtensionTemplate = PointTemplate - - def test_tp_init(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_xy - HPyDef_SLOT_IMPL(Point_new, HPyType_GenericNew, HPy_tp_new) - - HPyDef_SLOT(Point_init, HPy_tp_init) - static int Point_init_impl(HPyContext *ctx, HPy self, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - long x, y; - if (!HPyArg_Parse(ctx, NULL, args, nargs, "ll", &x, &y)) - return -1; - - PointObject *p = PointObject_AsStruct(ctx, self); - p->x = x; - p->y = y; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_init, &Point_x, &Point_y) - @INIT - """) - p = mod.Point(1, 2) - assert p.x == 1 - assert p.y == 2 - - @pytest.mark.syncgc - def test_tp_destroy(self): - import gc - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - static long destroyed_x; - - HPyDef_SLOT(Point_destroy, HPy_tp_destroy) - static void Point_destroy_impl(void *obj) - { - PointObject *point = (PointObject *)obj; - destroyed_x += point->x; - } - - HPyDef_METH(get_destroyed_x, "get_destroyed_x", HPyFunc_NOARGS) - static HPy get_destroyed_x_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, destroyed_x); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_destroy) - @EXPORT(get_destroyed_x) - @INIT - """) - point = mod.Point(7, 3) - assert mod.get_destroyed_x() == 0 - del point - gc.collect() - assert mod.get_destroyed_x() == 7 - gc.collect() - assert mod.get_destroyed_x() == 7 - - @pytest.mark.syncgc - def test_tp_finalize_nongc(self): - import gc - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - static long finalized_x; - - HPyDef_SLOT(Point_finalize, HPy_tp_finalize) - static void Point_finalize_impl(HPyContext *ctx, HPy obj) - { - PointObject *point = PointObject_AsStruct(ctx, obj); - finalized_x += point->x; - } - - HPyDef_METH(get_finalized_x, "get_finalized_x", HPyFunc_NOARGS) - static HPy get_finalized_x_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, finalized_x); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_finalize) - @EXPORT(get_finalized_x) - @INIT - """) - point = mod.Point(7, 3) - assert mod.get_finalized_x() == 0 - del point - gc.collect() - assert mod.get_finalized_x() == 7 - gc.collect() - assert mod.get_finalized_x() == 7 - - @pytest.mark.syncgc - def test_tp_finalize_gc(self): - import gc - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - static long finalized_x; - - HPyDef_SLOT(Point_finalize, HPy_tp_finalize) - static void Point_finalize_impl(HPyContext *ctx, HPy obj) - { - PointObject *point = PointObject_AsStruct(ctx, obj); - finalized_x += point->x; - } - - HPyDef_SLOT(Point_traverse, HPy_tp_traverse) - static int Point_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg) - { - return 0; - } - - static HPyDef *Point_defines[] = { - &Point_new, &Point_finalize, &Point_traverse, NULL}; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .flags = HPy_TPFLAGS_DEFAULT | HPy_TPFLAGS_HAVE_GC, - .builtin_shape = SHAPE(PointObject), - .defines = Point_defines, - }; - @EXPORT_TYPE("Point", Point_spec) - - HPyDef_METH(get_finalized_x, "get_finalized_x", HPyFunc_NOARGS) - static HPy get_finalized_x_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, finalized_x); - } - - @EXPORT(get_finalized_x) - @INIT - """) - point = mod.Point(7, 3) - assert mod.get_finalized_x() == 0 - del point - gc.collect() - assert mod.get_finalized_x() == 7 - gc.collect() - assert mod.get_finalized_x() == 7 - - def test_nb_ops_binary(self): - import operator - mod = self.make_module(r""" - @DEFINE_PointObject - - #define MYSLOT(NAME) \ - HPyDef_SLOT_IMPL(p_##NAME, NAME##_impl, HPy_nb_##NAME) \ - static HPy NAME##_impl(HPyContext *ctx, HPy self, HPy other) \ - { \ - HPy s = HPyUnicode_FromString(ctx, #NAME); \ - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); \ - HPy_Close(ctx, s); \ - return res; \ - } - - MYSLOT(add) - MYSLOT(and) - MYSLOT(divmod) - MYSLOT(floor_divide) - MYSLOT(lshift) - MYSLOT(multiply) - MYSLOT(or) - MYSLOT(remainder) - MYSLOT(rshift) - MYSLOT(subtract) - MYSLOT(true_divide) - MYSLOT(xor) - MYSLOT(matrix_multiply) - - @EXPORT_POINT_TYPE(&p_add, &p_and, &p_divmod, &p_floor_divide, &p_lshift, &p_multiply, &p_or, &p_remainder, &p_rshift, &p_subtract, &p_true_divide, &p_xor, &p_matrix_multiply) - @INIT - """) - p = mod.Point() - assert p + 42 == (p, "add", 42) - assert p & 42 == (p, "and", 42) - assert divmod(p, 42) == (p, "divmod", 42) - assert p // 42 == (p, "floor_divide", 42) - assert p << 42 == (p, "lshift", 42) - assert p * 42 == (p, "multiply", 42) - assert p | 42 == (p, "or", 42) - assert p % 42 == (p, "remainder", 42) - assert p >> 42 == (p, "rshift", 42) - assert p - 42 == (p, "subtract", 42) - assert p / 42 == (p, "true_divide", 42) - assert p ^ 42 == (p, "xor", 42) - # we can't use '@' because we want to be importable on py27 - assert operator.matmul(p, 42) == (p, "matrix_multiply", 42) - - def test_nb_ops_inplace(self): - import operator - mod = self.make_module(r""" - @DEFINE_PointObject - - #define MYSLOT(NAME) \ - HPyDef_SLOT_IMPL(p_##NAME, NAME##_impl, HPy_nb_##NAME); \ - static HPy NAME##_impl(HPyContext *ctx, HPy self, HPy other) \ - { \ - HPy s = HPyUnicode_FromString(ctx, #NAME); \ - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); \ - HPy_Close(ctx, s); \ - return res; \ - } - - MYSLOT(inplace_add) - MYSLOT(inplace_and) - MYSLOT(inplace_floor_divide) - MYSLOT(inplace_lshift) - MYSLOT(inplace_multiply) - MYSLOT(inplace_or) - MYSLOT(inplace_remainder) - MYSLOT(inplace_rshift) - MYSLOT(inplace_subtract) - MYSLOT(inplace_true_divide) - MYSLOT(inplace_xor) - MYSLOT(inplace_matrix_multiply) - - @EXPORT_POINT_TYPE(&p_inplace_add, &p_inplace_and, &p_inplace_floor_divide, &p_inplace_lshift, &p_inplace_multiply, &p_inplace_or, &p_inplace_remainder, &p_inplace_rshift, &p_inplace_subtract, &p_inplace_true_divide, &p_inplace_xor, &p_inplace_matrix_multiply) - @INIT - """) - p = mod.Point() - tmp = p; tmp += 42; assert tmp == (p, "inplace_add", 42) - tmp = p; tmp &= 42; assert tmp == (p, "inplace_and", 42) - tmp = p; tmp //= 42; assert tmp == (p, "inplace_floor_divide", 42) - tmp = p; tmp <<= 42; assert tmp == (p, "inplace_lshift", 42) - tmp = p; tmp *= 42; assert tmp == (p, "inplace_multiply", 42) - tmp = p; tmp |= 42; assert tmp == (p, "inplace_or", 42) - tmp = p; tmp %= 42; assert tmp == (p, "inplace_remainder", 42) - tmp = p; tmp >>= 42; assert tmp == (p, "inplace_rshift", 42) - tmp = p; tmp -= 42; assert tmp == (p, "inplace_subtract", 42) - tmp = p; tmp /= 42; assert tmp == (p, "inplace_true_divide", 42) - tmp = p; tmp ^= 42; assert tmp == (p, "inplace_xor", 42) - # - # we can't use '@=' because we want to be importable on py27 - tmp = p - tmp = operator.imatmul(p, 42) - assert tmp == (p, "inplace_matrix_multiply", 42) - - def test_nb_ops_unary(self): - mod = self.make_module(r""" - @DEFINE_PointObject - - #define MYSLOT(NAME) \ - HPyDef_SLOT_IMPL(p_##NAME, NAME##_impl, HPy_nb_##NAME); \ - static HPy NAME##_impl(HPyContext *ctx, HPy self) \ - { \ - HPy s = HPyUnicode_FromString(ctx, #NAME); \ - HPy res = HPyTuple_Pack(ctx, 2, s, self); \ - HPy_Close(ctx, s); \ - return res; \ - } - - MYSLOT(negative) - MYSLOT(positive) - MYSLOT(absolute) - MYSLOT(invert) - - @EXPORT_POINT_TYPE(&p_negative, &p_positive, &p_absolute, &p_invert) - @INIT - """) - p = mod.Point() - assert +p == ('positive', p) - assert -p == ('negative', p) - assert abs(p) == ('absolute', p) - assert ~p == ('invert', p) - - def test_nb_ops_type_conversion(self): - import operator - mod = self.make_module(r""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_SLOT(p_int, HPy_nb_int); - static HPy p_int_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 42); - } - - HPyDef_SLOT(p_float, HPy_nb_float); - static HPy p_float_impl(HPyContext *ctx, HPy self) - { - return HPyFloat_FromDouble(ctx, 123.4); - } - - HPyDef_SLOT(p_index, HPy_nb_index); - static HPy p_index_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, -456); - } - - HPyDef_SLOT(p_bool, HPy_nb_bool); - static int p_bool_impl(HPyContext *ctx, HPy self) - { - PointObject *point = PointObject_AsStruct(ctx, self); - return (point->x != 0); - } - - @EXPORT_POINT_TYPE(&Point_new, &p_int, &p_float, &p_index, &p_bool) - @INIT - """) - p = mod.Point(0, 0) - assert int(p) == 42 - assert float(p) == 123.4 - assert operator.index(p) == -456 - # - assert bool(mod.Point(0, 0)) is False - assert bool(mod.Point(1, 0)) is True - - def test_nb_ops_power(self): - mod = self.make_module(r""" - @DEFINE_PointObject - - HPyDef_SLOT(p_power, HPy_nb_power); - static HPy p_power_impl(HPyContext *ctx, HPy self, HPy x, HPy y) - { - HPy s = HPyUnicode_FromString(ctx, "power"); - HPy res = HPyTuple_Pack(ctx, 4, self, s, x, y); - HPy_Close(ctx, s); - return res; - } - - HPyDef_SLOT(p_inplace_power, HPy_nb_inplace_power); - static HPy p_inplace_power_impl(HPyContext *ctx, HPy self, HPy x, HPy y) - { - HPy s = HPyUnicode_FromString(ctx, "inplace_power"); - HPy res = HPyTuple_Pack(ctx, 4, self, s, x, y); - HPy_Close(ctx, s); - return res; - } - - @EXPORT_POINT_TYPE(&p_power, &p_inplace_power) - @INIT - """) - p = mod.Point() - assert p**42 == (p, 'power', 42, None) - assert pow(p, 42, 123) == (p, 'power', 42, 123) - tmp = p - tmp **= 42 - assert tmp == (p, 'inplace_power', 42, None) - - def test_buffer(self): - import pytest - import sys - mod = self.make_module(""" - @TYPE_STRUCT_BEGIN(FakeArrayObject) - int exports; - @TYPE_STRUCT_END - - static char static_mem[12] = {0,1,2,3,4,5,6,7,8,9,10,11}; - static HPy_ssize_t _shape[1] = {12}; - static HPy_ssize_t _strides[1] = {1}; - - HPyDef_SLOT_IMPL(FakeArray_getbuffer, _getbuffer_impl, HPy_bf_getbuffer) - static int _getbuffer_impl(HPyContext *ctx, HPy self, HPy_buffer* buf, int flags) { - FakeArrayObject *arr = FakeArrayObject_AsStruct(ctx, self); - if (arr->exports > 0) { - buf->obj = HPy_NULL; - HPyErr_SetString(ctx, ctx->h_BufferError, - "only one buffer allowed"); - return -1; - } - arr->exports++; - buf->buf = static_mem; - buf->len = 12; - buf->itemsize = 1; - buf->readonly = 1; - buf->ndim = 1; - buf->format = (char*)"B"; - buf->shape = _shape; - buf->strides = _strides; - buf->suboffsets = NULL; - buf->internal = NULL; - buf->obj = HPy_Dup(ctx, self); - return 0; - } - - HPyDef_SLOT_IMPL(FakeArray_releasebuffer, _relbuffer_impl, HPy_bf_releasebuffer) - static void _relbuffer_impl(HPyContext *ctx, HPy h_obj, HPy_buffer* buf) { - FakeArrayObject *arr = FakeArrayObject_AsStruct(ctx, h_obj); - arr->exports--; - } - - static HPyDef *FakeArray_defines[] = { - &FakeArray_getbuffer, - &FakeArray_releasebuffer, - NULL - }; - - static HPyType_Spec FakeArray_Spec = { - .name = "mytest.FakeArray", - .basicsize = sizeof(FakeArrayObject), - .builtin_shape = SHAPE(FakeArrayObject), - .defines = FakeArray_defines, - }; - - @EXPORT_TYPE("FakeArray", FakeArray_Spec) - @INIT - """) - arr = mod.FakeArray() - if self.supports_refcounts(): - init_refcount = sys.getrefcount(arr) - with memoryview(arr) as mv: - with pytest.raises(BufferError): - mv2 = memoryview(arr) - if self.supports_refcounts(): - assert sys.getrefcount(arr) == init_refcount + 1 - for i in range(12): - assert mv[i] == i - if self.supports_refcounts(): - assert sys.getrefcount(arr) == init_refcount - mv2 = memoryview(arr) # doesn't raise - - def test_tp_repr_and_tp_str(self): - mod = self.make_module(""" - #include - - #define BUF_SIZE 128 - - @DEFINE_PointObject - @DEFINE_Point_new - - static HPy - point_str_repr(HPyContext *ctx, HPy h, int str) - { - char buf[BUF_SIZE]; - PointObject *p = PointObject_AsStruct(ctx, h); - snprintf(buf, BUF_SIZE, "%s(Point(%ld, %ld))", - (str ? "str" : "repr"), p->x, p->y); - return HPyUnicode_FromString(ctx, buf); - } - - HPyDef_SLOT(Point_repr, HPy_tp_repr) - static HPy Point_repr_impl(HPyContext *ctx, HPy self) - { - return point_str_repr(ctx, self, 0); - } - - HPyDef_SLOT(Point_str, HPy_tp_str) - static HPy Point_str_impl(HPyContext *ctx, HPy self) - { - return point_str_repr(ctx, self, 1); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_str, &Point_repr) - @INIT - """) - p = mod.Point(1, 2) - assert str(p) == 'str(Point(1, 2))' - assert repr(p) == 'repr(Point(1, 2))' - - def test_tp_hash(self): - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_SLOT(Point_hash, HPy_tp_hash) - static HPy_ssize_t Point_hash_impl(HPyContext *ctx, HPy self) - { - PointObject *p = PointObject_AsStruct(ctx, self); - if (p->x < 0) { - HPyErr_SetString(ctx, ctx->h_ValueError, "cannot hash Point object with negative x"); - return -1; - } - return p->x + p->y; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_hash) - @INIT - """) - p = mod.Point(1, 10) - assert p.__hash__() == 11 - assert hash(p) == 11 - # We expect that the slot wrapper accepts hash code -1 without - # complaining. This is not the case for built-in function 'hash'. - assert mod.Point(0, -1).__hash__() == -1 - with pytest.raises(ValueError): - hash(mod.Point(-1, 10)) - - -class TestSqSlots(HPyTest): - - ExtensionTemplate = PointTemplate - - def test_mp_subscript_and_mp_length(self): - mod = self.make_module(""" - @DEFINE_PointObject - - HPyDef_SLOT(Point_getitem, HPy_mp_subscript); - static HPy Point_getitem_impl(HPyContext *ctx, HPy self, HPy key) - { - HPy prefix = HPyUnicode_FromString(ctx, "key was: "); - HPy key_repr = HPy_Repr(ctx, key); - HPy res = HPy_Add(ctx, prefix, key_repr); - HPy_Close(ctx, key_repr); - HPy_Close(ctx, prefix); - return res; - } - - HPyDef_SLOT(Point_length, HPy_mp_length); - static HPy_ssize_t Point_length_impl(HPyContext *ctx, HPy self) - { - return 1234; - } - - @EXPORT_POINT_TYPE(&Point_getitem, &Point_length) - @INIT - """) - p = mod.Point() - class Dummy: - def __repr__(self): - return "Hello, World" - assert len(p) == 1234 - assert p[4] == "key was: 4" - assert p["hello"] == "key was: 'hello'" - assert p[Dummy()] == "key was: Hello, World" - - def test_mp_ass_subscript(self): - import pytest - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_xy - - HPyDef_SLOT(Point_len, HPy_mp_length); - static HPy_ssize_t Point_len_impl(HPyContext *ctx, HPy self) - { - return 2; - } - - HPyDef_SLOT(Point_setitem, HPy_mp_ass_subscript); - static int Point_setitem_impl(HPyContext *ctx, HPy self, HPy key, - HPy h_value) - { - long value; - if (HPy_IsNull(h_value)) { - value = -123; // this is the del p[] case - } else { - value = HPyLong_AsLong(ctx, h_value); - if (HPyErr_Occurred(ctx)) - return -1; - } - PointObject *point = PointObject_AsStruct(ctx, self); - const char *s_key = HPyUnicode_AsUTF8AndSize(ctx, key, NULL); - if (s_key == NULL) { - return -1; - } - if (s_key[0] == 'x') { - point->x = value; - } else if (s_key[0] == 'y') { - point->y = value; - } else { - HPyErr_SetString(ctx, ctx->h_KeyError, "invalid key"); - return -1; - } - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y, &Point_len, &Point_setitem) - @INIT - """) - p = mod.Point(1, 2) - # check __setitem__ - p['x'] = 100 - assert p.x == 100 - p['y'] = 200 - assert p.y == 200 - with pytest.raises(KeyError): - p['z'] = 300 - with pytest.raises(TypeError): - p[0] = 300 - # check __delitem__ - del p['x'] - assert p.x == -123 - del p['y'] - assert p.y == -123 - - def test_sq_item_and_sq_length(self): - mod = self.make_module(""" - @DEFINE_PointObject - - HPyDef_SLOT(Point_getitem, HPy_sq_item); - static HPy Point_getitem_impl(HPyContext *ctx, HPy self, HPy_ssize_t idx) - { - return HPyLong_FromLong(ctx, (long)idx*2); - } - - HPyDef_SLOT(Point_length, HPy_sq_length); - static HPy_ssize_t Point_length_impl(HPyContext *ctx, HPy self) - { - return 1234; - } - - @EXPORT_POINT_TYPE(&Point_getitem, &Point_length) - @INIT - """) - p = mod.Point() - assert len(p) == 1234 - assert p[4] == 8 - assert p[21] == 42 - assert p[-1] == 1233 * 2, str(p[-1]) - assert p.__getitem__(4) == 8 - assert p.__getitem__(21) == 42 - assert p.__getitem__(-1) == 1233 * 2 - - def test_sq_ass_item(self): - import pytest - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - @DEFINE_Point_xy - - HPyDef_SLOT(Point_len, HPy_sq_length); - static HPy_ssize_t Point_len_impl(HPyContext *ctx, HPy self) - { - return 2; - } - - HPyDef_SLOT(Point_setitem, HPy_sq_ass_item); - static int Point_setitem_impl(HPyContext *ctx, HPy self, HPy_ssize_t idx, - HPy h_value) - { - long value; - if (HPy_IsNull(h_value)) - value = -123; // this is the del p[] case - else { - value = HPyLong_AsLong(ctx, h_value); - if (HPyErr_Occurred(ctx)) - return -1; - } - PointObject *point = PointObject_AsStruct(ctx, self); - if (idx == 0) - point->x = value; - else if (idx == 1) - point->y = value; - else { - HPyErr_SetString(ctx, ctx->h_IndexError, "invalid index"); - return -1; - } - return 0; - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_x, &Point_y, &Point_len, &Point_setitem) - @INIT - """) - p = mod.Point(1, 2) - # check __setitem__ - p[0] = 100 - assert p.x == 100 - p[1] = 200 - assert p.y == 200 - with pytest.raises(IndexError): - p[2] = 300 - # check __delitem__ - del p[0] - assert p.x == -123 - del p[1] - assert p.y == -123 - # check negative indexes - p[-2] = 400 - p[-1] = 500 - assert p.x == 400 - assert p.y == 500 - del p[-2] - assert p.x == -123 - del p[-1] - assert p.y == -123 - - def test_sq_concat_and_sq_inplace_concat(self): - mod = self.make_module(""" - @DEFINE_PointObject - - HPyDef_SLOT(Point_concat, HPy_sq_concat); - static HPy Point_concat_impl(HPyContext *ctx, HPy self, HPy other) - { - HPy s = HPyUnicode_FromString(ctx, "sq_concat"); - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); - HPy_Close(ctx, s); - return res; - } - - HPyDef_SLOT(Point_inplace_concat, HPy_sq_inplace_concat); - static HPy Point_inplace_concat_impl(HPyContext *ctx, HPy self, HPy other) - { - HPy s = HPyUnicode_FromString(ctx, "sq_inplace_concat"); - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); - HPy_Close(ctx, s); - return res; - } - - @EXPORT_POINT_TYPE(&Point_concat, &Point_inplace_concat) - @INIT - """) - p = mod.Point() - res = p + 42 - assert res == (p, "sq_concat", 42) - # - tmp = p - tmp += 43 - assert tmp == (p, "sq_inplace_concat", 43) - - def test_sq_repeat_and_sq_inplace_repeat(self): - mod = self.make_module(""" - @DEFINE_PointObject - - HPyDef_SLOT(Point_repeat, HPy_sq_repeat); - static HPy Point_repeat_impl(HPyContext *ctx, HPy self, HPy_ssize_t t) - { - HPy s = HPyUnicode_FromString(ctx, "sq_repeat"); - HPy other = HPyLong_FromLong(ctx, (long) t); - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); - HPy_Close(ctx, other); - HPy_Close(ctx, s); - return res; - } - - HPyDef_SLOT(Point_inplace_repeat, HPy_sq_inplace_repeat); - static HPy Point_inplace_repeat_impl(HPyContext *ctx, HPy self, HPy_ssize_t t) - { - HPy s = HPyUnicode_FromString(ctx, "sq_inplace_repeat"); - HPy other = HPyLong_FromLong(ctx, (long) t); - HPy res = HPyTuple_Pack(ctx, 3, self, s, other); - HPy_Close(ctx, other); - HPy_Close(ctx, s); - return res; - } - - @EXPORT_POINT_TYPE(&Point_repeat, &Point_inplace_repeat) - @INIT - """) - p = mod.Point() - res = p * 42 - assert res == (p, "sq_repeat", 42) - # - tmp = p - tmp *= 43 - assert tmp == (p, "sq_inplace_repeat", 43) - - def test_sq_contains(self): - import pytest - mod = self.make_module(""" - @DEFINE_PointObject - - HPyDef_SLOT(Point_contains, HPy_sq_contains); - static int Point_contains_impl(HPyContext *ctx, HPy self, HPy other) - { - long val = HPyLong_AsLong(ctx, other); - if (HPyErr_Occurred(ctx)) - return -1; - if (val == 42) - return 1; - return 0; - } - - @EXPORT_POINT_TYPE(&Point_contains) - @INIT - """) - p = mod.Point() - assert 42 in p - assert 43 not in p - with pytest.raises(TypeError): - 'hello' in p - - def test_tp_richcompare(self): - import pytest - mod = self.make_module(""" - @DEFINE_PointObject - @DEFINE_Point_new - - HPyDef_SLOT(Point_cmp, HPy_tp_richcompare); - static HPy Point_cmp_impl(HPyContext *ctx, HPy self, HPy o, HPy_RichCmpOp op) - { - // XXX we should check the type of o - PointObject *p1 = PointObject_AsStruct(ctx, self); - PointObject *p2 = PointObject_AsStruct(ctx, o); - HPy_RETURN_RICHCOMPARE(ctx, p1->x, p2->x, op); - } - - @EXPORT_POINT_TYPE(&Point_new, &Point_cmp) - @INIT - """) - p1 = mod.Point(10, 10) - p2 = mod.Point(20, 20) - assert p1 == p1 - assert not p1 == p2 - # - assert p1 != p2 - assert not p1 != p1 - # - assert p1 < p2 - assert not p1 < p1 - # - assert not p1 > p2 - assert not p1 > p1 - # - assert p1 <= p2 - assert p1 <= p1 - # - assert not p1 >= p2 - assert p1 >= p1 diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots_legacy.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots_legacy.py deleted file mode 100644 index fd77e275eb..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_slots_legacy.py +++ /dev/null @@ -1,289 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" HPyType slot tests on legacy types. """ -import pytest - -from .support import HPyTest, make_hpy_abi_fixture -from .test_hpytype_legacy import LegacyPointTemplate -from .test_slots import TestSlots as _TestSlots, TestSqSlots as _TestSqSlots - -hpy_abi = make_hpy_abi_fixture('with hybrid') - -class TestLegacySlots(_TestSlots): - ExtensionTemplate = LegacyPointTemplate - - -class TestLegacySqSlots(_TestSqSlots): - ExtensionTemplate = LegacyPointTemplate - - -class TestCustomLegacySlotsFeatures(HPyTest): - - def test_legacy_slots(self): - mod = self.make_module(""" - #include - - static PyObject *Dummy_repr(PyObject *self) - { - return PyUnicode_FromString("myrepr"); - } - - static PyObject *Dummy_add(PyObject *self, PyObject *other) - { - return Py_BuildValue("OO", self, other); - } - - HPyDef_SLOT(Dummy_abs, HPy_nb_absolute); - static HPy Dummy_abs_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - static HPyDef *Dummy_defines[] = { - &Dummy_abs, - NULL - }; - static PyType_Slot Dummy_type_slots[] = { - {Py_tp_repr, (void*)Dummy_repr}, - {Py_nb_add, (void*)Dummy_add}, - {0, 0}, - }; - static HPyType_Spec Dummy_spec = { - .name = "mytest.Dummy", - .builtin_shape = HPyType_BuiltinShape_Legacy, - .legacy_slots = Dummy_type_slots, - .defines = Dummy_defines - }; - - @EXPORT_TYPE("Dummy", Dummy_spec) - @INIT - """) - d = mod.Dummy() - assert repr(d) == 'myrepr' - assert d + 42 == (d, 42) - assert abs(d) == 1234 - - def test_legacy_slots_methods(self): - mod = self.make_module(""" - #include - - static PyObject *Dummy_foo(PyObject *self, PyObject *arg) - { - Py_INCREF(arg); - return arg; - } - - HPyDef_METH(Dummy_bar, "bar", HPyFunc_NOARGS) - static HPy Dummy_bar_impl(HPyContext *ctx, HPy self) - { - return HPyLong_FromLong(ctx, 1234); - } - - static PyMethodDef dummy_methods[] = { - {"foo", Dummy_foo, METH_O}, - {NULL, NULL} /* Sentinel */ - }; - - static PyType_Slot dummy_type_slots[] = { - {Py_tp_methods, dummy_methods}, - {0, 0}, - }; - - static HPyDef *dummy_type_defines[] = { - &Dummy_bar, - NULL - }; - - static HPyType_Spec dummy_type_spec = { - .name = "mytest.Dummy", - .builtin_shape = HPyType_BuiltinShape_Legacy, - .legacy_slots = dummy_type_slots, - .defines = dummy_type_defines - }; - - @EXPORT_TYPE("Dummy", dummy_type_spec) - @INIT - """) - d = mod.Dummy() - assert d.foo(21) == 21 - assert d.bar() == 1234 - - def test_legacy_slots_members(self): - import pytest - mod = self.make_module(""" - #include - #include "structmember.h" - - typedef struct { - PyObject_HEAD - long x; - long y; - } PointObject; - - HPyDef_SLOT(Point_new, HPy_tp_new) - static HPy Point_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - PointObject *point; - HPy h_point = HPy_New(ctx, cls, &point); - if (HPy_IsNull(h_point)) - return HPy_NULL; - point->x = 7; - point->y = 3; - return h_point; - } - - HPyDef_MEMBER(Point_x, "x", HPyMember_LONG, offsetof(PointObject, x)) - - // legacy members - static PyMemberDef legacy_members[] = { - {"y", T_LONG, offsetof(PointObject, y), 0}, - {"y_ro", T_LONG, offsetof(PointObject, y), READONLY}, - {NULL} - }; - - static PyType_Slot legacy_slots[] = { - {Py_tp_members, legacy_members}, - {0, NULL} - }; - - static HPyDef *Point_defines[] = { - &Point_new, - &Point_x, - NULL - }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = HPyType_BuiltinShape_Legacy, - .legacy_slots = legacy_slots, - .defines = Point_defines - }; - - @EXPORT_TYPE("Point", Point_spec) - @INIT - """) - p = mod.Point() - assert p.x == 7 - assert p.y == 3 - assert p.y_ro == 3 - p.x = 123 - p.y = 456 - with pytest.raises(AttributeError): - p.y_ro = 789 - assert p.x == 123 - assert p.y == 456 - - def test_legacy_slots_getsets(self): - mod = self.make_module(""" - #include - - typedef struct { - PyObject_HEAD - long x; - long y; - } PointObject; - - HPyDef_SLOT(Point_new, HPy_tp_new) - static HPy Point_new_impl(HPyContext *ctx, HPy cls, const HPy *args, - HPy_ssize_t nargs, HPy kw) - { - PointObject *point; - HPy h_point = HPy_New(ctx, cls, &point); - if (HPy_IsNull(h_point)) - return HPy_NULL; - point->x = 7; - point->y = 3; - return h_point; - } - - static PyObject *z_get(PointObject *point, void *closure) - { - long z = point->x*10 + point->y + (long)(HPy_ssize_t)closure; - return PyLong_FromLong(z); - } - - // legacy getsets - static PyGetSetDef legacy_getsets[] = { - {"z", (getter)z_get, NULL, NULL, (void *)2000}, - {NULL} - }; - - static PyType_Slot legacy_slots[] = { - {Py_tp_getset, legacy_getsets}, - {0, NULL} - }; - - static HPyDef *Point_defines[] = { - &Point_new, - NULL - }; - static HPyType_Spec Point_spec = { - .name = "mytest.Point", - .basicsize = sizeof(PointObject), - .builtin_shape = HPyType_BuiltinShape_Legacy, - .legacy_slots = legacy_slots, - .defines = Point_defines - }; - - @EXPORT_TYPE("Point", Point_spec) - @INIT - """) - p = mod.Point() - assert p.z == 2073 - - def test_legacy_slots_fails_without_legacy(self): - import pytest - mod_src = """ - #include - - static PyObject *Dummy_foo(PyObject *self, PyObject *arg) - { - Py_INCREF(arg); - return arg; - } - - static PyMethodDef dummy_methods[] = { - {"foo", Dummy_foo, METH_O}, - {NULL, NULL} /* Sentinel */ - }; - - static PyType_Slot dummy_type_slots[] = { - {Py_tp_methods, dummy_methods}, - {0, 0}, - }; - - static HPyType_Spec dummy_type_spec = { - .name = "mytest.Dummy", - .builtin_shape = HPyType_BuiltinShape_Object, - .legacy_slots = dummy_type_slots, - }; - - @EXPORT_TYPE("Dummy", dummy_type_spec) - @INIT - """ - with pytest.raises(TypeError) as err: - self.make_module(mod_src) - assert str(err.value) == ( - "cannot specify .legacy_slots without setting .builtin_shape=HPyType_BuiltinShape_Legacy") diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_support.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_support.py deleted file mode 100644 index 09745b1793..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_support.py +++ /dev/null @@ -1,73 +0,0 @@ -# MIT License -# -# Copyright (c) 2020, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from pathlib import Path -from . import support - - -def expand_template(template, name): - return support.DefaultExtensionTemplate(template, name).expand() - - -def test_expand_template(): - expanded = expand_template(""" - @EXPORT(f) - @EXPORT(g) - some more C stuff - @INIT - """, name='mytest') - defines_table = ['&f,', '&g,'] - defines = '\n '.join(defines_table) - init_code = support.DefaultExtensionTemplate.INIT_TEMPLATE % { - 'defines': defines, - 'legacy_methods': 'NULL', - 'name': 'mytest', - 'init_types': '', - 'globals_defs': '', - 'globals_field': '', - } - assert expanded.rstrip() == f"""#include - -some more C stuff -{init_code} -""".rstrip() - - -TEST_DIR = Path(__file__).parent - - -def test_source_dump(tmpdir): - import pytest - test_file = 'test_00_basic' - parts = ['TestBasic', 'test_noop_function'] - rc = pytest.main(['--dump-dir=' + str(tmpdir), '::'.join([str(TEST_DIR.joinpath(test_file + ".py"))] + parts)]) - assert rc == 0 - expected_dir = '_'.join([test_file] + parts) - print("expected_dir = " + expected_dir) - test_dump_dir = None - for child in Path(tmpdir).iterdir(): - if expected_dir in str(child): - test_dump_dir = Path(child) - assert test_dump_dir and test_dump_dir.exists() - assert test_dump_dir.joinpath('mytest.c').exists() diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_tracker.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_tracker.py deleted file mode 100644 index f73d00b9d9..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/test_tracker.py +++ /dev/null @@ -1,143 +0,0 @@ -# MIT License -# -# Copyright (c) 2021, 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -""" -NOTE: this tests are also meant to be run as PyPy "applevel" tests. - -This means that global imports will NOT be visible inside the test -functions. In particular, you have to "import pytest" inside the test in order -to be able to use e.g. pytest.raises (which on PyPy will be implemented by a -"fake pytest module") -""" -from .support import HPyTest - - -class TestHPyTracker(HPyTest): - def hpytracker_module(self, ops, size=0): - return self.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - {{ - HPyTracker ht; - HPy result = HPy_NULL; - ht = HPyTracker_New(ctx, {size}); - if HPy_IsNull(ht) {{ - return HPy_NULL; - }} - {ops} - HPyTracker_Close(ctx, ht); - if (HPy_IsNull(result)) - result = HPy_Dup(ctx, ctx->h_None); - return result; - }} - @EXPORT(f) - @INIT - """.format(ops=ops, size=size)) - - def test_new_and_free(self): - mod = self.hpytracker_module(ops="") - mod.f() - - def test_new_with_size_and_free(self): - mod = self.hpytracker_module(ops="", size=10) - mod.f() - - def test_add_and_free(self): - mod = self.hpytracker_module(ops=""" - HPyTracker_Add(ctx, ht, HPy_Dup(ctx, args[0])); - """) - mod.f(5) - - def test_add_and_remove_all(self): - mod = self.hpytracker_module(ops=""" - HPyTracker_Add(ctx, ht, args[0]); - HPyTracker_ForgetAll(ctx, ht); - """) - assert mod.f(5) is None - - def test_remove_all_on_nothing(self): - mod = self.hpytracker_module(ops=""" - HPyTracker_ForgetAll(ctx, ht); - """) - assert mod.f() is None - - def test_squares_example(self): - import pytest - mod = self.make_module(""" - HPyDef_METH(squares, "squares", HPyFunc_VARARGS) - static HPy squares_impl(HPyContext *ctx, HPy self, - const HPy *args, size_t nargs) - { - long i, n; - long n_err = -1; // simulate an error at the given index - int result; - HPy key, value; - HPyTracker ht; - - if (!HPyArg_Parse(ctx, NULL, args, nargs, "l|l", &n, &n_err)) - return HPy_NULL; - - ht = HPyTracker_New(ctx, 0); // track key-value pairs - if HPy_IsNull(ht) - return HPy_NULL; - - HPy dict = HPyDict_New(ctx); - if (HPy_IsNull(dict)) - goto error; - - for (i=1; i<=n; i++) { - if (i==n_err) - goto error; - key = HPyLong_FromLong(ctx, i); - if (HPy_IsNull(key)) - goto error; - if (HPyTracker_Add(ctx, ht, key) < 0) - goto error; - value = HPyLong_FromLong(ctx, i * i); - if (HPy_IsNull(value)) - goto error; - if (HPyTracker_Add(ctx, ht, value) < 0) - goto error; - result = HPy_SetItem(ctx, dict, key, value); - if (result < 0) - goto error; - } - - HPyTracker_Close(ctx, ht); - return dict; - - error: - HPyTracker_Close(ctx, ht); - HPy_Close(ctx, dict); - HPyErr_SetString(ctx, ctx->h_ValueError, "Failed!"); - return HPy_NULL; - } - @EXPORT(squares) - @INIT - """) - assert mod.squares(5) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} - assert mod.squares(100) == dict((i, i**2) for i in range(1, 101)) - with pytest.raises(ValueError) as err: - mod.squares(5, 3) - assert str(err.value) == "Failed!" diff --git a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/trace/test_trace.py b/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/trace/test_trace.py deleted file mode 100644 index 675f68d16c..0000000000 --- a/graalpython/com.oracle.graal.python.hpy.test/src/hpytest/trace/test_trace.py +++ /dev/null @@ -1,153 +0,0 @@ -# MIT License -# -# Copyright (c) 2023, Oracle and/or its affiliates. -# Copyright (c) 2019 pyhandle -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall 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. - -import pytest -from hpytest.support import HPyTest -from hpy.trace import get_call_counts, get_durations, set_trace_functions - -pytestmark = pytest.mark.skipif(not HPyTest.supports_trace_mode(), reason="trace mode not supported") - -@pytest.fixture -def hpy_abi(): - return "trace" - - -def get_call_counter(): - from collections import Counter - return Counter(get_call_counts()) - - -def _assert_unchanged_except(expected, actual, *ignore): - import pytest - for x in expected.keys(): - if x not in ignore and actual[x] != expected[x]: - pytest.fail("%s unexpectedly changed (expected %d but was %d)." % - (x, expected[x], actual[x])) - - -def test_get_call_counts(compiler): - import pytest - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly two args"); - return HPy_NULL; - } - return HPy_Add(ctx, args[0], args[1]); - } - - @EXPORT(f) - @INIT - """) - # Don't rely on absolute call count numbers since the module setup could - # already do some API calls we don't expect. - call_counter_0 = get_call_counter() - - assert mod.f(1, 2) == 3 - assert get_call_counter() - call_counter_0 == {"ctx_Add": 1} - assert mod.f(10, 20) == 30 - assert get_call_counter() - call_counter_0 == {"ctx_Add": 2} - with pytest.raises(TypeError): - mod.f(1, 2, 3) - assert get_call_counter() - call_counter_0 == {"ctx_Add": 2, "ctx_Err_SetString": 1} - - -def test_get_durations(compiler): - import time - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_O) - static HPy f_impl(HPyContext *ctx, HPy self, HPy arg) - { - if (!HPyCallable_Check(ctx, arg)) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected callable"); - return HPy_NULL; - } - return HPy_CallTupleDict(ctx, arg, HPy_NULL, HPy_NULL); - } - - @EXPORT(f) - @INIT - """) - # Don't rely on absolute durations numbers since the module setup could - # already do some API calls we don't expect. - durations0 = get_durations().copy() - - def callback(): - time.sleep(0.3) - return 123 - - assert mod.f(callback) == 123 - assert get_durations()["ctx_CallTupleDict"] >= durations0["ctx_CallTupleDict"] + 3e5 - _assert_unchanged_except(durations0, get_durations(), "ctx_CallTupleDict", "ctx_Callable_Check") - - -def test_trace_funcs(compiler): - import pytest - mod = compiler.make_module(""" - HPyDef_METH(f, "f", HPyFunc_VARARGS) - static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - { - if (nargs != 2) { - HPyErr_SetString(ctx, ctx->h_TypeError, "expected exactly two args"); - return HPy_NULL; - } - return HPy_Add(ctx, args[0], args[1]); - } - - @EXPORT(f) - @INIT - """) - on_enter_cnt = 0 - on_exit_cnt = 0 - - def on_enter(name): - assert name == "ctx_Add" - nonlocal on_enter_cnt - on_enter_cnt += 1 - - def on_exit(name): - assert name == "ctx_Add" - nonlocal on_exit_cnt - on_exit_cnt += 1 - - set_trace_functions(on_enter) - assert on_enter_cnt == 0 - assert on_exit_cnt == 0 - assert mod.f(1, 2) == 3 - assert on_enter_cnt == 1 - assert on_exit_cnt == 0 - # on_enter should stay untouched - set_trace_functions(on_exit=on_exit) - assert mod.f(2, 3) == 5 - assert on_enter_cnt == 2 - assert on_exit_cnt == 1 - # clear on_enter func - set_trace_functions(on_enter=None) - assert mod.f(2, 3) == 5 - assert on_enter_cnt == 2 - assert on_exit_cnt == 2 - - with pytest.raises(TypeError): - set_trace_functions(1) diff --git a/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_call_jni.c b/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_call_jni.c deleted file mode 100644 index a718db4a96..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_call_jni.c +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Copyright (c) 2023, 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_call_jni - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#include "hpy_jni.h" -#include "com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNITrampolines.h" - -#define TRAMPOLINE(name) Java_com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNITrampolines_ ## name - -/******************************************************************* - * UNIVERSAL MODE TRAMPOLINES * - ******************************************************************/ - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeModuleInit)(JNIEnv *env, jclass clazz, jlong target) -{ - return (jlong) (((HPyModuleDef *(*)(void)) target)()); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeNoargs)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self) -{ - HPyFunc_noargs f = (HPyFunc_noargs)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(self))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeO)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong arg) -{ - HPyFunc_o f = (HPyFunc_o)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(self), _jlong2h(arg))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeVarargs)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs) -{ - HPyFunc_varargs f = (HPyFunc_varargs)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(self), (const HPy *) args, (size_t) nargs)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeKeywords)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs, jlong kwnames) -{ - HPyFunc_keywords f = (HPyFunc_keywords)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(self), (const HPy *) args, (size_t) nargs, _jlong2h(kwnames))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeUnaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_unaryfunc f = (HPyFunc_unaryfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeBinaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_binaryfunc f = (HPyFunc_binaryfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeTernaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_ternaryfunc f = (HPyFunc_ternaryfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), _jlong2h(arg2))); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeInquiry)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_inquiry f = (HPyFunc_inquiry)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeLenfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_lenfunc f = (HPyFunc_lenfunc)target; - return (jlong) f((HPyContext *)ctx, _jlong2h(arg0)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeSsizeargfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_ssizeargfunc f = (HPyFunc_ssizeargfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), (HPy_ssize_t) arg1)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeSsizessizeargfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_ssizessizeargfunc f = (HPyFunc_ssizessizeargfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), (HPy_ssize_t) arg1, (HPy_ssize_t) arg2)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeSsizeobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_ssizeobjargproc f = (HPyFunc_ssizeobjargproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), (HPy_ssize_t) arg1, _jlong2h(arg2)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeSsizessizeobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2, jlong arg3) -{ - HPyFunc_ssizessizeobjargproc f = (HPyFunc_ssizessizeobjargproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), (HPy_ssize_t) arg1, (HPy_ssize_t) arg2, _jlong2h(arg3)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeObjobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_objobjargproc f = (HPyFunc_objobjargproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), _jlong2h(arg2)); -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeFreefunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_freefunc f = (HPyFunc_freefunc)target; - f((HPyContext *)ctx, (void *) arg0); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeGetattrfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_getattrfunc f = (HPyFunc_getattrfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), (char *) arg1)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeGetattrofunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_getattrofunc f = (HPyFunc_getattrofunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1))); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeSetattrfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_setattrfunc f = (HPyFunc_setattrfunc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), (char *) arg1, _jlong2h(arg2)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeSetattrofunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_setattrofunc f = (HPyFunc_setattrofunc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), _jlong2h(arg2)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeReprfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_reprfunc f = (HPyFunc_reprfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeHashfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_hashfunc f = (HPyFunc_hashfunc)target; - return (jlong) f((HPyContext *)ctx, _jlong2h(arg0)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeRichcmpfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_richcmpfunc f = (HPyFunc_richcmpfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), (HPy_RichCmpOp) arg2)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeGetiterfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_getiterfunc f = (HPyFunc_getiterfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeIternextfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_iternextfunc f = (HPyFunc_iternextfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDescrgetfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_descrgetfunc f = (HPyFunc_descrgetfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), _jlong2h(arg2))); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDescrsetfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_descrsetfunc f = (HPyFunc_descrsetfunc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), _jlong2h(arg2)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeInitproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs, jlong kw) -{ - HPyFunc_initproc f = (HPyFunc_initproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(self), (const HPy *) args, (HPy_ssize_t) nargs, _jlong2h(kw)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeNewfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong type, jlong args, jlong nargs, jlong kw) -{ - HPyFunc_newfunc f = (HPyFunc_newfunc)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(type), (const HPy *) args, (HPy_ssize_t) nargs, _jlong2h(kw))); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeGetter)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_getter f = (HPyFunc_getter)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0), (void *) arg1)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeSetter)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyFunc_setter f = (HPyFunc_setter)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1), (void *) arg2); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeObjobjproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_objobjproc f = (HPyFunc_objobjproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), _jlong2h(arg1)); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeGetbufferproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jint arg2) -{ - HPyFunc_getbufferproc f = (HPyFunc_getbufferproc)target; - return (jint) f((HPyContext *)ctx, _jlong2h(arg0), (HPy_buffer *) arg1, (int) arg2); -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeReleasebufferproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyFunc_releasebufferproc f = (HPyFunc_releasebufferproc)target; - f((HPyContext *)ctx, _jlong2h(arg0), (HPy_buffer *) arg1); -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeDestructor)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_destructor f = (HPyFunc_destructor)target; - f((HPyContext *)ctx, _jlong2h(arg0)); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeModcreate)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyFunc_mod_create f = (HPyFunc_mod_create)target; - return _h2jlong(f((HPyContext *)ctx, _jlong2h(arg0))); -} - - -/******************************************************************* - * DEBUG MODE TRAMPOLINES * - ******************************************************************/ - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugNoargs)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_noargs f = (HPyFunc_noargs)target; - DHPy dh_self = _jlong2dh(dctx, self); - DHPy dh_result = f(dctx, dh_self); - DHPy_close_and_check(dctx, dh_self); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugO)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong arg) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_o f = (HPyFunc_o)target; - DHPy dh_self = _jlong2dh(dctx, self); - DHPy dh_arg = _jlong2dh(dctx, arg); - DHPy dh_result = f(dctx, dh_self, dh_arg); - DHPy_close_and_check(dctx, dh_self); - DHPy_close_and_check(dctx, dh_arg); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugVarargs)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_varargs f = (HPyFunc_varargs)target; - DHPy dh_self = _jlong2dh(dctx, self); - _ARR_JLONG2DH(dctx, dh_args, args, nargs) - DHPy dh_result = f(dctx, dh_self, dh_args, (size_t)nargs); - _ARR_DH_CLOSE(dctx, dh_args, nargs) - DHPy_close_and_check(dctx, dh_self); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugUnaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_unaryfunc f = (HPyFunc_unaryfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugBinaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_binaryfunc f = (HPyFunc_binaryfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_result = f(dctx, dh_arg0, dh_arg1); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugTernaryfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_ternaryfunc f = (HPyFunc_ternaryfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - DHPy dh_result = f(dctx, dh_arg0, dh_arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - DHPy_close_and_check(dctx, dh_arg2); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugInquiry)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_inquiry f = (HPyFunc_inquiry)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - jint result = (jint) f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return result; -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugLenfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_lenfunc f = (HPyFunc_lenfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - jlong result = (jlong) f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return result; -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugSsizeargfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_ssizeargfunc f = (HPyFunc_ssizeargfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0, (HPy_ssize_t)arg1); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugSsizessizeargfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_ssizessizeargfunc f = (HPyFunc_ssizessizeargfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0, (HPy_ssize_t)arg1, (HPy_ssize_t)arg2); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugSsizeobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_ssizeobjargproc f = (HPyFunc_ssizeobjargproc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - jint result = (jint) f(dctx, dh_arg0, (HPy_ssize_t)arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg2); - return result; -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugSsizessizeobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2, jlong arg3) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_ssizessizeobjargproc f = (HPyFunc_ssizessizeobjargproc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg3 = _jlong2dh(dctx, arg3); - jint result = (jint) f(dctx, dh_arg0, (HPy_ssize_t)arg1, (HPy_ssize_t)arg2, dh_arg3); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg3); - return result; -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugObjobjargproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_objobjargproc f = (HPyFunc_objobjargproc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - jint result = (jint) f(dctx, dh_arg0, dh_arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - DHPy_close_and_check(dctx, dh_arg2); - return result; -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeDebugFreefunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_freefunc f = (HPyFunc_freefunc)target; - f(dctx, (void *)arg0); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugGetattrfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_getattrfunc f = (HPyFunc_getattrfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0, (char *)arg1); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugGetattrofunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_getattrofunc f = (HPyFunc_getattrofunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_result = f(dctx, dh_arg0, dh_arg1); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugSetattrfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_setattrfunc f = (HPyFunc_setattrfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - jint result = (jint) f(dctx, dh_arg0, (char *)arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg2); - return result; -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugSetattrofunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_setattrofunc f = (HPyFunc_setattrofunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - jint result = (jint) f(dctx, dh_arg0, dh_arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - DHPy_close_and_check(dctx, dh_arg2); - return result; -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugReprfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_reprfunc f = (HPyFunc_reprfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugHashfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_hashfunc f = (HPyFunc_hashfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - jlong result = (jlong) f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return result; -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugRichcmpfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_richcmpfunc f = (HPyFunc_richcmpfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_result = f(dctx, dh_arg0, dh_arg1, (HPy_RichCmpOp)arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugGetiterfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_getiterfunc f = (HPyFunc_getiterfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugIternextfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_iternextfunc f = (HPyFunc_iternextfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugDescrgetfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_descrgetfunc f = (HPyFunc_descrgetfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - DHPy dh_result = f(dctx, dh_arg0, dh_arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - DHPy_close_and_check(dctx, dh_arg2); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugDescrsetfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_descrsetfunc f = (HPyFunc_descrsetfunc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - DHPy dh_arg2 = _jlong2dh(dctx, arg2); - jint result = (jint) f(dctx, dh_arg0, dh_arg1, dh_arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - DHPy_close_and_check(dctx, dh_arg2); - return result; -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugInitproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs, jlong kw) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_initproc f = (HPyFunc_initproc)target; - DHPy dh_self = _jlong2dh(dctx, self); - DHPy dh_kw = _jlong2dh(dctx, kw); - _ARR_JLONG2DH(dctx, dh_args, args, nargs) - jint result = (jint) f(dctx, dh_self, dh_args, (HPy_ssize_t)nargs, dh_kw); - _ARR_DH_CLOSE(dctx, dh_args, nargs) - DHPy_close_and_check(dctx, dh_self); - DHPy_close_and_check(dctx, dh_kw); - return result; -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugNewfunc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong type, jlong args, jlong nargs, jlong kw) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_newfunc f = (HPyFunc_newfunc)target; - DHPy dh_type = _jlong2dh(dctx, type); - DHPy dh_kw = _jlong2dh(dctx, kw); - _ARR_JLONG2DH(dctx, dh_args, args, nargs) - DHPy dh_result = f(dctx, dh_type, dh_args, (HPy_ssize_t)nargs, dh_kw); - _ARR_DH_CLOSE(dctx, dh_args, nargs) - DHPy_close_and_check(dctx, dh_type); - DHPy_close_and_check(dctx, dh_kw); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugGetter)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_getter f = (HPyFunc_getter)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0, (void *)arg1); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugSetter)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1, jlong arg2) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_setter f = (HPyFunc_setter)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - jint result = (jint) f(dctx, dh_arg0, dh_arg1, (void *)arg2); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - return result; -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugObjobjproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0, jlong arg1) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_objobjproc f = (HPyFunc_objobjproc)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - jint result = (jint) f(dctx, dh_arg0, dh_arg1); - DHPy_close_and_check(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg1); - return result; -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeDebugDestructor)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_destructor f = (HPyFunc_destructor)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); -} - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugModcreate)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg0) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_mod_create f = (HPyFunc_mod_create)target; - DHPy dh_arg0 = _jlong2dh(dctx, arg0); - DHPy dh_result = f(dctx, dh_arg0); - DHPy_close_and_check(dctx, dh_arg0); - return from_dh(dctx, dh_result); -} - -#undef TRAMPOLINE diff --git a/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_init_jni.h b/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_init_jni.h deleted file mode 100644 index 80305c6288..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/autogen_ctx_init_jni.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023, 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_init_jni_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -_HPy_HIDDEN int init_autogen_jni_ctx(JNIEnv *env, jclass clazz, HPyContext *ctx, jlongArray jctx_handles); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_Unicode_FromWideChar; -_HPy_HIDDEN HPy ctx_Unicode_FromWideChar_jni(HPyContext *ctx, const wchar_t *w, HPy_ssize_t size); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_ListBuilder_New; -_HPy_HIDDEN HPyListBuilder ctx_ListBuilder_New_jni(HPyContext *ctx, HPy_ssize_t size); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_ListBuilder_Set; -_HPy_HIDDEN void ctx_ListBuilder_Set_jni(HPyContext *ctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_ListBuilder_Build; -_HPy_HIDDEN HPy ctx_ListBuilder_Build_jni(HPyContext *ctx, HPyListBuilder builder); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_ListBuilder_Cancel; -_HPy_HIDDEN void ctx_ListBuilder_Cancel_jni(HPyContext *ctx, HPyListBuilder builder); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_TupleBuilder_New; -_HPy_HIDDEN HPyTupleBuilder ctx_TupleBuilder_New_jni(HPyContext *ctx, HPy_ssize_t size); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_TupleBuilder_Set; -_HPy_HIDDEN void ctx_TupleBuilder_Set_jni(HPyContext *ctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_TupleBuilder_Build; -_HPy_HIDDEN HPy ctx_TupleBuilder_Build_jni(HPyContext *ctx, HPyTupleBuilder builder); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_TupleBuilder_Cancel; -_HPy_HIDDEN void ctx_TupleBuilder_Cancel_jni(HPyContext *ctx, HPyTupleBuilder builder); -_HPy_HIDDEN extern jmethodID jniMethod_ctx_Global_Load; -_HPy_HIDDEN HPy ctx_Global_Load_jni(HPyContext *ctx, HPyGlobal global); - diff --git a/graalpython/com.oracle.graal.python.jni/src/autogen_wrappers_jni.c b/graalpython/com.oracle.graal.python.jni/src/autogen_wrappers_jni.c deleted file mode 100644 index 949f71b8c6..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/autogen_wrappers_jni.c +++ /dev/null @@ -1,2282 +0,0 @@ -/* - * Copyright (c) 2023, 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.graalpy.autogen_wrappers_jni - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#include "hpy_jni.h" -#include "hpynative.h" -#include "hpy_log.h" -#include "com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNIContext.h" -#include "autogen_ctx_init_jni.h" - -#define TRAMPOLINE(FUN_NAME) Java_com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNIContext_ ## FUN_NAME - -static jmethodID jniMethod_ctx_Dup; -static HPy ctx_Dup_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Close; -static void ctx_Close_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_FromInt32_t; -static HPy ctx_Long_FromInt32_t_jni(HPyContext *ctx, int32_t value); -static jmethodID jniMethod_ctx_Long_FromUInt32_t; -static HPy ctx_Long_FromUInt32_t_jni(HPyContext *ctx, uint32_t value); -static jmethodID jniMethod_ctx_Long_FromInt64_t; -static HPy ctx_Long_FromInt64_t_jni(HPyContext *ctx, int64_t v); -static jmethodID jniMethod_ctx_Long_FromUInt64_t; -static HPy ctx_Long_FromUInt64_t_jni(HPyContext *ctx, uint64_t v); -static jmethodID jniMethod_ctx_Long_FromSize_t; -static HPy ctx_Long_FromSize_t_jni(HPyContext *ctx, size_t value); -static jmethodID jniMethod_ctx_Long_FromSsize_t; -static HPy ctx_Long_FromSsize_t_jni(HPyContext *ctx, HPy_ssize_t value); -static jmethodID jniMethod_ctx_Long_AsInt32_t; -static int32_t ctx_Long_AsInt32_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsUInt32_t; -static uint32_t ctx_Long_AsUInt32_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsUInt32_tMask; -static uint32_t ctx_Long_AsUInt32_tMask_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsInt64_t; -static int64_t ctx_Long_AsInt64_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsUInt64_t; -static uint64_t ctx_Long_AsUInt64_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsUInt64_tMask; -static uint64_t ctx_Long_AsUInt64_tMask_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsSize_t; -static size_t ctx_Long_AsSize_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsSsize_t; -static HPy_ssize_t ctx_Long_AsSsize_t_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsVoidPtr; -static void *ctx_Long_AsVoidPtr_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Long_AsDouble; -static double ctx_Long_AsDouble_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Float_FromDouble; -static HPy ctx_Float_FromDouble_jni(HPyContext *ctx, double v); -static jmethodID jniMethod_ctx_Float_AsDouble; -static double ctx_Float_AsDouble_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bool_FromBool; -static HPy ctx_Bool_FromBool_jni(HPyContext *ctx, bool v); -static jmethodID jniMethod_ctx_Length; -static HPy_ssize_t ctx_Length_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Number_Check; -static int ctx_Number_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Add; -static HPy ctx_Add_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Subtract; -static HPy ctx_Subtract_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Multiply; -static HPy ctx_Multiply_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_MatrixMultiply; -static HPy ctx_MatrixMultiply_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_FloorDivide; -static HPy ctx_FloorDivide_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_TrueDivide; -static HPy ctx_TrueDivide_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Remainder; -static HPy ctx_Remainder_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Divmod; -static HPy ctx_Divmod_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Power; -static HPy ctx_Power_jni(HPyContext *ctx, HPy h1, HPy h2, HPy h3); -static jmethodID jniMethod_ctx_Negative; -static HPy ctx_Negative_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Positive; -static HPy ctx_Positive_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Absolute; -static HPy ctx_Absolute_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Invert; -static HPy ctx_Invert_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Lshift; -static HPy ctx_Lshift_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Rshift; -static HPy ctx_Rshift_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_And; -static HPy ctx_And_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Xor; -static HPy ctx_Xor_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Or; -static HPy ctx_Or_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Index; -static HPy ctx_Index_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Long; -static HPy ctx_Long_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_Float; -static HPy ctx_Float_jni(HPyContext *ctx, HPy h1); -static jmethodID jniMethod_ctx_InPlaceAdd; -static HPy ctx_InPlaceAdd_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceSubtract; -static HPy ctx_InPlaceSubtract_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceMultiply; -static HPy ctx_InPlaceMultiply_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceMatrixMultiply; -static HPy ctx_InPlaceMatrixMultiply_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceFloorDivide; -static HPy ctx_InPlaceFloorDivide_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceTrueDivide; -static HPy ctx_InPlaceTrueDivide_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceRemainder; -static HPy ctx_InPlaceRemainder_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlacePower; -static HPy ctx_InPlacePower_jni(HPyContext *ctx, HPy h1, HPy h2, HPy h3); -static jmethodID jniMethod_ctx_InPlaceLshift; -static HPy ctx_InPlaceLshift_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceRshift; -static HPy ctx_InPlaceRshift_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceAnd; -static HPy ctx_InPlaceAnd_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceXor; -static HPy ctx_InPlaceXor_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_InPlaceOr; -static HPy ctx_InPlaceOr_jni(HPyContext *ctx, HPy h1, HPy h2); -static jmethodID jniMethod_ctx_Callable_Check; -static int ctx_Callable_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_CallTupleDict; -static HPy ctx_CallTupleDict_jni(HPyContext *ctx, HPy callable, HPy args, HPy kw); -static jmethodID jniMethod_ctx_Call; -static HPy ctx_Call_jni(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames); -static jmethodID jniMethod_ctx_CallMethod; -static HPy ctx_CallMethod_jni(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames); -static jmethodID jniMethod_ctx_FatalError; -static void ctx_FatalError_jni(HPyContext *ctx, const char *message); -static jmethodID jniMethod_ctx_Err_SetString; -static void ctx_Err_SetString_jni(HPyContext *ctx, HPy h_type, const char *utf8_message); -static jmethodID jniMethod_ctx_Err_SetObject; -static void ctx_Err_SetObject_jni(HPyContext *ctx, HPy h_type, HPy h_value); -static jmethodID jniMethod_ctx_Err_SetFromErrnoWithFilename; -static HPy ctx_Err_SetFromErrnoWithFilename_jni(HPyContext *ctx, HPy h_type, const char *filename_fsencoded); -static jmethodID jniMethod_ctx_Err_SetFromErrnoWithFilenameObjects; -static void ctx_Err_SetFromErrnoWithFilenameObjects_jni(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2); -static jmethodID jniMethod_ctx_Err_Occurred; -static int ctx_Err_Occurred_jni(HPyContext *ctx); -static jmethodID jniMethod_ctx_Err_ExceptionMatches; -static int ctx_Err_ExceptionMatches_jni(HPyContext *ctx, HPy exc); -static jmethodID jniMethod_ctx_Err_NoMemory; -static void ctx_Err_NoMemory_jni(HPyContext *ctx); -static jmethodID jniMethod_ctx_Err_Clear; -static void ctx_Err_Clear_jni(HPyContext *ctx); -static jmethodID jniMethod_ctx_Err_NewException; -static HPy ctx_Err_NewException_jni(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict); -static jmethodID jniMethod_ctx_Err_NewExceptionWithDoc; -static HPy ctx_Err_NewExceptionWithDoc_jni(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict); -static jmethodID jniMethod_ctx_Err_WarnEx; -static int ctx_Err_WarnEx_jni(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level); -static jmethodID jniMethod_ctx_Err_WriteUnraisable; -static void ctx_Err_WriteUnraisable_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_IsTrue; -static int ctx_IsTrue_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Type_FromSpec; -static HPy ctx_Type_FromSpec_jni(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params); -static jmethodID jniMethod_ctx_Type_GenericNew; -static HPy ctx_Type_GenericNew_jni(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw); -static jmethodID jniMethod_ctx_GetAttr; -static HPy ctx_GetAttr_jni(HPyContext *ctx, HPy obj, HPy name); -static jmethodID jniMethod_ctx_HasAttr; -static int ctx_HasAttr_jni(HPyContext *ctx, HPy obj, HPy name); -static jmethodID jniMethod_ctx_HasAttr_s; -static int ctx_HasAttr_s_jni(HPyContext *ctx, HPy obj, const char *utf8_name); -static jmethodID jniMethod_ctx_SetAttr; -static int ctx_SetAttr_jni(HPyContext *ctx, HPy obj, HPy name, HPy value); -static jmethodID jniMethod_ctx_SetAttr_s; -static int ctx_SetAttr_s_jni(HPyContext *ctx, HPy obj, const char *utf8_name, HPy value); -static jmethodID jniMethod_ctx_GetItem; -static HPy ctx_GetItem_jni(HPyContext *ctx, HPy obj, HPy key); -static jmethodID jniMethod_ctx_GetItem_i; -static HPy ctx_GetItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -static jmethodID jniMethod_ctx_Contains; -static int ctx_Contains_jni(HPyContext *ctx, HPy container, HPy key); -static jmethodID jniMethod_ctx_SetItem; -static int ctx_SetItem_jni(HPyContext *ctx, HPy obj, HPy key, HPy value); -static jmethodID jniMethod_ctx_SetItem_i; -static int ctx_SetItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value); -static jmethodID jniMethod_ctx_DelItem; -static int ctx_DelItem_jni(HPyContext *ctx, HPy obj, HPy key); -static jmethodID jniMethod_ctx_DelItem_i; -static int ctx_DelItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx); -static jmethodID jniMethod_ctx_DelItem_s; -static int ctx_DelItem_s_jni(HPyContext *ctx, HPy obj, const char *utf8_key); -static jmethodID jniMethod_ctx_Type; -static HPy ctx_Type_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_TypeCheck; -static int ctx_TypeCheck_jni(HPyContext *ctx, HPy obj, HPy type); -static jmethodID jniMethod_ctx_Type_GetName; -static const char *ctx_Type_GetName_jni(HPyContext *ctx, HPy type); -static jmethodID jniMethod_ctx_Type_IsSubtype; -static int ctx_Type_IsSubtype_jni(HPyContext *ctx, HPy sub, HPy type); -static jmethodID jniMethod_ctx_Is; -static int ctx_Is_jni(HPyContext *ctx, HPy obj, HPy other); -static jmethodID jniMethod_ctx_AsStruct_Object; -static void *ctx_AsStruct_Object_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Legacy; -static void *ctx_AsStruct_Legacy_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Type; -static void *ctx_AsStruct_Type_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Long; -static void *ctx_AsStruct_Long_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Float; -static void *ctx_AsStruct_Float_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Unicode; -static void *ctx_AsStruct_Unicode_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_Tuple; -static void *ctx_AsStruct_Tuple_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_AsStruct_List; -static void *ctx_AsStruct_List_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Type_GetBuiltinShape; -static HPyType_BuiltinShape ctx_Type_GetBuiltinShape_jni(HPyContext *ctx, HPy h_type); -static jmethodID jniMethod_ctx_New; -static HPy ctx_New_jni(HPyContext *ctx, HPy h_type, void **data); -static jmethodID jniMethod_ctx_Repr; -static HPy ctx_Repr_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_Str; -static HPy ctx_Str_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_ASCII; -static HPy ctx_ASCII_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_Bytes; -static HPy ctx_Bytes_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_RichCompare; -static HPy ctx_RichCompare_jni(HPyContext *ctx, HPy v, HPy w, int op); -static jmethodID jniMethod_ctx_RichCompareBool; -static int ctx_RichCompareBool_jni(HPyContext *ctx, HPy v, HPy w, int op); -static jmethodID jniMethod_ctx_Hash; -static HPy_hash_t ctx_Hash_jni(HPyContext *ctx, HPy obj); -static jmethodID jniMethod_ctx_Bytes_Check; -static int ctx_Bytes_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bytes_Size; -static HPy_ssize_t ctx_Bytes_Size_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bytes_GET_SIZE; -static HPy_ssize_t ctx_Bytes_GET_SIZE_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bytes_AsString; -static const char *ctx_Bytes_AsString_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bytes_AS_STRING; -static const char *ctx_Bytes_AS_STRING_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Bytes_FromString; -static HPy ctx_Bytes_FromString_jni(HPyContext *ctx, const char *bytes); -static jmethodID jniMethod_ctx_Bytes_FromStringAndSize; -static HPy ctx_Bytes_FromStringAndSize_jni(HPyContext *ctx, const char *bytes, HPy_ssize_t len); -static jmethodID jniMethod_ctx_Unicode_FromString; -static HPy ctx_Unicode_FromString_jni(HPyContext *ctx, const char *utf8); -static jmethodID jniMethod_ctx_Unicode_Check; -static int ctx_Unicode_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Unicode_AsASCIIString; -static HPy ctx_Unicode_AsASCIIString_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Unicode_AsLatin1String; -static HPy ctx_Unicode_AsLatin1String_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Unicode_AsUTF8String; -static HPy ctx_Unicode_AsUTF8String_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Unicode_AsUTF8AndSize; -static const char *ctx_Unicode_AsUTF8AndSize_jni(HPyContext *ctx, HPy h, HPy_ssize_t *size); -_HPy_HIDDEN jmethodID jniMethod_ctx_Unicode_FromWideChar; -static jmethodID jniMethod_ctx_Unicode_DecodeFSDefault; -static HPy ctx_Unicode_DecodeFSDefault_jni(HPyContext *ctx, const char *v); -static jmethodID jniMethod_ctx_Unicode_DecodeFSDefaultAndSize; -static HPy ctx_Unicode_DecodeFSDefaultAndSize_jni(HPyContext *ctx, const char *v, HPy_ssize_t size); -static jmethodID jniMethod_ctx_Unicode_EncodeFSDefault; -static HPy ctx_Unicode_EncodeFSDefault_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Unicode_ReadChar; -static HPy_UCS4 ctx_Unicode_ReadChar_jni(HPyContext *ctx, HPy h, HPy_ssize_t index); -static jmethodID jniMethod_ctx_Unicode_DecodeASCII; -static HPy ctx_Unicode_DecodeASCII_jni(HPyContext *ctx, const char *ascii, HPy_ssize_t size, const char *errors); -static jmethodID jniMethod_ctx_Unicode_DecodeLatin1; -static HPy ctx_Unicode_DecodeLatin1_jni(HPyContext *ctx, const char *latin1, HPy_ssize_t size, const char *errors); -static jmethodID jniMethod_ctx_Unicode_FromEncodedObject; -static HPy ctx_Unicode_FromEncodedObject_jni(HPyContext *ctx, HPy obj, const char *encoding, const char *errors); -static jmethodID jniMethod_ctx_Unicode_Substring; -static HPy ctx_Unicode_Substring_jni(HPyContext *ctx, HPy str, HPy_ssize_t start, HPy_ssize_t end); -static jmethodID jniMethod_ctx_List_Check; -static int ctx_List_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_List_New; -static HPy ctx_List_New_jni(HPyContext *ctx, HPy_ssize_t len); -static jmethodID jniMethod_ctx_List_Append; -static int ctx_List_Append_jni(HPyContext *ctx, HPy h_list, HPy h_item); -static jmethodID jniMethod_ctx_Dict_Check; -static int ctx_Dict_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Dict_New; -static HPy ctx_Dict_New_jni(HPyContext *ctx); -static jmethodID jniMethod_ctx_Dict_Keys; -static HPy ctx_Dict_Keys_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Dict_Copy; -static HPy ctx_Dict_Copy_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Tuple_Check; -static int ctx_Tuple_Check_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Slice_Unpack; -static int ctx_Slice_Unpack_jni(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step); -static jmethodID jniMethod_ctx_Import_ImportModule; -static HPy ctx_Import_ImportModule_jni(HPyContext *ctx, const char *utf8_name); -static jmethodID jniMethod_ctx_Capsule_New; -static HPy ctx_Capsule_New_jni(HPyContext *ctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor); -static jmethodID jniMethod_ctx_Capsule_Get; -static void *ctx_Capsule_Get_jni(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name); -static jmethodID jniMethod_ctx_Capsule_IsValid; -static int ctx_Capsule_IsValid_jni(HPyContext *ctx, HPy capsule, const char *utf8_name); -static jmethodID jniMethod_ctx_Capsule_Set; -static int ctx_Capsule_Set_jni(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value); -static jmethodID jniMethod_ctx_FromPyObject; -static HPy ctx_FromPyObject_jni(HPyContext *ctx, cpy_PyObject *obj); -static jmethodID jniMethod_ctx_AsPyObject; -static cpy_PyObject *ctx_AsPyObject_jni(HPyContext *ctx, HPy h); -_HPy_HIDDEN jmethodID jniMethod_ctx_ListBuilder_New; -_HPy_HIDDEN jmethodID jniMethod_ctx_ListBuilder_Set; -_HPy_HIDDEN jmethodID jniMethod_ctx_ListBuilder_Build; -_HPy_HIDDEN jmethodID jniMethod_ctx_ListBuilder_Cancel; -_HPy_HIDDEN jmethodID jniMethod_ctx_TupleBuilder_New; -_HPy_HIDDEN jmethodID jniMethod_ctx_TupleBuilder_Set; -_HPy_HIDDEN jmethodID jniMethod_ctx_TupleBuilder_Build; -_HPy_HIDDEN jmethodID jniMethod_ctx_TupleBuilder_Cancel; -static jmethodID jniMethod_ctx_Field_Load; -static HPy ctx_Field_Load_jni(HPyContext *ctx, HPy source_object, HPyField source_field); -static jmethodID jniMethod_ctx_ReenterPythonExecution; -static void ctx_ReenterPythonExecution_jni(HPyContext *ctx, HPyThreadState state); -static jmethodID jniMethod_ctx_LeavePythonExecution; -static HPyThreadState ctx_LeavePythonExecution_jni(HPyContext *ctx); -_HPy_HIDDEN jmethodID jniMethod_ctx_Global_Load; -static jmethodID jniMethod_ctx_Dump; -static void ctx_Dump_jni(HPyContext *ctx, HPy h); -static jmethodID jniMethod_ctx_Compile_s; -static HPy ctx_Compile_s_jni(HPyContext *ctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind); -static jmethodID jniMethod_ctx_EvalCode; -static HPy ctx_EvalCode_jni(HPyContext *ctx, HPy code, HPy globals, HPy locals); -static jmethodID jniMethod_ctx_ContextVar_New; -static HPy ctx_ContextVar_New_jni(HPyContext *ctx, const char *name, HPy default_value); -static jmethodID jniMethod_ctx_ContextVar_Set; -static HPy ctx_ContextVar_Set_jni(HPyContext *ctx, HPy context_var, HPy value); -static jmethodID jniMethod_ctx_SetCallFunction; -static int ctx_SetCallFunction_jni(HPyContext *ctx, HPy h, HPyCallFunction *func); - -_HPy_HIDDEN int init_autogen_jni_ctx(JNIEnv *env, jclass clazz, HPyContext *ctx, jlongArray jctx_handles) -{ - - jlong *ctx_handles = (*env)->GetPrimitiveArrayCritical(env, jctx_handles, NULL); - if (ctx_handles == NULL) { - LOGS("ERROR: Could not access Java context handle array elements\n"); - return 1; - } - ctx->h_None = _jlong2h(ctx_handles[0]); - ctx->h_True = _jlong2h(ctx_handles[1]); - ctx->h_False = _jlong2h(ctx_handles[2]); - ctx->h_NotImplemented = _jlong2h(ctx_handles[3]); - ctx->h_Ellipsis = _jlong2h(ctx_handles[4]); - ctx->h_BaseException = _jlong2h(ctx_handles[5]); - ctx->h_Exception = _jlong2h(ctx_handles[6]); - ctx->h_StopAsyncIteration = _jlong2h(ctx_handles[7]); - ctx->h_StopIteration = _jlong2h(ctx_handles[8]); - ctx->h_GeneratorExit = _jlong2h(ctx_handles[9]); - ctx->h_ArithmeticError = _jlong2h(ctx_handles[10]); - ctx->h_LookupError = _jlong2h(ctx_handles[11]); - ctx->h_AssertionError = _jlong2h(ctx_handles[12]); - ctx->h_AttributeError = _jlong2h(ctx_handles[13]); - ctx->h_BufferError = _jlong2h(ctx_handles[14]); - ctx->h_EOFError = _jlong2h(ctx_handles[15]); - ctx->h_FloatingPointError = _jlong2h(ctx_handles[16]); - ctx->h_OSError = _jlong2h(ctx_handles[17]); - ctx->h_ImportError = _jlong2h(ctx_handles[18]); - ctx->h_ModuleNotFoundError = _jlong2h(ctx_handles[19]); - ctx->h_IndexError = _jlong2h(ctx_handles[20]); - ctx->h_KeyError = _jlong2h(ctx_handles[21]); - ctx->h_KeyboardInterrupt = _jlong2h(ctx_handles[22]); - ctx->h_MemoryError = _jlong2h(ctx_handles[23]); - ctx->h_NameError = _jlong2h(ctx_handles[24]); - ctx->h_OverflowError = _jlong2h(ctx_handles[25]); - ctx->h_RuntimeError = _jlong2h(ctx_handles[26]); - ctx->h_RecursionError = _jlong2h(ctx_handles[27]); - ctx->h_NotImplementedError = _jlong2h(ctx_handles[28]); - ctx->h_SyntaxError = _jlong2h(ctx_handles[29]); - ctx->h_IndentationError = _jlong2h(ctx_handles[30]); - ctx->h_TabError = _jlong2h(ctx_handles[31]); - ctx->h_ReferenceError = _jlong2h(ctx_handles[32]); - ctx->h_SystemError = _jlong2h(ctx_handles[33]); - ctx->h_SystemExit = _jlong2h(ctx_handles[34]); - ctx->h_TypeError = _jlong2h(ctx_handles[35]); - ctx->h_UnboundLocalError = _jlong2h(ctx_handles[36]); - ctx->h_UnicodeError = _jlong2h(ctx_handles[37]); - ctx->h_UnicodeEncodeError = _jlong2h(ctx_handles[38]); - ctx->h_UnicodeDecodeError = _jlong2h(ctx_handles[39]); - ctx->h_UnicodeTranslateError = _jlong2h(ctx_handles[40]); - ctx->h_ValueError = _jlong2h(ctx_handles[41]); - ctx->h_ZeroDivisionError = _jlong2h(ctx_handles[42]); - ctx->h_BlockingIOError = _jlong2h(ctx_handles[43]); - ctx->h_BrokenPipeError = _jlong2h(ctx_handles[44]); - ctx->h_ChildProcessError = _jlong2h(ctx_handles[45]); - ctx->h_ConnectionError = _jlong2h(ctx_handles[46]); - ctx->h_ConnectionAbortedError = _jlong2h(ctx_handles[47]); - ctx->h_ConnectionRefusedError = _jlong2h(ctx_handles[48]); - ctx->h_ConnectionResetError = _jlong2h(ctx_handles[49]); - ctx->h_FileExistsError = _jlong2h(ctx_handles[50]); - ctx->h_FileNotFoundError = _jlong2h(ctx_handles[51]); - ctx->h_InterruptedError = _jlong2h(ctx_handles[52]); - ctx->h_IsADirectoryError = _jlong2h(ctx_handles[53]); - ctx->h_NotADirectoryError = _jlong2h(ctx_handles[54]); - ctx->h_PermissionError = _jlong2h(ctx_handles[55]); - ctx->h_ProcessLookupError = _jlong2h(ctx_handles[56]); - ctx->h_TimeoutError = _jlong2h(ctx_handles[57]); - ctx->h_Warning = _jlong2h(ctx_handles[58]); - ctx->h_UserWarning = _jlong2h(ctx_handles[59]); - ctx->h_DeprecationWarning = _jlong2h(ctx_handles[60]); - ctx->h_PendingDeprecationWarning = _jlong2h(ctx_handles[61]); - ctx->h_SyntaxWarning = _jlong2h(ctx_handles[62]); - ctx->h_RuntimeWarning = _jlong2h(ctx_handles[63]); - ctx->h_FutureWarning = _jlong2h(ctx_handles[64]); - ctx->h_ImportWarning = _jlong2h(ctx_handles[65]); - ctx->h_UnicodeWarning = _jlong2h(ctx_handles[66]); - ctx->h_BytesWarning = _jlong2h(ctx_handles[67]); - ctx->h_ResourceWarning = _jlong2h(ctx_handles[68]); - ctx->h_BaseObjectType = _jlong2h(ctx_handles[69]); - ctx->h_TypeType = _jlong2h(ctx_handles[70]); - ctx->h_BoolType = _jlong2h(ctx_handles[71]); - ctx->h_LongType = _jlong2h(ctx_handles[72]); - ctx->h_FloatType = _jlong2h(ctx_handles[73]); - ctx->h_UnicodeType = _jlong2h(ctx_handles[74]); - ctx->h_TupleType = _jlong2h(ctx_handles[75]); - ctx->h_ListType = _jlong2h(ctx_handles[76]); - ctx->h_ComplexType = _jlong2h(ctx_handles[238]); - ctx->h_BytesType = _jlong2h(ctx_handles[239]); - ctx->h_MemoryViewType = _jlong2h(ctx_handles[240]); - ctx->h_CapsuleType = _jlong2h(ctx_handles[241]); - ctx->h_SliceType = _jlong2h(ctx_handles[242]); - ctx->h_Builtins = _jlong2h(ctx_handles[243]); - (*env)->ReleasePrimitiveArrayCritical(env, jctx_handles, ctx_handles, JNI_ABORT); - - jniMethod_ctx_Dup = (*env)->GetMethodID(env, clazz, "ctxDup", "(J)J"); - if (jniMethod_ctx_Dup == NULL) { - LOGS("ERROR: Java method ctxDup not found found !\n"); - return 1; - } - ctx->ctx_Dup = &ctx_Dup_jni; - jniMethod_ctx_Close = (*env)->GetMethodID(env, clazz, "ctxClose", "(J)V"); - if (jniMethod_ctx_Close == NULL) { - LOGS("ERROR: Java method ctxClose not found found !\n"); - return 1; - } - ctx->ctx_Close = &ctx_Close_jni; - jniMethod_ctx_Long_FromInt32_t = (*env)->GetMethodID(env, clazz, "ctxLongFromInt32t", "(I)J"); - if (jniMethod_ctx_Long_FromInt32_t == NULL) { - LOGS("ERROR: Java method ctxLongFromInt32t not found found !\n"); - return 1; - } - ctx->ctx_Long_FromInt32_t = &ctx_Long_FromInt32_t_jni; - jniMethod_ctx_Long_FromUInt32_t = (*env)->GetMethodID(env, clazz, "ctxLongFromUInt32t", "(I)J"); - if (jniMethod_ctx_Long_FromUInt32_t == NULL) { - LOGS("ERROR: Java method ctxLongFromUInt32t not found found !\n"); - return 1; - } - ctx->ctx_Long_FromUInt32_t = &ctx_Long_FromUInt32_t_jni; - jniMethod_ctx_Long_FromInt64_t = (*env)->GetMethodID(env, clazz, "ctxLongFromInt64t", "(J)J"); - if (jniMethod_ctx_Long_FromInt64_t == NULL) { - LOGS("ERROR: Java method ctxLongFromInt64t not found found !\n"); - return 1; - } - ctx->ctx_Long_FromInt64_t = &ctx_Long_FromInt64_t_jni; - jniMethod_ctx_Long_FromUInt64_t = (*env)->GetMethodID(env, clazz, "ctxLongFromUInt64t", "(J)J"); - if (jniMethod_ctx_Long_FromUInt64_t == NULL) { - LOGS("ERROR: Java method ctxLongFromUInt64t not found found !\n"); - return 1; - } - ctx->ctx_Long_FromUInt64_t = &ctx_Long_FromUInt64_t_jni; - jniMethod_ctx_Long_FromSize_t = (*env)->GetMethodID(env, clazz, "ctxLongFromSizet", "(J)J"); - if (jniMethod_ctx_Long_FromSize_t == NULL) { - LOGS("ERROR: Java method ctxLongFromSizet not found found !\n"); - return 1; - } - ctx->ctx_Long_FromSize_t = &ctx_Long_FromSize_t_jni; - jniMethod_ctx_Long_FromSsize_t = (*env)->GetMethodID(env, clazz, "ctxLongFromSsizet", "(J)J"); - if (jniMethod_ctx_Long_FromSsize_t == NULL) { - LOGS("ERROR: Java method ctxLongFromSsizet not found found !\n"); - return 1; - } - ctx->ctx_Long_FromSsize_t = &ctx_Long_FromSsize_t_jni; - jniMethod_ctx_Long_AsInt32_t = (*env)->GetMethodID(env, clazz, "ctxLongAsInt32t", "(J)I"); - if (jniMethod_ctx_Long_AsInt32_t == NULL) { - LOGS("ERROR: Java method ctxLongAsInt32t not found found !\n"); - return 1; - } - ctx->ctx_Long_AsInt32_t = &ctx_Long_AsInt32_t_jni; - jniMethod_ctx_Long_AsUInt32_t = (*env)->GetMethodID(env, clazz, "ctxLongAsUInt32t", "(J)I"); - if (jniMethod_ctx_Long_AsUInt32_t == NULL) { - LOGS("ERROR: Java method ctxLongAsUInt32t not found found !\n"); - return 1; - } - ctx->ctx_Long_AsUInt32_t = &ctx_Long_AsUInt32_t_jni; - jniMethod_ctx_Long_AsUInt32_tMask = (*env)->GetMethodID(env, clazz, "ctxLongAsUInt32tMask", "(J)I"); - if (jniMethod_ctx_Long_AsUInt32_tMask == NULL) { - LOGS("ERROR: Java method ctxLongAsUInt32tMask not found found !\n"); - return 1; - } - ctx->ctx_Long_AsUInt32_tMask = &ctx_Long_AsUInt32_tMask_jni; - jniMethod_ctx_Long_AsInt64_t = (*env)->GetMethodID(env, clazz, "ctxLongAsInt64t", "(J)J"); - if (jniMethod_ctx_Long_AsInt64_t == NULL) { - LOGS("ERROR: Java method ctxLongAsInt64t not found found !\n"); - return 1; - } - ctx->ctx_Long_AsInt64_t = &ctx_Long_AsInt64_t_jni; - jniMethod_ctx_Long_AsUInt64_t = (*env)->GetMethodID(env, clazz, "ctxLongAsUInt64t", "(J)J"); - if (jniMethod_ctx_Long_AsUInt64_t == NULL) { - LOGS("ERROR: Java method ctxLongAsUInt64t not found found !\n"); - return 1; - } - ctx->ctx_Long_AsUInt64_t = &ctx_Long_AsUInt64_t_jni; - jniMethod_ctx_Long_AsUInt64_tMask = (*env)->GetMethodID(env, clazz, "ctxLongAsUInt64tMask", "(J)J"); - if (jniMethod_ctx_Long_AsUInt64_tMask == NULL) { - LOGS("ERROR: Java method ctxLongAsUInt64tMask not found found !\n"); - return 1; - } - ctx->ctx_Long_AsUInt64_tMask = &ctx_Long_AsUInt64_tMask_jni; - jniMethod_ctx_Long_AsSize_t = (*env)->GetMethodID(env, clazz, "ctxLongAsSizet", "(J)J"); - if (jniMethod_ctx_Long_AsSize_t == NULL) { - LOGS("ERROR: Java method ctxLongAsSizet not found found !\n"); - return 1; - } - ctx->ctx_Long_AsSize_t = &ctx_Long_AsSize_t_jni; - jniMethod_ctx_Long_AsSsize_t = (*env)->GetMethodID(env, clazz, "ctxLongAsSsizet", "(J)J"); - if (jniMethod_ctx_Long_AsSsize_t == NULL) { - LOGS("ERROR: Java method ctxLongAsSsizet not found found !\n"); - return 1; - } - ctx->ctx_Long_AsSsize_t = &ctx_Long_AsSsize_t_jni; - jniMethod_ctx_Long_AsVoidPtr = (*env)->GetMethodID(env, clazz, "ctxLongAsVoidPtr", "(J)J"); - if (jniMethod_ctx_Long_AsVoidPtr == NULL) { - LOGS("ERROR: Java method ctxLongAsVoidPtr not found found !\n"); - return 1; - } - ctx->ctx_Long_AsVoidPtr = &ctx_Long_AsVoidPtr_jni; - jniMethod_ctx_Long_AsDouble = (*env)->GetMethodID(env, clazz, "ctxLongAsDouble", "(J)D"); - if (jniMethod_ctx_Long_AsDouble == NULL) { - LOGS("ERROR: Java method ctxLongAsDouble not found found !\n"); - return 1; - } - ctx->ctx_Long_AsDouble = &ctx_Long_AsDouble_jni; - jniMethod_ctx_Float_FromDouble = (*env)->GetMethodID(env, clazz, "ctxFloatFromDouble", "(D)J"); - if (jniMethod_ctx_Float_FromDouble == NULL) { - LOGS("ERROR: Java method ctxFloatFromDouble not found found !\n"); - return 1; - } - ctx->ctx_Float_FromDouble = &ctx_Float_FromDouble_jni; - jniMethod_ctx_Float_AsDouble = (*env)->GetMethodID(env, clazz, "ctxFloatAsDouble", "(J)D"); - if (jniMethod_ctx_Float_AsDouble == NULL) { - LOGS("ERROR: Java method ctxFloatAsDouble not found found !\n"); - return 1; - } - ctx->ctx_Float_AsDouble = &ctx_Float_AsDouble_jni; - jniMethod_ctx_Bool_FromBool = (*env)->GetMethodID(env, clazz, "ctxBoolFromBool", "(Z)J"); - if (jniMethod_ctx_Bool_FromBool == NULL) { - LOGS("ERROR: Java method ctxBoolFromBool not found found !\n"); - return 1; - } - ctx->ctx_Bool_FromBool = &ctx_Bool_FromBool_jni; - jniMethod_ctx_Length = (*env)->GetMethodID(env, clazz, "ctxLength", "(J)J"); - if (jniMethod_ctx_Length == NULL) { - LOGS("ERROR: Java method ctxLength not found found !\n"); - return 1; - } - ctx->ctx_Length = &ctx_Length_jni; - jniMethod_ctx_Number_Check = (*env)->GetMethodID(env, clazz, "ctxNumberCheck", "(J)I"); - if (jniMethod_ctx_Number_Check == NULL) { - LOGS("ERROR: Java method ctxNumberCheck not found found !\n"); - return 1; - } - ctx->ctx_Number_Check = &ctx_Number_Check_jni; - jniMethod_ctx_Add = (*env)->GetMethodID(env, clazz, "ctxAdd", "(JJ)J"); - if (jniMethod_ctx_Add == NULL) { - LOGS("ERROR: Java method ctxAdd not found found !\n"); - return 1; - } - ctx->ctx_Add = &ctx_Add_jni; - jniMethod_ctx_Subtract = (*env)->GetMethodID(env, clazz, "ctxSubtract", "(JJ)J"); - if (jniMethod_ctx_Subtract == NULL) { - LOGS("ERROR: Java method ctxSubtract not found found !\n"); - return 1; - } - ctx->ctx_Subtract = &ctx_Subtract_jni; - jniMethod_ctx_Multiply = (*env)->GetMethodID(env, clazz, "ctxMultiply", "(JJ)J"); - if (jniMethod_ctx_Multiply == NULL) { - LOGS("ERROR: Java method ctxMultiply not found found !\n"); - return 1; - } - ctx->ctx_Multiply = &ctx_Multiply_jni; - jniMethod_ctx_MatrixMultiply = (*env)->GetMethodID(env, clazz, "ctxMatrixMultiply", "(JJ)J"); - if (jniMethod_ctx_MatrixMultiply == NULL) { - LOGS("ERROR: Java method ctxMatrixMultiply not found found !\n"); - return 1; - } - ctx->ctx_MatrixMultiply = &ctx_MatrixMultiply_jni; - jniMethod_ctx_FloorDivide = (*env)->GetMethodID(env, clazz, "ctxFloorDivide", "(JJ)J"); - if (jniMethod_ctx_FloorDivide == NULL) { - LOGS("ERROR: Java method ctxFloorDivide not found found !\n"); - return 1; - } - ctx->ctx_FloorDivide = &ctx_FloorDivide_jni; - jniMethod_ctx_TrueDivide = (*env)->GetMethodID(env, clazz, "ctxTrueDivide", "(JJ)J"); - if (jniMethod_ctx_TrueDivide == NULL) { - LOGS("ERROR: Java method ctxTrueDivide not found found !\n"); - return 1; - } - ctx->ctx_TrueDivide = &ctx_TrueDivide_jni; - jniMethod_ctx_Remainder = (*env)->GetMethodID(env, clazz, "ctxRemainder", "(JJ)J"); - if (jniMethod_ctx_Remainder == NULL) { - LOGS("ERROR: Java method ctxRemainder not found found !\n"); - return 1; - } - ctx->ctx_Remainder = &ctx_Remainder_jni; - jniMethod_ctx_Divmod = (*env)->GetMethodID(env, clazz, "ctxDivmod", "(JJ)J"); - if (jniMethod_ctx_Divmod == NULL) { - LOGS("ERROR: Java method ctxDivmod not found found !\n"); - return 1; - } - ctx->ctx_Divmod = &ctx_Divmod_jni; - jniMethod_ctx_Power = (*env)->GetMethodID(env, clazz, "ctxPower", "(JJJ)J"); - if (jniMethod_ctx_Power == NULL) { - LOGS("ERROR: Java method ctxPower not found found !\n"); - return 1; - } - ctx->ctx_Power = &ctx_Power_jni; - jniMethod_ctx_Negative = (*env)->GetMethodID(env, clazz, "ctxNegative", "(J)J"); - if (jniMethod_ctx_Negative == NULL) { - LOGS("ERROR: Java method ctxNegative not found found !\n"); - return 1; - } - ctx->ctx_Negative = &ctx_Negative_jni; - jniMethod_ctx_Positive = (*env)->GetMethodID(env, clazz, "ctxPositive", "(J)J"); - if (jniMethod_ctx_Positive == NULL) { - LOGS("ERROR: Java method ctxPositive not found found !\n"); - return 1; - } - ctx->ctx_Positive = &ctx_Positive_jni; - jniMethod_ctx_Absolute = (*env)->GetMethodID(env, clazz, "ctxAbsolute", "(J)J"); - if (jniMethod_ctx_Absolute == NULL) { - LOGS("ERROR: Java method ctxAbsolute not found found !\n"); - return 1; - } - ctx->ctx_Absolute = &ctx_Absolute_jni; - jniMethod_ctx_Invert = (*env)->GetMethodID(env, clazz, "ctxInvert", "(J)J"); - if (jniMethod_ctx_Invert == NULL) { - LOGS("ERROR: Java method ctxInvert not found found !\n"); - return 1; - } - ctx->ctx_Invert = &ctx_Invert_jni; - jniMethod_ctx_Lshift = (*env)->GetMethodID(env, clazz, "ctxLshift", "(JJ)J"); - if (jniMethod_ctx_Lshift == NULL) { - LOGS("ERROR: Java method ctxLshift not found found !\n"); - return 1; - } - ctx->ctx_Lshift = &ctx_Lshift_jni; - jniMethod_ctx_Rshift = (*env)->GetMethodID(env, clazz, "ctxRshift", "(JJ)J"); - if (jniMethod_ctx_Rshift == NULL) { - LOGS("ERROR: Java method ctxRshift not found found !\n"); - return 1; - } - ctx->ctx_Rshift = &ctx_Rshift_jni; - jniMethod_ctx_And = (*env)->GetMethodID(env, clazz, "ctxAnd", "(JJ)J"); - if (jniMethod_ctx_And == NULL) { - LOGS("ERROR: Java method ctxAnd not found found !\n"); - return 1; - } - ctx->ctx_And = &ctx_And_jni; - jniMethod_ctx_Xor = (*env)->GetMethodID(env, clazz, "ctxXor", "(JJ)J"); - if (jniMethod_ctx_Xor == NULL) { - LOGS("ERROR: Java method ctxXor not found found !\n"); - return 1; - } - ctx->ctx_Xor = &ctx_Xor_jni; - jniMethod_ctx_Or = (*env)->GetMethodID(env, clazz, "ctxOr", "(JJ)J"); - if (jniMethod_ctx_Or == NULL) { - LOGS("ERROR: Java method ctxOr not found found !\n"); - return 1; - } - ctx->ctx_Or = &ctx_Or_jni; - jniMethod_ctx_Index = (*env)->GetMethodID(env, clazz, "ctxIndex", "(J)J"); - if (jniMethod_ctx_Index == NULL) { - LOGS("ERROR: Java method ctxIndex not found found !\n"); - return 1; - } - ctx->ctx_Index = &ctx_Index_jni; - jniMethod_ctx_Long = (*env)->GetMethodID(env, clazz, "ctxLong", "(J)J"); - if (jniMethod_ctx_Long == NULL) { - LOGS("ERROR: Java method ctxLong not found found !\n"); - return 1; - } - ctx->ctx_Long = &ctx_Long_jni; - jniMethod_ctx_Float = (*env)->GetMethodID(env, clazz, "ctxFloat", "(J)J"); - if (jniMethod_ctx_Float == NULL) { - LOGS("ERROR: Java method ctxFloat not found found !\n"); - return 1; - } - ctx->ctx_Float = &ctx_Float_jni; - jniMethod_ctx_InPlaceAdd = (*env)->GetMethodID(env, clazz, "ctxInPlaceAdd", "(JJ)J"); - if (jniMethod_ctx_InPlaceAdd == NULL) { - LOGS("ERROR: Java method ctxInPlaceAdd not found found !\n"); - return 1; - } - ctx->ctx_InPlaceAdd = &ctx_InPlaceAdd_jni; - jniMethod_ctx_InPlaceSubtract = (*env)->GetMethodID(env, clazz, "ctxInPlaceSubtract", "(JJ)J"); - if (jniMethod_ctx_InPlaceSubtract == NULL) { - LOGS("ERROR: Java method ctxInPlaceSubtract not found found !\n"); - return 1; - } - ctx->ctx_InPlaceSubtract = &ctx_InPlaceSubtract_jni; - jniMethod_ctx_InPlaceMultiply = (*env)->GetMethodID(env, clazz, "ctxInPlaceMultiply", "(JJ)J"); - if (jniMethod_ctx_InPlaceMultiply == NULL) { - LOGS("ERROR: Java method ctxInPlaceMultiply not found found !\n"); - return 1; - } - ctx->ctx_InPlaceMultiply = &ctx_InPlaceMultiply_jni; - jniMethod_ctx_InPlaceMatrixMultiply = (*env)->GetMethodID(env, clazz, "ctxInPlaceMatrixMultiply", "(JJ)J"); - if (jniMethod_ctx_InPlaceMatrixMultiply == NULL) { - LOGS("ERROR: Java method ctxInPlaceMatrixMultiply not found found !\n"); - return 1; - } - ctx->ctx_InPlaceMatrixMultiply = &ctx_InPlaceMatrixMultiply_jni; - jniMethod_ctx_InPlaceFloorDivide = (*env)->GetMethodID(env, clazz, "ctxInPlaceFloorDivide", "(JJ)J"); - if (jniMethod_ctx_InPlaceFloorDivide == NULL) { - LOGS("ERROR: Java method ctxInPlaceFloorDivide not found found !\n"); - return 1; - } - ctx->ctx_InPlaceFloorDivide = &ctx_InPlaceFloorDivide_jni; - jniMethod_ctx_InPlaceTrueDivide = (*env)->GetMethodID(env, clazz, "ctxInPlaceTrueDivide", "(JJ)J"); - if (jniMethod_ctx_InPlaceTrueDivide == NULL) { - LOGS("ERROR: Java method ctxInPlaceTrueDivide not found found !\n"); - return 1; - } - ctx->ctx_InPlaceTrueDivide = &ctx_InPlaceTrueDivide_jni; - jniMethod_ctx_InPlaceRemainder = (*env)->GetMethodID(env, clazz, "ctxInPlaceRemainder", "(JJ)J"); - if (jniMethod_ctx_InPlaceRemainder == NULL) { - LOGS("ERROR: Java method ctxInPlaceRemainder not found found !\n"); - return 1; - } - ctx->ctx_InPlaceRemainder = &ctx_InPlaceRemainder_jni; - jniMethod_ctx_InPlacePower = (*env)->GetMethodID(env, clazz, "ctxInPlacePower", "(JJJ)J"); - if (jniMethod_ctx_InPlacePower == NULL) { - LOGS("ERROR: Java method ctxInPlacePower not found found !\n"); - return 1; - } - ctx->ctx_InPlacePower = &ctx_InPlacePower_jni; - jniMethod_ctx_InPlaceLshift = (*env)->GetMethodID(env, clazz, "ctxInPlaceLshift", "(JJ)J"); - if (jniMethod_ctx_InPlaceLshift == NULL) { - LOGS("ERROR: Java method ctxInPlaceLshift not found found !\n"); - return 1; - } - ctx->ctx_InPlaceLshift = &ctx_InPlaceLshift_jni; - jniMethod_ctx_InPlaceRshift = (*env)->GetMethodID(env, clazz, "ctxInPlaceRshift", "(JJ)J"); - if (jniMethod_ctx_InPlaceRshift == NULL) { - LOGS("ERROR: Java method ctxInPlaceRshift not found found !\n"); - return 1; - } - ctx->ctx_InPlaceRshift = &ctx_InPlaceRshift_jni; - jniMethod_ctx_InPlaceAnd = (*env)->GetMethodID(env, clazz, "ctxInPlaceAnd", "(JJ)J"); - if (jniMethod_ctx_InPlaceAnd == NULL) { - LOGS("ERROR: Java method ctxInPlaceAnd not found found !\n"); - return 1; - } - ctx->ctx_InPlaceAnd = &ctx_InPlaceAnd_jni; - jniMethod_ctx_InPlaceXor = (*env)->GetMethodID(env, clazz, "ctxInPlaceXor", "(JJ)J"); - if (jniMethod_ctx_InPlaceXor == NULL) { - LOGS("ERROR: Java method ctxInPlaceXor not found found !\n"); - return 1; - } - ctx->ctx_InPlaceXor = &ctx_InPlaceXor_jni; - jniMethod_ctx_InPlaceOr = (*env)->GetMethodID(env, clazz, "ctxInPlaceOr", "(JJ)J"); - if (jniMethod_ctx_InPlaceOr == NULL) { - LOGS("ERROR: Java method ctxInPlaceOr not found found !\n"); - return 1; - } - ctx->ctx_InPlaceOr = &ctx_InPlaceOr_jni; - jniMethod_ctx_Callable_Check = (*env)->GetMethodID(env, clazz, "ctxCallableCheck", "(J)I"); - if (jniMethod_ctx_Callable_Check == NULL) { - LOGS("ERROR: Java method ctxCallableCheck not found found !\n"); - return 1; - } - ctx->ctx_Callable_Check = &ctx_Callable_Check_jni; - jniMethod_ctx_CallTupleDict = (*env)->GetMethodID(env, clazz, "ctxCallTupleDict", "(JJJ)J"); - if (jniMethod_ctx_CallTupleDict == NULL) { - LOGS("ERROR: Java method ctxCallTupleDict not found found !\n"); - return 1; - } - ctx->ctx_CallTupleDict = &ctx_CallTupleDict_jni; - jniMethod_ctx_Call = (*env)->GetMethodID(env, clazz, "ctxCall", "(JJJJ)J"); - if (jniMethod_ctx_Call == NULL) { - LOGS("ERROR: Java method ctxCall not found found !\n"); - return 1; - } - ctx->ctx_Call = &ctx_Call_jni; - jniMethod_ctx_CallMethod = (*env)->GetMethodID(env, clazz, "ctxCallMethod", "(JJJJ)J"); - if (jniMethod_ctx_CallMethod == NULL) { - LOGS("ERROR: Java method ctxCallMethod not found found !\n"); - return 1; - } - ctx->ctx_CallMethod = &ctx_CallMethod_jni; - jniMethod_ctx_FatalError = (*env)->GetMethodID(env, clazz, "ctxFatalError", "(J)V"); - if (jniMethod_ctx_FatalError == NULL) { - LOGS("ERROR: Java method ctxFatalError not found found !\n"); - return 1; - } - ctx->ctx_FatalError = &ctx_FatalError_jni; - jniMethod_ctx_Err_SetString = (*env)->GetMethodID(env, clazz, "ctxErrSetString", "(JJ)V"); - if (jniMethod_ctx_Err_SetString == NULL) { - LOGS("ERROR: Java method ctxErrSetString not found found !\n"); - return 1; - } - ctx->ctx_Err_SetString = &ctx_Err_SetString_jni; - jniMethod_ctx_Err_SetObject = (*env)->GetMethodID(env, clazz, "ctxErrSetObject", "(JJ)V"); - if (jniMethod_ctx_Err_SetObject == NULL) { - LOGS("ERROR: Java method ctxErrSetObject not found found !\n"); - return 1; - } - ctx->ctx_Err_SetObject = &ctx_Err_SetObject_jni; - jniMethod_ctx_Err_SetFromErrnoWithFilename = (*env)->GetMethodID(env, clazz, "ctxErrSetFromErrnoWithFilename", "(JJ)J"); - if (jniMethod_ctx_Err_SetFromErrnoWithFilename == NULL) { - LOGS("ERROR: Java method ctxErrSetFromErrnoWithFilename not found found !\n"); - return 1; - } - ctx->ctx_Err_SetFromErrnoWithFilename = &ctx_Err_SetFromErrnoWithFilename_jni; - jniMethod_ctx_Err_SetFromErrnoWithFilenameObjects = (*env)->GetMethodID(env, clazz, "ctxErrSetFromErrnoWithFilenameObjects", "(JJJ)V"); - if (jniMethod_ctx_Err_SetFromErrnoWithFilenameObjects == NULL) { - LOGS("ERROR: Java method ctxErrSetFromErrnoWithFilenameObjects not found found !\n"); - return 1; - } - ctx->ctx_Err_SetFromErrnoWithFilenameObjects = &ctx_Err_SetFromErrnoWithFilenameObjects_jni; - jniMethod_ctx_Err_Occurred = (*env)->GetMethodID(env, clazz, "ctxErrOccurred", "()I"); - if (jniMethod_ctx_Err_Occurred == NULL) { - LOGS("ERROR: Java method ctxErrOccurred not found found !\n"); - return 1; - } - ctx->ctx_Err_Occurred = &ctx_Err_Occurred_jni; - jniMethod_ctx_Err_ExceptionMatches = (*env)->GetMethodID(env, clazz, "ctxErrExceptionMatches", "(J)I"); - if (jniMethod_ctx_Err_ExceptionMatches == NULL) { - LOGS("ERROR: Java method ctxErrExceptionMatches not found found !\n"); - return 1; - } - ctx->ctx_Err_ExceptionMatches = &ctx_Err_ExceptionMatches_jni; - jniMethod_ctx_Err_NoMemory = (*env)->GetMethodID(env, clazz, "ctxErrNoMemory", "()V"); - if (jniMethod_ctx_Err_NoMemory == NULL) { - LOGS("ERROR: Java method ctxErrNoMemory not found found !\n"); - return 1; - } - ctx->ctx_Err_NoMemory = &ctx_Err_NoMemory_jni; - jniMethod_ctx_Err_Clear = (*env)->GetMethodID(env, clazz, "ctxErrClear", "()V"); - if (jniMethod_ctx_Err_Clear == NULL) { - LOGS("ERROR: Java method ctxErrClear not found found !\n"); - return 1; - } - ctx->ctx_Err_Clear = &ctx_Err_Clear_jni; - jniMethod_ctx_Err_NewException = (*env)->GetMethodID(env, clazz, "ctxErrNewException", "(JJJ)J"); - if (jniMethod_ctx_Err_NewException == NULL) { - LOGS("ERROR: Java method ctxErrNewException not found found !\n"); - return 1; - } - ctx->ctx_Err_NewException = &ctx_Err_NewException_jni; - jniMethod_ctx_Err_NewExceptionWithDoc = (*env)->GetMethodID(env, clazz, "ctxErrNewExceptionWithDoc", "(JJJJ)J"); - if (jniMethod_ctx_Err_NewExceptionWithDoc == NULL) { - LOGS("ERROR: Java method ctxErrNewExceptionWithDoc not found found !\n"); - return 1; - } - ctx->ctx_Err_NewExceptionWithDoc = &ctx_Err_NewExceptionWithDoc_jni; - jniMethod_ctx_Err_WarnEx = (*env)->GetMethodID(env, clazz, "ctxErrWarnEx", "(JJJ)I"); - if (jniMethod_ctx_Err_WarnEx == NULL) { - LOGS("ERROR: Java method ctxErrWarnEx not found found !\n"); - return 1; - } - ctx->ctx_Err_WarnEx = &ctx_Err_WarnEx_jni; - jniMethod_ctx_Err_WriteUnraisable = (*env)->GetMethodID(env, clazz, "ctxErrWriteUnraisable", "(J)V"); - if (jniMethod_ctx_Err_WriteUnraisable == NULL) { - LOGS("ERROR: Java method ctxErrWriteUnraisable not found found !\n"); - return 1; - } - ctx->ctx_Err_WriteUnraisable = &ctx_Err_WriteUnraisable_jni; - jniMethod_ctx_IsTrue = (*env)->GetMethodID(env, clazz, "ctxIsTrue", "(J)I"); - if (jniMethod_ctx_IsTrue == NULL) { - LOGS("ERROR: Java method ctxIsTrue not found found !\n"); - return 1; - } - ctx->ctx_IsTrue = &ctx_IsTrue_jni; - jniMethod_ctx_Type_FromSpec = (*env)->GetMethodID(env, clazz, "ctxTypeFromSpec", "(JJ)J"); - if (jniMethod_ctx_Type_FromSpec == NULL) { - LOGS("ERROR: Java method ctxTypeFromSpec not found found !\n"); - return 1; - } - ctx->ctx_Type_FromSpec = &ctx_Type_FromSpec_jni; - jniMethod_ctx_Type_GenericNew = (*env)->GetMethodID(env, clazz, "ctxTypeGenericNew", "(JJJJ)J"); - if (jniMethod_ctx_Type_GenericNew == NULL) { - LOGS("ERROR: Java method ctxTypeGenericNew not found found !\n"); - return 1; - } - ctx->ctx_Type_GenericNew = &ctx_Type_GenericNew_jni; - jniMethod_ctx_GetAttr = (*env)->GetMethodID(env, clazz, "ctxGetAttr", "(JJ)J"); - if (jniMethod_ctx_GetAttr == NULL) { - LOGS("ERROR: Java method ctxGetAttr not found found !\n"); - return 1; - } - ctx->ctx_GetAttr = &ctx_GetAttr_jni; - jniMethod_ctx_HasAttr = (*env)->GetMethodID(env, clazz, "ctxHasAttr", "(JJ)I"); - if (jniMethod_ctx_HasAttr == NULL) { - LOGS("ERROR: Java method ctxHasAttr not found found !\n"); - return 1; - } - ctx->ctx_HasAttr = &ctx_HasAttr_jni; - jniMethod_ctx_HasAttr_s = (*env)->GetMethodID(env, clazz, "ctxHasAttrs", "(JJ)I"); - if (jniMethod_ctx_HasAttr_s == NULL) { - LOGS("ERROR: Java method ctxHasAttrs not found found !\n"); - return 1; - } - ctx->ctx_HasAttr_s = &ctx_HasAttr_s_jni; - jniMethod_ctx_SetAttr = (*env)->GetMethodID(env, clazz, "ctxSetAttr", "(JJJ)I"); - if (jniMethod_ctx_SetAttr == NULL) { - LOGS("ERROR: Java method ctxSetAttr not found found !\n"); - return 1; - } - ctx->ctx_SetAttr = &ctx_SetAttr_jni; - jniMethod_ctx_SetAttr_s = (*env)->GetMethodID(env, clazz, "ctxSetAttrs", "(JJJ)I"); - if (jniMethod_ctx_SetAttr_s == NULL) { - LOGS("ERROR: Java method ctxSetAttrs not found found !\n"); - return 1; - } - ctx->ctx_SetAttr_s = &ctx_SetAttr_s_jni; - jniMethod_ctx_GetItem = (*env)->GetMethodID(env, clazz, "ctxGetItem", "(JJ)J"); - if (jniMethod_ctx_GetItem == NULL) { - LOGS("ERROR: Java method ctxGetItem not found found !\n"); - return 1; - } - ctx->ctx_GetItem = &ctx_GetItem_jni; - jniMethod_ctx_GetItem_i = (*env)->GetMethodID(env, clazz, "ctxGetItemi", "(JJ)J"); - if (jniMethod_ctx_GetItem_i == NULL) { - LOGS("ERROR: Java method ctxGetItemi not found found !\n"); - return 1; - } - ctx->ctx_GetItem_i = &ctx_GetItem_i_jni; - jniMethod_ctx_Contains = (*env)->GetMethodID(env, clazz, "ctxContains", "(JJ)I"); - if (jniMethod_ctx_Contains == NULL) { - LOGS("ERROR: Java method ctxContains not found found !\n"); - return 1; - } - ctx->ctx_Contains = &ctx_Contains_jni; - jniMethod_ctx_SetItem = (*env)->GetMethodID(env, clazz, "ctxSetItem", "(JJJ)I"); - if (jniMethod_ctx_SetItem == NULL) { - LOGS("ERROR: Java method ctxSetItem not found found !\n"); - return 1; - } - ctx->ctx_SetItem = &ctx_SetItem_jni; - jniMethod_ctx_SetItem_i = (*env)->GetMethodID(env, clazz, "ctxSetItemi", "(JJJ)I"); - if (jniMethod_ctx_SetItem_i == NULL) { - LOGS("ERROR: Java method ctxSetItemi not found found !\n"); - return 1; - } - ctx->ctx_SetItem_i = &ctx_SetItem_i_jni; - jniMethod_ctx_DelItem = (*env)->GetMethodID(env, clazz, "ctxDelItem", "(JJ)I"); - if (jniMethod_ctx_DelItem == NULL) { - LOGS("ERROR: Java method ctxDelItem not found found !\n"); - return 1; - } - ctx->ctx_DelItem = &ctx_DelItem_jni; - jniMethod_ctx_DelItem_i = (*env)->GetMethodID(env, clazz, "ctxDelItemi", "(JJ)I"); - if (jniMethod_ctx_DelItem_i == NULL) { - LOGS("ERROR: Java method ctxDelItemi not found found !\n"); - return 1; - } - ctx->ctx_DelItem_i = &ctx_DelItem_i_jni; - jniMethod_ctx_DelItem_s = (*env)->GetMethodID(env, clazz, "ctxDelItems", "(JJ)I"); - if (jniMethod_ctx_DelItem_s == NULL) { - LOGS("ERROR: Java method ctxDelItems not found found !\n"); - return 1; - } - ctx->ctx_DelItem_s = &ctx_DelItem_s_jni; - jniMethod_ctx_Type = (*env)->GetMethodID(env, clazz, "ctxType", "(J)J"); - if (jniMethod_ctx_Type == NULL) { - LOGS("ERROR: Java method ctxType not found found !\n"); - return 1; - } - ctx->ctx_Type = &ctx_Type_jni; - jniMethod_ctx_TypeCheck = (*env)->GetMethodID(env, clazz, "ctxTypeCheck", "(JJ)I"); - if (jniMethod_ctx_TypeCheck == NULL) { - LOGS("ERROR: Java method ctxTypeCheck not found found !\n"); - return 1; - } - ctx->ctx_TypeCheck = &ctx_TypeCheck_jni; - jniMethod_ctx_Type_GetName = (*env)->GetMethodID(env, clazz, "ctxTypeGetName", "(J)J"); - if (jniMethod_ctx_Type_GetName == NULL) { - LOGS("ERROR: Java method ctxTypeGetName not found found !\n"); - return 1; - } - ctx->ctx_Type_GetName = &ctx_Type_GetName_jni; - jniMethod_ctx_Type_IsSubtype = (*env)->GetMethodID(env, clazz, "ctxTypeIsSubtype", "(JJ)I"); - if (jniMethod_ctx_Type_IsSubtype == NULL) { - LOGS("ERROR: Java method ctxTypeIsSubtype not found found !\n"); - return 1; - } - ctx->ctx_Type_IsSubtype = &ctx_Type_IsSubtype_jni; - jniMethod_ctx_Is = (*env)->GetMethodID(env, clazz, "ctxIs", "(JJ)I"); - if (jniMethod_ctx_Is == NULL) { - LOGS("ERROR: Java method ctxIs not found found !\n"); - return 1; - } - ctx->ctx_Is = &ctx_Is_jni; - jniMethod_ctx_AsStruct_Object = (*env)->GetMethodID(env, clazz, "ctxAsStructObject", "(J)J"); - if (jniMethod_ctx_AsStruct_Object == NULL) { - LOGS("ERROR: Java method ctxAsStructObject not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Object = &ctx_AsStruct_Object_jni; - jniMethod_ctx_AsStruct_Legacy = (*env)->GetMethodID(env, clazz, "ctxAsStructLegacy", "(J)J"); - if (jniMethod_ctx_AsStruct_Legacy == NULL) { - LOGS("ERROR: Java method ctxAsStructLegacy not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Legacy = &ctx_AsStruct_Legacy_jni; - jniMethod_ctx_AsStruct_Type = (*env)->GetMethodID(env, clazz, "ctxAsStructType", "(J)J"); - if (jniMethod_ctx_AsStruct_Type == NULL) { - LOGS("ERROR: Java method ctxAsStructType not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Type = &ctx_AsStruct_Type_jni; - jniMethod_ctx_AsStruct_Long = (*env)->GetMethodID(env, clazz, "ctxAsStructLong", "(J)J"); - if (jniMethod_ctx_AsStruct_Long == NULL) { - LOGS("ERROR: Java method ctxAsStructLong not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Long = &ctx_AsStruct_Long_jni; - jniMethod_ctx_AsStruct_Float = (*env)->GetMethodID(env, clazz, "ctxAsStructFloat", "(J)J"); - if (jniMethod_ctx_AsStruct_Float == NULL) { - LOGS("ERROR: Java method ctxAsStructFloat not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Float = &ctx_AsStruct_Float_jni; - jniMethod_ctx_AsStruct_Unicode = (*env)->GetMethodID(env, clazz, "ctxAsStructUnicode", "(J)J"); - if (jniMethod_ctx_AsStruct_Unicode == NULL) { - LOGS("ERROR: Java method ctxAsStructUnicode not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Unicode = &ctx_AsStruct_Unicode_jni; - jniMethod_ctx_AsStruct_Tuple = (*env)->GetMethodID(env, clazz, "ctxAsStructTuple", "(J)J"); - if (jniMethod_ctx_AsStruct_Tuple == NULL) { - LOGS("ERROR: Java method ctxAsStructTuple not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_Tuple = &ctx_AsStruct_Tuple_jni; - jniMethod_ctx_AsStruct_List = (*env)->GetMethodID(env, clazz, "ctxAsStructList", "(J)J"); - if (jniMethod_ctx_AsStruct_List == NULL) { - LOGS("ERROR: Java method ctxAsStructList not found found !\n"); - return 1; - } - ctx->ctx_AsStruct_List = &ctx_AsStruct_List_jni; - jniMethod_ctx_Type_GetBuiltinShape = (*env)->GetMethodID(env, clazz, "ctxTypeGetBuiltinShape", "(J)I"); - if (jniMethod_ctx_Type_GetBuiltinShape == NULL) { - LOGS("ERROR: Java method ctxTypeGetBuiltinShape not found found !\n"); - return 1; - } - ctx->ctx_Type_GetBuiltinShape = &ctx_Type_GetBuiltinShape_jni; - jniMethod_ctx_New = (*env)->GetMethodID(env, clazz, "ctxNew", "(JJ)J"); - if (jniMethod_ctx_New == NULL) { - LOGS("ERROR: Java method ctxNew not found found !\n"); - return 1; - } - ctx->ctx_New = &ctx_New_jni; - jniMethod_ctx_Repr = (*env)->GetMethodID(env, clazz, "ctxRepr", "(J)J"); - if (jniMethod_ctx_Repr == NULL) { - LOGS("ERROR: Java method ctxRepr not found found !\n"); - return 1; - } - ctx->ctx_Repr = &ctx_Repr_jni; - jniMethod_ctx_Str = (*env)->GetMethodID(env, clazz, "ctxStr", "(J)J"); - if (jniMethod_ctx_Str == NULL) { - LOGS("ERROR: Java method ctxStr not found found !\n"); - return 1; - } - ctx->ctx_Str = &ctx_Str_jni; - jniMethod_ctx_ASCII = (*env)->GetMethodID(env, clazz, "ctxASCII", "(J)J"); - if (jniMethod_ctx_ASCII == NULL) { - LOGS("ERROR: Java method ctxASCII not found found !\n"); - return 1; - } - ctx->ctx_ASCII = &ctx_ASCII_jni; - jniMethod_ctx_Bytes = (*env)->GetMethodID(env, clazz, "ctxBytes", "(J)J"); - if (jniMethod_ctx_Bytes == NULL) { - LOGS("ERROR: Java method ctxBytes not found found !\n"); - return 1; - } - ctx->ctx_Bytes = &ctx_Bytes_jni; - jniMethod_ctx_RichCompare = (*env)->GetMethodID(env, clazz, "ctxRichCompare", "(JJI)J"); - if (jniMethod_ctx_RichCompare == NULL) { - LOGS("ERROR: Java method ctxRichCompare not found found !\n"); - return 1; - } - ctx->ctx_RichCompare = &ctx_RichCompare_jni; - jniMethod_ctx_RichCompareBool = (*env)->GetMethodID(env, clazz, "ctxRichCompareBool", "(JJI)I"); - if (jniMethod_ctx_RichCompareBool == NULL) { - LOGS("ERROR: Java method ctxRichCompareBool not found found !\n"); - return 1; - } - ctx->ctx_RichCompareBool = &ctx_RichCompareBool_jni; - jniMethod_ctx_Hash = (*env)->GetMethodID(env, clazz, "ctxHash", "(J)J"); - if (jniMethod_ctx_Hash == NULL) { - LOGS("ERROR: Java method ctxHash not found found !\n"); - return 1; - } - ctx->ctx_Hash = &ctx_Hash_jni; - jniMethod_ctx_Bytes_Check = (*env)->GetMethodID(env, clazz, "ctxBytesCheck", "(J)I"); - if (jniMethod_ctx_Bytes_Check == NULL) { - LOGS("ERROR: Java method ctxBytesCheck not found found !\n"); - return 1; - } - ctx->ctx_Bytes_Check = &ctx_Bytes_Check_jni; - jniMethod_ctx_Bytes_Size = (*env)->GetMethodID(env, clazz, "ctxBytesSize", "(J)J"); - if (jniMethod_ctx_Bytes_Size == NULL) { - LOGS("ERROR: Java method ctxBytesSize not found found !\n"); - return 1; - } - ctx->ctx_Bytes_Size = &ctx_Bytes_Size_jni; - jniMethod_ctx_Bytes_GET_SIZE = (*env)->GetMethodID(env, clazz, "ctxBytesGETSIZE", "(J)J"); - if (jniMethod_ctx_Bytes_GET_SIZE == NULL) { - LOGS("ERROR: Java method ctxBytesGETSIZE not found found !\n"); - return 1; - } - ctx->ctx_Bytes_GET_SIZE = &ctx_Bytes_GET_SIZE_jni; - jniMethod_ctx_Bytes_AsString = (*env)->GetMethodID(env, clazz, "ctxBytesAsString", "(J)J"); - if (jniMethod_ctx_Bytes_AsString == NULL) { - LOGS("ERROR: Java method ctxBytesAsString not found found !\n"); - return 1; - } - ctx->ctx_Bytes_AsString = &ctx_Bytes_AsString_jni; - jniMethod_ctx_Bytes_AS_STRING = (*env)->GetMethodID(env, clazz, "ctxBytesASSTRING", "(J)J"); - if (jniMethod_ctx_Bytes_AS_STRING == NULL) { - LOGS("ERROR: Java method ctxBytesASSTRING not found found !\n"); - return 1; - } - ctx->ctx_Bytes_AS_STRING = &ctx_Bytes_AS_STRING_jni; - jniMethod_ctx_Bytes_FromString = (*env)->GetMethodID(env, clazz, "ctxBytesFromString", "(J)J"); - if (jniMethod_ctx_Bytes_FromString == NULL) { - LOGS("ERROR: Java method ctxBytesFromString not found found !\n"); - return 1; - } - ctx->ctx_Bytes_FromString = &ctx_Bytes_FromString_jni; - jniMethod_ctx_Bytes_FromStringAndSize = (*env)->GetMethodID(env, clazz, "ctxBytesFromStringAndSize", "(JJ)J"); - if (jniMethod_ctx_Bytes_FromStringAndSize == NULL) { - LOGS("ERROR: Java method ctxBytesFromStringAndSize not found found !\n"); - return 1; - } - ctx->ctx_Bytes_FromStringAndSize = &ctx_Bytes_FromStringAndSize_jni; - jniMethod_ctx_Unicode_FromString = (*env)->GetMethodID(env, clazz, "ctxUnicodeFromString", "(J)J"); - if (jniMethod_ctx_Unicode_FromString == NULL) { - LOGS("ERROR: Java method ctxUnicodeFromString not found found !\n"); - return 1; - } - ctx->ctx_Unicode_FromString = &ctx_Unicode_FromString_jni; - jniMethod_ctx_Unicode_Check = (*env)->GetMethodID(env, clazz, "ctxUnicodeCheck", "(J)I"); - if (jniMethod_ctx_Unicode_Check == NULL) { - LOGS("ERROR: Java method ctxUnicodeCheck not found found !\n"); - return 1; - } - ctx->ctx_Unicode_Check = &ctx_Unicode_Check_jni; - jniMethod_ctx_Unicode_AsASCIIString = (*env)->GetMethodID(env, clazz, "ctxUnicodeAsASCIIString", "(J)J"); - if (jniMethod_ctx_Unicode_AsASCIIString == NULL) { - LOGS("ERROR: Java method ctxUnicodeAsASCIIString not found found !\n"); - return 1; - } - ctx->ctx_Unicode_AsASCIIString = &ctx_Unicode_AsASCIIString_jni; - jniMethod_ctx_Unicode_AsLatin1String = (*env)->GetMethodID(env, clazz, "ctxUnicodeAsLatin1String", "(J)J"); - if (jniMethod_ctx_Unicode_AsLatin1String == NULL) { - LOGS("ERROR: Java method ctxUnicodeAsLatin1String not found found !\n"); - return 1; - } - ctx->ctx_Unicode_AsLatin1String = &ctx_Unicode_AsLatin1String_jni; - jniMethod_ctx_Unicode_AsUTF8String = (*env)->GetMethodID(env, clazz, "ctxUnicodeAsUTF8String", "(J)J"); - if (jniMethod_ctx_Unicode_AsUTF8String == NULL) { - LOGS("ERROR: Java method ctxUnicodeAsUTF8String not found found !\n"); - return 1; - } - ctx->ctx_Unicode_AsUTF8String = &ctx_Unicode_AsUTF8String_jni; - jniMethod_ctx_Unicode_AsUTF8AndSize = (*env)->GetMethodID(env, clazz, "ctxUnicodeAsUTF8AndSize", "(JJ)J"); - if (jniMethod_ctx_Unicode_AsUTF8AndSize == NULL) { - LOGS("ERROR: Java method ctxUnicodeAsUTF8AndSize not found found !\n"); - return 1; - } - ctx->ctx_Unicode_AsUTF8AndSize = &ctx_Unicode_AsUTF8AndSize_jni; - jniMethod_ctx_Unicode_FromWideChar = (*env)->GetMethodID(env, clazz, "ctxUnicodeFromWideChar", "(JJ)J"); - if (jniMethod_ctx_Unicode_FromWideChar == NULL) { - LOGS("ERROR: Java method ctxUnicodeFromWideChar not found found !\n"); - return 1; - } - ctx->ctx_Unicode_FromWideChar = &ctx_Unicode_FromWideChar_jni; - jniMethod_ctx_Unicode_DecodeFSDefault = (*env)->GetMethodID(env, clazz, "ctxUnicodeDecodeFSDefault", "(J)J"); - if (jniMethod_ctx_Unicode_DecodeFSDefault == NULL) { - LOGS("ERROR: Java method ctxUnicodeDecodeFSDefault not found found !\n"); - return 1; - } - ctx->ctx_Unicode_DecodeFSDefault = &ctx_Unicode_DecodeFSDefault_jni; - jniMethod_ctx_Unicode_DecodeFSDefaultAndSize = (*env)->GetMethodID(env, clazz, "ctxUnicodeDecodeFSDefaultAndSize", "(JJ)J"); - if (jniMethod_ctx_Unicode_DecodeFSDefaultAndSize == NULL) { - LOGS("ERROR: Java method ctxUnicodeDecodeFSDefaultAndSize not found found !\n"); - return 1; - } - ctx->ctx_Unicode_DecodeFSDefaultAndSize = &ctx_Unicode_DecodeFSDefaultAndSize_jni; - jniMethod_ctx_Unicode_EncodeFSDefault = (*env)->GetMethodID(env, clazz, "ctxUnicodeEncodeFSDefault", "(J)J"); - if (jniMethod_ctx_Unicode_EncodeFSDefault == NULL) { - LOGS("ERROR: Java method ctxUnicodeEncodeFSDefault not found found !\n"); - return 1; - } - ctx->ctx_Unicode_EncodeFSDefault = &ctx_Unicode_EncodeFSDefault_jni; - jniMethod_ctx_Unicode_ReadChar = (*env)->GetMethodID(env, clazz, "ctxUnicodeReadChar", "(JJ)I"); - if (jniMethod_ctx_Unicode_ReadChar == NULL) { - LOGS("ERROR: Java method ctxUnicodeReadChar not found found !\n"); - return 1; - } - ctx->ctx_Unicode_ReadChar = &ctx_Unicode_ReadChar_jni; - jniMethod_ctx_Unicode_DecodeASCII = (*env)->GetMethodID(env, clazz, "ctxUnicodeDecodeASCII", "(JJJ)J"); - if (jniMethod_ctx_Unicode_DecodeASCII == NULL) { - LOGS("ERROR: Java method ctxUnicodeDecodeASCII not found found !\n"); - return 1; - } - ctx->ctx_Unicode_DecodeASCII = &ctx_Unicode_DecodeASCII_jni; - jniMethod_ctx_Unicode_DecodeLatin1 = (*env)->GetMethodID(env, clazz, "ctxUnicodeDecodeLatin1", "(JJJ)J"); - if (jniMethod_ctx_Unicode_DecodeLatin1 == NULL) { - LOGS("ERROR: Java method ctxUnicodeDecodeLatin1 not found found !\n"); - return 1; - } - ctx->ctx_Unicode_DecodeLatin1 = &ctx_Unicode_DecodeLatin1_jni; - jniMethod_ctx_Unicode_FromEncodedObject = (*env)->GetMethodID(env, clazz, "ctxUnicodeFromEncodedObject", "(JJJ)J"); - if (jniMethod_ctx_Unicode_FromEncodedObject == NULL) { - LOGS("ERROR: Java method ctxUnicodeFromEncodedObject not found found !\n"); - return 1; - } - ctx->ctx_Unicode_FromEncodedObject = &ctx_Unicode_FromEncodedObject_jni; - jniMethod_ctx_Unicode_Substring = (*env)->GetMethodID(env, clazz, "ctxUnicodeSubstring", "(JJJ)J"); - if (jniMethod_ctx_Unicode_Substring == NULL) { - LOGS("ERROR: Java method ctxUnicodeSubstring not found found !\n"); - return 1; - } - ctx->ctx_Unicode_Substring = &ctx_Unicode_Substring_jni; - jniMethod_ctx_List_Check = (*env)->GetMethodID(env, clazz, "ctxListCheck", "(J)I"); - if (jniMethod_ctx_List_Check == NULL) { - LOGS("ERROR: Java method ctxListCheck not found found !\n"); - return 1; - } - ctx->ctx_List_Check = &ctx_List_Check_jni; - jniMethod_ctx_List_New = (*env)->GetMethodID(env, clazz, "ctxListNew", "(J)J"); - if (jniMethod_ctx_List_New == NULL) { - LOGS("ERROR: Java method ctxListNew not found found !\n"); - return 1; - } - ctx->ctx_List_New = &ctx_List_New_jni; - jniMethod_ctx_List_Append = (*env)->GetMethodID(env, clazz, "ctxListAppend", "(JJ)I"); - if (jniMethod_ctx_List_Append == NULL) { - LOGS("ERROR: Java method ctxListAppend not found found !\n"); - return 1; - } - ctx->ctx_List_Append = &ctx_List_Append_jni; - jniMethod_ctx_Dict_Check = (*env)->GetMethodID(env, clazz, "ctxDictCheck", "(J)I"); - if (jniMethod_ctx_Dict_Check == NULL) { - LOGS("ERROR: Java method ctxDictCheck not found found !\n"); - return 1; - } - ctx->ctx_Dict_Check = &ctx_Dict_Check_jni; - jniMethod_ctx_Dict_New = (*env)->GetMethodID(env, clazz, "ctxDictNew", "()J"); - if (jniMethod_ctx_Dict_New == NULL) { - LOGS("ERROR: Java method ctxDictNew not found found !\n"); - return 1; - } - ctx->ctx_Dict_New = &ctx_Dict_New_jni; - jniMethod_ctx_Dict_Keys = (*env)->GetMethodID(env, clazz, "ctxDictKeys", "(J)J"); - if (jniMethod_ctx_Dict_Keys == NULL) { - LOGS("ERROR: Java method ctxDictKeys not found found !\n"); - return 1; - } - ctx->ctx_Dict_Keys = &ctx_Dict_Keys_jni; - jniMethod_ctx_Dict_Copy = (*env)->GetMethodID(env, clazz, "ctxDictCopy", "(J)J"); - if (jniMethod_ctx_Dict_Copy == NULL) { - LOGS("ERROR: Java method ctxDictCopy not found found !\n"); - return 1; - } - ctx->ctx_Dict_Copy = &ctx_Dict_Copy_jni; - jniMethod_ctx_Tuple_Check = (*env)->GetMethodID(env, clazz, "ctxTupleCheck", "(J)I"); - if (jniMethod_ctx_Tuple_Check == NULL) { - LOGS("ERROR: Java method ctxTupleCheck not found found !\n"); - return 1; - } - ctx->ctx_Tuple_Check = &ctx_Tuple_Check_jni; - jniMethod_ctx_Slice_Unpack = (*env)->GetMethodID(env, clazz, "ctxSliceUnpack", "(JJJJ)I"); - if (jniMethod_ctx_Slice_Unpack == NULL) { - LOGS("ERROR: Java method ctxSliceUnpack not found found !\n"); - return 1; - } - ctx->ctx_Slice_Unpack = &ctx_Slice_Unpack_jni; - jniMethod_ctx_Import_ImportModule = (*env)->GetMethodID(env, clazz, "ctxImportImportModule", "(J)J"); - if (jniMethod_ctx_Import_ImportModule == NULL) { - LOGS("ERROR: Java method ctxImportImportModule not found found !\n"); - return 1; - } - ctx->ctx_Import_ImportModule = &ctx_Import_ImportModule_jni; - jniMethod_ctx_Capsule_New = (*env)->GetMethodID(env, clazz, "ctxCapsuleNew", "(JJJ)J"); - if (jniMethod_ctx_Capsule_New == NULL) { - LOGS("ERROR: Java method ctxCapsuleNew not found found !\n"); - return 1; - } - ctx->ctx_Capsule_New = &ctx_Capsule_New_jni; - jniMethod_ctx_Capsule_Get = (*env)->GetMethodID(env, clazz, "ctxCapsuleGet", "(JIJ)J"); - if (jniMethod_ctx_Capsule_Get == NULL) { - LOGS("ERROR: Java method ctxCapsuleGet not found found !\n"); - return 1; - } - ctx->ctx_Capsule_Get = &ctx_Capsule_Get_jni; - jniMethod_ctx_Capsule_IsValid = (*env)->GetMethodID(env, clazz, "ctxCapsuleIsValid", "(JJ)I"); - if (jniMethod_ctx_Capsule_IsValid == NULL) { - LOGS("ERROR: Java method ctxCapsuleIsValid not found found !\n"); - return 1; - } - ctx->ctx_Capsule_IsValid = &ctx_Capsule_IsValid_jni; - jniMethod_ctx_Capsule_Set = (*env)->GetMethodID(env, clazz, "ctxCapsuleSet", "(JIJ)I"); - if (jniMethod_ctx_Capsule_Set == NULL) { - LOGS("ERROR: Java method ctxCapsuleSet not found found !\n"); - return 1; - } - ctx->ctx_Capsule_Set = &ctx_Capsule_Set_jni; - jniMethod_ctx_FromPyObject = (*env)->GetMethodID(env, clazz, "ctxFromPyObject", "(J)J"); - if (jniMethod_ctx_FromPyObject == NULL) { - LOGS("ERROR: Java method ctxFromPyObject not found found !\n"); - return 1; - } - ctx->ctx_FromPyObject = &ctx_FromPyObject_jni; - jniMethod_ctx_AsPyObject = (*env)->GetMethodID(env, clazz, "ctxAsPyObject", "(J)J"); - if (jniMethod_ctx_AsPyObject == NULL) { - LOGS("ERROR: Java method ctxAsPyObject not found found !\n"); - return 1; - } - ctx->ctx_AsPyObject = &ctx_AsPyObject_jni; - jniMethod_ctx_ListBuilder_New = (*env)->GetMethodID(env, clazz, "ctxListBuilderNew", "(J)J"); - if (jniMethod_ctx_ListBuilder_New == NULL) { - LOGS("ERROR: Java method ctxListBuilderNew not found found !\n"); - return 1; - } - ctx->ctx_ListBuilder_New = &ctx_ListBuilder_New_jni; - jniMethod_ctx_ListBuilder_Set = (*env)->GetMethodID(env, clazz, "ctxListBuilderSet", "(JJJ)V"); - if (jniMethod_ctx_ListBuilder_Set == NULL) { - LOGS("ERROR: Java method ctxListBuilderSet not found found !\n"); - return 1; - } - ctx->ctx_ListBuilder_Set = &ctx_ListBuilder_Set_jni; - jniMethod_ctx_ListBuilder_Build = (*env)->GetMethodID(env, clazz, "ctxListBuilderBuild", "(J)J"); - if (jniMethod_ctx_ListBuilder_Build == NULL) { - LOGS("ERROR: Java method ctxListBuilderBuild not found found !\n"); - return 1; - } - ctx->ctx_ListBuilder_Build = &ctx_ListBuilder_Build_jni; - jniMethod_ctx_ListBuilder_Cancel = (*env)->GetMethodID(env, clazz, "ctxListBuilderCancel", "(J)V"); - if (jniMethod_ctx_ListBuilder_Cancel == NULL) { - LOGS("ERROR: Java method ctxListBuilderCancel not found found !\n"); - return 1; - } - ctx->ctx_ListBuilder_Cancel = &ctx_ListBuilder_Cancel_jni; - jniMethod_ctx_TupleBuilder_New = (*env)->GetMethodID(env, clazz, "ctxTupleBuilderNew", "(J)J"); - if (jniMethod_ctx_TupleBuilder_New == NULL) { - LOGS("ERROR: Java method ctxTupleBuilderNew not found found !\n"); - return 1; - } - ctx->ctx_TupleBuilder_New = &ctx_TupleBuilder_New_jni; - jniMethod_ctx_TupleBuilder_Set = (*env)->GetMethodID(env, clazz, "ctxTupleBuilderSet", "(JJJ)V"); - if (jniMethod_ctx_TupleBuilder_Set == NULL) { - LOGS("ERROR: Java method ctxTupleBuilderSet not found found !\n"); - return 1; - } - ctx->ctx_TupleBuilder_Set = &ctx_TupleBuilder_Set_jni; - jniMethod_ctx_TupleBuilder_Build = (*env)->GetMethodID(env, clazz, "ctxTupleBuilderBuild", "(J)J"); - if (jniMethod_ctx_TupleBuilder_Build == NULL) { - LOGS("ERROR: Java method ctxTupleBuilderBuild not found found !\n"); - return 1; - } - ctx->ctx_TupleBuilder_Build = &ctx_TupleBuilder_Build_jni; - jniMethod_ctx_TupleBuilder_Cancel = (*env)->GetMethodID(env, clazz, "ctxTupleBuilderCancel", "(J)V"); - if (jniMethod_ctx_TupleBuilder_Cancel == NULL) { - LOGS("ERROR: Java method ctxTupleBuilderCancel not found found !\n"); - return 1; - } - ctx->ctx_TupleBuilder_Cancel = &ctx_TupleBuilder_Cancel_jni; - jniMethod_ctx_Field_Load = (*env)->GetMethodID(env, clazz, "ctxFieldLoad", "(JJ)J"); - if (jniMethod_ctx_Field_Load == NULL) { - LOGS("ERROR: Java method ctxFieldLoad not found found !\n"); - return 1; - } - ctx->ctx_Field_Load = &ctx_Field_Load_jni; - jniMethod_ctx_ReenterPythonExecution = (*env)->GetMethodID(env, clazz, "ctxReenterPythonExecution", "(J)V"); - if (jniMethod_ctx_ReenterPythonExecution == NULL) { - LOGS("ERROR: Java method ctxReenterPythonExecution not found found !\n"); - return 1; - } - ctx->ctx_ReenterPythonExecution = &ctx_ReenterPythonExecution_jni; - jniMethod_ctx_LeavePythonExecution = (*env)->GetMethodID(env, clazz, "ctxLeavePythonExecution", "()J"); - if (jniMethod_ctx_LeavePythonExecution == NULL) { - LOGS("ERROR: Java method ctxLeavePythonExecution not found found !\n"); - return 1; - } - ctx->ctx_LeavePythonExecution = &ctx_LeavePythonExecution_jni; - jniMethod_ctx_Global_Load = (*env)->GetMethodID(env, clazz, "ctxGlobalLoad", "(J)J"); - if (jniMethod_ctx_Global_Load == NULL) { - LOGS("ERROR: Java method ctxGlobalLoad not found found !\n"); - return 1; - } - ctx->ctx_Global_Load = &ctx_Global_Load_jni; - jniMethod_ctx_Dump = (*env)->GetMethodID(env, clazz, "ctxDump", "(J)V"); - if (jniMethod_ctx_Dump == NULL) { - LOGS("ERROR: Java method ctxDump not found found !\n"); - return 1; - } - ctx->ctx_Dump = &ctx_Dump_jni; - jniMethod_ctx_Compile_s = (*env)->GetMethodID(env, clazz, "ctxCompiles", "(JJI)J"); - if (jniMethod_ctx_Compile_s == NULL) { - LOGS("ERROR: Java method ctxCompiles not found found !\n"); - return 1; - } - ctx->ctx_Compile_s = &ctx_Compile_s_jni; - jniMethod_ctx_EvalCode = (*env)->GetMethodID(env, clazz, "ctxEvalCode", "(JJJ)J"); - if (jniMethod_ctx_EvalCode == NULL) { - LOGS("ERROR: Java method ctxEvalCode not found found !\n"); - return 1; - } - ctx->ctx_EvalCode = &ctx_EvalCode_jni; - jniMethod_ctx_ContextVar_New = (*env)->GetMethodID(env, clazz, "ctxContextVarNew", "(JJ)J"); - if (jniMethod_ctx_ContextVar_New == NULL) { - LOGS("ERROR: Java method ctxContextVarNew not found found !\n"); - return 1; - } - ctx->ctx_ContextVar_New = &ctx_ContextVar_New_jni; - jniMethod_ctx_ContextVar_Set = (*env)->GetMethodID(env, clazz, "ctxContextVarSet", "(JJ)J"); - if (jniMethod_ctx_ContextVar_Set == NULL) { - LOGS("ERROR: Java method ctxContextVarSet not found found !\n"); - return 1; - } - ctx->ctx_ContextVar_Set = &ctx_ContextVar_Set_jni; - jniMethod_ctx_SetCallFunction = (*env)->GetMethodID(env, clazz, "ctxSetCallFunction", "(JJ)I"); - if (jniMethod_ctx_SetCallFunction == NULL) { - LOGS("ERROR: Java method ctxSetCallFunction not found found !\n"); - return 1; - } - ctx->ctx_SetCallFunction = &ctx_SetCallFunction_jni; - return 0; -} - -static HPy ctx_Dup_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Dup, HPY_UP(h)); -} - -static void ctx_Close_jni(HPyContext *ctx, HPy h) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Close, HPY_UP(h)); -} - -static HPy ctx_Long_FromInt32_t_jni(HPyContext *ctx, int32_t value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromInt32_t, INT32_UP(value)); -} - -static HPy ctx_Long_FromUInt32_t_jni(HPyContext *ctx, uint32_t value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromUInt32_t, UINT32_UP(value)); -} - -static HPy ctx_Long_FromInt64_t_jni(HPyContext *ctx, int64_t v) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromInt64_t, LONG_UP(v)); -} - -static HPy ctx_Long_FromUInt64_t_jni(HPyContext *ctx, uint64_t v) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromUInt64_t, LONG_UP(v)); -} - -static HPy ctx_Long_FromSize_t_jni(HPyContext *ctx, size_t value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromSize_t, LONG_UP(value)); -} - -static HPy ctx_Long_FromSsize_t_jni(HPyContext *ctx, HPy_ssize_t value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long_FromSsize_t, SIZE_T_UP(value)); -} - -static int32_t ctx_Long_AsInt32_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT32_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsInt32_t, HPY_UP(h)); -} - -static uint32_t ctx_Long_AsUInt32_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_UINT32_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsUInt32_t, HPY_UP(h)); -} - -static uint32_t ctx_Long_AsUInt32_tMask_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_UINT32_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsUInt32_tMask, HPY_UP(h)); -} - -static int64_t ctx_Long_AsInt64_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT64_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsInt64_t, HPY_UP(h)); -} - -static uint64_t ctx_Long_AsUInt64_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_UINT64_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsUInt64_t, HPY_UP(h)); -} - -static uint64_t ctx_Long_AsUInt64_tMask_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_UINT64_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsUInt64_tMask, HPY_UP(h)); -} - -static size_t ctx_Long_AsSize_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_SIZE_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsSize_t, HPY_UP(h)); -} - -static HPy_ssize_t ctx_Long_AsSsize_t_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY_SSIZE_T(CONTEXT_INSTANCE(ctx), ctx_Long_AsSsize_t, HPY_UP(h)); -} - -static void *ctx_Long_AsVoidPtr_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Long_AsVoidPtr, HPY_UP(h)); -} - -static double ctx_Long_AsDouble_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_DOUBLE(CONTEXT_INSTANCE(ctx), ctx_Long_AsDouble, HPY_UP(h)); -} - -static HPy ctx_Float_FromDouble_jni(HPyContext *ctx, double v) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Float_FromDouble, DOUBLE_UP(v)); -} - -static double ctx_Float_AsDouble_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_DOUBLE(CONTEXT_INSTANCE(ctx), ctx_Float_AsDouble, HPY_UP(h)); -} - -static HPy ctx_Bool_FromBool_jni(HPyContext *ctx, bool v) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Bool_FromBool, LONG_UP(v)); -} - -static HPy_ssize_t ctx_Length_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY_SSIZE_T(CONTEXT_INSTANCE(ctx), ctx_Length, HPY_UP(h)); -} - -static int ctx_Number_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Number_Check, HPY_UP(h)); -} - -static HPy ctx_Add_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Add, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Subtract_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Subtract, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Multiply_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Multiply, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_MatrixMultiply_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_MatrixMultiply, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_FloorDivide_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_FloorDivide, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_TrueDivide_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_TrueDivide, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Remainder_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Remainder, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Divmod_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Divmod, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Power_jni(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Power, HPY_UP(h1), HPY_UP(h2), HPY_UP(h3)); -} - -static HPy ctx_Negative_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Negative, HPY_UP(h1)); -} - -static HPy ctx_Positive_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Positive, HPY_UP(h1)); -} - -static HPy ctx_Absolute_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Absolute, HPY_UP(h1)); -} - -static HPy ctx_Invert_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Invert, HPY_UP(h1)); -} - -static HPy ctx_Lshift_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Lshift, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Rshift_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Rshift, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_And_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_And, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Xor_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Xor, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Or_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Or, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_Index_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Index, HPY_UP(h1)); -} - -static HPy ctx_Long_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Long, HPY_UP(h1)); -} - -static HPy ctx_Float_jni(HPyContext *ctx, HPy h1) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Float, HPY_UP(h1)); -} - -static HPy ctx_InPlaceAdd_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceAdd, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceSubtract_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceSubtract, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceMultiply_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceMultiply, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceMatrixMultiply_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceMatrixMultiply, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceFloorDivide_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceFloorDivide, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceTrueDivide_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceTrueDivide, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceRemainder_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceRemainder, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlacePower_jni(HPyContext *ctx, HPy h1, HPy h2, HPy h3) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlacePower, HPY_UP(h1), HPY_UP(h2), HPY_UP(h3)); -} - -static HPy ctx_InPlaceLshift_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceLshift, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceRshift_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceRshift, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceAnd_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceAnd, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceXor_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceXor, HPY_UP(h1), HPY_UP(h2)); -} - -static HPy ctx_InPlaceOr_jni(HPyContext *ctx, HPy h1, HPy h2) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_InPlaceOr, HPY_UP(h1), HPY_UP(h2)); -} - -static int ctx_Callable_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Callable_Check, HPY_UP(h)); -} - -static HPy ctx_CallTupleDict_jni(HPyContext *ctx, HPy callable, HPy args, HPy kw) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_CallTupleDict, HPY_UP(callable), HPY_UP(args), HPY_UP(kw)); -} - -static HPy ctx_Call_jni(HPyContext *ctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Call, HPY_UP(callable), PTR_UP(args), LONG_UP(nargs), HPY_UP(kwnames)); -} - -static HPy ctx_CallMethod_jni(HPyContext *ctx, HPy name, const HPy *args, size_t nargs, HPy kwnames) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_CallMethod, HPY_UP(name), PTR_UP(args), LONG_UP(nargs), HPY_UP(kwnames)); -} - -static void ctx_FatalError_jni(HPyContext *ctx, const char *message) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_FatalError, PTR_UP(message)); -} - -static void ctx_Err_SetString_jni(HPyContext *ctx, HPy h_type, const char *utf8_message) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Err_SetString, HPY_UP(h_type), PTR_UP(utf8_message)); -} - -static void ctx_Err_SetObject_jni(HPyContext *ctx, HPy h_type, HPy h_value) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Err_SetObject, HPY_UP(h_type), HPY_UP(h_value)); -} - -static HPy ctx_Err_SetFromErrnoWithFilename_jni(HPyContext *ctx, HPy h_type, const char *filename_fsencoded) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Err_SetFromErrnoWithFilename, HPY_UP(h_type), PTR_UP(filename_fsencoded)); -} - -static void ctx_Err_SetFromErrnoWithFilenameObjects_jni(HPyContext *ctx, HPy h_type, HPy filename1, HPy filename2) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Err_SetFromErrnoWithFilenameObjects, HPY_UP(h_type), HPY_UP(filename1), HPY_UP(filename2)); -} - -static int ctx_Err_Occurred_jni(HPyContext *ctx) -{ - return DO_UPCALL_INT0(CONTEXT_INSTANCE(ctx), ctx_Err_Occurred); -} - -static int ctx_Err_ExceptionMatches_jni(HPyContext *ctx, HPy exc) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Err_ExceptionMatches, HPY_UP(exc)); -} - -static void ctx_Err_NoMemory_jni(HPyContext *ctx) -{ - DO_UPCALL_VOID0(CONTEXT_INSTANCE(ctx), ctx_Err_NoMemory); -} - -static void ctx_Err_Clear_jni(HPyContext *ctx) -{ - DO_UPCALL_VOID0(CONTEXT_INSTANCE(ctx), ctx_Err_Clear); -} - -static HPy ctx_Err_NewException_jni(HPyContext *ctx, const char *utf8_name, HPy base, HPy dict) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Err_NewException, PTR_UP(utf8_name), HPY_UP(base), HPY_UP(dict)); -} - -static HPy ctx_Err_NewExceptionWithDoc_jni(HPyContext *ctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Err_NewExceptionWithDoc, PTR_UP(utf8_name), PTR_UP(utf8_doc), HPY_UP(base), HPY_UP(dict)); -} - -static int ctx_Err_WarnEx_jni(HPyContext *ctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Err_WarnEx, HPY_UP(category), PTR_UP(utf8_message), SIZE_T_UP(stack_level)); -} - -static void ctx_Err_WriteUnraisable_jni(HPyContext *ctx, HPy obj) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Err_WriteUnraisable, HPY_UP(obj)); -} - -static int ctx_IsTrue_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_IsTrue, HPY_UP(h)); -} - -static HPy ctx_Type_FromSpec_jni(HPyContext *ctx, HPyType_Spec *spec, HPyType_SpecParam *params) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Type_FromSpec, PTR_UP(spec), PTR_UP(params)); -} - -static HPy ctx_Type_GenericNew_jni(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Type_GenericNew, HPY_UP(type), PTR_UP(args), SIZE_T_UP(nargs), HPY_UP(kw)); -} - -static HPy ctx_GetAttr_jni(HPyContext *ctx, HPy obj, HPy name) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_GetAttr, HPY_UP(obj), HPY_UP(name)); -} - -static int ctx_HasAttr_jni(HPyContext *ctx, HPy obj, HPy name) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_HasAttr, HPY_UP(obj), HPY_UP(name)); -} - -static int ctx_HasAttr_s_jni(HPyContext *ctx, HPy obj, const char *utf8_name) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_HasAttr_s, HPY_UP(obj), PTR_UP(utf8_name)); -} - -static int ctx_SetAttr_jni(HPyContext *ctx, HPy obj, HPy name, HPy value) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_SetAttr, HPY_UP(obj), HPY_UP(name), HPY_UP(value)); -} - -static int ctx_SetAttr_s_jni(HPyContext *ctx, HPy obj, const char *utf8_name, HPy value) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_SetAttr_s, HPY_UP(obj), PTR_UP(utf8_name), HPY_UP(value)); -} - -static HPy ctx_GetItem_jni(HPyContext *ctx, HPy obj, HPy key) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_GetItem, HPY_UP(obj), HPY_UP(key)); -} - -static HPy ctx_GetItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_GetItem_i, HPY_UP(obj), SIZE_T_UP(idx)); -} - -static int ctx_Contains_jni(HPyContext *ctx, HPy container, HPy key) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Contains, HPY_UP(container), HPY_UP(key)); -} - -static int ctx_SetItem_jni(HPyContext *ctx, HPy obj, HPy key, HPy value) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_SetItem, HPY_UP(obj), HPY_UP(key), HPY_UP(value)); -} - -static int ctx_SetItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx, HPy value) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_SetItem_i, HPY_UP(obj), SIZE_T_UP(idx), HPY_UP(value)); -} - -static int ctx_DelItem_jni(HPyContext *ctx, HPy obj, HPy key) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_DelItem, HPY_UP(obj), HPY_UP(key)); -} - -static int ctx_DelItem_i_jni(HPyContext *ctx, HPy obj, HPy_ssize_t idx) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_DelItem_i, HPY_UP(obj), SIZE_T_UP(idx)); -} - -static int ctx_DelItem_s_jni(HPyContext *ctx, HPy obj, const char *utf8_key) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_DelItem_s, HPY_UP(obj), PTR_UP(utf8_key)); -} - -static HPy ctx_Type_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Type, HPY_UP(obj)); -} - -static int ctx_TypeCheck_jni(HPyContext *ctx, HPy obj, HPy type) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_TypeCheck, HPY_UP(obj), HPY_UP(type)); -} - -static const char *ctx_Type_GetName_jni(HPyContext *ctx, HPy type) -{ - return (const char *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Type_GetName, HPY_UP(type)); -} - -static int ctx_Type_IsSubtype_jni(HPyContext *ctx, HPy sub, HPy type) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Type_IsSubtype, HPY_UP(sub), HPY_UP(type)); -} - -static int ctx_Is_jni(HPyContext *ctx, HPy obj, HPy other) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Is, HPY_UP(obj), HPY_UP(other)); -} - -static void *ctx_AsStruct_Object_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Object, HPY_UP(h)); -} - -static void *ctx_AsStruct_Legacy_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Legacy, HPY_UP(h)); -} - -static void *ctx_AsStruct_Type_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Type, HPY_UP(h)); -} - -static void *ctx_AsStruct_Long_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Long, HPY_UP(h)); -} - -static void *ctx_AsStruct_Float_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Float, HPY_UP(h)); -} - -static void *ctx_AsStruct_Unicode_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Unicode, HPY_UP(h)); -} - -static void *ctx_AsStruct_Tuple_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_Tuple, HPY_UP(h)); -} - -static void *ctx_AsStruct_List_jni(HPyContext *ctx, HPy h) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsStruct_List, HPY_UP(h)); -} - -static HPyType_BuiltinShape ctx_Type_GetBuiltinShape_jni(HPyContext *ctx, HPy h_type) -{ - return DO_UPCALL_HPYTYPE_BUILTINSHAPE(CONTEXT_INSTANCE(ctx), ctx_Type_GetBuiltinShape, HPY_UP(h_type)); -} - -static HPy ctx_New_jni(HPyContext *ctx, HPy h_type, void **data) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_New, HPY_UP(h_type), PTR_UP(data)); -} - -static HPy ctx_Repr_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Repr, HPY_UP(obj)); -} - -static HPy ctx_Str_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Str, HPY_UP(obj)); -} - -static HPy ctx_ASCII_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_ASCII, HPY_UP(obj)); -} - -static HPy ctx_Bytes_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Bytes, HPY_UP(obj)); -} - -static HPy ctx_RichCompare_jni(HPyContext *ctx, HPy v, HPy w, int op) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_RichCompare, HPY_UP(v), HPY_UP(w), INT_UP(op)); -} - -static int ctx_RichCompareBool_jni(HPyContext *ctx, HPy v, HPy w, int op) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_RichCompareBool, HPY_UP(v), HPY_UP(w), INT_UP(op)); -} - -static HPy_hash_t ctx_Hash_jni(HPyContext *ctx, HPy obj) -{ - return DO_UPCALL_HPY_HASH_T(CONTEXT_INSTANCE(ctx), ctx_Hash, HPY_UP(obj)); -} - -static int ctx_Bytes_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Bytes_Check, HPY_UP(h)); -} - -static HPy_ssize_t ctx_Bytes_Size_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY_SSIZE_T(CONTEXT_INSTANCE(ctx), ctx_Bytes_Size, HPY_UP(h)); -} - -static HPy_ssize_t ctx_Bytes_GET_SIZE_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY_SSIZE_T(CONTEXT_INSTANCE(ctx), ctx_Bytes_GET_SIZE, HPY_UP(h)); -} - -static const char *ctx_Bytes_AsString_jni(HPyContext *ctx, HPy h) -{ - return (const char *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Bytes_AsString, HPY_UP(h)); -} - -static const char *ctx_Bytes_AS_STRING_jni(HPyContext *ctx, HPy h) -{ - return (const char *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Bytes_AS_STRING, HPY_UP(h)); -} - -static HPy ctx_Bytes_FromString_jni(HPyContext *ctx, const char *bytes) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Bytes_FromString, PTR_UP(bytes)); -} - -static HPy ctx_Bytes_FromStringAndSize_jni(HPyContext *ctx, const char *bytes, HPy_ssize_t len) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Bytes_FromStringAndSize, PTR_UP(bytes), SIZE_T_UP(len)); -} - -static HPy ctx_Unicode_FromString_jni(HPyContext *ctx, const char *utf8) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_FromString, PTR_UP(utf8)); -} - -static int ctx_Unicode_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Unicode_Check, HPY_UP(h)); -} - -static HPy ctx_Unicode_AsASCIIString_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_AsASCIIString, HPY_UP(h)); -} - -static HPy ctx_Unicode_AsLatin1String_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_AsLatin1String, HPY_UP(h)); -} - -static HPy ctx_Unicode_AsUTF8String_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_AsUTF8String, HPY_UP(h)); -} - -static const char *ctx_Unicode_AsUTF8AndSize_jni(HPyContext *ctx, HPy h, HPy_ssize_t *size) -{ - return (const char *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Unicode_AsUTF8AndSize, HPY_UP(h), PTR_UP(size)); -} - -static HPy ctx_Unicode_DecodeFSDefault_jni(HPyContext *ctx, const char *v) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_DecodeFSDefault, PTR_UP(v)); -} - -static HPy ctx_Unicode_DecodeFSDefaultAndSize_jni(HPyContext *ctx, const char *v, HPy_ssize_t size) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_DecodeFSDefaultAndSize, PTR_UP(v), SIZE_T_UP(size)); -} - -static HPy ctx_Unicode_EncodeFSDefault_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_EncodeFSDefault, HPY_UP(h)); -} - -static HPy_UCS4 ctx_Unicode_ReadChar_jni(HPyContext *ctx, HPy h, HPy_ssize_t index) -{ - return DO_UPCALL_HPY_UCS4(CONTEXT_INSTANCE(ctx), ctx_Unicode_ReadChar, HPY_UP(h), SIZE_T_UP(index)); -} - -static HPy ctx_Unicode_DecodeASCII_jni(HPyContext *ctx, const char *ascii, HPy_ssize_t size, const char *errors) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_DecodeASCII, PTR_UP(ascii), SIZE_T_UP(size), PTR_UP(errors)); -} - -static HPy ctx_Unicode_DecodeLatin1_jni(HPyContext *ctx, const char *latin1, HPy_ssize_t size, const char *errors) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_DecodeLatin1, PTR_UP(latin1), SIZE_T_UP(size), PTR_UP(errors)); -} - -static HPy ctx_Unicode_FromEncodedObject_jni(HPyContext *ctx, HPy obj, const char *encoding, const char *errors) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_FromEncodedObject, HPY_UP(obj), PTR_UP(encoding), PTR_UP(errors)); -} - -static HPy ctx_Unicode_Substring_jni(HPyContext *ctx, HPy str, HPy_ssize_t start, HPy_ssize_t end) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_Substring, HPY_UP(str), SIZE_T_UP(start), SIZE_T_UP(end)); -} - -static int ctx_List_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_List_Check, HPY_UP(h)); -} - -static HPy ctx_List_New_jni(HPyContext *ctx, HPy_ssize_t len) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_List_New, SIZE_T_UP(len)); -} - -static int ctx_List_Append_jni(HPyContext *ctx, HPy h_list, HPy h_item) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_List_Append, HPY_UP(h_list), HPY_UP(h_item)); -} - -static int ctx_Dict_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Dict_Check, HPY_UP(h)); -} - -static HPy ctx_Dict_New_jni(HPyContext *ctx) -{ - return DO_UPCALL_HPY0(CONTEXT_INSTANCE(ctx), ctx_Dict_New); -} - -static HPy ctx_Dict_Keys_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Dict_Keys, HPY_UP(h)); -} - -static HPy ctx_Dict_Copy_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Dict_Copy, HPY_UP(h)); -} - -static int ctx_Tuple_Check_jni(HPyContext *ctx, HPy h) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Tuple_Check, HPY_UP(h)); -} - -static int ctx_Slice_Unpack_jni(HPyContext *ctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Slice_Unpack, HPY_UP(slice), PTR_UP(start), PTR_UP(stop), PTR_UP(step)); -} - -static HPy ctx_Import_ImportModule_jni(HPyContext *ctx, const char *utf8_name) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Import_ImportModule, PTR_UP(utf8_name)); -} - -static HPy ctx_Capsule_New_jni(HPyContext *ctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Capsule_New, PTR_UP(pointer), PTR_UP(utf8_name), PTR_UP(destructor)); -} - -static void *ctx_Capsule_Get_jni(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name) -{ - return (void *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_Capsule_Get, HPY_UP(capsule), INT_UP(key), PTR_UP(utf8_name)); -} - -static int ctx_Capsule_IsValid_jni(HPyContext *ctx, HPy capsule, const char *utf8_name) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Capsule_IsValid, HPY_UP(capsule), PTR_UP(utf8_name)); -} - -static int ctx_Capsule_Set_jni(HPyContext *ctx, HPy capsule, _HPyCapsule_key key, void *value) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_Capsule_Set, HPY_UP(capsule), INT_UP(key), PTR_UP(value)); -} - -static HPy ctx_FromPyObject_jni(HPyContext *ctx, cpy_PyObject *obj) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_FromPyObject, PTR_UP(obj)); -} - -static cpy_PyObject *ctx_AsPyObject_jni(HPyContext *ctx, HPy h) -{ - return (cpy_PyObject *)DO_UPCALL_PTR(CONTEXT_INSTANCE(ctx), ctx_AsPyObject, HPY_UP(h)); -} - -static HPy ctx_Field_Load_jni(HPyContext *ctx, HPy source_object, HPyField source_field) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Field_Load, HPY_UP(source_object), HPY_FIELD_UP(source_field)); -} - -static void ctx_ReenterPythonExecution_jni(HPyContext *ctx, HPyThreadState state) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_ReenterPythonExecution, HPY_THREAD_STATE_UP(state)); -} - -static HPyThreadState ctx_LeavePythonExecution_jni(HPyContext *ctx) -{ - return DO_UPCALL_HPYTHREADSTATE0(CONTEXT_INSTANCE(ctx), ctx_LeavePythonExecution); -} - -static void ctx_Dump_jni(HPyContext *ctx, HPy h) -{ - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctx_Dump, HPY_UP(h)); -} - -static HPy ctx_Compile_s_jni(HPyContext *ctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Compile_s, PTR_UP(utf8_source), PTR_UP(utf8_filename), INT_UP(kind)); -} - -static HPy ctx_EvalCode_jni(HPyContext *ctx, HPy code, HPy globals, HPy locals) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_EvalCode, HPY_UP(code), HPY_UP(globals), HPY_UP(locals)); -} - -static HPy ctx_ContextVar_New_jni(HPyContext *ctx, const char *name, HPy default_value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_ContextVar_New, PTR_UP(name), HPY_UP(default_value)); -} - -static HPy ctx_ContextVar_Set_jni(HPyContext *ctx, HPy context_var, HPy value) -{ - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_ContextVar_Set, HPY_UP(context_var), HPY_UP(value)); -} - -static int ctx_SetCallFunction_jni(HPyContext *ctx, HPy h, HPyCallFunction *func) -{ - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctx_SetCallFunction, HPY_UP(h), PTR_UP(func)); -} - diff --git a/graalpython/com.oracle.graal.python.jni/src/ctx_builder.c b/graalpython/com.oracle.graal.python.jni/src/ctx_builder.c deleted file mode 100644 index 0cdc74a7b7..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/ctx_builder.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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. - */ - -/* - * Native implementation of HPyTupleBuilder. - * This is written in a way that we could also use the internal functions - * 'builder_*' to implement HPyListBuilder. - */ - - -#include "hpy_jni.h" - -typedef struct { - HPy_ssize_t capacity; // allocated handles - HPy handles[0]; -} _HPyBuilder_s; - -static inline _HPyBuilder_s *_ht2hb(HPyTupleBuilder ht) { - return (_HPyBuilder_s *) (ht)._tup; -} - -static inline HPyTupleBuilder _hb2ht(_HPyBuilder_s *hp) { - return (HPyTupleBuilder) {(intptr_t) (hp)}; -} - -static inline _HPyBuilder_s *_hl2hb(HPyListBuilder ht) { - return (_HPyBuilder_s *) (ht)._lst; -} - -static inline HPyListBuilder _hb2hl(_HPyBuilder_s *hp) { - return (HPyListBuilder) {(intptr_t) (hp)}; -} - -static inline _HPyBuilder_s *builder_new(HPy_ssize_t size) { - _HPyBuilder_s *hb = calloc(1, sizeof(_HPyBuilder_s) + size * sizeof(HPy)); - if (hb == NULL) { - /* delay the MemoryError */ - /* note: it's done this way so that the caller doesn't need to - check if HPyTupleBuilder_New() or every HPyTupleBuilder_Set() - raised. If there is a rare error like a MemoryError somewhere, - further calls to the HPyTupleBuilder are ignored. The final - HPyTupleBuilder_Build() will re-raise the MemoryError and so - it's enough for the caller to check at that point. */ - } else { - hb->capacity = size; - } - return hb; -} -static inline void builder_set(HPyContext *ctx, _HPyBuilder_s *hb, HPy_ssize_t index, HPy h_item) -{ - if (hb != NULL) { - assert(index >= 0 && index < hb->capacity); - assert(HPy_IsNull(hb->handles[index])); - hb->handles[index] = HPy_Dup(ctx, h_item); - } -} - -static inline void builder_cancel(HPyContext *ctx, _HPyBuilder_s *hb) -{ - if (hb == NULL) { - // we don't report the memory error here: the builder - // is being cancelled (so the result of the builder is not being used) - // and likely it's being cancelled during the handling of another error - return; - } - for (HPy_ssize_t i = 0; i < hb->capacity; i++) { - HPy_Close(ctx, hb->handles[i]); - } - free(hb); -} - -_HPy_HIDDEN HPyTupleBuilder -ctx_TupleBuilder_New_jni(HPyContext *ctx, HPy_ssize_t size) -{ - return _hb2ht(builder_new(size)); -} - -_HPy_HIDDEN void -ctx_TupleBuilder_Set_jni(HPyContext *ctx, HPyTupleBuilder builder, - HPy_ssize_t index, HPy h_item) -{ - builder_set(ctx, _ht2hb(builder), index, h_item); -} - -_HPy_HIDDEN HPy -ctx_TupleBuilder_Build_jni(HPyContext *ctx, HPyTupleBuilder builder) -{ - _HPyBuilder_s *hb = _ht2hb(builder); - if (hb == NULL) { - HPyErr_NoMemory(ctx); - return HPy_NULL; - } - HPy res = upcallSequenceFromArray(ctx, hb->handles, hb->capacity, JNI_TRUE, JNI_FALSE); - free(hb); - return res; -} - -_HPy_HIDDEN void -ctx_TupleBuilder_Cancel_jni(HPyContext *ctx, HPyTupleBuilder builder) -{ - builder_cancel(ctx, _ht2hb(builder)); -} - -_HPy_HIDDEN HPyListBuilder -ctx_ListBuilder_New_jni(HPyContext *ctx, HPy_ssize_t size) -{ - return _hb2hl(builder_new(size)); -} - -_HPy_HIDDEN void -ctx_ListBuilder_Set_jni(HPyContext *ctx, HPyListBuilder builder, - HPy_ssize_t index, HPy h_item) -{ - builder_set(ctx, _hl2hb(builder), index, h_item); -} - -_HPy_HIDDEN HPy -ctx_ListBuilder_Build_jni(HPyContext *ctx, HPyListBuilder builder) -{ - _HPyBuilder_s *hb = _hl2hb(builder); - if (hb == NULL) { - HPyErr_NoMemory(ctx); - return HPy_NULL; - } - HPy res = upcallSequenceFromArray(ctx, hb->handles, hb->capacity, JNI_TRUE, JNI_TRUE); - free(hb); - return res; -} - -_HPy_HIDDEN void -ctx_ListBuilder_Cancel_jni(HPyContext *ctx, HPyListBuilder builder) -{ - builder_cancel(ctx, _hl2hb(builder)); -} diff --git a/graalpython/com.oracle.graal.python.jni/src/ctx_call_jni.c b/graalpython/com.oracle.graal.python.jni/src/ctx_call_jni.c deleted file mode 100644 index 9c07c5aa12..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/ctx_call_jni.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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. - */ - -#include "hpy_jni.h" -#include "com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNITrampolines.h" - -#define TRAMPOLINE(name) Java_com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNITrampolines_ ## name - - -/******************************************************************* - * MANUAL TRAMPOLINES * - *******************************************************************/ - -JNIEXPORT jlong JNICALL TRAMPOLINE(executeDebugKeywords)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong self, jlong args, jlong nargs, jlong kwnames) -{ - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_keywords f = (HPyFunc_keywords)target; - DHPy dh_self = _jlong2dh(dctx, self); - UHPy uh_kwnames = _jlong2h(kwnames); - DHPy dh_kwnames; - HPy_ssize_t n_kwnames; - if (!HPy_IsNull(uh_kwnames)) - { - n_kwnames = HPy_Length(get_info(dctx)->uctx, uh_kwnames); - dh_kwnames = DHPy_open(dctx, uh_kwnames); - } - else - { - n_kwnames = 0; - dh_kwnames = HPy_NULL; - } - assert(nargs >= 0); - assert(n_kwnames >= 0); - jlong nargs_with_kw = nargs + n_kwnames; - _ARR_JLONG2DH(dctx, dh_args, args, nargs_with_kw) - DHPy dh_result = f(dctx, dh_self, dh_args, (size_t)nargs, dh_kwnames); - _ARR_DH_CLOSE(dctx, dh_args, nargs_with_kw) - DHPy_close_and_check(dctx, dh_self); - DHPy_close_and_check(dctx, dh_kwnames); - return from_dh(dctx, dh_result); -} - -JNIEXPORT jint JNICALL TRAMPOLINE(executeDebugGetbufferproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg1, jlong arg2, jint arg3) { - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_getbufferproc f = (HPyFunc_getbufferproc) target; - DHPy_buffer dbuffer; - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - jint result = f(dctx, dh_arg1, &dbuffer, (int) arg3); - DHPy_close_and_check(dctx, dh_arg1); - _buffer_d2u(dctx, &dbuffer, (UHPy_buffer *) arg2); - DHPy_close(dctx, dbuffer.obj); - return result; -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeDebugReleasebufferproc)(JNIEnv *env, jclass clazz, jlong target, jlong ctx, jlong arg1, jlong arg2) { - HPyContext *dctx = (HPyContext *) ctx; - HPyFunc_releasebufferproc f = (HPyFunc_releasebufferproc) target; - DHPy_buffer dbuf; - _buffer_u2d(dctx, (UHPy_buffer *) arg2, &dbuf); - DHPy dh_arg1 = _jlong2dh(dctx, arg1); - f(dctx, dh_arg1, &dbuf); - DHPy_close_and_check(dctx, dh_arg1); - // TODO(fa): should we use DHPy_close_and_check ? - DHPy_close(dctx, dbuf.obj); -} - -JNIEXPORT void JNICALL TRAMPOLINE(executeDestroyfunc)(JNIEnv *env, jclass clazz, jlong target, jlong dataptr) -{ - HPyFunc_destroyfunc f = (HPyFunc_destroyfunc)target; - f((void *)dataptr); -} - -#undef TRAMPOLINE diff --git a/graalpython/com.oracle.graal.python.jni/src/ctx_tracker.c b/graalpython/com.oracle.graal.python.jni/src/ctx_tracker.c deleted file mode 100644 index 047bcd3643..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/ctx_tracker.c +++ /dev/null @@ -1,171 +0,0 @@ -/* MIT License - * - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/** - * A manager for HPy handles, allowing handles to be tracked - * and closed as a group. - * - * Note:: - * Calling HPyTracker_New(ctx, n) will ensure that at least n handles - * can be tracked without a call to HPyTracker_Add failing. - * - * If a call to HPyTracker_Add fails, the tracker still guarantees that - * the handle passed to it has been tracked (internally it does this by - * maintaining space for one more handle). - * - * After HPyTracker_Add fails, HPyTracker_Close should be called without - * any further calls to HPyTracker_Add. Calling HPyTracker_Close will close - * all the tracked handles, including the handled passed to the failed call - * to HPyTracker_Add. - * - * Example usage (inside an HPyDef_METH function):: - * - * long i; - * HPy key, value; - * HPyTracker ht; - * - * ht = HPyTracker_New(ctx, 0); // track the key-value pairs - * if (HPy_IsNull(ht)) - * return HPy_NULL; - * - * HPy dict = HPyDict_New(ctx); - * if (HPy_IsNull(dict)) - * goto error; - * - * for (i=0; i<5; i++) { - * key = HPyLong_FromLong(ctx, i); - * if (HPy_IsNull(key)) - * goto error; - * if (HPyTracker_Add(ctx, ht, key) < 0) - * goto error; - * value = HPyLong_FromLong(ctx, i * i); - * if (HPy_IsNull(value)) { - * goto error; - * } - * if (HPyTracker_Add(ctx, ht, value) < 0) - * goto error; - * result = HPy_SetItem(ctx, dict, key, value); - * if (result < 0) - * goto error; - * } - * - * success: - * HPyTracker_Close(ctx, ht); - * return dict; - * - * error: - * HPyTracker_Close(ctx, ht); - * HPy_Close(ctx, dict); - * // HPyErr will already have been set by the error that occurred. - * return HPy_NULL; - */ - -#include "hpy_jni.h" - -static const HPy_ssize_t HPYTRACKER_INITIAL_CAPACITY = 5; - -_HPy_HIDDEN HPyTracker -ctx_Tracker_New_jni(HPyContext *ctx, HPy_ssize_t capacity) -{ - _HPyTracker_s *hp; - if (capacity == 0) { - capacity = HPYTRACKER_INITIAL_CAPACITY; - } - capacity++; // always reserve space for an extra handle, see the docs - - hp = (_HPyTracker_s*)malloc(sizeof(_HPyTracker_s)); - if (hp == NULL) { - HPyErr_NoMemory(ctx); - return _hp2ht(0); - } - hp->handles = (HPy*)calloc(capacity, sizeof(HPy)); - if (hp->handles == NULL) { - free(hp); - HPyErr_NoMemory(ctx); - return _hp2ht(0); - } - hp->capacity = capacity; - hp->length = 0; - return _hp2ht(hp); -} - -static int -tracker_resize(HPyContext *ctx, _HPyTracker_s *hp, HPy_ssize_t capacity) -{ - HPy *new_handles; - capacity++; - - if (capacity <= hp->length) { - // refuse a resize that would either 1) lose handles or 2) not leave - // space for one new handle - HPyErr_SetString(ctx, ctx->h_ValueError, "HPyTracker resize would lose handles"); - return -1; - } - new_handles = (HPy*)realloc(hp->handles, capacity * sizeof(HPy)); - if (new_handles == NULL) { - HPyErr_NoMemory(ctx); - return -1; - } - hp->capacity = capacity; - hp->handles = new_handles; - return 0; -} - -_HPy_HIDDEN int -raw_Tracker_Add(HPyContext *ctx, HPyTracker ht, HPy h) -{ - _HPyTracker_s *hp = _ht2hp(ht); - hp->handles[hp->length++] = h; - if (hp->capacity <= hp->length) { - if (tracker_resize(ctx, hp, hp->capacity * 2 - 1) < 0) - return -1; - } - return 0; -} - -_HPy_HIDDEN int -ctx_Tracker_Add_jni(HPyContext *ctx, HPyTracker ht, HPy h) -{ - uint64_t bits = toBits(h); - if (!isBoxedHandle(bits) || bits < IMMUTABLE_HANDLES) { - return 0; - } - return raw_Tracker_Add(ctx, ht, h); -} - -_HPy_HIDDEN void -ctx_Tracker_ForgetAll_jni(HPyContext *ctx, HPyTracker ht) -{ - _HPyTracker_s *hp = _ht2hp(ht); - hp->length = 0; -} - -_HPy_HIDDEN void -ctx_Tracker_Close_jni(HPyContext *ctx, HPyTracker ht) -{ - _HPyTracker_s *hp = _ht2hp(ht); - upcallBulkClose(ctx, hp->handles, hp->length); - free(hp->handles); - free(hp); -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/_debugmod.c b/graalpython/com.oracle.graal.python.jni/src/debug/_debugmod.c deleted file mode 100644 index e67601e210..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/_debugmod.c +++ /dev/null @@ -1,456 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -// Python-level interface for the _debug module. Written in HPy itself, the -// idea is that it should be reusable by other implementations - -// NOTE: hpy.debug._debug is loaded using the UNIVERSAL ctx. To make it -// clearer, we will use "uctx" and "dctx" to distinguish them. - -#include "hpy.h" -#include "debug_internal.h" - -static UHPy new_DebugHandleObj(HPyContext *uctx, UHPy u_DebugHandleType, - DebugHandle *handle); - -HPY_MOD_EMBEDDABLE(_trace) - -HPyDef_METH(new_generation, "new_generation", HPyFunc_NOARGS) -static UHPy new_generation_impl(HPyContext *uctx, UHPy self) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - info->current_generation++; - return HPyLong_FromLong(uctx, info->current_generation); -} - -static UHPy build_list_of_handles(HPyContext *uctx, UHPy u_self, DHQueue *q, - long gen) -{ - UHPy u_DebugHandleType = HPy_NULL; - UHPy u_result = HPy_NULL; - UHPy u_item = HPy_NULL; - - u_DebugHandleType = HPy_GetAttr_s(uctx, u_self, "DebugHandle"); - if (HPy_IsNull(u_DebugHandleType)) - goto error; - - u_result = HPyList_New(uctx, 0); - if (HPy_IsNull(u_result)) - goto error; - - DHQueueNode *node = q->head; - while(node != NULL) { - DebugHandle *dh = (DebugHandle *)node; - if (dh->generation >= gen) { - UHPy u_item = new_DebugHandleObj(uctx, u_DebugHandleType, dh); - if (HPy_IsNull(u_item)) - goto error; - if (HPyList_Append(uctx, u_result, u_item) == -1) - goto error; - HPy_Close(uctx, u_item); - } - node = node->next; - } - - HPy_Close(uctx, u_DebugHandleType); - return u_result; - - error: - HPy_Close(uctx, u_DebugHandleType); - HPy_Close(uctx, u_result); - HPy_Close(uctx, u_item); - return HPy_NULL; -} - - -HPyDef_METH(get_open_handles, "get_open_handles", HPyFunc_O, .doc= - "Return a list containing all the open handles whose generation is >= " - "of the given arg") -static UHPy get_open_handles_impl(HPyContext *uctx, UHPy u_self, UHPy u_gen) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - - long gen = HPyLong_AsLong(uctx, u_gen); - if (HPyErr_Occurred(uctx)) - return HPy_NULL; - - return build_list_of_handles(uctx, u_self, &info->open_handles, gen); -} - -HPyDef_METH(get_closed_handles, "get_closed_handles", HPyFunc_VARARGS, - .doc="Return a list of all the closed handle in the cache") -static UHPy get_closed_handles_impl(HPyContext *uctx, UHPy u_self, const HPy *args, size_t nargs) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - long gen = 0; - if (nargs > 0) { - if (nargs != 1) { - HPyErr_SetString(uctx, uctx->h_TypeError, - "get_closed_handles expects no arguments or exactly one argument"); - return HPy_NULL; - } - gen = HPyLong_AsLong(uctx, args[0]); - if (HPyErr_Occurred(uctx)) - return HPy_NULL; - } - return build_list_of_handles(uctx, u_self, &info->closed_handles, gen); -} - -HPyDef_METH(get_closed_handles_queue_max_size, "get_closed_handles_queue_max_size", HPyFunc_NOARGS, - .doc="Return the maximum size of the closed handles queue") -static UHPy get_closed_handles_queue_max_size_impl(HPyContext *uctx, UHPy u_self) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - return HPyLong_FromSsize_t(uctx, info->closed_handles_queue_max_size); -} - -HPyDef_METH(set_closed_handles_queue_max_size, "set_closed_handles_queue_max_size", HPyFunc_O, - .doc="Set the maximum size of the closed handles queue") -static UHPy set_closed_handles_queue_max_size_impl(HPyContext *uctx, UHPy u_self, UHPy u_size) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - HPy_ssize_t size = HPyLong_AsSize_t(uctx, u_size); - if (HPyErr_Occurred(uctx)) - return HPy_NULL; - info->closed_handles_queue_max_size = size; - return HPy_Dup(uctx, uctx->h_None); -} - -HPyDef_METH(get_protected_raw_data_max_size, "get_protected_raw_data_max_size", HPyFunc_NOARGS, - .doc="Return the maximum size of the retained raw memory associated with closed handles") -static UHPy get_protected_raw_data_max_size_impl(HPyContext *uctx, UHPy u_self) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - return HPyLong_FromSsize_t(uctx, info->protected_raw_data_max_size); -} - -HPyDef_METH(set_protected_raw_data_max_size, "set_protected_raw_data_max_size", HPyFunc_O, - .doc="Set the maximum size of the retained raw memory associated with closed handles") -static UHPy set_protected_raw_data_max_size_impl(HPyContext *uctx, UHPy u_self, UHPy u_size) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - HPy_ssize_t size = HPyLong_AsSize_t(uctx, u_size); - if (HPyErr_Occurred(uctx)) - return HPy_NULL; - info->protected_raw_data_max_size = size; - return HPy_Dup(uctx, uctx->h_None); -} - -HPyDef_METH(set_on_invalid_handle, "set_on_invalid_handle", HPyFunc_O, - .doc="Set the function to call when we detect the usage of an invalid handle") -static UHPy set_on_invalid_handle_impl(HPyContext *uctx, UHPy u_self, UHPy u_arg) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - if (HPy_Is(uctx, u_arg, uctx->h_None)) { - info->uh_on_invalid_handle = HPy_NULL; - } else if (!HPyCallable_Check(uctx, u_arg)) { - HPyErr_SetString(uctx, uctx->h_TypeError, "Expected a callable object"); - return HPy_NULL; - } else { - info->uh_on_invalid_handle = HPy_Dup(uctx, u_arg); - } - return HPy_Dup(uctx, uctx->h_None); -} - -HPyDef_METH(set_on_invalid_builder_handle, "set_on_invalid_builder_handle", HPyFunc_O, - .doc="Set the function to call when we detect the usage of an invalid builder handle") -static UHPy set_on_invalid_builder_handle_impl(HPyContext *uctx, UHPy u_self, UHPy u_arg) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - if (HPy_Is(uctx, u_arg, uctx->h_None)) { - info->uh_on_invalid_builder_handle = HPy_NULL; - } else if (!HPyCallable_Check(uctx, u_arg)) { - HPyErr_SetString(uctx, uctx->h_TypeError, "Expected a callable object"); - return HPy_NULL; - } else { - info->uh_on_invalid_builder_handle = HPy_Dup(uctx, u_arg); - } - return HPy_Dup(uctx, uctx->h_None); -} - -HPyDef_METH(set_handle_stack_trace_limit, "set_handle_stack_trace_limit", HPyFunc_O, - .doc="Set the limit to captured HPy handles allocations stack traces. " - "None means do not capture the stack traces.") -static UHPy set_handle_stack_trace_limit_impl(HPyContext *uctx, UHPy u_self, UHPy u_arg) -{ - HPyContext *dctx = hpy_debug_get_ctx(uctx); - HPyDebugInfo *info = get_info(dctx); - if (HPy_Is(uctx, u_arg, uctx->h_None)) { - info->handle_alloc_stacktrace_limit = 0; - } else { - assert(!HPyErr_Occurred(uctx)); - HPy_ssize_t newlimit = HPyLong_AsSsize_t(uctx, u_arg); - if (newlimit == -1 && HPyErr_Occurred(uctx)) { - return HPy_NULL; - } - info->handle_alloc_stacktrace_limit = newlimit; - } - return HPy_Dup(uctx, uctx->h_None); -} - - -/* ~~~~~~ DebugHandleType and DebugHandleObject ~~~~~~~~ - - This is the applevel view of a DebugHandle/DHPy. - - Note that there are two different ways to expose DebugHandle to applevel: - - 1. make DebugHandle itself a Python object: this is simple but means that - you have to pay the PyObject_HEAD overhead (16 bytes) for all of them - - 2. make DebugHandle a plain C struct, and expose them through a - Python-level wrapper. - - We choose to implement solution 2 because we expect to have many - DebugHandle around, but to expose only few of them to applevel, when you - call get_open_handles. This way, we save 16 bytes per DebugHandle. - - This means that you can have different DebugHandleObjects wrapping the same - DebugHandle. To make it easier to compare them, they expose the .id - attribute, which is the address of the wrapped DebugHandle. Also, - DebugHandleObjects compare equal if their .id is equal. -*/ - -typedef struct { - DebugHandle *handle; -} DebugHandleObject; - -HPyType_HELPERS(DebugHandleObject) - -HPyDef_GET(DebugHandle_obj, "obj", .doc="The object which the handle points to") -static UHPy DebugHandle_obj_get(HPyContext *uctx, UHPy self, void *closure) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - return HPy_Dup(uctx, dh->handle->uh); -} - -HPyDef_GET(DebugHandle_id, "id", - .doc="A numeric identifier representing the underlying universal handle") -static UHPy DebugHandle_id_get(HPyContext *uctx, UHPy self, void *closure) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - return HPyLong_FromSsize_t(uctx, (HPy_ssize_t)dh->handle); -} - -HPyDef_GET(DebugHandle_is_closed, "is_closed", - .doc="Self-explanatory") -static UHPy DebugHandle_is_closed_get(HPyContext *uctx, UHPy self, void *closure) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - return HPyBool_FromBool(uctx, dh->handle->is_closed); -} - -HPyDef_GET(DebugHandle_raw_data_size, "raw_data_size", -.doc="Size of retained raw memory. FOR TESTS ONLY.") -static UHPy DebugHandle_raw_data_size_get(HPyContext *uctx, UHPy self, void *closure) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - if (dh->handle->associated_data) { - return HPyLong_FromSsize_t(uctx, dh->handle->associated_data_size); - } else { - return HPyLong_FromLong(uctx, -1); - } -} - -HPyDef_SLOT(DebugHandle_cmp, HPy_tp_richcompare) -static UHPy DebugHandle_cmp_impl(HPyContext *uctx, UHPy self, UHPy o, HPy_RichCmpOp op) -{ - UHPy T = HPy_Type(uctx, self); - if (!HPy_TypeCheck(uctx, o, T)) - return HPy_Dup(uctx, uctx->h_NotImplemented); - DebugHandleObject *dh_self = DebugHandleObject_AsStruct(uctx, self); - DebugHandleObject *dh_o = DebugHandleObject_AsStruct(uctx, o); - - switch(op) { - case HPy_EQ: - return HPyBool_FromBool(uctx, dh_self->handle == dh_o->handle); - case HPy_NE: - return HPyBool_FromBool(uctx, dh_self->handle != dh_o->handle); - default: - return HPy_Dup(uctx, uctx->h_NotImplemented); - } -} - -HPyDef_SLOT(DebugHandle_repr, HPy_tp_repr) -static UHPy DebugHandle_repr_impl(HPyContext *uctx, UHPy self) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - UHPy uh_fmt = HPy_NULL; - UHPy uh_id = HPy_NULL; - UHPy uh_args = HPy_NULL; - UHPy uh_result = HPy_NULL; - UHPy h_trace_header = HPy_NULL; - UHPy h_trace = HPy_NULL; - - const char *fmt = NULL; - if (dh->handle->is_closed) - fmt = "\n%s%s"; - else - fmt = "\n%s%s"; - - // XXX: switch to HPyUnicode_FromFormat when we have it - uh_fmt = HPyUnicode_FromString(uctx, fmt); - if (HPy_IsNull(uh_fmt)) - goto exit; - - uh_id = HPyLong_FromSsize_t(uctx, (HPy_ssize_t)dh->handle); - if (HPy_IsNull(uh_id)) - goto exit; - - const char *trace_header; - const char *trace; - if (dh->handle->allocation_stacktrace) { - trace_header = "Allocation stacktrace:\n"; - trace = dh->handle->allocation_stacktrace; - } else { - trace_header = "To get the stack trace of where it was allocated use:\nhpy.debug."; - trace = set_handle_stack_trace_limit.meth.name; - } - h_trace_header = HPyUnicode_FromString(uctx, trace_header); - h_trace = HPyUnicode_FromString(uctx, trace); - - if (dh->handle->is_closed) - uh_args = HPyTuple_FromArray(uctx, (UHPy[]){uh_id, - h_trace_header, h_trace}, 3); - else - uh_args = HPyTuple_FromArray(uctx, (UHPy[]){uh_id, dh->handle->uh, - h_trace_header, h_trace}, 4); - if (HPy_IsNull(uh_args)) - goto exit; - - uh_result = HPy_Remainder(uctx, uh_fmt, uh_args); - - exit: - HPy_Close(uctx, uh_fmt); - HPy_Close(uctx, uh_id); - HPy_Close(uctx, uh_args); - HPy_Close(uctx, h_trace); - HPy_Close(uctx, h_trace_header); - return uh_result; -} - - -HPyDef_METH(DebugHandle__force_close, "_force_close", - HPyFunc_NOARGS, .doc="Close the underlying handle. FOR TESTS ONLY.") -static UHPy DebugHandle__force_close_impl(HPyContext *uctx, UHPy self) -{ - DebugHandleObject *dh = DebugHandleObject_AsStruct(uctx, self); - HPyContext *dctx = hpy_debug_get_ctx(uctx); - if (dctx == NULL) - return HPy_NULL; - HPy_Close(dctx, as_DHPy(dh->handle)); - return HPy_Dup(uctx, uctx->h_None); -} - -static HPyDef *DebugHandleType_defs[] = { - &DebugHandle_obj, - &DebugHandle_id, - &DebugHandle_is_closed, - &DebugHandle_raw_data_size, - &DebugHandle_cmp, - &DebugHandle_repr, - &DebugHandle__force_close, - NULL -}; - -static HPyType_Spec DebugHandleType_spec = { - .name = "hpy.debug._debug.DebugHandle", - .basicsize = sizeof(DebugHandleObject), - .flags = HPy_TPFLAGS_DEFAULT, - .defines = DebugHandleType_defs, -}; - - -static UHPy new_DebugHandleObj(HPyContext *uctx, UHPy u_DebugHandleType, - DebugHandle *handle) -{ - DebugHandleObject *dhobj; - UHPy u_result = HPy_New(uctx, u_DebugHandleType, &dhobj); - dhobj->handle = handle; - return u_result; -} - - -/* ~~~~~~ definition of the module hpy.debug._debug ~~~~~~~ */ - -HPyDef_SLOT(module_exec, HPy_mod_exec) -static int module_exec_impl(HPyContext *uctx, HPy m) -{ - UHPy h_DebugHandleType = HPyType_FromSpec(uctx, &DebugHandleType_spec, NULL); - if (HPy_IsNull(h_DebugHandleType)) - return -1; - HPy_SetAttr_s(uctx, m, "DebugHandle", h_DebugHandleType); - HPy_Close(uctx, h_DebugHandleType); - return 0; -} - -static HPyDef *module_defines[] = { - &new_generation, - &get_open_handles, - &get_closed_handles, - &get_closed_handles_queue_max_size, - &set_closed_handles_queue_max_size, - &get_protected_raw_data_max_size, - &set_protected_raw_data_max_size, - &set_on_invalid_handle, - &set_on_invalid_builder_handle, - &set_handle_stack_trace_limit, - &module_exec, - NULL -}; - -static HPyModuleDef moduledef = { - .doc = "HPy debug mode", - .size = 0, - .defines = module_defines -}; - -HPy_MODINIT(_debug, moduledef) diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_ctx_init.h b/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_ctx_init.h deleted file mode 100644 index d2ddd85633..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_ctx_init.h +++ /dev/null @@ -1,483 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.debug.autogen_debug_ctx_init_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -DHPy debug_ctx_Dup(HPyContext *dctx, DHPy h); -void debug_ctx_Close(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Long_FromInt32_t(HPyContext *dctx, int32_t value); -DHPy debug_ctx_Long_FromUInt32_t(HPyContext *dctx, uint32_t value); -DHPy debug_ctx_Long_FromInt64_t(HPyContext *dctx, int64_t v); -DHPy debug_ctx_Long_FromUInt64_t(HPyContext *dctx, uint64_t v); -DHPy debug_ctx_Long_FromSize_t(HPyContext *dctx, size_t value); -DHPy debug_ctx_Long_FromSsize_t(HPyContext *dctx, HPy_ssize_t value); -int32_t debug_ctx_Long_AsInt32_t(HPyContext *dctx, DHPy h); -uint32_t debug_ctx_Long_AsUInt32_t(HPyContext *dctx, DHPy h); -uint32_t debug_ctx_Long_AsUInt32_tMask(HPyContext *dctx, DHPy h); -int64_t debug_ctx_Long_AsInt64_t(HPyContext *dctx, DHPy h); -uint64_t debug_ctx_Long_AsUInt64_t(HPyContext *dctx, DHPy h); -uint64_t debug_ctx_Long_AsUInt64_tMask(HPyContext *dctx, DHPy h); -size_t debug_ctx_Long_AsSize_t(HPyContext *dctx, DHPy h); -HPy_ssize_t debug_ctx_Long_AsSsize_t(HPyContext *dctx, DHPy h); -void *debug_ctx_Long_AsVoidPtr(HPyContext *dctx, DHPy h); -double debug_ctx_Long_AsDouble(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Float_FromDouble(HPyContext *dctx, double v); -double debug_ctx_Float_AsDouble(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Bool_FromBool(HPyContext *dctx, bool v); -HPy_ssize_t debug_ctx_Length(HPyContext *dctx, DHPy h); -int debug_ctx_Number_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Add(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Subtract(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Multiply(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_MatrixMultiply(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_FloorDivide(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_TrueDivide(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Remainder(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Divmod(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Power(HPyContext *dctx, DHPy h1, DHPy h2, DHPy h3); -DHPy debug_ctx_Negative(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Positive(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Absolute(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Invert(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Lshift(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Rshift(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_And(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Xor(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Or(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_Index(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Long(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_Float(HPyContext *dctx, DHPy h1); -DHPy debug_ctx_InPlaceAdd(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceSubtract(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceMultiply(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceMatrixMultiply(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceFloorDivide(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceTrueDivide(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceRemainder(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlacePower(HPyContext *dctx, DHPy h1, DHPy h2, DHPy h3); -DHPy debug_ctx_InPlaceLshift(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceRshift(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceAnd(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceXor(HPyContext *dctx, DHPy h1, DHPy h2); -DHPy debug_ctx_InPlaceOr(HPyContext *dctx, DHPy h1, DHPy h2); -int debug_ctx_Callable_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_CallTupleDict(HPyContext *dctx, DHPy callable, DHPy args, DHPy kw); -DHPy debug_ctx_Call(HPyContext *dctx, DHPy callable, const DHPy *args, size_t nargs, DHPy kwnames); -DHPy debug_ctx_CallMethod(HPyContext *dctx, DHPy name, const DHPy *args, size_t nargs, DHPy kwnames); -void debug_ctx_FatalError(HPyContext *dctx, const char *message); -void debug_ctx_Err_SetString(HPyContext *dctx, DHPy h_type, const char *utf8_message); -void debug_ctx_Err_SetObject(HPyContext *dctx, DHPy h_type, DHPy h_value); -DHPy debug_ctx_Err_SetFromErrnoWithFilename(HPyContext *dctx, DHPy h_type, const char *filename_fsencoded); -void debug_ctx_Err_SetFromErrnoWithFilenameObjects(HPyContext *dctx, DHPy h_type, DHPy filename1, DHPy filename2); -int debug_ctx_Err_Occurred(HPyContext *dctx); -int debug_ctx_Err_ExceptionMatches(HPyContext *dctx, DHPy exc); -void debug_ctx_Err_NoMemory(HPyContext *dctx); -void debug_ctx_Err_Clear(HPyContext *dctx); -DHPy debug_ctx_Err_NewException(HPyContext *dctx, const char *utf8_name, DHPy base, DHPy dict); -DHPy debug_ctx_Err_NewExceptionWithDoc(HPyContext *dctx, const char *utf8_name, const char *utf8_doc, DHPy base, DHPy dict); -int debug_ctx_Err_WarnEx(HPyContext *dctx, DHPy category, const char *utf8_message, HPy_ssize_t stack_level); -void debug_ctx_Err_WriteUnraisable(HPyContext *dctx, DHPy obj); -int debug_ctx_IsTrue(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Type_FromSpec(HPyContext *dctx, HPyType_Spec *spec, HPyType_SpecParam *params); -DHPy debug_ctx_Type_GenericNew(HPyContext *dctx, DHPy type, const DHPy *args, HPy_ssize_t nargs, DHPy kw); -DHPy debug_ctx_GetAttr(HPyContext *dctx, DHPy obj, DHPy name); -DHPy debug_ctx_GetAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name); -int debug_ctx_HasAttr(HPyContext *dctx, DHPy obj, DHPy name); -int debug_ctx_HasAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name); -int debug_ctx_SetAttr(HPyContext *dctx, DHPy obj, DHPy name, DHPy value); -int debug_ctx_SetAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name, DHPy value); -DHPy debug_ctx_GetItem(HPyContext *dctx, DHPy obj, DHPy key); -DHPy debug_ctx_GetItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx); -DHPy debug_ctx_GetItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key); -int debug_ctx_Contains(HPyContext *dctx, DHPy container, DHPy key); -int debug_ctx_SetItem(HPyContext *dctx, DHPy obj, DHPy key, DHPy value); -int debug_ctx_SetItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx, DHPy value); -int debug_ctx_SetItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key, DHPy value); -int debug_ctx_DelItem(HPyContext *dctx, DHPy obj, DHPy key); -int debug_ctx_DelItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx); -int debug_ctx_DelItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key); -DHPy debug_ctx_Type(HPyContext *dctx, DHPy obj); -int debug_ctx_TypeCheck(HPyContext *dctx, DHPy obj, DHPy type); -const char *debug_ctx_Type_GetName(HPyContext *dctx, DHPy type); -int debug_ctx_Type_IsSubtype(HPyContext *dctx, DHPy sub, DHPy type); -int debug_ctx_Is(HPyContext *dctx, DHPy obj, DHPy other); -void *debug_ctx_AsStruct_Object(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Legacy(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Type(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Long(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Float(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Unicode(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_Tuple(HPyContext *dctx, DHPy h); -void *debug_ctx_AsStruct_List(HPyContext *dctx, DHPy h); -HPyType_BuiltinShape debug_ctx_Type_GetBuiltinShape(HPyContext *dctx, DHPy h_type); -DHPy debug_ctx_New(HPyContext *dctx, DHPy h_type, void **data); -DHPy debug_ctx_Repr(HPyContext *dctx, DHPy obj); -DHPy debug_ctx_Str(HPyContext *dctx, DHPy obj); -DHPy debug_ctx_ASCII(HPyContext *dctx, DHPy obj); -DHPy debug_ctx_Bytes(HPyContext *dctx, DHPy obj); -DHPy debug_ctx_RichCompare(HPyContext *dctx, DHPy v, DHPy w, int op); -int debug_ctx_RichCompareBool(HPyContext *dctx, DHPy v, DHPy w, int op); -HPy_hash_t debug_ctx_Hash(HPyContext *dctx, DHPy obj); -int debug_ctx_Bytes_Check(HPyContext *dctx, DHPy h); -HPy_ssize_t debug_ctx_Bytes_Size(HPyContext *dctx, DHPy h); -HPy_ssize_t debug_ctx_Bytes_GET_SIZE(HPyContext *dctx, DHPy h); -const char *debug_ctx_Bytes_AsString(HPyContext *dctx, DHPy h); -const char *debug_ctx_Bytes_AS_STRING(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Bytes_FromString(HPyContext *dctx, const char *bytes); -DHPy debug_ctx_Bytes_FromStringAndSize(HPyContext *dctx, const char *bytes, HPy_ssize_t len); -DHPy debug_ctx_Unicode_FromString(HPyContext *dctx, const char *utf8); -int debug_ctx_Unicode_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Unicode_AsASCIIString(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Unicode_AsLatin1String(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Unicode_AsUTF8String(HPyContext *dctx, DHPy h); -const char *debug_ctx_Unicode_AsUTF8AndSize(HPyContext *dctx, DHPy h, HPy_ssize_t *size); -DHPy debug_ctx_Unicode_FromWideChar(HPyContext *dctx, const wchar_t *w, HPy_ssize_t size); -DHPy debug_ctx_Unicode_DecodeFSDefault(HPyContext *dctx, const char *v); -DHPy debug_ctx_Unicode_DecodeFSDefaultAndSize(HPyContext *dctx, const char *v, HPy_ssize_t size); -DHPy debug_ctx_Unicode_EncodeFSDefault(HPyContext *dctx, DHPy h); -HPy_UCS4 debug_ctx_Unicode_ReadChar(HPyContext *dctx, DHPy h, HPy_ssize_t index); -DHPy debug_ctx_Unicode_DecodeASCII(HPyContext *dctx, const char *ascii, HPy_ssize_t size, const char *errors); -DHPy debug_ctx_Unicode_DecodeLatin1(HPyContext *dctx, const char *latin1, HPy_ssize_t size, const char *errors); -DHPy debug_ctx_Unicode_FromEncodedObject(HPyContext *dctx, DHPy obj, const char *encoding, const char *errors); -DHPy debug_ctx_Unicode_Substring(HPyContext *dctx, DHPy str, HPy_ssize_t start, HPy_ssize_t end); -int debug_ctx_List_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_List_New(HPyContext *dctx, HPy_ssize_t len); -int debug_ctx_List_Append(HPyContext *dctx, DHPy h_list, DHPy h_item); -int debug_ctx_Dict_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Dict_New(HPyContext *dctx); -DHPy debug_ctx_Dict_Keys(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Dict_Copy(HPyContext *dctx, DHPy h); -int debug_ctx_Tuple_Check(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Tuple_FromArray(HPyContext *dctx, DHPy items[], HPy_ssize_t n); -int debug_ctx_Slice_Unpack(HPyContext *dctx, DHPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step); -DHPy debug_ctx_Import_ImportModule(HPyContext *dctx, const char *utf8_name); -DHPy debug_ctx_Capsule_New(HPyContext *dctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor); -void *debug_ctx_Capsule_Get(HPyContext *dctx, DHPy capsule, _HPyCapsule_key key, const char *utf8_name); -int debug_ctx_Capsule_IsValid(HPyContext *dctx, DHPy capsule, const char *utf8_name); -int debug_ctx_Capsule_Set(HPyContext *dctx, DHPy capsule, _HPyCapsule_key key, void *value); -DHPy debug_ctx_FromPyObject(HPyContext *dctx, cpy_PyObject *obj); -cpy_PyObject *debug_ctx_AsPyObject(HPyContext *dctx, DHPy h); -void debug_ctx_CallRealFunctionFromTrampoline(HPyContext *dctx, HPyFunc_Signature sig, HPyCFunction func, void *args); -HPyListBuilder debug_ctx_ListBuilder_New(HPyContext *dctx, HPy_ssize_t size); -void debug_ctx_ListBuilder_Set(HPyContext *dctx, HPyListBuilder builder, HPy_ssize_t index, DHPy h_item); -DHPy debug_ctx_ListBuilder_Build(HPyContext *dctx, HPyListBuilder builder); -void debug_ctx_ListBuilder_Cancel(HPyContext *dctx, HPyListBuilder builder); -HPyTupleBuilder debug_ctx_TupleBuilder_New(HPyContext *dctx, HPy_ssize_t size); -void debug_ctx_TupleBuilder_Set(HPyContext *dctx, HPyTupleBuilder builder, HPy_ssize_t index, DHPy h_item); -DHPy debug_ctx_TupleBuilder_Build(HPyContext *dctx, HPyTupleBuilder builder); -void debug_ctx_TupleBuilder_Cancel(HPyContext *dctx, HPyTupleBuilder builder); -HPyTracker debug_ctx_Tracker_New(HPyContext *dctx, HPy_ssize_t size); -int debug_ctx_Tracker_Add(HPyContext *dctx, HPyTracker ht, DHPy h); -void debug_ctx_Tracker_ForgetAll(HPyContext *dctx, HPyTracker ht); -void debug_ctx_Tracker_Close(HPyContext *dctx, HPyTracker ht); -void debug_ctx_Field_Store(HPyContext *dctx, DHPy target_object, HPyField *target_field, DHPy h); -DHPy debug_ctx_Field_Load(HPyContext *dctx, DHPy source_object, HPyField source_field); -void debug_ctx_ReenterPythonExecution(HPyContext *dctx, HPyThreadState state); -HPyThreadState debug_ctx_LeavePythonExecution(HPyContext *dctx); -void debug_ctx_Global_Store(HPyContext *dctx, HPyGlobal *global, DHPy h); -DHPy debug_ctx_Global_Load(HPyContext *dctx, HPyGlobal global); -void debug_ctx_Dump(HPyContext *dctx, DHPy h); -DHPy debug_ctx_Compile_s(HPyContext *dctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind); -DHPy debug_ctx_EvalCode(HPyContext *dctx, DHPy code, DHPy globals, DHPy locals); -DHPy debug_ctx_ContextVar_New(HPyContext *dctx, const char *name, DHPy default_value); -int32_t debug_ctx_ContextVar_Get(HPyContext *dctx, DHPy context_var, DHPy default_value, DHPy *result); -DHPy debug_ctx_ContextVar_Set(HPyContext *dctx, DHPy context_var, DHPy value); -int debug_ctx_SetCallFunction(HPyContext *dctx, DHPy h, HPyCallFunction *func); - -static inline void debug_ctx_init_fields(HPyContext *dctx, HPyContext *uctx) -{ - dctx->h_None = DHPy_open_immortal(dctx, uctx->h_None); - dctx->h_True = DHPy_open_immortal(dctx, uctx->h_True); - dctx->h_False = DHPy_open_immortal(dctx, uctx->h_False); - dctx->h_NotImplemented = DHPy_open_immortal(dctx, uctx->h_NotImplemented); - dctx->h_Ellipsis = DHPy_open_immortal(dctx, uctx->h_Ellipsis); - dctx->h_BaseException = DHPy_open_immortal(dctx, uctx->h_BaseException); - dctx->h_Exception = DHPy_open_immortal(dctx, uctx->h_Exception); - dctx->h_StopAsyncIteration = DHPy_open_immortal(dctx, uctx->h_StopAsyncIteration); - dctx->h_StopIteration = DHPy_open_immortal(dctx, uctx->h_StopIteration); - dctx->h_GeneratorExit = DHPy_open_immortal(dctx, uctx->h_GeneratorExit); - dctx->h_ArithmeticError = DHPy_open_immortal(dctx, uctx->h_ArithmeticError); - dctx->h_LookupError = DHPy_open_immortal(dctx, uctx->h_LookupError); - dctx->h_AssertionError = DHPy_open_immortal(dctx, uctx->h_AssertionError); - dctx->h_AttributeError = DHPy_open_immortal(dctx, uctx->h_AttributeError); - dctx->h_BufferError = DHPy_open_immortal(dctx, uctx->h_BufferError); - dctx->h_EOFError = DHPy_open_immortal(dctx, uctx->h_EOFError); - dctx->h_FloatingPointError = DHPy_open_immortal(dctx, uctx->h_FloatingPointError); - dctx->h_OSError = DHPy_open_immortal(dctx, uctx->h_OSError); - dctx->h_ImportError = DHPy_open_immortal(dctx, uctx->h_ImportError); - dctx->h_ModuleNotFoundError = DHPy_open_immortal(dctx, uctx->h_ModuleNotFoundError); - dctx->h_IndexError = DHPy_open_immortal(dctx, uctx->h_IndexError); - dctx->h_KeyError = DHPy_open_immortal(dctx, uctx->h_KeyError); - dctx->h_KeyboardInterrupt = DHPy_open_immortal(dctx, uctx->h_KeyboardInterrupt); - dctx->h_MemoryError = DHPy_open_immortal(dctx, uctx->h_MemoryError); - dctx->h_NameError = DHPy_open_immortal(dctx, uctx->h_NameError); - dctx->h_OverflowError = DHPy_open_immortal(dctx, uctx->h_OverflowError); - dctx->h_RuntimeError = DHPy_open_immortal(dctx, uctx->h_RuntimeError); - dctx->h_RecursionError = DHPy_open_immortal(dctx, uctx->h_RecursionError); - dctx->h_NotImplementedError = DHPy_open_immortal(dctx, uctx->h_NotImplementedError); - dctx->h_SyntaxError = DHPy_open_immortal(dctx, uctx->h_SyntaxError); - dctx->h_IndentationError = DHPy_open_immortal(dctx, uctx->h_IndentationError); - dctx->h_TabError = DHPy_open_immortal(dctx, uctx->h_TabError); - dctx->h_ReferenceError = DHPy_open_immortal(dctx, uctx->h_ReferenceError); - dctx->h_SystemError = DHPy_open_immortal(dctx, uctx->h_SystemError); - dctx->h_SystemExit = DHPy_open_immortal(dctx, uctx->h_SystemExit); - dctx->h_TypeError = DHPy_open_immortal(dctx, uctx->h_TypeError); - dctx->h_UnboundLocalError = DHPy_open_immortal(dctx, uctx->h_UnboundLocalError); - dctx->h_UnicodeError = DHPy_open_immortal(dctx, uctx->h_UnicodeError); - dctx->h_UnicodeEncodeError = DHPy_open_immortal(dctx, uctx->h_UnicodeEncodeError); - dctx->h_UnicodeDecodeError = DHPy_open_immortal(dctx, uctx->h_UnicodeDecodeError); - dctx->h_UnicodeTranslateError = DHPy_open_immortal(dctx, uctx->h_UnicodeTranslateError); - dctx->h_ValueError = DHPy_open_immortal(dctx, uctx->h_ValueError); - dctx->h_ZeroDivisionError = DHPy_open_immortal(dctx, uctx->h_ZeroDivisionError); - dctx->h_BlockingIOError = DHPy_open_immortal(dctx, uctx->h_BlockingIOError); - dctx->h_BrokenPipeError = DHPy_open_immortal(dctx, uctx->h_BrokenPipeError); - dctx->h_ChildProcessError = DHPy_open_immortal(dctx, uctx->h_ChildProcessError); - dctx->h_ConnectionError = DHPy_open_immortal(dctx, uctx->h_ConnectionError); - dctx->h_ConnectionAbortedError = DHPy_open_immortal(dctx, uctx->h_ConnectionAbortedError); - dctx->h_ConnectionRefusedError = DHPy_open_immortal(dctx, uctx->h_ConnectionRefusedError); - dctx->h_ConnectionResetError = DHPy_open_immortal(dctx, uctx->h_ConnectionResetError); - dctx->h_FileExistsError = DHPy_open_immortal(dctx, uctx->h_FileExistsError); - dctx->h_FileNotFoundError = DHPy_open_immortal(dctx, uctx->h_FileNotFoundError); - dctx->h_InterruptedError = DHPy_open_immortal(dctx, uctx->h_InterruptedError); - dctx->h_IsADirectoryError = DHPy_open_immortal(dctx, uctx->h_IsADirectoryError); - dctx->h_NotADirectoryError = DHPy_open_immortal(dctx, uctx->h_NotADirectoryError); - dctx->h_PermissionError = DHPy_open_immortal(dctx, uctx->h_PermissionError); - dctx->h_ProcessLookupError = DHPy_open_immortal(dctx, uctx->h_ProcessLookupError); - dctx->h_TimeoutError = DHPy_open_immortal(dctx, uctx->h_TimeoutError); - dctx->h_Warning = DHPy_open_immortal(dctx, uctx->h_Warning); - dctx->h_UserWarning = DHPy_open_immortal(dctx, uctx->h_UserWarning); - dctx->h_DeprecationWarning = DHPy_open_immortal(dctx, uctx->h_DeprecationWarning); - dctx->h_PendingDeprecationWarning = DHPy_open_immortal(dctx, uctx->h_PendingDeprecationWarning); - dctx->h_SyntaxWarning = DHPy_open_immortal(dctx, uctx->h_SyntaxWarning); - dctx->h_RuntimeWarning = DHPy_open_immortal(dctx, uctx->h_RuntimeWarning); - dctx->h_FutureWarning = DHPy_open_immortal(dctx, uctx->h_FutureWarning); - dctx->h_ImportWarning = DHPy_open_immortal(dctx, uctx->h_ImportWarning); - dctx->h_UnicodeWarning = DHPy_open_immortal(dctx, uctx->h_UnicodeWarning); - dctx->h_BytesWarning = DHPy_open_immortal(dctx, uctx->h_BytesWarning); - dctx->h_ResourceWarning = DHPy_open_immortal(dctx, uctx->h_ResourceWarning); - dctx->h_BaseObjectType = DHPy_open_immortal(dctx, uctx->h_BaseObjectType); - dctx->h_TypeType = DHPy_open_immortal(dctx, uctx->h_TypeType); - dctx->h_BoolType = DHPy_open_immortal(dctx, uctx->h_BoolType); - dctx->h_LongType = DHPy_open_immortal(dctx, uctx->h_LongType); - dctx->h_FloatType = DHPy_open_immortal(dctx, uctx->h_FloatType); - dctx->h_UnicodeType = DHPy_open_immortal(dctx, uctx->h_UnicodeType); - dctx->h_TupleType = DHPy_open_immortal(dctx, uctx->h_TupleType); - dctx->h_ListType = DHPy_open_immortal(dctx, uctx->h_ListType); - dctx->h_ComplexType = DHPy_open_immortal(dctx, uctx->h_ComplexType); - dctx->h_BytesType = DHPy_open_immortal(dctx, uctx->h_BytesType); - dctx->h_MemoryViewType = DHPy_open_immortal(dctx, uctx->h_MemoryViewType); - dctx->h_CapsuleType = DHPy_open_immortal(dctx, uctx->h_CapsuleType); - dctx->h_SliceType = DHPy_open_immortal(dctx, uctx->h_SliceType); - dctx->h_Builtins = DHPy_open_immortal(dctx, uctx->h_Builtins); - dctx->ctx_Dup = &debug_ctx_Dup; - dctx->ctx_Close = &debug_ctx_Close; - dctx->ctx_Long_FromInt32_t = &debug_ctx_Long_FromInt32_t; - dctx->ctx_Long_FromUInt32_t = &debug_ctx_Long_FromUInt32_t; - dctx->ctx_Long_FromInt64_t = &debug_ctx_Long_FromInt64_t; - dctx->ctx_Long_FromUInt64_t = &debug_ctx_Long_FromUInt64_t; - dctx->ctx_Long_FromSize_t = &debug_ctx_Long_FromSize_t; - dctx->ctx_Long_FromSsize_t = &debug_ctx_Long_FromSsize_t; - dctx->ctx_Long_AsInt32_t = &debug_ctx_Long_AsInt32_t; - dctx->ctx_Long_AsUInt32_t = &debug_ctx_Long_AsUInt32_t; - dctx->ctx_Long_AsUInt32_tMask = &debug_ctx_Long_AsUInt32_tMask; - dctx->ctx_Long_AsInt64_t = &debug_ctx_Long_AsInt64_t; - dctx->ctx_Long_AsUInt64_t = &debug_ctx_Long_AsUInt64_t; - dctx->ctx_Long_AsUInt64_tMask = &debug_ctx_Long_AsUInt64_tMask; - dctx->ctx_Long_AsSize_t = &debug_ctx_Long_AsSize_t; - dctx->ctx_Long_AsSsize_t = &debug_ctx_Long_AsSsize_t; - dctx->ctx_Long_AsVoidPtr = &debug_ctx_Long_AsVoidPtr; - dctx->ctx_Long_AsDouble = &debug_ctx_Long_AsDouble; - dctx->ctx_Float_FromDouble = &debug_ctx_Float_FromDouble; - dctx->ctx_Float_AsDouble = &debug_ctx_Float_AsDouble; - dctx->ctx_Bool_FromBool = &debug_ctx_Bool_FromBool; - dctx->ctx_Length = &debug_ctx_Length; - dctx->ctx_Number_Check = &debug_ctx_Number_Check; - dctx->ctx_Add = &debug_ctx_Add; - dctx->ctx_Subtract = &debug_ctx_Subtract; - dctx->ctx_Multiply = &debug_ctx_Multiply; - dctx->ctx_MatrixMultiply = &debug_ctx_MatrixMultiply; - dctx->ctx_FloorDivide = &debug_ctx_FloorDivide; - dctx->ctx_TrueDivide = &debug_ctx_TrueDivide; - dctx->ctx_Remainder = &debug_ctx_Remainder; - dctx->ctx_Divmod = &debug_ctx_Divmod; - dctx->ctx_Power = &debug_ctx_Power; - dctx->ctx_Negative = &debug_ctx_Negative; - dctx->ctx_Positive = &debug_ctx_Positive; - dctx->ctx_Absolute = &debug_ctx_Absolute; - dctx->ctx_Invert = &debug_ctx_Invert; - dctx->ctx_Lshift = &debug_ctx_Lshift; - dctx->ctx_Rshift = &debug_ctx_Rshift; - dctx->ctx_And = &debug_ctx_And; - dctx->ctx_Xor = &debug_ctx_Xor; - dctx->ctx_Or = &debug_ctx_Or; - dctx->ctx_Index = &debug_ctx_Index; - dctx->ctx_Long = &debug_ctx_Long; - dctx->ctx_Float = &debug_ctx_Float; - dctx->ctx_InPlaceAdd = &debug_ctx_InPlaceAdd; - dctx->ctx_InPlaceSubtract = &debug_ctx_InPlaceSubtract; - dctx->ctx_InPlaceMultiply = &debug_ctx_InPlaceMultiply; - dctx->ctx_InPlaceMatrixMultiply = &debug_ctx_InPlaceMatrixMultiply; - dctx->ctx_InPlaceFloorDivide = &debug_ctx_InPlaceFloorDivide; - dctx->ctx_InPlaceTrueDivide = &debug_ctx_InPlaceTrueDivide; - dctx->ctx_InPlaceRemainder = &debug_ctx_InPlaceRemainder; - dctx->ctx_InPlacePower = &debug_ctx_InPlacePower; - dctx->ctx_InPlaceLshift = &debug_ctx_InPlaceLshift; - dctx->ctx_InPlaceRshift = &debug_ctx_InPlaceRshift; - dctx->ctx_InPlaceAnd = &debug_ctx_InPlaceAnd; - dctx->ctx_InPlaceXor = &debug_ctx_InPlaceXor; - dctx->ctx_InPlaceOr = &debug_ctx_InPlaceOr; - dctx->ctx_Callable_Check = &debug_ctx_Callable_Check; - dctx->ctx_CallTupleDict = &debug_ctx_CallTupleDict; - dctx->ctx_Call = &debug_ctx_Call; - dctx->ctx_CallMethod = &debug_ctx_CallMethod; - dctx->ctx_FatalError = &debug_ctx_FatalError; - dctx->ctx_Err_SetString = &debug_ctx_Err_SetString; - dctx->ctx_Err_SetObject = &debug_ctx_Err_SetObject; - dctx->ctx_Err_SetFromErrnoWithFilename = &debug_ctx_Err_SetFromErrnoWithFilename; - dctx->ctx_Err_SetFromErrnoWithFilenameObjects = &debug_ctx_Err_SetFromErrnoWithFilenameObjects; - dctx->ctx_Err_Occurred = &debug_ctx_Err_Occurred; - dctx->ctx_Err_ExceptionMatches = &debug_ctx_Err_ExceptionMatches; - dctx->ctx_Err_NoMemory = &debug_ctx_Err_NoMemory; - dctx->ctx_Err_Clear = &debug_ctx_Err_Clear; - dctx->ctx_Err_NewException = &debug_ctx_Err_NewException; - dctx->ctx_Err_NewExceptionWithDoc = &debug_ctx_Err_NewExceptionWithDoc; - dctx->ctx_Err_WarnEx = &debug_ctx_Err_WarnEx; - dctx->ctx_Err_WriteUnraisable = &debug_ctx_Err_WriteUnraisable; - dctx->ctx_IsTrue = &debug_ctx_IsTrue; - dctx->ctx_Type_FromSpec = &debug_ctx_Type_FromSpec; - dctx->ctx_Type_GenericNew = &debug_ctx_Type_GenericNew; - dctx->ctx_GetAttr = &debug_ctx_GetAttr; - dctx->ctx_GetAttr_s = &debug_ctx_GetAttr_s; - dctx->ctx_HasAttr = &debug_ctx_HasAttr; - dctx->ctx_HasAttr_s = &debug_ctx_HasAttr_s; - dctx->ctx_SetAttr = &debug_ctx_SetAttr; - dctx->ctx_SetAttr_s = &debug_ctx_SetAttr_s; - dctx->ctx_GetItem = &debug_ctx_GetItem; - dctx->ctx_GetItem_i = &debug_ctx_GetItem_i; - dctx->ctx_GetItem_s = &debug_ctx_GetItem_s; - dctx->ctx_Contains = &debug_ctx_Contains; - dctx->ctx_SetItem = &debug_ctx_SetItem; - dctx->ctx_SetItem_i = &debug_ctx_SetItem_i; - dctx->ctx_SetItem_s = &debug_ctx_SetItem_s; - dctx->ctx_DelItem = &debug_ctx_DelItem; - dctx->ctx_DelItem_i = &debug_ctx_DelItem_i; - dctx->ctx_DelItem_s = &debug_ctx_DelItem_s; - dctx->ctx_Type = &debug_ctx_Type; - dctx->ctx_TypeCheck = &debug_ctx_TypeCheck; - dctx->ctx_Type_GetName = &debug_ctx_Type_GetName; - dctx->ctx_Type_IsSubtype = &debug_ctx_Type_IsSubtype; - dctx->ctx_Is = &debug_ctx_Is; - dctx->ctx_AsStruct_Object = &debug_ctx_AsStruct_Object; - dctx->ctx_AsStruct_Legacy = &debug_ctx_AsStruct_Legacy; - dctx->ctx_AsStruct_Type = &debug_ctx_AsStruct_Type; - dctx->ctx_AsStruct_Long = &debug_ctx_AsStruct_Long; - dctx->ctx_AsStruct_Float = &debug_ctx_AsStruct_Float; - dctx->ctx_AsStruct_Unicode = &debug_ctx_AsStruct_Unicode; - dctx->ctx_AsStruct_Tuple = &debug_ctx_AsStruct_Tuple; - dctx->ctx_AsStruct_List = &debug_ctx_AsStruct_List; - dctx->ctx_Type_GetBuiltinShape = &debug_ctx_Type_GetBuiltinShape; - dctx->ctx_New = &debug_ctx_New; - dctx->ctx_Repr = &debug_ctx_Repr; - dctx->ctx_Str = &debug_ctx_Str; - dctx->ctx_ASCII = &debug_ctx_ASCII; - dctx->ctx_Bytes = &debug_ctx_Bytes; - dctx->ctx_RichCompare = &debug_ctx_RichCompare; - dctx->ctx_RichCompareBool = &debug_ctx_RichCompareBool; - dctx->ctx_Hash = &debug_ctx_Hash; - dctx->ctx_Bytes_Check = &debug_ctx_Bytes_Check; - dctx->ctx_Bytes_Size = &debug_ctx_Bytes_Size; - dctx->ctx_Bytes_GET_SIZE = &debug_ctx_Bytes_GET_SIZE; - dctx->ctx_Bytes_AsString = &debug_ctx_Bytes_AsString; - dctx->ctx_Bytes_AS_STRING = &debug_ctx_Bytes_AS_STRING; - dctx->ctx_Bytes_FromString = &debug_ctx_Bytes_FromString; - dctx->ctx_Bytes_FromStringAndSize = &debug_ctx_Bytes_FromStringAndSize; - dctx->ctx_Unicode_FromString = &debug_ctx_Unicode_FromString; - dctx->ctx_Unicode_Check = &debug_ctx_Unicode_Check; - dctx->ctx_Unicode_AsASCIIString = &debug_ctx_Unicode_AsASCIIString; - dctx->ctx_Unicode_AsLatin1String = &debug_ctx_Unicode_AsLatin1String; - dctx->ctx_Unicode_AsUTF8String = &debug_ctx_Unicode_AsUTF8String; - dctx->ctx_Unicode_AsUTF8AndSize = &debug_ctx_Unicode_AsUTF8AndSize; - dctx->ctx_Unicode_FromWideChar = &debug_ctx_Unicode_FromWideChar; - dctx->ctx_Unicode_DecodeFSDefault = &debug_ctx_Unicode_DecodeFSDefault; - dctx->ctx_Unicode_DecodeFSDefaultAndSize = &debug_ctx_Unicode_DecodeFSDefaultAndSize; - dctx->ctx_Unicode_EncodeFSDefault = &debug_ctx_Unicode_EncodeFSDefault; - dctx->ctx_Unicode_ReadChar = &debug_ctx_Unicode_ReadChar; - dctx->ctx_Unicode_DecodeASCII = &debug_ctx_Unicode_DecodeASCII; - dctx->ctx_Unicode_DecodeLatin1 = &debug_ctx_Unicode_DecodeLatin1; - dctx->ctx_Unicode_FromEncodedObject = &debug_ctx_Unicode_FromEncodedObject; - dctx->ctx_Unicode_Substring = &debug_ctx_Unicode_Substring; - dctx->ctx_List_Check = &debug_ctx_List_Check; - dctx->ctx_List_New = &debug_ctx_List_New; - dctx->ctx_List_Append = &debug_ctx_List_Append; - dctx->ctx_Dict_Check = &debug_ctx_Dict_Check; - dctx->ctx_Dict_New = &debug_ctx_Dict_New; - dctx->ctx_Dict_Keys = &debug_ctx_Dict_Keys; - dctx->ctx_Dict_Copy = &debug_ctx_Dict_Copy; - dctx->ctx_Tuple_Check = &debug_ctx_Tuple_Check; - dctx->ctx_Tuple_FromArray = &debug_ctx_Tuple_FromArray; - dctx->ctx_Slice_Unpack = &debug_ctx_Slice_Unpack; - dctx->ctx_Import_ImportModule = &debug_ctx_Import_ImportModule; - dctx->ctx_Capsule_New = &debug_ctx_Capsule_New; - dctx->ctx_Capsule_Get = &debug_ctx_Capsule_Get; - dctx->ctx_Capsule_IsValid = &debug_ctx_Capsule_IsValid; - dctx->ctx_Capsule_Set = &debug_ctx_Capsule_Set; - dctx->ctx_FromPyObject = &debug_ctx_FromPyObject; - dctx->ctx_AsPyObject = &debug_ctx_AsPyObject; - dctx->ctx_CallRealFunctionFromTrampoline = &debug_ctx_CallRealFunctionFromTrampoline; - dctx->ctx_ListBuilder_New = &debug_ctx_ListBuilder_New; - dctx->ctx_ListBuilder_Set = &debug_ctx_ListBuilder_Set; - dctx->ctx_ListBuilder_Build = &debug_ctx_ListBuilder_Build; - dctx->ctx_ListBuilder_Cancel = &debug_ctx_ListBuilder_Cancel; - dctx->ctx_TupleBuilder_New = &debug_ctx_TupleBuilder_New; - dctx->ctx_TupleBuilder_Set = &debug_ctx_TupleBuilder_Set; - dctx->ctx_TupleBuilder_Build = &debug_ctx_TupleBuilder_Build; - dctx->ctx_TupleBuilder_Cancel = &debug_ctx_TupleBuilder_Cancel; - dctx->ctx_Tracker_New = &debug_ctx_Tracker_New; - dctx->ctx_Tracker_Add = &debug_ctx_Tracker_Add; - dctx->ctx_Tracker_ForgetAll = &debug_ctx_Tracker_ForgetAll; - dctx->ctx_Tracker_Close = &debug_ctx_Tracker_Close; - dctx->ctx_Field_Store = &debug_ctx_Field_Store; - dctx->ctx_Field_Load = &debug_ctx_Field_Load; - dctx->ctx_ReenterPythonExecution = &debug_ctx_ReenterPythonExecution; - dctx->ctx_LeavePythonExecution = &debug_ctx_LeavePythonExecution; - dctx->ctx_Global_Store = &debug_ctx_Global_Store; - dctx->ctx_Global_Load = &debug_ctx_Global_Load; - dctx->ctx_Dump = &debug_ctx_Dump; - dctx->ctx_Compile_s = &debug_ctx_Compile_s; - dctx->ctx_EvalCode = &debug_ctx_EvalCode; - dctx->ctx_ContextVar_New = &debug_ctx_ContextVar_New; - dctx->ctx_ContextVar_Get = &debug_ctx_ContextVar_Get; - dctx->ctx_ContextVar_Set = &debug_ctx_ContextVar_Set; - dctx->ctx_SetCallFunction = &debug_ctx_SetCallFunction; -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_wrappers.c b/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_wrappers.c deleted file mode 100644 index c4337edee4..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/autogen_debug_wrappers.c +++ /dev/null @@ -1,1794 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.debug.autogen_debug_wrappers - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#include "debug_internal.h" - -DHPy debug_ctx_Dup(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Dup(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromInt32_t(HPyContext *dctx, int32_t value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromInt32_t(get_info(dctx)->uctx, value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromUInt32_t(HPyContext *dctx, uint32_t value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromUInt32_t(get_info(dctx)->uctx, value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromInt64_t(HPyContext *dctx, int64_t v) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromInt64_t(get_info(dctx)->uctx, v); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromUInt64_t(HPyContext *dctx, uint64_t v) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromUInt64_t(get_info(dctx)->uctx, v); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromSize_t(HPyContext *dctx, size_t value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromSize_t(get_info(dctx)->uctx, value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long_FromSsize_t(HPyContext *dctx, HPy_ssize_t value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyLong_FromSsize_t(get_info(dctx)->uctx, value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int32_t debug_ctx_Long_AsInt32_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int32_t universal_result = HPyLong_AsInt32_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -uint32_t debug_ctx_Long_AsUInt32_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - uint32_t universal_result = HPyLong_AsUInt32_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -uint32_t debug_ctx_Long_AsUInt32_tMask(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - uint32_t universal_result = HPyLong_AsUInt32_tMask(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int64_t debug_ctx_Long_AsInt64_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int64_t universal_result = HPyLong_AsInt64_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -uint64_t debug_ctx_Long_AsUInt64_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - uint64_t universal_result = HPyLong_AsUInt64_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -uint64_t debug_ctx_Long_AsUInt64_tMask(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - uint64_t universal_result = HPyLong_AsUInt64_tMask(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -size_t debug_ctx_Long_AsSize_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - size_t universal_result = HPyLong_AsSize_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -HPy_ssize_t debug_ctx_Long_AsSsize_t(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy_ssize_t universal_result = HPyLong_AsSsize_t(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -void *debug_ctx_Long_AsVoidPtr(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - void * universal_result = HPyLong_AsVoidPtr(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -double debug_ctx_Long_AsDouble(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - double universal_result = HPyLong_AsDouble(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Float_FromDouble(HPyContext *dctx, double v) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyFloat_FromDouble(get_info(dctx)->uctx, v); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -double debug_ctx_Float_AsDouble(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - double universal_result = HPyFloat_AsDouble(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Bool_FromBool(HPyContext *dctx, bool v) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyBool_FromBool(get_info(dctx)->uctx, v); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -HPy_ssize_t debug_ctx_Length(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy_ssize_t universal_result = HPy_Length(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Number_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyNumber_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Add(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Add(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Subtract(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Subtract(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Multiply(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Multiply(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_MatrixMultiply(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_MatrixMultiply(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_FloorDivide(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_FloorDivide(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_TrueDivide(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_TrueDivide(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Remainder(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Remainder(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Divmod(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Divmod(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Power(HPyContext *dctx, DHPy h1, DHPy h2, DHPy h3) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - HPy dh_h3 = DHPy_unwrap(dctx, h3); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Power(get_info(dctx)->uctx, dh_h1, dh_h2, dh_h3); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Negative(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Negative(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Positive(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Positive(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Absolute(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Absolute(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Invert(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Invert(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Lshift(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Lshift(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Rshift(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Rshift(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_And(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_And(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Xor(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Xor(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Or(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Or(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Index(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Index(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Long(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Long(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Float(HPyContext *dctx, DHPy h1) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Float(get_info(dctx)->uctx, dh_h1); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceAdd(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceAdd(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceSubtract(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceSubtract(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceMultiply(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceMultiply(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceMatrixMultiply(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceMatrixMultiply(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceFloorDivide(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceFloorDivide(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceTrueDivide(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceTrueDivide(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceRemainder(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceRemainder(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlacePower(HPyContext *dctx, DHPy h1, DHPy h2, DHPy h3) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - HPy dh_h3 = DHPy_unwrap(dctx, h3); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlacePower(get_info(dctx)->uctx, dh_h1, dh_h2, dh_h3); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceLshift(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceLshift(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceRshift(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceRshift(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceAnd(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceAnd(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceXor(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceXor(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_InPlaceOr(HPyContext *dctx, DHPy h1, DHPy h2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h1 = DHPy_unwrap(dctx, h1); - HPy dh_h2 = DHPy_unwrap(dctx, h2); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_InPlaceOr(get_info(dctx)->uctx, dh_h1, dh_h2); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Callable_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyCallable_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_CallTupleDict(HPyContext *dctx, DHPy callable, DHPy args, DHPy kw) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_callable = DHPy_unwrap(dctx, callable); - HPy dh_args = DHPy_unwrap(dctx, args); - HPy dh_kw = DHPy_unwrap(dctx, kw); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_CallTupleDict(get_info(dctx)->uctx, dh_callable, dh_args, dh_kw); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -void debug_ctx_FatalError(HPyContext *dctx, const char *message) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy_FatalError(get_info(dctx)->uctx, message); - get_ctx_info(dctx)->is_valid = true; -} - -void debug_ctx_Err_SetString(HPyContext *dctx, DHPy h_type, const char *utf8_message) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - get_ctx_info(dctx)->is_valid = false; - HPyErr_SetString(get_info(dctx)->uctx, dh_h_type, utf8_message); - get_ctx_info(dctx)->is_valid = true; -} - -void debug_ctx_Err_SetObject(HPyContext *dctx, DHPy h_type, DHPy h_value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - HPy dh_h_value = DHPy_unwrap(dctx, h_value); - get_ctx_info(dctx)->is_valid = false; - HPyErr_SetObject(get_info(dctx)->uctx, dh_h_type, dh_h_value); - get_ctx_info(dctx)->is_valid = true; -} - -DHPy debug_ctx_Err_SetFromErrnoWithFilename(HPyContext *dctx, DHPy h_type, const char *filename_fsencoded) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyErr_SetFromErrnoWithFilename(get_info(dctx)->uctx, dh_h_type, filename_fsencoded); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -void debug_ctx_Err_SetFromErrnoWithFilenameObjects(HPyContext *dctx, DHPy h_type, DHPy filename1, DHPy filename2) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - HPy dh_filename1 = DHPy_unwrap(dctx, filename1); - HPy dh_filename2 = DHPy_unwrap(dctx, filename2); - get_ctx_info(dctx)->is_valid = false; - HPyErr_SetFromErrnoWithFilenameObjects(get_info(dctx)->uctx, dh_h_type, dh_filename1, dh_filename2); - get_ctx_info(dctx)->is_valid = true; -} - -int debug_ctx_Err_Occurred(HPyContext *dctx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyErr_Occurred(get_info(dctx)->uctx); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Err_ExceptionMatches(HPyContext *dctx, DHPy exc) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_exc = DHPy_unwrap(dctx, exc); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyErr_ExceptionMatches(get_info(dctx)->uctx, dh_exc); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -void debug_ctx_Err_NoMemory(HPyContext *dctx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPyErr_NoMemory(get_info(dctx)->uctx); - get_ctx_info(dctx)->is_valid = true; -} - -void debug_ctx_Err_Clear(HPyContext *dctx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPyErr_Clear(get_info(dctx)->uctx); - get_ctx_info(dctx)->is_valid = true; -} - -DHPy debug_ctx_Err_NewException(HPyContext *dctx, const char *utf8_name, DHPy base, DHPy dict) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_base = DHPy_unwrap(dctx, base); - HPy dh_dict = DHPy_unwrap(dctx, dict); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyErr_NewException(get_info(dctx)->uctx, utf8_name, dh_base, dh_dict); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Err_NewExceptionWithDoc(HPyContext *dctx, const char *utf8_name, const char *utf8_doc, DHPy base, DHPy dict) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_base = DHPy_unwrap(dctx, base); - HPy dh_dict = DHPy_unwrap(dctx, dict); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyErr_NewExceptionWithDoc(get_info(dctx)->uctx, utf8_name, utf8_doc, dh_base, dh_dict); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Err_WarnEx(HPyContext *dctx, DHPy category, const char *utf8_message, HPy_ssize_t stack_level) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_category = DHPy_unwrap(dctx, category); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyErr_WarnEx(get_info(dctx)->uctx, dh_category, utf8_message, stack_level); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -void debug_ctx_Err_WriteUnraisable(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPyErr_WriteUnraisable(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; -} - -int debug_ctx_IsTrue(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_IsTrue(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_GetAttr(HPyContext *dctx, DHPy obj, DHPy name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_name = DHPy_unwrap(dctx, name); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_GetAttr(get_info(dctx)->uctx, dh_obj, dh_name); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_GetAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_GetAttr_s(get_info(dctx)->uctx, dh_obj, utf8_name); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_HasAttr(HPyContext *dctx, DHPy obj, DHPy name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_name = DHPy_unwrap(dctx, name); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_HasAttr(get_info(dctx)->uctx, dh_obj, dh_name); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_HasAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_HasAttr_s(get_info(dctx)->uctx, dh_obj, utf8_name); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_SetAttr(HPyContext *dctx, DHPy obj, DHPy name, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_name = DHPy_unwrap(dctx, name); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetAttr(get_info(dctx)->uctx, dh_obj, dh_name, dh_value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_SetAttr_s(HPyContext *dctx, DHPy obj, const char *utf8_name, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetAttr_s(get_info(dctx)->uctx, dh_obj, utf8_name, dh_value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_GetItem(HPyContext *dctx, DHPy obj, DHPy key) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_key = DHPy_unwrap(dctx, key); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_GetItem(get_info(dctx)->uctx, dh_obj, dh_key); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_GetItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_GetItem_i(get_info(dctx)->uctx, dh_obj, idx); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_GetItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_GetItem_s(get_info(dctx)->uctx, dh_obj, utf8_key); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Contains(HPyContext *dctx, DHPy container, DHPy key) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_container = DHPy_unwrap(dctx, container); - HPy dh_key = DHPy_unwrap(dctx, key); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_Contains(get_info(dctx)->uctx, dh_container, dh_key); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_SetItem(HPyContext *dctx, DHPy obj, DHPy key, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_key = DHPy_unwrap(dctx, key); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetItem(get_info(dctx)->uctx, dh_obj, dh_key, dh_value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_SetItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetItem_i(get_info(dctx)->uctx, dh_obj, idx, dh_value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_SetItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetItem_s(get_info(dctx)->uctx, dh_obj, utf8_key, dh_value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_DelItem(HPyContext *dctx, DHPy obj, DHPy key) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_key = DHPy_unwrap(dctx, key); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_DelItem(get_info(dctx)->uctx, dh_obj, dh_key); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_DelItem_i(HPyContext *dctx, DHPy obj, HPy_ssize_t idx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_DelItem_i(get_info(dctx)->uctx, dh_obj, idx); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_DelItem_s(HPyContext *dctx, DHPy obj, const char *utf8_key) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_DelItem_s(get_info(dctx)->uctx, dh_obj, utf8_key); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Type(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Type(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Is(HPyContext *dctx, DHPy obj, DHPy other) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - HPy dh_other = DHPy_unwrap(dctx, other); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_Is(get_info(dctx)->uctx, dh_obj, dh_other); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -HPyType_BuiltinShape debug_ctx_Type_GetBuiltinShape(HPyContext *dctx, DHPy h_type) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - get_ctx_info(dctx)->is_valid = false; - HPyType_BuiltinShape universal_result = _HPyType_GetBuiltinShape(get_info(dctx)->uctx, dh_h_type); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_New(HPyContext *dctx, DHPy h_type, void **data) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_type = DHPy_unwrap(dctx, h_type); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = _HPy_New(get_info(dctx)->uctx, dh_h_type, data); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Repr(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Repr(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Str(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Str(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_ASCII(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_ASCII(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Bytes(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Bytes(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_RichCompare(HPyContext *dctx, DHPy v, DHPy w, int op) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_v = DHPy_unwrap(dctx, v); - HPy dh_w = DHPy_unwrap(dctx, w); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_RichCompare(get_info(dctx)->uctx, dh_v, dh_w, op); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_RichCompareBool(HPyContext *dctx, DHPy v, DHPy w, int op) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_v = DHPy_unwrap(dctx, v); - HPy dh_w = DHPy_unwrap(dctx, w); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_RichCompareBool(get_info(dctx)->uctx, dh_v, dh_w, op); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -HPy_hash_t debug_ctx_Hash(HPyContext *dctx, DHPy obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy_hash_t universal_result = HPy_Hash(get_info(dctx)->uctx, dh_obj); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Bytes_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyBytes_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -HPy_ssize_t debug_ctx_Bytes_Size(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy_ssize_t universal_result = HPyBytes_Size(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -HPy_ssize_t debug_ctx_Bytes_GET_SIZE(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy_ssize_t universal_result = HPyBytes_GET_SIZE(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Bytes_FromString(HPyContext *dctx, const char *bytes) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyBytes_FromString(get_info(dctx)->uctx, bytes); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Bytes_FromStringAndSize(HPyContext *dctx, const char *bytes, HPy_ssize_t len) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyBytes_FromStringAndSize(get_info(dctx)->uctx, bytes, len); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_FromString(HPyContext *dctx, const char *utf8) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_FromString(get_info(dctx)->uctx, utf8); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Unicode_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyUnicode_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Unicode_AsASCIIString(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_AsASCIIString(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_AsLatin1String(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_AsLatin1String(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_AsUTF8String(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_AsUTF8String(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_FromWideChar(HPyContext *dctx, const wchar_t *w, HPy_ssize_t size) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_FromWideChar(get_info(dctx)->uctx, w, size); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_DecodeFSDefault(HPyContext *dctx, const char *v) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_DecodeFSDefault(get_info(dctx)->uctx, v); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_DecodeFSDefaultAndSize(HPyContext *dctx, const char *v, HPy_ssize_t size) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_DecodeFSDefaultAndSize(get_info(dctx)->uctx, v, size); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_EncodeFSDefault(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_EncodeFSDefault(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -HPy_UCS4 debug_ctx_Unicode_ReadChar(HPyContext *dctx, DHPy h, HPy_ssize_t index) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy_UCS4 universal_result = HPyUnicode_ReadChar(get_info(dctx)->uctx, dh_h, index); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Unicode_DecodeASCII(HPyContext *dctx, const char *ascii, HPy_ssize_t size, const char *errors) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_DecodeASCII(get_info(dctx)->uctx, ascii, size, errors); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_DecodeLatin1(HPyContext *dctx, const char *latin1, HPy_ssize_t size, const char *errors) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_DecodeLatin1(get_info(dctx)->uctx, latin1, size, errors); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Unicode_FromEncodedObject(HPyContext *dctx, DHPy obj, const char *encoding, const char *errors) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_obj = DHPy_unwrap(dctx, obj); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyUnicode_FromEncodedObject(get_info(dctx)->uctx, dh_obj, encoding, errors); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_List_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyList_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_List_New(HPyContext *dctx, HPy_ssize_t len) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyList_New(get_info(dctx)->uctx, len); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_List_Append(HPyContext *dctx, DHPy h_list, DHPy h_item) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h_list = DHPy_unwrap(dctx, h_list); - HPy dh_h_item = DHPy_unwrap(dctx, h_item); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyList_Append(get_info(dctx)->uctx, dh_h_list, dh_h_item); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Dict_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyDict_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Dict_New(HPyContext *dctx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyDict_New(get_info(dctx)->uctx); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Dict_Keys(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyDict_Keys(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Dict_Copy(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyDict_Copy(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_Tuple_Check(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyTuple_Check(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Slice_Unpack(HPyContext *dctx, DHPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_slice = DHPy_unwrap(dctx, slice); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPySlice_Unpack(get_info(dctx)->uctx, dh_slice, start, stop, step); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_Import_ImportModule(HPyContext *dctx, const char *utf8_name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyImport_ImportModule(get_info(dctx)->uctx, utf8_name); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Capsule_New(HPyContext *dctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyCapsule_New(get_info(dctx)->uctx, pointer, utf8_name, destructor); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -void *debug_ctx_Capsule_Get(HPyContext *dctx, DHPy capsule, _HPyCapsule_key key, const char *utf8_name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_capsule = DHPy_unwrap(dctx, capsule); - get_ctx_info(dctx)->is_valid = false; - void * universal_result = HPyCapsule_Get(get_info(dctx)->uctx, dh_capsule, key, utf8_name); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Capsule_IsValid(HPyContext *dctx, DHPy capsule, const char *utf8_name) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_capsule = DHPy_unwrap(dctx, capsule); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyCapsule_IsValid(get_info(dctx)->uctx, dh_capsule, utf8_name); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -int debug_ctx_Capsule_Set(HPyContext *dctx, DHPy capsule, _HPyCapsule_key key, void *value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_capsule = DHPy_unwrap(dctx, capsule); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPyCapsule_Set(get_info(dctx)->uctx, dh_capsule, key, value); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -DHPy debug_ctx_FromPyObject(HPyContext *dctx, cpy_PyObject *obj) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_FromPyObject(get_info(dctx)->uctx, obj); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -cpy_PyObject *debug_ctx_AsPyObject(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - cpy_PyObject * universal_result = HPy_AsPyObject(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -void debug_ctx_Field_Store(HPyContext *dctx, DHPy target_object, HPyField *target_field, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_target_object = DHPy_unwrap(dctx, target_object); - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPyField_Store(get_info(dctx)->uctx, dh_target_object, target_field, dh_h); - get_ctx_info(dctx)->is_valid = true; -} - -DHPy debug_ctx_Field_Load(HPyContext *dctx, DHPy source_object, HPyField source_field) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_source_object = DHPy_unwrap(dctx, source_object); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyField_Load(get_info(dctx)->uctx, dh_source_object, source_field); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -void debug_ctx_ReenterPythonExecution(HPyContext *dctx, HPyThreadState state) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy_ReenterPythonExecution(get_info(dctx)->uctx, state); - get_ctx_info(dctx)->is_valid = true; -} - -HPyThreadState debug_ctx_LeavePythonExecution(HPyContext *dctx) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPyThreadState universal_result = HPy_LeavePythonExecution(get_info(dctx)->uctx); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - -void debug_ctx_Global_Store(HPyContext *dctx, HPyGlobal *global, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - HPyGlobal_Store(get_info(dctx)->uctx, global, dh_h); - get_ctx_info(dctx)->is_valid = true; -} - -DHPy debug_ctx_Global_Load(HPyContext *dctx, HPyGlobal global) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyGlobal_Load(get_info(dctx)->uctx, global); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -void debug_ctx_Dump(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - _HPy_Dump(get_info(dctx)->uctx, dh_h); - get_ctx_info(dctx)->is_valid = true; -} - -DHPy debug_ctx_Compile_s(HPyContext *dctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_Compile_s(get_info(dctx)->uctx, utf8_source, utf8_filename, kind); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_EvalCode(HPyContext *dctx, DHPy code, DHPy globals, DHPy locals) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_code = DHPy_unwrap(dctx, code); - HPy dh_globals = DHPy_unwrap(dctx, globals); - HPy dh_locals = DHPy_unwrap(dctx, locals); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPy_EvalCode(get_info(dctx)->uctx, dh_code, dh_globals, dh_locals); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_ContextVar_New(HPyContext *dctx, const char *name, DHPy default_value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_default_value = DHPy_unwrap(dctx, default_value); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyContextVar_New(get_info(dctx)->uctx, name, dh_default_value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_ContextVar_Set(HPyContext *dctx, DHPy context_var, DHPy value) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_context_var = DHPy_unwrap(dctx, context_var); - HPy dh_value = DHPy_unwrap(dctx, value); - get_ctx_info(dctx)->is_valid = false; - HPy universal_result = HPyContextVar_Set(get_info(dctx)->uctx, dh_context_var, dh_value); - get_ctx_info(dctx)->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -int debug_ctx_SetCallFunction(HPyContext *dctx, DHPy h, HPyCallFunction *func) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPy dh_h = DHPy_unwrap(dctx, h); - get_ctx_info(dctx)->is_valid = false; - int universal_result = HPy_SetCallFunction(get_info(dctx)->uctx, dh_h, func); - get_ctx_info(dctx)->is_valid = true; - return universal_result; -} - diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx.c b/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx.c deleted file mode 100644 index bb02fa5588..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx.c +++ /dev/null @@ -1,619 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include -#include -#include "debug_internal.h" -#include "autogen_debug_ctx_init.h" -#include "hpy/runtime/ctx_funcs.h" -#if defined(_MSC_VER) -# include /* for alloca() */ -#endif - -static HPyDebugCtxInfo *init_ctx_info(HPyContext *dctx, HPyContext *uctx) { - HPyDebugCtxInfo *ctx_info = (HPyDebugCtxInfo*) malloc(sizeof(HPyDebugCtxInfo)); - if (ctx_info == NULL) { - HPyErr_NoMemory(uctx); - return NULL; - } - dctx->_private = ctx_info; - ctx_info->magic_number = HPY_DEBUG_CTX_INFO_MAGIC; - ctx_info->is_valid = false; - return ctx_info; -} - -static HPyContext *copy_debug_context(HPyContext *dctx) { - HPyDebugInfo *info = get_info(dctx); - HPyContext *new_dcxt = (HPyContext *) malloc(sizeof(struct _HPyContext_s)); - memcpy(new_dcxt, dctx, sizeof(struct _HPyContext_s)); - HPyDebugCtxInfo *ctx_info = init_ctx_info(new_dcxt, info->uctx); - if (ctx_info == NULL) { - return NULL; - } - ctx_info->info = info; - return new_dcxt; -} - -static int init_dctx_cache(HPyContext *dctx, HPyDebugInfo *info) { - // We prefill the context cache to keep it simple - for (size_t i = 0; i < HPY_DEBUG_CTX_CACHE_SIZE; ++i) { - info->dctx_cache[i] = copy_debug_context(dctx); - if (info->dctx_cache[i] == NULL) { - return -1; - } - } - info->dctx_cache_current_index = 0; - return 0; -} - -// NOTE: at the moment this function assumes that uctx is always the -// same. If/when we migrate to a system in which we can have multiple -// independent contexts, this function should ensure to create a different -// debug wrapper for each of them. -_HPy_HIDDEN int hpy_debug_ctx_init(HPyContext *dctx, HPyContext *uctx) -{ - if (dctx->_private != NULL) { - // already initialized - assert(get_info(dctx)->uctx == uctx); // sanity check - return 0; - } - // initialize debug_info - // XXX: currently we never free this malloc and - // the allocations of the cached debug contexts - HPyDebugCtxInfo *ctx_info = init_ctx_info(dctx, uctx); - if (ctx_info == NULL) { - return -1; - } - ctx_info->is_valid = true; - HPyDebugInfo *info = ctx_info->info = malloc(sizeof(HPyDebugInfo)); - if (info == NULL) { - HPyErr_NoMemory(uctx); - return -1; - } - info->magic_number = HPY_DEBUG_INFO_MAGIC; - info->uctx = uctx; - info->current_generation = 0; - info->uh_on_invalid_handle = HPy_NULL; - info->closed_handles_queue_max_size = DEFAULT_CLOSED_HANDLES_QUEUE_MAX_SIZE; - info->protected_raw_data_max_size = DEFAULT_PROTECTED_RAW_DATA_MAX_SIZE; - info->handle_alloc_stacktrace_limit = 0; - info->protected_raw_data_size = 0; - DHQueue_init(&info->open_handles); - DHQueue_init(&info->closed_handles); - DHQueue_init(&info->closed_builder); - debug_ctx_init_fields(dctx, uctx); - if (init_dctx_cache(dctx, info) != 0) { - return -1; - } - return 0; -} - -_HPy_HIDDEN void hpy_debug_ctx_free(HPyContext *dctx) -{ - free(dctx->_private); -} - -HPy hpy_debug_open_handle(HPyContext *dctx, HPy uh) -{ - return DHPy_open(dctx, uh); -} - -HPy hpy_debug_unwrap_handle(HPyContext *dctx, HPy dh) -{ - return DHPy_unwrap(dctx, dh); -} - -void hpy_debug_close_handle(HPyContext *dctx, HPy dh) -{ - DHPy_close(dctx, dh); -} - -// this function is supposed to be called from gdb: it tries to determine -// whether a handle is universal or debug by looking at the last bit -#ifndef _MSC_VER -__attribute__((unused)) -#endif -static void hpy_magic_dump(HPyContext *uctx, HPy h) -{ - int universal = h._i & 1; - if (universal) - fprintf(stderr, "\nUniversal handle\n"); - else - fprintf(stderr, "\nDebug handle\n"); - -#ifdef _MSC_VER - fprintf(stderr, "raw value: %Ix (%Id)\n", h._i, h._i); -#else - fprintf(stderr, "raw value: %lx (%ld)\n", h._i, h._i); -#endif - if (universal) - _HPy_Dump(uctx, h); - else { - DebugHandle *dh = as_DebugHandle(h); -#ifdef _MSC_VER - fprintf(stderr, "dh->uh: %Ix\n", dh->uh._i); -#else - fprintf(stderr, "dh->uh: %lx\n", dh->uh._i); -#endif - _HPy_Dump(uctx, dh->uh); - } -} - -HPyContext* hpy_debug_get_next_dctx_from_cache(HPyContext *dctx) { - HPyDebugInfo *info = get_info(dctx); - HPyContext *result = info->dctx_cache[info->dctx_cache_current_index]; - info->dctx_cache_current_index = - (info->dctx_cache_current_index + 1) % HPY_DEBUG_CTX_CACHE_SIZE; - return result; -} - -void report_invalid_debug_context() { - fputs("Error: Wrong HPy Context!\n", stderr); - char *stacktrace; - create_stacktrace(&stacktrace, HPY_DEBUG_DEFAULT_STACKTRACE_LIMIT); - if (stacktrace != NULL) { - fputs(stacktrace, stderr); - } - fflush(stderr); - abort(); -} - -/* ~~~~~~~~~~ manually written wrappers ~~~~~~~~~~ */ - -void debug_ctx_Close(HPyContext *dctx, DHPy dh) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - UHPy uh = DHPy_unwrap(dctx, dh); - DHPy_close(dctx, dh); - // Note: this may run __del__ - get_ctx_info(dctx)->is_valid = false; - HPy_Close(get_info(dctx)->uctx, uh); - get_ctx_info(dctx)->is_valid = true; -} - -static void * -protect_and_associate_data_ptr(DHPy h, void *ptr, HPy_ssize_t data_size) -{ - DebugHandle *handle = as_DebugHandle(h); - void *new_ptr; - if (ptr != NULL) - { - new_ptr = raw_data_copy(ptr, data_size, true); - handle->associated_data = new_ptr; - handle->associated_data_size = data_size; - return new_ptr; - } - else - { - handle->associated_data = NULL; - handle->associated_data_size = 0; - } - return NULL; -} - -const char *debug_ctx_Unicode_AsUTF8AndSize(HPyContext *dctx, DHPy h, HPy_ssize_t *size) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - const char *ptr = HPyUnicode_AsUTF8AndSize(get_info(dctx)->uctx, DHPy_unwrap(dctx, h), size); - HPy_ssize_t data_size = 0; - if (ptr != NULL) { - data_size = size != NULL ? *size + 1 : (HPy_ssize_t) strlen(ptr) + 1; - } - return (const char *)protect_and_associate_data_ptr(h, (void *)ptr, data_size); -} - -const char *debug_ctx_Bytes_AsString(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh = DHPy_unwrap(dctx, h); - const char *ptr = HPyBytes_AsString(uctx, uh); - HPy_ssize_t data_size = 0; - if (ptr != NULL) { - // '+ 1' accountd for the implicit null byte termination - data_size = HPyBytes_Size(uctx, uh) + 1; - } - return (const char *)protect_and_associate_data_ptr(h, (void *)ptr, data_size); -} - -const char *debug_ctx_Bytes_AS_STRING(HPyContext *dctx, DHPy h) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh = DHPy_unwrap(dctx, h); - const char *ptr = HPyBytes_AS_STRING(uctx, uh); - HPy_ssize_t data_size = 0; - if (ptr != NULL) { - // '+ 1' accountd for the implicit null byte termination - data_size = HPyBytes_GET_SIZE(uctx, uh) + 1; - } - return (const char *)protect_and_associate_data_ptr(h, (void *)ptr, data_size); -} - -DHPy debug_ctx_Tuple_FromArray(HPyContext *dctx, DHPy dh_items[], HPy_ssize_t n) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - UHPy *uh_items = (UHPy *)alloca(n * sizeof(UHPy)); - for(int i=0; iuctx, uh_items, n)); -} - -DHPy debug_ctx_Type_GenericNew(HPyContext *dctx, DHPy dh_type, const DHPy *dh_args, - HPy_ssize_t nargs, DHPy dh_kw) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - UHPy uh_type = DHPy_unwrap(dctx, dh_type); - UHPy uh_kw = DHPy_unwrap(dctx, dh_kw); - UHPy *uh_args = (UHPy *)alloca(nargs * sizeof(UHPy)); - for(int i=0; iis_valid = false; - HPy uh_result = HPyType_GenericNew(get_info(dctx)->uctx, uh_type, uh_args, - nargs, uh_kw); - DHPy dh_result = DHPy_open(dctx, uh_result); - get_ctx_info(dctx)->is_valid = true; - return dh_result; -} - -DHPy debug_ctx_Type_FromSpec(HPyContext *dctx, HPyType_Spec *spec, HPyType_SpecParam *dparams) -{ - if (!get_ctx_info(dctx)->is_valid) { - report_invalid_debug_context(); - } - // dparams might contain some hidden DHPy: we need to manually unwrap them. - if (dparams != NULL) { - // count the params - HPy_ssize_t n = 1; - for (HPyType_SpecParam *p = dparams; p->kind != 0; p++) { - n++; - } - HPyType_SpecParam *uparams = (HPyType_SpecParam *)alloca(n * sizeof(HPyType_SpecParam)); - for (HPy_ssize_t i=0; iuctx, spec, uparams)); - } - return DHPy_open(dctx, HPyType_FromSpec(get_info(dctx)->uctx, spec, NULL)); -} - -static const char *get_builtin_shape_name(HPyType_BuiltinShape shape) -{ -#define SHAPE_NAME(SHAPE) \ - case SHAPE: \ - return #SHAPE; \ - - /* Note: we use a switch here because then the compiler will warn us about - missing cases if shapes are added to enum 'HPyType_BuiltinShape' */ - switch (shape) - { - SHAPE_NAME(HPyType_BuiltinShape_Legacy) - SHAPE_NAME(HPyType_BuiltinShape_Object) - SHAPE_NAME(HPyType_BuiltinShape_Type) - SHAPE_NAME(HPyType_BuiltinShape_Long) - SHAPE_NAME(HPyType_BuiltinShape_Float) - SHAPE_NAME(HPyType_BuiltinShape_Unicode) - SHAPE_NAME(HPyType_BuiltinShape_Tuple) - SHAPE_NAME(HPyType_BuiltinShape_List) - } - return ""; -#undef SHAPE_NAME -} - -#define MAKE_debug_ctx_AsStruct(SHAPE) \ - void *debug_ctx_AsStruct_##SHAPE(HPyContext *dctx, DHPy dh) \ - { \ - if (!get_ctx_info(dctx)->is_valid) { \ - report_invalid_debug_context(); \ - } \ - HPyContext *uctx = get_info(dctx)->uctx; \ - UHPy uh = DHPy_unwrap(dctx, dh); \ - UHPy uh_type = HPy_Type(uctx, uh); \ - HPyType_BuiltinShape actual_shape = _HPyType_GetBuiltinShape(uctx, uh_type); \ - HPy_Close(uctx, uh_type); \ - if (actual_shape != HPyType_BuiltinShape_##SHAPE) { \ - const char *actual_shape_name = get_builtin_shape_name(actual_shape); \ - static const char *fmt = "Invalid usage of _HPy_AsStruct_%s" \ - ". Expected shape HPyType_BuiltinShape_%s but got %s"; \ - size_t nbuf = strlen(fmt) + 2 * strlen(#SHAPE) + strlen(actual_shape_name) + 1; \ - char *buf = (char *)alloca(nbuf); \ - snprintf(buf, nbuf, fmt, #SHAPE, #SHAPE, actual_shape_name); \ - HPy_FatalError(uctx, buf); \ - } \ - return _HPy_AsStruct_##SHAPE(uctx, uh); \ - } - -MAKE_debug_ctx_AsStruct(Legacy) - -MAKE_debug_ctx_AsStruct(Object) - -MAKE_debug_ctx_AsStruct(Type) - -MAKE_debug_ctx_AsStruct(Long) - -MAKE_debug_ctx_AsStruct(Float) - -MAKE_debug_ctx_AsStruct(Unicode) - -MAKE_debug_ctx_AsStruct(Tuple) - -MAKE_debug_ctx_AsStruct(List) - -/* ~~~ debug mode implementation of HPyTracker ~~~ */ -/* MOVED TO file 'debug_ctx_tracker.c' */ - -HPyListBuilder debug_ctx_ListBuilder_New(HPyContext *dctx, HPy_ssize_t size) -{ - return DHPyListBuilder_open(dctx, HPyListBuilder_New(get_info(dctx)->uctx, size)); -} - -void debug_ctx_ListBuilder_Set(HPyContext *dctx, HPyListBuilder builder, HPy_ssize_t index, DHPy h_item) -{ - HPyListBuilder_Set(get_info(dctx)->uctx, DHPyListBuilder_unwrap(dctx, builder), index, DHPy_unwrap(dctx, h_item)); -} - -DHPy debug_ctx_ListBuilder_Build(HPyContext *dctx, HPyListBuilder dh_builder) -{ - DebugBuilderHandle *handle = DHPyListBuilder_as_DebugBuilderHandle(dh_builder); - if (handle == NULL) - return HPy_NULL; - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh_result = HPyListBuilder_Build(uctx, DHPyListBuilder_unwrap(dctx, dh_builder)); - DHPy_builder_handle_close(dctx, handle); - return DHPy_open(dctx, uh_result); -} - -void debug_ctx_ListBuilder_Cancel(HPyContext *dctx, HPyListBuilder dh_builder) -{ - DebugBuilderHandle *handle = DHPyListBuilder_as_DebugBuilderHandle(dh_builder); - if (handle == NULL) - return; - HPyContext *uctx = get_info(dctx)->uctx; - HPyListBuilder_Cancel(uctx, DHPyListBuilder_unwrap(dctx, dh_builder)); - DHPy_builder_handle_close(dctx, handle); -} - -HPyTupleBuilder debug_ctx_TupleBuilder_New(HPyContext *dctx, HPy_ssize_t size) -{ - return DHPyTupleBuilder_open(dctx, HPyTupleBuilder_New(get_info(dctx)->uctx, size)); -} - -void debug_ctx_TupleBuilder_Set(HPyContext *dctx, HPyTupleBuilder builder, HPy_ssize_t index, DHPy h_item) -{ - HPyTupleBuilder_Set(get_info(dctx)->uctx, DHPyTupleBuilder_unwrap(dctx, builder), index, DHPy_unwrap(dctx, h_item)); -} - -DHPy debug_ctx_TupleBuilder_Build(HPyContext *dctx, HPyTupleBuilder dh_builder) -{ - DebugBuilderHandle *handle = DHPyTupleBuilder_as_DebugBuilderHandle(dh_builder); - if (handle == NULL) - return HPy_NULL; - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh_result = HPyTupleBuilder_Build(uctx, DHPyTupleBuilder_unwrap(dctx, dh_builder)); - DHPy_builder_handle_close(dctx, handle); - return DHPy_open(dctx, uh_result); -} - -void debug_ctx_TupleBuilder_Cancel(HPyContext *dctx, HPyTupleBuilder dh_builder) -{ - DebugBuilderHandle *handle = DHPyTupleBuilder_as_DebugBuilderHandle(dh_builder); - if (handle == NULL) - return; - HPyContext *uctx = get_info(dctx)->uctx; - HPyTupleBuilder_Cancel(uctx, DHPyTupleBuilder_unwrap(dctx, dh_builder)); - DHPy_builder_handle_close(dctx, handle); -} - -/* - However, we don't want to raise an exception if you pass a non-type, - because the CPython version (PyObject_TypeCheck) always succeed and it - would be too easy to forget to check the return value. We just raise a - fatal error instead. - */ -int debug_ctx_TypeCheck(HPyContext *dctx, DHPy obj, DHPy type) -{ - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh_obj = DHPy_unwrap(dctx, obj); - UHPy uh_type = DHPy_unwrap(dctx, type); - assert(!HPy_IsNull(uh_obj)); - assert(!HPy_IsNull(uh_type)); - if (!HPy_TypeCheck(uctx, uh_type, uctx->h_TypeType)) { - HPy_FatalError(uctx, "HPy_TypeCheck arg 2 must be a type"); - } - return HPy_TypeCheck(uctx, uh_obj, uh_type); -} - -int32_t debug_ctx_ContextVar_Get(HPyContext *dctx, DHPy context_var, DHPy default_value, DHPy *result) -{ - HPyContext *uctx = get_info(dctx)->uctx; - UHPy uh_context_var = DHPy_unwrap(dctx, context_var); - UHPy uh_default_value = DHPy_unwrap(dctx, default_value); - UHPy uh_result; - assert(!HPy_IsNull(uh_context_var)); - int32_t ret = HPyContextVar_Get(uctx, uh_context_var, uh_default_value, &uh_result); - if (ret < 0) { - *result = HPy_NULL; - return ret; - } - *result = DHPy_open(dctx, uh_result); - return ret; -} - -const char *debug_ctx_Type_GetName(HPyContext *dctx, DHPy type) -{ - HPyDebugCtxInfo *ctx_info; - HPyContext *uctx; - UHPy uh_type; - HPy_ssize_t n_name; - - ctx_info = get_ctx_info(dctx); - if (!ctx_info->is_valid) { - report_invalid_debug_context(); - } - uh_type = DHPy_unwrap(dctx, type); - uctx = ctx_info->info->uctx; - if (!HPy_TypeCheck(uctx, uh_type, uctx->h_TypeType)) { - HPy_FatalError(uctx, "HPyType_GetName arg must be a type"); - } - ctx_info->is_valid = false; - const char *name = HPyType_GetName(uctx, uh_type); - ctx_info->is_valid = true; - n_name = strlen(name) + 1; - return (const char *)protect_and_associate_data_ptr(type, (void *)name, n_name); -} - -int debug_ctx_Type_IsSubtype(HPyContext *dctx, DHPy sub, DHPy type) -{ - HPyDebugCtxInfo *ctx_info; - HPyContext *uctx; - int res; - - ctx_info = get_ctx_info(dctx); - if (!ctx_info->is_valid) { - report_invalid_debug_context(); - } - - UHPy uh_sub = DHPy_unwrap(dctx, sub); - uctx = ctx_info->info->uctx; - if (!HPy_TypeCheck(uctx, uh_sub, uctx->h_TypeType)) { - HPy_FatalError(uctx, "HPyType_IsSubtype arg 1 must be a type"); - } - UHPy uh_type = DHPy_unwrap(dctx, type); - if (!HPy_TypeCheck(uctx, uh_type, uctx->h_TypeType)) { - HPy_FatalError(uctx, "HPyType_IsSubtype arg 2 must be a type"); - } - - ctx_info->is_valid = false; - res = HPyType_IsSubtype(uctx, uh_sub, uh_type); - ctx_info->is_valid = true; - return res; -} - -DHPy debug_ctx_Unicode_Substring(HPyContext *dctx, DHPy str, HPy_ssize_t start, HPy_ssize_t end) -{ - HPyDebugCtxInfo *ctx_info; - HPyContext *uctx; - - ctx_info = get_ctx_info(dctx); - if (!ctx_info->is_valid) { - report_invalid_debug_context(); - } - - HPy uh_str = DHPy_unwrap(dctx, str); - uctx = ctx_info->info->uctx; - if (!HPy_TypeCheck(uctx, uh_str, uctx->h_UnicodeType)) { - HPy_FatalError(uctx, "HPyUnicode_Substring arg 1 must be a Unicode object"); - } - ctx_info->is_valid = false; - HPy universal_result = HPyUnicode_Substring(uctx, uh_str, start, end); - ctx_info->is_valid = true; - return DHPy_open(dctx, universal_result); -} - -DHPy debug_ctx_Call(HPyContext *dctx, DHPy dh_callable, const DHPy *dh_args, size_t nargs, DHPy dh_kwnames) -{ - HPyDebugCtxInfo *ctx_info; - HPyContext *uctx; - - ctx_info = get_ctx_info(dctx); - if (!ctx_info->is_valid) { - report_invalid_debug_context(); - } - - UHPy uh_callable = DHPy_unwrap(dctx, dh_callable); - UHPy uh_kwnames = DHPy_unwrap(dctx, dh_kwnames); - uctx = ctx_info->info->uctx; - HPy_ssize_t nkw; - if (!HPy_IsNull(uh_kwnames)) { - if (!HPyTuple_Check(uctx, uh_kwnames)) { - HPy_FatalError(uctx, "HPy_Call arg 'kwnames' must be a tuple object or HPy_NULL"); - } - nkw = HPy_Length(uctx, uh_kwnames); - if (nkw < 0) { - return HPy_NULL; - } - } else { - nkw = 0; - } - const size_t n_all_args = nargs + nkw; - UHPy *uh_args = (UHPy *)alloca(n_all_args * sizeof(UHPy)); - for(size_t i=0; i < n_all_args; i++) { - uh_args[i] = DHPy_unwrap(dctx, dh_args[i]); - } - ctx_info->is_valid = false; - DHPy dh_result = DHPy_open(dctx, HPy_Call(uctx, uh_callable, uh_args, nargs, uh_kwnames)); - ctx_info->is_valid = true; - return dh_result; -} - -DHPy debug_ctx_CallMethod(HPyContext *dctx, DHPy dh_name, const DHPy *dh_args, size_t nargs, DHPy dh_kwnames) -{ - HPyDebugCtxInfo *ctx_info; - HPyContext *uctx; - - ctx_info = get_ctx_info(dctx); - if (!ctx_info->is_valid) { - report_invalid_debug_context(); - } - - UHPy uh_name = DHPy_unwrap(dctx, dh_name); - UHPy uh_kwnames = DHPy_unwrap(dctx, dh_kwnames); - uctx = ctx_info->info->uctx; - HPy_ssize_t nkw; - if (!HPy_IsNull(uh_kwnames)) { - if (!HPyTuple_Check(uctx, uh_kwnames)) { - HPy_FatalError(uctx, "HPy_CallMethod arg 'kwnames' must be a tuple object or HPy_NULL"); - } - nkw = HPy_Length(uctx, uh_kwnames); - if (nkw < 0) { - return HPy_NULL; - } - } else { - nkw = 0; - } - const size_t n_all_args = nargs + nkw; - UHPy *uh_args = (UHPy *)alloca(n_all_args * sizeof(UHPy)); - for(size_t i=0; i < n_all_args; i++) { - uh_args[i] = DHPy_unwrap(dctx, dh_args[i]); - } - ctx_info->is_valid = false; - DHPy dh_result = DHPy_open(dctx, HPy_CallMethod(uctx, uh_name, uh_args, nargs, uh_kwnames)); - ctx_info->is_valid = true; - return dh_result; -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_not_cpython.c b/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_not_cpython.c deleted file mode 100644 index a1a5815413..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_not_cpython.c +++ /dev/null @@ -1,40 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -// This is for non-CPython implementations! -// -// If you want to bundle the debug mode into your own version of -// hpy.universal, make sure to compile this file and NOT debug_ctx_cpython.c - -#include "debug_internal.h" - -void debug_ctx_CallRealFunctionFromTrampoline(HPyContext *dctx, - HPyFunc_Signature sig, - void *func, void *args) -{ - HPyContext *uctx = get_info(dctx)->uctx; - HPy_FatalError(uctx, - "Something is very wrong! _HPy_CallRealFunctionFromTrampoline() " - "should be used only by the CPython version of hpy.universal"); -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_tracker.c b/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_tracker.c deleted file mode 100644 index e635238c1f..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/debug_ctx_tracker.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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. - */ - -#include "debug_internal.h" -#include "../hpy_jni.h" - -/* ~~~ debug mode implementation of HPyTracker ~~~ - - This is a bit special and it's worth explaining what is going on. - - The HPyTracker functions need their own debug mode implementation because - the debug mode needs to be aware of when a DHPy is closed, for the same - reason for why we need debug_ctx_Close. - - So, in theory here we should have our own implementation of a - DebugHPyTracker which manages a growable list of handles, and which calls - debug_ctx_Close at the end. But, we ALREADY have the logic available, it's - implemented in ctx_tracker.c. - - So, we can share some functions but note that the tracker will not store - universal handles but debug handles. - - Since we already have some special (and faster) implementation for - 'ctx_Tracker_Add' and 'ctx_Tracker_Close', we need to have a separate debug - mode implementation for them. -*/ - -HPyTracker debug_ctx_Tracker_New(HPyContext *dctx, HPy_ssize_t size) -{ - return ctx_Tracker_New_jni(dctx, size); -} - -_HPy_HIDDEN int -debug_ctx_Tracker_Add(HPyContext *dctx, HPyTracker ht, DHPy h) -{ - return raw_Tracker_Add(dctx, ht, h); -} - -void debug_ctx_Tracker_ForgetAll(HPyContext *dctx, HPyTracker ht) -{ - ctx_Tracker_ForgetAll_jni(dctx, ht); -} - -_HPy_HIDDEN void -debug_ctx_Tracker_Close(HPyContext *ctx, HPyTracker ht) -{ - _HPyTracker_s *hp = _ht2hp(ht); - HPy_ssize_t i; - for (i=0; ilength; i++) { - HPy_Close(ctx, hp->handles[i]); - } - free(hp->handles); - free(hp); -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/debug_handles.c b/graalpython/com.oracle.graal.python.jni/src/debug/debug_handles.c deleted file mode 100644 index aaca064244..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/debug_handles.c +++ /dev/null @@ -1,322 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include -#include "debug_internal.h" - -static void debug_handles_sanity_check(HPyDebugInfo *info) -{ -#ifndef NDEBUG - DHQueue_sanity_check(&info->open_handles); - DHQueue_sanity_check(&info->closed_handles); - DebugHandle *h = (DebugHandle *)info->open_handles.head; - while(h != NULL) { - assert(!h->is_closed); - h = (DebugHandle *)h->node.next; - } - h = (DebugHandle *)info->closed_handles.head; - while(h != NULL) { - assert(h->is_closed); - h = (DebugHandle *)h->node.next; - } -#endif -} - -static void DebugHandle_free_raw_data(HPyDebugInfo *info, DebugHandle *handle, bool was_counted_in_limit) { - if (handle->associated_data) { - if (was_counted_in_limit) { - info->protected_raw_data_size -= handle->associated_data_size; - } - if (raw_data_free(handle->associated_data, handle->associated_data_size)) { - HPy_FatalError(info->uctx, "HPy could not free internally allocated memory."); - } - handle->associated_data = NULL; - } -} - -static DHPy _DHPy_open(HPyContext *dctx, UHPy uh, bool is_immortal) -{ - UHPy_sanity_check(uh); - if (HPy_IsNull(uh)) - return HPy_NULL; - HPyDebugInfo *info = get_info(dctx); - - // if the closed_handles queue is full, let's reuse one of those. Else, - // malloc a new one - DebugHandle *handle = NULL; - if (info->closed_handles.size >= info->closed_handles_queue_max_size) { - handle = (DebugHandle *)DHQueue_popfront(&info->closed_handles); - DebugHandle_free_raw_data(info, handle, true); - if (handle->allocation_stacktrace) - free(handle->allocation_stacktrace); - } - else { - handle = malloc(sizeof(DebugHandle)); - if (handle == NULL) { - return HPyErr_NoMemory(info->uctx); - } - } - if (info->handle_alloc_stacktrace_limit > 0) { - create_stacktrace(&handle->allocation_stacktrace, - info->handle_alloc_stacktrace_limit); - } else { - handle->allocation_stacktrace = NULL; - } - handle->uh = uh; - handle->generation = info->current_generation; - handle->is_closed = 0; - handle->is_immortal = is_immortal; - handle->associated_data = NULL; - handle->associated_data_size = 0; - DHQueue_append(&info->open_handles, (DHQueueNode *)handle); - debug_handles_sanity_check(info); - return as_DHPy(handle); -} - -DHPy DHPy_open_immortal(HPyContext *dctx, UHPy uh) { - return _DHPy_open(dctx, uh, true); -} - -DHPy DHPy_open(HPyContext *dctx, UHPy uh) -{ - return _DHPy_open(dctx, uh, false); -} - -static void print_error(HPyContext *uctx, const char *message) -{ - // We don't have a way to propagate exceptions from within DHPy_unwrap, so - // we just print the exception to stderr and clear it - // XXX: we should use HPySys_WriteStderr when we have it - fprintf(stderr, "%s\n", message); - //HPyErr_PrintEx(0); // uncomment when we have it -} - -static inline void -debug_call_invalid_callback(HPyContext *uctx, HPy h_callback) -{ - /* Call the custom callback but do NOT abort the execution. This is useful - e.g. on CPython where "closed handles" are still actually valid (as long - as the refcount > 0): it should make it easier to port extensions to HPy, - e.g. by printing a warning inside the callback and let the execution to - continue, so that people can fix the warnings one by one. - */ - UHPy uh_res = HPy_NULL; - uh_res = HPy_CallTupleDict(uctx, h_callback, HPy_NULL, HPy_NULL); - if (HPy_IsNull(uh_res)) - print_error(uctx, - "Error when executing the on_invalid_(builder_)handle callback"); - HPy_Close(uctx, uh_res); -} - -// this is called when we try to use a closed handle -void DHPy_invalid_handle(HPyContext *dctx, DHPy dh) -{ - HPyDebugInfo *info = get_info(dctx); - HPyContext *uctx = info->uctx; - assert(as_DebugHandle(dh)->is_closed || as_DebugHandle(dh)->is_immortal); - if (HPy_IsNull(info->uh_on_invalid_handle)) { - // default behavior: print an error and abort - HPy_FatalError(uctx, "Invalid usage of already closed handle"); - } - debug_call_invalid_callback(uctx, info->uh_on_invalid_handle); -} - -// DHPy_close, unlike debug_ctx_Close does not check the validity of the handle. -// Use this in case you want to close only the debug handle like DHPy_close, -// you but still want to check its validity -void DHPy_close_and_check(HPyContext *dctx, DHPy dh) { - DHPy_unwrap(dctx, dh); - DHPy_close(dctx, dh); -} - -// Note: the difference from just HPy_Close(dctx, dh), which calls debug_ctx_Close, -// is that this only closes the debug handle. This is useful in situations -// where we know that the wrapped handle will be closed by the wrapped context. -void DHPy_close(HPyContext *dctx, DHPy dh) -{ - DHPy_sanity_check(dh); - if (HPy_IsNull(dh)) - return; - HPyDebugInfo *info = get_info(dctx); - DebugHandle *handle = as_DebugHandle(dh); - - /* This check is needed for a very specific case: calling HPy_Close twice - on the same handle is considered an error, and by default the - DHPy_unwrap inside debug_ctx_Close catches the problem and abort the - process with a HPy_FatalError. - - However, we leave the possibility to the user to install a custom hook - to be called when we detect an invalid handle. In this case, the - process does not abort and the execution tries to continue. This is - more useful than what it sounds, because on CPython "closing a handle - twice" still works in practice as long as the refcount > 0. So, we can - install a hook which emits a warning and let the user to fix the - problems one by one, without aborting the process. - */ - if (handle->is_closed) - return; - - // Closing context constants is never allowed - if (handle->is_immortal) - DHPy_invalid_handle(dctx, dh); - - // move the handle from open_handles to closed_handles - DHQueue_remove(&info->open_handles, (DHQueueNode *)handle); - DHQueue_append(&info->closed_handles, (DHQueueNode *)handle); - handle->is_closed = true; - if (handle->associated_data) { - // So far all implementations of raw_data_protect keep the physical - // memory (or at least are not guaranteed to release it), which leaks. - // Ideally the raw_data_protect implementation would at least release - // the physical memory, but in any case it would still leak the virtual - // memory. To mitigate this a bit, we free the memory once the closed - // handle is removed from the closed handles queue (because it reaches - // max size), or if the total size of the retained/leaked memory would - // overflow configured limit. - HPy_ssize_t new_size = info->protected_raw_data_size + handle->associated_data_size; - if (new_size > info->protected_raw_data_max_size) { - // free it now - DebugHandle_free_raw_data(info, handle, false); - } else { - // keep/leak it and make it protected from further reading - info->protected_raw_data_size = new_size; - raw_data_protect(handle->associated_data, handle->associated_data_size); - } - } - - if (info->closed_handles.size > info->closed_handles_queue_max_size) { - // we have too many closed handles. Let's free the oldest one - DebugHandle *oldest = (DebugHandle *)DHQueue_popfront(&info->closed_handles); - DHPy_free(dctx, as_DHPy(oldest)); - } - debug_handles_sanity_check(info); -} - -void DHPy_free(HPyContext *dctx, DHPy dh) -{ - DHPy_sanity_check(dh); - DebugHandle *handle = as_DebugHandle(dh); - HPyDebugInfo *info = get_info(dctx); - DebugHandle_free_raw_data(info, handle, true); - if (handle->allocation_stacktrace) - free(handle->allocation_stacktrace); - // this is not strictly necessary, but it increases the chances that you - // get a clear segfault if you use a freed handle - handle->uh = HPy_NULL; - free(handle); -} - -static DebugBuilderHandle *debug_builder_handle_open(HPyContext *dctx) -{ - HPyDebugInfo *info = get_info(dctx); - - /* If the closed_builder queue is full, let's reuse one of those; otherwise, - malloc a new one. */ - DebugBuilderHandle *handle = NULL; - if (info->closed_builder.size >= info->closed_handles_queue_max_size) { - handle = (DebugBuilderHandle *)DHQueue_popfront(&info->closed_builder); - } - else { - handle = malloc(sizeof(DebugBuilderHandle)); - if (handle == NULL) { - /* To be consistent with the contract of - 'HPy(Tuple|List)Builder_New', don't raise an error here and defer - to the build function. */ - return NULL; - } - } - handle->is_closed = false; - /* If we want to track open builder handles, this would be the right place - to move append the new builder handle to the list of open ones. */ - return handle; -} - -/** - * Closes a ``DebugBuilderHandle`` which means that it is appended to the list - * of closed builder handles. If the list reached its maximum, the oldest - * builder handle will be free'd. Note, that the contained builder handle - * (i.e. ``UHPyTupleBuilder`` or ``UHPyListBuilder``) won't be closed since - * that will be done by the wrapped function. - */ -void DHPy_builder_handle_close(HPyContext *dctx, DebugBuilderHandle *handle) -{ - HPyDebugInfo *info; - - /* This check is needed for a very specific case: calling - DHPy_builder_handle_close twice on the same handle is considered an - error and by default the DHPy(Tuple|List)Builder_unwrap catches the - problem and aborts the process with a HPy_FatalError. - - However, we leave the possibility to the user to install a custom hook - to be called when we detect an invalid builder handle. In this case, the - process does not abort and the execution tries to continue. This is - more useful than what it sounds. So, we can install a hook which emits a - warning and let the user to fix the problems one by one, without - aborting the process. - */ - if (handle->is_closed) - return; - - handle->is_closed = true; - info = get_info(dctx); - /* If we want to track open builder handles, this would be the right place - to move the handle from 'open_handles' to 'closed_handles'. */ - DHQueue_append(&info->closed_builder, (DHQueueNode *)handle); - if (info->closed_builder.size > info->closed_handles_queue_max_size) { - // we have too many closed builder handles. Let's free the oldest one - DebugBuilderHandle *oldest = (DebugBuilderHandle *)DHQueue_popfront(&info->closed_builder); - free(oldest); - } -} - -DHPyTupleBuilder DHPyTupleBuilder_open(HPyContext *dctx, UHPyTupleBuilder uh) -{ - if (DHPyTupleBuilder_IsNull(uh)) - return DHPyTupleBuilder_NULL; - DebugBuilderHandle *handle = debug_builder_handle_open(dctx); - if (handle != NULL) - handle->uh.tuple_builder = uh; - return as_DHPyTupleBuilder(handle); -} - -DHPyListBuilder DHPyListBuilder_open(HPyContext *dctx, UHPyListBuilder uh) -{ - if (DHPyListBuilder_IsNull(uh)) - return DHPyListBuilder_NULL; - DebugBuilderHandle *handle = debug_builder_handle_open(dctx); - if (handle != NULL) - handle->uh.list_builder = uh; - return as_DHPyListBuilder(handle); -} - -void DHPy_invalid_builder_handle(HPyContext *dctx) -{ - HPyDebugInfo *info = get_info(dctx); - HPyContext *uctx = info->uctx; - if (HPy_IsNull(info->uh_on_invalid_builder_handle)) { - // default behavior: print an error and abort - HPy_FatalError(uctx, "Invalid usage of already closed builder"); - } - debug_call_invalid_callback(uctx, info->uh_on_invalid_builder_handle); -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/debug_internal.h b/graalpython/com.oracle.graal.python.jni/src/debug/debug_internal.h deleted file mode 100644 index d56861e426..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/debug_internal.h +++ /dev/null @@ -1,383 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/* Internal header for all the files in hpy/debug/src. The public API is in - include/hpy_debug.h -*/ -#ifndef HPY_DEBUG_INTERNAL_H -#define HPY_DEBUG_INTERNAL_H - -#include -#include "hpy.h" -#include "hpy_debug.h" - -#define HPY_DEBUG_INFO_MAGIC 0xDEB00FF -#define HPY_DEBUG_CTX_INFO_MAGIC 0xDDA003F - -/* === DHQueue === */ - -/** - * This struct is meant to be embedded in the actual payload struct to avoid - * a separate allocation of the queue node. - */ -typedef struct _DHQueueNode_s { - struct _DHQueueNode_s *next; - struct _DHQueueNode_s *prev; - HPy_ssize_t size; -} DHQueueNode; - -typedef struct { - DHQueueNode *head; - DHQueueNode *tail; - HPy_ssize_t size; -} DHQueue; - -void DHQueue_init(DHQueue *q); -void DHQueue_append(DHQueue *q, DHQueueNode *h); -DHQueueNode *DHQueue_popfront(DHQueue *q); -void DHQueue_remove(DHQueue *q, DHQueueNode *h); -void DHQueue_sanity_check(DHQueue *q); - -/* === DHQueue === */ - -/* The Debug context is a wrapper around an underlying context, which we will - call Universal. Inside the debug mode we manipulate handles which belongs - to both contexts, so to make things easier we create two typedefs to make - it clear what kind of handle we expect: UHPy and DHPy: - - * UHPy are opaque from our point of view. - - * DHPy are actually DebugHandle* in disguise. DebugHandles are wrappers - around a UHPy, with a bunch of extra info. - - To cast between DHPy and DebugHandle*, use as_DebugHandle and as_DHPy: - these are just no-op casts. - - Each DHPy wraps a corresponding UHPy: DHPys are created by calling - DHPy_open, and they must be eventually closed by DHPy_close. Note that if - you call DHPy_open twice on the same UHPy, you get two different DHPy. - - To unwrap a DHPy and get the underlying UHPy, call DHPy_unwrap. If you call - DHPy_unwrap multiple times on the same DHPy, you always get the same UHPy. - - WARNING: both UHPy and DHPy are alias of HPy, so we need to take care of - not mixing them, because the compiler cannot help. - - Each DebugHandle has a "generation", which is just an int to be able to get - only the handles which were created after a certain point. - - DHPys/DebugHandles are memory-managed by using a free list: - - - info->open_handles is a list of all DHPys which are currently open - - - DHPy_close() moves a DHPy from info->open_handles to info->closed_handles - - - if closed_handles is too big, the oldest DHPy is freed by DHPy_free() - - - to allocate memory for a new DHPy, DHPy_open() does the following: - - * if closed_handles is full, it reuses the memory of the oldest DHPy - in the queue - - * else, it malloc()s memory for a new DHPy - - - Each DebugHandle can have some "raw" data associated with it. It is a - generic pointer to any data. The validity, or life-time, of such pointer - is supposed to be the same as the that of the handle and the debug mode - enforces it. Additionally, the data can be also marked as write protected. - - Example is the `const char*` handed out by `HPyUnicode_AsUTF8AndSize`. It - must not be written by the user (users may discard the const modifier), and - the pointer is considered invalid once the handle is closed, so it must not - be accessed even for reading. Most Python implementations, will choose to - hand out pointer to the actual internal data, which happen to stay valid and - accessible and this may lead the users to a wrong conclusion that they can - use the pointer after the handle is closed. - - The memory protection mechanism is abstracted by several functions that - may have different implementations depending on the compile-time - configuration. Those are: - - * `raw_data_copy`: makes a copy of some data, optionally the copy can be - made read-only. - * `raw_data_protect`: protects the result of `raw_data_copy` from reading - * `raw_data_free`: if `raw_data_protect` retained any actual memory or other - resources, this indicates that those can be freed - - Any HPy context function that wishes to attach raw data to a handle should - make a copy of the actual data by using `raw_data_copy`. This copy should be - then set as the value of the associated_data field. Once the handle is - closed, the raw data pointer is passed to raw_data_protect and once the handle - is reused the raw data pointer is passed to raw_data_free. - - This means that if the implementation of `raw_data_protect` retains some - resources, we are leaking them. To mitigate this a bit, we have a limit on the - overall size of data that can be leaked and once it is reached, we use - raw_data_free immediately once the associated handle is closed. - - Note that, for example, the mmap based implementation of `raw_data_copy` - never allocates less than a page, so it actually takes more memory than - what is the size of the raw data. This is, however, mostly covered by the - limit on closed handles. For the default configuration we have: - - DEFAULT_CLOSED_HANDLES_QUEUE_MAX_SIZE = 1024 - DEFAULT_PROTECTED_RAW_DATA_MAX_SIZE = 1024 * 1024 * 10 - - the total leaked raw data size limit of 10MB is larger than if we created - and leaked 1024 handles with only a small raw data attached to them (4MB - for 1024 pages of 4KB). This ratio may be different for larger pages or for - different configuration of the limits. For the sake of keeping the - implementation reasonably simple and portable, we choose to ignore this - for the time being. -*/ - -typedef HPy UHPy; -typedef HPy DHPy; -typedef HPyTupleBuilder UHPyTupleBuilder; -typedef HPyTupleBuilder DHPyTupleBuilder; -typedef HPyListBuilder UHPyListBuilder; -typedef HPyListBuilder DHPyListBuilder; - -#define DHPyTupleBuilder_IsNull(h) ((h)._tup == 0) -#define DHPyListBuilder_IsNull(h) ((h)._lst == 0) - -#if defined(_MSC_VER) && defined(__cplusplus) // MSVC C4576 -# define UHPyListBuilder_NULL {0} -# define UHPyTupleBuilder_NULL {0} -# define DHPyListBuilder_NULL UHPyListBuilder_NULL -# define DHPyTupleBuilder_NULL UHPyTupleBuilder_NULL -#else -# define UHPyListBuilder_NULL ((UHPyListBuilder){0}) -# define UHPyTupleBuilder_NULL ((UHPyTupleBuilder){0}) -# define DHPyListBuilder_NULL ((DHPyListBuilder){0}) -# define DHPyTupleBuilder_NULL ((DHPyTupleBuilder){0}) -#endif - -/* Under CPython: - - UHPy always end with 1 (see hpy.universal's _py2h and _h2py) - - DHPy are pointers, so they always end with 0 - - DHPy_sanity_check is a minimal check to ensure that we are not treating a - UHPy as a DHPy. Note that DHPy_sanity_check works fine also on HPy_NULL. - - NOTE: UHPy_sanity_check works ONLY with CPython's hpy.universal, because - UHPys are computed in such a way that the last bit it's always 1. On other - implementations this assumption might not hold. By default, - UHPy_sanity_check does nothing, unless you #define - HPY_DEBUG_ENABLE_UHPY_SANITY_CHECK, which for CPython is done by setup.py -*/ -static inline void DHPy_sanity_check(DHPy dh) { - assert( (dh._i & 1) == 0 ); -} - -static inline void UHPy_sanity_check(UHPy uh) { -#ifdef HPY_DEBUG_ENABLE_UHPY_SANITY_CHECK - if (!HPy_IsNull(uh)) - assert( (uh._i & 1) == 1 ); -#endif -} - -// NOTE: having a "generation" field is the easiest way to know when a handle -// was created, but we waste 8 bytes per handle. Since all handles of the same -// generation are stored sequentially in the open_handles list, a possible -// alternative implementation is to put special placeholders inside the list -// to mark the creation of a new generation -typedef struct DebugHandle { - DHQueueNode node; - UHPy uh; - long generation; - bool is_closed:1; - bool is_immortal:1; - // pointer to and size of any raw data associated with - // the lifetime of the handle: - void *associated_data; - // allocation_stacktrace information if available - char *allocation_stacktrace; - HPy_ssize_t associated_data_size; -} DebugHandle; - -/** A debug handle for a tuple or list builder. */ -typedef struct DebugBuilderHandle { - DHQueueNode node; - union { - UHPyTupleBuilder tuple_builder; - UHPyListBuilder list_builder; - } uh; - - /** - * ``true`` if the builder was consumed by the build function or cancelled. - */ - bool is_closed:1; -} DebugBuilderHandle; - -static inline DebugHandle * as_DebugHandle(DHPy dh) { - DHPy_sanity_check(dh); - return (DebugHandle *)dh._i; -} - -static inline DHPy as_DHPy(DebugHandle *handle) { - return (DHPy){(HPy_ssize_t)handle}; -} - -static inline DebugBuilderHandle * DHPyTupleBuilder_as_DebugBuilderHandle(DHPyTupleBuilder dh) { - if (DHPyTupleBuilder_IsNull(dh)) - return NULL; - return (DebugBuilderHandle *)dh._tup; -} - -static inline DHPyTupleBuilder as_DHPyTupleBuilder(DebugBuilderHandle *handle) { - return (DHPyTupleBuilder){(HPy_ssize_t)handle}; -} - -static inline DebugBuilderHandle * DHPyListBuilder_as_DebugBuilderHandle(DHPyListBuilder dh) { - if (DHPyListBuilder_IsNull(dh)) - return NULL; - return (DebugBuilderHandle *)dh._lst; -} - -static inline DHPyListBuilder as_DHPyListBuilder(DebugBuilderHandle *handle) { - return (DHPyListBuilder){(HPy_ssize_t)handle}; -} - -DHPy DHPy_open(HPyContext *dctx, UHPy uh); -DHPy DHPy_open_immortal(HPyContext *dctx, UHPy uh); -void DHPy_close(HPyContext *dctx, DHPy dh); -void DHPy_close_and_check(HPyContext *dctx, DHPy dh); -void DHPy_free(HPyContext *dctx, DHPy dh); -void DHPy_invalid_handle(HPyContext *dctx, DHPy dh); -DHPyTupleBuilder DHPyTupleBuilder_open(HPyContext *dctx, UHPyTupleBuilder uh); -DHPyListBuilder DHPyListBuilder_open(HPyContext *dctx, UHPyListBuilder uh); -void DHPy_invalid_builder_handle(HPyContext *dctx); -void DHPy_builder_handle_close(HPyContext *dctx, DebugBuilderHandle *handle); - -static inline UHPy DHPy_unwrap(HPyContext *dctx, DHPy dh) -{ - if (HPy_IsNull(dh)) - return HPy_NULL; - DebugHandle *handle = as_DebugHandle(dh); - if (handle->is_closed) - DHPy_invalid_handle(dctx, dh); - return handle->uh; -} - -#define BUILDER_UNWRAP(TYPE, ACCESS) \ - static inline U##TYPE D##TYPE##_unwrap(HPyContext *dctx, D##TYPE dh) \ - { \ - DebugBuilderHandle *handle = D##TYPE##_as_DebugBuilderHandle(dh); \ - if (handle == NULL) \ - return U##TYPE##_NULL; \ - if (handle->is_closed) { \ - DHPy_invalid_builder_handle(dctx); \ - return U##TYPE##_NULL; \ - } \ - return handle->uh.ACCESS; \ - } - -BUILDER_UNWRAP(HPyTupleBuilder, tuple_builder) -BUILDER_UNWRAP(HPyListBuilder, list_builder) - -/* === HPyDebugInfo === */ - -static const HPy_ssize_t DEFAULT_CLOSED_HANDLES_QUEUE_MAX_SIZE = 1024; -static const HPy_ssize_t DEFAULT_PROTECTED_RAW_DATA_MAX_SIZE = 1024 * 1024 * 10; -static const HPy_ssize_t HPY_DEBUG_DEFAULT_STACKTRACE_LIMIT = 16; -#define HPY_DEBUG_CTX_CACHE_SIZE 16 // Keep in sync with test_context_reuse.py - -// We intentionally create multiple HPyContext instances to check that -// the extension is not relying on the HPyContext identity. Before bouncing -// to HPy function in the CallRealFunctionFromTrampoline, we take next debug -// context copy from a circular buffer and mark the current one as invalid. -// -// HPyDebugInfo: represents meta-data shared between all the copies of the -// debug context. -// -// HPyDebugCtxInfo represents meta-data specific to each debug context -// instance. At this point it is main flag is_valid that is checked by all -// the context functions as the first thing. - -typedef struct { - long magic_number; // used just for sanity checks - HPyContext *uctx; - long current_generation; - - // Array of cached debug contexts used as a circular buffer - HPyContext *dctx_cache[HPY_DEBUG_CTX_CACHE_SIZE]; - size_t dctx_cache_current_index; - - // the following should be an HPyField, but it's complicate: - // HPyFields should be used only on memory which is known by the GC, which - // happens automatically if you use e.g. HPy_New, but currently - // HPy_DebugInfo is malloced(). We need either: - // 1. a generic HPy_GcMalloc() OR - // 2. HPy_{Un}TrackMemory(), so that we can add manually allocated - // memory as a GC root - // Alternative is to put it into a module state or to put it into HPyGlobal - // once those features are implemented - UHPy uh_on_invalid_handle; - UHPy uh_on_invalid_builder_handle; - HPy_ssize_t closed_handles_queue_max_size; // configurable by the user - HPy_ssize_t protected_raw_data_max_size; - HPy_ssize_t protected_raw_data_size; - // Limit for the stack traces captured for allocated handles - // Value 0 implies that stack traces should not be captured - HPy_ssize_t handle_alloc_stacktrace_limit; - DHQueue open_handles; - DHQueue closed_handles; - DHQueue closed_builder; -} HPyDebugInfo; - -typedef struct { - long magic_number; // used just for sanity checks - bool is_valid; - HPyDebugInfo *info; -} HPyDebugCtxInfo; - -static inline HPyDebugCtxInfo *get_ctx_info(HPyContext *dctx) -{ - HPyDebugCtxInfo *info = (HPyDebugCtxInfo*)dctx->_private; - assert(info->magic_number == HPY_DEBUG_CTX_INFO_MAGIC); // sanity check - return info; -} - -static inline HPyDebugInfo *get_info(HPyContext *dctx) -{ - HPyDebugInfo *info = get_ctx_info(dctx)->info; - assert(info->magic_number == HPY_DEBUG_INFO_MAGIC); // sanity check - return info; -} - - -HPyContext* hpy_debug_get_next_dctx_from_cache(HPyContext *dctx); - -void report_invalid_debug_context(); - -void *raw_data_copy(const void* data, HPy_ssize_t size, bool write_protect); -void raw_data_protect(void* data, HPy_ssize_t size); -/* Return value: 0 indicates success, any different value indicates an error */ -int raw_data_free(void *data, HPy_ssize_t size); - -void create_stacktrace(char **target, HPy_ssize_t max_frames_count); - -#endif /* HPY_DEBUG_INTERNAL_H */ diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/dhqueue.c b/graalpython/com.oracle.graal.python.jni/src/debug/dhqueue.c deleted file mode 100644 index e6875aabca..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/dhqueue.c +++ /dev/null @@ -1,145 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include "debug_internal.h" - -// TODO: we need to make DHQueue thread-safe if we want to use the same -// context in multiple threads -void DHQueue_init(DHQueue *q) { - q->head = NULL; - q->tail = NULL; - q->size = 0; -} - -void DHQueue_append(DHQueue *q, DHQueueNode *h) { - if (q->head == NULL) { - h->prev = NULL; - h->next = NULL; - q->head = h; - q->tail = h; - } else { - h->next = NULL; - h->prev = q->tail; - q->tail->next = h; - q->tail = h; - } - q->size++; -} - -DHQueueNode *DHQueue_popfront(DHQueue *q) -{ - assert(q->size > 0); - assert(q->head != NULL); - DHQueueNode *head = q->head; - if (q->size == 1) { - q->head = NULL; - q->tail = NULL; - q->size = 0; - } - else { - q->head = head->next; - q->head->prev = NULL; - q->size--; - } - // the following is not strictly necessary, but it makes thing much easier - // to debug in case of bugs - head->next = NULL; - head->prev = NULL; - return head; -} - -void DHQueue_remove(DHQueue *q, DHQueueNode *h) -{ -#ifndef NDEBUG - // if we are debugging, let's check that h is effectively in the queue - DHQueueNode *it = q->head; - bool found = false; - while(it != NULL) { - if (it == h) { - found = true; - break; - } - it = it->next; - } - assert(found); -#endif - if (q->size == 1) { - q->head = NULL; - q->tail = NULL; - } else if (h == q->head) { - assert(h->prev == NULL); - q->head = h->next; - q->head->prev = NULL; - } else if (h == q->tail) { - assert(h->next == NULL); - q->tail = h->prev; - q->tail->next = NULL; - } - else { - h->prev->next = h->next; - h->next->prev = h->prev; - } - q->size--; - h->next = NULL; - h->prev = NULL; -} - - -#ifndef NDEBUG -static void linked_item_sanity_check(DHQueueNode *h) -{ - if (h == NULL) - return; - if (h->next != NULL) - assert(h->next->prev == h); - if (h->prev != NULL) - assert(h->prev->next == h); -} -#endif - -void DHQueue_sanity_check(DHQueue *q) -{ -#ifndef NDEBUG - if (q->head == NULL || q->tail == NULL) { - assert(q->head == NULL); - assert(q->tail == NULL); - assert(q->size == 0); - } - else { - assert(q->head->prev == NULL); - assert(q->tail->next == NULL); - assert(q->size > 0); - DHQueueNode *h = q->head; - HPy_ssize_t size = 0; - while(h != NULL) { - linked_item_sanity_check(h); - if (h->next == NULL) - assert(h == q->tail); - h = h->next; - size++; - } - assert(q->size == size); - } -#endif -} diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/hpy_debug.h b/graalpython/com.oracle.graal.python.jni/src/debug/hpy_debug.h deleted file mode 100644 index aab3701176..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/hpy_debug.h +++ /dev/null @@ -1,81 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_DEBUG_H -#define HPY_DEBUG_H - -#include "hpy.h" - -/* - This is the main public API for the debug mode, and it's meant to be used - by hpy.universal implementations (including but not limited to the - CPython's version of hpy.universal which is included in this repo). - - The idea is that for every uctx there is a corresponding unique dctx which - wraps it. - - If you call hpy_debug_get_ctx twice on the same uctx, you get the same - result. - - IMPLEMENTATION NOTE: at the moment of writing, the only known user of the - debug mode is CPython's hpy.universal: in that module, the uctx is a - statically allocated singleton, so for simplicity of implementation - currently we do the same inside debug_ctx.c, with a sanity check to ensure - that we don't call hpy_debug_get_ctx with different uctxs. But this is a - limitation of the current implementation and users should not rely on it. It - is likely that we will need to change it in the future, e.g. if we want to - have per-subinterpreter uctxs. -*/ - -HPyContext * hpy_debug_get_ctx(HPyContext *uctx); -int hpy_debug_ctx_init(HPyContext *dctx, HPyContext *uctx); -void hpy_debug_set_ctx(HPyContext *dctx); - -// convert between debug and universal handles. These are basically -// the same as DHPy_open and DHPy_unwrap but with a different name -// because this is the public-facing API and DHPy/UHPy are only internal -// implementation details. -HPy hpy_debug_open_handle(HPyContext *dctx, HPy uh); -HPy hpy_debug_unwrap_handle(HPyContext *dctx, HPy dh); -void hpy_debug_close_handle(HPyContext *dctx, HPy dh); - -// this is the HPy init function created by HPy_MODINIT. In CPython's version -// of hpy.universal the code is embedded inside the extension, so we can call -// this function directly instead of dlopen it. This is similar to what -// CPython does for its own built-in modules. But we must use the same -// signature as HPy_MODINIT - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -HPyModuleDef* HPyInit__debug(); - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -void HPyInitGlobalContext__debug(HPyContext *ctx); - -#endif /* HPY_DEBUG_H */ diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/include/hpy_debug.h b/graalpython/com.oracle.graal.python.jni/src/debug/include/hpy_debug.h deleted file mode 100644 index 858cf5960b..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/include/hpy_debug.h +++ /dev/null @@ -1,81 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_DEBUG_H -#define HPY_DEBUG_H - -#include "hpy.h" - -/* - This is the main public API for the debug mode, and it's meant to be used - by hpy.universal implementations (including but not limited to the - CPython's version of hpy.universal which is included in this repo). - - The idea is that for every uctx there is a corresponding unique dctx which - wraps it. - - If you call hpy_debug_get_ctx twice on the same uctx, you get the same - result. - - IMPLEMENTATION NOTE: at the moment of writing, the only known user of the - debug mode is CPython's hpy.universal: in that module, the uctx is a - statically allocated singleton, so for simplicity of implementation - currently we do the same inside debug_ctx.c, with a sanity check to ensure - that we don't call hpy_debug_get_ctx with different uctxs. But this is a - limitation of the current implementation and users should not rely on it. It - is likely that we will need to change it in the future, e.g. if we want to - have per-subinterpreter uctxs. -*/ - -HPyContext * hpy_debug_get_ctx(HPyContext *uctx); -int hpy_debug_ctx_init(HPyContext *dctx, HPyContext *uctx); -void hpy_debug_set_ctx(HPyContext *dctx); - -// convert between debug and universal handles. These are basically -// the same as DHPy_open and DHPy_unwrap but with a different name -// because this is the public-facing API and DHPy/UHPy are only internal -// implementation details. -HPy hpy_debug_open_handle(HPyContext *dctx, HPy uh); -HPy hpy_debug_unwrap_handle(HPyContext *dctx, HPy dh); -void hpy_debug_close_handle(HPyContext *dctx, HPy dh); - -// this is the HPy init function created by HPy_MODINIT. In CPython's version -// of hpy.universal the code is embedded inside the extension, so we can call -// this function directly instead of dlopen it. This is similar to what -// CPython does for its own built-in modules. But we must use the same -// signature as HPy_MODINIT - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -HPyModuleDef* HPyInit__debug(); - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -void HPyInitGlobalContext__debug(HPyContext *ctx); - -#endif /* HPY_DEBUG_H */ diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/memprotect.c b/graalpython/com.oracle.graal.python.jni/src/debug/memprotect.c deleted file mode 100644 index 909372b125..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/memprotect.c +++ /dev/null @@ -1,118 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include "debug_internal.h" - -// Implements OS dependent abstraction of memory protection - -#ifdef _HPY_DEBUG_MEM_PROTECT_USEMMAP - -#ifndef _WIN32 - -// On UNIX systems we use mmap and mprotect - -#include -#include - -void *raw_data_copy(const void* data, HPy_ssize_t size, bool write_protect) { - void* new_ptr; - new_ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (new_ptr == NULL) - return NULL; - memcpy(new_ptr, data, size); - if (write_protect) { - mprotect(new_ptr, size, PROT_READ); - } - return new_ptr; -} - -void raw_data_protect(void* data, HPy_ssize_t size) { - mprotect(data, size, PROT_NONE); -} - -int raw_data_free(void *data, HPy_ssize_t size) { - return munmap(data, size); -} - -#else - -// On Windows systems we use VirtualAlloc and VirtualProtect - -#include -#include - -void *raw_data_copy(const void* data, HPy_ssize_t size, bool write_protect) { - void* new_ptr; - DWORD old; - new_ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); - if (new_ptr == NULL) - return NULL; - memcpy(new_ptr, data, size); - if (write_protect) { - VirtualProtect(new_ptr, size, PAGE_READONLY, &old); - } - return new_ptr; -} - -void raw_data_protect(void* data, HPy_ssize_t size) { - DWORD old; - VirtualProtect(data, size, PAGE_NOACCESS, &old); -} - -int raw_data_free(void *data, HPy_ssize_t size) { - return !VirtualFree(data, 0, MEM_RELEASE); -} - -#endif /* _WIN32 */ - -#else - -// Generic fallback that should work for any OS with decent C compiler: copy -// the memory and then override it with garbage to "protect" it from reading. - -#include -#include - -void *raw_data_copy(const void* data, HPy_ssize_t size, bool write_protect) { - void *new_data = malloc(size); - memcpy(new_data, data, size); - return new_data; -} - -void raw_data_protect(void* data, HPy_ssize_t size) { - // Override the data with some garbage in hope that the program will - // eventually crash or give incorrect result if it reads the garbage - char poison[] = {0xBA, 0xD0, 0xDA, 0x7A}; - for (HPy_ssize_t dataIdx = 0, poisonIdx = 0; dataIdx < size; ++dataIdx) { - ((char*)data)[dataIdx] = poison[poisonIdx]; - poisonIdx = (poisonIdx + 1) % sizeof(poison); - } -} - -int raw_data_free(void *data, HPy_ssize_t size) { - free(data); - return 0; -} - -#endif diff --git a/graalpython/com.oracle.graal.python.jni/src/debug/stacktrace.c b/graalpython/com.oracle.graal.python.jni/src/debug/stacktrace.c deleted file mode 100644 index 17e2c7f20d..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/debug/stacktrace.c +++ /dev/null @@ -1,118 +0,0 @@ -/* MIT License - * - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include "debug_internal.h" - -#if ((__linux__ && __GNU_LIBRARY__) || __APPLE__) - -// Basic implementation that uses backtrace from glibc - -#include -#include -#include - -static inline int max_s(size_t a, size_t b) { - return a > b ? a : b; -} - -void create_stacktrace(char **target, HPy_ssize_t max_frames_count) { - const size_t skip_frames = 2; - size_t max_stack_size = (size_t) max_frames_count; - void* stack = calloc(sizeof(void*), max_stack_size); - if (stack == NULL) { - *target = NULL; - return; - } - - size_t stack_size = backtrace(stack, max_stack_size); - if (stack_size <= skip_frames) { - *target = NULL; - free(stack); - return; - } - - char** symbols = backtrace_symbols(stack, stack_size); - if (symbols == NULL) { - *target = NULL; - free(stack); - return; - } - - size_t buffer_size = 1024; - size_t buffer_index = 0; - char *buffer = malloc(buffer_size); - if (buffer == NULL) { - *target = NULL; - free(symbols); - free(stack); - return; - } - - size_t i; - for (i = skip_frames; i < stack_size; ++i) { - size_t current_len = strlen(symbols[i]); - size_t required_buffer_size = buffer_index + current_len + 1; - if (required_buffer_size > buffer_size) { - buffer_size = max_s(buffer_size * 2, required_buffer_size); - char *new_buffer = realloc(buffer, buffer_size); - if (new_buffer == NULL) { - // allocation failed, we can still provide at least part of - // the stack trace that is currently in the buffer - break; - } - buffer = new_buffer; - } - memcpy(buffer + buffer_index, symbols[i], current_len); - buffer[buffer_index + current_len] = '\n'; - buffer_index = required_buffer_size; - } - - // override the last '\n' to '\0' - assert(stack_size - skip_frames > 0); - assert(buffer[buffer_index - 1] == '\n'); - buffer[buffer_index - 1] = '\0'; - char *shorter_buffer = realloc(buffer, buffer_index); - if (shorter_buffer != NULL) { - buffer = shorter_buffer; - } - *target = buffer; - - free(symbols); - free(stack); -} - -#else - -#include - -void create_stacktrace(char **target, HPy_ssize_t max_frames_count) { - const char msg[] = - "Current HPy build does not support getting C stack traces.\n" - "At the moment this is only supported on Linux with glibc" - " and macOS."; - *target = malloc(sizeof(msg)); - memcpy(*target, msg, sizeof(msg)); -} - -#endif diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_jni.c b/graalpython/com.oracle.graal.python.jni/src/hpy_jni.c deleted file mode 100644 index 23a79fc5fb..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_jni.c +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright (c) 2021, 2024, 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. - */ - -#include "hpy_jni.h" -#include "hpy_log.h" -#include "hpy_native_cache.h" -#include "hpy_trace.h" - -#include -#include -#include -#include -#include -#include - -//************************* -// JNI upcalls - -#include "com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNIContext.h" -#include "hpynative.h" - -#include "autogen_ctx_init_jni.h" -#include "autogen_c_access.h" - -/* definitions for HPyTracker */ -#include "hpy/runtime/ctx_funcs.h" - -#define JNI_HELPER(NAME) Java_com_oracle_graal_python_builtins_objects_cext_hpy_jni_GraalHPyJNIContext_ ## NAME - -_HPy_HIDDEN JNIEnv* jniEnv; - -#define ALL_FIELDS \ - FIELD(hpyHandleTable, CLASS_HPYCONTEXT, SIG_JOBJECTARRAY) \ - FIELD(hpyGlobalsTable, CLASS_HPYCONTEXT, SIG_JOBJECTARRAY) \ - FIELD(nextHandle, CLASS_HPYCONTEXT, SIG_INT) - -#define FIELD(name, clazz, jniSig) static jfieldID jniField_ ## name; -ALL_FIELDS -#undef FIELD - -/* - * This macro specifies custom JNI upcalls. - * Add entries if you want to have (a) an additional upcall that does not - * correspond to an official HPy context function, or (b) if an upcall has a - * different signature then the public one. - */ -#define CUSTOM_UPCALLS \ - UPCALL(ctxGetItems, SIG_HPY SIG_JSTRING, SIG_HPY) \ - UPCALL(ctxSetItems, SIG_HPY SIG_JSTRING SIG_HPY, SIG_INT) \ - UPCALL(ctxGetAttrs, SIG_HPY SIG_JSTRING, SIG_HPY) \ - UPCALL(ctxFieldStore, SIG_HPY SIG_HPYFIELD SIG_HPY, SIG_PTR) \ - UPCALL(ctxGlobalStore, SIG_HPY SIG_HPYGLOBAL, SIG_PTR) \ - UPCALL(ctxContextVarGet, SIG_HPY SIG_HPY SIG_HPY, SIG_HPY) \ - UPCALL(ctxBulkClose, SIG_PTR SIG_INT, SIG_VOID) \ - UPCALL(ctxUnicodeFromJCharArray, SIG_JCHARARRAY, SIG_HPY) \ - UPCALL(ctxSequenceFromArray, SIG_JLONGARRAY SIG_BOOL SIG_BOOL, SIG_HPY) - - -#define UPCALL(name, jniSigArgs, jniSigRet) static jmethodID jniMethod_ ## name; -CUSTOM_UPCALLS -#undef UPCALL - -static jmethodID jniMethod_hpy_debug_get_context; -static jmethodID jniMethod_hpy_trace_get_context; - - -#define MAX_UNCLOSED_HANDLES 32 -static int32_t unclosedHandleTop = 0; -static HPy unclosedHandles[MAX_UNCLOSED_HANDLES]; - -static inline jsize get_handle_table_size(HPyContext *ctx) { - uint64_t size = HANDLE_TABLE_SIZE(ctx->_private); - assert((jsize)size == size); - return (jsize)size; -} - -static uint64_t get_hpy_handle_for_object(HPyContext *ctx, jobject hpyContext, jobject element, bool update_native_cache) { - /* TODO(fa): for now, we fall back to the upcall */ - if (update_native_cache) { - return 0; - } - - jobjectArray hpy_handles = (jobjectArray)(*jniEnv)->GetObjectField(jniEnv, hpyContext, jniField_hpyHandleTable); - if (hpy_handles == NULL) { - LOGS("hpy handle table is NULL") - return 0; - } - - /* try to reuse a closed handle from our native list */ - jsize next_handle; - if (unclosedHandleTop > 0) { - uint64_t recycled = toBits(unclosedHandles[--unclosedHandleTop]); - LOG("%llu", (unsigned long long)recycled) - assert(recycled < INT32_MAX); - next_handle = (jsize) recycled; - } else { - next_handle = (*jniEnv)->GetIntField(jniEnv, hpyContext, jniField_nextHandle); - LOG("%d", next_handle) - jsize s = get_handle_table_size(ctx); - if (next_handle >= s) { - return 0; - } - (*jniEnv)->SetIntField(jniEnv, hpyContext, jniField_nextHandle, next_handle+1); - } - (*jniEnv)->SetObjectArrayElement(jniEnv, hpy_handles, next_handle, element); - (*jniEnv)->DeleteLocalRef(jniEnv, hpy_handles); - /* TODO(fa): update native data pointer cache here (if specified) */ - return boxHandle(next_handle); -} - -static jobject get_object_for_hpy_global(jobject hpyContext, uint64_t bits) { - jobject hpy_globals = (*jniEnv)->GetObjectField(jniEnv, hpyContext, jniField_hpyGlobalsTable); - if (hpy_globals == NULL) { - LOGS("hpy globals is NULL") - return NULL; - } - jobject element = (*jniEnv)->GetObjectArrayElement(jniEnv, (jobjectArray)hpy_globals, (jsize)unboxHandle(bits)); - (*jniEnv)->DeleteLocalRef(jniEnv, hpy_globals); - if (element == NULL) { - LOGS("globals element is NULL") - return NULL; - } - return element; -} - -#define MAX_UNICODE 0x10ffff - -_HPy_HIDDEN HPy ctx_Unicode_FromWideChar_jni(HPyContext *ctx, const wchar_t *u, HPy_ssize_t size) { - if (u == NULL && size != 0) { - return HPy_NULL; - } - - if (sizeof(wchar_t) != sizeof(uint32_t)) { - HPyErr_SetString(ctx, ctx->h_SystemError, "unsupported size of type wchar_t"); - return HPy_NULL; - } - - if (size == -1) { - size = wcslen(u); - } - - if (size > INT32_MAX) { - HPyErr_SetString(ctx, ctx->h_SystemError, "wchar_t array is too large"); - return HPy_NULL; - } - - uint32_t maxchar = 0; - wchar_t ch; - HPy_ssize_t i; - for (i = 0; i < size; i++) { - ch = u[i]; - if (ch > maxchar) { - maxchar = ch; - if (maxchar > MAX_UNICODE) { - HPyErr_SetString(ctx, ctx->h_ValueError, "character is not in range [U+0000; U+10ffff]"); - return HPy_NULL; - } - } - } - - if (maxchar < UINT16_MAX) { - jarray jCharArray = (*jniEnv)->NewCharArray(jniEnv, (jsize) size); - jchar *content = (*jniEnv)->GetPrimitiveArrayCritical(jniEnv, jCharArray, 0); - HPy_ssize_t i; - for (i = 0; i < size; i++) { - content[i] = (jchar) u[i]; - } - (*jniEnv)->ReleasePrimitiveArrayCritical(jniEnv, jCharArray, content, 0); - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctxUnicodeFromJCharArray, jCharArray); - } else { - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Unicode_FromWideChar, PTR_UP(u), SIZE_T_UP(size)); - } -} - -_HPy_HIDDEN HPy ctx_Global_Load_jni(HPyContext *ctx, HPyGlobal global) { - uint64_t bits = toBits(global); - if (bits && isBoxedHandle(bits)) { - jobject hpyContext = graal_hpy_context_get_native_context(ctx)->jni_context; - jobject element = get_object_for_hpy_global(hpyContext, bits); - if (element == NULL) { - return HPy_NULL; - } - - uint64_t new_handle = get_hpy_handle_for_object(ctx, hpyContext, element, false); - (*jniEnv)->DeleteLocalRef(jniEnv, element); - if (new_handle) { - load_global_native_data_pointer(ctx, bits, new_handle); - return toPtr(new_handle); - } - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctx_Global_Load, bits); - } else { - return toPtr(bits); - } -} - -static void ctx_Global_Store_jni(HPyContext *ctx, HPyGlobal *h, HPy v) { - h->_i = DO_UPCALL_INTPTR_T(CONTEXT_INSTANCE(ctx), ctxGlobalStore, HPY_GLOBAL_UP(*h), HPY_UP(v)); -} - -static void ctx_Field_Store_jni(HPyContext *ctx, HPy owner, HPyField *field, HPy value) { - field->_i = DO_UPCALL_INTPTR_T(CONTEXT_INSTANCE(ctx), ctxFieldStore, HPY_UP(owner), HPY_FIELD_UP(*field), HPY_UP(value)); -} - -static const char* getBoxedPrimitiveName(uint64_t bits) { - assert(!isBoxedHandle(bits)); - if (isBoxedInt(bits)) { - return "int"; - } - assert(isBoxedDouble(bits)); - return "float"; -} - -static int ctx_SetItem_s_jni(HPyContext *ctx, HPy target, const char *name, HPy value) { - uint64_t bits = toBits(target); - if (!isBoxedHandle(bits)) { - const size_t buffer_size = 128; -#ifdef _MSC_VER - char *message = (char *)alloca(buffer_size); -#else - char message[buffer_size]; -#endif - snprintf(message, buffer_size, - "'%s' object does not support item assignment", getBoxedPrimitiveName(bits)); - HPyErr_SetString(ctx, ctx->h_TypeError, message); - return -1; - } - jstring jname = (*jniEnv)->NewStringUTF(jniEnv, name); - return DO_UPCALL_INT(CONTEXT_INSTANCE(ctx), ctxSetItems, target, jname, value); -} - -static HPy ctx_GetItem_s_jni(HPyContext *ctx, HPy target, const char *name) { - uint64_t bits = toBits(target); - if (!isBoxedHandle(bits)) { - const size_t buffer_size = 128; -#ifdef _MSC_VER - char *message = (char *)alloca(buffer_size); -#else - char message[buffer_size]; -#endif - snprintf(message, buffer_size, - "'%s' object is not subscriptable", getBoxedPrimitiveName(bits)); - return HPyErr_SetString(ctx, ctx->h_TypeError, message); - } - jstring jname = (*jniEnv)->NewStringUTF(jniEnv, name); - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctxGetItems, target, jname); -} - -static HPy ctx_GetAttr_s_jni(HPyContext *ctx, HPy target, const char *name) { - jstring jname = (*jniEnv)->NewStringUTF(jniEnv, name); - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctxGetAttrs, target, jname); -} - -static int ctx_ContextVar_Get_jni(HPyContext *ctx, HPy var, HPy def, HPy *result) { - /* This uses 'h_Ellipsis' as an error marker assuming that it is rather uncertain that this will be a valid return - value. If 'h_Ellipsis' is returned, this indicates an error and we explicitly check for an error then. */ - HPy err_marker = ctx->h_Ellipsis; - HPy r = DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctxContextVarGet, HPY_UP(var), HPY_UP(def), HPY_UP(err_marker)); - if (toBits(r) == toBits(err_marker) && HPyErr_Occurred(ctx)) { - return -1; - } - *result = r; - return 0; -} - -_HPy_HIDDEN HPy upcallSequenceFromArray(HPyContext *ctx, HPy *items, HPy_ssize_t nitems, bool steal, bool create_list) { - jarray jLongArray = (*jniEnv)->NewLongArray(jniEnv, (jsize) nitems); - (*jniEnv)->SetLongArrayRegion(jniEnv, jLongArray, 0, (jsize) nitems, (const jlong *)items); - return DO_UPCALL_HPY(CONTEXT_INSTANCE(ctx), ctxSequenceFromArray, jLongArray, (jboolean) steal, (jboolean) create_list); -} - -static HPy ctx_Tuple_FromArray_jni(HPyContext *ctx, HPy *items, HPy_ssize_t nitems) { - return upcallSequenceFromArray(ctx, items, nitems, false, JNI_FALSE); -} - -_HPy_HIDDEN void upcallBulkClose(HPyContext *ctx, HPy *items, HPy_ssize_t nitems) { - DO_UPCALL_VOID(CONTEXT_INSTANCE(ctx), ctxBulkClose, items, nitems); -} - -/* Initialize the jmethodID pointers for all the context functions implemented via JNI. */ -JNIEXPORT jlong JNICALL JNI_HELPER(initJNI)(JNIEnv *env, jclass clazz, jobject jbackend, jobject jctx, jlongArray jctx_handles, jintArray ctype_sizes, jintArray cfield_offsets) { - LOG("%s", "hpy_jni.c:initJNI\n"); - int res; - GraalHPyContext *graal_hpy_context = (GraalHPyContext *) calloc(1, sizeof(GraalHPyContext)); - HPyContext *ctx = graal_native_context_get_hpy_context(graal_hpy_context); - ctx->name = "HPy Universal ABI (GraalVM backend, JNI)"; - graal_hpy_context->jni_backend = (*env)->NewGlobalRef(env, jbackend); - graal_hpy_context->jni_context = (*env)->NewGlobalRef(env, jctx); - jniEnv = env; - - if (init_autogen_jni_ctx(env, clazz, ctx, jctx_handles)) { - return PTR_UP(NULL); - } - - assert(sizeof(int32_t) == sizeof(jint)); - int32_t *ctype_sizes_data = (*env)->GetPrimitiveArrayCritical(env, ctype_sizes, 0); - res = fill_c_type_sizes(ctype_sizes_data); - (*env)->ReleasePrimitiveArrayCritical(env, ctype_sizes, ctype_sizes_data, 0); - if (res) { - return PTR_UP(NULL); - } - int32_t *cfield_offsets_data = (*env)->GetPrimitiveArrayCritical(env, cfield_offsets, 0); - res = fill_c_field_offsets(cfield_offsets_data); - (*env)->ReleasePrimitiveArrayCritical(env, cfield_offsets, cfield_offsets_data, 0); - if (res) { - return PTR_UP(NULL); - } - - /* The HPyTracker is backend-specific. For JNI, we stay in native since there is no benefit for - doing an upcall. */ - ctx->ctx_Tracker_New = ctx_Tracker_New_jni; - ctx->ctx_Tracker_Add = ctx_Tracker_Add_jni; - ctx->ctx_Tracker_ForgetAll = ctx_Tracker_ForgetAll_jni; - ctx->ctx_Tracker_Close = ctx_Tracker_Close_jni; - - ctx->ctx_Unicode_FromWideChar = ctx_Unicode_FromWideChar_jni; - - ctx->ctx_Tuple_FromArray = ctx_Tuple_FromArray_jni; - - ctx->ctx_Global_Load = ctx_Global_Load_jni; - ctx->ctx_Global_Store = ctx_Global_Store_jni; - ctx->ctx_Field_Store = ctx_Field_Store_jni; - - ctx->ctx_SetItem_s = ctx_SetItem_s_jni; - ctx->ctx_GetItem_s = ctx_GetItem_s_jni; - - ctx->ctx_ContextVar_Get = ctx_ContextVar_Get_jni; - ctx->ctx_GetAttr_s = ctx_GetAttr_s_jni; - - assert(clazz != NULL); - - jclass jctx_class = (*env)->GetObjectClass(env, jctx); - if (jctx_class == NULL) { - LOGS("ERROR: could not get class of Java HPy context object"); - return PTR_UP(NULL); - } - -#define CLASS_HPYCONTEXT jctx_class - -#define SIG_HPY "J" -#define SIG_HPYGLOBAL "J" -#define SIG_HPYFIELD "J" -#define SIG_PTR "J" -#define SIG_VOID "V" -#define SIG_INT "I" -#define SIG_BOOL "Z" -#define SIG_JSTRING "Ljava/lang/String;" -#define SIG_JCHARARRAY "[C" -#define SIG_JLONGARRAY "[J" -#define SIG_JOBJECTARRAY "[Ljava/lang/Object;" - -#define FIELD(name, clazz, jniSig) \ - jniField_ ## name = (*env)->GetFieldID(env, clazz, #name, jniSig); \ - if (jniField_ ## name == NULL) { \ - LOGS("ERROR: jni field " #name " not found found !\n"); \ - return PTR_UP(NULL); \ - } - -ALL_FIELDS -#undef FIELD - -#define UPCALL(name, jniSigArgs, jniSigRet) \ - jniMethod_ ## name = (*env)->GetMethodID(env, clazz, #name, "(" jniSigArgs ")" jniSigRet); \ - if (jniMethod_ ## name == NULL) { \ - LOGS("ERROR: jni method " #name " not found found !\n"); \ - return PTR_UP(NULL); \ - } - -CUSTOM_UPCALLS -#undef UPCALL - - jniMethod_hpy_debug_get_context = (*env)->GetMethodID(env, clazz, "getHPyDebugContext", "()" SIG_PTR); - if (jniMethod_hpy_debug_get_context == NULL) { - LOGS("ERROR: jni method getHPyDebugContext not found found !\n"); - return PTR_UP(NULL); - } - - jniMethod_hpy_trace_get_context = (*env)->GetMethodID(env, clazz, "getHPyTraceContext", "()" SIG_PTR); - if (jniMethod_hpy_trace_get_context == NULL) { - LOGS("ERROR: jni method getHPyTraceContext not found found !\n"); - return PTR_UP(NULL); - } - - return PTR_UP(ctx); -} - -JNIEXPORT jint JNICALL JNI_HELPER(finalizeJNIContext)(JNIEnv *env, jclass clazz, jlong ctx) { - LOG("%s", "hpy_jni.c:finalizeJNIContext\n"); - // assert(info->magic_number == HPY_TRACE_MAGIC); - GraalHPyContext *native_ctx = graal_hpy_context_get_native_context((HPyContext *) ctx); - (*env)->DeleteGlobalRef(env, (jobject) native_ctx->jni_backend); - (*env)->DeleteGlobalRef(env, (jobject) native_ctx->jni_context); - free((void *)native_ctx); - return 0; -} - -JNIEXPORT jlong JNICALL JNI_HELPER(initJNIDebugContext)(JNIEnv *env, jclass clazz, jlong uctxPointer) { - LOG("%s", "hpy_jni.c:initJNIDebugContext\n"); - HPyContext *uctx = (HPyContext *) uctxPointer; - - HPyContext *dctx = (HPyContext *) malloc(sizeof(HPyContext)); - dctx->name = "HPy Debug Mode ABI"; - dctx->_private = NULL; - dctx->abi_version = HPY_ABI_VERSION; - - hpy_debug_ctx_init(dctx, uctx); - return PTR_UP(dctx); -} - -JNIEXPORT jint JNICALL JNI_HELPER(finalizeJNIDebugContext)(JNIEnv *env, jclass clazz, jlong dctxPointer) { - LOG("%s", "hpy_jni.c:finalizeJNIDebugContext\n"); - HPyContext *dctx = (HPyContext *) dctxPointer; - hpy_debug_ctx_free(dctx); - free(dctx); - return 0; -} - -JNIEXPORT jlong JNICALL JNI_HELPER(initJNIDebugModule)(JNIEnv *env, jclass clazz, jlong uctxPointer) { - LOG("%s", "hpy_jni.c:initJNIDebugModule\n"); - return PTR_UP(HPyInit__debug()); -} - -JNIEXPORT jlong JNICALL JNI_HELPER(initJNITraceContext)(JNIEnv *env, jclass clazz, jlong uctxPointer) { - LOG("%s", "hpy_jni.c:initJNITraceContext\n"); - HPyContext *uctx = (HPyContext *) uctxPointer; - - HPyContext *tctx = (HPyContext *) malloc(sizeof(HPyContext)); - tctx->name = "HPy Trace Mode ABI"; - tctx->_private = NULL; - tctx->abi_version = HPY_ABI_VERSION; - - hpy_trace_ctx_init(tctx, uctx); - return PTR_UP(tctx); -} - -JNIEXPORT jint JNICALL JNI_HELPER(finalizeJNITraceContext)(JNIEnv *env, jclass clazz, jlong tctxPointer) { - LOG("%s", "hpy_jni.c:finalizeJNITraceContext\n"); - HPyContext *tctx = (HPyContext *) tctxPointer; - hpy_trace_ctx_free(tctx); - free(tctx); - return 0; -} - -JNIEXPORT jlong JNICALL JNI_HELPER(initJNITraceModule)(JNIEnv *env, jclass clazz, jlong uctxPointer) { - LOG("%s", "hpy_jni.c:initJNITraceModule\n"); - return PTR_UP(HPyInit__trace()); -} - -JNIEXPORT void JNICALL JNI_HELPER(bulkFreeNativeSpace)(JNIEnv *env, jclass clazz, jlongArray nativeSpacePtrs, jlongArray destroyFuncPtrs, jint n) { - jlong *native_space_ptrs_data = (*env)->GetLongArrayElements(env, nativeSpacePtrs, 0); - jlong *destroy_func_ptrs_data = (*env)->GetLongArrayElements(env, destroyFuncPtrs, 0); - for (jint i=0; i < n; i++) - { - HPyFunc_destroyfunc destroy_func = (HPyFunc_destroyfunc) destroy_func_ptrs_data[i]; - destroy_func((void *)native_space_ptrs_data[i]); - } - (*jniEnv)->ReleaseLongArrayElements(env, nativeSpacePtrs, native_space_ptrs_data, JNI_ABORT); - (*jniEnv)->ReleaseLongArrayElements(env, destroyFuncPtrs, destroy_func_ptrs_data, JNI_ABORT); -} - -JNIEXPORT jint JNICALL JNI_HELPER(strcmp)(JNIEnv *env, jclass clazz, jlong s1, jlong s2) { - return (jint) strcmp((const char *)s1, (const char *)s2); -} - -JNIEXPORT jint JNICALL JNI_HELPER(initJNINativeFastPaths)(JNIEnv *env, jclass clazz, jlong uctxPointer) { - init_native_fast_paths((HPyContext *) uctxPointer); - return 0; -} - -JNIEXPORT jint JNICALL JNI_HELPER(setNativeSpaceFunction)(JNIEnv *env, jclass clazz, jlong uctxPointer, jlong cachePtr) { - LOG("%ld %ld", uctxPointer, cachePtr); - HPyContext *ctx = (HPyContext *) uctxPointer; - ctx->_private = (void *) cachePtr; - return 0; -} - -JNIEXPORT jint JNICALL JNI_HELPER(getErrno)(JNIEnv *env, jclass clazz) { - return (jint) errno; -} - -JNIEXPORT jlong JNICALL JNI_HELPER(getStrerror)(JNIEnv *env, jclass clazz, jint i) { - return PTR_UP(strerror(i)); -} - -HPyContext * hpy_debug_get_ctx(HPyContext *uctx) -{ - HPyContext *dctx = (HPyContext *) DO_UPCALL_PTR_NOARGS(CONTEXT_INSTANCE(uctx), hpy_debug_get_context); - if (uctx == dctx) { - HPy_FatalError(uctx, "hpy_debug_get_ctx: expected an universal ctx, got a debug ctx"); - } - return dctx; -} - -HPyContext * hpy_trace_get_ctx(HPyContext *uctx) -{ - HPyContext *tctx = (HPyContext *) DO_UPCALL_PTR_NOARGS(CONTEXT_INSTANCE(uctx), hpy_trace_get_context); - if (uctx == tctx) { - HPy_FatalError(uctx, "hpy_trace_get_ctx: expected an universal ctx, " - "got a trace ctx"); - } - return tctx; -} diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_jni.h b/graalpython/com.oracle.graal.python.jni/src/hpy_jni.h deleted file mode 100644 index 585ce6c554..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_jni.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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. - */ - -#ifndef SRC_HPY_JNI_H_ -#define SRC_HPY_JNI_H_ - -#include -#include -#include - -#if defined(_MSC_VER) -# include /* for alloca() */ -#endif - -#include "debug_internal.h" -#include "hpy_native_fast_paths.h" - -#define DO_UPCALL_JINT(jni_ctx, name, ...) (*jniEnv)->CallIntMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_JLONG(jni_ctx, name, ...) (*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_HPY_NOARGS(jni_ctx, name) ((HPy){(HPy_ssize_t)(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name)}) -#define DO_UPCALL_HPY(jni_ctx, name, ...) ((HPy){(HPy_ssize_t)(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__)}) -#define DO_UPCALL_HPY0(jni_ctx, name) ((HPy){(HPy_ssize_t)(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name)}) -#define DO_UPCALL_HPYTRACKER(jni_ctx, name, ...) ((HPyTracker){(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__)}) -#define DO_UPCALL_HPYTHREADSTATE0(jni_ctx, name) ((HPyThreadState){(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name)}) -#define DO_UPCALL_HPYLISTBUILDER(jni_ctx, name, ...) ((HPyListBuilder){(*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__)}) -#define DO_UPCALL_PTR(jni_ctx, name, ...) (void*) (*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_PTR_NOARGS(jni_ctx, name) (void*) (*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name) -#define DO_UPCALL_INTPTR_T(jni_ctx, name, ...) (intptr_t) (*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_SIZE_T(jni_ctx, name, ...) (HPy_ssize_t) (*jniEnv)->CallLongMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_INT0(jni_ctx, name, ...) (int) (*jniEnv)->CallIntMethod(jniEnv, (jni_ctx), jniMethod_ ## name) -#define DO_UPCALL_DOUBLE(jni_ctx, name, ...) (double) (*jniEnv)->CallDoubleMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_VOID(jni_ctx, name, ...) (*jniEnv)->CallVoidMethod(jniEnv, (jni_ctx), jniMethod_ ## name, __VA_ARGS__) -#define DO_UPCALL_VOID0(jni_ctx, name) (*jniEnv)->CallVoidMethod(jniEnv, (jni_ctx), jniMethod_ ## name) -#define DO_UPCALL_HPY_SSIZE_T (HPy_ssize_t) DO_UPCALL_JLONG -#define DO_UPCALL_HPY_HASH_T (HPy_hash_t) DO_UPCALL_JLONG -#define DO_UPCALL_HPY_UCS4 (HPy_UCS4) DO_UPCALL_JINT -#define DO_UPCALL_HPYTYPE_BUILTINSHAPE (HPyType_BuiltinShape) DO_UPCALL_JINT -#define DO_UPCALL_INT (int) DO_UPCALL_JINT -#define DO_UPCALL_INT32_T (int32_t) DO_UPCALL_JINT -#define DO_UPCALL_UINT32_T (uint32_t) DO_UPCALL_JINT -#define DO_UPCALL_INT64_T (int64_t) DO_UPCALL_JLONG -#define DO_UPCALL_UINT64_T (uint64_t) DO_UPCALL_JLONG - -#define HPY_UP(_h) ((jlong)((_h)._i)) -#define PTR_UP(_h) ((jlong)_h) -#define INT_UP(_h) ((jint)_h) -#define INT32_UP(_h) ((jint)_h) -#define UINT32_UP(_h) ((jint)_h) -#define LONG_UP(_h) ((jlong)_h) -#define DOUBLE_UP(_h) ((jdouble)_h) -#define SIZE_T_UP(_h) ((jlong)_h) -#define HPY_TRACKER_UP(_h) ((jlong)((_h)._i)) -#define HPY_LIST_BUILDER_UP(_h) ((jlong)((_h)._lst)) -#define HPY_THREAD_STATE_UP(_h) ((jlong)((_h)._i)) -#define HPY_GLOBAL_UP(_h) ((jlong)((_h)._i)) -#define HPY_FIELD_UP(_h) ((jlong)((_h)._i)) - -static inline HPy _jlong2h(jlong obj) { - return (HPy){(HPy_ssize_t)obj}; -} - -static inline jlong _h2jlong(HPy h) { - return (jlong)(h._i); -} - -static inline DHPy _jlong2dh(HPyContext *dctx, jlong obj) -{ - return DHPy_open(dctx, _jlong2h(obj)); -} - -static inline jlong _dh2jlong(HPyContext *dctx, DHPy dh) -{ - return _h2jlong(DHPy_unwrap(dctx, dh)); -} - -static inline jlong from_dh(HPyContext *dctx, DHPy dh_result) -{ - jlong result = _dh2jlong(dctx, dh_result); - DHPy_close(dctx, dh_result); - return result; -} - -#define _ARR_JLONG2DH(DCTX, DST, ARGS, NARGS) \ - DHPy *DST = (DHPy *)alloca((NARGS) * sizeof(DHPy)); \ - for (HPy_ssize_t i = 0; i < (NARGS); i++) { \ - DST[i] = _jlong2dh(DCTX, ((jlong *)(ARGS))[i]); \ - } \ - -#define _ARR_DH_CLOSE(DCTX, DH_ARR, NARGS) \ - for (HPy_ssize_t i = 0; i < (NARGS); i++) { \ - DHPy_close_and_check((DCTX), (DH_ARR)[i]); \ - } \ - -/* just for better readability */ -typedef HPy_buffer DHPy_buffer; -typedef HPy_buffer UHPy_buffer; - -/* Copies everything from 'src' to 'dest' and unwraps the 'obj' debug handle. */ -static inline void -_buffer_d2u(HPyContext *dctx, const DHPy_buffer *src, UHPy_buffer *dest) -{ - dest->buf = src->buf; - dest->obj = DHPy_unwrap(dctx, src->obj); - dest->len = src->len; - dest->itemsize = src->itemsize; - dest->readonly = src->readonly; - dest->ndim = src->ndim; - dest->format = src->format; - dest->shape = src->shape; - dest->strides = src->strides; - dest->suboffsets = src->suboffsets; - dest->internal = src->internal; -} - -/* Copies everything from 'src' to 'dest' and opens a debug handle for 'obj'. */ -static inline void -_buffer_u2d(HPyContext *dctx, const UHPy_buffer *src, DHPy_buffer *dest) -{ - dest->buf = src->buf; - dest->obj = DHPy_open(dctx, src->obj); - dest->len = src->len; - dest->itemsize = src->itemsize; - dest->readonly = src->readonly; - dest->ndim = src->ndim; - dest->format = src->format; - dest->shape = src->shape; - dest->strides = src->strides; - dest->suboffsets = src->suboffsets; - dest->internal = src->internal; -} - -#define CONTEXT_INSTANCE(_hpy_ctx) ((jobject)(graal_hpy_context_get_native_context(_hpy_ctx)->jni_backend)) - -_HPy_HIDDEN extern JNIEnv* jniEnv; - -_HPy_HIDDEN HPy upcallSequenceFromArray(HPyContext *ctx, HPy *items, HPy_ssize_t nitems, bool steal, bool create_list); - -_HPy_HIDDEN void upcallBulkClose(HPyContext *ctx, HPy *items, HPy_ssize_t nitems); - -_HPy_HIDDEN HPyTracker ctx_Tracker_New_jni(HPyContext *ctx, HPy_ssize_t capacity); - -/* Very much like 'augment_Tracker_Add' but doesn't do special handling for - boxed values and immutable handles */ -_HPy_HIDDEN int raw_Tracker_Add(HPyContext *ctx, HPyTracker ht, HPy h); - -_HPy_HIDDEN int ctx_Tracker_Add_jni(HPyContext *ctx, HPyTracker ht, HPy h); - -_HPy_HIDDEN void ctx_Tracker_ForgetAll_jni(HPyContext *ctx, HPyTracker ht); - -_HPy_HIDDEN void ctx_Tracker_Close_jni(HPyContext *ctx, HPyTracker ht); - -_HPy_HIDDEN int hpy_debug_ctx_init(HPyContext *dctx, HPyContext *uctx); - -_HPy_HIDDEN void hpy_debug_ctx_free(HPyContext *dctx); - -#endif /* SRC_HPY_JNI_H_ */ diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_log.h b/graalpython/com.oracle.graal.python.jni/src/hpy_log.h deleted file mode 100644 index f6cf73a214..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_log.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022, 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. - */ - -#ifndef SRC_HPY_LOG_H_ -#define SRC_HPY_LOG_H_ - -#ifndef NDEBUG -#include -#define LOG(FORMAT, ...) do { printf("%-15s (%s:%d): %s " FORMAT "\n", __FUNCTION__, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__); fflush(stdout); } while(0); -#define LOGS(FORMAT) do { printf("%-15s (%s:%d): " FORMAT "\n", __FUNCTION__, __FILE__, __LINE__); fflush(stdout); } while(0); -#else -#define LOG(FORMAT, ...) -#define LOGS(FORMAT) -#endif - -#endif /* SRC_HPY_LOG_H_ */ diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_native_cache.h b/graalpython/com.oracle.graal.python.jni/src/hpy_native_cache.h deleted file mode 100644 index d91f717a6f..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_native_cache.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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. - */ - -/* - * HPy native cache implementation. - * Currently, the native cache is an array of uint64_t values. - * Layout: - * ----------------------------------------------------------------------- - * | n | hptr_0 | hptr_1 | ... | hptr_n | gptr_0 | gptr_1 | ... | gptr_m | - * ----------------------------------------------------------------------- - * 'n' is the current size of the handle table. - * 'hptr_0' is the native data pointer of the object associated with HPy handle 0. - * 'gptr_0' is the native data pointer of the object associated with HPy global 0. - */ - - -#ifndef SRC_HPY_NATIVE_CACHE_H_ -#define SRC_HPY_NATIVE_CACHE_H_ - -#include "hpy_native_fast_paths.h" -#include "hpy_log.h" - -#define HANDLE_MIRROR_OFFSET 1 -#define HANDLE_DATAPTR_INDEX(bits) (HANDLE_MIRROR_OFFSET + unboxHandle(bits)) -#define GLOBAL_DATAPTR_INDEX(n_ht, bits) (HANDLE_MIRROR_OFFSET + n_ht + unboxHandle(bits)) -#define HANDLE_TABLE_SIZE(cache_ptr) (((uint64_t *)cache_ptr)[0]) - -/* - * Get the native data pointer of an object denoted by a handle from the native - * cache. - */ -static inline void * -get_handle_native_data_pointer(HPyContext *ctx, uint64_t bits) { - void** space = (void**)ctx->_private; - return space[HANDLE_DATAPTR_INDEX(bits)]; -} - - -/* - * Get the native data pointer of an object denoted by an HPyGlobal from the - * native cache. - */ -static inline void * -get_global_native_data_pointer(HPyContext *ctx, uint64_t bits) { - void** space = (void**)ctx->_private; - return space[GLOBAL_DATAPTR_INDEX(HANDLE_TABLE_SIZE(space), bits)]; -} - -/* - * Load the native data pointer of an object denoted by an HPyGlobal into the - * native cache. - */ -static inline void -load_global_native_data_pointer(HPyContext *ctx, uint64_t g_bits, uint64_t h_bits) { - void** space = (void**)ctx->_private; - uint64_t n_handle_table = (uint64_t)space[0]; - void *g_data_ptr = space[GLOBAL_DATAPTR_INDEX(n_handle_table, g_bits)]; - LOG("%llu %llu %p", (unsigned long long)g_bits, (unsigned long long)h_bits, g_data_ptr) - space[HANDLE_DATAPTR_INDEX(h_bits)] = g_data_ptr; -} - -#endif /* SRC_HPY_NATIVE_CACHE_H_ */ diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.c b/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.c deleted file mode 100644 index 4bff9d56fb..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright (c) 2022, 2024, 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. - */ - -#include "hpy_jni.h" -#include "hpy_log.h" -#include "hpy_native_fast_paths.h" -#include "hpy_native_cache.h" - -#include -#include - -#define MAX_UNCLOSED_HANDLES 32 -static int32_t unclosedHandleTop = 0; -static HPy unclosedHandles[MAX_UNCLOSED_HANDLES]; - -//************************* -// BOXING - -static_assert(sizeof(uint64_t) == sizeof(double), "Assumption necessary for NaN boxing to work"); - -static inline double unboxDouble(uint64_t value) { - double result; - uint64_t unboxed = value - NAN_BOXING_BASE; - memcpy(&result, &unboxed, sizeof(double)); - return result; -} - -static inline uint64_t boxDouble(double value) { - // assumes that value doesn't contain non-standard silent NaNs - uint64_t unboxed; - memcpy(&unboxed, &value, sizeof(double)); - return unboxed + NAN_BOXING_BASE; -} - -//************************* -// direct fast paths that handle certain calls on the native side: - -static void *(*original_AsStruct_Object)(HPyContext *ctx, HPy h); -static HPy (*original_Dup)(HPyContext *ctx, HPy h); -static HPy (*original_Long)(HPyContext *ctx, HPy h); -static HPy (*original_Float_FromDouble)(HPyContext *ctx, double v); -static double (*original_Float_AsDouble)(HPyContext *ctx, HPy h); -static int32_t (*original_Long_AsInt32_t)(HPyContext *ctx, HPy h); -static int64_t (*original_Long_AsInt64_t)(HPyContext *ctx, HPy h); -static uint32_t (*original_Long_AsUInt32_t)(HPyContext *ctx, HPy h); -static size_t (*original_Long_AsSize_t)(HPyContext *ctx, HPy h); -static HPy_ssize_t (*original_Long_AsSsize_t)(HPyContext *ctx, HPy h); -static double (*original_Long_AsDouble)(HPyContext *ctx, HPy h); -static HPy (*original_Long_FromInt32_t)(HPyContext *ctx, int32_t l); -static HPy (*original_Long_FromUInt32_t)(HPyContext *ctx, uint32_t l); -static HPy (*original_Long_FromInt64_t)(HPyContext *ctx, int64_t l); -static HPy (*original_Long_FromUInt64_t)(HPyContext *ctx, uint64_t l); -static HPy (*original_Long_FromSsize_t)(HPyContext *ctx, HPy_ssize_t l); -static HPy (*original_Long_FromSize_t)(HPyContext *ctx, size_t l); -static int (*original_List_Check)(HPyContext *ctx, HPy h); -static int (*original_Number_Check)(HPyContext *ctx, HPy h); -static int (*original_TypeCheck)(HPyContext *ctx, HPy h, HPy type); -static void (*original_Close)(HPyContext *ctx, HPy h); -static void (*original_Global_Store)(HPyContext *ctx, HPyGlobal *global, HPy h); -static HPy (*original_Global_Load)(HPyContext *ctx, HPyGlobal global); -static void (*original_Field_Store)(HPyContext *ctx, HPy target_object, HPyField *target_field, HPy h); -static HPy (*original_Field_Load)(HPyContext *ctx, HPy source_object, HPyField source_field); -static int (*original_Is)(HPyContext *ctx, HPy a, HPy b); -static int (*original_IsTrue)(HPyContext *ctx, HPy h); -static HPy (*original_Type)(HPyContext *ctx, HPy obj); -static HPy (*original_Add)(HPyContext *ctx, HPy h1, HPy h2); -static HPy (*original_Subtract)(HPyContext *ctx, HPy h1, HPy h2); -static HPy (*original_Multiply)(HPyContext *ctx, HPy h1, HPy h2); -static HPy (*original_FloorDivide)(HPyContext *ctx, HPy h1, HPy h2); -static HPy (*original_TrueDivide)(HPyContext *ctx, HPy h1, HPy h2); -static HPy (*original_RichCompare)(HPyContext *ctx, HPy v, HPy w, int op); -static int (*original_RichCompareBool)(HPyContext *ctx, HPy v, HPy w, int op); - -static int augment_Is(HPyContext *ctx, HPy a, HPy b) { - uint64_t bitsA = toBits(a); - uint64_t bitsB = toBits(b); - if (bitsA == bitsB) { - return 1; - } else if (isBoxedHandle(bitsA) && isBoxedHandle(bitsB)) { - // This code assumes that objects pointed by a handle <= SINGLETON_HANDLES_MAX - // always get that same handle - uint64_t unboxedA = unboxHandle(bitsA); - uint64_t unboxedB = unboxHandle(bitsB); - if (unboxedA <= SINGLETON_HANDLES_MAX) { - return 0; - } else if (unboxedB <= SINGLETON_HANDLES_MAX) { - return 0; - } - // This code assumes that space[x] != NULL <=> objects pointed by x has native struct - void *dataA = get_handle_native_data_pointer(ctx, unboxedA); - void *dataB = get_handle_native_data_pointer(ctx, unboxedB); - if (dataA == NULL && dataB == NULL) { - return original_Is(ctx, a, b); - } - return dataA == dataB; - } else { - return 0; - } -} - -static int augment_IsTrue(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - return unboxInt(bits) != 0; - } else if (isBoxedDouble(bits)) { - return unboxDouble(bits) != 0.0; - } else if (augment_Is(ctx, ctx->h_None, h)) { - return 0; - } - return original_IsTrue(ctx, h); -} - -static void *augment_AsStruct_Object(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedHandle(bits)) { - return get_handle_native_data_pointer(ctx, bits); - } else { - return NULL; - } -} - -static HPy augment_Long(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - return h; - } else if (isBoxedDouble(bits)) { - double v = unboxDouble(bits); - return toPtr(boxInt((int) v)); - } - return original_Long(ctx, h); -} - -static HPy augment_Float_FromDouble(HPyContext *ctx, double v) { - return toPtr(boxDouble(v)); -} - -static double augment_Float_AsDouble(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedDouble(bits)) { - return unboxDouble(bits); - } else if (isBoxedInt(bits)) { - return unboxInt(bits); - } else { - return original_Float_AsDouble(ctx, h); - } -} - -static int32_t augment_Long_AsInt32_t(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - return unboxInt(bits); - } else { - return original_Long_AsInt32_t(ctx, h); - } -} - -static int64_t augment_Long_AsInt64_t(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - return unboxInt(bits); - } else { - return original_Long_AsInt64_t(ctx, h); - } -} - -static uint32_t augment_Long_AsUInt32_t(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - int32_t unboxed = unboxInt(bits); - if (unboxed >= 0) { - return unboxed; - } - } - return original_Long_AsUInt32_t(ctx, h); -} - -static HPy_ssize_t augment_Long_AsSsize_t(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - int32_t unboxed = unboxInt(bits); - if (unboxed >= 0) { - return unboxed; - } - } - return original_Long_AsSsize_t(ctx, h); -} - -static size_t augment_Long_AsSize_t(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - int32_t unboxed = unboxInt(bits); - if (unboxed >= 0) { - return unboxed; - } - } - return original_Long_AsSize_t(ctx, h); -} - -static double augment_Long_AsDouble(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedInt(bits)) { - return unboxInt(bits); - } else { - return original_Long_AsDouble(ctx, h); - } -} - -static HPy augment_Long_FromInt32_t(HPyContext *ctx, int32_t l) { - return toPtr(boxInt(l)); -} - -static HPy augment_Long_FromUInt32_t(HPyContext *ctx, uint32_t l) { - if (isBoxableUnsignedInt(l)) { - return toPtr(boxInt((int32_t) l)); - } else { - return original_Long_FromUInt32_t(ctx, l); - } -} - -static HPy augment_Long_FromInt64_t(HPyContext *ctx, int64_t l) { - if (isBoxableInt(l)) { - return toPtr(boxInt((int32_t) l)); - } else { - return original_Long_FromInt64_t(ctx, l); - } -} - -static HPy augment_Long_FromUInt64_t(HPyContext *ctx, uint64_t l) { - if (isBoxableUnsignedInt(l)) { - return toPtr(boxInt((int32_t) l)); - } else { - return original_Long_FromUInt64_t(ctx, l); - } -} - -static HPy augment_Long_FromSsize_t(HPyContext *ctx, HPy_ssize_t l) { - if (isBoxableInt(l)) { - return toPtr(boxInt((int32_t) l)); - } else { - return original_Long_FromSsize_t(ctx, l); - } -} - -static HPy augment_Long_FromSize_t(HPyContext *ctx, size_t l) { - if (isBoxableUnsignedInt(l)) { - return toPtr(boxInt((int32_t) l)); - } else { - return original_Long_FromSize_t(ctx, l); - } -} - -static void augment_Close(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (!bits) { - return; - } else if (isBoxedHandle(bits)) { - if (bits < IMMUTABLE_HANDLES) { - return; - } - if (unclosedHandleTop < MAX_UNCLOSED_HANDLES) { - unclosedHandles[unclosedHandleTop++] = h; - } else { - upcallBulkClose(ctx, unclosedHandles, unclosedHandleTop); - memset(unclosedHandles, 0, sizeof(uint64_t) * unclosedHandleTop); - unclosedHandleTop = 0; - } - } -} - -static HPy augment_Dup(HPyContext *ctx, HPy h) { - uint64_t bits = toBits(h); - if (isBoxedHandle(bits)) { - if (bits < IMMUTABLE_HANDLES) { - return h; - } - return original_Dup(ctx, h); - } else { - return h; - } -} - -static int augment_Number_Check(HPyContext *ctx, HPy obj) { - uint64_t bits = toBits(obj); - if (isBoxedDouble(bits) || isBoxedInt(bits)) { - return true; - } else { - return original_Number_Check(ctx, obj); - } -} - -static int augment_TypeCheck(HPyContext *ctx, HPy obj, HPy type) { - uint64_t bits = toBits(obj); - if (isBoxedInt(bits)) { - return toBits(type) == toBits(ctx->h_LongType) || toBits(type) == toBits(ctx->h_BaseObjectType); - } else if (isBoxedDouble(bits)) { - return toBits(type) == toBits(ctx->h_FloatType) || toBits(type) == toBits(ctx->h_BaseObjectType); - } - return original_TypeCheck(ctx, obj, type); -} - -static int augment_List_Check(HPyContext *ctx, HPy obj) { - uint64_t bits = toBits(obj); - if (isBoxedHandle(bits)) { - return original_List_Check(ctx, obj); - } else { - return false; - } -} - -HPy augment_Global_Load(HPyContext *ctx, HPyGlobal global) { - uint64_t bits = toBits(global); - if (bits && isBoxedHandle(bits)) { - return original_Global_Load(ctx, global); - } else { - return toPtr(bits); - } -} - -void augment_Global_Store(HPyContext *ctx, HPyGlobal *global, HPy h) { - uint64_t bits = toBits(h); - if (bits && isBoxedHandle(bits)) { - original_Global_Store(ctx, global, h); - } else { - global->_i = h._i; - } -} - -HPy augment_Field_Load(HPyContext *ctx, HPy source_object, HPyField source_field) { - uint64_t bits = toBits(source_field); - if (bits && isBoxedHandle(bits)) { - return original_Field_Load(ctx, source_object, source_field); - } else { - return toPtr(bits); - } -} - -void augment_Field_Store(HPyContext *ctx, HPy target_object, HPyField *target_field, HPy h) { - uint64_t bits = toBits(h); - if (bits && isBoxedHandle(bits)) { - original_Field_Store(ctx, target_object, target_field, h); - } else { - target_field->_i = h._i; - } -} - -HPy augment_Type(HPyContext *ctx, HPy obj) { - uint64_t bits = toBits(obj); - if (isBoxedInt(bits)) { - return augment_Dup(ctx, ctx->h_LongType); - } else if (isBoxedDouble(bits)) - return augment_Dup(ctx, ctx->h_FloatType); - if (bits && isBoxedHandle(bits)) { - return original_Type(ctx, obj); - } else { - return toPtr(bits); - } -} - -#define GENERATE_AUGMENTED_BINOP(NAME, OP) \ - static HPy augment_##NAME(HPyContext *ctx, HPy h1, HPy h2) { \ - uint64_t bits1 = toBits(h1); \ - uint64_t bits2 = toBits(h2); \ - if (isBoxedInt(bits1) && isBoxedInt(bits2)) { \ - int64_t i1 = (int64_t) unboxInt(bits1); \ - int64_t i2 = (int64_t) unboxInt(bits2); \ - return augment_Long_FromInt64_t(ctx, i1 OP i2); \ - } else if (isBoxedInt(bits1) && isBoxedDouble(bits2)) { \ - int32_t i1 = unboxInt(bits1); \ - double f2 = unboxDouble(bits2); \ - return augment_Float_FromDouble(ctx, i1 OP f2); \ - } else if (isBoxedDouble(bits1) && isBoxedInt(bits2)) { \ - double f1 = unboxDouble(bits1); \ - int32_t i2 = unboxInt(bits2); \ - return augment_Float_FromDouble(ctx, f1 OP i2); \ - } else if (isBoxedDouble(bits1) && isBoxedDouble(bits2)) { \ - double f1 = unboxDouble(bits1); \ - double f2 = unboxDouble(bits2); \ - return augment_Float_FromDouble(ctx, f1 OP f2); \ - } \ - return original_##NAME(ctx, h1, h2); \ - } - -GENERATE_AUGMENTED_BINOP(Add, +) -GENERATE_AUGMENTED_BINOP(Subtract, -) -GENERATE_AUGMENTED_BINOP(Multiply, *) - -static HPy augment_FloorDivide(HPyContext *ctx, HPy h1, HPy h2) { - uint64_t bits1 = toBits(h1); - uint64_t bits2 = toBits(h2); - if (isBoxedInt(bits1) && isBoxedInt(bits2)) { - int32_t i1 = unboxInt(bits1); - int32_t i2 = unboxInt(bits2); - if (i2 == 0) { - HPyErr_SetString(ctx, ctx->h_ZeroDivisionError, "division by zero"); - return HPy_NULL; - } - return augment_Long_FromInt64_t(ctx, i1 / i2); - } - return original_FloorDivide(ctx, h1, h2); -} - -static HPy augment_TrueDivide(HPyContext *ctx, HPy h1, HPy h2) { - uint64_t bits1 = toBits(h1); - uint64_t bits2 = toBits(h2); - if (isBoxedInt(bits1) && isBoxedInt(bits2)) { - int32_t i2 = unboxInt(bits2); - if (i2 == 0) { - goto div_by_zero; - } - double f1 = (double) unboxInt(bits1); - return augment_Float_FromDouble(ctx, f1 / i2); - } else if (isBoxedInt(bits1) && isBoxedDouble(bits2)) { - int32_t i1 = unboxInt(bits1); - double f2 = unboxDouble(bits2); - if (f2 == 0.0) { - goto div_by_zero; - } - return augment_Float_FromDouble(ctx, i1 / f2); - } else if (isBoxedDouble(bits1) && isBoxedInt(bits2)) { - double f1 = unboxDouble(bits1); - int32_t i2 = unboxInt(bits2); - if (i2 == 0) { - goto div_by_zero; - } - return augment_Float_FromDouble(ctx, f1 / i2); - } else if (isBoxedDouble(bits1) && isBoxedDouble(bits2)) { - double f1 = unboxDouble(bits1); - double f2 = unboxDouble(bits2); - if (f2 == 0.0) { - goto div_by_zero; - } - return augment_Float_FromDouble(ctx, f1 / f2); - } - return original_TrueDivide(ctx, h1, h2); -div_by_zero: - HPyErr_SetString(ctx, ctx->h_ZeroDivisionError, "division by zero"); - return HPy_NULL; -} - -#define HPy_RETURN_RICHCOMPARE_BOOL(ctx, val1, val2, op) \ - do { \ - int result; \ - switch (op) { \ - case HPy_EQ: result = ((val1) == (val2)); break; \ - case HPy_NE: result = ((val1) != (val2)); break; \ - case HPy_LT: result = ((val1) < (val2)); break; \ - case HPy_GT: result = ((val1) > (val2)); break; \ - case HPy_LE: result = ((val1) <= (val2)); break; \ - case HPy_GE: result = ((val1) >= (val2)); break; \ - default: \ - HPy_FatalError(ctx, "Invalid value for HPy_RichCmpOp"); \ - } \ - return result; \ - } while (0) - -static inline int richcompare_boxed_values(HPyContext *ctx, uint64_t vbits, uint64_t wbits, int op) { - if (isBoxedInt(vbits)) { - if (isBoxedInt(wbits)) { - HPy_RETURN_RICHCOMPARE_BOOL(ctx, unboxInt(vbits), unboxInt(wbits), op); - } else { - assert(isBoxedDouble(wbits)); - HPy_RETURN_RICHCOMPARE_BOOL(ctx, unboxInt(vbits), unboxDouble(wbits), op); - } - } else { - assert(isBoxedDouble(vbits)); - if (isBoxedInt(wbits)) { - HPy_RETURN_RICHCOMPARE_BOOL(ctx, unboxDouble(vbits), unboxInt(wbits), op); - } else { - assert(isBoxedDouble(wbits)); - HPy_RETURN_RICHCOMPARE_BOOL(ctx, unboxDouble(vbits), unboxDouble(wbits), op); - } - } -} - -static HPy augment_RichCompare(HPyContext *ctx, HPy v, HPy w, int op) { - uint64_t vbits = toBits(v); - uint64_t wbits = toBits(w); - int result; - if (!isBoxedHandle(vbits) && !isBoxedHandle(wbits)) { - result = richcompare_boxed_values(ctx, vbits, wbits, op); - if (result) - return HPy_Dup(ctx, ctx->h_True); - return HPy_Dup(ctx, ctx->h_False); - } - return original_RichCompare(ctx, v, w, op); -} - -static int augment_RichCompareBool(HPyContext *ctx, HPy v, HPy w, int op) { - uint64_t vbits = toBits(v); - uint64_t wbits = toBits(w); - if (!isBoxedHandle(vbits) && !isBoxedHandle(wbits)) { - return richcompare_boxed_values(ctx, vbits, wbits, op); - } - return original_RichCompareBool(ctx, v, w, op); -} - -void init_native_fast_paths(HPyContext *context) { - LOG("%p", context); - -#define AUGMENT(name) \ - original_ ## name = context->ctx_ ## name; \ - context->ctx_ ## name = augment_ ## name; - - AUGMENT(Float_FromDouble); - AUGMENT(Float_AsDouble); - - AUGMENT(Long); - AUGMENT(Long_AsInt32_t); - AUGMENT(Long_AsInt64_t); - AUGMENT(Long_AsUInt32_t); - AUGMENT(Long_AsDouble); - AUGMENT(Long_AsSsize_t); - AUGMENT(Long_AsSize_t); - AUGMENT(Long_FromInt32_t); - AUGMENT(Long_FromUInt32_t); - AUGMENT(Long_FromInt64_t); - AUGMENT(Long_FromUInt64_t); - AUGMENT(Long_FromSsize_t); - AUGMENT(Long_FromSize_t); - - AUGMENT(Dup); - AUGMENT(Close); - - AUGMENT(AsStruct_Object); - context->ctx_AsStruct_Legacy = augment_AsStruct_Object; - context->ctx_AsStruct_Float = augment_AsStruct_Object; - context->ctx_AsStruct_List = augment_AsStruct_Object; - context->ctx_AsStruct_Long = augment_AsStruct_Object; - context->ctx_AsStruct_Type = augment_AsStruct_Object; - context->ctx_AsStruct_Unicode = augment_AsStruct_Object; - context->ctx_AsStruct_Tuple = augment_AsStruct_Object; - - - AUGMENT(Number_Check); - - AUGMENT(TypeCheck); - - AUGMENT(List_Check); - - AUGMENT(Global_Load); - AUGMENT(Global_Store); - - AUGMENT(Field_Load); - AUGMENT(Field_Store); - - AUGMENT(Is); - AUGMENT(IsTrue); - - AUGMENT(Type); - - AUGMENT(Add); - AUGMENT(Subtract); - AUGMENT(Multiply); - AUGMENT(FloorDivide); - AUGMENT(TrueDivide); - - AUGMENT(RichCompare); - AUGMENT(RichCompareBool); - -#undef AUGMENT -} diff --git a/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.h b/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.h deleted file mode 100644 index 7fb7582366..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/hpy_native_fast_paths.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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. - */ - - -#ifndef HPY_NATIVE_FAST_PATHS_H_ -#define HPY_NATIVE_FAST_PATHS_H_ - -//************************* -// BOXING - -#define NAN_BOXING_BASE (0x0007000000000000llu) -#define NAN_BOXING_MASK (0xFFFF000000000000llu) -#define NAN_BOXING_INT (0x0001000000000000llu) -#define NAN_BOXING_INT_MASK (0x00000000FFFFFFFFllu) -#define NAN_BOXING_MAX_HANDLE (0x000000007FFFFFFFllu) -#define IMMUTABLE_HANDLES (0x0000000000000100llu) - -// Some singleton Python objects are guaranteed to be always represented by -// those handles, so that we do not have to upcall to unambiguously check if -// a handle represents one of those -#define SINGLETON_HANDLES_MAX (3) - -#define isBoxedDouble(value) ((value) >= NAN_BOXING_BASE) -#define isBoxedHandle(value) ((value) <= NAN_BOXING_MAX_HANDLE) -#define isBoxedInt(value) (((value) & NAN_BOXING_MASK) == NAN_BOXING_INT) - -#define unboxHandle(value) (value) -#define boxHandle(handle) (handle) - -#define isBoxableInt(value) (INT32_MIN < (value) && (value) < INT32_MAX) -#define isBoxableUnsignedInt(value) ((value) < INT32_MAX) -#define unboxInt(value) ((int32_t) ((value) - NAN_BOXING_INT)) -#define boxInt(value) ((((uint64_t) (value)) & NAN_BOXING_INT_MASK) + NAN_BOXING_INT) - -#define toBits(ptr) ((uint64_t) ((ptr)._i)) -#define toPtr(ptr) ((HPy) { (HPy_ssize_t) (ptr) }) - -//************************* -// native HPyTracker implementation - -typedef struct { - HPy_ssize_t capacity; // allocated handles - HPy_ssize_t length; // used handles - HPy *handles; -} _HPyTracker_s; - -static inline _HPyTracker_s *_ht2hp(HPyTracker ht) { - return (_HPyTracker_s *) (ht)._i; -} -static inline HPyTracker _hp2ht(_HPyTracker_s *hp) { - return (HPyTracker) {(HPy_ssize_t) (hp)}; -} - -void init_native_fast_paths(HPyContext *context); - -#endif /* HPY_NATIVE_FAST_PATHS_H_ */ diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/_tracemod.c b/graalpython/com.oracle.graal.python.jni/src/trace/_tracemod.c deleted file mode 100644 index e52bb5a464..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/_tracemod.c +++ /dev/null @@ -1,275 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -// Python-level interface for the _trace module. Written in HPy itself, the -// idea is that it should be reusable by other implementations - -// NOTE: hpy.trace._trace is loaded using the UNIVERSAL ctx. To make it -// clearer, we will use "uctx" and "tctx" to distinguish them. - -#include "hpy.h" -#include "trace_internal.h" - -#ifndef _WIN32 -#include -#define MAX_SEC (LLONG_MAX / FREQ_NSEC) -#endif - -HPY_MOD_EMBEDDABLE(_trace) - -static inline int is_empty(const char *s) -{ - return s[0] == '\0'; -} - -#ifdef _WIN32 -static inline HPy win_time_to_ns(HPyContext *uctx, const LONGLONG to_ns, _HPyTime_t t) -{ - return HPyLong_FromLongLong(uctx, t.QuadPart * to_ns); -} - -#else -static inline HPy posix_time_to_ns(HPyContext *uctx, HPy *s_to_ns, _HPyTime_t t) -{ - /* Fast-path: If we can fit into a signed 64-bit integer, then do the - computation in C. This is the case if we can do 't.tv_sec * FREQ_SEC' - (i.e. converting seconds to nanoseconds) and add 'tv.tv_nsec' without - overflowing. */ - if (t.tv_sec < MAX_SEC) { - return HPyLong_FromLongLong(uctx, (long long)t.tv_sec * FREQ_NSEC + - (long long)t.tv_nsec); - } else { - /* Slow-path: do the computation with an (unbound) Python long */ - if (HPy_IsNull(*s_to_ns)) { - *s_to_ns = HPyLong_FromLongLong(uctx, FREQ_NSEC); - } - - HPy h_tv_sec = HPyLong_FromLongLong(uctx, t.tv_sec); - HPy h_tv_sec_as_ns = HPy_Multiply(uctx, h_tv_sec, *s_to_ns); - HPy_Close(uctx, h_tv_sec); - - HPy tv_nsec = HPyLong_FromLong(uctx, t.tv_nsec); - HPy res = HPy_Add(uctx, h_tv_sec_as_ns, tv_nsec); - HPy_Close(uctx, h_tv_sec_as_ns); - HPy_Close(uctx, tv_nsec); - - return res; - } -} -#endif - -HPyDef_METH(get_durations, "get_durations", HPyFunc_NOARGS) -static HPy get_durations_impl(HPyContext *uctx, HPy self) -{ - HPyContext *tctx = hpy_trace_get_ctx(uctx); - HPyTraceInfo *info = get_info(tctx); - HPyTracker ht = HPyTracker_New(uctx, hpy_trace_get_nfunc()); - -#ifdef _WIN32 - const LONGLONG to_ns = FREQ_NSEC / info->counter_freq.QuadPart; -#else - HPy s_to_ns = HPy_NULL; -#endif - HPy res = HPyDict_New(uctx); - const char *func_name; - for (int i=0; (func_name = hpy_trace_get_func_name(i)); i++) - { - /* skip empty names; those indices denote a context handle */ - if (!is_empty(func_name)) - { -#ifdef _WIN32 - HPy value = win_time_to_ns(uctx, to_ns, info->durations[i]); -#else - HPy value = posix_time_to_ns(uctx, &s_to_ns, info->durations[i]); -#endif - HPyTracker_Add(uctx, ht, value); - if (HPy_IsNull(value)) - goto fail; - if (HPy_SetItem_s(uctx, res, func_name, value) < 0) - goto fail; - } - } -#ifndef _WIN32 - HPy_Close(uctx, s_to_ns); -#endif - HPyTracker_Close(uctx, ht); - return res; -fail: - HPy_Close(uctx, res); - HPyTracker_Close(uctx, ht); - return HPy_NULL; -} - -HPyDef_METH(get_call_counts, "get_call_counts", HPyFunc_NOARGS) -static HPy get_call_counts_impl(HPyContext *uctx, HPy self) -{ - HPyContext *tctx = hpy_trace_get_ctx(uctx); - HPyTraceInfo *info = get_info(tctx); - HPyTracker ht = HPyTracker_New(uctx, hpy_trace_get_nfunc()); - HPy res = HPyDict_New(uctx); - const char *func_name; - for (int i=0; (func_name = hpy_trace_get_func_name(i)); i++) - { - /* skip empty names; those indices denote a context handle */ - if (!is_empty(func_name)) - { - HPy value = HPyLong_FromUnsignedLongLong(uctx, - (unsigned long long)info->call_counts[i]); - HPyTracker_Add(uctx, ht, value); - if (HPy_IsNull(value)) - goto fail; - if (HPy_SetItem_s(uctx, res, func_name, value) < 0) - goto fail; - } - } - HPyTracker_Close(uctx, ht); - return res; -fail: - HPy_Close(uctx, res); - HPyTracker_Close(uctx, ht); - return HPy_NULL; -} - -static int check_and_set_func(HPyContext *uctx, HPy arg, HPy *out) -{ - if (HPy_IsNull(arg)) { - // not provided -> do not change value - return 0; - } else if (HPy_Is(uctx, arg, uctx->h_None)) { - // None -> clear function - *out = HPy_NULL; - return 0; - } else if (!HPyCallable_Check(uctx, arg)) { - // not null, not None, not callable -> error - HPyErr_SetString(uctx, uctx->h_TypeError, "Expected a callable object or None"); - return -1; - } - // a callable -> set function - *out = HPy_Dup(uctx, arg); - return 0; -} - -static const char *set_trace_funcs_kwlist[] = { "on_enter", "on_exit", NULL }; - -static int -get_optional_arg(HPyContext *ctx, const HPy *args, size_t nargs, HPy kwnames, - HPy_ssize_t i, const char *kwname, HPy *out) -{ - HPy_ssize_t nkw, j; - HPy h_kwname, h_item; - // if given as positional arg - if (i < (HPy_ssize_t) nargs) { - *out = args[i]; - return 0; - } - - if (HPy_IsNull(kwnames)) { - return 0; - } - - nkw = HPy_Length(ctx, kwnames); - if (nkw < 0) { - return -1; - } - h_kwname = HPyUnicode_FromString(ctx, kwname); - if (HPy_IsNull(h_kwname)) { - return -1; - } - for (j=0; j < nkw; j++) { - h_item = HPy_GetItem_i(ctx, kwnames, j); - if (HPy_IsNull(h_item)) { - HPy_Close(ctx, h_kwname); - return -1; - } - if (HPy_RichCompareBool(ctx, h_kwname, h_item, HPy_EQ)) { - HPy_Close(ctx, h_kwname); - HPy_Close(ctx, h_item); - *out = args[nargs + j]; - return 0; - } - HPy_Close(ctx, h_item); - } - return 0; -} - -HPyDef_METH(set_trace_functions, "set_trace_functions", HPyFunc_KEYWORDS, - .doc="Set the functions to call if an HPy API is entered/exited.") -static HPy set_trace_functions_impl(HPyContext *uctx, HPy self, const HPy *args, - size_t nargs, HPy kwnames) -{ - HPy h_on_enter = HPy_NULL; - HPy h_on_exit = HPy_NULL; - HPyContext *dctx = hpy_trace_get_ctx(uctx); - HPyTraceInfo *info = get_info(dctx); - - // GraalPy change: avoid usage of HPyArg_ParseKeywords - if (get_optional_arg(uctx, args, nargs, kwnames, 0, - set_trace_funcs_kwlist[0], &h_on_enter) < 0 - || get_optional_arg(uctx, args, nargs, kwnames, 1, - set_trace_funcs_kwlist[1], &h_on_exit) < 0) - { - return HPy_NULL; - } - - int r = check_and_set_func(uctx, h_on_enter, &info->on_enter_func) < 0 || - check_and_set_func(uctx, h_on_exit, &info->on_exit_func) < 0; - if (r) { - return HPy_NULL; - } - return HPy_Dup(uctx, uctx->h_None); -} - -HPyDef_METH(get_frequency, "get_frequency", HPyFunc_NOARGS, - .doc="Resolution of the used clock in Hertz.") -static HPy get_frequency_impl(HPyContext *uctx, HPy self) -{ - HPyContext *tctx = hpy_trace_get_ctx(uctx); - HPyTraceInfo *info = get_info(tctx); -#ifdef _WIN32 - long long f = (long long) info->counter_freq.QuadPart; -#else - long long f = (long long) info->counter_freq.tv_sec + - (long long)info->counter_freq.tv_nsec * FREQ_NSEC; -#endif - return HPyLong_FromLongLong(uctx, f); -} - - -/* ~~~~~~ definition of the module hpy.trace._trace ~~~~~~~ */ - -static HPyDef *module_defines[] = { - &get_durations, - &get_call_counts, - &set_trace_functions, - &get_frequency, - NULL -}; - -static HPyModuleDef moduledef = { - .doc = "HPy trace mode", - .size = 0, - .defines = module_defines -}; - -HPy_MODINIT(_trace, moduledef) diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_ctx_init.h b/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_ctx_init.h deleted file mode 100644 index cbcfd1a31e..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_ctx_init.h +++ /dev/null @@ -1,500 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.trace.autogen_tracer_ctx_init_h - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -HPy trace_ctx_Dup(HPyContext *tctx, HPy h); -void trace_ctx_Close(HPyContext *tctx, HPy h); -HPy trace_ctx_Long_FromInt32_t(HPyContext *tctx, int32_t value); -HPy trace_ctx_Long_FromUInt32_t(HPyContext *tctx, uint32_t value); -HPy trace_ctx_Long_FromInt64_t(HPyContext *tctx, int64_t v); -HPy trace_ctx_Long_FromUInt64_t(HPyContext *tctx, uint64_t v); -HPy trace_ctx_Long_FromSize_t(HPyContext *tctx, size_t value); -HPy trace_ctx_Long_FromSsize_t(HPyContext *tctx, HPy_ssize_t value); -int32_t trace_ctx_Long_AsInt32_t(HPyContext *tctx, HPy h); -uint32_t trace_ctx_Long_AsUInt32_t(HPyContext *tctx, HPy h); -uint32_t trace_ctx_Long_AsUInt32_tMask(HPyContext *tctx, HPy h); -int64_t trace_ctx_Long_AsInt64_t(HPyContext *tctx, HPy h); -uint64_t trace_ctx_Long_AsUInt64_t(HPyContext *tctx, HPy h); -uint64_t trace_ctx_Long_AsUInt64_tMask(HPyContext *tctx, HPy h); -size_t trace_ctx_Long_AsSize_t(HPyContext *tctx, HPy h); -HPy_ssize_t trace_ctx_Long_AsSsize_t(HPyContext *tctx, HPy h); -void *trace_ctx_Long_AsVoidPtr(HPyContext *tctx, HPy h); -double trace_ctx_Long_AsDouble(HPyContext *tctx, HPy h); -HPy trace_ctx_Float_FromDouble(HPyContext *tctx, double v); -double trace_ctx_Float_AsDouble(HPyContext *tctx, HPy h); -HPy trace_ctx_Bool_FromBool(HPyContext *tctx, bool v); -HPy_ssize_t trace_ctx_Length(HPyContext *tctx, HPy h); -int trace_ctx_Number_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_Add(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Subtract(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Multiply(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_MatrixMultiply(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_FloorDivide(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_TrueDivide(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Remainder(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Divmod(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Power(HPyContext *tctx, HPy h1, HPy h2, HPy h3); -HPy trace_ctx_Negative(HPyContext *tctx, HPy h1); -HPy trace_ctx_Positive(HPyContext *tctx, HPy h1); -HPy trace_ctx_Absolute(HPyContext *tctx, HPy h1); -HPy trace_ctx_Invert(HPyContext *tctx, HPy h1); -HPy trace_ctx_Lshift(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Rshift(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_And(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Xor(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Or(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_Index(HPyContext *tctx, HPy h1); -HPy trace_ctx_Long(HPyContext *tctx, HPy h1); -HPy trace_ctx_Float(HPyContext *tctx, HPy h1); -HPy trace_ctx_InPlaceAdd(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceSubtract(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceMultiply(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceMatrixMultiply(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceFloorDivide(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceTrueDivide(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceRemainder(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlacePower(HPyContext *tctx, HPy h1, HPy h2, HPy h3); -HPy trace_ctx_InPlaceLshift(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceRshift(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceAnd(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceXor(HPyContext *tctx, HPy h1, HPy h2); -HPy trace_ctx_InPlaceOr(HPyContext *tctx, HPy h1, HPy h2); -int trace_ctx_Callable_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_CallTupleDict(HPyContext *tctx, HPy callable, HPy args, HPy kw); -HPy trace_ctx_Call(HPyContext *tctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames); -HPy trace_ctx_CallMethod(HPyContext *tctx, HPy name, const HPy *args, size_t nargs, HPy kwnames); -void trace_ctx_Err_SetString(HPyContext *tctx, HPy h_type, const char *utf8_message); -void trace_ctx_Err_SetObject(HPyContext *tctx, HPy h_type, HPy h_value); -HPy trace_ctx_Err_SetFromErrnoWithFilename(HPyContext *tctx, HPy h_type, const char *filename_fsencoded); -void trace_ctx_Err_SetFromErrnoWithFilenameObjects(HPyContext *tctx, HPy h_type, HPy filename1, HPy filename2); -int trace_ctx_Err_Occurred(HPyContext *tctx); -int trace_ctx_Err_ExceptionMatches(HPyContext *tctx, HPy exc); -void trace_ctx_Err_NoMemory(HPyContext *tctx); -void trace_ctx_Err_Clear(HPyContext *tctx); -HPy trace_ctx_Err_NewException(HPyContext *tctx, const char *utf8_name, HPy base, HPy dict); -HPy trace_ctx_Err_NewExceptionWithDoc(HPyContext *tctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict); -int trace_ctx_Err_WarnEx(HPyContext *tctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level); -void trace_ctx_Err_WriteUnraisable(HPyContext *tctx, HPy obj); -int trace_ctx_IsTrue(HPyContext *tctx, HPy h); -HPy trace_ctx_Type_FromSpec(HPyContext *tctx, HPyType_Spec *spec, HPyType_SpecParam *params); -HPy trace_ctx_Type_GenericNew(HPyContext *tctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw); -HPy trace_ctx_GetAttr(HPyContext *tctx, HPy obj, HPy name); -HPy trace_ctx_GetAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name); -int trace_ctx_HasAttr(HPyContext *tctx, HPy obj, HPy name); -int trace_ctx_HasAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name); -int trace_ctx_SetAttr(HPyContext *tctx, HPy obj, HPy name, HPy value); -int trace_ctx_SetAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name, HPy value); -HPy trace_ctx_GetItem(HPyContext *tctx, HPy obj, HPy key); -HPy trace_ctx_GetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx); -HPy trace_ctx_GetItem_s(HPyContext *tctx, HPy obj, const char *utf8_key); -int trace_ctx_Contains(HPyContext *tctx, HPy container, HPy key); -int trace_ctx_SetItem(HPyContext *tctx, HPy obj, HPy key, HPy value); -int trace_ctx_SetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx, HPy value); -int trace_ctx_SetItem_s(HPyContext *tctx, HPy obj, const char *utf8_key, HPy value); -int trace_ctx_DelItem(HPyContext *tctx, HPy obj, HPy key); -int trace_ctx_DelItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx); -int trace_ctx_DelItem_s(HPyContext *tctx, HPy obj, const char *utf8_key); -HPy trace_ctx_Type(HPyContext *tctx, HPy obj); -int trace_ctx_TypeCheck(HPyContext *tctx, HPy obj, HPy type); -const char *trace_ctx_Type_GetName(HPyContext *tctx, HPy type); -int trace_ctx_Type_IsSubtype(HPyContext *tctx, HPy sub, HPy type); -int trace_ctx_Is(HPyContext *tctx, HPy obj, HPy other); -void *trace_ctx_AsStruct_Object(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Legacy(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Type(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Long(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Float(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Unicode(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_Tuple(HPyContext *tctx, HPy h); -void *trace_ctx_AsStruct_List(HPyContext *tctx, HPy h); -HPyType_BuiltinShape trace_ctx_Type_GetBuiltinShape(HPyContext *tctx, HPy h_type); -HPy trace_ctx_New(HPyContext *tctx, HPy h_type, void **data); -HPy trace_ctx_Repr(HPyContext *tctx, HPy obj); -HPy trace_ctx_Str(HPyContext *tctx, HPy obj); -HPy trace_ctx_ASCII(HPyContext *tctx, HPy obj); -HPy trace_ctx_Bytes(HPyContext *tctx, HPy obj); -HPy trace_ctx_RichCompare(HPyContext *tctx, HPy v, HPy w, int op); -int trace_ctx_RichCompareBool(HPyContext *tctx, HPy v, HPy w, int op); -HPy_hash_t trace_ctx_Hash(HPyContext *tctx, HPy obj); -int trace_ctx_Bytes_Check(HPyContext *tctx, HPy h); -HPy_ssize_t trace_ctx_Bytes_Size(HPyContext *tctx, HPy h); -HPy_ssize_t trace_ctx_Bytes_GET_SIZE(HPyContext *tctx, HPy h); -const char *trace_ctx_Bytes_AsString(HPyContext *tctx, HPy h); -const char *trace_ctx_Bytes_AS_STRING(HPyContext *tctx, HPy h); -HPy trace_ctx_Bytes_FromString(HPyContext *tctx, const char *bytes); -HPy trace_ctx_Bytes_FromStringAndSize(HPyContext *tctx, const char *bytes, HPy_ssize_t len); -HPy trace_ctx_Unicode_FromString(HPyContext *tctx, const char *utf8); -int trace_ctx_Unicode_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_Unicode_AsASCIIString(HPyContext *tctx, HPy h); -HPy trace_ctx_Unicode_AsLatin1String(HPyContext *tctx, HPy h); -HPy trace_ctx_Unicode_AsUTF8String(HPyContext *tctx, HPy h); -const char *trace_ctx_Unicode_AsUTF8AndSize(HPyContext *tctx, HPy h, HPy_ssize_t *size); -HPy trace_ctx_Unicode_FromWideChar(HPyContext *tctx, const wchar_t *w, HPy_ssize_t size); -HPy trace_ctx_Unicode_DecodeFSDefault(HPyContext *tctx, const char *v); -HPy trace_ctx_Unicode_DecodeFSDefaultAndSize(HPyContext *tctx, const char *v, HPy_ssize_t size); -HPy trace_ctx_Unicode_EncodeFSDefault(HPyContext *tctx, HPy h); -HPy_UCS4 trace_ctx_Unicode_ReadChar(HPyContext *tctx, HPy h, HPy_ssize_t index); -HPy trace_ctx_Unicode_DecodeASCII(HPyContext *tctx, const char *ascii, HPy_ssize_t size, const char *errors); -HPy trace_ctx_Unicode_DecodeLatin1(HPyContext *tctx, const char *latin1, HPy_ssize_t size, const char *errors); -HPy trace_ctx_Unicode_FromEncodedObject(HPyContext *tctx, HPy obj, const char *encoding, const char *errors); -HPy trace_ctx_Unicode_Substring(HPyContext *tctx, HPy str, HPy_ssize_t start, HPy_ssize_t end); -int trace_ctx_List_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_List_New(HPyContext *tctx, HPy_ssize_t len); -int trace_ctx_List_Append(HPyContext *tctx, HPy h_list, HPy h_item); -int trace_ctx_Dict_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_Dict_New(HPyContext *tctx); -HPy trace_ctx_Dict_Keys(HPyContext *tctx, HPy h); -HPy trace_ctx_Dict_Copy(HPyContext *tctx, HPy h); -int trace_ctx_Tuple_Check(HPyContext *tctx, HPy h); -HPy trace_ctx_Tuple_FromArray(HPyContext *tctx, HPy items[], HPy_ssize_t n); -int trace_ctx_Slice_Unpack(HPyContext *tctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step); -HPy trace_ctx_Import_ImportModule(HPyContext *tctx, const char *utf8_name); -HPy trace_ctx_Capsule_New(HPyContext *tctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor); -void *trace_ctx_Capsule_Get(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name); -int trace_ctx_Capsule_IsValid(HPyContext *tctx, HPy capsule, const char *utf8_name); -int trace_ctx_Capsule_Set(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, void *value); -HPy trace_ctx_FromPyObject(HPyContext *tctx, cpy_PyObject *obj); -cpy_PyObject *trace_ctx_AsPyObject(HPyContext *tctx, HPy h); -HPyListBuilder trace_ctx_ListBuilder_New(HPyContext *tctx, HPy_ssize_t size); -void trace_ctx_ListBuilder_Set(HPyContext *tctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item); -HPy trace_ctx_ListBuilder_Build(HPyContext *tctx, HPyListBuilder builder); -void trace_ctx_ListBuilder_Cancel(HPyContext *tctx, HPyListBuilder builder); -HPyTupleBuilder trace_ctx_TupleBuilder_New(HPyContext *tctx, HPy_ssize_t size); -void trace_ctx_TupleBuilder_Set(HPyContext *tctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item); -HPy trace_ctx_TupleBuilder_Build(HPyContext *tctx, HPyTupleBuilder builder); -void trace_ctx_TupleBuilder_Cancel(HPyContext *tctx, HPyTupleBuilder builder); -HPyTracker trace_ctx_Tracker_New(HPyContext *tctx, HPy_ssize_t size); -int trace_ctx_Tracker_Add(HPyContext *tctx, HPyTracker ht, HPy h); -void trace_ctx_Tracker_ForgetAll(HPyContext *tctx, HPyTracker ht); -void trace_ctx_Tracker_Close(HPyContext *tctx, HPyTracker ht); -void trace_ctx_Field_Store(HPyContext *tctx, HPy target_object, HPyField *target_field, HPy h); -HPy trace_ctx_Field_Load(HPyContext *tctx, HPy source_object, HPyField source_field); -void trace_ctx_ReenterPythonExecution(HPyContext *tctx, HPyThreadState state); -HPyThreadState trace_ctx_LeavePythonExecution(HPyContext *tctx); -void trace_ctx_Global_Store(HPyContext *tctx, HPyGlobal *global, HPy h); -HPy trace_ctx_Global_Load(HPyContext *tctx, HPyGlobal global); -void trace_ctx_Dump(HPyContext *tctx, HPy h); -HPy trace_ctx_Compile_s(HPyContext *tctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind); -HPy trace_ctx_EvalCode(HPyContext *tctx, HPy code, HPy globals, HPy locals); -HPy trace_ctx_ContextVar_New(HPyContext *tctx, const char *name, HPy default_value); -int32_t trace_ctx_ContextVar_Get(HPyContext *tctx, HPy context_var, HPy default_value, HPy *result); -HPy trace_ctx_ContextVar_Set(HPyContext *tctx, HPy context_var, HPy value); -int trace_ctx_SetCallFunction(HPyContext *tctx, HPy h, HPyCallFunction *func); - -static inline void trace_ctx_init_info(HPyTraceInfo *info, HPyContext *uctx) -{ - info->magic_number = HPY_TRACE_MAGIC; - info->uctx = uctx; - info->call_counts = (uint64_t *)calloc(263, sizeof(uint64_t)); - info->durations = (_HPyTime_t *)calloc(263, sizeof(_HPyTime_t)); - info->on_enter_func = HPy_NULL; - info->on_exit_func = HPy_NULL; -} - -static inline void trace_ctx_free_info(HPyTraceInfo *info) -{ - assert(info->magic_number == HPY_TRACE_MAGIC); - free(info->call_counts); - free(info->durations); - HPy_Close(info->uctx, info->on_enter_func); - HPy_Close(info->uctx, info->on_exit_func); -} - -static inline void trace_ctx_init_fields(HPyContext *tctx, HPyContext *uctx) -{ - tctx->h_None = uctx->h_None; - tctx->h_True = uctx->h_True; - tctx->h_False = uctx->h_False; - tctx->h_NotImplemented = uctx->h_NotImplemented; - tctx->h_Ellipsis = uctx->h_Ellipsis; - tctx->h_BaseException = uctx->h_BaseException; - tctx->h_Exception = uctx->h_Exception; - tctx->h_StopAsyncIteration = uctx->h_StopAsyncIteration; - tctx->h_StopIteration = uctx->h_StopIteration; - tctx->h_GeneratorExit = uctx->h_GeneratorExit; - tctx->h_ArithmeticError = uctx->h_ArithmeticError; - tctx->h_LookupError = uctx->h_LookupError; - tctx->h_AssertionError = uctx->h_AssertionError; - tctx->h_AttributeError = uctx->h_AttributeError; - tctx->h_BufferError = uctx->h_BufferError; - tctx->h_EOFError = uctx->h_EOFError; - tctx->h_FloatingPointError = uctx->h_FloatingPointError; - tctx->h_OSError = uctx->h_OSError; - tctx->h_ImportError = uctx->h_ImportError; - tctx->h_ModuleNotFoundError = uctx->h_ModuleNotFoundError; - tctx->h_IndexError = uctx->h_IndexError; - tctx->h_KeyError = uctx->h_KeyError; - tctx->h_KeyboardInterrupt = uctx->h_KeyboardInterrupt; - tctx->h_MemoryError = uctx->h_MemoryError; - tctx->h_NameError = uctx->h_NameError; - tctx->h_OverflowError = uctx->h_OverflowError; - tctx->h_RuntimeError = uctx->h_RuntimeError; - tctx->h_RecursionError = uctx->h_RecursionError; - tctx->h_NotImplementedError = uctx->h_NotImplementedError; - tctx->h_SyntaxError = uctx->h_SyntaxError; - tctx->h_IndentationError = uctx->h_IndentationError; - tctx->h_TabError = uctx->h_TabError; - tctx->h_ReferenceError = uctx->h_ReferenceError; - tctx->h_SystemError = uctx->h_SystemError; - tctx->h_SystemExit = uctx->h_SystemExit; - tctx->h_TypeError = uctx->h_TypeError; - tctx->h_UnboundLocalError = uctx->h_UnboundLocalError; - tctx->h_UnicodeError = uctx->h_UnicodeError; - tctx->h_UnicodeEncodeError = uctx->h_UnicodeEncodeError; - tctx->h_UnicodeDecodeError = uctx->h_UnicodeDecodeError; - tctx->h_UnicodeTranslateError = uctx->h_UnicodeTranslateError; - tctx->h_ValueError = uctx->h_ValueError; - tctx->h_ZeroDivisionError = uctx->h_ZeroDivisionError; - tctx->h_BlockingIOError = uctx->h_BlockingIOError; - tctx->h_BrokenPipeError = uctx->h_BrokenPipeError; - tctx->h_ChildProcessError = uctx->h_ChildProcessError; - tctx->h_ConnectionError = uctx->h_ConnectionError; - tctx->h_ConnectionAbortedError = uctx->h_ConnectionAbortedError; - tctx->h_ConnectionRefusedError = uctx->h_ConnectionRefusedError; - tctx->h_ConnectionResetError = uctx->h_ConnectionResetError; - tctx->h_FileExistsError = uctx->h_FileExistsError; - tctx->h_FileNotFoundError = uctx->h_FileNotFoundError; - tctx->h_InterruptedError = uctx->h_InterruptedError; - tctx->h_IsADirectoryError = uctx->h_IsADirectoryError; - tctx->h_NotADirectoryError = uctx->h_NotADirectoryError; - tctx->h_PermissionError = uctx->h_PermissionError; - tctx->h_ProcessLookupError = uctx->h_ProcessLookupError; - tctx->h_TimeoutError = uctx->h_TimeoutError; - tctx->h_Warning = uctx->h_Warning; - tctx->h_UserWarning = uctx->h_UserWarning; - tctx->h_DeprecationWarning = uctx->h_DeprecationWarning; - tctx->h_PendingDeprecationWarning = uctx->h_PendingDeprecationWarning; - tctx->h_SyntaxWarning = uctx->h_SyntaxWarning; - tctx->h_RuntimeWarning = uctx->h_RuntimeWarning; - tctx->h_FutureWarning = uctx->h_FutureWarning; - tctx->h_ImportWarning = uctx->h_ImportWarning; - tctx->h_UnicodeWarning = uctx->h_UnicodeWarning; - tctx->h_BytesWarning = uctx->h_BytesWarning; - tctx->h_ResourceWarning = uctx->h_ResourceWarning; - tctx->h_BaseObjectType = uctx->h_BaseObjectType; - tctx->h_TypeType = uctx->h_TypeType; - tctx->h_BoolType = uctx->h_BoolType; - tctx->h_LongType = uctx->h_LongType; - tctx->h_FloatType = uctx->h_FloatType; - tctx->h_UnicodeType = uctx->h_UnicodeType; - tctx->h_TupleType = uctx->h_TupleType; - tctx->h_ListType = uctx->h_ListType; - tctx->h_ComplexType = uctx->h_ComplexType; - tctx->h_BytesType = uctx->h_BytesType; - tctx->h_MemoryViewType = uctx->h_MemoryViewType; - tctx->h_CapsuleType = uctx->h_CapsuleType; - tctx->h_SliceType = uctx->h_SliceType; - tctx->h_Builtins = uctx->h_Builtins; - tctx->ctx_Dup = &trace_ctx_Dup; - tctx->ctx_Close = &trace_ctx_Close; - tctx->ctx_Long_FromInt32_t = &trace_ctx_Long_FromInt32_t; - tctx->ctx_Long_FromUInt32_t = &trace_ctx_Long_FromUInt32_t; - tctx->ctx_Long_FromInt64_t = &trace_ctx_Long_FromInt64_t; - tctx->ctx_Long_FromUInt64_t = &trace_ctx_Long_FromUInt64_t; - tctx->ctx_Long_FromSize_t = &trace_ctx_Long_FromSize_t; - tctx->ctx_Long_FromSsize_t = &trace_ctx_Long_FromSsize_t; - tctx->ctx_Long_AsInt32_t = &trace_ctx_Long_AsInt32_t; - tctx->ctx_Long_AsUInt32_t = &trace_ctx_Long_AsUInt32_t; - tctx->ctx_Long_AsUInt32_tMask = &trace_ctx_Long_AsUInt32_tMask; - tctx->ctx_Long_AsInt64_t = &trace_ctx_Long_AsInt64_t; - tctx->ctx_Long_AsUInt64_t = &trace_ctx_Long_AsUInt64_t; - tctx->ctx_Long_AsUInt64_tMask = &trace_ctx_Long_AsUInt64_tMask; - tctx->ctx_Long_AsSize_t = &trace_ctx_Long_AsSize_t; - tctx->ctx_Long_AsSsize_t = &trace_ctx_Long_AsSsize_t; - tctx->ctx_Long_AsVoidPtr = &trace_ctx_Long_AsVoidPtr; - tctx->ctx_Long_AsDouble = &trace_ctx_Long_AsDouble; - tctx->ctx_Float_FromDouble = &trace_ctx_Float_FromDouble; - tctx->ctx_Float_AsDouble = &trace_ctx_Float_AsDouble; - tctx->ctx_Bool_FromBool = &trace_ctx_Bool_FromBool; - tctx->ctx_Length = &trace_ctx_Length; - tctx->ctx_Number_Check = &trace_ctx_Number_Check; - tctx->ctx_Add = &trace_ctx_Add; - tctx->ctx_Subtract = &trace_ctx_Subtract; - tctx->ctx_Multiply = &trace_ctx_Multiply; - tctx->ctx_MatrixMultiply = &trace_ctx_MatrixMultiply; - tctx->ctx_FloorDivide = &trace_ctx_FloorDivide; - tctx->ctx_TrueDivide = &trace_ctx_TrueDivide; - tctx->ctx_Remainder = &trace_ctx_Remainder; - tctx->ctx_Divmod = &trace_ctx_Divmod; - tctx->ctx_Power = &trace_ctx_Power; - tctx->ctx_Negative = &trace_ctx_Negative; - tctx->ctx_Positive = &trace_ctx_Positive; - tctx->ctx_Absolute = &trace_ctx_Absolute; - tctx->ctx_Invert = &trace_ctx_Invert; - tctx->ctx_Lshift = &trace_ctx_Lshift; - tctx->ctx_Rshift = &trace_ctx_Rshift; - tctx->ctx_And = &trace_ctx_And; - tctx->ctx_Xor = &trace_ctx_Xor; - tctx->ctx_Or = &trace_ctx_Or; - tctx->ctx_Index = &trace_ctx_Index; - tctx->ctx_Long = &trace_ctx_Long; - tctx->ctx_Float = &trace_ctx_Float; - tctx->ctx_InPlaceAdd = &trace_ctx_InPlaceAdd; - tctx->ctx_InPlaceSubtract = &trace_ctx_InPlaceSubtract; - tctx->ctx_InPlaceMultiply = &trace_ctx_InPlaceMultiply; - tctx->ctx_InPlaceMatrixMultiply = &trace_ctx_InPlaceMatrixMultiply; - tctx->ctx_InPlaceFloorDivide = &trace_ctx_InPlaceFloorDivide; - tctx->ctx_InPlaceTrueDivide = &trace_ctx_InPlaceTrueDivide; - tctx->ctx_InPlaceRemainder = &trace_ctx_InPlaceRemainder; - tctx->ctx_InPlacePower = &trace_ctx_InPlacePower; - tctx->ctx_InPlaceLshift = &trace_ctx_InPlaceLshift; - tctx->ctx_InPlaceRshift = &trace_ctx_InPlaceRshift; - tctx->ctx_InPlaceAnd = &trace_ctx_InPlaceAnd; - tctx->ctx_InPlaceXor = &trace_ctx_InPlaceXor; - tctx->ctx_InPlaceOr = &trace_ctx_InPlaceOr; - tctx->ctx_Callable_Check = &trace_ctx_Callable_Check; - tctx->ctx_CallTupleDict = &trace_ctx_CallTupleDict; - tctx->ctx_Call = &trace_ctx_Call; - tctx->ctx_CallMethod = &trace_ctx_CallMethod; - tctx->ctx_FatalError = uctx->ctx_FatalError; - tctx->ctx_Err_SetString = &trace_ctx_Err_SetString; - tctx->ctx_Err_SetObject = &trace_ctx_Err_SetObject; - tctx->ctx_Err_SetFromErrnoWithFilename = &trace_ctx_Err_SetFromErrnoWithFilename; - tctx->ctx_Err_SetFromErrnoWithFilenameObjects = &trace_ctx_Err_SetFromErrnoWithFilenameObjects; - tctx->ctx_Err_Occurred = &trace_ctx_Err_Occurred; - tctx->ctx_Err_ExceptionMatches = &trace_ctx_Err_ExceptionMatches; - tctx->ctx_Err_NoMemory = &trace_ctx_Err_NoMemory; - tctx->ctx_Err_Clear = &trace_ctx_Err_Clear; - tctx->ctx_Err_NewException = &trace_ctx_Err_NewException; - tctx->ctx_Err_NewExceptionWithDoc = &trace_ctx_Err_NewExceptionWithDoc; - tctx->ctx_Err_WarnEx = &trace_ctx_Err_WarnEx; - tctx->ctx_Err_WriteUnraisable = &trace_ctx_Err_WriteUnraisable; - tctx->ctx_IsTrue = &trace_ctx_IsTrue; - tctx->ctx_Type_FromSpec = &trace_ctx_Type_FromSpec; - tctx->ctx_Type_GenericNew = &trace_ctx_Type_GenericNew; - tctx->ctx_GetAttr = &trace_ctx_GetAttr; - tctx->ctx_GetAttr_s = &trace_ctx_GetAttr_s; - tctx->ctx_HasAttr = &trace_ctx_HasAttr; - tctx->ctx_HasAttr_s = &trace_ctx_HasAttr_s; - tctx->ctx_SetAttr = &trace_ctx_SetAttr; - tctx->ctx_SetAttr_s = &trace_ctx_SetAttr_s; - tctx->ctx_GetItem = &trace_ctx_GetItem; - tctx->ctx_GetItem_i = &trace_ctx_GetItem_i; - tctx->ctx_GetItem_s = &trace_ctx_GetItem_s; - tctx->ctx_Contains = &trace_ctx_Contains; - tctx->ctx_SetItem = &trace_ctx_SetItem; - tctx->ctx_SetItem_i = &trace_ctx_SetItem_i; - tctx->ctx_SetItem_s = &trace_ctx_SetItem_s; - tctx->ctx_DelItem = &trace_ctx_DelItem; - tctx->ctx_DelItem_i = &trace_ctx_DelItem_i; - tctx->ctx_DelItem_s = &trace_ctx_DelItem_s; - tctx->ctx_Type = &trace_ctx_Type; - tctx->ctx_TypeCheck = &trace_ctx_TypeCheck; - tctx->ctx_Type_GetName = &trace_ctx_Type_GetName; - tctx->ctx_Type_IsSubtype = &trace_ctx_Type_IsSubtype; - tctx->ctx_Is = &trace_ctx_Is; - tctx->ctx_AsStruct_Object = &trace_ctx_AsStruct_Object; - tctx->ctx_AsStruct_Legacy = &trace_ctx_AsStruct_Legacy; - tctx->ctx_AsStruct_Type = &trace_ctx_AsStruct_Type; - tctx->ctx_AsStruct_Long = &trace_ctx_AsStruct_Long; - tctx->ctx_AsStruct_Float = &trace_ctx_AsStruct_Float; - tctx->ctx_AsStruct_Unicode = &trace_ctx_AsStruct_Unicode; - tctx->ctx_AsStruct_Tuple = &trace_ctx_AsStruct_Tuple; - tctx->ctx_AsStruct_List = &trace_ctx_AsStruct_List; - tctx->ctx_Type_GetBuiltinShape = &trace_ctx_Type_GetBuiltinShape; - tctx->ctx_New = &trace_ctx_New; - tctx->ctx_Repr = &trace_ctx_Repr; - tctx->ctx_Str = &trace_ctx_Str; - tctx->ctx_ASCII = &trace_ctx_ASCII; - tctx->ctx_Bytes = &trace_ctx_Bytes; - tctx->ctx_RichCompare = &trace_ctx_RichCompare; - tctx->ctx_RichCompareBool = &trace_ctx_RichCompareBool; - tctx->ctx_Hash = &trace_ctx_Hash; - tctx->ctx_Bytes_Check = &trace_ctx_Bytes_Check; - tctx->ctx_Bytes_Size = &trace_ctx_Bytes_Size; - tctx->ctx_Bytes_GET_SIZE = &trace_ctx_Bytes_GET_SIZE; - tctx->ctx_Bytes_AsString = &trace_ctx_Bytes_AsString; - tctx->ctx_Bytes_AS_STRING = &trace_ctx_Bytes_AS_STRING; - tctx->ctx_Bytes_FromString = &trace_ctx_Bytes_FromString; - tctx->ctx_Bytes_FromStringAndSize = &trace_ctx_Bytes_FromStringAndSize; - tctx->ctx_Unicode_FromString = &trace_ctx_Unicode_FromString; - tctx->ctx_Unicode_Check = &trace_ctx_Unicode_Check; - tctx->ctx_Unicode_AsASCIIString = &trace_ctx_Unicode_AsASCIIString; - tctx->ctx_Unicode_AsLatin1String = &trace_ctx_Unicode_AsLatin1String; - tctx->ctx_Unicode_AsUTF8String = &trace_ctx_Unicode_AsUTF8String; - tctx->ctx_Unicode_AsUTF8AndSize = &trace_ctx_Unicode_AsUTF8AndSize; - tctx->ctx_Unicode_FromWideChar = &trace_ctx_Unicode_FromWideChar; - tctx->ctx_Unicode_DecodeFSDefault = &trace_ctx_Unicode_DecodeFSDefault; - tctx->ctx_Unicode_DecodeFSDefaultAndSize = &trace_ctx_Unicode_DecodeFSDefaultAndSize; - tctx->ctx_Unicode_EncodeFSDefault = &trace_ctx_Unicode_EncodeFSDefault; - tctx->ctx_Unicode_ReadChar = &trace_ctx_Unicode_ReadChar; - tctx->ctx_Unicode_DecodeASCII = &trace_ctx_Unicode_DecodeASCII; - tctx->ctx_Unicode_DecodeLatin1 = &trace_ctx_Unicode_DecodeLatin1; - tctx->ctx_Unicode_FromEncodedObject = &trace_ctx_Unicode_FromEncodedObject; - tctx->ctx_Unicode_Substring = &trace_ctx_Unicode_Substring; - tctx->ctx_List_Check = &trace_ctx_List_Check; - tctx->ctx_List_New = &trace_ctx_List_New; - tctx->ctx_List_Append = &trace_ctx_List_Append; - tctx->ctx_Dict_Check = &trace_ctx_Dict_Check; - tctx->ctx_Dict_New = &trace_ctx_Dict_New; - tctx->ctx_Dict_Keys = &trace_ctx_Dict_Keys; - tctx->ctx_Dict_Copy = &trace_ctx_Dict_Copy; - tctx->ctx_Tuple_Check = &trace_ctx_Tuple_Check; - tctx->ctx_Tuple_FromArray = &trace_ctx_Tuple_FromArray; - tctx->ctx_Slice_Unpack = &trace_ctx_Slice_Unpack; - tctx->ctx_Import_ImportModule = &trace_ctx_Import_ImportModule; - tctx->ctx_Capsule_New = &trace_ctx_Capsule_New; - tctx->ctx_Capsule_Get = &trace_ctx_Capsule_Get; - tctx->ctx_Capsule_IsValid = &trace_ctx_Capsule_IsValid; - tctx->ctx_Capsule_Set = &trace_ctx_Capsule_Set; - tctx->ctx_FromPyObject = &trace_ctx_FromPyObject; - tctx->ctx_AsPyObject = &trace_ctx_AsPyObject; - tctx->ctx_CallRealFunctionFromTrampoline = uctx->ctx_CallRealFunctionFromTrampoline; - tctx->ctx_ListBuilder_New = &trace_ctx_ListBuilder_New; - tctx->ctx_ListBuilder_Set = &trace_ctx_ListBuilder_Set; - tctx->ctx_ListBuilder_Build = &trace_ctx_ListBuilder_Build; - tctx->ctx_ListBuilder_Cancel = &trace_ctx_ListBuilder_Cancel; - tctx->ctx_TupleBuilder_New = &trace_ctx_TupleBuilder_New; - tctx->ctx_TupleBuilder_Set = &trace_ctx_TupleBuilder_Set; - tctx->ctx_TupleBuilder_Build = &trace_ctx_TupleBuilder_Build; - tctx->ctx_TupleBuilder_Cancel = &trace_ctx_TupleBuilder_Cancel; - tctx->ctx_Tracker_New = &trace_ctx_Tracker_New; - tctx->ctx_Tracker_Add = &trace_ctx_Tracker_Add; - tctx->ctx_Tracker_ForgetAll = &trace_ctx_Tracker_ForgetAll; - tctx->ctx_Tracker_Close = &trace_ctx_Tracker_Close; - tctx->ctx_Field_Store = &trace_ctx_Field_Store; - tctx->ctx_Field_Load = &trace_ctx_Field_Load; - tctx->ctx_ReenterPythonExecution = &trace_ctx_ReenterPythonExecution; - tctx->ctx_LeavePythonExecution = &trace_ctx_LeavePythonExecution; - tctx->ctx_Global_Store = &trace_ctx_Global_Store; - tctx->ctx_Global_Load = &trace_ctx_Global_Load; - tctx->ctx_Dump = &trace_ctx_Dump; - tctx->ctx_Compile_s = &trace_ctx_Compile_s; - tctx->ctx_EvalCode = &trace_ctx_EvalCode; - tctx->ctx_ContextVar_New = &trace_ctx_ContextVar_New; - tctx->ctx_ContextVar_Get = &trace_ctx_ContextVar_Get; - tctx->ctx_ContextVar_Set = &trace_ctx_ContextVar_Set; - tctx->ctx_SetCallFunction = &trace_ctx_SetCallFunction; -} diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_func_table.c b/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_func_table.c deleted file mode 100644 index edc0987a02..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_func_table.c +++ /dev/null @@ -1,320 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.trace.autogen_trace_func_table_c - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#include "trace_internal.h" - -#define TRACE_NFUNC 180 - -#define NO_FUNC "" -static const char *trace_func_table[] = { - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - "ctx_Dup", - "ctx_Close", - "ctx_Long_FromInt32_t", - "ctx_Long_FromUInt32_t", - "ctx_Long_FromInt64_t", - "ctx_Long_FromUInt64_t", - "ctx_Long_FromSize_t", - "ctx_Long_FromSsize_t", - "ctx_Long_AsInt32_t", - "ctx_Long_AsUInt32_t", - "ctx_Long_AsUInt32_tMask", - "ctx_Long_AsInt64_t", - "ctx_Long_AsUInt64_t", - "ctx_Long_AsUInt64_tMask", - "ctx_Long_AsSize_t", - "ctx_Long_AsSsize_t", - "ctx_Long_AsVoidPtr", - "ctx_Long_AsDouble", - "ctx_Float_FromDouble", - "ctx_Float_AsDouble", - "ctx_Bool_FromBool", - "ctx_Length", - "ctx_Number_Check", - "ctx_Add", - "ctx_Subtract", - "ctx_Multiply", - "ctx_MatrixMultiply", - "ctx_FloorDivide", - "ctx_TrueDivide", - "ctx_Remainder", - "ctx_Divmod", - "ctx_Power", - "ctx_Negative", - "ctx_Positive", - "ctx_Absolute", - "ctx_Invert", - "ctx_Lshift", - "ctx_Rshift", - "ctx_And", - "ctx_Xor", - "ctx_Or", - "ctx_Index", - "ctx_Long", - "ctx_Float", - "ctx_InPlaceAdd", - "ctx_InPlaceSubtract", - "ctx_InPlaceMultiply", - "ctx_InPlaceMatrixMultiply", - "ctx_InPlaceFloorDivide", - "ctx_InPlaceTrueDivide", - "ctx_InPlaceRemainder", - "ctx_InPlacePower", - "ctx_InPlaceLshift", - "ctx_InPlaceRshift", - "ctx_InPlaceAnd", - "ctx_InPlaceXor", - "ctx_InPlaceOr", - "ctx_Callable_Check", - "ctx_CallTupleDict", - "ctx_FatalError", - "ctx_Err_SetString", - "ctx_Err_SetObject", - "ctx_Err_SetFromErrnoWithFilename", - "ctx_Err_SetFromErrnoWithFilenameObjects", - "ctx_Err_Occurred", - "ctx_Err_ExceptionMatches", - "ctx_Err_NoMemory", - "ctx_Err_Clear", - "ctx_Err_NewException", - "ctx_Err_NewExceptionWithDoc", - "ctx_Err_WarnEx", - "ctx_Err_WriteUnraisable", - "ctx_IsTrue", - "ctx_Type_FromSpec", - "ctx_Type_GenericNew", - "ctx_GetAttr", - "ctx_GetAttr_s", - "ctx_HasAttr", - "ctx_HasAttr_s", - "ctx_SetAttr", - "ctx_SetAttr_s", - "ctx_GetItem", - "ctx_GetItem_i", - "ctx_GetItem_s", - "ctx_Contains", - "ctx_SetItem", - "ctx_SetItem_i", - "ctx_SetItem_s", - "ctx_Type", - "ctx_TypeCheck", - "ctx_Is", - "ctx_AsStruct_Object", - "ctx_AsStruct_Legacy", - "ctx_New", - "ctx_Repr", - "ctx_Str", - "ctx_ASCII", - "ctx_Bytes", - "ctx_RichCompare", - "ctx_RichCompareBool", - "ctx_Hash", - "ctx_Bytes_Check", - "ctx_Bytes_Size", - "ctx_Bytes_GET_SIZE", - "ctx_Bytes_AsString", - "ctx_Bytes_AS_STRING", - "ctx_Bytes_FromString", - "ctx_Bytes_FromStringAndSize", - "ctx_Unicode_FromString", - "ctx_Unicode_Check", - "ctx_Unicode_AsASCIIString", - "ctx_Unicode_AsLatin1String", - "ctx_Unicode_AsUTF8String", - "ctx_Unicode_AsUTF8AndSize", - "ctx_Unicode_FromWideChar", - "ctx_Unicode_DecodeFSDefault", - "ctx_Unicode_DecodeFSDefaultAndSize", - "ctx_Unicode_EncodeFSDefault", - "ctx_Unicode_ReadChar", - "ctx_Unicode_DecodeASCII", - "ctx_Unicode_DecodeLatin1", - "ctx_List_Check", - "ctx_List_New", - "ctx_List_Append", - "ctx_Dict_Check", - "ctx_Dict_New", - "ctx_Tuple_Check", - "ctx_Tuple_FromArray", - "ctx_Import_ImportModule", - "ctx_FromPyObject", - "ctx_AsPyObject", - "ctx_CallRealFunctionFromTrampoline", - "ctx_ListBuilder_New", - "ctx_ListBuilder_Set", - "ctx_ListBuilder_Build", - "ctx_ListBuilder_Cancel", - "ctx_TupleBuilder_New", - "ctx_TupleBuilder_Set", - "ctx_TupleBuilder_Build", - "ctx_TupleBuilder_Cancel", - "ctx_Tracker_New", - "ctx_Tracker_Add", - "ctx_Tracker_ForgetAll", - "ctx_Tracker_Close", - "ctx_Field_Store", - "ctx_Field_Load", - "ctx_ReenterPythonExecution", - "ctx_LeavePythonExecution", - "ctx_Global_Store", - "ctx_Global_Load", - "ctx_Dump", - "ctx_AsStruct_Type", - "ctx_AsStruct_Long", - "ctx_AsStruct_Float", - "ctx_AsStruct_Unicode", - "ctx_AsStruct_Tuple", - "ctx_AsStruct_List", - "ctx_Type_GetBuiltinShape", - "ctx_DelItem", - "ctx_DelItem_i", - "ctx_DelItem_s", - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - NO_FUNC, - "ctx_Capsule_New", - "ctx_Capsule_Get", - "ctx_Capsule_IsValid", - "ctx_Capsule_Set", - "ctx_Compile_s", - "ctx_EvalCode", - "ctx_ContextVar_New", - "ctx_ContextVar_Get", - "ctx_ContextVar_Set", - "ctx_Type_GetName", - "ctx_Type_IsSubtype", - "ctx_Unicode_FromEncodedObject", - "ctx_Unicode_Substring", - "ctx_Dict_Keys", - "ctx_Dict_Copy", - "ctx_Slice_Unpack", - "ctx_SetCallFunction", - "ctx_Call", - "ctx_CallMethod", - NULL /* sentinel */ -}; - -int hpy_trace_get_nfunc(void) -{ - return TRACE_NFUNC; -} - -const char * hpy_trace_get_func_name(int idx) -{ - if (idx >= 0 && idx < 263) - return trace_func_table[idx]; - return NULL; -} - diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_wrappers.c b/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_wrappers.c deleted file mode 100644 index 095bb5377d..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/autogen_trace_wrappers.c +++ /dev/null @@ -1,2335 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - - -/* - DO NOT EDIT THIS FILE! - - This file is automatically generated by hpy.tools.autogen.trace.autogen_tracer_wrappers - See also hpy.tools.autogen and hpy/tools/public_api.h - - Run this to regenerate: - make autogen - -*/ - -#include "trace_internal.h" - -HPy trace_ctx_Dup(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 77); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Dup(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 77, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Close(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 78); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_Close(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 78, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Long_FromInt32_t(HPyContext *tctx, int32_t value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 79); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromInt32_t(uctx, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 79, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long_FromUInt32_t(HPyContext *tctx, uint32_t value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 80); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromUInt32_t(uctx, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 80, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long_FromInt64_t(HPyContext *tctx, int64_t v) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 81); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromInt64_t(uctx, v); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 81, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long_FromUInt64_t(HPyContext *tctx, uint64_t v) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 82); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromUInt64_t(uctx, v); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 82, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long_FromSize_t(HPyContext *tctx, size_t value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 83); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromSize_t(uctx, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 83, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long_FromSsize_t(HPyContext *tctx, HPy_ssize_t value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 84); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyLong_FromSsize_t(uctx, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 84, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int32_t trace_ctx_Long_AsInt32_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 85); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int32_t res = HPyLong_AsInt32_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 85, r0, r1, &_ts_start, &_ts_end); - return res; -} - -uint32_t trace_ctx_Long_AsUInt32_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 86); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - uint32_t res = HPyLong_AsUInt32_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 86, r0, r1, &_ts_start, &_ts_end); - return res; -} - -uint32_t trace_ctx_Long_AsUInt32_tMask(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 87); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - uint32_t res = HPyLong_AsUInt32_tMask(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 87, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int64_t trace_ctx_Long_AsInt64_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 88); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int64_t res = HPyLong_AsInt64_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 88, r0, r1, &_ts_start, &_ts_end); - return res; -} - -uint64_t trace_ctx_Long_AsUInt64_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 89); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - uint64_t res = HPyLong_AsUInt64_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 89, r0, r1, &_ts_start, &_ts_end); - return res; -} - -uint64_t trace_ctx_Long_AsUInt64_tMask(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 90); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - uint64_t res = HPyLong_AsUInt64_tMask(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 90, r0, r1, &_ts_start, &_ts_end); - return res; -} - -size_t trace_ctx_Long_AsSize_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 91); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - size_t res = HPyLong_AsSize_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 91, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_ssize_t trace_ctx_Long_AsSsize_t(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 92); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_ssize_t res = HPyLong_AsSsize_t(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 92, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_Long_AsVoidPtr(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 93); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = HPyLong_AsVoidPtr(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 93, r0, r1, &_ts_start, &_ts_end); - return res; -} - -double trace_ctx_Long_AsDouble(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 94); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - double res = HPyLong_AsDouble(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 94, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Float_FromDouble(HPyContext *tctx, double v) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 95); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyFloat_FromDouble(uctx, v); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 95, r0, r1, &_ts_start, &_ts_end); - return res; -} - -double trace_ctx_Float_AsDouble(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 96); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - double res = HPyFloat_AsDouble(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 96, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Bool_FromBool(HPyContext *tctx, bool v) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 97); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyBool_FromBool(uctx, v); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 97, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_ssize_t trace_ctx_Length(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 98); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_ssize_t res = HPy_Length(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 98, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Number_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 99); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyNumber_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 99, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Add(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 100); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Add(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 100, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Subtract(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 101); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Subtract(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 101, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Multiply(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 102); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Multiply(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 102, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_MatrixMultiply(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 103); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_MatrixMultiply(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 103, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_FloorDivide(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 104); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_FloorDivide(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 104, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_TrueDivide(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 105); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_TrueDivide(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 105, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Remainder(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 106); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Remainder(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 106, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Divmod(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 107); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Divmod(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 107, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Power(HPyContext *tctx, HPy h1, HPy h2, HPy h3) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 108); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Power(uctx, h1, h2, h3); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 108, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Negative(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 109); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Negative(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 109, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Positive(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 110); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Positive(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 110, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Absolute(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 111); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Absolute(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 111, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Invert(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 112); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Invert(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 112, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Lshift(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 113); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Lshift(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 113, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Rshift(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 114); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Rshift(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 114, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_And(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 115); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_And(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 115, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Xor(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 116); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Xor(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 116, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Or(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 117); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Or(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 117, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Index(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 118); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Index(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 118, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Long(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 119); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Long(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 119, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Float(HPyContext *tctx, HPy h1) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 120); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Float(uctx, h1); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 120, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceAdd(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 121); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceAdd(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 121, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceSubtract(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 122); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceSubtract(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 122, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceMultiply(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 123); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceMultiply(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 123, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceMatrixMultiply(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 124); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceMatrixMultiply(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 124, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceFloorDivide(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 125); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceFloorDivide(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 125, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceTrueDivide(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 126); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceTrueDivide(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 126, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceRemainder(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 127); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceRemainder(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 127, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlacePower(HPyContext *tctx, HPy h1, HPy h2, HPy h3) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 128); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlacePower(uctx, h1, h2, h3); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 128, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceLshift(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 129); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceLshift(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 129, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceRshift(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 130); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceRshift(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 130, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceAnd(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 131); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceAnd(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 131, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceXor(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 132); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceXor(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 132, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_InPlaceOr(HPyContext *tctx, HPy h1, HPy h2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 133); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_InPlaceOr(uctx, h1, h2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 133, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Callable_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 134); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyCallable_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 134, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_CallTupleDict(HPyContext *tctx, HPy callable, HPy args, HPy kw) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 135); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_CallTupleDict(uctx, callable, args, kw); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 135, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Call(HPyContext *tctx, HPy callable, const HPy *args, size_t nargs, HPy kwnames) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 261); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Call(uctx, callable, args, nargs, kwnames); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 261, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_CallMethod(HPyContext *tctx, HPy name, const HPy *args, size_t nargs, HPy kwnames) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 262); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_CallMethod(uctx, name, args, nargs, kwnames); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 262, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Err_SetString(HPyContext *tctx, HPy h_type, const char *utf8_message) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 137); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_SetString(uctx, h_type, utf8_message); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 137, r0, r1, &_ts_start, &_ts_end); -} - -void trace_ctx_Err_SetObject(HPyContext *tctx, HPy h_type, HPy h_value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 138); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_SetObject(uctx, h_type, h_value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 138, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Err_SetFromErrnoWithFilename(HPyContext *tctx, HPy h_type, const char *filename_fsencoded) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 139); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyErr_SetFromErrnoWithFilename(uctx, h_type, filename_fsencoded); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 139, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Err_SetFromErrnoWithFilenameObjects(HPyContext *tctx, HPy h_type, HPy filename1, HPy filename2) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 140); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_SetFromErrnoWithFilenameObjects(uctx, h_type, filename1, filename2); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 140, r0, r1, &_ts_start, &_ts_end); -} - -int trace_ctx_Err_Occurred(HPyContext *tctx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 141); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyErr_Occurred(uctx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 141, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Err_ExceptionMatches(HPyContext *tctx, HPy exc) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 142); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyErr_ExceptionMatches(uctx, exc); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 142, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Err_NoMemory(HPyContext *tctx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 143); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_NoMemory(uctx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 143, r0, r1, &_ts_start, &_ts_end); -} - -void trace_ctx_Err_Clear(HPyContext *tctx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 144); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_Clear(uctx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 144, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Err_NewException(HPyContext *tctx, const char *utf8_name, HPy base, HPy dict) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 145); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyErr_NewException(uctx, utf8_name, base, dict); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 145, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Err_NewExceptionWithDoc(HPyContext *tctx, const char *utf8_name, const char *utf8_doc, HPy base, HPy dict) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 146); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyErr_NewExceptionWithDoc(uctx, utf8_name, utf8_doc, base, dict); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 146, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Err_WarnEx(HPyContext *tctx, HPy category, const char *utf8_message, HPy_ssize_t stack_level) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 147); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyErr_WarnEx(uctx, category, utf8_message, stack_level); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 147, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Err_WriteUnraisable(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 148); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyErr_WriteUnraisable(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 148, r0, r1, &_ts_start, &_ts_end); -} - -int trace_ctx_IsTrue(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 149); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_IsTrue(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 149, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Type_FromSpec(HPyContext *tctx, HPyType_Spec *spec, HPyType_SpecParam *params) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 150); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyType_FromSpec(uctx, spec, params); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 150, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Type_GenericNew(HPyContext *tctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 151); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyType_GenericNew(uctx, type, args, nargs, kw); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 151, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_GetAttr(HPyContext *tctx, HPy obj, HPy name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 152); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_GetAttr(uctx, obj, name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 152, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_GetAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 153); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_GetAttr_s(uctx, obj, utf8_name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 153, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_HasAttr(HPyContext *tctx, HPy obj, HPy name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 154); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_HasAttr(uctx, obj, name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 154, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_HasAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 155); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_HasAttr_s(uctx, obj, utf8_name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 155, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetAttr(HPyContext *tctx, HPy obj, HPy name, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 156); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetAttr(uctx, obj, name, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 156, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetAttr_s(HPyContext *tctx, HPy obj, const char *utf8_name, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 157); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetAttr_s(uctx, obj, utf8_name, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 157, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_GetItem(HPyContext *tctx, HPy obj, HPy key) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 158); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_GetItem(uctx, obj, key); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 158, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_GetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 159); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_GetItem_i(uctx, obj, idx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 159, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_GetItem_s(HPyContext *tctx, HPy obj, const char *utf8_key) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 160); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_GetItem_s(uctx, obj, utf8_key); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 160, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Contains(HPyContext *tctx, HPy container, HPy key) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 161); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_Contains(uctx, container, key); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 161, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetItem(HPyContext *tctx, HPy obj, HPy key, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 162); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetItem(uctx, obj, key, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 162, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 163); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetItem_i(uctx, obj, idx, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 163, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetItem_s(HPyContext *tctx, HPy obj, const char *utf8_key, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 164); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetItem_s(uctx, obj, utf8_key, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 164, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_DelItem(HPyContext *tctx, HPy obj, HPy key) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 235); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_DelItem(uctx, obj, key); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 235, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_DelItem_i(HPyContext *tctx, HPy obj, HPy_ssize_t idx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 236); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_DelItem_i(uctx, obj, idx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 236, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_DelItem_s(HPyContext *tctx, HPy obj, const char *utf8_key) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 237); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_DelItem_s(uctx, obj, utf8_key); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 237, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Type(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 165); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Type(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 165, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_TypeCheck(HPyContext *tctx, HPy obj, HPy type) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 166); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_TypeCheck(uctx, obj, type); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 166, r0, r1, &_ts_start, &_ts_end); - return res; -} - -const char *trace_ctx_Type_GetName(HPyContext *tctx, HPy type) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 253); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - const char * res = HPyType_GetName(uctx, type); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 253, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Type_IsSubtype(HPyContext *tctx, HPy sub, HPy type) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 254); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyType_IsSubtype(uctx, sub, type); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 254, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Is(HPyContext *tctx, HPy obj, HPy other) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 167); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_Is(uctx, obj, other); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 167, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Object(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 168); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Object(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 168, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Legacy(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 169); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Legacy(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 169, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Type(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 228); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Type(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 228, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Long(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 229); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Long(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 229, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Float(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 230); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Float(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 230, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Unicode(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 231); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Unicode(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 231, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_Tuple(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 232); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_Tuple(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 232, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_AsStruct_List(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 233); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = _HPy_AsStruct_List(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 233, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPyType_BuiltinShape trace_ctx_Type_GetBuiltinShape(HPyContext *tctx, HPy h_type) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 234); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyType_BuiltinShape res = _HPyType_GetBuiltinShape(uctx, h_type); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 234, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_New(HPyContext *tctx, HPy h_type, void **data) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 170); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = _HPy_New(uctx, h_type, data); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 170, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Repr(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 171); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Repr(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 171, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Str(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 172); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Str(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 172, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_ASCII(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 173); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_ASCII(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 173, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Bytes(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 174); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Bytes(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 174, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_RichCompare(HPyContext *tctx, HPy v, HPy w, int op) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 175); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_RichCompare(uctx, v, w, op); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 175, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_RichCompareBool(HPyContext *tctx, HPy v, HPy w, int op) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 176); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_RichCompareBool(uctx, v, w, op); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 176, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_hash_t trace_ctx_Hash(HPyContext *tctx, HPy obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 177); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_hash_t res = HPy_Hash(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 177, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Bytes_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 178); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyBytes_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 178, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_ssize_t trace_ctx_Bytes_Size(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 179); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_ssize_t res = HPyBytes_Size(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 179, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_ssize_t trace_ctx_Bytes_GET_SIZE(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 180); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_ssize_t res = HPyBytes_GET_SIZE(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 180, r0, r1, &_ts_start, &_ts_end); - return res; -} - -const char *trace_ctx_Bytes_AsString(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 181); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - const char * res = HPyBytes_AsString(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 181, r0, r1, &_ts_start, &_ts_end); - return res; -} - -const char *trace_ctx_Bytes_AS_STRING(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 182); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - const char * res = HPyBytes_AS_STRING(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 182, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Bytes_FromString(HPyContext *tctx, const char *bytes) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 183); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyBytes_FromString(uctx, bytes); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 183, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Bytes_FromStringAndSize(HPyContext *tctx, const char *bytes, HPy_ssize_t len) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 184); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyBytes_FromStringAndSize(uctx, bytes, len); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 184, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_FromString(HPyContext *tctx, const char *utf8) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 185); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_FromString(uctx, utf8); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 185, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Unicode_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 186); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyUnicode_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 186, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_AsASCIIString(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 187); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_AsASCIIString(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 187, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_AsLatin1String(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 188); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_AsLatin1String(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 188, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_AsUTF8String(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 189); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_AsUTF8String(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 189, r0, r1, &_ts_start, &_ts_end); - return res; -} - -const char *trace_ctx_Unicode_AsUTF8AndSize(HPyContext *tctx, HPy h, HPy_ssize_t *size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 190); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - const char * res = HPyUnicode_AsUTF8AndSize(uctx, h, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 190, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_FromWideChar(HPyContext *tctx, const wchar_t *w, HPy_ssize_t size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 191); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_FromWideChar(uctx, w, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 191, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_DecodeFSDefault(HPyContext *tctx, const char *v) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 192); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_DecodeFSDefault(uctx, v); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 192, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_DecodeFSDefaultAndSize(HPyContext *tctx, const char *v, HPy_ssize_t size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 193); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_DecodeFSDefaultAndSize(uctx, v, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 193, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_EncodeFSDefault(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 194); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_EncodeFSDefault(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 194, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy_UCS4 trace_ctx_Unicode_ReadChar(HPyContext *tctx, HPy h, HPy_ssize_t index) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 195); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_UCS4 res = HPyUnicode_ReadChar(uctx, h, index); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 195, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_DecodeASCII(HPyContext *tctx, const char *ascii, HPy_ssize_t size, const char *errors) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 196); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_DecodeASCII(uctx, ascii, size, errors); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 196, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_DecodeLatin1(HPyContext *tctx, const char *latin1, HPy_ssize_t size, const char *errors) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 197); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_DecodeLatin1(uctx, latin1, size, errors); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 197, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_FromEncodedObject(HPyContext *tctx, HPy obj, const char *encoding, const char *errors) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 255); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_FromEncodedObject(uctx, obj, encoding, errors); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 255, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Unicode_Substring(HPyContext *tctx, HPy str, HPy_ssize_t start, HPy_ssize_t end) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 256); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyUnicode_Substring(uctx, str, start, end); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 256, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_List_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 198); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyList_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 198, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_List_New(HPyContext *tctx, HPy_ssize_t len) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 199); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyList_New(uctx, len); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 199, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_List_Append(HPyContext *tctx, HPy h_list, HPy h_item) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 200); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyList_Append(uctx, h_list, h_item); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 200, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Dict_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 201); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyDict_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 201, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Dict_New(HPyContext *tctx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 202); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyDict_New(uctx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 202, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Dict_Keys(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 257); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyDict_Keys(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 257, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Dict_Copy(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 258); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyDict_Copy(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 258, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Tuple_Check(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 203); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyTuple_Check(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 203, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Tuple_FromArray(HPyContext *tctx, HPy items[], HPy_ssize_t n) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 204); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyTuple_FromArray(uctx, items, n); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 204, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Slice_Unpack(HPyContext *tctx, HPy slice, HPy_ssize_t *start, HPy_ssize_t *stop, HPy_ssize_t *step) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 259); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPySlice_Unpack(uctx, slice, start, stop, step); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 259, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Import_ImportModule(HPyContext *tctx, const char *utf8_name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 205); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyImport_ImportModule(uctx, utf8_name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 205, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_Capsule_New(HPyContext *tctx, void *pointer, const char *utf8_name, HPyCapsule_Destructor *destructor) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 244); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyCapsule_New(uctx, pointer, utf8_name, destructor); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 244, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void *trace_ctx_Capsule_Get(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, const char *utf8_name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 245); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - void * res = HPyCapsule_Get(uctx, capsule, key, utf8_name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 245, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Capsule_IsValid(HPyContext *tctx, HPy capsule, const char *utf8_name) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 246); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyCapsule_IsValid(uctx, capsule, utf8_name); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 246, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Capsule_Set(HPyContext *tctx, HPy capsule, _HPyCapsule_key key, void *value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 247); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyCapsule_Set(uctx, capsule, key, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 247, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_FromPyObject(HPyContext *tctx, cpy_PyObject *obj) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 206); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_FromPyObject(uctx, obj); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 206, r0, r1, &_ts_start, &_ts_end); - return res; -} - -cpy_PyObject *trace_ctx_AsPyObject(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 207); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - cpy_PyObject * res = HPy_AsPyObject(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 207, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPyListBuilder trace_ctx_ListBuilder_New(HPyContext *tctx, HPy_ssize_t size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 209); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyListBuilder res = HPyListBuilder_New(uctx, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 209, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_ListBuilder_Set(HPyContext *tctx, HPyListBuilder builder, HPy_ssize_t index, HPy h_item) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 210); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyListBuilder_Set(uctx, builder, index, h_item); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 210, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_ListBuilder_Build(HPyContext *tctx, HPyListBuilder builder) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 211); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyListBuilder_Build(uctx, builder); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 211, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_ListBuilder_Cancel(HPyContext *tctx, HPyListBuilder builder) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 212); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyListBuilder_Cancel(uctx, builder); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 212, r0, r1, &_ts_start, &_ts_end); -} - -HPyTupleBuilder trace_ctx_TupleBuilder_New(HPyContext *tctx, HPy_ssize_t size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 213); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTupleBuilder res = HPyTupleBuilder_New(uctx, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 213, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_TupleBuilder_Set(HPyContext *tctx, HPyTupleBuilder builder, HPy_ssize_t index, HPy h_item) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 214); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTupleBuilder_Set(uctx, builder, index, h_item); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 214, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_TupleBuilder_Build(HPyContext *tctx, HPyTupleBuilder builder) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 215); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyTupleBuilder_Build(uctx, builder); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 215, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_TupleBuilder_Cancel(HPyContext *tctx, HPyTupleBuilder builder) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 216); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTupleBuilder_Cancel(uctx, builder); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 216, r0, r1, &_ts_start, &_ts_end); -} - -HPyTracker trace_ctx_Tracker_New(HPyContext *tctx, HPy_ssize_t size) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 217); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTracker res = HPyTracker_New(uctx, size); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 217, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_Tracker_Add(HPyContext *tctx, HPyTracker ht, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 218); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPyTracker_Add(uctx, ht, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 218, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Tracker_ForgetAll(HPyContext *tctx, HPyTracker ht) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 219); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTracker_ForgetAll(uctx, ht); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 219, r0, r1, &_ts_start, &_ts_end); -} - -void trace_ctx_Tracker_Close(HPyContext *tctx, HPyTracker ht) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 220); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyTracker_Close(uctx, ht); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 220, r0, r1, &_ts_start, &_ts_end); -} - -void trace_ctx_Field_Store(HPyContext *tctx, HPy target_object, HPyField *target_field, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 221); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyField_Store(uctx, target_object, target_field, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 221, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Field_Load(HPyContext *tctx, HPy source_object, HPyField source_field) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 222); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyField_Load(uctx, source_object, source_field); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 222, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_ReenterPythonExecution(HPyContext *tctx, HPyThreadState state) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 223); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy_ReenterPythonExecution(uctx, state); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 223, r0, r1, &_ts_start, &_ts_end); -} - -HPyThreadState trace_ctx_LeavePythonExecution(HPyContext *tctx) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 224); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyThreadState res = HPy_LeavePythonExecution(uctx); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 224, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Global_Store(HPyContext *tctx, HPyGlobal *global, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 225); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPyGlobal_Store(uctx, global, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 225, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Global_Load(HPyContext *tctx, HPyGlobal global) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 226); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyGlobal_Load(uctx, global); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 226, r0, r1, &_ts_start, &_ts_end); - return res; -} - -void trace_ctx_Dump(HPyContext *tctx, HPy h) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 227); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - _HPy_Dump(uctx, h); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 227, r0, r1, &_ts_start, &_ts_end); -} - -HPy trace_ctx_Compile_s(HPyContext *tctx, const char *utf8_source, const char *utf8_filename, HPy_SourceKind kind) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 248); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_Compile_s(uctx, utf8_source, utf8_filename, kind); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 248, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_EvalCode(HPyContext *tctx, HPy code, HPy globals, HPy locals) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 249); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPy_EvalCode(uctx, code, globals, locals); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 249, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_ContextVar_New(HPyContext *tctx, const char *name, HPy default_value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 250); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyContextVar_New(uctx, name, default_value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 250, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int32_t trace_ctx_ContextVar_Get(HPyContext *tctx, HPy context_var, HPy default_value, HPy *result) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 251); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int32_t res = HPyContextVar_Get(uctx, context_var, default_value, result); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 251, r0, r1, &_ts_start, &_ts_end); - return res; -} - -HPy trace_ctx_ContextVar_Set(HPyContext *tctx, HPy context_var, HPy value) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 252); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - HPy res = HPyContextVar_Set(uctx, context_var, value); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 252, r0, r1, &_ts_start, &_ts_end); - return res; -} - -int trace_ctx_SetCallFunction(HPyContext *tctx, HPy h, HPyCallFunction *func) -{ - HPyTraceInfo *info = hpy_trace_on_enter(tctx, 260); - HPyContext *uctx = info->uctx; - _HPyTime_t _ts_start, _ts_end; - _HPyClockStatus_t r0, r1; - r0 = get_monotonic_clock(&_ts_start); - int res = HPy_SetCallFunction(uctx, h, func); - r1 = get_monotonic_clock(&_ts_end); - hpy_trace_on_exit(info, 260, r0, r1, &_ts_start, &_ts_end); - return res; -} - diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/hpy_trace.h b/graalpython/com.oracle.graal.python.jni/src/trace/hpy_trace.h deleted file mode 100644 index 70d6320239..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/hpy_trace.h +++ /dev/null @@ -1,66 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_TRACE_H -#define HPY_TRACE_H - -#include "hpy.h" - -/* - This is the main public API for the trace mode, and it's meant to be used - by hpy.universal implementations (including but not limited to the - CPython's version of hpy.universal which is included in this repo). - - The idea is that for every uctx there is a corresponding unique tctx which - wraps it. - - If you call hpy_trace_get_ctx twice on the same uctx, you get the same - result. -*/ - -HPyContext * hpy_trace_get_ctx(HPyContext *uctx); -int hpy_trace_ctx_init(HPyContext *tctx, HPyContext *uctx); -int hpy_trace_ctx_free(HPyContext *tctx); -int hpy_trace_get_nfunc(void); -const char * hpy_trace_get_func_name(int idx); - -// this is the HPy init function created by HPy_MODINIT. In CPython's version -// of hpy.universal the code is embedded inside the extension, so we can call -// this function directly instead of dlopen it. This is similar to what -// CPython does for its own built-in modules. But we must use the same -// signature as HPy_MODINIT - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -HPyModuleDef* HPyInit__trace(); - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -void HPyInitGlobalContext__trace(HPyContext *ctx); - -#endif /* HPY_TRACE_H */ diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/include/hpy_trace.h b/graalpython/com.oracle.graal.python.jni/src/trace/include/hpy_trace.h deleted file mode 100644 index 70d6320239..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/include/hpy_trace.h +++ /dev/null @@ -1,66 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#ifndef HPY_TRACE_H -#define HPY_TRACE_H - -#include "hpy.h" - -/* - This is the main public API for the trace mode, and it's meant to be used - by hpy.universal implementations (including but not limited to the - CPython's version of hpy.universal which is included in this repo). - - The idea is that for every uctx there is a corresponding unique tctx which - wraps it. - - If you call hpy_trace_get_ctx twice on the same uctx, you get the same - result. -*/ - -HPyContext * hpy_trace_get_ctx(HPyContext *uctx); -int hpy_trace_ctx_init(HPyContext *tctx, HPyContext *uctx); -int hpy_trace_ctx_free(HPyContext *tctx); -int hpy_trace_get_nfunc(void); -const char * hpy_trace_get_func_name(int idx); - -// this is the HPy init function created by HPy_MODINIT. In CPython's version -// of hpy.universal the code is embedded inside the extension, so we can call -// this function directly instead of dlopen it. This is similar to what -// CPython does for its own built-in modules. But we must use the same -// signature as HPy_MODINIT - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -HPyModuleDef* HPyInit__trace(); - -#ifdef ___cplusplus -extern "C" -#endif -HPy_EXPORTED_SYMBOL -void HPyInitGlobalContext__trace(HPyContext *ctx); - -#endif /* HPY_TRACE_H */ diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/trace_ctx.c b/graalpython/com.oracle.graal.python.jni/src/trace/trace_ctx.c deleted file mode 100644 index 1e8a68a519..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/trace_ctx.c +++ /dev/null @@ -1,148 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -#include "trace_internal.h" -#include "autogen_trace_ctx_init.h" - -// NOTE: at the moment this function assumes that uctx is always the -// same. If/when we migrate to a system in which we can have multiple -// independent contexts, this function should ensure to create a different -// debug wrapper for each of them. -int hpy_trace_ctx_init(HPyContext *tctx, HPyContext *uctx) -{ - if (tctx->_private != NULL) { - // already initialized - assert(get_info(tctx)->uctx == uctx); // sanity check - return 0; - } - // initialize trace_info - // XXX: currently we never free this malloc - HPyTraceInfo *info = malloc(sizeof(HPyTraceInfo)); - if (info == NULL) { - HPyErr_NoMemory(uctx); - return -1; - } -#ifdef _WIN32 - (void)QueryPerformanceFrequency(&info->counter_freq); -#else - clock_getres(CLOCK_MONOTONIC_RAW, &info->counter_freq); -#endif - trace_ctx_init_info(info, uctx); - tctx->_private = info; - trace_ctx_init_fields(tctx, uctx); - return 0; -} - -int hpy_trace_ctx_free(HPyContext *tctx) -{ - trace_ctx_free_info(get_info(tctx)); - return 0; -} - -static HPy create_trace_func_args(HPyContext *uctx, int id) -{ - HPy h_name = HPyUnicode_FromString(uctx, hpy_trace_get_func_name(id)); - if (HPy_IsNull(h_name)) - goto fail; - HPy h_args = HPyTuple_FromArray(uctx, &h_name, 1); - if (HPy_IsNull(h_args)) - goto fail; - HPy_Close(uctx, h_name); - return h_args; -fail: - HPy_FatalError(uctx, "could not create arguments for user trace function"); - return HPy_NULL; -} - -static inline void -update_duration(_HPyTime_t *res, _HPyTime_t *start, _HPyTime_t *end) -{ -#ifdef _WIN32 - res->QuadPart += end->QuadPart - start->QuadPart; - assert(res->QuadPart >= 0); -#else - /* Normalize: since the clock is guaranteed to be monotonic, we know that - 'end >= start'. It can still happen that 'end->tv_nsec < start->tv_nsec' - but in this case, we know that 'end->tv_sec > start->tv_sec'. */ - if (end->tv_nsec < start->tv_nsec) { - assert(end->tv_sec > start->tv_sec); - res->tv_sec += end->tv_sec - start->tv_sec - 1, - res->tv_nsec += end->tv_nsec - start->tv_nsec + FREQ_NSEC; - } else { - res->tv_sec += end->tv_sec - start->tv_sec, - res->tv_nsec += end->tv_nsec - start->tv_nsec; - } - assert(res->tv_sec >= 0); - assert(res->tv_nsec >= 0); -#endif -} - -HPyTraceInfo *hpy_trace_on_enter(HPyContext *tctx, int id) -{ - HPyTraceInfo *tctx_info = get_info(tctx); - HPyContext *uctx = tctx_info->uctx; - HPy args, res; - tctx_info->call_counts[id]++; - if(!HPy_IsNull(tctx_info->on_enter_func)) { - args = create_trace_func_args(uctx, id); - res = HPy_CallTupleDict( - uctx, tctx_info->on_enter_func, args, HPy_NULL); - HPy_Close(uctx, args); - if (HPy_IsNull(res)) { - HPy_FatalError(uctx, - "error when executing on-enter trace function"); - } - } - return tctx_info; -} - -#ifdef _WIN32 -#define CLOCK_FAILED(_R0, _R1) (!(_R0) || !(_R1)) -#else -#define CLOCK_FAILED(_R0, _R1) ((_R0) + (_R1)) -#endif - -void hpy_trace_on_exit(HPyTraceInfo *info, int id, _HPyClockStatus_t r0, - _HPyClockStatus_t r1, _HPyTime_t *_ts_start, _HPyTime_t *_ts_end) -{ - HPyContext *uctx = info->uctx; - HPy args, res; - if (CLOCK_FAILED(r0, r1)) - { - printf("Could not get monotonic clock in %s\n", hpy_trace_get_func_name(id)); - fflush(stdout); - HPy_FatalError(uctx, "could not get monotonic clock123"); - } - update_duration(&info->durations[id], _ts_start, _ts_end); - if(!HPy_IsNull(info->on_exit_func)) { - args = create_trace_func_args(uctx, id); - res = HPy_CallTupleDict(uctx, info->on_exit_func, args, HPy_NULL); - HPy_Close(uctx, args); - if (HPy_IsNull(res)) { - HPy_FatalError(uctx, - "error when executing on-exit trace function"); - } - } -} - diff --git a/graalpython/com.oracle.graal.python.jni/src/trace/trace_internal.h b/graalpython/com.oracle.graal.python.jni/src/trace/trace_internal.h deleted file mode 100644 index 30c3da6d85..0000000000 --- a/graalpython/com.oracle.graal.python.jni/src/trace/trace_internal.h +++ /dev/null @@ -1,96 +0,0 @@ -/* MIT License - * - * Copyright (c) 2023, 2023, Oracle and/or its affiliates. - * Copyright (c) 2019 pyhandle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall 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. - */ - -/* Internal header for all the files in hpy/debug/src. The public API is in - include/hpy_debug.h -*/ -#ifndef HPY_TRACE_INTERNAL_H -#define HPY_TRACE_INTERNAL_H - -#include -#ifdef _WIN32 -#include -#else -#include -#endif -#include "hpy.h" -#include "hpy_trace.h" - - -#define HPY_TRACE_MAGIC 0xF00BAA5 - -// frequency of nanosecond resolution -#define FREQ_NSEC 1000000000L - -/* === HPyTraceInfo === */ - -#ifdef _WIN32 -typedef LARGE_INTEGER _HPyTime_t; -typedef BOOL _HPyClockStatus_t; -#else -typedef struct timespec _HPyTime_t; -typedef int _HPyClockStatus_t; -#endif - -typedef struct { - long magic_number; // used just for sanity checks - HPyContext *uctx; - /* frequency of the used performance counter */ - _HPyTime_t counter_freq; -#ifdef _WIN32 - /* to_ns = FREQ_NS / counter_freq */ - int64_t to_ns; -#endif - /* call count of the corresponding HPy API function */ - uint64_t *call_counts; - /* durations spent in the corresponding HPy API function */ - _HPyTime_t *durations; - HPy on_enter_func; - HPy on_exit_func; -} HPyTraceInfo; - - -static inline HPyTraceInfo *get_info(HPyContext *tctx) -{ - HPyTraceInfo *info = (HPyTraceInfo*)tctx->_private; - assert(info->magic_number == HPY_TRACE_MAGIC); // sanity check - return info; -} - -/* Get the current value of the monotonic clock. This is a platform-dependent - operation. */ -static inline _HPyClockStatus_t get_monotonic_clock(_HPyTime_t *t) -{ -#ifdef _WIN32 - return (int)QueryPerformanceCounter(t); -#else - return clock_gettime(CLOCK_MONOTONIC_RAW, t); -#endif -} - -HPyTraceInfo *hpy_trace_on_enter(HPyContext *tctx, int id); -void hpy_trace_on_exit(HPyTraceInfo *info, int id, _HPyClockStatus_t r0, - _HPyClockStatus_t r1, _HPyTime_t *_ts_start, _HPyTime_t *_ts_end); - -#endif /* HPY_TRACE_INTERNAL_H */ diff --git a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java index 29045f263d..53216be0f4 100644 --- a/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java +++ b/graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonMain.java @@ -750,15 +750,6 @@ protected void launch(Builder contextBuilder) { } } - if (isLLVMToolchainLauncher()) { - if (!hasContextOptionSetViaCommandLine("UseSystemToolchain")) { - contextBuilder.option("python.UseSystemToolchain", "false"); - } - if (!hasContextOptionSetViaCommandLine("NativeModules")) { - contextBuilder.option("python.NativeModules", "false"); - } - } - if (relaunchArgs != null) { Iterator it = origArgs.iterator(); while (it.hasNext()) { @@ -1068,9 +1059,6 @@ protected String getLanguageId() { @Override protected void printHelp(OptionCategory maxCategory) { - if (isLLVMToolchainLauncher()) { - System.out.println("GraalPy launcher to use LLVM toolchain and Sulong execution of native extensions.\n"); - } System.out.println("usage: python [option] ... (-c cmd | file) [arg] ...\n" + "Options and arguments (and corresponding environment variables):\n" + "-B : this disables writing .py[co] files on import\n" + @@ -1136,14 +1124,7 @@ protected void printHelp(OptionCategory maxCategory) { " All following arguments are passed to the compiler.\n" + "-LD : run the linker used for generating GraalPython C extensions.\n" + " All following arguments are passed to the linker.\n" + - "\nEnvironment variables specific to the Graal Python launcher:\n" + - "SULONG_LIBRARY_PATH: Specifies the library path for Sulong.\n" + - " This is required when starting subprocesses of python.\n" : "")); - } - - private boolean isLLVMToolchainLauncher() { - String exeName = getResolvedExecutableName(); - return exeName != null && exeName.endsWith("-lt"); + "\nEnvironment variables specific to the Graal Python launcher:\n" : "")); } @Override diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/MultiContextTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/MultiContextTest.java index f9e6c2f1e9..83b09a06c0 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/MultiContextTest.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/MultiContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -57,19 +57,6 @@ public void testSharingWithMemoryview() { } } - @Test - public void testSharingWithCpythonSreAndLLVM() { - // This test is going to use the Sulong backend.This is why we need "sulong:SULONG_NATIVE" - // among the dependencies for GRAALPYTHON_UNIT_TESTS distribution, and - // org.graalvm.polyglot:llvm-community dependency in the pom.xml - Engine engine = Engine.newBuilder().build(); - for (int i = 0; i < 10; i++) { - try (Context context = newContextWithNativeModulesFalse(engine)) { - context.eval("python", "import _cpython_sre\nassert _cpython_sre.ascii_tolower(88) == 120\n"); - } - } - } - @Test public void testTryCatch() { Engine engine = Engine.newBuilder().build(); @@ -90,8 +77,4 @@ public void testTryCatch() { private static Context newContext(Engine engine) { return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).engine(engine).build(); } - - private static Context newContextWithNativeModulesFalse(Engine engine) { - return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).engine(engine).option("python.NativeModules", "false").build(); - } } diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java index 0d8d90e643..3bcb66c7b3 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/NativeExtTest.java @@ -57,16 +57,17 @@ public class NativeExtTest { public void testSharingErrorWithCpythonSre() throws InterruptedException { // The first context is the one that will use native extensions Engine engine = Engine.newBuilder().build(); - Context cextContext = newContext(engine); + Context cextContext = newContext(engine).option("python.IsolateNativeModules", "true").build(); try { cextContext.eval("python", "import _cpython_sre\nassert _cpython_sre.ascii_tolower(88) == 120\n"); - // Check that second context that tries to load native extension fails - try (Context secondCtx = newContext(engine)) { + // Check that second context that tries to load native extension fails without + // IsolateNativeModules + try (Context secondCtx = newContext(engine).build()) { try { secondCtx.eval("python", "import _cpython_sre\nassert _cpython_sre.ascii_tolower(88) == 120\n"); } catch (PolyglotException ex) { - Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("Option python.NativeModules is set to 'true' and a second GraalPy context attempted")); + Assert.assertTrue(ex.getMessage(), ex.getMessage().contains("Option python.IsolateNativeModules is set to 'false' and a second GraalPy context attempted")); } } @@ -99,7 +100,7 @@ public void testSharingErrorWithCpythonSre() throws InterruptedException { } } - private static Context newContext(Engine engine) { - return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).engine(engine).build(); + private static Context.Builder newContext(Engine engine) { + return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).engine(engine); } } diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ShutdownTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ShutdownTest.java index 453d802402..9ea6b40e2b 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ShutdownTest.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/advanced/ShutdownTest.java @@ -40,6 +40,10 @@ */ package com.oracle.graal.python.test.integration.advanced; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + import org.graalvm.polyglot.Context; import org.graalvm.polyglot.PolyglotException; import org.junit.Assert; @@ -47,10 +51,6 @@ import com.oracle.graal.python.test.integration.PythonTests; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - // See also NativeExtTest public class ShutdownTest extends PythonTests { @Test @@ -154,7 +154,7 @@ public void testJavaThreadNotExecutingPythonAnymore() throws InterruptedExceptio } private static Context createContext() { - return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).option("python.NativeModules", "false").build(); + return Context.newBuilder().allowExperimentalOptions(true).allowAllAccess(true).option("python.IsolateNativeModules", "true").build(); } private static void loadNativeExtension(Context context) { diff --git a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingBenchmarkTest.java b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingBenchmarkTest.java index 3c70a77024..1111650d02 100644 --- a/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingBenchmarkTest.java +++ b/graalpython/com.oracle.graal.python.test.integration/src/com/oracle/graal/python/test/integration/engine/SharedEngineMultithreadingBenchmarkTest.java @@ -52,7 +52,7 @@ public class SharedEngineMultithreadingBenchmarkTest extends SharedEngineMultithreadingTestBase { @Test public void testRichardsInParallelInMultipleContexts() throws Throwable { - try (Engine engine = Engine.newBuilder().allowExperimentalOptions(true).option("python.NativeModules", "false").build()) { + try (Engine engine = Engine.newBuilder().allowExperimentalOptions(true).option("python.IsolateNativeModules", "true").build()) { Source richardsSource = PythonTests.getScriptSource("richards3.py"); Task[] tasks = new Task[THREADS_COUNT]; for (int taskIdx = 0; taskIdx < tasks.length; taskIdx++) { diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/cext/CExtContextTest.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/cext/CExtContextTest.java index d5d6adcf6d..11c32ed59a 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/cext/CExtContextTest.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/cext/CExtContextTest.java @@ -80,8 +80,8 @@ public void testGetBaseName() { } private static class TestCExtContext extends CExtContext { - public TestCExtContext(PythonContext context, Object llvmLibrary) { - super(context, llvmLibrary, false); + public TestCExtContext(PythonContext context, Object library) { + super(context, library); } public static TruffleString getBN(TruffleString s) { diff --git a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/MemMoveNodeTests.java b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/MemMoveNodeTests.java index c9e582cb0e..c6afa91a00 100644 --- a/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/MemMoveNodeTests.java +++ b/graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/nodes/MemMoveNodeTests.java @@ -65,7 +65,7 @@ public class MemMoveNodeTests { @Before public void setUp() { - PythonTests.enterContext(Map.of("python.NativeModules", "false"), new String[0]); + PythonTests.enterContext(Map.of("python.IsolateNativeModules", "true"), new String[0]); this.gil = GilNode.uncachedAcquire(); CApiContext.ensureCapiWasLoaded("internal"); } diff --git a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java index 8750e2b653..5f53706f93 100644 --- a/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java +++ b/graalpython/com.oracle.graal.python.test/src/org/graalvm/python/embedding/cext/test/MultiContextCExtTest.java @@ -254,7 +254,7 @@ public void testCreatingVenvForMulticontext() throws IOException, VFSUtils.Packa c0.eval(code); fail("should not reach here"); } catch (PolyglotException e) { - assertTrue("needs LLVM", e.getMessage().contains("LLVM")); + assertTrue("needs IsolateNativeModules", e.getMessage().contains("cannot use native module")); } } finally { for (var c : contexts) { diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py index 5c6050f9d1..12e142b5c4 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py @@ -53,7 +53,6 @@ DIR = Path(__file__).parent.absolute() GRAALPYTHON = sys.implementation.name == "graalpy" -RUNS_ON_LLVM = GRAALPYTHON and __graalpython__.ext_mode == 'llvm' def assert_raises(err, fn, *args, **kwargs): raised = False diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_bool.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_bool.py index c295ba3dc5..b1e7255376 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_bool.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_bool.py @@ -47,7 +47,7 @@ class DummyNonInt(): class TestPyBool(CPyExtTestCase): # (tfel): This test actually checks that the wrapped booleans that are - # stored as sulong globals are singletons + # stored as native globals are singletons test_PyBools_areSingleton = CPyExtFunction( lambda args: 1, lambda: ( diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_float.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_float.py index 0dbd303bee..5ae784686c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_float.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_float.py @@ -40,7 +40,7 @@ import unittest from . import CPyExtType, CPyExtTestCase, CPyExtFunction, CPyExtFunctionOutVars, unhandled_error_compare, \ - is_native_object, RUNS_ON_LLVM + is_native_object def _float_compare(x, y): @@ -212,8 +212,6 @@ def test_PyOS_double_to_string(self): assert tester.PyOS_double_to_string_test(190.08) == '190.080000' def test_PyOS_string_to_double(self): - if RUNS_ON_LLVM: - return TestPyOS_String_To_Double = CPyExtType( "TestPyOS_String_To_Double", ''' diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_functions.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_functions.py index 4cda51bf9f..92080c9a33 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_functions.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_functions.py @@ -41,7 +41,7 @@ import sys import unittest -from . import CPyExtType, CPyExtTestCase, CPyExtFunction, unhandled_error_compare, CPyExtHeapType, RUNS_ON_LLVM +from . import CPyExtType, CPyExtTestCase, CPyExtFunction, unhandled_error_compare, CPyExtHeapType DIR = os.path.dirname(__file__) diff --git a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_gc.py b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_gc.py index d381537528..5db5722d5c 100644 --- a/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_gc.py +++ b/graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_gc.py @@ -44,7 +44,7 @@ import unittest from unittest import skipIf -from . import CPyExtType, RUNS_ON_LLVM +from . import CPyExtType GRAALPY = sys.implementation.name == 'graalpy' @@ -220,8 +220,6 @@ def _trigger_gc(self): gc.collect() def test_cycle_with_native_objects(self): - if RUNS_ON_LLVM: - return TestCycle0 = CPyExtType("TestCycle0", ''' #define N 16 @@ -896,6 +894,6 @@ def test_module_globals(self): self._trigger_gc() ################################################################################## -@skipIf(not (GRAALPY) or RUNS_ON_LLVM, "Internal GraalPy RSS function") +@skipIf(not GRAALPY, "Internal GraalPy RSS function") def test_current_rss_monitor(): assert __graalpython__.get_current_rss() > 0 diff --git a/graalpython/com.oracle.graal.python/src/META-INF/native-image/org.graalvm.python/python-language/native-image.properties b/graalpython/com.oracle.graal.python/src/META-INF/native-image/org.graalvm.python/python-language/native-image.properties index 8fcfded464..0771ed8aaf 100644 --- a/graalpython/com.oracle.graal.python/src/META-INF/native-image/org.graalvm.python/python-language/native-image.properties +++ b/graalpython/com.oracle.graal.python/src/META-INF/native-image/org.graalvm.python/python-language/native-image.properties @@ -1,6 +1,6 @@ # This file contains native-image arguments needed to build graalpython Args = -H:MaxRuntimeCompileMethods=20000 \ --initialize-at-build-time=com.oracle.graal.python,com.oracle.truffle.regex,jline,org.fusesource \ - --features=com.oracle.graal.python.BouncyCastleFeature,com.oracle.graal.python.JNIFeature \ + --features=com.oracle.graal.python.BouncyCastleFeature \ --add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=org.graalvm.py \ --add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/JNIFeature.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/JNIFeature.java deleted file mode 100644 index 68d162e6d7..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/JNIFeature.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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; - -import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNIContext; - -public final class JNIFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - if (!PythonImageBuildOptions.WITHOUT_JNI) { - try { - // {{start jni upcall config}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_svm_jni_upcall_config - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDup", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxClose", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromInt32t", int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromUInt32t", int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromInt64t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromUInt64t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromSizet", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongFromSsizet", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsInt32t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsUInt32t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsUInt32tMask", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsInt64t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsUInt64t", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsUInt64tMask", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsSizet", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsSsizet", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsVoidPtr", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLongAsDouble", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFloatFromDouble", double.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFloatAsDouble", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBoolFromBool", boolean.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLength", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxNumberCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAdd", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSubtract", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxMultiply", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxMatrixMultiply", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFloorDivide", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTrueDivide", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxRemainder", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDivmod", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxPower", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxNegative", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxPositive", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAbsolute", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInvert", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLshift", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxRshift", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAnd", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxXor", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxOr", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxIndex", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLong", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFloat", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceAdd", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceSubtract", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceMultiply", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceMatrixMultiply", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceFloorDivide", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceTrueDivide", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceRemainder", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlacePower", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceLshift", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceRshift", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceAnd", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceXor", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxInPlaceOr", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCallableCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCallTupleDict", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCall", long.class, long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCallMethod", long.class, long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFatalError", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrSetString", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrSetObject", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrSetFromErrnoWithFilename", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrSetFromErrnoWithFilenameObjects", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrOccurred")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrExceptionMatches", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrNoMemory")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrClear")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrNewException", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrNewExceptionWithDoc", long.class, long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrWarnEx", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxErrWriteUnraisable", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxIsTrue", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeFromSpec", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeGenericNew", long.class, long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGetAttr", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxHasAttr", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxHasAttrs", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetAttr", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetAttrs", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGetItem", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGetItemi", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxContains", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetItem", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetItemi", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDelItem", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDelItemi", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDelItems", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxType", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeCheck", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeGetName", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeIsSubtype", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxIs", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructObject", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructLegacy", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructType", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructLong", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructFloat", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructUnicode", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructTuple", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsStructList", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTypeGetBuiltinShape", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxNew", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxRepr", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxStr", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxASCII", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytes", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxRichCompare", long.class, long.class, int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxRichCompareBool", long.class, long.class, int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxHash", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesSize", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesGETSIZE", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesAsString", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesASSTRING", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesFromString", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBytesFromStringAndSize", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeFromString", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeAsASCIIString", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeAsLatin1String", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeAsUTF8String", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeAsUTF8AndSize", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeFromWideChar", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeDecodeFSDefault", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeDecodeFSDefaultAndSize", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeEncodeFSDefault", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeReadChar", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeDecodeASCII", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeDecodeLatin1", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeFromEncodedObject", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeSubstring", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListNew", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListAppend", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDictCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDictNew")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDictKeys", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDictCopy", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTupleCheck", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSliceUnpack", long.class, long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxImportImportModule", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCapsuleNew", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCapsuleGet", long.class, int.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCapsuleIsValid", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCapsuleSet", long.class, int.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFromPyObject", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxAsPyObject", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListBuilderNew", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListBuilderSet", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListBuilderBuild", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxListBuilderCancel", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTupleBuilderNew", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTupleBuilderSet", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTupleBuilderBuild", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxTupleBuilderCancel", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFieldLoad", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxReenterPythonExecution", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxLeavePythonExecution")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGlobalLoad", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxDump", long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxCompiles", long.class, long.class, int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxEvalCode", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxContextVarNew", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxContextVarSet", long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetCallFunction", long.class, long.class)); - // @formatter:on - // Checkstyle: resume - // {{end jni upcall config}} - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("getHPyDebugContext")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("getHPyTraceContext")); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGetItems", long.class, String.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSetItems", long.class, String.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGetAttrs", long.class, String.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxBulkClose", long.class, int.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxUnicodeFromJCharArray", char[].class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxSequenceFromArray", long[].class, boolean.class, boolean.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxContextVarGet", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxFieldStore", long.class, long.class, long.class)); - RuntimeJNIAccess.register(GraalHPyJNIContext.class.getDeclaredMethod("ctxGlobalStore", long.class, long.class)); - } catch (NoSuchMethodException e) { - throw new RuntimeException("Could not register method for JNI access!", e); - } - try { - RuntimeJNIAccess.register(GraalHPyContext.class.getDeclaredField("hpyHandleTable")); - RuntimeJNIAccess.register(GraalHPyContext.class.getDeclaredField("hpyGlobalsTable")); - RuntimeJNIAccess.register(GraalHPyContext.class.getDeclaredField("nextHandle")); - } catch (SecurityException | NoSuchFieldException e) { - throw new RuntimeException("Could not register field for JNI access!", e); - } - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java index a422e89714..71ce059246 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java @@ -75,9 +75,6 @@ import com.oracle.graal.python.builtins.modules.FaulthandlerModuleBuiltins; import com.oracle.graal.python.builtins.modules.FcntlModuleBuiltins; import com.oracle.graal.python.builtins.modules.GcModuleBuiltins; -import com.oracle.graal.python.builtins.modules.GraalHPyDebugModuleBuiltins; -import com.oracle.graal.python.builtins.modules.GraalHPyTraceModuleBuiltins; -import com.oracle.graal.python.builtins.modules.GraalHPyUniversalModuleBuiltins; import com.oracle.graal.python.builtins.modules.GraalPythonModuleBuiltins; import com.oracle.graal.python.builtins.modules.ImpModuleBuiltins; import com.oracle.graal.python.builtins.modules.ItertoolsModuleBuiltins; @@ -784,11 +781,6 @@ private static PythonBuiltins[] initializeBuiltins(TruffleLanguage.Env env) { new PyCPointerBuiltins(), new CDataBuiltins(), - // _hpy_universal, _hpy_debug, and _hpy_trace - new GraalHPyUniversalModuleBuiltins(), - new GraalHPyDebugModuleBuiltins(), - new GraalHPyTraceModuleBuiltins(), - new StructModuleBuiltins(), new StructBuiltins(), new StructUnpackIteratorBuiltins(), diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java deleted file mode 100644 index 70ac43ebaf..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyDebugModuleBuiltins.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2021, 2025, 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.builtins.modules; - -import static com.oracle.graal.python.nodes.StringLiterals.J_DEBUG; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.Builtin; -import com.oracle.graal.python.builtins.CoreFunctions; -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.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinNode; -import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.NodeFactory; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.strings.TruffleString; - -@CoreFunctions(defineModule = GraalHPyDebugModuleBuiltins.J_HPY_DEBUG) -@GenerateNodeFactory -public final class GraalHPyDebugModuleBuiltins extends PythonBuiltins { - - public static final String J_HPY_DEBUG = "_hpy_debug"; - - static final String J_NOT_AVAILABLE = "_not_available"; - - private static final TruffleString T_NEW_GENERATION = tsLiteral("new_generation"); - private static final TruffleString T_GET_OPEN_HANDLES = tsLiteral("get_open_handles"); - private static final TruffleString T_GET_CLOSED_HANDLES = tsLiteral("get_closed_handles"); - private static final TruffleString T_GET_QUEUE_MAX_SIZE = tsLiteral("get_closed_handles_queue_max_size"); - private static final TruffleString T_SET_QUEUE_MAX_SIZE = tsLiteral("set_closed_handles_queue_max_size"); - private static final TruffleString T_GET_DATA_MAX_SIZE = tsLiteral("get_protected_raw_data_max_size"); - private static final TruffleString T_SET_DATA_MAX_SIZE = tsLiteral("set_protected_raw_data_max_size"); - private static final TruffleString T_SET_ON_INVALID_HANDLE = tsLiteral("set_on_invalid_handle"); - private static final TruffleString T_STACK_TRACE_LIMIT = tsLiteral("set_handle_stack_trace_limit"); - - @Override - protected List> getNodeFactories() { - return Collections.emptyList(); - } - - @Override - public void postInitialize(Python3Core core) { - PythonModule hpyDebugModule = core.lookupBuiltinModule(PythonUtils.tsLiteral(J_HPY_DEBUG)); - TruffleString[] keys = new TruffleString[]{T_NEW_GENERATION, T_GET_OPEN_HANDLES, T_GET_CLOSED_HANDLES, T_GET_QUEUE_MAX_SIZE, T_SET_QUEUE_MAX_SIZE, T_GET_DATA_MAX_SIZE, T_SET_DATA_MAX_SIZE, - T_SET_ON_INVALID_HANDLE, T_STACK_TRACE_LIMIT}; - try { - GraalHPyContext hpyContext = GraalHPyContext.ensureHPyWasLoaded(null, core.getContext(), null, null); - PythonModule nativeDebugModule = hpyContext.getHPyDebugModule(); - PDict nativeDebugDict = GetDictIfExistsNode.getUncached().execute(nativeDebugModule); - for (TruffleString tkey : keys) { - hpyDebugModule.setAttribute(tkey, nativeDebugDict.getItem(tkey)); - } - } catch (IOException | ApiInitException | ImportException e) { - /* - * Error case: install "not_available" for everything. So, loading still works, but you - * cannot use it. - */ - PythonBuiltinObject notAvailableObj = createFunction(core, hpyDebugModule); - for (TruffleString tkey : keys) { - hpyDebugModule.setAttribute(tkey, notAvailableObj); - } - } - } - - @Builtin(name = J_NOT_AVAILABLE, autoRegister = false, takesVarArgs = true, takesVarKeywordArgs = true) - static final class NotAvailable extends PythonBuiltinNode { - private static final NodeFactory NODE_FACTORY = new PrototypeNodeFactory<>(new NotAvailable()); - - @Override - public Object execute(VirtualFrame frame) { - throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_DEBUG); - } - } - - @TruffleBoundary - static PBuiltinMethod createFunction(Python3Core core, PythonModule module) { - Builtin builtin = NotAvailable.class.getAnnotation(Builtin.class); - PythonLanguage language = core.getLanguage(); - RootCallTarget callTarget = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, NotAvailable.NODE_FACTORY, false), NotAvailable.class, - builtin.name()); - int flags = PBuiltinFunction.getFlags(builtin, callTarget); - TruffleString name = PythonUtils.toTruffleStringUncached(builtin.name()); - PBuiltinFunction fun = PFactory.createBuiltinFunction(language, name, null, 0, flags, callTarget); - return PFactory.createBuiltinMethod(language, module, fun); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyTraceModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyTraceModuleBuiltins.java deleted file mode 100644 index 4cd1c216ca..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyTraceModuleBuiltins.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.modules; - -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -import com.oracle.graal.python.builtins.CoreFunctions; -import com.oracle.graal.python.builtins.Python3Core; -import com.oracle.graal.python.builtins.PythonBuiltins; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; -import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.object.GetDictIfExistsNode; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.NodeFactory; -import com.oracle.truffle.api.strings.TruffleString; - -@CoreFunctions(defineModule = GraalHPyTraceModuleBuiltins.J_HPY_TRACE) -@GenerateNodeFactory -public final class GraalHPyTraceModuleBuiltins extends PythonBuiltins { - - public static final String J_HPY_TRACE = "_hpy_trace"; - - private static final TruffleString T_GET_DURATIONS = tsLiteral("get_durations"); - private static final TruffleString T_GET_CALL_COUNTS = tsLiteral("get_call_counts"); - private static final TruffleString T_SET_TRACE_FUNCTIONS = tsLiteral("set_trace_functions"); - private static final TruffleString T_GET_FREQUENCY = tsLiteral("get_frequency"); - - @Override - protected List> getNodeFactories() { - return Collections.emptyList(); - } - - @Override - public void postInitialize(Python3Core core) { - PythonModule hpyTraceModule = core.lookupBuiltinModule(PythonUtils.tsLiteral(J_HPY_TRACE)); - TruffleString[] keys = new TruffleString[]{T_GET_DURATIONS, T_GET_CALL_COUNTS, T_SET_TRACE_FUNCTIONS, T_GET_FREQUENCY}; - try { - GraalHPyContext hpyContext = GraalHPyContext.ensureHPyWasLoaded(null, core.getContext(), null, null); - PythonModule nativeTraceModule = hpyContext.getHPyTraceModule(); - PDict nativeTraceDict = GetDictIfExistsNode.getUncached().execute(nativeTraceModule); - for (TruffleString tkey : keys) { - hpyTraceModule.setAttribute(tkey, nativeTraceDict.getItem(tkey)); - } - } catch (IOException | ApiInitException | ImportException e) { - /* - * Error case: install "not_available" for everything. So, loading still works, but you - * cannot use it. - */ - PythonBuiltinObject notAvailableObj = GraalHPyDebugModuleBuiltins.createFunction(core, hpyTraceModule); - for (TruffleString tkey : keys) { - hpyTraceModule.setAttribute(tkey, notAvailableObj); - } - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java deleted file mode 100644 index 2933df3032..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalHPyUniversalModuleBuiltins.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2021, 2025, 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.builtins.modules; - -import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___ALL__; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.annotations.ArgumentClinic; -import com.oracle.graal.python.annotations.ArgumentClinic.ClinicConversion; -import com.oracle.graal.python.builtins.Builtin; -import com.oracle.graal.python.builtins.CoreFunctions; -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.GraalHPyUniversalModuleBuiltinsClinicProviders.HPyUniversalLoadBootstrapNodeClinicProviderGen; -import com.oracle.graal.python.builtins.modules.GraalHPyUniversalModuleBuiltinsClinicProviders.HPyUniversalLoadNodeClinicProviderGen; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyMode; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.lib.PyObjectGetItem; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PConstructAndRaiseNode; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialAttributeNames; -import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; -import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; -import com.oracle.graal.python.nodes.function.builtins.PythonClinicBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider; -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile; -import com.oracle.graal.python.nodes.util.CannotCastException; -import com.oracle.graal.python.nodes.util.CastToJavaStringNode; -import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; -import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateNodeFactory; -import com.oracle.truffle.api.dsl.NodeFactory; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.strings.TruffleString; - -@CoreFunctions(defineModule = GraalHPyUniversalModuleBuiltins.J_HPY_UNIVERSAL) -@GenerateNodeFactory -public final class GraalHPyUniversalModuleBuiltins extends PythonBuiltins { - - static final String J_HPY_UNIVERSAL = "_hpy_universal"; - private static final TruffleString T_HPY_UNIVERSAL = tsLiteral(J_HPY_UNIVERSAL); - private static final TruffleString T_HPY = tsLiteral("HPY"); - - private static final TruffleString[] ALL_ARRAY; - - static { - List allList = new ArrayList<>(); - for (HPyMode mode : HPyMode.values()) { - allList.add(tsLiteral(mode.name())); - } - allList.add(tsLiteral("load")); - allList.add(tsLiteral("_load_bootstrap")); - ALL_ARRAY = allList.toArray(new TruffleString[0]); - } - - @Override - protected List> getNodeFactories() { - return GraalHPyUniversalModuleBuiltinsFactory.getFactories(); - } - - @Override - public void initialize(Python3Core core) { - for (HPyMode mode : HPyMode.values()) { - addBuiltinConstant(mode.name(), mode.getValue()); - } - super.initialize(core); - } - - @Override - public void postInitialize(Python3Core core) { - PythonModule module = core.lookupBuiltinModule(T_HPY_UNIVERSAL); - module.setAttribute(T___ALL__, PFactory.createTuple(core.getLanguage(), ALL_ARRAY)); - } - - @Builtin(name = "load", parameterNames = {"name", "path", "spec", "debug", "mode"}, minNumOfPositionalArgs = 3) - @GenerateNodeFactory - @ArgumentClinic(name = "name", conversion = ClinicConversion.TString) - @ArgumentClinic(name = "path", conversion = ClinicConversion.TString) - @ArgumentClinic(name = "debug", conversion = ClinicConversion.Boolean, defaultValue = "false") - @ArgumentClinic(name = "mode", conversion = ClinicConversion.Int, defaultValue = "-1") - abstract static class HPyUniversalLoadNode extends PythonClinicBuiltinNode { - - @Override - protected ArgumentClinicProvider getArgumentClinic() { - return HPyUniversalLoadNodeClinicProviderGen.INSTANCE; - } - - @Specialization - static Object doGeneric(VirtualFrame frame, TruffleString name, TruffleString path, Object spec, boolean debug, int mode, - @Bind("this") Node inliningTarget, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached TruffleString.EqualNode eqNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode) { - PythonContext context = PythonContext.get(inliningTarget); - PythonLanguage language = context.getLanguage(inliningTarget); - Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); - try { - HPyMode hmode = debug ? HPyMode.MODE_DEBUG : HPyMode.MODE_UNIVERSAL; - // 'mode' just overwrites 'debug' - if (mode > 0) { - hmode = HPyMode.fromValue(mode); - } - return GraalHPyContext.loadHPyModule(inliningTarget, context, name, path, spec, hmode); - } catch (ApiInitException ie) { - throw ie.reraise(frame, inliningTarget, constructAndRaiseNode); - } catch (ImportException ie) { - throw ie.reraise(frame, inliningTarget, constructAndRaiseNode); - } catch (IOException e) { - throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, e, eqNode); - } finally { - IndirectCallContext.exit(frame, language, context, state); - } - } - } - - @Builtin(name = "_load_bootstrap", parameterNames = {"name", "ext_name", "package", "file", "loader", "spec", "env"}) - @GenerateNodeFactory - @ArgumentClinic(name = "name", conversion = ClinicConversion.TString) - @ArgumentClinic(name = "ext_name", conversion = ClinicConversion.TString) - @ArgumentClinic(name = "file", conversion = ClinicConversion.TString) - abstract static class HPyUniversalLoadBootstrapNode extends PythonClinicBuiltinNode { - - @Override - protected ArgumentClinicProvider getArgumentClinic() { - return HPyUniversalLoadBootstrapNodeClinicProviderGen.INSTANCE; - } - - @Specialization - static Object doGeneric(VirtualFrame frame, TruffleString name, TruffleString extName, Object pkg, TruffleString file, Object loader, Object spec, Object env, - @Bind("this") Node inliningTarget, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @Cached TruffleString.EqualNode eqNode, - @Cached WriteAttributeToObjectNode writeAttrNode, - @Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode, - @Cached PRaiseNode raiseNode) { - Object module; - - PythonContext context = PythonContext.get(inliningTarget); - PythonLanguage language = context.getLanguage(inliningTarget); - Object state = IndirectCallContext.enter(frame, language, context, indirectCallData); - try { - HPyMode hmode = getHPyModeFromEnviron(name, env); - module = GraalHPyContext.loadHPyModule(inliningTarget, context, name, file, spec, hmode); - } catch (CannotCastException e) { - // thrown by getHPyModeFromEnviron if value is not a string - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_MODE_VALUE_MUST_BE_STRING); - } catch (ApiInitException ie) { - throw ie.reraise(frame, inliningTarget, constructAndRaiseNode); - } catch (ImportException ie) { - throw ie.reraise(frame, inliningTarget, constructAndRaiseNode); - } catch (IOException e) { - throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, e, eqNode); - } finally { - IndirectCallContext.exit(frame, language, context, state); - } - - writeAttrNode.execute(module, SpecialAttributeNames.T___FILE__, file); - writeAttrNode.execute(module, SpecialAttributeNames.T___LOADER__, loader); - writeAttrNode.execute(module, SpecialAttributeNames.T___NAME__, extName); - writeAttrNode.execute(module, SpecialAttributeNames.T___PACKAGE__, pkg); - writeAttrNode.execute(spec, ImpModuleBuiltins.T_ORIGIN, file); - writeAttrNode.execute(module, SpecialAttributeNames.T___SPEC__, spec); - return module; - } - - /** - *
    -         *     HPY_MODE := MODE | (MODULE_NAME ':' MODE { ',' MODULE_NAME ':' MODE })
    -         *     MODULE_NAME :=
    -         *     IDENTIFIER MODE := 'debug' | 'trace' | 'universal'
    -         * 
    - */ - @TruffleBoundary - private static HPyMode getHPyModeFromEnviron(TruffleString moduleName, Object env) throws CannotCastException { - Object result; - try { - result = PyObjectGetItem.executeUncached(env, T_HPY); - } catch (PException e) { - e.expect(null, PythonBuiltinClassType.KeyError, IsBuiltinObjectProfile.getUncached()); - // this is not an error; it just means that the key was not present in 'env' - return HPyMode.MODE_UNIVERSAL; - } - - String s = CastToJavaStringNode.getUncached().execute(result); - - int colonIdx = s.indexOf(':'); - if (colonIdx != -1) { - // case 2: modes are specified per module - String[] moduleParts = s.split(","); - String sModuleName = moduleName.toJavaStringUncached(); - for (String modulePars : moduleParts) { - String[] def = modulePars.split(":"); - if (sModuleName.equals(def[0])) { - return HPyMode.valueOf("MODE_" + def[1].toUpperCase()); - } - } - } else { - // case 1: mode was globally specified - return HPyMode.valueOf("MODE_" + s.toUpperCase()); - } - return HPyMode.MODE_UNIVERSAL; - } - } -} 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 97a4d50576..4ce7b9349e 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 @@ -53,10 +53,8 @@ import static com.oracle.graal.python.nodes.BuiltinNames.T___MAIN__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___NAME__; import static com.oracle.graal.python.nodes.SpecialMethodNames.T_INSERT; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_COLON; import static com.oracle.graal.python.nodes.StringLiterals.T_JAVA; -import static com.oracle.graal.python.nodes.StringLiterals.T_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_NATIVE; import static com.oracle.graal.python.nodes.StringLiterals.T_PATH; import static com.oracle.graal.python.nodes.StringLiterals.T_STRICT; @@ -204,7 +202,6 @@ import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.llvm.api.Toolchain; @CoreFunctions(defineModule = J___GRAALPYTHON__, isEager = true) public final class GraalPythonModuleBuiltins extends PythonBuiltins { @@ -272,14 +269,11 @@ public void postInitialize(Python3Core core) { mod.setAttribute(tsLiteral("core_home"), coreHome); mod.setAttribute(tsLiteral("stdlib_home"), stdlibHome); mod.setAttribute(tsLiteral("capi_home"), capiHome); - mod.setAttribute(tsLiteral("jni_home"), context.getJNIHome()); Object[] arr = convertToObjectArray(PythonOptions.getExecutableList(context)); PList executableList = PFactory.createList(language, arr); mod.setAttribute(tsLiteral("executable_list"), executableList); mod.setAttribute(tsLiteral("venvlauncher_command"), context.getOption(PythonOptions.VenvlauncherCommand)); mod.setAttribute(tsLiteral("ForeignType"), core.lookupType(PythonBuiltinClassType.ForeignObject)); - mod.setAttribute(tsLiteral("use_system_toolchain"), context.getOption(PythonOptions.UseSystemToolchain)); - mod.setAttribute(tsLiteral("ext_mode"), context.getOption(PythonOptions.NativeModules) ? T_NATIVE : T_LLVM_LANGUAGE); if (!context.getOption(PythonOptions.EnableDebuggingBuiltins)) { mod.setAttribute(tsLiteral("dump_truffle_ast"), PNone.NO_VALUE); @@ -602,117 +596,6 @@ public Object doIt(PFunction func) { } } - @Builtin(name = "get_toolchain_tools_for_venv") - @GenerateNodeFactory - public abstract static class GetToolchainToolsForVenv extends PythonBuiltinNode { - private static final class Tool { - final String name; - final boolean isVariableName; - final Object[] targets; - - public Tool(String name, boolean isVariableName, Object[] targets) { - this.name = name; - this.isVariableName = isVariableName; - this.targets = targets; - } - - static Tool forVariable(String name, Object... targets) { - return new Tool(name, true, targets); - } - - static Tool forBinary(String name, Object... targets) { - return new Tool(name, true, targets); - } - } - - static final Tool[] tools = new Tool[]{ - Tool.forVariable("AR", tsLiteral("ar")), - Tool.forVariable("RANLIB", tsLiteral("ranlib")), - Tool.forVariable("NM", tsLiteral("nm")), - Tool.forVariable("LD", tsLiteral("ld.lld"), tsLiteral("ld"), tsLiteral("lld")), - Tool.forVariable("CC", tsLiteral("clang"), tsLiteral("cc")), - Tool.forVariable("CXX", tsLiteral("clang++"), tsLiteral("c++")), - Tool.forVariable("FC", tsLiteral("graalvm-flang"), tsLiteral("flang-new"), tsLiteral("flang")), - Tool.forBinary("llvm-as", tsLiteral("as")), - Tool.forBinary("clang-cl", tsLiteral("cl")), - Tool.forBinary("clang-cpp", tsLiteral("cpp")), - }; - - @Specialization - @TruffleBoundary - Object getToolPath() { - PythonContext context = getContext(); - Env env = context.getEnv(); - LanguageInfo llvmInfo = env.getInternalLanguages().get(J_LLVM_LANGUAGE); - Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); - List toolchainPaths = toolchain.getPaths("PATH"); - EconomicMapStorage storage = EconomicMapStorage.create(tools.length); - for (Tool tool : tools) { - String path = null; - if (tool.isVariableName) { - TruffleFile toolPath = toolchain.getToolPath(tool.name); - if (toolPath != null) { - path = toolPath.getAbsoluteFile().getPath(); - } - } else { - for (TruffleFile toolchainPath : toolchainPaths) { - LOGGER.finest(() -> " Testing path " + toolchainPath.getPath() + " for tool " + tool.name); - TruffleFile pathToTest = toolchainPath.resolve(tool.name); - if (pathToTest.exists()) { - path = pathToTest.getAbsoluteFile().getPath(); - break; - } - } - } - if (path != null) { - storage.putUncached(toTruffleStringUncached(path), PFactory.createTuple(context.getLanguage(), tool.targets)); - } else { - LOGGER.fine("Could not locate tool " + tool.name); - } - } - return PFactory.createDict(context.getLanguage(), storage); - } - } - - @Builtin(name = "get_toolchain_tool_path", minNumOfPositionalArgs = 1) - @GenerateNodeFactory - public abstract static class GetToolPathNode extends PythonUnaryBuiltinNode { - @Specialization - @TruffleBoundary - protected Object getToolPath(TruffleString tool) { - Env env = getContext().getEnv(); - LanguageInfo llvmInfo = env.getInternalLanguages().get(J_LLVM_LANGUAGE); - Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); - TruffleFile toolPath = toolchain.getToolPath(tool.toJavaStringUncached()); - if (toolPath == null) { - return PNone.NONE; - } - return toTruffleStringUncached(toolPath.toString().replace("\\", "/")); - } - } - - @Builtin(name = "get_toolchain_paths", minNumOfPositionalArgs = 1) - @GenerateNodeFactory - public abstract static class GetToolchainPathsNode extends PythonUnaryBuiltinNode { - @Specialization - @TruffleBoundary - protected Object getToolPath(TruffleString tool) { - PythonContext context = getContext(); - Env env = context.getEnv(); - LanguageInfo llvmInfo = env.getInternalLanguages().get(J_LLVM_LANGUAGE); - Toolchain toolchain = env.lookup(llvmInfo, Toolchain.class); - List toolPaths = toolchain.getPaths(tool.toJavaStringUncached()); - if (toolPaths == null) { - return PNone.NONE; - } - Object[] pathNames = new Object[toolPaths.size()]; - for (int i = 0; i < pathNames.length; i++) { - pathNames[i] = toTruffleStringUncached(toolPaths.get(i).toString().replace("\\", "/")); - } - return PFactory.createList(context.getLanguage(), pathNames); - } - } - @Builtin(name = "determine_system_toolchain", maxNumOfPositionalArgs = 1) @GenerateNodeFactory public abstract static class DetermineSystemToolchain extends PythonUnaryBuiltinNode { @@ -1071,17 +954,6 @@ static boolean doGeneric(int id) { } } - // This is only used from HPy - @Builtin(name = "PyTruffle_CreateType", minNumOfPositionalArgs = 4) - @GenerateNodeFactory - abstract static class PyTruffle_CreateType extends PythonQuaternaryBuiltinNode { - @Specialization - static PythonClass createType(VirtualFrame frame, TruffleString name, PTuple bases, PDict namespaceOrig, Object metaclass, - @Cached CreateTypeNode createType) { - return createType.execute(frame, namespaceOrig, name, bases, metaclass, PKeyword.EMPTY_KEYWORDS); - } - } - @Builtin(name = "get_graalvm_version", minNumOfPositionalArgs = 0) @GenerateNodeFactory abstract static class GetGraalVmVersion extends PythonBuiltinNode { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java index a651521214..f88c7a2d80 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java @@ -891,9 +891,9 @@ public enum CApiCallPath { */ Direct, /** - * This builtin has an explicit C implementation that can be executed both from native and - * from Sulong - no automatic stub will be generated. Further, there *MUST NOT* be a C API - * builtin that would implement the function in Java. + * This builtin has an explicit C implementation that can be executed both from native - no + * automatic stub will be generated. Further, there *MUST NOT* be a C API builtin that would + * implement the function in Java. */ CImpl, /** diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java index d4d4de5040..12cc56edf2 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java @@ -71,7 +71,6 @@ import static com.oracle.graal.python.nodes.ErrorMessages.TOO_MANY_ARGUMENTS_D_MAXIMUM_IS_D; import static com.oracle.graal.python.nodes.StringLiterals.J_DEFAULT; import static com.oracle.graal.python.nodes.StringLiterals.J_EMPTY_STRING; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_LPAREN; import static com.oracle.graal.python.runtime.PosixConstants.RTLD_GLOBAL; @@ -123,7 +122,6 @@ import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNIContext; import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItem; @@ -275,23 +273,9 @@ public void postInitialize(Python3Core core) { if (PythonOS.getPythonOS() == PythonOS.PLATFORM_WIN32) { PythonModule sysModule = context.getSysModule(); Object loadLibraryMethod = ReadAttributeFromObjectNode.getUncached().execute(ctypesModule, toTruffleStringUncached("LoadLibrary")); - Object pythonLib = CallNode.executeUncached(loadLibraryMethod, toTruffleStringUncached(GraalHPyJNIContext.getJNILibrary()), 0); + Object pythonLib = CallNode.executeUncached(loadLibraryMethod, toTruffleStringUncached(PythonContext.getSupportLibName("python-native")), 0); WriteAttributeToPythonObjectNode.getUncached().execute(sysModule, toTruffleStringUncached("dllhandle"), pythonLib); } - } else if (!PythonOptions.NativeModules.getValue(context.getEnv().getOptions())) { - // If native is not available, we can use the C API support library only if it was - // loaded through LLVM and not NFI. This limitation can be lifted: we can reload the - // library with LLVM here. - try { - Object llvmLibrary = CApiContext.ensureCApiLLVMLibrary(context); - handle = new DLHandler(llvmLibrary, 0, J_EMPTY_STRING, true); - } catch (ApiInitException e) { - throw e.reraise(null, null, PConstructAndRaiseNode.Lazy.getUncached()); - } catch (ImportException e) { - throw e.reraise(null, null, PConstructAndRaiseNode.Lazy.getUncached()); - } catch (IOException e) { - throw PConstructAndRaiseNode.getUncached().raiseOSError(null, e, EqualNode.getUncached()); - } } if (handle != null) { NativeFunction memmove = MemMoveFunction.create(handle, context); @@ -353,10 +337,6 @@ protected boolean isManaged() { return isManaged; } - protected boolean isLLVM() { - return sym instanceof CallLLVMFunction; - } - protected boolean isManaged(long address) { return adr == address; } @@ -686,16 +666,6 @@ private static Object load(PythonContext context, String src, String name) { return context.getEnv().parseInternal(loadSrc).call(); } - @TruffleBoundary - protected static Object loadLLVMLibrary(PythonContext context, Node nodeForRaise, TruffleString path) throws ImportException, ApiInitException, IOException { - context.ensureLLVMLanguage(nodeForRaise); - if (path.isEmpty()) { - return CApiContext.ensureCApiLLVMLibrary(context); - } - Source loadSrc = Source.newBuilder(J_LLVM_LANGUAGE, context.getPublicTruffleFileRelaxed(path)).build(); - return context.getEnv().parseInternal(loadSrc).call(); - } - @TruffleBoundary private static TruffleString getErrMsg(Exception e) { String errmsg = e != null ? e.getMessage() : null; @@ -725,13 +695,7 @@ static Object py_dl_open(PythonModule self, TruffleString name, int m, DLHandler handle; Exception exception = null; try { - if (!context.getEnv().isNativeAccessAllowed() && !PythonOptions.NativeModules.getValue(context.getEnv().getOptions())) { - Object handler = loadLLVMLibrary(context, inliningTarget, name); - long adr = PyObjectHashNode.executeUncached(handler); - handle = new DLHandler(handler, adr, name.toJavaStringUncached(), true); - registerAddress(context, handle.adr, handle); - return PFactory.createNativeVoidPtr(language, handle); - } else if (context.getEnv().isNativeAccessAllowed()) { + if (context.getEnv().isNativeAccessAllowed()) { CtypesThreadState ctypes = CtypesThreadState.get(context, context.getLanguage()); /*- TODO: (mq) cryptography in macos isn't always compatible with ctypes. @@ -789,17 +753,11 @@ static Object ctypes_dlsym(VirtualFrame frame, Pointer handlePtr, Object n, Pyth } try { Object sym = ilib.readMember(handle.library, name); - boolean isManaged = handle.isManaged; - long adr = isManaged ? hashNode.execute(frame, inliningTarget, sym) : ilib.asPointer(sym); - sym = isManaged ? CallLLVMFunction.create(sym, ilib) : sym; - NativeFunction func = new NativeFunction(sym, adr, name, isManaged); + long adr = ilib.asPointer(sym); + NativeFunction func = new NativeFunction(sym, adr, name, false); registerAddress(context, adr, func); // PyLong_FromVoidPtr(ptr); - if (!isManaged) { - return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func, adr); - } else { - return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func); - } + return PFactory.createNativeVoidPtr(context.getLanguage(inliningTarget), func, adr); } catch (UnsupportedMessageException | UnknownIdentifierException e) { throw raiseNode.raise(inliningTarget, error, e); } @@ -1162,11 +1120,7 @@ Object _ctypes_callproc(VirtualFrame frame, NativeFunction pProc, Object[] argar /* Convert the arguments */ BackendMode mode = BackendMode.NFI; if (pProc.isManaged()) { - if (pProc.isLLVM()) { - mode = BackendMode.LLVM; - } else { - mode = BackendMode.INTRINSIC; - } + mode = BackendMode.INTRINSIC; } for (int i = 0; i < argcount; ++i) { args[i] = new CTypesCallArgument(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java index b4d387410d..b282180676 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java @@ -45,7 +45,6 @@ import static com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.pollReferenceQueue; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___FILE__; import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___LIBRARY__; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_DASH; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; @@ -343,8 +342,8 @@ public static TruffleLogger getLogger(Class clazz) { return PythonLanguage.getLogger(LOGGER_CAPI_NAME + "." + clazz.getSimpleName()); } - public CApiContext(PythonContext context, Object llvmLibrary, NativeLibraryLocator locator) { - super(context, llvmLibrary, locator != null); + public CApiContext(PythonContext context, Object library, NativeLibraryLocator locator) { + super(context, library); this.nativeSymbolCache = new Object[NativeCAPISymbol.values().length]; this.nativeLibraryLocator = locator; @@ -696,7 +695,7 @@ private static Object lookupNativeSymbol(Object[] nativeSymbolCache, NativeCAPIS CompilerAsserts.neverPartOfCompilation(); String name = symbol.getName(); try { - Object nativeSymbol = InteropLibrary.getUncached().readMember(PythonContext.get(null).getCApiContext().getLLVMLibrary(), name); + Object nativeSymbol = InteropLibrary.getUncached().readMember(PythonContext.get(null).getCApiContext().getLibrary(), name); nativeSymbol = EnsureExecutableNode.executeUncached(nativeSymbol, symbol); VarHandle.storeStoreFence(); return nativeSymbolCache[symbol.ordinal()] = nativeSymbol; @@ -901,14 +900,6 @@ public static CApiContext ensureCapiWasLoaded(String reason) { } } - @TruffleBoundary - public static Object ensureCApiLLVMLibrary(PythonContext context) throws IOException, ImportException, ApiInitException { - assert !PythonOptions.NativeModules.getValue(context.getEnv().getOptions()); - CApiContext cApiContext = ensureCapiWasLoaded(null, context, T_EMPTY_STRING, T_EMPTY_STRING, - " load LLVM library (this is an internal bug, LLVM library should not be loaded when running on native backend)"); - return cApiContext.getLLVMLibrary(); - } - @TruffleBoundary public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context, TruffleString name, TruffleString path) throws IOException, ImportException, ApiInitException { return ensureCapiWasLoaded(node, context, name, path, null); @@ -923,46 +914,36 @@ public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context, TruffleFile homePath = env.getInternalTruffleFile(context.getCAPIHome().toJavaStringUncached()); // e.g. "libpython-native.so" - String libName = context.getLLVMSupportExt("python"); + String libName = PythonContext.getSupportLibName("python-native"); final TruffleFile capiFile = homePath.resolve(libName).getCanonicalFile(); try { SourceBuilder capiSrcBuilder; - boolean useNative = PythonOptions.NativeModules.getValue(env.getOptions()); + boolean useNative = true; boolean isolateNative = PythonOptions.IsolateNativeModules.getValue(env.getOptions()); final NativeLibraryLocator loc; - if (useNative) { - if (!isolateNative) { - useNative = nativeCAPILoaded.compareAndSet(NO_NATIVE_CONTEXT, GLOBAL_NATIVE_CONTEXT); - } else { - useNative = nativeCAPILoaded.compareAndSet(NO_NATIVE_CONTEXT, ISOLATED_NATIVE_CONTEXT) || nativeCAPILoaded.get() == ISOLATED_NATIVE_CONTEXT; - } - if (!useNative) { - String actualReason = "initialize native extensions support"; - if (reason != null) { - actualReason = reason; - } else if (name != null && path != null) { - actualReason = String.format("load a native module '%s' from path '%s'", name.toJavaStringUncached(), path.toJavaStringUncached()); - } - throw new ApiInitException(toTruffleStringUncached( - String.format("Option python.NativeModules is set to 'true' and a second GraalPy context attempted to %s. " + - "At least one context in this process runs with 'IsolateNativeModules' set to false. " + - "Depending on the order of context creation, this means some contexts in the process " + - "cannot use native module, all other contexts must fall back and set python.NativeModules " + - "to 'false' to run native extensions in LLVM mode. This is recommended only " + - "for extensions included in the Python standard library. Running a 3rd party extension in LLVM mode requires " + - "a custom build of the extension and is generally discouraged due to compatibility reasons.", actualReason))); - } - loc = new NativeLibraryLocator(context, capiFile, isolateNative); - context.ensureNFILanguage(node, "NativeModules", "true"); - String dlopenFlags = isolateNative ? "RTLD_LOCAL" : "RTLD_GLOBAL"; - capiSrcBuilder = Source.newBuilder(J_NFI_LANGUAGE, String.format("load(%s) \"%s\"", dlopenFlags, loc.getCapiLibrary()), ""); - LOGGER.config(() -> "loading CAPI from " + loc.getCapiLibrary() + " as native"); + if (!isolateNative) { + useNative = nativeCAPILoaded.compareAndSet(NO_NATIVE_CONTEXT, GLOBAL_NATIVE_CONTEXT); } else { - loc = null; - context.ensureLLVMLanguage(node); - capiSrcBuilder = Source.newBuilder(J_LLVM_LANGUAGE, capiFile); - LOGGER.config(() -> "loading CAPI from " + capiFile + " as bitcode"); + useNative = nativeCAPILoaded.compareAndSet(NO_NATIVE_CONTEXT, ISOLATED_NATIVE_CONTEXT) || nativeCAPILoaded.get() == ISOLATED_NATIVE_CONTEXT; + } + if (!useNative) { + String actualReason = "initialize native extensions support"; + if (reason != null) { + actualReason = reason; + } else if (name != null && path != null) { + actualReason = String.format("load a native module '%s' from path '%s'", name.toJavaStringUncached(), path.toJavaStringUncached()); + } + throw new ApiInitException(toTruffleStringUncached( + String.format("Option python.IsolateNativeModules is set to 'false' and a second GraalPy context attempted to %s. " + + "At least one context in this process runs with 'IsolateNativeModules' set to false. " + + "Depending on the order of context creation, this means some contexts in the process " + + "cannot use native module.", actualReason))); } + loc = new NativeLibraryLocator(context, capiFile, isolateNative); + context.ensureNFILanguage(node, "allowNativeAccess", "true"); + String dlopenFlags = isolateNative ? "RTLD_LOCAL" : "RTLD_GLOBAL"; + capiSrcBuilder = Source.newBuilder(J_NFI_LANGUAGE, String.format("load(%s) \"%s\"", dlopenFlags, loc.getCapiLibrary()), ""); + LOGGER.config(() -> "loading CAPI from " + loc.getCapiLibrary() + " as native"); if (!context.getLanguage().getEngineOption(PythonOptions.ExposeInternalSources)) { capiSrcBuilder.internal(true); } @@ -980,40 +961,32 @@ public static CApiContext ensureCapiWasLoaded(Node node, PythonContext context, * then already require the GC state. */ Object gcState = cApiContext.createGCState(); - if (useNative) { - Object signature = env.parseInternal(Source.newBuilder(J_NFI_LANGUAGE, "(ENV,POINTER,POINTER):VOID", "exec").build()).call(); - initFunction = SignatureLibrary.getUncached().bind(signature, initFunction); - U.execute(initFunction, builtinArrayWrapper, gcState); - } else { - assert U.isExecutable(initFunction); - U.execute(initFunction, NativePointer.createNull(), builtinArrayWrapper, gcState); - } + Object signature = env.parseInternal(Source.newBuilder(J_NFI_LANGUAGE, "(ENV,POINTER,POINTER):VOID", "exec").build()).call(); + initFunction = SignatureLibrary.getUncached().bind(signature, initFunction); + U.execute(initFunction, builtinArrayWrapper, gcState); } assert PythonCApiAssertions.assertBuiltins(capiLibrary); cApiContext.pyDateTimeCAPICapsule = PyDateTimeCAPIWrapper.initWrapper(context, cApiContext); context.runCApiHooks(); - if (useNative) { - /* - * C++ libraries sometimes declare global objects that have destructors that - * call Py_DECREF. Those destructors are then called during native shutdown, - * which is after the JVM/SVM shut down and the upcall would segfault. This - * finalizer code rebinds reference operations to native no-ops that don't - * upcall. In normal scenarios we call it during context exit, but when the VM - * is terminated by a signal, the context exit is skipped. For that case we set - * up the shutdown hook. - */ - Object finalizeFunction = U.readMember(capiLibrary, "GraalPy_get_finalize_capi_pointer"); - Object finalizeSignature = env.parseInternal(Source.newBuilder(J_NFI_LANGUAGE, "():POINTER", "exec").build()).call(); - Object finalizingPointer = SignatureLibrary.getUncached().call(finalizeSignature, finalizeFunction); - try { - cApiContext.addNativeFinalizer(context, finalizingPointer); - cApiContext.runBackgroundGCTask(context); - } catch (RuntimeException e) { - // This can happen when other languages restrict multithreading - LOGGER.warning(() -> "didn't register a native finalizer due to: " + e.getMessage()); - } + /* + * C++ libraries sometimes declare global objects that have destructors that call + * Py_DECREF. Those destructors are then called during native shutdown, which is + * after the JVM/SVM shut down and the upcall would segfault. This finalizer code + * rebinds reference operations to native no-ops that don't upcall. In normal + * scenarios we call it during context exit, but when the VM is terminated by a + * signal, the context exit is skipped. For that case we set up the shutdown hook. + */ + Object finalizeFunction = U.readMember(capiLibrary, "GraalPy_get_finalize_capi_pointer"); + Object finalizeSignature = env.parseInternal(Source.newBuilder(J_NFI_LANGUAGE, "():POINTER", "exec").build()).call(); + Object finalizingPointer = SignatureLibrary.getUncached().call(finalizeSignature, finalizeFunction); + try { + cApiContext.addNativeFinalizer(context, finalizingPointer); + cApiContext.runBackgroundGCTask(context); + } catch (RuntimeException e) { + // This can happen when other languages restrict multithreading + LOGGER.warning(() -> "didn't register a native finalizer due to: " + e.getMessage()); } return cApiContext; @@ -1094,51 +1067,39 @@ public static Object loadCExtModule(Node location, PythonContext context, Module Object library; InteropLibrary interopLib; - if (cApiContext.useNativeBackend) { - TruffleFile realPath = context.getPublicTruffleFileRelaxed(spec.path, context.getSoAbi()).getCanonicalFile(); - String loadPath = cApiContext.nativeLibraryLocator.resolve(context, realPath); - getLogger(CApiContext.class).config(String.format("loading module %s (real path: %s) as native", spec.path, loadPath)); - int dlopenFlags = context.getDlopenFlags(); - if (context.getOption(PythonOptions.IsolateNativeModules)) { - if ((dlopenFlags & PosixConstants.RTLD_GLOBAL.value) != 0) { - getLogger(CApiContext.class).warning("The IsolateNativeModules option was specified, but the dlopen flags were set to include RTLD_GLOBAL " + - "(likely via some call to sys.setdlopenflags). This will probably lead to broken isolation and possibly incorrect results and crashing. " + - "You can patch sys.setdlopenflags to trace callers and/or prevent setting the RTLD_GLOBAL flags. " + - "See https://www.graalvm.org/latest/reference-manual/python/Native-Extensions for more details."); - } - dlopenFlags |= PosixConstants.RTLD_LOCAL.value; - } - String loadExpr = String.format("load(%s) \"%s\"", dlopenFlagsToString(dlopenFlags), loadPath); - if (PythonOptions.UsePanama.getValue(context.getEnv().getOptions())) { - loadExpr = "with panama " + loadExpr; - } - try { - Source librarySource = Source.newBuilder(J_NFI_LANGUAGE, loadExpr, "load " + spec.name).build(); - library = context.getEnv().parseInternal(librarySource).call(); - interopLib = InteropLibrary.getUncached(library); - } catch (PException e) { - throw e; - } catch (AbstractTruffleException e) { - if (!realPath.exists() && realPath.toString().contains("org.graalvm.python.vfsx")) { - // file does not exist and it is from VirtualFileSystem - // => we probably failed to extract it due to unconventional libs location - getLogger(CApiContext.class).severe(String.format("could not load module %s (real path: %s) from virtual file system.\n\n" + - "!!! Please try to run with java system property org.graalvm.python.vfs.extractOnStartup=true !!!\n", spec.path, realPath)); - - } - - throw new ImportException(CExtContext.wrapJavaException(e, location), spec.name, spec.path, ErrorMessages.CANNOT_LOAD_M, spec.path, e); + TruffleFile realPath = context.getPublicTruffleFileRelaxed(spec.path, context.getSoAbi()).getCanonicalFile(); + String loadPath = cApiContext.nativeLibraryLocator.resolve(context, realPath); + getLogger(CApiContext.class).config(String.format("loading module %s (real path: %s) as native", spec.path, loadPath)); + int dlopenFlags = context.getDlopenFlags(); + if (context.getOption(PythonOptions.IsolateNativeModules)) { + if ((dlopenFlags & PosixConstants.RTLD_GLOBAL.value) != 0) { + getLogger(CApiContext.class).warning("The IsolateNativeModules option was specified, but the dlopen flags were set to include RTLD_GLOBAL " + + "(likely via some call to sys.setdlopenflags). This will probably lead to broken isolation and possibly incorrect results and crashing. " + + "You can patch sys.setdlopenflags to trace callers and/or prevent setting the RTLD_GLOBAL flags. " + + "See https://www.graalvm.org/latest/reference-manual/python/Native-Extensions for more details."); } - } else { - library = loadLLVMLibrary(location, context, spec.name, spec.path); + dlopenFlags |= PosixConstants.RTLD_LOCAL.value; + } + String loadExpr = String.format("load(%s) \"%s\"", dlopenFlagsToString(dlopenFlags), loadPath); + if (PythonOptions.UsePanama.getValue(context.getEnv().getOptions())) { + loadExpr = "with panama " + loadExpr; + } + try { + Source librarySource = Source.newBuilder(J_NFI_LANGUAGE, loadExpr, "load " + spec.name).build(); + library = context.getEnv().parseInternal(librarySource).call(); interopLib = InteropLibrary.getUncached(library); - try { - if (interopLib.getLanguage(library).toString().startsWith("class com.oracle.truffle.nfi")) { - throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.SystemError, ErrorMessages.NO_BITCODE_FOUND, spec.path); - } - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); + } catch (PException e) { + throw e; + } catch (AbstractTruffleException e) { + if (!realPath.exists() && realPath.toString().contains("org.graalvm.python.vfsx")) { + // file does not exist and it is from VirtualFileSystem + // => we probably failed to extract it due to unconventional libs location + getLogger(CApiContext.class).severe(String.format("could not load module %s (real path: %s) from virtual file system.\n\n" + + "!!! Please try to run with java system property org.graalvm.python.vfs.extractOnStartup=true !!!\n", spec.path, realPath)); + } + + throw new ImportException(CExtContext.wrapJavaException(e, location), spec.name, spec.path, ErrorMessages.CANNOT_LOAD_M, spec.path, e); } try { @@ -1457,13 +1418,13 @@ private static boolean isAvailable(CApiBuiltinExecutable builtin) { if (cApiContext == null) { return false; } - Object llvmLibrary = cApiContext.getLLVMLibrary(); - InteropLibrary lib = InteropLibrary.getUncached(llvmLibrary); - if (!lib.isMemberReadable(llvmLibrary, builtin.name())) { + Object library = cApiContext.getLibrary(); + InteropLibrary lib = InteropLibrary.getUncached(library); + if (!lib.isMemberReadable(library, builtin.name())) { return false; } try { - lib.readMember(llvmLibrary, builtin.name()); + lib.readMember(library, builtin.name()); return true; } catch (UnsupportedMessageException e) { throw CompilerDirectives.shouldNotReachHere(e); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java index 75e04b30cf..193683c935 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiFunction.java @@ -184,7 +184,7 @@ public final class CApiFunction { /* - * Functions that are implemented as C code that can be executed both in native and in Sulong: + * Functions that are implemented as C code that can be executed in native */ @CApiBuiltin(name = "PyGILState_Check", ret = Int, args = {}, acquireGil = false, call = CImpl) @CApiBuiltin(name = "PyArg_Parse", ret = Int, args = {PyObject, ConstCharPtrAsTruffleString, VARARGS}, call = CImpl) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java index e8ffc7c7a4..0d6de96176 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtCommonNodes.java @@ -538,7 +538,7 @@ public abstract static class TransformExceptionFromNativeNode extends Node { /** * Checks the current exception state with respect to flag {@code indicatesError} (and * {@code strict}). - * + * * * @param inliningTarget The processing node (also needed for the source location if a * {@code SystemError} is raised). @@ -957,7 +957,6 @@ private static Object toInt64(Node inliningTarget, Object object, int signed, bo * This node converts a {@link String} object to a {@link TruffleString} or it converts a * {@code NULL} pointer to {@link PNone#NONE}. This is a very special use case and certainly * only good for reading a member of type - * {@link com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef#HPY_MEMBER_STRING} or * {@link com.oracle.graal.python.builtins.objects.cext.capi.CApiMemberAccessNodes#T_STRING}. */ @GenerateInline(false) // footprint reduction 32 -> 13, inherits non-inlineable execute() diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java index 31306784eb..dc3897753d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CExtContext.java @@ -41,7 +41,6 @@ package com.oracle.graal.python.builtins.objects.cext.common; import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_DOT; import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; @@ -84,26 +83,20 @@ public abstract class CExtContext { private final PythonContext context; - /** The LLVM bitcode library object representing 'libpython.*.so' or similar. */ - private final Object llvmLibrary; + /** The library object representing 'libpython.*.so' or similar. */ + private final Object library; - /** - * The native API implementation was loaded as native code (as opposed to bitcode via Sulong). - */ - protected final boolean useNativeBackend; - - public CExtContext(PythonContext context, Object llvmLibrary, boolean useNativeBackend) { + public CExtContext(PythonContext context, Object library) { this.context = context; - this.llvmLibrary = llvmLibrary; - this.useNativeBackend = useNativeBackend; + this.library = library; } public final PythonContext getContext() { return context; } - public final Object getLLVMLibrary() { - return llvmLibrary; + public final Object getLibrary() { + return library; } public static boolean isMethVarargs(int flags) { @@ -158,20 +151,6 @@ protected static TruffleString getBaseName(TruffleString name) { return name.substringUncached(idx + 1, len - idx - 1, TS_ENCODING, true); } - public static Object loadLLVMLibrary(Node location, PythonContext context, TruffleString name, TruffleString path) throws ImportException, IOException { - Env env = context.getEnv(); - try { - TruffleString extSuffix = context.getSoAbi(); - TruffleFile realPath = context.getPublicTruffleFileRelaxed(path, extSuffix).getCanonicalFile(); - CallTarget callTarget = env.parseInternal(Source.newBuilder(J_LLVM_LANGUAGE, realPath).build()); - return callTarget.call(); - } catch (SecurityException e) { - throw new ImportException(CExtContext.wrapJavaException(e, location), name, path, ErrorMessages.CANNOT_LOAD_M, path, e); - } catch (RuntimeException e) { - throw reportImportError(e, name, path); - } - } - @TruffleBoundary protected static PException reportImportError(RuntimeException e, TruffleString name, TruffleString path) throws ImportException { StringBuilder sb = new StringBuilder(); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBoxing.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBoxing.java deleted file mode 100644 index 1eb6543026..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBoxing.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2021, 2022, 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.builtins.objects.cext.hpy; - -public class GraalHPyBoxing { - - // see the corresponding implementation in hpy_jni.c - - /*- - * This NaN boxing mechanism puts all non-double values into the range - * [0 - NAN_BOXING_BASE[. Boxing a double value adds NAN_BOXING_BASE, and - * unboxing a double value subtracts NAN_BOXING_BASE. - * Therefore, unboxing the non-double values ends up in the range - * [fff9_0000_0000_0000 - ffff_ffff_ffff_ffff], which are non-standard - * quiet NaNs with sign bit - these don't appear in normal calculations. - * - * The range [0 - 7fff_ffff] is currently used for HPy handles, - * and the range [0001_0000_0000_0000 - 0001_0000_ffff_ffff] is currently - * used to represent primitive integers. - * - * There is space left to add other types and extend the bit size of - * handles and integers. - */ - - private static final long NAN_BOXING_BASE = 0x0007_0000_0000_0000L; - private static final long NAN_BOXING_MASK = 0xFFFF_0000_0000_0000L; - private static final long NAN_BOXING_INT = 0x0001_0000_0000_0000L; - - private static final long NAN_BOXING_INT_MASK = 0x00000000FFFFFFFFL; - private static final long NAN_BOXING_MAX_HANDLE = Integer.MAX_VALUE; - - // First N constants in the HPyContext are guaranteed to always get the same handle assigned. - // Note that 0 is HPy_NULL, so in this case we are counting from 1. - public static final int SINGLETON_HANDLE_MAX = 3; - - public static boolean isBoxedDouble(long value) { - return Long.compareUnsigned(value, NAN_BOXING_BASE) >= 0; - } - - public static boolean isBoxedHandle(long value) { - return Long.compareUnsigned(value, NAN_BOXING_MAX_HANDLE) <= 0; - } - - public static boolean isBoxedInt(long value) { - return (value & NAN_BOXING_MASK) == NAN_BOXING_INT; - } - - public static boolean isBoxedNullHandle(long value) { - return value == 0; - } - - public static int unboxHandle(long value) { - return (int) value; - } - - public static long boxHandle(int handle) { - return handle; - } - - public static double unboxDouble(long value) { - return Double.longBitsToDouble(value - NAN_BOXING_BASE); - } - - public static long boxDouble(double value) { - // assumes that value doesn't contain non-standard silent NaNs - assert Long.compareUnsigned(Double.doubleToRawLongBits(value) + NAN_BOXING_BASE, NAN_BOXING_BASE) >= 0; - - long doubleBits = Double.doubleToRawLongBits(value); - return doubleBits + NAN_BOXING_BASE; - } - - public static int unboxInt(long value) { - return (int) (value - NAN_BOXING_INT); - } - - public static long boxInt(int value) { - return (value & NAN_BOXING_INT_MASK) + NAN_BOXING_INT; - } - - public static boolean isBoxablePrimitive(Object value) { - return value instanceof Double || value instanceof Integer; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBuffer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBuffer.java deleted file mode 100644 index 28442bf8a1..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyBuffer.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2021, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.truffle.api.strings.TruffleString.Encoding.UTF_8; - -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PythonAbstractObject; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CIntArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.memoryview.CExtPyBuffer; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnknownIdentifierException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.strings.TruffleString; - -/** - * This class implements an interop object that behaves like {@code HPy_buffer} and is backed by - * {@link CExtPyBuffer}. Therefore, this object is just a view and is read-only. The idea is to use - * this view for releasing a buffer since releasing usually doesn't need all values and so we try to - * avoid to do costly conversions eagerly. - * - * The {@code HPy_buffer} structure: - * - *
    - *     typedef struct {
    - *         void *buf;
    - *         HPy obj;
    - *         HPy_ssize_t len;
    - *         HPy_ssize_t itemsize;
    - *         int readonly;
    - *         int ndim;
    - *         char *format;
    - *         HPy_ssize_t *shape;
    - *         HPy_ssize_t *strides;
    - *         HPy_ssize_t *suboffsets;
    - *         void *internal;
    - * } HPy_buffer;
    - * 
    - */ -@ExportLibrary(InteropLibrary.class) -@SuppressWarnings("static-method") -public final class GraalHPyBuffer implements TruffleObject { - private static final String J_MEMBER_BUF = "buf"; - private static final String J_MEMBER_OBJ = "obj"; - private static final String J_MEMBER_LEN = "len"; - private static final String J_MEMBER_ITEMSIZE = "itemsize"; - private static final String J_MEMBER_READONLY = "readonly"; - private static final String J_MEMBER_NDIM = "ndim"; - private static final String J_MEMBER_FORMAT = "format"; - private static final String J_MEMBER_SHAPE = "shape"; - private static final String J_MEMBER_STRIDES = "strides"; - private static final String J_MEMBER_SUBOFFSETS = "suboffsets"; - private static final String J_MEMBER_INTERNAL = "internal"; - - @CompilationFinal(dimensions = 1) private static final String[] MEMBERS = new String[]{J_MEMBER_BUF, J_MEMBER_OBJ, J_MEMBER_LEN, J_MEMBER_ITEMSIZE, J_MEMBER_READONLY, J_MEMBER_NDIM, - J_MEMBER_FORMAT, J_MEMBER_SHAPE, J_MEMBER_STRIDES, J_MEMBER_SUBOFFSETS, J_MEMBER_INTERNAL}; - - final GraalHPyContext context; - private final CExtPyBuffer buffer; - - private GraalHPyHandle ownerHandle; - Object nativePointer; - - public GraalHPyBuffer(GraalHPyContext context, CExtPyBuffer buffer) { - this.context = context; - this.buffer = buffer; - } - - @ExportMessage - boolean hasMembers() { - return true; - } - - @ExportMessage - Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { - return new PythonAbstractObject.Keys(new Object[]{J_MEMBER_BUF, J_MEMBER_OBJ, J_MEMBER_LEN, J_MEMBER_ITEMSIZE, J_MEMBER_READONLY, - J_MEMBER_NDIM, J_MEMBER_FORMAT, J_MEMBER_SHAPE, J_MEMBER_STRIDES, J_MEMBER_SUBOFFSETS, J_MEMBER_INTERNAL}); - } - - @ExportMessage - boolean isMemberReadable(String key) { - for (int i = 0; i < MEMBERS.length; i++) { - if (MEMBERS[i].equals(key)) { - return true; - } - } - return false; - } - - @ExportMessage - Object readMember(String member, - @Cached HPyAsHandleNode toNativeNode) throws UnknownIdentifierException { - switch (member) { - case J_MEMBER_BUF: - return buffer.getBuf(); - case J_MEMBER_OBJ: - if (ownerHandle == null) { - Object obj = buffer.getObj(); - ownerHandle = toNativeNode.execute(obj != null ? obj : PNone.NO_VALUE); - } - return ownerHandle; - case J_MEMBER_LEN: - return buffer.getLen(); - case J_MEMBER_ITEMSIZE: - return buffer.getItemSize(); - case J_MEMBER_READONLY: - return PInt.intValue(buffer.isReadOnly()); - case J_MEMBER_NDIM: - return buffer.getDims(); - case J_MEMBER_FORMAT: - return buffer.getFormat() != null ? new CStringWrapper(buffer.getFormat().switchEncodingUncached(UTF_8), UTF_8) : toNativeNode.execute(PNone.NO_VALUE); - case J_MEMBER_SHAPE: - return toCArray(toNativeNode, buffer.getShape()); - case J_MEMBER_STRIDES: - return toCArray(toNativeNode, buffer.getStrides()); - case J_MEMBER_SUBOFFSETS: - return toCArray(toNativeNode, buffer.getSuboffsets()); - case J_MEMBER_INTERNAL: - return buffer.getInternal(); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw UnknownIdentifierException.create(member); - } - - private static Object toCArray(HPyAsHandleNode toNativeNode, int[] arr) { - if (arr != null) { - return new CIntArrayWrapper(arr); - } - return toNativeNode.execute(PNone.NO_VALUE); - } - - @ExportMessage - boolean isPointer() { - return nativePointer != null; - } - - @ExportMessage - long asPointer( - @CachedLibrary(limit = "1") InteropLibrary lib) throws UnsupportedMessageException { - return PythonUtils.coerceToLong(nativePointer, lib); - } - - @ExportMessage - void toNative( - @Cached(parameters = "this.context") GraalHPyCAccess.AllocateNode allocateNode, - @Cached(parameters = "this.context") GraalHPyCAccess.WritePointerNode writePointerNode, - @Cached(parameters = "this.context") GraalHPyCAccess.WriteHPyNode writeHPyNode, - @Cached(parameters = "this.context") GraalHPyCAccess.WriteSizeTNode writeSizeTNode, - @Cached(parameters = "this.context") GraalHPyCAccess.WriteI32Node writeI32Node, - @Cached TruffleString.AsNativeNode asNativeNode, - @Cached TruffleString.GetInternalNativePointerNode getInternalNativePointerNode, - @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - if (nativePointer == null) { - Object nativePointer = allocateNode.malloc(context, HPyContextSignatureType.HPy_buffer); - TruffleString formatUtf8 = switchEncodingNode.execute(buffer.getFormat(), UTF_8); - TruffleString formatNative = asNativeNode.execute(formatUtf8, byteSize -> context.nativeToInteropPointer(allocateNode.malloc(context, byteSize)), UTF_8, true, true); - Object formatPtr = getInternalNativePointerNode.execute(formatNative, UTF_8); - - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__buf, buffer.getBuf()); - writeHPyNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__obj, buffer.getObj()); - writeSizeTNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__len, buffer.getLen()); - writeSizeTNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__itemsize, buffer.getItemSize()); - writeI32Node.write(context, nativePointer, GraalHPyCField.HPy_buffer__readonly, PInt.intValue(buffer.isReadOnly())); - writeI32Node.write(context, nativePointer, GraalHPyCField.HPy_buffer__ndim, buffer.getDims()); - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__format, formatPtr); - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__shape, intArrayToNativeInt64(context, buffer.getShape(), allocateNode, writeSizeTNode)); - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__strides, intArrayToNativeInt64(context, buffer.getStrides(), allocateNode, writeSizeTNode)); - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__suboffsets, intArrayToNativeInt64(context, buffer.getSuboffsets(), allocateNode, writeSizeTNode)); - writePointerNode.write(context, nativePointer, GraalHPyCField.HPy_buffer__internal, buffer.getInternal()); - this.nativePointer = nativePointer; - } - } - - private static Object intArrayToNativeInt64(GraalHPyContext ctx, int[] data, GraalHPyCAccess.AllocateNode allocateNode, GraalHPyCAccess.WriteSizeTNode writeSizeTNode) { - if (data != null) { - long elemSize = ctx.getCTypeSize(HPyContextSignatureType.HPy_ssize_t); - Object ptr = allocateNode.calloc(ctx, data.length, elemSize); - for (int i = 0; i < data.length; i++) { - writeSizeTNode.execute(ctx, ptr, i * elemSize, data[i]); - } - return ptr; - } - return ctx.getNativeNull(); - } - - void free(GraalHPyContext ctx, GraalHPyCAccess.FreeNode freeNode, GraalHPyCAccess.ReadPointerNode readPointerNode, GraalHPyCAccess.ReadHPyNode readHPyNode) { - if (ownerHandle != null) { - ownerHandle.closeAndInvalidate(context); - } - if (nativePointer != null) { - Object owner = readHPyNode.readAndClose(ctx, nativePointer, GraalHPyCField.HPy_buffer__obj); - assert owner == buffer.getObj(); - Object format = readPointerNode.read(ctx, nativePointer, GraalHPyCField.HPy_buffer__format); - Object shape = readPointerNode.read(ctx, nativePointer, GraalHPyCField.HPy_buffer__shape); - Object suboffsets = readPointerNode.read(ctx, nativePointer, GraalHPyCField.HPy_buffer__suboffsets); - freeNode.free(ctx, format); - freeNode.free(ctx, shape); - freeNode.free(ctx, suboffsets); - freeNode.free(ctx, nativePointer); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCAccess.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCAccess.java deleted file mode 100644 index 5f38920088..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCAccess.java +++ /dev/null @@ -1,726 +0,0 @@ -/* - * Copyright (c) 2023, 2023, 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.builtins.objects.cext.hpy; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GraalHPyHandleReference; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.nodes.Node; - -public abstract class GraalHPyCAccess { - - private GraalHPyCAccess() { - } - - private abstract static class CStructAccessNode extends Node { - - abstract boolean accepts(HPyContextSignatureType type); - - final boolean accepts(GraalHPyCField field) { - return accepts(field.getType()); - } - - /** - * Use this method to compute the address of a struct field where the struct is one element - * in an array. For example: - * - *
    -         *     HPyType_SpecParam params[] = {
    -         *         {HPyType_SpecParam_Base, ctx->h_LongType},
    -         *         {HPyType_SpecParam_Base, ctx->h_UnicodeType},
    -         *         {0}
    -         *     }
    -         * 
    - * - * Assume you want to read the field {@code object} (the second field of type {@code HPy}) - * of the second array element. The address is then computed by: - * - *
    -         *     long arrElemOffset = getElementPtr(1, GraalHPyCStruct.HPyType_SpecParam.getSize(), GraalHPyCField.HPyType_SpecParam_object)
    -         * 
    - * - * You may later read the value using {@code ReadHPyNode.execute(ctx, base, arrElemOffset)}. - * - * @param idx Index of the element (e.g. a struct type). - * @param elementSize Size of each element. - * @param field Field of the element (e.g. a struct field). - */ - public static long getElementPtr(GraalHPyContext ctx, long idx, long elementSize, GraalHPyCField field) { - return idx * elementSize + ctx.getCFieldOffset(field); - } - - public static long getElementPtr(GraalHPyContext ctx, long idx, HPyContextSignatureType elementType, GraalHPyCField field) { - return idx * ctx.getCTypeSize(elementType) + ctx.getCFieldOffset(field); - } - - } - - public abstract static class AllocateNode extends Node { - - protected abstract Object execute(GraalHPyContext ctx, long size, boolean zero); - - public final Object malloc(GraalHPyContext ctx, long size) { - return execute(ctx, size, false); - } - - public final Object malloc(GraalHPyContext ctx, HPyContextSignatureType ctype) { - return execute(ctx, ctx.getCTypeSize(ctype), false); - } - - public final Object calloc(GraalHPyContext ctx, long count, long size) { - return execute(ctx, count * size, true); - } - - @NeverDefault - public static AllocateNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createAllocateNode(); - } - - public static AllocateNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedAllocateNode(); - } - } - - public abstract static class FreeNode extends Node { - - protected abstract void execute(GraalHPyContext ctx, Object pointer); - - public final void free(GraalHPyContext ctx, Object pointer) { - execute(ctx, pointer); - } - - @NeverDefault - public static FreeNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createFreeNode(); - } - - public static FreeNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedFreeNode(); - } - } - - public abstract static class BulkFreeHandleReferencesNode extends Node { - - protected abstract void execute(GraalHPyContext ctx, GraalHPyHandleReference[] references); - - @NeverDefault - public static BulkFreeHandleReferencesNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createBulkFreeHandleReferencesNode(); - } - } - - public abstract static class IsNullNode extends Node { - - protected abstract boolean execute(GraalHPyContext ctx, Object pointer); - - public static boolean executeUncached(GraalHPyContext ctx, Object pointer) { - return IsNullNode.getUncached(ctx).execute(ctx, pointer); - } - - @NeverDefault - public static IsNullNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createIsNullNode(); - } - - public static IsNullNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedIsNullNode(); - } - } - - public abstract static class GetElementPtrNode extends CStructAccessNode { - - public abstract Object execute(GraalHPyContext ctx, Object pointer, long offset); - - public final Object getElementPtr(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return true; - } - - @NeverDefault - public static GetElementPtrNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createGetElementPtrNode(); - } - - public static GetElementPtrNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedGetElementPtrNode(); - } - } - - public abstract static class ReadGenericNode extends CStructAccessNode { - - protected abstract Object execute(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType size); - - protected abstract int executeInt(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType size); - - protected abstract long executeLong(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType size); - - @Override - boolean accepts(HPyContextSignatureType type) { - return true; - } - - public final Object read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - return execute(ctx, pointer, ctx.getCFieldOffset(field), field.getType()); - } - - public final int readInt(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - return executeInt(ctx, pointer, ctx.getCFieldOffset(field), field.getType()); - } - - public final long readLong(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - return executeLong(ctx, pointer, ctx.getCFieldOffset(field), field.getType()); - } - - @NeverDefault - public static ReadGenericNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadGenericNode(); - } - - public static ReadGenericNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadGenericNode(); - } - } - - public abstract static class ReadI8ArrayNode extends CStructAccessNode { - - protected abstract byte[] execute(GraalHPyContext ctx, Object pointer, long offset, long n); - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return false; - } - - @NeverDefault - public static ReadI8ArrayNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadI8ArrayNode(); - } - - public static ReadI8ArrayNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadI8ArrayNode(); - } - } - - public abstract static class ReadHPyNode extends CStructAccessNode { - - protected abstract Object execute(GraalHPyContext ctx, Object pointer, long offset, boolean close); - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return false; - } - - public final Object read(GraalHPyContext ctx, Object pointer, long offset) { - return execute(ctx, pointer, offset, false); - } - - /** - * Read an {@code HPy} handle and return the referred object. - */ - public final Object read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field), false); - } - - /** - * Read and close an {@code HPy} handle and return the referred object. This method is - * mostly useful if some C function returns a handle via an out param. For example, - * any {@code HPyFunc_getbufferproc} function returns a handle in the {@code HPy_buffer} - * struct. - */ - public final Object readAndClose(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field), true); - } - - @NeverDefault - public static ReadHPyNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadHPyNode(); - } - - public static ReadHPyNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadHPyNode(); - } - } - - public abstract static class ReadHPyFieldNode extends CStructAccessNode { - - protected abstract Object execute(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, boolean close); - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return false; - } - - public final Object read(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset) { - return execute(ctx, owner, pointer, offset, false); - } - - /** - * Read an {@code HPy} handle and return the referred object. - */ - public final Object read(GraalHPyContext ctx, PythonObject owner, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, owner, pointer, ctx.getCFieldOffset(field), false); - } - - @NeverDefault - public static ReadHPyFieldNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadHPyFieldNode(); - } - - public static ReadHPyFieldNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadFieldHPyNode(); - } - } - - public abstract static class ReadHPyArrayNode extends CStructAccessNode { - - protected abstract Object[] execute(GraalHPyContext ctx, Object pointer, long offset, long n); - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return false; - } - - @NeverDefault - public static ReadHPyArrayNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadHPyArrayNode(); - } - - public static ReadHPyArrayNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadHPyArrayNode(); - } - } - - public abstract static class ReadI32Node extends CStructAccessNode { - - protected abstract int execute(GraalHPyContext ctx, Object pointer, long offset); - - public final int read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - public final long readUnsigned(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - assert field.getType() == HPyContextSignatureType.Uint32_t; - return execute(ctx, pointer, ctx.getCFieldOffset(field)) & 0xFFFFFFFFL; - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == int.class; - } - - public final int readOffset(GraalHPyContext ctx, Object pointer, long offset) { - return execute(ctx, pointer, offset); - } - - public final int readArrayElement(GraalHPyContext ctx, Object pointer, long element) { - return execute(ctx, pointer, element * Integer.BYTES); - } - - @NeverDefault - public static ReadI32Node create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadI32Node(); - } - - public static ReadI32Node getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadI32Node(); - } - } - - public abstract static class ReadI64Node extends CStructAccessNode { - - protected abstract long execute(GraalHPyContext ctx, Object pointer, long offset); - - public final long read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == long.class; - } - - @NeverDefault - public static ReadI64Node create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadI64Node(); - } - - public static ReadI64Node getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadI64Node(); - } - } - - /** - * Note that this node returns a double, not a float, even though it reads only 32 bits. - */ - public abstract static class ReadFloatNode extends CStructAccessNode { - - protected abstract double execute(GraalHPyContext ctx, Object pointer, long offset); - - public final double read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == double.class; - } - - public final double readArrayElement(GraalHPyContext ctx, Object pointer, int element) { - return execute(ctx, pointer, (long) element * Float.BYTES); - } - - @NeverDefault - public static ReadFloatNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadFloatNode(); - } - - public static ReadFloatNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadFloatNode(); - } - } - - public abstract static class ReadDoubleNode extends CStructAccessNode { - - protected abstract double execute(GraalHPyContext ctx, Object pointer, long offset); - - public final double read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == double.class; - } - - public final double readArrayElement(GraalHPyContext ctx, Object pointer, int element) { - return execute(ctx, pointer, (long) element * Double.BYTES); - } - - @NeverDefault - public static ReadDoubleNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadDoubleNode(); - } - - public static ReadDoubleNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadDoubleNode(); - } - } - - public abstract static class ReadPointerNode extends CStructAccessNode { - - protected abstract Object execute(GraalHPyContext ctx, Object pointer, long offset); - - public final Object read(GraalHPyContext ctx, Object pointer, GraalHPyCField field) { - // GR-50245 - // assert accepts(field); - return execute(ctx, pointer, ctx.getCFieldOffset(field)); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return "POINTER".equals(desc.nfiType); - } - - public final Object readArrayElement(GraalHPyContext ctx, Object pointer, long element) { - return execute(ctx, pointer, element * ctx.getCTypeSize(HPyContextSignatureType.VoidPtr)); - } - - @NeverDefault - public static ReadPointerNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createReadPointerNode(); - } - - public static ReadPointerNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedReadPointerNode(); - } - } - - public abstract static class WriteDoubleNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, double value); - - public final void write(GraalHPyContext ctx, Object pointer, GraalHPyCField field, double value) { - // GR-50245 - // assert accepts(field); - execute(ctx, pointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, Object pointer, double value) { - execute(ctx, pointer, 0, value); - } - - public final void writeArrayElement(GraalHPyContext ctx, Object pointer, long element, double value) { - execute(ctx, pointer, element * Double.BYTES, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc == HPyContextSignatureType.CDouble; - } - - @NeverDefault - public static WriteDoubleNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteDoubleNode(); - } - - public static WriteDoubleNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteDoubleNode(); - } - } - - public abstract static class WriteI32Node extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, int value); - - public final void write(GraalHPyContext ctx, Object pointer, GraalHPyCField field, int value) { - // GR-50245 - // assert accepts(field); - execute(ctx, pointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, Object pointer, int value) { - execute(ctx, pointer, 0, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == int.class; - } - - public final void writeArrayElement(GraalHPyContext ctx, Object pointer, long element, int value) { - execute(ctx, pointer, element * Integer.BYTES, value); - } - - @NeverDefault - public static WriteI32Node create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteI32Node(); - } - - public static WriteI32Node getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteI32Node(); - } - } - - public abstract static class WriteI64Node extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, long value); - - public final void write(GraalHPyContext ctx, Object pointer, GraalHPyCField field, long value) { - // GR-50245 - // assert accepts(field); - execute(ctx, pointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, Object pointer, long value) { - execute(ctx, pointer, 0, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc.jniType == long.class; - } - - @NeverDefault - public static WriteI64Node create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteI64Node(); - } - - public static WriteI64Node getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteI64Node(); - } - } - - public abstract static class WriteGenericNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type, Object value); - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type, long value); - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return true; - } - - @NeverDefault - public static WriteGenericNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteGenericNode(); - } - - public static WriteGenericNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteGenericNode(); - } - } - - public abstract static class WriteHPyNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object pointer, long offset, Object value); - - public final void write(GraalHPyContext ctx, Object pointer, GraalHPyCField field, Object value) { - // GR-50245 - // assert accepts(field); - execute(ctx, pointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, Object pointer, Object value) { - execute(ctx, pointer, 0, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc == HPyContextSignatureType.HPy; - } - - @NeverDefault - public static WriteHPyNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteHPyNode(); - } - - public static WriteHPyNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteHPyNode(); - } - } - - public abstract static class WriteHPyFieldNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, Object value); - - public final void write(GraalHPyContext ctx, PythonObject owner, Object pointer, GraalHPyCField field, Object value) { - // GR-50245 - // assert accepts(field); - execute(ctx, owner, pointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, PythonObject owner, Object pointer, Object value) { - execute(ctx, owner, pointer, 0, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc == HPyContextSignatureType.HPyField; - } - - @NeverDefault - public static WriteHPyFieldNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteHPyFieldNode(); - } - - public static WriteHPyFieldNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteHPyFieldNode(); - } - } - - public abstract static class WritePointerNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object basePointer, long offset, Object valuePointer); - - public final void write(GraalHPyContext ctx, Object basePointer, GraalHPyCField field, Object valuePointer) { - // GR-50245 - // assert accepts(field); - execute(ctx, basePointer, ctx.getCFieldOffset(field), valuePointer); - } - - public final void write(GraalHPyContext ctx, Object basePointer, Object valuePointer) { - execute(ctx, basePointer, 0, valuePointer); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return "POINTER".equals(desc.nfiType); - } - - @NeverDefault - public static WritePointerNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWritePointerNode(); - } - - public static WritePointerNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWritePointerNode(); - } - } - - public abstract static class WriteSizeTNode extends CStructAccessNode { - - protected abstract void execute(GraalHPyContext ctx, Object basePointer, long offset, long value); - - public final void write(GraalHPyContext ctx, Object basePointer, GraalHPyCField field, long value) { - // GR-50245 - // assert accepts(field); - execute(ctx, basePointer, ctx.getCFieldOffset(field), value); - } - - public final void write(GraalHPyContext ctx, Object basePointer, long value) { - execute(ctx, basePointer, 0, value); - } - - @Override - public final boolean accepts(HPyContextSignatureType desc) { - return desc == HPyContextSignatureType.Size_t || desc == HPyContextSignatureType.HPy_ssize_t; - } - - @NeverDefault - public static WriteSizeTNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createWriteSizeTNode(); - } - - public static WriteSizeTNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedWriteSizeTNode(); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCField.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCField.java deleted file mode 100644 index ca7862c321..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyCField.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2023, 2023, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.CharPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.ConstCharPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Cpy_PyObjectPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyFunc_Signature; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPySlot_Slot; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyType_BuiltinShape; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_ssize_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int32_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.PyType_SlotPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Uint32_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.VoidPtr; - -public enum GraalHPyCField { - HPyType_SpecParam__kind(Int32_t), - HPyType_SpecParam__object(HPy), - HPyType_Spec__name(ConstCharPtr), - HPyType_Spec__basicsize(Int32_t), - HPyType_Spec__itemsize(Int32_t), - HPyType_Spec__flags(Uint32_t), - HPyType_Spec__builtin_shape(HPyType_BuiltinShape), - HPyType_Spec__legacy_slots(PyType_SlotPtr), - HPyType_Spec__defines(VoidPtr), - HPyType_Spec__doc(ConstCharPtr), - HPyDef__kind(Int32_t), - HPyDef__meth__name(ConstCharPtr), - HPyDef__meth__impl(VoidPtr), - HPyDef__meth__signature(HPyFunc_Signature), - HPyDef__meth__doc(ConstCharPtr), - HPyDef__member__name(ConstCharPtr), - HPyDef__member__type(Int), - HPyDef__member__offset(HPy_ssize_t), - HPyDef__member__readonly(Int), - HPyDef__member__doc(ConstCharPtr), - HPyDef__getset__name(ConstCharPtr), - HPyDef__getset__getter_impl(VoidPtr), - HPyDef__getset__setter_impl(VoidPtr), - HPyDef__getset__doc(ConstCharPtr), - HPyDef__getset__closure(VoidPtr), - HPyDef__slot__slot(HPySlot_Slot), - HPyDef__slot__impl(VoidPtr), - PyType_Slot__slot(Int), - PyType_Slot__pfunc(VoidPtr), - HPyCapsule_Destructor__cpy_trampoline(VoidPtr), - HPyCapsule_Destructor__impl(VoidPtr), - HPyCallFunction__impl(VoidPtr), - HPyModuleDef__doc(ConstCharPtr), - HPyModuleDef__size(HPy_ssize_t), - HPyModuleDef__legacy_methods(Cpy_PyObjectPtr), - HPyModuleDef__defines(VoidPtr), - HPyModuleDef__globals(VoidPtr), - PyGetSetDef__name(ConstCharPtr), - PyGetSetDef__get(VoidPtr), - PyGetSetDef__set(VoidPtr), - PyGetSetDef__doc(ConstCharPtr), - PyGetSetDef__closure(VoidPtr), - PyMemberDef__name(ConstCharPtr), - PyMemberDef__type(Int), - PyMemberDef__offset(HPy_ssize_t), - PyMemberDef__flags(Int), - PyMemberDef__doc(ConstCharPtr), - HPy_buffer__buf(VoidPtr), - HPy_buffer__obj(HPy), - HPy_buffer__len(HPy_ssize_t), - HPy_buffer__itemsize(HPy_ssize_t), - HPy_buffer__readonly(Int), - HPy_buffer__ndim(Int), - HPy_buffer__format(CharPtr), - HPy_buffer__shape(HPy_ssize_t), - HPy_buffer__strides(HPy_ssize_t), - HPy_buffer__suboffsets(HPy_ssize_t), - HPy_buffer__internal(VoidPtr); - - private final HPyContextSignatureType type; - - GraalHPyCField(HPyContextSignatureType type) { - this.type = type; - } - - public HPyContextSignatureType getType() { - return type; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java deleted file mode 100644 index 0c3aea8ee8..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java +++ /dev/null @@ -1,1217 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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. - */ -// skip GIL -package com.oracle.graal.python.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.UNSAFE; -import static com.oracle.graal.python.util.PythonUtils.EMPTY_TRUFFLESTRING_ARRAY; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsArray; - -import java.io.IOException; -import java.lang.invoke.VarHandle; -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import java.util.logging.Level; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; -import com.oracle.graal.python.builtins.objects.cext.common.CExtContext; -import com.oracle.graal.python.builtins.objects.cext.common.HandleStack; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyGetNativeSpacePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.GraalHPyModuleCreateNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.GraalHPyModuleExecNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNIContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMContext; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis; -import com.oracle.graal.python.builtins.objects.frame.PFrame; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRootNode; -import com.oracle.graal.python.nodes.call.CallTargetInvokeNode; -import com.oracle.graal.python.nodes.call.GenericInvokeNode; -import com.oracle.graal.python.runtime.AsyncHandler; -import com.oracle.graal.python.runtime.GilNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.PythonOptions.HPyBackendMode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonSystemThreadTask; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.CompilerDirectives.ValueType; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLanguage.Env; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.TruffleSafepoint; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.RootNode; -import com.oracle.truffle.api.profiles.LoopConditionProfile; -import com.oracle.truffle.api.strings.TruffleString; - -public final class GraalHPyContext extends CExtContext implements TruffleObject { - - // {{start autogen}} - public static final int HPY_ABI_VERSION = 0; - public static final int HPY_ABI_VERSION_MINOR = 0; - public static final String HPY_ABI_TAG = "hpy0"; - // {{end autogen}} - - private static final String J_HPY_INIT = "HPyInit_"; - private static final String J_HPY_MAJOR_VER_FUN = "get_required_hpy_major_version_"; - private static final String J_HPY_MINOR_VER_FUN = "get_required_hpy_minor_version_"; - private static final String LOGGER_HPY_NAME = "hpy"; - private static final String HPY_EXT = ".hpy"; - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyContext.class); - - public static final long SIZEOF_LONG = java.lang.Long.BYTES; - private static final long NATIVE_ARGUMENT_STACK_SIZE = 1 << 15; // 32 kB stack size - - // "blah.hpy123[-graalpy231-310].so" - private static final Pattern SO_NAME_PATTERN = Pattern.compile(".*" + Pattern.quote(HPY_EXT) + "(\\d+)(?:-[\\w-]+)?\\.so$"); - - public static TruffleLogger getLogger(Class clazz) { - return PythonLanguage.getLogger(LOGGER_HPY_NAME + "." + clazz.getSimpleName()); - } - - @TruffleBoundary - public static GraalHPyContext ensureHPyWasLoaded(Node node, PythonContext context, TruffleString name, TruffleString path) throws IOException, ApiInitException, ImportException { - if (!context.hasHPyContext()) { - /* - * TODO(fa): Currently, you can't have the HPy context without the C API context. This - * should eventually be possible but requires some refactoring. - */ - CApiContext.ensureCapiWasLoaded(node, context, name, path); - - try { - GraalHPyContext hPyContext = context.createHPyContext(GraalHPyLLVMContext.loadLLVMLibrary(context)); - assert hPyContext == context.getHPyContext(); - return hPyContext; - } catch (ApiInitException e) { - throw e; - } catch (Exception e) { - // we don't expect any other exception - throw CompilerDirectives.shouldNotReachHere(e); - } - } - return context.getHPyContext(); - } - - /** - * This method loads an HPy extension module and will initialize the corresponding native - * contexts if necessary. - * - * @param location The node that's requesting this operation. This is required for reporting - * correct source code location in case exceptions occur. - * @param context The Python context object. - * @param name The name of the module to load (also just required for creating appropriate error - * messages). - * @param path The path of the C extension module to load (usually something ending with - * {@code .so} or {@code .pyd} or similar). - * @param mode The mode (e.g. debug or trace) to use when loading the module. - * @return Pointer to the HPy module definition struct. - * @throws IOException If the specified file cannot be loaded. - * @throws ApiInitException If the corresponding native context could not be initialized. - * @throws ImportException If an exception occurred during C extension initialization. - */ - @TruffleBoundary - public static Object loadHPyModule(Node location, PythonContext context, TruffleString name, TruffleString path, Object spec, HPyMode mode) throws IOException, ApiInitException, ImportException { - - /* - * Unfortunately, we need eagerly initialize the HPy context because the ctors of the - * extension may already require some symbols defined in the HPy API or C API. - */ - GraalHPyContext hpyUniversalContext = GraalHPyContext.ensureHPyWasLoaded(location, context, name, path); - GraalHPyNativeContext backend = hpyUniversalContext.backend; - Object llvmLibrary = backend.loadExtensionLibrary(location, context, name, path); - String basename = getBaseName(name).toJavaStringUncached(); - String hpyInitFuncName = J_HPY_INIT + basename; - - // get_required_hpy_major_version_ - String hpyMajorVersionFuncName = J_HPY_MAJOR_VER_FUN + basename; - - // get_required_hpy_minor_version_ - String hpyMinorVersionFuncName = J_HPY_MINOR_VER_FUN + basename; - - HPyABIVersion abiVersion; - try { - abiVersion = backend.getHPyABIVersion(llvmLibrary, hpyMajorVersionFuncName, hpyMinorVersionFuncName); - } catch (Exception e) { - throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ERROR_LOADING_EXT_MODULE, path, hpyMajorVersionFuncName, hpyMinorVersionFuncName, - e.getMessage()); - } - - /* - * For now, we have only one major version but in the future at this point we would decide - * which HPyContext to create. - */ - if (abiVersion.major != HPY_ABI_VERSION || abiVersion.minor > HPY_ABI_VERSION_MINOR) { - throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_VERSION_ERROR, name, abiVersion.major, abiVersion.minor, HPY_ABI_VERSION, - HPY_ABI_VERSION_MINOR); - } - - // Sanity check of the tag in the shared object filename - validateABITag(location, basename, path.toJavaStringUncached(), abiVersion); - - HPyMode saved = hpyUniversalContext.currentMode; - hpyUniversalContext.currentMode = mode; - try { - Object hpyModuleDefPtr = backend.initHPyModule(llvmLibrary, hpyInitFuncName, name, path, mode); - // HPy only supports multi-phase extension module initialization. - assert !(hpyModuleDefPtr instanceof PythonModule); - if (InteropLibrary.getUncached().isNull(hpyModuleDefPtr)) { - throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.ERROR_LOADING_HPY_EXT_S_S, path, name); - } - - Object module = GraalHPyModuleCreateNodeGen.getUncached().execute(context.getHPyContext(), name, spec, hpyModuleDefPtr); - if (module instanceof PythonModule pythonModule) { - GraalHPyModuleExecNodeGen.getUncached().execute(location, context.getHPyContext(), pythonModule); - } - return module; - } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { - throw new ImportException(CExtContext.wrapJavaException(e, location), name, path, ErrorMessages.CANNOT_INITIALIZE_WITH, path, basename, ""); - } finally { - hpyUniversalContext.currentMode = saved; - } - } - - private static void validateABITag(Node location, String shortname, String soname, HPyABIVersion abiVersion) { - // assumes format: "blah.hpy123[-310].so" - Matcher matcher = SO_NAME_PATTERN.matcher(soname); - if (matcher.matches()) { - String abiTagVersion = matcher.group(1); - int abiTag = Integer.parseInt(abiTagVersion); - if (abiTag != abiVersion.major) { - throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_ABI_TAG_MISMATCH, shortname, soname, abiTag, abiVersion.major, abiVersion.minor); - } - // major version fits -> validation successful - return; - } - throw PRaiseNode.raiseStatic(location, PythonBuiltinClassType.RuntimeError, ErrorMessages.HPY_NO_ABI_TAG, shortname, soname, abiVersion.major, abiVersion.minor); - } - - public Object createArgumentsArray(Object[] args) { - return backend.createArgumentsArray(args); - } - - public void freeArgumentsArray(Object argsArray) { - backend.freeArgumentsArray(argsArray); - } - - public long createNativeArguments(Object[] delegate) { - if (nativeArgumentsStack == 0) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we use 'getContext().getUnsafe()' because this will check if native access is allowed - nativeArgumentsStack = getContext().getUnsafe().allocateMemory(NATIVE_ARGUMENT_STACK_SIZE); - nativeArgumentStackTop = nativeArgumentsStack + NATIVE_ARGUMENT_STACK_SIZE; - } - long arraySize = delegate.length * SIZEOF_LONG; - if (nativeArgumentsStack + arraySize > nativeArgumentStackTop) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - String msg = String.format("overflow on native argument stack (requested size: %d bytes)", arraySize); - LOGGER.severe(msg); - throw new InternalError(msg); - } - long arrayPtr = nativeArgumentsStack; - nativeArgumentsStack += arraySize; - - for (int i = 0; i < delegate.length; i++) { - Object element = delegate[i]; - UNSAFE.putLong(arrayPtr + i * SIZEOF_LONG, pythonObjectAsBits(element)); - } - return arrayPtr; - } - - public void freeNativeArgumentsArray(int nargs) { - freeNativeArgumentsUntil(nativeArgumentsStack - nargs * SIZEOF_LONG); - } - - public void freeNativeArgumentsUntil(long basePtr) { - assert basePtr <= nativeArgumentsStack; - for (long cur = basePtr; cur < nativeArgumentsStack; cur += SIZEOF_LONG) { - long h = UNSAFE.getLong(cur); - if (GraalHPyBoxing.isBoxedHandle(h)) { - releaseHPyHandleForObject(GraalHPyBoxing.unboxHandle(h)); - } - } - nativeArgumentsStack = basePtr; - } - - @ValueType - public record HPyABIVersion(int major, int minor) { - } - - public interface HPyUpcall { - String getName(); - } - - /** - * Enum of C types used in the HPy API. These type names need to stay in sync with the - * declarations in 'hpytypes.h'. - */ - public enum LLVMType { - HPyFunc_noargs, - HPyFunc_o, - HPyFunc_varargs, - HPyFunc_keywords, - HPyFunc_unaryfunc, - HPyFunc_binaryfunc, - HPyFunc_ternaryfunc, - HPyFunc_inquiry, - HPyFunc_lenfunc, - HPyFunc_ssizeargfunc, - HPyFunc_ssizessizeargfunc, - HPyFunc_ssizeobjargproc, - HPyFunc_ssizessizeobjargproc, - HPyFunc_objobjargproc, - HPyFunc_freefunc, - HPyFunc_getattrfunc, - HPyFunc_getattrofunc, - HPyFunc_setattrfunc, - HPyFunc_setattrofunc, - HPyFunc_reprfunc, - HPyFunc_hashfunc, - HPyFunc_richcmpfunc, - HPyFunc_getiterfunc, - HPyFunc_iternextfunc, - HPyFunc_descrgetfunc, - HPyFunc_descrsetfunc, - HPyFunc_initproc, - HPyFunc_getter, - HPyFunc_setter, - HPyFunc_objobjproc, - HPyFunc_traverseproc, - HPyFunc_destructor, - HPyFunc_getbufferproc, - HPyFunc_releasebufferproc, - HPyFunc_destroyfunc, - HPyModule_init, - HPyModule_create - } - - public static final int IMMUTABLE_HANDLE_COUNT = 256; - - private Object[] hpyHandleTable; - private int nextHandle = 1; - - private Object[] hpyGlobalsTable = new Object[]{GraalHPyHandle.NULL_HANDLE_DELEGATE}; - private final HandleStack freeStack = new HandleStack(16); - private final GraalHPyNativeContext backend; - - /** - * This field mirrors value of {@link PythonOptions#HPyEnableJNIFastPaths}. We store it in this - * final field because the value is also used in non-PE code paths. - */ - final boolean useNativeFastPaths; - - /** - * This is set to the appropriate mode if an HPy extension is initialized (i.e. - * {@code HPyInit_*} is called) in, e.g., debug mode. The value is then used to create the right - * closures for down calls during module ({@code HPyModule_Create}) and type creation - * ({@code HPyType_FromSpec}). We need this because the debug context is just a wrapper around - * the universal context, so the module and type creation will look as normal. For reference on - * how other implementations do it: - *

    - * CPython stores the HPy context into global C variable {@code _ctx_for_trampolines} defined by - * {@code HPy_MODINIT}. This variable belongs to the HPy extension and the context is loaded - * from it when calling HPy extension functions. - *

    - *

    - * PyPy has a different structure but basically also uses a global state (see file - * {@code interp_hpy.py}). When initializing the module, the appropriate handle manager - * is used. The manager then decides which trampolines are used to call HPy extensions and the - * trampolines pick the appropriate context. - *

    - */ - private HPyMode currentMode = HPyMode.MODE_UNIVERSAL; - - /** - * Few well known Python objects that are also HPyContext constants are guaranteed to always get - * the same handle. - */ - public static final int SINGLETON_HANDLE_NONE = 1; - public static final int SINGLETON_HANDLE_NOT_IMPLEMENTED = 2; - public static final int SINGLETON_HANDLE_ELIPSIS = 3; - - /** - * The global reference queue is a list consisting of {@link GraalHPyHandleReference} objects. - * It is used to keep those objects (which are weak refs) alive until they are enqueued in the - * corresponding reference queue. The list instance referenced by this variable is exclusively - * owned by the main thread (i.e. the main thread may operate on the list without - * synchronization). The HPy reference cleaner thread (see - * {@link GraalHPyReferenceCleanerRunnable}) will consume this instance using an atomic - * {@code getAndSet} operation. At this point, the ownership is transferred to the cleaner - * thread. - */ - public final AtomicReference references = new AtomicReference<>(null); - private ReferenceQueue nativeSpaceReferenceQueue; - @CompilationFinal private RootCallTarget referenceCleanerCallTarget; - - private long nativeSpacePointers; - - private long nativeArgumentsStack = 0; - private long nativeArgumentStackTop = 0; - - private final ScheduledExecutorService scheduler; - - public GraalHPyContext(PythonContext context, Object hpyLibrary) throws ApiInitException { - super(context, hpyLibrary, false /* TODO: provide proper value */); - CompilerAsserts.neverPartOfCompilation(); - PythonLanguage language = context.getLanguage(); - int traceUpcallsInterval = language.getEngineOption(PythonOptions.HPyTraceUpcalls); - Boolean shouldUseNativeFastPaths = language.getEngineOption(PythonOptions.HPyEnableJNIFastPaths); - HPyBackendMode backendMode = language.getEngineOption(PythonOptions.HPyBackend); - - nextHandle = GraalHPyBoxing.SINGLETON_HANDLE_MAX + 1; - hpyHandleTable = new Object[IMMUTABLE_HANDLE_COUNT * 2]; - - // initialize singleton handles - hpyHandleTable[0] = GraalHPyHandle.NULL_HANDLE_DELEGATE; - hpyHandleTable[SINGLETON_HANDLE_NONE] = PNone.NONE; - hpyHandleTable[SINGLETON_HANDLE_NOT_IMPLEMENTED] = PNotImplemented.NOT_IMPLEMENTED; - hpyHandleTable[SINGLETON_HANDLE_ELIPSIS] = PEllipsis.INSTANCE; - - LOGGER.config("Using HPy backend:" + backendMode.name()); - if (backendMode == HPyBackendMode.JNI) { - if (!PythonImageBuildOptions.WITHOUT_JNI) { - this.useNativeFastPaths = shouldUseNativeFastPaths; - backend = new GraalHPyJNIContext(this, traceUpcallsInterval > 0); - } else { - throw new ApiInitException(ErrorMessages.HPY_CANNOT_USE_JNI_BACKEND); - } - } else if (backendMode == HPyBackendMode.NFI) { - throw new ApiInitException(ErrorMessages.HPY_NFI_NOT_YET_IMPLEMENTED); - } else if (backendMode == HPyBackendMode.LLVM) { - // TODO(fa): we currently don't use native fast paths with the LLVM backend - this.useNativeFastPaths = false; - backend = new GraalHPyLLVMContext(this, traceUpcallsInterval > 0); - } else { - throw new ApiInitException(ErrorMessages.HPY_UNKNOWN_BACKEND, TruffleString.fromJavaStringUncached(backendMode.name(), TS_ENCODING)); - } - - backend.initNativeContext(); - - // createMembers already assigns numeric handles to "singletons" - nextHandle = IMMUTABLE_HANDLE_COUNT; - - assert getHPyHandleForObject(PNone.NONE) == SINGLETON_HANDLE_NONE; - assert getHPyHandleForObject(PEllipsis.INSTANCE) == SINGLETON_HANDLE_ELIPSIS; - assert getHPyHandleForObject(PNotImplemented.NOT_IMPLEMENTED) == SINGLETON_HANDLE_NOT_IMPLEMENTED; - - if (traceUpcallsInterval > 0) { - scheduler = Executors.newScheduledThreadPool(1); - startUpcallsDaemon(traceUpcallsInterval); - } else { - scheduler = null; - } - } - - /** - * Reference cleaner action that will be executed by the {@link AsyncHandler}. - */ - private static final class GraalHPyHandleReferenceCleanerAction implements AsyncHandler.AsyncAction { - - private final GraalHPyHandleReference[] nativeObjectReferences; - - public GraalHPyHandleReferenceCleanerAction(GraalHPyHandleReference[] nativeObjectReferences) { - this.nativeObjectReferences = nativeObjectReferences; - } - - @Override - public void execute(PythonContext context) { - Object[] pArguments = PArguments.create(1); - PArguments.setArgument(pArguments, 0, nativeObjectReferences); - GenericInvokeNode.getUncached().execute(context.getHPyContext().getReferenceCleanerCallTarget(), pArguments); - } - } - - private RootCallTarget getReferenceCleanerCallTarget() { - if (referenceCleanerCallTarget == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - RootCallTarget localTarget = PythonUtils.getOrCreateCallTarget(new HPyNativeSpaceCleanerRootNode(getContext())); - VarHandle.storeStoreFence(); - referenceCleanerCallTarget = localTarget; - } - return referenceCleanerCallTarget; - } - - /** - * This is the HPy cleaner thread runnable. It will run in parallel to the main thread, collect - * references from the corresponding reference queue, and eventually call - * {@link HPyNativeSpaceCleanerRootNode}. For this, the cleaner thread consumes the - * {@link #references} list by exchanging it with an empty one (for a description of the - * exchanging process, see also {@link #references}). - */ - static final class GraalHPyReferenceCleanerRunnable extends PythonSystemThreadTask { - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyReferenceCleanerRunnable.class); - private final ReferenceQueue referenceQueue; - private GraalHPyHandleReference cleanerList; - - GraalHPyReferenceCleanerRunnable(ReferenceQueue referenceQueue) { - super("HPy reference cleaner", LOGGER); - this.referenceQueue = referenceQueue; - } - - @Override - public void doRun() { - PythonContext pythonContext = PythonContext.get(null); - PythonLanguage language = pythonContext.getLanguage(); - GraalHPyContext hPyContext = pythonContext.getHPyContext(); - RootCallTarget callTarget = hPyContext.getReferenceCleanerCallTarget(); - PDict dummyGlobals = PFactory.createDict(language); - boolean isLoggable = LOGGER.isLoggable(Level.FINE); - /* - * Intentionally retrieve the thread state every time since this will kill the thread if - * shutting down. - */ - RootNode location = language.unavailableSafepointLocation; - while (!pythonContext.getThreadState(language).isShuttingDown()) { - Reference reference = TruffleSafepoint.setBlockedThreadInterruptibleFunction(location, ReferenceQueue::remove, referenceQueue); - ArrayList refs = new ArrayList<>(); - do { - if (reference instanceof GraalHPyHandleReference) { - refs.add((GraalHPyHandleReference) reference); - } - // consume all - reference = referenceQueue.poll(); - TruffleSafepoint.poll(location); - } while (reference != null); - - if (isLoggable) { - LOGGER.fine(PythonUtils.formatJString("Collected references: %d", refs.size())); - } - - /* - * To avoid race conditions, we take the whole references list such that we can - * solely process it. At this point, the references list is owned by the main thread - * and this will now transfer ownership to the cleaner thread. The list will be - * replaced by an empty list (which will then be owned by the main thread). - */ - GraalHPyHandleReference refList; - int retries = 0; - do { - /* - * If 'refList' is null then the main is currently updating it. So, we need to - * repeat until we get something. The written empty list will just be lost. - */ - refList = hPyContext.references.getAndSet(null); - } while (refList == null && retries++ < 3); - - if (!refs.isEmpty()) { - try { - Object[] arguments = PArguments.create(3); - PArguments.setGlobals(arguments, dummyGlobals); - PArguments.setException(arguments, PException.NO_EXCEPTION); - PArguments.setCallerFrameInfo(arguments, PFrame.Reference.EMPTY); - PArguments.setArgument(arguments, 0, refs.toArray(new GraalHPyHandleReference[0])); - PArguments.setArgument(arguments, 1, refList); - PArguments.setArgument(arguments, 2, cleanerList); - cleanerList = (GraalHPyHandleReference) CallTargetInvokeNode.invokeUncached(callTarget, arguments); - } catch (PException e) { - /* - * Since the cleaner thread is not running any Python code, we should never - * receive a Python exception. If it happens, consider that to be a problem - * (however, it is not fatal problem). - */ - e.materializeMessage(); - LOGGER.warning("HPy reference cleaner thread received a Python exception: " + e); - } - } - } - } - } - - /** - * Root node that actually runs the destroy functions for the native memory of unreachable - * Python objects. - */ - private static final class HPyNativeSpaceCleanerRootNode extends PRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("refs"), EMPTY_TRUFFLESTRING_ARRAY); - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(HPyNativeSpaceCleanerRootNode.class); - - @Child private GraalHPyCAccess.BulkFreeHandleReferencesNode callBulkFree; - - private final LoopConditionProfile loopProfile = LoopConditionProfile.create(); - - HPyNativeSpaceCleanerRootNode(PythonContext context) { - super(context.getLanguage()); - } - - @Override - public Object execute(VirtualFrame frame) { - /* - * This node is not running any Python code in the sense that it does not run any code - * that would run in CPython's interpreter loop. So, we don't need to do a - * calleeContext.enter/exit since we should never get any Python exception. - */ - - GraalHPyHandleReference[] handleReferences = (GraalHPyHandleReference[]) PArguments.getArgument(frame, 0); - GraalHPyHandleReference refList = (GraalHPyHandleReference) PArguments.getArgument(frame, 1); - GraalHPyHandleReference oldRefList = (GraalHPyHandleReference) PArguments.getArgument(frame, 2); - long startTime = 0; - long middleTime = 0; - final int n = handleReferences.length; - boolean loggable = LOGGER.isLoggable(Level.FINE); - - if (loggable) { - startTime = System.currentTimeMillis(); - } - - GraalHPyContext context = PythonContext.get(this).getHPyContext(); - - // mark queued references as cleaned - loopProfile.profileCounted(n); - for (int i = 0; loopProfile.inject(i < n); i++) { - handleReferences[i].cleaned = true; - } - - // remove marked references from the global reference list such that they can die - GraalHPyHandleReference prev = null; - for (GraalHPyHandleReference cur = refList; cur != null; cur = cur.next) { - if (cur.cleaned) { - if (prev != null) { - prev.next = cur.next; - } else { - // new head - refList = cur.next; - } - } else { - prev = cur; - } - } - - /* - * Merge the received reference list into the existing one or just take it if there - * wasn't one before. - */ - if (prev != null) { - // if prev exists, it now points to the tail - prev.next = oldRefList; - } else { - refList = oldRefList; - } - - if (loggable) { - middleTime = System.currentTimeMillis(); - } - - if (callBulkFree == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callBulkFree = insert(GraalHPyCAccess.BulkFreeHandleReferencesNode.create(context)); - } - callBulkFree.execute(context, handleReferences); - - if (loggable) { - final long countDuration = middleTime - startTime; - final long duration = System.currentTimeMillis() - middleTime; - LOGGER.fine(PythonUtils.formatJString("Cleaned references: %d", n)); - LOGGER.fine(PythonUtils.formatJString("Count duration: %d", countDuration)); - LOGGER.fine(PythonUtils.formatJString("Duration: %d", duration)); - } - return refList; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - - @Override - public String getName() { - return "hpy_native_reference_cleaner"; - } - - @Override - public boolean isInternal() { - return true; - } - - @Override - public boolean isPythonInternal() { - return true; - } - } - - public void initHPyDebugContext() throws ApiInitException { - backend.initHPyDebugContext(); - } - - public PythonModule getHPyDebugModule() throws ImportException { - return backend.getHPyDebugModule(); - } - - public PythonModule getHPyTraceModule() throws ImportException { - return backend.getHPyTraceModule(); - } - - HPyMode getCurrentMode() { - return currentMode; - } - - public GraalHPyNativeContext getBackend() { - return backend; - } - - @SuppressWarnings("static-method") - public GraalHPyHandle createHandle(Object delegate) { - return GraalHPyHandle.create(delegate); - } - - @SuppressWarnings("static-method") - public GraalHPyHandle createField(Object delegate, int idx) { - return GraalHPyHandle.createField(delegate, idx); - } - - public int createGlobal(Object delegate, int idx) { - assert !GilNode.getUncached().acquire(PythonContext.get(null)) : "Gil not held when creating global"; - final int newIdx; - if (idx <= 0) { - newIdx = allocateHPyGlobal(); - } else { - newIdx = idx; - } - hpyGlobalsTable[newIdx] = delegate; - if (useNativeFastPaths) { - mirrorGlobalNativeSpacePointerToNative(delegate, newIdx); - } - if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.finer(PythonUtils.formatJString("allocating HPy global %d (object: %s)", newIdx, delegate)); - } - return newIdx; - } - - int getEndIndexOfGlobalTable() { - for (int i = hpyGlobalsTable.length - 1; i > 0; i--) { - if (hpyGlobalsTable[i] != null) { - return i + 1; - } - } - return hpyGlobalsTable.length; - } - - @TruffleBoundary - void initBatchGlobals(int startIdx, int nModuleGlobals) { - if (nModuleGlobals == 0) { - return; - } - int gtLen = hpyGlobalsTable.length; - int endIdx = startIdx + nModuleGlobals; - if (endIdx >= gtLen) { - int newSize = endIdx + 1; - LOGGER.fine(() -> PythonUtils.formatJString("resizing HPy globals table to %d", newSize)); - hpyGlobalsTable = Arrays.copyOf(hpyGlobalsTable, newSize); - if (useNativeFastPaths) { - reallocateNativeSpacePointersMirror(hpyHandleTable.length, gtLen); - } - } - Arrays.fill(hpyGlobalsTable, startIdx, endIdx, GraalHPyHandle.NULL_HANDLE_DELEGATE); - if (useNativeFastPaths) { - GraalHPyNativeCache.initGlobalsNativeSpacePointer(nativeSpacePointers, hpyHandleTable.length, startIdx, nModuleGlobals); - } - } - - @TruffleBoundary - private int allocateHPyGlobal() { - int handle = 0; - for (int i = 1; i < hpyGlobalsTable.length; i++) { - if (hpyGlobalsTable[i] == null) { - handle = i; - break; - } - } - if (handle == 0) { - // resize - handle = hpyGlobalsTable.length; - int newSize = Math.max(16, hpyGlobalsTable.length * 2); - LOGGER.fine(() -> "resizing HPy globals table to " + newSize); - hpyGlobalsTable = Arrays.copyOf(hpyGlobalsTable, newSize); - if (useNativeFastPaths) { - reallocateNativeSpacePointersMirror(hpyHandleTable.length, handle); - } - } - return handle; - } - - private int resizeHandleTable() { - CompilerAsserts.neverPartOfCompilation(); - assert nextHandle == hpyHandleTable.length; - int oldSize = hpyHandleTable.length; - int newSize = Math.max(16, hpyHandleTable.length * 2); - LOGGER.fine(() -> "resizing HPy handle table to " + newSize); - hpyHandleTable = Arrays.copyOf(hpyHandleTable, newSize); - if (useNativeFastPaths) { - reallocateNativeSpacePointersMirror(oldSize, hpyGlobalsTable.length); - } - return nextHandle++; - } - - public int getHPyHandleForObject(Object object) { - assert !(object instanceof GraalHPyHandle); - int singletonHandle = getHPyHandleForSingleton(object); - if (singletonHandle != -1) { - return singletonHandle; - } - return getHPyHandleForNonSingleton(object); - } - - public static int getHPyHandleForSingleton(Object object) { - assert !(object instanceof GraalHPyHandle); - return GetHPyHandleForSingleton.doGeneric(object); - } - - /** - * Allocates a handle for the given object. This method is intended to be used by the - * appropriate backend to initialize the context handles (i.e. handles available in - * {@code HPyContext *}; e.g. {@code HPyContext.h_None}). Following properties/restrictions - * apply: - *
      - *
    • This method *MUST NOT* be called after the context initialization was finished.
    • - *
    • The handles are not mirrored to the native cache even if {@link #useNativeFastPaths}. - * This should be done in a bulk operation after all context handles have been allocated.
    • - *
    • {@code object} must not be a singleton handle (i.e. - * {@link #getHPyHandleForSingleton(Object)} must return {@code -1}).
    • - *
    - */ - public int getHPyContextHandle(Object object) { - CompilerAsserts.neverPartOfCompilation(); - assert getHPyHandleForSingleton(object) == -1; - assert freeStack.getTop() == 0; - assert nextHandle < hpyHandleTable.length; - if (nextHandle >= IMMUTABLE_HANDLE_COUNT) { - throw CompilerDirectives.shouldNotReachHere("attempting to create context handle after initialization"); - } - int i = nextHandle++; - assert hpyHandleTable[i] == null; - hpyHandleTable[i] = object; - return i; - } - - public int getHPyHandleForNonSingleton(Object object) { - assert !(object instanceof GraalHPyHandle); - // find free association - - int handle = freeStack.pop(); - if (handle == -1) { - if (nextHandle < hpyHandleTable.length) { - handle = nextHandle++; - } else { - CompilerDirectives.transferToInterpreter(); - handle = resizeHandleTable(); - } - } - - assert 0 <= handle && handle < hpyHandleTable.length; - assert hpyHandleTable[handle] == null; - - hpyHandleTable[handle] = object; - if (useNativeFastPaths) { - mirrorNativeSpacePointerToNative(object, handle); - } - if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.finer(PythonUtils.formatJString("allocating HPy handle %d (object: %s)", handle, object)); - } - return handle; - } - - public Object bitsAsPythonObject(long bits) { - if (GraalHPyBoxing.isBoxedNullHandle(bits)) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } else if (GraalHPyBoxing.isBoxedInt(bits)) { - return GraalHPyBoxing.unboxInt(bits); - } else if (GraalHPyBoxing.isBoxedDouble(bits)) { - return GraalHPyBoxing.unboxDouble(bits); - } - assert GraalHPyBoxing.isBoxedHandle(bits); - return getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - } - - public long pythonObjectAsBits(Object object) { - if (GraalHPyBoxing.isBoxablePrimitive(object)) { - if (object instanceof Integer) { - return GraalHPyBoxing.boxInt((Integer) object); - } - assert object instanceof Double; - return GraalHPyBoxing.boxDouble((Double) object); - } else if (object == GraalHPyHandle.NULL_HANDLE_DELEGATE) { - return 0; - } - return getHPyHandleForObject(object); - } - - @GenerateUncached - @GenerateInline(false) - @ImportStatic(PGuards.class) - public abstract static class GetHPyHandleForSingleton extends Node { - public abstract int execute(Object delegateObject); - - @Specialization(guards = "isNoValue(x)") - static int doNoValue(@SuppressWarnings("unused") PNone x) { - return 0; - } - - @Specialization(guards = "!isNoValue(x)") - static int doNone(@SuppressWarnings("unused") PNone x) { - return SINGLETON_HANDLE_NONE; - } - - @Specialization - static int doEllipsis(@SuppressWarnings("unused") PEllipsis x) { - return SINGLETON_HANDLE_ELIPSIS; - } - - @Specialization - static int doNotImplemented(@SuppressWarnings("unused") PNotImplemented x) { - return SINGLETON_HANDLE_NOT_IMPLEMENTED; - } - - @Specialization(guards = "!isSingleton(delegate)") - static int doOthers(@SuppressWarnings("unused") Object delegate) { - return -1; - } - - @Specialization(replaces = {"doNoValue", "doNone", "doEllipsis", "doNotImplemented", "doOthers"}) - static int doGeneric(Object object) { - if (object == PNone.NO_VALUE) { - return 0; - } else if (object == PNone.NONE) { - return SINGLETON_HANDLE_NONE; - } else if (object == PEllipsis.INSTANCE) { - return SINGLETON_HANDLE_ELIPSIS; - } else if (object == PNotImplemented.NOT_IMPLEMENTED) { - return SINGLETON_HANDLE_NOT_IMPLEMENTED; - } - return -1; - } - - static boolean isSingleton(Object object) { - return object == PNone.NONE || object == PEllipsis.INSTANCE || object == PNotImplemented.NOT_IMPLEMENTED; - } - } - - @TruffleBoundary - private void mirrorNativeSpacePointerToNative(Object delegate, int handleID) { - assert useNativeFastPaths; - long l; - if (delegate instanceof PythonObject) { - Object nativeSpace = HPyGetNativeSpacePointerNode.doPythonObject((PythonObject) delegate); - try { - l = nativeSpace instanceof Long ? ((long) nativeSpace) : InteropLibrary.getUncached().asPointer(nativeSpace); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } else { - l = 0; - } - GraalHPyNativeCache.putHandleNativeSpacePointer(nativeSpacePointers, handleID, l); - } - - @TruffleBoundary - private void mirrorGlobalNativeSpacePointerToNative(Object delegate, int globalID) { - assert useNativeFastPaths; - long l; - if (delegate instanceof PythonObject) { - Object nativeSpace = HPyGetNativeSpacePointerNode.doPythonObject((PythonObject) delegate); - try { - l = nativeSpace instanceof Long ? ((long) nativeSpace) : InteropLibrary.getUncached().asPointer(nativeSpace); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } else { - l = 0; - } - GraalHPyNativeCache.putGlobalNativeSpacePointer(nativeSpacePointers, hpyHandleTable.length, globalID, l); - } - - @TruffleBoundary - private void reallocateNativeSpacePointersMirror(int oldHandleTabelSize, int oldGlobalsTableSize) { - assert useNativeFastPaths; - nativeSpacePointers = GraalHPyNativeCache.reallocateNativeCache(nativeSpacePointers, oldHandleTabelSize, hpyHandleTable.length, oldGlobalsTableSize, hpyGlobalsTable.length); - backend.setNativeCache(nativeSpacePointers); - } - - /** - * Allocates a native array (element size is {@link #SIZEOF_LONG} for as many elements as in - * {@link #hpyHandleTable} and writes the native space pointers of all objects in the handle - * table into this array. The pointer of the array is then set to - * {@code ((HPyContext) ctx)->_private} and meant to be used by the {@code ctx_Cast}'s upcall - * stub to avoid an expensive upcall. - */ - @TruffleBoundary - void allocateNativeSpacePointersMirror() { - long arrayPtr = GraalHPyNativeCache.allocateNativeCache(hpyHandleTable.length, hpyGlobalsTable.length); - - // publish pointer value (needed for initialization) - nativeSpacePointers = arrayPtr; - - // write existing values to mirror; start at 1 to omit the NULL handle - for (int i = 1; i < hpyHandleTable.length; i++) { - Object delegate = hpyHandleTable[i]; - if (delegate != null) { - mirrorNativeSpacePointerToNative(delegate, i); - } - } - - // commit pointer value for native usage - backend.setNativeCache(arrayPtr); - } - - public Object getObjectForHPyHandle(int handle) { - // GR-50245 - // assert !GilNode.getUncached().acquire(PythonContext.get(null)) : "Gil not held when - // resolving object from handle"; - assert !GraalHPyBoxing.isBoxedInt(handle) && !GraalHPyBoxing.isBoxedDouble(handle) : "trying to lookup boxed primitive"; - return hpyHandleTable[handle]; - } - - public Object getObjectForHPyGlobal(int handle) { - // GR-50245 - // assert !GilNode.getUncached().acquire(PythonContext.get(null)) : "Gil not held when - // resolving object from global"; - assert !GraalHPyBoxing.isBoxedInt(handle) && !GraalHPyBoxing.isBoxedDouble(handle) : "trying to lookup boxed primitive"; - return hpyGlobalsTable[handle]; - } - - public boolean releaseHPyHandleForObject(int handle) { - // GR-50245 - // assert !GilNode.getUncached().acquire(PythonContext.get(null)) : "Gil not held when - // releasing handle"; - assert handle != 0 : "NULL handle cannot be released"; - assert hpyHandleTable[handle] != null : PythonUtils.formatJString("releasing handle that has already been released: %d", handle); - if (LOGGER.isLoggable(Level.FINER)) { - LOGGER.finer(PythonUtils.formatJString("releasing HPy handle %d (object: %s)", handle, hpyHandleTable[handle])); - } - if (handle < IMMUTABLE_HANDLE_COUNT) { - return false; - } - hpyHandleTable[handle] = null; - freeStack.push(handle); - return true; - } - - /** - * A weak reference to an object that has an associated HPy native space ( - * {@link PythonHPyObject}). - */ - public static final class GraalHPyHandleReference extends WeakReference { - - private final Object nativeSpace; - private final Object destroyFunc; - - boolean cleaned; - private GraalHPyHandleReference next; - - public GraalHPyHandleReference(Object referent, ReferenceQueue q, Object nativeSpace, Object destroyFunc) { - super(referent, q); - this.nativeSpace = nativeSpace; - this.destroyFunc = destroyFunc; - } - - public Object getNativeSpace() { - return nativeSpace; - } - - public Object getDestroyFunc() { - return destroyFunc; - } - - public GraalHPyHandleReference getNext() { - return next; - } - - public void setNext(GraalHPyHandleReference next) { - this.next = next; - } - } - - /** - * Registers an HPy native space of a Python object.
    - * Use this method to register a native memory that is associated with a Python object in order - * to ensure that the native memory will be free'd when the owning Python object dies.
    - * This works by creating a weak reference to the Python object, using a thread that - * concurrently polls the reference queue. If threading is allowed, cleaning will be done fully - * concurrent on a cleaner thread. If not, an async action will be scheduled to free the native - * memory. Hence, the destroy function could also be executed on the cleaner thread. - * - * @param pythonObject The Python object that has associated native memory. - * @param dataPtr The pointer object of the native memory. - * @param destroyFunc The destroy function to call when the Python object is unreachable (may be - * {@code null}; in this case, bare {@code free} will be used). - */ - @TruffleBoundary - public void createHandleReference(Object pythonObject, Object dataPtr, Object destroyFunc) { - GraalHPyHandleReference newHead = new GraalHPyHandleReference(pythonObject, ensureReferenceQueue(), dataPtr, destroyFunc); - references.getAndAccumulate(newHead, (prev, x) -> { - x.next = prev; - return x; - }); - } - - private ReferenceQueue ensureReferenceQueue() { - if (nativeSpaceReferenceQueue == null) { - ReferenceQueue referenceQueue = createReferenceQueue(); - nativeSpaceReferenceQueue = referenceQueue; - return referenceQueue; - } - return nativeSpaceReferenceQueue; - } - - @TruffleBoundary - private ReferenceQueue createReferenceQueue() { - final ReferenceQueue referenceQueue = new ReferenceQueue<>(); - - // lazily register the runnable that concurrently collects the queued references - PythonContext context = getContext(); - Env env = context.getEnv(); - if (env.isCreateThreadAllowed()) { - context.createSystemThread(new GraalHPyReferenceCleanerRunnable(referenceQueue)).start(); - } else { - context.registerAsyncAction(() -> { - Reference reference = null; - if (PythonOptions.AUTOMATIC_ASYNC_ACTIONS) { - try { - reference = referenceQueue.remove(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } else { - referenceQueue.poll(); - } - - ArrayList refs = new ArrayList<>(); - do { - if (reference instanceof GraalHPyHandleReference) { - refs.add((GraalHPyHandleReference) reference); - } - // consume all - reference = referenceQueue.poll(); - } while (reference != null); - - if (!refs.isEmpty()) { - return new GraalHPyHandleReferenceCleanerAction(refs.toArray(new GraalHPyHandleReference[0])); - } - - return null; - }); - } - return referenceQueue; - } - - public int getCTypeSize(HPyContextSignatureType ctype) { - return backend.getCTypeSize(ctype); - } - - public int getCFieldOffset(GraalHPyCField ctype) { - return backend.getCFieldOffset(ctype); - } - - public Object nativeToInteropPointer(Object object) { - return backend.nativeToInteropPointer(object); - } - - public Object getNativeNull() { - return backend.getNativeNull(); - } - - /** - * Join the reference cleaner thread. - */ - public void finalizeContext() { - backend.finalizeNativeContext(); - if (nativeArgumentsStack != 0) { - UNSAFE.freeMemory(nativeArgumentsStack); - nativeArgumentsStack = 0; - } - if (scheduler != null) { - scheduler.shutdown(); - } - } - - private void startUpcallsDaemon(long interval) { - scheduler.scheduleAtFixedRate(() -> { - HPyUpcall[] upcalls = backend.getUpcalls(); - int[] counts = backend.getUpcallCounts(); - StringBuilder sb = new StringBuilder(); - sb.append("========= HPy context upcall counts (").append(backend.getName()).append(')'); - for (int i = 0; i < counts.length; i++) { - if (counts[i] != 0) { - sb.append(String.format(" %40s[%3d]: %d\n", upcalls[i].getName(), i, counts[i])); - } - } - System.out.print(sb); - System.out.flush(); - }, interval, interval, TimeUnit.MILLISECONDS); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java deleted file mode 100644 index 5de41baf2e..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java +++ /dev/null @@ -1,3712 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RuntimeWarning; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_FLOAT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_LIST; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_LONG; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_OBJECT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_TUPLE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_TYPE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyType_BUILTIN_SHAPE_UNICODE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle.NULL_HANDLE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle.NULL_HANDLE_DELEGATE; -import static com.oracle.graal.python.nodes.StringLiterals.T_EMPTY_STRING; -import static com.oracle.graal.python.nodes.StringLiterals.T_STRICT; -import static com.oracle.graal.python.nodes.StringLiterals.T_UTF8; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.PrintWriter; -import java.lang.annotation.Repeatable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CodingErrorAction; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.logging.Level; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.Python3Core; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.modules.CodecsModuleBuiltins; -import com.oracle.graal.python.builtins.modules.SysModuleBuiltins.GetFileSystemEncodingNode; -import com.oracle.graal.python.builtins.modules.WarningsModuleBuiltins.WarnNode; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.bytes.PBytes; -import com.oracle.graal.python.builtins.objects.capsule.PyCapsule; -import com.oracle.graal.python.builtins.objects.capsule.PyCapsuleNameMatchesNode; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.FromCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.capi.PySequenceArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonNode; -import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNewRefNode; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.AsNativePrimitiveNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ClearCurrentExceptionNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EncodeNativeStringNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ReadUnicodeArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyASCIINodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAbsoluteNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAddNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAndNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAsIndexNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyAsPyObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBoolFromBoolNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBuilderCancelNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBuilderNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBuilderSetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesAsStringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesFromStringAndSizeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesFromStringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesGetSizeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyBytesNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCallMethodNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCallNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCallTupleDictNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCapsuleGetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCapsuleIsValidNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCapsuleNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCapsuleSetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCastNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyCompileNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyContainsNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyContextVarGetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyContextVarNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyContextVarSetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDelItemNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDelItemSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDictCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDictCopyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDictKeysNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDictNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDivmodNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDumpNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyDupNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrClearNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrExceptionMatchesNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrNoMemoryNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrOccurredNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrSetFromErrnoWithFilenameNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrSetFromErrnoWithFilenameObjectsNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrSetObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrSetStringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrWarnExNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyErrWriteUnraisableNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyEvalCodeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFatalErrorNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFieldLoadNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFieldStoreNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFloatAsDoubleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFloatFromDoubleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFloatNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFloorDivideNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyFromPyObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGetAttrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGetAttrSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGetItemNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGetItemSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGlobalLoadNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyGlobalStoreNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyHasAttrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyHasAttrSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyHashNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyImportModuleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceAddNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceAndNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceFloorDivideNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceLshiftNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceMatrixMultiplyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceMultiplyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceOrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlacePowerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceRemainderNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceRshiftNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceSubtractNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceTrueDivideNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInPlaceXorNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyInvertNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyIsCallableNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyIsNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyIsNumberNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyIsTrueNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLeavePythonExecutionNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLengthNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyListAppendNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyListBuilderBuildNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyListCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyListNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsDoubleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsInt32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsSsizeTNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsUInt32MaskNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsUInt32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsUInt64MaskNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongAsUInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongFromInt32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongFromInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongFromUInt32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongFromUInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyLshiftNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyMatrixMultiplyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyMultiplyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyNegativeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyNewExceptionNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyNewExceptionWithDocNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyOrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyPositiveNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyPowerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyReenterPythonExecutionNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyRemainderNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyReprNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyRichcompareBoolNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyRichcompareNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyRshiftNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySetAttrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySetAttrSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySetCallFunctionNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySetItemNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySetItemSNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySliceUnpackNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyStrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPySubtractNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTrackerAddNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTrackerCleanupNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTrackerForgetAllNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTrackerNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTrueDivideNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTupleBuilderBuildNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTupleCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTupleFromArrayNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeFromSpecNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeGenericNewNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeGetBuiltinShapeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeGetNameNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeIsSubtypeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyTypeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeAsASCIIStringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeAsLatin1StringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeAsUTF8AndSizeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeAsUTF8StringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeCheckNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeDecodeASCIINodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeDecodeCharsetAndSizeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeDecodeCharsetNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeDecodeLatin1NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeEncodeFSDefaultNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeFromEncodedObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeFromStringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeFromWcharNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeReadCharNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyUnicodeSubstringNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctionsFactory.GraalHPyXorNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsPythonObjectNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseAndGetHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCreateTypeFromSpecNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyEnsureHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFieldLoadNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyGetNativeSpacePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyLongFromLong; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyPackKeywordArgsNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyReadCallFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyTypeGetNameNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.RecursiveExceptionMatches; -import com.oracle.graal.python.builtins.objects.cext.structs.CStructs; -import com.oracle.graal.python.builtins.objects.code.CodeNodes; -import com.oracle.graal.python.builtins.objects.code.PCode; -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.HashingStorageCopy; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItem; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageLen; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; -import com.oracle.graal.python.builtins.objects.common.SequenceNodes; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.NoGeneralizationNode; -import com.oracle.graal.python.builtins.objects.contextvars.PContextVar; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.exception.GetEscapedExceptionNode; -import com.oracle.graal.python.builtins.objects.exception.GetUnreifiedExceptionNode; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.slice.PSlice; -import com.oracle.graal.python.builtins.objects.slice.PSlice.SliceInfo; -import com.oracle.graal.python.builtins.objects.slice.PSlice.SliceInfoLong; -import com.oracle.graal.python.builtins.objects.slice.SliceNodes; -import com.oracle.graal.python.builtins.objects.str.StringBuiltins.StrGetItemNodeWithSlice; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot; -import com.oracle.graal.python.builtins.objects.type.TypeNodes; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; -import com.oracle.graal.python.lib.PyCallableCheckNode; -import com.oracle.graal.python.lib.PyDictKeys; -import com.oracle.graal.python.lib.PyExceptionInstanceCheckNode; -import com.oracle.graal.python.lib.PyFloatAsDoubleNode; -import com.oracle.graal.python.lib.PyLongAsDoubleNode; -import com.oracle.graal.python.lib.PyNumberAddNode; -import com.oracle.graal.python.lib.PyNumberAndNode; -import com.oracle.graal.python.lib.PyNumberCheckNode; -import com.oracle.graal.python.lib.PyNumberDivmodNode; -import com.oracle.graal.python.lib.PyNumberFloorDivideNode; -import com.oracle.graal.python.lib.PyNumberInPlaceAddNode; -import com.oracle.graal.python.lib.PyNumberInPlaceAndNode; -import com.oracle.graal.python.lib.PyNumberInPlaceFloorDivideNode; -import com.oracle.graal.python.lib.PyNumberInPlaceLshiftNode; -import com.oracle.graal.python.lib.PyNumberInPlaceMatrixMultiplyNode; -import com.oracle.graal.python.lib.PyNumberInPlaceMultiplyNode; -import com.oracle.graal.python.lib.PyNumberInPlaceOrNode; -import com.oracle.graal.python.lib.PyNumberInPlacePowerNode; -import com.oracle.graal.python.lib.PyNumberInPlaceRemainderNode; -import com.oracle.graal.python.lib.PyNumberInPlaceRshiftNode; -import com.oracle.graal.python.lib.PyNumberInPlaceSubtractNode; -import com.oracle.graal.python.lib.PyNumberInPlaceTrueDivideNode; -import com.oracle.graal.python.lib.PyNumberInPlaceXorNode; -import com.oracle.graal.python.lib.PyNumberIndexNode; -import com.oracle.graal.python.lib.PyNumberInvertNode; -import com.oracle.graal.python.lib.PyNumberLshiftNode; -import com.oracle.graal.python.lib.PyNumberMatrixMultiplyNode; -import com.oracle.graal.python.lib.PyNumberMultiplyNode; -import com.oracle.graal.python.lib.PyNumberNegativeNode; -import com.oracle.graal.python.lib.PyNumberOrNode; -import com.oracle.graal.python.lib.PyNumberPositiveNode; -import com.oracle.graal.python.lib.PyNumberPowerNode; -import com.oracle.graal.python.lib.PyNumberRemainderNode; -import com.oracle.graal.python.lib.PyNumberRshiftNode; -import com.oracle.graal.python.lib.PyNumberSubtractNode; -import com.oracle.graal.python.lib.PyNumberTrueDivideNode; -import com.oracle.graal.python.lib.PyNumberXorNode; -import com.oracle.graal.python.lib.PyObjectDelItem; -import com.oracle.graal.python.lib.PyObjectGetAttr; -import com.oracle.graal.python.lib.PyObjectGetAttrO; -import com.oracle.graal.python.lib.PyObjectGetItem; -import com.oracle.graal.python.lib.PyObjectGetMethod; -import com.oracle.graal.python.lib.PyObjectIsTrueNode; -import com.oracle.graal.python.lib.PyObjectReprAsTruffleStringNode; -import com.oracle.graal.python.lib.PyObjectRichCompare; -import com.oracle.graal.python.lib.PyObjectRichCompareBool; -import com.oracle.graal.python.lib.PyObjectSetAttr; -import com.oracle.graal.python.lib.PyObjectSetAttrO; -import com.oracle.graal.python.lib.PyObjectSetItem; -import com.oracle.graal.python.lib.PySequenceContainsNode; -import com.oracle.graal.python.lib.PyTupleSizeNode; -import com.oracle.graal.python.lib.PyUnicodeFromEncodedObject; -import com.oracle.graal.python.lib.PyUnicodeReadCharNode; -import com.oracle.graal.python.lib.RichCmpOp; -import com.oracle.graal.python.nodes.BuiltinNames; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialAttributeNames; -import com.oracle.graal.python.nodes.WriteUnraisableNode; -import com.oracle.graal.python.nodes.argument.keywords.ExpandKeywordStarargsNode; -import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode; -import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; -import com.oracle.graal.python.nodes.builtins.ListNodes; -import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.call.GenericInvokeNode; -import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; -import com.oracle.graal.python.nodes.object.IsNode; -import com.oracle.graal.python.nodes.statement.AbstractImportNode; -import com.oracle.graal.python.nodes.util.CannotCastException; -import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.GilNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; -import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.runtime.sequence.PSequence; -import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; -import com.oracle.graal.python.util.CharsetMapping; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.exception.AbstractTruffleException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.object.Shape; -import com.oracle.truffle.api.profiles.InlinedBranchProfile; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.api.profiles.InlinedExactClassProfile; -import com.oracle.truffle.api.strings.InternalByteArray; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.Encoding; - -@SuppressWarnings("truffle-inlining") -public abstract class GraalHPyContextFunctions { - - @Retention(RetentionPolicy.RUNTIME) - public @interface HPyContextFunctions { - HPyContextFunction[] value(); - } - - /** - * Context function implementations are marked with this annotation. It is used to annotate a - * node with the name of the implemented context function. This information is further consumed - * to automatically generate the appropriate upcall path. - */ - @Retention(RetentionPolicy.RUNTIME) - @Repeatable(value = HPyContextFunctions.class) - public @interface HPyContextFunction { - - /** - * Name of this builtin - the name can be omitted, which will use the name of the class that - * this annotation is applied to. - */ - String value() default ""; - } - - public abstract static class GraalHPyContextFunction extends Node { - - public abstract Object execute(Object[] arguments); - - // {{start ctx func factory}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_function_factory - @NeverDefault - public static GraalHPyContextFunction create(HPyContextMember member) { - return switch (member) { - case CTX_DUP -> GraalHPyDupNodeGen.create(); - case CTX_CLOSE -> GraalHPyCloseNodeGen.create(); - case CTX_POSITIVE -> GraalHPyPositiveNodeGen.create(); - case CTX_NEGATIVE -> GraalHPyNegativeNodeGen.create(); - case CTX_INVERT -> GraalHPyInvertNodeGen.create(); - case CTX_ADD -> GraalHPyAddNodeGen.create(); - case CTX_SUBTRACT -> GraalHPySubtractNodeGen.create(); - case CTX_MULTIPLY -> GraalHPyMultiplyNodeGen.create(); - case CTX_MATRIXMULTIPLY -> GraalHPyMatrixMultiplyNodeGen.create(); - case CTX_FLOORDIVIDE -> GraalHPyFloorDivideNodeGen.create(); - case CTX_TRUEDIVIDE -> GraalHPyTrueDivideNodeGen.create(); - case CTX_REMAINDER -> GraalHPyRemainderNodeGen.create(); - case CTX_DIVMOD -> GraalHPyDivmodNodeGen.create(); - case CTX_AND -> GraalHPyAndNodeGen.create(); - case CTX_XOR -> GraalHPyXorNodeGen.create(); - case CTX_OR -> GraalHPyOrNodeGen.create(); - case CTX_LSHIFT -> GraalHPyLshiftNodeGen.create(); - case CTX_RSHIFT -> GraalHPyRshiftNodeGen.create(); - case CTX_POWER -> GraalHPyPowerNodeGen.create(); - case CTX_INPLACEADD -> GraalHPyInPlaceAddNodeGen.create(); - case CTX_INPLACESUBTRACT -> GraalHPyInPlaceSubtractNodeGen.create(); - case CTX_INPLACEMULTIPLY -> GraalHPyInPlaceMultiplyNodeGen.create(); - case CTX_INPLACEMATRIXMULTIPLY -> GraalHPyInPlaceMatrixMultiplyNodeGen.create(); - case CTX_INPLACEFLOORDIVIDE -> GraalHPyInPlaceFloorDivideNodeGen.create(); - case CTX_INPLACETRUEDIVIDE -> GraalHPyInPlaceTrueDivideNodeGen.create(); - case CTX_INPLACEREMAINDER -> GraalHPyInPlaceRemainderNodeGen.create(); - case CTX_INPLACEPOWER -> GraalHPyInPlacePowerNodeGen.create(); - case CTX_INPLACELSHIFT -> GraalHPyInPlaceLshiftNodeGen.create(); - case CTX_INPLACERSHIFT -> GraalHPyInPlaceRshiftNodeGen.create(); - case CTX_INPLACEAND -> GraalHPyInPlaceAndNodeGen.create(); - case CTX_INPLACEXOR -> GraalHPyInPlaceXorNodeGen.create(); - case CTX_INPLACEOR -> GraalHPyInPlaceOrNodeGen.create(); - case CTX_BOOL_FROMBOOL -> GraalHPyBoolFromBoolNodeGen.create(); - case CTX_LONG_FROMINT32_T -> GraalHPyLongFromInt32NodeGen.create(); - case CTX_LONG_FROMUINT32_T -> GraalHPyLongFromUInt32NodeGen.create(); - case CTX_LONG_FROMINT64_T, CTX_LONG_FROMSSIZE_T -> GraalHPyLongFromInt64NodeGen.create(); - case CTX_LONG_FROMUINT64_T, CTX_LONG_FROMSIZE_T -> GraalHPyLongFromUInt64NodeGen.create(); - case CTX_LONG_ASINT32_T -> GraalHPyLongAsInt32NodeGen.create(); - case CTX_LONG_ASUINT32_T -> GraalHPyLongAsUInt32NodeGen.create(); - case CTX_LONG_ASUINT32_TMASK -> GraalHPyLongAsUInt32MaskNodeGen.create(); - case CTX_LONG_ASINT64_T -> GraalHPyLongAsInt64NodeGen.create(); - case CTX_LONG_ASUINT64_T, CTX_LONG_ASSIZE_T, CTX_LONG_ASVOIDPTR -> GraalHPyLongAsUInt64NodeGen.create(); - case CTX_LONG_ASUINT64_TMASK -> GraalHPyLongAsUInt64MaskNodeGen.create(); - case CTX_LONG_ASSSIZE_T -> GraalHPyLongAsSsizeTNodeGen.create(); - case CTX_LONG_ASDOUBLE -> GraalHPyLongAsDoubleNodeGen.create(); - case CTX_DICT_NEW -> GraalHPyDictNewNodeGen.create(); - case CTX_LIST_NEW -> GraalHPyListNewNodeGen.create(); - case CTX_LIST_APPEND -> GraalHPyListAppendNodeGen.create(); - case CTX_FLOAT_FROMDOUBLE -> GraalHPyFloatFromDoubleNodeGen.create(); - case CTX_FLOAT_ASDOUBLE -> GraalHPyFloatAsDoubleNodeGen.create(); - case CTX_DICT_CHECK -> GraalHPyDictCheckNodeGen.create(); - case CTX_BYTES_CHECK -> GraalHPyBytesCheckNodeGen.create(); - case CTX_UNICODE_CHECK -> GraalHPyUnicodeCheckNodeGen.create(); - case CTX_TUPLE_CHECK -> GraalHPyTupleCheckNodeGen.create(); - case CTX_LIST_CHECK -> GraalHPyListCheckNodeGen.create(); - case CTX_ERR_NOMEMORY -> GraalHPyErrNoMemoryNodeGen.create(); - case CTX_ERR_SETOBJECT -> GraalHPyErrSetObjectNodeGen.create(); - case CTX_ERR_SETSTRING -> GraalHPyErrSetStringNodeGen.create(); - case CTX_ERR_SETFROMERRNOWITHFILENAME -> GraalHPyErrSetFromErrnoWithFilenameNodeGen.create(); - case CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS -> GraalHPyErrSetFromErrnoWithFilenameObjectsNodeGen.create(); - case CTX_FATALERROR -> GraalHPyFatalErrorNodeGen.create(); - case CTX_ERR_OCCURRED -> GraalHPyErrOccurredNodeGen.create(); - case CTX_ERR_EXCEPTIONMATCHES -> GraalHPyErrExceptionMatchesNodeGen.create(); - case CTX_ERR_CLEAR -> GraalHPyErrClearNodeGen.create(); - case CTX_ERR_WARNEX -> GraalHPyErrWarnExNodeGen.create(); - case CTX_ERR_WRITEUNRAISABLE -> GraalHPyErrWriteUnraisableNodeGen.create(); - case CTX_UNICODE_ASUTF8STRING -> GraalHPyUnicodeAsUTF8StringNodeGen.create(); - case CTX_UNICODE_ASLATIN1STRING -> GraalHPyUnicodeAsLatin1StringNodeGen.create(); - case CTX_UNICODE_ASASCIISTRING -> GraalHPyUnicodeAsASCIIStringNodeGen.create(); - case CTX_UNICODE_ENCODEFSDEFAULT -> GraalHPyUnicodeEncodeFSDefaultNodeGen.create(); - case CTX_UNICODE_ASUTF8ANDSIZE -> GraalHPyUnicodeAsUTF8AndSizeNodeGen.create(); - case CTX_UNICODE_FROMSTRING -> GraalHPyUnicodeFromStringNodeGen.create(); - case CTX_UNICODE_FROMWIDECHAR -> GraalHPyUnicodeFromWcharNodeGen.create(); - case CTX_UNICODE_DECODEFSDEFAULT -> GraalHPyUnicodeDecodeCharsetNodeGen.create(); - case CTX_UNICODE_DECODEFSDEFAULTANDSIZE -> GraalHPyUnicodeDecodeCharsetAndSizeNodeGen.create(); - case CTX_UNICODE_DECODEASCII -> GraalHPyUnicodeDecodeASCIINodeGen.create(); - case CTX_UNICODE_DECODELATIN1 -> GraalHPyUnicodeDecodeLatin1NodeGen.create(); - case CTX_UNICODE_READCHAR -> GraalHPyUnicodeReadCharNodeGen.create(); - case CTX_ASPYOBJECT -> GraalHPyAsPyObjectNodeGen.create(); - case CTX_BYTES_ASSTRING, CTX_BYTES_AS_STRING -> GraalHPyBytesAsStringNodeGen.create(); - case CTX_BYTES_SIZE, CTX_BYTES_GET_SIZE -> GraalHPyBytesGetSizeNodeGen.create(); - case CTX_BYTES_FROMSTRING -> GraalHPyBytesFromStringNodeGen.create(); - case CTX_BYTES_FROMSTRINGANDSIZE -> GraalHPyBytesFromStringAndSizeNodeGen.create(); - case CTX_ISTRUE -> GraalHPyIsTrueNodeGen.create(); - case CTX_GETATTR -> GraalHPyGetAttrNodeGen.create(); - case CTX_GETATTR_S -> GraalHPyGetAttrSNodeGen.create(); - case CTX_TYPE_FROMSPEC -> GraalHPyTypeFromSpecNodeGen.create(); - case CTX_HASATTR -> GraalHPyHasAttrNodeGen.create(); - case CTX_HASATTR_S -> GraalHPyHasAttrSNodeGen.create(); - case CTX_SETATTR -> GraalHPySetAttrNodeGen.create(); - case CTX_SETATTR_S -> GraalHPySetAttrSNodeGen.create(); - case CTX_GETITEM, CTX_GETITEM_I -> GraalHPyGetItemNodeGen.create(); - case CTX_GETITEM_S -> GraalHPyGetItemSNodeGen.create(); - case CTX_SETITEM, CTX_SETITEM_I -> GraalHPySetItemNodeGen.create(); - case CTX_SETITEM_S -> GraalHPySetItemSNodeGen.create(); - case CTX_DELITEM, CTX_DELITEM_I -> GraalHPyDelItemNodeGen.create(); - case CTX_DELITEM_S -> GraalHPyDelItemSNodeGen.create(); - case CTX_FROMPYOBJECT -> GraalHPyFromPyObjectNodeGen.create(); - case CTX_NEW -> GraalHPyNewNodeGen.create(); - case CTX_ASSTRUCT_OBJECT, CTX_ASSTRUCT_LEGACY, CTX_ASSTRUCT_TYPE, CTX_ASSTRUCT_LONG, CTX_ASSTRUCT_FLOAT, CTX_ASSTRUCT_UNICODE, CTX_ASSTRUCT_TUPLE, CTX_ASSTRUCT_LIST -> GraalHPyCastNodeGen.create(); - case CTX_TYPE_GENERICNEW -> GraalHPyTypeGenericNewNodeGen.create(); - case CTX_ABSOLUTE -> GraalHPyAbsoluteNodeGen.create(); - case CTX_LONG -> GraalHPyLongNodeGen.create(); - case CTX_FLOAT -> GraalHPyFloatNodeGen.create(); - case CTX_STR -> GraalHPyStrNodeGen.create(); - case CTX_REPR -> GraalHPyReprNodeGen.create(); - case CTX_ASCII -> GraalHPyASCIINodeGen.create(); - case CTX_BYTES -> GraalHPyBytesNodeGen.create(); - case CTX_HASH -> GraalHPyHashNodeGen.create(); - case CTX_LENGTH -> GraalHPyLengthNodeGen.create(); - case CTX_RICHCOMPARE -> GraalHPyRichcompareNodeGen.create(); - case CTX_RICHCOMPAREBOOL -> GraalHPyRichcompareBoolNodeGen.create(); - case CTX_INDEX -> GraalHPyAsIndexNodeGen.create(); - case CTX_NUMBER_CHECK -> GraalHPyIsNumberNodeGen.create(); - case CTX_TUPLE_FROMARRAY -> GraalHPyTupleFromArrayNodeGen.create(); - case CTX_TUPLEBUILDER_NEW, CTX_LISTBUILDER_NEW -> GraalHPyBuilderNewNodeGen.create(); - case CTX_TUPLEBUILDER_SET, CTX_LISTBUILDER_SET -> GraalHPyBuilderSetNodeGen.create(); - case CTX_TUPLEBUILDER_BUILD -> GraalHPyTupleBuilderBuildNodeGen.create(); - case CTX_LISTBUILDER_BUILD -> GraalHPyListBuilderBuildNodeGen.create(); - case CTX_TUPLEBUILDER_CANCEL, CTX_LISTBUILDER_CANCEL -> GraalHPyBuilderCancelNodeGen.create(); - case CTX_TRACKER_NEW -> GraalHPyTrackerNewNodeGen.create(); - case CTX_TRACKER_ADD -> GraalHPyTrackerAddNodeGen.create(); - case CTX_TRACKER_CLOSE -> GraalHPyTrackerCleanupNodeGen.create(); - case CTX_TRACKER_FORGETALL -> GraalHPyTrackerForgetAllNodeGen.create(); - case CTX_CALLABLE_CHECK -> GraalHPyIsCallableNodeGen.create(); - case CTX_CALLTUPLEDICT -> GraalHPyCallTupleDictNodeGen.create(); - case CTX_CALL -> GraalHPyCallNodeGen.create(); - case CTX_CALLMETHOD -> GraalHPyCallMethodNodeGen.create(); - case CTX_DUMP -> GraalHPyDumpNodeGen.create(); - case CTX_TYPE -> GraalHPyTypeNodeGen.create(); - case CTX_TYPECHECK -> GraalHPyTypeCheckNodeGen.create(); - case CTX_ERR_NEWEXCEPTIONWITHDOC -> GraalHPyNewExceptionWithDocNodeGen.create(); - case CTX_ERR_NEWEXCEPTION -> GraalHPyNewExceptionNodeGen.create(); - case CTX_IS -> GraalHPyIsNodeGen.create(); - case CTX_IMPORT_IMPORTMODULE -> GraalHPyImportModuleNodeGen.create(); - case CTX_FIELD_STORE -> GraalHPyFieldStoreNodeGen.create(); - case CTX_FIELD_LOAD -> GraalHPyFieldLoadNodeGen.create(); - case CTX_GLOBAL_STORE -> GraalHPyGlobalStoreNodeGen.create(); - case CTX_GLOBAL_LOAD -> GraalHPyGlobalLoadNodeGen.create(); - case CTX_LEAVEPYTHONEXECUTION -> GraalHPyLeavePythonExecutionNodeGen.create(); - case CTX_REENTERPYTHONEXECUTION -> GraalHPyReenterPythonExecutionNodeGen.create(); - case CTX_CONTAINS -> GraalHPyContainsNodeGen.create(); - case CTX_TYPE_ISSUBTYPE -> GraalHPyTypeIsSubtypeNodeGen.create(); - case CTX_TYPE_GETNAME -> GraalHPyTypeGetNameNodeGen.create(); - case CTX_DICT_KEYS -> GraalHPyDictKeysNodeGen.create(); - case CTX_DICT_COPY -> GraalHPyDictCopyNodeGen.create(); - case CTX_CAPSULE_NEW -> GraalHPyCapsuleNewNodeGen.create(); - case CTX_CAPSULE_GET -> GraalHPyCapsuleGetNodeGen.create(); - case CTX_CAPSULE_SET -> GraalHPyCapsuleSetNodeGen.create(); - case CTX_CAPSULE_ISVALID -> GraalHPyCapsuleIsValidNodeGen.create(); - case CTX_CONTEXTVAR_NEW -> GraalHPyContextVarNewNodeGen.create(); - case CTX_CONTEXTVAR_GET -> GraalHPyContextVarGetNodeGen.create(); - case CTX_CONTEXTVAR_SET -> GraalHPyContextVarSetNodeGen.create(); - case CTX_UNICODE_FROMENCODEDOBJECT -> GraalHPyUnicodeFromEncodedObjectNodeGen.create(); - case CTX_UNICODE_SUBSTRING -> GraalHPyUnicodeSubstringNodeGen.create(); - case CTX_SLICE_UNPACK -> GraalHPySliceUnpackNodeGen.create(); - case CTX_TYPE_GETBUILTINSHAPE -> GraalHPyTypeGetBuiltinShapeNodeGen.create(); - case CTX_COMPILE_S -> GraalHPyCompileNodeGen.create(); - case CTX_EVALCODE -> GraalHPyEvalCodeNodeGen.create(); - case CTX_SETCALLFUNCTION -> GraalHPySetCallFunctionNodeGen.create(); - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } - - public static GraalHPyContextFunction getUncached(HPyContextMember member) { - return switch (member) { - case CTX_DUP -> GraalHPyDupNodeGen.getUncached(); - case CTX_CLOSE -> GraalHPyCloseNodeGen.getUncached(); - case CTX_POSITIVE -> GraalHPyPositiveNodeGen.getUncached(); - case CTX_NEGATIVE -> GraalHPyNegativeNodeGen.getUncached(); - case CTX_INVERT -> GraalHPyInvertNodeGen.getUncached(); - case CTX_ADD -> GraalHPyAddNodeGen.getUncached(); - case CTX_SUBTRACT -> GraalHPySubtractNodeGen.getUncached(); - case CTX_MULTIPLY -> GraalHPyMultiplyNodeGen.getUncached(); - case CTX_MATRIXMULTIPLY -> GraalHPyMatrixMultiplyNodeGen.getUncached(); - case CTX_FLOORDIVIDE -> GraalHPyFloorDivideNodeGen.getUncached(); - case CTX_TRUEDIVIDE -> GraalHPyTrueDivideNodeGen.getUncached(); - case CTX_REMAINDER -> GraalHPyRemainderNodeGen.getUncached(); - case CTX_DIVMOD -> GraalHPyDivmodNodeGen.getUncached(); - case CTX_AND -> GraalHPyAndNodeGen.getUncached(); - case CTX_XOR -> GraalHPyXorNodeGen.getUncached(); - case CTX_OR -> GraalHPyOrNodeGen.getUncached(); - case CTX_LSHIFT -> GraalHPyLshiftNodeGen.getUncached(); - case CTX_RSHIFT -> GraalHPyRshiftNodeGen.getUncached(); - case CTX_POWER -> GraalHPyPowerNodeGen.getUncached(); - case CTX_INPLACEADD -> GraalHPyInPlaceAddNodeGen.getUncached(); - case CTX_INPLACESUBTRACT -> GraalHPyInPlaceSubtractNodeGen.getUncached(); - case CTX_INPLACEMULTIPLY -> GraalHPyInPlaceMultiplyNodeGen.getUncached(); - case CTX_INPLACEMATRIXMULTIPLY -> GraalHPyInPlaceMatrixMultiplyNodeGen.getUncached(); - case CTX_INPLACEFLOORDIVIDE -> GraalHPyInPlaceFloorDivideNodeGen.getUncached(); - case CTX_INPLACETRUEDIVIDE -> GraalHPyInPlaceTrueDivideNodeGen.getUncached(); - case CTX_INPLACEREMAINDER -> GraalHPyInPlaceRemainderNodeGen.getUncached(); - case CTX_INPLACEPOWER -> GraalHPyInPlacePowerNodeGen.getUncached(); - case CTX_INPLACELSHIFT -> GraalHPyInPlaceLshiftNodeGen.getUncached(); - case CTX_INPLACERSHIFT -> GraalHPyInPlaceRshiftNodeGen.getUncached(); - case CTX_INPLACEAND -> GraalHPyInPlaceAndNodeGen.getUncached(); - case CTX_INPLACEXOR -> GraalHPyInPlaceXorNodeGen.getUncached(); - case CTX_INPLACEOR -> GraalHPyInPlaceOrNodeGen.getUncached(); - case CTX_BOOL_FROMBOOL -> GraalHPyBoolFromBoolNodeGen.getUncached(); - case CTX_LONG_FROMINT32_T -> GraalHPyLongFromInt32NodeGen.getUncached(); - case CTX_LONG_FROMUINT32_T -> GraalHPyLongFromUInt32NodeGen.getUncached(); - case CTX_LONG_FROMINT64_T, CTX_LONG_FROMSSIZE_T -> GraalHPyLongFromInt64NodeGen.getUncached(); - case CTX_LONG_FROMUINT64_T, CTX_LONG_FROMSIZE_T -> GraalHPyLongFromUInt64NodeGen.getUncached(); - case CTX_LONG_ASINT32_T -> GraalHPyLongAsInt32NodeGen.getUncached(); - case CTX_LONG_ASUINT32_T -> GraalHPyLongAsUInt32NodeGen.getUncached(); - case CTX_LONG_ASUINT32_TMASK -> GraalHPyLongAsUInt32MaskNodeGen.getUncached(); - case CTX_LONG_ASINT64_T -> GraalHPyLongAsInt64NodeGen.getUncached(); - case CTX_LONG_ASUINT64_T, CTX_LONG_ASSIZE_T, CTX_LONG_ASVOIDPTR -> GraalHPyLongAsUInt64NodeGen.getUncached(); - case CTX_LONG_ASUINT64_TMASK -> GraalHPyLongAsUInt64MaskNodeGen.getUncached(); - case CTX_LONG_ASSSIZE_T -> GraalHPyLongAsSsizeTNodeGen.getUncached(); - case CTX_LONG_ASDOUBLE -> GraalHPyLongAsDoubleNodeGen.getUncached(); - case CTX_DICT_NEW -> GraalHPyDictNewNodeGen.getUncached(); - case CTX_LIST_NEW -> GraalHPyListNewNodeGen.getUncached(); - case CTX_LIST_APPEND -> GraalHPyListAppendNodeGen.getUncached(); - case CTX_FLOAT_FROMDOUBLE -> GraalHPyFloatFromDoubleNodeGen.getUncached(); - case CTX_FLOAT_ASDOUBLE -> GraalHPyFloatAsDoubleNodeGen.getUncached(); - case CTX_DICT_CHECK -> GraalHPyDictCheckNodeGen.getUncached(); - case CTX_BYTES_CHECK -> GraalHPyBytesCheckNodeGen.getUncached(); - case CTX_UNICODE_CHECK -> GraalHPyUnicodeCheckNodeGen.getUncached(); - case CTX_TUPLE_CHECK -> GraalHPyTupleCheckNodeGen.getUncached(); - case CTX_LIST_CHECK -> GraalHPyListCheckNodeGen.getUncached(); - case CTX_ERR_NOMEMORY -> GraalHPyErrNoMemoryNodeGen.getUncached(); - case CTX_ERR_SETOBJECT -> GraalHPyErrSetObjectNodeGen.getUncached(); - case CTX_ERR_SETSTRING -> GraalHPyErrSetStringNodeGen.getUncached(); - case CTX_ERR_SETFROMERRNOWITHFILENAME -> GraalHPyErrSetFromErrnoWithFilenameNodeGen.getUncached(); - case CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS -> GraalHPyErrSetFromErrnoWithFilenameObjectsNodeGen.getUncached(); - case CTX_FATALERROR -> GraalHPyFatalErrorNodeGen.getUncached(); - case CTX_ERR_OCCURRED -> GraalHPyErrOccurredNodeGen.getUncached(); - case CTX_ERR_EXCEPTIONMATCHES -> GraalHPyErrExceptionMatchesNodeGen.getUncached(); - case CTX_ERR_CLEAR -> GraalHPyErrClearNodeGen.getUncached(); - case CTX_ERR_WARNEX -> GraalHPyErrWarnExNodeGen.getUncached(); - case CTX_ERR_WRITEUNRAISABLE -> GraalHPyErrWriteUnraisableNodeGen.getUncached(); - case CTX_UNICODE_ASUTF8STRING -> GraalHPyUnicodeAsUTF8StringNodeGen.getUncached(); - case CTX_UNICODE_ASLATIN1STRING -> GraalHPyUnicodeAsLatin1StringNodeGen.getUncached(); - case CTX_UNICODE_ASASCIISTRING -> GraalHPyUnicodeAsASCIIStringNodeGen.getUncached(); - case CTX_UNICODE_ENCODEFSDEFAULT -> GraalHPyUnicodeEncodeFSDefaultNodeGen.getUncached(); - case CTX_UNICODE_ASUTF8ANDSIZE -> GraalHPyUnicodeAsUTF8AndSizeNodeGen.getUncached(); - case CTX_UNICODE_FROMSTRING -> GraalHPyUnicodeFromStringNodeGen.getUncached(); - case CTX_UNICODE_FROMWIDECHAR -> GraalHPyUnicodeFromWcharNodeGen.getUncached(); - case CTX_UNICODE_DECODEFSDEFAULT -> GraalHPyUnicodeDecodeCharsetNodeGen.getUncached(); - case CTX_UNICODE_DECODEFSDEFAULTANDSIZE -> GraalHPyUnicodeDecodeCharsetAndSizeNodeGen.getUncached(); - case CTX_UNICODE_DECODEASCII -> GraalHPyUnicodeDecodeASCIINodeGen.getUncached(); - case CTX_UNICODE_DECODELATIN1 -> GraalHPyUnicodeDecodeLatin1NodeGen.getUncached(); - case CTX_UNICODE_READCHAR -> GraalHPyUnicodeReadCharNodeGen.getUncached(); - case CTX_ASPYOBJECT -> GraalHPyAsPyObjectNodeGen.getUncached(); - case CTX_BYTES_ASSTRING, CTX_BYTES_AS_STRING -> GraalHPyBytesAsStringNodeGen.getUncached(); - case CTX_BYTES_SIZE, CTX_BYTES_GET_SIZE -> GraalHPyBytesGetSizeNodeGen.getUncached(); - case CTX_BYTES_FROMSTRING -> GraalHPyBytesFromStringNodeGen.getUncached(); - case CTX_BYTES_FROMSTRINGANDSIZE -> GraalHPyBytesFromStringAndSizeNodeGen.getUncached(); - case CTX_ISTRUE -> GraalHPyIsTrueNodeGen.getUncached(); - case CTX_GETATTR -> GraalHPyGetAttrNodeGen.getUncached(); - case CTX_GETATTR_S -> GraalHPyGetAttrSNodeGen.getUncached(); - case CTX_TYPE_FROMSPEC -> GraalHPyTypeFromSpecNodeGen.getUncached(); - case CTX_HASATTR -> GraalHPyHasAttrNodeGen.getUncached(); - case CTX_HASATTR_S -> GraalHPyHasAttrSNodeGen.getUncached(); - case CTX_SETATTR -> GraalHPySetAttrNodeGen.getUncached(); - case CTX_SETATTR_S -> GraalHPySetAttrSNodeGen.getUncached(); - case CTX_GETITEM, CTX_GETITEM_I -> GraalHPyGetItemNodeGen.getUncached(); - case CTX_GETITEM_S -> GraalHPyGetItemSNodeGen.getUncached(); - case CTX_SETITEM, CTX_SETITEM_I -> GraalHPySetItemNodeGen.getUncached(); - case CTX_SETITEM_S -> GraalHPySetItemSNodeGen.getUncached(); - case CTX_DELITEM, CTX_DELITEM_I -> GraalHPyDelItemNodeGen.getUncached(); - case CTX_DELITEM_S -> GraalHPyDelItemSNodeGen.getUncached(); - case CTX_FROMPYOBJECT -> GraalHPyFromPyObjectNodeGen.getUncached(); - case CTX_NEW -> GraalHPyNewNodeGen.getUncached(); - case CTX_ASSTRUCT_OBJECT, CTX_ASSTRUCT_LEGACY, CTX_ASSTRUCT_TYPE, CTX_ASSTRUCT_LONG, CTX_ASSTRUCT_FLOAT, CTX_ASSTRUCT_UNICODE, CTX_ASSTRUCT_TUPLE, CTX_ASSTRUCT_LIST -> GraalHPyCastNodeGen.getUncached(); - case CTX_TYPE_GENERICNEW -> GraalHPyTypeGenericNewNodeGen.getUncached(); - case CTX_ABSOLUTE -> GraalHPyAbsoluteNodeGen.getUncached(); - case CTX_LONG -> GraalHPyLongNodeGen.getUncached(); - case CTX_FLOAT -> GraalHPyFloatNodeGen.getUncached(); - case CTX_STR -> GraalHPyStrNodeGen.getUncached(); - case CTX_REPR -> GraalHPyReprNodeGen.getUncached(); - case CTX_ASCII -> GraalHPyASCIINodeGen.getUncached(); - case CTX_BYTES -> GraalHPyBytesNodeGen.getUncached(); - case CTX_HASH -> GraalHPyHashNodeGen.getUncached(); - case CTX_LENGTH -> GraalHPyLengthNodeGen.getUncached(); - case CTX_RICHCOMPARE -> GraalHPyRichcompareNodeGen.getUncached(); - case CTX_RICHCOMPAREBOOL -> GraalHPyRichcompareBoolNodeGen.getUncached(); - case CTX_INDEX -> GraalHPyAsIndexNodeGen.getUncached(); - case CTX_NUMBER_CHECK -> GraalHPyIsNumberNodeGen.getUncached(); - case CTX_TUPLE_FROMARRAY -> GraalHPyTupleFromArrayNodeGen.getUncached(); - case CTX_TUPLEBUILDER_NEW, CTX_LISTBUILDER_NEW -> GraalHPyBuilderNewNodeGen.getUncached(); - case CTX_TUPLEBUILDER_SET, CTX_LISTBUILDER_SET -> GraalHPyBuilderSetNodeGen.getUncached(); - case CTX_TUPLEBUILDER_BUILD -> GraalHPyTupleBuilderBuildNodeGen.getUncached(); - case CTX_LISTBUILDER_BUILD -> GraalHPyListBuilderBuildNodeGen.getUncached(); - case CTX_TUPLEBUILDER_CANCEL, CTX_LISTBUILDER_CANCEL -> GraalHPyBuilderCancelNodeGen.getUncached(); - case CTX_TRACKER_NEW -> GraalHPyTrackerNewNodeGen.getUncached(); - case CTX_TRACKER_ADD -> GraalHPyTrackerAddNodeGen.getUncached(); - case CTX_TRACKER_CLOSE -> GraalHPyTrackerCleanupNodeGen.getUncached(); - case CTX_TRACKER_FORGETALL -> GraalHPyTrackerForgetAllNodeGen.getUncached(); - case CTX_CALLABLE_CHECK -> GraalHPyIsCallableNodeGen.getUncached(); - case CTX_CALLTUPLEDICT -> GraalHPyCallTupleDictNodeGen.getUncached(); - case CTX_CALL -> GraalHPyCallNodeGen.getUncached(); - case CTX_CALLMETHOD -> GraalHPyCallMethodNodeGen.getUncached(); - case CTX_DUMP -> GraalHPyDumpNodeGen.getUncached(); - case CTX_TYPE -> GraalHPyTypeNodeGen.getUncached(); - case CTX_TYPECHECK -> GraalHPyTypeCheckNodeGen.getUncached(); - case CTX_ERR_NEWEXCEPTIONWITHDOC -> GraalHPyNewExceptionWithDocNodeGen.getUncached(); - case CTX_ERR_NEWEXCEPTION -> GraalHPyNewExceptionNodeGen.getUncached(); - case CTX_IS -> GraalHPyIsNodeGen.getUncached(); - case CTX_IMPORT_IMPORTMODULE -> GraalHPyImportModuleNodeGen.getUncached(); - case CTX_FIELD_STORE -> GraalHPyFieldStoreNodeGen.getUncached(); - case CTX_FIELD_LOAD -> GraalHPyFieldLoadNodeGen.getUncached(); - case CTX_GLOBAL_STORE -> GraalHPyGlobalStoreNodeGen.getUncached(); - case CTX_GLOBAL_LOAD -> GraalHPyGlobalLoadNodeGen.getUncached(); - case CTX_LEAVEPYTHONEXECUTION -> GraalHPyLeavePythonExecutionNodeGen.getUncached(); - case CTX_REENTERPYTHONEXECUTION -> GraalHPyReenterPythonExecutionNodeGen.getUncached(); - case CTX_CONTAINS -> GraalHPyContainsNodeGen.getUncached(); - case CTX_TYPE_ISSUBTYPE -> GraalHPyTypeIsSubtypeNodeGen.getUncached(); - case CTX_TYPE_GETNAME -> GraalHPyTypeGetNameNodeGen.getUncached(); - case CTX_DICT_KEYS -> GraalHPyDictKeysNodeGen.getUncached(); - case CTX_DICT_COPY -> GraalHPyDictCopyNodeGen.getUncached(); - case CTX_CAPSULE_NEW -> GraalHPyCapsuleNewNodeGen.getUncached(); - case CTX_CAPSULE_GET -> GraalHPyCapsuleGetNodeGen.getUncached(); - case CTX_CAPSULE_SET -> GraalHPyCapsuleSetNodeGen.getUncached(); - case CTX_CAPSULE_ISVALID -> GraalHPyCapsuleIsValidNodeGen.getUncached(); - case CTX_CONTEXTVAR_NEW -> GraalHPyContextVarNewNodeGen.getUncached(); - case CTX_CONTEXTVAR_GET -> GraalHPyContextVarGetNodeGen.getUncached(); - case CTX_CONTEXTVAR_SET -> GraalHPyContextVarSetNodeGen.getUncached(); - case CTX_UNICODE_FROMENCODEDOBJECT -> GraalHPyUnicodeFromEncodedObjectNodeGen.getUncached(); - case CTX_UNICODE_SUBSTRING -> GraalHPyUnicodeSubstringNodeGen.getUncached(); - case CTX_SLICE_UNPACK -> GraalHPySliceUnpackNodeGen.getUncached(); - case CTX_TYPE_GETBUILTINSHAPE -> GraalHPyTypeGetBuiltinShapeNodeGen.getUncached(); - case CTX_COMPILE_S -> GraalHPyCompileNodeGen.getUncached(); - case CTX_EVALCODE -> GraalHPyEvalCodeNodeGen.getUncached(); - case CTX_SETCALLFUNCTION -> GraalHPySetCallFunctionNodeGen.getUncached(); - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } - - // @formatter:on - // Checkstyle: resume - // {{end ctx func factory}} - } - - public abstract static class HPyUnaryContextFunction extends GraalHPyContextFunction { - public abstract Object execute(Object arg0); - - @Override - public final Object execute(Object[] args) { - return execute(args[0]); - } - } - - public abstract static class HPyBinaryContextFunction extends GraalHPyContextFunction { - public abstract Object execute(Object arg0, Object arg1); - - @Override - public final Object execute(Object[] args) { - return execute(args[0], args[1]); - } - } - - public abstract static class HPyTernaryContextFunction extends GraalHPyContextFunction { - public abstract Object execute(Object arg0, Object arg1, Object arg2); - - @Override - public final Object execute(Object[] args) { - return execute(args[0], args[1], args[2]); - } - } - - public abstract static class HPyQuaternaryContextFunction extends GraalHPyContextFunction { - public abstract Object execute(Object arg0, Object arg1, Object arg2, Object arg3); - - @Override - public final Object execute(Object[] args) { - return execute(args[0], args[1], args[2], args[3]); - } - } - - public abstract static class HPy5ContextFunction extends GraalHPyContextFunction { - public abstract Object execute(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4); - - @Override - public final Object execute(Object[] args) { - return execute(args[0], args[1], args[2], args[3], args[4]); - } - } - - @HPyContextFunction("ctx_Dup") - @GenerateUncached - public abstract static class GraalHPyDup extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object) { - return object; - } - } - - @HPyContextFunction("ctx_Close") - @GenerateUncached - public abstract static class GraalHPyClose extends HPyBinaryContextFunction { - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object handle, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeHandleNode) { - closeHandleNode.execute(inliningTarget, handle); - return 0; - } - } - - @HPyContextFunction("ctx_Positive") - @GenerateUncached - public abstract static class GraalHPyPositive extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached PyNumberPositiveNode arithmeticNode) { - return arithmeticNode.execute(null, arg); - } - } - - @HPyContextFunction("ctx_Negative") - @GenerateUncached - public abstract static class GraalHPyNegative extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached PyNumberNegativeNode arithmeticNode) { - return arithmeticNode.execute(null, arg); - } - } - - @HPyContextFunction("ctx_Invert") - @GenerateUncached - public abstract static class GraalHPyInvert extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Cached PyNumberInvertNode arithmeticNode) { - return arithmeticNode.execute(null, arg); - } - } - - @HPyContextFunction("ctx_Add") - @GenerateUncached - public abstract static class GraalHPyAdd extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberAddNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Subtract") - @GenerateUncached - public abstract static class GraalHPySubtract extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberSubtractNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Multiply") - @GenerateUncached - public abstract static class GraalHPyMultiply extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberMultiplyNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_MatrixMultiply") - @GenerateUncached - public abstract static class GraalHPyMatrixMultiply extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberMatrixMultiplyNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_FloorDivide") - @GenerateUncached - public abstract static class GraalHPyFloorDivide extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberFloorDivideNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_TrueDivide") - @GenerateUncached - public abstract static class GraalHPyTrueDivide extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberTrueDivideNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Remainder") - @GenerateUncached - public abstract static class GraalHPyRemainder extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberRemainderNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Divmod") - @GenerateUncached - public abstract static class GraalHPyDivmod extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberDivmodNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_And") - @GenerateUncached - public abstract static class GraalHPyAnd extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberAndNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Xor") - @GenerateUncached - public abstract static class GraalHPyXor extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberXorNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Or") - @GenerateUncached - public abstract static class GraalHPyOr extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberOrNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Lshift") - @GenerateUncached - public abstract static class GraalHPyLshift extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberLshiftNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Rshift") - @GenerateUncached - public abstract static class GraalHPyRshift extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberRshiftNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Power") - @GenerateUncached - public abstract static class GraalHPyPower extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, Object arg2, - @Cached PyNumberPowerNode powerNode) { - return powerNode.execute(null, arg0, arg1, arg2); - } - } - - @HPyContextFunction("ctx_InPlaceAdd") - @GenerateUncached - public abstract static class GraalHPyInPlaceAdd extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceAddNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceSubtract") - @GenerateUncached - public abstract static class GraalHPyInPlaceSubtract extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceSubtractNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceMultiply") - @GenerateUncached - public abstract static class GraalHPyInPlaceMultiply extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceMultiplyNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceMatrixMultiply") - @GenerateUncached - public abstract static class GraalHPyInPlaceMatrixMultiply extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceMatrixMultiplyNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceFloorDivide") - @GenerateUncached - public abstract static class GraalHPyInPlaceFloorDivide extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceFloorDivideNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceTrueDivide") - @GenerateUncached - public abstract static class GraalHPyInPlaceTrueDivide extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceTrueDivideNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceRemainder") - @GenerateUncached - public abstract static class GraalHPyInPlaceRemainder extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceRemainderNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlacePower") - @GenerateUncached - public abstract static class GraalHPyInPlacePower extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, Object arg2, - @Cached PyNumberInPlacePowerNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1, arg2); - } - } - - @HPyContextFunction("ctx_InPlaceLshift") - @GenerateUncached - public abstract static class GraalHPyInPlaceLshift extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceLshiftNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceRshift") - @GenerateUncached - public abstract static class GraalHPyInPlaceRshift extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceRshiftNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceAnd") - @GenerateUncached - public abstract static class GraalHPyInPlaceAnd extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceAndNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceXor") - @GenerateUncached - public abstract static class GraalHPyInPlaceXor extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceXorNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_InPlaceOr") - @GenerateUncached - public abstract static class GraalHPyInPlaceOr extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg0, Object arg1, - @Cached PyNumberInPlaceOrNode arithmeticNode) { - return arithmeticNode.execute(null, arg0, arg1); - } - } - - @HPyContextFunction("ctx_Bool_FromBool") - @GenerateUncached - public abstract static class GraalHPyBoolFromBool extends HPyBinaryContextFunction { - - @Specialization - static PInt doBoolean(GraalHPyContext hpyContext, boolean value) { - Python3Core core = hpyContext.getContext(); - return value ? core.getTrue() : core.getFalse(); - } - - @Specialization - static PInt doByte(GraalHPyContext hpyContext, byte value) { - return doBoolean(hpyContext, value != 0); - } - } - - @HPyContextFunction("ctx_Long_FromInt32_t") - @GenerateUncached - public abstract static class GraalHPyLongFromInt32 extends HPyBinaryContextFunction { - - @Specialization - static Object doInt(@SuppressWarnings("unused") Object hpyContext, int value, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLongFromLong fromLongNode) { - return fromLongNode.execute(inliningTarget, value, true); - } - - @Specialization - static Object doLong(@SuppressWarnings("unused") Object hpyContext, long value, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLongFromLong fromLongNode) { - return fromLongNode.execute(inliningTarget, value, true); - } - } - - @HPyContextFunction("ctx_Long_FromUInt32_t") - @GenerateUncached - public abstract static class GraalHPyLongFromUInt32 extends HPyBinaryContextFunction { - - @Specialization - static Object doInt(@SuppressWarnings("unused") Object hpyContext, int value, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyLongFromLong fromLongNode) { - return fromLongNode.execute(inliningTarget, value, false); - } - - @Specialization - static Object doLong(Object hpyContext, long value, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyLongFromLong fromLongNode) { - return doInt(hpyContext, (int) value, inliningTarget, fromLongNode); - } - } - - @HPyContextFunction("ctx_Long_FromInt64_t") - @HPyContextFunction("ctx_Long_FromSsize_t") - @GenerateUncached - public abstract static class GraalHPyLongFromInt64 extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, long value, - @Bind("this") Node inliningTarget, - @Cached HPyLongFromLong fromLongNode) { - return fromLongNode.execute(inliningTarget, value, true); - } - } - - @HPyContextFunction("ctx_Long_FromUInt64_t") - @HPyContextFunction("ctx_Long_FromSize_t") - @GenerateUncached - public abstract static class GraalHPyLongFromUInt64 extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, long value, - @Bind("this") Node inliningTarget, - @Cached HPyLongFromLong fromLongNode) { - return fromLongNode.execute(inliningTarget, value, false); - } - } - - private static final int SIZEOF_INT32 = 4; - private static final int SIZEOF_INT64 = 8; - private static final int SIZEOF_INTPTR = 8; - - @HPyContextFunction("ctx_Long_AsInt32_t") - @GenerateUncached - public abstract static class GraalHPyLongAsInt32 extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - return asNativePrimitiveNode.execute(object, 1, SIZEOF_INT32, true); - } - } - - @HPyContextFunction("ctx_Long_AsUInt32_t") - @GenerateUncached - public abstract static class GraalHPyLongAsUInt32 extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); - } - return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT32, true); - } - } - - @HPyContextFunction("ctx_Long_AsUInt32_tMask") - @GenerateUncached - public abstract static class GraalHPyLongAsUInt32Mask extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT32, false); - } - } - - @HPyContextFunction("ctx_Long_AsInt64_t") - @GenerateUncached - public abstract static class GraalHPyLongAsInt64 extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - return asNativePrimitiveNode.execute(object, 1, SIZEOF_INT64, true); - } - } - - @HPyContextFunction("ctx_Long_AsUInt64_t") - @HPyContextFunction("ctx_Long_AsSize_t") - @HPyContextFunction("ctx_Long_AsVoidPtr") - @GenerateUncached - public abstract static class GraalHPyLongAsUInt64 extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); - } - return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT64, true); - } - } - - @HPyContextFunction("ctx_Long_AsUInt64_tMask") - @GenerateUncached - public abstract static class GraalHPyLongAsUInt64Mask extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - return asNativePrimitiveNode.execute(object, 0, SIZEOF_INT64, false); - } - } - - @HPyContextFunction("ctx_Long_AsSsize_t") - @GenerateUncached - public abstract static class GraalHPyLongAsSsizeT extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unusued") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached PRaiseNode raiseNode, - @Cached AsNativePrimitiveNode asNativePrimitiveNode) { - if (!isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PInt)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INTEGER_REQUIRED); - } - return asNativePrimitiveNode.execute(object, 1, SIZEOF_INTPTR, true); - } - } - - @HPyContextFunction("ctx_Long_AsDouble") - @GenerateUncached - public abstract static class GraalHPyLongAsDouble extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object arg, - @Bind("this") Node inliningTarget, - @Cached PyLongAsDoubleNode asDoubleNode) { - return asDoubleNode.execute(inliningTarget, arg); - } - } - - @HPyContextFunction("ctx_Dict_New") - @GenerateUncached - public abstract static class GraalHPyDictNew extends HPyUnaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, - @Bind("this") Node inliningTarget) { - return PFactory.createDict(hpyContext.getContext().getLanguage(inliningTarget)); - } - } - - @HPyContextFunction("ctx_List_New") - @GenerateUncached - public abstract static class GraalHPyListNew extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, long len, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode) { - try { - Object[] data = new Object[PInt.intValueExact(len)]; - // TODO(fa) maybe this should be NO_VALUE (representing native 'NULL') - Arrays.fill(data, PNone.NONE); - return PFactory.createList(hpyContext.getContext().getLanguage(inliningTarget), data); - } catch (OverflowException e) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.MemoryError); - } - } - } - - @HPyContextFunction("ctx_List_Append") - @GenerateUncached - public abstract static class GraalHPyListAppend extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object left, Object value, - @Bind("this") Node inliningTarget, - @Cached ListNodes.AppendNode appendNode, - @Cached PRaiseNode raiseNode) { - if (!PGuards.isList(left)) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_INTERNAL_CALL); - } - appendNode.execute((PList) left, value); - return 0; - } - } - - @HPyContextFunction("ctx_Float_FromDouble") - @GenerateUncached - public abstract static class GraalHPyFloatFromDouble extends HPyBinaryContextFunction { - - @Specialization - static double doGeneric(@SuppressWarnings("unused") Object hpyContext, double value) { - return value; - } - } - - @HPyContextFunction("ctx_Float_AsDouble") - @GenerateUncached - public abstract static class GraalHPyFloatAsDouble extends HPyBinaryContextFunction { - - @Specialization - static double doGeneric(@SuppressWarnings("unused") Object hpyContext, Object value, - @Bind("this") Node inliningTarget, - @Cached PyFloatAsDoubleNode asDoubleNode) { - return asDoubleNode.execute(null, inliningTarget, value); - } - } - - abstract static class HPyCheckBuiltinType extends HPyBinaryContextFunction { - - abstract PythonBuiltinClassType getExpectedType(); - - } - - @HPyContextFunction("ctx_Dict_Check") - @GenerateUncached - public abstract static class GraalHPyDictCheck extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PDict)); - } - } - - @HPyContextFunction("ctx_Bytes_Check") - @GenerateUncached - public abstract static class GraalHPyBytesCheck extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PBytes)); - } - } - - @HPyContextFunction("ctx_Unicode_Check") - @GenerateUncached - public abstract static class GraalHPyUnicodeCheck extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PString)); - } - } - - @HPyContextFunction("ctx_Tuple_Check") - @GenerateUncached - public abstract static class GraalHPyTupleCheck extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PTuple)); - } - } - - @HPyContextFunction("ctx_List_Check") - @GenerateUncached - public abstract static class GraalHPyListCheck extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), PythonBuiltinClassType.PList)); - } - } - - @HPyContextFunction("ctx_Err_NoMemory") - @GenerateUncached - public abstract static class GraalHPyErrNoMemory extends HPyUnaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.MemoryError); - } - } - - @HPyContextFunction("ctx_Err_SetObject") - @GenerateUncached - public abstract static class GraalHPyErrSetObject extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object errTypeObj, Object valueObj, - @Bind("this") Node inliningTarget, - @Cached IsSubtypeNode isSubtypeNode, - @Cached IsSubtypeNode isExcValueSubtypeNode, - @Cached GetClassNode getClassNode, - @Cached CallNode callExceptionConstructorNode, - @Cached PyExceptionInstanceCheckNode exceptionCheckNode, - @Cached PRaiseNode raiseNode) { - if (!(PGuards.isPythonClass(errTypeObj) && isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException))) { - return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); - } - Object exception; - // If the exception value is already an exception object, just take it. - if (isExcValueSubtypeNode.execute(getClassNode.execute(inliningTarget, valueObj), PythonBuiltinClassType.PBaseException)) { - exception = valueObj; - } else { - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, valueObj); - } - - if (exceptionCheckNode.execute(inliningTarget, exception)) { - throw raiseNode.raiseExceptionObject(exception); - } - // This should really not happen since we did a type check above but in theory, - // the constructor could be broken. - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_Err_SetString") - @GenerateUncached - public abstract static class GraalHPyErrSetString extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object errTypeObj, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached CallNode callExceptionConstructorNode, - @Cached PyExceptionInstanceCheckNode exceptionCheckNode, - @Cached PRaiseNode raiseNode) { - if (!(PGuards.isPythonClass(errTypeObj) && isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException))) { - return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); - } - Object exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, fromCharPointerNode.execute(charPtr)); - - if (exceptionCheckNode.execute(isSubtypeNode, exception)) { - throw raiseNode.raiseExceptionObject(exception); - } - // This should really not happen since we did a type check above but in theory, - // the constructor could be broken. - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_Err_SetFromErrnoWithFilename") - @GenerateUncached - public abstract static class GraalHPyErrSetFromErrnoWithFilename extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object errTypeObj, Object errMessagePtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "hpyContext") HPyCallHelperFunctionNode callHelperFunctionNode, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached CallNode callExceptionConstructorNode, - @Cached PyExceptionInstanceCheckNode exceptionCheckNode, - @Cached PRaiseNode raiseNode) { - Object i = callHelperFunctionNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_ERRNO); - Object message = fromCharPointerNode.execute(hpyContext, callHelperFunctionNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_STRERROR, i), true); - if (!isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException)) { - return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); - } - Object exception = null; - if (!isNullNode.execute(hpyContext, errMessagePtr)) { - TruffleString filename_fsencoded = fromCharPointerNode.execute(hpyContext, errMessagePtr, true); - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, i, message, filename_fsencoded); - } - - if (exception == null) { - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, i, message); - } - - if (exceptionCheckNode.execute(inliningTarget, exception)) { - throw raiseNode.raiseExceptionObject(exception); - } - // This should really not happen since we did a type check above but in theory, - // the constructor could be broken. - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_Err_SetFromErrnoWithFilenameObjects") - @GenerateUncached - public abstract static class GraalHPyErrSetFromErrnoWithFilenameObjects extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object errTypeObj, Object filenameObject1, Object filenameObject2, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") HPyCallHelperFunctionNode callHelperNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached IsSubtypeNode isSubtypeNode, - @Cached CallNode callExceptionConstructorNode, - @Cached PyExceptionInstanceCheckNode exceptionCheckNode, - @Cached PRaiseNode raiseNode) { - Object i = callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_ERRNO); - Object message = fromCharPointerNode.execute(callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_GET_STRERROR, i)); - if (!isSubtypeNode.execute(errTypeObj, PythonBuiltinClassType.PBaseException)) { - return raiseNode.raise(inliningTarget, SystemError, ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION, errTypeObj); - } - Object exception = null; - if (filenameObject1 != NULL_HANDLE_DELEGATE) { - if (filenameObject2 != NULL_HANDLE_DELEGATE) { - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, i, message, filenameObject1, 0, filenameObject2); - } else { - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, i, message, filenameObject1); - } - } - - if (exception == null) { - exception = callExceptionConstructorNode.executeWithoutFrame(errTypeObj, i, message); - } - - if (exceptionCheckNode.execute(inliningTarget, exception)) { - throw raiseNode.raiseExceptionObject(exception); - } - // This should really not happen since we did a type check above but in theory, - // the constructor could be broken. - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_FatalError") - @GenerateUncached - public abstract static class GraalHPyFatalError extends HPyBinaryContextFunction { - @TruffleBoundary - @Specialization - Object doGeneric(GraalHPyContext hpyContext, Object charPtr) { - TruffleString errorMessage; - if (GraalHPyCAccess.IsNullNode.getUncached(hpyContext).execute(hpyContext, charPtr)) { - errorMessage = ErrorMessages.MSG_NOT_SET; - } else { - // we don't need to copy the bytes since we die anyway - errorMessage = FromCharPointerNodeGen.getUncached().execute(charPtr, false); - } - CExtCommonNodes.fatalError(this, hpyContext.getContext(), null, errorMessage, -1); - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_Err_Occurred") - @GenerateUncached - public abstract static class GraalHPyErrOccurred extends HPyUnaryContextFunction { - - @Specialization - static int doGeneric(GraalHPyContext hpyContext, - @Bind("this") Node inliningTarget, - @Cached GetThreadStateNode getThreadStateNode) { - return getThreadStateNode.execute(inliningTarget, hpyContext.getContext()).getCurrentException() != null ? 1 : 0; - } - } - - @HPyContextFunction("ctx_Err_ExceptionMatches") - @GenerateUncached - public abstract static class GraalHPyErrExceptionMatches extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object exc, - @Bind("this") Node inliningTarget, - @Cached GetThreadStateNode getThreadStateNode, - @Cached GetUnreifiedExceptionNode getUnreifiedExceptionNode, - @Cached RecursiveExceptionMatches exceptionMatches) { - AbstractTruffleException err = getThreadStateNode.execute(inliningTarget, hpyContext.getContext()).getCurrentException(); - if (err == null) { - return 0; - } - if (exc == NULL_HANDLE_DELEGATE) { - return 0; - } - Object exceptionObject = getUnreifiedExceptionNode.execute(inliningTarget, err); - return exceptionMatches.execute(hpyContext, exceptionObject, exc); - } - } - - @HPyContextFunction("ctx_Err_Clear") - @GenerateUncached - public abstract static class GraalHPyErrClear extends HPyUnaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, - @Bind("this") Node inliningTarget, - @Cached GetThreadStateNode getThreadStateNode, - @Cached ClearCurrentExceptionNode clearCurrentExceptionNode) { - PythonThreadState threadState = getThreadStateNode.execute(inliningTarget, hpyContext.getContext()); - clearCurrentExceptionNode.execute(inliningTarget, threadState); - return NULL_HANDLE_DELEGATE; - } - } - - @HPyContextFunction("ctx_Err_WarnEx") - @GenerateUncached - public abstract static class GraalHPyErrWarnEx extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(GraalHPyContext hpyContext, Object categoryArg, Object messageArg, long stackLevel, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached WarnNode warnNode) { - Object category = categoryArg == NULL_HANDLE_DELEGATE ? RuntimeWarning : categoryArg; - TruffleString message = isNullNode.execute(hpyContext, messageArg) ? T_EMPTY_STRING : fromCharPointerNode.execute(messageArg); - warnNode.warnEx(null, category, message, (int) stackLevel); - return 0; - } - } - - @HPyContextFunction("ctx_Err_WriteUnraisable") - @GenerateUncached - public abstract static class GraalHPyErrWriteUnraisable extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetThreadStateNode getThreadStateNode, - @Cached WriteUnraisableNode writeUnraisableNode, - @Cached GetEscapedExceptionNode getEscapedExceptionNode, - @Cached ClearCurrentExceptionNode clearCurrentExceptionNode) { - PythonThreadState threadState = getThreadStateNode.execute(inliningTarget, hpyContext.getContext()); - AbstractTruffleException exception = threadState.getCurrentException(); - clearCurrentExceptionNode.execute(inliningTarget, threadState); - Object exceptionObject = getEscapedExceptionNode.execute(inliningTarget, exception); - writeUnraisableNode.execute(null, exceptionObject, null, (object instanceof PNone) ? PNone.NONE : object); - return 0; // void - } - } - - @HPyContextFunction("ctx_Unicode_AsUTF8String") - @GenerateUncached - public abstract static class GraalHPyUnicodeAsUTF8String extends HPyBinaryContextFunction { - - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, - @Bind("this") Node inliningTarget, - @Cached EncodeNativeStringNode encodeNativeStringNode) { - return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.UTF_8, unicodeObject, T_STRICT)); - } - } - - @HPyContextFunction("ctx_Unicode_AsLatin1String") - @GenerateUncached - public abstract static class GraalHPyUnicodeAsLatin1String extends HPyBinaryContextFunction { - - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, - @Bind("this") Node inliningTarget, - @Cached EncodeNativeStringNode encodeNativeStringNode) { - return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.ISO_8859_1, unicodeObject, T_STRICT)); - } - } - - @HPyContextFunction("ctx_Unicode_AsASCIIString") - @GenerateUncached - public abstract static class GraalHPyUnicodeAsASCIIString extends HPyBinaryContextFunction { - - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, - @Bind("this") Node inliningTarget, - @Cached EncodeNativeStringNode encodeNativeStringNode) { - return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(StandardCharsets.US_ASCII, unicodeObject, T_STRICT)); - } - } - - @HPyContextFunction("ctx_Unicode_EncodeFSDefault") - @GenerateUncached - public abstract static class GraalHPyUnicodeEncodeFSDefault extends HPyBinaryContextFunction { - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object unicodeObject, - @Bind("this") Node inliningTarget, - @Cached EncodeNativeStringNode encodeNativeStringNode) { - return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), encodeNativeStringNode.execute(getFSDefaultCharset(), unicodeObject, T_STRICT)); - } - - @TruffleBoundary - public static Charset getFSDefaultCharset() { - TruffleString normalizedEncoding = CharsetMapping.normalizeUncached(GetFileSystemEncodingNode.getFileSystemEncoding()); - return CharsetMapping.getCharsetNormalized(normalizedEncoding); - } - } - - @HPyContextFunction("ctx_Unicode_AsUTF8AndSize") - @GenerateUncached - public abstract static class GraalHPyUnicodeAsUTF8AndSize extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object unicodeObject, Object sizePtr, - @Bind("this") Node inliningTarget, - @Cached CastToTruffleStringNode castToTruffleStringNode, - @Cached PRaiseNode raiseNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WriteSizeTNode writeSizeTNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode) { - TruffleString tsUtf8; - try { - tsUtf8 = switchEncodingNode.execute(castToTruffleStringNode.execute(inliningTarget, unicodeObject), Encoding.UTF_8); - } catch (CannotCastException e) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); - } - InternalByteArray internalByteArray = getInternalByteArrayNode.execute(tsUtf8, Encoding.UTF_8); - if (!isNullNode.execute(hpyContext, sizePtr)) { - writeSizeTNode.write(hpyContext, sizePtr, internalByteArray.getLength()); - } - return new CByteArrayWrapper(internalByteArray.getArray()); - } - } - - @HPyContextFunction("ctx_Unicode_FromString") - @GenerateUncached - public abstract static class GraalHPyUnicodeFromString extends HPyBinaryContextFunction { - - @Specialization - static TruffleString doGeneric(@SuppressWarnings("unused") Object hpyContext, Object charPtr, - @Cached FromCharPointerNode fromCharPointerNode) { - if (charPtr instanceof TruffleString ts) { - return ts; - } - return fromCharPointerNode.execute(charPtr); - } - } - - @HPyContextFunction("ctx_Unicode_FromWideChar") - @GenerateUncached - public abstract static class GraalHPyUnicodeFromWchar extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object wcharPtr, long len, - @Bind("this") Node inliningTarget, - @Cached ReadUnicodeArrayNode readArray, - @Cached TruffleString.FromIntArrayUTF32Node fromArray) { - try { - return fromArray.execute(readArray.execute(inliningTarget, wcharPtr, PInt.intValueExact(len), CStructs.wchar_t.size())); - } catch (OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - } - - @HPyContextFunction("ctx_Unicode_DecodeFSDefault") - @GenerateUncached - public abstract static class GraalHPyUnicodeDecodeCharset extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object charPtr, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode) { - return fromCharPointerNode.execute(hpyContext, charPtr, getFSDefault()); - } - - @TruffleBoundary - static Encoding getFSDefault() { - String fileEncoding = System.getProperty("file.encoding"); - if (fileEncoding != null) { - try { - return Encoding.valueOf(fileEncoding.replace('-', '_')); - } catch (IllegalArgumentException e) { - // avoid any fatal Java exceptions; fall through - } - } - // fall back to UTF-8 - return Encoding.UTF_8; - } - } - - @HPyContextFunction("ctx_Unicode_DecodeFSDefaultAndSize") - @GenerateUncached - public abstract static class GraalHPyUnicodeDecodeCharsetAndSize extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object charPtr, long lsize, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode) { - Encoding fsDefault = GraalHPyUnicodeDecodeCharset.getFSDefault(); - try { - return fromCharPointerNode.execute(hpyContext, charPtr, PInt.intValueExact(lsize), fsDefault, true); - } catch (OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - } - - @HPyContextFunction("ctx_Unicode_DecodeASCII") - @GenerateUncached - public abstract static class GraalHPyUnicodeDecodeASCII extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object charPtr, long size, Object errorsPtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, - @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PRaiseNode raiseNode, - @Cached TruffleString.EqualNode equalNode) { - CodingErrorAction errorAction; - if (isNullNode.execute(hpyContext, errorsPtr)) { - errorAction = CodingErrorAction.REPORT; - } else { - TruffleString errors = fromCharPointerNode.execute(hpyContext, errorsPtr, false); - errorAction = CodecsModuleBuiltins.convertCodingErrorAction(errors, equalNode); - } - byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, size); - String decoded = decode(StandardCharsets.US_ASCII, errorAction, bytes); - if (decoded != null) { - return fromJavaStringNode.execute(decoded, TS_ENCODING); - } - // TODO: refactor helper nodes for CodecsModuleBuiltins to use them here - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.UnicodeDecodeError, ErrorMessages.MALFORMED_INPUT); - } - - @TruffleBoundary - static String decode(Charset charset, CodingErrorAction errorAction, byte[] bytes) { - try { - return charset.newDecoder().onMalformedInput(errorAction).onUnmappableCharacter(errorAction).decode(ByteBuffer.wrap(bytes)).toString(); - } catch (CharacterCodingException ex) { - return null; - } - } - } - - @HPyContextFunction("ctx_Unicode_DecodeLatin1") - @GenerateUncached - public abstract static class GraalHPyUnicodeDecodeLatin1 extends HPyQuaternaryContextFunction { - - @Specialization - Object doGeneric(GraalHPyContext hpyContext, Object charPtr, long lsize, @SuppressWarnings("unused") Object errorsPtr, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode) { - if (PInt.isIntRange(lsize)) { - /* - * If we have ISO-8859-1, we can just force the encoding and short-circuit the error - * reading etc since there cannot be an invalid byte - */ - return fromCharPointerNode.execute(hpyContext, charPtr, (int) lsize, Encoding.ISO_8859_1, true); - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @HPyContextFunction("ctx_Unicode_ReadChar") - @GenerateUncached - public abstract static class GraalHPyUnicodeReadChar extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object unicodeObject, long index, - @Bind("this") Node inliningTarget, - @Cached PyUnicodeReadCharNode unicodeReadChar) { - return unicodeReadChar.execute(inliningTarget, unicodeObject, index); - } - } - - @HPyContextFunction("ctx_AsPyObject") - @GenerateUncached - public abstract static class GraalHPyAsPyObject extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Cached PythonToNativeNewRefNode toPyObjectPointerNode) { - return toPyObjectPointerNode.execute(object); - } - } - - @HPyContextFunction("ctx_Bytes_AsString") - @HPyContextFunction("ctx_Bytes_AS_STRING") - @GenerateUncached - public abstract static class GraalHPyBytesAsString extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode) { - if (object instanceof PBytes bytes) { - return PySequenceArrayWrapper.ensureNativeSequence(bytes); - } - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); - } - } - - @HPyContextFunction("ctx_Bytes_Size") - @HPyContextFunction("ctx_Bytes_GET_SIZE") - @GenerateUncached - public abstract static class GraalHPyBytesGetSize extends HPyBinaryContextFunction { - - @Specialization - static long doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached SequenceNodes.LenNode lenNode, - @Cached PRaiseNode raiseNode) { - if (object instanceof PBytes) { - return lenNode.execute(inliningTarget, (PSequence) object); - } - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_BYTES_P_FOUND, object); - } - } - - @HPyContextFunction("ctx_Bytes_FromString") - @GenerateUncached - public abstract static class GraalHPyBytesFromString extends HPyBinaryContextFunction { - - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached CastToJavaIntExactNode castToJavaIntNode, - @Cached(parameters = "hpyContext") HPyCallHelperFunctionNode callHelperNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, - @Cached PRaiseNode raiseNode) { - int size; - try { - size = castToJavaIntNode.execute(inliningTarget, callHelperNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_STRLEN, charPtr)); - } catch (PException e) { - throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.BYTE_STR_IS_TOO_LARGE); - } - byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, size); - return PFactory.createBytes(hpyContext.getContext().getLanguage(inliningTarget), bytes); - } - } - - @HPyContextFunction("ctx_Bytes_FromStringAndSize") - @GenerateUncached - public abstract static class GraalHPyBytesFromStringAndSize extends HPyTernaryContextFunction { - - @Specialization - static PBytes doGeneric(GraalHPyContext hpyContext, Object charPtr, long lsize, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadI8ArrayNode readI8ArrayNode, - @Cached PRaiseNode raiseNode) { - if (isNullNode.execute(hpyContext, charPtr)) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.NULL_CHAR_PASSED); - } - if (lsize < 0) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NEGATIVE_SIZE_PASSED); - } - PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); - if (lsize == 0) { - return PFactory.createEmptyBytes(language); - } - byte[] bytes = readI8ArrayNode.execute(hpyContext, charPtr, 0, lsize); - return PFactory.createBytes(language, bytes); - } - } - - @HPyContextFunction("ctx_IsTrue") - @GenerateUncached - public abstract static class GraalHPyIsTrue extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Cached PyObjectIsTrueNode isTrueNode) { - return PInt.intValue(isTrueNode.execute(null, object)); - } - } - - @HPyContextFunction("ctx_GetAttr") - @GenerateUncached - public abstract static class GraalHPyGetAttr extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, - @Bind("this") Node inliningTarget, - @Cached PyObjectGetAttrO getAttributeNode) { - return getAttributeNode.execute(null, inliningTarget, receiver, key); - } - } - - @HPyContextFunction("ctx_GetAttr_s") - @GenerateUncached - public abstract static class GraalHPyGetAttrS extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectGetAttr getAttributeNode) { - return getAttributeNode.execute(inliningTarget, receiver, fromCharPointerNode.execute(charPtr)); - } - } - - @HPyContextFunction("ctx_Type_FromSpec") - @GenerateUncached - public abstract static class GraalHPyTypeFromSpec extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object typeSpecPtr, Object typeSpecParamArrayPtr, - @Cached HPyCreateTypeFromSpecNode createTypeFromSpecNode) { - Object newType = createTypeFromSpecNode.execute(hpyContext, typeSpecPtr, typeSpecParamArrayPtr); - assert PGuards.isClassUncached(newType) : "Object created from type spec is not a type"; - return newType; - } - } - - @HPyContextFunction("ctx_HasAttr") - @GenerateUncached - public abstract static class GraalHPyHasAttr extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, - @Bind("this") Node inliningTarget, - @Cached PyObjectGetAttrO getAttributeNode) { - try { - Object attr = getAttributeNode.execute(null, inliningTarget, receiver, key); - return PInt.intValue(attr != PNone.NO_VALUE); - } catch (PException e) { - return 0; - } - } - } - - @HPyContextFunction("ctx_HasAttr_s") - @GenerateUncached - public abstract static class GraalHPyHasAttrS extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectGetAttr getAttributeNode) { - try { - Object attr = getAttributeNode.execute(inliningTarget, receiver, fromCharPointerNode.execute(charPtr)); - return PInt.intValue(attr != PNone.NO_VALUE); - } catch (PException e) { - return 0; - } - } - } - - @HPyContextFunction("ctx_SetAttr") - @GenerateUncached - public abstract static class GraalHPySetAttr extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, Object value, - @Bind("this") Node inliningTarget, - @Cached PyObjectSetAttrO setAttrNode) { - if (value == NULL_HANDLE_DELEGATE) { - setAttrNode.execute(null, inliningTarget, receiver, key, PNone.NO_VALUE); - } else { - setAttrNode.execute(null, inliningTarget, receiver, key, value); - } - return 0; - } - } - - @HPyContextFunction("ctx_SetAttr_s") - @GenerateUncached - public abstract static class GraalHPySetAttrS extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, Object value, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectSetAttr setAttrNode) { - TruffleString key = fromCharPointerNode.execute(charPtr); - if (value == NULL_HANDLE_DELEGATE) { - setAttrNode.execute(inliningTarget, receiver, key, PNone.NO_VALUE); - } else { - setAttrNode.execute(inliningTarget, receiver, key, value); - } - return 0; - } - } - - @HPyContextFunction("ctx_GetItem") - @HPyContextFunction("ctx_GetItem_i") - @GenerateUncached - public abstract static class GraalHPyGetItem extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, - @Bind("this") Node inliningTarget, - @Cached PyObjectGetItem getItemNode) { - return getItemNode.execute(null, inliningTarget, receiver, key); - } - } - - @HPyContextFunction("ctx_GetItem_s") - @GenerateUncached - public abstract static class GraalHPyGetItemS extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectGetItem getItemNode) { - return getItemNode.execute(null, inliningTarget, receiver, fromCharPointerNode.execute(charPtr)); - } - } - - @HPyContextFunction("ctx_SetItem") - @HPyContextFunction("ctx_SetItem_i") - @GenerateUncached - public abstract static class GraalHPySetItem extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, Object value, - @Bind("this") Node inliningTarget, - @Cached PyObjectSetItem setItemNode) { - setItemNode.execute(null, inliningTarget, receiver, key, value); - return 0; - } - } - - @HPyContextFunction("ctx_SetItem_s") - @GenerateUncached - public abstract static class GraalHPySetItemS extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, Object value, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectSetItem setItemNode) { - setItemNode.execute(null, inliningTarget, receiver, fromCharPointerNode.execute(charPtr), value); - return 0; - } - } - - @HPyContextFunction("ctx_DelItem") - @HPyContextFunction("ctx_DelItem_i") - @GenerateUncached - public abstract static class GraalHPyDelItem extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object key, - @Bind("this") Node inliningTarget, - @Cached PyObjectDelItem delItemNode) { - delItemNode.execute(null, inliningTarget, receiver, key); - return 0; - } - } - - @HPyContextFunction("ctx_DelItem_s") - @GenerateUncached - public abstract static class GraalHPyDelItemS extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object charPtr, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PyObjectDelItem delItemNode) { - delItemNode.execute(null, inliningTarget, receiver, fromCharPointerNode.execute(charPtr)); - return 0; - } - } - - @HPyContextFunction("ctx_FromPyObject") - @GenerateUncached - public abstract static class GraalHPyFromPyObject extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object object, - @Cached NativeToPythonNode toJavaNode) { - // IMPORTANT: this is not stealing the reference. The CPython implementation - // actually increases the reference count by 1. - return toJavaNode.execute(object); - } - } - - @HPyContextFunction("ctx_New") - @GenerateUncached - public abstract static class GraalHPyNew extends HPyTernaryContextFunction { - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyNew.class); - public static final String INVALID_BUILT_IN_SHAPE = "invalid built-in shape"; - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object type, Object dataOutVar, - @Bind("this") Node inliningTarget, - @Cached IsTypeNode isTypeNode, - @Cached PRaiseNode raiseNode, - @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached(parameters = "hpyContext") GraalHPyCAccess.AllocateNode allocateNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WritePointerNode writePointerNode, - @Cached InlinedExactClassProfile classProfile) { - - Object profiledTypeObject = classProfile.profile(inliningTarget, type); - - // check if argument is actually a type - if (!isTypeNode.execute(inliningTarget, profiledTypeObject)) { - return raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_NEW_ARG_1_MUST_BE_A_TYPE); - } - - Object dataPtr = null; - Object destroyFunc = null; - Object defaultCallFunc = null; - - if (profiledTypeObject instanceof PythonClass clazz) { - // allocate native space - long basicSize = clazz.getBasicSize(); - if (basicSize != -1) { - dataPtr = allocateNode.calloc(hpyContext, 1, basicSize); - destroyFunc = clazz.getHPyDestroyFunc(); - - // write data pointer to out var - writePointerNode.write(hpyContext, dataOutVar, dataPtr); - - if (LOGGER.isLoggable(Level.FINEST)) { - LOGGER.finest(PythonUtils.formatJString("Allocated HPy object with native space of size %d at %s", basicSize, dataPtr)); - } - // TODO(fa): add memory tracing - } - defaultCallFunc = clazz.getHPyDefaultCallFunc(); - } - - int builtinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); - PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); - PythonObject pythonObject = createFromBuiltinShape(builtinShape, profiledTypeObject, dataPtr, language, getInstanceShape); - - if (destroyFunc != null) { - hpyContext.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); - } - if (defaultCallFunc != null) { - GraalHPyData.setHPyCallFunction(pythonObject, defaultCallFunc); - } - - return pythonObject; - } - - static PythonObject createFromBuiltinShape(int builtinShape, Object type, Object dataPtr, PythonLanguage language, TypeNodes.GetInstanceShape getInstanceShape) { - Shape shape = getInstanceShape.execute(type); - PythonObject result = switch (builtinShape) { - case HPyType_BUILTIN_SHAPE_LEGACY, HPyType_BUILTIN_SHAPE_OBJECT -> PFactory.createPythonHPyObject(language, type, shape, dataPtr); - case HPyType_BUILTIN_SHAPE_TYPE -> throw CompilerDirectives.shouldNotReachHere("built-in shape type not yet implemented"); - case HPyType_BUILTIN_SHAPE_LONG -> PFactory.createInt(language, type, shape, BigInteger.ZERO); - case HPyType_BUILTIN_SHAPE_FLOAT -> PFactory.createFloat(language, type, shape, 0.0); - case HPyType_BUILTIN_SHAPE_UNICODE -> PFactory.createString(language, type, shape, T_EMPTY_STRING); - case HPyType_BUILTIN_SHAPE_TUPLE -> PFactory.createEmptyTuple(language, type, shape); - case HPyType_BUILTIN_SHAPE_LIST -> PFactory.createList(language, type, shape); - default -> throw CompilerDirectives.shouldNotReachHere(INVALID_BUILT_IN_SHAPE); - }; - if (builtinShape != HPyType_BUILTIN_SHAPE_LEGACY && builtinShape != HPyType_BUILTIN_SHAPE_OBJECT) { - GraalHPyData.setHPyNativeSpace(result, dataPtr); - } - return result; - } - } - - @HPyContextFunction("ctx_AsStruct_Object") - @HPyContextFunction("ctx_AsStruct_Legacy") - @HPyContextFunction("ctx_AsStruct_Type") - @HPyContextFunction("ctx_AsStruct_Long") - @HPyContextFunction("ctx_AsStruct_Float") - @HPyContextFunction("ctx_AsStruct_Unicode") - @HPyContextFunction("ctx_AsStruct_Tuple") - @HPyContextFunction("ctx_AsStruct_List") - @GenerateUncached - public abstract static class GraalHPyCast extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached HPyGetNativeSpacePointerNode getNativeSpacePointerNode) { - // we can also just return NO_VALUE since that will be interpreter as NULL - return getNativeSpacePointerNode.execute(inliningTarget, object); - } - } - - @HPyContextFunction("ctx_Type_GenericNew") - @GenerateUncached - public abstract static class GraalHPyTypeGenericNew extends HPy5ContextFunction { - - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyTypeGenericNew.class); - - @Specialization - @SuppressWarnings("unused") - static Object doGeneric(GraalHPyContext hpyContext, Object type, Object args, long nargs, Object kw, - @Bind("this") Node inliningTarget, - @Cached TypeNodes.GetInstanceShape getInstanceShape, - @Cached(parameters = "hpyContext") GraalHPyCAccess.AllocateNode allocateNode, - @Cached InlinedExactClassProfile classProfile) { - - Object profiledTypeObject = classProfile.profile(inliningTarget, type); - Object dataPtr = null; - Object destroyFunc = null; - - if (type instanceof PythonClass clazz) { - long basicSize = clazz.getBasicSize(); - if (basicSize != -1) { - // we fully control this attribute; if it is there, it's always a long - dataPtr = allocateNode.calloc(hpyContext, 1, basicSize); - destroyFunc = clazz.getHPyDestroyFunc(); - - if (LOGGER.isLoggable(Level.FINEST)) { - LOGGER.finest(PythonUtils.formatJString("Allocated HPy object with native space of size %d at %s", basicSize, dataPtr)); - } - // TODO(fa): add memory tracing - } - } - - int builtinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); - PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); - PythonObject pythonObject = GraalHPyNew.createFromBuiltinShape(builtinShape, type, dataPtr, language, getInstanceShape); - - if (destroyFunc != null) { - hpyContext.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); - } - return pythonObject; - } - } - - @HPyContextFunction("ctx_Absolute") - @GenerateUncached - public abstract static class GraalHPyAbsolute extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_ABS); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Long") - @GenerateUncached - public abstract static class GraalHPyLong extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_INT); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Float") - @GenerateUncached - public abstract static class GraalHPyFloat extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_FLOAT); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Str") - @GenerateUncached - public abstract static class GraalHPyStr extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_STR); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Repr") - @GenerateUncached - public abstract static class GraalHPyRepr extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_REPR); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_ASCII") - @GenerateUncached - public abstract static class GraalHPyASCII extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_ASCII); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Bytes") - @GenerateUncached - public abstract static class GraalHPyBytes extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_BYTES); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Hash") - @GenerateUncached - public abstract static class GraalHPyHash extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_HASH); - return callNode.executeObject(builtinFunction, arg); - } - } - - @HPyContextFunction("ctx_Length") - @GenerateUncached - public abstract static class GraalHPyLength extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arg, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached CallUnaryMethodNode callNode) { - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_LEN); - return callNode.executeObject(builtinFunction, arg); - } - } - - public abstract static class GraalHPyRichcompareBaseNode extends HPyQuaternaryContextFunction { - static final int RICH_CMP_OP_COUNT = RichCmpOp.VALUES.length; - - static RichCmpOp opFromNative(int op) { - return RichCmpOp.fromNative(op); - } - } - - @HPyContextFunction("ctx_RichCompare") - @GenerateUncached - public abstract static class GraalHPyRichcompare extends GraalHPyRichcompareBaseNode { - - @Specialization(guards = "opFromNative(arg2) == op", limit = "RICH_CMP_OP_COUNT") - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object receiver, Object arg1, int arg2, - @Bind("this") Node inliningTarget, - @Cached(value = "opFromNative(arg2)", allowUncached = true) RichCmpOp op, - @Cached PyObjectRichCompare richCmpNode) { - return richCmpNode.execute(null, inliningTarget, receiver, arg1, op); - } - } - - @HPyContextFunction("ctx_RichCompareBool") - @GenerateUncached - public abstract static class GraalHPyRichcompareBool extends GraalHPyRichcompareBaseNode { - - @Specialization(guards = "opFromNative(arg2) == op", limit = "RICH_CMP_OP_COUNT") - static int doGeneric(Object ctx, Object receiver, Object arg1, int arg2, - @Bind("this") Node inliningTarget, - @Cached(value = "opFromNative(arg2)", allowUncached = true) RichCmpOp op, - @Cached PyObjectRichCompareBool richCmpNode) { - return PInt.intValue(richCmpNode.execute(null, inliningTarget, receiver, arg1, op)); - } - } - - @HPyContextFunction("ctx_Index") - @GenerateUncached - public abstract static class GraalHPyAsIndex extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached PyNumberIndexNode indexNode) { - return indexNode.execute(null, inliningTarget, object); - } - } - - @HPyContextFunction("ctx_Number_Check") - @GenerateUncached - public abstract static class GraalHPyIsNumber extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached PyNumberCheckNode checkNode) { - return PInt.intValue(checkNode.execute(inliningTarget, object)); - } - } - - @HPyContextFunction("ctx_Tuple_FromArray") - @GenerateUncached - public abstract static class GraalHPyTupleFromArray extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object arrayPtr, long nelements, - @Bind("this") Node inliningTarget, - @Cached CastToJavaIntExactNode castToJavaIntExactNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadHPyArrayNode readHPyArrayNode) { - int n; - try { - n = castToJavaIntExactNode.execute(inliningTarget, nelements); - } catch (CannotCastException e) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(castToJavaIntExactNode, PythonBuiltinClassType.MemoryError); - } - - Object[] elements = readHPyArrayNode.execute(hpyContext, arrayPtr, 0, n); - return PFactory.createTuple(hpyContext.getContext().getLanguage(inliningTarget), elements); - } - } - - @HPyContextFunction("ctx_TupleBuilder_New") - @HPyContextFunction("ctx_ListBuilder_New") - @GenerateUncached - public abstract static class GraalHPyBuilderNew extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, long lcapacity, - @Cached HPyAsHandleNode asHandleNode) { - int capacity; - if (PInt.isIntRange(lcapacity) && (capacity = (int) lcapacity) >= 0) { - Object[] data = new Object[capacity]; - Arrays.fill(data, PNone.NONE); - return asHandleNode.execute(new ObjectSequenceStorage(data)); - } - return NULL_HANDLE; - } - } - - @HPyContextFunction("ctx_TupleBuilder_Set") - @HPyContextFunction("ctx_ListBuilder_Set") - @GenerateUncached - public abstract static class GraalHPyBuilderSet extends HPyQuaternaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderHandle, long lidx, Object value, - @Bind("this") Node inliningTarget, - @Cached HPyAsPythonObjectNode asPythonObjectNode, - @Cached CastToJavaIntExactNode castToJavaIntExactNode, - @Cached SequenceStorageNodes.SetItemDynamicNode setItemNode) { - Object builder = asPythonObjectNode.execute(builderHandle); - if (builder instanceof ObjectSequenceStorage storage) { - try { - int idx = castToJavaIntExactNode.execute(inliningTarget, lidx); - setItemNode.execute(null, NoGeneralizationNode.DEFAULT, storage, idx, value); - } catch (CannotCastException e) { - // fall through - } - return 0; - } - /* - * that's really unexpected since the C signature should enforce a valid builder but - * someone could have messed it up - */ - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - } - - @GenerateCached(false) - abstract static class HPyBuilderBuild extends HPyBinaryContextFunction { - - boolean isTupleBuilder() { - throw CompilerDirectives.shouldNotReachHere(); - } - - @Specialization - Object doGeneric(GraalHPyContext hpyContext, Object builderHandle, - @Bind("this") Node inliningTarget, - @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode) { - ObjectSequenceStorage builder = cast(closeAndGetHandleNode.execute(inliningTarget, builderHandle)); - if (builder == null) { - /* - * that's really unexpected since the C signature should enforce a valid builder but - * someone could have messed it up - */ - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - PythonLanguage language = hpyContext.getContext().getLanguage(inliningTarget); - return isTupleBuilder() ? PFactory.createTuple(language, builder) : PFactory.createList(language, builder); - } - - static ObjectSequenceStorage cast(Object object) { - if (object instanceof ObjectSequenceStorage) { - return (ObjectSequenceStorage) object; - } - return null; - } - } - - @HPyContextFunction("ctx_TupleBuilder_Build") - @GenerateUncached - public abstract static class GraalHPyTupleBuilderBuild extends HPyBuilderBuild { - @Override - final boolean isTupleBuilder() { - return true; - } - } - - @HPyContextFunction("ctx_ListBuilder_Build") - @GenerateUncached - public abstract static class GraalHPyListBuilderBuild extends HPyBuilderBuild { - @Override - final boolean isTupleBuilder() { - return false; - } - } - - @HPyContextFunction("ctx_TupleBuilder_Cancel") - @HPyContextFunction("ctx_ListBuilder_Cancel") - @GenerateUncached - public abstract static class GraalHPyBuilderCancel extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderHandle, - @Bind("this") Node inliningTarget, - @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode) { - // be pedantic and also check what we are cancelling - ObjectSequenceStorage builder = HPyBuilderBuild.cast(closeAndGetHandleNode.execute(inliningTarget, builderHandle)); - if (builder == null) { - /* - * that's really unexpected since the C signature should enforce a valid builder but - * someone could have messed it up - */ - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - return 0; - } - } - - @HPyContextFunction("ctx_Tracker_New") - @GenerateUncached - public abstract static class GraalHPyTrackerNew extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, long lcapacity, - @Cached HPyAsHandleNode asHandleNode) { - int capacity; - if (PInt.isIntRange(lcapacity) && (capacity = (int) lcapacity) >= 0) { - return asHandleNode.execute(new GraalHPyTracker(capacity)); - } - return NULL_HANDLE; - } - } - - @HPyContextFunction("ctx_Tracker_Add") - @GenerateUncached - public abstract static class GraalHPyTrackerAdd extends HPyTernaryContextFunction { - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderArg, Object item, - @Bind("this") Node inliningTarget, - @Cached HPyAsPythonObjectNode asPythonObjectNode, - @Cached HPyEnsureHandleNode ensureHandleNode) { - GraalHPyTracker builder = cast(asPythonObjectNode.execute(builderArg)); - if (builder == null) { - // that's really unexpected since the C signature should enforce a valid builder - // but someone could have messed it up - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - try { - GraalHPyHandle handle = ensureHandleNode.execute(inliningTarget, item); - if (handle != null) { - builder.add(handle); - } - } catch (OverflowException | OutOfMemoryError e) { - return -1; - } - return 0; - } - - static GraalHPyTracker cast(Object object) { - if (object instanceof GraalHPyTracker) { - return (GraalHPyTracker) object; - } - return null; - } - } - - @HPyContextFunction("ctx_Tracker_Close") - @GenerateUncached - public abstract static class GraalHPyTrackerCleanup extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderHandle, - @Bind("this") Node inliningTarget, - @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode, - @Cached HPyCloseHandleNode closeHandleNode) { - GraalHPyTracker builder = GraalHPyTrackerAdd.cast(closeAndGetHandleNode.execute(inliningTarget, builderHandle)); - if (builder == null) { - // that's really unexpected since the C signature should enforce a valid builder - // but someone could have messed it up - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - builder.free(inliningTarget, closeHandleNode); - return 0; - } - } - - @HPyContextFunction("ctx_Tracker_ForgetAll") - @GenerateUncached - public abstract static class GraalHPyTrackerForgetAll extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object builderArg, - @Cached HPyAsPythonObjectNode asPythonObjectNode) { - GraalHPyTracker builder = GraalHPyTrackerAdd.cast(asPythonObjectNode.execute(builderArg)); - if (builder == null) { - // that's really unexpected since the C signature should enforce a valid builder - // but someone could have messed it up - throw CompilerDirectives.shouldNotReachHere("invalid builder object"); - } - builder.removeAll(); - return 0; - } - } - - @HPyContextFunction("ctx_Callable_Check") - @GenerateUncached - public abstract static class GraalHPyIsCallable extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached PyCallableCheckNode callableCheck) { - return PInt.intValue(callableCheck.execute(inliningTarget, object)); - } - } - - @HPyContextFunction("ctx_CallTupleDict") - @GenerateUncached - public abstract static class GraalHPyCallTupleDict extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object callable, Object argsObject, Object kwargsObject, - @Bind("this") Node inliningTarget, - @Cached ExecutePositionalStarargsNode expandArgsNode, - @Cached HashingStorageLen lenNode, - @Cached ExpandKeywordStarargsNode expandKwargsNode, - @Cached CallNode callNode, - @Cached PRaiseNode raiseNode) { - // check and expand args - Object[] args = castArgs(inliningTarget, argsObject, expandArgsNode, raiseNode); - // check and expand kwargs - PKeyword[] keywords = castKwargs(inliningTarget, kwargsObject, lenNode, expandKwargsNode, raiseNode); - return callNode.executeWithoutFrame(callable, args, keywords); - } - - private static Object[] castArgs(Node inliningTarget, Object args, - ExecutePositionalStarargsNode expandArgsNode, - PRaiseNode raiseNode) { - // this indicates that a NULL handle was passed (which is valid) - if (args == PNone.NO_VALUE) { - return PythonUtils.EMPTY_OBJECT_ARRAY; - } - if (PGuards.isPTuple(args)) { - return expandArgsNode.executeWith(null, args); - } - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_ARGS_TUPLE_OR_NULL); - } - - private static PKeyword[] castKwargs(Node inliningTarget, Object kwargs, - HashingStorageLen lenNode, - ExpandKeywordStarargsNode expandKwargsNode, - PRaiseNode raiseNode) { - // this indicates that a NULL handle was passed (which is valid) - if (kwargs == PNone.NO_VALUE || isEmptyDict(inliningTarget, kwargs, lenNode)) { - return PKeyword.EMPTY_KEYWORDS; - } - if (PGuards.isDict(kwargs)) { - return expandKwargsNode.execute(inliningTarget, kwargs); - } - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CALLTUPLEDICT_REQUIRES_KW_DICT_OR_NULL); - } - - private static boolean isEmptyDict(Node inliningTarget, Object delegate, HashingStorageLen lenNode) { - return delegate instanceof PDict && lenNode.execute(inliningTarget, ((PDict) delegate).getDictStorage()) == 0; - } - } - - @HPyContextFunction("ctx_Call") - @GenerateUncached - public abstract static class GraalHPyCall extends HPy5ContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object callable, Object args, long lnargs, Object kwnamesObj, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadHPyArrayNode readHPyArrayNode, - @Cached PyTupleSizeNode tupleSizeNode, - @Cached HPyPackKeywordArgsNode packKeywordArgsNode, - @Cached PRaiseNode raiseNode) { - - if (!PInt.isIntRange(lnargs)) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); - } - int nargs = (int) lnargs; - PTuple kwnames; - int nkw; - if (kwnamesObj instanceof PTuple) { - kwnames = (PTuple) kwnamesObj; - nkw = tupleSizeNode.execute(inliningTarget, kwnames); - } else { - nkw = 0; - kwnames = null; - } - - // positional args are from 'args[0]' ... 'args[nargs - 1]' - Object[] positionalArgs = readHPyArrayNode.execute(hpyContext, args, 0, nargs); - - PKeyword[] keywords; - if (nkw > 0) { - // keyword arg values are from 'args[nargs]' ... 'args[nargs + nkw - 1]' - Object[] kwObjs = readHPyArrayNode.execute(hpyContext, args, nargs, nkw); - keywords = packKeywordArgsNode.execute(inliningTarget, kwObjs, kwnames, nkw); - } else { - keywords = PKeyword.EMPTY_KEYWORDS; - } - - /* - * We use the uncached CallNode for now as a workaround because - * 'AbstractCallMethodNode.callerExceedsMaxSize' assumes that a call node is always - * under a root node. However, in cross-language calls, this may not be the case. - */ - return CallNode.executeUncached(callable, positionalArgs, keywords); - } - } - - @HPyContextFunction("ctx_CallMethod") - @GenerateUncached - @ImportStatic(PGuards.class) - public abstract static class GraalHPyCallMethod extends HPy5ContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, TruffleString name, Object args, long lnargs, Object kwnames, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadHPyArrayNode readHPyArrayNode, - @Cached PyTupleSizeNode tupleSizeNode, - @Cached HPyPackKeywordArgsNode packKeywordArgsNode, - @Cached PyObjectGetMethod getMethodNode, - @Cached CallNode callNode, - @Cached PRaiseNode raiseNode) { - - if (!PInt.isIntRange(lnargs)) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); - } - int nargs = (int) lnargs; - int nkw = kwnames != PNone.NO_VALUE ? tupleSizeNode.execute(inliningTarget, kwnames) : 0; - - // positional args are from 'args[0]' ... 'args[nargs - 1]' (including 'self') - Object[] positionalArgs = readHPyArrayNode.execute(hpyContext, args, 0, nargs); - Object receiver = positionalArgs[0]; - - Object callable = getMethodNode.execute(null, inliningTarget, receiver, name); - - PKeyword[] keywords; - if (nkw > 0) { - // check and expand kwargs - Object[] kwObjs = readHPyArrayNode.execute(hpyContext, args, nargs, nkw); - keywords = packKeywordArgsNode.execute(inliningTarget, kwObjs, (PTuple) kwnames, nkw); - } else { - keywords = PKeyword.EMPTY_KEYWORDS; - } - return callNode.executeWithoutFrame(callable, positionalArgs, keywords); - } - } - - @HPyContextFunction("ctx_Dump") - @GenerateUncached - public abstract static class GraalHPyDump extends HPyBinaryContextFunction { - - @Specialization - @TruffleBoundary - static int doGeneric(GraalHPyContext hpyContext, Object object) { - PythonContext context = hpyContext.getContext(); - Object type = GetClassNode.executeUncached(object); - PrintWriter stderr = new PrintWriter(context.getStandardErr()); - stderr.println("object type : " + type); - stderr.println("object type name: " + GetNameNode.executeUncached(type)); - - // the most dangerous part - stderr.println("object repr : "); - stderr.flush(); - try { - stderr.println(PyObjectReprAsTruffleStringNode.executeUncached(object).toJavaStringUncached()); - stderr.flush(); - } catch (PException | CannotCastException e) { - // errors are ignored at this point - } - return 0; - } - } - - @HPyContextFunction("ctx_Type") - @GenerateUncached - public abstract static class GraalHPyType extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode) { - return getClassNode.execute(inliningTarget, object); - } - } - - @HPyContextFunction("ctx_TypeCheck") - @GenerateUncached - public abstract static class GraalHPyTypeCheck extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object object, Object type, - @Bind("this") Node inliningTarget, - @Cached GetClassNode getClassNode, - @Cached IsSubtypeNode isSubtypeNode) { - return PInt.intValue(isSubtypeNode.execute(getClassNode.execute(inliningTarget, object), type)); - } - } - - @HPyContextFunction("ctx_Err_NewExceptionWithDoc") - @GenerateUncached - public abstract static class GraalHPyNewExceptionWithDoc extends HPy5ContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object namePtr, Object docPtr, Object base, Object dictObj, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached TruffleString.IndexOfCodePointNode indexOfCodepointNode, - @Cached TruffleString.CodePointLengthNode codepointLengthNode, - @Cached TruffleString.SubstringNode substringNode, - @Cached HashingStorageGetItem getHashingStorageItem, - @Cached HashingStorageSetItem setHashingStorageItem, - @Cached CallNode callTypeConstructorNode, - @Cached PRaiseNode raiseNode) { - TruffleString doc; - if (!isNullNode.execute(hpyContext, docPtr)) { - doc = fromCharPointerNode.execute(docPtr); - } else { - doc = null; - } - return createNewExceptionWithDoc(inliningTarget, namePtr, base, dictObj, doc, fromCharPointerNode, indexOfCodepointNode, codepointLengthNode, substringNode, - getHashingStorageItem, - setHashingStorageItem, callTypeConstructorNode, raiseNode); - } - - static Object createNewExceptionWithDoc(Node inliningTarget, Object namePtr, Object base, Object dictObj, TruffleString doc, - FromCharPointerNode fromCharPointerNode, - TruffleString.IndexOfCodePointNode indexOfCodepointNode, - TruffleString.CodePointLengthNode codepointLengthNode, - TruffleString.SubstringNode substringNode, - HashingStorageGetItem getHashingStorageItem, - HashingStorageSetItem setHashingStorageItem, - CallNode callTypeConstructorNode, - PRaiseNode raiseNode) { - - TruffleString name = fromCharPointerNode.execute(namePtr); - int len = codepointLengthNode.execute(name, TS_ENCODING); - int dotIdx = indexOfCodepointNode.execute(name, '.', 0, len, TS_ENCODING); - if (dotIdx < 0) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.NAME_MUST_BE_MOD_CLS); - } - - if (base == PNone.NO_VALUE) { - base = PythonBuiltinClassType.Exception; - } - PythonLanguage language = PythonLanguage.get(inliningTarget); - PDict dict; - HashingStorage dictStorage; - if (dictObj == PNone.NO_VALUE) { - dictStorage = new DynamicObjectStorage(PythonLanguage.get(inliningTarget)); - dict = PFactory.createDict(language, dictStorage); - } else { - if (!(dictObj instanceof PDict)) { - /* - * CPython expects a PyDictObject and if not, it raises a - * ErrorMessages.BAD_INTERNAL_CALL. - */ - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); - } - dict = (PDict) dictObj; - dictStorage = dict.getDictStorage(); - } - - if (!getHashingStorageItem.hasKey(inliningTarget, dictStorage, SpecialAttributeNames.T___MODULE__)) { - dictStorage = setHashingStorageItem.execute(inliningTarget, dictStorage, SpecialAttributeNames.T___MODULE__, substringNode.execute(name, 0, dotIdx, TS_ENCODING, false)); - } - if (doc != null) { - dictStorage = setHashingStorageItem.execute(inliningTarget, dictStorage, SpecialAttributeNames.T___DOC__, doc); - } - dict.setDictStorage(dictStorage); - - PTuple bases; - if (base instanceof PTuple) { - bases = (PTuple) base; - } else { - bases = PFactory.createTuple(language, new Object[]{base}); - } - - return callTypeConstructorNode.executeWithoutFrame(PythonBuiltinClassType.PythonClass, substringNode.execute(name, dotIdx + 1, len - dotIdx - 1, TS_ENCODING, false), bases, dict); - } - } - - @HPyContextFunction("ctx_Err_NewException") - @GenerateUncached - public abstract static class GraalHPyNewException extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object namePtr, Object base, Object dictObj, - @Bind("this") Node inliningTarget, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached TruffleString.IndexOfCodePointNode indexOfCodepointNode, - @Cached TruffleString.CodePointLengthNode codepointLengthNode, - @Cached TruffleString.SubstringNode substringNode, - @Cached HashingStorageGetItem getHashingStorageItem, - @Cached HashingStorageSetItem setHashingStorageItem, - @Cached CallNode callTypeConstructorNode, - @Cached PRaiseNode raiseNode) { - return GraalHPyNewExceptionWithDoc.createNewExceptionWithDoc(inliningTarget, namePtr, base, dictObj, null, fromCharPointerNode, indexOfCodepointNode, - codepointLengthNode, - substringNode, getHashingStorageItem, setHashingStorageItem, callTypeConstructorNode, raiseNode); - } - } - - @HPyContextFunction("ctx_Is") - @GenerateUncached - public abstract static class GraalHPyIs extends HPyTernaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object left, Object right, - @Cached IsNode isNode) { - return PInt.intValue(isNode.execute(left, right)); - } - } - - @HPyContextFunction("ctx_Import_ImportModule") - @GenerateUncached - public abstract static class GraalHPyImportModule extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object charPtr, - @Cached FromCharPointerNode fromCharPointerNode) { - return AbstractImportNode.importModule(fromCharPointerNode.execute(charPtr)); - } - } - - @HPyContextFunction("ctx_Field_Store") - @GenerateUncached - public abstract static class GraalHPyFieldStore extends HPyQuaternaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, PythonObject owner, Object hpyFieldPtr, Object referent, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WriteHPyFieldNode writeHPyFieldNode) { - writeHPyFieldNode.write(hpyContext, owner, hpyFieldPtr, referent); - return 0; - } - } - - @HPyContextFunction("ctx_Field_Load") - @GenerateUncached - public abstract static class GraalHPyFieldLoad extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, PythonObject owner, Object hpyFieldPtr, - @Bind("this") Node inliningTarget, - @Cached HPyFieldLoadNode hPyFieldLoadNode) { - return hPyFieldLoadNode.execute(inliningTarget, owner, hpyFieldPtr); - } - } - - @HPyContextFunction("ctx_Global_Store") - @GenerateUncached - public abstract static class GraalHPyGlobalStore extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object hpyGlobalPtr, Object value, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WritePointerNode writePointerNode, - @Cached InlinedExactClassProfile typeProfile, - @CachedLibrary(limit = "3") InteropLibrary lib) { - Object hpyGlobal = typeProfile.profile(inliningTarget, readPointerNode.execute(hpyContext, hpyGlobalPtr, 0)); - - int idx = -1; - if (hpyGlobal instanceof GraalHPyHandle) { - // branch profiling with typeProfile - idx = ((GraalHPyHandle) hpyGlobal).getGlobalId(); - } else if (!(hpyGlobal instanceof Long) && lib.isNull(hpyGlobal)) { - // nothing to do - } else { - long bits; - if (hpyGlobal instanceof Long) { - // branch profile due to lib.asPointer usage in else branch - // and typeProfile - bits = (Long) hpyGlobal; - } else { - try { - bits = lib.asPointer(hpyGlobal); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - if (GraalHPyBoxing.isBoxedHandle(bits)) { - idx = GraalHPyBoxing.unboxHandle(bits); - } - } - - // TODO: (tfel) do not actually allocate the index / free the existing one when - // value can be stored as tagged handle - idx = hpyContext.createGlobal(value, idx); - GraalHPyHandle newHandle = GraalHPyHandle.createGlobal(value, idx); - writePointerNode.execute(hpyContext, hpyGlobalPtr, 0, newHandle); - return 0; - } - } - - @HPyContextFunction("ctx_Global_Load") - @GenerateUncached - public abstract static class GraalHPyGlobalLoad extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object hpyGlobal, - @CachedLibrary(limit = "3") InteropLibrary lib) { - if (hpyGlobal instanceof GraalHPyHandle h) { - // branch profiling with typeProfile - return h.getDelegate(); - } else if (!(hpyGlobal instanceof Long) && lib.isNull(hpyGlobal)) { - // type profile influences first test - return NULL_HANDLE_DELEGATE; - } else { - long bits; - if (hpyGlobal instanceof Long) { - // branch profile due to lib.asPointer usage in else branch - // and typeProfile - bits = (Long) hpyGlobal; - } else { - try { - bits = lib.asPointer(hpyGlobal); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - if (GraalHPyBoxing.isBoxedHandle(bits)) { - // if asHandleNode wasn't used above, it acts as a branch profile - // here. otherwise we're probably already pulling in a lot of code - // and are a bit too polymorphic - return hpyContext.getObjectForHPyGlobal(GraalHPyBoxing.unboxHandle(bits)); - } else { - // tagged handles can be returned directly - return bits; - } - } - } - } - - @HPyContextFunction("ctx_LeavePythonExecution") - @GenerateUncached - public abstract static class GraalHPyLeavePythonExecution extends HPyUnaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, - @Bind("this") Node inliningTarget, - @Cached GilNode gil) { - PythonContext context = hpyContext.getContext(); - PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); - gil.release(context, true); - return threadState; - } - } - - @HPyContextFunction("ctx_ReenterPythonExecution") - @GenerateUncached - public abstract static class GraalHPyReenterPythonExecution extends HPyBinaryContextFunction { - - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, @SuppressWarnings("unused") Object threadState, - @Cached GilNode gil) { - // nothing to do with PThreadState in 'threadState' - gil.acquire(hpyContext.getContext()); - return 0; - } - } - - @HPyContextFunction("ctx_Contains") - @ImportStatic(SpecialMethodSlot.class) - @GenerateUncached - public abstract static class GraalHPyContains extends HPyTernaryContextFunction { - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object container, Object key, - @Bind("this") Node inliningTarget, - @Cached PySequenceContainsNode containsNode) { - return PInt.intValue(containsNode.execute(null, inliningTarget, container, key)); - } - } - - @HPyContextFunction("ctx_Type_IsSubtype") - @GenerateUncached - public abstract static class GraalHPyTypeIsSubtype extends HPyTernaryContextFunction { - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object derived, Object type, - @Cached IsSubtypeNode isSubtype) { - return PInt.intValue(isSubtype.execute(derived, type)); - } - } - - @HPyContextFunction("ctx_Type_GetName") - @GenerateUncached - public abstract static class GraalHPyTypeGetName extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object type, - @Bind("this") Node inliningTarget, - @Cached HPyTypeGetNameNode getName) { - return getName.execute(inliningTarget, hpyContext, type); - } - } - - @HPyContextFunction("ctx_Dict_Keys") - @GenerateUncached - public abstract static class GraalHPyDictKeys extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object dictObj, - @Bind("this") Node inliningTarget, - @Cached PyDictKeys keysNode, - @Cached PRaiseNode raiseNode) { - if (dictObj instanceof PDict dict) { - return keysNode.execute(inliningTarget, dict); - } - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); - } - } - - @HPyContextFunction("ctx_Dict_Copy") - @GenerateUncached - public abstract static class GraalHPyDictCopy extends HPyBinaryContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object dictObj, - @Bind("this") Node inliningTarget, - @Cached HashingStorageCopy copyNode, - @Cached PRaiseNode raiseNode) { - if (dictObj instanceof PDict dict) { - return PFactory.createDict(hpyContext.getContext().getLanguage(inliningTarget), copyNode.execute(inliningTarget, dict.getDictStorage())); - } - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); - } - } - - // see _HPyCapsule_key in the HPy API - public static final class CapsuleKey { - public static final byte Pointer = 0; - public static final byte Name = 1; - public static final byte Context = 2; - public static final byte Destructor = 3; - } - - @HPyContextFunction("ctx_Capsule_New") - @GenerateUncached - public abstract static class GraalHPyCapsuleNew extends HPyQuaternaryContextFunction { - - @Specialization - static PyCapsule doGeneric(GraalHPyContext hpyContext, Object pointer, Object namePtr, Object dtorPtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached PRaiseNode raiseNode) { - if (isNullNode.execute(hpyContext, pointer)) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HPYCAPSULE_NEW_NULL_PTR_ERROR); - } - Object hpyDestructor = null; - if (!isNullNode.execute(hpyContext, dtorPtr)) { - Object cpyTrampoline = readPointerNode.read(hpyContext, dtorPtr, GraalHPyCField.HPyCapsule_Destructor__cpy_trampoline); - hpyDestructor = readPointerNode.read(hpyContext, dtorPtr, GraalHPyCField.HPyCapsule_Destructor__impl); - if (isNullNode.execute(hpyContext, cpyTrampoline) || isNullNode.execute(hpyContext, hpyDestructor)) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.INVALID_HPYCAPSULE_DESTRUCTOR); - } - } - PyCapsule capsule = PFactory.createCapsuleNativeName(hpyContext.getContext().getLanguage(inliningTarget), pointer, namePtr); - if (hpyDestructor != null) { - capsule.registerDestructor(hpyDestructor); - } - return capsule; - } - } - - @HPyContextFunction("ctx_Capsule_Get") - @GenerateUncached - public abstract static class GraalHPyCapsuleGet extends HPyQuaternaryContextFunction { - public static final TruffleString INCORRECT_NAME = tsLiteral("HPyCapsule_GetPointer called with incorrect name"); - - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object capsule, int key, Object namePtr, - @Bind("this") Node inliningTarget, - @Cached PyCapsuleNameMatchesNode nameMatchesNode, - @Cached PRaiseNode raiseNode) { - isLegalCapsule(inliningTarget, capsule, key, raiseNode); - PyCapsule pyCapsule = (PyCapsule) capsule; - Object result; - switch (key) { - case CapsuleKey.Pointer -> { - if (!nameMatchesNode.execute(inliningTarget, pyCapsule.getNamePtr(), namePtr)) { - throw raiseNode.raise(inliningTarget, ValueError, INCORRECT_NAME); - } - result = pyCapsule.getPointer(); - } - case CapsuleKey.Context -> result = pyCapsule.getContext(); - case CapsuleKey.Name -> result = pyCapsule.getNamePtr(); - case CapsuleKey.Destructor -> result = pyCapsule.getDestructor(); - default -> throw CompilerDirectives.shouldNotReachHere("invalid key"); - } - // never allow Java 'null' to be returned - if (result == null) { - return PNone.NO_VALUE; - } - return result; - } - - public static void isLegalCapsule(Node inliningTarget, Object object, int key, PRaiseNode raiseNode) { - if (!(object instanceof PyCapsule) || ((PyCapsule) object).getPointer() == null) { - throw raiseNode.raise(inliningTarget, ValueError, getErrorMessage(key)); - } - } - - @TruffleBoundary - public static TruffleString getErrorMessage(int key) { - return switch (key) { - case CapsuleKey.Pointer -> ErrorMessages.CAPSULE_GETPOINTER_WITH_INVALID_CAPSULE; - case CapsuleKey.Context -> ErrorMessages.CAPSULE_GETCONTEXT_WITH_INVALID_CAPSULE; - case CapsuleKey.Name -> ErrorMessages.CAPSULE_GETNAME_WITH_INVALID_CAPSULE; - case CapsuleKey.Destructor -> ErrorMessages.CAPSULE_GETDESTRUCTOR_WITH_INVALID_CAPSULE; - default -> throw CompilerDirectives.shouldNotReachHere("invalid key"); - }; - } - } - - @HPyContextFunction("ctx_Capsule_Set") - @GenerateUncached - public abstract static class GraalHPyCapsuleSet extends HPyQuaternaryContextFunction { - @Specialization - static int doGeneric(GraalHPyContext hpyContext, Object capsule, int key, Object valuePtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached PRaiseNode raiseNode) { - GraalHPyCapsuleGet.isLegalCapsule(inliningTarget, capsule, key, raiseNode); - PyCapsule pyCapsule = (PyCapsule) capsule; - switch (key) { - case CapsuleKey.Pointer -> { - if (isNullNode.execute(hpyContext, valuePtr)) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.CAPSULE_SETPOINTER_CALLED_WITH_NULL_POINTER); - } - pyCapsule.setPointer(valuePtr); - } - case CapsuleKey.Context -> pyCapsule.setContext(valuePtr); - case CapsuleKey.Name -> { - // we may assume that the pointer is owned - pyCapsule.setNamePtr(fromCharPointerNode.execute(valuePtr, false)); - } - case CapsuleKey.Destructor -> pyCapsule.registerDestructor(isNullNode.execute(hpyContext, valuePtr) ? null : valuePtr); - default -> throw CompilerDirectives.shouldNotReachHere("invalid key"); - } - return 0; - } - } - - @HPyContextFunction("ctx_Capsule_IsValid") - @GenerateUncached - public abstract static class GraalHPyCapsuleIsValid extends HPyTernaryContextFunction { - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object capsule, Object namePtr, - @Bind("this") Node inliningTarget, - @Cached PyCapsuleNameMatchesNode nameMatchesNode) { - return PInt.intValue(capsule instanceof PyCapsule pyCapsule && nameMatchesNode.execute(inliningTarget, pyCapsule.getNamePtr(), namePtr)); - } - } - - @HPyContextFunction("ctx_ContextVar_New") - @GenerateUncached - public abstract static class GraalHPyContextVarNew extends HPyTernaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object namePtr, Object def, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached CallNode callContextvar) { - TruffleString name = fromCharPointerNode.execute(namePtr); - return callContextvar.executeWithoutFrame(PythonBuiltinClassType.ContextVar, name, def); - } - } - - @HPyContextFunction("ctx_ContextVar_Get") - @GenerateUncached - public abstract static class GraalHPyContextVarGet extends HPyQuaternaryContextFunction { - @Specialization - static int doGeneric(GraalHPyContext hpyContext, Object var, Object def, Object outPtr, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WriteHPyNode writeHPyNode) { - if (!(var instanceof PContextVar contextVar)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); - } - PythonContext context = hpyContext.getContext(); - PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); - Object result = getObject(threadState, contextVar, def); - writeHPyNode.write(hpyContext, outPtr, result); - return 0; - } - - public static Object getObject(PythonThreadState threadState, PContextVar var, Object def) { - Object result = var.getValue(threadState); - if (result == null) { - if (def == NULL_HANDLE_DELEGATE) { - def = var.getDefault(); - if (def == PContextVar.NO_DEFAULT) { - def = NULL_HANDLE_DELEGATE; - } - } - result = def; - } - return result; - } - } - - @HPyContextFunction("ctx_ContextVar_Set") - @GenerateUncached - public abstract static class GraalHPyContextVarSet extends HPyTernaryContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object var, Object val, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode) { - if (!(var instanceof PContextVar contextVar)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); - } - PythonContext context = hpyContext.getContext(); - PythonThreadState threadState = context.getThreadState(context.getLanguage(inliningTarget)); - Object oldValue = contextVar.getValue(threadState); - contextVar.setValue(threadState, val); - return PFactory.createContextVarsToken(hpyContext.getContext().getLanguage(inliningTarget), contextVar, oldValue); - } - } - - @HPyContextFunction("ctx_Unicode_FromEncodedObject") - @GenerateUncached - public abstract static class GraalHPyUnicodeFromEncodedObject extends HPyQuaternaryContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object obj, Object encodingPtr, Object errorsPtr, - @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile nullProfile, - @Cached(parameters = "hpyContext") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromNativeCharPointerNode, - @Cached PyUnicodeFromEncodedObject libNode) { - if (nullProfile.profile(inliningTarget, obj == PNone.NO_VALUE)) { - throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); - } - TruffleString encoding; - if (!isNullNode.execute(hpyContext, encodingPtr)) { - encoding = fromNativeCharPointerNode.execute(hpyContext, encodingPtr, true); - } else { - encoding = T_UTF8; - } - - TruffleString errors; - if (!isNullNode.execute(hpyContext, errorsPtr)) { - errors = fromNativeCharPointerNode.execute(hpyContext, errorsPtr, true); - } else { - errors = T_STRICT; - } - return libNode.execute(null, inliningTarget, obj, encoding, errors); - } - } - - @HPyContextFunction("ctx_Unicode_Substring") - @GenerateUncached - public abstract static class GraalHPyUnicodeSubstring extends HPyQuaternaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, Object obj, long lstart, long lend, - @Bind("this") Node inliningTarget, - @Cached CastToTruffleStringNode castStr, - @Cached CastToJavaIntExactNode castStart, - @Cached CastToJavaIntExactNode castEnd, - @Cached InlinedConditionProfile profile, - @Cached TruffleString.CodePointLengthNode codePointLengthNode, - @Cached StrGetItemNodeWithSlice getSlice) { - TruffleString value = castStr.execute(inliningTarget, obj); - int start = castStart.execute(inliningTarget, lstart); - int end = castEnd.execute(inliningTarget, lend); - if (profile.profile(inliningTarget, start < 0 || end < 0)) { - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE); - } - SliceInfo sliceInfo = PSlice.computeIndices(start, end, 1, codePointLengthNode.execute(value, TS_ENCODING)); - return getSlice.execute(value, sliceInfo); - } - } - - @HPyContextFunction("ctx_Slice_Unpack") - @GenerateUncached - public abstract static class GraalHPySliceUnpack extends HPy5ContextFunction { - @Specialization - static int doGeneric(GraalHPyContext hpyContext, Object obj, Object startPtr, Object endPtr, Object stepPtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "hpyContext") GraalHPyCAccess.WriteI64Node writeHPyNode, - @Cached SliceNodes.SliceUnpackLong sliceUnpack) { - if (obj instanceof PSlice slice) { - SliceInfoLong info = sliceUnpack.execute(inliningTarget, slice); - writeHPyNode.write(hpyContext, startPtr, info.start()); - writeHPyNode.write(hpyContext, endPtr, info.stop()); - writeHPyNode.write(hpyContext, stepPtr, info.step()); - return 0; - } - return -1; - } - } - - @HPyContextFunction("ctx_Type_GetBuiltinShape") - @GenerateUncached - public abstract static class GraalHPyTypeGetBuiltinShape extends HPyBinaryContextFunction { - - @Specialization - static int doGeneric(@SuppressWarnings("unused") Object hpyContext, Object typeObject, - @Bind("this") Node inliningTarget, - @Cached InlinedExactClassProfile classProfile, - @Cached PRaiseNode raiseNode) { - Object profiledTypeObject = classProfile.profile(inliningTarget, typeObject); - int result = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(profiledTypeObject); - if (result == -2) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_BE_S, "arg", "type"); - } - return result; - } - } - - @HPyContextFunction("ctx_Compile_s") - @GenerateUncached - public abstract static class GraalHPyCompile extends HPyQuaternaryContextFunction { - @Specialization - static Object doGeneric(GraalHPyContext hpyContext, Object srcPtr, Object filenamePtr, int kind, - @Bind("this") Node inliningTarget, - @Cached ReadAttributeFromObjectNode readAttributeFromObjectNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached CallNode callNode, - @Cached PRaiseNode raiseNode) { - TruffleString src = fromCharPointerNode.execute(srcPtr); - TruffleString filename = fromCharPointerNode.execute(filenamePtr); - Object builtinFunction = readAttributeFromObjectNode.execute(hpyContext.getContext().getBuiltins(), BuiltinNames.T_COMPILE); - GraalHPySourceKind sourceKind = GraalHPySourceKind.fromValue(kind); - if (sourceKind == null) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_INVALID_SOURCE_KIND); - } - return callNode.executeWithoutFrame(builtinFunction, src, filename, sourceKind.getMode()); - } - } - - @HPyContextFunction("ctx_EvalCode") - @GenerateUncached - public abstract static class GraalHPyEvalCode extends HPyQuaternaryContextFunction { - @Specialization - static Object doGeneric(@SuppressWarnings("unused") Object hpyContext, PCode code, Object globals, Object locals, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode, - @Cached CodeNodes.GetCodeCallTargetNode getCallTargetNode, - @Cached GenericInvokeNode invokeNode) { - - // prepare Python frame arguments - Object[] pArguments = PArguments.create(); - - if (locals == PNone.NO_VALUE) { - locals = globals; - } - PArguments.setSpecialArgument(pArguments, locals); - // TODO(fa): set builtins in globals - // PythonModule builtins = getContext().getBuiltins(); - // setBuiltinsInGlobals(globals, setBuiltins, builtins, lib); - if (globals instanceof PythonObject) { - PArguments.setGlobals(pArguments, (PythonObject) globals); - } else { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.BAD_ARG_TO_INTERNAL_FUNC); - } - - RootCallTarget rootCallTarget = getCallTargetNode.execute(inliningTarget, code); - return invokeNode.execute(rootCallTarget, pArguments); - } - } - - @HPyContextFunction("ctx_SetCallFunction") - @GenerateUncached - public abstract static class GraalHPySetCallFunction extends HPyTernaryContextFunction { - @Specialization - static int doGeneric(GraalHPyContext hpyContext, PythonObject object, Object callFunctionDefPtr, - @Bind("this") Node inliningTarget, - @Cached GetPythonObjectClassNode getClassNode, - @Cached InlinedBranchProfile errorProfile, - @Cached HPyReadCallFunctionNode readCallFunctionNode) { - - Object clazz = getClassNode.execute(inliningTarget, object); - if (!(clazz instanceof PythonClass pythonClass) || !pythonClass.isHPyType()) { - errorProfile.enter(inliningTarget); - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.HPY_TYPE_DOES_NOT_IMPLEMENT_CALL_PROTOCOL, clazz); - } - Object callFunction = readCallFunctionNode.execute(inliningTarget, hpyContext, callFunctionDefPtr); - GraalHPyData.setHPyCallFunction(object, callFunction); - return 0; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyData.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyData.java deleted file mode 100644 index 660ada5a2b..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyData.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.util.PythonUtils; - -public abstract class GraalHPyData { - private static final int INDEX_DATA_PTR = 0; - private static final int INDEX_CALL_FUN = 1; - private static final int HPY_FIELD_OFFSET = 1; - - private static final Long DEFAULT_DATA_PTR_VALUE = 0L; - private static final Object DEFAULT_CALL_FUNCTION_VALUE = null; - - public static void setHPyNativeSpace(PythonObject object, Object dataPtr) { - Object[] hpyData = object.getHPyData(); - if (hpyData == null) { - hpyData = new Object[]{dataPtr, DEFAULT_CALL_FUNCTION_VALUE}; - object.setHPyData(hpyData); - } else { - hpyData[INDEX_DATA_PTR] = dataPtr; - } - } - - public static Object getHPyNativeSpace(PythonObject object) { - Object[] hpyData = object.getHPyData(); - return hpyData != null ? hpyData[INDEX_DATA_PTR] : DEFAULT_DATA_PTR_VALUE; - } - - public static void setHPyCallFunction(PythonObject object, Object callFunctionPtr) { - Object[] hpyData = object.getHPyData(); - if (hpyData == null) { - hpyData = new Object[]{DEFAULT_DATA_PTR_VALUE, callFunctionPtr}; - object.setHPyData(hpyData); - } else { - hpyData[INDEX_CALL_FUN] = callFunctionPtr; - } - } - - public static Object getHPyCallFunction(PythonObject object) { - Object[] hpyData = object.getHPyData(); - return hpyData != null ? hpyData[INDEX_CALL_FUN] : null; - } - - public static Object getHPyField(PythonObject object, int location) { - assert location > 0; - Object[] hpyData = object.getHPyData(); - return hpyData != null ? hpyData[location + HPY_FIELD_OFFSET] : null; - } - - public static int setHPyField(PythonObject object, Object referent, int location) { - Object[] hpyFields = object.getHPyData(); - if (location != 0) { - assert hpyFields != null; - hpyFields[location + HPY_FIELD_OFFSET] = referent; - return location; - } else { - int newLocation; - if (hpyFields == null) { - newLocation = 1; - hpyFields = new Object[]{DEFAULT_DATA_PTR_VALUE, null, referent}; - } else { - int newFieldIdx = hpyFields.length; - hpyFields = PythonUtils.arrayCopyOf(hpyFields, newFieldIdx + 1); - hpyFields[newFieldIdx] = referent; - newLocation = newFieldIdx - HPY_FIELD_OFFSET; - } - object.setHPyData(hpyFields); - return newLocation; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyDef.java deleted file mode 100644 index 81803d6aff..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyDef.java +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Copyright (c) 2020, 2024, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_EQ; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_GE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_GT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_LE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_LT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper.RICHCMP_NE; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ABS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BOOL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DIVMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___EQ__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOAT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INDEX__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LEN__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEG__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RLSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ROR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RTRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RXOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___XOR__; - -import java.util.Arrays; - -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; -import com.oracle.graal.python.builtins.objects.cext.common.CExtContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.LLVMType; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyNew; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.builtins.objects.type.TpSlots.TpSlotMeta; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; -import com.oracle.graal.python.nodes.HiddenAttr; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.strings.TruffleString; - -/** - * A container class for mirroring definitions of {@code hpydef.h} - */ -public abstract class GraalHPyDef { - - /* enum values of 'HPyDef_Kind' */ - public static final int HPY_DEF_KIND_SLOT = 1; - public static final int HPY_DEF_KIND_METH = 2; - public static final int HPY_DEF_KIND_MEMBER = 3; - public static final int HPY_DEF_KIND_GETSET = 4; - - /** - * Same as {@code HPyFunc_Signature}. - */ - enum HPyFuncSignature { - VARARGS(1, LLVMType.HPyFunc_varargs), // METH_VARARGS - KEYWORDS(2, LLVMType.HPyFunc_keywords), // METH_VARARGS | METH_KEYWORDS - NOARGS(3, LLVMType.HPyFunc_noargs), // METH_NOARGS - O(4, LLVMType.HPyFunc_o), // METH_O - DESTROYFUNC(5, LLVMType.HPyFunc_destroyfunc), - GETBUFFERPROC(6, LLVMType.HPyFunc_getbufferproc), - RELEASEBUFFERPROC(7, LLVMType.HPyFunc_releasebufferproc), - UNARYFUNC(8, LLVMType.HPyFunc_unaryfunc), - BINARYFUNC(9, LLVMType.HPyFunc_binaryfunc), - TERNARYFUNC(10, LLVMType.HPyFunc_ternaryfunc), - INQUIRY(11, LLVMType.HPyFunc_inquiry), - LENFUNC(12, LLVMType.HPyFunc_lenfunc), - SSIZEARGFUNC(13, LLVMType.HPyFunc_ssizeargfunc), - SSIZESSIZEARGFUNC(14, LLVMType.HPyFunc_ssizessizeargfunc), - SSIZEOBJARGPROC(15, LLVMType.HPyFunc_ssizeobjargproc), - SSIZESSIZEOBJARGPROC(16, LLVMType.HPyFunc_ssizessizeobjargproc), - OBJOBJARGPROC(17, LLVMType.HPyFunc_objobjargproc), - FREEFUNC(18, LLVMType.HPyFunc_freefunc), - GETATTRFUNC(19, LLVMType.HPyFunc_getattrfunc), - GETATTROFUNC(20, LLVMType.HPyFunc_getattrofunc), - SETATTRFUNC(21, LLVMType.HPyFunc_setattrfunc), - SETATTROFUNC(22, LLVMType.HPyFunc_setattrofunc), - REPRFUNC(23, LLVMType.HPyFunc_reprfunc), - HASHFUNC(24, LLVMType.HPyFunc_hashfunc), - RICHCMPFUNC(25, LLVMType.HPyFunc_richcmpfunc), - GETITERFUNC(26, LLVMType.HPyFunc_getiterfunc), - ITERNEXTFUNC(27, LLVMType.HPyFunc_iternextfunc), - DESCRGETFUNC(28, LLVMType.HPyFunc_descrgetfunc), - DESCRSETFUNC(29, LLVMType.HPyFunc_descrsetfunc), - INITPROC(30, LLVMType.HPyFunc_initproc), - GETTER(31, LLVMType.HPyFunc_getter), - SETTER(32, LLVMType.HPyFunc_setter), - OBJOBJPROC(33, LLVMType.HPyFunc_objobjproc); - - /** The corresponding C enum value. */ - private final int value; - - /** The C function's type (basically it's signature). */ - private final LLVMType llvmFunctionType; - - HPyFuncSignature(int value, LLVMType llvmFunctionType) { - this.value = value; - this.llvmFunctionType = llvmFunctionType; - } - - public int getValue() { - return value; - } - - public LLVMType getLLVMFunctionType() { - return llvmFunctionType; - } - - @CompilationFinal(dimensions = 1) private static final HPyFuncSignature[] VALUES = values(); - @CompilationFinal(dimensions = 1) private static final HPyFuncSignature[] BY_VALUE = new HPyFuncSignature[40]; - - static { - for (var entry : VALUES) { - assert BY_VALUE[entry.value] == null; - BY_VALUE[entry.value] = entry; - } - } - - static HPyFuncSignature fromValue(int value) { - return value >= 0 && value < BY_VALUE.length ? BY_VALUE[value] : null; - } - - public static int getFlags(HPyFuncSignature sig) { - switch (sig) { - case VARARGS: - return CExtContext.METH_VARARGS; - case KEYWORDS: - return CExtContext.METH_VARARGS | CExtContext.METH_KEYWORDS; - case NOARGS: - return CExtContext.METH_NOARGS; - case O: - return CExtContext.METH_O; - } - return 0; - } - - static boolean isValid(int value) { - return fromValue(value) != null; - } - } - - /** - * An enumeration of all available slot wrappers as used by CPython (see - * {@code typeobject.c: slotdefs}. Each enum value (except of {@link #NULL}, - * {@link #DESTROYFUNC}, {@link #GETBUFFER}, and {@link #RELEASEBUFFER}) corresponds to a - * wrapper function which name starts with {@code wrap_}. For example, value {@link #UNARYFUNC} - * corresponds to wrapper function {@code wrap_unaryfunc}. - */ - public enum HPySlotWrapper { - NULL(LLVMType.HPyFunc_keywords), - UNARYFUNC(LLVMType.HPyFunc_unaryfunc), - BINARYFUNC(LLVMType.HPyFunc_binaryfunc), - BINARYFUNC_L(LLVMType.HPyFunc_binaryfunc), - BINARYFUNC_R(LLVMType.HPyFunc_binaryfunc), - CALL(LLVMType.HPyFunc_keywords), - HASHFUNC(LLVMType.HPyFunc_hashfunc), - TERNARYFUNC(LLVMType.HPyFunc_ternaryfunc), - TERNARYFUNC_R(LLVMType.HPyFunc_ternaryfunc), - INQUIRYPRED(LLVMType.HPyFunc_inquiry), - DEL, - INIT(LLVMType.HPyFunc_initproc), - LENFUNC(LLVMType.HPyFunc_lenfunc), - DELITEM, - SQ_ITEM(LLVMType.HPyFunc_ssizeargfunc), - SQ_SETITEM(LLVMType.HPyFunc_ssizeobjargproc), - SQ_DELITEM(LLVMType.HPyFunc_ssizeobjargproc), - OBJOBJARGPROC(LLVMType.HPyFunc_objobjargproc), - OBJOBJPROC(LLVMType.HPyFunc_objobjproc), - INDEXARGFUNC(LLVMType.HPyFunc_ssizeargfunc), - SETATTR(LLVMType.HPyFunc_setattrfunc), - DELATTR(LLVMType.HPyFunc_setattrfunc), - RICHCMP_LT(LLVMType.HPyFunc_richcmpfunc), - RICHCMP_LE(LLVMType.HPyFunc_richcmpfunc), - RICHCMP_EQ(LLVMType.HPyFunc_richcmpfunc), - RICHCMP_NE(LLVMType.HPyFunc_richcmpfunc), - RICHCMP_GT(LLVMType.HPyFunc_richcmpfunc), - RICHCMP_GE(LLVMType.HPyFunc_richcmpfunc), - DESCR_GET(LLVMType.HPyFunc_descrgetfunc), - DESCR_SET(LLVMType.HPyFunc_descrsetfunc), - DESCR_DELETE(LLVMType.HPyFunc_descrsetfunc), - DESTROYFUNC(LLVMType.HPyFunc_destroyfunc), - TRAVERSE(LLVMType.HPyFunc_traverseproc), - DESTRUCTOR(LLVMType.HPyFunc_destructor), - GETBUFFER(LLVMType.HPyFunc_getbufferproc), - RELEASEBUFFER(LLVMType.HPyFunc_releasebufferproc), - MOD_CREATE(LLVMType.HPyModule_create); - - /** The C function's type (basically it's signature). */ - private final LLVMType llvmFunctionType; - - HPySlotWrapper() { - this.llvmFunctionType = null; - } - - HPySlotWrapper(LLVMType llvmFunctionType) { - this.llvmFunctionType = llvmFunctionType; - } - - public LLVMType getLLVMFunctionType() { - return llvmFunctionType; - } - } - - /* enum values of 'HPyMember_FieldType' */ - public static final int HPY_MEMBER_SHORT = 0; - public static final int HPY_MEMBER_INT = 1; - public static final int HPY_MEMBER_LONG = 2; - public static final int HPY_MEMBER_FLOAT = 3; - public static final int HPY_MEMBER_DOUBLE = 4; - public static final int HPY_MEMBER_STRING = 5; - public static final int HPY_MEMBER_OBJECT = 6; - public static final int HPY_MEMBER_CHAR = 7; - public static final int HPY_MEMBER_BYTE = 8; - public static final int HPY_MEMBER_UBYTE = 9; - public static final int HPY_MEMBER_USHORT = 10; - public static final int HPY_MEMBER_UINT = 11; - public static final int HPY_MEMBER_ULONG = 12; - public static final int HPY_MEMBER_STRING_INPLACE = 13; - public static final int HPY_MEMBER_BOOL = 14; - public static final int HPY_MEMBER_OBJECT_EX = 16; - public static final int HPY_MEMBER_LONGLONG = 17; - public static final int HPY_MEMBER_ULONGLONG = 18; - public static final int HPY_MEMBER_HPYSSIZET = 19; - public static final int HPY_MEMBER_NONE = 20; - - /* enum values of 'HPyType_SpecParam_Kind' */ - public static final int HPyType_SPEC_PARAM_BASE = 1; - public static final int HPyType_SPEC_PARAM_BASES_TUPLE = 2; - public static final int HPyType_SPEC_PARAM_METACLASS = 3; - - /* type flags according to 'hpytype.h' */ - public static final long _Py_TPFLAGS_HEAPTYPE = (1L << 9); - public static final long HPy_TPFLAGS_BASETYPE = (1L << 10); - public static final long HPy_TPFLAGS_HAVE_GC = (1L << 14); - public static final long HPy_TPFLAGS_DEFAULT = _Py_TPFLAGS_HEAPTYPE; - - /* enum values of 'HPyType_BuiltinShape' */ - public static final int HPyType_BUILTIN_SHAPE_LEGACY = -1; - public static final int HPyType_BUILTIN_SHAPE_OBJECT = 0; - public static final int HPyType_BUILTIN_SHAPE_TYPE = 1; - public static final int HPyType_BUILTIN_SHAPE_LONG = 2; - public static final int HPyType_BUILTIN_SHAPE_FLOAT = 3; - public static final int HPyType_BUILTIN_SHAPE_UNICODE = 4; - public static final int HPyType_BUILTIN_SHAPE_TUPLE = 5; - public static final int HPyType_BUILTIN_SHAPE_LIST = 6; - - /** - * Used when the corresponding slot has not been migrated to the CPython compatible TpSlot, or - * when the CPython compatible TpSlot does not have HPy support yet. - */ - public static final TpSlotMeta NO_TP_SLOT = null; - - /* enum values for 'HPySlot_Slot' */ - enum HPySlot { - HPY_BF_GETBUFFER(1, NO_TP_SLOT, HPySlotWrapper.GETBUFFER, HiddenAttr.GETBUFFER), - HPY_BF_RELEASEBUFFER(2, NO_TP_SLOT, HPySlotWrapper.RELEASEBUFFER, HiddenAttr.RELEASEBUFFER), - HPY_MP_ASS_SUBSCRRIPT(3, NO_TP_SLOT, HPySlotWrapper.OBJOBJARGPROC, T___SETITEM__, T___DELITEM__), - HPY_MP_LENGTH(4, TpSlotMeta.MP_LENGTH, HPySlotWrapper.LENFUNC, T___LEN__), - HPY_MP_SUBSCRIPT(5, TpSlotMeta.MP_SUBSCRIPT, HPySlotWrapper.BINARYFUNC, T___GETITEM__), - HPY_NB_ABSOLUTE(6, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___ABS__), - HPY_NB_ADD(7, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___ADD__, HPySlotWrapper.BINARYFUNC_R, T___RADD__), - HPY_NB_AND(8, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___AND__, HPySlotWrapper.BINARYFUNC_R, T___RAND__), - HPY_NB_BOOL(9, NO_TP_SLOT, HPySlotWrapper.INQUIRYPRED, T___BOOL__), - HPY_NB_DIVMOD(10, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___DIVMOD__), - HPY_NB_FLOAT(11, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___FLOAT__), - HPY_NB_FLOOR_DIVIDE(12, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___FLOORDIV__, HPySlotWrapper.BINARYFUNC_R, T___RFLOORDIV__), - HPY_NB_INDEX(13, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___INDEX__), - HPY_NB_INPLACE_ADD(14, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IADD__), - HPY_NB_INPLACE_AND(15, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IAND__), - HPY_NB_INPLACE_FLOOR_DIVIDE(16, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IFLOORDIV__), - HPY_NB_INPLACE_LSHIFT(17, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___ILSHIFT__), - HPY_NB_INPLACE_MULTIPLY(18, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IMUL__), - HPY_NB_INPLACE_OR(19, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IOR__), - HPY_NB_INPLACE_POWER(20, NO_TP_SLOT, HPySlotWrapper.TERNARYFUNC, T___IPOW__), - HPY_NB_INPLACE_REMAINDER(21, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IMOD__), - HPY_NB_INPLACE_RSHIFT(22, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IRSHIFT__), - HPY_NB_INPLACE_SUBTRACT(23, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___ISUB__), - HPY_NB_INPLACE_TRUE_DIVIDE(24, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___ITRUEDIV__), - HPY_NB_INPLACE_XOR(25, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IXOR__), - HPY_NB_INT(26, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___INT__), - HPY_NB_INVERT(27, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___INVERT__), - HPY_NB_LSHIFT(28, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___LSHIFT__, HPySlotWrapper.BINARYFUNC_R, T___RLSHIFT__), - HPY_NB_MULTIPLY(29, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___MUL__, HPySlotWrapper.BINARYFUNC_R, T___RMUL__), - HPY_NB_NEGATIVE(30, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___NEG__), - HPY_NB_OR(31, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___OR__, HPySlotWrapper.BINARYFUNC_R, T___ROR__), - HPY_NB_POSITIVE(32, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___POS__), - HPY_NB_POWER(33, NO_TP_SLOT, HPySlotWrapper.TERNARYFUNC, T___POW__), - HPY_NB_REMAINDER(34, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___MOD__, HPySlotWrapper.BINARYFUNC_R, T___RMOD__), - HPY_NB_RSHIFT(35, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___RSHIFT__, HPySlotWrapper.BINARYFUNC_R, T___RRSHIFT__), - HPY_NB_SUBTRACT(36, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___SUB__, HPySlotWrapper.BINARYFUNC_R, T___RSUB__), - HPY_NB_TRUE_DIVIDE(37, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___TRUEDIV__, HPySlotWrapper.BINARYFUNC_R, T___RTRUEDIV__), - HPY_NB_XOR(38, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___XOR__, HPySlotWrapper.BINARYFUNC_R, T___RXOR__), - HPY_SQ_ASS_ITEM(39, NO_TP_SLOT, HPySlotWrapper.SQ_SETITEM, T___SETITEM__, HPySlotWrapper.SQ_DELITEM, T___DELITEM__), - HPY_SQ_CONCAT(40, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___ADD__), - HPY_SQ_CONTAINS(41, NO_TP_SLOT, HPySlotWrapper.OBJOBJPROC, T___CONTAINS__), - HPY_SQ_INPLACE_CONCAT(42, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IADD__), - HPY_SQ_INPLACE_REPEAT(43, NO_TP_SLOT, HPySlotWrapper.INDEXARGFUNC, T___IMUL__), - HPY_SQ_ITEM(44, TpSlotMeta.SQ_ITEM, HPySlotWrapper.SQ_ITEM, T___GETITEM__), - HPY_SQ_LENGTH(45, TpSlotMeta.SQ_LENGTH, HPySlotWrapper.LENFUNC, T___LEN__), - HPY_SQ_REPEAT(46, TpSlotMeta.SQ_REPEAT, HPySlotWrapper.INDEXARGFUNC, T___MUL__, T___RMUL__), - HPY_TP_CALL(50, NO_TP_SLOT, HPySlotWrapper.CALL, T___CALL__), - HPY_TP_HASH(59, NO_TP_SLOT, HPySlotWrapper.HASHFUNC, T___HASH__), - HPY_TP_INIT(60, NO_TP_SLOT, HPySlotWrapper.INIT, T___INIT__), - HPY_TP_ITER(62, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___ITER__), - HPY_TP_NEW(65, NO_TP_SLOT, HPySlotWrapper.NULL, T___NEW__), - HPY_TP_REPR(66, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___REPR__), - HPY_TP_RICHCOMPARE(67, NO_TP_SLOT, w(RICHCMP_LT, RICHCMP_LE, RICHCMP_EQ, RICHCMP_NE, RICHCMP_GT, RICHCMP_GE), k(T___LT__, T___LE__, T___EQ__, T___NE__, T___GT__, T___GE__)), - HPY_TP_STR(70, NO_TP_SLOT, HPySlotWrapper.UNARYFUNC, T___STR__), - HPY_TP_TRAVERSE(71, NO_TP_SLOT, HPySlotWrapper.TRAVERSE), - HPY_NB_MATRIX_MULTIPLY(75, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___MATMUL__, HPySlotWrapper.BINARYFUNC_R, T___RMATMUL__), - HPY_NB_INPLACE_MATRIX_MULTIPLY(76, NO_TP_SLOT, HPySlotWrapper.BINARYFUNC_L, T___IMATMUL__), - HPY_TP_FINALIZE(80, NO_TP_SLOT, HPySlotWrapper.DESTRUCTOR), - HPY_TP_DESTROY(1000, NO_TP_SLOT, HPySlotWrapper.DESTROYFUNC), - HPY_MOD_CREATE(2000, NO_TP_SLOT, HPySlotWrapper.MOD_CREATE), - HPY_MOD_EXEC(2001, NO_TP_SLOT, HPySlotWrapper.INQUIRYPRED); - - /** The corresponding C enum value. */ - private final int value; - - /** Corresponding CPython compatible slot */ - private final TpSlotMeta tpSlot; - - /** - * The corresponding attribute key (mostly a {@link TruffleString} which is the name of a - * magic method, or a {@link HiddenAttr} if it's not exposed to the user, or {@code null} if - * unsupported). - */ - @CompilationFinal(dimensions = 1) private final Object[] attributeKeys; - - /** The signatures of the slot functions. */ - @CompilationFinal(dimensions = 1) private final HPySlotWrapper[] signatures; - - /** - * Common case: one slot causes the creation of one attribute. - */ - HPySlot(int value, TpSlotMeta tpSlot, HPySlotWrapper signature, HiddenAttr attributeKey) { - this.value = value; - this.tpSlot = tpSlot; - this.attributeKeys = new Object[]{attributeKey}; - this.signatures = new HPySlotWrapper[]{signature}; - } - - /** - * Special case: one slot causes the creation of multiple attributes using the same slot - * wrapper. - */ - HPySlot(int value, TpSlotMeta tpSlot, HPySlotWrapper signature, TruffleString... attributeKeys) { - this.value = value; - this.tpSlot = tpSlot; - this.attributeKeys = attributeKeys; - if (attributeKeys.length > 0) { - this.signatures = new HPySlotWrapper[attributeKeys.length]; - Arrays.fill(this.signatures, signature); - } else { - this.signatures = new HPySlotWrapper[]{signature}; - } - } - - /** - * Special case: one slot causes the creation of two attributes using different slot - * wrappers. - */ - HPySlot(int value, TpSlotMeta tpSlot, HPySlotWrapper sig0, TruffleString key0, HPySlotWrapper sig1, TruffleString key1) { - this.value = value; - this.tpSlot = tpSlot; - this.attributeKeys = new Object[]{key0, key1}; - this.signatures = new HPySlotWrapper[]{sig0, sig1}; - } - - /** - * Generic case: one slot causes the creation of multiple attributes with each different - * slot wrappers. - */ - HPySlot(int value, TpSlotMeta tpSlot, HPySlotWrapper[] sigs, TruffleString... keys) { - this.value = value; - this.tpSlot = tpSlot; - this.attributeKeys = keys; - this.signatures = sigs; - } - - int getValue() { - return value; - } - - Object[] getAttributeKeys() { - return attributeKeys; - } - - HPySlotWrapper[] getSignatures() { - return signatures; - } - - @CompilationFinal(dimensions = 1) private static final HPySlot[] BY_VALUE = new HPySlot[100]; - - static { - for (var entry : values()) { - if (entry.value >= 0 && entry.value < BY_VALUE.length) { - assert BY_VALUE[entry.value] == null; - BY_VALUE[entry.value] = entry; - } - } - } - - static HPySlot fromValue(int value) { - if (value >= 0 && value < BY_VALUE.length) { - return BY_VALUE[value]; - } - if (HPY_TP_DESTROY.value == value) { - return HPY_TP_DESTROY; - } else if (HPY_MOD_CREATE.value == value) { - return HPY_MOD_CREATE; - } else if (HPY_MOD_EXEC.value == value) { - return HPY_MOD_EXEC; - } - return null; - } - - private static HPySlotWrapper[] w(HPySlotWrapper... wrappers) { - return wrappers; - } - - private static TruffleString[] k(TruffleString... keys) { - return keys; - } - - public TpSlotMeta getTpSlot() { - return tpSlot; - } - } - - public static boolean isValidBuiltinShape(int i) { - return HPyType_BUILTIN_SHAPE_LEGACY <= i && i <= HPyType_BUILTIN_SHAPE_LIST; - } - - public static int getBuiltinShapeFromHiddenAttribute(Object object) { - if (object instanceof PythonClass pythonClass) { - return pythonClass.getBuiltinShape(); - } else if (object instanceof PythonAbstractNativeObject) { - assert IsTypeNode.executeUncached(object); - return HPyType_BUILTIN_SHAPE_LEGACY; - } - return -2; // error - } - - static PythonBuiltinClassType getBuiltinClassType(int builtinShape) { - return switch (builtinShape) { - case HPyType_BUILTIN_SHAPE_LEGACY, HPyType_BUILTIN_SHAPE_OBJECT -> PythonBuiltinClassType.PythonObject; - case HPyType_BUILTIN_SHAPE_TYPE -> PythonBuiltinClassType.PythonClass; - case HPyType_BUILTIN_SHAPE_LONG -> PythonBuiltinClassType.PInt; - case HPyType_BUILTIN_SHAPE_FLOAT -> PythonBuiltinClassType.PFloat; - case HPyType_BUILTIN_SHAPE_UNICODE -> PythonBuiltinClassType.PString; - case HPyType_BUILTIN_SHAPE_TUPLE -> PythonBuiltinClassType.PTuple; - case HPyType_BUILTIN_SHAPE_LIST -> PythonBuiltinClassType.PList; - default -> throw CompilerDirectives.shouldNotReachHere(GraalHPyNew.INVALID_BUILT_IN_SHAPE); - }; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyHandle.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyHandle.java deleted file mode 100644 index 132e94c20a..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyHandle.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2019, 2023, 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. - */ -// skip GIL -package com.oracle.graal.python.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.assertNoJavaString; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PythonAbstractObject; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GetHPyHandleForSingleton; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFactory.GetHPyHandleForSingletonNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMContext; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnknownIdentifierException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.llvm.spi.NativeTypeLibrary; - -@ExportLibrary(InteropLibrary.class) -@ExportLibrary(value = NativeTypeLibrary.class, useForAOT = false) -public final class GraalHPyHandle implements TruffleObject { - private static final int UNINITIALIZED = Integer.MIN_VALUE; - - public static final Object NULL_HANDLE_DELEGATE = PNone.NO_VALUE; - public static final GraalHPyHandle NULL_HANDLE = new GraalHPyHandle(); - public static final String J_I = "_i"; - public static final TruffleString T_I = tsLiteral(J_I); - - private final Object delegate; - /** - * The ID of the handle if it was allocated in the handle table. - *

    - * The value also encodes the state:
    - * (1) If the value is {@link #UNINITIALIZED}, then the handle was never allocated in the handle - * table.
    - * (2) If the value is zero or positive then this is the index for the handle table. If the
    - * (3) If the value is negative but not {@link #UNINITIALIZED} then the handle was already - * closed (only used in HPy debug mode)
    - *

    - */ - private int id; - - private GraalHPyHandle() { - this(NULL_HANDLE_DELEGATE, 0); - } - - private GraalHPyHandle(Object delegate) { - this(delegate, UNINITIALIZED); - } - - private GraalHPyHandle(Object delegate, int id) { - assert delegate != null : "HPy handles to Java null are not allowed"; - assert delegate != NULL_HANDLE_DELEGATE || id == 0 : "must not not create more than on HPy_NULL"; - this.delegate = assertNoJavaString(delegate); - this.id = id; - } - - public static GraalHPyHandle createSingleton(Object delegate, int handle) { - assert handle <= GraalHPyBoxing.SINGLETON_HANDLE_MAX; - return new GraalHPyHandle(delegate, handle); - } - - public static GraalHPyHandle create(Object delegate) { - return new GraalHPyHandle(delegate); - } - - public static GraalHPyHandle createField(Object delegate, int idx) { - return new GraalHPyHandle(delegate, idx); - } - - public static GraalHPyHandle createGlobal(Object delegate, int idx) { - return new GraalHPyHandle(delegate, idx); - } - - /** - * This is basically like {@code toNative} but also returns the ID. - */ - public int getIdUncached(GraalHPyContext context) { - return getId(context, ConditionProfile.getUncached(), GetHPyHandleForSingletonNodeGen.getUncached()); - } - - public int getId(GraalHPyContext context, ConditionProfile hasIdProfile, GetHPyHandleForSingleton getSingletonNode) { - int result = id; - if (!isPointer(hasIdProfile)) { - assert !GraalHPyBoxing.isBoxablePrimitive(delegate) : "allocating handle for value that could be boxed"; - result = getSingletonNode.execute(this.delegate); - if (result == -1) { - // profiled by the node - result = context.getHPyHandleForNonSingleton(this.delegate); - } - id = result; - } - assert isValidId(this.delegate, result); - return result; - } - - public boolean isValidId(Object obj, int newId) { - if (delegate == PNone.NO_VALUE) { - // special case of HPy_NULL internally represented as NO_VALUE - return newId == 0; - } - int singletonId = GraalHPyContext.getHPyHandleForSingleton(obj); - return singletonId == -1 || singletonId == newId; - } - - @ExportMessage - boolean isPointer( - @Exclusive @Cached(inline = false) ConditionProfile isNativeProfile) { - return isNativeProfile.profile(id >= 0 || delegate instanceof Integer || delegate instanceof Double); - } - - @ExportMessage - long asPointer() throws UnsupportedMessageException { - // note: we don't use a profile here since 'asPointer' is usually used right after - // 'isPointer' - if (!isPointer(ConditionProfile.getUncached())) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw UnsupportedMessageException.create(); - } - if (id != UNINITIALIZED) { - return GraalHPyBoxing.boxHandle(id); - } else if (delegate instanceof Integer) { - return GraalHPyBoxing.boxInt((Integer) delegate); - } else if (delegate instanceof Double) { - return GraalHPyBoxing.boxDouble((Double) delegate); - } - throw CompilerDirectives.shouldNotReachHere(); - } - - /** - * Allocates the handle in the global handle table of the provided HPy context. If this is used - * in compiled code, this {@code GraalHPyHandle} object will definitively be allocated. - */ - @ExportMessage - void toNative(@Exclusive @Cached(inline = false) ConditionProfile isNativeProfile, - @Cached GetHPyHandleForSingleton getSingletonNode, - @CachedLibrary("this") InteropLibrary lib) { - getId(PythonContext.get(lib).getHPyContext(), isNativeProfile, getSingletonNode); - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasNativeType(@Bind("$node") Node node) { - return PythonContext.get(node).getHPyContext().getBackend() instanceof GraalHPyLLVMContext; - } - - @ExportMessage - Object getNativeType(@Bind("$node") Node node) { - if (PythonContext.get(node).getHPyContext().getBackend() instanceof GraalHPyLLVMContext backend) { - return backend.getHPyNativeType(); - } - throw CompilerDirectives.shouldNotReachHere(); - } - - public Object getDelegate() { - return delegate; - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasMembers() { - return true; - } - - @ExportMessage - @SuppressWarnings("static-method") - Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { - return new PythonAbstractObject.Keys(new TruffleString[]{T_I}); - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean isMemberReadable(String key, - @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared("eq") @Cached TruffleString.EqualNode eqNode) { - TruffleString tmember = fromJavaStringNode.execute(key, TS_ENCODING); - return eqNode.execute(T_I, tmember, TS_ENCODING); - } - - @ExportMessage - Object readMember(String key, - @Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Shared("eq") @Cached TruffleString.EqualNode eqNode) throws UnknownIdentifierException { - TruffleString tmember = fromJavaStringNode.execute(key, TS_ENCODING); - if (eqNode.execute(T_I, tmember, TS_ENCODING)) { - return this; - } - throw UnknownIdentifierException.create(key); - } - - @ExportMessage - boolean isNull() { - return id == 0; - } - - static boolean isAllocated(int id) { - return id != UNINITIALIZED && id != 0; - } - - boolean isAllocated() { - return GraalHPyHandle.isAllocated(id); - } - - boolean isValid() { - return id > 0; - } - - void closeAndInvalidate(GraalHPyContext hpyContext) { - assert id != UNINITIALIZED; - if (hpyContext.releaseHPyHandleForObject(id)) { - id = -id; - } - } - - int getGlobalId() { - assert id > 0 : "any HPyGlobal handle already has an id"; - return id; - } - - int getFieldId() { - assert id >= 0 : "any HPyField handle already has an id"; - return id; - } - - public GraalHPyHandle copy() { - return new GraalHPyHandle(delegate); - } - - static boolean wasAllocated(int id) { - return id != UNINITIALIZED; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyLegacyDef.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyLegacyDef.java deleted file mode 100644 index 1138394fe8..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyLegacyDef.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.nodes.SpecialMethodNames.T_TP_RICHCOMPARE; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ABS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ALLOC__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___BOOL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CLEAR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CONTAINS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DEALLOC__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DEL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DIVMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOAT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FREE__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GET__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IADD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IAND__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IFLOORDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ILSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INDEX__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INIT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___INVERT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IPOW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IRSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ISUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LEN__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MATMUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MUL__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEG__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POS__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETATTR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETITEM__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SET__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUB__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUEDIV__; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___XOR__; - -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; -import com.oracle.graal.python.builtins.objects.type.TpSlots.TpSlotMeta; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.strings.TruffleString; - -/** - * Definitions for legacy slots. - */ -public abstract class GraalHPyLegacyDef { - public static final int MEMBER_FLAG_READONLY = 1; - - /** - * Used when the corresponding slot has not been migrated to the CPython compatible TpSlot, or - * there is no equivalent CPython slot (for those we may still reserve space in TpSlots in the - * future). - */ - public static final TpSlotMeta NO_TP_SLOT = null; - - /** - * Values for field {@code slot} of structure {@code PyType_Slot}. - */ - enum HPyLegacySlot { - // generic type slots - Py_tp_alloc(47, NO_TP_SLOT, T___ALLOC__, PExternalFunctionWrapper.ALLOC), - Py_tp_base(48, NO_TP_SLOT), - Py_tp_bases(49, NO_TP_SLOT), - Py_tp_call(50, NO_TP_SLOT, T___CALL__, PExternalFunctionWrapper.KEYWORDS), - Py_tp_clear(51, NO_TP_SLOT, T___CLEAR__, PExternalFunctionWrapper.INQUIRY), - Py_tp_dealloc(52, NO_TP_SLOT, T___DEALLOC__), - Py_tp_del(53, NO_TP_SLOT, T___DEL__), - Py_tp_descr_get(54, NO_TP_SLOT, T___GET__), - Py_tp_descr_set(55, NO_TP_SLOT, T___SET__), - Py_tp_doc(56, NO_TP_SLOT), - Py_tp_getattr(57, NO_TP_SLOT, T___GETATTR__, PExternalFunctionWrapper.GETATTR), - Py_tp_getattro(58, NO_TP_SLOT, T___GETATTR__), - Py_tp_hash(59, NO_TP_SLOT, T___HASH__, PExternalFunctionWrapper.HASHFUNC), - Py_tp_init(60, NO_TP_SLOT, T___INIT__, PExternalFunctionWrapper.INITPROC), - Py_tp_is_gc(61, NO_TP_SLOT), - Py_tp_iter(62, NO_TP_SLOT, T___ITER__), - Py_tp_iternext(63, NO_TP_SLOT, T___NEXT__, PExternalFunctionWrapper.ITERNEXT), - Py_tp_methods(64, NO_TP_SLOT), - Py_tp_new(65, NO_TP_SLOT, T___NEW__, PExternalFunctionWrapper.KEYWORDS), - Py_tp_repr(66, NO_TP_SLOT, T___REPR__, PExternalFunctionWrapper.TP_REPR), - Py_tp_richcompare(67, TpSlotMeta.TP_RICHCOMPARE, T_TP_RICHCOMPARE, PExternalFunctionWrapper.RICHCMP), - Py_tp_setattr(68, NO_TP_SLOT, T___SETATTR__, PExternalFunctionWrapper.SETATTR), - Py_tp_setattro(69, NO_TP_SLOT, T___SETATTR__), - Py_tp_str(70, NO_TP_SLOT, T___STR__, PExternalFunctionWrapper.TP_STR), - Py_tp_traverse(71, NO_TP_SLOT), - Py_tp_members(72, NO_TP_SLOT), - Py_tp_getset(73, NO_TP_SLOT), - Py_tp_free(74, NO_TP_SLOT, T___FREE__), - - // PyMappingMethods, NO_TP_SLOT - Py_mp_ass_subscript(3, NO_TP_SLOT, T___SETITEM__, PExternalFunctionWrapper.OBJOBJARGPROC), - Py_mp_length(4, NO_TP_SLOT, T___LEN__, PExternalFunctionWrapper.LENFUNC), - Py_mp_subscript(5, NO_TP_SLOT, T___GETITEM__), - - // PyNumberMethods, NO_TP_SLOT - Py_nb_absolute(6, NO_TP_SLOT, T___ABS__), - Py_nb_add(7, NO_TP_SLOT, T___ADD__), - Py_nb_and(8, NO_TP_SLOT, T___AND__), - Py_nb_bool(9, NO_TP_SLOT, T___BOOL__, PExternalFunctionWrapper.INQUIRY), - Py_nb_divmod(10, NO_TP_SLOT, T___DIVMOD__), - Py_nb_float(11, NO_TP_SLOT, T___FLOAT__), - Py_nb_floor_divide(12, NO_TP_SLOT, T___FLOORDIV__), - Py_nb_index(13, NO_TP_SLOT, T___INDEX__), - Py_nb_inplace_add(14, NO_TP_SLOT, T___IADD__), - Py_nb_inplace_and(15, NO_TP_SLOT, T___IAND__), - Py_nb_inplace_floor_divide(16, NO_TP_SLOT, T___IFLOORDIV__), - Py_nb_inplace_lshift(17, NO_TP_SLOT, T___ILSHIFT__), - Py_nb_inplace_multiply(18, NO_TP_SLOT, T___IMUL__), - Py_nb_inplace_or(19, NO_TP_SLOT, T___IOR__), - Py_nb_inplace_power(20, NO_TP_SLOT, T___IPOW__), - Py_nb_inplace_remainder(21, NO_TP_SLOT, T___IMOD__), - Py_nb_inplace_rshift(22, NO_TP_SLOT, T___IRSHIFT__), - Py_nb_inplace_subtract(23, NO_TP_SLOT, T___ISUB__), - Py_nb_inplace_true_divide(24, NO_TP_SLOT, T___ITRUEDIV__), - Py_nb_inplace_xor(25, NO_TP_SLOT, T___IXOR__), - Py_nb_int(26, NO_TP_SLOT, T___INT__), - Py_nb_invert(27, NO_TP_SLOT, T___INVERT__), - Py_nb_lshift(28, NO_TP_SLOT, T___LSHIFT__), - Py_nb_multiply(29, NO_TP_SLOT, T___MUL__), - Py_nb_negative(30, NO_TP_SLOT, T___NEG__), - Py_nb_or(31, NO_TP_SLOT, T___OR__), - Py_nb_positive(32, NO_TP_SLOT, T___POS__), - Py_nb_power(33, NO_TP_SLOT, T___POW__, PExternalFunctionWrapper.TERNARYFUNC), - Py_nb_remainder(34, NO_TP_SLOT, T___MOD__), - Py_nb_rshift(35, NO_TP_SLOT, T___RSHIFT__), - Py_nb_subtract(36, NO_TP_SLOT, T___SUB__), - Py_nb_true_divide(37, NO_TP_SLOT, T___TRUEDIV__), - Py_nb_xor(38, NO_TP_SLOT, T___XOR__), - Py_nb_matrix_multiply(75, NO_TP_SLOT, T___MATMUL__), - Py_nb_inplace_matrix_multiply(76, NO_TP_SLOT, T___IMATMUL__), - - // PySequenceMethods, NO_TP_SLOT - Py_sq_ass_item(39, NO_TP_SLOT, T___SETITEM__, PExternalFunctionWrapper.SETITEM), - Py_sq_concat(40, NO_TP_SLOT, T___ADD__), - Py_sq_contains(41, NO_TP_SLOT, T___CONTAINS__, PExternalFunctionWrapper.OBJOBJPROC), - Py_sq_inplace_concat(42, NO_TP_SLOT, T___IADD__), - Py_sq_inplace_repeat(43, NO_TP_SLOT, T___IMUL__, PExternalFunctionWrapper.SSIZE_ARG), - Py_sq_item(44, TpSlotMeta.SQ_ITEM, T___GETITEM__, PExternalFunctionWrapper.GETITEM), - Py_sq_length(45, NO_TP_SLOT, T___LEN__, PExternalFunctionWrapper.LENFUNC), - Py_sq_repeat(46, NO_TP_SLOT, T___MUL__, PExternalFunctionWrapper.SSIZE_ARG), - - // PyAsyncMethods, NO_TP_SLOT - Py_am_await(77, NO_TP_SLOT), - Py_am_aiter(78, NO_TP_SLOT), - Py_am_anext(79, NO_TP_SLOT); - - /** The corresponding C enum value. */ - private final int value; - - /** Corresponding CPython compatible slot. */ - private final TpSlotMeta tpSlot; - - /** - * The corresponding attribute key (mostly a {@link String} which is the name of a magic - * method, or a {@link com.oracle.graal.python.nodes.HiddenAttr} if it's not exposed to the - * user, or {@code null} if unsupported). - */ - private final TruffleString attributeKey; - - /** The signature of the slot function. */ - private final PExternalFunctionWrapper signature; - - HPyLegacySlot(int value, TpSlotMeta tpSlot) { - this(value, tpSlot, null); - } - - HPyLegacySlot(int value, TpSlotMeta tpSlot, TruffleString attributeKey) { - this(value, tpSlot, attributeKey, PExternalFunctionWrapper.DIRECT); - } - - HPyLegacySlot(int value, TpSlotMeta tpSlot, TruffleString attributeKey, PExternalFunctionWrapper signature) { - this.value = value; - this.tpSlot = tpSlot; - this.attributeKey = attributeKey; - this.signature = signature; - } - - int getValue() { - return value; - } - - TruffleString getAttributeKey() { - return attributeKey; - } - - PExternalFunctionWrapper getSignature() { - return signature; - } - - @CompilationFinal(dimensions = 1) private static final HPyLegacySlot[] VALUES = values(); - @CompilationFinal(dimensions = 1) private static final HPyLegacySlot[] BY_VALUE = new HPyLegacySlot[100]; - - static { - for (var entry : VALUES) { - assert BY_VALUE[entry.value] == null; - BY_VALUE[entry.value] = entry; - } - } - - static HPyLegacySlot fromValue(int value) { - return value >= 0 && value < BY_VALUE.length ? BY_VALUE[value] : null; - } - - public TpSlotMeta getTpSlot() { - return tpSlot; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java deleted file mode 100644 index b343ff1d62..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyMemberAccessNodes.java +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Copyright (c) 2020, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_BOOL; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_BYTE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_CHAR; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_DOUBLE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_FLOAT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_HPYSSIZET; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_INT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_LONG; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_LONGLONG; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_NONE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_OBJECT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_OBJECT_EX; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_SHORT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_STRING; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_STRING_INPLACE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_UBYTE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_UINT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_ULONG; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_ULONGLONG; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPY_MEMBER_USHORT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Bool; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.CDouble; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.CFloat; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int16_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int64_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int8_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Uint16_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Uint8_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.UnsignedInt; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.UnsignedLong; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.Builtin; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.cext.common.CExtAsPythonObjectNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.AsNativeCharNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.AsNativePrimitiveNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.AsNativeCharNodeGen; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.AsNativePrimitiveNodeGen; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.NativePrimitiveAsPythonBooleanNodeGen; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.NativePrimitiveAsPythonCharNodeGen; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.NativeUnsignedPrimitiveAsPythonObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodesFactory.HPyBadMemberDescrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodesFactory.HPyReadMemberNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodesFactory.HPyReadOnlyMemberNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodesFactory.HPyWriteMemberNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodesFactory.PyFloatAsDoubleCachedNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyGetNativeSpacePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetNativeSpacePointerNodeGen; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.getsetdescriptor.DescriptorDeleteMarker; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.lib.PyFloatAsDoubleNode; -import com.oracle.graal.python.lib.PyLongAsLongNode; -import com.oracle.graal.python.lib.PyLongAsLongNodeGen; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; -import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; -import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; -import com.oracle.graal.python.nodes.interop.PForeignToPTypeNode; -import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectExactProfile; -import com.oracle.graal.python.nodes.object.IsNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils.PrototypeNodeFactory; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.strings.TruffleString; - -public class GraalHPyMemberAccessNodes { - - static HPyContextSignatureType getCType(int type) { - switch (type) { - case HPY_MEMBER_SHORT: - return HPyContextSignatureType.Int16_t; - case HPY_MEMBER_INT: - return HPyContextSignatureType.Int; - case HPY_MEMBER_LONG: - return HPyContextSignatureType.Long; - case HPY_MEMBER_FLOAT: - return HPyContextSignatureType.CFloat; - case HPY_MEMBER_DOUBLE: - return HPyContextSignatureType.CDouble; - case HPY_MEMBER_STRING: - return HPyContextSignatureType.CharPtr; - case HPY_MEMBER_OBJECT: - case HPY_MEMBER_OBJECT_EX: - return HPyContextSignatureType.HPyField; - case HPY_MEMBER_CHAR: - case HPY_MEMBER_BYTE: - return HPyContextSignatureType.Int8_t; - case HPY_MEMBER_BOOL: - return HPyContextSignatureType.Bool; - case HPY_MEMBER_UBYTE: - return HPyContextSignatureType.Uint8_t; - case HPY_MEMBER_USHORT: - return HPyContextSignatureType.Uint16_t; - case HPY_MEMBER_UINT: - return HPyContextSignatureType.UnsignedInt; - case HPY_MEMBER_ULONG: - return HPyContextSignatureType.UnsignedLong; - case HPY_MEMBER_STRING_INPLACE, HPY_MEMBER_NONE: - return null; - case HPY_MEMBER_LONGLONG: - return HPyContextSignatureType.Uint64_t; - case HPY_MEMBER_ULONGLONG: - return HPyContextSignatureType.Int64_t; - case HPY_MEMBER_HPYSSIZET: - return HPyContextSignatureType.HPy_ssize_t; - } - throw CompilerDirectives.shouldNotReachHere("invalid member type"); - } - - static CExtAsPythonObjectNode getReadConverterNode(int type) { - return switch (type) { - // no conversion needed - case HPY_MEMBER_SHORT, HPY_MEMBER_INT, HPY_MEMBER_LONG, HPY_MEMBER_FLOAT, HPY_MEMBER_DOUBLE, HPY_MEMBER_BYTE, HPY_MEMBER_UBYTE, HPY_MEMBER_USHORT, HPY_MEMBER_STRING, - HPY_MEMBER_STRING_INPLACE, HPY_MEMBER_HPYSSIZET, HPY_MEMBER_NONE, HPY_MEMBER_OBJECT, HPY_MEMBER_OBJECT_EX -> - null; - case HPY_MEMBER_BOOL -> NativePrimitiveAsPythonBooleanNodeGen.create(); - case HPY_MEMBER_CHAR -> NativePrimitiveAsPythonCharNodeGen.create(); - case HPY_MEMBER_UINT, HPY_MEMBER_ULONG, HPY_MEMBER_LONGLONG, HPY_MEMBER_ULONGLONG -> NativeUnsignedPrimitiveAsPythonObjectNodeGen.create(); - default -> throw CompilerDirectives.shouldNotReachHere("invalid member type"); - }; - } - - /** - * Special case: members with type {@code STRING} and {@code STRING_INPLACE} are always - * read-only. - */ - static boolean isReadOnlyType(int type) { - return type == HPY_MEMBER_STRING || type == HPY_MEMBER_STRING_INPLACE; - } - - @Builtin(name = "hpy_member_read", minNumOfPositionalArgs = 1, parameterNames = "$self") - protected abstract static class HPyReadMemberNode extends PythonUnaryBuiltinNode { - private static final Builtin builtin = HPyReadMemberNode.class.getAnnotation(Builtin.class); - - @Child private GraalHPyCAccess.ReadGenericNode readGenericNode; - @Child private GraalHPyCAccess.ReadHPyFieldNode readHPyFieldNode; - @Child private GraalHPyCAccess.GetElementPtrNode getElementPtrNode; - @Child private GraalHPyCAccess.IsNullNode isNullNode; - @Child private HPyFromCharPointerNode fromCharPointerNode; - @Child private CExtAsPythonObjectNode asPythonObjectNode; - @Child private PForeignToPTypeNode fromForeign; - @Child private HPyGetNativeSpacePointerNode readNativeSpaceNode; - - /** The specified member type. */ - private final int type; - - /** The name of the native getter function. */ - private final HPyContextSignatureType fieldType; - - /** The offset where to read from (will be passed to the native getter). */ - private final int offset; - - protected HPyReadMemberNode(int offset, int type, CExtAsPythonObjectNode asPythonObjectNode) { - this.fieldType = getCType(type); - this.offset = offset; - this.type = type; - this.asPythonObjectNode = asPythonObjectNode; - if (asPythonObjectNode == null) { - fromForeign = PForeignToPTypeNode.create(); - } - } - - @Specialization - Object doGeneric(@SuppressWarnings("unused") VirtualFrame frame, Object self, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode) { - GraalHPyContext hPyContext = getContext().getHPyContext(); - - Object nativeSpacePtr = ensureReadNativeSpaceNode().executeCached(self); - if (nativeSpacePtr == PNone.NO_VALUE) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_READ_FROM_OFFSET_D, offset, self); - } - Object nativeResult; - switch (type) { - case HPY_MEMBER_OBJECT, HPY_MEMBER_OBJECT_EX: { - if (self instanceof PythonObject pythonObject) { - Object fieldValue = ensureReadHPyFieldNode(hPyContext).read(hPyContext, pythonObject, nativeSpacePtr, offset); - if (fieldValue == GraalHPyHandle.NULL_HANDLE_DELEGATE) { - if (type == HPY_MEMBER_OBJECT) { - return PNone.NONE; - } else { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError); - } - } - return fieldValue; - } else { - throw CompilerDirectives.shouldNotReachHere("Cannot have HPyField on non-Python object"); - } - } - case HPY_MEMBER_NONE: - return PNone.NONE; - case HPY_MEMBER_STRING: - nativeResult = ensureReadGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, fieldType); - if (ensureIsNullNode(hPyContext).execute(hPyContext, nativeResult)) { - return PNone.NONE; - } - return ensureFromCharPointerNode(hPyContext).execute(hPyContext, nativeResult, false); - case HPY_MEMBER_STRING_INPLACE: - Object elementPtr = ensureGetElementPtrNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset); - return ensureFromCharPointerNode(hPyContext).execute(hPyContext, elementPtr, false); - default: - // default case: reading a primitive or a pointer - assert fieldType != null; - nativeResult = ensureReadGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, fieldType); - if (asPythonObjectNode != null) { - return asPythonObjectNode.execute(nativeResult); - } - /* - * We still need to use 'PForeignToPTypeNode' to ensure that we do not introduce - * unknown values into our value space. - */ - return fromForeign.executeConvert(nativeResult); - } - } - - private GraalHPyCAccess.ReadGenericNode ensureReadGenericNode(GraalHPyContext ctx) { - if (readGenericNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readGenericNode = insert(GraalHPyCAccess.ReadGenericNode.create(ctx)); - } - return readGenericNode; - } - - private GraalHPyCAccess.IsNullNode ensureIsNullNode(GraalHPyContext ctx) { - if (isNullNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - isNullNode = insert(GraalHPyCAccess.IsNullNode.create(ctx)); - } - return isNullNode; - } - - private GraalHPyCAccess.ReadHPyFieldNode ensureReadHPyFieldNode(GraalHPyContext ctx) { - if (readHPyFieldNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readHPyFieldNode = insert(GraalHPyCAccess.ReadHPyFieldNode.create(ctx)); - } - return readHPyFieldNode; - } - - private GraalHPyCAccess.GetElementPtrNode ensureGetElementPtrNode(GraalHPyContext ctx) { - if (getElementPtrNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getElementPtrNode = insert(GraalHPyCAccess.GetElementPtrNode.create(ctx)); - } - return getElementPtrNode; - } - - private HPyFromCharPointerNode ensureFromCharPointerNode(GraalHPyContext ctx) { - if (fromCharPointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - fromCharPointerNode = insert(HPyFromCharPointerNode.create(ctx)); - } - return fromCharPointerNode; - } - - private HPyGetNativeSpacePointerNode ensureReadNativeSpaceNode() { - if (readNativeSpaceNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readNativeSpaceNode = insert(HPyGetNativeSpacePointerNodeGen.create()); - } - return readNativeSpaceNode; - } - - @TruffleBoundary - public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString propertyName, int type, int offset) { - CExtAsPythonObjectNode asPythonObjectNode = getReadConverterNode(type); - RootCallTarget callTarget = language.createCachedPropAccessCallTarget( - l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyReadMemberNodeGen.create(offset, type, asPythonObjectNode)), true), - HPyReadMemberNode.class, builtin.name(), type, offset); - int flags = PBuiltinFunction.getFlags(builtin, callTarget); - return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, callTarget); - } - } - - @Builtin(name = "hpy_member_write_read_only", minNumOfPositionalArgs = 1, parameterNames = {"$self", "value"}) - protected abstract static class HPyReadOnlyMemberNode extends PythonBinaryBuiltinNode { - private static final Builtin builtin = HPyReadOnlyMemberNode.class.getAnnotation(Builtin.class); - private final TruffleString propertyName; - - protected HPyReadOnlyMemberNode(TruffleString propertyName) { - this.propertyName = propertyName; - } - - @Specialization - @SuppressWarnings("unused") - Object doGeneric(Object self, Object value, - @Bind("this") Node inliningTarget) { - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTRIBUTE_S_OF_P_OBJECTS_IS_NOT_WRITABLE, propertyName, self); - } - - @TruffleBoundary - public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString propertyName) { - RootCallTarget builtinCt = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyReadOnlyMemberNodeGen.create(propertyName)), true), - HPyReadOnlyMemberNode.class, builtin.name()); - int flags = PBuiltinFunction.getFlags(builtin, builtinCt); - return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); - } - } - - @Builtin(name = "hpy_bad_member_descr", minNumOfPositionalArgs = 2, parameterNames = {"$self", "value"}) - protected abstract static class HPyBadMemberDescrNode extends PythonBinaryBuiltinNode { - private static final Builtin builtin = HPyBadMemberDescrNode.class.getAnnotation(Builtin.class); - - @Specialization - static Object doGeneric(Object self, @SuppressWarnings("unused") Object value, - @Bind("this") Node inliningTarget) { - if (value == DescriptorDeleteMarker.INSTANCE) { - // This node is actually only used for T_NONE, so this error message is right. - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); - } - throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_P, self); - } - - @TruffleBoundary - public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString propertyName) { - RootCallTarget builtinCt = language.createCachedCallTarget(l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyBadMemberDescrNodeGen.create()), true), - HPyBadMemberDescrNode.class, builtin.name()); - int flags = PBuiltinFunction.getFlags(builtin, builtinCt); - return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, builtinCt); - } - } - - @Builtin(name = "hpy_write_member", minNumOfPositionalArgs = 2, parameterNames = {"$self", "value"}) - protected abstract static class HPyWriteMemberNode extends PythonBinaryBuiltinNode { - private static final Builtin builtin = HPyWriteMemberNode.class.getAnnotation(Builtin.class); - - @Child private AsNativeCharNode asNativeCharNode; - @Child private PyLongAsLongNode pyLongAsLongNode; - @Child private PyFloatAsDoubleCachedNode pyFloatAsDoubleNode; - @Child private AsNativePrimitiveNode asNativePrimitiveNode; - @Child private IsBuiltinObjectExactProfile isBuiltinObjectProfile; - @Child private IsNode isNode; - @Child private GraalHPyCAccess.ReadHPyFieldNode readHPyFieldNode; - @Child private GraalHPyCAccess.WriteHPyFieldNode writeHPyFieldNode; - @Child private GraalHPyCAccess.WriteGenericNode writeGenericNode; - @Child private HPyGetNativeSpacePointerNode readNativeSpaceNode; - - /** The specified member type. */ - private final int type; - - /** The offset where to read from (will be passed to the native getter). */ - private final int offset; - - protected HPyWriteMemberNode(int type, int offset) { - this.type = type; - this.offset = offset; - } - - @Specialization - Object doGeneric(VirtualFrame frame, Object self, Object value, - @Bind("this") Node inliningTarget, - @Cached PRaiseNode raiseNode) { - PythonContext context = getContext(); - GraalHPyContext hPyContext = context.getHPyContext(); - - Object nativeSpacePtr = ensureReadNativeSpaceNode().executeCached(self); - if (nativeSpacePtr == PNone.NO_VALUE) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.SystemError, ErrorMessages.ATTEMPTING_WRITE_OFFSET_D, offset, self); - } - - /* - * Deleting values is only allowed for members with object type (see structmember.c: - * PyMember_SetOne). - */ - Object newValue; - if (value == DescriptorDeleteMarker.INSTANCE) { - if (type == HPY_MEMBER_OBJECT_EX) { - if (self instanceof PythonObject pythonObject) { - Object oldValue = ensureReadHPyFieldNode(hPyContext).read(hPyContext, pythonObject, nativeSpacePtr, offset); - if (oldValue == PNone.NO_VALUE) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.AttributeError); - } - } else { - throw CompilerDirectives.shouldNotReachHere("Cannot have HPyField on non-Python object"); - } - } else if (type != HPY_MEMBER_OBJECT) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CAN_T_DELETE_NUMERIC_CHAR_ATTRIBUTE); - } - // NO_VALUE will be converted to the NULL handle - newValue = PNone.NO_VALUE; - } else { - newValue = value; - } - - long val; - switch (type) { - case HPY_MEMBER_SHORT: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int16_t, val); - // TODO(fa): truncation warning - // if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN)) - // WARN("Truncation of value to short"); - break; - case HPY_MEMBER_INT: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int, val); - // TODO(fa): truncation warning - // if ((long_val > INT_MAX) || (long_val < INT_MIN)) - // WARN("Truncation of value to int"); - break; - case HPY_MEMBER_LONG: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, HPyContextSignatureType.Long, val); - break; - case HPY_MEMBER_FLOAT: { - float fvalue = (float) ensurePyFloatAsDoubleNode().execute(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, CFloat, fvalue); - break; - } - case HPY_MEMBER_DOUBLE: { - double dvalue = ensurePyFloatAsDoubleNode().execute(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, CDouble, dvalue); - break; - } - case HPY_MEMBER_STRING, HPY_MEMBER_STRING_INPLACE: - /* - * This node is never created for string members because they are not writeable - * and we create HPyReadOnlyMemberNode for those. - */ - throw CompilerDirectives.shouldNotReachHere(); - case HPY_MEMBER_OBJECT, HPY_MEMBER_OBJECT_EX: - if (self instanceof PythonObject pythonObject) { - ensureWriteHPyFieldNode(hPyContext).execute(hPyContext, pythonObject, nativeSpacePtr, offset, newValue); - } else { - throw CompilerDirectives.shouldNotReachHere("Cannot have HPyField on non-Python object"); - } - break; - case HPY_MEMBER_CHAR: - val = ensureAsNativeCharNode().executeByte(newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int8_t, val); - break; - case HPY_MEMBER_BYTE: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int8_t, val); - // TODO(fa): truncation warning - // if ((long_val > CHAR_MAX) || (long_val < CHAR_MIN)) - // WARN("Truncation of value to char"); - break; - case HPY_MEMBER_UBYTE: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Uint8_t, val); - // TODO(fa): truncation warning - // if ((long_val > UCHAR_MAX) || (long_val < 0)) - // WARN("Truncation of value to unsigned char"); - break; - case HPY_MEMBER_USHORT: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Uint16_t, val); - // TODO(fa): truncation warning - // if ((long_val > USHRT_MAX) || (long_val < 0)) - // WARN("Truncation of value to unsigned short"); - break; - case HPY_MEMBER_UINT: { - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - Object uint = ensureAsNativePrimitiveNode().execute(val, 0, hPyContext.getCTypeSize(UnsignedInt), true); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, UnsignedInt, uint); - break; - } - case HPY_MEMBER_ULONG: { - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - Object ulong = ensureAsNativePrimitiveNode().execute(val, 0, hPyContext.getCTypeSize(UnsignedLong), true); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, UnsignedLong, ulong); - break; - } - case HPY_MEMBER_BOOL: - // note: exact type check is sufficient; bool cannot be subclassed - if (!ensureIsBuiltinObjectProfile().profileObject(this, newValue, PythonBuiltinClassType.Boolean)) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.ATTR_VALUE_MUST_BE_BOOL); - } - val = ensureIsNode().isTrue(newValue) ? 1 : 0; - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Bool, val); - break; - case HPY_MEMBER_LONGLONG: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int64_t, val); - break; - case HPY_MEMBER_ULONGLONG: - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - val = (long) ensureAsNativePrimitiveNode().execute(val, 0, 8, true); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, Int64_t, val); - break; - case HPY_MEMBER_HPYSSIZET: - // TODO(fa): PyLongAsLong is not correct - val = ensurePyLongAsLongNode().executeCached(frame, newValue); - ensureWriteGenericNode(hPyContext).execute(hPyContext, nativeSpacePtr, offset, HPyContextSignatureType.HPy_ssize_t, val); - break; - default: - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.BAD_MEMBER_DESCR_TYPE_FOR_S, ""); - } - return PNone.NONE; - } - - private GraalHPyCAccess.ReadHPyFieldNode ensureReadHPyFieldNode(GraalHPyContext ctx) { - if (readHPyFieldNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readHPyFieldNode = insert(GraalHPyCAccess.ReadHPyFieldNode.create(ctx)); - } - return readHPyFieldNode; - } - - private GraalHPyCAccess.WriteHPyFieldNode ensureWriteHPyFieldNode(GraalHPyContext ctx) { - if (writeHPyFieldNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - writeHPyFieldNode = insert(GraalHPyCAccess.WriteHPyFieldNode.create(ctx)); - } - return writeHPyFieldNode; - } - - private GraalHPyCAccess.WriteGenericNode ensureWriteGenericNode(GraalHPyContext ctx) { - if (writeGenericNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - writeGenericNode = insert(GraalHPyCAccess.WriteGenericNode.create(ctx)); - } - return writeGenericNode; - } - - private HPyGetNativeSpacePointerNode ensureReadNativeSpaceNode() { - if (readNativeSpaceNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readNativeSpaceNode = insert(HPyGetNativeSpacePointerNodeGen.create()); - } - return readNativeSpaceNode; - } - - private PyLongAsLongNode ensurePyLongAsLongNode() { - if (pyLongAsLongNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - pyLongAsLongNode = insert(PyLongAsLongNodeGen.create()); - } - return pyLongAsLongNode; - } - - private PyFloatAsDoubleCachedNode ensurePyFloatAsDoubleNode() { - if (pyFloatAsDoubleNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - pyFloatAsDoubleNode = insert(PyFloatAsDoubleCachedNodeGen.create()); - } - return pyFloatAsDoubleNode; - } - - private AsNativePrimitiveNode ensureAsNativePrimitiveNode() { - if (asNativePrimitiveNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - asNativePrimitiveNode = insert(AsNativePrimitiveNodeGen.create()); - } - return asNativePrimitiveNode; - } - - private IsBuiltinObjectExactProfile ensureIsBuiltinObjectProfile() { - if (isBuiltinObjectProfile == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - isBuiltinObjectProfile = insert(IsBuiltinObjectExactProfile.create()); - } - return isBuiltinObjectProfile; - } - - private IsNode ensureIsNode() { - if (isNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - isNode = insert(IsNode.create()); - } - return isNode; - } - - private AsNativeCharNode ensureAsNativeCharNode() { - if (asNativeCharNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - asNativeCharNode = insert(AsNativeCharNodeGen.create()); - } - return asNativeCharNode; - } - - @TruffleBoundary - public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, TruffleString propertyName, int type, int offset) { - if (isReadOnlyType(type)) { - return HPyReadOnlyMemberNode.createBuiltinFunction(language, propertyName); - } - if (type == HPY_MEMBER_NONE) { - return HPyBadMemberDescrNode.createBuiltinFunction(language, propertyName); - } - RootCallTarget callTarget = language.createCachedPropAccessCallTarget( - l -> new BuiltinFunctionRootNode(l, builtin, new PrototypeNodeFactory<>(HPyWriteMemberNodeGen.create(type, offset)), true), - HPyWriteMemberNode.class, builtin.name(), type, offset); - int flags = PBuiltinFunction.getFlags(builtin, callTarget); - return PFactory.createBuiltinFunction(language, propertyName, null, 0, flags, callTarget); - } - } - - @GenerateInline(false) - abstract static class PyFloatAsDoubleCachedNode extends Node { - - public abstract double execute(VirtualFrame frame, Object object); - - @Specialization - static double doGeneric(VirtualFrame frame, Object object, - @Bind("this") Node inliningTarget, - @Cached PyFloatAsDoubleNode pyFloatAsDoubleNode) { - return pyFloatAsDoubleNode.execute(frame, inliningTarget, object); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeCache.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeCache.java deleted file mode 100644 index 4b3cb6b7f7..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeCache.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2022, 2023, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SIZEOF_LONG; - -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers; - -import sun.misc.Unsafe; - -/** - * HPy native cache implementation. For documentation of the layout, see {@code hpy_native_cache.h}. - */ -public abstract class GraalHPyNativeCache { - - private static final Unsafe UNSAFE = CArrayWrappers.UNSAFE; - - private static final long HANDLE_MIRROR_OFFSET = 1; - - static long toBytes(long idx) { - return (HANDLE_MIRROR_OFFSET + idx) * SIZEOF_LONG; - } - - static long allocateNativeCache(int nHandleTable, int nGlobalsTable) { - long arraySize = toBytes(nHandleTable + nGlobalsTable); - long arrayPtr = UNSAFE.allocateMemory(arraySize); - UNSAFE.setMemory(arrayPtr, arraySize, (byte) 0); - UNSAFE.putLong(arrayPtr, nHandleTable); - return arrayPtr; - } - - static long reallocateNativeCache(long cachePtr, int nHandleTableOld, int nHandleTable, int nGlobalsTableOld, int nGlobalsTable) { - if (nHandleTableOld > nHandleTable || nGlobalsTableOld > nGlobalsTable) { - throw new RuntimeException("shrinking HPy handle/globals table is not yet supported"); - } - long arraySize = toBytes(nHandleTable + nGlobalsTable); - long newCachePtr = UNSAFE.reallocateMemory(cachePtr, arraySize); - if (nHandleTableOld != nHandleTable) { - // update handle table size - UNSAFE.putLong(newCachePtr, nHandleTable); - // move globals table entries (only if the handle table size changed) - UNSAFE.copyMemory(newCachePtr + toBytes(nHandleTableOld), newCachePtr + toBytes(nHandleTable), nGlobalsTableOld * SIZEOF_LONG); - } - return newCachePtr; - } - - static void putHandleNativeSpacePointer(long cachePtr, int handleID, long value) { - UNSAFE.putLong(cachePtr + toBytes(handleID), value); - } - - static void putGlobalNativeSpacePointer(long cachePtr, long nHandleTable, int globalID, long value) { - UNSAFE.putLong(cachePtr + toBytes(nHandleTable + globalID), value); - } - - static void initGlobalsNativeSpacePointer(long cachePtr, long nHandleTable, int globalStartID, int numElem) { - UNSAFE.setMemory(cachePtr + toBytes(nHandleTable + globalStartID), numElem * SIZEOF_LONG, (byte) 0); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java deleted file mode 100644 index 2a36d5cf01..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeContext.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2023, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.MemoryError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.RecursionError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY; - -import java.io.IOException; -import java.io.PrintStream; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.BulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.FreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.GetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.IsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyABIVersion; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyUpcall; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.exception.PBaseException; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.util.CannotCastException; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.exception.ExceptionUtils; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.strings.TruffleString; - -@ExportLibrary(InteropLibrary.class) -public abstract class GraalHPyNativeContext implements TruffleObject { - - protected final GraalHPyContext context; - - protected GraalHPyNativeContext(GraalHPyContext context, boolean traceUpcalls) { - this.context = context; - } - - protected abstract String getName(); - - protected final PythonContext getContext() { - return context.getContext(); - } - - protected abstract void initNativeContext() throws ApiInitException; - - protected abstract void finalizeNativeContext(); - - protected abstract Object loadExtensionLibrary(Node location, PythonContext context, TruffleString name, TruffleString path) throws ImportException, IOException; - - protected abstract HPyABIVersion getHPyABIVersion(Object extLib, String getMajorVersionFuncName, String getMinorVersionFuncName) throws Exception; - - /** - * Execute an HPy extension's init function and return the raw result value. - * - * @param extLib The HPy extension's shared library object (received from - * {@link #loadExtensionLibrary(Node, PythonContext, TruffleString, TruffleString)}). - * @param initFuncName The HPy extension's init function name (e.g. {@code HPyInit_poc}). - * @param name The HPy extension's name as requested by the user. - * @param path The HPy extension's shared library path. - * @param mode An enum indicating which mode should be used to initialize the HPy extension. - * @return The bare (unconverted) result of the HPy extension's init function. This will be a - * handle that was created with the given {@code hpyContext}. - */ - protected abstract Object initHPyModule(Object extLib, String initFuncName, TruffleString name, TruffleString path, HPyMode mode) - throws UnsupportedMessageException, ArityException, UnsupportedTypeException, ImportException, ApiInitException; - - protected abstract HPyUpcall[] getUpcalls(); - - protected abstract int[] getUpcallCounts(); - - public abstract void initHPyDebugContext() throws ApiInitException; - - public abstract void initHPyTraceContext() throws ApiInitException; - - public abstract PythonModule getHPyDebugModule() throws ImportException; - - public abstract PythonModule getHPyTraceModule() throws ImportException; - - protected abstract void setNativeCache(long cachePtr); - - protected abstract int getCTypeSize(HPyContextSignatureType ctype); - - protected abstract int getCFieldOffset(GraalHPyCField cfield); - - /** - * Converts a native pointer from the representation used by this native context (e.g. - * {@link Long}) to an interop pointer object that responds to interop messages - * {@link InteropLibrary#isPointer(Object)} and {@link InteropLibrary#asPointer(Object)}. - */ - protected abstract Object nativeToInteropPointer(Object object); - - protected abstract Object getNativeNull(); - - protected abstract Object createArgumentsArray(Object[] args); - - protected abstract void freeArgumentsArray(Object argsArray); - - public abstract HPyCallHelperFunctionNode createCallHelperFunctionNode(); - - public abstract HPyCallHelperFunctionNode getUncachedCallHelperFunctionNode(); - - public abstract HPyFromCharPointerNode createFromCharPointerNode(); - - public abstract HPyFromCharPointerNode getUncachedFromCharPointerNode(); - - protected final boolean useNativeFastPaths() { - return context.useNativeFastPaths; - } - - public final GraalHPyContext getHPyContext() { - return context; - } - - @ExportMessage - public void toNative() { - try { - toNativeInternal(); - if (useNativeFastPaths()) { - initNativeFastPaths(); - /* - * Allocate a native array for the native space pointers of HPy objects and - * initialize it. - */ - context.allocateNativeSpacePointersMirror(); - } - } catch (CannotCastException e) { - /* - * We should only receive 'toNative' if native access is allowed. Hence, the exception - * should never happen. - */ - throw CompilerDirectives.shouldNotReachHere(); - } - } - - protected abstract void toNativeInternal(); - - protected abstract void initNativeFastPaths(); - - @TruffleBoundary - public static PException checkThrowableBeforeNative(Throwable t, String where1, Object where2) { - if (t instanceof PException pe) { - // this is ok, and will be handled correctly - throw pe; - } - if (t instanceof ThreadDeath td) { - // ThreadDeath subclasses are used internally by Truffle - throw td; - } - if (t instanceof StackOverflowError soe) { - CompilerDirectives.transferToInterpreter(); - PythonContext context = PythonContext.get(null); - context.ensureGilAfterFailure(); - PBaseException newException = PFactory.createBaseException(context.getLanguage(), RecursionError, ErrorMessages.MAXIMUM_RECURSION_DEPTH_EXCEEDED, EMPTY_OBJECT_ARRAY); - throw ExceptionUtils.wrapJavaException(soe, null, newException); - } - if (t instanceof OutOfMemoryError oome) { - PBaseException newException = PFactory.createBaseException(PythonLanguage.get(null), MemoryError); - throw ExceptionUtils.wrapJavaException(oome, null, newException); - } - // everything else: log and convert to PException (SystemError) - CompilerDirectives.transferToInterpreter(); - PNodeWithContext.printStack(); - PrintStream out = new PrintStream(PythonContext.get(null).getEnv().err()); - out.println("while executing " + where1 + " " + where2); - out.println("should not throw exceptions apart from PException"); - t.printStackTrace(out); - out.flush(); - throw PRaiseNode.raiseStatic(null, SystemError, ErrorMessages.INTERNAL_EXCEPTION_OCCURED); - } - - public abstract AllocateNode createAllocateNode(); - - public abstract AllocateNode getUncachedAllocateNode(); - - public abstract FreeNode createFreeNode(); - - public abstract FreeNode getUncachedFreeNode(); - - public abstract ReadI32Node createReadI32Node(); - - public abstract ReadI32Node getUncachedReadI32Node(); - - public abstract ReadI64Node createReadI64Node(); - - public abstract ReadI64Node getUncachedReadI64Node(); - - public abstract ReadFloatNode createReadFloatNode(); - - public abstract ReadFloatNode getUncachedReadFloatNode(); - - public abstract ReadDoubleNode createReadDoubleNode(); - - public abstract ReadDoubleNode getUncachedReadDoubleNode(); - - public abstract ReadPointerNode createReadPointerNode(); - - public abstract ReadPointerNode getUncachedReadPointerNode(); - - public abstract WriteDoubleNode createWriteDoubleNode(); - - public abstract WriteDoubleNode getUncachedWriteDoubleNode(); - - public abstract WriteI32Node createWriteI32Node(); - - public abstract WriteI32Node getUncachedWriteI32Node(); - - public abstract WriteI64Node createWriteI64Node(); - - public abstract WriteI64Node getUncachedWriteI64Node(); - - public abstract WriteHPyNode createWriteHPyNode(); - - public abstract WriteHPyNode getUncachedWriteHPyNode(); - - public abstract ReadI8ArrayNode createReadI8ArrayNode(); - - public abstract ReadI8ArrayNode getUncachedReadI8ArrayNode(); - - public abstract WritePointerNode createWritePointerNode(); - - public abstract WritePointerNode getUncachedWritePointerNode(); - - public abstract ReadHPyArrayNode createReadHPyArrayNode(); - - public abstract ReadHPyArrayNode getUncachedReadHPyArrayNode(); - - public abstract ReadHPyNode createReadHPyNode(); - - public abstract ReadHPyNode getUncachedReadHPyNode(); - - public abstract ReadHPyFieldNode createReadHPyFieldNode(); - - public abstract ReadHPyFieldNode getUncachedReadFieldHPyNode(); - - public abstract IsNullNode createIsNullNode(); - - public abstract IsNullNode getUncachedIsNullNode(); - - public abstract GraalHPyCAccess.ReadGenericNode createReadGenericNode(); - - public abstract GraalHPyCAccess.ReadGenericNode getUncachedReadGenericNode(); - - public abstract WriteSizeTNode createWriteSizeTNode(); - - public abstract WriteSizeTNode getUncachedWriteSizeTNode(); - - public abstract GetElementPtrNode createGetElementPtrNode(); - - public abstract GetElementPtrNode getUncachedGetElementPtrNode(); - - public abstract WriteHPyFieldNode createWriteHPyFieldNode(); - - public abstract WriteHPyFieldNode getUncachedWriteHPyFieldNode(); - - public abstract WriteGenericNode createWriteGenericNode(); - - public abstract WriteGenericNode getUncachedWriteGenericNode(); - - public abstract BulkFreeHandleReferencesNode createBulkFreeHandleReferencesNode(); - - public abstract HPyAsCharPointerNode createAsCharPointerNode(); - - public abstract HPyAsCharPointerNode getUncachedAsCharPointerNode(); -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeSymbol.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeSymbol.java deleted file mode 100644 index 9366d0a759..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNativeSymbol.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2019, 2023, 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.builtins.objects.cext.hpy; - -public enum GraalHPyNativeSymbol { - - GRAAL_HPY_BUFFER_TO_NATIVE("graal_hpy_buffer_to_native"), - GRAAL_HPY_FREE("graal_hpy_free"), - GRAAL_HPY_FROM_HPY_ARRAY("graal_hpy_from_HPy_array"), - GRAAL_HPY_GET_ERRNO("graal_hpy_get_errno"), - GRAAL_HPY_GET_STRERROR("graal_hpy_get_strerror"), - GRAAL_HPY_STRLEN("graal_hpy_strlen"), - GRAAL_HPY_ARRAY_TO_NATIVE("graal_hpy_array_to_native"), - GRAAL_HPY_FROM_I8_ARRAY("graal_hpy_from_i8_array"), - GRAAL_HPY_CONTEXT_TO_NATIVE("graal_hpy_context_to_native"), - GRAAL_HPY_CALLOC("graal_hpy_calloc"), - GRAAL_HPY_GET_FIELD_I("graal_hpy_get_field_i"), - GRAAL_HPY_SET_FIELD_I("graal_hpy_set_field_i"), - GRAAL_HPY_GET_GLOBAL_I("graal_hpy_get_global_i"), - GRAAL_HPY_SET_GLOBAL_I("graal_hpy_set_global_i"), - GRAAL_HPY_GET_ELEMENT_PTR("graal_hpy_get_element_ptr"), - - /* C functions for reading native members by offset */ - GRAAL_HPY_READ_BOOL("graal_hpy_read_bool"), - GRAAL_HPY_READ_I8("graal_hpy_read_i8"), - GRAAL_HPY_READ_UI8("graal_hpy_read_ui8"), - GRAAL_HPY_READ_I16("graal_hpy_read_i16"), - GRAAL_HPY_READ_UI16("graal_hpy_read_ui16"), - GRAAL_HPY_READ_I32("graal_hpy_read_i32"), - GRAAL_HPY_READ_UI32("graal_hpy_read_ui32"), - GRAAL_HPY_READ_I64("graal_hpy_read_i64"), - GRAAL_HPY_READ_UI64("graal_hpy_read_ui64"), - GRAAL_HPY_READ_I("graal_hpy_read_i"), - GRAAL_HPY_READ_L("graal_hpy_read_l"), - GRAAL_HPY_READ_F("graal_hpy_read_f"), - GRAAL_HPY_READ_D("graal_hpy_read_d"), - GRAAL_HPY_READ_PTR("graal_hpy_read_ptr"), - GRAAL_HPY_READ_HPY("graal_hpy_read_HPy"), - GRAAL_HPY_READ_HPYFIELD("graal_hpy_read_HPyField"), - GRAAL_HPY_READ_UI("graal_hpy_read_ui"), - GRAAL_HPY_READ_UL("graal_hpy_read_ul"), - GRAAL_HPY_READ_HPY_SSIZE_T("graal_hpy_read_HPy_ssize_t"), - - /* C functions for writing native members by offset */ - GRAAL_HPY_WRITE_BOOL("graal_hpy_write_bool"), - GRAAL_HPY_WRITE_I8("graal_hpy_write_i8"), - GRAAL_HPY_WRITE_UI8("graal_hpy_write_ui8"), - GRAAL_HPY_WRITE_I16("graal_hpy_write_i16"), - GRAAL_HPY_WRITE_UI16("graal_hpy_write_ui16"), - GRAAL_HPY_WRITE_I32("graal_hpy_write_i32"), - GRAAL_HPY_WRITE_UI32("graal_hpy_write_ui32"), - GRAAL_HPY_WRITE_I64("graal_hpy_write_i64"), - GRAAL_HPY_WRITE_UI64("graal_hpy_write_ui64"), - GRAAL_HPY_WRITE_I("graal_hpy_write_i"), - GRAAL_HPY_WRITE_L("graal_hpy_write_l"), - GRAAL_HPY_WRITE_F("graal_hpy_write_f"), - GRAAL_HPY_WRITE_D("graal_hpy_write_d"), - GRAAL_HPY_WRITE_HPY("graal_hpy_write_HPy"), - GRAAL_HPY_WRITE_HPYFIELD("graal_hpy_write_HPyField"), - GRAAL_HPY_WRITE_UI("graal_hpy_write_ui"), - GRAAL_HPY_WRITE_UL("graal_hpy_write_ul"), - GRAAL_HPY_WRITE_HPY_SSIZE_T("graal_hpy_write_HPy_ssize_t"), - GRAAL_HPY_WRITE_PTR("graal_hpy_write_ptr"), - - GRAAL_HPY_BULK_FREE("graal_hpy_bulk_free"); - - private final String name; - - GraalHPyNativeSymbol(String name) { - this.name = name; - } - - public String getName() { - return name; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java deleted file mode 100644 index 4ed2679731..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java +++ /dev/null @@ -1,3180 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlot.HPY_TP_CALL; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlot.HPY_TP_DESTROY; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlot.HPY_TP_NEW; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlot.HPY_TP_TRAVERSE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle.NULL_HANDLE_DELEGATE; -import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_basicsize; -import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEW__; -import static com.oracle.graal.python.nodes.StringLiterals.T_EXEC; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Level; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PythonAbstractObject; -import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; -import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CreateFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.CreateMethodNode; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.AsNativePrimitiveNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ConvertPIntToPrimitiveNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureExecutableNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.TransformExceptionToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtToJavaNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.LLVMType; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyFuncSignature; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlot; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyLegacyDef.HPyLegacySlot; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodes.HPyReadMemberNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyMemberAccessNodes.HPyWriteMemberNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAllHandleCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAttachJNIFunctionTypeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAttachNFIFunctionTypeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyCloseHandleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetNativeSpacePointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetSetSetterHandleCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyKeywordsHandleCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyRaiseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyRichcmptFuncArgsCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPySSizeObjArgProcCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPySelfHandleCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyTransformExceptionToNativeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyTypeGetNameNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyVarargsHandleCloseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyObjectBuiltins.HPyObjectNewNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyCheckFunctionResultNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyCheckHandleResultNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyCheckPrimitiveResultNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyGetSetDescriptorGetterRootNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyGetSetDescriptorSetterRootNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyLegacyGetSetDescriptorGetterRoot; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyLegacyGetSetDescriptorSetterRoot; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNIFunctionPointer; -import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.function.BuiltinMethodDescriptor; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptor; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.builtins.objects.type.TpSlots; -import com.oracle.graal.python.builtins.objects.type.TpSlots.Builder; -import com.oracle.graal.python.builtins.objects.type.TpSlots.TpSlotMeta; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetBaseClassNode; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetNameNode; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.HasSameConstructorNode; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotNative; -import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs; -import com.oracle.graal.python.lib.PyObjectGetItem; -import com.oracle.graal.python.lib.PyObjectIsTrueNode; -import com.oracle.graal.python.nodes.BuiltinNames; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.HiddenAttr; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.SpecialAttributeNames; -import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode; -import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode; -import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode; -import com.oracle.graal.python.nodes.attributes.WriteAttributeToPythonObjectNode; -import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.object.IsNode; -import com.oracle.graal.python.nodes.util.CannotCastException; -import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.exception.PythonErrorType; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CallTarget; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.CompilerDirectives.ValueType; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.Frame; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.object.DynamicObjectLibrary; -import com.oracle.truffle.api.profiles.InlinedBranchProfile; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.api.profiles.InlinedExactClassProfile; -import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.Encoding; -import com.oracle.truffle.nfi.api.SignatureLibrary; - -public abstract class GraalHPyNodes { - - /** - * A node interface for calling (native) helper functions. The implementation depends on the HPy - * backend. This is the reason why this node takes the HPy context as construction parameter. - * The recommended usage of this node is - * - *
    -     * @Specialization
    -     * Object doSomething(GraalHPyContext hpyContext,
    -     *                 @Cached(parameters = "hpyContext") HPyCallHelperFunctionNode callHelperNode) {
    -     *     // ...
    -     * }
    -     * 
    - */ - public abstract static class HPyCallHelperFunctionNode extends Node { - public final Object call(GraalHPyContext context, GraalHPyNativeSymbol name, Object... args) { - return execute(context, name, args); - } - - protected abstract Object execute(GraalHPyContext context, GraalHPyNativeSymbol name, Object[] args); - - @NeverDefault - public static HPyCallHelperFunctionNode create(GraalHPyContext context) { - return context.getBackend().createCallHelperFunctionNode(); - } - - public static HPyCallHelperFunctionNode getUncached(GraalHPyContext context) { - return context.getBackend().getUncachedCallHelperFunctionNode(); - } - } - - /** - * Use this node to transform an exception to native if a Python exception was thrown during an - * upcall and before returning to native code. This node will correctly link to the current - * frame using the frame reference and tries to avoid any materialization of the frame. The - * exception is then registered in the native context as the current exception. - */ - @GenerateInline - @GenerateCached(false) - @GenerateUncached - public abstract static class HPyTransformExceptionToNativeNode extends Node { - - public abstract void execute(Frame frame, Node inliningTarget, GraalHPyContext nativeContext, PException e); - - public final void execute(Node inliningTarget, GraalHPyContext nativeContext, PException e) { - execute(null, inliningTarget, nativeContext, e); - } - - public final void execute(Node inliningTarget, PException e) { - execute(null, inliningTarget, PythonContext.get(this).getHPyContext(), e); - } - - public static void executeUncached(GraalHPyContext nativeContext, PException e) { - HPyTransformExceptionToNativeNodeGen.getUncached().execute(null, nativeContext, e); - } - - public static void executeUncached(PException e) { - HPyTransformExceptionToNativeNodeGen.getUncached().execute(null, null, e); - } - - @Specialization - static void setCurrentException(Frame frame, Node inliningTarget, @SuppressWarnings("unused") GraalHPyContext nativeContext, PException e, - @Cached TransformExceptionToNativeNode transformExceptionToNativeNode) { - transformExceptionToNativeNode.execute(frame, inliningTarget, e); - } - } - - @GenerateUncached - @GenerateInline(false) - public abstract static class HPyRaiseNode extends Node { - - public final int raiseInt(Frame frame, GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object... arguments) { - return executeInt(frame, nativeContext, errorValue, errType, format, arguments); - } - - public final Object raise(Frame frame, GraalHPyContext nativeContext, Object errorValue, PythonBuiltinClassType errType, TruffleString format, Object... arguments) { - return execute(frame, nativeContext, errorValue, errType, format, arguments); - } - - public final int raiseIntWithoutFrame(GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object... arguments) { - return executeInt(null, nativeContext, errorValue, errType, format, arguments); - } - - public final Object raiseWithoutFrame(GraalHPyContext nativeContext, Object errorValue, PythonBuiltinClassType errType, TruffleString format, Object... arguments) { - return execute(null, nativeContext, errorValue, errType, format, arguments); - } - - public static int raiseIntUncached(GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object... arguments) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(nativeContext, errorValue, errType, format, arguments); - } - - public abstract Object execute(Frame frame, GraalHPyContext nativeContext, Object errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments); - - public abstract int executeInt(Frame frame, GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments); - - @Specialization - static int doInt(Frame frame, GraalHPyContext nativeContext, int errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments, - @Bind("this") Node inliningTarget, - @Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) { - try { - throw PRaiseNode.raiseStatic(inliningTarget, errType, format, arguments); - } catch (PException p) { - transformExceptionToNativeNode.execute(frame, inliningTarget, nativeContext, p); - } - return errorValue; - } - - @Specialization - static Object doObject(Frame frame, GraalHPyContext nativeContext, Object errorValue, PythonBuiltinClassType errType, TruffleString format, Object[] arguments, - @Bind("this") Node inliningTarget, - @Shared("transformExceptionToNativeNode") @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) { - try { - throw PRaiseNode.raiseStatic(inliningTarget, errType, format, arguments); - } catch (PException p) { - transformExceptionToNativeNode.execute(frame, inliningTarget, nativeContext, p); - } - return errorValue; - } - } - - /** - * A node interface for creating a TruffleString from a {@code char *}. The implementation - * depends on the HPy backend. This is the reason why this node takes the HPy context as - * construction parameter. The recommended usage of this node is - * - *
    -     * @Specialization
    -     * Object doSomething(GraalHPyContext hpyContext,
    -     *                 @Cached(parameters = "hpyContext") HPyFromCharPointerNode fromCharPointerNode) {
    -     *     // ...
    -     * }
    -     * 
    - */ - public abstract static class HPyFromCharPointerNode extends Node { - - public final TruffleString execute(GraalHPyContext hpyContext, Object charPtr, boolean copy) { - return execute(hpyContext, charPtr, -1, Encoding.UTF_8, copy); - } - - public final TruffleString execute(GraalHPyContext hpyContext, Object charPtr, Encoding encoding) { - return execute(hpyContext, charPtr, -1, encoding, true); - } - - public abstract TruffleString execute(GraalHPyContext hpyContext, Object charPtr, int n, Encoding encoding, boolean copy); - - public abstract TruffleString execute(GraalHPyContext hpyContext, long charPtr, int n, Encoding encoding, boolean copy); - - @NeverDefault - public static HPyFromCharPointerNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createFromCharPointerNode(); - } - - public static HPyFromCharPointerNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedFromCharPointerNode(); - } - } - - public abstract static class HPyAsCharPointerNode extends Node { - - public abstract Object execute(GraalHPyContext hpyContext, TruffleString string, Encoding encoding); - - @NeverDefault - public static HPyAsCharPointerNode create(GraalHPyContext hpyContext) { - return hpyContext.getBackend().createAsCharPointerNode(); - } - - public static HPyAsCharPointerNode getUncached(GraalHPyContext hpyContext) { - return hpyContext.getBackend().getUncachedAsCharPointerNode(); - } - } - - /** - * Creates an HPy module from a module definition structure: - * - *
    -     * typedef struct {
    -     *     const char* doc;
    -     *     HPy_ssize_t size;
    -     *     cpy_PyMethodDef *legacy_methods;
    -     *     HPyDef **defines;
    -     *     HPyGlobal **globals;
    -     * } HPyModuleDef;
    -     * 
    - */ - @GenerateUncached - @GenerateCached(false) - @GenerateInline(false) // footprint reduction 108 -> 89 - public abstract static class GraalHPyModuleCreate extends Node { - - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyModuleCreate.class); - - public abstract Object execute(GraalHPyContext hpyContext, TruffleString mName, Object spec, Object moduleDefPtr); - - @Specialization - static Object doGeneric(GraalHPyContext context, TruffleString mName, Object spec, Object moduleDefPtr, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached(parameters = "context") GraalHPyCAccess.WriteSizeTNode writeSizeTNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached WriteAttributeToObjectNode writeAttrNode, - @Cached WriteAttributeToPythonObjectNode writeAttrToMethodNode, - @Cached HPyCreateFunctionNode addFunctionNode, - @Cached CreateMethodNode addLegacyMethodNode, - @Cached HPyReadSlotNode readSlotNode, - @Cached HPyCheckHandleResultNode checkFunctionResultNode, - @Cached HPyAsHandleNode asHandleNode, - @CachedLibrary(limit = "1") InteropLibrary createLib, - @Cached PRaiseNode raiseNode) { - - PythonLanguage language = context.getContext().getLanguage(); - - TruffleString mDoc; - long size; - Object docPtr = readPointerNode.read(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__doc); - if (!isNullNode.execute(context, docPtr)) { - mDoc = fromCharPointerNode.execute(docPtr); - } else { - mDoc = null; - } - - size = readGenericNode.readLong(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__size); - if (size < 0) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, tsLiteral("HPy does not permit HPyModuleDef.size < 0")); - } else if (size > 0) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, - tsLiteral("Module state is not supported yet in HPy, set HPyModuleDef.size = 0 if module state is not needed")); - } - - // process HPy module slots - Object moduleDefinesPtr = readPointerNode.read(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__defines); - - List executeSlots = new LinkedList<>(); - List methodDefs = new LinkedList<>(); - Object createFunction = null; - - if (!isNullNode.execute(context, moduleDefinesPtr)) { - for (int i = 0;; i++) { - Object def = readPointerNode.readArrayElement(context, moduleDefinesPtr, i); - if (isNullNode.execute(context, def)) { - break; - } - int kind = readGenericNode.readInt(context, def, GraalHPyCField.HPyDef__kind); - switch (kind) { - case GraalHPyDef.HPY_DEF_KIND_METH: - methodDefs.add(def); - break; - case GraalHPyDef.HPY_DEF_KIND_SLOT: - HPySlotData slotData = readSlotNode.execute(inliningTarget, context, def); - switch (slotData.slot) { - case HPY_MOD_CREATE -> { - if (createFunction != null) { - throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.MODULE_HAS_MULTIPLE_CREATE_SLOTS, mName); - } - createFunction = slotData.impl; - } - case HPY_MOD_EXEC -> { - if (createFunction != null) { - throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_OTHER_SLOTS, mName); - } - /* - * In contrast to CPython, we already parse and store the - * HPy_mod_exec slots here since parsing is a bit more expensive - * in our case. - */ - executeSlots.add(slotData.impl); - } - default -> throw raiseNode.raise(inliningTarget, PythonErrorType.SystemError, ErrorMessages.MODULE_USES_UNKNOW_SLOT_ID, mName, slotData.slot); - } - break; - case GraalHPyDef.HPY_DEF_KIND_MEMBER: - case GraalHPyDef.HPY_DEF_KIND_GETSET: - // silently ignore - LOGGER.warning("get/set definitions are not supported for modules"); - break; - default: - if (LOGGER.isLoggable(Level.SEVERE)) { - LOGGER.severe(PythonUtils.formatJString("unknown definition kind: %d", kind)); - } - assert false; - } - } - } - - // determine of 'legacy_methods' is NULL upfront (required for a consistency check) - Object legacyMethods = readPointerNode.read(context, moduleDefPtr, GraalHPyCField.HPyModuleDef__legacy_methods); - // the field 'legacy_methods' may be 'NULL' - boolean hasLegacyMethods = !isNullNode.execute(context, legacyMethods); - - // allocate module's HPyGlobals - int globalStartIdx = context.getEndIndexOfGlobalTable(); - int nModuleGlobals = initModuleGlobals(context, moduleDefPtr, globalStartIdx, isNullNode, readPointerNode, writeSizeTNode); - context.initBatchGlobals(globalStartIdx, nModuleGlobals); - - // create the module object - Object module; - if (createFunction != null) { - /* - * TODO(fa): this check should be before any other check (and the also test for - * 'size > 0') - */ - if (hasLegacyMethods || mDoc != null || nModuleGlobals != 0) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_DEFINES_CREATE_AND_NON_DEFAULT); - } - module = callCreate(inliningTarget, createFunction, context, spec, checkFunctionResultNode, asHandleNode, createLib); - if (module instanceof PythonModule) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.HPY_MOD_CREATE_RETURNED_BUILTIN_MOD); - } - } else { - PythonModule pmodule = PFactory.createPythonModule(language, mName); - pmodule.setNativeModuleDef(executeSlots); - module = pmodule; - } - - // process HPy methods - for (Object methodDef : methodDefs) { - PBuiltinFunction fun = addFunctionNode.execute(context, null, methodDef); - PBuiltinMethod method = PFactory.createBuiltinMethod(language, module, fun); - writeAttrToMethodNode.execute(method, SpecialAttributeNames.T___MODULE__, mName); - writeAttrNode.execute(module, fun.getName(), method); - } - - // process legacy methods - if (hasLegacyMethods) { - for (int i = 0;; i++) { - PBuiltinFunction fun = addLegacyMethodNode.execute(inliningTarget, legacyMethods, i); - if (fun == null) { - break; - } - PBuiltinMethod method = PFactory.createBuiltinMethod(language, module, fun); - writeAttrToMethodNode.execute(method, SpecialAttributeNames.T___MODULE__, mName); - writeAttrNode.execute(module, fun.getName(), method); - } - } - - if (mDoc != null) { - writeAttrNode.execute(module, SpecialAttributeNames.T___DOC__, mDoc); - } - - return module; - } - - /** - * Initializes all HPy globals of the currently created module. - */ - private static int initModuleGlobals(GraalHPyContext hpyContext, Object moduleDefPtr, int startID, - GraalHPyCAccess.IsNullNode isNullNode, - GraalHPyCAccess.ReadPointerNode readPointerNode, - GraalHPyCAccess.WriteSizeTNode writeSizeTNode) { - Object globalsPtrArr = readPointerNode.read(hpyContext, moduleDefPtr, GraalHPyCField.HPyModuleDef__globals); - if (!isNullNode.execute(hpyContext, globalsPtrArr)) { - for (int i = 0;; i++) { - Object globalPtr = readPointerNode.readArrayElement(hpyContext, globalsPtrArr, i); - if (isNullNode.execute(hpyContext, globalPtr)) { - return i; - } - writeSizeTNode.execute(hpyContext, globalPtr, 0, startID + i); - } - } - return 0; - } - - private static final TruffleString CREATE = tsLiteral("create"); - - /** - * Call the create slot function. - * - * TODO(fa): This method shares some logic with - * {@link com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyExternalFunctionInvokeNode}. - * We should refactor the node such that we can use it here. - */ - static Object callCreate(Node inliningTarget, Object callable, GraalHPyContext hPyContext, Object spec, - HPyCheckFunctionResultNode checkFunctionResultNode, HPyAsHandleNode asHandleNode, InteropLibrary lib) { - - PythonContext ctx = hPyContext.getContext(); - PythonLanguage language = ctx.getLanguage(inliningTarget); - PythonThreadState pythonThreadState = ctx.getThreadState(language); - - GraalHPyHandle hSpec = asHandleNode.execute(spec); - try { - return checkFunctionResultNode.execute(pythonThreadState, CREATE, lib.execute(callable, hPyContext.getBackend(), hSpec)); - } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, CREATE, e); - } catch (ArityException e) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, CREATE, e.getExpectedMinArity(), e.getActualArity()); - } finally { - // close all handles (if necessary) - if (hSpec.isAllocated()) { - hSpec.closeAndInvalidate(hPyContext); - } - } - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class GraalHPyModuleExecNode extends Node { - - public abstract void execute(Node node, GraalHPyContext hpyContext, PythonModule module); - - @Specialization - static void doGeneric(Node node, GraalHPyContext hpyContext, PythonModule module, - @Cached(inline = false) HPyCheckPrimitiveResultNode checkFunctionResultNode, - @Cached(inline = false) HPyAsHandleNode asHandleNode, - @CachedLibrary(limit = "1") InteropLibrary lib) { - // TODO(fa): once we support HPy module state, we need to allocate it here - Object execSlotsObj = module.getNativeModuleDef(); - if (execSlotsObj instanceof LinkedList execSlots) { - for (Object execSlot : execSlots) { - callExec(node, hpyContext, execSlot, module, checkFunctionResultNode, asHandleNode, lib); - } - } - } - - /** - * Call the exec slot function. - *

    - * TODO(fa): This method shares some logic with - * {@link com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes.HPyExternalFunctionInvokeNode}. - * We should refactor the node such that we can use it here. - *

    - */ - static void callExec(Node node, GraalHPyContext hPyContext, Object callable, PythonModule module, - HPyCheckPrimitiveResultNode checkFunctionResultNode, HPyAsHandleNode asHandleNode, InteropLibrary lib) { - - PythonContext ctx = hPyContext.getContext(); - PythonLanguage language = ctx.getLanguage(node); - PythonThreadState pythonThreadState = ctx.getThreadState(language); - - GraalHPyHandle hModule = asHandleNode.execute(module); - try { - checkFunctionResultNode.execute(pythonThreadState, T_EXEC, lib.execute(callable, hPyContext.getBackend(), hModule)); - } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, T_EXEC, e); - } catch (ArityException e) { - throw PRaiseNode.raiseStatic(node, TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, T_EXEC, e.getExpectedMinArity(), e.getActualArity()); - } finally { - // close all handles (if necessary) - if (hModule.isAllocated()) { - hModule.closeAndInvalidate(hPyContext); - } - } - } - } - - /** - *
    -     *     typedef struct {
    -     *         const char *name;             // The name of the built-in function/method
    -     *         const char *doc;              // The __doc__ attribute, or NULL
    -     *         void *impl;                   // Function pointer to the implementation
    -     *         void *cpy_trampoline;         // Used by CPython to call impl
    -     *         HPyFunc_Signature signature;  // Indicates impl's expected the signature
    -     *     } HPyMeth;
    -     * 
    - */ - @GenerateUncached - @GenerateInline(false) // footprint reduction 52 -> 33 - public abstract static class HPyCreateFunctionNode extends PNodeWithContext { - - public abstract PBuiltinFunction execute(GraalHPyContext context, Object enclosingType, Object methodDef); - - @Specialization - static PBuiltinFunction doIt(GraalHPyContext context, Object enclosingType, Object methodDef, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached HPyAttachFunctionTypeNode attachFunctionTypeNode, - @Cached WriteAttributeToPythonObjectNode writeAttributeToPythonObjectNode, - @Cached PRaiseNode raiseNode) { - - TruffleString methodName = fromCharPointerNode.execute(readPointerNode.read(context, methodDef, GraalHPyCField.HPyDef__meth__name)); - - // note: 'ml_doc' may be NULL; in this case, we would store 'None' - Object methodDoc = PNone.NONE; - Object doc = readPointerNode.read(context, methodDef, GraalHPyCField.HPyDef__meth__doc); - if (!isNullNode.execute(context, doc)) { - methodDoc = fromCharPointerNode.execute(doc, false); - } - - HPyFuncSignature signature; - Object methodFunctionPointer; - signature = HPyFuncSignature.fromValue(readGenericNode.readInt(context, methodDef, GraalHPyCField.HPyDef__meth__signature)); - if (signature == null) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.ValueError, ErrorMessages.UNSUPPORTED_HYPMETH_SIG); - } - - methodFunctionPointer = readPointerNode.read(context, methodDef, GraalHPyCField.HPyDef__meth__impl); - methodFunctionPointer = attachFunctionTypeNode.execute(context, methodFunctionPointer, signature.getLLVMFunctionType()); - - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - PBuiltinFunction function = HPyExternalFunctionNodes.createWrapperFunction(language, context, signature, methodName, methodFunctionPointer, enclosingType); - - // write doc string; we need to directly write to the storage otherwise it is - // disallowed writing to builtin types. - writeAttributeToPythonObjectNode.execute(function, SpecialAttributeNames.T___DOC__, methodDoc); - - return function; - } - } - - /** - * Parses a pointer to a {@code PyGetSetDef} struct and creates the corresponding property. - * - *
    -     *     typedef struct PyGetSetDef {
    -     *         const char *name;
    -     *         getter get;
    -     *         setter set;
    -     *         const char *doc;
    -     *         void *closure;
    -     * } PyGetSetDef;
    -     * 
    - */ - @GenerateUncached - @GenerateInline(false) // footprint reduction 44 -> 25 - public abstract static class HPyAddLegacyGetSetDefNode extends PNodeWithContext { - - public abstract GetSetDescriptor execute(GraalHPyContext context, Object owner, Object legacyGetSetDefArrPtr, int i); - - @Specialization - static GetSetDescriptor doGeneric(GraalHPyContext context, Object owner, Object legacyGetSetDef, int i, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached EnsureExecutableNode ensureExecutableNode, - @Cached WriteAttributeToPythonObjectNode writeDocNode) { - - // compute offset of name and read name pointer - long nameOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__name); - Object namePtr = readPointerNode.execute(context, legacyGetSetDef, nameOffset); - - // if the name pointer is null, this is the sentinel - if (isNullNode.execute(context, namePtr)) { - return null; - } - TruffleString getSetDescrName = fromCharPointerNode.execute(namePtr); - - // compute remaining offsets - long docOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__doc); - long getOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__get); - long setOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__set); - long closureOffset = GraalHPyCAccess.ReadPointerNode.getElementPtr(context, i, HPyContextSignatureType.PyGetSetDef, GraalHPyCField.PyGetSetDef__closure); - - // note: 'doc' may be NULL; in this case, we would store 'None' - Object getSetDescrDoc = PNone.NONE; - Object docPtr = readPointerNode.execute(context, legacyGetSetDef, docOffset); - if (!isNullNode.execute(context, docPtr)) { - getSetDescrDoc = fromCharPointerNode.execute(docPtr); - } - - Object getterFunPtr = readPointerNode.execute(context, legacyGetSetDef, getOffset); - Object setterFunPtr = readPointerNode.execute(context, legacyGetSetDef, setOffset); - /* - * Note: we need to convert the native closure pointer to an interop pointer because it - * will be handed to a C API root which expects that. - */ - Object closurePtr = context.nativeToInteropPointer(readPointerNode.execute(context, legacyGetSetDef, closureOffset)); - - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - PBuiltinFunction getterObject = null; - if (!isNullNode.execute(context, getterFunPtr)) { - Object getterFunInteropPtr = ensureExecutableNode.execute(inliningTarget, context.nativeToInteropPointer(getterFunPtr), PExternalFunctionWrapper.GETTER); - getterObject = HPyLegacyGetSetDescriptorGetterRoot.createLegacyFunction(language, owner, getSetDescrName, getterFunInteropPtr, closurePtr); - } - - PBuiltinFunction setterObject = null; - boolean hasSetter = !isNullNode.execute(context, setterFunPtr); - if (hasSetter) { - Object setterFunInteropPtr = ensureExecutableNode.execute(inliningTarget, context.nativeToInteropPointer(setterFunPtr), PExternalFunctionWrapper.SETTER); - setterObject = HPyLegacyGetSetDescriptorSetterRoot.createLegacyFunction(language, owner, getSetDescrName, setterFunInteropPtr, closurePtr); - } - - context.getContext().getLanguage(inliningTarget); - GetSetDescriptor getSetDescriptor = PFactory.createGetSetDescriptor(language, getterObject, setterObject, getSetDescrName, owner, hasSetter); - writeDocNode.execute(getSetDescriptor, SpecialAttributeNames.T___DOC__, getSetDescrDoc); - return getSetDescriptor; - } - } - - /** - * A simple helper class to return the property and its name separately. - */ - @ValueType - static final class HPyProperty { - final Object key; - final Object value; - - /** - * In a very few cases, a single definition can define several properties. For example, slot - * {@link HPySlot#HPY_SQ_ASS_ITEM} defines properties - * {@link com.oracle.graal.python.nodes.SpecialMethodNames#T___SETITEM__} and - * {@link com.oracle.graal.python.nodes.SpecialMethodNames#T___DELITEM__}. Therefore, we use - * this field to create a linked list of such related properties. - */ - final HPyProperty next; - - HPyProperty(Object key, Object value, HPyProperty next) { - assert key instanceof TruffleString || key instanceof HiddenAttr; - this.key = key; - this.value = value; - this.next = next; - } - - HPyProperty(TruffleString key, Object value) { - this(key, value, null); - } - - void write(Node inliningTarget, WritePropertyNode writePropertyNode, ReadPropertyNode readPropertyNode, Object enclosingType) { - for (HPyProperty prop = this; prop != null; prop = prop.next) { - /* - * Do not overwrite existing attributes. Reason: Different slots may map to the same - * magic method. For example: 'nb_add' and 'sq_concat' are both mapped to '__add__'. - * For now, we will always use the first mapping. However, that is not fully - * correct. CPython has a fixed order for slots defined by array 'static slotdef - * slotdefs[]' in 'typeobject.c'. They iterate over this array and check if the new - * type provides the slot. The first mapping will then be install. The problem is - * that we cannot easily do the same since we have two separate sets of slots: HPy - * slots and legacy slots. Right now, the HPy slots have precedence. - */ - if (!keyExists(inliningTarget, readPropertyNode, enclosingType, prop.key)) { - writePropertyNode.execute(inliningTarget, enclosingType, prop.key, prop.value); - } - } - } - - static boolean keyExists(Node inliningTarget, ReadPropertyNode readPropertyNode, Object enclosingType, Object key) { - return readPropertyNode.execute(inliningTarget, enclosingType, key) != PNone.NO_VALUE; - } - - static boolean keyExists(ReadAttributeFromObjectNode readAttributeFromObjectNode, Object enclosingType, TruffleString key) { - return readAttributeFromObjectNode.execute(enclosingType, key) != PNone.NO_VALUE; - } - - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - abstract static class ReadPropertyNode extends Node { - abstract Object execute(Node inliningTarget, Object receiver, Object key); - - @Specialization - static Object doHiddenAttr(Node inliningTarget, PythonAbstractObject receiver, HiddenAttr key, - @Cached HiddenAttr.ReadNode readNode) { - return readNode.execute(inliningTarget, receiver, key, PNone.NO_VALUE); - } - - @Specialization - static Object doOther(Object receiver, TruffleString key, - @Cached(inline = false) ReadAttributeFromObjectNode readAttributeFromObjectNode) { - return readAttributeFromObjectNode.execute(receiver, key); - } - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - abstract static class WritePropertyNode extends Node { - // key comes from HPyProperty#key which is either TruffleString or HiddenAttr - abstract void execute(Node inliningTarget, Object receiver, Object key, Object value); - - @Specialization - static void doHiddenAttr(Node inliningTarget, PythonAbstractObject receiver, HiddenAttr key, Object value, - @Cached HiddenAttr.WriteNode writeNode) { - writeNode.execute(inliningTarget, receiver, key, value); - } - - @Specialization - static void doString(Object receiver, TruffleString key, Object value, - @Cached(inline = false) WriteAttributeToObjectNode writeAttributeToObjectNode) { - writeAttributeToObjectNode.execute(receiver, key, value); - } - } - - /** - * A simple helper class to return the parsed data of an {@code HPySlot} structure. - * - *
    -     * typedef struct {
    -     *     HPySlot_Slot slot;     // The slot to fill
    -     *     void *impl;            // Function pointer to the implementation
    -     *     void *cpy_trampoline;  // Used by CPython to call impl
    -     * } HPySlot;
    -     * 
    - */ - @ValueType - record HPySlotData(HPySlot slot, Object impl) { - } - - @GenerateUncached - @GenerateInline(false) // footprint reduction 48 -> 29 - public abstract static class HPyCreateLegacyMemberNode extends PNodeWithContext { - - public abstract HPyProperty execute(GraalHPyContext context, Object enclosingType, Object memberDefArrPtr, int i); - - /** - *
    -         * typedef struct PyMemberDef {
    -         *     const char *name;
    -         *     int type;
    -         *     Py_ssize_t offset;
    -         *     int flags;
    -         *     const char *doc;
    -         * } PyMemberDef;
    -         * 
    - */ - @Specialization - static HPyProperty doIt(GraalHPyContext context, Object enclosingType, Object memberDefArrPtr, int i, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached WriteAttributeToPythonObjectNode writeDocNode) { - - // computes offsets like '&(memberDefArrPtr[i].name)' - int pyMemberDefSize = context.getCTypeSize(HPyContextSignatureType.PyMemberDef); - long nameOffset = ReadGenericNode.getElementPtr(context, i, pyMemberDefSize, GraalHPyCField.PyMemberDef__name); - long typeOffset = ReadGenericNode.getElementPtr(context, i, pyMemberDefSize, GraalHPyCField.PyMemberDef__type); - long offsetOffset = ReadGenericNode.getElementPtr(context, i, pyMemberDefSize, GraalHPyCField.PyMemberDef__offset); - long flagsOffset = ReadGenericNode.getElementPtr(context, i, pyMemberDefSize, GraalHPyCField.PyMemberDef__flags); - long docOffset = ReadGenericNode.getElementPtr(context, i, pyMemberDefSize, GraalHPyCField.PyMemberDef__doc); - - Object namePtr = readPointerNode.execute(context, memberDefArrPtr, nameOffset); - if (isNullNode.execute(context, namePtr)) { - return null; - } - - TruffleString name = fromCharPointerNode.execute(namePtr); - - // note: 'doc' may be NULL; in this case, we would store 'None' - Object memberDoc = PNone.NONE; - Object doc = readPointerNode.execute(context, memberDefArrPtr, docOffset); - if (!isNullNode.execute(context, doc)) { - memberDoc = fromCharPointerNode.execute(doc, false); - } - - int flags = readGenericNode.executeInt(context, memberDefArrPtr, flagsOffset, HPyContextSignatureType.Int); - int type = readGenericNode.executeInt(context, memberDefArrPtr, typeOffset, HPyContextSignatureType.Int); - int offset = readGenericNode.executeInt(context, memberDefArrPtr, offsetOffset, HPyContextSignatureType.Int); - - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - PBuiltinFunction getterObject = HPyReadMemberNode.createBuiltinFunction(language, name, type, offset); - - Object setterObject = null; - if ((flags & GraalHPyLegacyDef.MEMBER_FLAG_READONLY) == 0) { - setterObject = HPyWriteMemberNode.createBuiltinFunction(language, name, type, offset); - } - - // create a property - GetSetDescriptor memberDescriptor = PFactory.createMemberDescriptor(language, getterObject, setterObject, name, enclosingType); - writeDocNode.execute(memberDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); - return new HPyProperty(name, memberDescriptor); - } - } - - @GenerateUncached - @GenerateInline(false) // footprint reduction 52 -> 33 - public abstract static class HPyAddMemberNode extends PNodeWithContext { - - public abstract HPyProperty execute(GraalHPyContext context, PythonClass enclosingType, Object memberDef); - - /** - *
    -         * typedef struct {
    -         *     const char *name;
    -         *     HPyMember_FieldType type;
    -         *     HPy_ssize_t offset;
    -         *     int readonly;
    -         *     const char *doc;
    -         * } HPyMember;
    -         * 
    - */ - @Specialization - static HPyProperty doIt(GraalHPyContext context, PythonClass enclosingType, Object memberDef, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached TruffleString.EqualNode equalNode, - @Cached WriteAttributeToPythonObjectNode writeDocNode) { - - TruffleString name = fromCharPointerNode.execute(readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__member__name)); - - // note: 'doc' may be NULL; in this case, we would store 'None' - Object memberDoc = PNone.NONE; - Object doc = readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__member__doc); - if (!isNullNode.execute(context, doc)) { - memberDoc = fromCharPointerNode.execute(doc, false); - } - - int type = readGenericNode.readInt(context, memberDef, GraalHPyCField.HPyDef__member__type); - boolean readOnly = readGenericNode.readInt(context, memberDef, GraalHPyCField.HPyDef__member__readonly) != 0; - int offset = readGenericNode.readInt(context, memberDef, GraalHPyCField.HPyDef__member__offset); - - if (equalNode.execute(SpecialAttributeNames.T___VECTORCALLOFFSET__, name, TS_ENCODING)) { - enclosingType.setHPyVectorcallOffset(offset); - } - - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - PBuiltinFunction getterObject = HPyReadMemberNode.createBuiltinFunction(language, name, type, offset); - - Object setterObject = null; - if (!readOnly) { - setterObject = HPyWriteMemberNode.createBuiltinFunction(language, name, type, offset); - } - - // create member descriptor - GetSetDescriptor memberDescriptor = PFactory.createMemberDescriptor(language, getterObject, setterObject, name, enclosingType); - writeDocNode.execute(memberDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); - return new HPyProperty(name, memberDescriptor); - } - } - - /** - * Creates a get/set descriptor from an HPy get/set descriptor specification. - * - *
    -     * typedef struct {
    -     *     const char *name;
    -     *     void *getter_impl;            // Function pointer to the implementation
    -     *     void *setter_impl;            // Same; this may be NULL
    -     *     void *getter_cpy_trampoline;  // Used by CPython to call getter_impl
    -     *     void *setter_cpy_trampoline;  // Same; this may be NULL
    -     *     const char *doc;
    -     *     void *closure;
    -     * } HPyGetSet;
    -     * 
    - */ - @GenerateUncached - @GenerateInline(false) // footprint reduction 44 -> 25 - public abstract static class HPyCreateGetSetDescriptorNode extends PNodeWithContext { - - public abstract GetSetDescriptor execute(GraalHPyContext context, Object type, Object memberDef); - - @Specialization - static GetSetDescriptor doIt(GraalHPyContext context, Object type, Object memberDef, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached HPyAttachFunctionTypeNode attachFunctionTypeNode, - @Cached WriteAttributeToPythonObjectNode writeDocNode) { - - TruffleString name = fromCharPointerNode.execute(readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__name)); - - // note: 'doc' may be NULL; in this case, we would store 'None' - Object memberDoc = PNone.NONE; - Object docCharPtr = readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__doc); - if (!isNullNode.execute(context, docCharPtr)) { - memberDoc = fromCharPointerNode.execute(docCharPtr, false); - } - - Object closurePtr = readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__closure); - - // signature: self, closure - Object getterFunctionPtr = readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__getter_impl); - boolean hasGetter = !isNullNode.execute(context, getterFunctionPtr); - if (hasGetter) { - getterFunctionPtr = attachFunctionTypeNode.execute(context, getterFunctionPtr, LLVMType.HPyFunc_getter); - } - - // signature: self, value, closure - Object setterFunctionPtr = readPointerNode.read(context, memberDef, GraalHPyCField.HPyDef__getset__setter_impl); - boolean hasSetter = !isNullNode.execute(context, setterFunctionPtr); - if (hasSetter) { - setterFunctionPtr = attachFunctionTypeNode.execute(context, setterFunctionPtr, LLVMType.HPyFunc_setter); - } - - PBuiltinFunction getterObject; - if (hasGetter) { - getterObject = HPyGetSetDescriptorGetterRootNode.createFunction(context, type, name, getterFunctionPtr, closurePtr); - } else { - getterObject = null; - } - - PBuiltinFunction setterObject; - if (hasSetter) { - setterObject = HPyGetSetDescriptorSetterRootNode.createFunction(context, type, name, setterFunctionPtr, closurePtr); - } else { - setterObject = null; - } - - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - GetSetDescriptor getSetDescriptor = PFactory.createGetSetDescriptor(language, getterObject, setterObject, name, type, !hasSetter); - writeDocNode.execute(getSetDescriptor, SpecialAttributeNames.T___DOC__, memberDoc); - return getSetDescriptor; - } - } - - /** - * Parser an {@code HPySlot} structure, creates and adds the appropriate function as magic - * method. Returns either an HPyProperty if created, or the HPySlot itself. - * - *
    -     * typedef struct {
    -     *     HPySlot_Slot slot;     // The slot to fill
    -     *     void *impl;            // Function pointer to the implementation
    -     *     void *cpy_trampoline;  // Used by CPython to call impl
    -     * } HPySlot;
    -     * 
    - */ - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyReadSlotNode extends PNodeWithContext { - - public abstract HPySlotData execute(Node inliningTarget, GraalHPyContext context, Object slotDef); - - @Specialization - static HPySlotData doIt(Node inliningTarget, GraalHPyContext context, Object slotDef, - @Cached(parameters = "context", inline = false) GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached(parameters = "context", inline = false) GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(inline = false) HPyAttachFunctionTypeNode attachFunctionTypeNode) { - - int slotNr = readGenericNode.readInt(context, slotDef, GraalHPyCField.HPyDef__slot__slot); - HPySlot slot = HPySlot.fromValue(slotNr); - if (slot == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(inliningTarget, SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotNr); - } - - // read and check the function pointer - Object methodFunctionPointer = readPointerNode.read(context, slotDef, GraalHPyCField.HPyDef__slot__impl); - methodFunctionPointer = attachFunctionTypeNode.execute(context, methodFunctionPointer, slot.getSignatures()[0].getLLVMFunctionType()); - return new HPySlotData(slot, methodFunctionPointer); - } - } - - @GenerateUncached - @GenerateInline(false) // footprint reduction 44 -> 25 - public abstract static class HPyCreateSlotNode extends PNodeWithContext { - - public abstract Object execute(GraalHPyContext context, PythonClass enclosingType, TpSlots.Builder tpSlotsBuilder, Object slotDef); - - @Specialization - static Object doIt(GraalHPyContext context, PythonClass enclosingType, TpSlots.Builder tpSlotsBuilder, Object slotDef, - @Bind("this") Node inliningTarget, - @Cached HPyReadSlotNode readSlotNode, - @Cached TruffleString.FromJavaStringNode fromJavaStringNode, - @Cached PRaiseNode raiseNode) { - - assert enclosingType.isHPyType(); - HPySlotData slotData = readSlotNode.execute(inliningTarget, context, slotDef); - HPySlot slot = slotData.slot; - - TpSlotMeta tpSlot = slot.getTpSlot(); - if (tpSlot != null) { - // Slot that directly maps to a CPython compatible slot - Object boundExecutable = EnsureExecutableNode.executeUncached(slotData.impl(), tpSlot.getNativeSignature()); - tpSlotsBuilder.set(tpSlot, TpSlotNative.createHPySlot(boundExecutable)); - return null; - } - - HPyProperty property = null; - Object[] methodNames = slot.getAttributeKeys(); - HPySlotWrapper[] slotWrappers = slot.getSignatures(); - - /* - * Special case: DESTROYFUNC. This won't be usable from Python, so we just store the - * bare pointer object into Java field. - */ - if (HPY_TP_DESTROY.equals(slot)) { - enclosingType.setHPyDestroyFunc(slotData.impl()); - } else if (HPY_TP_TRAVERSE.equals(slot)) { - assert methodNames.length == 0; - return HPY_TP_TRAVERSE; - } else { - // create properties - for (int i = 0; i < methodNames.length; i++) { - Object methodName; - TruffleString methodNameStr; - if (methodNames[i] instanceof HiddenAttr ha) { - methodNameStr = fromJavaStringNode.execute(ha.getName(), TS_ENCODING); - methodName = methodNames[i]; - } else { - methodNameStr = (TruffleString) methodNames[i]; - methodName = methodNameStr; - } - HPySlotWrapper slotWrapper = slotWrappers[i]; - - Object enclosingTypeForFun = HPY_TP_NEW.equals(slot) ? null : enclosingType; - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - Object function = HPyExternalFunctionNodes.createWrapperFunction(language, context, slotWrapper, null, null, methodNameStr, slotData.impl(), enclosingTypeForFun); - property = new HPyProperty(methodName, function, property); - } - } - - /* - * Special case: HPy_tp_call. The installed attributed __call__ will be just a - * dispatcher. The actual function pointer given by the HPy definition is just the - * default call function that we need to remember and set on every freshly created - * instance of this type. - */ - if (HPY_TP_CALL.equals(slot)) { - if (enclosingType.getItemSize() > 0) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_VAR_OBJECTS); - } - if (enclosingType.getBuiltinShape() == GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY && enclosingType.getBasicSize() == 0) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_USE_CALL_WITH_LEGACY); - } - enclosingType.setHPyDefaultCallFunc(slotData.impl()); - } - return property; - } - } - - /** - * Parses a {@code PyType_Slot} structure - * - *
    -     * typedef struct{
    -     *     int slot;
    -     *     void *pfunc;
    -     * } PyType_Slot;
    -     * 
    - */ - @GenerateUncached - @GenerateInline(false) // footprint reduction 80 -> 61 - public abstract static class HPyCreateLegacySlotNode extends PNodeWithContext { - - public abstract boolean execute(GraalHPyContext context, Object enclosingType, TpSlots.Builder tpSlotsBuilder, Object slotDefArrPtr, int i); - - @Specialization - static boolean doIt(GraalHPyContext context, Object enclosingType, TpSlots.Builder tpSlotsBuilder, Object slotDefArrPtr, int i, - @Bind("this") Node inliningTarget, - @Cached(parameters = "context") GraalHPyCAccess.ReadGenericNode readGenericNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached CreateMethodNode legacyMethodNode, - @Cached HPyCreateLegacyMemberNode createLegacyMemberNode, - @Cached HPyAddLegacyGetSetDefNode legacyGetSetNode, - @Cached WriteAttributeToObjectNode writeAttributeToObjectNode, - @Cached ReadAttributeFromObjectNode readAttributeToObjectNode, - @Cached ReadPropertyNode readPropertyNode, - @Cached WritePropertyNode writePropertyNode, - @CachedLibrary(limit = "1") InteropLibrary lib, - @Cached PRaiseNode raiseNode) { - - // computes '&(slotDefArrPtr[i].slot)' - long slotIdOffset = ReadGenericNode.getElementPtr(context, i, context.getCTypeSize(HPyContextSignatureType.PyType_Slot), GraalHPyCField.PyType_Slot__slot); - int slotId = readGenericNode.executeInt(context, slotDefArrPtr, slotIdOffset, HPyContextSignatureType.Int); - if (slotId == 0) { - return false; - } - - HPyLegacySlot slot = HPyLegacySlot.fromValue(slotId); - if (slot == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, ErrorMessages.INVALID_SLOT_VALUE, slotId); - } - - // computes '&(slotDefArrPtr[i].pfunc)' - long pfuncOffset = ReadGenericNode.getElementPtr(context, i, context.getCTypeSize(HPyContextSignatureType.PyType_Slot), GraalHPyCField.PyType_Slot__pfunc); - Object pfuncPtr = readPointerNode.execute(context, slotDefArrPtr, pfuncOffset); - - TpSlotMeta tpSlot = slot.getTpSlot(); - if (tpSlot != null) { - // Note: not a HPy native slot, just plain native slot, because it is legacy and - // expects PyObject* arguments - Object boundExecutable = EnsureExecutableNode.executeUncached(pfuncPtr, tpSlot.getNativeSignature()); - tpSlotsBuilder.set(tpSlot, TpSlotNative.createCExtSlot(boundExecutable)); - return true; - } - - // treatment for special slots 'Py_tp_members', 'Py_tp_getset', 'Py_tp_methods' - switch (slot) { - case Py_tp_members: - for (int j = 0;; j++) { - HPyProperty property = createLegacyMemberNode.execute(context, enclosingType, pfuncPtr, j); - if (property == null) { - break; - } - property.write(inliningTarget, writePropertyNode, readPropertyNode, enclosingType); - } - break; - case Py_tp_methods: - for (int j = 0;; j++) { - PBuiltinFunction method = legacyMethodNode.execute(inliningTarget, pfuncPtr, j); - if (method == null) { - break; - } - writeAttributeToObjectNode.execute(enclosingType, method.getName(), method); - } - break; - case Py_tp_getset: - for (int j = 0;; j++) { - GetSetDescriptor getSetDescriptor = legacyGetSetNode.execute(context, enclosingType, pfuncPtr, j); - if (getSetDescriptor == null) { - break; - } - writeAttributeToObjectNode.execute(enclosingType, getSetDescriptor.getName(), getSetDescriptor); - } - break; - default: - // this is the generic slot case - // TODO: when all CPython compatible slots are implemented, this should go away - TruffleString attributeKey = slot.getAttributeKey(); - if (attributeKey != null) { - if (!HPyProperty.keyExists(readAttributeToObjectNode, enclosingType, attributeKey)) { - Object interopPFuncPtr = context.nativeToInteropPointer(pfuncPtr); - PythonObject method; - Object resolved = CreateFunctionNode.resolveClosurePointerToBuiltinFun(context.getContext(), interopPFuncPtr, lib, enclosingType, attributeKey, - slot.getSignature()); - if (resolved instanceof PBuiltinFunction builtinFunction) { - method = builtinFunction; - } else { - Object callable; - if (resolved instanceof RootCallTarget || resolved instanceof BuiltinMethodDescriptor) { - callable = resolved; - } else { - assert resolved == null; - // the pointer is not a closure pointer, so we assume it is a - // native function pointer - callable = interopPFuncPtr; - } - PythonLanguage lang = context.getContext().getLanguage(inliningTarget); - method = PExternalFunctionWrapper.createWrapperFunction(attributeKey, callable, enclosingType, 0, slot.getSignature(), lang, true); - } - writeAttributeToObjectNode.execute(enclosingType, attributeKey, method); - } else { - // TODO(fa): implement support for remaining legacy slot kinds - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere(PythonUtils.formatJString("support for legacy slot %s not yet implemented", slot.name())); - } - } - break; - } - return true; - } - } - - @GenerateUncached - @GenerateInline(false) - public abstract static class HPyAsContextNode extends CExtToJavaNode { - - @Specialization - static GraalHPyContext doHandle(GraalHPyNativeContext hpyContext) { - return hpyContext.context; - } - - /* - * n.b. we could actually accept anything else, but we have specializations to be more * - * strict about what we expect - */ - - @Specialization - GraalHPyContext doInt(@SuppressWarnings("unused") int handle) { - return getContext().getHPyContext(); - } - - @Specialization - GraalHPyContext doLong(@SuppressWarnings("unused") long handle) { - return getContext().getHPyContext(); - } - - @Specialization(guards = "interopLibrary.isPointer(handle)", limit = "2") - static GraalHPyContext doPointer(@SuppressWarnings("unused") Object handle, - @CachedLibrary("handle") InteropLibrary interopLibrary) { - return PythonContext.get(interopLibrary).getHPyContext(); - } - } - - @ImportStatic(GraalHPyBoxing.class) - public abstract static class HPyWithContextNode extends PNodeWithContext { - - static long asPointer(Object handle, InteropLibrary lib) { - try { - return lib.asPointer(handle); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - @ImportStatic(GraalHPyBoxing.class) - public abstract static class HPyEnsureHandleNode extends HPyWithContextNode { - - public abstract GraalHPyHandle execute(Node inliningTarget, Object object); - - @Specialization - static GraalHPyHandle doHandle(GraalHPyHandle handle) { - return handle; - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - static GraalHPyHandle doOtherBoxedHandle(Node inliningTarget, @SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return doLong(inliningTarget, bits); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedNullHandle(bits)"}) - @SuppressWarnings("unused") - static GraalHPyHandle doOtherNull(Object value, - @Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyHandle.NULL_HANDLE; - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedInt(bits) || isBoxedDouble(bits)"}) - static GraalHPyHandle doOtherBoxedPrimitive(Node inliningTarget, @SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return doBoxedPrimitive(inliningTarget, bits); - } - - @Specialization(guards = "isBoxedNullHandle(bits)") - @SuppressWarnings("unused") - static GraalHPyHandle doLongNull(long bits) { - return GraalHPyHandle.NULL_HANDLE; - } - - @Specialization(guards = {"isBoxedHandle(bits)"}, replaces = "doLongNull") - static GraalHPyHandle doLong(Node inliningTarget, long bits) { - GraalHPyContext context = PythonContext.get(inliningTarget).getHPyContext(); - return context.createHandle(context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits))); - } - - @Specialization(guards = "isBoxedInt(bits) || isBoxedDouble(bits)") - @SuppressWarnings("unused") - static GraalHPyHandle doBoxedPrimitive(Node inliningTarget, long bits) { - /* - * In this case, the long value is a boxed primitive and we cannot resolve it to a - * GraalHPyHandle instance (because no instance has ever been created). We create a - * fresh GaalHPyHandle instance here. - */ - Object delegate; - if (GraalHPyBoxing.isBoxedInt(bits)) { - delegate = GraalHPyBoxing.unboxInt(bits); - } else if (GraalHPyBoxing.isBoxedDouble(bits)) { - delegate = GraalHPyBoxing.unboxDouble(bits); - } else { - throw CompilerDirectives.shouldNotReachHere(); - } - return PythonContext.get(inliningTarget).getHPyContext().createHandle(delegate); - } - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - @ImportStatic(GraalHPyBoxing.class) - public abstract static class HPyCloseHandleNode extends HPyWithContextNode { - - public abstract void execute(Node inliningTarget, Object object); - - public static void executeUncached(Object object) { - HPyCloseHandleNodeGen.getUncached().execute(null, object); - } - - @Specialization(guards = "!handle.isAllocated()") - @SuppressWarnings("unused") - static void doHandle(GraalHPyHandle handle) { - // nothing to do - } - - @Specialization(guards = "handle.isAllocated()") - static void doHandleAllocated(Node inliningTarget, GraalHPyHandle handle) { - handle.closeAndInvalidate(PythonContext.get(inliningTarget).getHPyContext()); - } - - @Specialization(guards = "isBoxedNullHandle(bits)") - @SuppressWarnings("unused") - static void doNullLong(long bits) { - // nothing to do - } - - @Specialization(guards = {"!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - static void doLong(Node inliningTarget, long bits) { - /* - * Since we have a long and it is in the "boxed handle" range, we know that the handle - * *MUST* be allocated. - */ - int id = GraalHPyBoxing.unboxHandle(bits); - assert GraalHPyHandle.isAllocated(id); - PythonContext.get(inliningTarget).getHPyContext().releaseHPyHandleForObject(id); - } - - @Specialization(guards = "!isBoxedHandle(bits)") - @SuppressWarnings("unused") - static void doLongDouble(long bits) { - // nothing to do - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedNullHandle(bits)"}) - @SuppressWarnings("unused") - static void doNullOther(Object value, - @Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - // nothing to do - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - static void doOther(Node inliningTarget, @SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - doLong(inliningTarget, bits); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedHandle(bits)"}) - @SuppressWarnings("unused") - static void doOtherDouble(Object value, - @Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - // nothing to do - } - } - - @GenerateInline - @GenerateCached(false) - @GenerateUncached - public abstract static class HPyCloseAndGetHandleNode extends HPyWithContextNode { - - public abstract Object execute(Node inliningTarget, Object object); - - public abstract Object execute(Node inliningTarget, long object); - - @Specialization(guards = "!handle.isAllocated()") - static Object doHandle(GraalHPyHandle handle) { - return handle.getDelegate(); - } - - @Specialization(guards = "handle.isAllocated()") - static Object doHandleAllocated(Node inliningTarget, GraalHPyHandle handle) { - handle.closeAndInvalidate(PythonContext.get(inliningTarget).getHPyContext()); - return handle.getDelegate(); - } - - @Specialization(guards = "isBoxedNullHandle(bits)") - @SuppressWarnings("unused") - static Object doNullLong(long bits) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - - @Specialization(guards = {"!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - static Object doLong(Node inliningTarget, long bits) { - /* - * Since we have a long and it is in the "boxed handle" range, we know that the handle - * *MUST* be allocated. - */ - int id = GraalHPyBoxing.unboxHandle(bits); - assert GraalHPyHandle.isAllocated(id); - GraalHPyContext context = PythonContext.get(inliningTarget).getHPyContext(); - Object delegate = context.getObjectForHPyHandle(id); - context.releaseHPyHandleForObject(id); - return delegate; - } - - @Specialization(guards = "isBoxedDouble(bits)") - static double doLongDouble(long bits) { - return GraalHPyBoxing.unboxDouble(bits); - } - - @Specialization(guards = "isBoxedInt(bits)") - static int doLongInt(long bits) { - return GraalHPyBoxing.unboxInt(bits); - } - - static long asPointer(Object handle, InteropLibrary lib) { - try { - return lib.asPointer(handle); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedNullHandle(bits)"}) - @SuppressWarnings("unused") - static Object doNullOther(Object value, - @Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - static Object doOther(Node inliningTarget, @SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return doLong(inliningTarget, bits); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedDouble(bits)"}) - static double doOtherDouble(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyBoxing.unboxDouble(bits); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedInt(bits)"}) - static int doOtherInt(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyBoxing.unboxInt(bits); - } - } - - @GenerateUncached - @GenerateInline(false) - @ImportStatic(GraalHPyBoxing.class) - public abstract static class HPyAsPythonObjectNode extends CExtToJavaNode { - - public abstract Object execute(long bits); - - @Specialization - static Object doHandle(GraalHPyHandle handle) { - return handle.getDelegate(); - } - - @Specialization(guards = "isBoxedNullHandle(bits)") - @SuppressWarnings("unused") - static Object doNullLong(long bits) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - - @Specialization(guards = {"!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - Object doLong(long bits) { - return getContext().getHPyContext().getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - } - - @Specialization(guards = "isBoxedDouble(bits)") - static double doLongDouble(long bits) { - return GraalHPyBoxing.unboxDouble(bits); - } - - @Specialization(guards = "isBoxedInt(bits)") - static int doLongInt(long bits) { - return GraalHPyBoxing.unboxInt(bits); - } - - static long asPointer(Object handle, InteropLibrary lib) { - try { - return lib.asPointer(handle); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedNullHandle(bits)"}) - static Object doNullOther(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") @SuppressWarnings("unused") long bits) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "!isBoxedNullHandle(bits)", "isBoxedHandle(bits)"}) - Object doOther(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return getContext().getHPyContext().getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedDouble(bits)"}) - static double doOtherDouble(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyBoxing.unboxDouble(bits); - } - - @Specialization(guards = {"!isLong(value)", "!isHPyHandle(value)", "isBoxedInt(bits)"}) - static int doOtherInt(@SuppressWarnings("unused") Object value, - @Shared("lib") @CachedLibrary(limit = "2") @SuppressWarnings("unused") InteropLibrary lib, - @Bind("asPointer(value, lib)") long bits) { - return GraalHPyBoxing.unboxInt(bits); - } - - @Specialization(replaces = {"doHandle", // - "doNullLong", "doLong", "doLongDouble", "doLongInt", // - "doNullOther", "doOther", "doOtherDouble", "doOtherInt" // - }) - Object doGeneric(Object value, - @Shared("lib") @CachedLibrary(limit = "2") InteropLibrary lib) { - if (value instanceof GraalHPyHandle) { - return ((GraalHPyHandle) value).getDelegate(); - } - long bits; - if (value instanceof Long) { - bits = (Long) value; - } else { - lib.toNative(value); - try { - bits = lib.asPointer(value); - } catch (UnsupportedMessageException ex) { - throw CompilerDirectives.shouldNotReachHere(ex); - } - } - if (GraalHPyBoxing.isBoxedNullHandle(bits)) { - return GraalHPyHandle.NULL_HANDLE_DELEGATE; - } else if (GraalHPyBoxing.isBoxedInt(bits)) { - return GraalHPyBoxing.unboxInt(bits); - } else if (GraalHPyBoxing.isBoxedDouble(bits)) { - return GraalHPyBoxing.unboxDouble(bits); - } else { - assert GraalHPyBoxing.isBoxedHandle(bits); - return getContext().getHPyContext().getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - } - } - } - - public static final class HPyDummyToJavaNode extends CExtToJavaNode { - private static final HPyDummyToJavaNode UNCACHED = new HPyDummyToJavaNode(); - - public static HPyDummyToJavaNode create() { - return new HPyDummyToJavaNode(); - } - - public static HPyDummyToJavaNode getUncached() { - return UNCACHED; - } - - @Override - public Object execute(Object object) { - return object; - } - - @Override - public boolean isAdoptable() { - return this != UNCACHED; - } - } - - @GenerateUncached - @GenerateInline(false) - @ImportStatic(PGuards.class) - public abstract static class HPyAsHandleNode extends CExtToNativeNode { - protected static final byte HANDLE = 0; - protected static final byte GLOBAL = 1; - protected static final byte FIELD = 2; - - @Override - public final GraalHPyHandle execute(Object object) { - return execute(object, 0, HANDLE); - } - - public final GraalHPyHandle executeGlobal(Object object, int id) { - return execute(object, id, GLOBAL); - } - - public final GraalHPyHandle executeField(Object object, int id) { - return execute(object, id, FIELD); - } - - protected abstract GraalHPyHandle execute(Object object, int id, int type); - - /* - * NOTE: We *MUST NOT* box values here because we don't know where the handle will be given - * to. In case we give it to LLVM code, we must still have an object that emulates the HPy - * struct. - */ - - @Specialization(guards = "isNoValue(object)") - @SuppressWarnings("unused") - static GraalHPyHandle doNoValue(PNone object, int id, int type) { - return GraalHPyHandle.NULL_HANDLE; - } - - @Specialization(guards = {"!isNoValue(object)", "type == HANDLE"}) - GraalHPyHandle doObject(Object object, @SuppressWarnings("unused") int id, @SuppressWarnings("unused") int type) { - return getContext().getHPyContext().createHandle(object); - } - - @Specialization(guards = {"!isNoValue(object)", "type == GLOBAL"}) - static GraalHPyHandle doGlobal(Object object, int id, @SuppressWarnings("unused") int type) { - return GraalHPyHandle.createGlobal(object, id); - } - - @Specialization(guards = {"!isNoValue(object)", "type == FIELD"}) - GraalHPyHandle doField(Object object, int id, @SuppressWarnings("unused") int type) { - return getContext().getHPyContext().createField(object, id); - } - } - - /** - * Converts a Python object to a native {@code int64_t} compatible value. - */ - @GenerateUncached - @GenerateInline(false) - public abstract static class HPyAsNativeInt64Node extends CExtToNativeNode { - - // Adding specializations for primitives does not make a lot of sense just to avoid - // un-/boxing in the interpreter since interop will force un-/boxing anyway. - @Specialization - static Object doGeneric(Object value, - @Bind("this") Node inliningTarget, - @Cached ConvertPIntToPrimitiveNode asNativePrimitiveNode) { - return asNativePrimitiveNode.execute(inliningTarget, value, 1, Long.BYTES); - } - } - - public abstract static class HPyConvertArgsToSulongNode extends PNodeWithContext { - - public abstract void executeInto(VirtualFrame frame, Object[] args, int argsOffset, Object[] dest, int destOffset); - - abstract HPyCloseArgHandlesNode createCloseHandleNode(); - } - - public abstract static class HPyCloseArgHandlesNode extends PNodeWithContext { - - public abstract void executeInto(VirtualFrame frame, Object[] args, int argsOffset); - } - - @GenerateInline(false) - public abstract static class HPyVarargsToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode selfAsHandleNode) { - dest[destOffset] = selfAsHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = args[argsOffset + 1]; - dest[destOffset + 2] = args[argsOffset + 2]; - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPyVarargsHandleCloseNodeGen.create(); - } - } - - /** - * The counter part of {@link HPyVarargsToSulongNode}. - */ - @GenerateInline(false) - public abstract static class HPyVarargsHandleCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeHandleNode) { - closeHandleNode.execute(inliningTarget, dest[destOffset]); - } - } - - /** - * Always closes parameter at position {@code destOffset} (assuming that it is a handle). - */ - @GenerateInline(false) - public abstract static class HPySelfHandleCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeHandleNode) { - closeHandleNode.execute(inliningTarget, dest[destOffset]); - } - } - - @GenerateInline(false) - public abstract static class HPyKeywordsToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode selfAsHandleNode, - @Cached HPyAsHandleNode kwAsHandleNode) { - dest[destOffset] = selfAsHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = args[argsOffset + 1]; - dest[destOffset + 2] = args[argsOffset + 2]; - dest[destOffset + 3] = kwAsHandleNode.execute(args[argsOffset + 3]); - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPyKeywordsHandleCloseNodeGen.create(); - } - } - - /** - * The counter part of {@link HPyKeywordsToSulongNode}. - */ - @GenerateInline(false) - public abstract static class HPyKeywordsHandleCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeFirstHandleNode, - @Cached HPyCloseHandleNode closeSecondHandleNode) { - closeFirstHandleNode.execute(inliningTarget, dest[destOffset]); - closeSecondHandleNode.execute(inliningTarget, dest[destOffset + 3]); - } - } - - @GenerateInline(false) - public abstract static class HPyAllAsHandleNode extends HPyConvertArgsToSulongNode { - - static boolean isArgsOffsetPlus(int len, int off, int plus) { - return len == off + plus; - } - - static boolean isLeArgsOffsetPlus(int len, int off, int plus) { - return len < plus + off; - } - - @Specialization(guards = {"args.length == argsOffset"}) - @SuppressWarnings("unused") - static void cached0(Object[] args, int argsOffset, Object[] dest, int destOffset) { - } - - @Specialization(guards = {"args.length == cachedLength", "isLeArgsOffsetPlus(cachedLength, argsOffset, 8)"}, limit = "1", replaces = "cached0") - @ExplodeLoop - static void cachedLoop(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached("args.length") int cachedLength, - @Shared @Cached HPyAsHandleNode toSulongNode) { - CompilerAsserts.partialEvaluationConstant(destOffset); - for (int i = 0; i < cachedLength - argsOffset; i++) { - dest[destOffset + i] = toSulongNode.execute(args[argsOffset + i]); - } - } - - @Specialization(replaces = {"cached0", "cachedLoop"}) - static void uncached(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Shared @Cached HPyAsHandleNode toSulongNode) { - int len = args.length; - for (int i = 0; i < len - argsOffset; i++) { - dest[destOffset + i] = toSulongNode.execute(args[argsOffset + i]); - } - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPyAllHandleCloseNodeGen.create(); - } - } - - /** - * The counter part of {@link HPyAllAsHandleNode}. - */ - @GenerateInline(false) - public abstract static class HPyAllHandleCloseNode extends HPyCloseArgHandlesNode { - - @Specialization(guards = {"dest.length == destOffset"}) - @SuppressWarnings("unused") - static void cached0(Object[] dest, int destOffset) { - } - - @Specialization(guards = {"dest.length == cachedLength", "isLeArgsOffsetPlus(cachedLength, destOffset, 8)"}, limit = "1", replaces = "cached0") - @ExplodeLoop - static void cachedLoop(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached("dest.length") int cachedLength, - @Shared @Cached HPyCloseHandleNode closeHandleNode) { - CompilerAsserts.partialEvaluationConstant(destOffset); - for (int i = 0; i < cachedLength - destOffset; i++) { - closeHandleNode.execute(inliningTarget, dest[destOffset + i]); - } - } - - @Specialization(replaces = {"cached0", "cachedLoop"}) - static void uncached(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyCloseHandleNode closeHandleNode) { - int len = dest.length; - for (int i = 0; i < len - destOffset; i++) { - closeHandleNode.execute(inliningTarget, dest[destOffset + i]); - } - } - - static boolean isLeArgsOffsetPlus(int len, int off, int plus) { - return len < plus + off; - } - } - - /** - * Argument converter for calling a native get/set descriptor getter function. The native - * signature is: {@code HPy getter(HPyContext ctx, HPy self, void* closure)}. - */ - @GenerateInline(false) - public abstract static class HPyGetSetGetterToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode selfAsHandleNode) { - dest[destOffset] = selfAsHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = args[argsOffset + 1]; - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPySelfHandleCloseNodeGen.create(); - } - } - - /** - * Argument converter for calling a native get/set descriptor setter function. The native - * signature is: {@code HPy setter(HPyContext ctx, HPy self, HPy value, void* closure)}. - */ - @GenerateInline(false) - public abstract static class HPyGetSetSetterToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode asHandleNode) { - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = asHandleNode.execute(args[argsOffset + 1]); - dest[destOffset + 2] = args[argsOffset + 2]; - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPyGetSetSetterHandleCloseNodeGen.create(); - } - } - - /** - * The counter part of {@link HPyGetSetSetterToSulongNode}. - */ - @GenerateInline(false) - public abstract static class HPyGetSetSetterHandleCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeFirstHandleNode, - @Cached HPyCloseHandleNode closeSecondHandleNode) { - closeFirstHandleNode.execute(inliningTarget, dest[destOffset]); - closeSecondHandleNode.execute(inliningTarget, dest[destOffset + 1]); - } - } - - /** - * Converts {@code self} to an HPy handle and any other argument to {@code HPy_ssize_t}. - */ - @GenerateInline(false) - public abstract static class HPySSizeArgFuncToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization(guards = {"isArity(args.length, argsOffset, 2)"}) - static void doHandleSsizeT(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyAsHandleNode asHandleNode, - @Shared @Cached ConvertPIntToPrimitiveNode asSsizeTNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = asSsizeTNode.execute(inliningTarget, args[argsOffset + 1], 1, Long.BYTES); - } - - @Specialization(guards = {"isArity(args.length, argsOffset, 3)"}) - static void doHandleSsizeTSsizeT(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyAsHandleNode asHandleNode, - @Shared @Cached ConvertPIntToPrimitiveNode asSsizeTNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = asSsizeTNode.execute(inliningTarget, args[argsOffset + 1], 1, Long.BYTES); - dest[destOffset + 2] = asSsizeTNode.execute(inliningTarget, args[argsOffset + 2], 1, Long.BYTES); - } - - @Specialization(replaces = {"doHandleSsizeT", "doHandleSsizeTSsizeT"}) - static void doGeneric(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Shared @Cached HPyAsHandleNode asHandleNode, - @Shared @Cached ConvertPIntToPrimitiveNode asSsizeTNode) { - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - for (int i = 1; i < args.length - argsOffset; i++) { - dest[destOffset + i] = asSsizeTNode.execute(inliningTarget, args[argsOffset + i], 1, Long.BYTES); - } - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPySelfHandleCloseNodeGen.create(); - } - - static boolean isArity(int len, int off, int expected) { - return len - off == expected; - } - } - - /** - * Converts arguments for C function signature - * {@code int (*HPyFunc_ssizeobjargproc)(HPyContext ctx, HPy, HPy_ssize_t, HPy)}. - */ - @GenerateInline(false) - public abstract static class HPySSizeObjArgProcToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyAsHandleNode asHandleNode, - @Cached ConvertPIntToPrimitiveNode asSsizeTNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = asSsizeTNode.execute(inliningTarget, args[argsOffset + 1], 1, Long.BYTES); - dest[destOffset + 2] = asHandleNode.execute(args[argsOffset + 2]); - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPySSizeObjArgProcCloseNodeGen.create(); - } - } - - /** - * Always closes handle parameter at position {@code destOffset} and also closes parameter at - * position {@code destOffset + 2} if it is not a {@code NULL} handle. - */ - @GenerateInline(false) - public abstract static class HPySSizeObjArgProcCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeFirstHandleNode, - @Cached HPyCloseHandleNode closeSecondHandleNode) { - closeFirstHandleNode.execute(inliningTarget, dest[destOffset]); - closeSecondHandleNode.execute(inliningTarget, dest[destOffset + 2]); - } - } - - /** - * Converts arguments for C function signature - * {@code HPy (*HPyFunc_richcmpfunc)(HPyContext ctx, HPy, HPy, HPy_RichCmpOp);}. - */ - @GenerateInline(false) - public abstract static class HPyRichcmpFuncArgsToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConvert(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode asHandleNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = asHandleNode.execute(args[argsOffset + 1]); - dest[destOffset + 2] = args[argsOffset + 2]; - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPyRichcmptFuncArgsCloseNodeGen.create(); - } - } - - /** - * Always closes handle parameter at positions {@code destOffset} and {@code destOffset + 1}. - */ - @GenerateInline(false) - public abstract static class HPyRichcmptFuncArgsCloseNode extends HPyCloseArgHandlesNode { - - @Specialization - static void doConvert(Object[] dest, int destOffset, - @Bind("this") Node inliningTarget, - @Cached HPyCloseHandleNode closeFirstHandleNode, - @Cached HPyCloseHandleNode closeSecondHandleNode) { - closeFirstHandleNode.execute(inliningTarget, dest[destOffset]); - closeSecondHandleNode.execute(inliningTarget, dest[destOffset + 1]); - } - } - - /** - * Converts for C function signature - * {@code int (*HPyFunc_getbufferproc)(HPyContext ctx, HPy self, HPy_buffer *buffer, int flags)} - * . - */ - @GenerateInline(false) - public abstract static class HPyGetBufferProcToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConversion(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode asHandleNode, - @Cached AsNativePrimitiveNode asIntNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = args[argsOffset + 1]; - dest[destOffset + 2] = asIntNode.execute(args[argsOffset + 2], 1, Integer.BYTES, true); - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPySelfHandleCloseNodeGen.create(); - } - } - - /** - * Converts for C function signature - * {@code void (*HPyFunc_releasebufferproc)(HPyContext ctx, HPy self, HPy_buffer *buffer)}. - */ - @GenerateInline(false) - public abstract static class HPyReleaseBufferProcToSulongNode extends HPyConvertArgsToSulongNode { - - @Specialization - static void doConversion(Object[] args, int argsOffset, Object[] dest, int destOffset, - @Cached HPyAsHandleNode asHandleNode) { - CompilerAsserts.partialEvaluationConstant(argsOffset); - dest[destOffset] = asHandleNode.execute(args[argsOffset]); - dest[destOffset + 1] = args[argsOffset + 1]; - } - - @Override - HPyCloseArgHandlesNode createCloseHandleNode() { - return HPySelfHandleCloseNodeGen.create(); - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - abstract static class HPyLongFromLong extends Node { - public abstract Object execute(Node inliningTarget, int value, boolean signed); - - public abstract Object execute(Node inliningTarget, long value, boolean signed); - - public abstract Object execute(Node inliningTarget, Object value, boolean signed); - - @Specialization(guards = "signed") - static int doSignedInt(int n, @SuppressWarnings("unused") boolean signed) { - return n; - } - - @Specialization(guards = "!signed") - static long doUnsignedInt(int n, @SuppressWarnings("unused") boolean signed) { - if (n < 0) { - return n & 0xFFFFFFFFL; - } - return n; - } - - @Specialization(guards = "signed") - static long doSignedLong(long n, @SuppressWarnings("unused") boolean signed) { - return n; - } - - @Specialization(guards = {"!signed", "n >= 0"}) - static long doUnsignedLongPositive(long n, @SuppressWarnings("unused") boolean signed) { - return n; - } - - @Specialization(guards = {"!signed", "n < 0"}) - static Object doUnsignedLongNegative(long n, @SuppressWarnings("unused") boolean signed, - @Bind PythonLanguage language) { - return PFactory.createInt(language, convertToBigInteger(n)); - } - - @TruffleBoundary - private static BigInteger convertToBigInteger(long n) { - return BigInteger.valueOf(n).add(BigInteger.ONE.shiftLeft(Long.SIZE)); - } - - @Specialization - static Object doPointer(PythonNativeObject n, @SuppressWarnings("unused") boolean signed, - @Bind PythonLanguage language) { - return PFactory.createNativeVoidPtr(language, n.getPtr()); - } - } - - /** - * Represents {@code HPyType_SpecParam}. - */ - @ValueType - record HPyTypeSpecParam(int kind, Object object) { - }; - - /** - *
    -     *     typedef struct {
    -     *         const char* name;
    -     *         int basicsize;
    -     *         int itemsize;
    -     *         unsigned int flags;
    -     *         int legacy;
    -     *         void *legacy_slots;
    -     *         HPyDef **defines;
    -     *         const char *doc;
    -     *     } HPyType_Spec;
    -     * 
    - */ - @GenerateUncached - @GenerateInline(false) // footprint reduction 196 -> 180 - abstract static class HPyCreateTypeFromSpecNode extends Node { - - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(HPyCreateTypeFromSpecNode.class); - static final TruffleString T_PYTRUFFLE_CREATETYPE = tsLiteral("PyTruffle_CreateType"); - - abstract Object execute(GraalHPyContext context, Object typeSpec, Object typeSpecParamArray); - - @Specialization - static Object doGeneric(GraalHPyContext context, Object typeSpec, Object typeSpecParamArray, - @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") DynamicObjectLibrary dylib, - @Cached(parameters = "context") GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context") GraalHPyCAccess.AllocateNode allocateNode, - @Cached(parameters = "context") GraalHPyCAccess.ReadI32Node readI32Node, - @Cached(parameters = "context") GraalHPyCAccess.IsNullNode isNullNode, - @Cached(parameters = "context") HPyAsCharPointerNode asCharPointerNode, - @Cached HPyTypeSplitNameNode splitName, - @Cached FromCharPointerNode fromCharPointerNode, - @Cached IsTypeNode isTypeNode, - @Cached HasSameConstructorNode hasSameConstructorNode, - @Cached CStructAccess.ReadI64Node getMetaSizeNode, - @Cached WriteAttributeToObjectNode writeAttributeToObjectNode, - @Cached ReadPropertyNode readPropertyNode, - @Cached WritePropertyNode writePropertyNode, - @Cached PyObjectCallMethodObjArgs callCreateTypeNode, - @Cached HPyCreateFunctionNode addFunctionNode, - @Cached HPyAddMemberNode addMemberNode, - @Cached HPyCreateSlotNode addSlotNode, - @Cached HPyCreateLegacySlotNode createLegacySlotNode, - @Cached HPyCreateGetSetDescriptorNode createGetSetDescriptorNode, - @Cached GetBaseClassNode getBaseClassNode, - @Cached LookupAttributeInMRONode.Dynamic lookupNewNode, - @Cached PRaiseNode raiseNode) { - - try { - PythonLanguage language = context.getContext().getLanguage(inliningTarget); - // the name as given by the specification - TruffleString specName = fromCharPointerNode.execute(readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__name), false); - - // extract module and type name - TruffleString[] names = splitName.execute(inliningTarget, specName); - assert names.length == 2; - - Object tpName = asCharPointerNode.execute(context, names[1], Encoding.UTF_8); - - PDict namespace; - Object doc = readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__doc); - if (!isNullNode.execute(context, doc)) { - TruffleString docString = fromCharPointerNode.execute(doc); - namespace = PFactory.createDict(language, new PKeyword[]{new PKeyword(SpecialAttributeNames.T___DOC__, docString)}); - } else { - namespace = PFactory.createDict(language); - } - - HPyTypeSpecParam[] typeSpecParams = extractTypeSpecParams(context, typeSpecParamArray); - - // extract bases from type spec params - PTuple bases = extractBases(typeSpecParams, language); - // extract metaclass from type spec params - Object metatype = getMetatype(inliningTarget, typeSpecParams); - - if (metatype != null) { - if (!isTypeNode.execute(inliningTarget, metatype)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, metatype); - } - if (!hasSameConstructorNode.execute(inliningTarget, metatype, PythonBuiltinClassType.PythonClass)) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_WITH_CUSTOM_CONS_NOT_SUPPORTED); - } - } - - // create the type object - PythonModule pythonCextModule = PythonContext.get(inliningTarget).lookupBuiltinModule(BuiltinNames.T___GRAALPYTHON__); - PythonClass newType = (PythonClass) callCreateTypeNode.execute(null, inliningTarget, pythonCextModule, T_PYTRUFFLE_CREATETYPE, - names[1], bases, namespace, metatype != null ? metatype : PythonBuiltinClassType.PythonClass); - // allocate additional memory for the metatype and set it - long metaBasicSize = 0; - Object destroyFunc = null; - if (metatype instanceof PythonClass metaclass) { - // get basicsize of metatype and allocate it into - // GraalHPyDef.OBJECT_HPY_NATIVE_SPACE - metaBasicSize = metaclass.getBasicSize(); - destroyFunc = metaclass.getHPyDestroyFunc(); - } else if (metatype instanceof PythonAbstractNativeObject nativeObject) { - // This path is implemented only for completeness, - // but is not expected to happen often, hence the - // uncached nodes, no profiling and potential leak - metaBasicSize = getMetaSizeNode.readFromObj(nativeObject, PyTypeObject__tp_basicsize); - } - if (metaBasicSize > 0) { - Object dataPtr = allocateNode.calloc(context, 1, metaBasicSize); - GraalHPyData.setHPyNativeSpace(newType, dataPtr); - if (destroyFunc != null) { - context.createHandleReference(newType, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); - } - } - - // determine and set the correct module attribute - TruffleString value = names[0]; - if (value != null) { - writeAttributeToObjectNode.execute(newType, SpecialAttributeNames.T___MODULE__, value); - } else { - // TODO(fa): issue deprecation warning with message "builtin type %.200s has no - // __module__ attribute" - } - - // store flags, basicsize, and itemsize to type - long flags = readI32Node.readUnsigned(context, typeSpec, GraalHPyCField.HPyType_Spec__flags); - int builtinShape = readI32Node.read(context, typeSpec, GraalHPyCField.HPyType_Spec__builtin_shape); - if (!GraalHPyDef.isValidBuiltinShape(builtinShape)) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.HPY_INVALID_BUILTIN_SHAPE, builtinShape); - } - - long basicSize = readI32Node.read(context, typeSpec, GraalHPyCField.HPyType_Spec__basicsize); - long itemSize = readI32Node.read(context, typeSpec, GraalHPyCField.HPyType_Spec__itemsize); - newType.setHPyTypeExtra(new HPyTypeExtra(flags, basicSize, itemSize, tpName, builtinShape)); - newType.makeStaticBase(dylib); - - boolean seenNew = false; - boolean needsTpTraverse = ((flags & GraalHPyDef.HPy_TPFLAGS_HAVE_GC) != 0); - // The builder will collect both the HPy and legacy slots - Builder tpSlotsBuilder = TpSlots.newBuilder(); - - // process defines - Object defines = readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__defines); - // field 'defines' may be 'NULL' - if (!isNullNode.execute(context, defines)) { - for (long i = 0;; i++) { - Object def = readPointerNode.readArrayElement(context, defines, i); - if (isNullNode.execute(context, def)) { - break; - } - HPyProperty property = null; - int kind = readI32Node.read(context, def, GraalHPyCField.HPyDef__kind); - switch (kind) { - case GraalHPyDef.HPY_DEF_KIND_METH: - PBuiltinFunction fun = addFunctionNode.execute(context, newType, def); - property = new HPyProperty(fun.getName(), fun); - break; - case GraalHPyDef.HPY_DEF_KIND_SLOT: - Object addSlotResult = addSlotNode.execute(context, newType, tpSlotsBuilder, def); - if (HPY_TP_TRAVERSE.equals(addSlotResult)) { - needsTpTraverse = false; - } else if (addSlotResult instanceof HPyProperty) { - property = (HPyProperty) addSlotResult; - } - if (property != null && T___NEW__.equals(property.key)) { - seenNew = true; - } - break; - case GraalHPyDef.HPY_DEF_KIND_MEMBER: - property = addMemberNode.execute(context, newType, def); - break; - case GraalHPyDef.HPY_DEF_KIND_GETSET: - GetSetDescriptor getSetDescriptor = createGetSetDescriptorNode.execute(context, newType, def); - property = new HPyProperty(getSetDescriptor.getName(), getSetDescriptor); - break; - default: - if (LOGGER.isLoggable(Level.SEVERE)) { - LOGGER.severe(PythonUtils.formatJString("unknown definition kind: %d", kind)); - } - assert false; - } - - if (property != null) { - property.write(inliningTarget, writePropertyNode, readPropertyNode, newType); - } - } - } - - /* - * Enforce constraint that we cannot have slot 'HPy_tp_call' and an explicit member - * '__vectorcalloffset__'. - */ - if (newType.getHPyVectorcallOffset() != Long.MIN_VALUE && newType.getHPyDefaultCallFunc() != null) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_HAVE_CALL_AND_VECTORCALLOFFSET); - } - - if (needsTpTraverse) { - throw raiseNode.raise(inliningTarget, ValueError, ErrorMessages.TRAVERSE_FUNCTION_NEEDED); - } - - // process legacy slots; this is of type 'cpy_PyTypeSlot legacy_slots[]' - Object legacySlotsArrPtr = readPointerNode.read(context, typeSpec, GraalHPyCField.HPyType_Spec__legacy_slots); - if (!isNullNode.execute(context, legacySlotsArrPtr)) { - if (builtinShape != GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.HPY_CANNOT_SPECIFY_LEG_SLOTS_WO_SETTING_LEG); - } - for (int i = 0;; i++) { - if (!createLegacySlotNode.execute(context, newType, tpSlotsBuilder, legacySlotsArrPtr, i)) { - break; - } - } - } - - // These are the slots for the type we are creating as specified by the user: - TpSlots newSlots = tpSlotsBuilder.build(); - // Slots inheritance: - newType.setTpSlots(newType.getTpSlots().copy().overrideIgnoreGroups(newSlots).build()); - // Create descriptors wrapping the slots, but only the new slots: - newSlots.addOperators(newType); - TpSlots.fixupSlotDispatchers(newType); - - /* - * If 'basicsize > 0' and no explicit constructor is given, the constructor of the - * object needs to allocate the native space for the object. However, the inherited - * constructors won't do that. Also, if the default call function needs to be set - * (i.e. 'HPy_tp_call' was defined), an inherited constructor won't do it. - * - * The built-in shape determines the "native" shape of the object which means that - * it determines which Java object we need to allocate (e.g. PInt, PythonObject, - * PFloat, etc.). - */ - Object baseClass = getBaseClassNode.execute(inliningTarget, newType); - if (!seenNew && (basicSize > 0 || newType.getHPyDefaultCallFunc() != null)) { - - /* - * TODO(fa): we could do some shortcut if 'baseClass == PythonObject' and use - * 'inheritedConstruct = null' but that needs to be considered in the decorating - * new as well - */ - // Lookup the inherited constructor and pass it to the HPy decorator. - Object inheritedConstructor = lookupNewNode.execute(baseClass, T___NEW__); - PBuiltinFunction constructorDecorator = HPyObjectNewNode.createBuiltinFunction(language, inheritedConstructor, builtinShape); - writeAttributeToObjectNode.execute(newType, T___NEW__, constructorDecorator); - } - - long baseFlags; - if (baseClass instanceof PythonClass pythonBaseClass) { - baseFlags = pythonBaseClass.getFlags(); - } else { - baseFlags = 0; - } - int baseBuiltinShape = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(baseClass); - checkInheritanceConstraints(inliningTarget, flags, baseFlags, builtinShape, baseBuiltinShape > GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY, raiseNode); - return newType; - } catch (CannotCastException e) { - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.COULD_NOT_CREATE_TYPE_FROM_SPEC_BECAUSE, e); - } - } - - /** - * Read the array of {@code HPyType_SpecParam} and convert to a Java array of - * {@link HPyTypeSpecParam}. - * - *
    -         *     typedef struct {
    -         *         HPyType_SpecParam_Kind kind;
    -         *         HPy object;
    -         *     } HPyType_SpecParam;
    -         * 
    - */ - @TruffleBoundary - private static HPyTypeSpecParam[] extractTypeSpecParams(GraalHPyContext context, Object typeSpecParamArray) { - - // if the pointer is NULL, no bases have been explicitly specified - if (GraalHPyCAccess.IsNullNode.executeUncached(context, typeSpecParamArray)) { - return null; - } - - GraalHPyCAccess.ReadI32Node readI32Node = GraalHPyCAccess.ReadI32Node.getUncached(context); - GraalHPyCAccess.ReadHPyNode readHPyNode = GraalHPyCAccess.ReadHPyNode.getUncached(context); - - long specParamSize = context.getCTypeSize(HPyContextSignatureType.HPyType_SpecParam); - - List specParams = new LinkedList<>(); - for (int i = 0;; i++) { - long specParamKindOffset = ReadHPyNode.getElementPtr(context, i, specParamSize, GraalHPyCField.HPyType_SpecParam__kind); - int specParamKind = readI32Node.readOffset(context, typeSpecParamArray, specParamKindOffset); - if (specParamKind == 0) { - break; - } - long specParamObjectOffset = ReadHPyNode.getElementPtr(context, i, specParamSize, GraalHPyCField.HPyType_SpecParam__object); - Object specParamObject = readHPyNode.read(context, typeSpecParamArray, specParamObjectOffset); - - specParams.add(new HPyTypeSpecParam(specParamKind, specParamObject)); - } - return specParams.toArray(new HPyTypeSpecParam[0]); - } - - /** - * Extract bases from the array of type spec params. Reference implementation can be found - * in {@code ctx_type.c:build_bases_from_params}. - * - * @return The bases tuple or {@code null} in case of an error. - */ - @TruffleBoundary - private static PTuple extractBases(HPyTypeSpecParam[] typeSpecParams, PythonLanguage language) { - - // if there are no type spec params, no bases have been explicitly specified - if (typeSpecParams == null) { - return PFactory.createEmptyTuple(language); - } - - ArrayList basesList = new ArrayList<>(); - for (HPyTypeSpecParam typeSpecParam : typeSpecParams) { - switch (typeSpecParam.kind()) { - case GraalHPyDef.HPyType_SPEC_PARAM_BASE: - // In this case, the 'specParamObject' is a single handle. We add it to - // the list of bases. - assert PGuards.isClassUncached(typeSpecParam.object()) : "base object is not a Python class"; - basesList.add(typeSpecParam.object()); - break; - case GraalHPyDef.HPyType_SPEC_PARAM_BASES_TUPLE: - // In this case, the 'specParamObject' is tuple. According to the - // reference implementation, we immediately use this tuple and throw - // away any other single base classes or subsequent params. - assert PGuards.isPTuple(typeSpecParam.object()) : "type spec param claims to be a tuple but isn't"; - return (PTuple) typeSpecParam.object(); - case GraalHPyDef.HPyType_SPEC_PARAM_METACLASS: - // intentionally ignored - break; - default: - assert false : "unknown type spec param kind"; - } - } - return PFactory.createTuple(language, basesList.toArray()); - } - - /** - * Reference implementation can be found in {@code ctx_type.c:get_metatype} - */ - @TruffleBoundary - private static Object getMetatype(Node inliningTarget, HPyTypeSpecParam[] typeSpecParams) { - Object result = null; - if (typeSpecParams != null) { - for (HPyTypeSpecParam typeSpecParam : typeSpecParams) { - if (typeSpecParam.kind() == GraalHPyDef.HPyType_SPEC_PARAM_METACLASS) { - if (result != null) { - throw PRaiseNode.raiseStatic(inliningTarget, ValueError, ErrorMessages.HPY_METACLASS_SPECIFIED_MULTIPLE_TIMES); - } - result = typeSpecParam.object(); - if (!IsTypeNode.executeUncached(result)) { - throw PRaiseNode.raiseStatic(inliningTarget, TypeError, ErrorMessages.HPY_METACLASS_IS_NOT_A_TYPE, result); - } - } - } - } - return result; - } - - private static void checkInheritanceConstraints(Node inliningTarget, long flags, long baseFlags, int builtinShape, boolean baseIsPure, PRaiseNode raiseNode) { - // Pure types may inherit from: - // - // * pure types, or - // * PyBaseObject_Type, or - // * other builtin or legacy types as long as as they do not - // access the struct layout (e.g. by using HPy_AsStruct or defining - // a deallocator with HPy_tp_destroy). - // - // It would be nice to relax these restrictions or check them here. - // See https://github.com/hpyproject/hpy/issues/169 for details. - assert GraalHPyDef.isValidBuiltinShape(builtinShape); - if (builtinShape == GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY && baseIsPure) { - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.LEG_TYPE_SHOULDNT_INHERIT_MEM_LAYOUT_FROM_PURE_TYPE); - } - } - } - - /** - * Extract the heap type's and the module's name from the name given by the type - * specification.
    - * According to CPython, we need to look for the last {@code '.'} and everything before it - * (which may also contain more dots) is the module name. Everything after it is the type name. - * See also: {@code typeobject.c: PyType_FromSpecWithBases} - */ - @GenerateUncached - @GenerateInline - @GenerateCached(false) - abstract static class HPyTypeSplitNameNode extends Node { - - public abstract TruffleString[] execute(Node inliningTarget, TruffleString tpName); - - @Specialization - static TruffleString[] doGeneric(TruffleString specNameUtf8, - @Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached(inline = false) TruffleString.LastIndexOfCodePointNode indexOfCodepointNode, - @Cached(inline = false) TruffleString.SubstringNode substringNode, - @Cached(inline = false) TruffleString.CodePointLengthNode lengthNode) { - TruffleString specName = switchEncodingNode.execute(specNameUtf8, TS_ENCODING); - int length = lengthNode.execute(specName, TS_ENCODING); - int firstDotIdx = indexOfCodepointNode.execute(specName, '.', length, 0, TS_ENCODING); - if (firstDotIdx > -1) { - TruffleString left = substringNode.execute(specName, 0, firstDotIdx, TS_ENCODING, false); - TruffleString right = substringNode.execute(specName, firstDotIdx + 1, length - firstDotIdx - 1, TS_ENCODING, false); - return new TruffleString[]{left, right}; - } - return new TruffleString[]{null, specName}; - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyTypeGetNameNode extends Node { - - public static Object executeUncached(GraalHPyContext ctx, Object object) { - return HPyTypeGetNameNodeGen.getUncached().execute(null, ctx, object); - } - - public abstract Object execute(Node inliningTarget, GraalHPyContext ctx, Object object); - - @Specialization(guards = "tpName != null") - static Object doTpName(@SuppressWarnings("unused") GraalHPyContext ctx, @SuppressWarnings("unused") PythonClass clazz, - @Bind("clazz.getTpName()") Object tpName) { - return tpName; - } - - @Specialization(replaces = "doTpName") - static Object doGeneric(Node inliningTarget, GraalHPyContext ctx, Object type, - @Cached GetNameNode getName, - @Cached(parameters = "ctx", inline = false) HPyAsCharPointerNode asCharPointerNode) { - if (type instanceof PythonClass pythonClass && pythonClass.getTpName() != null) { - return pythonClass.getTpName(); - } - TruffleString baseName = getName.execute(inliningTarget, type); - return asCharPointerNode.execute(ctx, baseName, Encoding.UTF_8); - } - } - - @GenerateInline(inlineByDefault = true) - @GenerateCached - @GenerateUncached - @ImportStatic(PGuards.class) - public abstract static class HPyGetNativeSpacePointerNode extends Node { - - public abstract Object execute(Node inliningTarget, Object object); - - public final Object executeCached(Object object) { - return execute(this, object); - } - - public static Object executeUncached(Object object) { - return HPyGetNativeSpacePointerNodeGen.getUncached().execute(null, object); - } - - @Specialization - static Object doPythonObject(PythonObject object) { - return GraalHPyData.getHPyNativeSpace(object); - } - - @Fallback - static Object doOther(Node inliningTarget, @SuppressWarnings("unused") Object object) { - // TODO(fa): this should be a backend-specific value - return PythonContext.get(inliningTarget).getNativeNull(); - } - } - - public abstract static class HPyAttachFunctionTypeNode extends PNodeWithContext { - public abstract Object execute(GraalHPyContext hpyContext, Object pointerObject, LLVMType llvmFunctionType); - - @NeverDefault - public static HPyAttachFunctionTypeNode create() { - PythonLanguage language = PythonLanguage.get(null); - switch (language.getEngineOption(PythonOptions.HPyBackend)) { - case JNI: - if (!PythonImageBuildOptions.WITHOUT_JNI) { - return HPyAttachJNIFunctionTypeNodeGen.create(); - } - throw CompilerDirectives.shouldNotReachHere(); - case LLVM: - return HPyLLVMAttachFunctionTypeNode.UNCACHED; - case NFI: - return HPyAttachNFIFunctionTypeNodeGen.create(); - } - throw CompilerDirectives.shouldNotReachHere(); - } - - public static HPyAttachFunctionTypeNode getUncached() { - PythonLanguage language = PythonLanguage.get(null); - switch (language.getEngineOption(PythonOptions.HPyBackend)) { - case JNI: - if (!PythonImageBuildOptions.WITHOUT_JNI) { - return HPyAttachJNIFunctionTypeNodeGen.getUncached(); - } - throw CompilerDirectives.shouldNotReachHere(); - case LLVM: - return HPyLLVMAttachFunctionTypeNode.UNCACHED; - case NFI: - return HPyAttachNFIFunctionTypeNodeGen.getUncached(); - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - /** - * This node can be used to attach a function type to a function pointer if the function pointer - * is not executable, i.e., if - * {@code InteropLibrary.getUncached().isExecutable(functionPointer) == false}. This should not - * be necessary if running bitcode because Sulong should then know if a pointer is a function - * pointer but it might be necessary if a library was loaded with NFI since no bitcode is - * available. The node will return a typed function pointer that is then executable. - */ - @GenerateUncached - @GenerateInline(false) - public abstract static class HPyAttachNFIFunctionTypeNode extends HPyAttachFunctionTypeNode { - private static final String J_NFI_LANGUAGE = "nfi"; - - @Specialization(guards = {"isSingleContext()", "llvmFunctionType == cachedType"}, limit = "3") - static Object doCachedSingleContext(@SuppressWarnings("unused") GraalHPyContext hpyContext, Object pointerObject, @SuppressWarnings("unused") LLVMType llvmFunctionType, - @Cached("llvmFunctionType") @SuppressWarnings("unused") LLVMType cachedType, - @Cached("getNFISignature(hpyContext, llvmFunctionType)") Object nfiSignature, - @CachedLibrary("nfiSignature") SignatureLibrary signatureLibrary) { - return signatureLibrary.bind(nfiSignature, pointerObject); - } - - @Specialization(guards = "llvmFunctionType == cachedType", limit = "3", replaces = "doCachedSingleContext") - static Object doCached(@SuppressWarnings("unused") GraalHPyContext hpyContext, Object pointerObject, @SuppressWarnings("unused") LLVMType llvmFunctionType, - @Cached("llvmFunctionType") @SuppressWarnings("unused") LLVMType cachedType, - @Cached("getNFISignatureCallTarget(hpyContext, llvmFunctionType)") CallTarget nfiSignatureCt, - @Shared @CachedLibrary(limit = "1") SignatureLibrary signatureLibrary) { - return signatureLibrary.bind(nfiSignatureCt.call(), pointerObject); - } - - @Specialization(replaces = {"doCachedSingleContext", "doCached"}) - static Object doGeneric(GraalHPyContext hpyContext, Object pointerObject, LLVMType llvmFunctionType, - @Shared @CachedLibrary(limit = "1") SignatureLibrary signatureLibrary) { - return signatureLibrary.bind(getNFISignature(hpyContext, llvmFunctionType), pointerObject); - } - - @TruffleBoundary - static Object getNFISignature(GraalHPyContext hpyContext, LLVMType llvmFunctionType) { - return hpyContext.getContext().getEnv().parseInternal(getNFISignatureSource(llvmFunctionType)).call(); - } - - @TruffleBoundary - static CallTarget getNFISignatureCallTarget(GraalHPyContext hpyContext, LLVMType llvmFunctionType) { - return hpyContext.getContext().getEnv().parseInternal(getNFISignatureSource(llvmFunctionType)); - } - - @TruffleBoundary - static Source getNFISignatureSource(LLVMType llvmFunctionType) { - return Source.newBuilder(J_NFI_LANGUAGE, getNFISignatureSourceString(llvmFunctionType), llvmFunctionType.name()).build(); - } - - private static String getNFISignatureSourceString(LLVMType llvmFunctionType) { - switch (llvmFunctionType) { - case HPyModule_init: - return "(POINTER): POINTER"; - case HPyFunc_noargs: - case HPyFunc_unaryfunc: - case HPyFunc_getiterfunc: - case HPyFunc_iternextfunc: - case HPyFunc_reprfunc: - return "(POINTER, POINTER): POINTER"; - case HPyFunc_binaryfunc: - case HPyFunc_o: - case HPyFunc_getter: - case HPyFunc_getattrfunc: - case HPyFunc_getattrofunc: - return "(POINTER, POINTER, POINTER): POINTER"; - case HPyFunc_varargs: - return "(POINTER, POINTER, POINTER, SINT64): POINTER"; - case HPyFunc_keywords: - return "(POINTER, POINTER, POINTER, SINT64, POINTER): POINTER"; - case HPyFunc_ternaryfunc: - case HPyFunc_descrgetfunc: - return "(POINTER, POINTER, POINTER, POINTER): POINTER"; - case HPyFunc_inquiry: - return "(POINTER, POINTER): SINT32"; - case HPyFunc_lenfunc: - case HPyFunc_hashfunc: - return "(POINTER, POINTER): SINT64"; - case HPyFunc_ssizeargfunc: - return "(POINTER, POINTER, SINT64): POINTER"; - case HPyFunc_ssizessizeargfunc: - return "(POINTER, POINTER, SINT64, SINT64): POINTER"; - case HPyFunc_ssizeobjargproc: - return "(POINTER, POINTER, SINT64, POINTER): SINT32"; - case HPyFunc_initproc: - return "(POINTER, POINTER, POINTER, SINT64, POINTER): SINT32"; - case HPyFunc_ssizessizeobjargproc: - return "(POINTER, POINTER, SINT64, SINT64, POINTER): SINT32"; - case HPyFunc_objobjargproc: - case HPyFunc_setter: - case HPyFunc_descrsetfunc: - case HPyFunc_setattrfunc: - case HPyFunc_setattrofunc: - return "(POINTER, POINTER, POINTER, POINTER): SINT32"; - case HPyFunc_freefunc: - return "(POINTER, POINTER): VOID"; - case HPyFunc_richcmpfunc: - return "(POINTER, POINTER, POINTER, SINT32): POINTER"; - case HPyFunc_objobjproc: - return "(POINTER, POINTER, POINTER): SINT32"; - case HPyFunc_getbufferproc: - return "(POINTER, POINTER, POINTER, SINT32): SINT32"; - case HPyFunc_releasebufferproc: - return "(POINTER, POINTER, POINTER): VOID"; - case HPyFunc_traverseproc: - return "(POINTER, POINTER, POINTER): SINT32"; - case HPyFunc_destroyfunc: - return "(POINTER): VOID"; - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - /** - */ - @GenerateUncached - @GenerateInline(false) - public abstract static class HPyAttachJNIFunctionTypeNode extends HPyAttachFunctionTypeNode { - - @Specialization - static GraalHPyJNIFunctionPointer doLong(GraalHPyContext hpyContext, long pointer, LLVMType llvmFunctionType) { - return new GraalHPyJNIFunctionPointer(pointer, llvmFunctionType, hpyContext.getCurrentMode()); - } - - @Specialization - static GraalHPyJNIFunctionPointer doGeneric(GraalHPyContext hpyContext, Object pointerObject, LLVMType llvmFunctionType, - @CachedLibrary(limit = "1") InteropLibrary interopLibrary) { - long pointer; - if (pointerObject instanceof Long pointerLong) { - pointer = pointerLong; - } else { - if (!interopLibrary.isPointer(pointerObject)) { - interopLibrary.toNative(pointerObject); - } - try { - pointer = interopLibrary.asPointer(pointerObject); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - return new GraalHPyJNIFunctionPointer(pointer, llvmFunctionType, hpyContext.getCurrentMode()); - } - } - - public static final class HPyLLVMAttachFunctionTypeNode extends HPyAttachFunctionTypeNode { - - private static final HPyLLVMAttachFunctionTypeNode UNCACHED = new HPyLLVMAttachFunctionTypeNode(); - - @Override - public Object execute(GraalHPyContext hpyContext, Object pointerObject, LLVMType llvmFunctionType) { - assert InteropLibrary.getUncached().isExecutable(pointerObject); - return pointerObject; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - protected static Object callBuiltinFunction(GraalHPyContext graalHPyContext, TruffleString func, Object[] pythonArguments, - ReadAttributeFromObjectNode readAttr, - CallNode callNode) { - Object builtinFunction = readAttr.execute(graalHPyContext.getContext().getBuiltins(), func); - return callNode.executeWithoutFrame(builtinFunction, pythonArguments, PKeyword.EMPTY_KEYWORDS); - } - - @ImportStatic(PGuards.class) - @GenerateUncached - @GenerateInline(false) // footprint reduction 60 -> 41 - public abstract static class RecursiveExceptionMatches extends Node { - abstract int execute(GraalHPyContext context, Object err, Object exc); - - @Specialization - static int tuple(GraalHPyContext context, Object err, PTuple exc, - @Bind("this") Node inliningTarget, - @Shared @Cached RecursiveExceptionMatches recExcMatch, - @Exclusive @Cached PyObjectGetItem getItemNode, - @Exclusive @Cached InlinedLoopConditionProfile loopProfile) { - int len = exc.getSequenceStorage().length(); - for (int i = 0; loopProfile.profile(inliningTarget, i < len); i++) { - Object e = getItemNode.execute(null, inliningTarget, exc, i); - if (recExcMatch.execute(context, err, e) != 0) { - return 1; - } - } - return 0; - } - - @Specialization(guards = {"!isPTuple(exc)", "isTupleSubtype(inliningTarget, exc, getClassNode, isSubtypeNode)"}, limit = "1") - static int subtuple(GraalHPyContext context, Object err, Object exc, - @Bind("this") Node inliningTarget, - @Shared @Cached RecursiveExceptionMatches recExcMatch, - @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, - @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached ReadAttributeFromObjectNode readAttr, - @Shared @Cached CallNode callNode, - @Cached CastToJavaIntExactNode cast, - @Exclusive @Cached PyObjectGetItem getItemNode, - @Exclusive @Cached InlinedLoopConditionProfile loopProfile) { - int len = cast.execute(inliningTarget, callBuiltinFunction(context, BuiltinNames.T_LEN, new Object[]{exc}, readAttr, callNode)); - for (int i = 0; loopProfile.profile(inliningTarget, i < len); i++) { - Object e = getItemNode.execute(null, inliningTarget, exc, i); - if (recExcMatch.execute(context, err, e) != 0) { - return 1; - } - } - return 0; - } - - @Specialization(guards = {"!isPTuple(exc)", "!isTupleSubtype(inliningTarget, exc, getClassNode, isSubtypeNode)"}, limit = "1") - static int others(GraalHPyContext context, Object err, Object exc, - @Bind("this") Node inliningTarget, - @Exclusive @Cached GetClassNode getClassNode, - @SuppressWarnings("unused") @Shared @Cached IsSubtypeNode isSubtypeNode, - @Shared @Cached ReadAttributeFromObjectNode readAttr, - @Shared @Cached CallNode callNode, - @Cached PyObjectIsTrueNode isTrueNode, - @Cached IsTypeNode isTypeNode, - @Cached IsNode isNode, - @Cached InlinedBranchProfile isBaseExceptionProfile, - @Cached InlinedConditionProfile isExceptionProfile) { - Object isInstance = callBuiltinFunction(context, - BuiltinNames.T_ISINSTANCE, - new Object[]{err, PythonBuiltinClassType.PBaseException}, - readAttr, callNode); - Object e = err; - if (isTrueNode.execute(null, isInstance)) { - isBaseExceptionProfile.enter(inliningTarget); - e = getClassNode.execute(inliningTarget, err); - } - if (isExceptionProfile.profile(inliningTarget, - isExceptionClass(context, inliningTarget, e, isTypeNode, readAttr, callNode, isTrueNode) && - isExceptionClass(context, inliningTarget, exc, isTypeNode, readAttr, callNode, isTrueNode))) { - return isSubClass(context, e, exc, readAttr, callNode, isTrueNode) ? 1 : 0; - } else { - return isNode.execute(exc, e) ? 1 : 0; - } - } - - protected boolean isTupleSubtype(Node inliningTarget, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) { - return isSubtypeNode.execute(getClassNode.execute(inliningTarget, obj), PythonBuiltinClassType.PTuple); - } - - static boolean isSubClass(GraalHPyContext graalHPyContext, Object derived, Object cls, - ReadAttributeFromObjectNode readAttr, - CallNode callNode, - PyObjectIsTrueNode isTrueNode) { - return isTrueNode.execute(null, callBuiltinFunction(graalHPyContext, - BuiltinNames.T_ISSUBCLASS, - new Object[]{derived, cls}, readAttr, callNode)); - - } - - private static boolean isExceptionClass(GraalHPyContext nativeContext, Node inliningTarget, Object obj, - IsTypeNode isTypeNode, - ReadAttributeFromObjectNode readAttr, - CallNode callNode, - PyObjectIsTrueNode isTrueNode) { - return isTypeNode.execute(inliningTarget, obj) && isSubClass(nativeContext, obj, PythonBuiltinClassType.PBaseException, readAttr, callNode, isTrueNode); - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyPackKeywordArgsNode extends Node { - - public abstract PKeyword[] execute(Node inliningTarget, Object[] kwvalues, PTuple kwnames, int nkw); - - @Specialization - static PKeyword[] doPTuple(Node inliningTarget, Object[] kwvalues, PTuple kwnames, int nkw, - @Cached SequenceStorageNodes.GetItemScalarNode getItemNode, - @Cached InlinedLoopConditionProfile loopProfile) { - loopProfile.profileCounted(inliningTarget, nkw); - if (nkw == 0) { - return PKeyword.EMPTY_KEYWORDS; - } - PKeyword[] result = new PKeyword[nkw]; - SequenceStorage storage = kwnames.getSequenceStorage(); - for (int i = 0; loopProfile.inject(inliningTarget, i < nkw); i++) { - TruffleString name = (TruffleString) getItemNode.execute(inliningTarget, storage, i); - result[i] = new PKeyword(name, kwvalues[i]); - } - return result; - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyFieldLoadNode extends Node { - - public abstract Object execute(Node inliningTarget, PythonObject owner, Object hpyFieldPtr); - - @Specialization - static Object doHandle(@SuppressWarnings("unused") PythonObject owner, GraalHPyHandle handle) { - return handle.getDelegate(); - } - - @Specialization(replaces = "doHandle") - static Object doGeneric(Node inliningTarget, PythonObject owner, Object hpyFieldPtr, - @CachedLibrary(limit = "3") InteropLibrary lib, - @Cached InlinedExactClassProfile fieldTypeProfile) { - Object hpyFieldObject = fieldTypeProfile.profile(inliningTarget, hpyFieldPtr); - Object referent; - // avoid `asPointer` message dispatch - if (hpyFieldObject instanceof GraalHPyHandle) { - referent = ((GraalHPyHandle) hpyFieldObject).getDelegate(); - } else { - int idx; - if (hpyFieldObject instanceof Long) { - // branch profile in lib.asPointer - try { - idx = PInt.intValueExact((Long) hpyFieldObject); - } catch (OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } else { - try { - idx = PInt.intValueExact(lib.asPointer(hpyFieldObject)); - } catch (InteropException | OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - if (idx == 0) { - return NULL_HANDLE_DELEGATE; - } - referent = GraalHPyData.getHPyField(owner, idx); - } - return referent; - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyFieldStoreNode extends Node { - - public abstract int execute(Node inliningTarget, PythonObject owner, Object hpyFieldObject, Object referent); - - @Specialization - static int doHandle(Node inliningTarget, @SuppressWarnings("unused") PythonObject owner, GraalHPyHandle hpyFieldObject, Object referent, - @Shared @Cached InlinedConditionProfile nullHandleProfile) { - int idx = hpyFieldObject.getFieldId(); - if (nullHandleProfile.profile(inliningTarget, referent == NULL_HANDLE_DELEGATE && idx == 0)) { - // assigning HPy_NULL to a field that already holds HPy_NULL, nothing to do - return 0; - } else { - return GraalHPyData.setHPyField(owner, referent, idx); - } - } - - @Specialization(replaces = "doHandle") - static int doGeneric(Node inliningTarget, PythonObject owner, Object hpyFieldObject, Object referent, - @CachedLibrary(limit = "3") InteropLibrary lib, - @Shared @Cached InlinedConditionProfile nullHandleProfile) { - int idx; - if (lib.isNull(hpyFieldObject)) { // uninitialized - idx = 0; - } else if (hpyFieldObject instanceof GraalHPyHandle) { - // avoid `asPointer` message dispatch - idx = ((GraalHPyHandle) hpyFieldObject).getFieldId(); - } else { - if (hpyFieldObject instanceof Long) { - // branch profile in lib.asPointer - try { - idx = PInt.intValueExact((Long) hpyFieldObject); - } catch (OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } else { - try { - idx = PInt.intValueExact(lib.asPointer(hpyFieldObject)); - } catch (InteropException | OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - } - // TODO: (tfel) do not actually allocate the index / free the existing one when - // value can be stored as tagged handle - if (nullHandleProfile.profile(inliningTarget, referent == NULL_HANDLE_DELEGATE && idx == 0)) { - // assigning HPy_NULL to a field that already holds HPy_NULL, nothing to do - } else { - idx = GraalHPyData.setHPyField(owner, referent, idx); - } - return idx; - } - } - - /** - * Parses an {@code HPyCallFunction} structure and returns the {@code impl} function pointer. A - * {@code NULL} pointer will be translated to Java {@code null}. - * - *
    -     * typedef struct {
    -     *     cpy_vectorcallfunc cpy_trampoline;
    -     *     HPyFunc_keywords impl;
    -     * } HPyCallFunction;
    -     * 
    - */ - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyReadCallFunctionNode extends PNodeWithContext { - - public abstract Object execute(Node inliningTarget, GraalHPyContext context, Object def); - - @Specialization - static Object doIt(GraalHPyContext context, Object def, - @Cached(parameters = "context", inline = false) GraalHPyCAccess.ReadPointerNode readPointerNode, - @Cached(parameters = "context", inline = false) GraalHPyCAccess.IsNullNode isNullNode, - @Cached(inline = false) HPyAttachFunctionTypeNode attachFunctionTypeNode) { - // read and check the function pointer - Object methodFunctionPointer = readPointerNode.read(context, def, GraalHPyCField.HPyCallFunction__impl); - if (isNullNode.execute(context, methodFunctionPointer)) { - return null; - } - HPySlotWrapper slotWrapper = HPY_TP_CALL.getSignatures()[0]; - return attachFunctionTypeNode.execute(context, methodFunctionPointer, slotWrapper.getLLVMFunctionType()); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java deleted file mode 100644 index 3a196bd0bf..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyObjectBuiltins.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (c) 2021, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.util.PythonUtils.tsArray; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.util.logging.Level; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.cext.common.CExtContext; -import com.oracle.graal.python.builtins.objects.floats.PFloat; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.str.PString; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.nodes.PRootNode; -import com.oracle.graal.python.nodes.SpecialMethodNames; -import com.oracle.graal.python.nodes.argument.ReadIndexedArgumentNode; -import com.oracle.graal.python.nodes.argument.ReadVarArgsNode; -import com.oracle.graal.python.nodes.argument.ReadVarKeywordsNode; -import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.strings.TruffleString; - -public abstract class GraalHPyObjectBuiltins { - - public static final class HPyObjectNewNode extends PRootNode { - private static final TruffleString KW_SUPERCONS = tsLiteral("$supercons"); - private static final TruffleString[] KEYWORDS_HIDDEN_SUPERCONS = {KW_SUPERCONS}; - - private static final Signature SIGNATURE = new Signature(-1, true, 1, tsArray("self"), KEYWORDS_HIDDEN_SUPERCONS, false); - - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(HPyObjectNewNode.class); - - private static PKeyword[] createKwDefaults(Object superConstructor) { - if (superConstructor != null) { - return new PKeyword[]{new PKeyword(KW_SUPERCONS, superConstructor)}; - } - return PKeyword.EMPTY_KEYWORDS; - } - - @Child private CalleeContext calleeContext; - @Child private ReadIndexedArgumentNode readSelfNode; - @Child private ReadVarArgsNode readVarargsNode; - @Child private ReadVarKeywordsNode readKwargsNode; - @Child private ReadIndexedArgumentNode readCallableNode; - @Child private GraalHPyCAccess.AllocateNode allocateNode; - @Child private CallNode callNewNode; - - private final int builtinShape; - - private HPyObjectNewNode(PythonLanguage language, int builtinShape) { - super(language); - this.builtinShape = builtinShape; - } - - @Override - public Object execute(VirtualFrame frame) { - getCalleeContext().enter(frame); - try { - return doCall(frame, getSuperConstructor(frame), getSelf(frame), getVarargs(frame), getKwargs(frame)); - } finally { - getCalleeContext().exit(frame, this); - } - } - - private Object doCall(VirtualFrame frame, Object superConstructor, Object explicitSelf, Object[] arguments, PKeyword[] keywords) { - assert explicitSelf != null; - - // create the managed Python object - - // delegate to the best base's constructor - Object self; - Object[] argsWithSelf; - if (explicitSelf == PNone.NO_VALUE) { - argsWithSelf = arguments; - self = argsWithSelf[0]; - } else { - argsWithSelf = new Object[arguments.length + 1]; - argsWithSelf[0] = explicitSelf; - PythonUtils.arraycopy(arguments, 0, argsWithSelf, 1, arguments.length); - self = explicitSelf; - } - PythonContext context = PythonContext.get(this); - Object dataPtr = null; - Object defaultCallFunction = null; - if (self instanceof PythonClass pythonClass) { - // allocate native space - long basicSize = pythonClass.getBasicSize(); - if (basicSize > 0) { - /* - * This is just calling 'calloc' which is a pure helper function. Therefore, we - * can take any HPy context and don't need to attach a context to this __new__ - * function for that since the helper function won't deal with handles. - */ - GraalHPyContext hpyContext = context.getHPyContext(); - dataPtr = ensureAllocateNode(hpyContext).calloc(hpyContext, 1L, basicSize); - - if (LOGGER.isLoggable(Level.FINEST)) { - LOGGER.finest(PythonUtils.formatJString("Allocated HPy object with native space of size %d at %s", basicSize, dataPtr)); - } - } - - defaultCallFunction = pythonClass.getHPyDefaultCallFunc(); - } - - Object result = ensureCallNewNode().execute(frame, superConstructor, argsWithSelf, keywords); - assert validateSuperConstructorResult(result, builtinShape); - - /* - * Since we are creating an object with an unknown constructor, the Java type may be - * anything (e.g. PInt, etc). However, we require it to be a PythonObject otherwise we - * don't know where to store the native data pointer. - */ - if (result instanceof PythonObject pythonObject) { - if (dataPtr != null) { - GraalHPyData.setHPyNativeSpace(pythonObject, dataPtr); - } - if (defaultCallFunction != null) { - GraalHPyData.setHPyCallFunction(pythonObject, defaultCallFunction); - } - } else { - assert false : "inherited constructor of HPy type did not create a managed Python object"; - } - return result; - } - - private static boolean validateSuperConstructorResult(Object result, int builtinShape) { - return switch (builtinShape) { - case GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY, GraalHPyDef.HPyType_BUILTIN_SHAPE_OBJECT -> result instanceof PythonObject; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_TYPE -> result instanceof PythonClass; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_LONG -> result instanceof PInt; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_FLOAT -> result instanceof PFloat; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_UNICODE -> result instanceof PString; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_TUPLE -> result instanceof PTuple; - case GraalHPyDef.HPyType_BUILTIN_SHAPE_LIST -> result instanceof PList; - default -> false; - }; - } - - private Object getSelf(VirtualFrame frame) { - if (readSelfNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readSelfNode = insert(ReadIndexedArgumentNode.create(0)); - } - return readSelfNode.execute(frame); - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - private PKeyword[] getKwargs(VirtualFrame frame) { - if (PArguments.getKeywordArguments(frame).length == 0) { - return PKeyword.EMPTY_KEYWORDS; - } - if (readKwargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readKwargsNode = insert(ReadVarKeywordsNode.create()); - } - return (PKeyword[]) readKwargsNode.execute(frame); - } - - private Object getSuperConstructor(VirtualFrame frame) { - if (readCallableNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden argument at the end of the positional arguments - int hiddenArg = getSignature().getParameterIds().length; - readCallableNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - return readCallableNode.execute(frame); - } - - private CalleeContext getCalleeContext() { - if (calleeContext == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - calleeContext = insert(CalleeContext.create()); - } - return calleeContext; - } - - private static Object extractInheritedConstructor(PythonContext context, PKeyword[] keywords) { - for (int i = 0; i < keywords.length; i++) { - if (keywords[i].getName() == KW_SUPERCONS) { - return keywords[i].getValue(); - } - } - return context.lookupType(PythonBuiltinClassType.PythonObject).getAttribute(SpecialMethodNames.T___NEW__); - } - - private GraalHPyCAccess.AllocateNode ensureAllocateNode(GraalHPyContext ctx) { - if (allocateNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - allocateNode = insert(GraalHPyCAccess.AllocateNode.create(ctx)); - } - return allocateNode; - } - - private CallNode ensureCallNewNode() { - if (callNewNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - callNewNode = insert(CallNode.create()); - } - return callNewNode; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - - @Override - public boolean isPythonInternal() { - return true; - } - - @Override - public boolean setsUpCalleeContext() { - return true; - } - - @TruffleBoundary - public static PBuiltinFunction createBuiltinFunction(PythonLanguage language, Object superConstructor, int builtinShape) { - // do not decorate the decorator - if (superConstructor instanceof PBuiltinFunction builtinFunction && isHPyObjectNewDecorator(builtinFunction)) { - return builtinFunction; - } - RootCallTarget callTarget = language.createCachedCallTarget(l -> new HPyObjectNewNode(language, builtinShape), HPyObjectNewNode.class, builtinShape); - int flags = CExtContext.METH_KEYWORDS | CExtContext.METH_VARARGS; - return PFactory.createBuiltinFunction(language, SpecialMethodNames.T___NEW__, null, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(superConstructor), flags, callTarget); - } - - public static Object getDecoratedSuperConstructor(PBuiltinFunction builtinFunction) { - if (isHPyObjectNewDecorator(builtinFunction)) { - return extractInheritedConstructor(PythonContext.get(null), builtinFunction.getKwDefaults()); - } - return null; - } - - private static boolean isHPyObjectNewDecorator(PBuiltinFunction builtinFunction) { - return builtinFunction.getFunctionRootNode() instanceof HPyObjectNewNode; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPySourceKind.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPySourceKind.java deleted file mode 100644 index 15ea21df24..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPySourceKind.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -import com.oracle.graal.python.nodes.StringLiterals; -import com.oracle.truffle.api.strings.TruffleString; - -public enum GraalHPySourceKind { - EXPR(0, StringLiterals.T_EVAL), - FILE(1, StringLiterals.T_EXEC), - SINGLE(2, StringLiterals.T_SINGLE); - - private final int value; - private final TruffleString mode; - - GraalHPySourceKind(int value, TruffleString mode) { - this.value = value; - this.mode = mode; - } - - public int getValue() { - return value; - } - - public TruffleString getMode() { - return mode; - } - - public static GraalHPySourceKind fromValue(int value) { - return switch (value) { - case 0 -> EXPR; - case 1 -> FILE; - case 2 -> SINGLE; - default -> null; - }; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyTracker.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyTracker.java deleted file mode 100644 index 2f151bdeb5..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyTracker.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021, 2023, 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.builtins.objects.cext.hpy; - -import java.util.Arrays; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseHandleNode; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.Node; - -public final class GraalHPyTracker { - private static final int HPYTRACKER_INITIAL_SIZE = 5; - - private GraalHPyHandle[] handles; - private int cursor; - - public GraalHPyTracker(int capacity) { - int size = capacity == 0 ? HPYTRACKER_INITIAL_SIZE : capacity; - this.handles = new GraalHPyHandle[size]; - } - - public void add(GraalHPyHandle h) throws OverflowException { - handles[cursor++] = h; - if (handles.length <= cursor) { - resize(); - } - } - - @TruffleBoundary - private void resize() throws OverflowException { - handles = Arrays.copyOf(handles, PythonUtils.multiplyExact(handles.length, 2) - 1); - } - - public void free(Node inliningTarget, HPyCloseHandleNode closeHandleNode) { - assert cursor <= handles.length; - for (int i = 0; i < cursor; i++) { - closeHandleNode.execute(inliningTarget, handles[i]); - } - cursor = 0; - } - - public void removeAll() { - for (int i = 0; i < handles.length; i++) { - handles[i] = null; - } - cursor = 0; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextMember.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextMember.java deleted file mode 100644 index 28dcf99fc7..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextMember.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Bool; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.CDouble; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.CVoid; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.ConstCharPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.ConstHPyPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.ConstWchar_tPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Cpy_PyObjectPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyCallFunctionPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyCapsule_DestructorPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyContextPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyField; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyFieldPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyGlobal; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyGlobalPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyListBuilder; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyThreadState; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyTracker; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyTupleBuilder; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyType_BuiltinShape; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyType_SpecParamPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPyType_SpecPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_SourceKind; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_UCS4; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_hash_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_ssize_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.HPy_ssize_tPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int32_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Int64_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Size_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Uint32_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.Uint64_t; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.VoidPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType.VoidPtrPtr; -import static com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType._HPyCapsule_key; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyUpcall; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; - -/** - * An enum of all fields currently available in the HPy context (see {@code public_api.h}). - */ -public enum HPyContextMember implements HPyUpcall { - NAME("name"), - PRIVATE("_private"), - ABI_VERSION("abi_version"), - - // {{start ctx members}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_member_enum - H_NONE("h_None"), - H_TRUE("h_True"), - H_FALSE("h_False"), - H_NOTIMPLEMENTED("h_NotImplemented"), - H_ELLIPSIS("h_Ellipsis"), - H_BASEEXCEPTION("h_BaseException"), - H_EXCEPTION("h_Exception"), - H_STOPASYNCITERATION("h_StopAsyncIteration"), - H_STOPITERATION("h_StopIteration"), - H_GENERATOREXIT("h_GeneratorExit"), - H_ARITHMETICERROR("h_ArithmeticError"), - H_LOOKUPERROR("h_LookupError"), - H_ASSERTIONERROR("h_AssertionError"), - H_ATTRIBUTEERROR("h_AttributeError"), - H_BUFFERERROR("h_BufferError"), - H_EOFERROR("h_EOFError"), - H_FLOATINGPOINTERROR("h_FloatingPointError"), - H_OSERROR("h_OSError"), - H_IMPORTERROR("h_ImportError"), - H_MODULENOTFOUNDERROR("h_ModuleNotFoundError"), - H_INDEXERROR("h_IndexError"), - H_KEYERROR("h_KeyError"), - H_KEYBOARDINTERRUPT("h_KeyboardInterrupt"), - H_MEMORYERROR("h_MemoryError"), - H_NAMEERROR("h_NameError"), - H_OVERFLOWERROR("h_OverflowError"), - H_RUNTIMEERROR("h_RuntimeError"), - H_RECURSIONERROR("h_RecursionError"), - H_NOTIMPLEMENTEDERROR("h_NotImplementedError"), - H_SYNTAXERROR("h_SyntaxError"), - H_INDENTATIONERROR("h_IndentationError"), - H_TABERROR("h_TabError"), - H_REFERENCEERROR("h_ReferenceError"), - H_SYSTEMERROR("h_SystemError"), - H_SYSTEMEXIT("h_SystemExit"), - H_TYPEERROR("h_TypeError"), - H_UNBOUNDLOCALERROR("h_UnboundLocalError"), - H_UNICODEERROR("h_UnicodeError"), - H_UNICODEENCODEERROR("h_UnicodeEncodeError"), - H_UNICODEDECODEERROR("h_UnicodeDecodeError"), - H_UNICODETRANSLATEERROR("h_UnicodeTranslateError"), - H_VALUEERROR("h_ValueError"), - H_ZERODIVISIONERROR("h_ZeroDivisionError"), - H_BLOCKINGIOERROR("h_BlockingIOError"), - H_BROKENPIPEERROR("h_BrokenPipeError"), - H_CHILDPROCESSERROR("h_ChildProcessError"), - H_CONNECTIONERROR("h_ConnectionError"), - H_CONNECTIONABORTEDERROR("h_ConnectionAbortedError"), - H_CONNECTIONREFUSEDERROR("h_ConnectionRefusedError"), - H_CONNECTIONRESETERROR("h_ConnectionResetError"), - H_FILEEXISTSERROR("h_FileExistsError"), - H_FILENOTFOUNDERROR("h_FileNotFoundError"), - H_INTERRUPTEDERROR("h_InterruptedError"), - H_ISADIRECTORYERROR("h_IsADirectoryError"), - H_NOTADIRECTORYERROR("h_NotADirectoryError"), - H_PERMISSIONERROR("h_PermissionError"), - H_PROCESSLOOKUPERROR("h_ProcessLookupError"), - H_TIMEOUTERROR("h_TimeoutError"), - H_WARNING("h_Warning"), - H_USERWARNING("h_UserWarning"), - H_DEPRECATIONWARNING("h_DeprecationWarning"), - H_PENDINGDEPRECATIONWARNING("h_PendingDeprecationWarning"), - H_SYNTAXWARNING("h_SyntaxWarning"), - H_RUNTIMEWARNING("h_RuntimeWarning"), - H_FUTUREWARNING("h_FutureWarning"), - H_IMPORTWARNING("h_ImportWarning"), - H_UNICODEWARNING("h_UnicodeWarning"), - H_BYTESWARNING("h_BytesWarning"), - H_RESOURCEWARNING("h_ResourceWarning"), - H_BASEOBJECTTYPE("h_BaseObjectType"), - H_TYPETYPE("h_TypeType"), - H_BOOLTYPE("h_BoolType"), - H_LONGTYPE("h_LongType"), - H_FLOATTYPE("h_FloatType"), - H_UNICODETYPE("h_UnicodeType"), - H_TUPLETYPE("h_TupleType"), - H_LISTTYPE("h_ListType"), - H_COMPLEXTYPE("h_ComplexType"), - H_BYTESTYPE("h_BytesType"), - H_MEMORYVIEWTYPE("h_MemoryViewType"), - H_CAPSULETYPE("h_CapsuleType"), - H_SLICETYPE("h_SliceType"), - H_BUILTINS("h_Builtins"), - CTX_DUP("ctx_Dup", HPy, HPyContextPtr, HPy), - CTX_CLOSE("ctx_Close", CVoid, HPyContextPtr, HPy), - CTX_LONG_FROMINT32_T("ctx_Long_FromInt32_t", HPy, HPyContextPtr, Int32_t), - CTX_LONG_FROMUINT32_T("ctx_Long_FromUInt32_t", HPy, HPyContextPtr, Uint32_t), - CTX_LONG_FROMINT64_T("ctx_Long_FromInt64_t", HPy, HPyContextPtr, Int64_t), - CTX_LONG_FROMUINT64_T("ctx_Long_FromUInt64_t", HPy, HPyContextPtr, Uint64_t), - CTX_LONG_FROMSIZE_T("ctx_Long_FromSize_t", HPy, HPyContextPtr, Size_t), - CTX_LONG_FROMSSIZE_T("ctx_Long_FromSsize_t", HPy, HPyContextPtr, HPy_ssize_t), - CTX_LONG_ASINT32_T("ctx_Long_AsInt32_t", Int32_t, HPyContextPtr, HPy), - CTX_LONG_ASUINT32_T("ctx_Long_AsUInt32_t", Uint32_t, HPyContextPtr, HPy), - CTX_LONG_ASUINT32_TMASK("ctx_Long_AsUInt32_tMask", Uint32_t, HPyContextPtr, HPy), - CTX_LONG_ASINT64_T("ctx_Long_AsInt64_t", Int64_t, HPyContextPtr, HPy), - CTX_LONG_ASUINT64_T("ctx_Long_AsUInt64_t", Uint64_t, HPyContextPtr, HPy), - CTX_LONG_ASUINT64_TMASK("ctx_Long_AsUInt64_tMask", Uint64_t, HPyContextPtr, HPy), - CTX_LONG_ASSIZE_T("ctx_Long_AsSize_t", Size_t, HPyContextPtr, HPy), - CTX_LONG_ASSSIZE_T("ctx_Long_AsSsize_t", HPy_ssize_t, HPyContextPtr, HPy), - CTX_LONG_ASVOIDPTR("ctx_Long_AsVoidPtr", VoidPtr, HPyContextPtr, HPy), - CTX_LONG_ASDOUBLE("ctx_Long_AsDouble", CDouble, HPyContextPtr, HPy), - CTX_FLOAT_FROMDOUBLE("ctx_Float_FromDouble", HPy, HPyContextPtr, CDouble), - CTX_FLOAT_ASDOUBLE("ctx_Float_AsDouble", CDouble, HPyContextPtr, HPy), - CTX_BOOL_FROMBOOL("ctx_Bool_FromBool", HPy, HPyContextPtr, Bool), - CTX_LENGTH("ctx_Length", HPy_ssize_t, HPyContextPtr, HPy), - CTX_NUMBER_CHECK("ctx_Number_Check", Int, HPyContextPtr, HPy), - CTX_ADD("ctx_Add", HPy, HPyContextPtr, HPy, HPy), - CTX_SUBTRACT("ctx_Subtract", HPy, HPyContextPtr, HPy, HPy), - CTX_MULTIPLY("ctx_Multiply", HPy, HPyContextPtr, HPy, HPy), - CTX_MATRIXMULTIPLY("ctx_MatrixMultiply", HPy, HPyContextPtr, HPy, HPy), - CTX_FLOORDIVIDE("ctx_FloorDivide", HPy, HPyContextPtr, HPy, HPy), - CTX_TRUEDIVIDE("ctx_TrueDivide", HPy, HPyContextPtr, HPy, HPy), - CTX_REMAINDER("ctx_Remainder", HPy, HPyContextPtr, HPy, HPy), - CTX_DIVMOD("ctx_Divmod", HPy, HPyContextPtr, HPy, HPy), - CTX_POWER("ctx_Power", HPy, HPyContextPtr, HPy, HPy, HPy), - CTX_NEGATIVE("ctx_Negative", HPy, HPyContextPtr, HPy), - CTX_POSITIVE("ctx_Positive", HPy, HPyContextPtr, HPy), - CTX_ABSOLUTE("ctx_Absolute", HPy, HPyContextPtr, HPy), - CTX_INVERT("ctx_Invert", HPy, HPyContextPtr, HPy), - CTX_LSHIFT("ctx_Lshift", HPy, HPyContextPtr, HPy, HPy), - CTX_RSHIFT("ctx_Rshift", HPy, HPyContextPtr, HPy, HPy), - CTX_AND("ctx_And", HPy, HPyContextPtr, HPy, HPy), - CTX_XOR("ctx_Xor", HPy, HPyContextPtr, HPy, HPy), - CTX_OR("ctx_Or", HPy, HPyContextPtr, HPy, HPy), - CTX_INDEX("ctx_Index", HPy, HPyContextPtr, HPy), - CTX_LONG("ctx_Long", HPy, HPyContextPtr, HPy), - CTX_FLOAT("ctx_Float", HPy, HPyContextPtr, HPy), - CTX_INPLACEADD("ctx_InPlaceAdd", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACESUBTRACT("ctx_InPlaceSubtract", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEMULTIPLY("ctx_InPlaceMultiply", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEMATRIXMULTIPLY("ctx_InPlaceMatrixMultiply", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEFLOORDIVIDE("ctx_InPlaceFloorDivide", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACETRUEDIVIDE("ctx_InPlaceTrueDivide", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEREMAINDER("ctx_InPlaceRemainder", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEPOWER("ctx_InPlacePower", HPy, HPyContextPtr, HPy, HPy, HPy), - CTX_INPLACELSHIFT("ctx_InPlaceLshift", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACERSHIFT("ctx_InPlaceRshift", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEAND("ctx_InPlaceAnd", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEXOR("ctx_InPlaceXor", HPy, HPyContextPtr, HPy, HPy), - CTX_INPLACEOR("ctx_InPlaceOr", HPy, HPyContextPtr, HPy, HPy), - CTX_CALLABLE_CHECK("ctx_Callable_Check", Int, HPyContextPtr, HPy), - CTX_CALLTUPLEDICT("ctx_CallTupleDict", HPy, HPyContextPtr, HPy, HPy, HPy), - CTX_CALL("ctx_Call", HPy, HPyContextPtr, HPy, ConstHPyPtr, Size_t, HPy), - CTX_CALLMETHOD("ctx_CallMethod", HPy, HPyContextPtr, HPy, ConstHPyPtr, Size_t, HPy), - CTX_FATALERROR("ctx_FatalError", CVoid, HPyContextPtr, ConstCharPtr), - CTX_ERR_SETSTRING("ctx_Err_SetString", CVoid, HPyContextPtr, HPy, ConstCharPtr), - CTX_ERR_SETOBJECT("ctx_Err_SetObject", CVoid, HPyContextPtr, HPy, HPy), - CTX_ERR_SETFROMERRNOWITHFILENAME("ctx_Err_SetFromErrnoWithFilename", HPy, HPyContextPtr, HPy, ConstCharPtr), - CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS("ctx_Err_SetFromErrnoWithFilenameObjects", CVoid, HPyContextPtr, HPy, HPy, HPy), - CTX_ERR_OCCURRED("ctx_Err_Occurred", Int, HPyContextPtr), - CTX_ERR_EXCEPTIONMATCHES("ctx_Err_ExceptionMatches", Int, HPyContextPtr, HPy), - CTX_ERR_NOMEMORY("ctx_Err_NoMemory", CVoid, HPyContextPtr), - CTX_ERR_CLEAR("ctx_Err_Clear", CVoid, HPyContextPtr), - CTX_ERR_NEWEXCEPTION("ctx_Err_NewException", HPy, HPyContextPtr, ConstCharPtr, HPy, HPy), - CTX_ERR_NEWEXCEPTIONWITHDOC("ctx_Err_NewExceptionWithDoc", HPy, HPyContextPtr, ConstCharPtr, ConstCharPtr, HPy, HPy), - CTX_ERR_WARNEX("ctx_Err_WarnEx", Int, HPyContextPtr, HPy, ConstCharPtr, HPy_ssize_t), - CTX_ERR_WRITEUNRAISABLE("ctx_Err_WriteUnraisable", CVoid, HPyContextPtr, HPy), - CTX_ISTRUE("ctx_IsTrue", Int, HPyContextPtr, HPy), - CTX_TYPE_FROMSPEC("ctx_Type_FromSpec", HPy, HPyContextPtr, HPyType_SpecPtr, HPyType_SpecParamPtr), - CTX_TYPE_GENERICNEW("ctx_Type_GenericNew", HPy, HPyContextPtr, HPy, ConstHPyPtr, HPy_ssize_t, HPy), - CTX_GETATTR("ctx_GetAttr", HPy, HPyContextPtr, HPy, HPy), - CTX_GETATTR_S("ctx_GetAttr_s", HPy, HPyContextPtr, HPy, ConstCharPtr), - CTX_HASATTR("ctx_HasAttr", Int, HPyContextPtr, HPy, HPy), - CTX_HASATTR_S("ctx_HasAttr_s", Int, HPyContextPtr, HPy, ConstCharPtr), - CTX_SETATTR("ctx_SetAttr", Int, HPyContextPtr, HPy, HPy, HPy), - CTX_SETATTR_S("ctx_SetAttr_s", Int, HPyContextPtr, HPy, ConstCharPtr, HPy), - CTX_GETITEM("ctx_GetItem", HPy, HPyContextPtr, HPy, HPy), - CTX_GETITEM_I("ctx_GetItem_i", HPy, HPyContextPtr, HPy, HPy_ssize_t), - CTX_GETITEM_S("ctx_GetItem_s", HPy, HPyContextPtr, HPy, ConstCharPtr), - CTX_CONTAINS("ctx_Contains", Int, HPyContextPtr, HPy, HPy), - CTX_SETITEM("ctx_SetItem", Int, HPyContextPtr, HPy, HPy, HPy), - CTX_SETITEM_I("ctx_SetItem_i", Int, HPyContextPtr, HPy, HPy_ssize_t, HPy), - CTX_SETITEM_S("ctx_SetItem_s", Int, HPyContextPtr, HPy, ConstCharPtr, HPy), - CTX_DELITEM("ctx_DelItem", Int, HPyContextPtr, HPy, HPy), - CTX_DELITEM_I("ctx_DelItem_i", Int, HPyContextPtr, HPy, HPy_ssize_t), - CTX_DELITEM_S("ctx_DelItem_s", Int, HPyContextPtr, HPy, ConstCharPtr), - CTX_TYPE("ctx_Type", HPy, HPyContextPtr, HPy), - CTX_TYPECHECK("ctx_TypeCheck", Int, HPyContextPtr, HPy, HPy), - CTX_TYPE_GETNAME("ctx_Type_GetName", ConstCharPtr, HPyContextPtr, HPy), - CTX_TYPE_ISSUBTYPE("ctx_Type_IsSubtype", Int, HPyContextPtr, HPy, HPy), - CTX_IS("ctx_Is", Int, HPyContextPtr, HPy, HPy), - CTX_ASSTRUCT_OBJECT("ctx_AsStruct_Object", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_LEGACY("ctx_AsStruct_Legacy", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_TYPE("ctx_AsStruct_Type", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_LONG("ctx_AsStruct_Long", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_FLOAT("ctx_AsStruct_Float", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_UNICODE("ctx_AsStruct_Unicode", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_TUPLE("ctx_AsStruct_Tuple", VoidPtr, HPyContextPtr, HPy), - CTX_ASSTRUCT_LIST("ctx_AsStruct_List", VoidPtr, HPyContextPtr, HPy), - CTX_TYPE_GETBUILTINSHAPE("ctx_Type_GetBuiltinShape", HPyType_BuiltinShape, HPyContextPtr, HPy), - CTX_NEW("ctx_New", HPy, HPyContextPtr, HPy, VoidPtrPtr), - CTX_REPR("ctx_Repr", HPy, HPyContextPtr, HPy), - CTX_STR("ctx_Str", HPy, HPyContextPtr, HPy), - CTX_ASCII("ctx_ASCII", HPy, HPyContextPtr, HPy), - CTX_BYTES("ctx_Bytes", HPy, HPyContextPtr, HPy), - CTX_RICHCOMPARE("ctx_RichCompare", HPy, HPyContextPtr, HPy, HPy, Int), - CTX_RICHCOMPAREBOOL("ctx_RichCompareBool", Int, HPyContextPtr, HPy, HPy, Int), - CTX_HASH("ctx_Hash", HPy_hash_t, HPyContextPtr, HPy), - CTX_BYTES_CHECK("ctx_Bytes_Check", Int, HPyContextPtr, HPy), - CTX_BYTES_SIZE("ctx_Bytes_Size", HPy_ssize_t, HPyContextPtr, HPy), - CTX_BYTES_GET_SIZE("ctx_Bytes_GET_SIZE", HPy_ssize_t, HPyContextPtr, HPy), - CTX_BYTES_ASSTRING("ctx_Bytes_AsString", ConstCharPtr, HPyContextPtr, HPy), - CTX_BYTES_AS_STRING("ctx_Bytes_AS_STRING", ConstCharPtr, HPyContextPtr, HPy), - CTX_BYTES_FROMSTRING("ctx_Bytes_FromString", HPy, HPyContextPtr, ConstCharPtr), - CTX_BYTES_FROMSTRINGANDSIZE("ctx_Bytes_FromStringAndSize", HPy, HPyContextPtr, ConstCharPtr, HPy_ssize_t), - CTX_UNICODE_FROMSTRING("ctx_Unicode_FromString", HPy, HPyContextPtr, ConstCharPtr), - CTX_UNICODE_CHECK("ctx_Unicode_Check", Int, HPyContextPtr, HPy), - CTX_UNICODE_ASASCIISTRING("ctx_Unicode_AsASCIIString", HPy, HPyContextPtr, HPy), - CTX_UNICODE_ASLATIN1STRING("ctx_Unicode_AsLatin1String", HPy, HPyContextPtr, HPy), - CTX_UNICODE_ASUTF8STRING("ctx_Unicode_AsUTF8String", HPy, HPyContextPtr, HPy), - CTX_UNICODE_ASUTF8ANDSIZE("ctx_Unicode_AsUTF8AndSize", ConstCharPtr, HPyContextPtr, HPy, HPy_ssize_tPtr), - CTX_UNICODE_FROMWIDECHAR("ctx_Unicode_FromWideChar", HPy, HPyContextPtr, ConstWchar_tPtr, HPy_ssize_t), - CTX_UNICODE_DECODEFSDEFAULT("ctx_Unicode_DecodeFSDefault", HPy, HPyContextPtr, ConstCharPtr), - CTX_UNICODE_DECODEFSDEFAULTANDSIZE("ctx_Unicode_DecodeFSDefaultAndSize", HPy, HPyContextPtr, ConstCharPtr, HPy_ssize_t), - CTX_UNICODE_ENCODEFSDEFAULT("ctx_Unicode_EncodeFSDefault", HPy, HPyContextPtr, HPy), - CTX_UNICODE_READCHAR("ctx_Unicode_ReadChar", HPy_UCS4, HPyContextPtr, HPy, HPy_ssize_t), - CTX_UNICODE_DECODEASCII("ctx_Unicode_DecodeASCII", HPy, HPyContextPtr, ConstCharPtr, HPy_ssize_t, ConstCharPtr), - CTX_UNICODE_DECODELATIN1("ctx_Unicode_DecodeLatin1", HPy, HPyContextPtr, ConstCharPtr, HPy_ssize_t, ConstCharPtr), - CTX_UNICODE_FROMENCODEDOBJECT("ctx_Unicode_FromEncodedObject", HPy, HPyContextPtr, HPy, ConstCharPtr, ConstCharPtr), - CTX_UNICODE_SUBSTRING("ctx_Unicode_Substring", HPy, HPyContextPtr, HPy, HPy_ssize_t, HPy_ssize_t), - CTX_LIST_CHECK("ctx_List_Check", Int, HPyContextPtr, HPy), - CTX_LIST_NEW("ctx_List_New", HPy, HPyContextPtr, HPy_ssize_t), - CTX_LIST_APPEND("ctx_List_Append", Int, HPyContextPtr, HPy, HPy), - CTX_DICT_CHECK("ctx_Dict_Check", Int, HPyContextPtr, HPy), - CTX_DICT_NEW("ctx_Dict_New", HPy, HPyContextPtr), - CTX_DICT_KEYS("ctx_Dict_Keys", HPy, HPyContextPtr, HPy), - CTX_DICT_COPY("ctx_Dict_Copy", HPy, HPyContextPtr, HPy), - CTX_TUPLE_CHECK("ctx_Tuple_Check", Int, HPyContextPtr, HPy), - CTX_TUPLE_FROMARRAY("ctx_Tuple_FromArray", HPy, HPyContextPtr, HPyPtr, HPy_ssize_t), - CTX_SLICE_UNPACK("ctx_Slice_Unpack", Int, HPyContextPtr, HPy, HPy_ssize_tPtr, HPy_ssize_tPtr, HPy_ssize_tPtr), - CTX_IMPORT_IMPORTMODULE("ctx_Import_ImportModule", HPy, HPyContextPtr, ConstCharPtr), - CTX_CAPSULE_NEW("ctx_Capsule_New", HPy, HPyContextPtr, VoidPtr, ConstCharPtr, HPyCapsule_DestructorPtr), - CTX_CAPSULE_GET("ctx_Capsule_Get", VoidPtr, HPyContextPtr, HPy, _HPyCapsule_key, ConstCharPtr), - CTX_CAPSULE_ISVALID("ctx_Capsule_IsValid", Int, HPyContextPtr, HPy, ConstCharPtr), - CTX_CAPSULE_SET("ctx_Capsule_Set", Int, HPyContextPtr, HPy, _HPyCapsule_key, VoidPtr), - CTX_FROMPYOBJECT("ctx_FromPyObject", HPy, HPyContextPtr, Cpy_PyObjectPtr), - CTX_ASPYOBJECT("ctx_AsPyObject", Cpy_PyObjectPtr, HPyContextPtr, HPy), - CTX_LISTBUILDER_NEW("ctx_ListBuilder_New", HPyListBuilder, HPyContextPtr, HPy_ssize_t), - CTX_LISTBUILDER_SET("ctx_ListBuilder_Set", CVoid, HPyContextPtr, HPyListBuilder, HPy_ssize_t, HPy), - CTX_LISTBUILDER_BUILD("ctx_ListBuilder_Build", HPy, HPyContextPtr, HPyListBuilder), - CTX_LISTBUILDER_CANCEL("ctx_ListBuilder_Cancel", CVoid, HPyContextPtr, HPyListBuilder), - CTX_TUPLEBUILDER_NEW("ctx_TupleBuilder_New", HPyTupleBuilder, HPyContextPtr, HPy_ssize_t), - CTX_TUPLEBUILDER_SET("ctx_TupleBuilder_Set", CVoid, HPyContextPtr, HPyTupleBuilder, HPy_ssize_t, HPy), - CTX_TUPLEBUILDER_BUILD("ctx_TupleBuilder_Build", HPy, HPyContextPtr, HPyTupleBuilder), - CTX_TUPLEBUILDER_CANCEL("ctx_TupleBuilder_Cancel", CVoid, HPyContextPtr, HPyTupleBuilder), - CTX_TRACKER_NEW("ctx_Tracker_New", HPyTracker, HPyContextPtr, HPy_ssize_t), - CTX_TRACKER_ADD("ctx_Tracker_Add", Int, HPyContextPtr, HPyTracker, HPy), - CTX_TRACKER_FORGETALL("ctx_Tracker_ForgetAll", CVoid, HPyContextPtr, HPyTracker), - CTX_TRACKER_CLOSE("ctx_Tracker_Close", CVoid, HPyContextPtr, HPyTracker), - CTX_FIELD_STORE("ctx_Field_Store", CVoid, HPyContextPtr, HPy, HPyFieldPtr, HPy), - CTX_FIELD_LOAD("ctx_Field_Load", HPy, HPyContextPtr, HPy, HPyField), - CTX_REENTERPYTHONEXECUTION("ctx_ReenterPythonExecution", CVoid, HPyContextPtr, HPyThreadState), - CTX_LEAVEPYTHONEXECUTION("ctx_LeavePythonExecution", HPyThreadState, HPyContextPtr), - CTX_GLOBAL_STORE("ctx_Global_Store", CVoid, HPyContextPtr, HPyGlobalPtr, HPy), - CTX_GLOBAL_LOAD("ctx_Global_Load", HPy, HPyContextPtr, HPyGlobal), - CTX_DUMP("ctx_Dump", CVoid, HPyContextPtr, HPy), - CTX_COMPILE_S("ctx_Compile_s", HPy, HPyContextPtr, ConstCharPtr, ConstCharPtr, HPy_SourceKind), - CTX_EVALCODE("ctx_EvalCode", HPy, HPyContextPtr, HPy, HPy, HPy), - CTX_CONTEXTVAR_NEW("ctx_ContextVar_New", HPy, HPyContextPtr, ConstCharPtr, HPy), - CTX_CONTEXTVAR_GET("ctx_ContextVar_Get", Int32_t, HPyContextPtr, HPy, HPy, HPyPtr), - CTX_CONTEXTVAR_SET("ctx_ContextVar_Set", HPy, HPyContextPtr, HPy, HPy), - CTX_SETCALLFUNCTION("ctx_SetCallFunction", Int, HPyContextPtr, HPy, HPyCallFunctionPtr); - - // @formatter:on - // Checkstyle: resume - // {{end ctx members}} - - private final String name; - private final HPyContextSignature signature; - - HPyContextMember(String name) { - this.name = name; - this.signature = null; - } - - HPyContextMember(String name, HPyContextSignatureType returnType, HPyContextSignatureType... paramTypes) { - this.name = name; - this.signature = new HPyContextSignature(returnType, paramTypes); - } - - @CompilationFinal(dimensions = 1) public static final HPyContextMember[] VALUES = values(); - - @Override - public String getName() { - return name; - } - - public HPyContextSignature getSignature() { - return signature; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignature.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignature.java deleted file mode 100644 index d3e9aa4ab9..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignature.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -/** - * Describes the signature of an HPyContext function. - */ -public record HPyContextSignature(HPyContextSignatureType returnType, HPyContextSignatureType[] parameterTypes) { -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignatureType.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignatureType.java deleted file mode 100644 index 1e4bed20c6..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyContextSignatureType.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -/** - * Describes the type of argument or return type in the HPyContext functions. - */ -public enum HPyContextSignatureType { - HPyContextPtr("HPyContext*", "POINTER", long.class), - CVoid("void", "VOID", void.class), - VoidPtr("void*", "POINTER", long.class), - VoidPtrPtr("void**", "POINTER", long.class), - Bool("bool", "UINT8", boolean.class), - Int("int", null, int.class), - UnsignedInt("unsigned int", null, int.class), - Long("long", null, int.class), - UnsignedLong("unsigned long", "SINT32", int.class), - Int8_t("int8_t", "SINT8", byte.class), - Uint8_t("uint8_t", "UINT8", byte.class), - Int16_t("int16_t", "SINT16", short.class), - Uint16_t("uint16_t", "UINT16", short.class), - Int32_t("int32_t", "SINT32", int.class), - Uint32_t("uint32_t", "UINT32", int.class), - CFloat("float", "FLOAT", float.class), - CDouble("double", "DOUBLE", double.class), - Int64_t("int64_t", "SINT64", int.class), - Uint64_t("uint64_t", "UINT64", int.class), - HPy("HPy", "POINTER", long.class), - HPyPtr("HPy*", "POINTER", long.class), - ConstHPyPtr("const HPy*", "POINTER", long.class), - Wchar_tPtr("wchar_t*", "POINTER", long.class), - ConstWchar_tPtr("const wchar_t*", "POINTER", long.class), - CharPtr("char*", "POINTER", long.class), - ConstCharPtr("const char*", "POINTER", long.class), - DataPtr("void*", "POINTER", long.class), - DataPtrPtr("void**", "POINTER", long.class), - HPyTracker("HPyTracker", "POINTER", long.class), - Size_t("size_t", "UINT64", long.class), - HPy_ssize_t("HPy_ssize_t", "UINT64", long.class), - HPy_ssize_tPtr("HPy_ssize_t*", "POINTER", long.class), - HPy_hash_t("HPy_hash_t", "UINT64", long.class), - HPy_UCS4("HPy_UCS4", "UINT32", int.class), - HPyTupleBuilder("HPyTupleBuilder", "POINTER", long.class), - HPyListBuilder("HPyListBuilder", "POINTER", long.class), - Cpy_PyObjectPtr("cpy_PyObject*", "POINTER", long.class), - Cpy_PyMethodDefPtr("cpy_PyMethodDef*", "POINTER", long.class), - HPyModuleDefPtr("HPyModuleDef*", "POINTER", long.class), - HPyType_SpecPtr("HPyType_Spec*", "POINTER", long.class), - HPyType_SpecParam("HPyType_SpecParam", null, null), - HPyType_SpecParamPtr("HPyType_SpecParam*", "POINTER", long.class), - HPyDefPtr("HPyDef*", "POINTER", long.class), - HPyThreadState("HPyThreadState", "POINTER", long.class), - HPyField("HPyField", "POINTER", long.class), - HPyFieldPtr("HPyField*", "POINTER", long.class), - HPyGlobal("HPyGlobal", "POINTER", long.class), - HPyGlobalPtr("HPyGlobal*", "POINTER", long.class), - HPyCapsule_DestructorPtr("HPyCapsule_Destructor*", "POINTER", long.class), - _HPyCapsule_key("_HPyCapsule_key", "SINT32", int.class), - HPyType_BuiltinShape("HPyType_BuiltinShape", "SINT32", int.class), - HPy_SourceKind("HPy_SourceKind", "SINT32", int.class), - HPyCallFunctionPtr("HPyCallFunction*", "POINTER", long.class), - PyType_Slot("PyType_Slot", null, null), - PyType_SlotPtr("PyType_Slot*", "POINTER", long.class), - HPyFunc_Signature("HPyFunc_Signature", null, null), - HPyMember_FieldType("HPyMember_FieldType", null, null), - HPySlot_Slot("HPySlot_Slot", null, null), - PyMemberDef("PyMemberDef", null, null), - HPy_buffer("HPy_buffer", null, null), - PyGetSetDef("PyGetSetDef", null, null); - - /** - * The type definition used in C source code. - */ - final String cType; - /** - * The type definition that is used in NFI signatures. - */ - final String nfiType; - /** - * The type used on the Java side in JNI/CLinker functions. - */ - final Class jniType; - - HPyContextSignatureType(String cType, String nfiType, Class jniType) { - this.cType = cType; - this.nfiType = nfiType; - this.jniType = jniType; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java deleted file mode 100644 index 3b65e7dde5..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyExternalFunctionNodes.java +++ /dev/null @@ -1,1847 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.builtins.objects.cext.hpy; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; -import static com.oracle.graal.python.util.PythonUtils.EMPTY_TRUFFLESTRING_ARRAY; -import static com.oracle.graal.python.util.PythonUtils.tsArray; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.cext.PythonAbstractNativeObject; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.FromCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.GetterRoot; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.SetterRoot; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureExecutableNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.GetIndexNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.TransformExceptionFromNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPyFuncSignature; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseAndGetHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseArgHandlesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyConvertArgsToSulongNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyGetNativeSpacePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAllAsHandleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetBufferProcToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetNativeSpacePointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetSetGetterToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyGetSetSetterToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyKeywordsToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyReleaseBufferProcToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyRichcmpFuncArgsToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPySSizeArgFuncToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPySSizeObjArgProcToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyVarargsToSulongNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodesFactory.HPyCheckHandleResultNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodesFactory.HPyCheckPrimitiveResultNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodesFactory.HPyCheckVoidResultNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodesFactory.HPyExternalFunctionInvokeNodeGen; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.function.Signature; -import com.oracle.graal.python.builtins.objects.memoryview.CExtPyBuffer; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotHPyNative; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.PRootNode; -import com.oracle.graal.python.nodes.argument.ReadIndexedArgumentNode; -import com.oracle.graal.python.nodes.argument.ReadVarArgsNode; -import com.oracle.graal.python.nodes.argument.ReadVarKeywordsNode; -import com.oracle.graal.python.runtime.ExecutionContext.CalleeContext; -import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; -import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.RootCallTarget; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.BranchProfile; -import com.oracle.truffle.api.strings.TruffleString; - -public abstract class HPyExternalFunctionNodes { - - public static final TruffleString KW_CALLABLE = tsLiteral("$callable"); - private static final TruffleString KW_CLOSURE = tsLiteral("$closure"); - private static final TruffleString KW_CONTEXT = tsLiteral("$context"); - private static final TruffleString[] KEYWORDS_HIDDEN_CONTEXT = {KW_CONTEXT}; - private static final TruffleString[] KEYWORDS_HIDDEN_CALLABLE = {KW_CONTEXT, KW_CALLABLE}; - private static final TruffleString[] KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE = {KW_CONTEXT, KW_CALLABLE, KW_CLOSURE}; - private static final Object[] KW_DEFAULTS = {PNone.NO_VALUE}; - - private static PKeyword[] createKwDefaults(GraalHPyContext context) { - return new PKeyword[]{new PKeyword(KW_CONTEXT, context)}; - } - - private static PKeyword[] createKwDefaults(Object callable, GraalHPyContext context) { - // return new PKeyword[]{new PKeyword(KW_CALLABLE, callable), new PKeyword(KW_CONTEXT, - // context)}; - return new PKeyword[]{new PKeyword(KW_CONTEXT, context), new PKeyword(KW_CALLABLE, callable)}; - } - - public static PKeyword[] createKwDefaults(Object callable, Object closure, GraalHPyContext context) { - // return new PKeyword[]{new PKeyword(KW_CALLABLE, callable), new PKeyword(KW_CONTEXT, - // context), new PKeyword(KW_CLOSURE, closure)}; - return new PKeyword[]{new PKeyword(KW_CONTEXT, context), new PKeyword(KW_CALLABLE, callable), new PKeyword(KW_CLOSURE, closure)}; - } - - /** - * Creates a built-in function that accepts the specified signatures, does appropriate argument - * and result conversion and calls the provided callable. - * - * @param language The Python language object. - * @param context The HPy context the new function object belongs to. This will also be the - * context that is passed to the native functions when they are called. - * @param signature The signature ID as defined in {@link GraalHPyDef}. - * @param name The name of the method. - * @param callable The native function pointer. - * @param enclosingType The type the function belongs to (needed for checking of {@code self}). - * @return A {@link PBuiltinFunction} that accepts the given signature. - */ - @TruffleBoundary - static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyContext context, HPyFuncSignature signature, TruffleString name, Object callable, Object enclosingType) { - assert InteropLibrary.getUncached(callable).isExecutable(callable) : "object is not callable"; - RootCallTarget callTarget = language.createCachedCallTarget(l -> createRootNode(l, signature, name), signature, name, true); - - Object[] defaults; - if (signature == HPyFuncSignature.TERNARYFUNC) { - // the third argument is optional - // so it has a default value (this implicitly is 'None') - defaults = KW_DEFAULTS; - } else { - defaults = PythonUtils.EMPTY_OBJECT_ARRAY; - } - int flags = HPyFuncSignature.getFlags(signature); - return PFactory.createBuiltinFunction(language, name, enclosingType, defaults, createKwDefaults(callable, context), flags, callTarget); - } - - private static PRootNode createRootNode(PythonLanguage language, HPyFuncSignature signature, TruffleString name) { - switch (signature) { - case NOARGS: - case UNARYFUNC: - case REPRFUNC: - case GETITERFUNC: - case ITERNEXTFUNC: - case DESTROYFUNC: - return new HPyMethNoargsRoot(language, name, false); - case O: - case BINARYFUNC: - return new HPyMethORoot(language, name, false); - case KEYWORDS: - return new HPyMethKeywordsRoot(language, name); - case INITPROC: - return new HPyMethInitProcRoot(language, name); - case VARARGS: - return new HPyMethVarargsRoot(language, name); - case TERNARYFUNC: - return new HPyMethTernaryRoot(language, name); - case LENFUNC: - return new HPyMethNoargsRoot(language, name, true); - case SSIZEOBJARGPROC: - return new HPyMethSSizeObjArgProcRoot(language, name); - case INQUIRY: - return new HPyMethInquiryRoot(language, name); - case SSIZEARGFUNC: - return new HPyMethSSizeArgFuncRoot(language, name); - case OBJOBJARGPROC: - return new HPyMethObjObjArgProcRoot(language, name); - case OBJOBJPROC: - return new HPyMethObjObjProcRoot(language, name); - default: - // TODO(fa): support remaining signatures - throw CompilerDirectives.shouldNotReachHere("unsupported HPy method signature: " + signature.name()); - } - } - - /** - * Creates a built-in function for a specific slot. This built-in function also does appropriate - * argument and result conversion and calls the provided callable. - * - * @param language The Python language object. - * @param wrapper The wrapper ID as defined in {@link HPySlotWrapper}. - * @param name The name of the method. - * @param callable The native function pointer. - * @param enclosingType The type the function belongs to (needed for checking of {@code self}). - * @return A {@link PBuiltinFunction} implementing the semantics of the specified slot wrapper. - */ - @TruffleBoundary - public static PBuiltinFunction createWrapperFunction(PythonLanguage language, GraalHPyContext context, HPySlotWrapper wrapper, TpSlotHPyNative slot, PExternalFunctionWrapper legacySlotWrapper, - TruffleString name, Object callable, Object enclosingType) { - assert InteropLibrary.getUncached(callable).isExecutable(callable) : "object is not callable"; - RootCallTarget callTarget = language.createCachedCallTarget(l -> createSlotRootNode(l, wrapper, name), wrapper, name); - Object[] defaults; - if (wrapper == HPySlotWrapper.TERNARYFUNC || wrapper == HPySlotWrapper.SQ_DELITEM) { - /* - * For TERNARYFUNC: The third argument is optional. So it has a default value (this - * implicitly is 'None'). For SQ_DELITEM: it's really the same as SQ_SETITEM but with a - * default. - */ - defaults = new Object[]{PNone.NO_VALUE}; - } else { - defaults = PythonUtils.EMPTY_OBJECT_ARRAY; - } - PKeyword[] kwDefaults; - if (wrapper == HPySlotWrapper.CALL) { - kwDefaults = createKwDefaults(context); - } else { - kwDefaults = createKwDefaults(callable, context); - - } - return PFactory.createWrapperDescriptor(language, name, enclosingType, defaults, kwDefaults, 0, callTarget, slot, legacySlotWrapper); - } - - private static PRootNode createSlotRootNode(PythonLanguage language, HPySlotWrapper wrapper, TruffleString name) { - switch (wrapper) { - case NULL: - return new HPyMethKeywordsRoot(language, name); - case UNARYFUNC: - return new HPyMethNoargsRoot(language, name, false); - case BINARYFUNC: - case BINARYFUNC_L: - return new HPyMethORoot(language, name, false); - case BINARYFUNC_R: - return new HPyMethReverseBinaryRoot(language, name, false); - case INIT: - return new HPyMethInitProcRoot(language, name); - case TERNARYFUNC: - return new HPyMethTernaryRoot(language, name); - case LENFUNC: - return new HPyMethNoargsRoot(language, name, true); - case INQUIRYPRED: - return new HPyMethInquiryRoot(language, name); - case INDEXARGFUNC: - return new HPyMethSSizeArgFuncRoot(language, name); - case OBJOBJARGPROC: - return new HPyMethObjObjArgProcRoot(language, name); - case OBJOBJPROC: - return new HPyMethObjObjProcRoot(language, name); - case SQ_ITEM: - return new HPyMethSqItemWrapperRoot(language, name); - case SQ_SETITEM: - case SQ_DELITEM: - // SQ_DELITEM is really the same as SQ_SETITEM but with a default - return new HPyMethSqSetitemWrapperRoot(language, name); - case RICHCMP_LT: - case RICHCMP_LE: - case RICHCMP_EQ: - case RICHCMP_NE: - case RICHCMP_GT: - case RICHCMP_GE: - return new HPyMethRichcmpOpRootNode(language, name, getCompareOpCode(wrapper)); - case GETBUFFER: - return new HPyGetBufferRootNode(language, name); - case RELEASEBUFFER: - return new HPyReleaseBufferRootNode(language, name); - case HASHFUNC: - return new HPyMethHashRoot(language, name); - case CALL: - return new HPyMethCallRoot(language, name); - default: - // TODO(fa): support remaining slot wrappers - throw CompilerDirectives.shouldNotReachHere("unsupported HPy slot wrapper: wrap_" + wrapper.name().toLowerCase()); - } - - } - - /** - * Resolve the requested slot wrapper to the numeric op code as defined by HPy's enum - * {@code HPy_RichCmpOp}. - */ - private static int getCompareOpCode(HPySlotWrapper sig) { - // op codes for binary comparisons (defined in 'object.h') - switch (sig) { - case RICHCMP_LT: - return 0; - case RICHCMP_LE: - return 1; - case RICHCMP_EQ: - return 2; - case RICHCMP_NE: - return 3; - case RICHCMP_GT: - return 4; - case RICHCMP_GE: - return 5; - } - throw CompilerDirectives.shouldNotReachHere(); - } - - /** - * Invokes an HPy C function. It takes care of argument and result conversion and always passes - * the HPy context as a first parameter. - */ - public abstract static class HPyExternalFunctionInvokeNode extends Node { - - @Child private HPyConvertArgsToSulongNode toSulongNode; - @Child private HPyCheckFunctionResultNode checkFunctionResultNode; - @Child private HPyCloseArgHandlesNode handleCloseNode; - - HPyExternalFunctionInvokeNode() { - CompilerAsserts.neverPartOfCompilation(); - this.toSulongNode = HPyAllAsHandleNodeGen.create(); - this.checkFunctionResultNode = HPyCheckHandleResultNodeGen.create(); - this.handleCloseNode = this.toSulongNode.createCloseHandleNode(); - } - - HPyExternalFunctionInvokeNode(HPyConvertArgsToSulongNode convertArgsNode) { - CompilerAsserts.neverPartOfCompilation(); - this.toSulongNode = convertArgsNode != null ? convertArgsNode : HPyAllAsHandleNodeGen.create(); - this.checkFunctionResultNode = HPyCheckHandleResultNodeGen.create(); - this.handleCloseNode = this.toSulongNode.createCloseHandleNode(); - } - - HPyExternalFunctionInvokeNode(HPyCheckFunctionResultNode checkFunctionResultNode, HPyConvertArgsToSulongNode convertArgsNode) { - CompilerAsserts.neverPartOfCompilation(); - this.toSulongNode = convertArgsNode != null ? convertArgsNode : HPyAllAsHandleNodeGen.create(); - this.checkFunctionResultNode = checkFunctionResultNode != null ? checkFunctionResultNode : HPyCheckHandleResultNodeGen.create(); - this.handleCloseNode = this.toSulongNode.createCloseHandleNode(); - } - - public abstract Object execute(VirtualFrame frame, TruffleString name, Object callable, GraalHPyContext hPyContext, Object[] frameArgs); - - @Specialization(limit = "1") - Object doIt(VirtualFrame frame, TruffleString name, Object callable, GraalHPyContext hPyContext, Object[] arguments, - @Bind("this") Node inliningTarget, - @Cached("createFor(this)") IndirectCallData indirectCallData, - @CachedLibrary("callable") InteropLibrary lib, - @Cached PRaiseNode raiseNode) { - Object[] convertedArguments = new Object[arguments.length + 1]; - toSulongNode.executeInto(frame, arguments, 0, convertedArguments, 1); - - // first arg is always the HPyContext - convertedArguments[0] = hPyContext.getBackend(); - - PythonContext ctx = hPyContext.getContext(); - PythonLanguage language = ctx.getLanguage(this); - PythonThreadState pythonThreadState = ctx.getThreadState(language); - - // If any code requested the caught exception (i.e. used 'sys.exc_info()'), we store - // it to the context since we cannot propagate it through the native frames. - Object state = IndirectCallContext.enter(frame, pythonThreadState, indirectCallData); - - try { - return checkFunctionResultNode.execute(pythonThreadState, name, lib.execute(callable, convertedArguments)); - } catch (UnsupportedTypeException | UnsupportedMessageException e) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_FAILED, name, e); - } catch (ArityException e) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.CALLING_NATIVE_FUNC_EXPECTED_ARGS, name, e.getExpectedMinArity(), e.getActualArity()); - } finally { - // special case after calling a C function: transfer caught exception back to frame - // to simulate the global state semantics - PArguments.setException(frame, pythonThreadState.getCaughtException()); - IndirectCallContext.exit(frame, pythonThreadState, state); - - // close all handles (if necessary) - if (handleCloseNode != null) { - handleCloseNode.executeInto(frame, convertedArguments, 1); - } - } - } - } - - abstract static class HPyMethodDescriptorRootNode extends PRootNode { - @Child private CalleeContext calleeContext; - @Child private HPyExternalFunctionInvokeNode invokeNode; - @Child private ReadIndexedArgumentNode readSelfNode; - @Child private ReadIndexedArgumentNode readCallableNode; - @Child private ReadIndexedArgumentNode readContextNode; - - private final TruffleString name; - - @TruffleBoundary - public HPyMethodDescriptorRootNode(PythonLanguage language, TruffleString name, HPyConvertArgsToSulongNode convertArgsToSulongNode) { - super(language); - this.name = name; - this.invokeNode = HPyExternalFunctionInvokeNodeGen.create(convertArgsToSulongNode); - } - - @TruffleBoundary - public HPyMethodDescriptorRootNode(PythonLanguage language, TruffleString name, HPyCheckFunctionResultNode checkFunctionResultNode, HPyConvertArgsToSulongNode convertArgsToSulongNode) { - super(language); - this.name = name; - this.invokeNode = HPyExternalFunctionInvokeNodeGen.create(checkFunctionResultNode, convertArgsToSulongNode); - } - - protected static Object intToBoolean(Object result) { - if (result instanceof Integer) { - return ((Integer) result) != 0; - } else if (result instanceof Long) { - return ((Long) result) != 0; - } - throw CompilerDirectives.shouldNotReachHere(); - } - - @Override - public Object execute(VirtualFrame frame) { - Object callable = ensureReadCallableNode().execute(frame); - GraalHPyContext hpyContext = readContext(frame); - Object[] cArguments = prepareCArguments(frame, hpyContext); - getCalleeContext().enter(frame); - try { - return processResult(frame, invokeNode.execute(frame, name, callable, hpyContext, cArguments)); - } finally { - getCalleeContext().exit(frame, this); - closeCArguments(frame, hpyContext, cArguments); - } - } - - protected abstract Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext); - - protected Object processResult(@SuppressWarnings("unused") VirtualFrame frame, Object result) { - return result; - } - - @SuppressWarnings("unused") - protected void closeCArguments(VirtualFrame frame, GraalHPyContext hpyContext, Object[] cArguments) { - // nothing to do by default - } - - protected final HPyExternalFunctionInvokeNode getInvokeNode() { - return invokeNode; - } - - protected final Object getSelf(VirtualFrame frame) { - if (readSelfNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readSelfNode = insert(ReadIndexedArgumentNode.create(0)); - } - return readSelfNode.execute(frame); - } - - protected final CalleeContext getCalleeContext() { - if (calleeContext == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - calleeContext = insert(CalleeContext.create()); - } - return calleeContext; - } - - protected final ReadIndexedArgumentNode ensureReadCallableNode() { - if (readCallableNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden argument after the hidden context argument - int hiddenArg = getSignature().getParameterIds().length + 1; - readCallableNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - return readCallableNode; - } - - protected final GraalHPyContext readContext(VirtualFrame frame) { - if (readContextNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden argument at the end of the positional arguments - int hiddenArg = getSignature().getParameterIds().length; - readContextNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - Object hpyContext = readContextNode.execute(frame); - if (hpyContext instanceof GraalHPyContext) { - return (GraalHPyContext) hpyContext; - } - throw CompilerDirectives.shouldNotReachHere("invalid HPy context"); - } - - @Override - public String getName() { - return name.toJavaStringUncached(); - } - - public TruffleString getTSName() { - return name; - } - - @Override - public String toString() { - return ""; - } - - @Override - public boolean isInternal() { - return true; - } - - @Override - public boolean isPythonInternal() { - return true; - } - - @Override - public boolean setsUpCalleeContext() { - return true; - } - } - - static final class HPyMethNoargsRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(1, false, -1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE, true); - - public HPyMethNoargsRoot(PythonLanguage language, TruffleString name, boolean nativePrimitiveResult) { - super(language, name, nativePrimitiveResult ? HPyCheckPrimitiveResultNodeGen.create() : HPyCheckHandleResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame)}; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethORoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("self", "arg"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArgNode; - - public HPyMethORoot(PythonLanguage language, TruffleString name, boolean nativePrimitiveResult) { - super(language, name, nativePrimitiveResult ? HPyCheckPrimitiveResultNodeGen.create() : HPyCheckHandleResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg(frame)}; - } - - private Object getArg(VirtualFrame frame) { - if (readArgNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArgNode = insert(ReadIndexedArgumentNode.create(1)); - } - return readArgNode.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethVarargsRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, 1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadVarArgsNode readVarargsNode; - - @TruffleBoundary - public HPyMethVarargsRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyVarargsToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - Object[] args = getVarargs(frame); - return new Object[]{getSelf(frame), hpyContext.createArgumentsArray(args), (long) args.length}; - } - - @Override - protected void closeCArguments(VirtualFrame frame, GraalHPyContext hpyContext, Object[] cArguments) { - hpyContext.freeArgumentsArray(cArguments[1]); - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethKeywordsRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, true, 1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadVarArgsNode readVarargsNode; - @Child private ReadVarKeywordsNode readKwargsNode; - - @TruffleBoundary - public HPyMethKeywordsRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyKeywordsToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - Object[] positionalArgs = getVarargs(frame); - PKeyword[] keywords = getKwargs(frame); - long nPositionalArgs = positionalArgs.length; - - Object[] args; - Object kwnamesTuple; - // this condition is implicitly profiled by 'getKwnamesTuple' - if (keywords.length > 0) { - args = PythonUtils.arrayCopyOf(positionalArgs, positionalArgs.length + keywords.length); - TruffleString[] kwnames = new TruffleString[keywords.length]; - for (int i = 0; i < keywords.length; i++) { - args[positionalArgs.length + i] = keywords[i].getValue(); - kwnames[i] = keywords[i].getName(); - } - kwnamesTuple = getKwnamesTuple(kwnames); - } else { - args = positionalArgs; - kwnamesTuple = GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - return new Object[]{getSelf(frame), createArgumentsArray(hpyContext, args), nPositionalArgs, kwnamesTuple}; - } - - @Override - protected void closeCArguments(VirtualFrame frame, GraalHPyContext hpyContext, Object[] cArguments) { - hpyContext.freeArgumentsArray(cArguments[1]); - } - - private Object createArgumentsArray(GraalHPyContext hpyContext, Object[] args) { - return hpyContext.createArgumentsArray(args); - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - private PKeyword[] getKwargs(VirtualFrame frame) { - if (PArguments.getKeywordArguments(frame).length == 0) { - return PKeyword.EMPTY_KEYWORDS; - } - if (readKwargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readKwargsNode = insert(ReadVarKeywordsNode.create()); - } - return (PKeyword[]) readKwargsNode.execute(frame); - } - - private PTuple getKwnamesTuple(TruffleString[] kwnames) { - return PFactory.createTuple(PythonLanguage.get(this), kwnames); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethInitProcRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, true, 1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadVarArgsNode readVarargsNode; - @Child private ReadVarKeywordsNode readKwargsNode; - - @TruffleBoundary - public HPyMethInitProcRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyKeywordsToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - Object[] args = getVarargs(frame); - return new Object[]{getSelf(frame), hpyContext.createArgumentsArray(args), (long) args.length, getKwargs(frame)}; - } - - @Override - protected void closeCArguments(VirtualFrame frame, GraalHPyContext hpyContext, Object[] cArguments) { - hpyContext.freeArgumentsArray(cArguments[1]); - } - - @Override - @SuppressWarnings("unused") - protected Object processResult(VirtualFrame frame, Object result) { - // If no error occurred, the init function always returns None. - // Possible errors are already handled in the HPyExternalFunctionInvokeNode. - return PNone.NONE; - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - private Object getKwargs(VirtualFrame frame) { - if (readKwargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readKwargsNode = insert(ReadVarKeywordsNode.createForUserFunction(EMPTY_TRUFFLESTRING_ARRAY)); - } - return readKwargsNode.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethTernaryRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(3, false, -1, tsArray("x", "y", "z"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private ReadIndexedArgumentNode readArg2Node; - - public HPyMethTernaryRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg1(frame), getArg2(frame)}; - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - private Object getArg2(VirtualFrame frame) { - if (readArg2Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg2Node = insert(ReadIndexedArgumentNode.create(2)); - } - Object arg2 = readArg2Node.execute(frame); - return arg2 != PNone.NO_VALUE ? arg2 : PNone.NONE; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static class HPyMethSSizeArgFuncRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(2, false, -1, tsArray("$self", "n"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - - public HPyMethSSizeArgFuncRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPySSizeArgFuncToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg1(frame)}; - } - - protected Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - /** - * Implements semantics of {@code typeobject.c: wrap_sq_item}. - */ - static final class HPyMethSqItemWrapperRoot extends HPyMethSSizeArgFuncRoot { - - @Child private GetIndexNode getIndexNode; - - public HPyMethSqItemWrapperRoot(PythonLanguage language, TruffleString name) { - super(language, name); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - Object self = getSelf(frame); - return new Object[]{self, getIndex(self, getArg1(frame))}; - } - - private int getIndex(Object self, Object index) { - if (getIndexNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getIndexNode = insert(CExtCommonNodes.GetIndexNode.create()); - } - return getIndexNode.execute(self, index); - } - } - - /** - * Implements semantics of {@code typeobject.c: wrap_sq_setitem}. - */ - static final class HPyMethSqSetitemWrapperRoot extends HPyMethSSizeObjArgProcRoot { - - @Child private GetIndexNode getIndexNode; - - public HPyMethSqSetitemWrapperRoot(PythonLanguage language, TruffleString name) { - super(language, name); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - Object self = getSelf(frame); - return new Object[]{self, getIndex(self, getArg1(frame)), getArg2(frame)}; - } - - private int getIndex(Object self, Object index) { - if (getIndexNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getIndexNode = insert(CExtCommonNodes.GetIndexNode.create()); - } - return getIndexNode.execute(self, index); - } - } - - static final class HPyMethSSizeSSizeArgFuncRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(3, false, -1, tsArray("$self", "n", "m"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private ReadIndexedArgumentNode readArg2Node; - - public HPyMethSSizeSSizeArgFuncRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPySSizeArgFuncToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg1(frame), getArg2(frame)}; - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - private Object getArg2(VirtualFrame frame) { - if (readArg2Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg2Node = insert(ReadIndexedArgumentNode.create(2)); - } - return readArg2Node.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - /** - * Very similar to {@link HPyMethNoargsRoot} but converts the result to a boolean. - */ - static final class HPyMethInquiryRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE); - - public HPyMethInquiryRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame)}; - } - - @Override - protected Object processResult(VirtualFrame frame, Object result) { - // 'HPyCheckPrimitiveResultNode' already guarantees that the result is 'int' or 'long'. - return intToBoolean(result); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethObjObjArgProcRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, 1, tsArray("$self", "x"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private ReadVarArgsNode readVarargsNode; - private final BranchProfile errorProfile = BranchProfile.create(); - - public HPyMethObjObjArgProcRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - Object[] varargs = getVarargs(frame); - if (varargs.length == 0) { - return new Object[]{getSelf(frame), getArg1(frame), PNone.NO_VALUE}; - } else if (varargs.length == 1) { - return new Object[]{getSelf(frame), getArg1(frame), varargs[0]}; - } else { - throw PRaiseNode.raiseStatic(this, PythonBuiltinClassType.TypeError, - ErrorMessages.TAKES_FROM_D_TO_D_POS_ARG_S_BUT_D_S_GIVEN_S, - getName(), 2, 3, "s", 1 + varargs.length, "were", ""); - } - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - @Override - protected Object processResult(VirtualFrame frame, Object result) { - // 'HPyCheckPrimitiveResultNode' already guarantees that the result is 'int' or 'long'. - return intToBoolean(result); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethObjObjProcRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(2, false, -1, tsArray("$self", "other"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - - public HPyMethObjObjProcRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg1(frame)}; - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - @Override - protected Object processResult(VirtualFrame frame, Object result) { - // 'HPyCheckPrimitiveResultNode' already guarantees that the result is 'int' or 'long'. - return intToBoolean(result); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static class HPyMethSSizeObjArgProcRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(3, false, -1, tsArray("$self", "arg0", "arg1"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private ReadIndexedArgumentNode readArg2Node; - - public HPyMethSSizeObjArgProcRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPySSizeObjArgProcToSulongNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), getArg1(frame), getArg2(frame)}; - } - - protected Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - protected Object getArg2(VirtualFrame frame) { - if (readArg2Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg2Node = insert(ReadIndexedArgumentNode.create(2)); - } - return readArg2Node.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethReverseBinaryRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("self", "other"), KEYWORDS_HIDDEN_CALLABLE, true); - - @Child private ReadIndexedArgumentNode readOtherNode; - - public HPyMethReverseBinaryRoot(PythonLanguage language, TruffleString name, boolean nativePrimitiveResult) { - super(language, name, nativePrimitiveResult ? HPyCheckPrimitiveResultNodeGen.create() : HPyCheckHandleResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getOther(frame), getSelf(frame)}; - } - - private Object getOther(VirtualFrame frame) { - if (readOtherNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readOtherNode = insert(ReadIndexedArgumentNode.create(1)); - } - return readOtherNode.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - public abstract static class HPyCheckFunctionResultNode extends Node { - - public abstract Object execute(PythonThreadState pythonThreadState, TruffleString name, Object value); - } - - // roughly equivalent to _Py_CheckFunctionResult in Objects/call.c - @GenerateUncached - @GenerateInline(false) - @ImportStatic(PGuards.class) - public abstract static class HPyCheckHandleResultNode extends HPyCheckFunctionResultNode { - - @Specialization - static Object doLongNull(PythonThreadState pythonThreadState, TruffleString name, Object value, - @Bind("this") Node inliningTarget, - @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode, - @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { - Object delegate = closeAndGetHandleNode.execute(inliningTarget, value); - transformExceptionFromNativeNode.execute(inliningTarget, pythonThreadState, name, delegate == GraalHPyHandle.NULL_HANDLE_DELEGATE, true); - return delegate; - } - } - - /** - * Similar to {@link HPyCheckFunctionResultNode}, this node checks a primitive result of a - * native function. This node guarantees that an {@code int} or {@code long} is returned. - */ - @GenerateUncached - @GenerateInline(false) - @ImportStatic(PGuards.class) - abstract static class HPyCheckPrimitiveResultNode extends HPyCheckFunctionResultNode { - public abstract int executeInt(PythonThreadState context, TruffleString name, int value); - - public abstract long executeLong(PythonThreadState context, TruffleString name, long value); - - @Specialization - static int doInteger(PythonThreadState pythonThreadState, TruffleString name, int value, - @Bind("this") Node inliningTarget, - @Shared @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { - transformExceptionFromNativeNode.execute(inliningTarget, pythonThreadState, name, value == -1, false); - return value; - } - - @Specialization(replaces = "doInteger") - static long doLong(PythonThreadState pythonThreadState, TruffleString name, long value, - @Bind("this") Node inliningTarget, - @Shared @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { - transformExceptionFromNativeNode.execute(inliningTarget, pythonThreadState, name, value == -1, false); - return value; - } - - @Specialization(limit = "1") - static Object doObject(PythonThreadState pythonThreadState, TruffleString name, Object value, - @Bind("this") Node inliningTarget, - @CachedLibrary("value") InteropLibrary lib, - @Shared @Cached PRaiseNode raiseNode, - @Shared @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { - if (lib.fitsInLong(value)) { - try { - long lvalue = lib.asLong(value); - transformExceptionFromNativeNode.execute(inliningTarget, pythonThreadState, name, lvalue == -1, false); - return lvalue; - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - throw raiseNode.raise(inliningTarget, SystemError, ErrorMessages.FUNC_S_DIDNT_RETURN_INT, name); - } - } - - /** - * Does not actually check the result of a function (since this is used when {@code void} - * functions are called) but checks if an error occurred during execution of the function. - */ - @GenerateUncached - @GenerateInline(false) - @ImportStatic(PGuards.class) - abstract static class HPyCheckVoidResultNode extends HPyCheckFunctionResultNode { - - @Specialization - static Object doGeneric(PythonThreadState threadState, TruffleString name, Object value, - @Bind("this") Node inliningTarget, - @Cached TransformExceptionFromNativeNode transformExceptionFromNativeNode) { - /* - * A 'void' function never indicates an error but an error could still happen. So this - * must also be checked. The actual result value (which will be something like NULL or - * 0) is not used. - */ - transformExceptionFromNativeNode.execute(inliningTarget, threadState, name, false, true); - return value; - } - } - - static final class HPyMethRichcmpOpRootNode extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("self", "other"), KEYWORDS_HIDDEN_CALLABLE, true); - @Child private ReadIndexedArgumentNode readArgNode; - - private final int op; - - HPyMethRichcmpOpRootNode(PythonLanguage language, TruffleString name, int op) { - super(language, name, HPyRichcmpFuncArgsToSulongNodeGen.create()); - this.readArgNode = ReadIndexedArgumentNode.create(1); - this.op = op; - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame), readArgNode.execute(frame), op}; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - /** - * A simple and lightweight Python root node that invokes a native getter function. The native - * call target and the native closure pointer are passed as Python closure. - */ - abstract static class HPyGetSetDescriptorRootNode extends PRootNode { - - @Child private CalleeContext calleeContext; - @Child private HPyExternalFunctionInvokeNode invokeNode; - @Child private ReadIndexedArgumentNode readCallableNode; - @Child private ReadIndexedArgumentNode readContextNode; - @Child private ReadIndexedArgumentNode readClosureNode; - - private final TruffleString name; - - HPyGetSetDescriptorRootNode(PythonLanguage language, TruffleString name) { - super(language); - this.name = name; - } - - @Override - public Object execute(VirtualFrame frame) { - getCalleeContext().enter(frame); - try { - Object target = readCallable(frame); - GraalHPyContext hpyContext = readContext(frame); - Object closure = readClosure(frame); - return ensureInvokeNode().execute(frame, name, target, hpyContext, createArguments(frame, closure)); - } finally { - getCalleeContext().exit(frame, this); - } - } - - protected abstract HPyConvertArgsToSulongNode createArgumentConversionNode(); - - protected abstract HPyCheckFunctionResultNode createResultConversionNode(); - - protected abstract Object[] createArguments(VirtualFrame frame, Object closure); - - @Override - public String getName() { - return name.toJavaStringUncached(); - } - - private CalleeContext getCalleeContext() { - if (calleeContext == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - calleeContext = insert(CalleeContext.create()); - } - return calleeContext; - } - - private HPyExternalFunctionInvokeNode ensureInvokeNode() { - if (invokeNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - invokeNode = insert(HPyExternalFunctionInvokeNodeGen.create(createResultConversionNode(), createArgumentConversionNode())); - } - return invokeNode; - } - - protected final Object readCallable(VirtualFrame frame) { - if (readCallableNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden argument after the hidden context argument - int hiddenArg = getSignature().getParameterIds().length + 1; - readCallableNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - return readCallableNode.execute(frame); - } - - private GraalHPyContext readContext(VirtualFrame frame) { - if (readContextNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden argument at the end of the positional arguments - int hiddenArg = getSignature().getParameterIds().length; - readContextNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - Object hpyContext = readContextNode.execute(frame); - if (hpyContext instanceof GraalHPyContext) { - return (GraalHPyContext) hpyContext; - } - throw CompilerDirectives.shouldNotReachHere("invalid HPy context"); - } - - protected final Object readClosure(VirtualFrame frame) { - if (readClosureNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - // we insert a hidden closure argument after the hidden context arg - int hiddenArg = getSignature().getParameterIds().length + 2; - readClosureNode = insert(ReadIndexedArgumentNode.create(hiddenArg)); - } - return readClosureNode.execute(frame); - } - - @Override - public boolean isPythonInternal() { - return true; - } - - @Override - public boolean isInternal() { - return true; - } - - @Override - public boolean setsUpCalleeContext() { - return true; - } - } - - /** - * A simple and lightweight Python root node that invokes a native getter function. The native - * call target and the native closure pointer are passed as Python closure. - */ - static final class HPyGetSetDescriptorGetterRootNode extends HPyGetSetDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("$self"), KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE, true); - - HPyGetSetDescriptorGetterRootNode(PythonLanguage language, TruffleString name) { - super(language, name); - } - - @Override - protected Object[] createArguments(VirtualFrame frame, Object closure) { - return new Object[]{PArguments.getArgument(frame, 0), closure}; - } - - @Override - protected HPyConvertArgsToSulongNode createArgumentConversionNode() { - return HPyGetSetGetterToSulongNodeGen.create(); - } - - @Override - protected HPyCheckFunctionResultNode createResultConversionNode() { - return HPyCheckHandleResultNodeGen.create(); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - - @TruffleBoundary - public static PBuiltinFunction createFunction(GraalHPyContext hpyContext, Object enclosingType, TruffleString propertyName, Object target, Object closure) { - PythonContext pythonContext = hpyContext.getContext(); - PythonLanguage lang = pythonContext.getLanguage(); - RootCallTarget callTarget = lang.createCachedCallTarget(l -> new HPyGetSetDescriptorGetterRootNode(l, propertyName), HPyGetSetDescriptorGetterRootNode.class, propertyName); - return PFactory.createBuiltinFunction(lang, propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); - } - } - - static final class HPyLegacyGetSetDescriptorGetterRoot extends GetterRoot { - - @Child private HPyGetNativeSpacePointerNode getNativeSpacePointerNode; - - protected HPyLegacyGetSetDescriptorGetterRoot(PythonLanguage language, TruffleString name, PExternalFunctionWrapper provider) { - super(language, name, provider); - } - - /* - * TODO(fa): It's still unclear how to handle HPy native space pointers when passed to an - * 'AsPythonObjectNode'. This can happen when, e.g., the getter returns the 'self' pointer. - */ - @Override - protected Object[] prepareCArguments(VirtualFrame frame) { - Object[] objects = super.prepareCArguments(frame); - if (getNativeSpacePointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getNativeSpacePointerNode = insert(HPyGetNativeSpacePointerNodeGen.create()); - } - /* - * We now need to pass the native space pointer in a way that the PythonToNativeNode - * correctly exposes the bare pointer object. For this, we pack the pointer into a - * PythonAbstractNativeObject which will just be unwrapped. - */ - Object nativeSpacePtr = getNativeSpacePointerNode.executeCached(objects[0]); - if (nativeSpacePtr == PNone.NO_VALUE) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.ATTEMPTING_GETTER_NO_NATIVE_SPACE); - } - objects[0] = new PythonAbstractNativeObject(nativeSpacePtr); - return objects; - } - - @TruffleBoundary - public static PBuiltinFunction createLegacyFunction(PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { - RootCallTarget rootCallTarget = lang.createCachedCallTarget(l -> new HPyLegacyGetSetDescriptorGetterRoot(l, propertyName, PExternalFunctionWrapper.GETTER), - HPyLegacyGetSetDescriptorGetterRoot.class, propertyName); - if (rootCallTarget == null) { - throw CompilerDirectives.shouldNotReachHere("Calling non-native get descriptor functions is not support in HPy"); - } - target = EnsureExecutableNode.executeUncached(target, PExternalFunctionWrapper.GETTER); - return PFactory.createBuiltinFunction(lang, propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); - } - } - - /** - * A simple and lightweight Python root node that invokes a native setter function. The native - * call target and the native closure pointer are passed as Python closure. - */ - static final class HPyGetSetDescriptorSetterRootNode extends HPyGetSetDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("$self", "value"), KEYWORDS_HIDDEN_CALLABLE_AND_CLOSURE, true); - - private HPyGetSetDescriptorSetterRootNode(PythonLanguage language, TruffleString name) { - super(language, name); - } - - @Override - protected Object[] createArguments(VirtualFrame frame, Object closure) { - return new Object[]{PArguments.getArgument(frame, 0), PArguments.getArgument(frame, 1), closure}; - } - - @Override - protected HPyConvertArgsToSulongNode createArgumentConversionNode() { - return HPyGetSetSetterToSulongNodeGen.create(); - } - - @Override - protected HPyCheckFunctionResultNode createResultConversionNode() { - return HPyCheckPrimitiveResultNodeGen.create(); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - - @TruffleBoundary - public static PBuiltinFunction createFunction(GraalHPyContext hpyContext, Object enclosingType, TruffleString propertyName, Object target, Object closure) { - PythonContext pythonContext = hpyContext.getContext(); - PythonLanguage lang = pythonContext.getLanguage(); - RootCallTarget callTarget = lang.createCachedCallTarget(l -> new HPyGetSetDescriptorSetterRootNode(l, propertyName), HPyGetSetDescriptorSetterRootNode.class, propertyName); - return PFactory.createBuiltinFunction(lang, propertyName, enclosingType, PythonUtils.EMPTY_OBJECT_ARRAY, createKwDefaults(target, closure, hpyContext), 0, callTarget); - } - - } - - static final class HPyLegacyGetSetDescriptorSetterRoot extends SetterRoot { - - @Child private HPyGetNativeSpacePointerNode getNativeSpacePointerNode; - - private HPyLegacyGetSetDescriptorSetterRoot(PythonLanguage language, TruffleString name, PExternalFunctionWrapper provider) { - super(language, name, provider); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame) { - Object[] objects = super.prepareCArguments(frame); - if (getNativeSpacePointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getNativeSpacePointerNode = insert(HPyGetNativeSpacePointerNodeGen.create()); - } - /* - * We now need to pass the native space pointer in a way that the PythonToNativeNode - * correctly exposes the bare pointer object. For this, we pack the pointer into a - * PythonAbstractNativeObject which will just be unwrapped. - */ - Object nativeSpacePtr = getNativeSpacePointerNode.executeCached(objects[0]); - if (nativeSpacePtr == PNone.NO_VALUE) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(this, SystemError, ErrorMessages.ATTEMPTING_SETTER_NO_NATIVE_SPACE); - } - objects[0] = new PythonAbstractNativeObject(nativeSpacePtr); - return objects; - } - - @TruffleBoundary - public static PBuiltinFunction createLegacyFunction(PythonLanguage lang, Object owner, TruffleString propertyName, Object target, Object closure) { - RootCallTarget rootCallTarget = lang.createCachedCallTarget(l -> new HPyLegacyGetSetDescriptorSetterRoot(l, propertyName, PExternalFunctionWrapper.SETTER), - HPyLegacyGetSetDescriptorSetterRoot.class, propertyName); - if (rootCallTarget == null) { - throw CompilerDirectives.shouldNotReachHere("Calling non-native get descriptor functions is not support in HPy"); - } - target = EnsureExecutableNode.executeUncached(target, PExternalFunctionWrapper.SETTER); - return PFactory.createBuiltinFunction(lang, propertyName, owner, PythonUtils.EMPTY_OBJECT_ARRAY, ExternalFunctionNodes.createKwDefaults(target, closure), 0, rootCallTarget); - } - } - - /** - * Root node to call a C functions with signature - * {@code int (*HPyFunc_getbufferproc)(HPyContext ctx, HPy self, HPy_buffer *buffer, int flags)} - * . The {@code buffer} arguments will be created by this root node since it needs the C - * extension context and the result of a call to this function is an instance of - * {@link CExtPyBuffer}. - */ - static final class HPyGetBufferRootNode extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, 1, tsArray("self", "flags"), KEYWORDS_HIDDEN_CALLABLE); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private FromCharPointerNode fromCharPointerNode; - @Child private GraalHPyCAccess.AllocateNode allocateNode; - @Child private GraalHPyCAccess.FreeNode freeNode; - @Child private GraalHPyCAccess.ReadPointerNode readPointerNode; - @Child private GraalHPyCAccess.ReadGenericNode readGenericNode; - @Child private GraalHPyCAccess.ReadHPyNode readHPyNode; - @Child private GraalHPyCAccess.IsNullNode isNullNode; - - @TruffleBoundary - public HPyGetBufferRootNode(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyGetBufferProcToSulongNodeGen.create()); - } - - @Override - public CExtPyBuffer execute(VirtualFrame frame) { - getCalleeContext().enter(frame); - Object bufferPtr = null; - GraalHPyContext hpyContext = null; - try { - Object callable = ensureReadCallableNode().execute(frame); - hpyContext = readContext(frame); - bufferPtr = ensureAllocateNode(hpyContext).malloc(hpyContext, HPyContextSignatureType.HPy_buffer); - Object[] cArguments = new Object[]{getSelf(frame), bufferPtr, getArg1(frame)}; - getInvokeNode().execute(frame, getTSName(), callable, hpyContext, cArguments); - return createPyBuffer(hpyContext, bufferPtr); - } finally { - if (hpyContext != null && bufferPtr != null) { - ensureFreeNode(hpyContext).free(hpyContext, bufferPtr); - } - getCalleeContext().exit(frame, this); - } - } - - /** - * Reads the values from C struct {@code HPy_buffer}, converts them appropriately and - * creates an instance of {@link CExtPyBuffer}. - * - *
    -         *     typedef struct {
    -         *         void *buf;
    -         *         HPy obj;
    -         *         Py_ssize_t len;
    -         *         Py_ssize_t itemsize;
    -         *         int readonly;
    -         *         int ndim;
    -         *         char *format;
    -         *         Py_ssize_t *shape;
    -         *         Py_ssize_t *strides;
    -         *         Py_ssize_t *suboffsets;
    -         *         void *internal;
    -         * } HPy_buffer;
    -         * 
    - * - */ - private CExtPyBuffer createPyBuffer(GraalHPyContext ctx, Object bufferPtr) { - if (readGenericNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readGenericNode = insert(GraalHPyCAccess.ReadGenericNode.create(ctx)); - } - if (readPointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readPointerNode = insert(GraalHPyCAccess.ReadPointerNode.create(ctx)); - } - if (readHPyNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readHPyNode = insert(GraalHPyCAccess.ReadHPyNode.create(ctx)); - } - if (isNullNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - isNullNode = insert(GraalHPyCAccess.IsNullNode.create(ctx)); - } - if (fromCharPointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - fromCharPointerNode = insert(FromCharPointerNodeGen.create()); - } - int len = readGenericNode.readInt(ctx, bufferPtr, GraalHPyCField.HPy_buffer__len); - Object buf = readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__buf); - /* - * Since we are now the owner of the handle and no one else will ever use it, we need to - * close it. - */ - Object owner = readHPyNode.readAndClose(ctx, bufferPtr, GraalHPyCField.HPy_buffer__obj); - - int ndim = readGenericNode.readInt(ctx, bufferPtr, GraalHPyCField.HPy_buffer__ndim); - int itemSize = readGenericNode.readInt(ctx, bufferPtr, GraalHPyCField.HPy_buffer__itemsize); - boolean readonly = readGenericNode.readInt(ctx, bufferPtr, GraalHPyCField.HPy_buffer__readonly) != 0; - TruffleString format = fromCharPointerNode.execute(readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__format)); - Object shapePtr = readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__shape); - Object stridesPtr = readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__strides); - Object suboffsetsPtr = readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__suboffsets); - Object internal = readPointerNode.read(ctx, bufferPtr, GraalHPyCField.HPy_buffer__internal); - int[] shape = null; - int[] strides = null; - int[] subOffsets = null; - if (ndim > 0) { - if (!isNullNode.execute(ctx, shapePtr)) { - shape = readLongAsIntArray(ctx, shapePtr, ndim); - } - if (!isNullNode.execute(ctx, stridesPtr)) { - strides = readLongAsIntArray(ctx, stridesPtr, ndim); - } - if (!isNullNode.execute(ctx, suboffsetsPtr)) { - subOffsets = readLongAsIntArray(ctx, suboffsetsPtr, ndim); - } - } - return new CExtPyBuffer(buf, owner, len, itemSize, readonly, ndim, format, shape, strides, subOffsets, internal); - } - - private int[] readLongAsIntArray(GraalHPyContext ctx, Object pointer, int elements) { - GraalHPyCAccess.ReadGenericNode readI64Node = ensureReadGenericNode(ctx); - int elemSize = ctx.getCTypeSize(HPyContextSignatureType.HPy_ssize_t); - int[] result = new int[elements]; - for (int i = 0; i < result.length; i++) { - result[i] = readI64Node.executeInt(ctx, pointer, (long) i * elemSize, HPyContextSignatureType.HPy_ssize_t); - } - return result; - } - - private GraalHPyCAccess.AllocateNode ensureAllocateNode(GraalHPyContext ctx) { - if (allocateNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - allocateNode = insert(GraalHPyCAccess.AllocateNode.create(ctx)); - } - return allocateNode; - } - - private GraalHPyCAccess.FreeNode ensureFreeNode(GraalHPyContext ctx) { - if (freeNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - freeNode = insert(GraalHPyCAccess.FreeNode.create(ctx)); - } - return freeNode; - } - - private GraalHPyCAccess.ReadGenericNode ensureReadGenericNode(GraalHPyContext ctx) { - if (readGenericNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readGenericNode = insert(GraalHPyCAccess.ReadGenericNode.create(ctx)); - } - return readGenericNode; - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - throw CompilerDirectives.shouldNotReachHere(); - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - /** - * Root node to call a C functions with signature - * {@code void (*HPyFunc_releasebufferproc)(HPyContext ctx, HPy self, HPy_buffer *buffer)} . - */ - static final class HPyReleaseBufferRootNode extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, 1, tsArray("self", "buffer"), KEYWORDS_HIDDEN_CALLABLE); - - @Child private ReadIndexedArgumentNode readArg1Node; - @Child private GraalHPyCAccess.FreeNode freeNode; - @Child private GraalHPyCAccess.ReadPointerNode readPointerNode; - @Child private GraalHPyCAccess.ReadHPyNode readHPyNode; - - @TruffleBoundary - public HPyReleaseBufferRootNode(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckVoidResultNodeGen.create(), HPyReleaseBufferProcToSulongNodeGen.create()); - } - - @Override - public Object execute(VirtualFrame frame) { - getCalleeContext().enter(frame); - try { - Object callable = ensureReadCallableNode().execute(frame); - GraalHPyContext hpyContext = readContext(frame); - Object arg1 = getArg1(frame); - if (!(arg1 instanceof CExtPyBuffer buffer)) { - throw CompilerDirectives.shouldNotReachHere("invalid argument"); - } - GraalHPyBuffer hpyBuffer = new GraalHPyBuffer(hpyContext, buffer); - try { - getInvokeNode().execute(frame, getTSName(), callable, hpyContext, new Object[]{getSelf(frame), hpyBuffer}); - } finally { - if (hpyBuffer.isPointer()) { - hpyBuffer.free(hpyContext, ensureFreeNode(hpyContext), ensureReadPointerNode(hpyContext), ensureReadHPyNode(hpyContext)); - } - } - return PNone.NONE; - } finally { - getCalleeContext().exit(frame, this); - } - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - throw CompilerDirectives.shouldNotReachHere(); - } - - @Override - protected Object processResult(VirtualFrame frame, Object result) { - throw CompilerDirectives.shouldNotReachHere(); - } - - private Object getArg1(VirtualFrame frame) { - if (readArg1Node == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readArg1Node = insert(ReadIndexedArgumentNode.create(1)); - } - return readArg1Node.execute(frame); - } - - private GraalHPyCAccess.FreeNode ensureFreeNode(GraalHPyContext ctx) { - if (freeNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - freeNode = insert(GraalHPyCAccess.FreeNode.create(ctx)); - } - return freeNode; - } - - private GraalHPyCAccess.ReadPointerNode ensureReadPointerNode(GraalHPyContext ctx) { - if (readPointerNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readPointerNode = insert(GraalHPyCAccess.ReadPointerNode.create(ctx)); - } - return readPointerNode; - } - - private GraalHPyCAccess.ReadHPyNode ensureReadHPyNode(GraalHPyContext ctx) { - if (readHPyNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readHPyNode = insert(GraalHPyCAccess.ReadHPyNode.create(ctx)); - } - return readHPyNode; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - /** - * Very similar to {@link HPyMethNoargsRoot} but converts the result to a boolean. - */ - static final class HPyMethHashRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, false, -1, tsArray("self"), KEYWORDS_HIDDEN_CALLABLE); - - public HPyMethHashRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyCheckPrimitiveResultNodeGen.create(), HPyAllAsHandleNodeGen.create()); - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, @SuppressWarnings("unused") GraalHPyContext hpyContext) { - return new Object[]{getSelf(frame)}; - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } - - static final class HPyMethCallRoot extends HPyMethodDescriptorRootNode { - private static final Signature SIGNATURE = new Signature(-1, true, 1, tsArray("self"), KEYWORDS_HIDDEN_CONTEXT, true); - - @Child private ReadVarArgsNode readVarargsNode; - @Child private ReadVarKeywordsNode readKwargsNode; - - @TruffleBoundary - public HPyMethCallRoot(PythonLanguage language, TruffleString name) { - super(language, name, HPyKeywordsToSulongNodeGen.create()); - } - - @Override - public Object execute(VirtualFrame frame) { - GraalHPyContext hpyContext = readContext(frame); - Object[] cArguments = prepareCArguments(frame, hpyContext); - Object self = cArguments[0]; - Object callable; - if (self instanceof PythonObject pythonObject) { - callable = GraalHPyData.getHPyCallFunction(pythonObject); - } else { - callable = null; - } - if (callable == null) { - throw PRaiseNode.raiseStatic(this, TypeError, ErrorMessages.HPY_OBJECT_DOES_NOT_SUPPORT_CALL, self); - } - - getCalleeContext().enter(frame); - try { - return getInvokeNode().execute(frame, getTSName(), callable, hpyContext, cArguments); - } finally { - getCalleeContext().exit(frame, this); - closeCArguments(frame, hpyContext, cArguments); - } - } - - @Override - protected Object[] prepareCArguments(VirtualFrame frame, GraalHPyContext hpyContext) { - Object[] positionalArgs = getVarargs(frame); - PKeyword[] keywords = getKwargs(frame); - long nPositionalArgs = positionalArgs.length; - - Object[] args; - Object kwnamesTuple; - // this condition is implicitly profiled by 'getKwnamesTuple' - if (keywords.length > 0) { - args = PythonUtils.arrayCopyOf(positionalArgs, positionalArgs.length + keywords.length); - TruffleString[] kwnames = new TruffleString[keywords.length]; - for (int i = 0; i < keywords.length; i++) { - args[positionalArgs.length + i] = keywords[i].getValue(); - kwnames[i] = keywords[i].getName(); - } - kwnamesTuple = getKwnamesTuple(kwnames); - } else { - args = positionalArgs; - kwnamesTuple = GraalHPyHandle.NULL_HANDLE_DELEGATE; - } - return new Object[]{getSelf(frame), createArgumentsArray(hpyContext, args), nPositionalArgs, kwnamesTuple}; - } - - @Override - protected void closeCArguments(VirtualFrame frame, GraalHPyContext hpyContext, Object[] cArguments) { - hpyContext.freeArgumentsArray(cArguments[1]); - } - - private Object createArgumentsArray(GraalHPyContext hpyContext, Object[] args) { - return hpyContext.createArgumentsArray(args); - } - - private Object[] getVarargs(VirtualFrame frame) { - if (readVarargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readVarargsNode = insert(ReadVarArgsNode.create(true)); - } - return readVarargsNode.executeObjectArray(frame); - } - - private PKeyword[] getKwargs(VirtualFrame frame) { - if (PArguments.getKeywordArguments(frame).length == 0) { - return PKeyword.EMPTY_KEYWORDS; - } - if (readKwargsNode == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - readKwargsNode = insert(ReadVarKeywordsNode.create()); - } - return (PKeyword[]) readKwargsNode.execute(frame); - } - - private PTuple getKwnamesTuple(TruffleString[] kwnames) { - return PFactory.createTuple(PythonLanguage.get(this), kwnames); - } - - @Override - public Signature getSignature() { - return SIGNATURE; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyMode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyMode.java deleted file mode 100644 index 0191a7054a..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyMode.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; - -public enum HPyMode { - MODE_INVALID(-1), - MODE_UNIVERSAL(0), - MODE_DEBUG(1), - MODE_TRACE(2); - /* - * We do currently not test the combinations of debug and trace mode, so we do not offer them - * right now. This may change in future. - */ - // DEBUG_TRACE(3), - // TRACE_DEBUG(4) - - private final int value; - - HPyMode(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - - @TruffleBoundary - public static HPyMode fromValue(int i) { - for (HPyMode mode : values()) { - if (mode.value == i) { - return mode; - } - } - return MODE_INVALID; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyTypeExtra.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyTypeExtra.java deleted file mode 100644 index 16a6c18c4e..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/HPyTypeExtra.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy; - -public final class HPyTypeExtra { - public final long flags; - public final long basicSize; - public final long itemSize; - public final Object tpName; - public final int builtinShape; - - public Object defaultCallFunc; - public Object hpyDestroyFunc; - public long vectorcallOffset = Long.MIN_VALUE; - - public HPyTypeExtra(long flags, long basicSize, long itemSize, Object tpName, int builtinShape) { - this.flags = flags; - this.basicSize = basicSize; - this.itemSize = itemSize; - this.tpName = tpName; - this.builtinShape = builtinShape; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/PythonHPyObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/PythonHPyObject.java deleted file mode 100644 index a632fa184e..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/PythonHPyObject.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2021, 2023, 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.builtins.objects.cext.hpy; - -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.truffle.api.object.Shape; - -public final class PythonHPyObject extends PythonObject { - - public PythonHPyObject(Object pythonClass, Shape instanceShape, Object hpyNativeSpace) { - super(pythonClass, instanceShape); - if (hpyNativeSpace != null) { - GraalHPyData.setHPyNativeSpace(this, hpyNativeSpace); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNICallHelperFunctionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNICallHelperFunctionNode.java deleted file mode 100644 index 237f547787..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNICallHelperFunctionNode.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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.builtins.objects.cext.hpy.jni; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.HPyJNIFromCharPointerNode; -import com.oracle.truffle.api.CompilerDirectives; - -/** - * This is the implementation of {@link HPyCallHelperFunctionNode} for the JNI backend. This node - * calls helper functions also via JNI. The goal of this node is minimal footprint and best - * uncached/interpreter performance. - */ -final class GraalHPyJNICallHelperFunctionNode extends HPyCallHelperFunctionNode { - - static final GraalHPyJNICallHelperFunctionNode UNCACHED = new GraalHPyJNICallHelperFunctionNode(); - - private GraalHPyJNICallHelperFunctionNode() { - } - - @Override - protected Object execute(GraalHPyContext context, GraalHPyNativeSymbol name, Object[] args) { - assert context.getBackend() instanceof GraalHPyJNIContext; - return switch (name) { - case GRAAL_HPY_GET_ERRNO -> GraalHPyJNIContext.getErrno(); - case GRAAL_HPY_GET_STRERROR -> GraalHPyJNIContext.getStrerror((int) args[0]); - case GRAAL_HPY_STRLEN -> HPyJNIFromCharPointerNode.strlen((long) args[0]); - default -> throw CompilerDirectives.shouldNotReachHere("not yet implemented"); - }; - } - - @Override - public boolean isAdoptable() { - return false; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java deleted file mode 100644 index 39d0935434..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIContext.java +++ /dev/null @@ -1,3010 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.builtins.objects.cext.hpy.jni; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError; -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; -import static com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.UNSAFE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.IMMUTABLE_HANDLE_COUNT; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_ELIPSIS; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_NONE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_NOT_IMPLEMENTED; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SIZEOF_LONG; -import static com.oracle.graal.python.nodes.StringLiterals.J_DEBUG; -import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; -import static com.oracle.graal.python.nodes.StringLiterals.J_TRACE; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.toTruffleStringUncached; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.IOException; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.Python3Core; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.bytes.PBytes; -import com.oracle.graal.python.builtins.objects.capsule.PyCapsule; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.AsNativePrimitiveNodeGen; -import com.oracle.graal.python.builtins.objects.cext.common.CExtContext; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyBoxing; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.BulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.FreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.GetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.IsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCField; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyABIVersion; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyUpcall; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.CapsuleKey; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyCapsuleGet; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyContextFunction; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyContextVarGet; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.HPyBinaryContextFunction; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.HPyTernaryContextFunction; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyData; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyGetNativeSpacePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyRaiseNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyTransformExceptionToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyTypeGetNameNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.GraalHPyModuleCreateNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.GraalHPyModuleExecNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsNativeInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsPythonObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyPackKeywordArgsNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyRaiseNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextMember; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignature; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyMode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeAllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeBulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeFreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeGetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeIsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodes.UnsafeWriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodesFactory.HPyJNIAsCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNINodesFactory.HPyJNIFromCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; -import com.oracle.graal.python.builtins.objects.common.EmptyStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorage; -import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageSetItem; -import com.oracle.graal.python.builtins.objects.contextvars.PContextVar; -import com.oracle.graal.python.builtins.objects.dict.PDict; -import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis; -import com.oracle.graal.python.builtins.objects.function.PKeyword; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.list.PList; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.builtins.objects.tuple.PTuple; -import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass; -import com.oracle.graal.python.builtins.objects.type.PythonClass; -import com.oracle.graal.python.builtins.objects.type.TypeNodes; -import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode; -import com.oracle.graal.python.lib.PyFloatAsDoubleNode; -import com.oracle.graal.python.lib.PyLongAsDoubleNode; -import com.oracle.graal.python.lib.PyNumberCheckNode; -import com.oracle.graal.python.lib.PyObjectGetAttr; -import com.oracle.graal.python.lib.PyObjectGetItem; -import com.oracle.graal.python.lib.PyObjectSetItem; -import com.oracle.graal.python.lib.PyObjectSizeNodeGen; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PGuards; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.nodes.call.CallNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNode; -import com.oracle.graal.python.nodes.classes.IsSubtypeNodeGen; -import com.oracle.graal.python.nodes.object.GetClassNode; -import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; -import com.oracle.graal.python.nodes.object.IsNodeGen; -import com.oracle.graal.python.nodes.util.CannotCastException; -import com.oracle.graal.python.nodes.util.CastToJavaIntExactNode; -import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.PythonOptions.HPyBackendMode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.runtime.object.PFactory; -import com.oracle.graal.python.runtime.sequence.PSequence; -import com.oracle.graal.python.runtime.sequence.storage.DoubleSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.IntSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.LongSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.ObjectSequenceStorage; -import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.TruffleFile; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnknownIdentifierException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.strings.InternalByteArray; -import com.oracle.truffle.api.strings.NativeAllocator; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.AsNativeNode; -import com.oracle.truffle.api.strings.TruffleString.Encoding; -import com.oracle.truffle.api.strings.TruffleString.GetInternalByteArrayNode; -import com.oracle.truffle.api.strings.TruffleString.GetInternalNativePointerNode; -import com.oracle.truffle.api.strings.TruffleString.SwitchEncodingNode; - -/** - * This object is used to override specific native upcall pointers in the HPyContext. This is - * queried for every member of HPyContext by {@code graal_hpy_context_to_native}, and overrides the - * original values (which are NFI closures for functions in {@code hpy.c}, subsequently calling into - * {@link GraalHPyContextFunctions}. - */ -@ExportLibrary(InteropLibrary.class) -public final class GraalHPyJNIContext extends GraalHPyNativeContext { - - private static final String J_NAME = "HPy Universal ABI (GraalVM JNI backend)"; - - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyJNIContext.class); - - static final NativeAllocator TS_NATIVE_ALLOCATOR = byteSize -> new NativePointer(UNSAFE.allocateMemory(byteSize)); - - private static boolean jniBackendLoaded = false; - - private final int[] counts; - - private final int[] ctypeSizes; - private final int[] cfieldOffsets; - - private long hPyDebugContext; - private long hPyTraceContext; - private long nativePointer; - - /** - * This list holds a strong reference to all loaded extension libraries to keep the library - * objects alive. This is necessary because NFI will {@code dlclose} the library (and thus - * {@code munmap} all code) if the library object is no longer reachable. However, it can happen - * that we still store raw function pointers (as Java {@code long} values) in - * {@link GraalHPyJNIFunctionPointer} objects which are invoked asynchronously. For - * example, destroy functions will be executed on a different thread some time after the object - * died. Buffer release functions run on the main thread but like an async action at some - * unknown point in time after the buffer owner died. - * - * Since we have no control over the execution order of those cleaners, we need to ensure that - * the code is still mapped. - */ - private final List loadedExtensions = new LinkedList<>(); - - public GraalHPyJNIContext(GraalHPyContext context, boolean traceUpcalls) { - super(context, traceUpcalls); - assert !PythonImageBuildOptions.WITHOUT_JNI; - this.counts = traceUpcalls ? new int[HPyJNIUpcall.VALUES.length] : null; - this.ctypeSizes = new int[HPyContextSignatureType.values().length]; - this.cfieldOffsets = new int[GraalHPyCField.values().length]; - } - - @Override - protected String getName() { - return J_NAME; - } - - @Override - protected Object loadExtensionLibrary(Node location, PythonContext context, TruffleString name, TruffleString path) throws ImportException { - CompilerAsserts.neverPartOfCompilation(); - TruffleFile extLibFile = context.getPublicTruffleFileRelaxed(path, context.getSoAbi()); - try { - /* - * Even in the JNI backend, we load the library with NFI (instead of using - * 'System.load') because NFI may take care of additional security checks. - */ - String src = "load \"" + extLibFile + '"'; - Source loadSrc = Source.newBuilder(J_NFI_LANGUAGE, src, "load:" + name).internal(true).build(); - Object extLib = context.getEnv().parseInternal(loadSrc).call(); - loadedExtensions.add(extLib); - return extLib; - } catch (SecurityException e) { - throw new ImportException(CExtContext.wrapJavaException(e, location), name, path, ErrorMessages.CANNOT_LOAD_M, path, e); - } - } - - @Override - protected HPyABIVersion getHPyABIVersion(Object extLib, String getMajorVersionFuncName, String getMinorVersionFuncName) throws UnknownIdentifierException { - CompilerAsserts.neverPartOfCompilation(); - try { - InteropLibrary lib = InteropLibrary.getUncached(extLib); - Object majorVersionFun = lib.readMember(extLib, getMajorVersionFuncName); - Object minorVersionFun = lib.readMember(extLib, getMinorVersionFuncName); - int requiredMajorVersion = (int) GraalHPyJNITrampolines.executeModuleInit(coerceToPointer(majorVersionFun)); - int requiredMinorVersion = (int) GraalHPyJNITrampolines.executeModuleInit(coerceToPointer(minorVersionFun)); - return new HPyABIVersion(requiredMajorVersion, requiredMinorVersion); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - - @Override - protected Object initHPyModule(Object extLib, String initFuncName, TruffleString name, TruffleString path, HPyMode mode) - throws ImportException, ApiInitException { - CompilerAsserts.neverPartOfCompilation(); - /* - * We eagerly initialize the debug mode here to be able to produce an error message now if - * we cannot use it. - */ - if (Objects.requireNonNull(mode) == HPyMode.MODE_DEBUG) { - initHPyDebugContext(); - } else if (mode == HPyMode.MODE_TRACE) { - initHPyTraceContext(); - } - - Object initFunction; - try { - InteropLibrary lib = InteropLibrary.getUncached(extLib); - initFunction = lib.readMember(extLib, initFuncName); - } catch (UnknownIdentifierException | UnsupportedMessageException e1) { - throw new ImportException(null, name, path, ErrorMessages.CANNOT_INITIALIZE_EXT_NO_ENTRY, name, path, initFuncName); - } - // NFI doesn't know if a symbol is executable, so it always reports false - assert !InteropLibrary.getUncached().isExecutable(initFunction); - - // coerce 'initFunction' to a native pointer and invoke it via JNI trampoline - long moduleDefPtr; - moduleDefPtr = GraalHPyJNITrampolines.executeModuleInit(coerceToPointer(initFunction)); - return convertLongArg(HPyContextSignatureType.HPyModuleDefPtr, moduleDefPtr); - } - - @Override - protected HPyUpcall[] getUpcalls() { - return HPyJNIUpcall.VALUES; - } - - @Override - protected int[] getUpcallCounts() { - return counts; - } - - @Override - protected int getCTypeSize(HPyContextSignatureType ctype) { - return ctypeSizes[ctype.ordinal()]; - } - - @Override - protected int getCFieldOffset(GraalHPyCField cfield) { - return cfieldOffsets[cfield.ordinal()]; - } - - @Override - protected NativePointer nativeToInteropPointer(Object object) { - assert object instanceof Long; - return new NativePointer((Long) object); - } - - static long interopPointerToNative(Object object, InteropLibrary lib) { - if (!lib.isPointer(object)) { - lib.toNative(object); - } - try { - return lib.asPointer(object); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Override - protected Object getNativeNull() { - return 0L; - } - - @ExportMessage - boolean isPointer() { - return nativePointer != 0; - } - - @ExportMessage - long asPointer() throws UnsupportedMessageException { - if (isPointer()) { - return nativePointer; - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw UnsupportedMessageException.create(); - } - - /** - * Internal method for transforming the HPy universal context to native. This is mostly like the - * interop message {@code toNative} but may of course fail if native access is not allowed. This - * method can be used to force the context to native if a native pointer is needed that will be - * handed to a native (e.g. JNI or NFI) function. - */ - @Override - protected void toNativeInternal() { - if (nativePointer == 0) { - CompilerDirectives.transferToInterpreter(); - assert PythonLanguage.get(null).getEngineOption(PythonOptions.HPyBackend) == HPyBackendMode.JNI; - if (!getContext().getEnv().isNativeAccessAllowed()) { - throw new RuntimeException(ErrorMessages.NATIVE_ACCESS_NOT_ALLOWED.toJavaStringUncached()); - } - loadJNIBackend(); - nativePointer = initJNI(this, context, createContextHandleArray(), ctypeSizes, cfieldOffsets); - if (nativePointer == 0) { - throw CompilerDirectives.shouldNotReachHere("Could not initialize HPy JNI backend."); - } - } - } - - @Override - protected void initNativeFastPaths() { - /* - * Currently, the native fast path functions are only available if the JNI backend is used - * because they rely on 'initJNI' being called. In the future, we might also want to use the - * native fast path functions for the NFI backend. - */ - assert useNativeFastPaths(); - initJNINativeFastPaths(nativePointer); - } - - @SuppressWarnings("restricted") - public void loadJNIBackend() { - if (!getContext().getEnv().isPreInitialization() && !jniBackendLoaded) { - String pythonJNIPath; - pythonJNIPath = getJNILibrary(); - try { - LOGGER.fine("Loading HPy JNI backend from " + pythonJNIPath); - System.load(pythonJNIPath); - jniBackendLoaded = true; - } catch (NullPointerException | UnsatisfiedLinkError e) { - LOGGER.severe("HPy JNI backend library could not be found: " + pythonJNIPath); - LOGGER.severe("Error was: " + e); - } - } - } - - public static String getJNILibrary() { - CompilerAsserts.neverPartOfCompilation(); - PythonContext context = PythonContext.get(null); - TruffleFile libPath = context.getPublicTruffleFileRelaxed(context.getJNIHome()).resolve(PythonContext.J_PYTHON_JNI_LIBRARY_NAME).getAbsoluteFile(); - try { - return libPath.getCanonicalFile().toString(); - } catch (IOException e) { - LOGGER.severe(String.format("Cannot determine canonical path for %s: %s", libPath, e)); - throw new IllegalStateException(e); - } - } - - @Override - protected void initNativeContext() { - /* - * We eagerly initialize any native resources (e.g. allocating off-heap memory for - * 'HPyContext') for the JNI backend because this method will be called if we are up to load - * an HPy extension module with the JNI backend and there is no way to run the JNI backend - * without native resources. - */ - toNative(); - } - - @Override - protected void finalizeNativeContext() { - finalizeJNIContext(nativePointer); - nativePointer = 0; - if (hPyDebugContext != 0) { - finalizeJNIDebugContext(hPyDebugContext); - hPyDebugContext = 0; - } - if (hPyTraceContext != 0) { - finalizeJNITraceContext(hPyTraceContext); - hPyTraceContext = 0; - } - loadedExtensions.clear(); - } - - @Override - public void initHPyDebugContext() throws ApiInitException { - if (hPyDebugContext == 0) { - CompilerDirectives.transferToInterpreter(); - if (!getContext().getEnv().isNativeAccessAllowed() || getContext().getLanguage().getEngineOption(PythonOptions.HPyBackend) != HPyBackendMode.JNI) { - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_DEBUG); - } - try { - toNativeInternal(); - long debugCtxPtr = initJNIDebugContext(nativePointer); - if (debugCtxPtr == 0) { - throw new RuntimeException("Could not initialize HPy debug context"); - } - hPyDebugContext = debugCtxPtr; - } catch (CannotCastException e) { - // TODO(fa): this can go away once 'isNativeAccessAllowed' is always correctly set - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_DEBUG); - } - } - } - - @Override - public void initHPyTraceContext() throws ApiInitException { - if (hPyTraceContext == 0) { - CompilerDirectives.transferToInterpreter(); - if (!getContext().getEnv().isNativeAccessAllowed() || getContext().getLanguage().getEngineOption(PythonOptions.HPyBackend) != HPyBackendMode.JNI) { - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, J_TRACE); - } - try { - toNativeInternal(); - long traceCtxPtr = initJNITraceContext(nativePointer); - if (traceCtxPtr == 0) { - throw new RuntimeException("Could not initialize HPy trace context"); - } - hPyTraceContext = traceCtxPtr; - } catch (CannotCastException e) { - // TODO(fa): this can go away once 'isNativeAccessAllowed' is always correctly set - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, "trace"); - } - } - } - - @Override - protected Object createArgumentsArray(Object[] args) { - return context.createNativeArguments(args); - } - - @Override - protected void freeArgumentsArray(Object argsArray) { - if (argsArray instanceof Long argsArrayPtr) { - context.freeNativeArgumentsUntil(argsArrayPtr); - } - } - - /** - * Equivalent of {@code hpy_debug_get_ctx}. In fact, this method is called from the native - * {@code hpy_jni.c: hpy_debug_get_ctx} function to get the debug context's pointer via JNI. So, - * if you change the name of this function, also modify {@code hpy_jni.c} appropriately. - */ - long getHPyDebugContext() { - /* - * It is a valid path that this method is called but the debug context has not yet been - * initialized. In particular, this can happen if the leak detector is used which calls - * methods of the native debug module. The native methods may call function - * 'hpy_debug_get_ctx' which upcalls to this method. All this may happen before any HPy - * extension was loaded with debug mode enabled. - */ - if (hPyDebugContext == 0) { - try { - initHPyDebugContext(); - } catch (ApiInitException e) { - throw CompilerDirectives.shouldNotReachHere(e.getMessage()); - } - } - return hPyDebugContext; - } - - @Override - @TruffleBoundary - public PythonModule getHPyDebugModule() throws ImportException { - // force the universal context to native; we need a real pointer for JNI - toNativeInternal(); - - // initialize the debug module via JNI - long debugModuleDef = initJNIDebugModule(nativePointer); - if (debugModuleDef == 0) { - throw new ImportException(null, null, null, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, "debug"); - } - return loadInternalModule(debugModuleDef, tsLiteral("_debug")); - } - - /** - * Equivalent of {@code hpy_trace_get_ctx}. In fact, this method is called from the native - * {@code hpy_jni.c: hpy_trace_get_ctx} function to get the debug context's pointer via JNI. So, - * if you change the name of this function, also modify {@code hpy_jni.c} appropriately. - */ - long getHPyTraceContext() { - /* - * It is a valid path that this method is called but the debug context has not yet been - * initialized. In particular, this can happen if the leak detector is used which calls - * methods of the native debug module. The native methods may call function - * 'hpy_debug_get_ctx' which upcalls to this method. All this may happen before any HPy - * extension was loaded with debug mode enabled. - */ - if (hPyTraceContext == 0) { - try { - initHPyTraceContext(); - } catch (ApiInitException e) { - throw CompilerDirectives.shouldNotReachHere(e.getMessage()); - } - } - return hPyTraceContext; - } - - @Override - @TruffleBoundary - public PythonModule getHPyTraceModule() throws ImportException { - // force the universal context to native; we need a real pointer for JNI - toNativeInternal(); - - // initialize the debug module via JNI - long debugModuleDef = initJNITraceModule(nativePointer); - if (debugModuleDef == 0) { - throw new ImportException(null, null, null, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, "trace"); - } - return loadInternalModule(debugModuleDef, tsLiteral("_trace")); - } - - private PythonModule loadInternalModule(long debugModuleDef, TruffleString name) { - CompilerAsserts.neverPartOfCompilation(); - assert getContext().getEnv().isNativeAccessAllowed(); - assert getContext().getLanguage().getEngineOption(PythonOptions.HPyBackend) == HPyBackendMode.JNI; - - /* - * Note: we don't need a 'spec' object since that's only required if the module has slot - * HPy_mod_create which is guaranteed to be missing in this case. - */ - Object moduleDefPtrObj = convertLongArg(HPyContextSignatureType.HPyModuleDefPtr, debugModuleDef); - Object nativeModule = GraalHPyModuleCreateNodeGen.getUncached().execute(context, name, null, moduleDefPtrObj); - if (nativeModule instanceof PythonModule pythonModule) { - GraalHPyModuleExecNodeGen.getUncached().execute(null, context, pythonModule); - return (PythonModule) nativeModule; - } - /* - * Since we have the internal modules fully under control, this is clearly an internal - * error. - */ - throw new RuntimeException(name.toJavaStringUncached() + " module is expected to be a Python module object"); - } - - @Override - protected void setNativeCache(long cachePtr) { - assert useNativeFastPaths(); - setNativeSpaceFunction(nativePointer, cachePtr); - } - - @Override - public HPyCallHelperFunctionNode createCallHelperFunctionNode() { - return GraalHPyJNICallHelperFunctionNode.UNCACHED; - } - - @Override - public HPyCallHelperFunctionNode getUncachedCallHelperFunctionNode() { - return GraalHPyJNICallHelperFunctionNode.UNCACHED; - } - - @Override - public HPyFromCharPointerNode createFromCharPointerNode() { - return HPyJNIFromCharPointerNodeGen.create(); - } - - @Override - public HPyFromCharPointerNode getUncachedFromCharPointerNode() { - return HPyJNIFromCharPointerNodeGen.getUncached(); - } - - @Override - public HPyAsCharPointerNode createAsCharPointerNode() { - return HPyJNIAsCharPointerNodeGen.create(); - } - - @Override - public HPyAsCharPointerNode getUncachedAsCharPointerNode() { - return HPyJNIAsCharPointerNodeGen.getUncached(); - } - - @Override - public AllocateNode createAllocateNode() { - return UnsafeAllocateNode.UNCACHED; - } - - @Override - public AllocateNode getUncachedAllocateNode() { - return UnsafeAllocateNode.UNCACHED; - } - - @Override - public FreeNode createFreeNode() { - return UnsafeFreeNode.UNCACHED; - } - - @Override - public FreeNode getUncachedFreeNode() { - return UnsafeFreeNode.UNCACHED; - } - - @Override - public BulkFreeHandleReferencesNode createBulkFreeHandleReferencesNode() { - return UnsafeBulkFreeHandleReferencesNode.UNCACHED; - } - - @Override - public GetElementPtrNode createGetElementPtrNode() { - return UnsafeGetElementPtrNode.UNCACHED; - } - - @Override - public GetElementPtrNode getUncachedGetElementPtrNode() { - return UnsafeGetElementPtrNode.UNCACHED; - } - - @Override - public ReadI32Node createReadI32Node() { - return UnsafeReadI32Node.UNCACHED; - } - - @Override - public ReadI32Node getUncachedReadI32Node() { - return UnsafeReadI32Node.UNCACHED; - } - - @Override - public ReadI64Node createReadI64Node() { - return UnsafeReadI64Node.UNCACHED; - } - - @Override - public ReadI64Node getUncachedReadI64Node() { - return UnsafeReadI64Node.UNCACHED; - } - - @Override - public ReadFloatNode createReadFloatNode() { - return UnsafeReadFloatNode.UNCACHED; - } - - @Override - public ReadFloatNode getUncachedReadFloatNode() { - return UnsafeReadFloatNode.UNCACHED; - } - - @Override - public ReadDoubleNode createReadDoubleNode() { - return UnsafeReadDoubleNode.UNCACHED; - } - - @Override - public ReadDoubleNode getUncachedReadDoubleNode() { - return UnsafeReadDoubleNode.UNCACHED; - } - - @Override - public ReadPointerNode createReadPointerNode() { - return UnsafeReadPointerNode.UNCACHED; - } - - @Override - public ReadPointerNode getUncachedReadPointerNode() { - return UnsafeReadPointerNode.UNCACHED; - } - - @Override - public IsNullNode createIsNullNode() { - return UnsafeIsNullNode.UNCACHED; - } - - @Override - public IsNullNode getUncachedIsNullNode() { - return UnsafeIsNullNode.UNCACHED; - } - - @Override - public ReadGenericNode createReadGenericNode() { - return UnsafeReadGenericNode.UNCACHED; - } - - @Override - public ReadGenericNode getUncachedReadGenericNode() { - return UnsafeReadGenericNode.UNCACHED; - } - - @Override - public ReadHPyNode createReadHPyNode() { - return UnsafeReadHPyNode.UNCACHED; - } - - @Override - public ReadHPyNode getUncachedReadHPyNode() { - return UnsafeReadHPyNode.UNCACHED; - } - - @Override - public ReadHPyFieldNode createReadHPyFieldNode() { - return UnsafeReadHPyFieldNode.UNCACHED; - } - - @Override - public ReadHPyFieldNode getUncachedReadFieldHPyNode() { - return UnsafeReadHPyFieldNode.UNCACHED; - } - - @Override - public WriteDoubleNode createWriteDoubleNode() { - return UnsafeWriteDoubleNode.UNCACHED; - } - - @Override - public WriteDoubleNode getUncachedWriteDoubleNode() { - return UnsafeWriteDoubleNode.UNCACHED; - } - - @Override - public WriteI32Node createWriteI32Node() { - return UnsafeWriteI32Node.UNCACHED; - } - - @Override - public WriteI32Node getUncachedWriteI32Node() { - return UnsafeWriteI32Node.UNCACHED; - } - - @Override - public WriteI64Node createWriteI64Node() { - return UnsafeWriteI64Node.UNCACHED; - } - - @Override - public WriteI64Node getUncachedWriteI64Node() { - return UnsafeWriteI64Node.UNCACHED; - } - - @Override - public WriteHPyNode createWriteHPyNode() { - return UnsafeWriteHPyNode.UNCACHED; - } - - @Override - public WriteHPyNode getUncachedWriteHPyNode() { - return UnsafeWriteHPyNode.UNCACHED; - } - - @Override - public WritePointerNode createWritePointerNode() { - return UnsafeWritePointerNode.UNCACHED; - } - - @Override - public WritePointerNode getUncachedWritePointerNode() { - return UnsafeWritePointerNode.UNCACHED; - } - - @Override - public ReadI8ArrayNode createReadI8ArrayNode() { - return UnsafeReadI8ArrayNode.UNCACHED; - } - - @Override - public ReadI8ArrayNode getUncachedReadI8ArrayNode() { - return UnsafeReadI8ArrayNode.UNCACHED; - } - - @Override - public ReadHPyArrayNode createReadHPyArrayNode() { - return UnsafeReadHPyArrayNode.UNCACHED; - } - - @Override - public ReadHPyArrayNode getUncachedReadHPyArrayNode() { - return UnsafeReadHPyArrayNode.UNCACHED; - } - - @Override - public WriteSizeTNode createWriteSizeTNode() { - return UnsafeWriteSizeTNode.UNCACHED; - } - - @Override - public WriteSizeTNode getUncachedWriteSizeTNode() { - return UnsafeWriteSizeTNode.UNCACHED; - } - - @Override - public WriteGenericNode createWriteGenericNode() { - return UnsafeWriteGenericNode.UNCACHED; - } - - @Override - public WriteGenericNode getUncachedWriteGenericNode() { - return UnsafeWriteGenericNode.UNCACHED; - } - - @Override - public WriteHPyFieldNode createWriteHPyFieldNode() { - return UnsafeWriteHPyFieldNode.UNCACHED; - } - - @Override - public WriteHPyFieldNode getUncachedWriteHPyFieldNode() { - return UnsafeWriteHPyFieldNode.UNCACHED; - } - - /* JNI helper functions */ - - @TruffleBoundary - public static native int strcmp(long s1, long s2); - - @TruffleBoundary - private static native int setNativeSpaceFunction(long uctxPointer, long cachePtr); - - @TruffleBoundary - private static native int initJNINativeFastPaths(long uctxPointer); - - @TruffleBoundary - public static native int getErrno(); - - @TruffleBoundary - public static native long getStrerror(int errno); - - /* HPY internal JNI trampoline declarations */ - - @TruffleBoundary - private static native long initJNI(GraalHPyJNIContext backend, GraalHPyContext hpyContext, long[] ctxHandles, int[] ctypeSizes, int[] cfieldOffsets); - - @TruffleBoundary - private static native int finalizeJNIContext(long uctxPointer); - - @TruffleBoundary - private static native long initJNIDebugContext(long uctxPointer); - - @TruffleBoundary - private static native int finalizeJNIDebugContext(long dctxPointer); - - @TruffleBoundary - private static native long initJNIDebugModule(long uctxPointer); - - @TruffleBoundary - private static native long initJNITraceContext(long uctxPointer); - - @TruffleBoundary - private static native int finalizeJNITraceContext(long dctxPointer); - - @TruffleBoundary - private static native long initJNITraceModule(long uctxPointer); - - @TruffleBoundary - static native void bulkFreeNativeSpace(long[] nativeSpacePtrs, long[] destroyFuncPtrs, int n); - - enum HPyJNIUpcall implements HPyUpcall { - HPyUnicodeFromJCharArray, - HPyBulkClose, - HPySequenceFromArray, - - // {{start jni upcalls}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_jni_upcall_enum - HPyDup, - HPyClose, - HPyLongFromInt32t, - HPyLongFromUInt32t, - HPyLongFromInt64t, - HPyLongFromUInt64t, - HPyLongFromSizet, - HPyLongFromSsizet, - HPyLongAsInt32t, - HPyLongAsUInt32t, - HPyLongAsUInt32tMask, - HPyLongAsInt64t, - HPyLongAsUInt64t, - HPyLongAsUInt64tMask, - HPyLongAsSizet, - HPyLongAsSsizet, - HPyLongAsVoidPtr, - HPyLongAsDouble, - HPyFloatFromDouble, - HPyFloatAsDouble, - HPyBoolFromBool, - HPyLength, - HPyNumberCheck, - HPyAdd, - HPySubtract, - HPyMultiply, - HPyMatrixMultiply, - HPyFloorDivide, - HPyTrueDivide, - HPyRemainder, - HPyDivmod, - HPyPower, - HPyNegative, - HPyPositive, - HPyAbsolute, - HPyInvert, - HPyLshift, - HPyRshift, - HPyAnd, - HPyXor, - HPyOr, - HPyIndex, - HPyLong, - HPyFloat, - HPyInPlaceAdd, - HPyInPlaceSubtract, - HPyInPlaceMultiply, - HPyInPlaceMatrixMultiply, - HPyInPlaceFloorDivide, - HPyInPlaceTrueDivide, - HPyInPlaceRemainder, - HPyInPlacePower, - HPyInPlaceLshift, - HPyInPlaceRshift, - HPyInPlaceAnd, - HPyInPlaceXor, - HPyInPlaceOr, - HPyCallableCheck, - HPyCallTupleDict, - HPyCall, - HPyCallMethod, - HPyFatalError, - HPyErrSetString, - HPyErrSetObject, - HPyErrSetFromErrnoWithFilename, - HPyErrSetFromErrnoWithFilenameObjects, - HPyErrOccurred, - HPyErrExceptionMatches, - HPyErrNoMemory, - HPyErrClear, - HPyErrNewException, - HPyErrNewExceptionWithDoc, - HPyErrWarnEx, - HPyErrWriteUnraisable, - HPyIsTrue, - HPyTypeFromSpec, - HPyTypeGenericNew, - HPyGetAttr, - HPyGetAttrs, - HPyHasAttr, - HPyHasAttrs, - HPySetAttr, - HPySetAttrs, - HPyGetItem, - HPyGetItemi, - HPyGetItems, - HPyContains, - HPySetItem, - HPySetItemi, - HPySetItems, - HPyDelItem, - HPyDelItemi, - HPyDelItems, - HPyType, - HPyTypeCheck, - HPyTypeGetName, - HPyTypeIsSubtype, - HPyIs, - HPyAsStructObject, - HPyAsStructLegacy, - HPyAsStructType, - HPyAsStructLong, - HPyAsStructFloat, - HPyAsStructUnicode, - HPyAsStructTuple, - HPyAsStructList, - HPyTypeGetBuiltinShape, - HPyNew, - HPyRepr, - HPyStr, - HPyASCII, - HPyBytes, - HPyRichCompare, - HPyRichCompareBool, - HPyHash, - HPyBytesCheck, - HPyBytesSize, - HPyBytesGETSIZE, - HPyBytesAsString, - HPyBytesASSTRING, - HPyBytesFromString, - HPyBytesFromStringAndSize, - HPyUnicodeFromString, - HPyUnicodeCheck, - HPyUnicodeAsASCIIString, - HPyUnicodeAsLatin1String, - HPyUnicodeAsUTF8String, - HPyUnicodeAsUTF8AndSize, - HPyUnicodeFromWideChar, - HPyUnicodeDecodeFSDefault, - HPyUnicodeDecodeFSDefaultAndSize, - HPyUnicodeEncodeFSDefault, - HPyUnicodeReadChar, - HPyUnicodeDecodeASCII, - HPyUnicodeDecodeLatin1, - HPyUnicodeFromEncodedObject, - HPyUnicodeSubstring, - HPyListCheck, - HPyListNew, - HPyListAppend, - HPyDictCheck, - HPyDictNew, - HPyDictKeys, - HPyDictCopy, - HPyTupleCheck, - HPyTupleFromArray, - HPySliceUnpack, - HPyImportImportModule, - HPyCapsuleNew, - HPyCapsuleGet, - HPyCapsuleIsValid, - HPyCapsuleSet, - HPyFromPyObject, - HPyAsPyObject, - HPyCallRealFunctionFromTrampoline, - HPyListBuilderNew, - HPyListBuilderSet, - HPyListBuilderBuild, - HPyListBuilderCancel, - HPyTupleBuilderNew, - HPyTupleBuilderSet, - HPyTupleBuilderBuild, - HPyTupleBuilderCancel, - HPyTrackerNew, - HPyTrackerAdd, - HPyTrackerForgetAll, - HPyTrackerClose, - HPyFieldStore, - HPyFieldLoad, - HPyReenterPythonExecution, - HPyLeavePythonExecution, - HPyGlobalStore, - HPyGlobalLoad, - HPyDump, - HPyCompiles, - HPyEvalCode, - HPyContextVarNew, - HPyContextVarGet, - HPyContextVarSet, - HPySetCallFunction; - - // @formatter:on - // Checkstyle: resume - // {{end jni upcalls}} - - @CompilationFinal(dimensions = 1) private static final HPyJNIUpcall[] VALUES = values(); - - @Override - public String getName() { - return name(); - } - } - - private void increment(HPyJNIUpcall upcall) { - if (counts != null) { - counts[upcall.ordinal()]++; - } - } - - private static PythonBuiltinClassType getBuiltinClass(Object cls) { - if (cls instanceof PythonBuiltinClassType) { - return (PythonBuiltinClassType) cls; - } else if (cls instanceof PythonBuiltinClass) { - return ((PythonBuiltinClass) cls).getType(); - } else { - return null; - } - } - - private int typeCheck(long handle, Object type) { - Object receiver; - if (GraalHPyBoxing.isBoxedDouble(handle)) { - receiver = PythonBuiltinClassType.PFloat; - } else if (GraalHPyBoxing.isBoxedInt(handle)) { - receiver = PythonBuiltinClassType.PInt; - } else { - receiver = GetClassNode.executeUncached(context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle))); - } - - if (receiver == type) { - return 1; - } - - PythonBuiltinClassType receiverBuiltin = getBuiltinClass(receiver); - if (receiverBuiltin != null) { - PythonBuiltinClassType typeBuiltin = getBuiltinClass(type); - if (typeBuiltin == null) { - // builtin type cannot be a subclass of a non-builtin type - return 0; - } - // fast path for builtin types: walk class hierarchy - while (true) { - if (receiverBuiltin == typeBuiltin) { - return 1; - } - if (receiverBuiltin == PythonBuiltinClassType.PythonObject) { - return 0; - } - receiverBuiltin = receiverBuiltin.getBase(); - } - } - - try { - return IsSubtypeNode.getUncached().execute(receiver, type) ? 1 : 0; - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return 0; - } - } - - /** - * Coerces an object to a native pointer (i.e. a {@code void *}; represented as Java - * {@code long}). This is similar to {@link #expectPointer(Object)} but will send - * {@link InteropLibrary#toNative(Object)} if the object is not a pointer already. - */ - static long coerceToPointer(Object value) { - if (value == null) { - return 0; - } - if (value instanceof Long) { - return (long) value; - } - if (value instanceof NativePointer nativePointer) { - return nativePointer.asPointer(); - } - return interopPointerToNative(value, InteropLibrary.getUncached(value)); - } - - /** - * Expects an object that can be casted (without coercion) to a native pointer (i.e. a - * {@code void *}; represented as Java {@code long}). This method will return {@code 0} in case - * of errors. - */ - public static long expectPointer(Object value) { - if (value instanceof Long) { - return (long) value; - } - InteropLibrary interopLibrary = InteropLibrary.getUncached(value); - if (interopLibrary.isPointer(value)) { - try { - return interopLibrary.asPointer(value); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere("cannot cast " + value); - } - } - return 0; - } - - private long createHPyObject(long typeHandle, long dataOutVar) { - PythonLanguage language = context.getContext().getLanguage(); - Object type = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(typeHandle)); - PythonObject pythonObject; - - /* - * Check if argument is actually a type. We will only accept PythonClass because that's the - * only one that makes sense here. - */ - if (type instanceof PythonClass clazz) { - // allocate native space - long basicSize = clazz.getBasicSize(); - if (basicSize == -1) { - // create the managed Python object - pythonObject = PFactory.createPythonObject(language, clazz, clazz.getInstanceShape()); - } else { - /* - * Since this is a JNI upcall method, we know that (1) we are not running in some - * managed mode, and (2) the data will be used in real native code. Hence, we can - * immediately allocate native memory via Unsafe. - */ - long dataPtr = UNSAFE.allocateMemory(basicSize); - UNSAFE.setMemory(dataPtr, basicSize, (byte) 0); - if (dataOutVar != 0) { - UNSAFE.putAddress(dataOutVar, dataPtr); - } - pythonObject = PFactory.createPythonHPyObject(language, clazz, clazz.getInstanceShape(), dataPtr); - Object destroyFunc = clazz.getHPyDestroyFunc(); - context.createHandleReference(pythonObject, dataPtr, destroyFunc != PNone.NO_VALUE ? destroyFunc : null); - } - Object defaultCallFunc = clazz.getHPyDefaultCallFunc(); - if (defaultCallFunc != null) { - GraalHPyData.setHPyCallFunction(pythonObject, defaultCallFunc); - } - } else { - // check if argument is still a type (e.g. a built-in type, ...) - if (!IsTypeNode.executeUncached(type)) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_NEW_ARG_1_MUST_BE_A_TYPE); - } - // TODO(fa): this should actually call __new__ - pythonObject = PFactory.createPythonObject(language, type, TypeNodes.GetInstanceShape.executeUncached(type)); - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(pythonObject)); - } - - // {{start ctx funcs}} - public int ctxTypeCheck(long bits, long typeBits) { - increment(HPyJNIUpcall.HPyTypeCheck); - Object type = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(typeBits)); - return typeCheck(bits, type); - } - - public int ctxTypeCheckg(long bits, long typeGlobalBits) { - increment(HPyJNIUpcall.HPyTypeCheck); - Object type = context.getObjectForHPyGlobal(GraalHPyBoxing.unboxHandle(typeGlobalBits)); - return typeCheck(bits, type); - } - - public long ctxLength(long handle) { - increment(HPyJNIUpcall.HPyLength); - assert GraalHPyBoxing.isBoxedHandle(handle); - - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - - Object clazz = GetClassNode.executeUncached(receiver); - if (clazz == PythonBuiltinClassType.PList || clazz == PythonBuiltinClassType.PTuple) { - PSequence sequence = (PSequence) receiver; - SequenceStorage storage = sequence.getSequenceStorage(); - return storage.length(); - } - try { - return PyObjectSizeNodeGen.executeUncached(receiver); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1; - } - } - - public int ctxListCheck(long handle) { - increment(HPyJNIUpcall.HPyListCheck); - if (GraalHPyBoxing.isBoxedHandle(handle)) { - Object obj = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - Object clazz = GetClassNode.executeUncached(obj); - return PInt.intValue(clazz == PythonBuiltinClassType.PList || IsSubtypeNodeGen.getUncached().execute(clazz, PythonBuiltinClassType.PList)); - } else { - return 0; - } - } - - public long ctxUnicodeFromWideChar(long wcharArrayPtr, long size) { - increment(HPyJNIUpcall.HPyUnicodeFromWideChar); - - if (!PInt.isIntRange(size)) { - // NULL handle - return 0; - } - int isize = (int) size; - // TODO GR-37216: use TruffleString.FromNativePointer? - char[] decoded = new char[isize]; - for (int i = 0; i < size; i++) { - int wchar = UNSAFE.getInt(wcharArrayPtr + (long) Integer.BYTES * i); - if (Character.isBmpCodePoint(wchar)) { - decoded[i] = (char) wchar; - } else { - // TODO(fa): handle this case - throw new RuntimeException(); - } - } - TruffleString result = toTruffleStringUncached(new String(decoded, 0, isize)); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } - - public long ctxUnicodeFromJCharArray(char[] arr) { - increment(HPyJNIUpcall.HPyUnicodeFromJCharArray); - TruffleString string = TruffleString.fromCharArrayUTF16Uncached(arr).switchEncodingUncached(TS_ENCODING); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(string)); - } - - public long ctxDictNew() { - increment(HPyJNIUpcall.HPyDictNew); - PDict dict = PFactory.createDict(context.getContext().getLanguage()); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(dict)); - } - - public long ctxListNew(long llen) { - try { - increment(HPyJNIUpcall.HPyListNew); - int len = CastToJavaIntExactNode.executeUncached(llen); - Object[] data = new Object[len]; - Arrays.fill(data, PNone.NONE); - PList list = PFactory.createList(context.getContext().getLanguage(), data); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(list)); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - // NULL handle - return 0; - } - } - - /** - * Implementation of context function {@code ctx_Tuple_FromArray} (JNI upcall). This method can - * optionally steal the item handles in order to avoid repeated upcalls just to close them. This - * is useful to implement, e.g., tuple builder. - */ - public long ctxSequenceFromArray(long[] hItems, boolean steal, boolean create_list) { - increment(HPyJNIUpcall.HPySequenceFromArray); - - Object[] objects = new Object[hItems.length]; - for (int i = 0; i < hItems.length; i++) { - long hBits = hItems[i]; - objects[i] = context.bitsAsPythonObject(hBits); - if (steal) { - closeNativeHandle(hBits); - } - } - Object result; - PythonLanguage language = context.getContext().getLanguage(); - if (create_list) { - result = PFactory.createList(language, objects); - } else { - result = PFactory.createTuple(language, objects); - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } - - public long ctxFieldLoad(long bits, long idx) { - increment(HPyJNIUpcall.HPyFieldLoad); - Object owner = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - // HPyField index is always non-zero because zero means: uninitialized - assert idx > 0; - Object referent = GraalHPyData.getHPyField((PythonObject) owner, (int) idx); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(referent)); - } - - public long ctxFieldStore(long bits, long idx, long value) { - increment(HPyJNIUpcall.HPyFieldStore); - PythonObject owner = (PythonObject) context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - Object referent = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(value)); - return GraalHPyData.setHPyField(owner, referent, (int) idx); - } - - public long ctxGlobalLoad(long bits) { - increment(HPyJNIUpcall.HPyGlobalLoad); - assert GraalHPyBoxing.isBoxedHandle(bits); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(context.getObjectForHPyGlobal(GraalHPyBoxing.unboxHandle(bits)))); - } - - public long ctxGlobalStore(long bits, long v) { - increment(HPyJNIUpcall.HPyGlobalStore); - assert GraalHPyBoxing.isBoxedHandle(bits); - return context.createGlobal(context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(v)), GraalHPyBoxing.unboxHandle(bits)); - } - - public long ctxType(long bits) { - increment(HPyJNIUpcall.HPyType); - Object clazz; - if (GraalHPyBoxing.isBoxedHandle(bits)) { - clazz = GetClassNode.executeUncached(context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits))); - } else if (GraalHPyBoxing.isBoxedInt(bits)) { - clazz = GetClassNode.executeUncached(GraalHPyBoxing.unboxInt(bits)); - } else if (GraalHPyBoxing.isBoxedDouble(bits)) { - clazz = GetClassNode.executeUncached(GraalHPyBoxing.unboxDouble(bits)); - } else { - assert false; - clazz = null; - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(clazz)); - } - - public long ctxTypeGetName(long bits) { - increment(HPyJNIUpcall.HPyTypeGetName); - assert GraalHPyBoxing.isBoxedHandle(bits); - Object clazz = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bits)); - Object tpName = HPyTypeGetNameNode.executeUncached(context, clazz); - try { - return coerceToPointer(tpName); - } catch (CannotCastException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - public long ctxContextVarGet(long varBits, long defBits, long errBits) { - increment(HPyJNIUpcall.HPyContextVarGet); - assert GraalHPyBoxing.isBoxedHandle(varBits); - Object var = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(varBits)); - if (!(var instanceof PContextVar)) { - try { - throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.INSTANCE_OF_CONTEXTVAR_EXPECTED); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - } - return errBits; - } - PythonContext ctx = getContext(); - PythonLanguage lang = ctx.getLanguage(); - Object def = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(defBits)); - Object res = GraalHPyContextVarGet.getObject(ctx.getThreadState(lang), (PContextVar) var, def); - if (res == GraalHPyHandle.NULL_HANDLE_DELEGATE) { - return 0; - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(res)); - } - - public int ctxIs(long aBits, long bBits) { - Object a = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(aBits)); - Object b = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(bBits)); - try { - return PInt.intValue(IsNodeGen.getUncached().execute(a, b)); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1; - } - } - - public int ctxIsg(long aBits, long bBits) { - Object a = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(aBits)); - Object b = context.getObjectForHPyGlobal(GraalHPyBoxing.unboxHandle(bBits)); - try { - return PInt.intValue(IsNodeGen.getUncached().execute(a, b)); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1; - } - } - - public long ctxCapsuleNew(long pointer, long name, long destructor) { - if (pointer == 0) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, ValueError, ErrorMessages.HPYCAPSULE_NEW_NULL_PTR_ERROR); - } - long hpyDestructor; - if (destructor != 0) { - long cpyTrampoline = UNSAFE.getLong(destructor); // HPyCapsule_Destructor.cpy_trampoline - hpyDestructor = UNSAFE.getLong(destructor + SIZEOF_LONG); // HPyCapsule_Destructor.impl - if (cpyTrampoline == 0 || hpyDestructor == 0) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, ValueError, ErrorMessages.INVALID_HPYCAPSULE_DESTRUCTOR); - } - } else { - hpyDestructor = 0; - } - PyCapsule result = PFactory.createCapsuleNativeName(context.getContext().getLanguage(), pointer, new NativePointer(name)); - if (hpyDestructor != 0) { - result.registerDestructor(hpyDestructor); - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } - - static boolean capsuleNameMatches(long name1, long name2) { - // additional shortcut (compared to CPython) to avoid a unnecessary downcalls - if (name1 == name2) { - return true; - } - /* - * If one of them is NULL, then both need to be NULL. However, at this point we have - * invariant 'name1 != name2' because of the above shortcut. - */ - if (name1 == 0 || name2 == 0) { - return false; - } - return strcmp(name1, name2) == 0; - } - - public long ctxCapsuleGet(long capsuleBits, int key, long namePtr) { - Object capsule = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(capsuleBits)); - try { - if (!(capsule instanceof PyCapsule pyCapsule) || pyCapsule.getPointer() == null) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, ValueError, GraalHPyCapsuleGet.getErrorMessage(key)); - } - GraalHPyCapsuleGet.isLegalCapsule(null, capsule, key, PRaiseNode.getUncached()); - Object result; - switch (key) { - case CapsuleKey.Pointer -> { - if (!capsuleNameMatches(namePtr, coerceToPointer(pyCapsule.getNamePtr()))) { - return HPyRaiseNodeGen.getUncached().raiseIntWithoutFrame(context, 0, ValueError, GraalHPyCapsuleGet.INCORRECT_NAME); - } - result = pyCapsule.getPointer(); - } - case CapsuleKey.Context -> result = pyCapsule.getContext(); - // The capsule's name may either be a native pointer or a TruffleString. - case CapsuleKey.Name -> result = pyCapsule.getNamePtr(); - case CapsuleKey.Destructor -> result = pyCapsule.getDestructor(); - default -> throw CompilerDirectives.shouldNotReachHere("invalid key"); - } - return coerceToPointer(result); - } catch (CannotCastException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - public long ctxGetAttrs(long receiverHandle, String name) { - increment(HPyJNIUpcall.HPyGetAttrs); - Object receiver = context.bitsAsPythonObject(receiverHandle); - TruffleString tsName = toTruffleStringUncached(name); - Object result; - try { - result = PyObjectGetAttr.executeUncached(receiver, tsName); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return 0; - } - return context.pythonObjectAsBits(result); - } - - @SuppressWarnings("static-method") - public long ctxFloatFromDouble(double value) { - increment(HPyJNIUpcall.HPyFloatFromDouble); - return GraalHPyBoxing.boxDouble(value); - } - - public double ctxFloatAsDouble(long handle) { - increment(HPyJNIUpcall.HPyFloatAsDouble); - - if (GraalHPyBoxing.isBoxedDouble(handle)) { - return GraalHPyBoxing.unboxDouble(handle); - } else if (GraalHPyBoxing.isBoxedInt(handle)) { - return GraalHPyBoxing.unboxInt(handle); - } else { - Object object = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - try { - return PyFloatAsDoubleNode.executeUncached(object); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1.0; - } - } - } - - public int ctxLongAsInt32t(long h) { - increment(HPyJNIUpcall.HPyLongAsInt32t); - if (GraalHPyBoxing.isBoxedInt(h)) { - return GraalHPyBoxing.unboxInt(h); - } - return executeIntBinaryContextFunction(HPyContextMember.CTX_LONG_ASINT32_T, h); - } - - public int ctxLongAsUInt32t(long h) { - increment(HPyJNIUpcall.HPyLongAsUInt32t); - // we may only unbox positive values; negative values will raise an error - int unboxedVal; - if (GraalHPyBoxing.isBoxedInt(h) && (unboxedVal = GraalHPyBoxing.unboxInt(h)) >= 0) { - return unboxedVal; - } - return executeIntBinaryContextFunction(HPyContextMember.CTX_LONG_ASUINT32_T, h); - } - - public int ctxLongAsUInt32tMask(long h) { - increment(HPyJNIUpcall.HPyLongAsUInt32tMask); - if (GraalHPyBoxing.isBoxedInt(h)) { - return GraalHPyBoxing.unboxInt(h); - } - return executeIntBinaryContextFunction(HPyContextMember.CTX_LONG_ASUINT32_TMASK, h); - } - - public long ctxLongAsInt64t(long handle) { - increment(HPyJNIUpcall.HPyLongAsInt64t); - - if (GraalHPyBoxing.isBoxedInt(handle)) { - return GraalHPyBoxing.unboxInt(handle); - } else { - Object object = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - try { - return (long) AsNativePrimitiveNodeGen.getUncached().execute(object, 1, java.lang.Long.BYTES, true); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1L; - } - } - } - - public long ctxLongAsUInt64t(long h) { - increment(HPyJNIUpcall.HPyLongAsUInt64t); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_ASUINT64_T, h); - } - - public long ctxLongAsUInt64tMask(long h) { - increment(HPyJNIUpcall.HPyLongAsUInt64tMask); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_ASUINT64_TMASK, h); - } - - public double ctxLongAsDouble(long handle) { - increment(HPyJNIUpcall.HPyLongAsDouble); - - if (GraalHPyBoxing.isBoxedInt(handle)) { - return GraalHPyBoxing.unboxInt(handle); - } else { - Object object = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - try { - return PyLongAsDoubleNode.executeUncached(object); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1L; - } - } - } - - public long ctxLongFromInt32t(int v) { - increment(HPyJNIUpcall.HPyLongFromInt32t); - return GraalHPyBoxing.boxInt(v); - } - - public long ctxLongFromUInt32t(int value) { - increment(HPyJNIUpcall.HPyLongFromUInt32t); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_FROMUINT32_T, value); - } - - public long ctxLongFromInt64t(long v) { - increment(HPyJNIUpcall.HPyLongFromInt64t); - if (PInt.isIntRange(v)) { - return GraalHPyBoxing.boxInt((int) v); - } - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_FROMINT64_T, v); - } - - public long ctxLongFromUInt64t(long v) { - increment(HPyJNIUpcall.HPyLongFromUInt64t); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_FROMUINT64_T, v); - } - - public long ctxBoolFromBool(boolean v) { - increment(HPyJNIUpcall.HPyBoolFromBool); - Python3Core core = context.getContext(); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(v ? core.getTrue() : core.getFalse())); - } - - public long ctxAsStructObject(long h) { - increment(HPyJNIUpcall.HPyAsStructObject); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructLegacy(long h) { - increment(HPyJNIUpcall.HPyAsStructLegacy); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructType(long h) { - increment(HPyJNIUpcall.HPyAsStructType); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructLong(long h) { - increment(HPyJNIUpcall.HPyAsStructLong); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructFloat(long h) { - increment(HPyJNIUpcall.HPyAsStructFloat); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructUnicode(long h) { - increment(HPyJNIUpcall.HPyAsStructUnicode); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructTuple(long h) { - increment(HPyJNIUpcall.HPyAsStructTuple); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - public long ctxAsStructList(long h) { - increment(HPyJNIUpcall.HPyAsStructList); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - return expectPointer(HPyGetNativeSpacePointerNode.executeUncached(receiver)); - } - - // Note: assumes that receiverHandle is not a boxed primitive value - public int ctxSetItems(long receiverHandle, String name, long valueHandle) { - increment(HPyJNIUpcall.HPySetItems); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(receiverHandle)); - Object value = context.bitsAsPythonObject(valueHandle); - if (value == GraalHPyHandle.NULL_HANDLE_DELEGATE) { - HPyRaiseNode.raiseIntUncached(context, -1, SystemError, ErrorMessages.HPY_UNEXPECTED_HPY_NULL); - return -1; - } - TruffleString tsName = toTruffleStringUncached(name); - try { - PyObjectSetItem.executeUncached(receiver, tsName, value); - return 0; - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return -1; - } - } - - // Note: assumes that receiverHandle is not a boxed primitive value - public long ctxGetItems(long receiverHandle, String name) { - increment(HPyJNIUpcall.HPyGetItems); - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(receiverHandle)); - TruffleString tsName = toTruffleStringUncached(name); - Object result; - try { - result = PyObjectGetItem.executeUncached(receiver, tsName); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return 0; - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } - - public long ctxNew(long typeHandle, long dataOutVar) { - increment(HPyJNIUpcall.HPyNew); - return createHPyObject(typeHandle, dataOutVar); - } - - @SuppressWarnings("unused") - public long ctxTypeGenericNew(long typeHandle, long args, long nargs, long kw) { - increment(HPyJNIUpcall.HPyTypeGenericNew); - return createHPyObject(typeHandle, 0); - } - - /** - * Close a native handle received from a JNI upcall (hence represented by a Java {code long}). - */ - private void closeNativeHandle(long handle) { - if (GraalHPyBoxing.isBoxedHandle(handle)) { - context.releaseHPyHandleForObject(GraalHPyBoxing.unboxHandle(handle)); - } - } - - public void ctxClose(long handle) { - increment(HPyJNIUpcall.HPyClose); - closeNativeHandle(handle); - } - - public void ctxBulkClose(long unclosedHandlePtr, int size) { - increment(HPyJNIUpcall.HPyBulkClose); - for (int i = 0; i < size; i++) { - long handle = UNSAFE.getLong(unclosedHandlePtr); - unclosedHandlePtr += 8; - assert GraalHPyBoxing.isBoxedHandle(handle); - assert handle >= IMMUTABLE_HANDLE_COUNT; - context.releaseHPyHandleForObject(GraalHPyBoxing.unboxHandle(handle)); - } - } - - public long ctxDup(long handle) { - increment(HPyJNIUpcall.HPyDup); - if (GraalHPyBoxing.isBoxedHandle(handle)) { - Object delegate = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(delegate)); - } else { - return handle; - } - } - - public long ctxGetItemi(long hCollection, long lidx) { - increment(HPyJNIUpcall.HPyGetItemi); - try { - // If handle 'hCollection' is a boxed int or double, the object is not subscriptable. - if (!GraalHPyBoxing.isBoxedHandle(hCollection)) { - throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, 0); - } - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hCollection)); - Object clazz = GetClassNode.executeUncached(receiver); - if (clazz == PythonBuiltinClassType.PList || clazz == PythonBuiltinClassType.PTuple) { - if (!PInt.isIntRange(lidx)) { - throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); - } - int idx = (int) lidx; - PSequence sequence = (PSequence) receiver; - SequenceStorage storage = sequence.getSequenceStorage(); - if (storage instanceof IntSequenceStorage) { - return GraalHPyBoxing.boxInt(((IntSequenceStorage) storage).getIntItemNormalized(idx)); - } else if (storage instanceof DoubleSequenceStorage) { - return GraalHPyBoxing.boxDouble(((DoubleSequenceStorage) storage).getDoubleItemNormalized(idx)); - } else if (storage instanceof LongSequenceStorage) { - long lresult = ((LongSequenceStorage) storage).getLongItemNormalized(idx); - if (com.oracle.graal.python.builtins.objects.ints.PInt.isIntRange(lresult)) { - return GraalHPyBoxing.boxInt((int) lresult); - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(lresult)); - } else if (storage instanceof ObjectSequenceStorage) { - Object result = ((ObjectSequenceStorage) storage).getObjectItemNormalized(idx); - if (result instanceof Integer) { - return GraalHPyBoxing.boxInt((int) result); - } else if (result instanceof Double) { - return GraalHPyBoxing.boxDouble((double) result); - } - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } - // TODO: other storages... - } - Object result = PyObjectGetItem.executeUncached(receiver, lidx); - return GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - // NULL handle - return 0; - } - } - - /** - * HPy signature: {@code HPy_SetItem(HPyContext ctx, HPy obj, HPy key, HPy value)} - * - * @param hSequence - * @param hKey - * @param hValue - * @return {@code 0} on success; {@code -1} on error - */ - public int ctxSetItem(long hSequence, long hKey, long hValue) { - increment(HPyJNIUpcall.HPySetItem); - try { - // If handle 'hSequence' is a boxed int or double, the object is not a sequence. - if (!GraalHPyBoxing.isBoxedHandle(hSequence)) { - throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); - } - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hSequence)); - Object clazz = GetClassNode.executeUncached(receiver); - Object key = HPyAsPythonObjectNodeGen.getUncached().execute(hKey); - Object value = HPyAsPythonObjectNodeGen.getUncached().execute(hValue); - - // fast path - if (clazz == PythonBuiltinClassType.PDict) { - PDict dict = (PDict) receiver; - HashingStorage dictStorage = dict.getDictStorage(); - - // super-fast path for string keys - if (key instanceof TruffleString) { - if (dictStorage instanceof EmptyStorage) { - dictStorage = PDict.createNewStorage(1); - dict.setDictStorage(dictStorage); - } - - if (dictStorage instanceof EconomicMapStorage) { - ((EconomicMapStorage) dictStorage).putUncached((TruffleString) key, value); - return 0; - } - // fall through to generic case - } - dict.setDictStorage(HashingStorageSetItem.executeUncached(dictStorage, key, value)); - return 0; - } else if (clazz == PythonBuiltinClassType.PList && PGuards.isInteger(key) && ctxListSetItem(receiver, ((Number) key).longValue(), hValue)) { - return 0; - } - PyObjectSetItem.executeUncached(receiver, key, value); - return 0; - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - // non-null value indicates an error - return -1; - } - } - - public int ctxSetItemi(long hSequence, long lidx, long hValue) { - increment(HPyJNIUpcall.HPySetItemi); - try { - // If handle 'hSequence' is a boxed int or double, the object is not a sequence. - if (!GraalHPyBoxing.isBoxedHandle(hSequence)) { - throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); - } - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hSequence)); - Object clazz = GetClassNode.executeUncached(receiver); - - if (clazz == PythonBuiltinClassType.PList && ctxListSetItem(receiver, lidx, hValue)) { - return 0; - } - Object value = HPyAsPythonObjectNodeGen.getUncached().execute(hValue); - PyObjectSetItem.executeUncached(receiver, lidx, value); - return 0; - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - // non-null value indicates an error - return -1; - } - } - - private boolean ctxListSetItem(Object receiver, long lidx, long hValue) { - // fast path for list - if (!PInt.isIntRange(lidx)) { - throw PRaiseNode.raiseStatic(null, PythonBuiltinClassType.IndexError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, lidx); - } - int idx = (int) lidx; - PList sequence = (PList) receiver; - SequenceStorage storage = sequence.getSequenceStorage(); - if (storage instanceof IntSequenceStorage && GraalHPyBoxing.isBoxedInt(hValue)) { - ((IntSequenceStorage) storage).setIntItemNormalized(idx, GraalHPyBoxing.unboxInt(hValue)); - return true; - } else if (storage instanceof DoubleSequenceStorage && GraalHPyBoxing.isBoxedDouble(hValue)) { - ((DoubleSequenceStorage) storage).setDoubleItemNormalized(idx, GraalHPyBoxing.unboxDouble(hValue)); - return true; - } else if (storage instanceof LongSequenceStorage && GraalHPyBoxing.isBoxedInt(hValue)) { - ((LongSequenceStorage) storage).setLongItemNormalized(idx, GraalHPyBoxing.unboxInt(hValue)); - return true; - } else if (storage instanceof ObjectSequenceStorage) { - Object value = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(hValue)); - ((ObjectSequenceStorage) storage).setObjectItemNormalized(idx, value); - return true; - } - // TODO: other storages... - return false; - } - - public int ctxNumberCheck(long handle) { - increment(HPyJNIUpcall.HPyNumberCheck); - if (GraalHPyBoxing.isBoxedDouble(handle) || GraalHPyBoxing.isBoxedInt(handle)) { - return 1; - } - Object receiver = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(handle)); - - try { - return PInt.intValue(PyNumberCheckNode.executeUncached(receiver)); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(context, e); - return 0; - } - } - - public long ctxLongFromSizet(long value) { - increment(HPyJNIUpcall.HPyLongFromSizet); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_FROMSIZE_T, value); - } - - public long ctxLongFromSsizet(long value) { - increment(HPyJNIUpcall.HPyLongFromSsizet); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_FROMSSIZE_T, value); - } - - public long ctxLongAsSizet(long h) { - increment(HPyJNIUpcall.HPyLongAsSizet); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_ASSIZE_T, h); - } - - public long ctxLongAsSsizet(long h) { - increment(HPyJNIUpcall.HPyLongAsSsizet); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_ASSSIZE_T, h); - } - - public long ctxLongAsVoidPtr(long h) { - increment(HPyJNIUpcall.HPyLongAsVoidPtr); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG_ASVOIDPTR, h); - } - - public long ctxAdd(long h1, long h2) { - increment(HPyJNIUpcall.HPyAdd); - return executeLongTernaryContextFunction(HPyContextMember.CTX_ADD, h1, h2); - } - - public long ctxSubtract(long h1, long h2) { - increment(HPyJNIUpcall.HPySubtract); - return executeLongTernaryContextFunction(HPyContextMember.CTX_SUBTRACT, h1, h2); - } - - public long ctxMultiply(long h1, long h2) { - increment(HPyJNIUpcall.HPyMultiply); - return executeLongTernaryContextFunction(HPyContextMember.CTX_MULTIPLY, h1, h2); - } - - public long ctxMatrixMultiply(long h1, long h2) { - increment(HPyJNIUpcall.HPyMatrixMultiply); - return executeLongTernaryContextFunction(HPyContextMember.CTX_MATRIXMULTIPLY, h1, h2); - } - - public long ctxFloorDivide(long h1, long h2) { - increment(HPyJNIUpcall.HPyFloorDivide); - return executeLongTernaryContextFunction(HPyContextMember.CTX_FLOORDIVIDE, h1, h2); - } - - public long ctxTrueDivide(long h1, long h2) { - increment(HPyJNIUpcall.HPyTrueDivide); - return executeLongTernaryContextFunction(HPyContextMember.CTX_TRUEDIVIDE, h1, h2); - } - - public long ctxRemainder(long h1, long h2) { - increment(HPyJNIUpcall.HPyRemainder); - return executeLongTernaryContextFunction(HPyContextMember.CTX_REMAINDER, h1, h2); - } - - public long ctxDivmod(long h1, long h2) { - increment(HPyJNIUpcall.HPyDivmod); - return executeLongTernaryContextFunction(HPyContextMember.CTX_DIVMOD, h1, h2); - } - - public long ctxPower(long h1, long h2, long h3) { - increment(HPyJNIUpcall.HPyPower); - return executeLongContextFunction(HPyContextMember.CTX_POWER, new long[]{h1, h2, h3}); - } - - public long ctxNegative(long h1) { - increment(HPyJNIUpcall.HPyNegative); - return executeLongBinaryContextFunction(HPyContextMember.CTX_NEGATIVE, h1); - } - - public long ctxPositive(long h1) { - increment(HPyJNIUpcall.HPyPositive); - return executeLongBinaryContextFunction(HPyContextMember.CTX_POSITIVE, h1); - } - - public long ctxAbsolute(long h1) { - increment(HPyJNIUpcall.HPyAbsolute); - return executeLongBinaryContextFunction(HPyContextMember.CTX_ABSOLUTE, h1); - } - - public long ctxInvert(long h1) { - increment(HPyJNIUpcall.HPyInvert); - return executeLongBinaryContextFunction(HPyContextMember.CTX_INVERT, h1); - } - - public long ctxLshift(long h1, long h2) { - increment(HPyJNIUpcall.HPyLshift); - return executeLongTernaryContextFunction(HPyContextMember.CTX_LSHIFT, h1, h2); - } - - public long ctxRshift(long h1, long h2) { - increment(HPyJNIUpcall.HPyRshift); - return executeLongTernaryContextFunction(HPyContextMember.CTX_RSHIFT, h1, h2); - } - - public long ctxAnd(long h1, long h2) { - increment(HPyJNIUpcall.HPyAnd); - return executeLongTernaryContextFunction(HPyContextMember.CTX_AND, h1, h2); - } - - public long ctxXor(long h1, long h2) { - increment(HPyJNIUpcall.HPyXor); - return executeLongTernaryContextFunction(HPyContextMember.CTX_XOR, h1, h2); - } - - public long ctxOr(long h1, long h2) { - increment(HPyJNIUpcall.HPyOr); - return executeLongTernaryContextFunction(HPyContextMember.CTX_OR, h1, h2); - } - - public long ctxIndex(long h1) { - increment(HPyJNIUpcall.HPyIndex); - return executeLongBinaryContextFunction(HPyContextMember.CTX_INDEX, h1); - } - - public long ctxLong(long h1) { - increment(HPyJNIUpcall.HPyLong); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LONG, h1); - } - - public long ctxFloat(long h1) { - increment(HPyJNIUpcall.HPyFloat); - return executeLongBinaryContextFunction(HPyContextMember.CTX_FLOAT, h1); - } - - public long ctxInPlaceAdd(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceAdd); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEADD, h1, h2); - } - - public long ctxInPlaceSubtract(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceSubtract); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACESUBTRACT, h1, h2); - } - - public long ctxInPlaceMultiply(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceMultiply); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEMULTIPLY, h1, h2); - } - - public long ctxInPlaceMatrixMultiply(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceMatrixMultiply); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEMATRIXMULTIPLY, h1, h2); - } - - public long ctxInPlaceFloorDivide(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceFloorDivide); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEFLOORDIVIDE, h1, h2); - } - - public long ctxInPlaceTrueDivide(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceTrueDivide); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACETRUEDIVIDE, h1, h2); - } - - public long ctxInPlaceRemainder(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceRemainder); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEREMAINDER, h1, h2); - } - - public long ctxInPlacePower(long h1, long h2, long h3) { - increment(HPyJNIUpcall.HPyInPlacePower); - return executeLongContextFunction(HPyContextMember.CTX_INPLACEPOWER, new long[]{h1, h2, h3}); - } - - public long ctxInPlaceLshift(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceLshift); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACELSHIFT, h1, h2); - } - - public long ctxInPlaceRshift(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceRshift); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACERSHIFT, h1, h2); - } - - public long ctxInPlaceAnd(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceAnd); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEAND, h1, h2); - } - - public long ctxInPlaceXor(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceXor); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEXOR, h1, h2); - } - - public long ctxInPlaceOr(long h1, long h2) { - increment(HPyJNIUpcall.HPyInPlaceOr); - return executeLongTernaryContextFunction(HPyContextMember.CTX_INPLACEOR, h1, h2); - } - - public int ctxCallableCheck(long h) { - increment(HPyJNIUpcall.HPyCallableCheck); - return executeIntBinaryContextFunction(HPyContextMember.CTX_CALLABLE_CHECK, h); - } - - public long ctxCallTupleDict(long callable, long args, long kw) { - increment(HPyJNIUpcall.HPyCallTupleDict); - return executeLongContextFunction(HPyContextMember.CTX_CALLTUPLEDICT, new long[]{callable, args, kw}); - } - - public void ctxFatalError(long message) { - increment(HPyJNIUpcall.HPyFatalError); - executeIntBinaryContextFunction(HPyContextMember.CTX_FATALERROR, message); - } - - public void ctxErrSetString(long h_type, long message) { - increment(HPyJNIUpcall.HPyErrSetString); - executeIntTernaryContextFunction(HPyContextMember.CTX_ERR_SETSTRING, h_type, message); - } - - public void ctxErrSetObject(long h_type, long h_value) { - increment(HPyJNIUpcall.HPyErrSetObject); - executeIntTernaryContextFunction(HPyContextMember.CTX_ERR_SETOBJECT, h_type, h_value); - } - - public long ctxErrSetFromErrnoWithFilename(long h_type, long filename_fsencoded) { - increment(HPyJNIUpcall.HPyErrSetFromErrnoWithFilename); - return executeLongTernaryContextFunction(HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAME, h_type, filename_fsencoded); - } - - public void ctxErrSetFromErrnoWithFilenameObjects(long h_type, long filename1, long filename2) { - increment(HPyJNIUpcall.HPyErrSetFromErrnoWithFilenameObjects); - executeIntContextFunction(HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS, new long[]{h_type, filename1, filename2}); - } - - public int ctxErrOccurred() { - increment(HPyJNIUpcall.HPyErrOccurred); - return executeIntContextFunction(HPyContextMember.CTX_ERR_OCCURRED, new long[]{}); - } - - public int ctxErrExceptionMatches(long exc) { - increment(HPyJNIUpcall.HPyErrExceptionMatches); - return executeIntBinaryContextFunction(HPyContextMember.CTX_ERR_EXCEPTIONMATCHES, exc); - } - - public void ctxErrNoMemory() { - increment(HPyJNIUpcall.HPyErrNoMemory); - executeIntContextFunction(HPyContextMember.CTX_ERR_NOMEMORY, new long[]{}); - } - - public void ctxErrClear() { - increment(HPyJNIUpcall.HPyErrClear); - executeIntContextFunction(HPyContextMember.CTX_ERR_CLEAR, new long[]{}); - } - - public long ctxErrNewException(long name, long base, long dict) { - increment(HPyJNIUpcall.HPyErrNewException); - return executeLongContextFunction(HPyContextMember.CTX_ERR_NEWEXCEPTION, new long[]{name, base, dict}); - } - - public long ctxErrNewExceptionWithDoc(long name, long doc, long base, long dict) { - increment(HPyJNIUpcall.HPyErrNewExceptionWithDoc); - return executeLongContextFunction(HPyContextMember.CTX_ERR_NEWEXCEPTIONWITHDOC, new long[]{name, doc, base, dict}); - } - - public int ctxErrWarnEx(long category, long message, long stack_level) { - increment(HPyJNIUpcall.HPyErrWarnEx); - return executeIntContextFunction(HPyContextMember.CTX_ERR_WARNEX, new long[]{category, message, stack_level}); - } - - public void ctxErrWriteUnraisable(long obj) { - increment(HPyJNIUpcall.HPyErrWriteUnraisable); - executeIntBinaryContextFunction(HPyContextMember.CTX_ERR_WRITEUNRAISABLE, obj); - } - - public int ctxIsTrue(long h) { - increment(HPyJNIUpcall.HPyIsTrue); - return executeIntBinaryContextFunction(HPyContextMember.CTX_ISTRUE, h); - } - - public long ctxTypeFromSpec(long spec, long params) { - increment(HPyJNIUpcall.HPyTypeFromSpec); - return executeLongTernaryContextFunction(HPyContextMember.CTX_TYPE_FROMSPEC, spec, params); - } - - public long ctxGetAttr(long obj, long name) { - increment(HPyJNIUpcall.HPyGetAttr); - return executeLongTernaryContextFunction(HPyContextMember.CTX_GETATTR, obj, name); - } - - public int ctxHasAttr(long obj, long name) { - increment(HPyJNIUpcall.HPyHasAttr); - return executeIntTernaryContextFunction(HPyContextMember.CTX_HASATTR, obj, name); - } - - public int ctxHasAttrs(long obj, long name) { - increment(HPyJNIUpcall.HPyHasAttrs); - return executeIntTernaryContextFunction(HPyContextMember.CTX_HASATTR_S, obj, name); - } - - public int ctxSetAttr(long obj, long name, long value) { - increment(HPyJNIUpcall.HPySetAttr); - return executeIntContextFunction(HPyContextMember.CTX_SETATTR, new long[]{obj, name, value}); - } - - public int ctxSetAttrs(long obj, long name, long value) { - increment(HPyJNIUpcall.HPySetAttrs); - return executeIntContextFunction(HPyContextMember.CTX_SETATTR_S, new long[]{obj, name, value}); - } - - public long ctxGetItem(long obj, long key) { - increment(HPyJNIUpcall.HPyGetItem); - return executeLongTernaryContextFunction(HPyContextMember.CTX_GETITEM, obj, key); - } - - public int ctxContains(long container, long key) { - increment(HPyJNIUpcall.HPyContains); - return executeIntTernaryContextFunction(HPyContextMember.CTX_CONTAINS, container, key); - } - - public int ctxTypeIsSubtype(long sub, long type) { - increment(HPyJNIUpcall.HPyTypeIsSubtype); - return executeIntTernaryContextFunction(HPyContextMember.CTX_TYPE_ISSUBTYPE, sub, type); - } - - public long ctxRepr(long obj) { - increment(HPyJNIUpcall.HPyRepr); - return executeLongBinaryContextFunction(HPyContextMember.CTX_REPR, obj); - } - - public long ctxStr(long obj) { - increment(HPyJNIUpcall.HPyStr); - return executeLongBinaryContextFunction(HPyContextMember.CTX_STR, obj); - } - - public long ctxASCII(long obj) { - increment(HPyJNIUpcall.HPyASCII); - return executeLongBinaryContextFunction(HPyContextMember.CTX_ASCII, obj); - } - - public long ctxBytes(long obj) { - increment(HPyJNIUpcall.HPyBytes); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES, obj); - } - - public long ctxRichCompare(long v, long w, int op) { - increment(HPyJNIUpcall.HPyRichCompare); - return executeLongContextFunction(HPyContextMember.CTX_RICHCOMPARE, new Object[]{v, w, op}); - } - - public int ctxRichCompareBool(long v, long w, int op) { - increment(HPyJNIUpcall.HPyRichCompareBool); - return executeIntContextFunction(HPyContextMember.CTX_RICHCOMPAREBOOL, new Object[]{v, w, op}); - } - - public long ctxHash(long obj) { - increment(HPyJNIUpcall.HPyHash); - return executeLongBinaryContextFunction(HPyContextMember.CTX_HASH, obj); - } - - public int ctxBytesCheck(long h) { - increment(HPyJNIUpcall.HPyBytesCheck); - if (GraalHPyBoxing.isBoxedHandle(h)) { - Object object = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(h)); - if (object instanceof PBytes) { - return 1; - } - return executeIntBinaryContextFunction(HPyContextMember.CTX_BYTES_CHECK, h); - } - return 0; - } - - public long ctxBytesSize(long h) { - increment(HPyJNIUpcall.HPyBytesSize); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES_SIZE, h); - } - - public long ctxBytesGETSIZE(long h) { - increment(HPyJNIUpcall.HPyBytesGETSIZE); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES_GET_SIZE, h); - } - - public long ctxBytesAsString(long h) { - increment(HPyJNIUpcall.HPyBytesAsString); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES_ASSTRING, h); - } - - public long ctxBytesASSTRING(long h) { - increment(HPyJNIUpcall.HPyBytesASSTRING); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES_AS_STRING, h); - } - - public long ctxBytesFromString(long v) { - increment(HPyJNIUpcall.HPyBytesFromString); - return executeLongBinaryContextFunction(HPyContextMember.CTX_BYTES_FROMSTRING, v); - } - - public long ctxBytesFromStringAndSize(long v, long len) { - increment(HPyJNIUpcall.HPyBytesFromStringAndSize); - return executeLongTernaryContextFunction(HPyContextMember.CTX_BYTES_FROMSTRINGANDSIZE, v, len); - } - - public long ctxUnicodeFromString(long utf8) { - increment(HPyJNIUpcall.HPyUnicodeFromString); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_FROMSTRING, utf8); - } - - public int ctxUnicodeCheck(long h) { - increment(HPyJNIUpcall.HPyUnicodeCheck); - return executeIntBinaryContextFunction(HPyContextMember.CTX_UNICODE_CHECK, h); - } - - public long ctxUnicodeAsASCIIString(long h) { - increment(HPyJNIUpcall.HPyUnicodeAsASCIIString); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_ASASCIISTRING, h); - } - - public long ctxUnicodeAsLatin1String(long h) { - increment(HPyJNIUpcall.HPyUnicodeAsLatin1String); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_ASLATIN1STRING, h); - } - - public long ctxUnicodeAsUTF8String(long h) { - increment(HPyJNIUpcall.HPyUnicodeAsUTF8String); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_ASUTF8STRING, h); - } - - public long ctxUnicodeAsUTF8AndSize(long h, long size) { - increment(HPyJNIUpcall.HPyUnicodeAsUTF8AndSize); - Object string = context.bitsAsPythonObject(h); - TruffleString tsUtf8; - try { - tsUtf8 = SwitchEncodingNode.getUncached().execute(CastToTruffleStringNode.executeUncached(string), Encoding.UTF_8); - } catch (CannotCastException e) { - return HPyRaiseNode.raiseIntUncached(context, 0, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP); - } - TruffleString nativeTName = AsNativeNode.getUncached().execute(tsUtf8, TS_NATIVE_ALLOCATOR, Encoding.UTF_8, false, true); - Object result = GetInternalNativePointerNode.getUncached().execute(nativeTName, Encoding.UTF_8); - if (size != 0) { - InternalByteArray internalByteArray = GetInternalByteArrayNode.getUncached().execute(tsUtf8, Encoding.UTF_8); - UnsafeWriteSizeTNode.write(size, internalByteArray.getLength()); - } - - if (result instanceof NativePointer nativePointer) { - return nativePointer.asPointer(); - } - return interopPointerToNative(result, InteropLibrary.getUncached(result)); - } - - public long ctxUnicodeDecodeFSDefault(long v) { - increment(HPyJNIUpcall.HPyUnicodeDecodeFSDefault); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_DECODEFSDEFAULT, v); - } - - public long ctxUnicodeDecodeFSDefaultAndSize(long v, long size) { - increment(HPyJNIUpcall.HPyUnicodeDecodeFSDefaultAndSize); - return executeLongTernaryContextFunction(HPyContextMember.CTX_UNICODE_DECODEFSDEFAULTANDSIZE, v, size); - } - - public long ctxUnicodeEncodeFSDefault(long h) { - increment(HPyJNIUpcall.HPyUnicodeEncodeFSDefault); - return executeLongBinaryContextFunction(HPyContextMember.CTX_UNICODE_ENCODEFSDEFAULT, h); - } - - public int ctxUnicodeReadChar(long h, long index) { - increment(HPyJNIUpcall.HPyUnicodeReadChar); - return executeIntTernaryContextFunction(HPyContextMember.CTX_UNICODE_READCHAR, h, index); - } - - public long ctxUnicodeDecodeASCII(long s, long size, long errors) { - increment(HPyJNIUpcall.HPyUnicodeDecodeASCII); - return executeLongContextFunction(HPyContextMember.CTX_UNICODE_DECODEASCII, new long[]{s, size, errors}); - } - - public long ctxUnicodeDecodeLatin1(long s, long size, long errors) { - increment(HPyJNIUpcall.HPyUnicodeDecodeLatin1); - return executeLongContextFunction(HPyContextMember.CTX_UNICODE_DECODELATIN1, new long[]{s, size, errors}); - } - - public long ctxUnicodeFromEncodedObject(long obj, long encoding, long errors) { - increment(HPyJNIUpcall.HPyUnicodeFromEncodedObject); - return executeLongContextFunction(HPyContextMember.CTX_UNICODE_FROMENCODEDOBJECT, new long[]{obj, encoding, errors}); - } - - public long ctxUnicodeSubstring(long obj, long start, long end) { - increment(HPyJNIUpcall.HPyUnicodeSubstring); - return executeLongContextFunction(HPyContextMember.CTX_UNICODE_SUBSTRING, new long[]{obj, start, end}); - } - - public int ctxListAppend(long h_list, long h_item) { - increment(HPyJNIUpcall.HPyListAppend); - return executeIntTernaryContextFunction(HPyContextMember.CTX_LIST_APPEND, h_list, h_item); - } - - public int ctxDictCheck(long h) { - increment(HPyJNIUpcall.HPyDictCheck); - return executeIntBinaryContextFunction(HPyContextMember.CTX_DICT_CHECK, h); - } - - public long ctxDictKeys(long h) { - increment(HPyJNIUpcall.HPyDictKeys); - return executeLongBinaryContextFunction(HPyContextMember.CTX_DICT_KEYS, h); - } - - public int ctxTupleCheck(long h) { - increment(HPyJNIUpcall.HPyTupleCheck); - return executeIntBinaryContextFunction(HPyContextMember.CTX_TUPLE_CHECK, h); - } - - public int ctxSliceUnpack(long slice, long start, long stop, long step) { - increment(HPyJNIUpcall.HPySliceUnpack); - return executeIntContextFunction(HPyContextMember.CTX_SLICE_UNPACK, new long[]{slice, start, stop, step}); - } - - public long ctxContextVarNew(long name, long default_value) { - increment(HPyJNIUpcall.HPyContextVarNew); - return executeLongTernaryContextFunction(HPyContextMember.CTX_CONTEXTVAR_NEW, name, default_value); - } - - public long ctxContextVarSet(long context_var, long value) { - increment(HPyJNIUpcall.HPyContextVarSet); - return executeLongTernaryContextFunction(HPyContextMember.CTX_CONTEXTVAR_SET, context_var, value); - } - - public long ctxImportImportModule(long name) { - increment(HPyJNIUpcall.HPyImportImportModule); - return executeLongBinaryContextFunction(HPyContextMember.CTX_IMPORT_IMPORTMODULE, name); - } - - public int ctxCapsuleIsValid(long capsule, long name) { - increment(HPyJNIUpcall.HPyCapsuleIsValid); - return executeIntTernaryContextFunction(HPyContextMember.CTX_CAPSULE_ISVALID, capsule, name); - } - - public int ctxCapsuleSet(long capsule, int key, long value) { - increment(HPyJNIUpcall.HPyCapsuleSet); - return executeIntContextFunction(HPyContextMember.CTX_CAPSULE_SET, new Object[]{capsule, key, value}); - } - - public long ctxFromPyObject(long obj) { - increment(HPyJNIUpcall.HPyFromPyObject); - return executeLongBinaryContextFunction(HPyContextMember.CTX_FROMPYOBJECT, obj); - } - - public long ctxAsPyObject(long h) { - increment(HPyJNIUpcall.HPyAsPyObject); - return executeLongBinaryContextFunction(HPyContextMember.CTX_ASPYOBJECT, h); - } - - public long ctxListBuilderNew(long initial_size) { - increment(HPyJNIUpcall.HPyListBuilderNew); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LISTBUILDER_NEW, initial_size); - } - - public void ctxListBuilderSet(long builder, long index, long h_item) { - increment(HPyJNIUpcall.HPyListBuilderSet); - executeIntContextFunction(HPyContextMember.CTX_LISTBUILDER_SET, new long[]{builder, index, h_item}); - } - - public long ctxListBuilderBuild(long builder) { - increment(HPyJNIUpcall.HPyListBuilderBuild); - return executeLongBinaryContextFunction(HPyContextMember.CTX_LISTBUILDER_BUILD, builder); - } - - public void ctxListBuilderCancel(long builder) { - increment(HPyJNIUpcall.HPyListBuilderCancel); - executeIntBinaryContextFunction(HPyContextMember.CTX_LISTBUILDER_CANCEL, builder); - } - - public long ctxTupleBuilderNew(long initial_size) { - increment(HPyJNIUpcall.HPyTupleBuilderNew); - return executeLongBinaryContextFunction(HPyContextMember.CTX_TUPLEBUILDER_NEW, initial_size); - } - - public void ctxTupleBuilderSet(long builder, long index, long h_item) { - increment(HPyJNIUpcall.HPyTupleBuilderSet); - executeIntContextFunction(HPyContextMember.CTX_TUPLEBUILDER_SET, new long[]{builder, index, h_item}); - } - - public long ctxTupleBuilderBuild(long builder) { - increment(HPyJNIUpcall.HPyTupleBuilderBuild); - return executeLongBinaryContextFunction(HPyContextMember.CTX_TUPLEBUILDER_BUILD, builder); - } - - public void ctxTupleBuilderCancel(long builder) { - increment(HPyJNIUpcall.HPyTupleBuilderCancel); - executeIntBinaryContextFunction(HPyContextMember.CTX_TUPLEBUILDER_CANCEL, builder); - } - - public void ctxReenterPythonExecution(long state) { - increment(HPyJNIUpcall.HPyReenterPythonExecution); - executeIntBinaryContextFunction(HPyContextMember.CTX_REENTERPYTHONEXECUTION, state); - } - - public long ctxLeavePythonExecution() { - increment(HPyJNIUpcall.HPyLeavePythonExecution); - return executeLongContextFunction(HPyContextMember.CTX_LEAVEPYTHONEXECUTION, new long[]{}); - } - - public void ctxDump(long h) { - increment(HPyJNIUpcall.HPyDump); - executeIntBinaryContextFunction(HPyContextMember.CTX_DUMP, h); - } - - public long ctxCall(long callable, long args, long lnargs, long kwnames) { - increment(HPyJNIUpcall.HPyCall); - // some assumptions that may be made - assert callable != 0 && GraalHPyBoxing.isBoxedHandle(callable); - assert kwnames == 0 || GraalHPyBoxing.isBoxedHandle(kwnames); - assert args != 0 || lnargs == 0; - try { - if (!PInt.isIntRange(lnargs)) { - throw PRaiseNode.raiseStatic(null, TypeError, ErrorMessages.OBJ_DOES_NOT_SUPPORT_ITEM_ASSIGMENT, 0); - } - int nargs = (int) lnargs; - Object callableObj = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(callable)); - - PKeyword[] keywords; - Object[] argsArr = new Object[nargs]; - for (int i = 0; i < argsArr.length; i++) { - long argBits = UNSAFE.getLong(args + i * SIZEOF_LONG); - argsArr[i] = context.bitsAsPythonObject(argBits); - } - - if (kwnames != 0) { - Object kwnamesObj = context.getObjectForHPyHandle(GraalHPyBoxing.unboxHandle(kwnames)); - if (kwnamesObj instanceof PTuple kwnamesTuple) { - int nkw = kwnamesTuple.getSequenceStorage().length(); - Object[] kwvalues = new Object[nkw]; - long kwvaluesPtr = args + nargs * SIZEOF_LONG; - for (int i = 0; i < kwvalues.length; i++) { - long argBits = UNSAFE.getLong(kwvaluesPtr + i * SIZEOF_LONG); - kwvalues[i] = context.bitsAsPythonObject(argBits); - } - keywords = HPyPackKeywordArgsNodeGen.getUncached().execute(null, kwvalues, kwnamesTuple, nkw); - } else { - // fatal error (CPython would just cause a memory corruption) - throw CompilerDirectives.shouldNotReachHere(); - } - } else { - keywords = PKeyword.EMPTY_KEYWORDS; - } - - Object result = CallNode.executeUncached(callableObj, argsArr, keywords); - return context.pythonObjectAsBits(result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return 0; - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", HPyJNIUpcall.HPyCall.getName()); - } - } - - public long ctxCallMethod(long name, long args, long nargs, long kwnames) { - increment(HPyJNIUpcall.HPyCallMethod); - return executeLongContextFunction(HPyContextMember.CTX_CALLMETHOD, new long[]{name, args, nargs, kwnames}); - } - - public int ctxDelItem(long obj, long key) { - increment(HPyJNIUpcall.HPyDelItem); - return executeIntTernaryContextFunction(HPyContextMember.CTX_DELITEM, obj, key); - } - - public int ctxDelItemi(long obj, long idx) { - increment(HPyJNIUpcall.HPyDelItemi); - return executeIntTernaryContextFunction(HPyContextMember.CTX_DELITEM_I, obj, idx); - } - - public int ctxDelItems(long obj, long utf8_key) { - increment(HPyJNIUpcall.HPyDelItems); - return executeIntTernaryContextFunction(HPyContextMember.CTX_DELITEM_S, obj, utf8_key); - } - - public int ctxTypeGetBuiltinShape(long h_type) { - increment(HPyJNIUpcall.HPyTypeGetBuiltinShape); - assert GraalHPyBoxing.isBoxedHandle(h_type); - Object typeObject = context.bitsAsPythonObject(h_type); - int result = GraalHPyDef.getBuiltinShapeFromHiddenAttribute(typeObject); - if (result == -2) { - return HPyRaiseNode.raiseIntUncached(context, -2, TypeError, ErrorMessages.S_MUST_BE_S, "arg", "type"); - } - assert GraalHPyDef.isValidBuiltinShape(result); - return result; - } - - public long ctxDictCopy(long h) { - increment(HPyJNIUpcall.HPyDictCopy); - return executeLongBinaryContextFunction(HPyContextMember.CTX_DICT_COPY, h); - } - - public long ctxCompiles(long utf8_source, long utf8_filename, int kind) { - increment(HPyJNIUpcall.HPyCompiles); - return executeLongContextFunction(HPyContextMember.CTX_COMPILE_S, new Object[]{utf8_source, utf8_filename, kind}); - } - - public long ctxEvalCode(long code, long globals, long locals) { - increment(HPyJNIUpcall.HPyEvalCode); - return executeLongContextFunction(HPyContextMember.CTX_EVALCODE, new long[]{code, globals, locals}); - } - - public int ctxSetCallFunction(long h, long func) { - increment(HPyJNIUpcall.HPySetCallFunction); - return executeIntTernaryContextFunction(HPyContextMember.CTX_SETCALLFUNCTION, h, func); - } - // {{end ctx funcs}} - - private long createConstant(Object value) { - return context.getHPyContextHandle(value); - } - - private long createBuiltinsConstant() { - return createConstant(GetOrCreateDictNode.executeUncached(context.getContext().getBuiltins())); - } - - private static long createSingletonConstant(Object value, int handle) { - assert GraalHPyContext.getHPyHandleForSingleton(value) == handle; - return handle; - } - - private long createTypeConstant(PythonBuiltinClassType value) { - return context.getHPyContextHandle(context.getContext().lookupType(value)); - } - - /** - * Creates the context handles, i.e., allocates a handle for each object that is available in - * {@code HPyContext} (e.g. {@code HPyContext.h_None}). This table is then intended to be used - * to initialize the native {@code HPyContext *}. The handles are stored in a {@code long} array - * and the index for each handle is the context index (i.e. the index as specified in - * HPy's {@code public_api.h}). - */ - private long[] createContextHandleArray() { - // {{start ctx handles array}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_handles_init - long[] ctxHandles = new long[244]; - ctxHandles[0] = createSingletonConstant(PNone.NONE, SINGLETON_HANDLE_NONE); - ctxHandles[1] = createConstant(context.getContext().getTrue()); - ctxHandles[2] = createConstant(context.getContext().getFalse()); - ctxHandles[3] = createSingletonConstant(PNotImplemented.NOT_IMPLEMENTED, SINGLETON_HANDLE_NOT_IMPLEMENTED); - ctxHandles[4] = createSingletonConstant(PEllipsis.INSTANCE, SINGLETON_HANDLE_ELIPSIS); - ctxHandles[5] = createTypeConstant(PythonBuiltinClassType.PBaseException); - ctxHandles[6] = createTypeConstant(PythonBuiltinClassType.Exception); - ctxHandles[7] = createTypeConstant(PythonBuiltinClassType.StopAsyncIteration); - ctxHandles[8] = createTypeConstant(PythonBuiltinClassType.StopIteration); - ctxHandles[9] = createTypeConstant(PythonBuiltinClassType.GeneratorExit); - ctxHandles[10] = createTypeConstant(PythonBuiltinClassType.ArithmeticError); - ctxHandles[11] = createTypeConstant(PythonBuiltinClassType.LookupError); - ctxHandles[12] = createTypeConstant(PythonBuiltinClassType.AssertionError); - ctxHandles[13] = createTypeConstant(PythonBuiltinClassType.AttributeError); - ctxHandles[14] = createTypeConstant(PythonBuiltinClassType.BufferError); - ctxHandles[15] = createTypeConstant(PythonBuiltinClassType.EOFError); - ctxHandles[16] = createTypeConstant(PythonBuiltinClassType.FloatingPointError); - ctxHandles[17] = createTypeConstant(PythonBuiltinClassType.OSError); - ctxHandles[18] = createTypeConstant(PythonBuiltinClassType.ImportError); - ctxHandles[19] = createTypeConstant(PythonBuiltinClassType.ModuleNotFoundError); - ctxHandles[20] = createTypeConstant(PythonBuiltinClassType.IndexError); - ctxHandles[21] = createTypeConstant(PythonBuiltinClassType.KeyError); - ctxHandles[22] = createTypeConstant(PythonBuiltinClassType.KeyboardInterrupt); - ctxHandles[23] = createTypeConstant(PythonBuiltinClassType.MemoryError); - ctxHandles[24] = createTypeConstant(PythonBuiltinClassType.NameError); - ctxHandles[25] = createTypeConstant(PythonBuiltinClassType.OverflowError); - ctxHandles[26] = createTypeConstant(PythonBuiltinClassType.RuntimeError); - ctxHandles[27] = createTypeConstant(PythonBuiltinClassType.RecursionError); - ctxHandles[28] = createTypeConstant(PythonBuiltinClassType.NotImplementedError); - ctxHandles[29] = createTypeConstant(PythonBuiltinClassType.SyntaxError); - ctxHandles[30] = createTypeConstant(PythonBuiltinClassType.IndentationError); - ctxHandles[31] = createTypeConstant(PythonBuiltinClassType.TabError); - ctxHandles[32] = createTypeConstant(PythonBuiltinClassType.ReferenceError); - ctxHandles[33] = createTypeConstant(SystemError); - ctxHandles[34] = createTypeConstant(PythonBuiltinClassType.SystemExit); - ctxHandles[35] = createTypeConstant(PythonBuiltinClassType.TypeError); - ctxHandles[36] = createTypeConstant(PythonBuiltinClassType.UnboundLocalError); - ctxHandles[37] = createTypeConstant(PythonBuiltinClassType.UnicodeError); - ctxHandles[38] = createTypeConstant(PythonBuiltinClassType.UnicodeEncodeError); - ctxHandles[39] = createTypeConstant(PythonBuiltinClassType.UnicodeDecodeError); - ctxHandles[40] = createTypeConstant(PythonBuiltinClassType.UnicodeTranslateError); - ctxHandles[41] = createTypeConstant(PythonBuiltinClassType.ValueError); - ctxHandles[42] = createTypeConstant(PythonBuiltinClassType.ZeroDivisionError); - ctxHandles[43] = createTypeConstant(PythonBuiltinClassType.BlockingIOError); - ctxHandles[44] = createTypeConstant(PythonBuiltinClassType.BrokenPipeError); - ctxHandles[45] = createTypeConstant(PythonBuiltinClassType.ChildProcessError); - ctxHandles[46] = createTypeConstant(PythonBuiltinClassType.ConnectionError); - ctxHandles[47] = createTypeConstant(PythonBuiltinClassType.ConnectionAbortedError); - ctxHandles[48] = createTypeConstant(PythonBuiltinClassType.ConnectionRefusedError); - ctxHandles[49] = createTypeConstant(PythonBuiltinClassType.ConnectionResetError); - ctxHandles[50] = createTypeConstant(PythonBuiltinClassType.FileExistsError); - ctxHandles[51] = createTypeConstant(PythonBuiltinClassType.FileNotFoundError); - ctxHandles[52] = createTypeConstant(PythonBuiltinClassType.InterruptedError); - ctxHandles[53] = createTypeConstant(PythonBuiltinClassType.IsADirectoryError); - ctxHandles[54] = createTypeConstant(PythonBuiltinClassType.NotADirectoryError); - ctxHandles[55] = createTypeConstant(PythonBuiltinClassType.PermissionError); - ctxHandles[56] = createTypeConstant(PythonBuiltinClassType.ProcessLookupError); - ctxHandles[57] = createTypeConstant(PythonBuiltinClassType.TimeoutError); - ctxHandles[58] = createTypeConstant(PythonBuiltinClassType.Warning); - ctxHandles[59] = createTypeConstant(PythonBuiltinClassType.UserWarning); - ctxHandles[60] = createTypeConstant(PythonBuiltinClassType.DeprecationWarning); - ctxHandles[61] = createTypeConstant(PythonBuiltinClassType.PendingDeprecationWarning); - ctxHandles[62] = createTypeConstant(PythonBuiltinClassType.SyntaxWarning); - ctxHandles[63] = createTypeConstant(PythonBuiltinClassType.RuntimeWarning); - ctxHandles[64] = createTypeConstant(PythonBuiltinClassType.FutureWarning); - ctxHandles[65] = createTypeConstant(PythonBuiltinClassType.ImportWarning); - ctxHandles[66] = createTypeConstant(PythonBuiltinClassType.UnicodeWarning); - ctxHandles[67] = createTypeConstant(PythonBuiltinClassType.BytesWarning); - ctxHandles[68] = createTypeConstant(PythonBuiltinClassType.ResourceWarning); - ctxHandles[69] = createTypeConstant(PythonBuiltinClassType.PythonObject); - ctxHandles[70] = createTypeConstant(PythonBuiltinClassType.PythonClass); - ctxHandles[71] = createTypeConstant(PythonBuiltinClassType.Boolean); - ctxHandles[72] = createTypeConstant(PythonBuiltinClassType.PInt); - ctxHandles[73] = createTypeConstant(PythonBuiltinClassType.PFloat); - ctxHandles[74] = createTypeConstant(PythonBuiltinClassType.PString); - ctxHandles[75] = createTypeConstant(PythonBuiltinClassType.PTuple); - ctxHandles[76] = createTypeConstant(PythonBuiltinClassType.PList); - ctxHandles[238] = createTypeConstant(PythonBuiltinClassType.PComplex); - ctxHandles[239] = createTypeConstant(PythonBuiltinClassType.PBytes); - ctxHandles[240] = createTypeConstant(PythonBuiltinClassType.PMemoryView); - ctxHandles[241] = createTypeConstant(PythonBuiltinClassType.Capsule); - ctxHandles[242] = createTypeConstant(PythonBuiltinClassType.PSlice); - ctxHandles[243] = createBuiltinsConstant(); - return ctxHandles; - - // @formatter:on - // Checkstyle: resume - // {{end ctx handles array}} - } - - private Object executeContextFunction(HPyContextMember member, long[] arguments) { - HPyContextSignature signature = member.getSignature(); - HPyContextSignatureType[] argTypes = signature.parameterTypes(); - assert arguments.length == argTypes.length - 1; - Object[] argCast = new Object[argTypes.length]; - argCast[0] = context; - for (int i = 1; i < argCast.length; i++) { - argCast[i] = convertLongArg(argTypes[i], arguments[i - 1]); - } - return GraalHPyContextFunction.getUncached(member).execute(argCast); - } - - private Object executeBinaryContextFunction(HPyContextMember member, long larg0) { - HPyContextSignature signature = member.getSignature(); - HPyContextSignatureType[] argTypes = signature.parameterTypes(); - assert argTypes.length - 1 == 1; - Object arg0 = convertLongArg(argTypes[1], larg0); - return ((HPyBinaryContextFunction) GraalHPyContextFunction.getUncached(member)).execute(context, arg0); - } - - private Object executeTernaryContextFunction(HPyContextMember member, long larg0, long larg1) { - HPyContextSignature signature = member.getSignature(); - HPyContextSignatureType[] argTypes = signature.parameterTypes(); - assert argTypes.length - 1 == 2; - Object arg0 = convertLongArg(argTypes[1], larg0); - Object arg1 = convertLongArg(argTypes[2], larg1); - return ((HPyTernaryContextFunction) GraalHPyContextFunction.getUncached(member)).execute(context, arg0, arg1); - } - - private Object executeContextFunction(HPyContextMember member, Object[] arguments) { - HPyContextSignature signature = member.getSignature(); - HPyContextSignatureType[] argTypes = signature.parameterTypes(); - assert arguments.length == argTypes.length - 1; - Object[] argCast = new Object[argTypes.length]; - argCast[0] = context; - for (int i = 1; i < argCast.length; i++) { - argCast[i] = convertArg(argTypes[i], arguments[i - 1]); - } - return GraalHPyContextFunction.getUncached(member).execute(argCast); - } - - private long executeLongContextFunction(HPyContextMember member, long[] arguments) { - try { - Object result = executeContextFunction(member, arguments); - return convertLongRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getLongErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private long executeLongBinaryContextFunction(HPyContextMember member, long arg0) { - try { - Object result = executeBinaryContextFunction(member, arg0); - return convertLongRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getLongErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private long executeLongTernaryContextFunction(HPyContextMember member, long arg0, long arg1) { - try { - Object result = executeTernaryContextFunction(member, arg0, arg1); - return convertLongRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getLongErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private int executeIntContextFunction(HPyContextMember member, long[] arguments) { - try { - Object result = executeContextFunction(member, arguments); - return convertIntRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getIntErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - @TruffleBoundary - private int executeIntBinaryContextFunction(HPyContextMember member, long arg0) { - try { - Object result = executeBinaryContextFunction(member, arg0); - return convertIntRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getIntErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private int executeIntTernaryContextFunction(HPyContextMember member, long arg0, long arg1) { - try { - Object result = executeTernaryContextFunction(member, arg0, arg1); - return convertIntRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getIntErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private long executeLongContextFunction(HPyContextMember member, Object[] arguments) { - try { - Object result = executeContextFunction(member, arguments); - return convertLongRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getLongErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private int executeIntContextFunction(HPyContextMember member, Object[] arguments) { - try { - Object result = executeContextFunction(member, arguments); - return convertIntRet(member.getSignature().returnType(), result); - } catch (PException e) { - HPyTransformExceptionToNativeNode.executeUncached(e); - return getIntErrorValue(member.getSignature().returnType()); - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", member.getName()); - } - } - - private Object convertLongArg(HPyContextSignatureType type, long argBits) { - return switch (type) { - case HPy, HPyThreadState, HPyListBuilder, HPyTupleBuilder -> context.bitsAsPythonObject(argBits); - case Int, HPy_UCS4 -> -1; - case Int64_t, Uint64_t, Size_t, HPy_ssize_t, HPy_hash_t, VoidPtr, CVoid -> argBits; - case Int32_t, Uint32_t -> argBits & 0xFFFFFFFFL; - case CDouble -> throw CompilerDirectives.shouldNotReachHere("invalid argument handle"); - case HPyModuleDefPtr, HPyType_SpecPtr, HPyType_SpecParamPtr, HPy_ssize_tPtr, ConstHPyPtr, HPyPtr, HPyCallFunctionPtr, CharPtr, ConstCharPtr -> argBits; - case Cpy_PyObjectPtr -> nativeToInteropPointer(argBits); - default -> throw CompilerDirectives.shouldNotReachHere("unsupported arg type"); - }; - } - - private Object convertArg(HPyContextSignatureType type, Object arg) { - return switch (type) { - case Int, Int32_t, Uint32_t, HPy_UCS4, _HPyCapsule_key, HPy_SourceKind -> (Integer) arg; - default -> convertLongArg(type, (Long) arg); - }; - } - - private long convertLongRet(HPyContextSignatureType type, Object result) { - return switch (type) { - case HPy, HPyThreadState, HPyListBuilder, HPyTupleBuilder -> GraalHPyBoxing.boxHandle(context.getHPyHandleForObject(result)); - case VoidPtr, CharPtr, ConstCharPtr, Cpy_PyObjectPtr -> coerceToPointer(result); - case Int64_t, Uint64_t, Size_t, HPy_ssize_t, HPy_hash_t -> (Long) HPyAsNativeInt64NodeGen.getUncached().execute(result); - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } - - private int convertIntRet(HPyContextSignatureType type, Object result) { - return switch (type) { - case Int, Int32_t, Uint32_t, HPy_UCS4 -> (int) result; - case CVoid -> 0; - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } - - private long getLongErrorValue(HPyContextSignatureType type) { - return switch (type) { - case HPy, VoidPtr, CharPtr, ConstCharPtr, Cpy_PyObjectPtr, HPyListBuilder, HPyTupleBuilder, HPyThreadState -> 0; - case Int64_t, Uint64_t, Size_t, HPy_ssize_t, HPy_hash_t -> -1L; - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } - - private int getIntErrorValue(HPyContextSignatureType type) { - return switch (type) { - case Int, Int32_t, Uint32_t, HPy_UCS4 -> -1; - case CVoid -> 0; - case HPyType_BuiltinShape -> -2; - default -> throw CompilerDirectives.shouldNotReachHere(); - }; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIConvertArgNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIConvertArgNode.java deleted file mode 100644 index db63b1a2d1..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIConvertArgNode.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy.jni; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyBoxing; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GetHPyHandleForSingleton; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.LLVMType; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFactory.GetHPyHandleForSingletonNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.dsl.NeverDefault; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; - -public abstract class GraalHPyJNIConvertArgNode extends Node { - - private static final GraalHPyJNIConvertArgUncachedNode UNCACHED = new GraalHPyJNIConvertArgUncachedNode(); - - @NeverDefault - public static GraalHPyJNIConvertArgNode create(@SuppressWarnings("unused") LLVMType signature) { - return new GraalHPyJNIConvertArgCachedNode(); - } - - public static GraalHPyJNIConvertArgNode getUncached(@SuppressWarnings("unused") LLVMType signature) { - return UNCACHED; - } - - public abstract long execute(Object[] arguments, int i); - - protected static GraalHPyJNIContext getHPyContext(Object[] arguments) { - Object backend = arguments[0]; - if (backend instanceof GraalHPyJNIContext jniBackend) { - return jniBackend; - } - /* - * That's clearly an internal error because we cannot have a GraalHPyJNIConvertArgNode - * instance if we are not using the JNI backend. - */ - throw CompilerDirectives.shouldNotReachHere("first argument is expected to the HPy context"); - } - - static final class GraalHPyJNIConvertArgCachedNode extends GraalHPyJNIConvertArgNode { - /** - * Carefully picked limit. Expected possible argument object types are: LLVM native pointer, - * LLVM managed pointer, {@link GraalHPyContext}, and {@link GraalHPyHandle}. - */ - private static final int CACHE_LIMIT = 4; - - @Child private InteropLibrary interopLibrary; - @CompilationFinal private ConditionProfile profile; - @Child GetHPyHandleForSingleton getHPyHandleForSingleton; - - @Override - public long execute(Object[] arguments, int i) { - CompilerAsserts.partialEvaluationConstant(i); - // TODO(fa): improved cached implementation; use state bits to remember types we've - // seen per argument - Object value = arguments[i]; - - if (value instanceof GraalHPyHandle handle) { - Object delegate = handle.getDelegate(); - if (GraalHPyBoxing.isBoxablePrimitive(delegate)) { - if (delegate instanceof Integer) { - return GraalHPyBoxing.boxInt((Integer) delegate); - } - assert delegate instanceof Double; - return GraalHPyBoxing.boxDouble((Double) delegate); - } else { - return handle.getId(getHPyContext(arguments).getHPyContext(), ensureProfile(), ensureHandleForSingletonNode()); - } - } else if (value instanceof Long) { - return (long) value; - } else { - if (interopLibrary == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - interopLibrary = insert(InteropLibrary.getFactory().createDispatched(CACHE_LIMIT)); - } - if (!interopLibrary.isPointer(value)) { - interopLibrary.toNative(value); - } - try { - return interopLibrary.asPointer(value); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - } - - private ConditionProfile ensureProfile() { - if (profile == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - profile = ConditionProfile.create(); - } - return profile; - } - - private GetHPyHandleForSingleton ensureHandleForSingletonNode() { - if (getHPyHandleForSingleton == null) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - getHPyHandleForSingleton = insert(GetHPyHandleForSingletonNodeGen.create()); - } - return getHPyHandleForSingleton; - } - } - - static final class GraalHPyJNIConvertArgUncachedNode extends GraalHPyJNIConvertArgNode { - - @Override - public long execute(Object[] arguments, int i) { - Object value = arguments[i]; - if (value instanceof GraalHPyHandle handle) { - Object delegate = handle.getDelegate(); - if (GraalHPyBoxing.isBoxablePrimitive(delegate)) { - if (delegate instanceof Integer) { - return GraalHPyBoxing.boxInt((Integer) delegate); - } - assert delegate instanceof Double; - return GraalHPyBoxing.boxDouble((Double) delegate); - } else { - return handle.getIdUncached(getHPyContext(arguments).getHPyContext()); - } - } else if (value instanceof Long) { - return (long) value; - } else { - InteropLibrary interopLibrary = InteropLibrary.getUncached(value); - if (!interopLibrary.isPointer(value)) { - interopLibrary.toNative(value); - } - try { - return interopLibrary.asPointer(value); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIFunctionPointer.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIFunctionPointer.java deleted file mode 100644 index 670b66bb97..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNIFunctionPointer.java +++ /dev/null @@ -1,516 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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.builtins.objects.cext.hpy.jni; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.LLVMType; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyMode; -import com.oracle.graal.python.runtime.PythonImageBuildOptions; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; - -/** - * Represents a native function pointer that will be called using an appropriate JNI trampoline - * function depending on the {@link #signature} and the {@link #mode} enum. - */ -@ExportLibrary(InteropLibrary.class) -public final class GraalHPyJNIFunctionPointer implements TruffleObject { - final long pointer; - final LLVMType signature; - - /** - * Function pointers created through {@code HPyModule_Create} or {@code HPyType_FromSpec} - * remembers if the context that created it was in debug mode. Depending on this flag, we decide - * which trampolines (universal or debug) we need to use. For reference: In CPython this is - * implicitly given by the fact that the HPy context is stored in a C global variable - * {@code _ctx_for_trampolines}. - */ - final HPyMode mode; - - public GraalHPyJNIFunctionPointer(long pointer, LLVMType signature, HPyMode mode) { - assert !PythonImageBuildOptions.WITHOUT_JNI; - this.pointer = pointer; - this.signature = signature; - this.mode = mode; - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean isExecutable() { - return true; - } - - @ExportMessage - static final class Execute { - - @Specialization(guards = "receiver.signature == cachedSignature", limit = "1") - static Object doCached(GraalHPyJNIFunctionPointer receiver, Object[] arguments, - @CachedLibrary(limit = "1") InteropLibrary interopLibrary, - @Cached("receiver.signature") LLVMType cachedSignature, - @Cached(parameters = "receiver.signature") GraalHPyJNIConvertArgNode convertArgNode) { - // Make it explicit, that we cannot to JNI calls if WITHOUT_JNI is true. - if (PythonImageBuildOptions.WITHOUT_JNI) { - throw CompilerDirectives.shouldNotReachHere(); - } - return switch (receiver.mode) { - case MODE_UNIVERSAL -> callUniversal(receiver, cachedSignature, convertHPyContext(arguments), arguments, interopLibrary, convertArgNode); - case MODE_DEBUG -> callDebug(receiver, cachedSignature, convertHPyDebugContext(arguments), arguments, interopLibrary, convertArgNode); - case MODE_TRACE -> callUniversal(receiver, cachedSignature, convertHPyTraceContext(arguments), arguments, interopLibrary, convertArgNode); - default -> throw CompilerDirectives.shouldNotReachHere("unsupported HPy mode"); - }; - } - - /** - * Uses the appropriate trampoline to call the native function pointer. - */ - private static long callUniversal(GraalHPyJNIFunctionPointer receiver, LLVMType signature, long ctx, Object[] arguments, - InteropLibrary interopLibrary, GraalHPyJNIConvertArgNode convertArgNode) { - switch (signature) { - case HPyModule_init: - return GraalHPyJNITrampolines.executeModuleInit(receiver.pointer); - case HPyModule_create: - return GraalHPyJNITrampolines.executeModcreate(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_noargs: - return GraalHPyJNITrampolines.executeNoargs(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_unaryfunc: - return GraalHPyJNITrampolines.executeUnaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_getiterfunc: - return GraalHPyJNITrampolines.executeGetiterfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_iternextfunc: - return GraalHPyJNITrampolines.executeIternextfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_reprfunc: - return GraalHPyJNITrampolines.executeReprfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_lenfunc: - return GraalHPyJNITrampolines.executeLenfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_hashfunc: - return GraalHPyJNITrampolines.executeHashfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_binaryfunc: - return GraalHPyJNITrampolines.executeBinaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_o: - return GraalHPyJNITrampolines.executeO(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_getter: - return GraalHPyJNITrampolines.executeGetter(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrfunc: - return GraalHPyJNITrampolines.executeGetattrfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrofunc: - return GraalHPyJNITrampolines.executeGetattrofunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_ssizeargfunc: - return GraalHPyJNITrampolines.executeSsizeargfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_traverseproc: - return GraalHPyJNITrampolines.executeTraverseproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_varargs: - return GraalHPyJNITrampolines.executeVarargs(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_ternaryfunc: - return GraalHPyJNITrampolines.executeTernaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_descrgetfunc: - return GraalHPyJNITrampolines.executeDescrgetfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_ssizessizeargfunc: - return GraalHPyJNITrampolines.executeSsizessizeargfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_keywords: - return GraalHPyJNITrampolines.executeKeywords(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3), convertArgNode.execute(arguments, 4)); - case HPyFunc_inquiry: - return GraalHPyJNITrampolines.executeInquiry(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_ssizeobjargproc: - return GraalHPyJNITrampolines.executeSsizeobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), (long) arguments[2], convertArgNode.execute(arguments, 3)); - case HPyFunc_initproc: - return GraalHPyJNITrampolines.executeInitproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), (long) arguments[3], - convertArgNode.execute(arguments, 4)); - case HPyFunc_ssizessizeobjargproc: - return GraalHPyJNITrampolines.executeSsizessizeobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), (long) arguments[2], (long) arguments[3], - convertArgNode.execute(arguments, 4)); - case HPyFunc_setter: - return GraalHPyJNITrampolines.executeSetter(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrfunc: - return GraalHPyJNITrampolines.executeSetattrfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_objobjargproc: - return GraalHPyJNITrampolines.executeObjobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_descrsetfunc: - return GraalHPyJNITrampolines.executeDescrsetfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrofunc: - return GraalHPyJNITrampolines.executeSetattrofunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), - convertArgNode.execute(arguments, 3)); - case HPyFunc_freefunc: - GraalHPyJNITrampolines.executeFreefunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - return 0; - case HPyFunc_richcmpfunc: - return GraalHPyJNITrampolines.executeRichcmpfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_objobjproc: - return GraalHPyJNITrampolines.executeObjobjproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - case HPyFunc_getbufferproc: - return GraalHPyJNITrampolines.executeGetbufferproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_releasebufferproc: - GraalHPyJNITrampolines.executeReleasebufferproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), convertArgNode.execute(arguments, 2)); - return 0; - case HPyFunc_destroyfunc: - GraalHPyJNITrampolines.executeDestroyfunc(receiver.pointer, convertPointer(arguments[0], interopLibrary)); - return 0; - case HPyFunc_destructor: - GraalHPyJNITrampolines.executeDestructor(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - return 0; - } - throw CompilerDirectives.shouldNotReachHere(); - } - - /** - * When we are in debug mode, we need to use different trampolines for calling the HPy - * extension functions because object parameters (that will become handles) will be wrapped - * in debug handles ({@code DHPy}) and, vice versa, object return values need to be - * unwrapped. This un/-wrapping is done by the trampoline via calling {@code DHPy_open} and - * {@code DHPy_unwrap}. - */ - private static long callTrace(GraalHPyJNIFunctionPointer receiver, LLVMType signature, Object[] arguments, - InteropLibrary interopLibrary, GraalHPyJNIConvertArgNode convertArgNode) { - switch (signature) { - case HPyModule_init: - // there is no difference to the universal mode - return GraalHPyJNITrampolines.executeModuleInit(receiver.pointer); - case HPyModule_create: - return GraalHPyJNITrampolines.executeDebugModcreate(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_noargs: - return GraalHPyJNITrampolines.executeDebugNoargs(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_unaryfunc: - return GraalHPyJNITrampolines.executeDebugUnaryfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_getiterfunc: - return GraalHPyJNITrampolines.executeDebugGetiterfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_iternextfunc: - return GraalHPyJNITrampolines.executeDebugIternextfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_reprfunc: - return GraalHPyJNITrampolines.executeDebugReprfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_lenfunc: - return GraalHPyJNITrampolines.executeDebugLenfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_hashfunc: - // HPy_ssize_t (*HPyFunc_lenfunc)(HPyContext *ctx, HPy); - // HPy_hash_t (*HPyFunc_hashfunc)(HPyContext *ctx, HPy); - return GraalHPyJNITrampolines.executeDebugHashfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_binaryfunc: - return GraalHPyJNITrampolines.executeDebugBinaryfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_o: - return GraalHPyJNITrampolines.executeDebugO(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrofunc: - return GraalHPyJNITrampolines.executeDebugGetattrofunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrfunc: - // HPy (*HPyFunc_getattrfunc) (HPyContext *ctx, HPy, char *); - return GraalHPyJNITrampolines.executeDebugGetattrfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_ssizeargfunc: - // HPy (*HPyFunc_ssizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugSsizeargfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getter: - // HPy (*HPyFunc_getter) (HPyContext *ctx, HPy, void *); - return GraalHPyJNITrampolines.executeDebugGetter(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_traverseproc: - // int (*HPyFunc_traverseproc)(void *, HPyFunc_visitproc, void *); - return GraalHPyJNITrampolines.executeTraverseproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_varargs: - // HPy (*HPyFunc_varargs)(HPyContext *, HPy, HPy *, HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugVarargs(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_ternaryfunc: - // HPy (*HPyFunc_ternaryfunc)(HPyContext *, HPy, HPy, HPy) - return GraalHPyJNITrampolines.executeDebugTernaryfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_descrgetfunc: - return GraalHPyJNITrampolines.executeDebugDescrgetfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - // HPy (*HPyFunc_descrgetfunc)(HPyContext *, HPy, HPy, HPy) - case HPyFunc_ssizessizeargfunc: - // HPy (*HPyFunc_ssizessizeargfunc)(HPyContext *, HPy, HPy_ssize_t, - // HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugSsizessizeargfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_keywords: - // HPy (*HPyFunc_keywords)(HPyContext *, HPy, HPy *, HPy_ssize_t , HPy) - return GraalHPyJNITrampolines.executeDebugKeywords(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3), convertArgNode.execute(arguments, 4)); - case HPyFunc_inquiry: - return GraalHPyJNITrampolines.executeDebugInquiry(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - case HPyFunc_ssizeobjargproc: - return GraalHPyJNITrampolines.executeDebugSsizeobjargproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), (long) arguments[2], - convertArgNode.execute(arguments, 3)); - case HPyFunc_initproc: - return GraalHPyJNITrampolines.executeDebugInitproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (long) arguments[3], convertArgNode.execute(arguments, 4)); - case HPyFunc_ssizessizeobjargproc: - return GraalHPyJNITrampolines.executeDebugSsizessizeobjargproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), (long) arguments[2], - (long) arguments[3], convertArgNode.execute(arguments, 4)); - case HPyFunc_setter: - // int (*HPyFunc_setter)(HPyContext *ctx, HPy, HPy, void *); - return GraalHPyJNITrampolines.executeDebugSetter(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrfunc: - // int (*HPyFunc_setattrfunc)(HPyContext *ctx, HPy, char *, HPy); - return GraalHPyJNITrampolines.executeDebugSetattrfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_objobjargproc: - return GraalHPyJNITrampolines.executeDebugObjobjargproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_descrsetfunc: - return GraalHPyJNITrampolines.executeDebugDescrsetfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrofunc: - return GraalHPyJNITrampolines.executeDebugSetattrofunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_freefunc: - // no handles involved in freefunc; we can use the universal trampoline - GraalHPyJNITrampolines.executeDebugFreefunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - return 0; - case HPyFunc_richcmpfunc: - // HPy (*HPyFunc_richcmpfunc)(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp) - return GraalHPyJNITrampolines.executeDebugRichcmpfunc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_objobjproc: - return GraalHPyJNITrampolines.executeDebugObjobjproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getbufferproc: - return GraalHPyJNITrampolines.executeDebugGetbufferproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_releasebufferproc: - GraalHPyJNITrampolines.executeDebugReleasebufferproc(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - return 0; - case HPyFunc_destroyfunc: - GraalHPyJNITrampolines.executeDestroyfunc(convertPointer(arguments[0], interopLibrary), receiver.pointer); - return 0; - case HPyFunc_destructor: - GraalHPyJNITrampolines.executeDebugDestructor(receiver.pointer, convertHPyTraceContext(arguments), convertArgNode.execute(arguments, 1)); - return 0; - } - throw CompilerDirectives.shouldNotReachHere(); - } - - /** - * When we are in debug mode, we need to use different trampolines for calling the HPy - * extension functions because object parameters (that will become handles) will be wrapped - * in debug handles ({@code DHPy}) and, vice versa, object return values need to be - * unwrapped. This un/-wrapping is done by the trampoline via calling {@code DHPy_open} and - * {@code DHPy_unwrap}. - */ - private static long callDebug(GraalHPyJNIFunctionPointer receiver, LLVMType signature, long ctx, Object[] arguments, - InteropLibrary interopLibrary, GraalHPyJNIConvertArgNode convertArgNode) { - switch (signature) { - case HPyModule_init: - // there is not difference to the universal mode - return GraalHPyJNITrampolines.executeModuleInit(receiver.pointer); - case HPyModule_create: - return GraalHPyJNITrampolines.executeDebugModcreate(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_noargs: - return GraalHPyJNITrampolines.executeDebugNoargs(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_unaryfunc: - return GraalHPyJNITrampolines.executeDebugUnaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_getiterfunc: - return GraalHPyJNITrampolines.executeDebugGetiterfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_iternextfunc: - return GraalHPyJNITrampolines.executeDebugIternextfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_reprfunc: - return GraalHPyJNITrampolines.executeDebugReprfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_lenfunc: - return GraalHPyJNITrampolines.executeDebugLenfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_hashfunc: - // HPy_ssize_t (*HPyFunc_lenfunc)(HPyContext *ctx, HPy); - // HPy_hash_t (*HPyFunc_hashfunc)(HPyContext *ctx, HPy); - return GraalHPyJNITrampolines.executeDebugHashfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_binaryfunc: - return GraalHPyJNITrampolines.executeDebugBinaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_o: - return GraalHPyJNITrampolines.executeDebugO(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrofunc: - return GraalHPyJNITrampolines.executeDebugGetattrofunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getattrfunc: - // HPy (*HPyFunc_getattrfunc) (HPyContext *ctx, HPy, char *); - return GraalHPyJNITrampolines.executeDebugGetattrfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_ssizeargfunc: - // HPy (*HPyFunc_ssizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugSsizeargfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getter: - // HPy (*HPyFunc_getter) (HPyContext *ctx, HPy, void *); - return GraalHPyJNITrampolines.executeDebugGetter(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_traverseproc: - // int (*HPyFunc_traverseproc)(void *, HPyFunc_visitproc, void *); - return GraalHPyJNITrampolines.executeTraverseproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_varargs: - // HPy (*HPyFunc_varargs)(HPyContext *, HPy, HPy *, HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugVarargs(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_ternaryfunc: - // HPy (*HPyFunc_ternaryfunc)(HPyContext *, HPy, HPy, HPy) - return GraalHPyJNITrampolines.executeDebugTernaryfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_descrgetfunc: - return GraalHPyJNITrampolines.executeDebugDescrgetfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - // HPy (*HPyFunc_descrgetfunc)(HPyContext *, HPy, HPy, HPy) - case HPyFunc_ssizessizeargfunc: - // HPy (*HPyFunc_ssizessizeargfunc)(HPyContext *, HPy, HPy_ssize_t, - // HPy_ssize_t); - return GraalHPyJNITrampolines.executeDebugSsizessizeargfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_keywords: - // HPy (*HPyFunc_keywords)(HPyContext *, HPy, HPy *, HPy_ssize_t , HPy) - return GraalHPyJNITrampolines.executeDebugKeywords(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3), convertArgNode.execute(arguments, 4)); - case HPyFunc_inquiry: - return GraalHPyJNITrampolines.executeDebugInquiry(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - case HPyFunc_ssizeobjargproc: - return GraalHPyJNITrampolines.executeDebugSsizeobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), (long) arguments[2], - convertArgNode.execute(arguments, 3)); - case HPyFunc_initproc: - return GraalHPyJNITrampolines.executeDebugInitproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (long) arguments[3], convertArgNode.execute(arguments, 4)); - case HPyFunc_ssizessizeobjargproc: - return GraalHPyJNITrampolines.executeDebugSsizessizeobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), (long) arguments[2], - (long) arguments[3], convertArgNode.execute(arguments, 4)); - case HPyFunc_setter: - // int (*HPyFunc_setter)(HPyContext *ctx, HPy, HPy, void *); - return GraalHPyJNITrampolines.executeDebugSetter(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrfunc: - // int (*HPyFunc_setattrfunc)(HPyContext *ctx, HPy, char *, HPy); - return GraalHPyJNITrampolines.executeDebugSetattrfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_objobjargproc: - return GraalHPyJNITrampolines.executeDebugObjobjargproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_descrsetfunc: - return GraalHPyJNITrampolines.executeDebugDescrsetfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_setattrofunc: - return GraalHPyJNITrampolines.executeDebugSetattrofunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), convertArgNode.execute(arguments, 3)); - case HPyFunc_freefunc: - // no handles involved in freefunc; we can use the universal trampoline - GraalHPyJNITrampolines.executeDebugFreefunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - return 0; - case HPyFunc_richcmpfunc: - // HPy (*HPyFunc_richcmpfunc)(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp) - return GraalHPyJNITrampolines.executeDebugRichcmpfunc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_objobjproc: - return GraalHPyJNITrampolines.executeDebugObjobjproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - case HPyFunc_getbufferproc: - return GraalHPyJNITrampolines.executeDebugGetbufferproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2), (int) arguments[3]); - case HPyFunc_releasebufferproc: - GraalHPyJNITrampolines.executeDebugReleasebufferproc(receiver.pointer, ctx, convertArgNode.execute(arguments, 1), - convertArgNode.execute(arguments, 2)); - return 0; - case HPyFunc_destroyfunc: - GraalHPyJNITrampolines.executeDestroyfunc(convertPointer(arguments[0], interopLibrary), receiver.pointer); - return 0; - case HPyFunc_destructor: - GraalHPyJNITrampolines.executeDebugDestructor(receiver.pointer, ctx, convertArgNode.execute(arguments, 1)); - return 0; - } - throw CompilerDirectives.shouldNotReachHere(); - } - - private static long convertHPyContext(Object[] arguments) { - GraalHPyJNIContext jniBackend = GraalHPyJNIConvertArgNode.getHPyContext(arguments); - try { - return jniBackend.asPointer(); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - private static long convertHPyDebugContext(Object[] arguments) { - GraalHPyJNIContext jniBackend = GraalHPyJNIConvertArgNode.getHPyContext(arguments); - assert jniBackend.getHPyDebugContext() != 0; - return jniBackend.getHPyDebugContext(); - } - - private static long convertHPyTraceContext(Object[] arguments) { - GraalHPyJNIContext jniBackend = GraalHPyJNIConvertArgNode.getHPyContext(arguments); - assert jniBackend.getHPyTraceContext() != 0; - return jniBackend.getHPyTraceContext(); - } - - private static long convertPointer(Object argument, InteropLibrary interopLibrary) { - if (!interopLibrary.isPointer(argument)) { - interopLibrary.toNative(argument); - } - try { - return interopLibrary.asPointer(argument); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean isPointer() { - return true; - } - - @ExportMessage - long asPointer() { - return pointer; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNINodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNINodes.java deleted file mode 100644 index bef2dab579..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNINodes.java +++ /dev/null @@ -1,848 +0,0 @@ -/* - * Copyright (c) 2023, 2024, 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.builtins.objects.cext.hpy.jni; - -import static com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.UNSAFE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle.NULL_HANDLE_DELEGATE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.jni.GraalHPyJNIContext.coerceToPointer; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; - -import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyBoxing; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.BulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.FreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.GetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.IsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GraalHPyHandleReference; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyData; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.api.profiles.InlinedExactClassProfile; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.Encoding; - -import sun.misc.Unsafe; - -abstract class GraalHPyJNINodes { - - private GraalHPyJNINodes() { - } - - static final class UnsafeIsNullNode extends IsNullNode { - - static final UnsafeIsNullNode UNCACHED = new UnsafeIsNullNode(); - - private UnsafeIsNullNode() { - } - - @Override - protected boolean execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer) { - return coerceToPointer(pointer) == 0; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeAllocateNode extends AllocateNode { - - static final UnsafeAllocateNode UNCACHED = new UnsafeAllocateNode(); - - private UnsafeAllocateNode() { - } - - @Override - protected Object execute(@SuppressWarnings("unused") GraalHPyContext ctx, long size, boolean zero) { - long result = UNSAFE.allocateMemory(size); - if (zero) { - UNSAFE.setMemory(result, size, (byte) 0); - } - return result; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeFreeNode extends FreeNode { - - static final UnsafeFreeNode UNCACHED = new UnsafeFreeNode(); - - private UnsafeFreeNode() { - } - - @Override - protected void execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer) { - UNSAFE.freeMemory(coerceToPointer(pointer)); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeBulkFreeHandleReferencesNode extends BulkFreeHandleReferencesNode { - - private static final int BULK_CAPACITY = 1024; - - static final UnsafeBulkFreeHandleReferencesNode UNCACHED = new UnsafeBulkFreeHandleReferencesNode(); - - private UnsafeBulkFreeHandleReferencesNode() { - } - - @Override - @TruffleBoundary - protected void execute(@SuppressWarnings("unused") GraalHPyContext ctx, GraalHPyHandleReference[] references) { - long[] nativeSpacePtrs = new long[BULK_CAPACITY]; - long[] destroyFuncPtrs = new long[BULK_CAPACITY]; - int i = 0; - for (GraalHPyHandleReference ref : references) { - long destroyFunPtr = coerceToPointer(ref.getDestroyFunc()); - long nativeSpacePtr = coerceToPointer(ref.getNativeSpace()); - if (destroyFunPtr == 0) { - // in this case, we can just use 'free' - UNSAFE.freeMemory(nativeSpacePtr); - } else { - if (i >= BULK_CAPACITY) { - GraalHPyJNIContext.bulkFreeNativeSpace(nativeSpacePtrs, destroyFuncPtrs, BULK_CAPACITY); - i = 0; - } - destroyFuncPtrs[i] = destroyFunPtr; - nativeSpacePtrs[i] = nativeSpacePtr; - i++; - } - } - if (i > 0) { - GraalHPyJNIContext.bulkFreeNativeSpace(nativeSpacePtrs, destroyFuncPtrs, i); - } - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeGetElementPtrNode extends GetElementPtrNode { - static final UnsafeGetElementPtrNode UNCACHED = new UnsafeGetElementPtrNode(); - - private UnsafeGetElementPtrNode() { - } - - @Override - public Object execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return coerceToPointer(pointer) + offset; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadI8ArrayNode extends ReadI8ArrayNode { - - static final UnsafeReadI8ArrayNode UNCACHED = new UnsafeReadI8ArrayNode(); - - private UnsafeReadI8ArrayNode() { - } - - @Override - protected byte[] execute(GraalHPyContext ctx, Object pointer, long offset, long n) { - if (!PInt.isIntRange(n)) { - throw CompilerDirectives.shouldNotReachHere("cannot fit long into int"); - } - byte[] result = new byte[(int) n]; - long ptr = coerceToPointer(pointer) + offset; - UNSAFE.copyMemory(null, ptr, result, Unsafe.ARRAY_BYTE_BASE_OFFSET, n); - return result; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadHPyNode extends ReadHPyNode { - - static final UnsafeReadHPyNode UNCACHED = new UnsafeReadHPyNode(); - - private UnsafeReadHPyNode() { - } - - @Override - protected Object execute(GraalHPyContext ctx, Object pointer, long offset, boolean close) { - assert ctx.getCTypeSize(HPyContextSignatureType.HPy) == UNSAFE.addressSize(); - long bits = UNSAFE.getAddress(coerceToPointer(pointer) + offset); - Object result = ctx.bitsAsPythonObject(bits); - if (close && GraalHPyBoxing.isBoxedHandle(bits)) { - ctx.releaseHPyHandleForObject(GraalHPyBoxing.unboxHandle(bits)); - } - return result; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadHPyFieldNode extends ReadHPyFieldNode { - - static final UnsafeReadHPyFieldNode UNCACHED = new UnsafeReadHPyFieldNode(); - - private UnsafeReadHPyFieldNode() { - } - - @Override - protected Object execute(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, boolean close) { - assert ctx.getCTypeSize(HPyContextSignatureType.HPy) == UNSAFE.addressSize(); - long bits = UNSAFE.getAddress(coerceToPointer(pointer) + offset); - if (!PInt.isIntRange(bits)) { - throw CompilerDirectives.shouldNotReachHere(); - } - int idx = (int) bits; - if (idx == 0) { - return NULL_HANDLE_DELEGATE; - } - return GraalHPyData.getHPyField(owner, idx); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadHPyArrayNode extends ReadHPyArrayNode { - - static final UnsafeReadHPyArrayNode UNCACHED = new UnsafeReadHPyArrayNode(); - - private UnsafeReadHPyArrayNode() { - } - - @Override - protected Object[] execute(GraalHPyContext ctx, Object pointer, long offset, long n) { - if (!PInt.isIntRange(n)) { - throw CompilerDirectives.shouldNotReachHere("cannot fit long into int"); - } - long basePtr = coerceToPointer(pointer); - Object[] result = new Object[(int) n]; - for (int i = 0; i < result.length; i++) { - result[i] = ctx.bitsAsPythonObject(UNSAFE.getAddress(basePtr + (i + offset) * UNSAFE.addressSize())); - } - return result; - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadI32Node extends ReadI32Node { - - static final UnsafeReadI32Node UNCACHED = new UnsafeReadI32Node(); - - private UnsafeReadI32Node() { - } - - @Override - protected int execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return UNSAFE.getInt(coerceToPointer(pointer) + offset); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadI64Node extends ReadI64Node { - - static final UnsafeReadI64Node UNCACHED = new UnsafeReadI64Node(); - - private UnsafeReadI64Node() { - } - - @Override - protected long execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return UNSAFE.getLong(coerceToPointer(pointer) + offset); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadFloatNode extends ReadFloatNode { - - static final UnsafeReadFloatNode UNCACHED = new UnsafeReadFloatNode(); - - private UnsafeReadFloatNode() { - } - - @Override - protected double execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return UNSAFE.getFloat(coerceToPointer(pointer) + offset); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadDoubleNode extends ReadDoubleNode { - - static final UnsafeReadDoubleNode UNCACHED = new UnsafeReadDoubleNode(); - - private UnsafeReadDoubleNode() { - } - - @Override - protected double execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return UNSAFE.getDouble(coerceToPointer(pointer) + offset); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadPointerNode extends ReadPointerNode { - - static final UnsafeReadPointerNode UNCACHED = new UnsafeReadPointerNode(); - - private UnsafeReadPointerNode() { - } - - @Override - protected Object execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset) { - return UNSAFE.getAddress(coerceToPointer(pointer) + offset); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeReadGenericNode extends ReadGenericNode { - - static final UnsafeReadGenericNode UNCACHED = new UnsafeReadGenericNode(); - - private UnsafeReadGenericNode() { - } - - @Override - protected Object execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type) { - long addr = coerceToPointer(pointer) + offset; - switch (type) { - case Int8_t, Uint8_t, Bool: - return UNSAFE.getByte(addr); - case Int16_t, Uint16_t: - return UNSAFE.getShort(addr); - case Int32_t, Uint32_t: - return UNSAFE.getInt(addr); - case Int64_t, Uint64_t: - return UNSAFE.getLong(addr); - case CFloat: - return UNSAFE.getFloat(addr); - case CDouble: - return UNSAFE.getDouble(addr); - case HPyContextPtr, VoidPtr, VoidPtrPtr, HPyPtr, ConstHPyPtr, Wchar_tPtr, ConstWchar_tPtr, CharPtr: - case ConstCharPtr, DataPtr, DataPtrPtr, Cpy_PyObjectPtr, HPyModuleDefPtr, HPyType_SpecPtr: - case HPyType_SpecParamPtr, HPyDefPtr, HPyFieldPtr, HPyGlobalPtr, HPyCapsule_DestructorPtr, PyType_SlotPtr: - return UNSAFE.getAddress(addr); - default: - int size = ctx.getCTypeSize(type); - switch (size) { - case 1: - return UNSAFE.getByte(addr); - case 2: - return UNSAFE.getShort(addr); - case 4: - return UNSAFE.getInt(addr); - case 8: - return UNSAFE.getLong(addr); - } - - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Override - protected int executeInt(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type) { - return (int) executeLong(ctx, pointer, offset, type); - } - - @Override - protected long executeLong(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type) { - long addr = coerceToPointer(pointer) + offset; - int size; - switch (type) { - case Int8_t, Uint8_t, Bool: - size = 1; - break; - case Int16_t, Uint16_t: - size = 2; - break; - case Int32_t, Uint32_t: - size = 4; - break; - case Int64_t, Uint64_t: - size = 8; - break; - default: - size = ctx.getCTypeSize(type); - break; - } - switch (size) { - case 1: - return UNSAFE.getByte(addr); - case 2: - return UNSAFE.getShort(addr); - case 4: - return UNSAFE.getInt(addr); - case 8: - return UNSAFE.getLong(addr); - default: - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteI32Node extends WriteI32Node { - - static final UnsafeWriteI32Node UNCACHED = new UnsafeWriteI32Node(); - - private UnsafeWriteI32Node() { - } - - @Override - protected void execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, int value) { - UNSAFE.putInt(coerceToPointer(pointer) + offset, value); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteI64Node extends WriteI64Node { - - static final UnsafeWriteI64Node UNCACHED = new UnsafeWriteI64Node(); - - private UnsafeWriteI64Node() { - } - - @Override - protected void execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, long value) { - UNSAFE.putLong(coerceToPointer(pointer) + offset, value); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteDoubleNode extends WriteDoubleNode { - - static final UnsafeWriteDoubleNode UNCACHED = new UnsafeWriteDoubleNode(); - - private UnsafeWriteDoubleNode() { - } - - @Override - protected void execute(@SuppressWarnings("unused") GraalHPyContext ctx, Object pointer, long offset, double value) { - UNSAFE.putDouble(coerceToPointer(pointer) + offset, value); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteGenericNode extends WriteGenericNode { - - static final UnsafeWriteGenericNode UNCACHED = new UnsafeWriteGenericNode(); - - private UnsafeWriteGenericNode() { - } - - @Override - protected void execute(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type, long value) { - long addr = coerceToPointer(pointer) + offset; - int size; - switch (type) { - case Int8_t, Uint8_t, Bool: - size = 1; - break; - case Int16_t, Uint16_t: - size = 2; - break; - case Int32_t, Uint32_t: - size = 4; - break; - case Int64_t, Uint64_t: - size = 8; - break; - default: - size = ctx.getCTypeSize(type); - break; - } - switch (size) { - case 1: - UNSAFE.putByte(addr, (byte) value); - break; - case 2: - UNSAFE.putShort(addr, (short) value); - break; - case 4: - UNSAFE.putInt(addr, (int) value); - break; - case 8: - UNSAFE.putLong(addr, value); - break; - default: - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Override - protected void execute(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type, Object value) { - long addr = coerceToPointer(pointer) + offset; - switch (type) { - case Int8_t, Uint8_t, Bool: - UNSAFE.putByte(addr, (byte) value); - break; - case Int16_t, Uint16_t: - UNSAFE.putShort(addr, (short) value); - break; - case Int32_t, Uint32_t: - UNSAFE.putInt(addr, (int) value); - break; - case Int64_t, Uint64_t: - UNSAFE.putLong(addr, (long) value); - break; - case CFloat: - UNSAFE.putFloat(addr, (float) value); - break; - case CDouble: - UNSAFE.putDouble(addr, (double) value); - break; - case HPyContextPtr, VoidPtr, VoidPtrPtr, HPyPtr, ConstHPyPtr, Wchar_tPtr, ConstWchar_tPtr, CharPtr: - case ConstCharPtr, DataPtr, DataPtrPtr, Cpy_PyObjectPtr, HPyModuleDefPtr, HPyType_SpecPtr: - case HPyType_SpecParamPtr, HPyDefPtr, HPyFieldPtr, HPyGlobalPtr, HPyCapsule_DestructorPtr, PyType_SlotPtr: - UNSAFE.putAddress(addr, (long) value); - break; - default: - int size = ctx.getCTypeSize(type); - switch (size) { - case 1: - UNSAFE.putByte(addr, (byte) value); - break; - case 2: - UNSAFE.putShort(addr, (short) value); - break; - case 4: - UNSAFE.putInt(addr, (int) value); - break; - case 8: - UNSAFE.putLong(addr, (long) value); - break; - default: - throw CompilerDirectives.shouldNotReachHere(); - } - } - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteHPyNode extends WriteHPyNode { - - static final UnsafeWriteHPyNode UNCACHED = new UnsafeWriteHPyNode(); - - private UnsafeWriteHPyNode() { - } - - @Override - protected void execute(GraalHPyContext ctx, Object pointer, long offset, Object value) { - long bits = ctx.pythonObjectAsBits(value); - UNSAFE.putAddress(coerceToPointer(pointer) + offset, bits); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteHPyFieldNode extends WriteHPyFieldNode { - - static final UnsafeWriteHPyFieldNode UNCACHED = new UnsafeWriteHPyFieldNode(); - - private UnsafeWriteHPyFieldNode() { - } - - @Override - protected void execute(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, Object value) { - long address = coerceToPointer(pointer) + offset; - long loldValue = UNSAFE.getAddress(address); - if (!PInt.isIntRange(loldValue)) { - throw CompilerDirectives.shouldNotReachHere(); - } - int oldValue = (int) loldValue; - // TODO: (tfel) do not actually allocate the index / free the existing one when - // value can be stored as tagged handle - if (value == NULL_HANDLE_DELEGATE && oldValue == 0) { - // assigning HPy_NULL to a field that already holds HPy_NULL, nothing to do - } else { - int newValue = GraalHPyData.setHPyField(owner, value, oldValue); - if (oldValue != newValue) { - UNSAFE.putAddress(address, newValue); - } - } - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWritePointerNode extends WritePointerNode { - - static final UnsafeWritePointerNode UNCACHED = new UnsafeWritePointerNode(); - - private UnsafeWritePointerNode() { - } - - @Override - protected void execute(GraalHPyContext ctx, Object basePointer, long offset, Object valuePointer) { - UNSAFE.putAddress(coerceToPointer(basePointer) + offset, coerceToPointer(valuePointer)); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - static final class UnsafeWriteSizeTNode extends WriteSizeTNode { - - static final UnsafeWriteSizeTNode UNCACHED = new UnsafeWriteSizeTNode(); - - private UnsafeWriteSizeTNode() { - } - - @Override - protected void execute(GraalHPyContext ctx, Object basePointer, long offset, long valuePointer) { - write(coerceToPointer(basePointer) + offset, valuePointer); - } - - static void write(long address, long value) { - UNSAFE.putAddress(address, value); - } - - @Override - public boolean isAdoptable() { - return false; - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyJNIFromCharPointerNode extends HPyFromCharPointerNode { - - @Specialization - static TruffleString doLong(@SuppressWarnings("unused") GraalHPyContext hpyContext, long charPtr, int n, Encoding encoding, boolean copy, - @Bind("this") Node inliningTarget, - @Exclusive @Cached InlinedConditionProfile lengthProfile, - @Exclusive @Cached TruffleString.FromNativePointerNode fromNativePointerNode, - @Exclusive @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - int length = lengthProfile.profile(inliningTarget, n < 0) ? strlen(charPtr) : n; - return read(new NativePointer(charPtr), length, encoding, copy, fromNativePointerNode, switchEncodingNode); - } - - @Specialization - static TruffleString doNativePointer(@SuppressWarnings("unused") GraalHPyContext hpyContext, NativePointer charPtr, int n, Encoding encoding, boolean copy, - @Bind("this") Node inliningTarget, - @Exclusive @Cached InlinedConditionProfile lengthProfile, - @Exclusive @Cached TruffleString.FromNativePointerNode fromNativePointerNode, - @Exclusive @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - int length = lengthProfile.profile(inliningTarget, n < 0) ? strlen(charPtr.asPointer()) : n; - return read(charPtr, length, encoding, copy, fromNativePointerNode, switchEncodingNode); - } - - @Specialization(replaces = {"doLong", "doNativePointer"}) - static TruffleString doGeneric(@SuppressWarnings("unused") GraalHPyContext hpyContext, Object charPtr, int n, Encoding encoding, boolean copy, - @Bind("this") Node inliningTarget, - @Exclusive @CachedLibrary(limit = "1") InteropLibrary lib, - @Exclusive @Cached InlinedConditionProfile lengthProfile, - @Exclusive @Cached TruffleString.FromNativePointerNode fromNativePointerNode, - @Exclusive @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - - long lcharPtr; - Object interopPtr; - if (charPtr instanceof Long ltmp) { - interopPtr = new NativePointer(ltmp); - lcharPtr = ltmp; - } else if (charPtr instanceof NativePointer nativeCharPtr) { - interopPtr = nativeCharPtr; - lcharPtr = nativeCharPtr.asPointer(); - } else { - try { - interopPtr = charPtr; - lcharPtr = lib.asPointer(charPtr); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - int length = lengthProfile.profile(inliningTarget, n < 0) ? strlen(lcharPtr) : n; - return read(interopPtr, length, encoding, copy, fromNativePointerNode, switchEncodingNode); - } - - private static TruffleString read(Object charPtr, int length, Encoding encoding, boolean copy, - TruffleString.FromNativePointerNode fromNativePointerNode, - TruffleString.SwitchEncodingNode switchEncodingNode) { - assert length >= 0; - TruffleString result = fromNativePointerNode.execute(charPtr, 0, length, encoding, copy); - if (TS_ENCODING != encoding) { - return switchEncodingNode.execute(result, TS_ENCODING); - } - return result; - } - - static int strlen(long charPtr) { - int length = 0; - while (UNSAFE.getByte(charPtr + length) != 0) { - length++; - } - return length; - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyJNIAsCharPointerNode extends HPyAsCharPointerNode { - - abstract long executeLong(GraalHPyContext hpyContext, TruffleString string, Encoding encoding); - - @Specialization - static long doGeneric(@SuppressWarnings("unused") GraalHPyContext hpyContext, TruffleString string, Encoding encoding, - @Bind("this") Node inliningTarget, - @Cached InlinedExactClassProfile classProfile, - @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Cached TruffleString.AsNativeNode asNativeNode, - @Cached TruffleString.GetInternalNativePointerNode getInternalNativePointerNode) { - TruffleString tsEncoded = switchEncodingNode.execute(string, encoding); - TruffleString tsNative = asNativeNode.execute(tsEncoded, GraalHPyJNIContext.TS_NATIVE_ALLOCATOR, encoding, false, true); - Object profiledInteropPointer = classProfile.profile(inliningTarget, getInternalNativePointerNode.execute(tsNative, encoding)); - if (profiledInteropPointer instanceof NativePointer nativePointer) { - return nativePointer.asPointer(); - } - return interopPointerToNative(profiledInteropPointer); - } - - @TruffleBoundary - private static long interopPointerToNative(Object object) { - return GraalHPyJNIContext.interopPointerToNative(object, InteropLibrary.getUncached(object)); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNITrampolines.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNITrampolines.java deleted file mode 100644 index a15956b467..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/jni/GraalHPyJNITrampolines.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy.jni; - -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; - -abstract class GraalHPyJNITrampolines { - - /* manual HPY JNI trampoline declarations */ - - @TruffleBoundary - public static native long executeModuleInit(long target); - - @TruffleBoundary - public static native void executeDestroyfunc(long target, long dataptr); - - // int (*HPyFunc_traverseproc)(void *, HPyFunc_visitproc, void *); - public static long executeTraverseproc(long target, long self, long visitproc, long field) { - throw CompilerDirectives.shouldNotReachHere("traverseproc should never be called"); - } - - /* generated HPY JNI trampoline declarations */ - - // {{start autogen}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_jni - // typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self) - @TruffleBoundary - public static native long executeNoargs(long target, long ctx, long self); - - // typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg) - @TruffleBoundary - public static native long executeO(long target, long ctx, long self, long arg); - - // typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - @TruffleBoundary - public static native long executeVarargs(long target, long ctx, long self, long args, long nargs); - - // typedef HPy (*HPyFunc_keywords)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames) - @TruffleBoundary - public static native long executeKeywords(long target, long ctx, long self, long args, long nargs, long kwnames); - - // typedef HPy (*HPyFunc_unaryfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeUnaryfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_binaryfunc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native long executeBinaryfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_ternaryfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native long executeTernaryfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_inquiry)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native int executeInquiry(long target, long ctx, long arg0); - - // typedef HPy_ssize_t (*HPyFunc_lenfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeLenfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_ssizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t) - @TruffleBoundary - public static native long executeSsizeargfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_ssizessizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t) - @TruffleBoundary - public static native long executeSsizessizeargfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_ssizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy) - @TruffleBoundary - public static native int executeSsizeobjargproc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_ssizessizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t, HPy) - @TruffleBoundary - public static native int executeSsizessizeobjargproc(long target, long ctx, long arg0, long arg1, long arg2, long arg3); - - // typedef int (*HPyFunc_objobjargproc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeObjobjargproc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef void (*HPyFunc_freefunc)(HPyContext *ctx, void *) - @TruffleBoundary - public static native void executeFreefunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_getattrfunc)(HPyContext *ctx, HPy, char *) - @TruffleBoundary - public static native long executeGetattrfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_getattrofunc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native long executeGetattrofunc(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_setattrfunc)(HPyContext *ctx, HPy, char *, HPy) - @TruffleBoundary - public static native int executeSetattrfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_setattrofunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeSetattrofunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef HPy (*HPyFunc_reprfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeReprfunc(long target, long ctx, long arg0); - - // typedef HPy_hash_t (*HPyFunc_hashfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeHashfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_richcmpfunc)(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp) - @TruffleBoundary - public static native long executeRichcmpfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef HPy (*HPyFunc_getiterfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeGetiterfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_iternextfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeIternextfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_descrgetfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native long executeDescrgetfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_descrsetfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeDescrsetfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_initproc)(HPyContext *ctx, HPy self, const HPy *args, HPy_ssize_t nargs, HPy kw) - @TruffleBoundary - public static native int executeInitproc(long target, long ctx, long self, long args, long nargs, long kw); - - // typedef HPy (*HPyFunc_newfunc)(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) - @TruffleBoundary - public static native long executeNewfunc(long target, long ctx, long type, long args, long nargs, long kw); - - // typedef HPy (*HPyFunc_getter)(HPyContext *ctx, HPy, void *) - @TruffleBoundary - public static native long executeGetter(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_setter)(HPyContext *ctx, HPy, HPy, void *) - @TruffleBoundary - public static native int executeSetter(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_objobjproc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native int executeObjobjproc(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_getbufferproc)(HPyContext *ctx, HPy, HPy_buffer *, int) - @TruffleBoundary - public static native int executeGetbufferproc(long target, long ctx, long arg0, long arg1, int arg2); - - // typedef void (*HPyFunc_releasebufferproc)(HPyContext *ctx, HPy, HPy_buffer *) - @TruffleBoundary - public static native void executeReleasebufferproc(long target, long ctx, long arg0, long arg1); - - // typedef void (*HPyFunc_destructor)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native void executeDestructor(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_mod_create)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeModcreate(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_noargs)(HPyContext *ctx, HPy self) - @TruffleBoundary - public static native long executeDebugNoargs(long target, long ctx, long self); - - // typedef HPy (*HPyFunc_o)(HPyContext *ctx, HPy self, HPy arg) - @TruffleBoundary - public static native long executeDebugO(long target, long ctx, long self, long arg); - - // typedef HPy (*HPyFunc_varargs)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs) - @TruffleBoundary - public static native long executeDebugVarargs(long target, long ctx, long self, long args, long nargs); - - // typedef HPy (*HPyFunc_keywords)(HPyContext *ctx, HPy self, const HPy *args, size_t nargs, HPy kwnames) - @TruffleBoundary - public static native long executeDebugKeywords(long target, long ctx, long self, long args, long nargs, long kwnames); - - // typedef HPy (*HPyFunc_unaryfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugUnaryfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_binaryfunc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native long executeDebugBinaryfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_ternaryfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native long executeDebugTernaryfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_inquiry)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native int executeDebugInquiry(long target, long ctx, long arg0); - - // typedef HPy_ssize_t (*HPyFunc_lenfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugLenfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_ssizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t) - @TruffleBoundary - public static native long executeDebugSsizeargfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_ssizessizeargfunc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t) - @TruffleBoundary - public static native long executeDebugSsizessizeargfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_ssizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy) - @TruffleBoundary - public static native int executeDebugSsizeobjargproc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_ssizessizeobjargproc)(HPyContext *ctx, HPy, HPy_ssize_t, HPy_ssize_t, HPy) - @TruffleBoundary - public static native int executeDebugSsizessizeobjargproc(long target, long ctx, long arg0, long arg1, long arg2, long arg3); - - // typedef int (*HPyFunc_objobjargproc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeDebugObjobjargproc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef void (*HPyFunc_freefunc)(HPyContext *ctx, void *) - @TruffleBoundary - public static native void executeDebugFreefunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_getattrfunc)(HPyContext *ctx, HPy, char *) - @TruffleBoundary - public static native long executeDebugGetattrfunc(long target, long ctx, long arg0, long arg1); - - // typedef HPy (*HPyFunc_getattrofunc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native long executeDebugGetattrofunc(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_setattrfunc)(HPyContext *ctx, HPy, char *, HPy) - @TruffleBoundary - public static native int executeDebugSetattrfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_setattrofunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeDebugSetattrofunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef HPy (*HPyFunc_reprfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugReprfunc(long target, long ctx, long arg0); - - // typedef HPy_hash_t (*HPyFunc_hashfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugHashfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_richcmpfunc)(HPyContext *ctx, HPy, HPy, HPy_RichCmpOp) - @TruffleBoundary - public static native long executeDebugRichcmpfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef HPy (*HPyFunc_getiterfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugGetiterfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_iternextfunc)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugIternextfunc(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_descrgetfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native long executeDebugDescrgetfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_descrsetfunc)(HPyContext *ctx, HPy, HPy, HPy) - @TruffleBoundary - public static native int executeDebugDescrsetfunc(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_initproc)(HPyContext *ctx, HPy self, const HPy *args, HPy_ssize_t nargs, HPy kw) - @TruffleBoundary - public static native int executeDebugInitproc(long target, long ctx, long self, long args, long nargs, long kw); - - // typedef HPy (*HPyFunc_newfunc)(HPyContext *ctx, HPy type, const HPy *args, HPy_ssize_t nargs, HPy kw) - @TruffleBoundary - public static native long executeDebugNewfunc(long target, long ctx, long type, long args, long nargs, long kw); - - // typedef HPy (*HPyFunc_getter)(HPyContext *ctx, HPy, void *) - @TruffleBoundary - public static native long executeDebugGetter(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_setter)(HPyContext *ctx, HPy, HPy, void *) - @TruffleBoundary - public static native int executeDebugSetter(long target, long ctx, long arg0, long arg1, long arg2); - - // typedef int (*HPyFunc_objobjproc)(HPyContext *ctx, HPy, HPy) - @TruffleBoundary - public static native int executeDebugObjobjproc(long target, long ctx, long arg0, long arg1); - - // typedef int (*HPyFunc_getbufferproc)(HPyContext *ctx, HPy, HPy_buffer *, int) - @TruffleBoundary - public static native int executeDebugGetbufferproc(long target, long ctx, long arg0, long arg1, int arg2); - - // typedef void (*HPyFunc_releasebufferproc)(HPyContext *ctx, HPy, HPy_buffer *) - @TruffleBoundary - public static native void executeDebugReleasebufferproc(long target, long ctx, long arg0, long arg1); - - // typedef void (*HPyFunc_destructor)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native void executeDebugDestructor(long target, long ctx, long arg0); - - // typedef HPy (*HPyFunc_mod_create)(HPyContext *ctx, HPy) - @TruffleBoundary - public static native long executeDebugModcreate(long target, long ctx, long arg0); - - // @formatter:on - // Checkstyle: resume - // {{end autogen}} -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyInitObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyInitObject.java deleted file mode 100644 index 2278ff6ce0..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyInitObject.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019, 2023, 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.builtins.objects.cext.hpy.llvm; - -import com.oracle.graal.python.builtins.objects.PythonAbstractObject; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; - -/** - * A simple interop-capable object that is used to initialize the HPy LLVM backend. - */ -@ExportLibrary(InteropLibrary.class) -public final class GraalHPyInitObject implements TruffleObject { - - private static final String J_SET_HPY_CONTEXT_NATIVE_TYPE = "setHPyContextNativeType"; - private static final String J_SET_HPY_NATIVE_TYPE = "setHPyNativeType"; - private static final String J_SET_HPY_ARRAY_NATIVE_TYPE = "setHPyArrayNativeType"; - private static final String J_SET_NATIVE_CACHE_FUNCTION_PTR = "setNativeCacheFunctionPtr"; - - private final GraalHPyLLVMContext backend; - - public GraalHPyInitObject(GraalHPyLLVMContext backend) { - this.backend = backend; - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasMembers() { - return true; - } - - @ExportMessage - @TruffleBoundary - @SuppressWarnings("static-method") - Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { - return new PythonAbstractObject.Keys( - new String[]{J_SET_HPY_CONTEXT_NATIVE_TYPE, J_SET_HPY_NATIVE_TYPE, J_SET_HPY_ARRAY_NATIVE_TYPE, J_SET_NATIVE_CACHE_FUNCTION_PTR}); - } - - @ExportMessage - @TruffleBoundary - @SuppressWarnings("static-method") - boolean isMemberInvocable(String key) { - return switch (key) { - case J_SET_HPY_CONTEXT_NATIVE_TYPE, J_SET_HPY_NATIVE_TYPE, J_SET_HPY_ARRAY_NATIVE_TYPE, J_SET_NATIVE_CACHE_FUNCTION_PTR -> true; - default -> false; - }; - } - - @ExportMessage - @TruffleBoundary - Object invokeMember(String key, Object[] arguments) throws UnsupportedMessageException, ArityException { - if (arguments.length != 1) { - throw ArityException.create(1, 1, arguments.length); - } - - switch (key) { - case J_SET_HPY_CONTEXT_NATIVE_TYPE -> backend.hpyContextNativeTypeID = arguments[0]; - case J_SET_HPY_NATIVE_TYPE -> backend.hpyNativeTypeID = arguments[0]; - case J_SET_HPY_ARRAY_NATIVE_TYPE -> backend.hpyArrayNativeTypeID = arguments[0]; - case J_SET_NATIVE_CACHE_FUNCTION_PTR -> backend.setNativeSpaceFunction = arguments[0]; - default -> throw UnsupportedMessageException.create(); - } - return 0; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMCallHelperFunctionNode.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMCallHelperFunctionNode.java deleted file mode 100644 index 0122356b89..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMCallHelperFunctionNode.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2023, 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.builtins.objects.cext.hpy.llvm; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodes.HPyLLVMCallHelperFunctionNode; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; - -/** - * This is the implementation of {@link HPyCallHelperFunctionNode} for the LLVM backend. This node - * currently just delegates to {@link HPyLLVMCallHelperFunctionNode} but this may change in the - * future. - */ -@GenerateUncached -@GenerateInline(false) -abstract class GraalHPyLLVMCallHelperFunctionNode extends HPyCallHelperFunctionNode { - - @Specialization - static Object doGeneric(GraalHPyContext context, GraalHPyNativeSymbol name, Object[] args, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHPyFunction) { - return callHPyFunction.execute(inliningTarget, context, name, args); - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMContext.java deleted file mode 100644 index 616bfdb93c..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMContext.java +++ /dev/null @@ -1,1357 +0,0 @@ -/* - * Copyright (c) 2019, 2025, 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.builtins.objects.cext.hpy.llvm; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_ELIPSIS; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_NONE; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.SINGLETON_HANDLE_NOT_IMPLEMENTED; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_CONTEXT_TO_NATIVE; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; -import static com.oracle.graal.python.util.PythonUtils.tsLiteral; - -import java.io.IOException; -import java.util.HashMap; - -import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.PNotImplemented; -import com.oracle.graal.python.builtins.objects.PythonAbstractObject; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CExtAsPythonObjectNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtContext; -import com.oracle.graal.python.builtins.objects.cext.common.CExtToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; -import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ImportException; -import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyBoxing; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.BulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.FreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.GetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.IsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCField; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyABIVersion; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.HPyUpcall; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContextFunctions.GraalHPyContextFunction; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyDummyToJavaNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyTransformExceptionToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsContextNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsHandleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsNativeInt64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyAsPythonObjectNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodesFactory.HPyTransformExceptionToNativeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextMember; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyMode; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodes.HPyLLVMCallHelperFunctionNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMAsCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMBulkFreeHandleReferencesNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMFreeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMFromCharPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMGetElementPtrNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMIsNullNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadDoubleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadFloatNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadGenericNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadHPyArrayNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadHPyFieldNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadHPyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadI32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadI64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMReadPointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteDoubleNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteGenericNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteHPyFieldNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteHPyNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteI32NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteI64NodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWritePointerNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMWriteSizeTNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.LLVMAllocateNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.LLVMReadI8ArrayNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.HPyArrayWrappers.HPyArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.HPyArrayWrappers.IntArrayWrapper; -import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis; -import com.oracle.graal.python.builtins.objects.module.PythonModule; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.StringLiterals; -import com.oracle.graal.python.nodes.object.GetOrCreateDictNode; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonOptions; -import com.oracle.graal.python.runtime.PythonOptions.HPyBackendMode; -import com.oracle.graal.python.runtime.exception.PException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.TruffleFile; -import com.oracle.truffle.api.TruffleLanguage.Env; -import com.oracle.truffle.api.TruffleLogger; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.ReportPolymorphism.Megamorphic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnknownIdentifierException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.source.Source; -import com.oracle.truffle.api.source.Source.SourceBuilder; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.llvm.spi.NativeTypeLibrary; - -/** - * This object is used to override specific native upcall pointers in the HPyContext. This is - * queried for every member of HPyContext by {@code graal_hpy_context_to_native}, and overrides the - * original values (which are NFI closures for functions in {@code hpy.c}, subsequently calling into - * {@link GraalHPyContextFunctions}. - */ -@ExportLibrary(InteropLibrary.class) -@ExportLibrary(value = NativeTypeLibrary.class, useForAOT = false) -public final class GraalHPyLLVMContext extends GraalHPyNativeContext { - - private static final String J_NAME = "HPy Universal ABI (GraalVM LLVM backend)"; - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(GraalHPyLLVMContext.class); - - /** A resolving cache from Java string to HPyContextMember */ - public static HashMap contextMembersByName; - - private final int[] counts; - - /** the native type ID of C struct 'HPyContext' */ - @CompilationFinal Object hpyContextNativeTypeID; - - /** the native type ID of C struct 'HPy' */ - @CompilationFinal Object hpyNativeTypeID; - @CompilationFinal Object hpyArrayNativeTypeID; - @CompilationFinal Object setNativeSpaceFunction; - - @CompilationFinal(dimensions = 1) private final int[] ctypeSizes; - @CompilationFinal(dimensions = 1) private final int[] cfieldOffsets; - - @CompilationFinal(dimensions = 1) private final Object[] hpyContextMembers; - @CompilationFinal(dimensions = 1) private final Object[] nativeSymbolCache; - - Object nativePointer; - - public GraalHPyLLVMContext(GraalHPyContext context, boolean traceUpcalls) { - super(context, traceUpcalls); - Object[] ctxMembers = createMembers(tsLiteral(J_NAME)); - this.ctypeSizes = new int[HPyContextSignatureType.values().length]; - this.cfieldOffsets = new int[GraalHPyCField.values().length]; - if (traceUpcalls) { - this.counts = new int[HPyContextMember.VALUES.length]; - /* - * For upcall tracing, each executable member is wrapped into an HPyExecuteWrapper which - * does the tracing - */ - for (int i = 0; i < ctxMembers.length; i++) { - Object m = ctxMembers[i]; - if (m instanceof HPyExecuteWrapper executeWrapper) { - ctxMembers[i] = new HPyExecuteWrapperTraceUpcall(this.counts, i, executeWrapper); - } - } - } else { - this.counts = null; - } - // This will assign handles to the remaining context constants - for (Object member : ctxMembers) { - if (member instanceof GraalHPyHandle handle) { - int id = handle.getIdUncached(context); - assert id > 0 && id < GraalHPyContext.IMMUTABLE_HANDLE_COUNT; - assert id > GraalHPyBoxing.SINGLETON_HANDLE_MAX || - context.getHPyHandleForObject(handle.getDelegate()) == id; - } - } - this.hpyContextMembers = ctxMembers; - this.nativeSymbolCache = new Object[GraalHPyNativeSymbol.values().length]; - } - - void setHPyContextNativeType(Object nativeType) { - this.hpyContextNativeTypeID = nativeType; - } - - public Object getHPyNativeType() { - assert this.hpyNativeTypeID != null : "HPy native type ID not available"; - return hpyNativeTypeID; - } - - public Object getHPyArrayNativeType() { - assert this.hpyArrayNativeTypeID != null : "HPy* native type ID not available"; - return hpyArrayNativeTypeID; - } - - @Override - protected int getCTypeSize(HPyContextSignatureType ctype) { - assert ctypeSizes != null; - return ctypeSizes[ctype.ordinal()]; - } - - @Override - protected int getCFieldOffset(GraalHPyCField cfield) { - assert cfieldOffsets != null; - return cfieldOffsets[cfield.ordinal()]; - } - - @Override - protected Object nativeToInteropPointer(Object object) { - return object; - } - - Object[] getNativeSymbolCache() { - return nativeSymbolCache; - } - - @Override - protected Object getNativeNull() { - return NativePointer.createNull(); - } - - @Override - protected String getName() { - return J_NAME; - } - - /** - * Load {@code libhpy} with LLVM and return the library object. - */ - public static Object loadLLVMLibrary(PythonContext context) throws IOException { - CompilerAsserts.neverPartOfCompilation(); - Env env = context.getEnv(); - TruffleFile homePath = env.getInternalTruffleFile(context.getCAPIHome().toJavaStringUncached()); - // e.g. "libhpy-native.so" - TruffleFile capiFile = homePath.resolve(context.getLLVMSupportExt("hpy")); - try { - LOGGER.fine("Loading HPy LLVM backend from " + capiFile); - SourceBuilder capiSrcBuilder = Source.newBuilder(J_LLVM_LANGUAGE, capiFile); - if (!context.getLanguage().getEngineOption(PythonOptions.ExposeInternalSources)) { - capiSrcBuilder.internal(true); - } - return context.getEnv().parseInternal(capiSrcBuilder.build()).call(); - } catch (RuntimeException e) { - LOGGER.severe(String.format("Fatal error occurred when loading %s", capiFile)); - /* - * Just loading the library is not expected to throw any legitimate exceptions because - * it does not have any 'ctors' that could raise, e.g., a Python exception. So, any - * exception is considered to be fatal. - */ - throw CompilerDirectives.shouldNotReachHere(e); - } - } - - @Override - protected Object loadExtensionLibrary(Node location, PythonContext context, TruffleString name, TruffleString path) throws ImportException, IOException { - CompilerAsserts.neverPartOfCompilation(); - return CExtContext.loadLLVMLibrary(location, context, name, path); - } - - @Override - protected HPyABIVersion getHPyABIVersion(Object extLib, String getMajorVersionFuncName, String getMinorVersionFuncName) throws InteropException { - CompilerAsserts.neverPartOfCompilation(); - InteropLibrary lib = InteropLibrary.getUncached(extLib); - Object majorVersionFun = lib.readMember(extLib, getMajorVersionFuncName); - Object minorVersionFun = lib.readMember(extLib, getMinorVersionFuncName); - InteropLibrary funLib = InteropLibrary.getUncached(majorVersionFun); - assert (funLib.accepts(minorVersionFun)); - int requiredMajorVersion = expectInt(funLib.execute(majorVersionFun)); - int requiredMinorVersion = expectInt(funLib.execute(minorVersionFun)); - return new HPyABIVersion(requiredMajorVersion, requiredMinorVersion); - } - - @Override - protected Object initHPyModule(Object llvmLibrary, String initFuncName, TruffleString name, TruffleString path, HPyMode mode) - throws UnsupportedMessageException, ArityException, UnsupportedTypeException, ImportException { - CompilerAsserts.neverPartOfCompilation(); - assert mode == HPyMode.MODE_UNIVERSAL; - Object initFunction; - InteropLibrary lib = InteropLibrary.getUncached(llvmLibrary); - if (lib.isMemberReadable(llvmLibrary, initFuncName)) { - try { - initFunction = lib.readMember(llvmLibrary, initFuncName); - } catch (UnknownIdentifierException | UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } else { - throw new ImportException(null, name, path, ErrorMessages.CANNOT_INITIALIZE_EXT_NO_ENTRY, name, path, initFuncName); - } - /* - * LLVM always answers message 'isExecutable' correctly. If the pointer object is not - * executable, this most certainly means that the loaded library does not contain bitcode, - * and so we fail. - */ - if (!InteropLibrary.getUncached().isExecutable(initFunction)) { - throw new ImportException(null, name, path, ErrorMessages.NO_FUNCTION_FOUND, "", initFuncName, path); - } - return InteropLibrary.getUncached().execute(initFunction, this); - } - - @Override - protected void initNativeContext() throws ApiInitException { - Object hpyLibrary = context.getLLVMLibrary(); - InteropLibrary interopLibrary = InteropLibrary.getFactory().getUncached(hpyLibrary); - try { - interopLibrary.invokeMember(hpyLibrary, "graal_hpy_init", context, new GraalHPyInitObject(this), new IntArrayWrapper(ctypeSizes), new IntArrayWrapper(cfieldOffsets)); - } catch (InteropException e) { - throw new ApiInitException(e); - } - assert nativeSymbolCache != null; - for (GraalHPyNativeSymbol symbol : GraalHPyNativeSymbol.values()) { - try { - String name = symbol.getName(); - Object nativeSymbol = interopLibrary.readMember(hpyLibrary, name); - assert nativeSymbolCache[symbol.ordinal()] == null; - nativeSymbolCache[symbol.ordinal()] = nativeSymbol; - } catch (UnknownIdentifierException e) { - throw new ApiInitException(ErrorMessages.INVALID_CAPI_FUNC, TruffleString.fromJavaStringUncached(symbol.getName(), TS_ENCODING)); - } catch (UnsupportedMessageException e) { - throw new ApiInitException(ErrorMessages.CORRUPTED_CAPI_LIB_OBJ, hpyLibrary); - } - } - } - - @Override - protected void initNativeFastPaths() { - throw CompilerDirectives.shouldNotReachHere(""); - } - - @Override - protected HPyUpcall[] getUpcalls() { - return HPyContextMember.VALUES; - } - - @Override - protected int[] getUpcallCounts() { - return counts; - } - - @Override - protected void finalizeNativeContext() { - - } - - @Override - public void initHPyDebugContext() throws ApiInitException { - // debug mode is currently not available with the LLVM backend - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, StringLiterals.J_DEBUG); - } - - @Override - public PythonModule getHPyDebugModule() throws ImportException { - // debug mode is currently not available with the LLVM backend - throw new ImportException(null, null, null, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, StringLiterals.J_DEBUG); - } - - @Override - public void initHPyTraceContext() throws ApiInitException { - // debug mode is currently not available with the LLVM backend - throw new ApiInitException(ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, StringLiterals.J_TRACE); - } - - @Override - public PythonModule getHPyTraceModule() throws ImportException { - // trace mode is currently not available with the LLVM backend - throw new ImportException(null, null, null, ErrorMessages.HPY_S_MODE_NOT_AVAILABLE, StringLiterals.J_TRACE); - } - - @Override - protected void setNativeCache(long cachePtr) { - assert useNativeFastPaths(); - try { - InteropLibrary.getUncached().execute(setNativeSpaceFunction, nativePointer, cachePtr); - } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @Override - public HPyCallHelperFunctionNode createCallHelperFunctionNode() { - return GraalHPyLLVMCallHelperFunctionNodeGen.create(); - } - - @Override - public HPyCallHelperFunctionNode getUncachedCallHelperFunctionNode() { - return GraalHPyLLVMCallHelperFunctionNodeGen.getUncached(); - } - - @Override - public HPyFromCharPointerNode createFromCharPointerNode() { - return HPyLLVMFromCharPointerNodeGen.create(); - } - - @Override - public HPyFromCharPointerNode getUncachedFromCharPointerNode() { - return HPyLLVMFromCharPointerNodeGen.getUncached(); - } - - @Override - public HPyAsCharPointerNode createAsCharPointerNode() { - return HPyLLVMAsCharPointerNodeGen.create(); - } - - @Override - public HPyAsCharPointerNode getUncachedAsCharPointerNode() { - return HPyLLVMAsCharPointerNodeGen.getUncached(); - } - - @Override - public AllocateNode createAllocateNode() { - return LLVMAllocateNodeGen.create(); - } - - @Override - public AllocateNode getUncachedAllocateNode() { - return LLVMAllocateNodeGen.getUncached(); - } - - @Override - public FreeNode createFreeNode() { - return HPyLLVMFreeNodeGen.create(); - } - - @Override - public FreeNode getUncachedFreeNode() { - return HPyLLVMFreeNodeGen.getUncached(); - } - - @Override - public BulkFreeHandleReferencesNode createBulkFreeHandleReferencesNode() { - return HPyLLVMBulkFreeHandleReferencesNodeGen.create(); - } - - @Override - public GetElementPtrNode createGetElementPtrNode() { - return HPyLLVMGetElementPtrNodeGen.create(); - } - - @Override - public GetElementPtrNode getUncachedGetElementPtrNode() { - return HPyLLVMGetElementPtrNodeGen.getUncached(); - } - - @Override - public IsNullNode createIsNullNode() { - return HPyLLVMIsNullNodeGen.create(); - } - - @Override - public IsNullNode getUncachedIsNullNode() { - return HPyLLVMIsNullNodeGen.getUncached(); - } - - @Override - public ReadI32Node createReadI32Node() { - return HPyLLVMReadI32NodeGen.create(); - } - - @Override - public ReadI32Node getUncachedReadI32Node() { - return HPyLLVMReadI32NodeGen.getUncached(); - } - - @Override - public ReadI64Node createReadI64Node() { - return HPyLLVMReadI64NodeGen.create(); - } - - @Override - public ReadI64Node getUncachedReadI64Node() { - return HPyLLVMReadI64NodeGen.getUncached(); - } - - @Override - public ReadFloatNode createReadFloatNode() { - return HPyLLVMReadFloatNodeGen.create(); - } - - @Override - public ReadFloatNode getUncachedReadFloatNode() { - return HPyLLVMReadFloatNodeGen.getUncached(); - } - - @Override - public ReadDoubleNode createReadDoubleNode() { - return HPyLLVMReadDoubleNodeGen.create(); - } - - @Override - public ReadDoubleNode getUncachedReadDoubleNode() { - return HPyLLVMReadDoubleNodeGen.getUncached(); - } - - @Override - public ReadPointerNode createReadPointerNode() { - return HPyLLVMReadPointerNodeGen.create(); - } - - @Override - public ReadPointerNode getUncachedReadPointerNode() { - return HPyLLVMReadPointerNodeGen.getUncached(); - } - - @Override - public WriteDoubleNode createWriteDoubleNode() { - return HPyLLVMWriteDoubleNodeGen.create(); - } - - @Override - public WriteDoubleNode getUncachedWriteDoubleNode() { - return HPyLLVMWriteDoubleNodeGen.getUncached(); - } - - @Override - public WriteI32Node createWriteI32Node() { - return HPyLLVMWriteI32NodeGen.create(); - } - - @Override - public WriteI32Node getUncachedWriteI32Node() { - return HPyLLVMWriteI32NodeGen.getUncached(); - } - - @Override - public WriteI64Node createWriteI64Node() { - return HPyLLVMWriteI64NodeGen.create(); - } - - @Override - public WriteI64Node getUncachedWriteI64Node() { - return HPyLLVMWriteI64NodeGen.getUncached(); - } - - @Override - public WriteHPyNode createWriteHPyNode() { - return HPyLLVMWriteHPyNodeGen.create(); - } - - @Override - public WriteHPyNode getUncachedWriteHPyNode() { - return HPyLLVMWriteHPyNodeGen.getUncached(); - } - - @Override - public ReadI8ArrayNode createReadI8ArrayNode() { - return LLVMReadI8ArrayNodeGen.create(); - } - - @Override - public ReadI8ArrayNode getUncachedReadI8ArrayNode() { - return LLVMReadI8ArrayNodeGen.getUncached(); - } - - @Override - public ReadHPyNode createReadHPyNode() { - return HPyLLVMReadHPyNodeGen.create(); - } - - @Override - public ReadHPyNode getUncachedReadHPyNode() { - return HPyLLVMReadHPyNodeGen.getUncached(); - } - - @Override - public ReadHPyFieldNode createReadHPyFieldNode() { - return HPyLLVMReadHPyFieldNodeGen.create(); - } - - @Override - public ReadHPyFieldNode getUncachedReadFieldHPyNode() { - return HPyLLVMReadHPyFieldNodeGen.getUncached(); - } - - @Override - public ReadGenericNode createReadGenericNode() { - return HPyLLVMReadGenericNodeGen.create(); - } - - @Override - public ReadGenericNode getUncachedReadGenericNode() { - return HPyLLVMReadGenericNodeGen.getUncached(); - } - - @Override - public ReadHPyArrayNode createReadHPyArrayNode() { - return HPyLLVMReadHPyArrayNodeGen.create(); - } - - @Override - public ReadHPyArrayNode getUncachedReadHPyArrayNode() { - return HPyLLVMReadHPyArrayNodeGen.getUncached(); - } - - @Override - public WritePointerNode createWritePointerNode() { - return HPyLLVMWritePointerNodeGen.create(); - } - - @Override - public WritePointerNode getUncachedWritePointerNode() { - return HPyLLVMWritePointerNodeGen.getUncached(); - } - - @Override - public WriteSizeTNode createWriteSizeTNode() { - return HPyLLVMWriteSizeTNodeGen.create(); - } - - @Override - public WriteSizeTNode getUncachedWriteSizeTNode() { - return HPyLLVMWriteSizeTNodeGen.getUncached(); - } - - @Override - public WriteGenericNode createWriteGenericNode() { - return HPyLLVMWriteGenericNodeGen.create(); - } - - @Override - public WriteGenericNode getUncachedWriteGenericNode() { - return HPyLLVMWriteGenericNodeGen.getUncached(); - } - - @Override - public WriteHPyFieldNode createWriteHPyFieldNode() { - return HPyLLVMWriteHPyFieldNodeGen.create(); - } - - @Override - public WriteHPyFieldNode getUncachedWriteHPyFieldNode() { - return HPyLLVMWriteHPyFieldNodeGen.getUncached(); - } - - @ExportMessage - boolean isPointer() { - return nativePointer != null; - } - - @ExportMessage(limit = "1") - long asPointer(@CachedLibrary("this.nativePointer") InteropLibrary lib) throws UnsupportedMessageException { - if (isPointer()) { - return lib.asPointer(nativePointer); - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw UnsupportedMessageException.create(); - } - - /** - * Internal method for transforming the HPy universal context to native. This is mostly like the - * interop message {@code toNative} but may of course fail if native access is not allowed. This - * method can be used to force the context to native if a native pointer is needed that will be - * handed to a native (e.g. JNI or NFI) function. - */ - @Override - protected void toNativeInternal() { - CompilerDirectives.transferToInterpreter(); - assert !isPointer(); - assert PythonLanguage.get(null).getEngineOption(PythonOptions.HPyBackend) == HPyBackendMode.LLVM; - nativePointer = HPyLLVMCallHelperFunctionNode.callUncached(context, GRAAL_HPY_CONTEXT_TO_NATIVE, this); - } - - @Override - protected Object createArgumentsArray(Object[] args) { - return new HPyArrayWrapper(context, args); - } - - @Override - protected void freeArgumentsArray(Object argsArray) { - if (argsArray instanceof HPyArrayWrapper hpyArrayWrapper) { - hpyArrayWrapper.close(); - } - } - - private static int expectInt(Object value) { - if (value instanceof Integer i) { - return i; - } - InteropLibrary lib = InteropLibrary.getUncached(value); - if (lib.fitsInInt(value)) { - try { - return lib.asInt(value); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw CompilerDirectives.shouldNotReachHere(); - } - - private static Object createConstant(Object value) { - return GraalHPyHandle.create(value); - } - - private Object createBuiltinsConstant() { - return createConstant(GetOrCreateDictNode.executeUncached(context.getContext().getBuiltins())); - } - - private static Object createSingletonConstant(Object value, int handle) { - return GraalHPyHandle.createSingleton(value, handle); - } - - private Object createTypeConstant(PythonBuiltinClassType value) { - return GraalHPyHandle.create(context.getContext().lookupType(value)); - } - - private static HPyExecuteWrapper createContextFunction(HPyContextMember member) { - return new HPyExecuteWrapper(member); - } - - private Object[] createMembers(TruffleString name) { - Object[] members = new Object[HPyContextMember.VALUES.length]; - - members[HPyContextMember.NAME.ordinal()] = new CStringWrapper(name.switchEncodingUncached(TruffleString.Encoding.UTF_8), TruffleString.Encoding.UTF_8); - // TODO(fa): we should use the value of macro HPY_ABI_VERSION here - members[HPyContextMember.ABI_VERSION.ordinal()] = 0; - - // {{start llvm ctx init}} - // @formatter:off - // Checkstyle: stop - // DO NOT EDIT THIS PART! - // This part is automatically generated by hpy.tools.autogen.graalpy.autogen_ctx_llvm_init - members[HPyContextMember.H_NONE.ordinal()] = createSingletonConstant(PNone.NONE, SINGLETON_HANDLE_NONE); - members[HPyContextMember.H_TRUE.ordinal()] = createConstant(context.getContext().getTrue()); - members[HPyContextMember.H_FALSE.ordinal()] = createConstant(context.getContext().getFalse()); - members[HPyContextMember.H_NOTIMPLEMENTED.ordinal()] = createSingletonConstant(PNotImplemented.NOT_IMPLEMENTED, SINGLETON_HANDLE_NOT_IMPLEMENTED); - members[HPyContextMember.H_ELLIPSIS.ordinal()] = createSingletonConstant(PEllipsis.INSTANCE, SINGLETON_HANDLE_ELIPSIS); - members[HPyContextMember.H_BASEEXCEPTION.ordinal()] = createTypeConstant(PythonBuiltinClassType.PBaseException); - members[HPyContextMember.H_EXCEPTION.ordinal()] = createTypeConstant(PythonBuiltinClassType.Exception); - members[HPyContextMember.H_STOPASYNCITERATION.ordinal()] = createTypeConstant(PythonBuiltinClassType.StopAsyncIteration); - members[HPyContextMember.H_STOPITERATION.ordinal()] = createTypeConstant(PythonBuiltinClassType.StopIteration); - members[HPyContextMember.H_GENERATOREXIT.ordinal()] = createTypeConstant(PythonBuiltinClassType.GeneratorExit); - members[HPyContextMember.H_ARITHMETICERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ArithmeticError); - members[HPyContextMember.H_LOOKUPERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.LookupError); - members[HPyContextMember.H_ASSERTIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.AssertionError); - members[HPyContextMember.H_ATTRIBUTEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.AttributeError); - members[HPyContextMember.H_BUFFERERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.BufferError); - members[HPyContextMember.H_EOFERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.EOFError); - members[HPyContextMember.H_FLOATINGPOINTERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.FloatingPointError); - members[HPyContextMember.H_OSERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.OSError); - members[HPyContextMember.H_IMPORTERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ImportError); - members[HPyContextMember.H_MODULENOTFOUNDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ModuleNotFoundError); - members[HPyContextMember.H_INDEXERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.IndexError); - members[HPyContextMember.H_KEYERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.KeyError); - members[HPyContextMember.H_KEYBOARDINTERRUPT.ordinal()] = createTypeConstant(PythonBuiltinClassType.KeyboardInterrupt); - members[HPyContextMember.H_MEMORYERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.MemoryError); - members[HPyContextMember.H_NAMEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.NameError); - members[HPyContextMember.H_OVERFLOWERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.OverflowError); - members[HPyContextMember.H_RUNTIMEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.RuntimeError); - members[HPyContextMember.H_RECURSIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.RecursionError); - members[HPyContextMember.H_NOTIMPLEMENTEDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.NotImplementedError); - members[HPyContextMember.H_SYNTAXERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.SyntaxError); - members[HPyContextMember.H_INDENTATIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.IndentationError); - members[HPyContextMember.H_TABERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.TabError); - members[HPyContextMember.H_REFERENCEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ReferenceError); - members[HPyContextMember.H_SYSTEMERROR.ordinal()] = createTypeConstant(SystemError); - members[HPyContextMember.H_SYSTEMEXIT.ordinal()] = createTypeConstant(PythonBuiltinClassType.SystemExit); - members[HPyContextMember.H_TYPEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.TypeError); - members[HPyContextMember.H_UNBOUNDLOCALERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnboundLocalError); - members[HPyContextMember.H_UNICODEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnicodeError); - members[HPyContextMember.H_UNICODEENCODEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnicodeEncodeError); - members[HPyContextMember.H_UNICODEDECODEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnicodeDecodeError); - members[HPyContextMember.H_UNICODETRANSLATEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnicodeTranslateError); - members[HPyContextMember.H_VALUEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ValueError); - members[HPyContextMember.H_ZERODIVISIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ZeroDivisionError); - members[HPyContextMember.H_BLOCKINGIOERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.BlockingIOError); - members[HPyContextMember.H_BROKENPIPEERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.BrokenPipeError); - members[HPyContextMember.H_CHILDPROCESSERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ChildProcessError); - members[HPyContextMember.H_CONNECTIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ConnectionError); - members[HPyContextMember.H_CONNECTIONABORTEDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ConnectionAbortedError); - members[HPyContextMember.H_CONNECTIONREFUSEDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ConnectionRefusedError); - members[HPyContextMember.H_CONNECTIONRESETERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ConnectionResetError); - members[HPyContextMember.H_FILEEXISTSERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.FileExistsError); - members[HPyContextMember.H_FILENOTFOUNDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.FileNotFoundError); - members[HPyContextMember.H_INTERRUPTEDERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.InterruptedError); - members[HPyContextMember.H_ISADIRECTORYERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.IsADirectoryError); - members[HPyContextMember.H_NOTADIRECTORYERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.NotADirectoryError); - members[HPyContextMember.H_PERMISSIONERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.PermissionError); - members[HPyContextMember.H_PROCESSLOOKUPERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.ProcessLookupError); - members[HPyContextMember.H_TIMEOUTERROR.ordinal()] = createTypeConstant(PythonBuiltinClassType.TimeoutError); - members[HPyContextMember.H_WARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.Warning); - members[HPyContextMember.H_USERWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.UserWarning); - members[HPyContextMember.H_DEPRECATIONWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.DeprecationWarning); - members[HPyContextMember.H_PENDINGDEPRECATIONWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.PendingDeprecationWarning); - members[HPyContextMember.H_SYNTAXWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.SyntaxWarning); - members[HPyContextMember.H_RUNTIMEWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.RuntimeWarning); - members[HPyContextMember.H_FUTUREWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.FutureWarning); - members[HPyContextMember.H_IMPORTWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.ImportWarning); - members[HPyContextMember.H_UNICODEWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.UnicodeWarning); - members[HPyContextMember.H_BYTESWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.BytesWarning); - members[HPyContextMember.H_RESOURCEWARNING.ordinal()] = createTypeConstant(PythonBuiltinClassType.ResourceWarning); - members[HPyContextMember.H_BASEOBJECTTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PythonObject); - members[HPyContextMember.H_TYPETYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PythonClass); - members[HPyContextMember.H_BOOLTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.Boolean); - members[HPyContextMember.H_LONGTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PInt); - members[HPyContextMember.H_FLOATTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PFloat); - members[HPyContextMember.H_UNICODETYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PString); - members[HPyContextMember.H_TUPLETYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PTuple); - members[HPyContextMember.H_LISTTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PList); - members[HPyContextMember.H_COMPLEXTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PComplex); - members[HPyContextMember.H_BYTESTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PBytes); - members[HPyContextMember.H_MEMORYVIEWTYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PMemoryView); - members[HPyContextMember.H_CAPSULETYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.Capsule); - members[HPyContextMember.H_SLICETYPE.ordinal()] = createTypeConstant(PythonBuiltinClassType.PSlice); - members[HPyContextMember.H_BUILTINS.ordinal()] = createBuiltinsConstant(); - - members[HPyContextMember.CTX_DUP.ordinal()] = createContextFunction(HPyContextMember.CTX_DUP); - members[HPyContextMember.CTX_CLOSE.ordinal()] = createContextFunction(HPyContextMember.CTX_CLOSE); - members[HPyContextMember.CTX_LONG_FROMINT32_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMINT32_T); - members[HPyContextMember.CTX_LONG_FROMUINT32_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMUINT32_T); - members[HPyContextMember.CTX_LONG_FROMINT64_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMINT64_T); - members[HPyContextMember.CTX_LONG_FROMUINT64_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMUINT64_T); - members[HPyContextMember.CTX_LONG_FROMSIZE_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMSIZE_T); - members[HPyContextMember.CTX_LONG_FROMSSIZE_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_FROMSSIZE_T); - members[HPyContextMember.CTX_LONG_ASINT32_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASINT32_T); - members[HPyContextMember.CTX_LONG_ASUINT32_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASUINT32_T); - members[HPyContextMember.CTX_LONG_ASUINT32_TMASK.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASUINT32_TMASK); - members[HPyContextMember.CTX_LONG_ASINT64_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASINT64_T); - members[HPyContextMember.CTX_LONG_ASUINT64_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASUINT64_T); - members[HPyContextMember.CTX_LONG_ASUINT64_TMASK.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASUINT64_TMASK); - members[HPyContextMember.CTX_LONG_ASSIZE_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASSIZE_T); - members[HPyContextMember.CTX_LONG_ASSSIZE_T.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASSSIZE_T); - members[HPyContextMember.CTX_LONG_ASVOIDPTR.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASVOIDPTR); - members[HPyContextMember.CTX_LONG_ASDOUBLE.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG_ASDOUBLE); - members[HPyContextMember.CTX_FLOAT_FROMDOUBLE.ordinal()] = createContextFunction(HPyContextMember.CTX_FLOAT_FROMDOUBLE); - members[HPyContextMember.CTX_FLOAT_ASDOUBLE.ordinal()] = createContextFunction(HPyContextMember.CTX_FLOAT_ASDOUBLE); - members[HPyContextMember.CTX_BOOL_FROMBOOL.ordinal()] = createContextFunction(HPyContextMember.CTX_BOOL_FROMBOOL); - members[HPyContextMember.CTX_LENGTH.ordinal()] = createContextFunction(HPyContextMember.CTX_LENGTH); - members[HPyContextMember.CTX_NUMBER_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_NUMBER_CHECK); - members[HPyContextMember.CTX_ADD.ordinal()] = createContextFunction(HPyContextMember.CTX_ADD); - members[HPyContextMember.CTX_SUBTRACT.ordinal()] = createContextFunction(HPyContextMember.CTX_SUBTRACT); - members[HPyContextMember.CTX_MULTIPLY.ordinal()] = createContextFunction(HPyContextMember.CTX_MULTIPLY); - members[HPyContextMember.CTX_MATRIXMULTIPLY.ordinal()] = createContextFunction(HPyContextMember.CTX_MATRIXMULTIPLY); - members[HPyContextMember.CTX_FLOORDIVIDE.ordinal()] = createContextFunction(HPyContextMember.CTX_FLOORDIVIDE); - members[HPyContextMember.CTX_TRUEDIVIDE.ordinal()] = createContextFunction(HPyContextMember.CTX_TRUEDIVIDE); - members[HPyContextMember.CTX_REMAINDER.ordinal()] = createContextFunction(HPyContextMember.CTX_REMAINDER); - members[HPyContextMember.CTX_DIVMOD.ordinal()] = createContextFunction(HPyContextMember.CTX_DIVMOD); - members[HPyContextMember.CTX_POWER.ordinal()] = createContextFunction(HPyContextMember.CTX_POWER); - members[HPyContextMember.CTX_NEGATIVE.ordinal()] = createContextFunction(HPyContextMember.CTX_NEGATIVE); - members[HPyContextMember.CTX_POSITIVE.ordinal()] = createContextFunction(HPyContextMember.CTX_POSITIVE); - members[HPyContextMember.CTX_ABSOLUTE.ordinal()] = createContextFunction(HPyContextMember.CTX_ABSOLUTE); - members[HPyContextMember.CTX_INVERT.ordinal()] = createContextFunction(HPyContextMember.CTX_INVERT); - members[HPyContextMember.CTX_LSHIFT.ordinal()] = createContextFunction(HPyContextMember.CTX_LSHIFT); - members[HPyContextMember.CTX_RSHIFT.ordinal()] = createContextFunction(HPyContextMember.CTX_RSHIFT); - members[HPyContextMember.CTX_AND.ordinal()] = createContextFunction(HPyContextMember.CTX_AND); - members[HPyContextMember.CTX_XOR.ordinal()] = createContextFunction(HPyContextMember.CTX_XOR); - members[HPyContextMember.CTX_OR.ordinal()] = createContextFunction(HPyContextMember.CTX_OR); - members[HPyContextMember.CTX_INDEX.ordinal()] = createContextFunction(HPyContextMember.CTX_INDEX); - members[HPyContextMember.CTX_LONG.ordinal()] = createContextFunction(HPyContextMember.CTX_LONG); - members[HPyContextMember.CTX_FLOAT.ordinal()] = createContextFunction(HPyContextMember.CTX_FLOAT); - members[HPyContextMember.CTX_INPLACEADD.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEADD); - members[HPyContextMember.CTX_INPLACESUBTRACT.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACESUBTRACT); - members[HPyContextMember.CTX_INPLACEMULTIPLY.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEMULTIPLY); - members[HPyContextMember.CTX_INPLACEMATRIXMULTIPLY.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEMATRIXMULTIPLY); - members[HPyContextMember.CTX_INPLACEFLOORDIVIDE.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEFLOORDIVIDE); - members[HPyContextMember.CTX_INPLACETRUEDIVIDE.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACETRUEDIVIDE); - members[HPyContextMember.CTX_INPLACEREMAINDER.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEREMAINDER); - members[HPyContextMember.CTX_INPLACEPOWER.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEPOWER); - members[HPyContextMember.CTX_INPLACELSHIFT.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACELSHIFT); - members[HPyContextMember.CTX_INPLACERSHIFT.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACERSHIFT); - members[HPyContextMember.CTX_INPLACEAND.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEAND); - members[HPyContextMember.CTX_INPLACEXOR.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEXOR); - members[HPyContextMember.CTX_INPLACEOR.ordinal()] = createContextFunction(HPyContextMember.CTX_INPLACEOR); - members[HPyContextMember.CTX_CALLABLE_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_CALLABLE_CHECK); - members[HPyContextMember.CTX_CALLTUPLEDICT.ordinal()] = createContextFunction(HPyContextMember.CTX_CALLTUPLEDICT); - members[HPyContextMember.CTX_CALL.ordinal()] = createContextFunction(HPyContextMember.CTX_CALL); - members[HPyContextMember.CTX_CALLMETHOD.ordinal()] = createContextFunction(HPyContextMember.CTX_CALLMETHOD); - members[HPyContextMember.CTX_FATALERROR.ordinal()] = createContextFunction(HPyContextMember.CTX_FATALERROR); - members[HPyContextMember.CTX_ERR_SETSTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_SETSTRING); - members[HPyContextMember.CTX_ERR_SETOBJECT.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_SETOBJECT); - members[HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAME.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAME); - members[HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_SETFROMERRNOWITHFILENAMEOBJECTS); - members[HPyContextMember.CTX_ERR_OCCURRED.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_OCCURRED); - members[HPyContextMember.CTX_ERR_EXCEPTIONMATCHES.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_EXCEPTIONMATCHES); - members[HPyContextMember.CTX_ERR_NOMEMORY.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_NOMEMORY); - members[HPyContextMember.CTX_ERR_CLEAR.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_CLEAR); - members[HPyContextMember.CTX_ERR_NEWEXCEPTION.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_NEWEXCEPTION); - members[HPyContextMember.CTX_ERR_NEWEXCEPTIONWITHDOC.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_NEWEXCEPTIONWITHDOC); - members[HPyContextMember.CTX_ERR_WARNEX.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_WARNEX); - members[HPyContextMember.CTX_ERR_WRITEUNRAISABLE.ordinal()] = createContextFunction(HPyContextMember.CTX_ERR_WRITEUNRAISABLE); - members[HPyContextMember.CTX_ISTRUE.ordinal()] = createContextFunction(HPyContextMember.CTX_ISTRUE); - members[HPyContextMember.CTX_TYPE_FROMSPEC.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE_FROMSPEC); - members[HPyContextMember.CTX_TYPE_GENERICNEW.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE_GENERICNEW); - members[HPyContextMember.CTX_GETATTR.ordinal()] = createContextFunction(HPyContextMember.CTX_GETATTR); - members[HPyContextMember.CTX_GETATTR_S.ordinal()] = createContextFunction(HPyContextMember.CTX_GETATTR_S); - members[HPyContextMember.CTX_HASATTR.ordinal()] = createContextFunction(HPyContextMember.CTX_HASATTR); - members[HPyContextMember.CTX_HASATTR_S.ordinal()] = createContextFunction(HPyContextMember.CTX_HASATTR_S); - members[HPyContextMember.CTX_SETATTR.ordinal()] = createContextFunction(HPyContextMember.CTX_SETATTR); - members[HPyContextMember.CTX_SETATTR_S.ordinal()] = createContextFunction(HPyContextMember.CTX_SETATTR_S); - members[HPyContextMember.CTX_GETITEM.ordinal()] = createContextFunction(HPyContextMember.CTX_GETITEM); - members[HPyContextMember.CTX_GETITEM_I.ordinal()] = createContextFunction(HPyContextMember.CTX_GETITEM_I); - members[HPyContextMember.CTX_GETITEM_S.ordinal()] = createContextFunction(HPyContextMember.CTX_GETITEM_S); - members[HPyContextMember.CTX_CONTAINS.ordinal()] = createContextFunction(HPyContextMember.CTX_CONTAINS); - members[HPyContextMember.CTX_SETITEM.ordinal()] = createContextFunction(HPyContextMember.CTX_SETITEM); - members[HPyContextMember.CTX_SETITEM_I.ordinal()] = createContextFunction(HPyContextMember.CTX_SETITEM_I); - members[HPyContextMember.CTX_SETITEM_S.ordinal()] = createContextFunction(HPyContextMember.CTX_SETITEM_S); - members[HPyContextMember.CTX_DELITEM.ordinal()] = createContextFunction(HPyContextMember.CTX_DELITEM); - members[HPyContextMember.CTX_DELITEM_I.ordinal()] = createContextFunction(HPyContextMember.CTX_DELITEM_I); - members[HPyContextMember.CTX_DELITEM_S.ordinal()] = createContextFunction(HPyContextMember.CTX_DELITEM_S); - members[HPyContextMember.CTX_TYPE.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE); - members[HPyContextMember.CTX_TYPECHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPECHECK); - members[HPyContextMember.CTX_TYPE_GETNAME.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE_GETNAME); - members[HPyContextMember.CTX_TYPE_ISSUBTYPE.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE_ISSUBTYPE); - members[HPyContextMember.CTX_IS.ordinal()] = createContextFunction(HPyContextMember.CTX_IS); - members[HPyContextMember.CTX_ASSTRUCT_OBJECT.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_OBJECT); - members[HPyContextMember.CTX_ASSTRUCT_LEGACY.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_LEGACY); - members[HPyContextMember.CTX_ASSTRUCT_TYPE.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_TYPE); - members[HPyContextMember.CTX_ASSTRUCT_LONG.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_LONG); - members[HPyContextMember.CTX_ASSTRUCT_FLOAT.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_FLOAT); - members[HPyContextMember.CTX_ASSTRUCT_UNICODE.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_UNICODE); - members[HPyContextMember.CTX_ASSTRUCT_TUPLE.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_TUPLE); - members[HPyContextMember.CTX_ASSTRUCT_LIST.ordinal()] = createContextFunction(HPyContextMember.CTX_ASSTRUCT_LIST); - members[HPyContextMember.CTX_TYPE_GETBUILTINSHAPE.ordinal()] = createContextFunction(HPyContextMember.CTX_TYPE_GETBUILTINSHAPE); - members[HPyContextMember.CTX_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_NEW); - members[HPyContextMember.CTX_REPR.ordinal()] = createContextFunction(HPyContextMember.CTX_REPR); - members[HPyContextMember.CTX_STR.ordinal()] = createContextFunction(HPyContextMember.CTX_STR); - members[HPyContextMember.CTX_ASCII.ordinal()] = createContextFunction(HPyContextMember.CTX_ASCII); - members[HPyContextMember.CTX_BYTES.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES); - members[HPyContextMember.CTX_RICHCOMPARE.ordinal()] = createContextFunction(HPyContextMember.CTX_RICHCOMPARE); - members[HPyContextMember.CTX_RICHCOMPAREBOOL.ordinal()] = createContextFunction(HPyContextMember.CTX_RICHCOMPAREBOOL); - members[HPyContextMember.CTX_HASH.ordinal()] = createContextFunction(HPyContextMember.CTX_HASH); - members[HPyContextMember.CTX_BYTES_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_CHECK); - members[HPyContextMember.CTX_BYTES_SIZE.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_SIZE); - members[HPyContextMember.CTX_BYTES_GET_SIZE.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_GET_SIZE); - members[HPyContextMember.CTX_BYTES_ASSTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_ASSTRING); - members[HPyContextMember.CTX_BYTES_AS_STRING.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_AS_STRING); - members[HPyContextMember.CTX_BYTES_FROMSTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_FROMSTRING); - members[HPyContextMember.CTX_BYTES_FROMSTRINGANDSIZE.ordinal()] = createContextFunction(HPyContextMember.CTX_BYTES_FROMSTRINGANDSIZE); - members[HPyContextMember.CTX_UNICODE_FROMSTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_FROMSTRING); - members[HPyContextMember.CTX_UNICODE_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_CHECK); - members[HPyContextMember.CTX_UNICODE_ASASCIISTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_ASASCIISTRING); - members[HPyContextMember.CTX_UNICODE_ASLATIN1STRING.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_ASLATIN1STRING); - members[HPyContextMember.CTX_UNICODE_ASUTF8STRING.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_ASUTF8STRING); - members[HPyContextMember.CTX_UNICODE_ASUTF8ANDSIZE.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_ASUTF8ANDSIZE); - members[HPyContextMember.CTX_UNICODE_FROMWIDECHAR.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_FROMWIDECHAR); - members[HPyContextMember.CTX_UNICODE_DECODEFSDEFAULT.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_DECODEFSDEFAULT); - members[HPyContextMember.CTX_UNICODE_DECODEFSDEFAULTANDSIZE.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_DECODEFSDEFAULTANDSIZE); - members[HPyContextMember.CTX_UNICODE_ENCODEFSDEFAULT.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_ENCODEFSDEFAULT); - members[HPyContextMember.CTX_UNICODE_READCHAR.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_READCHAR); - members[HPyContextMember.CTX_UNICODE_DECODEASCII.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_DECODEASCII); - members[HPyContextMember.CTX_UNICODE_DECODELATIN1.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_DECODELATIN1); - members[HPyContextMember.CTX_UNICODE_FROMENCODEDOBJECT.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_FROMENCODEDOBJECT); - members[HPyContextMember.CTX_UNICODE_SUBSTRING.ordinal()] = createContextFunction(HPyContextMember.CTX_UNICODE_SUBSTRING); - members[HPyContextMember.CTX_LIST_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_LIST_CHECK); - members[HPyContextMember.CTX_LIST_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_LIST_NEW); - members[HPyContextMember.CTX_LIST_APPEND.ordinal()] = createContextFunction(HPyContextMember.CTX_LIST_APPEND); - members[HPyContextMember.CTX_DICT_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_DICT_CHECK); - members[HPyContextMember.CTX_DICT_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_DICT_NEW); - members[HPyContextMember.CTX_DICT_KEYS.ordinal()] = createContextFunction(HPyContextMember.CTX_DICT_KEYS); - members[HPyContextMember.CTX_DICT_COPY.ordinal()] = createContextFunction(HPyContextMember.CTX_DICT_COPY); - members[HPyContextMember.CTX_TUPLE_CHECK.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLE_CHECK); - members[HPyContextMember.CTX_TUPLE_FROMARRAY.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLE_FROMARRAY); - members[HPyContextMember.CTX_SLICE_UNPACK.ordinal()] = createContextFunction(HPyContextMember.CTX_SLICE_UNPACK); - members[HPyContextMember.CTX_IMPORT_IMPORTMODULE.ordinal()] = createContextFunction(HPyContextMember.CTX_IMPORT_IMPORTMODULE); - members[HPyContextMember.CTX_CAPSULE_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_CAPSULE_NEW); - members[HPyContextMember.CTX_CAPSULE_GET.ordinal()] = createContextFunction(HPyContextMember.CTX_CAPSULE_GET); - members[HPyContextMember.CTX_CAPSULE_ISVALID.ordinal()] = createContextFunction(HPyContextMember.CTX_CAPSULE_ISVALID); - members[HPyContextMember.CTX_CAPSULE_SET.ordinal()] = createContextFunction(HPyContextMember.CTX_CAPSULE_SET); - members[HPyContextMember.CTX_FROMPYOBJECT.ordinal()] = createContextFunction(HPyContextMember.CTX_FROMPYOBJECT); - members[HPyContextMember.CTX_ASPYOBJECT.ordinal()] = createContextFunction(HPyContextMember.CTX_ASPYOBJECT); - members[HPyContextMember.CTX_LISTBUILDER_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_LISTBUILDER_NEW); - members[HPyContextMember.CTX_LISTBUILDER_SET.ordinal()] = createContextFunction(HPyContextMember.CTX_LISTBUILDER_SET); - members[HPyContextMember.CTX_LISTBUILDER_BUILD.ordinal()] = createContextFunction(HPyContextMember.CTX_LISTBUILDER_BUILD); - members[HPyContextMember.CTX_LISTBUILDER_CANCEL.ordinal()] = createContextFunction(HPyContextMember.CTX_LISTBUILDER_CANCEL); - members[HPyContextMember.CTX_TUPLEBUILDER_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLEBUILDER_NEW); - members[HPyContextMember.CTX_TUPLEBUILDER_SET.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLEBUILDER_SET); - members[HPyContextMember.CTX_TUPLEBUILDER_BUILD.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLEBUILDER_BUILD); - members[HPyContextMember.CTX_TUPLEBUILDER_CANCEL.ordinal()] = createContextFunction(HPyContextMember.CTX_TUPLEBUILDER_CANCEL); - members[HPyContextMember.CTX_TRACKER_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_TRACKER_NEW); - members[HPyContextMember.CTX_TRACKER_ADD.ordinal()] = createContextFunction(HPyContextMember.CTX_TRACKER_ADD); - members[HPyContextMember.CTX_TRACKER_FORGETALL.ordinal()] = createContextFunction(HPyContextMember.CTX_TRACKER_FORGETALL); - members[HPyContextMember.CTX_TRACKER_CLOSE.ordinal()] = createContextFunction(HPyContextMember.CTX_TRACKER_CLOSE); - members[HPyContextMember.CTX_FIELD_STORE.ordinal()] = createContextFunction(HPyContextMember.CTX_FIELD_STORE); - members[HPyContextMember.CTX_FIELD_LOAD.ordinal()] = createContextFunction(HPyContextMember.CTX_FIELD_LOAD); - members[HPyContextMember.CTX_REENTERPYTHONEXECUTION.ordinal()] = createContextFunction(HPyContextMember.CTX_REENTERPYTHONEXECUTION); - members[HPyContextMember.CTX_LEAVEPYTHONEXECUTION.ordinal()] = createContextFunction(HPyContextMember.CTX_LEAVEPYTHONEXECUTION); - members[HPyContextMember.CTX_GLOBAL_STORE.ordinal()] = createContextFunction(HPyContextMember.CTX_GLOBAL_STORE); - members[HPyContextMember.CTX_GLOBAL_LOAD.ordinal()] = createContextFunction(HPyContextMember.CTX_GLOBAL_LOAD); - members[HPyContextMember.CTX_DUMP.ordinal()] = createContextFunction(HPyContextMember.CTX_DUMP); - members[HPyContextMember.CTX_COMPILE_S.ordinal()] = createContextFunction(HPyContextMember.CTX_COMPILE_S); - members[HPyContextMember.CTX_EVALCODE.ordinal()] = createContextFunction(HPyContextMember.CTX_EVALCODE); - members[HPyContextMember.CTX_CONTEXTVAR_NEW.ordinal()] = createContextFunction(HPyContextMember.CTX_CONTEXTVAR_NEW); - members[HPyContextMember.CTX_CONTEXTVAR_GET.ordinal()] = createContextFunction(HPyContextMember.CTX_CONTEXTVAR_GET); - members[HPyContextMember.CTX_CONTEXTVAR_SET.ordinal()] = createContextFunction(HPyContextMember.CTX_CONTEXTVAR_SET); - members[HPyContextMember.CTX_SETCALLFUNCTION.ordinal()] = createContextFunction(HPyContextMember.CTX_SETCALLFUNCTION); - - // @formatter:on - // Checkstyle: resume - // {{end llvm ctx init}} - - return members; - } - - @TruffleBoundary - public static int getIndex(String key) { - if (contextMembersByName == null) { - HashMap contextMemberHashMap = new HashMap<>(); - for (HPyContextMember member : HPyContextMember.VALUES) { - contextMemberHashMap.put(member.getName(), member); - } - // allow races; it doesn't matter since contents will always be the same - contextMembersByName = contextMemberHashMap; - } - HPyContextMember member = contextMembersByName.get(key); - return member == null ? -1 : member.ordinal(); - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasMembers() { - return true; - } - - @ExportMessage - @SuppressWarnings("static-method") - Object getMembers(@SuppressWarnings("unused") boolean includeInternal) { - String[] names = new String[HPyContextMember.VALUES.length]; - for (int i = 0; i < names.length; i++) { - names[i] = HPyContextMember.VALUES[i].getName(); - } - return new PythonAbstractObject.Keys(names); - } - - @ExportMessage - @ImportStatic(GraalHPyLLVMContext.class) - static class IsMemberReadable { - @Specialization(guards = "cachedKey.equals(key)", limit = "1") - static boolean isMemberReadableCached(@SuppressWarnings("unused") GraalHPyLLVMContext context, @SuppressWarnings("unused") String key, - @Cached(value = "key") @SuppressWarnings("unused") String cachedKey, - @Cached(value = "getIndex(key)") int cachedIdx) { - return cachedIdx != -1; - } - - @Specialization(replaces = "isMemberReadableCached") - static boolean isMemberReadable(@SuppressWarnings("unused") GraalHPyLLVMContext context, String key) { - return getIndex(key) != -1; - } - } - - @ExportMessage - Object readMember(String key, - @Bind("$node") Node inliningTarget, - @Shared("readMemberNode") @Cached GraalHPyReadMemberNode readMemberNode) { - return readMemberNode.execute(inliningTarget, this, key); - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasNativeType() { - return true; - } - - @ExportMessage - Object getNativeType() { - return hpyContextNativeTypeID; - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - @ImportStatic(GraalHPyLLVMContext.class) - abstract static class GraalHPyReadMemberNode extends Node { - - public abstract Object execute(Node node, GraalHPyLLVMContext backend, String key); - - @Specialization(guards = "cachedKey == key", limit = "1") - static Object doMemberCached(GraalHPyLLVMContext backend, String key, - @Cached("key") @SuppressWarnings("unused") String cachedKey, - @Cached("getIndex(key)") int cachedIdx) { - // TODO(fa) once everything is implemented, remove this check - if (cachedIdx != -1) { - Object value = backend.hpyContextMembers[cachedIdx]; - if (value != null) { - return value; - } - } - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw CompilerDirectives.shouldNotReachHere(PythonUtils.formatJString("context function %s not yet implemented: ", key)); - } - - @Specialization(replaces = "doMemberCached") - static Object doMember(GraalHPyLLVMContext backend, String key) { - return doMemberCached(backend, key, key, getIndex(key)); - } - } - - @ExportMessage - boolean isMemberInvocable(String key, - @Bind("$node") Node inliningTarget, - @Shared("readMemberNode") @Cached GraalHPyReadMemberNode readMemberNode, - @Shared("memberInvokeLib") @CachedLibrary(limit = "1") InteropLibrary memberInvokeLib) { - Object member = readMemberNode.execute(inliningTarget, this, key); - return member != null && memberInvokeLib.isExecutable(member); - } - - @ExportMessage - Object invokeMember(String key, Object[] args, - @Bind("$node") Node inliningTarget, - @Shared("readMemberNode") @Cached GraalHPyReadMemberNode readMemberNode, - @Shared("memberInvokeLib") @CachedLibrary(limit = "1") InteropLibrary memberInvokeLib) - throws UnsupportedMessageException, UnsupportedTypeException, ArityException { - Object member = readMemberNode.execute(inliningTarget, this, key); - assert member != null; - /* - * Optimization: the first argument *MUST* always be the context. If not, we can just set - * 'this'. - */ - args[0] = context; - return memberInvokeLib.execute(member, args); - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - @SuppressWarnings("truffle-inlining") - abstract static class HPyExecuteContextFunction extends Node { - public abstract Object execute(Node inliningTarget, HPyContextMember member, Object[] arguments) throws ArityException; - - @Specialization(guards = "member == cachedMember", limit = "1") - static Object doCached(Node inliningTarget, @SuppressWarnings("unused") HPyContextMember member, Object[] arguments, - @Cached("member") HPyContextMember cachedMember, - @Cached(parameters = "member") GraalHPyContextFunction contextFunctionNode, - @Cached("createRetNode(member)") CExtToNativeNode retNode, - @Cached("createArgNodes(member)") CExtAsPythonObjectNode[] argNodes, - @Cached HPyTransformExceptionToNativeNode transformExceptionToNativeNode) throws ArityException { - checkArity(arguments, cachedMember.getSignature().parameterTypes().length); - try { - try { - Object[] argCast; - if (argNodes != null) { - argCast = new Object[argNodes.length]; - castArguments(arguments, argCast, argNodes); - } else { - argCast = arguments; - } - Object result = contextFunctionNode.execute(argCast); - if (retNode != null) { - result = retNode.execute(result); - } - return result; - } catch (Throwable t) { - throw checkThrowableBeforeNative(t, "HPy context function", cachedMember.getName()); - } - } catch (PException e) { - transformExceptionToNativeNode.execute(inliningTarget, e); - return getErrorValue(inliningTarget, cachedMember.getSignature().returnType()); - } - } - - @Specialization(replaces = "doCached") - @Megamorphic - @TruffleBoundary - static Object doUncached(Node inliningTarget, HPyContextMember member, Object[] arguments) throws ArityException { - return doCached(inliningTarget, member, arguments, member, GraalHPyContextFunction.getUncached(member), getUncachedRetNode(member), getUncachedArgNodes(member), - HPyTransformExceptionToNativeNodeGen.getUncached()); - } - - private static void checkArity(Object[] arguments, int expectedArity) throws ArityException { - if (arguments.length != expectedArity) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw ArityException.create(expectedArity, expectedArity, arguments.length); - } - } - - @ExplodeLoop - private static void castArguments(Object[] arguments, Object[] argCast, CExtAsPythonObjectNode[] argNodes) { - for (int i = 0; i < argNodes.length; i++) { - argCast[i] = argNodes[i] == null ? arguments[i] : argNodes[i].execute(arguments[i]); - } - } - - private static Object getErrorValue(Node inliningTarget, HPyContextSignatureType type) { - return switch (type) { - case Int, Int32_t, Uint32_t, HPy_UCS4 -> -1; - case Int64_t, Uint64_t, Size_t, HPy_ssize_t, HPy_hash_t -> -1L; - case CDouble -> -1.0; - case HPy -> GraalHPyHandle.NULL_HANDLE; - case VoidPtr, CharPtr, ConstCharPtr, Cpy_PyObjectPtr -> PythonContext.get(inliningTarget).getNativeNull(); - case CVoid -> PNone.NO_VALUE; - default -> throw CompilerDirectives.shouldNotReachHere("unsupported return type"); - }; - } - - static CExtToNativeNode createRetNode(HPyContextMember member) { - return switch (member.getSignature().returnType()) { - case HPy, HPyThreadState -> HPyAsHandleNodeGen.create(); - case HPy_ssize_t, HPy_hash_t -> HPyAsNativeInt64NodeGen.create(); - default -> null; - }; - } - - static CExtToNativeNode getUncachedRetNode(HPyContextMember member) { - return switch (member.getSignature().returnType()) { - case HPy, HPyThreadState -> HPyAsHandleNodeGen.getUncached(); - case HPy_ssize_t, HPy_hash_t -> HPyAsNativeInt64NodeGen.getUncached(); - default -> null; - }; - } - - /* - * Special cases: the following context functions need the bare handles. Hence, we leave the - * conversion up to the context function impl. - */ - private static boolean noArgumentConversion(HPyContextMember member) { - return switch (member) { - case CTX_CLOSE, CTX_TRACKER_ADD -> true; - default -> false; - }; - } - - static CExtAsPythonObjectNode[] createArgNodes(HPyContextMember member) { - if (noArgumentConversion(member)) { - return null; - } - HPyContextSignatureType[] argTypes = member.getSignature().parameterTypes(); - CExtAsPythonObjectNode[] argNodes = new CExtAsPythonObjectNode[argTypes.length]; - for (int i = 0; i < argNodes.length; i++) { - argNodes[i] = switch (argTypes[i]) { - case HPyContextPtr -> HPyAsContextNodeGen.create(); - case HPy, HPyThreadState -> HPyAsPythonObjectNodeGen.create(); - default -> HPyDummyToJavaNode.getUncached(); - }; - } - return argNodes; - } - - static CExtAsPythonObjectNode[] getUncachedArgNodes(HPyContextMember member) { - if (noArgumentConversion(member)) { - return null; - } - HPyContextSignatureType[] argTypes = member.getSignature().parameterTypes(); - CExtAsPythonObjectNode[] argNodes = new CExtAsPythonObjectNode[argTypes.length]; - for (int i = 0; i < argNodes.length; i++) { - argNodes[i] = switch (argTypes[i]) { - case HPyContextPtr -> HPyAsContextNodeGen.getUncached(); - case HPy, HPyThreadState -> HPyAsPythonObjectNodeGen.getUncached(); - default -> HPyDummyToJavaNode.getUncached(); - }; - } - return argNodes; - } - } - - @ExportLibrary(InteropLibrary.class) - static final class HPyExecuteWrapper implements TruffleObject { - final HPyContextMember member; - - HPyExecuteWrapper(HPyContextMember member) { - this.member = member; - } - - @ExportMessage - boolean isExecutable() { - return true; - } - - @ExportMessage - Object execute(Object[] arguments, - @Bind("$node") Node inliningTarget, - @Cached HPyExecuteContextFunction call) throws ArityException { - return call.execute(inliningTarget, member, arguments); - } - } - - @ExportLibrary(InteropLibrary.class) - static final class HPyExecuteWrapperTraceUpcall implements TruffleObject { - - private final int[] counts; - private final int index; - - final HPyExecuteWrapper delegate; - - public HPyExecuteWrapperTraceUpcall(int[] counts, int index, HPyExecuteWrapper delegate) { - this.counts = counts; - this.index = index; - this.delegate = delegate; - } - - @ExportMessage - boolean isExecutable() { - return true; - } - - @ExportMessage - Object execute(Object[] arguments, - @CachedLibrary("this.delegate") InteropLibrary lib) throws UnsupportedMessageException, UnsupportedTypeException, ArityException { - counts[index]++; - return lib.execute(delegate, arguments); - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java deleted file mode 100644 index e05918ba65..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/GraalHPyLLVMNodes.java +++ /dev/null @@ -1,914 +0,0 @@ -/* - * Copyright (c) 2023, 2025, 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.builtins.objects.cext.hpy.llvm; - -import static com.oracle.graal.python.builtins.PythonBuiltinClassType.SystemError; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_D; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_HPY; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_HPY_SSIZE_T; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I32; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I64; -import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_PTR; -import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING; - -import com.oracle.graal.python.builtins.PythonBuiltinClassType; -import com.oracle.graal.python.builtins.objects.cext.capi.PySequenceArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureTruffleStringNode; -import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.GetByteArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.AllocateNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.BulkFreeHandleReferencesNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.FreeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.GetElementPtrNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.IsNullNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadFloatNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadI8ArrayNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.ReadPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteDoubleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteGenericNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyFieldNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteHPyNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI32Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteI64Node; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WritePointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyCAccess.WriteSizeTNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GraalHPyHandleReference; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsPythonObjectNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseAndGetHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFieldLoadNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFieldStoreNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyFromCharPointerNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyContextSignatureType; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.HPyLLVMCallHelperFunctionNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.GraalHPyLLVMNodesFactory.LLVMAllocateNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.llvm.HPyArrayWrappers.HPyArrayWrapper; -import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.object.PythonObject; -import com.oracle.graal.python.nodes.ErrorMessages; -import com.oracle.graal.python.nodes.PNodeWithContext; -import com.oracle.graal.python.nodes.PRaiseNode; -import com.oracle.graal.python.util.OverflowException; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Bind; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.Cached.Shared; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.ArityException; -import com.oracle.truffle.api.interop.InteropException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.InvalidArrayIndexException; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.api.profiles.InlinedExactClassProfile; -import com.oracle.truffle.api.strings.InternalByteArray; -import com.oracle.truffle.api.strings.TruffleString; -import com.oracle.truffle.api.strings.TruffleString.Encoding; - -import sun.misc.Unsafe; - -abstract class GraalHPyLLVMNodes { - - private GraalHPyLLVMNodes() { - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMIsNullNode extends IsNullNode { - @Specialization(limit = "2") - static boolean doGeneric(@SuppressWarnings("unused") GraalHPyContext hpyContext, Object pointer, - @CachedLibrary("pointer") InteropLibrary lib) { - return lib.isNull(pointer); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class LLVMAllocateNode extends AllocateNode { - - @Specialization - static Object doGeneric(GraalHPyContext ctx, long size, @SuppressWarnings("unused") boolean zero, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode) { - return callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_CALLOC, size, 1L); - } - - static LLVMAllocateNode create() { - return LLVMAllocateNodeGen.create(); - } - - static LLVMAllocateNode getUncached() { - return LLVMAllocateNodeGen.getUncached(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMFreeNode extends FreeNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object pointer, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode) { - callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_FREE, pointer); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMBulkFreeHandleReferencesNode extends BulkFreeHandleReferencesNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, GraalHPyHandleReference[] references, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode) { - NativeSpaceArrayWrapper nativeSpaceArrayWrapper = new NativeSpaceArrayWrapper(references); - callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_BULK_FREE, nativeSpaceArrayWrapper); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMGetElementPtrNode extends GetElementPtrNode { - - @Specialization - static Object doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode) { - return callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_GET_ELEMENT_PTR, pointer, offset); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class LLVMReadI8ArrayNode extends ReadI8ArrayNode { - - @Specialization(limit = "1") - static byte[] doGeneric(GraalHPyContext ctx, Object pointer, long offset, long n, - @Bind("this") Node inliningTarget, - @CachedLibrary("pointer") InteropLibrary interopLib, - @Cached GetByteArrayNode getByteArrayNode, - @Cached HPyLLVMCallHelperFunctionNode callHPyFunction) { - if (!PInt.isIntRange(n)) { - throw CompilerDirectives.shouldNotReachHere("cannot fit long into int"); - } - Object typedPointer; - if (!interopLib.hasArrayElements(pointer)) { - typedPointer = callHPyFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_FROM_I8_ARRAY, pointer, n); - } else { - typedPointer = pointer; - } - try { - return getByteArrayNode.execute(inliningTarget, typedPointer, n); - } catch (OverflowException | InteropException ex) { - throw CompilerDirectives.shouldNotReachHere(ex); - } - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadHPyNode extends ReadHPyNode { - - @Specialization(guards = "!close") - static Object doGet(GraalHPyContext ctx, Object pointer, long offset, @SuppressWarnings("unused") boolean close, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Exclusive @Cached HPyAsPythonObjectNode asPythonObjectNode) { - Object nativeValue = callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_HPY, pointer, offset); - return asPythonObjectNode.execute(nativeValue); - } - - @Specialization(guards = "close") - static Object doClose(GraalHPyContext ctx, Object pointer, long offset, @SuppressWarnings("unused") boolean close, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Exclusive @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode) { - Object nativeValue = callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_HPY, pointer, offset); - return closeAndGetHandleNode.execute(inliningTarget, nativeValue); - } - - @Specialization(replaces = {"doGet", "doClose"}) - static Object doGeneric(GraalHPyContext ctx, Object pointer, long offset, @SuppressWarnings("unused") boolean close, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Exclusive @Cached HPyAsPythonObjectNode asPythonObjectNode, - @Exclusive @Cached HPyCloseAndGetHandleNode closeAndGetHandleNode) { - Object nativeValue = callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_HPY, pointer, offset); - if (close) { - return closeAndGetHandleNode.execute(inliningTarget, nativeValue); - } - return asPythonObjectNode.execute(nativeValue); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadHPyFieldNode extends ReadHPyFieldNode { - - @Specialization - static Object doGeneric(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, @SuppressWarnings("unused") boolean close, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Cached HPyFieldLoadNode hpyFieldLoadNode) { - Object nativeValue = callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_HPYFIELD, pointer, offset); - return hpyFieldLoadNode.execute(inliningTarget, owner, nativeValue); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadHPyArrayNode extends ReadHPyArrayNode { - - @Specialization - static Object[] doHPyArrayWrapper(@SuppressWarnings("unused") GraalHPyContext ctx, HPyArrayWrapper pointer, long loffset, long ln, - @Bind("this") Node inliningTarget, - @Cached InlinedConditionProfile profile) { - int n = ensureIntRange(ln); - int offset = ensureIntRange(loffset); - Object[] delegate = pointer.getDelegate(); - if (profile.profile(inliningTarget, offset == 0 && delegate.length == n)) { - return delegate; - } - return PythonUtils.arrayCopyOfRange(delegate, offset, offset + n); - } - - @Specialization - static Object[] doPointer(GraalHPyContext ctx, Object pointer, long offset, long ln, - @Bind("this") Node inliningTarget, - @CachedLibrary(limit = "1") InteropLibrary arrayLib, - @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Cached HPyAsPythonObjectNode asPythonObjectNode) { - int n = ensureIntRange(ln); - Object typedArrayPtr = callHelperNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_FROM_HPY_ARRAY, pointer, offset + ln); - if (!arrayLib.hasArrayElements(typedArrayPtr)) { - throw CompilerDirectives.shouldNotReachHere("returned pointer object must have array type"); - } - - Object[] elements = new Object[n]; - try { - for (int i = 0; i < elements.length; i++) { - /* - * This will read an element of a 'VoidPtr arr[]' and the returned value will be - * 'void *'. So, there is no need to read any further element (in particular - * "_i") to get the internal handle value. - */ - Object element = arrayLib.readArrayElement(typedArrayPtr, offset + i); - elements[i] = asPythonObjectNode.execute(element); - } - return elements; - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } catch (InvalidArrayIndexException e) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw PRaiseNode.raiseStatic(arrayLib, SystemError, ErrorMessages.CANNOT_ACCESS_IDX, e.getInvalidIndex(), n); - } - } - - private static int ensureIntRange(long n) { - if (PInt.isIntRange(n)) { - return (int) n; - } - throw CompilerDirectives.shouldNotReachHere("cannot fit long into int"); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadI32Node extends ReadI32Node { - - @Specialization - static int doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction, - @CachedLibrary(limit = "1") InteropLibrary lib) { - - Object nativeValue = callHelperFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_I32, pointer, offset); - if (nativeValue instanceof Integer) { - return (int) nativeValue; - } - if (lib.fitsInInt(nativeValue)) { - try { - return lib.asInt(nativeValue); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadI64Node extends ReadI64Node { - - @Specialization - static long doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction, - @CachedLibrary(limit = "1") InteropLibrary lib) { - - Object nativeValue = callHelperFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_I64, pointer, offset); - if (nativeValue instanceof Long) { - return (long) nativeValue; - } - if (lib.fitsInLong(nativeValue)) { - try { - return lib.asLong(nativeValue); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadFloatNode extends ReadFloatNode { - - @Specialization - static double doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction, - @CachedLibrary(limit = "1") InteropLibrary lib) { - - // note: C function 'graal_hpy_read_f' already returns a C double - Object nativeValue = callHelperFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_F, pointer, offset); - if (nativeValue instanceof Double d) { - return d; - } - if (lib.fitsInDouble(nativeValue)) { - try { - return lib.asDouble(nativeValue); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadDoubleNode extends ReadDoubleNode { - - @Specialization - static double doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction, - @CachedLibrary(limit = "1") InteropLibrary lib) { - - Object nativeValue = callHelperFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_D, pointer, offset); - if (nativeValue instanceof Double d) { - return d; - } - if (lib.fitsInDouble(nativeValue)) { - try { - return lib.asDouble(nativeValue); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadPointerNode extends ReadPointerNode { - - @Specialization - static Object doGeneric(GraalHPyContext ctx, Object pointer, long offset, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - return callHelperFunction.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_READ_PTR, pointer, offset); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMReadGenericNode extends ReadGenericNode { - - @Override - protected final int executeInt(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType size) { - Object object = execute(ctx, pointer, offset, size); - if (object instanceof Integer i) { - return i; - } else if (object instanceof Long l) { - return (int) (long) l; - } - return numberAsInt((Number) object); - } - - @Override - protected final long executeLong(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType size) { - Object object = execute(ctx, pointer, offset, size); - if (object instanceof Integer i) { - return (int) i; - } else if (object instanceof Long l) { - return l; - } - return numberAsLong((Number) object); - } - - @Specialization - static Object doGeneric(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType ctype, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - return callHelperFunction.call(inliningTarget, ctx, getReadAccessorName(ctx, ctype), pointer, offset); - } - - static GraalHPyNativeSymbol getReadAccessorName(GraalHPyContext ctx, HPyContextSignatureType type) { - switch (type) { - case Int8_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I8; - case Uint8_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UI8; - case Int16_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I16; - case Uint16_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UI16; - case Int32_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I32; - case Uint32_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UI32; - case Int64_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I64; - case Uint64_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UI64; - case Int: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I; - case Long: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_L; - case CFloat: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_F; - case CDouble: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_D; - case HPyContextPtr, VoidPtr, VoidPtrPtr, HPyPtr, ConstHPyPtr, Wchar_tPtr, ConstWchar_tPtr, CharPtr: - case ConstCharPtr, DataPtr, DataPtrPtr, Cpy_PyObjectPtr, HPyModuleDefPtr, HPyType_SpecPtr: - case HPyType_SpecParamPtr, HPyDefPtr, HPyFieldPtr, HPyGlobalPtr, HPyCapsule_DestructorPtr, PyType_SlotPtr: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_PTR; - case Bool: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_BOOL; - case UnsignedInt: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UI; - case UnsignedLong: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_UL; - case HPy_ssize_t: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_HPY_SSIZE_T; - } - int size = ctx.getCTypeSize(type); - switch (size) { - case 1: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I8; - case 2: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I16; - case 4: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I32; - case 8: - return GraalHPyNativeSymbol.GRAAL_HPY_READ_I64; - } - throw CompilerDirectives.shouldNotReachHere("invalid member type"); - } - - @TruffleBoundary - private int numberAsInt(Number number) { - return number.intValue(); - } - - @TruffleBoundary - private long numberAsLong(Number number) { - return number.longValue(); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteI32Node extends WriteI32Node { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, int value, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, GRAAL_HPY_WRITE_I32, basePointer, offset, value); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteI64Node extends WriteI64Node { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, long value, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, GRAAL_HPY_WRITE_I64, basePointer, offset, value); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteSizeTNode extends WriteSizeTNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, long value, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, GRAAL_HPY_WRITE_HPY_SSIZE_T, basePointer, offset, value); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteDoubleNode extends WriteDoubleNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, double value, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, GRAAL_HPY_WRITE_D, basePointer, offset, value); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteGenericNode extends WriteGenericNode { - - @Specialization(guards = {"type == cachedType"}, limit = "1") - static void doCached(GraalHPyContext ctx, Object pointer, long offset, @SuppressWarnings("unused") HPyContextSignatureType type, Object value, - @Bind("this") Node inliningTarget, - @Cached("type") HPyContextSignatureType cachedType, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, getWriteAccessor(ctx, cachedType), pointer, offset, value); - } - - @Specialization(replaces = "doCached") - static void doGeneric(GraalHPyContext ctx, Object pointer, long offset, HPyContextSignatureType type, Object value, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperFunction) { - callHelperFunction.call(inliningTarget, ctx, getWriteAccessor(ctx, type), pointer, offset, value); - } - - static GraalHPyNativeSymbol getWriteAccessor(GraalHPyContext ctx, HPyContextSignatureType type) { - switch (type) { - case Int8_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I8; - case Uint8_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UI8; - case Int16_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I16; - case Uint16_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UI16; - case Int32_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I32; - case Uint32_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UI32; - case Int64_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I64; - case Uint64_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UI64; - case Int: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I; - case Long: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_L; - case CFloat: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_F; - case CDouble: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_D; - case HPyContextPtr, VoidPtr, VoidPtrPtr, HPyPtr, ConstHPyPtr, Wchar_tPtr, ConstWchar_tPtr, CharPtr: - case ConstCharPtr, DataPtr, DataPtrPtr, Cpy_PyObjectPtr, HPyModuleDefPtr, HPyType_SpecPtr: - case HPyType_SpecParamPtr, HPyDefPtr, HPyFieldPtr, HPyGlobalPtr, HPyCapsule_DestructorPtr, PyType_SlotPtr: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_PTR; - case Bool: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_BOOL; - case UnsignedInt: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UI; - case UnsignedLong: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_UL; - case HPy_ssize_t: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_HPY_SSIZE_T; - } - int size = ctx.getCTypeSize(type); - switch (size) { - case 1: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I8; - case 2: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I16; - case 4: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I32; - case 8: - return GraalHPyNativeSymbol.GRAAL_HPY_WRITE_I64; - } - throw CompilerDirectives.shouldNotReachHere("invalid member type"); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteHPyNode extends WriteHPyNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, Object object, - @Bind("this") Node inliningTarget, - @Cached HPyAsHandleNode asHandleNode, - @Cached HPyLLVMCallHelperFunctionNode callWriteDataNode) { - callWriteDataNode.call(inliningTarget, ctx, GRAAL_HPY_WRITE_HPY, basePointer, offset, asHandleNode.execute(object)); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWriteHPyFieldNode extends WriteHPyFieldNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, PythonObject owner, Object pointer, long offset, Object referent, - @Bind("this") Node inliningTarget, - @Cached HPyFieldStoreNode fieldStoreNode, - @Cached HPyAsHandleNode asHandleNode, - @Cached HPyLLVMCallHelperFunctionNode callGetElementPtr, - @Cached HPyLLVMCallHelperFunctionNode callHelperFunctionNode) { - Object hpyFieldPtr = HPyLLVMGetElementPtrNode.doGeneric(ctx, pointer, offset, inliningTarget, callGetElementPtr); - Object hpyFieldObject = callHelperFunctionNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_GET_FIELD_I, hpyFieldPtr); - int idx = fieldStoreNode.execute(inliningTarget, owner, hpyFieldObject, referent); - GraalHPyHandle newHandle = asHandleNode.executeField(referent, idx); - callHelperFunctionNode.call(inliningTarget, ctx, GraalHPyNativeSymbol.GRAAL_HPY_SET_FIELD_I, hpyFieldPtr, newHandle); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMWritePointerNode extends WritePointerNode { - - @Specialization - static void doGeneric(GraalHPyContext ctx, Object basePointer, long offset, Object valuePointer, - @Bind("this") Node inliningTarget, - @Cached HPyLLVMCallHelperFunctionNode callWriteDataNode) { - callWriteDataNode.call(inliningTarget, ctx, GRAAL_HPY_WRITE_PTR, basePointer, offset, valuePointer); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMFromCharPointerNode extends HPyFromCharPointerNode { - - @Specialization - @SuppressWarnings("unused") - static TruffleString doCStringWrapper(GraalHPyContext hpyContext, CStringWrapper cStringWrapper, int n, Encoding encoding, boolean copy) { - return cStringWrapper.getString(); - } - - @Specialization - static TruffleString doCByteArrayWrapper(@SuppressWarnings("unused") GraalHPyContext hpyContext, CByteArrayWrapper cByteArrayWrapper, int n, Encoding encoding, boolean copy, - @Shared @Cached TruffleString.FromByteArrayNode fromByteArrayNode, - @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - CompilerAsserts.partialEvaluationConstant(encoding); - CompilerAsserts.partialEvaluationConstant(copy); - byte[] byteArray = cByteArrayWrapper.getByteArray(); - int length = n < 0 ? byteArray.length : n; - return switchEncodingNode.execute(fromByteArrayNode.execute(byteArray, 0, length, encoding, copy), TS_ENCODING); - } - - @Specialization(guards = {"!isCArrayWrapper(charPtr)", "isPointer(lib, charPtr)"}) - static TruffleString doPointer(GraalHPyContext hpyContext, Object charPtr, int n, Encoding encoding, boolean copy, - @Shared @CachedLibrary(limit = "2") InteropLibrary lib, - @Cached TruffleString.FromNativePointerNode fromNative, - @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - CompilerAsserts.partialEvaluationConstant(encoding); - CompilerAsserts.partialEvaluationConstant(copy); - long pointer; - try { - pointer = lib.asPointer(charPtr); - } catch (UnsupportedMessageException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - int length; - if (n < 0) { - length = 0; - /* - * We use 'PythonContext.getUnsafe()' here to ensure that native access is allowed - * because this specialization can be reached if 'charPtr' is not a CArrayWrapper - * but a pointer. An attacker could create a TruffleObject that answers - * 'isPointer()' with 'true' (but isn't really a native pointer). - */ - Unsafe unsafe = hpyContext.getContext().getUnsafe(); - while (unsafe.getByte(pointer + length) != 0) { - length++; - } - } else { - length = n; - } - return switchEncodingNode.execute(fromNative.execute(charPtr, 0, length, encoding, copy), TS_ENCODING); - } - - @Specialization(guards = {"!isCArrayWrapper(charPtr)", "!isPointer(lib, charPtr)"}) - static TruffleString doForeignArray(@SuppressWarnings("unused") GraalHPyContext hpyContext, Object charPtr, int n, Encoding encoding, @SuppressWarnings("unused") boolean copy, - @Shared @CachedLibrary(limit = "2") InteropLibrary lib, - @CachedLibrary(limit = "1") InteropLibrary elementLib, - @Bind("this") Node inliningTarget, - @Cached GraalHPyLLVMCallHelperFunctionNode callHelperFunctionNode, - @Cached GetByteArrayNode getByteArrayNode, - @Shared @Cached TruffleString.FromByteArrayNode fromByteArrayNode, - @Shared @Cached TruffleString.SwitchEncodingNode switchEncodingNode) { - CompilerAsserts.partialEvaluationConstant(encoding); - CompilerAsserts.partialEvaluationConstant(copy); - - Object typedCharPtr; - int length; - try { - if (!lib.hasArrayElements(charPtr)) { - /* - * If the foreign object does not have array elements, we assume it is an LLVM - * pointer where we can attach a type. We use size 'n' if available, otherwise - * we determine the size by looking for the zero-byte. - */ - int size = n < 0 ? Integer.MAX_VALUE : n; - typedCharPtr = callHelperFunctionNode.call(hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_FROM_I8_ARRAY, charPtr, size); - if (n < 0) { - length = 0; - while (elementLib.asByte(lib.readArrayElement(typedCharPtr, length)) != 0) { - length++; - } - } else { - length = n; - } - } else { - /* - * Simple case: the foreign object has array elements, so just use the array - * size and read the elements. - */ - typedCharPtr = charPtr; - length = n < 0 ? PInt.intValueExact(lib.getArraySize(charPtr)) : n; - } - assert lib.hasArrayElements(typedCharPtr); - assert length >= 0; - byte[] bytes = getByteArrayNode.execute(inliningTarget, typedCharPtr, length); - // since we created a fresh byte array, we don't need to copy it - return switchEncodingNode.execute(fromByteArrayNode.execute(bytes, 0, bytes.length, encoding, false), TS_ENCODING); - } catch (InteropException | OverflowException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } - } - - static boolean isCArrayWrapper(Object object) { - return object instanceof CArrayWrapper || object instanceof PySequenceArrayWrapper; - } - - static boolean isPointer(InteropLibrary lib, Object object) { - return lib.isPointer(object); - } - } - - @GenerateUncached - @GenerateInline(false) - abstract static class HPyLLVMAsCharPointerNode extends HPyAsCharPointerNode { - - @Specialization(guards = "isNativeAccessAllowed(hpyContext)") - static Object doNative(GraalHPyContext hpyContext, TruffleString string, Encoding encoding, - @Bind("this") Node inliningTarget, - @Exclusive @Cached HPyLLVMCallHelperFunctionNode callHelperNode, - @Exclusive @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Exclusive @Cached TruffleString.AsNativeNode asNativeNode, - @Exclusive @Cached TruffleString.GetInternalNativePointerNode getInternalNativePointerNode) { - TruffleString tsEncoded = switchEncodingNode.execute(string, encoding); - TruffleString tsNative = asNativeNode.execute(tsEncoded, byteSize -> callHelperNode.call(inliningTarget, hpyContext, GraalHPyNativeSymbol.GRAAL_HPY_CALLOC, byteSize, 1L), encoding, - false, true); - return getInternalNativePointerNode.execute(tsNative, encoding); - } - - @Specialization(replaces = "doNative") - static Object doGeneric(@SuppressWarnings("unused") GraalHPyContext hpyContext, TruffleString string, Encoding encoding, - @Exclusive @Cached TruffleString.SwitchEncodingNode switchEncodingNode, - @Exclusive @Cached TruffleString.GetInternalByteArrayNode getInternalByteArrayNode) { - TruffleString tsEncoded = switchEncodingNode.execute(string, encoding); - InternalByteArray internalByteArray = getInternalByteArrayNode.execute(tsEncoded, encoding); - return new CByteArrayWrapper(internalByteArray.getArray()); - - } - - static boolean isNativeAccessAllowed(GraalHPyContext hpyContext) { - return hpyContext.getContext().isNativeAccessAllowed(); - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyLLVMImportSymbolNode extends PNodeWithContext { - - public abstract Object execute(Node inliningTarget, GraalHPyContext hpyContext, GraalHPyNativeSymbol symbol); - - @Specialization(guards = {"isSingleContext()", "cachedSymbol == symbol"}, limit = "1") - static Object doSymbolCached(@SuppressWarnings("unused") GraalHPyContext nativeContext, @SuppressWarnings("unused") GraalHPyNativeSymbol symbol, - @SuppressWarnings("unused") @Cached("symbol") GraalHPyNativeSymbol cachedSymbol, - @Cached("getLLVMSymbol(nativeContext, symbol)") Object llvmSymbol) { - return llvmSymbol; - } - - @Specialization(replaces = "doSymbolCached") - static Object doGeneric(Node inliningTarget, GraalHPyContext hpyContext, GraalHPyNativeSymbol symbol, - @Cached InlinedExactClassProfile exactClassProfile) { - return getLLVMSymbol(exactClassProfile.profile(inliningTarget, hpyContext), symbol); - } - - static Object getLLVMSymbol(GraalHPyContext hpyContext, GraalHPyNativeSymbol symbol) { - if (hpyContext.getBackend() instanceof GraalHPyLLVMContext hpyLLVMContext) { - return hpyLLVMContext.getNativeSymbolCache()[symbol.ordinal()]; - } - throw CompilerDirectives.shouldNotReachHere(); - } - } - - @GenerateUncached - @GenerateInline - @GenerateCached(false) - public abstract static class HPyLLVMCallHelperFunctionNode extends PNodeWithContext { - - public static Object callUncached(GraalHPyContext context, GraalHPyNativeSymbol name, Object... args) { - return HPyLLVMCallHelperFunctionNodeGen.getUncached().execute(null, context, name, args); - } - - public final Object call(Node inliningTarget, GraalHPyContext context, GraalHPyNativeSymbol name, Object... args) { - return execute(inliningTarget, context, name, args); - } - - public abstract Object execute(Node inliningTarget, GraalHPyContext context, GraalHPyNativeSymbol name, Object[] args); - - @Specialization - static Object doIt(Node inliningTarget, GraalHPyContext context, GraalHPyNativeSymbol name, Object[] args, - @CachedLibrary(limit = "1") InteropLibrary interopLibrary, - @Cached HPyLLVMImportSymbolNode importCExtSymbolNode, - @Cached EnsureTruffleStringNode ensureTruffleStringNode, - @Cached PRaiseNode raiseNode) { - try { - Object llvmFunction = importCExtSymbolNode.execute(inliningTarget, context, name); - return ensureTruffleStringNode.execute(inliningTarget, interopLibrary.execute(llvmFunction, args)); - } catch (UnsupportedTypeException | ArityException e) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, e); - } catch (UnsupportedMessageException e) { - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.HPY_CAPI_SYM_NOT_CALLABLE, name); - } - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/HPyArrayWrappers.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/HPyArrayWrappers.java deleted file mode 100644 index 6fb73174d7..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/HPyArrayWrappers.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (c) 2020, 2024, 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.builtins.objects.cext.hpy.llvm; - -import java.util.Arrays; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyCloseHandleNode; -import com.oracle.graal.python.util.PythonUtils; -import com.oracle.truffle.api.CompilerAsserts; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.Cached.Exclusive; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.ImportStatic; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.InvalidArrayIndexException; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.interop.UnsupportedMessageException; -import com.oracle.truffle.api.interop.UnsupportedTypeException; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; -import com.oracle.truffle.api.nodes.ExplodeLoop; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.profiles.ConditionProfile; -import com.oracle.truffle.api.profiles.InlinedConditionProfile; -import com.oracle.truffle.llvm.spi.NativeTypeLibrary; - -abstract class HPyArrayWrappers { - - /** - * Wraps a sequence object (like a list) such that it behaves like a {@code HPy} array (C type - * {@code HPy *}). - */ - @ExportLibrary(InteropLibrary.class) - @ExportLibrary(value = NativeTypeLibrary.class, useForAOT = false) - static final class HPyArrayWrapper implements TruffleObject { - - private static final int UNINITIALIZED = 0; - private static final int INVALIDATED = -1; - - final GraalHPyContext hpyContext; - - final Object[] delegate; - - private final GraalHPyHandle[] wrappers; - private long nativePointer = UNINITIALIZED; - - public HPyArrayWrapper(GraalHPyContext hpyContext, Object[] delegate) { - this.hpyContext = hpyContext; - this.delegate = delegate; - this.wrappers = new GraalHPyHandle[delegate.length]; - } - - public Object[] getDelegate() { - return delegate; - } - - void setNativePointer(long nativePointer) { - assert nativePointer != UNINITIALIZED; - this.nativePointer = nativePointer; - } - - long getNativePointer() { - return this.nativePointer; - } - - @Override - public int hashCode() { - CompilerAsserts.neverPartOfCompilation(); - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(delegate); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - // n.b.: (tfel) This is hopefully fine here, since if we get to this - // code path, we don't speculate that either of those objects is - // constant anymore, so any caching on them won't happen anyway - return delegate == ((HPyArrayWrapper) obj).delegate; - } - - @SuppressWarnings("static-method") - @ExportMessage - boolean hasArrayElements() { - return true; - } - - @ExportMessage - long getArraySize() { - return delegate.length; - } - - @ExportMessage - boolean isArrayElementReadable(long index) { - return 0 <= index && index < delegate.length; - } - - @ExportMessage - Object readArrayElement(long index, - @Cached HPyAsHandleNode asHandleNode) throws InvalidArrayIndexException { - if (index < 0 || index > delegate.length) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw InvalidArrayIndexException.create(index); - } - int i = (int) index; - GraalHPyHandle wrapper = wrappers[i]; - if (wrapper == null) { - wrapper = asHandleNode.execute(delegate[i]); - wrappers[i] = wrapper; - } - return wrapper; - } - - @ExportMessage - boolean isPointer() { - return nativePointer != UNINITIALIZED; - } - - @ExportMessage - long asPointer() throws UnsupportedMessageException { - if (!isPointer()) { - CompilerDirectives.transferToInterpreterAndInvalidate(); - throw UnsupportedMessageException.create(); - } - return nativePointer; - } - - @ExportMessage - void toNative() { - if (!isPointer()) { - setNativePointer(hpyContext.createNativeArguments(delegate)); - } - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasNativeType() { - return hpyContext.getBackend() instanceof GraalHPyLLVMContext; - } - - @ExportMessage - Object getNativeType() { - if (hpyContext.getBackend() instanceof GraalHPyLLVMContext llvmContext) { - return llvmContext.getHPyArrayNativeType(); - } - throw CompilerDirectives.shouldNotReachHere(); - } - - void close() { - for (int i = 0; i < wrappers.length; i++) { - if (wrappers[i] != null) { - HPyCloseHandleNode.executeUncached(wrappers[i]); - wrappers[i] = null; - } - } - if (isPointer()) { - hpyContext.freeNativeArgumentsArray(delegate.length); - } - } - } - - @GenerateInline - @GenerateCached(false) - @ImportStatic(PythonUtils.class) - abstract static class HPyCloseArrayWrapperNode extends Node { - - public abstract void execute(Node inliningTarget, HPyArrayWrapper wrapper); - - @Specialization(guards = {"cachedLen == wrapper.delegate.length", "cachedLen <= 8"}, limit = "1") - @ExplodeLoop - static void doCachedLen(Node inliningTarget, HPyArrayWrapper wrapper, - @Cached("wrapper.delegate.length") int cachedLen, - @Exclusive @Cached HPyCloseHandleNode closeHandleNode, - @Cached(value = "createConditionProfiles(cachedLen)", dimensions = 1) ConditionProfile[] profiles, - @Exclusive @Cached InlinedConditionProfile isPointerProfile) { - for (int i = 0; i < cachedLen; i++) { - Object element = wrapper.delegate[i]; - if (profiles[i].profile(element instanceof GraalHPyHandle)) { - closeHandleNode.execute(inliningTarget, element); - } - } - if (isPointerProfile.profile(inliningTarget, wrapper.isPointer())) { - wrapper.hpyContext.freeNativeArgumentsArray(wrapper.delegate.length); - wrapper.setNativePointer(HPyArrayWrapper.INVALIDATED); - } - } - - @Specialization(replaces = "doCachedLen") - static void doLoop(Node inliningTarget, HPyArrayWrapper wrapper, - @Exclusive @Cached HPyCloseHandleNode closeHandleNode, - @Exclusive @Cached InlinedConditionProfile profile, - @Exclusive @Cached InlinedConditionProfile isPointerProfile) { - int n = wrapper.delegate.length; - for (int i = 0; i < n; i++) { - Object element = wrapper.delegate[i]; - if (profile.profile(inliningTarget, element instanceof GraalHPyHandle)) { - closeHandleNode.execute(inliningTarget, element); - } - } - if (isPointerProfile.profile(inliningTarget, wrapper.isPointer())) { - wrapper.hpyContext.freeNativeArgumentsArray(wrapper.delegate.length); - wrapper.setNativePointer(HPyArrayWrapper.INVALIDATED); - } - } - - } - - /** - * Wraps a sequence object (like a list) such that it behaves like a {@code HPy} array (C type - * {@code HPy *}). - */ - @ExportLibrary(InteropLibrary.class) - static final class IntArrayWrapper implements TruffleObject { - - final int[] delegate; - - public IntArrayWrapper(int[] delegate) { - this.delegate = delegate; - } - - public int[] getDelegate() { - return delegate; - } - - @SuppressWarnings("static-method") - @ExportMessage - boolean hasArrayElements() { - return true; - } - - @ExportMessage - long getArraySize() { - return delegate.length; - } - - @ExportMessage(name = "isArrayElementReadable") - @ExportMessage(name = "isArrayElementModifiable") - boolean isValidIndex(long index) { - return 0 <= index && index < delegate.length; - } - - @ExportMessage - boolean isArrayElementInsertable(@SuppressWarnings("unused") long index) { - return false; - } - - @ExportMessage - @TruffleBoundary - Object readArrayElement(long index) throws InvalidArrayIndexException { - return delegate[checkIndex(index)]; - } - - @ExportMessage - @TruffleBoundary - void writeArrayElement(long index, Object value, - @CachedLibrary(limit = "1") InteropLibrary lib) throws UnsupportedTypeException, InvalidArrayIndexException { - delegate[checkIndex(index)] = coerceToInt(value, lib); - } - - private int coerceToInt(Object value, InteropLibrary lib) throws UnsupportedTypeException { - if (value instanceof Integer i) { - return i; - } - if (lib.fitsInInt(value)) { - try { - return lib.asInt(value); - } catch (UnsupportedMessageException e) { - // fall through - } - } - throw UnsupportedTypeException.create(new Object[]{value}); - } - - private int checkIndex(long index) throws InvalidArrayIndexException { - if (index < 0 || index > delegate.length) { - throw InvalidArrayIndexException.create(index); - } - return (int) index; - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/NativeSpaceArrayWrapper.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/NativeSpaceArrayWrapper.java deleted file mode 100644 index ce9f1732f0..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/llvm/NativeSpaceArrayWrapper.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2020, 2023, 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.builtins.objects.cext.hpy.llvm; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext.GraalHPyHandleReference; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.interop.TruffleObject; -import com.oracle.truffle.api.library.ExportLibrary; -import com.oracle.truffle.api.library.ExportMessage; - -/** - * This class implements a simple interop array that has elements with following layout: - * - *
    - *     [nativeSpacePtr0, destroyFun0, nativeSpacePtr1, destroyFun1, ...]
    - * 
    - * - * So, each element at indices {@code i % 2 == 0} is a native space pointer and each element at - * indices {@code i % 2 == 1} is the corresponding pointer to a destroy function. On the C side, - * this should be use like this: - * - *
    - *     typedef void (*destroyfunc_t)(void *);
    - *     void bulk_cleanup(void *nativeSpaceArrayWrapper) {
    - *         int64_t n = polyglot_get_array_size(nativeSpaceArrayWrapper);
    - *         void *nativeSpacePtr;
    - *         destroyfunc_t destroyfunc;
    - *         for (int64_t i = 0; i < n; i += 2) {
    - *             nativeSpacePtr = nativeSpaceArrayWrapper[i];
    - *             destroyfunc = nativeSpaceArrayWrapper[i+1];
    - *             ... 
    - *         }
    - *     }
    - * 
    - */ -@ExportLibrary(InteropLibrary.class) -final class NativeSpaceArrayWrapper implements TruffleObject { - - final GraalHPyHandleReference[] data; - - public NativeSpaceArrayWrapper(GraalHPyHandleReference[] data) { - this.data = data; - } - - @ExportMessage - @SuppressWarnings("static-method") - boolean hasArrayElements() { - return true; - } - - @ExportMessage - long getArraySize() { - return data.length * 2L; - } - - @ExportMessage - boolean isArrayElementReadable(long i) { - return i < data.length * 2L; - } - - @ExportMessage - Object readArrayElement(long i) { - GraalHPyHandleReference ref = data[(int) i / 2]; - if (ref != null) { - if (i % 2 == 0) { - return ref.getNativeSpace(); - } else { - Object destroyFunc = ref.getDestroyFunc(); - return destroyFunc != null ? destroyFunc : GraalHPyHandle.NULL_HANDLE; - } - } - /* - * At this point, we need to return something that fulfills 'interopLib.isNull(obj)'. - * However, it MUST NOT be any 'PythonAbstractObject' because the interop messages could try - * to acquire the GIL. - */ - return GraalHPyHandle.NULL_HANDLE; - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java index f0e8f57138..8a5e350743 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingCollectionNodes.java @@ -256,7 +256,7 @@ static HashingStorage doHashingCollection(VirtualFrame frame, HashingStorage oth * Returns {@link HashingStorage} with the same keys as the given iterator. There is no * guarantee about the values! * - * @see DictNodes.GetDictStorageNode + * @see com.oracle.graal.python.builtins.objects.dict.DictNodes.GetDictStorageNode */ @GenerateInline(inlineByDefault = true) public abstract static class GetSetStorageNode extends PNodeWithContext { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java index a0383d1ea6..015d5a53f9 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java @@ -72,8 +72,6 @@ public class PythonObject extends PythonAbstractObject { private final Object initialPythonClass; - private Object[] hpyData; - @SuppressWarnings("this-escape") // escapes in the assertion public PythonObject(Object pythonClass, Shape instanceShape) { super(instanceShape); @@ -158,12 +156,4 @@ public String toString() { public static int getCallSiteInlineCacheMaxDepth() { return PythonOptions.getCallSiteInlineCacheMaxDepth(); } - - public final Object[] getHPyData() { - return hpyData; - } - - public final void setHPyData(Object[] hpyFields) { - this.hpyData = hpyFields; - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonClass.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonClass.java index b8db247479..755d654b9c 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonClass.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonClass.java @@ -32,8 +32,6 @@ import com.oracle.graal.python.PythonLanguage; import com.oracle.graal.python.builtins.objects.PNone; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyTypeExtra; import com.oracle.graal.python.builtins.objects.type.TypeNodes.GetSubclassesAsArrayNode; import com.oracle.graal.python.nodes.HiddenAttr; import com.oracle.graal.python.nodes.attributes.ReadAttributeFromPythonObjectNode; @@ -71,8 +69,6 @@ public final class PythonClass extends PythonManagedClass { private static final int MRO_SUBTYPES_MAX = 64; private static final int MRO_SHAPE_INVALIDATIONS_MAX = 5; - public HPyTypeExtra hPyTypeExtra; - private final AtomicReference slotsFinalAssumption = new AtomicReference<>(); private MroShape mroShape; // only set if there's no inheritance from native types /** @@ -382,59 +378,4 @@ static void updateMroShapeSubTypes(PythonBuiltinClass klass) { } } } - - public long getBasicSize() { - return hPyTypeExtra != null ? hPyTypeExtra.basicSize : -1; - } - - public long getItemSize() { - return hPyTypeExtra != null ? hPyTypeExtra.itemSize : -1; - } - - public Object getHPyDestroyFunc() { - if (hPyTypeExtra != null) { - return hPyTypeExtra.hpyDestroyFunc; - } - return null; - } - - public Object getTpName() { - return hPyTypeExtra != null ? hPyTypeExtra.tpName : null; - } - - public long getFlags() { - return hPyTypeExtra != null ? hPyTypeExtra.flags : 0; - } - - public int getBuiltinShape() { - return hPyTypeExtra != null ? hPyTypeExtra.builtinShape : GraalHPyDef.HPyType_BUILTIN_SHAPE_LEGACY; - } - - public Object getHPyDefaultCallFunc() { - return hPyTypeExtra != null ? hPyTypeExtra.defaultCallFunc : null; - } - - public long getHPyVectorcallOffset() { - return hPyTypeExtra != null ? hPyTypeExtra.vectorcallOffset : Long.MIN_VALUE; - } - - public void setHPyDestroyFunc(Object destroyFunc) { - hPyTypeExtra.hpyDestroyFunc = destroyFunc; - } - - public void setHPyDefaultCallFunc(Object defaultCallFunc) { - hPyTypeExtra.defaultCallFunc = defaultCallFunc; - } - - public void setHPyVectorcallOffset(int vectorcallOffset) { - hPyTypeExtra.vectorcallOffset = vectorcallOffset; - } - - public void setHPyTypeExtra(HPyTypeExtra hpyTypeExtra) { - this.hPyTypeExtra = hpyTypeExtra; - } - - public boolean isHPyType() { - return hPyTypeExtra != null; - } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java index a89a184141..1c666e55ae 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TpSlots.java @@ -164,8 +164,6 @@ import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.UnaryFuncWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.PythonClassNativeWrapper; import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.EnsureExecutableNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef.HPySlotWrapper; -import com.oracle.graal.python.builtins.objects.cext.hpy.HPyExternalFunctionNodes; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess.ReadPointerNode; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess.WritePointerNode; @@ -179,7 +177,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.TpSlot; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotHPyNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotManaged; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPython; @@ -1098,29 +1095,21 @@ public TpSlotGroup getGroup() { * @param wrapper {@code descrobject.h:wrapperbase#wrapper} */ public record TpSlotDef(TruffleString name, PythonFunctionFactory functionFactory, - PExternalFunctionWrapper wrapper, HPySlotWrapper hpyWrapper) { - public static TpSlotDef withoutHPy(TruffleString name, PythonFunctionFactory functionFactory, PExternalFunctionWrapper wrapper) { - return new TpSlotDef(name, functionFactory, wrapper, null); + PExternalFunctionWrapper wrapper) { + public static TpSlotDef create(TruffleString name, PythonFunctionFactory functionFactory, PExternalFunctionWrapper wrapper) { + return new TpSlotDef(name, functionFactory, wrapper); } public static TpSlotDef withSimpleFunction(TruffleString name, PExternalFunctionWrapper wrapper) { - return new TpSlotDef(name, SimplePythonWrapper.INSTANCE, wrapper, null); - } - - public static TpSlotDef withSimpleFunction(TruffleString name, PExternalFunctionWrapper wrapper, HPySlotWrapper hpyWrapper) { - return new TpSlotDef(name, SimplePythonWrapper.INSTANCE, wrapper, hpyWrapper); + return new TpSlotDef(name, SimplePythonWrapper.INSTANCE, wrapper); } public static TpSlotDef withNoFunctionNoWrapper(TruffleString name) { - return new TpSlotDef(name, null, null, null); + return new TpSlotDef(name, null, null); } public static TpSlotDef withNoFunction(TruffleString name, PExternalFunctionWrapper wrapper) { - return new TpSlotDef(name, null, wrapper, null); - } - - public static TpSlotDef withNoFunction(TruffleString name, PExternalFunctionWrapper wrapper, HPySlotWrapper hpyWrapper) { - return new TpSlotDef(name, null, wrapper, hpyWrapper); + return new TpSlotDef(name, null, wrapper); } } @@ -1148,22 +1137,22 @@ private static void addSlotDef(LinkedHashMap defs, TpSl TpSlotDef.withNoFunctionNoWrapper(T___DELATTR__)); addSlotDef(s, TpSlotMeta.TP_HASH, TpSlotDef.withSimpleFunction(T___HASH__, PExternalFunctionWrapper.HASHFUNC)); addSlotDef(s, TpSlotMeta.TP_GETATTRO, - TpSlotDef.withoutHPy(T___GETATTRIBUTE__, TpSlotGetAttrPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___GETATTR__, TpSlotGetAttrPython::create, null)); + TpSlotDef.create(T___GETATTRIBUTE__, TpSlotGetAttrPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___GETATTR__, TpSlotGetAttrPython::create, null)); addSlotDef(s, TpSlotMeta.TP_SETATTRO, - TpSlotDef.withoutHPy(T___SETATTR__, TpSlotSetAttrPython::create, PExternalFunctionWrapper.SETATTRO), - TpSlotDef.withoutHPy(T___DELATTR__, TpSlotSetAttrPython::create, PExternalFunctionWrapper.DELATTRO)); + TpSlotDef.create(T___SETATTR__, TpSlotSetAttrPython::create, PExternalFunctionWrapper.SETATTRO), + TpSlotDef.create(T___DELATTR__, TpSlotSetAttrPython::create, PExternalFunctionWrapper.DELATTRO)); addSlotDef(s, TpSlotMeta.TP_RICHCOMPARE, - TpSlotDef.withoutHPy(T___LT__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___LE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___EQ__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___NE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___GT__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), - TpSlotDef.withoutHPy(T___GE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC)); + TpSlotDef.create(T___LT__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___LE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___EQ__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___NE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___GT__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC), + TpSlotDef.create(T___GE__, TpSlotRichCmpPython::create, PExternalFunctionWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.TP_DESCR_GET, TpSlotDef.withSimpleFunction(T___GET__, PExternalFunctionWrapper.DESCR_GET)); addSlotDef(s, TpSlotMeta.TP_DESCR_SET, // - TpSlotDef.withoutHPy(T___SET__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_SET), // - TpSlotDef.withoutHPy(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE)); + TpSlotDef.create(T___SET__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_SET), // + TpSlotDef.create(T___DELETE__, TpSlotDescrSetPython::create, PExternalFunctionWrapper.DESCR_DELETE)); addSlotDef(s, TpSlotMeta.TP_ITER, TpSlotDef.withSimpleFunction(T___ITER__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.TP_ITERNEXT, TpSlotDef.withSimpleFunction(T___NEXT__, PExternalFunctionWrapper.ITERNEXT)); addSlotDef(s, TpSlotMeta.TP_STR, TpSlotDef.withSimpleFunction(T___STR__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1172,59 +1161,59 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.TP_NEW, TpSlotDef.withSimpleFunction(T___NEW__, PExternalFunctionWrapper.NEW)); addSlotDef(s, TpSlotMeta.TP_CALL, TpSlotDef.withSimpleFunction(T___CALL__, PExternalFunctionWrapper.CALL)); addSlotDef(s, TpSlotMeta.NB_ADD, - TpSlotDef.withoutHPy(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___ADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RADD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_SUBTRACT, - TpSlotDef.withoutHPy(T___SUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RSUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___SUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RSUB__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_MULTIPLY, - TpSlotDef.withoutHPy(T___MUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___MUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_REMAINDER, - TpSlotDef.withoutHPy(T___MOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___MOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_LSHIFT, - TpSlotDef.withoutHPy(T___LSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RLSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___LSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RLSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_RSHIFT, - TpSlotDef.withoutHPy(T___RSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RRSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___RSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RRSHIFT__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_AND, - TpSlotDef.withoutHPy(T___AND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RAND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___AND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RAND__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_XOR, - TpSlotDef.withoutHPy(T___XOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RXOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___XOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RXOR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_OR, - TpSlotDef.withoutHPy(T___OR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___ROR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___OR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___ROR__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_FLOOR_DIVIDE, - TpSlotDef.withoutHPy(T___FLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RFLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___FLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RFLOORDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_TRUE_DIVIDE, - TpSlotDef.withoutHPy(T___TRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RTRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___TRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RTRUEDIV__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_DIVMOD, - TpSlotDef.withoutHPy(T___DIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RDIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___DIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RDIVMOD__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_MATRIX_MULTIPLY, - TpSlotDef.withoutHPy(T___MATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), - TpSlotDef.withoutHPy(T___RMATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); + TpSlotDef.create(T___MATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_L), + TpSlotDef.create(T___RMATMUL__, TpSlotReversiblePython::create, PExternalFunctionWrapper.BINARYFUNC_R)); addSlotDef(s, TpSlotMeta.NB_POWER, - TpSlotDef.withoutHPy(T___POW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC), - TpSlotDef.withoutHPy(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_SUBTRACT, TpSlotDef.withSimpleFunction(T___ISUB__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_REMAINDER, TpSlotDef.withSimpleFunction(T___IMOD__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_LSHIFT, TpSlotDef.withSimpleFunction(T___ILSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_RSHIFT, TpSlotDef.withSimpleFunction(T___IRSHIFT__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_AND, TpSlotDef.withSimpleFunction(T___IAND__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_XOR, TpSlotDef.withSimpleFunction(T___IXOR__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_OR, TpSlotDef.withSimpleFunction(T___IOR__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE, TpSlotDef.withSimpleFunction(T___IFLOORDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_TRUE_DIVIDE, TpSlotDef.withSimpleFunction(T___ITRUEDIV__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMATMUL__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + TpSlotDef.create(T___POW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC), + TpSlotDef.create(T___RPOW__, TpSlotReversiblePython::create, PExternalFunctionWrapper.TERNARYFUNC_R)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_ADD, TpSlotDef.withSimpleFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_SUBTRACT, TpSlotDef.withSimpleFunction(T___ISUB__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMUL__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_REMAINDER, TpSlotDef.withSimpleFunction(T___IMOD__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_LSHIFT, TpSlotDef.withSimpleFunction(T___ILSHIFT__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_RSHIFT, TpSlotDef.withSimpleFunction(T___IRSHIFT__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_AND, TpSlotDef.withSimpleFunction(T___IAND__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_XOR, TpSlotDef.withSimpleFunction(T___IXOR__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_OR, TpSlotDef.withSimpleFunction(T___IOR__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_FLOOR_DIVIDE, TpSlotDef.withSimpleFunction(T___IFLOORDIV__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_TRUE_DIVIDE, TpSlotDef.withSimpleFunction(T___ITRUEDIV__, PExternalFunctionWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.NB_INPLACE_MATRIX_MULTIPLY, TpSlotDef.withSimpleFunction(T___IMATMUL__, PExternalFunctionWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INPLACE_POWER, TpSlotDef.withSimpleFunction(T___IPOW__, PExternalFunctionWrapper.TERNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_BOOL, TpSlotDef.withSimpleFunction(T___BOOL__, PExternalFunctionWrapper.INQUIRY)); addSlotDef(s, TpSlotMeta.NB_INDEX, TpSlotDef.withSimpleFunction(T___INDEX__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1234,26 +1223,26 @@ private static void addSlotDef(LinkedHashMap defs, TpSl addSlotDef(s, TpSlotMeta.NB_POSITIVE, TpSlotDef.withSimpleFunction(T___POS__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_NEGATIVE, TpSlotDef.withSimpleFunction(T___NEG__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.NB_INVERT, TpSlotDef.withSimpleFunction(T___INVERT__, PExternalFunctionWrapper.UNARYFUNC)); - addSlotDef(s, TpSlotMeta.MP_LENGTH, TpSlotDef.withSimpleFunction(T___LEN__, PExternalFunctionWrapper.LENFUNC, HPySlotWrapper.LENFUNC)); - addSlotDef(s, TpSlotMeta.MP_SUBSCRIPT, TpSlotDef.withSimpleFunction(T___GETITEM__, PExternalFunctionWrapper.BINARYFUNC, HPySlotWrapper.BINARYFUNC)); + addSlotDef(s, TpSlotMeta.MP_LENGTH, TpSlotDef.withSimpleFunction(T___LEN__, PExternalFunctionWrapper.LENFUNC)); + addSlotDef(s, TpSlotMeta.MP_SUBSCRIPT, TpSlotDef.withSimpleFunction(T___GETITEM__, PExternalFunctionWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.MP_ASS_SUBSCRIPT, - TpSlotDef.withoutHPy(T___SETITEM__, TpSlotMpAssSubscriptPython::create, PExternalFunctionWrapper.OBJOBJARGPROC), - TpSlotDef.withoutHPy(T___DELITEM__, TpSlotMpAssSubscriptPython::create, PExternalFunctionWrapper.MP_DELITEM)); - addSlotDef(s, TpSlotMeta.SQ_LENGTH, TpSlotDef.withSimpleFunction(T___LEN__, PExternalFunctionWrapper.LENFUNC, HPySlotWrapper.LENFUNC)); + TpSlotDef.create(T___SETITEM__, TpSlotMpAssSubscriptPython::create, PExternalFunctionWrapper.OBJOBJARGPROC), + TpSlotDef.create(T___DELITEM__, TpSlotMpAssSubscriptPython::create, PExternalFunctionWrapper.MP_DELITEM)); + addSlotDef(s, TpSlotMeta.SQ_LENGTH, TpSlotDef.withSimpleFunction(T___LEN__, PExternalFunctionWrapper.LENFUNC)); // sq_concat does not have a slotdef for __radd__ unlike sq_repeat. This have consequences // w.r.t. inheritance from native classes, where sq_repeat is not overridden by __mul__. // Makes one wonder whether this CPython behavior is intended. // see test_sq_repeat_mul_without_rmul_inheritance addSlotDef(s, TpSlotMeta.SQ_CONCAT, TpSlotDef.withNoFunction(T___ADD__, PExternalFunctionWrapper.BINARYFUNC)); addSlotDef(s, TpSlotMeta.SQ_REPEAT, - TpSlotDef.withNoFunction(T___MUL__, PExternalFunctionWrapper.SSIZE_ARG, HPySlotWrapper.INDEXARGFUNC), - TpSlotDef.withNoFunction(T___RMUL__, PExternalFunctionWrapper.SSIZE_ARG, HPySlotWrapper.INDEXARGFUNC)); - addSlotDef(s, TpSlotMeta.SQ_ITEM, TpSlotDef.withSimpleFunction(T___GETITEM__, PExternalFunctionWrapper.GETITEM, HPySlotWrapper.SQ_ITEM)); + TpSlotDef.withNoFunction(T___MUL__, PExternalFunctionWrapper.SSIZE_ARG), + TpSlotDef.withNoFunction(T___RMUL__, PExternalFunctionWrapper.SSIZE_ARG)); + addSlotDef(s, TpSlotMeta.SQ_ITEM, TpSlotDef.withSimpleFunction(T___GETITEM__, PExternalFunctionWrapper.GETITEM)); addSlotDef(s, TpSlotMeta.SQ_ASS_ITEM, - TpSlotDef.withoutHPy(T___SETITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.SETITEM), - TpSlotDef.withoutHPy(T___DELITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.DELITEM)); + TpSlotDef.create(T___SETITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.SETITEM), + TpSlotDef.create(T___DELITEM__, TpSlotSqAssItemPython::create, PExternalFunctionWrapper.DELITEM)); addSlotDef(s, TpSlotMeta.SQ_INPLACE_CONCAT, TpSlotDef.withNoFunction(T___IADD__, PExternalFunctionWrapper.BINARYFUNC)); - addSlotDef(s, TpSlotMeta.SQ_INPLACE_REPEAT, TpSlotDef.withNoFunction(T___IMUL__, PExternalFunctionWrapper.SSIZE_ARG, HPySlotWrapper.INDEXARGFUNC)); + addSlotDef(s, TpSlotMeta.SQ_INPLACE_REPEAT, TpSlotDef.withNoFunction(T___IMUL__, PExternalFunctionWrapper.SSIZE_ARG)); addSlotDef(s, TpSlotMeta.SQ_CONTAINS, TpSlotDef.withSimpleFunction(T___CONTAINS__, PExternalFunctionWrapper.OBJOBJPROC)); addSlotDef(s, TpSlotMeta.AM_AWAIT, TpSlotDef.withSimpleFunction(T___AWAIT__, PExternalFunctionWrapper.UNARYFUNC)); addSlotDef(s, TpSlotMeta.AM_ANEXT, TpSlotDef.withSimpleFunction(T___ANEXT__, PExternalFunctionWrapper.UNARYFUNC)); @@ -1733,55 +1722,6 @@ public static void addOperatorsToBuiltin(Python3Core core, PythonBuiltinClassTyp } } - /** - * Version of CPython's {@code add_operators} that assumes only native slots. This is useful for - * the HPy case where users cannot "steal" other type's slots or builtin slots. TODO: (GR-53923) - * extend this to support python/builtin slots, use it instead of PyTruffleType_AddSlot upcalls. - */ - @TruffleBoundary - public void addOperators(PythonClass type) { - // Current version assumes no dict and writes to the object directly - assert GetDictIfExistsNode.getUncached().execute(type) == null; - - PythonContext context = PythonContext.get(null); - PythonLanguage language = context.getLanguage(); - for (Entry slotDefEntry : SLOTDEFS.entrySet()) { - TpSlotMeta tpSlotMeta = slotDefEntry.getKey(); - for (TpSlotDef tpSlotDef : slotDefEntry.getValue()) { - if (tpSlotDef.wrapper == null) { - continue; - } - TpSlot value = tpSlotMeta.getValue(this); - if (value == null) { - continue; - } - Object existingValue = ReadAttributeFromObjectNode.getUncachedForceType().execute(type, tpSlotDef.name); - if (!PGuards.isNoValue(existingValue)) { - continue; - } - Object wrapperDescriptor = null; - if (value == TpSlotHashFun.HASH_NOT_IMPLEMENTED) { - wrapperDescriptor = PNone.NO_VALUE; - } else if (value instanceof TpSlotBuiltin builtinSlot) { - wrapperDescriptor = builtinSlot.createBuiltin(context, type, tpSlotDef.name, tpSlotDef.wrapper); - } else if (value instanceof TpSlotPython) { - // TODO: see CExtNodes$CreateFunctionNode - throw new IllegalStateException("addOperators: TpSlotPython not implemented yet"); - } else if (value instanceof TpSlotNative nativeSlot) { - if (nativeSlot instanceof TpSlotHPyNative hpySlot) { - wrapperDescriptor = HPyExternalFunctionNodes.createWrapperFunction(language, context.getHPyContext(), tpSlotDef.hpyWrapper, hpySlot, tpSlotDef.wrapper, tpSlotDef.name, - nativeSlot.getCallable(), type); - } else { - wrapperDescriptor = PExternalFunctionWrapper.createWrapperFunction(tpSlotDef.name, (TpSlotCExtNative) nativeSlot, type, tpSlotDef.wrapper, language); - } - } - assert wrapperDescriptor != null; - // TODO: optionally take TpDict and write into it if provided - WriteAttributeToPythonObjectNode.executeUncached(type, tpSlotDef.name, wrapperDescriptor); - } - } - } - public Builder copy() { var result = new Builder(); for (TpSlotMeta def : TpSlotMeta.VALUES) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java index 18bc0b4227..b6f8493d1e 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeNodes.java @@ -115,8 +115,6 @@ import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction; import com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory.PythonToNativeNodeGen; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyDef; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyObjectBuiltins.HPyObjectNewNode; import com.oracle.graal.python.builtins.objects.cext.structs.CFields; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; @@ -1456,7 +1454,7 @@ private static boolean extraivars(Object type, Object base, Object typeSlots) { DynamicObjectLibrary.getUncached()); Object baseNewMethod = LookupAttributeInMRONode.lookup(T___NEW__, GetMroStorageNode.executeUncached(base), ReadAttributeFromObjectNode.getUncached(), true, DynamicObjectLibrary.getUncached()); - return !HasSameConstructorNode.isSameFunction(typeNewMethod, baseNewMethod); + return typeNewMethod != baseNewMethod; } @TruffleBoundary @@ -1803,11 +1801,6 @@ public abstract static class IsAcceptableBaseNode extends Node { @Specialization static boolean doUserClass(PythonClass obj) { - // Special case for custom classes created via HPy: They are managed classes but can - // have custom flags. The flags may prohibit subtyping. - if (obj.isHPyType()) { - return (obj.getFlags() & GraalHPyDef.HPy_TPFLAGS_BASETYPE) != 0; - } return true; } @@ -2793,25 +2786,7 @@ static boolean doGeneric(Node inliningTarget, Object left, Object right, Object leftNew = leftNewProfile.profile(inliningTarget, lookupNew.execute(left, T___NEW__)); Object rightNew = rightNewProfile.profile(inliningTarget, lookupNew.execute(right, T___NEW__)); - return isSameFunction(leftNew, rightNew); - } - - static boolean isSameFunction(Object leftFunc, Object rightFunc) { - Object leftResolved = leftFunc; - if (leftFunc instanceof PBuiltinFunction builtinFunction) { - Object typeDecorated = HPyObjectNewNode.getDecoratedSuperConstructor(builtinFunction); - if (typeDecorated != null) { - leftResolved = typeDecorated; - } - } - Object rightResolved = rightFunc; - if (rightFunc instanceof PBuiltinFunction builtinFunction) { - Object baseDecorated = HPyObjectNewNode.getDecoratedSuperConstructor(builtinFunction); - if (baseDecorated != null) { - rightResolved = baseDecorated; - } - } - return leftResolved == rightResolved; + return leftNew == rightNew; } } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/HPyDispatchers.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/HPyDispatchers.java deleted file mode 100644 index 96fe528b10..0000000000 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/HPyDispatchers.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2024, 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.builtins.objects.type.slots; - -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.function.PArguments; -import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext; -import com.oracle.graal.python.runtime.IndirectCallData; -import com.oracle.graal.python.runtime.PythonContext; -import com.oracle.graal.python.runtime.PythonContext.PythonThreadState; -import com.oracle.truffle.api.CompilerDirectives; -import com.oracle.truffle.api.dsl.Cached; -import com.oracle.truffle.api.dsl.GenerateCached; -import com.oracle.truffle.api.dsl.GenerateInline; -import com.oracle.truffle.api.dsl.GenerateUncached; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.interop.InteropException; -import com.oracle.truffle.api.interop.InteropLibrary; -import com.oracle.truffle.api.library.CachedLibrary; -import com.oracle.truffle.api.nodes.Node; - -class HPyDispatchers { - private HPyDispatchers() { - } - - @GenerateInline - @GenerateUncached - @GenerateCached(false) - public abstract static class UnaryHPySlotDispatcherNode extends Node { - public abstract Object execute(VirtualFrame frame, Node inliningTarget, PythonContext ctx, PythonThreadState threadState, Object nativeSlotCallable, Object self); - - @Specialization - static Object doIt(VirtualFrame frame, PythonContext ctx, PythonThreadState threadState, Object nativeSlotCallable, Object self, - @Cached("createFor(this)") IndirectCallData callData, - @Cached(inline = false) HPyAsHandleNode toHandleNode, - @CachedLibrary(limit = "3") InteropLibrary lib) { - Object hpyCtx = ctx.getHPyContext().getBackend(); - Object state = IndirectCallContext.enter(frame, threadState, callData); - try { - return lib.execute(nativeSlotCallable, hpyCtx, toHandleNode.execute(self)); - } catch (InteropException e) { - throw CompilerDirectives.shouldNotReachHere(e); - } finally { - if (frame != null) { - PArguments.setException(frame, threadState.getCaughtException()); - } - IndirectCallContext.exit(frame, threadState, state); - } - } - } -} diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java index 16b6fccca7..69d19626d8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlot.java @@ -205,7 +205,7 @@ static TruffleWeakReference asWeakRef(Object value) { * stored determines the signature. On Java level we have to do a call with boxed arguments * array and cannot optimize for specific signature. */ - public abstract static sealed class TpSlotNative extends TpSlot permits TpSlotCExtNative, TpSlotHPyNative { + public abstract static sealed class TpSlotNative extends TpSlot permits TpSlotCExtNative { final Object callable; public TpSlotNative(Object callable) { @@ -216,10 +216,6 @@ public static TpSlotNative createCExtSlot(Object callable) { return new TpSlotCExtNative(callable); } - public static TpSlotNative createHPySlot(Object callable) { - return new TpSlotHPyNative(callable); - } - public final boolean isSameCallable(TpSlotNative other, InteropLibrary interop) { if (this == other || this.callable == other.callable) { return true; @@ -253,19 +249,6 @@ public TpSlotCExtNative(Object callable) { } } - /** - * HPy slots currently "pretend" to be Python magic methods. They are added to a newly - * constructed type in HPyCreateTypeFromSpecNode, which triggers {@code TpSlots#updateSlot} for - * every added slot. In the future HPy slots should be treated like native slots, except that - * they will have another dispatch method in CallXYZSlot nodes, see {@link TpSlotLen} for an - * example. - */ - public static final class TpSlotHPyNative extends TpSlotNative { - public TpSlotHPyNative(Object callable) { - super(callable); - } - } - /** * Represents a slot that should delegate to a builtin node. Outside of this package, builtin * slots are opaque. The leaf subclasses of this class are specific to concrete signature of diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java index 4bf7a3da19..a8234df965 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryFunc.java @@ -52,13 +52,10 @@ import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonTransferNode; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsPythonObjectNode; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.BinaryPythonSlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltinBase; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotHPyNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode; import com.oracle.graal.python.runtime.ExecutionContext.CallContext; @@ -161,22 +158,6 @@ static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNati return checkResultNode.execute(state, T_BINARY_SLOT, toPythonNode.execute(result)); } - @Specialization - @InliningCutoff - static Object callHPy(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative slot, Object self, Object index, - @Exclusive @Cached GetThreadStateNode getThreadStateNode, - @Cached(inline = false) HPyAsHandleNode selfToNativeNode, - @Cached(inline = false) HPyAsHandleNode indexToNativeNode, - @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Cached(inline = false) HPyAsPythonObjectNode toPythonNode, - @Exclusive @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { - PythonContext ctx = PythonContext.get(inliningTarget); - PythonThreadState threadState = getThreadStateNode.execute(inliningTarget, ctx); - Object result = externalInvokeNode.call(frame, inliningTarget, threadState, C_API_TIMING, T___GETITEM__, slot.callable, - ctx.getHPyContext().getBackend(), selfToNativeNode.execute(self), indexToNativeNode.execute(index)); - return checkResultNode.execute(threadState, T___GETITEM__, toPythonNode.execute(result)); - } - @Specialization(replaces = "callCachedBuiltin") @InliningCutoff static Object callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotBinaryFuncBuiltin slot, Object self, Object arg, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java index bbe5b1dc34..77453078c5 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotBinaryOp.java @@ -378,24 +378,6 @@ static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNati return checkResultNode.execute(state, op.name, toPythonNode.execute(result)); } - /*- TODO - @Specialization - @InliningCutoff - static Object callHPy(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative slot, Object self, Object index, - @Exclusive @Cached GetThreadStateNode getThreadStateNode, - @Cached(inline = false) HPyAsHandleNode selfToNativeNode, - @Cached(inline = false) HPyAsHandleNode indexToNativeNode, - @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Cached(inline = false) HPyAsPythonObjectNode toPythonNode, - @Exclusive @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { - PythonContext ctx = PythonContext.get(inliningTarget); - PythonThreadState threadState = getThreadStateNode.execute(inliningTarget, ctx); - Object result = externalInvokeNode.call(frame, inliningTarget, threadState, C_API_TIMING, T___GETITEM__, slot.callable, - ctx.getHPyContext().getBackend(), selfToNativeNode.execute(self), indexToNativeNode.execute(index)); - return checkResultNode.execute(threadState, T___GETITEM__, toPythonNode.execute(result)); - } - */ - @SuppressWarnings("unused") @Specialization(replaces = "callCachedBuiltin") @InliningCutoff diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java index eff42396a4..fecbade2e8 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotLen.java @@ -51,14 +51,11 @@ import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.PExternalFunctionWrapper; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.ints.PInt; -import com.oracle.graal.python.builtins.objects.type.slots.HPyDispatchers.UnaryHPySlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.UnaryPythonSlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltinBase; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotHPyNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; import com.oracle.graal.python.lib.PyNumberAsSizeNode; @@ -186,23 +183,6 @@ static int callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNative return (int) l; } - @Specialization - static int callHPy(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative slot, Object self, - @Exclusive @Cached GetThreadStateNode getThreadStateNode, - @Cached(inline = false) HPyAsHandleNode toNativeNode, - @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Exclusive @Cached PRaiseNode raiseNode, - @Exclusive @Cached(inline = false) CheckPrimitiveFunctionResultNode checkResultNode) { - PythonContext ctx = PythonContext.get(inliningTarget); - PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); - Object result = externalInvokeNode.call(frame, inliningTarget, state, C_API_TIMING, T___LEN__, slot.callable, ctx.getHPyContext().getBackend(), toNativeNode.execute(self)); - long l = checkResultNode.executeLong(state, T___LEN__, result); - if (!PInt.isIntRange(l)) { - raiseOverflow(inliningTarget, raiseNode, l); - } - return (int) l; - } - @InliningCutoff private static void raiseOverflow(Node inliningTarget, PRaiseNode raiseNode, long l) { throw raiseNode.raise(inliningTarget, OverflowError, ErrorMessages.CANNOT_FIT_P_INTO_INDEXSIZED_INT, l); @@ -223,24 +203,6 @@ static int callGenericComplexBuiltin(VirtualFrame frame, Node inliningTarget, Tp PArguments.setArgument(arguments, 0, self); return (int) BuiltinDispatchers.callGenericBuiltin(frame, inliningTarget, slot.callTargetIndex, arguments, callContext, isNullFrameProfile, indirectCallNode); } - - // @Specialization(guards = "slot.isHPySlot()") - // @InliningCutoff - @SuppressWarnings("unused") - static int callHPy(VirtualFrame frame, Node inliningTarget, TpSlotNative slot, Object self, - @Cached GetThreadStateNode getThreadStateNode, - @Cached UnaryHPySlotDispatcherNode hpyDispatcher, - @Cached PRaiseNode raiseNode, - @Cached(inline = false) CheckPrimitiveFunctionResultNode checkResultNode) { - PythonContext ctx = PythonContext.get(inliningTarget); - PythonThreadState state = getThreadStateNode.execute(inliningTarget, ctx); - Object result = hpyDispatcher.execute(frame, inliningTarget, ctx, state, slot.callable, self); - long l = checkResultNode.executeLong(state, T___LEN__, result); - if (!PInt.isIntRange(l)) { - raiseOverflow(inliningTarget, raiseNode, l); - } - return (int) l; - } } /** diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java index 21490870fd..976ccd20f1 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/slots/TpSlotSizeArgFun.java @@ -53,8 +53,6 @@ import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTiming; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonTransferNode; import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsHandleNode; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNodes.HPyAsPythonObjectNode; import com.oracle.graal.python.builtins.objects.function.PArguments; import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction; import com.oracle.graal.python.builtins.objects.type.TpSlots; @@ -63,7 +61,6 @@ import com.oracle.graal.python.builtins.objects.type.slots.PythonDispatchers.BinaryPythonSlotDispatcherNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotBuiltin; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotCExtNative; -import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotHPyNative; import com.oracle.graal.python.builtins.objects.type.slots.TpSlot.TpSlotPythonSingle; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.CallSlotLenNode; import com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFunFactory.FixNegativeIndexNodeGen; @@ -267,21 +264,6 @@ static Object callNative(VirtualFrame frame, Node inliningTarget, TpSlotCExtNati return checkResultNode.execute(threadState, T___GETITEM__, toPythonNode.execute(result)); } - @Specialization - @InliningCutoff - static Object callHPy(VirtualFrame frame, Node inliningTarget, TpSlotHPyNative slot, Object self, int index, - @Exclusive @Cached GetThreadStateNode getThreadStateNode, - @Cached(inline = false) HPyAsHandleNode toNativeNode, - @Exclusive @Cached ExternalFunctionInvokeNode externalInvokeNode, - @Cached(inline = false) HPyAsPythonObjectNode toPythonNode, - @Exclusive @Cached(inline = false) PyObjectCheckFunctionResultNode checkResultNode) { - PythonContext ctx = PythonContext.get(inliningTarget); - PythonThreadState threadState = getThreadStateNode.execute(inliningTarget, ctx); - Object result = externalInvokeNode.call(frame, inliningTarget, threadState, C_API_TIMING, T___GETITEM__, slot.callable, ctx.getHPyContext().getBackend(), toNativeNode.execute(self), - (long) index); - return checkResultNode.execute(threadState, T___GETITEM__, toPythonNode.execute(result)); - } - @Specialization(replaces = "callCachedBuiltin") @InliningCutoff static Object callGenericBuiltin(VirtualFrame frame, Node inliningTarget, TpSlotSizeArgFunBuiltin slot, Object self, int index, diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java index 56277c1399..7d85603e5d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java @@ -1435,64 +1435,10 @@ public abstract class ErrorMessages { public static final TruffleString NULL_ARG_INTERNAL = tsLiteral("null argument to internal routine"); - // HPy - - public static final TruffleString UNSUPPORTED_HYPMETH_SIG = tsLiteral("Unsupported HPyMeth signature"); - public static final TruffleString NULL_CHAR_PASSED = tsLiteral("NULL char * passed to HPyBytes_FromStringAndSize"); - public static final TruffleString CAPSULE_GETDESTRUCTOR_WITH_INVALID_CAPSULE = tsLiteral("HPyCapsule_GetDestructor called with invalid PyCapsule object"); - public static final TruffleString CAPSULE_GETPOINTER_WITH_INVALID_CAPSULE = tsLiteral("HPyCapsule_GetPointer called with invalid PyCapsule object"); - public static final TruffleString CAPSULE_GETCONTEXT_WITH_INVALID_CAPSULE = tsLiteral("HPyCapsule_GetContext called with invalid PyCapsule object"); - public static final TruffleString CAPSULE_GETNAME_WITH_INVALID_CAPSULE = tsLiteral("HPyCapsule_GetName called with invalid PyCapsule object"); - public static final TruffleString HPY_NEW_ARG_1_MUST_BE_A_TYPE = tsLiteral("HPy_New arg 1 must be a type"); - public static final TruffleString ERROR_LOADING_HPY_EXT_S_S = tsLiteral("Error during loading of the HPy extension module at path '%s'. Function HPyInit_'%s' returned NULL."); - public static final TruffleString HPY_CAPI_SYM_NOT_CALLABLE = tsLiteral("HPy C API symbol %s is not callable"); - public static final TruffleString HPY_CALLTUPLEDICT_REQUIRES_ARGS_TUPLE_OR_NULL = tsLiteral("HPy_CallTupleDict requires args to be a tuple or null handle"); - public static final TruffleString HPY_CALLTUPLEDICT_REQUIRES_KW_DICT_OR_NULL = tsLiteral("HPy_CallTupleDict requires kw to be a dict or null handle"); - public static final TruffleString CANNOT_INITIALIZE_EXT_NO_ENTRY = tsLiteral("cannot initialize extension '%s' at path '%s', entry point '%s' not found"); - public static final TruffleString HPY_S_MODE_NOT_AVAILABLE = tsLiteral("HPy %s mode is not available"); - public static final TruffleString HPY_UNEXPECTED_HPY_NULL = tsLiteral("unexpected HPy_NULL"); - public static final TruffleString HPY_MOD_CREATE_RETURNED_BUILTIN_MOD = tsLiteral("HPy_mod_create slot returned a builtin module object. This is currently not supported."); - public static final TruffleString HPYCAPSULE_NEW_NULL_PTR_ERROR = tsLiteral("HPyCapsule_New called with null pointer"); - public static final TruffleString INVALID_HPYCAPSULE_DESTRUCTOR = tsLiteral("Invalid HPyCapsule destructor"); - public static final TruffleString HPY_MODE_VALUE_MUST_BE_STRING = tsLiteral("Value of HPy mode environment variable must be a string"); - public static final TruffleString HPY_METACLASS_IS_NOT_A_TYPE = tsLiteral("Metaclass '%s' is not a subclass of 'type'."); - public static final TruffleString HPY_METACLASS_WITH_CUSTOM_CONS_NOT_SUPPORTED = tsLiteral("Metaclasses with custom constructor are not supported."); - public static final TruffleString HPY_ERROR_LOADING_EXT_MODULE = tsLiteral("Error during loading of the HPy extension module at path '%s'. " + - "Cannot locate the required minimal HPy versions as symbols '%s' and `%s`. Error message from dlopen/WinAPI: %s"); - public static final TruffleString HPY_ABI_VERSION_ERROR = tsLiteral("HPy extension module '%s' requires unsupported version of the HPy runtime. " + - "Requested version: %d.%d. Current HPy version: %d.%d."); - public static final TruffleString HPY_ABI_TAG_MISMATCH = tsLiteral("HPy extension module '%s' at path '%s': mismatch between the HPy ABI tag encoded in the filename " + - "and the major version requested by the HPy extension itself. Major version tag parsed from filename: %d. Requested version: %d.%d."); - public static final TruffleString HPY_NO_ABI_TAG = tsLiteral("HPy extension module '%s' at path '%s': could not find HPy ABI tag encoded in the filename. " + - "The extension claims to be compiled with HPy ABI version: %d.%d."); - public static final TruffleString HPY_INVALID_SOURCE_KIND = tsLiteral("invalid source kind"); - public static final TruffleString HPY_OBJECT_DOES_NOT_SUPPORT_CALL = tsLiteral("'%p' object does not support HPy call protocol"); - public static final TruffleString HPY_TYPE_DOES_NOT_IMPLEMENT_CALL_PROTOCOL = tsLiteral("type '%p' does not implement the HPy call protocol"); - public static final TruffleString HPY_METACLASS_SPECIFIED_MULTIPLE_TIMES = tsLiteral("metaclass was specified multiple times"); - public static final TruffleString HPY_INVALID_BUILTIN_SHAPE = tsLiteral("invalid shape: %d"); - public static final TruffleString HPY_CANNOT_USE_CALL_WITH_VAR_OBJECTS = tsLiteral("Cannot use HPy call protocol with var objects"); - public static final TruffleString HPY_CANNOT_HAVE_CALL_AND_VECTORCALLOFFSET = tsLiteral("Cannot have HPy_tp_call and explicit member '__vectorcalloffset__'. Specify just one of them."); - public static final TruffleString HPY_CANNOT_SPECIFY_LEG_SLOTS_WO_SETTING_LEG = tsLiteral("cannot specify .legacy_slots without setting .builtin_shape=HPyType_BuiltinShape_Legacy"); - public static final TruffleString HPY_CANNOT_USE_CALL_WITH_LEGACY = tsLiteral("Cannot use HPy call protocol with legacy types that inherit the struct. " + - "Either set the basicsize to a non-zero value or use legacy slot 'Py_tp_call'."); public static final TruffleString NFI_NOT_AVAILABLE = tsLiteral("GraalPy option '%s' is set to '%s, but the 'nfi' language, which is required for this feature, is not available. " + "If this is a GraalPy standalone distribution: this indicates internal error. If GraalPy was used as a Maven dependency: " + "are you missing a runtime dependency 'org.graalvm.truffle:truffle-nfi-libffi', which should be a dependency of 'org.graalvm.polyglot:python{-community}'?"); - public static final TruffleString LLVM_NOT_AVAILABLE = tsLiteral("GraalPy option 'NativeModules' is set to false, but the 'llvm' language, which is required for this feature, is not available. " + - "If this is a GraalPy standalone distribution: this indicates internal error. If GraalPy was used as a Maven dependency: are you missing a runtime dependency " + - "'org.graalvm.polyglot:llvm{-community}'?"); - public static final TruffleString HPY_CANNOT_USE_JNI_BACKEND = tsLiteral("Cannot use HPy JNI backend because JNI access is forbidden."); - public static final TruffleString HPY_NFI_NOT_YET_IMPLEMENTED = tsLiteral("HPy NFI backend is not yet implemented"); - public static final TruffleString HPY_UNKNOWN_BACKEND = tsLiteral("unknown HPy backend: "); - private static final String HPY_NON_DEFAULT_MESSAGE = "This is not allowed because custom HPy_mod_create slot cannot return a builtin module object and cannot make any use of any other " + - "data defined in the HPyModuleDef. Either do not define HPy_mod_create slot and let the runtime create a builtin module object from the provided HPyModuleDef, or do not " + - "define anything else but the HPy_mod_create slot."; - public static final TruffleString HPY_DEFINES_CREATE_AND_NON_DEFAULT = tsLiteral("HPyModuleDef defines a HPy_mod_create slot and some of the other fields are not set to their default value. " + - HPY_NON_DEFAULT_MESSAGE); - public static final TruffleString HPY_DEFINES_CREATE_AND_OTHER_SLOTS = tsLiteral("HPyModuleDef defines a HPy_mod_create slot and some other slots or methods. " + - HPY_NON_DEFAULT_MESSAGE); - // AST Validator public static final TruffleString ANN_ASSIGN_WITH_SIMPLE_NON_NAME_TARGET = tsLiteral("AnnAssign with simple non-Name target"); public static final TruffleString BOOL_OP_WITH_LESS_THAN_2_VALUES = tsLiteral("BoolOp with less than 2 values"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java index 30d9f320f9..6fc8c7bc92 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PGuards.java @@ -57,8 +57,6 @@ import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject; import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper; import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyHandle; -import com.oracle.graal.python.builtins.objects.cext.hpy.PythonHPyObject; import com.oracle.graal.python.builtins.objects.code.PCode; import com.oracle.graal.python.builtins.objects.common.EconomicMapStorage; import com.oracle.graal.python.builtins.objects.common.EmptyStorage; @@ -565,14 +563,6 @@ public static boolean isCDataObject(Object obj) { return obj instanceof CDataObject; } - public static boolean isHPyHandle(Object obj) { - return obj instanceof GraalHPyHandle; - } - - public static boolean isHPyObject(Object obj) { - return obj instanceof PythonHPyObject; - } - public static boolean expectBoolean(Object result) throws UnexpectedResultException { if (result instanceof Boolean) { return (Boolean) result; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java index 40fb5ff99b..4428a2fa2d 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/StringLiterals.java @@ -134,8 +134,6 @@ public abstract class StringLiterals { public static final TruffleString T_VERSION = tsLiteral("version"); public static final String J_DEFAULT = "default"; public static final TruffleString T_DEFAULT = tsLiteral(J_DEFAULT); - public static final String J_LLVM_LANGUAGE = "llvm"; - public static final TruffleString T_LLVM_LANGUAGE = tsLiteral(J_LLVM_LANGUAGE); public static final String J_NFI_LANGUAGE = "nfi"; public static final TruffleString T_ID = tsLiteral("id"); public static final TruffleString T_SITE = tsLiteral("site"); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java index a247e976ed..4405a4f3fe 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NFIPosixSupport.java @@ -44,7 +44,6 @@ import static com.oracle.graal.python.nodes.StringLiterals.J_DEFAULT; import static com.oracle.graal.python.nodes.StringLiterals.J_NATIVE; import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; -import static com.oracle.graal.python.nodes.StringLiterals.T_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_NATIVE; import static com.oracle.graal.python.runtime.NFIPosixConstants.OFFSETOF_STRUCT_IN6_ADDR_S6_ADDR; import static com.oracle.graal.python.runtime.NFIPosixConstants.OFFSETOF_STRUCT_IN_ADDR_S_ADDR; @@ -453,7 +452,7 @@ public InteropLibrary getResultInterop() { @CompilationFinal(dimensions = 1) private long[] constantValues; public NFIPosixSupport(PythonContext context, TruffleString nfiBackend) { - assert nfiBackend.equalsUncached(T_NATIVE, TS_ENCODING) || nfiBackend.equalsUncached(T_LLVM_LANGUAGE, TS_ENCODING); + assert nfiBackend.equalsUncached(T_NATIVE, TS_ENCODING); this.context = context; this.nfiBackend = nfiBackend; this.cachedFunctions = new AtomicReferenceArray<>(PosixNativeFunction.values().length); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NativeBufferContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NativeBufferContext.java index 46e7f44904..b66d11eba3 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NativeBufferContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/NativeBufferContext.java @@ -44,7 +44,7 @@ import java.util.concurrent.ConcurrentHashMap; import com.oracle.graal.python.PythonLanguage; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; +import com.oracle.graal.python.builtins.objects.cext.capi.CApiContext; import com.oracle.graal.python.runtime.native_memory.NativeBuffer; import com.oracle.graal.python.runtime.native_memory.NativePrimitiveReference; import com.oracle.graal.python.runtime.sequence.storage.NativeIntSequenceStorage; @@ -107,7 +107,7 @@ private ReferenceQueue getReferenceQueue() { } static final class NativeBufferDeallocatorRunnable extends PythonSystemThreadTask { - private static final TruffleLogger LOGGER = GraalHPyContext.getLogger(NativeBufferDeallocatorRunnable.class); + private static final TruffleLogger LOGGER = CApiContext.getLogger(NativeBufferDeallocatorRunnable.class); private final ReferenceQueue referenceQueue; private final ConcurrentHashMap references; diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java index d2ddcc3dc0..cbb8bd2d96 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java @@ -48,8 +48,6 @@ import static com.oracle.graal.python.nodes.StringLiterals.J_EXT_DYLIB; import static com.oracle.graal.python.nodes.StringLiterals.J_EXT_SO; import static com.oracle.graal.python.nodes.StringLiterals.J_LIB_PREFIX; -import static com.oracle.graal.python.nodes.StringLiterals.J_LLVM_LANGUAGE; -import static com.oracle.graal.python.nodes.StringLiterals.J_NATIVE; import static com.oracle.graal.python.nodes.StringLiterals.J_NFI_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_DASH; import static com.oracle.graal.python.nodes.StringLiterals.T_DOT; @@ -57,7 +55,6 @@ import static com.oracle.graal.python.nodes.StringLiterals.T_EXT_PYD; import static com.oracle.graal.python.nodes.StringLiterals.T_EXT_SO; import static com.oracle.graal.python.nodes.StringLiterals.T_JAVA; -import static com.oracle.graal.python.nodes.StringLiterals.T_LLVM_LANGUAGE; import static com.oracle.graal.python.nodes.StringLiterals.T_NATIVE; import static com.oracle.graal.python.nodes.StringLiterals.T_PATH; import static com.oracle.graal.python.nodes.StringLiterals.T_SITE; @@ -118,7 +115,6 @@ import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.HandleContext; import com.oracle.graal.python.builtins.objects.cext.common.LoadCExtException.ApiInitException; import com.oracle.graal.python.builtins.objects.cext.common.NativePointer; -import com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyContext; import com.oracle.graal.python.builtins.objects.cext.structs.CStructAccess; import com.oracle.graal.python.builtins.objects.common.HashingStorage; import com.oracle.graal.python.builtins.objects.common.HashingStorageNodes.HashingStorageGetItem; @@ -244,8 +240,6 @@ public static String getSupportLibName(String libName) { return getSupportLibName(getPythonOS(), libName); } - public static final String J_PYTHON_JNI_LIBRARY_NAME = System.getProperty("python.jni.library", getSupportLibName("pythonjni")); - /** * An enum of events which can currently be traced using python's tracing */ @@ -794,7 +788,6 @@ PythonThreadState getThreadState(Node n) { private static final String J_NO_CORE_WARNING = "could not determine Graal.Python's core path - you may need to pass --python.CoreHome."; private static final String J_NO_STDLIB = "could not determine Graal.Python's standard library path. You need to pass --python.StdLibHome if you want to use the standard library."; private static final String J_NO_CAPI = "could not determine Graal.Python's C API library path. You need to pass --python.CAPI if you want to use the C extension modules."; - private static final String J_NO_JNI = "could not determine Graal.Python's JNI library. You need to pass --python.JNILibrary if you want to run, for example, binary HPy extension modules."; private PythonModule mainModule; private final List shutdownHooks = new ArrayList<>(); @@ -836,7 +829,6 @@ PythonThreadState getThreadState(Node n) { private OutputStream err; private InputStream in; @CompilationFinal private CApiContext cApiContext; - @CompilationFinal private GraalHPyContext hPyContext; @CompilationFinal private boolean nativeAccessAllowed; private TruffleString soABI; // cache for soAPI @@ -1358,7 +1350,7 @@ public long spawnTruffleContext(int fd, int sentinel, int[] fdsToKeep) { forceSharing(getOption(PythonOptions.ForceSharingForInnerContexts)).// inheritAllAccess(true).// initializeCreatorContext(true).// - option("python.NativeModules", "false").// + option("python.IsolateNativeModules", "true").// // TODO always force java posix in spawned: test_multiprocessing_spawn fails // with that. Gives "OSError: [Errno 9] Bad file number" // option("python.PosixModuleBackend", "java").// @@ -1848,7 +1840,7 @@ private void initializePosixSupport() { "switching to Java backend."); } result = new EmulatedPosixSupport(this); - } else if (eqNode.execute(T_NATIVE, option, TS_ENCODING) || eqNode.execute(T_LLVM_LANGUAGE, option, TS_ENCODING)) { + } else if (eqNode.execute(T_NATIVE, option, TS_ENCODING)) { if (env.isPreInitialization()) { EmulatedPosixSupport emulatedPosixSupport = new EmulatedPosixSupport(this); NFIPosixSupport nativePosixSupport = new NFIPosixSupport(this, option); @@ -1877,13 +1869,12 @@ private void initializePosixSupport() { } } - private TruffleString langHome, sysPrefix, basePrefix, coreHome, capiHome, jniHome, stdLibHome; + private TruffleString langHome, sysPrefix, basePrefix, coreHome, capiHome, stdLibHome; public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { if (env.isPreInitialization()) { - // during pre-initialization we do not need these paths to be valid, since all boot - // files are frozen - basePrefix = sysPrefix = langHome = coreHome = stdLibHome = capiHome = jniHome = T_DOT; + // at buildtime we do not need these paths to be valid, since all boot files are frozen + basePrefix = sysPrefix = langHome = coreHome = stdLibHome = capiHome = T_DOT; return; } @@ -1929,7 +1920,6 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { coreHome = newEnv.getOptions().get(PythonOptions.CoreHome); stdLibHome = newEnv.getOptions().get(PythonOptions.StdLibHome); capiHome = newEnv.getOptions().get(PythonOptions.CAPI); - jniHome = newEnv.getOptions().get(PythonOptions.JNIHome); final TruffleFile homeCandidate = (TruffleFile) homeCandidateSupplier.get(); if (homeCandidate == null) { continue; @@ -1943,8 +1933,7 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { "\n\tCoreHome: {3}" + "\n\tStdLibHome: {4}" + "\n\tCAPI: {5}" + - "\n\tJNI library: {6}" + - "\n\tHome candidate: {7}", languageHome, sysPrefix, basePrefix, coreHome, stdLibHome, capiHome, jniHome, homeCandidate.toString())); + "\n\tHome candidate: {6}", languageHome, sysPrefix, basePrefix, coreHome, stdLibHome, capiHome, homeCandidate.toString())); langHome = toTruffleStringUncached(homeCandidate.toString()); TruffleString prefix = toTruffleStringUncached(homeCandidate.getAbsoluteFile().getPath()); @@ -2012,10 +2001,6 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { capiHome = coreHome; } - if (jniHome.isEmpty()) { - jniHome = coreHome; - } - if (homeSeemsValid) { break; } @@ -2028,9 +2013,7 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) { "\n\tCoreHome: {3}" + "\n\tStdLibHome: {4}" + "\n\tExecutable: {5}" + - "\n\tCAPI: {6}" + - "\n\tJNI library: {7}", langHome, sysPrefix, basePrefix, coreHome, stdLibHome, newEnv.getOptions().get(PythonOptions.Executable), capiHome, - jniHome)); + "\n\tCAPI: {6}", langHome, sysPrefix, basePrefix, coreHome, stdLibHome, newEnv.getOptions().get(PythonOptions.Executable), capiHome)); } @TruffleBoundary @@ -2093,15 +2076,6 @@ public TruffleString getCAPIHome() { return capiHome; } - @TruffleBoundary - public TruffleString getJNIHome() { - if (jniHome.isEmpty()) { - writeWarning(J_NO_JNI); - return jniHome; - } - return jniHome; - } - private static void writeWarning(String warning) { LOGGER.warning(warning); } @@ -2159,7 +2133,6 @@ public void finalizeContext() { } // interrupt and join or kill system threads joinSystemThreads(); - cleanupHPyResources(); for (int fd : getChildContextFDs()) { if (!getSharedMultiprocessingData().decrementFDRefCount(fd)) { getSharedMultiprocessingData().closePipe(fd); @@ -2244,12 +2217,6 @@ private void disposeThreadStates() { threadStateMapping.clear(); } - private void cleanupHPyResources() { - if (hPyContext != null) { - hPyContext.finalizeContext(); - } - } - /** * This method is the equivalent to {@code pylifecycle.c: wait_for_thread_shutdown} and calls * {@code threading._shutdown} (if the threading module was loaded) to tear down all threads @@ -2745,34 +2712,6 @@ public void runCApiHooks() { capiHooks.clear(); } - public boolean hasHPyContext() { - return hPyContext != null; - } - - public synchronized GraalHPyContext createHPyContext(Object hpyLibrary) throws ApiInitException { - assert hPyContext == null : "tried to create new HPy context but it was already created"; - GraalHPyContext hpyContext = new GraalHPyContext(this, hpyLibrary); - this.hPyContext = hpyContext; - return hpyContext; - } - - public GraalHPyContext getHPyContext() { - assert hPyContext != null : "tried to get HPy context but was not created yet"; - return hPyContext; - } - - /** - * Equivalent of {@code debug_ctx.c: hpy_debug_init_ctx}. - */ - @TruffleBoundary - private Object initDebugMode() { - if (!hasHPyContext()) { - throw CompilerDirectives.shouldNotReachHere("cannot initialize HPy debug context without HPy universal context"); - } - // TODO: call 'hpy_debug_init_ctx' - throw CompilerDirectives.shouldNotReachHere("not yet implemented"); - } - public GCState getGcState() { return gcState; } @@ -2805,26 +2744,12 @@ public long getDeserializationId(TruffleString fileName) { return deserializationId.computeIfAbsent(fileName, f -> new AtomicLong()).incrementAndGet(); } - public void ensureLLVMLanguage(Node nodeForRaise) { - if (!env.getInternalLanguages().containsKey(J_LLVM_LANGUAGE)) { - throw PRaiseNode.raiseStatic(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.LLVM_NOT_AVAILABLE); - } - } - public void ensureNFILanguage(Node nodeForRaise, String optionName, String optionValue) { if (!env.getInternalLanguages().containsKey(J_NFI_LANGUAGE)) { throw PRaiseNode.raiseStatic(nodeForRaise, PythonBuiltinClassType.SystemError, ErrorMessages.NFI_NOT_AVAILABLE, optionName, optionValue); } } - @TruffleBoundary - public String getLLVMSupportExt(String libName) { - if (!getOption(PythonOptions.NativeModules)) { - ensureLLVMLanguage(null); - } - return PythonContext.getSupportLibName(libName + '-' + J_NATIVE); - } - @TruffleBoundary public TruffleString getSoAbi() { if (soABI == null) { diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonImageBuildOptions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonImageBuildOptions.java index 31c1bb4324..4917a377da 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonImageBuildOptions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonImageBuildOptions.java @@ -76,10 +76,6 @@ public final class PythonImageBuildOptions { * This property can be used to exclude socket and inet support from the Java posix backend. */ public static final boolean WITHOUT_JAVA_INET = Boolean.getBoolean("python.WithoutJavaInet"); - /** - * This property can be used to disable any usage of JNI. - */ - public static final boolean WITHOUT_JNI = Boolean.getBoolean("python.WithoutJNI"); private PythonImageBuildOptions() { } diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java index 01225837a6..1d0633c4af 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonOptions.java @@ -88,21 +88,6 @@ public final class PythonOptions { * bytecode interpreter. */ public static final boolean ENABLE_BYTECODE_DSL_INTERPRETER = Boolean.getBoolean("python.EnableBytecodeDSLInterpreter"); - - public enum HPyBackendMode { - NFI, - JNI, - LLVM - } - - static final OptionType HPY_BACKEND_TYPE = new OptionType<>("HPyBackend", s -> { - try { - return HPyBackendMode.valueOf(s.toUpperCase()); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Backend can be one of: " + Arrays.toString(HPyBackendMode.values())); - } - }); - private static final OptionType TS_OPTION_TYPE = new OptionType<>("graal.python.TruffleString", PythonUtils::toTruffleStringUncached); private PythonOptions() { @@ -250,20 +235,6 @@ private PythonOptions() { @EngineOption @Option(category = OptionCategory.INTERNAL, usageSyntax = "true|false", help = "Enable catching all Exceptions in generic try-catch statements.") // public static final OptionKey CatchAllExceptions = new OptionKey<>(false); - @EngineOption @Option(category = OptionCategory.INTERNAL, help = "Choose the backend for HPy binary mode.", usageSyntax = "jni|nfi|llvm", stability = OptionStability.EXPERIMENTAL) // - public static final OptionKey HPyBackend = new OptionKey<>(HPyBackendMode.JNI, HPY_BACKEND_TYPE); - - @EngineOption @Option(category = OptionCategory.INTERNAL, usageSyntax = "true|false", help = "If {@code true}, code is enabled that tries to reduce expensive upcalls into the runtime" + - "when HPy API functions are used. This is achieved by mirroring data in native memory.", stability = OptionStability.EXPERIMENTAL) // - public static final OptionKey HPyEnableJNIFastPaths = new OptionKey<>(true); - - @EngineOption @Option(category = OptionCategory.INTERNAL, usageSyntax = "